@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,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
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
NysCombobox as NysComboboxElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
Event,
|
|
6
|
+
} from "../../dist/nysds.es.js";
|
|
7
|
+
|
|
8
|
+
export type { NysComboboxElement, CustomEvent, Event };
|
|
9
|
+
|
|
10
|
+
export interface NysComboboxProps 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
|
+
/** undefined */
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
|
|
28
|
+
/** undefined */
|
|
29
|
+
required?: boolean;
|
|
30
|
+
|
|
31
|
+
/** undefined */
|
|
32
|
+
optional?: boolean;
|
|
33
|
+
|
|
34
|
+
/** undefined */
|
|
35
|
+
inverted?: boolean;
|
|
36
|
+
|
|
37
|
+
/** undefined */
|
|
38
|
+
showError?: boolean;
|
|
39
|
+
|
|
40
|
+
/** undefined */
|
|
41
|
+
id?: NysComboboxElement["id"];
|
|
42
|
+
|
|
43
|
+
/** undefined */
|
|
44
|
+
name?: NysComboboxElement["name"];
|
|
45
|
+
|
|
46
|
+
/** undefined */
|
|
47
|
+
label?: NysComboboxElement["label"];
|
|
48
|
+
|
|
49
|
+
/** undefined */
|
|
50
|
+
description?: NysComboboxElement["description"];
|
|
51
|
+
|
|
52
|
+
/** undefined */
|
|
53
|
+
value?: NysComboboxElement["value"];
|
|
54
|
+
|
|
55
|
+
/** undefined */
|
|
56
|
+
tooltip?: NysComboboxElement["tooltip"];
|
|
57
|
+
|
|
58
|
+
/** undefined */
|
|
59
|
+
form?: NysComboboxElement["form"];
|
|
60
|
+
|
|
61
|
+
/** undefined */
|
|
62
|
+
width?: NysComboboxElement["width"];
|
|
63
|
+
|
|
64
|
+
/** undefined */
|
|
65
|
+
errorMessage?: NysComboboxElement["errorMessage"];
|
|
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 on input change. Detail: `{ id, value }`. */
|
|
89
|
+
onNysInput?: (event: CustomEvent) => void;
|
|
90
|
+
|
|
91
|
+
/** Fired when combobox receives focus. */
|
|
92
|
+
onNysFocus?: (event: CustomEvent) => void;
|
|
93
|
+
|
|
94
|
+
/** Fired when combobox loses focus. */
|
|
95
|
+
onNysBlur?: (event: CustomEvent) => void;
|
|
96
|
+
|
|
97
|
+
/** Fired when selection changes. Detail: `{ id, value }`. */
|
|
98
|
+
onNysChange?: (event: CustomEvent) => void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* `<nys-combobox>` is a form-enabled combo box combining text input with a filterable dropdown.
|
|
103
|
+
*
|
|
104
|
+
* Features:
|
|
105
|
+
* - Type to filter options
|
|
106
|
+
* - Keyboard navigation (Arrow keys, Enter, Escape)
|
|
107
|
+
* - Mouse and keyboard interaction
|
|
108
|
+
* - Clears non-selected text on blur
|
|
109
|
+
* - Clear button when value is selected
|
|
110
|
+
* - Integrates with forms via ElementInternals
|
|
111
|
+
* - Supports native <option> and <optgroup> elements
|
|
112
|
+
* - Accessible per W3C ARIA Authoring Practices
|
|
113
|
+
* ---
|
|
114
|
+
*
|
|
115
|
+
*
|
|
116
|
+
* ### **Events:**
|
|
117
|
+
* - **nys-input** - Fired on input change. Detail: `{ id, value }`.
|
|
118
|
+
* - **nys-focus** - Fired when combobox receives focus.
|
|
119
|
+
* - **nys-blur** - Fired when combobox loses focus.
|
|
120
|
+
* - **nys-change** - Fired when selection changes. Detail: `{ id, value }`.
|
|
121
|
+
*
|
|
122
|
+
* ### **Slots:**
|
|
123
|
+
* - **description** - Optional custom description content below the label.
|
|
124
|
+
* - **default** - Options (<option>, <optgroup>) to populate the dropdown
|
|
125
|
+
*/
|
|
126
|
+
export const NysCombobox: React.ForwardRefExoticComponent<NysComboboxProps>;
|
|
@@ -0,0 +1,66 @@
|
|
|
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 NysCombobox = 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
|
+
width,
|
|
21
|
+
errorMessage,
|
|
22
|
+
...filteredProps
|
|
23
|
+
} = props;
|
|
24
|
+
|
|
25
|
+
/** Event listeners - run once */
|
|
26
|
+
useEventListener(ref, "nys-input", props.onNysInput);
|
|
27
|
+
useEventListener(ref, "nys-focus", props.onNysFocus);
|
|
28
|
+
useEventListener(ref, "nys-blur", props.onNysBlur);
|
|
29
|
+
useEventListener(ref, "nys-change", props.onNysChange);
|
|
30
|
+
|
|
31
|
+
return React.createElement(
|
|
32
|
+
"nys-combobox",
|
|
33
|
+
{
|
|
34
|
+
ref: (node) => {
|
|
35
|
+
ref.current = node;
|
|
36
|
+
if (typeof forwardedRef === "function") {
|
|
37
|
+
forwardedRef(node);
|
|
38
|
+
} else if (forwardedRef) {
|
|
39
|
+
forwardedRef.current = node;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
...filteredProps,
|
|
43
|
+
id: props.id,
|
|
44
|
+
name: props.name,
|
|
45
|
+
label: props.label,
|
|
46
|
+
description: props.description,
|
|
47
|
+
value: props.value,
|
|
48
|
+
tooltip: props.tooltip,
|
|
49
|
+
form: props.form,
|
|
50
|
+
width: props.width,
|
|
51
|
+
errorMessage: props.errorMessage,
|
|
52
|
+
class: props.className,
|
|
53
|
+
exportparts: props.exportparts,
|
|
54
|
+
for: props.htmlFor,
|
|
55
|
+
part: props.part,
|
|
56
|
+
tabindex: props.tabIndex,
|
|
57
|
+
disabled: props.disabled ? true : undefined,
|
|
58
|
+
required: props.required ? true : undefined,
|
|
59
|
+
optional: props.optional ? true : undefined,
|
|
60
|
+
inverted: props.inverted ? true : undefined,
|
|
61
|
+
showError: props.showError ? true : undefined,
|
|
62
|
+
style: { ...props.style },
|
|
63
|
+
},
|
|
64
|
+
props.children,
|
|
65
|
+
);
|
|
66
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
NysDatepicker as NysDatepickerElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
Event,
|
|
6
|
+
} from "../../dist/nysds.es.js";
|
|
7
|
+
|
|
8
|
+
export type { NysDatepickerElement, CustomEvent, Event };
|
|
9
|
+
|
|
10
|
+
export interface NysDatepickerProps 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
|
+
/** Hide the "Today" button in calendar popup. */
|
|
26
|
+
hideTodayButton?: boolean;
|
|
27
|
+
|
|
28
|
+
/** Hide the "Clear" button in calendar popup. */
|
|
29
|
+
hideClearButton?: boolean;
|
|
30
|
+
|
|
31
|
+
/** Disable interaction. */
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
|
|
34
|
+
/** Mark as required. Shows "Required" flag and validates on blur. */
|
|
35
|
+
required?: boolean;
|
|
36
|
+
|
|
37
|
+
/** Show "Optional" flag. Use when most fields are required. */
|
|
38
|
+
optional?: boolean;
|
|
39
|
+
|
|
40
|
+
/** Show error state. */
|
|
41
|
+
showError?: boolean;
|
|
42
|
+
|
|
43
|
+
/** Dark background mode. */
|
|
44
|
+
inverted?: boolean;
|
|
45
|
+
|
|
46
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
47
|
+
id?: NysDatepickerElement["id"];
|
|
48
|
+
|
|
49
|
+
/** Name for form submission. */
|
|
50
|
+
name?: NysDatepickerElement["name"];
|
|
51
|
+
|
|
52
|
+
/** Input width: `md` (200px), `lg` (384px), `full` (100%). */
|
|
53
|
+
width?: NysDatepickerElement["width"];
|
|
54
|
+
|
|
55
|
+
/** Error message text. */
|
|
56
|
+
errorMessage?: NysDatepickerElement["errorMessage"];
|
|
57
|
+
|
|
58
|
+
/** Form `id` to associate with when input is outside form. */
|
|
59
|
+
form?: NysDatepickerElement["form"];
|
|
60
|
+
|
|
61
|
+
/** Tooltip text on info icon hover. */
|
|
62
|
+
tooltip?: NysDatepickerElement["tooltip"];
|
|
63
|
+
|
|
64
|
+
/** Input type. Currently only supports `date`. */
|
|
65
|
+
type?: NysDatepickerElement["type"];
|
|
66
|
+
|
|
67
|
+
/** Label text. Required for accessibility. */
|
|
68
|
+
label?: NysDatepickerElement["label"];
|
|
69
|
+
|
|
70
|
+
/** Helper text below label. */
|
|
71
|
+
description?: NysDatepickerElement["description"];
|
|
72
|
+
|
|
73
|
+
/** Initial date when calendar opens (YYYY-MM-DD). */
|
|
74
|
+
startDate?: NysDatepickerElement["startDate"];
|
|
75
|
+
|
|
76
|
+
/** Selected date. Accepts Date object or ISO string (YYYY-MM-DD). */
|
|
77
|
+
value?: NysDatepickerElement["value"];
|
|
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 on date selection. Detail: `{id, value}`. */
|
|
101
|
+
onNysInput?: (event: CustomEvent) => void;
|
|
102
|
+
|
|
103
|
+
/** Fired when input or calendar loses focus. Triggers validation. */
|
|
104
|
+
onNysBlur?: (event: CustomEvent) => void;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Date picker with calendar popup and native fallback.
|
|
109
|
+
* ---
|
|
110
|
+
*
|
|
111
|
+
*
|
|
112
|
+
* ### **Events:**
|
|
113
|
+
* - **nys-input** - Fired on date selection. Detail: `{id, value}`.
|
|
114
|
+
* - **nys-blur** - Fired when input or calendar loses focus. Triggers validation.
|
|
115
|
+
*
|
|
116
|
+
* ### **Methods:**
|
|
117
|
+
* - **checkValidity(): _boolean_** - Passive check of validity:
|
|
118
|
+
* - Returns true/false
|
|
119
|
+
* - Does NOT update UI or show errors
|
|
120
|
+
* - Used in form submission checks
|
|
121
|
+
*/
|
|
122
|
+
export const NysDatepicker: React.ForwardRefExoticComponent<NysDatepickerProps>;
|
|
@@ -0,0 +1,72 @@
|
|
|
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 NysDatepicker = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const {
|
|
8
|
+
hideTodayButton,
|
|
9
|
+
hideClearButton,
|
|
10
|
+
disabled,
|
|
11
|
+
required,
|
|
12
|
+
optional,
|
|
13
|
+
showError,
|
|
14
|
+
inverted,
|
|
15
|
+
id,
|
|
16
|
+
name,
|
|
17
|
+
width,
|
|
18
|
+
errorMessage,
|
|
19
|
+
form,
|
|
20
|
+
tooltip,
|
|
21
|
+
type,
|
|
22
|
+
label,
|
|
23
|
+
description,
|
|
24
|
+
startDate,
|
|
25
|
+
value,
|
|
26
|
+
...filteredProps
|
|
27
|
+
} = props;
|
|
28
|
+
|
|
29
|
+
/** Event listeners - run once */
|
|
30
|
+
useEventListener(ref, "nys-input", props.onNysInput);
|
|
31
|
+
useEventListener(ref, "nys-blur", props.onNysBlur);
|
|
32
|
+
|
|
33
|
+
return React.createElement(
|
|
34
|
+
"nys-datepicker",
|
|
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
|
+
id: props.id,
|
|
46
|
+
name: props.name,
|
|
47
|
+
width: props.width,
|
|
48
|
+
errorMessage: props.errorMessage,
|
|
49
|
+
form: props.form,
|
|
50
|
+
tooltip: props.tooltip,
|
|
51
|
+
type: props.type,
|
|
52
|
+
label: props.label,
|
|
53
|
+
description: props.description,
|
|
54
|
+
startDate: props.startDate,
|
|
55
|
+
value: props.value,
|
|
56
|
+
class: props.className,
|
|
57
|
+
exportparts: props.exportparts,
|
|
58
|
+
for: props.htmlFor,
|
|
59
|
+
part: props.part,
|
|
60
|
+
tabindex: props.tabIndex,
|
|
61
|
+
hideTodayButton: props.hideTodayButton ? true : undefined,
|
|
62
|
+
hideClearButton: props.hideClearButton ? true : undefined,
|
|
63
|
+
disabled: props.disabled ? true : undefined,
|
|
64
|
+
required: props.required ? true : undefined,
|
|
65
|
+
optional: props.optional ? true : undefined,
|
|
66
|
+
showError: props.showError ? true : undefined,
|
|
67
|
+
inverted: props.inverted ? true : undefined,
|
|
68
|
+
style: { ...props.style },
|
|
69
|
+
},
|
|
70
|
+
props.children,
|
|
71
|
+
);
|
|
72
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysDivider as NysDividerElement } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysDividerElement };
|
|
5
|
+
|
|
6
|
+
export interface NysDividerProps 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
|
+
/** A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access specific elements via the class selectors or functions like the method `Document.getElementsByClassName()`. */
|
|
25
|
+
className?: string;
|
|
26
|
+
|
|
27
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
28
|
+
exportparts?: string;
|
|
29
|
+
|
|
30
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
31
|
+
htmlFor?: string;
|
|
32
|
+
|
|
33
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
34
|
+
key?: number | string;
|
|
35
|
+
|
|
36
|
+
/** 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. */
|
|
37
|
+
part?: string;
|
|
38
|
+
|
|
39
|
+
/** 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. */
|
|
40
|
+
ref?: any;
|
|
41
|
+
|
|
42
|
+
/** 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. */
|
|
43
|
+
tabIndex?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Horizontal divider for visual separation of content sections.
|
|
48
|
+
* ---
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
export const NysDivider: React.ForwardRefExoticComponent<NysDividerProps>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export const NysDivider = forwardRef((props, forwardedRef) => {
|
|
5
|
+
const { inverted, ...filteredProps } = props;
|
|
6
|
+
|
|
7
|
+
return React.createElement(
|
|
8
|
+
"nys-divider",
|
|
9
|
+
{
|
|
10
|
+
...filteredProps,
|
|
11
|
+
class: props.className,
|
|
12
|
+
exportparts: props.exportparts,
|
|
13
|
+
for: props.htmlFor,
|
|
14
|
+
part: props.part,
|
|
15
|
+
tabindex: props.tabIndex,
|
|
16
|
+
inverted: props.inverted ? true : undefined,
|
|
17
|
+
style: { ...props.style },
|
|
18
|
+
},
|
|
19
|
+
props.children,
|
|
20
|
+
);
|
|
21
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NysDropdownMenu as NysDropdownMenuElement } from "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export type { NysDropdownMenuElement };
|
|
5
|
+
|
|
6
|
+
export interface NysDropdownMenuProps 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
|
+
showDropdown?: boolean;
|
|
23
|
+
|
|
24
|
+
/** undefined */
|
|
25
|
+
for?: NysDropdownMenuElement["for"];
|
|
26
|
+
|
|
27
|
+
/** Preferred position relative to trigger. */
|
|
28
|
+
position?: NysDropdownMenuElement["position"];
|
|
29
|
+
|
|
30
|
+
/** A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access specific elements via the class selectors or functions like the method `Document.getElementsByClassName()`. */
|
|
31
|
+
className?: string;
|
|
32
|
+
|
|
33
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
34
|
+
exportparts?: string;
|
|
35
|
+
|
|
36
|
+
/** Used 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
|
+
*
|
|
51
|
+
* ---
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
export const NysDropdownMenu: React.ForwardRefExoticComponent<NysDropdownMenuProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "../../dist/nysds.es.js";
|
|
3
|
+
|
|
4
|
+
export const NysDropdownMenu = forwardRef((props, forwardedRef) => {
|
|
5
|
+
const { showDropdown, position, ...filteredProps } = props;
|
|
6
|
+
|
|
7
|
+
return React.createElement(
|
|
8
|
+
"nys-dropdownmenu",
|
|
9
|
+
{
|
|
10
|
+
...filteredProps,
|
|
11
|
+
for: props.for,
|
|
12
|
+
position: props.position,
|
|
13
|
+
class: props.className,
|
|
14
|
+
exportparts: props.exportparts,
|
|
15
|
+
part: props.part,
|
|
16
|
+
tabindex: props.tabIndex,
|
|
17
|
+
showDropdown: props.showDropdown ? true : undefined,
|
|
18
|
+
style: { ...props.style },
|
|
19
|
+
},
|
|
20
|
+
props.children,
|
|
21
|
+
);
|
|
22
|
+
});
|