@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.
- package/custom-elements.json +671 -317
- package/dist/.vscode/vscode.html-custom-data.json +1 -1
- package/dist/custom-elements.json +671 -317
- package/dist/nysds.es.js +779 -724
- package/dist/nysds.es.js.map +1 -1
- package/dist/nysds.js +37 -37
- package/dist/nysds.js.map +1 -1
- package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenu.d.ts +1 -1
- package/dist/packages/nys-globalheader/src/nys-globalheader.d.ts +4 -2
- package/dist/packages/nys-table/src/nys-table.d.ts +12 -1
- 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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysIcon as NysIconElement } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysIconElement };
|
|
5
|
+
|
|
6
|
+
export interface NysIconProps 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
|
+
/** Icon name from Material Symbols library. Required. */
|
|
22
|
+
name?: NysIconElement["name"];
|
|
23
|
+
|
|
24
|
+
/** Accessible label. When set, removes `aria-hidden` and adds `aria-label` to the SVG. */
|
|
25
|
+
ariaLabel?: NysIconElement["ariaLabel"];
|
|
26
|
+
|
|
27
|
+
/** Rotation in degrees. Applied via CSS `rotate`. */
|
|
28
|
+
rotate?: NysIconElement["rotate"];
|
|
29
|
+
|
|
30
|
+
/** Flip direction: `horizontal`, `vertical`, or empty for none. */
|
|
31
|
+
flip?: NysIconElement["flip"];
|
|
32
|
+
|
|
33
|
+
/** Icon color. Accepts any CSS color value. Defaults to `currentcolor`. */
|
|
34
|
+
color?: NysIconElement["color"];
|
|
35
|
+
|
|
36
|
+
/** Icon size. Semantic sizes: `xs`-`5xl`. Pixel sizes: `12`-`50`. */
|
|
37
|
+
size?: NysIconElement["size"];
|
|
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
|
+
|
|
61
|
+
/**
|
|
62
|
+
* SVG icon from Material Symbols library with size, rotation, and color options.
|
|
63
|
+
* ---
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
export const NysIcon: React.ForwardRefExoticComponent<NysIconProps>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export const NysIcon = forwardRef((props, forwardedRef) => {
|
|
5
|
+
const { name, ariaLabel, rotate, flip, color, size, ...filteredProps } =
|
|
6
|
+
props;
|
|
7
|
+
|
|
8
|
+
return React.createElement(
|
|
9
|
+
"nys-icon",
|
|
10
|
+
{
|
|
11
|
+
...filteredProps,
|
|
12
|
+
name: props.name,
|
|
13
|
+
ariaLabel: props.ariaLabel,
|
|
14
|
+
rotate: props.rotate,
|
|
15
|
+
flip: props.flip,
|
|
16
|
+
color: props.color,
|
|
17
|
+
size: props.size,
|
|
18
|
+
class: props.className,
|
|
19
|
+
exportparts: props.exportparts,
|
|
20
|
+
for: props.htmlFor,
|
|
21
|
+
part: props.part,
|
|
22
|
+
tabindex: props.tabIndex,
|
|
23
|
+
style: { ...props.style },
|
|
24
|
+
},
|
|
25
|
+
props.children,
|
|
26
|
+
);
|
|
27
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysLabel as NysLabelElement } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysLabelElement };
|
|
5
|
+
|
|
6
|
+
export interface NysLabelProps 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
|
+
/** Adjusts colors for dark backgrounds. */
|
|
22
|
+
inverted?: boolean;
|
|
23
|
+
|
|
24
|
+
/** ID of the form element this label is associated with. */
|
|
25
|
+
for?: NysLabelElement["for"];
|
|
26
|
+
|
|
27
|
+
/** Label text displayed above the form field. */
|
|
28
|
+
label?: NysLabelElement["label"];
|
|
29
|
+
|
|
30
|
+
/** Helper text displayed below the label. */
|
|
31
|
+
description?: NysLabelElement["description"];
|
|
32
|
+
|
|
33
|
+
/** Flag type: `required` shows asterisk, `optional` shows "(Optional)". */
|
|
34
|
+
flag?: NysLabelElement["flag"];
|
|
35
|
+
|
|
36
|
+
/** Tooltip text shown on hover/focus of info icon next to label. */
|
|
37
|
+
tooltip?: NysLabelElement["tooltip"];
|
|
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 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
|
+
* Internal label component for form fields with flag and tooltip support.
|
|
60
|
+
* ---
|
|
61
|
+
*
|
|
62
|
+
*
|
|
63
|
+
* ### **Slots:**
|
|
64
|
+
* - **description** - Custom HTML description content below the label.
|
|
65
|
+
*/
|
|
66
|
+
export const NysLabel: React.ForwardRefExoticComponent<NysLabelProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export const NysLabel = forwardRef((props, forwardedRef) => {
|
|
5
|
+
const { inverted, label, description, flag, tooltip, ...filteredProps } =
|
|
6
|
+
props;
|
|
7
|
+
|
|
8
|
+
return React.createElement(
|
|
9
|
+
"nys-label",
|
|
10
|
+
{
|
|
11
|
+
...filteredProps,
|
|
12
|
+
for: props.for,
|
|
13
|
+
label: props.label,
|
|
14
|
+
description: props.description,
|
|
15
|
+
flag: props.flag,
|
|
16
|
+
tooltip: props.tooltip,
|
|
17
|
+
class: props.className,
|
|
18
|
+
exportparts: props.exportparts,
|
|
19
|
+
part: props.part,
|
|
20
|
+
tabindex: props.tabIndex,
|
|
21
|
+
inverted: props.inverted ? true : undefined,
|
|
22
|
+
style: { ...props.style },
|
|
23
|
+
},
|
|
24
|
+
props.children,
|
|
25
|
+
);
|
|
26
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
NysModal as NysModalElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
} from "../../dist/nysds.es.js";
|
|
6
|
+
|
|
7
|
+
export type { NysModalElement, CustomEvent };
|
|
8
|
+
|
|
9
|
+
export interface NysModalProps 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
|
+
/** Controls modal visibility. Set to `true` to show. */
|
|
25
|
+
open?: boolean;
|
|
26
|
+
|
|
27
|
+
/** Prevents dismissal via close button or Escape key. User must take an action. */
|
|
28
|
+
mandatory?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
31
|
+
id?: NysModalElement["id"];
|
|
32
|
+
|
|
33
|
+
/** Modal heading text. Required for accessibility. */
|
|
34
|
+
heading?: NysModalElement["heading"];
|
|
35
|
+
|
|
36
|
+
/** Secondary heading below the main heading. */
|
|
37
|
+
subheading?: NysModalElement["subheading"];
|
|
38
|
+
|
|
39
|
+
/** Modal width: `sm` (400px), `md` (600px), or `lg` (800px). */
|
|
40
|
+
width?: NysModalElement["width"];
|
|
41
|
+
|
|
42
|
+
/** 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()`. */
|
|
43
|
+
className?: string;
|
|
44
|
+
|
|
45
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
46
|
+
exportparts?: string;
|
|
47
|
+
|
|
48
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
49
|
+
htmlFor?: string;
|
|
50
|
+
|
|
51
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
52
|
+
key?: number | string;
|
|
53
|
+
|
|
54
|
+
/** 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. */
|
|
55
|
+
part?: string;
|
|
56
|
+
|
|
57
|
+
/** 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. */
|
|
58
|
+
ref?: any;
|
|
59
|
+
|
|
60
|
+
/** Allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the `Tab` key, hence the name) and determine their relative ordering for sequential focus navigation. */
|
|
61
|
+
tabIndex?: number;
|
|
62
|
+
|
|
63
|
+
/** Fired when modal opens. Detail: `{id}`. */
|
|
64
|
+
onNysOpen?: (event: CustomEvent) => void;
|
|
65
|
+
|
|
66
|
+
/** Fired when modal closes. Detail: `{id}`. */
|
|
67
|
+
onNysClose?: (event: CustomEvent) => void;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Accessible modal dialog with focus trap, keyboard support, and action slots.
|
|
72
|
+
* ---
|
|
73
|
+
*
|
|
74
|
+
*
|
|
75
|
+
* ### **Events:**
|
|
76
|
+
* - **nys-open** - Fired when modal opens. Detail: `{id}`.
|
|
77
|
+
* - **nys-close** - Fired when modal closes. Detail: `{id}`.
|
|
78
|
+
*
|
|
79
|
+
* ### **Slots:**
|
|
80
|
+
* - _default_ - Default slot for body content.
|
|
81
|
+
* - **actions** - Action buttons displayed in footer. Buttons auto-resize on mobile.
|
|
82
|
+
*/
|
|
83
|
+
export const NysModal: React.ForwardRefExoticComponent<NysModalProps>;
|
|
@@ -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 NysModal = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const { open, mandatory, id, heading, subheading, width, ...filteredProps } =
|
|
8
|
+
props;
|
|
9
|
+
|
|
10
|
+
/** Event listeners - run once */
|
|
11
|
+
useEventListener(ref, "nys-open", props.onNysOpen);
|
|
12
|
+
useEventListener(ref, "nys-close", props.onNysClose);
|
|
13
|
+
|
|
14
|
+
return React.createElement(
|
|
15
|
+
"nys-modal",
|
|
16
|
+
{
|
|
17
|
+
ref: (node) => {
|
|
18
|
+
ref.current = node;
|
|
19
|
+
if (typeof forwardedRef === "function") {
|
|
20
|
+
forwardedRef(node);
|
|
21
|
+
} else if (forwardedRef) {
|
|
22
|
+
forwardedRef.current = node;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
...filteredProps,
|
|
26
|
+
id: props.id,
|
|
27
|
+
heading: props.heading,
|
|
28
|
+
subheading: props.subheading,
|
|
29
|
+
width: props.width,
|
|
30
|
+
class: props.className,
|
|
31
|
+
exportparts: props.exportparts,
|
|
32
|
+
for: props.htmlFor,
|
|
33
|
+
part: props.part,
|
|
34
|
+
tabindex: props.tabIndex,
|
|
35
|
+
open: props.open ? true : undefined,
|
|
36
|
+
mandatory: props.mandatory ? true : undefined,
|
|
37
|
+
style: { ...props.style },
|
|
38
|
+
},
|
|
39
|
+
props.children,
|
|
40
|
+
);
|
|
41
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysOption as NysOptionElement } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysOptionElement };
|
|
5
|
+
|
|
6
|
+
export interface NysOptionProps 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
|
+
/** Prevents selection of this option. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
|
|
24
|
+
/** Pre-selects this option. */
|
|
25
|
+
selected?: boolean;
|
|
26
|
+
|
|
27
|
+
/** Hides the option from the dropdown list. */
|
|
28
|
+
hidden?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Value submitted when this option is selected. */
|
|
31
|
+
value?: NysOptionElement["value"];
|
|
32
|
+
|
|
33
|
+
/** Display text for the option. Auto-populated from slot content if not set. */
|
|
34
|
+
label?: NysOptionElement["label"];
|
|
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
|
+
* Option item for nys-select dropdown.
|
|
60
|
+
* ---
|
|
61
|
+
*
|
|
62
|
+
*
|
|
63
|
+
* ### **Slots:**
|
|
64
|
+
* - _default_ - Option label text. Auto-populates the `label` prop if provided.
|
|
65
|
+
*/
|
|
66
|
+
export const NysOption: React.ForwardRefExoticComponent<NysOptionProps>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export const NysOption = forwardRef((props, forwardedRef) => {
|
|
5
|
+
const { disabled, selected, hidden, value, label, ...filteredProps } = props;
|
|
6
|
+
|
|
7
|
+
return React.createElement(
|
|
8
|
+
"nys-option",
|
|
9
|
+
{
|
|
10
|
+
...filteredProps,
|
|
11
|
+
value: props.value,
|
|
12
|
+
label: props.label,
|
|
13
|
+
class: props.className,
|
|
14
|
+
exportparts: props.exportparts,
|
|
15
|
+
for: props.htmlFor,
|
|
16
|
+
part: props.part,
|
|
17
|
+
tabindex: props.tabIndex,
|
|
18
|
+
disabled: props.disabled ? true : undefined,
|
|
19
|
+
selected: props.selected ? true : undefined,
|
|
20
|
+
hidden: props.hidden ? true : undefined,
|
|
21
|
+
style: { ...props.style },
|
|
22
|
+
},
|
|
23
|
+
props.children,
|
|
24
|
+
);
|
|
25
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
NysPagination as NysPaginationElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
} from "../../dist/nysds.es.js";
|
|
6
|
+
|
|
7
|
+
export type { NysPaginationElement, CustomEvent };
|
|
8
|
+
|
|
9
|
+
export interface NysPaginationProps 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
|
+
/** Internal state for layout adjustments near the end. */
|
|
25
|
+
_twoBeforeLast?: boolean;
|
|
26
|
+
|
|
27
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
28
|
+
id?: NysPaginationElement["id"];
|
|
29
|
+
|
|
30
|
+
/** Name attribute for form association. */
|
|
31
|
+
name?: NysPaginationElement["name"];
|
|
32
|
+
|
|
33
|
+
/** Currently active page (1-indexed). Clamped to valid range. */
|
|
34
|
+
currentPage?: NysPaginationElement["currentPage"];
|
|
35
|
+
|
|
36
|
+
/** Total number of pages. Must be at least 1. */
|
|
37
|
+
totalPages?: NysPaginationElement["totalPages"];
|
|
38
|
+
|
|
39
|
+
/** A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access specific elements via the class selectors or functions like the method `Document.getElementsByClassName()`. */
|
|
40
|
+
className?: string;
|
|
41
|
+
|
|
42
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
43
|
+
exportparts?: string;
|
|
44
|
+
|
|
45
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
46
|
+
htmlFor?: string;
|
|
47
|
+
|
|
48
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
49
|
+
key?: number | string;
|
|
50
|
+
|
|
51
|
+
/** Contains a space-separated list of the part names of the element. Part names allows CSS to select and style specific elements in a shadow tree via the ::part pseudo-element. */
|
|
52
|
+
part?: string;
|
|
53
|
+
|
|
54
|
+
/** A mutable ref object whose `.current` property is initialized to the passed argument (`initialValue`). The returned object will persist for the full lifetime of the component. */
|
|
55
|
+
ref?: any;
|
|
56
|
+
|
|
57
|
+
/** Allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the `Tab` key, hence the name) and determine their relative ordering for sequential focus navigation. */
|
|
58
|
+
tabIndex?: number;
|
|
59
|
+
|
|
60
|
+
/** Fired when page changes. Detail: `{page}`. */
|
|
61
|
+
onNysChange?: (event: CustomEvent) => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Page navigation with numbered links, prev/next buttons, and responsive layout.
|
|
66
|
+
* ---
|
|
67
|
+
*
|
|
68
|
+
*
|
|
69
|
+
* ### **Events:**
|
|
70
|
+
* - **nys-change** - Fired when page changes. Detail: `{page}`.
|
|
71
|
+
*/
|
|
72
|
+
export const NysPagination: React.ForwardRefExoticComponent<NysPaginationProps>;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 NysPagination = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const {
|
|
8
|
+
_twoBeforeLast,
|
|
9
|
+
id,
|
|
10
|
+
name,
|
|
11
|
+
currentPage,
|
|
12
|
+
totalPages,
|
|
13
|
+
...filteredProps
|
|
14
|
+
} = props;
|
|
15
|
+
|
|
16
|
+
/** Event listeners - run once */
|
|
17
|
+
useEventListener(ref, "nys-change", props.onNysChange);
|
|
18
|
+
|
|
19
|
+
return React.createElement(
|
|
20
|
+
"nys-pagination",
|
|
21
|
+
{
|
|
22
|
+
ref: (node) => {
|
|
23
|
+
ref.current = node;
|
|
24
|
+
if (typeof forwardedRef === "function") {
|
|
25
|
+
forwardedRef(node);
|
|
26
|
+
} else if (forwardedRef) {
|
|
27
|
+
forwardedRef.current = node;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
...filteredProps,
|
|
31
|
+
id: props.id,
|
|
32
|
+
name: props.name,
|
|
33
|
+
currentPage: props.currentPage,
|
|
34
|
+
totalPages: props.totalPages,
|
|
35
|
+
class: props.className,
|
|
36
|
+
exportparts: props.exportparts,
|
|
37
|
+
for: props.htmlFor,
|
|
38
|
+
part: props.part,
|
|
39
|
+
tabindex: props.tabIndex,
|
|
40
|
+
_twoBeforeLast: props._twoBeforeLast ? true : undefined,
|
|
41
|
+
style: { ...props.style },
|
|
42
|
+
},
|
|
43
|
+
props.children,
|
|
44
|
+
);
|
|
45
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
NysRadiobutton as NysRadiobuttonElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
Event,
|
|
6
|
+
} from "../../dist/nysds.es.js";
|
|
7
|
+
|
|
8
|
+
export type { NysRadiobuttonElement, CustomEvent, Event };
|
|
9
|
+
|
|
10
|
+
export interface NysRadiobuttonProps 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 this radio is selected. Only one per group can be checked. */
|
|
26
|
+
checked?: boolean;
|
|
27
|
+
|
|
28
|
+
/** Prevents interaction. */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
|
|
31
|
+
/** Marks group as required. Set on radiogroup, not individual radios. */
|
|
32
|
+
required?: boolean;
|
|
33
|
+
|
|
34
|
+
/** Adjusts colors for dark backgrounds. */
|
|
35
|
+
inverted?: boolean;
|
|
36
|
+
|
|
37
|
+
/** Renders as tile with larger clickable area. */
|
|
38
|
+
tile?: boolean;
|
|
39
|
+
|
|
40
|
+
/** undefined */
|
|
41
|
+
other?: boolean;
|
|
42
|
+
|
|
43
|
+
/** undefined */
|
|
44
|
+
showOtherError?: boolean;
|
|
45
|
+
|
|
46
|
+
/** Visible label text. Required for accessibility. */
|
|
47
|
+
label?: NysRadiobuttonElement["label"];
|
|
48
|
+
|
|
49
|
+
/** Helper text below label. Use slot for custom HTML. */
|
|
50
|
+
description?: NysRadiobuttonElement["description"];
|
|
51
|
+
|
|
52
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
53
|
+
id?: NysRadiobuttonElement["id"];
|
|
54
|
+
|
|
55
|
+
/** Group name. Radios with same name are mutually exclusive. */
|
|
56
|
+
name?: NysRadiobuttonElement["name"];
|
|
57
|
+
|
|
58
|
+
/** Value submitted when this radio is selected. */
|
|
59
|
+
value?: NysRadiobuttonElement["value"];
|
|
60
|
+
|
|
61
|
+
/** Form `id` to associate with. */
|
|
62
|
+
form?: NysRadiobuttonElement["form"];
|
|
63
|
+
|
|
64
|
+
/** Radio size: `sm` (24px) or `md` (32px, default). */
|
|
65
|
+
size?: NysRadiobuttonElement["size"];
|
|
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
|
+
/** undefined */
|
|
89
|
+
onNysErrorClear?: (event: CustomEvent) => void;
|
|
90
|
+
|
|
91
|
+
/** Fired when selection changes. Detail: `{id, checked, name, value}`. */
|
|
92
|
+
onNysChange?: (event: CustomEvent) => void;
|
|
93
|
+
|
|
94
|
+
/** Fired when "other" text input value changes. Detail: `{id, name, value}`. */
|
|
95
|
+
onNysOtherInput?: (event: CustomEvent) => void;
|
|
96
|
+
|
|
97
|
+
/** Fired when radio gains focus. */
|
|
98
|
+
onNysFocus?: (event: CustomEvent) => void;
|
|
99
|
+
|
|
100
|
+
/** Fired when radio loses focus. */
|
|
101
|
+
onNysBlur?: (event: CustomEvent) => void;
|
|
102
|
+
|
|
103
|
+
/** undefined */
|
|
104
|
+
onNysError?: (event: CustomEvent) => void;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Radio button for single selection from mutually exclusive options.
|
|
109
|
+
* ---
|
|
110
|
+
*
|
|
111
|
+
*
|
|
112
|
+
* ### **Events:**
|
|
113
|
+
* - **nys-error-clear**
|
|
114
|
+
* - **nys-change** - Fired when selection changes. Detail: `{id, checked, name, value}`.
|
|
115
|
+
* - **nys-other-input** - Fired when "other" text input value changes. Detail: `{id, name, value}`.
|
|
116
|
+
* - **nys-focus** - Fired when radio gains focus.
|
|
117
|
+
* - **nys-blur** - Fired when radio loses focus.
|
|
118
|
+
* - **nys-error**
|
|
119
|
+
*
|
|
120
|
+
* ### **Methods:**
|
|
121
|
+
* - **getInputElement(): _Promise<HTMLInputElement | null>_** - Functions
|
|
122
|
+
* --------------------------------------------------------------------------
|
|
123
|
+
*
|
|
124
|
+
* ### **Slots:**
|
|
125
|
+
* - **description** - Custom HTML description content.
|
|
126
|
+
*/
|
|
127
|
+
export const NysRadiobutton: React.ForwardRefExoticComponent<NysRadiobuttonProps>;
|