frontile 0.18.0-beta.0 → 0.18.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/-private/deprecated-args.d.ts +18 -0
- package/declarations/-private/notification.d.ts +4 -4
- package/declarations/-private/types.d.ts +10 -8
- package/declarations/components/buttons/button-group.d.ts +3 -1
- package/declarations/components/buttons/button.d.ts +12 -3
- package/declarations/components/buttons/chip.d.ts +15 -8
- package/declarations/components/buttons/close-button.d.ts +5 -2
- package/declarations/components/buttons/segmented-control/segmented-control.d.ts +9 -9
- package/declarations/components/buttons/toggle-button.d.ts +9 -1
- package/declarations/components/collections/calendar/calendar.d.ts +49 -49
- package/declarations/components/collections/calendar/utils.d.ts +1 -0
- package/declarations/components/collections/dropdown/dropdown.d.ts +13 -2
- package/declarations/components/collections/dropdown/menu-context.d.ts +3 -3
- package/declarations/components/collections/listbox/group.d.ts +7 -2
- package/declarations/components/collections/listbox/item.d.ts +27 -6
- package/declarations/components/collections/listbox/listbox.d.ts +31 -4
- package/declarations/components/collections/simple-table/body.d.ts +72 -72
- package/declarations/components/collections/simple-table/cell.d.ts +72 -72
- package/declarations/components/collections/simple-table/column.d.ts +72 -72
- package/declarations/components/collections/simple-table/footer.d.ts +72 -72
- package/declarations/components/collections/simple-table/header.d.ts +72 -72
- package/declarations/components/collections/simple-table/index.d.ts +84 -72
- package/declarations/components/collections/simple-table/row.d.ts +72 -72
- package/declarations/components/collections/table/column-visibility.d.ts +72 -72
- package/declarations/components/collections/table/sort-button.d.ts +72 -72
- package/declarations/components/collections/table/table.d.ts +73 -72
- package/declarations/components/disclosure/accordion/accordion.d.ts +23 -23
- package/declarations/components/forms/autocomplete.d.ts +24 -12
- package/declarations/components/forms/date-picker/date-picker.d.ts +268 -0
- package/declarations/components/forms/date-picker/end-content.d.ts +29 -0
- package/declarations/components/forms/date-picker/trigger.d.ts +40 -0
- package/declarations/components/forms/date-picker/types.d.ts +149 -0
- package/declarations/components/forms/date-picker/value.d.ts +43 -0
- package/declarations/components/forms/date-picker.d.ts +3 -0
- package/declarations/components/forms/field.d.ts +5 -0
- package/declarations/components/forms/form-control.d.ts +1 -1
- package/declarations/components/forms/form-feedback.d.ts +17 -2
- package/declarations/components/forms/icons.d.ts +4 -1
- package/declarations/components/forms/index.d.ts +2 -0
- package/declarations/components/forms/input.d.ts +10 -10
- package/declarations/components/forms/native-select.d.ts +7 -7
- package/declarations/components/forms/select/select.d.ts +30 -17
- package/declarations/components/forms/select/trigger.d.ts +5 -3
- package/declarations/components/forms/select/types.d.ts +42 -12
- package/declarations/components/forms/switch.d.ts +22 -18
- package/declarations/components/forms/textarea.d.ts +6 -6
- package/declarations/components/navigation/pagination/pagination.d.ts +21 -20
- package/declarations/components/navigation/tab-nav/tab-nav.d.ts +12 -12
- package/declarations/components/navigation/tabs/tabs.d.ts +12 -12
- package/declarations/components/notifications/index.d.ts +2 -2
- package/declarations/components/notifications/notification-card.d.ts +5 -5
- package/declarations/components/notifications/notifications-container.d.ts +2 -2
- package/declarations/components/overlays/drawer.d.ts +32 -32
- package/declarations/components/overlays/popover.d.ts +1 -1
- package/declarations/components/overlays/tooltip.d.ts +2 -2
- package/declarations/components/status/alert.d.ts +10 -10
- package/declarations/components/status/progress-bar.d.ts +5 -1
- package/declarations/components/utilities/kbd.d.ts +4 -4
- package/declarations/components/utilities/spinner.d.ts +14 -7
- package/declarations/index.d.ts +1 -1
- package/declarations/template-registry.d.ts +2 -1
- package/declarations/test-support.d.ts +22 -0
- package/declarations/utils/selection-indicator.d.ts +4 -0
- package/dist/components/buttons/button-group.js +26 -1
- package/dist/components/buttons/button-group.js.map +1 -1
- package/dist/components/buttons/button.js +23 -4
- package/dist/components/buttons/button.js.map +1 -1
- package/dist/components/buttons/chip.js +20 -3
- package/dist/components/buttons/chip.js.map +1 -1
- package/dist/components/buttons/close-button.js +18 -2
- package/dist/components/buttons/close-button.js.map +1 -1
- package/dist/components/buttons/segmented-control/item.js +1 -1
- package/dist/components/buttons/segmented-control/item.js.map +1 -1
- package/dist/components/buttons/segmented-control/segmented-control.js +2 -2
- package/dist/components/buttons/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/buttons/toggle-button.js +37 -3
- package/dist/components/buttons/toggle-button.js.map +1 -1
- package/dist/components/collections/calendar/calendar.js +43 -6
- package/dist/components/collections/calendar/calendar.js.map +1 -1
- package/dist/components/collections/calendar/day-cell.js +1 -1
- package/dist/components/collections/calendar/day-cell.js.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/calendar/header.js.map +1 -1
- package/dist/components/collections/calendar/month-grid.js +1 -1
- package/dist/components/collections/calendar/month-grid.js.map +1 -1
- package/dist/components/collections/calendar/utils.js +1 -1
- package/dist/components/collections/calendar/utils.js.map +1 -1
- package/dist/components/collections/calendar/year-grid.js +15 -3
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/collections/command/command.js +1 -1
- package/dist/components/collections/command/command.js.map +1 -1
- package/dist/components/collections/command/dialog.js +1 -1
- package/dist/components/collections/command/dialog.js.map +1 -1
- package/dist/components/collections/command/footer.js +3 -3
- package/dist/components/collections/command/footer.js.map +1 -1
- package/dist/components/collections/command/input.js +1 -1
- package/dist/components/collections/command/input.js.map +1 -1
- package/dist/components/collections/command/list.js +1 -1
- package/dist/components/collections/command/list.js.map +1 -1
- package/dist/components/collections/dropdown/dropdown.js +45 -7
- package/dist/components/collections/dropdown/dropdown.js.map +1 -1
- package/dist/components/collections/dropdown/menu-context.js.map +1 -1
- package/dist/components/collections/listbox/group.js +1 -1
- package/dist/components/collections/listbox/group.js.map +1 -1
- package/dist/components/collections/listbox/item.js +47 -8
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/listbox/listbox.js +53 -2
- package/dist/components/collections/listbox/listbox.js.map +1 -1
- package/dist/components/collections/simple-table/body.js +1 -1
- package/dist/components/collections/simple-table/body.js.map +1 -1
- package/dist/components/collections/simple-table/cell.js +1 -1
- package/dist/components/collections/simple-table/cell.js.map +1 -1
- package/dist/components/collections/simple-table/column.js +1 -1
- package/dist/components/collections/simple-table/column.js.map +1 -1
- package/dist/components/collections/simple-table/footer.js +1 -1
- package/dist/components/collections/simple-table/footer.js.map +1 -1
- package/dist/components/collections/simple-table/header.js +1 -1
- package/dist/components/collections/simple-table/header.js.map +1 -1
- package/dist/components/collections/simple-table/index.js +5 -3
- package/dist/components/collections/simple-table/index.js.map +1 -1
- package/dist/components/collections/simple-table/row.js +1 -1
- package/dist/components/collections/simple-table/row.js.map +1 -1
- package/dist/components/collections/table/checkbox.js +1 -1
- package/dist/components/collections/table/checkbox.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +1 -1
- package/dist/components/collections/table/column-visibility.js.map +1 -1
- package/dist/components/collections/table/sort-button.js +1 -1
- package/dist/components/collections/table/sort-button.js.map +1 -1
- package/dist/components/collections/table/table.js +7 -3
- package/dist/components/collections/table/table.js.map +1 -1
- package/dist/components/disclosure/accordion/accordion.js +3 -2
- package/dist/components/disclosure/accordion/accordion.js.map +1 -1
- package/dist/components/disclosure/accordion/item.js +1 -1
- package/dist/components/disclosure/accordion/item.js.map +1 -1
- package/dist/components/forms/autocomplete.js +47 -2
- package/dist/components/forms/autocomplete.js.map +1 -1
- package/dist/components/forms/checkbox-group.js +1 -1
- package/dist/components/forms/checkbox-group.js.map +1 -1
- package/dist/components/forms/checkbox.js +1 -1
- package/dist/components/forms/checkbox.js.map +1 -1
- package/dist/components/forms/date-picker/date-picker.js +301 -0
- package/dist/components/forms/date-picker/date-picker.js.map +1 -0
- package/dist/components/forms/date-picker/end-content.js +21 -0
- package/dist/components/forms/date-picker/end-content.js.map +1 -0
- package/dist/components/forms/date-picker/trigger.js +14 -0
- package/dist/components/forms/date-picker/trigger.js.map +1 -0
- package/dist/components/forms/date-picker/types.js +2 -0
- package/dist/components/forms/date-picker/types.js.map +1 -0
- package/dist/components/forms/date-picker/value.js +97 -0
- package/dist/components/forms/date-picker/value.js.map +1 -0
- package/dist/components/forms/date-picker.js +2 -0
- package/dist/components/forms/date-picker.js.map +1 -0
- package/dist/components/forms/field.js +3 -1
- package/dist/components/forms/field.js.map +1 -1
- package/dist/components/forms/form-control.js +1 -1
- package/dist/components/forms/form-control.js.map +1 -1
- package/dist/components/forms/form-description.js +1 -1
- package/dist/components/forms/form-description.js.map +1 -1
- package/dist/components/forms/form-feedback.js +26 -3
- package/dist/components/forms/form-feedback.js.map +1 -1
- package/dist/components/forms/icons.js +4 -1
- package/dist/components/forms/icons.js.map +1 -1
- package/dist/components/forms/index.js +2 -0
- package/dist/components/forms/index.js.map +1 -1
- package/dist/components/forms/input-otp.js +1 -1
- package/dist/components/forms/input-otp.js.map +1 -1
- package/dist/components/forms/input.js +1 -1
- package/dist/components/forms/input.js.map +1 -1
- package/dist/components/forms/label.js +1 -1
- package/dist/components/forms/label.js.map +1 -1
- package/dist/components/forms/native-select.js +2 -2
- package/dist/components/forms/native-select.js.map +1 -1
- package/dist/components/forms/radio-group.js +1 -1
- package/dist/components/forms/radio-group.js.map +1 -1
- package/dist/components/forms/radio.js +1 -1
- package/dist/components/forms/radio.js.map +1 -1
- package/dist/components/forms/select/end-content.js +1 -1
- package/dist/components/forms/select/end-content.js.map +1 -1
- package/dist/components/forms/select/select.js +61 -7
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/components/forms/select/selected-items.js +1 -1
- package/dist/components/forms/select/selected-items.js.map +1 -1
- package/dist/components/forms/select/trigger.js +6 -4
- package/dist/components/forms/select/trigger.js.map +1 -1
- package/dist/components/forms/switch.js +10 -2
- package/dist/components/forms/switch.js.map +1 -1
- package/dist/components/forms/textarea.js +1 -1
- package/dist/components/forms/textarea.js.map +1 -1
- package/dist/components/navigation/external-link.js +2 -2
- package/dist/components/navigation/external-link.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +2 -2
- package/dist/components/navigation/pagination/pagination.js.map +1 -1
- package/dist/components/navigation/tab-nav/item.js +1 -1
- package/dist/components/navigation/tab-nav/item.js.map +1 -1
- package/dist/components/navigation/tab-nav/tab-nav.js +2 -2
- package/dist/components/navigation/tab-nav/tab-nav.js.map +1 -1
- package/dist/components/navigation/tabs/panel.js +1 -1
- package/dist/components/navigation/tabs/panel.js.map +1 -1
- package/dist/components/navigation/tabs/tab.js +1 -1
- package/dist/components/navigation/tabs/tab.js.map +1 -1
- package/dist/components/navigation/tabs/tabs.js +3 -3
- package/dist/components/navigation/tabs/tabs.js.map +1 -1
- package/dist/components/notifications/index.js +2 -2
- package/dist/components/notifications/notification-card.js +1 -1
- package/dist/components/notifications/notifications-container.js +2 -2
- package/dist/components/notifications/notifications-container.js.map +1 -1
- package/dist/components/overlays/drawer/body.js +1 -1
- package/dist/components/overlays/drawer/body.js.map +1 -1
- package/dist/components/overlays/drawer/drag-handle.js +1 -1
- package/dist/components/overlays/drawer/drag-handle.js.map +1 -1
- package/dist/components/overlays/drawer/footer.js +1 -1
- package/dist/components/overlays/drawer/footer.js.map +1 -1
- package/dist/components/overlays/drawer/header.js +4 -4
- package/dist/components/overlays/drawer/header.js.map +1 -1
- package/dist/components/overlays/drawer.js +4 -4
- package/dist/components/overlays/drawer.js.map +1 -1
- package/dist/components/overlays/modal/body.js +1 -1
- package/dist/components/overlays/modal/body.js.map +1 -1
- package/dist/components/overlays/modal/footer.js +1 -1
- package/dist/components/overlays/modal/footer.js.map +1 -1
- package/dist/components/overlays/modal/header.js +1 -1
- package/dist/components/overlays/modal/header.js.map +1 -1
- package/dist/components/overlays/modal.js +1 -1
- package/dist/components/overlays/modal.js.map +1 -1
- package/dist/components/overlays/overlay.js +1 -1
- package/dist/components/overlays/overlay.js.map +1 -1
- package/dist/components/overlays/popover.js.map +1 -1
- package/dist/components/overlays/tooltip.js +14 -2
- package/dist/components/overlays/tooltip.js.map +1 -1
- package/dist/components/status/alert.js +19 -15
- package/dist/components/status/alert.js.map +1 -1
- package/dist/components/status/progress-bar.js +10 -2
- package/dist/components/status/progress-bar.js.map +1 -1
- package/dist/components/utilities/avatar.js +1 -1
- package/dist/components/utilities/avatar.js.map +1 -1
- package/dist/components/utilities/divider.js +1 -1
- package/dist/components/utilities/divider.js.map +1 -1
- package/dist/components/utilities/kbd.js +3 -3
- package/dist/components/utilities/kbd.js.map +1 -1
- package/dist/components/utilities/skeleton.js +1 -1
- package/dist/components/utilities/skeleton.js.map +1 -1
- package/dist/components/utilities/spinner.js +26 -7
- package/dist/components/utilities/spinner.js.map +1 -1
- package/dist/deprecated-args-BIUjLA8y.js +32 -0
- package/dist/deprecated-args-BIUjLA8y.js.map +1 -0
- package/dist/forms.js +2 -0
- package/dist/forms.js.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/{manager-CDIZzrQ9.js → manager-B-PnYqDs.js} +28 -22
- package/dist/manager-B-PnYqDs.js.map +1 -0
- package/dist/{notification-card-D5fd-Sxa.js → notification-card-CYmWQ35W.js} +25 -22
- package/dist/notification-card-CYmWQ35W.js.map +1 -0
- package/dist/notifications.js +2 -2
- package/dist/services/notifications.js +1 -1
- package/dist/test-support.js +40 -2
- package/dist/test-support.js.map +1 -1
- package/dist/utils/selection-indicator.js +30 -2
- package/dist/utils/selection-indicator.js.map +1 -1
- package/package.json +3 -3
- package/dist/manager-CDIZzrQ9.js.map +0 -1
- package/dist/notification-card-D5fd-Sxa.js.map +0 -1
|
@@ -25,6 +25,12 @@ class SelectionIndicator {
|
|
|
25
25
|
#resize = deferredWork('@frontile/utils:selection-indicator:resize');
|
|
26
26
|
#isReady = false;
|
|
27
27
|
|
|
28
|
+
// Whether a real measurement has ever landed. Only the very first one is
|
|
29
|
+
// forced-layout-sensitive (see `setupContainer`); once it has happened, a
|
|
30
|
+
// click that moves the selection is no longer racing an ancestor's own
|
|
31
|
+
// mount-time transition, so there is no reason to defer those.
|
|
32
|
+
#hasMeasuredOnce = false;
|
|
33
|
+
|
|
28
34
|
/**
|
|
29
35
|
* Modifier to place on the container element. Observes its size and, once
|
|
30
36
|
* a target is selected, publishes that target's geometry as CSS custom
|
|
@@ -42,7 +48,22 @@ class SelectionIndicator {
|
|
|
42
48
|
if (this.#target) {
|
|
43
49
|
this.#observer.observe(this.#target);
|
|
44
50
|
}
|
|
45
|
-
|
|
51
|
+
|
|
52
|
+
// Before the first real measurement, this call is happening during the
|
|
53
|
+
// control's own initial mount -- the same render pass that can be
|
|
54
|
+
// mounting an ancestor overlay's enter transition. Forcing layout here
|
|
55
|
+
// lands at an arbitrary point in `ember-css-transitions`' own
|
|
56
|
+
// reflow-then-swap sequence for that transition, which is enough to make
|
|
57
|
+
// the browser skip it entirely. `ResizeObserver.observe()` above already
|
|
58
|
+
// guarantees an initial, asynchronous notification for `element` (and for
|
|
59
|
+
// the target, if already claimed), so leaving it to that -- deferred
|
|
60
|
+
// through `#resize` like any other resize -- gets the same measurement
|
|
61
|
+
// without the synchronous reflow. Once a first measurement has actually
|
|
62
|
+
// landed, later remounts of this same container are no longer racing
|
|
63
|
+
// anything, so measure immediately as before.
|
|
64
|
+
if (this.#hasMeasuredOnce) {
|
|
65
|
+
this.#measure();
|
|
66
|
+
}
|
|
46
67
|
return () => {
|
|
47
68
|
this.#shutDown();
|
|
48
69
|
};
|
|
@@ -53,11 +74,17 @@ class SelectionIndicator {
|
|
|
53
74
|
* so a consumer composing its own modifier -- a navigation bar that also has
|
|
54
75
|
* to write `aria-current` -- can delegate here rather than reimplement the
|
|
55
76
|
* handover rules below.
|
|
77
|
+
*
|
|
78
|
+
* Measures synchronously once a first measurement has already landed --
|
|
79
|
+
* see `setupContainer` -- so a click that moves the selection updates the
|
|
80
|
+
* indicator immediately rather than a frame later.
|
|
56
81
|
*/
|
|
57
82
|
claim(element) {
|
|
58
83
|
this.#target = element;
|
|
59
84
|
this.#observer?.observe(element);
|
|
60
|
-
this.#
|
|
85
|
+
if (this.#hasMeasuredOnce) {
|
|
86
|
+
this.#measure();
|
|
87
|
+
}
|
|
61
88
|
}
|
|
62
89
|
|
|
63
90
|
/**
|
|
@@ -130,6 +157,7 @@ class SelectionIndicator {
|
|
|
130
157
|
container.style.setProperty('--fr-si-y', `${target.offsetTop}px`);
|
|
131
158
|
container.style.setProperty('--fr-si-width', `${width}px`);
|
|
132
159
|
container.style.setProperty('--fr-si-height', `${height}px`);
|
|
160
|
+
this.#hasMeasuredOnce = true;
|
|
133
161
|
if (!this.#isReady) {
|
|
134
162
|
this.#isReady = true;
|
|
135
163
|
this.#scheduleReady(container);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-indicator.js","sources":["../../src/utils/selection-indicator.ts"],"sourcesContent":["import { modifier } from 'ember-modifier';\nimport { deferredWork } from './deferred-work';\n\nconst READY_ATTRIBUTE = 'data-fr-si-ready';\n\n/**\n * Measures whichever element is currently selected and publishes its geometry\n * on the container as CSS custom properties. It never paints anything: the\n * theme decides whether that geometry becomes a full pill or a bar pinned to\n * one edge, which is what lets one primitive serve a segmented control and\n * tabs alike.\n *\n * Offsets are physical (`offsetLeft` / `offsetTop`), not logical, and that is\n * deliberate. The browser has already laid the items out for the container's\n * direction, so a physical offset fed to `translate` is correct in both LTR\n * and RTL. Reaching for `inset-inline-start` here would flip an already\n * flipped value.\n */\nclass SelectionIndicator {\n #container?: HTMLElement;\n #target?: HTMLElement;\n #observer?: ResizeObserver;\n #ready = deferredWork('@frontile/utils:selection-indicator:ready');\n #remeasure = deferredWork('@frontile/utils:selection-indicator:remeasure');\n #resize = deferredWork('@frontile/utils:selection-indicator:resize');\n #isReady = false;\n\n /**\n * Modifier to place on the container element. Observes its size and, once\n * a target is selected, publishes that target's geometry as CSS custom\n * properties on this element.\n */\n setupContainer = modifier((element: HTMLElement) => {\n this.#container = element;\n // Coalesced to one measurement per frame: the container and the target are\n // both observed, and resizing the container usually resizes the target too,\n // so a single layout change delivers two entries. Measuring reads layout\n // and then writes four custom properties, and a window drag fires this\n // continuously.\n this.#observer = new ResizeObserver(() =>\n this.#resize.schedule(() => this.#measure())\n );\n this.#observer.observe(element);\n\n if (this.#target) {\n this.#observer.observe(this.#target);\n }\n this.#measure();\n\n return (): void => {\n this.#shutDown();\n };\n });\n\n /**\n * Claims `element` as the measured target. Exposed alongside `setupTarget`\n * so a consumer composing its own modifier -- a navigation bar that also has\n * to write `aria-current` -- can delegate here rather than reimplement the\n * handover rules below.\n */\n claim(element: HTMLElement): void {\n this.#target = element;\n this.#observer?.observe(element);\n this.#measure();\n }\n\n /**\n * Releases `element` if it is still the target. When selection moves\n * backwards, the incoming item's setup runs before the outgoing item's\n * teardown, and without this guard that teardown would wipe the new\n * target.\n */\n release(element: HTMLElement): void {\n if (this.#target !== element) {\n return;\n }\n this.#observer?.unobserve(element);\n this.#target = undefined;\n\n // Do not re-measure synchronously. When selection moves forwards the\n // order is reversed -- ember-modifier tears down before re-running\n // setup, and Glimmer revalidates in tree order -- so the outgoing\n // teardown lands first and the incoming target is still moments away\n // in this same render. Measuring now would strip the ready attribute,\n // and the theme gates both opacity and the transition on it, so the\n // indicator would blink out and jump to its new position instead of\n // sliding. Defer instead, and only fall through to the not-ready path\n // if nothing has claimed the target by then.\n this.#scheduleRemeasure();\n }\n\n /**\n * Modifier to place on each candidate target element, passing whether it\n * is currently selected as the sole positional argument. Only the\n * currently-selected target's geometry is measured and published.\n */\n setupTarget = modifier((element: HTMLElement, [isSelected]: [boolean]) => {\n if (isSelected) {\n this.claim(element);\n }\n\n return (): void => {\n this.release(element);\n };\n });\n\n /**\n * Recomputes and republishes the current target's geometry. Called\n * automatically on setup, selection change, and container/target resize;\n * exposed for callers that need to force a recomputation.\n */\n #measure = (): void => {\n const container = this.#container;\n if (!container) {\n return;\n }\n\n const target = this.#target;\n if (!target) {\n this.#markNotReady();\n return;\n }\n\n const width = target.offsetWidth;\n const height = target.offsetHeight;\n\n // A control inside a hidden ancestor -- a closed drawer, an inactive tab\n // panel -- measures zero. Publishing that would collapse the indicator and,\n // worse, mark it ready, so the first real measurement once it is shown\n // would animate in from the container origin. Stay un-ready instead; the\n // ResizeObserver fires when it becomes visible.\n if (width === 0 && height === 0) {\n this.#markNotReady();\n return;\n }\n\n container.style.setProperty('--fr-si-x', `${target.offsetLeft}px`);\n container.style.setProperty('--fr-si-y', `${target.offsetTop}px`);\n container.style.setProperty('--fr-si-width', `${width}px`);\n container.style.setProperty('--fr-si-height', `${height}px`);\n\n if (!this.#isReady) {\n this.#isReady = true;\n this.#scheduleReady(container);\n }\n };\n\n /**\n * Everything the container modifier's destructor undoes. The target is not\n * reset here: it belongs to `setupTarget`, whose own destructor clears it.\n */\n #shutDown(): void {\n this.#observer?.disconnect();\n this.#observer = undefined;\n this.#ready.cancel();\n this.#remeasure.cancel();\n this.#resize.cancel();\n this.#container = undefined;\n this.#isReady = false;\n }\n\n #markNotReady(): void {\n this.#ready.cancel();\n this.#isReady = false;\n this.#container?.removeAttribute(READY_ATTRIBUTE);\n }\n\n // The ready flag is set a frame after the first real measurement so the\n // theme can hold transitions off until the indicator is already in place.\n #scheduleReady(container: HTMLElement): void {\n this.#ready.schedule(() => container.setAttribute(READY_ATTRIBUTE, ''));\n }\n\n // Re-measures once the current render has settled, so a target being handed\n // from one element to another is never observed mid-handover.\n #scheduleRemeasure(): void {\n this.#remeasure.schedule(() => {\n // A new target claimed the slot in the meantime and measured itself.\n if (this.#target) {\n return;\n }\n this.#measure();\n }, 'microtask');\n }\n}\n\n/**\n * Creates a selection indicator.\n *\n * Mirrors the shape of `ref` and `toggleState`: the class stays internal and\n * the public surface is this lowercase factory, since this is a utility rather\n * than a component.\n */\nfunction selectionIndicator(): SelectionIndicator {\n return new SelectionIndicator();\n}\n\nexport { selectionIndicator, READY_ATTRIBUTE };\nexport type { SelectionIndicator };\n"],"names":["READY_ATTRIBUTE","SelectionIndicator","deferredWork","setupContainer","modifier","element","ResizeObserver","schedule","observe","claim","release","unobserve","undefined","setupTarget","isSelected","#measure","container","target","width","offsetWidth","height","offsetHeight","style","setProperty","offsetLeft","offsetTop","#shutDown","disconnect","cancel","#markNotReady","removeAttribute","#scheduleReady","setAttribute","#sc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AAE,EAAE,CAAC,CAAC;AACzE,EAAA;;AAEA;AACA;EACA,kBAAkBiC,GAAS;AACzB,IAAA,IAAI,CAAC,UAAU,CAAC1B,QAAQ,CAAC,MAAM;AAC7B;AACA,MAAA,IAAI,IAAI,CAAC,OAAO,EAAE;AAChB,QAAA;AACF,MAAA;AACA,MAAA,IAAI,CAAC,QAAQ,EAAE;IACjB,CAAC,EAAE,WAAW,CAAC;AACjB,EAAA;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS2B,kBAAkBA,GAAuB;EAChD,OAAO,IAAIjC,kBAAkB,EAAE;AACjC;;;;"}
|
|
1
|
+
{"version":3,"file":"selection-indicator.js","sources":["../../src/utils/selection-indicator.ts"],"sourcesContent":["import { modifier } from 'ember-modifier';\nimport { deferredWork } from './deferred-work';\n\nconst READY_ATTRIBUTE = 'data-fr-si-ready';\n\n/**\n * Measures whichever element is currently selected and publishes its geometry\n * on the container as CSS custom properties. It never paints anything: the\n * theme decides whether that geometry becomes a full pill or a bar pinned to\n * one edge, which is what lets one primitive serve a segmented control and\n * tabs alike.\n *\n * Offsets are physical (`offsetLeft` / `offsetTop`), not logical, and that is\n * deliberate. The browser has already laid the items out for the container's\n * direction, so a physical offset fed to `translate` is correct in both LTR\n * and RTL. Reaching for `inset-inline-start` here would flip an already\n * flipped value.\n */\nclass SelectionIndicator {\n #container?: HTMLElement;\n #target?: HTMLElement;\n #observer?: ResizeObserver;\n #ready = deferredWork('@frontile/utils:selection-indicator:ready');\n #remeasure = deferredWork('@frontile/utils:selection-indicator:remeasure');\n #resize = deferredWork('@frontile/utils:selection-indicator:resize');\n #isReady = false;\n\n // Whether a real measurement has ever landed. Only the very first one is\n // forced-layout-sensitive (see `setupContainer`); once it has happened, a\n // click that moves the selection is no longer racing an ancestor's own\n // mount-time transition, so there is no reason to defer those.\n #hasMeasuredOnce = false;\n\n /**\n * Modifier to place on the container element. Observes its size and, once\n * a target is selected, publishes that target's geometry as CSS custom\n * properties on this element.\n */\n setupContainer = modifier((element: HTMLElement) => {\n this.#container = element;\n // Coalesced to one measurement per frame: the container and the target are\n // both observed, and resizing the container usually resizes the target too,\n // so a single layout change delivers two entries. Measuring reads layout\n // and then writes four custom properties, and a window drag fires this\n // continuously.\n this.#observer = new ResizeObserver(() =>\n this.#resize.schedule(() => this.#measure())\n );\n this.#observer.observe(element);\n\n if (this.#target) {\n this.#observer.observe(this.#target);\n }\n\n // Before the first real measurement, this call is happening during the\n // control's own initial mount -- the same render pass that can be\n // mounting an ancestor overlay's enter transition. Forcing layout here\n // lands at an arbitrary point in `ember-css-transitions`' own\n // reflow-then-swap sequence for that transition, which is enough to make\n // the browser skip it entirely. `ResizeObserver.observe()` above already\n // guarantees an initial, asynchronous notification for `element` (and for\n // the target, if already claimed), so leaving it to that -- deferred\n // through `#resize` like any other resize -- gets the same measurement\n // without the synchronous reflow. Once a first measurement has actually\n // landed, later remounts of this same container are no longer racing\n // anything, so measure immediately as before.\n if (this.#hasMeasuredOnce) {\n this.#measure();\n }\n\n return (): void => {\n this.#shutDown();\n };\n });\n\n /**\n * Claims `element` as the measured target. Exposed alongside `setupTarget`\n * so a consumer composing its own modifier -- a navigation bar that also has\n * to write `aria-current` -- can delegate here rather than reimplement the\n * handover rules below.\n *\n * Measures synchronously once a first measurement has already landed --\n * see `setupContainer` -- so a click that moves the selection updates the\n * indicator immediately rather than a frame later.\n */\n claim(element: HTMLElement): void {\n this.#target = element;\n this.#observer?.observe(element);\n if (this.#hasMeasuredOnce) {\n this.#measure();\n }\n }\n\n /**\n * Releases `element` if it is still the target. When selection moves\n * backwards, the incoming item's setup runs before the outgoing item's\n * teardown, and without this guard that teardown would wipe the new\n * target.\n */\n release(element: HTMLElement): void {\n if (this.#target !== element) {\n return;\n }\n this.#observer?.unobserve(element);\n this.#target = undefined;\n\n // Do not re-measure synchronously. When selection moves forwards the\n // order is reversed -- ember-modifier tears down before re-running\n // setup, and Glimmer revalidates in tree order -- so the outgoing\n // teardown lands first and the incoming target is still moments away\n // in this same render. Measuring now would strip the ready attribute,\n // and the theme gates both opacity and the transition on it, so the\n // indicator would blink out and jump to its new position instead of\n // sliding. Defer instead, and only fall through to the not-ready path\n // if nothing has claimed the target by then.\n this.#scheduleRemeasure();\n }\n\n /**\n * Modifier to place on each candidate target element, passing whether it\n * is currently selected as the sole positional argument. Only the\n * currently-selected target's geometry is measured and published.\n */\n setupTarget = modifier((element: HTMLElement, [isSelected]: [boolean]) => {\n if (isSelected) {\n this.claim(element);\n }\n\n return (): void => {\n this.release(element);\n };\n });\n\n /**\n * Recomputes and republishes the current target's geometry. Called\n * automatically on setup, selection change, and container/target resize;\n * exposed for callers that need to force a recomputation.\n */\n #measure = (): void => {\n const container = this.#container;\n if (!container) {\n return;\n }\n\n const target = this.#target;\n if (!target) {\n this.#markNotReady();\n return;\n }\n\n const width = target.offsetWidth;\n const height = target.offsetHeight;\n\n // A control inside a hidden ancestor -- a closed drawer, an inactive tab\n // panel -- measures zero. Publishing that would collapse the indicator and,\n // worse, mark it ready, so the first real measurement once it is shown\n // would animate in from the container origin. Stay un-ready instead; the\n // ResizeObserver fires when it becomes visible.\n if (width === 0 && height === 0) {\n this.#markNotReady();\n return;\n }\n\n container.style.setProperty('--fr-si-x', `${target.offsetLeft}px`);\n container.style.setProperty('--fr-si-y', `${target.offsetTop}px`);\n container.style.setProperty('--fr-si-width', `${width}px`);\n container.style.setProperty('--fr-si-height', `${height}px`);\n\n this.#hasMeasuredOnce = true;\n\n if (!this.#isReady) {\n this.#isReady = true;\n this.#scheduleReady(container);\n }\n };\n\n /**\n * Everything the container modifier's destructor undoes. The target is not\n * reset here: it belongs to `setupTarget`, whose own destructor clears it.\n */\n #shutDown(): void {\n this.#observer?.disconnect();\n this.#observer = undefined;\n this.#ready.cancel();\n this.#remeasure.cancel();\n this.#resize.cancel();\n this.#container = undefined;\n this.#isReady = false;\n }\n\n #markNotReady(): void {\n this.#ready.cancel();\n this.#isReady = false;\n this.#container?.removeAttribute(READY_ATTRIBUTE);\n }\n\n // The ready flag is set a frame after the first real measurement so the\n // theme can hold transitions off until the indicator is already in place.\n #scheduleReady(container: HTMLElement): void {\n this.#ready.schedule(() => container.setAttribute(READY_ATTRIBUTE, ''));\n }\n\n // Re-measures once the current render has settled, so a target being handed\n // from one element to another is never observed mid-handover.\n #scheduleRemeasure(): void {\n this.#remeasure.schedule(() => {\n // A new target claimed the slot in the meantime and measured itself.\n if (this.#target) {\n return;\n }\n this.#measure();\n }, 'microtask');\n }\n}\n\n/**\n * Creates a selection indicator.\n *\n * Mirrors the shape of `ref` and `toggleState`: the class stays internal and\n * the public surface is this lowercase factory, since this is a utility rather\n * than a component.\n */\nfunction selectionIndicator(): SelectionIndicator {\n return new SelectionIndicator();\n}\n\nexport { selectionIndicator, READY_ATTRIBUTE };\nexport type { SelectionIndicator };\n"],"names":["READY_ATTRIBUTE","SelectionIndicator","deferredWork","setupContainer","modifier","element","ResizeObserver","schedule","observe","claim","release","unobserve","undefined","setupTarget","isSelected","#measure","container","target","width","offsetWidth","height","offsetHeight","style","setProperty","offsetLeft","offsetTop","#shutDown","disconnect","cancel","#markNotReady","removeAttribute","#scheduleReady","setAttribute","#scheduleRemeasure","selectionIndicator"],"mappings":";;;AAGA,MAAMA,eAAe,GAAG;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,CAAC;AACvB,EAAA,UAAU;AACV,EAAA,OAAO;AACP,EAAA,SAAS;AACT,EAAA,MAAM,GAAGC,YAAY,CAAC,2CAA2C,CAAC;AAClE,EAAA,UAAU,GAAGA,YAAY,CAAC,+CAA+C,CAAC;AAC1E,EAAA,OAAO,GAAGA,YAAY,CAAC,4CAA4C,CAAC;EACpE,QAAQ,GAAG,KAAK;;AAEhB;AACA;AACA;AACA;EACA,gBAAgB,GAAG,KAAK;;AAExB;AACF;AACA;AACA;AACA;AACEC,EAAAA,cAAc,GAAGC,QAAQ,CAAEC,OAAoB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C,QAAQ,EAAE;IACjB,CAAC,EAAE,WAAW,CAAC;AACjB,EAAA;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS2B,kBAAkBA,GAAuB;EAChD,OAAO,IAAIjC,kBAAkB,EAAE;AACjC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frontile",
|
|
3
|
-
"version": "0.18.0-beta.
|
|
3
|
+
"version": "0.18.0-beta.2",
|
|
4
4
|
"description": "Component Library for Ember Octane apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@embroider/addon-shim": "^1.10.3",
|
|
95
95
|
"@embroider/macros": "^1.20.6",
|
|
96
96
|
"@floating-ui/dom": "^1.0.1",
|
|
97
|
-
"@frontile/theme": "^0.18.0-beta.
|
|
97
|
+
"@frontile/theme": "^0.18.0-beta.2",
|
|
98
98
|
"@glint/template": "^1.8.0",
|
|
99
99
|
"@universal-ember/table": "^4.0.0",
|
|
100
100
|
"date-fns": "^4.4.0",
|
|
@@ -153,5 +153,5 @@
|
|
|
153
153
|
"./services/notifications.js": "./dist/_app_/services/notifications.js"
|
|
154
154
|
}
|
|
155
155
|
},
|
|
156
|
-
"gitHead": "
|
|
156
|
+
"gitHead": "29d155aabf542b6e3434ed7b1ea4a7ff7c28db7d"
|
|
157
157
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manager-CDIZzrQ9.js","sources":["../src/-private/timer.ts","../src/-private/get-config.ts","../src/-private/notification.ts","../src/-private/manager.ts"],"sourcesContent":["/* eslint-disable ember/no-runloop */\nimport { tracked } from '@glimmer/tracking';\nimport { later, cancel } from '@ember/runloop';\nimport type { Timer as EmberTimer } from '@ember/runloop';\nimport { action } from '@ember/object';\n\nexport default class Timer {\n @tracked remaining: number;\n @tracked isRunning = true;\n\n readonly onFinish: () => void;\n private timer?: EmberTimer;\n private start!: number;\n\n constructor(duration: number, onFinish: () => void) {\n this.remaining = duration;\n this.onFinish = onFinish;\n this.setup();\n }\n\n @action clear(): void {\n this.isRunning = false;\n\n if (this.timer) {\n cancel(this.timer);\n }\n }\n\n @action pause(): void {\n // Pausing an already paused timer would subtract the elapsed time twice,\n // eventually driving `remaining` to zero or below.\n if (!this.isRunning) {\n return;\n }\n\n this.clear();\n this.remaining = Math.max(0, this.remaining - (Date.now() - this.start));\n }\n\n @action resume(): void {\n // Already counting down; resuming again would restart the remaining time.\n if (this.isRunning) {\n return;\n }\n\n this.clear();\n this.setup();\n }\n\n private setup(): void {\n this.start = Date.now();\n this.isRunning = true;\n\n this.timer = later(\n this,\n () => {\n this.onFinish();\n this.isRunning = false;\n },\n this.remaining\n );\n }\n}\n","import { get } from '@ember/object';\nimport type { DefaultConfig } from './types';\n\nexport function getConfigOption<T extends keyof DefaultConfig>(\n config: DefaultConfig,\n key: T,\n defaultValue: NonNullable<DefaultConfig[T]>\n): NonNullable<DefaultConfig[T]> {\n const value = get(config, key);\n\n if (value === undefined) {\n return defaultValue;\n }\n\n return value;\n}\n","import { tracked } from '@glimmer/tracking';\nimport { deprecate } from '@ember/debug';\nimport Timer from './timer';\nimport { getConfigOption } from './get-config';\nimport type {\n NotificationOptions,\n NotificationContent,\n NotificationIntent,\n NotificationAppearance,\n NotificationUpdate,\n CustomAction,\n DefaultConfig\n} from './types';\n\n/**\n * Normalise the two content forms into `{ title, description }`.\n */\nfunction toContent(content: string | NotificationContent): NotificationContent {\n return typeof content === 'string' ? { title: content } : content;\n}\n\n/**\n * Emit the shared deprecation notice and remap `error` onto `danger`. Used\n * for both the option-level and config-level `appearance` fallbacks in\n * `resolveIntent`, which must apply the same remap.\n */\nfunction mapAppearance(appearance: NotificationAppearance): NotificationIntent {\n deprecate(\n 'The `appearance` option for notifications is deprecated. Use `intent` instead, and `danger` in place of `error`.',\n false,\n {\n id: 'frontile.notification-appearance',\n until: '0.19.0',\n for: 'frontile',\n since: { available: '0.18.0', enabled: '0.18.0' }\n }\n );\n\n return appearance === 'error' ? 'danger' : appearance;\n}\n\n/**\n * Resolve the notification intent from the current option, the deprecated\n * `appearance` option, and the app config, in that order.\n */\nfunction resolveIntent(\n config: DefaultConfig,\n options: NotificationOptions\n): NotificationIntent {\n if (options.intent) {\n return options.intent;\n }\n\n if (options.appearance) {\n return mapAppearance(options.appearance);\n }\n\n if (config.intent) {\n return config.intent;\n }\n\n if (config.appearance) {\n return mapAppearance(config.appearance);\n }\n\n // `config.intent`/`config.appearance` were already read directly above, so\n // there is no distinct config lookup left to fall back to.\n return 'default';\n}\n\nexport default class Notification<\n TMetadata extends Record<string, unknown> = Record<string, unknown>\n> {\n /**\n * The title of the notification. Named `message` for backwards\n * compatibility with the original single-string API.\n */\n @tracked message: string;\n @tracked description?: string;\n @tracked intent: NotificationIntent;\n @tracked allowClosing: boolean;\n @tracked isLoading: boolean;\n @tracked customActions?: CustomAction[];\n @tracked timer?: Timer;\n @tracked isRemoving = false;\n\n readonly transitionDuration: number;\n readonly duration: number;\n readonly hideIcon: boolean;\n readonly metadata?: TMetadata;\n\n constructor(\n config: DefaultConfig,\n content: string | NotificationContent,\n options: NotificationOptions<TMetadata> = {}\n ) {\n const { title, description } = toContent(content);\n\n this.message = title;\n // An object content form owns the description outright; the option is only\n // a convenience for the string form.\n this.description =\n typeof content === 'string' ? options.description : description;\n this.intent = resolveIntent(config, options);\n this.isLoading = options.isLoading === true;\n this.hideIcon = options.hideIcon === true;\n this.customActions = options.customActions;\n this.duration =\n options.duration || getConfigOption(config, 'duration', 5000);\n this.transitionDuration =\n typeof options.transitionDuration !== 'undefined'\n ? options.transitionDuration\n : getConfigOption(config, 'transitionDuration', 200);\n this.metadata = options.metadata;\n this.allowClosing = options.allowClosing !== false;\n }\n\n /** Read-only alias of `message` — do not add a setter. */\n get title(): string {\n return this.message;\n }\n\n /**\n * @deprecated Read `intent` instead.\n *\n * The return type is widened to include `'default'` because `default` is\n * new vocabulary introduced alongside this getter's deprecation — it has\n * no equivalent in the old `NotificationAppearance` names, so mapping it\n * onto `'info'` here would silently lie about the notification's intent.\n * Everything else keeps the old four-value shape.\n */\n get appearance(): 'default' | 'info' | 'success' | 'warning' | 'error' {\n return this.intent === 'danger' ? 'error' : this.intent;\n }\n\n /**\n * Mutate the notification in place. Used by `promise()` so a settling\n * promise swaps the content of the toast already on screen rather than\n * replacing it with a new one.\n */\n update(changes: NotificationUpdate): void {\n if (typeof changes.title !== 'undefined') {\n this.message = changes.title;\n }\n\n if (typeof changes.description !== 'undefined') {\n this.description = changes.description;\n }\n\n if (typeof changes.intent !== 'undefined') {\n this.intent = changes.intent;\n }\n\n if (typeof changes.allowClosing !== 'undefined') {\n this.allowClosing = changes.allowClosing;\n }\n\n if (typeof changes.isLoading !== 'undefined') {\n this.isLoading = changes.isLoading;\n }\n }\n\n remove(): void {\n this.isRemoving = true;\n\n if (this.timer) {\n this.timer.clear();\n }\n }\n}\n","/* eslint-disable ember/no-runloop */\nimport Notification from './notification';\nimport Timer from './timer';\nimport { tracked } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { getConfigOption } from './get-config';\nimport { getOwner } from '@ember/owner';\nimport { isDestroyed } from '@ember/destroyable';\nimport { later } from '@ember/runloop';\nimport type Owner from '@ember/owner';\nimport type {\n DefaultConfig,\n NotificationOptions,\n NotificationContent,\n NotificationIntent,\n PromiseMessage,\n PromiseNotificationOptions\n} from './types';\n\nfunction resolveMessage<T>(\n message: PromiseMessage<T>,\n value: T\n): NotificationContent {\n const resolved = typeof message === 'function' ? message(value) : message;\n return typeof resolved === 'string' ? { title: resolved } : resolved;\n}\n\n/**\n * Whether a notification should get an auto-removal timer, given its own\n * `preserve` option and the manager's config. An explicit `preserve` wins;\n * otherwise the config's `preserve` default applies. Either way, a\n * config-level `skipTimer: true` forces preservation — there's no timer to\n * skip if the notification is never auto-removed in the first place.\n *\n * Shared by `add()` and `promise()`'s settle path, which must apply this\n * decision identically.\n */\nfunction shouldAutoRemove(\n config: DefaultConfig,\n preserveOption: boolean | undefined\n): boolean {\n const preserve =\n typeof preserveOption === 'undefined'\n ? getConfigOption(config, 'preserve', false)\n : preserveOption;\n\n if (getConfigOption(config, 'skipTimer', false) === true) {\n return false;\n }\n\n return preserve === false;\n}\n\nexport default class NotificationsManager {\n @tracked notifications: Notification<Record<string, unknown>>[] = [];\n\n config: DefaultConfig = {};\n onRemove?: (notification: Notification<Record<string, unknown>>) => void;\n\n constructor(\n context: object,\n onRemove?: (notification: Notification<Record<string, unknown>>) => void\n ) {\n if (isDestroyed(context)) {\n return;\n }\n const owner = getOwner(context) as Owner;\n assert('NotificationsManager context must have an owner', owner);\n const configFactory = owner.factoryFor('config:environment');\n\n if (configFactory && configFactory.class) {\n this.config =\n (configFactory.class as never)['@frontile/notifications'] || {};\n }\n\n this.onRemove = onRemove;\n }\n\n add<TMetadata extends Record<string, unknown> = Record<string, unknown>>(\n content: string | NotificationContent,\n options: NotificationOptions<TMetadata> = {}\n ): Notification<TMetadata> {\n const notification = new Notification<TMetadata>(\n this.config,\n content,\n options\n );\n this.notifications = [...this.notifications, notification];\n\n if (shouldAutoRemove(this.config, options.preserve)) {\n this.setupAutoRemoval(notification, notification.duration);\n }\n return notification;\n }\n\n /**\n * Show a notification driven by a promise: a spinner while pending, then\n * the same notification mutated in place once it settles.\n *\n * Returns the original promise, so callers can still await it — and are\n * still responsible for handling its rejection.\n */\n promise<\n T,\n TMetadata extends Record<string, unknown> = Record<string, unknown>\n >(\n promise: Promise<T>,\n options: PromiseNotificationOptions<T, TMetadata>\n ): Promise<T> {\n const { loading, success, error, ...rest } = options;\n\n const notification = this.add<TMetadata>(loading, {\n ...(rest as NotificationOptions<TMetadata>),\n preserve: true,\n allowClosing: false,\n isLoading: true\n });\n\n const settle = (\n content: NotificationContent,\n intent: NotificationIntent\n ) => {\n // The user may have dismissed the toast before the promise settled; in\n // that case there is nothing left to update.\n if (notification.isRemoving) {\n return;\n }\n\n notification.update({\n ...content,\n // `update()` treats an absent key as \"leave this field alone\" (that\n // distinction is load-bearing elsewhere), so a settle message with\n // no description must still pass an explicit empty string here —\n // otherwise `resolveMessage`'s string-form `{ title }` (no\n // `description` key at all) would leave the loading phase's stale\n // description on screen instead of clearing it.\n description: content.description ?? '',\n intent,\n allowClosing: true,\n isLoading: false\n });\n\n // `preserve: true` forces the loading phase to skip auto-dismissal\n // (there's nothing useful to time out on a spinner), but the docs\n // promise every option except `isLoading` carries through to the\n // settled notification — so a caller's own `preserve` must still be\n // honored here, not silently overridden by the loading phase's.\n if (shouldAutoRemove(this.config, rest.preserve)) {\n this.setupAutoRemoval(notification, notification.duration);\n }\n };\n\n promise.then(\n (value) => settle(resolveMessage(success, value), 'success'),\n (reason) => settle(resolveMessage(error, reason), 'danger')\n );\n\n return promise;\n }\n\n remove(notification?: Notification<Record<string, unknown>>): void {\n // Removal is single-shot: a notification already on its way out must not\n // schedule a second removal, otherwise `onRemove` is called twice for it.\n if (!notification || notification.isRemoving) {\n return;\n }\n\n notification.remove();\n\n // The unmount is timed to `transitionDuration` (default 200ms), which\n // governs the card's exit *opacity* fade. The exit *slide/scale*\n // transform, however, runs at a fixed 400ms (see notificationCard's\n // theme slots) independent of `transitionDuration`. At the defaults this\n // is invisible only because the opacity reaches 0 at the same moment the\n // card unmounts, hiding the fact that the slide is truncated mid-flight.\n // If the opacity duration is ever decoupled from this unmount timer (or\n // `transitionDuration` is changed without also revisiting the transform\n // duration), cards will visibly disappear mid-slide instead of fading\n // out cleanly. Keep the two in sync, or make the unmount wait for the\n // longer of the two durations.\n later(\n this,\n () => {\n this.notifications = this.notifications.filter((n) => {\n return n !== notification;\n });\n\n // Call the onRemove callback after the notification is actually removed\n if (this.onRemove) {\n this.onRemove(notification);\n }\n },\n notification.transitionDuration\n );\n }\n\n removeAll(): void {\n this.notifications.forEach((notification) => {\n this.remove(notification);\n });\n }\n\n private setupAutoRemoval(\n notification: Notification<Record<string, unknown>>,\n duration: number\n ): void {\n notification.timer = new Timer(duration, () => {\n this.remove(notification);\n });\n }\n}\n"],"names":["Timer","g","prototype","tracked","i","onFinish","timer","start","constructor","duration","remaining","setup","clear","isRunning","cancel","n","action","pause","Math","max","Date","now","resume","later","getConfigOption","config","key","defaultValue","value","get","undefined","toContent","content","title","mapAppearance","appearance","deprecate","id","until","for","since","available","enabled","resolveIntent","options","intent","Notification","transitionDuration","hideIcon","metadata","description","message","isLoading","customActions","allowClosing","update","changes","remove","isRemoving","resolveMessage","resolved","shouldAutoRemove","preserveOption","preserve","NotificationsManager","onRemove","context","isDestroyed","owner","getOwner","assert","configFactory","factoryFor","class","add","notification","notifications","setupAutoRemoval","promise","loading","success","error","rest","settle","then","reason","filter","removeAll","forEach"],"mappings":";;;;;;;;AAAA;AAMe,MAAMA,KAAK,CAAC;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,WAAA,EAAA,CACxBC,OAAO,CAAA,CAAA;AAAA;EAAA,UAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,WAAA,CAAA,EAAA,MAAA;AAAA,EAAA;IAAAH,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,WAAA,EAAA,CACPC,OAAO,CAAA,EAAA,YAAA;AAAA,MAAA,OAAa,IAAI;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,UAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,WAAA,CAAA,EAAA,MAAA;EAEhBC,QAAQ;EACTC,KAAK;EACLC,KAAK;AAEbC,EAAAA,WAAWA,CAACC,QAAgB,EAAEJ,QAAoB,EAAE;IAClD,IAAI,CAACK,SAAS,GAAGD,QAAQ;IACzB,IAAI,CAACJ,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACM,KAAK,EAAE;AACd,EAAA;AAEQC,EAAAA,KAAKA,GAAS;IACpB,IAAI,CAACC,SAAS,GAAG,KAAK;IAEtB,IAAI,IAAI,CAACP,KAAK,EAAE;AACdQ,MAAAA,MAAM,CAAC,I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EAwC,EAAAA,SAASA,GAAS;AAChB,IAAA,IAAI,CAACX,aAAa,CAACY,OAAO,CAAEb,YAAY,IAAK;AAC3C,MAAA,IAAI,CAAClB,MAAM,CAACkB,YAAY,CAAC;AAC3B,IAAA,CAAC,CAAC;AACJ,EAAA;AAEQE,EAAAA,gBAAgBA,CACtBF,YAAmD,EACnDlE,QAAgB,EACV;IACNkE,YAAY,CAACrE,KAAK,GAAG,IAAIN,KAAK,CAACS,QAAQ,EAAE,MAAM;AAC7C,MAAA,IAAI,CAACgD,MAAM,CAACkB,YAAY,CAAC;AAC3B,IAAA,CAAC,CAAC;AACJ,EAAA;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notification-card-D5fd-Sxa.js","sources":["../src/-private/notification-stack.ts","../src/components/notifications/notification-card.gts"],"sourcesContent":["import type { containerPlacement } from './types';\n\n/**\n * How much each card behind the front of the stack shrinks, as a fraction.\n */\nconst SCALE_STEP = 0.05;\n\n/**\n * Cards are pinned to the placement edge, so a top placement stacks\n * downwards and a bottom placement stacks upwards. Exported so\n * notification-card.gts's own enter/exit slide direction can share this\n * instead of re-deriving it from the placement string.\n */\nfunction isTopPlacement(placement: containerPlacement): boolean {\n return placement.startsWith('top');\n}\n\ninterface NotificationStackInput {\n /**\n * Measured card heights in px, ordered front-first (index 0 is the newest\n * notification). A card that has not been measured yet contributes 0.\n */\n heights: number[];\n\n isExpanded: boolean;\n\n /**\n * Peek offset between collapsed cards, and the gap between expanded cards.\n */\n gap: number;\n\n /**\n * How many cards stay visible while collapsed.\n */\n visibleToasts: number;\n\n placement: containerPlacement;\n}\n\ninterface CardGeometry {\n transform: string;\n zIndex: number;\n opacity: number;\n\n /**\n * Fixed height in px while collapsed, so a taller card behind the front one\n * cannot stick out past it. `null` means the card sizes to its content.\n */\n height: number | null;\n\n transformOrigin: 'top center' | 'bottom center';\n\n /**\n * `'none'` when the card is fully transparent (collapsed beyond\n * `visibleToasts`), so it cannot swallow clicks meant for the page beneath\n * it; `'auto'` otherwise.\n */\n pointerEvents: 'auto' | 'none';\n}\n\n/**\n * Pure geometry for the notification stack: given measured card heights and\n * the current expansion state, it produces the transform for each card and\n * the height the container should animate to.\n *\n * Deliberately free of Ember and DOM dependencies so the layout maths can be\n * tested on its own.\n */\nclass NotificationStack {\n readonly heights: number[];\n readonly isExpanded: boolean;\n readonly gap: number;\n readonly visibleToasts: number;\n readonly placement: containerPlacement;\n\n constructor(input: NotificationStackInput) {\n this.heights = input.heights;\n this.isExpanded = input.isExpanded;\n this.gap = input.gap;\n this.visibleToasts = input.visibleToasts;\n this.placement = input.placement;\n }\n\n get isTopPlacement(): boolean {\n return isTopPlacement(this.placement);\n }\n\n /**\n * Cards are pinned to the placement edge, so a top placement stacks\n * downwards and a bottom placement stacks upwards.\n */\n get directionSign(): number {\n return this.isTopPlacement ? 1 : -1;\n }\n\n get transformOrigin(): CardGeometry['transformOrigin'] {\n return this.isTopPlacement ? 'top center' : 'bottom center';\n }\n\n get count(): number {\n return this.heights.length;\n }\n\n get frontHeight(): number {\n return this.heights[0] ?? 0;\n }\n\n geometryFor(index: number): CardGeometry {\n const zIndex = this.count - index;\n\n if (this.isExpanded) {\n return {\n transform: `translateY(${this.directionSign * this.offsetBefore(index)}px) scale(1)`,\n zIndex,\n opacity: 1,\n height: null,\n transformOrigin: this.transformOrigin,\n pointerEvents: 'auto'\n };\n }\n\n const offset = index * this.gap;\n const scale = Math.max(0, 1 - index * SCALE_STEP);\n const isVisible = index < this.visibleToasts;\n\n return {\n transform: `translateY(${this.directionSign * offset}px) scale(${scale})`,\n zIndex,\n opacity: isVisible ? 1 : 0,\n // The front card must size to its own content (`null`). Clamping it to\n // `frontHeight` would be self-referential — `frontHeight` *is* the\n // front card's own measurement — and would permanently lock in\n // whatever height was measured first, before content (e.g. a long\n // description) finished laying out. Only cards behind the front one\n // need clamping, so a taller card further back can't poke out past it.\n height: index === 0 ? null : this.frontHeight,\n transformOrigin: this.transformOrigin,\n // A card past `visibleToasts` is fully transparent while collapsed;\n // without this it would still sit in the fixed-position stack and\n // swallow clicks meant for the page beneath it.\n pointerEvents: isVisible ? 'auto' : 'none'\n };\n }\n\n get containerHeight(): number {\n if (this.count === 0) {\n return 0;\n }\n\n if (this.isExpanded) {\n return this.offsetBefore(this.count) - this.gap;\n }\n\n const visible = Math.min(this.count, this.visibleToasts);\n return this.frontHeight + (visible - 1) * this.gap;\n }\n\n /**\n * Distance from the placement edge to the leading edge of `index`, i.e. the\n * summed heights and gaps of every card in front of it.\n */\n private offsetBefore(index: number): number {\n let offset = 0;\n\n for (let i = 0; i < index; i++) {\n offset += (this.heights[i] ?? 0) + this.gap;\n }\n\n return offset;\n }\n}\n\nexport { NotificationStack, isTopPlacement };\nexport type { NotificationStackInput, CardGeometry };\n","import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { modifier } from 'ember-modifier';\nimport { service } from '@ember/service';\nimport { htmlSafe } from '@ember/template';\nimport { fn } from '@ember/helper';\nimport { CloseButton } from '../buttons/close-button';\nimport { Button } from '../buttons/button';\nimport { Spinner } from '../utilities/spinner';\nimport {\n IconInfo,\n IconSuccess,\n IconWarning,\n IconDanger\n} from '../../-private/intent-icons';\nimport { useStyles } from '@frontile/theme';\n\nimport type NotificationsService from '../../services/notifications';\nimport type Notification from '../../-private/notification';\nimport { isTopPlacement } from '../../-private/notification-stack';\nimport type { CardGeometry } from '../../-private/notification-stack';\nimport type {\n CustomAction,\n containerPlacement,\n NotificationIntent\n} from '../../-private/types';\nimport type { SafeString } from '@ember/template';\n\n/**\n * Everything that varies by `NotificationIntent`, keyed in one place so\n * adding an intent means adding one row here instead of remembering to\n * touch an icon map, an action-intent map, and the `role` getter's cascade\n * separately.\n */\nconst INTENT_CONFIG = {\n default: {\n icon: IconInfo,\n // Button intent for the primary custom action. Also reused as the\n // loading <Spinner>'s `@intent` (its `intent` union has the same\n // default/primary/success/warning/danger shape), so the spinner's arc\n // matches the same accent the card's custom action button would use.\n actionIntent: 'default',\n // `alert` interrupts a screen reader, so it is reserved for the\n // intents that warrant interrupting.\n role: 'status'\n },\n info: {\n icon: IconInfo,\n actionIntent: 'primary',\n role: 'status'\n },\n success: {\n icon: IconSuccess,\n actionIntent: 'success',\n role: 'status'\n },\n warning: {\n icon: IconWarning,\n actionIntent: 'warning',\n role: 'alert'\n },\n danger: {\n icon: IconDanger,\n actionIntent: 'danger',\n role: 'alert'\n }\n} as const satisfies Record<\n NotificationIntent,\n {\n icon: unknown;\n actionIntent: 'default' | 'primary' | 'success' | 'warning' | 'danger';\n role: 'status' | 'alert';\n }\n>;\n\ninterface NotificationCardSignature {\n Args: {\n notification: Notification<Record<string, unknown>>;\n placement: containerPlacement;\n\n /**\n * The visual style of the card.\n *\n * @defaultValue 'default'\n */\n variant?: 'default' | 'tonal' | 'solid';\n\n /**\n * Position, scale, and stacking supplied by the container. When omitted\n * the card renders in place with no stack transform.\n *\n * Part of the container/card plumbing, not a consumer-facing argument.\n *\n * @internal\n */\n geometry?: CardGeometry;\n\n /**\n * Called with the card's measured height whenever it changes.\n *\n * Part of the container/card plumbing, not a consumer-facing argument.\n *\n * @internal\n */\n onMeasure?: (height: number) => void;\n };\n Element: HTMLDivElement;\n}\n\nclass NotificationCard extends Component<NotificationCardSignature> {\n @service notifications!: NotificationsService;\n\n /**\n * False for the first frame so the card can transition in from the\n * placement edge rather than appearing at its resting position.\n */\n @tracked hasEntered = false;\n\n get isTopPlacement(): boolean {\n return isTopPlacement(this.args.placement || 'bottom-right');\n }\n\n get intent(): NotificationIntent {\n return this.args.notification.intent;\n }\n\n get icon() {\n return INTENT_CONFIG[this.intent].icon;\n }\n\n get actionIntent() {\n return INTENT_CONFIG[this.intent].actionIntent;\n }\n\n get role(): 'status' | 'alert' {\n return INTENT_CONFIG[this.intent].role;\n }\n\n get style(): SafeString {\n const { geometry, notification } = this.args;\n // The theme owns the whole `transition-duration` shorthand (and its\n // `motion-reduce:` override) so the per-property duration order can\n // never drift out of sync with `transition-[transform,opacity,height]`\n // across the component boundary — see notification-card.ts. This card\n // only supplies the one value `@transitionDuration` actually governs\n // (the enter/exit fade), as a custom property the theme's `var()` reads.\n const declarations = [\n `--frontile-toast-fade: ${notification.transitionDuration}ms`\n ];\n\n // The static edge-pinning (`position: absolute` + `left/right/top` or\n // `bottom`) lives in the `stackPlacement` theme variant (see\n // `this.classes`) rather than here, since it never varies frame to\n // frame — only the geometry-driven parts below (transform, opacity,\n // height, z-index, transform-origin) need to be inline, because a\n // `style` attribute passed through `...attributes` replaces the\n // element's own `style` outright and would drop them.\n\n if (!this.hasEntered || notification.isRemoving) {\n // Enter from, and exit to, the placement edge.\n const offset = this.isTopPlacement ? '-100%' : '100%';\n declarations.push(\n `opacity: 0`,\n `transform: translateY(${offset}) scale(0.95)`,\n // A card can be transparent-and-collapsed the instant it starts\n // exiting; keep it out of the click path either way.\n `pointer-events: none`\n );\n\n if (geometry) {\n declarations.push(\n `z-index: ${geometry.zIndex}`,\n `transform-origin: ${geometry.transformOrigin}`,\n // Preserve the collapsed height clamp through the exit\n // transition — otherwise a non-front collapsed card snaps from\n // its clamped height to `auto` for the slide-out.\n geometry.height === null\n ? `height: auto`\n : `height: ${geometry.height}px`\n );\n }\n\n return htmlSafe(declarations.join('; '));\n }\n\n if (geometry) {\n declarations.push(\n `transform: ${geometry.transform}`,\n `transform-origin: ${geometry.transformOrigin}`,\n `z-index: ${geometry.zIndex}`,\n `opacity: ${geometry.opacity}`,\n `pointer-events: ${geometry.pointerEvents}`,\n geometry.height === null\n ? `height: auto`\n : `height: ${geometry.height}px`\n );\n }\n\n return htmlSafe(declarations.join('; '));\n }\n\n /**\n * Flip to the resting position on the frame after insertion, so the browser\n * has a start value to transition from.\n */\n enter = modifier(() => {\n const frame = requestAnimationFrame(() => {\n this.hasEntered = true;\n });\n\n return () => cancelAnimationFrame(frame);\n });\n\n /**\n * Report the card's height to the container so the stack can lay itself\n * out. Also fires when promise content swaps change the height.\n *\n * `element` is the inner element (never height-constrained, so its\n * `offsetHeight` is always the content's true natural height). The border\n * lives on the outer element (`element.parentElement`), so it isn't part\n * of that number — we add it back via `outer.offsetHeight -\n * outer.clientHeight`, the outer element's vertical border width. That\n * difference is constant whether or not the outer element's height is\n * currently clamped by the collapsed-stack height, so it's safe to read\n * off the outer element even while it's clamped, and it stays correct if\n * the theme's border width ever changes.\n */\n measure = modifier((element: HTMLElement) => {\n const { onMeasure } = this.args;\n\n if (!onMeasure) {\n return;\n }\n\n const outer = element.parentElement as HTMLElement;\n\n const report = () => {\n const outerBorder = outer.offsetHeight - outer.clientHeight;\n onMeasure(element.offsetHeight + outerBorder);\n };\n\n const observer = new ResizeObserver(report);\n\n report();\n observer.observe(element);\n\n return () => observer.disconnect();\n });\n\n remove = () => {\n this.notifications.remove(this.args.notification);\n };\n\n handleClickCustomAction = (customAction: CustomAction) => {\n customAction.onClick();\n this.notifications.remove(this.args.notification);\n };\n\n get classes() {\n const { notificationCard } = useStyles();\n\n const {\n base,\n inner,\n icon,\n spinner,\n content,\n title,\n description,\n customActions,\n customActionButton,\n closeButton\n } = notificationCard({\n intent: this.intent,\n variant: this.args.variant || 'default',\n hasDescription: !!this.args.notification.description,\n // Only pin the card to the placement edge once the container has\n // supplied stack geometry — see the `stackPlacement` variant's\n // comment in the theme.\n stackPlacement: this.args.geometry\n ? this.isTopPlacement\n ? 'top'\n : 'bottom'\n : 'none'\n });\n\n return {\n base: base(),\n inner: inner(),\n icon: icon(),\n spinner: spinner(),\n content: content(),\n title: title(),\n description: description(),\n customActions: customActions(),\n customActionButton: customActionButton(),\n closeButton: closeButton()\n };\n }\n\n <template>\n {{! template-lint-disable no-inline-styles style-concatenation }}\n <div\n class={{this.classes.base}}\n style={{this.style}}\n role={{this.role}}\n data-test-notification-card\n data-test-intent={{this.intent}}\n {{this.enter}}\n ...attributes\n >\n {{! measure reads offsetHeight off this inner element, not the outer one above, since the outer carries the collapsed-stack height clamp. See notification-stack.ts. }}\n <div class={{this.classes.inner}} {{this.measure}}>\n {{#unless @notification.hideIcon}}\n {{#if @notification.isLoading}}\n <Spinner\n @class={{this.classes.spinner}}\n @intent={{this.actionIntent}}\n @size=\"sm\"\n data-test-icon=\"loading\"\n />\n {{else}}\n {{#let this.icon as |Icon|}}\n <Icon class={{this.classes.icon}} />\n {{/let}}\n {{/if}}\n {{/unless}}\n\n <div class={{this.classes.content}}>\n <div class={{this.classes.title}}>{{@notification.title}}</div>\n\n {{#if @notification.description}}\n <div class={{this.classes.description}}>\n {{@notification.description}}\n </div>\n {{/if}}\n </div>\n\n {{#if @notification.customActions}}\n <div class={{this.classes.customActions}}>\n {{#each @notification.customActions as |customAction index|}}\n <Button\n @size=\"xs\"\n @intent={{if index \"default\" this.actionIntent}}\n @appearance={{if index \"minimal\" \"default\"}}\n @class={{this.classes.customActionButton}}\n @onPress={{fn this.handleClickCustomAction customAction}}\n >\n {{customAction.label}}\n </Button>\n {{/each}}\n </div>\n {{/if}}\n\n {{#if @notification.allowClosing}}\n <CloseButton\n @onPress={{this.remove}}\n @size=\"sm\"\n @class={{this.classes.closeButton}}\n />\n {{/if}}\n </div>\n </div>\n </template>\n}\n\nexport { NotificationCard, type NotificationCardSignature };\nexport default NotificationCard;\n"],"names":["SCALE_STEP","isTopPlacement","placement","startsWith","NotificationStack","heights","isExpanded","gap","visibleToasts","constructor","input","directionSign","transformOrigin","count","length","frontHeight","geometryFor","index","zIndex","transform","offsetBefore","opacity","height","pointerEvents","offset","scale","Math","max","isVisible","containerHeight","visible","min","i","INTENT_CONFIG","default","icon","IconInfo","actionIntent","role","info","success","IconSuccess","warning","IconWarning","danger","IconDanger","NotificationCard","Component","g","prototype","service","tracked","args","intent","notification","style","geometry","declarations","transitionDuration","hasEntered","isRemoving","push","htmlSafe","join","enter","modifier","frame","requestAnimationFrame","cancelAnimationFrame","measure","element","onMeasure","outer","parentElement","report","outerBorder","offsetHeight","clientHeight","observer","ResizeObserver","observe","disconnect","remove","notifications","handleClickCustomAction","customAction","onClick","classes","notificationCard","useStyles","base","inner","spinner","content","title","description","customActions","customActionButton","closeButton","variant","hasDescription","stackPlacement","setComponentTemplate","precompileTemplate","strictMode","scope","Spinner","Button","fn","CloseButton"],"mappings":";;;;;;;;;;;;;;;AAEA;AACA;AACA;AACA,MAAMA,UAAU,GAAG,IAAI;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAACC,SAA6B,EAAW;AAC9D,EAAA,OAAOA,SAAS,CAACC,UAAU,CAAC,KAAK,CAAC;AACpC;AA6CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,CAAC;EACbC,OAAO;EACPC,UAAU;EACVC,GAAG;EACHC,aAAa;EACbN,SAAS;EAElBO,WAAWA,CAACC,KAA6B,EAAE;AACzC,IAAA,IAAI,CAACL,OAAO,GAAGK,KAAK,CAACL,OAAO;AAC5B,IAAA,IAAI,CAACC,UAAU,GAAGI,KAAK,CAACJ,UAAU;AAClC,IAAA,IAAI,CAACC,GAAG,GAAGG,KAAK,CAACH,GAAG;AACpB,IAAA,IAAI,CAACC,aAAa,GAAGE,KAAK,CAACF,aAAa;AACxC,IAAA,IAAI,CAACN,SAAS,GAAGQ,KAAK,CAACR,SAAS;AAClC,EAAA;EAEA,IAAID,cAAcA,GAAY;AAC5B,IAAA,OAAOA,cAAc,CAAC,IAAI,CAACC,SAAS,CAAC;AACvC,EAAA;;AAEA;AACF;AACA;AACA;EACE,IAAIS,aAAaA,GAAW;AAC1B,IAAA,OAAO,IAAI,CAACV,cAAc,GAAG,CAAC,GAAG,EAAE;AACrC,EAAA;EAEA,IAAIW,eAAeA,GAAoC;AACrD,IAAA,OAAO,IAAI,CAACX,cAAc,GAAG,YAAY,GAAG,eAAe;AAC7D,EAAA;EAEA,IAAIY,KAAKA,GAAW;AAClB,IAAA,OAAO,IAAI,CAACR,OAAO,CAACS,MAAM;AAC5B,EAAA;EAEA,IAAIC,WAAWA,GAAW;AACxB,IAAA,OAAO,IAAI,CAACV,OAA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