@ember-joinery/primitives 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +480 -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 +311 -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/heading.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { As } from './as.js';
|
|
3
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
|
+
import { setComponentTemplate } from '@ember/component';
|
|
5
|
+
|
|
6
|
+
/** The elements that can change the heading level of what they hold. */const BOUNDARY_ELEMENTS = new Set(['SECTION', 'ARTICLE', 'ASIDE', 'HEADER', 'FOOTER', 'MAIN', 'NAV']);
|
|
7
|
+
/**
|
|
8
|
+
* The boundaries that start a section of their own (HTML's sectioning content). The others
|
|
9
|
+
* (`header`, `footer`, `main`) belong to the section they are in: a `<header>` usually holds
|
|
10
|
+
* its section's heading, so the search looks inside it.
|
|
11
|
+
*/
|
|
12
|
+
const SECTIONING_CONTENT = new Set(['SECTION', 'ARTICLE', 'ASIDE', 'NAV']);
|
|
13
|
+
const HEADINGS = new Set(['H1', 'H2', 'H3', 'H4', 'H5', 'H6']);
|
|
14
|
+
/** Where ember-qunit renders a test: the search stops there, as at `<body>`. */
|
|
15
|
+
const TEST_ROOT = 'ember-testing';
|
|
16
|
+
const levels = new WeakMap();
|
|
17
|
+
// By node type rather than `instanceof`, so a heading rendered in an iframe is found too.
|
|
18
|
+
function isElement(node) {
|
|
19
|
+
return node?.nodeType === Node.ELEMENT_NODE;
|
|
20
|
+
}
|
|
21
|
+
function isShadowRoot(node) {
|
|
22
|
+
return node?.nodeType === Node.DOCUMENT_FRAGMENT_NODE && 'host' in node;
|
|
23
|
+
}
|
|
24
|
+
function isRoot(element) {
|
|
25
|
+
return element === element.ownerDocument.body || element.id === TEST_ROOT || !(element.parentElement || isShadowRoot(element.parentNode));
|
|
26
|
+
}
|
|
27
|
+
function isBoundary(element) {
|
|
28
|
+
return BOUNDARY_ELEMENTS.has(element.tagName.toUpperCase());
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The level of the heading in `node`, or in what it holds outside any nested section, if
|
|
32
|
+
* there is one. With `from`, the child of `node` the search came up through, the siblings
|
|
33
|
+
* before it are searched first, nearest first, leaving out the boundaries among them: a
|
|
34
|
+
* heading inside one of those is another section's.
|
|
35
|
+
*/
|
|
36
|
+
function headingIn(node, from) {
|
|
37
|
+
if (!isElement(node)) return undefined;
|
|
38
|
+
const tag = node.tagName.toUpperCase();
|
|
39
|
+
if (HEADINGS.has(tag)) return Number(tag.slice(1));
|
|
40
|
+
for (let previous = from?.previousSibling; previous; previous = previous.previousSibling) {
|
|
41
|
+
if (!isElement(previous) || isBoundary(previous)) continue;
|
|
42
|
+
const level = headingIn(previous);
|
|
43
|
+
if (level) return level;
|
|
44
|
+
}
|
|
45
|
+
// Then anything inside it, since a heading can be inside an <a> or a <header>, but not
|
|
46
|
+
// inside a nested section, whose headings are its own.
|
|
47
|
+
for (const child of node.children) {
|
|
48
|
+
if (SECTIONING_CONTENT.has(child.tagName.toUpperCase())) continue;
|
|
49
|
+
const level = headingIn(child);
|
|
50
|
+
if (level) return level;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
/** The nearest ancestor that `matches`, through shadow roots (which `closest()` stops at). */
|
|
55
|
+
function nearestAncestor(node, matches) {
|
|
56
|
+
let parent = node.parentNode;
|
|
57
|
+
while (parent) {
|
|
58
|
+
if (isShadowRoot(parent)) {
|
|
59
|
+
parent = parent.host;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (isElement(parent) && matches(parent)) return parent;
|
|
63
|
+
parent = parent.parentNode;
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const boundaryOrRoot = element => isBoundary(element) || isRoot(element);
|
|
68
|
+
/**
|
|
69
|
+
* The level for a heading at `node`. From the boundary around it, the search goes up the
|
|
70
|
+
* document; the first heading before it, between that boundary and the next one up, is its
|
|
71
|
+
* parent section's heading, and this heading is one level below. A boundary with no heading
|
|
72
|
+
* of its own is passed through, so a heading-less `<section>` doesn't start again at `<h1>`.
|
|
73
|
+
*/
|
|
74
|
+
function levelOf(node) {
|
|
75
|
+
const boundary = nearestAncestor(node, isBoundary);
|
|
76
|
+
if (!boundary) return 1;
|
|
77
|
+
let stopAt = nearestAncestor(boundary, boundaryOrRoot);
|
|
78
|
+
if (!stopAt) return 1;
|
|
79
|
+
let previous = boundary;
|
|
80
|
+
let current = boundary.parentNode;
|
|
81
|
+
while (current) {
|
|
82
|
+
const level = headingIn(current, previous);
|
|
83
|
+
if (level) return Math.min(level + 1, 6);
|
|
84
|
+
if (current === stopAt) {
|
|
85
|
+
if (!isElement(current) || isRoot(current)) break;
|
|
86
|
+
stopAt = nearestAncestor(current, boundaryOrRoot);
|
|
87
|
+
if (!stopAt) break;
|
|
88
|
+
}
|
|
89
|
+
if (isShadowRoot(current)) current = current.host;
|
|
90
|
+
previous = current;
|
|
91
|
+
current = current.parentNode;
|
|
92
|
+
}
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Which section heading, `<h1>` to `<h6>`, belongs at `node`, from the document around it:
|
|
97
|
+
* one level below the heading of the section it is in. `<section>`, `<article>`, `<aside>`
|
|
98
|
+
* and `<nav>` start a section, and `<header>`, `<footer>` and `<main>` are looked inside. The
|
|
99
|
+
* first answer for a node is kept, so ask once it is where it will stay.
|
|
100
|
+
*
|
|
101
|
+
* const marker = document.createTextNode('')
|
|
102
|
+
* section.append(marker)
|
|
103
|
+
* getSectionHeadingLevel(marker) // 2, under a page's <h1>
|
|
104
|
+
*
|
|
105
|
+
* It is ember-primitives' `which-heading-do-i-need`, which its `<Heading>` uses.
|
|
106
|
+
*/
|
|
107
|
+
function getSectionHeadingLevel(node, options) {
|
|
108
|
+
let level = levels.get(node);
|
|
109
|
+
if (!level) {
|
|
110
|
+
level = levelOf(node);
|
|
111
|
+
levels.set(node, level);
|
|
112
|
+
}
|
|
113
|
+
if (level === 1 && options?.startAt) return options.startAt;
|
|
114
|
+
return level;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A section heading, `<h1>` to `<h6>`, whose level comes from where it renders, as
|
|
118
|
+
* ember-primitives' `Heading`: one below the heading of the section it is in. Put content in
|
|
119
|
+
* `<section>`, `<article>`, `<aside>` or `<nav>` to start a section, and its headings go one
|
|
120
|
+
* level down, so a component can render a heading without knowing where it will be used.
|
|
121
|
+
*
|
|
122
|
+
* <Heading>Settings</Heading> {{! <h1> at the top of the page }}
|
|
123
|
+
* <section>
|
|
124
|
+
* <Heading>Profile</Heading> {{! <h2> }}
|
|
125
|
+
* </section>
|
|
126
|
+
*
|
|
127
|
+
* The level is found once, as it first renders, from the document as it is then. Before the
|
|
128
|
+
* heading it renders an empty text node, which the search starts from. It wraps its text, so
|
|
129
|
+
* it is a wrapper for the harnesses (`data-test-jn-wrapper`): a part inside it still belongs
|
|
130
|
+
* to the component around it.
|
|
131
|
+
*/
|
|
132
|
+
class Heading extends Component {
|
|
133
|
+
/** Where the search for the level starts, rendered just before the heading. */marker;
|
|
134
|
+
constructor(owner, args) {
|
|
135
|
+
super(owner, args);
|
|
136
|
+
this.marker = document.createTextNode('');
|
|
137
|
+
}
|
|
138
|
+
get tagName() {
|
|
139
|
+
return `h${getSectionHeadingLevel(this.marker)}`;
|
|
140
|
+
}
|
|
141
|
+
static {
|
|
142
|
+
setComponentTemplate(precompileTemplate("{{this.marker}}\n<As @as={{this.tagName}} @tag=\"h1\" data-test-jn=\"heading\" data-test-jn-wrapper data-test-jn-name={{@name}} ...attributes>{{yield}}</As>", {
|
|
143
|
+
strictMode: true,
|
|
144
|
+
scope: () => ({
|
|
145
|
+
As
|
|
146
|
+
})
|
|
147
|
+
}), this);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { Heading, getSectionHeadingLevel };
|
|
152
|
+
//# sourceMappingURL=heading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.js","sources":["../src/heading.gts"],"sourcesContent":["import Component from '@glimmer/component'\nimport type Owner from '@ember/owner'\nimport { As } from './as.gts'\n\n/** A section heading's level: `<h1>` to `<h6>`. */\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6\n\n/** The elements that can change the heading level of what they hold. */\nconst BOUNDARY_ELEMENTS = new Set([\n 'SECTION',\n 'ARTICLE',\n 'ASIDE',\n 'HEADER',\n 'FOOTER',\n 'MAIN',\n 'NAV',\n])\n\n/**\n * The boundaries that start a section of their own (HTML's sectioning content). The others\n * (`header`, `footer`, `main`) belong to the section they are in: a `<header>` usually holds\n * its section's heading, so the search looks inside it.\n */\nconst SECTIONING_CONTENT = new Set(['SECTION', 'ARTICLE', 'ASIDE', 'NAV'])\n\nconst HEADINGS = new Set(['H1', 'H2', 'H3', 'H4', 'H5', 'H6'])\n\n/** Where ember-qunit renders a test: the search stops there, as at `<body>`. */\nconst TEST_ROOT = 'ember-testing'\n\nconst levels = new WeakMap<Text, HeadingLevel>()\n\n// By node type rather than `instanceof`, so a heading rendered in an iframe is found too.\nfunction isElement(node: Node | null | undefined): node is Element {\n return node?.nodeType === Node.ELEMENT_NODE\n}\n\nfunction isShadowRoot(node: Node | null | undefined): node is ShadowRoot {\n return node?.nodeType === Node.DOCUMENT_FRAGMENT_NODE && 'host' in node\n}\n\nfunction isRoot(element: Element): boolean {\n return (\n element === element.ownerDocument.body ||\n element.id === TEST_ROOT ||\n !(element.parentElement || isShadowRoot(element.parentNode))\n )\n}\n\nfunction isBoundary(element: Element): boolean {\n return BOUNDARY_ELEMENTS.has(element.tagName.toUpperCase())\n}\n\n/**\n * The level of the heading in `node`, or in what it holds outside any nested section, if\n * there is one. With `from`, the child of `node` the search came up through, the siblings\n * before it are searched first, nearest first, leaving out the boundaries among them: a\n * heading inside one of those is another section's.\n */\nfunction headingIn(node: Node, from?: Node): HeadingLevel | undefined {\n if (!isElement(node)) return undefined\n const tag = node.tagName.toUpperCase()\n if (HEADINGS.has(tag)) return Number(tag.slice(1)) as HeadingLevel\n\n for (let previous = from?.previousSibling; previous; previous = previous.previousSibling) {\n if (!isElement(previous) || isBoundary(previous)) continue\n const level = headingIn(previous)\n if (level) return level\n }\n\n // Then anything inside it, since a heading can be inside an <a> or a <header>, but not\n // inside a nested section, whose headings are its own.\n for (const child of node.children) {\n if (SECTIONING_CONTENT.has(child.tagName.toUpperCase())) continue\n const level = headingIn(child)\n if (level) return level\n }\n return undefined\n}\n\n/** The nearest ancestor that `matches`, through shadow roots (which `closest()` stops at). */\nfunction nearestAncestor(node: Node, matches: (element: Element) => boolean): Element | undefined {\n let parent: Node | null = node.parentNode\n while (parent) {\n if (isShadowRoot(parent)) {\n parent = parent.host\n continue\n }\n if (isElement(parent) && matches(parent)) return parent\n parent = parent.parentNode\n }\n return undefined\n}\n\nconst boundaryOrRoot = (element: Element) => isBoundary(element) || isRoot(element)\n\n/**\n * The level for a heading at `node`. From the boundary around it, the search goes up the\n * document; the first heading before it, between that boundary and the next one up, is its\n * parent section's heading, and this heading is one level below. A boundary with no heading\n * of its own is passed through, so a heading-less `<section>` doesn't start again at `<h1>`.\n */\nfunction levelOf(node: Text): HeadingLevel {\n const boundary = nearestAncestor(node, isBoundary)\n if (!boundary) return 1\n\n let stopAt = nearestAncestor(boundary, boundaryOrRoot)\n if (!stopAt) return 1\n\n let previous: Node = boundary\n let current: Node | null = boundary.parentNode\n while (current) {\n const level = headingIn(current, previous)\n if (level) return Math.min(level + 1, 6) as HeadingLevel\n\n if (current === stopAt) {\n if (!isElement(current) || isRoot(current)) break\n stopAt = nearestAncestor(current, boundaryOrRoot)\n if (!stopAt) break\n }\n\n if (isShadowRoot(current)) current = current.host\n previous = current\n current = current.parentNode\n }\n return 1\n}\n\nexport interface SectionHeadingOptions {\n /**\n * The level to use when nothing above `node` sets one: the top of what the page has\n * rendered so far. Default 1. It doesn't lower a level the document sets.\n */\n startAt?: HeadingLevel\n}\n\n/**\n * Which section heading, `<h1>` to `<h6>`, belongs at `node`, from the document around it:\n * one level below the heading of the section it is in. `<section>`, `<article>`, `<aside>`\n * and `<nav>` start a section, and `<header>`, `<footer>` and `<main>` are looked inside. The\n * first answer for a node is kept, so ask once it is where it will stay.\n *\n * const marker = document.createTextNode('')\n * section.append(marker)\n * getSectionHeadingLevel(marker) // 2, under a page's <h1>\n *\n * It is ember-primitives' `which-heading-do-i-need`, which its `<Heading>` uses.\n */\nexport function getSectionHeadingLevel(node: Text, options?: SectionHeadingOptions): HeadingLevel {\n let level = levels.get(node)\n if (!level) {\n level = levelOf(node)\n levels.set(node, level)\n }\n if (level === 1 && options?.startAt) return options.startAt\n return level\n}\n\nexport interface HeadingSignature {\n Args: {\n /** Its name, for its harness (`data-test-jn-name`). */\n name?: string\n }\n Blocks: {\n /** The heading's text. */\n default: []\n }\n /** The heading: an `<h1>` to `<h6>`. */\n Element: HTMLHeadingElement\n}\n\n/**\n * A section heading, `<h1>` to `<h6>`, whose level comes from where it renders, as\n * ember-primitives' `Heading`: one below the heading of the section it is in. Put content in\n * `<section>`, `<article>`, `<aside>` or `<nav>` to start a section, and its headings go one\n * level down, so a component can render a heading without knowing where it will be used.\n *\n * <Heading>Settings</Heading> {{! <h1> at the top of the page }}\n * <section>\n * <Heading>Profile</Heading> {{! <h2> }}\n * </section>\n *\n * The level is found once, as it first renders, from the document as it is then. Before the\n * heading it renders an empty text node, which the search starts from. It wraps its text, so\n * it is a wrapper for the harnesses (`data-test-jn-wrapper`): a part inside it still belongs\n * to the component around it.\n */\nexport class Heading extends Component<HeadingSignature> {\n /** Where the search for the level starts, rendered just before the heading. */\n readonly marker: Text\n\n constructor(owner: Owner, args: HeadingSignature['Args']) {\n super(owner, args)\n this.marker = document.createTextNode('')\n }\n\n get tagName(): string {\n return `h${getSectionHeadingLevel(this.marker)}`\n }\n\n <template>\n {{this.marker}}\n <As\n @as={{this.tagName}}\n @tag=\"h1\"\n data-test-jn=\"heading\"\n data-test-jn-wrapper\n data-test-jn-name={{@name}}\n ...attributes\n >{{yield}}</As>\n </template>\n}\n"],"names":["BOUNDARY_ELEMENTS","Set","SECTIONING_CONTENT","HEADINGS","TEST_ROOT","levels","WeakMap","isElement","node","nodeType","Node","ELEMENT_NODE","isShadowRoot","DOCUMENT_FRAGMENT_NODE","isRoot","element","ownerDocument","body","id","parentElement","parentNode","isBoundary","has","tagName","toUpperCase","headingIn","from","undefined","tag","Number","slice","previous","previousSibling","level","child","children","nearestAncestor","matches","parent","host","boundaryOrRoot","levelOf","boundary","stopAt","current","Math","min","getSectionHeadingLevel","options","get","set","startAt","Heading","Component","marker","constructor","owner","args","document","createTextNode","setComponentTemplate","precompileTemplate","strictMode","scope","As"],"mappings":";;;;;AAOA,wEACA,MAAMA,iBAAA,GAAoB,IAAIC,GAAA,CAAI,CAChC,SAAA,EACA,SAAA,EACA,OAAA,EACA,QAAA,EACA,QAAA,EACA,MAAA,EACA,KAAA,CACD,CAAA;AAED;;;;;AAKA,MAAMC,kBAAA,GAAqB,IAAID,GAAA,CAAI,CAAC,SAAA,EAAW,SAAA,EAAW,OAAA,EAAS,KAAA,CAAM,CAAA;AAEzE,MAAME,QAAA,GAAW,IAAIF,GAAA,CAAI,CAAC,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IA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c,CAAC,EAAA,CAAA;AACxC,EAAA;EAEA,IAAIpC,OAAAA,GAAkB;AACpB,IAAA,OAAO,IAAIwB,uBAAuB,IAAI,CAACO,MAAM,CAAA,CAAA,CAAG;AAClD,EAAA;AAEA,EAAA;IAAAM,oBAAA,CAAAC,kBAAA,CAAA,8JAAA,EAUA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
package/dist/hero.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { modifier } from 'ember-modifier';
|
|
2
|
+
import { a as adoptLayoutStyles } from './layout-styles-DY86so8a.js';
|
|
3
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
|
+
import { setComponentTemplate } from '@ember/component';
|
|
5
|
+
import templateOnly from '@ember/component/template-only';
|
|
6
|
+
|
|
7
|
+
const STYLES = `@layer joinery {
|
|
8
|
+
:where([data-jn-hero]) { width: 100dvw; height: 100dvh; position: relative; }
|
|
9
|
+
}`;
|
|
10
|
+
const styled = modifier(element => adoptLayoutStyles(element, 'hero', STYLES));
|
|
11
|
+
/**
|
|
12
|
+
* A layout for featuring large, eye-catching content across the whole browser window, as
|
|
13
|
+
* ember-primitives' `Hero`: `100dvw` by `100dvh` (the dynamic viewport units, which follow a
|
|
14
|
+
* phone's toolbars) and `position: relative`, so headers and footers inside can be placed along
|
|
15
|
+
* its edges.
|
|
16
|
+
*
|
|
17
|
+
* <Hero class="landing">
|
|
18
|
+
* <h1>Joinery</h1>
|
|
19
|
+
* <a href="/guide">Get started</a>
|
|
20
|
+
* </Hero>
|
|
21
|
+
*
|
|
22
|
+
* Its rules are in `@layer joinery` at no specificity, so a class of the app's resizes it: an
|
|
23
|
+
* unlayered one always, and a layered one (a Tailwind utility) where the app names `joinery`
|
|
24
|
+
* before its own layers, as joinery.css and the guide's Tailwind setup do. It adds no landmark:
|
|
25
|
+
* put `<main>` or `<header>` inside or around it as the page needs. It wraps content, so it is a
|
|
26
|
+
* wrapper for the harnesses (`data-test-jn-wrapper`).
|
|
27
|
+
*/
|
|
28
|
+
const Hero = setComponentTemplate(precompileTemplate("<div data-jn-hero data-test-jn=\"hero\" data-test-jn-wrapper data-test-jn-name={{@name}} ...attributes {{styled}}>\n {{yield}}\n</div>", {
|
|
29
|
+
strictMode: true,
|
|
30
|
+
scope: () => ({
|
|
31
|
+
styled
|
|
32
|
+
})
|
|
33
|
+
}), templateOnly());
|
|
34
|
+
|
|
35
|
+
export { Hero };
|
|
36
|
+
//# sourceMappingURL=hero.js.map
|
package/dist/hero.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hero.js","sources":["../src/hero.gts"],"sourcesContent":["import type { TOC } from '@ember/component/template-only'\nimport { modifier } from 'ember-modifier'\nimport { adoptLayoutStyles } from './-private/layout-styles.ts'\n\n/**\n * ember-primitives' hero rules: the whole viewport, with the dynamic viewport units so it fits\n * a phone's browser as its toolbars come and go. `position: relative`, so what's inside can be\n * placed along its edges. The app's CSS wins, where the `joinery` layer comes before its own\n * (see `-private/layout-styles.ts`).\n */\nconst STYLES = `@layer joinery {\n :where([data-jn-hero]) { width: 100dvw; height: 100dvh; position: relative; }\n}`\n\nconst styled = modifier((element: HTMLElement) => adoptLayoutStyles(element, 'hero', STYLES))\n\nexport interface HeroSignature {\n Args: {\n /** Its name, for its harness (`data-test-jn-name`). */\n name?: string\n }\n Blocks: {\n /** What the hero features: an image or a video, a headline, a call to action. */\n default: []\n }\n /** The hero's element, as wide and tall as the viewport. */\n Element: HTMLDivElement\n}\n\n/**\n * A layout for featuring large, eye-catching content across the whole browser window, as\n * ember-primitives' `Hero`: `100dvw` by `100dvh` (the dynamic viewport units, which follow a\n * phone's toolbars) and `position: relative`, so headers and footers inside can be placed along\n * its edges.\n *\n * <Hero class=\"landing\">\n * <h1>Joinery</h1>\n * <a href=\"/guide\">Get started</a>\n * </Hero>\n *\n * Its rules are in `@layer joinery` at no specificity, so a class of the app's resizes it: an\n * unlayered one always, and a layered one (a Tailwind utility) where the app names `joinery`\n * before its own layers, as joinery.css and the guide's Tailwind setup do. It adds no landmark:\n * put `<main>` or `<header>` inside or around it as the page needs. It wraps content, so it is a\n * wrapper for the harnesses (`data-test-jn-wrapper`).\n */\nexport const Hero: TOC<HeroSignature> = <template>\n <div\n data-jn-hero\n data-test-jn=\"hero\"\n data-test-jn-wrapper\n data-test-jn-name={{@name}}\n ...attributes\n {{styled}}\n >\n {{yield}}\n </div>\n</template>\n"],"names":["STYLES","styled","modifier","element","adoptLayoutStyles","Hero","setComponentTemplate","precompileTemplate","strictMode","scope","templateOnly"],"mappings":";;;;;;AAUA,MAAMA,SAAS,CAAA;;EAEb;AAEF,MAAMC,SAASC,QAAA,CAAUC,OAAS,IAAgBC,iBAAA,CAAkBD,SAAS,MAAA,EAAQH,MAAA,CAAA,CAAA;AAerF;;;;;;;;;;;;;;;;AAgBC;MACYK,IAAU,GAAAC,oBAAA,CAAiBC,kBAAA,CAAA,yIAAA,EAWxC;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAR,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAS,YAAA,EAAA;;"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/** Puts back what `hideOthers` or `inertOthers` changed. */
|
|
2
|
+
|
|
3
|
+
/** How many live calls hide each element, by the attribute they set. */
|
|
4
|
+
const counts = {};
|
|
5
|
+
/** Elements that had the attribute already, which are never given it back or taken off. */
|
|
6
|
+
const theirOwn = {};
|
|
7
|
+
function list(targets) {
|
|
8
|
+
const all = Array.isArray(targets) ? targets : [targets];
|
|
9
|
+
return all.filter(target => target instanceof Element);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Sets `attribute` on every element in `parent` but the targets, their ancestors and the
|
|
14
|
+
* elements it keeps, as the aria-hidden package does: it walks down from `parent`, and at each
|
|
15
|
+
* level marks the children that hold no target. Calls stack, so an element stays marked until
|
|
16
|
+
* every call that marked it is undone, and an element that had the attribute before keeps it.
|
|
17
|
+
*/
|
|
18
|
+
function applyToOthers(targets, parent, attribute, marker) {
|
|
19
|
+
const keep = new Set();
|
|
20
|
+
const stop = new Set(targets.filter(target => parent.contains(target)));
|
|
21
|
+
for (const target of stop) {
|
|
22
|
+
for (let node = target; node && !keep.has(node); node = node.parentElement) {
|
|
23
|
+
keep.add(node);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const byAttribute = counts[attribute] ??= new WeakMap();
|
|
27
|
+
const own = theirOwn[attribute] ??= new WeakSet();
|
|
28
|
+
const marked = [];
|
|
29
|
+
const walk = node => {
|
|
30
|
+
if (stop.has(node)) return;
|
|
31
|
+
for (const child of node.children) {
|
|
32
|
+
if (keep.has(child)) {
|
|
33
|
+
walk(child);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const count = byAttribute.get(child) ?? 0;
|
|
37
|
+
if (count === 0) {
|
|
38
|
+
const value = child.getAttribute(attribute);
|
|
39
|
+
// `inert` is a boolean attribute: any value is inert. `aria-hidden="false"` isn't hidden.
|
|
40
|
+
const already = attribute === 'inert' ? value !== null : value !== null && value !== 'false';
|
|
41
|
+
if (already) own.add(child);else child.setAttribute(attribute, attribute === 'inert' ? '' : 'true');
|
|
42
|
+
child.setAttribute(marker, 'true');
|
|
43
|
+
}
|
|
44
|
+
byAttribute.set(child, count + 1);
|
|
45
|
+
marked.push(child);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
walk(parent);
|
|
49
|
+
let undone = false;
|
|
50
|
+
return () => {
|
|
51
|
+
if (undone) return;
|
|
52
|
+
undone = true;
|
|
53
|
+
for (const node of marked) {
|
|
54
|
+
const count = (byAttribute.get(node) ?? 1) - 1;
|
|
55
|
+
byAttribute.set(node, count);
|
|
56
|
+
if (count > 0) continue;
|
|
57
|
+
if (own.has(node)) own.delete(node);else node.removeAttribute(attribute);
|
|
58
|
+
node.removeAttribute(marker);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function start(targets, options) {
|
|
63
|
+
const elements = list(targets);
|
|
64
|
+
const parent = options.parent ?? elements[0]?.ownerDocument.body;
|
|
65
|
+
if (!parent) return undefined;
|
|
66
|
+
// Live regions and scripts stay as they are: an announcement outside a dialog is still heard.
|
|
67
|
+
elements.push(...parent.querySelectorAll('[aria-live], script'));
|
|
68
|
+
return [elements, parent];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Hides everything on the page from assistive technology but the targets, as the aria-hidden
|
|
73
|
+
* package's `hideOthers` (which Radix's modal parts use) does: `aria-hidden="true"` on every
|
|
74
|
+
* element that isn't a target, inside one or above one. Live regions (`aria-live`) stay heard.
|
|
75
|
+
* It returns the function that puts it all back; calls stack, so an element stays hidden until
|
|
76
|
+
* every call that hid it is undone, and one that was hidden already stays hidden.
|
|
77
|
+
*
|
|
78
|
+
* const undo = hideOthers(dialog)
|
|
79
|
+
* undo()
|
|
80
|
+
*
|
|
81
|
+
* Hidden elements can still take focus, so trap it inside the targets (`focusScope`), or use
|
|
82
|
+
* `inertOthers`, which a modal dialog does.
|
|
83
|
+
*/
|
|
84
|
+
function hideOthers(targets, options = {}) {
|
|
85
|
+
const started = start(targets, options);
|
|
86
|
+
if (!started) return () => {};
|
|
87
|
+
return applyToOthers(started[0], started[1], 'aria-hidden', 'data-aria-hidden');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Makes everything on the page inert but the targets, as a modal `<dialog>` does to the page
|
|
92
|
+
* behind it (and as the aria-hidden package's `inertOthers`): `inert` on every element that isn't
|
|
93
|
+
* a target, inside one or above one, so nothing else can be focused, clicked or read by
|
|
94
|
+
* assistive technology. Live regions (`aria-live`) are left alone, so a toast outside stays
|
|
95
|
+
* heard and usable. It returns the function that puts it all back; calls stack, as
|
|
96
|
+
* `hideOthers`' do.
|
|
97
|
+
*
|
|
98
|
+
* const undo = inertOthers([dialog, overlay])
|
|
99
|
+
* undo()
|
|
100
|
+
*/
|
|
101
|
+
function inertOthers(targets, options = {}) {
|
|
102
|
+
const started = start(targets, options);
|
|
103
|
+
if (!started) return () => {};
|
|
104
|
+
return applyToOthers(started[0], started[1], 'inert', 'data-inert-ed');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { hideOthers, inertOthers };
|
|
108
|
+
//# sourceMappingURL=hide-others.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hide-others.js","sources":["../src/hide-others.ts"],"sourcesContent":["/** Puts back what `hideOthers` or `inertOthers` changed. */\nexport type Undo = () => void\n\nexport interface HideOthersOptions {\n /** Where to start: only what's inside it is hidden. Default the targets' `<body>`. */\n parent?: Element\n}\n\ntype Targets = Element | ReadonlyArray<Element | null | undefined>\n\n/** How many live calls hide each element, by the attribute they set. */\nconst counts: Record<string, WeakMap<Element, number>> = {}\n/** Elements that had the attribute already, which are never given it back or taken off. */\nconst theirOwn: Record<string, WeakSet<Element>> = {}\n\nfunction list(targets: Targets): Element[] {\n const all = Array.isArray(targets) ? targets : [targets as Element]\n return all.filter((target): target is Element => target instanceof Element)\n}\n\n/**\n * Sets `attribute` on every element in `parent` but the targets, their ancestors and the\n * elements it keeps, as the aria-hidden package does: it walks down from `parent`, and at each\n * level marks the children that hold no target. Calls stack, so an element stays marked until\n * every call that marked it is undone, and an element that had the attribute before keeps it.\n */\nfunction applyToOthers(\n targets: Element[],\n parent: Element,\n attribute: string,\n marker: string,\n): Undo {\n const keep = new Set<Element>()\n const stop = new Set(targets.filter(target => parent.contains(target)))\n for (const target of stop) {\n for (let node: Element | null = target; node && !keep.has(node); node = node.parentElement) {\n keep.add(node)\n }\n }\n const byAttribute = (counts[attribute] ??= new WeakMap())\n const own = (theirOwn[attribute] ??= new WeakSet())\n const marked: Element[] = []\n\n const walk = (node: Element) => {\n if (stop.has(node)) return\n for (const child of node.children) {\n if (keep.has(child)) {\n walk(child)\n continue\n }\n const count = byAttribute.get(child) ?? 0\n if (count === 0) {\n const value = child.getAttribute(attribute)\n // `inert` is a boolean attribute: any value is inert. `aria-hidden=\"false\"` isn't hidden.\n const already = attribute === 'inert' ? value !== null : value !== null && value !== 'false'\n if (already) own.add(child)\n else child.setAttribute(attribute, attribute === 'inert' ? '' : 'true')\n child.setAttribute(marker, 'true')\n }\n byAttribute.set(child, count + 1)\n marked.push(child)\n }\n }\n walk(parent)\n\n let undone = false\n return () => {\n if (undone) return\n undone = true\n for (const node of marked) {\n const count = (byAttribute.get(node) ?? 1) - 1\n byAttribute.set(node, count)\n if (count > 0) continue\n if (own.has(node)) own.delete(node)\n else node.removeAttribute(attribute)\n node.removeAttribute(marker)\n }\n }\n}\n\nfunction start(targets: Targets, options: HideOthersOptions): [Element[], Element] | undefined {\n const elements = list(targets)\n const parent = options.parent ?? elements[0]?.ownerDocument.body\n if (!parent) return undefined\n // Live regions and scripts stay as they are: an announcement outside a dialog is still heard.\n elements.push(...parent.querySelectorAll('[aria-live], script'))\n return [elements, parent]\n}\n\n/**\n * Hides everything on the page from assistive technology but the targets, as the aria-hidden\n * package's `hideOthers` (which Radix's modal parts use) does: `aria-hidden=\"true\"` on every\n * element that isn't a target, inside one or above one. Live regions (`aria-live`) stay heard.\n * It returns the function that puts it all back; calls stack, so an element stays hidden until\n * every call that hid it is undone, and one that was hidden already stays hidden.\n *\n * const undo = hideOthers(dialog)\n * undo()\n *\n * Hidden elements can still take focus, so trap it inside the targets (`focusScope`), or use\n * `inertOthers`, which a modal dialog does.\n */\nexport function hideOthers(targets: Targets, options: HideOthersOptions = {}): Undo {\n const started = start(targets, options)\n if (!started) return () => {}\n return applyToOthers(started[0], started[1], 'aria-hidden', 'data-aria-hidden')\n}\n\n/**\n * Makes everything on the page inert but the targets, as a modal `<dialog>` does to the page\n * behind it (and as the aria-hidden package's `inertOthers`): `inert` on every element that isn't\n * a target, inside one or above one, so nothing else can be focused, clicked or read by\n * assistive technology. Live regions (`aria-live`) are left alone, so a toast outside stays\n * heard and usable. It returns the function that puts it all back; calls stack, as\n * `hideOthers`' do.\n *\n * const undo = inertOthers([dialog, overlay])\n * undo()\n */\nexport function inertOthers(targets: Targets, options: HideOthersOptions = {}): Undo {\n const started = start(targets, options)\n if (!started) return () => {}\n return applyToOthers(started[0], started[1], 'inert', 'data-inert-ed')\n}\n"],"names":["counts","theirOwn","list","targets","all","Array","isArray","filter","target","Element","applyToOthers","parent","attribute","marker","keep","Set","stop","contains","node","has","parentElement","add","byAttribute","WeakMap","own","WeakSet","marked","walk","child","children","count","get","value","getAttribute","already","setAttribute","set","push","undone","delete","removeAttribute","start","options","elements","ownerDocument","body","undefined","querySelectorAll","hideOthers","started","inertOthers"],"mappings":"AAAA;;AAUA;AACA,MAAMA,MAAgD,GAAG,EAAE;AAC3D;AACA,MAAMC,QAA0C,GAAG,EAAE;AAErD,SAASC,IAAIA,CAACC,OAAgB,EAAa;AACzC,EAAA,MAAMC,GAAG,GAAGC,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAY;EACnE,OAAOC,GAAG,CAACG,MAAM,CAAEC,MAAM,IAAwBA,MAAM,YAAYC,OAAO,CAAC;AAC7E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CACpBP,OAAkB,EAClBQ,MAAe,EACfC,SAAiB,EACjBC,MAAc,EACR;AACN,EAAA,MAAMC,IAAI,GAAG,IAAIC,GAAG,EAAW;AAC/B,EAAA,MAAMC,IAAI,GAAG,IAAID,GAAG,CAACZ,OAAO,CAACI,MAAM,CAACC,MAAM,IAAIG,MAAM,CAACM,QAAQ,CAACT,MAAM,CAAC,CAAC,CAAC;AACvE,EAAA,KAAK,MAAMA,MAAM,IAAIQ,IAAI,EAAE;IACzB,KAAK,IAAIE,IAAoB,GAAGV,MAAM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ACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASqC,UAAUA,CAAC7C,OAAgB,EAAEuC,OAA0B,GAAG,EAAE,EAAQ;AAClF,EAAA,MAAMO,OAAO,GAAGR,KAAK,CAACtC,OAAO,EAAEuC,OAAO,CAAC;AACvC,EAAA,IAAI,CAACO,OAAO,EAAE,OAAO,MAAM,CAAC,CAAC;AAC7B,EAAA,OAAOvC,aAAa,CAACuC,OAAO,CAAC,CAAC,CAAC,EAAEA,OAAO,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,kBAAkB,CAAC;AACjF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAWA,CAAC/C,OAAgB,EAAEuC,OAA0B,GAAG,EAAE,EAAQ;AACnF,EAAA,MAAMO,OAAO,GAAGR,KAAK,CAACtC,OAAO,EAAEuC,OAAO,CAAC;AACvC,EAAA,IAAI,CAACO,OAAO,EAAE,OAAO,MAAM,CAAC,CAAC;AAC7B,EAAA,OAAOvC,aAAa,CAACuC,OAAO,CAAC,CAAC,CAAC,EAAEA,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC;AACxE;;"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { array, hash } from '@ember/helper';
|
|
3
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
4
|
+
import Modifier from 'ember-modifier';
|
|
5
|
+
import { As } from './as.js';
|
|
6
|
+
import { controllable } from './controllable-state.js';
|
|
7
|
+
import { dismissable } from './dismiss.js';
|
|
8
|
+
import { idFor } from './id.js';
|
|
9
|
+
import { topLayer } from './layer.js';
|
|
10
|
+
import { part } from './part.js';
|
|
11
|
+
import { Presence } from './presence.js';
|
|
12
|
+
import { h as hoverIntent } from './hover-intent-Bxb83fgX.js';
|
|
13
|
+
import { p as popperOptions, a as anchorContent, P as PopperArrow, E as ElementRef, f as PlacedData, c as exposeProperties, d as displayContents } from './popper-BbTzV8dP.js';
|
|
14
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
15
|
+
import { setComponentTemplate } from '@ember/component';
|
|
16
|
+
import templateOnly from '@ember/component/template-only';
|
|
17
|
+
|
|
18
|
+
/** Radix's Popper defaults for a hover card: below its trigger, centred, touching it. */const CONTENT_DEFAULTS = {
|
|
19
|
+
side: 'bottom',
|
|
20
|
+
align: 'center',
|
|
21
|
+
sideOffset: 0
|
|
22
|
+
};
|
|
23
|
+
function isTouch(event) {
|
|
24
|
+
return event.pointerType === 'touch';
|
|
25
|
+
}
|
|
26
|
+
/** An `<a>`, or `@as`, that opens the card while the pointer rests on it or it has focus. */const HoverCardTrigger = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"a\" ...attributes {{@part}}>{{yield}}</As>", {
|
|
27
|
+
strictMode: true,
|
|
28
|
+
scope: () => ({
|
|
29
|
+
As
|
|
30
|
+
})
|
|
31
|
+
}), templateOnly());
|
|
32
|
+
/**
|
|
33
|
+
* What an open card does, as Radix's content does: a press inside lets the user select its text
|
|
34
|
+
* (and only its text) without the card closing, and the links and buttons inside are out of the
|
|
35
|
+
* tab order, since a hover card is for pointers.
|
|
36
|
+
*/
|
|
37
|
+
class HoverCardBehaviour extends Modifier {
|
|
38
|
+
#installed = false;
|
|
39
|
+
modify(content, _, {
|
|
40
|
+
card
|
|
41
|
+
}) {
|
|
42
|
+
if (this.#installed) return;
|
|
43
|
+
this.#installed = true;
|
|
44
|
+
const body = document.body.style;
|
|
45
|
+
let selecting = false;
|
|
46
|
+
const startSelecting = () => {
|
|
47
|
+
if (selecting) return;
|
|
48
|
+
selecting = true;
|
|
49
|
+
body.setProperty('user-select', 'none');
|
|
50
|
+
body.setProperty('-webkit-user-select', 'none');
|
|
51
|
+
content.style.setProperty('user-select', 'text');
|
|
52
|
+
content.style.setProperty('-webkit-user-select', 'text');
|
|
53
|
+
};
|
|
54
|
+
const stopSelecting = () => {
|
|
55
|
+
if (!selecting) return;
|
|
56
|
+
selecting = false;
|
|
57
|
+
body.removeProperty('user-select');
|
|
58
|
+
body.removeProperty('-webkit-user-select');
|
|
59
|
+
content.style.removeProperty('user-select');
|
|
60
|
+
content.style.removeProperty('-webkit-user-select');
|
|
61
|
+
};
|
|
62
|
+
const onPointerDown = event => {
|
|
63
|
+
if (event.target instanceof Node && content.contains(event.target)) startSelecting();
|
|
64
|
+
card.hasSelection = false;
|
|
65
|
+
card.isPointerDownOnContent = true;
|
|
66
|
+
};
|
|
67
|
+
let timer;
|
|
68
|
+
const onPointerUp = () => {
|
|
69
|
+
stopSelecting();
|
|
70
|
+
card.isPointerDownOnContent = false;
|
|
71
|
+
timer = setTimeout(() => {
|
|
72
|
+
if (document.getSelection()?.toString()) card.hasSelection = true;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const untab = () => {
|
|
76
|
+
const walker = document.createTreeWalker(content, NodeFilter.SHOW_ELEMENT);
|
|
77
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
78
|
+
if (node instanceof HTMLElement && node.tabIndex >= 0) node.setAttribute('tabindex', '-1');
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const observer = new MutationObserver(untab);
|
|
82
|
+
untab();
|
|
83
|
+
observer.observe(content, {
|
|
84
|
+
childList: true,
|
|
85
|
+
subtree: true
|
|
86
|
+
});
|
|
87
|
+
content.addEventListener('pointerdown', onPointerDown);
|
|
88
|
+
document.addEventListener('pointerup', onPointerUp);
|
|
89
|
+
registerDestructor(this, () => {
|
|
90
|
+
observer.disconnect();
|
|
91
|
+
content.removeEventListener('pointerdown', onPointerDown);
|
|
92
|
+
document.removeEventListener('pointerup', onPointerUp);
|
|
93
|
+
clearTimeout(timer);
|
|
94
|
+
stopSelecting();
|
|
95
|
+
card.hasSelection = false;
|
|
96
|
+
card.isPointerDownOnContent = false;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The card itself: in the top layer while it is open (and while it animates out), placed
|
|
102
|
+
* against its trigger (below it, by default) and flipped to stay in view. The pointer can move
|
|
103
|
+
* onto it, and Escape or a press outside closes it.
|
|
104
|
+
*/
|
|
105
|
+
class HoverCardContent extends Component {
|
|
106
|
+
get anchorOptions() {
|
|
107
|
+
const {
|
|
108
|
+
card
|
|
109
|
+
} = this.args;
|
|
110
|
+
return popperOptions(this.args, {}, CONTENT_DEFAULTS, {
|
|
111
|
+
arrow: card.arrowRef.value,
|
|
112
|
+
setData: card.placed.set
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
onEscapeKeyDown = event => this.args.onEscapeKeyDown?.(event);
|
|
116
|
+
onPointerDownOutside = event => this.args.onPointerDownOutside?.(event);
|
|
117
|
+
onFocusOutside = event => {
|
|
118
|
+
this.args.onFocusOutside?.(event);
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
};
|
|
121
|
+
onInteractOutside = event => this.args.onInteractOutside?.(event);
|
|
122
|
+
static {
|
|
123
|
+
setComponentTemplate(precompileTemplate("<Presence @present={{@card.isOpen}} @forceMount={{@forceMount}} as |presence|>\n <As @as={{@as}} @tag=\"div\" ...attributes {{presence.ref}} {{@card.content}} {{topLayer}} {{anchorContent @card.reference this.anchorOptions}} {{dismissable enabled=@card.isOpen onDismiss=@card.dismiss onEscapeKeyDown=this.onEscapeKeyDown onPointerDownOutside=this.onPointerDownOutside onFocusOutside=this.onFocusOutside onInteractOutside=this.onInteractOutside inside=(array @card.triggerRef.value)}} {{HoverCardBehaviour card=@card}}>{{yield}}</As>\n</Presence>", {
|
|
124
|
+
strictMode: true,
|
|
125
|
+
scope: () => ({
|
|
126
|
+
Presence,
|
|
127
|
+
As,
|
|
128
|
+
topLayer,
|
|
129
|
+
anchorContent,
|
|
130
|
+
dismissable,
|
|
131
|
+
array,
|
|
132
|
+
HoverCardBehaviour
|
|
133
|
+
})
|
|
134
|
+
}), this);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Radix's `HoverCard.Arrow`: an `<svg>` triangle on the card's edge, pointing at the trigger. */const HoverCardArrow = setComponentTemplate(precompileTemplate("{{#if (has-block)}}\n <PopperArrow @arrow={{@card.arrowRef}} @width={{@width}} @height={{@height}} ...attributes>\n {{yield}}\n </PopperArrow>\n{{else}}\n <PopperArrow @arrow={{@card.arrowRef}} @width={{@width}} @height={{@height}} ...attributes />\n{{/if}}", {
|
|
138
|
+
strictMode: true,
|
|
139
|
+
scope: () => ({
|
|
140
|
+
PopperArrow
|
|
141
|
+
})
|
|
142
|
+
}), templateOnly());
|
|
143
|
+
// ----- The hover card ------------------------------------------------------------------------
|
|
144
|
+
/** What a `<HoverCard>` takes. */
|
|
145
|
+
|
|
146
|
+
/** What a `<HoverCard>` yields. */
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* A preview of what is behind a link, for sighted users with a pointer, as Radix's HoverCard
|
|
150
|
+
* (which shadcn's is built on). It renders no box of its own, and yields its parts:
|
|
151
|
+
*
|
|
152
|
+
* <HoverCard @openDelay={{100}} @closeDelay={{200}} as |h|>
|
|
153
|
+
* <h.Trigger href="/@nextjs">@nextjs</h.Trigger>
|
|
154
|
+
* <h.Content @side="top" @align="start">…</h.Content>
|
|
155
|
+
* </HoverCard>
|
|
156
|
+
*
|
|
157
|
+
* It opens once the pointer has rested on the trigger for `@openDelay` (or the trigger has had
|
|
158
|
+
* focus as long), and closes `@closeDelay` after the pointer has left both the trigger and the
|
|
159
|
+
* card (or focus left), unless the user is selecting text in it; Escape and a press outside
|
|
160
|
+
* close it at once. Touch doesn't open it. The state is its own, or yours with `@open` and
|
|
161
|
+
* `@onOpenChange`.
|
|
162
|
+
*/
|
|
163
|
+
class HoverCard extends Component {
|
|
164
|
+
openState = controllable(this, 'open', false);
|
|
165
|
+
triggerRef = new ElementRef();
|
|
166
|
+
arrowRef = new ElementRef();
|
|
167
|
+
placed = new PlacedData();
|
|
168
|
+
intent = hoverIntent(this, this);
|
|
169
|
+
/** Whether the user selected text in the card, which keeps it open. */
|
|
170
|
+
hasSelection = false;
|
|
171
|
+
/** Whether a press inside the card is still down, which keeps it open. */
|
|
172
|
+
isPointerDownOnContent = false;
|
|
173
|
+
get id() {
|
|
174
|
+
return idFor(this);
|
|
175
|
+
}
|
|
176
|
+
get isOpen() {
|
|
177
|
+
return this.openState.value;
|
|
178
|
+
}
|
|
179
|
+
get state() {
|
|
180
|
+
return this.isOpen ? 'open' : 'closed';
|
|
181
|
+
}
|
|
182
|
+
get reference() {
|
|
183
|
+
return this.triggerRef.value;
|
|
184
|
+
}
|
|
185
|
+
get openDelay() {
|
|
186
|
+
return this.args.openDelay ?? 700;
|
|
187
|
+
}
|
|
188
|
+
get closeDelay() {
|
|
189
|
+
return this.args.closeDelay ?? 300;
|
|
190
|
+
}
|
|
191
|
+
get isHeld() {
|
|
192
|
+
return this.hasSelection || this.isPointerDownOnContent;
|
|
193
|
+
}
|
|
194
|
+
handleOpen = () => this.intent.enter();
|
|
195
|
+
handleClose = () => this.intent.leave();
|
|
196
|
+
setOpen = open => {
|
|
197
|
+
this.intent.cancel();
|
|
198
|
+
this.openState.set(open);
|
|
199
|
+
};
|
|
200
|
+
dismiss = _reason => this.setOpen(false);
|
|
201
|
+
trigger = part(() => ({
|
|
202
|
+
attributes: {
|
|
203
|
+
'data-state': this.state,
|
|
204
|
+
'data-test-jn-part': 'trigger'
|
|
205
|
+
},
|
|
206
|
+
on: {
|
|
207
|
+
pointerenter: event => !isTouch(event) && this.handleOpen(),
|
|
208
|
+
pointerleave: event => !isTouch(event) && this.handleClose(),
|
|
209
|
+
focus: this.handleOpen,
|
|
210
|
+
blur: this.handleClose,
|
|
211
|
+
// A touch would otherwise follow the link; the card isn't for touch.
|
|
212
|
+
touchstart: event => event.preventDefault()
|
|
213
|
+
},
|
|
214
|
+
element: element => {
|
|
215
|
+
this.triggerRef.set(element);
|
|
216
|
+
return () => this.triggerRef.release(element);
|
|
217
|
+
}
|
|
218
|
+
}));
|
|
219
|
+
content = part(() => ({
|
|
220
|
+
attributes: {
|
|
221
|
+
'data-state': this.state,
|
|
222
|
+
'data-test-jn-part': 'content',
|
|
223
|
+
'data-test-jn-owner': this.id
|
|
224
|
+
},
|
|
225
|
+
on: {
|
|
226
|
+
pointerenter: event => !isTouch(event) && this.handleOpen(),
|
|
227
|
+
pointerleave: event => !isTouch(event) && this.handleClose()
|
|
228
|
+
},
|
|
229
|
+
element: element => exposeProperties(element, 'hover-card')
|
|
230
|
+
}));
|
|
231
|
+
static {
|
|
232
|
+
setComponentTemplate(precompileTemplate("<div id={{this.id}} data-test-jn=\"hover-card\" data-test-jn-name={{@name}} ...attributes {{displayContents}}>\n {{yield (hash Trigger=(component HoverCardTrigger part=this.trigger) Content=(component HoverCardContent card=this) Arrow=(component HoverCardArrow card=this) trigger=this.trigger isOpen=this.isOpen setOpen=this.setOpen)}}\n</div>", {
|
|
233
|
+
strictMode: true,
|
|
234
|
+
scope: () => ({
|
|
235
|
+
displayContents,
|
|
236
|
+
hash,
|
|
237
|
+
HoverCardTrigger,
|
|
238
|
+
HoverCardContent,
|
|
239
|
+
HoverCardArrow
|
|
240
|
+
})
|
|
241
|
+
}), this);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export { HoverCard, HoverCard as default };
|
|
246
|
+
//# sourceMappingURL=hover-card.js.map
|