frontile 0.18.6 → 0.18.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/-private/icons.d.ts +4 -0
- package/declarations/-private/icons.d.ts.map +1 -1
- package/declarations/components/buttons/chip.d.ts +2 -3
- package/declarations/components/buttons/chip.d.ts.map +1 -1
- package/declarations/components/collections/dropdown/dropdown.d.ts +50 -53
- package/declarations/components/collections/dropdown/dropdown.d.ts.map +1 -1
- package/declarations/components/collections/listbox/item.d.ts +52 -1
- package/declarations/components/collections/listbox/item.d.ts.map +1 -1
- package/declarations/components/forms/form.d.ts +3 -2
- package/declarations/components/forms/form.d.ts.map +1 -1
- package/declarations/components/forms/native-select.d.ts.map +1 -1
- package/declarations/components/forms/select/select.d.ts +17 -0
- package/declarations/components/forms/select/select.d.ts.map +1 -1
- package/declarations/components/forms/select/trigger.d.ts +8 -0
- package/declarations/components/forms/select/trigger.d.ts.map +1 -1
- package/declarations/components/forms/select/types.d.ts +8 -4
- package/declarations/components/forms/select/types.d.ts.map +1 -1
- package/declarations/components/layout/app-layout-state.d.ts +32 -0
- package/declarations/components/layout/app-layout-state.d.ts.map +1 -0
- package/declarations/components/layout/app-layout.d.ts +1298 -0
- package/declarations/components/layout/app-layout.d.ts.map +1 -0
- package/declarations/components/layout/aside-toggle.d.ts +55 -0
- package/declarations/components/layout/aside-toggle.d.ts.map +1 -0
- package/declarations/components/layout/aside.d.ts +1055 -0
- package/declarations/components/layout/aside.d.ts.map +1 -0
- package/declarations/components/layout/bottom-nav-more.d.ts +123 -0
- package/declarations/components/layout/bottom-nav-more.d.ts.map +1 -0
- package/declarations/components/layout/bottom-nav.d.ts +60 -0
- package/declarations/components/layout/bottom-nav.d.ts.map +1 -0
- package/declarations/components/layout/context.d.ts +143 -0
- package/declarations/components/layout/context.d.ts.map +1 -0
- package/declarations/components/layout/index.d.ts +14 -0
- package/declarations/components/layout/index.d.ts.map +1 -0
- package/declarations/components/layout/main.d.ts +28 -0
- package/declarations/components/layout/main.d.ts.map +1 -0
- package/declarations/components/layout/menu-toggle.d.ts +58 -0
- package/declarations/components/layout/menu-toggle.d.ts.map +1 -0
- package/declarations/components/layout/nav-context.d.ts +45 -0
- package/declarations/components/layout/nav-context.d.ts.map +1 -0
- package/declarations/components/layout/nav-folder.d.ts +216 -0
- package/declarations/components/layout/nav-folder.d.ts.map +1 -0
- package/declarations/components/layout/nav-item.d.ts +220 -0
- package/declarations/components/layout/nav-item.d.ts.map +1 -0
- package/declarations/components/layout/nav-link.d.ts +67 -0
- package/declarations/components/layout/nav-link.d.ts.map +1 -0
- package/declarations/components/layout/navbar.d.ts +1028 -0
- package/declarations/components/layout/navbar.d.ts.map +1 -0
- package/declarations/components/layout/page-header.d.ts +40 -0
- package/declarations/components/layout/page-header.d.ts.map +1 -0
- package/declarations/components/layout/sidebar-group.d.ts +41 -0
- package/declarations/components/layout/sidebar-group.d.ts.map +1 -0
- package/declarations/components/layout/sidebar-toggle.d.ts +71 -0
- package/declarations/components/layout/sidebar-toggle.d.ts.map +1 -0
- package/declarations/components/layout/sidebar.d.ts +1215 -0
- package/declarations/components/layout/sidebar.d.ts.map +1 -0
- package/declarations/components/navigation/index.d.ts +1 -0
- package/declarations/components/navigation/index.d.ts.map +1 -1
- package/declarations/components/navigation/stepper/collapse-menu.d.ts +42 -0
- package/declarations/components/navigation/stepper/collapse-menu.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/list.d.ts +24 -0
- package/declarations/components/navigation/stepper/list.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/panel.d.ts +42 -0
- package/declarations/components/navigation/stepper/panel.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/step.d.ts +123 -0
- package/declarations/components/navigation/stepper/step.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/stepper.d.ts +947 -0
- package/declarations/components/navigation/stepper/stepper.d.ts.map +1 -0
- package/declarations/components/navigation/stepper.d.ts +6 -0
- package/declarations/components/navigation/stepper.d.ts.map +1 -0
- package/declarations/components/navigation/tab-nav/item.d.ts +2 -2
- package/declarations/components/navigation/tab-nav/item.d.ts.map +1 -1
- package/declarations/components/overlays/portal.d.ts.map +1 -1
- package/declarations/components/status/badge.d.ts +83 -0
- package/declarations/components/status/badge.d.ts.map +1 -0
- package/declarations/components/status/index.d.ts +1 -0
- package/declarations/components/status/index.d.ts.map +1 -1
- package/declarations/components/utilities/collapsible.d.ts +19 -2
- package/declarations/components/utilities/collapsible.d.ts.map +1 -1
- package/declarations/index.d.ts +1 -0
- package/declarations/index.d.ts.map +1 -1
- package/declarations/layout.d.ts +2 -0
- package/declarations/layout.d.ts.map +1 -0
- package/declarations/utils/breakpoint.d.ts +16 -0
- package/declarations/utils/breakpoint.d.ts.map +1 -0
- package/declarations/utils/document-listener.d.ts +6 -0
- package/declarations/utils/document-listener.d.ts.map +1 -0
- package/declarations/utils/listManager.d.ts +7 -1
- package/declarations/utils/listManager.d.ts.map +1 -1
- package/declarations/utils/route-active.d.ts +34 -0
- package/declarations/utils/route-active.d.ts.map +1 -0
- package/declarations/utils/selection-indicator.d.ts +7 -4
- package/declarations/utils/selection-indicator.d.ts.map +1 -1
- package/dist/components/buttons/chip.js +12 -1
- package/dist/components/buttons/chip.js.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/dropdown/dropdown.js +172 -48
- package/dist/components/collections/dropdown/dropdown.js.map +1 -1
- package/dist/components/collections/listbox/item.js +36 -2
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +1 -1
- package/dist/components/collections/table/sort-button.js +1 -1
- package/dist/components/disclosure/accordion/item.js +1 -1
- package/dist/components/forms/autocomplete.js +1 -1
- package/dist/components/forms/date-picker/end-content.js +1 -1
- package/dist/components/forms/form.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/select/end-content.js +1 -1
- package/dist/components/forms/select/select.js +3 -2
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/components/forms/select/trigger.js +1 -1
- package/dist/components/forms/select/trigger.js.map +1 -1
- package/dist/components/layout/app-layout-state.js +64 -0
- package/dist/components/layout/app-layout-state.js.map +1 -0
- package/dist/components/layout/app-layout.js +441 -0
- package/dist/components/layout/app-layout.js.map +1 -0
- package/dist/components/layout/aside-toggle.js +55 -0
- package/dist/components/layout/aside-toggle.js.map +1 -0
- package/dist/components/layout/aside.js +98 -0
- package/dist/components/layout/aside.js.map +1 -0
- package/dist/components/layout/bottom-nav-more.js +150 -0
- package/dist/components/layout/bottom-nav-more.js.map +1 -0
- package/dist/components/layout/bottom-nav.js +65 -0
- package/dist/components/layout/bottom-nav.js.map +1 -0
- package/dist/components/layout/context.js +103 -0
- package/dist/components/layout/context.js.map +1 -0
- package/dist/components/layout/index.js +14 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/layout/main.js +34 -0
- package/dist/components/layout/main.js.map +1 -0
- package/dist/components/layout/menu-toggle.js +61 -0
- package/dist/components/layout/menu-toggle.js.map +1 -0
- package/dist/components/layout/nav-context.js +85 -0
- package/dist/components/layout/nav-context.js.map +1 -0
- package/dist/components/layout/nav-folder.js +271 -0
- package/dist/components/layout/nav-folder.js.map +1 -0
- package/dist/components/layout/nav-item.js +192 -0
- package/dist/components/layout/nav-item.js.map +1 -0
- package/dist/components/layout/nav-link.js +58 -0
- package/dist/components/layout/nav-link.js.map +1 -0
- package/dist/components/layout/navbar.js +51 -0
- package/dist/components/layout/navbar.js.map +1 -0
- package/dist/components/layout/page-header.js +45 -0
- package/dist/components/layout/page-header.js.map +1 -0
- package/dist/components/layout/sidebar-group.js +41 -0
- package/dist/components/layout/sidebar-group.js.map +1 -0
- package/dist/components/layout/sidebar-toggle.js +82 -0
- package/dist/components/layout/sidebar-toggle.js.map +1 -0
- package/dist/components/layout/sidebar.js +252 -0
- package/dist/components/layout/sidebar.js.map +1 -0
- package/dist/components/navigation/breadcrumbs/separator.js +1 -1
- package/dist/components/navigation/index.js +4 -0
- package/dist/components/navigation/index.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +1 -1
- package/dist/components/navigation/stepper/collapse-menu.js +128 -0
- package/dist/components/navigation/stepper/collapse-menu.js.map +1 -0
- package/dist/components/navigation/stepper/list.js +17 -0
- package/dist/components/navigation/stepper/list.js.map +1 -0
- package/dist/components/navigation/stepper/panel.js +26 -0
- package/dist/components/navigation/stepper/panel.js.map +1 -0
- package/dist/components/navigation/stepper/step.js +130 -0
- package/dist/components/navigation/stepper/step.js.map +1 -0
- package/dist/components/navigation/stepper/stepper.js +475 -0
- package/dist/components/navigation/stepper/stepper.js.map +1 -0
- package/dist/components/navigation/stepper.js +5 -0
- package/dist/components/navigation/stepper.js.map +1 -0
- package/dist/components/navigation/tab-nav/item.js +6 -40
- package/dist/components/navigation/tab-nav/item.js.map +1 -1
- package/dist/components/notifications/index.js +1 -1
- package/dist/components/notifications/notification-card.js +2 -2
- package/dist/components/notifications/notifications-container.js +1 -1
- package/dist/components/overlays/portal.js +11 -2
- package/dist/components/overlays/portal.js.map +1 -1
- package/dist/components/status/alert.js +1 -1
- package/dist/components/status/badge.js +52 -0
- package/dist/components/status/badge.js.map +1 -0
- package/dist/components/status/index.js +1 -0
- package/dist/components/status/index.js.map +1 -1
- package/dist/components/utilities/collapsible.js +33 -5
- package/dist/components/utilities/collapsible.js.map +1 -1
- package/dist/{icons-DZ61nCzv.js → icons-55dthVFk.js} +14 -2
- package/dist/{icons-DZ61nCzv.js.map → icons-55dthVFk.js.map} +1 -1
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/layout.js +14 -0
- package/dist/layout.js.map +1 -0
- package/dist/navigation.js +4 -0
- package/dist/navigation.js.map +1 -1
- package/dist/{notification-card-dz-eE6z9.js → notification-card-BPfDo-Gf.js} +2 -2
- package/dist/{notification-card-dz-eE6z9.js.map → notification-card-BPfDo-Gf.js.map} +1 -1
- package/dist/notifications.js +1 -1
- package/dist/status.js +1 -0
- package/dist/status.js.map +1 -1
- package/dist/utils/breakpoint.js +56 -0
- package/dist/utils/breakpoint.js.map +1 -0
- package/dist/utils/document-listener.js +10 -0
- package/dist/utils/document-listener.js.map +1 -0
- package/dist/utils/listManager.js +12 -2
- package/dist/utils/listManager.js.map +1 -1
- package/dist/utils/route-active.js +70 -0
- package/dist/utils/route-active.js.map +1 -0
- package/dist/utils/selection-indicator.js +25 -5
- package/dist/utils/selection-indicator.js.map +1 -1
- package/package.json +7 -3
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { on } from '@ember/modifier';
|
|
3
|
+
import { guidFor } from '@ember/object/internals';
|
|
4
|
+
import { modifier } from 'ember-modifier';
|
|
5
|
+
import { Spinner } from '../../utilities/spinner.js';
|
|
6
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
|
+
import { setComponentTemplate } from '@ember/component';
|
|
8
|
+
|
|
9
|
+
/** What the `indicator` and `label` blocks receive. */
|
|
10
|
+
// Long enough for the check's draw (60ms delay + 320ms) to finish.
|
|
11
|
+
const COMPLETION_ANIMATION_MS = 450;
|
|
12
|
+
class StepperStep extends Component {
|
|
13
|
+
id = guidFor(this);
|
|
14
|
+
get isSelected() {
|
|
15
|
+
return this.args.context.isSelected(this.args.value);
|
|
16
|
+
}
|
|
17
|
+
get state() {
|
|
18
|
+
const derived = this.args.context.stateOf(this.args.value);
|
|
19
|
+
// The active step is always active; `@isComplete` only decides between
|
|
20
|
+
// complete and upcoming for the rest.
|
|
21
|
+
if (derived === 'active' || this.args.isComplete === undefined) {
|
|
22
|
+
return derived;
|
|
23
|
+
}
|
|
24
|
+
return this.args.isComplete ? 'complete' : 'upcoming';
|
|
25
|
+
}
|
|
26
|
+
/** The state, once the step has registered; before that, `undefined`. */
|
|
27
|
+
get settledState() {
|
|
28
|
+
return this.number > 0 ? this.state : undefined;
|
|
29
|
+
}
|
|
30
|
+
/** What a screen reader announces for an invalid step. */
|
|
31
|
+
get invalidText() {
|
|
32
|
+
return this.args.invalidLabel ?? 'Invalid';
|
|
33
|
+
}
|
|
34
|
+
get isLoading() {
|
|
35
|
+
return this.args.isLoading ?? false;
|
|
36
|
+
}
|
|
37
|
+
get isInvalid() {
|
|
38
|
+
return this.args.isInvalid ?? false;
|
|
39
|
+
}
|
|
40
|
+
get isCompleteMark() {
|
|
41
|
+
return this.state === 'complete';
|
|
42
|
+
}
|
|
43
|
+
get hasText() {
|
|
44
|
+
return Boolean(this.args.title || this.args.description);
|
|
45
|
+
}
|
|
46
|
+
get slotState() {
|
|
47
|
+
return {
|
|
48
|
+
state: this.state,
|
|
49
|
+
isInvalid: this.isInvalid,
|
|
50
|
+
isLoading: this.isLoading
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** One-based position, or 0 before the step has registered. */
|
|
54
|
+
get number() {
|
|
55
|
+
return this.args.context.steps.findIndex(step => step.id === this.id) + 1;
|
|
56
|
+
}
|
|
57
|
+
get isDisabled() {
|
|
58
|
+
return this.args.isDisabled ?? false;
|
|
59
|
+
}
|
|
60
|
+
registerStep = modifier(element => {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
62
|
+
const step = this;
|
|
63
|
+
const record = {
|
|
64
|
+
id: this.id,
|
|
65
|
+
element,
|
|
66
|
+
get value() {
|
|
67
|
+
return step.args.value;
|
|
68
|
+
},
|
|
69
|
+
get title() {
|
|
70
|
+
return step.args.title;
|
|
71
|
+
},
|
|
72
|
+
get isDisabled() {
|
|
73
|
+
return step.isDisabled;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
this.args.context.register(record);
|
|
77
|
+
return () => {
|
|
78
|
+
this.args.context.unregister(record);
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
// The state this step was in the last time the modifier ran. Not tracked:
|
|
82
|
+
// it is bookkeeping for the modifier, never read by a template.
|
|
83
|
+
#previousState;
|
|
84
|
+
/**
|
|
85
|
+
* Flags the `<li>` with `data-just-completed` for the length of the check's
|
|
86
|
+
* animation, but only when the step *becomes* complete -- not when it first
|
|
87
|
+
* renders complete, which would replay the animation on every step of a
|
|
88
|
+
* Stepper that opens partway through. The attribute is written straight to
|
|
89
|
+
* the element: the animation is a one-shot visual, and routing it through
|
|
90
|
+
* tracked state would re-render the step for nothing.
|
|
91
|
+
*/
|
|
92
|
+
trackCompletion = modifier((element, [state]) => {
|
|
93
|
+
// `undefined`: the step has not registered yet, so its state is still the
|
|
94
|
+
// provisional one every step starts with. It is not a real transition.
|
|
95
|
+
if (state === undefined) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const previous = this.#previousState;
|
|
99
|
+
this.#previousState = state;
|
|
100
|
+
if (previous === undefined || previous === 'complete' || state !== 'complete') {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
element.dataset['justCompleted'] = 'true';
|
|
104
|
+
const timer = setTimeout(() => {
|
|
105
|
+
delete element.dataset['justCompleted'];
|
|
106
|
+
}, COMPLETION_ANIMATION_MS);
|
|
107
|
+
return () => {
|
|
108
|
+
clearTimeout(timer);
|
|
109
|
+
delete element.dataset['justCompleted'];
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
handleClick = () => {
|
|
113
|
+
if (this.isDisabled) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.args.context.pick(this.args.value);
|
|
117
|
+
};
|
|
118
|
+
static {
|
|
119
|
+
setComponentTemplate(precompileTemplate("<li data-part=\"item\" data-state={{this.state}} data-invalid=\"{{this.isInvalid}}\" data-loading=\"{{this.isLoading}}\" data-disabled=\"{{this.isDisabled}}\" class={{@context.itemClass}} {{this.trackCompletion this.settledState}}>\n <button type=\"button\" data-part=\"step\" id={{this.id}} aria-current={{if this.isSelected \"step\"}} aria-disabled=\"{{this.isDisabled}}\" aria-busy={{if this.isLoading \"true\"}} data-selected=\"{{this.isSelected}}\" class=\"{{@context.stepClass}} {{@class}}\" {{this.registerStep}} {{@context.roving.setupItem}} {{on \"click\" this.handleClick}} ...attributes>\n <span data-part=\"indicator\" aria-hidden=\"true\" class={{@context.indicatorClass}}>\n {{#if (has-block \"indicator\")}}\n {{yield this.slotState to=\"indicator\"}}\n {{else if this.isLoading}}\n <Spinner @size=\"sm\" class={{@context.spinnerClass}} />\n {{else if this.isInvalid}}\n <svg viewBox=\"0 0 16 16\" class={{@context.markClass}} fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 4v5M8 12h.01\" /></svg>\n {{else if this.isCompleteMark}}\n <svg viewBox=\"0 0 16 16\" class={{@context.checkClass}} fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3.5 8.5l3 3 6-6.5\" pathLength=\"1\" /></svg>\n {{else if @icon}}\n <@icon />\n {{else if this.number}}\n {{this.number}}\n {{/if}}\n </span>\n {{#if (has-block \"label\")}}\n <span data-part=\"label\" class={{@context.labelClass}}>\n {{yield this.slotState to=\"label\"}}\n </span>\n {{else if this.hasText}}\n <span data-part=\"label\" class={{@context.labelClass}}>\n {{#if @title}}\n <span data-part=\"title\" class={{@context.titleClass}}>\n {{@title}}\n </span>\n {{/if}}\n {{#if @description}}\n <span data-part=\"description\" class={{@context.descriptionClass}}>\n {{@description}}\n </span>\n {{/if}}\n </span>\n {{/if}}\n {{#if this.isInvalid}}\n <span class={{@context.invalidTextClass}}>{{this.invalidText}}</span>\n {{/if}}\n </button>\n <span data-part=\"connector\" aria-hidden=\"true\" class={{@context.connectorClass}}></span>\n</li>", {
|
|
120
|
+
strictMode: true,
|
|
121
|
+
scope: () => ({
|
|
122
|
+
on,
|
|
123
|
+
Spinner
|
|
124
|
+
})
|
|
125
|
+
}), this);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { StepperStep, StepperStep as default };
|
|
130
|
+
//# sourceMappingURL=step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.js","sources":["../../../../src/components/navigation/stepper/step.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { on } from '@ember/modifier';\nimport { guidFor } from '@ember/object/internals';\nimport { modifier } from 'ember-modifier';\nimport Spinner from '../../utilities/spinner';\nimport type { StepperContext, StepRecord, StepState } from './stepper';\nimport type { ComponentLike } from '@glint/template';\n\ninterface StepperStepArgs<T> {\n /**\n * The value this step represents. Steps are matched by value, never by\n * position, so they can be conditional, looped or wrapped in components.\n */\n value: T;\n\n /**\n * Prevents the user from selecting this step: clicks are ignored and arrow\n * keys skip over it.\n *\n * @defaultValue false\n */\n isDisabled?: boolean;\n\n /** The step's title. */\n title?: string;\n\n /** Supporting text shown beneath or beside the title. */\n description?: string;\n\n /**\n * An icon component shown in the indicator while the step is active or\n * upcoming. Complete, invalid and loading steps show their own marks.\n */\n icon?: ComponentLike<{ Element: SVGElement }>;\n\n /**\n * Shows a spinner in place of the indicator content and sets `aria-busy`.\n *\n * @defaultValue false\n */\n isLoading?: boolean;\n\n /**\n * Marks the step as having a problem: a danger-colored indicator with a\n * screen-reader-only \"Invalid\" announcement. Always danger, whatever the\n * Stepper's `@color`.\n *\n * @defaultValue false\n */\n isInvalid?: boolean;\n\n /**\n * The text announced to screen readers for an invalid step. Use it to\n * localize the announcement.\n *\n * @defaultValue 'Invalid'\n */\n invalidLabel?: string;\n\n /**\n * Overrides whether the step counts as complete. Omit it and a step is\n * complete when it comes before the selected step. Pass it when completion\n * is business logic rather than position.\n */\n isComplete?: boolean;\n\n /** Class names appended to this step's theme classes. */\n class?: string;\n\n /**\n * Supplied by Stepper. Not part of the public API.\n *\n * @internal\n */\n context: StepperContext<T>;\n}\n\n/** What the `indicator` and `label` blocks receive. */\ninterface StepperStepSlotState {\n state: StepState;\n isInvalid: boolean;\n isLoading: boolean;\n}\n\ninterface StepperStepSignature<T> {\n Args: StepperStepArgs<T>;\n Blocks: {\n /** Replaces the content of the indicator circle. */\n indicator: [StepperStepSlotState];\n /** Replaces the default title and description. */\n label: [StepperStepSlotState];\n };\n Element: HTMLButtonElement;\n}\n\n// Long enough for the check's draw (60ms delay + 320ms) to finish.\nconst COMPLETION_ANIMATION_MS = 450;\n\nclass StepperStep<T> extends Component<StepperStepSignature<T>> {\n id = guidFor(this);\n\n get isSelected(): boolean {\n return this.args.context.isSelected(this.args.value);\n }\n\n get state(): StepState {\n const derived = this.args.context.stateOf(this.args.value);\n // The active step is always active; `@isComplete` only decides between\n // complete and upcoming for the rest.\n if (derived === 'active' || this.args.isComplete === undefined) {\n return derived;\n }\n return this.args.isComplete ? 'complete' : 'upcoming';\n }\n\n /** The state, once the step has registered; before that, `undefined`. */\n get settledState(): StepState | undefined {\n return this.number > 0 ? this.state : undefined;\n }\n\n /** What a screen reader announces for an invalid step. */\n get invalidText(): string {\n return this.args.invalidLabel ?? 'Invalid';\n }\n\n get isLoading(): boolean {\n return this.args.isLoading ?? false;\n }\n\n get isInvalid(): boolean {\n return this.args.isInvalid ?? false;\n }\n\n get isCompleteMark(): boolean {\n return this.state === 'complete';\n }\n\n get hasText(): boolean {\n return Boolean(this.args.title || this.args.description);\n }\n\n get slotState(): StepperStepSlotState {\n return {\n state: this.state,\n isInvalid: this.isInvalid,\n isLoading: this.isLoading\n };\n }\n\n /** One-based position, or 0 before the step has registered. */\n get number(): number {\n return this.args.context.steps.findIndex((step) => step.id === this.id) + 1;\n }\n\n get isDisabled(): boolean {\n return this.args.isDisabled ?? false;\n }\n\n registerStep = modifier((element: HTMLElement) => {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const step = this;\n const record: StepRecord<T> = {\n id: this.id,\n element,\n get value() {\n return step.args.value;\n },\n get title() {\n return step.args.title;\n },\n get isDisabled() {\n return step.isDisabled;\n }\n };\n\n this.args.context.register(record);\n\n return (): void => {\n this.args.context.unregister(record);\n };\n });\n\n // The state this step was in the last time the modifier ran. Not tracked:\n // it is bookkeeping for the modifier, never read by a template.\n #previousState: StepState | undefined;\n\n /**\n * Flags the `<li>` with `data-just-completed` for the length of the check's\n * animation, but only when the step *becomes* complete -- not when it first\n * renders complete, which would replay the animation on every step of a\n * Stepper that opens partway through. The attribute is written straight to\n * the element: the animation is a one-shot visual, and routing it through\n * tracked state would re-render the step for nothing.\n */\n trackCompletion = modifier(\n (element: HTMLElement, [state]: [StepState | undefined]) => {\n // `undefined`: the step has not registered yet, so its state is still the\n // provisional one every step starts with. It is not a real transition.\n if (state === undefined) {\n return;\n }\n\n const previous = this.#previousState;\n this.#previousState = state;\n\n if (\n previous === undefined ||\n previous === 'complete' ||\n state !== 'complete'\n ) {\n return;\n }\n\n element.dataset['justCompleted'] = 'true';\n const timer = setTimeout(() => {\n delete element.dataset['justCompleted'];\n }, COMPLETION_ANIMATION_MS);\n\n return (): void => {\n clearTimeout(timer);\n delete element.dataset['justCompleted'];\n };\n }\n );\n\n handleClick = (): void => {\n if (this.isDisabled) {\n return;\n }\n this.args.context.pick(this.args.value);\n };\n\n <template>\n <li\n data-part=\"item\"\n data-state={{this.state}}\n data-invalid=\"{{this.isInvalid}}\"\n data-loading=\"{{this.isLoading}}\"\n data-disabled=\"{{this.isDisabled}}\"\n class={{@context.itemClass}}\n {{this.trackCompletion this.settledState}}\n >\n <button\n type=\"button\"\n data-part=\"step\"\n id={{this.id}}\n aria-current={{if this.isSelected \"step\"}}\n aria-disabled=\"{{this.isDisabled}}\"\n aria-busy={{if this.isLoading \"true\"}}\n data-selected=\"{{this.isSelected}}\"\n class=\"{{@context.stepClass}} {{@class}}\"\n {{this.registerStep}}\n {{@context.roving.setupItem}}\n {{on \"click\" this.handleClick}}\n ...attributes\n >\n <span\n data-part=\"indicator\"\n aria-hidden=\"true\"\n class={{@context.indicatorClass}}\n >\n {{#if (has-block \"indicator\")}}\n {{yield this.slotState to=\"indicator\"}}\n {{else if this.isLoading}}\n <Spinner @size=\"sm\" class={{@context.spinnerClass}} />\n {{else if this.isInvalid}}\n <svg\n viewBox=\"0 0 16 16\"\n class={{@context.markClass}}\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n ><path d=\"M8 4v5M8 12h.01\" /></svg>\n {{else if this.isCompleteMark}}\n <svg\n viewBox=\"0 0 16 16\"\n class={{@context.checkClass}}\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n ><path d=\"M3.5 8.5l3 3 6-6.5\" pathLength=\"1\" /></svg>\n {{else if @icon}}\n <@icon />\n {{else if this.number}}\n {{this.number}}\n {{/if}}\n </span>\n {{#if (has-block \"label\")}}\n <span data-part=\"label\" class={{@context.labelClass}}>\n {{yield this.slotState to=\"label\"}}\n </span>\n {{else if this.hasText}}\n <span data-part=\"label\" class={{@context.labelClass}}>\n {{#if @title}}\n <span data-part=\"title\" class={{@context.titleClass}}>\n {{@title}}\n </span>\n {{/if}}\n {{#if @description}}\n <span data-part=\"description\" class={{@context.descriptionClass}}>\n {{@description}}\n </span>\n {{/if}}\n </span>\n {{/if}}\n {{#if this.isInvalid}}\n <span class={{@context.invalidTextClass}}>{{this.invalidText}}</span>\n {{/if}}\n </button>\n <span\n data-part=\"connector\"\n aria-hidden=\"true\"\n class={{@context.connectorClass}}\n ></span>\n </li>\n </template>\n}\n\nexport {\n StepperStep,\n type StepperStepSignature,\n type StepperStepArgs,\n type StepperStepSlotState\n};\nexport default StepperStep;\n"],"names":["COMPLETION_ANIMATION_MS","StepperStep","Component","id","guidFor","isSelected","args","context","value","state","derived","stateOf","isComplete","undefined","settledState","number","invalidText","invalidLabel","isLoading","isInvalid","isCompleteMark","hasText","Boolean","title","description","slotState","steps","findIndex","step","isDisabled","registerStep","modifier","element","record","register","unregister","trackCompletion","previous","dataset","timer","setTimeout","clearTimeout","handleClick","pick","setComponentTemplate","precompileTemplate","strictMode","scope","on","Spinner"],"mappings":"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"}
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked, cached } from '@glimmer/tracking';
|
|
3
|
+
import { hash } from '@ember/helper';
|
|
4
|
+
import { guidFor } from '@ember/object/internals';
|
|
5
|
+
import { isDestroying, isDestroyed } from '@ember/destroyable';
|
|
6
|
+
import { schedule } from '@ember/runloop';
|
|
7
|
+
import { modifier } from 'ember-modifier';
|
|
8
|
+
import { rovingFocus } from '../../../utils/roving-focus.js';
|
|
9
|
+
import { useStyles } from '@frontile/theme';
|
|
10
|
+
import { CollapseMenu } from './collapse-menu.js';
|
|
11
|
+
import { StepperList } from './list.js';
|
|
12
|
+
import { StepperPanel } from './panel.js';
|
|
13
|
+
import { StepperStep } from './step.js';
|
|
14
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
15
|
+
import { setComponentTemplate } from '@ember/component';
|
|
16
|
+
import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2 } from '../../../runtime--fcdnjmJ-BOdRhmsS.js';
|
|
17
|
+
|
|
18
|
+
class Stepper extends Component {
|
|
19
|
+
// Selection is manual -- Enter or Space -- unlike `Tabs`' automatic default:
|
|
20
|
+
// selecting a step can trigger validation or navigation, which arrowing
|
|
21
|
+
// past one must not.
|
|
22
|
+
roving = rovingFocus(() => ({
|
|
23
|
+
// The collapsed menu lists the steps vertically, so the arrow keys follow.
|
|
24
|
+
orientation: this.layout.orientation,
|
|
25
|
+
activationMode: 'manual',
|
|
26
|
+
onActivate: this.activateElement
|
|
27
|
+
}));
|
|
28
|
+
// Uncontrolled mode's own selection, seeded from `@defaultValue`. Written on
|
|
29
|
+
// every `select` regardless of mode -- the getter ignores it when controlled
|
|
30
|
+
// -- so both modes share one code path, as `Tabs` does.
|
|
31
|
+
static {
|
|
32
|
+
decorateFieldV2(this.prototype, "_value", [tracked]);
|
|
33
|
+
}
|
|
34
|
+
#_value = (initializeDeferredDecorator(this, "_value"), void 0);
|
|
35
|
+
static {
|
|
36
|
+
decorateFieldV2(this.prototype, "_hasSelection", [tracked], function () {
|
|
37
|
+
return false;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
#_hasSelection = (initializeDeferredDecorator(this, "_hasSelection"), void 0);
|
|
41
|
+
static {
|
|
42
|
+
decorateFieldV2(this.prototype, "_isNarrow", [tracked], function () {
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
#_isNarrow = (initializeDeferredDecorator(this, "_isNarrow"), void 0); // Whether the root is narrower than the full row needs. Measured, not
|
|
47
|
+
// derived: the answer lives in a container query, which JS can only read
|
|
48
|
+
// back from the rendered page.
|
|
49
|
+
listId = `${guidFor(this)}-list`;
|
|
50
|
+
menu = new CollapseMenu();
|
|
51
|
+
// Registered steps live in an untracked list, with a tracked version that
|
|
52
|
+
// consumers read. A step registers from its modifier, which installs inside
|
|
53
|
+
// the render transaction that already read `steps` (via `stateOf`): writing
|
|
54
|
+
// tracked state there trips Ember's backtracking assertion. So the list is
|
|
55
|
+
// mutated freely and only the version bump -- which is what makes `steps`
|
|
56
|
+
// reactive -- is deferred to `afterRender`, outside the transaction.
|
|
57
|
+
#records = [];
|
|
58
|
+
static {
|
|
59
|
+
decorateFieldV2(this.prototype, "_version", [tracked], function () {
|
|
60
|
+
return 0;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
#_version = (initializeDeferredDecorator(this, "_version"), void 0);
|
|
64
|
+
#bumpScheduled = false;
|
|
65
|
+
// Panel ids are derived from the order values are first seen, not from the
|
|
66
|
+
// value's `String()` form: two distinct values that stringify alike would
|
|
67
|
+
// otherwise collide. Untracked, so populating it during render raises no
|
|
68
|
+
// backtracking assertion.
|
|
69
|
+
#panelIndices = new Map();
|
|
70
|
+
constructor(owner, args) {
|
|
71
|
+
super(owner, args);
|
|
72
|
+
if ('defaultValue' in this.args) {
|
|
73
|
+
this._value = this.args.defaultValue;
|
|
74
|
+
this._hasSelection = true;
|
|
75
|
+
}
|
|
76
|
+
this.context = this.#buildContext();
|
|
77
|
+
}
|
|
78
|
+
get collapseMode() {
|
|
79
|
+
return this.args.collapse === false ? 'none' : this.args.collapse ?? 'menu';
|
|
80
|
+
}
|
|
81
|
+
/** Whether a menu is configured and applicable (horizontal only). */
|
|
82
|
+
get usesMenu() {
|
|
83
|
+
return this.collapseMode === 'menu' && this.orientation === 'horizontal';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The layout the steps are drawn in. Collapsed into the menu, the list uses
|
|
87
|
+
* the vertical layout inside the panel, whatever was configured; everything
|
|
88
|
+
* that depends on the layout (styles and arrow keys)
|
|
89
|
+
* reads it from here.
|
|
90
|
+
*/
|
|
91
|
+
get layout() {
|
|
92
|
+
return this.collapsed ? {
|
|
93
|
+
orientation: 'vertical',
|
|
94
|
+
labelPosition: 'end'
|
|
95
|
+
} : {
|
|
96
|
+
orientation: this.orientation,
|
|
97
|
+
labelPosition: this.args.labelPosition ?? 'end'
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** Whether the menu is active right now. */
|
|
101
|
+
get collapsed() {
|
|
102
|
+
return this.usesMenu && this._isNarrow;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Styles for the root and the probe, which keep the *configured* layout:
|
|
106
|
+
* the probe's threshold depends on `labelPosition`, and it must not change
|
|
107
|
+
* when the list switches to its vertical, in-menu layout.
|
|
108
|
+
*/
|
|
109
|
+
get rootStyles() {
|
|
110
|
+
const {
|
|
111
|
+
stepper
|
|
112
|
+
} = useStyles();
|
|
113
|
+
return stepper({
|
|
114
|
+
color: this.args.color,
|
|
115
|
+
size: this.args.size,
|
|
116
|
+
orientation: this.args.orientation,
|
|
117
|
+
labelPosition: this.args.labelPosition,
|
|
118
|
+
collapse: this.collapseMode
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
static {
|
|
122
|
+
decorateMethodV2(this.prototype, "rootStyles", [cached]);
|
|
123
|
+
}
|
|
124
|
+
get probeClass() {
|
|
125
|
+
return this.rootStyles.probe();
|
|
126
|
+
}
|
|
127
|
+
// Everything below the root. Collapsed, the list lays out vertically, like
|
|
128
|
+
// `@orientation='vertical'`, inside the floating panel.
|
|
129
|
+
get styles() {
|
|
130
|
+
const {
|
|
131
|
+
stepper
|
|
132
|
+
} = useStyles();
|
|
133
|
+
return stepper({
|
|
134
|
+
color: this.args.color,
|
|
135
|
+
size: this.args.size,
|
|
136
|
+
orientation: this.layout.orientation,
|
|
137
|
+
labelPosition: this.layout.labelPosition,
|
|
138
|
+
collapse: this.collapseMode,
|
|
139
|
+
collapsed: this.collapsed
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
static {
|
|
143
|
+
decorateMethodV2(this.prototype, "styles", [cached]);
|
|
144
|
+
}
|
|
145
|
+
get orientation() {
|
|
146
|
+
return this.args.orientation ?? 'horizontal';
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Whether `@value` was *passed* decides the mode -- not whether it holds a
|
|
150
|
+
* value. `T` is generic, so `undefined` is a legitimate selection meaning
|
|
151
|
+
* "nothing is selected". Glimmer's named-args object carries a key for every
|
|
152
|
+
* argument written in the invoking template, so `in` distinguishes
|
|
153
|
+
* `@value={{undefined}}` from an omitted `@value`.
|
|
154
|
+
*/
|
|
155
|
+
get isControlled() {
|
|
156
|
+
return 'value' in this.args;
|
|
157
|
+
}
|
|
158
|
+
/** Registered steps in document order. */
|
|
159
|
+
get steps() {
|
|
160
|
+
// Consumed for its tag only: this is what re-runs dependents when the
|
|
161
|
+
// registry changes.
|
|
162
|
+
void this._version;
|
|
163
|
+
return [...this.#records].sort((a, b) => a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
164
|
+
}
|
|
165
|
+
get selectedValue() {
|
|
166
|
+
if (this.isControlled) {
|
|
167
|
+
return this.args.value;
|
|
168
|
+
}
|
|
169
|
+
// A Stepper always has a current step. Uncontrolled, a stored value that no
|
|
170
|
+
// registered step matches -- its step was removed -- falls back to the
|
|
171
|
+
// first enabled step. Before any step has registered there is nothing to
|
|
172
|
+
// compare against, so the stored value stands.
|
|
173
|
+
if (this._hasSelection) {
|
|
174
|
+
const steps = this.steps;
|
|
175
|
+
if (steps.length === 0 || steps.some(step => step.value === this._value)) {
|
|
176
|
+
return this._value;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return this.steps.find(step => !step.isDisabled)?.value;
|
|
180
|
+
}
|
|
181
|
+
/** Backs the menu trigger and the narrow-width "Step N of M" line. */
|
|
182
|
+
get summary() {
|
|
183
|
+
if (this.orientation !== 'horizontal' || this.collapseMode === 'none') {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
const steps = this.steps;
|
|
187
|
+
const selected = this.selectedValue;
|
|
188
|
+
const index = steps.findIndex(step => step.value === selected);
|
|
189
|
+
if (index === -1) {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
const position = index + 1;
|
|
193
|
+
const total = steps.length;
|
|
194
|
+
return {
|
|
195
|
+
label: this.args.summaryLabel ? this.args.summaryLabel(position, total) : `Step ${position} of ${total}`,
|
|
196
|
+
title: steps[index]?.title
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
isSelected = value => this.selectedValue === value;
|
|
200
|
+
stateOf = value => {
|
|
201
|
+
const selected = this.selectedValue;
|
|
202
|
+
if (value === selected) {
|
|
203
|
+
return 'active';
|
|
204
|
+
}
|
|
205
|
+
const values = this.steps.map(step => step.value);
|
|
206
|
+
const activeIndex = values.indexOf(selected);
|
|
207
|
+
const index = values.indexOf(value);
|
|
208
|
+
return activeIndex !== -1 && index !== -1 && index < activeIndex ? 'complete' : 'upcoming';
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* The nearest step in `direction` that is not disabled. With no current
|
|
212
|
+
* step (nothing selected, or the selected value matches no step) `next`
|
|
213
|
+
* finds the first enabled step and `prev` finds none.
|
|
214
|
+
*/
|
|
215
|
+
#neighbor(direction) {
|
|
216
|
+
const steps = this.steps;
|
|
217
|
+
const selected = this.selectedValue;
|
|
218
|
+
const current = steps.findIndex(step => step.value === selected);
|
|
219
|
+
for (let i = current + direction; i >= 0 && i < steps.length; i += direction) {
|
|
220
|
+
const step = steps[i];
|
|
221
|
+
if (step && !step.isDisabled) {
|
|
222
|
+
return step;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
get hasNext() {
|
|
228
|
+
return this.#neighbor(1) !== undefined;
|
|
229
|
+
}
|
|
230
|
+
get hasPrev() {
|
|
231
|
+
return this.#neighbor(-1) !== undefined;
|
|
232
|
+
}
|
|
233
|
+
next = () => {
|
|
234
|
+
const target = this.#neighbor(1);
|
|
235
|
+
if (target) {
|
|
236
|
+
this.select(target.value);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
prev = () => {
|
|
240
|
+
const target = this.#neighbor(-1);
|
|
241
|
+
if (target) {
|
|
242
|
+
this.select(target.value);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
select = value => {
|
|
246
|
+
this._value = value;
|
|
247
|
+
this._hasSelection = true;
|
|
248
|
+
this.args.onChange?.(value);
|
|
249
|
+
};
|
|
250
|
+
// A step chosen by the user, as opposed to `next`/`prev`/`goTo`. Picking one
|
|
251
|
+
// from the menu also closes it.
|
|
252
|
+
pick = value => {
|
|
253
|
+
this.select(value);
|
|
254
|
+
this.menu.close();
|
|
255
|
+
};
|
|
256
|
+
#setNarrow(narrow) {
|
|
257
|
+
if (narrow === this._isNarrow) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
// From a modifier or a ResizeObserver: the first runs inside the render
|
|
261
|
+
// transaction that already read `collapsed`, so the write waits for
|
|
262
|
+
// `afterRender`, like the step registry's version bump.
|
|
263
|
+
schedule('afterRender', () => {
|
|
264
|
+
if (isDestroying(this) || isDestroyed(this)) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
this._isNarrow = narrow;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Reads which side of the threshold the root is on from the probe element,
|
|
272
|
+
* whose `display` the container query flips. Re-reads when the root
|
|
273
|
+
* resizes.
|
|
274
|
+
*/
|
|
275
|
+
observeWidth = modifier((root, [enabled]) => {
|
|
276
|
+
const probe = root.querySelector('[data-part="probe"]');
|
|
277
|
+
if (!enabled || !probe) {
|
|
278
|
+
this.#setNarrow(false);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const measure = () => {
|
|
282
|
+
this.#setNarrow(getComputedStyle(probe).display === 'none');
|
|
283
|
+
};
|
|
284
|
+
measure();
|
|
285
|
+
const observer = new ResizeObserver(measure);
|
|
286
|
+
observer.observe(root);
|
|
287
|
+
return () => {
|
|
288
|
+
observer.disconnect();
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
register = record => {
|
|
292
|
+
this.#records.push(record);
|
|
293
|
+
this.#bump();
|
|
294
|
+
};
|
|
295
|
+
unregister = record => {
|
|
296
|
+
this.#records = this.#records.filter(item => item !== record);
|
|
297
|
+
this.#bump();
|
|
298
|
+
};
|
|
299
|
+
#bump() {
|
|
300
|
+
if (this.#bumpScheduled) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.#bumpScheduled = true;
|
|
304
|
+
schedule('afterRender', () => {
|
|
305
|
+
this.#bumpScheduled = false;
|
|
306
|
+
if (isDestroying(this) || isDestroyed(this)) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
this._version++;
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
activateElement = element => {
|
|
313
|
+
const record = this.#records.find(item => item.element === element);
|
|
314
|
+
if (!record || record.isDisabled) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
this.pick(record.value);
|
|
318
|
+
};
|
|
319
|
+
stepIdFor = value => this.steps.find(step => step.value === value)?.id;
|
|
320
|
+
panelIdFor = value => {
|
|
321
|
+
let index = this.#panelIndices.get(value);
|
|
322
|
+
if (index === undefined) {
|
|
323
|
+
index = this.#panelIndices.size;
|
|
324
|
+
this.#panelIndices.set(value, index);
|
|
325
|
+
}
|
|
326
|
+
return `${guidFor(this)}-panel-${index}`;
|
|
327
|
+
};
|
|
328
|
+
// One object for the life of the component, with the class strings as
|
|
329
|
+
// getters. A context rebuilt whenever the styles change (they do when the
|
|
330
|
+
// menu collapses) is a new `@context` for every step, which re-runs each
|
|
331
|
+
// `{{@context.…}}` modifier -- tearing down and reinstalling the roving
|
|
332
|
+
// focus listeners on every step mid-update.
|
|
333
|
+
context;
|
|
334
|
+
#buildContext() {
|
|
335
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
336
|
+
const stepper = this;
|
|
337
|
+
return {
|
|
338
|
+
get listClass() {
|
|
339
|
+
return stepper.styles.list({
|
|
340
|
+
class: stepper.args.classes?.list
|
|
341
|
+
});
|
|
342
|
+
},
|
|
343
|
+
get itemClass() {
|
|
344
|
+
return stepper.styles.item({
|
|
345
|
+
class: stepper.args.classes?.item
|
|
346
|
+
});
|
|
347
|
+
},
|
|
348
|
+
get stepClass() {
|
|
349
|
+
return stepper.styles.step({
|
|
350
|
+
class: stepper.args.classes?.step
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
get indicatorClass() {
|
|
354
|
+
return stepper.styles.indicator({
|
|
355
|
+
class: stepper.args.classes?.indicator
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
get checkClass() {
|
|
359
|
+
return stepper.styles.check({
|
|
360
|
+
class: stepper.args.classes?.check
|
|
361
|
+
});
|
|
362
|
+
},
|
|
363
|
+
get connectorClass() {
|
|
364
|
+
return stepper.styles.connector({
|
|
365
|
+
class: stepper.args.classes?.connector
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
get labelClass() {
|
|
369
|
+
return stepper.styles.label({
|
|
370
|
+
class: stepper.args.classes?.label
|
|
371
|
+
});
|
|
372
|
+
},
|
|
373
|
+
get titleClass() {
|
|
374
|
+
return stepper.styles.title({
|
|
375
|
+
class: stepper.args.classes?.title
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
get descriptionClass() {
|
|
379
|
+
return stepper.styles.description({
|
|
380
|
+
class: stepper.args.classes?.description
|
|
381
|
+
});
|
|
382
|
+
},
|
|
383
|
+
get summaryClass() {
|
|
384
|
+
return stepper.styles.summary({
|
|
385
|
+
class: stepper.args.classes?.summary
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
get triggerLabelClass() {
|
|
389
|
+
return stepper.styles.triggerLabel({
|
|
390
|
+
class: stepper.args.classes?.triggerLabel
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
get chevronClass() {
|
|
394
|
+
return stepper.styles.chevron({
|
|
395
|
+
class: stepper.args.classes?.chevron
|
|
396
|
+
});
|
|
397
|
+
},
|
|
398
|
+
get summaryTextClass() {
|
|
399
|
+
return stepper.styles.summaryText({
|
|
400
|
+
class: stepper.args.classes?.summaryText
|
|
401
|
+
});
|
|
402
|
+
},
|
|
403
|
+
get summaryTitleClass() {
|
|
404
|
+
return stepper.styles.summaryTitle({
|
|
405
|
+
class: stepper.args.classes?.summaryTitle
|
|
406
|
+
});
|
|
407
|
+
},
|
|
408
|
+
get markClass() {
|
|
409
|
+
return stepper.styles.mark({
|
|
410
|
+
class: stepper.args.classes?.mark
|
|
411
|
+
});
|
|
412
|
+
},
|
|
413
|
+
get spinnerClass() {
|
|
414
|
+
return stepper.styles.spinner({
|
|
415
|
+
class: stepper.args.classes?.spinner
|
|
416
|
+
});
|
|
417
|
+
},
|
|
418
|
+
get invalidTextClass() {
|
|
419
|
+
return stepper.styles.invalidText({
|
|
420
|
+
class: stepper.args.classes?.invalidText
|
|
421
|
+
});
|
|
422
|
+
},
|
|
423
|
+
get triggerClass() {
|
|
424
|
+
return stepper.styles.trigger({
|
|
425
|
+
class: stepper.args.classes?.trigger
|
|
426
|
+
});
|
|
427
|
+
},
|
|
428
|
+
get panelClass() {
|
|
429
|
+
return stepper.styles.panel({
|
|
430
|
+
class: stepper.args.classes?.panel
|
|
431
|
+
});
|
|
432
|
+
},
|
|
433
|
+
get summary() {
|
|
434
|
+
return stepper.summary;
|
|
435
|
+
},
|
|
436
|
+
get showSummaryLine() {
|
|
437
|
+
return stepper.collapseMode === 'summary' && !!stepper.summary;
|
|
438
|
+
},
|
|
439
|
+
get collapsed() {
|
|
440
|
+
return stepper.collapsed;
|
|
441
|
+
},
|
|
442
|
+
get isMenuOpen() {
|
|
443
|
+
return stepper.menu.isOpen;
|
|
444
|
+
},
|
|
445
|
+
get steps() {
|
|
446
|
+
return stepper.steps;
|
|
447
|
+
},
|
|
448
|
+
listId: this.listId,
|
|
449
|
+
registerTrigger: this.menu.registerTrigger,
|
|
450
|
+
menuList: this.menu.list,
|
|
451
|
+
pick: this.pick,
|
|
452
|
+
isSelected: this.isSelected,
|
|
453
|
+
stateOf: this.stateOf,
|
|
454
|
+
register: this.register,
|
|
455
|
+
unregister: this.unregister,
|
|
456
|
+
stepIdFor: this.stepIdFor,
|
|
457
|
+
panelIdFor: this.panelIdFor,
|
|
458
|
+
roving: this.roving
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
static {
|
|
462
|
+
setComponentTemplate(precompileTemplate("<div data-component=\"stepper\" data-part=\"base\" data-orientation={{this.orientation}} data-collapsed=\"{{this.collapsed}}\" class={{this.rootStyles.base class=@classes.base}} {{this.observeWidth this.usesMenu}} ...attributes>\n {{#if this.usesMenu}}\n <span data-part=\"probe\" aria-hidden=\"true\" class={{this.probeClass}}></span>\n {{/if}}\n {{#let (component StepperList context=this.context) (component StepperStep context=this.context) (component StepperPanel context=this.context) as |List Step Panel|}}\n {{!-- @glint-ignore: WithBoundArgs vs. a generic component --}}\n {{yield (hash List=List Step=Step Panel=Panel next=this.next prev=this.prev goTo=this.select hasNext=this.hasNext hasPrev=this.hasPrev)}}\n {{/let}}\n</div>", {
|
|
463
|
+
strictMode: true,
|
|
464
|
+
scope: () => ({
|
|
465
|
+
StepperList,
|
|
466
|
+
StepperStep,
|
|
467
|
+
StepperPanel,
|
|
468
|
+
hash
|
|
469
|
+
})
|
|
470
|
+
}), this);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export { Stepper, Stepper as default };
|
|
475
|
+
//# sourceMappingURL=stepper.js.map
|