frontile 0.18.0 → 0.18.2

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.
Files changed (155) hide show
  1. package/declarations/-private/get-config.d.ts.map +1 -1
  2. package/declarations/-private/timer.d.ts +3 -3
  3. package/declarations/-private/timer.d.ts.map +1 -1
  4. package/declarations/components/buttons/chip.d.ts +1 -1
  5. package/declarations/components/buttons/chip.d.ts.map +1 -1
  6. package/declarations/components/buttons/close-button.d.ts +2 -2
  7. package/declarations/components/buttons/close-button.d.ts.map +1 -1
  8. package/declarations/components/collections/listbox/item.d.ts +2 -2
  9. package/declarations/components/collections/listbox/item.d.ts.map +1 -1
  10. package/declarations/components/collections/simple-table/column.d.ts +6 -0
  11. package/declarations/components/collections/simple-table/column.d.ts.map +1 -1
  12. package/declarations/components/collections/simple-table/footer.d.ts +2 -1
  13. package/declarations/components/collections/simple-table/footer.d.ts.map +1 -1
  14. package/declarations/components/collections/simple-table/header.d.ts +2 -1
  15. package/declarations/components/collections/simple-table/header.d.ts.map +1 -1
  16. package/declarations/components/collections/simple-table/index.d.ts +1 -1
  17. package/declarations/components/collections/simple-table/index.d.ts.map +1 -1
  18. package/declarations/components/collections/table/checkbox.d.ts +1 -1
  19. package/declarations/components/collections/table/checkbox.d.ts.map +1 -1
  20. package/declarations/components/collections/table/column-visibility.d.ts +2 -2
  21. package/declarations/components/collections/table/column-visibility.d.ts.map +1 -1
  22. package/declarations/components/collections/table/table.d.ts +9 -7
  23. package/declarations/components/collections/table/table.d.ts.map +1 -1
  24. package/declarations/components/forms/autocomplete.d.ts +12 -12
  25. package/declarations/components/forms/checkbox.d.ts +2 -2
  26. package/declarations/components/forms/checkbox.d.ts.map +1 -1
  27. package/declarations/components/forms/date-input/clipboard.d.ts +34 -0
  28. package/declarations/components/forms/date-input/clipboard.d.ts.map +1 -0
  29. package/declarations/components/forms/date-input/date-input.d.ts +93 -0
  30. package/declarations/components/forms/date-input/date-input.d.ts.map +1 -0
  31. package/declarations/components/forms/date-input/segment-group.d.ts +132 -0
  32. package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -0
  33. package/declarations/components/forms/date-input/segments.d.ts +163 -0
  34. package/declarations/components/forms/date-input/segments.d.ts.map +1 -0
  35. package/declarations/components/forms/date-input/types.d.ts +175 -0
  36. package/declarations/components/forms/date-input/types.d.ts.map +1 -0
  37. package/declarations/components/forms/date-input.d.ts +6 -0
  38. package/declarations/components/forms/date-input.d.ts.map +1 -0
  39. package/declarations/components/forms/date-picker/date-picker.d.ts +263 -15
  40. package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
  41. package/declarations/components/forms/date-picker/end-content.d.ts +33 -3
  42. package/declarations/components/forms/date-picker/end-content.d.ts.map +1 -1
  43. package/declarations/components/forms/date-picker/types.d.ts +45 -2
  44. package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
  45. package/declarations/components/forms/date-picker/value.d.ts +21 -5
  46. package/declarations/components/forms/date-picker/value.d.ts.map +1 -1
  47. package/declarations/components/forms/field.d.ts +7 -5
  48. package/declarations/components/forms/field.d.ts.map +1 -1
  49. package/declarations/components/forms/form.d.ts +5 -5
  50. package/declarations/components/forms/form.d.ts.map +1 -1
  51. package/declarations/components/forms/index.d.ts +1 -0
  52. package/declarations/components/forms/index.d.ts.map +1 -1
  53. package/declarations/components/forms/input-otp.d.ts +5 -5
  54. package/declarations/components/forms/input-otp.d.ts.map +1 -1
  55. package/declarations/components/forms/input.d.ts +15 -15
  56. package/declarations/components/forms/input.d.ts.map +1 -1
  57. package/declarations/components/forms/native-select.d.ts +10 -10
  58. package/declarations/components/forms/native-select.d.ts.map +1 -1
  59. package/declarations/components/forms/radio.d.ts +2 -2
  60. package/declarations/components/forms/radio.d.ts.map +1 -1
  61. package/declarations/components/forms/select/select.d.ts +16 -16
  62. package/declarations/components/forms/textarea.d.ts +10 -10
  63. package/declarations/components/forms/textarea.d.ts.map +1 -1
  64. package/declarations/components/navigation/pagination/pagination.d.ts +32 -1
  65. package/declarations/components/navigation/pagination/pagination.d.ts.map +1 -1
  66. package/declarations/components/overlays/overlay.d.ts +4 -4
  67. package/declarations/components/overlays/overlay.d.ts.map +1 -1
  68. package/declarations/components/utilities/avatar.d.ts +35 -2
  69. package/declarations/components/utilities/avatar.d.ts.map +1 -1
  70. package/declarations/components/utilities/collapsible.d.ts +16 -0
  71. package/declarations/components/utilities/collapsible.d.ts.map +1 -1
  72. package/declarations/test-support.d.ts +30 -0
  73. package/declarations/test-support.d.ts.map +1 -1
  74. package/declarations/utils/forms-utils-index.d.ts +1 -1
  75. package/declarations/utils/forms-utils-index.d.ts.map +1 -1
  76. package/declarations/utils/nested-data.d.ts +17 -0
  77. package/declarations/utils/nested-data.d.ts.map +1 -1
  78. package/dist/components/buttons/chip.js.map +1 -1
  79. package/dist/components/buttons/close-button.js +5 -12
  80. package/dist/components/buttons/close-button.js.map +1 -1
  81. package/dist/components/collections/listbox/item.js +4 -11
  82. package/dist/components/collections/listbox/item.js.map +1 -1
  83. package/dist/components/collections/simple-table/column.js +2 -2
  84. package/dist/components/collections/simple-table/column.js.map +1 -1
  85. package/dist/components/collections/simple-table/footer.js +1 -1
  86. package/dist/components/collections/simple-table/footer.js.map +1 -1
  87. package/dist/components/collections/simple-table/header.js +1 -1
  88. package/dist/components/collections/simple-table/header.js.map +1 -1
  89. package/dist/components/collections/simple-table/index.js +1 -1
  90. package/dist/components/collections/simple-table/index.js.map +1 -1
  91. package/dist/components/collections/table/checkbox.js +2 -7
  92. package/dist/components/collections/table/checkbox.js.map +1 -1
  93. package/dist/components/collections/table/column-visibility.js +2 -7
  94. package/dist/components/collections/table/column-visibility.js.map +1 -1
  95. package/dist/components/forms/checkbox.js +4 -12
  96. package/dist/components/forms/checkbox.js.map +1 -1
  97. package/dist/components/forms/date-input/clipboard.js +231 -0
  98. package/dist/components/forms/date-input/clipboard.js.map +1 -0
  99. package/dist/components/forms/date-input/date-input.js +204 -0
  100. package/dist/components/forms/date-input/date-input.js.map +1 -0
  101. package/dist/components/forms/date-input/segment-group.js +292 -0
  102. package/dist/components/forms/date-input/segment-group.js.map +1 -0
  103. package/dist/components/forms/date-input/segments.js +562 -0
  104. package/dist/components/forms/date-input/segments.js.map +1 -0
  105. package/dist/components/forms/date-input/types.js +2 -0
  106. package/dist/components/forms/date-input/types.js.map +1 -0
  107. package/dist/components/forms/date-input.js +4 -0
  108. package/dist/components/forms/date-input.js.map +1 -0
  109. package/dist/components/forms/date-picker/date-picker.js +361 -20
  110. package/dist/components/forms/date-picker/date-picker.js.map +1 -1
  111. package/dist/components/forms/date-picker/end-content.js +17 -4
  112. package/dist/components/forms/date-picker/end-content.js.map +1 -1
  113. package/dist/components/forms/date-picker/value.js +44 -6
  114. package/dist/components/forms/date-picker/value.js.map +1 -1
  115. package/dist/components/forms/field.js +12 -20
  116. package/dist/components/forms/field.js.map +1 -1
  117. package/dist/components/forms/form.js +11 -27
  118. package/dist/components/forms/form.js.map +1 -1
  119. package/dist/components/forms/index.js +5 -2
  120. package/dist/components/forms/index.js.map +1 -1
  121. package/dist/components/forms/input-otp.js +10 -26
  122. package/dist/components/forms/input-otp.js.map +1 -1
  123. package/dist/components/forms/input.js +9 -22
  124. package/dist/components/forms/input.js.map +1 -1
  125. package/dist/components/forms/native-select.js +5 -12
  126. package/dist/components/forms/native-select.js.map +1 -1
  127. package/dist/components/forms/radio.js +4 -12
  128. package/dist/components/forms/radio.js.map +1 -1
  129. package/dist/components/forms/textarea.js +6 -17
  130. package/dist/components/forms/textarea.js.map +1 -1
  131. package/dist/components/navigation/pagination/pagination.js +18 -2
  132. package/dist/components/navigation/pagination/pagination.js.map +1 -1
  133. package/dist/components/notifications/index.js +1 -1
  134. package/dist/components/overlays/overlay.js +8 -21
  135. package/dist/components/overlays/overlay.js.map +1 -1
  136. package/dist/components/utilities/avatar.js +26 -5
  137. package/dist/components/utilities/avatar.js.map +1 -1
  138. package/dist/components/utilities/collapsible.js +47 -3
  139. package/dist/components/utilities/collapsible.js.map +1 -1
  140. package/dist/forms.js +5 -2
  141. package/dist/forms.js.map +1 -1
  142. package/dist/index.js +6 -3
  143. package/dist/index.js.map +1 -1
  144. package/dist/{manager-jDaRVZ5o.js → manager-Dge4r8Vn.js} +9 -19
  145. package/dist/manager-Dge4r8Vn.js.map +1 -0
  146. package/dist/notifications.js +1 -1
  147. package/dist/services/notifications.js +1 -1
  148. package/dist/test-support.js +903 -389
  149. package/dist/test-support.js.map +1 -1
  150. package/dist/utils/forms-utils-index.js +1 -1
  151. package/dist/utils/forms-utils-index.js.map +1 -1
  152. package/dist/utils/nested-data.js +28 -1
  153. package/dist/utils/nested-data.js.map +1 -1
  154. package/package.json +10 -10
  155. package/dist/manager-jDaRVZ5o.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"overlay.js","sources":["../../../src/components/overlays/overlay.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { later } from '@ember/runloop';\nimport { on } from '@ember/modifier';\nimport { cssTransition } from 'ember-css-transitions';\nimport { useStyles } from '@frontile/theme';\nimport { modifier } from 'ember-modifier';\nimport { focusTrap, type FocusTrapModifierSignature } from 'ember-focus-trap';\nimport { createFocusTrap, type FocusTrap } from 'focus-trap';\nimport onClickOutside from 'ember-click-outside/modifiers/on-click-outside';\nimport { Backdrop, type BackdropSignature } from './backdrop';\nimport {\n afterFirstPaint,\n hasPainted,\n shouldDeferMount,\n shouldSkipEnterTransition,\n withoutEnterTransition\n} from './mount-animation';\nimport { Portal, findParentPortal, type PortalSignature } from './portal';\nimport type Owner from '@ember/owner';\nimport type { ModifierLike } from '@glint/template';\nimport type { CssTransitionSignature } from 'ember-css-transitions/modifiers/css-transition';\nimport { isTesting, macroCondition } from '@embroider/macros';\n\ntype FocusTrapOptions = NonNullable<\n FocusTrapModifierSignature['Args']['Named']['focusTrapOptions']\n>;\n\ntype FocusTrapLifecycleMethod = 'activate' | 'deactivate' | 'pause' | 'unpause';\n\n/**\n * Wraps `createFocusTrap` so activate/deactivate/pause/unpause never throw.\n *\n * focus-trap keeps a page-global stack of traps; deactivating one can reach\n * into the stack to re-validate (`unpause`) whichever trap is now on top. If\n * that other trap's container was already torn down -- which this test suite\n * does constantly, mounting and unmounting hundreds of trapped overlays in a\n * single browser session -- focus-trap throws \"must have at least one\n * container with at least one tabbable node\", per its own docs' \"Help\"\n * section: this is an expected hazard of trapped elements that \"appear and\n * disappear dynamically\", not a sign of a real focus bug. Test-only: real\n * usage never hits the same rapid-fire mount/unmount churn.\n */\nfunction createTestResilientFocusTrap(\n ...args: Parameters<typeof createFocusTrap>\n): FocusTrap {\n const trap = createFocusTrap(...args);\n\n const guard =\n (method: FocusTrapLifecycleMethod) =>\n (...methodArgs: unknown[]): FocusTrap => {\n try {\n return (trap[method] as (...a: unknown[]) => FocusTrap)(...methodArgs);\n } catch {\n return trap;\n }\n };\n\n return {\n ...trap,\n activate: guard('activate'),\n deactivate: guard('deactivate'),\n pause: guard('pause'),\n unpause: guard('unpause')\n };\n}\n\n/**\n * Whether `target` sits inside a portal nested within this overlay's own\n * portal.\n *\n * The question a click handler needs answered is about *this* click, not about\n * the mere existence of a nested portal. Asking only \"is a nested portal\n * mounted?\" made a parent overlay ignore every outside click for as long as a\n * child was open -- so with a Dropdown submenu (or a Select inside a Modal)\n * open, clicking the page did not close anything.\n *\n * A portal that is not a descendant of this overlay's portal -- one given an\n * explicit `@target`, or opted out of `appendToParentPortal` -- is not nested,\n * and a click in it is a genuine outside click.\n */\nfunction isWithinNestedPortal(\n contentElement: HTMLElement,\n target: EventTarget | null\n): boolean {\n const ownPortal = findParentPortal(contentElement);\n if (!ownPortal || !(target instanceof Element)) {\n return false;\n }\n\n const targetPortal = target.closest('[data-portal=\"true\"]');\n if (!targetPortal || targetPortal === ownPortal) {\n return false;\n }\n\n return ownPortal.contains(targetPortal);\n}\n\n// Blocking the body scroll mutates global state, so it has to be reference\n// counted: nested overlays (a Drawer opened from a Modal, a Select inside a\n// Modal) each lock on open and unlock on close, and only the last one out is\n// allowed to restore the page. We also remember the inline value the app had\n// before the first lock, so restoring does not silently wipe an app-level\n// `body { overflow: ... }`.\nlet bodyScrollLockCount = 0;\nlet previousBodyOverflow = '';\n\nfunction lockBodyScroll(): void {\n if (bodyScrollLockCount === 0) {\n previousBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n }\n bodyScrollLockCount++;\n}\n\nfunction unlockBodyScroll(): void {\n if (bodyScrollLockCount === 0) {\n return;\n }\n\n bodyScrollLockCount--;\n\n if (bodyScrollLockCount === 0) {\n document.body.style.overflow = previousBodyOverflow;\n previousBodyOverflow = '';\n }\n}\n\nfunction hasWormholeOrAlertParentElement(el: HTMLElement) {\n let parent = el.parentElement;\n while (parent) {\n if (\n parent.id === 'ember-basic-dropdown-wormhole' ||\n parent.role === 'alert'\n ) {\n return true;\n }\n parent = parent.parentElement;\n }\n return false;\n}\n\ninterface Args extends Pick<\n PortalSignature['Args'],\n 'renderInPlace' | 'target'\n> {\n /**\n * Duration of the animation\n *\n * @defaultValue 200\n */\n transitionDuration?: number;\n\n /**\n * How the area behind the overlay is rendered: `none` omits the backdrop\n * entirely, `transparent` keeps it clickable but invisible, `faded` dims the\n * page, and `blur` blurs it.\n */\n backdrop?: BackdropSignature['Args']['type'];\n\n /**\n * Transition classes for the backdrop, overriding the defaults used when it\n * fades in and out.\n */\n backdropTransition?: BackdropSignature['Args']['transition'];\n\n /**\n * Disable css transitions\n *\n * @defaultValue false\n */\n disableTransitions?: boolean;\n\n /**\n * Whether an overlay that is *already open the first time it renders* --\n * deep-linked open, or restored by a page refresh -- animates in.\n *\n * When true (the default) the overlay waits for the browser's first paint\n * before mounting, so the animation plays against a page the user has\n * already seen. Set it to false for an already-open overlay that should\n * simply be there, with no reveal. An overlay opened later by interaction\n * animates either way, and so does closing.\n *\n * @defaultValue true\n */\n animateOnMount?: boolean;\n\n /**\n * Whether the focus trap is disabled or not\n *\n * @defaultValue false\n */\n disableFocusTrap?: boolean;\n\n /**\n * Focus trap options\n *\n * @defaultValue { clickOutsideDeactivates: true, allowOutsideClick: true }\n */\n focusTrapOptions?: FocusTrapOptions;\n\n /**\n * Whether it is open or not\n */\n isOpen: boolean;\n\n /**\n * A function that will be called when closed\n */\n onClose?: () => void;\n\n /**\n * A function that will be called when closing is finished executing, this\n * includes waiting for animations/transitions to finish.\n */\n didClose?: () => void;\n\n /**\n * A function that will be called when opened\n */\n onOpen?: () => void;\n\n /**\n * Whether to close when the area outside (the backdrop) is clicked\n *\n * @defaultValue true\n */\n closeOnOutsideClick?: boolean;\n\n /**\n * Whether to close when the overlay element is clicked, used for modal and drawer components.\n * This is set to true by default to allow \"outside click\" functionality to work properly.\n * Most overlay content is wrapped with an inner element, preventing accidental closure.\n *\n * @defaultValue true\n */\n closeOnOverlayElementClick?: boolean;\n\n /**\n * Whether to close when the escape key is pressed\n *\n * @defaultValue true\n */\n closeOnEscapeKey?: boolean;\n\n /**\n * Transition options\n *\n * @defaultValue {name:'overlay-transition--fade'}\n */\n transition?: CssTransitionSignature['Args']['Named'];\n\n /**\n * Opt out of the flex layout applied to the content element, for overlays\n * that need to lay their content out themselves.\n *\n * @defaultValue false\n */\n disableFlexContent?: boolean;\n\n /**\n * An extra modifier applied to the content element, for behavior the overlay\n * doesn't provide itself.\n */\n customContentModifier?: ModifierLike<{ Element: HTMLElement }>;\n\n /**\n * Custom class name for the content element, merged with the default ones\n * using Tailwind Merge.\n */\n class?: string;\n /**\n * @defaultValue false\n */\n preventFocusRestore?: boolean;\n\n /**\n * When focusTrap is disabled, by default Oberlay will be auto focused. This option prevents that.\n * @defaultValue false\n */\n preventAutoFocus?: boolean;\n\n /**\n * @defaultValue true\n */\n blockScroll?: boolean;\n}\n\ninterface OverlaySignature {\n Args: Args;\n Element: HTMLDivElement;\n Blocks: { default: [] };\n}\n\nclass Overlay extends Component<OverlaySignature> {\n @tracked keepOpen = false;\n\n // Whether the browser has painted since this overlay was created. Only ever\n // consulted while the mount is being deferred; see `mount-animation.ts`.\n @tracked hasWaitedForPaint = false;\n\n // Whether `@isOpen` was already true on the very first render. Captured once\n // rather than derived, because the whole question is about what the args\n // looked like at mount.\n isOpenAtMount = this.args.isOpen === true;\n\n // Whether the page had already painted when this overlay was created, which\n // only an overlay that mounts open ever has to know -- and every Dropdown,\n // Select and Tooltip in the app builds an Overlay too.\n hadPaintedAtMount = this.isOpenAtMount ? hasPainted() : false;\n\n // Latched when the first open closes, so a *reopen* of the same overlay\n // animates normally. Only a genuine close counts: the content element is\n // also torn down and rebuilt when the portal destination changes under an\n // open overlay, and flipping this then would swap the enter class names out\n // from under the running modifier, which cleans up using whatever names it\n // holds when the transition ends.\n @tracked hasClosedOnce = false;\n\n contentElement: HTMLElement | undefined;\n focusedElement: Element | null | undefined;\n mouseDownContentElement: EventTarget | null = null;\n\n // Whether *this* overlay is holding a reference on the body scroll lock. We\n // record the decision made when opening instead of re-deriving it at\n // teardown, because the args can change while the overlay is open and an\n // asymmetric lock/unlock would leak the reference count.\n didLockBodyScroll = false;\n\n cancelPaintWait: (() => void) | undefined;\n\n constructor(owner: Owner, args: Args) {\n super(owner, args);\n\n if (!this.shouldDeferMount) {\n return;\n }\n\n this.cancelPaintWait = afterFirstPaint(() => {\n if (!this.isDestroying && !this.isDestroyed) {\n this.hasWaitedForPaint = true;\n }\n });\n }\n\n willDestroy(): void {\n super.willDestroy();\n this.cancelPaintWait?.();\n }\n\n handleClose(): void {\n if (this.args.isOpen && typeof this.args.onClose === 'function') {\n this.args.onClose();\n }\n }\n\n @action handleContentClick(event: MouseEvent): void {\n if (\n this.args.closeOnOutsideClick !== false &&\n this.args.closeOnOverlayElementClick !== false &&\n event.target === this.contentElement &&\n this.mouseDownContentElement == this.contentElement &&\n !isWithinNestedPortal(this.contentElement, event.target) &&\n !hasWormholeOrAlertParentElement(event.target as HTMLElement)\n ) {\n this.handleClose();\n }\n this.mouseDownContentElement = null;\n }\n\n @action handleOutsideClick(e: Event): void {\n if (\n this.args.closeOnOutsideClick !== false &&\n this.contentElement &&\n !isWithinNestedPortal(this.contentElement, e.target) &&\n !hasWormholeOrAlertParentElement(e.target as HTMLElement)\n ) {\n this.handleClose();\n e.preventDefault();\n }\n }\n\n @action\n handleContentMouseDown(event: MouseEvent): void {\n if (this.args.closeOnOverlayElementClick !== false) {\n this.mouseDownContentElement = event.target;\n }\n }\n\n @action\n handleKeyDown(event: KeyboardEvent): void {\n if (event.key === 'Escape' && this.args.closeOnEscapeKey !== false) {\n this.handleClose();\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n setupContent = modifier((el: HTMLDivElement) => {\n let transitionDuration = this.args.transitionDuration || 200;\n if (!this.isAnimationEnabled) {\n transitionDuration = 0;\n }\n later(() => {\n if (this.isDestroyed) return;\n if (this.args.disableFocusTrap !== true) return;\n if (this.args.preventAutoFocus === true) return;\n el.focus();\n }, transitionDuration);\n\n this.contentElement = el;\n this.keepOpen = true;\n this.focusedElement = document.activeElement;\n\n if (this.args.renderInPlace !== true && this.args.blockScroll !== false) {\n this.didLockBodyScroll = true;\n lockBodyScroll();\n }\n\n if (typeof this.args.onOpen === 'function') {\n this.args.onOpen();\n }\n return () => {\n this.contentElement = undefined;\n\n if (this.args.isOpen !== true) {\n this.hasClosedOnce = true;\n }\n\n if (this.didLockBodyScroll) {\n this.didLockBodyScroll = false;\n unlockBodyScroll();\n }\n\n const { didClose } = this.args;\n later(() => {\n if (!this.isDestroyed) this.keepOpen = false;\n if (typeof didClose === 'function' && !this.isDestroyed) {\n didClose();\n }\n\n // restore focus\n if (\n !this.args.preventFocusRestore &&\n this.focusedElement &&\n (this.focusedElement as HTMLElement).tabIndex > -1 &&\n typeof (this.focusedElement as HTMLElement).focus !== 'undefined'\n ) {\n (this.focusedElement as HTMLElement).focus();\n }\n }, transitionDuration);\n };\n });\n\n @cached\n get mountAnimationState() {\n return {\n isFirstOpen: this.isOpenAtMount && !this.hasClosedOnce,\n animationsEnabled: this.isAnimationEnabled,\n animateOnMount: this.args.animateOnMount,\n canWaitForFrame: typeof requestAnimationFrame === 'function',\n hasPainted: this.hadPaintedAtMount\n };\n }\n\n get shouldDeferMount(): boolean {\n return shouldDeferMount(this.mountAnimationState);\n }\n\n get skipEnterTransition(): boolean {\n return shouldSkipEnterTransition(this.mountAnimationState);\n }\n\n get isVisible(): boolean {\n if (this.shouldDeferMount && !this.hasWaitedForPaint) {\n return false;\n }\n\n return this.args.isOpen || this.keepOpen;\n }\n\n get backdrop(): BackdropSignature['Args']['type'] {\n if (!this.args.isOpen) {\n return 'none';\n }\n return this.args.backdrop || 'faded';\n }\n\n get isAnimationEnabled(): boolean {\n if (macroCondition(isTesting())) {\n return false;\n }\n return !(this.args.disableTransitions === true);\n }\n\n /**\n * Consumer options are merged over the defaults rather than replacing them.\n *\n * Swapping the object wholesale made setting any single option -- a\n * `setReturnFocus`, an `initialFocus` -- silently drop\n * `clickOutsideDeactivates` and `allowOutsideClick` with it, at which point\n * the trap swallows outside clicks and the overlay can only be dismissed\n * with Escape. Nothing warns, and the cause is nowhere near the symptom.\n * A consumer that genuinely wants the trap to hold outside clicks can still\n * say so by passing those two as `false`.\n */\n get focusTrapOptions(): FocusTrapOptions {\n return {\n clickOutsideDeactivates: true,\n allowOutsideClick: true,\n ...this.args.focusTrapOptions\n };\n }\n\n get createFocusTrap(): typeof createFocusTrap | undefined {\n if (macroCondition(isTesting())) {\n return createTestResilientFocusTrap;\n }\n return undefined;\n }\n\n get classes() {\n const { overlay } = useStyles();\n\n return overlay({\n class: this.args.class,\n inPlace: this.args.renderInPlace,\n enableFlexContent: !(this.args.disableFlexContent === true)\n });\n }\n\n get customContentModifier() {\n if (this.args.customContentModifier) {\n return this.args.customContentModifier;\n }\n\n return modifier(() => {});\n }\n\n // Applied to both the content and the backdrop, so they never disagree about\n // whether this mount animates.\n maybeWithoutEnter<T extends object>(options: T): T {\n return this.skipEnterTransition ? withoutEnterTransition(options) : options;\n }\n\n get backdropTransition() {\n return this.maybeWithoutEnter(\n this.args.backdropTransition || { isEnabled: this.isAnimationEnabled }\n );\n }\n\n get transition() {\n let options: BackdropSignature['Args']['transition'] = {\n name: 'overlay-transition--fade',\n isEnabled: this.isAnimationEnabled\n };\n\n if (typeof this.args.transition === 'object') {\n options = { ...options, ...this.args.transition };\n }\n\n return this.maybeWithoutEnter(options);\n }\n\n <template>\n {{! template-lint-disable no-invalid-interactive }}\n {{! template-lint-disable no-pointer-down-event-binding }}\n\n {{#if this.isVisible}}\n <Portal @renderInPlace={{@renderInPlace}} @target={{@target}}>\n <Backdrop\n @type={{this.backdrop}}\n @inPlace={{@renderInPlace}}\n @transition={{this.backdropTransition}}\n />\n\n {{#if @isOpen}}\n <div\n {{this.setupContent}}\n {{on \"click\" this.handleContentClick}}\n {{on \"keydown\" this.handleKeyDown}}\n {{on \"mousedown\" this.handleContentMouseDown}}\n {{cssTransition\n didTransitionIn=this.transition.didTransitionIn\n didTransitionOut=this.transition.didTransitionOut\n enterClass=this.transition.enterClass\n enterActiveClass=this.transition.enterActiveClass\n enterToClass=this.transition.enterToClass\n isEnabled=this.transition.isEnabled\n leaveClass=this.transition.leaveClass\n leaveActiveClass=this.transition.leaveActiveClass\n leaveToClass=this.transition.leaveToClass\n name=this.transition.name\n parentSelector=this.transition.parentSelector\n }}\n {{onClickOutside this.handleOutsideClick capture=true}}\n {{focusTrap\n isActive=(if @disableFocusTrap false @isOpen)\n focusTrapOptions=this.focusTrapOptions\n _createFocusTrap=this.createFocusTrap\n }}\n class={{this.classes}}\n {{! Keep this custom modifer by last}}\n {{this.customContentModifier}}\n data-component=\"overlay\"\n data-part=\"base\"\n tabindex=\"0\"\n ...attributes\n >\n {{yield}}\n </div>\n {{/if}}\n </Portal>\n {{/if}}\n </template>\n}\n\nexport { Overlay, type OverlaySignature };\nexport default Overlay;\n"],"names":["createTestResilientFocusTrap","args","trap","createFocusTrap","guard","method","methodArgs","activate","deactivate","pause","unpause","isWithinNestedPortal","contentElement","target","ownPortal","findParentPortal","Element","targetPortal","closest","contains","bodyScrollLockCount","previousBodyOverflow","lockBodyScroll","document","body","style","overflow","unlockBodyScroll","hasWormholeOrAlertParentElement","el","parent","parentElement","id","role","Overlay","Component","g","prototype","tracked","i","isOpenAtMount","isOpen","hadPaintedAtMount","hasPainted","focusedElement","mouseDownContentElement","didLockBodyScroll","cancelPaintWait","constructor","owner","shouldDeferMount","afterFirstPaint","isDestroying","isDestroyed","hasWaitedForPaint","willDestroy","handleClose","onClose","handleContentClick","event","closeOnOutsideClick","closeOnOverlayElementClick","n","action","handleOutsideClick","e","preventDefault","handleContentMouseDown","handleKeyDown","key","closeOnEscapeKey","stopImmediatePropagation","setupContent","modifier","transitionDuration","isAnimationEnabled","later","disableFocusTrap","preventAutoFocus","focus","keepOpen","activeElement","renderInPlace","blockScroll","onOpen","undefined","hasClosedOnce","didClose","preventFocusRestore","tabIndex","mountAnimationState","isFirstOpen","animationsEnabled","animateOnMount","canWaitForFrame","requestAnimationFrame","cached","skipEnterTransition","shouldSkipEnterTransition","isVisible","backdrop","macroCondition","isTesting","disableTransitions","focusTrapOptions","clickOutsideDeactivates","allowOutsideClick","classes","overlay","useStyles","class","inPlace","enableFlexContent","disableFlexContent","customContentModifier","maybeWithoutEnter","options","withoutEnterTransition","backdropTransition","isEnabled","transition","name","setComponentTemplate","precompileTemplate","strictMode","scope","Portal","Backdrop","on","cssTransition","onClickOutside","focusTrap"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA;;;;;;;;;;;;AAYC;AACD,SAASA,4BAAAA,CACP,GAAGC,IAAwC,EAC1C;AACD,EAAA,MAAMC,OAAOC,eAAA,CAAA,GAAmBF,IAAA,CAAA;AAEhC,EAAA,MAAMG,KAAA,GACHC,MAAQ,IACT,CAAC,GAAGC,UAAmB,KAAK;IAC1B,IAAI;AACF,MAAA,OAAQJ,IAAI,CAACG,MAAA,CAAO,CAAkC,GAAKC,UAAA,CAAA;AAC7D,IAAA,CAAA,CAAE,MAAM;AACN,MAAA,OAAOJ,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EAAA;IAAAM,oBAAA,CAAAC,kBAAA,CAAA,k5CAAA,EAkDA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,MAAA;QAAAC,QAAA;QAAAC,EAAA;QAAAC,aAAA;QAAAC,cAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
1
+ {"version":3,"file":"overlay.js","sources":["../../../src/components/overlays/overlay.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { later } from '@ember/runloop';\nimport { on } from '@ember/modifier';\nimport { cssTransition } from 'ember-css-transitions';\nimport { useStyles } from '@frontile/theme';\nimport { modifier } from 'ember-modifier';\nimport { focusTrap, type FocusTrapModifierSignature } from 'ember-focus-trap';\nimport { createFocusTrap, type FocusTrap } from 'focus-trap';\nimport onClickOutside from 'ember-click-outside/modifiers/on-click-outside';\nimport { Backdrop, type BackdropSignature } from './backdrop';\nimport {\n afterFirstPaint,\n hasPainted,\n shouldDeferMount,\n shouldSkipEnterTransition,\n withoutEnterTransition\n} from './mount-animation';\nimport { Portal, findParentPortal, type PortalSignature } from './portal';\nimport type Owner from '@ember/owner';\nimport type { ModifierLike } from '@glint/template';\nimport type { CssTransitionSignature } from 'ember-css-transitions/modifiers/css-transition';\nimport { isTesting, macroCondition } from '@embroider/macros';\n\ntype FocusTrapOptions = NonNullable<\n FocusTrapModifierSignature['Args']['Named']['focusTrapOptions']\n>;\n\ntype FocusTrapLifecycleMethod = 'activate' | 'deactivate' | 'pause' | 'unpause';\n\n/**\n * Wraps `createFocusTrap` so activate/deactivate/pause/unpause never throw.\n *\n * focus-trap keeps a page-global stack of traps; deactivating one can reach\n * into the stack to re-validate (`unpause`) whichever trap is now on top. If\n * that other trap's container was already torn down -- which this test suite\n * does constantly, mounting and unmounting hundreds of trapped overlays in a\n * single browser session -- focus-trap throws \"must have at least one\n * container with at least one tabbable node\", per its own docs' \"Help\"\n * section: this is an expected hazard of trapped elements that \"appear and\n * disappear dynamically\", not a sign of a real focus bug. Test-only: real\n * usage never hits the same rapid-fire mount/unmount churn.\n */\nfunction createTestResilientFocusTrap(\n ...args: Parameters<typeof createFocusTrap>\n): FocusTrap {\n const trap = createFocusTrap(...args);\n\n const guard =\n (method: FocusTrapLifecycleMethod) =>\n (...methodArgs: unknown[]): FocusTrap => {\n try {\n return (trap[method] as (...a: unknown[]) => FocusTrap)(...methodArgs);\n } catch {\n return trap;\n }\n };\n\n return {\n ...trap,\n activate: guard('activate'),\n deactivate: guard('deactivate'),\n pause: guard('pause'),\n unpause: guard('unpause')\n };\n}\n\n/**\n * Whether `target` sits inside a portal nested within this overlay's own\n * portal.\n *\n * The question a click handler needs answered is about *this* click, not about\n * the mere existence of a nested portal. Asking only \"is a nested portal\n * mounted?\" made a parent overlay ignore every outside click for as long as a\n * child was open -- so with a Dropdown submenu (or a Select inside a Modal)\n * open, clicking the page did not close anything.\n *\n * A portal that is not a descendant of this overlay's portal -- one given an\n * explicit `@target`, or opted out of `appendToParentPortal` -- is not nested,\n * and a click in it is a genuine outside click.\n */\nfunction isWithinNestedPortal(\n contentElement: HTMLElement,\n target: EventTarget | null\n): boolean {\n const ownPortal = findParentPortal(contentElement);\n if (!ownPortal || !(target instanceof Element)) {\n return false;\n }\n\n const targetPortal = target.closest('[data-portal=\"true\"]');\n if (!targetPortal || targetPortal === ownPortal) {\n return false;\n }\n\n return ownPortal.contains(targetPortal);\n}\n\n// Blocking the body scroll mutates global state, so it has to be reference\n// counted: nested overlays (a Drawer opened from a Modal, a Select inside a\n// Modal) each lock on open and unlock on close, and only the last one out is\n// allowed to restore the page. We also remember the inline value the app had\n// before the first lock, so restoring does not silently wipe an app-level\n// `body { overflow: ... }`.\nlet bodyScrollLockCount = 0;\nlet previousBodyOverflow = '';\n\nfunction lockBodyScroll(): void {\n if (bodyScrollLockCount === 0) {\n previousBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n }\n bodyScrollLockCount++;\n}\n\nfunction unlockBodyScroll(): void {\n if (bodyScrollLockCount === 0) {\n return;\n }\n\n bodyScrollLockCount--;\n\n if (bodyScrollLockCount === 0) {\n document.body.style.overflow = previousBodyOverflow;\n previousBodyOverflow = '';\n }\n}\n\nfunction hasWormholeOrAlertParentElement(el: HTMLElement) {\n let parent = el.parentElement;\n while (parent) {\n if (\n parent.id === 'ember-basic-dropdown-wormhole' ||\n parent.role === 'alert'\n ) {\n return true;\n }\n parent = parent.parentElement;\n }\n return false;\n}\n\ninterface Args extends Pick<\n PortalSignature['Args'],\n 'renderInPlace' | 'target'\n> {\n /**\n * Duration of the animation\n *\n * @defaultValue 200\n */\n transitionDuration?: number;\n\n /**\n * How the area behind the overlay is rendered: `none` omits the backdrop\n * entirely, `transparent` keeps it clickable but invisible, `faded` dims the\n * page, and `blur` blurs it.\n */\n backdrop?: BackdropSignature['Args']['type'];\n\n /**\n * Transition classes for the backdrop, overriding the defaults used when it\n * fades in and out.\n */\n backdropTransition?: BackdropSignature['Args']['transition'];\n\n /**\n * Disable css transitions\n *\n * @defaultValue false\n */\n disableTransitions?: boolean;\n\n /**\n * Whether an overlay that is *already open the first time it renders* --\n * deep-linked open, or restored by a page refresh -- animates in.\n *\n * When true (the default) the overlay waits for the browser's first paint\n * before mounting, so the animation plays against a page the user has\n * already seen. Set it to false for an already-open overlay that should\n * simply be there, with no reveal. An overlay opened later by interaction\n * animates either way, and so does closing.\n *\n * @defaultValue true\n */\n animateOnMount?: boolean;\n\n /**\n * Whether the focus trap is disabled or not\n *\n * @defaultValue false\n */\n disableFocusTrap?: boolean;\n\n /**\n * Focus trap options\n *\n * @defaultValue { clickOutsideDeactivates: true, allowOutsideClick: true }\n */\n focusTrapOptions?: FocusTrapOptions;\n\n /**\n * Whether it is open or not\n */\n isOpen: boolean;\n\n /**\n * A function that will be called when closed\n */\n onClose?: () => void;\n\n /**\n * A function that will be called when closing is finished executing, this\n * includes waiting for animations/transitions to finish.\n */\n didClose?: () => void;\n\n /**\n * A function that will be called when opened\n */\n onOpen?: () => void;\n\n /**\n * Whether to close when the area outside (the backdrop) is clicked\n *\n * @defaultValue true\n */\n closeOnOutsideClick?: boolean;\n\n /**\n * Whether to close when the overlay element is clicked, used for modal and drawer components.\n * This is set to true by default to allow \"outside click\" functionality to work properly.\n * Most overlay content is wrapped with an inner element, preventing accidental closure.\n *\n * @defaultValue true\n */\n closeOnOverlayElementClick?: boolean;\n\n /**\n * Whether to close when the escape key is pressed\n *\n * @defaultValue true\n */\n closeOnEscapeKey?: boolean;\n\n /**\n * Transition options\n *\n * @defaultValue {name:'overlay-transition--fade'}\n */\n transition?: CssTransitionSignature['Args']['Named'];\n\n /**\n * Opt out of the flex layout applied to the content element, for overlays\n * that need to lay their content out themselves.\n *\n * @defaultValue false\n */\n disableFlexContent?: boolean;\n\n /**\n * An extra modifier applied to the content element, for behavior the overlay\n * doesn't provide itself.\n */\n customContentModifier?: ModifierLike<{ Element: HTMLElement }>;\n\n /**\n * Custom class name for the content element, merged with the default ones\n * using Tailwind Merge.\n */\n class?: string;\n /**\n * @defaultValue false\n */\n preventFocusRestore?: boolean;\n\n /**\n * When focusTrap is disabled, by default Oberlay will be auto focused. This option prevents that.\n * @defaultValue false\n */\n preventAutoFocus?: boolean;\n\n /**\n * @defaultValue true\n */\n blockScroll?: boolean;\n}\n\ninterface OverlaySignature {\n Args: Args;\n Element: HTMLDivElement;\n Blocks: { default: [] };\n}\n\nclass Overlay extends Component<OverlaySignature> {\n @tracked keepOpen = false;\n\n // Whether the browser has painted since this overlay was created. Only ever\n // consulted while the mount is being deferred; see `mount-animation.ts`.\n @tracked hasWaitedForPaint = false;\n\n // Whether `@isOpen` was already true on the very first render. Captured once\n // rather than derived, because the whole question is about what the args\n // looked like at mount.\n isOpenAtMount = this.args.isOpen === true;\n\n // Whether the page had already painted when this overlay was created, which\n // only an overlay that mounts open ever has to know -- and every Dropdown,\n // Select and Tooltip in the app builds an Overlay too.\n hadPaintedAtMount = this.isOpenAtMount ? hasPainted() : false;\n\n // Latched when the first open closes, so a *reopen* of the same overlay\n // animates normally. Only a genuine close counts: the content element is\n // also torn down and rebuilt when the portal destination changes under an\n // open overlay, and flipping this then would swap the enter class names out\n // from under the running modifier, which cleans up using whatever names it\n // holds when the transition ends.\n @tracked hasClosedOnce = false;\n\n contentElement: HTMLElement | undefined;\n focusedElement: Element | null | undefined;\n mouseDownContentElement: EventTarget | null = null;\n\n // Whether *this* overlay is holding a reference on the body scroll lock. We\n // record the decision made when opening instead of re-deriving it at\n // teardown, because the args can change while the overlay is open and an\n // asymmetric lock/unlock would leak the reference count.\n didLockBodyScroll = false;\n\n cancelPaintWait: (() => void) | undefined;\n\n constructor(owner: Owner, args: Args) {\n super(owner, args);\n\n if (!this.shouldDeferMount) {\n return;\n }\n\n this.cancelPaintWait = afterFirstPaint(() => {\n if (!this.isDestroying && !this.isDestroyed) {\n this.hasWaitedForPaint = true;\n }\n });\n }\n\n willDestroy(): void {\n super.willDestroy();\n this.cancelPaintWait?.();\n }\n\n handleClose(): void {\n if (this.args.isOpen && typeof this.args.onClose === 'function') {\n this.args.onClose();\n }\n }\n\n handleContentClick = (event: MouseEvent): void => {\n if (\n this.args.closeOnOutsideClick !== false &&\n this.args.closeOnOverlayElementClick !== false &&\n event.target === this.contentElement &&\n this.mouseDownContentElement == this.contentElement &&\n !isWithinNestedPortal(this.contentElement, event.target) &&\n !hasWormholeOrAlertParentElement(event.target as HTMLElement)\n ) {\n this.handleClose();\n }\n this.mouseDownContentElement = null;\n };\n\n handleOutsideClick = (e: Event): void => {\n if (\n this.args.closeOnOutsideClick !== false &&\n this.contentElement &&\n !isWithinNestedPortal(this.contentElement, e.target) &&\n !hasWormholeOrAlertParentElement(e.target as HTMLElement)\n ) {\n this.handleClose();\n e.preventDefault();\n }\n };\n\n handleContentMouseDown = (event: MouseEvent): void => {\n if (this.args.closeOnOverlayElementClick !== false) {\n this.mouseDownContentElement = event.target;\n }\n };\n\n handleKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape' && this.args.closeOnEscapeKey !== false) {\n this.handleClose();\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n\n setupContent = modifier((el: HTMLDivElement) => {\n let transitionDuration = this.args.transitionDuration || 200;\n if (!this.isAnimationEnabled) {\n transitionDuration = 0;\n }\n later(() => {\n if (this.isDestroyed) return;\n if (this.args.disableFocusTrap !== true) return;\n if (this.args.preventAutoFocus === true) return;\n el.focus();\n }, transitionDuration);\n\n this.contentElement = el;\n this.keepOpen = true;\n this.focusedElement = document.activeElement;\n\n if (this.args.renderInPlace !== true && this.args.blockScroll !== false) {\n this.didLockBodyScroll = true;\n lockBodyScroll();\n }\n\n if (typeof this.args.onOpen === 'function') {\n this.args.onOpen();\n }\n return () => {\n this.contentElement = undefined;\n\n if (this.args.isOpen !== true) {\n this.hasClosedOnce = true;\n }\n\n if (this.didLockBodyScroll) {\n this.didLockBodyScroll = false;\n unlockBodyScroll();\n }\n\n const { didClose } = this.args;\n later(() => {\n if (!this.isDestroyed) this.keepOpen = false;\n if (typeof didClose === 'function' && !this.isDestroyed) {\n didClose();\n }\n\n // restore focus\n if (\n !this.args.preventFocusRestore &&\n this.focusedElement &&\n (this.focusedElement as HTMLElement).tabIndex > -1 &&\n typeof (this.focusedElement as HTMLElement).focus !== 'undefined'\n ) {\n (this.focusedElement as HTMLElement).focus();\n }\n }, transitionDuration);\n };\n });\n\n @cached\n get mountAnimationState() {\n return {\n isFirstOpen: this.isOpenAtMount && !this.hasClosedOnce,\n animationsEnabled: this.isAnimationEnabled,\n animateOnMount: this.args.animateOnMount,\n canWaitForFrame: typeof requestAnimationFrame === 'function',\n hasPainted: this.hadPaintedAtMount\n };\n }\n\n get shouldDeferMount(): boolean {\n return shouldDeferMount(this.mountAnimationState);\n }\n\n get skipEnterTransition(): boolean {\n return shouldSkipEnterTransition(this.mountAnimationState);\n }\n\n get isVisible(): boolean {\n if (this.shouldDeferMount && !this.hasWaitedForPaint) {\n return false;\n }\n\n return this.args.isOpen || this.keepOpen;\n }\n\n get backdrop(): BackdropSignature['Args']['type'] {\n if (!this.args.isOpen) {\n return 'none';\n }\n return this.args.backdrop || 'faded';\n }\n\n get isAnimationEnabled(): boolean {\n if (macroCondition(isTesting())) {\n return false;\n }\n return !(this.args.disableTransitions === true);\n }\n\n /**\n * Consumer options are merged over the defaults rather than replacing them.\n *\n * Swapping the object wholesale made setting any single option -- a\n * `setReturnFocus`, an `initialFocus` -- silently drop\n * `clickOutsideDeactivates` and `allowOutsideClick` with it, at which point\n * the trap swallows outside clicks and the overlay can only be dismissed\n * with Escape. Nothing warns, and the cause is nowhere near the symptom.\n * A consumer that genuinely wants the trap to hold outside clicks can still\n * say so by passing those two as `false`.\n */\n get focusTrapOptions(): FocusTrapOptions {\n return {\n clickOutsideDeactivates: true,\n allowOutsideClick: true,\n ...this.args.focusTrapOptions\n };\n }\n\n get createFocusTrap(): typeof createFocusTrap | undefined {\n if (macroCondition(isTesting())) {\n return createTestResilientFocusTrap;\n }\n return undefined;\n }\n\n get classes() {\n const { overlay } = useStyles();\n\n return overlay({\n class: this.args.class,\n inPlace: this.args.renderInPlace,\n enableFlexContent: !(this.args.disableFlexContent === true)\n });\n }\n\n get customContentModifier() {\n if (this.args.customContentModifier) {\n return this.args.customContentModifier;\n }\n\n return modifier(() => {});\n }\n\n // Applied to both the content and the backdrop, so they never disagree about\n // whether this mount animates.\n maybeWithoutEnter<T extends object>(options: T): T {\n return this.skipEnterTransition ? withoutEnterTransition(options) : options;\n }\n\n get backdropTransition() {\n return this.maybeWithoutEnter(\n this.args.backdropTransition || { isEnabled: this.isAnimationEnabled }\n );\n }\n\n get transition() {\n let options: BackdropSignature['Args']['transition'] = {\n name: 'overlay-transition--fade',\n isEnabled: this.isAnimationEnabled\n };\n\n if (typeof this.args.transition === 'object') {\n options = { ...options, ...this.args.transition };\n }\n\n return this.maybeWithoutEnter(options);\n }\n\n <template>\n {{! template-lint-disable no-invalid-interactive }}\n {{! template-lint-disable no-pointer-down-event-binding }}\n\n {{#if this.isVisible}}\n <Portal @renderInPlace={{@renderInPlace}} @target={{@target}}>\n <Backdrop\n @type={{this.backdrop}}\n @inPlace={{@renderInPlace}}\n @transition={{this.backdropTransition}}\n />\n\n {{#if @isOpen}}\n <div\n {{this.setupContent}}\n {{on \"click\" this.handleContentClick}}\n {{on \"keydown\" this.handleKeyDown}}\n {{on \"mousedown\" this.handleContentMouseDown}}\n {{cssTransition\n didTransitionIn=this.transition.didTransitionIn\n didTransitionOut=this.transition.didTransitionOut\n enterClass=this.transition.enterClass\n enterActiveClass=this.transition.enterActiveClass\n enterToClass=this.transition.enterToClass\n isEnabled=this.transition.isEnabled\n leaveClass=this.transition.leaveClass\n leaveActiveClass=this.transition.leaveActiveClass\n leaveToClass=this.transition.leaveToClass\n name=this.transition.name\n parentSelector=this.transition.parentSelector\n }}\n {{onClickOutside this.handleOutsideClick capture=true}}\n {{focusTrap\n isActive=(if @disableFocusTrap false @isOpen)\n focusTrapOptions=this.focusTrapOptions\n _createFocusTrap=this.createFocusTrap\n }}\n class={{this.classes}}\n {{! Keep this custom modifer by last}}\n {{this.customContentModifier}}\n data-component=\"overlay\"\n data-part=\"base\"\n tabindex=\"0\"\n ...attributes\n >\n {{yield}}\n </div>\n {{/if}}\n </Portal>\n {{/if}}\n </template>\n}\n\nexport { Overlay, type OverlaySignature };\nexport default Overlay;\n"],"names":["createTestResilientFocusTrap","args","trap","createFocusTrap","guard","method","methodArgs","activate","deactivate","pause","unpause","isWithinNestedPortal","contentElement","target","ownPortal","findParentPortal","Element","targetPortal","closest","contains","bodyScrollLockCount","previousBodyOverflow","lockBodyScroll","document","body","style","overflow","unlockBodyScroll","hasWormholeOrAlertParentElement","el","parent","parentElement","id","role","Overlay","Component","g","prototype","tracked","i","isOpenAtMount","isOpen","hadPaintedAtMount","hasPainted","focusedElement","mouseDownContentElement","didLockBodyScroll","cancelPaintWait","constructor","owner","shouldDeferMount","afterFirstPaint","isDestroying","isDestroyed","hasWaitedForPaint","willDestroy","handleClose","onClose","handleContentClick","event","closeOnOutsideClick","closeOnOverlayElementClick","handleOutsideClick","e","preventDefault","handleContentMouseDown","handleKeyDown","key","closeOnEscapeKey","stopImmediatePropagation","setupContent","modifier","transitionDuration","isAnimationEnabled","later","disableFocusTrap","preventAutoFocus","focus","keepOpen","activeElement","renderInPlace","blockScroll","onOpen","undefined","hasClosedOnce","didClose","preventFocusRestore","tabIndex","mountAnimationState","isFirstOpen","animationsEnabled","animateOnMount","canWaitForFrame","requestAnimationFrame","n","cached","skipEnterTransition","shouldSkipEnterTransition","isVisible","backdrop","macroCondition","isTesting","disableTransitions","focusTrapOptions","clickOutsideDeactivates","allowOutsideClick","classes","overlay","useStyles","class","inPlace","enableFlexContent","disableFlexContent","customContentModifier","maybeWithoutEnter","options","withoutEnterTransition","backdropTransition","isEnabled","transition","name","setComponentTemplate","precompileTemplate","strictMode","scope","Portal","Backdrop","on","cssTransition","onClickOutside","focusTrap"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA;;;;;;;;;;;;AAYC;AACD,SAASA,4BAAAA,CACP,GAAGC,IAAwC,EAC1C;AACD,EAAA,MAAMC,OAAOC,eAAA,CAAA,GAAmBF,IAAA,CAAA;AAEhC,EAAA,MAAMG,KAAA,GACHC,MAAQ,IACT,CAAC,GAAGC,UAAmB,KAAK;IAC1B,IAAI;AACF,MAAA,OAAQJ,IAAI,CAACG,MAAA,CAAO,CAAkC,GAAKC,UAAA,CAAA;AAC7D,IAAA,CAAA,CAAE,MAAM;AACN,MAAA,OAAOJ,IAAA;AACT,IAAA;EACF,CAAA;EAEF,OAAO;AACL,IAAA,GAAGA,IAAI;AACPK,IAAAA,QAAA,EAAUH,KAAA,CAAM,UAAA,CAAA;AAChBI,IAAAA,UAAA,EAAYJ,KAAA,CAAM,YAAA,CAAA;AAClBK,IAAAA,KAAA,EAAOL,KAAA,CAAM,OAAA,CAAA;IACbM,OAAA,EAASN,KAAA,C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AAA;EAEA,IAAIE,kBAAAA,GAAqB;IACvB,OAAO,IAAI,CAACH,iBAAiB,CAC3B,IAAI,CAACjH,IAAI,CAACoH,kBAAkB,IAAI;MAAEC,SAAA,EAAW,IAAI,CAAC7C;AAAmB,KAAA,CAAA;AAEzE,EAAA;EAEA,IAAI8C,UAAAA,GAAa;AACf,IAAA,IAAIJ,OAAmC,GAAgB;AACrDK,MAAAA,IAAA,EAAM,0BAAA;MACNF,SAAA,EAAW,IAAI,CAAC7C;KAClB;IAEA,IAAI,OAAO,IAAI,CAACxE,IAAI,CAACsH,UAAU,KAAK,QAAA,EAAU;AAC5CJ,MAAAA,OAAA,GAAU;AAAE,QAAA,GAAGA,OAAO;QAAE,GAAG,IAAI,CAAClH,IAAI,CAACsH;OAAW;AAClD,IAAA;AAEA,IAAA,OAAO,IAAI,CAACL,iBAAiB,CAACC,OAAA,CAAA;AAChC,EAAA;AAEA,EAAA;IAAAM,oBAAA,CAAAC,kBAAA,CAAA,k5CAAA,EAkDA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,MAAA;QAAAC,QAAA;QAAAC,EAAA;QAAAC,aAAA;QAAAC,cAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
@@ -1,18 +1,37 @@
1
1
  import Component from '@glimmer/component';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import { on } from '@ember/modifier';
2
4
  import { useStyles } from '@frontile/theme';
3
5
  import { precompileTemplate } from '@ember/template-compilation';
4
6
  import { setComponentTemplate } from '@ember/component';
7
+ import { d as decorateFieldV2, i as initializeDeferredDecorator } from '../../runtime--fcdnjmJ-BOdRhmsS.js';
5
8
 
6
9
  class Avatar extends Component {
10
+ static {
11
+ decorateFieldV2(this.prototype, "failedSrc", [tracked]);
12
+ }
13
+ #failedSrc = (initializeDeferredDecorator(this, "failedSrc"), void 0); // Keyed by URL rather than a boolean, so a new `@src` is tried afresh
14
+ // without having to reset anything when the argument changes.
7
15
  get classes() {
8
16
  const {
9
17
  avatar
10
18
  } = useStyles();
11
19
  return avatar({
12
20
  size: this.args.size,
13
- shape: this.args.shape
21
+ shape: this.args.shape,
22
+ fit: this.args.fit,
23
+ isBordered: this.args.isBordered
14
24
  });
15
25
  }
26
+ get hasImage() {
27
+ const {
28
+ src
29
+ } = this.args;
30
+ return Boolean(src) && src !== this.failedSrc;
31
+ }
32
+ handleImageError = () => {
33
+ this.failedSrc = this.args.src;
34
+ };
16
35
  get initials() {
17
36
  const {
18
37
  name,
@@ -27,19 +46,21 @@ class Avatar extends Component {
27
46
  }
28
47
  get shouldShowInitials() {
29
48
  const {
30
- src,
31
49
  name,
32
50
  firstName,
33
51
  lastName
34
52
  } = this.args;
35
- if (src) {
53
+ if (this.hasImage) {
36
54
  return false;
37
55
  }
38
56
  return Boolean(name || firstName || lastName);
39
57
  }
40
58
  static {
41
- setComponentTemplate(precompileTemplate("<span class={{this.classes.base class=@classes.base}} data-component=\"avatar\" data-part=\"base\" ...attributes>\n {{#if this.shouldShowInitials}}\n {{!-- role=\"img\" makes the contents presentational, so the initials stop\n being read. Only claim the role when there is an @alt to name it with;\n otherwise leave the letters as plain text. --}}\n <span aria-label={{@alt}} class={{this.classes.name class=@classes.name}} data-part=\"name\" role={{if @alt \"img\"}}>\n {{this.initials}}\n </span>\n {{/if}}\n {{#if @src}}\n {{!-- An omitted alt makes screen readers fall back to the URL. An empty\n one marks the image decorative, which is right beside a visible name. --}}\n <img class={{this.classes.img class=@classes.img}} data-part=\"img\" src={{@src}} alt={{if @alt @alt \"\"}} />\n {{/if}}\n</span>", {
42
- strictMode: true
59
+ setComponentTemplate(precompileTemplate("<span class={{this.classes.base class=@classes.base}} data-component=\"avatar\" data-part=\"base\" ...attributes>\n {{#if this.shouldShowInitials}}\n {{!-- role=\"img\" makes the contents presentational, so the initials stop\n being read. Only claim the role when there is an @alt to name it with;\n otherwise leave the letters as plain text. --}}\n <span aria-label={{@alt}} class={{this.classes.name class=@classes.name}} data-part=\"name\" role={{if @alt \"img\"}}>\n {{this.initials}}\n </span>\n {{/if}}\n {{#if this.hasImage}}\n {{!-- An omitted alt makes screen readers fall back to the URL. An empty\n one marks the image decorative, which is right beside a visible name. --}}\n <img class={{this.classes.img class=@classes.img}} data-part=\"img\" src={{@src}} alt={{if @alt @alt \"\"}} {{on \"error\" this.handleImageError}} />\n {{/if}}\n</span>", {
60
+ strictMode: true,
61
+ scope: () => ({
62
+ on
63
+ })
43
64
  }), this);
44
65
  }
45
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.js","sources":["../../../src/components/utilities/avatar.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport {\n useStyles,\n type AvatarVariants,\n type AvatarSlots,\n type SlotsToClasses\n} from '@frontile/theme';\n\ninterface AvatarSignature {\n Args: {\n /**\n * Controls the size of the avatar.\n *\n * @defaultValue 'md'\n */\n size?: AvatarVariants['size'];\n\n /**\n * Defines the shape of the avatar.\n *\n * @defaultValue 'circle'\n */\n shape?: AvatarVariants['shape'];\n\n /**\n * URL of the image to be displayed in the avatar.\n * If provided, the image will be used instead of initials.\n *\n */\n src?: string | null;\n\n /**\n * Full name of the user, used to generate initials.\n * If `@firstName` and `@lastName` are not provided, initials will be\n * derived from this property.\n */\n name?: string;\n\n /**\n * First name of the user, used to generate initials.\n * If `@name` is not provided, initials will be generated from\n * `@firstName` and `@lastName`.\n */\n firstName?: string;\n\n /**\n * Last name of the user, used to generate initials.\n * If `@name` is not provided, initials will be generated from\n * `@firstName` and `@lastName`.\n */\n lastName?: string;\n\n /**\n * Alternative text for accessibility.\n * If `@src` is provided, this text will be used as the `alt`\n * attribute for the image.\n * If only initials are displayed, this text will be read by screen readers.\n */\n alt?: string;\n\n /**\n * Custom CSS classes for styling different slots within the avatar component.\n */\n classes?: SlotsToClasses<AvatarSlots>;\n };\n\n /**\n * The root element of the avatar component, which is an HTML `<span>` tag.\n */\n Element: HTMLSpanElement;\n}\n\nclass Avatar extends Component<AvatarSignature> {\n get classes() {\n const { avatar } = useStyles();\n return avatar({\n size: this.args.size,\n shape: this.args.shape\n });\n }\n\n get initials() {\n const { name, firstName, lastName } = this.args;\n\n if (name) {\n return name\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((word) => word.charAt(0))\n .join('')\n .toUpperCase();\n }\n\n const initials = [firstName?.charAt(0), lastName?.charAt(0)]\n .filter(Boolean)\n .join('')\n .toUpperCase();\n\n return initials;\n }\n\n get shouldShowInitials() {\n const { src, name, firstName, lastName } = this.args;\n if (src) {\n return false;\n }\n\n return Boolean(name || firstName || lastName);\n }\n\n <template>\n <span\n class={{this.classes.base class=@classes.base}}\n data-component=\"avatar\"\n data-part=\"base\"\n ...attributes\n >\n {{#if this.shouldShowInitials}}\n {{! role=\"img\" makes the contents presentational, so the initials stop\n being read. Only claim the role when there is an @alt to name it with;\n otherwise leave the letters as plain text. }}\n <span\n aria-label={{@alt}}\n class={{this.classes.name class=@classes.name}}\n data-part=\"name\"\n role={{if @alt \"img\"}}\n >\n {{this.initials}}\n </span>\n {{/if}}\n {{#if @src}}\n {{! An omitted alt makes screen readers fall back to the URL. An empty\n one marks the image decorative, which is right beside a visible name. }}\n <img\n class={{this.classes.img class=@classes.img}}\n data-part=\"img\"\n src={{@src}}\n alt={{if @alt @alt \"\"}}\n />\n {{/if}}\n </span>\n </template>\n}\n\nexport { Avatar };\nexport default Avatar;\n"],"names":["Avatar","Component","classes","avatar","useStyles","size","args","shape","initials","name","firstName","lastName","trim","split","slice","map","word","charAt","join","toUpperCase","filter","Boolean","shouldShowInitials","src","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;AAwEA,MAAMA,eAAeC,SAAA,CAAU;EAC7B,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAQ,GAAGC,SAAA,EAAA;AACnB,IAAA,OAAOD,MAAA,CAAO;AACZE,MAAAA,IAAA,EAAM,IAAI,CAACC,IAAI,CAACD,IAAI;AACpBE,MAAAA,KAAA,EAAO,IAAI,CAACD,IAAI,CAACC;AACnB,KAAA,CAAA;AACF,EAAA;EAEA,IAAIC,QAAAA,GAAW;IACb,MAAM;MAAEC,IAAI;MAAEC,SAAS;AAAEC,MAAAA;KAAU,GAAG,IAAI,CAACL,IAAI;AAE/C,IAAA,IAAIG,IAAA,EAAM;AACR,MAAA,OAAOA,IAAA,CACJG,IAAI,EAAA,CACJC,KAAK,CAAC,KAAA,CAAA,CACNC,KAAK,CAAC,CAAA,EAAG,CAAA,CAAA,CACTC,GAAG,CAAEC,QAASA,IAAA,CAAKC,MAAM,CAAC,CAAA,CAAA,CAAA,CAC1BC,IAAI,CAAC,EAAA,CAAA,CACLC,WAAW,EAAA;AAChB,IAAA;AAEA,IAAA,MAAMX,QAAA,GAAW,CAACE,SAAA,EAAWO,MAAA,CAAO,CAAA,CAAA,EAAIN,QAAA,EAAUM,MAAA,CAAO,CAAA,CAAA,CAAG,CACzDG,MAAM,CAACC,OAAA,CAAA,CACPH,IAAI,CAAC,IACLC,WAAW,EAAA;AAEd,IAAA,OAAOX,QAAA;AACT,EAAA;EAEA,IAAIc,kBAAAA,GAAqB;IACvB,MAAM;MAAEC,GAAG;MAAEd,IAAI;MAAEC,SAAS;AAAEC,MAAAA;KAAU,GAAG,IAAI,CAACL,IAAI;AACpD,IAAA,IAAIiB,GAAA,EAAK;AACP,MAAA,OAAO,KAAA;AACT,IAAA;AAEA,IAAA,OAAOF,OAAA,CAAQZ,QAAQC,SAAA,IAAaC,QAAA,CAAA;AACtC,EAAA;AAEA,EAAA;IAAAa,oBAAA,CAAAC,kBAAA,CAAA,00BAAA,EA+BA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
1
+ {"version":3,"file":"avatar.js","sources":["../../../src/components/utilities/avatar.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { on } from '@ember/modifier';\nimport {\n useStyles,\n type AvatarVariants,\n type AvatarSlots,\n type SlotsToClasses\n} from '@frontile/theme';\n\ninterface AvatarSignature {\n Args: {\n /**\n * Controls the size of the avatar.\n *\n * @defaultValue 'md'\n */\n size?: AvatarVariants['size'];\n\n /**\n * Defines the shape of the avatar.\n *\n * @defaultValue 'circle'\n */\n shape?: AvatarVariants['shape'];\n\n /**\n * How the image fills the avatar. `cover` crops the image to fill the\n * avatar, which suits photos. `contain` shows the whole image, inset from\n * the edge, which suits logos and wordmarks.\n *\n * @defaultValue 'cover'\n */\n fit?: AvatarVariants['fit'];\n\n /**\n * Draws a faint hairline just inside the avatar's edge. Pass `false` to\n * remove it.\n *\n * @defaultValue true\n */\n isBordered?: boolean;\n\n /**\n * URL of the image to be displayed in the avatar.\n * If provided, the image will be used instead of initials. If the image\n * fails to load, the avatar falls back to the initials, or to an empty\n * plate when there is no name.\n */\n src?: string | null;\n\n /**\n * Full name of the user, used to generate initials.\n * If `@firstName` and `@lastName` are not provided, initials will be\n * derived from this property.\n */\n name?: string;\n\n /**\n * First name of the user, used to generate initials.\n * If `@name` is not provided, initials will be generated from\n * `@firstName` and `@lastName`.\n */\n firstName?: string;\n\n /**\n * Last name of the user, used to generate initials.\n * If `@name` is not provided, initials will be generated from\n * `@firstName` and `@lastName`.\n */\n lastName?: string;\n\n /**\n * Alternative text for accessibility.\n * If `@src` is provided, this text will be used as the `alt`\n * attribute for the image.\n * If only initials are displayed, this text will be read by screen readers.\n */\n alt?: string;\n\n /**\n * Custom CSS classes for styling different slots within the avatar component.\n */\n classes?: SlotsToClasses<AvatarSlots>;\n };\n\n /**\n * The root element of the avatar component, which is an HTML `<span>` tag.\n */\n Element: HTMLSpanElement;\n}\n\nclass Avatar extends Component<AvatarSignature> {\n // Keyed by URL rather than a boolean, so a new `@src` is tried afresh\n // without having to reset anything when the argument changes.\n @tracked failedSrc?: string | null;\n\n get classes() {\n const { avatar } = useStyles();\n return avatar({\n size: this.args.size,\n shape: this.args.shape,\n fit: this.args.fit,\n isBordered: this.args.isBordered\n });\n }\n\n get hasImage() {\n const { src } = this.args;\n return Boolean(src) && src !== this.failedSrc;\n }\n\n handleImageError = () => {\n this.failedSrc = this.args.src;\n };\n\n get initials() {\n const { name, firstName, lastName } = this.args;\n\n if (name) {\n return name\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((word) => word.charAt(0))\n .join('')\n .toUpperCase();\n }\n\n const initials = [firstName?.charAt(0), lastName?.charAt(0)]\n .filter(Boolean)\n .join('')\n .toUpperCase();\n\n return initials;\n }\n\n get shouldShowInitials() {\n const { name, firstName, lastName } = this.args;\n if (this.hasImage) {\n return false;\n }\n\n return Boolean(name || firstName || lastName);\n }\n\n <template>\n <span\n class={{this.classes.base class=@classes.base}}\n data-component=\"avatar\"\n data-part=\"base\"\n ...attributes\n >\n {{#if this.shouldShowInitials}}\n {{! role=\"img\" makes the contents presentational, so the initials stop\n being read. Only claim the role when there is an @alt to name it with;\n otherwise leave the letters as plain text. }}\n <span\n aria-label={{@alt}}\n class={{this.classes.name class=@classes.name}}\n data-part=\"name\"\n role={{if @alt \"img\"}}\n >\n {{this.initials}}\n </span>\n {{/if}}\n {{#if this.hasImage}}\n {{! An omitted alt makes screen readers fall back to the URL. An empty\n one marks the image decorative, which is right beside a visible name. }}\n <img\n class={{this.classes.img class=@classes.img}}\n data-part=\"img\"\n src={{@src}}\n alt={{if @alt @alt \"\"}}\n {{on \"error\" this.handleImageError}}\n />\n {{/if}}\n </span>\n </template>\n}\n\nexport { Avatar };\nexport default Avatar;\n"],"names":["Avatar","Component","g","prototype","tracked","i","classes","avatar","useStyles","size","args","shape","fit","isBordered","hasImage","src","Boolean","failedSrc","handleImageError","initials","name","firstName","lastName","trim","split","slice","map","word","charAt","join","toUpperCase","filter","shouldShowInitials","setComponentTemplate","precompileTemplate","strictMode","scope","on"],"mappings":";;;;;;;;AA4FA,MAAMA,eAAeC,SAAA,CAAU;AAAA,EAAA;IAAAC,eAAA,CAAA,IA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,CAAA,CAAA,EAAIN,QAAA,EAAUM,MAAA,CAAO,CAAA,CAAA,CAAG,CACzDG,MAAM,CAACf,OAAA,CAAA,CACPa,IAAI,CAAC,IACLC,WAAW,EAAA;AAEd,IAAA,OAAOX,QAAA;AACT,EAAA;EAEA,IAAIa,kBAAAA,GAAqB;IACvB,MAAM;MAAEZ,IAAI;MAAEC,SAAS;AAAEC,MAAAA;KAAU,GAAG,IAAI,CAACZ,IAAI;IAC/C,IAAI,IAAI,CAACI,QAAQ,EAAE;AACjB,MAAA,OAAO,KAAA;AACT,IAAA;AAEA,IAAA,OAAOE,OAAA,CAAQI,QAAQC,SAAA,IAAaC,QAAA,CAAA;AACtC,EAAA;AAEA,EAAA;IAAAW,oBAAA,CAAAC,kBAAA,CAAA,03BAAA,EAgCA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
@@ -102,9 +102,45 @@ class Collapsible extends Component {
102
102
  }
103
103
  willDestroy() {
104
104
  super.willDestroy();
105
+ this.cancelFrames();
105
106
  // Do not leave a waiter pending if we are torn down mid-transition.
106
107
  this.endWaiter();
107
108
  }
109
+ /**
110
+ * Frames scheduled by the current `expand`/`contract`. A frame left over
111
+ * from the previous direction would otherwise still apply its styles after
112
+ * the toggle, e.g. making a panel that was just closed visible again.
113
+ */
114
+ pendingFrames = new Set();
115
+ requestFrame(callback) {
116
+ const id = window.requestAnimationFrame(() => {
117
+ this.pendingFrames.delete(id);
118
+ callback();
119
+ });
120
+ this.pendingFrames.add(id);
121
+ }
122
+ cancelFrames() {
123
+ this.pendingFrames.forEach(id => window.cancelAnimationFrame(id));
124
+ this.pendingFrames.clear();
125
+ }
126
+ /**
127
+ * Ends the waiter when none of `properties` is transitioning after the
128
+ * styles just written. `onTransitionEnd` only hears about transitions that
129
+ * run: when the start and end values match -- a close that lands before the
130
+ * open frame ever made the panel visible, or a transition that never got
131
+ * to start -- no `transitionend` fires and the waiter would leak.
132
+ */
133
+ endWaiterUnlessTransitioning(element, properties) {
134
+ // Without the Web Animations API there is no way to tell; leave it to
135
+ // `onTransitionEnd`.
136
+ if (typeof element.getAnimations !== 'function') {
137
+ return;
138
+ }
139
+ const isTransitioning = element.getAnimations().some(animation => 'transitionProperty' in animation && properties.includes(animation.transitionProperty));
140
+ if (!isTransitioning) {
141
+ this.endWaiter();
142
+ }
143
+ }
108
144
  onTransitionEnd = event => {
109
145
  // `transitionend` bubbles, so ignore transitions of our own descendants.
110
146
  // Otherwise any child that animates height/opacity would get our inline
@@ -122,6 +158,10 @@ class Collapsible extends Component {
122
158
  // direction (open/close, with/without initialHeight) has settled.
123
159
  if (this.args.isOpen && event.propertyName === 'height' || !this.args.isOpen && event.propertyName === 'opacity' && element.style.opacity == '0' || this.args.isOpen && event.propertyName === 'opacity' && element.style.opacity == '1' || !this.args.isOpen && this.initialHeight && event.propertyName === 'height') {
124
160
  this.endWaiter();
161
+ } else if (event.propertyName === 'height' || event.propertyName === 'opacity') {
162
+ // The transition the condition above waits for may never have run
163
+ // (see `endWaiterUnlessTransitioning`); settle once nothing is left.
164
+ this.endWaiterUnlessTransitioning(element, ['height', 'opacity']);
125
165
  }
126
166
  }
127
167
  };
@@ -133,6 +173,7 @@ class Collapsible extends Component {
133
173
  }
134
174
  expand(element) {
135
175
  this.isCurrentlyOpen = true;
176
+ this.cancelFrames();
136
177
  // The transition is written as an inline style, so a
137
178
  // `motion-reduce:transition-none` class could never beat it. The check has
138
179
  // to happen here.
@@ -154,9 +195,10 @@ class Collapsible extends Component {
154
195
  element.style.transition = [this.heightTransition(0.4), this.opacityTransition(0.3)].join(', ');
155
196
  element.style.overflow = 'hidden';
156
197
  const height = element.scrollHeight;
157
- window.requestAnimationFrame(() => {
198
+ this.requestFrame(() => {
158
199
  element.style.opacity = '1';
159
200
  element.style.height = `${height}px`;
201
+ this.endWaiterUnlessTransitioning(element, ['height', 'opacity']);
160
202
  });
161
203
  }
162
204
  /**
@@ -176,6 +218,7 @@ class Collapsible extends Component {
176
218
  }
177
219
  contract(element) {
178
220
  this.isCurrentlyOpen = false;
221
+ this.cancelFrames();
179
222
  if (prefersReducedMotion()) {
180
223
  element.style.transition = '';
181
224
  element.style.overflow = 'hidden';
@@ -186,11 +229,12 @@ class Collapsible extends Component {
186
229
  const height = element.scrollHeight;
187
230
  element.style.transition = '';
188
231
  element.style.overflow = 'hidden';
189
- window.requestAnimationFrame(() => {
232
+ this.requestFrame(() => {
190
233
  element.style.height = `${height}px`;
191
234
  element.style.transition = [this.heightTransition(0.2), this.opacityTransition(0.3)].join(', ');
192
- window.requestAnimationFrame(() => {
235
+ this.requestFrame(() => {
193
236
  this.applyClosedState(element);
237
+ this.endWaiterUnlessTransitioning(element, ['height', 'opacity']);
194
238
  });
195
239
  });
196
240
  }
@@ -1 +1 @@
1
- {"version":3,"file":"collapsible.js","sources":["../../../src/components/utilities/collapsible.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { buildWaiter } from '@ember/test-waiters';\nimport { on } from '@ember/modifier';\nimport { modifier } from 'ember-modifier';\nimport safeStyles from '../../utils/safe-styles';\nimport { prefersReducedMotion } from '../../utils/prefers-reduced-motion';\nimport type Owner from '@ember/owner';\n\nconst waiter = buildWaiter('frontile:collapsible');\n\n/**\n * Runs a caller-supplied height through the browser's own CSS parser.\n *\n * `@initialHeight` ends up in an inline `style` attribute, so a value such as\n * `10px; position: fixed` would otherwise smuggle in a second declaration.\n * Assigning it to a detached element's `style.height` lets the CSSOM decide:\n * it accepts every real height (`10px`, `2rem`, `50%`, `0`,\n * `calc(1rem + 2px)`, `var(--x)`, …) and drops anything it cannot parse as a\n * single height value — a trailing declaration included. Returns the parsed\n * value, or `undefined` when the input is unusable.\n */\nfunction parseHeight(value: string | undefined): string | undefined {\n if (!value) {\n return undefined;\n }\n\n // Reject anything that could terminate the declaration up front. The CSSOM\n // check below catches this too, but the explicit test keeps the guarantee\n // even where `document` has no real CSS parser (SSR / prerender).\n if (/[;}]/.test(value)) {\n return undefined;\n }\n\n if (typeof document === 'undefined') {\n return value;\n }\n\n const probe = document.createElement('div');\n probe.style.height = value;\n\n return probe.style.height || undefined;\n}\n\ninterface CollapsibleArgs {\n /**\n * If true, the content will be visible\n */\n isOpen: boolean;\n\n /**\n * The height for the content in it's collapsed state.\n * The unit of the value should be included, eg. '10px'. Any CSS height is\n * accepted (`2rem`, `50%`, `calc(1rem + 2px)`, …); a value the CSS parser\n * rejects is ignored and the content collapses to `0`.\n *\n * @defaultValue 0\n */\n initialHeight?: string;\n}\n\ninterface CollapsibleSignature {\n Args: CollapsibleArgs;\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nclass Collapsible extends Component<CollapsibleSignature> {\n isInitiallyOpen = false;\n waiterToken?: unknown;\n isCurrentlyOpen = false;\n\n constructor(owner: Owner, args: CollapsibleArgs) {\n super(owner, args);\n\n if (this.args.isOpen) {\n this.isInitiallyOpen = true;\n this.isCurrentlyOpen = true;\n }\n }\n\n /**\n * `@initialHeight`, validated by the CSS parser. `undefined` when it was not\n * given or could not be parsed as a height, in which case the collapsed\n * state falls back to `0`.\n */\n get initialHeight(): string | undefined {\n return parseHeight(this.args.initialHeight);\n }\n\n get styles(): ReturnType<typeof safeStyles> {\n let styles: Record<string, string | number> = {};\n const initialHeight = this.initialHeight;\n\n if (!this.isInitiallyOpen) {\n styles = {\n ...styles,\n height: initialHeight || 0,\n opacity: initialHeight ? '1' : '0'\n };\n }\n\n if (initialHeight || !this.isInitiallyOpen) {\n styles = {\n ...styles,\n overflow: 'hidden'\n };\n }\n\n return safeStyles(styles);\n }\n\n hasSetupUpdate = false;\n update = modifier((element: HTMLElement, [isOpen]: boolean[]) => {\n // do not run update on the initial setup of modifier\n if (!this.hasSetupUpdate) {\n this.hasSetupUpdate = true;\n return;\n }\n\n if (this.isCurrentlyOpen !== !!isOpen) {\n // A previous transition may still be in flight; end its token first so\n // toggling faster than the animation cannot leak a test waiter.\n this.endWaiter();\n this.waiterToken = waiter.beginAsync();\n }\n\n if (isOpen) {\n this.expand(element);\n } else {\n this.contract(element);\n }\n });\n\n endWaiter(): void {\n if (this.waiterToken) {\n const token = this.waiterToken;\n // Clear before ending so the same token can never be ended twice.\n this.waiterToken = undefined;\n waiter.endAsync(token);\n }\n }\n\n willDestroy(): void {\n super.willDestroy();\n // Do not leave a waiter pending if we are torn down mid-transition.\n this.endWaiter();\n }\n\n onTransitionEnd = (event: TransitionEvent) => {\n // `transitionend` bubbles, so ignore transitions of our own descendants.\n // Otherwise any child that animates height/opacity would get our inline\n // styles stamped onto it.\n if (event.target !== event.currentTarget) {\n return;\n }\n\n const element = event.currentTarget as HTMLElement;\n\n if (\n (event.propertyName === 'height' || event.propertyName == 'opacity') &&\n this.args.isOpen\n ) {\n element.style.height = 'auto';\n element.style.overflow = '';\n }\n if (this.waiterToken) {\n // End the waiter once the transition that matters for the current\n // direction (open/close, with/without initialHeight) has settled.\n if (\n (this.args.isOpen && event.propertyName === 'height') ||\n (!this.args.isOpen &&\n event.propertyName === 'opacity' &&\n element.style.opacity == '0') ||\n (this.args.isOpen &&\n event.propertyName === 'opacity' &&\n element.style.opacity == '1') ||\n (!this.args.isOpen &&\n this.initialHeight &&\n event.propertyName === 'height')\n ) {\n this.endWaiter();\n }\n }\n };\n\n heightTransition(duration: number): string {\n return `height ${duration}s cubic-bezier(0.4, 0, 0.2, 1) 0ms`;\n }\n\n opacityTransition(duration: number): string {\n return `opacity ${duration}s ease-in-out 0ms`;\n }\n\n expand(element: HTMLElement): void {\n this.isCurrentlyOpen = true;\n\n // The transition is written as an inline style, so a\n // `motion-reduce:transition-none` class could never beat it. The check has\n // to happen here.\n //\n // Height, overflow and opacity below land where `onTransitionEnd` leaves\n // them at the end of a normal expand. `transition` is the one property\n // that differs: the animated path never clears it, so an element that has\n // animated keeps an inline `transition` at rest while this path clears it.\n // Nothing reads that property between runs, so the asymmetry is harmless\n // -- but it is why this is not, strictly, the same terminal state.\n if (prefersReducedMotion()) {\n element.style.transition = '';\n element.style.overflow = '';\n element.style.opacity = '1';\n element.style.height = 'auto';\n this.endWaiter();\n return;\n }\n\n element.style.transition = [\n this.heightTransition(0.4),\n this.opacityTransition(0.3)\n ].join(', ');\n element.style.overflow = 'hidden';\n\n const height = element.scrollHeight;\n window.requestAnimationFrame(() => {\n element.style.opacity = '1';\n element.style.height = `${height}px`;\n });\n }\n\n /**\n * The geometry a collapsed panel ends at.\n *\n * Shared by the animated path's final frame and the reduced-motion early\n * return. Extracted rather than written twice: these two have to agree\n * about what \"closed\" means, and a second copy is only a way for them to\n * drift apart.\n */\n applyClosedState(element: HTMLElement): void {\n const initialHeight = this.initialHeight;\n\n if (!initialHeight) {\n element.style.opacity = '0';\n }\n element.style.height = initialHeight || '0';\n }\n\n contract(element: HTMLElement): void {\n this.isCurrentlyOpen = false;\n\n if (prefersReducedMotion()) {\n element.style.transition = '';\n element.style.overflow = 'hidden';\n this.applyClosedState(element);\n this.endWaiter();\n return;\n }\n\n const height = element.scrollHeight;\n element.style.transition = '';\n element.style.overflow = 'hidden';\n\n window.requestAnimationFrame(() => {\n element.style.height = `${height}px`;\n element.style.transition = [\n this.heightTransition(0.2),\n this.opacityTransition(0.3)\n ].join(', ');\n\n window.requestAnimationFrame(() => {\n this.applyClosedState(element);\n });\n });\n }\n\n <template>\n <div\n style={{this.styles}}\n ...attributes\n {{this.update @isOpen}}\n {{on \"transitionend\" this.onTransitionEnd}}\n >\n {{yield}}\n </div>\n </template>\n}\n\nexport { Collapsible, type CollapsibleSignature };\nexport default Collapsible;\n"],"names":["waiter","buildWaiter","parseHeight","value","undefined","test","document","probe","createElement","style","height","Collapsible","Component","isInitiallyOpen","waiterToken","isCurrentlyOpen","constructor","owner","args","isOpen","initialHeight","styles","opacity","overflow","safeStyles","hasSetupUpdate","update","modifier","element","endWaiter","beginAsync","expand","contract","token","endAsync","willDestroy","onTransitionEnd","event","target","currentTarget","propertyName","heightTransition","duration","opacityTransition","prefersReducedMotion","transition","join","scrollHeight","window","requestAnimationFrame","applyClosedState","setComponentTemplate","precompileTemplate","strictMode","scope","on"],"mappings":";;;;;;;;;AAQA,MAAMA,SAASC,WAAA,CAAY,sBAAA,CAAA;AAE3B;;;;;;;;;;;AAWA,SAASC,YAAYC,KAAyB,EAAqB;EACjE,IAAI,CAACA,KAAA,EAAO;AACV,IAAA,OAAOC,SAAA;AACT,EAAA;AAEA;AACA;AACA;AACA,EAAA,IAAI,MAAA,CAAOC,IAAI,CAACF,KAAA,CAAA,EAAQ;AACtB,IAAA,OAAOC,SAAA;AACT,EAAA;AAEA,EAAA,IAAI,OAAOE,aAAa,WAAA,EAAa;AACnC,IAAA,OAAOH,KAAA;AACT,EAAA;AAEA,EAAA,MAAMI,KAAA,GAAQD,QAAA,CAASE,aAAa,CAAC,KAAA,CAAA;AACrCD,EAAAA,KAAA,CAAME,KAAK,CAACC,MAAM,GAAGP,KAAA;AAErB,EAAA,OAAOI,KAAA,CAAME,KAAK,CAACC,MAAM,IAAIN,SAAA;AAC/B;AA2BA,MAAMO,oBAAoBC,SAAA,CAAU;AAClCC,EAAAA,eAAA,GAAkB,KAAA;EAClBC,WAAA;AACAC,EAAAA,eAAA,GAAkB,KAAA;AAElBC,EAAAA,WAAAA,CAAYC,KAAY,EAAEC,IAAqB,EAAE;AAC/C,IAAA,KAAK,CAACD,KAAA,EAAOC,IAAA,CAAA;AAEb,IAAA,IAAI,IAAI,CAACA,IAAI,CAACC,MAAM,EAAE;MACpB,IAAI,CAACN,eAAe,GAAG,IAAA;MACvB,IAAI,CAACE,eAAe,GAAG,IAAA;AACzB,IAAA;AACF,EAAA;AAEA;;;;AAIC;EACD,IAAIK,aAAAA,GAAoC;AACtC,IAAA,OAAOlB,WAAA,CAAY,IAAI,CAACgB,IAAI,CAACE,aAAa,CAAA;AAC5C,EAAA;EAEA,IAAIC,MAAAA,GAAwC;IAC1C,IAAIA,SAA0C,EAAC;AAC/C,IAAA,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EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
1
+ {"version":3,"file":"collapsible.js","sources":["../../../src/components/utilities/collapsible.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { buildWaiter } from '@ember/test-waiters';\nimport { on } from '@ember/modifier';\nimport { modifier } from 'ember-modifier';\nimport safeStyles from '../../utils/safe-styles';\nimport { prefersReducedMotion } from '../../utils/prefers-reduced-motion';\nimport type Owner from '@ember/owner';\n\nconst waiter = buildWaiter('frontile:collapsible');\n\n/**\n * Runs a caller-supplied height through the browser's own CSS parser.\n *\n * `@initialHeight` ends up in an inline `style` attribute, so a value such as\n * `10px; position: fixed` would otherwise smuggle in a second declaration.\n * Assigning it to a detached element's `style.height` lets the CSSOM decide:\n * it accepts every real height (`10px`, `2rem`, `50%`, `0`,\n * `calc(1rem + 2px)`, `var(--x)`, …) and drops anything it cannot parse as a\n * single height value — a trailing declaration included. Returns the parsed\n * value, or `undefined` when the input is unusable.\n */\nfunction parseHeight(value: string | undefined): string | undefined {\n if (!value) {\n return undefined;\n }\n\n // Reject anything that could terminate the declaration up front. The CSSOM\n // check below catches this too, but the explicit test keeps the guarantee\n // even where `document` has no real CSS parser (SSR / prerender).\n if (/[;}]/.test(value)) {\n return undefined;\n }\n\n if (typeof document === 'undefined') {\n return value;\n }\n\n const probe = document.createElement('div');\n probe.style.height = value;\n\n return probe.style.height || undefined;\n}\n\ninterface CollapsibleArgs {\n /**\n * If true, the content will be visible\n */\n isOpen: boolean;\n\n /**\n * The height for the content in it's collapsed state.\n * The unit of the value should be included, eg. '10px'. Any CSS height is\n * accepted (`2rem`, `50%`, `calc(1rem + 2px)`, …); a value the CSS parser\n * rejects is ignored and the content collapses to `0`.\n *\n * @defaultValue 0\n */\n initialHeight?: string;\n}\n\ninterface CollapsibleSignature {\n Args: CollapsibleArgs;\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nclass Collapsible extends Component<CollapsibleSignature> {\n isInitiallyOpen = false;\n waiterToken?: unknown;\n isCurrentlyOpen = false;\n\n constructor(owner: Owner, args: CollapsibleArgs) {\n super(owner, args);\n\n if (this.args.isOpen) {\n this.isInitiallyOpen = true;\n this.isCurrentlyOpen = true;\n }\n }\n\n /**\n * `@initialHeight`, validated by the CSS parser. `undefined` when it was not\n * given or could not be parsed as a height, in which case the collapsed\n * state falls back to `0`.\n */\n get initialHeight(): string | undefined {\n return parseHeight(this.args.initialHeight);\n }\n\n get styles(): ReturnType<typeof safeStyles> {\n let styles: Record<string, string | number> = {};\n const initialHeight = this.initialHeight;\n\n if (!this.isInitiallyOpen) {\n styles = {\n ...styles,\n height: initialHeight || 0,\n opacity: initialHeight ? '1' : '0'\n };\n }\n\n if (initialHeight || !this.isInitiallyOpen) {\n styles = {\n ...styles,\n overflow: 'hidden'\n };\n }\n\n return safeStyles(styles);\n }\n\n hasSetupUpdate = false;\n update = modifier((element: HTMLElement, [isOpen]: boolean[]) => {\n // do not run update on the initial setup of modifier\n if (!this.hasSetupUpdate) {\n this.hasSetupUpdate = true;\n return;\n }\n\n if (this.isCurrentlyOpen !== !!isOpen) {\n // A previous transition may still be in flight; end its token first so\n // toggling faster than the animation cannot leak a test waiter.\n this.endWaiter();\n this.waiterToken = waiter.beginAsync();\n }\n\n if (isOpen) {\n this.expand(element);\n } else {\n this.contract(element);\n }\n });\n\n endWaiter(): void {\n if (this.waiterToken) {\n const token = this.waiterToken;\n // Clear before ending so the same token can never be ended twice.\n this.waiterToken = undefined;\n waiter.endAsync(token);\n }\n }\n\n willDestroy(): void {\n super.willDestroy();\n this.cancelFrames();\n // Do not leave a waiter pending if we are torn down mid-transition.\n this.endWaiter();\n }\n\n /**\n * Frames scheduled by the current `expand`/`contract`. A frame left over\n * from the previous direction would otherwise still apply its styles after\n * the toggle, e.g. making a panel that was just closed visible again.\n */\n pendingFrames = new Set<number>();\n\n requestFrame(callback: () => void): void {\n const id = window.requestAnimationFrame(() => {\n this.pendingFrames.delete(id);\n callback();\n });\n this.pendingFrames.add(id);\n }\n\n cancelFrames(): void {\n this.pendingFrames.forEach((id) => window.cancelAnimationFrame(id));\n this.pendingFrames.clear();\n }\n\n /**\n * Ends the waiter when none of `properties` is transitioning after the\n * styles just written. `onTransitionEnd` only hears about transitions that\n * run: when the start and end values match -- a close that lands before the\n * open frame ever made the panel visible, or a transition that never got\n * to start -- no `transitionend` fires and the waiter would leak.\n */\n endWaiterUnlessTransitioning(\n element: HTMLElement,\n properties: string[]\n ): void {\n // Without the Web Animations API there is no way to tell; leave it to\n // `onTransitionEnd`.\n if (typeof element.getAnimations !== 'function') {\n return;\n }\n\n const isTransitioning = element\n .getAnimations()\n .some(\n (animation) =>\n 'transitionProperty' in animation &&\n properties.includes((animation as CSSTransition).transitionProperty)\n );\n\n if (!isTransitioning) {\n this.endWaiter();\n }\n }\n\n onTransitionEnd = (event: TransitionEvent) => {\n // `transitionend` bubbles, so ignore transitions of our own descendants.\n // Otherwise any child that animates height/opacity would get our inline\n // styles stamped onto it.\n if (event.target !== event.currentTarget) {\n return;\n }\n\n const element = event.currentTarget as HTMLElement;\n\n if (\n (event.propertyName === 'height' || event.propertyName == 'opacity') &&\n this.args.isOpen\n ) {\n element.style.height = 'auto';\n element.style.overflow = '';\n }\n if (this.waiterToken) {\n // End the waiter once the transition that matters for the current\n // direction (open/close, with/without initialHeight) has settled.\n if (\n (this.args.isOpen && event.propertyName === 'height') ||\n (!this.args.isOpen &&\n event.propertyName === 'opacity' &&\n element.style.opacity == '0') ||\n (this.args.isOpen &&\n event.propertyName === 'opacity' &&\n element.style.opacity == '1') ||\n (!this.args.isOpen &&\n this.initialHeight &&\n event.propertyName === 'height')\n ) {\n this.endWaiter();\n } else if (\n event.propertyName === 'height' ||\n event.propertyName === 'opacity'\n ) {\n // The transition the condition above waits for may never have run\n // (see `endWaiterUnlessTransitioning`); settle once nothing is left.\n this.endWaiterUnlessTransitioning(element, ['height', 'opacity']);\n }\n }\n };\n\n heightTransition(duration: number): string {\n return `height ${duration}s cubic-bezier(0.4, 0, 0.2, 1) 0ms`;\n }\n\n opacityTransition(duration: number): string {\n return `opacity ${duration}s ease-in-out 0ms`;\n }\n\n expand(element: HTMLElement): void {\n this.isCurrentlyOpen = true;\n this.cancelFrames();\n\n // The transition is written as an inline style, so a\n // `motion-reduce:transition-none` class could never beat it. The check has\n // to happen here.\n //\n // Height, overflow and opacity below land where `onTransitionEnd` leaves\n // them at the end of a normal expand. `transition` is the one property\n // that differs: the animated path never clears it, so an element that has\n // animated keeps an inline `transition` at rest while this path clears it.\n // Nothing reads that property between runs, so the asymmetry is harmless\n // -- but it is why this is not, strictly, the same terminal state.\n if (prefersReducedMotion()) {\n element.style.transition = '';\n element.style.overflow = '';\n element.style.opacity = '1';\n element.style.height = 'auto';\n this.endWaiter();\n return;\n }\n\n element.style.transition = [\n this.heightTransition(0.4),\n this.opacityTransition(0.3)\n ].join(', ');\n element.style.overflow = 'hidden';\n\n const height = element.scrollHeight;\n this.requestFrame(() => {\n element.style.opacity = '1';\n element.style.height = `${height}px`;\n this.endWaiterUnlessTransitioning(element, ['height', 'opacity']);\n });\n }\n\n /**\n * The geometry a collapsed panel ends at.\n *\n * Shared by the animated path's final frame and the reduced-motion early\n * return. Extracted rather than written twice: these two have to agree\n * about what \"closed\" means, and a second copy is only a way for them to\n * drift apart.\n */\n applyClosedState(element: HTMLElement): void {\n const initialHeight = this.initialHeight;\n\n if (!initialHeight) {\n element.style.opacity = '0';\n }\n element.style.height = initialHeight || '0';\n }\n\n contract(element: HTMLElement): void {\n this.isCurrentlyOpen = false;\n this.cancelFrames();\n\n if (prefersReducedMotion()) {\n element.style.transition = '';\n element.style.overflow = 'hidden';\n this.applyClosedState(element);\n this.endWaiter();\n return;\n }\n\n const height = element.scrollHeight;\n element.style.transition = '';\n element.style.overflow = 'hidden';\n\n this.requestFrame(() => {\n element.style.height = `${height}px`;\n element.style.transition = [\n this.heightTransition(0.2),\n this.opacityTransition(0.3)\n ].join(', ');\n\n this.requestFrame(() => {\n this.applyClosedState(element);\n this.endWaiterUnlessTransitioning(element, ['height', 'opacity']);\n });\n });\n }\n\n <template>\n <div\n style={{this.styles}}\n ...attributes\n {{this.update @isOpen}}\n {{on \"transitionend\" this.onTransitionEnd}}\n >\n {{yield}}\n </div>\n </template>\n}\n\nexport { Collapsible, type CollapsibleSignature };\nexport default Collapsible;\n"],"names":["waiter","buildWaiter","parseHeight","value","undefined","test","document","probe","createElement","style","height","Collapsible","Component","isInitiallyOpen","waiterToken","isCurrentlyOpen","constructor","owner","args","isOpen","initialHeight","styles","opacity","overflow","safeStyles","hasSetupUpdate","update","modifier","element","endWaiter","beginAsync","expand","contract","token","endAsync","willDestroy","cancelFrames","pendingFrames","Set","requestFrame","callback","id","window","requestAnimationFrame","delete","add","forEach","cancelAnimationFrame","clear","endWaiterUnlessTransitioning","properties","getAnimations","isTransitioning","some","animation","includes","transitionProperty","onTransitionEnd","event","target","currentTarget","propertyName","heightTransition","duration","opacityTransition","prefersReducedMotion","transition","join","scrollHeight","applyClosedState","setComponentTemplate","precompileTemplate","strictMode","scope","on"],"mappings":";;;;;;;;;AAQA,MAAMA,SAASC,WAAA,CAAY,sBAAA,CAAA;AAE3B;;;;;;;;;;;AAWA,SAASC,YAAYC,KAAyB,EAAqB;EACjE,IAAI,CAACA,KAAA,EAAO;AACV,IAAA,OAAOC,SAAA;AACT,EAAA;AAEA;AACA;AACA;AACA,EAAA,IAAI,MAAA,CAAOC,IAAI,CAACF,KAAA,CAAA,EAAQ;AACtB,IAAA,OAAOC,SAAA;AACT,EAAA;AAEA,EAAA,IAAI,OAAOE,aAAa,WAAA,EAAa;AACnC,IAAA,OAAOH,KAAA;AACT,EAAA;AAEA,EAAA,MAAMI,KAAA,GAAQD,QAAA,CAASE,aAAa,CAAC,KAAA,CAAA;AACrCD,EAAAA,KAAA,CAAME,KAAK,CAACC,MAAM,GAAGP,KAAA;AA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AS,EAAA;AACd,MAAA;AACF,IAAA;AAEA,IAAA,MAAMnB,MAAA,GAASkB,QAAQwC,YAAY;AACnCxC,IAAAA,OAAA,CAAQnB,KAAK,CAACyD,UAAU,GAAG,EAAA;AAC3BtC,IAAAA,OAAA,CAAQnB,KAAK,CAACc,QAAQ,GAAG,QAAA;IAEzB,IAAI,CAACgB,YAAY,CAAC,MAAA;AAChBX,MAAAA,OAAA,CAAQnB,KAAK,CAACC,MAAM,GAAG,CAAA,EAAGA,MAAA,CAAA,EAAA,CAAU;MACpCkB,OAAA,CAAQnB,KAAK,CAACyD,UAAU,GAAG,CACzB,IAAI,CAACJ,gBAAgB,CAAC,GAAA,CAAA,EACtB,IAAI,CAACE,iBAAiB,CAAC,GAAA,CAAA,CACxB,CAACG,IAAI,CAAC,IAAA,CAAA;MAEP,IAAI,CAAC5B,YAAY,CAAC,MAAA;AAChB,QAAA,IAAI,CAAC8B,gBAAgB,CAACzC,OAAA,CAAA;QACtB,IAAI,CAACqB,4BAA4B,CAACrB,OAAA,EAAS,CAAC,QAAA,EAAU,SAAA,CAAU,CAAA;AAClE,MAAA,CAAA,CAAA;AACF,IAAA,CAAA,CAAA;AACF,EAAA;AAEA,EAAA;IAAA0C,oBAAA,CAAAC,kBAAA,CAAA,sIAAA,EASA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
package/dist/forms.js CHANGED
@@ -16,7 +16,10 @@ export { RadioGroup } from './components/forms/radio-group.js';
16
16
  export { FormControl } from './components/forms/form-control.js';
17
17
  export { Switch } from './components/forms/switch.js';
18
18
  export { DatePicker } from './components/forms/date-picker/date-picker.js';
19
- export { formatValue, isEmptyValue, parseDate, parseRange, toWire } from './components/forms/date-picker/value.js';
19
+ export { DEFAULT_TIME_FORMAT, formatValue, isEmptyValue, parseDate, parseRange, toWire, withTimeOf } from './components/forms/date-picker/value.js';
20
+ export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, timeOf, toDate, toNumericFormat, withTime, withValue } from './components/forms/date-input/segments.js';
21
+ export { formatForClipboard, parsePasted, splitRange } from './components/forms/date-input/clipboard.js';
22
+ export { DateInput } from './components/forms/date-input/date-input.js';
20
23
  export { StandardValidator } from './utils/standard-validator.js';
21
- export { deepEqual, flattenData, hasNestedData, unflattenData } from './utils/nested-data.js';
24
+ export { deepEqual, flattenData, getPath, hasNestedData, unflattenData } from './utils/nested-data.js';
22
25
  //# sourceMappingURL=forms.js.map
package/dist/forms.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"forms.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"forms.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -33,9 +33,12 @@ export { RadioGroup } from './components/forms/radio-group.js';
33
33
  export { FormControl } from './components/forms/form-control.js';
34
34
  export { Switch } from './components/forms/switch.js';
35
35
  export { DatePicker } from './components/forms/date-picker/date-picker.js';
36
- export { formatValue, isEmptyValue, parseDate, parseRange, toWire } from './components/forms/date-picker/value.js';
36
+ export { DEFAULT_TIME_FORMAT, formatValue, isEmptyValue, parseDate, parseRange, toWire, withTimeOf } from './components/forms/date-picker/value.js';
37
+ export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, timeOf, toDate, toNumericFormat, withTime, withValue } from './components/forms/date-input/segments.js';
38
+ export { formatForClipboard, parsePasted, splitRange } from './components/forms/date-input/clipboard.js';
39
+ export { DateInput } from './components/forms/date-input/date-input.js';
37
40
  export { StandardValidator } from './utils/standard-validator.js';
38
- export { deepEqual, flattenData, hasNestedData, unflattenData } from './utils/nested-data.js';
41
+ export { deepEqual, flattenData, getPath, hasNestedData, unflattenData } from './utils/nested-data.js';
39
42
  export { Overlay } from './components/overlays/overlay.js';
40
43
  export { default as Modal } from './components/overlays/modal.js';
41
44
  export { default as Drawer } from './components/overlays/drawer.js';
@@ -80,7 +83,7 @@ export { BreadcrumbsItem } from './components/navigation/breadcrumbs/item.js';
80
83
  export { BreadcrumbsEllipsis } from './components/navigation/breadcrumbs/ellipsis.js';
81
84
  export { Accordion } from './components/disclosure/accordion/accordion.js';
82
85
  export { AccordionItem } from './components/disclosure/accordion/item.js';
83
- import './manager-jDaRVZ5o.js';
86
+ import './manager-Dge4r8Vn.js';
84
87
  import '@ember/service';
85
88
  export { N as NotificationCard } from './notification-card-dz-eE6z9.js';
86
89
  export { NotificationsContainer } from './components/notifications/notifications-container.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,8 +1,7 @@
1
1
  import { tracked } from '@glimmer/tracking';
2
2
  import { deprecate, assert } from '@ember/debug';
3
3
  import { cancel, later } from '@ember/runloop';
4
- import { action, get } from '@ember/object';
5
- import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2 } from './runtime--fcdnjmJ-BOdRhmsS.js';
4
+ import { d as decorateFieldV2, i as initializeDeferredDecorator } from './runtime--fcdnjmJ-BOdRhmsS.js';
6
5
  import { getOwner } from '@ember/owner';
7
6
  import { isDestroyed } from '@ember/destroyable';
8
7
 
@@ -25,16 +24,13 @@ class Timer {
25
24
  this.onFinish = onFinish;
26
25
  this.setup();
27
26
  }
28
- clear() {
27
+ clear = () => {
29
28
  this.isRunning = false;
30
29
  if (this.timer) {
31
30
  cancel(this.timer);
32
31
  }
33
- }
34
- static {
35
- decorateMethodV2(this.prototype, "clear", [action]);
36
- }
37
- pause() {
32
+ };
33
+ pause = () => {
38
34
  // Pausing an already paused timer would subtract the elapsed time twice,
39
35
  // eventually driving `remaining` to zero or below.
40
36
  if (!this.isRunning) {
@@ -42,21 +38,15 @@ class Timer {
42
38
  }
43
39
  this.clear();
44
40
  this.remaining = Math.max(0, this.remaining - (Date.now() - this.start));
45
- }
46
- static {
47
- decorateMethodV2(this.prototype, "pause", [action]);
48
- }
49
- resume() {
41
+ };
42
+ resume = () => {
50
43
  // Already counting down; resuming again would restart the remaining time.
51
44
  if (this.isRunning) {
52
45
  return;
53
46
  }
54
47
  this.clear();
55
48
  this.setup();
56
- }
57
- static {
58
- decorateMethodV2(this.prototype, "resume", [action]);
59
- }
49
+ };
60
50
  setup() {
61
51
  this.start = Date.now();
62
52
  this.isRunning = true;
@@ -68,7 +58,7 @@ class Timer {
68
58
  }
69
59
 
70
60
  function getConfigOption(config, key, defaultValue) {
71
- const value = get(config, key);
61
+ const value = config[key];
72
62
  if (value === undefined) {
73
63
  return defaultValue;
74
64
  }
@@ -389,4 +379,4 @@ class NotificationsManager {
389
379
  }
390
380
 
391
381
  export { Notification as N, Timer as T, NotificationsManager as a };
392
- //# sourceMappingURL=manager-jDaRVZ5o.js.map
382
+ //# sourceMappingURL=manager-Dge4r8Vn.js.map