boss-css 0.0.13 → 0.0.15
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/LICENSE +21 -0
- package/README.md +146 -1
- package/dist/ai/server.cjs +1 -0
- package/dist/ai/server.mjs +1 -0
- package/dist/ai/skills.cjs +3 -0
- package/dist/ai/skills.mjs +3 -0
- package/dist/cli/tasks/init.cjs +43 -21
- package/dist/cli/tasks/init.mjs +43 -21
- package/dist/cli/templates/init.cjs +5 -5
- package/dist/cli/templates/init.mjs +5 -5
- package/dist/compile/jsx.cjs +4 -2
- package/dist/compile/jsx.mjs +4 -2
- package/dist/devtools-app/index.mjs +320 -0
- package/dist/devtools-app/monaco/vs/_commonjsHelpers-CT9FvmAN.js +1 -0
- package/dist/devtools-app/monaco/vs/abap-D-t0cyap.js +1 -0
- package/dist/devtools-app/monaco/vs/apex-CcIm7xu6.js +1 -0
- package/dist/devtools-app/monaco/vs/assets/css.worker-HnVq6Ewq.js +93 -0
- package/dist/devtools-app/monaco/vs/assets/editor.worker-Be8ye1pW.js +26 -0
- package/dist/devtools-app/monaco/vs/assets/html.worker-B51mlPHg.js +470 -0
- package/dist/devtools-app/monaco/vs/assets/json.worker-DKiEKt88.js +58 -0
- package/dist/devtools-app/monaco/vs/assets/ts.worker-CMbG-7ft.js +67731 -0
- package/dist/devtools-app/monaco/vs/azcli-BA0tQDCg.js +1 -0
- package/dist/devtools-app/monaco/vs/basic-languages/monaco.contribution.js +1 -0
- package/dist/devtools-app/monaco/vs/bat-C397hTD6.js +1 -0
- package/dist/devtools-app/monaco/vs/bicep-DF5aW17k.js +2 -0
- package/dist/devtools-app/monaco/vs/cameligo-plsz8qhj.js +1 -0
- package/dist/devtools-app/monaco/vs/clojure-Y2auQMzK.js +1 -0
- package/dist/devtools-app/monaco/vs/coffee-Bu45yuWE.js +1 -0
- package/dist/devtools-app/monaco/vs/cpp-CkKPQIni.js +1 -0
- package/dist/devtools-app/monaco/vs/csharp-CX28MZyh.js +1 -0
- package/dist/devtools-app/monaco/vs/csp-D8uWnyxW.js +1 -0
- package/dist/devtools-app/monaco/vs/css-CaeNmE3S.js +3 -0
- package/dist/devtools-app/monaco/vs/cssMode-CjiAH6dQ.js +1 -0
- package/dist/devtools-app/monaco/vs/cypher-DVThT8BS.js +1 -0
- package/dist/devtools-app/monaco/vs/dart-CmGfCvrO.js +1 -0
- package/dist/devtools-app/monaco/vs/dockerfile-CZqqYdch.js +1 -0
- package/dist/devtools-app/monaco/vs/ecl-30fUercY.js +1 -0
- package/dist/devtools-app/monaco/vs/editor/editor.main.css +1 -0
- package/dist/devtools-app/monaco/vs/editor/editor.main.js +5 -0
- package/dist/devtools-app/monaco/vs/editor.api-CalNCsUg.js +903 -0
- package/dist/devtools-app/monaco/vs/elixir-xjPaIfzF.js +1 -0
- package/dist/devtools-app/monaco/vs/flow9-DqtmStfK.js +1 -0
- package/dist/devtools-app/monaco/vs/freemarker2-Cz_sV6Md.js +3 -0
- package/dist/devtools-app/monaco/vs/fsharp-BOMdg4U1.js +1 -0
- package/dist/devtools-app/monaco/vs/go-D_hbi-Jt.js +1 -0
- package/dist/devtools-app/monaco/vs/graphql-CKUU4kLG.js +1 -0
- package/dist/devtools-app/monaco/vs/handlebars-OwglfO-1.js +1 -0
- package/dist/devtools-app/monaco/vs/hcl-DTaboeZW.js +1 -0
- package/dist/devtools-app/monaco/vs/html-Pa1xEWsY.js +1 -0
- package/dist/devtools-app/monaco/vs/htmlMode-Bz67EXwp.js +1 -0
- package/dist/devtools-app/monaco/vs/ini-CsNwO04R.js +1 -0
- package/dist/devtools-app/monaco/vs/java-CI4ZMsH9.js +1 -0
- package/dist/devtools-app/monaco/vs/javascript-PczUCGdz.js +1 -0
- package/dist/devtools-app/monaco/vs/jsonMode-DULH5oaX.js +7 -0
- package/dist/devtools-app/monaco/vs/julia-BwzEvaQw.js +1 -0
- package/dist/devtools-app/monaco/vs/kotlin-IUYPiTV8.js +1 -0
- package/dist/devtools-app/monaco/vs/language/css/monaco.contribution.js +1 -0
- package/dist/devtools-app/monaco/vs/language/html/monaco.contribution.js +1 -0
- package/dist/devtools-app/monaco/vs/language/json/monaco.contribution.js +1 -0
- package/dist/devtools-app/monaco/vs/language/typescript/monaco.contribution.js +1 -0
- package/dist/devtools-app/monaco/vs/less-C0eDYdqa.js +2 -0
- package/dist/devtools-app/monaco/vs/lexon-iON-Kj97.js +1 -0
- package/dist/devtools-app/monaco/vs/liquid-DqKjdPGy.js +1 -0
- package/dist/devtools-app/monaco/vs/loader.js +1368 -0
- package/dist/devtools-app/monaco/vs/lspLanguageFeatures-kM9O9rjY.js +4 -0
- package/dist/devtools-app/monaco/vs/lua-DtygF91M.js +1 -0
- package/dist/devtools-app/monaco/vs/m3-CsR4AuFi.js +1 -0
- package/dist/devtools-app/monaco/vs/markdown-C_rD0bIw.js +1 -0
- package/dist/devtools-app/monaco/vs/mdx-DEWtB1K5.js +1 -0
- package/dist/devtools-app/monaco/vs/mips-CiYP61RB.js +1 -0
- package/dist/devtools-app/monaco/vs/monaco.contribution-D2OdxNBt.js +1 -0
- package/dist/devtools-app/monaco/vs/monaco.contribution-DO3azKX8.js +1 -0
- package/dist/devtools-app/monaco/vs/monaco.contribution-EcChJV6a.js +1 -0
- package/dist/devtools-app/monaco/vs/monaco.contribution-qLAYrEOP.js +1 -0
- package/dist/devtools-app/monaco/vs/msdax-C38-sJlp.js +1 -0
- package/dist/devtools-app/monaco/vs/mysql-CdtbpvbG.js +1 -0
- package/dist/devtools-app/monaco/vs/nls.messages-loader.js +1 -0
- package/dist/devtools-app/monaco/vs/nls.messages.cs.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.de.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.es.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.fr.js.js +15 -0
- package/dist/devtools-app/monaco/vs/nls.messages.it.js.js +15 -0
- package/dist/devtools-app/monaco/vs/nls.messages.ja.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.js.js +10 -0
- package/dist/devtools-app/monaco/vs/nls.messages.ko.js.js +25 -0
- package/dist/devtools-app/monaco/vs/nls.messages.pl.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.pt-br.js.js +6 -0
- package/dist/devtools-app/monaco/vs/nls.messages.ru.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.tr.js.js +15 -0
- package/dist/devtools-app/monaco/vs/nls.messages.zh-cn.js.js +17 -0
- package/dist/devtools-app/monaco/vs/nls.messages.zh-tw.js.js +15 -0
- package/dist/devtools-app/monaco/vs/objective-c-CntZFaHX.js +1 -0
- package/dist/devtools-app/monaco/vs/pascal-r6kuqfl_.js +1 -0
- package/dist/devtools-app/monaco/vs/pascaligo-BiXoTmXh.js +1 -0
- package/dist/devtools-app/monaco/vs/perl-DABw_TcH.js +1 -0
- package/dist/devtools-app/monaco/vs/pgsql-me_jFXeX.js +1 -0
- package/dist/devtools-app/monaco/vs/php-D_kh-9LK.js +1 -0
- package/dist/devtools-app/monaco/vs/pla-VfZjczW0.js +1 -0
- package/dist/devtools-app/monaco/vs/postiats-BBSzz8Pk.js +1 -0
- package/dist/devtools-app/monaco/vs/powerquery-Dt-g_2cc.js +1 -0
- package/dist/devtools-app/monaco/vs/powershell-B-7ap1zc.js +1 -0
- package/dist/devtools-app/monaco/vs/protobuf-BmtuEB1A.js +2 -0
- package/dist/devtools-app/monaco/vs/pug-BRpRNeEb.js +1 -0
- package/dist/devtools-app/monaco/vs/python-Cr0UkIbn.js +1 -0
- package/dist/devtools-app/monaco/vs/qsharp-BzsFaUU9.js +1 -0
- package/dist/devtools-app/monaco/vs/r-f8dDdrp4.js +1 -0
- package/dist/devtools-app/monaco/vs/razor-BYAHOTkz.js +1 -0
- package/dist/devtools-app/monaco/vs/redis-fvZQY4PI.js +1 -0
- package/dist/devtools-app/monaco/vs/redshift-45Et0LQi.js +1 -0
- package/dist/devtools-app/monaco/vs/restructuredtext-C7UUFKFD.js +1 -0
- package/dist/devtools-app/monaco/vs/ruby-CZO8zYTz.js +1 -0
- package/dist/devtools-app/monaco/vs/rust-Bfetafyc.js +1 -0
- package/dist/devtools-app/monaco/vs/sb-3GYllVck.js +1 -0
- package/dist/devtools-app/monaco/vs/scala-foMgrKo1.js +1 -0
- package/dist/devtools-app/monaco/vs/scheme-CHdMtr7p.js +1 -0
- package/dist/devtools-app/monaco/vs/scss-C1cmLt9V.js +3 -0
- package/dist/devtools-app/monaco/vs/shell-ClXCKCEW.js +1 -0
- package/dist/devtools-app/monaco/vs/solidity-MZ6ExpPy.js +1 -0
- package/dist/devtools-app/monaco/vs/sophia-DWkuSsPQ.js +1 -0
- package/dist/devtools-app/monaco/vs/sparql-AUGFYSyk.js +1 -0
- package/dist/devtools-app/monaco/vs/sql-32GpJSV2.js +1 -0
- package/dist/devtools-app/monaco/vs/st-CuDFIVZ_.js +1 -0
- package/dist/devtools-app/monaco/vs/swift-n-2HociN.js +3 -0
- package/dist/devtools-app/monaco/vs/systemverilog-Ch4vA8Yt.js +1 -0
- package/dist/devtools-app/monaco/vs/tcl-D74tq1nH.js +1 -0
- package/dist/devtools-app/monaco/vs/tsMode-CZz1Umrk.js +11 -0
- package/dist/devtools-app/monaco/vs/twig-C6taOxMV.js +1 -0
- package/dist/devtools-app/monaco/vs/typescript-DfOrAzoV.js +1 -0
- package/dist/devtools-app/monaco/vs/typespec-D-PIh9Xw.js +1 -0
- package/dist/devtools-app/monaco/vs/vb-Dyb2648j.js +1 -0
- package/dist/devtools-app/monaco/vs/wgsl-BhLXMOR0.js +298 -0
- package/dist/devtools-app/monaco/vs/workers-DcJshg-q.js +1 -0
- package/dist/devtools-app/monaco/vs/xml-CdsdnY8S.js +1 -0
- package/dist/devtools-app/monaco/vs/yaml-DYGvmE88.js +1 -0
- package/dist/eslint-plugin/index.cjs +5 -2
- package/dist/eslint-plugin/index.mjs +5 -2
- package/dist/eslint-plugin/rules/prefer-unitless-values.cjs +217 -0
- package/dist/eslint-plugin/rules/prefer-unitless-values.mjs +217 -0
- package/dist/eslint-plugin/utils/api.cjs +3 -4
- package/dist/eslint-plugin/utils/api.mjs +2 -2
- package/dist/native/browser.cjs +14 -1
- package/dist/native/browser.mjs +14 -1
- package/dist/native/server.cjs +4 -4
- package/dist/native/server.mjs +4 -4
- package/dist/parser/classname/server.cjs +2 -0
- package/dist/parser/classname/server.mjs +2 -0
- package/dist/parser/jsx/server.cjs +13 -7
- package/dist/parser/jsx/server.mjs +13 -7
- package/dist/prop/at/server.cjs +6 -4
- package/dist/prop/at/server.mjs +6 -4
- package/dist/prop/at/shared.cjs +3 -3
- package/dist/prop/at/shared.mjs +3 -3
- package/dist/prop/bosswind/browser.cjs +3 -0
- package/dist/prop/bosswind/browser.mjs +3 -0
- package/dist/prop/bosswind/runtime-only.cjs +3 -0
- package/dist/prop/bosswind/runtime-only.mjs +3 -0
- package/dist/prop/bosswind/selectors.cjs +18 -0
- package/dist/prop/bosswind/selectors.mjs +16 -0
- package/dist/prop/bosswind/shared.cjs +93 -32
- package/dist/prop/bosswind/shared.mjs +94 -32
- package/dist/prop/child/server.cjs +3 -2
- package/dist/prop/child/server.mjs +3 -2
- package/dist/prop/css/server.cjs +2 -1
- package/dist/prop/css/server.mjs +2 -1
- package/dist/prop/pseudo/server.cjs +3 -2
- package/dist/prop/pseudo/server.mjs +3 -2
- package/dist/strategy/classname-first/browser.cjs +7 -1
- package/dist/strategy/classname-first/browser.mjs +7 -1
- package/dist/strategy/classname-first/runtime-only.cjs +15 -4
- package/dist/strategy/classname-first/runtime-only.mjs +15 -4
- package/dist/strategy/classname-first/server.cjs +1 -1
- package/dist/strategy/classname-first/server.mjs +1 -1
- package/dist/transform/cache.cjs +0 -3
- package/dist/transform/cache.mjs +0 -2
- package/dist/use/token/browser.cjs +17 -9
- package/dist/use/token/browser.mjs +18 -10
- package/dist/use/token/normalize.cjs +474 -0
- package/dist/use/token/normalize.mjs +473 -0
- package/dist/use/token/propMap.cjs +34 -5
- package/dist/use/token/propMap.mjs +34 -6
- package/dist/use/token/runtime-only.cjs +36 -47
- package/dist/use/token/runtime-only.mjs +37 -48
- package/dist/use/token/server.cjs +84 -17
- package/dist/use/token/server.mjs +85 -19
- package/dist/use/token/vars.cjs +14 -2
- package/dist/use/token/vars.mjs +15 -2
- package/package.json +13 -7
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
//#region src/use/token/normalize.ts
|
|
2
|
+
const isPlainObject = (value) => {
|
|
3
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
4
|
+
};
|
|
5
|
+
const hasDtcgValue = (value) => {
|
|
6
|
+
return isPlainObject(value) && Object.prototype.hasOwnProperty.call(value, "$value");
|
|
7
|
+
};
|
|
8
|
+
const hasValueEntry = (value) => {
|
|
9
|
+
return isPlainObject(value) && Object.prototype.hasOwnProperty.call(value, "value") && !Object.prototype.hasOwnProperty.call(value, "unit");
|
|
10
|
+
};
|
|
11
|
+
const hasRefEntry = (value) => {
|
|
12
|
+
return isPlainObject(value) && typeof value.$ref === "string";
|
|
13
|
+
};
|
|
14
|
+
const decodeJsonPointer = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
15
|
+
const resolveJsonPointer = (root, pointer) => {
|
|
16
|
+
if (!pointer.startsWith("#/")) return void 0;
|
|
17
|
+
const parts = pointer.slice(2).split("/").map(decodeJsonPointer);
|
|
18
|
+
let current = root;
|
|
19
|
+
for (const part of parts) {
|
|
20
|
+
if (Array.isArray(current)) {
|
|
21
|
+
const index = Number(part);
|
|
22
|
+
if (!Number.isInteger(index) || index < 0 || index >= current.length) return void 0;
|
|
23
|
+
current = current[index];
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (!isPlainObject(current)) return void 0;
|
|
27
|
+
current = current[part];
|
|
28
|
+
}
|
|
29
|
+
return current;
|
|
30
|
+
};
|
|
31
|
+
const resolvePath = (root, path) => {
|
|
32
|
+
const parts = path.split(".").filter(Boolean);
|
|
33
|
+
let current = root;
|
|
34
|
+
for (const part of parts) {
|
|
35
|
+
if (!isPlainObject(current)) return void 0;
|
|
36
|
+
current = current[part];
|
|
37
|
+
}
|
|
38
|
+
return current;
|
|
39
|
+
};
|
|
40
|
+
const resolveTokenValueReference = (root, path) => {
|
|
41
|
+
const node = resolvePath(root, path);
|
|
42
|
+
if (!node) return void 0;
|
|
43
|
+
if (hasDtcgValue(node)) return node.$value;
|
|
44
|
+
if (hasValueEntry(node)) return node.value;
|
|
45
|
+
return node;
|
|
46
|
+
};
|
|
47
|
+
const applyRef = (root, ref) => {
|
|
48
|
+
if (ref.startsWith("#/")) return resolveJsonPointer(root, ref);
|
|
49
|
+
const match = ref.match(/^\{(.+)\}$/);
|
|
50
|
+
if (match) return resolveTokenValueReference(root, match[1]);
|
|
51
|
+
return resolveTokenValueReference(root, ref);
|
|
52
|
+
};
|
|
53
|
+
const mergeGroups = (base, next) => {
|
|
54
|
+
const result = { ...base };
|
|
55
|
+
for (const [key, value] of Object.entries(next)) {
|
|
56
|
+
if (key === "$extends" || key === "$ref") continue;
|
|
57
|
+
const existing = result[key];
|
|
58
|
+
const existingIsToken = hasDtcgValue(existing);
|
|
59
|
+
const nextIsToken = hasDtcgValue(value);
|
|
60
|
+
if (!existing || existingIsToken || nextIsToken) {
|
|
61
|
+
result[key] = value;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (isPlainObject(existing) && isPlainObject(value)) result[key] = mergeGroups(existing, value);
|
|
65
|
+
else result[key] = value;
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
const resolveGroupExtends = (node, root, stack) => {
|
|
70
|
+
if (!isPlainObject(node) || hasDtcgValue(node)) return node;
|
|
71
|
+
const extendsValue = node.$extends ?? node.$ref;
|
|
72
|
+
const extendRefs = Array.isArray(extendsValue) ? extendsValue : extendsValue ? [extendsValue] : [];
|
|
73
|
+
let merged = {};
|
|
74
|
+
for (const ref of extendRefs) {
|
|
75
|
+
if (typeof ref !== "string") continue;
|
|
76
|
+
if (stack.has(ref)) continue;
|
|
77
|
+
const target = ref.startsWith("#/") ? resolveJsonPointer(root, ref) : resolvePath(root, ref.replace(/^\{|\}$/g, ""));
|
|
78
|
+
if (!isPlainObject(target)) continue;
|
|
79
|
+
stack.add(ref);
|
|
80
|
+
const resolvedTarget = resolveGroupExtends(target, root, stack);
|
|
81
|
+
stack.delete(ref);
|
|
82
|
+
if (isPlainObject(resolvedTarget)) merged = mergeGroups(merged, resolvedTarget);
|
|
83
|
+
}
|
|
84
|
+
const resolvedNode = {};
|
|
85
|
+
for (const [key, value] of Object.entries(node)) {
|
|
86
|
+
if (key === "$extends" || key === "$ref") continue;
|
|
87
|
+
resolvedNode[key] = resolveGroupExtends(value, root, stack);
|
|
88
|
+
}
|
|
89
|
+
return mergeGroups(merged, resolvedNode);
|
|
90
|
+
};
|
|
91
|
+
const tokenRefPattern = /\{([^}]+)\}/g;
|
|
92
|
+
const resolveReferences = (node, root, stack) => {
|
|
93
|
+
if (typeof node === "string") {
|
|
94
|
+
const matches = Array.from(node.matchAll(tokenRefPattern));
|
|
95
|
+
if (!matches.length) return node;
|
|
96
|
+
if (matches.length === 1 && matches[0][0] === node) {
|
|
97
|
+
const refPath = matches[0][1];
|
|
98
|
+
if (stack.has(refPath)) return node;
|
|
99
|
+
const refValue = resolveTokenValueReference(root, refPath);
|
|
100
|
+
if (refValue === void 0) return node;
|
|
101
|
+
stack.add(refPath);
|
|
102
|
+
const resolved = resolveReferences(refValue, root, stack);
|
|
103
|
+
stack.delete(refPath);
|
|
104
|
+
return resolved;
|
|
105
|
+
}
|
|
106
|
+
let nextValue = node;
|
|
107
|
+
for (const match of matches) {
|
|
108
|
+
const refPath = match[1];
|
|
109
|
+
if (stack.has(refPath)) continue;
|
|
110
|
+
const refValue = resolveTokenValueReference(root, refPath);
|
|
111
|
+
if (refValue === void 0) continue;
|
|
112
|
+
stack.add(refPath);
|
|
113
|
+
const resolved = resolveReferences(refValue, root, stack);
|
|
114
|
+
stack.delete(refPath);
|
|
115
|
+
nextValue = nextValue.replace(match[0], String(resolved));
|
|
116
|
+
}
|
|
117
|
+
return nextValue;
|
|
118
|
+
}
|
|
119
|
+
if (Array.isArray(node)) return node.map((entry) => resolveReferences(entry, root, stack));
|
|
120
|
+
if (!isPlainObject(node)) return node;
|
|
121
|
+
if (hasRefEntry(node)) {
|
|
122
|
+
const resolved = applyRef(root, node.$ref);
|
|
123
|
+
if (resolved === void 0) return node;
|
|
124
|
+
return resolveReferences(resolved, root, stack);
|
|
125
|
+
}
|
|
126
|
+
if (hasDtcgValue(node)) {
|
|
127
|
+
const nextValue = resolveReferences(node.$value, root, stack);
|
|
128
|
+
return {
|
|
129
|
+
...node,
|
|
130
|
+
$value: nextValue
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (hasValueEntry(node)) {
|
|
134
|
+
const nextValue = resolveReferences(node.value, root, stack);
|
|
135
|
+
return {
|
|
136
|
+
...node,
|
|
137
|
+
value: nextValue
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const result = {};
|
|
141
|
+
for (const [key, value] of Object.entries(node)) result[key] = resolveReferences(value, root, stack);
|
|
142
|
+
return result;
|
|
143
|
+
};
|
|
144
|
+
const getTokenPathFromRef = (ref) => {
|
|
145
|
+
if (ref.startsWith("#/")) {
|
|
146
|
+
const parts = ref.slice(2).split("/").map(decodeJsonPointer);
|
|
147
|
+
if (!parts.length) return null;
|
|
148
|
+
const valueIndex = parts.indexOf("$value");
|
|
149
|
+
const typeIndex = parts.indexOf("$type");
|
|
150
|
+
const stopIndex = valueIndex >= 0 ? valueIndex : typeIndex >= 0 ? typeIndex : parts.length;
|
|
151
|
+
const tokenParts = parts.slice(0, stopIndex);
|
|
152
|
+
return tokenParts.length ? tokenParts.join(".") : null;
|
|
153
|
+
}
|
|
154
|
+
const match = ref.match(/^\{(.+)\}$/);
|
|
155
|
+
if (match) return match[1];
|
|
156
|
+
return ref;
|
|
157
|
+
};
|
|
158
|
+
const getAliasPath = (node) => {
|
|
159
|
+
const value = hasDtcgValue(node) ? node.$value : hasValueEntry(node) ? node.value : void 0;
|
|
160
|
+
if (typeof value === "string") {
|
|
161
|
+
if (value.startsWith("#/")) return getTokenPathFromRef(value);
|
|
162
|
+
const match = value.match(/^\{(.+)\}$/);
|
|
163
|
+
return match ? match[1] : null;
|
|
164
|
+
}
|
|
165
|
+
if (isPlainObject(value) && hasRefEntry(value)) return getTokenPathFromRef(value.$ref);
|
|
166
|
+
if (hasRefEntry(node)) return getTokenPathFromRef(node.$ref);
|
|
167
|
+
return null;
|
|
168
|
+
};
|
|
169
|
+
const buildTokenMaps = (root) => {
|
|
170
|
+
const typeMap = /* @__PURE__ */ new Map();
|
|
171
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
172
|
+
const walk = (node, path, inheritedType) => {
|
|
173
|
+
if (!isPlainObject(node)) return;
|
|
174
|
+
const nodeType = typeof node.$type === "string" ? node.$type : inheritedType;
|
|
175
|
+
const hasOnlyMetaKeys = Object.keys(node).every((key) => key.startsWith("$"));
|
|
176
|
+
if ((hasDtcgValue(node) || hasValueEntry(node) || hasRefEntry(node) && hasOnlyMetaKeys) && path.length) {
|
|
177
|
+
const pathKey = path.join(".");
|
|
178
|
+
typeMap.set(pathKey, nodeType);
|
|
179
|
+
nodeMap.set(pathKey, node);
|
|
180
|
+
}
|
|
181
|
+
for (const [key, value] of Object.entries(node)) {
|
|
182
|
+
if (key.startsWith("$")) continue;
|
|
183
|
+
walk(value, [...path, key], nodeType);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
walk(root, []);
|
|
187
|
+
for (let iteration = 0; iteration < 6; iteration += 1) {
|
|
188
|
+
let changed = false;
|
|
189
|
+
for (const [path, node] of nodeMap.entries()) {
|
|
190
|
+
if (typeMap.get(path)) continue;
|
|
191
|
+
const aliasPath = getAliasPath(node);
|
|
192
|
+
if (!aliasPath) continue;
|
|
193
|
+
const aliasType = typeMap.get(aliasPath);
|
|
194
|
+
if (aliasType) {
|
|
195
|
+
typeMap.set(path, aliasType);
|
|
196
|
+
changed = true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!changed) break;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
typeMap,
|
|
203
|
+
nodeMap
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
const isValueUnitObject = (value) => Object.prototype.hasOwnProperty.call(value, "value") && Object.prototype.hasOwnProperty.call(value, "unit");
|
|
207
|
+
const normalizeValueUnit = (value, unit) => {
|
|
208
|
+
if (typeof value === "number" || typeof value === "string") return `${value}${typeof unit === "string" ? unit : unit == null ? "" : String(unit)}`;
|
|
209
|
+
return value;
|
|
210
|
+
};
|
|
211
|
+
const normalizeFontFamilyToken = (value) => {
|
|
212
|
+
const trimmed = value.trim();
|
|
213
|
+
if (trimmed.startsWith("\"") && trimmed.endsWith("\"") || trimmed.startsWith("'") && trimmed.endsWith("'")) return trimmed;
|
|
214
|
+
const needsQuotes = /\s/.test(trimmed);
|
|
215
|
+
const escaped = trimmed.replace(/"/g, "\\\"");
|
|
216
|
+
return needsQuotes ? `"${escaped}"` : escaped;
|
|
217
|
+
};
|
|
218
|
+
const fontWeightMap = {
|
|
219
|
+
thin: 100,
|
|
220
|
+
hairline: 100,
|
|
221
|
+
"extra-light": 200,
|
|
222
|
+
"ultra-light": 200,
|
|
223
|
+
light: 300,
|
|
224
|
+
normal: 400,
|
|
225
|
+
regular: 400,
|
|
226
|
+
book: 400,
|
|
227
|
+
medium: 500,
|
|
228
|
+
"semi-bold": 600,
|
|
229
|
+
"demi-bold": 600,
|
|
230
|
+
bold: 700,
|
|
231
|
+
"extra-bold": 800,
|
|
232
|
+
"ultra-bold": 800,
|
|
233
|
+
black: 900,
|
|
234
|
+
heavy: 900,
|
|
235
|
+
"extra-black": 950,
|
|
236
|
+
"ultra-black": 950
|
|
237
|
+
};
|
|
238
|
+
const normalizeFontWeight = (value) => {
|
|
239
|
+
if (typeof value === "number") return value;
|
|
240
|
+
if (typeof value === "string") {
|
|
241
|
+
const trimmed = value.trim();
|
|
242
|
+
if (/^\d+$/.test(trimmed)) return trimmed;
|
|
243
|
+
return fontWeightMap[trimmed.toLowerCase().replace(/_/g, "-").replace(/\s+/g, "-")] ?? trimmed;
|
|
244
|
+
}
|
|
245
|
+
return value;
|
|
246
|
+
};
|
|
247
|
+
const parseHexColor = (input) => {
|
|
248
|
+
const raw = input.startsWith("#") ? input.slice(1) : input;
|
|
249
|
+
if (![
|
|
250
|
+
3,
|
|
251
|
+
4,
|
|
252
|
+
6,
|
|
253
|
+
8
|
|
254
|
+
].includes(raw.length)) return null;
|
|
255
|
+
const expand = (value) => value.split("").map((ch) => ch + ch).join("");
|
|
256
|
+
const hex = raw.length <= 4 ? expand(raw) : raw;
|
|
257
|
+
const hasAlpha = hex.length === 8;
|
|
258
|
+
const r = parseInt(hex.slice(0, 2), 16);
|
|
259
|
+
const g = parseInt(hex.slice(2, 4), 16);
|
|
260
|
+
const b = parseInt(hex.slice(4, 6), 16);
|
|
261
|
+
const a = hasAlpha ? parseInt(hex.slice(6, 8), 16) / 255 : null;
|
|
262
|
+
if ([
|
|
263
|
+
r,
|
|
264
|
+
g,
|
|
265
|
+
b
|
|
266
|
+
].some(Number.isNaN)) return null;
|
|
267
|
+
return {
|
|
268
|
+
r,
|
|
269
|
+
g,
|
|
270
|
+
b,
|
|
271
|
+
a
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
const normalizeColor = (value) => {
|
|
275
|
+
if (typeof value === "string") return value;
|
|
276
|
+
if (!isPlainObject(value)) return value;
|
|
277
|
+
if (typeof value.hex === "string") {
|
|
278
|
+
const parsed = parseHexColor(value.hex);
|
|
279
|
+
const alpha = typeof value.alpha === "number" ? value.alpha : null;
|
|
280
|
+
if (parsed) {
|
|
281
|
+
const alphaValue = alpha ?? parsed.a;
|
|
282
|
+
if (alphaValue != null && alphaValue >= 0 && alphaValue <= 1) return `rgb(${parsed.r} ${parsed.g} ${parsed.b} / ${alphaValue})`;
|
|
283
|
+
}
|
|
284
|
+
return value.hex;
|
|
285
|
+
}
|
|
286
|
+
if (Array.isArray(value.components)) {
|
|
287
|
+
const components = value.components;
|
|
288
|
+
const colorSpace = typeof value.colorSpace === "string" ? value.colorSpace : "srgb";
|
|
289
|
+
let alpha = typeof value.alpha === "number" ? value.alpha : void 0;
|
|
290
|
+
if (alpha === void 0 && components.length >= 4 && typeof components[3] === "number") alpha = components[3];
|
|
291
|
+
const normalized = components.map((component) => {
|
|
292
|
+
if (component === "none") return "none";
|
|
293
|
+
if (typeof component === "number") return component;
|
|
294
|
+
const numeric = Number(component);
|
|
295
|
+
return Number.isNaN(numeric) ? null : numeric;
|
|
296
|
+
});
|
|
297
|
+
if (normalized.some((component) => component === null)) return value;
|
|
298
|
+
const sanitized = normalized;
|
|
299
|
+
if (colorSpace === "srgb" || colorSpace === "srgb-linear") {
|
|
300
|
+
const numeric = sanitized.slice(0, 3);
|
|
301
|
+
const usesNormalized = numeric.every((component) => component === "none" || component >= 0 && component <= 1);
|
|
302
|
+
const rgb = numeric.map((component) => {
|
|
303
|
+
if (component === "none") return "none";
|
|
304
|
+
return usesNormalized ? Math.round(component * 255) : Math.round(component);
|
|
305
|
+
});
|
|
306
|
+
if (alpha != null && alpha >= 0 && alpha <= 1) return `rgb(${rgb[0]} ${rgb[1]} ${rgb[2]} / ${alpha})`;
|
|
307
|
+
return `rgb(${rgb[0]} ${rgb[1]} ${rgb[2]})`;
|
|
308
|
+
}
|
|
309
|
+
const colorArgs = sanitized.slice(0, 3).map((component) => String(component)).join(" ");
|
|
310
|
+
if (alpha != null && alpha >= 0 && alpha <= 1) return `color(${colorSpace} ${colorArgs} / ${alpha})`;
|
|
311
|
+
return `color(${colorSpace} ${colorArgs})`;
|
|
312
|
+
}
|
|
313
|
+
return value;
|
|
314
|
+
};
|
|
315
|
+
const normalizeCubicBezier = (value) => {
|
|
316
|
+
if (Array.isArray(value)) {
|
|
317
|
+
const numeric = value.filter((component) => typeof component === "number");
|
|
318
|
+
if (numeric.length >= 4) return `cubic-bezier(${numeric.slice(0, 4).join(", ")})`;
|
|
319
|
+
}
|
|
320
|
+
if (typeof value === "string") return value;
|
|
321
|
+
return value;
|
|
322
|
+
};
|
|
323
|
+
const normalizeStrokeStyle = (value) => {
|
|
324
|
+
if (typeof value === "string") return value;
|
|
325
|
+
if (isPlainObject(value)) {
|
|
326
|
+
if (Array.isArray(value.dashArray) || value.dashArray != null) return "dashed";
|
|
327
|
+
return "solid";
|
|
328
|
+
}
|
|
329
|
+
return value;
|
|
330
|
+
};
|
|
331
|
+
const normalizeShadowItem = (value, normalize) => {
|
|
332
|
+
const inset = value.inset ? "inset" : null;
|
|
333
|
+
const offsetX = normalize(value.offsetX, "dimension") ?? "0";
|
|
334
|
+
const offsetY = normalize(value.offsetY, "dimension") ?? "0";
|
|
335
|
+
const blur = normalize(value.blur, "dimension");
|
|
336
|
+
const spread = normalize(value.spread, "dimension");
|
|
337
|
+
const color = normalize(value.color, "color");
|
|
338
|
+
const parts = [
|
|
339
|
+
inset,
|
|
340
|
+
offsetX,
|
|
341
|
+
offsetY
|
|
342
|
+
].filter(Boolean).map(String);
|
|
343
|
+
const blurValue = blur ?? (spread != null ? "0" : null);
|
|
344
|
+
if (blurValue != null) parts.push(String(blurValue));
|
|
345
|
+
if (spread != null) parts.push(String(spread));
|
|
346
|
+
if (color != null) parts.push(String(color));
|
|
347
|
+
return parts.join(" ");
|
|
348
|
+
};
|
|
349
|
+
const normalizeGradientStops = (value) => {
|
|
350
|
+
if (Array.isArray(value)) {
|
|
351
|
+
const stops = [];
|
|
352
|
+
for (const entry of value) if (Array.isArray(entry)) stops.push(...entry);
|
|
353
|
+
else stops.push(entry);
|
|
354
|
+
return stops;
|
|
355
|
+
}
|
|
356
|
+
return [value];
|
|
357
|
+
};
|
|
358
|
+
const normalizeGradientPosition = (value) => {
|
|
359
|
+
if (typeof value === "number") {
|
|
360
|
+
const clamped = Math.min(Math.max(value, 0), 1);
|
|
361
|
+
return `${Math.round(clamped * 1e4) / 100}%`;
|
|
362
|
+
}
|
|
363
|
+
if (typeof value === "string") return value;
|
|
364
|
+
if (isPlainObject(value) && isValueUnitObject(value)) return normalizeValueUnit(value.value, value.unit);
|
|
365
|
+
return value;
|
|
366
|
+
};
|
|
367
|
+
const normalizeTokenValue = (value, type) => {
|
|
368
|
+
if (hasDtcgValue(value)) {
|
|
369
|
+
const nestedType = typeof value.$type === "string" ? value.$type : type;
|
|
370
|
+
return normalizeTokenValue(value.$value, nestedType);
|
|
371
|
+
}
|
|
372
|
+
if (hasValueEntry(value)) {
|
|
373
|
+
const nestedType = typeof value.$type === "string" ? value.$type : type;
|
|
374
|
+
return normalizeTokenValue(value.value, nestedType);
|
|
375
|
+
}
|
|
376
|
+
if (type === "color") return normalizeColor(value);
|
|
377
|
+
if (type === "dimension" || type === "duration") {
|
|
378
|
+
if (isPlainObject(value) && isValueUnitObject(value)) return normalizeValueUnit(value.value, value.unit);
|
|
379
|
+
return value;
|
|
380
|
+
}
|
|
381
|
+
if (type === "fontFamily") {
|
|
382
|
+
if (Array.isArray(value)) return value.map((entry) => normalizeFontFamilyToken(String(entry))).join(", ");
|
|
383
|
+
if (typeof value === "string") {
|
|
384
|
+
if (value.includes(",")) return value.split(",").map((entry) => normalizeFontFamilyToken(entry.trim())).join(", ");
|
|
385
|
+
return normalizeFontFamilyToken(value);
|
|
386
|
+
}
|
|
387
|
+
return value;
|
|
388
|
+
}
|
|
389
|
+
if (type === "fontWeight") return normalizeFontWeight(value);
|
|
390
|
+
if (type === "cubicBezier") return normalizeCubicBezier(value);
|
|
391
|
+
if (type === "strokeStyle") return normalizeStrokeStyle(value);
|
|
392
|
+
if (type === "border") {
|
|
393
|
+
if (!isPlainObject(value)) return value;
|
|
394
|
+
return [
|
|
395
|
+
normalizeTokenValue(value.width, "dimension"),
|
|
396
|
+
normalizeTokenValue(value.style, "strokeStyle"),
|
|
397
|
+
normalizeTokenValue(value.color, "color")
|
|
398
|
+
].filter((v) => v != null && v !== "").map(String).join(" ");
|
|
399
|
+
}
|
|
400
|
+
if (type === "transition") {
|
|
401
|
+
if (!isPlainObject(value)) return value;
|
|
402
|
+
return [
|
|
403
|
+
normalizeTokenValue(value.duration, "duration"),
|
|
404
|
+
normalizeTokenValue(value.timingFunction, "cubicBezier"),
|
|
405
|
+
normalizeTokenValue(value.delay, "duration")
|
|
406
|
+
].filter((v) => v != null && v !== "").map(String).join(" ");
|
|
407
|
+
}
|
|
408
|
+
if (type === "shadow") {
|
|
409
|
+
if (Array.isArray(value)) return normalizeGradientStops(value).map((item) => isPlainObject(item) ? normalizeShadowItem(item, normalizeTokenValue) : String(item)).filter(Boolean).join(", ");
|
|
410
|
+
if (!isPlainObject(value)) return value;
|
|
411
|
+
return normalizeShadowItem(value, normalizeTokenValue);
|
|
412
|
+
}
|
|
413
|
+
if (type === "gradient") return `linear-gradient(${normalizeGradientStops(value).map((stop) => {
|
|
414
|
+
if (typeof stop === "string") return stop;
|
|
415
|
+
if (!isPlainObject(stop)) return String(stop);
|
|
416
|
+
return [normalizeTokenValue(stop.color, "color"), normalizeGradientPosition(stop.position)].filter((v) => v != null && v !== "").map(String).join(" ");
|
|
417
|
+
}).filter(Boolean).join(", ")})`;
|
|
418
|
+
if (type === "typography") {
|
|
419
|
+
if (!isPlainObject(value)) return value;
|
|
420
|
+
const fontWeight = normalizeTokenValue(value.fontWeight, "fontWeight");
|
|
421
|
+
const fontSize = normalizeTokenValue(value.fontSize, "dimension");
|
|
422
|
+
const lineHeight = normalizeTokenValue(value.lineHeight, "number");
|
|
423
|
+
const fontFamily = normalizeTokenValue(value.fontFamily, "fontFamily");
|
|
424
|
+
const parts = [];
|
|
425
|
+
if (fontWeight != null && fontWeight !== "") parts.push(String(fontWeight));
|
|
426
|
+
if (fontSize != null && fontSize !== "") if (lineHeight != null && lineHeight !== "") parts.push(`${fontSize}/${lineHeight}`);
|
|
427
|
+
else parts.push(String(fontSize));
|
|
428
|
+
if (fontFamily != null && fontFamily !== "") parts.push(String(fontFamily));
|
|
429
|
+
return parts.join(" ");
|
|
430
|
+
}
|
|
431
|
+
if (isPlainObject(value) && isValueUnitObject(value)) return normalizeValueUnit(value.value, value.unit);
|
|
432
|
+
if (isPlainObject(value) && typeof value.hex === "string" && Object.keys(value).length <= 3) return normalizeColor(value);
|
|
433
|
+
if (Array.isArray(value)) return value.map((entry) => normalizeTokenValue(entry));
|
|
434
|
+
if (isPlainObject(value)) {
|
|
435
|
+
const result = {};
|
|
436
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
437
|
+
if (key.startsWith("$")) continue;
|
|
438
|
+
result[key] = normalizeTokenValue(entry);
|
|
439
|
+
}
|
|
440
|
+
return result;
|
|
441
|
+
}
|
|
442
|
+
return value;
|
|
443
|
+
};
|
|
444
|
+
const normalizeNode = (node, context) => {
|
|
445
|
+
const pathKey = context.path.join(".");
|
|
446
|
+
const mappedType = pathKey ? context.typeMap.get(pathKey) : void 0;
|
|
447
|
+
if (mappedType && !hasDtcgValue(node) && !hasValueEntry(node)) return normalizeTokenValue(node, mappedType);
|
|
448
|
+
if (Array.isArray(node)) return node.map((entry) => normalizeNode(entry, context));
|
|
449
|
+
if (!isPlainObject(node)) return node;
|
|
450
|
+
if (hasDtcgValue(node) || hasValueEntry(node)) return normalizeTokenValue(hasDtcgValue(node) ? node.$value : node.value, (typeof node.$type === "string" ? node.$type : void 0) ?? context.type ?? mappedType);
|
|
451
|
+
const nodeType = typeof node.$type === "string" ? node.$type : context.type;
|
|
452
|
+
const result = {};
|
|
453
|
+
for (const [key, value] of Object.entries(node)) {
|
|
454
|
+
if (key.startsWith("$")) continue;
|
|
455
|
+
result[key] = normalizeNode(value, {
|
|
456
|
+
type: nodeType,
|
|
457
|
+
path: [...context.path, key],
|
|
458
|
+
typeMap: context.typeMap
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return result;
|
|
462
|
+
};
|
|
463
|
+
const normalizeTokens = (input) => {
|
|
464
|
+
const extended = resolveGroupExtends(input, input, /* @__PURE__ */ new Set());
|
|
465
|
+
const { typeMap } = buildTokenMaps(extended);
|
|
466
|
+
return normalizeNode(resolveReferences(extended, extended, /* @__PURE__ */ new Set()), {
|
|
467
|
+
path: [],
|
|
468
|
+
typeMap
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
//#endregion
|
|
473
|
+
export { normalizeTokens };
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/use/token/propMap.ts
|
|
3
3
|
const propMap = new Map([
|
|
4
|
+
["gradient", new Set([
|
|
5
|
+
"background-image",
|
|
6
|
+
"linear-gradient",
|
|
7
|
+
"radial-gradient",
|
|
8
|
+
"conic-gradient"
|
|
9
|
+
])],
|
|
10
|
+
["shadow", new Set(["box-shadow", "text-shadow"])],
|
|
4
11
|
["color", new Set([
|
|
5
12
|
"color",
|
|
6
13
|
"background",
|
|
@@ -20,6 +27,16 @@ const propMap = new Map([
|
|
|
20
27
|
"conic-gradient",
|
|
21
28
|
"filter"
|
|
22
29
|
])],
|
|
30
|
+
["border", new Set([
|
|
31
|
+
"border",
|
|
32
|
+
"border-top",
|
|
33
|
+
"border-right",
|
|
34
|
+
"border-bottom",
|
|
35
|
+
"border-left",
|
|
36
|
+
"outline",
|
|
37
|
+
"outline-offset"
|
|
38
|
+
])],
|
|
39
|
+
["transition", new Set(["transition"])],
|
|
23
40
|
["size", new Set([
|
|
24
41
|
"width",
|
|
25
42
|
"height",
|
|
@@ -79,17 +96,28 @@ const propMap = new Map([
|
|
|
79
96
|
"object-position",
|
|
80
97
|
"transform-origin"
|
|
81
98
|
])],
|
|
99
|
+
["typography", new Set(["font"])],
|
|
82
100
|
["font", new Set(["font-family"])]
|
|
83
101
|
]);
|
|
84
102
|
const toDashCase = (value) => value.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
85
|
-
const
|
|
86
|
-
if (!prop) return
|
|
103
|
+
const getTokenGroupsForProp = (prop) => {
|
|
104
|
+
if (!prop) return [];
|
|
87
105
|
const target = toDashCase(prop);
|
|
106
|
+
const matches = [];
|
|
88
107
|
for (const [group, props] of propMap.entries()) {
|
|
89
|
-
if (toDashCase(group) === target)
|
|
90
|
-
|
|
108
|
+
if (toDashCase(group) === target) {
|
|
109
|
+
matches.push(group);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
for (const name of props) if (toDashCase(String(name)) === target) {
|
|
113
|
+
matches.push(group);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
91
116
|
}
|
|
92
|
-
return
|
|
117
|
+
return matches;
|
|
118
|
+
};
|
|
119
|
+
const getTokenGroupForProp = (prop) => {
|
|
120
|
+
return getTokenGroupsForProp(prop)[0] ?? null;
|
|
93
121
|
};
|
|
94
122
|
const setTokenPropGroups = (groups) => {
|
|
95
123
|
propMap.clear();
|
|
@@ -104,6 +132,7 @@ const getTokenPropGroups = () => {
|
|
|
104
132
|
|
|
105
133
|
//#endregion
|
|
106
134
|
exports.getTokenGroupForProp = getTokenGroupForProp;
|
|
135
|
+
exports.getTokenGroupsForProp = getTokenGroupsForProp;
|
|
107
136
|
exports.getTokenPropGroups = getTokenPropGroups;
|
|
108
137
|
exports.propMap = propMap;
|
|
109
138
|
exports.setTokenPropGroups = setTokenPropGroups;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
//#region src/use/token/propMap.ts
|
|
2
2
|
const propMap = new Map([
|
|
3
|
+
["gradient", new Set([
|
|
4
|
+
"background-image",
|
|
5
|
+
"linear-gradient",
|
|
6
|
+
"radial-gradient",
|
|
7
|
+
"conic-gradient"
|
|
8
|
+
])],
|
|
9
|
+
["shadow", new Set(["box-shadow", "text-shadow"])],
|
|
3
10
|
["color", new Set([
|
|
4
11
|
"color",
|
|
5
12
|
"background",
|
|
@@ -19,6 +26,16 @@ const propMap = new Map([
|
|
|
19
26
|
"conic-gradient",
|
|
20
27
|
"filter"
|
|
21
28
|
])],
|
|
29
|
+
["border", new Set([
|
|
30
|
+
"border",
|
|
31
|
+
"border-top",
|
|
32
|
+
"border-right",
|
|
33
|
+
"border-bottom",
|
|
34
|
+
"border-left",
|
|
35
|
+
"outline",
|
|
36
|
+
"outline-offset"
|
|
37
|
+
])],
|
|
38
|
+
["transition", new Set(["transition"])],
|
|
22
39
|
["size", new Set([
|
|
23
40
|
"width",
|
|
24
41
|
"height",
|
|
@@ -78,17 +95,28 @@ const propMap = new Map([
|
|
|
78
95
|
"object-position",
|
|
79
96
|
"transform-origin"
|
|
80
97
|
])],
|
|
98
|
+
["typography", new Set(["font"])],
|
|
81
99
|
["font", new Set(["font-family"])]
|
|
82
100
|
]);
|
|
83
101
|
const toDashCase = (value) => value.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
84
|
-
const
|
|
85
|
-
if (!prop) return
|
|
102
|
+
const getTokenGroupsForProp = (prop) => {
|
|
103
|
+
if (!prop) return [];
|
|
86
104
|
const target = toDashCase(prop);
|
|
105
|
+
const matches = [];
|
|
87
106
|
for (const [group, props] of propMap.entries()) {
|
|
88
|
-
if (toDashCase(group) === target)
|
|
89
|
-
|
|
107
|
+
if (toDashCase(group) === target) {
|
|
108
|
+
matches.push(group);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
for (const name of props) if (toDashCase(String(name)) === target) {
|
|
112
|
+
matches.push(group);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
90
115
|
}
|
|
91
|
-
return
|
|
116
|
+
return matches;
|
|
117
|
+
};
|
|
118
|
+
const getTokenGroupForProp = (prop) => {
|
|
119
|
+
return getTokenGroupsForProp(prop)[0] ?? null;
|
|
92
120
|
};
|
|
93
121
|
const setTokenPropGroups = (groups) => {
|
|
94
122
|
propMap.clear();
|
|
@@ -102,4 +130,4 @@ const getTokenPropGroups = () => {
|
|
|
102
130
|
};
|
|
103
131
|
|
|
104
132
|
//#endregion
|
|
105
|
-
export { getTokenGroupForProp, getTokenPropGroups, propMap, setTokenPropGroups };
|
|
133
|
+
export { getTokenGroupForProp, getTokenGroupsForProp, getTokenPropGroups, propMap, setTokenPropGroups };
|