@nysds/components 1.20.0-alpha1 → 1.20.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.
Files changed (135) hide show
  1. package/custom-elements.json +7119 -3701
  2. package/dist/.vscode/vscode.css-custom-data.json +5 -0
  3. package/dist/.vscode/vscode.html-custom-data.json +317 -38
  4. package/dist/custom-elements.json +7119 -3701
  5. package/dist/nys-icon.library-Cfdq5Zdc.js +696 -0
  6. package/dist/nys-icon.library-Cfdq5Zdc.js.map +1 -0
  7. package/dist/nys-icon.library-DHBltclg-BYYeCcpo.js +706 -0
  8. package/dist/nys-icon.library-DHBltclg-BYYeCcpo.js.map +1 -0
  9. package/dist/nysds.es.js +9113 -4162
  10. package/dist/nysds.es.js.map +1 -1
  11. package/dist/nysds.js +2413 -492
  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 +37 -12
  33. package/dist/packages/nys-checkbox/src/nys-checkboxgroup.d.ts +84 -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 +129 -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 +197 -7
  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 +219 -10
  76. package/dist/packages/nys-verticalnav/src/nys-verticalnav.d.ts +421 -37
  77. package/dist/packages/nys-verticalnav/src/nys-verticalnavgroup.d.ts +4 -54
  78. package/dist/packages/nys-video/src/nys-video.d.ts +67 -7
  79. package/dist/src/index.d.ts +5 -2
  80. package/package.json +14 -6
  81. package/packages/react/NysAccordion.d.ts +10 -0
  82. package/packages/react/NysAccordion.js +2 -1
  83. package/packages/react/NysAccordionItem.d.ts +10 -0
  84. package/packages/react/NysAccordionItem.js +3 -1
  85. package/packages/react/NysAlert.d.ts +8 -10
  86. package/packages/react/NysAlert.js +0 -2
  87. package/packages/react/NysAvatar.d.ts +11 -1
  88. package/packages/react/NysBacktotop.d.ts +3 -0
  89. package/packages/react/NysBacktotop.js +2 -1
  90. package/packages/react/NysBreadcrumbs.d.ts +2 -2
  91. package/packages/react/NysButton.d.ts +38 -8
  92. package/packages/react/NysButton.js +6 -4
  93. package/packages/react/NysCard.d.ts +110 -0
  94. package/packages/react/NysCard.js +61 -0
  95. package/packages/react/NysCheckbox.d.ts +9 -0
  96. package/packages/react/NysCheckbox.js +4 -0
  97. package/packages/react/NysDropdownMenu.d.ts +4 -2
  98. package/packages/react/NysFileinput.d.ts +25 -3
  99. package/packages/react/NysFileinput.js +8 -1
  100. package/packages/react/NysGlobalFooter.d.ts +17 -0
  101. package/packages/react/NysGlobalFooter.js +10 -2
  102. package/packages/react/NysGlobalHeader.d.ts +23 -1
  103. package/packages/react/NysGlobalHeader.js +11 -2
  104. package/packages/react/NysIconlist.d.ts +54 -0
  105. package/packages/react/NysIconlist.js +22 -0
  106. package/packages/react/NysIconlistitem.d.ts +59 -0
  107. package/packages/react/NysIconlistitem.js +22 -0
  108. package/packages/react/NysLabel.d.ts +4 -1
  109. package/packages/react/NysModal.d.ts +8 -1
  110. package/packages/react/NysModal.js +11 -2
  111. package/packages/react/NysProcesslist.d.ts +65 -0
  112. package/packages/react/NysProcesslist.js +25 -0
  113. package/packages/react/NysProcesslistitem.d.ts +61 -0
  114. package/packages/react/NysProcesslistitem.js +35 -0
  115. package/packages/react/NysRadiobutton.d.ts +27 -3
  116. package/packages/react/NysRadiobutton.js +9 -1
  117. package/packages/react/NysSelect.d.ts +3 -0
  118. package/packages/react/NysSelect.js +2 -0
  119. package/packages/react/NysStepper.d.ts +1 -1
  120. package/packages/react/NysTabgroup.d.ts +5 -4
  121. package/packages/react/NysTable.d.ts +1 -1
  122. package/packages/react/NysTabpanel.d.ts +11 -4
  123. package/packages/react/NysTextarea.d.ts +4 -1
  124. package/packages/react/NysTextarea.js +2 -0
  125. package/packages/react/NysUnavFooter.d.ts +13 -0
  126. package/packages/react/NysUnavFooter.js +4 -1
  127. package/packages/react/NysUnavHeader.d.ts +24 -1
  128. package/packages/react/NysUnavHeader.js +17 -1
  129. package/packages/react/NysVerticalnav.d.ts +15 -8
  130. package/packages/react/NysVerticalnav.js +6 -4
  131. package/packages/react/NysVerticalnavGroup.d.ts +4 -0
  132. package/packages/react/NysVerticalnavGroup.js +5 -0
  133. package/packages/react/index.d.ts +5 -0
  134. package/packages/react/index.js +5 -0
  135. package/packages/react/nysds-jsx.d.ts +394 -56
@@ -1,4 +1,22 @@
1
- import { LitElement } from "lit";
1
+ import { type PropertyValues } from "lit";
2
+ import { NysElement } from "@nysds/internals";
3
+ import "@nysds/nys-button";
4
+ import "@nysds/nys-icon";
5
+ import "@nysds/nys-textinput";
6
+ import "@nysds/nys-alert";
7
+ interface Language {
8
+ code: string;
9
+ label: string;
10
+ url?: string;
11
+ }
12
+ /**
13
+ * Statewide alert endpoint, read once per page load. Sites don't opt in or out and
14
+ * never author the content, so an alert reads identically everywhere it appears.
15
+ *
16
+ * Production is https://alerts-cta.static-assets.ny.gov/alerts.json.
17
+ * For dev testing use: https://alerts-cta-dev.static-assets.ny.gov/alerts.json
18
+ */
19
+ export declare const NYS_ALERT_URL = "https://alerts-cta.static-assets.ny.gov/alerts.json";
2
20
  /**
3
21
  * Universal NYS header with trust bar, logo, search, and language translation. Required on all NYS sites.
4
22
  *
@@ -6,26 +24,87 @@ import { LitElement } from "lit";
6
24
  * site search (searches ny.gov), and 14-language translation dropdown. Use `hideSearch` or `hideTranslate`
7
25
  * to remove features if not applicable.
8
26
  *
27
+ * @accessibility
28
+ * - Semantic `<header>` element ensures assistive technology recognition.
29
+ * - Trust bar button: `role="button"`, `aria-expanded`, descriptive `aria-label`.
30
+ * - All links and buttons are keyboard-navigable via Tab.
31
+ * - Translate control: the WAI-ARIA APG menu button pattern. A real button carries
32
+ * `aria-expanded`, `aria-haspopup="menu"`, and `aria-controls` pointing at a
33
+ * `role="menu"` list of `role="menuitem"` options. The menu is display-hidden when
34
+ * closed, so its options only enter the tab order once it opens.
35
+ * - Translate keyboard model: Down/Up on the trigger open the menu on its first/last
36
+ * option; inside the menu Down/Up step and wrap, Home/End jump to either end,
37
+ * Enter/Space pick an option, and Escape closes the menu and returns focus to the
38
+ * trigger. A roving tabindex keeps the open menu to a single tab stop.
39
+ * - Each language option carries the BCP 47 `lang` of the language it names, so its
40
+ * label is announced in that language rather than the page's.
41
+ * - Search input announces field purpose and keyboard shortcuts (Enter to submit, Escape to dismiss).
42
+ * - Visual focus indicators meet WCAG 2.2 AA standards.
43
+ * - All text has sufficient color contrast (4.5:1 minimum).
44
+ * - Icons have text labels or `aria-label` attributes.
45
+ *
9
46
  * @summary Universal NYS header with trust bar, search, and translation. Required site-wide.
10
47
  * @element nys-unavheader
11
48
  *
12
- * @example Standard usage
49
+ * @remarks Statewide alerts are not configurable. On load the header reads the statewide
50
+ * alert endpoint and renders whatever is currently published, so an emergency message
51
+ * reaches every NYS site with no per-site work. If the endpoint is unreachable or nothing
52
+ * is published, the header renders normally. It takes no children.
53
+ *
54
+ * @fires nys-language-select - Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Smartling redirect.
55
+ * @fires nys-search-submit - Fired when a search is submitted. Detail: `{query}`. Cancelable; `preventDefault()` overrides the default search redirect.
56
+ *
57
+ * @example Basic
13
58
  * ```html
14
59
  * <nys-unavheader></nys-unavheader>
15
- * <nys-globalheader>...</nys-globalheader>
16
60
  * ```
17
61
  *
18
- * @example Without search
62
+ * @example Hide search
19
63
  * ```html
20
64
  * <nys-unavheader hideSearch></nys-unavheader>
21
65
  * ```
66
+ *
67
+ * @example Hide translate
68
+ * ```html
69
+ * <nys-unavheader hideTranslate></nys-unavheader>
70
+ * ```
71
+ *
72
+ * @example Custom landmark label
73
+ * ```html
74
+ * <!-- Renames the banner landmark. Keep it distinct from the agency header's. -->
75
+ * <nys-unavheader landmarkLabel="Statewide"></nys-unavheader>
76
+ * ```
77
+ *
78
+ * @example Custom Search URL
79
+ * ```html
80
+ * <nys-unavheader searchUrl="https://designsystem.ny.gov/search/?q="></nys-unavheader>
81
+ * ```
82
+ *
83
+ * @example Custom Language List
84
+ * ```html
85
+ * <nys-unavheader id="my-header"></nys-unavheader>
86
+ * <script>
87
+ * const header = document.querySelector('#my-header');
88
+ * header.languages = [
89
+ * { code: 'en', label: 'English' },
90
+ * { code: 'es', label: 'Español' , url: '"https://ny.gov/?lang=es"'},
91
+ * { code: 'fr', label: 'Français', url: '"https://ny.gov/?lang=fr"'},
92
+ * ];
93
+ * </script>
94
+ * ```
95
+ *
96
+ * @example Custom Language List JS
97
+ * ```html
98
+ * <nys-unavheader id="my-header2"></nys-unavheader>
99
+ * <script>
100
+ * document.querySelector('#my-header2').addEventListener('nys-language-select', (event) => {
101
+ * event.preventDefault();
102
+ * const selectedLanguage = event.detail.language.label;
103
+ * });
104
+ * </script>
105
+ * ```
22
106
  */
23
- interface Language {
24
- code: string;
25
- label: string;
26
- url?: string;
27
- }
28
- export declare class NysUnavHeader extends LitElement {
107
+ export declare class NysUnavHeader extends NysElement {
29
108
  static styles: import("lit").CSSResult;
30
109
  /** Internal: Whether trust bar panel is expanded. */
31
110
  trustbarVisible: boolean;
@@ -41,28 +120,158 @@ export declare class NysUnavHeader extends LitElement {
41
120
  hideSearch: boolean;
42
121
  /** The URL endpoint of the search, make sure to include the query param. */
43
122
  searchUrl: string;
123
+ /**
124
+ * Accessible name for the `banner` landmark this header renders.
125
+ * Defaults to `"New York State"`.
126
+ *
127
+ * A page pairing this header with `nys-globalheader` carries two `banner`
128
+ * landmarks; distinct names are what keep landmark navigation useful instead of
129
+ * announcing "banner, banner". Override only when your wording is clearer for
130
+ * your audience — and keep it distinct from the agency header's name, which
131
+ * comes from that header's visible title.
132
+ *
133
+ * A blank value falls back to the default rather than leaving the landmark
134
+ * unnamed.
135
+ *
136
+ * @default "New York State"
137
+ */
138
+ landmarkLabel: string;
44
139
  /** The list of languages this site can be translated to, default to use Smartling */
45
140
  languages: Language[];
46
141
  /**
47
142
  * Lifecycle Methods
48
143
  * --------------------------------------------------------------------------
144
+ * connectedCallback is inherited from NysElement, which assigns an
145
+ * auto-generated host id (prefix "nys-unavheader") when none is provided. The
146
+ * banner landmark intentionally lives on the inner <header> element, so this
147
+ * component keeps defaultRole = null and does not move a role onto the host.
49
148
  */
50
149
  connectedCallback(): void;
51
150
  disconnectedCallback(): void;
151
+ protected updated(changed: PropertyValues): void;
52
152
  /**
53
153
  * Functions
54
154
  * --------------------------------------------------------------------------
55
155
  */
56
156
  private _getNysLogo;
57
157
  private _toggleTrustbar;
158
+ /**
159
+ * The translate menu — WAI-ARIA APG "Menu Button"
160
+ * --------------------------------------------------------------------------
161
+ * The options are actions, not links: picking one fires a cancelable
162
+ * `nys-language-select` and, unless the page handles it, redirects. That, plus a
163
+ * trigger already declaring `aria-haspopup`/`aria-expanded`/`aria-controls`, makes
164
+ * this a menu button rather than a disclosure navigation menu — and it is the same
165
+ * shape `nys-dropdownmenu` uses, so #1412's eventual move onto that component
166
+ * won't change a single ARIA attribute.
167
+ *
168
+ * Focus moves by roving tabindex, not `aria-activedescendant`. Each option's
169
+ * `role="menuitem"` sits on the real `<button>` inside a `nys-button`'s shadow
170
+ * root, and `aria-activedescendant` is an IDREF — it cannot reach across a shadow
171
+ * boundary.
172
+ */
173
+ /** Which translate trigger opened the menu, so Escape can return focus to it. */
174
+ private _translateTrigger;
175
+ /** Index of the option holding the menu's single tab stop. */
176
+ private _activeOption;
177
+ /**
178
+ * Where focus lands when the menu opens, set only by a keyboard activation. A
179
+ * mouse open leaves focus on the trigger: moving it would put a focus ring on an
180
+ * option the pointer user never asked for.
181
+ */
182
+ private _openWithFocus;
58
183
  private _toggleLanguageList;
184
+ /**
185
+ * Closes the menu and puts focus back on the trigger. The open list is the only
186
+ * thing keeping the language buttons focusable, so closing it while focus sits on
187
+ * one would drop focus to the top of the page (WCAG 2.4.3).
188
+ */
189
+ private _closeLanguageList;
190
+ /**
191
+ * `nys-button` renders the real `<button>` inside its own shadow root, so an
192
+ * `aria-expanded` written on the host never reaches the element that carries the
193
+ * button role — assistive tech was never told the translate menu collapses. Mirror
194
+ * the state onto the inner control, the same way `nys-dropdownmenu` does for its
195
+ * trigger (WCAG 4.1.2).
196
+ */
197
+ private _syncTranslateTriggerAria;
198
+ /** The language options, in the order they are rendered. */
199
+ private _languageOptions;
200
+ /**
201
+ * Menu semantics for the options, and the same shadow-root problem as the trigger:
202
+ * `role="menuitem"` and the tab stop have to land on the real `<button>`, not on
203
+ * the `nys-button` host. The hosts carry `role="presentation"` in the template so
204
+ * they don't sit between the menu and its items in the accessibility tree.
205
+ */
206
+ private _syncLanguageMenuAria;
207
+ /**
208
+ * Moves both focus and the tab stop to an option, wrapping at either end. Index
209
+ * -1 is the last option, so "previous from the first" and "End" are the same call.
210
+ */
211
+ private _focusOption;
59
212
  private _toggleSearchDropdown;
60
213
  private _handleLanguageSelect;
214
+ /**
215
+ * Keyboard model for the translate menu (APG menu button):
216
+ * - on the trigger: Down/Up open the menu on its first/last option, Enter/Space
217
+ * open it on the first option, Escape closes it
218
+ * - in the menu: Down/Up step and wrap, Home/End jump to either end, Enter/Space
219
+ * pick the option (native `<button>` activation), Escape closes the menu and
220
+ * returns focus to the trigger
221
+ *
222
+ * Type-ahead is deliberately left out. Each label is written in its own script, so
223
+ * matching typed characters would mean transliteration plus an IME to be usable —
224
+ * "e" finds nothing in "Español" for anyone who would need it. The pattern lists
225
+ * type-ahead as optional.
226
+ */
227
+ private _handleTranslateKeydown;
228
+ private _handleTriggerKeydown;
229
+ private _handleOptionKeydown;
230
+ /**
231
+ * Focus leaving the menu closes it — that is what Tab and Shift+Tab do under the
232
+ * menu button pattern, and it also covers clicking away. Closing without touching
233
+ * focus is the point here: the browser is already moving it somewhere else.
234
+ */
235
+ private _handleTranslateFocusout;
61
236
  private _handleSearchFocus;
62
237
  private _handleSearchBlur;
63
238
  private _handleSearchKeyup;
64
239
  private _handleSearchButton;
65
240
  private _handleSearch;
241
+ /**
242
+ * Statewide alerts
243
+ * --------------------------------------------------------------------------
244
+ * Content comes from the alert feed, never from the consuming page, so the same
245
+ * message renders identically everywhere it is shown. A missing, malformed, or
246
+ * unreachable feed leaves the header untouched — an alert failing to load must
247
+ * never take a site's navigation down with it.
248
+ */
249
+ /** The published alerts, in feed order. Empty when nothing is published. */
250
+ private _alerts;
251
+ /** In-flight feed request, aborted if the header leaves the page first. */
252
+ private _alertRequest;
253
+ private _loadAlerts;
254
+ /** Fetches the alert feed. Resolves to null on any failure. */
255
+ private _readFeed;
256
+ /** Feed severity → `nys-alert` type. */
257
+ private _alertType;
258
+ /**
259
+ * Feed icon name → `nys-icon` name. Unknown names resolve to "", which leaves
260
+ * `nys-alert` to draw the default icon for the alert's type.
261
+ */
262
+ private _alertIcon;
263
+ /**
264
+ * One full-bleed band per published alert, so alerts of different severities keep
265
+ * their own background instead of sharing one. The body is slotted rather than
266
+ * passed as `text`/`primaryAction` so the link can carry the feed's `linkAriaLabel`.
267
+ */
268
+ private _renderAlerts;
269
+ private _renderAlert;
270
+ /**
271
+ * The banner's accessible name. A blank override would put the page back where
272
+ * #1795 found it — two unnamed banners — so it falls back to the default.
273
+ */
274
+ private get _landmarkLabel();
66
275
  render(): import("lit-html").TemplateResult<1>;
67
276
  }
68
277
  export {};