@servicetitan/hammer-token 2.5.2 → 3.0.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 (146) hide show
  1. package/CHANGELOG.md +52 -2
  2. package/README.md +332 -0
  3. package/build/web/core/component-variables.scss +1088 -131
  4. package/build/web/core/component.d.ts +558 -0
  5. package/build/web/core/component.js +6685 -249
  6. package/build/web/core/component.scss +557 -69
  7. package/build/web/core/css-utils/a2-border.css +23 -51
  8. package/build/web/core/css-utils/a2-color.css +221 -233
  9. package/build/web/core/css-utils/a2-font.css +1 -29
  10. package/build/web/core/css-utils/a2-spacing.css +238 -483
  11. package/build/web/core/css-utils/a2-utils.css +496 -781
  12. package/build/web/core/css-utils/border.css +23 -51
  13. package/build/web/core/css-utils/color.css +221 -233
  14. package/build/web/core/css-utils/font.css +1 -29
  15. package/build/web/core/css-utils/spacing.css +238 -483
  16. package/build/web/core/css-utils/utils.css +496 -781
  17. package/build/web/core/index.d.ts +6 -0
  18. package/build/web/core/index.js +1 -1
  19. package/build/web/core/primitive-variables.scss +148 -65
  20. package/build/web/core/primitive.d.ts +209 -0
  21. package/build/web/core/primitive.js +779 -61
  22. package/build/web/core/primitive.scss +207 -124
  23. package/build/web/core/semantic-variables.scss +363 -245
  24. package/build/web/core/semantic.d.ts +221 -0
  25. package/build/web/core/semantic.js +1592 -347
  26. package/build/web/core/semantic.scss +219 -140
  27. package/build/web/index.d.ts +3 -4
  28. package/build/web/types.d.ts +17 -0
  29. package/config.js +121 -496
  30. package/eslint.config.mjs +11 -1
  31. package/package.json +15 -5
  32. package/src/global/primitive/breakpoint.tokens.json +54 -0
  33. package/src/global/primitive/color.tokens.json +1092 -0
  34. package/src/global/primitive/duration.tokens.json +44 -0
  35. package/src/global/primitive/font.tokens.json +151 -0
  36. package/src/global/primitive/radius.tokens.json +94 -0
  37. package/src/global/primitive/size.tokens.json +174 -0
  38. package/src/global/primitive/transition.tokens.json +32 -0
  39. package/src/theme/core/background.tokens.json +1312 -0
  40. package/src/theme/core/border.tokens.json +192 -0
  41. package/src/theme/core/chart.tokens.json +982 -0
  42. package/src/theme/core/component/ai-mark.tokens.json +20 -0
  43. package/src/theme/core/component/alert.tokens.json +261 -0
  44. package/src/theme/core/component/announcement.tokens.json +460 -0
  45. package/src/theme/core/component/avatar.tokens.json +137 -0
  46. package/src/theme/core/component/badge.tokens.json +42 -0
  47. package/src/theme/core/component/breadcrumb.tokens.json +42 -0
  48. package/src/theme/core/component/button-toggle.tokens.json +428 -0
  49. package/src/theme/core/component/button.tokens.json +941 -0
  50. package/src/theme/core/component/calendar.tokens.json +391 -0
  51. package/src/theme/core/component/card.tokens.json +107 -0
  52. package/src/theme/core/component/checkbox.tokens.json +631 -0
  53. package/src/theme/core/component/chip.tokens.json +169 -0
  54. package/src/theme/core/component/combobox.tokens.json +269 -0
  55. package/src/theme/core/component/details.tokens.json +152 -0
  56. package/src/theme/core/component/dialog.tokens.json +87 -0
  57. package/src/theme/core/component/divider.tokens.json +23 -0
  58. package/src/theme/core/component/dnd.tokens.json +208 -0
  59. package/src/theme/core/component/drawer.tokens.json +61 -0
  60. package/src/theme/core/component/drilldown.tokens.json +61 -0
  61. package/src/theme/core/component/edit-card.tokens.json +381 -0
  62. package/src/theme/core/component/field-label.tokens.json +42 -0
  63. package/src/theme/core/component/field-message.tokens.json +65 -0
  64. package/src/theme/core/component/icon.tokens.json +42 -0
  65. package/src/theme/core/component/link.tokens.json +108 -0
  66. package/src/theme/core/component/list-view.tokens.json +82 -0
  67. package/src/theme/core/component/listbox.tokens.json +283 -0
  68. package/src/theme/core/component/menu.tokens.json +230 -0
  69. package/src/theme/core/component/overflow.tokens.json +84 -0
  70. package/src/theme/core/component/page.tokens.json +377 -0
  71. package/src/theme/core/component/pagination.tokens.json +63 -0
  72. package/src/theme/core/component/popover.tokens.json +122 -0
  73. package/src/theme/core/component/progress-bar.tokens.json +133 -0
  74. package/src/theme/core/component/radio.tokens.json +631 -0
  75. package/src/theme/core/component/segmented-control.tokens.json +175 -0
  76. package/src/theme/core/component/select-card.tokens.json +943 -0
  77. package/src/theme/core/component/side-nav.tokens.json +349 -0
  78. package/src/theme/core/component/skeleton.tokens.json +42 -0
  79. package/src/theme/core/component/spinner.tokens.json +96 -0
  80. package/src/theme/core/component/status-icon.tokens.json +164 -0
  81. package/src/theme/core/component/stepper.tokens.json +484 -0
  82. package/src/theme/core/component/switch.tokens.json +285 -0
  83. package/src/theme/core/component/tab.tokens.json +192 -0
  84. package/src/theme/core/component/text-field.tokens.json +160 -0
  85. package/src/theme/core/component/text.tokens.json +59 -0
  86. package/src/theme/core/component/toast.tokens.json +343 -0
  87. package/src/theme/core/component/toolbar.tokens.json +114 -0
  88. package/src/theme/core/component/tooltip.tokens.json +61 -0
  89. package/src/theme/core/focus.tokens.json +56 -0
  90. package/src/theme/core/foreground.tokens.json +416 -0
  91. package/src/theme/core/gradient.tokens.json +41 -0
  92. package/src/theme/core/opacity.tokens.json +25 -0
  93. package/src/theme/core/shadow.tokens.json +81 -0
  94. package/src/theme/core/status.tokens.json +74 -0
  95. package/src/theme/core/typography.tokens.json +163 -0
  96. package/src/utils/__tests__/css-utils-format-utils.test.js +312 -0
  97. package/src/utils/__tests__/sd-build-configs.test.js +306 -0
  98. package/src/utils/__tests__/sd-formats.test.js +942 -0
  99. package/src/utils/__tests__/sd-transforms.test.js +336 -0
  100. package/src/utils/__tests__/token-helpers.test.js +1160 -0
  101. package/src/utils/copy-css-utils-cli.js +13 -1
  102. package/src/utils/css-utils-format-utils.js +105 -176
  103. package/src/utils/figma/__tests__/sync-gradient.test.js +561 -0
  104. package/src/utils/figma/__tests__/token-conversion.test.js +117 -0
  105. package/src/utils/figma/__tests__/token-resolution.test.js +231 -0
  106. package/src/utils/figma/auth.js +355 -0
  107. package/src/utils/figma/constants.js +22 -0
  108. package/src/utils/figma/errors.js +80 -0
  109. package/src/utils/figma/figma-api.js +1069 -0
  110. package/src/utils/figma/get-token.js +348 -0
  111. package/src/utils/figma/sync-components.js +909 -0
  112. package/src/utils/figma/sync-main.js +692 -0
  113. package/src/utils/figma/sync-orchestration.js +683 -0
  114. package/src/utils/figma/sync-primitives.js +230 -0
  115. package/src/utils/figma/sync-semantic.js +1056 -0
  116. package/src/utils/figma/token-conversion.js +340 -0
  117. package/src/utils/figma/token-parsing.js +186 -0
  118. package/src/utils/figma/token-resolution.js +569 -0
  119. package/src/utils/figma/utils.js +199 -0
  120. package/src/utils/sd-build-configs.js +305 -0
  121. package/src/utils/sd-formats.js +948 -0
  122. package/src/utils/sd-transforms.js +165 -0
  123. package/src/utils/token-helpers.js +848 -0
  124. package/tsconfig.json +18 -0
  125. package/vitest.config.js +17 -0
  126. package/.turbo/turbo-build.log +0 -37
  127. package/build/web/core/raw.js +0 -234
  128. package/src/global/primitive/breakpoint.js +0 -19
  129. package/src/global/primitive/color.js +0 -231
  130. package/src/global/primitive/duration.js +0 -16
  131. package/src/global/primitive/font.js +0 -60
  132. package/src/global/primitive/radius.js +0 -31
  133. package/src/global/primitive/size.js +0 -55
  134. package/src/global/primitive/transition.js +0 -16
  135. package/src/theme/core/background.js +0 -170
  136. package/src/theme/core/border.js +0 -103
  137. package/src/theme/core/charts.js +0 -464
  138. package/src/theme/core/component/button.js +0 -708
  139. package/src/theme/core/component/checkbox.js +0 -405
  140. package/src/theme/core/focus.js +0 -35
  141. package/src/theme/core/foreground.js +0 -148
  142. package/src/theme/core/overlay.js +0 -137
  143. package/src/theme/core/shadow.js +0 -29
  144. package/src/theme/core/status.js +0 -49
  145. package/src/theme/core/typography.js +0 -82
  146. package/type/types.ts +0 -344
@@ -0,0 +1,199 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Utility Functions for Figma Sync
5
+ *
6
+ * Common utility functions for validation, token masking, and other helpers.
7
+ */
8
+
9
+ /**
10
+ * Mask a token for safe logging (shows first 8 chars and last 4 chars)
11
+ * @param {string} token - Token to mask
12
+ * @returns {string} Masked token
13
+ */
14
+ function maskToken(token) {
15
+ if (!token || typeof token !== "string") {
16
+ return "***";
17
+ }
18
+ if (token.length <= 12) {
19
+ return "***";
20
+ }
21
+ return token.substring(0, 8) + "..." + token.substring(token.length - 4);
22
+ }
23
+
24
+ /**
25
+ * Validate fileKey format
26
+ * @param {string} fileKey - Figma file key to validate
27
+ * @returns {boolean} True if valid
28
+ * @throws {Error} If fileKey is invalid
29
+ */
30
+ function validateFileKey(fileKey) {
31
+ if (!fileKey || typeof fileKey !== "string") {
32
+ throw new Error("File key must be a non-empty string");
33
+ }
34
+
35
+ // Figma file keys are typically 15-30 alphanumeric characters
36
+ if (!/^[a-zA-Z0-9]{15,30}$/.test(fileKey)) {
37
+ throw new Error(
38
+ `Invalid file key format: ${fileKey}. Expected 15-30 alphanumeric characters.`,
39
+ );
40
+ }
41
+
42
+ return true;
43
+ }
44
+
45
+ /**
46
+ * Parse CLI arguments into options object
47
+ * @param {Array<string>} args - Command line arguments
48
+ * @returns {Object} Parsed options
49
+ */
50
+ function parseCliArgs(args) {
51
+ const options = {
52
+ command: null,
53
+ fileKey: null,
54
+ dryRun: false,
55
+ verbose: false,
56
+ full: false,
57
+ };
58
+
59
+ let i = 0;
60
+ while (i < args.length) {
61
+ const arg = args[i];
62
+
63
+ // Handle flags
64
+ if (arg === "--file-key" || arg === "-f") {
65
+ if (i + 1 < args.length) {
66
+ options.fileKey = args[i + 1];
67
+ i += 2;
68
+ continue;
69
+ } else {
70
+ throw new Error(`Missing value for ${arg}`);
71
+ }
72
+ }
73
+
74
+ if (arg === "--dry-run") {
75
+ options.dryRun = true;
76
+ i++;
77
+ continue;
78
+ }
79
+
80
+ if (arg === "--verbose" || arg === "-v") {
81
+ options.verbose = true;
82
+ i++;
83
+ continue;
84
+ }
85
+
86
+ if (arg === "--full") {
87
+ options.full = true;
88
+ i++;
89
+ continue;
90
+ }
91
+
92
+ // Handle commands
93
+ if (arg === "sync" || arg === "test" || arg === "validate") {
94
+ options.command = arg;
95
+ i++;
96
+ continue;
97
+ }
98
+
99
+ // Handle test:file command
100
+ if (arg === "test:file") {
101
+ options.command = "test:file";
102
+ if (i + 1 < args.length) {
103
+ options.fileKey = args[i + 1];
104
+ i += 2;
105
+ continue;
106
+ } else {
107
+ throw new Error("test:file requires a fileKey argument");
108
+ }
109
+ }
110
+
111
+ // Legacy: file command
112
+ if (arg === "file" || arg === "--file") {
113
+ if (i + 1 < args.length) {
114
+ options.fileKey = args[i + 1];
115
+ options.command = "file";
116
+ i += 2;
117
+ continue;
118
+ } else {
119
+ throw new Error("file command requires a fileKey argument");
120
+ }
121
+ }
122
+
123
+ // Legacy: If it looks like a fileKey and we don't have one, use it
124
+ if (!options.fileKey && /^[a-zA-Z0-9]{15,30}$/.test(arg)) {
125
+ options.fileKey = arg;
126
+ i++;
127
+ continue;
128
+ }
129
+
130
+ // Unknown argument
131
+ i++;
132
+ }
133
+
134
+ return options;
135
+ }
136
+
137
+ /**
138
+ * Format duration in milliseconds to human-readable string
139
+ * @param {number} ms - Duration in milliseconds
140
+ * @returns {string} Formatted duration
141
+ */
142
+ function formatDuration(ms) {
143
+ if (ms < 1000) {
144
+ return `${ms}ms`;
145
+ }
146
+ if (ms < 60000) {
147
+ return `${(ms / 1000).toFixed(2)}s`;
148
+ }
149
+ const minutes = Math.floor(ms / 60000);
150
+ const seconds = ((ms % 60000) / 1000).toFixed(2);
151
+ return `${minutes}m ${seconds}s`;
152
+ }
153
+
154
+ /**
155
+ * Print help text
156
+ */
157
+ function printHelp() {
158
+ console.log(`
159
+ Figma Variables Sync - Usage
160
+
161
+ Commands:
162
+ sync Sync tokens to Figma (default)
163
+ test Test Figma API access
164
+ test:file <fileKey> Test access to a specific Figma file
165
+ validate Validate token files without syncing
166
+ file <fileKey> Legacy: Sync to specific file
167
+
168
+ Options:
169
+ -f, --file-key <key> Figma file key (overrides env/config)
170
+ --dry-run Validate without making changes
171
+ --verbose, -v Enable verbose logging
172
+ --full Run full test suite (for test commands)
173
+ --help, -h Show this help message
174
+
175
+ Examples:
176
+ pnpm figma:sync
177
+ pnpm figma:sync --file-key <fileKey>
178
+ pnpm figma:sync --dry-run
179
+ pnpm figma:test
180
+ pnpm figma:test:file rBPlrqjRiS8vxfY3IsNfZB
181
+ pnpm figma:test:file rBPlrqjRiS8vxfY3IsNfZB --full
182
+ pnpm figma:validate
183
+
184
+ Environment Variables:
185
+ FIGMA_CLIENT_ID OAuth2 client ID
186
+ FIGMA_CLIENT_SECRET OAuth2 client secret
187
+ FIGMA_REFRESH_TOKEN OAuth2 refresh token
188
+ FIGMA_FILE_KEY Default Figma file key
189
+ DEBUG Enable debug logging
190
+ `);
191
+ }
192
+
193
+ module.exports = {
194
+ maskToken,
195
+ validateFileKey,
196
+ parseCliArgs,
197
+ formatDuration,
198
+ printHelp,
199
+ };
@@ -0,0 +1,305 @@
1
+ /**
2
+ * Style Dictionary build configurations
3
+ * @module sd-build-configs
4
+ */
5
+ const { getTokenName } = require("./token-helpers");
6
+
7
+ /**
8
+ * CSS Utils prefixes for generating utility class variants
9
+ * @constant {string[]}
10
+ */
11
+ const CSS_UTILS_PREFIXES = ["", "a2-"];
12
+
13
+ /**
14
+ * Filters tokens to include only semantic tokens (excludes primitive and component tokens).
15
+ * @param {Object} token - The token object from Style Dictionary
16
+ * @returns {boolean} True if the token is a semantic token
17
+ */
18
+ const isSemanticToken = (token) => {
19
+ if (!token.filePath) return true;
20
+ return (
21
+ !token.filePath.includes("primitive") &&
22
+ !token.filePath.includes("/component/")
23
+ );
24
+ };
25
+
26
+ /**
27
+ * Filters tokens to include only component tokens.
28
+ * @param {Object} token - The token object from Style Dictionary
29
+ * @returns {boolean} True if the token is a component token
30
+ */
31
+ const isComponentToken = (token) =>
32
+ token.filePath && token.filePath.includes("/component/");
33
+
34
+ /**
35
+ * Creates a platform configuration for Style Dictionary.
36
+ * @param {Object} options - Platform configuration options
37
+ * @param {string} options.buildPath - Output directory path for built files
38
+ * @param {Array<Object>} options.files - Array of file configurations with destination and format
39
+ * @returns {Object} Platform configuration object
40
+ */
41
+ const createPlatform = ({ buildPath, files }) => ({
42
+ transformGroup: "dtcg",
43
+ options: {
44
+ usesDtcg: true,
45
+ },
46
+ buildPath,
47
+ files,
48
+ });
49
+
50
+ /**
51
+ * Creates CSS utility file configurations for a given class prefix.
52
+ * Generates configurations for all utils, colors, fonts, and spacing.
53
+ * Note: borders are only in the semantic build (createSemanticCssUtilsFiles).
54
+ * @param {string} prefix - CSS class prefix (e.g., '' or 'a2-')
55
+ * @returns {Array<Object>} Array of file configurations for CSS utilities
56
+ */
57
+ const createCssUtilsFiles = (prefix) => [
58
+ {
59
+ destination: `${prefix}utils.css`,
60
+ format: `custom/CSSUtils/${prefix}All`,
61
+ },
62
+ {
63
+ destination: `${prefix}color.css`,
64
+ format: `custom/CSSUtils/${prefix}Colors`,
65
+ filter: (token) => {
66
+ const name = getTokenName(token);
67
+ return name && name.startsWith("color");
68
+ },
69
+ },
70
+ {
71
+ destination: `${prefix}font.css`,
72
+ format: `custom/CSSUtils/${prefix}Fonts`,
73
+ filter: (token) => {
74
+ const name = getTokenName(token);
75
+ return name && name.startsWith("font");
76
+ },
77
+ },
78
+ {
79
+ destination: `${prefix}spacing.css`,
80
+ format: `custom/CSSUtils/${prefix}Spacing`,
81
+ filter: (token) => {
82
+ const name = getTokenName(token);
83
+ return name && name.startsWith("size");
84
+ },
85
+ },
86
+ ];
87
+
88
+ /**
89
+ * Creates CSS utility file configurations for semantic tokens with a given class prefix.
90
+ * Similar to createCssUtilsFiles but with filters appropriate for semantic token naming.
91
+ * @param {string} prefix - CSS class prefix (e.g., '' or 'a2-')
92
+ * @returns {Array<Object>} Array of file configurations for semantic CSS utilities
93
+ * @example
94
+ * createSemanticCssUtilsFiles('a2-')
95
+ */
96
+ const createSemanticCssUtilsFiles = (prefix) => [
97
+ {
98
+ destination: `${prefix}utils.css`,
99
+ format: `custom/CSSUtils/${prefix}All`,
100
+ filter: () => true,
101
+ },
102
+ {
103
+ destination: `${prefix}border.css`,
104
+ format: `custom/CSSUtils/${prefix}Borders`,
105
+ filter: (token) => {
106
+ const name = getTokenName(token);
107
+ return name && name.includes("border");
108
+ },
109
+ },
110
+ {
111
+ destination: `${prefix}color.css`,
112
+ format: `custom/CSSUtils/${prefix}Colors`,
113
+ filter: (token) => {
114
+ const name = getTokenName(token);
115
+ return (
116
+ name &&
117
+ (name.includes("color") ||
118
+ name.includes("status-color") ||
119
+ name.includes("foreground-color") ||
120
+ name.includes("background-color") ||
121
+ name.includes("overlay-color"))
122
+ );
123
+ },
124
+ },
125
+ {
126
+ destination: `${prefix}font.css`,
127
+ format: `custom/CSSUtils/${prefix}Fonts`,
128
+ filter: (token) => {
129
+ const name = getTokenName(token);
130
+ return name && name.includes("typography");
131
+ },
132
+ },
133
+ {
134
+ destination: `${prefix}spacing.css`,
135
+ format: `custom/CSSUtils/${prefix}Spacing`,
136
+ filter: (token) => {
137
+ const name = getTokenName(token);
138
+ return name && name.startsWith("size");
139
+ },
140
+ },
141
+ ];
142
+
143
+ /**
144
+ * Creates the Style Dictionary configuration for primitive tokens.
145
+ * Primitive tokens are the foundational design values (colors, sizes, etc.).
146
+ * @returns {Object} Style Dictionary configuration object for primitive tokens
147
+ * @example
148
+ * const StyleDictionary = require('style-dictionary');
149
+ * const config = createPrimitiveConfig();
150
+ * const sd = new StyleDictionary(config);
151
+ */
152
+ const createPrimitiveConfig = () => ({
153
+ log: {
154
+ verbosity: "verbose",
155
+ },
156
+ preprocessors: ["dtcg/set-token-names"],
157
+ source: ["src/global/primitive/*.tokens.json"],
158
+ platforms: {
159
+ scss: createPlatform({
160
+ buildPath: "build/web/core/",
161
+ files: [
162
+ {
163
+ destination: "primitive.scss",
164
+ format: "custom/scss-variables",
165
+ },
166
+ {
167
+ destination: "primitive-variables.scss",
168
+ format: "custom/scss-variables-map",
169
+ },
170
+ ],
171
+ }),
172
+ js: createPlatform({
173
+ buildPath: "build/web/core/",
174
+ files: [
175
+ {
176
+ destination: "primitive.js",
177
+ format: "custom/es6-variable",
178
+ },
179
+ ],
180
+ }),
181
+ css: createPlatform({
182
+ buildPath: "build/web/core/css-utils/",
183
+ files: CSS_UTILS_PREFIXES.flatMap((prefix) =>
184
+ createCssUtilsFiles(prefix),
185
+ ),
186
+ }),
187
+ },
188
+ });
189
+
190
+ /**
191
+ * Creates the Style Dictionary configuration for theme tokens.
192
+ * Theme tokens include semantic tokens that reference primitives, excluding component tokens.
193
+ * @returns {Object} Style Dictionary configuration object for theme tokens
194
+ * @example
195
+ * const StyleDictionary = require('style-dictionary');
196
+ * const config = createThemeConfig();
197
+ * const sd = new StyleDictionary(config);
198
+ */
199
+ const createThemeConfig = () => ({
200
+ log: {
201
+ verbosity: "verbose",
202
+ errors: {
203
+ brokenReferences: "warn",
204
+ },
205
+ },
206
+ preprocessors: ["dtcg/set-token-names"],
207
+ include: [
208
+ "src/global/primitive/*.tokens.json",
209
+ "src/theme/core/status.tokens.json",
210
+ ],
211
+ source: ["src/theme/**/*.tokens.json"],
212
+ platforms: {
213
+ scss: createPlatform({
214
+ buildPath: "build/web/core/",
215
+ files: [
216
+ {
217
+ destination: "semantic.scss",
218
+ format: "custom/scss-variables",
219
+ filter: isSemanticToken,
220
+ },
221
+ {
222
+ destination: "semantic-variables.scss",
223
+ format: "custom/scss-variables-map",
224
+ filter: isSemanticToken,
225
+ },
226
+ ],
227
+ }),
228
+ js: createPlatform({
229
+ buildPath: "build/web/core/",
230
+ files: [
231
+ {
232
+ destination: "semantic.js",
233
+ format: "custom/es6-variable",
234
+ filter: isSemanticToken,
235
+ },
236
+ ],
237
+ }),
238
+ css: createPlatform({
239
+ buildPath: "build/web/core/css-utils/",
240
+ files: CSS_UTILS_PREFIXES.flatMap((prefix) =>
241
+ createSemanticCssUtilsFiles(prefix),
242
+ ),
243
+ }),
244
+ },
245
+ });
246
+
247
+ /**
248
+ * Creates the Style Dictionary configuration for component tokens.
249
+ * Component tokens are specific to UI components and reference theme/primitive tokens.
250
+ * @returns {Object} Style Dictionary configuration object for component tokens
251
+ * @example
252
+ * const StyleDictionary = require('style-dictionary');
253
+ * const config = createComponentConfig();
254
+ * const sd = new StyleDictionary(config);
255
+ */
256
+ const createComponentConfig = () => ({
257
+ usesDtcg: true,
258
+ log: {
259
+ verbosity: "verbose",
260
+ errors: {
261
+ brokenReferences: "warn",
262
+ },
263
+ },
264
+ preprocessors: ["dtcg/set-token-names"],
265
+ include: [
266
+ "src/global/primitive/*.tokens.json",
267
+ "src/theme/core/*.tokens.json",
268
+ ],
269
+ source: ["src/theme/core/component/*.tokens.json"],
270
+ platforms: {
271
+ scss: createPlatform({
272
+ buildPath: "build/web/core/",
273
+ files: [
274
+ {
275
+ destination: "component.scss",
276
+ format: "custom/scss-variables",
277
+ filter: isComponentToken,
278
+ },
279
+ {
280
+ destination: "component-variables.scss",
281
+ format: "custom/scss-variables-map",
282
+ filter: isComponentToken,
283
+ },
284
+ ],
285
+ }),
286
+ js: createPlatform({
287
+ buildPath: "build/web/core/",
288
+ files: [
289
+ {
290
+ destination: "component.js",
291
+ format: "custom/es6-variable",
292
+ filter: isComponentToken,
293
+ },
294
+ ],
295
+ }),
296
+ },
297
+ });
298
+
299
+ module.exports = {
300
+ createPrimitiveConfig,
301
+ createThemeConfig,
302
+ createComponentConfig,
303
+ isSemanticToken,
304
+ isComponentToken,
305
+ };