@mlightcad/ribbon 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +40 -3
  2. package/dist/components/Ribbon.vue.d.ts +102 -0
  3. package/dist/components/RibbonCollection.vue.d.ts +41 -0
  4. package/dist/components/RibbonGroup.vue.d.ts +77 -0
  5. package/dist/components/RibbonGroupContent.vue.d.ts +39 -0
  6. package/dist/components/RibbonItemHost.vue.d.ts +52 -0
  7. package/dist/components/RibbonTab.vue.d.ts +47 -0
  8. package/dist/components/RibbonTabs.vue.d.ts +34 -0
  9. package/dist/composables/useRibbonState.d.ts +17 -0
  10. package/dist/context.d.ts +3 -0
  11. package/{src/ribbon/index.ts → dist/index.d.ts} +15 -43
  12. package/dist/items/RibbonGallery.vue.d.ts +48 -0
  13. package/dist/items/RibbonGroupButton.vue.d.ts +49 -0
  14. package/dist/items/RibbonTemplateItem.vue.d.ts +40 -0
  15. package/dist/ml-ribbon.css +2 -0
  16. package/dist/ml-ribbon.es.js +1431 -0
  17. package/dist/ml-ribbon.umd.js +1 -0
  18. package/dist/modules/RibbonBackstage.vue.d.ts +61 -0
  19. package/dist/modules/RibbonContextualTabs.vue.d.ts +41 -0
  20. package/dist/modules/RibbonFileMenu.vue.d.ts +44 -0
  21. package/dist/modules/RibbonKeyTips.vue.d.ts +39 -0
  22. package/dist/types.d.ts +130 -0
  23. package/package.json +25 -2
  24. package/.github/workflows/ci.yml +0 -110
  25. package/.vscode/extensions.json +0 -3
  26. package/AGENTS.md +0 -42
  27. package/docs/requirements.md +0 -96
  28. package/eslint.config.js +0 -41
  29. package/images/ribbon.jpg +0 -0
  30. package/index.html +0 -13
  31. package/playwright/ribbon.spec.ts +0 -6
  32. package/playwright.config.ts +0 -10
  33. package/public/favicon.svg +0 -1
  34. package/public/icons.svg +0 -24
  35. package/src/App.vue +0 -418
  36. package/src/assets/hero.png +0 -0
  37. package/src/assets/vite.svg +0 -1
  38. package/src/assets/vue.svg +0 -1
  39. package/src/components/HelloWorld.vue +0 -106
  40. package/src/main.ts +0 -9
  41. package/src/ribbon/components/Ribbon.vue +0 -844
  42. package/src/ribbon/components/RibbonCollection.vue +0 -51
  43. package/src/ribbon/components/RibbonGroup.vue +0 -327
  44. package/src/ribbon/components/RibbonGroupContent.vue +0 -61
  45. package/src/ribbon/components/RibbonItemHost.vue +0 -221
  46. package/src/ribbon/components/RibbonTab.vue +0 -44
  47. package/src/ribbon/components/RibbonTabs.vue +0 -49
  48. package/src/ribbon/composables/useRibbonState.ts +0 -272
  49. package/src/ribbon/context.ts +0 -4
  50. package/src/ribbon/items/RibbonGallery.vue +0 -78
  51. package/src/ribbon/items/RibbonGroupButton.vue +0 -85
  52. package/src/ribbon/items/RibbonTemplateItem.vue +0 -38
  53. package/src/ribbon/modules/RibbonBackstage.vue +0 -69
  54. package/src/ribbon/modules/RibbonContextualTabs.vue +0 -65
  55. package/src/ribbon/modules/RibbonFileMenu.vue +0 -88
  56. package/src/ribbon/modules/RibbonKeyTips.vue +0 -114
  57. package/src/ribbon/styles/ribbon.css +0 -925
  58. package/src/ribbon/types.ts +0 -162
  59. package/src/style.css +0 -328
  60. package/src/tests/ribbon.spec.ts +0 -830
  61. package/src/tests/setup.ts +0 -4
  62. package/tools/release.mjs +0 -107
  63. package/tsconfig.app.json +0 -14
  64. package/tsconfig.json +0 -7
  65. package/tsconfig.node.json +0 -24
  66. package/vite.config.ts +0 -38
@@ -1,44 +0,0 @@
1
- <script setup lang="ts">
2
- /**
3
- * @component MlRibbonTab
4
- * @description
5
- * Declarative tab definition component. It is primarily used as a structural marker
6
- * and keeps tab metadata close to authored markup.
7
- *
8
- * @prop id - Unique tab identifier.
9
- * @prop title - Display title in the tab strip.
10
- * @prop visible - Controls tab visibility. Defaults to `true`.
11
- * @prop contextual - Marks the tab as contextual.
12
- * @prop contextualColor - Accent color used by contextual tab blocks.
13
- * @prop contextualTitle - Group label shown above contextual tabs.
14
- *
15
- * @slot default - Optional declarative content for custom tab authoring workflows.
16
- *
17
- * @example
18
- * ```vue
19
- * <MlRibbonTab
20
- * id="chart-tools"
21
- * title="Chart Design"
22
- * contextual
23
- * contextual-title="Chart Tools"
24
- * contextual-color="#eebe77"
25
- * />
26
- * ```
27
- */
28
- defineProps<{
29
- id: string
30
- title: string
31
- visible?: boolean
32
- contextual?: boolean
33
- contextualColor?: string
34
- contextualTitle?: string
35
- }>()
36
- </script>
37
-
38
- <template>
39
- <div class="ml-ribbon-tab-definition" hidden>
40
- <slot />
41
- </div>
42
- </template>
43
-
44
-
@@ -1,49 +0,0 @@
1
- <script setup lang="ts">
2
- import { computed } from 'vue'
3
-
4
- /**
5
- * @component MlRibbonTabs
6
- * @description
7
- * Renders the tab strip used by the ribbon header and emits selection changes.
8
- *
9
- * @prop tabs - Tab definitions to render. Tabs with `visible: false` are hidden.
10
- * @prop activeTab - Currently active tab id.
11
- *
12
- * @event select - Emitted when a tab is clicked. Payload is the selected tab id.
13
- *
14
- * @example
15
- * ```vue
16
- * <MlRibbonTabs
17
- * :tabs="[{ id: 'home', title: 'Home' }, { id: 'insert', title: 'Insert' }]"
18
- * active-tab="home"
19
- * @select="onTabSelect"
20
- * />
21
- * ```
22
- */
23
- const props = defineProps<{
24
- tabs: { id: string; title: string; visible?: boolean }[]
25
- activeTab: string
26
- }>()
27
-
28
- const emit = defineEmits<{ (e: 'select', id: string): void }>()
29
- const visibleTabs = computed(() => props.tabs.filter((x) => x.visible !== false))
30
- </script>
31
-
32
- <template>
33
- <div class="ml-ribbon-tabs" role="tablist">
34
- <button
35
- v-for="tab in visibleTabs"
36
- :key="tab.id"
37
- type="button"
38
- class="ml-ribbon-tab"
39
- :class="{ 'is-active': activeTab === tab.id }"
40
- role="tab"
41
- :aria-selected="activeTab === tab.id"
42
- @click="emit('select', tab.id)"
43
- >
44
- {{ tab.title }}
45
- </button>
46
- </div>
47
- </template>
48
-
49
-
@@ -1,272 +0,0 @@
1
- import { computed, markRaw, ref, toRaw } from 'vue'
2
- import type {
3
- KeyTipModel,
4
- RibbonContextValue,
5
- RibbonDynamicApi,
6
- RibbonGroupModel,
7
- RibbonItemModel,
8
- RibbonLayout,
9
- RibbonTabModel,
10
- } from '../types'
11
-
12
- /**
13
- * Normalizes potential component definitions to non-reactive objects.
14
- * @param value Unknown schema value that may contain a component.
15
- * @returns Normalized value safe for reactive storage.
16
- */
17
- function normalizeComponentCandidate<T>(value: T): T {
18
- if (value == null || typeof value === 'string') return value
19
- if (typeof value === 'object' || typeof value === 'function') {
20
- return markRaw(toRaw(value as object)) as T
21
- }
22
- return value
23
- }
24
-
25
- /**
26
- * Clones and normalizes item props, including icon-like fields.
27
- * @param props Raw item props from schema.
28
- * @returns Normalized props clone.
29
- */
30
- function normalizeItemProps(props?: Record<string, unknown>): Record<string, unknown> | undefined {
31
- if (!props) return undefined
32
- const nextProps: Record<string, unknown> = { ...props }
33
- if ('icon' in nextProps) {
34
- nextProps.icon = normalizeComponentCandidate(nextProps.icon)
35
- }
36
- if (Array.isArray(nextProps.options)) {
37
- nextProps.options = nextProps.options.map((option) => {
38
- if (!option || typeof option !== 'object') return option
39
- const optionRecord = option as Record<string, unknown>
40
- if (!('icon' in optionRecord)) return optionRecord
41
- return {
42
- ...optionRecord,
43
- icon: normalizeComponentCandidate(optionRecord.icon),
44
- }
45
- })
46
- }
47
- return nextProps
48
- }
49
-
50
- /**
51
- * Clones a ribbon item and normalizes component-like fields.
52
- * @param item Source item model.
53
- * @returns Cloned item model.
54
- */
55
- function cloneItem(item: RibbonItemModel): RibbonItemModel {
56
- return {
57
- ...item,
58
- icon: normalizeComponentCandidate(item.icon),
59
- props: normalizeItemProps(item.props),
60
- }
61
- }
62
-
63
- /**
64
- * Clones a ribbon group recursively.
65
- * @param group Source group model.
66
- * @returns Cloned group model.
67
- */
68
- function cloneGroup(group: RibbonGroupModel): RibbonGroupModel {
69
- return {
70
- ...group,
71
- icon: normalizeComponentCandidate(group.icon),
72
- collections: group.collections?.map((collection) => ({
73
- ...collection,
74
- items: collection.items.map(cloneItem),
75
- })),
76
- }
77
- }
78
-
79
- /**
80
- * Clones a ribbon tab recursively.
81
- * @param tab Source tab model.
82
- * @returns Cloned tab model.
83
- */
84
- function cloneTab(tab: RibbonTabModel): RibbonTabModel {
85
- return {
86
- ...tab,
87
- groups: tab.groups?.map(cloneGroup),
88
- }
89
- }
90
-
91
- /**
92
- * Clones a tab array for mutable runtime state.
93
- * @param tabs Source tab list.
94
- * @returns Cloned tab list.
95
- */
96
- function cloneTabs(tabs: RibbonTabModel[]): RibbonTabModel[] {
97
- return tabs.map(cloneTab)
98
- }
99
-
100
- /**
101
- * Ensures group has at least one collection for item insertion.
102
- * @param group Group model that may miss collections.
103
- */
104
- function ensureCollections(group: RibbonGroupModel) {
105
- if (!group.collections || group.collections.length === 0) {
106
- group.collections = [{ id: `${group.id}-collection-1`, items: [] }]
107
- }
108
- }
109
-
110
- /**
111
- * Locates a target item list and applies a mutation callback.
112
- * @param tabs Current mutable tabs tree.
113
- * @param tabId Target tab id.
114
- * @param groupId Target group id.
115
- * @param collectionId Target collection id.
116
- * @param fn Mutation callback for collection items.
117
- */
118
- function mutateItem(
119
- tabs: RibbonTabModel[],
120
- tabId: string,
121
- groupId: string,
122
- collectionId: string,
123
- fn: (items: RibbonItemModel[]) => void,
124
- ) {
125
- const tab = tabs.find((x) => x.id === tabId)
126
- if (!tab?.groups) return
127
- const group = tab.groups.find((x) => x.id === groupId)
128
- if (!group?.collections) return
129
- const collection = group.collections.find((x) => x.id === collectionId)
130
- if (!collection) return
131
- fn(collection.items)
132
- }
133
-
134
- /**
135
- * Creates the ribbon runtime state container and dynamic mutation API.
136
- * @param ribbonId Ribbon instance id.
137
- * @param initialTabs Initial tab schema.
138
- * @param initialLayout Initial layout mode.
139
- * @param initialMinimized Initial minimized state.
140
- * @param initialActiveTab Initial active tab id.
141
- * @returns Ribbon context plus computed visible tabs.
142
- */
143
- export function useRibbonState(
144
- ribbonId: string,
145
- initialTabs: RibbonTabModel[],
146
- initialLayout: RibbonLayout,
147
- initialMinimized: boolean,
148
- initialActiveTab: string,
149
- ) {
150
- const layout = ref<RibbonLayout>(initialLayout)
151
- const minimized = ref(initialMinimized)
152
- const activeTab = ref(initialActiveTab)
153
- const tabs = ref<RibbonTabModel[]>(cloneTabs(initialTabs))
154
- const overflowOpen = ref(false)
155
- const backdropOpen = ref(false)
156
- const keyTipsOpen = ref(false)
157
- const keyTips = ref<KeyTipModel[]>([])
158
- const keyTipsSequence = ref('')
159
-
160
- const visibleTabs = computed(() => tabs.value.filter((tab) => tab.visible !== false))
161
-
162
- const api: RibbonDynamicApi = {
163
- addTab(tab) {
164
- tabs.value.push(cloneTab(tab))
165
- if (!activeTab.value) activeTab.value = tab.id
166
- },
167
- removeTab(tabId) {
168
- tabs.value = tabs.value.filter((tab) => tab.id !== tabId)
169
- if (activeTab.value === tabId) {
170
- activeTab.value = visibleTabs.value[0]?.id ?? ''
171
- }
172
- },
173
- showTab(tabId) {
174
- const tab = tabs.value.find((x) => x.id === tabId)
175
- if (tab) tab.visible = true
176
- },
177
- hideTab(tabId) {
178
- const tab = tabs.value.find((x) => x.id === tabId)
179
- if (tab) tab.visible = false
180
- },
181
- selectTab(tabId) {
182
- activeTab.value = tabId
183
- },
184
- addGroup(tabId, group) {
185
- const tab = tabs.value.find((x) => x.id === tabId)
186
- if (!tab) return
187
- tab.groups ??= []
188
- ensureCollections(group)
189
- tab.groups.push(cloneGroup(group))
190
- },
191
- removeGroup(tabId, groupId) {
192
- const tab = tabs.value.find((x) => x.id === tabId)
193
- if (!tab?.groups) return
194
- tab.groups = tab.groups.filter((group) => group.id !== groupId)
195
- },
196
- showGroup(tabId, groupId) {
197
- const tab = tabs.value.find((x) => x.id === tabId)
198
- const group = tab?.groups?.find((x) => x.id === groupId)
199
- if (group) group.visible = true
200
- },
201
- hideGroup(tabId, groupId) {
202
- const tab = tabs.value.find((x) => x.id === tabId)
203
- const group = tab?.groups?.find((x) => x.id === groupId)
204
- if (group) group.visible = false
205
- },
206
- addItem(tabId, groupId, collectionId, item) {
207
- mutateItem(tabs.value, tabId, groupId, collectionId, (items) => items.push(cloneItem(item)))
208
- },
209
- removeItem(tabId, groupId, collectionId, itemId) {
210
- mutateItem(tabs.value, tabId, groupId, collectionId, (items) => {
211
- const index = items.findIndex((x) => x.id === itemId)
212
- if (index >= 0) items.splice(index, 1)
213
- })
214
- },
215
- updateItem(tabId, groupId, collectionId, itemId, patch) {
216
- mutateItem(tabs.value, tabId, groupId, collectionId, (items) => {
217
- const item = items.find((x) => x.id === itemId)
218
- if (item) Object.assign(item, patch)
219
- })
220
- },
221
- enableItem(tabId, groupId, collectionId, itemId) {
222
- api.updateItem(tabId, groupId, collectionId, itemId, { disabled: false })
223
- },
224
- disableItem(tabId, groupId, collectionId, itemId) {
225
- api.updateItem(tabId, groupId, collectionId, itemId, { disabled: true })
226
- },
227
- refreshLayout() {
228
- overflowOpen.value = false
229
- },
230
- minimize(value) {
231
- minimized.value = value
232
- },
233
- toggleSimplified() {
234
- layout.value = layout.value === 'classic' ? 'simplified' : 'classic'
235
- },
236
- }
237
-
238
- /**
239
- * Registers a key tip if it is not already present.
240
- * @param tip Key tip model.
241
- */
242
- const registerKeyTip = (tip: KeyTipModel) => {
243
- if (keyTips.value.some((x) => x.id === tip.id)) return
244
- keyTips.value.push(tip)
245
- }
246
-
247
- /**
248
- * Unregisters a key tip by id.
249
- * @param id Key tip id.
250
- */
251
- const unregisterKeyTip = (id: string) => {
252
- keyTips.value = keyTips.value.filter((x) => x.id !== id)
253
- }
254
-
255
- const context: RibbonContextValue = {
256
- id: ribbonId,
257
- layout,
258
- minimized,
259
- activeTab,
260
- tabs,
261
- overflowOpen,
262
- backdropOpen,
263
- keyTipsOpen,
264
- keyTips,
265
- keyTipsSequence,
266
- registerKeyTip,
267
- unregisterKeyTip,
268
- api,
269
- }
270
-
271
- return { context, visibleTabs }
272
- }
@@ -1,4 +0,0 @@
1
- import type { InjectionKey } from 'vue'
2
- import type { RibbonContextValue } from './types'
3
-
4
- export const ribbonKey: InjectionKey<RibbonContextValue> = Symbol('RibbonContext')
@@ -1,78 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref } from 'vue'
3
-
4
- /**
5
- * @component MlRibbonGallery
6
- * @description
7
- * Categorized gallery selector for previewable ribbon commands.
8
- *
9
- * @prop id - Gallery identifier.
10
- * @prop label - Optional gallery title.
11
- * @prop categories - Gallery categories and their selectable items.
12
- * @prop disabled - Disables selection.
13
- * @prop previewFallback - Fallback preview text when an item has no preview.
14
- *
15
- * @event select - Emitted with selected gallery item id.
16
- *
17
- * @example
18
- * ```vue
19
- * <MlRibbonGallery
20
- * id="styles"
21
- * label="Styles"
22
- * :categories="styleCategories"
23
- * preview-fallback="Preview"
24
- * @select="onStylePick"
25
- * />
26
- * ```
27
- */
28
- const props = withDefaults(
29
- defineProps<{
30
- id: string
31
- label: string
32
- categories: { id: string; title: string; items: { id: string; label: string; preview?: string }[] }[]
33
- disabled?: boolean
34
- previewFallback?: string
35
- }>(),
36
- { disabled: false },
37
- )
38
-
39
- const emit = defineEmits<{ (e: 'select', id: string): void }>()
40
- const selected = ref<string>('')
41
-
42
- /**
43
- * Selects a gallery item and emits its id.
44
- * @param id Target gallery item id.
45
- */
46
- function selectItem(id: string) {
47
- if (props.disabled) return
48
- selected.value = id
49
- emit('select', id)
50
- }
51
- </script>
52
-
53
- <template>
54
- <div class="ml-ribbon-gallery" :class="{ 'is-disabled': disabled }">
55
- <div v-if="label" class="ml-ribbon-gallery__title">{{ label }}</div>
56
- <div class="ml-ribbon-gallery__categories">
57
- <section v-for="category in categories" :key="category.id" class="ml-ribbon-gallery__category">
58
- <h4 class="ml-ribbon-gallery__category-title">{{ category.title }}</h4>
59
- <div class="ml-ribbon-gallery__grid">
60
- <button
61
- v-for="item in category.items"
62
- :key="item.id"
63
- type="button"
64
- class="ml-ribbon-gallery__item"
65
- :class="{ 'is-selected': selected === item.id }"
66
- :disabled="disabled"
67
- @click="selectItem(item.id)"
68
- >
69
- <div class="ml-ribbon-gallery__preview">{{ item.preview ?? props.previewFallback }}</div>
70
- <div class="ml-ribbon-gallery__label">{{ item.label }}</div>
71
- </button>
72
- </div>
73
- </section>
74
- </div>
75
- </div>
76
- </template>
77
-
78
-
@@ -1,85 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref } from 'vue'
3
- import { ElButton, ElButtonGroup, ElIcon } from 'element-plus'
4
- import type { Component } from 'vue'
5
-
6
- /**
7
- * @component MlRibbonGroupButton
8
- * @description
9
- * Segmented button control for ribbon items. Supports single-select and
10
- * multi-select modes and emits selected values.
11
- *
12
- * @prop id - Component identifier.
13
- * @prop label - Caption shown above segmented buttons.
14
- * @prop options - Selectable options with optional icons.
15
- * @prop multiple - Enables multi-select behavior.
16
- * @prop disabled - Disables interaction.
17
- *
18
- * @event change - Emitted with `string` in single mode or `string[]` in multiple mode.
19
- *
20
- * @example
21
- * ```vue
22
- * <MlRibbonGroupButton
23
- * id="find-replace"
24
- * label="Find / Replace"
25
- * :options="[
26
- * { label: 'Find', value: 'find' },
27
- * { label: 'Replace', value: 'replace' }
28
- * ]"
29
- * @change="onModeChange"
30
- * />
31
- * ```
32
- */
33
- const props = withDefaults(
34
- defineProps<{
35
- id: string
36
- label: string
37
- options: { label: string; value: string; icon?: Component }[]
38
- multiple?: boolean
39
- disabled?: boolean
40
- }>(),
41
- { multiple: false, disabled: false },
42
- )
43
-
44
- const emit = defineEmits<{ (e: 'change', value: string | string[]): void }>()
45
- const selected = ref<string[]>([])
46
-
47
- /**
48
- * Toggles option selection state and emits normalized payload by selection mode.
49
- * @param value Option value to toggle.
50
- */
51
- function toggle(value: string) {
52
- if (props.disabled) return
53
- if (props.multiple) {
54
- if (selected.value.includes(value)) {
55
- selected.value = selected.value.filter((x) => x !== value)
56
- } else {
57
- selected.value = [...selected.value, value]
58
- }
59
- emit('change', selected.value)
60
- return
61
- }
62
- selected.value = [value]
63
- emit('change', value)
64
- }
65
- </script>
66
-
67
- <template>
68
- <div class="ml-ribbon-group-button" :data-id="id">
69
- <div class="ml-ribbon-group-button__label">{{ label }}</div>
70
- <ElButtonGroup>
71
- <ElButton
72
- v-for="option in options"
73
- :key="option.value"
74
- :disabled="disabled"
75
- :type="selected.includes(option.value) ? 'primary' : 'default'"
76
- @click="toggle(option.value)"
77
- >
78
- <ElIcon v-if="option.icon" class="ml-ribbon-item-host__icon"><component :is="option.icon" /></ElIcon>
79
- {{ option.label }}
80
- </ElButton>
81
- </ElButtonGroup>
82
- </div>
83
- </template>
84
-
85
-
@@ -1,38 +0,0 @@
1
- <script setup lang="ts">
2
- import type { RibbonItemModel } from '../types'
3
-
4
- /**
5
- * @component MlRibbonTemplateItem
6
- * @description
7
- * Wrapper for fully custom ribbon item rendering while preserving ribbon layout
8
- * and item metadata context.
9
- *
10
- * @prop id - Template item identifier.
11
- * @prop item - Original ribbon item model passed to slot consumers.
12
- *
13
- * @slot default - Custom template content with `{ item }` slot prop.
14
- *
15
- * @example
16
- * ```vue
17
- * <MlRibbonTemplateItem :id="item.id" :item="item">
18
- * <template #default="{ item }">
19
- * <MyCustomCommand :label="item.label" />
20
- * </template>
21
- * </MlRibbonTemplateItem>
22
- * ```
23
- */
24
- defineProps<{
25
- id: string
26
- item: RibbonItemModel
27
- }>()
28
- </script>
29
-
30
- <template>
31
- <div class="ml-ribbon-template-item" :data-template-id="id">
32
- <slot :item="item">
33
- <span>{{ item.label ?? item.id }}</span>
34
- </slot>
35
- </div>
36
- </template>
37
-
38
-
@@ -1,69 +0,0 @@
1
- <script setup lang="ts">
2
- import { ElButton, ElDrawer, ElMenu, ElMenuItem } from 'element-plus'
3
-
4
- /**
5
- * @component MlRibbonBackstage
6
- * @description
7
- * Full-screen backstage panel used for document-level tasks such as open, save,
8
- * export, and app settings.
9
- *
10
- * @prop open - Controls drawer visibility.
11
- * @prop items - Navigation entries shown on the left side.
12
- * @prop backLabel - Label for the back/close button.
13
- * @prop title - Optional content title.
14
- * @prop description - Optional content description.
15
- *
16
- * @event close - Emitted when user closes the backstage panel.
17
- *
18
- * @example
19
- * ```vue
20
- * <MlRibbonBackstage
21
- * :open="backstageOpen"
22
- * :items="backstageItems"
23
- * back-label="Back"
24
- * title="Backstage"
25
- * description="Manage document-level actions."
26
- * @close="backstageOpen = false"
27
- * />
28
- * ```
29
- */
30
- const props = withDefaults(
31
- defineProps<{
32
- open: boolean
33
- items: { id: string; label: string; description?: string }[]
34
- backLabel?: string
35
- title?: string
36
- description?: string
37
- }>(),
38
- { items: () => [] },
39
- )
40
-
41
- const emit = defineEmits<{ (e: 'close'): void }>()
42
- </script>
43
-
44
- <template>
45
- <ElDrawer
46
- :model-value="props.open"
47
- size="100%"
48
- :with-header="false"
49
- direction="ltr"
50
- @close="emit('close')"
51
- >
52
- <div class="ml-ribbon-backstage">
53
- <aside class="ml-ribbon-backstage__nav">
54
- <ElButton type="primary" @click="emit('close')">{{ props.backLabel }}</ElButton>
55
- <ElMenu default-active="" class="ml-ribbon-backstage__menu">
56
- <ElMenuItem v-for="item in props.items" :key="item.id" :index="item.id">
57
- {{ item.label }}
58
- </ElMenuItem>
59
- </ElMenu>
60
- </aside>
61
- <section class="ml-ribbon-backstage__content">
62
- <h2 v-if="props.title">{{ props.title }}</h2>
63
- <p v-if="props.description">{{ props.description }}</p>
64
- </section>
65
- </div>
66
- </ElDrawer>
67
- </template>
68
-
69
-