@vitus-labs/unistyle 2.6.2 → 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 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** — 100+ CSS properties processed from a theme object
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,
@@ -1579,6 +1602,11 @@ const propertyMap = [
1579
1602
  css: "border-spacing",
1580
1603
  key: "borderSpacing"
1581
1604
  },
1605
+ {
1606
+ kind: "simple",
1607
+ css: "border-collapse",
1608
+ key: "borderCollapse"
1609
+ },
1582
1610
  {
1583
1611
  kind: "simple",
1584
1612
  css: "border-inline",
@@ -2079,13 +2107,40 @@ const propertyMap = [
2079
2107
 
2080
2108
  //#endregion
2081
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();
2082
2127
  /**
2083
2128
  * Data-driven style processor. Iterates the `propertyMap` descriptors
2084
2129
  * and delegates each to `processDescriptor`, which maps theme values
2085
2130
  * to CSS strings. The result is a single `css` tagged-template literal
2086
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.
2087
2135
  */
2088
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
+ }
2089
2144
  const calc = (...params) => values(params, rootSize);
2090
2145
  const shorthand = edge(rootSize);
2091
2146
  const borderRadiusFn = borderRadius(rootSize);
@@ -2095,5 +2150,5 @@ const styles = ({ theme: t, css, rootSize }) => {
2095
2150
  };
2096
2151
 
2097
2152
  //#endregion
2098
- 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 };
2099
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,
@@ -1565,6 +1588,11 @@ const propertyMap = [
1565
1588
  css: "border-spacing",
1566
1589
  key: "borderSpacing"
1567
1590
  },
1591
+ {
1592
+ kind: "simple",
1593
+ css: "border-collapse",
1594
+ key: "borderCollapse"
1595
+ },
1568
1596
  {
1569
1597
  kind: "simple",
1570
1598
  css: "border-inline",
@@ -2065,13 +2093,40 @@ const propertyMap = [
2065
2093
 
2066
2094
  //#endregion
2067
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();
2068
2113
  /**
2069
2114
  * Data-driven style processor. Iterates the `propertyMap` descriptors
2070
2115
  * and delegates each to `processDescriptor`, which maps theme values
2071
2116
  * to CSS strings. The result is a single `css` tagged-template literal
2072
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.
2073
2121
  */
2074
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
+ }
2075
2130
  const calc = (...params) => values(params, rootSize);
2076
2131
  const shorthand = edge(rootSize);
2077
2132
  const borderRadiusFn = borderRadius(rootSize);
@@ -2081,5 +2136,5 @@ const styles = ({ theme: t, css, rootSize }) => {
2081
2136
  };
2082
2137
 
2083
2138
  //#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 };
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 };
2085
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.6.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.6.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.3.1",
65
- "@vitus-labs/tools-typescript": "2.3.1"
58
+ "@vitus-labs/tools-rolldown": "2.5.0",
59
+ "@vitus-labs/tools-typescript": "2.5.0"
66
60
  }
67
61
  }