frontile 0.18.5 → 0.18.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/-private/icons.d.ts +4 -0
- package/declarations/-private/icons.d.ts.map +1 -1
- package/declarations/-private/reveal-within.d.ts +19 -0
- package/declarations/-private/reveal-within.d.ts.map +1 -0
- package/declarations/components/collections/calendar/year-grid.d.ts.map +1 -1
- package/declarations/components/collections/dropdown/dropdown.d.ts +50 -53
- package/declarations/components/collections/dropdown/dropdown.d.ts.map +1 -1
- package/declarations/components/collections/listbox/item.d.ts +52 -1
- package/declarations/components/collections/listbox/item.d.ts.map +1 -1
- package/declarations/components/forms/date-input/segment-group.d.ts +2 -1
- package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -1
- package/declarations/components/forms/date-input/segments.d.ts +3 -1
- package/declarations/components/forms/date-input/segments.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/date-picker.d.ts +119 -1
- package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/time-columns.d.ts +87 -0
- package/declarations/components/forms/date-picker/time-columns.d.ts.map +1 -0
- package/declarations/components/forms/date-picker/types.d.ts +28 -0
- package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
- package/declarations/components/forms/select/native-mirror.d.ts +3 -2
- package/declarations/components/forms/select/native-mirror.d.ts.map +1 -1
- package/declarations/components/forms/select/select.d.ts +31 -2
- package/declarations/components/forms/select/select.d.ts.map +1 -1
- package/declarations/components/forms/select/types.d.ts +3 -2
- package/declarations/components/forms/select/types.d.ts.map +1 -1
- package/declarations/components/layout/app-layout-state.d.ts +32 -0
- package/declarations/components/layout/app-layout-state.d.ts.map +1 -0
- package/declarations/components/layout/app-layout.d.ts +954 -0
- package/declarations/components/layout/app-layout.d.ts.map +1 -0
- package/declarations/components/layout/aside-toggle.d.ts +55 -0
- package/declarations/components/layout/aside-toggle.d.ts.map +1 -0
- package/declarations/components/layout/aside.d.ts +761 -0
- package/declarations/components/layout/aside.d.ts.map +1 -0
- package/declarations/components/layout/bottom-nav-more.d.ts +123 -0
- package/declarations/components/layout/bottom-nav-more.d.ts.map +1 -0
- package/declarations/components/layout/bottom-nav.d.ts +60 -0
- package/declarations/components/layout/bottom-nav.d.ts.map +1 -0
- package/declarations/components/layout/context.d.ts +134 -0
- package/declarations/components/layout/context.d.ts.map +1 -0
- package/declarations/components/layout/index.d.ts +14 -0
- package/declarations/components/layout/index.d.ts.map +1 -0
- package/declarations/components/layout/main.d.ts +28 -0
- package/declarations/components/layout/main.d.ts.map +1 -0
- package/declarations/components/layout/menu-toggle.d.ts +58 -0
- package/declarations/components/layout/menu-toggle.d.ts.map +1 -0
- package/declarations/components/layout/nav-context.d.ts +45 -0
- package/declarations/components/layout/nav-context.d.ts.map +1 -0
- package/declarations/components/layout/nav-folder.d.ts +216 -0
- package/declarations/components/layout/nav-folder.d.ts.map +1 -0
- package/declarations/components/layout/nav-item.d.ts +220 -0
- package/declarations/components/layout/nav-item.d.ts.map +1 -0
- package/declarations/components/layout/nav-link.d.ts +67 -0
- package/declarations/components/layout/nav-link.d.ts.map +1 -0
- package/declarations/components/layout/navbar.d.ts +27 -0
- package/declarations/components/layout/navbar.d.ts.map +1 -0
- package/declarations/components/layout/page-header.d.ts +40 -0
- package/declarations/components/layout/page-header.d.ts.map +1 -0
- package/declarations/components/layout/sidebar-group.d.ts +41 -0
- package/declarations/components/layout/sidebar-group.d.ts.map +1 -0
- package/declarations/components/layout/sidebar-toggle.d.ts +71 -0
- package/declarations/components/layout/sidebar-toggle.d.ts.map +1 -0
- package/declarations/components/layout/sidebar.d.ts +904 -0
- package/declarations/components/layout/sidebar.d.ts.map +1 -0
- package/declarations/components/navigation/index.d.ts +1 -0
- package/declarations/components/navigation/index.d.ts.map +1 -1
- package/declarations/components/navigation/stepper/collapse-menu.d.ts +42 -0
- package/declarations/components/navigation/stepper/collapse-menu.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/list.d.ts +24 -0
- package/declarations/components/navigation/stepper/list.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/panel.d.ts +42 -0
- package/declarations/components/navigation/stepper/panel.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/step.d.ts +123 -0
- package/declarations/components/navigation/stepper/step.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/stepper.d.ts +947 -0
- package/declarations/components/navigation/stepper/stepper.d.ts.map +1 -0
- package/declarations/components/navigation/stepper.d.ts +6 -0
- package/declarations/components/navigation/stepper.d.ts.map +1 -0
- package/declarations/components/navigation/tab-nav/item.d.ts +2 -2
- package/declarations/components/navigation/tab-nav/item.d.ts.map +1 -1
- package/declarations/components/overlays/overlay.d.ts +17 -2
- package/declarations/components/overlays/overlay.d.ts.map +1 -1
- package/declarations/components/overlays/portal.d.ts.map +1 -1
- package/declarations/components/utilities/collapsible.d.ts +19 -2
- package/declarations/components/utilities/collapsible.d.ts.map +1 -1
- package/declarations/index.d.ts +1 -0
- package/declarations/index.d.ts.map +1 -1
- package/declarations/layout.d.ts +2 -0
- package/declarations/layout.d.ts.map +1 -0
- package/declarations/test-support.d.ts.map +1 -1
- package/declarations/utils/breakpoint.d.ts +16 -0
- package/declarations/utils/breakpoint.d.ts.map +1 -0
- package/declarations/utils/document-listener.d.ts +6 -0
- package/declarations/utils/document-listener.d.ts.map +1 -0
- package/declarations/utils/listManager.d.ts +7 -1
- package/declarations/utils/listManager.d.ts.map +1 -1
- package/declarations/utils/route-active.d.ts +34 -0
- package/declarations/utils/route-active.d.ts.map +1 -0
- package/declarations/utils/selection-indicator.d.ts +7 -4
- package/declarations/utils/selection-indicator.d.ts.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/calendar/year-grid.js +1 -30
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/collections/dropdown/dropdown.js +172 -48
- package/dist/components/collections/dropdown/dropdown.js.map +1 -1
- package/dist/components/collections/listbox/item.js +36 -2
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +1 -1
- package/dist/components/collections/table/sort-button.js +1 -1
- package/dist/components/disclosure/accordion/item.js +1 -1
- package/dist/components/forms/autocomplete.js +1 -1
- package/dist/components/forms/date-input/segment-group.js +1 -1
- package/dist/components/forms/date-input/segment-group.js.map +1 -1
- package/dist/components/forms/date-input/segments.js +1 -1
- package/dist/components/forms/date-input/segments.js.map +1 -1
- package/dist/components/forms/date-input.js +1 -1
- package/dist/components/forms/date-picker/date-picker.js +57 -6
- package/dist/components/forms/date-picker/date-picker.js.map +1 -1
- package/dist/components/forms/date-picker/end-content.js +1 -1
- package/dist/components/forms/date-picker/time-columns.js +238 -0
- package/dist/components/forms/date-picker/time-columns.js.map +1 -0
- package/dist/components/forms/index.js +1 -1
- package/dist/components/forms/native-select.js +1 -1
- package/dist/components/forms/select/end-content.js +1 -1
- package/dist/components/forms/select/native-mirror.js.map +1 -1
- package/dist/components/forms/select/select.js +24 -5
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/components/layout/app-layout-state.js +64 -0
- package/dist/components/layout/app-layout-state.js.map +1 -0
- package/dist/components/layout/app-layout.js +416 -0
- package/dist/components/layout/app-layout.js.map +1 -0
- package/dist/components/layout/aside-toggle.js +55 -0
- package/dist/components/layout/aside-toggle.js.map +1 -0
- package/dist/components/layout/aside.js +100 -0
- package/dist/components/layout/aside.js.map +1 -0
- package/dist/components/layout/bottom-nav-more.js +150 -0
- package/dist/components/layout/bottom-nav-more.js.map +1 -0
- package/dist/components/layout/bottom-nav.js +65 -0
- package/dist/components/layout/bottom-nav.js.map +1 -0
- package/dist/components/layout/context.js +89 -0
- package/dist/components/layout/context.js.map +1 -0
- package/dist/components/layout/index.js +14 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/layout/main.js +34 -0
- package/dist/components/layout/main.js.map +1 -0
- package/dist/components/layout/menu-toggle.js +61 -0
- package/dist/components/layout/menu-toggle.js.map +1 -0
- package/dist/components/layout/nav-context.js +85 -0
- package/dist/components/layout/nav-context.js.map +1 -0
- package/dist/components/layout/nav-folder.js +271 -0
- package/dist/components/layout/nav-folder.js.map +1 -0
- package/dist/components/layout/nav-item.js +192 -0
- package/dist/components/layout/nav-item.js.map +1 -0
- package/dist/components/layout/nav-link.js +58 -0
- package/dist/components/layout/nav-link.js.map +1 -0
- package/dist/components/layout/navbar.js +30 -0
- package/dist/components/layout/navbar.js.map +1 -0
- package/dist/components/layout/page-header.js +45 -0
- package/dist/components/layout/page-header.js.map +1 -0
- package/dist/components/layout/sidebar-group.js +41 -0
- package/dist/components/layout/sidebar-group.js.map +1 -0
- package/dist/components/layout/sidebar-toggle.js +82 -0
- package/dist/components/layout/sidebar-toggle.js.map +1 -0
- package/dist/components/layout/sidebar.js +249 -0
- package/dist/components/layout/sidebar.js.map +1 -0
- package/dist/components/navigation/breadcrumbs/separator.js +1 -1
- package/dist/components/navigation/index.js +4 -0
- package/dist/components/navigation/index.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +1 -1
- package/dist/components/navigation/stepper/collapse-menu.js +128 -0
- package/dist/components/navigation/stepper/collapse-menu.js.map +1 -0
- package/dist/components/navigation/stepper/list.js +17 -0
- package/dist/components/navigation/stepper/list.js.map +1 -0
- package/dist/components/navigation/stepper/panel.js +26 -0
- package/dist/components/navigation/stepper/panel.js.map +1 -0
- package/dist/components/navigation/stepper/step.js +130 -0
- package/dist/components/navigation/stepper/step.js.map +1 -0
- package/dist/components/navigation/stepper/stepper.js +475 -0
- package/dist/components/navigation/stepper/stepper.js.map +1 -0
- package/dist/components/navigation/stepper.js +5 -0
- package/dist/components/navigation/stepper.js.map +1 -0
- package/dist/components/navigation/tab-nav/item.js +6 -40
- package/dist/components/navigation/tab-nav/item.js.map +1 -1
- package/dist/components/notifications/index.js +1 -1
- package/dist/components/notifications/notification-card.js +2 -2
- package/dist/components/notifications/notifications-container.js +1 -1
- package/dist/components/overlays/overlay.js +55 -7
- package/dist/components/overlays/overlay.js.map +1 -1
- package/dist/components/overlays/portal.js +11 -2
- package/dist/components/overlays/portal.js.map +1 -1
- package/dist/components/status/alert.js +1 -1
- package/dist/components/utilities/collapsible.js +33 -5
- package/dist/components/utilities/collapsible.js.map +1 -1
- package/dist/forms.js +1 -1
- package/dist/{icons-DZ61nCzv.js → icons-55dthVFk.js} +14 -2
- package/dist/{icons-DZ61nCzv.js.map → icons-55dthVFk.js.map} +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/layout.js +14 -0
- package/dist/layout.js.map +1 -0
- package/dist/navigation.js +4 -0
- package/dist/navigation.js.map +1 -1
- package/dist/{notification-card-dz-eE6z9.js → notification-card-BPfDo-Gf.js} +2 -2
- package/dist/{notification-card-dz-eE6z9.js.map → notification-card-BPfDo-Gf.js.map} +1 -1
- package/dist/notifications.js +1 -1
- package/dist/reveal-within-BcqpOmSI.js +33 -0
- package/dist/reveal-within-BcqpOmSI.js.map +1 -0
- package/dist/test-support.js +3 -1
- package/dist/test-support.js.map +1 -1
- package/dist/utils/breakpoint.js +56 -0
- package/dist/utils/breakpoint.js.map +1 -0
- package/dist/utils/document-listener.js +10 -0
- package/dist/utils/document-listener.js.map +1 -0
- package/dist/utils/listManager.js +12 -2
- package/dist/utils/listManager.js.map +1 -1
- package/dist/utils/route-active.js +70 -0
- package/dist/utils/route-active.js.map +1 -0
- package/dist/utils/selection-indicator.js +25 -5
- package/dist/utils/selection-indicator.js.map +1 -1
- package/package.json +7 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sources":["../../../../src/components/navigation/tab-nav/item.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { service } from '@ember/service';\nimport { LinkTo } from '@ember/routing';\nimport type RouterService from '@ember/routing/router-service';\nimport type { ModifierLike } from '@glint/template';\n\ninterface TabNavItemArgs {\n /**\n * Renders a `LinkTo` for this route and derives the active state from the\n * router. Omit it (and pass `@href`) to stay entirely router-free.\n */\n route?: string;\n\n /** Dynamic segments for `@route`. */\n models?: unknown[];\n\n /** A single dynamic segment for `@route`. */\n model?: unknown;\n\n /** Query params for `@route`. */\n query?: Record<string, unknown>;\n\n /** Renders a plain anchor. Ignored when `@route` is given. */\n href?: string;\n\n /**\n * Overrides the active state. Always wins over anything derived from the\n * router, and is the only source of truth when `@route` is not used.\n */\n isActive?: boolean;\n\n /**\n * Marks the link as disabled. An anchor cannot be natively disabled, so the\n * href is dropped as well -- `aria-disabled` alone still leaves it\n * clickable.\n *\n * @defaultValue false\n */\n isDisabled?: boolean;\n\n /** Class names appended to this item's theme classes. */\n class?: string;\n\n /**\n * Supplied by TabNav. Not part of the public API.\n *\n * @internal\n */\n itemClass: string;\n\n /**\n * Supplied by TabNav. Not part of the public API.\n *\n * @internal\n */\n setupItem: ModifierLike<{\n Element: HTMLElement;\n Args: { Positional: [boolean] };\n }>;\n}\n\ninterface TabNavItemSignature {\n Args: TabNavItemArgs;\n Blocks: { default: [] };\n Element: HTMLAnchorElement;\n}\n\nclass TabNavItem extends Component<TabNavItemSignature> {\n // Ember's service injection is getter-based, so this resolves only when\n // `isActive` below actually reads it -- which happens only when `@route` was\n // passed and `@isActive` was not. An application that does not route never\n // touches the router.\n @service declare router: RouterService;\n\n @cached\n get
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../../src/components/navigation/tab-nav/item.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { service } from '@ember/service';\nimport { LinkTo } from '@ember/routing';\nimport type RouterService from '@ember/routing/router-service';\nimport type { ModifierLike } from '@glint/template';\nimport { isLinkActive, normalizeRouteArgs } from '../../../utils/route-active';\n\ninterface TabNavItemArgs {\n /**\n * Renders a `LinkTo` for this route and derives the active state from the\n * router. Omit it (and pass `@href`) to stay entirely router-free.\n */\n route?: string;\n\n /** Dynamic segments for `@route`. */\n models?: unknown[];\n\n /** A single dynamic segment for `@route`. */\n model?: unknown;\n\n /** Query params for `@route`. */\n query?: Record<string, unknown>;\n\n /** Renders a plain anchor. Ignored when `@route` is given. */\n href?: string;\n\n /**\n * Overrides the active state. Always wins over anything derived from the\n * router, and is the only source of truth when `@route` is not used.\n */\n isActive?: boolean;\n\n /**\n * Marks the link as disabled. An anchor cannot be natively disabled, so the\n * href is dropped as well -- `aria-disabled` alone still leaves it\n * clickable.\n *\n * @defaultValue false\n */\n isDisabled?: boolean;\n\n /** Class names appended to this item's theme classes. */\n class?: string;\n\n /**\n * Supplied by TabNav. Not part of the public API.\n *\n * @internal\n */\n itemClass: string;\n\n /**\n * Supplied by TabNav. Not part of the public API.\n *\n * @internal\n */\n setupItem: ModifierLike<{\n Element: HTMLElement;\n Args: { Positional: [boolean] };\n }>;\n}\n\ninterface TabNavItemSignature {\n Args: TabNavItemArgs;\n Blocks: { default: [] };\n Element: HTMLAnchorElement;\n}\n\nclass TabNavItem extends Component<TabNavItemSignature> {\n // Ember's service injection is getter-based, so this resolves only when\n // `isActive` below actually reads it -- which happens only when `@route` was\n // passed and `@isActive` was not. An application that does not route never\n // touches the router.\n @service declare router: RouterService;\n\n @cached\n get routeArgs(): ReturnType<typeof normalizeRouteArgs> {\n return normalizeRouteArgs(this.args);\n }\n\n get isActive(): boolean {\n return isLinkActive(this.args, () => this.router);\n }\n\n get isDisabled(): boolean {\n return this.args.isDisabled ?? false;\n }\n\n /**\n * A `LinkTo` is only rendered for a route the item can actually navigate to.\n * `LinkTo` cannot be talked out of a real, navigable href -- its `@disabled`\n * only short-circuits the click handler and tags on an un-themed `disabled`\n * class -- so a disabled route item falls through to the plain anchor\n * instead, where dropping the href is what actually disables it.\n *\n * That anchor keeps `aria-disabled` even with no href at all, per this\n * component's documented contract. `no-unsupported-role-attributes` is\n * disabled over it for exactly that pairing: the rule cannot see that the\n * href is conditional.\n */\n get rendersLink(): boolean {\n return Boolean(this.args.route) && !this.isDisabled;\n }\n\n <template>\n {{#if this.rendersLink}}\n <LinkTo\n @route={{@route}}\n @models={{this.routeArgs.models}}\n @query={{this.routeArgs.query}}\n data-part=\"tab\"\n class=\"{{@itemClass}} {{@class}}\"\n aria-disabled=\"false\"\n data-disabled=\"false\"\n {{@setupItem this.isActive}}\n ...attributes\n >\n {{yield}}\n </LinkTo>\n {{else}}\n {{! template-lint-disable no-unsupported-role-attributes }}\n <a\n data-part=\"tab\"\n href={{unless this.isDisabled @href}}\n class=\"{{@itemClass}} {{@class}}\"\n aria-disabled=\"{{this.isDisabled}}\"\n data-disabled=\"{{this.isDisabled}}\"\n {{@setupItem this.isActive}}\n ...attributes\n >\n {{yield}}\n </a>\n {{/if}}\n </template>\n}\n\nexport { TabNavItem, type TabNavItemSignature, type TabNavItemArgs };\nexport default TabNavItem;\n"],"names":["TabNavItem","Component","g","prototype","service","i","routeArgs","normalizeRouteArgs","args","n","cached","isActive","isLinkActive","router","isDisabled","rendersLink","Boolean","route","setComponentTemplate","precompileTemplate","strictMode","scope","LinkTo"],"mappings":";;;;;;;;;AAqEA,MAAMA,mBAAmBC,SAAA,CAAU;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CAKhCC,OAAA,CAAA,CAAA;AAAA;EAAA,OAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAA,MAAA,EAAA;AAHD;AACA;AACA;EAGA,IACIC,SAAAA,GAAmD;AACrD,IAAA,OAAOC,kBAAA,CAAmB,IAAI,CAACC,IAAI,CAAA;AACrC,EAAA;AAAA,EAAA;IAAAC,gBAAA,CAAA,IAAA,CAAAN,SAAA,EAAA,WAAA,EAAA,CAHCO,MAAA,CAAA,CAAA;AAAA;EAKD,IAAIC,QAAAA,GAAoB;IACtB,OAAOC,YAAA,CAAa,IAAI,CAACJ,IAAI,EAAE,MAAM,IAAI,CAACK,MAAM,CAAA;AAClD,EAAA;EAEA,IAAIC,UAAAA,GAAsB;AACxB,IAAA,OAAO,IAAI,CAACN,IAAI,CAACM,UAAU,IAAI,KAAA;AACjC,EAAA;AAEA;;;;;;;;;;;;EAYA,IAAIC,WAAAA,GAAuB;AACzB,IAAA,OAAOC,OAAA,CAAQ,IAAI,CAACR,IAAI,CAACS,KAAK,CAAA,IAAK,CAAC,IAAI,CAACH,UAAU;AACrD,EAAA;AAEA,EAAA;IAAAI,oBAAA,CAAAC,kBAAA,CAAA,8mBAAA,EA6BA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { N as Notification, T as Timer } from '../../manager-Dge4r8Vn.js';
|
|
2
2
|
import '@ember/service';
|
|
3
|
-
export { N as NotificationCard, a as NotificationStack } from '../../notification-card-
|
|
3
|
+
export { N as NotificationCard, a as NotificationStack } from '../../notification-card-BPfDo-Gf.js';
|
|
4
4
|
export { NotificationsContainer } from './notifications-container.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -7,9 +7,9 @@ import '@ember/helper';
|
|
|
7
7
|
import '../buttons/close-button.js';
|
|
8
8
|
import '../buttons/button.js';
|
|
9
9
|
import '../utilities/spinner.js';
|
|
10
|
-
import '../../icons-
|
|
10
|
+
import '../../icons-55dthVFk.js';
|
|
11
11
|
import '@frontile/theme';
|
|
12
|
-
export { N as NotificationCard, N as default } from '../../notification-card-
|
|
12
|
+
export { N as NotificationCard, N as default } from '../../notification-card-BPfDo-Gf.js';
|
|
13
13
|
import '@ember/template-compilation';
|
|
14
14
|
import '@ember/component';
|
|
15
15
|
import '../../runtime--fcdnjmJ-BOdRhmsS.js';
|
|
@@ -7,7 +7,7 @@ import { on } from '@ember/modifier';
|
|
|
7
7
|
import { modifier } from 'ember-modifier';
|
|
8
8
|
import { htmlSafe } from '@ember/template';
|
|
9
9
|
import { registerDestructor } from '@ember/destroyable';
|
|
10
|
-
import { a as NotificationStack, N as NotificationCard } from '../../notification-card-
|
|
10
|
+
import { a as NotificationStack, N as NotificationCard } from '../../notification-card-BPfDo-Gf.js';
|
|
11
11
|
import { useStyles } from '@frontile/theme';
|
|
12
12
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
13
13
|
import { setComponentTemplate } from '@ember/component';
|
|
@@ -10,14 +10,15 @@ import { createFocusTrap } from 'focus-trap';
|
|
|
10
10
|
import onClickOutside from 'ember-click-outside/modifiers/on-click-outside';
|
|
11
11
|
import { Backdrop } from './backdrop.js';
|
|
12
12
|
import { hasPainted, afterFirstPaint, shouldDeferMount, shouldSkipEnterTransition, withoutEnterTransition } from './mount-animation.js';
|
|
13
|
-
import {
|
|
13
|
+
import { findParentPortal, Portal } from './portal.js';
|
|
14
14
|
import { macroCondition, isTesting } from '@embroider/macros';
|
|
15
15
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
16
16
|
import { setComponentTemplate } from '@ember/component';
|
|
17
17
|
import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2 } from '../../runtime--fcdnjmJ-BOdRhmsS.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Wraps `createFocusTrap` so activate/deactivate/pause/unpause
|
|
20
|
+
* Wraps `createFocusTrap` so activate/deactivate/pause/unpause (and
|
|
21
|
+
* updateContainerElements, which re-validates the same way) never throw.
|
|
21
22
|
*
|
|
22
23
|
* focus-trap keeps a page-global stack of traps; deactivating one can reach
|
|
23
24
|
* into the stack to re-validate (`unpause`) whichever trap is now on top. If
|
|
@@ -43,7 +44,8 @@ function createTestResilientFocusTrap(...args) {
|
|
|
43
44
|
activate: guard('activate'),
|
|
44
45
|
deactivate: guard('deactivate'),
|
|
45
46
|
pause: guard('pause'),
|
|
46
|
-
unpause: guard('unpause')
|
|
47
|
+
unpause: guard('unpause'),
|
|
48
|
+
updateContainerElements: guard('updateContainerElements')
|
|
47
49
|
};
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
@@ -71,6 +73,18 @@ function isWithinNestedPortal(contentElement, target) {
|
|
|
71
73
|
}
|
|
72
74
|
return ownPortal.contains(targetPortal);
|
|
73
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The portals nested directly in the one `contentElement` renders into: where
|
|
78
|
+
* a Select's list, a Popover or a Dropdown opened from inside this overlay
|
|
79
|
+
* renders. Portals nested deeper sit inside these.
|
|
80
|
+
*/
|
|
81
|
+
function nestedPortalsOf(contentElement) {
|
|
82
|
+
const ownPortal = findParentPortal(contentElement);
|
|
83
|
+
if (!ownPortal) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
return Array.from(ownPortal.children).filter(child => child instanceof HTMLElement && child.getAttribute('data-portal') === 'true');
|
|
87
|
+
}
|
|
74
88
|
// Blocking the body scroll mutates global state, so it has to be reference
|
|
75
89
|
// counted: nested overlays (a Drawer opened from a Modal, a Select inside a
|
|
76
90
|
// Modal) each lock on open and unlock on close, and only the last one out is
|
|
@@ -148,6 +162,8 @@ class Overlay extends Component {
|
|
|
148
162
|
// teardown, because the args can change while the overlay is open and an
|
|
149
163
|
// asymmetric lock/unlock would leak the reference count.
|
|
150
164
|
didLockBodyScroll = false;
|
|
165
|
+
// Keeps the focus trap's containers in step with the nested portals.
|
|
166
|
+
nestedPortalObserver;
|
|
151
167
|
cancelPaintWait;
|
|
152
168
|
constructor(owner, args) {
|
|
153
169
|
super(owner, args);
|
|
@@ -216,6 +232,8 @@ class Overlay extends Component {
|
|
|
216
232
|
}
|
|
217
233
|
return () => {
|
|
218
234
|
this.contentElement = undefined;
|
|
235
|
+
this.nestedPortalObserver?.disconnect();
|
|
236
|
+
this.nestedPortalObserver = undefined;
|
|
219
237
|
if (this.args.isOpen !== true) {
|
|
220
238
|
this.hasClosedOnce = true;
|
|
221
239
|
}
|
|
@@ -292,12 +310,42 @@ class Overlay extends Component {
|
|
|
292
310
|
...this.args.focusTrapOptions
|
|
293
311
|
};
|
|
294
312
|
}
|
|
295
|
-
|
|
313
|
+
/**
|
|
314
|
+
* The trap covers the content and the portals nested in this overlay's
|
|
315
|
+
* portal, the same ones `handleOutsideClick` doesn't count as outside.
|
|
316
|
+
*
|
|
317
|
+
* With the content alone as its container, the trap took a press in a
|
|
318
|
+
* nested portal for an outside click and deactivated: from then on Tab
|
|
319
|
+
* walked out of the Drawer. A touch on a Select's list also sent the focus
|
|
320
|
+
* back to where it was when the trap activated, out of the Select's
|
|
321
|
+
* filter. As containers, nested overlays are also part of the Tab cycle,
|
|
322
|
+
* after the content.
|
|
323
|
+
*
|
|
324
|
+
* Nested overlays open and close while this one stays open, so a
|
|
325
|
+
* MutationObserver on the portal keeps the containers current.
|
|
326
|
+
*/
|
|
327
|
+
createFocusTrap = (...[element, options]) => {
|
|
328
|
+
let create = createFocusTrap;
|
|
296
329
|
if (macroCondition(isTesting())) {
|
|
297
|
-
|
|
330
|
+
create = createTestResilientFocusTrap;
|
|
298
331
|
}
|
|
299
|
-
|
|
300
|
-
|
|
332
|
+
// The element the `focusTrap` modifier is on: the content. We pass it no
|
|
333
|
+
// `additionalElements`, so it's never a list.
|
|
334
|
+
const content = element;
|
|
335
|
+
const containers = () => [content, ...nestedPortalsOf(content)];
|
|
336
|
+
const trap = create(containers(), options);
|
|
337
|
+
const ownPortal = findParentPortal(content);
|
|
338
|
+
if (ownPortal) {
|
|
339
|
+
this.nestedPortalObserver?.disconnect();
|
|
340
|
+
this.nestedPortalObserver = new MutationObserver(() => {
|
|
341
|
+
trap.updateContainerElements(containers());
|
|
342
|
+
});
|
|
343
|
+
this.nestedPortalObserver.observe(ownPortal, {
|
|
344
|
+
childList: true
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
return trap;
|
|
348
|
+
};
|
|
301
349
|
get classes() {
|
|
302
350
|
const {
|
|
303
351
|
overlay
|
|
@@ -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 { 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,CAAM,SAAA;GACjB;AACF;AAEA;;;;;;;;;;;;;;AAcA,SAASO,qBACPC,cAA2B,EAC3BC,MAA0B,EAClB;AACR,EAAA,MAAMC,YAAYC,gBAAA,CAAiBH,cAAA,CAAA;EACnC,IAAI,CAACE,SAAA,IAAa,EAAED,MAAA,YAAkBG,OAAO,CAAA,EAAG;AAC9C,IAAA,OAAO,KAAA;AACT,EAAA;AAEA,EAAA,MAAMC,YAAA,GAAeJ,MAAA,CAAOK,OAAO,CAAC,sBAAA,CAAA;AACpC,EAAA,IAAI,CAACD,YAAA,IAAgBA,Y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AU,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
|
+
{"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 GuardedFocusTrapMethod =\n 'activate' | 'deactivate' | 'pause' | 'unpause' | 'updateContainerElements';\n\n/**\n * Wraps `createFocusTrap` so activate/deactivate/pause/unpause (and\n * updateContainerElements, which re-validates the same way) 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: GuardedFocusTrapMethod) =>\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 updateContainerElements: guard('updateContainerElements')\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/**\n * The portals nested directly in the one `contentElement` renders into: where\n * a Select's list, a Popover or a Dropdown opened from inside this overlay\n * renders. Portals nested deeper sit inside these.\n */\nfunction nestedPortalsOf(contentElement: HTMLElement): HTMLElement[] {\n const ownPortal = findParentPortal(contentElement);\n if (!ownPortal) {\n return [];\n }\n\n return Array.from(ownPortal.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement &&\n child.getAttribute('data-portal') === 'true'\n );\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 // Keeps the focus trap's containers in step with the nested portals.\n nestedPortalObserver: MutationObserver | undefined;\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 this.nestedPortalObserver?.disconnect();\n this.nestedPortalObserver = 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 /**\n * The trap covers the content and the portals nested in this overlay's\n * portal, the same ones `handleOutsideClick` doesn't count as outside.\n *\n * With the content alone as its container, the trap took a press in a\n * nested portal for an outside click and deactivated: from then on Tab\n * walked out of the Drawer. A touch on a Select's list also sent the focus\n * back to where it was when the trap activated, out of the Select's\n * filter. As containers, nested overlays are also part of the Tab cycle,\n * after the content.\n *\n * Nested overlays open and close while this one stays open, so a\n * MutationObserver on the portal keeps the containers current.\n */\n createFocusTrap = (\n ...[element, options]: Parameters<typeof createFocusTrap>\n ): FocusTrap => {\n let create = createFocusTrap;\n if (macroCondition(isTesting())) {\n create = createTestResilientFocusTrap;\n }\n\n // The element the `focusTrap` modifier is on: the content. We pass it no\n // `additionalElements`, so it's never a list.\n const content = element as HTMLElement;\n const containers = () => [content, ...nestedPortalsOf(content)];\n const trap = create(containers(), options);\n\n const ownPortal = findParentPortal(content);\n if (ownPortal) {\n this.nestedPortalObserver?.disconnect();\n this.nestedPortalObserver = new MutationObserver(() => {\n trap.updateContainerElements(containers());\n });\n this.nestedPortalObserver.observe(ownPortal, { childList: true });\n }\n\n return trap;\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","updateContainerElements","isWithinNestedPortal","contentElement","target","ownPortal","findParentPortal","Element","targetPortal","closest","contains","nestedPortalsOf","Array","from","children","filter","child","HTMLElement","getAttribute","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","nestedPortalObserver","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","disconnect","hasClosedOnce","didClose","preventFocusRestore","tabIndex","mountAnimationState","isFirstOpen","animationsEnabled","animateOnMount","canWaitForFrame","requestAnimationFrame","n","cached","skipEnterTransition","shouldSkipEnterTransition","isVisible","backdrop","macroCondition","isTesting","disableTransitions","focusTrapOptions","clickOutsideDeactivates","allowOutsideClick","element","options","create","content","containers","MutationObserver","observe","childList","classes","overlay","useStyles","class","inPlace","enableFlexContent","disableFlexContent","customContentModifier","maybeWithoutEnter","withoutEnterTransition","backdropTransition","isEnabled","transition","name","setComponentTemplate","precompileTemplate","strictMode","scope","Portal","Backdrop","on","cssTransition","onClickOutside","focusTrap"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA;;;;;;;;;;;;;AAaC;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,CA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A;AAEA;AACA;EACAoD,iBAAAA,CAAoCf,OAAU,EAAK;IACjD,OAAO,IAAI,CAACX,mBAAmB,GAAG2B,uBAAuBhB,OAAA,CAAA,GAAWA,OAAA;AACtE,EAAA;EAEA,IAAIiB,kBAAAA,GAAqB;IACvB,OAAO,IAAI,CAACF,iBAAiB,CAC3B,IAAI,CAACpI,IAAI,CAACsI,kBAAkB,IAAI;MAAEC,SAAA,EAAW,IAAI,CAACrD;AAAmB,KAAA,CAAA;AAEzE,EAAA;EAEA,IAAIsD,UAAAA,GAAa;AACf,IAAA,IAAInB,OAAmC,GAAgB;AACrDoB,MAAAA,IAAA,EAAM,0BAAA;MACNF,SAAA,EAAW,IAAI,CAACrD;KAClB;IAEA,IAAI,OAAO,IAAI,CAAClF,IAAI,CAACwI,UAAU,KAAK,QAAA,EAAU;AAC5CnB,MAAAA,OAAA,GAAU;AAAE,QAAA,GAAGA,OAAO;QAAE,GAAG,IAAI,CAACrH,IAAI,CAACwI;OAAW;AAClD,IAAA;AAEA,IAAA,OAAO,IAAI,CAACJ,iBAAiB,CAACf,OAAA,CAAA;AAChC,EAAA;AAEA,EAAA;IAAAqB,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;;"}
|
|
@@ -23,6 +23,15 @@ function findParentPortal(origin) {
|
|
|
23
23
|
}
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* A portal target that no `Portal` made for itself. A portal with nowhere
|
|
28
|
+
* better to go makes its own (see `needsTarget`), marked with
|
|
29
|
+
* `data-portal-owner`, and another portal must not adopt that one: it is
|
|
30
|
+
* removed together with the portal that made it, and would take anything
|
|
31
|
+
* else rendered into it along. A tooltip that closed as the menu on the
|
|
32
|
+
* same trigger opened did exactly that, emptying the menu.
|
|
33
|
+
*/
|
|
34
|
+
const UNOWNED_TARGET = '[data-portal-target="true"]:not([data-portal-owner])';
|
|
26
35
|
function findClosestPortalTarget(element, name) {
|
|
27
36
|
if (!element) {
|
|
28
37
|
return null;
|
|
@@ -35,7 +44,7 @@ function findClosestPortalTarget(element, name) {
|
|
|
35
44
|
return target;
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
|
-
const target =
|
|
47
|
+
const target = parent.querySelector(UNOWNED_TARGET);
|
|
39
48
|
if (target && target.getAttribute('data-portal-for') === null) {
|
|
40
49
|
return target;
|
|
41
50
|
}
|
|
@@ -97,7 +106,7 @@ class Portal extends Component {
|
|
|
97
106
|
return !!destEl && destEl.getAttribute('data-portal-target') !== 'true' && destEl.getAttribute('data-portal') !== 'true';
|
|
98
107
|
};
|
|
99
108
|
static {
|
|
100
|
-
setComponentTemplate(precompileTemplate("<script type=\"x/portal-marker\" id={{this.id}}></script>\n\n{{#let this.destinationElement as |destinationElement|}}\n <MaybeInElement @renderInPlace={{@renderInPlace}} @destinationElement={{destinationElement}}>\n {{#if (this.needsTarget destinationElement)}}\n <PortalTarget>\n <div data-portal=\"true\" ...attributes>\n {{yield}}\n </div>\n </PortalTarget>\n {{else}}\n <div data-portal=\"true\" ...attributes>\n {{yield}}\n </div>\n {{/if}}\n </MaybeInElement>\n{{/let}}", {
|
|
109
|
+
setComponentTemplate(precompileTemplate("<script type=\"x/portal-marker\" id={{this.id}}></script>\n\n{{#let this.destinationElement as |destinationElement|}}\n <MaybeInElement @renderInPlace={{@renderInPlace}} @destinationElement={{destinationElement}}>\n {{#if (this.needsTarget destinationElement)}}\n <PortalTarget data-portal-owner={{this.id}}>\n <div data-portal=\"true\" ...attributes>\n {{yield}}\n </div>\n </PortalTarget>\n {{else}}\n <div data-portal=\"true\" ...attributes>\n {{yield}}\n </div>\n {{/if}}\n </MaybeInElement>\n{{/let}}", {
|
|
101
110
|
strictMode: true,
|
|
102
111
|
scope: () => ({
|
|
103
112
|
MaybeInElement,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.js","sources":["../../../src/components/overlays/portal.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport {\n getDOM,\n getElementById,\n getElementByAttribute\n} from '../../-private/dom';\nimport type { TOC } from '@ember/component/template-only';\nimport { guidFor } from '@ember/object/internals';\nimport { isTesting, macroCondition } from '@embroider/macros';\nimport { PortalTarget } from './portal-target';\n\nconst MaybeInElement: TOC<{\n Args: {\n destinationElement?: Element | null;\n renderInPlace?: boolean;\n };\n Blocks: {\n default: [];\n };\n}> = <template>\n {{#if @renderInPlace}}\n {{yield}}\n {{else if @destinationElement}}\n {{#in-element @destinationElement insertBefore=null}}\n {{yield}}\n {{/in-element}}\n {{/if}}\n</template>;\n\ninterface PortalSignature {\n Args: {\n /**\n * Whether to render in place or in the specified/default destination\n *\n * @defaultValue false\n */\n renderInPlace?: boolean;\n\n /**\n * The target where to render the portal.\n * There are 3 options: 1) `Element` object, 2) element id, 3) portal target name.\n *\n * For element id, string must be prefixed with `#`.\n * If no value is passed in, we will render to the closest unnamed portal target,\n * parent portal or `document.body`.\n */\n target?: string | Element;\n\n /**\n * @defaultValue true\n */\n appendToParentPortal?: boolean;\n };\n Element: HTMLDivElement;\n Blocks: { default: [] };\n}\n\nfunction findParentPortal(origin: Element | null): Element | null {\n if (!origin) {\n return null;\n }\n\n let parent = origin.parentElement;\n while (parent) {\n if (parent.getAttribute('data-portal') === 'true') {\n return parent;\n }\n\n parent = parent.parentElement;\n }\n\n return null;\n}\n\nfunction findClosestPortalTarget(\n element: Element | null,\n name?: string\n): Element | null {\n if (!element) {\n return null;\n }\n\n let parent = element.parentElement;\n while (parent) {\n if (name) {\n const target = getElementByAttribute(parent, 'data-portal-for', name);\n if (target) {\n return target;\n }\n }\n const target =
|
|
1
|
+
{"version":3,"file":"portal.js","sources":["../../../src/components/overlays/portal.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport {\n getDOM,\n getElementById,\n getElementByAttribute\n} from '../../-private/dom';\nimport type { TOC } from '@ember/component/template-only';\nimport { guidFor } from '@ember/object/internals';\nimport { isTesting, macroCondition } from '@embroider/macros';\nimport { PortalTarget } from './portal-target';\n\nconst MaybeInElement: TOC<{\n Args: {\n destinationElement?: Element | null;\n renderInPlace?: boolean;\n };\n Blocks: {\n default: [];\n };\n}> = <template>\n {{#if @renderInPlace}}\n {{yield}}\n {{else if @destinationElement}}\n {{#in-element @destinationElement insertBefore=null}}\n {{yield}}\n {{/in-element}}\n {{/if}}\n</template>;\n\ninterface PortalSignature {\n Args: {\n /**\n * Whether to render in place or in the specified/default destination\n *\n * @defaultValue false\n */\n renderInPlace?: boolean;\n\n /**\n * The target where to render the portal.\n * There are 3 options: 1) `Element` object, 2) element id, 3) portal target name.\n *\n * For element id, string must be prefixed with `#`.\n * If no value is passed in, we will render to the closest unnamed portal target,\n * parent portal or `document.body`.\n */\n target?: string | Element;\n\n /**\n * @defaultValue true\n */\n appendToParentPortal?: boolean;\n };\n Element: HTMLDivElement;\n Blocks: { default: [] };\n}\n\nfunction findParentPortal(origin: Element | null): Element | null {\n if (!origin) {\n return null;\n }\n\n let parent = origin.parentElement;\n while (parent) {\n if (parent.getAttribute('data-portal') === 'true') {\n return parent;\n }\n\n parent = parent.parentElement;\n }\n\n return null;\n}\n\n/**\n * A portal target that no `Portal` made for itself. A portal with nowhere\n * better to go makes its own (see `needsTarget`), marked with\n * `data-portal-owner`, and another portal must not adopt that one: it is\n * removed together with the portal that made it, and would take anything\n * else rendered into it along. A tooltip that closed as the menu on the\n * same trigger opened did exactly that, emptying the menu.\n */\nconst UNOWNED_TARGET = '[data-portal-target=\"true\"]:not([data-portal-owner])';\n\nfunction findClosestPortalTarget(\n element: Element | null,\n name?: string\n): Element | null {\n if (!element) {\n return null;\n }\n\n let parent = element.parentElement;\n while (parent) {\n if (name) {\n const target = getElementByAttribute(parent, 'data-portal-for', name);\n if (target) {\n return target;\n }\n }\n const target = parent.querySelector(UNOWNED_TARGET);\n if (target && target.getAttribute('data-portal-for') === null) {\n return target;\n }\n parent = parent.parentElement;\n }\n\n return null;\n}\n\nclass Portal extends Component<PortalSignature> {\n id = guidFor(this);\n dom = getDOM(this);\n\n get destinationElement(): Element | null {\n const doc = this.dom;\n if (!doc) {\n return null;\n }\n\n if (this.args.target) {\n if (typeof this.args.target === 'string') {\n if (this.args.target[0] === '#') {\n return getElementById(doc, this.args.target.replace('#', ''));\n }\n\n const namedTarget = findClosestPortalTarget(\n this.portalMarker,\n this.args.target\n );\n if (namedTarget) {\n return namedTarget;\n }\n } else if (typeof this.args.target === 'object') {\n return this.args.target;\n }\n }\n\n let containerEl: Element = doc.body;\n\n if (macroCondition(isTesting())) {\n const testingContainer = getElementById(doc, 'ember-testing');\n if (testingContainer) {\n containerEl = testingContainer;\n }\n }\n\n if (this.args.appendToParentPortal !== false) {\n const parentPortal = findParentPortal(this.portalMarker);\n if (parentPortal) {\n return parentPortal;\n }\n }\n\n const portalTarget = findClosestPortalTarget(this.portalMarker);\n if (portalTarget) {\n return portalTarget;\n }\n\n return containerEl;\n }\n\n get portalMarker(): Element | null {\n const doc = this.dom;\n if (!doc) {\n return null;\n }\n\n return getElementById(doc, this.id);\n }\n\n needsTarget = (destEl: Element | null): boolean => {\n if (this.args.renderInPlace || this.args.target) {\n return false;\n }\n\n return (\n !!destEl &&\n destEl.getAttribute('data-portal-target') !== 'true' &&\n destEl.getAttribute('data-portal') !== 'true'\n );\n };\n\n <template>\n <script type=\"x/portal-marker\" id={{this.id}}></script>\n\n {{#let this.destinationElement as |destinationElement|}}\n <MaybeInElement\n @renderInPlace={{@renderInPlace}}\n @destinationElement={{destinationElement}}\n >\n {{#if (this.needsTarget destinationElement)}}\n <PortalTarget data-portal-owner={{this.id}}>\n <div data-portal=\"true\" ...attributes>\n {{yield}}\n </div>\n </PortalTarget>\n {{else}}\n <div data-portal=\"true\" ...attributes>\n {{yield}}\n </div>\n {{/if}}\n </MaybeInElement>\n {{/let}}\n </template>\n}\n\nexport { Portal, type PortalSignature, findParentPortal };\nexport default Portal;\n"],"names":["MaybeInElement","setComponentTemplate","precompileTemplate","strictMode","templateOnly","findParentPortal","origin","parent","parentElement","getAttribute","UNOWNED_TARGET","findClosestPortalTarget","element","name","target","getElementByAttribute","querySelector","Portal","Component","id","guidFor","dom","getDOM","destinationElement","doc","args","getElementById","replace","namedTarget","portalMarker","containerEl","body","macroCondition","isTesting","testingContainer","appendToParentPortal","parentPortal","portalTarget","needsTarget","destEl","renderInPlace","scope","PortalTarget"],"mappings":";;;;;;;;;AAWA,MAAMA,cAQD,GAAAC,oBAAA,CAAAC,kBAAA,CAAA,0KAAA,EAQL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA,CAAA;AA8BV,SAASC,iBAAiBC,MAAsB,EAAiB;EAC/D,IAAI,CAACA,MAAA,EAAQ;AACX,IAAA,OAAO,IAAA;AACT,EAAA;AAEA,EAAA,IAAIC,MAAA,GAASD,OAAOE,aAAa;AACjC,EAAA,OAAOD,MAAA,EAAQ;IACb,IAAIA,MAAA,CAAOE,YAAY,CAAC,aAAA,CAAA,KAAmB,MAAA,EAAQ;AACjD,MAAA,OAAOF,MAAA;AACT,IAAA;IAEAA,MAAA,GAASA,OAAOC,aAAa;AAC/B,EAAA;AAEA,EAAA,OAAO,IAAA;AACT;AAEA;;;;;;;AAOC;AACD,MAAME,cAAA,GAAiB,sDAAA;AAEvB,SAASC,uBAAAA,CACPC,OAAuB,EACvBC,IAAa,EACE;EACf,IAAI,CAACD,OAAA,EAAS;AACZ,IAAA,OAAO,IAAA;AACT,EAAA;AAEA,EAAA,IAAIL,MAAA,GAASK,QAAQJ,aAAa;AAClC,EAAA,OAAOD,MAAA,EAAQ;AACb,IAAA,IAAIM,IAAA,EAAM;MACR,MAAMC,MAAA,GAASC,qBAAA,CAAsBR,MAAA,EAAQ,iB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AAmB,MACzC;EACF,CAAA;AAEA,EAAA;IAAAR,oBAAA,CAAAC,kBAAA,CAAA,wjBAAA,EAqBA;MAAAC,UAAA,EAAA,IAAA;AAAAsC,MAAAA,KAAA,EAAAA,OAAA;QAAAzC,cAAA;AAAA0C,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { useStyles } from '@frontile/theme';
|
|
3
|
-
import {
|
|
3
|
+
import { i as IconDanger, j as IconWarning, k as IconSuccess, l as IconInfo } from '../../icons-55dthVFk.js';
|
|
4
4
|
import { CloseButton } from '../buttons/close-button.js';
|
|
5
5
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
6
6
|
import { setComponentTemplate } from '@ember/component';
|
|
@@ -73,11 +73,25 @@ class Collapsible extends Component {
|
|
|
73
73
|
}
|
|
74
74
|
return safeStyles(styles);
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* False from insert until the first animation frame, while
|
|
78
|
+
* `@instantUntilPainted` is set; changes in that window skip the transition.
|
|
79
|
+
*/
|
|
80
|
+
isPainted = true;
|
|
81
|
+
paintFrame;
|
|
76
82
|
hasSetupUpdate = false;
|
|
77
83
|
update = modifier((element, [isOpen]) => {
|
|
78
84
|
// do not run update on the initial setup of modifier
|
|
79
85
|
if (!this.hasSetupUpdate) {
|
|
80
86
|
this.hasSetupUpdate = true;
|
|
87
|
+
if (this.args.instantUntilPainted) {
|
|
88
|
+
this.isPainted = false;
|
|
89
|
+
// Kept apart from `pendingFrames`: expand/contract cancel those.
|
|
90
|
+
this.paintFrame = window.requestAnimationFrame(() => {
|
|
91
|
+
this.paintFrame = undefined;
|
|
92
|
+
this.isPainted = true;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
81
95
|
return;
|
|
82
96
|
}
|
|
83
97
|
if (this.isCurrentlyOpen !== !!isOpen) {
|
|
@@ -86,10 +100,11 @@ class Collapsible extends Component {
|
|
|
86
100
|
this.endWaiter();
|
|
87
101
|
this.waiterToken = waiter.beginAsync();
|
|
88
102
|
}
|
|
103
|
+
const instant = !this.isPainted;
|
|
89
104
|
if (isOpen) {
|
|
90
|
-
this.expand(element);
|
|
105
|
+
this.expand(element, instant);
|
|
91
106
|
} else {
|
|
92
|
-
this.contract(element);
|
|
107
|
+
this.contract(element, instant);
|
|
93
108
|
}
|
|
94
109
|
});
|
|
95
110
|
endWaiter() {
|
|
@@ -103,6 +118,9 @@ class Collapsible extends Component {
|
|
|
103
118
|
willDestroy() {
|
|
104
119
|
super.willDestroy();
|
|
105
120
|
this.cancelFrames();
|
|
121
|
+
if (this.paintFrame !== undefined) {
|
|
122
|
+
window.cancelAnimationFrame(this.paintFrame);
|
|
123
|
+
}
|
|
106
124
|
// Do not leave a waiter pending if we are torn down mid-transition.
|
|
107
125
|
this.endWaiter();
|
|
108
126
|
}
|
|
@@ -171,9 +189,19 @@ class Collapsible extends Component {
|
|
|
171
189
|
opacityTransition(duration) {
|
|
172
190
|
return `opacity ${duration}s ease-in-out 0ms`;
|
|
173
191
|
}
|
|
174
|
-
expand(element) {
|
|
192
|
+
expand(element, instant = false) {
|
|
175
193
|
this.isCurrentlyOpen = true;
|
|
176
194
|
this.cancelFrames();
|
|
195
|
+
// Before the first paint (`@instantUntilPainted`): end where an
|
|
196
|
+
// initially open panel starts, with no inline geometry at all.
|
|
197
|
+
if (instant) {
|
|
198
|
+
element.style.transition = '';
|
|
199
|
+
element.style.overflow = this.initialHeight ? 'hidden' : '';
|
|
200
|
+
element.style.opacity = '';
|
|
201
|
+
element.style.height = '';
|
|
202
|
+
this.endWaiter();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
177
205
|
// The transition is written as an inline style, so a
|
|
178
206
|
// `motion-reduce:transition-none` class could never beat it. The check has
|
|
179
207
|
// to happen here.
|
|
@@ -216,10 +244,10 @@ class Collapsible extends Component {
|
|
|
216
244
|
}
|
|
217
245
|
element.style.height = initialHeight || '0';
|
|
218
246
|
}
|
|
219
|
-
contract(element) {
|
|
247
|
+
contract(element, instant = false) {
|
|
220
248
|
this.isCurrentlyOpen = false;
|
|
221
249
|
this.cancelFrames();
|
|
222
|
-
if (prefersReducedMotion()) {
|
|
250
|
+
if (instant || prefersReducedMotion()) {
|
|
223
251
|
element.style.transition = '';
|
|
224
252
|
element.style.overflow = 'hidden';
|
|
225
253
|
this.applyClosedState(element);
|