Skip to content

Commit

Permalink
[docbuilder] fix broken docbuilder stories (#231)
Browse files Browse the repository at this point in the history
Co-authored-by: Rohan Bansal <[email protected]>
  • Loading branch information
Alchez and Rohan Bansal authored Jan 3, 2025
1 parent ba7b8d8 commit 6eb9aa7
Show file tree
Hide file tree
Showing 21 changed files with 293 additions and 96 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@stonecrop/desktop",
"comment": "fix broken docbuilder stories",
"type": "patch"
}
],
"packageName": "@stonecrop/desktop"
}
26 changes: 26 additions & 0 deletions common/reviews/api/desktop.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,38 @@ import { Plugin as Plugin_2 } from 'vue';
import Records from './components/Records.vue';
import SheetNav from './components/SheetNav.vue';

// @public
export type ActionElements = ButtonElement | DropdownElement;

export { ActionSet }

// @public
export type BaseElement = {
label: string;
show?: boolean;
};

// @public
export type ButtonElement = BaseElement & ElementAction & {
type: 'button';
};

export { CommandPalette }

export { Doctype }

// @public
export type DropdownElement = BaseElement & {
type: 'dropdown';
actions: ElementAction[];
};

// @public
export type ElementAction = BaseElement & {
link?: string;
action?: () => void;
};

export { Records }

export { SheetNav }
Expand Down
23 changes: 5 additions & 18 deletions desktop/src/components/ActionSet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
</div>
<div style="margin-right: 30px"></div>
<div class="action-element" v-for="(el, index) in _elements" :key="el.label">
<button v-if="el.elementType == 'button'" :onclick="el.action" class="button-default">{{ el.label }}</button>
<div v-if="el.elementType == 'dropdown'">
<button v-if="el.type == 'button'" :onclick="el.action" class="button-default">{{ el.label }}</button>
<div v-if="el.type == 'dropdown'">
<button class="button-default" @click="toggleDropdown(index)">{{ el.label }}</button>
<div class="dropdown-container" v-show="el.show">
<div class="dropdown">
Expand All @@ -60,22 +60,9 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
type SetAction = {
label: string
link?: string
action?: () => void
}
type SetElement = {
elementType: string
label: string
link?: string
show?: boolean
action?: () => void
actions?: SetAction[]
}
import type { ActionElements } from '../types'
const { elements } = defineProps<{ elements?: SetElement[] }>()
const { elements } = defineProps<{ elements?: ActionElements[] }>()
const _elements = ref(elements)
const isOpen = ref(false)
Expand All @@ -89,7 +76,7 @@ onMounted(() => {
const closeDropdowns = () => {
for (const element of _elements.value) {
if (element.elementType === 'dropdown') {
if (element.type === 'dropdown') {
element.show = false
}
}
Expand Down
1 change: 1 addition & 0 deletions desktop/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import Doctype from './components/Doctype.vue'
import Records from './components/Records.vue'
import SheetNav from './components/SheetNav.vue'
import StonecropDesktop from './plugins'
export type { ActionElements, BaseElement, ButtonElement, DropdownElement, ElementAction } from './types'

export { ActionSet, CommandPalette, Doctype, Records, SheetNav, StonecropDesktop }
3 changes: 1 addition & 2 deletions desktop/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import Records from '../components/Records.vue'
import SheetNav from '../components/SheetNav.vue'

/**
* This is the main plugin file that will be used to register all the components
* that we want to use in our application.
* This is the main plugin that will be used to register all the desktop components.
* @public
*/
const plugin: Plugin = {
Expand Down
41 changes: 41 additions & 0 deletions desktop/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Base type for elements in the Action Set
* @public
*/
export type BaseElement = {
label: string
show?: boolean
}

/**
* Element actions
* @public
*/
export type ElementAction = BaseElement & {
link?: string
action?: () => void
}

/**
* Button elements
* @public
*/
export type ButtonElement = BaseElement &
ElementAction & {
type: 'button'
}

/**
* Dropdown elements
* @public
*/
export type DropdownElement = BaseElement & {
type: 'dropdown'
actions: ElementAction[]
}

/**
* Superset of all element types in the Action Set
* @public
*/
export type ActionElements = ButtonElement | DropdownElement
15 changes: 15 additions & 0 deletions docs/desktop/desktop.actionelements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@stonecrop/desktop](./desktop.md) &gt; [ActionElements](./desktop.actionelements.md)

## ActionElements type

Superset of all element types in the Action Set

**Signature:**

```typescript
export type ActionElements = ButtonElement | DropdownElement;
```
**References:** [ButtonElement](./desktop.buttonelement.md)<!-- -->, [DropdownElement](./desktop.dropdownelement.md)

16 changes: 16 additions & 0 deletions docs/desktop/desktop.baseelement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@stonecrop/desktop](./desktop.md) &gt; [BaseElement](./desktop.baseelement.md)

## BaseElement type

Base type for elements in the Action Set

**Signature:**

```typescript
export type BaseElement = {
label: string;
show?: boolean;
};
```
17 changes: 17 additions & 0 deletions docs/desktop/desktop.buttonelement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@stonecrop/desktop](./desktop.md) &gt; [ButtonElement](./desktop.buttonelement.md)

## ButtonElement type

Button elements

**Signature:**

```typescript
export type ButtonElement = BaseElement & ElementAction & {
type: 'button';
};
```
**References:** [BaseElement](./desktop.baseelement.md)<!-- -->, [ElementAction](./desktop.elementaction.md)

18 changes: 18 additions & 0 deletions docs/desktop/desktop.dropdownelement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@stonecrop/desktop](./desktop.md) &gt; [DropdownElement](./desktop.dropdownelement.md)

## DropdownElement type

Dropdown elements

**Signature:**

```typescript
export type DropdownElement = BaseElement & {
type: 'dropdown';
actions: ElementAction[];
};
```
**References:** [BaseElement](./desktop.baseelement.md)<!-- -->, [ElementAction](./desktop.elementaction.md)

18 changes: 18 additions & 0 deletions docs/desktop/desktop.elementaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@stonecrop/desktop](./desktop.md) &gt; [ElementAction](./desktop.elementaction.md)

## ElementAction type

Element actions

**Signature:**

```typescript
export type ElementAction = BaseElement & {
link?: string;
action?: () => void;
};
```
**References:** [BaseElement](./desktop.baseelement.md)

72 changes: 71 additions & 1 deletion docs/desktop/desktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,77 @@ Description

</td><td>

This is the main plugin file that will be used to register all the components that we want to use in our application.
This is the main plugin that will be used to register all the desktop components.


</td></tr>
</tbody></table>

## Type Aliases

<table><thead><tr><th>

Type Alias


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[ActionElements](./desktop.actionelements.md)


</td><td>

Superset of all element types in the Action Set


</td></tr>
<tr><td>

[BaseElement](./desktop.baseelement.md)


</td><td>

Base type for elements in the Action Set


</td></tr>
<tr><td>

[ButtonElement](./desktop.buttonelement.md)


</td><td>

Button elements


</td></tr>
<tr><td>

[DropdownElement](./desktop.dropdownelement.md)


</td><td>

Dropdown elements


</td></tr>
<tr><td>

[ElementAction](./desktop.elementaction.md)


</td><td>

Element actions


</td></tr>
Expand Down
2 changes: 1 addition & 1 deletion docs/desktop/desktop.stonecropdesktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## StonecropDesktop variable

This is the main plugin file that will be used to register all the components that we want to use in our application.
This is the main plugin that will be used to register all the desktop components.

**Signature:**

Expand Down
6 changes: 3 additions & 3 deletions examples/desktop/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<script setup lang="ts">
const elements = [
{
elementType: 'button',
type: 'button',
label: 'Show Alert',
action: buttonClicked,
},
{
elementType: 'dropdown',
type: 'dropdown',
label: 'Action Menu',
actions: [
{
Expand All @@ -38,7 +38,7 @@ const elements = [
],
},
{
elementType: 'dropdown',
type: 'dropdown',
label: 'Link Menu',
actions: [
{
Expand Down
10 changes: 5 additions & 5 deletions examples/docbuilder/assets/doctype_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"fieldtype": "Data",
"align": "left",
"edit": false,
"width": "35ch"
"width": "25ch"
},
{
"label": "Fieldtype",
"name": "fieldtype",
"fieldtype": "Select",
"align": "left",
"width": "20ch",
"width": "25ch",
"edit": true
},
{
Expand All @@ -47,15 +47,15 @@
"component": "<input type=\"radio\"/>",
"align": "left",
"edit": true,
"width": "5ch"
"width": "10ch"
},
{
"label": "Read Only",
"name": "read_only",
"component": "<input type=\"radio\"/>",
"align": "left",
"edit": true,
"width": "5ch"
"width": "10ch"
}
],
"config": { "view": "list", "fullWidth": true },
Expand Down Expand Up @@ -87,7 +87,7 @@
"fieldtype": "Data",
"align": "left",
"edit": true,
"width": "40ch",
"width": "50ch",
"cellComponent": "textarea",
"cellComponentProps": {
"rows": 8,
Expand Down
Loading

0 comments on commit 6eb9aa7

Please sign in to comment.