@nysds/components 1.20.0-alpha-3 → 1.20.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 (136) hide show
  1. package/custom-elements.json +9101 -5385
  2. package/dist/.vscode/vscode.css-custom-data.json +5 -0
  3. package/dist/.vscode/vscode.html-custom-data.json +332 -30
  4. package/dist/custom-elements.json +9101 -5385
  5. package/dist/nys-icon.library-Bu3noJqZ-1mvg_e5Y.js +706 -0
  6. package/dist/nys-icon.library-Bu3noJqZ-1mvg_e5Y.js.map +1 -0
  7. package/dist/nys-icon.library-eNVZmfkf.js +696 -0
  8. package/dist/nys-icon.library-eNVZmfkf.js.map +1 -0
  9. package/dist/nysds.es.js +10460 -5393
  10. package/dist/nysds.es.js.map +1 -1
  11. package/dist/nysds.js +2436 -472
  12. package/dist/nysds.js.map +1 -1
  13. package/dist/packages/internals/src/aria-associate.d.ts +41 -0
  14. package/dist/packages/internals/src/form-control-mixin.d.ts +34 -0
  15. package/dist/packages/internals/src/id.d.ts +8 -0
  16. package/dist/packages/internals/src/identified-mixin.d.ts +23 -0
  17. package/dist/packages/internals/src/index.d.ts +7 -0
  18. package/dist/packages/internals/src/reflects-aria-mixin.d.ts +33 -0
  19. package/dist/packages/internals/src/test-helpers.d.ts +29 -0
  20. package/dist/packages/internals/src/types.d.ts +9 -0
  21. package/dist/packages/nys-accordion/src/nys-accordion.d.ts +72 -10
  22. package/dist/packages/nys-accordion/src/nys-accordionitem.d.ts +63 -8
  23. package/dist/packages/nys-alert/src/nys-alert.d.ts +95 -20
  24. package/dist/packages/nys-avatar/src/nys-avatar.d.ts +100 -7
  25. package/dist/packages/nys-backtotop/src/nys-backtotop.d.ts +75 -5
  26. package/dist/packages/nys-badge/src/nys-badge.d.ts +63 -6
  27. package/dist/packages/nys-breadcrumbs/src/nys-breadcrumbs.d.ts +79 -10
  28. package/dist/packages/nys-button/src/nys-button.d.ts +132 -26
  29. package/dist/packages/nys-card/src/index.d.ts +1 -0
  30. package/dist/packages/nys-card/src/nys-card.d.ts +325 -0
  31. package/dist/packages/nys-card/src/nys-card.figma.d.ts +1 -0
  32. package/dist/packages/nys-checkbox/src/nys-checkbox.d.ts +36 -12
  33. package/dist/packages/nys-checkbox/src/nys-checkboxgroup.d.ts +81 -6
  34. package/dist/packages/nys-combobox/src/nys-combobox.d.ts +174 -5
  35. package/dist/packages/nys-datepicker/src/nys-datepicker.d.ts +83 -13
  36. package/dist/packages/nys-divider/src/nys-divider.d.ts +33 -9
  37. package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenu.d.ts +24 -15
  38. package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenuitem.d.ts +3 -12
  39. package/dist/packages/nys-errormessage/src/nys-errormessage.d.ts +22 -0
  40. package/dist/packages/nys-fileinput/src/nys-fileinput.d.ts +101 -12
  41. package/dist/packages/nys-fileinput/src/nys-fileitem.d.ts +23 -2
  42. package/dist/packages/nys-globalfooter/src/nys-globalfooter.d.ts +99 -9
  43. package/dist/packages/nys-globalheader/src/nys-globalheader.d.ts +189 -6
  44. package/dist/packages/nys-icon/src/icon-cache.d.ts +11 -4
  45. package/dist/packages/nys-icon/src/icon-library-registry.d.ts +33 -16
  46. package/dist/packages/nys-icon/src/index.d.ts +2 -2
  47. package/dist/packages/nys-icon/src/nys-icon.d.ts +98 -8
  48. package/dist/packages/nys-iconlist/src/index.d.ts +2 -0
  49. package/dist/packages/nys-iconlist/src/nys-iconlist.d.ts +92 -0
  50. package/dist/packages/nys-iconlist/src/nys-iconlist.figma.d.ts +1 -0
  51. package/dist/packages/nys-iconlist/src/nys-iconlistitem.d.ts +32 -0
  52. package/dist/packages/nys-label/src/nys-label.d.ts +37 -2
  53. package/dist/packages/nys-modal/src/nys-modal.d.ts +145 -13
  54. package/dist/packages/nys-pagination/src/nys-pagination.d.ts +67 -3
  55. package/dist/packages/nys-processlist/src/index.d.ts +2 -0
  56. package/dist/packages/nys-processlist/src/nys-processlist.d.ts +184 -0
  57. package/dist/packages/nys-processlist/src/nys-processlist.figma.d.ts +1 -0
  58. package/dist/packages/nys-processlist/src/nys-processlistitem.d.ts +41 -0
  59. package/dist/packages/nys-radiobutton/src/nys-radiobutton.d.ts +201 -7
  60. package/dist/packages/nys-radiobutton/src/nys-radiogroup.d.ts +88 -6
  61. package/dist/packages/nys-select/src/nys-option.d.ts +0 -8
  62. package/dist/packages/nys-select/src/nys-select.d.ts +150 -15
  63. package/dist/packages/nys-skipnav/src/nys-skipnav.d.ts +4 -4
  64. package/dist/packages/nys-stepper/src/nys-step.d.ts +26 -20
  65. package/dist/packages/nys-stepper/src/nys-stepper.d.ts +128 -75
  66. package/dist/packages/nys-tab/src/nys-tab.d.ts +19 -10
  67. package/dist/packages/nys-tab/src/nys-tabgroup.d.ts +181 -39
  68. package/dist/packages/nys-tab/src/nys-tabpanel.d.ts +15 -24
  69. package/dist/packages/nys-table/src/nys-table.d.ts +90 -3
  70. package/dist/packages/nys-textarea/src/nys-textarea.d.ts +60 -10
  71. package/dist/packages/nys-textinput/src/nys-textinput.d.ts +77 -14
  72. package/dist/packages/nys-toggle/src/nys-toggle.d.ts +47 -10
  73. package/dist/packages/nys-tooltip/src/nys-tooltip.d.ts +48 -8
  74. package/dist/packages/nys-unavfooter/src/nys-unavfooter.d.ts +45 -4
  75. package/dist/packages/nys-unavheader/src/nys-unavheader.d.ts +216 -11
  76. package/dist/packages/nys-verticalnav/src/index.d.ts +2 -0
  77. package/dist/packages/nys-verticalnav/src/nys-verticalnav.d.ts +572 -0
  78. package/dist/packages/nys-verticalnav/src/nys-verticalnav.figma.d.ts +1 -0
  79. package/dist/packages/nys-verticalnav/src/nys-verticalnavgroup.d.ts +24 -0
  80. package/dist/packages/nys-video/src/nys-video.d.ts +67 -7
  81. package/dist/src/index.d.ts +6 -2
  82. package/package.json +11 -6
  83. package/packages/react/NysAccordion.d.ts +10 -0
  84. package/packages/react/NysAccordion.js +2 -1
  85. package/packages/react/NysAccordionItem.d.ts +10 -0
  86. package/packages/react/NysAccordionItem.js +3 -1
  87. package/packages/react/NysAlert.d.ts +8 -10
  88. package/packages/react/NysAlert.js +0 -2
  89. package/packages/react/NysAvatar.d.ts +11 -1
  90. package/packages/react/NysBacktotop.d.ts +3 -0
  91. package/packages/react/NysBacktotop.js +2 -1
  92. package/packages/react/NysBreadcrumbs.d.ts +2 -2
  93. package/packages/react/NysButton.d.ts +38 -8
  94. package/packages/react/NysButton.js +6 -4
  95. package/packages/react/NysCard.d.ts +110 -0
  96. package/packages/react/NysCard.js +61 -0
  97. package/packages/react/NysCheckbox.d.ts +9 -0
  98. package/packages/react/NysCheckbox.js +4 -0
  99. package/packages/react/NysDropdownMenu.d.ts +4 -2
  100. package/packages/react/NysFileinput.d.ts +2 -2
  101. package/packages/react/NysGlobalFooter.d.ts +17 -0
  102. package/packages/react/NysGlobalFooter.js +10 -2
  103. package/packages/react/NysGlobalHeader.d.ts +17 -0
  104. package/packages/react/NysGlobalHeader.js +11 -2
  105. package/packages/react/NysIconlist.d.ts +54 -0
  106. package/packages/react/NysIconlist.js +22 -0
  107. package/packages/react/NysIconlistitem.d.ts +59 -0
  108. package/packages/react/NysIconlistitem.js +22 -0
  109. package/packages/react/NysLabel.d.ts +4 -1
  110. package/packages/react/NysModal.d.ts +8 -1
  111. package/packages/react/NysModal.js +11 -2
  112. package/packages/react/NysProcesslist.d.ts +65 -0
  113. package/packages/react/NysProcesslist.js +25 -0
  114. package/packages/react/NysProcesslistitem.d.ts +61 -0
  115. package/packages/react/NysProcesslistitem.js +35 -0
  116. package/packages/react/NysRadiobutton.d.ts +27 -3
  117. package/packages/react/NysRadiobutton.js +9 -1
  118. package/packages/react/NysSelect.d.ts +3 -0
  119. package/packages/react/NysSelect.js +2 -0
  120. package/packages/react/NysStepper.d.ts +1 -1
  121. package/packages/react/NysTabgroup.d.ts +5 -4
  122. package/packages/react/NysTable.d.ts +1 -1
  123. package/packages/react/NysTabpanel.d.ts +11 -4
  124. package/packages/react/NysTextarea.d.ts +4 -1
  125. package/packages/react/NysTextarea.js +2 -0
  126. package/packages/react/NysUnavFooter.d.ts +13 -0
  127. package/packages/react/NysUnavFooter.js +4 -1
  128. package/packages/react/NysUnavHeader.d.ts +24 -1
  129. package/packages/react/NysUnavHeader.js +17 -1
  130. package/packages/react/NysVerticalnav.d.ts +67 -0
  131. package/packages/react/NysVerticalnav.js +26 -0
  132. package/packages/react/NysVerticalnavGroup.d.ts +76 -0
  133. package/packages/react/NysVerticalnavGroup.js +43 -0
  134. package/packages/react/index.d.ts +7 -0
  135. package/packages/react/index.js +7 -0
  136. package/packages/react/nysds-jsx.d.ts +404 -46
@@ -1,4 +1,4 @@
1
1
  export * from "./nys-icon";
2
- export { registerIconLibrary, unregisterIconLibrary, } from "./icon-library-registry";
3
- export type { IconLibrary } from "./icon-library-registry";
2
+ export { registerIconLibrary, unregisterIconLibrary, getIconLibrary, } from "./icon-library-registry";
3
+ export type { IconLibrary, IconResolution } from "./icon-library-registry";
4
4
  export { clearIconCache } from "./icon-cache";
@@ -1,4 +1,4 @@
1
- import { LitElement } from "lit";
1
+ import { NysElement } from "@nysds/internals";
2
2
  import { NysIconWatcher } from "./icon-library-registry";
3
3
  /**
4
4
  * Renders SVG icons from a registered icon library. The built-in NYSDS icon
@@ -13,22 +13,99 @@ import { NysIconWatcher } from "./icon-library-registry";
13
13
  * @summary SVG icon with swappable library support, size, rotation, and color options.
14
14
  * @element nys-icon
15
15
  *
16
- * @example Basic icon (default NYSDS library)
16
+ * @example Basic
17
17
  * ```html
18
- * <nys-icon name="check_circle" size="lg"></nys-icon>
18
+ * <nys-icon name="check_circle"></nys-icon>
19
19
  * ```
20
20
  *
21
- * @example Font Awesome icon
21
+ * @example ARIA Label
22
22
  * ```html
23
- * <nys-icon name="house" library="fa" size="lg"></nys-icon>
23
+ * <nys-icon
24
+ * name="edit_square"
25
+ * ariaLabel="Edit content"
26
+ * ></nys-icon>
24
27
  * ```
25
28
  *
26
- * @example Accessible icon with label
29
+ * @example Size relative
27
30
  * ```html
28
- * <nys-icon name="warning" ariaLabel="Warning" color="var(--nys-color-warning)"></nys-icon>
31
+ * <nys-icon
32
+ * name="edit_square"
33
+ * size="4xl"
34
+ * ></nys-icon>
35
+ * ```
36
+ *
37
+ * @example Size literal
38
+ * ```html
39
+ * <nys-icon
40
+ * name="edit_square"
41
+ * size="24"
42
+ * ></nys-icon>
43
+ * ```
44
+ *
45
+ * @example Color
46
+ * ```html
47
+ * <nys-icon
48
+ * name="edit_square"
49
+ * color="#db117d"
50
+ * ></nys-icon>
51
+ * ```
52
+ *
53
+ * @example Rotate
54
+ * ```html
55
+ * <nys-icon
56
+ * name="edit_square"
57
+ * rotate="20"
58
+ * ></nys-icon>
59
+ * ```
60
+ *
61
+ * @example Flip
62
+ * ```html
63
+ * <nys-icon
64
+ * name="edit_square"
65
+ * flip="vertical"
66
+ * ></nys-icon>
67
+ * ```
68
+ *
69
+ * @example External Library - Font Awesome
70
+ * ```html
71
+ * <nys-icon name="heart" library="fa"></nys-icon>
72
+ * ```
73
+ *
74
+ * @render External Library - Font Awesome
75
+ * ```html
76
+ * <nys-icon name="heart" library="fa"></nys-icon>
77
+ * <script data-scope="module">
78
+ * registerIconLibrary("fa", {
79
+ * resolver: (name) =>
80
+ * `https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/svgs/solid/${name}.svg`,
81
+ * mutator: (svg) => {
82
+ * svg.setAttribute("fill", "currentColor");
83
+ * },
84
+ * });
85
+ * </script>
86
+ * ```
87
+ *
88
+ * @example External Library - Material
89
+ * ```html
90
+ * <nys-icon name="favorite" library="material"></nys-icon>
91
+ * ```
92
+ *
93
+ *
94
+ * @render External Library - Material
95
+ * ```html
96
+ * <nys-icon name="favorite" library="material"></nys-icon>
97
+ * <script data-scope="module">
98
+ * registerIconLibrary("material", {
99
+ * resolver: (name) =>
100
+ * `https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/${name}/default/24px.svg`,
101
+ * mutator: (svg) => {
102
+ * svg.setAttribute("fill", "currentColor");
103
+ * },
104
+ * });
105
+ * </script>
29
106
  * ```
30
107
  */
31
- export declare class NysIcon extends LitElement implements NysIconWatcher {
108
+ export declare class NysIcon extends NysElement implements NysIconWatcher {
32
109
  static styles: import("lit").CSSResult;
33
110
  /** Icon name to resolve from the selected library. Required. */
34
111
  name: string;
@@ -70,5 +147,18 @@ export declare class NysIcon extends LitElement implements NysIconWatcher {
70
147
  updated(changedProps: Map<string, unknown>): void;
71
148
  private _loadIcon;
72
149
  private _applyAttributes;
150
+ /**
151
+ * Reflects the icon's accessible state onto the host:
152
+ * - Labeled icon -> role="img" + aria-label, no aria-hidden.
153
+ * - Decorative -> aria-hidden="true", no role/label.
154
+ *
155
+ * These are reflected as host *attributes* (rather than via
156
+ * ElementInternals) on purpose: aria-hidden / role / aria-label in
157
+ * attribute form have universal, consistent assistive-technology support,
158
+ * whereas AT support for these states set through ElementInternals is still
159
+ * uneven across browser/screen-reader combinations. The host role/label
160
+ * therefore depend on runtime state (ariaLabel), so defaultRole stays null.
161
+ */
162
+ private _reflectHostSemantics;
73
163
  render(): import("lit-html").TemplateResult<1> | null;
74
164
  }
@@ -0,0 +1,2 @@
1
+ export * from "./nys-iconlist";
2
+ export * from "./nys-iconlistitem";
@@ -0,0 +1,92 @@
1
+ import { PropertyValues } from "lit";
2
+ import { NysElement } from "@nysds/internals";
3
+ import "./nys-iconlistitem";
4
+ /**
5
+ * An icon list is a component that displays a collection of items paired with visual icons, making it easy to create structured, scannable lists across web projects. Commonly used in the card component.
6
+ *
7
+ * Add `<nys-iconlistitem>` elements as children. Each item accepts an `icon` attribute and uses its
8
+ * default slot for the primary label. A second line can be added with `<span slot="secondary">`.
9
+ * Set `divider` to draw a rule between items; no divider is drawn after the last item.
10
+ *
11
+ * @summary A scannable list of icon + text items, with an optional divider between rows.
12
+ * @element nys-iconlist
13
+ *
14
+ * Children: one or more `<nys-iconlistitem>` elements, kept in light DOM so the
15
+ * `list`/`listitem` roles stay directly related in the accessibility tree. The
16
+ * host itself is the `role="list"` container and renders in the light DOM, so
17
+ * its styling comes from `nys-iconlist.light.scss` adopted once onto
18
+ * `document.adoptedStyleSheets` rather than from a shadow-DOM stylesheet.
19
+ *
20
+ * @example Basic
21
+ * ```html
22
+ * <nys-iconlist id="event-details">
23
+ * <nys-iconlistitem icon="calendar_month">July 4, 2026</nys-iconlistitem>
24
+ * <nys-iconlistitem icon="schedule">5:00</nys-iconlistitem>
25
+ * <nys-iconlistitem icon="location_on">Central Park West</nys-iconlistitem>
26
+ * </nys-iconlist>
27
+ * ```
28
+ *
29
+ * @example Accessible Name
30
+ * A list carries no accessible name of its own. Because the host renders in the light DOM,
31
+ * `aria-label` works natively with zero component code — set it directly when the surrounding
32
+ * content does not already make the list's purpose obvious.
33
+ * ```html
34
+ * <nys-iconlist id="event-details-labelled" aria-label="Event details">
35
+ * <nys-iconlistitem icon="calendar_month">July 4, 2026</nys-iconlistitem>
36
+ * <nys-iconlistitem icon="schedule">5:00</nys-iconlistitem>
37
+ * </nys-iconlist>
38
+ * ```
39
+ *
40
+ * @example Divider
41
+ * ```html
42
+ * <nys-iconlist id="event-details2" divider>
43
+ * <nys-iconlistitem icon="calendar_month">July 4, 2026</nys-iconlistitem>
44
+ * <nys-iconlistitem icon="schedule">5:00</nys-iconlistitem>
45
+ * <nys-iconlistitem icon="location_on">Central Park West</nys-iconlistitem>
46
+ * </nys-iconlist>
47
+ * ```
48
+ *
49
+ * @example Secondary label
50
+ * ```html
51
+ * <nys-iconlist id="event-details3">
52
+ * <nys-iconlistitem icon="calendar_month">July 4, 2026</nys-iconlistitem>
53
+ * <nys-iconlistitem icon="schedule">
54
+ * 5:00 PM
55
+ * <span slot="secondary">Eastern Standard Time</span>
56
+ * </nys-iconlistitem>
57
+ * <nys-iconlistitem icon="location_on">
58
+ * Central Park West
59
+ * <span slot="secondary">New York, NY</span>
60
+ * </nys-iconlistitem>
61
+ * </nys-iconlist>
62
+ * ```
63
+ *
64
+ * @example Checklist
65
+ * ```html
66
+ * <nys-iconlist id="requirements">
67
+ * <nys-iconlistitem icon="check_circle">Recent pay stubs</nys-iconlistitem>
68
+ * <nys-iconlistitem icon="check_circle">Current rent/mortgage statement</nys-iconlistitem>
69
+ * <nys-iconlistitem icon="check_circle">Current property tax bill</nys-iconlistitem>
70
+ * <nys-iconlistitem icon="check_circle">Current homeowner's insurance bill</nys-iconlistitem>
71
+ * <nys-iconlistitem icon="check_circle">Social Security card</nys-iconlistitem>
72
+ * </nys-iconlist>
73
+ * ```
74
+ */
75
+ export declare class NysIconlist extends NysElement {
76
+ /**
77
+ * Unique identifier. Auto-generated if not provided.
78
+ */
79
+ id: string;
80
+ /**
81
+ * Draws a divider between items. No divider is drawn after the last item.
82
+ * @default false
83
+ */
84
+ divider: boolean;
85
+ private _childObserver;
86
+ private _warnedChildren;
87
+ createRenderRoot(): this;
88
+ connectedCallback(): void;
89
+ disconnectedCallback(): void;
90
+ updated(changedProperties: PropertyValues<this>): void;
91
+ private _syncDividers;
92
+ }
@@ -0,0 +1,32 @@
1
+ import { NysElement } from "@nysds/internals";
2
+ import "@nysds/nys-icon";
3
+ /**
4
+ * A single item in a `<nys-iconlist>`. Renders as a list item containing an icon and one or two lines of text.
5
+ *
6
+ * The default slot holds the primary label. Use `<span slot="secondary">` for a second line of text;
7
+ * when present the icon aligns to the top rather than centering against the full block.
8
+ *
9
+ * @summary An icon-paired list item for use inside `<nys-iconlist>`.
10
+ * @element nys-iconlistitem
11
+ *
12
+ * @prop {string} icon - Material Symbols icon name passed to `<nys-icon>`.
13
+ *
14
+ * @slot - Primary label text.
15
+ * @slot secondary - Optional second line of text rendered below the primary label.
16
+ */
17
+ export declare class NysIconlistitem extends NysElement {
18
+ static styles: import("lit").CSSResult;
19
+ /**
20
+ * Material Symbols icon name displayed beside the label.
21
+ */
22
+ icon: string;
23
+ /**
24
+ * Draws a rule below the item. Set by the parent `<nys-iconlist divider>`; not intended to be
25
+ * set directly.
26
+ * @default false
27
+ */
28
+ divider: boolean;
29
+ connectedCallback(): void;
30
+ private _handleSecondarySlotChange;
31
+ render(): import("lit-html").TemplateResult<1>;
32
+ }
@@ -1,12 +1,44 @@
1
1
  import { LitElement } from "lit";
2
+ import "@nysds/nys-tooltip";
3
+ import "@nysds/nys-icon";
2
4
  /**
3
5
  * **Internal component.** Renders form labels with description, required/optional flag, and tooltip.
4
6
  *
5
7
  * Used internally by form components (textinput, select, checkbox, etc.). Not intended for direct use.
6
8
  * Handles label association via `for`, displays asterisk for required fields, and integrates tooltips.
7
9
  *
8
- * @summary Internal label component for form fields with flag and tooltip support.
9
- * @element nys-label
10
+ * @example Basic
11
+ * ```html
12
+ * <nys-label label="This is a basic nys-label"></nys-label>
13
+ * ```
14
+ *
15
+ * @example Required
16
+ * ```html
17
+ * <nys-label label="This form is required" flag="required"></nys-label>
18
+ * ```
19
+ *
20
+ * @example Optional
21
+ * ```html
22
+ * <nys-label label="This form is required" flag="optional"></nys-label>
23
+ * ```
24
+ *
25
+ * @example Description
26
+ * ```html
27
+ * <nys-label label="Label Text" description="Description text"></nys-label>
28
+ * ```
29
+ *
30
+ * @example Description Slot
31
+ * ```html
32
+ * <nys-label label="Label Text">
33
+ * <p slot="description">Rich text description passed in <strong>HERE</strong></p>
34
+ * </nys-label>
35
+ * ```
36
+ *
37
+ * @example With Tooltip
38
+ * ```html
39
+ * <nys-label id="label-id" label="This label has a tooltip"></nys-label>
40
+ * <nys-tooltip for="label-id" text="Tooltip text in here"></nys-tooltip>
41
+ * ```
10
42
  *
11
43
  * @slot description - Custom HTML description content below the label.
12
44
  */
@@ -24,7 +56,10 @@ export declare class NysLabel extends LitElement {
24
56
  inverted: boolean;
25
57
  /** Tooltip text shown on hover/focus of info icon next to label. */
26
58
  tooltip: string;
59
+ private _labelInternals;
60
+ get _hasDescription(): boolean;
27
61
  connectedCallback(): void;
62
+ updated(): void;
28
63
  /**
29
64
  * Event Handlers
30
65
  * --------------------------------------------------------------------------
@@ -1,4 +1,5 @@
1
- import { LitElement } from "lit";
1
+ import { NysElement } from "@nysds/internals";
2
+ import "@nysds/nys-button";
2
3
  /**
3
4
  * An accessible modal dialog with focus trapping, keyboard navigation, and scroll management.
4
5
  *
@@ -14,23 +15,158 @@ import { LitElement } from "lit";
14
15
  * @fires nys-open - Fired when modal opens. Detail: `{id}`.
15
16
  * @fires nys-close - Fired when modal closes. Detail: `{id}`.
16
17
  *
17
- * @example Basic modal
18
+ * @example Basic
18
19
  * ```html
19
- * <nys-modal id="confirm-modal" heading="Confirm action" open>
20
- * <p>Are you sure you want to proceed?</p>
20
+ * <nys-modal
21
+ * id="modal1"
22
+ * heading="Update Available"
23
+ * >
24
+ * <p>
25
+ * Would you like to install the latest version? Albany ipsum dolor sit
26
+ * Empire, Hudson consectetur Adirondack elit, sed do MetroCard tempor
27
+ * incididunt ut Capitol et Broadway magna Niagara. Ut enim ad Erie
28
+ * veniam, quis nostrud Catskill ullamco Bronx nisi ut LongIsland ex ea
29
+ * Cuomo consequat.
30
+ * </p>
31
+ * </nys-modal>
32
+ * ```
33
+ *
34
+ * @render Basic
35
+ * ```html
36
+ * <div id="modal-wrapper1">
37
+ * <nys-button label="Open Modal" onclick="document.querySelector('.modal1').open = true; document.getElementById('modal-wrapper1').style.padding = '100px 0'"></nys-button>
38
+ * <nys-modal
39
+ * class="modal1"
40
+ * id="modal1"
41
+ * heading="Update Available"
42
+ * >
43
+ * <p>
44
+ * Would you like to install the latest version? Albany ipsum dolor sit
45
+ * Empire, Hudson consectetur Adirondack elit, sed do MetroCard tempor
46
+ * incididunt ut Capitol et Broadway magna Niagara. Ut enim ad Erie
47
+ * veniam, quis nostrud Catskill ullamco Bronx nisi ut LongIsland ex ea
48
+ * Cuomo consequat.
49
+ * </p>
50
+ * </nys-modal>
51
+ * </div>
52
+ * ```
53
+ *
54
+ *
55
+ * @example Subheading
56
+ * ```html
57
+ * <nys-modal
58
+ * id="modal-subheading"
59
+ * heading="Before you continue"
60
+ * subheading="Your progress has been saved automatically."
61
+ * >
62
+ * <p>You can safely leave this page and return later to pick up where you left off.</p>
63
+ * </nys-modal>
64
+ * ```
65
+ *
66
+ * @render Subheading
67
+ * ```html
68
+ * <div id="modal-wrapper-subheading">
69
+ * <nys-button label="Open Modal" onclick="document.querySelector('.modal-subheading').open = true; document.getElementById('modal-wrapper-subheading').style.padding = '100px 0'"></nys-button>
70
+ * <nys-modal
71
+ * class="modal-subheading"
72
+ * id="modal-subheading"
73
+ * heading="Before you continue"
74
+ * subheading="Your progress has been saved automatically."
75
+ * >
76
+ * <p>You can safely leave this page and return later to pick up where you left off.</p>
77
+ * </nys-modal>
78
+ * </div>
79
+ * ```
80
+ *
81
+ * @example Actions Slot
82
+ * ```html
83
+ * <nys-modal id="modal3" heading="Update password?">
84
+ * <p>
85
+ * Would you like to install the latest version? Albany ipsum dolor sit
86
+ * Empire, Hudson consectetur Adirondack elit, sed do MetroCard tempor
87
+ * incididunt ut Capitol et Broadway magna Niagara. Ut enim ad Erie
88
+ * veniam, quis nostrud Catskill ullamco Bronx nisi ut LongIsland ex ea
89
+ * Cuomo consequat.
90
+ * </p>
21
91
  * <div slot="actions">
22
- * <nys-button label="Cancel" variant="outline"></nys-button>
23
- * <nys-button label="Confirm" variant="filled"></nys-button>
92
+ * <nys-button label="Not now" variant="outline"></nys-button>
93
+ * <nys-button label="Update"></nys-button>
24
94
  * </div>
25
95
  * </nys-modal>
26
96
  * ```
97
+ *
98
+ * @render Actions Slot
99
+ * ```html
100
+ * <div id="modal-wrapper3">
101
+ * <nys-button label="Open Modal" onclick="document.querySelector('.modal3').open = true; document.getElementById('modal-wrapper3').style.padding = '100px 0'"></nys-button>
102
+ * <nys-modal
103
+ * class="modal3"
104
+ * id="modal3"
105
+ * heading="Update password?"
106
+ * >
107
+ * <p>
108
+ * Would you like to install the latest version? Albany ipsum dolor sit
109
+ * Empire, Hudson consectetur Adirondack elit, sed do MetroCard tempor
110
+ * incididunt ut Capitol et Broadway magna Niagara. Ut enim ad Erie
111
+ * veniam, quis nostrud Catskill ullamco Bronx nisi ut LongIsland ex ea
112
+ * Cuomo consequat.
113
+ * </p>
114
+ * <div slot="actions">
115
+ * <nys-button label="Not now" variant="outline" onclick="document.querySelector('.modal3').open = false; document.getElementById('modal-wrapper3').style.padding = '0'"></nys-button>
116
+ * <nys-button label="Update" onclick="alert('Mock Alert: Changes saved!'); document.querySelector('.modal3').open = false; document.getElementById('modal-wrapper3').style.padding = '0'"></nys-button>
117
+ * </div>
118
+ * </nys-modal>
119
+ * </div>
120
+ * ```
121
+ *
122
+ * @example Mandatory Action
123
+ * ```html
124
+ * <nys-modal
125
+ * id="modal4"
126
+ * heading="There is no way to X out of here"
127
+ * subheading="Don't use this prop unless you add in the actions slot so the user does not get stuck in here."
128
+ * mandatory
129
+ * >
130
+ * <div slot="actions">
131
+ * <nys-button label="Get me out"></nys-button>
132
+ * </div>
133
+ * </nys-modal>
134
+ * ```
135
+ *
136
+ * @render Mandatory Action
137
+ * ```html
138
+ * <div id="modal-wrapper4">
139
+ * <nys-button label="Open Modal" onclick="document.querySelector('.modal4').open = true; document.getElementById('modal-wrapper4').style.padding = '100px 0'"></nys-button>
140
+ * <nys-modal
141
+ * class="modal4"
142
+ * id="modal4"
143
+ * heading="There is no way to X out of here"
144
+ * subheading="Don't use this prop unless you add in the actions slot so the user does not get stuck in here."
145
+ * mandatory
146
+ * >
147
+ * <div slot="actions">
148
+ * <nys-button label="Get me out" onclick="alert('Ok, ok. You can go now.'); document.querySelector('.modal4').open = false; document.getElementById('modal-wrapper4').style.padding = '0'"></nys-button>
149
+ * </div>
150
+ * </nys-modal>
151
+ * </div>
152
+ * ```
27
153
  */
28
- export declare class NysModal extends LitElement {
154
+ export declare class NysModal extends NysElement {
29
155
  static styles: import("lit").CSSResult;
30
156
  /** Unique identifier. Auto-generated if not provided. */
31
157
  id: string;
32
- /** Modal heading text. Required for accessibility. */
158
+ /**
159
+ * Modal heading text. Required for accessibility — it becomes the dialog's
160
+ * accessible name via `aria-labelledby`.
161
+ */
33
162
  heading: string;
163
+ /**
164
+ * Accessible name for the dialog, used only when no `heading` is set.
165
+ * Prefer a visible `heading`: a visible label satisfies WCAG 2.5.3 (Label in
166
+ * Name) and gives sighted users the same information. Use `ariaLabel` for the
167
+ * rare headless dialog so it still exposes a name (WCAG 4.1.2).
168
+ */
169
+ ariaLabel: string;
34
170
  /** Secondary heading below the main heading. */
35
171
  subheading: string;
36
172
  /** Controls modal visibility. Set to `true` to show. */
@@ -53,6 +189,7 @@ export declare class NysModal extends LitElement {
53
189
  * --------------------------------------------------------------------------
54
190
  */
55
191
  constructor();
192
+ private _boundHandleKeydown;
56
193
  connectedCallback(): void;
57
194
  disconnectedCallback(): void;
58
195
  updated(changeProps: Map<string, any>): Promise<void>;
@@ -71,11 +208,6 @@ export declare class NysModal extends LitElement {
71
208
  private _dispatchOpenEvent;
72
209
  private _dispatchCloseEvent;
73
210
  private _getAriaDescribedBy;
74
- /**
75
- * This exist to prevent the VO for dismiss button from announcing itself between the heading & subheading/slot content.
76
- * We add the "Close this window" ariaLabel after the initial VO is done
77
- */
78
- private _updateDismissAria;
79
211
  /**
80
212
  * Event Handlers
81
213
  * --------------------------------------------------------------------------
@@ -1,21 +1,43 @@
1
- import { LitElement, TemplateResult } from "lit";
1
+ import { TemplateResult } from "lit";
2
+ import { NysElement } from "@nysds/internals";
3
+ import "@nysds/nys-button";
2
4
  /**
3
5
  * Page navigation with Previous/Next buttons and numbered page links. Auto-collapses with ellipses for many pages.
4
6
  *
5
7
  * Set `totalPages` and `currentPage` to control state. Listen to `nys-change` for page selection.
6
8
  * Hidden automatically when `totalPages` is 1. Responsive: shows compact controls on mobile.
7
9
  *
10
+ * ## Accessibility
11
+ * - The controls sit in a `navigation` landmark named "Pagination".
12
+ * - The current page's button carries `aria-current="page"` so assistive technology
13
+ * announces which page the user is on.
14
+ * - Keyboard focus follows the user across a page change: it stays on the page they
15
+ * activated, and moves to the current page's button when Previous or Next disables
16
+ * itself on the first or last page rather than falling back to the document.
17
+ * - The ellipsis between non-adjacent page numbers is inert text, not a control, and is
18
+ * hidden from assistive technology.
19
+ *
8
20
  * @summary Page navigation with numbered links, prev/next buttons, and responsive layout.
9
21
  * @element nys-pagination
10
22
  *
11
23
  * @fires nys-change - Fired when page changes. Detail: `{page}`.
12
24
  *
13
- * @example Basic pagination
25
+ * @example Basic
26
+ * ```html
27
+ * <nys-pagination currentPage="5" totalPages="10"></nys-pagination>
28
+ * ```
29
+ *
30
+ * @example First Page
14
31
  * ```html
15
32
  * <nys-pagination currentPage="1" totalPages="10"></nys-pagination>
16
33
  * ```
34
+ *
35
+ * @example Last Page
36
+ * ```html
37
+ * <nys-pagination currentPage="10" totalPages="10"></nys-pagination>
38
+ * ```
17
39
  */
18
- export declare class NysPagination extends LitElement {
40
+ export declare class NysPagination extends NysElement {
19
41
  static styles: import("lit").CSSResult;
20
42
  /** Unique identifier. Auto-generated if not provided. */
21
43
  id: string;
@@ -27,18 +49,60 @@ export declare class NysPagination extends LitElement {
27
49
  totalPages: number;
28
50
  /** Internal state for layout adjustments near the end. */
29
51
  _twoBeforeLast: boolean;
52
+ /**
53
+ * Logical identity of the control that held focus when this update was scheduled,
54
+ * captured before the re-render that invalidates it. Null whenever focus was outside
55
+ * the component, which is what keeps a programmatic page change from stealing focus.
56
+ */
57
+ private _focusKeyBeforeUpdate;
58
+ /** Guards against an older, still-pending focus restore overriding a newer one. */
59
+ private _focusRestoreToken;
30
60
  /**
31
61
  * Lifecycle Methods
32
62
  * --------------------------------------------------------------------------
33
63
  */
34
64
  constructor();
35
65
  willUpdate(changedProps: Map<string, unknown>): void;
66
+ updated(): void;
36
67
  connectedCallback(): void;
37
68
  /**
38
69
  * Functions
39
70
  * --------------------------------------------------------------------------
40
71
  */
41
72
  private _clampPage;
73
+ /**
74
+ * Stable identity for a control in the shadow root, one that survives a re-render.
75
+ *
76
+ * DOM position is not that identity: the window of visible page numbers slides as the
77
+ * user pages through, and Lit reuses the element sitting at a given position, so the
78
+ * button under the user's focus silently starts navigating to a different page. Page
79
+ * buttons are therefore identified by the page they navigate to, and the fixed
80
+ * Previous/Next controls by their id.
81
+ */
82
+ private _focusKeyOf;
83
+ /** Resolve a focus key back to the control that now carries that identity. */
84
+ private _controlForKey;
85
+ /**
86
+ * A control has to be both enabled and rendered to take focus. `getClientRects()`
87
+ * covers the responsive rules that swap the desktop Previous/Next for their
88
+ * icon-only mobile twins, and hide the page neighbors on narrow screens.
89
+ */
90
+ private _isFocusable;
91
+ /**
92
+ * Where focus goes when the control the user was on is gone or has just been
93
+ * disabled: the current page's button. It is always rendered, it is never disabled,
94
+ * and it announces the page the user just landed on.
95
+ */
96
+ private _fallbackFocusTarget;
97
+ /**
98
+ * Keep keyboard focus on the control the user was operating.
99
+ *
100
+ * Two things pull focus out from under them otherwise. Reaching the first or last page
101
+ * disables Previous/Next while it still holds focus, which drops focus to `<body>` and
102
+ * ends the keyboard journey. And activating a page slides the window of page numbers,
103
+ * so the button that keeps focus by DOM position is now a different, non-current page.
104
+ */
105
+ private _restoreFocus;
42
106
  private renderPageButtons;
43
107
  /**
44
108
  * Event Handlers
@@ -0,0 +1,2 @@
1
+ export * from "./nys-processlist";
2
+ export * from "./nys-processlistitem";