@ds-mo/ui 14.23.0 → 14.25.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/dist/.package-ready.json +1 -1
- package/dist/agent-patterns.json +10 -7
- package/dist/agent.json +59 -15
- package/dist/angular/ds-bar-title.d.ts +1 -1
- package/dist/angular/ds-bar-title.js +3 -3
- package/dist/angular/ds-button-filled.d.ts +3 -1
- package/dist/angular/ds-button-filled.js +7 -4
- package/dist/angular/ds-button-unfilled.d.ts +3 -1
- package/dist/angular/ds-button-unfilled.js +7 -4
- package/dist/components/ds-agent-questionnaire.js +1 -1
- package/dist/components/ds-agent-response.js +1 -1
- package/dist/components/ds-banner.js +1 -1
- package/dist/components/ds-bar-nav.js +1 -1
- package/dist/components/ds-bar-title.js +1 -1
- package/dist/components/ds-bar-workflow.js +1 -1
- package/dist/components/ds-button-filled.js +1 -1
- package/dist/components/ds-button-unfilled.js +1 -1
- package/dist/components/ds-card-chart.js +1 -1
- package/dist/components/ds-card-setting.js +1 -1
- package/dist/components/ds-code-block.js +1 -1
- package/dist/components/ds-filter-menu.js +1 -1
- package/dist/components/ds-input.js +1 -1
- package/dist/components/ds-markdown.js +1 -1
- package/dist/components/ds-message-actions.js +1 -1
- package/dist/components/ds-message-composer.js +1 -1
- package/dist/components/ds-message-scroller.js +1 -1
- package/dist/components/ds-mobile-sheet-nav.js +1 -1
- package/dist/components/ds-modal.js +1 -1
- package/dist/components/ds-pagination.js +1 -1
- package/dist/components/ds-panel-nav.js +1 -1
- package/dist/components/ds-panel-tool-header.js +1 -1
- package/dist/components/ds-panel-tool-search.js +1 -1
- package/dist/components/ds-panel-tools.js +1 -1
- package/dist/components/ds-select.js +1 -1
- package/dist/components/ds-shell-app.js +1 -1
- package/dist/components/ds-shell-app.js.map +1 -1
- package/dist/components/ds-shell-tools.js +1 -1
- package/dist/components/ds-table-filter.js +1 -1
- package/dist/components/ds-table-group.js +1 -1
- package/dist/components/ds-table-saved-views.js +1 -1
- package/dist/components/ds-table-search.js +1 -1
- package/dist/components/ds-table-sort.js +1 -1
- package/dist/components/ds-table.js +1 -1
- package/dist/components/ds-table.js.map +1 -1
- package/dist/components/ds-toast.js +1 -1
- package/dist/components/p-BR1ayqMU.js +2 -0
- package/dist/components/p-BR1ayqMU.js.map +1 -0
- package/dist/components/{p-DzVYGJJv.js → p-BSRIF4m8.js} +2 -2
- package/dist/components/{p-FitB53eM.js → p-BZlhBJZL.js} +2 -2
- package/dist/components/{p-BmqnrfTf.js → p-Bo6uW_8T.js} +2 -2
- package/dist/components/{p-BIaHDBfP.js → p-Bq8svcPs.js} +2 -2
- package/dist/components/{p-DAFR4U9P.js → p-BqbdABo3.js} +2 -2
- package/dist/components/{p-nVv71P3f.js → p-CEXchU5N.js} +2 -2
- package/dist/components/p-CEfxLsbX.js +2 -0
- package/dist/components/p-CEfxLsbX.js.map +1 -0
- package/dist/components/{p-DXbryJHz.js → p-CYMKmJ2s.js} +2 -2
- package/dist/components/{p-C13fWp2x.js → p-CZHIkVgj.js} +2 -2
- package/dist/components/{p-CL0tECXf.js → p-CZjjDhUl.js} +2 -2
- package/dist/components/{p-Bd-Kpekh.js → p-C_FFU6W3.js} +2 -2
- package/dist/components/{p-CilwchJH.js → p-CglHiyY2.js} +2 -2
- package/dist/components/{p-9M0ak2q_.js → p-DLaN9BPq.js} +2 -2
- package/dist/components/{p-CrYJnDev.js → p-DiS5BgLA.js} +2 -2
- package/dist/components/{p-DiyO47xX.js → p-PXdvBMXB.js} +2 -2
- package/dist/components/{p-7MWaWl8w.js → p-kslioYhf.js} +2 -2
- package/dist/components/p-kslioYhf.js.map +1 -0
- package/dist/docs/components.json +257 -30
- package/dist/lib/components/BarTitle/bar-title-types.d.ts +54 -1
- package/dist/lib/components/ButtonFilled/ButtonFilled.d.ts +12 -1
- package/dist/lib/components/ShellApp/shell-app-types.d.ts +3 -1
- package/dist/lib/shell/index.d.ts +1 -0
- package/dist/mcp-data/registry/bar-title.json +34 -12
- package/dist/mcp-data/registry/button-filled.json +60 -6
- package/dist/mcp-data/registry/button-unfilled.json +60 -6
- package/dist/mcp-data/registry/registry.json +58 -14
- package/dist/mcp-data/registry/shell-app.json +7 -2
- package/dist/mcp-data/registry/table.json +3 -3
- package/dist/react/ds-button-filled.d.ts +1 -0
- package/dist/react/ds-button-filled.js +4 -1
- package/dist/react/ds-button-unfilled.d.ts +1 -0
- package/dist/react/ds-button-unfilled.js +1 -0
- package/dist/styles/table.css +13 -1
- package/dist/types/components/BarTitle/BarTitle.d.ts +19 -6
- package/dist/types/components/BarTitle/bar-title-actions.d.ts +11 -0
- package/dist/types/components/BarTitle/bar-title-types.d.ts +54 -1
- package/dist/types/components/BarTitle/index.d.ts +1 -1
- package/dist/types/components/ButtonFilled/ButtonFilled.d.ts +12 -1
- package/dist/types/components/ButtonUnfilled/ButtonUnfilled.d.ts +12 -1
- package/dist/types/components/ShellApp/ShellApp.d.ts +12 -0
- package/dist/types/components/ShellApp/shell-app-types.d.ts +3 -1
- package/dist/types/components/Table/Table.d.ts +2 -2
- package/dist/types/components/Table/table-row-view.d.ts +2 -1
- package/dist/types/components.d.ts +60 -4
- package/dist/types/shell/index.d.ts +1 -0
- package/dist/types/utils/button-story-foundation.d.ts +2 -0
- package/dist/vue/ds-bar-title.js +1 -0
- package/dist/vue/ds-button-filled.js +6 -2
- package/dist/vue/ds-button-unfilled.js +4 -0
- package/package.json +1 -1
- package/dist/components/p--68f7nIx.js +0 -2
- package/dist/components/p--68f7nIx.js.map +0 -1
- package/dist/components/p-7MWaWl8w.js.map +0 -1
- package/dist/components/p-BnTPuV3x.js +0 -2
- package/dist/components/p-BnTPuV3x.js.map +0 -1
- /package/dist/components/{p-DzVYGJJv.js.map → p-BSRIF4m8.js.map} +0 -0
- /package/dist/components/{p-FitB53eM.js.map → p-BZlhBJZL.js.map} +0 -0
- /package/dist/components/{p-BmqnrfTf.js.map → p-Bo6uW_8T.js.map} +0 -0
- /package/dist/components/{p-BIaHDBfP.js.map → p-Bq8svcPs.js.map} +0 -0
- /package/dist/components/{p-DAFR4U9P.js.map → p-BqbdABo3.js.map} +0 -0
- /package/dist/components/{p-nVv71P3f.js.map → p-CEXchU5N.js.map} +0 -0
- /package/dist/components/{p-DXbryJHz.js.map → p-CYMKmJ2s.js.map} +0 -0
- /package/dist/components/{p-C13fWp2x.js.map → p-CZHIkVgj.js.map} +0 -0
- /package/dist/components/{p-CL0tECXf.js.map → p-CZjjDhUl.js.map} +0 -0
- /package/dist/components/{p-Bd-Kpekh.js.map → p-C_FFU6W3.js.map} +0 -0
- /package/dist/components/{p-CilwchJH.js.map → p-CglHiyY2.js.map} +0 -0
- /package/dist/components/{p-9M0ak2q_.js.map → p-DLaN9BPq.js.map} +0 -0
- /package/dist/components/{p-CrYJnDev.js.map → p-DiS5BgLA.js.map} +0 -0
- /package/dist/components/{p-DiyO47xX.js.map → p-PXdvBMXB.js.map} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "bar-title",
|
|
4
4
|
"title": "BarTitle",
|
|
5
|
-
"description": "Page-level title chrome with
|
|
5
|
+
"description": "Page-level title chrome with route identity, responsive ordered button, icon, menu, split, and overflow actions, plus explicit expanded, compact, or constrained variants.",
|
|
6
6
|
"type": "registry:ui",
|
|
7
7
|
"meta": {
|
|
8
8
|
"library": "@ds-mo/ui",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"intent": {
|
|
14
14
|
"audience": "general",
|
|
15
15
|
"status": "stable",
|
|
16
|
-
"summary": "Page-level title chrome with
|
|
16
|
+
"summary": "Page-level title chrome with route identity, responsive ordered button, icon, menu, split, and overflow actions, plus explicit expanded, compact, or constrained variants.",
|
|
17
17
|
"useWhen": [
|
|
18
18
|
"A top-level page needs one h1 above its content.",
|
|
19
19
|
"A list or detail page has multiple route-level sections that belong in the inline active-section menu.",
|
|
20
20
|
"A detail page needs route ancestors in expanded presentation and a page-level Back action in compact chrome.",
|
|
21
|
-
"A page needs
|
|
21
|
+
"A page needs an ordered set of primary, secondary, icon, menu, split, or overflow commands."
|
|
22
22
|
],
|
|
23
23
|
"avoidWhen": [
|
|
24
24
|
"The title belongs to a PanelTools drawer or fullscreen pane; use PanelToolHeader through PanelTools instead.",
|
|
@@ -62,15 +62,17 @@
|
|
|
62
62
|
"Provide ordered breadcrumb items for deeper expanded paths and handle dsBreadcrumbSelect when native href navigation is not used; backLabel remains the single-parent expanded fallback.",
|
|
63
63
|
"Keep value synchronized with the current child route; dsSectionChange returns the selected section id.",
|
|
64
64
|
"Section and overflow triggers expose menu relationships and restore focus after selection or dismissal.",
|
|
65
|
-
"Use one filled primary action in the page decision area and mark destructive overflow actions explicitly."
|
|
65
|
+
"Use one filled primary action in the page decision area, give icon and menu triggers specific accessible names, and mark destructive overflow actions explicitly.",
|
|
66
|
+
"Keep every top-level action and nested menu-choice id non-empty and unique; dsAction emits the selected id without adding a parent prefix."
|
|
66
67
|
],
|
|
67
68
|
"states": [
|
|
68
69
|
"Omitting Back, sections, primaryAction, and actions produces the top-level title-only header.",
|
|
69
70
|
"Two or more selectable sections add the inline section trigger; one section does not render a redundant menu.",
|
|
70
71
|
"Dividers in sections or actions create separate Menu groups without becoming selectable rows.",
|
|
71
|
-
"The overflow trigger uses its bordered treatment whenever
|
|
72
|
+
"The overflow trigger uses its bordered treatment whenever any visible action sits beside it; overflow-only presentations keep the trigger borderless.",
|
|
73
|
+
"Ordered actions preserve authored order, but only the first eligible filled button, unfilled button, icon button, labeled menu button, or split button renders beside the title. Remaining commands use the shared overflow, whose rows are text-only. Menu choices and overflowed split commands become separate rows and share the same flat action event.",
|
|
72
74
|
"expanded renders the larger heading, optional description, inset divider, and a full-width caption breadcrumb row above the title. The breadcrumb begins after 32px top padding; the following title and right-side actions share one top alignment. Compact renders 48px chrome with the existing icon Back action; constrained uses compact chrome and moves an auto-collapse primary action into overflow.",
|
|
73
|
-
"
|
|
75
|
+
"The one visible ordered action collapses by default in constrained presentation. Use never for an exceptional action whose hierarchy must remain visible; explicit overflow actions never leave the shared menu.",
|
|
74
76
|
"showDivider=false removes the bottom divider when the surrounding page composition supplies the boundary; showCompactDivider can independently restore or remove that boundary in compact and constrained variants.",
|
|
75
77
|
"placement=shell-bar is reserved for ShellApp panel section navigation. It remains compact, omits description and breadcrumb presentation, and preserves applicable Back, section, primary, and overflow controls."
|
|
76
78
|
],
|
|
@@ -80,15 +82,16 @@
|
|
|
80
82
|
"ShellApp owns shell-bar placement and always selects compact presentation there; mobile continues to use MobileHeader.",
|
|
81
83
|
"When ShellPage owns BarTitle on a secondary desktop or tablet page, its expanded, compact, and constrained presentations all match that canvas; the separate MobileHeader component remains primary.",
|
|
82
84
|
"Compact titles use the shared compact-header geometry and md control inset so top-level headings align with BarNav and inline Back geometry aligns with PanelToolHeader. Long headings and section labels truncate independently while Back and action controls retain complete hit targets and accessible names.",
|
|
83
|
-
"A never-collapse
|
|
85
|
+
"A never-collapse action remains visible in constrained mode; the title and section label yield space first.",
|
|
86
|
+
"On mobile, icon commands remain visible by default while labeled buttons, labeled menus, split buttons, and explicit overflow commands become one flat overflow menu derived by ShellApp."
|
|
84
87
|
],
|
|
85
88
|
"frameworkCaveats": {
|
|
86
89
|
"customElements": [
|
|
87
|
-
"Assign breadcrumbs, sections, primaryAction, and actions as JavaScript properties and replace array or object identities when controlled state changes.",
|
|
90
|
+
"Assign breadcrumbs, sections, actionItems, primaryAction, and actions as JavaScript properties and replace array or object identities when controlled state changes.",
|
|
88
91
|
"Handle dsBack for compact navigation and dsBreadcrumbSelect for application-owned expanded breadcrumb navigation, update value after dsSectionChange, and execute product commands from dsAction."
|
|
89
92
|
],
|
|
90
93
|
"react": [
|
|
91
|
-
"Pass breadcrumb, section, and action arrays directly to DsBarTitle and keep value controlled from route state.",
|
|
94
|
+
"Pass breadcrumb, section, and ordered action arrays directly to DsBarTitle and keep value controlled from route state.",
|
|
92
95
|
"Place DsBarTitle in DsShellPage with slot=header when automatic page behavior is required."
|
|
93
96
|
],
|
|
94
97
|
"angular": [
|
|
@@ -113,6 +116,13 @@
|
|
|
113
116
|
},
|
|
114
117
|
"api": {
|
|
115
118
|
"props": {
|
|
119
|
+
"actionItems": {
|
|
120
|
+
"type": "BarTitleActionConfigItem[]",
|
|
121
|
+
"resolvedType": "BarTitleActionConfigItem[] | undefined",
|
|
122
|
+
"required": false,
|
|
123
|
+
"mutable": false,
|
|
124
|
+
"description": "Ordered page-header actions. When supplied, this replaces the legacy\nprimaryAction/actions presentation while preserving the same dsAction event."
|
|
125
|
+
},
|
|
116
126
|
"actions": {
|
|
117
127
|
"type": "BarTitleActionItem[]",
|
|
118
128
|
"resolvedType": "BarTitleActionItem[]",
|
|
@@ -299,6 +309,13 @@
|
|
|
299
309
|
"slots": []
|
|
300
310
|
},
|
|
301
311
|
"props": {
|
|
312
|
+
"actionItems": {
|
|
313
|
+
"type": "BarTitleActionConfigItem[]",
|
|
314
|
+
"resolvedType": "BarTitleActionConfigItem[] | undefined",
|
|
315
|
+
"required": false,
|
|
316
|
+
"mutable": false,
|
|
317
|
+
"description": "Ordered page-header actions. When supplied, this replaces the legacy\nprimaryAction/actions presentation while preserving the same dsAction event."
|
|
318
|
+
},
|
|
302
319
|
"actions": {
|
|
303
320
|
"type": "BarTitleActionItem[]",
|
|
304
321
|
"resolvedType": "BarTitleActionItem[]",
|
|
@@ -508,7 +525,7 @@
|
|
|
508
525
|
"import": "import { DsBarTitle } from '@ds-mo/ui/angular/ds-bar-title';",
|
|
509
526
|
"example": "<ds-bar-title></ds-bar-title>"
|
|
510
527
|
},
|
|
511
|
-
"complexPropertyNote": "Assign these non-primitive values as JavaScript properties: actions, breadcrumbs, primaryAction, sections.",
|
|
528
|
+
"complexPropertyNote": "Assign these non-primitive values as JavaScript properties: actionItems, actions, breadcrumbs, primaryAction, sections.",
|
|
512
529
|
"peerDependencies": {
|
|
513
530
|
"required": [
|
|
514
531
|
"@ds-mo/tokens ^6.5.1",
|
|
@@ -540,12 +557,17 @@
|
|
|
540
557
|
},
|
|
541
558
|
{
|
|
542
559
|
"path": "src/wc/components/BarTitle/BarTitle.tsx",
|
|
543
|
-
"content": "import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Prop,\n State,\n Watch,\n} from '@stencil/core';\nimport type { BreadcrumbItem, BreadcrumbSelectDetail } from '../Breadcrumb/breadcrumb-types';\nimport type { MenuItemData, MenuSection } from '../Menu/menu-types';\nimport {\n isBarTitleDivider,\n type BarTitleAction,\n type BarTitleActionItem,\n type BarTitlePrimaryAction,\n type BarTitleSection,\n type BarTitleSectionItem,\n type BarTitlePlacement,\n type BarTitleVariant,\n} from './bar-title-types';\n\nlet nextBarTitleId = 0;\n\ntype FocusableButton = HTMLElement & { setFocus?: () => Promise<void> };\n\n@Component({\n tag: 'ds-bar-title',\n styleUrl: 'BarTitle.css',\n scoped: true,\n})\nexport class BarTitle {\n @Element() el!: HTMLElement;\n\n /** The page's single visible h1. */\n @Prop() heading!: string;\n\n /** Optional supporting copy shown in the expanded presentation. */\n @Prop() description: string = '';\n\n /** Show the leading page-level Back action. */\n @Prop({ attribute: 'show-back' }) showBack: boolean = false;\n\n /** Accessible name for the leading Back action. */\n @Prop() backAriaLabel: string = 'Back';\n\n /** Visible parent-page label used by the expanded breadcrumb when breadcrumbs is empty. */\n @Prop() backLabel: string = 'Back';\n\n /** Optional expanded ancestor path. Compact variants continue to use the Back action. */\n @Prop() breadcrumbs: BreadcrumbItem[] = [];\n\n /** Accessible name for the expanded breadcrumb navigation landmark. */\n @Prop() breadcrumbAriaLabel: string = 'Breadcrumb';\n\n /** Optional page sections exposed through the active-section menu. */\n @Prop() sections: BarTitleSectionItem[] = [];\n\n /** Id of the active page section. */\n @Prop() value: string = '';\n\n /** Accessible name for the page-section menu. */\n @Prop() sectionsAriaLabel: string = 'Change page section';\n\n /** The one highest-emphasis page action. */\n @Prop() primaryAction: BarTitlePrimaryAction | null = null;\n\n /** Secondary page actions shown in the overflow menu. Dividers create groups. */\n @Prop() actions: BarTitleActionItem[] = [];\n\n /** Accessible name for the page-actions menu. */\n @Prop() actionsAriaLabel: string = 'More page actions';\n\n /** Explicit visual/capacity variant. ShellPage owns automatic selection. */\n @Prop() variant: BarTitleVariant = 'expanded';\n\n /** Page-header placement, or compact application-shell bar placement. */\n @Prop({ reflect: true }) placement: BarTitlePlacement = 'page';\n\n /** Draw the page-title divider beneath the header. */\n @Prop() showDivider: boolean = true;\n\n /** Override divider visibility for compact and constrained variants. */\n @Prop() showCompactDivider?: boolean;\n\n /** Emitted when the leading Back action is activated. */\n @Event() dsBack!: EventEmitter<MouseEvent>;\n\n /** Emitted when an authored expanded breadcrumb item is activated. */\n @Event({ cancelable: true }) dsBreadcrumbSelect!: EventEmitter<BreadcrumbSelectDetail>;\n\n /** Emitted with the newly selected page-section id. */\n @Event() dsSectionChange!: EventEmitter<string>;\n\n /** Emitted with the activated primary or overflow action id. */\n @Event() dsAction!: EventEmitter<string>;\n\n @State() private sectionMenuOpen = false;\n @State() private actionMenuOpen = false;\n @State() private sectionMenuInitialFocusVisible = false;\n @State() private actionMenuInitialFocusVisible = false;\n\n private readonly instanceId = nextBarTitleId++;\n private readonly sectionMenuTriggerId = `bar-title-section-trigger-${this.instanceId}`;\n private readonly sectionMenuId = `bar-title-section-menu-${this.instanceId}`;\n private readonly actionMenuTriggerId = `bar-title-action-trigger-${this.instanceId}`;\n private readonly actionMenuId = `bar-title-action-menu-${this.instanceId}`;\n private sectionTriggerEl: HTMLButtonElement | null = null;\n private actionTriggerEl: FocusableButton | null = null;\n\n componentWillLoad() {\n if (this.el.closest('ds-shell-page')) {\n this.el.setAttribute('data-shell-page-syncing', '');\n }\n }\n\n @Watch('sections')\n handleSectionsChange() {\n if (!this.hasSectionSelector) this.closeSectionMenu();\n }\n\n @Watch('actions')\n @Watch('primaryAction')\n handleActionsChange() {\n if (!this.showActionMenuTrigger) this.closeActionMenu();\n }\n\n private get compact(): boolean {\n return this.effectiveVariant !== 'expanded';\n }\n\n private get effectiveVariant(): BarTitleVariant {\n return this.placement === 'shell-bar' ? 'compact' : this.variant;\n }\n\n private get dividerVisible(): boolean {\n return this.compact ? (this.showCompactDivider ?? this.showDivider) : this.showDivider;\n }\n\n private get expandedBreadcrumbItems(): BreadcrumbItem[] {\n if (this.breadcrumbs.length > 0) return this.breadcrumbs;\n if (!this.showBack) return [];\n return [\n {\n id: 'back',\n label: this.backLabel,\n ariaLabel: this.backAriaLabel,\n },\n ];\n }\n\n /** Tooltip copy is fixed and generic; backAriaLabel/actionsAriaLabel stay page-specific. */\n private get backTooltipLabel(): string {\n return 'Go back';\n }\n\n private get primaryCollapsed(): boolean {\n return (\n this.effectiveVariant === 'constrained' &&\n this.primaryAction !== null &&\n (this.primaryAction.collapse ?? 'auto') === 'auto'\n );\n }\n\n private get selectableSections(): BarTitleSection[] {\n return this.sections.filter((item): item is BarTitleSection => !isBarTitleDivider(item));\n }\n\n private get hasSectionSelector(): boolean {\n return this.selectableSections.length > 1;\n }\n\n private get effectiveValue(): string {\n return this.selectableSections.some(section => section.id === this.value)\n ? this.value\n : (this.selectableSections[0]?.id ?? '');\n }\n\n private get selectedSectionLabel(): string {\n return this.selectableSections.find(section => section.id === this.effectiveValue)?.label ?? '';\n }\n\n private get sectionTriggerAriaLabel(): string {\n return `${this.sectionsAriaLabel}. Current section: ${this.selectedSectionLabel}`;\n }\n\n private groupsFromItems<T extends BarTitleSection | BarTitleAction>(\n source: Array<T | { type: 'divider' }>,\n map: (item: T) => MenuItemData\n ): MenuSection[] {\n const groups: MenuSection[] = [];\n let items: MenuItemData[] = [];\n const commit = () => {\n if (items.length > 0) groups.push({ items });\n items = [];\n };\n\n for (const item of source) {\n if (isBarTitleDivider(item)) {\n commit();\n } else {\n items.push(map(item));\n }\n }\n commit();\n return groups;\n }\n\n private get sectionMenuSections(): MenuSection[] {\n return this.groupsFromItems(this.sections, section => ({\n label: section.label,\n value: section.id,\n isSelected: section.id === this.effectiveValue,\n isInactive: section.isInactive,\n }));\n }\n\n private get selectableActions(): BarTitleAction[] {\n return this.actions.filter((item): item is BarTitleAction => !isBarTitleDivider(item));\n }\n\n private get showActionMenuTrigger(): boolean {\n return (\n this.selectableActions.length > 0 || (this.primaryCollapsed && this.primaryAction !== null)\n );\n }\n\n private actionMenuItem(action: BarTitleAction | BarTitlePrimaryAction): MenuItemData {\n const primary = action as BarTitlePrimaryAction;\n return {\n label: action.label,\n value: action.id,\n isInactive: action.isInactive || primary.isLoading,\n isDestructive: action.isDestructive || primary.intent === 'negative',\n };\n }\n\n private get actionMenuSections(): MenuSection[] {\n const groups = this.groupsFromItems(this.actions, action => this.actionMenuItem(action));\n if (!this.primaryCollapsed || !this.primaryAction) return groups;\n return [{ items: [this.actionMenuItem(this.primaryAction)] }, ...groups];\n }\n\n private toggleSectionMenu = (event: MouseEvent) => {\n this.sectionMenuInitialFocusVisible = event.detail === 0;\n this.actionMenuOpen = false;\n this.sectionMenuOpen = !this.sectionMenuOpen;\n };\n\n private closeSectionMenu = () => {\n this.sectionMenuOpen = false;\n };\n\n private handleSectionSelect = (event: CustomEvent<MenuItemData>) => {\n const id = String(event.detail?.value ?? '');\n const selected = this.selectableSections.find(section => section.id === id);\n if (!selected || selected.isInactive) return;\n this.closeSectionMenu();\n this.dsSectionChange.emit(id);\n requestAnimationFrame(() => this.sectionTriggerEl?.focus());\n };\n\n private toggleActionMenu = (event: MouseEvent) => {\n this.actionMenuInitialFocusVisible = event.detail === 0;\n this.sectionMenuOpen = false;\n this.actionMenuOpen = !this.actionMenuOpen;\n };\n\n private closeActionMenu = () => {\n this.actionMenuOpen = false;\n };\n\n private handleActionSelect = (event: CustomEvent<MenuItemData>) => {\n const id = String(event.detail?.value ?? '');\n const primaryMatches = this.primaryCollapsed && this.primaryAction?.id === id;\n const action = this.selectableActions.find(candidate => candidate.id === id);\n if (!primaryMatches && !action) return;\n if (\n (primaryMatches && (this.primaryAction?.isInactive || this.primaryAction?.isLoading)) ||\n action?.isInactive\n ) {\n return;\n }\n this.closeActionMenu();\n this.dsAction.emit(id);\n requestAnimationFrame(() => void this.actionTriggerEl?.setFocus?.());\n };\n\n private renderSectionSelector() {\n if (!this.hasSectionSelector) return null;\n return [\n <div class=\"bar-title__divider\" aria-hidden=\"true\" />,\n <div class=\"bar-title__section-selector\">\n <button\n ref={el => {\n this.sectionTriggerEl = el ?? null;\n }}\n id={this.sectionMenuTriggerId}\n class={{\n 'bar-title__section-trigger': true,\n 'bar-title__section-trigger--expanded': this.sectionMenuOpen,\n 'ds-control--md': true,\n 'ds-focus-ring-inset': true,\n 'ds-interaction-fill': true,\n }}\n type=\"button\"\n aria-haspopup=\"menu\"\n aria-controls={this.sectionMenuId}\n aria-expanded={String(this.sectionMenuOpen)}\n aria-label={this.sectionTriggerAriaLabel}\n onClick={this.toggleSectionMenu}\n >\n <ds-text\n class=\"bar-title__section-label ds-interaction-fill__content\"\n as=\"span\"\n variant=\"text-body-medium\"\n emphasis\n color=\"primary\"\n lineTruncation={1}\n >\n {this.selectedSectionLabel}\n </ds-text>\n <ds-icon\n class=\"bar-title__section-chevron ds-interaction-fill__content\"\n name=\"ChevronUpDown\"\n size=\"md\"\n color=\"inherit\"\n aria-hidden=\"true\"\n />\n </button>\n </div>,\n ];\n }\n\n private renderActions() {\n const primary = this.primaryAction;\n if (!primary && !this.showActionMenuTrigger) return null;\n\n return (\n <div class=\"bar-title__actions\">\n {primary && !this.primaryCollapsed ? (\n <ds-button-filled\n class=\"bar-title__primary-action\"\n variant={primary.icon ? 'icon-label' : 'label'}\n icon={primary.icon ?? ''}\n label={primary.label}\n intent={primary.intent ?? 'brand'}\n contrast={primary.contrast ?? 'bold'}\n size=\"md\"\n type={primary.type ?? 'button'}\n isInactive={primary.isInactive}\n isLoading={primary.isLoading}\n onDsClick={() => this.dsAction.emit(primary.id)}\n />\n ) : null}\n {this.showActionMenuTrigger ? (\n <ds-tooltip label=\"Page options\" side=\"bottom\" size=\"sm\">\n <ds-button-unfilled\n ref={el => {\n this.actionTriggerEl = el ?? null;\n }}\n id={this.actionMenuTriggerId}\n class=\"bar-title__more-actions\"\n variant=\"icon\"\n icon=\"Ellipses\"\n aria-label={this.actionsAriaLabel}\n size=\"md\"\n activeFill={!this.compact}\n hasBorder={primary !== null && !this.primaryCollapsed}\n haspopup=\"menu\"\n controls={this.actionMenuId}\n expanded={this.actionMenuOpen}\n onDsClick={(event: CustomEvent<MouseEvent>) => this.toggleActionMenu(event.detail)}\n />\n </ds-tooltip>\n ) : null}\n </div>\n );\n }\n\n private handleBreadcrumbSelect = (event: CustomEvent<BreadcrumbSelectDetail>) => {\n if (this.breadcrumbs.length === 0) {\n this.dsBack.emit(event.detail.originalEvent);\n return;\n }\n const forwarded = this.dsBreadcrumbSelect.emit(event.detail);\n if (forwarded.defaultPrevented) event.preventDefault();\n };\n\n private renderBreadcrumb() {\n const items = this.expandedBreadcrumbItems;\n if (items.length === 0) return null;\n return (\n <ds-breadcrumb\n class=\"bar-title__breadcrumb\"\n items={items}\n ariaLabel={this.breadcrumbAriaLabel}\n onDsSelect={this.handleBreadcrumbSelect}\n />\n );\n }\n\n private renderBack() {\n if (!this.showBack) return null;\n return (\n <ds-tooltip label={this.backTooltipLabel} side=\"bottom\" size=\"sm\">\n <ds-button-unfilled\n class=\"bar-title__back\"\n variant=\"icon\"\n icon=\"ChevronLeft\"\n aria-label={this.backAriaLabel}\n size=\"md\"\n activeFill={false}\n hasBorder={false}\n onDsClick={(event: CustomEvent<MouseEvent>) => this.dsBack.emit(event.detail)}\n />\n </ds-tooltip>\n );\n }\n\n render() {\n const compact = this.compact;\n return (\n <Host\n class={{\n 'bar-title-host--compact': compact,\n 'bar-title-host--expanded': this.effectiveVariant === 'expanded',\n 'bar-title-host--constrained': this.effectiveVariant === 'constrained',\n 'bar-title-host--has-description': !!this.description,\n 'bar-title-host--has-back': this.showBack,\n 'bar-title-host--has-breadcrumb': !compact && this.expandedBreadcrumbItems.length > 0,\n 'bar-title-host--shell-bar': this.placement === 'shell-bar',\n }}\n >\n <div\n class={{\n 'bar-title': true,\n 'bar-title--divider-hidden': !this.dividerVisible,\n 'ds-chrome-header': compact,\n }}\n >\n <div class=\"bar-title__inner\">\n {!compact ? this.renderBreadcrumb() : null}\n <div class=\"bar-title__row\">\n <div class=\"bar-title__leading\">\n <div class=\"bar-title__title-row\" data-shell-page-header-anchor>\n <div class=\"bar-title__identity\">\n {compact ? this.renderBack() : null}\n <ds-text\n class=\"bar-title__heading ds-control--md\"\n variant={compact ? 'text-title-small' : 'text-title-medium'}\n emphasis\n color=\"primary\"\n as=\"h1\"\n lineTruncation={1}\n >\n {this.heading}\n </ds-text>\n </div>\n {this.renderSectionSelector()}\n </div>\n {this.description && !compact ? (\n <ds-text\n class=\"bar-title__description\"\n variant=\"text-body-small\"\n color=\"secondary\"\n lineTruncation={2}\n wrap=\"wrap\"\n as=\"p\"\n >\n {this.description}\n </ds-text>\n ) : null}\n </div>\n {this.renderActions()}\n </div>\n </div>\n </div>\n\n {this.hasSectionSelector ? (\n <ds-menu\n id={this.sectionMenuId}\n class=\"bar-title__section-menu\"\n anchorId={this.sectionMenuTriggerId}\n menuLabel={this.sectionsAriaLabel}\n open={this.sectionMenuOpen}\n initialFocusVisible={this.sectionMenuInitialFocusVisible}\n sections={this.sectionMenuSections}\n onDsClose={this.closeSectionMenu}\n onDsSelect={this.handleSectionSelect}\n />\n ) : null}\n\n {this.showActionMenuTrigger ? (\n <ds-menu\n id={this.actionMenuId}\n class=\"bar-title__action-menu\"\n anchorId={this.actionMenuTriggerId}\n align=\"end\"\n menuLabel={this.actionsAriaLabel}\n open={this.actionMenuOpen}\n initialFocusVisible={this.actionMenuInitialFocusVisible}\n sections={this.actionMenuSections}\n onDsClose={this.closeActionMenu}\n onDsSelect={this.handleActionSelect}\n />\n ) : null}\n </Host>\n );\n }\n}\n",
|
|
560
|
+
"content": "import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Prop,\n State,\n Watch,\n} from '@stencil/core';\nimport type { BreadcrumbItem, BreadcrumbSelectDetail } from '../Breadcrumb/breadcrumb-types';\nimport type { MenuItemData, MenuSection } from '../Menu/menu-types';\nimport {\n isBarTitleDivider,\n type BarTitleActionConfigItem,\n type BarTitleActionItem,\n type BarTitleMenuAction,\n type BarTitlePrimaryAction,\n type BarTitleSection,\n type BarTitleSectionItem,\n type BarTitlePlacement,\n type BarTitleSplitAction,\n type BarTitleVariant,\n} from './bar-title-types';\nimport {\n barTitleActionIdIssues,\n barTitleChoiceSections,\n findBarTitleAction,\n overflowBarTitleActionSections,\n resolveBarTitleActionItems,\n visibleBarTitleActions,\n} from './bar-title-actions';\n\nlet nextBarTitleId = 0;\n\ntype FocusableButton = HTMLElement & {\n setFocus?: (segment?: 'primary' | 'menu') => Promise<void>;\n};\n\n@Component({\n tag: 'ds-bar-title',\n styleUrl: 'BarTitle.css',\n scoped: true,\n})\nexport class BarTitle {\n @Element() el!: HTMLElement;\n\n /** The page's single visible h1. */\n @Prop() heading!: string;\n\n /** Optional supporting copy shown in the expanded presentation. */\n @Prop() description: string = '';\n\n /** Show the leading page-level Back action. */\n @Prop({ attribute: 'show-back' }) showBack: boolean = false;\n\n /** Accessible name for the leading Back action. */\n @Prop() backAriaLabel: string = 'Back';\n\n /** Visible parent-page label used by the expanded breadcrumb when breadcrumbs is empty. */\n @Prop() backLabel: string = 'Back';\n\n /** Optional expanded ancestor path. Compact variants continue to use the Back action. */\n @Prop() breadcrumbs: BreadcrumbItem[] = [];\n\n /** Accessible name for the expanded breadcrumb navigation landmark. */\n @Prop() breadcrumbAriaLabel: string = 'Breadcrumb';\n\n /** Optional page sections exposed through the active-section menu. */\n @Prop() sections: BarTitleSectionItem[] = [];\n\n /** Id of the active page section. */\n @Prop() value: string = '';\n\n /** Accessible name for the page-section menu. */\n @Prop() sectionsAriaLabel: string = 'Change page section';\n\n /** The one highest-emphasis page action. */\n @Prop() primaryAction: BarTitlePrimaryAction | null = null;\n\n /** Secondary page actions shown in the overflow menu. Dividers create groups. */\n @Prop() actions: BarTitleActionItem[] = [];\n\n /**\n * Ordered page-header actions. When supplied, this replaces the legacy\n * primaryAction/actions presentation while preserving the same dsAction event.\n */\n @Prop() actionItems?: BarTitleActionConfigItem[];\n\n /** Accessible name for the page-actions menu. */\n @Prop() actionsAriaLabel: string = 'More page actions';\n\n /** Explicit visual/capacity variant. ShellPage owns automatic selection. */\n @Prop() variant: BarTitleVariant = 'expanded';\n\n /** Page-header placement, or compact application-shell bar placement. */\n @Prop({ reflect: true }) placement: BarTitlePlacement = 'page';\n\n /** Draw the page-title divider beneath the header. */\n @Prop() showDivider: boolean = true;\n\n /** Override divider visibility for compact and constrained variants. */\n @Prop() showCompactDivider?: boolean;\n\n /** Emitted when the leading Back action is activated. */\n @Event() dsBack!: EventEmitter<MouseEvent>;\n\n /** Emitted when an authored expanded breadcrumb item is activated. */\n @Event({ cancelable: true }) dsBreadcrumbSelect!: EventEmitter<BreadcrumbSelectDetail>;\n\n /** Emitted with the newly selected page-section id. */\n @Event() dsSectionChange!: EventEmitter<string>;\n\n /** Emitted with the activated primary or overflow action id. */\n @Event() dsAction!: EventEmitter<string>;\n\n @State() private sectionMenuOpen = false;\n @State() private openActionMenuId = '';\n @State() private sectionMenuInitialFocusVisible = false;\n @State() private actionMenuInitialFocusVisible = false;\n\n private readonly instanceId = nextBarTitleId++;\n private readonly sectionMenuTriggerId = `bar-title-section-trigger-${this.instanceId}`;\n private readonly sectionMenuId = `bar-title-section-menu-${this.instanceId}`;\n private readonly actionMenuTriggerId = `bar-title-action-trigger-${this.instanceId}`;\n private readonly actionMenuId = `bar-title-action-menu-${this.instanceId}`;\n private sectionTriggerEl: HTMLButtonElement | null = null;\n private actionTriggerEl: FocusableButton | null = null;\n private actionTriggerEls = new Map<string, FocusableButton>();\n\n componentWillLoad() {\n if (this.el.closest('ds-shell-page')) {\n this.el.setAttribute('data-shell-page-syncing', '');\n }\n this.reportActionIdIssues();\n }\n\n @Watch('sections')\n handleSectionsChange() {\n if (!this.hasSectionSelector) this.closeSectionMenu();\n }\n\n @Watch('actions')\n @Watch('primaryAction')\n @Watch('actionItems')\n handleActionsChange() {\n this.reportActionIdIssues();\n if (!this.availableActionMenuIds.has(this.openActionMenuId)) this.closeActionMenu();\n }\n\n private reportActionIdIssues() {\n for (const issue of barTitleActionIdIssues(this.resolvedActionItems)) {\n console.warn(`[ds-bar-title] ${issue}`);\n }\n }\n\n private get compact(): boolean {\n return this.effectiveVariant !== 'expanded';\n }\n\n private get effectiveVariant(): BarTitleVariant {\n return this.placement === 'shell-bar' ? 'compact' : this.variant;\n }\n\n private get dividerVisible(): boolean {\n return this.compact ? (this.showCompactDivider ?? this.showDivider) : this.showDivider;\n }\n\n private get expandedBreadcrumbItems(): BreadcrumbItem[] {\n if (this.breadcrumbs.length > 0) return this.breadcrumbs;\n if (!this.showBack) return [];\n return [\n {\n id: 'back',\n label: this.backLabel,\n ariaLabel: this.backAriaLabel,\n },\n ];\n }\n\n /** Tooltip copy is fixed and generic; backAriaLabel/actionsAriaLabel stay page-specific. */\n private get backTooltipLabel(): string {\n return 'Go back';\n }\n\n private get primaryCollapsed(): boolean {\n return (\n this.actionItems === undefined &&\n this.effectiveVariant === 'constrained' &&\n this.primaryAction !== null &&\n (this.primaryAction.collapse ?? 'auto') === 'auto'\n );\n }\n\n private get selectableSections(): BarTitleSection[] {\n return this.sections.filter((item): item is BarTitleSection => !isBarTitleDivider(item));\n }\n\n private get hasSectionSelector(): boolean {\n return this.selectableSections.length > 1;\n }\n\n private get effectiveValue(): string {\n return this.selectableSections.some(section => section.id === this.value)\n ? this.value\n : (this.selectableSections[0]?.id ?? '');\n }\n\n private get selectedSectionLabel(): string {\n return this.selectableSections.find(section => section.id === this.effectiveValue)?.label ?? '';\n }\n\n private get sectionTriggerAriaLabel(): string {\n return `${this.sectionsAriaLabel}. Current section: ${this.selectedSectionLabel}`;\n }\n\n private groupsFromSections(): MenuSection[] {\n const groups: MenuSection[] = [];\n let items: MenuItemData[] = [];\n const commit = () => {\n if (items.length > 0) groups.push({ items });\n items = [];\n };\n\n for (const item of this.sections) {\n if (isBarTitleDivider(item)) {\n commit();\n } else {\n items.push({\n label: item.label,\n value: item.id,\n isSelected: item.id === this.effectiveValue,\n isInactive: item.isInactive,\n });\n }\n }\n commit();\n return groups;\n }\n\n private get sectionMenuSections(): MenuSection[] {\n return this.groupsFromSections();\n }\n\n private get resolvedActionItems(): BarTitleActionConfigItem[] {\n return resolveBarTitleActionItems(this.actionItems, this.primaryAction, this.actions);\n }\n\n private get visibleActions(): BarTitleActionConfigItem[] {\n return visibleBarTitleActions(this.resolvedActionItems, this.effectiveVariant);\n }\n\n private get actionMenuSections(): MenuSection[] {\n return overflowBarTitleActionSections(this.resolvedActionItems, this.effectiveVariant);\n }\n\n private get showActionMenuTrigger(): boolean {\n return this.actionMenuSections.length > 0;\n }\n\n private get availableActionMenuIds(): Set<string> {\n const ids = new Set<string>();\n if (this.showActionMenuTrigger) ids.add('__overflow');\n for (const item of this.visibleActions) {\n if (!isBarTitleDivider(item) && (item.type === 'menu' || item.type === 'split')) {\n ids.add(item.id);\n }\n }\n return ids;\n }\n\n private actionMenuDomId(id: string): string {\n const index = this.resolvedActionItems.findIndex(\n item => !isBarTitleDivider(item) && item.id === id\n );\n return `bar-title-action-menu-${this.instanceId}-${index}`;\n }\n\n private actionMenuAnchor(id: string): HTMLElement | undefined {\n if (id === '__overflow') return this.actionTriggerEl ?? undefined;\n const trigger = this.actionTriggerEls.get(id);\n if (!trigger) return undefined;\n const splitMenu = trigger.querySelector<HTMLElement>('.ds-button-split__menu');\n return splitMenu ?? trigger;\n }\n\n private menuSectionsForAction(action: BarTitleMenuAction | BarTitleSplitAction): MenuSection[] {\n return barTitleChoiceSections(action.choices);\n }\n\n private toggleSectionMenu = (event: MouseEvent) => {\n this.sectionMenuInitialFocusVisible = event.detail === 0;\n this.openActionMenuId = '';\n this.sectionMenuOpen = !this.sectionMenuOpen;\n };\n\n private closeSectionMenu = () => {\n this.sectionMenuOpen = false;\n };\n\n private handleSectionSelect = (event: CustomEvent<MenuItemData>) => {\n const id = String(event.detail?.value ?? '');\n const selected = this.selectableSections.find(section => section.id === id);\n if (!selected || selected.isInactive) return;\n this.closeSectionMenu();\n this.dsSectionChange.emit(id);\n requestAnimationFrame(() => this.sectionTriggerEl?.focus());\n };\n\n private toggleActionMenu = (id: string, event: MouseEvent) => {\n this.actionMenuInitialFocusVisible = event.detail === 0;\n this.sectionMenuOpen = false;\n this.openActionMenuId = this.openActionMenuId === id ? '' : id;\n };\n\n private closeActionMenu = () => {\n this.openActionMenuId = '';\n };\n\n private handleActionSelect = (event: CustomEvent<MenuItemData>) => {\n const id = String(event.detail?.value ?? '');\n const action = findBarTitleAction(this.resolvedActionItems, id);\n if (!action || action.isInactive || ('isLoading' in action && action.isLoading)) return;\n const menuId = this.openActionMenuId;\n this.closeActionMenu();\n this.dsAction.emit(id);\n requestAnimationFrame(() => {\n if (menuId === '__overflow') {\n void this.actionTriggerEl?.setFocus?.();\n return;\n }\n const trigger = this.actionTriggerEls.get(menuId);\n if ('setFocus' in (trigger ?? {})) {\n const split = this.resolvedActionItems.some(\n item => !isBarTitleDivider(item) && item.id === menuId && item.type === 'split'\n );\n void trigger?.setFocus?.(split ? 'menu' : undefined);\n }\n });\n };\n\n private renderSectionSelector() {\n if (!this.hasSectionSelector) return null;\n return [\n <div class=\"bar-title__divider\" aria-hidden=\"true\" />,\n <div class=\"bar-title__section-selector\">\n <button\n ref={el => {\n this.sectionTriggerEl = el ?? null;\n }}\n id={this.sectionMenuTriggerId}\n class={{\n 'bar-title__section-trigger': true,\n 'bar-title__section-trigger--expanded': this.sectionMenuOpen,\n 'ds-control--md': true,\n 'ds-focus-ring-inset': true,\n 'ds-interaction-fill': true,\n }}\n type=\"button\"\n aria-haspopup=\"menu\"\n aria-controls={this.sectionMenuId}\n aria-expanded={String(this.sectionMenuOpen)}\n aria-label={this.sectionTriggerAriaLabel}\n onClick={this.toggleSectionMenu}\n >\n <ds-text\n class=\"bar-title__section-label ds-interaction-fill__content\"\n as=\"span\"\n variant=\"text-body-medium\"\n emphasis\n color=\"primary\"\n lineTruncation={1}\n >\n {this.selectedSectionLabel}\n </ds-text>\n <ds-icon\n class=\"bar-title__section-chevron ds-interaction-fill__content\"\n name=\"ChevronUpDown\"\n size=\"md\"\n color=\"inherit\"\n aria-hidden=\"true\"\n />\n </button>\n </div>,\n ];\n }\n\n private renderVisibleAction(action: BarTitleActionConfigItem) {\n if (isBarTitleDivider(action) || action.type === 'overflow') return null;\n const appearance = action.appearance ?? (action.type === 'split' ? 'filled' : 'unfilled');\n const variant: 'icon' | 'icon-label' | 'label' =\n action.type === 'icon' ? 'icon' : action.icon ? 'icon-label' : 'label';\n const menu = action.type === 'menu';\n const menuId = menu ? this.actionMenuDomId(action.id) : undefined;\n\n if (action.type === 'split') {\n const splitMenuId = this.actionMenuDomId(action.id);\n const splitProps = {\n key: action.id,\n ref: (el: FocusableButton | undefined) => {\n if (el) this.actionTriggerEls.set(action.id, el);\n else this.actionTriggerEls.delete(action.id);\n },\n class: 'bar-title__action bar-title__split-action',\n split: true,\n variant,\n label: action.label,\n icon: action.icon ?? '',\n menuAriaLabel: action.menuAriaLabel,\n controls: splitMenuId,\n expanded: this.openActionMenuId === action.id,\n size: 'md' as const,\n type: action.buttonType ?? 'button',\n isInactive: action.isInactive,\n isLoading: action.isLoading,\n onDsClick: () => this.dsAction.emit(action.id),\n onDsMenuClick: (event: CustomEvent<MouseEvent>) =>\n this.toggleActionMenu(action.id, event.detail),\n };\n return appearance === 'filled' ? (\n <ds-button-filled\n {...splitProps}\n intent={action.intent ?? 'brand'}\n contrast={action.contrast ?? 'bold'}\n />\n ) : (\n <ds-button-unfilled {...splitProps} />\n );\n }\n\n const buttonProps = {\n key: action.id,\n ref: (el: FocusableButton | undefined) => {\n if (el) this.actionTriggerEls.set(action.id, el);\n else this.actionTriggerEls.delete(action.id);\n },\n class: `bar-title__action bar-title__action--${action.type}${\n this.actionItems === undefined && action.id === this.primaryAction?.id\n ? ' bar-title__primary-action'\n : ''\n }`,\n variant,\n icon: action.icon ?? '',\n label: action.label,\n ariaLabel: action.ariaLabel ?? (action.type === 'icon' ? action.label : undefined),\n size: 'md' as const,\n type: action.buttonType ?? 'button',\n isInactive: action.isInactive,\n isLoading: action.isLoading,\n controls: menuId,\n expanded: menu ? this.openActionMenuId === action.id : undefined,\n hasMenu: menu,\n onDsClick: (event: CustomEvent<MouseEvent>) => {\n if (menu) this.toggleActionMenu(action.id, event.detail);\n else this.dsAction.emit(action.id);\n },\n };\n\n const button =\n appearance === 'filled' ? (\n <ds-button-filled\n {...buttonProps}\n intent={action.intent ?? 'brand'}\n contrast={action.contrast ?? 'bold'}\n />\n ) : (\n <ds-button-unfilled {...buttonProps} />\n );\n\n return action.type === 'icon' ? (\n <ds-tooltip key={action.id} label={action.label} side=\"bottom\" size=\"sm\">\n {button}\n </ds-tooltip>\n ) : (\n button\n );\n }\n\n private renderActions() {\n if (this.visibleActions.length === 0 && !this.showActionMenuTrigger) return null;\n\n return (\n <div class=\"bar-title__actions\">\n {this.visibleActions.map(action => this.renderVisibleAction(action))}\n {this.showActionMenuTrigger ? (\n <ds-tooltip label=\"Page options\" side=\"bottom\" size=\"sm\">\n <ds-button-unfilled\n ref={el => {\n this.actionTriggerEl = el ?? null;\n }}\n id={this.actionMenuTriggerId}\n class=\"bar-title__more-actions\"\n variant=\"icon\"\n icon=\"Ellipses\"\n aria-label={this.actionsAriaLabel}\n size=\"md\"\n activeFill={!this.compact}\n hasBorder={this.visibleActions.length > 0}\n haspopup=\"menu\"\n controls={this.actionMenuId}\n expanded={this.openActionMenuId === '__overflow'}\n onDsClick={(event: CustomEvent<MouseEvent>) =>\n this.toggleActionMenu('__overflow', event.detail)\n }\n />\n </ds-tooltip>\n ) : null}\n </div>\n );\n }\n\n private renderActionMenus() {\n return this.visibleActions.flatMap(action => {\n if (isBarTitleDivider(action) || (action.type !== 'menu' && action.type !== 'split')) {\n return [];\n }\n const menuLabel = action.menuAriaLabel ?? action.ariaLabel ?? action.label;\n return [\n <ds-menu\n key={action.id}\n id={this.actionMenuDomId(action.id)}\n class=\"bar-title__action-menu\"\n anchor={this.actionMenuAnchor(action.id)}\n align=\"end\"\n menuLabel={menuLabel}\n open={this.openActionMenuId === action.id}\n initialFocusVisible={this.actionMenuInitialFocusVisible}\n sections={this.menuSectionsForAction(action)}\n onDsClose={this.closeActionMenu}\n onDsSelect={this.handleActionSelect}\n />,\n ];\n });\n }\n\n private handleBreadcrumbSelect = (event: CustomEvent<BreadcrumbSelectDetail>) => {\n if (this.breadcrumbs.length === 0) {\n this.dsBack.emit(event.detail.originalEvent);\n return;\n }\n const forwarded = this.dsBreadcrumbSelect.emit(event.detail);\n if (forwarded.defaultPrevented) event.preventDefault();\n };\n\n private renderBreadcrumb() {\n const items = this.expandedBreadcrumbItems;\n if (items.length === 0) return null;\n return (\n <ds-breadcrumb\n class=\"bar-title__breadcrumb\"\n items={items}\n ariaLabel={this.breadcrumbAriaLabel}\n onDsSelect={this.handleBreadcrumbSelect}\n />\n );\n }\n\n private renderBack() {\n if (!this.showBack) return null;\n return (\n <ds-tooltip label={this.backTooltipLabel} side=\"bottom\" size=\"sm\">\n <ds-button-unfilled\n class=\"bar-title__back\"\n variant=\"icon\"\n icon=\"ChevronLeft\"\n aria-label={this.backAriaLabel}\n size=\"md\"\n activeFill={false}\n hasBorder={false}\n onDsClick={(event: CustomEvent<MouseEvent>) => this.dsBack.emit(event.detail)}\n />\n </ds-tooltip>\n );\n }\n\n render() {\n const compact = this.compact;\n return (\n <Host\n class={{\n 'bar-title-host--compact': compact,\n 'bar-title-host--expanded': this.effectiveVariant === 'expanded',\n 'bar-title-host--constrained': this.effectiveVariant === 'constrained',\n 'bar-title-host--has-description': !!this.description,\n 'bar-title-host--has-back': this.showBack,\n 'bar-title-host--has-breadcrumb': !compact && this.expandedBreadcrumbItems.length > 0,\n 'bar-title-host--shell-bar': this.placement === 'shell-bar',\n }}\n >\n <div\n class={{\n 'bar-title': true,\n 'bar-title--divider-hidden': !this.dividerVisible,\n 'ds-chrome-header': compact,\n }}\n >\n <div class=\"bar-title__inner\">\n {!compact ? this.renderBreadcrumb() : null}\n <div class=\"bar-title__row\">\n <div class=\"bar-title__leading\">\n <div class=\"bar-title__title-row\" data-shell-page-header-anchor>\n <div class=\"bar-title__identity\">\n {compact ? this.renderBack() : null}\n <ds-text\n class=\"bar-title__heading ds-control--md\"\n variant={compact ? 'text-title-small' : 'text-title-medium'}\n emphasis\n color=\"primary\"\n as=\"h1\"\n lineTruncation={1}\n >\n {this.heading}\n </ds-text>\n </div>\n {this.renderSectionSelector()}\n </div>\n {this.description && !compact ? (\n <ds-text\n class=\"bar-title__description\"\n variant=\"text-body-small\"\n color=\"secondary\"\n lineTruncation={2}\n wrap=\"wrap\"\n as=\"p\"\n >\n {this.description}\n </ds-text>\n ) : null}\n </div>\n {this.renderActions()}\n </div>\n </div>\n </div>\n\n {this.hasSectionSelector ? (\n <ds-menu\n id={this.sectionMenuId}\n class=\"bar-title__section-menu\"\n anchorId={this.sectionMenuTriggerId}\n menuLabel={this.sectionsAriaLabel}\n open={this.sectionMenuOpen}\n initialFocusVisible={this.sectionMenuInitialFocusVisible}\n sections={this.sectionMenuSections}\n onDsClose={this.closeSectionMenu}\n onDsSelect={this.handleSectionSelect}\n />\n ) : null}\n\n {this.renderActionMenus()}\n\n {this.showActionMenuTrigger ? (\n <ds-menu\n id={this.actionMenuId}\n class=\"bar-title__action-menu\"\n anchorId={this.actionMenuTriggerId}\n align=\"end\"\n menuLabel={this.actionsAriaLabel}\n open={this.openActionMenuId === '__overflow'}\n initialFocusVisible={this.actionMenuInitialFocusVisible}\n sections={this.actionMenuSections}\n onDsClose={this.closeActionMenu}\n onDsSelect={this.handleActionSelect}\n />\n ) : null}\n </Host>\n );\n }\n}\n",
|
|
561
|
+
"type": "registry:ui"
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
"path": "src/wc/components/BarTitle/bar-title-actions.ts",
|
|
565
|
+
"content": "import type { MenuItemData, MenuSection } from '../Menu/menu-types';\nimport type {\n BarTitleAction,\n BarTitleActionConfigItem,\n BarTitleActionItem,\n BarTitleDivider,\n BarTitleMenuChoiceItem,\n BarTitlePrimaryAction,\n BarTitleVariant,\n} from './bar-title-types';\n\nexport type BarTitleActionPresentation = BarTitleVariant | 'mobile';\n\nexport function isBarTitleActionDivider(\n item: BarTitleActionConfigItem | BarTitleMenuChoiceItem\n): item is BarTitleDivider {\n return 'type' in item && item.type === 'divider';\n}\n\nexport function resolveBarTitleActionItems(\n actionItems: BarTitleActionConfigItem[] | undefined,\n primaryAction: BarTitlePrimaryAction | null,\n actions: BarTitleActionItem[]\n): BarTitleActionConfigItem[] {\n if (actionItems !== undefined) return actionItems;\n\n const resolved: BarTitleActionConfigItem[] = [];\n if (primaryAction) {\n const { type, ...primary } = primaryAction;\n resolved.push({\n ...primary,\n type: 'button',\n buttonType: type,\n appearance: 'filled',\n });\n }\n for (const action of actions) {\n resolved.push(\n 'type' in action\n ? action\n : {\n ...action,\n type: 'overflow',\n }\n );\n }\n return resolved;\n}\n\nfunction nestedChoices(item: BarTitleActionConfigItem): BarTitleMenuChoiceItem[] | undefined {\n return item.type === 'menu' || item.type === 'split' ? item.choices : undefined;\n}\n\nexport function barTitleActionIdIssues(items: BarTitleActionConfigItem[]): string[] {\n const seen = new Set<string>();\n const issues: string[] = [];\n const visit = (id: string) => {\n if (!id.trim()) {\n issues.push('Action ids must be non-empty.');\n return;\n }\n if (seen.has(id)) {\n issues.push(`Duplicate action id: ${id}`);\n return;\n }\n seen.add(id);\n };\n\n for (const item of items) {\n if (isBarTitleActionDivider(item)) continue;\n visit(item.id);\n for (const choice of nestedChoices(item) ?? []) {\n if (!isBarTitleActionDivider(choice)) visit(choice.id);\n }\n }\n return issues;\n}\n\nfunction actionCollapses(\n item: BarTitleActionConfigItem,\n presentation: BarTitleActionPresentation\n): boolean {\n if (isBarTitleActionDivider(item) || item.type === 'overflow') return false;\n if (presentation === 'mobile') {\n if (item.type !== 'icon') return true;\n return (item.mobile ?? 'auto') === 'overflow';\n }\n return presentation === 'constrained' && (item.collapse ?? 'auto') === 'auto';\n}\n\nexport function visibleBarTitleActions(\n items: BarTitleActionConfigItem[],\n presentation: BarTitleActionPresentation\n): BarTitleActionConfigItem[] {\n const primary = items.find(\n item =>\n !isBarTitleActionDivider(item) &&\n item.type !== 'overflow' &&\n !actionCollapses(item, presentation)\n );\n return primary ? [primary] : [];\n}\n\nfunction menuItem(action: BarTitleAction, includeIcon: boolean = true): MenuItemData {\n return {\n label: action.label,\n value: action.id,\n icon: includeIcon ? action.icon : undefined,\n isInactive: action.isInactive,\n isDestructive: action.isDestructive,\n };\n}\n\nfunction appendChoices(\n output: Array<MenuItemData | BarTitleDivider>,\n choices: BarTitleMenuChoiceItem[],\n includeIcons: boolean = true\n) {\n for (const choice of choices) {\n output.push(isBarTitleActionDivider(choice) ? choice : menuItem(choice, includeIcons));\n }\n}\n\nfunction toSections(items: Array<MenuItemData | BarTitleDivider>): MenuSection[] {\n const sections: MenuSection[] = [];\n let current: MenuItemData[] = [];\n const commit = () => {\n if (current.length > 0) sections.push({ items: current });\n current = [];\n };\n\n for (const item of items) {\n if ('type' in item && item.type === 'divider') commit();\n else current.push(item as MenuItemData);\n }\n commit();\n return sections;\n}\n\nexport function barTitleChoiceSections(choices: BarTitleMenuChoiceItem[]): MenuSection[] {\n const rows: Array<MenuItemData | BarTitleDivider> = [];\n appendChoices(rows, choices);\n return toSections(rows);\n}\n\nexport function overflowBarTitleActionSections(\n items: BarTitleActionConfigItem[],\n presentation: BarTitleActionPresentation\n): MenuSection[] {\n const rows: Array<MenuItemData | BarTitleDivider> = [];\n const [visibleAction] = visibleBarTitleActions(items, presentation);\n\n for (const item of items) {\n if (isBarTitleActionDivider(item)) {\n rows.push(item);\n continue;\n }\n if (item.type === 'overflow') {\n rows.push(menuItem(item, false));\n continue;\n }\n if (item === visibleAction) continue;\n\n if (item.type === 'menu') {\n appendChoices(rows, item.choices, false);\n continue;\n }\n if (item.type === 'split') {\n rows.push(menuItem(item, false));\n appendChoices(rows, item.choices, false);\n continue;\n }\n rows.push(menuItem(item, false));\n }\n\n return toSections(rows);\n}\n\nexport function findBarTitleAction(\n items: BarTitleActionConfigItem[],\n id: string\n): BarTitleAction | undefined {\n for (const item of items) {\n if (isBarTitleActionDivider(item)) continue;\n if (item.id === id) return item;\n const choice = nestedChoices(item)?.find(\n candidate => !isBarTitleActionDivider(candidate) && candidate.id === id\n );\n if (choice && !isBarTitleActionDivider(choice)) return choice;\n }\n return undefined;\n}\n",
|
|
544
566
|
"type": "registry:ui"
|
|
545
567
|
},
|
|
546
568
|
{
|
|
547
569
|
"path": "src/wc/components/BarTitle/bar-title-types.ts",
|
|
548
|
-
"content": "import type { ButtonFilledContrast, ButtonFilledIntent } from '../ButtonFilled/ButtonFilled';\n\nexport interface BarTitleSection {\n id: string;\n label: string;\n isInactive?: boolean;\n}\n\nexport interface BarTitleDivider {\n type: 'divider';\n}\n\nexport type BarTitleSectionItem = BarTitleSection | BarTitleDivider;\n\nexport interface BarTitleAction {\n id: string;\n label: string;\n isInactive?: boolean;\n isDestructive?: boolean;\n}\n\nexport interface BarTitlePrimaryAction extends BarTitleAction {\n
|
|
570
|
+
"content": "import type { ButtonFilledContrast, ButtonFilledIntent } from '../ButtonFilled/ButtonFilled';\n\nexport interface BarTitleSection {\n id: string;\n label: string;\n isInactive?: boolean;\n}\n\nexport interface BarTitleDivider {\n type: 'divider';\n}\n\nexport type BarTitleSectionItem = BarTitleSection | BarTitleDivider;\n\nexport interface BarTitleAction {\n id: string;\n label: string;\n ariaLabel?: string;\n icon?: string;\n isInactive?: boolean;\n isDestructive?: boolean;\n}\n\nexport interface BarTitlePrimaryAction extends BarTitleAction {\n intent?: ButtonFilledIntent;\n contrast?: ButtonFilledContrast;\n isLoading?: boolean;\n type?: 'button' | 'submit' | 'reset';\n collapse?: BarTitlePrimaryActionCollapse;\n}\n\nexport type BarTitleActionItem = BarTitleAction | BarTitleDivider;\n\nexport type BarTitleActionAppearance = 'filled' | 'unfilled';\nexport type BarTitleActionCollapse = 'auto' | 'never';\nexport type BarTitleActionMobile = 'auto' | 'visible' | 'overflow';\n\ninterface BarTitleVisibleActionBase extends BarTitleAction {\n appearance?: BarTitleActionAppearance;\n intent?: ButtonFilledIntent;\n contrast?: ButtonFilledContrast;\n isLoading?: boolean;\n buttonType?: 'button' | 'submit' | 'reset';\n /** Auto moves the action into overflow only in constrained presentation. */\n collapse?: BarTitleActionCollapse;\n /**\n * Mobile defaults icon actions to visible and all labeled actions to overflow.\n * `visible` is supported only by icon actions.\n */\n mobile?: BarTitleActionMobile;\n}\n\n/** Visible labeled command in the authored action order. */\nexport interface BarTitleButtonAction extends BarTitleVisibleActionBase {\n type: 'button';\n}\n\n/** Visible icon-only command. ariaLabel is required because label is not rendered. */\nexport interface BarTitleIconAction extends BarTitleVisibleActionBase {\n type: 'icon';\n icon: string;\n ariaLabel: string;\n}\n\nexport type BarTitleMenuChoice = BarTitleAction;\nexport type BarTitleMenuChoiceItem = BarTitleMenuChoice | BarTitleDivider;\n\n/** Visible labeled menu button. Selecting a choice emits that choice's flat id. */\nexport interface BarTitleMenuAction extends BarTitleVisibleActionBase {\n type: 'menu';\n choices: BarTitleMenuChoiceItem[];\n menuAriaLabel?: string;\n}\n\n/** Command with a dedicated menu segment; defaults filled when appearance is omitted. */\nexport interface BarTitleSplitAction extends BarTitleVisibleActionBase {\n type: 'split';\n choices: BarTitleMenuChoiceItem[];\n menuAriaLabel: string;\n}\n\n/** Command that is always presented in the shared overflow menu. */\nexport interface BarTitleOverflowAction extends BarTitleAction {\n type: 'overflow';\n}\n\n/**\n * Ordered page-header action model. IDs must be non-empty and unique across\n * top-level actions and every nested menu choice. At most the first eligible\n * action renders beside the title; remaining actions use the text-only overflow.\n */\nexport type BarTitleActionConfigItem =\n | BarTitleButtonAction\n | BarTitleIconAction\n | BarTitleMenuAction\n | BarTitleSplitAction\n | BarTitleOverflowAction\n | BarTitleDivider;\n\nexport type BarTitleVariant = 'expanded' | 'compact' | 'constrained';\nexport type BarTitlePlacement = 'page' | 'shell-bar';\n\nexport type BarTitlePrimaryActionCollapse = 'auto' | 'never';\n\nexport function isBarTitleDivider(\n item: BarTitleSectionItem | BarTitleActionItem\n): item is BarTitleDivider {\n return 'type' in item && item.type === 'divider';\n}\n",
|
|
549
571
|
"type": "registry:ui"
|
|
550
572
|
}
|
|
551
573
|
]
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"useWhen": [
|
|
18
18
|
"The user initiates the single primary command in a local decision area.",
|
|
19
19
|
"An action's consequence requires a matching semantic treatment.",
|
|
20
|
-
"A standalone compact primary action needs an icon-only presentation with an explicit accessible name."
|
|
20
|
+
"A standalone compact primary action needs an icon-only presentation with an explicit accessible name.",
|
|
21
|
+
"The primary command has closely related alternatives and needs split mode without losing its filled intent, contrast, variant, or loading treatment."
|
|
21
22
|
],
|
|
22
23
|
"avoidWhen": [
|
|
23
24
|
"Another filled action already exists in the same local decision area.",
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
],
|
|
55
56
|
"accessibility": [
|
|
56
57
|
"Provide an explicit accessible name for icon-only buttons.",
|
|
58
|
+
"In split mode, provide menuAriaLabel for the appended ChevronDown segment, pass controls with the Menu id, and synchronize expanded with the Menu open state.",
|
|
57
59
|
"Set hasMenu when the action opens a Menu; it implies aria-haspopup of menu and renders the trailing chevron. Pass controls with the Menu id and expanded from the same open state given to Menu.",
|
|
58
60
|
"Use haspopup directly for a non-menu popup such as a dialog; that case gets no chevron.",
|
|
59
61
|
"Use inactive state only when the action must remain visible but unavailable.",
|
|
@@ -77,7 +79,9 @@
|
|
|
77
79
|
"Visible labels are emphasized by default. Set labelEmphasis to false when a composed surface deliberately needs the button label to match adjacent regular-weight control labels; this does not change the action hierarchy, foreground, icon, or interaction states.",
|
|
78
80
|
"ButtonFilled has no active, pressed, or selected state; a filled action is a command, not a toggle or a persistent selection.",
|
|
79
81
|
"An open popup is a transient pressed state instead. While expanded is true the pressed wash is held for the popup's complete rendered lifecycle and survives hover, so the trigger reads as held open without introducing a selected treatment.",
|
|
80
|
-
"hasMenu supports only the label and icon-label variants. The chevron is what communicates that a menu will open, so an icon-only filled menu button would leave the affordance unstated."
|
|
82
|
+
"hasMenu supports only the label and icon-label variants. The chevron is what communicates that a menu will open, so an icon-only filled menu button would leave the affordance unstated.",
|
|
83
|
+
"Split mode supports label, icon, and icon-label primary segments. The primary segment emits dsClick and the appended menu segment emits dsMenuClick.",
|
|
84
|
+
"Split mode keeps both segments flush and uses a tertiary on-background separator. Rounded changes the shared outer radius without separating the segments."
|
|
81
85
|
],
|
|
82
86
|
"responsiveBehavior": [
|
|
83
87
|
"Use fill width only when the parent layout calls for a full-width action, commonly on narrow form layouts."
|
|
@@ -242,6 +246,15 @@
|
|
|
242
246
|
"mutable": false,
|
|
243
247
|
"description": "Whether the visible label uses the emphasized weight."
|
|
244
248
|
},
|
|
249
|
+
"menuAriaLabel": {
|
|
250
|
+
"type": "string",
|
|
251
|
+
"resolvedType": "string",
|
|
252
|
+
"attribute": "menu-aria-label",
|
|
253
|
+
"default": "'More options'",
|
|
254
|
+
"required": false,
|
|
255
|
+
"mutable": false,
|
|
256
|
+
"description": "Accessible name for the appended menu segment in split mode."
|
|
257
|
+
},
|
|
245
258
|
"pressScale": {
|
|
246
259
|
"type": "boolean",
|
|
247
260
|
"resolvedType": "boolean",
|
|
@@ -269,6 +282,15 @@
|
|
|
269
282
|
"mutable": false,
|
|
270
283
|
"description": "Control density (height, padding, icon, type)."
|
|
271
284
|
},
|
|
285
|
+
"split": {
|
|
286
|
+
"type": "boolean",
|
|
287
|
+
"resolvedType": "boolean",
|
|
288
|
+
"attribute": "split",
|
|
289
|
+
"default": "false",
|
|
290
|
+
"required": false,
|
|
291
|
+
"mutable": false,
|
|
292
|
+
"description": "Append a separate ChevronDown menu segment while preserving this button's\nvariant, size, intent, contrast, loading, inactive, and width treatment."
|
|
293
|
+
},
|
|
272
294
|
"type": {
|
|
273
295
|
"type": "'button' | 'submit' | 'reset'",
|
|
274
296
|
"resolvedType": "\"button\" | \"reset\" | \"submit\"",
|
|
@@ -304,12 +326,19 @@
|
|
|
304
326
|
"bubbles": true,
|
|
305
327
|
"cancelable": true,
|
|
306
328
|
"composed": true
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"name": "dsMenuClick",
|
|
332
|
+
"detail": "MouseEvent",
|
|
333
|
+
"bubbles": true,
|
|
334
|
+
"cancelable": true,
|
|
335
|
+
"composed": true
|
|
307
336
|
}
|
|
308
337
|
],
|
|
309
338
|
"methods": [
|
|
310
339
|
{
|
|
311
340
|
"name": "setFocus",
|
|
312
|
-
"signature": "setFocus() => Promise<void>"
|
|
341
|
+
"signature": "setFocus(segment?: \"primary\" | \"menu\") => Promise<void>"
|
|
313
342
|
}
|
|
314
343
|
],
|
|
315
344
|
"slots": []
|
|
@@ -455,6 +484,15 @@
|
|
|
455
484
|
"mutable": false,
|
|
456
485
|
"description": "Whether the visible label uses the emphasized weight."
|
|
457
486
|
},
|
|
487
|
+
"menuAriaLabel": {
|
|
488
|
+
"type": "string",
|
|
489
|
+
"resolvedType": "string",
|
|
490
|
+
"attribute": "menu-aria-label",
|
|
491
|
+
"default": "'More options'",
|
|
492
|
+
"required": false,
|
|
493
|
+
"mutable": false,
|
|
494
|
+
"description": "Accessible name for the appended menu segment in split mode."
|
|
495
|
+
},
|
|
458
496
|
"pressScale": {
|
|
459
497
|
"type": "boolean",
|
|
460
498
|
"resolvedType": "boolean",
|
|
@@ -482,6 +520,15 @@
|
|
|
482
520
|
"mutable": false,
|
|
483
521
|
"description": "Control density (height, padding, icon, type)."
|
|
484
522
|
},
|
|
523
|
+
"split": {
|
|
524
|
+
"type": "boolean",
|
|
525
|
+
"resolvedType": "boolean",
|
|
526
|
+
"attribute": "split",
|
|
527
|
+
"default": "false",
|
|
528
|
+
"required": false,
|
|
529
|
+
"mutable": false,
|
|
530
|
+
"description": "Append a separate ChevronDown menu segment while preserving this button's\nvariant, size, intent, contrast, loading, inactive, and width treatment."
|
|
531
|
+
},
|
|
485
532
|
"type": {
|
|
486
533
|
"type": "'button' | 'submit' | 'reset'",
|
|
487
534
|
"resolvedType": "\"button\" | \"reset\" | \"submit\"",
|
|
@@ -517,12 +564,19 @@
|
|
|
517
564
|
"bubbles": true,
|
|
518
565
|
"cancelable": true,
|
|
519
566
|
"composed": true
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
"name": "dsMenuClick",
|
|
570
|
+
"detail": "MouseEvent",
|
|
571
|
+
"bubbles": true,
|
|
572
|
+
"cancelable": true,
|
|
573
|
+
"composed": true
|
|
520
574
|
}
|
|
521
575
|
],
|
|
522
576
|
"methods": [
|
|
523
577
|
{
|
|
524
578
|
"name": "setFocus",
|
|
525
|
-
"signature": "setFocus() => Promise<void>"
|
|
579
|
+
"signature": "setFocus(segment?: \"primary\" | \"menu\") => Promise<void>"
|
|
526
580
|
}
|
|
527
581
|
],
|
|
528
582
|
"slots": [],
|
|
@@ -574,12 +628,12 @@
|
|
|
574
628
|
"files": [
|
|
575
629
|
{
|
|
576
630
|
"path": "src/wc/components/ButtonFilled/ButtonFilled.css",
|
|
577
|
-
"content": "@import '../../utils/button-base.css';\n\n:host {\n --ds-button-filled-bg: var(--color-background-bold-brand);\n --ds-button-filled-fg: var(--color-foreground-faint-brand);\n --ds-button-filled-border: var(--color-border-secondary);\n}\n\n.button-filled {\n background-color: var(--ds-button-filled-bg);\n color: var(--ds-button-filled-fg);\n transition:\n background-color var(--effect-motion-short-2),\n color var(--effect-motion-short-2);\n /* Hover/press: `.ds-interaction-fill` + contrast → `--on-*` (token overlay, not color-mix). */\n}\n\n/*\n * An open popup is a transient pressed state, not a selected state. ButtonFilled\n * deliberately has no active state, so hold the pressed wash for the popup's\n * complete rendered lifecycle instead of promoting any selected treatment.\n */\n/* Inset stroke via interaction-fill ::after (above hover and pressed washes). */\n.button-filled--bordered {\n --ds-interaction-border-color: var(--ds-button-filled-border);\n}\n\n/*\n * Parent-surface context affects only the optional inset border.\n * Intent + contrast continue to own fill, foreground, and interaction overlays.\n */\n.button-filled--background-medium {\n --ds-button-filled-border: var(--color-border-on-medium-background-secondary);\n}\n\n.button-filled--background-bold {\n --ds-button-filled-border: var(--color-border-on-bold-background-secondary);\n}\n\n.button-filled--background-strong {\n --ds-button-filled-border: var(--color-border-on-strong-background-secondary);\n}\n\n.button-filled--background-translucent {\n --ds-button-filled-border: var(--color-translucent-border-secondary);\n}\n\n.button-filled--background-inverted {\n --ds-button-filled-border: var(--color-inverted-border-secondary);\n}\n\n.button-filled--background-media {\n --ds-button-filled-border: var(--color-media-border-secondary);\n}\n\n.button-filled--background-always-dark {\n --ds-button-filled-border: var(--color-always-dark-border-secondary);\n}\n\n/* Inactive: `.ds-control-inactive` (50% opacity). */\n\n/* ── Intent + contrast (bold default) ─────────────────────────────────────── */\n\n.button-filled--intent-neutral {\n --ds-button-filled-bg: var(--color-background-bold-neutral);\n --ds-button-filled-fg: var(--color-foreground-faint-neutral);\n}\n\n.button-filled--intent-brand {\n --ds-button-filled-bg: var(--color-background-bold-brand);\n --ds-button-filled-fg: var(--color-foreground-faint-brand);\n}\n\n.button-filled--intent-ai {\n --ds-button-filled-bg: var(--color-background-bold-ai);\n --ds-button-filled-fg: var(--color-foreground-faint-ai);\n}\n\n.button-filled--intent-negative {\n --ds-button-filled-bg: var(--color-background-bold-negative);\n --ds-button-filled-fg: var(--color-foreground-faint-negative);\n}\n\n.button-filled--intent-warning {\n --ds-button-filled-bg: var(--color-background-bold-warning);\n --ds-button-filled-fg: var(--color-foreground-faint-warning);\n}\n\n.button-filled--intent-caution {\n --ds-button-filled-bg: var(--color-background-bold-caution);\n --ds-button-filled-fg: var(--color-foreground-faint-caution);\n}\n\n.button-filled--intent-positive {\n --ds-button-filled-bg: var(--color-background-bold-positive);\n --ds-button-filled-fg: var(--color-foreground-faint-positive);\n}\n\n.button-filled--intent-guide {\n --ds-button-filled-bg: var(--color-background-bold-guide);\n --ds-button-filled-fg: var(--color-foreground-faint-guide);\n}\n\n.button-filled--intent-walkthrough {\n --ds-button-filled-bg: var(--color-background-bold-walkthrough);\n --ds-button-filled-fg: var(--color-foreground-faint-walkthrough);\n}\n\n/* strong → medium fg */\n.button-filled--contrast-strong.button-filled--intent-neutral {\n --ds-button-filled-bg: var(--color-background-strong-neutral);\n --ds-button-filled-fg: var(--color-foreground-medium-neutral);\n}\n\n.button-filled--contrast-strong.button-filled--intent-brand {\n --ds-button-filled-bg: var(--color-background-strong-brand);\n --ds-button-filled-fg: var(--color-foreground-medium-brand);\n}\n\n.button-filled--contrast-strong.button-filled--intent-ai {\n --ds-button-filled-bg: var(--color-background-strong-ai);\n --ds-button-filled-fg: var(--color-foreground-medium-ai);\n}\n\n.button-filled--contrast-strong.button-filled--intent-negative {\n --ds-button-filled-bg: var(--color-background-strong-negative);\n --ds-button-filled-fg: var(--color-foreground-medium-negative);\n}\n\n.button-filled--contrast-strong.button-filled--intent-warning {\n --ds-button-filled-bg: var(--color-background-strong-warning);\n --ds-button-filled-fg: var(--color-foreground-medium-warning);\n}\n\n.button-filled--contrast-strong.button-filled--intent-caution {\n --ds-button-filled-bg: var(--color-background-strong-caution);\n --ds-button-filled-fg: var(--color-foreground-medium-caution);\n}\n\n.button-filled--contrast-strong.button-filled--intent-positive {\n --ds-button-filled-bg: var(--color-background-strong-positive);\n --ds-button-filled-fg: var(--color-foreground-medium-positive);\n}\n\n.button-filled--contrast-strong.button-filled--intent-guide {\n --ds-button-filled-bg: var(--color-background-strong-guide);\n --ds-button-filled-fg: var(--color-foreground-medium-guide);\n}\n\n.button-filled--contrast-strong.button-filled--intent-walkthrough {\n --ds-button-filled-bg: var(--color-background-strong-walkthrough);\n --ds-button-filled-fg: var(--color-foreground-medium-walkthrough);\n}\n\n/* medium → strong fg */\n.button-filled--contrast-medium.button-filled--intent-neutral {\n --ds-button-filled-bg: var(--color-background-medium-neutral);\n --ds-button-filled-fg: var(--color-foreground-strong-neutral);\n}\n\n.button-filled--contrast-medium.button-filled--intent-brand {\n --ds-button-filled-bg: var(--color-background-medium-brand);\n --ds-button-filled-fg: var(--color-foreground-strong-brand);\n}\n\n.button-filled--contrast-medium.button-filled--intent-ai {\n --ds-button-filled-bg: var(--color-background-medium-ai);\n --ds-button-filled-fg: var(--color-foreground-strong-ai);\n}\n\n.button-filled--contrast-medium.button-filled--intent-negative {\n --ds-button-filled-bg: var(--color-background-medium-negative);\n --ds-button-filled-fg: var(--color-foreground-strong-negative);\n}\n\n.button-filled--contrast-medium.button-filled--intent-warning {\n --ds-button-filled-bg: var(--color-background-medium-warning);\n --ds-button-filled-fg: var(--color-foreground-strong-warning);\n}\n\n.button-filled--contrast-medium.button-filled--intent-caution {\n --ds-button-filled-bg: var(--color-background-medium-caution);\n --ds-button-filled-fg: var(--color-foreground-strong-caution);\n}\n\n.button-filled--contrast-medium.button-filled--intent-positive {\n --ds-button-filled-bg: var(--color-background-medium-positive);\n --ds-button-filled-fg: var(--color-foreground-strong-positive);\n}\n\n.button-filled--contrast-medium.button-filled--intent-guide {\n --ds-button-filled-bg: var(--color-background-medium-guide);\n --ds-button-filled-fg: var(--color-foreground-strong-guide);\n}\n\n.button-filled--contrast-medium.button-filled--intent-walkthrough {\n --ds-button-filled-bg: var(--color-background-medium-walkthrough);\n --ds-button-filled-fg: var(--color-foreground-strong-walkthrough);\n}\n\n/* faint → bold fg */\n.button-filled--contrast-faint.button-filled--intent-neutral {\n --ds-button-filled-bg: var(--color-background-faint-neutral);\n --ds-button-filled-fg: var(--color-foreground-bold-neutral);\n}\n\n.button-filled--contrast-faint.button-filled--intent-brand {\n --ds-button-filled-bg: var(--color-background-faint-brand);\n --ds-button-filled-fg: var(--color-foreground-bold-brand);\n}\n\n.button-filled--contrast-faint.button-filled--intent-ai {\n --ds-button-filled-bg: var(--color-background-faint-ai);\n --ds-button-filled-fg: var(--color-foreground-bold-ai);\n}\n\n.button-filled--contrast-faint.button-filled--intent-negative {\n --ds-button-filled-bg: var(--color-background-faint-negative);\n --ds-button-filled-fg: var(--color-foreground-bold-negative);\n}\n\n.button-filled--contrast-faint.button-filled--intent-warning {\n --ds-button-filled-bg: var(--color-background-faint-warning);\n --ds-button-filled-fg: var(--color-foreground-bold-warning);\n}\n\n.button-filled--contrast-faint.button-filled--intent-caution {\n --ds-button-filled-bg: var(--color-background-faint-caution);\n --ds-button-filled-fg: var(--color-foreground-bold-caution);\n}\n\n.button-filled--contrast-faint.button-filled--intent-positive {\n --ds-button-filled-bg: var(--color-background-faint-positive);\n --ds-button-filled-fg: var(--color-foreground-bold-positive);\n}\n\n.button-filled--contrast-faint.button-filled--intent-guide {\n --ds-button-filled-bg: var(--color-background-faint-guide);\n --ds-button-filled-fg: var(--color-foreground-bold-guide);\n}\n\n.button-filled--contrast-faint.button-filled--intent-walkthrough {\n --ds-button-filled-bg: var(--color-background-faint-walkthrough);\n --ds-button-filled-fg: var(--color-foreground-bold-walkthrough);\n}\n\n/*\n * Bold, strong, and medium fills already communicate semantic intent. Their\n * on-background foreground tokens preserve AA text contrast across themes,\n * including brand pairs whose chromatic counterparts sit on the 4.5:1 edge.\n */\n.button-filled--contrast-bold.button-filled {\n --ds-button-filled-fg: var(--color-foreground-on-bold-background-primary);\n}\n\n.button-filled--contrast-strong.button-filled {\n --ds-button-filled-fg: var(--color-foreground-on-strong-background-primary);\n}\n\n.button-filled--contrast-medium.button-filled {\n --ds-button-filled-fg: var(--color-foreground-on-medium-background-primary);\n}\n",
|
|
631
|
+
"content": "@import '../../utils/button-base.css';\n@import '../../utils/button-split.css';\n\n:host {\n --ds-button-filled-bg: var(--color-background-bold-brand);\n --ds-button-filled-fg: var(--color-foreground-faint-brand);\n --ds-button-filled-border: var(--color-border-secondary);\n --ds-button-split-border: var(--color-border-secondary);\n --ds-button-split-divider: var(--color-border-on-bold-background-tertiary);\n}\n\n:host(.button-filled-host--contrast-strong) {\n --ds-button-split-divider: var(--color-border-on-strong-background-tertiary);\n}\n\n:host(.button-filled-host--contrast-medium) {\n --ds-button-split-divider: var(--color-border-on-medium-background-tertiary);\n}\n\n:host(.button-filled-host--contrast-faint) {\n --ds-button-split-divider: var(--color-border-tertiary);\n}\n\n:host(.button-filled-host--background-medium) {\n --ds-button-split-border: var(--color-border-on-medium-background-secondary);\n}\n\n:host(.button-filled-host--background-bold) {\n --ds-button-split-border: var(--color-border-on-bold-background-secondary);\n}\n\n:host(.button-filled-host--background-strong) {\n --ds-button-split-border: var(--color-border-on-strong-background-secondary);\n}\n\n:host(.button-filled-host--background-translucent) {\n --ds-button-split-border: var(--color-translucent-border-secondary);\n}\n\n:host(.button-filled-host--background-inverted) {\n --ds-button-split-border: var(--color-inverted-border-secondary);\n}\n\n:host(.button-filled-host--background-media) {\n --ds-button-split-border: var(--color-media-border-secondary);\n}\n\n:host(.button-filled-host--background-always-dark) {\n --ds-button-split-border: var(--color-always-dark-border-secondary);\n}\n\n.button-filled {\n background-color: var(--ds-button-filled-bg);\n color: var(--ds-button-filled-fg);\n transition:\n background-color var(--effect-motion-short-2),\n color var(--effect-motion-short-2);\n /* Hover/press: `.ds-interaction-fill` + contrast → `--on-*` (token overlay, not color-mix). */\n}\n\n/*\n * An open popup is a transient pressed state, not a selected state. ButtonFilled\n * deliberately has no active state, so hold the pressed wash for the popup's\n * complete rendered lifecycle instead of promoting any selected treatment.\n */\n/* Inset stroke via interaction-fill ::after (above hover and pressed washes). */\n.button-filled--bordered {\n --ds-interaction-border-color: var(--ds-button-filled-border);\n}\n\n/*\n * Parent-surface context affects only the optional inset border.\n * Intent + contrast continue to own fill, foreground, and interaction overlays.\n */\n.button-filled--background-medium {\n --ds-button-filled-border: var(--color-border-on-medium-background-secondary);\n}\n\n.button-filled--background-bold {\n --ds-button-filled-border: var(--color-border-on-bold-background-secondary);\n}\n\n.button-filled--background-strong {\n --ds-button-filled-border: var(--color-border-on-strong-background-secondary);\n}\n\n.button-filled--background-translucent {\n --ds-button-filled-border: var(--color-translucent-border-secondary);\n}\n\n.button-filled--background-inverted {\n --ds-button-filled-border: var(--color-inverted-border-secondary);\n}\n\n.button-filled--background-media {\n --ds-button-filled-border: var(--color-media-border-secondary);\n}\n\n.button-filled--background-always-dark {\n --ds-button-filled-border: var(--color-always-dark-border-secondary);\n}\n\n/* Inactive: `.ds-control-inactive` (50% opacity). */\n\n/* ── Intent + contrast (bold default) ─────────────────────────────────────── */\n\n.button-filled--intent-neutral {\n --ds-button-filled-bg: var(--color-background-bold-neutral);\n --ds-button-filled-fg: var(--color-foreground-faint-neutral);\n}\n\n.button-filled--intent-brand {\n --ds-button-filled-bg: var(--color-background-bold-brand);\n --ds-button-filled-fg: var(--color-foreground-faint-brand);\n}\n\n.button-filled--intent-ai {\n --ds-button-filled-bg: var(--color-background-bold-ai);\n --ds-button-filled-fg: var(--color-foreground-faint-ai);\n}\n\n.button-filled--intent-negative {\n --ds-button-filled-bg: var(--color-background-bold-negative);\n --ds-button-filled-fg: var(--color-foreground-faint-negative);\n}\n\n.button-filled--intent-warning {\n --ds-button-filled-bg: var(--color-background-bold-warning);\n --ds-button-filled-fg: var(--color-foreground-faint-warning);\n}\n\n.button-filled--intent-caution {\n --ds-button-filled-bg: var(--color-background-bold-caution);\n --ds-button-filled-fg: var(--color-foreground-faint-caution);\n}\n\n.button-filled--intent-positive {\n --ds-button-filled-bg: var(--color-background-bold-positive);\n --ds-button-filled-fg: var(--color-foreground-faint-positive);\n}\n\n.button-filled--intent-guide {\n --ds-button-filled-bg: var(--color-background-bold-guide);\n --ds-button-filled-fg: var(--color-foreground-faint-guide);\n}\n\n.button-filled--intent-walkthrough {\n --ds-button-filled-bg: var(--color-background-bold-walkthrough);\n --ds-button-filled-fg: var(--color-foreground-faint-walkthrough);\n}\n\n/* strong → medium fg */\n.button-filled--contrast-strong.button-filled--intent-neutral {\n --ds-button-filled-bg: var(--color-background-strong-neutral);\n --ds-button-filled-fg: var(--color-foreground-medium-neutral);\n}\n\n.button-filled--contrast-strong.button-filled--intent-brand {\n --ds-button-filled-bg: var(--color-background-strong-brand);\n --ds-button-filled-fg: var(--color-foreground-medium-brand);\n}\n\n.button-filled--contrast-strong.button-filled--intent-ai {\n --ds-button-filled-bg: var(--color-background-strong-ai);\n --ds-button-filled-fg: var(--color-foreground-medium-ai);\n}\n\n.button-filled--contrast-strong.button-filled--intent-negative {\n --ds-button-filled-bg: var(--color-background-strong-negative);\n --ds-button-filled-fg: var(--color-foreground-medium-negative);\n}\n\n.button-filled--contrast-strong.button-filled--intent-warning {\n --ds-button-filled-bg: var(--color-background-strong-warning);\n --ds-button-filled-fg: var(--color-foreground-medium-warning);\n}\n\n.button-filled--contrast-strong.button-filled--intent-caution {\n --ds-button-filled-bg: var(--color-background-strong-caution);\n --ds-button-filled-fg: var(--color-foreground-medium-caution);\n}\n\n.button-filled--contrast-strong.button-filled--intent-positive {\n --ds-button-filled-bg: var(--color-background-strong-positive);\n --ds-button-filled-fg: var(--color-foreground-medium-positive);\n}\n\n.button-filled--contrast-strong.button-filled--intent-guide {\n --ds-button-filled-bg: var(--color-background-strong-guide);\n --ds-button-filled-fg: var(--color-foreground-medium-guide);\n}\n\n.button-filled--contrast-strong.button-filled--intent-walkthrough {\n --ds-button-filled-bg: var(--color-background-strong-walkthrough);\n --ds-button-filled-fg: var(--color-foreground-medium-walkthrough);\n}\n\n/* medium → strong fg */\n.button-filled--contrast-medium.button-filled--intent-neutral {\n --ds-button-filled-bg: var(--color-background-medium-neutral);\n --ds-button-filled-fg: var(--color-foreground-strong-neutral);\n}\n\n.button-filled--contrast-medium.button-filled--intent-brand {\n --ds-button-filled-bg: var(--color-background-medium-brand);\n --ds-button-filled-fg: var(--color-foreground-strong-brand);\n}\n\n.button-filled--contrast-medium.button-filled--intent-ai {\n --ds-button-filled-bg: var(--color-background-medium-ai);\n --ds-button-filled-fg: var(--color-foreground-strong-ai);\n}\n\n.button-filled--contrast-medium.button-filled--intent-negative {\n --ds-button-filled-bg: var(--color-background-medium-negative);\n --ds-button-filled-fg: var(--color-foreground-strong-negative);\n}\n\n.button-filled--contrast-medium.button-filled--intent-warning {\n --ds-button-filled-bg: var(--color-background-medium-warning);\n --ds-button-filled-fg: var(--color-foreground-strong-warning);\n}\n\n.button-filled--contrast-medium.button-filled--intent-caution {\n --ds-button-filled-bg: var(--color-background-medium-caution);\n --ds-button-filled-fg: var(--color-foreground-strong-caution);\n}\n\n.button-filled--contrast-medium.button-filled--intent-positive {\n --ds-button-filled-bg: var(--color-background-medium-positive);\n --ds-button-filled-fg: var(--color-foreground-strong-positive);\n}\n\n.button-filled--contrast-medium.button-filled--intent-guide {\n --ds-button-filled-bg: var(--color-background-medium-guide);\n --ds-button-filled-fg: var(--color-foreground-strong-guide);\n}\n\n.button-filled--contrast-medium.button-filled--intent-walkthrough {\n --ds-button-filled-bg: var(--color-background-medium-walkthrough);\n --ds-button-filled-fg: var(--color-foreground-strong-walkthrough);\n}\n\n/* faint → bold fg */\n.button-filled--contrast-faint.button-filled--intent-neutral {\n --ds-button-filled-bg: var(--color-background-faint-neutral);\n --ds-button-filled-fg: var(--color-foreground-bold-neutral);\n}\n\n.button-filled--contrast-faint.button-filled--intent-brand {\n --ds-button-filled-bg: var(--color-background-faint-brand);\n --ds-button-filled-fg: var(--color-foreground-bold-brand);\n}\n\n.button-filled--contrast-faint.button-filled--intent-ai {\n --ds-button-filled-bg: var(--color-background-faint-ai);\n --ds-button-filled-fg: var(--color-foreground-bold-ai);\n}\n\n.button-filled--contrast-faint.button-filled--intent-negative {\n --ds-button-filled-bg: var(--color-background-faint-negative);\n --ds-button-filled-fg: var(--color-foreground-bold-negative);\n}\n\n.button-filled--contrast-faint.button-filled--intent-warning {\n --ds-button-filled-bg: var(--color-background-faint-warning);\n --ds-button-filled-fg: var(--color-foreground-bold-warning);\n}\n\n.button-filled--contrast-faint.button-filled--intent-caution {\n --ds-button-filled-bg: var(--color-background-faint-caution);\n --ds-button-filled-fg: var(--color-foreground-bold-caution);\n}\n\n.button-filled--contrast-faint.button-filled--intent-positive {\n --ds-button-filled-bg: var(--color-background-faint-positive);\n --ds-button-filled-fg: var(--color-foreground-bold-positive);\n}\n\n.button-filled--contrast-faint.button-filled--intent-guide {\n --ds-button-filled-bg: var(--color-background-faint-guide);\n --ds-button-filled-fg: var(--color-foreground-bold-guide);\n}\n\n.button-filled--contrast-faint.button-filled--intent-walkthrough {\n --ds-button-filled-bg: var(--color-background-faint-walkthrough);\n --ds-button-filled-fg: var(--color-foreground-bold-walkthrough);\n}\n\n/*\n * Bold, strong, and medium fills already communicate semantic intent. Their\n * on-background foreground tokens preserve AA text contrast across themes,\n * including brand pairs whose chromatic counterparts sit on the 4.5:1 edge.\n */\n.button-filled--contrast-bold.button-filled {\n --ds-button-filled-fg: var(--color-foreground-on-bold-background-primary);\n}\n\n.button-filled--contrast-strong.button-filled {\n --ds-button-filled-fg: var(--color-foreground-on-strong-background-primary);\n}\n\n.button-filled--contrast-medium.button-filled {\n --ds-button-filled-fg: var(--color-foreground-on-medium-background-primary);\n}\n",
|
|
578
632
|
"type": "registry:ui"
|
|
579
633
|
},
|
|
580
634
|
{
|
|
581
635
|
"path": "src/wc/components/ButtonFilled/ButtonFilled.tsx",
|
|
582
|
-
"content": "import { Component, Element, Event, EventEmitter, h, Host, Method, Prop } from '@stencil/core';\nimport { controlWidthClass } from '../../utils';\nimport type { ChoiceBackground } from '../../utils/choice-list';\nimport { beginElevatedControlPress } from '../../utils/control-press';\nimport { renderButtonContent } from '../../utils/button-render';\nimport type { ControlInsetDepth } from '../../utils/control-text';\nimport type { ButtonPopup, ButtonSize, ButtonVariant, ButtonWidth } from '../../utils/button-types';\n\nexport type ButtonFilledIntent =\n | 'neutral'\n | 'brand'\n | 'ai'\n | 'negative'\n | 'warning'\n | 'caution'\n | 'positive'\n | 'guide'\n | 'walkthrough';\n\nexport type ButtonFilledContrast = 'bold' | 'strong' | 'medium' | 'faint';\n\nexport type ButtonFilledBackground = ChoiceBackground;\n\nexport type ButtonFilledVariant = ButtonVariant;\nexport type ButtonFilledSize = ButtonSize;\nexport type ButtonFilledWidth = ButtonWidth;\nexport type ButtonFilledPopup = ButtonPopup;\n\n@Component({\n tag: 'ds-button-filled',\n styleUrl: 'ButtonFilled.css',\n scoped: true,\n})\nexport class ButtonFilled {\n @Element() el!: HTMLElement;\n\n /**\n * Content layout. Default is label-only; pass `icon` for icon-only chrome\n * (nav / tool rails) or `icon-label` for leading icon + text.\n */\n @Prop() variant: ButtonFilledVariant = 'label';\n\n /** Control density (height, padding, icon, type). */\n @Prop() size: ButtonFilledSize = 'md';\n\n /** Use reduced outer geometry when nested inside a control of the same size. */\n @Prop() isInset: boolean = false;\n\n /** Single removes 4px overall; double removes 8px overall (xs stays single). */\n @Prop() insetDepth: ControlInsetDepth = 'single';\n\n /** Width fit — hug content (default) or fill the parent. */\n @Prop() width: ButtonFilledWidth = 'hug';\n\n /** Visible text for `label` / `icon-label` variants. */\n @Prop() label: string = '';\n\n /** Whether the visible label uses the emphasized weight. */\n @Prop() labelEmphasis: boolean = true;\n\n /** Icon name passed to <ds-icon> for `icon` / `icon-label` variants. */\n @Prop() icon: string = '';\n\n /** Semantic colour intent. */\n @Prop() intent: ButtonFilledIntent = 'brand';\n\n /**\n * Background fill weight. Foreground uses the paired contrast token:\n * bold → faint, strong → medium, medium → strong, faint → bold.\n */\n @Prop() contrast: ButtonFilledContrast = 'bold';\n\n /** Show a 1px secondary inset border. */\n @Prop() hasBorder: boolean = false;\n\n /**\n * Actual parent surface context for the optional inset border color only.\n * Omit on primary and secondary surfaces.\n */\n @Prop() background: ButtonFilledBackground | undefined;\n\n /** Use the half-radius treatment instead of the default control radius. */\n @Prop() rounded: boolean = false;\n\n /**\n * Scale down during a physical pointer press.\n * Disable when an owning composite requires fixed child or background geometry.\n */\n @Prop() pressScale: boolean = true;\n\n /** Disables interaction. */\n @Prop() isInactive: boolean = false;\n\n /** Shows an inline loader and prevents interaction without applying inactive opacity. */\n @Prop() isLoading: boolean = false;\n\n /** Native button type. */\n @Prop() type: 'button' | 'submit' | 'reset' = 'button';\n\n /** Accessible name override. Required for icon-only buttons. */\n @Prop({ attribute: 'aria-label' }) ariaLabel: string | null = null;\n\n /** ID of the popup this button controls. */\n @Prop() controls: string | undefined;\n\n /**\n * Controlled open state of the popup this button triggers. Holds the pressed\n * wash for the popup's rendered lifecycle. ButtonFilled has no selected state,\n * so an open popup never promotes to an active treatment.\n */\n @Prop() expanded: boolean | undefined;\n\n /** Popup type exposed to assistive technology. */\n @Prop() haspopup: ButtonFilledPopup | undefined;\n\n /**\n * This action *has* a menu: implies `aria-haspopup=\"menu\"` and adds the trailing\n * chevron that carries the affordance.\n *\n * Only `label` and `icon-label` are supported. A filled button is never the\n * overflow / more-options control — that role belongs to ButtonUnfilled with an\n * `Ellipses` glyph, which conveys the menu without a chevron.\n *\n * Use `haspopup` directly for non-menu popups.\n */\n @Prop() hasMenu: boolean = false;\n\n @Event() dsClick!: EventEmitter<MouseEvent>;\n\n private buttonEl: HTMLButtonElement | null = null;\n\n @Method()\n async setFocus() {\n this.buttonEl?.focus();\n }\n\n private handleClick = (event: MouseEvent) => {\n if (this.isInactive || this.isLoading) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n this.dsClick.emit(event);\n };\n\n private get resolvedHaspopup(): ButtonFilledPopup | undefined {\n return this.haspopup ?? (this.hasMenu ? 'menu' : undefined);\n }\n\n private get accessibleName(): string | undefined {\n if (this.ariaLabel) return this.ariaLabel;\n if (this.isLoading && this.variant === 'label' && this.label) return this.label;\n return undefined;\n }\n\n private get doubleInset(): boolean {\n return this.isInset && this.insetDepth === 'double' && this.size !== 'xs';\n }\n\n render() {\n const cls: Record<string, boolean> = {\n 'button-filled': true,\n 'ds-button': true,\n 'ds-focus-ring-inset': true,\n 'ds-control-press-scale': this.pressScale,\n 'ds-interaction-fill': !this.isInactive,\n /* Bold is the default filled contrast — on-bold interaction tokens. */\n 'ds-interaction-fill--on-bold': this.contrast === 'bold',\n 'ds-interaction-fill--on-strong': this.contrast === 'strong',\n 'ds-interaction-fill--on-medium': this.contrast === 'medium',\n /* faint → default app interaction tokens (no --on-*). */\n 'button-filled--bordered': this.hasBorder,\n 'ds-button--bordered': this.hasBorder,\n 'button-filled--expanded': this.expanded === true && !this.isInactive,\n 'ds-button--expanded': this.expanded === true && !this.isInactive,\n 'ds-control-inactive': this.isInactive,\n 'ds-control--lg': this.size === 'lg',\n 'ds-control--md': this.size === 'md',\n 'ds-control--sm': this.size === 'sm',\n 'ds-control--xs': this.size === 'xs',\n 'ds-control--inset': this.isInset && !this.doubleInset,\n 'ds-control--inset-double': this.doubleInset,\n 'ds-control-frame': true,\n 'button-filled--icon': this.variant === 'icon',\n 'ds-button--icon': this.variant === 'icon',\n 'button-filled--label': this.variant === 'label',\n 'button-filled--icon-label': this.variant === 'icon-label',\n 'button-filled--rounded': this.rounded,\n 'ds-button--rounded': this.rounded,\n [`button-filled--background-${this.background}`]: this.background !== undefined,\n [`button-filled--intent-${this.intent}`]: true,\n [`button-filled--contrast-${this.contrast}`]: true,\n };\n\n return (\n <Host\n class={{\n 'button-filled-host': true,\n 'button-filled-host--icon': this.variant === 'icon',\n 'ds-button-host--icon': this.variant === 'icon',\n 'ds-control--lg': this.size === 'lg',\n 'ds-control--md': this.size === 'md',\n 'ds-control--sm': this.size === 'sm',\n 'ds-control--xs': this.size === 'xs',\n 'ds-control--inset': this.isInset && !this.doubleInset,\n 'ds-control--inset-double': this.doubleInset,\n ...controlWidthClass(this.width),\n }}\n tabIndex={-1}\n >\n <button\n ref={el => {\n this.buttonEl = el ?? null;\n }}\n type={this.type}\n class={cls}\n disabled={this.isInactive}\n aria-label={this.accessibleName}\n aria-busy={this.isLoading ? 'true' : undefined}\n aria-disabled={this.isLoading ? 'true' : undefined}\n aria-controls={this.controls}\n aria-expanded={this.expanded === undefined ? undefined : String(this.expanded)}\n aria-haspopup={this.resolvedHaspopup}\n onPointerDown={event =>\n beginElevatedControlPress(event, this.pressScale && !this.isInactive && !this.isLoading)\n }\n onClick={this.handleClick}\n >\n {renderButtonContent({\n namespace: 'button-filled',\n variant: this.variant,\n size: this.size,\n label: this.label,\n labelEmphasis: this.labelEmphasis,\n icon: this.icon,\n hasMenu: this.hasMenu,\n isLoading: this.isLoading,\n })}\n </button>\n </Host>\n );\n }\n}\n",
|
|
636
|
+
"content": "import { Component, Element, Event, EventEmitter, h, Host, Method, Prop } from '@stencil/core';\nimport { controlWidthClass } from '../../utils';\nimport type { ChoiceBackground } from '../../utils/choice-list';\nimport { beginElevatedControlPress } from '../../utils/control-press';\nimport { renderButtonContent } from '../../utils/button-render';\nimport type { ControlInsetDepth } from '../../utils/control-text';\nimport type { ButtonPopup, ButtonSize, ButtonVariant, ButtonWidth } from '../../utils/button-types';\n\nexport type ButtonFilledIntent =\n | 'neutral'\n | 'brand'\n | 'ai'\n | 'negative'\n | 'warning'\n | 'caution'\n | 'positive'\n | 'guide'\n | 'walkthrough';\n\nexport type ButtonFilledContrast = 'bold' | 'strong' | 'medium' | 'faint';\n\nexport type ButtonFilledBackground = ChoiceBackground;\n\nexport type ButtonFilledVariant = ButtonVariant;\nexport type ButtonFilledSize = ButtonSize;\nexport type ButtonFilledWidth = ButtonWidth;\nexport type ButtonFilledPopup = ButtonPopup;\n\n@Component({\n tag: 'ds-button-filled',\n styleUrl: 'ButtonFilled.css',\n scoped: true,\n})\nexport class ButtonFilled {\n @Element() el!: HTMLElement;\n\n /**\n * Content layout. Default is label-only; pass `icon` for icon-only chrome\n * (nav / tool rails) or `icon-label` for leading icon + text.\n */\n @Prop() variant: ButtonFilledVariant = 'label';\n\n /** Control density (height, padding, icon, type). */\n @Prop() size: ButtonFilledSize = 'md';\n\n /** Use reduced outer geometry when nested inside a control of the same size. */\n @Prop() isInset: boolean = false;\n\n /** Single removes 4px overall; double removes 8px overall (xs stays single). */\n @Prop() insetDepth: ControlInsetDepth = 'single';\n\n /** Width fit — hug content (default) or fill the parent. */\n @Prop() width: ButtonFilledWidth = 'hug';\n\n /** Visible text for `label` / `icon-label` variants. */\n @Prop() label: string = '';\n\n /** Whether the visible label uses the emphasized weight. */\n @Prop() labelEmphasis: boolean = true;\n\n /** Icon name passed to <ds-icon> for `icon` / `icon-label` variants. */\n @Prop() icon: string = '';\n\n /** Semantic colour intent. */\n @Prop() intent: ButtonFilledIntent = 'brand';\n\n /**\n * Background fill weight. Foreground uses the paired contrast token:\n * bold → faint, strong → medium, medium → strong, faint → bold.\n */\n @Prop() contrast: ButtonFilledContrast = 'bold';\n\n /** Show a 1px secondary inset border. */\n @Prop() hasBorder: boolean = false;\n\n /**\n * Actual parent surface context for the optional inset border color only.\n * Omit on primary and secondary surfaces.\n */\n @Prop() background: ButtonFilledBackground | undefined;\n\n /** Use the half-radius treatment instead of the default control radius. */\n @Prop() rounded: boolean = false;\n\n /**\n * Scale down during a physical pointer press.\n * Disable when an owning composite requires fixed child or background geometry.\n */\n @Prop() pressScale: boolean = true;\n\n /** Disables interaction. */\n @Prop() isInactive: boolean = false;\n\n /** Shows an inline loader and prevents interaction without applying inactive opacity. */\n @Prop() isLoading: boolean = false;\n\n /** Native button type. */\n @Prop() type: 'button' | 'submit' | 'reset' = 'button';\n\n /** Accessible name override. Required for icon-only buttons. */\n @Prop({ attribute: 'aria-label' }) ariaLabel: string | null = null;\n\n /** ID of the popup this button controls. */\n @Prop() controls: string | undefined;\n\n /**\n * Controlled open state of the popup this button triggers. Holds the pressed\n * wash for the popup's rendered lifecycle. ButtonFilled has no selected state,\n * so an open popup never promotes to an active treatment.\n */\n @Prop() expanded: boolean | undefined;\n\n /** Popup type exposed to assistive technology. */\n @Prop() haspopup: ButtonFilledPopup | undefined;\n\n /**\n * Append a separate ChevronDown menu segment while preserving this button's\n * variant, size, intent, contrast, loading, inactive, and width treatment.\n */\n @Prop() split: boolean = false;\n\n /** Accessible name for the appended menu segment in split mode. */\n @Prop() menuAriaLabel: string = 'More options';\n\n /**\n * This action *has* a menu: implies `aria-haspopup=\"menu\"` and adds the trailing\n * chevron that carries the affordance.\n *\n * Only `label` and `icon-label` are supported. A filled button is never the\n * overflow / more-options control — that role belongs to ButtonUnfilled with an\n * `Ellipses` glyph, which conveys the menu without a chevron.\n *\n * Use `haspopup` directly for non-menu popups.\n */\n @Prop() hasMenu: boolean = false;\n\n @Event() dsClick!: EventEmitter<MouseEvent>;\n @Event() dsMenuClick!: EventEmitter<MouseEvent>;\n\n private buttonEl: HTMLButtonElement | null = null;\n private menuButtonEl: HTMLButtonElement | null = null;\n\n @Method()\n async setFocus(segment: 'primary' | 'menu' = 'primary') {\n (segment === 'menu' ? this.menuButtonEl : this.buttonEl)?.focus();\n }\n\n private handleClick = (event: MouseEvent) => {\n if (this.isInactive || this.isLoading) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n this.dsClick.emit(event);\n };\n\n private handleMenuClick = (event: MouseEvent) => {\n if (this.isInactive || this.isLoading) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n this.dsMenuClick.emit(event);\n };\n\n private get resolvedHaspopup(): ButtonFilledPopup | undefined {\n return this.haspopup ?? (this.hasMenu ? 'menu' : undefined);\n }\n\n private get accessibleName(): string | undefined {\n if (this.ariaLabel) return this.ariaLabel;\n if (this.isLoading && this.variant === 'label' && this.label) return this.label;\n return undefined;\n }\n\n private get doubleInset(): boolean {\n return this.isInset && this.insetDepth === 'double' && this.size !== 'xs';\n }\n\n private buttonClass(\n variant: ButtonFilledVariant,\n expanded: boolean,\n bordered: boolean\n ): Record<string, boolean> {\n const cls: Record<string, boolean> = {\n 'button-filled': true,\n 'ds-button': true,\n 'ds-focus-ring-inset': true,\n 'ds-control-press-scale': this.pressScale && !this.split,\n 'ds-interaction-fill': !this.isInactive,\n /* Bold is the default filled contrast — on-bold interaction tokens. */\n 'ds-interaction-fill--on-bold': this.contrast === 'bold',\n 'ds-interaction-fill--on-strong': this.contrast === 'strong',\n 'ds-interaction-fill--on-medium': this.contrast === 'medium',\n /* faint → default app interaction tokens (no --on-*). */\n 'button-filled--bordered': bordered,\n 'ds-button--bordered': bordered,\n 'button-filled--expanded': expanded && !this.isInactive,\n 'ds-button--expanded': expanded && !this.isInactive,\n 'ds-control-inactive': this.isInactive,\n 'ds-control--lg': this.size === 'lg',\n 'ds-control--md': this.size === 'md',\n 'ds-control--sm': this.size === 'sm',\n 'ds-control--xs': this.size === 'xs',\n 'ds-control--inset': this.isInset && !this.doubleInset,\n 'ds-control--inset-double': this.doubleInset,\n 'ds-control-frame': true,\n 'button-filled--icon': variant === 'icon',\n 'ds-button--icon': variant === 'icon',\n 'button-filled--label': variant === 'label',\n 'button-filled--icon-label': variant === 'icon-label',\n 'button-filled--rounded': this.rounded,\n 'ds-button--rounded': this.rounded,\n [`button-filled--background-${this.background}`]: this.background !== undefined,\n [`button-filled--intent-${this.intent}`]: true,\n [`button-filled--contrast-${this.contrast}`]: true,\n };\n return cls;\n }\n\n render() {\n const primaryButton = (\n <button\n ref={el => {\n this.buttonEl = el ?? null;\n }}\n type={this.type}\n class={{\n ...this.buttonClass(\n this.variant,\n !this.split && this.expanded === true,\n this.hasBorder && !this.split\n ),\n 'ds-button-split__primary': this.split,\n }}\n disabled={this.isInactive}\n aria-label={this.accessibleName}\n aria-busy={this.isLoading ? 'true' : undefined}\n aria-disabled={this.isLoading ? 'true' : undefined}\n aria-controls={this.split ? undefined : this.controls}\n aria-expanded={\n this.split || this.expanded === undefined ? undefined : String(this.expanded)\n }\n aria-haspopup={this.split ? undefined : this.resolvedHaspopup}\n onPointerDown={event =>\n beginElevatedControlPress(\n event,\n this.pressScale && !this.split && !this.isInactive && !this.isLoading\n )\n }\n onClick={this.handleClick}\n >\n {renderButtonContent({\n namespace: 'button-filled',\n variant: this.variant,\n size: this.size,\n label: this.label,\n labelEmphasis: this.labelEmphasis,\n icon: this.icon,\n hasMenu: !this.split && this.hasMenu,\n isLoading: this.isLoading,\n })}\n </button>\n );\n\n const control = this.split ? (\n <div\n class={{\n 'ds-button-split': true,\n 'ds-button-split--rounded': this.rounded,\n }}\n >\n {primaryButton}\n <span class=\"ds-button-split__divider\" aria-hidden=\"true\" />\n <button\n ref={el => {\n this.menuButtonEl = el ?? null;\n }}\n class={{\n ...this.buttonClass('icon', this.expanded === true, false),\n 'ds-button-split__menu': true,\n }}\n type=\"button\"\n disabled={this.isInactive || this.isLoading}\n aria-label={this.menuAriaLabel}\n aria-controls={this.controls}\n aria-expanded={String(this.expanded === true)}\n aria-haspopup=\"menu\"\n onClick={this.handleMenuClick}\n >\n {renderButtonContent({\n namespace: 'button-filled',\n variant: 'icon',\n size: this.size,\n label: '',\n labelEmphasis: true,\n icon: 'ChevronDown',\n hasMenu: false,\n isLoading: false,\n })}\n </button>\n {this.hasBorder ? <span class=\"ds-button-split__outline\" aria-hidden=\"true\" /> : null}\n </div>\n ) : (\n primaryButton\n );\n\n return (\n <Host\n class={{\n 'button-filled-host': true,\n 'button-filled-host--icon': this.variant === 'icon' && !this.split,\n 'ds-button-host--icon': this.variant === 'icon' && !this.split,\n 'ds-button-split-host': this.split,\n 'ds-button-split-host--primary-icon': this.split && this.variant === 'icon',\n [`button-filled-host--contrast-${this.contrast}`]: this.split,\n [`button-filled-host--background-${this.background}`]:\n this.split && this.background !== undefined,\n 'ds-control--lg': this.size === 'lg',\n 'ds-control--md': this.size === 'md',\n 'ds-control--sm': this.size === 'sm',\n 'ds-control--xs': this.size === 'xs',\n 'ds-control--inset': this.isInset && !this.doubleInset,\n 'ds-control--inset-double': this.doubleInset,\n ...controlWidthClass(this.width),\n }}\n tabIndex={-1}\n >\n {control}\n </Host>\n );\n }\n}\n",
|
|
583
637
|
"type": "registry:ui"
|
|
584
638
|
}
|
|
585
639
|
]
|