@servicetitan/hammer-token 0.0.0-rc-1.48.0-20251104214834 → 0.0.0-rc-3.0.0-20260127161418

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 (80) hide show
  1. package/CHANGELOG.md +37 -1
  2. package/README.md +222 -0
  3. package/build/web/core/component-variables.scss +176 -130
  4. package/build/web/core/component.d.ts +96 -0
  5. package/build/web/core/component.js +574 -252
  6. package/build/web/core/component.scss +94 -69
  7. package/build/web/core/css-utils/a2-border.css +39 -41
  8. package/build/web/core/css-utils/a2-color.css +367 -227
  9. package/build/web/core/css-utils/a2-font.css +0 -2
  10. package/build/web/core/css-utils/a2-spacing.css +0 -2
  11. package/build/web/core/css-utils/a2-utils.css +434 -292
  12. package/build/web/core/css-utils/border.css +39 -41
  13. package/build/web/core/css-utils/color.css +367 -227
  14. package/build/web/core/css-utils/font.css +0 -2
  15. package/build/web/core/css-utils/spacing.css +0 -2
  16. package/build/web/core/css-utils/utils.css +434 -292
  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 +130 -71
  20. package/build/web/core/primitive.d.ts +185 -0
  21. package/build/web/core/primitive.js +328 -72
  22. package/build/web/core/primitive.scss +183 -124
  23. package/build/web/core/semantic-variables.scss +295 -220
  24. package/build/web/core/semantic.d.ts +198 -0
  25. package/build/web/core/semantic.js +913 -341
  26. package/build/web/core/semantic.scss +196 -140
  27. package/build/web/index.d.ts +3 -4
  28. package/build/web/index.js +0 -1
  29. package/build/web/types.d.ts +17 -0
  30. package/config.js +121 -496
  31. package/package.json +5 -4
  32. package/src/global/primitive/breakpoint.tokens.json +39 -0
  33. package/src/global/primitive/color.tokens.json +536 -0
  34. package/src/global/primitive/duration.tokens.json +32 -0
  35. package/src/global/primitive/font.tokens.json +103 -0
  36. package/src/global/primitive/radius.tokens.json +67 -0
  37. package/src/global/primitive/size.tokens.json +123 -0
  38. package/src/global/primitive/transition.tokens.json +20 -0
  39. package/src/theme/core/background.tokens.json +1058 -0
  40. package/src/theme/core/border.tokens.json +148 -0
  41. package/src/theme/core/charts.tokens.json +802 -0
  42. package/src/theme/core/component/alert.tokens.json +180 -0
  43. package/src/theme/core/component/announcement.tokens.json +186 -0
  44. package/src/theme/core/component/avatar.tokens.json +132 -0
  45. package/src/theme/core/component/badge.tokens.json +40 -0
  46. package/src/theme/core/component/button.tokens.json +752 -0
  47. package/src/theme/core/component/checkbox.tokens.json +292 -0
  48. package/src/theme/core/focus.tokens.json +48 -0
  49. package/src/theme/core/foreground.tokens.json +306 -0
  50. package/src/theme/core/shadow.tokens.json +43 -0
  51. package/src/theme/core/status.tokens.json +70 -0
  52. package/src/theme/core/typography.tokens.json +100 -0
  53. package/src/utils/copy-css-utils-cli.js +13 -0
  54. package/src/utils/css-utils-format-utils.js +98 -1
  55. package/src/utils/sd-build-configs.js +372 -0
  56. package/src/utils/sd-formats.js +752 -0
  57. package/src/utils/sd-transforms.js +126 -0
  58. package/src/utils/token-helpers.js +555 -0
  59. package/tsconfig.json +18 -0
  60. package/.turbo/turbo-build.log +0 -37
  61. package/build/web/core/raw.js +0 -234
  62. package/src/global/primitive/breakpoint.js +0 -19
  63. package/src/global/primitive/color.js +0 -231
  64. package/src/global/primitive/duration.js +0 -16
  65. package/src/global/primitive/font.js +0 -60
  66. package/src/global/primitive/radius.js +0 -31
  67. package/src/global/primitive/size.js +0 -55
  68. package/src/global/primitive/transition.js +0 -16
  69. package/src/theme/core/background.js +0 -170
  70. package/src/theme/core/border.js +0 -103
  71. package/src/theme/core/charts.js +0 -464
  72. package/src/theme/core/component/button.js +0 -708
  73. package/src/theme/core/component/checkbox.js +0 -405
  74. package/src/theme/core/focus.js +0 -35
  75. package/src/theme/core/foreground.js +0 -148
  76. package/src/theme/core/overlay.js +0 -137
  77. package/src/theme/core/shadow.js +0 -29
  78. package/src/theme/core/status.js +0 -49
  79. package/src/theme/core/typography.js +0 -82
  80. package/type/types.ts +0 -344
@@ -0,0 +1,372 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports */
2
+ /**
3
+ * Style Dictionary build configurations
4
+ * @module sd-build-configs
5
+ */
6
+ const { getTokenName } = require("./token-helpers");
7
+
8
+ /**
9
+ * CSS Utils prefixes for generating utility class variants
10
+ * @constant {string[]}
11
+ */
12
+ const CSS_UTILS_PREFIXES = ["", "a2-"];
13
+
14
+ /**
15
+ * Filters tokens to include only semantic tokens (excludes primitive and component tokens).
16
+ * @param {Object} token - The token object from Style Dictionary
17
+ * @returns {boolean} True if the token is a semantic token
18
+ */
19
+ const isSemanticToken = (token) => {
20
+ if (!token.filePath) return true;
21
+ return (
22
+ !token.filePath.includes("primitive") &&
23
+ !token.filePath.includes("/component/")
24
+ );
25
+ };
26
+
27
+ /**
28
+ * Filters tokens to include only component tokens.
29
+ * @param {Object} token - The token object from Style Dictionary
30
+ * @returns {boolean} True if the token is a component token
31
+ */
32
+ const isComponentToken = (token) =>
33
+ token.filePath && token.filePath.includes("/component/");
34
+
35
+ /**
36
+ * Creates an SCSS platform configuration for Style Dictionary.
37
+ * @param {Object} options - Platform configuration options
38
+ * @param {string} options.buildPath - Output directory path for built files
39
+ * @param {Array<Object>} options.files - Array of file configurations with destination and format
40
+ * @returns {Object} SCSS platform configuration object
41
+ * @example
42
+ * createScssPlatform({
43
+ * buildPath: 'build/web/core/',
44
+ * files: [{ destination: 'tokens.scss', format: 'custom/scss-variables' }]
45
+ * })
46
+ */
47
+ const createScssPlatform = ({ buildPath, files }) => ({
48
+ transformGroup: "dtcg",
49
+ options: {
50
+ usesDtcg: true,
51
+ },
52
+ buildPath,
53
+ files,
54
+ });
55
+
56
+ /**
57
+ * Creates a JavaScript platform configuration for Style Dictionary.
58
+ * @param {Object} options - Platform configuration options
59
+ * @param {string} options.buildPath - Output directory path for built files
60
+ * @param {Array<Object>} options.files - Array of file configurations with destination and format
61
+ * @returns {Object} JavaScript platform configuration object
62
+ * @example
63
+ * createJsPlatform({
64
+ * buildPath: 'build/web/core/',
65
+ * files: [{ destination: 'tokens.js', format: 'custom/es6-variable' }]
66
+ * })
67
+ */
68
+ const createJsPlatform = ({ buildPath, files }) => ({
69
+ transformGroup: "dtcg",
70
+ options: {
71
+ usesDtcg: true,
72
+ },
73
+ buildPath,
74
+ files,
75
+ });
76
+
77
+ /**
78
+ * Creates a CSS platform configuration for Style Dictionary.
79
+ * @param {Object} options - Platform configuration options
80
+ * @param {string} options.buildPath - Output directory path for built files
81
+ * @param {Array<Object>} options.files - Array of file configurations with destination and format
82
+ * @returns {Object} CSS platform configuration object
83
+ * @example
84
+ * createCssPlatform({
85
+ * buildPath: 'build/web/core/css-utils/',
86
+ * files: [{ destination: 'utils.css', format: 'custom/CSSUtils/All' }]
87
+ * })
88
+ */
89
+ const createCssPlatform = ({ buildPath, files }) => ({
90
+ transformGroup: "dtcg",
91
+ options: {
92
+ usesDtcg: true,
93
+ },
94
+ buildPath,
95
+ files,
96
+ });
97
+
98
+ /**
99
+ * Creates CSS utility file configurations for a given class prefix.
100
+ * Generates configurations for all utils, borders, colors, fonts, and spacing.
101
+ * @param {string} prefix - CSS class prefix (e.g., '' or 'a2-')
102
+ * @returns {Array<Object>} Array of file configurations for CSS utilities
103
+ * @example
104
+ * createCssUtilsFiles('a2-')
105
+ * // Returns: [
106
+ * // { destination: 'a2-utils.css', format: 'custom/CSSUtils/a2-All' },
107
+ * // { destination: 'a2-border.css', format: 'custom/CSSUtils/a2-Borders', filter: ... },
108
+ * // ...
109
+ * // ]
110
+ */
111
+ const createCssUtilsFiles = (prefix) => [
112
+ {
113
+ destination: `${prefix}utils.css`,
114
+ format: `custom/CSSUtils/${prefix}All`,
115
+ },
116
+ {
117
+ destination: `${prefix}border.css`,
118
+ format: `custom/CSSUtils/${prefix}Borders`,
119
+ filter: (token) => {
120
+ const name = getTokenName(token);
121
+ return name && name.includes("border");
122
+ },
123
+ },
124
+ {
125
+ destination: `${prefix}color.css`,
126
+ format: `custom/CSSUtils/${prefix}Colors`,
127
+ filter: (token) => {
128
+ const name = getTokenName(token);
129
+ return (
130
+ name &&
131
+ ((name.includes("primitive") && name.includes("color")) ||
132
+ name.includes("color"))
133
+ );
134
+ },
135
+ },
136
+ {
137
+ destination: `${prefix}font.css`,
138
+ format: `custom/CSSUtils/${prefix}Fonts`,
139
+ filter: (token) => {
140
+ const name = getTokenName(token);
141
+ return (
142
+ name &&
143
+ ((name.includes("primitive") && name.includes("font")) ||
144
+ name.includes("typography"))
145
+ );
146
+ },
147
+ },
148
+ {
149
+ destination: `${prefix}spacing.css`,
150
+ format: `custom/CSSUtils/${prefix}Spacing`,
151
+ filter: (token) => {
152
+ const name = getTokenName(token);
153
+ return name && name.startsWith("size");
154
+ },
155
+ },
156
+ ];
157
+
158
+ /**
159
+ * Creates CSS utility file configurations for semantic tokens with a given class prefix.
160
+ * Similar to createCssUtilsFiles but with filters appropriate for semantic token naming.
161
+ * @param {string} prefix - CSS class prefix (e.g., '' or 'a2-')
162
+ * @returns {Array<Object>} Array of file configurations for semantic CSS utilities
163
+ * @example
164
+ * createSemanticCssUtilsFiles('a2-')
165
+ */
166
+ const createSemanticCssUtilsFiles = (prefix) => [
167
+ {
168
+ destination: `${prefix}utils.css`,
169
+ format: `custom/CSSUtils/${prefix}All`,
170
+ filter: () => true,
171
+ },
172
+ {
173
+ destination: `${prefix}border.css`,
174
+ format: `custom/CSSUtils/${prefix}Borders`,
175
+ filter: (token) => {
176
+ const name = getTokenName(token);
177
+ return name && name.includes("border");
178
+ },
179
+ },
180
+ {
181
+ destination: `${prefix}color.css`,
182
+ format: `custom/CSSUtils/${prefix}Colors`,
183
+ filter: (token) => {
184
+ const name = getTokenName(token);
185
+ return (
186
+ name &&
187
+ (name.includes("color") ||
188
+ name.includes("status-color") ||
189
+ name.includes("foreground-color") ||
190
+ name.includes("background-color") ||
191
+ name.includes("overlay-color"))
192
+ );
193
+ },
194
+ },
195
+ {
196
+ destination: `${prefix}font.css`,
197
+ format: `custom/CSSUtils/${prefix}Fonts`,
198
+ filter: (token) => {
199
+ const name = getTokenName(token);
200
+ return name && name.includes("typography");
201
+ },
202
+ },
203
+ {
204
+ destination: `${prefix}spacing.css`,
205
+ format: `custom/CSSUtils/${prefix}Spacing`,
206
+ filter: (token) => {
207
+ const name = getTokenName(token);
208
+ return name && name.startsWith("size");
209
+ },
210
+ },
211
+ ];
212
+
213
+ /**
214
+ * Creates the Style Dictionary configuration for primitive tokens.
215
+ * Primitive tokens are the foundational design values (colors, sizes, etc.).
216
+ * @returns {Object} Style Dictionary configuration object for primitive tokens
217
+ * @example
218
+ * const StyleDictionary = require('style-dictionary');
219
+ * const config = createPrimitiveConfig();
220
+ * const sd = new StyleDictionary(config);
221
+ */
222
+ const createPrimitiveConfig = () => ({
223
+ log: {
224
+ verbosity: "verbose",
225
+ },
226
+ source: ["src/global/primitive/*.tokens.json"],
227
+ platforms: {
228
+ scss: createScssPlatform({
229
+ buildPath: "build/web/core/",
230
+ files: [
231
+ {
232
+ destination: "primitive.scss",
233
+ format: "custom/scss-variables",
234
+ },
235
+ {
236
+ destination: "primitive-variables.scss",
237
+ format: "custom/scss-variables-map",
238
+ },
239
+ ],
240
+ }),
241
+ js: createJsPlatform({
242
+ buildPath: "build/web/core/",
243
+ files: [
244
+ {
245
+ destination: "primitive.js",
246
+ format: "custom/es6-variable",
247
+ },
248
+ ],
249
+ }),
250
+ css: createCssPlatform({
251
+ buildPath: "build/web/core/css-utils/",
252
+ files: CSS_UTILS_PREFIXES.flatMap((prefix) =>
253
+ createCssUtilsFiles(prefix),
254
+ ),
255
+ }),
256
+ },
257
+ });
258
+
259
+ /**
260
+ * Creates the Style Dictionary configuration for theme tokens.
261
+ * Theme tokens include semantic tokens that reference primitives, excluding component tokens.
262
+ * @returns {Object} Style Dictionary configuration object for theme tokens
263
+ * @example
264
+ * const StyleDictionary = require('style-dictionary');
265
+ * const config = createThemeConfig();
266
+ * const sd = new StyleDictionary(config);
267
+ */
268
+ const createThemeConfig = () => ({
269
+ log: {
270
+ verbosity: "verbose",
271
+ errors: {
272
+ brokenReferences: "warn",
273
+ },
274
+ },
275
+ include: [
276
+ "src/global/primitive/*.tokens.json",
277
+ "src/theme/core/status.tokens.json",
278
+ ],
279
+ source: ["src/theme/**/*.tokens.json"],
280
+ platforms: {
281
+ scss: createScssPlatform({
282
+ buildPath: "build/web/core/",
283
+ files: [
284
+ {
285
+ destination: "semantic.scss",
286
+ format: "custom/scss-variables",
287
+ filter: isSemanticToken,
288
+ },
289
+ {
290
+ destination: "semantic-variables.scss",
291
+ format: "custom/scss-variables-map",
292
+ filter: isSemanticToken,
293
+ },
294
+ ],
295
+ }),
296
+ js: createJsPlatform({
297
+ buildPath: "build/web/core/",
298
+ files: [
299
+ {
300
+ destination: "semantic.js",
301
+ format: "custom/es6-variable",
302
+ filter: isSemanticToken,
303
+ },
304
+ ],
305
+ }),
306
+ css: createCssPlatform({
307
+ buildPath: "build/web/core/css-utils/",
308
+ files: CSS_UTILS_PREFIXES.flatMap((prefix) =>
309
+ createSemanticCssUtilsFiles(prefix),
310
+ ),
311
+ }),
312
+ },
313
+ });
314
+
315
+ /**
316
+ * Creates the Style Dictionary configuration for component tokens.
317
+ * Component tokens are specific to UI components and reference theme/primitive tokens.
318
+ * @returns {Object} Style Dictionary configuration object for component tokens
319
+ * @example
320
+ * const StyleDictionary = require('style-dictionary');
321
+ * const config = createComponentConfig();
322
+ * const sd = new StyleDictionary(config);
323
+ */
324
+ const createComponentConfig = () => ({
325
+ usesDtcg: true,
326
+ log: {
327
+ verbosity: "verbose",
328
+ errors: {
329
+ brokenReferences: "warn",
330
+ },
331
+ },
332
+ include: [
333
+ "src/global/primitive/*.tokens.json",
334
+ "src/theme/core/*.tokens.json",
335
+ ],
336
+ source: ["src/theme/core/component/*.tokens.json"],
337
+ platforms: {
338
+ scss: createScssPlatform({
339
+ buildPath: "build/web/core/",
340
+ files: [
341
+ {
342
+ destination: "component.scss",
343
+ format: "custom/scss-variables",
344
+ filter: isComponentToken,
345
+ },
346
+ {
347
+ destination: "component-variables.scss",
348
+ format: "custom/scss-variables-map",
349
+ filter: isComponentToken,
350
+ },
351
+ ],
352
+ }),
353
+ js: createJsPlatform({
354
+ buildPath: "build/web/core/",
355
+ files: [
356
+ {
357
+ destination: "component.js",
358
+ format: "custom/es6-variable",
359
+ filter: isComponentToken,
360
+ },
361
+ ],
362
+ }),
363
+ },
364
+ });
365
+
366
+ module.exports = {
367
+ createPrimitiveConfig,
368
+ createThemeConfig,
369
+ createComponentConfig,
370
+ isSemanticToken,
371
+ isComponentToken,
372
+ };