boss-css 0.0.1 → 0.0.3
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/README.md +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +43 -0
- package/dist/_virtual/rolldown_runtime.mjs +20 -0
- package/dist/api/browser.cjs +54 -0
- package/dist/api/browser.mjs +48 -0
- package/dist/api/config.cjs +94 -0
- package/dist/api/config.mjs +91 -0
- package/dist/api/css.cjs +304 -0
- package/dist/api/css.mjs +303 -0
- package/dist/api/dictionary.cjs +218 -0
- package/dist/api/dictionary.mjs +215 -0
- package/dist/api/file/dts.cjs +21 -0
- package/dist/api/file/dts.mjs +21 -0
- package/dist/api/file/file.cjs +123 -0
- package/dist/api/file/file.mjs +120 -0
- package/dist/api/file/js.cjs +118 -0
- package/dist/api/file/js.mjs +116 -0
- package/dist/api/names.cjs +52 -0
- package/dist/api/names.mjs +46 -0
- package/dist/api/noopCss.cjs +37 -0
- package/dist/api/noopCss.mjs +36 -0
- package/dist/api/propTree.cjs +54 -0
- package/dist/api/propTree.mjs +48 -0
- package/dist/api/server.cjs +112 -0
- package/dist/api/server.mjs +106 -0
- package/dist/cli/build.cjs +1 -0
- package/dist/cli/build.mjs +3 -0
- package/dist/cli/index.cjs +30 -0
- package/dist/cli/index.mjs +29 -0
- package/dist/cli/tasks/build.cjs +24 -0
- package/dist/cli/tasks/build.mjs +23 -0
- package/dist/cli/tasks/choose.cjs +47 -0
- package/dist/cli/tasks/choose.mjs +46 -0
- package/dist/cli/tasks/compile.cjs +68 -0
- package/dist/cli/tasks/compile.mjs +67 -0
- package/dist/cli/tasks/dev.cjs +51 -0
- package/dist/cli/tasks/dev.mjs +48 -0
- package/dist/cli/tasks/init.cjs +1835 -0
- package/dist/cli/tasks/init.mjs +1831 -0
- package/dist/cli/tasks/watch.cjs +38 -0
- package/dist/cli/tasks/watch.mjs +37 -0
- package/dist/cli/templates/init.cjs +82 -0
- package/dist/cli/templates/init.mjs +78 -0
- package/dist/cli/types.cjs +13 -0
- package/dist/cli/types.mjs +13 -0
- package/dist/cli/utils.cjs +43 -0
- package/dist/cli/utils.mjs +41 -0
- package/dist/compile/classname-strategy.cjs +79 -0
- package/dist/compile/classname-strategy.mjs +77 -0
- package/dist/compile/classname.cjs +366 -0
- package/dist/compile/classname.mjs +360 -0
- package/dist/compile/index.cjs +238 -0
- package/dist/compile/index.mjs +235 -0
- package/dist/compile/jsx.cjs +803 -0
- package/dist/compile/jsx.mjs +800 -0
- package/dist/compile/prepared.cjs +88 -0
- package/dist/compile/prepared.mjs +87 -0
- package/dist/compile/runtime.cjs +33 -0
- package/dist/compile/runtime.mjs +32 -0
- package/dist/compile/transform.cjs +371 -0
- package/dist/compile/transform.mjs +369 -0
- package/dist/cx/index.cjs +93 -0
- package/dist/cx/index.mjs +85 -0
- package/dist/detect-fw/index.cjs +384 -0
- package/dist/detect-fw/index.mjs +379 -0
- package/dist/dev/client.cjs +39 -0
- package/dist/dev/client.mjs +38 -0
- package/dist/dev/plugin/browser.cjs +11 -0
- package/dist/dev/plugin/browser.mjs +9 -0
- package/dist/dev/plugin/server.cjs +86 -0
- package/dist/dev/plugin/server.mjs +78 -0
- package/dist/dev/port.cjs +46 -0
- package/dist/dev/port.mjs +43 -0
- package/dist/dev/runtime.cjs +28 -0
- package/dist/dev/runtime.mjs +29 -0
- package/dist/dev/server.cjs +808 -0
- package/dist/dev/server.mjs +805 -0
- package/dist/dev/shared.cjs +6 -0
- package/dist/dev/shared.mjs +5 -0
- package/dist/eslint-plugin/index.cjs +66 -0
- package/dist/eslint-plugin/index.mjs +66 -0
- package/dist/eslint-plugin/rules/classnames-only.cjs +68 -0
- package/dist/eslint-plugin/rules/classnames-only.mjs +68 -0
- package/dist/eslint-plugin/rules/format-classnames.cjs +137 -0
- package/dist/eslint-plugin/rules/format-classnames.mjs +136 -0
- package/dist/eslint-plugin/rules/no-unknown-classes.cjs +119 -0
- package/dist/eslint-plugin/rules/no-unknown-classes.mjs +119 -0
- package/dist/eslint-plugin/rules/prefer-classnames.cjs +69 -0
- package/dist/eslint-plugin/rules/prefer-classnames.mjs +69 -0
- package/dist/eslint-plugin/rules/prefer-token-values.cjs +197 -0
- package/dist/eslint-plugin/rules/prefer-token-values.mjs +197 -0
- package/dist/eslint-plugin/rules/props-only.cjs +115 -0
- package/dist/eslint-plugin/rules/props-only.mjs +115 -0
- package/dist/eslint-plugin/rules/redundant-cx.cjs +66 -0
- package/dist/eslint-plugin/rules/redundant-cx.mjs +66 -0
- package/dist/eslint-plugin/rules/require-prop-functions.cjs +130 -0
- package/dist/eslint-plugin/rules/require-prop-functions.mjs +130 -0
- package/dist/eslint-plugin/utils/api.cjs +30 -0
- package/dist/eslint-plugin/utils/api.mjs +29 -0
- package/dist/eslint-plugin/utils/ast.cjs +119 -0
- package/dist/eslint-plugin/utils/ast.mjs +112 -0
- package/dist/eslint-plugin/utils/boss-classes.cjs +185 -0
- package/dist/eslint-plugin/utils/boss-classes.mjs +175 -0
- package/dist/eslint-plugin/utils/defaults.cjs +99 -0
- package/dist/eslint-plugin/utils/defaults.mjs +93 -0
- package/dist/eslint-plugin/utils/format.cjs +20 -0
- package/dist/eslint-plugin/utils/format.mjs +19 -0
- package/dist/eslint-plugin/utils/order.cjs +76 -0
- package/dist/eslint-plugin/utils/order.mjs +76 -0
- package/dist/eslint-plugin/utils/property-order.cjs +449 -0
- package/dist/eslint-plugin/utils/property-order.mjs +448 -0
- package/dist/eslint-plugin/utils/static.cjs +36 -0
- package/dist/eslint-plugin/utils/static.mjs +35 -0
- package/dist/fontsource/directory.cjs +39588 -0
- package/dist/fontsource/directory.mjs +39587 -0
- package/dist/fontsource/server.cjs +291 -0
- package/dist/fontsource/server.mjs +282 -0
- package/dist/index.cjs +10 -0
- package/dist/index.mjs +6 -0
- package/dist/log/browser.cjs +28 -0
- package/dist/log/browser.mjs +28 -0
- package/dist/log/server.cjs +32 -0
- package/dist/log/server.mjs +30 -0
- package/dist/merge/index.cjs +590 -0
- package/dist/merge/index.mjs +586 -0
- package/dist/native/browser.cjs +78 -0
- package/dist/native/browser.mjs +77 -0
- package/dist/native/server.cjs +180 -0
- package/dist/native/server.mjs +176 -0
- package/dist/native/styleTypes.cjs +168 -0
- package/dist/native/styleTypes.mjs +164 -0
- package/dist/parser/classname/server.cjs +239 -0
- package/dist/parser/classname/server.mjs +232 -0
- package/dist/parser/jsx/browser.cjs +66 -0
- package/dist/parser/jsx/browser.mjs +63 -0
- package/dist/parser/jsx/extractCode.cjs +99 -0
- package/dist/parser/jsx/extractCode.mjs +98 -0
- package/dist/parser/jsx/extractPrepared.cjs +123 -0
- package/dist/parser/jsx/extractPrepared.mjs +122 -0
- package/dist/parser/jsx/extractProps.cjs +234 -0
- package/dist/parser/jsx/extractProps.mjs +232 -0
- package/dist/parser/jsx/isDOMProp.cjs +17 -0
- package/dist/parser/jsx/isDOMProp.mjs +15 -0
- package/dist/parser/jsx/native.cjs +110 -0
- package/dist/parser/jsx/native.mjs +108 -0
- package/dist/parser/jsx/runtime.cjs +4 -0
- package/dist/parser/jsx/runtime.mjs +3 -0
- package/dist/parser/jsx/server.cjs +278 -0
- package/dist/parser/jsx/server.mjs +268 -0
- package/dist/postcss/index.cjs +16 -0
- package/dist/postcss/index.mjs +16 -0
- package/dist/prop/at/runtime-only.cjs +90 -0
- package/dist/prop/at/runtime-only.mjs +88 -0
- package/dist/prop/at/server.cjs +282 -0
- package/dist/prop/at/server.mjs +268 -0
- package/dist/prop/at/shared.cjs +153 -0
- package/dist/prop/at/shared.mjs +144 -0
- package/dist/prop/bosswind/browser.cjs +18 -0
- package/dist/prop/bosswind/browser.mjs +16 -0
- package/dist/prop/bosswind/runtime-only.cjs +18 -0
- package/dist/prop/bosswind/runtime-only.mjs +16 -0
- package/dist/prop/bosswind/server.cjs +81 -0
- package/dist/prop/bosswind/server.mjs +72 -0
- package/dist/prop/bosswind/shared.cjs +861 -0
- package/dist/prop/bosswind/shared.mjs +855 -0
- package/dist/prop/bosswind/tailwind-theme.cjs +703 -0
- package/dist/prop/bosswind/tailwind-theme.mjs +702 -0
- package/dist/prop/child/runtime-only.cjs +18 -0
- package/dist/prop/child/runtime-only.mjs +15 -0
- package/dist/prop/child/server.cjs +81 -0
- package/dist/prop/child/server.mjs +72 -0
- package/dist/prop/css/getDtsTemplate.cjs +65 -0
- package/dist/prop/css/getDtsTemplate.mjs +63 -0
- package/dist/prop/css/runtime-only.cjs +14 -0
- package/dist/prop/css/runtime-only.mjs +13 -0
- package/dist/prop/css/server.cjs +99 -0
- package/dist/prop/css/server.mjs +90 -0
- package/dist/prop/pseudo/runtime-only.cjs +23 -0
- package/dist/prop/pseudo/runtime-only.mjs +21 -0
- package/dist/prop/pseudo/server.cjs +91 -0
- package/dist/prop/pseudo/server.mjs +82 -0
- package/dist/prop/pseudo/shared.cjs +61 -0
- package/dist/prop/pseudo/shared.mjs +60 -0
- package/dist/reset/server.cjs +34 -0
- package/dist/reset/server.mjs +26 -0
- package/dist/runtime/index.cjs +119 -0
- package/dist/runtime/index.mjs +118 -0
- package/dist/runtime/preact.cjs +4 -0
- package/dist/runtime/preact.mjs +3 -0
- package/dist/runtime/qwik.cjs +21 -0
- package/dist/runtime/qwik.mjs +18 -0
- package/dist/runtime/react.cjs +4 -0
- package/dist/runtime/react.mjs +3 -0
- package/dist/runtime/solid.cjs +15 -0
- package/dist/runtime/solid.mjs +14 -0
- package/dist/runtime/stencil.cjs +25 -0
- package/dist/runtime/stencil.mjs +21 -0
- package/dist/runtime/style.cjs +14 -0
- package/dist/runtime/style.mjs +13 -0
- package/dist/shared/boundaries.cjs +288 -0
- package/dist/shared/boundaries.mjs +285 -0
- package/dist/shared/customCss.cjs +212 -0
- package/dist/shared/customCss.mjs +211 -0
- package/dist/shared/debug.cjs +76 -0
- package/dist/shared/debug.mjs +74 -0
- package/dist/shared/file.cjs +21 -0
- package/dist/shared/file.mjs +19 -0
- package/dist/shared/framework.cjs +10 -0
- package/dist/shared/framework.mjs +9 -0
- package/dist/shared/json.cjs +58 -0
- package/dist/shared/json.mjs +57 -0
- package/dist/shared/types.cjs +11 -0
- package/dist/shared/types.mjs +10 -0
- package/dist/strategy/classic/runtime-only.cjs +190 -0
- package/dist/strategy/classic/runtime-only.mjs +186 -0
- package/dist/strategy/classname-first/runtime-only.cjs +138 -0
- package/dist/strategy/classname-first/runtime-only.mjs +134 -0
- package/dist/strategy/classname-first/server.cjs +139 -0
- package/dist/strategy/classname-first/server.mjs +133 -0
- package/dist/strategy/classname-only/server.cjs +43 -0
- package/dist/strategy/classname-only/server.mjs +35 -0
- package/dist/strategy/inline-first/browser.cjs +61 -0
- package/dist/strategy/inline-first/browser.mjs +58 -0
- package/dist/strategy/inline-first/runtime-only.cjs +159 -0
- package/dist/strategy/inline-first/runtime-only.mjs +155 -0
- package/dist/strategy/inline-first/server.cjs +92 -0
- package/dist/strategy/inline-first/server.mjs +83 -0
- package/dist/strategy/runtime/runtime-only.cjs +24 -0
- package/dist/strategy/runtime/runtime-only.mjs +22 -0
- package/dist/strategy/runtime/server.cjs +72 -0
- package/dist/strategy/runtime/server.mjs +63 -0
- package/dist/strategy/runtime-only/css.cjs +183 -0
- package/dist/strategy/runtime-only/css.mjs +181 -0
- package/dist/tasks/build.cjs +88 -0
- package/dist/tasks/build.mjs +84 -0
- package/dist/tasks/compile.cjs +12 -0
- package/dist/tasks/compile.mjs +12 -0
- package/dist/tasks/postcss.cjs +116 -0
- package/dist/tasks/postcss.mjs +113 -0
- package/dist/tasks/session.cjs +46 -0
- package/dist/tasks/session.mjs +42 -0
- package/dist/tasks/watch.cjs +102 -0
- package/dist/tasks/watch.mjs +99 -0
- package/dist/transform/cache.cjs +24 -0
- package/dist/transform/cache.mjs +21 -0
- package/dist/transform/processFile.cjs +26 -0
- package/dist/transform/processFile.mjs +24 -0
- package/dist/use/token/browser.cjs +65 -0
- package/dist/use/token/browser.mjs +61 -0
- package/dist/use/token/runtime-only.cjs +245 -0
- package/dist/use/token/runtime-only.mjs +239 -0
- package/dist/use/token/server.cjs +325 -0
- package/dist/use/token/server.mjs +313 -0
- package/dist/use/token/vars.cjs +47 -0
- package/dist/use/token/vars.mjs +46 -0
- package/package.json +300 -4
- package/src/api/config.d.ts +1 -0
- package/src/fontsource/types.d.ts +50 -0
- package/src/packages/document-create-element/createElement.browser.js +3 -0
- package/src/packages/document-create-element/createElement.js +7 -0
- package/src/packages/document-create-element/package.json +17 -0
- package/src/packages/is-css-prop/browser.js +13 -0
- package/src/packages/is-css-prop/index.js +13 -0
- package/src/packages/is-css-prop/package-lock.json +52 -0
- package/src/packages/is-css-prop/package.json +17 -0
- package/src/prop/css/csstype.json +4387 -0
- package/src/prop/css/package.json +3 -0
- package/src/reset/reset.css +259 -0
|
@@ -0,0 +1,855 @@
|
|
|
1
|
+
//#region src/prop/bosswind/shared.ts
|
|
2
|
+
const toDashCase = (value) => value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
3
|
+
const displayKeywords = new Map([
|
|
4
|
+
["block", "block"],
|
|
5
|
+
["inline", "inline"],
|
|
6
|
+
["inlineBlock", "inline-block"],
|
|
7
|
+
["inlineFlex", "inline-flex"],
|
|
8
|
+
["inlineGrid", "inline-grid"],
|
|
9
|
+
["contents", "contents"],
|
|
10
|
+
["flowRoot", "flow-root"],
|
|
11
|
+
["table", "table"],
|
|
12
|
+
["inlineTable", "inline-table"],
|
|
13
|
+
["tableRow", "table-row"],
|
|
14
|
+
["tableCell", "table-cell"]
|
|
15
|
+
]);
|
|
16
|
+
const positionKeywords = new Map([
|
|
17
|
+
["static", "static"],
|
|
18
|
+
["relative", "relative"],
|
|
19
|
+
["absolute", "absolute"],
|
|
20
|
+
["fixed", "fixed"],
|
|
21
|
+
["sticky", "sticky"]
|
|
22
|
+
]);
|
|
23
|
+
const booleanAliases = new Map([
|
|
24
|
+
["flexRow", {
|
|
25
|
+
prop: "flexDirection",
|
|
26
|
+
value: "row"
|
|
27
|
+
}],
|
|
28
|
+
["flexCol", {
|
|
29
|
+
prop: "flexDirection",
|
|
30
|
+
value: "column"
|
|
31
|
+
}],
|
|
32
|
+
["flexWrap", {
|
|
33
|
+
prop: "flexWrap",
|
|
34
|
+
value: "wrap"
|
|
35
|
+
}],
|
|
36
|
+
["flexNoWrap", {
|
|
37
|
+
prop: "flexWrap",
|
|
38
|
+
value: "nowrap"
|
|
39
|
+
}]
|
|
40
|
+
]);
|
|
41
|
+
const aliasMap = new Map([
|
|
42
|
+
["p", ["padding"]],
|
|
43
|
+
["px", ["paddingLeft", "paddingRight"]],
|
|
44
|
+
["py", ["paddingTop", "paddingBottom"]],
|
|
45
|
+
["pt", ["paddingTop"]],
|
|
46
|
+
["pr", ["paddingRight"]],
|
|
47
|
+
["pb", ["paddingBottom"]],
|
|
48
|
+
["pl", ["paddingLeft"]],
|
|
49
|
+
["m", ["margin"]],
|
|
50
|
+
["mx", ["marginLeft", "marginRight"]],
|
|
51
|
+
["my", ["marginTop", "marginBottom"]],
|
|
52
|
+
["mt", ["marginTop"]],
|
|
53
|
+
["mr", ["marginRight"]],
|
|
54
|
+
["mb", ["marginBottom"]],
|
|
55
|
+
["ml", ["marginLeft"]],
|
|
56
|
+
["gapX", ["columnGap"]],
|
|
57
|
+
["gapY", ["rowGap"]],
|
|
58
|
+
["w", ["width"]],
|
|
59
|
+
["h", ["height"]],
|
|
60
|
+
["minW", ["minWidth"]],
|
|
61
|
+
["minH", ["minHeight"]],
|
|
62
|
+
["maxW", ["maxWidth"]],
|
|
63
|
+
["maxH", ["maxHeight"]],
|
|
64
|
+
["inset", [
|
|
65
|
+
"top",
|
|
66
|
+
"right",
|
|
67
|
+
"bottom",
|
|
68
|
+
"left"
|
|
69
|
+
]],
|
|
70
|
+
["insetX", ["left", "right"]],
|
|
71
|
+
["insetY", ["top", "bottom"]],
|
|
72
|
+
["basis", ["flexBasis"]],
|
|
73
|
+
["items", ["alignItems"]],
|
|
74
|
+
["justify", ["justifyContent"]],
|
|
75
|
+
["self", ["alignSelf"]],
|
|
76
|
+
["leading", ["lineHeight"]],
|
|
77
|
+
["tracking", ["letterSpacing"]],
|
|
78
|
+
["z", ["zIndex"]],
|
|
79
|
+
["aspect", ["aspectRatio"]]
|
|
80
|
+
]);
|
|
81
|
+
const textAlias = "text";
|
|
82
|
+
const bgAlias = "bg";
|
|
83
|
+
const borderAlias = "border";
|
|
84
|
+
const axisPairs = [{
|
|
85
|
+
x: "translateX",
|
|
86
|
+
y: "translateY",
|
|
87
|
+
prop: "translate",
|
|
88
|
+
defaults: {
|
|
89
|
+
x: 0,
|
|
90
|
+
y: 0
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
x: "scaleX",
|
|
94
|
+
y: "scaleY",
|
|
95
|
+
prop: "scale",
|
|
96
|
+
defaults: {
|
|
97
|
+
x: 1,
|
|
98
|
+
y: 1
|
|
99
|
+
}
|
|
100
|
+
}];
|
|
101
|
+
const borderWidthKeywords = new Set([
|
|
102
|
+
"thin",
|
|
103
|
+
"medium",
|
|
104
|
+
"thick"
|
|
105
|
+
]);
|
|
106
|
+
const toTokenPath = (value, tokens) => {
|
|
107
|
+
if (!tokens || !value.includes("-")) return value;
|
|
108
|
+
const parts = value.split("-");
|
|
109
|
+
if (parts.length < 2) return value;
|
|
110
|
+
const [prefix, ...restParts] = parts;
|
|
111
|
+
const suffix = restParts.join("-");
|
|
112
|
+
const group = tokens[prefix];
|
|
113
|
+
if (!group || typeof group !== "object") return value;
|
|
114
|
+
if (suffix in group) return `${prefix}.${suffix}`;
|
|
115
|
+
return value;
|
|
116
|
+
};
|
|
117
|
+
const isPlainObject = (value) => {
|
|
118
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
119
|
+
};
|
|
120
|
+
const isNumericString = (value) => /^-?\d+(?:\.\d+)?$/.test(value);
|
|
121
|
+
const isLengthLike = (value) => {
|
|
122
|
+
if (typeof value === "number") return true;
|
|
123
|
+
if (typeof value !== "string") return false;
|
|
124
|
+
if (isNumericString(value)) return true;
|
|
125
|
+
if (value.startsWith("calc(") || value.startsWith("clamp(") || value.startsWith("min(") || value.startsWith("max(")) return true;
|
|
126
|
+
return /^-?\d+(?:\.\d+)?(px|rem|em|vh|vw|vmin|vmax|ch|ex|%|pt|pc|mm|cm|in)$/.test(value);
|
|
127
|
+
};
|
|
128
|
+
const readTokenGroup = (value) => {
|
|
129
|
+
if (typeof value === "function" && value.IS_TOKEN_FN) {
|
|
130
|
+
const [group, ...rest] = String(value()).replace("$$.token.", "").split(".");
|
|
131
|
+
return {
|
|
132
|
+
group,
|
|
133
|
+
path: rest.join(".")
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (typeof value === "string" && value.startsWith("$$.token.")) {
|
|
137
|
+
const [group, ...rest] = value.replace("$$.token.", "").split(".");
|
|
138
|
+
return {
|
|
139
|
+
group,
|
|
140
|
+
path: rest.join(".")
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
};
|
|
145
|
+
const resolveTextTarget = (_api, value, config, tokens) => {
|
|
146
|
+
const tokenGroup = readTokenGroup(value);
|
|
147
|
+
if (tokenGroup?.group === "fontSize") return {
|
|
148
|
+
prop: "fontSize",
|
|
149
|
+
value
|
|
150
|
+
};
|
|
151
|
+
if (tokenGroup?.group === "color") return {
|
|
152
|
+
prop: "color",
|
|
153
|
+
value
|
|
154
|
+
};
|
|
155
|
+
if (typeof value === "string" && tokens?.color) {
|
|
156
|
+
const normalized = toTokenPath(value, tokens.color);
|
|
157
|
+
if (normalized !== value) return {
|
|
158
|
+
prop: "color",
|
|
159
|
+
value: normalized
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
if (typeof value === "string" && tokens?.fontSize) {
|
|
163
|
+
const normalized = toTokenPath(value, tokens.fontSize);
|
|
164
|
+
if (normalized !== value) return {
|
|
165
|
+
prop: "fontSize",
|
|
166
|
+
value: normalized
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
if (isLengthLike(value)) return {
|
|
170
|
+
prop: "fontSize",
|
|
171
|
+
value
|
|
172
|
+
};
|
|
173
|
+
if (typeof value === "string" && config.fontSizeKeys?.includes(value)) return {
|
|
174
|
+
prop: "fontSize",
|
|
175
|
+
value
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
prop: "color",
|
|
179
|
+
value
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
const resolveBorderTarget = (value, config, tokens) => {
|
|
183
|
+
if (value === null || value === true) return {
|
|
184
|
+
prop: "borderWidth",
|
|
185
|
+
value: config.defaults?.borderWidth ?? 1
|
|
186
|
+
};
|
|
187
|
+
if (Array.isArray(value)) return null;
|
|
188
|
+
if (typeof value === "string" && tokens?.color) {
|
|
189
|
+
const normalized = toTokenPath(value, tokens.color);
|
|
190
|
+
if (normalized !== value) return {
|
|
191
|
+
prop: "borderColor",
|
|
192
|
+
value: normalized
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (isLengthLike(value)) return {
|
|
196
|
+
prop: "borderWidth",
|
|
197
|
+
value
|
|
198
|
+
};
|
|
199
|
+
if (typeof value === "string" && borderWidthKeywords.has(value)) return {
|
|
200
|
+
prop: "borderWidth",
|
|
201
|
+
value
|
|
202
|
+
};
|
|
203
|
+
if (typeof value === "string" && (value.includes(" ") || value.includes("_"))) return null;
|
|
204
|
+
return {
|
|
205
|
+
prop: "borderColor",
|
|
206
|
+
value
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
const resolveShadowValue = (value, config) => {
|
|
210
|
+
if (value === null || value === true) return config.defaults?.boxShadow ?? value;
|
|
211
|
+
return value;
|
|
212
|
+
};
|
|
213
|
+
const resolveRoundedValue = (value, config) => {
|
|
214
|
+
if (value === null || value === true) return config.defaults?.borderRadius ?? value;
|
|
215
|
+
return value;
|
|
216
|
+
};
|
|
217
|
+
const resolveGrowShrinkValue = (name, value) => {
|
|
218
|
+
if (value === null || value === true) return name === "grow" ? 1 : 1;
|
|
219
|
+
return value;
|
|
220
|
+
};
|
|
221
|
+
const resolveTranslateScaleValue = (value, fallback) => {
|
|
222
|
+
if (value === null || value === true) return fallback;
|
|
223
|
+
return value ?? fallback;
|
|
224
|
+
};
|
|
225
|
+
const resolveSkewAxisValue = (value, fallback) => {
|
|
226
|
+
if (value === null || value === true) return fallback;
|
|
227
|
+
if (typeof value === "number") return `${value}deg`;
|
|
228
|
+
if (typeof value === "string" && isNumericString(value)) return `${value}deg`;
|
|
229
|
+
return value;
|
|
230
|
+
};
|
|
231
|
+
const buildSkewTransform = (xValue, yValue, includeX, includeY) => {
|
|
232
|
+
const parts = [];
|
|
233
|
+
if (includeX) parts.push(`skewX(${xValue})`);
|
|
234
|
+
if (includeY) parts.push(`skewY(${yValue})`);
|
|
235
|
+
return parts.length ? parts.join(" ") : null;
|
|
236
|
+
};
|
|
237
|
+
const resolveSkewTransformValue = (xValue, yValue, includeX, includeY) => {
|
|
238
|
+
if (typeof xValue === "function" || typeof yValue === "function") return () => {
|
|
239
|
+
return buildSkewTransform(includeX ? resolveSkewAxisValue(typeof xValue === "function" ? xValue() : xValue, "0deg") : null, includeY ? resolveSkewAxisValue(typeof yValue === "function" ? yValue() : yValue, "0deg") : null, includeX, includeY);
|
|
240
|
+
};
|
|
241
|
+
return buildSkewTransform(includeX ? resolveSkewAxisValue(xValue, "0deg") : null, includeY ? resolveSkewAxisValue(yValue, "0deg") : null, includeX, includeY);
|
|
242
|
+
};
|
|
243
|
+
const bosswindProps = [
|
|
244
|
+
{
|
|
245
|
+
name: "p",
|
|
246
|
+
description: "Padding (all sides)."
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: "px",
|
|
250
|
+
description: "Padding on the x-axis (left + right)."
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "py",
|
|
254
|
+
description: "Padding on the y-axis (top + bottom)."
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: "pt",
|
|
258
|
+
description: "Padding top."
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "pr",
|
|
262
|
+
description: "Padding right."
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: "pb",
|
|
266
|
+
description: "Padding bottom."
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: "pl",
|
|
270
|
+
description: "Padding left."
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "m",
|
|
274
|
+
description: "Margin (all sides)."
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
name: "mx",
|
|
278
|
+
description: "Margin on the x-axis (left + right)."
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "my",
|
|
282
|
+
description: "Margin on the y-axis (top + bottom)."
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: "mt",
|
|
286
|
+
description: "Margin top."
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: "mr",
|
|
290
|
+
description: "Margin right."
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: "mb",
|
|
294
|
+
description: "Margin bottom."
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
name: "ml",
|
|
298
|
+
description: "Margin left."
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
name: "gapX",
|
|
302
|
+
description: "Column gap."
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: "gapY",
|
|
306
|
+
description: "Row gap."
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
name: "w",
|
|
310
|
+
description: "Width."
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: "h",
|
|
314
|
+
description: "Height."
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
name: "minW",
|
|
318
|
+
description: "Min width."
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: "minH",
|
|
322
|
+
description: "Min height."
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
name: "maxW",
|
|
326
|
+
description: "Max width."
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: "maxH",
|
|
330
|
+
description: "Max height."
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: "inset",
|
|
334
|
+
description: "Top, right, bottom, left."
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "insetX",
|
|
338
|
+
description: "Left and right."
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: "insetY",
|
|
342
|
+
description: "Top and bottom."
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
name: "grow",
|
|
346
|
+
description: "Flex grow.",
|
|
347
|
+
single: true
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
name: "shrink",
|
|
351
|
+
description: "Flex shrink.",
|
|
352
|
+
single: true
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "basis",
|
|
356
|
+
description: "Flex basis."
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "items",
|
|
360
|
+
description: "Align items."
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: "justify",
|
|
364
|
+
description: "Justify content."
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "self",
|
|
368
|
+
description: "Align self."
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
name: "leading",
|
|
372
|
+
description: "Line height."
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: "tracking",
|
|
376
|
+
description: "Letter spacing."
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: "rounded",
|
|
380
|
+
description: "Border radius.",
|
|
381
|
+
single: true
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: "shadow",
|
|
385
|
+
description: "Box shadow.",
|
|
386
|
+
single: true
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: "z",
|
|
390
|
+
description: "Z index."
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
name: "aspect",
|
|
394
|
+
description: "Aspect ratio."
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
name: "text",
|
|
398
|
+
description: "Text color or font size."
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: "bg",
|
|
402
|
+
description: "Background color."
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "border",
|
|
406
|
+
description: "Border width or border color.",
|
|
407
|
+
single: true
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: "block",
|
|
411
|
+
description: "Display block.",
|
|
412
|
+
single: true
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
name: "inline",
|
|
416
|
+
description: "Display inline.",
|
|
417
|
+
single: true
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
name: "inlineBlock",
|
|
421
|
+
description: "Display inline-block.",
|
|
422
|
+
single: true
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
name: "inlineFlex",
|
|
426
|
+
description: "Display inline-flex.",
|
|
427
|
+
single: true
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: "inlineGrid",
|
|
431
|
+
description: "Display inline-grid.",
|
|
432
|
+
single: true
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
name: "contents",
|
|
436
|
+
description: "Display contents.",
|
|
437
|
+
single: true
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
name: "flowRoot",
|
|
441
|
+
description: "Display flow-root.",
|
|
442
|
+
single: true
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
name: "table",
|
|
446
|
+
description: "Display table.",
|
|
447
|
+
single: true
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
name: "inlineTable",
|
|
451
|
+
description: "Display inline-table.",
|
|
452
|
+
single: true
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
name: "tableRow",
|
|
456
|
+
description: "Display table-row.",
|
|
457
|
+
single: true
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
name: "tableCell",
|
|
461
|
+
description: "Display table-cell.",
|
|
462
|
+
single: true
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
name: "static",
|
|
466
|
+
description: "Position static.",
|
|
467
|
+
single: true
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
name: "relative",
|
|
471
|
+
description: "Position relative.",
|
|
472
|
+
single: true
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
name: "absolute",
|
|
476
|
+
description: "Position absolute.",
|
|
477
|
+
single: true
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
name: "fixed",
|
|
481
|
+
description: "Position fixed.",
|
|
482
|
+
single: true
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
name: "sticky",
|
|
486
|
+
description: "Position sticky.",
|
|
487
|
+
single: true
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
name: "flexRow",
|
|
491
|
+
description: "Flex direction row.",
|
|
492
|
+
single: true
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
name: "flexCol",
|
|
496
|
+
description: "Flex direction column.",
|
|
497
|
+
single: true
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
name: "flexWrap",
|
|
501
|
+
description: "Flex wrap.",
|
|
502
|
+
single: true
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
name: "flexNoWrap",
|
|
506
|
+
description: "Flex nowrap.",
|
|
507
|
+
single: true
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
name: "translateX",
|
|
511
|
+
description: "Translate x-axis."
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
name: "translateY",
|
|
515
|
+
description: "Translate y-axis."
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
name: "scaleX",
|
|
519
|
+
description: "Scale x-axis."
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
name: "scaleY",
|
|
523
|
+
description: "Scale y-axis."
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
name: "skewX",
|
|
527
|
+
description: "Skew x-axis."
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
name: "skewY",
|
|
531
|
+
description: "Skew y-axis."
|
|
532
|
+
}
|
|
533
|
+
];
|
|
534
|
+
const bosswindDashAliases = new Map(bosswindProps.map((entry) => [toDashCase(entry.name), entry.name]).filter(([dashName, original]) => dashName !== original));
|
|
535
|
+
const normalizeBosswindName = (name) => bosswindDashAliases.get(name) ?? name;
|
|
536
|
+
const registerBosswindDictionary = (api) => {
|
|
537
|
+
for (const entry of bosswindProps) {
|
|
538
|
+
if (entry.name === "flex" || entry.name === "grid") continue;
|
|
539
|
+
const aliases = new Set([entry.name]);
|
|
540
|
+
const dashedAlias = toDashCase(entry.name);
|
|
541
|
+
if (dashedAlias !== entry.name) aliases.add(dashedAlias);
|
|
542
|
+
const prop = {
|
|
543
|
+
property: entry.name,
|
|
544
|
+
aliases: Array.from(aliases),
|
|
545
|
+
description: entry.description,
|
|
546
|
+
values: [],
|
|
547
|
+
initial: "",
|
|
548
|
+
isCSSProp: true,
|
|
549
|
+
single: entry.single === true
|
|
550
|
+
};
|
|
551
|
+
api.dictionary.set(entry.name, prop);
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
const cloneProp = (prop, value) => ({
|
|
555
|
+
...prop,
|
|
556
|
+
value
|
|
557
|
+
});
|
|
558
|
+
const combineAxisValues = (xValue, yValue, defaults) => {
|
|
559
|
+
if (typeof xValue === "function" || typeof yValue === "function") return () => [resolveTranslateScaleValue(typeof xValue === "function" ? xValue() : xValue, defaults.x), resolveTranslateScaleValue(typeof yValue === "function" ? yValue() : yValue, defaults.y)];
|
|
560
|
+
return [resolveTranslateScaleValue(xValue, defaults.x), resolveTranslateScaleValue(yValue, defaults.y)];
|
|
561
|
+
};
|
|
562
|
+
const resolveAxisPairs = (entries, node) => {
|
|
563
|
+
const results = [];
|
|
564
|
+
for (const pair of axisPairs) {
|
|
565
|
+
if (pair.prop in node) continue;
|
|
566
|
+
const xIndex = entries.findIndex(([name]) => name === pair.x);
|
|
567
|
+
const yIndex = entries.findIndex(([name]) => name === pair.y);
|
|
568
|
+
if (xIndex === -1 && yIndex === -1) continue;
|
|
569
|
+
const emitIndex = Math.min(xIndex === -1 ? Number.POSITIVE_INFINITY : xIndex, yIndex === -1 ? Number.POSITIVE_INFINITY : yIndex);
|
|
570
|
+
results.push({
|
|
571
|
+
emitIndex,
|
|
572
|
+
prop: pair.prop,
|
|
573
|
+
x: pair.x,
|
|
574
|
+
y: pair.y,
|
|
575
|
+
defaults: pair.defaults
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
return results;
|
|
579
|
+
};
|
|
580
|
+
const applyAxisPairsToTree = (entries, node, output, used) => {
|
|
581
|
+
const pairs = resolveAxisPairs(entries, node);
|
|
582
|
+
if (!pairs.length) return;
|
|
583
|
+
for (const pair of pairs) {
|
|
584
|
+
if (!Number.isFinite(pair.emitIndex)) continue;
|
|
585
|
+
const xValue = node[pair.x]?.value ?? null;
|
|
586
|
+
const yValue = node[pair.y]?.value ?? null;
|
|
587
|
+
output[pair.prop] = cloneProp(node[pair.x] || node[pair.y], combineAxisValues(xValue, yValue, pair.defaults));
|
|
588
|
+
used.set(pair.x, true);
|
|
589
|
+
used.set(pair.y, true);
|
|
590
|
+
used.set(`__emit:${pair.emitIndex}:${pair.prop}`, true);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
const rewriteBosswindTree = (api, tree, config, tokens) => {
|
|
594
|
+
let usedBosswind = false;
|
|
595
|
+
let usedText = false;
|
|
596
|
+
const rewriteNode = (node) => {
|
|
597
|
+
const rawEntries = Object.entries(node);
|
|
598
|
+
const entries = [];
|
|
599
|
+
const normalizedNode = {};
|
|
600
|
+
rawEntries.forEach(([rawName, prop]) => {
|
|
601
|
+
const name = normalizeBosswindName(rawName);
|
|
602
|
+
if (Object.prototype.hasOwnProperty.call(normalizedNode, name)) return;
|
|
603
|
+
normalizedNode[name] = prop;
|
|
604
|
+
entries.push([name, prop]);
|
|
605
|
+
});
|
|
606
|
+
const output = {};
|
|
607
|
+
const used = /* @__PURE__ */ new Map();
|
|
608
|
+
applyAxisPairsToTree(entries, normalizedNode, output, used);
|
|
609
|
+
const hasSkewX = Object.prototype.hasOwnProperty.call(normalizedNode, "skewX");
|
|
610
|
+
const hasSkewY = Object.prototype.hasOwnProperty.call(normalizedNode, "skewY");
|
|
611
|
+
if (!Object.prototype.hasOwnProperty.call(normalizedNode, "transform") && (hasSkewX || hasSkewY)) {
|
|
612
|
+
const transformValue = resolveSkewTransformValue(hasSkewX ? normalizedNode.skewX?.value ?? null : null, hasSkewY ? normalizedNode.skewY?.value ?? null : null, hasSkewX, hasSkewY);
|
|
613
|
+
if (transformValue) {
|
|
614
|
+
const sourceProp = normalizedNode.skewX || normalizedNode.skewY;
|
|
615
|
+
if (sourceProp) output.transform = cloneProp(sourceProp, transformValue);
|
|
616
|
+
used.set("skewX", true);
|
|
617
|
+
used.set("skewY", true);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
entries.forEach(([name, prop], index) => {
|
|
621
|
+
if (used.get(name)) return;
|
|
622
|
+
if (used.get(`__emit:${index}:${name}`)) return;
|
|
623
|
+
if (prop?.value && isPlainObject(prop.value)) {
|
|
624
|
+
const nested = rewriteNode(prop.value);
|
|
625
|
+
if (Object.keys(nested).length) output[name] = {
|
|
626
|
+
...prop,
|
|
627
|
+
value: nested
|
|
628
|
+
};
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
const value = prop?.value;
|
|
632
|
+
if (name === "flex" || name === "grid") {
|
|
633
|
+
if (value === null || value === true) {
|
|
634
|
+
output.display = cloneProp(prop, name);
|
|
635
|
+
usedBosswind = true;
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
output[name] = prop;
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
if (displayKeywords.has(name)) {
|
|
642
|
+
if (value === null || value === true) {
|
|
643
|
+
const displayValue = displayKeywords.get(name);
|
|
644
|
+
if (displayValue) output.display = cloneProp(prop, displayValue);
|
|
645
|
+
}
|
|
646
|
+
usedBosswind = true;
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
if (positionKeywords.has(name)) {
|
|
650
|
+
if (value === null || value === true) {
|
|
651
|
+
const positionValue = positionKeywords.get(name);
|
|
652
|
+
if (positionValue) output.position = cloneProp(prop, positionValue);
|
|
653
|
+
}
|
|
654
|
+
usedBosswind = true;
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (booleanAliases.has(name)) {
|
|
658
|
+
if (value === null || value === true) {
|
|
659
|
+
const entry = booleanAliases.get(name);
|
|
660
|
+
if (entry) output[entry.prop] = cloneProp(prop, entry.value);
|
|
661
|
+
}
|
|
662
|
+
usedBosswind = true;
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
if (name === textAlias) {
|
|
666
|
+
usedBosswind = true;
|
|
667
|
+
usedText = true;
|
|
668
|
+
if (value === null || value === true) return;
|
|
669
|
+
const resolved = resolveTextTarget(api, value, config, tokens);
|
|
670
|
+
output[resolved.prop] = cloneProp(prop, resolved.value);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
if (name === bgAlias) {
|
|
674
|
+
usedBosswind = true;
|
|
675
|
+
if (value === null || value === true) return;
|
|
676
|
+
output.backgroundColor = cloneProp(prop, typeof value === "string" && tokens?.color ? toTokenPath(value, tokens.color) : value);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
if (name === borderAlias) {
|
|
680
|
+
usedBosswind = true;
|
|
681
|
+
const resolved = resolveBorderTarget(value, config, tokens);
|
|
682
|
+
if (!resolved) {
|
|
683
|
+
output[name] = prop;
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
output[resolved.prop] = cloneProp(prop, resolved.value);
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
if (name === "shadow") {
|
|
690
|
+
usedBosswind = true;
|
|
691
|
+
if (value === null || value === true) output.boxShadow = cloneProp(prop, resolveShadowValue(value, config));
|
|
692
|
+
else output.boxShadow = prop;
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
if (name === "rounded") {
|
|
696
|
+
usedBosswind = true;
|
|
697
|
+
if (value === null || value === true) output.borderRadius = cloneProp(prop, resolveRoundedValue(value, config));
|
|
698
|
+
else output.borderRadius = prop;
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
if (name === "grow" || name === "shrink") {
|
|
702
|
+
usedBosswind = true;
|
|
703
|
+
const target = name === "grow" ? "flexGrow" : "flexShrink";
|
|
704
|
+
output[target] = cloneProp(prop, resolveGrowShrinkValue(name, value));
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
if (aliasMap.has(name)) {
|
|
708
|
+
usedBosswind = true;
|
|
709
|
+
if (value === null || value === true) return;
|
|
710
|
+
const targets = aliasMap.get(name) || [];
|
|
711
|
+
const resolvedValue = name === "shadow" ? resolveShadowValue(value, config) : value;
|
|
712
|
+
targets.forEach((target) => {
|
|
713
|
+
output[target] = cloneProp(prop, resolvedValue);
|
|
714
|
+
});
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
output[name] = prop;
|
|
718
|
+
});
|
|
719
|
+
return output;
|
|
720
|
+
};
|
|
721
|
+
return {
|
|
722
|
+
tree: rewriteNode(tree),
|
|
723
|
+
usedBosswind,
|
|
724
|
+
usedText
|
|
725
|
+
};
|
|
726
|
+
};
|
|
727
|
+
const applyAxisPairsToInput = (entries, input, output, used) => {
|
|
728
|
+
const pairs = resolveAxisPairs(entries, input);
|
|
729
|
+
if (!pairs.length) return;
|
|
730
|
+
for (const pair of pairs) {
|
|
731
|
+
if (!Number.isFinite(pair.emitIndex)) continue;
|
|
732
|
+
const xValue = input[pair.x];
|
|
733
|
+
const yValue = input[pair.y];
|
|
734
|
+
output[pair.prop] = combineAxisValues(xValue, yValue, pair.defaults);
|
|
735
|
+
used.set(pair.x, true);
|
|
736
|
+
used.set(pair.y, true);
|
|
737
|
+
used.set(`__emit:${pair.emitIndex}:${pair.prop}`, true);
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
const rewriteBosswindInput = (api, input, config) => {
|
|
741
|
+
const rawEntries = Object.entries(input);
|
|
742
|
+
const entries = [];
|
|
743
|
+
const normalizedInput = {};
|
|
744
|
+
rawEntries.forEach(([rawName, value]) => {
|
|
745
|
+
const name = normalizeBosswindName(rawName);
|
|
746
|
+
if (Object.prototype.hasOwnProperty.call(normalizedInput, name)) return;
|
|
747
|
+
normalizedInput[name] = value;
|
|
748
|
+
entries.push([name, value]);
|
|
749
|
+
});
|
|
750
|
+
const output = {};
|
|
751
|
+
const used = /* @__PURE__ */ new Map();
|
|
752
|
+
applyAxisPairsToInput(entries, normalizedInput, output, used);
|
|
753
|
+
const hasSkewX = Object.prototype.hasOwnProperty.call(normalizedInput, "skewX");
|
|
754
|
+
const hasSkewY = Object.prototype.hasOwnProperty.call(normalizedInput, "skewY");
|
|
755
|
+
if (!Object.prototype.hasOwnProperty.call(normalizedInput, "transform") && (hasSkewX || hasSkewY)) {
|
|
756
|
+
const transformValue = resolveSkewTransformValue(hasSkewX ? normalizedInput.skewX : null, hasSkewY ? normalizedInput.skewY : null, hasSkewX, hasSkewY);
|
|
757
|
+
if (transformValue) {
|
|
758
|
+
output.transform = transformValue;
|
|
759
|
+
used.set("skewX", true);
|
|
760
|
+
used.set("skewY", true);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
entries.forEach(([name, value], index) => {
|
|
764
|
+
if (used.get(name)) return;
|
|
765
|
+
if (used.get(`__emit:${index}:${name}`)) return;
|
|
766
|
+
if (value && isPlainObject(value)) {
|
|
767
|
+
output[name] = rewriteBosswindInput(api, value, config);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
if (name === "flex" || name === "grid") {
|
|
771
|
+
if (value === null || value === true) output.display = name;
|
|
772
|
+
else output[name] = value;
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
if (displayKeywords.has(name)) {
|
|
776
|
+
if (value === null || value === true) {
|
|
777
|
+
const displayValue = displayKeywords.get(name);
|
|
778
|
+
if (displayValue) output.display = displayValue;
|
|
779
|
+
}
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
if (positionKeywords.has(name)) {
|
|
783
|
+
if (value === null || value === true) {
|
|
784
|
+
const positionValue = positionKeywords.get(name);
|
|
785
|
+
if (positionValue) output.position = positionValue;
|
|
786
|
+
}
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
if (booleanAliases.has(name)) {
|
|
790
|
+
if (value === null || value === true) {
|
|
791
|
+
const entry = booleanAliases.get(name);
|
|
792
|
+
if (entry) output[entry.prop] = entry.value;
|
|
793
|
+
}
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
if (name === textAlias) {
|
|
797
|
+
if (value === null || value === true) return;
|
|
798
|
+
const resolved = resolveTextTarget(api, value, config, void 0);
|
|
799
|
+
output[resolved.prop] = resolved.value;
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
if (name === bgAlias) {
|
|
803
|
+
if (value === null || value === true) return;
|
|
804
|
+
output.backgroundColor = value;
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
if (name === borderAlias) {
|
|
808
|
+
const resolved = resolveBorderTarget(value, config, void 0);
|
|
809
|
+
if (!resolved) {
|
|
810
|
+
output[name] = value;
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
output[resolved.prop] = resolved.value;
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
if (name === "shadow") {
|
|
817
|
+
output.boxShadow = resolveShadowValue(value, config);
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
if (name === "rounded") {
|
|
821
|
+
output.borderRadius = resolveRoundedValue(value, config);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
if (name === "grow" || name === "shrink") {
|
|
825
|
+
output[name === "grow" ? "flexGrow" : "flexShrink"] = resolveGrowShrinkValue(name, value);
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
if (aliasMap.has(name)) {
|
|
829
|
+
if (value === null || value === true) return;
|
|
830
|
+
(aliasMap.get(name) || []).forEach((target) => {
|
|
831
|
+
output[target] = value;
|
|
832
|
+
});
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
output[name] = value;
|
|
836
|
+
});
|
|
837
|
+
return output;
|
|
838
|
+
};
|
|
839
|
+
const getBosswindDefaults = (theme) => {
|
|
840
|
+
const borderRadius = theme.borderRadius?.DEFAULT;
|
|
841
|
+
const boxShadow = theme.boxShadow?.DEFAULT;
|
|
842
|
+
const borderWidth = theme.borderWidth?.DEFAULT;
|
|
843
|
+
return {
|
|
844
|
+
borderRadius: borderRadius ?? "0.25rem",
|
|
845
|
+
boxShadow: boxShadow ?? "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
|
|
846
|
+
borderWidth: borderWidth ?? 1
|
|
847
|
+
};
|
|
848
|
+
};
|
|
849
|
+
const getBosswindFontSizeKeys = (theme) => {
|
|
850
|
+
const fontSize = theme.fontSize;
|
|
851
|
+
return fontSize ? Object.keys(fontSize) : [];
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
//#endregion
|
|
855
|
+
export { bosswindProps, getBosswindDefaults, getBosswindFontSizeKeys, registerBosswindDictionary, rewriteBosswindInput, rewriteBosswindTree };
|