@umber-style/vue 0.1.0-alpha.2 → 0.1.0-rc.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.
package/dist/index.cjs CHANGED
@@ -71,7 +71,7 @@ styles: {
71
71
  const local = cache === void 0 ? engine : engine.withCache(cache);
72
72
  const outerView = (0, vue.inject)(keys.view, null);
73
73
  const outerTheme = (0, vue.inject)(keys.theme, null);
74
- const readOwnTheme = () => engine.baseTheme ?? _umber_style_core.EMPTY_THEME;
74
+ const readOwnTheme = () => engine.givenTheme ?? _umber_style_core.EMPTY_THEME;
75
75
  const sets = (0, vue.computed)(() => {
76
76
  const view = local === engine ? outerView?.value ?? engine.createThemeView(readOwnTheme()) : local.createThemeView(outerTheme?.value ?? readOwnTheme());
77
77
  return local.resolveGlobal(props.styles, view);
@@ -120,10 +120,10 @@ function createHoldRef(hold) {
120
120
  }
121
121
  };
122
122
  }
123
- /** The attributes that the element is given: all but those of `styled` (`as`, `theme`, `class`, `style`), and of those only what `filter` lets through when there is one. */
124
- function forwardAttributes(attrs, filter) {
123
+ /** The attributes that the element is given: all but those of `styled` (`as` where it replaces a string tag, `theme`, `class`, `style`), and of those only what `filter` lets through when there is one. */
124
+ function forwardAttributes(attrs, filter, isTag) {
125
125
  const forwarded = {};
126
- for (const [key, value] of Object.entries(attrs)) if (!(key === "as" || key === "theme" || key === "class" || key === "style") && (!filter || filter(key))) forwarded[key] = value;
126
+ for (const [key, value] of Object.entries(attrs)) if (!(isTag && key === "as" || key === "theme" || key === "class" || key === "style") && (!filter || filter(key))) forwarded[key] = value;
127
127
  return forwarded;
128
128
  }
129
129
  /**
@@ -138,6 +138,7 @@ function createStyled(engine, useThemeView) {
138
138
  const styles = (0, _umber_style_core.readStyleArguments)(args);
139
139
  const inner = isStyledComponent(tag) ? tag : void 0;
140
140
  const baseTag = inner?._tag ?? tag;
141
+ const isTag = typeof baseTag === "string";
141
142
  const shouldForward = options.shouldForwardProp ?? inner?._shouldForwardProp;
142
143
  const target = [inner?._target, options.target].filter(Boolean).join(" ") || void 0;
143
144
  const styler = engine.createStyler(options, styles, inner?._styles);
@@ -160,8 +161,8 @@ function createStyled(engine, useThemeView) {
160
161
  const held = typeof document !== "undefined" && attrs.style ? own.getHeldClass(attrs, extra, theme) : void 0;
161
162
  let className = held ? held.className : own.getClassName(attrs, extra, theme);
162
163
  if (target) className = className ? `${className} ${target}` : target;
163
- const element = attrs.as ?? baseTag;
164
- const forwarded = forwardAttributes(attrs, typeof element === "string" ? shouldForward : void 0);
164
+ const element = isTag ? attrs.as ?? baseTag : baseTag;
165
+ const forwarded = forwardAttributes(attrs, typeof element === "string" ? shouldForward : void 0, isTag);
165
166
  forwarded.class = className || void 0;
166
167
  if (held?.hold) forwarded.ref = createHoldRef(held.hold);
167
168
  return (0, vue.h)(element, forwarded, slots);
@@ -235,9 +236,9 @@ function createThemeProvider(baseEngine, keys) {
235
236
  const outer = (0, vue.inject)(keys.theme, null);
236
237
  const scope = (0, vue.inject)(keys.engine, null) === engine ? (0, vue.inject)(keys.scope, null) : null;
237
238
  const isNested = scope !== null && !props.isRoot;
238
- const readOuter = () => outer?.value ?? engine.baseTheme;
239
+ const readOuter = () => outer?.value ?? engine.givenTheme;
239
240
  const given = (0, vue.computed)(() => (0, _umber_style_core.resolveThemeInput)(props.theme, readOuter() ?? _umber_style_core.EMPTY_THEME));
240
- if (!engine.hasTheme) engine.setTheme(given.value);
241
+ engine.adoptTheme(given.value);
241
242
  const merged = (0, vue.computed)(() => (0, _umber_style_core.mergeTheme)(readOuter(), given.value));
242
243
  const classes = (0, vue.computed)(() => {
243
244
  const own = engine.themeClass(given.value, props.colorScheme);
@@ -290,8 +291,8 @@ function createThemeScope(keys) {
290
291
  function bindEngine(engine) {
291
292
  const keys = createThemeKeys();
292
293
  const { ThemeScope, useThemeClass } = createThemeScope(keys);
293
- /** The theme where no provider is above: the base theme, or the empty theme. */
294
- const readOwnTheme = () => engine.baseTheme ?? _umber_style_core.EMPTY_THEME;
294
+ /** The theme where no provider is above: the base theme given on purpose, or the empty theme; never one that a provider gave the engine. */
295
+ const readOwnTheme = () => engine.givenTheme ?? _umber_style_core.EMPTY_THEME;
295
296
  const useTheme = () => (0, vue.inject)(keys.theme, null) ?? (0, vue.computed)(readOwnTheme);
296
297
  const useThemeView = (cache) => {
297
298
  const local = cache === void 0 ? engine : engine.withCache(cache);
@@ -328,7 +329,7 @@ function bindEngine(engine) {
328
329
  /** Makes the Vue styling of one theme shape, apart from the default one: its own engine, or the one given. */
329
330
  function createStyle(theme, options = {}) {
330
331
  const engine = options.engine ?? (0, _umber_style_core.createEngine)(theme, options);
331
- if (!engine.hasTheme) engine.setTheme(theme);
332
+ if (engine.givenTheme === void 0) engine.setTheme(theme);
332
333
  return bindEngine(engine);
333
334
  }
334
335
  // src/defaultStyle.ts
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Component, ComputedRef, FunctionalComponent, IntrinsicElementAttributes, PropType } from "vue";
2
- import { AlphaColor, BindingOptions, CSSObject, Cache, ColorScheme, ComponentSelector, CssArgument, CssArgument as CssArgument$1, Engine, GlobalInput, GlobalInput as GlobalInput$1, GlobalStyleObject, GlobalStyleObject as GlobalStyleObject$1, GlobalStyles, GlobalStyles as GlobalStyles$1, GlobalStylesInput, Interpolation as Interpolation$1, InterpolationResult, InterpolationResult as InterpolationResult$1, Keyframes, Keyframes as Keyframes$1, KeyframesInput, KeyframesOptions, KeyframesSteps, KeyframesSteps as KeyframesSteps$1, NestedKey, ObjectSheet, SchemeKey, SchemeName, SerializedStyles, SerializedStyles as SerializedStyles$1, SheetEntry, SheetEntry as SheetEntry$1, SheetStyles, StaticTemplateValue, StaticTemplateValue as StaticTemplateValue$1, StyleInput, StyleObject, StylerOptions, TemplateValue, TemplateValue as TemplateValue$1, Theme as Theme$1, ThemeInput, ThemeInput as ThemeInput$1, ThemeKey, UmberCache, WebNested, WebProperties, WebStyleObject, WebStyleObject as WebStyleObject$1, add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
2
+ import { AlphaColor, BindingOptions, CSSObject, Cache, ColorScheme, ComponentSelector, CssArgument, CssArgument as CssArgument$1, Engine, GlobalInput, GlobalInput as GlobalInput$1, GlobalStyleObject, GlobalStyleObject as GlobalStyleObject$1, GlobalStyles, GlobalStyles as GlobalStyles$1, GlobalStylesInput, Interpolation as Interpolation$1, InterpolationResult, InterpolationResult as InterpolationResult$1, Keyframes, Keyframes as Keyframes$1, KeyframesInput, KeyframesOptions, KeyframesSteps, KeyframesSteps as KeyframesSteps$1, NestedKey, ObjectSheet, SchemeKey, SchemeName, SerializedStyles, SerializedStyles as SerializedStyles$1, SheetEntry, SheetEntry as SheetEntry$1, SheetStyles, StaticTemplateValue, StaticTemplateValue as StaticTemplateValue$1, StyleInput, StyleObject, StyleTypeOptions, StylerOptions, TemplateValue, TemplateValue as TemplateValue$1, Theme as Theme$1, ThemeInput, ThemeInput as ThemeInput$1, ThemeKey, UmberCache, WebNested, WebProperties, WebStyleObject, WebStyleObject as WebStyleObject$1, add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
3
3
  /**
4
4
  * The theme of the default style of this binding: what `styled`, `useTheme`, `StyleSheet` and
5
5
  * `ThemeProvider` of the default style read. It extends the core's `Theme`, so an app gives it members
@@ -20,7 +20,7 @@ export type Interpolation<Props = Record<string, unknown>, T = Theme> = Interpol
20
20
  export type StyleOptions<T = never> = BindingOptions<T>;
21
21
  /** The options of `styled(tag, options)`: the label of the class, what reaches the element, a class name of your own. */
22
22
  export interface StyledOptions extends StylerOptions {
23
- /** Whether an attribute is forwarded to a string tag. Default: every attribute but `as`, `theme`, `class` and `style`, which the component handles itself. */
23
+ /** Whether an attribute is forwarded to a string tag. Default: every attribute but `as`, `theme`, `class` and `style`, which the component handles itself; a component that is not made by `styled` is always rendered, and is given `as`. */
24
24
  shouldForwardProp?: (prop: string) => boolean;
25
25
  /**
26
26
  * A class name of your own that the element always has, after the engine's classes: a stable name
@@ -258,4 +258,4 @@ export declare const configure: (options: DefaultStyleOptions) => void, getEngin
258
258
  (template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").GlobalStyles<Theme>;
259
259
  (styles: import("@umber-style/core").GlobalStylesInput<Theme>): import("@umber-style/core").GlobalStyles<Theme>;
260
260
  }, Global: import("vue").Component<GlobalProps<Theme>>;
261
- export { type AlphaColor, type CSSObject, type ComponentSelector, type CssArgument, type GlobalInput, type GlobalStyleObject, type GlobalStyles, type InterpolationResult, type Keyframes, type KeyframesSteps, type NestedKey, type SchemeKey, type SchemeName, type SerializedStyles, type SheetEntry, type StaticTemplateValue, type StyleObject, type TemplateValue, type ThemeInput, type ThemeKey, type UmberCache, type WebNested, type WebProperties, type WebStyleObject, add, alpha, at, divide, multiply, negate, subtract };
261
+ export { type AlphaColor, type CSSObject, type ComponentSelector, type CssArgument, type GlobalInput, type GlobalStyleObject, type GlobalStyles, type InterpolationResult, type Keyframes, type KeyframesSteps, type NestedKey, type SchemeKey, type SchemeName, type SerializedStyles, type SheetEntry, type StaticTemplateValue, type StyleObject, type StyleTypeOptions, type TemplateValue, type ThemeInput, type ThemeKey, type UmberCache, type WebNested, type WebProperties, type WebStyleObject, add, alpha, at, divide, multiply, negate, subtract };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Component, ComputedRef, FunctionalComponent, IntrinsicElementAttributes, PropType } from "vue";
2
- import { AlphaColor, BindingOptions, CSSObject, Cache, ColorScheme, ComponentSelector, CssArgument, CssArgument as CssArgument$1, Engine, GlobalInput, GlobalInput as GlobalInput$1, GlobalStyleObject, GlobalStyleObject as GlobalStyleObject$1, GlobalStyles, GlobalStyles as GlobalStyles$1, GlobalStylesInput, Interpolation as Interpolation$1, InterpolationResult, InterpolationResult as InterpolationResult$1, Keyframes, Keyframes as Keyframes$1, KeyframesInput, KeyframesOptions, KeyframesSteps, KeyframesSteps as KeyframesSteps$1, NestedKey, ObjectSheet, SchemeKey, SchemeName, SerializedStyles, SerializedStyles as SerializedStyles$1, SheetEntry, SheetEntry as SheetEntry$1, SheetStyles, StaticTemplateValue, StaticTemplateValue as StaticTemplateValue$1, StyleInput, StyleObject, StylerOptions, TemplateValue, TemplateValue as TemplateValue$1, Theme as Theme$1, ThemeInput, ThemeInput as ThemeInput$1, ThemeKey, UmberCache, WebNested, WebProperties, WebStyleObject, WebStyleObject as WebStyleObject$1, add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
2
+ import { AlphaColor, BindingOptions, CSSObject, Cache, ColorScheme, ComponentSelector, CssArgument, CssArgument as CssArgument$1, Engine, GlobalInput, GlobalInput as GlobalInput$1, GlobalStyleObject, GlobalStyleObject as GlobalStyleObject$1, GlobalStyles, GlobalStyles as GlobalStyles$1, GlobalStylesInput, Interpolation as Interpolation$1, InterpolationResult, InterpolationResult as InterpolationResult$1, Keyframes, Keyframes as Keyframes$1, KeyframesInput, KeyframesOptions, KeyframesSteps, KeyframesSteps as KeyframesSteps$1, NestedKey, ObjectSheet, SchemeKey, SchemeName, SerializedStyles, SerializedStyles as SerializedStyles$1, SheetEntry, SheetEntry as SheetEntry$1, SheetStyles, StaticTemplateValue, StaticTemplateValue as StaticTemplateValue$1, StyleInput, StyleObject, StyleTypeOptions, StylerOptions, TemplateValue, TemplateValue as TemplateValue$1, Theme as Theme$1, ThemeInput, ThemeInput as ThemeInput$1, ThemeKey, UmberCache, WebNested, WebProperties, WebStyleObject, WebStyleObject as WebStyleObject$1, add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
3
3
  /**
4
4
  * The theme of the default style of this binding: what `styled`, `useTheme`, `StyleSheet` and
5
5
  * `ThemeProvider` of the default style read. It extends the core's `Theme`, so an app gives it members
@@ -20,7 +20,7 @@ export type Interpolation<Props = Record<string, unknown>, T = Theme> = Interpol
20
20
  export type StyleOptions<T = never> = BindingOptions<T>;
21
21
  /** The options of `styled(tag, options)`: the label of the class, what reaches the element, a class name of your own. */
22
22
  export interface StyledOptions extends StylerOptions {
23
- /** Whether an attribute is forwarded to a string tag. Default: every attribute but `as`, `theme`, `class` and `style`, which the component handles itself. */
23
+ /** Whether an attribute is forwarded to a string tag. Default: every attribute but `as`, `theme`, `class` and `style`, which the component handles itself; a component that is not made by `styled` is always rendered, and is given `as`. */
24
24
  shouldForwardProp?: (prop: string) => boolean;
25
25
  /**
26
26
  * A class name of your own that the element always has, after the engine's classes: a stable name
@@ -258,4 +258,4 @@ export declare const configure: (options: DefaultStyleOptions) => void, getEngin
258
258
  (template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").GlobalStyles<Theme>;
259
259
  (styles: import("@umber-style/core").GlobalStylesInput<Theme>): import("@umber-style/core").GlobalStyles<Theme>;
260
260
  }, Global: import("vue").Component<GlobalProps<Theme>>;
261
- export { type AlphaColor, type CSSObject, type ComponentSelector, type CssArgument, type GlobalInput, type GlobalStyleObject, type GlobalStyles, type InterpolationResult, type Keyframes, type KeyframesSteps, type NestedKey, type SchemeKey, type SchemeName, type SerializedStyles, type SheetEntry, type StaticTemplateValue, type StyleObject, type TemplateValue, type ThemeInput, type ThemeKey, type UmberCache, type WebNested, type WebProperties, type WebStyleObject, add, alpha, at, divide, multiply, negate, subtract };
261
+ export { type AlphaColor, type CSSObject, type ComponentSelector, type CssArgument, type GlobalInput, type GlobalStyleObject, type GlobalStyles, type InterpolationResult, type Keyframes, type KeyframesSteps, type NestedKey, type SchemeKey, type SchemeName, type SerializedStyles, type SheetEntry, type StaticTemplateValue, type StyleObject, type StyleTypeOptions, type TemplateValue, type ThemeInput, type ThemeKey, type UmberCache, type WebNested, type WebProperties, type WebStyleObject, add, alpha, at, divide, multiply, negate, subtract };
package/dist/index.mjs CHANGED
@@ -70,7 +70,7 @@ styles: {
70
70
  const local = cache === void 0 ? engine : engine.withCache(cache);
71
71
  const outerView = inject(keys.view, null);
72
72
  const outerTheme = inject(keys.theme, null);
73
- const readOwnTheme = () => engine.baseTheme ?? EMPTY_THEME;
73
+ const readOwnTheme = () => engine.givenTheme ?? EMPTY_THEME;
74
74
  const sets = computed(() => {
75
75
  const view = local === engine ? outerView?.value ?? engine.createThemeView(readOwnTheme()) : local.createThemeView(outerTheme?.value ?? readOwnTheme());
76
76
  return local.resolveGlobal(props.styles, view);
@@ -119,10 +119,10 @@ function createHoldRef(hold) {
119
119
  }
120
120
  };
121
121
  }
122
- /** The attributes that the element is given: all but those of `styled` (`as`, `theme`, `class`, `style`), and of those only what `filter` lets through when there is one. */
123
- function forwardAttributes(attrs, filter) {
122
+ /** The attributes that the element is given: all but those of `styled` (`as` where it replaces a string tag, `theme`, `class`, `style`), and of those only what `filter` lets through when there is one. */
123
+ function forwardAttributes(attrs, filter, isTag) {
124
124
  const forwarded = {};
125
- for (const [key, value] of Object.entries(attrs)) if (!(key === "as" || key === "theme" || key === "class" || key === "style") && (!filter || filter(key))) forwarded[key] = value;
125
+ for (const [key, value] of Object.entries(attrs)) if (!(isTag && key === "as" || key === "theme" || key === "class" || key === "style") && (!filter || filter(key))) forwarded[key] = value;
126
126
  return forwarded;
127
127
  }
128
128
  /**
@@ -137,6 +137,7 @@ function createStyled(engine, useThemeView) {
137
137
  const styles = readStyleArguments(args);
138
138
  const inner = isStyledComponent(tag) ? tag : void 0;
139
139
  const baseTag = inner?._tag ?? tag;
140
+ const isTag = typeof baseTag === "string";
140
141
  const shouldForward = options.shouldForwardProp ?? inner?._shouldForwardProp;
141
142
  const target = [inner?._target, options.target].filter(Boolean).join(" ") || void 0;
142
143
  const styler = engine.createStyler(options, styles, inner?._styles);
@@ -159,8 +160,8 @@ function createStyled(engine, useThemeView) {
159
160
  const held = typeof document !== "undefined" && attrs.style ? own.getHeldClass(attrs, extra, theme) : void 0;
160
161
  let className = held ? held.className : own.getClassName(attrs, extra, theme);
161
162
  if (target) className = className ? `${className} ${target}` : target;
162
- const element = attrs.as ?? baseTag;
163
- const forwarded = forwardAttributes(attrs, typeof element === "string" ? shouldForward : void 0);
163
+ const element = isTag ? attrs.as ?? baseTag : baseTag;
164
+ const forwarded = forwardAttributes(attrs, typeof element === "string" ? shouldForward : void 0, isTag);
164
165
  forwarded.class = className || void 0;
165
166
  if (held?.hold) forwarded.ref = createHoldRef(held.hold);
166
167
  return h(element, forwarded, slots);
@@ -234,9 +235,9 @@ function createThemeProvider(baseEngine, keys) {
234
235
  const outer = inject(keys.theme, null);
235
236
  const scope = inject(keys.engine, null) === engine ? inject(keys.scope, null) : null;
236
237
  const isNested = scope !== null && !props.isRoot;
237
- const readOuter = () => outer?.value ?? engine.baseTheme;
238
+ const readOuter = () => outer?.value ?? engine.givenTheme;
238
239
  const given = computed(() => resolveThemeInput(props.theme, readOuter() ?? EMPTY_THEME));
239
- if (!engine.hasTheme) engine.setTheme(given.value);
240
+ engine.adoptTheme(given.value);
240
241
  const merged = computed(() => mergeTheme(readOuter(), given.value));
241
242
  const classes = computed(() => {
242
243
  const own = engine.themeClass(given.value, props.colorScheme);
@@ -289,8 +290,8 @@ function createThemeScope(keys) {
289
290
  function bindEngine(engine) {
290
291
  const keys = createThemeKeys();
291
292
  const { ThemeScope, useThemeClass } = createThemeScope(keys);
292
- /** The theme where no provider is above: the base theme, or the empty theme. */
293
- const readOwnTheme = () => engine.baseTheme ?? EMPTY_THEME;
293
+ /** The theme where no provider is above: the base theme given on purpose, or the empty theme; never one that a provider gave the engine. */
294
+ const readOwnTheme = () => engine.givenTheme ?? EMPTY_THEME;
294
295
  const useTheme = () => inject(keys.theme, null) ?? computed(readOwnTheme);
295
296
  const useThemeView = (cache) => {
296
297
  const local = cache === void 0 ? engine : engine.withCache(cache);
@@ -327,7 +328,7 @@ function bindEngine(engine) {
327
328
  /** Makes the Vue styling of one theme shape, apart from the default one: its own engine, or the one given. */
328
329
  function createStyle(theme, options = {}) {
329
330
  const engine = options.engine ?? createEngine(theme, options);
330
- if (!engine.hasTheme) engine.setTheme(theme);
331
+ if (engine.givenTheme === void 0) engine.setTheme(theme);
331
332
  return bindEngine(engine);
332
333
  }
333
334
  // src/defaultStyle.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umber-style/vue",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-rc.1",
4
4
  "description": "UmberStyle for Vue: the same names as the React binding, with a reactive useTheme.",
5
5
  "keywords": [
6
6
  "styling",
@@ -43,7 +43,7 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@umber-style/core": "0.1.0-alpha.5"
46
+ "@umber-style/core": "0.1.0-rc.1"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "vue": "^3.5.0"
@@ -63,7 +63,7 @@
63
63
  "scripts": {
64
64
  "build": "tsdown",
65
65
  "lint": "oxlint --deny-warnings",
66
- "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.defaultStyle.json",
66
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.defaultStyle.json && tsc --noEmit -p tsconfig.strict.json",
67
67
  "test": "vitest run",
68
68
  "test:coverage": "vitest run --coverage"
69
69
  },