@nysds/components 1.16.1 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/custom-elements.json +480 -52
  2. package/dist/.vscode/vscode.html-custom-data.json +52 -9
  3. package/dist/custom-elements.json +480 -52
  4. package/dist/nysds.es.js +1752 -1560
  5. package/dist/nysds.es.js.map +1 -1
  6. package/dist/nysds.js +218 -218
  7. package/dist/nysds.js.map +1 -1
  8. package/dist/packages/nys-breadcrumbs/src/index.d.ts +1 -0
  9. package/dist/packages/nys-breadcrumbs/src/nys-breadcrumbs.d.ts +119 -0
  10. package/dist/packages/nys-breadcrumbs/src/nys-breadcrumbs.figma.d.ts +1 -0
  11. package/dist/packages/nys-button/src/nys-button.d.ts +2 -2
  12. package/dist/packages/nys-combobox/src/nys-combobox.d.ts +8 -0
  13. package/dist/packages/nys-datepicker/src/nys-datepicker.d.ts +1 -0
  14. package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenu.d.ts +3 -1
  15. package/dist/packages/nys-errormessage/src/nys-errormessage.d.ts +2 -2
  16. package/dist/packages/nys-label/src/nys-label.d.ts +9 -6
  17. package/dist/packages/nys-textarea/src/nys-textarea.d.ts +1 -1
  18. package/dist/packages/nys-textinput/src/nys-textinput.d.ts +2 -1
  19. package/dist/packages/nys-video/src/nys-video.d.ts +25 -0
  20. package/dist/src/index.d.ts +1 -0
  21. package/package.json +3 -2
  22. package/packages/react/NysBreadcrumbItem.d.ts +72 -0
  23. package/packages/react/NysBreadcrumbItem.js +42 -0
  24. package/packages/react/NysBreadcrumbs.d.ts +89 -0
  25. package/packages/react/NysBreadcrumbs.js +50 -0
  26. package/packages/react/NysButton.d.ts +2 -2
  27. package/packages/react/NysErrorMessage.d.ts +3 -0
  28. package/packages/react/NysErrorMessage.js +2 -1
  29. package/packages/react/NysLabel.d.ts +16 -4
  30. package/packages/react/NysLabel.js +17 -3
  31. package/packages/react/NysVideo.d.ts +7 -1
  32. package/packages/react/NysVideo.js +14 -1
  33. package/packages/react/index.d.ts +1 -0
  34. package/packages/react/index.js +1 -0
  35. package/packages/react/nysds-jsx.d.ts +59 -5
@@ -1,7 +1,10 @@
1
1
  import React from "react";
2
- import { NysLabel as NysLabelElement } from "../../dist/nysds.es.js";
2
+ import {
3
+ NysLabel as NysLabelElement,
4
+ CustomEvent,
5
+ } from "../../dist/nysds.es.js";
3
6
 
4
- export type { NysLabelElement };
7
+ export type { NysLabelElement, CustomEvent };
5
8
 
6
9
  export interface NysLabelProps extends Pick<
7
10
  React.AllHTMLAttributes<HTMLElement>,
@@ -21,8 +24,8 @@ export interface NysLabelProps extends Pick<
21
24
  /** Adjusts colors for dark backgrounds. */
22
25
  inverted?: boolean;
23
26
 
24
- /** ID of the form element this label is associated with. */
25
- for?: NysLabelElement["for"];
27
+ /** The ID of the label. */
28
+ id?: NysLabelElement["id"];
26
29
 
27
30
  /** Label text displayed above the form field. */
28
31
  label?: NysLabelElement["label"];
@@ -42,6 +45,9 @@ export interface NysLabelProps extends Pick<
42
45
  /** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
43
46
  exportparts?: string;
44
47
 
48
+ /** Used for labels to link them with their inputs (using input id). */
49
+ htmlFor?: string;
50
+
45
51
  /** Used to help React identify which items have changed, are added, or are removed within a list. */
46
52
  key?: number | string;
47
53
 
@@ -53,6 +59,9 @@ export interface NysLabelProps extends Pick<
53
59
 
54
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. */
55
61
  tabIndex?: number;
62
+
63
+ /** undefined */
64
+ onNysLabelClick?: (event: CustomEvent) => void;
56
65
  }
57
66
 
58
67
  /**
@@ -60,6 +69,9 @@ export interface NysLabelProps extends Pick<
60
69
  * ---
61
70
  *
62
71
  *
72
+ * ### **Events:**
73
+ * - **nys-label-click**
74
+ *
63
75
  * ### **Slots:**
64
76
  * - **description** - Custom HTML description content below the label.
65
77
  */
@@ -1,21 +1,35 @@
1
- import React, { forwardRef } from "react";
1
+ import React, { forwardRef, useRef, useEffect } from "react";
2
2
  import "../../dist/nysds.es.js";
3
+ import { useEventListener } from "./react-utils.js";
3
4
 
4
5
  export const NysLabel = forwardRef((props, forwardedRef) => {
5
- const { inverted, label, description, flag, tooltip, ...filteredProps } =
6
+ const ref = useRef(null);
7
+ const { inverted, id, label, description, flag, tooltip, ...filteredProps } =
6
8
  props;
7
9
 
10
+ /** Event listeners - run once */
11
+ useEventListener(ref, "nys-label-click", props.onNysLabelClick);
12
+
8
13
  return React.createElement(
9
14
  "nys-label",
10
15
  {
16
+ ref: (node) => {
17
+ ref.current = node;
18
+ if (typeof forwardedRef === "function") {
19
+ forwardedRef(node);
20
+ } else if (forwardedRef) {
21
+ forwardedRef.current = node;
22
+ }
23
+ },
11
24
  ...filteredProps,
12
- for: props.for,
25
+ id: props.id,
13
26
  label: props.label,
14
27
  description: props.description,
15
28
  flag: props.flag,
16
29
  tooltip: props.tooltip,
17
30
  class: props.className,
18
31
  exportparts: props.exportparts,
32
+ for: props.htmlFor,
19
33
  part: props.part,
20
34
  tabindex: props.tabIndex,
21
35
  inverted: props.inverted ? true : undefined,
@@ -67,11 +67,17 @@ Falls back to YouTube's auto-generated thumbnail if not provided. */
67
67
 
68
68
  /** 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. */
69
69
  tabIndex?: number;
70
+
71
+ /** Fired when the user clicks the thumbnail to load the player. */
72
+ onNysVideoPlay?: (event: CustomEvent) => void;
70
73
  }
71
74
 
72
75
  /**
73
- *
76
+ * YouTube video player with thumbnail preview and accessibility announcements.
74
77
  * ---
75
78
  *
79
+ *
80
+ * ### **Events:**
81
+ * - **nys-video-play** - Fired when the user clicks the thumbnail to load the player.
76
82
  */
77
83
  export const NysVideo: React.ForwardRefExoticComponent<NysVideoProps>;
@@ -1,7 +1,9 @@
1
- import React, { forwardRef } from "react";
1
+ import React, { forwardRef, useRef, useEffect } from "react";
2
2
  import "../../dist/nysds.es.js";
3
+ import { useEventListener } from "./react-utils.js";
3
4
 
4
5
  export const NysVideo = forwardRef((props, forwardedRef) => {
6
+ const ref = useRef(null);
5
7
  const {
6
8
  autoplay,
7
9
  disabled,
@@ -15,9 +17,20 @@ export const NysVideo = forwardRef((props, forwardedRef) => {
15
17
  ...filteredProps
16
18
  } = props;
17
19
 
20
+ /** Event listeners - run once */
21
+ useEventListener(ref, "nys-video-play", props.onNysVideoPlay);
22
+
18
23
  return React.createElement(
19
24
  "nys-video",
20
25
  {
26
+ ref: (node) => {
27
+ ref.current = node;
28
+ if (typeof forwardedRef === "function") {
29
+ forwardedRef(node);
30
+ } else if (forwardedRef) {
31
+ forwardedRef.current = node;
32
+ }
33
+ },
21
34
  ...filteredProps,
22
35
  id: props.id,
23
36
  titleText: props.titleText,
@@ -4,6 +4,7 @@ export * from "./NysAlert.js";
4
4
  export * from "./NysAvatar.js";
5
5
  export * from "./NysBacktotop.js";
6
6
  export * from "./NysBadge.js";
7
+ export * from "./NysBreadcrumbs.js";
7
8
  export * from "./NysButton.js";
8
9
  export * from "./NysCheckbox.js";
9
10
  export * from "./NysCheckboxgroup.js";
@@ -4,6 +4,7 @@ export * from "./NysAlert.js";
4
4
  export * from "./NysAvatar.js";
5
5
  export * from "./NysBacktotop.js";
6
6
  export * from "./NysBadge.js";
7
+ export * from "./NysBreadcrumbs.js";
7
8
  export * from "./NysButton.js";
8
9
  export * from "./NysCheckbox.js";
9
10
  export * from "./NysCheckboxgroup.js";
@@ -171,6 +171,32 @@ export type NysBadgeProps = {
171
171
  suffixicon?: string | boolean;
172
172
  };
173
173
 
174
+ export type NysBreadcrumbsProps = {
175
+ /** Unique identifier. Auto-generated if not provided. */
176
+ id?: string;
177
+ /** Accessible label for the `<nav>` landmark. Defaults to "path to this page" if not set.
178
+ Override when multiple crumbs exist on the same page. */
179
+ ariaLabel?: string;
180
+ /** Controls the visual size of the breadcrumb text and spacing: `sm` for dense layouts, `md` (default) for standard use. */
181
+ size?: "sm" | "md" | "";
182
+ /** On mobile, renders the trail as a single back-to-parent link pointing to the item before the current page.
183
+ Has no effect on desktop or when only one item is present (which always renders as a back link). */
184
+ backToParent?: boolean;
185
+ /** Forces the trail into its collapsed state.
186
+ It shows only the first item, an ellipsis, and the last two items.
187
+ The user can still expand the trail by clicking the ellipsis. */
188
+ collapsed?: boolean;
189
+ /** Renders a filled light theme background bar behind the breadcrumb trail. */
190
+ backgroundBar?: boolean;
191
+ /** Prevents interaction. */
192
+ disabled?: boolean;
193
+
194
+ /** */
195
+ "onnys-expand"?: (e: CustomEvent<CustomEvent>) => void;
196
+ /** Fired when the user clicks the ellipsis to expand the trail. */
197
+ "onnys-breadcrumbs-expand"?: (e: CustomEvent<never>) => void;
198
+ };
199
+
174
200
  export type NysButtonProps = {
175
201
  /** Unique identifier. Auto-generated if not provided. */
176
202
  id?: string;
@@ -190,9 +216,9 @@ export type NysButtonProps = {
190
216
  ariaLabel?: string;
191
217
  /** ID of controlled element (e.g., dropdown or modal). Sets `aria-controls`. */
192
218
  ariaControls?: string;
193
- /** Material Symbol icon before label. Not shown for `text` variant or `circle` mode. */
219
+ /** Material Symbol icon before label. Not shown for `circle` mode. */
194
220
  prefixIcon?: string;
195
- /** Material Symbol icon after label. Use `chevron_down` for dropdowns, `open_in_new` for external links. Not shown for `text` variant or `circle` mode. */
221
+ /** Material Symbol icon after label. Use `chevron_down` for dropdowns, `open_in_new` for external links. Not shown for `circle` mode. */
196
222
  suffixIcon?: string;
197
223
  /** Renders circular icon-only button. Requires `icon` prop. `label` becomes aria-label. */
198
224
  circle?: boolean;
@@ -425,6 +451,8 @@ export type NysDropdownMenuItemProps = {
425
451
  };
426
452
 
427
453
  export type NysErrorMessageProps = {
454
+ /** The "id" of the error message. */
455
+ id?: string;
428
456
  /** Whether to display the error message. */
429
457
  showError?: boolean;
430
458
  /** Error text to display. Falls back to native validation message if available. */
@@ -537,8 +565,8 @@ export type NysIconProps = {
537
565
  };
538
566
 
539
567
  export type NysLabelProps = {
540
- /** ID of the form element this label is associated with. */
541
- for?: string;
568
+ /** The ID of the label. */
569
+ id?: string;
542
570
  /** Label text displayed above the form field. */
543
571
  label?: string;
544
572
  /** Helper text displayed below the label. */
@@ -549,6 +577,9 @@ export type NysLabelProps = {
549
577
  inverted?: boolean;
550
578
  /** Tooltip text shown on hover/focus of info icon next to label. */
551
579
  tooltip?: string;
580
+
581
+ /** */
582
+ "onnys-label-click"?: (e: CustomEvent<CustomEvent>) => void;
552
583
  };
553
584
 
554
585
  export type NysModalProps = {
@@ -965,6 +996,9 @@ Falls back to YouTube's auto-generated thumbnail if not provided. */
965
996
  autoplay?: boolean;
966
997
  /** Prevents the video from being played */
967
998
  disabled?: boolean;
999
+
1000
+ /** Fired when the user clicks the thumbnail to load the player. */
1001
+ "onnys-video-play"?: (e: CustomEvent<never>) => void;
968
1002
  };
969
1003
 
970
1004
  export type CustomElements = {
@@ -1033,6 +1067,20 @@ export type CustomElements = {
1033
1067
  */
1034
1068
  "nys-badge": Partial<NysBadgeProps & BaseProps & BaseEvents>;
1035
1069
 
1070
+ /**
1071
+ * Breadcrumb navigation trail with responsive collapse support.
1072
+ * ---
1073
+ *
1074
+ *
1075
+ * ### **Events:**
1076
+ * - **nys-expand**
1077
+ * - **nys-breadcrumbs-expand** - Fired when the user clicks the ellipsis to expand the trail.
1078
+ *
1079
+ * ### **Slots:**
1080
+ * - _default_ - One or more `nys-breadcrumbitem` elements defining the trail.
1081
+ */
1082
+ "nys-breadcrumbs": Partial<NysBreadcrumbsProps & BaseProps & BaseEvents>;
1083
+
1036
1084
  /**
1037
1085
  * Button for actions and CTAs with variants, sizes, and icon support.
1038
1086
  * ---
@@ -1224,6 +1272,9 @@ export type CustomElements = {
1224
1272
  * ---
1225
1273
  *
1226
1274
  *
1275
+ * ### **Events:**
1276
+ * - **nys-label-click**
1277
+ *
1227
1278
  * ### **Slots:**
1228
1279
  * - **description** - Custom HTML description content below the label.
1229
1280
  */
@@ -1439,9 +1490,12 @@ export type CustomElements = {
1439
1490
  "nys-unavheader": Partial<NysUnavHeaderProps & BaseProps & BaseEvents>;
1440
1491
 
1441
1492
  /**
1442
- *
1493
+ * YouTube video player with thumbnail preview and accessibility announcements.
1443
1494
  * ---
1444
1495
  *
1496
+ *
1497
+ * ### **Events:**
1498
+ * - **nys-video-play** - Fired when the user clicks the thumbnail to load the player.
1445
1499
  */
1446
1500
  "nys-video": Partial<NysVideoProps & BaseProps & BaseEvents>;
1447
1501
  };