@pyreon/unistyle 0.3.0 → 0.11.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/lib/index.d.ts +25 -7
- package/lib/index.js +37 -15
- package/package.json +9 -7
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/
|
|
5
|
-
type
|
|
6
|
-
rootSize
|
|
4
|
+
//#region src/enrichTheme.d.ts
|
|
5
|
+
type PyreonTheme = {
|
|
6
|
+
rootSize?: number;
|
|
7
7
|
breakpoints?: Record<string, number>;
|
|
8
|
-
__PYREON__?:
|
|
9
|
-
|
|
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:
|
|
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/
|
|
181
|
+
//#region src/enrichTheme.ts
|
|
180
182
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
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
|
|
186
|
-
const {
|
|
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,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/unistyle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/pyreon/ui-system",
|
|
7
|
-
"directory": "packages/unistyle"
|
|
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
|
+
"bun": "./src/index.ts",
|
|
14
15
|
"source": "./src/index.ts",
|
|
15
16
|
"import": "./lib/index.js",
|
|
16
17
|
"types": "./lib/index.d.ts"
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
"LICENSE"
|
|
26
27
|
],
|
|
27
28
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
29
|
+
"node": ">= 22"
|
|
29
30
|
},
|
|
30
31
|
"publishConfig": {
|
|
31
32
|
"access": "public"
|
|
@@ -41,12 +42,13 @@
|
|
|
41
42
|
"typecheck": "tsc --noEmit"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"@pyreon/core": "
|
|
45
|
-
"@pyreon/reactivity": "
|
|
46
|
-
"@pyreon/ui-core": "
|
|
45
|
+
"@pyreon/core": "^0.11.0",
|
|
46
|
+
"@pyreon/reactivity": "^0.11.0",
|
|
47
|
+
"@pyreon/ui-core": "^0.11.0",
|
|
48
|
+
"@pyreon/styler": "^0.11.0"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"@vitus-labs/tools-rolldown": "^1.15.3",
|
|
50
|
-
"@pyreon/typescript": "^0.
|
|
52
|
+
"@pyreon/typescript": "^0.11.0"
|
|
51
53
|
}
|
|
52
54
|
}
|