@tenphi/tasty 0.0.0-snapshot.c11c8b8 → 0.0.0-snapshot.fafcbfe
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 +5 -1
- package/dist/pipeline/conditions.d.ts +1 -1
- package/dist/pipeline/conditions.js +2 -2
- package/dist/pipeline/conditions.js.map +1 -1
- package/dist/pipeline/index.js +2 -2
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/materialize.js +192 -104
- package/dist/pipeline/materialize.js.map +1 -1
- package/dist/pipeline/parseStateKey.d.ts +0 -3
- package/dist/pipeline/parseStateKey.js +7 -7
- package/dist/pipeline/parseStateKey.js.map +1 -1
- package/dist/styles/inset.d.ts +3 -1
- package/dist/styles/inset.js +48 -40
- package/dist/styles/inset.js.map +1 -1
- package/dist/styles/margin.d.ts +1 -5
- package/dist/styles/margin.js +48 -40
- package/dist/styles/margin.js.map +1 -1
- package/dist/styles/padding.d.ts +1 -5
- package/dist/styles/padding.js +48 -40
- package/dist/styles/padding.js.map +1 -1
- package/dist/styles/transition.js +26 -6
- package/dist/styles/transition.js.map +1 -1
- package/package.json +5 -3
- package/tasty.config.ts +14 -0
package/dist/styles/inset.js
CHANGED
|
@@ -12,25 +12,39 @@ function parseInsetValue(value) {
|
|
|
12
12
|
return values[0] || "0";
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Extract values and directions from a single parsed group.
|
|
16
16
|
*/
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
values: [`${value}px`],
|
|
20
|
-
directions: []
|
|
21
|
-
};
|
|
22
|
-
if (!value) return {
|
|
23
|
-
values: [],
|
|
24
|
-
directions: []
|
|
25
|
-
};
|
|
26
|
-
if (value === true) value = "0";
|
|
27
|
-
const { values = [], mods = [] } = parseStyle(value).groups[0] ?? {};
|
|
17
|
+
function extractGroupData(group) {
|
|
18
|
+
const { values = [], mods = [] } = group;
|
|
28
19
|
return {
|
|
29
20
|
values: values.length ? values : ["0"],
|
|
30
21
|
directions: filterMods(mods, DIRECTIONS)
|
|
31
22
|
};
|
|
32
23
|
}
|
|
33
24
|
/**
|
|
25
|
+
* Apply a single group's values and directions onto a direction map.
|
|
26
|
+
*/
|
|
27
|
+
function applyGroup(dirs, values, directions) {
|
|
28
|
+
if (!values.length) return;
|
|
29
|
+
if (directions.length === 0) {
|
|
30
|
+
dirs.top = values[0];
|
|
31
|
+
dirs.right = values[1] || values[0];
|
|
32
|
+
dirs.bottom = values[2] || values[0];
|
|
33
|
+
dirs.left = values[3] || values[1] || values[0];
|
|
34
|
+
} else directions.forEach((dir, i) => {
|
|
35
|
+
dirs[dir] = values[i] ?? values[0];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Optimize inset output shorthand.
|
|
40
|
+
*/
|
|
41
|
+
function optimizeInset(dirs) {
|
|
42
|
+
const { top, right, bottom, left } = dirs;
|
|
43
|
+
if (top === right && right === bottom && bottom === left) return { inset: top };
|
|
44
|
+
if (top === bottom && left === right) return { inset: `${top} ${left}` };
|
|
45
|
+
return { inset: `${top} ${right} ${bottom} ${left}` };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
34
48
|
* Inset style handler.
|
|
35
49
|
*
|
|
36
50
|
* IMPORTANT: This handler uses individual CSS properties (top, right, bottom, left)
|
|
@@ -78,54 +92,48 @@ function insetStyle({ inset, insetBlock, insetInline, top, right, bottom, left }
|
|
|
78
92
|
}
|
|
79
93
|
return result;
|
|
80
94
|
}
|
|
81
|
-
|
|
82
|
-
"auto",
|
|
83
|
-
"auto",
|
|
84
|
-
"auto",
|
|
85
|
-
"auto"
|
|
86
|
-
|
|
95
|
+
const dirs = {
|
|
96
|
+
top: "auto",
|
|
97
|
+
right: "auto",
|
|
98
|
+
bottom: "auto",
|
|
99
|
+
left: "auto"
|
|
100
|
+
};
|
|
87
101
|
if (inset != null) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
else if (dir === "right") rightVal = val;
|
|
98
|
-
else if (dir === "bottom") bottomVal = val;
|
|
99
|
-
else if (dir === "left") leftVal = val;
|
|
100
|
-
});
|
|
102
|
+
if (typeof inset === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${inset}px`;
|
|
103
|
+
else if (inset === true) inset = "0";
|
|
104
|
+
if (typeof inset === "string" && inset) {
|
|
105
|
+
const groups = parseStyle(inset).groups ?? [];
|
|
106
|
+
for (const group of groups) {
|
|
107
|
+
const { values, directions } = extractGroupData(group);
|
|
108
|
+
applyGroup(dirs, values, directions);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
101
111
|
}
|
|
102
112
|
if (insetBlock != null) {
|
|
103
113
|
const val = parseInsetValue(insetBlock);
|
|
104
|
-
if (val)
|
|
114
|
+
if (val) dirs.top = dirs.bottom = val;
|
|
105
115
|
}
|
|
106
116
|
if (insetInline != null) {
|
|
107
117
|
const val = parseInsetValue(insetInline);
|
|
108
|
-
if (val)
|
|
118
|
+
if (val) dirs.left = dirs.right = val;
|
|
109
119
|
}
|
|
110
120
|
if (top != null) {
|
|
111
121
|
const val = parseInsetValue(top);
|
|
112
|
-
if (val)
|
|
122
|
+
if (val) dirs.top = val;
|
|
113
123
|
}
|
|
114
124
|
if (right != null) {
|
|
115
125
|
const val = parseInsetValue(right);
|
|
116
|
-
if (val)
|
|
126
|
+
if (val) dirs.right = val;
|
|
117
127
|
}
|
|
118
128
|
if (bottom != null) {
|
|
119
129
|
const val = parseInsetValue(bottom);
|
|
120
|
-
if (val)
|
|
130
|
+
if (val) dirs.bottom = val;
|
|
121
131
|
}
|
|
122
132
|
if (left != null) {
|
|
123
133
|
const val = parseInsetValue(left);
|
|
124
|
-
if (val)
|
|
134
|
+
if (val) dirs.left = val;
|
|
125
135
|
}
|
|
126
|
-
|
|
127
|
-
if (topVal === bottomVal && leftVal === rightVal) return { inset: `${topVal} ${leftVal}` };
|
|
128
|
-
return { inset: `${topVal} ${rightVal} ${bottomVal} ${leftVal}` };
|
|
136
|
+
return optimizeInset(dirs);
|
|
129
137
|
}
|
|
130
138
|
insetStyle.__lookupStyles = [
|
|
131
139
|
"inset",
|
package/dist/styles/inset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inset.js","names":[],"sources":["../../src/styles/inset.ts"],"sourcesContent":["import { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\n/**\n * Parse an inset value and return the first processed value\n */\nfunction parseInsetValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '0';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || '0';\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"inset.js","names":[],"sources":["../../src/styles/inset.ts"],"sourcesContent":["import type { StyleDetails } from '../parser/types';\nimport { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\ntype Direction = (typeof DIRECTIONS)[number];\n\n/**\n * Parse an inset value and return the first processed value\n */\nfunction parseInsetValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '0';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || '0';\n}\n\n/**\n * Extract values and directions from a single parsed group.\n */\nfunction extractGroupData(group: StyleDetails): {\n values: string[];\n directions: Direction[];\n} {\n const { values = [], mods = [] } = group;\n return {\n values: values.length ? values : ['0'],\n directions: filterMods(mods, DIRECTIONS) as Direction[],\n };\n}\n\n/**\n * Apply a single group's values and directions onto a direction map.\n */\nfunction applyGroup(\n dirs: Record<Direction, string>,\n values: string[],\n directions: Direction[],\n): void {\n if (!values.length) return;\n\n if (directions.length === 0) {\n dirs.top = values[0];\n dirs.right = values[1] || values[0];\n dirs.bottom = values[2] || values[0];\n dirs.left = values[3] || values[1] || values[0];\n } else {\n directions.forEach((dir, i) => {\n dirs[dir] = values[i] ?? values[0];\n });\n }\n}\n\n/**\n * Optimize inset output shorthand.\n */\nfunction optimizeInset(dirs: Record<Direction, string>): { inset: string } {\n const { top, right, bottom, left } = dirs;\n if (top === right && right === bottom && bottom === left) {\n return { inset: top };\n }\n if (top === bottom && left === right) {\n return { inset: `${top} ${left}` };\n }\n return { inset: `${top} ${right} ${bottom} ${left}` };\n}\n\n/**\n * Inset style handler.\n *\n * IMPORTANT: This handler uses individual CSS properties (top, right, bottom, left)\n * when only individual direction props are specified. This allows CSS cascade to work\n * correctly when modifiers override only some directions.\n *\n * Example problem with using `inset` shorthand everywhere:\n * styles: {\n * top: { '': 0, 'side=bottom': 'initial' },\n * right: { '': 0, 'side=left': 'initial' },\n * bottom: { '': 0, 'side=top': 'initial' },\n * left: { '': 0, 'side=right': 'initial' },\n * }\n *\n * If we output `inset` for both cases:\n * - Default: inset: 0 0 0 0\n * - side=bottom: inset: initial auto auto auto ← WRONG! Overrides all 4 directions\n *\n * With individual properties:\n * - Default: top: 0; right: 0; bottom: 0; left: 0\n * - side=bottom: top: initial ← CORRECT! Only overrides top\n *\n * The `inset` shorthand is only used when the base `inset` prop is specified\n * OR when `insetBlock`/`insetInline` are used (which imply setting pairs).\n */\nexport function insetStyle({\n inset,\n insetBlock,\n insetInline,\n top,\n right,\n bottom,\n left,\n}: {\n inset?: string | number | boolean;\n insetBlock?: string | number | boolean;\n insetInline?: string | number | boolean;\n top?: string | number | boolean;\n right?: string | number | boolean;\n bottom?: string | number | boolean;\n left?: string | number | boolean;\n}) {\n if (\n inset == null &&\n insetBlock == null &&\n insetInline == null &&\n top == null &&\n right == null &&\n bottom == null &&\n left == null\n ) {\n return {};\n }\n\n // When only individual direction props are used (no inset, insetBlock, insetInline),\n // output individual CSS properties to allow proper CSS cascade with modifiers\n const onlyIndividualProps =\n inset == null && insetBlock == null && insetInline == null;\n\n if (onlyIndividualProps) {\n const result: Record<string, string> = {};\n\n if (top != null) {\n const val = parseInsetValue(top);\n if (val) result['top'] = val;\n }\n if (right != null) {\n const val = parseInsetValue(right);\n if (val) result['right'] = val;\n }\n if (bottom != null) {\n const val = parseInsetValue(bottom);\n if (val) result['bottom'] = val;\n }\n if (left != null) {\n const val = parseInsetValue(left);\n if (val) result['left'] = val;\n }\n\n return result;\n }\n\n const dirs: Record<Direction, string> = {\n top: 'auto',\n right: 'auto',\n bottom: 'auto',\n left: 'auto',\n };\n\n // Priority 1 (lowest): inset\n if (inset != null) {\n if (typeof inset === 'number') {\n const v = `${inset}px`;\n dirs.top = dirs.right = dirs.bottom = dirs.left = v;\n } else if (inset === true) {\n inset = '0';\n }\n\n if (typeof inset === 'string' && inset) {\n const processed = parseStyle(inset);\n const groups = processed.groups ?? [];\n\n for (const group of groups) {\n const { values, directions } = extractGroupData(group);\n applyGroup(dirs, values, directions);\n }\n }\n }\n\n // Priority 2 (medium): insetBlock/insetInline\n if (insetBlock != null) {\n const val = parseInsetValue(insetBlock);\n if (val) dirs.top = dirs.bottom = val;\n }\n if (insetInline != null) {\n const val = parseInsetValue(insetInline);\n if (val) dirs.left = dirs.right = val;\n }\n\n // Priority 3 (highest): individual directions\n if (top != null) {\n const val = parseInsetValue(top);\n if (val) dirs.top = val;\n }\n if (right != null) {\n const val = parseInsetValue(right);\n if (val) dirs.right = val;\n }\n if (bottom != null) {\n const val = parseInsetValue(bottom);\n if (val) dirs.bottom = val;\n }\n if (left != null) {\n const val = parseInsetValue(left);\n if (val) dirs.left = val;\n }\n\n return optimizeInset(dirs);\n}\n\ninsetStyle.__lookupStyles = [\n 'inset',\n 'insetBlock',\n 'insetInline',\n 'top',\n 'right',\n 'bottom',\n 'left',\n];\n"],"mappings":";;;;;;AAQA,SAAS,gBAAgB,OAAiD;AACxE,KAAI,OAAO,UAAU,SAAU,QAAO,GAAG,MAAM;AAC/C,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,UAAU,KAAM,SAAQ;CAE5B,MAAM,EA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;AACjC,MAAI,IAAK,MAAK,OAAO;;AAGvB,QAAO,cAAc,KAAK;;AAG5B,WAAW,iBAAiB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
package/dist/styles/margin.d.ts
CHANGED
|
@@ -15,11 +15,7 @@ declare function marginStyle({
|
|
|
15
15
|
marginRight?: string | number | boolean;
|
|
16
16
|
marginBottom?: string | number | boolean;
|
|
17
17
|
marginLeft?: string | number | boolean;
|
|
18
|
-
}): {
|
|
19
|
-
margin?: undefined;
|
|
20
|
-
} | {
|
|
21
|
-
margin: string;
|
|
22
|
-
};
|
|
18
|
+
}): {};
|
|
23
19
|
declare namespace marginStyle {
|
|
24
20
|
var __lookupStyles: string[];
|
|
25
21
|
}
|
package/dist/styles/margin.js
CHANGED
|
@@ -12,74 +12,82 @@ function parseMarginValue(value) {
|
|
|
12
12
|
return values[0] || "var(--gap)";
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Extract values and directions from a single parsed group.
|
|
16
16
|
*/
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
values: [`${value}px`],
|
|
20
|
-
directions: []
|
|
21
|
-
};
|
|
22
|
-
if (!value) return {
|
|
23
|
-
values: [],
|
|
24
|
-
directions: []
|
|
25
|
-
};
|
|
26
|
-
if (value === true) value = "1x";
|
|
27
|
-
const { values = [], mods = [] } = parseStyle(value).groups[0] ?? {};
|
|
17
|
+
function extractGroupData(group) {
|
|
18
|
+
const { values = [], mods = [] } = group;
|
|
28
19
|
return {
|
|
29
20
|
values: values.length ? values : ["var(--gap)"],
|
|
30
21
|
directions: filterMods(mods, DIRECTIONS)
|
|
31
22
|
};
|
|
32
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Apply a single group's values and directions onto a direction map.
|
|
26
|
+
*/
|
|
27
|
+
function applyGroup(dirs, values, directions) {
|
|
28
|
+
if (!values.length) return;
|
|
29
|
+
if (directions.length === 0) {
|
|
30
|
+
dirs.top = values[0];
|
|
31
|
+
dirs.right = values[1] || values[0];
|
|
32
|
+
dirs.bottom = values[2] || values[0];
|
|
33
|
+
dirs.left = values[3] || values[1] || values[0];
|
|
34
|
+
} else directions.forEach((dir, i) => {
|
|
35
|
+
dirs[dir] = values[i] ?? values[0];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Optimize margin output shorthand.
|
|
40
|
+
*/
|
|
41
|
+
function optimizeMargin(dirs) {
|
|
42
|
+
const { top, right, bottom, left } = dirs;
|
|
43
|
+
if (top === right && right === bottom && bottom === left) return { margin: top };
|
|
44
|
+
if (top === bottom && left === right) return { margin: `${top} ${left}` };
|
|
45
|
+
return { margin: `${top} ${right} ${bottom} ${left}` };
|
|
46
|
+
}
|
|
33
47
|
function marginStyle({ margin, marginBlock, marginInline, marginTop, marginRight, marginBottom, marginLeft }) {
|
|
34
48
|
if (margin == null && marginBlock == null && marginInline == null && marginTop == null && marginRight == null && marginBottom == null && marginLeft == null) return {};
|
|
35
|
-
|
|
36
|
-
"0",
|
|
37
|
-
"0",
|
|
38
|
-
"0",
|
|
39
|
-
"0"
|
|
40
|
-
|
|
49
|
+
const dirs = {
|
|
50
|
+
top: "0",
|
|
51
|
+
right: "0",
|
|
52
|
+
bottom: "0",
|
|
53
|
+
left: "0"
|
|
54
|
+
};
|
|
41
55
|
if (margin != null) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
else if (dir === "right") right = val;
|
|
52
|
-
else if (dir === "bottom") bottom = val;
|
|
53
|
-
else if (dir === "left") left = val;
|
|
54
|
-
});
|
|
56
|
+
if (typeof margin === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${margin}px`;
|
|
57
|
+
else if (margin === true) margin = "1x";
|
|
58
|
+
if (typeof margin === "string" && margin) {
|
|
59
|
+
const groups = parseStyle(margin).groups ?? [];
|
|
60
|
+
for (const group of groups) {
|
|
61
|
+
const { values, directions } = extractGroupData(group);
|
|
62
|
+
applyGroup(dirs, values, directions);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
55
65
|
}
|
|
56
66
|
if (marginBlock != null) {
|
|
57
67
|
const val = parseMarginValue(marginBlock);
|
|
58
|
-
if (val) top = bottom = val;
|
|
68
|
+
if (val) dirs.top = dirs.bottom = val;
|
|
59
69
|
}
|
|
60
70
|
if (marginInline != null) {
|
|
61
71
|
const val = parseMarginValue(marginInline);
|
|
62
|
-
if (val) left = right = val;
|
|
72
|
+
if (val) dirs.left = dirs.right = val;
|
|
63
73
|
}
|
|
64
74
|
if (marginTop != null) {
|
|
65
75
|
const val = parseMarginValue(marginTop);
|
|
66
|
-
if (val) top = val;
|
|
76
|
+
if (val) dirs.top = val;
|
|
67
77
|
}
|
|
68
78
|
if (marginRight != null) {
|
|
69
79
|
const val = parseMarginValue(marginRight);
|
|
70
|
-
if (val) right = val;
|
|
80
|
+
if (val) dirs.right = val;
|
|
71
81
|
}
|
|
72
82
|
if (marginBottom != null) {
|
|
73
83
|
const val = parseMarginValue(marginBottom);
|
|
74
|
-
if (val) bottom = val;
|
|
84
|
+
if (val) dirs.bottom = val;
|
|
75
85
|
}
|
|
76
86
|
if (marginLeft != null) {
|
|
77
87
|
const val = parseMarginValue(marginLeft);
|
|
78
|
-
if (val) left = val;
|
|
88
|
+
if (val) dirs.left = val;
|
|
79
89
|
}
|
|
80
|
-
|
|
81
|
-
if (top === bottom && left === right) return { margin: `${top} ${left}` };
|
|
82
|
-
return { margin: `${top} ${right} ${bottom} ${left}` };
|
|
90
|
+
return optimizeMargin(dirs);
|
|
83
91
|
}
|
|
84
92
|
marginStyle.__lookupStyles = [
|
|
85
93
|
"margin",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"margin.js","names":[],"sources":["../../src/styles/margin.ts"],"sourcesContent":["import { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\n/**\n * Parse a margin value and return the first processed value\n */\nfunction parseMarginValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '1x';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || 'var(--gap)';\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"margin.js","names":[],"sources":["../../src/styles/margin.ts"],"sourcesContent":["import type { StyleDetails } from '../parser/types';\nimport { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\ntype Direction = (typeof DIRECTIONS)[number];\n\n/**\n * Parse a margin value and return the first processed value\n */\nfunction parseMarginValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '1x';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || 'var(--gap)';\n}\n\n/**\n * Extract values and directions from a single parsed group.\n */\nfunction extractGroupData(group: StyleDetails): {\n values: string[];\n directions: Direction[];\n} {\n const { values = [], mods = [] } = group;\n return {\n values: values.length ? values : ['var(--gap)'],\n directions: filterMods(mods, DIRECTIONS) as Direction[],\n };\n}\n\n/**\n * Apply a single group's values and directions onto a direction map.\n */\nfunction applyGroup(\n dirs: Record<Direction, string>,\n values: string[],\n directions: Direction[],\n): void {\n if (!values.length) return;\n\n if (directions.length === 0) {\n dirs.top = values[0];\n dirs.right = values[1] || values[0];\n dirs.bottom = values[2] || values[0];\n dirs.left = values[3] || values[1] || values[0];\n } else {\n directions.forEach((dir, i) => {\n dirs[dir] = values[i] ?? values[0];\n });\n }\n}\n\n/**\n * Optimize margin output shorthand.\n */\nfunction optimizeMargin(dirs: Record<Direction, string>): {\n margin: string;\n} {\n const { top, right, bottom, left } = dirs;\n if (top === right && right === bottom && bottom === left) {\n return { margin: top };\n }\n if (top === bottom && left === right) {\n return { margin: `${top} ${left}` };\n }\n return { margin: `${top} ${right} ${bottom} ${left}` };\n}\n\nexport function marginStyle({\n margin,\n marginBlock,\n marginInline,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n}: {\n margin?: string | number | boolean;\n marginBlock?: string | number | boolean;\n marginInline?: string | number | boolean;\n marginTop?: string | number | boolean;\n marginRight?: string | number | boolean;\n marginBottom?: string | number | boolean;\n marginLeft?: string | number | boolean;\n}) {\n if (\n margin == null &&\n marginBlock == null &&\n marginInline == null &&\n marginTop == null &&\n marginRight == null &&\n marginBottom == null &&\n marginLeft == null\n ) {\n return {};\n }\n\n const dirs: Record<Direction, string> = {\n top: '0',\n right: '0',\n bottom: '0',\n left: '0',\n };\n\n // Priority 1 (lowest): margin\n if (margin != null) {\n if (typeof margin === 'number') {\n const v = `${margin}px`;\n dirs.top = dirs.right = dirs.bottom = dirs.left = v;\n } else if (margin === true) {\n margin = '1x';\n }\n\n if (typeof margin === 'string' && margin) {\n const processed = parseStyle(margin);\n const groups = processed.groups ?? [];\n\n for (const group of groups) {\n const { values, directions } = extractGroupData(group);\n applyGroup(dirs, values, directions);\n }\n }\n }\n\n // Priority 2 (medium): marginBlock/marginInline\n if (marginBlock != null) {\n const val = parseMarginValue(marginBlock);\n if (val) dirs.top = dirs.bottom = val;\n }\n if (marginInline != null) {\n const val = parseMarginValue(marginInline);\n if (val) dirs.left = dirs.right = val;\n }\n\n // Priority 3 (highest): individual directions\n if (marginTop != null) {\n const val = parseMarginValue(marginTop);\n if (val) dirs.top = val;\n }\n if (marginRight != null) {\n const val = parseMarginValue(marginRight);\n if (val) dirs.right = val;\n }\n if (marginBottom != null) {\n const val = parseMarginValue(marginBottom);\n if (val) dirs.bottom = val;\n }\n if (marginLeft != null) {\n const val = parseMarginValue(marginLeft);\n if (val) dirs.left = val;\n }\n\n return optimizeMargin(dirs);\n}\n\nmarginStyle.__lookupStyles = [\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'marginBlock',\n 'marginInline',\n];\n"],"mappings":";;;;;;AAQA,SAAS,iBAAiB,OAAiD;AACzE,KAAI,OAAO,UA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P;AAGD,KAAI,UAAU,MAAM;AAClB,MAAI,OAAO,WAAW,SAEpB,MAAK,MAAM,KAAK,QAAQ,KAAK,SAAS,KAAK,OADjC,GAAG,OAAO;WAEX,WAAW,KACpB,UAAS;AAGX,MAAI,OAAO,WAAW,YAAY,QAAQ;GAExC,MAAM,SADY,WAAW,OAAO,CACX,UAAU,EAAE;AAErC,QAAK,MAAM,SAAS,QAAQ;IAC1B,MAAM,EAAE,QAAQ,eAAe,iBAAiB,MAAM;AACtD,eAAW,MAAM,QAAQ,WAAW;;;;AAM1C,KAAI,eAAe,MAAM;EACvB,MAAM,MAAM,iBAAiB,YAAY;AACzC,MAAI,IAAK,MAAK,MAAM,KAAK,SAAS;;AAEpC,KAAI,gBAAgB,MAAM;EACxB,MAAM,MAAM,iBAAiB,aAAa;AAC1C,MAAI,IAAK,MAAK,OAAO,KAAK,QAAQ;;AAIpC,KAAI,aAAa,MAAM;EACrB,MAAM,MAAM,iBAAiB,UAAU;AACvC,MAAI,IAAK,MAAK,MAAM;;AAEtB,KAAI,eAAe,MAAM;EACvB,MAAM,MAAM,iBAAiB,YAAY;AACzC,MAAI,IAAK,MAAK,QAAQ;;AAExB,KAAI,gBAAgB,MAAM;EACxB,MAAM,MAAM,iBAAiB,aAAa;AAC1C,MAAI,IAAK,MAAK,SAAS;;AAEzB,KAAI,cAAc,MAAM;EACtB,MAAM,MAAM,iBAAiB,WAAW;AACxC,MAAI,IAAK,MAAK,OAAO;;AAGvB,QAAO,eAAe,KAAK;;AAG7B,YAAY,iBAAiB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
package/dist/styles/padding.d.ts
CHANGED
|
@@ -15,11 +15,7 @@ declare function paddingStyle({
|
|
|
15
15
|
paddingRight?: string | number | boolean;
|
|
16
16
|
paddingBottom?: string | number | boolean;
|
|
17
17
|
paddingLeft?: string | number | boolean;
|
|
18
|
-
}): {
|
|
19
|
-
padding?: undefined;
|
|
20
|
-
} | {
|
|
21
|
-
padding: string;
|
|
22
|
-
};
|
|
18
|
+
}): {};
|
|
23
19
|
declare namespace paddingStyle {
|
|
24
20
|
var __lookupStyles: string[];
|
|
25
21
|
}
|
package/dist/styles/padding.js
CHANGED
|
@@ -12,74 +12,82 @@ function parsePaddingValue(value) {
|
|
|
12
12
|
return values[0] || "var(--gap)";
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Extract values and directions from a single parsed group.
|
|
16
16
|
*/
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
values: [`${value}px`],
|
|
20
|
-
directions: []
|
|
21
|
-
};
|
|
22
|
-
if (!value) return {
|
|
23
|
-
values: [],
|
|
24
|
-
directions: []
|
|
25
|
-
};
|
|
26
|
-
if (value === true) value = "1x";
|
|
27
|
-
const { values = [], mods = [] } = parseStyle(value).groups[0] ?? {};
|
|
17
|
+
function extractGroupData(group) {
|
|
18
|
+
const { values = [], mods = [] } = group;
|
|
28
19
|
return {
|
|
29
20
|
values: values.length ? values : ["var(--gap)"],
|
|
30
21
|
directions: filterMods(mods, DIRECTIONS)
|
|
31
22
|
};
|
|
32
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Apply a single group's values and directions onto a direction map.
|
|
26
|
+
*/
|
|
27
|
+
function applyGroup(dirs, values, directions) {
|
|
28
|
+
if (!values.length) return;
|
|
29
|
+
if (directions.length === 0) {
|
|
30
|
+
dirs.top = values[0];
|
|
31
|
+
dirs.right = values[1] || values[0];
|
|
32
|
+
dirs.bottom = values[2] || values[0];
|
|
33
|
+
dirs.left = values[3] || values[1] || values[0];
|
|
34
|
+
} else directions.forEach((dir, i) => {
|
|
35
|
+
dirs[dir] = values[i] ?? values[0];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Optimize padding output shorthand.
|
|
40
|
+
*/
|
|
41
|
+
function optimizePadding(dirs) {
|
|
42
|
+
const { top, right, bottom, left } = dirs;
|
|
43
|
+
if (top === right && right === bottom && bottom === left) return { padding: top };
|
|
44
|
+
if (top === bottom && left === right) return { padding: `${top} ${left}` };
|
|
45
|
+
return { padding: `${top} ${right} ${bottom} ${left}` };
|
|
46
|
+
}
|
|
33
47
|
function paddingStyle({ padding, paddingBlock, paddingInline, paddingTop, paddingRight, paddingBottom, paddingLeft }) {
|
|
34
48
|
if (padding == null && paddingBlock == null && paddingInline == null && paddingTop == null && paddingRight == null && paddingBottom == null && paddingLeft == null) return {};
|
|
35
|
-
|
|
36
|
-
"0",
|
|
37
|
-
"0",
|
|
38
|
-
"0",
|
|
39
|
-
"0"
|
|
40
|
-
|
|
49
|
+
const dirs = {
|
|
50
|
+
top: "0",
|
|
51
|
+
right: "0",
|
|
52
|
+
bottom: "0",
|
|
53
|
+
left: "0"
|
|
54
|
+
};
|
|
41
55
|
if (padding != null) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
else if (dir === "right") right = val;
|
|
52
|
-
else if (dir === "bottom") bottom = val;
|
|
53
|
-
else if (dir === "left") left = val;
|
|
54
|
-
});
|
|
56
|
+
if (typeof padding === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${padding}px`;
|
|
57
|
+
else if (padding === true) padding = "1x";
|
|
58
|
+
if (typeof padding === "string" && padding) {
|
|
59
|
+
const groups = parseStyle(padding).groups ?? [];
|
|
60
|
+
for (const group of groups) {
|
|
61
|
+
const { values, directions } = extractGroupData(group);
|
|
62
|
+
applyGroup(dirs, values, directions);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
55
65
|
}
|
|
56
66
|
if (paddingBlock != null) {
|
|
57
67
|
const val = parsePaddingValue(paddingBlock);
|
|
58
|
-
if (val) top = bottom = val;
|
|
68
|
+
if (val) dirs.top = dirs.bottom = val;
|
|
59
69
|
}
|
|
60
70
|
if (paddingInline != null) {
|
|
61
71
|
const val = parsePaddingValue(paddingInline);
|
|
62
|
-
if (val) left = right = val;
|
|
72
|
+
if (val) dirs.left = dirs.right = val;
|
|
63
73
|
}
|
|
64
74
|
if (paddingTop != null) {
|
|
65
75
|
const val = parsePaddingValue(paddingTop);
|
|
66
|
-
if (val) top = val;
|
|
76
|
+
if (val) dirs.top = val;
|
|
67
77
|
}
|
|
68
78
|
if (paddingRight != null) {
|
|
69
79
|
const val = parsePaddingValue(paddingRight);
|
|
70
|
-
if (val) right = val;
|
|
80
|
+
if (val) dirs.right = val;
|
|
71
81
|
}
|
|
72
82
|
if (paddingBottom != null) {
|
|
73
83
|
const val = parsePaddingValue(paddingBottom);
|
|
74
|
-
if (val) bottom = val;
|
|
84
|
+
if (val) dirs.bottom = val;
|
|
75
85
|
}
|
|
76
86
|
if (paddingLeft != null) {
|
|
77
87
|
const val = parsePaddingValue(paddingLeft);
|
|
78
|
-
if (val) left = val;
|
|
88
|
+
if (val) dirs.left = val;
|
|
79
89
|
}
|
|
80
|
-
|
|
81
|
-
if (top === bottom && left === right) return { padding: `${top} ${left}` };
|
|
82
|
-
return { padding: `${top} ${right} ${bottom} ${left}` };
|
|
90
|
+
return optimizePadding(dirs);
|
|
83
91
|
}
|
|
84
92
|
paddingStyle.__lookupStyles = [
|
|
85
93
|
"padding",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"padding.js","names":[],"sources":["../../src/styles/padding.ts"],"sourcesContent":["import { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\n/**\n * Parse a padding value and return the first processed value\n */\nfunction parsePaddingValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '1x';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || 'var(--gap)';\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"padding.js","names":[],"sources":["../../src/styles/padding.ts"],"sourcesContent":["import type { StyleDetails } from '../parser/types';\nimport { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\ntype Direction = (typeof DIRECTIONS)[number];\n\n/**\n * Parse a padding value and return the first processed value\n */\nfunction parsePaddingValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '1x';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || 'var(--gap)';\n}\n\n/**\n * Extract values and directions from a single parsed group.\n */\nfunction extractGroupData(group: StyleDetails): {\n values: string[];\n directions: Direction[];\n} {\n const { values = [], mods = [] } = group;\n return {\n values: values.length ? values : ['var(--gap)'],\n directions: filterMods(mods, DIRECTIONS) as Direction[],\n };\n}\n\n/**\n * Apply a single group's values and directions onto a direction map.\n */\nfunction applyGroup(\n dirs: Record<Direction, string>,\n values: string[],\n directions: Direction[],\n): void {\n if (!values.length) return;\n\n if (directions.length === 0) {\n dirs.top = values[0];\n dirs.right = values[1] || values[0];\n dirs.bottom = values[2] || values[0];\n dirs.left = values[3] || values[1] || values[0];\n } else {\n directions.forEach((dir, i) => {\n dirs[dir] = values[i] ?? values[0];\n });\n }\n}\n\n/**\n * Optimize padding output shorthand.\n */\nfunction optimizePadding(dirs: Record<Direction, string>): {\n padding: string;\n} {\n const { top, right, bottom, left } = dirs;\n if (top === right && right === bottom && bottom === left) {\n return { padding: top };\n }\n if (top === bottom && left === right) {\n return { padding: `${top} ${left}` };\n }\n return { padding: `${top} ${right} ${bottom} ${left}` };\n}\n\nexport function paddingStyle({\n padding,\n paddingBlock,\n paddingInline,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n}: {\n padding?: string | number | boolean;\n paddingBlock?: string | number | boolean;\n paddingInline?: string | number | boolean;\n paddingTop?: string | number | boolean;\n paddingRight?: string | number | boolean;\n paddingBottom?: string | number | boolean;\n paddingLeft?: string | number | boolean;\n}) {\n if (\n padding == null &&\n paddingBlock == null &&\n paddingInline == null &&\n paddingTop == null &&\n paddingRight == null &&\n paddingBottom == null &&\n paddingLeft == null\n ) {\n return {};\n }\n\n const dirs: Record<Direction, string> = {\n top: '0',\n right: '0',\n bottom: '0',\n left: '0',\n };\n\n // Priority 1 (lowest): padding\n if (padding != null) {\n if (typeof padding === 'number') {\n const v = `${padding}px`;\n dirs.top = dirs.right = dirs.bottom = dirs.left = v;\n } else if (padding === true) {\n padding = '1x';\n }\n\n if (typeof padding === 'string' && padding) {\n const processed = parseStyle(padding);\n const groups = processed.groups ?? [];\n\n for (const group of groups) {\n const { values, directions } = extractGroupData(group);\n applyGroup(dirs, values, directions);\n }\n }\n }\n\n // Priority 2 (medium): paddingBlock/paddingInline\n if (paddingBlock != null) {\n const val = parsePaddingValue(paddingBlock);\n if (val) dirs.top = dirs.bottom = val;\n }\n if (paddingInline != null) {\n const val = parsePaddingValue(paddingInline);\n if (val) dirs.left = dirs.right = val;\n }\n\n // Priority 3 (highest): individual directions\n if (paddingTop != null) {\n const val = parsePaddingValue(paddingTop);\n if (val) dirs.top = val;\n }\n if (paddingRight != null) {\n const val = parsePaddingValue(paddingRight);\n if (val) dirs.right = val;\n }\n if (paddingBottom != null) {\n const val = parsePaddingValue(paddingBottom);\n if (val) dirs.bottom = val;\n }\n if (paddingLeft != null) {\n const val = parsePaddingValue(paddingLeft);\n if (val) dirs.left = val;\n }\n\n return optimizePadding(dirs);\n}\n\npaddingStyle.__lookupStyles = [\n 'padding',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'paddingBlock',\n 'paddingInline',\n];\n"],"mappings":";;;;;;AAQA,SAAS,kBAAkB,OAAiD;AAC1E,KAAI,OAAO,UAAU,SAAU,QAAO,GAAG,MAAM;AAC/C,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,UAAU,KAAM,SAAQ;CAE5B,MAAM,EAAE,WAAW,WAAW,MAAM,CAAC,OAAO,MAAM,EAAE,QAAQ,EAAE,EAAE;AAEhE,QAAO,OAAO,MAAM;;;;;AAMtB,SAAS,iBAAiB,OAGxB;CACA,MAAM,EAAE,SAAS,EAAE,E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AS,QAAQ;IAC1B,MAAM,EAAE,QAAQ,eAAe,iBAAiB,MAAM;AACtD,eAAW,MAAM,QAAQ,WAAW;;;;AAM1C,KAAI,gBAAgB,MAAM;EACxB,MAAM,MAAM,kBAAkB,aAAa;AAC3C,MAAI,IAAK,MAAK,MAAM,KAAK,SAAS;;AAEpC,KAAI,iBAAiB,MAAM;EACzB,MAAM,MAAM,kBAAkB,cAAc;AAC5C,MAAI,IAAK,MAAK,OAAO,KAAK,QAAQ;;AAIpC,KAAI,cAAc,MAAM;EACtB,MAAM,MAAM,kBAAkB,WAAW;AACzC,MAAI,IAAK,MAAK,MAAM;;AAEtB,KAAI,gBAAgB,MAAM;EACxB,MAAM,MAAM,kBAAkB,aAAa;AAC3C,MAAI,IAAK,MAAK,QAAQ;;AAExB,KAAI,iBAAiB,MAAM;EACzB,MAAM,MAAM,kBAAkB,cAAc;AAC5C,MAAI,IAAK,MAAK,SAAS;;AAEzB,KAAI,eAAe,MAAM;EACvB,MAAM,MAAM,kBAAkB,YAAY;AAC1C,MAAI,IAAK,MAAK,OAAO;;AAGvB,QAAO,gBAAgB,KAAK;;AAG9B,aAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
|
@@ -86,6 +86,18 @@ const MAP = {
|
|
|
86
86
|
]
|
|
87
87
|
};
|
|
88
88
|
const DEFAULT_EASING = "linear";
|
|
89
|
+
const EASING_KEYWORDS = new Set([
|
|
90
|
+
"ease",
|
|
91
|
+
"ease-in",
|
|
92
|
+
"ease-out",
|
|
93
|
+
"ease-in-out",
|
|
94
|
+
"linear",
|
|
95
|
+
"step-start",
|
|
96
|
+
"step-end"
|
|
97
|
+
]);
|
|
98
|
+
function isEasing(token) {
|
|
99
|
+
return EASING_KEYWORDS.has(token) || token.startsWith("cubic-bezier(") || token.startsWith("steps(") || token.startsWith("linear(");
|
|
100
|
+
}
|
|
89
101
|
function getTiming(name) {
|
|
90
102
|
return `var(--${name}-transition, var(--transition))`;
|
|
91
103
|
}
|
|
@@ -97,24 +109,32 @@ function transitionStyle({ transition }) {
|
|
|
97
109
|
tokens.push(...g.all);
|
|
98
110
|
if (idx < processed.groups.length - 1) tokens.push(",");
|
|
99
111
|
});
|
|
100
|
-
if (
|
|
112
|
+
if (tokens.length === 0) return;
|
|
101
113
|
let tempTransition = [];
|
|
102
114
|
const transitions = [];
|
|
103
115
|
tokens.forEach((token) => {
|
|
104
116
|
if (token === ",") {
|
|
105
|
-
if (tempTransition) {
|
|
117
|
+
if (tempTransition.length) {
|
|
106
118
|
transitions.push(tempTransition);
|
|
107
119
|
tempTransition = [];
|
|
108
120
|
}
|
|
109
121
|
} else tempTransition.push(token);
|
|
110
122
|
});
|
|
111
|
-
if (tempTransition) transitions.push(tempTransition);
|
|
123
|
+
if (tempTransition.length) transitions.push(tempTransition);
|
|
112
124
|
const map = {};
|
|
113
125
|
transitions.forEach((transition) => {
|
|
114
126
|
const name = transition[0];
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
let timing;
|
|
128
|
+
let easing;
|
|
129
|
+
let delay;
|
|
130
|
+
if (transition[1] && isEasing(transition[1])) {
|
|
131
|
+
easing = transition[1];
|
|
132
|
+
delay = transition[2];
|
|
133
|
+
} else {
|
|
134
|
+
timing = transition[1];
|
|
135
|
+
easing = transition[2];
|
|
136
|
+
delay = transition[3];
|
|
137
|
+
}
|
|
118
138
|
(MAP[name] || [name]).forEach((style) => {
|
|
119
139
|
map[style] = [
|
|
120
140
|
name,
|