@design.estate/dees-catalog 21.45.0 → 21.46.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.
- package/dist_bundle/bundle.js +262 -72
- package/dist_bundle/bundle.js.map +1 -1
- package/dist_bundle/bundle.js.third-party-notices.json +1 -1
- package/dist_bundle/bundle.js.third-party-notices.txt +1 -1
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-L4Z3DS4M.js → chunk-FCUX4QGD.js} +3 -3
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-Y2OCV2BV.js → chunk-LWT7IIPZ.js} +2 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-L3H6FV4W.js → chunk-VJVZHESI.js} +37 -14
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/chunk-VJVZHESI.js.map +1 -0
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-SOLSWJ7V.js → de-7PGZC4IF.js} +2 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-VDA5LOS7.js → dees-modal-VOIWY235.js} +3 -3
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-SD4GXHX5.js → dees-workspace-terminal-EJRHSZ5F.js} +4 -4
- package/dist_bundle/third-party-notices.md +2 -2
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/elements/00group-appui/dees-appui/dees-appui.d.ts +37 -3
- package/dist_ts_web/elements/00group-appui/dees-appui/dees-appui.js +79 -19
- package/dist_ts_web/elements/00group-input/dees-input-radiogroup/dees-input-radiogroup.d.ts +11 -1
- package/dist_ts_web/elements/00group-input/dees-input-radiogroup/dees-input-radiogroup.demo.js +17 -1
- package/dist_ts_web/elements/00group-input/dees-input-radiogroup/dees-input-radiogroup.js +19 -2
- package/dist_ts_web/elements/00group-layout/dees-stepper/dees-stepper.d.ts +33 -2
- package/dist_ts_web/elements/00group-layout/dees-stepper/dees-stepper.demo.js +92 -13
- package/dist_ts_web/elements/00group-layout/dees-stepper/dees-stepper.js +58 -15
- package/dist_ts_web/elements/00group-layout/dees-stepper/styles.js +31 -2
- package/dist_ts_web/elements/interfaces/appconfig.d.ts +9 -2
- package/package.json +2 -2
- package/readme.md +34 -5
- package/third-party-notices.md +2 -2
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/elements/00group-appui/dees-appui/dees-appui.ts +95 -21
- package/ts_web/elements/00group-appui/dees-appui/readme.md +16 -4
- package/ts_web/elements/00group-input/dees-input-radiogroup/dees-input-radiogroup.demo.ts +20 -0
- package/ts_web/elements/00group-input/dees-input-radiogroup/dees-input-radiogroup.ts +18 -1
- package/ts_web/elements/00group-layout/dees-stepper/dees-stepper.demo.ts +79 -4
- package/ts_web/elements/00group-layout/dees-stepper/dees-stepper.ts +69 -13
- package/ts_web/elements/00group-layout/dees-stepper/styles.ts +32 -1
- package/ts_web/elements/interfaces/appconfig.ts +9 -2
- package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/chunk-L3H6FV4W.js.map +0 -1
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-L4Z3DS4M.js.map → chunk-FCUX4QGD.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-Y2OCV2BV.js.map → chunk-LWT7IIPZ.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-SOLSWJ7V.js.map → de-7PGZC4IF.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-VDA5LOS7.js.map → dees-modal-VOIWY235.js.map} +0 -0
- /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-SD4GXHX5.js.map → dees-workspace-terminal-EJRHSZ5F.js.map} +0 -0
|
@@ -76,10 +76,23 @@ type TNavigationIntent = 'reader' | 'system';
|
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* How a navigation meets the browser's history: `push` adds an entry, `replace`
|
|
79
|
-
* rewrites the current one,
|
|
80
|
-
*
|
|
79
|
+
* rewrites the current one, `return` goes back to the entry before the current
|
|
80
|
+
* one where that shows the screen and replaces the current one elsewhere, and
|
|
81
|
+
* `traverse` follows a move the browser already made itself — Back, Forward,
|
|
82
|
+
* an edited address.
|
|
81
83
|
*/
|
|
82
|
-
type TNavigationMode = 'push' | 'replace' | 'traverse';
|
|
84
|
+
type TNavigationMode = 'push' | 'replace' | 'return' | 'traverse';
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The shell's mark on a history entry it wrote: whose it is, where it stands,
|
|
88
|
+
* its number, and for an entry pushed, the number of the entry before it.
|
|
89
|
+
*/
|
|
90
|
+
interface IHistoryMarker {
|
|
91
|
+
owner: string;
|
|
92
|
+
index: number;
|
|
93
|
+
entry: number;
|
|
94
|
+
previous?: number;
|
|
95
|
+
}
|
|
83
96
|
|
|
84
97
|
/** A navigation whose screen failed to load, kept so the reader can try it again. */
|
|
85
98
|
interface IFailedNavigation {
|
|
@@ -2494,7 +2507,9 @@ export class DeesAppui extends DeesElement {
|
|
|
2494
2507
|
* Navigate to a registered view. The URL follows an accepted activation, and
|
|
2495
2508
|
* `options.history` decides whether that leaves a step behind: `push` (the
|
|
2496
2509
|
* default) adds a history entry, `replace` rewrites the current one, which is
|
|
2497
|
-
* what a screen correcting its own route needs
|
|
2510
|
+
* what a screen correcting its own route needs, and `return` goes back to the
|
|
2511
|
+
* screen a step was taken from, where the entry before the current one shows
|
|
2512
|
+
* it, and replaces the current entry elsewhere.
|
|
2498
2513
|
*/
|
|
2499
2514
|
public navigateToView(
|
|
2500
2515
|
viewId: string,
|
|
@@ -2502,9 +2517,10 @@ export class DeesAppui extends DeesElement {
|
|
|
2502
2517
|
query: Record<string, string> = {},
|
|
2503
2518
|
options?: interfaces.IViewNavigationOptions,
|
|
2504
2519
|
): Promise<boolean> {
|
|
2505
|
-
const mode = options?.history === 'replace'
|
|
2520
|
+
const mode = options?.history === 'replace' || options?.history === 'return' ? options.history : 'push';
|
|
2506
2521
|
// A replacing navigation is a screen correcting its own route: nobody asked
|
|
2507
|
-
// to be taken anywhere, so the focus stays where the reader put it.
|
|
2522
|
+
// to be taken anywhere, so the focus stays where the reader put it. A return
|
|
2523
|
+
// takes the reader back, as Back does.
|
|
2508
2524
|
return this.queueNavigation(viewId, { ...params }, { ...query }, mode, mode === 'replace' ? 'system' : 'reader');
|
|
2509
2525
|
}
|
|
2510
2526
|
|
|
@@ -2514,6 +2530,10 @@ export class DeesAppui extends DeesElement {
|
|
|
2514
2530
|
private latestNavigationRequest = 0;
|
|
2515
2531
|
private historyOwner = '';
|
|
2516
2532
|
private historyIndex = 0;
|
|
2533
|
+
/** Numbers the history entries this shell writes, so an entry it pushes can name the one it was pushed from. */
|
|
2534
|
+
private historyEntries = 0;
|
|
2535
|
+
/** The location each history entry this shell wrote shows, by the entry's number: what a return finds before it (`returnsBack`). */
|
|
2536
|
+
private historyEntryLocations = new Map<number, string>();
|
|
2517
2537
|
/** The traversal back a refused browser change started, to `location`; the next change of any address ends it. */
|
|
2518
2538
|
private restoringHistory?: { location: string; resolve: () => void };
|
|
2519
2539
|
|
|
@@ -2582,8 +2602,8 @@ export class DeesAppui extends DeesElement {
|
|
|
2582
2602
|
this.markViewInMainMenu(viewId);
|
|
2583
2603
|
if (mode !== 'push') {
|
|
2584
2604
|
this.historyIndex = index ?? this.historyIndex;
|
|
2585
|
-
if (mode === 'replace' || this.addressing.currentLocation() === traversalLocation)
|
|
2586
|
-
window.history.replaceState(this.routeHistoryState(), '', this.addressing.entryLocation(location));
|
|
2605
|
+
if (mode === 'replace' || mode === 'return' || this.addressing.currentLocation() === traversalLocation)
|
|
2606
|
+
window.history.replaceState(this.routeHistoryState(location), '', this.addressing.entryLocation(location));
|
|
2587
2607
|
}
|
|
2588
2608
|
return true;
|
|
2589
2609
|
}
|
|
@@ -2642,12 +2662,14 @@ export class DeesAppui extends DeesElement {
|
|
|
2642
2662
|
}
|
|
2643
2663
|
if (mode === 'push') {
|
|
2644
2664
|
this.historyIndex++;
|
|
2645
|
-
window.history.pushState(this.routeHistoryState(), '', location);
|
|
2665
|
+
window.history.pushState(this.routeHistoryState(location, true), '', location);
|
|
2666
|
+
} else if (mode === 'return' && this.returnsBack(location)) {
|
|
2667
|
+
await this.goBackTo(location);
|
|
2646
2668
|
} else {
|
|
2647
2669
|
if (index !== undefined) this.historyIndex = index;
|
|
2648
2670
|
// Traversal already moved the browser. Do not overwrite a newer queued traversal.
|
|
2649
|
-
if (mode === 'replace' || this.addressing.currentLocation() === traversalLocation) {
|
|
2650
|
-
window.history.replaceState(this.routeHistoryState(), '', this.addressing.entryLocation(location));
|
|
2671
|
+
if (mode === 'replace' || mode === 'return' || this.addressing.currentLocation() === traversalLocation) {
|
|
2672
|
+
window.history.replaceState(this.routeHistoryState(location), '', this.addressing.entryLocation(location));
|
|
2651
2673
|
}
|
|
2652
2674
|
}
|
|
2653
2675
|
return true;
|
|
@@ -2692,13 +2714,16 @@ export class DeesAppui extends DeesElement {
|
|
|
2692
2714
|
* Ask again for the screen that failed to load, as the reader who pressed
|
|
2693
2715
|
* Retry: the same view, parameters and query. History is written the way the
|
|
2694
2716
|
* failed request would have left it: onto the current entry for a replace, or
|
|
2695
|
-
* while the address still shows the attempted route;
|
|
2696
|
-
*
|
|
2717
|
+
* while the address still shows the attempted route; back to the entry before
|
|
2718
|
+
* for a return that may still go there; as a new entry otherwise, which is
|
|
2719
|
+
* also where a rolled-back traversal left the reader.
|
|
2697
2720
|
*/
|
|
2698
2721
|
private retryFailedNavigation(): void {
|
|
2699
2722
|
const failed = this.failedNavigation;
|
|
2700
2723
|
if (!failed) return;
|
|
2701
|
-
const mode = failed.mode === 'replace' || this.addressing.currentLocation() === failed.location
|
|
2724
|
+
const mode = failed.mode === 'replace' || this.addressing.currentLocation() === failed.location
|
|
2725
|
+
? 'replace'
|
|
2726
|
+
: failed.mode === 'return' ? 'return' : 'push';
|
|
2702
2727
|
void this.queueNavigation(failed.view.id, failed.params, failed.query, mode, 'reader');
|
|
2703
2728
|
}
|
|
2704
2729
|
|
|
@@ -2724,8 +2749,27 @@ export class DeesAppui extends DeesElement {
|
|
|
2724
2749
|
});
|
|
2725
2750
|
}
|
|
2726
2751
|
|
|
2727
|
-
|
|
2728
|
-
|
|
2752
|
+
/**
|
|
2753
|
+
* The state of a history entry the shell writes, showing a location: where the
|
|
2754
|
+
* entry stands (`historyIndex`) and a number of its own. An entry pushed also
|
|
2755
|
+
* names the entry it was pushed from, the one right before it; one rewritten
|
|
2756
|
+
* keeps its number and the entry before it. The location an entry shows is
|
|
2757
|
+
* kept by its number, so a return can tell what the entry before shows
|
|
2758
|
+
* (`returnsBack`).
|
|
2759
|
+
*/
|
|
2760
|
+
private routeHistoryState(locationArg?: string, pushedArg = false) {
|
|
2761
|
+
const current = this.historyMarker();
|
|
2762
|
+
const entry = pushedArg || !current ? ++this.historyEntries : current.entry;
|
|
2763
|
+
const previous = pushedArg ? current?.entry : current?.previous;
|
|
2764
|
+
if (locationArg !== undefined) this.historyEntryLocations.set(entry, locationArg);
|
|
2765
|
+
const marker: IHistoryMarker = { owner: this.historyOwner, index: this.historyIndex, entry, previous };
|
|
2766
|
+
return { ...window.history.state, deesAppui: marker };
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
/** This shell's marker on the entry the browser stands on; absent on an entry this shell never wrote. */
|
|
2770
|
+
private historyMarker(): IHistoryMarker | undefined {
|
|
2771
|
+
const marker = window.history.state?.deesAppui as IHistoryMarker | undefined;
|
|
2772
|
+
return marker?.owner === this.historyOwner ? marker : undefined;
|
|
2729
2773
|
}
|
|
2730
2774
|
|
|
2731
2775
|
/**
|
|
@@ -2733,10 +2777,9 @@ export class DeesAppui extends DeesElement {
|
|
|
2733
2777
|
* this shell's marker on the entry, absent on an entry this shell never wrote.
|
|
2734
2778
|
*/
|
|
2735
2779
|
private browserPosition(): { location: string; index?: number } {
|
|
2736
|
-
const marker = window.history.state?.deesAppui as { owner?: string; index?: number } | undefined;
|
|
2737
2780
|
return {
|
|
2738
2781
|
location: this.addressing.currentLocation(),
|
|
2739
|
-
index:
|
|
2782
|
+
index: this.historyMarker()?.index,
|
|
2740
2783
|
};
|
|
2741
2784
|
}
|
|
2742
2785
|
|
|
@@ -2745,6 +2788,37 @@ export class DeesAppui extends DeesElement {
|
|
|
2745
2788
|
return current.location !== positionArg.location || current.index !== positionArg.index;
|
|
2746
2789
|
}
|
|
2747
2790
|
|
|
2791
|
+
/**
|
|
2792
|
+
* Whether a return to a location goes back: the browser stands where this
|
|
2793
|
+
* shell is, on an entry it pushed, and the entry that one was pushed from —
|
|
2794
|
+
* the one right before it — still shows the location. An entry the shell did
|
|
2795
|
+
* not push from one of its own, such as the first one after a reload or a deep
|
|
2796
|
+
* link into a flow, has no entry before it the shell knows, so a return from it
|
|
2797
|
+
* replaces. So does one whose address shows the location already: going back
|
|
2798
|
+
* from it would change no address, and no change would say it landed.
|
|
2799
|
+
*/
|
|
2800
|
+
private returnsBack(locationArg: string): boolean {
|
|
2801
|
+
const marker = this.historyMarker();
|
|
2802
|
+
return marker?.index === this.historyIndex
|
|
2803
|
+
&& marker.previous !== undefined
|
|
2804
|
+
&& this.historyEntryLocations.get(marker.previous) === locationArg
|
|
2805
|
+
&& this.addressing.currentLocation() !== locationArg;
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
/**
|
|
2809
|
+
* Goes back one entry, to the location of the screen already on show, and
|
|
2810
|
+
* waits until the browser stands there, so no request writes history from
|
|
2811
|
+
* the entry it leaves. The change the browser brings finds that location
|
|
2812
|
+
* and is not taken as a move of the reader's (`restoringHistory`).
|
|
2813
|
+
*/
|
|
2814
|
+
private goBackTo(locationArg: string): Promise<void> {
|
|
2815
|
+
this.historyIndex--;
|
|
2816
|
+
return new Promise<void>((resolve) => {
|
|
2817
|
+
this.restoringHistory = { location: locationArg, resolve };
|
|
2818
|
+
window.history.back();
|
|
2819
|
+
});
|
|
2820
|
+
}
|
|
2821
|
+
|
|
2748
2822
|
/**
|
|
2749
2823
|
* Get the current view
|
|
2750
2824
|
*/
|
|
@@ -2959,6 +3033,7 @@ export class DeesAppui extends DeesElement {
|
|
|
2959
3033
|
this.failedNavigation = undefined;
|
|
2960
3034
|
this.historyOwner = `${Date.now()}-${Math.random()}`;
|
|
2961
3035
|
this.historyIndex = 0;
|
|
3036
|
+
this.historyEntryLocations.clear();
|
|
2962
3037
|
}
|
|
2963
3038
|
|
|
2964
3039
|
/** Follow the address: mark the entry the shell stands on, listen for its changes, show the first screen. */
|
|
@@ -3064,8 +3139,7 @@ export class DeesAppui extends DeesElement {
|
|
|
3064
3139
|
if (location !== addressing.currentLocation()) return;
|
|
3065
3140
|
const route = addressing.routeOf(new URL(window.location.href));
|
|
3066
3141
|
if (route === undefined) return;
|
|
3067
|
-
const
|
|
3068
|
-
const index = marker?.owner === this.historyOwner ? marker.index : this.historyIndex + 1;
|
|
3142
|
+
const index = this.historyMarker()?.index ?? this.historyIndex + 1;
|
|
3069
3143
|
if (location === this.activeLocation) {
|
|
3070
3144
|
this.historyIndex = index;
|
|
3071
3145
|
return;
|
|
@@ -3086,7 +3160,7 @@ export class DeesAppui extends DeesElement {
|
|
|
3086
3160
|
this.restoringHistory = { location: this.activeLocation, resolve };
|
|
3087
3161
|
window.history.go(distance);
|
|
3088
3162
|
});
|
|
3089
|
-
} else window.history.replaceState(this.routeHistoryState(), '', this.addressing.entryLocation(this.activeLocation));
|
|
3163
|
+
} else window.history.replaceState(this.routeHistoryState(this.activeLocation), '', this.addressing.entryLocation(this.activeLocation));
|
|
3090
3164
|
return false;
|
|
3091
3165
|
});
|
|
3092
3166
|
// A cancelled browser traversal must finish restoring before accepting another request.
|
|
@@ -1467,8 +1467,20 @@ A fourth argument decides what the navigation leaves behind:
|
|
|
1467
1467
|
`navigateToView(viewId, params, query, { history: 'replace' })` rewrites the current
|
|
1468
1468
|
history entry instead of adding one, which is what a screen correcting its own route — a
|
|
1469
1469
|
redirect to a default section, a normalized identifier — needs so that Back still returns
|
|
1470
|
-
to the screen the reader came from. `
|
|
1471
|
-
the
|
|
1470
|
+
to the screen the reader came from. `{ history: 'return' }` ends a step the reader took
|
|
1471
|
+
from the screen asked for — a flow opened from a list that goes back to it once it is done
|
|
1472
|
+
or closed: when the entry before the current one shows that screen, the shell goes back to
|
|
1473
|
+
it, so the flow's entry stays only as Forward and Back leaves the list rather than showing
|
|
1474
|
+
it once more; otherwise, as after a reload or a deep link into the flow, it replaces the
|
|
1475
|
+
current entry. `navigateToUrl(href, { history })` takes the same options. Unset, both
|
|
1476
|
+
push, as they always have.
|
|
1477
|
+
|
|
1478
|
+
```typescript
|
|
1479
|
+
// The list opens the flow as a step of its own…
|
|
1480
|
+
await appui.navigateToView('invoice', { id: 'new' });
|
|
1481
|
+
// …and the flow, once done or closed, goes back to the list it was opened from.
|
|
1482
|
+
await appui.navigateToView('invoices', {}, {}, { history: 'return' });
|
|
1483
|
+
```
|
|
1472
1484
|
|
|
1473
1485
|
A guard that returns a string asks a question, and the shell asks it in a `dees-modal`
|
|
1474
1486
|
with **Stay** and **Leave** and awaits the answer, rather than opening the browser's own
|
|
@@ -1517,8 +1529,8 @@ appui.configure({
|
|
|
1517
1529
|
entry); a final slash names the same screen as the path without it. `createViewUrl()`
|
|
1518
1530
|
builds these URLs, `navigateToUrl()` accepts them, and `getCurrentRoute()`, guards,
|
|
1519
1531
|
`notFoundView`, `restoreLastView`, the location field and the tray work as in hash mode.
|
|
1520
|
-
- **History.** A navigation pushes (or, with `{ history: 'replace' }`, replaces
|
|
1521
|
-
once its view is accepted; Back and Forward arrive as `popstate` and go through the same
|
|
1532
|
+
- **History.** A navigation pushes (or, with `{ history: 'replace' }`, replaces; with
|
|
1533
|
+
`{ history: 'return' }`, goes back to or replaces) the path once its view is accepted; Back and Forward arrive as `popstate` and go through the same
|
|
1522
1534
|
guards, so a refused traversal is undone. A reload or a deep link opens the screen its
|
|
1523
1535
|
path names.
|
|
1524
1536
|
- **Links.** A plain click on an `<a href>` inside the shell — a view's shadow tree included
|
|
@@ -9,6 +9,15 @@ const imports = [
|
|
|
9
9
|
{ key: 'website', option: 'Read them from a website', description: 'Give the address of an imprint page; a language model reads it.' },
|
|
10
10
|
];
|
|
11
11
|
|
|
12
|
+
const facts = [
|
|
13
|
+
{ key: 'business_start', option: 'Business start', description: 'The day the business opened; its first fiscal year begins on it.' },
|
|
14
|
+
{ key: 'legal_form', option: 'Legal form', description: 'The legal form from a day on, with the register entry where there is one.' },
|
|
15
|
+
{ key: 'bookkeeping_duty', option: 'Duty to keep books', description: 'From when the books are kept as a merchant\'s, and why.' },
|
|
16
|
+
{ key: 'profit_method', option: 'Profit method', description: 'Whether the profit is found by comparing assets or by income over expenses.' },
|
|
17
|
+
{ key: 'fiscal_year', option: 'Fiscal year', description: 'The day and month the fiscal years start on, from a year on.' },
|
|
18
|
+
{ key: 'accrual_waiver', option: 'Accrual waiver', description: 'That accruals are waived from a year on, where the law allows it.' },
|
|
19
|
+
];
|
|
20
|
+
|
|
12
21
|
const sections = html`
|
|
13
22
|
${demoSection('Choices that explain themselves',
|
|
14
23
|
'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.',
|
|
@@ -29,6 +38,17 @@ const sections = html`
|
|
|
29
38
|
${demoOutput('Chosen: text')}
|
|
30
39
|
${demoCode('<p>How do you want to add the contact?</p>\n<dees-input-radiogroup aria-label="How do you want to add the contact?" .options=${options}></dees-input-radiogroup>')}
|
|
31
40
|
`)}
|
|
41
|
+
${demoSection('In a scrolled container',
|
|
42
|
+
'A step\'s body or a dialog that scrolls: scroll down and press the last option\'s label or description. The press focuses that option where it stands, so the container stays put and the click chooses the option pressed, whatever option holds the group\'s tab stop.',
|
|
43
|
+
html`
|
|
44
|
+
<div style="max-height: calc(var(--dees-control-height-lg) * 4); overflow: auto; overscroll-behavior: contain;">
|
|
45
|
+
<dees-input-radiogroup key="fact" aria-label="Which fact holds from a day on?" .options=${facts} required
|
|
46
|
+
@change=${(event: Event) => showDemoResult(event.currentTarget as Element,
|
|
47
|
+
`Chosen: ${(event.currentTarget as DeesInputRadiogroup).selectedOption}`)}></dees-input-radiogroup>
|
|
48
|
+
</div>
|
|
49
|
+
${demoOutput('Nothing chosen yet.')}
|
|
50
|
+
${demoCode('<div style="max-height: …; overflow: auto">\n <dees-input-radiogroup required .options=${facts}></dees-input-radiogroup>\n</div>')}
|
|
51
|
+
`)}
|
|
32
52
|
`;
|
|
33
53
|
|
|
34
54
|
export const demoFunc = () => focusedInputDemo('radiogroup', sections);
|
|
@@ -261,7 +261,8 @@ export class DeesInputRadiogroup extends DeesInputBase<string | object> {
|
|
|
261
261
|
* option, or the first while nothing is chosen. The arrow keys move the
|
|
262
262
|
* choice with the focus and wrap; Space chooses the focused option. Enter is
|
|
263
263
|
* the form's, as in a native radio group: it moves to the next field or
|
|
264
|
-
* submits from the last.
|
|
264
|
+
* submits from the last. A press on an option focuses that option's own
|
|
265
|
+
* circle, where it is (`focusPressedOption`).
|
|
265
266
|
*/
|
|
266
267
|
public render(): TemplateResult {
|
|
267
268
|
const keys = this.options.map((option) => this.getOptionKey(option));
|
|
@@ -283,6 +284,7 @@ export class DeesInputRadiogroup extends DeesInputBase<string | object> {
|
|
|
283
284
|
return html`
|
|
284
285
|
<div
|
|
285
286
|
class="radio-option ${isSelected ? 'selected' : ''} ${optionDescription ? 'described' : ''}"
|
|
287
|
+
@mousedown="${(e: MouseEvent) => this.focusPressedOption(e, optionKey)}"
|
|
286
288
|
@click="${() => this.selectOption(optionKey)}"
|
|
287
289
|
@keydown="${(e: KeyboardEvent) => this.handleKeydown(e, optionKey)}"
|
|
288
290
|
>
|
|
@@ -386,6 +388,21 @@ export class DeesInputRadiogroup extends DeesInputBase<string | object> {
|
|
|
386
388
|
}
|
|
387
389
|
}
|
|
388
390
|
|
|
391
|
+
/**
|
|
392
|
+
* A press on an option, on its circle, label or description, focuses that
|
|
393
|
+
* option's circle without scrolling. Left to the browser, a press on the
|
|
394
|
+
* label or the description would go to the group's tab stop (the input
|
|
395
|
+
* delegates focus, `dees-input-base`), and in a scrolled container that
|
|
396
|
+
* scrolls the tab stop into view: the pressed option moves away before the
|
|
397
|
+
* release, and the click lands beside it.
|
|
398
|
+
*/
|
|
399
|
+
private focusPressedOption(event: MouseEvent, optionKey: string) {
|
|
400
|
+
if (this.disabled) return;
|
|
401
|
+
event.preventDefault();
|
|
402
|
+
const keys = this.options.map((option) => this.getOptionKey(option));
|
|
403
|
+
this.shadowRoot!.querySelectorAll<HTMLElement>('.radio-circle')[keys.indexOf(optionKey)]?.focus({ preventScroll: true });
|
|
404
|
+
}
|
|
405
|
+
|
|
389
406
|
private handleKeydown(event: KeyboardEvent, optionKey: string) {
|
|
390
407
|
if (this.disabled) return;
|
|
391
408
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DeesElement, customElement, property, state, html, css, cssManager } from '@design.estate/dees-element';
|
|
1
|
+
import { DeesElement, customElement, property, state, html, css, cssManager, provideI18n } from '@design.estate/dees-element';
|
|
2
|
+
import * as plugins from '../../00plugins.js';
|
|
2
3
|
import { DeesStepper, type IStep, type TStepperCardAlign, type TStepperLayout } from './dees-stepper.js';
|
|
3
4
|
import { DeesModal } from '../../00group-overlay/dees-modal/dees-modal.js';
|
|
4
5
|
import { themeDefaultStyles } from '../../00theme.js';
|
|
@@ -262,17 +263,78 @@ const createChoiceSteps = (finish: (name: string) => void): { steps: IStep[]; be
|
|
|
262
263
|
return { steps: [choose, ...flows.manual], beforeClose };
|
|
263
264
|
};
|
|
264
265
|
|
|
266
|
+
/**
|
|
267
|
+
* The host's own words, for the refusal of the one-step flow: a catalog of the
|
|
268
|
+
* demo's, defined once when the demo is first shown rather than whenever the
|
|
269
|
+
* stepper is imported.
|
|
270
|
+
*/
|
|
271
|
+
const defineRecordWords = () => {
|
|
272
|
+
const catalog = plugins.smarti18n.defineCatalog({
|
|
273
|
+
namespace: '@design.estate/dees-catalog/demo-stepper',
|
|
274
|
+
source: 'en',
|
|
275
|
+
messages: {
|
|
276
|
+
'record.yearClosed': {
|
|
277
|
+
message: 'The books of {year} are closed, so no change can start in that year. Record it again to start it in the open year.',
|
|
278
|
+
description: 'Why a change cannot start on the day chosen; {year} is a closed year.',
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
catalog.addTranslation(catalog.translation('de', {
|
|
283
|
+
'record.yearClosed': 'Die Bücher für {year} sind abgeschlossen, in diesem Jahr kann keine Änderung beginnen. Erfassen Sie sie erneut, um sie im offenen Jahr beginnen zu lassen.',
|
|
284
|
+
}));
|
|
285
|
+
return catalog;
|
|
286
|
+
};
|
|
287
|
+
let demoRecordWords: ReturnType<typeof defineRecordWords> | undefined;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* A flow of one step, under `ribbon: 'auto'`: its card alone, with no ribbon
|
|
291
|
+
* and no "1 of 1". Record is refused once with an error in the host's words
|
|
292
|
+
* (`refuse`), which follows a change of language while it shows.
|
|
293
|
+
*/
|
|
294
|
+
const createOneStep = (finish: (name: string) => void, refuse: () => Error): IStep[] => {
|
|
295
|
+
let attempts = 0;
|
|
296
|
+
return [{
|
|
297
|
+
title: 'Record a change.',
|
|
298
|
+
description: 'One fact, from the day it holds. Nothing is recorded until you choose Record.',
|
|
299
|
+
content: html`<dees-form>
|
|
300
|
+
<dees-input-radiogroup key="fact" aria-label="Which fact holds from a day on?" selectedOption="small_business" .options=${[
|
|
301
|
+
{ key: 'small_business', option: 'Small business rule', description: 'No VAT is charged on sales from this day on.' },
|
|
302
|
+
{ key: 'cash_basis', option: 'Cash basis', description: 'Income and expenses count on the day they are paid.' },
|
|
303
|
+
{ key: 'business_start', option: 'Business start', description: 'The day the business began.' },
|
|
304
|
+
]}></dees-input-radiogroup>
|
|
305
|
+
</dees-form>`,
|
|
306
|
+
menuOptions: [{ name: 'Record', action: async (stepper) => {
|
|
307
|
+
attempts++;
|
|
308
|
+
if (attempts === 1) throw refuse();
|
|
309
|
+
finish('The change');
|
|
310
|
+
await stepper?.destroy();
|
|
311
|
+
} }],
|
|
312
|
+
}];
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const languages = [{ key: 'en', label: 'English' }, { key: 'de', label: 'Deutsch' }];
|
|
316
|
+
|
|
265
317
|
@customElement('dees-demo-stepper')
|
|
266
318
|
class DeesDemoStepper extends DeesElement {
|
|
267
319
|
@property() accessor scenario = 'Standard setup';
|
|
268
320
|
@property() accessor width = 'Wide';
|
|
269
321
|
@property() accessor layout = 'Auto';
|
|
270
322
|
@property() accessor card = 'Top';
|
|
323
|
+
@state() private accessor language = 'English';
|
|
271
324
|
@state() private accessor closed = false;
|
|
272
325
|
@state() private accessor result = '';
|
|
273
326
|
private steps = createDemoSteps(false, name => { this.result = `${name} is ready.`; });
|
|
274
327
|
private beforeClose?: () => Promise<boolean>;
|
|
275
328
|
private overlayStepper?: DeesStepper;
|
|
329
|
+
/** The language the demo's steppers speak, apart from the page's: their own words follow it, the sample's stay English. */
|
|
330
|
+
private readonly i18n = plugins.smarti18n.createI18n({ locale: 'en', locales: ['en', 'de'] });
|
|
331
|
+
private readonly recordWords = demoRecordWords ??= defineRecordWords();
|
|
332
|
+
|
|
333
|
+
constructor() {
|
|
334
|
+
super();
|
|
335
|
+
// lives with this element: the stepper in its shadow root speaks the demo's language
|
|
336
|
+
provideI18n(this, this.i18n);
|
|
337
|
+
}
|
|
276
338
|
|
|
277
339
|
public static styles = [themeDefaultStyles, cssManager.defaultStyles, css`
|
|
278
340
|
:host { display: block; min-width: 0; }
|
|
@@ -294,7 +356,10 @@ class DeesDemoStepper extends DeesElement {
|
|
|
294
356
|
this.closed = false;
|
|
295
357
|
const choice = this.scenario === 'Choice first' ? createChoiceSteps(name => { this.result = `${name} was added.`; }) : null;
|
|
296
358
|
this.beforeClose = choice?.beforeClose;
|
|
297
|
-
|
|
359
|
+
const words = this.i18n.bind(this.recordWords);
|
|
360
|
+
this.steps = this.scenario === 'One step'
|
|
361
|
+
? createOneStep(name => { this.result = `${name} was recorded.`; }, () => new plugins.smarti18n.LocalizedError(words, 'record.yearClosed', { year: '2025' }))
|
|
362
|
+
: this.scenario === 'Lookup'
|
|
298
363
|
? createLookupSteps(name => { this.result = `${name} was added.`; })
|
|
299
364
|
: choice
|
|
300
365
|
? choice.steps
|
|
@@ -308,6 +373,7 @@ class DeesDemoStepper extends DeesElement {
|
|
|
308
373
|
if (this.overlayStepper?.isConnected) return;
|
|
309
374
|
this.overlayStepper = await DeesStepper.createAndShow({
|
|
310
375
|
cancelable,
|
|
376
|
+
i18n: this.i18n,
|
|
311
377
|
layout: this.stepperLayout(),
|
|
312
378
|
cardAlign: this.stepperAlign(),
|
|
313
379
|
steps: createDemoSteps(this.scenario === 'Retry example', name => { this.result = `${name} is ready.`; }, this.scenario === 'Component step'),
|
|
@@ -322,10 +388,15 @@ class DeesDemoStepper extends DeesElement {
|
|
|
322
388
|
return this.card === 'Centred' ? 'center' : 'start';
|
|
323
389
|
}
|
|
324
390
|
|
|
391
|
+
private async setLanguage(label: string) {
|
|
392
|
+
const locale = languages.find((language) => language.label === label)?.key ?? 'en';
|
|
393
|
+
if (await this.i18n.setLocale(locale)) this.language = label;
|
|
394
|
+
}
|
|
395
|
+
|
|
325
396
|
public render() {
|
|
326
397
|
return html`<div class="toolbar">
|
|
327
398
|
<dees-input-multitoggle size="sm" label="Demo scenario" labelPosition="none"
|
|
328
|
-
.options=${['Standard setup', 'Retry example', 'Component step', 'Lookup', 'Choice first', 'Long flow']} .selectedOption=${this.scenario}
|
|
399
|
+
.options=${['Standard setup', 'Retry example', 'Component step', 'Lookup', 'Choice first', 'Long flow', 'One step']} .selectedOption=${this.scenario}
|
|
329
400
|
@change=${(event: CustomEvent<{ value: string }>) => { this.scenario = event.detail.value; this.reset(); }}></dees-input-multitoggle>
|
|
330
401
|
<dees-input-multitoggle size="sm" label="Demo width" labelPosition="none"
|
|
331
402
|
.options=${['Wide', 'Narrow']} .selectedOption=${this.width}
|
|
@@ -336,6 +407,9 @@ class DeesDemoStepper extends DeesElement {
|
|
|
336
407
|
<dees-input-multitoggle size="sm" label="Demo card" labelPosition="none"
|
|
337
408
|
.options=${['Top', 'Centred']} .selectedOption=${this.card}
|
|
338
409
|
@change=${(event: CustomEvent<{ value: string }>) => { this.card = event.detail.value; }}></dees-input-multitoggle>
|
|
410
|
+
<dees-input-multitoggle size="sm" label="Demo language" labelPosition="none"
|
|
411
|
+
.options=${languages.map((language) => language.label)} .selectedOption=${this.language}
|
|
412
|
+
@change=${(event: CustomEvent<{ value: string }>) => { void this.setLanguage(event.detail.value); }}></dees-input-multitoggle>
|
|
339
413
|
<div class="actions"><dees-button type="secondary" text="Open overlay" @clicked=${() => this.openOverlay()}></dees-button>
|
|
340
414
|
<dees-button type="ghost" text="Reset" @clicked=${this.reset}></dees-button></div>
|
|
341
415
|
</div>
|
|
@@ -343,12 +417,13 @@ class DeesDemoStepper extends DeesElement {
|
|
|
343
417
|
<dees-icon icon=${this.result ? 'lucide:CircleCheck' : 'lucide:Layers'} iconSize="32"></dees-icon>
|
|
344
418
|
<h2>${this.result || 'Setup cancelled.'}</h2><p>This example uses local sample data.</p>
|
|
345
419
|
<dees-button type="secondary" text="Start again" @clicked=${this.reset}></dees-button>
|
|
346
|
-
</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>
|
|
420
|
+
</div>` : html`<dees-stepper .steps=${this.steps} .layout=${this.stepperLayout()} .cardAlign=${this.stepperAlign()} .stepCounter=${this.scenario === 'Lookup' ? 'position' : 'total'} .ribbon=${this.scenario === 'One step' ? 'auto' : 'always'} .beforeClose=${this.beforeClose} @stepper-close=${() => { this.closed = true; }}></dees-stepper>`}</div>
|
|
347
421
|
<p class="caption">${this.scenario === 'Retry example' ? 'The first setup attempt pauses with an error. Try again to continue with your saved choices.'
|
|
348
422
|
: 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.'
|
|
349
423
|
: 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. A text that names no email address or phone number stays on its step: the field says why and takes the focus. 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.'
|
|
350
424
|
: this.scenario === 'Component step' ? 'The first step is a component that draws its form in its own shadow root, as an app\'s step often is. Its required fields still hold Continue, a field that refuses its value says why and takes the focus, and Enter in the last field goes on.'
|
|
351
425
|
: 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.'
|
|
426
|
+
: this.scenario === 'One step' ? 'A flow of one step is its card alone: no ribbon and no "1 of 1", and the card stands in the middle. Record is refused once, in the host\'s own words; switch the language and the refusal follows it. Record again to finish.'
|
|
352
427
|
: '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>
|
|
353
428
|
<details><summary class="caption">Completion required</summary>
|
|
354
429
|
<p class="caption">For a flow that must finish, such as a required update, cancellation can be disabled.</p>
|