@nysds/components 1.20.1 → 1.21.1-alpha-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.
@@ -2,6 +2,54 @@
2
2
  * Utility Tools
3
3
  *
4
4
  * MCP tools for NYSDS utility classes.
5
+ *
6
+ * The class lists this tool returns are RENDERED from the scale constants
7
+ * below. Those constants mirror the Sass sources that actually generate the
8
+ * stylesheet:
9
+ *
10
+ * - packages/styles/src/utilities/_config.scss ($spacing, $opacity-values,
11
+ * $zindex-values, $display-values,
12
+ * $breakpoints, $flex-columns)
13
+ * - packages/styles/src/utilities/_layout-grid.scss ($responsive-gap-suffixes)
14
+ * - packages/styles/src/core/typography.scss ($body-sizes, $ui-sizes,
15
+ * $ui-underline-styles, $display-sizes)
16
+ *
17
+ * Do not hand-write a class name into the markdown. Add it to a scale and let
18
+ * the renderer emit it, so a name can never appear here without a scale entry
19
+ * behind it.
20
+ *
21
+ * `npm run verify:utility-docs` compiles the stylesheet and asserts that every
22
+ * class this tool names exists in it. Run it after touching any scale.
5
23
  */
6
24
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
25
+ declare const UTILITY_DOCS: {
26
+ grid: string;
27
+ flex: string;
28
+ spacing: string;
29
+ display: string;
30
+ opacity: string;
31
+ zindex: string;
32
+ typography: string;
33
+ responsive: string;
34
+ componentSpacing: string;
35
+ };
36
+ /**
37
+ * Classes the reference deliberately names in order to say they do NOT exist.
38
+ *
39
+ * These are the names people reach for out of habit from other frameworks.
40
+ * Saying so explicitly is more useful than silence, but it means the docs
41
+ * mention class names the stylesheet does not define, which would otherwise
42
+ * trip the verifier.
43
+ *
44
+ * `verify-utility-docs.mjs` asserts each of these is genuinely absent, so if
45
+ * NYSDS ever adds one, the stale warning fails the check instead of quietly
46
+ * misinforming people.
47
+ */
48
+ declare const KNOWN_ABSENT: readonly string[];
49
+ /**
50
+ * Exported so `src/scripts/verify-utility-docs.mjs` can assert that every class
51
+ * named in this reference exists in the compiled stylesheet — and that every
52
+ * class named in KNOWN_ABSENT still does not.
53
+ */
54
+ export { UTILITY_DOCS, KNOWN_ABSENT };
7
55
  export declare function registerUtilityTools(server: McpServer): void;
@@ -37,7 +37,7 @@ import "@nysds/nys-button";
37
37
  * font-size: var(--nys-font-size-sm);
38
38
  * }
39
39
  * </style>
40
- * <nys-unavheader hideTranslate hideSearch></nys-unavheader>
40
+ * <nys-unavheader translateKey="NEf4Y5qMb9PGP"></nys-unavheader>
41
41
  * <nys-globalheader appName="Back to Top Example"></nys-globalheader>
42
42
  * <main style="padding: 0 2rem">
43
43
  * <h1>Sample Content on page</h1>
@@ -79,7 +79,7 @@ import "@nysds/nys-button";
79
79
  * --_nys-button-border-radius: var(--nys-radius-round);
80
80
  * }
81
81
  * </style>
82
- * <nys-unavheader hideTranslate hideSearch></nys-unavheader>
82
+ * <nys-unavheader translateKey="NEf4Y5qMb9PGP"></nys-unavheader>
83
83
  * <nys-globalheader appName="Back to Top Example"></nys-globalheader>
84
84
  * <main style="padding: 0 2rem">
85
85
  * <h1>Sample Content on page</h1>
@@ -15,9 +15,14 @@ import "@nysds/nys-icon";
15
15
  * <nys-badge label="Basic badge"></nys-badge>
16
16
  * ```
17
17
  *
18
- * @example Error Intent
18
+ * @example Info Intent
19
19
  * ```html
20
- * <nys-badge label="Error" intent="error" prefixIcon></nys-badge>
20
+ * <nys-badge label="Info" intent="info" prefixIcon></nys-badge>
21
+ * ```
22
+ *
23
+ * @example Success Intent
24
+ * ```html
25
+ * <nys-badge label="Success" intent="success" prefixIcon></nys-badge>
21
26
  * ```
22
27
  *
23
28
  * @example Warning Intent
@@ -25,29 +30,39 @@ import "@nysds/nys-icon";
25
30
  * <nys-badge label="Warning" intent="warning" prefixIcon></nys-badge>
26
31
  * ```
27
32
  *
28
- * @example Success Intent
33
+ * @example Danger Intent
29
34
  * ```html
30
- * <nys-badge label="Success" intent="success" prefixIcon></nys-badge>
35
+ * <nys-badge label="Danger" intent="danger" prefixIcon></nys-badge>
31
36
  * ```
32
37
  *
33
- * @example Strong Neutral
38
+ * @example Emergency Intent
34
39
  * ```html
35
- * <nys-badge variant="strong" label="Neutral" prefixIcon></nys-badge>
40
+ * <nys-badge label="Emergency" intent="emergency" prefixIcon></nys-badge>
36
41
  * ```
37
42
  *
38
- * @example Strong Error
43
+ * @example Strong Base
39
44
  * ```html
40
- * <nys-badge variant="strong" label="Error" intent="error" prefixIcon></nys-badge>
45
+ * <nys-badge strong label="Base" prefixIcon></nys-badge>
41
46
  * ```
42
47
  *
43
- * @example Strong Warning
48
+ * @example Strong Info
44
49
  * ```html
45
- * <nys-badge variant="strong" label="Warning" intent="warning" prefixIcon></nys-badge>
50
+ * <nys-badge strong label="Info" intent="info" prefixIcon></nys-badge>
46
51
  * ```
47
52
  *
48
53
  * @example Strong Success
49
54
  * ```html
50
- * <nys-badge variant="strong" label="Success" intent="success" prefixIcon></nys-badge>
55
+ * <nys-badge strong label="Success" intent="success" prefixIcon></nys-badge>
56
+ * ```
57
+ *
58
+ * @example Strong Warning
59
+ * ```html
60
+ * <nys-badge strong label="Warning" intent="warning" prefixIcon></nys-badge>
61
+ * ```
62
+ *
63
+ * @example Strong Danger
64
+ * ```html
65
+ * <nys-badge strong label="Danger" intent="danger" prefixIcon></nys-badge>
51
66
  * ```
52
67
  *
53
68
  * @example Custom Prefix Icon
@@ -82,17 +97,18 @@ export declare class NysBadge extends NysElement {
82
97
  */
83
98
  size: "sm" | "md";
84
99
  /**
85
- * Semantic intent affecting color: `neutral`, `error`, `success`, or `warning`.
86
- * @default "neutral"
100
+ * Semantic intent affecting color: `base`, `info`, `success`, `warning` `danger`, `emergency`. `error` has been deprecated and support will be removed in a future release. Use `danger` instead
101
+ * @default "info"
87
102
  */
88
- intent: "neutral" | "error" | "success" | "warning";
103
+ intent: "base" | "info" | "success" | "warning" | "danger" | "error" | "emergency";
89
104
  /** Secondary label displayed before the main label. */
90
105
  prefixLabel: string;
91
106
  /** Primary label text displayed in the badge. */
92
107
  label: string;
93
108
  /** Screen reader text appended after the label for additional context. */
94
109
  srText: string;
95
- variant: "strong" | "";
110
+ /** Strong visual intent with bolder text and background. */
111
+ strong: boolean;
96
112
  private _prefixIcon;
97
113
  get prefixIcon(): string | boolean;
98
114
  set prefixIcon(value: string | boolean);
@@ -7,6 +7,7 @@ import "@nysds/nys-alert";
7
7
  interface Language {
8
8
  code: string;
9
9
  label: string;
10
+ nativeText: string;
10
11
  url?: string;
11
12
  }
12
13
  /**
@@ -51,12 +52,12 @@ export declare const NYS_ALERT_URL = "https://alerts-cta.static-assets.ny.gov/al
51
52
  * reaches every NYS site with no per-site work. If the endpoint is unreachable or nothing
52
53
  * is published, the header renders normally. It takes no children.
53
54
  *
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-language-select - Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Localize integration.
55
56
  * @fires nys-search-submit - Fired when a search is submitted. Detail: `{query}`. Cancelable; `preventDefault()` overrides the default search redirect.
56
57
  *
57
58
  * @example Basic
58
59
  * ```html
59
- * <nys-unavheader></nys-unavheader>
60
+ * <nys-unavheader translateKey="NEf4Y5qMb9PGP"></nys-unavheader>
60
61
  * ```
61
62
  *
62
63
  * @example Hide search
@@ -120,6 +121,8 @@ export declare class NysUnavHeader extends NysElement {
120
121
  hideSearch: boolean;
121
122
  /** The URL endpoint of the search, make sure to include the query param. */
122
123
  searchUrl: string;
124
+ /** Localize project key. If provided, the component will load and initialize LocalizeJS automatically. */
125
+ translateKey: string;
123
126
  /**
124
127
  * Accessible name for the `banner` landmark this header renders.
125
128
  * Defaults to `"New York State"`.
@@ -136,7 +139,7 @@ export declare class NysUnavHeader extends NysElement {
136
139
  * @default "New York State"
137
140
  */
138
141
  landmarkLabel: string;
139
- /** The list of languages this site can be translated to, default to use Smartling */
142
+ /** The list of languages this site can be translated to, default to use Localize */
140
143
  languages: Language[];
141
144
  /**
142
145
  * Lifecycle Methods
@@ -148,6 +151,7 @@ export declare class NysUnavHeader extends NysElement {
148
151
  */
149
152
  connectedCallback(): void;
150
153
  disconnectedCallback(): void;
154
+ willUpdate(changedProperties: PropertyValues): void;
151
155
  protected updated(changed: PropertyValues): void;
152
156
  /**
153
157
  * Functions
@@ -209,7 +213,15 @@ export declare class NysUnavHeader extends NysElement {
209
213
  * -1 is the last option, so "previous from the first" and "End" are the same call.
210
214
  */
211
215
  private _focusOption;
216
+ private _initLocalize;
212
217
  private _toggleSearchDropdown;
218
+ /**
219
+ * Shows, replaces, or removes the translation disclaimer banner for the given
220
+ * language code. Called from the Localize "setLanguage" listener — which also
221
+ * fires on page load for a remembered language — and directly from
222
+ * `_handleLanguageSelect` when the Localize API isn't available.
223
+ */
224
+ private _updateTranslateDisclaimer;
213
225
  private _handleLanguageSelect;
214
226
  /**
215
227
  * Keyboard model for the translate menu (APG menu button):
@@ -272,6 +284,7 @@ export declare class NysUnavHeader extends NysElement {
272
284
  * #1795 found it — two unnamed banners — so it falls back to the default.
273
285
  */
274
286
  private get _landmarkLabel();
287
+ private get _locale();
275
288
  render(): import("lit-html").TemplateResult<1>;
276
289
  }
277
290
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nysds/components",
3
- "version": "1.20.1",
3
+ "version": "1.21.1-alpha-1",
4
4
  "description": "New York State's design system and code component library.",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -45,7 +45,7 @@
45
45
  "playwright:install": "npx playwright install --with-deps",
46
46
  "release": "cross-env NODE_ENV=production npm run build:all && cross-env NODE_ENV=production npm run test && npm run cem && cross-env NODE_ENV=production npm publish --workspaces --access public && cross-env NODE_ENV=production npm publish --access public",
47
47
  "release:dry-run": "cross-env NODE_ENV=production npm run build:all && cross-env NODE_ENV=production npm run test && npm run cem && node src/scripts/publish-dry-run.js",
48
- "release:alpha": "npm run build && npm run build:umd && npm publish --tag next",
48
+ "release:alpha": "npm run build && npm run build:umd && npm publish --tag alpha",
49
49
  "release:zip": "npm run build:all && node src/scripts/create-release-zip.js",
50
50
  "pretest": "playwright install",
51
51
  "test": "wtr --node-resolve",
@@ -67,7 +67,8 @@
67
67
  "clean:all": "npm run clean:dist && npm run clean:node && npm run clean:cache && find packages -name '*.tsbuildinfo' -delete 2>/dev/null || true && npm run clean:turbo",
68
68
  "code-connect": "dotenv -- npx figma connect publish",
69
69
  "cem": "npx cem analyze --config src/scripts/custom-elements-manifest.config.mjs && cp ./custom-elements.json dist/ && node src/scripts/patch-react-utils.js",
70
- "verify:a11y-names": "node src/scripts/verify-a11y-names.mjs"
70
+ "verify:a11y-names": "node src/scripts/verify-a11y-names.mjs",
71
+ "verify:utility-docs": "npm run build:mcp && node src/scripts/verify-utility-docs.mjs"
71
72
  },
72
73
  "repository": {
73
74
  "type": "git",
@@ -94,10 +95,10 @@
94
95
  "@typescript-eslint/eslint-plugin": "^8.46.2",
95
96
  "@typescript-eslint/parser": "^8.46.2",
96
97
  "@wc-toolkit/wctools": "^0.0.9",
97
- "@web/dev-server-esbuild": "^1.0.4",
98
- "@web/test-runner": "^0.20.2",
99
- "@web/test-runner-commands": "^0.9.0",
100
- "@web/test-runner-playwright": "^0.11.1",
98
+ "@web/dev-server-esbuild": "^2.0.0",
99
+ "@web/test-runner": "^1.0.0",
100
+ "@web/test-runner-commands": "^1.0.1",
101
+ "@web/test-runner-playwright": "^1.0.0",
101
102
  "cem-plugin-examples": "github:its-hcd/cem-plugin-examples",
102
103
  "cross-env": "^10.1.0",
103
104
  "custom-element-jsx-integration": "^1.6.0",
@@ -18,6 +18,9 @@ export interface NysBadgeProps extends Pick<
18
18
  | "onFocus"
19
19
  | "onBlur"
20
20
  > {
21
+ /** Strong visual intent with bolder text and background. */
22
+ strong?: boolean;
23
+
21
24
  /** undefined */
22
25
  prefixIcon?: string | boolean;
23
26
 
@@ -33,7 +36,7 @@ export interface NysBadgeProps extends Pick<
33
36
  /** Badge size: `sm` (smaller text) or `md` (default). */
34
37
  size?: NysBadgeElement["size"];
35
38
 
36
- /** Semantic intent affecting color: `neutral`, `error`, `success`, or `warning`. */
39
+ /** Semantic intent affecting color: `base`, `info`, `success`, `warning` `danger`, `emergency`. `error` has been deprecated and support will be removed in a future release. Use `danger` instead */
37
40
  intent?: NysBadgeElement["intent"];
38
41
 
39
42
  /** Secondary label displayed before the main label. */
@@ -45,9 +48,6 @@ export interface NysBadgeProps extends Pick<
45
48
  /** Screen reader text appended after the label for additional context. */
46
49
  srText?: NysBadgeElement["srText"];
47
50
 
48
- /** undefined */
49
- variant?: NysBadgeElement["variant"];
50
-
51
51
  /** A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access specific elements via the class selectors or functions like the method `Document.getElementsByClassName()`. */
52
52
  className?: string;
53
53
 
@@ -3,6 +3,7 @@ import "../../dist/nysds.es.js";
3
3
 
4
4
  export const NysBadge = forwardRef((props, forwardedRef) => {
5
5
  const {
6
+ strong,
6
7
  prefixIcon,
7
8
  suffixIcon,
8
9
  id,
@@ -12,7 +13,6 @@ export const NysBadge = forwardRef((props, forwardedRef) => {
12
13
  prefixLabel,
13
14
  label,
14
15
  srText,
15
- variant,
16
16
  ...filteredProps
17
17
  } = props;
18
18
 
@@ -27,12 +27,12 @@ export const NysBadge = forwardRef((props, forwardedRef) => {
27
27
  prefixLabel: props.prefixLabel,
28
28
  label: props.label,
29
29
  srText: props.srText,
30
- variant: props.variant,
31
30
  class: props.className,
32
31
  exportparts: props.exportparts,
33
32
  for: props.htmlFor,
34
33
  part: props.part,
35
34
  tabindex: props.tabIndex,
35
+ strong: props.strong ? true : undefined,
36
36
  prefixicon: props.prefixIcon ? true : undefined,
37
37
  suffixicon: props.suffixIcon ? true : undefined,
38
38
  style: { ...props.style },
@@ -39,6 +39,9 @@ export interface NysUnavHeaderProps extends Pick<
39
39
  /** The URL endpoint of the search, make sure to include the query param. */
40
40
  searchUrl?: NysUnavHeaderElement["searchUrl"];
41
41
 
42
+ /** Localize project key. If provided, the component will load and initialize LocalizeJS automatically. */
43
+ translateKey?: NysUnavHeaderElement["translateKey"];
44
+
42
45
  /** Accessible name for the `banner` landmark this header renders.
43
46
  Defaults to `"New York State"`.
44
47
 
@@ -52,7 +55,7 @@ A blank value falls back to the default rather than leaving the landmark
52
55
  unnamed. */
53
56
  landmarkLabel?: NysUnavHeaderElement["landmarkLabel"];
54
57
 
55
- /** The list of languages this site can be translated to, default to use Smartling */
58
+ /** The list of languages this site can be translated to, default to use Localize */
56
59
  languages?: NysUnavHeaderElement["languages"];
57
60
 
58
61
  /** A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access specific elements via the class selectors or functions like the method `Document.getElementsByClassName()`. */
@@ -76,7 +79,7 @@ unnamed. */
76
79
  /** Allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the `Tab` key, hence the name) and determine their relative ordering for sequential focus navigation. */
77
80
  tabIndex?: number;
78
81
 
79
- /** Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Smartling redirect. */
82
+ /** Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Localize integration. */
80
83
  onNysLanguageSelect?: (event: CustomEvent) => void;
81
84
 
82
85
  /** Fired when a search is submitted. Detail: `{query}`. Cancelable; `preventDefault()` overrides the default search redirect. */
@@ -89,7 +92,7 @@ unnamed. */
89
92
  *
90
93
  *
91
94
  * ### **Events:**
92
- * - **nys-language-select** - Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Smartling redirect.
95
+ * - **nys-language-select** - Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Localize integration.
93
96
  * - **nys-search-submit** - Fired when a search is submitted. Detail: `{query}`. Cancelable; `preventDefault()` overrides the default search redirect.
94
97
  */
95
98
  export const NysUnavHeader: React.ForwardRefExoticComponent<NysUnavHeaderProps>;
@@ -12,6 +12,7 @@ export const NysUnavHeader = forwardRef((props, forwardedRef) => {
12
12
  hideTranslate,
13
13
  hideSearch,
14
14
  searchUrl,
15
+ translateKey,
15
16
  landmarkLabel,
16
17
  languages,
17
18
  ...filteredProps
@@ -34,6 +35,7 @@ export const NysUnavHeader = forwardRef((props, forwardedRef) => {
34
35
  },
35
36
  ...filteredProps,
36
37
  searchUrl: props.searchUrl,
38
+ translateKey: props.translateKey,
37
39
  landmarkLabel: props.landmarkLabel,
38
40
  languages: props.languages,
39
41
  class: props.className,
@@ -186,16 +186,16 @@ export type NysBadgeProps = {
186
186
  name?: string;
187
187
  /** Badge size: `sm` (smaller text) or `md` (default). */
188
188
  size?: "sm" | "md";
189
- /** Semantic intent affecting color: `neutral`, `error`, `success`, or `warning`. */
190
- intent?: "neutral" | "error" | "success" | "warning";
189
+ /** Semantic intent affecting color: `base`, `info`, `success`, `warning` `danger`, `emergency`. `error` has been deprecated and support will be removed in a future release. Use `danger` instead */
190
+ intent?: "base" | "info" | "success" | "warning" | "danger" | "error" | "emergency";
191
191
  /** Secondary label displayed before the main label. */
192
192
  prefixLabel?: string;
193
193
  /** Primary label text displayed in the badge. */
194
194
  label?: string;
195
195
  /** Screen reader text appended after the label for additional context. */
196
196
  srText?: string;
197
- /** */
198
- variant?: "strong" | "";
197
+ /** Strong visual intent with bolder text and background. */
198
+ strong?: boolean;
199
199
  /** */
200
200
  prefixicon?: string | boolean;
201
201
  /** */
@@ -1245,6 +1245,8 @@ export type NysUnavHeaderProps = {
1245
1245
  hideSearch?: boolean;
1246
1246
  /** The URL endpoint of the search, make sure to include the query param. */
1247
1247
  searchUrl?: string;
1248
+ /** Localize project key. If provided, the component will load and initialize LocalizeJS automatically. */
1249
+ translateKey?: string;
1248
1250
  /** Accessible name for the `banner` landmark this header renders.
1249
1251
  Defaults to `"New York State"`.
1250
1252
 
@@ -1257,10 +1259,10 @@ comes from that header's visible title.
1257
1259
  A blank value falls back to the default rather than leaving the landmark
1258
1260
  unnamed. */
1259
1261
  landmarkLabel?: string;
1260
- /** The list of languages this site can be translated to, default to use Smartling */
1262
+ /** The list of languages this site can be translated to, default to use Localize */
1261
1263
  languages?: Language[];
1262
1264
 
1263
- /** Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Smartling redirect. */
1265
+ /** Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Localize integration. */
1264
1266
  "onnys-language-select"?: (e: CustomEvent<never>) => void;
1265
1267
  /** Fired when a search is submitted. Detail: `{query}`. Cancelable; `preventDefault()` overrides the default search redirect. */
1266
1268
  "onnys-search-submit"?: (e: CustomEvent<never>) => void;
@@ -1957,7 +1959,7 @@ export type CustomElements = {
1957
1959
  *
1958
1960
  *
1959
1961
  * ### **Events:**
1960
- * - **nys-language-select** - Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Smartling redirect.
1962
+ * - **nys-language-select** - Fired when a language is selected. Detail: `{language: {code, label, url?}}`. Cancelable; `preventDefault()` overrides the default Localize integration.
1961
1963
  * - **nys-search-submit** - Fired when a search is submitted. Detail: `{query}`. Cancelable; `preventDefault()` overrides the default search redirect.
1962
1964
  */
1963
1965
  "nys-unavheader": Partial<NysUnavHeaderProps & BaseProps & BaseEvents>;