@nysds/components 1.19.2 → 1.20.0-alpha-2

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.
@@ -162,6 +162,7 @@ export declare class NysButton extends LitElement {
162
162
  private _internals;
163
163
  private _hasPrefixSlot;
164
164
  private _hasSuffixSlot;
165
+ private _hasCircleSlot;
165
166
  /**
166
167
  * Lifecycle methods
167
168
  * --------------------------------------------------------------------------
@@ -176,6 +177,7 @@ export declare class NysButton extends LitElement {
176
177
  private _generateUniqueId;
177
178
  private _onPrefixSlotChange;
178
179
  private _onSuffixSlotChange;
180
+ private _onCircleSlotChange;
179
181
  private _manageFormAction;
180
182
  /**
181
183
  * Event Handlers
@@ -106,6 +106,7 @@ export declare class NysCheckbox extends LitElement {
106
106
  private _handleInvalid;
107
107
  private _manageLabelClick;
108
108
  get _hasDescription(): boolean;
109
+ get _isStandalone(): boolean;
109
110
  /**
110
111
  * Event Handlers
111
112
  * --------------------------------------------------------------------------
@@ -60,6 +60,7 @@ export declare class NysCheckboxgroup extends LitElement {
60
60
  private _slottedDescriptionText;
61
61
  private _hasOtherError;
62
62
  private _otherErrorCheckbox;
63
+ private _hasSharedNames;
63
64
  private _internals;
64
65
  /**
65
66
  * Lifecycle methods
@@ -96,5 +97,7 @@ export declare class NysCheckboxgroup extends LitElement {
96
97
  private _handleChildErrorClear;
97
98
  private _handleOtherInput;
98
99
  private _checkOtherInputs;
100
+ /** Drupal-like naming support **/
101
+ private _checkSharedNames;
99
102
  render(): import("lit-html").TemplateResult<1>;
100
103
  }
@@ -1,11 +1,18 @@
1
1
  /**
2
2
  * Icon Cache
3
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.
4
+ * Shared SVG sanitize/parse pipeline and caches. URL-based icons (custom
5
+ * libraries) are fetched once per URL; inline SVG sources (the built-in
6
+ * NYSDS set) are parsed once per source string. Each consumer gets a
7
+ * cloned SVGElement via `cloneNode(true)` so DOM nodes are never shared.
7
8
  */
8
9
  /** Fetch and parse an SVG from a URL. Returns a cloned SVGElement (safe for multiple consumers). */
9
10
  export declare function fetchIcon(url: string): Promise<SVGElement>;
10
- /** Clear one or all entries from the cache. */
11
+ /**
12
+ * Parse an inline SVG source string. Results are cached by source content,
13
+ * so repeated renders of the same icon sanitize/parse once. Returns a
14
+ * cloned SVGElement (safe for multiple consumers).
15
+ */
16
+ export declare function parseIcon(source: string): SVGElement;
17
+ /** Clear one URL entry, or all cached icons (URL and inline) when no URL is given. */
11
18
  export declare function clearIconCache(url?: string): void;
@@ -1,33 +1,51 @@
1
1
  /**
2
2
  * Icon Library Registry
3
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()`.
4
+ * Global registry for icon libraries. The "default" library resolves the
5
+ * standard NYSDS icon set from an inline SVG map shipped as JavaScript
6
+ * (`nys-icon.library.ts`), loaded lazily as a separate chunk no base-URL
7
+ * discovery, no per-icon fetch, no browser globals. Custom libraries
8
+ * (Font Awesome, Material Icons, etc.) register at runtime via
9
+ * `registerIconLibrary()` and typically resolve to URLs.
8
10
  *
9
- * The registry and watcher maps are stored on `window` so that even
11
+ * The registry and watcher maps are stored on `globalThis` so that even
10
12
  * when bundlers (Storybook Vite, etc.) create duplicate module
11
- * instances, every copy shares a single source of truth.
13
+ * instances, every copy shares a single source of truth. `globalThis`
14
+ * (rather than `window`) keeps module import side-effect-safe in
15
+ * Node/SSR environments, where `window` does not exist.
12
16
  */
17
+ /**
18
+ * How a resolver locates an icon: a URL string (legacy shorthand for
19
+ * `{ type: "url" }`), an explicit URL, or inline SVG source. Resolvers may
20
+ * return synchronously or via a Promise.
21
+ */
22
+ export type IconResolution = string | {
23
+ type: "url";
24
+ href: string;
25
+ } | {
26
+ type: "svg";
27
+ content: string;
28
+ };
13
29
  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. */
30
+ /** Given an icon name, return where/what its SVG is. Return undefined if not found. */
31
+ resolver: (name: string) => IconResolution | undefined | Promise<IconResolution | undefined>;
32
+ /** Optional post-parse transform applied to the SVGElement. */
17
33
  mutator?: (svg: SVGElement) => void;
18
34
  }
19
35
  export interface NysIconWatcher {
20
36
  redraw(): void;
21
37
  }
22
- interface NysIconGlobals {
23
- __nysIconRegistry: Map<string, IconLibrary>;
24
- __nysIconWatchers: Map<string, Set<NysIconWatcher>>;
25
- }
26
38
  declare global {
27
- interface Window extends NysIconGlobals {
28
- }
39
+ var __nysIconRegistry: Map<string, IconLibrary> | undefined;
40
+ var __nysIconWatchers: Map<string, Set<NysIconWatcher>> | undefined;
41
+ var __nysIconDefaultRegistered: boolean | undefined;
29
42
  }
30
43
  /** Register or replace a named icon library. All watching icons using this library will redraw.
44
+ *
45
+ * Intended for custom/external libraries — the standard NYSDS set is
46
+ * built in and needs no registration. Registering under `"default"`
47
+ * replaces the built-in set (escape hatch).
48
+ *
31
49
  * @example Register a Font Awesome library with a custom resolver:
32
50
  * ```ts
33
51
  * registerIconLibrary("fa", {
@@ -44,4 +62,3 @@ export declare function getIconLibrary(name: string): IconLibrary | undefined;
44
62
  export declare function watchIconLibrary(name: string, watcher: NysIconWatcher): void;
45
63
  /** Unsubscribe an icon instance from library change notifications. */
46
64
  export declare function unwatchIconLibrary(name: string, watcher: NysIconWatcher): void;
47
- export {};
@@ -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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nysds/components",
3
- "version": "1.19.2",
3
+ "version": "1.20.0-alpha-2",
4
4
  "description": "New York State's design system and code component library.",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -47,7 +47,8 @@
47
47
  "release:zip": "npm run build:all && node src/scripts/create-release-zip.js",
48
48
  "pretest": "playwright install",
49
49
  "test": "wtr --node-resolve",
50
- "test:ssr": "node scripts/test-ssr.mjs",
50
+ "test:ssr": "node scripts/test-ssr.mjs && node scripts/audit-dist.mjs",
51
+ "audit:dist": "node scripts/audit-dist.mjs",
51
52
  "test:build": "npm run build:all && npm run test",
52
53
  "test:compact": "export NYSDS_TEST_OUTPUT=compact && wtr --node-resolve",
53
54
  "test:ai": "export NYSDS_TEST_OUTPUT=ai && wtr --node-resolve",
@@ -287,6 +287,8 @@ export type NysCheckboxProps = {
287
287
  showOtherError?: boolean;
288
288
  /** */
289
289
  _hasDescription?: string;
290
+ /** */
291
+ _isStandalone?: string;
290
292
  /** Fired when checked state changes. Detail: `{id, checked, name, value}`. */
291
293
  "onnys-change"?: (e: CustomEvent<CustomEvent>) => void;
292
294
  /** Fired when "other" text input value changes. Detail: `{id, name, value}`. */