umber-style 0.0.0 → 0.1.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 soroush.tech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1 +1,11 @@
1
- Placeholder. See https://github.com/soroush-tech/umber-style
1
+ # umber-style
2
+
3
+ The UmberStyle umbrella: it only re-exports the engine and the bindings as `umber-style`, `umber-style/react`, `umber-style/react-native` and `umber-style/vue`.
4
+
5
+ Install: `pnpm add umber-style`.
6
+
7
+ ```ts
8
+ import { styled, ThemeProvider } from 'umber-style/react'
9
+ ```
10
+
11
+ Documentation: [docs](../../docs/README.md). `umber-style/react` is the entry for code shared by the web and React Native: see [style sheets and the style prop](../../docs/style-sheets.md).
package/dist/index.cjs ADDED
@@ -0,0 +1,9 @@
1
+ var _umber_style_core = require("@umber-style/core");
2
+ Object.keys(_umber_style_core).forEach(function(k) {
3
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
4
+ enumerable: true,
5
+ get: function() {
6
+ return _umber_style_core[k];
7
+ }
8
+ });
9
+ });
@@ -0,0 +1 @@
1
+ export * from "@umber-style/core";
@@ -0,0 +1 @@
1
+ export * from "@umber-style/core";
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export * from "@umber-style/core";
2
+ export {};
@@ -0,0 +1,9 @@
1
+ var _umber_style_react_native = require("@umber-style/react-native");
2
+ Object.keys(_umber_style_react_native).forEach(function(k) {
3
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
4
+ enumerable: true,
5
+ get: function() {
6
+ return _umber_style_react_native[k];
7
+ }
8
+ });
9
+ });
@@ -0,0 +1 @@
1
+ export * from "@umber-style/react-native";
@@ -0,0 +1 @@
1
+ export * from "@umber-style/react-native";
@@ -0,0 +1,2 @@
1
+ export * from "@umber-style/react-native";
2
+ export {};
package/dist/react.cjs ADDED
@@ -0,0 +1,9 @@
1
+ var _umber_style_react = require("@umber-style/react");
2
+ Object.keys(_umber_style_react).forEach(function(k) {
3
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
4
+ enumerable: true,
5
+ get: function() {
6
+ return _umber_style_react[k];
7
+ }
8
+ });
9
+ });
@@ -0,0 +1 @@
1
+ export * from "@umber-style/react";
@@ -0,0 +1 @@
1
+ export * from "@umber-style/react";
package/dist/react.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export * from "@umber-style/react";
2
+ export {};
@@ -0,0 +1,9 @@
1
+ var _umber_style_react = require("@umber-style/react");
2
+ Object.keys(_umber_style_react).forEach(function(k) {
3
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
4
+ enumerable: true,
5
+ get: function() {
6
+ return _umber_style_react[k];
7
+ }
8
+ });
9
+ });
@@ -0,0 +1 @@
1
+ export * from "@umber-style/react";
@@ -0,0 +1 @@
1
+ export * from "@umber-style/react";
@@ -0,0 +1,2 @@
1
+ export * from "@umber-style/react";
2
+ export {};
File without changes
@@ -0,0 +1,14 @@
1
+ import { Theme as Theme$1 } from "@umber-style/core";
2
+ import { DefaultStyleOptions as DefaultStyleOptions$1, StyleOptions as StyleOptions$1 } from "@umber-style/react";
3
+ import { A as ThemeKey, B as configure, C as SharedStyledComponent, D as StyleSheet, E as StyleOptions, F as WebStyleObject, G as subtract, H as multiply, I as add, J as when, K as themeClass, L as alpha, M as ThemeProviderProps, N as WebNested, O as StyledOptions, P as WebProperties, R as apply, S as SharedStyled, T as StyleObject, U as negate, V as divide, W as styled, Y as whenScheme, _ as SharedStyleInput, a as SchemeName, b as SharedStyleResult, c as SharedEntry, d as SharedProperties, f as SharedSheetDefinition, g as SharedStyleFunction, h as SharedStyleBase, i as SchemeKey, j as ThemeProvider, k as Theme, l as SharedObjectSheet, m as SharedSheetStyles, n as DefaultStyleOptions, o as SharedApplied, p as SharedSheetInput, q as useStyle, r as NestedKey, s as SharedApply, t as AlphaColor, u as SharedPercent, v as SharedStyleObject, w as SheetEntry, x as SharedStyleSheet, y as SharedStyleProp, z as at } from "./sharedCommon-HC6xV0Ue.cjs";
4
+ /** The styling of one theme shape, with the names that both platforms have. */
5
+ export interface SharedStyle<T> extends SharedStyleBase<T> {
6
+ /** The real theme values, in a component. */
7
+ useTheme(): T;
8
+ }
9
+ export declare const useTheme: SharedStyle<Theme$1>['useTheme'];
10
+ export declare function createStyle<T extends object>(theme: T, options?: StyleOptions$1<T>): SharedStyle<T>;
11
+ export declare function createDefaultStyle(): SharedStyle<Theme$1> & {
12
+ configure: (options: DefaultStyleOptions$1) => void;
13
+ };
14
+ export { type AlphaColor, type DefaultStyleOptions, type NestedKey, type SchemeKey, type SchemeName, SharedApplied, SharedApply, SharedEntry, SharedObjectSheet, SharedPercent, SharedProperties, SharedSheetDefinition, SharedSheetInput, SharedSheetStyles, SharedStyleBase, SharedStyleFunction, SharedStyleInput, SharedStyleObject, SharedStyleProp, SharedStyleResult, SharedStyleSheet, SharedStyled, SharedStyledComponent, type SheetEntry, type StyleObject, type StyleOptions, StyleSheet, type StyledOptions, type Theme, type ThemeKey, ThemeProvider, type ThemeProviderProps, type WebNested, type WebProperties, type WebStyleObject, add, alpha, apply, at, configure, divide, multiply, negate, styled, subtract, themeClass, useStyle, when, whenScheme };
@@ -0,0 +1,14 @@
1
+ import { Theme as Theme$1 } from "@umber-style/core";
2
+ import { DefaultStyleOptions as DefaultStyleOptions$1, StyleOptions as StyleOptions$1 } from "@umber-style/react";
3
+ import { A as ThemeKey, B as configure, C as SharedStyledComponent, D as StyleSheet, E as StyleOptions, F as WebStyleObject, G as subtract, H as multiply, I as add, J as when, K as themeClass, L as alpha, M as ThemeProviderProps, N as WebNested, O as StyledOptions, P as WebProperties, R as apply, S as SharedStyled, T as StyleObject, U as negate, V as divide, W as styled, Y as whenScheme, _ as SharedStyleInput, a as SchemeName, b as SharedStyleResult, c as SharedEntry, d as SharedProperties, f as SharedSheetDefinition, g as SharedStyleFunction, h as SharedStyleBase, i as SchemeKey, j as ThemeProvider, k as Theme, l as SharedObjectSheet, m as SharedSheetStyles, n as DefaultStyleOptions, o as SharedApplied, p as SharedSheetInput, q as useStyle, r as NestedKey, s as SharedApply, t as AlphaColor, u as SharedPercent, v as SharedStyleObject, w as SheetEntry, x as SharedStyleSheet, y as SharedStyleProp, z as at } from "./sharedCommon-tz8e029q.mjs";
4
+ /** The styling of one theme shape, with the names that both platforms have. */
5
+ export interface SharedStyle<T> extends SharedStyleBase<T> {
6
+ /** The real theme values, in a component. */
7
+ useTheme(): T;
8
+ }
9
+ export declare const useTheme: SharedStyle<Theme$1>['useTheme'];
10
+ export declare function createStyle<T extends object>(theme: T, options?: StyleOptions$1<T>): SharedStyle<T>;
11
+ export declare function createDefaultStyle(): SharedStyle<Theme$1> & {
12
+ configure: (options: DefaultStyleOptions$1) => void;
13
+ };
14
+ export { type AlphaColor, type DefaultStyleOptions, type NestedKey, type SchemeKey, type SchemeName, SharedApplied, SharedApply, SharedEntry, SharedObjectSheet, SharedPercent, SharedProperties, SharedSheetDefinition, SharedSheetInput, SharedSheetStyles, SharedStyleBase, SharedStyleFunction, SharedStyleInput, SharedStyleObject, SharedStyleProp, SharedStyleResult, SharedStyleSheet, SharedStyled, SharedStyledComponent, type SheetEntry, type StyleObject, type StyleOptions, StyleSheet, type StyledOptions, type Theme, type ThemeKey, ThemeProvider, type ThemeProviderProps, type WebNested, type WebProperties, type WebStyleObject, add, alpha, apply, at, configure, divide, multiply, negate, styled, subtract, themeClass, useStyle, when, whenScheme };
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1,14 @@
1
+ import { Theme as Theme$1 } from "@umber-style/core";
2
+ import { DefaultStyleOptions as DefaultStyleOptions$1, StyleOptions as StyleOptions$1 } from "@umber-style/react";
3
+ import { A as ThemeKey, B as configure, C as SharedStyledComponent, D as StyleSheet, E as StyleOptions, F as WebStyleObject, G as subtract, H as multiply, I as add, J as when, K as themeClass, L as alpha, M as ThemeProviderProps, N as WebNested, O as StyledOptions, P as WebProperties, R as apply, S as SharedStyled, T as StyleObject, U as negate, V as divide, W as styled, Y as whenScheme, _ as SharedStyleInput, a as SchemeName, b as SharedStyleResult, c as SharedEntry, d as SharedProperties, f as SharedSheetDefinition, g as SharedStyleFunction, h as SharedStyleBase, i as SchemeKey, j as ThemeProvider, k as Theme, l as SharedObjectSheet, m as SharedSheetStyles, n as DefaultStyleOptions, o as SharedApplied, p as SharedSheetInput, q as useStyle, r as NestedKey, s as SharedApply, t as AlphaColor, u as SharedPercent, v as SharedStyleObject, w as SheetEntry, x as SharedStyleSheet, y as SharedStyleProp, z as at } from "./sharedCommon-HC6xV0Ue.cjs";
4
+ /** The styling of one theme shape for server components: the root theme is read with `readTheme`, not a hook. */
5
+ export interface SharedServerStyle<T> extends SharedStyleBase<T> {
6
+ /** The root theme of the request, or the base theme of the engine; throws when there is neither. */
7
+ readTheme(): T;
8
+ }
9
+ export declare const readTheme: SharedServerStyle<Theme$1>['readTheme'];
10
+ export declare function createStyle<T extends object>(theme: T, options?: StyleOptions$1<T>): SharedServerStyle<T>;
11
+ export declare function createDefaultStyle(): SharedServerStyle<Theme$1> & {
12
+ configure: (options: DefaultStyleOptions$1) => void;
13
+ };
14
+ export { type AlphaColor, type DefaultStyleOptions, type NestedKey, type SchemeKey, type SchemeName, SharedApplied, SharedApply, SharedEntry, SharedObjectSheet, SharedPercent, SharedProperties, SharedSheetDefinition, SharedSheetInput, SharedSheetStyles, SharedStyleBase, SharedStyleFunction, SharedStyleInput, SharedStyleObject, SharedStyleProp, SharedStyleResult, SharedStyleSheet, SharedStyled, SharedStyledComponent, type SheetEntry, type StyleObject, type StyleOptions, StyleSheet, type StyledOptions, type Theme, type ThemeKey, ThemeProvider, type ThemeProviderProps, type WebNested, type WebProperties, type WebStyleObject, add, alpha, apply, at, configure, divide, multiply, negate, styled, subtract, themeClass, useStyle, when, whenScheme };
@@ -0,0 +1,14 @@
1
+ import { Theme as Theme$1 } from "@umber-style/core";
2
+ import { DefaultStyleOptions as DefaultStyleOptions$1, StyleOptions as StyleOptions$1 } from "@umber-style/react";
3
+ import { A as ThemeKey, B as configure, C as SharedStyledComponent, D as StyleSheet, E as StyleOptions, F as WebStyleObject, G as subtract, H as multiply, I as add, J as when, K as themeClass, L as alpha, M as ThemeProviderProps, N as WebNested, O as StyledOptions, P as WebProperties, R as apply, S as SharedStyled, T as StyleObject, U as negate, V as divide, W as styled, Y as whenScheme, _ as SharedStyleInput, a as SchemeName, b as SharedStyleResult, c as SharedEntry, d as SharedProperties, f as SharedSheetDefinition, g as SharedStyleFunction, h as SharedStyleBase, i as SchemeKey, j as ThemeProvider, k as Theme, l as SharedObjectSheet, m as SharedSheetStyles, n as DefaultStyleOptions, o as SharedApplied, p as SharedSheetInput, q as useStyle, r as NestedKey, s as SharedApply, t as AlphaColor, u as SharedPercent, v as SharedStyleObject, w as SheetEntry, x as SharedStyleSheet, y as SharedStyleProp, z as at } from "./sharedCommon-tz8e029q.mjs";
4
+ /** The styling of one theme shape for server components: the root theme is read with `readTheme`, not a hook. */
5
+ export interface SharedServerStyle<T> extends SharedStyleBase<T> {
6
+ /** The root theme of the request, or the base theme of the engine; throws when there is neither. */
7
+ readTheme(): T;
8
+ }
9
+ export declare const readTheme: SharedServerStyle<Theme$1>['readTheme'];
10
+ export declare function createStyle<T extends object>(theme: T, options?: StyleOptions$1<T>): SharedServerStyle<T>;
11
+ export declare function createDefaultStyle(): SharedServerStyle<Theme$1> & {
12
+ configure: (options: DefaultStyleOptions$1) => void;
13
+ };
14
+ export { type AlphaColor, type DefaultStyleOptions, type NestedKey, type SchemeKey, type SchemeName, SharedApplied, SharedApply, SharedEntry, SharedObjectSheet, SharedPercent, SharedProperties, SharedSheetDefinition, SharedSheetInput, SharedSheetStyles, SharedStyleBase, SharedStyleFunction, SharedStyleInput, SharedStyleObject, SharedStyleProp, SharedStyleResult, SharedStyleSheet, SharedStyled, SharedStyledComponent, type SheetEntry, type StyleObject, type StyleOptions, StyleSheet, type StyledOptions, type Theme, type ThemeKey, ThemeProvider, type ThemeProviderProps, type WebNested, type WebProperties, type WebStyleObject, add, alpha, apply, at, configure, divide, multiply, negate, styled, subtract, themeClass, useStyle, when, whenScheme };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,112 @@
1
+ import { ComponentProps, ElementType, FunctionComponent, ReactElement } from "react";
2
+ import { DefaultStyleOptions, StyleOptions, StyledOptions, ThemeProviderProps } from "@umber-style/react";
3
+ import { AlphaColor, ColorScheme, DeepPartial, NestedKey, SchemeKey, SchemeName, SheetEntry, StyleObject, Theme, ThemeKey, WebNested, WebProperties, WebStyleObject } from "@umber-style/core";
4
+ import { NativeStyleObject } from "@umber-style/react-native";
5
+ /** The keys that the web style and the native style both have. */
6
+ type SharedKeys = keyof WebProperties & keyof NativeStyleObject;
7
+ /**
8
+ * The part of a style that both platforms understand: the keys that are in both types, each with the
9
+ * values that are valid in both (a number, a percentage and `auto` are; `grid` and `10px` are not).
10
+ */
11
+ type SharedProperties = { [K in SharedKeys]?: WebProperties[K] & NativeStyleObject[K]; };
12
+ /**
13
+ * A style for web and mobile: the keys valid on both, plus two parts for one platform each. On the web
14
+ * `web` is merged over the rest and `native` is dropped; on React Native it is the other way round.
15
+ */
16
+ type SharedStyleObject = SharedProperties & {
17
+ /** Only on the web: nested selectors, at-rules, any CSS property. */
18
+ web?: WebStyleObject | null | false;
19
+ /** Only on React Native: any key of the platform's styles. */
20
+ native?: NativeStyleObject | null | false;
21
+ };
22
+ /** What a shared style function may return. */
23
+ type SharedStyleResult = SharedStyleObject | null | undefined | false;
24
+ /** A shared style that is computed from the props and the theme. */
25
+ type SharedStyleFunction<T, P> = (props: P & {
26
+ theme: T;
27
+ }) => SharedStyleResult;
28
+ /** A shared style object, or a function of the props and the theme; the defaults accept any function. */
29
+ type SharedStyleInput<T = never, P = never> = SharedStyleObject | SharedStyleFunction<T, P>;
30
+ /** A set of named shared styles. */
31
+ type SharedSheetStyles = Record<string, SharedStyleObject>;
32
+ /** What a shared sheet is made from: one style for each name, or a function of the theme that returns them. */
33
+ type SharedSheetInput<K extends string, T> = Record<K, SharedStyleObject> | ((theme: T) => Record<K, SharedStyleObject>);
34
+ /** A shared sheet given as an object: one style for each name, with a function left out (the compiler tries the object form first). */
35
+ type SharedObjectSheet<K extends string> = Record<K, SharedStyleObject> & {
36
+ call?: never;
37
+ };
38
+ /** An entry of a sheet: a class name on the web, a style object on React Native. Pass it on; do not read it. */
39
+ type SharedEntry = SheetEntry | NativeStyleObject;
40
+ /** What the `style` prop of a shared styled component takes. */
41
+ type SharedStyleProp = SharedEntry | SharedStyleObject | false | null | undefined | readonly SharedStyleProp[];
42
+ type SharedStyledComponent<C extends ElementType, P extends object> = FunctionComponent<Omit<ComponentProps<C>, keyof P | 'as' | 'style'> & P & {
43
+ as?: ElementType;
44
+ style?: SharedStyleProp;
45
+ }>;
46
+ type SharedStyled<T> = <C extends ElementType>(tag: C, options?: StyledOptions) => <P extends object = object>(...styles: SharedStyleInput<T, P>[]) => SharedStyledComponent<C, P>;
47
+ /** A set of named styles; it only carries the types. */
48
+ interface SharedSheetDefinition<S extends SharedSheetStyles> {
49
+ readonly entries?: { [K in keyof S]: SharedEntry; };
50
+ }
51
+ interface SharedStyleSheet<T> {
52
+ /** A sheet given as an object is its entries, usable at once, with no hook and no theme. */
53
+ create<K extends string>(styles: SharedObjectSheet<K>): { readonly [P in K]: SharedEntry; };
54
+ /** A sheet given as a function of the theme is for `useStyle`, which resolves it against the theme. */
55
+ create<K extends string>(styles: (theme: T) => Record<K, SharedStyleObject>): SharedSheetDefinition<Record<K, SharedStyleObject>>;
56
+ }
57
+ /** The props that apply entries to a styled component: a class name on the web, a style array on React Native. */
58
+ interface SharedApplied {
59
+ className?: string;
60
+ style?: readonly SharedEntry[];
61
+ }
62
+ type SharedApply = (...entries: (SharedEntry | string | null | undefined | false)[]) => SharedApplied;
63
+ /** The styling of one theme shape without its theme hook: the names that both platforms have. */
64
+ interface SharedStyleBase<T> {
65
+ styled: SharedStyled<T>;
66
+ StyleSheet: SharedStyleSheet<T>;
67
+ /** The entries of a sheet; an object sheet is its own entries and is returned as it is. */
68
+ useStyle<K extends string>(sheet: { readonly [P in K]: SharedEntry; }): { readonly [P in K]: SharedEntry; };
69
+ useStyle<S extends SharedSheetStyles>(sheet: SharedSheetDefinition<S>): { [K in keyof S]: SharedEntry; };
70
+ apply: SharedApply;
71
+ ThemeProvider(props: ThemeProviderProps<T>): ReactElement;
72
+ themeClass(theme: DeepPartial<T>, colorScheme?: ColorScheme): string;
73
+ /** A style key for "the nearest theme is this theme", at the top of a style or inside `web` or `native`. On the web it needs `@scope`; on React Native it matches the theme object of the nearest provider. */
74
+ when(theme: DeepPartial<T>, colorScheme?: ColorScheme): ThemeKey;
75
+ /** A style key for "the nearest color scheme is this one": the nearest theme given that `colorScheme`, else the system preference. */
76
+ whenScheme(scheme: SchemeName): SchemeKey;
77
+ }
78
+ declare const configure: (options: DefaultStyleOptions) => void;
79
+ declare const styled: SharedStyled<Theme>;
80
+ declare const StyleSheet: SharedStyleSheet<Theme>;
81
+ declare const useStyle: SharedStyleBase<Theme>['useStyle'];
82
+ declare const ThemeProvider: SharedStyleBase<Theme>['ThemeProvider'];
83
+ declare const apply: SharedApply;
84
+ declare const themeClass: SharedStyleBase<Theme>['themeClass'];
85
+ declare const when: SharedStyleBase<Theme>['when'];
86
+ declare const whenScheme: SharedStyleBase<Theme>['whenScheme'];
87
+ /** `color` at `opacity` (0 to 1): a CSS mix on the web, rgba() on React Native. */
88
+ declare const alpha: (color: string, opacity: number) => string;
89
+ /** `{ [key]: style }` typed so that it spreads into a web style, for a key that is computed: `web: { ...at(`@media (width >= ${bp})`, { gap: 16 }) }`. */
90
+ declare function at<K extends NestedKey>(key: K, style: WebNested): Record<K, WebNested>;
91
+ /** A percentage: `'50%'`. */
92
+ type SharedPercent = `${number}%`;
93
+ /**
94
+ * `value` times `factor`. A token is typed as the number it is on React Native; on the web it is a
95
+ * `var(--x)` reference and the result is a CSS `calc()` that the browser computes. Percentages are the one
96
+ * string that both platforms compute.
97
+ */
98
+ declare function multiply(value: number, factor: number): number;
99
+ declare function multiply(value: SharedPercent, factor: number): number | SharedPercent;
100
+ /** `value` divided by `divisor`; a `divisor` of 0 throws a `RangeError`. */
101
+ declare function divide(value: number, divisor: number): number;
102
+ declare function divide(value: SharedPercent, divisor: number): number | SharedPercent;
103
+ /** The sum of `values`: all numbers, or all percentages. */
104
+ declare function add(...values: number[]): number;
105
+ declare function add(...values: SharedPercent[]): number | SharedPercent;
106
+ /** `value` minus each of `values`: all numbers, or all percentages. */
107
+ declare function subtract(value: number, ...values: number[]): number;
108
+ declare function subtract(value: SharedPercent, ...values: SharedPercent[]): number | SharedPercent;
109
+ /** `value` times -1: a negative margin from a token. */
110
+ declare function negate(value: number): number;
111
+ declare function negate(value: SharedPercent): number | SharedPercent;
112
+ export { ThemeKey as A, configure as B, SharedStyledComponent as C, StyleSheet as D, StyleOptions as E, WebStyleObject as F, subtract as G, multiply as H, add as I, when as J, themeClass as K, alpha as L, ThemeProviderProps as M, WebNested as N, StyledOptions as O, WebProperties as P, apply as R, SharedStyled as S, StyleObject as T, negate as U, divide as V, styled as W, whenScheme as Y, SharedStyleInput as _, SchemeName as a, SharedStyleResult as b, SharedEntry as c, SharedProperties as d, SharedSheetDefinition as f, SharedStyleFunction as g, SharedStyleBase as h, SchemeKey as i, ThemeProvider as j, Theme as k, SharedObjectSheet as l, SharedSheetStyles as m, DefaultStyleOptions as n, SharedApplied as o, SharedSheetInput as p, useStyle as q, NestedKey as r, SharedApply as s, AlphaColor as t, SharedPercent as u, SharedStyleObject as v, SheetEntry as w, SharedStyleSheet as x, SharedStyleProp as y, at as z };
@@ -0,0 +1,112 @@
1
+ import { ComponentProps, ElementType, FunctionComponent, ReactElement } from "react";
2
+ import { AlphaColor, ColorScheme, DeepPartial, NestedKey, SchemeKey, SchemeName, SheetEntry, StyleObject, Theme, ThemeKey, WebNested, WebProperties, WebStyleObject } from "@umber-style/core";
3
+ import { DefaultStyleOptions, StyleOptions, StyledOptions, ThemeProviderProps } from "@umber-style/react";
4
+ import { NativeStyleObject } from "@umber-style/react-native";
5
+ /** The keys that the web style and the native style both have. */
6
+ type SharedKeys = keyof WebProperties & keyof NativeStyleObject;
7
+ /**
8
+ * The part of a style that both platforms understand: the keys that are in both types, each with the
9
+ * values that are valid in both (a number, a percentage and `auto` are; `grid` and `10px` are not).
10
+ */
11
+ type SharedProperties = { [K in SharedKeys]?: WebProperties[K] & NativeStyleObject[K]; };
12
+ /**
13
+ * A style for web and mobile: the keys valid on both, plus two parts for one platform each. On the web
14
+ * `web` is merged over the rest and `native` is dropped; on React Native it is the other way round.
15
+ */
16
+ type SharedStyleObject = SharedProperties & {
17
+ /** Only on the web: nested selectors, at-rules, any CSS property. */
18
+ web?: WebStyleObject | null | false;
19
+ /** Only on React Native: any key of the platform's styles. */
20
+ native?: NativeStyleObject | null | false;
21
+ };
22
+ /** What a shared style function may return. */
23
+ type SharedStyleResult = SharedStyleObject | null | undefined | false;
24
+ /** A shared style that is computed from the props and the theme. */
25
+ type SharedStyleFunction<T, P> = (props: P & {
26
+ theme: T;
27
+ }) => SharedStyleResult;
28
+ /** A shared style object, or a function of the props and the theme; the defaults accept any function. */
29
+ type SharedStyleInput<T = never, P = never> = SharedStyleObject | SharedStyleFunction<T, P>;
30
+ /** A set of named shared styles. */
31
+ type SharedSheetStyles = Record<string, SharedStyleObject>;
32
+ /** What a shared sheet is made from: one style for each name, or a function of the theme that returns them. */
33
+ type SharedSheetInput<K extends string, T> = Record<K, SharedStyleObject> | ((theme: T) => Record<K, SharedStyleObject>);
34
+ /** A shared sheet given as an object: one style for each name, with a function left out (the compiler tries the object form first). */
35
+ type SharedObjectSheet<K extends string> = Record<K, SharedStyleObject> & {
36
+ call?: never;
37
+ };
38
+ /** An entry of a sheet: a class name on the web, a style object on React Native. Pass it on; do not read it. */
39
+ type SharedEntry = SheetEntry | NativeStyleObject;
40
+ /** What the `style` prop of a shared styled component takes. */
41
+ type SharedStyleProp = SharedEntry | SharedStyleObject | false | null | undefined | readonly SharedStyleProp[];
42
+ type SharedStyledComponent<C extends ElementType, P extends object> = FunctionComponent<Omit<ComponentProps<C>, keyof P | 'as' | 'style'> & P & {
43
+ as?: ElementType;
44
+ style?: SharedStyleProp;
45
+ }>;
46
+ type SharedStyled<T> = <C extends ElementType>(tag: C, options?: StyledOptions) => <P extends object = object>(...styles: SharedStyleInput<T, P>[]) => SharedStyledComponent<C, P>;
47
+ /** A set of named styles; it only carries the types. */
48
+ interface SharedSheetDefinition<S extends SharedSheetStyles> {
49
+ readonly entries?: { [K in keyof S]: SharedEntry; };
50
+ }
51
+ interface SharedStyleSheet<T> {
52
+ /** A sheet given as an object is its entries, usable at once, with no hook and no theme. */
53
+ create<K extends string>(styles: SharedObjectSheet<K>): { readonly [P in K]: SharedEntry; };
54
+ /** A sheet given as a function of the theme is for `useStyle`, which resolves it against the theme. */
55
+ create<K extends string>(styles: (theme: T) => Record<K, SharedStyleObject>): SharedSheetDefinition<Record<K, SharedStyleObject>>;
56
+ }
57
+ /** The props that apply entries to a styled component: a class name on the web, a style array on React Native. */
58
+ interface SharedApplied {
59
+ className?: string;
60
+ style?: readonly SharedEntry[];
61
+ }
62
+ type SharedApply = (...entries: (SharedEntry | string | null | undefined | false)[]) => SharedApplied;
63
+ /** The styling of one theme shape without its theme hook: the names that both platforms have. */
64
+ interface SharedStyleBase<T> {
65
+ styled: SharedStyled<T>;
66
+ StyleSheet: SharedStyleSheet<T>;
67
+ /** The entries of a sheet; an object sheet is its own entries and is returned as it is. */
68
+ useStyle<K extends string>(sheet: { readonly [P in K]: SharedEntry; }): { readonly [P in K]: SharedEntry; };
69
+ useStyle<S extends SharedSheetStyles>(sheet: SharedSheetDefinition<S>): { [K in keyof S]: SharedEntry; };
70
+ apply: SharedApply;
71
+ ThemeProvider(props: ThemeProviderProps<T>): ReactElement;
72
+ themeClass(theme: DeepPartial<T>, colorScheme?: ColorScheme): string;
73
+ /** A style key for "the nearest theme is this theme", at the top of a style or inside `web` or `native`. On the web it needs `@scope`; on React Native it matches the theme object of the nearest provider. */
74
+ when(theme: DeepPartial<T>, colorScheme?: ColorScheme): ThemeKey;
75
+ /** A style key for "the nearest color scheme is this one": the nearest theme given that `colorScheme`, else the system preference. */
76
+ whenScheme(scheme: SchemeName): SchemeKey;
77
+ }
78
+ declare const configure: (options: DefaultStyleOptions) => void;
79
+ declare const styled: SharedStyled<Theme>;
80
+ declare const StyleSheet: SharedStyleSheet<Theme>;
81
+ declare const useStyle: SharedStyleBase<Theme>['useStyle'];
82
+ declare const ThemeProvider: SharedStyleBase<Theme>['ThemeProvider'];
83
+ declare const apply: SharedApply;
84
+ declare const themeClass: SharedStyleBase<Theme>['themeClass'];
85
+ declare const when: SharedStyleBase<Theme>['when'];
86
+ declare const whenScheme: SharedStyleBase<Theme>['whenScheme'];
87
+ /** `color` at `opacity` (0 to 1): a CSS mix on the web, rgba() on React Native. */
88
+ declare const alpha: (color: string, opacity: number) => string;
89
+ /** `{ [key]: style }` typed so that it spreads into a web style, for a key that is computed: `web: { ...at(`@media (width >= ${bp})`, { gap: 16 }) }`. */
90
+ declare function at<K extends NestedKey>(key: K, style: WebNested): Record<K, WebNested>;
91
+ /** A percentage: `'50%'`. */
92
+ type SharedPercent = `${number}%`;
93
+ /**
94
+ * `value` times `factor`. A token is typed as the number it is on React Native; on the web it is a
95
+ * `var(--x)` reference and the result is a CSS `calc()` that the browser computes. Percentages are the one
96
+ * string that both platforms compute.
97
+ */
98
+ declare function multiply(value: number, factor: number): number;
99
+ declare function multiply(value: SharedPercent, factor: number): number | SharedPercent;
100
+ /** `value` divided by `divisor`; a `divisor` of 0 throws a `RangeError`. */
101
+ declare function divide(value: number, divisor: number): number;
102
+ declare function divide(value: SharedPercent, divisor: number): number | SharedPercent;
103
+ /** The sum of `values`: all numbers, or all percentages. */
104
+ declare function add(...values: number[]): number;
105
+ declare function add(...values: SharedPercent[]): number | SharedPercent;
106
+ /** `value` minus each of `values`: all numbers, or all percentages. */
107
+ declare function subtract(value: number, ...values: number[]): number;
108
+ declare function subtract(value: SharedPercent, ...values: SharedPercent[]): number | SharedPercent;
109
+ /** `value` times -1: a negative margin from a token. */
110
+ declare function negate(value: number): number;
111
+ declare function negate(value: SharedPercent): number | SharedPercent;
112
+ export { ThemeKey as A, configure as B, SharedStyledComponent as C, StyleSheet as D, StyleOptions as E, WebStyleObject as F, subtract as G, multiply as H, add as I, when as J, themeClass as K, alpha as L, ThemeProviderProps as M, WebNested as N, StyledOptions as O, WebProperties as P, apply as R, SharedStyled as S, StyleObject as T, negate as U, divide as V, styled as W, whenScheme as Y, SharedStyleInput as _, SchemeName as a, SharedStyleResult as b, SharedEntry as c, SharedProperties as d, SharedSheetDefinition as f, SharedStyleFunction as g, SharedStyleBase as h, SchemeKey as i, ThemeProvider as j, Theme as k, SharedObjectSheet as l, SharedSheetStyles as m, DefaultStyleOptions as n, SharedApplied as o, SharedSheetInput as p, useStyle as q, NestedKey as r, SharedApply as s, AlphaColor as t, SharedPercent as u, SharedStyleObject as v, SheetEntry as w, SharedStyleSheet as x, SharedStyleProp as y, at as z };
package/dist/vue.cjs ADDED
@@ -0,0 +1,9 @@
1
+ var _umber_style_vue = require("@umber-style/vue");
2
+ Object.keys(_umber_style_vue).forEach(function(k) {
3
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
4
+ enumerable: true,
5
+ get: function() {
6
+ return _umber_style_vue[k];
7
+ }
8
+ });
9
+ });
package/dist/vue.d.cts ADDED
@@ -0,0 +1 @@
1
+ export * from "@umber-style/vue";
package/dist/vue.d.mts ADDED
@@ -0,0 +1 @@
1
+ export * from "@umber-style/vue";
package/dist/vue.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export * from "@umber-style/vue";
2
+ export {};
package/package.json CHANGED
@@ -1,10 +1,141 @@
1
1
  {
2
2
  "name": "umber-style",
3
- "version": "0.0.0",
4
- "description": "Placeholder. The first release is on its way.",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "UmberStyle in one package: the engine at the root, and the React, React Native and Vue bindings as subpaths.",
5
+ "keywords": [
6
+ "styling",
7
+ "theme",
8
+ "design-tokens",
9
+ "css-variables",
10
+ "react",
11
+ "react-native",
12
+ "vue",
13
+ "ssr",
14
+ "typescript"
15
+ ],
5
16
  "license": "MIT",
17
+ "author": "Masoud Soroush <masoud@soroush.tech>",
18
+ "homepage": "https://umber-style.soroush.design",
6
19
  "repository": {
7
20
  "type": "git",
8
- "url": "git+https://github.com/soroush-tech/umber-style.git"
9
- }
10
- }
21
+ "url": "git+https://github.com/soroush-tech/umber-style.git",
22
+ "directory": "packages/umber-style"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/soroush-tech/umber-style/issues"
26
+ },
27
+ "type": "module",
28
+ "sideEffects": false,
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "exports": {
33
+ ".": {
34
+ "import": {
35
+ "types": "./dist/index.d.mts",
36
+ "default": "./dist/index.mjs"
37
+ },
38
+ "require": {
39
+ "types": "./dist/index.d.cts",
40
+ "default": "./dist/index.cjs"
41
+ }
42
+ },
43
+ "./react": {
44
+ "react-server": {
45
+ "import": {
46
+ "types": "./dist/shared.server.d.mts",
47
+ "default": "./dist/react.server.mjs"
48
+ },
49
+ "require": {
50
+ "types": "./dist/shared.server.d.cts",
51
+ "default": "./dist/react.server.cjs"
52
+ }
53
+ },
54
+ "react-native": {
55
+ "import": {
56
+ "types": "./dist/shared.d.mts",
57
+ "default": "./dist/react-native.mjs"
58
+ },
59
+ "require": {
60
+ "types": "./dist/shared.d.cts",
61
+ "default": "./dist/react-native.cjs"
62
+ }
63
+ },
64
+ "import": {
65
+ "types": "./dist/shared.d.mts",
66
+ "default": "./dist/react.mjs"
67
+ },
68
+ "require": {
69
+ "types": "./dist/shared.d.cts",
70
+ "default": "./dist/react.cjs"
71
+ }
72
+ },
73
+ "./react-native": {
74
+ "import": {
75
+ "types": "./dist/react-native.d.mts",
76
+ "default": "./dist/react-native.mjs"
77
+ },
78
+ "require": {
79
+ "types": "./dist/react-native.d.cts",
80
+ "default": "./dist/react-native.cjs"
81
+ }
82
+ },
83
+ "./vue": {
84
+ "import": {
85
+ "types": "./dist/vue.d.mts",
86
+ "default": "./dist/vue.mjs"
87
+ },
88
+ "require": {
89
+ "types": "./dist/vue.d.cts",
90
+ "default": "./dist/vue.cjs"
91
+ }
92
+ }
93
+ },
94
+ "publishConfig": {
95
+ "access": "public"
96
+ },
97
+ "dependencies": {
98
+ "@umber-style/core": "0.1.0-alpha.0",
99
+ "@umber-style/react": "0.1.0-alpha.0",
100
+ "@umber-style/react-native": "0.1.0-alpha.0",
101
+ "@umber-style/vue": "0.1.0-alpha.0"
102
+ },
103
+ "peerDependencies": {
104
+ "react": "^19.2.8",
105
+ "vue": "^3.5.0"
106
+ },
107
+ "peerDependenciesMeta": {
108
+ "react": {
109
+ "optional": true
110
+ },
111
+ "vue": {
112
+ "optional": true
113
+ }
114
+ },
115
+ "devDependencies": {
116
+ "@testing-library/react": "^16.3.3",
117
+ "@types/node": "^26.6.6",
118
+ "@types/react": "^19.3.0",
119
+ "@types/react-dom": "^19.3.0",
120
+ "@vitest/coverage-v8": "^5.1.0",
121
+ "jsdom": "^31.0.0",
122
+ "oxlint": "^1.93.0",
123
+ "react": "^19.3.1",
124
+ "react-dom": "^19.3.1",
125
+ "tsdown": "^0.23.7",
126
+ "typescript": "~7.0.2",
127
+ "vitest": "^5.1.0",
128
+ "vue": "^3.5.45",
129
+ "@umber-style/eslint-config": "0.0.0"
130
+ },
131
+ "scripts": {
132
+ "build": "tsdown",
133
+ "lint": "oxlint --deny-warnings",
134
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.native.json && tsc --noEmit -p tsconfig.server.json",
135
+ "test": "vitest run",
136
+ "test:coverage": "vitest run --coverage"
137
+ },
138
+ "main": "./dist/index.cjs",
139
+ "module": "./dist/index.mjs",
140
+ "types": "./dist/index.d.mts"
141
+ }