@servicetitan/hammer-token 2.5.1 → 3.0.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.
- package/CHANGELOG.md +50 -0
- package/README.md +332 -0
- package/build/web/core/component-variables.scss +1088 -131
- package/build/web/core/component.d.ts +558 -0
- package/build/web/core/component.js +6685 -249
- package/build/web/core/component.scss +557 -69
- package/build/web/core/css-utils/a2-border.css +47 -45
- package/build/web/core/css-utils/a2-color.css +443 -227
- package/build/web/core/css-utils/a2-font.css +0 -2
- package/build/web/core/css-utils/a2-spacing.css +476 -478
- package/build/web/core/css-utils/a2-utils.css +992 -772
- package/build/web/core/css-utils/border.css +47 -45
- package/build/web/core/css-utils/color.css +443 -227
- package/build/web/core/css-utils/font.css +0 -2
- package/build/web/core/css-utils/spacing.css +476 -478
- package/build/web/core/css-utils/utils.css +992 -772
- package/build/web/core/index.d.ts +6 -0
- package/build/web/core/index.js +1 -1
- package/build/web/core/primitive-variables.scss +148 -65
- package/build/web/core/primitive.d.ts +209 -0
- package/build/web/core/primitive.js +779 -61
- package/build/web/core/primitive.scss +207 -124
- package/build/web/core/semantic-variables.scss +363 -245
- package/build/web/core/semantic.d.ts +221 -0
- package/build/web/core/semantic.js +1592 -347
- package/build/web/core/semantic.scss +219 -140
- package/build/web/index.d.ts +3 -4
- package/build/web/index.js +0 -1
- package/build/web/types.d.ts +17 -0
- package/config.js +121 -497
- package/eslint.config.mjs +11 -1
- package/package.json +15 -5
- package/src/global/primitive/breakpoint.tokens.json +54 -0
- package/src/global/primitive/color.tokens.json +1092 -0
- package/src/global/primitive/duration.tokens.json +44 -0
- package/src/global/primitive/font.tokens.json +151 -0
- package/src/global/primitive/radius.tokens.json +94 -0
- package/src/global/primitive/size.tokens.json +174 -0
- package/src/global/primitive/transition.tokens.json +32 -0
- package/src/theme/core/background.tokens.json +1312 -0
- package/src/theme/core/border.tokens.json +192 -0
- package/src/theme/core/chart.tokens.json +982 -0
- package/src/theme/core/component/ai-mark.tokens.json +20 -0
- package/src/theme/core/component/alert.tokens.json +261 -0
- package/src/theme/core/component/announcement.tokens.json +460 -0
- package/src/theme/core/component/avatar.tokens.json +137 -0
- package/src/theme/core/component/badge.tokens.json +42 -0
- package/src/theme/core/component/breadcrumb.tokens.json +42 -0
- package/src/theme/core/component/button-toggle.tokens.json +428 -0
- package/src/theme/core/component/button.tokens.json +941 -0
- package/src/theme/core/component/calendar.tokens.json +391 -0
- package/src/theme/core/component/card.tokens.json +107 -0
- package/src/theme/core/component/checkbox.tokens.json +631 -0
- package/src/theme/core/component/chip.tokens.json +169 -0
- package/src/theme/core/component/combobox.tokens.json +269 -0
- package/src/theme/core/component/details.tokens.json +152 -0
- package/src/theme/core/component/dialog.tokens.json +87 -0
- package/src/theme/core/component/divider.tokens.json +23 -0
- package/src/theme/core/component/dnd.tokens.json +208 -0
- package/src/theme/core/component/drawer.tokens.json +61 -0
- package/src/theme/core/component/drilldown.tokens.json +61 -0
- package/src/theme/core/component/edit-card.tokens.json +381 -0
- package/src/theme/core/component/field-label.tokens.json +42 -0
- package/src/theme/core/component/field-message.tokens.json +74 -0
- package/src/theme/core/component/icon.tokens.json +42 -0
- package/src/theme/core/component/link.tokens.json +108 -0
- package/src/theme/core/component/list-view.tokens.json +82 -0
- package/src/theme/core/component/listbox.tokens.json +283 -0
- package/src/theme/core/component/menu.tokens.json +230 -0
- package/src/theme/core/component/overflow.tokens.json +84 -0
- package/src/theme/core/component/page.tokens.json +377 -0
- package/src/theme/core/component/pagination.tokens.json +63 -0
- package/src/theme/core/component/popover.tokens.json +122 -0
- package/src/theme/core/component/progress-bar.tokens.json +133 -0
- package/src/theme/core/component/radio.tokens.json +631 -0
- package/src/theme/core/component/segmented-control.tokens.json +175 -0
- package/src/theme/core/component/select-card.tokens.json +943 -0
- package/src/theme/core/component/side-nav.tokens.json +349 -0
- package/src/theme/core/component/skeleton.tokens.json +42 -0
- package/src/theme/core/component/spinner.tokens.json +96 -0
- package/src/theme/core/component/status-icon.tokens.json +164 -0
- package/src/theme/core/component/stepper.tokens.json +484 -0
- package/src/theme/core/component/switch.tokens.json +285 -0
- package/src/theme/core/component/tab.tokens.json +192 -0
- package/src/theme/core/component/text-field.tokens.json +160 -0
- package/src/theme/core/component/text.tokens.json +59 -0
- package/src/theme/core/component/toast.tokens.json +343 -0
- package/src/theme/core/component/toolbar.tokens.json +114 -0
- package/src/theme/core/component/tooltip.tokens.json +61 -0
- package/src/theme/core/focus.tokens.json +56 -0
- package/src/theme/core/foreground.tokens.json +416 -0
- package/src/theme/core/gradient.tokens.json +41 -0
- package/src/theme/core/opacity.tokens.json +25 -0
- package/src/theme/core/shadow.tokens.json +81 -0
- package/src/theme/core/status.tokens.json +74 -0
- package/src/theme/core/typography.tokens.json +163 -0
- package/src/utils/__tests__/css-utils-format-utils.test.js +312 -0
- package/src/utils/__tests__/sd-build-configs.test.js +306 -0
- package/src/utils/__tests__/sd-formats.test.js +950 -0
- package/src/utils/__tests__/sd-transforms.test.js +336 -0
- package/src/utils/__tests__/token-helpers.test.js +1160 -0
- package/src/utils/copy-css-utils-cli.js +13 -1
- package/src/utils/css-utils-format-utils.js +105 -176
- package/src/utils/figma/__tests__/sync-gradient.test.js +561 -0
- package/src/utils/figma/__tests__/token-conversion.test.js +117 -0
- package/src/utils/figma/__tests__/token-resolution.test.js +231 -0
- package/src/utils/figma/auth.js +355 -0
- package/src/utils/figma/constants.js +22 -0
- package/src/utils/figma/errors.js +80 -0
- package/src/utils/figma/figma-api.js +1069 -0
- package/src/utils/figma/get-token.js +348 -0
- package/src/utils/figma/sync-components.js +909 -0
- package/src/utils/figma/sync-main.js +692 -0
- package/src/utils/figma/sync-orchestration.js +683 -0
- package/src/utils/figma/sync-primitives.js +230 -0
- package/src/utils/figma/sync-semantic.js +1056 -0
- package/src/utils/figma/token-conversion.js +340 -0
- package/src/utils/figma/token-parsing.js +186 -0
- package/src/utils/figma/token-resolution.js +569 -0
- package/src/utils/figma/utils.js +199 -0
- package/src/utils/sd-build-configs.js +305 -0
- package/src/utils/sd-formats.js +965 -0
- package/src/utils/sd-transforms.js +165 -0
- package/src/utils/token-helpers.js +848 -0
- package/tsconfig.json +18 -0
- package/vitest.config.js +17 -0
- package/.turbo/turbo-build.log +0 -37
- package/build/web/core/raw.js +0 -234
- package/src/global/primitive/breakpoint.js +0 -19
- package/src/global/primitive/color.js +0 -231
- package/src/global/primitive/duration.js +0 -16
- package/src/global/primitive/font.js +0 -60
- package/src/global/primitive/radius.js +0 -31
- package/src/global/primitive/size.js +0 -55
- package/src/global/primitive/transition.js +0 -16
- package/src/theme/core/background.js +0 -170
- package/src/theme/core/border.js +0 -103
- package/src/theme/core/charts.js +0 -464
- package/src/theme/core/component/button.js +0 -708
- package/src/theme/core/component/checkbox.js +0 -405
- package/src/theme/core/focus.js +0 -35
- package/src/theme/core/foreground.js +0 -148
- package/src/theme/core/overlay.js +0 -137
- package/src/theme/core/shadow.js +0 -29
- package/src/theme/core/status.js +0 -49
- package/src/theme/core/typography.js +0 -82
- package/type/types.ts +0 -344
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style Dictionary transform registrations
|
|
3
|
+
* @module sd-transforms
|
|
4
|
+
*/
|
|
5
|
+
const {
|
|
6
|
+
getDtcgValue,
|
|
7
|
+
getTokenType,
|
|
8
|
+
isCompositeColor,
|
|
9
|
+
isDimensionValue,
|
|
10
|
+
isGradientValue,
|
|
11
|
+
} = require("./token-helpers");
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Registers all custom Style Dictionary transforms for DTCG token format.
|
|
15
|
+
* This includes transforms for token names, values, cubic-bezier functions, and color opacity.
|
|
16
|
+
* Also registers a "dtcg" transform group that combines all these transforms.
|
|
17
|
+
* @param {import('style-dictionary').default} StyleDictionary - The Style Dictionary class instance
|
|
18
|
+
* @returns {void}
|
|
19
|
+
* @example
|
|
20
|
+
* const StyleDictionary = require('style-dictionary');
|
|
21
|
+
* registerTransforms(StyleDictionary);
|
|
22
|
+
*/
|
|
23
|
+
const registerTransforms = (StyleDictionary) => {
|
|
24
|
+
/**
|
|
25
|
+
* Transform: dtcg/name
|
|
26
|
+
* Generates a clean token name from the token path, filtering out $schema
|
|
27
|
+
* and other $-prefixed segments.
|
|
28
|
+
*/
|
|
29
|
+
StyleDictionary.registerTransform({
|
|
30
|
+
name: "dtcg/name",
|
|
31
|
+
type: "name",
|
|
32
|
+
transform: (token) => {
|
|
33
|
+
const tokenPath =
|
|
34
|
+
token.path || token.original?.path || token.pathSegments;
|
|
35
|
+
|
|
36
|
+
if (Array.isArray(tokenPath) && tokenPath.length > 0) {
|
|
37
|
+
const filteredPath = tokenPath.filter(
|
|
38
|
+
(segment) =>
|
|
39
|
+
segment !== "$schema" && !String(segment).startsWith("$"),
|
|
40
|
+
);
|
|
41
|
+
if (filteredPath.length > 0) {
|
|
42
|
+
return filteredPath.join("-");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (token.name && typeof token.name === "string") {
|
|
46
|
+
return token.name
|
|
47
|
+
.replace(/\$schema/g, "")
|
|
48
|
+
.replace(/-+/g, "-")
|
|
49
|
+
.replace(/^-|-$/g, "");
|
|
50
|
+
}
|
|
51
|
+
return "unknown";
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Transform: dtcg/value
|
|
57
|
+
* Extracts the DTCG $value from a token, handling dimension objects with value/unit.
|
|
58
|
+
*/
|
|
59
|
+
StyleDictionary.registerTransform({
|
|
60
|
+
name: "dtcg/value",
|
|
61
|
+
type: "value",
|
|
62
|
+
transform: (token) => {
|
|
63
|
+
const value = getDtcgValue(token);
|
|
64
|
+
|
|
65
|
+
// Handle new format { value, unit }
|
|
66
|
+
if (isDimensionValue(value)) {
|
|
67
|
+
return `${value.value}${value.unit}`;
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Transform: dtcg/cubic-bezier
|
|
75
|
+
* Converts cubicBezier token arrays to CSS cubic-bezier() function strings.
|
|
76
|
+
*/
|
|
77
|
+
StyleDictionary.registerTransform({
|
|
78
|
+
name: "dtcg/cubic-bezier",
|
|
79
|
+
type: "value",
|
|
80
|
+
matcher: (token) => getTokenType(token) === "cubicBezier",
|
|
81
|
+
transform: (token) => {
|
|
82
|
+
const value = getDtcgValue(token);
|
|
83
|
+
if (Array.isArray(value)) {
|
|
84
|
+
return `cubic-bezier(${value.join(", ")})`;
|
|
85
|
+
}
|
|
86
|
+
return value;
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Transform: dtcg/color-opacity
|
|
92
|
+
* Handles composite color tokens that have separate color and alpha values.
|
|
93
|
+
*/
|
|
94
|
+
StyleDictionary.registerTransform({
|
|
95
|
+
name: "dtcg/color-opacity",
|
|
96
|
+
type: "value",
|
|
97
|
+
matcher: (token) =>
|
|
98
|
+
getTokenType(token) === "color" && isCompositeColor(getDtcgValue(token)),
|
|
99
|
+
transform: (token) => getDtcgValue(token),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Transform: dtcg/gradient
|
|
104
|
+
* Passes gradient token arrays through unchanged so the format layer can
|
|
105
|
+
* assemble the final linear-gradient() string with CSS var() chains.
|
|
106
|
+
*/
|
|
107
|
+
StyleDictionary.registerTransform({
|
|
108
|
+
name: "dtcg/gradient",
|
|
109
|
+
type: "value",
|
|
110
|
+
matcher: (token) =>
|
|
111
|
+
getTokenType(token) === "gradient" &&
|
|
112
|
+
isGradientValue(getDtcgValue(token)),
|
|
113
|
+
transform: (token) => getDtcgValue(token),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Preprocessor: dtcg/set-token-names
|
|
118
|
+
* Sets token.name to the full hyphenated path (minus $-prefixed segments) on every leaf
|
|
119
|
+
* token before transforms run. This ensures SD's collision detection uses the real unique
|
|
120
|
+
* name even for tokens that are deferred due to unresolvable references — those tokens
|
|
121
|
+
* skip the transform pipeline and would otherwise keep the last-segment default name
|
|
122
|
+
* (e.g. "color"), causing false collision warnings.
|
|
123
|
+
*/
|
|
124
|
+
StyleDictionary.registerPreprocessor({
|
|
125
|
+
name: "dtcg/set-token-names",
|
|
126
|
+
preprocessor: (tokens) => {
|
|
127
|
+
function walk(obj, path = []) {
|
|
128
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
129
|
+
if (val && typeof val === "object") {
|
|
130
|
+
if (val["$value"] !== undefined) {
|
|
131
|
+
const filtered = [...path, key].filter(
|
|
132
|
+
(s) => !String(s).startsWith("$"),
|
|
133
|
+
);
|
|
134
|
+
val.name = filtered.join("-");
|
|
135
|
+
} else {
|
|
136
|
+
walk(val, [...path, key]);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
walk(tokens);
|
|
142
|
+
return tokens;
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Transform Group: dtcg
|
|
148
|
+
* Combines all DTCG-related transforms plus the built-in color/css transform.
|
|
149
|
+
*/
|
|
150
|
+
StyleDictionary.registerTransformGroup({
|
|
151
|
+
name: "dtcg",
|
|
152
|
+
transforms: [
|
|
153
|
+
"dtcg/name",
|
|
154
|
+
"dtcg/value",
|
|
155
|
+
"dtcg/cubic-bezier",
|
|
156
|
+
"dtcg/color-opacity",
|
|
157
|
+
"dtcg/gradient",
|
|
158
|
+
"color/css",
|
|
159
|
+
],
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
module.exports = {
|
|
164
|
+
registerTransforms,
|
|
165
|
+
};
|