@redvars/peacock 3.8.1 → 3.8.3
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/{BaseInput-14YmcfK7.js → BaseInput-CU1zZYKc.js} +3 -3
- package/dist/{BaseInput-14YmcfK7.js.map → BaseInput-CU1zZYKc.js.map} +1 -1
- package/dist/ButtonConstants-CahP2_NA.js +4 -0
- package/dist/ButtonConstants-CahP2_NA.js.map +1 -0
- package/dist/{IndividualComponent-DUINtMGK.js → IndividualComponent-Bdwyrvd6.js} +2 -2
- package/dist/{IndividualComponent-DUINtMGK.js.map → IndividualComponent-Bdwyrvd6.js.map} +1 -1
- package/dist/{NativeHyperlinkMixin-DrYXyfMQ.js → NativeHyperlinkMixin-D9J4aBTy.js} +4 -30
- package/dist/NativeHyperlinkMixin-D9J4aBTy.js.map +1 -0
- package/dist/accordion-item.js +338 -0
- package/dist/accordion-item.js.map +1 -0
- package/dist/accordion.js +159 -0
- package/dist/accordion.js.map +1 -0
- package/dist/alert.js +190 -0
- package/dist/alert.js.map +1 -0
- package/dist/app-bar.js +324 -0
- package/dist/app-bar.js.map +1 -0
- package/dist/assets/components.css +1 -1
- package/dist/assets/components.css.map +1 -1
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/attachable-controller-CAKVrfcG.js +119 -0
- package/dist/attachable-controller-CAKVrfcG.js.map +1 -0
- package/dist/avatar.js +114 -0
- package/dist/avatar.js.map +1 -0
- package/dist/babel-DBsfpl3B.js +18 -0
- package/dist/babel-DBsfpl3B.js.map +1 -0
- package/dist/badge.js +91 -0
- package/dist/badge.js.map +1 -0
- package/dist/base-Cl6v8-BZ.js +9 -0
- package/dist/base-Cl6v8-BZ.js.map +1 -0
- package/dist/bottom-sheet.js +14 -5
- package/dist/bottom-sheet.js.map +1 -1
- package/dist/breadcrumb-item.js +163 -0
- package/dist/breadcrumb-item.js.map +1 -0
- package/dist/breadcrumb.js +95 -0
- package/dist/breadcrumb.js.map +1 -0
- package/dist/button-group.js +87 -137
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +863 -133
- package/dist/button.js.map +1 -1
- package/dist/calendar-column-view.js +8 -4
- package/dist/calendar-column-view.js.map +1 -1
- package/dist/calendar-month-view.js +8 -4
- package/dist/calendar-month-view.js.map +1 -1
- package/dist/calendar.js +8 -4
- package/dist/calendar.js.map +1 -1
- package/dist/canvas.js +8 -4
- package/dist/canvas.js.map +1 -1
- package/dist/card-content.js +1 -1
- package/dist/card.js +45 -52
- package/dist/card.js.map +1 -1
- package/dist/cb-compound-expression.js +6 -2
- package/dist/cb-compound-expression.js.map +1 -1
- package/dist/cb-divider.js +7 -3
- package/dist/cb-divider.js.map +1 -1
- package/dist/cb-expression.js +6 -2
- package/dist/cb-expression.js.map +1 -1
- package/dist/cb-predicate.js +7 -3
- package/dist/cb-predicate.js.map +1 -1
- package/dist/{chart-bar-cn6rrna-.js → chart-bar-CYoGNXnK.js} +6 -2
- package/dist/{chart-bar-cn6rrna-.js.map → chart-bar-CYoGNXnK.js.map} +1 -1
- package/dist/chart-bar.js +7 -6
- package/dist/chart-bar.js.map +1 -1
- package/dist/chart-doughnut.js +8 -3
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-pie.js +8 -3
- package/dist/chart-pie.js.map +1 -1
- package/dist/chart-stacked-bar.js +7 -6
- package/dist/chart-stacked-bar.js.map +1 -1
- package/dist/checkbox.js +526 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/chip.js +459 -0
- package/dist/chip.js.map +1 -0
- package/dist/{class-map-YU7g0o3B.js → class-map-DG7CA1et.js} +2 -2
- package/dist/{class-map-YU7g0o3B.js.map → class-map-DG7CA1et.js.map} +1 -1
- package/dist/clock.js +6 -2
- package/dist/clock.js.map +1 -1
- package/dist/code-editor.js +45 -30
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +82 -11216
- package/dist/code-highlighter.js.map +1 -1
- package/dist/color-picker.js +701 -0
- package/dist/color-picker.js.map +1 -0
- package/dist/condition-builder.js +5 -1
- package/dist/condition-builder.js.map +1 -1
- package/dist/container.js +141 -0
- package/dist/container.js.map +1 -0
- package/dist/custom-elements-jsdocs.json +823 -778
- package/dist/custom-elements.json +4067 -2207
- package/dist/datasource-B2eRh6Or.js +108 -0
- package/dist/datasource-B2eRh6Or.js.map +1 -0
- package/dist/dispatch-event-utils-CuEqjlPT.js.map +1 -1
- package/dist/divider.js +135 -0
- package/dist/divider.js.map +1 -0
- package/dist/dropdown-button.js +11 -6
- package/dist/dropdown-button.js.map +1 -1
- package/dist/element-internals-2CMts_0M.js +290 -0
- package/dist/element-internals-2CMts_0M.js.map +1 -0
- package/dist/elevation.js +94 -0
- package/dist/elevation.js.map +1 -0
- package/dist/empty-state.js +194 -0
- package/dist/empty-state.js.map +1 -0
- package/dist/estree-C2LDzX4U.js +47 -0
- package/dist/estree-C2LDzX4U.js.map +1 -0
- package/dist/{event-manager-D-QCmUgR.js → event-manager-DTyX2uYD.js} +2 -2
- package/dist/{event-manager-D-QCmUgR.js.map → event-manager-DTyX2uYD.js.map} +1 -1
- package/dist/fab.js +139 -148
- package/dist/fab.js.map +1 -1
- package/dist/field.js +461 -0
- package/dist/field.js.map +1 -0
- package/dist/{popover-DUPmMVWS.js → floating-controller-CnUZnOhK.js} +2 -171
- package/dist/floating-controller-CnUZnOhK.js.map +1 -0
- package/dist/{flow-designer-node-BWrPuxAR.js → flow-designer-node-DsVwQTac.js} +7 -3
- package/dist/{flow-designer-node-BWrPuxAR.js.map → flow-designer-node-DsVwQTac.js.map} +1 -1
- package/dist/flow-designer-node.js +3 -3
- package/dist/flow-designer.js +19 -12
- package/dist/flow-designer.js.map +1 -1
- package/dist/focus-ring.js +126 -0
- package/dist/focus-ring.js.map +1 -0
- package/dist/form-associated-BXADnjOB.js +388 -0
- package/dist/form-associated-BXADnjOB.js.map +1 -0
- package/dist/html-D22sQuVy.js +27 -0
- package/dist/html-D22sQuVy.js.map +1 -0
- package/dist/html-editor.js +21 -9
- package/dist/html-editor.js.map +1 -1
- package/dist/hyperlink-DLvb6MXE.js +98 -0
- package/dist/hyperlink-DLvb6MXE.js.map +1 -0
- package/dist/icon-button.js +1064 -0
- package/dist/icon-button.js.map +1 -0
- package/dist/icon.js +170 -0
- package/dist/icon.js.map +1 -0
- package/dist/if-defined-BXZpRQ4P.js +10 -0
- package/dist/if-defined-BXZpRQ4P.js.map +1 -0
- package/dist/image.js +201 -0
- package/dist/image.js.map +1 -0
- package/dist/index-_g_oLekF.js +14095 -0
- package/dist/index-_g_oLekF.js.map +1 -0
- package/dist/index.js +74 -20
- package/dist/index.js.map +1 -1
- package/dist/is-dark-mode-DOcaw4Yq.js.map +1 -1
- package/dist/is-link-Dk2OV3PM.js +6 -0
- package/dist/is-link-Dk2OV3PM.js.map +1 -0
- package/dist/item.js +213 -0
- package/dist/item.js.map +1 -0
- package/dist/link.js +75 -0
- package/dist/link.js.map +1 -0
- package/dist/list-H0itjRte.js +526 -0
- package/dist/list-H0itjRte.js.map +1 -0
- package/dist/list.js +14 -0
- package/dist/list.js.map +1 -0
- package/dist/{peacock-loader.js → loader.js} +87 -22
- package/dist/loader.js.map +1 -0
- package/dist/menu-item.js +388 -0
- package/dist/menu-item.js.map +1 -0
- package/dist/menu.js +520 -0
- package/dist/menu.js.map +1 -0
- package/dist/modal.js +9 -5
- package/dist/modal.js.map +1 -1
- package/dist/navigation-rail-item.js +400 -0
- package/dist/navigation-rail-item.js.map +1 -0
- package/dist/navigation-rail.js +219 -0
- package/dist/navigation-rail.js.map +1 -0
- package/dist/notification-manager.js +8 -4
- package/dist/notification-manager.js.map +1 -1
- package/dist/notification.js +8 -4
- package/dist/notification.js.map +1 -1
- package/dist/number-counter.js +7 -3
- package/dist/number-counter.js.map +1 -1
- package/dist/{observe-slot-change-D8Xg-kSS.js → observe-slot-change-DPxaZrZF.js} +3 -4
- package/dist/observe-slot-change-DPxaZrZF.js.map +1 -0
- package/dist/option.js +121 -0
- package/dist/option.js.map +1 -0
- package/dist/pagination.js +255 -0
- package/dist/pagination.js.map +1 -0
- package/dist/pierre-dark-DFWl0m-C.js +4 -0
- package/dist/pierre-dark-DFWl0m-C.js.map +1 -0
- package/dist/pierre-light-BEkAPImt.js +4 -0
- package/dist/pierre-light-BEkAPImt.js.map +1 -0
- package/dist/popover-content.js +7 -3
- package/dist/popover-content.js.map +1 -1
- package/dist/popover.js +175 -3
- package/dist/popover.js.map +1 -1
- package/dist/postcss-BhbitHaI.js +64 -0
- package/dist/postcss-BhbitHaI.js.map +1 -0
- package/dist/{property-1psGvXOq.js → property-B49QQ8pS.js} +2 -2
- package/dist/{property-1psGvXOq.js.map → property-B49QQ8pS.js.map} +1 -1
- package/dist/query-CHb9Ft_d.js +10 -0
- package/dist/query-CHb9Ft_d.js.map +1 -0
- package/dist/query-assigned-elements-BJaGSqM0.js +10 -0
- package/dist/query-assigned-elements-BJaGSqM0.js.map +1 -0
- package/dist/radio.js +476 -0
- package/dist/radio.js.map +1 -0
- package/dist/ripple.js +506 -0
- package/dist/ripple.js.map +1 -0
- package/dist/search.js +12 -7
- package/dist/search.js.map +1 -1
- package/dist/segmented-button-group.js +137 -0
- package/dist/segmented-button-group.js.map +1 -0
- package/dist/segmented-button.js +289 -0
- package/dist/segmented-button.js.map +1 -0
- package/dist/select-CspawZ18.js +3944 -0
- package/dist/select-CspawZ18.js.map +1 -0
- package/dist/side-sheet.js +9 -5
- package/dist/side-sheet.js.map +1 -1
- package/dist/skeleton.js +122 -0
- package/dist/skeleton.js.map +1 -0
- package/dist/slider.js +346 -0
- package/dist/slider.js.map +1 -0
- package/dist/snackbar.js +335 -0
- package/dist/snackbar.js.map +1 -0
- package/dist/spinner.js +100 -0
- package/dist/spinner.js.map +1 -0
- package/dist/split-button.js +10 -5
- package/dist/split-button.js.map +1 -1
- package/dist/spread-B5cgadZl.js +32 -0
- package/dist/spread-B5cgadZl.js.map +1 -0
- package/dist/src/__internal/aria/aria.d.ts +98 -0
- package/dist/src/__internal/aria/delegate.d.ts +54 -0
- package/dist/src/__internal/events/dispatch-hooks.d.ts +80 -0
- package/dist/src/__internal/mixins/element-internals.d.ts +40 -0
- package/dist/src/__internal/mixins/form-associated.d.ts +174 -0
- package/dist/src/__internal/mixins/form-submitter.d.ts +59 -0
- package/dist/src/__internal/mixins/hyperlink.d.ts +42 -0
- package/dist/src/__internal/mixins/mixin.d.ts +49 -0
- package/dist/src/{__utils → __internal/utils}/observe-slot-change.d.ts +1 -0
- package/dist/src/accordion/accordion-item.d.ts +3 -1
- package/dist/src/accordion/accordion.d.ts +1 -1
- package/dist/src/alert/alert.d.ts +43 -0
- package/dist/src/alert/index.d.ts +1 -0
- package/dist/src/app-bar/app-bar.d.ts +92 -0
- package/dist/src/app-bar/index.d.ts +1 -0
- package/dist/src/avatar/avatar.d.ts +2 -0
- package/dist/src/bottom-sheet/bottom-sheet.d.ts +1 -1
- package/dist/src/breadcrumb/breadcrumb-item/breadcrumb-item.d.ts +1 -0
- package/dist/src/button/ButtonTypes.d.ts +5 -0
- package/dist/src/button/base-button/base-button.d.ts +18 -0
- package/dist/src/button/button/button.d.ts +29 -37
- package/dist/src/button/button-group/button-group.d.ts +17 -18
- package/dist/src/{fab → button/fab}/fab.d.ts +8 -26
- package/dist/src/button/icon-button/icon-button.d.ts +20 -27
- package/dist/src/button/index.d.ts +1 -0
- package/dist/src/calendar/calendar.d.ts +1 -1
- package/dist/src/canvas/canvas.d.ts +1 -1
- package/dist/src/card/card.d.ts +5 -6
- package/dist/src/chart-bar/chart-bar.d.ts +1 -1
- package/dist/src/chart-bar/chart-stacked-bar.d.ts +1 -1
- package/dist/src/checkbox/checkbox.d.ts +5 -1
- package/dist/src/chip/chip/chip.d.ts +9 -8
- package/dist/src/code-highlighter/code-highlighter.d.ts +2 -2
- package/dist/src/color-picker/color-picker.d.ts +85 -0
- package/dist/src/color-picker/index.d.ts +1 -0
- package/dist/src/container/container.d.ts +5 -1
- package/dist/src/divider/divider.d.ts +2 -0
- package/dist/src/empty-state/empty-state.d.ts +1 -0
- package/dist/src/field/field.d.ts +19 -1
- package/dist/src/focus-ring/focus-ring.d.ts +3 -7
- package/dist/src/html-editor/html-editor.d.ts +1 -1
- package/dist/src/icon/icon.d.ts +9 -4
- package/dist/src/image/image.d.ts +4 -0
- package/dist/src/index.d.ts +8 -6
- package/dist/src/item/item.d.ts +19 -29
- package/dist/src/link/link.d.ts +1 -1
- package/dist/src/list/list-item.d.ts +10 -6
- package/dist/src/list/list.d.ts +27 -2
- package/dist/src/menu/menu/menu.d.ts +14 -0
- package/dist/src/menu/menu-item/menu-item.d.ts +11 -4
- package/dist/src/modal/modal.d.ts +1 -1
- package/dist/src/navigation-rail/navigation-rail-item.d.ts +5 -4
- package/dist/src/navigation-rail/navigation-rail.d.ts +1 -1
- package/dist/src/radio/radio.d.ts +5 -0
- package/dist/src/ripple/ripple.d.ts +10 -1
- package/dist/src/search/search.d.ts +1 -1
- package/dist/src/segmented-button/segmented-button-group.d.ts +2 -2
- package/dist/src/segmented-button/segmented-button.d.ts +2 -0
- package/dist/src/side-sheet/side-sheet.d.ts +1 -1
- package/dist/src/skeleton/skeleton.d.ts +1 -0
- package/dist/src/slider/slider.d.ts +1 -0
- package/dist/src/snackbar/snackbar.d.ts +12 -2
- package/dist/src/svg/svg.d.ts +5 -0
- package/dist/src/table/table.d.ts +5 -0
- package/dist/src/tabs/tab.d.ts +2 -7
- package/dist/src/toolbar/toolbar.d.ts +2 -2
- package/dist/standalone-Ccq0tWwA.js +32 -0
- package/dist/standalone-Ccq0tWwA.js.map +1 -0
- package/dist/{state-DwbEjqVk.js → state-DkTK9EGF.js} +2 -2
- package/dist/{state-DwbEjqVk.js.map → state-DkTK9EGF.js.map} +1 -1
- package/dist/{style-map-DVmWOuYy.js → style-map-BQD5Et1D.js} +2 -2
- package/dist/{style-map-DVmWOuYy.js.map → style-map-BQD5Et1D.js.map} +1 -1
- package/dist/sub-menu.js +246 -0
- package/dist/sub-menu.js.map +1 -0
- package/dist/svg.js +273 -0
- package/dist/svg.js.map +1 -0
- package/dist/tab-group.js +188 -0
- package/dist/tab-group.js.map +1 -0
- package/dist/tab-panel.js +61 -0
- package/dist/tab-panel.js.map +1 -0
- package/dist/tab.js +658 -0
- package/dist/tab.js.map +1 -0
- package/dist/table.js +620 -0
- package/dist/table.js.map +1 -0
- package/dist/tabs.js +240 -0
- package/dist/tabs.js.map +1 -0
- package/dist/throttle-C7ZAPqtu.js +24 -0
- package/dist/throttle-C7ZAPqtu.js.map +1 -0
- package/dist/toolbar.js +9 -5
- package/dist/toolbar.js.map +1 -1
- package/dist/tooltip.js +270 -0
- package/dist/tooltip.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{unsafe-html-BsGUjx94.js → unsafe-html-Ct0N2_UU.js} +2 -2
- package/dist/{unsafe-html-BsGUjx94.js.map → unsafe-html-Ct0N2_UU.js.map} +1 -1
- package/dist/when-DEJm_QN9.js +9 -0
- package/dist/when-DEJm_QN9.js.map +1 -0
- package/package.json +4 -2
- package/readme.md +4 -4
- package/scss/mixin.scss +9 -6
- package/src/__internal/aria/aria.ts +293 -0
- package/src/__internal/aria/delegate.ts +206 -0
- package/src/__internal/events/dispatch-hooks.ts +182 -0
- package/src/__internal/mixins/element-internals.ts +73 -0
- package/src/__internal/mixins/form-associated.ts +295 -0
- package/src/__internal/mixins/form-submitter.ts +133 -0
- package/src/__internal/mixins/hyperlink.ts +71 -0
- package/src/__internal/mixins/mixin.ts +58 -0
- package/src/{__utils → __internal/utils}/observe-slot-change.ts +2 -5
- package/src/accordion/accordion-item.ts +6 -2
- package/src/accordion/accordion.ts +4 -2
- package/src/accordion/demo/index.html +95 -90
- package/src/alert/alert.scss +82 -0
- package/src/{banner/banner.ts → alert/alert.ts} +22 -22
- package/src/alert/index.ts +1 -0
- package/src/app-bar/app-bar-colors.scss +17 -0
- package/src/app-bar/app-bar.scss +165 -0
- package/src/app-bar/app-bar.ts +155 -0
- package/src/app-bar/index.ts +1 -0
- package/src/avatar/avatar.ts +4 -0
- package/src/badge/badge.ts +2 -0
- package/src/bottom-sheet/bottom-sheet.ts +8 -2
- package/src/breadcrumb/breadcrumb/breadcrumb.ts +2 -0
- package/src/breadcrumb/breadcrumb-item/breadcrumb-item.ts +3 -0
- package/src/button/ButtonTypes.ts +17 -0
- package/src/button/base-button/base-button.ts +85 -0
- package/src/button/button/button-base.scss +307 -0
- package/src/button/button/button-colors.scss +27 -32
- package/src/button/button/button-layers.scss +126 -43
- package/src/button/button/button-shapes.scss +73 -0
- package/src/button/button/button.scss +12 -286
- package/src/button/button/button.ts +174 -194
- package/src/button/button-group/button-group.scss +43 -36
- package/src/button/button-group/button-group.ts +26 -137
- package/src/{fab → button/fab}/fab-colors.scss +0 -10
- package/src/button/fab/fab-sizes.scss +37 -0
- package/src/button/fab/fab.scss +172 -0
- package/src/{fab → button/fab}/fab.ts +69 -109
- package/src/button/icon-button/icon-button-sizes.scss +18 -3
- package/src/button/icon-button/icon-button.scss +5 -0
- package/src/button/icon-button/icon-button.ts +111 -141
- package/src/button/index.ts +7 -0
- package/src/calendar/calendar.ts +2 -2
- package/src/canvas/canvas.ts +2 -2
- package/src/card/card.scss +21 -8
- package/src/card/card.ts +20 -40
- package/src/chart-bar/chart-bar.ts +2 -2
- package/src/chart-bar/chart-stacked-bar.ts +2 -2
- package/src/checkbox/checkbox.ts +12 -4
- package/src/chip/chip/chip.scss +1 -1
- package/src/chip/chip/chip.ts +35 -55
- package/src/chip/demo/index.html +30 -26
- package/src/code-editor/code-editor.ts +68 -58
- package/src/code-editor/demo/index.html +32 -27
- package/src/code-highlighter/code-highlighter.ts +95 -40
- package/src/code-highlighter/demo/index.html +24 -21
- package/src/color-picker/color-picker.scss +217 -0
- package/src/color-picker/color-picker.ts +478 -0
- package/src/color-picker/index.ts +1 -0
- package/src/container/container.ts +8 -2
- package/src/date-picker/date-picker.ts +2 -3
- package/src/divider/divider.ts +5 -1
- package/src/dropdown-button/demo/index.html +106 -101
- package/src/dropdown-button/dropdown-button.ts +1 -1
- package/src/elevation/elevation.ts +2 -0
- package/src/empty-state/empty-state.ts +3 -0
- package/src/field/field.ts +52 -33
- package/src/focus-ring/focus-ring.ts +5 -7
- package/src/html-editor/html-editor.ts +28 -16
- package/src/icon/datasource.ts +1 -1
- package/src/icon/icon.ts +27 -15
- package/src/image/image.ts +18 -6
- package/src/index.ts +25 -6
- package/src/input/input.ts +2 -2
- package/src/item/item.scss +127 -161
- package/src/item/item.ts +69 -323
- package/src/link/link.ts +3 -1
- package/src/list/list-item.scss +48 -32
- package/src/list/list-item.ts +109 -79
- package/src/list/list.scss +1 -13
- package/src/list/list.ts +170 -5
- package/src/{peacock-loader.ts → loader.ts} +95 -79
- package/src/menu/menu/menu.scss +15 -26
- package/src/menu/menu/menu.ts +20 -9
- package/src/menu/menu-item/menu-item.scss +82 -20
- package/src/menu/menu-item/menu-item.ts +85 -46
- package/src/menu/sub-menu/sub-menu.scss +5 -1
- package/src/menu/sub-menu/sub-menu.ts +3 -0
- package/src/modal/modal.ts +2 -2
- package/src/navigation-rail/navigation-rail-item.scss +25 -8
- package/src/navigation-rail/navigation-rail-item.ts +21 -36
- package/src/navigation-rail/navigation-rail.scss +25 -21
- package/src/navigation-rail/navigation-rail.ts +4 -2
- package/src/number-field/number-field.ts +2 -2
- package/src/pagination/pagination.ts +2 -0
- package/src/popover/popover.ts +3 -3
- package/src/radio/radio.ts +13 -5
- package/src/ripple/ripple.ts +14 -1
- package/src/search/search.ts +3 -3
- package/src/segmented-button/segmented-button-group.ts +8 -4
- package/src/segmented-button/segmented-button.ts +4 -0
- package/src/select/option.ts +2 -0
- package/src/side-sheet/side-sheet.ts +3 -3
- package/src/sidebar-menu/sidebar-menu-item.scss +12 -6
- package/src/sidebar-menu/sidebar-menu-item.ts +3 -2
- package/src/skeleton/skeleton.ts +3 -0
- package/src/slider/slider.ts +4 -1
- package/src/snackbar/snackbar.ts +40 -25
- package/src/spinner/spinner.ts +2 -0
- package/src/svg/svg.ts +27 -9
- package/src/switch/switch.ts +1 -1
- package/src/table/table.ts +16 -3
- package/src/tabs/demo/index.html +79 -79
- package/src/tabs/tab-group.ts +2 -0
- package/src/tabs/tab-panel.ts +2 -0
- package/src/tabs/tab.scss +4 -4
- package/src/tabs/tab.ts +16 -39
- package/src/tabs/tabs.ts +2 -0
- package/src/textarea/textarea.ts +2 -2
- package/src/time-picker/time-picker.ts +2 -2
- package/src/toolbar/toolbar.ts +3 -3
- package/src/tooltip/tooltip.ts +14 -8
- package/src/url-field/url-field.ts +2 -3
- package/dist/ButtonConstants-D06bY4uy.js +0 -114
- package/dist/ButtonConstants-D06bY4uy.js.map +0 -1
- package/dist/NativeHyperlinkMixin-DrYXyfMQ.js.map +0 -1
- package/dist/banner.js +0 -186
- package/dist/banner.js.map +0 -1
- package/dist/button-colors-D7sJyPy8.js +0 -586
- package/dist/button-colors-D7sJyPy8.js.map +0 -1
- package/dist/icon-CueRR7wx.js +0 -260
- package/dist/icon-CueRR7wx.js.map +0 -1
- package/dist/icon-button-CAzYr_qr.js +0 -318
- package/dist/icon-button-CAzYr_qr.js.map +0 -1
- package/dist/navigation-rail-CM_svs5_.js +0 -14184
- package/dist/navigation-rail-CM_svs5_.js.map +0 -1
- package/dist/observe-slot-change-D8Xg-kSS.js.map +0 -1
- package/dist/peacock-loader.js.map +0 -1
- package/dist/popover-DUPmMVWS.js.map +0 -1
- package/dist/query-QBcUV-L_.js +0 -15
- package/dist/query-QBcUV-L_.js.map +0 -1
- package/dist/src/banner/banner.d.ts +0 -43
- package/dist/src/banner/index.d.ts +0 -1
- package/dist/src/button/GroupButtonInterface.d.ts +0 -4
- package/src/banner/banner.scss +0 -82
- package/src/banner/index.ts +0 -1
- package/src/button/GroupButtonInterface.ts +0 -4
- package/src/button/button/only-button.scss +0 -13
- package/src/fab/fab-sizes.scss +0 -37
- package/src/fab/fab.scss +0 -143
- /package/dist/src/{__controllers → __internal/controllers}/attachable-controller.d.ts +0 -0
- /package/dist/src/{__controllers → __internal/controllers}/floating-controller.d.ts +0 -0
- /package/dist/src/{__directive → __internal/directive}/spread.d.ts +0 -0
- /package/dist/src/{__mixins → __internal/mixins}/MixinConstructor.d.ts +0 -0
- /package/dist/src/{__mixins → __internal/mixins}/NativeButtonMixin.d.ts +0 -0
- /package/dist/src/{__mixins → __internal/mixins}/NativeHyperlinkMixin.d.ts +0 -0
- /package/dist/src/{__utils → __internal/utils}/cache-fetch.d.ts +0 -0
- /package/dist/src/{__utils → __internal/utils}/copy-to-clipboard.d.ts +0 -0
- /package/dist/src/{__utils → __internal/utils}/dispatch-event-utils.d.ts +0 -0
- /package/dist/src/{__utils → __internal/utils}/is-dark-mode.d.ts +0 -0
- /package/dist/src/{__utils → __internal/utils}/is-in-viewport.d.ts +0 -0
- /package/dist/src/{__utils → __internal/utils}/is-link.d.ts +0 -0
- /package/dist/src/{__utils → __internal/utils}/observe-theme-change.d.ts +0 -0
- /package/dist/src/{__utils → __internal/utils}/sanitize-svg.d.ts +0 -0
- /package/dist/src/{__utils → __internal/utils}/throttle.d.ts +0 -0
- /package/dist/src/{fab → button/fab}/index.d.ts +0 -0
- /package/dist/src/{peacock-loader.d.ts → loader.d.ts} +0 -0
- /package/dist/test/{banner.test.d.ts → alert.test.d.ts} +0 -0
- /package/src/{__controllers → __internal/controllers}/attachable-controller.ts +0 -0
- /package/src/{__controllers → __internal/controllers}/floating-controller.ts +0 -0
- /package/src/{__directive → __internal/directive}/spread.ts +0 -0
- /package/src/{__mixins → __internal/mixins}/MixinConstructor.ts +0 -0
- /package/src/{__mixins → __internal/mixins}/NativeButtonMixin.ts +0 -0
- /package/src/{__mixins → __internal/mixins}/NativeHyperlinkMixin.ts +0 -0
- /package/src/{__mixins → __internal/mixins}/README.md +0 -0
- /package/src/{__utils → __internal/utils}/cache-fetch.ts +0 -0
- /package/src/{__utils → __internal/utils}/copy-to-clipboard.ts +0 -0
- /package/src/{__utils → __internal/utils}/dispatch-event-utils.ts +0 -0
- /package/src/{__utils → __internal/utils}/is-dark-mode.ts +0 -0
- /package/src/{__utils → __internal/utils}/is-in-viewport.ts +0 -0
- /package/src/{__utils → __internal/utils}/is-link.ts +0 -0
- /package/src/{__utils → __internal/utils}/observe-theme-change.ts +0 -0
- /package/src/{__utils → __internal/utils}/sanitize-svg.ts +0 -0
- /package/src/{__utils → __internal/utils}/throttle.ts +0 -0
- /package/src/{fab → button/fab}/index.ts +0 -0
|
@@ -0,0 +1,3944 @@
|
|
|
1
|
+
import { i, _ as __decorate, a as i$1, b, A } from './IndividualComponent-Bdwyrvd6.js';
|
|
2
|
+
import { n } from './property-B49QQ8pS.js';
|
|
3
|
+
import { e } from './class-map-DG7CA1et.js';
|
|
4
|
+
import { o } from './style-map-BQD5Et1D.js';
|
|
5
|
+
import { r } from './state-DkTK9EGF.js';
|
|
6
|
+
import { e as e$1 } from './query-CHb9Ft_d.js';
|
|
7
|
+
import { r as redispatchEvent } from './dispatch-event-utils-CuEqjlPT.js';
|
|
8
|
+
import { s as spread } from './spread-B5cgadZl.js';
|
|
9
|
+
import { B as BaseInput } from './BaseInput-CU1zZYKc.js';
|
|
10
|
+
import { SelectOptionElement } from './option.js';
|
|
11
|
+
|
|
12
|
+
var css_248z$g = i`* {
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.screen-reader-only {
|
|
17
|
+
display: none !important;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[hidden] {
|
|
21
|
+
display: none !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host {
|
|
25
|
+
display: inline-block;
|
|
26
|
+
--tag-container-shape: inherit;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.tag {
|
|
30
|
+
position: relative;
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
height: var(--tag-height, var(--_chip-height, 2rem));
|
|
36
|
+
padding-inline: calc(var(--_container-padding) / 2);
|
|
37
|
+
width: 100%;
|
|
38
|
+
--_container-shape: var(--tag-container-shape, var(--shape-corner-medium));
|
|
39
|
+
--_container-corner-shape-variant: squircle;
|
|
40
|
+
}
|
|
41
|
+
.tag .tag-content {
|
|
42
|
+
position: relative;
|
|
43
|
+
z-index: 1;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
max-width: 100%;
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
color: var(--_input-text-color);
|
|
52
|
+
--icon-color: currentColor;
|
|
53
|
+
}
|
|
54
|
+
.tag .tag-content .slot-content {
|
|
55
|
+
padding-inline: calc(var(--_container-padding) / 2);
|
|
56
|
+
}
|
|
57
|
+
.tag .dismiss-button {
|
|
58
|
+
position: relative;
|
|
59
|
+
border-radius: 12px;
|
|
60
|
+
padding: 0;
|
|
61
|
+
margin: 0;
|
|
62
|
+
border: none;
|
|
63
|
+
background: transparent;
|
|
64
|
+
line-height: 0;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
}
|
|
67
|
+
.tag .dismiss-button .dismiss-button-icon {
|
|
68
|
+
--icon-size: var(--tag-icon-size, var(--_tag-icon-size));
|
|
69
|
+
--icon-color: var(--_input-text-color);
|
|
70
|
+
}
|
|
71
|
+
.tag .dismiss-button .ripple {
|
|
72
|
+
--ripple-state-opacity: var(--_container-state-opacity, 0);
|
|
73
|
+
--ripple-pressed-color: var(--_container-state-color);
|
|
74
|
+
}
|
|
75
|
+
.tag {
|
|
76
|
+
/**
|
|
77
|
+
* Tag background layers
|
|
78
|
+
*/
|
|
79
|
+
}
|
|
80
|
+
.tag .background {
|
|
81
|
+
display: block;
|
|
82
|
+
position: absolute;
|
|
83
|
+
width: 100%;
|
|
84
|
+
height: 100%;
|
|
85
|
+
background: var(--_container-color);
|
|
86
|
+
border-radius: var(--_container-shape);
|
|
87
|
+
corner-shape: var(--_container-corner-shape-variant);
|
|
88
|
+
pointer-events: none;
|
|
89
|
+
}
|
|
90
|
+
.tag .outline {
|
|
91
|
+
display: block;
|
|
92
|
+
position: absolute;
|
|
93
|
+
width: 100%;
|
|
94
|
+
height: 100%;
|
|
95
|
+
border-radius: var(--_container-shape);
|
|
96
|
+
corner-shape: var(--_container-corner-shape-variant);
|
|
97
|
+
border: 1px solid var(--_outline-color);
|
|
98
|
+
}
|
|
99
|
+
.tag .elevation {
|
|
100
|
+
--elevation-level: 0;
|
|
101
|
+
transition-duration: 280ms;
|
|
102
|
+
border-radius: var(--_container-shape);
|
|
103
|
+
corner-shape: var(--_container-corner-shape-variant);
|
|
104
|
+
}
|
|
105
|
+
.tag.dismissible .tag-content {
|
|
106
|
+
padding-inline-end: 0.25rem;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
slot::slotted(*) {
|
|
110
|
+
--icon-size: var(--tag-icon-size, var(--_tag-icon-size));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* IconButton variant definitions
|
|
115
|
+
*/
|
|
116
|
+
.tag.variant-elevated {
|
|
117
|
+
--_container-color: var(--elevated-tag-container-color);
|
|
118
|
+
--_input-text-color: var(--elevated-tag-label-text-color);
|
|
119
|
+
--_container-elevation-level: 1;
|
|
120
|
+
--_container-state-color: var(--_input-text-color);
|
|
121
|
+
}
|
|
122
|
+
.tag.variant-elevated .dismiss-button:hover {
|
|
123
|
+
--_container-state-opacity: 0.08;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.tag.variant-filled {
|
|
127
|
+
--_container-color: var(--filled-tag-container-color);
|
|
128
|
+
--_input-text-color: var(--filled-tag-label-text-color);
|
|
129
|
+
--_container-state-color: var(--_input-text-color);
|
|
130
|
+
}
|
|
131
|
+
.tag.variant-filled .dismiss-button:hover {
|
|
132
|
+
--_container-state-opacity: 0.08;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.tag.variant-tonal {
|
|
136
|
+
--_container-color: var(--tonal-tag-container-color);
|
|
137
|
+
--_input-text-color: var(--tonal-tag-label-text-color);
|
|
138
|
+
--_container-state-color: var(--_input-text-color);
|
|
139
|
+
}
|
|
140
|
+
.tag.variant-tonal .dismiss-button:hover {
|
|
141
|
+
--_container-state-opacity: 0.08;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.tag.variant-outlined {
|
|
145
|
+
--_outline-color: var(--outlined-tag-outline-color);
|
|
146
|
+
--_input-text-color: var(--outlined-tag-label-text-color);
|
|
147
|
+
--_container-state-color: var(--_input-text-color);
|
|
148
|
+
}
|
|
149
|
+
.tag.variant-outlined .dismiss-button:hover {
|
|
150
|
+
--_container-state-opacity: 0.08;
|
|
151
|
+
}`;
|
|
152
|
+
|
|
153
|
+
var css_248z$f = i`:host([color=default]) {
|
|
154
|
+
--filled-tag-container-color: var(--color-surface);
|
|
155
|
+
--filled-tag-label-text-color: var(--color-on-surface);
|
|
156
|
+
--tonal-tag-container-color: var(--color-surface-container);
|
|
157
|
+
--tonal-tag-label-text-color: var(--color-on-surface-container);
|
|
158
|
+
--elevated-tag-container-color: var(--color-surface-container-low);
|
|
159
|
+
--elevated-tag-label-text-color: var(--color-on-surface);
|
|
160
|
+
--outlined-tag-outline-color: var(--color-on-surface);
|
|
161
|
+
--outlined-tag-label-text-color: var(--color-on-surface);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
:host([color=red]) {
|
|
165
|
+
--filled-tag-container-color: var(--color-red);
|
|
166
|
+
--filled-tag-label-text-color: var(--color-on-red);
|
|
167
|
+
--tonal-tag-container-color: var(--color-red-container);
|
|
168
|
+
--tonal-tag-label-text-color: var(--color-on-red-container);
|
|
169
|
+
--elevated-tag-container-color: var(--color-surface-container-low);
|
|
170
|
+
--elevated-tag-label-text-color: var(--color-red);
|
|
171
|
+
--outlined-tag-outline-color: var(--color-red);
|
|
172
|
+
--outlined-tag-label-text-color: var(--color-red);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
:host([color=green]) {
|
|
176
|
+
--filled-tag-container-color: var(--color-green);
|
|
177
|
+
--filled-tag-label-text-color: var(--color-on-green);
|
|
178
|
+
--tonal-tag-container-color: var(--color-green-container);
|
|
179
|
+
--tonal-tag-label-text-color: var(--color-on-green-container);
|
|
180
|
+
--elevated-tag-container-color: var(--color-surface-container-low);
|
|
181
|
+
--elevated-tag-label-text-color: var(--color-green);
|
|
182
|
+
--outlined-tag-outline-color: var(--color-green);
|
|
183
|
+
--outlined-tag-label-text-color: var(--color-green);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
:host([color=blue]) {
|
|
187
|
+
--filled-tag-container-color: var(--color-blue);
|
|
188
|
+
--filled-tag-label-text-color: var(--color-on-blue);
|
|
189
|
+
--tonal-tag-container-color: var(--color-blue-container);
|
|
190
|
+
--tonal-tag-label-text-color: var(--color-on-blue-container);
|
|
191
|
+
--elevated-tag-container-color: var(--color-surface-container-low);
|
|
192
|
+
--elevated-tag-label-text-color: var(--color-blue);
|
|
193
|
+
--outlined-tag-outline-color: var(--color-blue);
|
|
194
|
+
--outlined-tag-label-text-color: var(--color-blue);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
:host([color=yellow]) {
|
|
198
|
+
--filled-tag-container-color: var(--color-yellow);
|
|
199
|
+
--filled-tag-label-text-color: var(--color-on-yellow);
|
|
200
|
+
--tonal-tag-container-color: var(--color-yellow-container);
|
|
201
|
+
--tonal-tag-label-text-color: var(--color-on-yellow-container);
|
|
202
|
+
--elevated-tag-container-color: var(--color-surface-container-low);
|
|
203
|
+
--elevated-tag-label-text-color: var(--color-yellow);
|
|
204
|
+
--outlined-tag-outline-color: var(--color-yellow);
|
|
205
|
+
--outlined-tag-label-text-color: var(--color-yellow);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
:host([color=purple]) {
|
|
209
|
+
--filled-tag-container-color: var(--color-purple);
|
|
210
|
+
--filled-tag-label-text-color: var(--color-on-purple);
|
|
211
|
+
--tonal-tag-container-color: var(--color-purple-container);
|
|
212
|
+
--tonal-tag-label-text-color: var(--color-on-purple-container);
|
|
213
|
+
--elevated-tag-container-color: var(--color-surface-container-low);
|
|
214
|
+
--elevated-tag-label-text-color: var(--color-purple);
|
|
215
|
+
--outlined-tag-outline-color: var(--color-purple);
|
|
216
|
+
--outlined-tag-label-text-color: var(--color-purple);
|
|
217
|
+
}`;
|
|
218
|
+
|
|
219
|
+
var css_248z$e = i`.tag {
|
|
220
|
+
font-family: var(--font-family-sans) !important;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.tag.size-sm,
|
|
224
|
+
.tag.size-small {
|
|
225
|
+
--_chip-height: 1.5rem;
|
|
226
|
+
--_tag-icon-size: 1rem;
|
|
227
|
+
--_container-padding: 0.75rem;
|
|
228
|
+
font-family: var(--typography-label-medium-font-family) !important;
|
|
229
|
+
font-size: var(--typography-label-medium-font-size) !important;
|
|
230
|
+
font-weight: var(--typography-label-medium-font-weight) !important;
|
|
231
|
+
line-height: var(--typography-label-medium-line-height) !important;
|
|
232
|
+
letter-spacing: var(--typography-label-medium-letter-spacing) !important;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.tag.size-md,
|
|
236
|
+
.tag.size-medium {
|
|
237
|
+
--_chip-height: 2rem;
|
|
238
|
+
--_tag-icon-size: 1.125rem;
|
|
239
|
+
--_container-padding: 1rem;
|
|
240
|
+
font-family: var(--typography-label-large-font-family) !important;
|
|
241
|
+
font-size: var(--typography-label-large-font-size) !important;
|
|
242
|
+
font-weight: var(--typography-label-large-font-weight) !important;
|
|
243
|
+
line-height: var(--typography-label-large-line-height) !important;
|
|
244
|
+
letter-spacing: var(--typography-label-large-letter-spacing) !important;
|
|
245
|
+
}`;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @label Tag
|
|
249
|
+
* @tag wc-tag
|
|
250
|
+
* @rawTag tag
|
|
251
|
+
* @summary Tag component for displaying labels or values with optional dismiss functionality.
|
|
252
|
+
* @tags display
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```html
|
|
256
|
+
* <wc-tag color="red">Tag</wc-tag>
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
class Tag extends i$1 {
|
|
260
|
+
constructor() {
|
|
261
|
+
super(...arguments);
|
|
262
|
+
/** If true, the tag will have a close icon. */
|
|
263
|
+
this.dismissible = false;
|
|
264
|
+
this.variant = 'tonal';
|
|
265
|
+
/** Tag color. */
|
|
266
|
+
this.color = 'default';
|
|
267
|
+
this.size = 'md';
|
|
268
|
+
}
|
|
269
|
+
_dismissClickHandler(e) {
|
|
270
|
+
e.stopPropagation();
|
|
271
|
+
// Custom Event: tag--dismiss
|
|
272
|
+
this.dispatchEvent(new CustomEvent('tag--dismiss', {
|
|
273
|
+
bubbles: true,
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
__renderDismissButton() {
|
|
277
|
+
if (!this.dismissible)
|
|
278
|
+
return null;
|
|
279
|
+
return b `
|
|
280
|
+
<button
|
|
281
|
+
class="dismiss-button"
|
|
282
|
+
@click=${this._dismissClickHandler}
|
|
283
|
+
aria-label="Dismiss"
|
|
284
|
+
>
|
|
285
|
+
<wc-ripple class="ripple"></wc-ripple>
|
|
286
|
+
<wc-icon class="dismiss-button-icon" name="close"></wc-icon>
|
|
287
|
+
</button>
|
|
288
|
+
`;
|
|
289
|
+
}
|
|
290
|
+
render() {
|
|
291
|
+
const classes = {
|
|
292
|
+
tag: true,
|
|
293
|
+
dismissible: this.dismissible,
|
|
294
|
+
[`color-${this.color}`]: true,
|
|
295
|
+
[`variant-${this.variant}`]: true,
|
|
296
|
+
[`size-${this.size}`]: true,
|
|
297
|
+
};
|
|
298
|
+
return b `
|
|
299
|
+
<div class="${e(classes)}">
|
|
300
|
+
<wc-elevation class="elevation"></wc-elevation>
|
|
301
|
+
<div class="background"></div>
|
|
302
|
+
<div class="outline"></div>
|
|
303
|
+
|
|
304
|
+
<div class="tag-content">
|
|
305
|
+
<slot name="icon"></slot>
|
|
306
|
+
|
|
307
|
+
<div class="slot-content">
|
|
308
|
+
<slot></slot>
|
|
309
|
+
</div>
|
|
310
|
+
${this.__renderDismissButton()}
|
|
311
|
+
</div>
|
|
312
|
+
</div>
|
|
313
|
+
`;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// Define styles (Lit handles Scoping via Shadow DOM by default)
|
|
317
|
+
// You would typically import your tag.scss.js here or use the css tag
|
|
318
|
+
Tag.styles = [css_248z$g, css_248z$f, css_248z$e];
|
|
319
|
+
__decorate([
|
|
320
|
+
n({ type: Boolean })
|
|
321
|
+
], Tag.prototype, "dismissible", void 0);
|
|
322
|
+
__decorate([
|
|
323
|
+
n()
|
|
324
|
+
], Tag.prototype, "variant", void 0);
|
|
325
|
+
__decorate([
|
|
326
|
+
n({ type: String, reflect: true })
|
|
327
|
+
], Tag.prototype, "color", void 0);
|
|
328
|
+
__decorate([
|
|
329
|
+
n()
|
|
330
|
+
], Tag.prototype, "size", void 0);
|
|
331
|
+
|
|
332
|
+
var css_248z$d = i`* {
|
|
333
|
+
box-sizing: border-box;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.screen-reader-only {
|
|
337
|
+
display: none !important;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
[hidden] {
|
|
341
|
+
display: none !important;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
:host {
|
|
345
|
+
display: block;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
slot {
|
|
349
|
+
display: flex;
|
|
350
|
+
flex-wrap: wrap;
|
|
351
|
+
gap: 8px;
|
|
352
|
+
}`;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @label Chip Set
|
|
356
|
+
* @tag wc-chip-set
|
|
357
|
+
* @rawTag chip-set
|
|
358
|
+
* @summary A layout container for wrapping chips.
|
|
359
|
+
* @tags layout
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```html
|
|
363
|
+
* <wc-chip-set>
|
|
364
|
+
* <wc-chip>One</wc-chip>
|
|
365
|
+
* <wc-chip>Two</wc-chip>
|
|
366
|
+
* </wc-chip-set>
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
class ChipSet extends i$1 {
|
|
370
|
+
render() {
|
|
371
|
+
return b `<slot></slot>`;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
ChipSet.styles = [css_248z$d];
|
|
375
|
+
|
|
376
|
+
var css_248z$c = i`:host {
|
|
377
|
+
display: block;
|
|
378
|
+
--progress-height: 0.25rem;
|
|
379
|
+
--progress-container-color: var(--color-primary);
|
|
380
|
+
--progress-track-color: var(--color-secondary-container);
|
|
381
|
+
min-width: 2.5rem;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.linear-progress {
|
|
385
|
+
display: flex;
|
|
386
|
+
flex-direction: column;
|
|
387
|
+
}
|
|
388
|
+
.linear-progress .progress-header {
|
|
389
|
+
display: flex;
|
|
390
|
+
align-items: center;
|
|
391
|
+
}
|
|
392
|
+
.linear-progress .progress-header .progress-label {
|
|
393
|
+
font-family: var(--typography-label-medium-font-family) !important;
|
|
394
|
+
font-size: var(--typography-label-medium-font-size) !important;
|
|
395
|
+
font-weight: var(--typography-label-medium-font-weight) !important;
|
|
396
|
+
line-height: var(--typography-label-medium-line-height) !important;
|
|
397
|
+
letter-spacing: var(--typography-label-medium-letter-spacing) !important;
|
|
398
|
+
color: var(--color-on-surface);
|
|
399
|
+
flex: 1;
|
|
400
|
+
}
|
|
401
|
+
.linear-progress .progress-body {
|
|
402
|
+
display: flex;
|
|
403
|
+
flex-direction: column;
|
|
404
|
+
}
|
|
405
|
+
.linear-progress .progress-body .linear-progress-container {
|
|
406
|
+
position: relative;
|
|
407
|
+
display: flex;
|
|
408
|
+
align-items: flex-start;
|
|
409
|
+
width: 100%;
|
|
410
|
+
margin: var(--spacing-100) 0;
|
|
411
|
+
}
|
|
412
|
+
.linear-progress .progress-body .linear-progress-container .track {
|
|
413
|
+
position: relative;
|
|
414
|
+
}
|
|
415
|
+
.linear-progress .progress-body .linear-progress-container .track:after {
|
|
416
|
+
content: "";
|
|
417
|
+
position: absolute;
|
|
418
|
+
display: block;
|
|
419
|
+
top: 0;
|
|
420
|
+
left: 0;
|
|
421
|
+
width: calc(100% - 0.25rem);
|
|
422
|
+
height: var(--progress-height);
|
|
423
|
+
background: var(--progress-track-color);
|
|
424
|
+
border-radius: var(--shape-corner-full);
|
|
425
|
+
}
|
|
426
|
+
.linear-progress .progress-body .linear-progress-container .track-start:after {
|
|
427
|
+
margin-inline-end: 0.25rem;
|
|
428
|
+
}
|
|
429
|
+
.linear-progress .progress-body .linear-progress-container .active-indicator {
|
|
430
|
+
height: var(--progress-height);
|
|
431
|
+
background: var(--progress-container-color);
|
|
432
|
+
border-radius: var(--shape-corner-full);
|
|
433
|
+
}
|
|
434
|
+
.linear-progress .progress-body .linear-progress-container .track-end {
|
|
435
|
+
flex: 1;
|
|
436
|
+
}
|
|
437
|
+
.linear-progress .progress-body .linear-progress-container .track-end:after {
|
|
438
|
+
margin-inline-start: 0.25rem;
|
|
439
|
+
}
|
|
440
|
+
.linear-progress .progress-body .progress-helper {
|
|
441
|
+
font-family: var(--typography-body-small-font-family) !important;
|
|
442
|
+
font-size: var(--typography-body-small-font-size) !important;
|
|
443
|
+
font-weight: var(--typography-body-small-font-weight) !important;
|
|
444
|
+
line-height: var(--typography-body-small-line-height) !important;
|
|
445
|
+
letter-spacing: var(--typography-body-small-letter-spacing) !important;
|
|
446
|
+
color: var(--color-on-surface-variant);
|
|
447
|
+
}
|
|
448
|
+
.linear-progress:not(.indeterminate) .track-start {
|
|
449
|
+
transition: width var(--duration-medium2) var(--easing-standard);
|
|
450
|
+
}
|
|
451
|
+
.linear-progress:not(.indeterminate) .active-indicator {
|
|
452
|
+
transition: width var(--duration-medium2) var(--easing-standard);
|
|
453
|
+
}
|
|
454
|
+
.linear-progress.indeterminate .linear-progress-container .track-start {
|
|
455
|
+
animation-duration: 3s;
|
|
456
|
+
animation-iteration-count: infinite;
|
|
457
|
+
animation-name: track-start-indeterminate;
|
|
458
|
+
animation-timing-function: var(--easing-linear);
|
|
459
|
+
}
|
|
460
|
+
.linear-progress.indeterminate .linear-progress-container .active-indicator {
|
|
461
|
+
animation-duration: 3s;
|
|
462
|
+
animation-iteration-count: infinite;
|
|
463
|
+
animation-name: active-indicator-indeterminate;
|
|
464
|
+
animation-timing-function: var(--easing-linear);
|
|
465
|
+
}
|
|
466
|
+
.linear-progress.inline {
|
|
467
|
+
flex-direction: row;
|
|
468
|
+
gap: var(--spacing-200);
|
|
469
|
+
}
|
|
470
|
+
.linear-progress.inline .progress-body {
|
|
471
|
+
flex: 1;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
@keyframes track-start-indeterminate {
|
|
475
|
+
0% {
|
|
476
|
+
width: 0;
|
|
477
|
+
}
|
|
478
|
+
50% {
|
|
479
|
+
width: 33%;
|
|
480
|
+
}
|
|
481
|
+
80%, to {
|
|
482
|
+
width: 100%;
|
|
483
|
+
padding-inline-end: 0;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
@keyframes active-indicator-indeterminate {
|
|
487
|
+
0% {
|
|
488
|
+
width: 0;
|
|
489
|
+
}
|
|
490
|
+
50% {
|
|
491
|
+
width: 33%;
|
|
492
|
+
}
|
|
493
|
+
80%, to {
|
|
494
|
+
width: 0;
|
|
495
|
+
}
|
|
496
|
+
}`;
|
|
497
|
+
|
|
498
|
+
class BaseProgress extends i$1 {
|
|
499
|
+
constructor() {
|
|
500
|
+
super(...arguments);
|
|
501
|
+
this.indeterminate = false;
|
|
502
|
+
this.inline = false;
|
|
503
|
+
}
|
|
504
|
+
__getPercentageValue() {
|
|
505
|
+
if (!this.value)
|
|
506
|
+
return 0;
|
|
507
|
+
return this.value;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
__decorate([
|
|
511
|
+
n({ type: Number })
|
|
512
|
+
], BaseProgress.prototype, "value", void 0);
|
|
513
|
+
__decorate([
|
|
514
|
+
n({ type: Boolean })
|
|
515
|
+
], BaseProgress.prototype, "indeterminate", void 0);
|
|
516
|
+
__decorate([
|
|
517
|
+
n({ type: String })
|
|
518
|
+
], BaseProgress.prototype, "label", void 0);
|
|
519
|
+
__decorate([
|
|
520
|
+
n({ type: String, attribute: 'helper-text' })
|
|
521
|
+
], BaseProgress.prototype, "helperText", void 0);
|
|
522
|
+
__decorate([
|
|
523
|
+
n({ type: Boolean })
|
|
524
|
+
], BaseProgress.prototype, "inline", void 0);
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* @label Linear Progress
|
|
528
|
+
* @tag wc-linear-progress
|
|
529
|
+
* @rawTag linear-progress
|
|
530
|
+
* @summary A linear progress indicator is a visual representation of progress toward a specific goal.
|
|
531
|
+
* @tags display
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```html
|
|
535
|
+
* <wc-linear-progress value="30" style="width:10rem"></wc-linear-progress>
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
538
|
+
class LinearProgress extends BaseProgress {
|
|
539
|
+
render() {
|
|
540
|
+
return b `
|
|
541
|
+
<div
|
|
542
|
+
class="${e({
|
|
543
|
+
'linear-progress': true,
|
|
544
|
+
indeterminate: this.indeterminate,
|
|
545
|
+
inline: this.inline,
|
|
546
|
+
})}"
|
|
547
|
+
>
|
|
548
|
+
${this.label
|
|
549
|
+
? b `<div class="progress-header">
|
|
550
|
+
<label class="progress-label">${this.label}</label>
|
|
551
|
+
</div>`
|
|
552
|
+
: ''}
|
|
553
|
+
|
|
554
|
+
<div class="progress-body">
|
|
555
|
+
<div
|
|
556
|
+
class="linear-progress-container"
|
|
557
|
+
title=${this.label}
|
|
558
|
+
?aria-valuenow="${this.__getPercentageValue()}"
|
|
559
|
+
aria-valuemin="0"
|
|
560
|
+
aria-valuemax="100"
|
|
561
|
+
role="progressbar"
|
|
562
|
+
>
|
|
563
|
+
<div class="track track-start"></div>
|
|
564
|
+
<div
|
|
565
|
+
class="active-indicator"
|
|
566
|
+
style="${o({
|
|
567
|
+
width: `${this.__getPercentageValue()}%`,
|
|
568
|
+
})}"
|
|
569
|
+
></div>
|
|
570
|
+
<div class="track track-end"></div>
|
|
571
|
+
</div>
|
|
572
|
+
|
|
573
|
+
${this.helperText
|
|
574
|
+
? b `<div class="progress-helper">${this.helperText}</div>`
|
|
575
|
+
: ''}
|
|
576
|
+
</div>
|
|
577
|
+
</div>
|
|
578
|
+
`;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
// Lit components use static styles for better performance
|
|
582
|
+
LinearProgress.styles = [css_248z$c];
|
|
583
|
+
|
|
584
|
+
var css_248z$b = i`:host {
|
|
585
|
+
display: inline-block;
|
|
586
|
+
--progress-height: 1.5rem;
|
|
587
|
+
--progress-line-thickness: 4px;
|
|
588
|
+
--progress-container-color: var(--color-primary);
|
|
589
|
+
--progress-track-color: var(--color-secondary-container);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
.circular-progress {
|
|
593
|
+
display: flex;
|
|
594
|
+
flex-direction: column;
|
|
595
|
+
}
|
|
596
|
+
.circular-progress .circular-progress-container {
|
|
597
|
+
position: relative;
|
|
598
|
+
width: 100%;
|
|
599
|
+
--_container-height: clamp(0rem, var(--progress-height), 15rem);
|
|
600
|
+
height: var(--_container-height);
|
|
601
|
+
}
|
|
602
|
+
.circular-progress .circular-progress-container .progress-label {
|
|
603
|
+
font-family: var(--typography-label-large-emphasized-font-family) !important;
|
|
604
|
+
font-size: var(--typography-label-large-emphasized-font-size) !important;
|
|
605
|
+
font-weight: var(--typography-label-large-emphasized-font-weight) !important;
|
|
606
|
+
line-height: var(--typography-label-large-emphasized-line-height) !important;
|
|
607
|
+
letter-spacing: var(--typography-label-large-emphasized-letter-spacing) !important;
|
|
608
|
+
color: var(--color-on-surface);
|
|
609
|
+
flex: 1;
|
|
610
|
+
width: 100%;
|
|
611
|
+
height: 100%;
|
|
612
|
+
display: flex;
|
|
613
|
+
align-items: center;
|
|
614
|
+
justify-content: center;
|
|
615
|
+
}
|
|
616
|
+
.circular-progress .circular-progress-container svg {
|
|
617
|
+
transform: rotate(-90deg);
|
|
618
|
+
width: 100%;
|
|
619
|
+
height: 100%;
|
|
620
|
+
}
|
|
621
|
+
.circular-progress .circular-progress-container circle {
|
|
622
|
+
fill: none;
|
|
623
|
+
stroke-linecap: round;
|
|
624
|
+
transition: stroke-dashoffset var(--duration-medium2) var(--easing-standard);
|
|
625
|
+
}
|
|
626
|
+
.circular-progress .circular-progress-container .track {
|
|
627
|
+
stroke: var(--progress-track-color);
|
|
628
|
+
stroke-width: calc(var(--progress-line-thickness) / (tan(atan2(var(--_container-height), 1px)) / 16));
|
|
629
|
+
}
|
|
630
|
+
.circular-progress .circular-progress-container .active-indicator {
|
|
631
|
+
stroke: var(--progress-container-color);
|
|
632
|
+
stroke-width: calc(var(--progress-line-thickness) / (tan(atan2(var(--_container-height), 1px)) / 16));
|
|
633
|
+
}
|
|
634
|
+
.circular-progress.indeterminate .active-indicator {
|
|
635
|
+
animation: arc-indeterminate 1.5s ease-in-out infinite;
|
|
636
|
+
}
|
|
637
|
+
.circular-progress .progress-label {
|
|
638
|
+
font-family: var(--typography-label-medium-font-family) !important;
|
|
639
|
+
font-size: var(--typography-label-medium-font-size) !important;
|
|
640
|
+
font-weight: var(--typography-label-medium-font-weight) !important;
|
|
641
|
+
line-height: var(--typography-label-medium-line-height) !important;
|
|
642
|
+
letter-spacing: var(--typography-label-medium-letter-spacing) !important;
|
|
643
|
+
color: var(--color-on-surface);
|
|
644
|
+
}
|
|
645
|
+
.circular-progress .progress-helper {
|
|
646
|
+
font-family: var(--typography-label-small-font-family) !important;
|
|
647
|
+
font-size: var(--typography-label-small-font-size) !important;
|
|
648
|
+
font-weight: var(--typography-label-small-font-weight) !important;
|
|
649
|
+
line-height: var(--typography-label-small-line-height) !important;
|
|
650
|
+
letter-spacing: var(--typography-label-small-letter-spacing) !important;
|
|
651
|
+
color: var(--color-on-surface-variant);
|
|
652
|
+
text-align: center;
|
|
653
|
+
}
|
|
654
|
+
.circular-progress.inline {
|
|
655
|
+
flex-direction: row;
|
|
656
|
+
align-items: center;
|
|
657
|
+
gap: var(--spacing-200);
|
|
658
|
+
}
|
|
659
|
+
.circular-progress.inline .progress-footer {
|
|
660
|
+
flex: 1;
|
|
661
|
+
}
|
|
662
|
+
.circular-progress.inline .progress-helper {
|
|
663
|
+
text-align: start;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
@keyframes rotate-container {
|
|
667
|
+
100% {
|
|
668
|
+
transform: rotate(360deg);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
@keyframes arc-indeterminate {
|
|
672
|
+
0% {
|
|
673
|
+
stroke-dasharray: 1, 150;
|
|
674
|
+
stroke-dashoffset: 0;
|
|
675
|
+
}
|
|
676
|
+
50% {
|
|
677
|
+
stroke-dasharray: 90, 150;
|
|
678
|
+
stroke-dashoffset: -35;
|
|
679
|
+
}
|
|
680
|
+
100% {
|
|
681
|
+
stroke-dasharray: 90, 150;
|
|
682
|
+
stroke-dashoffset: -124;
|
|
683
|
+
}
|
|
684
|
+
}`;
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* @label Circular Progress
|
|
688
|
+
* @tag wc-circular-progress
|
|
689
|
+
* @rawTag circular-progress
|
|
690
|
+
* @summary A circular progress indicator is a visual representation of progress toward a specific goal.
|
|
691
|
+
* @tags display
|
|
692
|
+
*
|
|
693
|
+
* @example
|
|
694
|
+
* ```html
|
|
695
|
+
* <wc-circular-progress value="30"></wc-circular-progress>
|
|
696
|
+
* ```
|
|
697
|
+
*/
|
|
698
|
+
class CircularProgress extends BaseProgress {
|
|
699
|
+
render() {
|
|
700
|
+
const percentage = this.__getPercentageValue();
|
|
701
|
+
// Radius of 18 with stroke 4 fits nicely in a 40x40 viewBox
|
|
702
|
+
const radius = 6;
|
|
703
|
+
const circumference = 2 * Math.PI * radius;
|
|
704
|
+
const offset = circumference - (percentage / 100) * circumference;
|
|
705
|
+
return b `
|
|
706
|
+
<div
|
|
707
|
+
class="${e({
|
|
708
|
+
'circular-progress': true,
|
|
709
|
+
indeterminate: this.indeterminate,
|
|
710
|
+
inline: this.inline,
|
|
711
|
+
})}"
|
|
712
|
+
title=${this.label}
|
|
713
|
+
role="progressbar"
|
|
714
|
+
aria-valuenow="${this.indeterminate ? undefined : percentage}"
|
|
715
|
+
aria-valuemin="0"
|
|
716
|
+
aria-valuemax="100"
|
|
717
|
+
>
|
|
718
|
+
<div class="circular-progress-container">
|
|
719
|
+
<svg viewBox="0 0 16 16">
|
|
720
|
+
<circle class="track" cx="8" cy="8" r="6"></circle>
|
|
721
|
+
<circle
|
|
722
|
+
class="active-indicator"
|
|
723
|
+
cx="8"
|
|
724
|
+
cy="8"
|
|
725
|
+
r="6"
|
|
726
|
+
style="${o({
|
|
727
|
+
strokeDasharray: `${circumference}`,
|
|
728
|
+
strokeDashoffset: this.indeterminate ? undefined : `${offset}`,
|
|
729
|
+
})}"
|
|
730
|
+
></circle>
|
|
731
|
+
</svg>
|
|
732
|
+
</div>
|
|
733
|
+
|
|
734
|
+
<div class="progress-footer">
|
|
735
|
+
${this.label
|
|
736
|
+
? b `<div class="progress-label">${this.label}</div>`
|
|
737
|
+
: ''}
|
|
738
|
+
${this.helperText
|
|
739
|
+
? b `<div class="progress-helper">${this.helperText}</div>`
|
|
740
|
+
: ''}
|
|
741
|
+
</div>
|
|
742
|
+
</div>
|
|
743
|
+
`;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
// Lit components use static styles for better performance
|
|
747
|
+
CircularProgress.styles = [css_248z$b];
|
|
748
|
+
|
|
749
|
+
var css_248z$a = i`* {
|
|
750
|
+
box-sizing: border-box;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
.screen-reader-only {
|
|
754
|
+
display: none !important;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
[hidden] {
|
|
758
|
+
display: none !important;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
:host {
|
|
762
|
+
display: block;
|
|
763
|
+
width: 100%;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
.input-element {
|
|
767
|
+
border: none;
|
|
768
|
+
outline: none;
|
|
769
|
+
margin: 0;
|
|
770
|
+
padding: 0;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
.input-wrapper .input {
|
|
774
|
+
flex: 1;
|
|
775
|
+
width: 100%;
|
|
776
|
+
background: none;
|
|
777
|
+
cursor: inherit;
|
|
778
|
+
}
|
|
779
|
+
.input-wrapper .password-toggle {
|
|
780
|
+
--button-container-shape: var(--shape-corner-full);
|
|
781
|
+
}`;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* @label Input
|
|
785
|
+
* @tag wc-input
|
|
786
|
+
* @rawTag input
|
|
787
|
+
*
|
|
788
|
+
* @summary The Input component is used to capture user input.
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* ```html
|
|
792
|
+
* <wc-input label="Name" required placeholder="Enter your name"></wc-input>
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
class Input extends BaseInput {
|
|
796
|
+
constructor() {
|
|
797
|
+
super(...arguments);
|
|
798
|
+
this.value = '';
|
|
799
|
+
this.name = '';
|
|
800
|
+
this.placeholder = '';
|
|
801
|
+
this.label = '';
|
|
802
|
+
this.inline = false;
|
|
803
|
+
this.size = 'md';
|
|
804
|
+
this.type = 'text';
|
|
805
|
+
this.autocomplete = 'off';
|
|
806
|
+
this.configAria = {};
|
|
807
|
+
this.variant = 'default';
|
|
808
|
+
/**
|
|
809
|
+
* Helper text to display below the input.
|
|
810
|
+
*/
|
|
811
|
+
this.helperText = '';
|
|
812
|
+
this.error = false;
|
|
813
|
+
this.errorText = '';
|
|
814
|
+
this.warning = false;
|
|
815
|
+
this.warningText = '';
|
|
816
|
+
this.focused = false;
|
|
817
|
+
this.passwordVisible = false;
|
|
818
|
+
/**
|
|
819
|
+
* Returns true when the text field has been interacted with. Native
|
|
820
|
+
* validation errors only display in response to user interactions.
|
|
821
|
+
*/
|
|
822
|
+
this.dirty = false;
|
|
823
|
+
this.__handleFocusChange = (event) => {
|
|
824
|
+
this.focused = event.type === 'focus';
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
async focus() {
|
|
828
|
+
await Promise.all([
|
|
829
|
+
customElements.whenDefined('wc-input'),
|
|
830
|
+
customElements.whenDefined('wc-field'),
|
|
831
|
+
]);
|
|
832
|
+
await this.updateComplete;
|
|
833
|
+
this.inputElement?.focus();
|
|
834
|
+
}
|
|
835
|
+
connectedCallback() {
|
|
836
|
+
super.connectedCallback();
|
|
837
|
+
this.handleInitialAttributes();
|
|
838
|
+
}
|
|
839
|
+
handleInitialAttributes() {
|
|
840
|
+
Array.from(this.attributes).forEach(attr => {
|
|
841
|
+
if (attr.name.startsWith('aria-')) {
|
|
842
|
+
this.configAria[attr.name] = attr.value;
|
|
843
|
+
this.removeAttribute(attr.name);
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
__handleInput(event) {
|
|
848
|
+
this.dirty = true;
|
|
849
|
+
this.value = event.target.value;
|
|
850
|
+
}
|
|
851
|
+
__redispatchEvent(event) {
|
|
852
|
+
redispatchEvent(this, event);
|
|
853
|
+
}
|
|
854
|
+
render() {
|
|
855
|
+
const displayType = this.type === 'password' && this.passwordVisible ? 'text' : this.type;
|
|
856
|
+
return b `
|
|
857
|
+
<wc-field
|
|
858
|
+
?required=${this.required}
|
|
859
|
+
?disabled=${this.disabled}
|
|
860
|
+
?readonly=${this.readonly}
|
|
861
|
+
?skeleton=${this.skeleton}
|
|
862
|
+
helper-text=${this.helperText}
|
|
863
|
+
?error=${this.error}
|
|
864
|
+
error-text=${this.errorText}
|
|
865
|
+
?warning=${this.warning}
|
|
866
|
+
variant=${this.variant}
|
|
867
|
+
?populated=${!!this.value}
|
|
868
|
+
warning-text=${this.warningText}
|
|
869
|
+
label=${this.label}
|
|
870
|
+
?focused=${this.focused}
|
|
871
|
+
.host=${this}
|
|
872
|
+
class="input-wrapper"
|
|
873
|
+
>
|
|
874
|
+
<slot name="start" slot="field-start"></slot>
|
|
875
|
+
|
|
876
|
+
<input
|
|
877
|
+
class="input input-element"
|
|
878
|
+
name=${this.name}
|
|
879
|
+
type=${displayType}
|
|
880
|
+
placeholder=${this.placeholder}
|
|
881
|
+
autocomplete=${this.autocomplete}
|
|
882
|
+
.value=${this.value}
|
|
883
|
+
?readonly=${this.readonly}
|
|
884
|
+
?required=${this.required}
|
|
885
|
+
?disabled=${this.disabled}
|
|
886
|
+
@input=${this.__handleInput}
|
|
887
|
+
@change=${this.__redispatchEvent}
|
|
888
|
+
@focus=${this.__handleFocusChange}
|
|
889
|
+
@blur=${this.__handleFocusChange}
|
|
890
|
+
${spread(this.configAria)}
|
|
891
|
+
/>
|
|
892
|
+
|
|
893
|
+
${this.type === 'password'
|
|
894
|
+
? b `
|
|
895
|
+
<wc-tooltip
|
|
896
|
+
slot="field-end"
|
|
897
|
+
content=${this.passwordVisible
|
|
898
|
+
? 'Hide password'
|
|
899
|
+
: 'Show password'}
|
|
900
|
+
>
|
|
901
|
+
<wc-icon-button
|
|
902
|
+
class="password-toggle"
|
|
903
|
+
variant="text"
|
|
904
|
+
@click=${() => {
|
|
905
|
+
this.passwordVisible = !this.passwordVisible;
|
|
906
|
+
}}
|
|
907
|
+
>
|
|
908
|
+
<wc-icon
|
|
909
|
+
name=${this.passwordVisible
|
|
910
|
+
? 'visibility_off'
|
|
911
|
+
: 'visibility'}
|
|
912
|
+
></wc-icon>
|
|
913
|
+
</wc-icon-button>
|
|
914
|
+
</wc-tooltip>
|
|
915
|
+
`
|
|
916
|
+
: A}
|
|
917
|
+
|
|
918
|
+
<slot name="end" slot="field-end"></slot>
|
|
919
|
+
</wc-field>
|
|
920
|
+
`;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
Input.styles = [css_248z$a];
|
|
924
|
+
__decorate([
|
|
925
|
+
n({ type: String })
|
|
926
|
+
], Input.prototype, "value", void 0);
|
|
927
|
+
__decorate([
|
|
928
|
+
n({ type: String })
|
|
929
|
+
], Input.prototype, "name", void 0);
|
|
930
|
+
__decorate([
|
|
931
|
+
n({ type: String })
|
|
932
|
+
], Input.prototype, "placeholder", void 0);
|
|
933
|
+
__decorate([
|
|
934
|
+
n({ type: String })
|
|
935
|
+
], Input.prototype, "label", void 0);
|
|
936
|
+
__decorate([
|
|
937
|
+
n({ type: Boolean, reflect: true })
|
|
938
|
+
], Input.prototype, "inline", void 0);
|
|
939
|
+
__decorate([
|
|
940
|
+
n({ type: String, reflect: true })
|
|
941
|
+
], Input.prototype, "size", void 0);
|
|
942
|
+
__decorate([
|
|
943
|
+
n({ type: String })
|
|
944
|
+
], Input.prototype, "type", void 0);
|
|
945
|
+
__decorate([
|
|
946
|
+
n({ type: String })
|
|
947
|
+
], Input.prototype, "autocomplete", void 0);
|
|
948
|
+
__decorate([
|
|
949
|
+
n({ type: Object })
|
|
950
|
+
], Input.prototype, "configAria", void 0);
|
|
951
|
+
__decorate([
|
|
952
|
+
n({ type: String })
|
|
953
|
+
], Input.prototype, "variant", void 0);
|
|
954
|
+
__decorate([
|
|
955
|
+
n({ type: String, attribute: 'helper-text' })
|
|
956
|
+
], Input.prototype, "helperText", void 0);
|
|
957
|
+
__decorate([
|
|
958
|
+
n({ type: Boolean })
|
|
959
|
+
], Input.prototype, "error", void 0);
|
|
960
|
+
__decorate([
|
|
961
|
+
n({ type: String, attribute: 'error-text' })
|
|
962
|
+
], Input.prototype, "errorText", void 0);
|
|
963
|
+
__decorate([
|
|
964
|
+
n({ type: Boolean })
|
|
965
|
+
], Input.prototype, "warning", void 0);
|
|
966
|
+
__decorate([
|
|
967
|
+
n({ type: String, attribute: 'warning-text' })
|
|
968
|
+
], Input.prototype, "warningText", void 0);
|
|
969
|
+
__decorate([
|
|
970
|
+
r()
|
|
971
|
+
], Input.prototype, "focused", void 0);
|
|
972
|
+
__decorate([
|
|
973
|
+
r()
|
|
974
|
+
], Input.prototype, "passwordVisible", void 0);
|
|
975
|
+
__decorate([
|
|
976
|
+
r()
|
|
977
|
+
], Input.prototype, "dirty", void 0);
|
|
978
|
+
__decorate([
|
|
979
|
+
e$1('.input-element')
|
|
980
|
+
], Input.prototype, "inputElement", void 0);
|
|
981
|
+
|
|
982
|
+
var css_248z$9 = i`* {
|
|
983
|
+
box-sizing: border-box;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
.screen-reader-only {
|
|
987
|
+
display: none !important;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
[hidden] {
|
|
991
|
+
display: none !important;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
:host {
|
|
995
|
+
display: block;
|
|
996
|
+
width: 100%;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
.url-input {
|
|
1000
|
+
flex: 1;
|
|
1001
|
+
width: 100%;
|
|
1002
|
+
border: none;
|
|
1003
|
+
outline: none;
|
|
1004
|
+
margin: 0;
|
|
1005
|
+
padding: 0;
|
|
1006
|
+
background: none;
|
|
1007
|
+
cursor: inherit;
|
|
1008
|
+
font: inherit;
|
|
1009
|
+
color: inherit;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
.url-display {
|
|
1013
|
+
flex: 1;
|
|
1014
|
+
display: flex;
|
|
1015
|
+
align-items: center;
|
|
1016
|
+
overflow: hidden;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
.url-link {
|
|
1020
|
+
flex: 1;
|
|
1021
|
+
overflow: hidden;
|
|
1022
|
+
text-overflow: ellipsis;
|
|
1023
|
+
white-space: nowrap;
|
|
1024
|
+
color: var(--color-primary);
|
|
1025
|
+
text-decoration: none;
|
|
1026
|
+
}
|
|
1027
|
+
.url-link:hover {
|
|
1028
|
+
text-decoration: underline;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
.url-placeholder {
|
|
1032
|
+
color: var(--color-on-surface-variant);
|
|
1033
|
+
opacity: 0.6;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
.edit-button {
|
|
1037
|
+
--button-container-shape: var(--shape-corner-full);
|
|
1038
|
+
}`;
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* @label URL Field
|
|
1042
|
+
* @tag wc-url-field
|
|
1043
|
+
* @rawTag url-field
|
|
1044
|
+
*
|
|
1045
|
+
* @summary A field for entering and displaying URLs with validation.
|
|
1046
|
+
* @overview
|
|
1047
|
+
* <p>URL Field wraps an input with URL validation, showing a clickable link preview when not in edit mode.</p>
|
|
1048
|
+
*
|
|
1049
|
+
* @example
|
|
1050
|
+
* ```html
|
|
1051
|
+
* <wc-url-field label="Website" value="https://example.com"></wc-url-field>
|
|
1052
|
+
* ```
|
|
1053
|
+
* @tags form
|
|
1054
|
+
*/
|
|
1055
|
+
class UrlField extends BaseInput {
|
|
1056
|
+
constructor() {
|
|
1057
|
+
super(...arguments);
|
|
1058
|
+
this.value = '';
|
|
1059
|
+
this.name = '';
|
|
1060
|
+
this.placeholder = '';
|
|
1061
|
+
this.label = '';
|
|
1062
|
+
this.editing = false;
|
|
1063
|
+
this.debounce = 300;
|
|
1064
|
+
this.size = 'md';
|
|
1065
|
+
this.variant = 'default';
|
|
1066
|
+
this.helperText = '';
|
|
1067
|
+
this.error = false;
|
|
1068
|
+
this.errorText = '';
|
|
1069
|
+
this.warning = false;
|
|
1070
|
+
this.warningText = '';
|
|
1071
|
+
this.focused = false;
|
|
1072
|
+
this.isValid = true;
|
|
1073
|
+
}
|
|
1074
|
+
disconnectedCallback() {
|
|
1075
|
+
super.disconnectedCallback();
|
|
1076
|
+
if (this.debounceTimer) {
|
|
1077
|
+
clearTimeout(this.debounceTimer);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
focus() {
|
|
1081
|
+
if (!this.editing && !this.disabled && !this.readonly) {
|
|
1082
|
+
this.startEditing();
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
this.inputElement?.focus();
|
|
1086
|
+
}
|
|
1087
|
+
blur() {
|
|
1088
|
+
this.inputElement?.blur();
|
|
1089
|
+
}
|
|
1090
|
+
startEditing() {
|
|
1091
|
+
if (this.disabled || this.readonly)
|
|
1092
|
+
return;
|
|
1093
|
+
this.editing = true;
|
|
1094
|
+
setTimeout(() => this.inputElement?.focus(), 80);
|
|
1095
|
+
}
|
|
1096
|
+
closeEditing() {
|
|
1097
|
+
this.isValid = this.validateUrl(this.value);
|
|
1098
|
+
this.dispatchEvent(new CustomEvent('input-invalid', {
|
|
1099
|
+
detail: !this.isValid,
|
|
1100
|
+
bubbles: true,
|
|
1101
|
+
composed: true,
|
|
1102
|
+
}));
|
|
1103
|
+
if (this.isValid) {
|
|
1104
|
+
this.editing = false;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
validateUrl(url) {
|
|
1108
|
+
if (!url)
|
|
1109
|
+
return true;
|
|
1110
|
+
try {
|
|
1111
|
+
new URL(url);
|
|
1112
|
+
return true;
|
|
1113
|
+
}
|
|
1114
|
+
catch {
|
|
1115
|
+
return false;
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
handleInput(event) {
|
|
1119
|
+
this.value = event.target.value;
|
|
1120
|
+
this.isValid = true;
|
|
1121
|
+
if (this.debounceTimer) {
|
|
1122
|
+
clearTimeout(this.debounceTimer);
|
|
1123
|
+
}
|
|
1124
|
+
this.debounceTimer = setTimeout(() => {
|
|
1125
|
+
this.dispatchEvent(new CustomEvent('value-change', {
|
|
1126
|
+
detail: this.value,
|
|
1127
|
+
bubbles: true,
|
|
1128
|
+
composed: true,
|
|
1129
|
+
}));
|
|
1130
|
+
}, this.debounce);
|
|
1131
|
+
}
|
|
1132
|
+
handleFocusChange() {
|
|
1133
|
+
this.focused = this.inputElement?.matches(':focus') ?? false;
|
|
1134
|
+
}
|
|
1135
|
+
handleBlur() {
|
|
1136
|
+
this.focused = false;
|
|
1137
|
+
this.closeEditing();
|
|
1138
|
+
}
|
|
1139
|
+
handleChange(event) {
|
|
1140
|
+
redispatchEvent(this, event);
|
|
1141
|
+
}
|
|
1142
|
+
renderDisplayValue() {
|
|
1143
|
+
if (!this.value) {
|
|
1144
|
+
return b `<span class="url-placeholder">${this.placeholder}</span>`;
|
|
1145
|
+
}
|
|
1146
|
+
return b `
|
|
1147
|
+
<a
|
|
1148
|
+
class="url-link"
|
|
1149
|
+
href=${this.value}
|
|
1150
|
+
target="_blank"
|
|
1151
|
+
rel="noopener noreferrer"
|
|
1152
|
+
>
|
|
1153
|
+
${this.value}
|
|
1154
|
+
</a>
|
|
1155
|
+
`;
|
|
1156
|
+
}
|
|
1157
|
+
render() {
|
|
1158
|
+
const hasValue = !!this.value;
|
|
1159
|
+
const showInvalidState = this.error || !this.isValid;
|
|
1160
|
+
const resolvedErrorText = !this.isValid
|
|
1161
|
+
? 'Please enter a valid URL'
|
|
1162
|
+
: this.errorText;
|
|
1163
|
+
return b `
|
|
1164
|
+
<wc-field
|
|
1165
|
+
label=${this.label}
|
|
1166
|
+
?required=${this.required}
|
|
1167
|
+
?disabled=${this.disabled}
|
|
1168
|
+
?readonly=${this.readonly}
|
|
1169
|
+
?skeleton=${this.skeleton}
|
|
1170
|
+
helper-text=${this.helperText}
|
|
1171
|
+
?error=${showInvalidState}
|
|
1172
|
+
error-text=${resolvedErrorText}
|
|
1173
|
+
?warning=${this.warning}
|
|
1174
|
+
warning-text=${this.warningText}
|
|
1175
|
+
variant=${this.variant}
|
|
1176
|
+
?populated=${hasValue || this.editing}
|
|
1177
|
+
?focused=${this.focused}
|
|
1178
|
+
.host=${this}
|
|
1179
|
+
class="url-field-wrapper"
|
|
1180
|
+
>
|
|
1181
|
+
${this.editing
|
|
1182
|
+
? b `
|
|
1183
|
+
<input
|
|
1184
|
+
class="url-input"
|
|
1185
|
+
name=${this.name}
|
|
1186
|
+
type="url"
|
|
1187
|
+
placeholder=${this.placeholder}
|
|
1188
|
+
.value=${this.value}
|
|
1189
|
+
?readonly=${this.readonly}
|
|
1190
|
+
?required=${this.required}
|
|
1191
|
+
?disabled=${this.disabled}
|
|
1192
|
+
@input=${this.handleInput}
|
|
1193
|
+
@change=${this.handleChange}
|
|
1194
|
+
@focus=${this.handleFocusChange}
|
|
1195
|
+
@blur=${this.handleBlur}
|
|
1196
|
+
/>
|
|
1197
|
+
`
|
|
1198
|
+
: b `<div class="url-display">${this.renderDisplayValue()}</div>`}
|
|
1199
|
+
${!this.editing && !this.disabled && !this.readonly
|
|
1200
|
+
? b `
|
|
1201
|
+
<wc-icon-button
|
|
1202
|
+
class="edit-button"
|
|
1203
|
+
slot="field-end"
|
|
1204
|
+
variant="text"
|
|
1205
|
+
@click=${(event) => {
|
|
1206
|
+
event.stopPropagation();
|
|
1207
|
+
this.startEditing();
|
|
1208
|
+
}}
|
|
1209
|
+
>
|
|
1210
|
+
<wc-icon name="edit"></wc-icon>
|
|
1211
|
+
</wc-icon-button>
|
|
1212
|
+
`
|
|
1213
|
+
: A}
|
|
1214
|
+
</wc-field>
|
|
1215
|
+
`;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
UrlField.styles = [css_248z$9];
|
|
1219
|
+
__decorate([
|
|
1220
|
+
n({ type: String })
|
|
1221
|
+
], UrlField.prototype, "value", void 0);
|
|
1222
|
+
__decorate([
|
|
1223
|
+
n({ type: String })
|
|
1224
|
+
], UrlField.prototype, "name", void 0);
|
|
1225
|
+
__decorate([
|
|
1226
|
+
n({ type: String })
|
|
1227
|
+
], UrlField.prototype, "placeholder", void 0);
|
|
1228
|
+
__decorate([
|
|
1229
|
+
n({ type: String })
|
|
1230
|
+
], UrlField.prototype, "label", void 0);
|
|
1231
|
+
__decorate([
|
|
1232
|
+
n({ type: Boolean, reflect: true })
|
|
1233
|
+
], UrlField.prototype, "editing", void 0);
|
|
1234
|
+
__decorate([
|
|
1235
|
+
n({ type: Number })
|
|
1236
|
+
], UrlField.prototype, "debounce", void 0);
|
|
1237
|
+
__decorate([
|
|
1238
|
+
n({ type: String, reflect: true })
|
|
1239
|
+
], UrlField.prototype, "size", void 0);
|
|
1240
|
+
__decorate([
|
|
1241
|
+
n({ type: String })
|
|
1242
|
+
], UrlField.prototype, "variant", void 0);
|
|
1243
|
+
__decorate([
|
|
1244
|
+
n({ type: String, attribute: 'helper-text' })
|
|
1245
|
+
], UrlField.prototype, "helperText", void 0);
|
|
1246
|
+
__decorate([
|
|
1247
|
+
n({ type: Boolean })
|
|
1248
|
+
], UrlField.prototype, "error", void 0);
|
|
1249
|
+
__decorate([
|
|
1250
|
+
n({ type: String, attribute: 'error-text' })
|
|
1251
|
+
], UrlField.prototype, "errorText", void 0);
|
|
1252
|
+
__decorate([
|
|
1253
|
+
n({ type: Boolean })
|
|
1254
|
+
], UrlField.prototype, "warning", void 0);
|
|
1255
|
+
__decorate([
|
|
1256
|
+
n({ type: String, attribute: 'warning-text' })
|
|
1257
|
+
], UrlField.prototype, "warningText", void 0);
|
|
1258
|
+
__decorate([
|
|
1259
|
+
r()
|
|
1260
|
+
], UrlField.prototype, "focused", void 0);
|
|
1261
|
+
__decorate([
|
|
1262
|
+
r()
|
|
1263
|
+
], UrlField.prototype, "isValid", void 0);
|
|
1264
|
+
__decorate([
|
|
1265
|
+
e$1('.url-input')
|
|
1266
|
+
], UrlField.prototype, "inputElement", void 0);
|
|
1267
|
+
|
|
1268
|
+
var css_248z$8 = i`* {
|
|
1269
|
+
box-sizing: border-box;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
.screen-reader-only {
|
|
1273
|
+
display: none !important;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
[hidden] {
|
|
1277
|
+
display: none !important;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
:host {
|
|
1281
|
+
display: block;
|
|
1282
|
+
width: 100%;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
.input-element {
|
|
1286
|
+
border: none;
|
|
1287
|
+
outline: none;
|
|
1288
|
+
margin: 0;
|
|
1289
|
+
padding: 0;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
.input-wrapper .input {
|
|
1293
|
+
flex: 1;
|
|
1294
|
+
width: 100%;
|
|
1295
|
+
background: none;
|
|
1296
|
+
cursor: inherit;
|
|
1297
|
+
}
|
|
1298
|
+
.input-wrapper .password-toggle {
|
|
1299
|
+
--button-container-shape: var(--shape-corner-full);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
.stepper {
|
|
1303
|
+
/* Chrome, Safari, Edge, Opera */
|
|
1304
|
+
}
|
|
1305
|
+
.stepper input::-webkit-outer-spin-button,
|
|
1306
|
+
.stepper input::-webkit-inner-spin-button {
|
|
1307
|
+
-webkit-appearance: none;
|
|
1308
|
+
margin: 0;
|
|
1309
|
+
}
|
|
1310
|
+
.stepper {
|
|
1311
|
+
/* Firefox */
|
|
1312
|
+
}
|
|
1313
|
+
.stepper input[type=number] {
|
|
1314
|
+
-moz-appearance: textfield;
|
|
1315
|
+
}`;
|
|
1316
|
+
|
|
1317
|
+
var _NumberField_id;
|
|
1318
|
+
/**
|
|
1319
|
+
* @label Number Field
|
|
1320
|
+
* @tag wc-number-field
|
|
1321
|
+
* @rawTag number-field
|
|
1322
|
+
*
|
|
1323
|
+
* @summary The Number Field component is used to capture numeric user input.
|
|
1324
|
+
*
|
|
1325
|
+
* @example
|
|
1326
|
+
* ```html
|
|
1327
|
+
* <wc-number-field label="Age" placeholder="Enter your age"></wc-number-field>
|
|
1328
|
+
* ```
|
|
1329
|
+
*/
|
|
1330
|
+
class NumberField extends BaseInput {
|
|
1331
|
+
constructor() {
|
|
1332
|
+
super(...arguments);
|
|
1333
|
+
_NumberField_id.set(this, crypto.randomUUID());
|
|
1334
|
+
this.name = '';
|
|
1335
|
+
this.placeholder = '';
|
|
1336
|
+
this.label = '';
|
|
1337
|
+
this.inline = false;
|
|
1338
|
+
this.size = 'md';
|
|
1339
|
+
this.autocomplete = 'off';
|
|
1340
|
+
this.configAria = {};
|
|
1341
|
+
/**
|
|
1342
|
+
* Helper text to display below the input.
|
|
1343
|
+
*/
|
|
1344
|
+
this.helperText = '';
|
|
1345
|
+
this.error = false;
|
|
1346
|
+
this.errorText = '';
|
|
1347
|
+
this.warning = false;
|
|
1348
|
+
this.warningText = '';
|
|
1349
|
+
this.stepper = false;
|
|
1350
|
+
this.focused = false;
|
|
1351
|
+
/**
|
|
1352
|
+
* Returns true when the text field has been interacted with. Native
|
|
1353
|
+
* validation errors only display in response to user interactions.
|
|
1354
|
+
*/
|
|
1355
|
+
this.dirty = false;
|
|
1356
|
+
}
|
|
1357
|
+
connectedCallback() {
|
|
1358
|
+
super.connectedCallback();
|
|
1359
|
+
this.handleInitialAttributes();
|
|
1360
|
+
}
|
|
1361
|
+
handleInitialAttributes() {
|
|
1362
|
+
if (this.hasAttribute('tabindex')) {
|
|
1363
|
+
this.tabindex = this.getAttribute('tabindex') || undefined;
|
|
1364
|
+
this.removeAttribute('tabindex');
|
|
1365
|
+
}
|
|
1366
|
+
Array.from(this.attributes).forEach(attr => {
|
|
1367
|
+
if (attr.name.startsWith('aria-')) {
|
|
1368
|
+
this.configAria[attr.name] = attr.value;
|
|
1369
|
+
this.removeAttribute(attr.name);
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
__handleInput(event) {
|
|
1374
|
+
this.dirty = true;
|
|
1375
|
+
this.value = Number(event.target.value);
|
|
1376
|
+
}
|
|
1377
|
+
focus() {
|
|
1378
|
+
this.inputElement?.focus();
|
|
1379
|
+
}
|
|
1380
|
+
blur() {
|
|
1381
|
+
this.inputElement?.blur();
|
|
1382
|
+
}
|
|
1383
|
+
__handleFocusChange() {
|
|
1384
|
+
// When calling focus() or reportValidity() during change, it's possible
|
|
1385
|
+
// for blur to be called after the new focus event. Rather than set
|
|
1386
|
+
// `this.focused` to true/false on focus/blur, we always set it to whether
|
|
1387
|
+
// or not the input itself is focused.
|
|
1388
|
+
this.focused = this.inputElement?.matches(':focus') ?? false;
|
|
1389
|
+
}
|
|
1390
|
+
__redispatchEvent(event) {
|
|
1391
|
+
redispatchEvent(this, event);
|
|
1392
|
+
}
|
|
1393
|
+
stepUp() {
|
|
1394
|
+
this.inputElement?.stepUp();
|
|
1395
|
+
}
|
|
1396
|
+
stepDown() {
|
|
1397
|
+
this.inputElement?.stepDown();
|
|
1398
|
+
}
|
|
1399
|
+
render() {
|
|
1400
|
+
const classes = {
|
|
1401
|
+
'input-wrapper': true,
|
|
1402
|
+
stepper: this.stepper,
|
|
1403
|
+
};
|
|
1404
|
+
return b `
|
|
1405
|
+
<wc-field
|
|
1406
|
+
?required=${this.required}
|
|
1407
|
+
?disabled=${this.disabled}
|
|
1408
|
+
?readonly=${this.readonly}
|
|
1409
|
+
?skeleton=${this.skeleton}
|
|
1410
|
+
helper-text=${this.helperText}
|
|
1411
|
+
?error=${this.error}
|
|
1412
|
+
error-text=${this.errorText}
|
|
1413
|
+
?warning=${this.warning}
|
|
1414
|
+
warning-text=${this.warningText}
|
|
1415
|
+
label=${this.label}
|
|
1416
|
+
?focused=${this.focused}
|
|
1417
|
+
.host=${this}
|
|
1418
|
+
class=${e(classes)}
|
|
1419
|
+
>
|
|
1420
|
+
${this.stepper && !this.disabled
|
|
1421
|
+
? b `<wc-icon-button
|
|
1422
|
+
class="stepper"
|
|
1423
|
+
variant="text"
|
|
1424
|
+
slot="field-start"
|
|
1425
|
+
@click=${this.stepDown}
|
|
1426
|
+
>
|
|
1427
|
+
<wc-icon name="remove"></wc-icon>
|
|
1428
|
+
</wc-icon-button>`
|
|
1429
|
+
: A}
|
|
1430
|
+
|
|
1431
|
+
<slot name="start" slot="field-start"></slot>
|
|
1432
|
+
|
|
1433
|
+
<input
|
|
1434
|
+
class="input input-element"
|
|
1435
|
+
name=${this.name}
|
|
1436
|
+
type="number"
|
|
1437
|
+
placeholder=${this.placeholder}
|
|
1438
|
+
autocomplete=${this.autocomplete}
|
|
1439
|
+
.value=${this.value}
|
|
1440
|
+
?tabindex=${this.tabindex}
|
|
1441
|
+
?readonly=${this.readonly}
|
|
1442
|
+
?required=${this.required}
|
|
1443
|
+
?disabled=${this.disabled}
|
|
1444
|
+
min=${this.min}
|
|
1445
|
+
max=${this.max}
|
|
1446
|
+
step=${this.step}
|
|
1447
|
+
@input=${this.__handleInput}
|
|
1448
|
+
@change=${this.__redispatchEvent}
|
|
1449
|
+
@focus=${this.__handleFocusChange}
|
|
1450
|
+
@blur=${this.__handleFocusChange}
|
|
1451
|
+
${spread(this.configAria)}
|
|
1452
|
+
/>
|
|
1453
|
+
|
|
1454
|
+
<slot name="end" slot="field-end"></slot>
|
|
1455
|
+
|
|
1456
|
+
${this.stepper && !this.disabled
|
|
1457
|
+
? b `<wc-icon-button
|
|
1458
|
+
class="stepper"
|
|
1459
|
+
variant="text"
|
|
1460
|
+
slot="field-end"
|
|
1461
|
+
@click=${this.stepUp}
|
|
1462
|
+
>
|
|
1463
|
+
<wc-icon name="add"></wc-icon>
|
|
1464
|
+
</wc-icon-button>`
|
|
1465
|
+
: A}
|
|
1466
|
+
</wc-field>
|
|
1467
|
+
`;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
_NumberField_id = new WeakMap();
|
|
1471
|
+
NumberField.styles = [css_248z$8];
|
|
1472
|
+
__decorate([
|
|
1473
|
+
n({ type: Number })
|
|
1474
|
+
], NumberField.prototype, "value", void 0);
|
|
1475
|
+
__decorate([
|
|
1476
|
+
n({ type: String })
|
|
1477
|
+
], NumberField.prototype, "name", void 0);
|
|
1478
|
+
__decorate([
|
|
1479
|
+
n({ type: String })
|
|
1480
|
+
], NumberField.prototype, "placeholder", void 0);
|
|
1481
|
+
__decorate([
|
|
1482
|
+
n({ type: String })
|
|
1483
|
+
], NumberField.prototype, "label", void 0);
|
|
1484
|
+
__decorate([
|
|
1485
|
+
n({ type: Boolean, reflect: true })
|
|
1486
|
+
], NumberField.prototype, "inline", void 0);
|
|
1487
|
+
__decorate([
|
|
1488
|
+
n({ type: String, reflect: true })
|
|
1489
|
+
], NumberField.prototype, "size", void 0);
|
|
1490
|
+
__decorate([
|
|
1491
|
+
n({ type: Number })
|
|
1492
|
+
], NumberField.prototype, "max", void 0);
|
|
1493
|
+
__decorate([
|
|
1494
|
+
n({ type: Number })
|
|
1495
|
+
], NumberField.prototype, "min", void 0);
|
|
1496
|
+
__decorate([
|
|
1497
|
+
n({ type: Number })
|
|
1498
|
+
], NumberField.prototype, "step", void 0);
|
|
1499
|
+
__decorate([
|
|
1500
|
+
n({ type: String })
|
|
1501
|
+
], NumberField.prototype, "autocomplete", void 0);
|
|
1502
|
+
__decorate([
|
|
1503
|
+
n({ type: Object })
|
|
1504
|
+
], NumberField.prototype, "configAria", void 0);
|
|
1505
|
+
__decorate([
|
|
1506
|
+
n({ type: String, attribute: 'helper-text' })
|
|
1507
|
+
], NumberField.prototype, "helperText", void 0);
|
|
1508
|
+
__decorate([
|
|
1509
|
+
n({ type: Boolean })
|
|
1510
|
+
], NumberField.prototype, "error", void 0);
|
|
1511
|
+
__decorate([
|
|
1512
|
+
n({ type: String, attribute: 'error-text' })
|
|
1513
|
+
], NumberField.prototype, "errorText", void 0);
|
|
1514
|
+
__decorate([
|
|
1515
|
+
n({ type: Boolean })
|
|
1516
|
+
], NumberField.prototype, "warning", void 0);
|
|
1517
|
+
__decorate([
|
|
1518
|
+
n({ type: String, attribute: 'warning-text' })
|
|
1519
|
+
], NumberField.prototype, "warningText", void 0);
|
|
1520
|
+
__decorate([
|
|
1521
|
+
n({ type: Boolean })
|
|
1522
|
+
], NumberField.prototype, "stepper", void 0);
|
|
1523
|
+
__decorate([
|
|
1524
|
+
r()
|
|
1525
|
+
], NumberField.prototype, "focused", void 0);
|
|
1526
|
+
__decorate([
|
|
1527
|
+
r()
|
|
1528
|
+
], NumberField.prototype, "dirty", void 0);
|
|
1529
|
+
__decorate([
|
|
1530
|
+
e$1('.input-element')
|
|
1531
|
+
], NumberField.prototype, "inputElement", void 0);
|
|
1532
|
+
|
|
1533
|
+
var css_248z$7 = i`* {
|
|
1534
|
+
box-sizing: border-box;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
.screen-reader-only {
|
|
1538
|
+
display: none !important;
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
[hidden] {
|
|
1542
|
+
display: none !important;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
:host {
|
|
1546
|
+
display: block;
|
|
1547
|
+
width: 100%;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
.input-element {
|
|
1551
|
+
border: none;
|
|
1552
|
+
outline: none;
|
|
1553
|
+
margin: 0;
|
|
1554
|
+
padding: 0;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
.input-wrapper .input {
|
|
1558
|
+
flex: 1;
|
|
1559
|
+
width: 100%;
|
|
1560
|
+
background: none;
|
|
1561
|
+
cursor: inherit;
|
|
1562
|
+
}
|
|
1563
|
+
.input-wrapper .input::-webkit-inner-spin-button,
|
|
1564
|
+
.input-wrapper .input::-webkit-calendar-picker-indicator {
|
|
1565
|
+
display: none;
|
|
1566
|
+
-webkit-appearance: none;
|
|
1567
|
+
}`;
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* @label Date Picker
|
|
1571
|
+
* @tag wc-date-picker
|
|
1572
|
+
* @rawTag date-picker
|
|
1573
|
+
* @summary The Date Picker component is used to capture date user input.
|
|
1574
|
+
* @tags input
|
|
1575
|
+
*
|
|
1576
|
+
* @example
|
|
1577
|
+
* ```html
|
|
1578
|
+
* <wc-date-picker label="Date" placeholder="Select a date"></wc-date-picker>
|
|
1579
|
+
* ```
|
|
1580
|
+
*/
|
|
1581
|
+
class DatePicker extends BaseInput {
|
|
1582
|
+
constructor() {
|
|
1583
|
+
super(...arguments);
|
|
1584
|
+
this.value = '';
|
|
1585
|
+
this.name = '';
|
|
1586
|
+
this.placeholder = '';
|
|
1587
|
+
this.label = '';
|
|
1588
|
+
this.inline = false;
|
|
1589
|
+
this.size = 'md';
|
|
1590
|
+
this.autocomplete = 'off';
|
|
1591
|
+
this.configAria = {};
|
|
1592
|
+
this.variant = 'default';
|
|
1593
|
+
/**
|
|
1594
|
+
* Helper text to display below the input.
|
|
1595
|
+
*/
|
|
1596
|
+
this.helperText = '';
|
|
1597
|
+
this.error = false;
|
|
1598
|
+
this.errorText = '';
|
|
1599
|
+
this.warning = false;
|
|
1600
|
+
this.warningText = '';
|
|
1601
|
+
this.focused = false;
|
|
1602
|
+
this.passwordVisible = false;
|
|
1603
|
+
/**
|
|
1604
|
+
* Returns true when the text field has been interacted with. Native
|
|
1605
|
+
* validation errors only display in response to user interactions.
|
|
1606
|
+
*/
|
|
1607
|
+
this.dirty = false;
|
|
1608
|
+
}
|
|
1609
|
+
connectedCallback() {
|
|
1610
|
+
super.connectedCallback();
|
|
1611
|
+
this.handleInitialAttributes();
|
|
1612
|
+
}
|
|
1613
|
+
handleInitialAttributes() {
|
|
1614
|
+
if (this.hasAttribute('tabindex')) {
|
|
1615
|
+
this.tabindex = this.getAttribute('tabindex') || undefined;
|
|
1616
|
+
this.removeAttribute('tabindex');
|
|
1617
|
+
}
|
|
1618
|
+
Array.from(this.attributes).forEach(attr => {
|
|
1619
|
+
if (attr.name.startsWith('aria-')) {
|
|
1620
|
+
this.configAria[attr.name] = attr.value;
|
|
1621
|
+
this.removeAttribute(attr.name);
|
|
1622
|
+
}
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
__handleInput(event) {
|
|
1626
|
+
this.dirty = true;
|
|
1627
|
+
this.value = event.target.value;
|
|
1628
|
+
}
|
|
1629
|
+
focus() {
|
|
1630
|
+
this.inputElement?.focus();
|
|
1631
|
+
}
|
|
1632
|
+
blur() {
|
|
1633
|
+
this.inputElement?.blur();
|
|
1634
|
+
}
|
|
1635
|
+
__handleFocusChange() {
|
|
1636
|
+
// When calling focus() or reportValidity() during change, it's possible
|
|
1637
|
+
// for blur to be called after the new focus event. Rather than set
|
|
1638
|
+
// `this.focused` to true/false on focus/blur, we always set it to whether
|
|
1639
|
+
// or not the input itself is focused.
|
|
1640
|
+
this.focused = this.inputElement?.matches(':focus') ?? false;
|
|
1641
|
+
}
|
|
1642
|
+
__redispatchEvent(event) {
|
|
1643
|
+
redispatchEvent(this, event);
|
|
1644
|
+
}
|
|
1645
|
+
render() {
|
|
1646
|
+
return b `
|
|
1647
|
+
<wc-field
|
|
1648
|
+
?required=${this.required}
|
|
1649
|
+
?disabled=${this.disabled}
|
|
1650
|
+
?readonly=${this.readonly}
|
|
1651
|
+
?skeleton=${this.skeleton}
|
|
1652
|
+
helper-text=${this.helperText}
|
|
1653
|
+
?error=${this.error}
|
|
1654
|
+
error-text=${this.errorText}
|
|
1655
|
+
?warning=${this.warning}
|
|
1656
|
+
variant=${this.variant}
|
|
1657
|
+
?populated=${!!this.value}
|
|
1658
|
+
warning-text=${this.warningText}
|
|
1659
|
+
label=${this.label}
|
|
1660
|
+
?focused=${this.focused}
|
|
1661
|
+
.host=${this}
|
|
1662
|
+
class="input-wrapper"
|
|
1663
|
+
>
|
|
1664
|
+
<slot name="start" slot="field-start"></slot>
|
|
1665
|
+
|
|
1666
|
+
<input
|
|
1667
|
+
class="input input-element"
|
|
1668
|
+
name=${this.name}
|
|
1669
|
+
type="date"
|
|
1670
|
+
placeholder=${this.placeholder}
|
|
1671
|
+
autocomplete=${this.autocomplete}
|
|
1672
|
+
.value=${this.value}
|
|
1673
|
+
?tabindex=${this.tabindex}
|
|
1674
|
+
?readonly=${this.readonly}
|
|
1675
|
+
?required=${this.required}
|
|
1676
|
+
?disabled=${this.disabled}
|
|
1677
|
+
@input=${this.__handleInput}
|
|
1678
|
+
@change=${this.__redispatchEvent}
|
|
1679
|
+
@focus=${this.__handleFocusChange}
|
|
1680
|
+
@blur=${this.__handleFocusChange}
|
|
1681
|
+
${spread(this.configAria)}
|
|
1682
|
+
/>
|
|
1683
|
+
|
|
1684
|
+
<slot name="end" slot="field-end"></slot>
|
|
1685
|
+
|
|
1686
|
+
<wc-icon-button
|
|
1687
|
+
slot="field-end"
|
|
1688
|
+
color="secondary"
|
|
1689
|
+
variant="text"
|
|
1690
|
+
?disabled=${this.disabled}
|
|
1691
|
+
@click=${() => {
|
|
1692
|
+
setTimeout(() => {
|
|
1693
|
+
// @ts-ignore
|
|
1694
|
+
this.inputElement.showPicker();
|
|
1695
|
+
});
|
|
1696
|
+
}}
|
|
1697
|
+
>
|
|
1698
|
+
<wc-icon name="calendar_today"></wc-icon>
|
|
1699
|
+
</wc-icon-button>
|
|
1700
|
+
</wc-field>
|
|
1701
|
+
`;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
DatePicker.styles = [css_248z$7];
|
|
1705
|
+
__decorate([
|
|
1706
|
+
n({ type: String })
|
|
1707
|
+
], DatePicker.prototype, "value", void 0);
|
|
1708
|
+
__decorate([
|
|
1709
|
+
n({ type: String })
|
|
1710
|
+
], DatePicker.prototype, "name", void 0);
|
|
1711
|
+
__decorate([
|
|
1712
|
+
n({ type: String })
|
|
1713
|
+
], DatePicker.prototype, "placeholder", void 0);
|
|
1714
|
+
__decorate([
|
|
1715
|
+
n({ type: String })
|
|
1716
|
+
], DatePicker.prototype, "label", void 0);
|
|
1717
|
+
__decorate([
|
|
1718
|
+
n({ type: Boolean, reflect: true })
|
|
1719
|
+
], DatePicker.prototype, "inline", void 0);
|
|
1720
|
+
__decorate([
|
|
1721
|
+
n({ type: String, reflect: true })
|
|
1722
|
+
], DatePicker.prototype, "size", void 0);
|
|
1723
|
+
__decorate([
|
|
1724
|
+
n({ type: String })
|
|
1725
|
+
], DatePicker.prototype, "autocomplete", void 0);
|
|
1726
|
+
__decorate([
|
|
1727
|
+
n({ type: Object })
|
|
1728
|
+
], DatePicker.prototype, "configAria", void 0);
|
|
1729
|
+
__decorate([
|
|
1730
|
+
n({ type: String })
|
|
1731
|
+
], DatePicker.prototype, "variant", void 0);
|
|
1732
|
+
__decorate([
|
|
1733
|
+
n({ type: String, attribute: 'helper-text' })
|
|
1734
|
+
], DatePicker.prototype, "helperText", void 0);
|
|
1735
|
+
__decorate([
|
|
1736
|
+
n({ type: Boolean })
|
|
1737
|
+
], DatePicker.prototype, "error", void 0);
|
|
1738
|
+
__decorate([
|
|
1739
|
+
n({ type: String, attribute: 'error-text' })
|
|
1740
|
+
], DatePicker.prototype, "errorText", void 0);
|
|
1741
|
+
__decorate([
|
|
1742
|
+
n({ type: Boolean })
|
|
1743
|
+
], DatePicker.prototype, "warning", void 0);
|
|
1744
|
+
__decorate([
|
|
1745
|
+
n({ type: String, attribute: 'warning-text' })
|
|
1746
|
+
], DatePicker.prototype, "warningText", void 0);
|
|
1747
|
+
__decorate([
|
|
1748
|
+
r()
|
|
1749
|
+
], DatePicker.prototype, "focused", void 0);
|
|
1750
|
+
__decorate([
|
|
1751
|
+
r()
|
|
1752
|
+
], DatePicker.prototype, "passwordVisible", void 0);
|
|
1753
|
+
__decorate([
|
|
1754
|
+
r()
|
|
1755
|
+
], DatePicker.prototype, "dirty", void 0);
|
|
1756
|
+
__decorate([
|
|
1757
|
+
e$1('.input-element')
|
|
1758
|
+
], DatePicker.prototype, "inputElement", void 0);
|
|
1759
|
+
|
|
1760
|
+
var css_248z$6 = i`* {
|
|
1761
|
+
box-sizing: border-box;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
.screen-reader-only {
|
|
1765
|
+
display: none !important;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
[hidden] {
|
|
1769
|
+
display: none !important;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
:host {
|
|
1773
|
+
display: block;
|
|
1774
|
+
width: 100%;
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
.input-element {
|
|
1778
|
+
border: none;
|
|
1779
|
+
outline: none;
|
|
1780
|
+
margin: 0;
|
|
1781
|
+
padding: 0;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
.input-wrapper .input {
|
|
1785
|
+
flex: 1;
|
|
1786
|
+
width: 100%;
|
|
1787
|
+
background: none;
|
|
1788
|
+
cursor: inherit;
|
|
1789
|
+
}
|
|
1790
|
+
.input-wrapper .input::-webkit-inner-spin-button,
|
|
1791
|
+
.input-wrapper .input::-webkit-calendar-picker-indicator {
|
|
1792
|
+
display: none;
|
|
1793
|
+
-webkit-appearance: none;
|
|
1794
|
+
}`;
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* @label Time Picker
|
|
1798
|
+
* @tag wc-time-picker
|
|
1799
|
+
* @rawTag time-picker
|
|
1800
|
+
* @summary The Time Picker component is used to capture time user input.
|
|
1801
|
+
* @tags input
|
|
1802
|
+
*
|
|
1803
|
+
* @example
|
|
1804
|
+
* ```html
|
|
1805
|
+
* <wc-time-picker label="Time" placeholder="Select a time"></wc-time-picker>
|
|
1806
|
+
* ```
|
|
1807
|
+
*/
|
|
1808
|
+
class TimePicker extends BaseInput {
|
|
1809
|
+
constructor() {
|
|
1810
|
+
super(...arguments);
|
|
1811
|
+
this.value = '';
|
|
1812
|
+
this.name = '';
|
|
1813
|
+
this.placeholder = '';
|
|
1814
|
+
this.label = '';
|
|
1815
|
+
this.inline = false;
|
|
1816
|
+
this.size = 'md';
|
|
1817
|
+
this.autocomplete = 'off';
|
|
1818
|
+
this.configAria = {};
|
|
1819
|
+
this.variant = 'default';
|
|
1820
|
+
/**
|
|
1821
|
+
* Helper text to display below the input.
|
|
1822
|
+
*/
|
|
1823
|
+
this.helperText = '';
|
|
1824
|
+
this.error = false;
|
|
1825
|
+
this.errorText = '';
|
|
1826
|
+
this.warning = false;
|
|
1827
|
+
this.warningText = '';
|
|
1828
|
+
this.focused = false;
|
|
1829
|
+
this.passwordVisible = false;
|
|
1830
|
+
/**
|
|
1831
|
+
* Returns true when the text field has been interacted with. Native
|
|
1832
|
+
* validation errors only display in response to user interactions.
|
|
1833
|
+
*/
|
|
1834
|
+
this.dirty = false;
|
|
1835
|
+
}
|
|
1836
|
+
connectedCallback() {
|
|
1837
|
+
super.connectedCallback();
|
|
1838
|
+
this.handleInitialAttributes();
|
|
1839
|
+
}
|
|
1840
|
+
handleInitialAttributes() {
|
|
1841
|
+
if (this.hasAttribute('tabindex')) {
|
|
1842
|
+
this.tabindex = this.getAttribute('tabindex') || undefined;
|
|
1843
|
+
this.removeAttribute('tabindex');
|
|
1844
|
+
}
|
|
1845
|
+
Array.from(this.attributes).forEach(attr => {
|
|
1846
|
+
if (attr.name.startsWith('aria-')) {
|
|
1847
|
+
this.configAria[attr.name] = attr.value;
|
|
1848
|
+
this.removeAttribute(attr.name);
|
|
1849
|
+
}
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
__handleInput(event) {
|
|
1853
|
+
this.dirty = true;
|
|
1854
|
+
this.value = event.target.value;
|
|
1855
|
+
}
|
|
1856
|
+
focus() {
|
|
1857
|
+
this.inputElement?.focus();
|
|
1858
|
+
}
|
|
1859
|
+
blur() {
|
|
1860
|
+
this.inputElement?.blur();
|
|
1861
|
+
}
|
|
1862
|
+
__handleFocusChange() {
|
|
1863
|
+
// When calling focus() or reportValidity() during change, it's possible
|
|
1864
|
+
// for blur to be called after the new focus event. Rather than set
|
|
1865
|
+
// `this.focused` to true/false on focus/blur, we always set it to whether
|
|
1866
|
+
// or not the input itself is focused.
|
|
1867
|
+
this.focused = this.inputElement?.matches(':focus') ?? false;
|
|
1868
|
+
}
|
|
1869
|
+
__redispatchEvent(event) {
|
|
1870
|
+
redispatchEvent(this, event);
|
|
1871
|
+
}
|
|
1872
|
+
render() {
|
|
1873
|
+
return b `
|
|
1874
|
+
<wc-field
|
|
1875
|
+
?required=${this.required}
|
|
1876
|
+
?disabled=${this.disabled}
|
|
1877
|
+
?readonly=${this.readonly}
|
|
1878
|
+
?skeleton=${this.skeleton}
|
|
1879
|
+
helper-text=${this.helperText}
|
|
1880
|
+
?error=${this.error}
|
|
1881
|
+
error-text=${this.errorText}
|
|
1882
|
+
?warning=${this.warning}
|
|
1883
|
+
variant=${this.variant}
|
|
1884
|
+
?populated=${!!this.value}
|
|
1885
|
+
warning-text=${this.warningText}
|
|
1886
|
+
label=${this.label}
|
|
1887
|
+
?focused=${this.focused}
|
|
1888
|
+
.host=${this}
|
|
1889
|
+
class="input-wrapper"
|
|
1890
|
+
>
|
|
1891
|
+
<slot name="start" slot="field-start"></slot>
|
|
1892
|
+
|
|
1893
|
+
<input
|
|
1894
|
+
class="input input-element"
|
|
1895
|
+
name=${this.name}
|
|
1896
|
+
type="time"
|
|
1897
|
+
placeholder=${this.placeholder}
|
|
1898
|
+
autocomplete=${this.autocomplete}
|
|
1899
|
+
.value=${this.value}
|
|
1900
|
+
?tabindex=${this.tabindex}
|
|
1901
|
+
?readonly=${this.readonly}
|
|
1902
|
+
?required=${this.required}
|
|
1903
|
+
?disabled=${this.disabled}
|
|
1904
|
+
@input=${this.__handleInput}
|
|
1905
|
+
@change=${this.__redispatchEvent}
|
|
1906
|
+
@focus=${this.__handleFocusChange}
|
|
1907
|
+
@blur=${this.__handleFocusChange}
|
|
1908
|
+
${spread(this.configAria)}
|
|
1909
|
+
/>
|
|
1910
|
+
|
|
1911
|
+
<slot name="end" slot="field-end"></slot>
|
|
1912
|
+
|
|
1913
|
+
<wc-icon-button
|
|
1914
|
+
slot="field-end"
|
|
1915
|
+
color="secondary"
|
|
1916
|
+
variant="text"
|
|
1917
|
+
?disabled=${this.disabled}
|
|
1918
|
+
@click=${() => {
|
|
1919
|
+
setTimeout(() => {
|
|
1920
|
+
// @ts-ignore
|
|
1921
|
+
this.inputElement.showPicker();
|
|
1922
|
+
});
|
|
1923
|
+
}}
|
|
1924
|
+
>
|
|
1925
|
+
<wc-icon name="calendar_today"></wc-icon>
|
|
1926
|
+
</wc-icon-button>
|
|
1927
|
+
</wc-field>
|
|
1928
|
+
`;
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
TimePicker.styles = [css_248z$6];
|
|
1932
|
+
__decorate([
|
|
1933
|
+
n({ type: String })
|
|
1934
|
+
], TimePicker.prototype, "value", void 0);
|
|
1935
|
+
__decorate([
|
|
1936
|
+
n({ type: String })
|
|
1937
|
+
], TimePicker.prototype, "name", void 0);
|
|
1938
|
+
__decorate([
|
|
1939
|
+
n({ type: String })
|
|
1940
|
+
], TimePicker.prototype, "placeholder", void 0);
|
|
1941
|
+
__decorate([
|
|
1942
|
+
n({ type: String })
|
|
1943
|
+
], TimePicker.prototype, "label", void 0);
|
|
1944
|
+
__decorate([
|
|
1945
|
+
n({ type: Boolean, reflect: true })
|
|
1946
|
+
], TimePicker.prototype, "inline", void 0);
|
|
1947
|
+
__decorate([
|
|
1948
|
+
n({ type: String, reflect: true })
|
|
1949
|
+
], TimePicker.prototype, "size", void 0);
|
|
1950
|
+
__decorate([
|
|
1951
|
+
n({ type: String })
|
|
1952
|
+
], TimePicker.prototype, "autocomplete", void 0);
|
|
1953
|
+
__decorate([
|
|
1954
|
+
n({ type: Object })
|
|
1955
|
+
], TimePicker.prototype, "configAria", void 0);
|
|
1956
|
+
__decorate([
|
|
1957
|
+
n({ type: String })
|
|
1958
|
+
], TimePicker.prototype, "variant", void 0);
|
|
1959
|
+
__decorate([
|
|
1960
|
+
n({ type: String, attribute: 'helper-text' })
|
|
1961
|
+
], TimePicker.prototype, "helperText", void 0);
|
|
1962
|
+
__decorate([
|
|
1963
|
+
n({ type: Boolean })
|
|
1964
|
+
], TimePicker.prototype, "error", void 0);
|
|
1965
|
+
__decorate([
|
|
1966
|
+
n({ type: String, attribute: 'error-text' })
|
|
1967
|
+
], TimePicker.prototype, "errorText", void 0);
|
|
1968
|
+
__decorate([
|
|
1969
|
+
n({ type: Boolean })
|
|
1970
|
+
], TimePicker.prototype, "warning", void 0);
|
|
1971
|
+
__decorate([
|
|
1972
|
+
n({ type: String, attribute: 'warning-text' })
|
|
1973
|
+
], TimePicker.prototype, "warningText", void 0);
|
|
1974
|
+
__decorate([
|
|
1975
|
+
r()
|
|
1976
|
+
], TimePicker.prototype, "focused", void 0);
|
|
1977
|
+
__decorate([
|
|
1978
|
+
r()
|
|
1979
|
+
], TimePicker.prototype, "passwordVisible", void 0);
|
|
1980
|
+
__decorate([
|
|
1981
|
+
r()
|
|
1982
|
+
], TimePicker.prototype, "dirty", void 0);
|
|
1983
|
+
__decorate([
|
|
1984
|
+
e$1('.input-element')
|
|
1985
|
+
], TimePicker.prototype, "inputElement", void 0);
|
|
1986
|
+
|
|
1987
|
+
var css_248z$5 = i`* {
|
|
1988
|
+
box-sizing: border-box;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
.screen-reader-only {
|
|
1992
|
+
display: none !important;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
[hidden] {
|
|
1996
|
+
display: none !important;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
:host {
|
|
2000
|
+
display: block;
|
|
2001
|
+
width: 100%;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
.input-element {
|
|
2005
|
+
border: none;
|
|
2006
|
+
outline: none;
|
|
2007
|
+
margin: 0;
|
|
2008
|
+
padding: 0;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
.input-wrapper .input {
|
|
2012
|
+
flex: 1;
|
|
2013
|
+
width: 100%;
|
|
2014
|
+
background: none;
|
|
2015
|
+
cursor: inherit;
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
.textarea {
|
|
2019
|
+
height: 100%;
|
|
2020
|
+
position: relative;
|
|
2021
|
+
align-items: flex-start;
|
|
2022
|
+
--field-height: auto;
|
|
2023
|
+
--field-padding-block: var(--spacing-100);
|
|
2024
|
+
}
|
|
2025
|
+
.textarea .input {
|
|
2026
|
+
height: 100%;
|
|
2027
|
+
resize: vertical;
|
|
2028
|
+
}`;
|
|
2029
|
+
|
|
2030
|
+
/**
|
|
2031
|
+
* @label Textarea
|
|
2032
|
+
* @tag wc-textarea
|
|
2033
|
+
* @rawTag textarea
|
|
2034
|
+
* @summary The Textarea component is used to capture user input.
|
|
2035
|
+
* @tags input
|
|
2036
|
+
*
|
|
2037
|
+
* @example
|
|
2038
|
+
* ```html
|
|
2039
|
+
* <wc-textarea label="Description" placeholder="Enter text"></wc-textarea>
|
|
2040
|
+
* ```
|
|
2041
|
+
*/
|
|
2042
|
+
class Textarea extends BaseInput {
|
|
2043
|
+
constructor() {
|
|
2044
|
+
super(...arguments);
|
|
2045
|
+
this.value = '';
|
|
2046
|
+
this.name = '';
|
|
2047
|
+
this.placeholder = '';
|
|
2048
|
+
this.label = '';
|
|
2049
|
+
this.inline = false;
|
|
2050
|
+
this.size = 'md';
|
|
2051
|
+
this.autocomplete = 'off';
|
|
2052
|
+
this.configAria = {};
|
|
2053
|
+
this.variant = 'default';
|
|
2054
|
+
/**
|
|
2055
|
+
* Helper text to display below the input.
|
|
2056
|
+
*/
|
|
2057
|
+
this.helperText = '';
|
|
2058
|
+
this.error = false;
|
|
2059
|
+
this.errorText = '';
|
|
2060
|
+
this.warning = false;
|
|
2061
|
+
this.warningText = '';
|
|
2062
|
+
this.rows = '3';
|
|
2063
|
+
this.focused = false;
|
|
2064
|
+
this.passwordVisible = false;
|
|
2065
|
+
/**
|
|
2066
|
+
* Returns true when the text field has been interacted with. Native
|
|
2067
|
+
* validation errors only display in response to user interactions.
|
|
2068
|
+
*/
|
|
2069
|
+
this.dirty = false;
|
|
2070
|
+
}
|
|
2071
|
+
connectedCallback() {
|
|
2072
|
+
super.connectedCallback();
|
|
2073
|
+
this.handleInitialAttributes();
|
|
2074
|
+
}
|
|
2075
|
+
handleInitialAttributes() {
|
|
2076
|
+
if (this.hasAttribute('tabindex')) {
|
|
2077
|
+
this.tabindex = this.getAttribute('tabindex') || undefined;
|
|
2078
|
+
this.removeAttribute('tabindex');
|
|
2079
|
+
}
|
|
2080
|
+
Array.from(this.attributes).forEach(attr => {
|
|
2081
|
+
if (attr.name.startsWith('aria-')) {
|
|
2082
|
+
this.configAria[attr.name] = attr.value;
|
|
2083
|
+
this.removeAttribute(attr.name);
|
|
2084
|
+
}
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
__handleInput(event) {
|
|
2088
|
+
this.dirty = true;
|
|
2089
|
+
this.value = event.target.value;
|
|
2090
|
+
}
|
|
2091
|
+
focus() {
|
|
2092
|
+
this.inputElement?.focus();
|
|
2093
|
+
}
|
|
2094
|
+
blur() {
|
|
2095
|
+
this.inputElement?.blur();
|
|
2096
|
+
}
|
|
2097
|
+
__handleFocusChange() {
|
|
2098
|
+
// When calling focus() or reportValidity() during change, it's possible
|
|
2099
|
+
// for blur to be called after the new focus event. Rather than set
|
|
2100
|
+
// `this.focused` to true/false on focus/blur, we always set it to whether
|
|
2101
|
+
// or not the input itself is focused.
|
|
2102
|
+
this.focused = this.inputElement?.matches(':focus') ?? false;
|
|
2103
|
+
}
|
|
2104
|
+
__redispatchEvent(event) {
|
|
2105
|
+
redispatchEvent(this, event);
|
|
2106
|
+
}
|
|
2107
|
+
render() {
|
|
2108
|
+
return b `
|
|
2109
|
+
<wc-field
|
|
2110
|
+
?required=${this.required}
|
|
2111
|
+
?disabled=${this.disabled}
|
|
2112
|
+
?readonly=${this.readonly}
|
|
2113
|
+
?skeleton=${this.skeleton}
|
|
2114
|
+
helper-text=${this.helperText}
|
|
2115
|
+
?error=${this.error}
|
|
2116
|
+
error-text=${this.errorText}
|
|
2117
|
+
?warning=${this.warning}
|
|
2118
|
+
variant=${this.variant}
|
|
2119
|
+
?populated=${!!this.value}
|
|
2120
|
+
warning-text=${this.warningText}
|
|
2121
|
+
label=${this.label}
|
|
2122
|
+
?focused=${this.focused}
|
|
2123
|
+
.host=${this}
|
|
2124
|
+
class="input-wrapper textarea"
|
|
2125
|
+
>
|
|
2126
|
+
<slot name="start" slot="field-start"></slot>
|
|
2127
|
+
|
|
2128
|
+
<textarea
|
|
2129
|
+
class="input input-element"
|
|
2130
|
+
rows=${this.rows}
|
|
2131
|
+
name=${this.name}
|
|
2132
|
+
placeholder=${this.placeholder}
|
|
2133
|
+
autocomplete=${this.autocomplete}
|
|
2134
|
+
.value=${this.value}
|
|
2135
|
+
?tabindex=${this.tabindex}
|
|
2136
|
+
?readonly=${this.readonly}
|
|
2137
|
+
?required=${this.required}
|
|
2138
|
+
?disabled=${this.disabled}
|
|
2139
|
+
@input=${this.__handleInput}
|
|
2140
|
+
@change=${this.__redispatchEvent}
|
|
2141
|
+
@focus=${this.__handleFocusChange}
|
|
2142
|
+
@blur=${this.__handleFocusChange}
|
|
2143
|
+
${spread(this.configAria)}
|
|
2144
|
+
></textarea>
|
|
2145
|
+
|
|
2146
|
+
<slot name="end" slot="field-end"></slot>
|
|
2147
|
+
</wc-field>
|
|
2148
|
+
`;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
Textarea.styles = [css_248z$5];
|
|
2152
|
+
__decorate([
|
|
2153
|
+
n({ type: String })
|
|
2154
|
+
], Textarea.prototype, "value", void 0);
|
|
2155
|
+
__decorate([
|
|
2156
|
+
n({ type: String })
|
|
2157
|
+
], Textarea.prototype, "name", void 0);
|
|
2158
|
+
__decorate([
|
|
2159
|
+
n({ type: String })
|
|
2160
|
+
], Textarea.prototype, "placeholder", void 0);
|
|
2161
|
+
__decorate([
|
|
2162
|
+
n({ type: String })
|
|
2163
|
+
], Textarea.prototype, "label", void 0);
|
|
2164
|
+
__decorate([
|
|
2165
|
+
n({ type: Boolean, reflect: true })
|
|
2166
|
+
], Textarea.prototype, "inline", void 0);
|
|
2167
|
+
__decorate([
|
|
2168
|
+
n({ type: String, reflect: true })
|
|
2169
|
+
], Textarea.prototype, "size", void 0);
|
|
2170
|
+
__decorate([
|
|
2171
|
+
n({ type: String })
|
|
2172
|
+
], Textarea.prototype, "autocomplete", void 0);
|
|
2173
|
+
__decorate([
|
|
2174
|
+
n({ type: Object })
|
|
2175
|
+
], Textarea.prototype, "configAria", void 0);
|
|
2176
|
+
__decorate([
|
|
2177
|
+
n({ type: String })
|
|
2178
|
+
], Textarea.prototype, "variant", void 0);
|
|
2179
|
+
__decorate([
|
|
2180
|
+
n({ type: String, attribute: 'helper-text' })
|
|
2181
|
+
], Textarea.prototype, "helperText", void 0);
|
|
2182
|
+
__decorate([
|
|
2183
|
+
n({ type: Boolean })
|
|
2184
|
+
], Textarea.prototype, "error", void 0);
|
|
2185
|
+
__decorate([
|
|
2186
|
+
n({ type: String, attribute: 'error-text' })
|
|
2187
|
+
], Textarea.prototype, "errorText", void 0);
|
|
2188
|
+
__decorate([
|
|
2189
|
+
n({ type: Boolean })
|
|
2190
|
+
], Textarea.prototype, "warning", void 0);
|
|
2191
|
+
__decorate([
|
|
2192
|
+
n({ type: String, attribute: 'warning-text' })
|
|
2193
|
+
], Textarea.prototype, "warningText", void 0);
|
|
2194
|
+
__decorate([
|
|
2195
|
+
n({ type: String })
|
|
2196
|
+
], Textarea.prototype, "rows", void 0);
|
|
2197
|
+
__decorate([
|
|
2198
|
+
r()
|
|
2199
|
+
], Textarea.prototype, "focused", void 0);
|
|
2200
|
+
__decorate([
|
|
2201
|
+
r()
|
|
2202
|
+
], Textarea.prototype, "passwordVisible", void 0);
|
|
2203
|
+
__decorate([
|
|
2204
|
+
r()
|
|
2205
|
+
], Textarea.prototype, "dirty", void 0);
|
|
2206
|
+
__decorate([
|
|
2207
|
+
e$1('.input-element')
|
|
2208
|
+
], Textarea.prototype, "inputElement", void 0);
|
|
2209
|
+
|
|
2210
|
+
var css_248z$4 = i`* {
|
|
2211
|
+
box-sizing: border-box;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
.screen-reader-only {
|
|
2215
|
+
display: none !important;
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
[hidden] {
|
|
2219
|
+
display: none !important;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
:host {
|
|
2223
|
+
display: inline-block;
|
|
2224
|
+
--switch-track-color: var(--color-primary);
|
|
2225
|
+
--switch-track-off-color: var(--color-surface-container-highest);
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
.switch {
|
|
2229
|
+
position: relative;
|
|
2230
|
+
display: flex;
|
|
2231
|
+
align-items: center;
|
|
2232
|
+
}
|
|
2233
|
+
.switch .input-native {
|
|
2234
|
+
position: absolute;
|
|
2235
|
+
width: 1px;
|
|
2236
|
+
height: 1px;
|
|
2237
|
+
padding: 0;
|
|
2238
|
+
margin: -1px;
|
|
2239
|
+
overflow: hidden;
|
|
2240
|
+
clip: rect(0, 0, 0, 0);
|
|
2241
|
+
border: 0;
|
|
2242
|
+
}
|
|
2243
|
+
.switch .label {
|
|
2244
|
+
font-family: var(--typography-label-medium-font-family) !important;
|
|
2245
|
+
font-size: var(--typography-label-medium-font-size) !important;
|
|
2246
|
+
font-weight: var(--typography-label-medium-font-weight) !important;
|
|
2247
|
+
line-height: var(--typography-label-medium-line-height) !important;
|
|
2248
|
+
letter-spacing: var(--typography-label-medium-letter-spacing) !important;
|
|
2249
|
+
}
|
|
2250
|
+
.switch.has-content {
|
|
2251
|
+
gap: var(--spacing-150);
|
|
2252
|
+
}
|
|
2253
|
+
.switch .track {
|
|
2254
|
+
position: relative;
|
|
2255
|
+
background: var(--switch-track-off-color);
|
|
2256
|
+
border: 2px solid var(--color-outline);
|
|
2257
|
+
border-radius: var(--shape-corner-full);
|
|
2258
|
+
cursor: pointer;
|
|
2259
|
+
display: flex;
|
|
2260
|
+
transition: background-color var(--duration-short2) var(--easing-standard);
|
|
2261
|
+
align-items: center;
|
|
2262
|
+
width: var(--_container-width);
|
|
2263
|
+
height: var(--_container-height);
|
|
2264
|
+
padding: 0 4px;
|
|
2265
|
+
}
|
|
2266
|
+
.switch .track .handle {
|
|
2267
|
+
display: flex;
|
|
2268
|
+
align-items: center;
|
|
2269
|
+
justify-content: center;
|
|
2270
|
+
border-radius: var(--shape-corner-full);
|
|
2271
|
+
transition: all var(--duration-short2) var(--easing-standard);
|
|
2272
|
+
background: white;
|
|
2273
|
+
height: var(--switch-handle-radius);
|
|
2274
|
+
width: var(--switch-handle-radius);
|
|
2275
|
+
background: var(--switch-handle-color);
|
|
2276
|
+
}
|
|
2277
|
+
.switch .track .handle .icon {
|
|
2278
|
+
--icon-size: .75rem;
|
|
2279
|
+
--icon-color: var(--switch-track-off-color);
|
|
2280
|
+
}
|
|
2281
|
+
.switch.has-focus:not(.active) .track {
|
|
2282
|
+
outline: 3px solid var(--color-primary);
|
|
2283
|
+
outline-offset: 2px;
|
|
2284
|
+
border-color: var(--color-white);
|
|
2285
|
+
}
|
|
2286
|
+
.switch.has-focus:not(.active):not(.state-checked) .handle {
|
|
2287
|
+
border-color: var(--icon-01);
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
.switch.state-checked .track {
|
|
2291
|
+
background: var(--switch-track-color);
|
|
2292
|
+
border-color: transparent;
|
|
2293
|
+
}
|
|
2294
|
+
.switch.state-checked .handle {
|
|
2295
|
+
margin-inline-start: calc(100% - var(--switch-handle-radius));
|
|
2296
|
+
}
|
|
2297
|
+
.switch.state-checked .handle .icon {
|
|
2298
|
+
--icon-size: 1rem;
|
|
2299
|
+
--icon-color: var(--switch-track-color);
|
|
2300
|
+
}
|
|
2301
|
+
.switch.state-checked.active .track {
|
|
2302
|
+
border-color: var(--switch-track-color);
|
|
2303
|
+
}
|
|
2304
|
+
.switch.state-checked.has-focus:not(.active) .track {
|
|
2305
|
+
outline: 3px solid var(--color-primary);
|
|
2306
|
+
outline-offset: 2px;
|
|
2307
|
+
border-color: var(--color-white);
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
.switch {
|
|
2311
|
+
--_container-width: 3.25rem;
|
|
2312
|
+
--_container-height: 2rem;
|
|
2313
|
+
--switch-handle-radius: 16px;
|
|
2314
|
+
--switch-handle-color: var(--color-outline);
|
|
2315
|
+
}
|
|
2316
|
+
.switch.state-checked {
|
|
2317
|
+
--switch-handle-radius: 22px;
|
|
2318
|
+
--switch-handle-color: var(--color-surface-container-lowest);
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
.switch.readonly {
|
|
2322
|
+
cursor: default;
|
|
2323
|
+
}
|
|
2324
|
+
.switch.readonly .track {
|
|
2325
|
+
border-color: var(--color-outline);
|
|
2326
|
+
background: var(--switch-track-off-color);
|
|
2327
|
+
opacity: 0.38;
|
|
2328
|
+
}
|
|
2329
|
+
.switch.readonly .track .handle {
|
|
2330
|
+
background: var(--color-outline) !important;
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
.switch.disabled {
|
|
2334
|
+
cursor: not-allowed;
|
|
2335
|
+
}
|
|
2336
|
+
.switch.disabled .track {
|
|
2337
|
+
border-color: var(--color-on-surface);
|
|
2338
|
+
background: var(--switch-track-off-color);
|
|
2339
|
+
opacity: 0.38;
|
|
2340
|
+
}
|
|
2341
|
+
.switch.disabled .track .handle {
|
|
2342
|
+
background: var(--color-on-surface) !important;
|
|
2343
|
+
}`;
|
|
2344
|
+
|
|
2345
|
+
/**
|
|
2346
|
+
* @label Switch
|
|
2347
|
+
* @tag wc-switch
|
|
2348
|
+
* @rawTag switch
|
|
2349
|
+
*
|
|
2350
|
+
* @summary Captures boolean input with an on/off switch interaction.
|
|
2351
|
+
* @overview
|
|
2352
|
+
* <p>Toggles are used to enable or disable a single option. They provide immediate feedback about whether an option is active or inactive.</p>
|
|
2353
|
+
*
|
|
2354
|
+
* @cssprop --switch-track-color: Color of the switch track when checked.
|
|
2355
|
+
* @cssprop --switch-track-off-color: Color of the switch track when unchecked.
|
|
2356
|
+
* @cssprop --switch-width: Width of the switch track.
|
|
2357
|
+
* @cssprop --switch-height: Height of the switch track.
|
|
2358
|
+
* @cssprop --switch-handle-radius: Size of the switch handle.
|
|
2359
|
+
* @cssprop --switch-handle-color: Color of the switch handle.
|
|
2360
|
+
*
|
|
2361
|
+
* @fires {CustomEvent} change - Dispatched when the switch value changes.
|
|
2362
|
+
* @fires {CustomEvent} blur - Dispatched when the switch loses focus.
|
|
2363
|
+
* @fires {CustomEvent} focus - Dispatched when the switch receives focus.
|
|
2364
|
+
*
|
|
2365
|
+
* @example
|
|
2366
|
+
* ```html
|
|
2367
|
+
* <wc-switch value="true"></wc-switch>
|
|
2368
|
+
* ```
|
|
2369
|
+
* @tags input, form
|
|
2370
|
+
*/
|
|
2371
|
+
class Switch extends BaseInput {
|
|
2372
|
+
constructor() {
|
|
2373
|
+
super(...arguments);
|
|
2374
|
+
this.value = false;
|
|
2375
|
+
/**
|
|
2376
|
+
* The input field name.
|
|
2377
|
+
*/
|
|
2378
|
+
this.name = '';
|
|
2379
|
+
/**
|
|
2380
|
+
* The switch label.
|
|
2381
|
+
*/
|
|
2382
|
+
this.label = '';
|
|
2383
|
+
/**
|
|
2384
|
+
* If true, the toggle has rounded corners. Defaults to `true`.
|
|
2385
|
+
*/
|
|
2386
|
+
this.rounded = true;
|
|
2387
|
+
/**
|
|
2388
|
+
* If true, required icon is shown. Defaults to `false`.
|
|
2389
|
+
*/
|
|
2390
|
+
this.required = false;
|
|
2391
|
+
/**
|
|
2392
|
+
* If true, the toggle is readonly. Defaults to `false`.
|
|
2393
|
+
*/
|
|
2394
|
+
this.readonly = false;
|
|
2395
|
+
/**
|
|
2396
|
+
* If true, the user cannot interact with the toggle. Defaults to `false`.
|
|
2397
|
+
*/
|
|
2398
|
+
this.disabled = false;
|
|
2399
|
+
this.withIcon = false;
|
|
2400
|
+
/**
|
|
2401
|
+
* Configuration object for aria attributes.
|
|
2402
|
+
*/
|
|
2403
|
+
this.configAria = {};
|
|
2404
|
+
this.hasFocus = false;
|
|
2405
|
+
this.isActive = false;
|
|
2406
|
+
this.slotHasContent = false;
|
|
2407
|
+
this.windowMouseUp = () => {
|
|
2408
|
+
if (this.isActive) {
|
|
2409
|
+
this.isActive = false;
|
|
2410
|
+
}
|
|
2411
|
+
};
|
|
2412
|
+
this.windowKeyUp = (evt) => {
|
|
2413
|
+
if (this.isActive && evt.key === ' ') {
|
|
2414
|
+
this.isActive = false;
|
|
2415
|
+
}
|
|
2416
|
+
};
|
|
2417
|
+
this.mouseDownHandler = () => {
|
|
2418
|
+
this.isActive = true;
|
|
2419
|
+
};
|
|
2420
|
+
this.keyDownHandler = (evt) => {
|
|
2421
|
+
if (evt.key === ' ') {
|
|
2422
|
+
evt.preventDefault();
|
|
2423
|
+
this.isActive = true;
|
|
2424
|
+
this.clickHandler(evt);
|
|
2425
|
+
}
|
|
2426
|
+
};
|
|
2427
|
+
this.clickHandler = (ev) => {
|
|
2428
|
+
if (!this.disabled && !this.readonly) {
|
|
2429
|
+
this.value = !this.value;
|
|
2430
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
2431
|
+
detail: { value: this.value, originalEvent: ev },
|
|
2432
|
+
bubbles: true,
|
|
2433
|
+
composed: true,
|
|
2434
|
+
}));
|
|
2435
|
+
this.trackElement?.focus();
|
|
2436
|
+
}
|
|
2437
|
+
};
|
|
2438
|
+
this.blurHandler = (ev) => {
|
|
2439
|
+
this.hasFocus = false;
|
|
2440
|
+
this.dispatchEvent(new CustomEvent('blur', {
|
|
2441
|
+
detail: ev,
|
|
2442
|
+
bubbles: true,
|
|
2443
|
+
composed: true,
|
|
2444
|
+
}));
|
|
2445
|
+
};
|
|
2446
|
+
this.focusHandler = (ev) => {
|
|
2447
|
+
this.hasFocus = true;
|
|
2448
|
+
this.dispatchEvent(new CustomEvent('focus', {
|
|
2449
|
+
detail: ev,
|
|
2450
|
+
bubbles: true,
|
|
2451
|
+
composed: true,
|
|
2452
|
+
}));
|
|
2453
|
+
};
|
|
2454
|
+
this.handleKeyUp = (evt) => {
|
|
2455
|
+
if (evt.key === 'Enter') {
|
|
2456
|
+
this.clickHandler(evt);
|
|
2457
|
+
}
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
connectedCallback() {
|
|
2461
|
+
super.connectedCallback();
|
|
2462
|
+
this.handleInitialAttributes();
|
|
2463
|
+
window.addEventListener('mouseup', this.windowMouseUp);
|
|
2464
|
+
window.addEventListener('keyup', this.windowKeyUp);
|
|
2465
|
+
}
|
|
2466
|
+
disconnectedCallback() {
|
|
2467
|
+
super.disconnectedCallback();
|
|
2468
|
+
window.removeEventListener('mouseup', this.windowMouseUp);
|
|
2469
|
+
window.removeEventListener('keyup', this.windowKeyUp);
|
|
2470
|
+
}
|
|
2471
|
+
firstUpdated() {
|
|
2472
|
+
this.slotHasContent = this.hasChildNodes();
|
|
2473
|
+
}
|
|
2474
|
+
handleInitialAttributes() {
|
|
2475
|
+
if (this.hasAttribute('tabindex')) {
|
|
2476
|
+
this.tabindex = this.getAttribute('tabindex') || undefined;
|
|
2477
|
+
this.removeAttribute('tabindex');
|
|
2478
|
+
}
|
|
2479
|
+
Array.from(this.attributes).forEach(attr => {
|
|
2480
|
+
if (attr.name.startsWith('aria-')) {
|
|
2481
|
+
this.configAria[attr.name] = attr.value;
|
|
2482
|
+
this.removeAttribute(attr.name);
|
|
2483
|
+
}
|
|
2484
|
+
});
|
|
2485
|
+
}
|
|
2486
|
+
/**
|
|
2487
|
+
* Sets focus on the toggle.
|
|
2488
|
+
*/
|
|
2489
|
+
focus() {
|
|
2490
|
+
this.trackElement?.focus();
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Removes focus from the toggle.
|
|
2494
|
+
*/
|
|
2495
|
+
blur() {
|
|
2496
|
+
this.trackElement?.blur();
|
|
2497
|
+
}
|
|
2498
|
+
__renderIcon() {
|
|
2499
|
+
if (this.withIcon) {
|
|
2500
|
+
if (this.value)
|
|
2501
|
+
return b `<wc-icon name="check" class="icon"></wc-icon>`;
|
|
2502
|
+
return b `<wc-icon name="close" class="icon"></wc-icon>`;
|
|
2503
|
+
}
|
|
2504
|
+
return A;
|
|
2505
|
+
}
|
|
2506
|
+
render() {
|
|
2507
|
+
const cssClasses = {
|
|
2508
|
+
switch: true,
|
|
2509
|
+
'state-checked': this.value,
|
|
2510
|
+
'has-focus': this.hasFocus,
|
|
2511
|
+
active: this.isActive,
|
|
2512
|
+
disabled: this.disabled,
|
|
2513
|
+
readonly: this.readonly,
|
|
2514
|
+
required: this.required,
|
|
2515
|
+
rounded: this.rounded,
|
|
2516
|
+
'has-content': this.slotHasContent,
|
|
2517
|
+
};
|
|
2518
|
+
return b `
|
|
2519
|
+
<label class=${e(cssClasses)}>
|
|
2520
|
+
<div
|
|
2521
|
+
class="track"
|
|
2522
|
+
tabindex=${this.tabindex || 0}
|
|
2523
|
+
@keyup=${this.handleKeyUp}
|
|
2524
|
+
@mousedown=${this.mouseDownHandler}
|
|
2525
|
+
@keydown=${this.keyDownHandler}
|
|
2526
|
+
@blur=${this.blurHandler}
|
|
2527
|
+
@focus=${this.focusHandler}
|
|
2528
|
+
role="checkbox"
|
|
2529
|
+
aria-disabled=${this.disabled}
|
|
2530
|
+
aria-required=${this.required}
|
|
2531
|
+
aria-checked=${this.value}
|
|
2532
|
+
${spread(this.configAria)}
|
|
2533
|
+
>
|
|
2534
|
+
<div class="handle">${this.__renderIcon()}</div>
|
|
2535
|
+
</div>
|
|
2536
|
+
|
|
2537
|
+
<input
|
|
2538
|
+
type="checkbox"
|
|
2539
|
+
class="input-native"
|
|
2540
|
+
name=${this.name}
|
|
2541
|
+
.checked=${this.value}
|
|
2542
|
+
aria-hidden="true"
|
|
2543
|
+
?required=${this.required}
|
|
2544
|
+
tabindex="-1"
|
|
2545
|
+
@click=${this.clickHandler}
|
|
2546
|
+
/>
|
|
2547
|
+
|
|
2548
|
+
${this.label
|
|
2549
|
+
? b `<div class="label">${this.label}</div>`
|
|
2550
|
+
: b `<div class="slot-container"><slot></slot></div>`}
|
|
2551
|
+
</label>
|
|
2552
|
+
`;
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
Switch.styles = [css_248z$4];
|
|
2556
|
+
__decorate([
|
|
2557
|
+
n({ type: Boolean })
|
|
2558
|
+
], Switch.prototype, "value", void 0);
|
|
2559
|
+
__decorate([
|
|
2560
|
+
n({ type: String })
|
|
2561
|
+
], Switch.prototype, "name", void 0);
|
|
2562
|
+
__decorate([
|
|
2563
|
+
n({ type: String })
|
|
2564
|
+
], Switch.prototype, "label", void 0);
|
|
2565
|
+
__decorate([
|
|
2566
|
+
n({ type: Boolean })
|
|
2567
|
+
], Switch.prototype, "rounded", void 0);
|
|
2568
|
+
__decorate([
|
|
2569
|
+
n({ type: Boolean, reflect: true })
|
|
2570
|
+
], Switch.prototype, "required", void 0);
|
|
2571
|
+
__decorate([
|
|
2572
|
+
n({ type: Boolean, reflect: true })
|
|
2573
|
+
], Switch.prototype, "readonly", void 0);
|
|
2574
|
+
__decorate([
|
|
2575
|
+
n({ type: Boolean, reflect: true })
|
|
2576
|
+
], Switch.prototype, "disabled", void 0);
|
|
2577
|
+
__decorate([
|
|
2578
|
+
n({ type: Boolean, reflect: true, attribute: 'with-icon' })
|
|
2579
|
+
], Switch.prototype, "withIcon", void 0);
|
|
2580
|
+
__decorate([
|
|
2581
|
+
n({ type: Object })
|
|
2582
|
+
], Switch.prototype, "configAria", void 0);
|
|
2583
|
+
__decorate([
|
|
2584
|
+
r()
|
|
2585
|
+
], Switch.prototype, "hasFocus", void 0);
|
|
2586
|
+
__decorate([
|
|
2587
|
+
r()
|
|
2588
|
+
], Switch.prototype, "isActive", void 0);
|
|
2589
|
+
__decorate([
|
|
2590
|
+
r()
|
|
2591
|
+
], Switch.prototype, "slotHasContent", void 0);
|
|
2592
|
+
__decorate([
|
|
2593
|
+
e$1('.track')
|
|
2594
|
+
], Switch.prototype, "trackElement", void 0);
|
|
2595
|
+
__decorate([
|
|
2596
|
+
e$1('.input-native')
|
|
2597
|
+
], Switch.prototype, "nativeElement", void 0);
|
|
2598
|
+
|
|
2599
|
+
var css_248z$3 = i`* {
|
|
2600
|
+
box-sizing: border-box;
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
.screen-reader-only {
|
|
2604
|
+
display: none !important;
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
[hidden] {
|
|
2608
|
+
display: none !important;
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
:host {
|
|
2612
|
+
display: block;
|
|
2613
|
+
--sidebar-menu-item-height: 3rem;
|
|
2614
|
+
--sidebar-menu-item-icon-size: 1.25rem;
|
|
2615
|
+
--sidebar-menu-item-border-radius: var(--global-shape-corner-full, 9999px);
|
|
2616
|
+
--sidebar-menu-item-label-color: var(--color-on-surface);
|
|
2617
|
+
--sidebar-menu-item-icon-color: var(--color-on-surface-variant);
|
|
2618
|
+
--sidebar-menu-item-selected-background: var(--color-secondary-container);
|
|
2619
|
+
--sidebar-menu-item-selected-label-color: var(--color-on-secondary-container);
|
|
2620
|
+
--sidebar-menu-item-focus-ring-color: var(--color-primary);
|
|
2621
|
+
--sidebar-menu-item-transition-duration: 200ms;
|
|
2622
|
+
--sidebar-menu-item-transition-easing: cubic-bezier(0.4, 0, 0.2, 1);
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
.sidebar-menu-item {
|
|
2626
|
+
position: relative;
|
|
2627
|
+
display: flex;
|
|
2628
|
+
align-items: center;
|
|
2629
|
+
min-height: var(--sidebar-menu-item-height);
|
|
2630
|
+
border-radius: var(--sidebar-menu-item-border-radius);
|
|
2631
|
+
color: var(--_label-color);
|
|
2632
|
+
cursor: pointer;
|
|
2633
|
+
user-select: none;
|
|
2634
|
+
text-decoration: none;
|
|
2635
|
+
outline: none;
|
|
2636
|
+
--_container-color: transparent;
|
|
2637
|
+
--_container-opacity: 1;
|
|
2638
|
+
--_label-color: var(--sidebar-menu-item-label-color);
|
|
2639
|
+
font-family: var(--typography-label-large-font-family) !important;
|
|
2640
|
+
font-size: var(--typography-label-large-font-size) !important;
|
|
2641
|
+
font-weight: var(--typography-label-large-font-weight) !important;
|
|
2642
|
+
line-height: var(--typography-label-large-line-height) !important;
|
|
2643
|
+
letter-spacing: var(--typography-label-large-letter-spacing) !important;
|
|
2644
|
+
}
|
|
2645
|
+
.sidebar-menu-item.selected {
|
|
2646
|
+
--_container-color: var(--sidebar-menu-item-selected-background);
|
|
2647
|
+
--_label-color: var(--sidebar-menu-item-selected-label-color);
|
|
2648
|
+
font-weight: var(--font-weight-bold) !important;
|
|
2649
|
+
}
|
|
2650
|
+
.sidebar-menu-item.disabled {
|
|
2651
|
+
cursor: not-allowed;
|
|
2652
|
+
opacity: 0.6;
|
|
2653
|
+
}
|
|
2654
|
+
.sidebar-menu-item.disabled .ripple {
|
|
2655
|
+
display: none;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
.sidebar-menu-item-content {
|
|
2659
|
+
display: flex;
|
|
2660
|
+
align-items: center;
|
|
2661
|
+
gap: 0.25rem;
|
|
2662
|
+
flex: 1;
|
|
2663
|
+
min-height: var(--sidebar-menu-item-height);
|
|
2664
|
+
padding-inline: 0.75rem;
|
|
2665
|
+
color: inherit;
|
|
2666
|
+
z-index: 1;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
.background {
|
|
2670
|
+
position: absolute;
|
|
2671
|
+
inset: 0;
|
|
2672
|
+
background-color: var(--_container-color);
|
|
2673
|
+
opacity: var(--_container-opacity);
|
|
2674
|
+
border-radius: inherit;
|
|
2675
|
+
pointer-events: none;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
.focus-ring {
|
|
2679
|
+
z-index: 2;
|
|
2680
|
+
--focus-ring-color: var(--sidebar-menu-item-focus-ring-color);
|
|
2681
|
+
--focus-ring-container-shape-start-start: var(
|
|
2682
|
+
--sidebar-menu-item-border-radius
|
|
2683
|
+
);
|
|
2684
|
+
--focus-ring-container-shape-start-end: var(
|
|
2685
|
+
--sidebar-menu-item-border-radius
|
|
2686
|
+
);
|
|
2687
|
+
--focus-ring-container-shape-end-start: var(
|
|
2688
|
+
--sidebar-menu-item-border-radius
|
|
2689
|
+
);
|
|
2690
|
+
--focus-ring-container-shape-end-end: var(--sidebar-menu-item-border-radius);
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
.ripple {
|
|
2694
|
+
--ripple-pressed-color: var(--color-on-surface);
|
|
2695
|
+
border-radius: inherit;
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
.sidebar-menu-item.selected .ripple {
|
|
2699
|
+
--ripple-pressed-color: var(--sidebar-menu-item-selected-color);
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
.sidebar-menu-item-label {
|
|
2703
|
+
flex: 1;
|
|
2704
|
+
overflow: hidden;
|
|
2705
|
+
text-overflow: ellipsis;
|
|
2706
|
+
white-space: nowrap;
|
|
2707
|
+
}`;
|
|
2708
|
+
|
|
2709
|
+
/**
|
|
2710
|
+
* @label Sidebar Menu Item
|
|
2711
|
+
* @tag wc-sidebar-menu-item
|
|
2712
|
+
* @rawTag sidebar-menu-item
|
|
2713
|
+
* @summary A sidebar menu item represents a selectable leaf item in the sidebar navigation tree.
|
|
2714
|
+
*
|
|
2715
|
+
* @example
|
|
2716
|
+
* ```html
|
|
2717
|
+
* <wc-sidebar-menu>
|
|
2718
|
+
* <wc-sidebar-sub-menu label="Parent" expanded>
|
|
2719
|
+
* <wc-sidebar-menu-item label="Child"></wc-sidebar-menu-item>
|
|
2720
|
+
* </wc-sidebar-sub-menu>
|
|
2721
|
+
* </wc-sidebar-menu>
|
|
2722
|
+
* ```
|
|
2723
|
+
* @tags navigation
|
|
2724
|
+
*/
|
|
2725
|
+
class SidebarMenuItem extends i$1 {
|
|
2726
|
+
constructor() {
|
|
2727
|
+
super(...arguments);
|
|
2728
|
+
/**
|
|
2729
|
+
* The value used to identify this item when selected.
|
|
2730
|
+
*/
|
|
2731
|
+
this.value = '';
|
|
2732
|
+
/**
|
|
2733
|
+
* The display label for this item.
|
|
2734
|
+
*/
|
|
2735
|
+
this.label = '';
|
|
2736
|
+
/**
|
|
2737
|
+
* Optional icon name to display before the label.
|
|
2738
|
+
*/
|
|
2739
|
+
this.icon = '';
|
|
2740
|
+
/**
|
|
2741
|
+
* Optional hyperlink to navigate to on click.
|
|
2742
|
+
*/
|
|
2743
|
+
this.href = '';
|
|
2744
|
+
/**
|
|
2745
|
+
* Sets or retrieves the window or frame at which to target content.
|
|
2746
|
+
*/
|
|
2747
|
+
this.target = '_self';
|
|
2748
|
+
/**
|
|
2749
|
+
* If true, the user cannot interact with the item.
|
|
2750
|
+
*/
|
|
2751
|
+
this.disabled = false;
|
|
2752
|
+
/**
|
|
2753
|
+
* Whether the item is currently selected.
|
|
2754
|
+
*/
|
|
2755
|
+
this.selected = false;
|
|
2756
|
+
/**
|
|
2757
|
+
* The nesting depth level (set automatically by the parent sidebar-menu).
|
|
2758
|
+
*/
|
|
2759
|
+
this.level = 0;
|
|
2760
|
+
this._onClick = () => {
|
|
2761
|
+
if (this.disabled)
|
|
2762
|
+
return;
|
|
2763
|
+
this.dispatchEvent(new CustomEvent('sidebar-menu-item:click', {
|
|
2764
|
+
bubbles: true,
|
|
2765
|
+
composed: true,
|
|
2766
|
+
detail: { value: this.value, label: this.label },
|
|
2767
|
+
}));
|
|
2768
|
+
};
|
|
2769
|
+
}
|
|
2770
|
+
focus() {
|
|
2771
|
+
this._nativeElement?.focus();
|
|
2772
|
+
}
|
|
2773
|
+
blur() {
|
|
2774
|
+
this._nativeElement?.blur();
|
|
2775
|
+
}
|
|
2776
|
+
render() {
|
|
2777
|
+
const classes = e({
|
|
2778
|
+
'sidebar-menu-item': true,
|
|
2779
|
+
disabled: this.disabled,
|
|
2780
|
+
selected: this.selected,
|
|
2781
|
+
});
|
|
2782
|
+
const content = b `
|
|
2783
|
+
<wc-focus-ring class="focus-ring" for="item"></wc-focus-ring>
|
|
2784
|
+
<div class="background"></div>
|
|
2785
|
+
<wc-ripple class="ripple"></wc-ripple>
|
|
2786
|
+
<div class="sidebar-menu-item-content">
|
|
2787
|
+
${this.icon ? b `<wc-icon name="${this.icon}"></wc-icon>` : ''}
|
|
2788
|
+
<span class="sidebar-menu-item-label">${this.label}</span>
|
|
2789
|
+
</div>
|
|
2790
|
+
`;
|
|
2791
|
+
if (this.href) {
|
|
2792
|
+
return b `
|
|
2793
|
+
<a
|
|
2794
|
+
id="item"
|
|
2795
|
+
href="${this.href}"
|
|
2796
|
+
target="${this.target}"
|
|
2797
|
+
class="${classes}"
|
|
2798
|
+
?aria-disabled=${this.disabled}
|
|
2799
|
+
tabindex="${this.disabled ? -1 : 0}"
|
|
2800
|
+
@click="${this._onClick}"
|
|
2801
|
+
>
|
|
2802
|
+
${content}
|
|
2803
|
+
</a>
|
|
2804
|
+
`;
|
|
2805
|
+
}
|
|
2806
|
+
return b `
|
|
2807
|
+
<div
|
|
2808
|
+
id="item"
|
|
2809
|
+
class="${classes}"
|
|
2810
|
+
role="treeitem"
|
|
2811
|
+
aria-label="${this.label}"
|
|
2812
|
+
aria-selected="${String(this.selected)}"
|
|
2813
|
+
?aria-disabled=${this.disabled}
|
|
2814
|
+
?disabled=${this.disabled}
|
|
2815
|
+
tabindex="${this.disabled ? -1 : 0}"
|
|
2816
|
+
@click="${this._onClick}"
|
|
2817
|
+
@keydown="${(e) => {
|
|
2818
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
2819
|
+
e.preventDefault();
|
|
2820
|
+
this._onClick();
|
|
2821
|
+
}
|
|
2822
|
+
}}"
|
|
2823
|
+
>
|
|
2824
|
+
${content}
|
|
2825
|
+
</div>
|
|
2826
|
+
`;
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
SidebarMenuItem.styles = [css_248z$3];
|
|
2830
|
+
__decorate([
|
|
2831
|
+
n({ type: String, reflect: true })
|
|
2832
|
+
], SidebarMenuItem.prototype, "value", void 0);
|
|
2833
|
+
__decorate([
|
|
2834
|
+
n({ type: String, reflect: true })
|
|
2835
|
+
], SidebarMenuItem.prototype, "label", void 0);
|
|
2836
|
+
__decorate([
|
|
2837
|
+
n({ type: String, reflect: true })
|
|
2838
|
+
], SidebarMenuItem.prototype, "icon", void 0);
|
|
2839
|
+
__decorate([
|
|
2840
|
+
n({ type: String, reflect: true })
|
|
2841
|
+
], SidebarMenuItem.prototype, "href", void 0);
|
|
2842
|
+
__decorate([
|
|
2843
|
+
n({ type: String, reflect: true })
|
|
2844
|
+
], SidebarMenuItem.prototype, "target", void 0);
|
|
2845
|
+
__decorate([
|
|
2846
|
+
n({ type: Boolean, reflect: true })
|
|
2847
|
+
], SidebarMenuItem.prototype, "disabled", void 0);
|
|
2848
|
+
__decorate([
|
|
2849
|
+
n({ type: Boolean, reflect: true })
|
|
2850
|
+
], SidebarMenuItem.prototype, "selected", void 0);
|
|
2851
|
+
__decorate([
|
|
2852
|
+
n({ type: Number, reflect: true })
|
|
2853
|
+
], SidebarMenuItem.prototype, "level", void 0);
|
|
2854
|
+
__decorate([
|
|
2855
|
+
e$1('.sidebar-menu-item-content')
|
|
2856
|
+
], SidebarMenuItem.prototype, "_nativeElement", void 0);
|
|
2857
|
+
|
|
2858
|
+
var css_248z$2 = i`* {
|
|
2859
|
+
box-sizing: border-box;
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2862
|
+
.screen-reader-only {
|
|
2863
|
+
display: none !important;
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
[hidden] {
|
|
2867
|
+
display: none !important;
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
:host {
|
|
2871
|
+
display: block;
|
|
2872
|
+
--sidebar-menu-item-height: 3rem;
|
|
2873
|
+
--sidebar-menu-item-border-radius: var(--global-shape-corner-full, 9999px);
|
|
2874
|
+
--sidebar-menu-item-label-color: var(--color-on-surface);
|
|
2875
|
+
--sidebar-menu-item-icon-color: var(--color-on-surface-variant);
|
|
2876
|
+
--sidebar-menu-item-selected-background: var(--color-secondary-container);
|
|
2877
|
+
--sidebar-menu-item-selected-color: var(--color-on-secondary-container);
|
|
2878
|
+
--sidebar-menu-item-focus-ring-color: var(--color-primary);
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
.sidebar-sub-menu {
|
|
2882
|
+
display: block;
|
|
2883
|
+
}
|
|
2884
|
+
|
|
2885
|
+
.sidebar-sub-menu-inner {
|
|
2886
|
+
position: relative;
|
|
2887
|
+
display: flex;
|
|
2888
|
+
align-items: center;
|
|
2889
|
+
gap: 0.5rem;
|
|
2890
|
+
min-height: var(--sidebar-menu-item-height);
|
|
2891
|
+
cursor: pointer;
|
|
2892
|
+
border-radius: var(--sidebar-menu-item-border-radius);
|
|
2893
|
+
outline: none;
|
|
2894
|
+
padding-inline-end: 0.75rem;
|
|
2895
|
+
color: var(--_label-color);
|
|
2896
|
+
--_container-color: transparent;
|
|
2897
|
+
--_container-opacity: 1;
|
|
2898
|
+
--_label-color: var(--sidebar-menu-item-label-color);
|
|
2899
|
+
font-family: var(--typography-label-large-font-family) !important;
|
|
2900
|
+
font-size: var(--typography-label-large-font-size) !important;
|
|
2901
|
+
font-weight: var(--typography-label-large-font-weight) !important;
|
|
2902
|
+
line-height: var(--typography-label-large-line-height) !important;
|
|
2903
|
+
letter-spacing: var(--typography-label-large-letter-spacing) !important;
|
|
2904
|
+
}
|
|
2905
|
+
.sidebar-sub-menu-inner.selected {
|
|
2906
|
+
--_container-color: var(--sidebar-menu-item-selected-background);
|
|
2907
|
+
--_label-color: var(--sidebar-menu-item-selected-color);
|
|
2908
|
+
}
|
|
2909
|
+
.sidebar-sub-menu-inner.disabled {
|
|
2910
|
+
cursor: not-allowed;
|
|
2911
|
+
opacity: 0.6;
|
|
2912
|
+
}
|
|
2913
|
+
.sidebar-sub-menu-inner.disabled .ripple {
|
|
2914
|
+
display: none;
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2917
|
+
.sidebar-sub-menu-content {
|
|
2918
|
+
display: flex;
|
|
2919
|
+
align-items: center;
|
|
2920
|
+
gap: 0.25rem;
|
|
2921
|
+
flex: 1;
|
|
2922
|
+
min-height: var(--sidebar-menu-item-height);
|
|
2923
|
+
color: inherit;
|
|
2924
|
+
user-select: none;
|
|
2925
|
+
text-decoration: none;
|
|
2926
|
+
outline: none;
|
|
2927
|
+
padding-inline: 0.75rem;
|
|
2928
|
+
z-index: 1;
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2931
|
+
.background {
|
|
2932
|
+
position: absolute;
|
|
2933
|
+
inset: 0;
|
|
2934
|
+
background-color: var(--_container-color);
|
|
2935
|
+
opacity: var(--_container-opacity);
|
|
2936
|
+
border-radius: inherit;
|
|
2937
|
+
pointer-events: none;
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
.focus-ring {
|
|
2941
|
+
z-index: 2;
|
|
2942
|
+
--focus-ring-color: var(--sidebar-menu-item-focus-ring-color);
|
|
2943
|
+
--focus-ring-container-shape-start-start: var(--sidebar-menu-item-border-radius);
|
|
2944
|
+
--focus-ring-container-shape-start-end: var(--sidebar-menu-item-border-radius);
|
|
2945
|
+
--focus-ring-container-shape-end-start: var(--sidebar-menu-item-border-radius);
|
|
2946
|
+
--focus-ring-container-shape-end-end: var(--sidebar-menu-item-border-radius);
|
|
2947
|
+
}
|
|
2948
|
+
|
|
2949
|
+
.ripple {
|
|
2950
|
+
--ripple-pressed-color: var(--color-on-surface);
|
|
2951
|
+
border-radius: inherit;
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
.sidebar-sub-menu-inner.selected .ripple {
|
|
2955
|
+
--ripple-pressed-color: var(--sidebar-menu-item-selected-color);
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
.sidebar-sub-menu-label {
|
|
2959
|
+
flex: 1;
|
|
2960
|
+
overflow: hidden;
|
|
2961
|
+
text-overflow: ellipsis;
|
|
2962
|
+
white-space: nowrap;
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2965
|
+
.expand-icon {
|
|
2966
|
+
display: flex;
|
|
2967
|
+
align-items: center;
|
|
2968
|
+
justify-content: center;
|
|
2969
|
+
color: var(--sidebar-menu-item-icon-color);
|
|
2970
|
+
flex-shrink: 0;
|
|
2971
|
+
width: var(--sidebar-menu-item-height);
|
|
2972
|
+
height: var(--sidebar-menu-item-height);
|
|
2973
|
+
transition: transform var(--duration-medium1) var(--easing-standard);
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
:host([expanded]) .expand-icon {
|
|
2977
|
+
transform: rotate(180deg);
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
.sidebar-sub-menu-children {
|
|
2981
|
+
display: block;
|
|
2982
|
+
overflow: hidden;
|
|
2983
|
+
margin-left: var(--spacing-200);
|
|
2984
|
+
max-height: 9999px;
|
|
2985
|
+
opacity: 1;
|
|
2986
|
+
transition: max-height var(--duration-medium1) var(--easing-standard), opacity var(--duration-medium1) var(--easing-standard);
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
.sidebar-sub-menu-children.hidden {
|
|
2990
|
+
max-height: 0;
|
|
2991
|
+
opacity: 0;
|
|
2992
|
+
}`;
|
|
2993
|
+
|
|
2994
|
+
/**
|
|
2995
|
+
* @label Sidebar Sub Menu
|
|
2996
|
+
* @tag wc-sidebar-sub-menu
|
|
2997
|
+
* @rawTag sidebar-sub-menu
|
|
2998
|
+
* @summary A sidebar sub menu groups sidebar menu items and handles expand/collapse behavior.
|
|
2999
|
+
*
|
|
3000
|
+
* @example
|
|
3001
|
+
* ```html
|
|
3002
|
+
* <wc-sidebar-sub-menu label="Parent" expanded>
|
|
3003
|
+
* <wc-sidebar-menu-item label="Child"></wc-sidebar-menu-item>
|
|
3004
|
+
* </wc-sidebar-sub-menu>
|
|
3005
|
+
* ```
|
|
3006
|
+
* @tags navigation
|
|
3007
|
+
*/
|
|
3008
|
+
class SidebarSubMenu extends i$1 {
|
|
3009
|
+
constructor() {
|
|
3010
|
+
super(...arguments);
|
|
3011
|
+
this.value = '';
|
|
3012
|
+
this.label = '';
|
|
3013
|
+
this.icon = '';
|
|
3014
|
+
this.disabled = false;
|
|
3015
|
+
this.selected = false;
|
|
3016
|
+
this.expanded = false;
|
|
3017
|
+
this.level = 0;
|
|
3018
|
+
this._updateChildLevels = () => {
|
|
3019
|
+
this._getChildNodes().forEach(child => {
|
|
3020
|
+
if ('level' in child) {
|
|
3021
|
+
// eslint-disable-next-line no-param-reassign
|
|
3022
|
+
child.level = this.level + 1;
|
|
3023
|
+
}
|
|
3024
|
+
});
|
|
3025
|
+
};
|
|
3026
|
+
this._onClick = () => {
|
|
3027
|
+
if (this.disabled)
|
|
3028
|
+
return;
|
|
3029
|
+
if (this._getChildNodes().length > 0) {
|
|
3030
|
+
this.expanded = !this.expanded;
|
|
3031
|
+
}
|
|
3032
|
+
this.dispatchEvent(new CustomEvent('sidebar-menu-item:click', {
|
|
3033
|
+
bubbles: true,
|
|
3034
|
+
composed: true,
|
|
3035
|
+
detail: { value: this.value, label: this.label },
|
|
3036
|
+
}));
|
|
3037
|
+
};
|
|
3038
|
+
}
|
|
3039
|
+
focus() {
|
|
3040
|
+
this._nativeElement?.focus();
|
|
3041
|
+
}
|
|
3042
|
+
blur() {
|
|
3043
|
+
this._nativeElement?.blur();
|
|
3044
|
+
}
|
|
3045
|
+
connectedCallback() {
|
|
3046
|
+
super.connectedCallback();
|
|
3047
|
+
this._updateChildLevels();
|
|
3048
|
+
}
|
|
3049
|
+
updated(changedProps) {
|
|
3050
|
+
super.updated(changedProps);
|
|
3051
|
+
if (changedProps.has('expanded')) {
|
|
3052
|
+
this.setAttribute('aria-expanded', String(this.expanded));
|
|
3053
|
+
if (this.expanded) {
|
|
3054
|
+
this.setAttribute('data-expanded', '');
|
|
3055
|
+
}
|
|
3056
|
+
else {
|
|
3057
|
+
this.removeAttribute('data-expanded');
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
_getChildNodes() {
|
|
3062
|
+
return Array.from(this.children).filter(el => {
|
|
3063
|
+
const tag = el.tagName.toLowerCase();
|
|
3064
|
+
return tag === 'wc-sidebar-menu-item' || tag === 'wc-sidebar-sub-menu';
|
|
3065
|
+
});
|
|
3066
|
+
}
|
|
3067
|
+
render() {
|
|
3068
|
+
const hasChildren = this._getChildNodes().length > 0;
|
|
3069
|
+
const wrapperClasses = e({
|
|
3070
|
+
'sidebar-sub-menu': true,
|
|
3071
|
+
});
|
|
3072
|
+
const innerClasses = e({
|
|
3073
|
+
'sidebar-sub-menu-inner': true,
|
|
3074
|
+
disabled: this.disabled,
|
|
3075
|
+
selected: this.selected,
|
|
3076
|
+
});
|
|
3077
|
+
const inlineStyles = o({
|
|
3078
|
+
paddingLeft: `calc(var(--sidebar-menu-item-height, 2.5rem) * ${this.level})`,
|
|
3079
|
+
});
|
|
3080
|
+
return b `
|
|
3081
|
+
<div class="${wrapperClasses}" style="${inlineStyles}">
|
|
3082
|
+
<div
|
|
3083
|
+
id="item"
|
|
3084
|
+
class="${innerClasses}"
|
|
3085
|
+
role="treeitem"
|
|
3086
|
+
aria-label="${this.label}"
|
|
3087
|
+
aria-selected="${String(this.selected)}"
|
|
3088
|
+
aria-disabled="${this.disabled}"
|
|
3089
|
+
aria-expanded="${this.expanded}"
|
|
3090
|
+
@click="${this._onClick}"
|
|
3091
|
+
@keydown="${(e) => {
|
|
3092
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
3093
|
+
e.preventDefault();
|
|
3094
|
+
this._onClick();
|
|
3095
|
+
}
|
|
3096
|
+
}}"
|
|
3097
|
+
tabindex="${this.disabled ? -1 : 0}"
|
|
3098
|
+
>
|
|
3099
|
+
<wc-focus-ring class="focus-ring" for="item"></wc-focus-ring>
|
|
3100
|
+
<div class="background"></div>
|
|
3101
|
+
<wc-ripple class="ripple"></wc-ripple>
|
|
3102
|
+
<div class="sidebar-sub-menu-content">
|
|
3103
|
+
${this.icon ? b `<wc-icon name="${this.icon}"></wc-icon>` : ''}
|
|
3104
|
+
<span class="sidebar-sub-menu-label">${this.label}</span>
|
|
3105
|
+
</div>
|
|
3106
|
+
${hasChildren
|
|
3107
|
+
? b `
|
|
3108
|
+
<wc-icon class="expand-icon" name="arrow_drop_down" aria-hidden="true"></wc-icon>
|
|
3109
|
+
`
|
|
3110
|
+
: ''}
|
|
3111
|
+
</div>
|
|
3112
|
+
<div class="sidebar-sub-menu-children ${(!hasChildren || !this.expanded) ? 'hidden' : ''}">
|
|
3113
|
+
<slot @slotchange="${this._updateChildLevels}"></slot>
|
|
3114
|
+
</div>
|
|
3115
|
+
</div>
|
|
3116
|
+
`;
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
SidebarSubMenu.styles = [css_248z$2];
|
|
3120
|
+
__decorate([
|
|
3121
|
+
n({ type: String, reflect: true })
|
|
3122
|
+
], SidebarSubMenu.prototype, "value", void 0);
|
|
3123
|
+
__decorate([
|
|
3124
|
+
n({ type: String, reflect: true })
|
|
3125
|
+
], SidebarSubMenu.prototype, "label", void 0);
|
|
3126
|
+
__decorate([
|
|
3127
|
+
n({ type: String, reflect: true })
|
|
3128
|
+
], SidebarSubMenu.prototype, "icon", void 0);
|
|
3129
|
+
__decorate([
|
|
3130
|
+
n({ type: Boolean, reflect: true })
|
|
3131
|
+
], SidebarSubMenu.prototype, "disabled", void 0);
|
|
3132
|
+
__decorate([
|
|
3133
|
+
n({ type: Boolean, reflect: true })
|
|
3134
|
+
], SidebarSubMenu.prototype, "selected", void 0);
|
|
3135
|
+
__decorate([
|
|
3136
|
+
n({ type: Boolean, reflect: true })
|
|
3137
|
+
], SidebarSubMenu.prototype, "expanded", void 0);
|
|
3138
|
+
__decorate([
|
|
3139
|
+
n({ type: Number, reflect: true })
|
|
3140
|
+
], SidebarSubMenu.prototype, "level", void 0);
|
|
3141
|
+
__decorate([
|
|
3142
|
+
e$1('.sidebar-sub-menu-inner')
|
|
3143
|
+
], SidebarSubMenu.prototype, "_nativeElement", void 0);
|
|
3144
|
+
|
|
3145
|
+
var css_248z$1 = i`* {
|
|
3146
|
+
box-sizing: border-box;
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
.screen-reader-only {
|
|
3150
|
+
display: none !important;
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
[hidden] {
|
|
3154
|
+
display: none !important;
|
|
3155
|
+
}
|
|
3156
|
+
|
|
3157
|
+
:host {
|
|
3158
|
+
display: block;
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
.sidebar-menu {
|
|
3162
|
+
display: block;
|
|
3163
|
+
padding: var(--spacing-100, 0.5rem) 0;
|
|
3164
|
+
}`;
|
|
3165
|
+
|
|
3166
|
+
/**
|
|
3167
|
+
* @label Sidebar Menu
|
|
3168
|
+
* @tag wc-sidebar-menu
|
|
3169
|
+
* @rawTag sidebar-menu
|
|
3170
|
+
* @summary A sidebar menu is a hierarchical structure that provides nested levels of navigation. It supports keyboard navigation, single/multi select, and expandable items.
|
|
3171
|
+
*
|
|
3172
|
+
* @example
|
|
3173
|
+
* ```html
|
|
3174
|
+
* <wc-sidebar-menu>
|
|
3175
|
+
* <wc-sidebar-sub-menu label="Parent" expanded>
|
|
3176
|
+
* <wc-sidebar-menu-item label="Child 1"></wc-sidebar-menu-item>
|
|
3177
|
+
* <wc-sidebar-menu-item label="Child 2"></wc-sidebar-menu-item>
|
|
3178
|
+
* </wc-sidebar-sub-menu>
|
|
3179
|
+
* </wc-sidebar-menu>
|
|
3180
|
+
* ```
|
|
3181
|
+
* @tags navigation
|
|
3182
|
+
*/
|
|
3183
|
+
class SidebarMenu extends i$1 {
|
|
3184
|
+
constructor() {
|
|
3185
|
+
super(...arguments);
|
|
3186
|
+
/**
|
|
3187
|
+
* The value of the currently selected item.
|
|
3188
|
+
*/
|
|
3189
|
+
this.selectedItem = '';
|
|
3190
|
+
this._onItemClick = (event) => {
|
|
3191
|
+
const item = event.target;
|
|
3192
|
+
if (item.disabled)
|
|
3193
|
+
return;
|
|
3194
|
+
const value = event.detail?.value ?? item.value ?? item.label;
|
|
3195
|
+
this.selectedItem = value;
|
|
3196
|
+
// Update selected state on all items
|
|
3197
|
+
this._updateSelectedState(value);
|
|
3198
|
+
this.dispatchEvent(new CustomEvent('sidebar-menu:change', {
|
|
3199
|
+
bubbles: true,
|
|
3200
|
+
composed: true,
|
|
3201
|
+
detail: { value, item },
|
|
3202
|
+
}));
|
|
3203
|
+
};
|
|
3204
|
+
this._onKeyDown = (event) => {
|
|
3205
|
+
const allVisible = this._getAllVisibleItems();
|
|
3206
|
+
const currentElement = event.composedPath().find(target => target instanceof SidebarMenuItem || target instanceof SidebarSubMenu);
|
|
3207
|
+
if (!currentElement) {
|
|
3208
|
+
return;
|
|
3209
|
+
}
|
|
3210
|
+
if (!allVisible.includes(currentElement)) {
|
|
3211
|
+
return;
|
|
3212
|
+
}
|
|
3213
|
+
const currentIndex = allVisible.indexOf(currentElement);
|
|
3214
|
+
if (event.key === 'ArrowDown') {
|
|
3215
|
+
event.preventDefault();
|
|
3216
|
+
const nextIndex = (currentIndex + 1) % allVisible.length;
|
|
3217
|
+
allVisible[nextIndex].focus();
|
|
3218
|
+
}
|
|
3219
|
+
else if (event.key === 'ArrowUp') {
|
|
3220
|
+
event.preventDefault();
|
|
3221
|
+
const prevIndex = currentIndex === 0 ? allVisible.length - 1 : currentIndex - 1;
|
|
3222
|
+
allVisible[prevIndex].focus();
|
|
3223
|
+
}
|
|
3224
|
+
else if (event.key === 'Enter' || event.key === ' ') {
|
|
3225
|
+
event.preventDefault();
|
|
3226
|
+
currentElement.click();
|
|
3227
|
+
}
|
|
3228
|
+
else if (event.key === 'ArrowRight') {
|
|
3229
|
+
event.preventDefault();
|
|
3230
|
+
if (currentElement instanceof SidebarSubMenu && !currentElement.expanded) {
|
|
3231
|
+
currentElement.expanded = true;
|
|
3232
|
+
}
|
|
3233
|
+
else if (currentElement instanceof SidebarSubMenu) {
|
|
3234
|
+
const children = this._getChildNodes(currentElement);
|
|
3235
|
+
if (children.length > 0) {
|
|
3236
|
+
children[0].focus();
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
else if (event.key === 'ArrowLeft') {
|
|
3241
|
+
event.preventDefault();
|
|
3242
|
+
if (currentElement instanceof SidebarSubMenu && currentElement.expanded) {
|
|
3243
|
+
currentElement.expanded = false;
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
};
|
|
3247
|
+
}
|
|
3248
|
+
connectedCallback() {
|
|
3249
|
+
super.connectedCallback();
|
|
3250
|
+
this.addEventListener('sidebar-menu-item:click', this._onItemClick);
|
|
3251
|
+
this.addEventListener('keydown', this._onKeyDown);
|
|
3252
|
+
this.setAttribute('role', 'tree');
|
|
3253
|
+
}
|
|
3254
|
+
updated(changedProps) {
|
|
3255
|
+
super.updated(changedProps);
|
|
3256
|
+
if (changedProps.has('selectedItem')) {
|
|
3257
|
+
this._syncSelectedStateFromProperty();
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
disconnectedCallback() {
|
|
3261
|
+
super.disconnectedCallback();
|
|
3262
|
+
this.removeEventListener('sidebar-menu-item:click', this._onItemClick);
|
|
3263
|
+
this.removeEventListener('keydown', this._onKeyDown);
|
|
3264
|
+
}
|
|
3265
|
+
_isSidebarNode(element) {
|
|
3266
|
+
const tag = element.tagName.toLowerCase();
|
|
3267
|
+
return tag === 'wc-sidebar-menu-item' || tag === 'wc-sidebar-sub-menu';
|
|
3268
|
+
}
|
|
3269
|
+
_getTopLevelItems() {
|
|
3270
|
+
return Array.from(this.children).filter(el => this._isSidebarNode(el));
|
|
3271
|
+
}
|
|
3272
|
+
_getChildNodes(item) {
|
|
3273
|
+
return Array.from(item.children).filter(child => this._isSidebarNode(child));
|
|
3274
|
+
}
|
|
3275
|
+
_getAllVisibleItems() {
|
|
3276
|
+
const result = [];
|
|
3277
|
+
const collect = (items) => {
|
|
3278
|
+
items.forEach(item => {
|
|
3279
|
+
result.push(item);
|
|
3280
|
+
if (item instanceof SidebarSubMenu && item.expanded) {
|
|
3281
|
+
collect(this._getChildNodes(item));
|
|
3282
|
+
}
|
|
3283
|
+
});
|
|
3284
|
+
};
|
|
3285
|
+
collect(this._getTopLevelItems());
|
|
3286
|
+
return result;
|
|
3287
|
+
}
|
|
3288
|
+
_updateSelectedState(selectedValue) {
|
|
3289
|
+
const allItems = this._collectAllItems(this._getTopLevelItems());
|
|
3290
|
+
allItems.forEach(item => {
|
|
3291
|
+
const itemValue = item.value || item.label;
|
|
3292
|
+
// eslint-disable-next-line no-param-reassign
|
|
3293
|
+
item.selected = itemValue === selectedValue;
|
|
3294
|
+
});
|
|
3295
|
+
}
|
|
3296
|
+
_collectAllItems(items) {
|
|
3297
|
+
const result = [];
|
|
3298
|
+
items.forEach(item => {
|
|
3299
|
+
result.push(item);
|
|
3300
|
+
if (item instanceof SidebarSubMenu) {
|
|
3301
|
+
result.push(...this._collectAllItems(this._getChildNodes(item)));
|
|
3302
|
+
}
|
|
3303
|
+
});
|
|
3304
|
+
return result;
|
|
3305
|
+
}
|
|
3306
|
+
_syncSelectedStateFromProperty() {
|
|
3307
|
+
const allItems = this._collectAllItems(this._getTopLevelItems());
|
|
3308
|
+
allItems.forEach(item => {
|
|
3309
|
+
const itemValue = item.value || item.label;
|
|
3310
|
+
item.selected = itemValue === this.selectedItem;
|
|
3311
|
+
});
|
|
3312
|
+
}
|
|
3313
|
+
render() {
|
|
3314
|
+
return b ` <div class="sidebar-menu"><slot></slot></div> `;
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
SidebarMenu.styles = [css_248z$1];
|
|
3318
|
+
__decorate([
|
|
3319
|
+
n({ type: String, attribute: 'selected-item', reflect: true })
|
|
3320
|
+
], SidebarMenu.prototype, "selectedItem", void 0);
|
|
3321
|
+
|
|
3322
|
+
var css_248z = i`@charset "UTF-8";
|
|
3323
|
+
* {
|
|
3324
|
+
box-sizing: border-box;
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
.screen-reader-only {
|
|
3328
|
+
display: none !important;
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
[hidden] {
|
|
3332
|
+
display: none !important;
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
:host {
|
|
3336
|
+
display: block;
|
|
3337
|
+
width: 100%;
|
|
3338
|
+
}
|
|
3339
|
+
|
|
3340
|
+
/* Make the field wrapper behave as a select (pointer cursor) */
|
|
3341
|
+
.select-field {
|
|
3342
|
+
cursor: pointer;
|
|
3343
|
+
}
|
|
3344
|
+
|
|
3345
|
+
.select-trigger {
|
|
3346
|
+
flex: 1;
|
|
3347
|
+
display: flex;
|
|
3348
|
+
align-items: center;
|
|
3349
|
+
min-height: 1.5rem;
|
|
3350
|
+
outline: none;
|
|
3351
|
+
cursor: pointer;
|
|
3352
|
+
user-select: none;
|
|
3353
|
+
overflow: hidden;
|
|
3354
|
+
min-width: 0;
|
|
3355
|
+
}
|
|
3356
|
+
.select-trigger:focus-visible {
|
|
3357
|
+
outline: none;
|
|
3358
|
+
}
|
|
3359
|
+
|
|
3360
|
+
.display-value {
|
|
3361
|
+
font-family: var(--typography-body-large-font-family) !important;
|
|
3362
|
+
font-size: var(--typography-body-large-font-size) !important;
|
|
3363
|
+
font-weight: var(--typography-body-large-font-weight) !important;
|
|
3364
|
+
line-height: var(--typography-body-large-line-height) !important;
|
|
3365
|
+
letter-spacing: var(--typography-body-large-letter-spacing) !important;
|
|
3366
|
+
color: var(--color-on-surface);
|
|
3367
|
+
overflow: hidden;
|
|
3368
|
+
text-overflow: ellipsis;
|
|
3369
|
+
white-space: nowrap;
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3372
|
+
.placeholder {
|
|
3373
|
+
font-family: var(--typography-body-large-font-family) !important;
|
|
3374
|
+
font-size: var(--typography-body-large-font-size) !important;
|
|
3375
|
+
font-weight: var(--typography-body-large-font-weight) !important;
|
|
3376
|
+
line-height: var(--typography-body-large-line-height) !important;
|
|
3377
|
+
letter-spacing: var(--typography-body-large-letter-spacing) !important;
|
|
3378
|
+
color: var(--color-on-surface-variant);
|
|
3379
|
+
overflow: hidden;
|
|
3380
|
+
text-overflow: ellipsis;
|
|
3381
|
+
white-space: nowrap;
|
|
3382
|
+
}
|
|
3383
|
+
|
|
3384
|
+
/* Typeahead search input */
|
|
3385
|
+
.search-input {
|
|
3386
|
+
flex: 1;
|
|
3387
|
+
width: 100%;
|
|
3388
|
+
border: none;
|
|
3389
|
+
outline: none;
|
|
3390
|
+
background: transparent;
|
|
3391
|
+
margin: 0;
|
|
3392
|
+
padding: 0;
|
|
3393
|
+
font-family: var(--typography-body-large-font-family) !important;
|
|
3394
|
+
font-size: var(--typography-body-large-font-size) !important;
|
|
3395
|
+
font-weight: var(--typography-body-large-font-weight) !important;
|
|
3396
|
+
line-height: var(--typography-body-large-line-height) !important;
|
|
3397
|
+
letter-spacing: var(--typography-body-large-letter-spacing) !important;
|
|
3398
|
+
color: var(--color-on-surface);
|
|
3399
|
+
cursor: pointer;
|
|
3400
|
+
}
|
|
3401
|
+
.search-input::placeholder {
|
|
3402
|
+
color: var(--color-on-surface-variant);
|
|
3403
|
+
}
|
|
3404
|
+
.search-input:focus {
|
|
3405
|
+
cursor: text;
|
|
3406
|
+
}
|
|
3407
|
+
|
|
3408
|
+
/* Field end slot wrapper */
|
|
3409
|
+
.field-end-wrapper {
|
|
3410
|
+
display: flex;
|
|
3411
|
+
align-items: center;
|
|
3412
|
+
gap: var(--spacing-050);
|
|
3413
|
+
}
|
|
3414
|
+
|
|
3415
|
+
.select-empty-state {
|
|
3416
|
+
display: block;
|
|
3417
|
+
inline-size: min(22rem, 100%);
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
/* Dropdown chevron icon */
|
|
3421
|
+
.dropdown-icon {
|
|
3422
|
+
--icon-size: 1.5rem;
|
|
3423
|
+
--icon-color: var(--color-on-surface-variant);
|
|
3424
|
+
transition: transform 200ms ease;
|
|
3425
|
+
flex-shrink: 0;
|
|
3426
|
+
}
|
|
3427
|
+
.dropdown-icon.dropdown-icon--open {
|
|
3428
|
+
transform: rotate(180deg);
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3431
|
+
/* Clear button */
|
|
3432
|
+
.clear-btn {
|
|
3433
|
+
--button-container-shape: var(--shape-corner-full);
|
|
3434
|
+
}
|
|
3435
|
+
|
|
3436
|
+
/* Multi-select chips area — single scrollable row, no vertical growth */
|
|
3437
|
+
.chips-container {
|
|
3438
|
+
display: flex;
|
|
3439
|
+
align-items: center;
|
|
3440
|
+
flex: 1;
|
|
3441
|
+
padding-block: 0.5rem;
|
|
3442
|
+
}
|
|
3443
|
+
|
|
3444
|
+
/* Disabled state */
|
|
3445
|
+
:host([disabled]) .select-trigger,
|
|
3446
|
+
:host([disabled]) .select-field {
|
|
3447
|
+
cursor: not-allowed;
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
/* Readonly state */
|
|
3451
|
+
:host([readonly]) .select-trigger,
|
|
3452
|
+
:host([readonly]) .select-field {
|
|
3453
|
+
cursor: default;
|
|
3454
|
+
}`;
|
|
3455
|
+
|
|
3456
|
+
/**
|
|
3457
|
+
* @label Select
|
|
3458
|
+
* @tag wc-select
|
|
3459
|
+
* @rawTag select
|
|
3460
|
+
*
|
|
3461
|
+
* @summary A dropdown select component supporting single and multi-select with optional typeahead search.
|
|
3462
|
+
* @overview
|
|
3463
|
+
* Select builds on wc-field and wc-menu to provide a fully-featured dropdown picker.
|
|
3464
|
+
*
|
|
3465
|
+
* - Single and multi-select modes
|
|
3466
|
+
* - Client-side typeahead with `search="contains"`
|
|
3467
|
+
* - Server-side typeahead with `search="managed"`
|
|
3468
|
+
* - Multi-select chips display
|
|
3469
|
+
*
|
|
3470
|
+
* @example
|
|
3471
|
+
* ```html
|
|
3472
|
+
* <wc-select label="Fruit" placeholder="Pick a fruit...">
|
|
3473
|
+
* <wc-option value="apple">Apple</wc-option>
|
|
3474
|
+
* <wc-option value="banana">Banana</wc-option>
|
|
3475
|
+
* </wc-select>
|
|
3476
|
+
* ```
|
|
3477
|
+
* @tags form
|
|
3478
|
+
*/
|
|
3479
|
+
class Select extends BaseInput {
|
|
3480
|
+
constructor() {
|
|
3481
|
+
super(...arguments);
|
|
3482
|
+
this._menuId = `wc-select-menu-${Math.random().toString(36).slice(2, 9)}`;
|
|
3483
|
+
/**
|
|
3484
|
+
* Array of options to display in the dropdown.
|
|
3485
|
+
* Setting this property creates matching `<wc-option>` children automatically.
|
|
3486
|
+
*/
|
|
3487
|
+
this.options = [];
|
|
3488
|
+
/**
|
|
3489
|
+
* The selected value. For multi-select, a comma-separated list of values.
|
|
3490
|
+
*/
|
|
3491
|
+
this.value = '';
|
|
3492
|
+
/**
|
|
3493
|
+
* Enable multi-select mode.
|
|
3494
|
+
*/
|
|
3495
|
+
this.multiple = false;
|
|
3496
|
+
/**
|
|
3497
|
+
* Enable typeahead search.
|
|
3498
|
+
* - `'contains'`: filters options client-side.
|
|
3499
|
+
* - `'managed'`: emits a `select-search` event for server-controlled filtering.
|
|
3500
|
+
*/
|
|
3501
|
+
this.search = '';
|
|
3502
|
+
/**
|
|
3503
|
+
* Placeholder text shown when no value is selected.
|
|
3504
|
+
*/
|
|
3505
|
+
this.placeholder = '';
|
|
3506
|
+
/**
|
|
3507
|
+
* Label displayed above the field.
|
|
3508
|
+
*/
|
|
3509
|
+
this.label = '';
|
|
3510
|
+
/**
|
|
3511
|
+
* Visual variant of the field.
|
|
3512
|
+
*/
|
|
3513
|
+
this.variant = 'default';
|
|
3514
|
+
/**
|
|
3515
|
+
* Helper text displayed below the field.
|
|
3516
|
+
*/
|
|
3517
|
+
this.helperText = '';
|
|
3518
|
+
this.error = false;
|
|
3519
|
+
this.errorText = '';
|
|
3520
|
+
this.warning = false;
|
|
3521
|
+
this.warningText = '';
|
|
3522
|
+
this._open = false;
|
|
3523
|
+
this._focused = false;
|
|
3524
|
+
this._searchQuery = '';
|
|
3525
|
+
/** True when all options are filtered out by the current search query. */
|
|
3526
|
+
this._noOptionsVisible = false;
|
|
3527
|
+
}
|
|
3528
|
+
get _menu() {
|
|
3529
|
+
return this.renderRoot?.querySelector('wc-menu') ?? null;
|
|
3530
|
+
}
|
|
3531
|
+
focus() {
|
|
3532
|
+
this._triggerEl?.focus();
|
|
3533
|
+
}
|
|
3534
|
+
blur() {
|
|
3535
|
+
this._triggerEl?.blur();
|
|
3536
|
+
}
|
|
3537
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
|
3538
|
+
updated(changedProperties) {
|
|
3539
|
+
if (changedProperties.has('options')) {
|
|
3540
|
+
this._syncProgrammaticOptions();
|
|
3541
|
+
}
|
|
3542
|
+
this._syncOptionStates();
|
|
3543
|
+
}
|
|
3544
|
+
// ── Programmatic options ───────────────────────────────────────────────────
|
|
3545
|
+
/**
|
|
3546
|
+
* Reconciles the `options` property with auto-generated `<wc-option>` light-DOM
|
|
3547
|
+
* children (marked `data-generated`). Declarative children placed by the
|
|
3548
|
+
* consumer are left untouched.
|
|
3549
|
+
*/
|
|
3550
|
+
_syncProgrammaticOptions() {
|
|
3551
|
+
this.querySelectorAll('wc-option[data-generated]').forEach(el => el.remove());
|
|
3552
|
+
for (const opt of this.options) {
|
|
3553
|
+
const el = new SelectOptionElement();
|
|
3554
|
+
el.value = opt.value;
|
|
3555
|
+
if (opt.icon)
|
|
3556
|
+
el.icon = opt.icon;
|
|
3557
|
+
el.textContent = opt.label || (opt.value === '' ? 'None' : '');
|
|
3558
|
+
el.dataset.generated = '';
|
|
3559
|
+
this.appendChild(el);
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
// ── Option state sync ──────────────────────────────────────────────────────
|
|
3563
|
+
/**
|
|
3564
|
+
* Pushes `selected`, `keepOpen`, and `filtered` state onto every `<wc-option>`
|
|
3565
|
+
* child element so each one can render itself correctly.
|
|
3566
|
+
*/
|
|
3567
|
+
_syncOptionStates() {
|
|
3568
|
+
const optEls = Array.from(this.querySelectorAll('wc-option'));
|
|
3569
|
+
let visibleCount = 0;
|
|
3570
|
+
for (const opt of optEls) {
|
|
3571
|
+
opt.selected = this._isSelected(opt.value);
|
|
3572
|
+
opt.keepOpen = this.multiple;
|
|
3573
|
+
if (this.search && this.search !== 'managed' && this._searchQuery) {
|
|
3574
|
+
const q = this._searchQuery.toLowerCase();
|
|
3575
|
+
const label = opt.textContent?.trim() ?? '';
|
|
3576
|
+
opt.filtered = !label.toLowerCase().includes(q);
|
|
3577
|
+
if (!opt.filtered)
|
|
3578
|
+
visibleCount += 1;
|
|
3579
|
+
}
|
|
3580
|
+
else {
|
|
3581
|
+
opt.filtered = false;
|
|
3582
|
+
visibleCount += 1;
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
this._noOptionsVisible = visibleCount === 0;
|
|
3586
|
+
}
|
|
3587
|
+
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
3588
|
+
get _selectedValues() {
|
|
3589
|
+
if (!this.value)
|
|
3590
|
+
return [];
|
|
3591
|
+
return this.value
|
|
3592
|
+
.split(',')
|
|
3593
|
+
.map(v => v.trim())
|
|
3594
|
+
.filter(Boolean);
|
|
3595
|
+
}
|
|
3596
|
+
_isSelected(value) {
|
|
3597
|
+
if (!this.multiple) {
|
|
3598
|
+
return this.value === value;
|
|
3599
|
+
}
|
|
3600
|
+
return this._selectedValues.includes(value);
|
|
3601
|
+
}
|
|
3602
|
+
/** Returns the display label for a given option value. */
|
|
3603
|
+
_getLabelForValue(val) {
|
|
3604
|
+
for (const opt of this.querySelectorAll('wc-option')) {
|
|
3605
|
+
if (opt.value === val) {
|
|
3606
|
+
const label = opt.textContent?.trim();
|
|
3607
|
+
if (label)
|
|
3608
|
+
return label;
|
|
3609
|
+
return val === '' ? 'None' : val;
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
// Fallback to options array (before wc-option children are created)
|
|
3613
|
+
const programmaticLabel = this.options.find(o => o.value === val)?.label;
|
|
3614
|
+
if (programmaticLabel)
|
|
3615
|
+
return programmaticLabel;
|
|
3616
|
+
return val === '' ? 'None' : val;
|
|
3617
|
+
}
|
|
3618
|
+
get _displayLabel() {
|
|
3619
|
+
if (!this.value)
|
|
3620
|
+
return '';
|
|
3621
|
+
const firstValue = this._selectedValues[0];
|
|
3622
|
+
if (!firstValue)
|
|
3623
|
+
return '';
|
|
3624
|
+
return this._getLabelForValue(firstValue);
|
|
3625
|
+
}
|
|
3626
|
+
get _isPopulated() {
|
|
3627
|
+
return !!this.value;
|
|
3628
|
+
}
|
|
3629
|
+
// ── Menu open/close ────────────────────────────────────────────────────────
|
|
3630
|
+
_openMenu() {
|
|
3631
|
+
if (this.disabled || this.readonly)
|
|
3632
|
+
return;
|
|
3633
|
+
this._open = true;
|
|
3634
|
+
this._focused = true;
|
|
3635
|
+
this._triggerEl?.focus();
|
|
3636
|
+
const menu = this._menu;
|
|
3637
|
+
if (menu && this._triggerEl) {
|
|
3638
|
+
menu.anchorElement = this._triggerEl;
|
|
3639
|
+
const triggerWidth = this._triggerEl.getBoundingClientRect().width;
|
|
3640
|
+
if (triggerWidth < 240) {
|
|
3641
|
+
menu.style.setProperty('--menu-width', '240px');
|
|
3642
|
+
}
|
|
3643
|
+
else {
|
|
3644
|
+
menu.style.setProperty('--menu-width', `${Math.ceil(triggerWidth)}px`);
|
|
3645
|
+
}
|
|
3646
|
+
menu.show();
|
|
3647
|
+
}
|
|
3648
|
+
if (this.search) {
|
|
3649
|
+
this._searchQuery = '';
|
|
3650
|
+
// Use rAF so that the search input receives focus *after* wc-menu has
|
|
3651
|
+
// finished showing and potentially focused a menu item.
|
|
3652
|
+
this.updateComplete.then(() => {
|
|
3653
|
+
requestAnimationFrame(() => {
|
|
3654
|
+
this._searchInputEl?.focus();
|
|
3655
|
+
});
|
|
3656
|
+
});
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
3659
|
+
_closeMenu() {
|
|
3660
|
+
if (!this._open)
|
|
3661
|
+
return;
|
|
3662
|
+
this._open = false;
|
|
3663
|
+
this._focused = false;
|
|
3664
|
+
this._searchQuery = '';
|
|
3665
|
+
this._menu?.close();
|
|
3666
|
+
}
|
|
3667
|
+
// ── Event handlers ─────────────────────────────────────────────────────────
|
|
3668
|
+
_handleTriggerClick(event) {
|
|
3669
|
+
event.stopPropagation();
|
|
3670
|
+
// Ignore clicks that originated inside the search input — those should not
|
|
3671
|
+
// toggle the menu (the input needs to stay open so the user can type).
|
|
3672
|
+
if (event.target instanceof HTMLInputElement) {
|
|
3673
|
+
return;
|
|
3674
|
+
}
|
|
3675
|
+
if (this._open) {
|
|
3676
|
+
this._closeMenu();
|
|
3677
|
+
}
|
|
3678
|
+
else {
|
|
3679
|
+
this._openMenu();
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
_handleFieldClick(event) {
|
|
3683
|
+
const eventPath = event.composedPath();
|
|
3684
|
+
if (eventPath.includes(this._triggerEl) ||
|
|
3685
|
+
eventPath.some(target => target instanceof HTMLInputElement ||
|
|
3686
|
+
(target instanceof HTMLElement &&
|
|
3687
|
+
(target.closest('.clear-btn') != null ||
|
|
3688
|
+
target.matches('wc-icon-button'))))) {
|
|
3689
|
+
return;
|
|
3690
|
+
}
|
|
3691
|
+
if (this._open) {
|
|
3692
|
+
this._closeMenu();
|
|
3693
|
+
}
|
|
3694
|
+
else {
|
|
3695
|
+
this._openMenu();
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3698
|
+
_handleTriggerKeyDown(event) {
|
|
3699
|
+
// When the typeahead search input is active, let the input handle its own
|
|
3700
|
+
// keys (Space, Enter, etc.). Only intercept Escape to close the menu.
|
|
3701
|
+
if (event.target instanceof HTMLInputElement) {
|
|
3702
|
+
if (event.key === 'Escape') {
|
|
3703
|
+
event.preventDefault();
|
|
3704
|
+
this._closeMenu();
|
|
3705
|
+
}
|
|
3706
|
+
return;
|
|
3707
|
+
}
|
|
3708
|
+
switch (event.key) {
|
|
3709
|
+
case 'Enter':
|
|
3710
|
+
case ' ':
|
|
3711
|
+
case 'ArrowDown':
|
|
3712
|
+
event.preventDefault();
|
|
3713
|
+
if (!this._open)
|
|
3714
|
+
this._openMenu();
|
|
3715
|
+
break;
|
|
3716
|
+
case 'Escape':
|
|
3717
|
+
if (this._open) {
|
|
3718
|
+
event.preventDefault();
|
|
3719
|
+
this._closeMenu();
|
|
3720
|
+
}
|
|
3721
|
+
break;
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
_handleMenuClosed() {
|
|
3725
|
+
this._open = false;
|
|
3726
|
+
this._focused = false;
|
|
3727
|
+
this._searchQuery = '';
|
|
3728
|
+
}
|
|
3729
|
+
_handleMenuItemActivate(event) {
|
|
3730
|
+
const item = event.detail?.item;
|
|
3731
|
+
if (!item)
|
|
3732
|
+
return;
|
|
3733
|
+
const val = item.value;
|
|
3734
|
+
if (val === undefined)
|
|
3735
|
+
return;
|
|
3736
|
+
if (this.multiple) {
|
|
3737
|
+
if (val === '')
|
|
3738
|
+
return;
|
|
3739
|
+
const values = this._selectedValues;
|
|
3740
|
+
const idx = values.indexOf(val);
|
|
3741
|
+
if (idx >= 0) {
|
|
3742
|
+
values.splice(idx, 1);
|
|
3743
|
+
}
|
|
3744
|
+
else {
|
|
3745
|
+
values.push(val);
|
|
3746
|
+
}
|
|
3747
|
+
this.value = values.join(',');
|
|
3748
|
+
}
|
|
3749
|
+
else {
|
|
3750
|
+
this.value = val;
|
|
3751
|
+
this._closeMenu();
|
|
3752
|
+
}
|
|
3753
|
+
this._dispatchChange();
|
|
3754
|
+
}
|
|
3755
|
+
_dispatchChange() {
|
|
3756
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
3757
|
+
detail: { value: this.value },
|
|
3758
|
+
bubbles: true,
|
|
3759
|
+
composed: true,
|
|
3760
|
+
}));
|
|
3761
|
+
}
|
|
3762
|
+
_handleSearchInput(event) {
|
|
3763
|
+
this._searchQuery = event.target.value;
|
|
3764
|
+
if (this.search === 'managed') {
|
|
3765
|
+
this.dispatchEvent(new CustomEvent('select-search', {
|
|
3766
|
+
detail: { value: this._searchQuery },
|
|
3767
|
+
bubbles: true,
|
|
3768
|
+
composed: true,
|
|
3769
|
+
}));
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
_handleChipDismiss(event, chipValue) {
|
|
3773
|
+
event.stopPropagation();
|
|
3774
|
+
const values = this._selectedValues.filter(v => v !== chipValue);
|
|
3775
|
+
this.value = values.join(',');
|
|
3776
|
+
this._dispatchChange();
|
|
3777
|
+
}
|
|
3778
|
+
_renderEmptyState() {
|
|
3779
|
+
const hasSearchQuery = this._searchQuery.trim().length > 0;
|
|
3780
|
+
return b `
|
|
3781
|
+
<wc-empty-state
|
|
3782
|
+
class="select-empty-state content-center"
|
|
3783
|
+
illustration="no-document"
|
|
3784
|
+
headline=${hasSearchQuery ? 'No results found' : 'No options available'}
|
|
3785
|
+
description=${hasSearchQuery
|
|
3786
|
+
? 'Try a different search term.'
|
|
3787
|
+
: 'There is nothing to select right now.'}
|
|
3788
|
+
></wc-empty-state>
|
|
3789
|
+
`;
|
|
3790
|
+
}
|
|
3791
|
+
// ── Render helpers ─────────────────────────────────────────────────────────
|
|
3792
|
+
_renderTriggerContent() {
|
|
3793
|
+
// Typeahead: when open, show a text input for filtering
|
|
3794
|
+
if (this.search && this._open) {
|
|
3795
|
+
return b `<input
|
|
3796
|
+
class="search-input"
|
|
3797
|
+
.value=${this._searchQuery}
|
|
3798
|
+
placeholder=${this._displayLabel || this.placeholder}
|
|
3799
|
+
@input=${this._handleSearchInput}
|
|
3800
|
+
/>`;
|
|
3801
|
+
}
|
|
3802
|
+
// Multi-select: show chips for selected items
|
|
3803
|
+
if (this.multiple && this._selectedValues.length > 0) {
|
|
3804
|
+
return b `<div class="chips-container">
|
|
3805
|
+
<wc-chip-set>
|
|
3806
|
+
${this._selectedValues.map(val => b `
|
|
3807
|
+
<wc-chip
|
|
3808
|
+
dismissible
|
|
3809
|
+
value=${val}
|
|
3810
|
+
@tag--dismiss=${(e) => this._handleChipDismiss(e, val)}
|
|
3811
|
+
>${this._getLabelForValue(val)}</wc-chip
|
|
3812
|
+
>
|
|
3813
|
+
`)}
|
|
3814
|
+
</wc-chip-set>
|
|
3815
|
+
</div>`;
|
|
3816
|
+
}
|
|
3817
|
+
// Single select: show selected label or placeholder
|
|
3818
|
+
const label = this._displayLabel;
|
|
3819
|
+
if (!label) {
|
|
3820
|
+
return b `<span class="placeholder">${this.placeholder}</span>`;
|
|
3821
|
+
}
|
|
3822
|
+
return b `<span class="display-value">${label}</span>`;
|
|
3823
|
+
}
|
|
3824
|
+
_renderFieldEnd() {
|
|
3825
|
+
return b `
|
|
3826
|
+
<wc-icon
|
|
3827
|
+
class=${e({
|
|
3828
|
+
'dropdown-icon': true,
|
|
3829
|
+
'dropdown-icon--open': this._open,
|
|
3830
|
+
})}
|
|
3831
|
+
name="arrow_drop_down"
|
|
3832
|
+
></wc-icon>
|
|
3833
|
+
`;
|
|
3834
|
+
}
|
|
3835
|
+
render() {
|
|
3836
|
+
return b `
|
|
3837
|
+
<wc-field
|
|
3838
|
+
label=${this.label}
|
|
3839
|
+
?required=${this.required}
|
|
3840
|
+
?disabled=${this.disabled}
|
|
3841
|
+
?readonly=${this.readonly}
|
|
3842
|
+
?skeleton=${this.skeleton}
|
|
3843
|
+
helper-text=${this.helperText}
|
|
3844
|
+
?error=${this.error}
|
|
3845
|
+
error-text=${this.errorText}
|
|
3846
|
+
?warning=${this.warning}
|
|
3847
|
+
warning-text=${this.warningText}
|
|
3848
|
+
variant=${this.variant}
|
|
3849
|
+
?populated=${this._isPopulated || this._open}
|
|
3850
|
+
?focused=${this._focused}
|
|
3851
|
+
.host=${this}
|
|
3852
|
+
class="select-field"
|
|
3853
|
+
@click=${this._handleFieldClick}
|
|
3854
|
+
>
|
|
3855
|
+
<div
|
|
3856
|
+
class="select-trigger"
|
|
3857
|
+
tabindex=${this.disabled ? -1 : 0}
|
|
3858
|
+
role="combobox"
|
|
3859
|
+
aria-label=${this.label || this.placeholder || 'Select option'}
|
|
3860
|
+
aria-controls=${this._menuId}
|
|
3861
|
+
aria-expanded=${String(this._open)}
|
|
3862
|
+
aria-haspopup="listbox"
|
|
3863
|
+
@click=${this._handleTriggerClick}
|
|
3864
|
+
@keydown=${this._handleTriggerKeyDown}
|
|
3865
|
+
>
|
|
3866
|
+
${this._renderTriggerContent()}
|
|
3867
|
+
</div>
|
|
3868
|
+
|
|
3869
|
+
<div slot="field-end" class="field-end-wrapper">
|
|
3870
|
+
${this._renderFieldEnd()}
|
|
3871
|
+
</div>
|
|
3872
|
+
</wc-field>
|
|
3873
|
+
|
|
3874
|
+
<wc-menu
|
|
3875
|
+
id=${this._menuId}
|
|
3876
|
+
placement="bottom-start"
|
|
3877
|
+
aria-label=${this.label || 'Options'}
|
|
3878
|
+
@closed=${this._handleMenuClosed}
|
|
3879
|
+
@menu-item-activate=${(e) => this._handleMenuItemActivate(e)}
|
|
3880
|
+
>
|
|
3881
|
+
<slot></slot>
|
|
3882
|
+
${this._noOptionsVisible ? this._renderEmptyState() : A}
|
|
3883
|
+
</wc-menu>
|
|
3884
|
+
`;
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3887
|
+
Select.styles = [css_248z];
|
|
3888
|
+
__decorate([
|
|
3889
|
+
n({ type: Array })
|
|
3890
|
+
], Select.prototype, "options", void 0);
|
|
3891
|
+
__decorate([
|
|
3892
|
+
n({ type: String, reflect: true })
|
|
3893
|
+
], Select.prototype, "value", void 0);
|
|
3894
|
+
__decorate([
|
|
3895
|
+
n({ type: Boolean, reflect: true })
|
|
3896
|
+
], Select.prototype, "multiple", void 0);
|
|
3897
|
+
__decorate([
|
|
3898
|
+
n({ type: String })
|
|
3899
|
+
], Select.prototype, "search", void 0);
|
|
3900
|
+
__decorate([
|
|
3901
|
+
n({ type: String })
|
|
3902
|
+
], Select.prototype, "placeholder", void 0);
|
|
3903
|
+
__decorate([
|
|
3904
|
+
n({ type: String })
|
|
3905
|
+
], Select.prototype, "label", void 0);
|
|
3906
|
+
__decorate([
|
|
3907
|
+
n({ type: String })
|
|
3908
|
+
], Select.prototype, "variant", void 0);
|
|
3909
|
+
__decorate([
|
|
3910
|
+
n({ type: String, attribute: 'helper-text' })
|
|
3911
|
+
], Select.prototype, "helperText", void 0);
|
|
3912
|
+
__decorate([
|
|
3913
|
+
n({ type: Boolean })
|
|
3914
|
+
], Select.prototype, "error", void 0);
|
|
3915
|
+
__decorate([
|
|
3916
|
+
n({ type: String, attribute: 'error-text' })
|
|
3917
|
+
], Select.prototype, "errorText", void 0);
|
|
3918
|
+
__decorate([
|
|
3919
|
+
n({ type: Boolean })
|
|
3920
|
+
], Select.prototype, "warning", void 0);
|
|
3921
|
+
__decorate([
|
|
3922
|
+
n({ type: String, attribute: 'warning-text' })
|
|
3923
|
+
], Select.prototype, "warningText", void 0);
|
|
3924
|
+
__decorate([
|
|
3925
|
+
r()
|
|
3926
|
+
], Select.prototype, "_open", void 0);
|
|
3927
|
+
__decorate([
|
|
3928
|
+
r()
|
|
3929
|
+
], Select.prototype, "_focused", void 0);
|
|
3930
|
+
__decorate([
|
|
3931
|
+
r()
|
|
3932
|
+
], Select.prototype, "_searchQuery", void 0);
|
|
3933
|
+
__decorate([
|
|
3934
|
+
r()
|
|
3935
|
+
], Select.prototype, "_noOptionsVisible", void 0);
|
|
3936
|
+
__decorate([
|
|
3937
|
+
e$1('.select-trigger')
|
|
3938
|
+
], Select.prototype, "_triggerEl", void 0);
|
|
3939
|
+
__decorate([
|
|
3940
|
+
e$1('.search-input')
|
|
3941
|
+
], Select.prototype, "_searchInputEl", void 0);
|
|
3942
|
+
|
|
3943
|
+
export { ChipSet as C, DatePicker as D, Input as I, LinearProgress as L, NumberField as N, Select as S, Tag as T, UrlField as U, CircularProgress as a, SidebarMenu as b, SidebarMenuItem as c, SidebarSubMenu as d, Switch as e, Textarea as f, TimePicker as g };
|
|
3944
|
+
//# sourceMappingURL=select-CspawZ18.js.map
|