@ds-gn/ui 0.9.0 → 0.11.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 (84) hide show
  1. package/README.md +4 -4
  2. package/custom-elements.json +5527 -2136
  3. package/dist/common/controllers/OverlayDismissController.d.ts +52 -0
  4. package/dist/common/controllers/OverlayPositionController.d.ts +168 -0
  5. package/dist/common/controllers/RovingFocusController.d.ts +99 -0
  6. package/dist/common/controllers/SectionEntranceController.d.ts +37 -0
  7. package/dist/common/helpers/field-control.d.ts +35 -0
  8. package/dist/common/helpers/listbox-navigation.d.ts +50 -0
  9. package/dist/common/props/size/size.props.d.ts +11 -0
  10. package/dist/common/styles/overlay-panel.styles.d.ts +55 -0
  11. package/dist/components/Button/src/Button.d.ts +20 -0
  12. package/dist/components/Button/src/Button.js +28 -0
  13. package/dist/components/Container/src/Container.d.ts +10 -0
  14. package/dist/components/Container/src/Container.js +148 -23
  15. package/dist/components/DropdownMenu/src/DropdownMenu.d.ts +150 -0
  16. package/dist/components/DropdownMenu/src/DropdownMenu.js +1550 -0
  17. package/dist/components/DropdownMenu/src/DropdownMenu.playground.d.ts +2 -0
  18. package/dist/components/DropdownMenu/src/DropdownMenu.props.d.ts +47 -0
  19. package/dist/components/DropdownMenu/src/DropdownMenu.props.js +54 -0
  20. package/dist/components/DropdownMenu/src/DropdownMenu.styles.d.ts +20 -0
  21. package/dist/components/Field/src/Field.d.ts +39 -0
  22. package/dist/components/Field/src/Field.js +203 -0
  23. package/dist/components/Field/src/Field.playground.d.ts +2 -0
  24. package/dist/components/Field/src/Field.styles.d.ts +6 -0
  25. package/dist/components/Icon/src/Icon.d.ts +5 -0
  26. package/dist/components/Icon/src/Icon.js +3 -0
  27. package/dist/components/Icon/src/icons/arrow-down.d.ts +1 -0
  28. package/dist/components/Icon/src/icons/arrow-down.js +6 -0
  29. package/dist/components/Icon/src/icons/arrow-up.d.ts +1 -0
  30. package/dist/components/Icon/src/icons/arrow-up.js +6 -0
  31. package/dist/components/Icon/src/icons/chevrons-up-down.d.ts +1 -0
  32. package/dist/components/Icon/src/icons/chevrons-up-down.js +6 -0
  33. package/dist/components/Icon/src/icons/cookie.d.ts +1 -0
  34. package/dist/components/Icon/src/icons/cookie.js +6 -0
  35. package/dist/components/Icon/src/icons/icon-names.d.ts +1 -1
  36. package/dist/components/Icon/src/icons/icon-names.js +4 -0
  37. package/dist/components/Icon/src/icons/index.d.ts +4 -0
  38. package/dist/components/Icon/src/icons/index.js +4 -0
  39. package/dist/components/Input/src/Input.d.ts +37 -0
  40. package/dist/components/Input/src/Input.js +300 -143
  41. package/dist/components/Input/src/Input.props.d.ts +2 -1
  42. package/dist/components/Input/src/Input.props.js +12 -6
  43. package/dist/components/Input/src/Input.styles.d.ts +12 -4
  44. package/dist/components/Modal/src/Modal.d.ts +1 -0
  45. package/dist/components/Modal/src/Modal.js +1 -0
  46. package/dist/components/Nav/src/Nav.js +2 -1
  47. package/dist/components/NavLink/src/NavLink.d.ts +14 -30
  48. package/dist/components/NavLink/src/NavLink.js +201 -65
  49. package/dist/components/Select/src/Select.d.ts +157 -0
  50. package/dist/components/Select/src/Select.js +1766 -0
  51. package/dist/components/Select/src/Select.playground.d.ts +2 -0
  52. package/dist/components/Select/src/Select.props.d.ts +19 -0
  53. package/dist/components/Select/src/Select.props.js +40 -0
  54. package/dist/components/Select/src/Select.styles.d.ts +30 -0
  55. package/dist/components/Table/src/Table.d.ts +93 -0
  56. package/dist/components/Table/src/Table.js +1105 -0
  57. package/dist/components/Table/src/Table.playground.d.ts +2 -0
  58. package/dist/components/Table/src/Table.props.d.ts +53 -0
  59. package/dist/components/Table/src/Table.props.js +18 -0
  60. package/dist/components/Table/src/Table.styles.d.ts +33 -0
  61. package/dist/components/Toaster/src/Toaster.d.ts +174 -0
  62. package/dist/components/Toaster/src/Toaster.js +1489 -0
  63. package/dist/components/Toaster/src/Toaster.playground.d.ts +2 -0
  64. package/dist/components/Toaster/src/Toaster.props.d.ts +14 -0
  65. package/dist/components/Toaster/src/Toaster.props.js +81 -0
  66. package/dist/components/Toaster/src/Toaster.styles.d.ts +52 -0
  67. package/dist/components/Toaster/src/toast.d.ts +115 -0
  68. package/dist/components/Toaster/src/toast.js +74 -0
  69. package/dist/playground/types.d.ts +27 -0
  70. package/dist/playground-manifest.d.ts +3 -2
  71. package/dist/playground-manifest.js +507 -7
  72. package/dist/react/DropdownMenu.d.ts +8 -0
  73. package/dist/react/DropdownMenu.js +13 -0
  74. package/dist/react/Field.d.ts +6 -0
  75. package/dist/react/Field.js +13 -0
  76. package/dist/react/Select.d.ts +8 -0
  77. package/dist/react/Select.js +13 -0
  78. package/dist/react/Table.d.ts +8 -0
  79. package/dist/react/Table.js +13 -0
  80. package/dist/react/Toaster.d.ts +8 -0
  81. package/dist/react/Toaster.js +13 -0
  82. package/dist/react/index.d.ts +6 -0
  83. package/dist/react/index.js +6 -0
  84. package/package.json +52 -2
@@ -0,0 +1,2 @@
1
+ import type { PlaygroundDefinition } from '../../../playground/types.js';
2
+ export declare const playground: PlaygroundDefinition;
@@ -0,0 +1,53 @@
1
+ export declare const tableAlignValues: {
2
+ readonly START: "start";
3
+ readonly END: "end";
4
+ };
5
+ export type TableAlignType = (typeof tableAlignValues)[keyof typeof tableAlignValues];
6
+ export declare const tablePinValues: {
7
+ readonly START: "start";
8
+ readonly NONE: "none";
9
+ };
10
+ export type TablePinType = (typeof tablePinValues)[keyof typeof tablePinValues];
11
+ export declare const tableSortDirectionValues: {
12
+ readonly ASCENDING: "ascending";
13
+ readonly DESCENDING: "descending";
14
+ };
15
+ export type TableSortDirection = (typeof tableSortDirectionValues)[keyof typeof tableSortDirectionValues];
16
+ /** One column of a `dsgn-table`. */
17
+ export interface TableColumn {
18
+ /** Field read from each row, and the column part of a cell slot name. */
19
+ key: string;
20
+ /** Header text. Also the sort button's accessible name. */
21
+ label: string;
22
+ /** Text alignment. Defaults to `end` for numeric columns, `start` otherwise. */
23
+ align?: TableAlignType;
24
+ /** Numbers, dates, sizes and amounts: monospace, tabular figures, end-aligned. */
25
+ numeric?: boolean;
26
+ /** Renders a sort button in the header and sets `aria-sort`. */
27
+ sortable?: boolean;
28
+ /**
29
+ * Renders this column's body cells as `<th scope="row">`. Defaults to the
30
+ * first column when no column sets it.
31
+ */
32
+ rowHeader?: boolean;
33
+ /**
34
+ * Keeps the column visible while the table scrolls sideways. Honoured on the
35
+ * first column only, and defaults to `start` there when it is the row header.
36
+ */
37
+ pin?: TablePinType;
38
+ /** CSS width for the column, e.g. `'140px'`. */
39
+ width?: string;
40
+ /** Keeps the header text for assistive technology but hides it visually. */
41
+ hideLabel?: boolean;
42
+ /** Lets body text wrap. Cells stay on one line by default. */
43
+ wrap?: boolean;
44
+ }
45
+ /** One row of data. Values are read by column `key`. */
46
+ export type TableRow = Record<string, unknown>;
47
+ /** The current sort, owned by the consumer and passed back in. */
48
+ export interface TableSort {
49
+ column: string;
50
+ direction: TableSortDirection;
51
+ }
52
+ /** `detail` of the `dsgn-sort` event. */
53
+ export type TableSortEventDetail = TableSort;
@@ -0,0 +1,18 @@
1
+ // components/Table/src/Table.props.ts
2
+ var tableAlignValues = {
3
+ START: "start",
4
+ END: "end"
5
+ };
6
+ var tablePinValues = {
7
+ START: "start",
8
+ NONE: "none"
9
+ };
10
+ var tableSortDirectionValues = {
11
+ ASCENDING: "ascending",
12
+ DESCENDING: "descending"
13
+ };
14
+ export {
15
+ tableAlignValues,
16
+ tablePinValues,
17
+ tableSortDirectionValues
18
+ };
@@ -0,0 +1,33 @@
1
+ import { type SizeType } from '../../../common/props/size/size.props.js';
2
+ import { type TableAlignType } from './Table.props.js';
3
+ export declare const containerClasses: () => string;
4
+ export declare const captionClasses: () => string;
5
+ export declare const captionTitleClasses: () => string;
6
+ export declare const captionMetaClasses: () => string;
7
+ export declare const frameClasses: () => string;
8
+ export declare const scrollerClasses: () => string;
9
+ export declare const tableClasses: (size: SizeType) => string;
10
+ export declare const headerCellClasses: ({ size, align, sortable, }: {
11
+ size: SizeType;
12
+ align: TableAlignType;
13
+ sortable: boolean;
14
+ }) => string;
15
+ export declare const sortButtonClasses: (size: SizeType, active: boolean) => string;
16
+ export declare const sortIconClasses: (active: boolean) => string;
17
+ export declare const rowClasses: () => string;
18
+ export declare const cellClasses: ({ size, align, numeric, rowHeader, wrap, }: {
19
+ size: SizeType;
20
+ align: TableAlignType;
21
+ numeric: boolean;
22
+ rowHeader: boolean;
23
+ wrap: boolean;
24
+ }) => string;
25
+ export declare const emptyCellClasses: () => string;
26
+ export declare const fadeClasses: (edge: "start" | "end") => string;
27
+ export declare const srOnlyClasses: () => string;
28
+ /**
29
+ * Rules utilities can't express: the last row has no divider, pinned cells
30
+ * need a solid background beneath the sticky offset, and the pinned edge and
31
+ * scroll fades depend on scroll state the component mirrors onto the frame.
32
+ */
33
+ export declare const structuralStyles: import("lit").CSSResult;
@@ -0,0 +1,174 @@
1
+ import '../../../types/global.d.ts';
2
+ import '../../Button/src/Button.js';
3
+ import { type CSSResultGroup } from 'lit';
4
+ import { Base } from '../../../common/Base/Base.js';
5
+ import { type SurfaceType } from '../../../common/props/surface/surface.props.js';
6
+ import { type ToastOptions } from './Toaster.props.js';
7
+ /**
8
+ * The page's notification region. Code anywhere shows a toast with the
9
+ * `toast()` function from `@ds-gn/ui/toast` (or this element's `show()`);
10
+ * mount one toaster per app.
11
+ *
12
+ * **Announcements.** Both live regions — `role="status"` (polite) and
13
+ * `role="alert"` (assertive, errors only) — exist from the moment the toaster
14
+ * connects, so screen readers have registered them before the first message.
15
+ * A toast is announced as "Title. Description." when it becomes visible, not
16
+ * when it is queued. Toasts never take focus.
17
+ *
18
+ * **Queue.** Up to `max-visible` timed toasts show at once; more wait, first in
19
+ * first out, behind a "+N queued" pill, and their timers do not start until
20
+ * they show. Persistent toasts (errors, and anything with `duration: 0`) skip
21
+ * the queue and don't count toward the limit, so they can never stall it.
22
+ *
23
+ * **Timing.** Info and success dismiss after 5s, warning after 7s; errors
24
+ * persist. Hovering or focusing anywhere in the region pauses every timer and
25
+ * fans the stack out.
26
+ *
27
+ * **Top layer.** The region renders into a container this element owns and is
28
+ * shown with `popover="manual"`, above page stacking contexts. A modal
29
+ * `<dialog>` makes everything outside it inert, top layer included, so while a
30
+ * `dsgn-modal` is open the container moves into that modal (its `toaster`
31
+ * slot) and is shown again above it; it moves back when the modal closes.
32
+ *
33
+ * **Copy.** All copy is supplied: the region's `label`, the dismiss button's
34
+ * `dismiss-label`, and the pill's `queued-label` and `paused-label`.
35
+ *
36
+ * @fires dsgn-dismiss - Fired when a toast is dismissed; `detail` is `{ id, reason }`, `reason` one of `timeout`, `close`, `action` or `programmatic`. React: `onDsgnDismiss`.
37
+ *
38
+ * @csspart region - The labelled notification region.
39
+ * @csspart queue - The "+N queued" pill.
40
+ * @csspart list - The stack of toasts.
41
+ * @csspart toast - Each toast's surface.
42
+ * @csspart icon - A toast's variant icon.
43
+ * @csspart title - A toast's title.
44
+ * @csspart description - A toast's description.
45
+ * @csspart links - A toast's row of links.
46
+ * @csspart actions - A toast's row of actions.
47
+ * @csspart action - Each action button.
48
+ * @csspart dismiss - The dismiss button.
49
+ * @csspart progress - The time-remaining bar.
50
+ */
51
+ export declare class Toaster extends Base {
52
+ static styles: CSSResultGroup;
53
+ surface: SurfaceType;
54
+ /** Timed toasts shown at once before the rest queue. */
55
+ maxVisible: number;
56
+ /** Accessible name for the region, e.g. "Notifications". */
57
+ label: string;
58
+ /** Accessible name for each toast's dismiss button. */
59
+ dismissLabel: string;
60
+ /**
61
+ * The pill's text while toasts wait; `{count}` becomes the number waiting,
62
+ * e.g. "+{count} queued". Empty shows just "+N".
63
+ */
64
+ queuedLabel: string;
65
+ /** Added to the pill while the timers are paused, e.g. "paused". */
66
+ pausedLabel: string;
67
+ private _toasts;
68
+ private _hovered;
69
+ private _focused;
70
+ private _polite;
71
+ private _assertive;
72
+ private readonly _motion;
73
+ private readonly _topLayer;
74
+ /** The light-DOM element the region renders into; see "Top layer". */
75
+ private _container?;
76
+ private _containerRoot?;
77
+ /** Open `dsgn-modal`s, innermost last. */
78
+ private _modals;
79
+ /**
80
+ * Announcements held while the live regions settle after a move: a region
81
+ * that has just been inserted can miss a message written in the same frame.
82
+ */
83
+ private _held;
84
+ private _settling;
85
+ private _settleRun;
86
+ /** Show the region again on the next render, above a newer top layer. */
87
+ private _reraise;
88
+ /** Toasts whose entrance runs after the next render. */
89
+ private readonly _entering;
90
+ private _resize?;
91
+ private get _paused();
92
+ /** Show a toast and return its id. */
93
+ show(options: ToastOptions): string;
94
+ /** Dismiss one toast, or every toast (shown and queued) with no id. */
95
+ dismiss(id?: string): void;
96
+ connectedCallback(): void;
97
+ disconnectedCallback(): void;
98
+ willUpdate(changedProperties: Map<string | number | symbol, unknown>): void;
99
+ updated(changedProperties: Map<string | number | symbol, unknown>): void;
100
+ /** The host renders nothing; the region renders into its own container. */
101
+ render(): import("lit").TemplateResult<1>;
102
+ private readonly _handleToastEvent;
103
+ private _handle;
104
+ private _add;
105
+ /**
106
+ * Show what may show: every persistent toast, and queued timed toasts while
107
+ * fewer than `maxVisible` timed toasts are showing.
108
+ */
109
+ private _promote;
110
+ private _reveal;
111
+ private _dismiss;
112
+ private _exit;
113
+ private _remove;
114
+ private _startTimer;
115
+ private _stopTimer;
116
+ private _syncTimers;
117
+ /** Drive the bar from the time left; the timer itself stays authoritative. */
118
+ private _startBar;
119
+ private _handlePointerEnter;
120
+ private _handlePointerLeave;
121
+ private _handleFocusIn;
122
+ private _handleFocusOut;
123
+ /**
124
+ * Dismissing the toast that holds focus removes its buttons, so focus moves
125
+ * to the next toast's dismiss button — the next older, else the next newer —
126
+ * or to the region itself, never to `<body>`.
127
+ */
128
+ private _moveFocusFrom;
129
+ private _announce;
130
+ private _write;
131
+ /** Drop a dismissed toast's text, so browsing the region finds only live ones. */
132
+ private _withdraw;
133
+ private _settle;
134
+ private readonly _handleModalOpen;
135
+ private readonly _handleModalClose;
136
+ /** The innermost open modal still in the document, if any. */
137
+ private _modalHome;
138
+ /** Create the region's container and keep it where it can be reached. */
139
+ private _place;
140
+ /** Into the top layer, above anything shown before it. */
141
+ private _raise;
142
+ /** Shown and leaving toasts, newest first. */
143
+ private _stack;
144
+ private _region;
145
+ private _itemFor;
146
+ private _cardFor;
147
+ /**
148
+ * Place each toast. Collapsed, the front toast sits at the bottom with up to
149
+ * two cards peeking 10px and 20px behind it at 94% and 88%; expanded, the
150
+ * stack fans out with an 8px gap. Toasts that changed place are moved from
151
+ * where they were by the motion engine (it measures the bottom edge, which
152
+ * scaling about the bottom leaves alone), so reduced motion jumps instead.
153
+ */
154
+ private _layout;
155
+ private _renderRegion;
156
+ private _observeCards;
157
+ private _startEntrances;
158
+ private _queueText;
159
+ private _regionTemplate;
160
+ private _toastTemplate;
161
+ private _bodyTemplate;
162
+ /**
163
+ * Its own template, as in DropdownMenu: the icon is the only part, so an
164
+ * engine that drops a child part inside `<svg>` cannot shift the others.
165
+ */
166
+ private _iconTemplate;
167
+ private _actionsTemplate;
168
+ private _linkTemplate;
169
+ }
170
+ declare global {
171
+ interface HTMLElementTagNameMap {
172
+ 'dsgn-toaster': Toaster;
173
+ }
174
+ }