@pgcorp/ui-kit 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +157 -0
- package/docs/accessibility.md +27 -0
- package/docs/getting-started.md +80 -0
- package/docs/licensing.md +30 -0
- package/docs/public-api.md +39 -0
- package/docs/security.md +21 -0
- package/docs/theming.md +35 -0
- package/docs/versioning.md +23 -0
- package/index.ts +3 -0
- package/package.json +592 -0
- package/src/components/icons/_internal/generatedSputnigUiIconMarkup.ts +971 -0
- package/src/components/icons/sputnigUiIcons.ts +530 -0
- package/src/components/layout/SAppShell.vue +232 -0
- package/src/components/layout/SDockRegion.vue +200 -0
- package/src/components/layout/SResizeHandle.vue +251 -0
- package/src/components/layout/SSideMenuButton.vue +104 -0
- package/src/components/layout/SSideMenuRail.vue +47 -0
- package/src/components/layout/SStack.css +25 -0
- package/src/components/layout/SStack.vue +57 -0
- package/src/components/layout/SStatusBarShell.css +15 -0
- package/src/components/layout/SStatusBarShell.vue +26 -0
- package/src/components/layout/SWorkbenchLayout.vue +53 -0
- package/src/components/layout/SWorkbenchPanelShell.css +161 -0
- package/src/components/layout/SWorkbenchPanelShell.vue +286 -0
- package/src/components/layout/_internal/SAppBrand.css +45 -0
- package/src/components/layout/_internal/SAppBrand.vue +37 -0
- package/src/components/layout/_internal/SAppBrandContent.vue +30 -0
- package/src/components/layout/types.ts +28 -0
- package/src/components/shared/_internal/SDialogSurface.css +127 -0
- package/src/components/shared/_internal/SDialogSurface.vue +117 -0
- package/src/components/shared/_internal/SDisclosureSummary.css +92 -0
- package/src/components/shared/_internal/SDisclosureSummary.vue +121 -0
- package/src/components/shared/_internal/SListboxGroup.css +18 -0
- package/src/components/shared/_internal/SListboxGroup.vue +24 -0
- package/src/components/shared/_internal/SMenuItem.css +112 -0
- package/src/components/shared/_internal/SMenuItem.vue +213 -0
- package/src/components/shared/_internal/SMenuLayer.css +21 -0
- package/src/components/shared/_internal/SMenuLayer.vue +48 -0
- package/src/components/shared/_internal/SMenuSeparator.css +5 -0
- package/src/components/shared/_internal/SMenuSeparator.vue +13 -0
- package/src/components/shared/_internal/SToastItem.css +65 -0
- package/src/components/shared/_internal/SToastItem.vue +58 -0
- package/src/components/shared/_internal/STreeNode.vue +761 -0
- package/src/components/shared/_internal/dialogSurface.ts +105 -0
- package/src/components/shared/_internal/focusTrap.ts +40 -0
- package/src/components/shared/_internal/listboxContext.ts +16 -0
- package/src/components/shared/_internal/markerContract.ts +10 -0
- package/src/components/shared/_internal/menuContext.ts +23 -0
- package/src/components/shared/_internal/selectionContract.ts +239 -0
- package/src/components/shared/_internal/sidebarGroupContext.ts +31 -0
- package/src/components/shared/_internal/tabsContext.ts +57 -0
- package/src/components/shared/_internal/treeRuntime.ts +203 -0
- package/src/components/shared/_internal/useSelectionRoving.ts +162 -0
- package/src/components/shared/codeLanguages.ts +168 -0
- package/src/components/shared/complex/SKanbanCard.css +8 -0
- package/src/components/shared/complex/SKanbanCard.vue +76 -0
- package/src/components/shared/complex/SKanbanLane.vue +82 -0
- package/src/components/shared/complex/STree.css +24 -0
- package/src/components/shared/complex/STree.vue +288 -0
- package/src/components/shared/complex/treeAdapter.ts +210 -0
- package/src/components/shared/complex/types.ts +102 -0
- package/src/components/shared/containers/SCloudChrome.css +103 -0
- package/src/components/shared/containers/SCloudChrome.vue +87 -0
- package/src/components/shared/containers/SCloudChromeEmpty.css +10 -0
- package/src/components/shared/containers/SCloudChromeEmpty.vue +18 -0
- package/src/components/shared/containers/SCloudChromeRow.css +78 -0
- package/src/components/shared/containers/SCloudChromeRow.vue +108 -0
- package/src/components/shared/containers/SCollapsiblePanel.css +57 -0
- package/src/components/shared/containers/SCollapsiblePanel.vue +360 -0
- package/src/components/shared/containers/SDrawer.css +60 -0
- package/src/components/shared/containers/SDrawer.vue +86 -0
- package/src/components/shared/containers/SFormGrid.css +26 -0
- package/src/components/shared/containers/SFormGrid.vue +46 -0
- package/src/components/shared/containers/SFormGridItem.css +18 -0
- package/src/components/shared/containers/SFormGridItem.vue +29 -0
- package/src/components/shared/containers/SLeftSidebar.vue +74 -0
- package/src/components/shared/containers/SModal.css +27 -0
- package/src/components/shared/containers/SModal.vue +105 -0
- package/src/components/shared/containers/SPageHeader.css +66 -0
- package/src/components/shared/containers/SPageHeader.vue +45 -0
- package/src/components/shared/containers/SPanel.css +134 -0
- package/src/components/shared/containers/SPanel.vue +169 -0
- package/src/components/shared/containers/SPopover.css +35 -0
- package/src/components/shared/containers/SPopover.vue +551 -0
- package/src/components/shared/containers/SSidebarGroup.css +12 -0
- package/src/components/shared/containers/SSidebarGroup.vue +443 -0
- package/src/components/shared/containers/SSidebarSection.css +41 -0
- package/src/components/shared/containers/SSidebarSection.vue +268 -0
- package/src/components/shared/containers/disclosureSummary.ts +48 -0
- package/src/components/shared/containers/popover.ts +72 -0
- package/src/components/shared/containers/sidebar.ts +206 -0
- package/src/components/shared/controls/SButton.css +274 -0
- package/src/components/shared/controls/SButton.vue +211 -0
- package/src/components/shared/controls/SCheckbox.css +65 -0
- package/src/components/shared/controls/SCheckbox.vue +130 -0
- package/src/components/shared/controls/SCheckboxGroup.vue +134 -0
- package/src/components/shared/controls/SChoiceCards.css +29 -0
- package/src/components/shared/controls/SChoiceCards.vue +145 -0
- package/src/components/shared/controls/SColorSelect.vue +146 -0
- package/src/components/shared/controls/SComboboxTrigger.css +35 -0
- package/src/components/shared/controls/SComboboxTrigger.vue +122 -0
- package/src/components/shared/controls/SContextMenu.css +11 -0
- package/src/components/shared/controls/SContextMenu.vue +186 -0
- package/src/components/shared/controls/SContextToggleButton.vue +64 -0
- package/src/components/shared/controls/SDragHandle.vue +100 -0
- package/src/components/shared/controls/SDropdownMenu.css +5 -0
- package/src/components/shared/controls/SDropdownMenu.vue +188 -0
- package/src/components/shared/controls/SField.css +79 -0
- package/src/components/shared/controls/SField.vue +89 -0
- package/src/components/shared/controls/SFieldGroup.css +58 -0
- package/src/components/shared/controls/SFieldGroup.vue +117 -0
- package/src/components/shared/controls/SFieldLabel.css +12 -0
- package/src/components/shared/controls/SFieldLabel.vue +51 -0
- package/src/components/shared/controls/SInlineTokenEditor.css +61 -0
- package/src/components/shared/controls/SInlineTokenEditor.vue +1081 -0
- package/src/components/shared/controls/SInputText.css +66 -0
- package/src/components/shared/controls/SInputText.vue +321 -0
- package/src/components/shared/controls/SInteractiveSurface.css +72 -0
- package/src/components/shared/controls/SInteractiveSurface.vue +326 -0
- package/src/components/shared/controls/SLink.css +114 -0
- package/src/components/shared/controls/SLink.ts +85 -0
- package/src/components/shared/controls/SLink.vue +114 -0
- package/src/components/shared/controls/SListbox.css +31 -0
- package/src/components/shared/controls/SListbox.vue +388 -0
- package/src/components/shared/controls/SListboxOption.css +63 -0
- package/src/components/shared/controls/SListboxOption.vue +85 -0
- package/src/components/shared/controls/SMarker.css +19 -0
- package/src/components/shared/controls/SMarker.vue +33 -0
- package/src/components/shared/controls/SMenuSurface.css +20 -0
- package/src/components/shared/controls/SMenuSurface.vue +333 -0
- package/src/components/shared/controls/SSegmentedControl.css +38 -0
- package/src/components/shared/controls/SSegmentedControl.vue +134 -0
- package/src/components/shared/controls/SSelect.css +12 -0
- package/src/components/shared/controls/SSelect.vue +338 -0
- package/src/components/shared/controls/STextarea.css +31 -0
- package/src/components/shared/controls/STextarea.vue +316 -0
- package/src/components/shared/controls/_internal/SInlineTokenSurface.vue +224 -0
- package/src/components/shared/controls/menu.ts +178 -0
- package/src/components/shared/data-display/SActionCard.css +6 -0
- package/src/components/shared/data-display/SActionCard.vue +49 -0
- package/src/components/shared/data-display/SActionList.css +15 -0
- package/src/components/shared/data-display/SActionList.vue +34 -0
- package/src/components/shared/data-display/SActionListItem.css +114 -0
- package/src/components/shared/data-display/SActionListItem.vue +230 -0
- package/src/components/shared/data-display/SBadge.css +73 -0
- package/src/components/shared/data-display/SBadge.vue +52 -0
- package/src/components/shared/data-display/SCodeBlock.css +56 -0
- package/src/components/shared/data-display/SCodeBlock.vue +188 -0
- package/src/components/shared/data-display/SCodeEditor.css +178 -0
- package/src/components/shared/data-display/SCodeEditor.vue +274 -0
- package/src/components/shared/data-display/SCodeSearchPanel.vue +327 -0
- package/src/components/shared/data-display/SCopyField.vue +77 -0
- package/src/components/shared/data-display/SDocBlock.css +136 -0
- package/src/components/shared/data-display/SDocBlock.vue +358 -0
- package/src/components/shared/data-display/SEmptyState.css +42 -0
- package/src/components/shared/data-display/SEmptyState.vue +79 -0
- package/src/components/shared/data-display/SExpandableText.vue +314 -0
- package/src/components/shared/data-display/SJsonTree.css +6 -0
- package/src/components/shared/data-display/SJsonTree.vue +111 -0
- package/src/components/shared/data-display/SKeyValueGrid.css +37 -0
- package/src/components/shared/data-display/SKeyValueGrid.vue +277 -0
- package/src/components/shared/data-display/SLinkedSystemsList.vue +270 -0
- package/src/components/shared/data-display/SMessage.css +88 -0
- package/src/components/shared/data-display/SMessage.vue +152 -0
- package/src/components/shared/data-display/SMetricCard.css +32 -0
- package/src/components/shared/data-display/SMetricCard.vue +117 -0
- package/src/components/shared/data-display/SProgressBar.css +84 -0
- package/src/components/shared/data-display/SProgressBar.vue +114 -0
- package/src/components/shared/data-display/SProgressIndicator.css +59 -0
- package/src/components/shared/data-display/SProgressIndicator.vue +104 -0
- package/src/components/shared/data-display/SSectionHeader.css +84 -0
- package/src/components/shared/data-display/SSectionHeader.vue +58 -0
- package/src/components/shared/data-display/SStatus.css +90 -0
- package/src/components/shared/data-display/SStatus.vue +79 -0
- package/src/components/shared/data-display/STable.css +83 -0
- package/src/components/shared/data-display/STable.vue +339 -0
- package/src/components/shared/data-display/SToastContainer.css +53 -0
- package/src/components/shared/data-display/SToastContainer.vue +31 -0
- package/src/components/shared/data-display/STooltip.css +114 -0
- package/src/components/shared/data-display/STooltip.vue +550 -0
- package/src/components/shared/data-display/STooltipAnchor.css +21 -0
- package/src/components/shared/data-display/STooltipAnchor.vue +119 -0
- package/src/components/shared/data-display/SVirtualList.css +24 -0
- package/src/components/shared/data-display/SVirtualList.ts +19 -0
- package/src/components/shared/data-display/SVirtualList.vue +361 -0
- package/src/components/shared/data-display/json.ts +136 -0
- package/src/components/shared/data-display/table.ts +76 -0
- package/src/components/shared/database/SDataGrid.css +3 -0
- package/src/components/shared/database/SDataGrid.vue +464 -0
- package/src/components/shared/database/SSqlEditor.vue +363 -0
- package/src/components/shared/database/dataGrid.ts +61 -0
- package/src/components/shared/feedback/SAsyncState.css +26 -0
- package/src/components/shared/feedback/SAsyncState.vue +190 -0
- package/src/components/shared/graph/SGraphViewport.ts +1 -0
- package/src/components/shared/graph/SGraphViewport.vue +858 -0
- package/src/components/shared/graph/_internal/graphViewportContract.ts +362 -0
- package/src/components/shared/markdown.ts +169 -0
- package/src/components/shared/navigation/SBottomNav.vue +692 -0
- package/src/components/shared/navigation/SBreadcrumbs.css +26 -0
- package/src/components/shared/navigation/SBreadcrumbs.vue +155 -0
- package/src/components/shared/navigation/SCatalogNavigator.css +100 -0
- package/src/components/shared/navigation/SCatalogNavigator.vue +308 -0
- package/src/components/shared/navigation/STab.vue +363 -0
- package/src/components/shared/navigation/STabList.vue +442 -0
- package/src/components/shared/navigation/STabPanel.vue +165 -0
- package/src/components/shared/navigation/STabPanels.vue +33 -0
- package/src/components/shared/navigation/STabs.vue +617 -0
- package/src/components/shared/navigation/SWizardSteps.css +69 -0
- package/src/components/shared/navigation/SWizardSteps.vue +171 -0
- package/src/components/shared/navigation/_internal/SCatalogNavigatorGroup.vue +63 -0
- package/src/components/shared/persona/SPersonaProjectPicker.css +36 -0
- package/src/components/shared/persona/SPersonaProjectPicker.vue +361 -0
- package/src/components/shared/persona/SPersonaRunWorkbench.css +109 -0
- package/src/components/shared/persona/SPersonaRunWorkbench.vue +549 -0
- package/src/components/shared/persona/_internal/SPersonaRunConsole.css +40 -0
- package/src/components/shared/persona/_internal/SPersonaRunConsole.vue +298 -0
- package/src/components/shared/persona/_internal/inventory.ts +110 -0
- package/src/components/shared/persona/_internal/labels.ts +79 -0
- package/src/components/shared/persona/presentation.ts +371 -0
- package/src/components/shared/persona/types.ts +256 -0
- package/src/composables/uiPreferencesReset.ts +52 -0
- package/src/composables/useClipboard.ts +37 -0
- package/src/composables/useDialogOverlay.ts +85 -0
- package/src/composables/useDisclosure.ts +40 -0
- package/src/composables/useFloatingPosition.ts +245 -0
- package/src/composables/useNotifier.ts +26 -0
- package/src/composables/useSidebarPanelState.ts +610 -0
- package/src/internal/codeEditorContract.ts +110 -0
- package/src/internal/codeEditorExtensions.ts +27 -0
- package/src/internal/feedbackPresentation.ts +136 -0
- package/src/internal/fieldSurface.ts +59 -0
- package/src/internal/focusNavigation.ts +69 -0
- package/src/internal/inlineTokenEditorContract.ts +136 -0
- package/src/internal/interactiveElement.ts +33 -0
- package/src/internal/layerStack.ts +202 -0
- package/src/internal/linkTarget.ts +256 -0
- package/src/internal/ownedAttrs.ts +464 -0
- package/src/internal/passiveContentContract.ts +129 -0
- package/src/internal/pointerInteractionLease.ts +81 -0
- package/src/internal/runtimeContract.ts +194 -0
- package/src/internal/runtimeTheme.ts +159 -0
- package/src/internal/semanticSizing.ts +60 -0
- package/src/internal/useMenuLayer.ts +129 -0
- package/src/stores/useNotifierStore.ts +69 -0
- package/src/styles/reference.css +4 -0
- package/src/styles/style.css +151 -0
- package/src/styles/tokens.css +836 -0
- package/src/theme.ts +449 -0
- package/src/types/highlight-js-lib.d.ts +76 -0
- package/src/variants.ts +15 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
@reference "../../../styles/reference.css";
|
|
2
|
+
|
|
3
|
+
.s-disclosure-summary {
|
|
4
|
+
@apply flex min-w-0 flex-1 items-center gap-1.5 text-left;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.s-disclosure-summary__title {
|
|
8
|
+
@apply min-w-0 truncate;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.s-disclosure-summary[data-summary-typography='default'] .s-disclosure-summary__title {
|
|
12
|
+
@apply font-medium;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.s-disclosure-summary[data-summary-typography='strong'] .s-disclosure-summary__title {
|
|
16
|
+
@apply font-semibold;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.s-disclosure-summary[data-summary-typography='mono'] .s-disclosure-summary__title {
|
|
20
|
+
@apply font-mono font-medium;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.s-disclosure-summary[data-summary-case='uppercase'] .s-disclosure-summary__title {
|
|
24
|
+
@apply uppercase tracking-wider;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.s-disclosure-summary__state {
|
|
28
|
+
@apply inline-flex shrink-0 items-center justify-center;
|
|
29
|
+
width: var(--s-icon-size-xs);
|
|
30
|
+
height: var(--s-icon-size-xs);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.s-disclosure-summary__state[data-summary-state-tone='neutral'] {
|
|
34
|
+
@apply text-surface-500 dark:text-surface-400;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.s-disclosure-summary__state[data-summary-state-tone='info'] {
|
|
38
|
+
@apply text-info-600 dark:text-info-300;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.s-disclosure-summary__state[data-summary-state-tone='success'] {
|
|
42
|
+
@apply text-success-600 dark:text-success-300;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.s-disclosure-summary__state[data-summary-state-tone='warn'] {
|
|
46
|
+
@apply text-warn-600 dark:text-warn-300;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.s-disclosure-summary__state[data-summary-state-tone='danger'] {
|
|
50
|
+
@apply text-danger-600 dark:text-danger-300;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.s-disclosure-summary__state-icon {
|
|
54
|
+
@apply h-full w-full;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.s-disclosure-summary__facts,
|
|
58
|
+
.s-disclosure-summary__badges {
|
|
59
|
+
@apply flex min-w-0 shrink items-center gap-1 overflow-hidden;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.s-disclosure-summary__fact {
|
|
63
|
+
@apply inline-flex min-w-0 max-w-32 shrink items-center gap-1 rounded border border-surface-200 bg-surface-50 px-1 text-[10px] font-medium leading-4 text-surface-600 dark:border-surface-700 dark:bg-surface-900 dark:text-surface-300;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.s-disclosure-summary__fact[data-summary-fact-tone='info'] {
|
|
67
|
+
@apply border-info-200 bg-info-50 text-info-700 dark:border-info-800 dark:bg-info-950 dark:text-info-300;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.s-disclosure-summary__fact[data-summary-fact-tone='success'] {
|
|
71
|
+
@apply border-success-200 bg-success-50 text-success-700 dark:border-success-800 dark:bg-success-950 dark:text-success-300;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.s-disclosure-summary__fact[data-summary-fact-tone='warn'] {
|
|
75
|
+
@apply border-warn-200 bg-warn-50 text-warn-700 dark:border-warn-800 dark:bg-warn-950 dark:text-warn-300;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.s-disclosure-summary__fact[data-summary-fact-tone='danger'] {
|
|
79
|
+
@apply border-danger-200 bg-danger-50 text-danger-700 dark:border-danger-800 dark:bg-danger-950 dark:text-danger-300;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.s-disclosure-summary__fact-label {
|
|
83
|
+
@apply shrink-0 text-surface-500 dark:text-surface-400;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.s-disclosure-summary__fact-value {
|
|
87
|
+
@apply min-w-0 truncate;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.s-disclosure-summary__status {
|
|
91
|
+
@apply ml-auto shrink-0;
|
|
92
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span
|
|
3
|
+
class="s-disclosure-summary"
|
|
4
|
+
:data-summary-typography="typography"
|
|
5
|
+
:data-summary-case="casing"
|
|
6
|
+
>
|
|
7
|
+
<span
|
|
8
|
+
v-if="statePresentation"
|
|
9
|
+
class="s-disclosure-summary__state"
|
|
10
|
+
:data-summary-state="state"
|
|
11
|
+
:data-summary-state-tone="statePresentation.tone"
|
|
12
|
+
aria-hidden="true"
|
|
13
|
+
>
|
|
14
|
+
<SProgressIndicator
|
|
15
|
+
v-if="state === 'progress'"
|
|
16
|
+
:accessibility="{ mode: 'decorative' }"
|
|
17
|
+
size="xs"
|
|
18
|
+
tone="info"
|
|
19
|
+
/>
|
|
20
|
+
<component v-else :is="statePresentation.icon" class="s-disclosure-summary__state-icon" />
|
|
21
|
+
</span>
|
|
22
|
+
<span class="s-disclosure-summary__title">{{ title }}</span>
|
|
23
|
+
<span v-if="facts.length > 0" class="s-disclosure-summary__facts">
|
|
24
|
+
<span
|
|
25
|
+
v-for="fact in facts"
|
|
26
|
+
:key="fact.id"
|
|
27
|
+
class="s-disclosure-summary__fact"
|
|
28
|
+
:data-summary-fact-tone="fact.tone ?? 'neutral'"
|
|
29
|
+
>
|
|
30
|
+
<span v-if="fact.label" class="s-disclosure-summary__fact-label">{{ fact.label }}</span>
|
|
31
|
+
<span class="s-disclosure-summary__fact-value">{{ fact.value }}</span>
|
|
32
|
+
</span>
|
|
33
|
+
</span>
|
|
34
|
+
<span v-if="badges.length > 0" class="s-disclosure-summary__badges">
|
|
35
|
+
<SBadge
|
|
36
|
+
v-for="badge in badges"
|
|
37
|
+
:key="badge.id"
|
|
38
|
+
:severity="badge.severity ?? 'secondary'"
|
|
39
|
+
size="xs"
|
|
40
|
+
:title="badge.title"
|
|
41
|
+
>
|
|
42
|
+
{{ badge.label }}
|
|
43
|
+
</SBadge>
|
|
44
|
+
</span>
|
|
45
|
+
<span v-if="status" class="s-disclosure-summary__status">
|
|
46
|
+
<SStatus
|
|
47
|
+
:label="status.label"
|
|
48
|
+
:tone="status.tone ?? 'neutral'"
|
|
49
|
+
:title="status.title"
|
|
50
|
+
:icon="null"
|
|
51
|
+
size="xs"
|
|
52
|
+
/>
|
|
53
|
+
</span>
|
|
54
|
+
</span>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script setup lang="ts">
|
|
58
|
+
import { computed, watchEffect } from 'vue'
|
|
59
|
+
|
|
60
|
+
import { resolveFeedbackIndicator } from '../../../internal/feedbackPresentation'
|
|
61
|
+
import { validateNonEmptyString } from '../../../internal/runtimeContract'
|
|
62
|
+
import SBadge from '../data-display/SBadge.vue'
|
|
63
|
+
import SProgressIndicator from '../data-display/SProgressIndicator.vue'
|
|
64
|
+
import SStatus from '../data-display/SStatus.vue'
|
|
65
|
+
import type {
|
|
66
|
+
SDisclosureSummaryBadge,
|
|
67
|
+
SDisclosureSummaryCase,
|
|
68
|
+
SDisclosureSummaryFact,
|
|
69
|
+
SDisclosureSummaryState,
|
|
70
|
+
SDisclosureSummaryStatus,
|
|
71
|
+
SDisclosureSummaryTypography,
|
|
72
|
+
} from '../containers/disclosureSummary'
|
|
73
|
+
|
|
74
|
+
const props = withDefaults(defineProps<{
|
|
75
|
+
title: string
|
|
76
|
+
typography?: SDisclosureSummaryTypography
|
|
77
|
+
casing?: SDisclosureSummaryCase
|
|
78
|
+
state?: SDisclosureSummaryState
|
|
79
|
+
facts?: readonly SDisclosureSummaryFact[]
|
|
80
|
+
badges?: readonly SDisclosureSummaryBadge[]
|
|
81
|
+
status?: SDisclosureSummaryStatus
|
|
82
|
+
}>(), {
|
|
83
|
+
typography: 'default',
|
|
84
|
+
casing: 'sentence',
|
|
85
|
+
state: undefined,
|
|
86
|
+
facts: () => [],
|
|
87
|
+
badges: () => [],
|
|
88
|
+
status: undefined,
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
const statePresentation = computed(() => props.state ? resolveFeedbackIndicator(props.state) : null)
|
|
92
|
+
|
|
93
|
+
watchEffect(() => {
|
|
94
|
+
if (props.title.trim().length === 0) {
|
|
95
|
+
throw new Error('SDisclosureSummary: title must be a non-empty string')
|
|
96
|
+
}
|
|
97
|
+
const factIds = new Set<string>()
|
|
98
|
+
props.facts.forEach((fact, index) => {
|
|
99
|
+
const id = validateNonEmptyString('SDisclosureSummary', `facts[${index}].id`, fact.id)
|
|
100
|
+
if (factIds.has(id)) throw new Error(`SDisclosureSummary: duplicate facts id "${id}"`)
|
|
101
|
+
factIds.add(id)
|
|
102
|
+
if (String(fact.value).trim().length === 0) {
|
|
103
|
+
throw new Error(`SDisclosureSummary: facts[${index}].value must be non-empty`)
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
const badgeIds = new Set<string>()
|
|
107
|
+
props.badges.forEach((badge, index) => {
|
|
108
|
+
const id = validateNonEmptyString('SDisclosureSummary', `badges[${index}].id`, badge.id)
|
|
109
|
+
if (badgeIds.has(id)) throw new Error(`SDisclosureSummary: duplicate badges id "${id}"`)
|
|
110
|
+
badgeIds.add(id)
|
|
111
|
+
if (String(badge.label).trim().length === 0) {
|
|
112
|
+
throw new Error(`SDisclosureSummary: badges[${index}].label must be non-empty`)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
if (props.status && props.status.label.trim().length === 0) {
|
|
116
|
+
throw new Error('SDisclosureSummary: status.label must be a non-empty string')
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
<style lang="postcss" src="./SDisclosureSummary.css" scoped></style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@reference "../../../styles/reference.css";
|
|
2
|
+
|
|
3
|
+
.s-listbox-group,
|
|
4
|
+
.s-listbox-group__options {
|
|
5
|
+
@apply m-0 list-none p-0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.s-listbox-group__label {
|
|
9
|
+
@apply block cursor-default px-3 py-2 text-xs font-bold uppercase tracking-wider text-surface-500 dark:text-surface-400;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.s-listbox-group[data-variant='color'] {
|
|
13
|
+
grid-column: 1 / -1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.s-listbox-group[data-variant='color'] .s-listbox-group__options {
|
|
17
|
+
@apply grid grid-cols-5 gap-2;
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<li class="s-listbox-group" :data-variant="variant" role="group" :aria-labelledby="labelId">
|
|
3
|
+
<span :id="labelId" class="s-listbox-group__label">
|
|
4
|
+
{{ label }}
|
|
5
|
+
</span>
|
|
6
|
+
<ul class="s-listbox-group__options" role="presentation">
|
|
7
|
+
<slot />
|
|
8
|
+
</ul>
|
|
9
|
+
</li>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
export interface Props {
|
|
14
|
+
label: string
|
|
15
|
+
labelId: string
|
|
16
|
+
variant?: 'select' | 'color'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
withDefaults(defineProps<Props>(), {
|
|
20
|
+
variant: 'select',
|
|
21
|
+
})
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<style lang="postcss" src="./SListboxGroup.css" scoped></style>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
@reference "../../../styles/reference.css";
|
|
2
|
+
|
|
3
|
+
.s-menu-item {
|
|
4
|
+
@apply flex w-full min-w-0 items-center text-left font-medium;
|
|
5
|
+
min-height: var(--s-density-row-default);
|
|
6
|
+
gap: var(--s-space-control-gap);
|
|
7
|
+
padding: var(--s-menu-item-block-padding) var(--s-menu-item-inline-padding);
|
|
8
|
+
border: 0;
|
|
9
|
+
border-radius: var(--radius-xs);
|
|
10
|
+
background: transparent;
|
|
11
|
+
color: var(--s-menu-item-foreground);
|
|
12
|
+
font-family: inherit;
|
|
13
|
+
font-size: 0.875rem;
|
|
14
|
+
line-height: 1.25rem;
|
|
15
|
+
appearance: none;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
transition:
|
|
18
|
+
background-color var(--s-motion-fast) ease,
|
|
19
|
+
color var(--s-motion-fast) ease;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.s-menu-item[data-density='compact'] {
|
|
23
|
+
min-height: var(--s-density-row-compact);
|
|
24
|
+
padding: var(--s-menu-item-block-padding-compact) var(--s-menu-item-inline-padding-compact);
|
|
25
|
+
font-size: 0.75rem;
|
|
26
|
+
line-height: 1rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.s-menu-item:hover:not([aria-disabled='true']),
|
|
30
|
+
.s-menu-item:focus-visible,
|
|
31
|
+
.s-menu-item[data-current='true'] {
|
|
32
|
+
background: var(--s-menu-item-state-background);
|
|
33
|
+
color: var(--s-menu-item-state-foreground);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.s-menu-item:focus-visible {
|
|
37
|
+
outline: var(--s-focus-ring-width) solid var(--s-focus-ring-color);
|
|
38
|
+
outline-offset: var(--s-focus-ring-inset-offset);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.s-menu-item[aria-disabled='true'] {
|
|
42
|
+
color: var(--s-menu-item-disabled-foreground);
|
|
43
|
+
cursor: not-allowed;
|
|
44
|
+
opacity: 0.62;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.s-menu-item__main {
|
|
48
|
+
@apply flex min-w-0 items-center;
|
|
49
|
+
gap: var(--s-space-control-gap);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.s-menu-item__state {
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
flex: 0 0 var(--s-icon-size-xs);
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.s-menu-item__state:empty {
|
|
60
|
+
display: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.s-menu-item__icon,
|
|
64
|
+
.s-menu-item__state-icon,
|
|
65
|
+
.s-menu-item__submenu-icon {
|
|
66
|
+
flex: 0 0 auto;
|
|
67
|
+
width: var(--s-icon-size-xs);
|
|
68
|
+
height: var(--s-icon-size-xs);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.s-menu-item__state-icon,
|
|
72
|
+
.s-menu-item__radio-dot {
|
|
73
|
+
color: var(--s-menu-item-indicator-foreground);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.s-menu-item__radio-dot {
|
|
77
|
+
width: calc(var(--s-icon-size-xs) / 2);
|
|
78
|
+
height: calc(var(--s-icon-size-xs) / 2);
|
|
79
|
+
border-radius: var(--s-radius-pill);
|
|
80
|
+
background: currentColor;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.s-menu-item__label {
|
|
84
|
+
min-width: 0;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
text-overflow: ellipsis;
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.s-menu-item__meta {
|
|
91
|
+
@apply ml-auto inline-flex shrink-0 items-center;
|
|
92
|
+
gap: var(--s-space-control-gap);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.s-menu-item__badge {
|
|
96
|
+
@apply inline-flex;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.s-menu-item__shortcut {
|
|
100
|
+
@apply whitespace-nowrap text-right text-xs leading-4;
|
|
101
|
+
color: var(--s-menu-item-secondary-foreground);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.s-menu-item:hover:not([aria-disabled='true']) .s-menu-item__shortcut,
|
|
105
|
+
.s-menu-item:focus-visible .s-menu-item__shortcut,
|
|
106
|
+
.s-menu-item[data-current='true'] .s-menu-item__shortcut {
|
|
107
|
+
color: var(--s-menu-item-state-foreground);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.s-menu-item[data-layout='tile'] {
|
|
111
|
+
min-width: 5rem;
|
|
112
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="destinationComponent"
|
|
4
|
+
v-if="entry.kind === 'destination' && !entry.disabled"
|
|
5
|
+
v-bind="destinationBindings"
|
|
6
|
+
class="s-menu-item"
|
|
7
|
+
role="menuitem"
|
|
8
|
+
:data-layout="entry.layout ?? 'row'"
|
|
9
|
+
:data-density="context.density.value"
|
|
10
|
+
:data-menu-entry-id="entry.id"
|
|
11
|
+
:data-current="entry.current || undefined"
|
|
12
|
+
tabindex="-1"
|
|
13
|
+
:aria-current="entry.current ? 'page' : undefined"
|
|
14
|
+
@click="handleDestinationClick"
|
|
15
|
+
@pointermove="emit('pointer-intent')"
|
|
16
|
+
@vue:mounted="bindInteractiveVNode"
|
|
17
|
+
@vue:updated="bindInteractiveVNode"
|
|
18
|
+
@vue:before-unmount="unbindInteractiveElement"
|
|
19
|
+
>
|
|
20
|
+
<span class="s-menu-item__main">
|
|
21
|
+
<span class="s-menu-item__state" />
|
|
22
|
+
<component :is="entry.icon" v-if="entry.icon" class="s-menu-item__icon" aria-hidden="true" />
|
|
23
|
+
<span class="s-menu-item__label">{{ entry.label }}</span>
|
|
24
|
+
</span>
|
|
25
|
+
<span v-if="entry.badge !== undefined || entry.shortcut" class="s-menu-item__meta">
|
|
26
|
+
<span v-if="entry.badge !== undefined" class="s-menu-item__badge">
|
|
27
|
+
<SBadge :severity="entry.badgeSeverity ?? 'secondary'" size="xs">{{ entry.badge }}</SBadge>
|
|
28
|
+
</span>
|
|
29
|
+
<span v-if="entry.shortcut" class="s-menu-item__shortcut" aria-hidden="true">{{ entry.shortcut }}</span>
|
|
30
|
+
</span>
|
|
31
|
+
</component>
|
|
32
|
+
<button
|
|
33
|
+
v-else
|
|
34
|
+
class="s-menu-item"
|
|
35
|
+
type="button"
|
|
36
|
+
:role="itemRole"
|
|
37
|
+
:data-layout="entry.layout ?? 'row'"
|
|
38
|
+
:data-density="context.density.value"
|
|
39
|
+
:data-menu-entry-id="entry.id"
|
|
40
|
+
:data-current="isCurrent || undefined"
|
|
41
|
+
tabindex="-1"
|
|
42
|
+
:aria-disabled="entry.disabled || undefined"
|
|
43
|
+
:aria-current="isCurrent ? 'page' : undefined"
|
|
44
|
+
:aria-checked="checkedState"
|
|
45
|
+
:aria-haspopup="entry.kind === 'submenu' ? 'menu' : undefined"
|
|
46
|
+
:aria-expanded="entry.kind === 'submenu' ? submenuOpen : undefined"
|
|
47
|
+
@click="handleSelect"
|
|
48
|
+
@pointermove="emit('pointer-intent')"
|
|
49
|
+
@vue:mounted="bindInteractiveVNode"
|
|
50
|
+
@vue:updated="bindInteractiveVNode"
|
|
51
|
+
@vue:before-unmount="unbindInteractiveElement"
|
|
52
|
+
>
|
|
53
|
+
<span class="s-menu-item__main">
|
|
54
|
+
<span class="s-menu-item__state">
|
|
55
|
+
<Check
|
|
56
|
+
v-if="entry.kind === 'checkbox' && entry.checked !== false"
|
|
57
|
+
class="s-menu-item__state-icon"
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
/>
|
|
60
|
+
<span
|
|
61
|
+
v-else-if="entry.kind === 'radio' && entry.checked"
|
|
62
|
+
class="s-menu-item__radio-dot"
|
|
63
|
+
aria-hidden="true"
|
|
64
|
+
/>
|
|
65
|
+
</span>
|
|
66
|
+
<component :is="entry.icon" v-if="entry.icon" class="s-menu-item__icon" aria-hidden="true" />
|
|
67
|
+
<span class="s-menu-item__label">{{ entry.label }}</span>
|
|
68
|
+
</span>
|
|
69
|
+
<span v-if="entry.badge !== undefined || entry.shortcut || entry.kind === 'submenu'" class="s-menu-item__meta">
|
|
70
|
+
<span v-if="entry.badge !== undefined" class="s-menu-item__badge">
|
|
71
|
+
<SBadge :severity="entry.badgeSeverity ?? 'secondary'" size="xs">{{ entry.badge }}</SBadge>
|
|
72
|
+
</span>
|
|
73
|
+
<span v-if="entry.shortcut" class="s-menu-item__shortcut" aria-hidden="true">{{ entry.shortcut }}</span>
|
|
74
|
+
<ChevronRight v-if="entry.kind === 'submenu'" class="s-menu-item__submenu-icon" aria-hidden="true" />
|
|
75
|
+
</span>
|
|
76
|
+
</button>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
|
+
<script setup lang="ts">
|
|
80
|
+
import { computed, inject, ref, type VNode } from 'vue'
|
|
81
|
+
import { RouterLink } from 'vue-router'
|
|
82
|
+
import { resolveLinkTarget } from '../../../internal/linkTarget'
|
|
83
|
+
import { useInteractiveLeafRegistration } from '../../../internal/passiveContentContract'
|
|
84
|
+
import { Check, ChevronRight } from '../../icons/sputnigUiIcons'
|
|
85
|
+
import type { SMenuActivationEvent, SMenuInteractiveEntry } from '../controls/menu'
|
|
86
|
+
import SBadge from '../data-display/SBadge.vue'
|
|
87
|
+
import { menuContextKey } from './menuContext'
|
|
88
|
+
|
|
89
|
+
defineOptions({ inheritAttrs: false })
|
|
90
|
+
|
|
91
|
+
const maybeContext = inject(menuContextKey)
|
|
92
|
+
if (!maybeContext) throw new Error('SMenuItem must be used inside SMenuSurface')
|
|
93
|
+
const context = maybeContext
|
|
94
|
+
|
|
95
|
+
export interface Props {
|
|
96
|
+
entry: SMenuInteractiveEntry
|
|
97
|
+
submenuOpen?: boolean
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const props = withDefaults(defineProps<Props>(), { submenuOpen: false })
|
|
101
|
+
const emit = defineEmits<{
|
|
102
|
+
select: [event: SMenuActivationEvent]
|
|
103
|
+
'open-submenu': []
|
|
104
|
+
'pointer-intent': []
|
|
105
|
+
}>()
|
|
106
|
+
const interactiveElement = ref<HTMLElement | null>(null)
|
|
107
|
+
useInteractiveLeafRegistration({ owner: 'SMenuItem' })
|
|
108
|
+
let unregister: (() => void) | undefined
|
|
109
|
+
let suppressNextDestinationSelection = false
|
|
110
|
+
|
|
111
|
+
const destinationTarget = computed(() => props.entry.kind === 'destination'
|
|
112
|
+
? resolveLinkTarget({
|
|
113
|
+
href: props.entry.href,
|
|
114
|
+
to: props.entry.to,
|
|
115
|
+
target: props.entry.target ?? '_self',
|
|
116
|
+
rel: props.entry.rel,
|
|
117
|
+
owner: `SMenuItem(${props.entry.id})`,
|
|
118
|
+
})
|
|
119
|
+
: null)
|
|
120
|
+
const destinationComponent = computed(() => destinationTarget.value?.kind === 'router' ? RouterLink : 'a')
|
|
121
|
+
const destinationBindings = computed(() => destinationTarget.value?.bindings ?? {})
|
|
122
|
+
const itemRole = computed(() => props.entry.kind === 'checkbox'
|
|
123
|
+
? 'menuitemcheckbox'
|
|
124
|
+
: props.entry.kind === 'radio' ? 'menuitemradio' : 'menuitem')
|
|
125
|
+
const checkedState = computed(() => props.entry.kind === 'checkbox' || props.entry.kind === 'radio'
|
|
126
|
+
? props.entry.checked
|
|
127
|
+
: undefined)
|
|
128
|
+
const isCurrent = computed(() => (
|
|
129
|
+
props.entry.kind === 'action' || props.entry.kind === 'destination'
|
|
130
|
+
) && Boolean(props.entry.current && !props.entry.disabled))
|
|
131
|
+
|
|
132
|
+
function requireInteractiveElement(): HTMLElement {
|
|
133
|
+
const element = interactiveElement.value
|
|
134
|
+
if (!element) throw new Error('SMenuItem: interactive element is unavailable')
|
|
135
|
+
return element
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function bindInteractiveVNode(vnode: VNode): void {
|
|
139
|
+
if (!(vnode.el instanceof HTMLElement)) {
|
|
140
|
+
throw new Error('SMenuItem: interactive component must render one HTMLElement root')
|
|
141
|
+
}
|
|
142
|
+
if (interactiveElement.value === vnode.el) return
|
|
143
|
+
unregister?.()
|
|
144
|
+
interactiveElement.value = vnode.el
|
|
145
|
+
unregister = context.register({
|
|
146
|
+
entryId: props.entry.id,
|
|
147
|
+
label: () => props.entry.label,
|
|
148
|
+
hasSubmenu: () => props.entry.kind === 'submenu',
|
|
149
|
+
element: requireInteractiveElement,
|
|
150
|
+
setTabStop: (active) => { requireInteractiveElement().tabIndex = active ? 0 : -1 },
|
|
151
|
+
focus: () => requireInteractiveElement().focus(),
|
|
152
|
+
isFocused: () => document.activeElement === interactiveElement.value,
|
|
153
|
+
ownsEventTarget: (target) => target instanceof Node && (
|
|
154
|
+
target === interactiveElement.value || requireInteractiveElement().contains(target)
|
|
155
|
+
),
|
|
156
|
+
activate: activateFromKeyboard,
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function unbindInteractiveElement(): void {
|
|
161
|
+
unregister?.()
|
|
162
|
+
unregister = undefined
|
|
163
|
+
interactiveElement.value = null
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function handleSelect(event: MouseEvent): void {
|
|
167
|
+
if (props.entry.disabled) {
|
|
168
|
+
event.preventDefault()
|
|
169
|
+
event.stopPropagation()
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
if (props.entry.kind === 'submenu') {
|
|
173
|
+
emit('open-submenu')
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
emit('select', event)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function handleDestinationClick(event: MouseEvent): void {
|
|
180
|
+
if (suppressNextDestinationSelection && event.detail === 0) {
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
suppressNextDestinationSelection = false
|
|
184
|
+
emit('select', event)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function activateFromKeyboard(event: KeyboardEvent): void {
|
|
188
|
+
if (props.entry.disabled) return
|
|
189
|
+
if (props.entry.kind === 'submenu') {
|
|
190
|
+
event.preventDefault()
|
|
191
|
+
emit('open-submenu')
|
|
192
|
+
return
|
|
193
|
+
}
|
|
194
|
+
if (props.entry.kind === 'destination') {
|
|
195
|
+
emit('select', event)
|
|
196
|
+
const navigationPrevented = event.defaultPrevented
|
|
197
|
+
event.preventDefault()
|
|
198
|
+
if (!navigationPrevented) {
|
|
199
|
+
suppressNextDestinationSelection = true
|
|
200
|
+
try {
|
|
201
|
+
requireInteractiveElement().click()
|
|
202
|
+
} finally {
|
|
203
|
+
suppressNextDestinationSelection = false
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
event.preventDefault()
|
|
209
|
+
emit('select', event)
|
|
210
|
+
}
|
|
211
|
+
</script>
|
|
212
|
+
|
|
213
|
+
<style lang="postcss" src="./SMenuItem.css" scoped></style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.s-menu-layer {
|
|
2
|
+
position: fixed;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.s-menu-layer--dropdown {
|
|
6
|
+
--s-menu-surface-width: max-content;
|
|
7
|
+
--s-menu-surface-min-width: 12rem;
|
|
8
|
+
--s-menu-surface-max-width: 90vw;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.s-menu-layer--context {
|
|
12
|
+
--s-menu-surface-width: min(24rem, calc(100vw - 10px));
|
|
13
|
+
--s-menu-surface-min-width: 14rem;
|
|
14
|
+
--s-menu-surface-max-width: calc(100vw - 10px);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.s-menu-layer--submenu {
|
|
18
|
+
--s-menu-surface-width: max-content;
|
|
19
|
+
--s-menu-surface-min-width: var(--s-menu-inline-size-min);
|
|
20
|
+
--s-menu-surface-max-width: var(--s-menu-inline-size-max);
|
|
21
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="layerRef"
|
|
4
|
+
class="s-menu-layer"
|
|
5
|
+
:class="[
|
|
6
|
+
`s-menu-layer--${kind}`,
|
|
7
|
+
kind === 'context' ? 's-context-menu' : kind === 'dropdown' ? 's-dropdown-menu-items' : 's-submenu-items',
|
|
8
|
+
]"
|
|
9
|
+
:data-kind="kind"
|
|
10
|
+
role="region"
|
|
11
|
+
:aria-label="landmarkLabel"
|
|
12
|
+
:style="layerStyle"
|
|
13
|
+
>
|
|
14
|
+
<slot />
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { computed, ref } from 'vue'
|
|
20
|
+
import type { ElementApi } from '../../../internal/interactiveElement'
|
|
21
|
+
|
|
22
|
+
export type SMenuLayerApi = ElementApi<HTMLDivElement>
|
|
23
|
+
|
|
24
|
+
interface Props {
|
|
25
|
+
kind: 'dropdown' | 'context' | 'submenu'
|
|
26
|
+
landmarkLabel: string
|
|
27
|
+
position: { left: number; top: number }
|
|
28
|
+
zIndex: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const props = defineProps<Props>()
|
|
32
|
+
const layerRef = ref<HTMLDivElement | null>(null)
|
|
33
|
+
const layerStyle = computed(() => ({
|
|
34
|
+
left: `${props.position.left}px`,
|
|
35
|
+
top: `${props.position.top}px`,
|
|
36
|
+
zIndex: props.zIndex,
|
|
37
|
+
}))
|
|
38
|
+
|
|
39
|
+
const getElement = (): HTMLDivElement => {
|
|
40
|
+
const element = layerRef.value
|
|
41
|
+
if (!element) throw new Error('SMenuLayer: layer element is unavailable')
|
|
42
|
+
return element
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
defineExpose<SMenuLayerApi>({ getElement })
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<style lang="postcss" src="./SMenuLayer.css" scoped></style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="s-menu-separator" role="separator" :data-menu-entry-id="entryId" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
defineOptions({ inheritAttrs: false })
|
|
7
|
+
|
|
8
|
+
defineProps<{
|
|
9
|
+
entryId: string
|
|
10
|
+
}>()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<style lang="postcss" src="./SMenuSeparator.css" scoped></style>
|