@ember-joinery/primitives 0.0.0-stage → 1.0.1
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/CHANGELOG.md +472 -0
- package/LICENSE.md +9 -0
- package/NOTICE +532 -0
- package/README.md +11 -2
- package/addon-main.cjs +4 -0
- package/declarations/-private/combobox-list.d.ts +59 -0
- package/declarations/-private/combobox-list.d.ts.map +1 -0
- package/declarations/-private/command-score.d.ts +33 -0
- package/declarations/-private/command-score.d.ts.map +1 -0
- package/declarations/-private/delay-group.d.ts +47 -0
- package/declarations/-private/delay-group.d.ts.map +1 -0
- package/declarations/-private/dialog.d.ts +180 -0
- package/declarations/-private/dialog.d.ts.map +1 -0
- package/declarations/-private/form-control.d.ts +70 -0
- package/declarations/-private/form-control.d.ts.map +1 -0
- package/declarations/-private/form-data.d.ts +14 -0
- package/declarations/-private/form-data.d.ts.map +1 -0
- package/declarations/-private/hover-intent.d.ts +48 -0
- package/declarations/-private/hover-intent.d.ts.map +1 -0
- package/declarations/-private/image-loading.d.ts +77 -0
- package/declarations/-private/image-loading.d.ts.map +1 -0
- package/declarations/-private/indicator.d.ts +27 -0
- package/declarations/-private/indicator.d.ts.map +1 -0
- package/declarations/-private/instances.d.ts +11 -0
- package/declarations/-private/instances.d.ts.map +1 -0
- package/declarations/-private/layout-styles.d.ts +34 -0
- package/declarations/-private/layout-styles.d.ts.map +1 -0
- package/declarations/-private/menu.d.ts +616 -0
- package/declarations/-private/menu.d.ts.map +1 -0
- package/declarations/-private/observers.d.ts +35 -0
- package/declarations/-private/observers.d.ts.map +1 -0
- package/declarations/-private/popper.d.ts +149 -0
- package/declarations/-private/popper.d.ts.map +1 -0
- package/declarations/-private/presence-chart.d.ts +39 -0
- package/declarations/-private/presence-chart.d.ts.map +1 -0
- package/declarations/-private/promise-state.d.ts +41 -0
- package/declarations/-private/promise-state.d.ts.map +1 -0
- package/declarations/-private/scroll-end.d.ts +16 -0
- package/declarations/-private/scroll-end.d.ts.map +1 -0
- package/declarations/-private/scroll-visibility.d.ts +68 -0
- package/declarations/-private/scroll-visibility.d.ts.map +1 -0
- package/declarations/-private/toast.d.ts +119 -0
- package/declarations/-private/toast.d.ts.map +1 -0
- package/declarations/-private/typeahead-search.d.ts +29 -0
- package/declarations/-private/typeahead-search.d.ts.map +1 -0
- package/declarations/accordion.d.ts +284 -0
- package/declarations/accordion.d.ts.map +1 -0
- package/declarations/alert-dialog.d.ts +80 -0
- package/declarations/alert-dialog.d.ts.map +1 -0
- package/declarations/anchor/component.d.ts +63 -0
- package/declarations/anchor/component.d.ts.map +1 -0
- package/declarations/anchor/index.d.ts +7 -0
- package/declarations/anchor/index.d.ts.map +1 -0
- package/declarations/anchor/middleware.d.ts +46 -0
- package/declarations/anchor/middleware.d.ts.map +1 -0
- package/declarations/anchor/modifier.d.ts +34 -0
- package/declarations/anchor/modifier.d.ts.map +1 -0
- package/declarations/anchor/options.d.ts +112 -0
- package/declarations/anchor/options.d.ts.map +1 -0
- package/declarations/anchor/position.d.ts +36 -0
- package/declarations/anchor/position.d.ts.map +1 -0
- package/declarations/anchor.d.ts +2 -0
- package/declarations/as.d.ts +33 -0
- package/declarations/as.d.ts.map +1 -0
- package/declarations/aspect-ratio.d.ts +34 -0
- package/declarations/aspect-ratio.d.ts.map +1 -0
- package/declarations/avatar.d.ts +178 -0
- package/declarations/avatar.d.ts.map +1 -0
- package/declarations/body-class.d.ts +30 -0
- package/declarations/body-class.d.ts.map +1 -0
- package/declarations/breadcrumb.d.ts +64 -0
- package/declarations/breadcrumb.d.ts.map +1 -0
- package/declarations/calendar/dates.d.ts +142 -0
- package/declarations/calendar/dates.d.ts.map +1 -0
- package/declarations/calendar/index.d.ts +59 -0
- package/declarations/calendar/index.d.ts.map +1 -0
- package/declarations/calendar/state.d.ts +415 -0
- package/declarations/calendar/state.d.ts.map +1 -0
- package/declarations/calendar.d.ts +3 -0
- package/declarations/checkbox.d.ts +71 -0
- package/declarations/checkbox.d.ts.map +1 -0
- package/declarations/collapsible.d.ts +216 -0
- package/declarations/collapsible.d.ts.map +1 -0
- package/declarations/color-scheme.d.ts +115 -0
- package/declarations/color-scheme.d.ts.map +1 -0
- package/declarations/combobox.d.ts +569 -0
- package/declarations/combobox.d.ts.map +1 -0
- package/declarations/command.d.ts +410 -0
- package/declarations/command.d.ts.map +1 -0
- package/declarations/context-menu.d.ts +155 -0
- package/declarations/context-menu.d.ts.map +1 -0
- package/declarations/controllable-state.d.ts +85 -0
- package/declarations/controllable-state.d.ts.map +1 -0
- package/declarations/dialog.d.ts +80 -0
- package/declarations/dialog.d.ts.map +1 -0
- package/declarations/direction.d.ts +55 -0
- package/declarations/direction.d.ts.map +1 -0
- package/declarations/dismiss.d.ts +111 -0
- package/declarations/dismiss.d.ts.map +1 -0
- package/declarations/dom-context.d.ts +74 -0
- package/declarations/dom-context.d.ts.map +1 -0
- package/declarations/drawer/controller.d.ts +174 -0
- package/declarations/drawer/controller.d.ts.map +1 -0
- package/declarations/drawer/index.d.ts +105 -0
- package/declarations/drawer/index.d.ts.map +1 -0
- package/declarations/drawer/machine.d.ts +139 -0
- package/declarations/drawer/machine.d.ts.map +1 -0
- package/declarations/drawer/parts.d.ts +85 -0
- package/declarations/drawer/parts.d.ts.map +1 -0
- package/declarations/drawer.d.ts +2 -0
- package/declarations/dropdown-menu.d.ts +169 -0
- package/declarations/dropdown-menu.d.ts.map +1 -0
- package/declarations/external-link.d.ts +26 -0
- package/declarations/external-link.d.ts.map +1 -0
- package/declarations/file-drop.d.ts +119 -0
- package/declarations/file-drop.d.ts.map +1 -0
- package/declarations/focus-scope.d.ts +105 -0
- package/declarations/focus-scope.d.ts.map +1 -0
- package/declarations/focus.d.ts +114 -0
- package/declarations/focus.d.ts.map +1 -0
- package/declarations/head.d.ts +20 -0
- package/declarations/head.d.ts.map +1 -0
- package/declarations/heading.d.ts +59 -0
- package/declarations/heading.d.ts.map +1 -0
- package/declarations/hero.d.ts +32 -0
- package/declarations/hero.d.ts.map +1 -0
- package/declarations/hide-others.d.ts +35 -0
- package/declarations/hide-others.d.ts.map +1 -0
- package/declarations/hover-card.d.ts +148 -0
- package/declarations/hover-card.d.ts.map +1 -0
- package/declarations/i18n.d.ts +47 -0
- package/declarations/i18n.d.ts.map +1 -0
- package/declarations/id.d.ts +15 -0
- package/declarations/id.d.ts.map +1 -0
- package/declarations/iframe.d.ts +12 -0
- package/declarations/iframe.d.ts.map +1 -0
- package/declarations/incremental-each.d.ts +81 -0
- package/declarations/incremental-each.d.ts.map +1 -0
- package/declarations/index.d.ts +108 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/input-otp.d.ts +201 -0
- package/declarations/input-otp.d.ts.map +1 -0
- package/declarations/keys.d.ts +50 -0
- package/declarations/keys.d.ts.map +1 -0
- package/declarations/label.d.ts +36 -0
- package/declarations/label.d.ts.map +1 -0
- package/declarations/layer.d.ts +56 -0
- package/declarations/layer.d.ts.map +1 -0
- package/declarations/link-helper.d.ts +73 -0
- package/declarations/link-helper.d.ts.map +1 -0
- package/declarations/link.d.ts +60 -0
- package/declarations/link.d.ts.map +1 -0
- package/declarations/load.d.ts +47 -0
- package/declarations/load.d.ts.map +1 -0
- package/declarations/menubar.d.ts +231 -0
- package/declarations/menubar.d.ts.map +1 -0
- package/declarations/message-scroller/components.d.ts +229 -0
- package/declarations/message-scroller/components.d.ts.map +1 -0
- package/declarations/message-scroller/geometry.d.ts +95 -0
- package/declarations/message-scroller/geometry.d.ts.map +1 -0
- package/declarations/message-scroller/index.d.ts +4 -0
- package/declarations/message-scroller/index.d.ts.map +1 -0
- package/declarations/message-scroller/state.d.ts +124 -0
- package/declarations/message-scroller/state.d.ts.map +1 -0
- package/declarations/message-scroller.d.ts +2 -0
- package/declarations/messages.d.ts +166 -0
- package/declarations/messages.d.ts.map +1 -0
- package/declarations/narrowing.d.ts +24 -0
- package/declarations/narrowing.d.ts.map +1 -0
- package/declarations/native-form.d.ts +56 -0
- package/declarations/native-form.d.ts.map +1 -0
- package/declarations/native-value.d.ts +47 -0
- package/declarations/native-value.d.ts.map +1 -0
- package/declarations/navigation-menu.d.ts +406 -0
- package/declarations/navigation-menu.d.ts.map +1 -0
- package/declarations/on-resize.d.ts +32 -0
- package/declarations/on-resize.d.ts.map +1 -0
- package/declarations/part.d.ts +99 -0
- package/declarations/part.d.ts.map +1 -0
- package/declarations/popover.d.ts +236 -0
- package/declarations/popover.d.ts.map +1 -0
- package/declarations/portal/index.d.ts +3 -0
- package/declarations/portal/index.d.ts.map +1 -0
- package/declarations/portal/portal.d.ts +46 -0
- package/declarations/portal/portal.d.ts.map +1 -0
- package/declarations/portal/targets.d.ts +40 -0
- package/declarations/portal/targets.d.ts.map +1 -0
- package/declarations/portal.d.ts +2 -0
- package/declarations/presence.d.ts +80 -0
- package/declarations/presence.d.ts.map +1 -0
- package/declarations/progress.d.ts +98 -0
- package/declarations/progress.d.ts.map +1 -0
- package/declarations/proper-links.d.ts +69 -0
- package/declarations/proper-links.d.ts.map +1 -0
- package/declarations/qp.d.ts +55 -0
- package/declarations/qp.d.ts.map +1 -0
- package/declarations/questionnaire/components.d.ts +348 -0
- package/declarations/questionnaire/components.d.ts.map +1 -0
- package/declarations/questionnaire/index.d.ts +4 -0
- package/declarations/questionnaire/index.d.ts.map +1 -0
- package/declarations/questionnaire/state.d.ts +400 -0
- package/declarations/questionnaire/state.d.ts.map +1 -0
- package/declarations/questionnaire/utils.d.ts +65 -0
- package/declarations/questionnaire/utils.d.ts.map +1 -0
- package/declarations/questionnaire.d.ts +2 -0
- package/declarations/radio-group.d.ts +115 -0
- package/declarations/radio-group.d.ts.map +1 -0
- package/declarations/rating.d.ts +214 -0
- package/declarations/rating.d.ts.map +1 -0
- package/declarations/resizable/components.d.ts +107 -0
- package/declarations/resizable/components.d.ts.map +1 -0
- package/declarations/resizable/index.d.ts +4 -0
- package/declarations/resizable/index.d.ts.map +1 -0
- package/declarations/resizable/layout.d.ts +93 -0
- package/declarations/resizable/layout.d.ts.map +1 -0
- package/declarations/resizable/state.d.ts +211 -0
- package/declarations/resizable/state.d.ts.map +1 -0
- package/declarations/resizable.d.ts +2 -0
- package/declarations/resize-observer.d.ts +40 -0
- package/declarations/resize-observer.d.ts.map +1 -0
- package/declarations/roving-focus.d.ts +204 -0
- package/declarations/roving-focus.d.ts.map +1 -0
- package/declarations/scroll-area/components.d.ts +125 -0
- package/declarations/scroll-area/components.d.ts.map +1 -0
- package/declarations/scroll-area/index.d.ts +3 -0
- package/declarations/scroll-area/index.d.ts.map +1 -0
- package/declarations/scroll-area/state.d.ts +147 -0
- package/declarations/scroll-area/state.d.ts.map +1 -0
- package/declarations/scroll-area.d.ts +2 -0
- package/declarations/scroll-lock.d.ts +69 -0
- package/declarations/scroll-lock.d.ts.map +1 -0
- package/declarations/scroller.d.ts +71 -0
- package/declarations/scroller.d.ts.map +1 -0
- package/declarations/select.d.ts +459 -0
- package/declarations/select.d.ts.map +1 -0
- package/declarations/separator.d.ts +71 -0
- package/declarations/separator.d.ts.map +1 -0
- package/declarations/service.d.ts +83 -0
- package/declarations/service.d.ts.map +1 -0
- package/declarations/shadowed.d.ts +63 -0
- package/declarations/shadowed.d.ts.map +1 -0
- package/declarations/slider.d.ts +283 -0
- package/declarations/slider.d.ts.map +1 -0
- package/declarations/sticky-footer.d.ts +43 -0
- package/declarations/sticky-footer.d.ts.map +1 -0
- package/declarations/store.d.ts +47 -0
- package/declarations/store.d.ts.map +1 -0
- package/declarations/switch.d.ts +76 -0
- package/declarations/switch.d.ts.map +1 -0
- package/declarations/tabs.d.ts +250 -0
- package/declarations/tabs.d.ts.map +1 -0
- package/declarations/toast/icons.d.ts +29 -0
- package/declarations/toast/icons.d.ts.map +1 -0
- package/declarations/toast/index.d.ts +4 -0
- package/declarations/toast/index.d.ts.map +1 -0
- package/declarations/toast/item.d.ts +162 -0
- package/declarations/toast/item.d.ts.map +1 -0
- package/declarations/toast/state.d.ts +276 -0
- package/declarations/toast/state.d.ts.map +1 -0
- package/declarations/toast/styles.d.ts +20 -0
- package/declarations/toast/styles.d.ts.map +1 -0
- package/declarations/toast/toaster.d.ts +173 -0
- package/declarations/toast/toaster.d.ts.map +1 -0
- package/declarations/toast.d.ts +2 -0
- package/declarations/toggle-group.d.ts +161 -0
- package/declarations/toggle-group.d.ts.map +1 -0
- package/declarations/toggle.d.ts +70 -0
- package/declarations/toggle.d.ts.map +1 -0
- package/declarations/tooltip.d.ts +227 -0
- package/declarations/tooltip.d.ts.map +1 -0
- package/declarations/typeahead.d.ts +97 -0
- package/declarations/typeahead.d.ts.map +1 -0
- package/declarations/viewport.d.ts +109 -0
- package/declarations/viewport.d.ts.map +1 -0
- package/declarations/visually-hidden.d.ts +42 -0
- package/declarations/visually-hidden.d.ts.map +1 -0
- package/declarations/zoetrope.d.ts +120 -0
- package/declarations/zoetrope.d.ts.map +1 -0
- package/dist/accordion.js +367 -0
- package/dist/accordion.js.map +1 -0
- package/dist/alert-dialog.js +122 -0
- package/dist/alert-dialog.js.map +1 -0
- package/dist/anchor.js +2 -0
- package/dist/anchor.js.map +1 -0
- package/dist/as.js +60 -0
- package/dist/as.js.map +1 -0
- package/dist/aspect-ratio.js +59 -0
- package/dist/aspect-ratio.js.map +1 -0
- package/dist/avatar.js +464 -0
- package/dist/avatar.js.map +1 -0
- package/dist/body-class.js +57 -0
- package/dist/body-class.js.map +1 -0
- package/dist/breadcrumb.js +59 -0
- package/dist/breadcrumb.js.map +1 -0
- package/dist/calendar.js +1494 -0
- package/dist/calendar.js.map +1 -0
- package/dist/checkbox.js +81 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/collapsible.js +255 -0
- package/dist/collapsible.js.map +1 -0
- package/dist/color-scheme.js +306 -0
- package/dist/color-scheme.js.map +1 -0
- package/dist/combobox.js +1413 -0
- package/dist/combobox.js.map +1 -0
- package/dist/command.js +1054 -0
- package/dist/command.js.map +1 -0
- package/dist/component-DqLt83fo.js +886 -0
- package/dist/component-DqLt83fo.js.map +1 -0
- package/dist/components-CWfg0cFs.js +1745 -0
- package/dist/components-CWfg0cFs.js.map +1 -0
- package/dist/components-DBWszEI3.js +1285 -0
- package/dist/components-DBWszEI3.js.map +1 -0
- package/dist/components-DI8Azu05.js +1542 -0
- package/dist/components-DI8Azu05.js.map +1 -0
- package/dist/components-F0Ini448.js +875 -0
- package/dist/components-F0Ini448.js.map +1 -0
- package/dist/context-menu.js +207 -0
- package/dist/context-menu.js.map +1 -0
- package/dist/controllable-state.js +134 -0
- package/dist/controllable-state.js.map +1 -0
- package/dist/delay-group-B1K03gBL.js +75 -0
- package/dist/delay-group-B1K03gBL.js.map +1 -0
- package/dist/dialog-3gfz_8NA.js +349 -0
- package/dist/dialog-3gfz_8NA.js.map +1 -0
- package/dist/dialog.js +57 -0
- package/dist/dialog.js.map +1 -0
- package/dist/direction.js +75 -0
- package/dist/direction.js.map +1 -0
- package/dist/dismiss.js +329 -0
- package/dist/dismiss.js.map +1 -0
- package/dist/dom-context.js +104 -0
- package/dist/dom-context.js.map +1 -0
- package/dist/drawer.js +1456 -0
- package/dist/drawer.js.map +1 -0
- package/dist/dropdown-menu.js +201 -0
- package/dist/dropdown-menu.js.map +1 -0
- package/dist/external-link.js +21 -0
- package/dist/external-link.js.map +1 -0
- package/dist/file-drop.js +183 -0
- package/dist/file-drop.js.map +1 -0
- package/dist/focus-scope.js +292 -0
- package/dist/focus-scope.js.map +1 -0
- package/dist/focus.js +307 -0
- package/dist/focus.js.map +1 -0
- package/dist/form-control-Ca_KHSKK.js +177 -0
- package/dist/form-control-Ca_KHSKK.js.map +1 -0
- package/dist/head.js +25 -0
- package/dist/head.js.map +1 -0
- package/dist/heading.js +152 -0
- package/dist/heading.js.map +1 -0
- package/dist/hero.js +36 -0
- package/dist/hero.js.map +1 -0
- package/dist/hide-others.js +108 -0
- package/dist/hide-others.js.map +1 -0
- package/dist/hover-card.js +246 -0
- package/dist/hover-card.js.map +1 -0
- package/dist/hover-intent-Bxb83fgX.js +92 -0
- package/dist/hover-intent-Bxb83fgX.js.map +1 -0
- package/dist/i18n.js +72 -0
- package/dist/i18n.js.map +1 -0
- package/dist/id.js +24 -0
- package/dist/id.js.map +1 -0
- package/dist/iframe.js +19 -0
- package/dist/iframe.js.map +1 -0
- package/dist/incremental-each.js +181 -0
- package/dist/incremental-each.js.map +1 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/indicator-sYuRuFJA.js +26 -0
- package/dist/indicator-sYuRuFJA.js.map +1 -0
- package/dist/input-otp.js +611 -0
- package/dist/input-otp.js.map +1 -0
- package/dist/keys.js +65 -0
- package/dist/keys.js.map +1 -0
- package/dist/label.js +41 -0
- package/dist/label.js.map +1 -0
- package/dist/layer.js +157 -0
- package/dist/layer.js.map +1 -0
- package/dist/layout-styles-DY86so8a.js +81 -0
- package/dist/layout-styles-DY86so8a.js.map +1 -0
- package/dist/link-helper.js +122 -0
- package/dist/link-helper.js.map +1 -0
- package/dist/link.js +39 -0
- package/dist/link.js.map +1 -0
- package/dist/load.js +54 -0
- package/dist/load.js.map +1 -0
- package/dist/menu-Da1LFCet.js +1109 -0
- package/dist/menu-Da1LFCet.js.map +1 -0
- package/dist/menubar.js +357 -0
- package/dist/menubar.js.map +1 -0
- package/dist/message-scroller.js +2 -0
- package/dist/message-scroller.js.map +1 -0
- package/dist/messages.js +168 -0
- package/dist/messages.js.map +1 -0
- package/dist/narrowing.js +29 -0
- package/dist/narrowing.js.map +1 -0
- package/dist/native-form.js +134 -0
- package/dist/native-form.js.map +1 -0
- package/dist/native-value.js +125 -0
- package/dist/native-value.js.map +1 -0
- package/dist/navigation-menu.js +872 -0
- package/dist/navigation-menu.js.map +1 -0
- package/dist/observers-aItWe029.js +113 -0
- package/dist/observers-aItWe029.js.map +1 -0
- package/dist/on-resize.js +47 -0
- package/dist/on-resize.js.map +1 -0
- package/dist/part.js +291 -0
- package/dist/part.js.map +1 -0
- package/dist/popover.js +419 -0
- package/dist/popover.js.map +1 -0
- package/dist/popper-BbTzV8dP.js +323 -0
- package/dist/popper-BbTzV8dP.js.map +1 -0
- package/dist/portal-U554WDI9.js +214 -0
- package/dist/portal-U554WDI9.js.map +1 -0
- package/dist/portal.js +2 -0
- package/dist/portal.js.map +1 -0
- package/dist/presence.js +243 -0
- package/dist/presence.js.map +1 -0
- package/dist/progress.js +106 -0
- package/dist/progress.js.map +1 -0
- package/dist/promise-state-BMi2zVoT.js +91 -0
- package/dist/promise-state-BMi2zVoT.js.map +1 -0
- package/dist/proper-links.js +136 -0
- package/dist/proper-links.js.map +1 -0
- package/dist/qp.js +77 -0
- package/dist/qp.js.map +1 -0
- package/dist/questionnaire.js +2 -0
- package/dist/questionnaire.js.map +1 -0
- package/dist/radio-group.js +149 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/rating.js +261 -0
- package/dist/rating.js.map +1 -0
- package/dist/resizable.js +2 -0
- package/dist/resizable.js.map +1 -0
- package/dist/resize-observer.js +85 -0
- package/dist/resize-observer.js.map +1 -0
- package/dist/roving-focus.js +355 -0
- package/dist/roving-focus.js.map +1 -0
- package/dist/scroll-area.js +2 -0
- package/dist/scroll-area.js.map +1 -0
- package/dist/scroll-end-Cer8JSIB.js +87 -0
- package/dist/scroll-end-Cer8JSIB.js.map +1 -0
- package/dist/scroll-lock.js +267 -0
- package/dist/scroll-lock.js.map +1 -0
- package/dist/scroller.js +117 -0
- package/dist/scroller.js.map +1 -0
- package/dist/select.js +1223 -0
- package/dist/select.js.map +1 -0
- package/dist/separator.js +80 -0
- package/dist/separator.js.map +1 -0
- package/dist/service.js +160 -0
- package/dist/service.js.map +1 -0
- package/dist/shadowed.js +70 -0
- package/dist/shadowed.js.map +1 -0
- package/dist/slider.js +586 -0
- package/dist/slider.js.map +1 -0
- package/dist/sticky-footer.js +40 -0
- package/dist/sticky-footer.js.map +1 -0
- package/dist/store-BjiAd-KP.js +93 -0
- package/dist/store-BjiAd-KP.js.map +1 -0
- package/dist/store.js +4 -0
- package/dist/store.js.map +1 -0
- package/dist/switch.js +58 -0
- package/dist/switch.js.map +1 -0
- package/dist/tabs.js +458 -0
- package/dist/tabs.js.map +1 -0
- package/dist/toast.js +2 -0
- package/dist/toast.js.map +1 -0
- package/dist/toaster-DwprFZ1J.js +1518 -0
- package/dist/toaster-DwprFZ1J.js.map +1 -0
- package/dist/toggle-group.js +221 -0
- package/dist/toggle-group.js.map +1 -0
- package/dist/toggle.js +78 -0
- package/dist/toggle.js.map +1 -0
- package/dist/tooltip.js +422 -0
- package/dist/tooltip.js.map +1 -0
- package/dist/typeahead.js +233 -0
- package/dist/typeahead.js.map +1 -0
- package/dist/viewport.js +138 -0
- package/dist/viewport.js.map +1 -0
- package/dist/visually-hidden.js +49 -0
- package/dist/visually-hidden.js.map +1 -0
- package/dist/zoetrope.js +336 -0
- package/dist/zoetrope.js.map +1 -0
- package/package.json +101 -3
package/dist/select.js
ADDED
|
@@ -0,0 +1,1223 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { hash } from '@ember/helper';
|
|
4
|
+
import { on } from '@ember/modifier';
|
|
5
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
6
|
+
import Modifier, { modifier } from 'ember-modifier';
|
|
7
|
+
import { As } from './as.js';
|
|
8
|
+
import { controllable } from './controllable-state.js';
|
|
9
|
+
import { getDirection } from './direction.js';
|
|
10
|
+
import { dismissable } from './dismiss.js';
|
|
11
|
+
import { addFocusGuards, createFocusScope } from './focus-scope.js';
|
|
12
|
+
import { focusFirst } from './focus.js';
|
|
13
|
+
import { inertOthers } from './hide-others.js';
|
|
14
|
+
import { idFor } from './id.js';
|
|
15
|
+
import { topLayer } from './layer.js';
|
|
16
|
+
import { part } from './part.js';
|
|
17
|
+
import { ignoreROError } from './resize-observer.js';
|
|
18
|
+
import { scrollLock } from './scroll-lock.js';
|
|
19
|
+
import { Typeahead, isTypeaheadKey, getNextMatch } from './typeahead.js';
|
|
20
|
+
import { E as ElementRef, P as PopperArrow, p as popperOptions, a as anchorContent, b as buttonType, e as ensureId, d as displayContents, c as exposeProperties } from './popper-BbTzV8dP.js';
|
|
21
|
+
import { isUndefined } from '@sindresorhus/is';
|
|
22
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
23
|
+
import { setComponentTemplate } from '@ember/component';
|
|
24
|
+
import templateOnly from '@ember/component/template-only';
|
|
25
|
+
import { g, i } from 'decorator-transforms/runtime';
|
|
26
|
+
|
|
27
|
+
const OPEN_KEYS = [' ', 'Enter', 'ArrowUp', 'ArrowDown'];
|
|
28
|
+
const SELECTION_KEYS = [' ', 'Enter'];
|
|
29
|
+
/** How far the item-aligned content stays from the viewport's edges, as Radix's. */
|
|
30
|
+
const CONTENT_MARGIN = 10;
|
|
31
|
+
/** Where the content goes: over its trigger, the selected option on the value (Radix's default), or below it. */
|
|
32
|
+
/** Whether the value shows the placeholder: none chosen, as Radix's `shouldShowPlaceholder`. */function showsPlaceholder(value) {
|
|
33
|
+
return value === '' || value === undefined;
|
|
34
|
+
}
|
|
35
|
+
function clamp(value, [min, max]) {
|
|
36
|
+
return Math.min(max, Math.max(min, value));
|
|
37
|
+
}
|
|
38
|
+
function byDocumentOrder(a, b) {
|
|
39
|
+
if (a.element === b.element) return 0;
|
|
40
|
+
return a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
41
|
+
}
|
|
42
|
+
function setStyles(element, styles) {
|
|
43
|
+
const previous = Object.keys(styles).map(property => [property, element.style.getPropertyValue(property), element.style.getPropertyPriority(property)]);
|
|
44
|
+
for (const [property, value] of Object.entries(styles)) element.style.setProperty(property, value);
|
|
45
|
+
return () => {
|
|
46
|
+
for (const [property, value, priority] of previous) {
|
|
47
|
+
if (value) element.style.setProperty(property, value, priority);else element.style.removeProperty(property);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// ----- Arguments -----------------------------------------------------------------------------
|
|
52
|
+
/** What a `<Select>` takes: Radix's Select props, by Joinery's names. */
|
|
53
|
+
|
|
54
|
+
/** What a select's Content takes: where it goes, and what Escape and a press outside do. */
|
|
55
|
+
|
|
56
|
+
/** Radix's defaults for the `popper` position: below, at the start, 10px from the viewport's edges. */const POPPER_DEFAULTS = {
|
|
57
|
+
side: 'bottom',
|
|
58
|
+
align: 'start',
|
|
59
|
+
sideOffset: 0,
|
|
60
|
+
collisionPadding: CONTENT_MARGIN
|
|
61
|
+
};
|
|
62
|
+
// ----- The open content's state ---------------------------------------------------------------
|
|
63
|
+
/**
|
|
64
|
+
* What the open content knows, for the parts inside it: its element, its viewport, whether it
|
|
65
|
+
* has been placed, and whether its viewport can scroll either way (the scroll buttons show then).
|
|
66
|
+
*/
|
|
67
|
+
class SelectContentState {
|
|
68
|
+
select;
|
|
69
|
+
position;
|
|
70
|
+
content = null;
|
|
71
|
+
wrapper = null;
|
|
72
|
+
viewport = new ElementRef();
|
|
73
|
+
static {
|
|
74
|
+
g(this.prototype, "isPositioned", [tracked], function () {
|
|
75
|
+
return false;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
#isPositioned = (i(this, "isPositioned"), void 0);
|
|
79
|
+
static {
|
|
80
|
+
g(this.prototype, "canScrollUp", [tracked], function () {
|
|
81
|
+
return false;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
#canScrollUp = (i(this, "canScrollUp"), void 0);
|
|
85
|
+
static {
|
|
86
|
+
g(this.prototype, "canScrollDown", [tracked], function () {
|
|
87
|
+
return false;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
#canScrollDown = (i(this, "canScrollDown"), void 0);
|
|
91
|
+
/** Whether a viewport scroll should grow the item-aligned content (on once it is placed). */expandOnScroll = false;
|
|
92
|
+
/** Whether a scroll button appearing should place the content again (once). */
|
|
93
|
+
repositionOnScrollButton = true;
|
|
94
|
+
/** The function that places the item-aligned content, once it is shown. */
|
|
95
|
+
reposition;
|
|
96
|
+
/** The content's typeahead, which focuses the next option starting with what was typed. */
|
|
97
|
+
typeahead = new Typeahead();
|
|
98
|
+
constructor(select, position) {
|
|
99
|
+
this.select = select;
|
|
100
|
+
this.position = position;
|
|
101
|
+
}
|
|
102
|
+
/** The option to show and focus first: the selected one, or else the first that isn't disabled. */
|
|
103
|
+
get selectedItem() {
|
|
104
|
+
const items = this.select.items;
|
|
105
|
+
const value = this.select.value;
|
|
106
|
+
return items.find(item => !showsPlaceholder(value) && item.value === value) ?? items.find(item => !item.isDisabled);
|
|
107
|
+
}
|
|
108
|
+
/** Focuses the first of `candidates` that takes focus, scrolling it into view, as Radix's. */
|
|
109
|
+
focusFirst(candidates) {
|
|
110
|
+
const items = this.select.items.map(item => item.element);
|
|
111
|
+
const first = items[0];
|
|
112
|
+
const last = items.at(-1);
|
|
113
|
+
const viewport = this.viewport.current;
|
|
114
|
+
const previous = document.activeElement;
|
|
115
|
+
for (const candidate of candidates) {
|
|
116
|
+
if (!candidate) continue;
|
|
117
|
+
if (candidate === previous) return;
|
|
118
|
+
candidate.scrollIntoView({
|
|
119
|
+
block: 'nearest'
|
|
120
|
+
});
|
|
121
|
+
// The viewport may have padding, so scroll to its edges for the first and last items.
|
|
122
|
+
if (candidate === first && viewport) viewport.scrollTop = 0;
|
|
123
|
+
if (candidate === last && viewport) viewport.scrollTop = viewport.scrollHeight;
|
|
124
|
+
// The viewport's scroll event comes a frame later: the scroll buttons follow now.
|
|
125
|
+
this.measureScroll();
|
|
126
|
+
if (focusFirst([candidate], {
|
|
127
|
+
preventScroll: true
|
|
128
|
+
})) return;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
focusSelectedItem = () => {
|
|
132
|
+
this.focusFirst([this.selectedItem?.element, this.content]);
|
|
133
|
+
};
|
|
134
|
+
/** A pointer left an item (or moved onto a disabled one): focus goes back to the content. */
|
|
135
|
+
itemLeft = () => {
|
|
136
|
+
this.content?.focus({
|
|
137
|
+
preventScroll: true
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
/** Whether the viewport can scroll up or down now. */
|
|
141
|
+
measureScroll = () => {
|
|
142
|
+
const viewport = this.viewport.current;
|
|
143
|
+
if (!viewport || !this.isPositioned) return;
|
|
144
|
+
const up = viewport.scrollTop > 0;
|
|
145
|
+
// Rounded up, because a zoomed page doesn't always report whole pixels.
|
|
146
|
+
const down = Math.ceil(viewport.scrollTop) < viewport.scrollHeight - viewport.clientHeight;
|
|
147
|
+
if (up !== this.canScrollUp) this.canScrollUp = up;
|
|
148
|
+
if (down !== this.canScrollDown) this.canScrollDown = down;
|
|
149
|
+
};
|
|
150
|
+
/** A scroll button appeared: it pushes the viewport, so place the content again, once. */
|
|
151
|
+
scrollButtonShown = () => {
|
|
152
|
+
if (!this.repositionOnScrollButton || !this.reposition) return;
|
|
153
|
+
this.repositionOnScrollButton = false;
|
|
154
|
+
this.reposition();
|
|
155
|
+
this.focusSelectedItem();
|
|
156
|
+
};
|
|
157
|
+
placed = () => {
|
|
158
|
+
this.isPositioned = true;
|
|
159
|
+
this.focusSelectedItem();
|
|
160
|
+
this.measureScroll();
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
// ----- Modifiers -----------------------------------------------------------------------------
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Everything the open content does that isn't anchoring or dismissal, as Radix's
|
|
167
|
+
* `SelectContentImpl`: its inline layout, keyboard (arrows, Home, End, typeahead, no Tab), no
|
|
168
|
+
* context menu, focus trapped inside with focus guards and the rest of the page inert (Radix
|
|
169
|
+
* hides it from assistive technology; inert does that and keeps focus off it, as
|
|
170
|
+
* `CONTRIBUTING.md` asks of a modal part), the pointer that opened it not selecting on release,
|
|
171
|
+
* and closing when the window loses focus or resizes.
|
|
172
|
+
*/
|
|
173
|
+
class ContentBehaviour extends Modifier {
|
|
174
|
+
#installed = false;
|
|
175
|
+
modify(element, _, {
|
|
176
|
+
content
|
|
177
|
+
}) {
|
|
178
|
+
if (this.#installed) return;
|
|
179
|
+
this.#installed = true;
|
|
180
|
+
const select = content.select;
|
|
181
|
+
const state = content.state;
|
|
182
|
+
state.content = element;
|
|
183
|
+
const restoreStyles = setStyles(element, {
|
|
184
|
+
display: 'flex',
|
|
185
|
+
'flex-direction': 'column',
|
|
186
|
+
outline: 'none',
|
|
187
|
+
'box-sizing': 'border-box',
|
|
188
|
+
...(state.position === 'item-aligned' ? {
|
|
189
|
+
'max-height': '100%'
|
|
190
|
+
} : {})
|
|
191
|
+
});
|
|
192
|
+
const restoreProperties = state.position === 'popper' ? exposeProperties(element, 'select') : () => {};
|
|
193
|
+
// Its size follows the trigger's (`min-w-(--radix-select-trigger-width)`), which anchoring
|
|
194
|
+
// sets from a resize observer: the browser's benign "ResizeObserver loop" message follows.
|
|
195
|
+
ignoreROError();
|
|
196
|
+
// Focusable itself, as Radix's FocusScope makes it, for when no option has focus.
|
|
197
|
+
const ownTabindex = element.hasAttribute('tabindex');
|
|
198
|
+
if (!ownTabindex) element.setAttribute('tabindex', '-1');
|
|
199
|
+
// Named by its trigger, unless the caller named it.
|
|
200
|
+
const named = element.hasAttribute('aria-label') || element.hasAttribute('aria-labelledby');
|
|
201
|
+
const triggerId = select.triggerRef.current?.id;
|
|
202
|
+
if (!named && triggerId) element.setAttribute('aria-labelledby', triggerId);
|
|
203
|
+
const onKeyDown = event => content.keyDown(event);
|
|
204
|
+
const onContextMenu = event => event.preventDefault();
|
|
205
|
+
element.addEventListener('keydown', onKeyDown);
|
|
206
|
+
element.addEventListener('contextmenu', onContextMenu);
|
|
207
|
+
// The press that opened it from the trigger: its release doesn't select unless the pointer
|
|
208
|
+
// moved, and a release outside closes it.
|
|
209
|
+
let moved = {
|
|
210
|
+
x: 0,
|
|
211
|
+
y: 0
|
|
212
|
+
};
|
|
213
|
+
const start = select.triggerPointerDownPosition;
|
|
214
|
+
const onPointerMove = event => {
|
|
215
|
+
moved = {
|
|
216
|
+
x: Math.abs(Math.round(event.pageX) - (start?.x ?? 0)),
|
|
217
|
+
y: Math.abs(Math.round(event.pageY) - (start?.y ?? 0))
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
const onPointerUp = event => {
|
|
221
|
+
if (moved.x <= 10 && moved.y <= 10) event.preventDefault();else if (!element.contains(event.target)) select.setOpen(false);
|
|
222
|
+
document.removeEventListener('pointermove', onPointerMove);
|
|
223
|
+
select.triggerPointerDownPosition = null;
|
|
224
|
+
};
|
|
225
|
+
if (start) {
|
|
226
|
+
document.addEventListener('pointermove', onPointerMove);
|
|
227
|
+
document.addEventListener('pointerup', onPointerUp, {
|
|
228
|
+
capture: true,
|
|
229
|
+
once: true
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
const close = () => select.setOpen(false);
|
|
233
|
+
window.addEventListener('blur', close);
|
|
234
|
+
window.addEventListener('resize', close);
|
|
235
|
+
const releaseGuards = addFocusGuards();
|
|
236
|
+
const undoInert = inertOthers(state.wrapper ?? element);
|
|
237
|
+
let scope = createFocusScope(element, {
|
|
238
|
+
trapped: true,
|
|
239
|
+
loop: false,
|
|
240
|
+
// Focus goes to the selected option once the content is placed, not to its first element.
|
|
241
|
+
onMountAutoFocus: event => event.preventDefault(),
|
|
242
|
+
onUnmountAutoFocus: event => content.closeAutoFocus(event)
|
|
243
|
+
});
|
|
244
|
+
registerDestructor(this, () => {
|
|
245
|
+
element.removeEventListener('keydown', onKeyDown);
|
|
246
|
+
element.removeEventListener('contextmenu', onContextMenu);
|
|
247
|
+
document.removeEventListener('pointermove', onPointerMove);
|
|
248
|
+
document.removeEventListener('pointerup', onPointerUp, {
|
|
249
|
+
capture: true
|
|
250
|
+
});
|
|
251
|
+
window.removeEventListener('blur', close);
|
|
252
|
+
window.removeEventListener('resize', close);
|
|
253
|
+
// The page stops being inert first, so focus can go back to the trigger.
|
|
254
|
+
undoInert();
|
|
255
|
+
scope?.destroy();
|
|
256
|
+
scope = undefined;
|
|
257
|
+
releaseGuards();
|
|
258
|
+
state.typeahead.dispose();
|
|
259
|
+
if (!named) element.removeAttribute('aria-labelledby');
|
|
260
|
+
if (!ownTabindex) element.removeAttribute('tabindex');
|
|
261
|
+
restoreProperties();
|
|
262
|
+
restoreStyles();
|
|
263
|
+
if (state.content === element) state.content = null;
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Places the content once the top layer shows it, and focuses the selected option: Radix's
|
|
269
|
+
* `onPlaced`. On the item-aligned wrapper it also works out where the wrapper goes. It goes
|
|
270
|
+
* after `{{topLayer}}` on the element the top layer shows, so it runs after the show.
|
|
271
|
+
*/
|
|
272
|
+
class Place extends Modifier {
|
|
273
|
+
#installed = false;
|
|
274
|
+
modify(element, _, {
|
|
275
|
+
content
|
|
276
|
+
}) {
|
|
277
|
+
if (this.#installed) return;
|
|
278
|
+
this.#installed = true;
|
|
279
|
+
const state = content.state;
|
|
280
|
+
let cancelled = false;
|
|
281
|
+
registerDestructor(this, () => cancelled = true);
|
|
282
|
+
if (state.position === 'item-aligned') {
|
|
283
|
+
state.wrapper = element;
|
|
284
|
+
const restore = setStyles(element, {
|
|
285
|
+
display: 'flex',
|
|
286
|
+
'flex-direction': 'column',
|
|
287
|
+
position: 'fixed',
|
|
288
|
+
// None of the browser's popover styles: Radix's wrapper is a plain fixed element.
|
|
289
|
+
inset: 'auto',
|
|
290
|
+
width: 'auto',
|
|
291
|
+
height: 'auto',
|
|
292
|
+
margin: '0',
|
|
293
|
+
padding: '0',
|
|
294
|
+
border: '0',
|
|
295
|
+
overflow: 'visible',
|
|
296
|
+
background: 'transparent',
|
|
297
|
+
color: 'inherit'
|
|
298
|
+
});
|
|
299
|
+
registerDestructor(this, restore);
|
|
300
|
+
state.reposition = () => alignItem(content.select, state);
|
|
301
|
+
}
|
|
302
|
+
queueMicrotask(() => {
|
|
303
|
+
if (cancelled) return;
|
|
304
|
+
state.reposition?.();
|
|
305
|
+
state.placed();
|
|
306
|
+
if (state.position === 'item-aligned') {
|
|
307
|
+
// The first adjustment to the scroll position mustn't grow the content.
|
|
308
|
+
requestAnimationFrame(() => state.expandOnScroll = true);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Radix's `SelectItemAlignedPosition`: puts the content over its trigger, with the selected
|
|
315
|
+
* option's text over the value, as a native select's menu opens, and as tall as fits in the
|
|
316
|
+
* viewport (10px from its edges); the viewport scrolls the option into place.
|
|
317
|
+
*/
|
|
318
|
+
function alignItem(select, state) {
|
|
319
|
+
const trigger = select.triggerRef.current;
|
|
320
|
+
const valueNode = select.valueRef.current ?? trigger;
|
|
321
|
+
const wrapper = state.wrapper;
|
|
322
|
+
const content = state.content;
|
|
323
|
+
const viewport = state.viewport.current;
|
|
324
|
+
const selected = state.selectedItem;
|
|
325
|
+
const selectedItem = selected?.element;
|
|
326
|
+
const selectedItemText = selected?.textElement ?? selectedItem;
|
|
327
|
+
if (!trigger || !valueNode || !wrapper || !content || !viewport || !selectedItem) return;
|
|
328
|
+
if (!selectedItemText) return;
|
|
329
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
330
|
+
// Horizontally
|
|
331
|
+
const contentRect = content.getBoundingClientRect();
|
|
332
|
+
const valueNodeRect = valueNode.getBoundingClientRect();
|
|
333
|
+
const itemTextRect = selectedItemText.getBoundingClientRect();
|
|
334
|
+
const dir = getDirection(trigger, select.args.dir);
|
|
335
|
+
if (dir !== 'rtl') {
|
|
336
|
+
const itemTextOffset = itemTextRect.left - contentRect.left;
|
|
337
|
+
const left = valueNodeRect.left - itemTextOffset;
|
|
338
|
+
const leftDelta = triggerRect.left - left;
|
|
339
|
+
const minContentWidth = triggerRect.width + leftDelta;
|
|
340
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
341
|
+
const rightEdge = window.innerWidth - CONTENT_MARGIN;
|
|
342
|
+
// It may go off the end edge; never off the start.
|
|
343
|
+
const clampedLeft = clamp(left, [CONTENT_MARGIN, Math.max(CONTENT_MARGIN, rightEdge - contentWidth)]);
|
|
344
|
+
wrapper.style.setProperty('min-width', `${minContentWidth}px`);
|
|
345
|
+
wrapper.style.setProperty('left', `${clampedLeft}px`);
|
|
346
|
+
} else {
|
|
347
|
+
const itemTextOffset = contentRect.right - itemTextRect.right;
|
|
348
|
+
const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
|
|
349
|
+
const rightDelta = window.innerWidth - triggerRect.right - right;
|
|
350
|
+
const minContentWidth = triggerRect.width + rightDelta;
|
|
351
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
352
|
+
const leftEdge = window.innerWidth - CONTENT_MARGIN;
|
|
353
|
+
const clampedRight = clamp(right, [CONTENT_MARGIN, Math.max(CONTENT_MARGIN, leftEdge - contentWidth)]);
|
|
354
|
+
wrapper.style.setProperty('min-width', `${minContentWidth}px`);
|
|
355
|
+
wrapper.style.setProperty('right', `${clampedRight}px`);
|
|
356
|
+
}
|
|
357
|
+
// Vertically
|
|
358
|
+
const items = select.items;
|
|
359
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
360
|
+
const itemsHeight = viewport.scrollHeight;
|
|
361
|
+
const contentStyles = getComputedStyle(content);
|
|
362
|
+
const contentBorderTopWidth = Number.parseInt(contentStyles.borderTopWidth, 10);
|
|
363
|
+
const contentPaddingTop = Number.parseInt(contentStyles.paddingTop, 10);
|
|
364
|
+
const contentBorderBottomWidth = Number.parseInt(contentStyles.borderBottomWidth, 10);
|
|
365
|
+
const contentPaddingBottom = Number.parseInt(contentStyles.paddingBottom, 10);
|
|
366
|
+
const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
|
|
367
|
+
const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
|
|
368
|
+
const viewportStyles = getComputedStyle(viewport);
|
|
369
|
+
const viewportPaddingTop = Number.parseInt(viewportStyles.paddingTop, 10);
|
|
370
|
+
const viewportPaddingBottom = Number.parseInt(viewportStyles.paddingBottom, 10);
|
|
371
|
+
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
|
|
372
|
+
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
|
373
|
+
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
|
374
|
+
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
|
375
|
+
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
|
376
|
+
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
|
377
|
+
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
|
378
|
+
if (willAlignWithoutTopOverflow) {
|
|
379
|
+
const isLastItem = items.length > 0 && selectedItem === items.at(-1)?.element;
|
|
380
|
+
wrapper.style.setProperty('bottom', '0px');
|
|
381
|
+
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
|
382
|
+
const clampedTriggerMiddleToBottomEdge = Math.max(triggerMiddleToBottomEdge, selectedItemHalfHeight + (
|
|
383
|
+
// The viewport may have padding at the bottom: include it, so it doesn't scroll.
|
|
384
|
+
isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth);
|
|
385
|
+
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
|
386
|
+
wrapper.style.setProperty('height', `${height}px`);
|
|
387
|
+
} else {
|
|
388
|
+
const isFirstItem = items.length > 0 && selectedItem === items[0]?.element;
|
|
389
|
+
wrapper.style.setProperty('top', '0px');
|
|
390
|
+
const clampedTopEdgeToTriggerMiddle = Math.max(topEdgeToTriggerMiddle, contentBorderTopWidth + viewport.offsetTop + (
|
|
391
|
+
// The viewport may have padding at the top: include it, so it doesn't scroll.
|
|
392
|
+
isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight);
|
|
393
|
+
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
|
394
|
+
wrapper.style.setProperty('height', `${height}px`);
|
|
395
|
+
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
|
396
|
+
}
|
|
397
|
+
wrapper.style.setProperty('margin', `${CONTENT_MARGIN}px 0`);
|
|
398
|
+
wrapper.style.setProperty('min-height', `${minContentHeight}px`);
|
|
399
|
+
wrapper.style.setProperty('max-height', `${availableHeight}px`);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* The viewport's inline styles (it scrolls up and down, with no scrollbar, and is the items'
|
|
403
|
+
* offset parent), and, in the item-aligned position, growing the content as it scrolls, as
|
|
404
|
+
* Radix's `SelectViewport`.
|
|
405
|
+
*/
|
|
406
|
+
class ViewportBehaviour extends Modifier {
|
|
407
|
+
#installed = false;
|
|
408
|
+
modify(element, _, {
|
|
409
|
+
select
|
|
410
|
+
}) {
|
|
411
|
+
if (this.#installed) return;
|
|
412
|
+
this.#installed = true;
|
|
413
|
+
const state = select.content;
|
|
414
|
+
const restore = setStyles(element, {
|
|
415
|
+
position: 'relative',
|
|
416
|
+
flex: '1',
|
|
417
|
+
overflow: 'hidden auto',
|
|
418
|
+
// Radix hides the scrollbar with a <style>; the CSSOM does it here, which a strict
|
|
419
|
+
// Content Security Policy allows.
|
|
420
|
+
'scrollbar-width': 'none'
|
|
421
|
+
});
|
|
422
|
+
state?.viewport.set(element);
|
|
423
|
+
let previousScrollTop = 0;
|
|
424
|
+
const onScroll = () => {
|
|
425
|
+
const wrapper = state?.wrapper;
|
|
426
|
+
if (state?.expandOnScroll && wrapper) {
|
|
427
|
+
const scrolledBy = Math.abs(previousScrollTop - element.scrollTop);
|
|
428
|
+
if (scrolledBy > 0) {
|
|
429
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
430
|
+
const cssMinHeight = Number.parseFloat(wrapper.style.minHeight);
|
|
431
|
+
const cssHeight = Number.parseFloat(wrapper.style.height);
|
|
432
|
+
const previousHeight = Math.max(cssMinHeight, cssHeight);
|
|
433
|
+
if (previousHeight < availableHeight) {
|
|
434
|
+
const nextHeight = previousHeight + scrolledBy;
|
|
435
|
+
const clampedNextHeight = Math.min(availableHeight, nextHeight);
|
|
436
|
+
const heightDiff = nextHeight - clampedNextHeight;
|
|
437
|
+
wrapper.style.setProperty('height', `${clampedNextHeight}px`);
|
|
438
|
+
if (wrapper.style.bottom === '0px') {
|
|
439
|
+
element.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
|
440
|
+
// Keep the content pinned to the bottom.
|
|
441
|
+
wrapper.style.setProperty('justify-content', 'flex-end');
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
previousScrollTop = element.scrollTop;
|
|
447
|
+
state?.measureScroll();
|
|
448
|
+
};
|
|
449
|
+
element.addEventListener('scroll', onScroll);
|
|
450
|
+
registerDestructor(this, () => {
|
|
451
|
+
element.removeEventListener('scroll', onScroll);
|
|
452
|
+
state?.viewport.release(element);
|
|
453
|
+
restore();
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Shows the selected option's text in the value, as Radix portals the ItemText's children into
|
|
459
|
+
* it: copies of its nodes (ids left off), kept up to date as the text changes.
|
|
460
|
+
*/
|
|
461
|
+
class ValueText extends Modifier {
|
|
462
|
+
#copies = [];
|
|
463
|
+
#observer;
|
|
464
|
+
#source;
|
|
465
|
+
#element;
|
|
466
|
+
modify(element, _, {
|
|
467
|
+
source,
|
|
468
|
+
enabled
|
|
469
|
+
}) {
|
|
470
|
+
if (!this.#element) {
|
|
471
|
+
this.#element = element;
|
|
472
|
+
registerDestructor(this, () => this.#clear());
|
|
473
|
+
}
|
|
474
|
+
const next = enabled ? source : null;
|
|
475
|
+
if (next === this.#source && this.#copies.every(copy => copy.parentNode === element)) return;
|
|
476
|
+
this.#source = next;
|
|
477
|
+
this.#observer?.disconnect();
|
|
478
|
+
this.#observer = undefined;
|
|
479
|
+
this.#copy();
|
|
480
|
+
if (next) {
|
|
481
|
+
this.#observer = new MutationObserver(() => this.#copy());
|
|
482
|
+
this.#observer.observe(next, {
|
|
483
|
+
childList: true,
|
|
484
|
+
subtree: true,
|
|
485
|
+
characterData: true
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
#copy() {
|
|
490
|
+
const element = this.#element;
|
|
491
|
+
if (!element) return;
|
|
492
|
+
for (const copy of this.#copies) copy.parentNode?.removeChild(copy);
|
|
493
|
+
this.#copies = [];
|
|
494
|
+
const source = this.#source;
|
|
495
|
+
if (!source) return;
|
|
496
|
+
for (const node of source.childNodes) {
|
|
497
|
+
const copy = node.cloneNode(true);
|
|
498
|
+
if (copy instanceof Element) {
|
|
499
|
+
copy.removeAttribute('id');
|
|
500
|
+
for (const inner of copy.querySelectorAll('[id]')) inner.removeAttribute('id');
|
|
501
|
+
}
|
|
502
|
+
element.append(copy);
|
|
503
|
+
this.#copies.push(copy);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
#clear() {
|
|
507
|
+
this.#observer?.disconnect();
|
|
508
|
+
for (const copy of this.#copies) copy.parentNode?.removeChild(copy);
|
|
509
|
+
this.#copies = [];
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
/** The value's `pointer-events: none`, as Radix's, through the CSSOM. */
|
|
513
|
+
const noPointerEvents = modifier(element => {
|
|
514
|
+
return setStyles(element, {
|
|
515
|
+
'pointer-events': 'none'
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
/** The scroll buttons' `flex-shrink: 0`, as Radix's. */
|
|
519
|
+
const noShrink = modifier(element => {
|
|
520
|
+
return setStyles(element, {
|
|
521
|
+
'flex-shrink': '0'
|
|
522
|
+
});
|
|
523
|
+
});
|
|
524
|
+
/**
|
|
525
|
+
* Radix's `SelectBubbleInput`: the hidden native `<select>` follows the value, and tells the
|
|
526
|
+
* form when it changes (`change`, bubbling), as a user's choice would.
|
|
527
|
+
*/
|
|
528
|
+
class BubbleSelect extends Modifier {
|
|
529
|
+
#previous;
|
|
530
|
+
#installed = false;
|
|
531
|
+
modify(element, _, {
|
|
532
|
+
value
|
|
533
|
+
}) {
|
|
534
|
+
if (!this.#installed) {
|
|
535
|
+
this.#installed = true;
|
|
536
|
+
this.#previous = value;
|
|
537
|
+
const restore = setStyles(element, {
|
|
538
|
+
position: 'absolute',
|
|
539
|
+
border: '0',
|
|
540
|
+
width: '1px',
|
|
541
|
+
height: '1px',
|
|
542
|
+
padding: '0',
|
|
543
|
+
margin: '-1px',
|
|
544
|
+
overflow: 'hidden',
|
|
545
|
+
clip: 'rect(0, 0, 0, 0)',
|
|
546
|
+
'white-space': 'nowrap',
|
|
547
|
+
'word-wrap': 'normal'
|
|
548
|
+
});
|
|
549
|
+
registerDestructor(this, restore);
|
|
550
|
+
// Once its options have rendered.
|
|
551
|
+
queueMicrotask(() => element.value = value);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
if (this.#previous === value) return;
|
|
555
|
+
this.#previous = value;
|
|
556
|
+
queueMicrotask(() => {
|
|
557
|
+
element.value = value;
|
|
558
|
+
element.dispatchEvent(new Event('change', {
|
|
559
|
+
bubbles: true
|
|
560
|
+
}));
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
// ----- The parts -----------------------------------------------------------------------------
|
|
565
|
+
|
|
566
|
+
/** A `<button type="button">`, or `@as`, that opens the select: Radix's `Select.Trigger`. */const SelectTrigger = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"button\" type=\"button\" ...attributes {{@part}}>{{yield}}</As>", {
|
|
567
|
+
strictMode: true,
|
|
568
|
+
scope: () => ({
|
|
569
|
+
As
|
|
570
|
+
})
|
|
571
|
+
}), templateOnly());
|
|
572
|
+
/** A `<span>` beside the value, hidden from assistive technology: Radix's `Select.Icon`, `▼` by default. */
|
|
573
|
+
const SelectIcon = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"span\" aria-hidden=\"true\" ...attributes {{@part}}>\n {{~#if (has-block)}}{{yield}}{{else}}\u25BC{{/if~}}\n</As>", {
|
|
574
|
+
strictMode: true,
|
|
575
|
+
scope: () => ({
|
|
576
|
+
As
|
|
577
|
+
})
|
|
578
|
+
}), templateOnly());
|
|
579
|
+
/** A `<div>` that labels its group: Radix's `Select.Label`. */
|
|
580
|
+
const SelectLabel = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" ...attributes {{@part}}>{{yield}}</As>", {
|
|
581
|
+
strictMode: true,
|
|
582
|
+
scope: () => ({
|
|
583
|
+
As
|
|
584
|
+
})
|
|
585
|
+
}), templateOnly());
|
|
586
|
+
/** A `<div>` between options, hidden from assistive technology: Radix's `Select.Separator`. */
|
|
587
|
+
const SelectSeparator = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" aria-hidden=\"true\" ...attributes {{@part}}>{{yield}}</As>", {
|
|
588
|
+
strictMode: true,
|
|
589
|
+
scope: () => ({
|
|
590
|
+
As
|
|
591
|
+
})
|
|
592
|
+
}), templateOnly());
|
|
593
|
+
/**
|
|
594
|
+
* The chosen option's text, or the placeholder: Radix's `Select.Value`, a `<span>` that ignores
|
|
595
|
+
* the pointer. With a block of its own it shows that instead of the option's text.
|
|
596
|
+
*/
|
|
597
|
+
class SelectValue extends Component {
|
|
598
|
+
get showsPlaceholder() {
|
|
599
|
+
return showsPlaceholder(this.args.select.value);
|
|
600
|
+
}
|
|
601
|
+
static {
|
|
602
|
+
setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"span\" ...attributes {{@select.valuePart}} {{noPointerEvents}} {{ValueText source=@select.selectedItem.textElement enabled=(if this.showsPlaceholder false (if (has-block) false true))}}>\n {{~#if this.showsPlaceholder}}{{@placeholder}}{{else if (has-block)}}{{yield}}{{/if~}}\n</As>", {
|
|
603
|
+
strictMode: true,
|
|
604
|
+
scope: () => ({
|
|
605
|
+
As,
|
|
606
|
+
noPointerEvents,
|
|
607
|
+
ValueText
|
|
608
|
+
})
|
|
609
|
+
}), this);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
/** The scrolling part of the content, around the options: Radix's `Select.Viewport`. */const SelectViewport = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" role=\"presentation\" data-radix-select-viewport ...attributes {{@select.viewportPart}} {{ViewportBehaviour select=@select}}>{{yield}}</As>", {
|
|
613
|
+
strictMode: true,
|
|
614
|
+
scope: () => ({
|
|
615
|
+
As,
|
|
616
|
+
ViewportBehaviour
|
|
617
|
+
})
|
|
618
|
+
}), templateOnly());
|
|
619
|
+
/** Options that belong together, `role="group"`, named by its Label: Radix's `Select.Group`. */const SelectGroup = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" role=\"group\" ...attributes {{@select.groupPart}}>{{yield}}</As>", {
|
|
620
|
+
strictMode: true,
|
|
621
|
+
scope: () => ({
|
|
622
|
+
As
|
|
623
|
+
})
|
|
624
|
+
}), templateOnly());
|
|
625
|
+
/**
|
|
626
|
+
* Shown while the viewport can scroll its way: hovering or pressing it scrolls an option's
|
|
627
|
+
* height every 50ms. Radix's `Select.ScrollUpButton` and `ScrollDownButton`, hidden from
|
|
628
|
+
* assistive technology (the keyboard scrolls the options into view).
|
|
629
|
+
*/
|
|
630
|
+
class SelectScrollButton extends Component {
|
|
631
|
+
#timer;
|
|
632
|
+
constructor(owner, args) {
|
|
633
|
+
super(owner, args);
|
|
634
|
+
registerDestructor(this, () => this.stop());
|
|
635
|
+
}
|
|
636
|
+
get state() {
|
|
637
|
+
const select = this.args.select;
|
|
638
|
+
return select.isOpen ? select.content ?? undefined : undefined;
|
|
639
|
+
}
|
|
640
|
+
get isShown() {
|
|
641
|
+
const state = this.state;
|
|
642
|
+
if (!state) return false;
|
|
643
|
+
return this.args.direction === 'up' ? state.canScrollUp : state.canScrollDown;
|
|
644
|
+
}
|
|
645
|
+
scroll = () => {
|
|
646
|
+
const state = this.state;
|
|
647
|
+
const viewport = state?.viewport.current;
|
|
648
|
+
const item = state?.selectedItem?.element;
|
|
649
|
+
if (!state || !viewport || !item) return;
|
|
650
|
+
const step = item.offsetHeight;
|
|
651
|
+
viewport.scrollTop += this.args.direction === 'up' ? -step : step;
|
|
652
|
+
// As in `focusFirst`: don't wait a frame for the scroll event to show the other button.
|
|
653
|
+
state.measureScroll();
|
|
654
|
+
};
|
|
655
|
+
start = () => {
|
|
656
|
+
this.#timer ??= setInterval(this.scroll, 50);
|
|
657
|
+
};
|
|
658
|
+
stop = () => {
|
|
659
|
+
if (this.#timer === undefined) return;
|
|
660
|
+
clearInterval(this.#timer);
|
|
661
|
+
this.#timer = undefined;
|
|
662
|
+
};
|
|
663
|
+
onPointerMove = () => {
|
|
664
|
+
this.state?.itemLeft();
|
|
665
|
+
this.start();
|
|
666
|
+
};
|
|
667
|
+
shown = modifier(() => {
|
|
668
|
+
const state = this.state;
|
|
669
|
+
// It pushes the viewport: keep the focused option in view, and place the content again.
|
|
670
|
+
const active = document.activeElement;
|
|
671
|
+
if (active instanceof HTMLElement && this.args.select.items.some(i => i.element === active)) {
|
|
672
|
+
active.scrollIntoView({
|
|
673
|
+
block: 'nearest'
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
queueMicrotask(() => {
|
|
677
|
+
state?.measureScroll();
|
|
678
|
+
state?.scrollButtonShown();
|
|
679
|
+
});
|
|
680
|
+
return () => this.stop();
|
|
681
|
+
});
|
|
682
|
+
static {
|
|
683
|
+
setComponentTemplate(precompileTemplate("{{#if this.isShown}}\n <As @as={{@as}} @tag=\"div\" aria-hidden=\"true\" data-test-jn-part=\"scroll-{{@direction}}-button\" ...attributes {{noShrink}} {{this.shown}} {{on \"pointerdown\" this.start}} {{on \"pointermove\" this.onPointerMove}} {{on \"pointerleave\" this.stop}}>{{yield}}</As>\n{{/if}}", {
|
|
684
|
+
strictMode: true,
|
|
685
|
+
scope: () => ({
|
|
686
|
+
As,
|
|
687
|
+
noShrink,
|
|
688
|
+
on
|
|
689
|
+
})
|
|
690
|
+
}), this);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
/** Radix's `Select.Arrow`: an arrow pointing at the trigger, in the `popper` position only. */const SelectArrow = setComponentTemplate(precompileTemplate("{{#if @select.showsArrow}}\n {{#if (has-block)}}\n <PopperArrow @arrow={{@select.arrowRef}} @width={{@width}} @height={{@height}} ...attributes>\n {{yield}}\n </PopperArrow>\n {{else}}\n <PopperArrow @arrow={{@select.arrowRef}} @width={{@width}} @height={{@height}} ...attributes />\n {{/if}}\n{{/if}}", {
|
|
694
|
+
strictMode: true,
|
|
695
|
+
scope: () => ({
|
|
696
|
+
PopperArrow
|
|
697
|
+
})
|
|
698
|
+
}), templateOnly());
|
|
699
|
+
// ----- Items ---------------------------------------------------------------------------------
|
|
700
|
+
|
|
701
|
+
/** What an option yields: its text and its indicator, bound to it. */
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* One option, `role="option"`: Radix's `Select.Item`. A mouse chooses it on release (so a press
|
|
705
|
+
* on the trigger can slide to an option and let go), a touch or pen on the click; Enter or
|
|
706
|
+
* Space chooses the focused one. Focus follows the mouse.
|
|
707
|
+
*/
|
|
708
|
+
class SelectItem extends Component {
|
|
709
|
+
textRef = new ElementRef();
|
|
710
|
+
static {
|
|
711
|
+
g(this.prototype, "isFocused", [tracked], function () {
|
|
712
|
+
return false;
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
#isFocused = (i(this, "isFocused"), void 0);
|
|
716
|
+
element;
|
|
717
|
+
#pointerType = 'touch';
|
|
718
|
+
get select() {
|
|
719
|
+
return this.args.select;
|
|
720
|
+
}
|
|
721
|
+
get value() {
|
|
722
|
+
return this.args.value;
|
|
723
|
+
}
|
|
724
|
+
get isDisabled() {
|
|
725
|
+
return this.args.disabled ?? false;
|
|
726
|
+
}
|
|
727
|
+
get isSelected() {
|
|
728
|
+
return this.select.value === this.args.value;
|
|
729
|
+
}
|
|
730
|
+
get textElement() {
|
|
731
|
+
return this.textRef.value;
|
|
732
|
+
}
|
|
733
|
+
/** The text typeahead matches: `@textValue`, or the ItemText's, trimmed. */
|
|
734
|
+
get textValue() {
|
|
735
|
+
return this.args.textValue ?? (this.textRef.current?.textContent ?? '').trim();
|
|
736
|
+
}
|
|
737
|
+
get textId() {
|
|
738
|
+
return idFor(this, 'text');
|
|
739
|
+
}
|
|
740
|
+
choose = () => {
|
|
741
|
+
if (this.isDisabled) return;
|
|
742
|
+
this.select.setValue(this.args.value);
|
|
743
|
+
this.select.setOpen(false);
|
|
744
|
+
};
|
|
745
|
+
part = part(() => ({
|
|
746
|
+
attributes: {
|
|
747
|
+
role: 'option',
|
|
748
|
+
'aria-labelledby': this.textRef.value ? this.textId : undefined,
|
|
749
|
+
'data-highlighted': this.isFocused,
|
|
750
|
+
// Only while focused, as Radix's: VoiceOver stutters otherwise.
|
|
751
|
+
'aria-selected': String(this.isSelected && this.isFocused),
|
|
752
|
+
'data-state': this.isSelected ? 'checked' : 'unchecked',
|
|
753
|
+
'aria-disabled': this.isDisabled ? 'true' : undefined,
|
|
754
|
+
'data-disabled': this.isDisabled,
|
|
755
|
+
tabindex: this.isDisabled ? undefined : '-1',
|
|
756
|
+
'data-test-jn-part': 'option',
|
|
757
|
+
'data-test-jn-value': this.args.value
|
|
758
|
+
},
|
|
759
|
+
on: {
|
|
760
|
+
focus: () => this.isFocused = true,
|
|
761
|
+
blur: () => this.isFocused = false,
|
|
762
|
+
click: () => {
|
|
763
|
+
// A mouse chooses on release; a touch or pen on the click.
|
|
764
|
+
if (this.#pointerType !== 'mouse') this.choose();
|
|
765
|
+
},
|
|
766
|
+
pointerup: () => {
|
|
767
|
+
if (this.#pointerType === 'mouse') this.choose();
|
|
768
|
+
},
|
|
769
|
+
pointerdown: event => this.#pointerType = event.pointerType,
|
|
770
|
+
pointermove: event => {
|
|
771
|
+
this.#pointerType = event.pointerType;
|
|
772
|
+
if (this.isDisabled) this.select.content?.itemLeft();else if (event.pointerType === 'mouse') this.element.focus({
|
|
773
|
+
preventScroll: true
|
|
774
|
+
});
|
|
775
|
+
},
|
|
776
|
+
pointerleave: () => {
|
|
777
|
+
if (this.element === document.activeElement) this.select.content?.itemLeft();
|
|
778
|
+
},
|
|
779
|
+
keydown: event => {
|
|
780
|
+
const typing = this.select.content?.typeahead.isTyping ?? false;
|
|
781
|
+
if (typing && event.key === ' ') return;
|
|
782
|
+
if (SELECTION_KEYS.includes(event.key)) this.choose();
|
|
783
|
+
// Space mustn't scroll the page.
|
|
784
|
+
if (event.key === ' ') event.preventDefault();
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
element: element => {
|
|
788
|
+
this.element = element;
|
|
789
|
+
return this.select.registerItem(this);
|
|
790
|
+
}
|
|
791
|
+
}));
|
|
792
|
+
text = part(() => ({
|
|
793
|
+
attributes: {
|
|
794
|
+
id: this.textId,
|
|
795
|
+
'data-test-jn-part': 'option-text'
|
|
796
|
+
},
|
|
797
|
+
element: element => {
|
|
798
|
+
this.textRef.set(element);
|
|
799
|
+
this.select.itemsChanged();
|
|
800
|
+
return () => {
|
|
801
|
+
this.textRef.release(element);
|
|
802
|
+
this.select.itemsChanged();
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
}));
|
|
806
|
+
static {
|
|
807
|
+
setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"div\" ...attributes {{this.part}}>\n {{yield (hash ItemText=(component SelectItemText item=this) ItemIndicator=(component SelectItemIndicator item=this) isSelected=this.isSelected isHighlighted=this.isFocused)}}\n</As>", {
|
|
808
|
+
strictMode: true,
|
|
809
|
+
scope: () => ({
|
|
810
|
+
As,
|
|
811
|
+
hash,
|
|
812
|
+
SelectItemText,
|
|
813
|
+
SelectItemIndicator
|
|
814
|
+
})
|
|
815
|
+
}), this);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
/** Radix's `Select.ItemText`: the option's text, which names it and which the value shows. */const SelectItemText = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"span\" ...attributes {{@item.text}}>{{yield}}</As>", {
|
|
819
|
+
strictMode: true,
|
|
820
|
+
scope: () => ({
|
|
821
|
+
As
|
|
822
|
+
})
|
|
823
|
+
}), templateOnly());
|
|
824
|
+
/** Radix's `Select.ItemIndicator`: rendered while its option is chosen, hidden from assistive technology. */const SelectItemIndicator = setComponentTemplate(precompileTemplate("{{#if @item.isSelected}}\n <As @as={{@as}} @tag=\"span\" aria-hidden=\"true\" data-test-jn-part=\"option-indicator\" ...attributes>{{yield}}</As>\n{{/if}}", {
|
|
825
|
+
strictMode: true,
|
|
826
|
+
scope: () => ({
|
|
827
|
+
As
|
|
828
|
+
})
|
|
829
|
+
}), templateOnly());
|
|
830
|
+
// ----- Content -------------------------------------------------------------------------------
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* The listbox: Radix's `Select.Content`. While the select is closed its options still render,
|
|
834
|
+
* outside the page (as Radix renders them into a fragment), so the value can show the chosen
|
|
835
|
+
* option's text and typeahead on the trigger can find the options. While it is open it is in
|
|
836
|
+
* the browser's top layer, over its trigger (`item-aligned`) or anchored below it (`popper`),
|
|
837
|
+
* with focus trapped inside and the rest of the page inert.
|
|
838
|
+
*/
|
|
839
|
+
class SelectContent extends Component {
|
|
840
|
+
/**
|
|
841
|
+
* Where the closed content's options render: an element outside the page. A server render
|
|
842
|
+
* (FastBoot) has no `document`, so there are none there; the value shows its placeholder until
|
|
843
|
+
* the page is in a browser.
|
|
844
|
+
*/
|
|
845
|
+
offPage = isUndefined(globalThis.document) ? undefined : globalThis.document.createElement('div');
|
|
846
|
+
get select() {
|
|
847
|
+
return this.args.select;
|
|
848
|
+
}
|
|
849
|
+
get position() {
|
|
850
|
+
return this.args.position ?? 'item-aligned';
|
|
851
|
+
}
|
|
852
|
+
get isPopper() {
|
|
853
|
+
return this.position === 'popper';
|
|
854
|
+
}
|
|
855
|
+
get anchorOptions() {
|
|
856
|
+
const own = this.isPopper ? this.args : {};
|
|
857
|
+
return popperOptions(own, {}, POPPER_DEFAULTS, {
|
|
858
|
+
arrow: this.select.arrowRef.value
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
#state;
|
|
862
|
+
/**
|
|
863
|
+
* The open content's state, made as it opens (the template reads it first thing, so the parts
|
|
864
|
+
* inside see it) and forgotten when it closes. A new position starts afresh.
|
|
865
|
+
*/
|
|
866
|
+
get state() {
|
|
867
|
+
return this.ensureState();
|
|
868
|
+
}
|
|
869
|
+
ensureState = () => {
|
|
870
|
+
let state = this.#state;
|
|
871
|
+
if (!state || state.position !== this.position) {
|
|
872
|
+
state = this.#state = new SelectContentState(this.select, this.position);
|
|
873
|
+
this.select.content = state;
|
|
874
|
+
}
|
|
875
|
+
return state;
|
|
876
|
+
};
|
|
877
|
+
opened = modifier(() => {
|
|
878
|
+
const state = this.#state;
|
|
879
|
+
return () => {
|
|
880
|
+
if (this.#state !== state) return;
|
|
881
|
+
this.#state = undefined;
|
|
882
|
+
if (this.select.content === state) this.select.content = null;
|
|
883
|
+
};
|
|
884
|
+
});
|
|
885
|
+
closeAutoFocus(event) {
|
|
886
|
+
this.args.onCloseAutoFocus?.(event);
|
|
887
|
+
if (event.defaultPrevented) return;
|
|
888
|
+
event.preventDefault();
|
|
889
|
+
this.select.triggerRef.current?.focus({
|
|
890
|
+
preventScroll: true
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
/** Radix's content keyboard: no Tab, typeahead, and the arrow keys, Home and End between options. */
|
|
894
|
+
keyDown(event) {
|
|
895
|
+
if (event.defaultPrevented) return;
|
|
896
|
+
const state = this.select.content;
|
|
897
|
+
if (!state) return;
|
|
898
|
+
// A select isn't navigated with Tab.
|
|
899
|
+
if (event.key === 'Tab') event.preventDefault();
|
|
900
|
+
if (isTypeaheadKey(event)) {
|
|
901
|
+
const items = this.select.items.filter(item => !item.isDisabled);
|
|
902
|
+
const current = items.find(item => item.element === document.activeElement);
|
|
903
|
+
const search = state.typeahead.type(event.key);
|
|
904
|
+
const next = getNextMatch(items, search, current, item => item.textValue);
|
|
905
|
+
if (next) next.element.focus();
|
|
906
|
+
}
|
|
907
|
+
if (['ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) {
|
|
908
|
+
let candidates = this.select.items.filter(item => !item.isDisabled).map(item => item.element);
|
|
909
|
+
if (['ArrowUp', 'End'].includes(event.key)) candidates = candidates.slice().reverse();
|
|
910
|
+
if (['ArrowUp', 'ArrowDown'].includes(event.key)) {
|
|
911
|
+
const index = candidates.indexOf(event.target);
|
|
912
|
+
candidates = candidates.slice(index + 1);
|
|
913
|
+
}
|
|
914
|
+
state.focusFirst(candidates);
|
|
915
|
+
event.preventDefault();
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
onEscapeKeyDown = event => this.args.onEscapeKeyDown?.(event);
|
|
919
|
+
onPointerDownOutside = event => this.args.onPointerDownOutside?.(event);
|
|
920
|
+
// Focus is trapped, but a focusout may still happen: it never closes the select.
|
|
921
|
+
onFocusOutside = event => event.preventDefault();
|
|
922
|
+
dismiss = () => this.select.setOpen(false);
|
|
923
|
+
static {
|
|
924
|
+
setComponentTemplate(precompileTemplate("{{#if @select.isOpen}}\n {{#let (this.ensureState) as |state|}}{{#if state.select}}{{/if}}{{/let}}\n {{#if this.isPopper}}\n <As @as={{@as}} @tag=\"div\" ...attributes {{this.opened}} {{@select.contentPart}} {{ContentBehaviour content=this}} {{dismissable onDismiss=this.dismiss onEscapeKeyDown=this.onEscapeKeyDown onPointerDownOutside=this.onPointerDownOutside onFocusOutside=this.onFocusOutside disableOutsidePointerEvents=true}} {{scrollLock}} {{topLayer}} {{anchorContent @select.triggerRef.value this.anchorOptions}} {{Place content=this}}>{{yield}}</As>\n {{else}}\n <div data-test-jn-part=\"content-wrapper\" {{this.opened}} {{topLayer}} {{Place content=this}}>\n <As @as={{@as}} @tag=\"div\" ...attributes {{@select.contentPart}} {{ContentBehaviour content=this}} {{dismissable onDismiss=this.dismiss onEscapeKeyDown=this.onEscapeKeyDown onPointerDownOutside=this.onPointerDownOutside onFocusOutside=this.onFocusOutside disableOutsidePointerEvents=true}} {{scrollLock}}>{{yield}}</As>\n </div>\n {{/if}}\n{{else if this.offPage}}\n {{#in-element this.offPage insertBefore=null}}\n <div>{{yield}}</div>\n {{/in-element}}\n{{/if}}", {
|
|
925
|
+
strictMode: true,
|
|
926
|
+
scope: () => ({
|
|
927
|
+
As,
|
|
928
|
+
ContentBehaviour,
|
|
929
|
+
dismissable,
|
|
930
|
+
scrollLock,
|
|
931
|
+
topLayer,
|
|
932
|
+
anchorContent,
|
|
933
|
+
Place
|
|
934
|
+
})
|
|
935
|
+
}), this);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
// ----- The select ----------------------------------------------------------------------------
|
|
939
|
+
/** What a `<Select>` yields: its parts, the trigger's modifier, and its state. */
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Displays a list of options for the user to pick from, triggered by a button: Radix's Select,
|
|
943
|
+
* which shadcn's is built on. It renders no box of its own, and yields its parts:
|
|
944
|
+
*
|
|
945
|
+
* <Select @defaultValue="apple" as |s|>
|
|
946
|
+
* <s.Trigger aria-label="Fruit"><s.Value @placeholder="Select a fruit" /><s.Icon /></s.Trigger>
|
|
947
|
+
* <s.Content>
|
|
948
|
+
* <s.Viewport>
|
|
949
|
+
* <s.Item @value="apple" as |item|><item.ItemText>Apple</item.ItemText></s.Item>
|
|
950
|
+
* <s.Item @value="banana" as |item|><item.ItemText>Banana</item.ItemText></s.Item>
|
|
951
|
+
* </s.Viewport>
|
|
952
|
+
* </s.Content>
|
|
953
|
+
* </Select>
|
|
954
|
+
*
|
|
955
|
+
* Its value and open state are its own, or yours (`@value` with `@onValueChange`, `@open` with
|
|
956
|
+
* `@onOpenChange`; `@defaultValue` and `@defaultOpen` to start). The trigger is a `combobox`
|
|
957
|
+
* button: a mouse opens it on press, the keyboard on Space, Enter or the arrows, and typing a
|
|
958
|
+
* letter on it chooses the next option starting with it. Inside a form, a hidden native
|
|
959
|
+
* `<select>` named `@formName` carries the value.
|
|
960
|
+
*/
|
|
961
|
+
class Select extends Component {
|
|
962
|
+
openState = controllable(this, 'open', false);
|
|
963
|
+
valueState = controllable(this, 'value', '');
|
|
964
|
+
triggerRef = new ElementRef();
|
|
965
|
+
valueRef = new ElementRef();
|
|
966
|
+
arrowRef = new ElementRef();
|
|
967
|
+
/** The open content's state, while it is open. */
|
|
968
|
+
static {
|
|
969
|
+
g(this.prototype, "content", [tracked], function () {
|
|
970
|
+
return null;
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
#content = (i(this, "content"), void 0);
|
|
974
|
+
/** Where the press on the trigger that opened it went down, in page coordinates. */triggerPointerDownPosition = null;
|
|
975
|
+
/** The trigger's typeahead, which chooses while closed. */
|
|
976
|
+
typeahead = new Typeahead();
|
|
977
|
+
#items = new Set();
|
|
978
|
+
static {
|
|
979
|
+
g(this.prototype, "itemsVersion", [tracked], function () {
|
|
980
|
+
return 0;
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
#itemsVersion = (i(this, "itemsVersion"), void 0);
|
|
984
|
+
#bumping = false;
|
|
985
|
+
constructor(owner, args) {
|
|
986
|
+
super(owner, args);
|
|
987
|
+
registerDestructor(this, () => this.typeahead.dispose());
|
|
988
|
+
}
|
|
989
|
+
get id() {
|
|
990
|
+
return idFor(this);
|
|
991
|
+
}
|
|
992
|
+
get contentId() {
|
|
993
|
+
return idFor(this, 'content');
|
|
994
|
+
}
|
|
995
|
+
get isOpen() {
|
|
996
|
+
return this.openState.value;
|
|
997
|
+
}
|
|
998
|
+
get value() {
|
|
999
|
+
return this.valueState.value;
|
|
1000
|
+
}
|
|
1001
|
+
get isDisabled() {
|
|
1002
|
+
return this.args.disabled ?? false;
|
|
1003
|
+
}
|
|
1004
|
+
get state() {
|
|
1005
|
+
return this.isOpen ? 'open' : 'closed';
|
|
1006
|
+
}
|
|
1007
|
+
get showsArrow() {
|
|
1008
|
+
return this.isOpen && this.content?.position === 'popper';
|
|
1009
|
+
}
|
|
1010
|
+
/** The options rendered now, in document order. */
|
|
1011
|
+
get items() {
|
|
1012
|
+
return [...this.#items].filter(item => item.element).sort(byDocumentOrder);
|
|
1013
|
+
}
|
|
1014
|
+
/** The options, tracked: for what renders from them (the native options, the value's text). */
|
|
1015
|
+
get trackedItems() {
|
|
1016
|
+
void this.itemsVersion;
|
|
1017
|
+
return this.items;
|
|
1018
|
+
}
|
|
1019
|
+
get selectedItem() {
|
|
1020
|
+
const value = this.value;
|
|
1021
|
+
if (showsPlaceholder(value)) return undefined;
|
|
1022
|
+
return this.trackedItems.find(item => item.value === value);
|
|
1023
|
+
}
|
|
1024
|
+
/** The hidden native `<select>`'s options: one for each option, and an empty one while none is chosen. */
|
|
1025
|
+
get nativeOptions() {
|
|
1026
|
+
return this.trackedItems.map(item => ({
|
|
1027
|
+
value: item.value,
|
|
1028
|
+
text: item.textElement?.textContent ?? item.textValue,
|
|
1029
|
+
disabled: item.isDisabled,
|
|
1030
|
+
selected: item.value === this.value
|
|
1031
|
+
}));
|
|
1032
|
+
}
|
|
1033
|
+
/** Whether it takes part in a form, so needs the hidden `<select>`: inside one, or given `@form`. */
|
|
1034
|
+
get isFormControl() {
|
|
1035
|
+
const trigger = this.triggerRef.value;
|
|
1036
|
+
return Boolean(this.args.form) || Boolean(trigger?.closest('form'));
|
|
1037
|
+
}
|
|
1038
|
+
registerItem(item) {
|
|
1039
|
+
this.#items.add(item);
|
|
1040
|
+
this.itemsChanged();
|
|
1041
|
+
return () => {
|
|
1042
|
+
this.#items.delete(item);
|
|
1043
|
+
this.itemsChanged();
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
/** Re-renders what depends on the options, after the render that changed them. */
|
|
1047
|
+
itemsChanged() {
|
|
1048
|
+
if (this.#bumping) return;
|
|
1049
|
+
this.#bumping = true;
|
|
1050
|
+
queueMicrotask(() => {
|
|
1051
|
+
this.#bumping = false;
|
|
1052
|
+
this.itemsVersion += 1;
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
setOpen = open => this.openState.set(open);
|
|
1056
|
+
setValue = value => this.valueState.set(value);
|
|
1057
|
+
/** Radix's `handleOpen`: opens it unless disabled, and starts a fresh typeahead. */
|
|
1058
|
+
openFrom(event) {
|
|
1059
|
+
if (!this.isDisabled) {
|
|
1060
|
+
this.setOpen(true);
|
|
1061
|
+
this.typeahead.reset();
|
|
1062
|
+
}
|
|
1063
|
+
if (event) {
|
|
1064
|
+
this.triggerPointerDownPosition = {
|
|
1065
|
+
x: Math.round(event.pageX),
|
|
1066
|
+
y: Math.round(event.pageY)
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
#pointerType = 'touch';
|
|
1071
|
+
trigger = part(() => ({
|
|
1072
|
+
attributes: {
|
|
1073
|
+
role: 'combobox',
|
|
1074
|
+
'aria-controls': this.isOpen ? this.contentId : undefined,
|
|
1075
|
+
'aria-expanded': String(this.isOpen),
|
|
1076
|
+
'aria-required': this.args.required ? 'true' : undefined,
|
|
1077
|
+
'aria-autocomplete': 'none',
|
|
1078
|
+
dir: this.args.dir,
|
|
1079
|
+
'data-state': this.state,
|
|
1080
|
+
disabled: this.isDisabled,
|
|
1081
|
+
'data-disabled': this.isDisabled,
|
|
1082
|
+
'data-placeholder': showsPlaceholder(this.value),
|
|
1083
|
+
'data-test-jn-part': 'trigger'
|
|
1084
|
+
},
|
|
1085
|
+
on: {
|
|
1086
|
+
click: event => {
|
|
1087
|
+
event.currentTarget.focus();
|
|
1088
|
+
// A touch or pen opens it on the click.
|
|
1089
|
+
if (this.#pointerType !== 'mouse') this.openFrom(event);
|
|
1090
|
+
},
|
|
1091
|
+
pointerdown: event => {
|
|
1092
|
+
this.#pointerType = event.pointerType;
|
|
1093
|
+
// No implicit pointer capture: the release goes to whatever is under the pointer.
|
|
1094
|
+
const target = event.target;
|
|
1095
|
+
if (target.hasPointerCapture?.(event.pointerId)) target.releasePointerCapture(event.pointerId);
|
|
1096
|
+
// The left button only, without Ctrl (a right click on macOS), and not a touch, which
|
|
1097
|
+
// might be a scroll.
|
|
1098
|
+
if (event.button === 0 && !event.ctrlKey && event.pointerType === 'mouse') {
|
|
1099
|
+
this.openFrom(event);
|
|
1100
|
+
// Focus goes to the chosen option, not the trigger.
|
|
1101
|
+
event.preventDefault();
|
|
1102
|
+
}
|
|
1103
|
+
},
|
|
1104
|
+
keydown: event => {
|
|
1105
|
+
const typing = this.typeahead.isTyping;
|
|
1106
|
+
const modifier = event.ctrlKey || event.altKey || event.metaKey;
|
|
1107
|
+
if (!modifier && event.key.length === 1) this.typeAhead(event.key);
|
|
1108
|
+
if (typing && event.key === ' ') return;
|
|
1109
|
+
if (OPEN_KEYS.includes(event.key)) {
|
|
1110
|
+
this.openFrom();
|
|
1111
|
+
event.preventDefault();
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
},
|
|
1115
|
+
element: element => {
|
|
1116
|
+
this.triggerRef.set(element);
|
|
1117
|
+
const restoreType = buttonType(element);
|
|
1118
|
+
const restoreId = ensureId(element, idFor(this, 'trigger'));
|
|
1119
|
+
return () => {
|
|
1120
|
+
restoreType();
|
|
1121
|
+
restoreId();
|
|
1122
|
+
this.triggerRef.release(element);
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
}));
|
|
1126
|
+
/** Typing on the closed trigger chooses the next option starting with what was typed. */
|
|
1127
|
+
typeAhead(key) {
|
|
1128
|
+
const items = this.items.filter(item => !item.isDisabled);
|
|
1129
|
+
const current = items.find(item => item.value === this.value);
|
|
1130
|
+
const next = getNextMatch(items, this.typeahead.type(key), current, item => item.textValue);
|
|
1131
|
+
if (next) this.setValue(next.value);
|
|
1132
|
+
}
|
|
1133
|
+
valuePart = part(() => ({
|
|
1134
|
+
attributes: {
|
|
1135
|
+
'data-test-jn-part': 'value'
|
|
1136
|
+
},
|
|
1137
|
+
element: element => {
|
|
1138
|
+
this.valueRef.set(element);
|
|
1139
|
+
return () => this.valueRef.release(element);
|
|
1140
|
+
}
|
|
1141
|
+
}));
|
|
1142
|
+
icon = part(() => ({
|
|
1143
|
+
attributes: {
|
|
1144
|
+
'data-test-jn-part': 'icon'
|
|
1145
|
+
}
|
|
1146
|
+
}));
|
|
1147
|
+
contentPart = part(() => ({
|
|
1148
|
+
attributes: {
|
|
1149
|
+
id: this.contentId,
|
|
1150
|
+
role: 'listbox',
|
|
1151
|
+
'data-state': this.state,
|
|
1152
|
+
dir: this.args.dir,
|
|
1153
|
+
'data-test-jn-part': 'content',
|
|
1154
|
+
'data-test-jn-owner': this.id
|
|
1155
|
+
}
|
|
1156
|
+
}));
|
|
1157
|
+
viewportPart = part(() => ({
|
|
1158
|
+
attributes: {
|
|
1159
|
+
'data-test-jn-part': 'viewport'
|
|
1160
|
+
}
|
|
1161
|
+
}));
|
|
1162
|
+
groupPart = part(() => ({
|
|
1163
|
+
attributes: {
|
|
1164
|
+
'data-test-jn-part': 'group'
|
|
1165
|
+
}
|
|
1166
|
+
}));
|
|
1167
|
+
/** A label names the group it is in, as Radix's `Select.Label` does its `Select.Group`. */
|
|
1168
|
+
label = part(() => ({
|
|
1169
|
+
attributes: {
|
|
1170
|
+
'data-test-jn-part': 'label'
|
|
1171
|
+
},
|
|
1172
|
+
element: element => {
|
|
1173
|
+
const restoreId = ensureId(element, idFor(element, 'label'));
|
|
1174
|
+
const group = element.closest('[role="group"]');
|
|
1175
|
+
const labelled = group && !group.hasAttribute('aria-labelledby');
|
|
1176
|
+
if (labelled) group.setAttribute('aria-labelledby', element.id);
|
|
1177
|
+
return () => {
|
|
1178
|
+
if (labelled && group.getAttribute('aria-labelledby') === element.id) {
|
|
1179
|
+
group.removeAttribute('aria-labelledby');
|
|
1180
|
+
}
|
|
1181
|
+
restoreId();
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
}));
|
|
1185
|
+
separator = part(() => ({
|
|
1186
|
+
attributes: {
|
|
1187
|
+
'data-test-jn-part': 'separator'
|
|
1188
|
+
}
|
|
1189
|
+
}));
|
|
1190
|
+
static {
|
|
1191
|
+
setComponentTemplate(precompileTemplate("<div id={{this.id}} data-test-jn=\"select\" data-test-jn-name={{@name}} data-test-jn-value={{this.value}} ...attributes {{displayContents}}>\n {{yield (hash Trigger=(component SelectTrigger part=this.trigger) Value=(component SelectValue select=this) Icon=(component SelectIcon part=this.icon) Content=(component SelectContent select=this) Viewport=(component SelectViewport select=this) Item=(component SelectItem select=this) Group=(component SelectGroup select=this) Label=(component SelectLabel part=this.label) Separator=(component SelectSeparator part=this.separator) ScrollUpButton=(component SelectScrollButton select=this direction=\"up\") ScrollDownButton=(component SelectScrollButton select=this direction=\"down\") Arrow=(component SelectArrow select=this) trigger=this.trigger value=this.value isOpen=this.isOpen setOpen=this.setOpen setValue=this.setValue)}}\n {{#if this.isFormControl}}\n <select aria-hidden=\"true\" tabindex=\"-1\" name={{@formName}} autocomplete={{@autoComplete}} required={{@required}} disabled={{@disabled}} form={{@form}} data-test-jn-part=\"native-select\" {{BubbleSelect value=this.value}} {{on \"change\" this.autofill}}>\n {{#if this.showsEmptyOption}}<option value></option>{{/if}}\n {{!-- Named native, not option: a block param named option would turn <option> into a call to it. --}}\n {{#each this.nativeOptions key=\"value\" as |native|}}\n <option value={{native.value}} disabled={{native.disabled}} selected={{native.selected}}>{{native.text}}</option>\n {{/each}}\n </select>\n {{/if}}\n</div>", {
|
|
1192
|
+
strictMode: true,
|
|
1193
|
+
scope: () => ({
|
|
1194
|
+
displayContents,
|
|
1195
|
+
hash,
|
|
1196
|
+
SelectTrigger,
|
|
1197
|
+
SelectValue,
|
|
1198
|
+
SelectIcon,
|
|
1199
|
+
SelectContent,
|
|
1200
|
+
SelectViewport,
|
|
1201
|
+
SelectItem,
|
|
1202
|
+
SelectGroup,
|
|
1203
|
+
SelectLabel,
|
|
1204
|
+
SelectSeparator,
|
|
1205
|
+
SelectScrollButton,
|
|
1206
|
+
SelectArrow,
|
|
1207
|
+
BubbleSelect,
|
|
1208
|
+
on
|
|
1209
|
+
})
|
|
1210
|
+
}), this);
|
|
1211
|
+
}
|
|
1212
|
+
get showsEmptyOption() {
|
|
1213
|
+
return showsPlaceholder(this.value);
|
|
1214
|
+
}
|
|
1215
|
+
/** The browser's autofill chose an option of the native `<select>`. */
|
|
1216
|
+
autofill = event => {
|
|
1217
|
+
const value = event.target.value;
|
|
1218
|
+
if (value !== this.value) this.setValue(value);
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
export { Select, SelectContent, SelectContentState, SelectItem, Select as default };
|
|
1223
|
+
//# sourceMappingURL=select.js.map
|