@nysds/components 1.19.3 → 1.19.4
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/custom-elements.json +100 -21
- package/dist/.vscode/vscode.html-custom-data.json +3 -3
- package/dist/custom-elements.json +100 -21
- package/dist/{nys-icon.library-ChLRj3i-.js → nys-icon.library-r6nNUTzA.js} +2 -2
- package/dist/{nys-icon.library-ChLRj3i-.js.map → nys-icon.library-r6nNUTzA.js.map} +1 -1
- package/dist/nysds.es.js +2047 -1989
- package/dist/nysds.es.js.map +1 -1
- package/dist/nysds.js +65 -66
- package/dist/nysds.js.map +1 -1
- package/dist/packages/nys-tab/src/nys-tabgroup.d.ts +94 -21
- package/dist/packages/nys-tab/src/nys-tabpanel.d.ts +13 -5
- package/dist/packages/nys-table/src/nys-table.d.ts +9 -1
- package/package.json +1 -1
- package/packages/react/NysTabgroup.d.ts +5 -4
- package/packages/react/NysTable.d.ts +1 -1
- package/packages/react/NysTabpanel.d.ts +11 -4
- package/packages/react/nysds-jsx.d.ts +17 -9
|
@@ -4,9 +4,10 @@ import { LitElement } from "lit";
|
|
|
4
4
|
* elements.
|
|
5
5
|
*
|
|
6
6
|
* Accepts tabs and panels as flat light-DOM children in any order (interleaved
|
|
7
|
-
* or grouped). On slot change,
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* or grouped). On slot change, each child is assigned `slot="tab"` or
|
|
8
|
+
* `slot="panel"` so it is projected into the correct shadow-DOM container
|
|
9
|
+
* while remaining in the light DOM, ARIA relationships are wired, and the
|
|
10
|
+
* first selected (or first) tab is activated.
|
|
10
11
|
*
|
|
11
12
|
* Scroll shadows are rendered on either side of the tab list and toggled via
|
|
12
13
|
* `ResizeObserver` and a `scroll` listener so they accurately reflect whether
|
|
@@ -19,9 +20,10 @@ import { LitElement } from "lit";
|
|
|
19
20
|
*
|
|
20
21
|
* @element nys-tabgroup
|
|
21
22
|
*
|
|
22
|
-
* @slot - Accepts `<nys-tab>` and `<nys-tabpanel>` children.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* @slot - Accepts `<nys-tab>` and `<nys-tabpanel>` children. On `slotchange`
|
|
24
|
+
* they are assigned `slot="tab"` / `slot="panel"` and projected into the
|
|
25
|
+
* tablist and panel containers; they stay in the light DOM. Any other
|
|
26
|
+
* children remain in the default slot, rendered below the panels.
|
|
25
27
|
*
|
|
26
28
|
* @example Basic
|
|
27
29
|
* ```html
|
|
@@ -106,6 +108,47 @@ import { LitElement } from "lit";
|
|
|
106
108
|
* <nys-tabpanel aria-labelledby="tab1">Content for tab 1</nys-tabpanel>
|
|
107
109
|
* </nys-tabgroup>
|
|
108
110
|
* ```
|
|
111
|
+
*
|
|
112
|
+
* @example JS in tabpanel
|
|
113
|
+
* ```html
|
|
114
|
+
* <nys-tabgroup>
|
|
115
|
+
* <nys-tab label="Tab 1"></nys-tab>
|
|
116
|
+
* <nys-tab label="Tab 2"></nys-tab>
|
|
117
|
+
* <nys-tabpanel>
|
|
118
|
+
* <p>Content for tab 1</p>
|
|
119
|
+
* </nys-tabpanel>
|
|
120
|
+
* <nys-tabpanel>
|
|
121
|
+
* <p>Content for tab 2</p>
|
|
122
|
+
* </nys-tabpanel>
|
|
123
|
+
* </nys-tabgroup>
|
|
124
|
+
* <script>
|
|
125
|
+
* const tabgroup = document.querySelector("nys-tabgroup");
|
|
126
|
+
* const panels = tabgroup.querySelectorAll("nys-tabpanel");
|
|
127
|
+
* panels[0].innerHTML += "<p>Added via JS</p>";
|
|
128
|
+
* </script>
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @example Custom Styling
|
|
132
|
+
* ```html
|
|
133
|
+
* <style>
|
|
134
|
+
* nys-tabpanel {
|
|
135
|
+
* --_nys-tabpanel-background-color: var(--nys-color-theme-faint);
|
|
136
|
+
* border: solid 2px var(--nys-color-theme-strong);
|
|
137
|
+
* --nys-button-background-color: var(--nys-color-success);
|
|
138
|
+
* }
|
|
139
|
+
* </style>
|
|
140
|
+
* <nys-tabgroup>
|
|
141
|
+
* <nys-tab label="Tab 1"></nys-tab>
|
|
142
|
+
* <nys-tab label="Tab 2"></nys-tab>
|
|
143
|
+
* <nys-tabpanel>
|
|
144
|
+
* <p>Content for tab 1</p>
|
|
145
|
+
* <nys-button>Click me</nys-button>
|
|
146
|
+
* </nys-tabpanel>
|
|
147
|
+
* <nys-tabpanel>
|
|
148
|
+
* <p>Content for tab 2</p>
|
|
149
|
+
* </nys-tabpanel>
|
|
150
|
+
* </nys-tabgroup>
|
|
151
|
+
* ```
|
|
109
152
|
*/
|
|
110
153
|
export declare class NysTabgroup extends LitElement {
|
|
111
154
|
static styles: import("lit").CSSResult;
|
|
@@ -179,19 +222,42 @@ export declare class NysTabgroup extends LitElement {
|
|
|
179
222
|
*/
|
|
180
223
|
private _updateScrollShadows;
|
|
181
224
|
/**
|
|
182
|
-
* Returns all `<nys-tab>`
|
|
183
|
-
*
|
|
225
|
+
* Returns all `<nys-tab>` light-DOM children in DOM order.
|
|
226
|
+
*
|
|
227
|
+
* Tabs are projected into the shadow-DOM tablist via the `tab` slot but
|
|
228
|
+
* remain light-DOM children of the group, so they stay reachable by consumer
|
|
229
|
+
* CSS and JavaScript.
|
|
184
230
|
*
|
|
185
231
|
* @returns An array of `HTMLElement` references to every `<nys-tab>` child.
|
|
186
232
|
*/
|
|
187
233
|
private _getTabs;
|
|
188
234
|
/**
|
|
189
|
-
* Returns
|
|
190
|
-
*
|
|
235
|
+
* Returns the `<nys-tabpanel>` light-DOM children ordered to align with
|
|
236
|
+
* `_getTabs()` — i.e. `panels[i]` is the panel paired with `tabs[i]`.
|
|
191
237
|
*
|
|
192
|
-
*
|
|
238
|
+
* Pairing honors explicit `aria-labelledby` references first, then falls
|
|
239
|
+
* back to source order for the remaining panels. See {@link _pairPanels}.
|
|
240
|
+
*
|
|
241
|
+
* @returns An array of `HTMLElement` references to every `<nys-tabpanel>`,
|
|
242
|
+
* in tab-paired order.
|
|
193
243
|
*/
|
|
194
244
|
private _getPanels;
|
|
245
|
+
/**
|
|
246
|
+
* Orders `panels` to align 1:1 with `tabs`.
|
|
247
|
+
*
|
|
248
|
+
* A panel is paired with a tab when its `aria-labelledby` matches that tab's
|
|
249
|
+
* `id`; explicit references win over position. Panels without a reference
|
|
250
|
+
* fill the remaining tab slots in source order. Any panels whose reference
|
|
251
|
+
* does not resolve to a tab are appended at the end.
|
|
252
|
+
*
|
|
253
|
+
* Idempotent: after `_applySelection` writes `aria-labelledby` onto every
|
|
254
|
+
* panel, re-running this yields the same order.
|
|
255
|
+
*
|
|
256
|
+
* @param tabs - Ordered `<nys-tab>` elements.
|
|
257
|
+
* @param panels - `<nys-tabpanel>` elements in source order.
|
|
258
|
+
* @returns The panels reordered to tab-paired order.
|
|
259
|
+
*/
|
|
260
|
+
private _pairPanels;
|
|
195
261
|
/**
|
|
196
262
|
* Single source of truth for ARIA wiring, `tabindex`, and panel visibility.
|
|
197
263
|
*
|
|
@@ -212,20 +278,27 @@ export declare class NysTabgroup extends LitElement {
|
|
|
212
278
|
*/
|
|
213
279
|
private _applySelection;
|
|
214
280
|
/**
|
|
215
|
-
* Handles `slotchange`
|
|
281
|
+
* Handles `slotchange` and keeps the tabs/panels wired without ever removing
|
|
282
|
+
* them from the light DOM.
|
|
283
|
+
*
|
|
284
|
+
* Consumers author `<nys-tab>` / `<nys-tabpanel>` as flat children with no
|
|
285
|
+
* `slot` attribute. This assigns `slot="tab"` / `slot="panel"` so each is
|
|
286
|
+
* projected into the correct shadow-DOM container while remaining a
|
|
287
|
+
* light-DOM child of the group (reachable by consumer CSS/JS). Any other
|
|
288
|
+
* children (e.g. a footnote `<p>`) are left untouched in the default slot.
|
|
289
|
+
*
|
|
290
|
+
* Reads all current light-DOM children on every call (rather than a single
|
|
291
|
+
* slot's assigned nodes), so it is robust to dynamic additions/removals and
|
|
292
|
+
* idempotent: setting the `slot` attributes triggers further `slotchange`
|
|
293
|
+
* events, but once the attributes are stable no more mutations occur and the
|
|
294
|
+
* cascade settles.
|
|
216
295
|
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* `.nys-tabgroup__panels`. If a panel has an `aria-labelledby` attribute,
|
|
220
|
-
* it is explicitly paired with the tab it references; otherwise panels are
|
|
221
|
-
* paired with tabs by index order. After sorting, calls `_applySelection`
|
|
222
|
-
* using the first element that already has a `selected` attribute, or
|
|
223
|
-
* index `0` if none is found.
|
|
296
|
+
* After (re)assignment, `_applySelection` is called honoring the first tab
|
|
297
|
+
* that already has a `selected` attribute, or index `0` if none is found.
|
|
224
298
|
*
|
|
225
|
-
* @param e - The `Event` fired by the `<slot>` element on slot change.
|
|
226
299
|
* @returns void
|
|
227
300
|
*/
|
|
228
|
-
private
|
|
301
|
+
private _syncChildren;
|
|
229
302
|
/**
|
|
230
303
|
* Handles the `nys-tab-select` custom event bubbled up from a child
|
|
231
304
|
* `<nys-tab>`.
|
|
@@ -4,14 +4,22 @@ import { LitElement } from "lit";
|
|
|
4
4
|
* `<nys-tabgroup>`.
|
|
5
5
|
*
|
|
6
6
|
* Pairing is determined by render order: the Nth `<nys-tabpanel>` child of a
|
|
7
|
-
* `<nys-tabgroup>` corresponds to the Nth `<nys-tab>` child
|
|
8
|
-
* `aria-labelledby` and the `hidden` attribute are managed
|
|
9
|
-
* `<nys-tabgroup>` via `_applySelection`; do not set them
|
|
7
|
+
* `<nys-tabgroup>` corresponds to the Nth `<nys-tab>` child (or by explicit
|
|
8
|
+
* `aria-labelledby`). `aria-labelledby` and the `hidden` attribute are managed
|
|
9
|
+
* externally by `<nys-tabgroup>` via `_applySelection`; do not set them
|
|
10
|
+
* directly.
|
|
11
|
+
*
|
|
12
|
+
* The panel container is styled from the light DOM (`nys-tabpanel.light.scss`,
|
|
13
|
+
* adopted on the document) rather than a shadow-DOM wrapper. This keeps the
|
|
14
|
+
* slotted panel content in the light DOM — reachable by consumer CSS and
|
|
15
|
+
* JavaScript — and lets consumers override the panel's own styling (e.g.
|
|
16
|
+
* `nys-tabpanel { padding: 0 }`), which a shadow wrapper would prevent.
|
|
10
17
|
*
|
|
11
18
|
* @element nys-tabpanel
|
|
12
19
|
*
|
|
13
|
-
* @slot - Default slot for panel content. Rendered
|
|
14
|
-
*
|
|
20
|
+
* @slot - Default slot for panel content. Rendered directly under the host,
|
|
21
|
+
* which is the scrollable, focusable (`tabindex="0"`) `role="tabpanel"`
|
|
22
|
+
* region.
|
|
15
23
|
*/
|
|
16
24
|
export declare class NysTabpanel extends LitElement {
|
|
17
25
|
static styles: import("lit").CSSResult;
|
|
@@ -3,7 +3,11 @@ import { LitElement } from "lit";
|
|
|
3
3
|
* `<nys-table>` is a responsive table component that can display native HTML tables,
|
|
4
4
|
* supports striped and bordered styling, sortable columns, and CSV download.
|
|
5
5
|
*
|
|
6
|
-
* @slot - Accepts a `<table>` element. Only the first table is
|
|
6
|
+
* @slot - Accepts a `<table>` element. Only the first table is used. The table
|
|
7
|
+
* is enhanced in place and stays in the light DOM (projected through a slot,
|
|
8
|
+
* never cloned), so embedded components remain interactive and reachable by
|
|
9
|
+
* consumer CSS/JS. Its cell styling is applied from `nys-table.light.scss`,
|
|
10
|
+
* adopted once onto `document.adoptedStyleSheets`.
|
|
7
11
|
*
|
|
8
12
|
* @fires nys-click - Fired when the download button or sortable headers are clicked.
|
|
9
13
|
* @fires nys-column-sort - Fired when a sortable column header is clicked. Can be prevented by calling `event.preventDefault()` to override default sort behavior.
|
|
@@ -94,6 +98,7 @@ export declare class NysTable extends LitElement {
|
|
|
94
98
|
private _sortDirection;
|
|
95
99
|
private _captionText;
|
|
96
100
|
private _observer;
|
|
101
|
+
private _enhancing;
|
|
97
102
|
/**************** Lifecycle Methods ****************/
|
|
98
103
|
constructor();
|
|
99
104
|
connectedCallback(): void;
|
|
@@ -101,6 +106,9 @@ export declare class NysTable extends LitElement {
|
|
|
101
106
|
disconnectedCallback(): void;
|
|
102
107
|
willUpdate(): void;
|
|
103
108
|
/******************** Functions ********************/
|
|
109
|
+
private _getSlottedTable;
|
|
110
|
+
private _observeTable;
|
|
111
|
+
private _withObserverPaused;
|
|
104
112
|
private _handleSlotChange;
|
|
105
113
|
private _setupMutationObserver;
|
|
106
114
|
private _normalizeTableDOM;
|
package/package.json
CHANGED
|
@@ -54,9 +54,10 @@ Used for form submission and accessibility purposes. */
|
|
|
54
54
|
* elements.
|
|
55
55
|
*
|
|
56
56
|
* Accepts tabs and panels as flat light-DOM children in any order (interleaved
|
|
57
|
-
* or grouped). On slot change,
|
|
58
|
-
*
|
|
59
|
-
*
|
|
57
|
+
* or grouped). On slot change, each child is assigned `slot="tab"` or
|
|
58
|
+
* `slot="panel"` so it is projected into the correct shadow-DOM container
|
|
59
|
+
* while remaining in the light DOM, ARIA relationships are wired, and the
|
|
60
|
+
* first selected (or first) tab is activated.
|
|
60
61
|
*
|
|
61
62
|
* Scroll shadows are rendered on either side of the tab list and toggled via
|
|
62
63
|
* `ResizeObserver` and a `scroll` listener so they accurately reflect whether
|
|
@@ -70,6 +71,6 @@ Used for form submission and accessibility purposes. */
|
|
|
70
71
|
*
|
|
71
72
|
*
|
|
72
73
|
* ### **Slots:**
|
|
73
|
-
* - _default_ - Accepts `<nys-tab>` and `<nys-tabpanel>` children.
|
|
74
|
+
* - _default_ - Accepts `<nys-tab>` and `<nys-tabpanel>` children. On `slotchange` they are assigned `slot="tab"` / `slot="panel"` and projected into the tablist and panel containers; they stay in the light DOM. Any other children remain in the default slot, rendered below the panels.
|
|
74
75
|
*/
|
|
75
76
|
export const NysTabgroup: React.ForwardRefExoticComponent<NysTabgroupProps>;
|
|
@@ -75,6 +75,6 @@ export interface NysTableProps extends Pick<
|
|
|
75
75
|
* - **nys-column-sort** - Fired when a sortable column header is clicked. Can be prevented by calling `event.preventDefault()` to override default sort behavior. Detail: { columnIndex: number, columnLabel: string, sortDirection: "asc" | "desc" | "none" }
|
|
76
76
|
*
|
|
77
77
|
* ### **Slots:**
|
|
78
|
-
* - _default_ - Accepts a `<table>` element. Only the first table is
|
|
78
|
+
* - _default_ - Accepts a `<table>` element. Only the first table is used. The table is enhanced in place and stays in the light DOM (projected through a slot, never cloned), so embedded components remain interactive and reachable by consumer CSS/JS. Its cell styling is applied from `nys-table.light.scss`, adopted once onto `document.adoptedStyleSheets`.
|
|
79
79
|
*/
|
|
80
80
|
export const NysTable: React.ForwardRefExoticComponent<NysTableProps>;
|
|
@@ -51,13 +51,20 @@ Reflected to the DOM attribute so `aria-controls` references on sibling
|
|
|
51
51
|
* `<nys-tabgroup>`.
|
|
52
52
|
*
|
|
53
53
|
* Pairing is determined by render order: the Nth `<nys-tabpanel>` child of a
|
|
54
|
-
* `<nys-tabgroup>` corresponds to the Nth `<nys-tab>` child
|
|
55
|
-
* `aria-labelledby` and the `hidden` attribute are managed
|
|
56
|
-
* `<nys-tabgroup>` via `_applySelection`; do not set them
|
|
54
|
+
* `<nys-tabgroup>` corresponds to the Nth `<nys-tab>` child (or by explicit
|
|
55
|
+
* `aria-labelledby`). `aria-labelledby` and the `hidden` attribute are managed
|
|
56
|
+
* externally by `<nys-tabgroup>` via `_applySelection`; do not set them
|
|
57
|
+
* directly.
|
|
58
|
+
*
|
|
59
|
+
* The panel container is styled from the light DOM (`nys-tabpanel.light.scss`,
|
|
60
|
+
* adopted on the document) rather than a shadow-DOM wrapper. This keeps the
|
|
61
|
+
* slotted panel content in the light DOM — reachable by consumer CSS and
|
|
62
|
+
* JavaScript — and lets consumers override the panel's own styling (e.g.
|
|
63
|
+
* `nys-tabpanel { padding: 0 }`), which a shadow wrapper would prevent.
|
|
57
64
|
* ---
|
|
58
65
|
*
|
|
59
66
|
*
|
|
60
67
|
* ### **Slots:**
|
|
61
|
-
* - _default_ - Default slot for panel content. Rendered
|
|
68
|
+
* - _default_ - Default slot for panel content. Rendered directly under the host, which is the scrollable, focusable (`tabindex="0"`) `role="tabpanel"` region.
|
|
62
69
|
*/
|
|
63
70
|
export const NysTabpanel: React.ForwardRefExoticComponent<NysTabpanelProps>;
|
|
@@ -1506,9 +1506,10 @@ export type CustomElements = {
|
|
|
1506
1506
|
* elements.
|
|
1507
1507
|
*
|
|
1508
1508
|
* Accepts tabs and panels as flat light-DOM children in any order (interleaved
|
|
1509
|
-
* or grouped). On slot change,
|
|
1510
|
-
*
|
|
1511
|
-
*
|
|
1509
|
+
* or grouped). On slot change, each child is assigned `slot="tab"` or
|
|
1510
|
+
* `slot="panel"` so it is projected into the correct shadow-DOM container
|
|
1511
|
+
* while remaining in the light DOM, ARIA relationships are wired, and the
|
|
1512
|
+
* first selected (or first) tab is activated.
|
|
1512
1513
|
*
|
|
1513
1514
|
* Scroll shadows are rendered on either side of the tab list and toggled via
|
|
1514
1515
|
* `ResizeObserver` and a `scroll` listener so they accurately reflect whether
|
|
@@ -1522,7 +1523,7 @@ export type CustomElements = {
|
|
|
1522
1523
|
*
|
|
1523
1524
|
*
|
|
1524
1525
|
* ### **Slots:**
|
|
1525
|
-
* - _default_ - Accepts `<nys-tab>` and `<nys-tabpanel>` children.
|
|
1526
|
+
* - _default_ - Accepts `<nys-tab>` and `<nys-tabpanel>` children. On `slotchange` they are assigned `slot="tab"` / `slot="panel"` and projected into the tablist and panel containers; they stay in the light DOM. Any other children remain in the default slot, rendered below the panels.
|
|
1526
1527
|
*/
|
|
1527
1528
|
"nys-tabgroup": Partial<NysTabgroupProps & BaseProps & BaseEvents>;
|
|
1528
1529
|
|
|
@@ -1531,14 +1532,21 @@ export type CustomElements = {
|
|
|
1531
1532
|
* `<nys-tabgroup>`.
|
|
1532
1533
|
*
|
|
1533
1534
|
* Pairing is determined by render order: the Nth `<nys-tabpanel>` child of a
|
|
1534
|
-
* `<nys-tabgroup>` corresponds to the Nth `<nys-tab>` child
|
|
1535
|
-
* `aria-labelledby` and the `hidden` attribute are managed
|
|
1536
|
-
* `<nys-tabgroup>` via `_applySelection`; do not set them
|
|
1535
|
+
* `<nys-tabgroup>` corresponds to the Nth `<nys-tab>` child (or by explicit
|
|
1536
|
+
* `aria-labelledby`). `aria-labelledby` and the `hidden` attribute are managed
|
|
1537
|
+
* externally by `<nys-tabgroup>` via `_applySelection`; do not set them
|
|
1538
|
+
* directly.
|
|
1539
|
+
*
|
|
1540
|
+
* The panel container is styled from the light DOM (`nys-tabpanel.light.scss`,
|
|
1541
|
+
* adopted on the document) rather than a shadow-DOM wrapper. This keeps the
|
|
1542
|
+
* slotted panel content in the light DOM — reachable by consumer CSS and
|
|
1543
|
+
* JavaScript — and lets consumers override the panel's own styling (e.g.
|
|
1544
|
+
* `nys-tabpanel { padding: 0 }`), which a shadow wrapper would prevent.
|
|
1537
1545
|
* ---
|
|
1538
1546
|
*
|
|
1539
1547
|
*
|
|
1540
1548
|
* ### **Slots:**
|
|
1541
|
-
* - _default_ - Default slot for panel content. Rendered
|
|
1549
|
+
* - _default_ - Default slot for panel content. Rendered directly under the host, which is the scrollable, focusable (`tabindex="0"`) `role="tabpanel"` region.
|
|
1542
1550
|
*/
|
|
1543
1551
|
"nys-tabpanel": Partial<NysTabpanelProps & BaseProps & BaseEvents>;
|
|
1544
1552
|
|
|
@@ -1553,7 +1561,7 @@ export type CustomElements = {
|
|
|
1553
1561
|
* - **nys-column-sort** - Fired when a sortable column header is clicked. Can be prevented by calling `event.preventDefault()` to override default sort behavior. Detail: { columnIndex: number, columnLabel: string, sortDirection: "asc" | "desc" | "none" }
|
|
1554
1562
|
*
|
|
1555
1563
|
* ### **Slots:**
|
|
1556
|
-
* - _default_ - Accepts a `<table>` element. Only the first table is
|
|
1564
|
+
* - _default_ - Accepts a `<table>` element. Only the first table is used. The table is enhanced in place and stays in the light DOM (projected through a slot, never cloned), so embedded components remain interactive and reachable by consumer CSS/JS. Its cell styling is applied from `nys-table.light.scss`, adopted once onto `document.adoptedStyleSheets`.
|
|
1557
1565
|
*/
|
|
1558
1566
|
"nys-table": Partial<NysTableProps & BaseProps & BaseEvents>;
|
|
1559
1567
|
|