@nysds/components 1.18.1 → 1.19.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 (122) hide show
  1. package/custom-elements.json +799 -372
  2. package/dist/.vscode/vscode.html-custom-data.json +29 -24
  3. package/dist/custom-elements.json +799 -372
  4. package/dist/icons/ac_unit.svg +8 -0
  5. package/dist/icons/account_balance_filled.svg +8 -0
  6. package/dist/icons/account_circle.svg +8 -0
  7. package/dist/icons/add.svg +8 -0
  8. package/dist/icons/air.svg +8 -0
  9. package/dist/icons/arrow_back.svg +8 -0
  10. package/dist/icons/arrow_downward.svg +8 -0
  11. package/dist/icons/arrow_forward.svg +8 -0
  12. package/dist/icons/arrow_upward.svg +8 -0
  13. package/dist/icons/attach_file.svg +8 -0
  14. package/dist/icons/calendar_month.svg +8 -0
  15. package/dist/icons/cancel.svg +8 -0
  16. package/dist/icons/cancel_filled.svg +8 -0
  17. package/dist/icons/check.svg +8 -0
  18. package/dist/icons/check_circle.svg +8 -0
  19. package/dist/icons/chevron_down.svg +8 -0
  20. package/dist/icons/chevron_left.svg +8 -0
  21. package/dist/icons/chevron_right.svg +8 -0
  22. package/dist/icons/chevron_up.svg +8 -0
  23. package/dist/icons/clear_day.svg +8 -0
  24. package/dist/icons/close.svg +8 -0
  25. package/dist/icons/code.svg +8 -0
  26. package/dist/icons/content_copy.svg +8 -0
  27. package/dist/icons/coronavirus.svg +8 -0
  28. package/dist/icons/delete.svg +8 -0
  29. package/dist/icons/download.svg +8 -0
  30. package/dist/icons/download_done.svg +8 -0
  31. package/dist/icons/drive_folder_upload.svg +8 -0
  32. package/dist/icons/edit_square.svg +8 -0
  33. package/dist/icons/emergency_home.svg +8 -0
  34. package/dist/icons/error.svg +8 -0
  35. package/dist/icons/expand_all.svg +8 -0
  36. package/dist/icons/filter_alt.svg +8 -0
  37. package/dist/icons/filter_list.svg +8 -0
  38. package/dist/icons/height.svg +8 -0
  39. package/dist/icons/help.svg +8 -0
  40. package/dist/icons/info.svg +8 -0
  41. package/dist/icons/language.svg +8 -0
  42. package/dist/icons/language_filled.svg +8 -0
  43. package/dist/icons/link.svg +8 -0
  44. package/dist/icons/lock_filled.svg +8 -0
  45. package/dist/icons/mail.svg +8 -0
  46. package/dist/icons/manifest.json +84 -0
  47. package/dist/icons/menu.svg +8 -0
  48. package/dist/icons/more_vert.svg +8 -0
  49. package/dist/icons/notifications.svg +8 -0
  50. package/dist/icons/open_in_new.svg +8 -0
  51. package/dist/icons/phone_in_talk.svg +8 -0
  52. package/dist/icons/print.svg +8 -0
  53. package/dist/icons/progress_activity.svg +8 -0
  54. package/dist/icons/publish.svg +8 -0
  55. package/dist/icons/rainy.svg +8 -0
  56. package/dist/icons/refresh.svg +8 -0
  57. package/dist/icons/remove.svg +8 -0
  58. package/dist/icons/search.svg +8 -0
  59. package/dist/icons/share.svg +8 -0
  60. package/dist/icons/sms.svg +8 -0
  61. package/dist/icons/social_bluesky.svg +8 -0
  62. package/dist/icons/social_facebook.svg +8 -0
  63. package/dist/icons/social_flickr.svg +8 -0
  64. package/dist/icons/social_google_play.svg +8 -0
  65. package/dist/icons/social_instagram.svg +10 -0
  66. package/dist/icons/social_linkedin.svg +8 -0
  67. package/dist/icons/social_pinterest.svg +8 -0
  68. package/dist/icons/social_rss.svg +10 -0
  69. package/dist/icons/social_snapchat.svg +8 -0
  70. package/dist/icons/social_soundcloud.svg +21 -0
  71. package/dist/icons/social_threads.svg +9 -0
  72. package/dist/icons/social_tiktok.svg +8 -0
  73. package/dist/icons/social_tumblr.svg +8 -0
  74. package/dist/icons/social_vimeo.svg +8 -0
  75. package/dist/icons/social_x.svg +8 -0
  76. package/dist/icons/social_youtube.svg +8 -0
  77. package/dist/icons/sort.svg +8 -0
  78. package/dist/icons/straight.svg +8 -0
  79. package/dist/icons/thumb_down.svg +8 -0
  80. package/dist/icons/thumb_up.svg +8 -0
  81. package/dist/icons/upload_file.svg +8 -0
  82. package/dist/icons/visibility.svg +8 -0
  83. package/dist/icons/visibility_off.svg +8 -0
  84. package/dist/icons/warning.svg +8 -0
  85. package/dist/nysds.es.js +3762 -3630
  86. package/dist/nysds.es.js.map +1 -1
  87. package/dist/nysds.js +342 -865
  88. package/dist/nysds.js.map +1 -1
  89. package/dist/packages/mcp-server/src/lib/token-parser.d.ts +19 -31
  90. package/dist/packages/mcp-server/src/tools/token-tools.d.ts +2 -3
  91. package/dist/packages/nys-avatar/src/nys-avatar.d.ts +2 -0
  92. package/dist/packages/nys-backtotop/src/nys-backtotop.d.ts +3 -3
  93. package/dist/packages/nys-button/src/nys-button.d.ts +5 -0
  94. package/dist/packages/nys-checkbox/src/nys-checkbox.d.ts +2 -1
  95. package/dist/packages/nys-divider/src/nys-divider.d.ts +2 -0
  96. package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenu.d.ts +1 -1
  97. package/dist/packages/nys-globalheader/src/nys-globalheader.d.ts +3 -0
  98. package/dist/packages/nys-icon/src/icon-cache.d.ts +11 -0
  99. package/dist/packages/nys-icon/src/icon-library-registry.d.ts +47 -0
  100. package/dist/packages/nys-icon/src/index.d.ts +3 -0
  101. package/dist/packages/nys-icon/src/nys-icon.d.ts +40 -11
  102. package/dist/packages/nys-modal/src/nys-modal.d.ts +1 -0
  103. package/dist/packages/nys-radiobutton/src/nys-radiobutton.d.ts +1 -38
  104. package/dist/packages/nys-radiobutton/src/nys-radiogroup.d.ts +17 -7
  105. package/dist/packages/nys-stepper/src/nys-step.d.ts +75 -23
  106. package/dist/packages/nys-stepper/src/nys-stepper.d.ts +81 -9
  107. package/dist/packages/nys-tab/src/nys-tabgroup.d.ts +1 -0
  108. package/dist/packages/nys-tooltip/src/nys-tooltip.d.ts +1 -0
  109. package/package.json +12 -6
  110. package/packages/react/NysDivider.d.ts +3 -0
  111. package/packages/react/NysDivider.js +2 -1
  112. package/packages/react/NysIcon.d.ts +11 -2
  113. package/packages/react/NysIcon.js +26 -3
  114. package/packages/react/NysRadiobutton.d.ts +7 -23
  115. package/packages/react/NysRadiobutton.js +1 -3
  116. package/packages/react/NysRadiogroup.d.ts +18 -2
  117. package/packages/react/NysRadiogroup.js +17 -1
  118. package/packages/react/NysStep.d.ts +10 -12
  119. package/packages/react/NysStep.js +1 -12
  120. package/packages/react/NysStepper.d.ts +6 -6
  121. package/packages/react/nysds-jsx.d.ts +46 -36
  122. package/dist/packages/mcp-server/src/lib/format.d.ts +0 -21
@@ -9,15 +9,6 @@
9
9
  * - Alias references become var() expressions
10
10
  * - Layer prefixes (primitive, applied) are stripped
11
11
  */
12
- /**
13
- * Legacy interface for backward compatibility
14
- */
15
- export interface DesignToken {
16
- name: string;
17
- value: string;
18
- category: string;
19
- description?: string;
20
- }
21
12
  /**
22
13
  * CSS-centric token info aligned with tokens.css output
23
14
  */
@@ -47,10 +38,6 @@ export interface TokenGraphNode {
47
38
  referencesVariable?: string;
48
39
  usedBy: string[];
49
40
  }
50
- export interface TokenGroup {
51
- category: string;
52
- tokens: DesignToken[];
53
- }
54
41
  /**
55
42
  * Get the path to tokens.json file
56
43
  * Uses ESM-compatible path resolution with fallbacks for different contexts
@@ -94,14 +81,6 @@ export declare function getCSSTokens(): CSSTokenInfo[];
94
81
  * Get CSS tokens filtered by category
95
82
  */
96
83
  export declare function getCSSTokensByCategory(category: string): CSSTokenInfo[];
97
- /**
98
- * Get CSS tokens filtered by layer
99
- */
100
- export declare function getCSSTokensByLayer(layer: string): CSSTokenInfo[];
101
- /**
102
- * Search CSS tokens by variable name, value, or description
103
- */
104
- export declare function searchCSSTokens(query: string): CSSTokenInfo[];
105
84
  /**
106
85
  * Get a single token by CSS variable name
107
86
  */
@@ -118,21 +97,30 @@ export declare function getCSSTokenCategories(): {
118
97
  */
119
98
  export declare function getTokensCSS(): string | null;
120
99
  /**
121
- * Load all design tokens (legacy format)
122
- */
123
- export declare function getAllTokens(): DesignToken[];
124
- /**
125
- * Get tokens filtered by category (legacy format)
100
+ * Get recommended tokens for everyday use.
101
+ *
102
+ * Excludes color primitive tokens (the ~150 palette ramps like neutral-*, red-*,
103
+ * blue-*) which are low-level raw values. For font tokens, applied aliases
104
+ * (body-*, h*, ui-*) are sorted before primitives so the most useful tokens
105
+ * appear first.
126
106
  */
127
- export declare function getTokensByCategory(category: string): DesignToken[];
107
+ export declare function getRecommendedTokens(): CSSTokenInfo[];
128
108
  /**
129
- * Search tokens by name or value (legacy format)
109
+ * Get only primitive (raw value) tokens across all categories.
130
110
  */
131
- export declare function searchTokens(query: string): DesignToken[];
111
+ export declare function getPrimitiveTokens(): CSSTokenInfo[];
132
112
  /**
133
- * Get available token categories (legacy format)
113
+ * Get alternative tokens in the same category that share the same name prefix.
114
+ *
115
+ * First looks for child variants (tokens starting with this token's name + "-"):
116
+ * --nys-color-text → finds --nys-color-text-weak, --nys-color-text-reverse, etc.
117
+ *
118
+ * If no children exist, looks for siblings (tokens sharing the same parent prefix):
119
+ * --nys-color-text-weak → parent: --nys-color-text → finds text, text-weaker, etc.
120
+ *
121
+ * Returns an array of cssVariable strings (empty if none found).
134
122
  */
135
- export declare function getTokenCategories(): string[];
123
+ export declare function getAlternativeTokens(token: CSSTokenInfo): string[];
136
124
  /**
137
125
  * Clear all cached tokens (useful for testing)
138
126
  */
@@ -4,9 +4,8 @@
4
4
  * MCP tools for working with NYSDS design tokens.
5
5
  *
6
6
  * Tools:
7
- * - get_tokens: Get tokens, categories, or themes
8
- * - find_tokens: Search tokens by CSS variable, value, or description
9
- * - get_token_info: Get detailed token info with optional context validation
7
+ * - find_tokens: Search or browse tokens (discovery)
8
+ * - get_token: Get full details for a specific token (deep dive)
10
9
  * - get_token_graph: Get token dependency graph
11
10
  */
12
11
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -51,6 +51,8 @@ export declare class NysAvatar extends LitElement {
51
51
  * Functions
52
52
  * --------------------------------------------------------------------------
53
53
  */
54
+ private get _cleanAriaLabel();
55
+ private _colorStyle;
54
56
  /**
55
57
  * Computes the appropriate foreground color (icon or initials)
56
58
  * based on the avatar's background color for sufficient contrast.
@@ -9,9 +9,9 @@ import { LitElement } from "lit";
9
9
  * If no footer exists, place at the bottom of the body tag (after main content). Floating
10
10
  * positioning allows it to overlay content without taking up layout space.
11
11
  *
12
- * **Focus Management:** When clicked, after scrolling to the top, focus is automatically moved
13
- * to the `<main>` element (if present), the first heading (`<h1>` or `<h2>`), or the document element.
14
- * This ensures keyboard navigation continues naturally from the top of the page.
12
+ * **Focus Management:** When clicked, after scrolling to the top, focus is moved to `<body>`.
13
+ * This places the user before the skip-navigation link so they can re-use it to jump directly
14
+ * back to main content and works regardless of whether the page uses `<main>` or heading landmarks.
15
15
  *
16
16
  * @summary Floating back-to-top button with auto-show behavior, smooth scroll, and focus management.
17
17
  * @element nys-backtotop
@@ -160,6 +160,8 @@ export declare class NysButton extends LitElement {
160
160
  */
161
161
  target: "_self" | "_blank" | "_parent" | "_top" | "framename";
162
162
  private _internals;
163
+ private _hasPrefixSlot;
164
+ private _hasSuffixSlot;
163
165
  /**
164
166
  * Lifecycle methods
165
167
  * --------------------------------------------------------------------------
@@ -172,6 +174,8 @@ export declare class NysButton extends LitElement {
172
174
  * --------------------------------------------------------------------------
173
175
  */
174
176
  private _generateUniqueId;
177
+ private _onPrefixSlotChange;
178
+ private _onSuffixSlotChange;
175
179
  private _manageFormAction;
176
180
  /**
177
181
  * Event Handlers
@@ -181,6 +185,7 @@ export declare class NysButton extends LitElement {
181
185
  private _handleBlur;
182
186
  private _handleClick;
183
187
  private _handleKeydown;
188
+ private _handleKeyup;
184
189
  /**
185
190
  * A Solution to the Vanilla JS & Native HTML keydown:
186
191
  *
@@ -75,6 +75,7 @@ export declare class NysCheckbox extends LitElement {
75
75
  size: "sm" | "md";
76
76
  other: boolean;
77
77
  showOtherError: boolean;
78
+ private _mobileQuery;
78
79
  private isMobile;
79
80
  private _hasUserInteracted;
80
81
  getInputElement(): Promise<HTMLInputElement | null>;
@@ -105,11 +106,11 @@ export declare class NysCheckbox extends LitElement {
105
106
  private _handleInvalid;
106
107
  private _manageLabelClick;
107
108
  get _hasDescription(): boolean;
108
- private _handleResize;
109
109
  /**
110
110
  * Event Handlers
111
111
  * --------------------------------------------------------------------------
112
112
  */
113
+ private _handleMobileQuery;
113
114
  private _emitChangeEvent;
114
115
  private _emitOtherInputEvent;
115
116
  private _handleChange;
@@ -18,6 +18,8 @@ export declare class NysDivider extends LitElement {
18
18
  static styles: import("lit").CSSResult;
19
19
  /** Adjusts colors for dark backgrounds. */
20
20
  inverted: boolean;
21
+ /** If true, the divider will use a lighter color. */
22
+ subtle: boolean;
21
23
  constructor();
22
24
  connectedCallback(): void;
23
25
  /**
@@ -40,6 +40,7 @@ export declare class NysDropdownMenu extends LitElement {
40
40
  private _ariaTarget;
41
41
  private _lastFocusedIndex;
42
42
  private readonly GAP;
43
+ private _resizeObserver;
43
44
  /**
44
45
  * Lifecycle Methods
45
46
  * --------------------------------------------------------------------------
@@ -105,7 +106,6 @@ export declare class NysDropdownMenu extends LitElement {
105
106
  private _handleMenuClick;
106
107
  private _handleTriggerKeydown;
107
108
  private _handleMenuKeydown;
108
- private _handleWindowResize;
109
109
  private _handleWindowScroll;
110
110
  render(): import("lit-html").TemplateResult<1>;
111
111
  }
@@ -36,6 +36,7 @@ export declare class NysGlobalHeader extends LitElement {
36
36
  * --------------------------------------------------------------------------
37
37
  */
38
38
  firstUpdated(): void;
39
+ disconnectedCallback(): void;
39
40
  /**
40
41
  * Functions
41
42
  * --------------------------------------------------------------------------
@@ -47,5 +48,7 @@ export declare class NysGlobalHeader extends LitElement {
47
48
  private _listenLinkClicks;
48
49
  private _renderBrandMark;
49
50
  private _getNysLogo;
51
+ private _boundClickOutside;
52
+ private _boundKeyDown;
50
53
  render(): import("lit-html").TemplateResult<1>;
51
54
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Icon Cache
3
+ *
4
+ * Shared SVG fetch and parse cache. Deduplicates concurrent requests
5
+ * for the same icon URL. Each consumer gets a cloned SVGElement via
6
+ * `cloneNode(true)` so DOM nodes are never shared.
7
+ */
8
+ /** Fetch and parse an SVG from a URL. Returns a cloned SVGElement (safe for multiple consumers). */
9
+ export declare function fetchIcon(url: string): Promise<SVGElement>;
10
+ /** Clear one or all entries from the cache. */
11
+ export declare function clearIconCache(url?: string): void;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Icon Library Registry
3
+ *
4
+ * Global registry for icon libraries. The "default" library resolves
5
+ * NYSDS icons from colocated SVG files extracted at build time.
6
+ * Custom libraries (Font Awesome, Material Icons, etc.) can be
7
+ * registered at runtime via `registerIconLibrary()`.
8
+ *
9
+ * The registry and watcher maps are stored on `window` so that even
10
+ * when bundlers (Storybook Vite, etc.) create duplicate module
11
+ * instances, every copy shares a single source of truth.
12
+ */
13
+ export interface IconLibrary {
14
+ /** Given an icon name, return the URL to its SVG file. Return undefined if not found. */
15
+ resolver: (name: string) => string | undefined;
16
+ /** Optional post-fetch transform applied to the parsed SVGElement. */
17
+ mutator?: (svg: SVGElement) => void;
18
+ }
19
+ export interface NysIconWatcher {
20
+ redraw(): void;
21
+ }
22
+ interface NysIconGlobals {
23
+ __nysIconRegistry: Map<string, IconLibrary>;
24
+ __nysIconWatchers: Map<string, Set<NysIconWatcher>>;
25
+ }
26
+ declare global {
27
+ interface Window extends NysIconGlobals {
28
+ }
29
+ }
30
+ /** Register or replace a named icon library. All watching icons using this library will redraw.
31
+ * @example Register a Font Awesome library with a custom resolver:
32
+ * ```ts
33
+ * registerIconLibrary("fa", {
34
+ * resolver: (name) => `https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/svg/${name}.svg`
35
+ * });
36
+ * ```
37
+ */
38
+ export declare function registerIconLibrary(name: string, library: IconLibrary): void;
39
+ /** Remove a registered icon library. All watching icons using this library will redraw. */
40
+ export declare function unregisterIconLibrary(name: string): void;
41
+ /** Get a registered icon library by name. */
42
+ export declare function getIconLibrary(name: string): IconLibrary | undefined;
43
+ /** Subscribe an icon instance to library change notifications. */
44
+ export declare function watchIconLibrary(name: string, watcher: NysIconWatcher): void;
45
+ /** Unsubscribe an icon instance from library change notifications. */
46
+ export declare function unwatchIconLibrary(name: string, watcher: NysIconWatcher): void;
47
+ export {};
@@ -1 +1,4 @@
1
1
  export * from "./nys-icon";
2
+ export { registerIconLibrary, unregisterIconLibrary, } from "./icon-library-registry";
3
+ export type { IconLibrary } from "./icon-library-registry";
4
+ export { clearIconCache } from "./icon-cache";
@@ -1,27 +1,39 @@
1
1
  import { LitElement } from "lit";
2
+ import { NysIconWatcher } from "./icon-library-registry";
2
3
  /**
3
- * Renders SVG icons from the NYSDS icon library (Material Symbols). Decorative by default (`aria-hidden`).
4
+ * Renders SVG icons from a registered icon library. The built-in NYSDS icon
5
+ * library (Material Symbols) is the default. Custom libraries (Font Awesome,
6
+ * Material Icons, etc.) can be registered via `registerIconLibrary()`.
4
7
  *
5
- * Pass `name` to select an icon from the library. Use `ariaLabel` to make the icon accessible
6
- * (removes `aria-hidden`). Supports size presets, rotation, flipping, and custom colors.
8
+ * Pass `name` to select an icon. Use `library` to choose a registered library
9
+ * (defaults to `"default"` for NYSDS icons). Use `ariaLabel` to make the icon
10
+ * accessible (removes `aria-hidden`). Supports size presets, rotation,
11
+ * flipping, and custom colors.
7
12
  *
8
- * @summary SVG icon from Material Symbols library with size, rotation, and color options.
13
+ * @summary SVG icon with swappable library support, size, rotation, and color options.
9
14
  * @element nys-icon
10
15
  *
11
- * @example Basic icon
16
+ * @example Basic icon (default NYSDS library)
12
17
  * ```html
13
18
  * <nys-icon name="check_circle" size="lg"></nys-icon>
14
19
  * ```
15
20
  *
21
+ * @example Font Awesome icon
22
+ * ```html
23
+ * <nys-icon name="house" library="fa" size="lg"></nys-icon>
24
+ * ```
25
+ *
16
26
  * @example Accessible icon with label
17
27
  * ```html
18
28
  * <nys-icon name="warning" ariaLabel="Warning" color="var(--nys-color-warning)"></nys-icon>
19
29
  * ```
20
30
  */
21
- export declare class NysIcon extends LitElement {
31
+ export declare class NysIcon extends LitElement implements NysIconWatcher {
22
32
  static styles: import("lit").CSSResult;
23
- /** Icon name from Material Symbols library. Required. */
33
+ /** Icon name to resolve from the selected library. Required. */
24
34
  name: string;
35
+ /** Which registered icon library to use. Defaults to the built-in NYSDS library. */
36
+ library: string;
25
37
  /** Accessible label. When set, removes `aria-hidden` and adds `aria-label` to the SVG. */
26
38
  ariaLabel: string;
27
39
  /** Rotation in degrees. Applied via CSS `rotate`. */
@@ -35,11 +47,28 @@ export declare class NysIcon extends LitElement {
35
47
  * @default "md"
36
48
  */
37
49
  size: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "12" | "14" | "16" | "18" | "20" | "24" | "32" | "40" | "50";
50
+ private _svg;
51
+ /** Monotonically increasing token so stale async fetches are discarded. */
52
+ private _loadSeq;
53
+ /** Promise for the in-flight icon load. */
54
+ private _loadPromise;
55
+ /** Resolves when the current icon load (if any) is complete. */
56
+ get updateComplete(): Promise<boolean>;
57
+ connectedCallback(): void;
58
+ disconnectedCallback(): void;
59
+ /** Called by the icon library registry when the current library changes. */
60
+ redraw(): void;
38
61
  /**
39
- * Retrieves the SVG element for the given icon name and applies
40
- * accessibility, rotation, flip, color, and size classes.
41
- * @returns SVGElement | null
62
+ * Lit calls firstUpdated after the first render, once all reactive
63
+ * properties (including those set from the template) are resolved.
64
+ * This guarantees the initial _loadIcon runs with the correct name
65
+ * and library values, avoiding the race where updated() might not
66
+ * fire for properties that equal their defaults.
42
67
  */
43
- private getIcon;
68
+ firstUpdated(): void;
69
+ private static _validName;
70
+ updated(changedProps: Map<string, unknown>): void;
71
+ private _loadIcon;
72
+ private _applyAttributes;
44
73
  render(): import("lit-html").TemplateResult<1> | null;
45
74
  }
@@ -45,6 +45,7 @@ export declare class NysModal extends LitElement {
45
45
  private _actionButtonSlot;
46
46
  private _prevFocusedElement;
47
47
  private _originalBodyOverflow;
48
+ private _mobileMedia;
48
49
  private hasBodySlots;
49
50
  private hasActionSlots;
50
51
  /**
@@ -1,12 +1,11 @@
1
1
  import { LitElement } from "lit";
2
- import "./nys-radiogroup";
3
2
  /**
4
3
  * A radio button for single selection within a `nys-radiogroup`. Only one radio with the same `name` can be selected.
5
4
  *
6
5
  * Use within `nys-radiogroup` for 2-6 mutually exclusive options. For 7+ options, use `nys-select`.
7
6
  * For multiple selections, use `nys-checkbox`.
8
7
  *
9
- * @summary Radio button for single selection from mutually exclusive options.
8
+ * @summary Radio button for single selection from mutually exclusive options. This is a READONLY data component.
10
9
  * @element nys-radiobutton
11
10
  *
12
11
  * @slot description - Custom HTML description content.
@@ -26,14 +25,6 @@ import "./nys-radiogroup";
26
25
  */
27
26
  export declare class NysRadiobutton extends LitElement {
28
27
  static styles: import("lit").CSSResult;
29
- static shadowRootOptions: {
30
- delegatesFocus: boolean;
31
- clonable?: boolean;
32
- customElementRegistry?: CustomElementRegistry;
33
- mode: ShadowRootMode;
34
- serializable?: boolean;
35
- slotAssignment?: SlotAssignmentMode;
36
- };
37
28
  /** Whether this radio is selected. Only one per group can be checked. */
38
29
  checked: boolean;
39
30
  /** Prevents interaction. */
@@ -61,38 +52,10 @@ export declare class NysRadiobutton extends LitElement {
61
52
  tile: boolean;
62
53
  other: boolean;
63
54
  showOtherError: boolean;
64
- private isMobile;
65
- private _hasUserInteracted;
66
- static buttonGroup: Record<string, NysRadiobutton>;
67
55
  /**
68
56
  * Lifecycle methods
69
57
  * --------------------------------------------------------------------------
70
58
  */
71
59
  connectedCallback(): void;
72
- disconnectedCallback(): void;
73
- updated(changedProperties: Map<string | number | symbol, unknown>): void;
74
- /**
75
- * Functions
76
- * --------------------------------------------------------------------------
77
- */
78
- getInputElement(): Promise<HTMLInputElement | null>;
79
- formResetUpdate(): void;
80
- private _handleResize;
81
- private _clearOtherState;
82
- private _dispatchClearErrorEvent;
83
- /**
84
- * Event Handlers
85
- * --------------------------------------------------------------------------
86
- */
87
- private _emitChangeEvent;
88
- private _emitOtherInputEvent;
89
- private _handleChange;
90
- private _handleFocus;
91
- private _handleBlur;
92
- private _callInputHandling;
93
- private _handleTextInput;
94
- private _handleTextInputBlur;
95
- private _validateOtherAndEmitError;
96
- private _handleOtherKeydown;
97
60
  render(): import("lit-html").TemplateResult<1>;
98
61
  }
@@ -58,8 +58,14 @@ export declare class NysRadiogroup extends LitElement {
58
58
  * @default "md"
59
59
  */
60
60
  size: "sm" | "md";
61
+ _showOtherError: boolean;
61
62
  private selectedValue;
62
63
  private _slottedDescriptionText;
64
+ private _radios;
65
+ private _mobileQuery;
66
+ private isMobile;
67
+ private _hasUserInteracted;
68
+ private _childObserver?;
63
69
  private _internals;
64
70
  /**
65
71
  * Lifecycle methods
@@ -88,20 +94,24 @@ export declare class NysRadiogroup extends LitElement {
88
94
  * Functions
89
95
  * --------------------------------------------------------------------------
90
96
  */
97
+ private _handleMobileQuery;
98
+ private _handleSlotChange;
91
99
  private _initializeChildAttributes;
92
100
  private _updateRadioButtonsSize;
93
- private _updateRadioButtonsTile;
94
- private _updateRadioButtonsShowError;
95
- private _updateRadioButtonsForm;
101
+ private _selectRadio;
96
102
  private _getSlotDescriptionForAria;
97
103
  /**
98
104
  * Event Handlers
99
105
  * --------------------------------------------------------------------------
100
106
  */
101
- private _handleRadioButtonChange;
102
107
  private _handleInvalid;
103
- private _handleChildError;
104
- private _handleChildErrorClear;
105
- private _handleOtherInput;
108
+ private _handleTextInput;
109
+ private _handleTextInputBlur;
110
+ private _validateOtherAndEmitError;
111
+ private _handleOtherKeydown;
112
+ private _handleGroupFocusout;
113
+ private _handleRadiobtnClick;
114
+ private _handleRadiobtnFocus;
115
+ private _handleRadiobtnBlur;
106
116
  render(): import("lit-html").TemplateResult<1>;
107
117
  }
@@ -2,27 +2,55 @@ import { LitElement } from "lit";
2
2
  /**
3
3
  * A single step within `nys-stepper`. Represents one stage in a multi-step process.
4
4
  *
5
- * Mark as `current` to indicate active progress point. Previous steps become clickable for navigation.
6
- * Set `href` for page-based navigation or listen to `nys-step-click` for SPA routing.
5
+ * Mark as `current` to indicate the active progress point. Previous steps become clickable for navigation.
6
+ * Set `href` for page-based navigation, or omit it and listen to `nys-step-click` for SPA/framework routing.
7
7
  *
8
- * ## Step States
8
+ * ## Step states
9
9
  *
10
- * Understanding the three step states is critical for proper stepper usage:
10
+ * Three boolean attributes control step appearance and behavior:
11
11
  *
12
- * - **`selected`** - Which step is currently being displayed/viewed. This controls which step's
13
- * content is shown. Defaults to `current` if not set. Cannot be set on a step after `current`.
14
- * Users can click previous steps to change `selected` without changing `current`.
12
+ * - **`current`** The furthest step the user has reached (the progress boundary). Only one step should
13
+ * have `current` at a time; if multiple are set the parent stepper keeps the first and removes the rest.
14
+ * Steps after `current` are not navigable and do not fire `nys-step-click`. Update `current` in your
15
+ * application state when the user advances.
15
16
  *
16
- * - **`current`** - The furthest step the user has reached. This is the progress boundary.
17
- * Update this as the user completes steps and advances. Steps after `current` are not navigable.
18
- * Only one step should have `current` at a time.
17
+ * - **`selected`** Which step's content is currently displayed. Defaults to the `current` step if not
18
+ * explicitly set. If `selected` is placed on a step after `current`, the stepper silently corrects it
19
+ * to match `current`. When managing state from a framework, always set `selected` explicitly without
20
+ * it the stepper's fallback will reset in-sidebar navigation on every state update.
19
21
  *
20
- * - **`previous`** - Auto-applied by the stepper to all steps before `current`. Do not set manually.
21
- * Steps with `previous` are clickable and allow the user to navigate back.
22
+ * - **`previous`** Auto-applied by the parent stepper to every step before `current`. Do not set this
23
+ * manually. Steps with `previous` are clickable and fire `nys-step-click`.
22
24
  *
23
- * ## Common Patterns
25
+ * ## `nys-step-click` firing conditions
24
26
  *
25
- * **Initial state:** Set `current` on the first step. `selected` will default to it.
27
+ * The event fires only when ALL of the following are true:
28
+ * 1. The step has `previous` or `current` (i.e. it is navigable).
29
+ * 2. The step does NOT already have `selected` (clicking the already-viewed step is a no-op).
30
+ *
31
+ * Steps that are neither `previous` nor `current` (future steps) never fire the event.
32
+ *
33
+ * ## `href` and navigation
34
+ *
35
+ * If `href` is set, the stepper calls `window.location.href = href` after dispatching `nys-step-click`
36
+ * — but only if the event was **not canceled**. To handle navigation yourself (SPA routing, fetch, etc.),
37
+ * always call `e.preventDefault()` in your listener. Omitting `href` entirely is simpler for SPAs.
38
+ *
39
+ * ## `onClick` vs `nys-step-click`
40
+ *
41
+ * The `onClick` property (a function reference, not a DOM attribute) is called **before** the
42
+ * `nys-step-click` event is dispatched. Use it for imperative pre-navigation logic. In React, pass it
43
+ * as the `onClick` prop on `NysStep`.
44
+ *
45
+ * ## Accessibility
46
+ * - The step label renders with `role="button"` and is keyboard-focusable (`tabindex="0"`) for navigable
47
+ * steps (`current`, `previous`). Future steps get `tabindex="-1"` and are not reachable by keyboard.
48
+ * - Enter and Space activate the step (same as click).
49
+ * - `aria-label` is set to `"{label} Step"` for screen reader announcement.
50
+ *
51
+ * ## Common patterns
52
+ *
53
+ * **Initial state:** Set `current` on the first step. `selected` defaults to it.
26
54
  * ```html
27
55
  * <nys-step label="Step 1" current></nys-step>
28
56
  * <nys-step label="Step 2"></nys-step>
@@ -34,7 +62,7 @@ import { LitElement } from "lit";
34
62
  * <nys-step label="Step 2" current></nys-step>
35
63
  * ```
36
64
  *
37
- * **User went back to review step 1 (but progress is still at step 2):**
65
+ * **User went back to review step 1 (progress still at step 2):**
38
66
  * ```html
39
67
  * <nys-step label="Step 1" selected></nys-step>
40
68
  * <nys-step label="Step 2" current></nys-step>
@@ -43,28 +71,52 @@ import { LitElement } from "lit";
43
71
  * @summary Individual step for use within nys-stepper with navigation support.
44
72
  * @element nys-step
45
73
  *
46
- * @fires nys-step-click - Fired when a navigable step is clicked. Detail: `{href, label}`. Cancelable.
74
+ * @fires nys-step-click - Fired when a navigable (`previous` or `current`) non-selected step is clicked
75
+ * or activated by keyboard. Detail: `{ href: string, label: string }`. Cancelable — call
76
+ * `e.preventDefault()` to suppress `window.location.href` navigation.
47
77
  *
48
- * @example Step with navigation
78
+ * @example Step with page navigation
49
79
  * ```html
50
80
  * <nys-step label="Personal Info" href="/step-1"></nys-step>
51
81
  * ```
82
+ *
83
+ * @example Step with SPA navigation (no href)
84
+ * ```js
85
+ * step.addEventListener('nys-step-click', (e) => {
86
+ * e.preventDefault(); // no href set, but good practice
87
+ * showStepContent(e.detail.label);
88
+ * });
89
+ * ```
52
90
  */
53
91
  export declare class NysStep extends LitElement {
54
92
  static styles: import("lit").CSSResult;
55
- /** Whether this step is currently being viewed. Set by parent stepper. */
93
+ /**
94
+ * Which step is currently being displayed. If not set, defaults to the `current` step.
95
+ * Setting this on a step after `current` is silently corrected to match `current`.
96
+ * When controlling state from a framework, always set this explicitly.
97
+ */
56
98
  selected: boolean;
57
- /** Marks the furthest reached step. Steps before this are navigable. */
99
+ /** The furthest step the user has reached (progress boundary). Steps before this are navigable. */
58
100
  current: boolean;
59
101
  /** Step label text displayed alongside the step number. */
60
102
  label: string;
61
- /** URL for page navigation when step is clicked. Optional for SPA routing. */
103
+ /**
104
+ * URL navigated to when the step is activated, via `window.location.href`.
105
+ * Navigation is suppressed if the `nys-step-click` listener calls `e.preventDefault()`.
106
+ * Omit for SPA/framework routing and handle navigation in the event listener instead.
107
+ */
62
108
  href: string;
63
- /** Internal: Whether parent stepper's compact view is expanded. */
109
+ /**
110
+ * @internal Auto-applied by `nys-stepper` to every step that comes before `current`.
111
+ * Marks the step as navigable and clickable. Do not set this manually — the parent stepper
112
+ * adds and removes it on every render based on which step has `current`.
113
+ */
114
+ previous: boolean;
115
+ /** @internal Propagated by the parent stepper. Do not set manually. */
64
116
  isCompactExpanded: boolean;
65
- /** Custom click handler. Called before `nys-step-click` event. */
117
+ /** Optional function called before `nys-step-click` is dispatched. Use for pre-navigation logic. */
66
118
  onClick?: (e: Event) => void;
67
- /** Step number (1-indexed). Auto-assigned by parent stepper. */
119
+ /** @internal 1-indexed position. Auto-assigned by the parent stepper on first render. Do not set manually. */
68
120
  stepNumber: number;
69
121
  private _handleActivate;
70
122
  private _handleKeydown;