@genesislcap/foundation-ui 14.352.0 → 14.353.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.
@@ -14370,6 +14370,40 @@
14370
14370
  }
14371
14371
  ]
14372
14372
  },
14373
+ {
14374
+ "kind": "function",
14375
+ "name": "applyCustomTokens",
14376
+ "return": {
14377
+ "type": {
14378
+ "text": "void"
14379
+ }
14380
+ },
14381
+ "parameters": [
14382
+ {
14383
+ "name": "provider",
14384
+ "type": {
14385
+ "text": "HTMLElement"
14386
+ },
14387
+ "description": "The HTML element to set CSS variables on"
14388
+ },
14389
+ {
14390
+ "name": "customTokens",
14391
+ "type": {
14392
+ "text": "CustomTokensConfig"
14393
+ },
14394
+ "description": "The custom tokens object to process"
14395
+ },
14396
+ {
14397
+ "name": "prefix",
14398
+ "default": "''",
14399
+ "type": {
14400
+ "text": "string"
14401
+ },
14402
+ "description": "Internal prefix for nested keys (used during recursion)"
14403
+ }
14404
+ ],
14405
+ "description": "Converts custom tokens to CSS custom properties and sets them on the provider element.\nSupports nested token groups which are flattened into kebab-case CSS variable names.\n\nExample:\n Input: { spacing: { padding: { small: { $value: \"8px\" } } } }\n Output: --spacing-padding-small: 8px"
14406
+ },
14373
14407
  {
14374
14408
  "kind": "function",
14375
14409
  "name": "getDefaultConfig",
@@ -14465,6 +14499,14 @@
14465
14499
  "module": "src/design-system-provider/design-system-provider.utils.ts"
14466
14500
  }
14467
14501
  },
14502
+ {
14503
+ "kind": "js",
14504
+ "name": "applyCustomTokens",
14505
+ "declaration": {
14506
+ "name": "applyCustomTokens",
14507
+ "module": "src/design-system-provider/design-system-provider.utils.ts"
14508
+ }
14509
+ },
14468
14510
  {
14469
14511
  "kind": "js",
14470
14512
  "name": "getDefaultConfig",
@@ -2,11 +2,24 @@ import { PaletteRGB } from '@microsoft/fast-components';
2
2
  import { ValueConverter } from '@microsoft/fast-element';
3
3
  import { FoundationElement, FoundationElementDefinition } from '@microsoft/fast-foundation';
4
4
  import type { DesignToken } from '@microsoft/fast-foundation';
5
- import { DesignTokensConfig } from './types';
5
+ import { CustomTokensConfig, DesignTokensConfig } from './types';
6
6
  export declare const provideTokens: (tokens: any, values: any, element?: HTMLElement) => void;
7
7
  export declare function designToken<T>(token: DesignToken<T>): (source: FoundationElement, key: string) => void;
8
8
  export declare const swatchConverter: ValueConverter;
9
9
  export declare const paletteFromHex: (hexColor: string) => PaletteRGB;
10
+ /**
11
+ * Converts custom tokens to CSS custom properties and sets them on the provider element.
12
+ * Supports nested token groups which are flattened into kebab-case CSS variable names.
13
+ *
14
+ * Example:
15
+ * Input: { spacing: { padding: { small: { $value: "8px" } } } }
16
+ * Output: --spacing-padding-small: 8px
17
+ *
18
+ * @param provider - The HTML element to set CSS variables on
19
+ * @param customTokens - The custom tokens object to process
20
+ * @param prefix - Internal prefix for nested keys (used during recursion)
21
+ */
22
+ export declare const applyCustomTokens: (provider: HTMLElement, customTokens: CustomTokensConfig, prefix?: string) => void;
10
23
  export declare const getDefaultConfig: (definition: Partial<FoundationElementDefinition>, exclusions?: string[]) => {};
11
24
  export declare const getExports: (registrationFunction: any) => {
12
25
  shadowOptions: any;
@@ -1 +1 @@
1
- {"version":3,"file":"design-system-provider.utils.d.ts","sourceRoot":"","sources":["../../../src/design-system-provider/design-system-provider.utils.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EA6BX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,aAAa,GAAI,WAAM,EAAE,WAAM,EAAE,UAAU,WAAW,SAalE,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,IAC1C,QAAQ,iBAAiB,EAAE,KAAK,MAAM,UAa/C;AAED,eAAO,MAAM,eAAe,EAAE,cAe7B,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,eACc,CAAC;AAG9D,eAAO,MAAM,gBAAgB,GAC3B,YAAY,OAAO,CAAC,2BAA2B,CAAC,EAChD,qBAA8B,OAO/B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,yBAAoB;;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,cAAc,MAAM,EAAE,OAAO,MAAM,WAOnE,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,UAAU,WAAW,EAAE,QAAQ,kBAAkB,SAuFtF,CAAC"}
1
+ {"version":3,"file":"design-system-provider.utils.d.ts","sourceRoot":"","sources":["../../../src/design-system-provider/design-system-provider.utils.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EA6BX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,aAAa,GAAI,WAAM,EAAE,WAAM,EAAE,UAAU,WAAW,SAalE,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,IAC1C,QAAQ,iBAAiB,EAAE,KAAK,MAAM,UAa/C;AAED,eAAO,MAAM,eAAe,EAAE,cAe7B,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,eACc,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,WAAW,EACrB,cAAc,kBAAkB,EAChC,SAAQ,MAAW,KAClB,IAcF,CAAC;AAGF,eAAO,MAAM,gBAAgB,GAC3B,YAAY,OAAO,CAAC,2BAA2B,CAAC,EAChD,qBAA8B,OAO/B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,yBAAoB;;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,cAAc,MAAM,EAAE,OAAO,MAAM,WAOnE,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,UAAU,WAAW,EAAE,QAAQ,kBAAkB,SA4FtF,CAAC"}
@@ -1,3 +1,18 @@
1
+ type TokenValue = string | number | boolean;
2
+ interface DesignToken {
3
+ $value: TokenValue;
4
+ $type?: string;
5
+ }
6
+ /**
7
+ * Custom tokens can be either a token value or nested token groups.
8
+ * This allows for arbitrary nesting depth (e.g., spacing.padding.small)
9
+ */
10
+ type CustomTokenValue = DesignToken | {
11
+ [key: string]: CustomTokenValue;
12
+ };
13
+ export interface CustomTokensConfig {
14
+ [key: string]: CustomTokenValue;
15
+ }
1
16
  export interface DesignTokensConfig {
2
17
  design_tokens: {
3
18
  color: {
@@ -53,5 +68,7 @@ export interface DesignTokensConfig {
53
68
  };
54
69
  };
55
70
  };
71
+ customTokens?: CustomTokensConfig;
56
72
  }
73
+ export {};
57
74
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/design-system-provider/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE;QACb,KAAK,EAAE;YACL,MAAM,EAAE;gBACN,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;YACF,OAAO,EAAE;gBACP,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,UAAU,EAAE;YACV,YAAY,EAAE;gBACZ,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;YACF,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,KAAK,EAAE;YACL,OAAO,EAAE;gBACP,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;YACF,YAAY,EAAE;gBACZ,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;YACF,WAAW,EAAE;gBACX,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,KAAK,EAAE;YACL,UAAU,EAAE;gBACV,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;KACH,CAAC;CACH"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/design-system-provider/types.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5C,UAAU,WAAW;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,KAAK,gBAAgB,GACjB,WAAW,GACX;IACE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACjC,CAAC;AAEN,MAAM,WAAW,kBAAkB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACjC;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE;QACb,KAAK,EAAE;YACL,MAAM,EAAE;gBACN,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;YACF,OAAO,EAAE;gBACP,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,UAAU,EAAE;YACV,YAAY,EAAE;gBACZ,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;YACF,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,KAAK,EAAE;YACL,OAAO,EAAE;gBACP,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;YACF,YAAY,EAAE;gBACZ,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;YACF,WAAW,EAAE;gBACX,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,KAAK,EAAE;YACL,UAAU,EAAE;gBACV,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;KACH,CAAC;IACF,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC"}
@@ -40,6 +40,33 @@ export const swatchConverter = {
40
40
  },
41
41
  };
42
42
  export const paletteFromHex = (hexColor) => PaletteRGB.from(SwatchRGB.from(parseColorHexRGB(hexColor)));
43
+ /**
44
+ * Converts custom tokens to CSS custom properties and sets them on the provider element.
45
+ * Supports nested token groups which are flattened into kebab-case CSS variable names.
46
+ *
47
+ * Example:
48
+ * Input: { spacing: { padding: { small: { $value: "8px" } } } }
49
+ * Output: --spacing-padding-small: 8px
50
+ *
51
+ * @param provider - The HTML element to set CSS variables on
52
+ * @param customTokens - The custom tokens object to process
53
+ * @param prefix - Internal prefix for nested keys (used during recursion)
54
+ */
55
+ export const applyCustomTokens = (provider, customTokens, prefix = '') => {
56
+ Object.entries(customTokens).forEach(([key, value]) => {
57
+ const cssVarName = prefix ? `${prefix}-${key}` : key;
58
+ if (value && typeof value === 'object') {
59
+ // If it has $value, this is a leaf token - set it as CSS variable
60
+ if ('$value' in value) {
61
+ provider.style.setProperty(`--${cssVarName}`, String(value.$value));
62
+ }
63
+ else {
64
+ // Otherwise, it's a token group - recurse into nested structure
65
+ applyCustomTokens(provider, value, cssVarName);
66
+ }
67
+ }
68
+ });
69
+ };
43
70
  const defaultExclusions = ['baseClass', 'baseName', 'shadowOptions', 'styles', 'template'];
44
71
  export const getDefaultConfig = (definition, exclusions = defaultExclusions) => {
45
72
  const keys = Object.keys(definition).filter((k) => !exclusions.includes(k));
@@ -92,4 +119,8 @@ export const configureDesignSystem = (provider, config) => {
92
119
  typeRampPlus5LineHeight.setValueFor(provider, getTypeRampValue(baseLineHeight, TypeRampValues.plusFive));
93
120
  typeRampPlus6FontSize.setValueFor(provider, getTypeRampValue(baseFontSize, TypeRampValues.plusSix));
94
121
  typeRampPlus6LineHeight.setValueFor(provider, getTypeRampValue(baseLineHeight, TypeRampValues.plusSix));
122
+ // Apply custom tokens if provided
123
+ if (config.customTokens) {
124
+ applyCustomTokens(provider, config.customTokens);
125
+ }
95
126
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-ui",
3
3
  "description": "Genesis Foundation UI",
4
- "version": "14.352.0",
4
+ "version": "14.353.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -83,13 +83,13 @@
83
83
  }
84
84
  },
85
85
  "devDependencies": {
86
- "@genesislcap/foundation-testing": "14.352.0",
87
- "@genesislcap/genx": "14.352.0",
88
- "@genesislcap/rollup-builder": "14.352.0",
89
- "@genesislcap/ts-builder": "14.352.0",
90
- "@genesislcap/uvu-playwright-builder": "14.352.0",
91
- "@genesislcap/vite-builder": "14.352.0",
92
- "@genesislcap/webpack-builder": "14.352.0",
86
+ "@genesislcap/foundation-testing": "14.353.0",
87
+ "@genesislcap/genx": "14.353.0",
88
+ "@genesislcap/rollup-builder": "14.353.0",
89
+ "@genesislcap/ts-builder": "14.353.0",
90
+ "@genesislcap/uvu-playwright-builder": "14.353.0",
91
+ "@genesislcap/vite-builder": "14.353.0",
92
+ "@genesislcap/webpack-builder": "14.353.0",
93
93
  "copyfiles": "^2.4.1"
94
94
  },
95
95
  "dependencies": {
@@ -98,15 +98,15 @@
98
98
  "@fortawesome/free-regular-svg-icons": "^6.2.1",
99
99
  "@fortawesome/free-solid-svg-icons": "^6.2.1",
100
100
  "@genesiscommunitysuccess/analyzer-import-alias-plugin": "^5.0.3",
101
- "@genesislcap/expression-builder": "14.352.0",
102
- "@genesislcap/foundation-comms": "14.352.0",
103
- "@genesislcap/foundation-criteria": "14.352.0",
104
- "@genesislcap/foundation-errors": "14.352.0",
105
- "@genesislcap/foundation-events": "14.352.0",
106
- "@genesislcap/foundation-logger": "14.352.0",
107
- "@genesislcap/foundation-notifications": "14.352.0",
108
- "@genesislcap/foundation-user": "14.352.0",
109
- "@genesislcap/foundation-utils": "14.352.0",
101
+ "@genesislcap/expression-builder": "14.353.0",
102
+ "@genesislcap/foundation-comms": "14.353.0",
103
+ "@genesislcap/foundation-criteria": "14.353.0",
104
+ "@genesislcap/foundation-errors": "14.353.0",
105
+ "@genesislcap/foundation-events": "14.353.0",
106
+ "@genesislcap/foundation-logger": "14.353.0",
107
+ "@genesislcap/foundation-notifications": "14.353.0",
108
+ "@genesislcap/foundation-user": "14.353.0",
109
+ "@genesislcap/foundation-utils": "14.353.0",
110
110
  "@microsoft/fast-colors": "5.3.1",
111
111
  "@microsoft/fast-components": "2.30.6",
112
112
  "@microsoft/fast-element": "1.14.0",
@@ -128,5 +128,5 @@
128
128
  "access": "public"
129
129
  },
130
130
  "customElements": "dist/custom-elements.json",
131
- "gitHead": "3d8a323fd4989f7862d640f7a66b5c206bb7ebea"
131
+ "gitHead": "056526f2c5983b54024fe6fcdeb7c6e83e0e5cb3"
132
132
  }