@nysds/components 1.18.1 → 1.19.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 +799 -372
- package/dist/.vscode/vscode.html-custom-data.json +29 -24
- package/dist/custom-elements.json +799 -372
- package/dist/icons/ac_unit.svg +8 -0
- package/dist/icons/account_balance_filled.svg +8 -0
- package/dist/icons/account_circle.svg +8 -0
- package/dist/icons/add.svg +8 -0
- package/dist/icons/air.svg +8 -0
- package/dist/icons/arrow_back.svg +8 -0
- package/dist/icons/arrow_downward.svg +8 -0
- package/dist/icons/arrow_forward.svg +8 -0
- package/dist/icons/arrow_upward.svg +8 -0
- package/dist/icons/attach_file.svg +8 -0
- package/dist/icons/calendar_month.svg +8 -0
- package/dist/icons/cancel.svg +8 -0
- package/dist/icons/cancel_filled.svg +8 -0
- package/dist/icons/check.svg +8 -0
- package/dist/icons/check_circle.svg +8 -0
- package/dist/icons/chevron_down.svg +8 -0
- package/dist/icons/chevron_left.svg +8 -0
- package/dist/icons/chevron_right.svg +8 -0
- package/dist/icons/chevron_up.svg +8 -0
- package/dist/icons/clear_day.svg +8 -0
- package/dist/icons/close.svg +8 -0
- package/dist/icons/code.svg +8 -0
- package/dist/icons/content_copy.svg +8 -0
- package/dist/icons/coronavirus.svg +8 -0
- package/dist/icons/delete.svg +8 -0
- package/dist/icons/download.svg +8 -0
- package/dist/icons/download_done.svg +8 -0
- package/dist/icons/drive_folder_upload.svg +8 -0
- package/dist/icons/edit_square.svg +8 -0
- package/dist/icons/emergency_home.svg +8 -0
- package/dist/icons/error.svg +8 -0
- package/dist/icons/expand_all.svg +8 -0
- package/dist/icons/filter_alt.svg +8 -0
- package/dist/icons/filter_list.svg +8 -0
- package/dist/icons/height.svg +8 -0
- package/dist/icons/help.svg +8 -0
- package/dist/icons/info.svg +8 -0
- package/dist/icons/language.svg +8 -0
- package/dist/icons/language_filled.svg +8 -0
- package/dist/icons/link.svg +8 -0
- package/dist/icons/lock_filled.svg +8 -0
- package/dist/icons/mail.svg +8 -0
- package/dist/icons/manifest.json +84 -0
- package/dist/icons/menu.svg +8 -0
- package/dist/icons/more_vert.svg +8 -0
- package/dist/icons/notifications.svg +8 -0
- package/dist/icons/open_in_new.svg +8 -0
- package/dist/icons/phone_in_talk.svg +8 -0
- package/dist/icons/print.svg +8 -0
- package/dist/icons/progress_activity.svg +8 -0
- package/dist/icons/publish.svg +8 -0
- package/dist/icons/rainy.svg +8 -0
- package/dist/icons/refresh.svg +8 -0
- package/dist/icons/remove.svg +8 -0
- package/dist/icons/search.svg +8 -0
- package/dist/icons/share.svg +8 -0
- package/dist/icons/sms.svg +8 -0
- package/dist/icons/social_bluesky.svg +8 -0
- package/dist/icons/social_facebook.svg +8 -0
- package/dist/icons/social_flickr.svg +8 -0
- package/dist/icons/social_google_play.svg +8 -0
- package/dist/icons/social_instagram.svg +10 -0
- package/dist/icons/social_linkedin.svg +8 -0
- package/dist/icons/social_pinterest.svg +8 -0
- package/dist/icons/social_rss.svg +10 -0
- package/dist/icons/social_snapchat.svg +8 -0
- package/dist/icons/social_soundcloud.svg +21 -0
- package/dist/icons/social_threads.svg +9 -0
- package/dist/icons/social_tiktok.svg +8 -0
- package/dist/icons/social_tumblr.svg +8 -0
- package/dist/icons/social_vimeo.svg +8 -0
- package/dist/icons/social_x.svg +8 -0
- package/dist/icons/social_youtube.svg +8 -0
- package/dist/icons/sort.svg +8 -0
- package/dist/icons/straight.svg +8 -0
- package/dist/icons/thumb_down.svg +8 -0
- package/dist/icons/thumb_up.svg +8 -0
- package/dist/icons/upload_file.svg +8 -0
- package/dist/icons/visibility.svg +8 -0
- package/dist/icons/visibility_off.svg +8 -0
- package/dist/icons/warning.svg +8 -0
- package/dist/nysds.es.js +3762 -3630
- package/dist/nysds.es.js.map +1 -1
- package/dist/nysds.js +342 -865
- package/dist/nysds.js.map +1 -1
- package/dist/packages/mcp-server/src/lib/token-parser.d.ts +19 -31
- package/dist/packages/mcp-server/src/tools/token-tools.d.ts +2 -3
- package/dist/packages/nys-avatar/src/nys-avatar.d.ts +2 -0
- package/dist/packages/nys-backtotop/src/nys-backtotop.d.ts +3 -3
- package/dist/packages/nys-button/src/nys-button.d.ts +5 -0
- package/dist/packages/nys-checkbox/src/nys-checkbox.d.ts +2 -1
- package/dist/packages/nys-divider/src/nys-divider.d.ts +2 -0
- package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenu.d.ts +1 -1
- package/dist/packages/nys-globalheader/src/nys-globalheader.d.ts +3 -0
- package/dist/packages/nys-icon/src/icon-cache.d.ts +11 -0
- package/dist/packages/nys-icon/src/icon-library-registry.d.ts +47 -0
- package/dist/packages/nys-icon/src/index.d.ts +3 -0
- package/dist/packages/nys-icon/src/nys-icon.d.ts +40 -11
- package/dist/packages/nys-modal/src/nys-modal.d.ts +1 -0
- package/dist/packages/nys-radiobutton/src/nys-radiobutton.d.ts +1 -38
- package/dist/packages/nys-radiobutton/src/nys-radiogroup.d.ts +17 -7
- package/dist/packages/nys-stepper/src/nys-step.d.ts +75 -23
- package/dist/packages/nys-stepper/src/nys-stepper.d.ts +81 -9
- package/dist/packages/nys-tab/src/nys-tabgroup.d.ts +1 -0
- package/dist/packages/nys-tooltip/src/nys-tooltip.d.ts +1 -0
- package/package.json +12 -6
- package/packages/react/NysDivider.d.ts +3 -0
- package/packages/react/NysDivider.js +2 -1
- package/packages/react/NysIcon.d.ts +11 -2
- package/packages/react/NysIcon.js +26 -3
- package/packages/react/NysRadiobutton.d.ts +7 -23
- package/packages/react/NysRadiobutton.js +1 -3
- package/packages/react/NysRadiogroup.d.ts +18 -2
- package/packages/react/NysRadiogroup.js +17 -1
- package/packages/react/NysStep.d.ts +10 -12
- package/packages/react/NysStep.js +1 -12
- package/packages/react/NysStepper.d.ts +6 -6
- package/packages/react/nysds-jsx.d.ts +46 -36
- package/dist/packages/mcp-server/src/lib/format.d.ts +0 -21
|
@@ -3,15 +3,50 @@ import "./nys-step";
|
|
|
3
3
|
/**
|
|
4
4
|
* A multi-step progress indicator for forms or wizards. Manages `nys-step` children with selection and navigation.
|
|
5
5
|
*
|
|
6
|
-
* Add `nys-step` elements as children. Mark one step as `current` to indicate progress;
|
|
7
|
-
* navigable. Compact view on mobile expands to show all steps. Use `actions` slot for
|
|
8
|
-
* Do not place the stepper inside a form element
|
|
6
|
+
* Add `nys-step` elements as children. Mark one step as `current` to indicate the progress boundary; all steps
|
|
7
|
+
* before it become navigable. Compact view on mobile expands to show all steps. Use the `actions` slot for
|
|
8
|
+
* persistent navigation buttons (e.g., Save & Exit). Do not place the stepper inside a `<form>` element —
|
|
9
|
+
* put form fields in the main content area alongside it.
|
|
10
|
+
*
|
|
11
|
+
* ## When to use
|
|
12
|
+
* - Linear, ordered forms or wizards with more than 2 sections.
|
|
13
|
+
*
|
|
14
|
+
* ## When not to use
|
|
15
|
+
* - Forms with only 1 or 2 sections — use a simpler layout.
|
|
16
|
+
* - Non-linear forms where sections can be completed in any order.
|
|
17
|
+
*
|
|
18
|
+
* ## Compact mode (mobile)
|
|
19
|
+
* On small screens the stepper collapses to a compact view: step labels are hidden and progress
|
|
20
|
+
* is shown as a bar indicator with a "Step x of y" counter. Clicking or pressing Enter/Space on
|
|
21
|
+
* the counter expands the full step list (counter text changes to "Back to Form"). Collapsing
|
|
22
|
+
* again returns the user to the form view.
|
|
23
|
+
*
|
|
24
|
+
* ## actions slot constraints
|
|
25
|
+
* The `actions` slot must contain exactly one `<div>` as its direct child. That `<div>` may only
|
|
26
|
+
* contain `<nys-button>` elements — any other element is removed with a console warning.
|
|
27
|
+
* The stepper automatically forces `size="sm"` on every button in the slot. Buttons with the
|
|
28
|
+
* `fullWidth` attribute get `flex: 1 1 0` injected so they share available width equally.
|
|
29
|
+
*
|
|
30
|
+
* ## Multiple `current` conflict
|
|
31
|
+
* If more than one `nys-step` has the `current` attribute, only the first one is kept; the rest
|
|
32
|
+
* are silently removed. Always mark exactly one step as `current`.
|
|
33
|
+
*
|
|
34
|
+
* ## id auto-generation
|
|
35
|
+
* If no `id` is provided, a unique id is generated automatically in the form
|
|
36
|
+
* `nys-stepper-{n}-{timestamp}`.
|
|
37
|
+
*
|
|
38
|
+
* ## Accessibility
|
|
39
|
+
* - The compact counter is rendered as a `role="button"` with `aria-expanded` and a descriptive
|
|
40
|
+
* `aria-label` that announces the current step (e.g., "Expand step navigation. You are on Step 2 of 4").
|
|
41
|
+
* - Keyboard: Enter or Space toggles the compact view.
|
|
42
|
+
* - Each `nys-step` label is keyboard-focusable and activatable for navigable steps.
|
|
43
|
+
* - Visual focus indicators are provided on all interactive elements.
|
|
9
44
|
*
|
|
10
45
|
* @summary Multi-step progress indicator with navigation and mobile-friendly compact view.
|
|
11
46
|
* @element nys-stepper
|
|
12
47
|
*
|
|
13
|
-
* @slot - Default slot for `nys-step` elements.
|
|
14
|
-
* @slot actions -
|
|
48
|
+
* @slot - Default slot for `nys-step` elements. Only `nys-step` children are accepted; others are removed.
|
|
49
|
+
* @slot actions - Persistent navigation buttons. Must contain exactly one `<div>` wrapping only `<nys-button>` elements.
|
|
15
50
|
*
|
|
16
51
|
* @example Basic stepper
|
|
17
52
|
* ```html
|
|
@@ -58,18 +93,55 @@ import "./nys-step";
|
|
|
58
93
|
* </div>
|
|
59
94
|
* </nys-stepper>
|
|
60
95
|
* ```
|
|
96
|
+
*
|
|
97
|
+
* @example SPA / programmatic navigation
|
|
98
|
+
* Two state variables drive the stepper in any framework or vanilla JS:
|
|
99
|
+
* - `currentStep` (progress boundary) → set `current` on the matching step
|
|
100
|
+
* - `viewingStep` (displayed content) → set `selected` on the matching step
|
|
101
|
+
*
|
|
102
|
+
* Always set both explicitly. Always call `e.preventDefault()` in the
|
|
103
|
+
* `nys-step-click` listener to suppress href navigation. Do NOT nest inside a
|
|
104
|
+
* `<form>` element.
|
|
105
|
+
* ```js
|
|
106
|
+
* let currentStep = 0; // furthest reached
|
|
107
|
+
* let viewingStep = 0; // currently displayed
|
|
108
|
+
*
|
|
109
|
+
* function updateStepper(steps) {
|
|
110
|
+
* steps.forEach((step, i) => {
|
|
111
|
+
* step.toggleAttribute('current', i === currentStep);
|
|
112
|
+
* step.toggleAttribute('selected', i === viewingStep);
|
|
113
|
+
* });
|
|
114
|
+
* }
|
|
115
|
+
*
|
|
116
|
+
* document.querySelector('nys-stepper').addEventListener('nys-step-click', (e) => {
|
|
117
|
+
* e.preventDefault();
|
|
118
|
+
* const steps = Array.from(document.querySelectorAll('nys-step'));
|
|
119
|
+
* const clicked = e.composedPath().find(el => el.tagName?.toLowerCase() === 'nys-step');
|
|
120
|
+
* const index = steps.indexOf(clicked);
|
|
121
|
+
* if (index !== -1) { viewingStep = index; updateStepper(steps); }
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* // Advance to next step (call on form submit / "Continue" click)
|
|
125
|
+
* function advance(steps) {
|
|
126
|
+
* if (currentStep < steps.length - 1) {
|
|
127
|
+
* currentStep++;
|
|
128
|
+
* viewingStep = currentStep;
|
|
129
|
+
* updateStepper(steps);
|
|
130
|
+
* }
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
61
133
|
*/
|
|
62
134
|
export declare class NysStepper extends LitElement {
|
|
63
135
|
static styles: import("lit").CSSResult;
|
|
64
|
-
/** Unique identifier. */
|
|
136
|
+
/** Unique identifier. Auto-generated as `nys-stepper-{n}-{timestamp}` if not provided. */
|
|
65
137
|
id: string;
|
|
66
138
|
/** Name attribute for form association. */
|
|
67
139
|
name: string;
|
|
68
|
-
/** Title displayed above the step counter. */
|
|
140
|
+
/** Title displayed above the step list and compact counter. */
|
|
69
141
|
label: string;
|
|
70
|
-
/** Progress text (e.g., "Step 2 of 5"). Auto-
|
|
142
|
+
/** Progress text displayed in compact mode (e.g., "Step 2 of 5"). Auto-managed — do not set manually. */
|
|
71
143
|
counterText: string;
|
|
72
|
-
/** Whether compact mobile view is expanded to show all steps. */
|
|
144
|
+
/** Whether compact mobile view is expanded to show all steps. Toggled by clicking the counter. */
|
|
73
145
|
isCompactExpanded: boolean;
|
|
74
146
|
private _stepsNumbered;
|
|
75
147
|
constructor();
|
|
@@ -101,6 +101,7 @@ export declare class NysTabgroup extends LitElement {
|
|
|
101
101
|
* is resized.
|
|
102
102
|
*/
|
|
103
103
|
firstUpdated(): void;
|
|
104
|
+
disconnectedCallback(): void;
|
|
104
105
|
/**
|
|
105
106
|
* Reads the current scroll state of `_tabsEl` and toggles the `is-visible`
|
|
106
107
|
* class on the left and right shadow overlays accordingly.
|
|
@@ -36,6 +36,7 @@ export declare class NysTooltip extends LitElement {
|
|
|
36
36
|
private _internallyUpdatingPosition;
|
|
37
37
|
private _hideTimeout;
|
|
38
38
|
private _position;
|
|
39
|
+
private _resizeObserver;
|
|
39
40
|
/**
|
|
40
41
|
* Preferred position relative to trigger. Auto-adjusts if space is insufficient.
|
|
41
42
|
* @default null (auto-positioned based on available space)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nysds/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "New York State's design system and code component library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
@@ -37,15 +37,18 @@
|
|
|
37
37
|
"build:all": "npm run clean:dist && npm run lint && npm run lit-analyze || true && cross-env NODE_ENV=production npm run build:packages && npm run build:root && npm run cem && npm run build:mcp",
|
|
38
38
|
"build:mcp": "npm run build -w @nysds/mcp-server",
|
|
39
39
|
"build:link": "npm run build:all && npm link && cd packages/styles && npm link",
|
|
40
|
-
"lint": "eslint --cache --cache-location node_modules/.cache/eslint && stylelint **/*.scss || true",
|
|
41
|
-
"lint:fix": "
|
|
40
|
+
"lint": "eslint --cache --cache-strategy=content --cache-location node_modules/.cache/eslint && (stylelint \"**/*.scss\" || true)",
|
|
41
|
+
"lint:fix": "bash src/scripts/lint-fix.sh",
|
|
42
42
|
"lit-analyze": "find ./packages/nys-*/ -name '*.ts' ! -name '*.figma.*' | xargs lit-analyzer {}",
|
|
43
|
+
"playwright:install": "npx playwright install --with-deps",
|
|
43
44
|
"release": "cross-env NODE_ENV=production npm run build:all && cross-env NODE_ENV=production npm run test && npm run cem && cross-env NODE_ENV=production npm publish --workspaces --access public && cross-env NODE_ENV=production npm publish --access public",
|
|
44
45
|
"release:dry-run": "cross-env NODE_ENV=production npm run build:all && cross-env NODE_ENV=production npm run test && npm run cem && node src/scripts/publish-dry-run.js",
|
|
45
46
|
"release:alpha": "npm run build && npm run build:umd && npm publish --tag next",
|
|
46
47
|
"release:zip": "npm run build:all && node src/scripts/create-release-zip.js",
|
|
47
|
-
"test": "
|
|
48
|
+
"test": "npm run playwright:install && wtr --node-resolve",
|
|
48
49
|
"test:build": "npm run build:all && npm run test",
|
|
50
|
+
"test:compact": "export NYSDS_TEST_OUTPUT=compact && wtr --node-resolve",
|
|
51
|
+
"test:ai": "export NYSDS_TEST_OUTPUT=ai && wtr --node-resolve",
|
|
49
52
|
"storybook": "cross-env NODE_ENV=production storybook dev -p 6006",
|
|
50
53
|
"storybook:build:all": "cross-env NODE_ENV=production npm run build:all && npm run storybook",
|
|
51
54
|
"build-storybook": "npm run build:packages && storybook build",
|
|
@@ -54,7 +57,8 @@
|
|
|
54
57
|
"clean:node": "rm -rf node_modules && rm -rf packages/*/node_modules && rm -rf packages/**/*/node_modules",
|
|
55
58
|
"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
59
|
"clean:turbo": "find packages -type d -name '.turbo' -exec rm -rf {} + && rm -rf .turbo",
|
|
57
|
-
"clean:
|
|
60
|
+
"clean:cache": "rm -rf node_modules/.cache",
|
|
61
|
+
"clean:all": "npm run clean:dist && npm run clean:node && npm run clean:cache && find packages -name '*.tsbuildinfo' -delete 2>/dev/null || true && npm run clean:turbo",
|
|
58
62
|
"code-connect": "dotenv -- npx figma connect publish",
|
|
59
63
|
"cem": "npx cem analyze --config ./custom-elements-manifest.config.mjs && cp ./custom-elements.json dist/ && node src/scripts/patch-react-utils.js"
|
|
60
64
|
},
|
|
@@ -89,8 +93,8 @@
|
|
|
89
93
|
"@web/test-runner-playwright": "^0.11.1",
|
|
90
94
|
"cem-plugin-examples": "github:its-hcd/cem-plugin-examples",
|
|
91
95
|
"cross-env": "^10.1.0",
|
|
92
|
-
"custom-element-react-wrappers": "^1.7.3",
|
|
93
96
|
"custom-element-jsx-integration": "^1.6.0",
|
|
97
|
+
"custom-element-react-wrappers": "^1.7.3",
|
|
94
98
|
"custom-element-vs-code-integration": "^1.5.0",
|
|
95
99
|
"dotenv-cli": "^10.0.0",
|
|
96
100
|
"eslint": "^10.0.0",
|
|
@@ -111,6 +115,7 @@
|
|
|
111
115
|
"stylelint": "^17.1.1",
|
|
112
116
|
"stylelint-config-standard": "^40.0.0",
|
|
113
117
|
"stylelint-config-standard-scss": "^17.0.0",
|
|
118
|
+
"stylelint-prettier": "^5.0.3",
|
|
114
119
|
"tslib": "^2.8.1",
|
|
115
120
|
"turbo": "^2.9.3",
|
|
116
121
|
"typescript": "^5.9.3",
|
|
@@ -125,6 +130,7 @@
|
|
|
125
130
|
"storybook": "$storybook"
|
|
126
131
|
},
|
|
127
132
|
"dependencies": {
|
|
133
|
+
"dompurify": "^3.4.7",
|
|
128
134
|
"wc-datepicker": "^0.10.0"
|
|
129
135
|
}
|
|
130
136
|
}
|
|
@@ -21,6 +21,9 @@ export interface NysDividerProps extends Pick<
|
|
|
21
21
|
/** Adjusts colors for dark backgrounds. */
|
|
22
22
|
inverted?: boolean;
|
|
23
23
|
|
|
24
|
+
/** If true, the divider will use a lighter color. */
|
|
25
|
+
subtle?: boolean;
|
|
26
|
+
|
|
24
27
|
/** 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()`. */
|
|
25
28
|
className?: string;
|
|
26
29
|
|
|
@@ -2,7 +2,7 @@ import React, { forwardRef } from "react";
|
|
|
2
2
|
import "../../dist/nysds.es.js";
|
|
3
3
|
|
|
4
4
|
export const NysDivider = forwardRef((props, forwardedRef) => {
|
|
5
|
-
const { inverted, ...filteredProps } = props;
|
|
5
|
+
const { inverted, subtle, ...filteredProps } = props;
|
|
6
6
|
|
|
7
7
|
return React.createElement(
|
|
8
8
|
"nys-divider",
|
|
@@ -14,6 +14,7 @@ export const NysDivider = forwardRef((props, forwardedRef) => {
|
|
|
14
14
|
part: props.part,
|
|
15
15
|
tabindex: props.tabIndex,
|
|
16
16
|
inverted: props.inverted ? true : undefined,
|
|
17
|
+
subtle: props.subtle ? true : undefined,
|
|
17
18
|
style: { ...props.style },
|
|
18
19
|
},
|
|
19
20
|
props.children,
|
|
@@ -18,9 +18,12 @@ export interface NysIconProps extends Pick<
|
|
|
18
18
|
| "onFocus"
|
|
19
19
|
| "onBlur"
|
|
20
20
|
> {
|
|
21
|
-
/** Icon name from
|
|
21
|
+
/** Icon name to resolve from the selected library. Required. */
|
|
22
22
|
name?: NysIconElement["name"];
|
|
23
23
|
|
|
24
|
+
/** Which registered icon library to use. Defaults to the built-in NYSDS library. */
|
|
25
|
+
library?: NysIconElement["library"];
|
|
26
|
+
|
|
24
27
|
/** Accessible label. When set, removes `aria-hidden` and adds `aria-label` to the SVG. */
|
|
25
28
|
ariaLabel?: NysIconElement["ariaLabel"];
|
|
26
29
|
|
|
@@ -56,11 +59,17 @@ export interface NysIconProps extends Pick<
|
|
|
56
59
|
|
|
57
60
|
/** 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
61
|
tabIndex?: number;
|
|
62
|
+
|
|
63
|
+
/** Resolves when the current icon load (if any) is complete. */
|
|
64
|
+
updateComplete?: NysIconElement["updateComplete"];
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
/**
|
|
62
|
-
* SVG icon
|
|
68
|
+
* SVG icon with swappable library support, size, rotation, and color options.
|
|
63
69
|
* ---
|
|
64
70
|
*
|
|
71
|
+
*
|
|
72
|
+
* ### **Methods:**
|
|
73
|
+
* - **redraw()** - Called by the icon library registry when the current library changes.
|
|
65
74
|
*/
|
|
66
75
|
export const NysIcon: React.ForwardRefExoticComponent<NysIconProps>;
|
|
@@ -1,15 +1,38 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
1
|
+
import React, { forwardRef, useRef, useEffect } from "react";
|
|
2
2
|
import "../../dist/nysds.es.js";
|
|
3
|
+
import { useProperties } from "./react-utils.js";
|
|
3
4
|
|
|
4
5
|
export const NysIcon = forwardRef((props, forwardedRef) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const {
|
|
8
|
+
name,
|
|
9
|
+
library,
|
|
10
|
+
ariaLabel,
|
|
11
|
+
rotate,
|
|
12
|
+
flip,
|
|
13
|
+
color,
|
|
14
|
+
size,
|
|
15
|
+
updateComplete,
|
|
16
|
+
...filteredProps
|
|
17
|
+
} = props;
|
|
18
|
+
|
|
19
|
+
/** Properties - run whenever a property has changed */
|
|
20
|
+
useProperties(ref, "updateComplete", props.updateComplete);
|
|
7
21
|
|
|
8
22
|
return React.createElement(
|
|
9
23
|
"nys-icon",
|
|
10
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
|
+
},
|
|
11
33
|
...filteredProps,
|
|
12
34
|
name: props.name,
|
|
35
|
+
library: props.library,
|
|
13
36
|
ariaLabel: props.ariaLabel,
|
|
14
37
|
rotate: props.rotate,
|
|
15
38
|
flip: props.flip,
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
NysRadiobutton as NysRadiobuttonElement,
|
|
4
|
-
CustomEvent,
|
|
5
|
-
Event,
|
|
6
|
-
} from "../../dist/nysds.es.js";
|
|
2
|
+
import { NysRadiobutton as NysRadiobuttonElement } from "../../dist/nysds.es.js";
|
|
7
3
|
|
|
8
|
-
export type { NysRadiobuttonElement
|
|
4
|
+
export type { NysRadiobuttonElement };
|
|
9
5
|
|
|
10
6
|
export interface NysRadiobuttonProps extends Pick<
|
|
11
7
|
React.AllHTMLAttributes<HTMLElement>,
|
|
@@ -82,41 +78,29 @@ export interface NysRadiobuttonProps extends Pick<
|
|
|
82
78
|
/** 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. */
|
|
83
79
|
tabIndex?: number;
|
|
84
80
|
|
|
85
|
-
/** undefined */
|
|
86
|
-
onNysErrorClear?: (event: CustomEvent) => void;
|
|
87
|
-
|
|
88
81
|
/** Fired when selection changes. Detail: `{id, checked, name, value}`. */
|
|
89
82
|
onNysChange?: (event: CustomEvent) => void;
|
|
90
83
|
|
|
91
|
-
/** Fired when "other" text input value changes. Detail: `{id, name, value}`. */
|
|
92
|
-
onNysOtherInput?: (event: CustomEvent) => void;
|
|
93
|
-
|
|
94
84
|
/** Fired when radio gains focus. */
|
|
95
85
|
onNysFocus?: (event: CustomEvent) => void;
|
|
96
86
|
|
|
97
87
|
/** Fired when radio loses focus. */
|
|
98
88
|
onNysBlur?: (event: CustomEvent) => void;
|
|
99
89
|
|
|
100
|
-
/**
|
|
101
|
-
|
|
90
|
+
/** Fired when "other" text input value changes. Detail: `{id, name, value}`. */
|
|
91
|
+
onNysOtherInput?: (event: CustomEvent) => void;
|
|
102
92
|
}
|
|
103
93
|
|
|
104
94
|
/**
|
|
105
|
-
* Radio button for single selection from mutually exclusive options.
|
|
95
|
+
* Radio button for single selection from mutually exclusive options. This is a READONLY data component.
|
|
106
96
|
* ---
|
|
107
97
|
*
|
|
108
98
|
*
|
|
109
99
|
* ### **Events:**
|
|
110
|
-
* - **nys-
|
|
111
|
-
* - **nys-change** - Fired when selection changes. Detail: `{id, checked, name, value}`.
|
|
112
|
-
* - **nys-other-input** - Fired when "other" text input value changes. Detail: `{id, name, value}`.
|
|
100
|
+
* - **nys-change** - Fired when selection changes. Detail: `{id, checked, name, value}`.
|
|
113
101
|
* - **nys-focus** - Fired when radio gains focus.
|
|
114
102
|
* - **nys-blur** - Fired when radio loses focus.
|
|
115
|
-
* - **nys-
|
|
116
|
-
*
|
|
117
|
-
* ### **Methods:**
|
|
118
|
-
* - **getInputElement(): _Promise<HTMLInputElement | null>_** - Functions
|
|
119
|
-
* --------------------------------------------------------------------------
|
|
103
|
+
* - **nys-other-input** - Fired when "other" text input value changes. Detail: `{id, name, value}`.
|
|
120
104
|
*
|
|
121
105
|
* ### **Slots:**
|
|
122
106
|
* - **description** - Custom HTML description content.
|
|
@@ -22,12 +22,10 @@ export const NysRadiobutton = forwardRef((props, forwardedRef) => {
|
|
|
22
22
|
} = props;
|
|
23
23
|
|
|
24
24
|
/** Event listeners - run once */
|
|
25
|
-
useEventListener(ref, "nys-error-clear", props.onNysErrorClear);
|
|
26
25
|
useEventListener(ref, "nys-change", props.onNysChange);
|
|
27
|
-
useEventListener(ref, "nys-other-input", props.onNysOtherInput);
|
|
28
26
|
useEventListener(ref, "nys-focus", props.onNysFocus);
|
|
29
27
|
useEventListener(ref, "nys-blur", props.onNysBlur);
|
|
30
|
-
useEventListener(ref, "nys-
|
|
28
|
+
useEventListener(ref, "nys-other-input", props.onNysOtherInput);
|
|
31
29
|
|
|
32
30
|
return React.createElement(
|
|
33
31
|
"nys-radiobutton",
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
NysRadiogroup as NysRadiogroupElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
} from "../../dist/nysds.es.js";
|
|
3
6
|
|
|
4
|
-
export type { NysRadiogroupElement };
|
|
7
|
+
export type { NysRadiogroupElement, CustomEvent };
|
|
5
8
|
|
|
6
9
|
export interface NysRadiogroupProps extends Pick<
|
|
7
10
|
React.AllHTMLAttributes<HTMLElement>,
|
|
@@ -30,6 +33,9 @@ export interface NysRadiogroupProps extends Pick<
|
|
|
30
33
|
/** Renders all radiobuttons as tiles with larger clickable area. */
|
|
31
34
|
tile?: boolean;
|
|
32
35
|
|
|
36
|
+
/** undefined */
|
|
37
|
+
_showOtherError?: boolean;
|
|
38
|
+
|
|
33
39
|
/** Unique identifier. Auto-generated if not provided. */
|
|
34
40
|
id?: NysRadiogroupElement["id"];
|
|
35
41
|
|
|
@@ -74,6 +80,12 @@ export interface NysRadiogroupProps extends Pick<
|
|
|
74
80
|
|
|
75
81
|
/** 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. */
|
|
76
82
|
tabIndex?: number;
|
|
83
|
+
|
|
84
|
+
/** undefined */
|
|
85
|
+
onNysChange?: (event: CustomEvent) => void;
|
|
86
|
+
|
|
87
|
+
/** undefined */
|
|
88
|
+
onNysOtherInput?: (event: CustomEvent) => void;
|
|
77
89
|
}
|
|
78
90
|
|
|
79
91
|
/**
|
|
@@ -81,6 +93,10 @@ export interface NysRadiogroupProps extends Pick<
|
|
|
81
93
|
* ---
|
|
82
94
|
*
|
|
83
95
|
*
|
|
96
|
+
* ### **Events:**
|
|
97
|
+
* - **nys-change**
|
|
98
|
+
* - **nys-other-input**
|
|
99
|
+
*
|
|
84
100
|
* ### **Slots:**
|
|
85
101
|
* - _default_ - Default slot for `nys-radiobutton` elements.
|
|
86
102
|
* - **description** - Custom HTML description content.
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
1
|
+
import React, { forwardRef, useRef, useEffect } from "react";
|
|
2
2
|
import "../../dist/nysds.es.js";
|
|
3
|
+
import { useEventListener } from "./react-utils.js";
|
|
3
4
|
|
|
4
5
|
export const NysRadiogroup = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
5
7
|
const {
|
|
6
8
|
required,
|
|
7
9
|
optional,
|
|
8
10
|
showError,
|
|
9
11
|
tile,
|
|
12
|
+
_showOtherError,
|
|
10
13
|
id,
|
|
11
14
|
name,
|
|
12
15
|
errorMessage,
|
|
@@ -18,9 +21,21 @@ export const NysRadiogroup = forwardRef((props, forwardedRef) => {
|
|
|
18
21
|
...filteredProps
|
|
19
22
|
} = props;
|
|
20
23
|
|
|
24
|
+
/** Event listeners - run once */
|
|
25
|
+
useEventListener(ref, "nys-change", props.onNysChange);
|
|
26
|
+
useEventListener(ref, "nys-other-input", props.onNysOtherInput);
|
|
27
|
+
|
|
21
28
|
return React.createElement(
|
|
22
29
|
"nys-radiogroup",
|
|
23
30
|
{
|
|
31
|
+
ref: (node) => {
|
|
32
|
+
ref.current = node;
|
|
33
|
+
if (typeof forwardedRef === "function") {
|
|
34
|
+
forwardedRef(node);
|
|
35
|
+
} else if (forwardedRef) {
|
|
36
|
+
forwardedRef.current = node;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
24
39
|
...filteredProps,
|
|
25
40
|
id: props.id,
|
|
26
41
|
name: props.name,
|
|
@@ -39,6 +54,7 @@ export const NysRadiogroup = forwardRef((props, forwardedRef) => {
|
|
|
39
54
|
optional: props.optional ? true : undefined,
|
|
40
55
|
showError: props.showError ? true : undefined,
|
|
41
56
|
tile: props.tile ? true : undefined,
|
|
57
|
+
_showOtherError: props._showOtherError ? true : undefined,
|
|
42
58
|
style: { ...props.style },
|
|
43
59
|
},
|
|
44
60
|
props.children,
|
|
@@ -18,24 +18,22 @@ export interface NysStepProps extends Pick<
|
|
|
18
18
|
| "onFocus"
|
|
19
19
|
| "onBlur"
|
|
20
20
|
> {
|
|
21
|
-
/**
|
|
21
|
+
/** Which step is currently being displayed. If not set, defaults to the `current` step.
|
|
22
|
+
Setting this on a step after `current` is silently corrected to match `current`.
|
|
23
|
+
When controlling state from a framework, always set this explicitly. */
|
|
22
24
|
selected?: boolean;
|
|
23
25
|
|
|
24
|
-
/**
|
|
26
|
+
/** The furthest step the user has reached (progress boundary). Steps before this are navigable. */
|
|
25
27
|
current?: boolean;
|
|
26
28
|
|
|
27
|
-
/** Internal: Whether parent stepper's compact view is expanded. */
|
|
28
|
-
isCompactExpanded?: boolean;
|
|
29
|
-
|
|
30
29
|
/** Step label text displayed alongside the step number. */
|
|
31
30
|
label?: NysStepElement["label"];
|
|
32
31
|
|
|
33
|
-
/** URL
|
|
32
|
+
/** URL navigated to when the step is activated, via `window.location.href`.
|
|
33
|
+
Navigation is suppressed if the `nys-step-click` listener calls `e.preventDefault()`.
|
|
34
|
+
Omit for SPA/framework routing and handle navigation in the event listener instead. */
|
|
34
35
|
href?: NysStepElement["href"];
|
|
35
36
|
|
|
36
|
-
/** Step number (1-indexed). Auto-assigned by parent stepper. */
|
|
37
|
-
stepNumber?: NysStepElement["stepNumber"];
|
|
38
|
-
|
|
39
37
|
/** 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
38
|
className?: string;
|
|
41
39
|
|
|
@@ -57,10 +55,10 @@ export interface NysStepProps extends Pick<
|
|
|
57
55
|
/** 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
56
|
tabIndex?: number;
|
|
59
57
|
|
|
60
|
-
/**
|
|
58
|
+
/** Optional function called before `nys-step-click` is dispatched. Use for pre-navigation logic. */
|
|
61
59
|
onClick?: NysStepElement["onClick"];
|
|
62
60
|
|
|
63
|
-
/** Fired when a navigable step is clicked. Detail: `{href, label}`. Cancelable. */
|
|
61
|
+
/** Fired when a navigable (`previous` or `current`) non-selected step is clicked or activated by keyboard. Detail: `{ href: string, label: string }`. Cancelable — call `e.preventDefault()` to suppress `window.location.href` navigation. */
|
|
64
62
|
onNysStepClick?: (event: CustomEvent) => void;
|
|
65
63
|
}
|
|
66
64
|
|
|
@@ -70,6 +68,6 @@ export interface NysStepProps extends Pick<
|
|
|
70
68
|
*
|
|
71
69
|
*
|
|
72
70
|
* ### **Events:**
|
|
73
|
-
* - **nys-step-click** - Fired when a navigable step is clicked. Detail: `{href, label}`. Cancelable.
|
|
71
|
+
* - **nys-step-click** - Fired when a navigable (`previous` or `current`) non-selected step is clicked or activated by keyboard. Detail: `{ href: string, label: string }`. Cancelable — call `e.preventDefault()` to suppress `window.location.href` navigation.
|
|
74
72
|
*/
|
|
75
73
|
export const NysStep: React.ForwardRefExoticComponent<NysStepProps>;
|
|
@@ -4,16 +4,7 @@ import { useEventListener, useProperties } from "./react-utils.js";
|
|
|
4
4
|
|
|
5
5
|
export const NysStep = forwardRef((props, forwardedRef) => {
|
|
6
6
|
const ref = useRef(null);
|
|
7
|
-
const {
|
|
8
|
-
selected,
|
|
9
|
-
current,
|
|
10
|
-
isCompactExpanded,
|
|
11
|
-
label,
|
|
12
|
-
href,
|
|
13
|
-
stepNumber,
|
|
14
|
-
onClick,
|
|
15
|
-
...filteredProps
|
|
16
|
-
} = props;
|
|
7
|
+
const { selected, current, label, href, onClick, ...filteredProps } = props;
|
|
17
8
|
|
|
18
9
|
/** Event listeners - run once */
|
|
19
10
|
useEventListener(ref, "nys-step-click", props.onNysStepClick);
|
|
@@ -35,7 +26,6 @@ export const NysStep = forwardRef((props, forwardedRef) => {
|
|
|
35
26
|
...filteredProps,
|
|
36
27
|
label: props.label,
|
|
37
28
|
href: props.href,
|
|
38
|
-
stepNumber: props.stepNumber,
|
|
39
29
|
class: props.className,
|
|
40
30
|
exportparts: props.exportparts,
|
|
41
31
|
for: props.htmlFor,
|
|
@@ -43,7 +33,6 @@ export const NysStep = forwardRef((props, forwardedRef) => {
|
|
|
43
33
|
tabindex: props.tabIndex,
|
|
44
34
|
selected: props.selected ? true : undefined,
|
|
45
35
|
current: props.current ? true : undefined,
|
|
46
|
-
isCompactExpanded: props.isCompactExpanded ? true : undefined,
|
|
47
36
|
style: { ...props.style },
|
|
48
37
|
},
|
|
49
38
|
props.children,
|
|
@@ -18,19 +18,19 @@ export interface NysStepperProps extends Pick<
|
|
|
18
18
|
| "onFocus"
|
|
19
19
|
| "onBlur"
|
|
20
20
|
> {
|
|
21
|
-
/** Whether compact mobile view is expanded to show all steps. */
|
|
21
|
+
/** Whether compact mobile view is expanded to show all steps. Toggled by clicking the counter. */
|
|
22
22
|
isCompactExpanded?: boolean;
|
|
23
23
|
|
|
24
|
-
/** Unique identifier. */
|
|
24
|
+
/** Unique identifier. Auto-generated as `nys-stepper-{n}-{timestamp}` if not provided. */
|
|
25
25
|
id?: NysStepperElement["id"];
|
|
26
26
|
|
|
27
27
|
/** Name attribute for form association. */
|
|
28
28
|
name?: NysStepperElement["name"];
|
|
29
29
|
|
|
30
|
-
/** Title displayed above the step counter. */
|
|
30
|
+
/** Title displayed above the step list and compact counter. */
|
|
31
31
|
label?: NysStepperElement["label"];
|
|
32
32
|
|
|
33
|
-
/** Progress text (e.g., "Step 2 of 5"). Auto-
|
|
33
|
+
/** Progress text displayed in compact mode (e.g., "Step 2 of 5"). Auto-managed — do not set manually. */
|
|
34
34
|
counterText?: NysStepperElement["counterText"];
|
|
35
35
|
|
|
36
36
|
/** 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()`. */
|
|
@@ -61,7 +61,7 @@ export interface NysStepperProps extends Pick<
|
|
|
61
61
|
*
|
|
62
62
|
*
|
|
63
63
|
* ### **Slots:**
|
|
64
|
-
* - _default_ - Default slot for `nys-step` elements.
|
|
65
|
-
* - **actions** -
|
|
64
|
+
* - _default_ - Default slot for `nys-step` elements. Only `nys-step` children are accepted; others are removed.
|
|
65
|
+
* - **actions** - Persistent navigation buttons. Must contain exactly one `<div>` wrapping only `<nys-button>` elements.
|
|
66
66
|
*/
|
|
67
67
|
export const NysStepper: React.ForwardRefExoticComponent<NysStepperProps>;
|