@pyreon/unistyle 0.3.0 → 0.11.1

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.
Files changed (3) hide show
  1. package/lib/index.d.ts +25 -7
  2. package/lib/index.js +37 -15
  3. package/package.json +14 -11
package/lib/index.d.ts CHANGED
@@ -1,14 +1,32 @@
1
1
  import { VNode } from "@pyreon/core";
2
2
  import { context } from "@pyreon/ui-core";
3
3
 
4
- //#region src/context.d.ts
5
- type Theme$2 = {
6
- rootSize: number;
4
+ //#region src/enrichTheme.d.ts
5
+ type PyreonTheme = {
6
+ rootSize?: number;
7
7
  breakpoints?: Record<string, number>;
8
- __PYREON__?: never;
9
- } & Partial<Record<string, unknown>>;
8
+ __PYREON__?: {
9
+ sortedBreakpoints: string[] | undefined;
10
+ media: Record<string, (...args: any[]) => any> | undefined;
11
+ };
12
+ } & Record<string, unknown>;
13
+ /**
14
+ * Enrich a theme with pre-computed responsive utilities.
15
+ * Adds sorted breakpoints and media-query tagged-template helpers
16
+ * to `theme.__PYREON__` for consumption by `makeItResponsive`.
17
+ *
18
+ * This is a pure function — safe to call outside of component context.
19
+ *
20
+ * @example
21
+ * const enriched = enrichTheme({ rootSize: 16, breakpoints: { xs: 0, sm: 576, md: 768 } })
22
+ * enriched.__PYREON__.sortedBreakpoints // ['xs', 'sm', 'md']
23
+ * enriched.__PYREON__.media.sm // tagged-template for @media (min-width: 36em)
24
+ */
25
+ declare function enrichTheme<T extends PyreonTheme>(theme: T): T & Required<Pick<PyreonTheme, "__PYREON__">>;
26
+ //#endregion
27
+ //#region src/context.d.ts
10
28
  type TProvider = {
11
- theme: Theme$2;
29
+ theme: PyreonTheme;
12
30
  children?: VNode | null;
13
31
  };
14
32
  /**
@@ -495,5 +513,5 @@ type CssUnits = "px" | "rem" | "%" | "em" | "ex" | "cm" | "mm" | "in" | "pt" | "
495
513
  type Values = (items: unknown[], rootSize?: number, outputUnit?: CssUnits) => string | number | null;
496
514
  declare const values: Values;
497
515
  //#endregion
498
- 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 };
516
+ 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 PyreonTheme, 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, enrichTheme, extendCss, makeItResponsive, normalizeTheme, sortBreakpoints, stripUnit, styles$1 as styles, transformTheme, value, values };
499
517
  //# sourceMappingURL=index2.d.ts.map
package/lib/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { provide } from "@pyreon/core";
2
+ import { ThemeContext } from "@pyreon/styler";
1
3
  import { Provider as Provider$1, config, context, isEmpty, set } from "@pyreon/ui-core";
2
4
 
3
5
  //#region src/responsive/breakpoints.ts
@@ -176,29 +178,49 @@ const sortBreakpoints = (breakpoints) => {
176
178
  };
177
179
 
178
180
  //#endregion
179
- //#region src/context.tsx
181
+ //#region src/enrichTheme.ts
180
182
  /**
181
- * Unistyle Provider wraps the core Provider and enriches the theme
182
- * with pre-computed sorted breakpoints and media-query tagged-template
183
- * helpers consumed by `makeItResponsive`.
183
+ * Enrich a theme with pre-computed responsive utilities.
184
+ * Adds sorted breakpoints and media-query tagged-template helpers
185
+ * to `theme.__PYREON__` for consumption by `makeItResponsive`.
186
+ *
187
+ * This is a pure function — safe to call outside of component context.
188
+ *
189
+ * @example
190
+ * const enriched = enrichTheme({ rootSize: 16, breakpoints: { xs: 0, sm: 576, md: 768 } })
191
+ * enriched.__PYREON__.sortedBreakpoints // ['xs', 'sm', 'md']
192
+ * enriched.__PYREON__.media.sm // tagged-template for @media (min-width: 36em)
184
193
  */
185
- function Provider(props) {
186
- const { theme, children } = props;
187
- const { breakpoints, rootSize } = theme;
194
+ function enrichTheme(theme) {
195
+ const { breakpoints, rootSize = 16 } = theme;
188
196
  const sortedBreakpoints = breakpoints && !isEmpty(breakpoints) ? sortBreakpoints(breakpoints) : void 0;
189
197
  const media = breakpoints && !isEmpty(breakpoints) ? createMediaQueries({
190
198
  breakpoints,
191
199
  css: config.css,
192
200
  rootSize
193
201
  }) : void 0;
202
+ return {
203
+ ...theme,
204
+ __PYREON__: {
205
+ sortedBreakpoints,
206
+ media
207
+ }
208
+ };
209
+ }
210
+
211
+ //#endregion
212
+ //#region src/context.tsx
213
+ /**
214
+ * Unistyle Provider — wraps the core Provider and enriches the theme
215
+ * with pre-computed sorted breakpoints and media-query tagged-template
216
+ * helpers consumed by `makeItResponsive`.
217
+ */
218
+ function Provider(props) {
219
+ const { theme, children } = props;
220
+ const enrichedTheme = enrichTheme(theme);
221
+ provide(ThemeContext, enrichedTheme);
194
222
  return Provider$1({
195
- theme: {
196
- ...theme,
197
- __PYREON__: {
198
- sortedBreakpoints,
199
- media
200
- }
201
- },
223
+ theme: enrichedTheme,
202
224
  children
203
225
  });
204
226
  }
@@ -1822,5 +1844,5 @@ const styles = ({ theme: t, css, rootSize }) => {
1822
1844
  };
1823
1845
 
1824
1846
  //#endregion
1825
- 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 };
1847
+ export { ALIGN_CONTENT_DIRECTION, ALIGN_CONTENT_MAP_X, ALIGN_CONTENT_MAP_Y, Provider, alignContent, breakpoints, context, createMediaQueries, enrichTheme, extendCss, makeItResponsive, normalizeTheme, sortBreakpoints, stripUnit, styles, transformTheme, value, values };
1826
1848
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,19 +1,21 @@
1
1
  {
2
2
  "name": "@pyreon/unistyle",
3
- "version": "0.3.0",
3
+ "version": "0.11.1",
4
4
  "repository": {
5
5
  "type": "git",
6
- "url": "https://github.com/pyreon/ui-system",
7
- "directory": "packages/unistyle"
6
+ "url": "https://github.com/pyreon/pyreon",
7
+ "directory": "packages/ui-system/unistyle"
8
8
  },
9
9
  "description": "Responsive theming and breakpoint utilities for Pyreon",
10
10
  "license": "MIT",
11
11
  "type": "module",
12
12
  "sideEffects": false,
13
13
  "exports": {
14
- "source": "./src/index.ts",
15
- "import": "./lib/index.js",
16
- "types": "./lib/index.d.ts"
14
+ ".": {
15
+ "bun": "./src/index.ts",
16
+ "import": "./lib/index.js",
17
+ "types": "./lib/index.d.ts"
18
+ }
17
19
  },
18
20
  "types": "./lib/index.d.ts",
19
21
  "main": "./lib/index.js",
@@ -25,7 +27,7 @@
25
27
  "LICENSE"
26
28
  ],
27
29
  "engines": {
28
- "node": ">= 18"
30
+ "node": ">= 22"
29
31
  },
30
32
  "publishConfig": {
31
33
  "access": "public"
@@ -41,12 +43,13 @@
41
43
  "typecheck": "tsc --noEmit"
42
44
  },
43
45
  "peerDependencies": {
44
- "@pyreon/core": ">=0.4.0 <1.0.0",
45
- "@pyreon/reactivity": ">=0.4.0 <1.0.0",
46
- "@pyreon/ui-core": ">=0.3.0"
46
+ "@pyreon/core": "^0.11.1",
47
+ "@pyreon/reactivity": "^0.11.1",
48
+ "@pyreon/ui-core": "^0.11.1",
49
+ "@pyreon/styler": "^0.11.1"
47
50
  },
48
51
  "devDependencies": {
49
52
  "@vitus-labs/tools-rolldown": "^1.15.3",
50
- "@pyreon/typescript": "^0.7.4"
53
+ "@pyreon/typescript": "^0.11.1"
51
54
  }
52
55
  }