@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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysBadge as NysBadgeElement } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysBadgeElement };
|
|
5
|
+
|
|
6
|
+
export interface NysBadgeProps 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
|
+
/** undefined */
|
|
22
|
+
prefixIcon?: string | boolean;
|
|
23
|
+
|
|
24
|
+
/** undefined */
|
|
25
|
+
suffixIcon?: string | boolean;
|
|
26
|
+
|
|
27
|
+
/** Unique identifier. */
|
|
28
|
+
id?: NysBadgeElement["id"];
|
|
29
|
+
|
|
30
|
+
/** Name attribute for form association. */
|
|
31
|
+
name?: NysBadgeElement["name"];
|
|
32
|
+
|
|
33
|
+
/** Badge size: `sm` (smaller text) or `md` (default). */
|
|
34
|
+
size?: NysBadgeElement["size"];
|
|
35
|
+
|
|
36
|
+
/** Semantic intent affecting color: `neutral`, `error`, `success`, or `warning`. */
|
|
37
|
+
intent?: NysBadgeElement["intent"];
|
|
38
|
+
|
|
39
|
+
/** Secondary label displayed before the main label. */
|
|
40
|
+
prefixLabel?: NysBadgeElement["prefixLabel"];
|
|
41
|
+
|
|
42
|
+
/** Primary label text displayed in the badge. */
|
|
43
|
+
label?: NysBadgeElement["label"];
|
|
44
|
+
|
|
45
|
+
/** undefined */
|
|
46
|
+
variant?: NysBadgeElement["variant"];
|
|
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
|
+
* Compact label for status, counts, or categorization with semantic styling.
|
|
72
|
+
* ---
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
export const NysBadge: React.ForwardRefExoticComponent<NysBadgeProps>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export const NysBadge = forwardRef((props, forwardedRef) => {
|
|
5
|
+
const {
|
|
6
|
+
prefixIcon,
|
|
7
|
+
suffixIcon,
|
|
8
|
+
id,
|
|
9
|
+
name,
|
|
10
|
+
size,
|
|
11
|
+
intent,
|
|
12
|
+
prefixLabel,
|
|
13
|
+
label,
|
|
14
|
+
variant,
|
|
15
|
+
...filteredProps
|
|
16
|
+
} = props;
|
|
17
|
+
|
|
18
|
+
return React.createElement(
|
|
19
|
+
"nys-badge",
|
|
20
|
+
{
|
|
21
|
+
...filteredProps,
|
|
22
|
+
id: props.id,
|
|
23
|
+
name: props.name,
|
|
24
|
+
size: props.size,
|
|
25
|
+
intent: props.intent,
|
|
26
|
+
prefixLabel: props.prefixLabel,
|
|
27
|
+
label: props.label,
|
|
28
|
+
variant: props.variant,
|
|
29
|
+
class: props.className,
|
|
30
|
+
exportparts: props.exportparts,
|
|
31
|
+
for: props.htmlFor,
|
|
32
|
+
part: props.part,
|
|
33
|
+
tabindex: props.tabIndex,
|
|
34
|
+
prefixicon: props.prefixIcon ? true : undefined,
|
|
35
|
+
suffixicon: props.suffixIcon ? true : undefined,
|
|
36
|
+
style: { ...props.style },
|
|
37
|
+
},
|
|
38
|
+
props.children,
|
|
39
|
+
);
|
|
40
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysButton as NysButtonElement, Event } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysButtonElement, Event };
|
|
5
|
+
|
|
6
|
+
export interface NysButtonProps 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
|
+
/** Expands button to fill container width. Use for mobile layouts or stacked button groups. */
|
|
22
|
+
fullWidth?: boolean;
|
|
23
|
+
|
|
24
|
+
/** Adjusts colors for dark backgrounds. */
|
|
25
|
+
inverted?: boolean;
|
|
26
|
+
|
|
27
|
+
/** Renders circular icon-only button. Requires `icon` prop. `label` becomes aria-label. */
|
|
28
|
+
circle?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Prevents interaction. Avoid disabling without explanation—show validation errors instead. */
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
|
|
33
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
34
|
+
id?: NysButtonElement["id"];
|
|
35
|
+
|
|
36
|
+
/** Name for form submission. */
|
|
37
|
+
name?: NysButtonElement["name"];
|
|
38
|
+
|
|
39
|
+
/** Button height: `sm` (40px) for dense UIs, `md` (48px, default) for standard use, `lg` (56px) for prominent CTAs. */
|
|
40
|
+
size?: NysButtonElement["size"];
|
|
41
|
+
|
|
42
|
+
/** Visual style: `filled` for primary (one per section), `outline` for secondary, `ghost` for tertiary, `text` for inline actions. Avoid `text` for navigation. */
|
|
43
|
+
variant?: NysButtonElement["variant"];
|
|
44
|
+
|
|
45
|
+
/** Visible button text. Use sentence case, action-oriented text (e.g., "Save Draft"). Becomes aria-label in `circle` mode. */
|
|
46
|
+
label?: NysButtonElement["label"];
|
|
47
|
+
|
|
48
|
+
/** Screen reader label. Required for icon-only buttons if `label` is not set. */
|
|
49
|
+
ariaLabel?: NysButtonElement["ariaLabel"];
|
|
50
|
+
|
|
51
|
+
/** ID of controlled element (e.g., dropdown or modal). Sets `aria-controls`. */
|
|
52
|
+
ariaControls?: NysButtonElement["ariaControls"];
|
|
53
|
+
|
|
54
|
+
/** Material Symbol icon before label. Not shown for `text` variant or `circle` mode. */
|
|
55
|
+
prefixIcon?: NysButtonElement["prefixIcon"];
|
|
56
|
+
|
|
57
|
+
/** Material Symbol icon after label. Use `chevron_down` for dropdowns, `open_in_new` for external links. Not shown for `text` variant or `circle` mode. */
|
|
58
|
+
suffixIcon?: NysButtonElement["suffixIcon"];
|
|
59
|
+
|
|
60
|
+
/** Icon for circle mode. Required when `circle` is true. Scales with size (sm=24px, md=32px, lg=40px). */
|
|
61
|
+
icon?: NysButtonElement["icon"];
|
|
62
|
+
|
|
63
|
+
/** Form `id` to associate with. Use when button is outside the form element. */
|
|
64
|
+
form?: NysButtonElement["form"];
|
|
65
|
+
|
|
66
|
+
/** Value submitted with form data. Only used when `type="submit"`. */
|
|
67
|
+
value?: NysButtonElement["value"];
|
|
68
|
+
|
|
69
|
+
/** Additional screen reader description. Sets `aria-description`. */
|
|
70
|
+
ariaDescription?: NysButtonElement["ariaDescription"];
|
|
71
|
+
|
|
72
|
+
/** Form behavior: `button` (default, no form action), `submit` (submits form), `reset` (resets form). Always set explicitly to avoid unintended submissions. */
|
|
73
|
+
type?: NysButtonElement["type"];
|
|
74
|
+
|
|
75
|
+
/** URL to navigate to. Renders as `<a>` tag. Omit for action buttons. */
|
|
76
|
+
href?: NysButtonElement["href"];
|
|
77
|
+
|
|
78
|
+
/** Link target: `_self` (same tab), `_blank` (new tab—add `suffixIcon="open_in_new"`), `_parent`, `_top`, or frame name. */
|
|
79
|
+
target?: NysButtonElement["target"];
|
|
80
|
+
|
|
81
|
+
/** 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()`. */
|
|
82
|
+
className?: string;
|
|
83
|
+
|
|
84
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
85
|
+
exportparts?: string;
|
|
86
|
+
|
|
87
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
88
|
+
htmlFor?: string;
|
|
89
|
+
|
|
90
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
91
|
+
key?: number | string;
|
|
92
|
+
|
|
93
|
+
/** 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. */
|
|
94
|
+
part?: string;
|
|
95
|
+
|
|
96
|
+
/** 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. */
|
|
97
|
+
ref?: any;
|
|
98
|
+
|
|
99
|
+
/** 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. */
|
|
100
|
+
tabIndex?: number;
|
|
101
|
+
|
|
102
|
+
/** Click handler. Use instead of `@click` to ensure keyboard accessibility. */
|
|
103
|
+
onClick?: NysButtonElement["onClick"];
|
|
104
|
+
|
|
105
|
+
/** Fired when the button receives focus. */
|
|
106
|
+
onNysFocus?: (event: CustomEvent) => void;
|
|
107
|
+
|
|
108
|
+
/** Fired when the button loses focus. */
|
|
109
|
+
onNysBlur?: (event: CustomEvent) => void;
|
|
110
|
+
|
|
111
|
+
/** Fired when the button is clicked (mouse or keyboard). Not fired when disabled. */
|
|
112
|
+
onNysClick?: (event: CustomEvent) => void;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Button for actions and CTAs with variants, sizes, and icon support.
|
|
117
|
+
* ---
|
|
118
|
+
*
|
|
119
|
+
*
|
|
120
|
+
* ### **Events:**
|
|
121
|
+
* - **nys-focus** - Fired when the button receives focus.
|
|
122
|
+
* - **nys-blur** - Fired when the button loses focus.
|
|
123
|
+
* - **nys-click** - Fired when the button is clicked (mouse or keyboard). Not fired when disabled.
|
|
124
|
+
*
|
|
125
|
+
* ### **Slots:**
|
|
126
|
+
* - **prefix-icon** - Icon before label. Not shown for `text` variant.
|
|
127
|
+
* - **suffix-icon** - Icon after label. Not shown for `text` variant.
|
|
128
|
+
* - **circle-icon** - Icon for circle mode. Overrides `icon` prop.
|
|
129
|
+
*
|
|
130
|
+
* ### **CSS Properties:**
|
|
131
|
+
* - **--nys-button-color** - Text color of the button label. _(default: undefined)_
|
|
132
|
+
* - **--nys-button-color--hover** - Text color when hovered. _(default: undefined)_
|
|
133
|
+
* - **--nys-button-color--active** - Text color when active/pressed. _(default: undefined)_
|
|
134
|
+
* - **--nys-button-background-color** - Background color of the button. _(default: undefined)_
|
|
135
|
+
* - **--nys-button-background-color--hover** - Background color when hovered. _(default: undefined)_
|
|
136
|
+
* - **--nys-button-background-color--active** - Background color when active/pressed. _(default: undefined)_
|
|
137
|
+
* - **--nys-button-border-color** - Border color of the button. _(default: undefined)_
|
|
138
|
+
* - **--nys-button-border-color--hover** - Border color when hovered. _(default: undefined)_
|
|
139
|
+
* - **--nys-button-border-color--active** - Border color when active/pressed. _(default: undefined)_
|
|
140
|
+
*/
|
|
141
|
+
export const NysButton: React.ForwardRefExoticComponent<NysButtonProps>;
|
|
@@ -0,0 +1,81 @@
|
|
|
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 NysButton = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const {
|
|
8
|
+
fullWidth,
|
|
9
|
+
inverted,
|
|
10
|
+
circle,
|
|
11
|
+
disabled,
|
|
12
|
+
id,
|
|
13
|
+
name,
|
|
14
|
+
size,
|
|
15
|
+
variant,
|
|
16
|
+
label,
|
|
17
|
+
ariaLabel,
|
|
18
|
+
ariaControls,
|
|
19
|
+
prefixIcon,
|
|
20
|
+
suffixIcon,
|
|
21
|
+
icon,
|
|
22
|
+
form,
|
|
23
|
+
value,
|
|
24
|
+
ariaDescription,
|
|
25
|
+
type,
|
|
26
|
+
href,
|
|
27
|
+
target,
|
|
28
|
+
onClick,
|
|
29
|
+
...filteredProps
|
|
30
|
+
} = props;
|
|
31
|
+
|
|
32
|
+
/** Event listeners - run once */
|
|
33
|
+
useEventListener(ref, "nys-focus", props.onNysFocus);
|
|
34
|
+
useEventListener(ref, "nys-blur", props.onNysBlur);
|
|
35
|
+
useEventListener(ref, "nys-click", props.onNysClick);
|
|
36
|
+
|
|
37
|
+
/** Properties - run whenever a property has changed */
|
|
38
|
+
useProperties(ref, "onClick", props.onClick);
|
|
39
|
+
|
|
40
|
+
return React.createElement(
|
|
41
|
+
"nys-button",
|
|
42
|
+
{
|
|
43
|
+
ref: (node) => {
|
|
44
|
+
ref.current = node;
|
|
45
|
+
if (typeof forwardedRef === "function") {
|
|
46
|
+
forwardedRef(node);
|
|
47
|
+
} else if (forwardedRef) {
|
|
48
|
+
forwardedRef.current = node;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
...filteredProps,
|
|
52
|
+
id: props.id,
|
|
53
|
+
name: props.name,
|
|
54
|
+
size: props.size,
|
|
55
|
+
variant: props.variant,
|
|
56
|
+
label: props.label,
|
|
57
|
+
ariaLabel: props.ariaLabel,
|
|
58
|
+
ariaControls: props.ariaControls,
|
|
59
|
+
prefixIcon: props.prefixIcon,
|
|
60
|
+
suffixIcon: props.suffixIcon,
|
|
61
|
+
icon: props.icon,
|
|
62
|
+
form: props.form,
|
|
63
|
+
value: props.value,
|
|
64
|
+
ariaDescription: props.ariaDescription,
|
|
65
|
+
type: props.type,
|
|
66
|
+
href: props.href,
|
|
67
|
+
target: props.target,
|
|
68
|
+
class: props.className,
|
|
69
|
+
exportparts: props.exportparts,
|
|
70
|
+
for: props.htmlFor,
|
|
71
|
+
part: props.part,
|
|
72
|
+
tabindex: props.tabIndex,
|
|
73
|
+
fullWidth: props.fullWidth ? true : undefined,
|
|
74
|
+
inverted: props.inverted ? true : undefined,
|
|
75
|
+
circle: props.circle ? true : undefined,
|
|
76
|
+
disabled: props.disabled ? true : undefined,
|
|
77
|
+
style: { ...props.style },
|
|
78
|
+
},
|
|
79
|
+
props.children,
|
|
80
|
+
);
|
|
81
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
NysCheckbox as NysCheckboxElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
Event,
|
|
6
|
+
} from "../../dist/nysds.es.js";
|
|
7
|
+
|
|
8
|
+
export type { NysCheckboxElement, CustomEvent, Event };
|
|
9
|
+
|
|
10
|
+
export interface NysCheckboxProps 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
|
+
/** Whether checkbox is checked. */
|
|
26
|
+
checked?: boolean;
|
|
27
|
+
|
|
28
|
+
/** Prevents interaction. */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
|
|
31
|
+
/** Marks as required. Validates that checkbox is checked. */
|
|
32
|
+
required?: boolean;
|
|
33
|
+
|
|
34
|
+
/** Shows error message when true. */
|
|
35
|
+
showError?: boolean;
|
|
36
|
+
|
|
37
|
+
/** Internal: Set by parent checkboxgroup. Do not set manually. */
|
|
38
|
+
groupExist?: boolean;
|
|
39
|
+
|
|
40
|
+
/** Renders as tile with larger clickable area. Apply to group for consistency. */
|
|
41
|
+
tile?: boolean;
|
|
42
|
+
|
|
43
|
+
/** Adjusts colors for dark backgrounds. */
|
|
44
|
+
inverted?: boolean;
|
|
45
|
+
|
|
46
|
+
/** undefined */
|
|
47
|
+
other?: boolean;
|
|
48
|
+
|
|
49
|
+
/** undefined */
|
|
50
|
+
showOtherError?: boolean;
|
|
51
|
+
|
|
52
|
+
/** Visible label text. Required for accessibility. */
|
|
53
|
+
label?: NysCheckboxElement["label"];
|
|
54
|
+
|
|
55
|
+
/** Helper text below label. Use slot for custom HTML. */
|
|
56
|
+
description?: NysCheckboxElement["description"];
|
|
57
|
+
|
|
58
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
59
|
+
id?: NysCheckboxElement["id"];
|
|
60
|
+
|
|
61
|
+
/** Name for form submission. Use same name for grouped checkboxes. */
|
|
62
|
+
name?: NysCheckboxElement["name"];
|
|
63
|
+
|
|
64
|
+
/** Value submitted when checked. */
|
|
65
|
+
value?: NysCheckboxElement["value"];
|
|
66
|
+
|
|
67
|
+
/** Form `id` to associate with when checkbox is outside form element. */
|
|
68
|
+
form?: NysCheckboxElement["form"];
|
|
69
|
+
|
|
70
|
+
/** Error message text. Shown only when `showError` is true. */
|
|
71
|
+
errorMessage?: NysCheckboxElement["errorMessage"];
|
|
72
|
+
|
|
73
|
+
/** Tooltip text shown on hover/focus of info icon. */
|
|
74
|
+
tooltip?: NysCheckboxElement["tooltip"];
|
|
75
|
+
|
|
76
|
+
/** Checkbox size: `sm` (24px) or `md` (32px, default). */
|
|
77
|
+
size?: NysCheckboxElement["size"];
|
|
78
|
+
|
|
79
|
+
/** 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()`. */
|
|
80
|
+
className?: string;
|
|
81
|
+
|
|
82
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
83
|
+
exportparts?: string;
|
|
84
|
+
|
|
85
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
86
|
+
htmlFor?: string;
|
|
87
|
+
|
|
88
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
89
|
+
key?: number | string;
|
|
90
|
+
|
|
91
|
+
/** 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. */
|
|
92
|
+
part?: string;
|
|
93
|
+
|
|
94
|
+
/** 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. */
|
|
95
|
+
ref?: any;
|
|
96
|
+
|
|
97
|
+
/** 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. */
|
|
98
|
+
tabIndex?: number;
|
|
99
|
+
|
|
100
|
+
/** Fired when checked state changes. Detail: `{id, checked, name, value}`. */
|
|
101
|
+
onNysChange?: (event: CustomEvent) => void;
|
|
102
|
+
|
|
103
|
+
/** Fired when "other" text input value changes. Detail: `{id, name, value}`. */
|
|
104
|
+
onNysOtherInput?: (event: CustomEvent) => void;
|
|
105
|
+
|
|
106
|
+
/** Fired when checkbox gains focus. */
|
|
107
|
+
onNysFocus?: (event: CustomEvent) => void;
|
|
108
|
+
|
|
109
|
+
/** Fired when checkbox loses focus. */
|
|
110
|
+
onNysBlur?: (event: CustomEvent) => void;
|
|
111
|
+
|
|
112
|
+
/** undefined */
|
|
113
|
+
onNysError?: (event: CustomEvent) => void;
|
|
114
|
+
|
|
115
|
+
/** undefined */
|
|
116
|
+
onNysErrorClear?: (event: CustomEvent) => void;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Checkbox for binary choices or multi-select options.
|
|
121
|
+
* ---
|
|
122
|
+
*
|
|
123
|
+
*
|
|
124
|
+
* ### **Events:**
|
|
125
|
+
* - **nys-change** - Fired when checked state changes. Detail: `{id, checked, name, value}`.
|
|
126
|
+
* - **nys-other-input** - Fired when "other" text input value changes. Detail: `{id, name, value}`.
|
|
127
|
+
* - **nys-focus** - Fired when checkbox gains focus.
|
|
128
|
+
* - **nys-blur** - Fired when checkbox loses focus.
|
|
129
|
+
* - **nys-error**
|
|
130
|
+
* - **nys-error-clear**
|
|
131
|
+
*
|
|
132
|
+
* ### **Methods:**
|
|
133
|
+
* - **checkValidity(): _boolean_** - Functions
|
|
134
|
+
* --------------------------------------------------------------------------
|
|
135
|
+
*
|
|
136
|
+
* ### **Slots:**
|
|
137
|
+
* - **description** - Custom HTML description content.
|
|
138
|
+
*/
|
|
139
|
+
export const NysCheckbox: React.ForwardRefExoticComponent<NysCheckboxProps>;
|
|
@@ -0,0 +1,76 @@
|
|
|
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 NysCheckbox = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const {
|
|
8
|
+
checked,
|
|
9
|
+
disabled,
|
|
10
|
+
required,
|
|
11
|
+
showError,
|
|
12
|
+
groupExist,
|
|
13
|
+
tile,
|
|
14
|
+
inverted,
|
|
15
|
+
other,
|
|
16
|
+
showOtherError,
|
|
17
|
+
label,
|
|
18
|
+
description,
|
|
19
|
+
id,
|
|
20
|
+
name,
|
|
21
|
+
value,
|
|
22
|
+
form,
|
|
23
|
+
errorMessage,
|
|
24
|
+
tooltip,
|
|
25
|
+
size,
|
|
26
|
+
...filteredProps
|
|
27
|
+
} = props;
|
|
28
|
+
|
|
29
|
+
/** Event listeners - run once */
|
|
30
|
+
useEventListener(ref, "nys-change", props.onNysChange);
|
|
31
|
+
useEventListener(ref, "nys-other-input", props.onNysOtherInput);
|
|
32
|
+
useEventListener(ref, "nys-focus", props.onNysFocus);
|
|
33
|
+
useEventListener(ref, "nys-blur", props.onNysBlur);
|
|
34
|
+
useEventListener(ref, "nys-error", props.onNysError);
|
|
35
|
+
useEventListener(ref, "nys-error-clear", props.onNysErrorClear);
|
|
36
|
+
|
|
37
|
+
return React.createElement(
|
|
38
|
+
"nys-checkbox",
|
|
39
|
+
{
|
|
40
|
+
ref: (node) => {
|
|
41
|
+
ref.current = node;
|
|
42
|
+
if (typeof forwardedRef === "function") {
|
|
43
|
+
forwardedRef(node);
|
|
44
|
+
} else if (forwardedRef) {
|
|
45
|
+
forwardedRef.current = node;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
...filteredProps,
|
|
49
|
+
label: props.label,
|
|
50
|
+
description: props.description,
|
|
51
|
+
id: props.id,
|
|
52
|
+
name: props.name,
|
|
53
|
+
value: props.value,
|
|
54
|
+
form: props.form,
|
|
55
|
+
errorMessage: props.errorMessage,
|
|
56
|
+
tooltip: props.tooltip,
|
|
57
|
+
size: props.size,
|
|
58
|
+
class: props.className,
|
|
59
|
+
exportparts: props.exportparts,
|
|
60
|
+
for: props.htmlFor,
|
|
61
|
+
part: props.part,
|
|
62
|
+
tabindex: props.tabIndex,
|
|
63
|
+
checked: props.checked ? true : undefined,
|
|
64
|
+
disabled: props.disabled ? true : undefined,
|
|
65
|
+
required: props.required ? true : undefined,
|
|
66
|
+
showError: props.showError ? true : undefined,
|
|
67
|
+
groupExist: props.groupExist ? true : undefined,
|
|
68
|
+
tile: props.tile ? true : undefined,
|
|
69
|
+
inverted: props.inverted ? true : undefined,
|
|
70
|
+
other: props.other ? true : undefined,
|
|
71
|
+
showOtherError: props.showOtherError ? true : undefined,
|
|
72
|
+
style: { ...props.style },
|
|
73
|
+
},
|
|
74
|
+
props.children,
|
|
75
|
+
);
|
|
76
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysCheckboxgroup as NysCheckboxgroupElement } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysCheckboxgroupElement };
|
|
5
|
+
|
|
6
|
+
export interface NysCheckboxgroupProps 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 at least one checkbox to be checked. */
|
|
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 checkboxes 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?: NysCheckboxgroupElement["id"];
|
|
38
|
+
|
|
39
|
+
/** Name for form submission. Set on group, not individual checkboxes. */
|
|
40
|
+
name?: NysCheckboxgroupElement["name"];
|
|
41
|
+
|
|
42
|
+
/** Error message text. Shown only when `showError` is true. */
|
|
43
|
+
errorMessage?: NysCheckboxgroupElement["errorMessage"];
|
|
44
|
+
|
|
45
|
+
/** Visible label text for the group. */
|
|
46
|
+
label?: NysCheckboxgroupElement["label"];
|
|
47
|
+
|
|
48
|
+
/** Helper text below label. Use slot for custom HTML. */
|
|
49
|
+
description?: NysCheckboxgroupElement["description"];
|
|
50
|
+
|
|
51
|
+
/** Tooltip text shown on hover/focus of info icon. */
|
|
52
|
+
tooltip?: NysCheckboxgroupElement["tooltip"];
|
|
53
|
+
|
|
54
|
+
/** Form `id` to associate with. Applied to all children. */
|
|
55
|
+
form?: NysCheckboxgroupElement["form"];
|
|
56
|
+
|
|
57
|
+
/** Checkbox size for all children: `sm` (24px) or `md` (32px, default). */
|
|
58
|
+
size?: NysCheckboxgroupElement["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 checkboxes as a single form control.
|
|
84
|
+
* ---
|
|
85
|
+
*
|
|
86
|
+
*
|
|
87
|
+
* ### **Slots:**
|
|
88
|
+
* - _default_ - Default slot for `nys-checkbox` elements.
|
|
89
|
+
* - **description** - Custom HTML description content.
|
|
90
|
+
*/
|
|
91
|
+
export const NysCheckboxgroup: React.ForwardRefExoticComponent<NysCheckboxgroupProps>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export const NysCheckboxgroup = 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-checkboxgroup",
|
|
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
|
+
});
|