@varlet/ui 2.18.2-alpha.1698728560863 → 2.18.2
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/es/countdown/countdown.css +1 -1
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/option/option.css +1 -1
- package/es/snackbar/style/index.mjs +1 -1
- package/es/style.css +1 -1
- package/es/utils/components.mjs +6 -67
- package/es/varlet.esm.js +2817 -2812
- package/highlight/web-types.en-US.json +11 -11
- package/highlight/web-types.zh-CN.json +11 -11
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +68 -64
- package/package.json +7 -7
- package/umd/varlet.js +6 -6
package/es/utils/components.mjs
CHANGED
|
@@ -34,7 +34,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
34
34
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
import { useEventListener } from "@varlet/use";
|
|
37
|
+
import { useEventListener, useVModel as _useVModel } from "@varlet/use";
|
|
38
38
|
import {
|
|
39
39
|
createApp,
|
|
40
40
|
h,
|
|
@@ -42,11 +42,9 @@ import {
|
|
|
42
42
|
onActivated,
|
|
43
43
|
onDeactivated,
|
|
44
44
|
Comment,
|
|
45
|
-
Fragment
|
|
46
|
-
computed,
|
|
47
|
-
watch
|
|
45
|
+
Fragment
|
|
48
46
|
} from "vue";
|
|
49
|
-
import {
|
|
47
|
+
import { call as _call, createNamespaceFn, isArray } from "@varlet/shared";
|
|
50
48
|
function pickProps(props, propsKey) {
|
|
51
49
|
return Array.isArray(propsKey) ? propsKey.reduce((pickedProps, key) => {
|
|
52
50
|
pickedProps[key] = props[key];
|
|
@@ -147,39 +145,9 @@ function useTeleport() {
|
|
|
147
145
|
disabled
|
|
148
146
|
};
|
|
149
147
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const createBEM = (suffix) => {
|
|
154
|
-
if (!suffix) {
|
|
155
|
-
return componentName;
|
|
156
|
-
}
|
|
157
|
-
if (suffix[0] === "$") {
|
|
158
|
-
return suffix.replace("$", namespace);
|
|
159
|
-
}
|
|
160
|
-
return suffix.startsWith("--") ? `${componentName}${suffix}` : `${componentName}__${suffix}`;
|
|
161
|
-
};
|
|
162
|
-
const classes = (...classes2) => classes2.map((className) => {
|
|
163
|
-
if (isArray(className)) {
|
|
164
|
-
const [condition, truthy, falsy = null] = className;
|
|
165
|
-
return condition ? truthy : falsy;
|
|
166
|
-
}
|
|
167
|
-
return className;
|
|
168
|
-
});
|
|
169
|
-
return {
|
|
170
|
-
name: bigCamelize(componentName),
|
|
171
|
-
n: createBEM,
|
|
172
|
-
classes
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
function call(fn, ...args) {
|
|
176
|
-
if (isArray(fn)) {
|
|
177
|
-
return fn.map((f) => f(...args));
|
|
178
|
-
}
|
|
179
|
-
if (fn) {
|
|
180
|
-
return fn(...args);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
148
|
+
const createNamespace = createNamespaceFn("var");
|
|
149
|
+
const call = _call;
|
|
150
|
+
const useVModel = _useVModel;
|
|
183
151
|
function defineListenerProp(fallback) {
|
|
184
152
|
return {
|
|
185
153
|
type: [Function, Array],
|
|
@@ -195,35 +163,6 @@ function formatElevation(elevation, defaultLevel) {
|
|
|
195
163
|
}
|
|
196
164
|
return `var-elevation--${elevation}`;
|
|
197
165
|
}
|
|
198
|
-
function useVModel(props, key, options = {}) {
|
|
199
|
-
const { passive = true, eventName, defaultValue, emit } = options;
|
|
200
|
-
const event = eventName != null ? eventName : `onUpdate:${key.toString()}`;
|
|
201
|
-
const getValue = () => props[key] != null ? props[key] : defaultValue;
|
|
202
|
-
if (!passive) {
|
|
203
|
-
return computed({
|
|
204
|
-
get() {
|
|
205
|
-
return getValue();
|
|
206
|
-
},
|
|
207
|
-
set(value) {
|
|
208
|
-
emit ? emit(event, value) : call(props[event], value);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
const proxy = ref(getValue());
|
|
213
|
-
watch(
|
|
214
|
-
() => props[key],
|
|
215
|
-
() => {
|
|
216
|
-
proxy.value = getValue();
|
|
217
|
-
}
|
|
218
|
-
);
|
|
219
|
-
watch(
|
|
220
|
-
() => proxy.value,
|
|
221
|
-
(newValue) => {
|
|
222
|
-
emit ? emit(event, newValue) : call(props[event], newValue);
|
|
223
|
-
}
|
|
224
|
-
);
|
|
225
|
-
return proxy;
|
|
226
|
-
}
|
|
227
166
|
export {
|
|
228
167
|
call,
|
|
229
168
|
createNamespace,
|