@nysds/components 1.16.1 → 1.18.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/custom-elements.json +4245 -3280
- package/dist/.vscode/vscode.html-custom-data.json +114 -30
- package/dist/custom-elements.json +4245 -3280
- package/dist/nysds.es.js +2550 -1977
- package/dist/nysds.es.js.map +1 -1
- package/dist/nysds.js +186 -164
- package/dist/nysds.js.map +1 -1
- package/dist/packages/nys-backtotop/src/nys-backtotop.d.ts +15 -3
- package/dist/packages/nys-badge/src/nys-badge.d.ts +2 -0
- package/dist/packages/nys-breadcrumbs/src/index.d.ts +1 -0
- package/dist/packages/nys-breadcrumbs/src/nys-breadcrumbs.d.ts +119 -0
- package/dist/packages/nys-breadcrumbs/src/nys-breadcrumbs.figma.d.ts +1 -0
- package/dist/packages/nys-button/src/nys-button.d.ts +2 -2
- package/dist/packages/nys-checkbox/src/nys-checkbox.d.ts +0 -2
- package/dist/packages/nys-checkbox/src/nys-checkboxgroup.d.ts +1 -4
- package/dist/packages/nys-combobox/src/nys-combobox.d.ts +8 -0
- package/dist/packages/nys-datepicker/src/nys-datepicker.d.ts +1 -0
- package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenu.d.ts +3 -1
- package/dist/packages/nys-errormessage/src/nys-errormessage.d.ts +2 -2
- package/dist/packages/nys-label/src/nys-label.d.ts +9 -6
- package/dist/packages/nys-radiobutton/src/nys-radiobutton.d.ts +0 -2
- package/dist/packages/nys-radiobutton/src/nys-radiogroup.d.ts +1 -4
- package/dist/packages/nys-tab/src/index.d.ts +3 -0
- package/dist/packages/nys-tab/src/nys-tab.d.ts +116 -0
- package/dist/packages/nys-tab/src/nys-tab.figma.d.ts +1 -0
- package/dist/packages/nys-tab/src/nys-tabgroup.d.ts +197 -0
- package/dist/packages/nys-tab/src/nys-tabpanel.d.ts +46 -0
- package/dist/packages/nys-table/src/nys-table.d.ts +10 -7
- package/dist/packages/nys-textarea/src/nys-textarea.d.ts +1 -1
- package/dist/packages/nys-textinput/src/nys-textinput.d.ts +2 -1
- package/dist/packages/nys-video/src/nys-video.d.ts +25 -0
- package/dist/src/index.d.ts +2 -0
- package/package.json +3 -2
- package/packages/react/NysBacktotop.d.ts +1 -1
- package/packages/react/NysBadge.d.ts +3 -0
- package/packages/react/NysBadge.js +2 -0
- package/packages/react/NysBreadcrumbItem.d.ts +72 -0
- package/packages/react/NysBreadcrumbItem.js +42 -0
- package/packages/react/NysBreadcrumbs.d.ts +89 -0
- package/packages/react/NysBreadcrumbs.js +50 -0
- package/packages/react/NysButton.d.ts +2 -2
- package/packages/react/NysCheckbox.d.ts +0 -3
- package/packages/react/NysCheckbox.js +0 -2
- package/packages/react/NysCheckboxgroup.d.ts +0 -3
- package/packages/react/NysCheckboxgroup.js +0 -2
- package/packages/react/NysErrorMessage.d.ts +3 -0
- package/packages/react/NysErrorMessage.js +2 -1
- package/packages/react/NysLabel.d.ts +16 -4
- package/packages/react/NysLabel.js +17 -3
- package/packages/react/NysRadiobutton.d.ts +0 -3
- package/packages/react/NysRadiobutton.js +0 -2
- package/packages/react/NysRadiogroup.d.ts +0 -3
- package/packages/react/NysRadiogroup.js +0 -2
- package/packages/react/NysTab.d.ts +90 -0
- package/packages/react/NysTab.js +39 -0
- package/packages/react/NysTabgroup.d.ts +75 -0
- package/packages/react/NysTabgroup.js +22 -0
- package/packages/react/NysTabpanel.d.ts +63 -0
- package/packages/react/NysTabpanel.js +21 -0
- package/packages/react/NysVideo.d.ts +7 -1
- package/packages/react/NysVideo.js +14 -1
- package/packages/react/index.d.ts +4 -0
- package/packages/react/index.js +4 -0
- package/packages/react/nysds-jsx.d.ts +167 -14
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* `<nys-tabgroup>` is the container for `<nys-tab>` and `<nys-tabpanel>`
|
|
4
|
+
* elements.
|
|
5
|
+
*
|
|
6
|
+
* Accepts tabs and panels as flat light-DOM children in any order (interleaved
|
|
7
|
+
* or grouped). On slot change, children are sorted into dedicated shadow-DOM
|
|
8
|
+
* containers, ARIA relationships are wired, and the first selected (or first)
|
|
9
|
+
* tab is activated.
|
|
10
|
+
*
|
|
11
|
+
* Scroll shadows are rendered on either side of the tab list and toggled via
|
|
12
|
+
* `ResizeObserver` and a `scroll` listener so they accurately reflect whether
|
|
13
|
+
* overflow content exists in each direction.
|
|
14
|
+
*
|
|
15
|
+
* Keyboard navigation follows the
|
|
16
|
+
* {@link https://www.w3.org/WAI/ARIA/apg/patterns/tabs/ ARIA Tabs Pattern}:
|
|
17
|
+
* - Arrow keys move focus without changing selection.
|
|
18
|
+
* - Enter / Space confirm selection on the focused tab.
|
|
19
|
+
*
|
|
20
|
+
* @element nys-tabgroup
|
|
21
|
+
*
|
|
22
|
+
* @slot - Accepts `<nys-tab>` and `<nys-tabpanel>` children. Elements are
|
|
23
|
+
* moved into internal shadow-DOM containers on `slotchange`; the slot
|
|
24
|
+
* itself is not rendered visibly.
|
|
25
|
+
*
|
|
26
|
+
* @example Disable a tab using the `disabled` attribute on `<nys-tab>`.
|
|
27
|
+
* ```html
|
|
28
|
+
* <nys-tabgroup name="Account Settings">
|
|
29
|
+
* <nys-tab label="Profile"></nys-tab>
|
|
30
|
+
* <nys-tab label="Security"></nys-tab>
|
|
31
|
+
* <nys-tab label="Notifications" disabled></nys-tab>
|
|
32
|
+
* <nys-tabpanel><p>Manage your profile information.</p></nys-tabpanel>
|
|
33
|
+
* <nys-tabpanel><p>Update your password and 2FA settings.</p></nys-tabpanel>
|
|
34
|
+
* <nys-tabpanel><p>Notification preferences (coming soon).</p></nys-tabpanel>
|
|
35
|
+
* </nys-tabgroup>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example Pre-select a tab using the `selected` attribute on `<nys-tab>`.
|
|
39
|
+
* ```html
|
|
40
|
+
* <nys-tabgroup name="Reports">
|
|
41
|
+
* <nys-tab label="Summary"></nys-tab>
|
|
42
|
+
* <nys-tab label="Details" selected></nys-tab>
|
|
43
|
+
* <nys-tabpanel><p>Summary view</p></nys-tabpanel>
|
|
44
|
+
* <nys-tabpanel><p>Detailed view (shown by default)</p></nys-tabpanel>
|
|
45
|
+
* </nys-tabgroup>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class NysTabgroup extends LitElement {
|
|
49
|
+
static styles: import("lit").CSSResult;
|
|
50
|
+
/**
|
|
51
|
+
* Unique identifier for the tabgroup element.
|
|
52
|
+
* If not provided, one is auto-generated in `connectedCallback`.
|
|
53
|
+
* Reflected to the DOM attribute.
|
|
54
|
+
*
|
|
55
|
+
* @attr id
|
|
56
|
+
*/
|
|
57
|
+
id: string;
|
|
58
|
+
/**
|
|
59
|
+
* The name of the tab group.
|
|
60
|
+
* Used for form submission and accessibility purposes.
|
|
61
|
+
*
|
|
62
|
+
* @attr name
|
|
63
|
+
*/
|
|
64
|
+
name: string;
|
|
65
|
+
/**
|
|
66
|
+
* Cached in `firstUpdated` and used by `_updateScrollShadows` to read
|
|
67
|
+
* scroll position and dimensions.
|
|
68
|
+
*/
|
|
69
|
+
private _tabsEl;
|
|
70
|
+
/**
|
|
71
|
+
* Reference to the left scroll-shadow overlay element.
|
|
72
|
+
* Receives the `is-visible` class when the tab list is scrolled away from
|
|
73
|
+
* its leftmost position.
|
|
74
|
+
*/
|
|
75
|
+
private _shadowLeft;
|
|
76
|
+
/**
|
|
77
|
+
* Reference to the right scroll-shadow overlay element.
|
|
78
|
+
* Receives the `is-visible` class when overflow content exists to the right
|
|
79
|
+
* of the current scroll position.
|
|
80
|
+
*/
|
|
81
|
+
private _shadowRight;
|
|
82
|
+
/**
|
|
83
|
+
* `ResizeObserver` instance watching `_tabsEl` for size changes.
|
|
84
|
+
* Re-evaluates scroll shadow visibility whenever the tab list is resized
|
|
85
|
+
* (e.g. viewport resize, dynamic tab additions).
|
|
86
|
+
* Stored so it can be disconnected if needed.
|
|
87
|
+
*/
|
|
88
|
+
private _resizeObserver?;
|
|
89
|
+
/**
|
|
90
|
+
* Called when the element is inserted into the document.
|
|
91
|
+
* Auto-generates a unique `id` if one was not provided.
|
|
92
|
+
*/
|
|
93
|
+
connectedCallback(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Called after the element's shadow DOM has been rendered for the first time.
|
|
96
|
+
*
|
|
97
|
+
* Caches references to the tab list and scroll-shadow elements, performs an
|
|
98
|
+
* initial scroll-shadow evaluation, and attaches:
|
|
99
|
+
* - A `scroll` event listener on `_tabsEl` to update shadows on scroll.
|
|
100
|
+
* - A `ResizeObserver` on `_tabsEl` to update shadows when the container
|
|
101
|
+
* is resized.
|
|
102
|
+
*/
|
|
103
|
+
firstUpdated(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Reads the current scroll state of `_tabsEl` and toggles the `is-visible`
|
|
106
|
+
* class on the left and right shadow overlays accordingly.
|
|
107
|
+
*
|
|
108
|
+
* - Left shadow is visible when `scrollLeft > 0`.
|
|
109
|
+
* - Right shadow is visible when `scrollLeft + clientWidth < scrollWidth`
|
|
110
|
+
* (i.e. content exists beyond the right edge).
|
|
111
|
+
*
|
|
112
|
+
* Defined as an arrow function so it can be passed directly as an event
|
|
113
|
+
* listener without losing `this` context.
|
|
114
|
+
*
|
|
115
|
+
* @returns void
|
|
116
|
+
*/
|
|
117
|
+
private _updateScrollShadows;
|
|
118
|
+
/**
|
|
119
|
+
* Returns all `<nys-tab>` elements currently residing in the shadow-DOM
|
|
120
|
+
* tabs container, in DOM order.
|
|
121
|
+
*
|
|
122
|
+
* @returns An array of `HTMLElement` references to every `<nys-tab>` child.
|
|
123
|
+
*/
|
|
124
|
+
private _getTabs;
|
|
125
|
+
/**
|
|
126
|
+
* Returns all `<nys-tabpanel>` elements currently residing in the
|
|
127
|
+
* shadow-DOM panels container, in DOM order.
|
|
128
|
+
*
|
|
129
|
+
* @returns An array of `HTMLElement` references to every `<nys-tabpanel>` child.
|
|
130
|
+
*/
|
|
131
|
+
private _getPanels;
|
|
132
|
+
/**
|
|
133
|
+
* Single source of truth for ARIA wiring, `tabindex`, and panel visibility.
|
|
134
|
+
*
|
|
135
|
+
* For each index `i`:
|
|
136
|
+
* - Sets `selected` / removes `selected` attribute on `tabs[i]`.
|
|
137
|
+
* - Sets `aria-controls` on `tabs[i]` to the `id` of `panels[i]`.
|
|
138
|
+
* - Sets `aria-labelledby` on `panels[i]` to the `id` of `tabs[i]`.
|
|
139
|
+
* - Removes `hidden` from `panels[selectedIndex]`; adds it to all others.
|
|
140
|
+
*
|
|
141
|
+
* Must be called any time the selected tab changes (initial render and
|
|
142
|
+
* subsequent user interactions).
|
|
143
|
+
*
|
|
144
|
+
* @param tabs - Ordered array of `<nys-tab>` elements to update.
|
|
145
|
+
* @param panels - Ordered array of `<nys-tabpanel>` elements to update.
|
|
146
|
+
* Must be the same length as `tabs` for correct pairing.
|
|
147
|
+
* @param selectedIndex - Zero-based index of the tab/panel pair to activate.
|
|
148
|
+
* @returns void
|
|
149
|
+
*/
|
|
150
|
+
private _applySelection;
|
|
151
|
+
/**
|
|
152
|
+
* Handles `slotchange` on the default slot.
|
|
153
|
+
*
|
|
154
|
+
* Iterates over all assigned elements and moves each `<nys-tab>` into
|
|
155
|
+
* `.nys-tabgroup__tabs` and each `<nys-tabpanel>` into
|
|
156
|
+
* `.nys-tabgroup__panels`, preserving relative order. After sorting,
|
|
157
|
+
* calls `_applySelection` using the first element that already has a
|
|
158
|
+
* `selected` attribute, or index `0` if none is found.
|
|
159
|
+
*
|
|
160
|
+
* @param e - The `Event` fired by the `<slot>` element on slot change.
|
|
161
|
+
* @returns void
|
|
162
|
+
*/
|
|
163
|
+
private _sortChildren;
|
|
164
|
+
/**
|
|
165
|
+
* Handles the `nys-tab-select` custom event bubbled up from a child
|
|
166
|
+
* `<nys-tab>`.
|
|
167
|
+
*
|
|
168
|
+
* Resolves the originating `<nys-tab>` via `composedPath()` (required
|
|
169
|
+
* because the event crosses shadow DOM boundaries), determines its index
|
|
170
|
+
* among the current tab list, and delegates to `_applySelection`.
|
|
171
|
+
*
|
|
172
|
+
* @param e - The `Event` (cast to `CustomEvent`) dispatched by `<nys-tab>`.
|
|
173
|
+
* @returns void
|
|
174
|
+
*/
|
|
175
|
+
private _handleTabSelect;
|
|
176
|
+
/**
|
|
177
|
+
* Implements the ARIA radio-button keyboard pattern:
|
|
178
|
+
* - `ArrowRight` — moves focus to the next enabled tab (wraps).
|
|
179
|
+
* - `ArrowLeft` — moves focus to the previous enabled tab (wraps).
|
|
180
|
+
*
|
|
181
|
+
* Focus is moved without changing selection; Enter / Space on the newly
|
|
182
|
+
* focused tab (handled by `<nys-tab>._handleKeydown`) confirm selection.
|
|
183
|
+
*
|
|
184
|
+
* The currently focused tab is resolved via `composedPath()` because focus
|
|
185
|
+
* may sit on a shadow-DOM descendant of `<nys-tab>` rather than the host
|
|
186
|
+
* itself.
|
|
187
|
+
*
|
|
188
|
+
* Disabled tabs are excluded from navigation and will never receive focus
|
|
189
|
+
* via arrow keys.
|
|
190
|
+
*
|
|
191
|
+
* @param e - The `KeyboardEvent` from the tablist `keydown` listener.
|
|
192
|
+
* @returns void
|
|
193
|
+
*/
|
|
194
|
+
private _handleKeydown;
|
|
195
|
+
private _handleWheel;
|
|
196
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
197
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* `<nys-tabpanel>` is a content panel paired with a `<nys-tab>` inside a
|
|
4
|
+
* `<nys-tabgroup>`.
|
|
5
|
+
*
|
|
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 externally by
|
|
9
|
+
* `<nys-tabgroup>` via `_applySelection`; do not set them directly.
|
|
10
|
+
*
|
|
11
|
+
* @element nys-tabpanel
|
|
12
|
+
*
|
|
13
|
+
* @slot - Default slot for panel content. Rendered inside a wrapper `<div>`
|
|
14
|
+
* with the `.nys-tabpanel` class for styling.
|
|
15
|
+
*
|
|
16
|
+
* @example Panel content is wrapped by `<nys-tabpanel>`.
|
|
17
|
+
* ```html
|
|
18
|
+
* <!-- Panels are paired by position with <nys-tab> elements in the same <nys-tabgroup>. -->
|
|
19
|
+
* <nys-tabgroup name="Steps">
|
|
20
|
+
* <nys-tab label="Step 1"></nys-tab>
|
|
21
|
+
* <nys-tab label="Step 2"></nys-tab>
|
|
22
|
+
* <nys-tabpanel>
|
|
23
|
+
* <h2>Step 1: Enter your information</h2>
|
|
24
|
+
* <p>Fill out the form below.</p>
|
|
25
|
+
* </nys-tabpanel>
|
|
26
|
+
* <nys-tabpanel>
|
|
27
|
+
* <h2>Step 2: Review and submit</h2>
|
|
28
|
+
* <p>Confirm your details before submitting.</p>
|
|
29
|
+
* </nys-tabpanel>
|
|
30
|
+
* </nys-tabgroup>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class NysTabpanel extends LitElement {
|
|
34
|
+
static styles: import("lit").CSSResult;
|
|
35
|
+
/**
|
|
36
|
+
* Unique identifier for the panel element.
|
|
37
|
+
* If not provided, one is auto-generated in `connectedCallback`.
|
|
38
|
+
* Reflected to the DOM attribute so `aria-controls` references on sibling
|
|
39
|
+
* `<nys-tab>` elements resolve correctly.
|
|
40
|
+
*
|
|
41
|
+
* @attr id
|
|
42
|
+
*/
|
|
43
|
+
id: string;
|
|
44
|
+
connectedCallback(): void;
|
|
45
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
46
|
+
}
|
|
@@ -22,19 +22,22 @@ export declare class NysTable extends LitElement {
|
|
|
22
22
|
private _sortColumn;
|
|
23
23
|
private _sortDirection;
|
|
24
24
|
private _captionText;
|
|
25
|
+
private _observer;
|
|
25
26
|
/**************** Lifecycle Methods ****************/
|
|
26
27
|
constructor();
|
|
27
28
|
connectedCallback(): void;
|
|
28
|
-
/******************** Functions ********************/
|
|
29
29
|
firstUpdated(): void;
|
|
30
|
-
|
|
31
|
-
_normalizeTableDOM(table: HTMLTableElement): void;
|
|
30
|
+
disconnectedCallback(): void;
|
|
32
31
|
willUpdate(): void;
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
/******************** Functions ********************/
|
|
33
|
+
private _handleSlotChange;
|
|
34
|
+
private _setupMutationObserver;
|
|
35
|
+
private _normalizeTableDOM;
|
|
36
|
+
private _addSortIcons;
|
|
37
|
+
private _updateSortIcons;
|
|
35
38
|
private _onSortClick;
|
|
36
|
-
_sortTable
|
|
37
|
-
_updateSortedColumnStyles
|
|
39
|
+
private _sortTable;
|
|
40
|
+
private _updateSortedColumnStyles;
|
|
38
41
|
downloadFile(): void;
|
|
39
42
|
/****************** Event Handlers ******************/
|
|
40
43
|
/**
|
|
@@ -83,7 +83,6 @@ export declare class NysTextarea extends LitElement {
|
|
|
83
83
|
showError: boolean;
|
|
84
84
|
/** Error message text. Shown only when `showError` is true. */
|
|
85
85
|
errorMessage: string;
|
|
86
|
-
updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void>;
|
|
87
86
|
private _hasUserInteracted;
|
|
88
87
|
private _internals;
|
|
89
88
|
/**
|
|
@@ -95,6 +94,7 @@ export declare class NysTextarea extends LitElement {
|
|
|
95
94
|
connectedCallback(): void;
|
|
96
95
|
disconnectedCallback(): void;
|
|
97
96
|
firstUpdated(): void;
|
|
97
|
+
updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void>;
|
|
98
98
|
/**
|
|
99
99
|
* Form Integration
|
|
100
100
|
* --------------------------------------------------------------------------
|
|
@@ -101,6 +101,7 @@ export declare class NysTextinput extends LitElement {
|
|
|
101
101
|
showError: boolean;
|
|
102
102
|
/** Error message text. Shown only when `showError` is true. */
|
|
103
103
|
errorMessage: string;
|
|
104
|
+
private _inputEl;
|
|
104
105
|
private showPassword;
|
|
105
106
|
private _originalErrorMessage;
|
|
106
107
|
private _hasUserInteracted;
|
|
@@ -114,7 +115,7 @@ export declare class NysTextinput extends LitElement {
|
|
|
114
115
|
constructor();
|
|
115
116
|
connectedCallback(): void;
|
|
116
117
|
disconnectedCallback(): void;
|
|
117
|
-
firstUpdated(): void
|
|
118
|
+
firstUpdated(): Promise<void>;
|
|
118
119
|
updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void>;
|
|
119
120
|
/**
|
|
120
121
|
* Form Integration
|
|
@@ -5,6 +5,27 @@ declare global {
|
|
|
5
5
|
onYouTubeIframeAPIReady: () => void;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* A YouTube video player with a thumbnail preview and play button.
|
|
10
|
+
* Loads the iframe only after the user clicks play, keeping initial page load light.
|
|
11
|
+
* Supports autoplay (muted), custom thumbnails, start time, lazy loading, and disabled state.
|
|
12
|
+
* Announces playback state and ad state to screen readers via a live region.
|
|
13
|
+
*
|
|
14
|
+
* For use with YouTube URLs only. Component renders nothing if the URL is invalid.
|
|
15
|
+
*
|
|
16
|
+
* @summary YouTube video player with thumbnail preview and accessibility announcements.
|
|
17
|
+
* @element nys-video
|
|
18
|
+
*
|
|
19
|
+
* @fires nys-video-play - Fired when the user clicks the thumbnail to load the player.
|
|
20
|
+
*
|
|
21
|
+
* @example Basic usage
|
|
22
|
+
* ```html
|
|
23
|
+
* <nys-video
|
|
24
|
+
* videourl="https://www.youtube.com/watch?v=dQw4w9WgXcQ"
|
|
25
|
+
* titleText="Video Title"
|
|
26
|
+
* ></nys-video>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
8
29
|
export declare class NysVideo extends LitElement {
|
|
9
30
|
static styles: import("lit").CSSResult;
|
|
10
31
|
/** Full YouTube URL — required. Component will not render if invalid. */
|
|
@@ -36,6 +57,10 @@ export declare class NysVideo extends LitElement {
|
|
|
36
57
|
private _announcement;
|
|
37
58
|
/** Tracks whether an ad is currently playing to suppress false "Video is playing" announcements */
|
|
38
59
|
private _adPlaying;
|
|
60
|
+
/**
|
|
61
|
+
* Lifecycle methods
|
|
62
|
+
* --------------------------------------------------------------------------
|
|
63
|
+
*/
|
|
39
64
|
constructor();
|
|
40
65
|
connectedCallback(): void;
|
|
41
66
|
disconnectedCallback(): void;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "../packages/nys-accordion/src/index";
|
|
|
2
2
|
export * from "../packages/nys-alert/src/index";
|
|
3
3
|
export * from "../packages/nys-avatar/src/index";
|
|
4
4
|
export * from "../packages/nys-backtotop/src/index";
|
|
5
|
+
export * from "../packages/nys-breadcrumbs/src/index";
|
|
5
6
|
export * from "../packages/nys-button/src/index";
|
|
6
7
|
export * from "../packages/nys-badge/src/index";
|
|
7
8
|
export * from "../packages/nys-checkbox/src/index";
|
|
@@ -19,6 +20,7 @@ export * from "../packages/nys-radiobutton/src/index";
|
|
|
19
20
|
export * from "../packages/nys-select/src/index";
|
|
20
21
|
export * from "../packages/nys-skipnav/src/index";
|
|
21
22
|
export * from "../packages/nys-stepper/src/index";
|
|
23
|
+
export * from "../packages/nys-tab/src/index";
|
|
22
24
|
export * from "../packages/nys-table/src/index";
|
|
23
25
|
export * from "../packages/nys-textarea/src/index";
|
|
24
26
|
export * from "../packages/nys-textinput/src/index";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nysds/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "New York State's design system and code component library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"mcp-server:build": "turbo run build --filter=@nysds/mcp-server",
|
|
54
54
|
"clean:node": "rm -rf node_modules && rm -rf packages/*/node_modules && rm -rf packages/**/*/node_modules",
|
|
55
55
|
"clean:dist": "rm -rf storybook-static && rm -rf coverage && rm -rf packages/*/coverage && rm -rf dist && find packages -type d -name dist ! -path '*/mcp-server/dist' -exec rm -rf {} + 2>/dev/null || true",
|
|
56
|
-
"clean:
|
|
56
|
+
"clean:turbo": "find packages -type d -name '.turbo' -exec rm -rf {} + && rm -rf .turbo",
|
|
57
|
+
"clean:all": "npm run clean:dist && npm run clean:node && find packages -name '*.tsbuildinfo' -delete 2>/dev/null || true && npm run clean:turbo",
|
|
57
58
|
"code-connect": "dotenv -- npx figma connect publish",
|
|
58
59
|
"cem": "npx cem analyze --config ./custom-elements-manifest.config.mjs && cp ./custom-elements.json dist/ && node src/scripts/patch-react-utils.js"
|
|
59
60
|
},
|
|
@@ -42,6 +42,9 @@ export interface NysBadgeProps extends Pick<
|
|
|
42
42
|
/** Primary label text displayed in the badge. */
|
|
43
43
|
label?: NysBadgeElement["label"];
|
|
44
44
|
|
|
45
|
+
/** Screen reader text appended after the label for additional context. */
|
|
46
|
+
srText?: NysBadgeElement["srText"];
|
|
47
|
+
|
|
45
48
|
/** undefined */
|
|
46
49
|
variant?: NysBadgeElement["variant"];
|
|
47
50
|
|
|
@@ -11,6 +11,7 @@ export const NysBadge = forwardRef((props, forwardedRef) => {
|
|
|
11
11
|
intent,
|
|
12
12
|
prefixLabel,
|
|
13
13
|
label,
|
|
14
|
+
srText,
|
|
14
15
|
variant,
|
|
15
16
|
...filteredProps
|
|
16
17
|
} = props;
|
|
@@ -25,6 +26,7 @@ export const NysBadge = forwardRef((props, forwardedRef) => {
|
|
|
25
26
|
intent: props.intent,
|
|
26
27
|
prefixLabel: props.prefixLabel,
|
|
27
28
|
label: props.label,
|
|
29
|
+
srText: props.srText,
|
|
28
30
|
variant: props.variant,
|
|
29
31
|
class: props.className,
|
|
30
32
|
exportparts: props.exportparts,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
NysBreadcrumbItem as NysBreadcrumbItemElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
} from "../../dist/nysds.es.js";
|
|
6
|
+
|
|
7
|
+
export type { NysBreadcrumbItemElement, CustomEvent };
|
|
8
|
+
|
|
9
|
+
export interface NysBreadcrumbItemProps extends Pick<
|
|
10
|
+
React.AllHTMLAttributes<HTMLElement>,
|
|
11
|
+
| "children"
|
|
12
|
+
| "dir"
|
|
13
|
+
| "hidden"
|
|
14
|
+
| "id"
|
|
15
|
+
| "lang"
|
|
16
|
+
| "slot"
|
|
17
|
+
| "style"
|
|
18
|
+
| "title"
|
|
19
|
+
| "translate"
|
|
20
|
+
| "onClick"
|
|
21
|
+
| "onFocus"
|
|
22
|
+
| "onBlur"
|
|
23
|
+
> {
|
|
24
|
+
/** Private property used by nys-breadcrumbs to indicate this breadcrumb item is the last in the trail * */
|
|
25
|
+
isLast?: boolean;
|
|
26
|
+
|
|
27
|
+
/** undefined */
|
|
28
|
+
isBackToParent?: boolean;
|
|
29
|
+
|
|
30
|
+
/** undefined */
|
|
31
|
+
id?: NysBreadcrumbItemElement["id"];
|
|
32
|
+
|
|
33
|
+
/** undefined */
|
|
34
|
+
label?: NysBreadcrumbItemElement["label"];
|
|
35
|
+
|
|
36
|
+
/** undefined */
|
|
37
|
+
link?: NysBreadcrumbItemElement["link"];
|
|
38
|
+
|
|
39
|
+
/** A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access specific elements via the class selectors or functions like the method `Document.getElementsByClassName()`. */
|
|
40
|
+
className?: string;
|
|
41
|
+
|
|
42
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
43
|
+
exportparts?: string;
|
|
44
|
+
|
|
45
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
46
|
+
htmlFor?: string;
|
|
47
|
+
|
|
48
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
49
|
+
key?: number | string;
|
|
50
|
+
|
|
51
|
+
/** Contains a space-separated list of the part names of the element. Part names allows CSS to select and style specific elements in a shadow tree via the ::part pseudo-element. */
|
|
52
|
+
part?: string;
|
|
53
|
+
|
|
54
|
+
/** A mutable ref object whose `.current` property is initialized to the passed argument (`initialValue`). The returned object will persist for the full lifetime of the component. */
|
|
55
|
+
ref?: any;
|
|
56
|
+
|
|
57
|
+
/** Allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the `Tab` key, hence the name) and determine their relative ordering for sequential focus navigation. */
|
|
58
|
+
tabIndex?: number;
|
|
59
|
+
|
|
60
|
+
/** Fired when the link is clicked. Detail: `{id, link}`. */
|
|
61
|
+
onNysBreadcrumbitemClick?: (event: CustomEvent) => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Single breadcrumb trail item with chevron separator and current page support.
|
|
66
|
+
* ---
|
|
67
|
+
*
|
|
68
|
+
*
|
|
69
|
+
* ### **Events:**
|
|
70
|
+
* - **nys-breadcrumbitem-click** - Fired when the link is clicked. Detail: `{id, link}`.
|
|
71
|
+
*/
|
|
72
|
+
export const NysBreadcrumbItem: React.ForwardRefExoticComponent<NysBreadcrumbItemProps>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { forwardRef, useRef, useEffect } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
import { useEventListener } from "./react-utils.js";
|
|
4
|
+
|
|
5
|
+
export const NysBreadcrumbItem = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const { isLast, isBackToParent, id, label, link, ...filteredProps } = props;
|
|
8
|
+
|
|
9
|
+
/** Event listeners - run once */
|
|
10
|
+
useEventListener(
|
|
11
|
+
ref,
|
|
12
|
+
"nys-breadcrumbitem-click",
|
|
13
|
+
props.onNysBreadcrumbitemClick,
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return React.createElement(
|
|
17
|
+
"nys-breadcrumbitem",
|
|
18
|
+
{
|
|
19
|
+
ref: (node) => {
|
|
20
|
+
ref.current = node;
|
|
21
|
+
if (typeof forwardedRef === "function") {
|
|
22
|
+
forwardedRef(node);
|
|
23
|
+
} else if (forwardedRef) {
|
|
24
|
+
forwardedRef.current = node;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
...filteredProps,
|
|
28
|
+
id: props.id,
|
|
29
|
+
label: props.label,
|
|
30
|
+
link: props.link,
|
|
31
|
+
class: props.className,
|
|
32
|
+
exportparts: props.exportparts,
|
|
33
|
+
for: props.htmlFor,
|
|
34
|
+
part: props.part,
|
|
35
|
+
tabindex: props.tabIndex,
|
|
36
|
+
isLast: props.isLast ? true : undefined,
|
|
37
|
+
isBackToParent: props.isBackToParent ? true : undefined,
|
|
38
|
+
style: { ...props.style },
|
|
39
|
+
},
|
|
40
|
+
props.children,
|
|
41
|
+
);
|
|
42
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
NysBreadcrumbs as NysBreadcrumbsElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
} from "../../dist/nysds.es.js";
|
|
6
|
+
|
|
7
|
+
export type { NysBreadcrumbsElement, CustomEvent };
|
|
8
|
+
|
|
9
|
+
export interface NysBreadcrumbsProps extends Pick<
|
|
10
|
+
React.AllHTMLAttributes<HTMLElement>,
|
|
11
|
+
| "children"
|
|
12
|
+
| "dir"
|
|
13
|
+
| "hidden"
|
|
14
|
+
| "id"
|
|
15
|
+
| "lang"
|
|
16
|
+
| "slot"
|
|
17
|
+
| "style"
|
|
18
|
+
| "title"
|
|
19
|
+
| "translate"
|
|
20
|
+
| "onClick"
|
|
21
|
+
| "onFocus"
|
|
22
|
+
| "onBlur"
|
|
23
|
+
> {
|
|
24
|
+
/** On mobile, renders the trail as a single back-to-parent link pointing to the item before the current page.
|
|
25
|
+
Has no effect on desktop or when only one item is present (which always renders as a back link). */
|
|
26
|
+
backToParent?: boolean;
|
|
27
|
+
|
|
28
|
+
/** Forces the trail into its collapsed state.
|
|
29
|
+
It shows only the first item, an ellipsis, and the last two items.
|
|
30
|
+
The user can still expand the trail by clicking the ellipsis. */
|
|
31
|
+
collapsed?: boolean;
|
|
32
|
+
|
|
33
|
+
/** Renders a filled light theme background bar behind the breadcrumb trail. */
|
|
34
|
+
backgroundBar?: boolean;
|
|
35
|
+
|
|
36
|
+
/** Prevents interaction. */
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
|
|
39
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
40
|
+
id?: NysBreadcrumbsElement["id"];
|
|
41
|
+
|
|
42
|
+
/** Accessible label for the `<nav>` landmark. Defaults to "path to this page" if not set.
|
|
43
|
+
Override when multiple crumbs exist on the same page. */
|
|
44
|
+
ariaLabel?: NysBreadcrumbsElement["ariaLabel"];
|
|
45
|
+
|
|
46
|
+
/** Controls the visual size of the breadcrumb text and spacing: `sm` for dense layouts, `md` (default) for standard use. */
|
|
47
|
+
size?: NysBreadcrumbsElement["size"];
|
|
48
|
+
|
|
49
|
+
/** A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access specific elements via the class selectors or functions like the method `Document.getElementsByClassName()`. */
|
|
50
|
+
className?: string;
|
|
51
|
+
|
|
52
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
53
|
+
exportparts?: string;
|
|
54
|
+
|
|
55
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
56
|
+
htmlFor?: string;
|
|
57
|
+
|
|
58
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
59
|
+
key?: number | string;
|
|
60
|
+
|
|
61
|
+
/** Contains a space-separated list of the part names of the element. Part names allows CSS to select and style specific elements in a shadow tree via the ::part pseudo-element. */
|
|
62
|
+
part?: string;
|
|
63
|
+
|
|
64
|
+
/** A mutable ref object whose `.current` property is initialized to the passed argument (`initialValue`). The returned object will persist for the full lifetime of the component. */
|
|
65
|
+
ref?: any;
|
|
66
|
+
|
|
67
|
+
/** Allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the `Tab` key, hence the name) and determine their relative ordering for sequential focus navigation. */
|
|
68
|
+
tabIndex?: number;
|
|
69
|
+
|
|
70
|
+
/** undefined */
|
|
71
|
+
onNysExpand?: (event: CustomEvent) => void;
|
|
72
|
+
|
|
73
|
+
/** Fired when the user clicks the ellipsis to expand the trail. */
|
|
74
|
+
onNysBreadcrumbsExpand?: (event: CustomEvent) => void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Breadcrumb navigation trail with responsive collapse support.
|
|
79
|
+
* ---
|
|
80
|
+
*
|
|
81
|
+
*
|
|
82
|
+
* ### **Events:**
|
|
83
|
+
* - **nys-expand**
|
|
84
|
+
* - **nys-breadcrumbs-expand** - Fired when the user clicks the ellipsis to expand the trail.
|
|
85
|
+
*
|
|
86
|
+
* ### **Slots:**
|
|
87
|
+
* - _default_ - One or more `nys-breadcrumbitem` elements defining the trail.
|
|
88
|
+
*/
|
|
89
|
+
export const NysBreadcrumbs: React.ForwardRefExoticComponent<NysBreadcrumbsProps>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { forwardRef, useRef, useEffect } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
import { useEventListener } from "./react-utils.js";
|
|
4
|
+
|
|
5
|
+
export const NysBreadcrumbs = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const {
|
|
8
|
+
backToParent,
|
|
9
|
+
collapsed,
|
|
10
|
+
backgroundBar,
|
|
11
|
+
disabled,
|
|
12
|
+
id,
|
|
13
|
+
ariaLabel,
|
|
14
|
+
size,
|
|
15
|
+
...filteredProps
|
|
16
|
+
} = props;
|
|
17
|
+
|
|
18
|
+
/** Event listeners - run once */
|
|
19
|
+
useEventListener(ref, "nys-expand", props.onNysExpand);
|
|
20
|
+
useEventListener(ref, "nys-breadcrumbs-expand", props.onNysBreadcrumbsExpand);
|
|
21
|
+
|
|
22
|
+
return React.createElement(
|
|
23
|
+
"nys-breadcrumbs",
|
|
24
|
+
{
|
|
25
|
+
ref: (node) => {
|
|
26
|
+
ref.current = node;
|
|
27
|
+
if (typeof forwardedRef === "function") {
|
|
28
|
+
forwardedRef(node);
|
|
29
|
+
} else if (forwardedRef) {
|
|
30
|
+
forwardedRef.current = node;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
...filteredProps,
|
|
34
|
+
id: props.id,
|
|
35
|
+
ariaLabel: props.ariaLabel,
|
|
36
|
+
size: props.size,
|
|
37
|
+
class: props.className,
|
|
38
|
+
exportparts: props.exportparts,
|
|
39
|
+
for: props.htmlFor,
|
|
40
|
+
part: props.part,
|
|
41
|
+
tabindex: props.tabIndex,
|
|
42
|
+
backToParent: props.backToParent ? true : undefined,
|
|
43
|
+
collapsed: props.collapsed ? true : undefined,
|
|
44
|
+
backgroundBar: props.backgroundBar ? true : undefined,
|
|
45
|
+
disabled: props.disabled ? true : undefined,
|
|
46
|
+
style: { ...props.style },
|
|
47
|
+
},
|
|
48
|
+
props.children,
|
|
49
|
+
);
|
|
50
|
+
});
|