@nysds/components 1.15.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.
Files changed (89) hide show
  1. package/custom-elements.json +671 -317
  2. package/dist/.vscode/vscode.html-custom-data.json +1 -1
  3. package/dist/custom-elements.json +671 -317
  4. package/dist/nysds.es.js +779 -724
  5. package/dist/nysds.es.js.map +1 -1
  6. package/dist/nysds.js +37 -37
  7. package/dist/nysds.js.map +1 -1
  8. package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenu.d.ts +1 -1
  9. package/dist/packages/nys-globalheader/src/nys-globalheader.d.ts +4 -2
  10. package/dist/packages/nys-table/src/nys-table.d.ts +12 -1
  11. package/package.json +19 -10
  12. package/packages/react/NysAccordion.d.ts +65 -0
  13. package/packages/react/NysAccordion.js +23 -0
  14. package/packages/react/NysAccordionItem.d.ts +72 -0
  15. package/packages/react/NysAccordionItem.js +41 -0
  16. package/packages/react/NysAlert.d.ts +104 -0
  17. package/packages/react/NysAlert.js +63 -0
  18. package/packages/react/NysAvatar.d.ts +78 -0
  19. package/packages/react/NysAvatar.js +40 -0
  20. package/packages/react/NysBacktotop.d.ts +54 -0
  21. package/packages/react/NysBacktotop.js +22 -0
  22. package/packages/react/NysBadge.d.ts +75 -0
  23. package/packages/react/NysBadge.js +40 -0
  24. package/packages/react/NysButton.d.ts +141 -0
  25. package/packages/react/NysButton.js +81 -0
  26. package/packages/react/NysCheckbox.d.ts +139 -0
  27. package/packages/react/NysCheckbox.js +76 -0
  28. package/packages/react/NysCheckboxgroup.d.ts +91 -0
  29. package/packages/react/NysCheckboxgroup.js +48 -0
  30. package/packages/react/NysCombobox.d.ts +126 -0
  31. package/packages/react/NysCombobox.js +66 -0
  32. package/packages/react/NysDatepicker.d.ts +122 -0
  33. package/packages/react/NysDatepicker.js +72 -0
  34. package/packages/react/NysDivider.d.ts +51 -0
  35. package/packages/react/NysDivider.js +21 -0
  36. package/packages/react/NysDropdownMenu.d.ts +54 -0
  37. package/packages/react/NysDropdownMenu.js +22 -0
  38. package/packages/react/NysDropdownMenuItem.d.ts +75 -0
  39. package/packages/react/NysDropdownMenuItem.js +47 -0
  40. package/packages/react/NysErrorMessage.d.ts +57 -0
  41. package/packages/react/NysErrorMessage.js +23 -0
  42. package/packages/react/NysFileItem.d.ts +69 -0
  43. package/packages/react/NysFileItem.js +37 -0
  44. package/packages/react/NysFileinput.d.ts +108 -0
  45. package/packages/react/NysFileinput.js +67 -0
  46. package/packages/react/NysGlobalFooter.d.ts +57 -0
  47. package/packages/react/NysGlobalFooter.js +22 -0
  48. package/packages/react/NysGlobalHeader.d.ts +60 -0
  49. package/packages/react/NysGlobalHeader.js +23 -0
  50. package/packages/react/NysIcon.d.ts +66 -0
  51. package/packages/react/NysIcon.js +27 -0
  52. package/packages/react/NysLabel.d.ts +66 -0
  53. package/packages/react/NysLabel.js +26 -0
  54. package/packages/react/NysModal.d.ts +83 -0
  55. package/packages/react/NysModal.js +41 -0
  56. package/packages/react/NysOption.d.ts +66 -0
  57. package/packages/react/NysOption.js +25 -0
  58. package/packages/react/NysPagination.d.ts +72 -0
  59. package/packages/react/NysPagination.js +45 -0
  60. package/packages/react/NysRadiobutton.d.ts +127 -0
  61. package/packages/react/NysRadiobutton.js +68 -0
  62. package/packages/react/NysRadiogroup.d.ts +91 -0
  63. package/packages/react/NysRadiogroup.js +48 -0
  64. package/packages/react/NysSelect.d.ts +116 -0
  65. package/packages/react/NysSelect.js +65 -0
  66. package/packages/react/NysSkipnav.d.ts +54 -0
  67. package/packages/react/NysSkipnav.js +22 -0
  68. package/packages/react/NysStep.d.ts +75 -0
  69. package/packages/react/NysStep.js +51 -0
  70. package/packages/react/NysStepper.d.ts +67 -0
  71. package/packages/react/NysStepper.js +26 -0
  72. package/packages/react/NysTable.d.ts +80 -0
  73. package/packages/react/NysTable.js +41 -0
  74. package/packages/react/NysTextarea.d.ts +138 -0
  75. package/packages/react/NysTextarea.js +77 -0
  76. package/packages/react/NysTextinput.d.ts +144 -0
  77. package/packages/react/NysTextinput.js +83 -0
  78. package/packages/react/NysToggle.d.ts +102 -0
  79. package/packages/react/NysToggle.js +59 -0
  80. package/packages/react/NysTooltip.d.ts +60 -0
  81. package/packages/react/NysTooltip.js +24 -0
  82. package/packages/react/NysUnavFooter.d.ts +48 -0
  83. package/packages/react/NysUnavFooter.js +18 -0
  84. package/packages/react/NysUnavHeader.d.ts +72 -0
  85. package/packages/react/NysUnavHeader.js +38 -0
  86. package/packages/react/README.md +92 -0
  87. package/packages/react/index.d.ts +37 -0
  88. package/packages/react/index.js +37 -0
  89. package/packages/react/react-utils.js +40 -0
@@ -0,0 +1,68 @@
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 NysRadiobutton = forwardRef((props, forwardedRef) => {
6
+ const ref = useRef(null);
7
+ const {
8
+ checked,
9
+ disabled,
10
+ required,
11
+ inverted,
12
+ tile,
13
+ other,
14
+ showOtherError,
15
+ label,
16
+ description,
17
+ id,
18
+ name,
19
+ value,
20
+ form,
21
+ size,
22
+ ...filteredProps
23
+ } = props;
24
+
25
+ /** Event listeners - run once */
26
+ useEventListener(ref, "nys-error-clear", props.onNysErrorClear);
27
+ useEventListener(ref, "nys-change", props.onNysChange);
28
+ useEventListener(ref, "nys-other-input", props.onNysOtherInput);
29
+ useEventListener(ref, "nys-focus", props.onNysFocus);
30
+ useEventListener(ref, "nys-blur", props.onNysBlur);
31
+ useEventListener(ref, "nys-error", props.onNysError);
32
+
33
+ return React.createElement(
34
+ "nys-radiobutton",
35
+ {
36
+ ref: (node) => {
37
+ ref.current = node;
38
+ if (typeof forwardedRef === "function") {
39
+ forwardedRef(node);
40
+ } else if (forwardedRef) {
41
+ forwardedRef.current = node;
42
+ }
43
+ },
44
+ ...filteredProps,
45
+ label: props.label,
46
+ description: props.description,
47
+ id: props.id,
48
+ name: props.name,
49
+ value: props.value,
50
+ form: props.form,
51
+ size: props.size,
52
+ class: props.className,
53
+ exportparts: props.exportparts,
54
+ for: props.htmlFor,
55
+ part: props.part,
56
+ tabindex: props.tabIndex,
57
+ checked: props.checked ? true : undefined,
58
+ disabled: props.disabled ? true : undefined,
59
+ required: props.required ? true : undefined,
60
+ inverted: props.inverted ? true : undefined,
61
+ tile: props.tile ? true : undefined,
62
+ other: props.other ? true : undefined,
63
+ showOtherError: props.showOtherError ? true : undefined,
64
+ style: { ...props.style },
65
+ },
66
+ props.children,
67
+ );
68
+ });
@@ -0,0 +1,91 @@
1
+ import React from "react";
2
+ import { NysRadiogroup as NysRadiogroupElement } from "../../dist/nysds.es.js";
3
+
4
+ export type { NysRadiogroupElement };
5
+
6
+ export interface NysRadiogroupProps 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
+ /** Requires a selection before form submission. */
22
+ required?: boolean;
23
+
24
+ /** Shows "Optional" flag. */
25
+ optional?: boolean;
26
+
27
+ /** Shows error message when true. */
28
+ showError?: boolean;
29
+
30
+ /** Renders all radiobuttons as tiles with larger clickable area. */
31
+ tile?: boolean;
32
+
33
+ /** Adjusts colors for dark backgrounds. Applied to all children. */
34
+ inverted?: boolean;
35
+
36
+ /** Unique identifier. Auto-generated if not provided. */
37
+ id?: NysRadiogroupElement["id"];
38
+
39
+ /** Name for form submission. Auto-populated from child radiobuttons. */
40
+ name?: NysRadiogroupElement["name"];
41
+
42
+ /** Error message text. Shown only when `showError` is true. */
43
+ errorMessage?: NysRadiogroupElement["errorMessage"];
44
+
45
+ /** Visible label text for the group. */
46
+ label?: NysRadiogroupElement["label"];
47
+
48
+ /** Helper text below label. Use slot for custom HTML. */
49
+ description?: NysRadiogroupElement["description"];
50
+
51
+ /** Tooltip text shown on hover/focus of info icon. */
52
+ tooltip?: NysRadiogroupElement["tooltip"];
53
+
54
+ /** Form `id` to associate with. Applied to all children. */
55
+ form?: NysRadiogroupElement["form"];
56
+
57
+ /** Radio size for all children: `sm` (24px) or `md` (32px, default). */
58
+ size?: NysRadiogroupElement["size"];
59
+
60
+ /** 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
+ className?: string;
62
+
63
+ /** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
64
+ exportparts?: string;
65
+
66
+ /** Used for labels to link them with their inputs (using input id). */
67
+ htmlFor?: string;
68
+
69
+ /** Used to help React identify which items have changed, are added, or are removed within a list. */
70
+ key?: number | string;
71
+
72
+ /** 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. */
73
+ part?: string;
74
+
75
+ /** 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. */
76
+ ref?: any;
77
+
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. */
79
+ tabIndex?: number;
80
+ }
81
+
82
+ /**
83
+ * Container for grouping radio buttons as a single form control.
84
+ * ---
85
+ *
86
+ *
87
+ * ### **Slots:**
88
+ * - _default_ - Default slot for `nys-radiobutton` elements.
89
+ * - **description** - Custom HTML description content.
90
+ */
91
+ export const NysRadiogroup: React.ForwardRefExoticComponent<NysRadiogroupProps>;
@@ -0,0 +1,48 @@
1
+ import React, { forwardRef } from "react";
2
+ import "../../dist/nysds.es.js";
3
+
4
+ export const NysRadiogroup = forwardRef((props, forwardedRef) => {
5
+ const {
6
+ required,
7
+ optional,
8
+ showError,
9
+ tile,
10
+ inverted,
11
+ id,
12
+ name,
13
+ errorMessage,
14
+ label,
15
+ description,
16
+ tooltip,
17
+ form,
18
+ size,
19
+ ...filteredProps
20
+ } = props;
21
+
22
+ return React.createElement(
23
+ "nys-radiogroup",
24
+ {
25
+ ...filteredProps,
26
+ id: props.id,
27
+ name: props.name,
28
+ errorMessage: props.errorMessage,
29
+ label: props.label,
30
+ description: props.description,
31
+ tooltip: props.tooltip,
32
+ form: props.form,
33
+ size: props.size,
34
+ class: props.className,
35
+ exportparts: props.exportparts,
36
+ for: props.htmlFor,
37
+ part: props.part,
38
+ tabindex: props.tabIndex,
39
+ required: props.required ? true : undefined,
40
+ optional: props.optional ? true : undefined,
41
+ showError: props.showError ? true : undefined,
42
+ tile: props.tile ? true : undefined,
43
+ inverted: props.inverted ? true : undefined,
44
+ style: { ...props.style },
45
+ },
46
+ props.children,
47
+ );
48
+ });
@@ -0,0 +1,116 @@
1
+ import React from "react";
2
+ import {
3
+ NysSelect as NysSelectElement,
4
+ CustomEvent,
5
+ Event,
6
+ } from "../../dist/nysds.es.js";
7
+
8
+ export type { NysSelectElement, CustomEvent, Event };
9
+
10
+ export interface NysSelectProps extends Pick<
11
+ React.AllHTMLAttributes<HTMLElement>,
12
+ | "children"
13
+ | "dir"
14
+ | "hidden"
15
+ | "id"
16
+ | "lang"
17
+ | "slot"
18
+ | "style"
19
+ | "title"
20
+ | "translate"
21
+ | "onClick"
22
+ | "onFocus"
23
+ | "onBlur"
24
+ > {
25
+ /** Prevents interaction. */
26
+ disabled?: boolean;
27
+
28
+ /** Marks as required. Shows "Required" flag and validates on blur. */
29
+ required?: boolean;
30
+
31
+ /** Shows "Optional" flag. Use when most fields are required. */
32
+ optional?: boolean;
33
+
34
+ /** Adjusts colors for dark backgrounds. */
35
+ inverted?: boolean;
36
+
37
+ /** Shows error message when true. Set by validation or manually. */
38
+ showError?: boolean;
39
+
40
+ /** Unique identifier. Auto-generated if not provided. */
41
+ id?: NysSelectElement["id"];
42
+
43
+ /** Name for form submission. */
44
+ name?: NysSelectElement["name"];
45
+
46
+ /** Visible label text. Required for accessibility. */
47
+ label?: NysSelectElement["label"];
48
+
49
+ /** Helper text below label. Use slot for custom HTML. */
50
+ description?: NysSelectElement["description"];
51
+
52
+ /** Currently selected option value. */
53
+ value?: NysSelectElement["value"];
54
+
55
+ /** Tooltip text shown on hover/focus of info icon. */
56
+ tooltip?: NysSelectElement["tooltip"];
57
+
58
+ /** Form `id` to associate with when select is outside form element. */
59
+ form?: NysSelectElement["form"];
60
+
61
+ /** Error message text. Shown only when `showError` is true. */
62
+ errorMessage?: NysSelectElement["errorMessage"];
63
+
64
+ /** Select width: `sm` (88px), `md` (200px), `lg` (384px), `full` (100%, default). */
65
+ width?: NysSelectElement["width"];
66
+
67
+ /** 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()`. */
68
+ className?: string;
69
+
70
+ /** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
71
+ exportparts?: string;
72
+
73
+ /** Used for labels to link them with their inputs (using input id). */
74
+ htmlFor?: string;
75
+
76
+ /** Used to help React identify which items have changed, are added, or are removed within a list. */
77
+ key?: number | string;
78
+
79
+ /** 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. */
80
+ part?: string;
81
+
82
+ /** 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. */
83
+ ref?: any;
84
+
85
+ /** 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. */
86
+ tabIndex?: number;
87
+
88
+ /** Fired when selection changes. Detail: `{id, value}`. */
89
+ onNysChange?: (event: CustomEvent) => void;
90
+
91
+ /** Fired when select gains focus. */
92
+ onNysFocus?: (event: CustomEvent) => void;
93
+
94
+ /** Fired when select loses focus. Triggers validation. */
95
+ onNysBlur?: (event: CustomEvent) => void;
96
+ }
97
+
98
+ /**
99
+ * Dropdown select for choosing one option from a list.
100
+ * ---
101
+ *
102
+ *
103
+ * ### **Events:**
104
+ * - **nys-change** - Fired when selection changes. Detail: `{id, value}`.
105
+ * - **nys-focus** - Fired when select gains focus.
106
+ * - **nys-blur** - Fired when select loses focus. Triggers validation.
107
+ *
108
+ * ### **Methods:**
109
+ * - **checkValidity(): _boolean_** - Functions
110
+ * --------------------------------------------------------------------------
111
+ *
112
+ * ### **Slots:**
113
+ * - _default_ - Default slot for `<option>` and `<optgroup>` elements.
114
+ * - **description** - Custom HTML description content below the label.
115
+ */
116
+ export const NysSelect: React.ForwardRefExoticComponent<NysSelectProps>;
@@ -0,0 +1,65 @@
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 NysSelect = forwardRef((props, forwardedRef) => {
6
+ const ref = useRef(null);
7
+ const {
8
+ disabled,
9
+ required,
10
+ optional,
11
+ inverted,
12
+ showError,
13
+ id,
14
+ name,
15
+ label,
16
+ description,
17
+ value,
18
+ tooltip,
19
+ form,
20
+ errorMessage,
21
+ width,
22
+ ...filteredProps
23
+ } = props;
24
+
25
+ /** Event listeners - run once */
26
+ useEventListener(ref, "nys-change", props.onNysChange);
27
+ useEventListener(ref, "nys-focus", props.onNysFocus);
28
+ useEventListener(ref, "nys-blur", props.onNysBlur);
29
+
30
+ return React.createElement(
31
+ "nys-select",
32
+ {
33
+ ref: (node) => {
34
+ ref.current = node;
35
+ if (typeof forwardedRef === "function") {
36
+ forwardedRef(node);
37
+ } else if (forwardedRef) {
38
+ forwardedRef.current = node;
39
+ }
40
+ },
41
+ ...filteredProps,
42
+ id: props.id,
43
+ name: props.name,
44
+ label: props.label,
45
+ description: props.description,
46
+ value: props.value,
47
+ tooltip: props.tooltip,
48
+ form: props.form,
49
+ errorMessage: props.errorMessage,
50
+ width: props.width,
51
+ class: props.className,
52
+ exportparts: props.exportparts,
53
+ for: props.htmlFor,
54
+ part: props.part,
55
+ tabindex: props.tabIndex,
56
+ disabled: props.disabled ? true : undefined,
57
+ required: props.required ? true : undefined,
58
+ optional: props.optional ? true : undefined,
59
+ inverted: props.inverted ? true : undefined,
60
+ showError: props.showError ? true : undefined,
61
+ style: { ...props.style },
62
+ },
63
+ props.children,
64
+ );
65
+ });
@@ -0,0 +1,54 @@
1
+ import React from "react";
2
+ import { NysSkipnav as NysSkipnavElement } from "../../dist/nysds.es.js";
3
+
4
+ export type { NysSkipnavElement };
5
+
6
+ export interface NysSkipnavProps 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
+ /** Unique identifier. Auto-generated if not provided. */
22
+ id?: NysSkipnavElement["id"];
23
+
24
+ /** Target element ID (with `#`). Defaults to `#main-content`. */
25
+ href?: NysSkipnavElement["href"];
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
+ * Skip navigation link for keyboard accessibility. Hidden until focused.
51
+ * ---
52
+ *
53
+ */
54
+ export const NysSkipnav: React.ForwardRefExoticComponent<NysSkipnavProps>;
@@ -0,0 +1,22 @@
1
+ import React, { forwardRef } from "react";
2
+ import "../../dist/nysds.es.js";
3
+
4
+ export const NysSkipnav = forwardRef((props, forwardedRef) => {
5
+ const { id, href, ...filteredProps } = props;
6
+
7
+ return React.createElement(
8
+ "nys-skipnav",
9
+ {
10
+ ...filteredProps,
11
+ id: props.id,
12
+ href: props.href,
13
+ class: props.className,
14
+ exportparts: props.exportparts,
15
+ for: props.htmlFor,
16
+ part: props.part,
17
+ tabindex: props.tabIndex,
18
+ style: { ...props.style },
19
+ },
20
+ props.children,
21
+ );
22
+ });
@@ -0,0 +1,75 @@
1
+ import React from "react";
2
+ import { NysStep as NysStepElement } from "../../dist/nysds.es.js";
3
+
4
+ export type { NysStepElement };
5
+
6
+ export interface NysStepProps 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
+ /** Whether this step is currently being viewed. Set by parent stepper. */
22
+ selected?: boolean;
23
+
24
+ /** Marks the furthest reached step. Steps before this are navigable. */
25
+ current?: boolean;
26
+
27
+ /** Internal: Whether parent stepper's compact view is expanded. */
28
+ isCompactExpanded?: boolean;
29
+
30
+ /** Step label text displayed alongside the step number. */
31
+ label?: NysStepElement["label"];
32
+
33
+ /** URL for page navigation when step is clicked. Optional for SPA routing. */
34
+ href?: NysStepElement["href"];
35
+
36
+ /** Step number (1-indexed). Auto-assigned by parent stepper. */
37
+ stepNumber?: NysStepElement["stepNumber"];
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
+ /** Custom click handler. Called before `nys-step-click` event. */
61
+ onClick?: NysStepElement["onClick"];
62
+
63
+ /** Fired when a navigable step is clicked. Detail: `{href, label}`. Cancelable. */
64
+ onNysStepClick?: (event: CustomEvent) => void;
65
+ }
66
+
67
+ /**
68
+ * Individual step for use within nys-stepper with navigation support.
69
+ * ---
70
+ *
71
+ *
72
+ * ### **Events:**
73
+ * - **nys-step-click** - Fired when a navigable step is clicked. Detail: `{href, label}`. Cancelable.
74
+ */
75
+ export const NysStep: React.ForwardRefExoticComponent<NysStepProps>;
@@ -0,0 +1,51 @@
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 NysStep = forwardRef((props, forwardedRef) => {
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;
17
+
18
+ /** Event listeners - run once */
19
+ useEventListener(ref, "nys-step-click", props.onNysStepClick);
20
+
21
+ /** Properties - run whenever a property has changed */
22
+ useProperties(ref, "onClick", props.onClick);
23
+
24
+ return React.createElement(
25
+ "nys-step",
26
+ {
27
+ ref: (node) => {
28
+ ref.current = node;
29
+ if (typeof forwardedRef === "function") {
30
+ forwardedRef(node);
31
+ } else if (forwardedRef) {
32
+ forwardedRef.current = node;
33
+ }
34
+ },
35
+ ...filteredProps,
36
+ label: props.label,
37
+ href: props.href,
38
+ stepNumber: props.stepNumber,
39
+ class: props.className,
40
+ exportparts: props.exportparts,
41
+ for: props.htmlFor,
42
+ part: props.part,
43
+ tabindex: props.tabIndex,
44
+ selected: props.selected ? true : undefined,
45
+ current: props.current ? true : undefined,
46
+ isCompactExpanded: props.isCompactExpanded ? true : undefined,
47
+ style: { ...props.style },
48
+ },
49
+ props.children,
50
+ );
51
+ });
@@ -0,0 +1,67 @@
1
+ import React from "react";
2
+ import { NysStepper as NysStepperElement } from "../../dist/nysds.es.js";
3
+
4
+ export type { NysStepperElement };
5
+
6
+ export interface NysStepperProps 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
+ /** Whether compact mobile view is expanded to show all steps. */
22
+ isCompactExpanded?: boolean;
23
+
24
+ /** Unique identifier. */
25
+ id?: NysStepperElement["id"];
26
+
27
+ /** Name attribute for form association. */
28
+ name?: NysStepperElement["name"];
29
+
30
+ /** Title displayed above the step counter. */
31
+ label?: NysStepperElement["label"];
32
+
33
+ /** Progress text (e.g., "Step 2 of 5"). Auto-updated based on selection. */
34
+ counterText?: NysStepperElement["counterText"];
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
+
58
+ /**
59
+ * Multi-step progress indicator with navigation and mobile-friendly compact view.
60
+ * ---
61
+ *
62
+ *
63
+ * ### **Slots:**
64
+ * - _default_ - Default slot for `nys-step` elements.
65
+ * - **actions** - Navigation buttons (e.g., Back, Continue). Must be wrapped in a `<div>`.
66
+ */
67
+ export const NysStepper: React.ForwardRefExoticComponent<NysStepperProps>;
@@ -0,0 +1,26 @@
1
+ import React, { forwardRef } from "react";
2
+ import "../../dist/nysds.es.js";
3
+
4
+ export const NysStepper = forwardRef((props, forwardedRef) => {
5
+ const { isCompactExpanded, id, name, label, counterText, ...filteredProps } =
6
+ props;
7
+
8
+ return React.createElement(
9
+ "nys-stepper",
10
+ {
11
+ ...filteredProps,
12
+ id: props.id,
13
+ name: props.name,
14
+ label: props.label,
15
+ counterText: props.counterText,
16
+ class: props.className,
17
+ exportparts: props.exportparts,
18
+ for: props.htmlFor,
19
+ part: props.part,
20
+ tabindex: props.tabIndex,
21
+ isCompactExpanded: props.isCompactExpanded ? true : undefined,
22
+ style: { ...props.style },
23
+ },
24
+ props.children,
25
+ );
26
+ });