@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
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import Modifier from 'ember-modifier';
|
|
2
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
3
|
+
import { focusable, focusElement } from './focus.js';
|
|
4
|
+
import { State, Machine, transition, after } from '@switchyard-ts/core';
|
|
5
|
+
import { n } from 'decorator-transforms/runtime';
|
|
6
|
+
|
|
7
|
+
class SearchState extends State {
|
|
8
|
+
/** Nothing typed. */
|
|
9
|
+
static Idle = SearchState.of('idle');
|
|
10
|
+
/** Keys are adding up; the search clears `timeout` after the last one. */
|
|
11
|
+
static Typing = SearchState.of('typing');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A typeahead search, as a chart: each key adds to `search` and (re)starts the wait in
|
|
16
|
+
* `Typing`; the wait running out, or `reset()`, goes back to `Idle` and clears it.
|
|
17
|
+
*/
|
|
18
|
+
class TypeaheadSearch extends Machine {
|
|
19
|
+
// A plain clock, not the Ember test waiter one: `settled()` between keys must not outwait the
|
|
20
|
+
// search, or a test could never type "bl".
|
|
21
|
+
static clock = {
|
|
22
|
+
setTimeout: (fn, ms) => setTimeout(fn, ms),
|
|
23
|
+
clearTimeout: handle => clearTimeout(handle)
|
|
24
|
+
};
|
|
25
|
+
#timeout;
|
|
26
|
+
search = '';
|
|
27
|
+
constructor(timeout) {
|
|
28
|
+
super();
|
|
29
|
+
this.#timeout = timeout;
|
|
30
|
+
}
|
|
31
|
+
get timeout() {
|
|
32
|
+
return this.#timeout;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A key: add it to the search and restart the wait. */
|
|
36
|
+
type(key) {
|
|
37
|
+
this.search += key;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Clear the search now. */
|
|
41
|
+
static {
|
|
42
|
+
n(this.prototype, "type", [transition({
|
|
43
|
+
to: SearchState.Typing,
|
|
44
|
+
reenter: true
|
|
45
|
+
})]);
|
|
46
|
+
}
|
|
47
|
+
reset() {
|
|
48
|
+
this.search = '';
|
|
49
|
+
}
|
|
50
|
+
static {
|
|
51
|
+
n(this.prototype, "reset", [transition({
|
|
52
|
+
to: SearchState.Idle
|
|
53
|
+
})]);
|
|
54
|
+
}
|
|
55
|
+
expired() {
|
|
56
|
+
this.search = '';
|
|
57
|
+
}
|
|
58
|
+
static {
|
|
59
|
+
n(this.prototype, "expired", [after('timeout', {
|
|
60
|
+
from: SearchState.Typing,
|
|
61
|
+
to: SearchState.Idle
|
|
62
|
+
})]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** How long a search lasts after its last key, in milliseconds, as in Radix: one second. */
|
|
67
|
+
const TYPEAHEAD_TIMEOUT = 1000;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Whether a key press types ahead: one printable character, with no Ctrl, Alt or Meta held
|
|
71
|
+
* (Shift is fine, for capitals), as Radix's menus and select read it.
|
|
72
|
+
*/
|
|
73
|
+
function isTypeaheadKey(event) {
|
|
74
|
+
return event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The array, starting at `start` and wrapping round. */
|
|
78
|
+
function wrap(array, start) {
|
|
79
|
+
return array.map((_, index) => array[(start + index) % array.length]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The item a search moves to, as Radix's menus and select find it: the first item after the
|
|
84
|
+
* current one whose text starts with the search, ignoring case, wrapping round. A search of one
|
|
85
|
+
* repeated letter (`"aaa"`) cycles through the items starting with that letter; a one-letter
|
|
86
|
+
* search never matches the current item, so pressing a letter again moves on. Returns
|
|
87
|
+
* `undefined` when nothing else matches.
|
|
88
|
+
*
|
|
89
|
+
* getNextMatch(['Apple', 'Banana', 'Blueberry'], 'b', 'Banana') // 'Blueberry'
|
|
90
|
+
* getNextMatch(options, 'bl', current, option => option.label)
|
|
91
|
+
*
|
|
92
|
+
* @param items the candidates, in order (leave out disabled ones)
|
|
93
|
+
* @param search what has been typed so far
|
|
94
|
+
* @param current the item that is current now, if any
|
|
95
|
+
* @param textOf an item's text (default: the item itself, as a string)
|
|
96
|
+
*/
|
|
97
|
+
function getNextMatch(items, search, current, textOf = String) {
|
|
98
|
+
const isRepeated = search.length > 1 && Array.from(search).every(char => char === search[0]);
|
|
99
|
+
const normalized = (isRepeated ? search[0] : search).toLowerCase();
|
|
100
|
+
const currentIndex = current === undefined ? -1 : items.indexOf(current);
|
|
101
|
+
let candidates = wrap(items, Math.max(currentIndex, 0));
|
|
102
|
+
if (normalized.length === 1) candidates = candidates.filter(item => item !== current);
|
|
103
|
+
const next = candidates.find(item => textOf(item).toLowerCase().startsWith(normalized));
|
|
104
|
+
return next !== current ? next : undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The text typed so far in a typeahead search, as Radix keeps it: each key adds to it, and it
|
|
109
|
+
* clears a second (`timeout`) after the last key.
|
|
110
|
+
*
|
|
111
|
+
* typeahead = new Typeahead()
|
|
112
|
+
* onKeyDown = (event) => {
|
|
113
|
+
* if (!isTypeaheadKey(event)) return
|
|
114
|
+
* const match = getNextMatch(this.options, this.typeahead.type(event.key), this.current, o => o.label)
|
|
115
|
+
* if (match) this.highlight(match)
|
|
116
|
+
* }
|
|
117
|
+
*
|
|
118
|
+
* Call `dispose()` when its owner goes, to stop the timer.
|
|
119
|
+
*/
|
|
120
|
+
class Typeahead {
|
|
121
|
+
#search;
|
|
122
|
+
constructor(options = {}) {
|
|
123
|
+
this.#search = new TypeaheadSearch(options.timeout ?? TYPEAHEAD_TIMEOUT).start();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** What has been typed so far, or `''`. */
|
|
127
|
+
get search() {
|
|
128
|
+
return this.#search.search;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Whether a search is under way. While it is, Space is part of the search, not a press of
|
|
133
|
+
* the focused item: a menu item or option shouldn't activate on it.
|
|
134
|
+
*/
|
|
135
|
+
get isTyping() {
|
|
136
|
+
return this.#search.matches(SearchState.Typing);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Adds a key to the search, restarts the timer, and returns the search. */
|
|
140
|
+
type(key) {
|
|
141
|
+
this.#search.type(key);
|
|
142
|
+
return this.#search.search;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Clears the search now. */
|
|
146
|
+
reset() {
|
|
147
|
+
this.#search.reset();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Stops the timer. */
|
|
151
|
+
dispose() {
|
|
152
|
+
this.reset();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** An element's text for typeahead: its own, with whitespace collapsed. */
|
|
157
|
+
function textContentOf(element) {
|
|
158
|
+
return (element.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Whether an item says it is disabled. */
|
|
162
|
+
function isDisabledItem(element) {
|
|
163
|
+
return element.getAttribute('aria-disabled') === 'true' || element.hasAttribute('data-disabled');
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Typeahead on a container, as in Radix's menus: typing the start of an item's text moves focus
|
|
167
|
+
* to it. Keys add up for a second, so "ba" goes past "Apple" to "Banana", and pressing one
|
|
168
|
+
* letter again moves on to the next item starting with it.
|
|
169
|
+
*
|
|
170
|
+
* <div role="listbox" aria-label="Fruit" {{typeahead}}>
|
|
171
|
+
* <div role="option" tabindex="-1">Apple</div>
|
|
172
|
+
* <div role="option" tabindex="-1">Banana</div>
|
|
173
|
+
* </div>
|
|
174
|
+
*
|
|
175
|
+
* While a search is under way, Space is part of it. The modifier hears keys before the items
|
|
176
|
+
* do, and prevents that Space, so a button isn't pressed and an item's own Space handler sees
|
|
177
|
+
* `event.defaultPrevented` (a part's listeners skip it on their own, as Radix's do). The search
|
|
178
|
+
* clears when focus leaves the container.
|
|
179
|
+
*/
|
|
180
|
+
class typeahead extends Modifier {
|
|
181
|
+
#named = {};
|
|
182
|
+
#typeahead;
|
|
183
|
+
#timeout;
|
|
184
|
+
#installed = false;
|
|
185
|
+
modify(element, _, named) {
|
|
186
|
+
this.#named = named;
|
|
187
|
+
if (!this.#typeahead || this.#timeout !== named.timeout) {
|
|
188
|
+
this.#typeahead?.dispose();
|
|
189
|
+
this.#timeout = named.timeout;
|
|
190
|
+
this.#typeahead = new Typeahead({
|
|
191
|
+
timeout: named.timeout
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (!this.#installed) this.#install(element);
|
|
195
|
+
}
|
|
196
|
+
#install(element) {
|
|
197
|
+
this.#installed = true;
|
|
198
|
+
const onKeyDown = event => this.#onKeyDown(event, element);
|
|
199
|
+
const onFocusOut = event => {
|
|
200
|
+
const next = event.relatedTarget;
|
|
201
|
+
if (!(next instanceof Node) || !element.contains(next)) this.#typeahead?.reset();
|
|
202
|
+
};
|
|
203
|
+
// Before the items hear the key, so an item's own Space handling sees it prevented.
|
|
204
|
+
element.addEventListener('keydown', onKeyDown, true);
|
|
205
|
+
element.addEventListener('focusout', onFocusOut);
|
|
206
|
+
registerDestructor(this, () => {
|
|
207
|
+
element.removeEventListener('keydown', onKeyDown, true);
|
|
208
|
+
element.removeEventListener('focusout', onFocusOut);
|
|
209
|
+
this.#typeahead?.dispose();
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
#onKeyDown(event, element) {
|
|
213
|
+
const named = this.#named;
|
|
214
|
+
const search = this.#typeahead;
|
|
215
|
+
if (named.disabled || !search || !isTypeaheadKey(event)) return;
|
|
216
|
+
if (event.key === ' ' && search.isTyping) event.preventDefault();
|
|
217
|
+
// A space on its own starts no search: it presses the focused item.
|
|
218
|
+
if (event.key === ' ' && !search.isTyping) return;
|
|
219
|
+
const items = named.items?.() ?? focusable.findAll({
|
|
220
|
+
container: element,
|
|
221
|
+
includeProgrammaticallyFocusable: true
|
|
222
|
+
}).filter(item => !isDisabledItem(item));
|
|
223
|
+
const active = document.activeElement;
|
|
224
|
+
const current = items.find(item => item === active || item.contains(active));
|
|
225
|
+
const textOf = named.textValue ?? textContentOf;
|
|
226
|
+
const match = getNextMatch(items, search.type(event.key), current, textOf);
|
|
227
|
+
if (!match) return;
|
|
228
|
+
if (named.onMatch) named.onMatch(match, event);else focusElement(match);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export { TYPEAHEAD_TIMEOUT, Typeahead, getNextMatch, isTypeaheadKey, typeahead };
|
|
233
|
+
//# sourceMappingURL=typeahead.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeahead.js","sources":["../src/-private/typeahead-search.ts","../src/typeahead.ts"],"sourcesContent":["import { after, Machine, State, transition, type Clock } from '@switchyard-ts/core'\n\nexport class SearchState extends State {\n declare private readonly brand: never\n /** Nothing typed. */\n static Idle = SearchState.of('idle')\n /** Keys are adding up; the search clears `timeout` after the last one. */\n static Typing = SearchState.of('typing')\n}\n\n/**\n * A typeahead search, as a chart: each key adds to `search` and (re)starts the wait in\n * `Typing`; the wait running out, or `reset()`, goes back to `Idle` and clears it.\n */\nexport class TypeaheadSearch extends Machine<SearchState> {\n // A plain clock, not the Ember test waiter one: `settled()` between keys must not outwait the\n // search, or a test could never type \"bl\".\n static override clock: Clock = {\n setTimeout: (fn, ms) => setTimeout(fn, ms),\n clearTimeout: handle => clearTimeout(handle as ReturnType<typeof setTimeout>),\n }\n\n readonly #timeout: number\n search = ''\n\n constructor(timeout: number) {\n super()\n this.#timeout = timeout\n }\n\n get timeout(): number {\n return this.#timeout\n }\n\n /** A key: add it to the search and restart the wait. */\n @transition({ to: SearchState.Typing, reenter: true })\n type(key: string) {\n this.search += key\n }\n\n /** Clear the search now. */\n @transition({ to: SearchState.Idle })\n reset() {\n this.search = ''\n }\n\n @after('timeout', { from: SearchState.Typing, to: SearchState.Idle })\n expired() {\n this.search = ''\n }\n}\n","import Modifier from 'ember-modifier'\nimport { registerDestructor } from '@ember/destroyable'\nimport { focusElement, focusable } from './focus.ts'\nimport { SearchState, TypeaheadSearch } from './-private/typeahead-search.ts'\n\n/** How long a search lasts after its last key, in milliseconds, as in Radix: one second. */\nexport const TYPEAHEAD_TIMEOUT = 1000\n\n/**\n * Whether a key press types ahead: one printable character, with no Ctrl, Alt or Meta held\n * (Shift is fine, for capitals), as Radix's menus and select read it.\n */\nexport function isTypeaheadKey(\n event: Pick<KeyboardEvent, 'key' | 'ctrlKey' | 'altKey' | 'metaKey'>,\n) {\n return event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey\n}\n\n/** The array, starting at `start` and wrapping round. */\nfunction wrap<T>(array: readonly T[], start: number): T[] {\n return array.map((_, index) => array[(start + index) % array.length]!)\n}\n\n/**\n * The item a search moves to, as Radix's menus and select find it: the first item after the\n * current one whose text starts with the search, ignoring case, wrapping round. A search of one\n * repeated letter (`\"aaa\"`) cycles through the items starting with that letter; a one-letter\n * search never matches the current item, so pressing a letter again moves on. Returns\n * `undefined` when nothing else matches.\n *\n * getNextMatch(['Apple', 'Banana', 'Blueberry'], 'b', 'Banana') // 'Blueberry'\n * getNextMatch(options, 'bl', current, option => option.label)\n *\n * @param items the candidates, in order (leave out disabled ones)\n * @param search what has been typed so far\n * @param current the item that is current now, if any\n * @param textOf an item's text (default: the item itself, as a string)\n */\nexport function getNextMatch<T>(\n items: readonly T[],\n search: string,\n current?: T,\n textOf: (item: T) => string = String,\n): T | undefined {\n const isRepeated = search.length > 1 && Array.from(search).every(char => char === search[0])\n const normalized = (isRepeated ? search[0]! : search).toLowerCase()\n const currentIndex = current === undefined ? -1 : items.indexOf(current)\n let candidates = wrap(items, Math.max(currentIndex, 0))\n if (normalized.length === 1) candidates = candidates.filter(item => item !== current)\n const next = candidates.find(item => textOf(item).toLowerCase().startsWith(normalized))\n return next !== current ? next : undefined\n}\n\n/**\n * The text typed so far in a typeahead search, as Radix keeps it: each key adds to it, and it\n * clears a second (`timeout`) after the last key.\n *\n * typeahead = new Typeahead()\n * onKeyDown = (event) => {\n * if (!isTypeaheadKey(event)) return\n * const match = getNextMatch(this.options, this.typeahead.type(event.key), this.current, o => o.label)\n * if (match) this.highlight(match)\n * }\n *\n * Call `dispose()` when its owner goes, to stop the timer.\n */\nexport class Typeahead {\n readonly #search: TypeaheadSearch\n\n constructor(options: { timeout?: number } = {}) {\n this.#search = new TypeaheadSearch(options.timeout ?? TYPEAHEAD_TIMEOUT).start()\n }\n\n /** What has been typed so far, or `''`. */\n get search(): string {\n return this.#search.search\n }\n\n /**\n * Whether a search is under way. While it is, Space is part of the search, not a press of\n * the focused item: a menu item or option shouldn't activate on it.\n */\n get isTyping(): boolean {\n return this.#search.matches(SearchState.Typing)\n }\n\n /** Adds a key to the search, restarts the timer, and returns the search. */\n type(key: string): string {\n this.#search.type(key)\n return this.#search.search\n }\n\n /** Clears the search now. */\n reset(): void {\n this.#search.reset()\n }\n\n /** Stops the timer. */\n dispose(): void {\n this.reset()\n }\n}\n\n/** An element's text for typeahead: its own, with whitespace collapsed. */\nfunction textContentOf(element: HTMLElement): string {\n return (element.textContent ?? '').replace(/\\s+/g, ' ').trim()\n}\n\n/** Whether an item says it is disabled. */\nfunction isDisabledItem(element: HTMLElement): boolean {\n return element.getAttribute('aria-disabled') === 'true' || element.hasAttribute('data-disabled')\n}\n\ninterface TypeaheadSignature {\n Element: HTMLElement\n Args: {\n Named: {\n /**\n * The items to search, in order. Default: the focusable elements inside (those with\n * `tabindex=\"-1\"` too), leaving out any with `aria-disabled=\"true\"` or `data-disabled`.\n */\n items?: () => HTMLElement[]\n /** An item's text. Default: its `textContent`, trimmed; give one for icons or extra text. */\n textValue?: (item: HTMLElement) => string\n /** Called with the matching item. Default: focus it. */\n onMatch?: (item: HTMLElement, event: KeyboardEvent) => void\n /** How long a search lasts after its last key. Default one second. */\n timeout?: number\n /** Turn it off. */\n disabled?: boolean\n }\n }\n}\n\n/**\n * Typeahead on a container, as in Radix's menus: typing the start of an item's text moves focus\n * to it. Keys add up for a second, so \"ba\" goes past \"Apple\" to \"Banana\", and pressing one\n * letter again moves on to the next item starting with it.\n *\n * <div role=\"listbox\" aria-label=\"Fruit\" {{typeahead}}>\n * <div role=\"option\" tabindex=\"-1\">Apple</div>\n * <div role=\"option\" tabindex=\"-1\">Banana</div>\n * </div>\n *\n * While a search is under way, Space is part of it. The modifier hears keys before the items\n * do, and prevents that Space, so a button isn't pressed and an item's own Space handler sees\n * `event.defaultPrevented` (a part's listeners skip it on their own, as Radix's do). The search\n * clears when focus leaves the container.\n */\nexport class typeahead extends Modifier<TypeaheadSignature> {\n #named: TypeaheadSignature['Args']['Named'] = {}\n #typeahead: Typeahead | undefined\n #timeout: number | undefined\n #installed = false\n\n override modify(element: HTMLElement, _: [], named: TypeaheadSignature['Args']['Named']): void {\n this.#named = named\n if (!this.#typeahead || this.#timeout !== named.timeout) {\n this.#typeahead?.dispose()\n this.#timeout = named.timeout\n this.#typeahead = new Typeahead({ timeout: named.timeout })\n }\n if (!this.#installed) this.#install(element)\n }\n\n #install(element: HTMLElement): void {\n this.#installed = true\n const onKeyDown = (event: KeyboardEvent) => this.#onKeyDown(event, element)\n const onFocusOut = (event: FocusEvent) => {\n const next = event.relatedTarget\n if (!(next instanceof Node) || !element.contains(next)) this.#typeahead?.reset()\n }\n // Before the items hear the key, so an item's own Space handling sees it prevented.\n element.addEventListener('keydown', onKeyDown, true)\n element.addEventListener('focusout', onFocusOut)\n registerDestructor(this, () => {\n element.removeEventListener('keydown', onKeyDown, true)\n element.removeEventListener('focusout', onFocusOut)\n this.#typeahead?.dispose()\n })\n }\n\n #onKeyDown(event: KeyboardEvent, element: HTMLElement): void {\n const named = this.#named\n const search = this.#typeahead\n if (named.disabled || !search || !isTypeaheadKey(event)) return\n if (event.key === ' ' && search.isTyping) event.preventDefault()\n // A space on its own starts no search: it presses the focused item.\n if (event.key === ' ' && !search.isTyping) return\n\n const items =\n named.items?.() ??\n focusable\n .findAll({ container: element, includeProgrammaticallyFocusable: true })\n .filter(item => !isDisabledItem(item))\n const active = document.activeElement\n const current = items.find(item => item === active || item.contains(active))\n const textOf = named.textValue ?? textContentOf\n const match = getNextMatch(items, search.type(event.key), current, textOf)\n if (!match) return\n if (named.onMatch) named.onMatch(match, event)\n else focusElement(match)\n }\n}\n"],"names":["SearchState","State","Idle","of","Typing","TypeaheadSearch","Machine","clock","setTimeout","fn","ms","clearTimeout","handle","search","constructor","timeout","type","key","n","prototype","transition","to","reenter","reset","expired","after","from","TYPEAHEAD_TIMEOUT","isTypeaheadKey","event","length","ctrlKey","altKey","metaKey","wrap","array","start","map","_","index","getNextMatch","items","current","textOf","String","isRepeated","Array","every","char","normalized","toLowerCase","currentIndex","undefined","indexOf","candidates","Math","max","filter","item","next","find","startsWith","Typeahead","options","isTyping","matches","dispose","textContentOf","element","textContent","replace","trim","isDisabledItem","getAttribute","hasAttribute","typeahead","Modifier","modify","named","#install","onKeyDown","onFocusOut","relatedTarget","Node","contains","addEventListener","registerDestructor","removeEventListener","#onKeyDown","disabled","preventDefault","focusable","findAll","container","includeProgrammaticallyFocusable","active","document","activeElement","textValue","match","onMatch","focusElement"],"mappings":";;;;;;AAEO,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AAChE;IACA,IAAI7D,KAAK,CAACZ,GAAG,KAAK,GAAG,IAAI,CAACJ,MAAM,CAACmD,QAAQ,EAAE;IAE3C,MAAMvB,KAAK,GACTqC,KAAK,CAACrC,KAAK,IAAI,IACfkD,SAAS,CACNC,OAAO,CAAC;AAAEC,MAAAA,SAAS,EAAEzB,OAAO;AAAE0B,MAAAA,gCAAgC,EAAE;KAAM,CAAC,CACvErC,MAAM,CAACC,IAAI,IAAI,CAACc,cAAc,CAACd,IAAI,CAAC,CAAC;AAC1C,IAAA,MAAMqC,MAAM,GAAGC,QAAQ,CAACC,aAAa;AACrC,IAAA,MAAMvD,OAAO,GAAGD,KAAK,CAACmB,IAAI,CAACF,IAAI,IAAIA,IAAI,KAAKqC,MAAM,IAAIrC,IAAI,CAAC0B,QAAQ,CAACW,MAAM,CAAC,CAAC;AAC5E,IAAA,MAAMpD,MAAM,GAAGmC,KAAK,CAACoB,SAAS,IAAI/B,aAAa;AAC/C,IAAA,MAAMgC,KAAK,GAAG3D,YAAY,CAACC,KAAK,EAAE5B,MAAM,CAACG,IAAI,CAACa,KAAK,CAACZ,GAAG,CAAC,EAAEyB,OAAO,EAAEC,MAAM,CAAC;IAC1E,IAAI,CAACwD,KAAK,EAAE;AACZ,IAAA,IAAIrB,KAAK,CAACsB,OAAO,EAAEtB,KAAK,CAACsB,OAAO,CAACD,KAAK,EAAEtE,KAAK,CAAC,CAAA,KACzCwE,YAAY,CAACF,KAAK,CAAC;AAC1B,EAAA;AACF;;"}
|
package/dist/viewport.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
4
|
+
import { modifier } from 'ember-modifier';
|
|
5
|
+
import { As } from './as.js';
|
|
6
|
+
import { S as SharedObserver } from './observers-aItWe029.js';
|
|
7
|
+
import { service } from './service.js';
|
|
8
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
9
|
+
import { setComponentTemplate } from '@ember/component';
|
|
10
|
+
import { g, i } from 'decorator-transforms/runtime';
|
|
11
|
+
|
|
12
|
+
function keyOf(options) {
|
|
13
|
+
const threshold = [options.threshold ?? 0].flat().join(',');
|
|
14
|
+
return `${options.rootMargin ?? '0px'}|${threshold}`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The app's intersection observers: one `IntersectionObserver` for each set of options,
|
|
18
|
+
* however many elements and callbacks use it. Get it with `viewport(this)`.
|
|
19
|
+
*/
|
|
20
|
+
class ViewportObservers {
|
|
21
|
+
#observers = new Map();
|
|
22
|
+
constructor() {
|
|
23
|
+
registerDestructor(this, () => {
|
|
24
|
+
for (const observer of this.#observers.values()) observer.disconnect();
|
|
25
|
+
this.#observers.clear();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Calls `callback` with an `IntersectionObserverEntry` each time `element` crosses into or
|
|
30
|
+
* out of the viewport (or past a `threshold`), and once at the start with where it is now.
|
|
31
|
+
* The options pick the observer; every element observed with the same options shares one.
|
|
32
|
+
*/
|
|
33
|
+
observe(element, callback, options = {}) {
|
|
34
|
+
const key = keyOf(options);
|
|
35
|
+
let observer = this.#observers.get(key);
|
|
36
|
+
if (!observer) {
|
|
37
|
+
observer = new SharedObserver(deliver => new IntersectionObserver(deliver, {
|
|
38
|
+
rootMargin: options.rootMargin ?? '0px',
|
|
39
|
+
threshold: options.threshold ?? 0
|
|
40
|
+
}));
|
|
41
|
+
this.#observers.set(key, observer);
|
|
42
|
+
}
|
|
43
|
+
observer.observe(element, callback);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Stops calling `callback` for `element`. Pass the same function `observe` was given, as
|
|
47
|
+
* with `removeEventListener`.
|
|
48
|
+
*/
|
|
49
|
+
unobserve(element, callback) {
|
|
50
|
+
for (const observer of this.#observers.values()) observer.unobserve(element, callback);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The app's intersection observers (one per owner, so one per test), for knowing when
|
|
55
|
+
* elements scroll into view without an `IntersectionObserver` each:
|
|
56
|
+
*
|
|
57
|
+
* class Row extends Component {
|
|
58
|
+
* @tracked seen = false
|
|
59
|
+
*
|
|
60
|
+
* watch = modifier(element => {
|
|
61
|
+
* const observers = viewport(this)
|
|
62
|
+
* const onChange = (entry: IntersectionObserverEntry) => (this.seen = entry.isIntersecting)
|
|
63
|
+
* observers.observe(element, onChange, { rootMargin: '100px' })
|
|
64
|
+
* return () => observers.unobserve(element, onChange)
|
|
65
|
+
* })
|
|
66
|
+
* }
|
|
67
|
+
*
|
|
68
|
+
* It is ember-primitives' `viewport`, which shares one observer; this one also honours the
|
|
69
|
+
* options, with one observer for each set of them.
|
|
70
|
+
*
|
|
71
|
+
* @param context anything with an owner, or the owner itself
|
|
72
|
+
*/
|
|
73
|
+
function viewport(context) {
|
|
74
|
+
return service(context, ViewportObservers);
|
|
75
|
+
}
|
|
76
|
+
/** How `InViewport` renders its block: inside its element, or in place of it. */
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Renders its block only once it comes near the viewport, for content below the fold that
|
|
80
|
+
* is expensive to render, or that measures itself on render:
|
|
81
|
+
*
|
|
82
|
+
* <InViewport @rootMargin="200px" class="chart-slot">
|
|
83
|
+
* <RevenueChart />
|
|
84
|
+
* </InViewport>
|
|
85
|
+
*
|
|
86
|
+
* Until then it renders an empty element (a `div`, or `@tagName`), with its attributes, to be
|
|
87
|
+
* watched; give it the size the content will have, so the page doesn't jump. Once the block
|
|
88
|
+
* renders it stays, wherever the page scrolls. With `@mode="replace"`, the block takes the
|
|
89
|
+
* element's place rather than going inside it. It is ember-primitives' `InViewport`, with
|
|
90
|
+
* `@rootMargin` added.
|
|
91
|
+
*/
|
|
92
|
+
class InViewport extends Component {
|
|
93
|
+
static {
|
|
94
|
+
g(this.prototype, "hasIntersected", [tracked], function () {
|
|
95
|
+
return false;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
#hasIntersected = (i(this, "hasIntersected"), void 0);
|
|
99
|
+
get mode() {
|
|
100
|
+
const mode = this.args.mode ?? 'contain';
|
|
101
|
+
if (mode !== 'contain' && mode !== 'replace') {
|
|
102
|
+
throw new Error(`Joinery: InViewport's @mode is "contain" or "replace", not "${mode}"`);
|
|
103
|
+
}
|
|
104
|
+
return mode;
|
|
105
|
+
}
|
|
106
|
+
get isReplacing() {
|
|
107
|
+
return this.mode === 'replace';
|
|
108
|
+
}
|
|
109
|
+
get tagName() {
|
|
110
|
+
return this.args.tagName ?? 'div';
|
|
111
|
+
}
|
|
112
|
+
handle = entry => {
|
|
113
|
+
if (!entry.isIntersecting || this.hasIntersected) return;
|
|
114
|
+
this.hasIntersected = true;
|
|
115
|
+
viewport(this).unobserve(entry.target, this.handle);
|
|
116
|
+
};
|
|
117
|
+
observe = modifier((element, _, {
|
|
118
|
+
rootMargin
|
|
119
|
+
}) => {
|
|
120
|
+
if (this.hasIntersected) return;
|
|
121
|
+
const observers = viewport(this);
|
|
122
|
+
observers.observe(element, this.handle, {
|
|
123
|
+
rootMargin
|
|
124
|
+
});
|
|
125
|
+
return () => observers.unobserve(element, this.handle);
|
|
126
|
+
});
|
|
127
|
+
static {
|
|
128
|
+
setComponentTemplate(precompileTemplate("{{#if this.isReplacing}}\n {{#if this.hasIntersected}}\n {{yield}}\n {{else}}\n <As @as={{this.tagName}} {{this.observe rootMargin=@rootMargin}} ...attributes />\n {{/if}}\n{{else}}\n <As @as={{this.tagName}} {{this.observe rootMargin=@rootMargin}} ...attributes>\n {{#if this.hasIntersected}}\n {{yield}}\n {{/if}}\n </As>\n{{/if}}", {
|
|
129
|
+
strictMode: true,
|
|
130
|
+
scope: () => ({
|
|
131
|
+
As
|
|
132
|
+
})
|
|
133
|
+
}), this);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { InViewport, ViewportObservers, viewport };
|
|
138
|
+
//# sourceMappingURL=viewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.js","sources":["../src/viewport.gts"],"sourcesContent":["import Component from '@glimmer/component'\nimport { tracked } from '@glimmer/tracking'\nimport { registerDestructor } from '@ember/destroyable'\nimport { modifier } from 'ember-modifier'\nimport { As, type TagName } from './as.gts'\nimport { SharedObserver, type EntryCallback } from './-private/observers.ts'\nimport { service } from './service.ts'\n\nexport interface ViewportOptions {\n /**\n * A margin around the viewport, as CSS writes `margin` (`'200px'`, `'10% 0px'`): a positive\n * one counts an element as visible before it scrolls in. Default `'0px'`.\n */\n rootMargin?: string\n /**\n * How much of the element must be visible for the callback to run: `0` (the default) as soon\n * as one pixel is, `1` when all of it is, or a list (`[0, 0.5, 1]`) to hear each step.\n */\n threshold?: number | number[]\n}\n\nfunction keyOf(options: ViewportOptions): string {\n const threshold = [options.threshold ?? 0].flat().join(',')\n return `${options.rootMargin ?? '0px'}|${threshold}`\n}\n\n/**\n * The app's intersection observers: one `IntersectionObserver` for each set of options,\n * however many elements and callbacks use it. Get it with `viewport(this)`.\n */\nexport class ViewportObservers {\n readonly #observers = new Map<string, SharedObserver<IntersectionObserverEntry>>()\n\n constructor() {\n registerDestructor(this, () => {\n for (const observer of this.#observers.values()) observer.disconnect()\n this.#observers.clear()\n })\n }\n\n /**\n * Calls `callback` with an `IntersectionObserverEntry` each time `element` crosses into or\n * out of the viewport (or past a `threshold`), and once at the start with where it is now.\n * The options pick the observer; every element observed with the same options shares one.\n */\n observe(\n element: Element,\n callback: EntryCallback<IntersectionObserverEntry>,\n options: ViewportOptions = {},\n ): void {\n const key = keyOf(options)\n let observer = this.#observers.get(key)\n if (!observer) {\n observer = new SharedObserver<IntersectionObserverEntry>(\n deliver =>\n new IntersectionObserver(deliver, {\n rootMargin: options.rootMargin ?? '0px',\n threshold: options.threshold ?? 0,\n }),\n )\n this.#observers.set(key, observer)\n }\n observer.observe(element, callback)\n }\n\n /**\n * Stops calling `callback` for `element`. Pass the same function `observe` was given, as\n * with `removeEventListener`.\n */\n unobserve(\n element: Element | null | undefined,\n callback: EntryCallback<IntersectionObserverEntry>,\n ): void {\n for (const observer of this.#observers.values()) observer.unobserve(element, callback)\n }\n}\n\n/**\n * The app's intersection observers (one per owner, so one per test), for knowing when\n * elements scroll into view without an `IntersectionObserver` each:\n *\n * class Row extends Component {\n * @tracked seen = false\n *\n * watch = modifier(element => {\n * const observers = viewport(this)\n * const onChange = (entry: IntersectionObserverEntry) => (this.seen = entry.isIntersecting)\n * observers.observe(element, onChange, { rootMargin: '100px' })\n * return () => observers.unobserve(element, onChange)\n * })\n * }\n *\n * It is ember-primitives' `viewport`, which shares one observer; this one also honours the\n * options, with one observer for each set of them.\n *\n * @param context anything with an owner, or the owner itself\n */\nexport function viewport(context: object): ViewportObservers {\n return service(context, ViewportObservers)\n}\n\n/** How `InViewport` renders its block: inside its element, or in place of it. */\nexport type InViewportMode = 'contain' | 'replace'\n\nexport interface InViewportSignature {\n Element: HTMLElement\n Args: {\n /**\n * `contain` (the default) renders the block inside the element once it is near the\n * viewport; `replace` renders the block in place of the element, which goes.\n */\n mode?: InViewportMode\n /** The element's tag, before and (in `contain` mode) after. Default `div`. */\n tagName?: TagName\n /**\n * How near the viewport counts, as `IntersectionObserver`'s `rootMargin`: `'200px'` renders\n * the block 200px before it would scroll in. Default `'0px'`.\n */\n rootMargin?: string\n }\n Blocks: {\n /** What renders once the element has come near the viewport, and stays from then on. */\n default: []\n }\n}\n\n/**\n * Renders its block only once it comes near the viewport, for content below the fold that\n * is expensive to render, or that measures itself on render:\n *\n * <InViewport @rootMargin=\"200px\" class=\"chart-slot\">\n * <RevenueChart />\n * </InViewport>\n *\n * Until then it renders an empty element (a `div`, or `@tagName`), with its attributes, to be\n * watched; give it the size the content will have, so the page doesn't jump. Once the block\n * renders it stays, wherever the page scrolls. With `@mode=\"replace\"`, the block takes the\n * element's place rather than going inside it. It is ember-primitives' `InViewport`, with\n * `@rootMargin` added.\n */\nexport class InViewport extends Component<InViewportSignature> {\n @tracked hasIntersected = false\n\n get mode(): InViewportMode {\n const mode = this.args.mode ?? 'contain'\n if (mode !== 'contain' && mode !== 'replace') {\n throw new Error(`Joinery: InViewport's @mode is \"contain\" or \"replace\", not \"${mode}\"`)\n }\n return mode\n }\n\n get isReplacing(): boolean {\n return this.mode === 'replace'\n }\n\n get tagName(): TagName {\n return this.args.tagName ?? 'div'\n }\n\n handle = (entry: IntersectionObserverEntry): void => {\n if (!entry.isIntersecting || this.hasIntersected) return\n this.hasIntersected = true\n viewport(this).unobserve(entry.target, this.handle)\n }\n\n observe = modifier((element: Element, _: [], { rootMargin }: { rootMargin?: string }) => {\n if (this.hasIntersected) return\n const observers = viewport(this)\n observers.observe(element, this.handle, { rootMargin })\n return () => observers.unobserve(element, this.handle)\n })\n\n <template>\n {{#if this.isReplacing}}\n {{#if this.hasIntersected}}\n {{yield}}\n {{else}}\n <As @as={{this.tagName}} {{this.observe rootMargin=@rootMargin}} ...attributes />\n {{/if}}\n {{else}}\n <As @as={{this.tagName}} {{this.observe rootMargin=@rootMargin}} ...attributes>\n {{#if this.hasIntersected}}\n {{yield}}\n {{/if}}\n </As>\n {{/if}}\n </template>\n}\n"],"names":["keyOf","options","threshold","flat","join","rootMargin","ViewportObservers","Map","constructor","registerDestructor","observer","values","disconnect","clear","observe","element","callback","key","get","SharedObserver","deliver","IntersectionObserver","set","unobserve","viewport","context","service","InViewport","Component","g","prototype","tracked","i","mode","args","Error","isReplacing","tagName","handle","entry","isIntersecting","hasIntersected","target","modifier","_","observers","setComponentTemplate","precompileTemplate","strictMode","scope","As"],"mappings":";;;;;;;;;;;AAqBA,SAASA,KAAAA,CAAMC,OAAwB,EAAS;AAC9C,EAAA,MAAMC,SAAA,GAAY,CAACD,OAAA,CAAQC,SAAS,IAAI,CAAA,CAAE,CAACC,IAAI,EAAA,CAAGC,IAAI,CAAC,GAAA,CAAA;EACvD,OAAO,CAAA,EAAGH,OAAA,CAAQI,UAAU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AAI,CAACoC,cAAc,EAAE;AACzB,IAAA,MAAMI,SAAA,GAAYrB,SAAS,IAAI,CAAA;IAC/BqB,SAAA,CAAU/B,OAAO,CAACC,OAAA,EAAS,IAAI,CAACuB,MAAM,EAAE;AAAEjC,MAAAA;AAAW,KAAA,CAAA;IACrD,OAAO,MAAMwC,SAAA,CAAUtB,SAAS,CAACR,OAAA,EAAS,IAAI,CAACuB,MAAM,CAAA;AACvD,EAAA,CAAA,CAAA;AAEA,EAAA;IAAAQ,oBAAA,CAAAC,kBAAA,CAAA,oWAAA,EAcA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { modifier } from 'ember-modifier';
|
|
2
|
+
import { As } from './as.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 = [['position', 'absolute'], ['border', '0'], ['width', '1px'], ['height', '1px'], ['padding', '0'], ['margin', '-1px'], ['overflow', 'hidden'], ['clip', 'rect(0, 0, 0, 0)'], ['white-space', 'nowrap'], ['word-wrap', 'normal']];
|
|
8
|
+
/**
|
|
9
|
+
* Hides any element visually and keeps it for assistive technology, like ember-primitives'
|
|
10
|
+
* `visually-hidden` attribute, without needing a style sheet. The element's other inline
|
|
11
|
+
* styles stay, and the ones it replaced come back when the modifier goes.
|
|
12
|
+
*
|
|
13
|
+
* <label for="search" {{visuallyHidden}}>Search</label>
|
|
14
|
+
*/
|
|
15
|
+
const visuallyHidden = modifier(element => {
|
|
16
|
+
const {
|
|
17
|
+
style
|
|
18
|
+
} = element;
|
|
19
|
+
const previous = STYLES.map(([property]) => [property, style.getPropertyValue(property), style.getPropertyPriority(property)]);
|
|
20
|
+
for (const [property, value] of STYLES) style.setProperty(property, value);
|
|
21
|
+
return () => {
|
|
22
|
+
for (const [property, value, priority] of previous) {
|
|
23
|
+
if (value) style.setProperty(property, value, priority);else style.removeProperty(property);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Content that screen readers read and sighted users don't see, such as an icon button's
|
|
29
|
+
* label. It renders a `span` (or `@as`) with the visually-hidden styles inline, so it needs
|
|
30
|
+
* no CSS.
|
|
31
|
+
*
|
|
32
|
+
* <button type="button">
|
|
33
|
+
* <XIcon />
|
|
34
|
+
* <VisuallyHidden>Close</VisuallyHidden>
|
|
35
|
+
* </button>
|
|
36
|
+
*
|
|
37
|
+
* It wraps content, so it isn't a component root for the harnesses: a part inside it still
|
|
38
|
+
* belongs to the component around it.
|
|
39
|
+
*/
|
|
40
|
+
const VisuallyHidden = setComponentTemplate(precompileTemplate("<As @as={{@as}} @tag=\"span\" data-slot=\"visually-hidden\" ...attributes {{visuallyHidden}}>\n {{yield}}\n</As>", {
|
|
41
|
+
strictMode: true,
|
|
42
|
+
scope: () => ({
|
|
43
|
+
As,
|
|
44
|
+
visuallyHidden
|
|
45
|
+
})
|
|
46
|
+
}), templateOnly());
|
|
47
|
+
|
|
48
|
+
export { VisuallyHidden, visuallyHidden };
|
|
49
|
+
//# sourceMappingURL=visually-hidden.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visually-hidden.js","sources":["../src/visually-hidden.gts"],"sourcesContent":["import type { TOC } from '@ember/component/template-only'\nimport { modifier } from 'ember-modifier'\nimport { As, type TagName } from './as.gts'\n\n/**\n * Bootstrap's visually-hidden rules, which Radix and ember-primitives use too: the element\n * takes no space and shows nothing, and screen readers still read it.\n */\nconst STYLES: ReadonlyArray<readonly [property: string, value: string]> = [\n ['position', 'absolute'],\n ['border', '0'],\n ['width', '1px'],\n ['height', '1px'],\n ['padding', '0'],\n ['margin', '-1px'],\n ['overflow', 'hidden'],\n ['clip', 'rect(0, 0, 0, 0)'],\n ['white-space', 'nowrap'],\n ['word-wrap', 'normal'],\n]\n\n/**\n * Hides any element visually and keeps it for assistive technology, like ember-primitives'\n * `visually-hidden` attribute, without needing a style sheet. The element's other inline\n * styles stay, and the ones it replaced come back when the modifier goes.\n *\n * <label for=\"search\" {{visuallyHidden}}>Search</label>\n */\nexport const visuallyHidden = modifier((element: HTMLElement | SVGElement) => {\n const { style } = element\n const previous = STYLES.map(\n ([property]) =>\n [property, style.getPropertyValue(property), style.getPropertyPriority(property)] as const,\n )\n for (const [property, value] of STYLES) style.setProperty(property, value)\n return () => {\n for (const [property, value, priority] of previous) {\n if (value) style.setProperty(property, value, priority)\n else style.removeProperty(property)\n }\n }\n})\n\nexport interface VisuallyHiddenSignature {\n Args: {\n /** The tag to render. Default `span`. */\n as?: TagName\n }\n Blocks: {\n /** What screen readers read and sighted users don't see. */\n default: []\n }\n Element: HTMLSpanElement\n}\n\n/**\n * Content that screen readers read and sighted users don't see, such as an icon button's\n * label. It renders a `span` (or `@as`) with the visually-hidden styles inline, so it needs\n * no CSS.\n *\n * <button type=\"button\">\n * <XIcon />\n * <VisuallyHidden>Close</VisuallyHidden>\n * </button>\n *\n * It wraps content, so it isn't a component root for the harnesses: a part inside it still\n * belongs to the component around it.\n */\nexport const VisuallyHidden: TOC<VisuallyHiddenSignature> = <template>\n <As @as={{@as}} @tag=\"span\" data-slot=\"visually-hidden\" ...attributes {{visuallyHidden}}>\n {{yield}}\n </As>\n</template>\n"],"names":["STYLES","visuallyHidden","modifier","element","style","previous","map","property","getPropertyValue","getPropertyPriority","value","setProperty","priority","removeProperty","VisuallyHidden","setComponentTemplate","precompileTemplate","strictMode","scope","As","templateOnly"],"mappings":";;;;;;AAQA,MAAMA,MAA+D,GAAK,CACxE,CAAC,UAAA,EAAY,UAAA,CAAW,EACxB,CAAC,QAAA,EAAU,GAAA,CAAI,EACf,CAAC,OAAA,EAAS,KAAA,CAAM,EA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