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