rx-compo 1.0.52 → 1.0.54

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.
Files changed (77) hide show
  1. package/entry/types/index.d.ts +0 -1
  2. package/es/components/RxButton/index.js +16 -25
  3. package/es/components/RxCheckbox/index.js +3712 -0
  4. package/es/components/RxCheckboxGroup/index.js +6430 -0
  5. package/es/components/RxDatePicker/index.js +13042 -0
  6. package/es/components/RxInput/index.js +1560 -0
  7. package/es/components/RxOption/index.js +8859 -0
  8. package/es/components/RxRadio/index.js +646 -0
  9. package/es/components/RxRadioButton/index.js +646 -0
  10. package/es/components/RxRadioGroup/index.js +1117 -0
  11. package/es/components/RxScrollbar/index.js +867 -0
  12. package/es/components/RxSelect/index.js +9022 -0
  13. package/es/components/RxSelectPlus/index.js +17471 -0
  14. package/es/components/RxSuperCondition/index.js +8690 -0
  15. package/es/components/RxTooltip/index.js +2470 -0
  16. package/es/components/index.js +13 -0
  17. package/es/index.d.ts +0 -1
  18. package/es/index.js +0 -1
  19. package/es/utils/useContext.d.ts +10 -0
  20. package/es/utils/useContext.js +13 -0
  21. package/es/utils/useTextOverflow.d.ts +4 -0
  22. package/es/utils/useTextOverflow.js +13 -0
  23. package/es/utils/with-install.d.ts +3 -0
  24. package/es/utils/with-install.js +7 -0
  25. package/index.esm.js +43171 -1577
  26. package/index.js +43192 -1585
  27. package/lib/components/RxButton/index.js +15 -24
  28. package/lib/components/RxCheckbox/index.js +3717 -0
  29. package/lib/components/RxCheckboxGroup/index.js +6435 -0
  30. package/lib/components/RxDatePicker/index.js +13047 -0
  31. package/lib/components/RxInput/index.js +1565 -0
  32. package/lib/components/RxOption/index.js +8864 -0
  33. package/lib/components/RxRadio/index.js +651 -0
  34. package/lib/components/RxRadioButton/index.js +651 -0
  35. package/lib/components/RxRadioGroup/index.js +1122 -0
  36. package/lib/components/RxScrollbar/index.js +872 -0
  37. package/lib/components/RxSelect/index.js +9027 -0
  38. package/lib/components/RxSelectPlus/index.js +17476 -0
  39. package/lib/components/RxSuperCondition/index.js +8695 -0
  40. package/lib/components/RxTooltip/index.js +2475 -0
  41. package/lib/components/index.js +91 -0
  42. package/lib/index.d.ts +0 -1
  43. package/lib/index.js +0 -1
  44. package/lib/utils/useContext.d.ts +10 -0
  45. package/lib/utils/useContext.js +18 -0
  46. package/lib/utils/useTextOverflow.d.ts +4 -0
  47. package/lib/utils/useTextOverflow.js +17 -0
  48. package/lib/utils/with-install.d.ts +3 -0
  49. package/lib/utils/with-install.js +11 -0
  50. package/package.json +4 -2
  51. package/theme-chalk/css/index.css +1 -1
  52. package/theme-chalk/css/rx-button.css +1 -0
  53. package/theme-chalk/css/rx-checkbox-group.css +1 -0
  54. package/theme-chalk/css/rx-checkbox.css +1 -0
  55. package/theme-chalk/css/rx-date-picker.css +0 -0
  56. package/theme-chalk/css/rx-input.css +1 -0
  57. package/theme-chalk/css/rx-option.css +1 -0
  58. package/theme-chalk/css/rx-radio-button.css +0 -0
  59. package/theme-chalk/css/rx-radio-group.css +1 -0
  60. package/theme-chalk/css/rx-radio.css +1 -0
  61. package/theme-chalk/css/rx-scrollbar.css +0 -0
  62. package/theme-chalk/css/rx-select.css +1 -0
  63. package/theme-chalk/css/rx-super-condition.css +0 -0
  64. package/theme-chalk/css/rx-tooltip.css +0 -0
  65. package/es/components/RxButton/index.d.ts +0 -3
  66. package/es/components/RxButton/src/index.d.ts +0 -3
  67. package/es/components/RxButton/src/index.vue.d.ts +0 -10
  68. package/es/components/index.d.ts +0 -2
  69. package/lib/components/RxButton/index.d.ts +0 -3
  70. package/lib/components/RxButton/src/index.d.ts +0 -3
  71. package/lib/components/RxButton/src/index.vue.d.ts +0 -10
  72. package/lib/components/index.d.ts +0 -2
  73. package/types/components/RxButton/index.d.ts +0 -3
  74. package/types/components/RxButton/src/index.d.ts +0 -3
  75. package/types/components/RxButton/src/index.vue.d.ts +0 -10
  76. package/types/components/index.d.ts +0 -2
  77. package/types/utils/with-install.d.ts +0 -3
@@ -0,0 +1,867 @@
1
+ import { withInstall as withInstall$1 } from 'rx-compo/es/utils/with-install';
2
+ import { warn, inject, ref as ref$1, computed, unref as unref$1, defineComponent, onBeforeUnmount, toRef, openBlock, createBlock, Transition, withCtx, withDirectives, createElementVNode, normalizeClass, normalizeStyle, vShow, createElementBlock, Fragment, createVNode, watch as watch$1, nextTick as nextTick$1, provide, reactive, onMounted as onMounted$1, onUpdated, resolveDynamicComponent, renderSlot, createCommentVNode, resolveComponent, normalizeProps, guardReactiveProps } from 'vue';
3
+ import { unref, getCurrentScope, onScopeDispose, getCurrentInstance, onMounted, nextTick, watch, ref } from 'vue-demi';
4
+
5
+ var _a;
6
+ const isClient = typeof window !== "undefined";
7
+ const isString$1 = (val) => typeof val === "string";
8
+ const noop = () => {
9
+ };
10
+ isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
11
+
12
+ function resolveUnref(r) {
13
+ return typeof r === "function" ? r() : unref(r);
14
+ }
15
+ function identity(arg) {
16
+ return arg;
17
+ }
18
+
19
+ function tryOnScopeDispose(fn) {
20
+ if (getCurrentScope()) {
21
+ onScopeDispose(fn);
22
+ return true;
23
+ }
24
+ return false;
25
+ }
26
+
27
+ function tryOnMounted(fn, sync = true) {
28
+ if (getCurrentInstance())
29
+ onMounted(fn);
30
+ else if (sync)
31
+ fn();
32
+ else
33
+ nextTick(fn);
34
+ }
35
+
36
+ function unrefElement(elRef) {
37
+ var _a;
38
+ const plain = resolveUnref(elRef);
39
+ return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
40
+ }
41
+
42
+ const defaultWindow = isClient ? window : void 0;
43
+ isClient ? window.document : void 0;
44
+ isClient ? window.navigator : void 0;
45
+ isClient ? window.location : void 0;
46
+
47
+ function useEventListener(...args) {
48
+ let target;
49
+ let events;
50
+ let listeners;
51
+ let options;
52
+ if (isString$1(args[0]) || Array.isArray(args[0])) {
53
+ [events, listeners, options] = args;
54
+ target = defaultWindow;
55
+ } else {
56
+ [target, events, listeners, options] = args;
57
+ }
58
+ if (!target)
59
+ return noop;
60
+ if (!Array.isArray(events))
61
+ events = [events];
62
+ if (!Array.isArray(listeners))
63
+ listeners = [listeners];
64
+ const cleanups = [];
65
+ const cleanup = () => {
66
+ cleanups.forEach((fn) => fn());
67
+ cleanups.length = 0;
68
+ };
69
+ const register = (el, event, listener, options2) => {
70
+ el.addEventListener(event, listener, options2);
71
+ return () => el.removeEventListener(event, listener, options2);
72
+ };
73
+ const stopWatch = watch(() => [unrefElement(target), resolveUnref(options)], ([el, options2]) => {
74
+ cleanup();
75
+ if (!el)
76
+ return;
77
+ cleanups.push(...events.flatMap((event) => {
78
+ return listeners.map((listener) => register(el, event, listener, options2));
79
+ }));
80
+ }, { immediate: true, flush: "post" });
81
+ const stop = () => {
82
+ stopWatch();
83
+ cleanup();
84
+ };
85
+ tryOnScopeDispose(stop);
86
+ return stop;
87
+ }
88
+
89
+ function useSupported(callback, sync = false) {
90
+ const isSupported = ref();
91
+ const update = () => isSupported.value = Boolean(callback());
92
+ update();
93
+ tryOnMounted(update, sync);
94
+ return isSupported;
95
+ }
96
+
97
+ const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
98
+ const globalKey = "__vueuse_ssr_handlers__";
99
+ _global[globalKey] = _global[globalKey] || {};
100
+ _global[globalKey];
101
+
102
+ var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
103
+ var __hasOwnProp$g = Object.prototype.hasOwnProperty;
104
+ var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
105
+ var __objRest$2 = (source, exclude) => {
106
+ var target = {};
107
+ for (var prop in source)
108
+ if (__hasOwnProp$g.call(source, prop) && exclude.indexOf(prop) < 0)
109
+ target[prop] = source[prop];
110
+ if (source != null && __getOwnPropSymbols$g)
111
+ for (var prop of __getOwnPropSymbols$g(source)) {
112
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$g.call(source, prop))
113
+ target[prop] = source[prop];
114
+ }
115
+ return target;
116
+ };
117
+ function useResizeObserver(target, callback, options = {}) {
118
+ const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest$2(_a, ["window"]);
119
+ let observer;
120
+ const isSupported = useSupported(() => window && "ResizeObserver" in window);
121
+ const cleanup = () => {
122
+ if (observer) {
123
+ observer.disconnect();
124
+ observer = void 0;
125
+ }
126
+ };
127
+ const stopWatch = watch(() => unrefElement(target), (el) => {
128
+ cleanup();
129
+ if (isSupported.value && window && el) {
130
+ observer = new ResizeObserver(callback);
131
+ observer.observe(el, observerOptions);
132
+ }
133
+ }, { immediate: true, flush: "post" });
134
+ const stop = () => {
135
+ cleanup();
136
+ stopWatch();
137
+ };
138
+ tryOnScopeDispose(stop);
139
+ return {
140
+ isSupported,
141
+ stop
142
+ };
143
+ }
144
+
145
+ var SwipeDirection;
146
+ (function(SwipeDirection2) {
147
+ SwipeDirection2["UP"] = "UP";
148
+ SwipeDirection2["RIGHT"] = "RIGHT";
149
+ SwipeDirection2["DOWN"] = "DOWN";
150
+ SwipeDirection2["LEFT"] = "LEFT";
151
+ SwipeDirection2["NONE"] = "NONE";
152
+ })(SwipeDirection || (SwipeDirection = {}));
153
+
154
+ var __defProp = Object.defineProperty;
155
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
156
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
157
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
158
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
159
+ var __spreadValues = (a, b) => {
160
+ for (var prop in b || (b = {}))
161
+ if (__hasOwnProp.call(b, prop))
162
+ __defNormalProp(a, prop, b[prop]);
163
+ if (__getOwnPropSymbols)
164
+ for (var prop of __getOwnPropSymbols(b)) {
165
+ if (__propIsEnum.call(b, prop))
166
+ __defNormalProp(a, prop, b[prop]);
167
+ }
168
+ return a;
169
+ };
170
+ const _TransitionPresets = {
171
+ easeInSine: [0.12, 0, 0.39, 0],
172
+ easeOutSine: [0.61, 1, 0.88, 1],
173
+ easeInOutSine: [0.37, 0, 0.63, 1],
174
+ easeInQuad: [0.11, 0, 0.5, 0],
175
+ easeOutQuad: [0.5, 1, 0.89, 1],
176
+ easeInOutQuad: [0.45, 0, 0.55, 1],
177
+ easeInCubic: [0.32, 0, 0.67, 0],
178
+ easeOutCubic: [0.33, 1, 0.68, 1],
179
+ easeInOutCubic: [0.65, 0, 0.35, 1],
180
+ easeInQuart: [0.5, 0, 0.75, 0],
181
+ easeOutQuart: [0.25, 1, 0.5, 1],
182
+ easeInOutQuart: [0.76, 0, 0.24, 1],
183
+ easeInQuint: [0.64, 0, 0.78, 0],
184
+ easeOutQuint: [0.22, 1, 0.36, 1],
185
+ easeInOutQuint: [0.83, 0, 0.17, 1],
186
+ easeInExpo: [0.7, 0, 0.84, 0],
187
+ easeOutExpo: [0.16, 1, 0.3, 1],
188
+ easeInOutExpo: [0.87, 0, 0.13, 1],
189
+ easeInCirc: [0.55, 0, 1, 0.45],
190
+ easeOutCirc: [0, 0.55, 0.45, 1],
191
+ easeInOutCirc: [0.85, 0, 0.15, 1],
192
+ easeInBack: [0.36, 0, 0.66, -0.56],
193
+ easeOutBack: [0.34, 1.56, 0.64, 1],
194
+ easeInOutBack: [0.68, -0.6, 0.32, 1.6]
195
+ };
196
+ __spreadValues({
197
+ linear: identity
198
+ }, _TransitionPresets);
199
+
200
+ !!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
201
+ !!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
202
+ const hasOwnProperty = Object.prototype.hasOwnProperty;
203
+ const hasOwn = (val, key) => hasOwnProperty.call(val, key);
204
+ const isString = (val) => typeof val === "string";
205
+ const isObject = (val) => val !== null && typeof val === "object";
206
+
207
+ /**
208
+ * The inverse of `_.toPairs`; this method returns an object composed
209
+ * from key-value `pairs`.
210
+ *
211
+ * @static
212
+ * @memberOf _
213
+ * @since 4.0.0
214
+ * @category Array
215
+ * @param {Array} pairs The key-value pairs.
216
+ * @returns {Object} Returns the new object.
217
+ * @example
218
+ *
219
+ * _.fromPairs([['a', 1], ['b', 2]]);
220
+ * // => { 'a': 1, 'b': 2 }
221
+ */
222
+ function fromPairs(pairs) {
223
+ var index = -1,
224
+ length = pairs == null ? 0 : pairs.length,
225
+ result = {};
226
+
227
+ while (++index < length) {
228
+ var pair = pairs[index];
229
+ result[pair[0]] = pair[1];
230
+ }
231
+ return result;
232
+ }
233
+
234
+ const isNumber = (val) => typeof val === "number";
235
+ const isStringNumber = (val) => {
236
+ if (!isString(val)) {
237
+ return false;
238
+ }
239
+ return !Number.isNaN(Number(val));
240
+ };
241
+
242
+ class ElementPlusError extends Error {
243
+ constructor(m) {
244
+ super(m);
245
+ this.name = "ElementPlusError";
246
+ }
247
+ }
248
+ function throwError(scope, m) {
249
+ throw new ElementPlusError(`[${scope}] ${m}`);
250
+ }
251
+ function debugWarn(scope, message) {
252
+ if (process.env.NODE_ENV !== "production") {
253
+ const error = isString(scope) ? new ElementPlusError(`[${scope}] ${message}`) : scope;
254
+ console.warn(error);
255
+ }
256
+ }
257
+
258
+ const SCOPE = "utils/dom/style";
259
+ function addUnit(value, defaultUnit = "px") {
260
+ if (!value)
261
+ return "";
262
+ if (isNumber(value) || isStringNumber(value)) {
263
+ return `${value}${defaultUnit}`;
264
+ } else if (isString(value)) {
265
+ return value;
266
+ }
267
+ debugWarn(SCOPE, "binding value must be a string or number");
268
+ }
269
+
270
+ const epPropKey = "__epPropKey";
271
+ const definePropType = (val) => val;
272
+ const isEpProp = (val) => isObject(val) && !!val[epPropKey];
273
+ const buildProp = (prop, key) => {
274
+ if (!isObject(prop) || isEpProp(prop))
275
+ return prop;
276
+ const { values, required, default: defaultValue, type, validator } = prop;
277
+ const _validator = values || validator ? (val) => {
278
+ let valid = false;
279
+ let allowedValues = [];
280
+ if (values) {
281
+ allowedValues = Array.from(values);
282
+ if (hasOwn(prop, "default")) {
283
+ allowedValues.push(defaultValue);
284
+ }
285
+ valid || (valid = allowedValues.includes(val));
286
+ }
287
+ if (validator)
288
+ valid || (valid = validator(val));
289
+ if (!valid && allowedValues.length > 0) {
290
+ const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", ");
291
+ warn(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`);
292
+ }
293
+ return valid;
294
+ } : void 0;
295
+ const epProp = {
296
+ type,
297
+ required: !!required,
298
+ validator: _validator,
299
+ [epPropKey]: true
300
+ };
301
+ if (hasOwn(prop, "default"))
302
+ epProp.default = defaultValue;
303
+ return epProp;
304
+ };
305
+ const buildProps = (props) => fromPairs(Object.entries(props).map(([key, option]) => [
306
+ key,
307
+ buildProp(option, key)
308
+ ]));
309
+
310
+ const withInstall = (main, extra) => {
311
+ main.install = (app) => {
312
+ for (const comp of [main, ...Object.values(extra != null ? extra : {})]) {
313
+ app.component(comp.name, comp);
314
+ }
315
+ };
316
+ if (extra) {
317
+ for (const [key, comp] of Object.entries(extra)) {
318
+ main[key] = comp;
319
+ }
320
+ }
321
+ return main;
322
+ };
323
+
324
+ const defaultNamespace = "el";
325
+ const statePrefix = "is-";
326
+ const _bem = (namespace, block, blockSuffix, element, modifier) => {
327
+ let cls = `${namespace}-${block}`;
328
+ if (blockSuffix) {
329
+ cls += `-${blockSuffix}`;
330
+ }
331
+ if (element) {
332
+ cls += `__${element}`;
333
+ }
334
+ if (modifier) {
335
+ cls += `--${modifier}`;
336
+ }
337
+ return cls;
338
+ };
339
+ const namespaceContextKey = Symbol("namespaceContextKey");
340
+ const useGetDerivedNamespace = (namespaceOverrides) => {
341
+ const derivedNamespace = namespaceOverrides || inject(namespaceContextKey, ref$1(defaultNamespace));
342
+ const namespace = computed(() => {
343
+ return unref$1(derivedNamespace) || defaultNamespace;
344
+ });
345
+ return namespace;
346
+ };
347
+ const useNamespace = (block, namespaceOverrides) => {
348
+ const namespace = useGetDerivedNamespace(namespaceOverrides);
349
+ const b = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", "");
350
+ const e = (element) => element ? _bem(namespace.value, block, "", element, "") : "";
351
+ const m = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : "";
352
+ const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : "";
353
+ const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : "";
354
+ const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : "";
355
+ const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : "";
356
+ const is = (name, ...args) => {
357
+ const state = args.length >= 1 ? args[0] : true;
358
+ return name && state ? `${statePrefix}${name}` : "";
359
+ };
360
+ const cssVar = (object) => {
361
+ const styles = {};
362
+ for (const key in object) {
363
+ if (object[key]) {
364
+ styles[`--${namespace.value}-${key}`] = object[key];
365
+ }
366
+ }
367
+ return styles;
368
+ };
369
+ const cssVarBlock = (object) => {
370
+ const styles = {};
371
+ for (const key in object) {
372
+ if (object[key]) {
373
+ styles[`--${namespace.value}-${block}-${key}`] = object[key];
374
+ }
375
+ }
376
+ return styles;
377
+ };
378
+ const cssVarName = (name) => `--${namespace.value}-${name}`;
379
+ const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`;
380
+ return {
381
+ namespace,
382
+ b,
383
+ e,
384
+ m,
385
+ be,
386
+ em,
387
+ bm,
388
+ bem,
389
+ is,
390
+ cssVar,
391
+ cssVarName,
392
+ cssVarBlock,
393
+ cssVarBlockName
394
+ };
395
+ };
396
+
397
+ var _export_sfc = (sfc, props) => {
398
+ const target = sfc.__vccOpts || sfc;
399
+ for (const [key, val] of props) {
400
+ target[key] = val;
401
+ }
402
+ return target;
403
+ };
404
+
405
+ const GAP = 4;
406
+ const BAR_MAP = {
407
+ vertical: {
408
+ offset: "offsetHeight",
409
+ scroll: "scrollTop",
410
+ scrollSize: "scrollHeight",
411
+ size: "height",
412
+ key: "vertical",
413
+ axis: "Y",
414
+ client: "clientY",
415
+ direction: "top"
416
+ },
417
+ horizontal: {
418
+ offset: "offsetWidth",
419
+ scroll: "scrollLeft",
420
+ scrollSize: "scrollWidth",
421
+ size: "width",
422
+ key: "horizontal",
423
+ axis: "X",
424
+ client: "clientX",
425
+ direction: "left"
426
+ }
427
+ };
428
+ const renderThumbStyle = ({
429
+ move,
430
+ size,
431
+ bar
432
+ }) => ({
433
+ [bar.size]: size,
434
+ transform: `translate${bar.axis}(${move}%)`
435
+ });
436
+
437
+ const scrollbarContextKey = Symbol("scrollbarContextKey");
438
+
439
+ const thumbProps = buildProps({
440
+ vertical: Boolean,
441
+ size: String,
442
+ move: Number,
443
+ ratio: {
444
+ type: Number,
445
+ required: true
446
+ },
447
+ always: Boolean
448
+ });
449
+
450
+ const COMPONENT_NAME$1 = "Thumb";
451
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
452
+ __name: "thumb",
453
+ props: thumbProps,
454
+ setup(__props) {
455
+ const props = __props;
456
+ const scrollbar = inject(scrollbarContextKey);
457
+ const ns = useNamespace("scrollbar");
458
+ if (!scrollbar)
459
+ throwError(COMPONENT_NAME$1, "can not inject scrollbar context");
460
+ const instance = ref$1();
461
+ const thumb = ref$1();
462
+ const thumbState = ref$1({});
463
+ const visible = ref$1(false);
464
+ let cursorDown = false;
465
+ let cursorLeave = false;
466
+ let originalOnSelectStart = isClient ? document.onselectstart : null;
467
+ const bar = computed(() => BAR_MAP[props.vertical ? "vertical" : "horizontal"]);
468
+ const thumbStyle = computed(() => renderThumbStyle({
469
+ size: props.size,
470
+ move: props.move,
471
+ bar: bar.value
472
+ }));
473
+ const offsetRatio = computed(() => instance.value[bar.value.offset] ** 2 / scrollbar.wrapElement[bar.value.scrollSize] / props.ratio / thumb.value[bar.value.offset]);
474
+ const clickThumbHandler = (e) => {
475
+ var _a;
476
+ e.stopPropagation();
477
+ if (e.ctrlKey || [1, 2].includes(e.button))
478
+ return;
479
+ (_a = window.getSelection()) == null ? void 0 : _a.removeAllRanges();
480
+ startDrag(e);
481
+ const el = e.currentTarget;
482
+ if (!el)
483
+ return;
484
+ thumbState.value[bar.value.axis] = el[bar.value.offset] - (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction]);
485
+ };
486
+ const clickTrackHandler = (e) => {
487
+ if (!thumb.value || !instance.value || !scrollbar.wrapElement)
488
+ return;
489
+ const offset = Math.abs(e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]);
490
+ const thumbHalf = thumb.value[bar.value.offset] / 2;
491
+ const thumbPositionPercentage = (offset - thumbHalf) * 100 * offsetRatio.value / instance.value[bar.value.offset];
492
+ scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
493
+ };
494
+ const startDrag = (e) => {
495
+ e.stopImmediatePropagation();
496
+ cursorDown = true;
497
+ document.addEventListener("mousemove", mouseMoveDocumentHandler);
498
+ document.addEventListener("mouseup", mouseUpDocumentHandler);
499
+ originalOnSelectStart = document.onselectstart;
500
+ document.onselectstart = () => false;
501
+ };
502
+ const mouseMoveDocumentHandler = (e) => {
503
+ if (!instance.value || !thumb.value)
504
+ return;
505
+ if (cursorDown === false)
506
+ return;
507
+ const prevPage = thumbState.value[bar.value.axis];
508
+ if (!prevPage)
509
+ return;
510
+ const offset = (instance.value.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1;
511
+ const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
512
+ const thumbPositionPercentage = (offset - thumbClickPosition) * 100 * offsetRatio.value / instance.value[bar.value.offset];
513
+ scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
514
+ };
515
+ const mouseUpDocumentHandler = () => {
516
+ cursorDown = false;
517
+ thumbState.value[bar.value.axis] = 0;
518
+ document.removeEventListener("mousemove", mouseMoveDocumentHandler);
519
+ document.removeEventListener("mouseup", mouseUpDocumentHandler);
520
+ restoreOnselectstart();
521
+ if (cursorLeave)
522
+ visible.value = false;
523
+ };
524
+ const mouseMoveScrollbarHandler = () => {
525
+ cursorLeave = false;
526
+ visible.value = !!props.size;
527
+ };
528
+ const mouseLeaveScrollbarHandler = () => {
529
+ cursorLeave = true;
530
+ visible.value = cursorDown;
531
+ };
532
+ onBeforeUnmount(() => {
533
+ restoreOnselectstart();
534
+ document.removeEventListener("mouseup", mouseUpDocumentHandler);
535
+ });
536
+ const restoreOnselectstart = () => {
537
+ if (document.onselectstart !== originalOnSelectStart)
538
+ document.onselectstart = originalOnSelectStart;
539
+ };
540
+ useEventListener(toRef(scrollbar, "scrollbarElement"), "mousemove", mouseMoveScrollbarHandler);
541
+ useEventListener(toRef(scrollbar, "scrollbarElement"), "mouseleave", mouseLeaveScrollbarHandler);
542
+ return (_ctx, _cache) => {
543
+ return openBlock(), createBlock(Transition, {
544
+ name: unref$1(ns).b("fade"),
545
+ persisted: ""
546
+ }, {
547
+ default: withCtx(() => [
548
+ withDirectives(createElementVNode("div", {
549
+ ref_key: "instance",
550
+ ref: instance,
551
+ class: normalizeClass([unref$1(ns).e("bar"), unref$1(ns).is(unref$1(bar).key)]),
552
+ onMousedown: clickTrackHandler
553
+ }, [
554
+ createElementVNode("div", {
555
+ ref_key: "thumb",
556
+ ref: thumb,
557
+ class: normalizeClass(unref$1(ns).e("thumb")),
558
+ style: normalizeStyle(unref$1(thumbStyle)),
559
+ onMousedown: clickThumbHandler
560
+ }, null, 38)
561
+ ], 34), [
562
+ [vShow, _ctx.always || visible.value]
563
+ ])
564
+ ]),
565
+ _: 1
566
+ }, 8, ["name"]);
567
+ };
568
+ }
569
+ });
570
+ var Thumb = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/thumb.vue"]]);
571
+
572
+ const barProps = buildProps({
573
+ always: {
574
+ type: Boolean,
575
+ default: true
576
+ },
577
+ width: String,
578
+ height: String,
579
+ ratioX: {
580
+ type: Number,
581
+ default: 1
582
+ },
583
+ ratioY: {
584
+ type: Number,
585
+ default: 1
586
+ }
587
+ });
588
+
589
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
590
+ __name: "bar",
591
+ props: barProps,
592
+ setup(__props, { expose }) {
593
+ const props = __props;
594
+ const moveX = ref$1(0);
595
+ const moveY = ref$1(0);
596
+ const handleScroll = (wrap) => {
597
+ if (wrap) {
598
+ const offsetHeight = wrap.offsetHeight - GAP;
599
+ const offsetWidth = wrap.offsetWidth - GAP;
600
+ moveY.value = wrap.scrollTop * 100 / offsetHeight * props.ratioY;
601
+ moveX.value = wrap.scrollLeft * 100 / offsetWidth * props.ratioX;
602
+ }
603
+ };
604
+ expose({
605
+ handleScroll
606
+ });
607
+ return (_ctx, _cache) => {
608
+ return openBlock(), createElementBlock(Fragment, null, [
609
+ createVNode(Thumb, {
610
+ move: moveX.value,
611
+ ratio: _ctx.ratioX,
612
+ size: _ctx.width,
613
+ always: _ctx.always
614
+ }, null, 8, ["move", "ratio", "size", "always"]),
615
+ createVNode(Thumb, {
616
+ move: moveY.value,
617
+ ratio: _ctx.ratioY,
618
+ size: _ctx.height,
619
+ vertical: "",
620
+ always: _ctx.always
621
+ }, null, 8, ["move", "ratio", "size", "always"])
622
+ ], 64);
623
+ };
624
+ }
625
+ });
626
+ var Bar = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/bar.vue"]]);
627
+
628
+ const scrollbarProps = buildProps({
629
+ height: {
630
+ type: [String, Number],
631
+ default: ""
632
+ },
633
+ maxHeight: {
634
+ type: [String, Number],
635
+ default: ""
636
+ },
637
+ native: {
638
+ type: Boolean,
639
+ default: false
640
+ },
641
+ wrapStyle: {
642
+ type: definePropType([String, Object, Array]),
643
+ default: ""
644
+ },
645
+ wrapClass: {
646
+ type: [String, Array],
647
+ default: ""
648
+ },
649
+ viewClass: {
650
+ type: [String, Array],
651
+ default: ""
652
+ },
653
+ viewStyle: {
654
+ type: [String, Array, Object],
655
+ default: ""
656
+ },
657
+ noresize: Boolean,
658
+ tag: {
659
+ type: String,
660
+ default: "div"
661
+ },
662
+ always: Boolean,
663
+ minSize: {
664
+ type: Number,
665
+ default: 20
666
+ }
667
+ });
668
+ const scrollbarEmits = {
669
+ scroll: ({
670
+ scrollTop,
671
+ scrollLeft
672
+ }) => [scrollTop, scrollLeft].every(isNumber)
673
+ };
674
+
675
+ const COMPONENT_NAME = "ElScrollbar";
676
+ const __default__ = defineComponent({
677
+ name: COMPONENT_NAME
678
+ });
679
+ const _sfc_main = /* @__PURE__ */ defineComponent({
680
+ ...__default__,
681
+ props: scrollbarProps,
682
+ emits: scrollbarEmits,
683
+ setup(__props, { expose, emit }) {
684
+ const props = __props;
685
+ const ns = useNamespace("scrollbar");
686
+ let stopResizeObserver = void 0;
687
+ let stopResizeListener = void 0;
688
+ const scrollbarRef = ref$1();
689
+ const wrapRef = ref$1();
690
+ const resizeRef = ref$1();
691
+ const sizeWidth = ref$1("0");
692
+ const sizeHeight = ref$1("0");
693
+ const barRef = ref$1();
694
+ const ratioY = ref$1(1);
695
+ const ratioX = ref$1(1);
696
+ const style = computed(() => {
697
+ const style2 = {};
698
+ if (props.height)
699
+ style2.height = addUnit(props.height);
700
+ if (props.maxHeight)
701
+ style2.maxHeight = addUnit(props.maxHeight);
702
+ return [props.wrapStyle, style2];
703
+ });
704
+ const wrapKls = computed(() => {
705
+ return [
706
+ props.wrapClass,
707
+ ns.e("wrap"),
708
+ { [ns.em("wrap", "hidden-default")]: !props.native }
709
+ ];
710
+ });
711
+ const resizeKls = computed(() => {
712
+ return [ns.e("view"), props.viewClass];
713
+ });
714
+ const handleScroll = () => {
715
+ var _a;
716
+ if (wrapRef.value) {
717
+ (_a = barRef.value) == null ? void 0 : _a.handleScroll(wrapRef.value);
718
+ emit("scroll", {
719
+ scrollTop: wrapRef.value.scrollTop,
720
+ scrollLeft: wrapRef.value.scrollLeft
721
+ });
722
+ }
723
+ };
724
+ function scrollTo(arg1, arg2) {
725
+ if (isObject(arg1)) {
726
+ wrapRef.value.scrollTo(arg1);
727
+ } else if (isNumber(arg1) && isNumber(arg2)) {
728
+ wrapRef.value.scrollTo(arg1, arg2);
729
+ }
730
+ }
731
+ const setScrollTop = (value) => {
732
+ if (!isNumber(value)) {
733
+ debugWarn(COMPONENT_NAME, "value must be a number");
734
+ return;
735
+ }
736
+ wrapRef.value.scrollTop = value;
737
+ };
738
+ const setScrollLeft = (value) => {
739
+ if (!isNumber(value)) {
740
+ debugWarn(COMPONENT_NAME, "value must be a number");
741
+ return;
742
+ }
743
+ wrapRef.value.scrollLeft = value;
744
+ };
745
+ const update = () => {
746
+ if (!wrapRef.value)
747
+ return;
748
+ const offsetHeight = wrapRef.value.offsetHeight - GAP;
749
+ const offsetWidth = wrapRef.value.offsetWidth - GAP;
750
+ const originalHeight = offsetHeight ** 2 / wrapRef.value.scrollHeight;
751
+ const originalWidth = offsetWidth ** 2 / wrapRef.value.scrollWidth;
752
+ const height = Math.max(originalHeight, props.minSize);
753
+ const width = Math.max(originalWidth, props.minSize);
754
+ ratioY.value = originalHeight / (offsetHeight - originalHeight) / (height / (offsetHeight - height));
755
+ ratioX.value = originalWidth / (offsetWidth - originalWidth) / (width / (offsetWidth - width));
756
+ sizeHeight.value = height + GAP < offsetHeight ? `${height}px` : "";
757
+ sizeWidth.value = width + GAP < offsetWidth ? `${width}px` : "";
758
+ };
759
+ watch$1(() => props.noresize, (noresize) => {
760
+ if (noresize) {
761
+ stopResizeObserver == null ? void 0 : stopResizeObserver();
762
+ stopResizeListener == null ? void 0 : stopResizeListener();
763
+ } else {
764
+ ({ stop: stopResizeObserver } = useResizeObserver(resizeRef, update));
765
+ stopResizeListener = useEventListener("resize", update);
766
+ }
767
+ }, { immediate: true });
768
+ watch$1(() => [props.maxHeight, props.height], () => {
769
+ if (!props.native)
770
+ nextTick$1(() => {
771
+ var _a;
772
+ update();
773
+ if (wrapRef.value) {
774
+ (_a = barRef.value) == null ? void 0 : _a.handleScroll(wrapRef.value);
775
+ }
776
+ });
777
+ });
778
+ provide(scrollbarContextKey, reactive({
779
+ scrollbarElement: scrollbarRef,
780
+ wrapElement: wrapRef
781
+ }));
782
+ onMounted$1(() => {
783
+ if (!props.native)
784
+ nextTick$1(() => {
785
+ update();
786
+ });
787
+ });
788
+ onUpdated(() => update());
789
+ expose({
790
+ wrapRef,
791
+ update,
792
+ scrollTo,
793
+ setScrollTop,
794
+ setScrollLeft,
795
+ handleScroll
796
+ });
797
+ return (_ctx, _cache) => {
798
+ return openBlock(), createElementBlock("div", {
799
+ ref_key: "scrollbarRef",
800
+ ref: scrollbarRef,
801
+ class: normalizeClass(unref$1(ns).b())
802
+ }, [
803
+ createElementVNode("div", {
804
+ ref_key: "wrapRef",
805
+ ref: wrapRef,
806
+ class: normalizeClass(unref$1(wrapKls)),
807
+ style: normalizeStyle(unref$1(style)),
808
+ onScroll: handleScroll
809
+ }, [
810
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), {
811
+ ref_key: "resizeRef",
812
+ ref: resizeRef,
813
+ class: normalizeClass(unref$1(resizeKls)),
814
+ style: normalizeStyle(_ctx.viewStyle)
815
+ }, {
816
+ default: withCtx(() => [
817
+ renderSlot(_ctx.$slots, "default")
818
+ ]),
819
+ _: 3
820
+ }, 8, ["class", "style"]))
821
+ ], 38),
822
+ !_ctx.native ? (openBlock(), createBlock(Bar, {
823
+ key: 0,
824
+ ref_key: "barRef",
825
+ ref: barRef,
826
+ height: sizeHeight.value,
827
+ width: sizeWidth.value,
828
+ always: _ctx.always,
829
+ "ratio-x": ratioX.value,
830
+ "ratio-y": ratioY.value
831
+ }, null, 8, ["height", "width", "always", "ratio-x", "ratio-y"])) : createCommentVNode("v-if", true)
832
+ ], 2);
833
+ };
834
+ }
835
+ });
836
+ var Scrollbar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/scrollbar.vue"]]);
837
+
838
+ const ElScrollbar = withInstall(Scrollbar);
839
+
840
+ const RxScrollbarProps = {};
841
+
842
+ var script = defineComponent({
843
+ name: 'RxScrollbar',
844
+ components: { ElScrollbar },
845
+ props: RxScrollbarProps,
846
+ setup() {
847
+ return {};
848
+ }
849
+ });
850
+
851
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
852
+ const _component_el_scrollbar = resolveComponent("el-scrollbar");
853
+
854
+ return (openBlock(), createBlock(_component_el_scrollbar, normalizeProps(guardReactiveProps(_ctx.$attrs)), {
855
+ default: withCtx(() => [
856
+ renderSlot(_ctx.$slots, "default")
857
+ ]),
858
+ _: 3 /* FORWARDED */
859
+ }, 16 /* FULL_PROPS */))
860
+ }
861
+
862
+ script.render = render;
863
+ script.__file = "packages/components/RxScrollbar/src/index.vue";
864
+
865
+ const RxScrollbar = withInstall$1(script);
866
+
867
+ export { RxScrollbar, RxScrollbar as default };