frontile 0.18.0-alpha.17 → 0.18.0-alpha.18
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/components/overlays/drawer.d.ts +1 -1
- package/declarations/components/overlays/modal.d.ts +1 -1
- package/dist/components/overlays/drawer.js +1 -1
- package/dist/components/overlays/drawer.js.map +1 -1
- package/dist/components/overlays/modal.js +1 -1
- package/dist/components/overlays/modal.js.map +1 -1
- package/package.json +3 -3
|
@@ -6,7 +6,7 @@ import { type DrawerHeaderSignature } from './drawer/header';
|
|
|
6
6
|
import { type CloseButtonSignature } from '../buttons/close-button';
|
|
7
7
|
import type { ComponentLike, WithBoundArgs } from '@glint/template';
|
|
8
8
|
import { type SlotsToClasses, type DrawerSlots, type DrawerVariants } from '@frontile/theme';
|
|
9
|
-
export interface DrawerArgs extends Pick<OverlaySignature['Args'], 'isOpen' | 'onOpen' | 'onClose' | 'didClose' | 'renderInPlace' | 'target' | 'transitionDuration' | 'backdrop' | 'disableTransitions' | 'disableFocusTrap' | 'focusTrapOptions' | 'closeOnOutsideClick' | 'closeOnEscapeKey' | 'backdropTransition'> {
|
|
9
|
+
export interface DrawerArgs extends Pick<OverlaySignature['Args'], 'isOpen' | 'onOpen' | 'onClose' | 'didClose' | 'renderInPlace' | 'target' | 'transitionDuration' | 'backdrop' | 'disableTransitions' | 'disableFocusTrap' | 'focusTrapOptions' | 'closeOnOutsideClick' | 'closeOnEscapeKey' | 'backdropTransition' | 'preventAutoFocus'> {
|
|
10
10
|
/**
|
|
11
11
|
* The transition to be used in the Drawer.
|
|
12
12
|
*
|
|
@@ -6,7 +6,7 @@ import { type ModalHeaderSignature } from './modal/header';
|
|
|
6
6
|
import { type CloseButtonSignature } from '../buttons/close-button';
|
|
7
7
|
import { type SlotsToClasses, type ModalSlots, type ModalVariants } from '@frontile/theme';
|
|
8
8
|
import type { ComponentLike, WithBoundArgs } from '@glint/template';
|
|
9
|
-
export interface ModalArgs extends Pick<OverlaySignature['Args'], 'isOpen' | 'onOpen' | 'onClose' | 'didClose' | 'renderInPlace' | 'target' | 'transitionDuration' | 'backdrop' | 'disableTransitions' | 'disableFocusTrap' | 'focusTrapOptions' | 'closeOnOutsideClick' | 'closeOnEscapeKey' | 'backdropTransition'> {
|
|
9
|
+
export interface ModalArgs extends Pick<OverlaySignature['Args'], 'isOpen' | 'onOpen' | 'onClose' | 'didClose' | 'renderInPlace' | 'target' | 'transitionDuration' | 'backdrop' | 'disableTransitions' | 'disableFocusTrap' | 'focusTrapOptions' | 'closeOnOutsideClick' | 'closeOnEscapeKey' | 'backdropTransition' | 'preventAutoFocus'> {
|
|
10
10
|
/**
|
|
11
11
|
* The transition to be used in the Modal.
|
|
12
12
|
*
|
|
@@ -111,7 +111,7 @@ class Drawer extends Component {
|
|
|
111
111
|
return options;
|
|
112
112
|
}
|
|
113
113
|
static {
|
|
114
|
-
setComponentTemplate(precompileTemplate("<Overlay @isOpen={{@isOpen}} @onClose={{@onClose}} @onOpen={{@onOpen}} @didClose={{@didClose}} @renderInPlace={{@renderInPlace}} @target={{@target}} @transitionDuration={{@transitionDuration}} @backdrop={{@backdrop}} @disableTransitions={{@disableTransitions}} @disableFocusTrap={{@disableFocusTrap}} @focusTrapOptions={{@focusTrapOptions}} @closeOnOutsideClick={{if this.preventClosing false @closeOnOutsideClick}} @closeOnEscapeKey={{if this.preventClosing false @closeOnEscapeKey}} @backdropTransition={{@backdropTransition}} @transition={{this.transition}} @closeOnOverlayElementClick={{true}}>\n <div class={{this.classes.base class=@classes.base}} tabindex=\"0\" role=\"dialog\" aria-modal={{this.ariaModal}} aria-labelledby={{this.labelledById}} {{this.warnIfUnnamed}} ...attributes>\n {{#if this.showCloseButton}}\n <CloseButton @onPress={{@onClose}} @size={{@closeButtonSize}} @class={{this.classes.closeButton class=@classes.closeButton}} />\n {{/if}}\n\n {{yield (hash CloseButton=(component CloseButton onPress=@onClose class=(this.classes.closeButton class=@classes.closeButton)) Header=(component DrawerHeader labelledById=this.headerId registerSelf=this.registerHeader classFromParent=(this.classes.header class=@classes.header)) Body=(component DrawerBody placement=this.placement classFromParent=(this.classes.body class=@classes.body)) Footer=(component DrawerFooter placement=this.placement classFromParent=(this.classes.footer class=@classes.footer)) headerId=this.headerId)}}\n </div>\n</Overlay>", {
|
|
114
|
+
setComponentTemplate(precompileTemplate("<Overlay @isOpen={{@isOpen}} @onClose={{@onClose}} @onOpen={{@onOpen}} @didClose={{@didClose}} @renderInPlace={{@renderInPlace}} @target={{@target}} @transitionDuration={{@transitionDuration}} @backdrop={{@backdrop}} @disableTransitions={{@disableTransitions}} @disableFocusTrap={{@disableFocusTrap}} @focusTrapOptions={{@focusTrapOptions}} @closeOnOutsideClick={{if this.preventClosing false @closeOnOutsideClick}} @closeOnEscapeKey={{if this.preventClosing false @closeOnEscapeKey}} @backdropTransition={{@backdropTransition}} @transition={{this.transition}} @closeOnOverlayElementClick={{true}} @preventAutoFocus={{@preventAutoFocus}}>\n <div class={{this.classes.base class=@classes.base}} tabindex=\"0\" role=\"dialog\" aria-modal={{this.ariaModal}} aria-labelledby={{this.labelledById}} {{this.warnIfUnnamed}} ...attributes>\n {{#if this.showCloseButton}}\n <CloseButton @onPress={{@onClose}} @size={{@closeButtonSize}} @class={{this.classes.closeButton class=@classes.closeButton}} />\n {{/if}}\n\n {{yield (hash CloseButton=(component CloseButton onPress=@onClose class=(this.classes.closeButton class=@classes.closeButton)) Header=(component DrawerHeader labelledById=this.headerId registerSelf=this.registerHeader classFromParent=(this.classes.header class=@classes.header)) Body=(component DrawerBody placement=this.placement classFromParent=(this.classes.body class=@classes.body)) Footer=(component DrawerFooter placement=this.placement classFromParent=(this.classes.footer class=@classes.footer)) headerId=this.headerId)}}\n </div>\n</Overlay>", {
|
|
115
115
|
strictMode: true,
|
|
116
116
|
scope: () => ({
|
|
117
117
|
Overlay,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.js","sources":["../../../src/components/overlays/drawer.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { guidFor } from '@ember/object/internals';\nimport { hash } from '@ember/helper';\nimport { modifier } from 'ember-modifier';\nimport { warnIfDialogHasNoAccessibleName } from '../../-private/dialog';\nimport Overlay, { type OverlaySignature } from './overlay';\nimport DrawerBody, { type DrawerBodySignature } from './drawer/body';\nimport DrawerFooter, { type DrawerFooterSignature } from './drawer/footer';\nimport DrawerHeader, { type DrawerHeaderSignature } from './drawer/header';\nimport {\n CloseButton,\n type CloseButtonSignature\n} from '../buttons/close-button';\nimport type { ComponentLike, WithBoundArgs } from '@glint/template';\nimport {\n useStyles,\n type SlotsToClasses,\n type DrawerSlots,\n type DrawerVariants\n} from '@frontile/theme';\n\nexport interface DrawerArgs extends Pick<\n OverlaySignature['Args'],\n | 'isOpen'\n | 'onOpen'\n | 'onClose'\n | 'didClose'\n | 'renderInPlace'\n | 'target'\n | 'transitionDuration'\n | 'backdrop'\n | 'disableTransitions'\n | 'disableFocusTrap'\n | 'focusTrapOptions'\n | 'closeOnOutsideClick'\n | 'closeOnEscapeKey'\n | 'backdropTransition'\n> {\n /**\n * The transition to be used in the Drawer.\n *\n * @defaultValue {name: 'overlay-transition--slide-from-[placement]'}\n */\n transition?: OverlaySignature['Args']['transition'];\n\n /**\n * If set to false, the close button will not be displayed,\n * closeOnOutsideClick will be set to false, and closeOnEscapeKey will also be set\n * to false.\n *\n * @defaultValue true\n */\n allowClosing?: boolean;\n\n /**\n * If set to false, the close button will not be displayed.\n *\n * @defaultValue true\n */\n allowCloseButton?: boolean;\n\n /**\n * The Close Button size.\n */\n closeButtonSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n /**\n * The Drawer can appear from any side of the screen. The 'placement'\n * option allows to choose where it appears from.\n *\n * @defaultValue 'right'\n */\n placement?: DrawerVariants['placement'];\n\n /**\n * The Drawer size.\n *\n * @defaultValue 'md'\n */\n size?: DrawerVariants['size'];\n\n /**\n * Class names for each slot of the component, merged with the theme's.\n */\n classes?: SlotsToClasses<DrawerSlots>;\n}\n\nexport interface DrawerSignature {\n Args: DrawerArgs;\n Blocks: {\n default: [\n {\n CloseButton: WithBoundArgs<\n ComponentLike<CloseButtonSignature>,\n 'onPress' | 'class'\n >;\n Header: WithBoundArgs<\n ComponentLike<DrawerHeaderSignature>,\n 'labelledById' | 'classFromParent' | 'registerSelf'\n >;\n Body: WithBoundArgs<\n ComponentLike<DrawerBodySignature>,\n 'classFromParent'\n >;\n Footer: WithBoundArgs<\n ComponentLike<DrawerFooterSignature>,\n 'classFromParent'\n >;\n headerId: string;\n }\n ];\n };\n Element: HTMLDivElement;\n}\n\nexport default class Drawer extends Component<DrawerSignature> {\n headerId = `${guidFor(this)}-header`;\n\n // `aria-labelledby` is only useful if it points at an element that actually\n // exists — a dangling reference leaves the dialog with no accessible name at\n // all. The yielded `Header` reports when it is rendered and when it goes\n // away, which keeps the reference correct even for a conditional header.\n // The count itself is deliberately untracked: registration happens while the\n // header's modifier is installing, and reading a tracked value there before\n // writing it trips Glimmer's backtracking assertion. Only the derived flag is\n // tracked, and it is always written, never read, from the callback.\n //\n // The `ref` utility looks like it should replace all of this, and it was\n // tried. It cannot: `Ref.setup` clears `current` unconditionally on teardown,\n // so it answers \"what is the current element?\" where this needs \"does any\n // header exist?\" — and those diverge when a header is *replaced* rather than\n // added or removed. Glimmer installs the modifiers of newly rendered elements\n // before tearing down the ones they replace (see the comments in\n // `utils/listManager.ts`), so with a `ref` a header swapped between the\n // branches of an `{{#if}}` leaves `current` undefined and the dialog silently\n // loses its accessible name. A `+1/-1` count is order-independent, which is\n // the whole point of it being a count.\n renderedHeaders = 0;\n @tracked hasHeader = false;\n\n registerHeader = (isRendered: boolean): void => {\n if (this.isDestroying || this.isDestroyed) {\n return;\n }\n\n this.renderedHeaders += isRendered ? 1 : -1;\n this.hasHeader = this.renderedHeaders > 0;\n };\n\n get labelledById(): string | undefined {\n return this.hasHeader ? this.headerId : undefined;\n }\n\n // What makes reading `hasHeader` here safe is *when* modifiers run, not in\n // what order: modifier install happens after the render transaction has\n // closed, so the template has already consumed `hasHeader` (through\n // `labelledById`) before any modifier hook fires. The header's write during\n // its own install therefore cannot invalidate a value still being rendered,\n // which is what would trip Glimmer's backtracking assertion.\n //\n // Whether the header's registration precedes this modifier is a separate,\n // unspecified Glimmer implementation detail. All it decides is whether this\n // first-render check already sees a registered header; if that order ever\n // inverted, the failure mode is a spurious development warning on a dialog\n // that does have a `Header` — not a broken render.\n //\n // Consumer-supplied names come through `...attributes`, which we cannot see\n // in args, hence inspecting the element itself.\n warnIfUnnamed = modifier((element: HTMLElement) => {\n warnIfDialogHasNoAccessibleName(element, this.hasHeader, 'drawer');\n });\n\n /**\n * `aria-modal=\"true\"` promises assistive technology that the rest of the page\n * is unreachable while this dialog is open. That promise only holds while the\n * overlay's focus trap is active, so when the consumer turns the trap off we\n * omit the attribute rather than lie about it — screen readers then keep\n * exposing the page behind, which is what actually happens.\n */\n get ariaModal(): 'true' | undefined {\n return this.args.disableFocusTrap === true ? undefined : 'true';\n }\n\n get preventClosing(): boolean {\n return this.args.allowClosing === false;\n }\n\n get showCloseButton(): boolean {\n return (\n this.args.allowClosing !== false && this.args.allowCloseButton !== false\n );\n }\n\n get placement() {\n return this.args.placement || 'right';\n }\n\n get classes() {\n const { drawer } = useStyles();\n\n return drawer({\n placement: this.placement,\n size: this.args.size || 'md'\n });\n }\n get transition() {\n let options: OverlaySignature['Args']['transition'] = {\n name: `overlay-transition--slide-from-${this.placement}`\n };\n\n if (typeof this.args.transition === 'object') {\n return { ...options, ...this.args.transition };\n }\n\n return options;\n }\n\n <template>\n <Overlay\n @isOpen={{@isOpen}}\n @onClose={{@onClose}}\n @onOpen={{@onOpen}}\n @didClose={{@didClose}}\n @renderInPlace={{@renderInPlace}}\n @target={{@target}}\n @transitionDuration={{@transitionDuration}}\n @backdrop={{@backdrop}}\n @disableTransitions={{@disableTransitions}}\n @disableFocusTrap={{@disableFocusTrap}}\n @focusTrapOptions={{@focusTrapOptions}}\n @closeOnOutsideClick={{if this.preventClosing false @closeOnOutsideClick}}\n @closeOnEscapeKey={{if this.preventClosing false @closeOnEscapeKey}}\n @backdropTransition={{@backdropTransition}}\n @transition={{this.transition}}\n @closeOnOverlayElementClick={{true}}\n >\n <div\n class={{this.classes.base class=@classes.base}}\n tabindex=\"0\"\n role=\"dialog\"\n aria-modal={{this.ariaModal}}\n aria-labelledby={{this.labelledById}}\n {{this.warnIfUnnamed}}\n ...attributes\n >\n {{#if this.showCloseButton}}\n <CloseButton\n @onPress={{@onClose}}\n @size={{@closeButtonSize}}\n @class={{this.classes.closeButton class=@classes.closeButton}}\n />\n {{/if}}\n\n {{yield\n (hash\n CloseButton=(component\n CloseButton\n onPress=@onClose\n class=(this.classes.closeButton class=@classes.closeButton)\n )\n Header=(component\n DrawerHeader\n labelledById=this.headerId\n registerSelf=this.registerHeader\n classFromParent=(this.classes.header class=@classes.header)\n )\n Body=(component\n DrawerBody\n placement=this.placement\n classFromParent=(this.classes.body class=@classes.body)\n )\n Footer=(component\n DrawerFooter\n placement=this.placement\n classFromParent=(this.classes.footer class=@classes.footer)\n )\n headerId=this.headerId\n )\n }}\n </div>\n </Overlay>\n </template>\n}\n"],"names":["Drawer","Component","headerId","guidFor","renderedHeaders","g","prototype","tracked","i","registerHeader","isRendered","isDestroying","isDestroyed","hasHeader","labelledById","undefined","warnIfUnnamed","modifier","element","warnIfDialogHasNoAccessibleName","ariaModal","args","disableFocusTrap","preventClosing","allowClosing","showCloseButton","allowCloseButton","placement","classes","drawer","useStyles","size","transition","options","name","setComponentTemplate","precompileTemplate","strictMode","scope","Overlay","CloseButton","hash","DrawerHeader","DrawerBody","DrawerFooter"],"mappings":";;;;;;;;;;;;;;;;AAoHe,MAAMA,eAAeC,SAAA,CAAU;AAC5CC,EAAAA,QAAA,GAAW,CAAA,EAAGC,OAAA,CAAQ,IAAI,CAAA,CAAA,OAAA,CAAU;AAEpC;AACA;AACA;AACA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AY,KAAK,KAAA,IAAS,IAAI,CAACH,IAAI,CAACK,gBAAgB,KAAK,KACrE;AACF,EAAA;EAEA,IAAIC,SAAAA,GAAY;AACd,IAAA,OAAO,IAAI,CAACN,IAAI,CAACM,SAAS,IAAI,OAAA;AAChC,EAAA;EAEA,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAQ,GAAGC,SAAA,EAAA;AAEnB,IAAA,OAAOD,MAAA,CAAO;MACZF,SAAA,EAAW,IAAI,CAACA,SAAS;AACzBI,MAAAA,IAAA,EAAM,IAAI,CAACV,IAAI,CAACU,IAAI,IAAI;AAC1B,KAAA,CAAA;AACF,EAAA;EACA,IAAIC,UAAAA,GAAa;AACf,IAAA,IAAIC,OAAkC,GAAgB;AACpDC,MAAAA,IAAA,EAAM,CAAA,+BAAA,EAAkC,IAAI,CAACP,SAAS,CAAA;KACxD;IAEA,IAAI,OAAO,IAAI,CAACN,IAAI,CAACW,UAAU,KAAK,QAAA,EAAU;MAC5C,OAAO;AAAE,QAAA,GAAGC,OAAO;QAAE,GAAG,IAAI,CAACZ,IAAI,CAACW;OAAW;AAC/C,IAAA;AAEA,IAAA,OAAOC,OAAA;AACT,EAAA;AAEA,EAAA;IAAAE,oBAAA,CAAAC,kBAAA,CAAA,+/CAAA,EAgEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,OAAA;QAAAC,WAAA;QAAAC,IAAA;QAAAC,YAAA;QAAAC,UAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
1
|
+
{"version":3,"file":"drawer.js","sources":["../../../src/components/overlays/drawer.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { guidFor } from '@ember/object/internals';\nimport { hash } from '@ember/helper';\nimport { modifier } from 'ember-modifier';\nimport { warnIfDialogHasNoAccessibleName } from '../../-private/dialog';\nimport Overlay, { type OverlaySignature } from './overlay';\nimport DrawerBody, { type DrawerBodySignature } from './drawer/body';\nimport DrawerFooter, { type DrawerFooterSignature } from './drawer/footer';\nimport DrawerHeader, { type DrawerHeaderSignature } from './drawer/header';\nimport {\n CloseButton,\n type CloseButtonSignature\n} from '../buttons/close-button';\nimport type { ComponentLike, WithBoundArgs } from '@glint/template';\nimport {\n useStyles,\n type SlotsToClasses,\n type DrawerSlots,\n type DrawerVariants\n} from '@frontile/theme';\n\nexport interface DrawerArgs extends Pick<\n OverlaySignature['Args'],\n | 'isOpen'\n | 'onOpen'\n | 'onClose'\n | 'didClose'\n | 'renderInPlace'\n | 'target'\n | 'transitionDuration'\n | 'backdrop'\n | 'disableTransitions'\n | 'disableFocusTrap'\n | 'focusTrapOptions'\n | 'closeOnOutsideClick'\n | 'closeOnEscapeKey'\n | 'backdropTransition'\n | 'preventAutoFocus'\n> {\n /**\n * The transition to be used in the Drawer.\n *\n * @defaultValue {name: 'overlay-transition--slide-from-[placement]'}\n */\n transition?: OverlaySignature['Args']['transition'];\n\n /**\n * If set to false, the close button will not be displayed,\n * closeOnOutsideClick will be set to false, and closeOnEscapeKey will also be set\n * to false.\n *\n * @defaultValue true\n */\n allowClosing?: boolean;\n\n /**\n * If set to false, the close button will not be displayed.\n *\n * @defaultValue true\n */\n allowCloseButton?: boolean;\n\n /**\n * The Close Button size.\n */\n closeButtonSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n /**\n * The Drawer can appear from any side of the screen. The 'placement'\n * option allows to choose where it appears from.\n *\n * @defaultValue 'right'\n */\n placement?: DrawerVariants['placement'];\n\n /**\n * The Drawer size.\n *\n * @defaultValue 'md'\n */\n size?: DrawerVariants['size'];\n\n /**\n * Class names for each slot of the component, merged with the theme's.\n */\n classes?: SlotsToClasses<DrawerSlots>;\n}\n\nexport interface DrawerSignature {\n Args: DrawerArgs;\n Blocks: {\n default: [\n {\n CloseButton: WithBoundArgs<\n ComponentLike<CloseButtonSignature>,\n 'onPress' | 'class'\n >;\n Header: WithBoundArgs<\n ComponentLike<DrawerHeaderSignature>,\n 'labelledById' | 'classFromParent' | 'registerSelf'\n >;\n Body: WithBoundArgs<\n ComponentLike<DrawerBodySignature>,\n 'classFromParent'\n >;\n Footer: WithBoundArgs<\n ComponentLike<DrawerFooterSignature>,\n 'classFromParent'\n >;\n headerId: string;\n }\n ];\n };\n Element: HTMLDivElement;\n}\n\nexport default class Drawer extends Component<DrawerSignature> {\n headerId = `${guidFor(this)}-header`;\n\n // `aria-labelledby` is only useful if it points at an element that actually\n // exists — a dangling reference leaves the dialog with no accessible name at\n // all. The yielded `Header` reports when it is rendered and when it goes\n // away, which keeps the reference correct even for a conditional header.\n // The count itself is deliberately untracked: registration happens while the\n // header's modifier is installing, and reading a tracked value there before\n // writing it trips Glimmer's backtracking assertion. Only the derived flag is\n // tracked, and it is always written, never read, from the callback.\n //\n // The `ref` utility looks like it should replace all of this, and it was\n // tried. It cannot: `Ref.setup` clears `current` unconditionally on teardown,\n // so it answers \"what is the current element?\" where this needs \"does any\n // header exist?\" — and those diverge when a header is *replaced* rather than\n // added or removed. Glimmer installs the modifiers of newly rendered elements\n // before tearing down the ones they replace (see the comments in\n // `utils/listManager.ts`), so with a `ref` a header swapped between the\n // branches of an `{{#if}}` leaves `current` undefined and the dialog silently\n // loses its accessible name. A `+1/-1` count is order-independent, which is\n // the whole point of it being a count.\n renderedHeaders = 0;\n @tracked hasHeader = false;\n\n registerHeader = (isRendered: boolean): void => {\n if (this.isDestroying || this.isDestroyed) {\n return;\n }\n\n this.renderedHeaders += isRendered ? 1 : -1;\n this.hasHeader = this.renderedHeaders > 0;\n };\n\n get labelledById(): string | undefined {\n return this.hasHeader ? this.headerId : undefined;\n }\n\n // What makes reading `hasHeader` here safe is *when* modifiers run, not in\n // what order: modifier install happens after the render transaction has\n // closed, so the template has already consumed `hasHeader` (through\n // `labelledById`) before any modifier hook fires. The header's write during\n // its own install therefore cannot invalidate a value still being rendered,\n // which is what would trip Glimmer's backtracking assertion.\n //\n // Whether the header's registration precedes this modifier is a separate,\n // unspecified Glimmer implementation detail. All it decides is whether this\n // first-render check already sees a registered header; if that order ever\n // inverted, the failure mode is a spurious development warning on a dialog\n // that does have a `Header` — not a broken render.\n //\n // Consumer-supplied names come through `...attributes`, which we cannot see\n // in args, hence inspecting the element itself.\n warnIfUnnamed = modifier((element: HTMLElement) => {\n warnIfDialogHasNoAccessibleName(element, this.hasHeader, 'drawer');\n });\n\n /**\n * `aria-modal=\"true\"` promises assistive technology that the rest of the page\n * is unreachable while this dialog is open. That promise only holds while the\n * overlay's focus trap is active, so when the consumer turns the trap off we\n * omit the attribute rather than lie about it — screen readers then keep\n * exposing the page behind, which is what actually happens.\n */\n get ariaModal(): 'true' | undefined {\n return this.args.disableFocusTrap === true ? undefined : 'true';\n }\n\n get preventClosing(): boolean {\n return this.args.allowClosing === false;\n }\n\n get showCloseButton(): boolean {\n return (\n this.args.allowClosing !== false && this.args.allowCloseButton !== false\n );\n }\n\n get placement() {\n return this.args.placement || 'right';\n }\n\n get classes() {\n const { drawer } = useStyles();\n\n return drawer({\n placement: this.placement,\n size: this.args.size || 'md'\n });\n }\n get transition() {\n let options: OverlaySignature['Args']['transition'] = {\n name: `overlay-transition--slide-from-${this.placement}`\n };\n\n if (typeof this.args.transition === 'object') {\n return { ...options, ...this.args.transition };\n }\n\n return options;\n }\n\n <template>\n <Overlay\n @isOpen={{@isOpen}}\n @onClose={{@onClose}}\n @onOpen={{@onOpen}}\n @didClose={{@didClose}}\n @renderInPlace={{@renderInPlace}}\n @target={{@target}}\n @transitionDuration={{@transitionDuration}}\n @backdrop={{@backdrop}}\n @disableTransitions={{@disableTransitions}}\n @disableFocusTrap={{@disableFocusTrap}}\n @focusTrapOptions={{@focusTrapOptions}}\n @closeOnOutsideClick={{if this.preventClosing false @closeOnOutsideClick}}\n @closeOnEscapeKey={{if this.preventClosing false @closeOnEscapeKey}}\n @backdropTransition={{@backdropTransition}}\n @transition={{this.transition}}\n @closeOnOverlayElementClick={{true}}\n @preventAutoFocus={{@preventAutoFocus}}\n >\n <div\n class={{this.classes.base class=@classes.base}}\n tabindex=\"0\"\n role=\"dialog\"\n aria-modal={{this.ariaModal}}\n aria-labelledby={{this.labelledById}}\n {{this.warnIfUnnamed}}\n ...attributes\n >\n {{#if this.showCloseButton}}\n <CloseButton\n @onPress={{@onClose}}\n @size={{@closeButtonSize}}\n @class={{this.classes.closeButton class=@classes.closeButton}}\n />\n {{/if}}\n\n {{yield\n (hash\n CloseButton=(component\n CloseButton\n onPress=@onClose\n class=(this.classes.closeButton class=@classes.closeButton)\n )\n Header=(component\n DrawerHeader\n labelledById=this.headerId\n registerSelf=this.registerHeader\n classFromParent=(this.classes.header class=@classes.header)\n )\n Body=(component\n DrawerBody\n placement=this.placement\n classFromParent=(this.classes.body class=@classes.body)\n )\n Footer=(component\n DrawerFooter\n placement=this.placement\n classFromParent=(this.classes.footer class=@classes.footer)\n )\n headerId=this.headerId\n )\n }}\n </div>\n </Overlay>\n </template>\n}\n"],"names":["Drawer","Component","headerId","guidFor","renderedHeaders","g","prototype","tracked","i","registerHeader","isRendered","isDestroying","isDestroyed","hasHeader","labelledById","undefined","warnIfUnnamed","modifier","element","warnIfDialogHasNoAccessibleName","ariaModal","args","disableFocusTrap","preventClosing","allowClosing","showCloseButton","allowCloseButton","placement","classes","drawer","useStyles","size","transition","options","name","setComponentTemplate","precompileTemplate","strictMode","scope","Overlay","CloseButton","hash","DrawerHeader","DrawerBody","DrawerFooter"],"mappings":";;;;;;;;;;;;;;;;AAqHe,MAAMA,eAAeC,SAAA,CAAU;AAC5CC,EAAAA,QAAA,GAAW,CAAA,EAAGC,OAAA,CAAQ,IAAI,CAAA,CAAA,OAAA,CAAU;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAC,EAAAA,eAAA,GAAkB,CAAA;AAAE,EAAA;IAAAC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I,CAACN,IAAI,CAACM,SAAS,IAAI,OAAA;AAChC,EAAA;EAEA,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAQ,GAAGC,SAAA,EAAA;AAEnB,IAAA,OAAOD,MAAA,CAAO;MACZF,SAAA,EAAW,IAAI,CAACA,SAAS;AACzBI,MAAAA,IAAA,EAAM,IAAI,CAACV,IAAI,CAACU,IAAI,IAAI;AAC1B,KAAA,CAAA;AACF,EAAA;EACA,IAAIC,UAAAA,GAAa;AACf,IAAA,IAAIC,OAAkC,GAAgB;AACpDC,MAAAA,IAAA,EAAM,CAAA,+BAAA,EAAkC,IAAI,CAACP,SAAS,CAAA;KACxD;IAEA,IAAI,OAAO,IAAI,CAACN,IAAI,CAACW,UAAU,KAAK,QAAA,EAAU;MAC5C,OAAO;AAAE,QAAA,GAAGC,OAAO;QAAE,GAAG,IAAI,CAACZ,IAAI,CAACW;OAAW;AAC/C,IAAA;AAEA,IAAA,OAAOC,OAAA;AACT,EAAA;AAEA,EAAA;IAAAE,oBAAA,CAAAC,kBAAA,CAAA,uiDAAA,EAiEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,OAAA;QAAAC,WAAA;QAAAC,IAAA;QAAAC,YAAA;QAAAC,UAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -111,7 +111,7 @@ class Modal extends Component {
|
|
|
111
111
|
return options;
|
|
112
112
|
}
|
|
113
113
|
static {
|
|
114
|
-
setComponentTemplate(precompileTemplate("<Overlay @isOpen={{@isOpen}} @onClose={{@onClose}} @onOpen={{@onOpen}} @didClose={{@didClose}} @renderInPlace={{@renderInPlace}} @target={{@target}} @transitionDuration={{@transitionDuration}} @backdrop={{@backdrop}} @disableTransitions={{@disableTransitions}} @disableFocusTrap={{@disableFocusTrap}} @focusTrapOptions={{@focusTrapOptions}} @closeOnOutsideClick={{if this.preventClosing false @closeOnOutsideClick}} @closeOnEscapeKey={{if this.preventClosing false @closeOnEscapeKey}} @backdropTransition={{@backdropTransition}} @transition={{this.transition}} @closeOnOverlayElementClick={{true}}>\n <div class={{this.classes.base class=@classes.base}} tabindex=\"0\" role=\"dialog\" aria-modal={{this.ariaModal}} aria-labelledby={{this.labelledById}} {{this.warnIfUnnamed}} ...attributes>\n {{#if this.showCloseButton}}\n <CloseButton @onPress={{@onClose}} @size={{@closeButtonSize}} @class={{this.classes.closeButton class=@classes.closeButton}} />\n {{/if}}\n\n {{yield (hash CloseButton=(component CloseButton onPress=@onClose class=(this.classes.closeButton class=@classes.closeButton)) Header=(component ModalHeader labelledById=this.headerId registerSelf=this.registerHeader classFromParent=(this.classes.header class=@classes.header)) Body=(component ModalBody classFromParent=(this.classes.body class=@classes.body)) Footer=(component ModalFooter classFromParent=(this.classes.footer class=@classes.footer)) headerId=this.headerId)}}\n </div>\n</Overlay>", {
|
|
114
|
+
setComponentTemplate(precompileTemplate("<Overlay @isOpen={{@isOpen}} @onClose={{@onClose}} @onOpen={{@onOpen}} @didClose={{@didClose}} @renderInPlace={{@renderInPlace}} @target={{@target}} @transitionDuration={{@transitionDuration}} @backdrop={{@backdrop}} @disableTransitions={{@disableTransitions}} @disableFocusTrap={{@disableFocusTrap}} @focusTrapOptions={{@focusTrapOptions}} @closeOnOutsideClick={{if this.preventClosing false @closeOnOutsideClick}} @closeOnEscapeKey={{if this.preventClosing false @closeOnEscapeKey}} @backdropTransition={{@backdropTransition}} @transition={{this.transition}} @closeOnOverlayElementClick={{true}} @preventAutoFocus={{@preventAutoFocus}}>\n <div class={{this.classes.base class=@classes.base}} tabindex=\"0\" role=\"dialog\" aria-modal={{this.ariaModal}} aria-labelledby={{this.labelledById}} {{this.warnIfUnnamed}} ...attributes>\n {{#if this.showCloseButton}}\n <CloseButton @onPress={{@onClose}} @size={{@closeButtonSize}} @class={{this.classes.closeButton class=@classes.closeButton}} />\n {{/if}}\n\n {{yield (hash CloseButton=(component CloseButton onPress=@onClose class=(this.classes.closeButton class=@classes.closeButton)) Header=(component ModalHeader labelledById=this.headerId registerSelf=this.registerHeader classFromParent=(this.classes.header class=@classes.header)) Body=(component ModalBody classFromParent=(this.classes.body class=@classes.body)) Footer=(component ModalFooter classFromParent=(this.classes.footer class=@classes.footer)) headerId=this.headerId)}}\n </div>\n</Overlay>", {
|
|
115
115
|
strictMode: true,
|
|
116
116
|
scope: () => ({
|
|
117
117
|
Overlay,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../../src/components/overlays/modal.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { guidFor } from '@ember/object/internals';\nimport { hash } from '@ember/helper';\nimport { modifier } from 'ember-modifier';\nimport { warnIfDialogHasNoAccessibleName } from '../../-private/dialog';\nimport Overlay, { type OverlaySignature } from './overlay';\nimport ModalFooter, { type ModalFooterSignature } from './modal/footer';\nimport ModalBody, { type ModalBodySignature } from './modal/body';\nimport ModalHeader, { type ModalHeaderSignature } from './modal/header';\nimport {\n CloseButton,\n type CloseButtonSignature\n} from '../buttons/close-button';\nimport {\n useStyles,\n type SlotsToClasses,\n type ModalSlots,\n type ModalVariants\n} from '@frontile/theme';\nimport type { ComponentLike, WithBoundArgs } from '@glint/template';\n\nexport interface ModalArgs extends Pick<\n OverlaySignature['Args'],\n | 'isOpen'\n | 'onOpen'\n | 'onClose'\n | 'didClose'\n | 'renderInPlace'\n | 'target'\n | 'transitionDuration'\n | 'backdrop'\n | 'disableTransitions'\n | 'disableFocusTrap'\n | 'focusTrapOptions'\n | 'closeOnOutsideClick'\n | 'closeOnEscapeKey'\n | 'backdropTransition'\n> {\n /**\n * The transition to be used in the Modal.\n *\n * @defaultValue {name: 'overlay-transition--zoom'}\n */\n transition?: OverlaySignature['Args']['transition'];\n\n /**\n * If set to false, the close button will not be displayed,\n * closeOnOutsideClick will be set to false, and closeOnEscapeKey will also be set\n * to false.\n *\n * @defaultValue true\n */\n allowClosing?: boolean;\n\n /**\n * If set to false, the close button will not be displayed.\n *\n * @defaultValue true\n */\n allowCloseButton?: boolean;\n\n /**\n * The Close Button size.\n */\n closeButtonSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n /**\n * If set to true, the modal will be vertically centered\n *\n * @defaultValue false\n */\n isCentered?: boolean;\n\n /**\n * The Modal size.\n *\n * @defaultValue 'lg'\n */\n size?: ModalVariants['size'];\n\n /**\n * Class names for each slot of the component, merged with the theme's.\n */\n classes?: SlotsToClasses<ModalSlots>;\n}\n\nexport interface ModalSignature {\n Args: ModalArgs;\n Blocks: {\n default: [\n {\n CloseButton: WithBoundArgs<\n ComponentLike<CloseButtonSignature>,\n 'onPress' | 'class'\n >;\n Header: WithBoundArgs<\n ComponentLike<ModalHeaderSignature>,\n 'labelledById' | 'classFromParent' | 'registerSelf'\n >;\n Body: WithBoundArgs<\n ComponentLike<ModalBodySignature>,\n 'classFromParent'\n >;\n Footer: WithBoundArgs<\n ComponentLike<ModalFooterSignature>,\n 'classFromParent'\n >;\n headerId: string;\n }\n ];\n };\n Element: HTMLDivElement;\n}\n\nexport default class Modal extends Component<ModalSignature> {\n headerId = `${guidFor(this)}-header`;\n\n // `aria-labelledby` is only useful if it points at an element that actually\n // exists — a dangling reference leaves the dialog with no accessible name at\n // all. The yielded `Header` reports when it is rendered and when it goes\n // away, which keeps the reference correct even for a conditional header.\n // The count itself is deliberately untracked: registration happens while the\n // header's modifier is installing, and reading a tracked value there before\n // writing it trips Glimmer's backtracking assertion. Only the derived flag is\n // tracked, and it is always written, never read, from the callback.\n //\n // The `ref` utility looks like it should replace all of this, and it was\n // tried. It cannot: `Ref.setup` clears `current` unconditionally on teardown,\n // so it answers \"what is the current element?\" where this needs \"does any\n // header exist?\" — and those diverge when a header is *replaced* rather than\n // added or removed. Glimmer installs the modifiers of newly rendered elements\n // before tearing down the ones they replace (see the comments in\n // `utils/listManager.ts`), so with a `ref` a header swapped between the\n // branches of an `{{#if}}` leaves `current` undefined and the dialog silently\n // loses its accessible name. A `+1/-1` count is order-independent, which is\n // the whole point of it being a count.\n renderedHeaders = 0;\n @tracked hasHeader = false;\n\n registerHeader = (isRendered: boolean): void => {\n if (this.isDestroying || this.isDestroyed) {\n return;\n }\n\n this.renderedHeaders += isRendered ? 1 : -1;\n this.hasHeader = this.renderedHeaders > 0;\n };\n\n get labelledById(): string | undefined {\n return this.hasHeader ? this.headerId : undefined;\n }\n\n // What makes reading `hasHeader` here safe is *when* modifiers run, not in\n // what order: modifier install happens after the render transaction has\n // closed, so the template has already consumed `hasHeader` (through\n // `labelledById`) before any modifier hook fires. The header's write during\n // its own install therefore cannot invalidate a value still being rendered,\n // which is what would trip Glimmer's backtracking assertion.\n //\n // Whether the header's registration precedes this modifier is a separate,\n // unspecified Glimmer implementation detail. All it decides is whether this\n // first-render check already sees a registered header; if that order ever\n // inverted, the failure mode is a spurious development warning on a dialog\n // that does have a `Header` — not a broken render.\n //\n // Consumer-supplied names come through `...attributes`, which we cannot see\n // in args, hence inspecting the element itself.\n warnIfUnnamed = modifier((element: HTMLElement) => {\n warnIfDialogHasNoAccessibleName(element, this.hasHeader, 'modal');\n });\n\n /**\n * `aria-modal=\"true\"` promises assistive technology that the rest of the page\n * is unreachable while this dialog is open. That promise only holds while the\n * overlay's focus trap is active, so when the consumer turns the trap off we\n * omit the attribute rather than lie about it — screen readers then keep\n * exposing the page behind, which is what actually happens.\n */\n get ariaModal(): 'true' | undefined {\n return this.args.disableFocusTrap === true ? undefined : 'true';\n }\n\n get preventClosing(): boolean {\n return this.args.allowClosing === false;\n }\n\n get showCloseButton(): boolean {\n return (\n this.args.allowClosing !== false && this.args.allowCloseButton !== false\n );\n }\n\n get size() {\n return this.args.size || 'lg';\n }\n\n get classes() {\n const { modal } = useStyles();\n\n return modal({\n size: this.size,\n isCentered: this.args.isCentered\n });\n }\n\n get transition() {\n let options: OverlaySignature['Args']['transition'] = {\n name: 'overlay-transition--zoom'\n };\n\n if (typeof this.args.transition === 'object') {\n return { ...options, ...this.args.transition };\n }\n\n return options;\n }\n\n <template>\n <Overlay\n @isOpen={{@isOpen}}\n @onClose={{@onClose}}\n @onOpen={{@onOpen}}\n @didClose={{@didClose}}\n @renderInPlace={{@renderInPlace}}\n @target={{@target}}\n @transitionDuration={{@transitionDuration}}\n @backdrop={{@backdrop}}\n @disableTransitions={{@disableTransitions}}\n @disableFocusTrap={{@disableFocusTrap}}\n @focusTrapOptions={{@focusTrapOptions}}\n @closeOnOutsideClick={{if this.preventClosing false @closeOnOutsideClick}}\n @closeOnEscapeKey={{if this.preventClosing false @closeOnEscapeKey}}\n @backdropTransition={{@backdropTransition}}\n @transition={{this.transition}}\n @closeOnOverlayElementClick={{true}}\n >\n <div\n class={{this.classes.base class=@classes.base}}\n tabindex=\"0\"\n role=\"dialog\"\n aria-modal={{this.ariaModal}}\n aria-labelledby={{this.labelledById}}\n {{this.warnIfUnnamed}}\n ...attributes\n >\n {{#if this.showCloseButton}}\n <CloseButton\n @onPress={{@onClose}}\n @size={{@closeButtonSize}}\n @class={{this.classes.closeButton class=@classes.closeButton}}\n />\n {{/if}}\n\n {{yield\n (hash\n CloseButton=(component\n CloseButton\n onPress=@onClose\n class=(this.classes.closeButton class=@classes.closeButton)\n )\n Header=(component\n ModalHeader\n labelledById=this.headerId\n registerSelf=this.registerHeader\n classFromParent=(this.classes.header class=@classes.header)\n )\n Body=(component\n ModalBody classFromParent=(this.classes.body class=@classes.body)\n )\n Footer=(component\n ModalFooter\n classFromParent=(this.classes.footer class=@classes.footer)\n )\n headerId=this.headerId\n )\n }}\n </div>\n </Overlay>\n </template>\n}\n"],"names":["Modal","Component","headerId","guidFor","renderedHeaders","g","prototype","tracked","i","registerHeader","isRendered","isDestroying","isDestroyed","hasHeader","labelledById","undefined","warnIfUnnamed","modifier","element","warnIfDialogHasNoAccessibleName","ariaModal","args","disableFocusTrap","preventClosing","allowClosing","showCloseButton","allowCloseButton","size","classes","modal","useStyles","isCentered","transition","options","name","setComponentTemplate","precompileTemplate","strictMode","scope","Overlay","CloseButton","hash","ModalHeader","ModalBody","ModalFooter"],"mappings":";;;;;;;;;;;;;;;;AAmHe,MAAMA,cAAcC,SAAA,CAAU;AAC3CC,EAAAA,QAAA,GAAW,CAAA,EAAGC,OAAA,CAAQ,IAAI,CAAA,CAAA,OAAA,CAAU;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAC,EAAAA,eAAA,GAAkB,CAAA;AAAE,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,WAAA,EAAA,CACnBC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAoB,KAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,UAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,WAAA,CAAA,EAAA,MAAA;EAErBC,cAAA,GAAkBC,UAAmB,IAAO;AAC1C,IAAA,IAAI,IAAI,CAACC,YAAY,IAAI,IAAI,CAACC,WAAW,EAAE;AACzC,MAAA;AACF,IAAA;IAEA,IAAI,CAACR,eAAe,IAAIM,UAAA,GAAa,IAAI,EAAC;AAC1C,IAAA,IAAI,CAACG,SAAS,GAAG,IAAI,CAACT,eAAe,GAAG,CAAA;EAC1C,CAAA;EAEA,IAAIU,YAAAA,GAAmC;IACrC,OAAO,IAAI,CAACD,SAAS,GAAG,IAAI,CAACX,QAAQ,GAAGa,SAAA;AAC1C,EAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAC,EAAAA,aAAA,GAAgBC,QAAA,CAAUC,OAAS,IAAA;IACjCC,+BAAA,CAAgCD,OAAA,EAAS,IAAI,CAACL,SAAS,EAAE,OAAA,CAAA;AAC3D,EAAA,CAAA,CAAA;AAEA;;;;;;AAMC;EACD,IAAIO,SAAAA,GAAgC;IAClC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"modal.js","sources":["../../../src/components/overlays/modal.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { guidFor } from '@ember/object/internals';\nimport { hash } from '@ember/helper';\nimport { modifier } from 'ember-modifier';\nimport { warnIfDialogHasNoAccessibleName } from '../../-private/dialog';\nimport Overlay, { type OverlaySignature } from './overlay';\nimport ModalFooter, { type ModalFooterSignature } from './modal/footer';\nimport ModalBody, { type ModalBodySignature } from './modal/body';\nimport ModalHeader, { type ModalHeaderSignature } from './modal/header';\nimport {\n CloseButton,\n type CloseButtonSignature\n} from '../buttons/close-button';\nimport {\n useStyles,\n type SlotsToClasses,\n type ModalSlots,\n type ModalVariants\n} from '@frontile/theme';\nimport type { ComponentLike, WithBoundArgs } from '@glint/template';\n\nexport interface ModalArgs extends Pick<\n OverlaySignature['Args'],\n | 'isOpen'\n | 'onOpen'\n | 'onClose'\n | 'didClose'\n | 'renderInPlace'\n | 'target'\n | 'transitionDuration'\n | 'backdrop'\n | 'disableTransitions'\n | 'disableFocusTrap'\n | 'focusTrapOptions'\n | 'closeOnOutsideClick'\n | 'closeOnEscapeKey'\n | 'backdropTransition'\n | 'preventAutoFocus'\n> {\n /**\n * The transition to be used in the Modal.\n *\n * @defaultValue {name: 'overlay-transition--zoom'}\n */\n transition?: OverlaySignature['Args']['transition'];\n\n /**\n * If set to false, the close button will not be displayed,\n * closeOnOutsideClick will be set to false, and closeOnEscapeKey will also be set\n * to false.\n *\n * @defaultValue true\n */\n allowClosing?: boolean;\n\n /**\n * If set to false, the close button will not be displayed.\n *\n * @defaultValue true\n */\n allowCloseButton?: boolean;\n\n /**\n * The Close Button size.\n */\n closeButtonSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n /**\n * If set to true, the modal will be vertically centered\n *\n * @defaultValue false\n */\n isCentered?: boolean;\n\n /**\n * The Modal size.\n *\n * @defaultValue 'lg'\n */\n size?: ModalVariants['size'];\n\n /**\n * Class names for each slot of the component, merged with the theme's.\n */\n classes?: SlotsToClasses<ModalSlots>;\n}\n\nexport interface ModalSignature {\n Args: ModalArgs;\n Blocks: {\n default: [\n {\n CloseButton: WithBoundArgs<\n ComponentLike<CloseButtonSignature>,\n 'onPress' | 'class'\n >;\n Header: WithBoundArgs<\n ComponentLike<ModalHeaderSignature>,\n 'labelledById' | 'classFromParent' | 'registerSelf'\n >;\n Body: WithBoundArgs<\n ComponentLike<ModalBodySignature>,\n 'classFromParent'\n >;\n Footer: WithBoundArgs<\n ComponentLike<ModalFooterSignature>,\n 'classFromParent'\n >;\n headerId: string;\n }\n ];\n };\n Element: HTMLDivElement;\n}\n\nexport default class Modal extends Component<ModalSignature> {\n headerId = `${guidFor(this)}-header`;\n\n // `aria-labelledby` is only useful if it points at an element that actually\n // exists — a dangling reference leaves the dialog with no accessible name at\n // all. The yielded `Header` reports when it is rendered and when it goes\n // away, which keeps the reference correct even for a conditional header.\n // The count itself is deliberately untracked: registration happens while the\n // header's modifier is installing, and reading a tracked value there before\n // writing it trips Glimmer's backtracking assertion. Only the derived flag is\n // tracked, and it is always written, never read, from the callback.\n //\n // The `ref` utility looks like it should replace all of this, and it was\n // tried. It cannot: `Ref.setup` clears `current` unconditionally on teardown,\n // so it answers \"what is the current element?\" where this needs \"does any\n // header exist?\" — and those diverge when a header is *replaced* rather than\n // added or removed. Glimmer installs the modifiers of newly rendered elements\n // before tearing down the ones they replace (see the comments in\n // `utils/listManager.ts`), so with a `ref` a header swapped between the\n // branches of an `{{#if}}` leaves `current` undefined and the dialog silently\n // loses its accessible name. A `+1/-1` count is order-independent, which is\n // the whole point of it being a count.\n renderedHeaders = 0;\n @tracked hasHeader = false;\n\n registerHeader = (isRendered: boolean): void => {\n if (this.isDestroying || this.isDestroyed) {\n return;\n }\n\n this.renderedHeaders += isRendered ? 1 : -1;\n this.hasHeader = this.renderedHeaders > 0;\n };\n\n get labelledById(): string | undefined {\n return this.hasHeader ? this.headerId : undefined;\n }\n\n // What makes reading `hasHeader` here safe is *when* modifiers run, not in\n // what order: modifier install happens after the render transaction has\n // closed, so the template has already consumed `hasHeader` (through\n // `labelledById`) before any modifier hook fires. The header's write during\n // its own install therefore cannot invalidate a value still being rendered,\n // which is what would trip Glimmer's backtracking assertion.\n //\n // Whether the header's registration precedes this modifier is a separate,\n // unspecified Glimmer implementation detail. All it decides is whether this\n // first-render check already sees a registered header; if that order ever\n // inverted, the failure mode is a spurious development warning on a dialog\n // that does have a `Header` — not a broken render.\n //\n // Consumer-supplied names come through `...attributes`, which we cannot see\n // in args, hence inspecting the element itself.\n warnIfUnnamed = modifier((element: HTMLElement) => {\n warnIfDialogHasNoAccessibleName(element, this.hasHeader, 'modal');\n });\n\n /**\n * `aria-modal=\"true\"` promises assistive technology that the rest of the page\n * is unreachable while this dialog is open. That promise only holds while the\n * overlay's focus trap is active, so when the consumer turns the trap off we\n * omit the attribute rather than lie about it — screen readers then keep\n * exposing the page behind, which is what actually happens.\n */\n get ariaModal(): 'true' | undefined {\n return this.args.disableFocusTrap === true ? undefined : 'true';\n }\n\n get preventClosing(): boolean {\n return this.args.allowClosing === false;\n }\n\n get showCloseButton(): boolean {\n return (\n this.args.allowClosing !== false && this.args.allowCloseButton !== false\n );\n }\n\n get size() {\n return this.args.size || 'lg';\n }\n\n get classes() {\n const { modal } = useStyles();\n\n return modal({\n size: this.size,\n isCentered: this.args.isCentered\n });\n }\n\n get transition() {\n let options: OverlaySignature['Args']['transition'] = {\n name: 'overlay-transition--zoom'\n };\n\n if (typeof this.args.transition === 'object') {\n return { ...options, ...this.args.transition };\n }\n\n return options;\n }\n\n <template>\n <Overlay\n @isOpen={{@isOpen}}\n @onClose={{@onClose}}\n @onOpen={{@onOpen}}\n @didClose={{@didClose}}\n @renderInPlace={{@renderInPlace}}\n @target={{@target}}\n @transitionDuration={{@transitionDuration}}\n @backdrop={{@backdrop}}\n @disableTransitions={{@disableTransitions}}\n @disableFocusTrap={{@disableFocusTrap}}\n @focusTrapOptions={{@focusTrapOptions}}\n @closeOnOutsideClick={{if this.preventClosing false @closeOnOutsideClick}}\n @closeOnEscapeKey={{if this.preventClosing false @closeOnEscapeKey}}\n @backdropTransition={{@backdropTransition}}\n @transition={{this.transition}}\n @closeOnOverlayElementClick={{true}}\n @preventAutoFocus={{@preventAutoFocus}}\n >\n <div\n class={{this.classes.base class=@classes.base}}\n tabindex=\"0\"\n role=\"dialog\"\n aria-modal={{this.ariaModal}}\n aria-labelledby={{this.labelledById}}\n {{this.warnIfUnnamed}}\n ...attributes\n >\n {{#if this.showCloseButton}}\n <CloseButton\n @onPress={{@onClose}}\n @size={{@closeButtonSize}}\n @class={{this.classes.closeButton class=@classes.closeButton}}\n />\n {{/if}}\n\n {{yield\n (hash\n CloseButton=(component\n CloseButton\n onPress=@onClose\n class=(this.classes.closeButton class=@classes.closeButton)\n )\n Header=(component\n ModalHeader\n labelledById=this.headerId\n registerSelf=this.registerHeader\n classFromParent=(this.classes.header class=@classes.header)\n )\n Body=(component\n ModalBody classFromParent=(this.classes.body class=@classes.body)\n )\n Footer=(component\n ModalFooter\n classFromParent=(this.classes.footer class=@classes.footer)\n )\n headerId=this.headerId\n )\n }}\n </div>\n </Overlay>\n </template>\n}\n"],"names":["Modal","Component","headerId","guidFor","renderedHeaders","g","prototype","tracked","i","registerHeader","isRendered","isDestroying","isDestroyed","hasHeader","labelledById","undefined","warnIfUnnamed","modifier","element","warnIfDialogHasNoAccessibleName","ariaModal","args","disableFocusTrap","preventClosing","allowClosing","showCloseButton","allowCloseButton","size","classes","modal","useStyles","isCentered","transition","options","name","setComponentTemplate","precompileTemplate","strictMode","scope","Overlay","CloseButton","hash","ModalHeader","ModalBody","ModalFooter"],"mappings":";;;;;;;;;;;;;;;;AAoHe,MAAMA,cAAcC,SAAA,CAAU;AAC3CC,EAAAA,QAAA,GAAW,CAAA,EAAGC,OAAA,CAAQ,IAAI,CAAA,CAAA,OAAA,CAAU;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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ACK,gBAAgB,KAAK,KACrE;AACF,EAAA;EAEA,IAAIC,IAAAA,GAAO;AACT,IAAA,OAAO,IAAI,CAACN,IAAI,CAACM,IAAI,IAAI,IAAA;AAC3B,EAAA;EAEA,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAO,GAAGC,SAAA,EAAA;AAElB,IAAA,OAAOD,KAAA,CAAM;MACXF,IAAA,EAAM,IAAI,CAACA,IAAI;AACfI,MAAAA,UAAA,EAAY,IAAI,CAACV,IAAI,CAACU;AACxB,KAAA,CAAA;AACF,EAAA;EAEA,IAAIC,UAAAA,GAAa;AACf,IAAA,IAAIC,OAAkC,GAAgB;AACpDC,MAAAA,IAAA,EAAM;KACR;IAEA,IAAI,OAAO,IAAI,CAACb,IAAI,CAACW,UAAU,KAAK,QAAA,EAAU;MAC5C,OAAO;AAAE,QAAA,GAAGC,OAAO;QAAE,GAAG,IAAI,CAACZ,IAAI,CAACW;OAAW;AAC/C,IAAA;AAEA,IAAA,OAAOC,OAAA;AACT,EAAA;AAEA,EAAA;IAAAE,oBAAA,CAAAC,kBAAA,CAAA,k/CAAA,EA8DA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,OAAA;QAAAC,WAAA;QAAAC,IAAA;QAAAC,WAAA;QAAAC,SAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frontile",
|
|
3
|
-
"version": "0.18.0-alpha.
|
|
3
|
+
"version": "0.18.0-alpha.18",
|
|
4
4
|
"description": "Component Library for Ember Octane apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@ember/test-waiters": "^4.1.2",
|
|
90
90
|
"@embroider/addon-shim": "^1.10.3",
|
|
91
91
|
"@embroider/macros": "^1.20.6",
|
|
92
|
-
"@frontile/theme": "^0.18.0-alpha.
|
|
92
|
+
"@frontile/theme": "^0.18.0-alpha.18",
|
|
93
93
|
"@glint/template": "^1.8.0",
|
|
94
94
|
"@universal-ember/table": "^4.0.0",
|
|
95
95
|
"ember-auto-import": "^2.13.1",
|
|
@@ -147,5 +147,5 @@
|
|
|
147
147
|
"./services/notifications.js": "./dist/_app_/services/notifications.js"
|
|
148
148
|
}
|
|
149
149
|
},
|
|
150
|
-
"gitHead": "
|
|
150
|
+
"gitHead": "2357ac9d299b69824a6b4372c62f070c9fb25b6c"
|
|
151
151
|
}
|