@vitus-labs/unistyle 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/index.d.ts +22 -1
- package/lib/index.js +96 -27
- package/lib/vitus-labs-unistyle.native.js +96 -27
- package/package.json +5 -11
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Transforms property-centric theme objects into breakpoint-centric CSS with media
|
|
|
13
13
|
- **px-to-rem conversion** — configurable rootSize, zero-effort unit handling
|
|
14
14
|
- **Breakpoint deduplication** — identical breakpoints are collapsed, no redundant CSS
|
|
15
15
|
- **Three input formats** — scalar, mobile-first array, or breakpoint object per property
|
|
16
|
-
- **Data-driven styles** —
|
|
16
|
+
- **Data-driven styles** — 170+ CSS properties processed from a theme object
|
|
17
17
|
- **Alignment helpers** — flex alignment constants for X and Y axes
|
|
18
18
|
|
|
19
19
|
## Installation
|
package/lib/index.d.ts
CHANGED
|
@@ -18,6 +18,24 @@ type TProvider = {
|
|
|
18
18
|
*/
|
|
19
19
|
declare const Provider: FC<TProvider>;
|
|
20
20
|
//#endregion
|
|
21
|
+
//#region src/responsive/between.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* Build a closed-range `@media` query string from two breakpoint values.
|
|
24
|
+
*
|
|
25
|
+
* Accepts any flat breakpoint map (`Record<string, number | string>`).
|
|
26
|
+
* Numeric values render as `${n}px`, string values pass through as-is
|
|
27
|
+
* so consumers can use rem/em units (`'36em'` → as-is). The upper
|
|
28
|
+
* bound is decremented by `0.02px` so adjacent ranges don't overlap on
|
|
29
|
+
* Safari's sub-pixel matching.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const onlyMobile = between({ xs: 0, sm: 576 }, 'xs', 'sm')
|
|
34
|
+
* // → '@media (min-width: 0px) and (max-width: 575.98px)'
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare const between: <B extends Record<string, number | string>>(breakpoints: B, minKey: keyof B, maxKey: keyof B) => string;
|
|
38
|
+
//#endregion
|
|
21
39
|
//#region src/responsive/breakpoints.d.ts
|
|
22
40
|
declare const breakpoints$1: {
|
|
23
41
|
readonly rootSize: 16;
|
|
@@ -516,6 +534,9 @@ type Styles = ({
|
|
|
516
534
|
* and delegates each to `processDescriptor`, which maps theme values
|
|
517
535
|
* to CSS strings. The result is a single `css` tagged-template literal
|
|
518
536
|
* containing all non-null property outputs.
|
|
537
|
+
*
|
|
538
|
+
* In development, warns once per unknown theme key — the typo class of
|
|
539
|
+
* silent failure (e.g. `paddng: 8`) that used to render empty CSS.
|
|
519
540
|
*/
|
|
520
541
|
declare const styles$1: Styles;
|
|
521
542
|
//#endregion
|
|
@@ -551,5 +572,5 @@ type Values = (values: unknown[], rootSize?: number, outputUnit?: Units) => stri
|
|
|
551
572
|
*/
|
|
552
573
|
declare const values: Values;
|
|
553
574
|
//#endregion
|
|
554
|
-
export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, type AlignContent, type AlignContentAlignXKeys, type AlignContentAlignYKeys, type AlignContentDirectionKeys, type Breakpoints, type BrowserColors, type Color, type CreateMediaQueries, type Defaults, type ExtendCss, type MakeItResponsive, type MakeItResponsiveStyles, type NormalizeTheme, type PropertyValue, Provider, type SortBreakpoints, type StripUnit, type Styles, type Theme as StylesTheme, type TProvider, type TransformTheme, type UnitValue, type Value, type Values, alignContent, breakpoints$1 as breakpoints, context, createMediaQueries, extendCss, makeItResponsive, normalizeTheme, sortBreakpoints, stripUnit, styles$1 as styles, transformTheme, value, values };
|
|
575
|
+
export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, type AlignContent, type AlignContentAlignXKeys, type AlignContentAlignYKeys, type AlignContentDirectionKeys, type Breakpoints, type BrowserColors, type Color, type CreateMediaQueries, type Defaults, type ExtendCss, type MakeItResponsive, type MakeItResponsiveStyles, type NormalizeTheme, type PropertyValue, Provider, type SortBreakpoints, type StripUnit, type Styles, type Theme as StylesTheme, type TProvider, type TransformTheme, type UnitValue, type Value, type Values, alignContent, between, breakpoints$1 as breakpoints, context, createMediaQueries, extendCss, makeItResponsive, normalizeTheme, sortBreakpoints, stripUnit, styles$1 as styles, transformTheme, value, values };
|
|
555
576
|
//# sourceMappingURL=index2.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,29 @@ import { Provider as Provider$1, config, context, isEmpty, set } from "@vitus-la
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
|
|
5
|
+
//#region src/responsive/between.ts
|
|
6
|
+
/**
|
|
7
|
+
* Build a closed-range `@media` query string from two breakpoint values.
|
|
8
|
+
*
|
|
9
|
+
* Accepts any flat breakpoint map (`Record<string, number | string>`).
|
|
10
|
+
* Numeric values render as `${n}px`, string values pass through as-is
|
|
11
|
+
* so consumers can use rem/em units (`'36em'` → as-is). The upper
|
|
12
|
+
* bound is decremented by `0.02px` so adjacent ranges don't overlap on
|
|
13
|
+
* Safari's sub-pixel matching.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const onlyMobile = between({ xs: 0, sm: 576 }, 'xs', 'sm')
|
|
18
|
+
* // → '@media (min-width: 0px) and (max-width: 575.98px)'
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
const between = (breakpoints, minKey, maxKey) => {
|
|
22
|
+
const min = breakpoints[minKey];
|
|
23
|
+
const max = breakpoints[maxKey];
|
|
24
|
+
return `@media (min-width: ${typeof min === "number" ? `${min}px` : String(min)}) and (max-width: ${typeof max === "number" ? `${Math.max(0, max - .02)}px` : String(max)})`;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
5
28
|
//#region src/responsive/breakpoints.ts
|
|
6
29
|
const breakpoints = {
|
|
7
30
|
rootSize: 16,
|
|
@@ -23,19 +46,22 @@ const breakpoints = {
|
|
|
23
46
|
* Others are wrapped in `@media (min-width: <em>)` — em units
|
|
24
47
|
* ensure correct behaviour when users change browser font size.
|
|
25
48
|
*/
|
|
26
|
-
const createMediaQueries = ({ breakpoints, rootSize, css }) =>
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
const createMediaQueries = ({ breakpoints, rootSize, css }) => {
|
|
50
|
+
const acc = {};
|
|
51
|
+
for (const key in breakpoints) {
|
|
52
|
+
const breakpointValue = breakpoints[key];
|
|
53
|
+
if (breakpointValue === 0) acc[key] = (...args) => css(...args);
|
|
54
|
+
else if (breakpointValue != null) {
|
|
55
|
+
const emSize = breakpointValue / rootSize;
|
|
56
|
+
acc[key] = (...args) => css`
|
|
32
57
|
@media only screen and (min-width: ${emSize}em) {
|
|
33
58
|
${css(...args)};
|
|
34
59
|
}
|
|
35
60
|
`;
|
|
61
|
+
}
|
|
36
62
|
}
|
|
37
63
|
return acc;
|
|
38
|
-
}
|
|
64
|
+
};
|
|
39
65
|
|
|
40
66
|
//#endregion
|
|
41
67
|
//#region src/responsive/normalizeTheme.ts
|
|
@@ -59,7 +85,13 @@ const handleObjectCb = (obj) => (bp, i, bps, res) => {
|
|
|
59
85
|
return previousValue;
|
|
60
86
|
};
|
|
61
87
|
const handleValueCb = (value) => () => value;
|
|
62
|
-
const shouldNormalize = (props) =>
|
|
88
|
+
const shouldNormalize = (props) => {
|
|
89
|
+
for (const key in props) {
|
|
90
|
+
const item = props[key];
|
|
91
|
+
if (typeof item === "object" || Array.isArray(item)) return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
};
|
|
63
95
|
/**
|
|
64
96
|
* Expands each theme property into a full breakpoint map so every
|
|
65
97
|
* breakpoint has a value. Arrays fill by index (last value carries forward),
|
|
@@ -70,12 +102,13 @@ const normalizeTheme = ({ theme, breakpoints }) => {
|
|
|
70
102
|
if (!shouldNormalize(theme)) return theme;
|
|
71
103
|
const getBpValues = assignToBreakpointKey(breakpoints);
|
|
72
104
|
const result = {};
|
|
73
|
-
|
|
74
|
-
|
|
105
|
+
for (const key in theme) {
|
|
106
|
+
const value = theme[key];
|
|
107
|
+
if (value == null) continue;
|
|
75
108
|
if (Array.isArray(value)) result[key] = getBpValues(handleArrayCb(value));
|
|
76
109
|
else if (typeof value === "object") result[key] = getBpValues(handleObjectCb(value));
|
|
77
110
|
else result[key] = getBpValues(handleValueCb(value));
|
|
78
|
-
}
|
|
111
|
+
}
|
|
79
112
|
return result;
|
|
80
113
|
};
|
|
81
114
|
|
|
@@ -205,11 +238,14 @@ const optimizeBreakpointDeltas = (cssStrings) => {
|
|
|
205
238
|
const shallowEqual = (a, b) => {
|
|
206
239
|
if (a === b) return true;
|
|
207
240
|
if (!a || !b) return false;
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
241
|
+
let aCount = 0;
|
|
242
|
+
for (const key in a) {
|
|
243
|
+
aCount++;
|
|
244
|
+
if (a[key] !== b[key]) return false;
|
|
245
|
+
}
|
|
246
|
+
let bCount = 0;
|
|
247
|
+
for (const _ in b) bCount++;
|
|
248
|
+
return aCount === bCount;
|
|
213
249
|
};
|
|
214
250
|
/**
|
|
215
251
|
* Removes breakpoints whose styles are identical to the previous one.
|
|
@@ -247,19 +283,20 @@ const removeUnexpectedKeys = (obj, keys) => {
|
|
|
247
283
|
const transformTheme = ({ theme, breakpoints }) => {
|
|
248
284
|
const result = {};
|
|
249
285
|
if (isEmpty(theme) || isEmpty(breakpoints)) return result;
|
|
250
|
-
|
|
251
|
-
|
|
286
|
+
for (const key in theme) {
|
|
287
|
+
const value = theme[key];
|
|
288
|
+
if (Array.isArray(value) && value.length > 0) for (let i = 0; i < value.length; i++) {
|
|
252
289
|
const indexBreakpoint = breakpoints[i];
|
|
253
|
-
set(result, [indexBreakpoint, key],
|
|
254
|
-
}
|
|
255
|
-
else if (typeof value === "object" && value !== null)
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
else if (value != null) {
|
|
290
|
+
set(result, [indexBreakpoint, key], value[i]);
|
|
291
|
+
}
|
|
292
|
+
else if (typeof value === "object" && value !== null) {
|
|
293
|
+
const obj = value;
|
|
294
|
+
for (const childKey in obj) set(result, [childKey, key], obj[childKey]);
|
|
295
|
+
} else if (value != null) {
|
|
259
296
|
const firstBreakpoint = breakpoints[0];
|
|
260
297
|
set(result, [firstBreakpoint, key], value);
|
|
261
298
|
}
|
|
262
|
-
}
|
|
299
|
+
}
|
|
263
300
|
return removeUnexpectedKeys(result, breakpoints);
|
|
264
301
|
};
|
|
265
302
|
|
|
@@ -424,7 +461,7 @@ const ALIGN_CONTENT_DIRECTION = {
|
|
|
424
461
|
const alignContent = (attrs) => {
|
|
425
462
|
const { direction, alignX, alignY } = attrs;
|
|
426
463
|
if (isEmpty(attrs) || !direction || !alignX || !alignY) return null;
|
|
427
|
-
const isReverted =
|
|
464
|
+
const isReverted = direction === "inline" || direction === "reverseInline";
|
|
428
465
|
const dir = ALIGN_CONTENT_DIRECTION[direction];
|
|
429
466
|
const x = ALIGN_CONTENT_MAP_X[alignX];
|
|
430
467
|
const y = ALIGN_CONTENT_MAP_Y[alignY];
|
|
@@ -1565,6 +1602,11 @@ const propertyMap = [
|
|
|
1565
1602
|
css: "border-spacing",
|
|
1566
1603
|
key: "borderSpacing"
|
|
1567
1604
|
},
|
|
1605
|
+
{
|
|
1606
|
+
kind: "simple",
|
|
1607
|
+
css: "border-collapse",
|
|
1608
|
+
key: "borderCollapse"
|
|
1609
|
+
},
|
|
1568
1610
|
{
|
|
1569
1611
|
kind: "simple",
|
|
1570
1612
|
css: "border-inline",
|
|
@@ -2065,13 +2107,40 @@ const propertyMap = [
|
|
|
2065
2107
|
|
|
2066
2108
|
//#endregion
|
|
2067
2109
|
//#region src/styles/styles/index.ts
|
|
2110
|
+
let knownKeysCache = null;
|
|
2111
|
+
const buildKnownKeys = () => {
|
|
2112
|
+
const out = /* @__PURE__ */ new Set();
|
|
2113
|
+
for (const d of propertyMap) {
|
|
2114
|
+
if ("key" in d) out.add(d.key);
|
|
2115
|
+
if ("id" in d) out.add(d.id);
|
|
2116
|
+
if ("keys" in d) {
|
|
2117
|
+
const keys = d.keys;
|
|
2118
|
+
if (keys && typeof keys === "object") {
|
|
2119
|
+
for (const k of Object.values(keys)) if (typeof k === "string") out.add(k);
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
out.add("keyframe");
|
|
2124
|
+
return out;
|
|
2125
|
+
};
|
|
2126
|
+
const warnedKeys = /* @__PURE__ */ new Set();
|
|
2068
2127
|
/**
|
|
2069
2128
|
* Data-driven style processor. Iterates the `propertyMap` descriptors
|
|
2070
2129
|
* and delegates each to `processDescriptor`, which maps theme values
|
|
2071
2130
|
* to CSS strings. The result is a single `css` tagged-template literal
|
|
2072
2131
|
* containing all non-null property outputs.
|
|
2132
|
+
*
|
|
2133
|
+
* In development, warns once per unknown theme key — the typo class of
|
|
2134
|
+
* silent failure (e.g. `paddng: 8`) that used to render empty CSS.
|
|
2073
2135
|
*/
|
|
2074
2136
|
const styles = ({ theme: t, css, rootSize }) => {
|
|
2137
|
+
if (process.env.NODE_ENV !== "production" && t) {
|
|
2138
|
+
if (!knownKeysCache) knownKeysCache = buildKnownKeys();
|
|
2139
|
+
for (const k in t) if (!knownKeysCache.has(k) && !warnedKeys.has(k)) {
|
|
2140
|
+
warnedKeys.add(k);
|
|
2141
|
+
console.warn(`[@vitus-labs/unistyle] unknown theme key "${k}" — no propertyMap descriptor exists. Possible typo? It will be silently ignored.`);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2075
2144
|
const calc = (...params) => values(params, rootSize);
|
|
2076
2145
|
const shorthand = edge(rootSize);
|
|
2077
2146
|
const borderRadiusFn = borderRadius(rootSize);
|
|
@@ -2081,5 +2150,5 @@ const styles = ({ theme: t, css, rootSize }) => {
|
|
|
2081
2150
|
};
|
|
2082
2151
|
|
|
2083
2152
|
//#endregion
|
|
2084
|
-
export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, Provider, alignContent, breakpoints, context, createMediaQueries, extendCss, makeItResponsive, normalizeTheme, sortBreakpoints, stripUnit, styles, transformTheme, value, values };
|
|
2153
|
+
export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, Provider, alignContent, between, breakpoints, context, createMediaQueries, extendCss, makeItResponsive, normalizeTheme, sortBreakpoints, stripUnit, styles, transformTheme, value, values };
|
|
2085
2154
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,6 +2,29 @@ import { Provider as Provider$1, config, context, isEmpty, set } from "@vitus-la
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
|
|
5
|
+
//#region src/responsive/between.ts
|
|
6
|
+
/**
|
|
7
|
+
* Build a closed-range `@media` query string from two breakpoint values.
|
|
8
|
+
*
|
|
9
|
+
* Accepts any flat breakpoint map (`Record<string, number | string>`).
|
|
10
|
+
* Numeric values render as `${n}px`, string values pass through as-is
|
|
11
|
+
* so consumers can use rem/em units (`'36em'` → as-is). The upper
|
|
12
|
+
* bound is decremented by `0.02px` so adjacent ranges don't overlap on
|
|
13
|
+
* Safari's sub-pixel matching.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const onlyMobile = between({ xs: 0, sm: 576 }, 'xs', 'sm')
|
|
18
|
+
* // → '@media (min-width: 0px) and (max-width: 575.98px)'
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
const between = (breakpoints, minKey, maxKey) => {
|
|
22
|
+
const min = breakpoints[minKey];
|
|
23
|
+
const max = breakpoints[maxKey];
|
|
24
|
+
return `@media (min-width: ${typeof min === "number" ? `${min}px` : String(min)}) and (max-width: ${typeof max === "number" ? `${Math.max(0, max - .02)}px` : String(max)})`;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
5
28
|
//#region src/responsive/breakpoints.ts
|
|
6
29
|
const breakpoints = {
|
|
7
30
|
rootSize: 16,
|
|
@@ -23,19 +46,22 @@ const breakpoints = {
|
|
|
23
46
|
* Others are wrapped in `@media (min-width: <em>)` — em units
|
|
24
47
|
* ensure correct behaviour when users change browser font size.
|
|
25
48
|
*/
|
|
26
|
-
const createMediaQueries = ({ breakpoints, rootSize, css }) =>
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
const createMediaQueries = ({ breakpoints, rootSize, css }) => {
|
|
50
|
+
const acc = {};
|
|
51
|
+
for (const key in breakpoints) {
|
|
52
|
+
const breakpointValue = breakpoints[key];
|
|
53
|
+
if (breakpointValue === 0) acc[key] = (...args) => css(...args);
|
|
54
|
+
else if (breakpointValue != null) {
|
|
55
|
+
const emSize = breakpointValue / rootSize;
|
|
56
|
+
acc[key] = (...args) => css`
|
|
32
57
|
@media only screen and (min-width: ${emSize}em) {
|
|
33
58
|
${css(...args)};
|
|
34
59
|
}
|
|
35
60
|
`;
|
|
61
|
+
}
|
|
36
62
|
}
|
|
37
63
|
return acc;
|
|
38
|
-
}
|
|
64
|
+
};
|
|
39
65
|
|
|
40
66
|
//#endregion
|
|
41
67
|
//#region src/responsive/normalizeTheme.ts
|
|
@@ -59,7 +85,13 @@ const handleObjectCb = (obj) => (bp, i, bps, res) => {
|
|
|
59
85
|
return previousValue;
|
|
60
86
|
};
|
|
61
87
|
const handleValueCb = (value) => () => value;
|
|
62
|
-
const shouldNormalize = (props) =>
|
|
88
|
+
const shouldNormalize = (props) => {
|
|
89
|
+
for (const key in props) {
|
|
90
|
+
const item = props[key];
|
|
91
|
+
if (typeof item === "object" || Array.isArray(item)) return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
};
|
|
63
95
|
/**
|
|
64
96
|
* Expands each theme property into a full breakpoint map so every
|
|
65
97
|
* breakpoint has a value. Arrays fill by index (last value carries forward),
|
|
@@ -70,12 +102,13 @@ const normalizeTheme = ({ theme, breakpoints }) => {
|
|
|
70
102
|
if (!shouldNormalize(theme)) return theme;
|
|
71
103
|
const getBpValues = assignToBreakpointKey(breakpoints);
|
|
72
104
|
const result = {};
|
|
73
|
-
|
|
74
|
-
|
|
105
|
+
for (const key in theme) {
|
|
106
|
+
const value = theme[key];
|
|
107
|
+
if (value == null) continue;
|
|
75
108
|
if (Array.isArray(value)) result[key] = getBpValues(handleArrayCb(value));
|
|
76
109
|
else if (typeof value === "object") result[key] = getBpValues(handleObjectCb(value));
|
|
77
110
|
else result[key] = getBpValues(handleValueCb(value));
|
|
78
|
-
}
|
|
111
|
+
}
|
|
79
112
|
return result;
|
|
80
113
|
};
|
|
81
114
|
|
|
@@ -205,11 +238,14 @@ const optimizeBreakpointDeltas = (cssStrings) => {
|
|
|
205
238
|
const shallowEqual = (a, b) => {
|
|
206
239
|
if (a === b) return true;
|
|
207
240
|
if (!a || !b) return false;
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
241
|
+
let aCount = 0;
|
|
242
|
+
for (const key in a) {
|
|
243
|
+
aCount++;
|
|
244
|
+
if (a[key] !== b[key]) return false;
|
|
245
|
+
}
|
|
246
|
+
let bCount = 0;
|
|
247
|
+
for (const _ in b) bCount++;
|
|
248
|
+
return aCount === bCount;
|
|
213
249
|
};
|
|
214
250
|
/**
|
|
215
251
|
* Removes breakpoints whose styles are identical to the previous one.
|
|
@@ -247,19 +283,20 @@ const removeUnexpectedKeys = (obj, keys) => {
|
|
|
247
283
|
const transformTheme = ({ theme, breakpoints }) => {
|
|
248
284
|
const result = {};
|
|
249
285
|
if (isEmpty(theme) || isEmpty(breakpoints)) return result;
|
|
250
|
-
|
|
251
|
-
|
|
286
|
+
for (const key in theme) {
|
|
287
|
+
const value = theme[key];
|
|
288
|
+
if (Array.isArray(value) && value.length > 0) for (let i = 0; i < value.length; i++) {
|
|
252
289
|
const indexBreakpoint = breakpoints[i];
|
|
253
|
-
set(result, [indexBreakpoint, key],
|
|
254
|
-
}
|
|
255
|
-
else if (typeof value === "object" && value !== null)
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
else if (value != null) {
|
|
290
|
+
set(result, [indexBreakpoint, key], value[i]);
|
|
291
|
+
}
|
|
292
|
+
else if (typeof value === "object" && value !== null) {
|
|
293
|
+
const obj = value;
|
|
294
|
+
for (const childKey in obj) set(result, [childKey, key], obj[childKey]);
|
|
295
|
+
} else if (value != null) {
|
|
259
296
|
const firstBreakpoint = breakpoints[0];
|
|
260
297
|
set(result, [firstBreakpoint, key], value);
|
|
261
298
|
}
|
|
262
|
-
}
|
|
299
|
+
}
|
|
263
300
|
return removeUnexpectedKeys(result, breakpoints);
|
|
264
301
|
};
|
|
265
302
|
|
|
@@ -424,7 +461,7 @@ const ALIGN_CONTENT_DIRECTION = {
|
|
|
424
461
|
const alignContent = (attrs) => {
|
|
425
462
|
const { direction, alignX, alignY } = attrs;
|
|
426
463
|
if (isEmpty(attrs) || !direction || !alignX || !alignY) return null;
|
|
427
|
-
const isReverted =
|
|
464
|
+
const isReverted = direction === "inline" || direction === "reverseInline";
|
|
428
465
|
const dir = ALIGN_CONTENT_DIRECTION[direction];
|
|
429
466
|
const x = ALIGN_CONTENT_MAP_X[alignX];
|
|
430
467
|
const y = ALIGN_CONTENT_MAP_Y[alignY];
|
|
@@ -1551,6 +1588,11 @@ const propertyMap = [
|
|
|
1551
1588
|
css: "border-spacing",
|
|
1552
1589
|
key: "borderSpacing"
|
|
1553
1590
|
},
|
|
1591
|
+
{
|
|
1592
|
+
kind: "simple",
|
|
1593
|
+
css: "border-collapse",
|
|
1594
|
+
key: "borderCollapse"
|
|
1595
|
+
},
|
|
1554
1596
|
{
|
|
1555
1597
|
kind: "simple",
|
|
1556
1598
|
css: "border-inline",
|
|
@@ -2051,13 +2093,40 @@ const propertyMap = [
|
|
|
2051
2093
|
|
|
2052
2094
|
//#endregion
|
|
2053
2095
|
//#region src/styles/styles/index.ts
|
|
2096
|
+
let knownKeysCache = null;
|
|
2097
|
+
const buildKnownKeys = () => {
|
|
2098
|
+
const out = /* @__PURE__ */ new Set();
|
|
2099
|
+
for (const d of propertyMap) {
|
|
2100
|
+
if ("key" in d) out.add(d.key);
|
|
2101
|
+
if ("id" in d) out.add(d.id);
|
|
2102
|
+
if ("keys" in d) {
|
|
2103
|
+
const keys = d.keys;
|
|
2104
|
+
if (keys && typeof keys === "object") {
|
|
2105
|
+
for (const k of Object.values(keys)) if (typeof k === "string") out.add(k);
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
out.add("keyframe");
|
|
2110
|
+
return out;
|
|
2111
|
+
};
|
|
2112
|
+
const warnedKeys = /* @__PURE__ */ new Set();
|
|
2054
2113
|
/**
|
|
2055
2114
|
* Data-driven style processor. Iterates the `propertyMap` descriptors
|
|
2056
2115
|
* and delegates each to `processDescriptor`, which maps theme values
|
|
2057
2116
|
* to CSS strings. The result is a single `css` tagged-template literal
|
|
2058
2117
|
* containing all non-null property outputs.
|
|
2118
|
+
*
|
|
2119
|
+
* In development, warns once per unknown theme key — the typo class of
|
|
2120
|
+
* silent failure (e.g. `paddng: 8`) that used to render empty CSS.
|
|
2059
2121
|
*/
|
|
2060
2122
|
const styles = ({ theme: t, css, rootSize }) => {
|
|
2123
|
+
if (process.env.NODE_ENV !== "production" && t) {
|
|
2124
|
+
if (!knownKeysCache) knownKeysCache = buildKnownKeys();
|
|
2125
|
+
for (const k in t) if (!knownKeysCache.has(k) && !warnedKeys.has(k)) {
|
|
2126
|
+
warnedKeys.add(k);
|
|
2127
|
+
console.warn(`[@vitus-labs/unistyle] unknown theme key "${k}" — no propertyMap descriptor exists. Possible typo? It will be silently ignored.`);
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2061
2130
|
const calc = (...params) => values(params, rootSize);
|
|
2062
2131
|
const shorthand = edge(rootSize);
|
|
2063
2132
|
const borderRadiusFn = borderRadius(rootSize);
|
|
@@ -2067,5 +2136,5 @@ const styles = ({ theme: t, css, rootSize }) => {
|
|
|
2067
2136
|
};
|
|
2068
2137
|
|
|
2069
2138
|
//#endregion
|
|
2070
|
-
export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, Provider, alignContent, breakpoints, context, createMediaQueries, extendCss, makeItResponsive, normalizeTheme, sortBreakpoints, stripUnit, styles, transformTheme, value, values };
|
|
2139
|
+
export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, Provider, alignContent, between, breakpoints, context, createMediaQueries, extendCss, makeItResponsive, normalizeTheme, sortBreakpoints, stripUnit, styles, transformTheme, value, values };
|
|
2071
2140
|
//# sourceMappingURL=vitus-labs-unistyle.native.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/unistyle",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -50,18 +50,12 @@
|
|
|
50
50
|
"node": ">= 18"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@vitus-labs/core": "^2.
|
|
54
|
-
"react": ">= 19"
|
|
55
|
-
"react-native": ">= 0.76"
|
|
56
|
-
},
|
|
57
|
-
"peerDependenciesMeta": {
|
|
58
|
-
"react-native": {
|
|
59
|
-
"optional": true
|
|
60
|
-
}
|
|
53
|
+
"@vitus-labs/core": "^2.7.0",
|
|
54
|
+
"react": ">= 19"
|
|
61
55
|
},
|
|
62
56
|
"devDependencies": {
|
|
63
57
|
"@vitus-labs/core": "workspace:*",
|
|
64
|
-
"@vitus-labs/tools-rolldown": "2.
|
|
65
|
-
"@vitus-labs/tools-typescript": "2.
|
|
58
|
+
"@vitus-labs/tools-rolldown": "2.5.0",
|
|
59
|
+
"@vitus-labs/tools-typescript": "2.5.0"
|
|
66
60
|
}
|
|
67
61
|
}
|