@nysds/components 1.14.0 → 1.15.1
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 +2350 -598
- package/dist/.vscode/vscode.html-custom-data.json +63 -7
- package/dist/custom-elements.json +2350 -598
- package/dist/nysds.es.js +2754 -1819
- package/dist/nysds.es.js.map +1 -1
- package/dist/nysds.js +340 -117
- package/dist/nysds.js.map +1 -1
- package/dist/packages/nys-button/src/nys-button.d.ts +8 -0
- package/dist/packages/nys-checkbox/src/nys-checkbox.d.ts +10 -0
- package/dist/packages/nys-checkbox/src/nys-checkboxgroup.d.ts +8 -0
- package/dist/packages/nys-combobox/src/index.d.ts +1 -0
- package/dist/packages/nys-combobox/src/nys-combobox.d.ts +118 -0
- package/dist/packages/nys-combobox/src/nys-combobox.figma.d.ts +1 -0
- package/dist/packages/nys-datepicker/src/nys-datepicker.d.ts +9 -0
- package/dist/packages/nys-dropdownmenu/src/index.d.ts +2 -0
- package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenu.d.ts +110 -0
- package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenu.figma.d.ts +1 -0
- package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenuitem.d.ts +40 -0
- package/dist/packages/nys-fileinput/src/nys-fileinput.d.ts +8 -0
- package/dist/packages/nys-fileinput/src/nys-fileitem.d.ts +8 -0
- package/dist/packages/nys-globalheader/src/nys-globalheader.d.ts +4 -2
- package/dist/packages/nys-radiobutton/src/nys-radiobutton.d.ts +10 -0
- package/dist/packages/nys-radiobutton/src/nys-radiogroup.d.ts +8 -0
- package/dist/packages/nys-select/src/nys-select.d.ts +8 -0
- package/dist/packages/nys-table/src/nys-table.d.ts +12 -1
- package/dist/packages/nys-textarea/src/nys-textarea.d.ts +8 -0
- package/dist/packages/nys-textinput/src/nys-textinput.d.ts +8 -1
- package/dist/packages/nys-toggle/src/nys-toggle.d.ts +10 -1
- package/dist/packages/nys-unavheader/src/nys-unavheader.d.ts +10 -1
- package/dist/src/index.d.ts +2 -0
- package/package.json +19 -10
- package/packages/react/NysAccordion.d.ts +65 -0
- package/packages/react/NysAccordion.js +23 -0
- package/packages/react/NysAccordionItem.d.ts +72 -0
- package/packages/react/NysAccordionItem.js +41 -0
- package/packages/react/NysAlert.d.ts +104 -0
- package/packages/react/NysAlert.js +63 -0
- package/packages/react/NysAvatar.d.ts +78 -0
- package/packages/react/NysAvatar.js +40 -0
- package/packages/react/NysBacktotop.d.ts +54 -0
- package/packages/react/NysBacktotop.js +22 -0
- package/packages/react/NysBadge.d.ts +75 -0
- package/packages/react/NysBadge.js +40 -0
- package/packages/react/NysButton.d.ts +141 -0
- package/packages/react/NysButton.js +81 -0
- package/packages/react/NysCheckbox.d.ts +139 -0
- package/packages/react/NysCheckbox.js +76 -0
- package/packages/react/NysCheckboxgroup.d.ts +91 -0
- package/packages/react/NysCheckboxgroup.js +48 -0
- package/packages/react/NysCombobox.d.ts +126 -0
- package/packages/react/NysCombobox.js +66 -0
- package/packages/react/NysDatepicker.d.ts +122 -0
- package/packages/react/NysDatepicker.js +72 -0
- package/packages/react/NysDivider.d.ts +51 -0
- package/packages/react/NysDivider.js +21 -0
- package/packages/react/NysDropdownMenu.d.ts +54 -0
- package/packages/react/NysDropdownMenu.js +22 -0
- package/packages/react/NysDropdownMenuItem.d.ts +75 -0
- package/packages/react/NysDropdownMenuItem.js +47 -0
- package/packages/react/NysErrorMessage.d.ts +57 -0
- package/packages/react/NysErrorMessage.js +23 -0
- package/packages/react/NysFileItem.d.ts +69 -0
- package/packages/react/NysFileItem.js +37 -0
- package/packages/react/NysFileinput.d.ts +108 -0
- package/packages/react/NysFileinput.js +67 -0
- package/packages/react/NysGlobalFooter.d.ts +57 -0
- package/packages/react/NysGlobalFooter.js +22 -0
- package/packages/react/NysGlobalHeader.d.ts +60 -0
- package/packages/react/NysGlobalHeader.js +23 -0
- package/packages/react/NysIcon.d.ts +66 -0
- package/packages/react/NysIcon.js +27 -0
- package/packages/react/NysLabel.d.ts +66 -0
- package/packages/react/NysLabel.js +26 -0
- package/packages/react/NysModal.d.ts +83 -0
- package/packages/react/NysModal.js +41 -0
- package/packages/react/NysOption.d.ts +66 -0
- package/packages/react/NysOption.js +25 -0
- package/packages/react/NysPagination.d.ts +72 -0
- package/packages/react/NysPagination.js +45 -0
- package/packages/react/NysRadiobutton.d.ts +127 -0
- package/packages/react/NysRadiobutton.js +68 -0
- package/packages/react/NysRadiogroup.d.ts +91 -0
- package/packages/react/NysRadiogroup.js +48 -0
- package/packages/react/NysSelect.d.ts +116 -0
- package/packages/react/NysSelect.js +65 -0
- package/packages/react/NysSkipnav.d.ts +54 -0
- package/packages/react/NysSkipnav.js +22 -0
- package/packages/react/NysStep.d.ts +75 -0
- package/packages/react/NysStep.js +51 -0
- package/packages/react/NysStepper.d.ts +67 -0
- package/packages/react/NysStepper.js +26 -0
- package/packages/react/NysTable.d.ts +80 -0
- package/packages/react/NysTable.js +41 -0
- package/packages/react/NysTextarea.d.ts +138 -0
- package/packages/react/NysTextarea.js +77 -0
- package/packages/react/NysTextinput.d.ts +144 -0
- package/packages/react/NysTextinput.js +83 -0
- package/packages/react/NysToggle.d.ts +102 -0
- package/packages/react/NysToggle.js +59 -0
- package/packages/react/NysTooltip.d.ts +60 -0
- package/packages/react/NysTooltip.js +24 -0
- package/packages/react/NysUnavFooter.d.ts +48 -0
- package/packages/react/NysUnavFooter.js +18 -0
- package/packages/react/NysUnavHeader.d.ts +72 -0
- package/packages/react/NysUnavHeader.js +38 -0
- package/packages/react/README.md +92 -0
- package/packages/react/index.d.ts +37 -0
- package/packages/react/index.js +37 -0
- package/packages/react/react-utils.js +40 -0
- package/dist/nys-stepper/newsletter.html +0 -4
- package/dist/nys-stepper/personal.html +0 -6
- package/dist/nys-stepper/survey.html +0 -5
- package/dist/nys-stepper/team.html +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nysds/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"description": "New York State's design system and code component library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
],
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/",
|
|
11
|
-
"custom-elements.json"
|
|
11
|
+
"custom-elements.json",
|
|
12
|
+
"packages/react/"
|
|
12
13
|
],
|
|
13
14
|
"main": "dist/nysds.js",
|
|
14
15
|
"module": "dist/nysds.es.js",
|
|
@@ -18,6 +19,10 @@
|
|
|
18
19
|
"types": "./dist/src/index.d.ts",
|
|
19
20
|
"import": "./dist/nysds.es.js",
|
|
20
21
|
"require": "./dist/nysds.js"
|
|
22
|
+
},
|
|
23
|
+
"./react": {
|
|
24
|
+
"import": "./packages/react/index.js",
|
|
25
|
+
"types": "./packages/react/index.d.ts"
|
|
21
26
|
}
|
|
22
27
|
},
|
|
23
28
|
"customElements": "custom-elements.json",
|
|
@@ -25,29 +30,31 @@
|
|
|
25
30
|
"dev": "vite",
|
|
26
31
|
"gen": "plop",
|
|
27
32
|
"build": "tsc --emitDeclarationOnly && vite build",
|
|
28
|
-
"build:umd": "
|
|
29
|
-
"
|
|
30
|
-
"build:
|
|
33
|
+
"build:umd": "cross-env BUILD_FORMAT=umd vite build",
|
|
34
|
+
"tsc:packages": "tsc -b tsconfig.build.json",
|
|
35
|
+
"build:packages": "npm run tsc:packages && turbo run build --filter='./packages/*'",
|
|
36
|
+
"build:root": "cross-env NODE_ENV=production npm run build && cross-env NODE_ENV=production npm run build:umd",
|
|
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 mcp-server:build",
|
|
31
38
|
"build:link": "npm run build:all && npm link",
|
|
32
|
-
"lint": "eslint && stylelint **/*.scss || true",
|
|
39
|
+
"lint": "eslint --cache --cache-location node_modules/.cache/eslint && stylelint **/*.scss || true",
|
|
33
40
|
"lint:fix": "eslint --fix && stylelint **/*.scss --fix",
|
|
34
41
|
"lit-analyze": "find ./packages/nys-*/ -name '*.ts' ! -name '*.figma.*' | xargs lit-analyzer {}",
|
|
35
42
|
"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",
|
|
36
43
|
"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",
|
|
37
44
|
"release:alpha": "npm run build && npm run build:umd && npm publish --tag next",
|
|
45
|
+
"release:zip": "npm run build:all && node src/scripts/create-release-zip.js",
|
|
38
46
|
"test": "npx playwright install && wtr --node-resolve",
|
|
39
47
|
"test:build": "npm run build:all && npm run test",
|
|
40
48
|
"storybook": "cross-env NODE_ENV=production storybook dev -p 6006",
|
|
41
49
|
"storybook:build:all": "cross-env NODE_ENV=production npm run build:all && npm run storybook",
|
|
42
50
|
"build-storybook": "npm run build:packages && storybook build",
|
|
43
51
|
"storybook:cibuild": "storybook build",
|
|
44
|
-
"mcp-server:build": "
|
|
52
|
+
"mcp-server:build": "turbo run build --filter=@nysds/mcp-server",
|
|
45
53
|
"clean:node": "rm -rf node_modules && rm -rf packages/*/node_modules && rm -rf packages/**/*/node_modules",
|
|
46
54
|
"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",
|
|
47
|
-
"clean:all": "npm run clean:dist && npm run clean:node",
|
|
55
|
+
"clean:all": "npm run clean:dist && npm run clean:node && find packages -name '*.tsbuildinfo' -delete 2>/dev/null || true",
|
|
48
56
|
"code-connect": "dotenv -- npx figma connect publish",
|
|
49
|
-
"cem": "npx cem analyze --config ./custom-elements-manifest.config.mjs"
|
|
50
|
-
"cem:copy": "cp ./custom-elements.json dist/"
|
|
57
|
+
"cem": "npx cem analyze --config ./custom-elements-manifest.config.mjs && cp ./custom-elements.json dist/ && node src/scripts/patch-react-utils.js"
|
|
51
58
|
},
|
|
52
59
|
"repository": {
|
|
53
60
|
"type": "git",
|
|
@@ -59,6 +66,7 @@
|
|
|
59
66
|
"url": "https://github.com/ITS-HCD/nysds/issues"
|
|
60
67
|
},
|
|
61
68
|
"homepage": "https://designsystem.ny.gov/",
|
|
69
|
+
"packageManager": "npm@11.6.2",
|
|
62
70
|
"devDependencies": {
|
|
63
71
|
"@chromatic-com/storybook": "^5.0.1",
|
|
64
72
|
"@custom-elements-manifest/analyzer": "^0.11.0",
|
|
@@ -99,6 +107,7 @@
|
|
|
99
107
|
"stylelint-config-standard": "^40.0.0",
|
|
100
108
|
"stylelint-config-standard-scss": "^17.0.0",
|
|
101
109
|
"tslib": "^2.8.1",
|
|
110
|
+
"turbo": "^2.8.19",
|
|
102
111
|
"typescript": "^5.9.3",
|
|
103
112
|
"vite": "^7.3.1"
|
|
104
113
|
},
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysAccordion as NysAccordionElement } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysAccordionElement };
|
|
5
|
+
|
|
6
|
+
export interface NysAccordionProps extends Pick<
|
|
7
|
+
React.AllHTMLAttributes<HTMLElement>,
|
|
8
|
+
| "children"
|
|
9
|
+
| "dir"
|
|
10
|
+
| "hidden"
|
|
11
|
+
| "id"
|
|
12
|
+
| "lang"
|
|
13
|
+
| "slot"
|
|
14
|
+
| "style"
|
|
15
|
+
| "title"
|
|
16
|
+
| "translate"
|
|
17
|
+
| "onClick"
|
|
18
|
+
| "onFocus"
|
|
19
|
+
| "onBlur"
|
|
20
|
+
> {
|
|
21
|
+
/** Only one item can be expanded at a time. Expanding one collapses others. */
|
|
22
|
+
singleSelect?: boolean;
|
|
23
|
+
|
|
24
|
+
/** Adds borders around each accordion item. Propagates to all children. */
|
|
25
|
+
bordered?: boolean;
|
|
26
|
+
|
|
27
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
28
|
+
id?: NysAccordionElement["id"];
|
|
29
|
+
|
|
30
|
+
/** 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()`. */
|
|
31
|
+
className?: string;
|
|
32
|
+
|
|
33
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
34
|
+
exportparts?: string;
|
|
35
|
+
|
|
36
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
37
|
+
htmlFor?: string;
|
|
38
|
+
|
|
39
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
40
|
+
key?: number | string;
|
|
41
|
+
|
|
42
|
+
/** 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. */
|
|
43
|
+
part?: string;
|
|
44
|
+
|
|
45
|
+
/** 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. */
|
|
46
|
+
ref?: any;
|
|
47
|
+
|
|
48
|
+
/** 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. */
|
|
49
|
+
tabIndex?: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Container for accordion items with optional single-select and bordered styling.
|
|
54
|
+
* ---
|
|
55
|
+
*
|
|
56
|
+
*
|
|
57
|
+
* ### **Slots:**
|
|
58
|
+
* - _default_ - Default slot for `nys-accordionitem` elements.
|
|
59
|
+
*
|
|
60
|
+
* ### **CSS Properties:**
|
|
61
|
+
* - **--nys-accordion-background-color--header** - Background color of the accordion header. _(default: undefined)_
|
|
62
|
+
* - **--nys-accordion-background-color--header--hover** - Background hover color of the accordion header. _(default: undefined)_
|
|
63
|
+
* - **--nys-accordion-content-max-width** - Maximum readable width of accordion content. Defaults to a character-based width (80ch) for readability. _(default: undefined)_
|
|
64
|
+
*/
|
|
65
|
+
export const NysAccordion: React.ForwardRefExoticComponent<NysAccordionProps>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export const NysAccordion = forwardRef((props, forwardedRef) => {
|
|
5
|
+
const { singleSelect, bordered, id, ...filteredProps } = props;
|
|
6
|
+
|
|
7
|
+
return React.createElement(
|
|
8
|
+
"nys-accordion",
|
|
9
|
+
{
|
|
10
|
+
...filteredProps,
|
|
11
|
+
id: props.id,
|
|
12
|
+
class: props.className,
|
|
13
|
+
exportparts: props.exportparts,
|
|
14
|
+
for: props.htmlFor,
|
|
15
|
+
part: props.part,
|
|
16
|
+
tabindex: props.tabIndex,
|
|
17
|
+
singleSelect: props.singleSelect ? true : undefined,
|
|
18
|
+
bordered: props.bordered ? true : undefined,
|
|
19
|
+
style: { ...props.style },
|
|
20
|
+
},
|
|
21
|
+
props.children,
|
|
22
|
+
);
|
|
23
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
NysAccordionItem as NysAccordionItemElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
} from "../../dist/nysds.es.js";
|
|
6
|
+
|
|
7
|
+
export type { NysAccordionItemElement, CustomEvent };
|
|
8
|
+
|
|
9
|
+
export interface NysAccordionItemProps 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
|
+
/** Whether the content panel is visible. Toggle via click or keyboard. */
|
|
25
|
+
expanded?: boolean;
|
|
26
|
+
|
|
27
|
+
/** Adds border styling. Set by parent `nys-accordion`, not directly. */
|
|
28
|
+
bordered?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
31
|
+
id?: NysAccordionItemElement["id"];
|
|
32
|
+
|
|
33
|
+
/** Heading text displayed in the clickable toggle button. */
|
|
34
|
+
heading?: NysAccordionItemElement["heading"];
|
|
35
|
+
|
|
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()`. */
|
|
37
|
+
className?: string;
|
|
38
|
+
|
|
39
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
40
|
+
exportparts?: string;
|
|
41
|
+
|
|
42
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
43
|
+
htmlFor?: string;
|
|
44
|
+
|
|
45
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
46
|
+
key?: number | string;
|
|
47
|
+
|
|
48
|
+
/** 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. */
|
|
49
|
+
part?: string;
|
|
50
|
+
|
|
51
|
+
/** 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. */
|
|
52
|
+
ref?: any;
|
|
53
|
+
|
|
54
|
+
/** 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. */
|
|
55
|
+
tabIndex?: number;
|
|
56
|
+
|
|
57
|
+
/** Fired when expanded state changes. Detail: `{id, heading, expanded}`. */
|
|
58
|
+
onNysAccordionitemToggle?: (event: CustomEvent) => void;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Collapsible panel for use within nys-accordion with keyboard support.
|
|
63
|
+
* ---
|
|
64
|
+
*
|
|
65
|
+
*
|
|
66
|
+
* ### **Events:**
|
|
67
|
+
* - **nys-accordionitem-toggle** - Fired when expanded state changes. Detail: `{id, heading, expanded}`.
|
|
68
|
+
*
|
|
69
|
+
* ### **Slots:**
|
|
70
|
+
* - _default_ - Default slot for panel content shown when expanded.
|
|
71
|
+
*/
|
|
72
|
+
export const NysAccordionItem: React.ForwardRefExoticComponent<NysAccordionItemProps>;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 NysAccordionItem = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const { expanded, bordered, id, heading, ...filteredProps } = props;
|
|
8
|
+
|
|
9
|
+
/** Event listeners - run once */
|
|
10
|
+
useEventListener(
|
|
11
|
+
ref,
|
|
12
|
+
"nys-accordionitem-toggle",
|
|
13
|
+
props.onNysAccordionitemToggle,
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return React.createElement(
|
|
17
|
+
"nys-accordionitem",
|
|
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
|
+
heading: props.heading,
|
|
30
|
+
class: props.className,
|
|
31
|
+
exportparts: props.exportparts,
|
|
32
|
+
for: props.htmlFor,
|
|
33
|
+
part: props.part,
|
|
34
|
+
tabindex: props.tabIndex,
|
|
35
|
+
expanded: props.expanded ? true : undefined,
|
|
36
|
+
bordered: props.bordered ? true : undefined,
|
|
37
|
+
style: { ...props.style },
|
|
38
|
+
},
|
|
39
|
+
props.children,
|
|
40
|
+
);
|
|
41
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
NysAlert as NysAlertElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
} from "../../dist/nysds.es.js";
|
|
6
|
+
|
|
7
|
+
export type { NysAlertElement, CustomEvent };
|
|
8
|
+
|
|
9
|
+
export interface NysAlertProps 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
|
+
/** Shows close button allowing users to dismiss the alert. */
|
|
25
|
+
dismissible?: boolean;
|
|
26
|
+
|
|
27
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
28
|
+
id?: NysAlertElement["id"];
|
|
29
|
+
|
|
30
|
+
/** Bold heading text displayed at the top of the alert. */
|
|
31
|
+
heading?: NysAlertElement["heading"];
|
|
32
|
+
|
|
33
|
+
/** Custom icon name. Defaults to type-appropriate icon if not set. */
|
|
34
|
+
icon?: NysAlertElement["icon"];
|
|
35
|
+
|
|
36
|
+
/** Auto-dismiss after specified milliseconds. Set to 0 to disable. */
|
|
37
|
+
duration?: NysAlertElement["duration"];
|
|
38
|
+
|
|
39
|
+
/** Body text content. Ignored if slot content is provided. */
|
|
40
|
+
text?: NysAlertElement["text"];
|
|
41
|
+
|
|
42
|
+
/** URL for the primary action link. */
|
|
43
|
+
primaryAction?: NysAlertElement["primaryAction"];
|
|
44
|
+
|
|
45
|
+
/** URL for the secondary action link. */
|
|
46
|
+
secondaryAction?: NysAlertElement["secondaryAction"];
|
|
47
|
+
|
|
48
|
+
/** Label text for primary action link. */
|
|
49
|
+
primaryLabel?: NysAlertElement["primaryLabel"];
|
|
50
|
+
|
|
51
|
+
/** Label text for secondary action link. */
|
|
52
|
+
secondaryLabel?: NysAlertElement["secondaryLabel"];
|
|
53
|
+
|
|
54
|
+
/** Semantic alert type affecting color and ARIA role. `danger`/`emergency` use assertive live region. */
|
|
55
|
+
type?: NysAlertElement["type"];
|
|
56
|
+
|
|
57
|
+
/** 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()`. */
|
|
58
|
+
className?: string;
|
|
59
|
+
|
|
60
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
61
|
+
exportparts?: string;
|
|
62
|
+
|
|
63
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
64
|
+
htmlFor?: string;
|
|
65
|
+
|
|
66
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
67
|
+
key?: number | string;
|
|
68
|
+
|
|
69
|
+
/** 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. */
|
|
70
|
+
part?: string;
|
|
71
|
+
|
|
72
|
+
/** 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. */
|
|
73
|
+
ref?: any;
|
|
74
|
+
|
|
75
|
+
/** 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
|
+
tabIndex?: number;
|
|
77
|
+
|
|
78
|
+
/** Returns ARIA role and label based on alert type.
|
|
79
|
+
- 'alert' => assertive live region (implied)
|
|
80
|
+
- 'status' => polite live region
|
|
81
|
+
- 'region' => generic, requires aria-label */
|
|
82
|
+
ariaAttributes?: NysAlertElement["ariaAttributes"];
|
|
83
|
+
|
|
84
|
+
/** Returns live-region type for screen readers if applicable.
|
|
85
|
+
- 'polite' for status role
|
|
86
|
+
- undefined for alert (since it's implicitly assertive) or region */
|
|
87
|
+
liveRegion?: NysAlertElement["liveRegion"];
|
|
88
|
+
|
|
89
|
+
/** Fired when alert is dismissed. Detail: `{id, type, label}`. */
|
|
90
|
+
onNysClose?: (event: CustomEvent) => void;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Alert for contextual feedback with semantic types and live region support.
|
|
95
|
+
* ---
|
|
96
|
+
*
|
|
97
|
+
*
|
|
98
|
+
* ### **Events:**
|
|
99
|
+
* - **nys-close** - Fired when alert is dismissed. Detail: `{id, type, label}`.
|
|
100
|
+
*
|
|
101
|
+
* ### **Slots:**
|
|
102
|
+
* - _default_ - Default slot for custom body content. Overrides `text` prop when provided.
|
|
103
|
+
*/
|
|
104
|
+
export const NysAlert: React.ForwardRefExoticComponent<NysAlertProps>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { forwardRef, useRef, useEffect } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
import { useEventListener, useProperties } from "./react-utils.js";
|
|
4
|
+
|
|
5
|
+
export const NysAlert = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const {
|
|
8
|
+
dismissible,
|
|
9
|
+
id,
|
|
10
|
+
heading,
|
|
11
|
+
icon,
|
|
12
|
+
duration,
|
|
13
|
+
text,
|
|
14
|
+
primaryAction,
|
|
15
|
+
secondaryAction,
|
|
16
|
+
primaryLabel,
|
|
17
|
+
secondaryLabel,
|
|
18
|
+
type,
|
|
19
|
+
ariaAttributes,
|
|
20
|
+
liveRegion,
|
|
21
|
+
...filteredProps
|
|
22
|
+
} = props;
|
|
23
|
+
|
|
24
|
+
/** Event listeners - run once */
|
|
25
|
+
useEventListener(ref, "nys-close", props.onNysClose);
|
|
26
|
+
|
|
27
|
+
/** Properties - run whenever a property has changed */
|
|
28
|
+
useProperties(ref, "ariaAttributes", props.ariaAttributes);
|
|
29
|
+
useProperties(ref, "liveRegion", props.liveRegion);
|
|
30
|
+
|
|
31
|
+
return React.createElement(
|
|
32
|
+
"nys-alert",
|
|
33
|
+
{
|
|
34
|
+
ref: (node) => {
|
|
35
|
+
ref.current = node;
|
|
36
|
+
if (typeof forwardedRef === "function") {
|
|
37
|
+
forwardedRef(node);
|
|
38
|
+
} else if (forwardedRef) {
|
|
39
|
+
forwardedRef.current = node;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
...filteredProps,
|
|
43
|
+
id: props.id,
|
|
44
|
+
heading: props.heading,
|
|
45
|
+
icon: props.icon,
|
|
46
|
+
duration: props.duration,
|
|
47
|
+
text: props.text,
|
|
48
|
+
primaryAction: props.primaryAction,
|
|
49
|
+
secondaryAction: props.secondaryAction,
|
|
50
|
+
primaryLabel: props.primaryLabel,
|
|
51
|
+
secondaryLabel: props.secondaryLabel,
|
|
52
|
+
type: props.type,
|
|
53
|
+
class: props.className,
|
|
54
|
+
exportparts: props.exportparts,
|
|
55
|
+
for: props.htmlFor,
|
|
56
|
+
part: props.part,
|
|
57
|
+
tabindex: props.tabIndex,
|
|
58
|
+
dismissible: props.dismissible ? true : undefined,
|
|
59
|
+
style: { ...props.style },
|
|
60
|
+
},
|
|
61
|
+
props.children,
|
|
62
|
+
);
|
|
63
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysAvatar as NysAvatarElement } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysAvatarElement };
|
|
5
|
+
|
|
6
|
+
export interface NysAvatarProps extends Pick<
|
|
7
|
+
React.AllHTMLAttributes<HTMLElement>,
|
|
8
|
+
| "children"
|
|
9
|
+
| "dir"
|
|
10
|
+
| "hidden"
|
|
11
|
+
| "id"
|
|
12
|
+
| "lang"
|
|
13
|
+
| "slot"
|
|
14
|
+
| "style"
|
|
15
|
+
| "title"
|
|
16
|
+
| "translate"
|
|
17
|
+
| "onClick"
|
|
18
|
+
| "onFocus"
|
|
19
|
+
| "onBlur"
|
|
20
|
+
> {
|
|
21
|
+
/** Makes avatar clickable with button role and focus ring. */
|
|
22
|
+
interactive?: boolean;
|
|
23
|
+
|
|
24
|
+
/** Prevents interaction when `interactive` is true. */
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
|
|
27
|
+
/** Enables lazy loading for the image. */
|
|
28
|
+
lazy?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
31
|
+
id?: NysAvatarElement["id"];
|
|
32
|
+
|
|
33
|
+
/** Accessible label for screen readers. Required when no image `alt` is available. */
|
|
34
|
+
ariaLabel?: NysAvatarElement["ariaLabel"];
|
|
35
|
+
|
|
36
|
+
/** Image URL. Takes priority over initials and icon. */
|
|
37
|
+
image?: NysAvatarElement["image"];
|
|
38
|
+
|
|
39
|
+
/** 1-2 character initials. Used when no image is provided. */
|
|
40
|
+
initials?: NysAvatarElement["initials"];
|
|
41
|
+
|
|
42
|
+
/** Custom icon name. Falls back to `account_circle` if not set. */
|
|
43
|
+
icon?: NysAvatarElement["icon"];
|
|
44
|
+
|
|
45
|
+
/** Background color. Foreground auto-adjusts for contrast. Accepts CSS values or variables. */
|
|
46
|
+
color?: NysAvatarElement["color"];
|
|
47
|
+
|
|
48
|
+
/** 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()`. */
|
|
49
|
+
className?: string;
|
|
50
|
+
|
|
51
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
52
|
+
exportparts?: string;
|
|
53
|
+
|
|
54
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
55
|
+
htmlFor?: string;
|
|
56
|
+
|
|
57
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
58
|
+
key?: number | string;
|
|
59
|
+
|
|
60
|
+
/** 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. */
|
|
61
|
+
part?: string;
|
|
62
|
+
|
|
63
|
+
/** 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. */
|
|
64
|
+
ref?: any;
|
|
65
|
+
|
|
66
|
+
/** 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. */
|
|
67
|
+
tabIndex?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* User avatar with image, initials, or icon fallback and contrast-aware colors.
|
|
72
|
+
* ---
|
|
73
|
+
*
|
|
74
|
+
*
|
|
75
|
+
* ### **Slots:**
|
|
76
|
+
* - _default_ - Custom icon content. Overrides default icon when no image or initials.
|
|
77
|
+
*/
|
|
78
|
+
export const NysAvatar: React.ForwardRefExoticComponent<NysAvatarProps>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export const NysAvatar = forwardRef((props, forwardedRef) => {
|
|
5
|
+
const {
|
|
6
|
+
interactive,
|
|
7
|
+
disabled,
|
|
8
|
+
lazy,
|
|
9
|
+
id,
|
|
10
|
+
ariaLabel,
|
|
11
|
+
image,
|
|
12
|
+
initials,
|
|
13
|
+
icon,
|
|
14
|
+
color,
|
|
15
|
+
...filteredProps
|
|
16
|
+
} = props;
|
|
17
|
+
|
|
18
|
+
return React.createElement(
|
|
19
|
+
"nys-avatar",
|
|
20
|
+
{
|
|
21
|
+
...filteredProps,
|
|
22
|
+
id: props.id,
|
|
23
|
+
ariaLabel: props.ariaLabel,
|
|
24
|
+
image: props.image,
|
|
25
|
+
initials: props.initials,
|
|
26
|
+
icon: props.icon,
|
|
27
|
+
color: props.color,
|
|
28
|
+
class: props.className,
|
|
29
|
+
exportparts: props.exportparts,
|
|
30
|
+
for: props.htmlFor,
|
|
31
|
+
part: props.part,
|
|
32
|
+
tabindex: props.tabIndex,
|
|
33
|
+
interactive: props.interactive ? true : undefined,
|
|
34
|
+
disabled: props.disabled ? true : undefined,
|
|
35
|
+
lazy: props.lazy ? true : undefined,
|
|
36
|
+
style: { ...props.style },
|
|
37
|
+
},
|
|
38
|
+
props.children,
|
|
39
|
+
);
|
|
40
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysBacktotop as NysBacktotopElement } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysBacktotopElement };
|
|
5
|
+
|
|
6
|
+
export interface NysBacktotopProps extends Pick<
|
|
7
|
+
React.AllHTMLAttributes<HTMLElement>,
|
|
8
|
+
| "children"
|
|
9
|
+
| "dir"
|
|
10
|
+
| "hidden"
|
|
11
|
+
| "id"
|
|
12
|
+
| "lang"
|
|
13
|
+
| "slot"
|
|
14
|
+
| "style"
|
|
15
|
+
| "title"
|
|
16
|
+
| "translate"
|
|
17
|
+
| "onClick"
|
|
18
|
+
| "onFocus"
|
|
19
|
+
| "onBlur"
|
|
20
|
+
> {
|
|
21
|
+
/** Force button visibility. Overrides auto-show scroll behavior. */
|
|
22
|
+
visible?: boolean;
|
|
23
|
+
|
|
24
|
+
/** Horizontal position: `left` or `right`. */
|
|
25
|
+
position?: NysBacktotopElement["position"];
|
|
26
|
+
|
|
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()`. */
|
|
28
|
+
className?: string;
|
|
29
|
+
|
|
30
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
31
|
+
exportparts?: string;
|
|
32
|
+
|
|
33
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
34
|
+
htmlFor?: string;
|
|
35
|
+
|
|
36
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
37
|
+
key?: number | string;
|
|
38
|
+
|
|
39
|
+
/** 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. */
|
|
40
|
+
part?: string;
|
|
41
|
+
|
|
42
|
+
/** 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. */
|
|
43
|
+
ref?: any;
|
|
44
|
+
|
|
45
|
+
/** 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. */
|
|
46
|
+
tabIndex?: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Floating back-to-top button with auto-show behavior and smooth scroll.
|
|
51
|
+
* ---
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
export const NysBacktotop: React.ForwardRefExoticComponent<NysBacktotopProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export const NysBacktotop = forwardRef((props, forwardedRef) => {
|
|
5
|
+
const { visible, position, ...filteredProps } = props;
|
|
6
|
+
|
|
7
|
+
return React.createElement(
|
|
8
|
+
"nys-backtotop",
|
|
9
|
+
{
|
|
10
|
+
...filteredProps,
|
|
11
|
+
position: props.position,
|
|
12
|
+
class: props.className,
|
|
13
|
+
exportparts: props.exportparts,
|
|
14
|
+
for: props.htmlFor,
|
|
15
|
+
part: props.part,
|
|
16
|
+
tabindex: props.tabIndex,
|
|
17
|
+
visible: props.visible ? true : undefined,
|
|
18
|
+
style: { ...props.style },
|
|
19
|
+
},
|
|
20
|
+
props.children,
|
|
21
|
+
);
|
|
22
|
+
});
|