@design.estate/dees-catalog 21.28.0 → 21.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist_bundle/bundle.js +281 -99
  2. package/dist_bundle/bundle.js.map +1 -1
  3. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-45QQJK4L.js → chunk-CJVVAKHG.js} +509 -358
  4. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-45QQJK4L.js.map → chunk-CJVVAKHG.js.map} +1 -1
  5. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-C63GPX4U.js → chunk-QFJ7LA5L.js} +2 -2
  6. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-OYJYQPHK.js → dees-modal-NVJRWZKO.js} +2 -2
  7. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-UTDYRJTX.js → dees-workspace-terminal-BSBYG5IX.js} +3 -3
  8. package/dist_ts_web/00_commitinfo_data.js +1 -1
  9. package/dist_ts_web/elements/00actionerror.d.ts +4 -2
  10. package/dist_ts_web/elements/00actionerror.js +1 -1
  11. package/dist_ts_web/elements/00group-button/dees-actionfooter/dees-actionfooter.d.ts +77 -0
  12. package/dist_ts_web/elements/00group-button/dees-actionfooter/dees-actionfooter.demo.d.ts +1 -0
  13. package/dist_ts_web/elements/00group-button/dees-actionfooter/dees-actionfooter.demo.js +60 -0
  14. package/dist_ts_web/elements/00group-button/dees-actionfooter/dees-actionfooter.js +240 -0
  15. package/dist_ts_web/elements/00group-button/dees-actionfooter/index.d.ts +1 -0
  16. package/dist_ts_web/elements/00group-button/dees-actionfooter/index.js +2 -0
  17. package/dist_ts_web/elements/00group-button/index.d.ts +1 -0
  18. package/dist_ts_web/elements/00group-button/index.js +2 -1
  19. package/dist_ts_web/elements/00group-dataview/dees-table/filters.d.ts +8 -3
  20. package/dist_ts_web/elements/00group-dataview/dees-table/filters.js +13 -15
  21. package/dist_ts_web/elements/00group-dataview/dees-table/search.js +3 -2
  22. package/dist_ts_web/elements/00group-input/dees-input-radiogroup/dees-input-radiogroup.d.ts +7 -1
  23. package/dist_ts_web/elements/00group-input/dees-input-radiogroup/dees-input-radiogroup.demo.js +17 -2
  24. package/dist_ts_web/elements/00group-input/dees-input-radiogroup/dees-input-radiogroup.js +25 -4
  25. package/dist_ts_web/elements/00group-input/profilepicture/profilepicture.modal.d.ts +1 -1
  26. package/dist_ts_web/elements/00group-input/profilepicture/profilepicture.modal.js +8 -20
  27. package/dist_ts_web/elements/00group-layout/dees-stepper/dees-stepper.d.ts +44 -3
  28. package/dist_ts_web/elements/00group-layout/dees-stepper/dees-stepper.demo.d.ts +2 -0
  29. package/dist_ts_web/elements/00group-layout/dees-stepper/dees-stepper.demo.js +118 -9
  30. package/dist_ts_web/elements/00group-layout/dees-stepper/dees-stepper.js +70 -13
  31. package/dist_ts_web/elements/00group-layout/dees-stepper/styles.js +54 -6
  32. package/dist_ts_web/elements/00group-overlay/dees-modal/dees-modal.d.ts +18 -26
  33. package/dist_ts_web/elements/00group-overlay/dees-modal/dees-modal.js +33 -100
  34. package/dist_ts_web/elements/00group-overlay/dees-popover/dees-popover.d.ts +14 -0
  35. package/dist_ts_web/elements/00group-overlay/dees-popover/dees-popover.js +49 -6
  36. package/package.json +1 -1
  37. package/readme.md +109 -16
  38. package/ts_web/00_commitinfo_data.ts +1 -1
  39. package/ts_web/elements/00actionerror.ts +4 -2
  40. package/ts_web/elements/00group-button/dees-actionfooter/dees-actionfooter.demo.ts +64 -0
  41. package/ts_web/elements/00group-button/dees-actionfooter/dees-actionfooter.ts +196 -0
  42. package/ts_web/elements/00group-button/dees-actionfooter/index.ts +1 -0
  43. package/ts_web/elements/00group-button/index.ts +1 -0
  44. package/ts_web/elements/00group-dataview/dees-table/filters.ts +14 -14
  45. package/ts_web/elements/00group-dataview/dees-table/search.ts +2 -1
  46. package/ts_web/elements/00group-input/dees-input-radiogroup/dees-input-radiogroup.demo.ts +22 -1
  47. package/ts_web/elements/00group-input/dees-input-radiogroup/dees-input-radiogroup.ts +31 -5
  48. package/ts_web/elements/00group-input/profilepicture/profilepicture.modal.ts +7 -19
  49. package/ts_web/elements/00group-layout/dees-stepper/dees-stepper.demo.ts +106 -4
  50. package/ts_web/elements/00group-layout/dees-stepper/dees-stepper.ts +95 -33
  51. package/ts_web/elements/00group-layout/dees-stepper/styles.ts +55 -5
  52. package/ts_web/elements/00group-overlay/dees-modal/dees-modal.ts +43 -101
  53. package/ts_web/elements/00group-overlay/dees-popover/dees-popover.ts +36 -2
  54. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-C63GPX4U.js.map → chunk-QFJ7LA5L.js.map} +0 -0
  55. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-OYJYQPHK.js.map → dees-modal-NVJRWZKO.js.map} +0 -0
  56. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-UTDYRJTX.js.map → dees-workspace-terminal-BSBYG5IX.js.map} +0 -0
@@ -1,3 +1,24 @@
1
+ import { html } from '@design.estate/dees-element';
1
2
  import { focusedInputDemo } from '../../../demos/inputs.js';
3
+ import { demoSection, demoOutput, demoCode, showDemoResult } from '../../../demos/templates.js';
4
+ import type { DeesInputRadiogroup } from './dees-input-radiogroup.js';
2
5
 
3
- export const demoFunc = () => focusedInputDemo('radiogroup');
6
+ const imports = [
7
+ { key: 'manual', option: 'Enter the details yourself', description: 'Type the name and whatever else you know.' },
8
+ { key: 'text', option: 'Read them from a text', description: 'Paste a signature or a letterhead; a language model picks out the details.' },
9
+ { key: 'website', option: 'Read them from a website', description: 'Give the address of an imprint page; a language model reads it.' },
10
+ ];
11
+
12
+ const sections = html`
13
+ ${demoSection('Choices that explain themselves',
14
+ 'An option can carry a description: a line under its label that says what the choice does. The circle stays on the label\'s line, and assistive technology reads the description with the option.',
15
+ html`
16
+ <dees-input-radiogroup key="source" label="How do you want to add the contact?" .options=${imports} selectedOption="manual"
17
+ @change=${(event: Event) => showDemoResult(event.currentTarget as Element,
18
+ `Chosen: ${(event.currentTarget as DeesInputRadiogroup).selectedOption}`)}></dees-input-radiogroup>
19
+ ${demoOutput('Chosen: manual')}
20
+ ${demoCode("<dees-input-radiogroup .options=${[\n { key: 'manual', option: 'Enter the details yourself', description: 'Type the name and whatever else you know.' },\n ...\n]}></dees-input-radiogroup>")}
21
+ `)}
22
+ `;
23
+
24
+ export const demoFunc = () => focusedInputDemo('radiogroup', sections);
@@ -16,8 +16,12 @@ declare global {
16
16
  }
17
17
  }
18
18
 
19
- /** One entry of `options`: a label that is its own key, or a label (`option`) with a `key` and an optional `payload`. */
20
- export type TRadiogroupOption = string | { option: string; key: string; payload?: any };
19
+ /**
20
+ * One entry of `options`: a label that is its own key, or a label (`option`)
21
+ * with a `key`, an optional `payload` and an optional `description`, a line
22
+ * under the label that explains the choice.
23
+ */
24
+ export type TRadiogroupOption = string | { option: string; key: string; payload?: any; description?: string };
21
25
 
22
26
  @customElement('dees-input-radiogroup')
23
27
  export class DeesInputRadiogroup extends DeesInputBase<string | object> {
@@ -162,6 +166,18 @@ export class DeesInputRadiogroup extends DeesInputBase<string | object> {
162
166
  line-height: var(--dees-font-subhead-line);
163
167
  }
164
168
 
169
+ /* Described choices: the explanation under the label, the circle on the label's line. */
170
+ .maincontainer.vertical.described { gap: var(--dees-spacing-md); }
171
+ .radio-option.described { align-items: flex-start; }
172
+ .radio-text { min-width: 0; }
173
+ .radio-description {
174
+ margin-block-start: var(--dees-spacing-2xs);
175
+ font-size: var(--dees-font-footnote-size);
176
+ line-height: var(--dees-font-footnote-line);
177
+ color: var(--dees-color-text-secondary);
178
+ overflow-wrap: anywhere;
179
+ }
180
+
165
181
  @media (pointer: coarse) {
166
182
  .radio-option { min-height: var(--dees-control-height-touch); }
167
183
  }
@@ -237,21 +253,23 @@ export class DeesInputRadiogroup extends DeesInputBase<string | object> {
237
253
  public render(): TemplateResult {
238
254
  const keys = this.options.map((option) => this.getOptionKey(option));
239
255
  const tabStop = keys.includes(this.selectedOption) ? this.selectedOption : keys[0];
256
+ const described = this.options.some((option) => this.getOptionDescription(option));
240
257
  return html`
241
258
  <div class="input-wrapper">
242
259
  ${this.label ? this.renderLabel() : ''}
243
- <div class="maincontainer ${this.direction}" role="radiogroup"
260
+ <div class="maincontainer ${this.direction} ${described ? 'described' : ''}" role="radiogroup"
244
261
  aria-label=${this.label} aria-required=${this.required ? 'true' : 'false'}
245
262
  aria-disabled=${this.disabled ? 'true' : 'false'}
246
263
  aria-invalid=${this.validationState === 'invalid' ? 'true' : 'false'}>
247
264
  ${this.options.map((option) => {
248
265
  const optionKey = this.getOptionKey(option);
249
266
  const optionLabel = this.getOptionLabel(option);
267
+ const optionDescription = this.getOptionDescription(option);
250
268
  const isSelected = this.selectedOption === optionKey;
251
269
 
252
270
  return html`
253
271
  <div
254
- class="radio-option ${isSelected ? 'selected' : ''}"
272
+ class="radio-option ${isSelected ? 'selected' : ''} ${optionDescription ? 'described' : ''}"
255
273
  @click="${() => this.selectOption(optionKey)}"
256
274
  @keydown="${(e: KeyboardEvent) => this.handleKeydown(e, optionKey)}"
257
275
  >
@@ -261,8 +279,12 @@ export class DeesInputRadiogroup extends DeesInputBase<string | object> {
261
279
  role="radio"
262
280
  aria-checked="${isSelected}"
263
281
  aria-label="${optionLabel}"
282
+ .ariaDescription=${optionDescription || null}
264
283
  ></div>
265
- <div class="radio-label">${optionLabel}</div>
284
+ <div class="radio-text">
285
+ <div class="radio-label">${optionLabel}</div>
286
+ ${optionDescription ? html`<div class="radio-description">${optionDescription}</div>` : ''}
287
+ </div>
266
288
  </div>
267
289
  `;
268
290
  })}
@@ -286,6 +308,10 @@ export class DeesInputRadiogroup extends DeesInputBase<string | object> {
286
308
  return option.option;
287
309
  }
288
310
 
311
+ private getOptionDescription(option: TRadiogroupOption): string | undefined {
312
+ return typeof option === 'string' ? undefined : option.description || undefined;
313
+ }
314
+
289
315
  private getOptionByKey(key: string): TRadiogroupOption | undefined {
290
316
  return this.options.find(opt => this.getOptionKey(opt) === key);
291
317
  }
@@ -11,7 +11,7 @@ import {
11
11
  import { cssGeistFontFamily } from '../../00fonts.js';
12
12
  import { zIndexRegistry } from '../../00zindex.js';
13
13
  import '../../00group-utility/dees-icon/dees-icon.js';
14
- import '../../00group-button/dees-button/dees-button.js';
14
+ import '../../00group-button/dees-actionfooter/dees-actionfooter.js';
15
15
  import '../../00group-overlay/dees-windowlayer/dees-windowlayer.js';
16
16
  import { DeesWindowLayer } from '../../00group-overlay/dees-windowlayer/dees-windowlayer.js';
17
17
  import { ImageCropper } from './profilepicture.cropper.js';
@@ -197,14 +197,6 @@ export class ProfilePictureModal extends DeesElement {
197
197
  100% { transform: scale(1); opacity: 1; }
198
198
  }
199
199
 
200
- .modal-footer {
201
- padding: 20px 24px;
202
- border-top: var(--dees-line-width-hairline) solid var(--dees-color-hover);
203
- display: flex;
204
- gap: 10px;
205
- justify-content: flex-end;
206
- }
207
-
208
200
  .instructions {
209
201
  text-align: center;
210
202
  color: var(--dees-color-text-muted);
@@ -312,16 +304,12 @@ export class ProfilePictureModal extends DeesElement {
312
304
  `}
313
305
  </div>
314
306
 
315
- <div class="modal-footer">
316
- ${this.currentStep === 'crop' ? html`
317
- <dees-button type="destructive" size="sm" @click=${this.close}>
318
- ${this.t('common.cancel')}
319
- </dees-button>
320
- <dees-button type="default" size="sm" @click=${this.handleCrop}>
321
- ${this.t('common.save')}
322
- </dees-button>
323
- ` : ''}
324
- </div>
307
+ ${this.currentStep === 'crop' ? html`
308
+ <dees-actionfooter .actions=${[
309
+ { name: this.t('common.cancel'), action: () => this.close() },
310
+ { name: this.t('common.save'), action: () => this.handleCrop() },
311
+ ]}></dees-actionfooter>
312
+ ` : ''}
325
313
  </div>
326
314
  `;
327
315
  }
@@ -1,11 +1,13 @@
1
1
  import { DeesElement, customElement, property, state, html, css, cssManager } from '@design.estate/dees-element';
2
- import { DeesStepper, type IStep, type TStepperLayout } from './dees-stepper.js';
2
+ import { DeesStepper, type IStep, type TStepperCardAlign, type TStepperLayout } from './dees-stepper.js';
3
3
  import { DeesModal } from '../../00group-overlay/dees-modal/dees-modal.js';
4
4
  import { themeDefaultStyles } from '../../00theme.js';
5
5
  import { demoPage } from '../../../demos/templates.js';
6
6
  import '../../00group-form/dees-form/dees-form.js';
7
7
  import '../../00group-input/dees-input-text/dees-input-text.js';
8
8
  import '../../00group-input/dees-input-multitoggle/dees-input-multitoggle.js';
9
+ import '../../00group-input/dees-input-radiogroup/dees-input-radiogroup.js';
10
+ import '../../00group-input/dees-input-textarea/dees-input-textarea.js';
9
11
  import '../../00group-input/dees-input-toggle/dees-input-toggle.js';
10
12
 
11
13
  const waitForProgressTick = (duration: number, signal?: AbortSignal): Promise<boolean> => new Promise(resolve => {
@@ -153,14 +155,101 @@ const createLongSteps = (finish: (name: string) => void): IStep[] => {
153
155
  }));
154
156
  };
155
157
 
158
+ /**
159
+ * A flow that starts with a choice: the first step asks how, and the steps
160
+ * after it follow the answer. Entering the details takes one more step; reading
161
+ * them from a text or a website reads first (not a step of its own) and then
162
+ * shows what was read for checking. Nothing is kept before Create. Cancelling
163
+ * closes at once until something was read and asks first after that.
164
+ */
165
+ const createChoiceSteps = (finish: (name: string) => void): { steps: IStep[]; beforeClose: () => Promise<boolean> } => {
166
+ let source = 'manual';
167
+ const read = { name: '', email: '' };
168
+ const create = { name: 'Create contact', action: async (stepper?: DeesStepper) => { finish(read.name); await stepper?.destroy(); } };
169
+ const collect = (event: CustomEvent<{ data: { name?: string; email?: string } }>) => { Object.assign(read, event.detail.data); };
170
+ const reviewForm = () => html`<dees-form @formData=${collect}>
171
+ <dees-input-text key="name" label="Name" .value=${read.name} required></dees-input-text>
172
+ <dees-input-text key="email" label="Email" .value=${read.email} type="email"></dees-input-text>
173
+ </dees-form>`;
174
+ const review: IStep = {
175
+ title: 'Check the details.',
176
+ description: 'Correct anything that was read wrongly. Nothing is saved until you create the contact.',
177
+ content: reviewForm(),
178
+ menuOptions: [create],
179
+ };
180
+ const reading = (label: string, readDetails: () => void): IStep => ({
181
+ title: 'Reading the details.',
182
+ description: 'This takes a few seconds.',
183
+ countsAsStep: false,
184
+ content: html``,
185
+ progressStep: { label, indeterminate: true, showPercentage: false },
186
+ validationFunc: async (_stepper, _element, signal) => {
187
+ if (!await waitForProgressTick(1800, signal)) return;
188
+ readDetails();
189
+ review.content = reviewForm();
190
+ },
191
+ });
192
+ const flows: Record<string, IStep[]> = {
193
+ manual: [{
194
+ title: 'Enter the details.',
195
+ description: 'Only the name is required. You can add the rest later.',
196
+ content: html`<dees-form @formData=${collect}>
197
+ <dees-input-text key="name" label="Name" placeholder="Northwind Traders GmbH" required></dees-input-text>
198
+ <dees-input-text key="email" label="Email" placeholder="hello@northwind.example" type="email"></dees-input-text>
199
+ </dees-form>`,
200
+ menuOptions: [create],
201
+ }],
202
+ text: [{
203
+ title: 'Paste the text.',
204
+ description: 'A signature, a letterhead or an email: whatever names the contact.',
205
+ content: html`<dees-form>
206
+ <dees-input-textarea key="text" label="Text" .rows=${5} required
207
+ .value=${'Northwind Traders GmbH\nHafenstraße 12, 20457 Hamburg\nhello@northwind.example'}></dees-input-textarea>
208
+ </dees-form>`,
209
+ menuOptions: [{ name: 'Read the details', action: async (stepper) => stepper?.goNext() }],
210
+ }, reading('Reading the text', () => Object.assign(read, { name: 'Northwind Traders GmbH', email: 'hello@northwind.example' })), review],
211
+ website: [{
212
+ title: 'Give the website.',
213
+ description: 'The address of its imprint page, or the website itself.',
214
+ content: html`<dees-form>
215
+ <dees-input-text key="url" label="Imprint address" value="https://northwind.example/imprint" required></dees-input-text>
216
+ </dees-form>`,
217
+ menuOptions: [{ name: 'Read the imprint', action: async (stepper) => stepper?.goNext() }],
218
+ }, reading('Reading the imprint', () => Object.assign(read, { name: 'Northwind Traders GmbH', email: 'imprint@northwind.example' })), review],
219
+ };
220
+ const choose: IStep = {
221
+ title: 'Add a contact.',
222
+ description: 'How do you want to bring in the details?',
223
+ content: html`<dees-form @formData=${(event: CustomEvent<{ data: { source?: string } }>) => { source = event.detail.data.source || source; }}>
224
+ <dees-input-radiogroup key="source" label="Source" labelPosition="none" selectedOption="manual" .options=${[
225
+ { key: 'manual', option: 'Enter the details yourself', description: 'Type the name and whatever else you know.' },
226
+ { key: 'text', option: 'Read them from a text', description: 'Paste a signature or a letterhead; a language model picks out the details.' },
227
+ { key: 'website', option: 'Read them from a website', description: 'Give the address of an imprint page; a language model reads it.' },
228
+ ]}></dees-input-radiogroup>
229
+ </dees-form>`,
230
+ menuOptions: [{ name: 'Continue', action: async (stepper) => {
231
+ if (!stepper) return;
232
+ // The steps after the choice follow it; going back and choosing again replaces them.
233
+ stepper.steps = [choose, ...flows[source]];
234
+ stepper.goNext();
235
+ } }],
236
+ };
237
+ // A reading is not free to repeat: once one is held, cancelling asks first.
238
+ const beforeClose = async () => !read.name
239
+ || DeesModal.confirm({ heading: 'Discard what was read?', question: 'Reading the details again takes another request.', confirmLabel: 'Discard' });
240
+ return { steps: [choose, ...flows.manual], beforeClose };
241
+ };
242
+
156
243
  @customElement('dees-demo-stepper')
157
244
  class DeesDemoStepper extends DeesElement {
158
245
  @property() accessor scenario = 'Standard setup';
159
246
  @property() accessor width = 'Wide';
160
247
  @property() accessor layout = 'Auto';
248
+ @property() accessor card = 'Top';
161
249
  @state() private accessor closed = false;
162
250
  @state() private accessor result = '';
163
251
  private steps = createDemoSteps(false, name => { this.result = `${name} is ready.`; });
252
+ private beforeClose?: () => Promise<boolean>;
164
253
  private overlayStepper?: DeesStepper;
165
254
 
166
255
  public static styles = [themeDefaultStyles, cssManager.defaultStyles, css`
@@ -181,8 +270,12 @@ class DeesDemoStepper extends DeesElement {
181
270
  private reset() {
182
271
  this.result = '';
183
272
  this.closed = false;
273
+ const choice = this.scenario === 'Choice first' ? createChoiceSteps(name => { this.result = `${name} was added.`; }) : null;
274
+ this.beforeClose = choice?.beforeClose;
184
275
  this.steps = this.scenario === 'Lookup'
185
276
  ? createLookupSteps(name => { this.result = `${name} was added.`; })
277
+ : choice
278
+ ? choice.steps
186
279
  : this.scenario === 'Long flow'
187
280
  ? createLongSteps(name => { this.result = `${name} is complete.`; })
188
281
  : createDemoSteps(this.scenario === 'Retry example', name => { this.result = `${name} is ready.`; });
@@ -194,6 +287,7 @@ class DeesDemoStepper extends DeesElement {
194
287
  this.overlayStepper = await DeesStepper.createAndShow({
195
288
  cancelable,
196
289
  layout: this.stepperLayout(),
290
+ cardAlign: this.stepperAlign(),
197
291
  steps: createDemoSteps(this.scenario === 'Retry example', name => { this.result = `${name} is ready.`; }),
198
292
  });
199
293
  }
@@ -202,10 +296,14 @@ class DeesDemoStepper extends DeesElement {
202
296
  return this.layout === 'Horizontal' ? 'horizontal' : this.layout === 'Vertical' ? 'vertical' : 'auto';
203
297
  }
204
298
 
299
+ private stepperAlign(): TStepperCardAlign {
300
+ return this.card === 'Centred' ? 'center' : 'start';
301
+ }
302
+
205
303
  public render() {
206
304
  return html`<div class="toolbar">
207
305
  <dees-input-multitoggle size="sm" label="Demo scenario" labelPosition="none"
208
- .options=${['Standard setup', 'Retry example', 'Lookup', 'Long flow']} .selectedOption=${this.scenario}
306
+ .options=${['Standard setup', 'Retry example', 'Lookup', 'Choice first', 'Long flow']} .selectedOption=${this.scenario}
209
307
  @change=${(event: CustomEvent<{ value: string }>) => { this.scenario = event.detail.value; this.reset(); }}></dees-input-multitoggle>
210
308
  <dees-input-multitoggle size="sm" label="Demo width" labelPosition="none"
211
309
  .options=${['Wide', 'Narrow']} .selectedOption=${this.width}
@@ -213,6 +311,9 @@ class DeesDemoStepper extends DeesElement {
213
311
  <dees-input-multitoggle size="sm" label="Demo layout" labelPosition="none"
214
312
  .options=${['Auto', 'Horizontal', 'Vertical']} .selectedOption=${this.layout}
215
313
  @change=${(event: CustomEvent<{ value: string }>) => { this.layout = event.detail.value; }}></dees-input-multitoggle>
314
+ <dees-input-multitoggle size="sm" label="Demo card" labelPosition="none"
315
+ .options=${['Top', 'Centred']} .selectedOption=${this.card}
316
+ @change=${(event: CustomEvent<{ value: string }>) => { this.card = event.detail.value; }}></dees-input-multitoggle>
216
317
  <div class="actions"><dees-button type="secondary" text="Open overlay" @clicked=${() => this.openOverlay()}></dees-button>
217
318
  <dees-button type="ghost" text="Reset" @clicked=${this.reset}></dees-button></div>
218
319
  </div>
@@ -220,11 +321,12 @@ class DeesDemoStepper extends DeesElement {
220
321
  <dees-icon icon=${this.result ? 'lucide:CircleCheck' : 'lucide:Layers'} iconSize="32"></dees-icon>
221
322
  <h2>${this.result || 'Setup cancelled.'}</h2><p>This example uses local sample data.</p>
222
323
  <dees-button type="secondary" text="Start again" @clicked=${this.reset}></dees-button>
223
- </div>` : html`<dees-stepper .steps=${this.steps} .layout=${this.stepperLayout()} .stepCounter=${this.scenario === 'Lookup' ? 'position' : 'total'} @stepper-close=${() => { this.closed = true; }}></dees-stepper>`}</div>
324
+ </div>` : html`<dees-stepper .steps=${this.steps} .layout=${this.stepperLayout()} .cardAlign=${this.stepperAlign()} .stepCounter=${this.scenario === 'Lookup' ? 'position' : 'total'} .beforeClose=${this.beforeClose} @stepper-close=${() => { this.closed = true; }}></dees-stepper>`}</div>
224
325
  <p class="caption">${this.scenario === 'Retry example' ? 'The first setup attempt pauses with an error. Try again to continue with your saved choices.'
225
326
  : this.scenario === 'Lookup' ? 'The counter says only where you are and the ribbon fades out after it; the lookup is not a step of its own and can be stopped while it runs. Discard asks first, and only Discard waits for the answer.'
327
+ : this.scenario === 'Choice first' ? 'The first step asks how; the steps after it follow the answer. Entering the details takes one more step; reading them from a text or a website reads first and then shows what was read for checking. Cancelling closes at once until something was read, and asks first after that. Centred stands the card in the middle of the stage, as a flow with a tab of its own would.'
226
328
  : this.scenario === 'Long flow' ? 'More steps than the ribbon has room for: it scrolls and keeps the current marker in view. Use a completed marker to go back.'
227
- : 'Move forward, go back with Back or a completed marker in the ribbon, and review your choices. Vertical, and Auto on a narrow surface, show the ribbon as a strip above the steps, and the steps slide sideways.'}</p>
329
+ : 'Move forward, go back with Back or a completed marker in the ribbon, and review your choices. Vertical, and Auto on a narrow surface, show the ribbon as a strip above the steps, and the steps slide sideways. Centred stands the card in the middle of the stage.'}</p>
228
330
  <details><summary class="caption">Completion required</summary>
229
331
  <p class="caption">For a flow that must finish, such as a required update, cancellation can be disabled.</p>
230
332
  <dees-button type="secondary" text="Open required setup" @clicked=${() => this.openOverlay(false)}></dees-button>
@@ -18,6 +18,7 @@ import { zIndexRegistry } from '../../00zindex.js';
18
18
  import { prefersReducedMotion } from '../../00motion.js';
19
19
  import { DeesModal } from '../../00group-overlay/dees-modal/dees-modal.js';
20
20
  import { provideOverlayI18n, type IOverlayI18nOptions } from '../../00overlay.js';
21
+ import { runAction } from '../../00actionerror.js';
21
22
  import type { DeesForm } from '../../00group-form/dees-form/dees-form.js';
22
23
  import '../../00group-feedback/dees-progressbar/dees-progressbar.js';
23
24
  import '../dees-tile/dees-tile.js';
@@ -68,6 +69,13 @@ export type TStepCounter = 'total' | 'position';
68
69
  */
69
70
  export type TStepperLayout = 'auto' | 'horizontal' | 'vertical';
70
71
 
72
+ /**
73
+ * Where the card stands in the stepper's height: `'start'` at an optical
74
+ * offset from the top, `'center'` in the middle, with as much room above it as
75
+ * below.
76
+ */
77
+ export type TStepperCardAlign = 'start' | 'center';
78
+
71
79
  export interface IStep {
72
80
  title: string;
73
81
  description?: string;
@@ -114,6 +122,10 @@ export class DeesStepper extends DeesElement {
114
122
  stepCounter?: TStepCounter;
115
123
  /** How the ribbon and the steps are arranged; see `layout`. */
116
124
  layout?: TStepperLayout;
125
+ /** Where the card stands in the stepper's height; see `cardAlign`. */
126
+ cardAlign?: TStepperCardAlign;
127
+ /** Asked before a cancellation in place of the stepper's own confirmation; see `beforeClose`. */
128
+ beforeClose?: () => boolean | Promise<boolean>;
117
129
  } & IOverlayI18nOptions): Promise<DeesStepper> {
118
130
  const body = document.body;
119
131
  const stepper = new DeesStepper();
@@ -125,6 +137,8 @@ export class DeesStepper extends DeesElement {
125
137
  }
126
138
  if (optionsArg.stepCounter !== undefined) stepper.stepCounter = optionsArg.stepCounter;
127
139
  if (optionsArg.layout !== undefined) stepper.layout = optionsArg.layout;
140
+ if (optionsArg.cardAlign !== undefined) stepper.cardAlign = optionsArg.cardAlign;
141
+ if (optionsArg.beforeClose) stepper.beforeClose = optionsArg.beforeClose;
128
142
  body.append(stepper);
129
143
 
130
144
  // Share overlay ordering with catalog controls opened from this dialog.
@@ -169,6 +183,20 @@ export class DeesStepper extends DeesElement {
169
183
  })
170
184
  accessor cancelable: boolean = true;
171
185
 
186
+ /**
187
+ * Asked before a cancellation the reader triggers — the close control, and
188
+ * in overlay mode Escape and a click on the backdrop — in place of the
189
+ * stepper's own confirmation, synchronously or as a promise. Only `false`
190
+ * keeps the flow open, so a flow that knows what would be lost asks its own
191
+ * question, and one with nothing to lose yet closes at once. A hook that
192
+ * throws or rejects keeps the flow open too, and that failure is announced as
193
+ * a failed action (source `stepper-cancel`) rather than swallowed. While the
194
+ * hook runs, further cancellations are ignored rather than stacked.
195
+ * `destroy()` is not a cancellation and never asks.
196
+ */
197
+ @property({ attribute: false })
198
+ accessor beforeClose: (() => boolean | Promise<boolean>) | undefined;
199
+
172
200
  @property({ type: Number, attribute: false })
173
201
  accessor stepperZIndex: number = 1000;
174
202
 
@@ -193,6 +221,19 @@ export class DeesStepper extends DeesElement {
193
221
  @property({ type: String, reflect: true })
194
222
  accessor layout: TStepperLayout = 'auto';
195
223
 
224
+ /**
225
+ * Where the card stands in the stepper's height, in either layout. `'start'`
226
+ * (default) sets it at an optical offset from the top: a step grows downward,
227
+ * so new content never moves its title. `'center'` centres it, with as much
228
+ * room above it as below and the ribbon at its top edge, as a dialog sits on
229
+ * a page but inside the page's own area: for a flow that has a page or a tab
230
+ * to itself. Each step is centred at its own height, and a step that is
231
+ * leaving fades out where it stood. (Not `align`: on an element, that
232
+ * attribute is the browser's legacy text alignment and would centre the text.)
233
+ */
234
+ @property({ type: String, reflect: true })
235
+ accessor cardAlign: TStepperCardAlign = 'start';
236
+
196
237
  @property({ type: Object, attribute: false })
197
238
  accessor activeForm: DeesForm | null = null;
198
239
 
@@ -268,7 +309,7 @@ export class DeesStepper extends DeesElement {
268
309
  const selectedIndex = this.getIndexOfStep(this.selectedStep);
269
310
  // Back points the way the steps run back: to the inline start, which is the right in a right-to-left page.
270
311
  const backIcon = this.matches(':dir(rtl)') ? 'lucide:ChevronRight' : 'lucide:ChevronLeft';
271
- return html`<div class="stepperSurface" data-layout=${this.getLayout()}>
312
+ return html`<div class="stepperSurface" data-layout=${this.getLayout()} data-align=${this.cardAlign === 'center' ? 'center' : 'start'}>
272
313
  ${this.renderRibbon()}
273
314
  <div class="stage">
274
315
  ${directives.repeat(this.steps.filter((step) => step === this.selectedStep || this.leavingSteps.has(step)), (step) => step, (stepArg) => {
@@ -528,7 +569,8 @@ export class DeesStepper extends DeesElement {
528
569
  if (!changedProperties.has('selectedStep') && !changedProperties.has('steps') && !changedProperties.has('overlay')) return;
529
570
  this.revealCurrentMarker();
530
571
  await this.activateSelectedStep();
531
- if (!this.isConnected) return;
572
+ // Only a change of step moves the focus: new steps around the same one leave it where the reader is.
573
+ if (!this.isConnected || (!changedProperties.has('selectedStep') && !changedProperties.has('overlay'))) return;
532
574
  if (this.overlay || this.shadowRoot?.activeElement) {
533
575
  this.shadowRoot?.querySelector<HTMLElement>('.selected .title')?.focus({ preventScroll: true });
534
576
  }
@@ -752,7 +794,8 @@ export class DeesStepper extends DeesElement {
752
794
  if (!this.isConnected || step !== this.selectedStep) return;
753
795
  await optionArg.action(this);
754
796
  } catch (error) {
755
- if (this.isConnected && step === this.selectedStep) this.stepError = error instanceof Error ? error.message : this.t('stepper.actionFailed');
797
+ // shown on the step, also when it is off the page meanwhile and comes back
798
+ if (step === this.selectedStep) this.stepError = error instanceof Error ? error.message : this.t('stepper.actionFailed');
756
799
  } finally {
757
800
  if (this.actionStep === step) { this.actionPending = false; this.pendingAction = null; this.actionStep = undefined; }
758
801
  }
@@ -910,9 +953,10 @@ export class DeesStepper extends DeesElement {
910
953
 
911
954
  /**
912
955
  * Shown by the backdrop click, Escape and the step header's close control.
913
- * Presents a dees-modal asking the user to confirm cancellation. If they
914
- * confirm, the stepper and window layer are destroyed; otherwise the
915
- * confirm modal is dismissed and the stepper stays open.
956
+ * Asks `beforeClose` when it is set and closes the flow unless it answers
957
+ * `false`. Otherwise presents a dees-modal asking the user to confirm
958
+ * cancellation. If they confirm, the stepper and window layer are destroyed;
959
+ * otherwise the confirm modal is dismissed and the stepper stays open.
916
960
  *
917
961
  * The isConnected check on the cached reference handles the case where the
918
962
  * user dismissed the previous confirm modal by clicking ITS OWN backdrop —
@@ -925,33 +969,48 @@ export class DeesStepper extends DeesElement {
925
969
  if (this.cancelConfirmModal && this.cancelConfirmModal.isConnected) return;
926
970
  this.cancelConfirmModal = undefined;
927
971
  this.cancelRequestPending = true;
928
- try { this.cancelConfirmModal = await DeesModal.createAndShow({
929
- heading: this.t('stepper.cancelHeading'),
930
- width: 'small',
931
- i18n: this.t.i18n,
932
- content: html`<p style="margin: 0;">${this.t('stepper.cancelQuestion')}</p>`,
933
- menuOptions: [
934
- {
935
- name: this.t('stepper.cancelStay'),
936
- action: async (modal) => {
937
- this.cancelConfirmModal = undefined;
938
- await modal!.destroy();
972
+ try {
973
+ if (this.beforeClose) {
974
+ const beforeClose = this.beforeClose;
975
+ let close = false;
976
+ await runAction(
977
+ this,
978
+ { action: beforeClose, source: 'stepper-cancel', ownerElement: this.shadowRoot?.querySelector('dialog') },
979
+ async () => { close = await beforeClose() !== false; },
980
+ );
981
+ if (close) await this.destroy();
982
+ return;
983
+ }
984
+ this.cancelConfirmModal = await DeesModal.createAndShow({
985
+ heading: this.t('stepper.cancelHeading'),
986
+ width: 'small',
987
+ i18n: this.t.i18n,
988
+ content: html`<p style="margin: 0;">${this.t('stepper.cancelQuestion')}</p>`,
989
+ menuOptions: [
990
+ {
991
+ name: this.t('stepper.cancelStay'),
992
+ action: async (modal) => {
993
+ this.cancelConfirmModal = undefined;
994
+ await modal!.destroy();
995
+ },
939
996
  },
940
- },
941
- {
942
- name: this.t('stepper.cancelConfirm'),
943
- action: async (modal) => {
944
- this.cancelConfirmModal = undefined;
945
- await modal!.destroy();
946
- await this.destroy();
997
+ {
998
+ name: this.t('stepper.cancelConfirm'),
999
+ action: async (modal) => {
1000
+ this.cancelConfirmModal = undefined;
1001
+ await modal!.destroy();
1002
+ await this.destroy();
1003
+ },
947
1004
  },
948
- },
949
- ],
950
- });
951
- if (!this.isConnected) await this.cancelConfirmModal.destroy();
952
- } finally { this.cancelRequestPending = false; }
1005
+ ],
1006
+ });
1007
+ if (!this.isConnected) await this.cancelConfirmModal.destroy();
1008
+ } finally {
1009
+ this.cancelRequestPending = false;
1010
+ }
953
1011
  }
954
1012
 
1013
+ /** Closes the flow: the stepper removes itself and fires `stepper-close`. */
955
1014
  public destroy(): Promise<void> {
956
1015
  return this.destroyPromise ??= this.closeAndRemove();
957
1016
  }
@@ -965,8 +1024,15 @@ export class DeesStepper extends DeesElement {
965
1024
  await Promise.allSettled(leaving.flatMap(element => element.getAnimations()).map(animation => animation.finished));
966
1025
  this.shadowRoot?.querySelector('dialog')?.close();
967
1026
  this.remove();
1027
+ this.dispatchEvent(new CustomEvent('stepper-close', { bubbles: true, composed: true }));
968
1028
  }
969
1029
 
1030
+ /**
1031
+ * Leaving the page is not closing the flow: an inline stepper the page takes
1032
+ * out and puts back (a tab switched away and back) keeps its steps, what was
1033
+ * entered and a running action, and fires no `stepper-close`. Its step's work
1034
+ * is aborted here and starts again when it returns.
1035
+ */
970
1036
  public async disconnectedCallback() {
971
1037
  this.selectedStep?.abortController?.abort();
972
1038
  if (this.selectedStep) this.selectedStep.validationFuncCalled = false;
@@ -978,12 +1044,8 @@ export class DeesStepper extends DeesElement {
978
1044
  this.activeFormSubscription?.unsubscribe();
979
1045
  this.activeFormSubscription = undefined;
980
1046
  this.activeForm = null;
981
- this.actionPending = false;
982
- this.pendingAction = null;
983
- this.actionStep = undefined;
984
1047
  this.progressRunning = false;
985
1048
  zIndexRegistry.unregister(this);
986
- this.dispatchEvent(new CustomEvent('stepper-close', { bubbles: true, composed: true }));
987
1049
  await super.disconnectedCallback();
988
1050
  }
989
1051
  }