@hoci/core 0.6.0 → 0.7.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 CHANGED
@@ -1,10 +1,416 @@
1
1
  'use strict';
2
2
 
3
- const vue = require('vue');
4
- const core = require('@vueuse/core');
5
3
  const shared = require('@hoci/shared');
4
+ const vue = require('vue');
6
5
  const tslx = require('tslx');
7
6
 
7
+ var _a;
8
+ const isClient = typeof window !== "undefined";
9
+ const isDef = (val) => typeof val !== "undefined";
10
+ const isFunction = (val) => typeof val === "function";
11
+ const isString = (val) => typeof val === "string";
12
+ const noop = () => {
13
+ };
14
+ isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
15
+
16
+ function resolveUnref(r) {
17
+ return typeof r === "function" ? r() : vue.unref(r);
18
+ }
19
+ function identity(arg) {
20
+ return arg;
21
+ }
22
+
23
+ function tryOnScopeDispose(fn) {
24
+ if (vue.getCurrentScope()) {
25
+ vue.onScopeDispose(fn);
26
+ return true;
27
+ }
28
+ return false;
29
+ }
30
+
31
+ function isDefined(v) {
32
+ return vue.unref(v) != null;
33
+ }
34
+
35
+ function syncRef(left, right, options = {}) {
36
+ var _a, _b;
37
+ const {
38
+ flush = "sync",
39
+ deep = false,
40
+ immediate = true,
41
+ direction = "both",
42
+ transform = {}
43
+ } = options;
44
+ let watchLeft;
45
+ let watchRight;
46
+ const transformLTR = (_a = transform.ltr) != null ? _a : (v) => v;
47
+ const transformRTL = (_b = transform.rtl) != null ? _b : (v) => v;
48
+ if (direction === "both" || direction === "ltr") {
49
+ watchLeft = vue.watch(left, (newValue) => right.value = transformLTR(newValue), { flush, deep, immediate });
50
+ }
51
+ if (direction === "both" || direction === "rtl") {
52
+ watchRight = vue.watch(right, (newValue) => left.value = transformRTL(newValue), { flush, deep, immediate });
53
+ }
54
+ return () => {
55
+ watchLeft == null ? void 0 : watchLeft();
56
+ watchRight == null ? void 0 : watchRight();
57
+ };
58
+ }
59
+
60
+ function tryOnMounted(fn, sync = true) {
61
+ if (vue.getCurrentInstance())
62
+ vue.onMounted(fn);
63
+ else if (sync)
64
+ fn();
65
+ else
66
+ vue.nextTick(fn);
67
+ }
68
+
69
+ function unrefElement(elRef) {
70
+ var _a;
71
+ const plain = resolveUnref(elRef);
72
+ return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
73
+ }
74
+
75
+ const defaultWindow = isClient ? window : void 0;
76
+
77
+ function useEventListener(...args) {
78
+ let target;
79
+ let events;
80
+ let listeners;
81
+ let options;
82
+ if (isString(args[0]) || Array.isArray(args[0])) {
83
+ [events, listeners, options] = args;
84
+ target = defaultWindow;
85
+ } else {
86
+ [target, events, listeners, options] = args;
87
+ }
88
+ if (!target)
89
+ return noop;
90
+ if (!Array.isArray(events))
91
+ events = [events];
92
+ if (!Array.isArray(listeners))
93
+ listeners = [listeners];
94
+ const cleanups = [];
95
+ const cleanup = () => {
96
+ cleanups.forEach((fn) => fn());
97
+ cleanups.length = 0;
98
+ };
99
+ const register = (el, event, listener) => {
100
+ el.addEventListener(event, listener, options);
101
+ return () => el.removeEventListener(event, listener, options);
102
+ };
103
+ const stopWatch = vue.watch(() => unrefElement(target), (el) => {
104
+ cleanup();
105
+ if (!el)
106
+ return;
107
+ cleanups.push(...events.flatMap((event) => {
108
+ return listeners.map((listener) => register(el, event, listener));
109
+ }));
110
+ }, { immediate: true, flush: "post" });
111
+ const stop = () => {
112
+ stopWatch();
113
+ cleanup();
114
+ };
115
+ tryOnScopeDispose(stop);
116
+ return stop;
117
+ }
118
+
119
+ function onClickOutside(target, handler, options = {}) {
120
+ const { window = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
121
+ if (!window)
122
+ return;
123
+ let shouldListen = true;
124
+ let fallback;
125
+ const shouldIgnore = (event) => {
126
+ return ignore.some((target2) => {
127
+ if (typeof target2 === "string") {
128
+ return Array.from(window.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
129
+ } else {
130
+ const el = unrefElement(target2);
131
+ return el && (event.target === el || event.composedPath().includes(el));
132
+ }
133
+ });
134
+ };
135
+ const listener = (event) => {
136
+ window.clearTimeout(fallback);
137
+ const el = unrefElement(target);
138
+ if (!el || el === event.target || event.composedPath().includes(el))
139
+ return;
140
+ if (event.detail === 0)
141
+ shouldListen = !shouldIgnore(event);
142
+ if (!shouldListen) {
143
+ shouldListen = true;
144
+ return;
145
+ }
146
+ handler(event);
147
+ };
148
+ const cleanup = [
149
+ useEventListener(window, "click", listener, { passive: true, capture }),
150
+ useEventListener(window, "pointerdown", (e) => {
151
+ const el = unrefElement(target);
152
+ if (el)
153
+ shouldListen = !e.composedPath().includes(el) && !shouldIgnore(e);
154
+ }, { passive: true }),
155
+ useEventListener(window, "pointerup", (e) => {
156
+ if (e.button === 0) {
157
+ const path = e.composedPath();
158
+ e.composedPath = () => path;
159
+ fallback = window.setTimeout(() => listener(e), 50);
160
+ }
161
+ }, { passive: true }),
162
+ detectIframe && useEventListener(window, "blur", (event) => {
163
+ var _a;
164
+ const el = unrefElement(target);
165
+ if (((_a = window.document.activeElement) == null ? void 0 : _a.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(window.document.activeElement)))
166
+ handler(event);
167
+ })
168
+ ].filter(Boolean);
169
+ const stop = () => cleanup.forEach((fn) => fn());
170
+ return stop;
171
+ }
172
+
173
+ function useSupported(callback, sync = false) {
174
+ const isSupported = vue.ref();
175
+ const update = () => isSupported.value = Boolean(callback());
176
+ update();
177
+ tryOnMounted(update, sync);
178
+ return isSupported;
179
+ }
180
+ function cloneFnJSON(source) {
181
+ return JSON.parse(JSON.stringify(source));
182
+ }
183
+
184
+ const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
185
+ const globalKey = "__vueuse_ssr_handlers__";
186
+ _global[globalKey] = _global[globalKey] || {};
187
+
188
+ var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
189
+ var __hasOwnProp$f = Object.prototype.hasOwnProperty;
190
+ var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
191
+ var __objRest$2 = (source, exclude) => {
192
+ var target = {};
193
+ for (var prop in source)
194
+ if (__hasOwnProp$f.call(source, prop) && exclude.indexOf(prop) < 0)
195
+ target[prop] = source[prop];
196
+ if (source != null && __getOwnPropSymbols$f)
197
+ for (var prop of __getOwnPropSymbols$f(source)) {
198
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$f.call(source, prop))
199
+ target[prop] = source[prop];
200
+ }
201
+ return target;
202
+ };
203
+ function useResizeObserver(target, callback, options = {}) {
204
+ const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest$2(_a, ["window"]);
205
+ let observer;
206
+ const isSupported = useSupported(() => window && "ResizeObserver" in window);
207
+ const cleanup = () => {
208
+ if (observer) {
209
+ observer.disconnect();
210
+ observer = void 0;
211
+ }
212
+ };
213
+ const stopWatch = vue.watch(() => unrefElement(target), (el) => {
214
+ cleanup();
215
+ if (isSupported.value && window && el) {
216
+ observer = new ResizeObserver(callback);
217
+ observer.observe(el, observerOptions);
218
+ }
219
+ }, { immediate: true, flush: "post" });
220
+ const stop = () => {
221
+ cleanup();
222
+ stopWatch();
223
+ };
224
+ tryOnScopeDispose(stop);
225
+ return {
226
+ isSupported,
227
+ stop
228
+ };
229
+ }
230
+
231
+ function useElementBounding(target, options = {}) {
232
+ const {
233
+ reset = true,
234
+ windowResize = true,
235
+ windowScroll = true,
236
+ immediate = true
237
+ } = options;
238
+ const height = vue.ref(0);
239
+ const bottom = vue.ref(0);
240
+ const left = vue.ref(0);
241
+ const right = vue.ref(0);
242
+ const top = vue.ref(0);
243
+ const width = vue.ref(0);
244
+ const x = vue.ref(0);
245
+ const y = vue.ref(0);
246
+ function update() {
247
+ const el = unrefElement(target);
248
+ if (!el) {
249
+ if (reset) {
250
+ height.value = 0;
251
+ bottom.value = 0;
252
+ left.value = 0;
253
+ right.value = 0;
254
+ top.value = 0;
255
+ width.value = 0;
256
+ x.value = 0;
257
+ y.value = 0;
258
+ }
259
+ return;
260
+ }
261
+ const rect = el.getBoundingClientRect();
262
+ height.value = rect.height;
263
+ bottom.value = rect.bottom;
264
+ left.value = rect.left;
265
+ right.value = rect.right;
266
+ top.value = rect.top;
267
+ width.value = rect.width;
268
+ x.value = rect.x;
269
+ y.value = rect.y;
270
+ }
271
+ useResizeObserver(target, update);
272
+ vue.watch(() => unrefElement(target), (ele) => !ele && update());
273
+ if (windowScroll)
274
+ useEventListener("scroll", update, { capture: true, passive: true });
275
+ if (windowResize)
276
+ useEventListener("resize", update, { passive: true });
277
+ tryOnMounted(() => {
278
+ if (immediate)
279
+ update();
280
+ });
281
+ return {
282
+ height,
283
+ bottom,
284
+ left,
285
+ right,
286
+ top,
287
+ width,
288
+ x,
289
+ y,
290
+ update
291
+ };
292
+ }
293
+
294
+ function useElementVisibility(element, { window = defaultWindow, scrollTarget } = {}) {
295
+ const elementIsVisible = vue.ref(false);
296
+ const testBounding = () => {
297
+ if (!window)
298
+ return;
299
+ const document = window.document;
300
+ const el = unrefElement(element);
301
+ if (!el) {
302
+ elementIsVisible.value = false;
303
+ } else {
304
+ const rect = el.getBoundingClientRect();
305
+ elementIsVisible.value = rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.left <= (window.innerWidth || document.documentElement.clientWidth) && rect.bottom >= 0 && rect.right >= 0;
306
+ }
307
+ };
308
+ vue.watch(() => unrefElement(element), () => testBounding(), { immediate: true, flush: "post" });
309
+ if (window) {
310
+ useEventListener(scrollTarget || window, "scroll", testBounding, {
311
+ capture: false,
312
+ passive: true
313
+ });
314
+ }
315
+ return elementIsVisible;
316
+ }
317
+
318
+ var SwipeDirection;
319
+ (function(SwipeDirection2) {
320
+ SwipeDirection2["UP"] = "UP";
321
+ SwipeDirection2["RIGHT"] = "RIGHT";
322
+ SwipeDirection2["DOWN"] = "DOWN";
323
+ SwipeDirection2["LEFT"] = "LEFT";
324
+ SwipeDirection2["NONE"] = "NONE";
325
+ })(SwipeDirection || (SwipeDirection = {}));
326
+
327
+ var __defProp = Object.defineProperty;
328
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
329
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
330
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
331
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
332
+ var __spreadValues = (a, b) => {
333
+ for (var prop in b || (b = {}))
334
+ if (__hasOwnProp.call(b, prop))
335
+ __defNormalProp(a, prop, b[prop]);
336
+ if (__getOwnPropSymbols)
337
+ for (var prop of __getOwnPropSymbols(b)) {
338
+ if (__propIsEnum.call(b, prop))
339
+ __defNormalProp(a, prop, b[prop]);
340
+ }
341
+ return a;
342
+ };
343
+ const _TransitionPresets = {
344
+ easeInSine: [0.12, 0, 0.39, 0],
345
+ easeOutSine: [0.61, 1, 0.88, 1],
346
+ easeInOutSine: [0.37, 0, 0.63, 1],
347
+ easeInQuad: [0.11, 0, 0.5, 0],
348
+ easeOutQuad: [0.5, 1, 0.89, 1],
349
+ easeInOutQuad: [0.45, 0, 0.55, 1],
350
+ easeInCubic: [0.32, 0, 0.67, 0],
351
+ easeOutCubic: [0.33, 1, 0.68, 1],
352
+ easeInOutCubic: [0.65, 0, 0.35, 1],
353
+ easeInQuart: [0.5, 0, 0.75, 0],
354
+ easeOutQuart: [0.25, 1, 0.5, 1],
355
+ easeInOutQuart: [0.76, 0, 0.24, 1],
356
+ easeInQuint: [0.64, 0, 0.78, 0],
357
+ easeOutQuint: [0.22, 1, 0.36, 1],
358
+ easeInOutQuint: [0.83, 0, 0.17, 1],
359
+ easeInExpo: [0.7, 0, 0.84, 0],
360
+ easeOutExpo: [0.16, 1, 0.3, 1],
361
+ easeInOutExpo: [0.87, 0, 0.13, 1],
362
+ easeInCirc: [0.55, 0, 1, 0.45],
363
+ easeOutCirc: [0, 0.55, 0.45, 1],
364
+ easeInOutCirc: [0.85, 0, 0.15, 1],
365
+ easeInBack: [0.36, 0, 0.66, -0.56],
366
+ easeOutBack: [0.34, 1.56, 0.64, 1],
367
+ easeInOutBack: [0.68, -0.6, 0.32, 1.6]
368
+ };
369
+ __spreadValues({
370
+ linear: identity
371
+ }, _TransitionPresets);
372
+
373
+ function useVModel(props, key, emit, options = {}) {
374
+ var _a, _b, _c;
375
+ const {
376
+ clone = false,
377
+ passive = false,
378
+ eventName,
379
+ deep = false,
380
+ defaultValue
381
+ } = options;
382
+ const vm = vue.getCurrentInstance();
383
+ const _emit = emit || (vm == null ? void 0 : vm.emit) || ((_a = vm == null ? void 0 : vm.$emit) == null ? void 0 : _a.bind(vm)) || ((_c = (_b = vm == null ? void 0 : vm.proxy) == null ? void 0 : _b.$emit) == null ? void 0 : _c.bind(vm == null ? void 0 : vm.proxy));
384
+ let event = eventName;
385
+ if (!key) {
386
+ {
387
+ key = "modelValue";
388
+ }
389
+ }
390
+ event = eventName || event || `update:${key.toString()}`;
391
+ const cloneFn = (val) => !clone ? val : isFunction(clone) ? clone(val) : cloneFnJSON(val);
392
+ const getValue = () => isDef(props[key]) ? cloneFn(props[key]) : defaultValue;
393
+ if (passive) {
394
+ const initialValue = getValue();
395
+ const proxy = vue.ref(initialValue);
396
+ vue.watch(() => props[key], (v) => proxy.value = cloneFn(v));
397
+ vue.watch(proxy, (v) => {
398
+ if (v !== props[key] || deep)
399
+ _emit(event, v);
400
+ }, { deep });
401
+ return proxy;
402
+ } else {
403
+ return vue.computed({
404
+ get() {
405
+ return getValue();
406
+ },
407
+ set(value) {
408
+ _emit(event, value);
409
+ }
410
+ });
411
+ }
412
+ }
413
+
8
414
  const affixProps = shared.defineHookProps(
9
415
  {
10
416
  fixedClass: {
@@ -54,8 +460,8 @@ function getTargetRect(target) {
54
460
  const useAffix = shared.defineHookComponent({
55
461
  props: affixProps,
56
462
  setup(props, { emit }) {
57
- const wrapperRef = vue.ref();
58
- const wrapperRect = shared.toReactive(core.useElementBounding(wrapperRef));
463
+ const wrapperRef = shared.elementRef();
464
+ const wrapperRect = shared.toReactive(useElementBounding(wrapperRef));
59
465
  const parentRef = vue.inject(AFFIX_TARGET_KEY, void 0);
60
466
  const targetRef = shared.useElement(props.target, parentRef);
61
467
  const isFixed = vue.ref(false);
@@ -64,7 +470,7 @@ const useAffix = shared.defineHookComponent({
64
470
  const className = vue.computed(() => {
65
471
  return isFixed.value ? props.fixedClass : "";
66
472
  });
67
- const wrapperVisible = core.useElementVisibility(wrapperRef);
473
+ const wrapperVisible = useElementVisibility(wrapperRef);
68
474
  const containerRef = vue.computed(() => {
69
475
  if (!wrapperVisible.value) {
70
476
  return null;
@@ -111,11 +517,11 @@ const useAffix = shared.defineHookComponent({
111
517
  ...newIsFixed ? newPlaceholderStyles : {}
112
518
  };
113
519
  });
114
- core.useEventListener(containerRef, "scroll", () => {
520
+ useEventListener(containerRef, "scroll", () => {
115
521
  emit("scroll");
116
522
  updatePosition();
117
523
  });
118
- core.useEventListener(containerRef, "resize", updatePosition);
524
+ useEventListener(containerRef, "resize", updatePosition);
119
525
  vue.watchPostEffect(updatePosition);
120
526
  return {
121
527
  className,
@@ -132,6 +538,150 @@ function provideAffixTarget(target) {
132
538
  vue.provide(AFFIX_TARGET_KEY, target);
133
539
  }
134
540
 
541
+ const configProviderProps = shared.defineHookProps({
542
+ icon: {
543
+ type: Object
544
+ },
545
+ activateEvent: {
546
+ type: String
547
+ }
548
+ });
549
+
550
+ const fileUploadProps = shared.defineHookProps({
551
+ modelValue: {
552
+ type: [File, Array],
553
+ default: () => []
554
+ },
555
+ multiple: {
556
+ type: Boolean,
557
+ default: false
558
+ }
559
+ });
560
+ const fileUploadEmits = shared.defineHookEmits([
561
+ "update:modelValue",
562
+ "change"
563
+ ]);
564
+ const useFileUpload = shared.defineHookComponent({
565
+ props: fileUploadProps,
566
+ emits: fileUploadEmits,
567
+ setup(props, { emit }) {
568
+ const fileInputRef = shared.elementRef();
569
+ const files = vue.ref([]);
570
+ vue.watch(props.modelValue, (value) => {
571
+ if (value instanceof File) {
572
+ files.value.push(value);
573
+ } else if (Array.isArray(value)) {
574
+ files.value.push(...value);
575
+ }
576
+ if (props.multiple) {
577
+ files.value.splice(1, files.value.length - 1);
578
+ }
579
+ }, {
580
+ immediate: true,
581
+ deep: true
582
+ });
583
+ const openFileInput = () => {
584
+ fileInputRef.value?.click();
585
+ };
586
+ useEventListener(fileInputRef, "change", (event) => {
587
+ const newFiles = event.target.files;
588
+ let value = [];
589
+ if (newFiles) {
590
+ if (props.multiple) {
591
+ value = Array.from(newFiles);
592
+ files.value.push(...value);
593
+ } else {
594
+ value = Array.from(newFiles)[0];
595
+ files.value = value ? [value] : [];
596
+ }
597
+ }
598
+ emit("update:modelValue", value);
599
+ emit("change", value);
600
+ });
601
+ return {
602
+ fileInputRef,
603
+ files,
604
+ openFileInput
605
+ };
606
+ }
607
+ });
608
+
609
+ const iconProps = shared.defineHookProps({
610
+ src: {
611
+ type: String,
612
+ required: true
613
+ },
614
+ size: {
615
+ type: [Number, String]
616
+ },
617
+ width: {
618
+ type: [Number, String]
619
+ },
620
+ height: {
621
+ type: [Number, String]
622
+ },
623
+ color: {
624
+ type: String,
625
+ default: "currentColor"
626
+ },
627
+ mask: {
628
+ type: [Boolean, String],
629
+ default: () => "auto"
630
+ }
631
+ });
632
+ const isSvg = (src) => src.endsWith(".svg") || src.startsWith("data:image/svg+xml");
633
+ const useIcon = shared.defineHookComponent({
634
+ props: iconProps,
635
+ setup(props, context) {
636
+ const sharedConfig = shared.useSharedConfig("icon");
637
+ const sizeStyle = vue.computed(() => {
638
+ const s = props.size ?? sharedConfig.size;
639
+ const unit = tslx.createUnitFormat(sharedConfig.sizeUnit ?? "px");
640
+ const size = s ? unit(s) : void 0;
641
+ const w = props.width ?? size;
642
+ const h = props.height ?? size;
643
+ const width = w ? unit(w) : void 0;
644
+ const height = h ? unit(h) : void 0;
645
+ return {
646
+ width,
647
+ height
648
+ };
649
+ });
650
+ const dynamicStyle = vue.computed(() => {
651
+ const mask = props.mask === "auto" ? isSvg(props.src) : props.mask;
652
+ if (!mask) {
653
+ return {
654
+ "background-image": "var(--icon-url)",
655
+ "background-size": "100% 100%"
656
+ };
657
+ }
658
+ return {
659
+ "mask": "var(--icon-url) no-repeat",
660
+ "mask-size": "100% 100%",
661
+ "-webkit-mask": "var(--icon-url) no-repeat",
662
+ "-webkit-mask-size": "100% 100%",
663
+ "background-color": props.color
664
+ };
665
+ });
666
+ const staticStyle = vue.computed(() => {
667
+ return {
668
+ "--icon-url": `url("${props.src}")`
669
+ };
670
+ });
671
+ const style = vue.computed(() => {
672
+ return {
673
+ ...staticStyle.value,
674
+ ...dynamicStyle.value,
675
+ ...sizeStyle.value,
676
+ ...context.attrs.style ?? {}
677
+ };
678
+ });
679
+ return {
680
+ style
681
+ };
682
+ }
683
+ });
684
+
135
685
  const selectionProps = shared.defineHookProps({
136
686
  modelValue: {
137
687
  type: shared.valuePropType,
@@ -217,7 +767,7 @@ const useSelectionList = shared.defineHookComponent({
217
767
  setup(props, { emit, slots }) {
218
768
  const options = vue.reactive([]);
219
769
  function toArray(value) {
220
- if (!core.isDefined(value)) {
770
+ if (!isDefined(value)) {
221
771
  return [];
222
772
  }
223
773
  if (props.multiple && Array.isArray(value)) {
@@ -244,7 +794,7 @@ const useSelectionList = shared.defineHookComponent({
244
794
  emit("update:modelValue", val);
245
795
  }
246
796
  });
247
- core.syncRef(currentValue, modelValue, { immediate: true, deep: true });
797
+ syncRef(currentValue, modelValue, { immediate: true, deep: true });
248
798
  const emitChange = () => emit("change", currentValue.value);
249
799
  function isActive(value) {
250
800
  return actives.includes(value);
@@ -407,7 +957,7 @@ const useSelectionItem = shared.defineHookComponent({
407
957
  },
408
958
  { immediate: true }
409
959
  );
410
- core.tryOnScopeDispose(remove);
960
+ tryOnScopeDispose(remove);
411
961
  }
412
962
  const isActive = vue.computed(() => context.isActive(props.value));
413
963
  const isDisabled = vue.computed(() => props.disabled);
@@ -433,157 +983,6 @@ const useSelectionItem = shared.defineHookComponent({
433
983
  }
434
984
  });
435
985
 
436
- const switchProps = shared.defineHookProps({
437
- modelValue: {
438
- type: Boolean,
439
- default: () => false
440
- },
441
- class: {
442
- type: shared.classPropType
443
- },
444
- activeClass: {
445
- type: shared.classPropType
446
- },
447
- unactiveClass: {
448
- type: shared.classPropType
449
- },
450
- activateEvent: {
451
- type: String
452
- },
453
- disabled: {
454
- type: Boolean,
455
- default: () => false
456
- },
457
- disabledClass: {
458
- type: shared.classPropType
459
- }
460
- });
461
- const switchEmits = shared.defineHookEmits(["update:modelValue", "change", "reject"]);
462
- const useSwitch = shared.defineHookComponent({
463
- props: switchProps,
464
- emits: switchEmits,
465
- setup(props, context) {
466
- const modelValue = core.useVModel(props, "modelValue", context.emit, {
467
- passive: true,
468
- defaultValue: false
469
- });
470
- const toggle = function(value) {
471
- if (props.disabled) {
472
- context.emit("reject", value);
473
- return;
474
- }
475
- const oldValue = modelValue.value;
476
- const newValue = typeof value === "boolean" ? value : !oldValue;
477
- if (newValue !== oldValue) {
478
- modelValue.value = newValue;
479
- context.emit("change", newValue);
480
- }
481
- };
482
- const isDisabled = vue.computed(() => props.disabled);
483
- const className = vue.computed(() => {
484
- return tslx.cls([
485
- props.class,
486
- modelValue.value ? props.activeClass : props.unactiveClass,
487
- isDisabled.value ? props.disabledClass : ""
488
- ]);
489
- });
490
- const sharedConfig = shared.useSharedConfig();
491
- const activateEvent = vue.computed(() => props.activateEvent ?? sharedConfig.activateEvent);
492
- return {
493
- toggle,
494
- modelValue,
495
- className,
496
- isDisabled,
497
- activateEvent
498
- };
499
- }
500
- });
501
-
502
- const iconProps = shared.defineHookProps({
503
- src: {
504
- type: String,
505
- required: true
506
- },
507
- size: {
508
- type: [Number, String]
509
- },
510
- width: {
511
- type: [Number, String]
512
- },
513
- height: {
514
- type: [Number, String]
515
- },
516
- color: {
517
- type: String,
518
- default: "currentColor"
519
- },
520
- mask: {
521
- type: [Boolean, String],
522
- default: () => "auto"
523
- }
524
- });
525
- const isSvg = (src) => src.endsWith(".svg") || src.startsWith("data:image/svg+xml");
526
- const useIcon = shared.defineHookComponent({
527
- props: iconProps,
528
- setup(props, context) {
529
- const sharedConfig = shared.useSharedConfig("icon");
530
- const sizeStyle = vue.computed(() => {
531
- const s = props.size ?? sharedConfig.size;
532
- const unit = tslx.createUnitFormat(sharedConfig.sizeUnit ?? "px");
533
- const size = s ? unit(s) : void 0;
534
- const w = props.width ?? size;
535
- const h = props.height ?? size;
536
- const width = w ? unit(w) : void 0;
537
- const height = h ? unit(h) : void 0;
538
- return {
539
- width,
540
- height
541
- };
542
- });
543
- const dynamicStyle = vue.computed(() => {
544
- const mask = props.mask === "auto" ? isSvg(props.src) : props.mask;
545
- if (!mask) {
546
- return {
547
- "background-image": "var(--icon-url)",
548
- "background-size": "100% 100%"
549
- };
550
- }
551
- return {
552
- "mask": "var(--icon-url) no-repeat",
553
- "mask-size": "100% 100%",
554
- "-webkit-mask": "var(--icon-url) no-repeat",
555
- "-webkit-mask-size": "100% 100%",
556
- "background-color": props.color
557
- };
558
- });
559
- const staticStyle = vue.computed(() => {
560
- return {
561
- "--icon-url": `url("${props.src}")`
562
- };
563
- });
564
- const style = vue.computed(() => {
565
- return {
566
- ...staticStyle.value,
567
- ...dynamicStyle.value,
568
- ...sizeStyle.value,
569
- ...context.attrs.style ?? {}
570
- };
571
- });
572
- return {
573
- style
574
- };
575
- }
576
- });
577
-
578
- const configProviderProps = shared.defineHookProps({
579
- icon: {
580
- type: Object
581
- },
582
- activateEvent: {
583
- type: String
584
- }
585
- });
586
-
587
986
  const popoverProps = shared.defineHookProps({
588
987
  popupClass: {
589
988
  type: String
@@ -622,11 +1021,11 @@ const usePopover = shared.defineHookComponent({
622
1021
  props: popoverProps,
623
1022
  emits: popoverEmits,
624
1023
  setup(props, context) {
625
- const visible = core.useVModel(props, "visible", context.emit, {
1024
+ const visible = useVModel(props, "visible", context.emit, {
626
1025
  passive: true
627
1026
  });
628
- const triggerRef = vue.ref();
629
- const popupRef = vue.ref();
1027
+ const triggerRef = shared.elementRef();
1028
+ const popupRef = shared.elementRef();
630
1029
  const validate = (event) => {
631
1030
  const events2 = Array.isArray(event) ? event : [event];
632
1031
  return !props.disabled && events2.includes(props.triggerEvent);
@@ -663,7 +1062,7 @@ const usePopover = shared.defineHookComponent({
663
1062
  e.stopPropagation();
664
1063
  toggle();
665
1064
  };
666
- core.onClickOutside(triggerRef, () => {
1065
+ onClickOutside(triggerRef, () => {
667
1066
  if (!validate(["click", "contextmenu", "touch", "dblclick", "mousedown"])) {
668
1067
  return;
669
1068
  }
@@ -817,10 +1216,78 @@ const usePopover = shared.defineHookComponent({
817
1216
  }
818
1217
  });
819
1218
 
1219
+ const switchProps = shared.defineHookProps({
1220
+ modelValue: {
1221
+ type: Boolean,
1222
+ default: () => false
1223
+ },
1224
+ class: {
1225
+ type: shared.classPropType
1226
+ },
1227
+ activeClass: {
1228
+ type: shared.classPropType
1229
+ },
1230
+ unactiveClass: {
1231
+ type: shared.classPropType
1232
+ },
1233
+ activateEvent: {
1234
+ type: String
1235
+ },
1236
+ disabled: {
1237
+ type: Boolean,
1238
+ default: () => false
1239
+ },
1240
+ disabledClass: {
1241
+ type: shared.classPropType
1242
+ }
1243
+ });
1244
+ const switchEmits = shared.defineHookEmits(["update:modelValue", "change", "reject"]);
1245
+ const useSwitch = shared.defineHookComponent({
1246
+ props: switchProps,
1247
+ emits: switchEmits,
1248
+ setup(props, context) {
1249
+ const modelValue = useVModel(props, "modelValue", context.emit, {
1250
+ passive: true,
1251
+ defaultValue: false
1252
+ });
1253
+ const toggle = function(value) {
1254
+ if (props.disabled) {
1255
+ context.emit("reject", value);
1256
+ return;
1257
+ }
1258
+ const oldValue = modelValue.value;
1259
+ const newValue = typeof value === "boolean" ? value : !oldValue;
1260
+ if (newValue !== oldValue) {
1261
+ modelValue.value = newValue;
1262
+ context.emit("change", newValue);
1263
+ }
1264
+ };
1265
+ const isDisabled = vue.computed(() => props.disabled);
1266
+ const className = vue.computed(() => {
1267
+ return tslx.cls([
1268
+ props.class,
1269
+ modelValue.value ? props.activeClass : props.unactiveClass,
1270
+ isDisabled.value ? props.disabledClass : ""
1271
+ ]);
1272
+ });
1273
+ const sharedConfig = shared.useSharedConfig();
1274
+ const activateEvent = vue.computed(() => props.activateEvent ?? sharedConfig.activateEvent);
1275
+ return {
1276
+ toggle,
1277
+ modelValue,
1278
+ className,
1279
+ isDisabled,
1280
+ activateEvent
1281
+ };
1282
+ }
1283
+ });
1284
+
820
1285
  exports.AFFIX_TARGET_KEY = AFFIX_TARGET_KEY;
821
1286
  exports.affixEmits = affixEmits;
822
1287
  exports.affixProps = affixProps;
823
1288
  exports.configProviderProps = configProviderProps;
1289
+ exports.fileUploadEmits = fileUploadEmits;
1290
+ exports.fileUploadProps = fileUploadProps;
824
1291
  exports.iconProps = iconProps;
825
1292
  exports.itemEmits = itemEmits;
826
1293
  exports.itemProps = itemProps;
@@ -832,12 +1299,20 @@ exports.selectionProps = selectionProps;
832
1299
  exports.switchEmits = switchEmits;
833
1300
  exports.switchProps = switchProps;
834
1301
  exports.useAffix = useAffix;
1302
+ exports.useFileUpload = useFileUpload;
835
1303
  exports.useIcon = useIcon;
836
1304
  exports.usePopover = usePopover;
837
1305
  exports.useSelectionContext = useSelectionContext;
838
1306
  exports.useSelectionItem = useSelectionItem;
839
1307
  exports.useSelectionList = useSelectionList;
840
1308
  exports.useSwitch = useSwitch;
1309
+ Object.prototype.hasOwnProperty.call(shared, '__proto__') &&
1310
+ !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
1311
+ Object.defineProperty(exports, '__proto__', {
1312
+ enumerable: true,
1313
+ value: shared['__proto__']
1314
+ });
1315
+
841
1316
  Object.keys(shared).forEach(function (k) {
842
1317
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = shared[k];
843
1318
  });