@umber-style/vue 0.1.0-alpha.2 → 0.1.0-rc.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/dist/index.cjs +6 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +6 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -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
|
|
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);
|
package/dist/index.d.cts
CHANGED
|
@@ -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
|
package/dist/index.d.mts
CHANGED
|
@@ -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
|
package/dist/index.mjs
CHANGED
|
@@ -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
|
|
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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umber-style/vue",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-rc.0",
|
|
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-
|
|
46
|
+
"@umber-style/core": "0.1.0-rc.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"vue": "^3.5.0"
|