rx-compo 1.0.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/index.esm.js ADDED
@@ -0,0 +1,1854 @@
1
+ import { openBlock, createElementBlock, createElementVNode, warn, watch, unref, inject, ref, computed, getCurrentInstance, defineComponent, mergeProps, renderSlot, useSlots, Text, createBlock, resolveDynamicComponent, withCtx, Fragment, normalizeClass, createCommentVNode, provide, reactive, toRef, resolveComponent, createTextVNode } from 'vue';
2
+
3
+ const withInstall$1 = (comp) => {
4
+ comp.install = function (app) {
5
+ app.component(comp.name, comp);
6
+ };
7
+ return comp;
8
+ };
9
+
10
+ /**
11
+ * Make a map and return a function for checking if a key
12
+ * is in that map.
13
+ * IMPORTANT: all calls of this function must be prefixed with
14
+ * \/\*#\_\_PURE\_\_\*\/
15
+ * So that rollup can tree-shake them if necessary.
16
+ */
17
+
18
+ (process.env.NODE_ENV !== 'production')
19
+ ? Object.freeze({})
20
+ : {};
21
+ (process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
22
+ const NOOP = () => { };
23
+ const hasOwnProperty = Object.prototype.hasOwnProperty;
24
+ const hasOwn = (val, key) => hasOwnProperty.call(val, key);
25
+ const isString = (val) => typeof val === 'string';
26
+ const isObject = (val) => val !== null && typeof val === 'object';
27
+
28
+ /**
29
+ * The inverse of `_.toPairs`; this method returns an object composed
30
+ * from key-value `pairs`.
31
+ *
32
+ * @static
33
+ * @memberOf _
34
+ * @since 4.0.0
35
+ * @category Array
36
+ * @param {Array} pairs The key-value pairs.
37
+ * @returns {Object} Returns the new object.
38
+ * @example
39
+ *
40
+ * _.fromPairs([['a', 1], ['b', 2]]);
41
+ * // => { 'a': 1, 'b': 2 }
42
+ */
43
+ function fromPairs(pairs) {
44
+ var index = -1,
45
+ length = pairs == null ? 0 : pairs.length,
46
+ result = {};
47
+
48
+ while (++index < length) {
49
+ var pair = pairs[index];
50
+ result[pair[0]] = pair[1];
51
+ }
52
+ return result;
53
+ }
54
+
55
+ const isUndefined = (val) => val === void 0;
56
+ const isNumber = (val) => typeof val === "number";
57
+ const isStringNumber = (val) => {
58
+ if (!isString(val)) {
59
+ return false;
60
+ }
61
+ return !Number.isNaN(Number(val));
62
+ };
63
+
64
+ class ElementPlusError extends Error {
65
+ constructor(m) {
66
+ super(m);
67
+ this.name = "ElementPlusError";
68
+ }
69
+ }
70
+ function debugWarn(scope, message) {
71
+ if (process.env.NODE_ENV !== "production") {
72
+ const error = isString(scope) ? new ElementPlusError(`[${scope}] ${message}`) : scope;
73
+ console.warn(error);
74
+ }
75
+ }
76
+
77
+ const SCOPE = "utils/dom/style";
78
+ function addUnit(value, defaultUnit = "px") {
79
+ if (!value)
80
+ return "";
81
+ if (isNumber(value) || isStringNumber(value)) {
82
+ return `${value}${defaultUnit}`;
83
+ } else if (isString(value)) {
84
+ return value;
85
+ }
86
+ debugWarn(SCOPE, "binding value must be a string or number");
87
+ }
88
+
89
+ /*! Element Plus Icons Vue v2.1.0 */
90
+
91
+ // unplugin-vue:/plugin-vue/export-helper
92
+ var export_helper_default = (sfc, props) => {
93
+ let target = sfc.__vccOpts || sfc;
94
+ for (let [key, val] of props)
95
+ target[key] = val;
96
+ return target;
97
+ };
98
+
99
+ // unplugin-vue:/home/runner/work/element-plus-icons/element-plus-icons/packages/vue/src/components/loading.vue?vue&type=script&lang.ts
100
+ var loading_vue_vue_type_script_lang_default = {
101
+ name: "Loading"
102
+ };
103
+ var _hoisted_1150 = {
104
+ xmlns: "http://www.w3.org/2000/svg",
105
+ viewBox: "0 0 1024 1024"
106
+ }, _hoisted_2150 = /* @__PURE__ */ createElementVNode(
107
+ "path",
108
+ {
109
+ fill: "currentColor",
110
+ d: "M512 64a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V96a32 32 0 0 1 32-32zm0 640a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V736a32 32 0 0 1 32-32zm448-192a32 32 0 0 1-32 32H736a32 32 0 1 1 0-64h192a32 32 0 0 1 32 32zm-640 0a32 32 0 0 1-32 32H96a32 32 0 0 1 0-64h192a32 32 0 0 1 32 32zM195.2 195.2a32 32 0 0 1 45.248 0L376.32 331.008a32 32 0 0 1-45.248 45.248L195.2 240.448a32 32 0 0 1 0-45.248zm452.544 452.544a32 32 0 0 1 45.248 0L828.8 783.552a32 32 0 0 1-45.248 45.248L647.744 692.992a32 32 0 0 1 0-45.248zM828.8 195.264a32 32 0 0 1 0 45.184L692.992 376.32a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0zm-452.544 452.48a32 32 0 0 1 0 45.248L240.448 828.8a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0z"
111
+ },
112
+ null,
113
+ -1
114
+ /* HOISTED */
115
+ ), _hoisted_3149 = [
116
+ _hoisted_2150
117
+ ];
118
+ function _sfc_render150(_ctx, _cache, $props, $setup, $data, $options) {
119
+ return openBlock(), createElementBlock("svg", _hoisted_1150, _hoisted_3149);
120
+ }
121
+ var loading_default = /* @__PURE__ */ export_helper_default(loading_vue_vue_type_script_lang_default, [["render", _sfc_render150], ["__file", "loading.vue"]]);
122
+
123
+ const epPropKey = "__epPropKey";
124
+ const definePropType = (val) => val;
125
+ const isEpProp = (val) => isObject(val) && !!val[epPropKey];
126
+ const buildProp = (prop, key) => {
127
+ if (!isObject(prop) || isEpProp(prop))
128
+ return prop;
129
+ const { values, required, default: defaultValue, type, validator } = prop;
130
+ const _validator = values || validator ? (val) => {
131
+ let valid = false;
132
+ let allowedValues = [];
133
+ if (values) {
134
+ allowedValues = Array.from(values);
135
+ if (hasOwn(prop, "default")) {
136
+ allowedValues.push(defaultValue);
137
+ }
138
+ valid || (valid = allowedValues.includes(val));
139
+ }
140
+ if (validator)
141
+ valid || (valid = validator(val));
142
+ if (!valid && allowedValues.length > 0) {
143
+ const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", ");
144
+ warn(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`);
145
+ }
146
+ return valid;
147
+ } : void 0;
148
+ const epProp = {
149
+ type,
150
+ required: !!required,
151
+ validator: _validator,
152
+ [epPropKey]: true
153
+ };
154
+ if (hasOwn(prop, "default"))
155
+ epProp.default = defaultValue;
156
+ return epProp;
157
+ };
158
+ const buildProps = (props) => fromPairs(Object.entries(props).map(([key, option]) => [
159
+ key,
160
+ buildProp(option, key)
161
+ ]));
162
+
163
+ const iconPropType = definePropType([
164
+ String,
165
+ Object,
166
+ Function
167
+ ]);
168
+
169
+ const withInstall = (main, extra) => {
170
+ main.install = (app) => {
171
+ for (const comp of [main, ...Object.values(extra != null ? extra : {})]) {
172
+ app.component(comp.name, comp);
173
+ }
174
+ };
175
+ if (extra) {
176
+ for (const [key, comp] of Object.entries(extra)) {
177
+ main[key] = comp;
178
+ }
179
+ }
180
+ return main;
181
+ };
182
+ const withNoopInstall = (component) => {
183
+ component.install = NOOP;
184
+ return component;
185
+ };
186
+
187
+ const componentSizes = ["", "default", "small", "large"];
188
+
189
+ const useDeprecated = ({ from, replacement, scope, version, ref, type = "API" }, condition) => {
190
+ watch(() => unref(condition), (val) => {
191
+ if (val) {
192
+ debugWarn(scope, `[${type}] ${from} is about to be deprecated in version ${version}, please use ${replacement} instead.
193
+ For more detail, please visit: ${ref}
194
+ `);
195
+ }
196
+ }, {
197
+ immediate: true
198
+ });
199
+ };
200
+
201
+ const defaultNamespace = "el";
202
+ const statePrefix = "is-";
203
+ const _bem = (namespace, block, blockSuffix, element, modifier) => {
204
+ let cls = `${namespace}-${block}`;
205
+ if (blockSuffix) {
206
+ cls += `-${blockSuffix}`;
207
+ }
208
+ if (element) {
209
+ cls += `__${element}`;
210
+ }
211
+ if (modifier) {
212
+ cls += `--${modifier}`;
213
+ }
214
+ return cls;
215
+ };
216
+ const namespaceContextKey = Symbol("namespaceContextKey");
217
+ const useGetDerivedNamespace = (namespaceOverrides) => {
218
+ const derivedNamespace = namespaceOverrides || inject(namespaceContextKey, ref(defaultNamespace));
219
+ const namespace = computed(() => {
220
+ return unref(derivedNamespace) || defaultNamespace;
221
+ });
222
+ return namespace;
223
+ };
224
+ const useNamespace = (block, namespaceOverrides) => {
225
+ const namespace = useGetDerivedNamespace(namespaceOverrides);
226
+ const b = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", "");
227
+ const e = (element) => element ? _bem(namespace.value, block, "", element, "") : "";
228
+ const m = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : "";
229
+ const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : "";
230
+ const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : "";
231
+ const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : "";
232
+ const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : "";
233
+ const is = (name, ...args) => {
234
+ const state = args.length >= 1 ? args[0] : true;
235
+ return name && state ? `${statePrefix}${name}` : "";
236
+ };
237
+ const cssVar = (object) => {
238
+ const styles = {};
239
+ for (const key in object) {
240
+ if (object[key]) {
241
+ styles[`--${namespace.value}-${key}`] = object[key];
242
+ }
243
+ }
244
+ return styles;
245
+ };
246
+ const cssVarBlock = (object) => {
247
+ const styles = {};
248
+ for (const key in object) {
249
+ if (object[key]) {
250
+ styles[`--${namespace.value}-${block}-${key}`] = object[key];
251
+ }
252
+ }
253
+ return styles;
254
+ };
255
+ const cssVarName = (name) => `--${namespace.value}-${name}`;
256
+ const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`;
257
+ return {
258
+ namespace,
259
+ b,
260
+ e,
261
+ m,
262
+ be,
263
+ em,
264
+ bm,
265
+ bem,
266
+ is,
267
+ cssVar,
268
+ cssVarName,
269
+ cssVarBlock,
270
+ cssVarBlockName
271
+ };
272
+ };
273
+
274
+ const useProp = (name) => {
275
+ const vm = getCurrentInstance();
276
+ return computed(() => {
277
+ var _a, _b;
278
+ return (_b = (_a = vm == null ? void 0 : vm.proxy) == null ? void 0 : _a.$props) == null ? void 0 : _b[name];
279
+ });
280
+ };
281
+
282
+ const useSizeProp = buildProp({
283
+ type: String,
284
+ values: componentSizes,
285
+ required: false
286
+ });
287
+ const SIZE_INJECTION_KEY = Symbol("size");
288
+ const useGlobalSize = () => {
289
+ const injectedSize = inject(SIZE_INJECTION_KEY, {});
290
+ return computed(() => {
291
+ return unref(injectedSize.size) || "";
292
+ });
293
+ };
294
+
295
+ const configProviderContextKey = Symbol();
296
+
297
+ const globalConfig = ref();
298
+ function useGlobalConfig(key, defaultValue = void 0) {
299
+ const config = getCurrentInstance() ? inject(configProviderContextKey, globalConfig) : globalConfig;
300
+ if (key) {
301
+ return computed(() => {
302
+ var _a, _b;
303
+ return (_b = (_a = config.value) == null ? void 0 : _a[key]) != null ? _b : defaultValue;
304
+ });
305
+ } else {
306
+ return config;
307
+ }
308
+ }
309
+
310
+ var _export_sfc = (sfc, props) => {
311
+ const target = sfc.__vccOpts || sfc;
312
+ for (const [key, val] of props) {
313
+ target[key] = val;
314
+ }
315
+ return target;
316
+ };
317
+
318
+ const iconProps = buildProps({
319
+ size: {
320
+ type: definePropType([Number, String])
321
+ },
322
+ color: {
323
+ type: String
324
+ }
325
+ });
326
+
327
+ const __default__$2 = defineComponent({
328
+ name: "ElIcon",
329
+ inheritAttrs: false
330
+ });
331
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
332
+ ...__default__$2,
333
+ props: iconProps,
334
+ setup(__props) {
335
+ const props = __props;
336
+ const ns = useNamespace("icon");
337
+ const style = computed(() => {
338
+ const { size, color } = props;
339
+ if (!size && !color)
340
+ return {};
341
+ return {
342
+ fontSize: isUndefined(size) ? void 0 : addUnit(size),
343
+ "--color": color
344
+ };
345
+ });
346
+ return (_ctx, _cache) => {
347
+ return openBlock(), createElementBlock("i", mergeProps({
348
+ class: unref(ns).b(),
349
+ style: unref(style)
350
+ }, _ctx.$attrs), [
351
+ renderSlot(_ctx.$slots, "default")
352
+ ], 16);
353
+ };
354
+ }
355
+ });
356
+ var Icon = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/icon/src/icon.vue"]]);
357
+
358
+ const ElIcon = withInstall(Icon);
359
+
360
+ const formContextKey = Symbol("formContextKey");
361
+ const formItemContextKey = Symbol("formItemContextKey");
362
+
363
+ const useFormSize = (fallback, ignore = {}) => {
364
+ const emptyRef = ref(void 0);
365
+ const size = ignore.prop ? emptyRef : useProp("size");
366
+ const globalConfig = ignore.global ? emptyRef : useGlobalSize();
367
+ const form = ignore.form ? { size: void 0 } : inject(formContextKey, void 0);
368
+ const formItem = ignore.formItem ? { size: void 0 } : inject(formItemContextKey, void 0);
369
+ return computed(() => size.value || unref(fallback) || (formItem == null ? void 0 : formItem.size) || (form == null ? void 0 : form.size) || globalConfig.value || "");
370
+ };
371
+ const useFormDisabled = (fallback) => {
372
+ const disabled = useProp("disabled");
373
+ const form = inject(formContextKey, void 0);
374
+ return computed(() => disabled.value || unref(fallback) || (form == null ? void 0 : form.disabled) || false);
375
+ };
376
+
377
+ const useFormItem = () => {
378
+ const form = inject(formContextKey, void 0);
379
+ const formItem = inject(formItemContextKey, void 0);
380
+ return {
381
+ form,
382
+ formItem
383
+ };
384
+ };
385
+
386
+ const buttonGroupContextKey = Symbol("buttonGroupContextKey");
387
+
388
+ const useButton = (props, emit) => {
389
+ useDeprecated({
390
+ from: "type.text",
391
+ replacement: "link",
392
+ version: "3.0.0",
393
+ scope: "props",
394
+ ref: "https://element-plus.org/en-US/component/button.html#button-attributes"
395
+ }, computed(() => props.type === "text"));
396
+ const buttonGroupContext = inject(buttonGroupContextKey, void 0);
397
+ const globalConfig = useGlobalConfig("button");
398
+ const { form } = useFormItem();
399
+ const _size = useFormSize(computed(() => buttonGroupContext == null ? void 0 : buttonGroupContext.size));
400
+ const _disabled = useFormDisabled();
401
+ const _ref = ref();
402
+ const slots = useSlots();
403
+ const _type = computed(() => props.type || (buttonGroupContext == null ? void 0 : buttonGroupContext.type) || "");
404
+ const autoInsertSpace = computed(() => {
405
+ var _a, _b, _c;
406
+ return (_c = (_b = props.autoInsertSpace) != null ? _b : (_a = globalConfig.value) == null ? void 0 : _a.autoInsertSpace) != null ? _c : false;
407
+ });
408
+ const _props = computed(() => {
409
+ if (props.tag === "button") {
410
+ return {
411
+ ariaDisabled: _disabled.value || props.loading,
412
+ disabled: _disabled.value || props.loading,
413
+ autofocus: props.autofocus,
414
+ type: props.nativeType
415
+ };
416
+ }
417
+ return {};
418
+ });
419
+ const shouldAddSpace = computed(() => {
420
+ var _a;
421
+ const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots);
422
+ if (autoInsertSpace.value && (defaultSlot == null ? void 0 : defaultSlot.length) === 1) {
423
+ const slot = defaultSlot[0];
424
+ if ((slot == null ? void 0 : slot.type) === Text) {
425
+ const text = slot.children;
426
+ return /^\p{Unified_Ideograph}{2}$/u.test(text.trim());
427
+ }
428
+ }
429
+ return false;
430
+ });
431
+ const handleClick = (evt) => {
432
+ if (props.nativeType === "reset") {
433
+ form == null ? void 0 : form.resetFields();
434
+ }
435
+ emit("click", evt);
436
+ };
437
+ return {
438
+ _disabled,
439
+ _size,
440
+ _type,
441
+ _ref,
442
+ _props,
443
+ shouldAddSpace,
444
+ handleClick
445
+ };
446
+ };
447
+
448
+ const buttonTypes = [
449
+ "default",
450
+ "primary",
451
+ "success",
452
+ "warning",
453
+ "info",
454
+ "danger",
455
+ "text",
456
+ ""
457
+ ];
458
+ const buttonNativeTypes = ["button", "submit", "reset"];
459
+ const buttonProps$1 = buildProps({
460
+ size: useSizeProp,
461
+ disabled: Boolean,
462
+ type: {
463
+ type: String,
464
+ values: buttonTypes,
465
+ default: ""
466
+ },
467
+ icon: {
468
+ type: iconPropType
469
+ },
470
+ nativeType: {
471
+ type: String,
472
+ values: buttonNativeTypes,
473
+ default: "button"
474
+ },
475
+ loading: Boolean,
476
+ loadingIcon: {
477
+ type: iconPropType,
478
+ default: () => loading_default
479
+ },
480
+ plain: Boolean,
481
+ text: Boolean,
482
+ link: Boolean,
483
+ bg: Boolean,
484
+ autofocus: Boolean,
485
+ round: Boolean,
486
+ circle: Boolean,
487
+ color: String,
488
+ dark: Boolean,
489
+ autoInsertSpace: {
490
+ type: Boolean,
491
+ default: void 0
492
+ },
493
+ tag: {
494
+ type: definePropType([String, Object]),
495
+ default: "button"
496
+ }
497
+ });
498
+ const buttonEmits = {
499
+ click: (evt) => evt instanceof MouseEvent
500
+ };
501
+
502
+ /**
503
+ * Take input from [0, n] and return it as [0, 1]
504
+ * @hidden
505
+ */
506
+ function bound01(n, max) {
507
+ if (isOnePointZero(n)) {
508
+ n = '100%';
509
+ }
510
+ var isPercent = isPercentage(n);
511
+ n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
512
+ // Automatically convert percentage into number
513
+ if (isPercent) {
514
+ n = parseInt(String(n * max), 10) / 100;
515
+ }
516
+ // Handle floating point rounding errors
517
+ if (Math.abs(n - max) < 0.000001) {
518
+ return 1;
519
+ }
520
+ // Convert into [0, 1] range if it isn't already
521
+ if (max === 360) {
522
+ // If n is a hue given in degrees,
523
+ // wrap around out-of-range values into [0, 360] range
524
+ // then convert into [0, 1].
525
+ n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));
526
+ }
527
+ else {
528
+ // If n not a hue given in degrees
529
+ // Convert into [0, 1] range if it isn't already.
530
+ n = (n % max) / parseFloat(String(max));
531
+ }
532
+ return n;
533
+ }
534
+ /**
535
+ * Force a number between 0 and 1
536
+ * @hidden
537
+ */
538
+ function clamp01(val) {
539
+ return Math.min(1, Math.max(0, val));
540
+ }
541
+ /**
542
+ * Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
543
+ * <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
544
+ * @hidden
545
+ */
546
+ function isOnePointZero(n) {
547
+ return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;
548
+ }
549
+ /**
550
+ * Check to see if string passed in is a percentage
551
+ * @hidden
552
+ */
553
+ function isPercentage(n) {
554
+ return typeof n === 'string' && n.indexOf('%') !== -1;
555
+ }
556
+ /**
557
+ * Return a valid alpha value [0,1] with all invalid values being set to 1
558
+ * @hidden
559
+ */
560
+ function boundAlpha(a) {
561
+ a = parseFloat(a);
562
+ if (isNaN(a) || a < 0 || a > 1) {
563
+ a = 1;
564
+ }
565
+ return a;
566
+ }
567
+ /**
568
+ * Replace a decimal with it's percentage value
569
+ * @hidden
570
+ */
571
+ function convertToPercentage(n) {
572
+ if (n <= 1) {
573
+ return "".concat(Number(n) * 100, "%");
574
+ }
575
+ return n;
576
+ }
577
+ /**
578
+ * Force a hex value to have 2 characters
579
+ * @hidden
580
+ */
581
+ function pad2(c) {
582
+ return c.length === 1 ? '0' + c : String(c);
583
+ }
584
+
585
+ // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
586
+ // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
587
+ /**
588
+ * Handle bounds / percentage checking to conform to CSS color spec
589
+ * <http://www.w3.org/TR/css3-color/>
590
+ * *Assumes:* r, g, b in [0, 255] or [0, 1]
591
+ * *Returns:* { r, g, b } in [0, 255]
592
+ */
593
+ function rgbToRgb(r, g, b) {
594
+ return {
595
+ r: bound01(r, 255) * 255,
596
+ g: bound01(g, 255) * 255,
597
+ b: bound01(b, 255) * 255,
598
+ };
599
+ }
600
+ /**
601
+ * Converts an RGB color value to HSL.
602
+ * *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
603
+ * *Returns:* { h, s, l } in [0,1]
604
+ */
605
+ function rgbToHsl(r, g, b) {
606
+ r = bound01(r, 255);
607
+ g = bound01(g, 255);
608
+ b = bound01(b, 255);
609
+ var max = Math.max(r, g, b);
610
+ var min = Math.min(r, g, b);
611
+ var h = 0;
612
+ var s = 0;
613
+ var l = (max + min) / 2;
614
+ if (max === min) {
615
+ s = 0;
616
+ h = 0; // achromatic
617
+ }
618
+ else {
619
+ var d = max - min;
620
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
621
+ switch (max) {
622
+ case r:
623
+ h = (g - b) / d + (g < b ? 6 : 0);
624
+ break;
625
+ case g:
626
+ h = (b - r) / d + 2;
627
+ break;
628
+ case b:
629
+ h = (r - g) / d + 4;
630
+ break;
631
+ }
632
+ h /= 6;
633
+ }
634
+ return { h: h, s: s, l: l };
635
+ }
636
+ function hue2rgb(p, q, t) {
637
+ if (t < 0) {
638
+ t += 1;
639
+ }
640
+ if (t > 1) {
641
+ t -= 1;
642
+ }
643
+ if (t < 1 / 6) {
644
+ return p + (q - p) * (6 * t);
645
+ }
646
+ if (t < 1 / 2) {
647
+ return q;
648
+ }
649
+ if (t < 2 / 3) {
650
+ return p + (q - p) * (2 / 3 - t) * 6;
651
+ }
652
+ return p;
653
+ }
654
+ /**
655
+ * Converts an HSL color value to RGB.
656
+ *
657
+ * *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
658
+ * *Returns:* { r, g, b } in the set [0, 255]
659
+ */
660
+ function hslToRgb(h, s, l) {
661
+ var r;
662
+ var g;
663
+ var b;
664
+ h = bound01(h, 360);
665
+ s = bound01(s, 100);
666
+ l = bound01(l, 100);
667
+ if (s === 0) {
668
+ // achromatic
669
+ g = l;
670
+ b = l;
671
+ r = l;
672
+ }
673
+ else {
674
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
675
+ var p = 2 * l - q;
676
+ r = hue2rgb(p, q, h + 1 / 3);
677
+ g = hue2rgb(p, q, h);
678
+ b = hue2rgb(p, q, h - 1 / 3);
679
+ }
680
+ return { r: r * 255, g: g * 255, b: b * 255 };
681
+ }
682
+ /**
683
+ * Converts an RGB color value to HSV
684
+ *
685
+ * *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
686
+ * *Returns:* { h, s, v } in [0,1]
687
+ */
688
+ function rgbToHsv(r, g, b) {
689
+ r = bound01(r, 255);
690
+ g = bound01(g, 255);
691
+ b = bound01(b, 255);
692
+ var max = Math.max(r, g, b);
693
+ var min = Math.min(r, g, b);
694
+ var h = 0;
695
+ var v = max;
696
+ var d = max - min;
697
+ var s = max === 0 ? 0 : d / max;
698
+ if (max === min) {
699
+ h = 0; // achromatic
700
+ }
701
+ else {
702
+ switch (max) {
703
+ case r:
704
+ h = (g - b) / d + (g < b ? 6 : 0);
705
+ break;
706
+ case g:
707
+ h = (b - r) / d + 2;
708
+ break;
709
+ case b:
710
+ h = (r - g) / d + 4;
711
+ break;
712
+ }
713
+ h /= 6;
714
+ }
715
+ return { h: h, s: s, v: v };
716
+ }
717
+ /**
718
+ * Converts an HSV color value to RGB.
719
+ *
720
+ * *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
721
+ * *Returns:* { r, g, b } in the set [0, 255]
722
+ */
723
+ function hsvToRgb(h, s, v) {
724
+ h = bound01(h, 360) * 6;
725
+ s = bound01(s, 100);
726
+ v = bound01(v, 100);
727
+ var i = Math.floor(h);
728
+ var f = h - i;
729
+ var p = v * (1 - s);
730
+ var q = v * (1 - f * s);
731
+ var t = v * (1 - (1 - f) * s);
732
+ var mod = i % 6;
733
+ var r = [v, q, p, p, t, v][mod];
734
+ var g = [t, v, v, q, p, p][mod];
735
+ var b = [p, p, t, v, v, q][mod];
736
+ return { r: r * 255, g: g * 255, b: b * 255 };
737
+ }
738
+ /**
739
+ * Converts an RGB color to hex
740
+ *
741
+ * Assumes r, g, and b are contained in the set [0, 255]
742
+ * Returns a 3 or 6 character hex
743
+ */
744
+ function rgbToHex(r, g, b, allow3Char) {
745
+ var hex = [
746
+ pad2(Math.round(r).toString(16)),
747
+ pad2(Math.round(g).toString(16)),
748
+ pad2(Math.round(b).toString(16)),
749
+ ];
750
+ // Return a 3 character hex if possible
751
+ if (allow3Char &&
752
+ hex[0].startsWith(hex[0].charAt(1)) &&
753
+ hex[1].startsWith(hex[1].charAt(1)) &&
754
+ hex[2].startsWith(hex[2].charAt(1))) {
755
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
756
+ }
757
+ return hex.join('');
758
+ }
759
+ /**
760
+ * Converts an RGBA color plus alpha transparency to hex
761
+ *
762
+ * Assumes r, g, b are contained in the set [0, 255] and
763
+ * a in [0, 1]. Returns a 4 or 8 character rgba hex
764
+ */
765
+ // eslint-disable-next-line max-params
766
+ function rgbaToHex(r, g, b, a, allow4Char) {
767
+ var hex = [
768
+ pad2(Math.round(r).toString(16)),
769
+ pad2(Math.round(g).toString(16)),
770
+ pad2(Math.round(b).toString(16)),
771
+ pad2(convertDecimalToHex(a)),
772
+ ];
773
+ // Return a 4 character hex if possible
774
+ if (allow4Char &&
775
+ hex[0].startsWith(hex[0].charAt(1)) &&
776
+ hex[1].startsWith(hex[1].charAt(1)) &&
777
+ hex[2].startsWith(hex[2].charAt(1)) &&
778
+ hex[3].startsWith(hex[3].charAt(1))) {
779
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
780
+ }
781
+ return hex.join('');
782
+ }
783
+ /** Converts a decimal to a hex value */
784
+ function convertDecimalToHex(d) {
785
+ return Math.round(parseFloat(d) * 255).toString(16);
786
+ }
787
+ /** Converts a hex value to a decimal */
788
+ function convertHexToDecimal(h) {
789
+ return parseIntFromHex(h) / 255;
790
+ }
791
+ /** Parse a base-16 hex value into a base-10 integer */
792
+ function parseIntFromHex(val) {
793
+ return parseInt(val, 16);
794
+ }
795
+ function numberInputToObject(color) {
796
+ return {
797
+ r: color >> 16,
798
+ g: (color & 0xff00) >> 8,
799
+ b: color & 0xff,
800
+ };
801
+ }
802
+
803
+ // https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
804
+ /**
805
+ * @hidden
806
+ */
807
+ var names = {
808
+ aliceblue: '#f0f8ff',
809
+ antiquewhite: '#faebd7',
810
+ aqua: '#00ffff',
811
+ aquamarine: '#7fffd4',
812
+ azure: '#f0ffff',
813
+ beige: '#f5f5dc',
814
+ bisque: '#ffe4c4',
815
+ black: '#000000',
816
+ blanchedalmond: '#ffebcd',
817
+ blue: '#0000ff',
818
+ blueviolet: '#8a2be2',
819
+ brown: '#a52a2a',
820
+ burlywood: '#deb887',
821
+ cadetblue: '#5f9ea0',
822
+ chartreuse: '#7fff00',
823
+ chocolate: '#d2691e',
824
+ coral: '#ff7f50',
825
+ cornflowerblue: '#6495ed',
826
+ cornsilk: '#fff8dc',
827
+ crimson: '#dc143c',
828
+ cyan: '#00ffff',
829
+ darkblue: '#00008b',
830
+ darkcyan: '#008b8b',
831
+ darkgoldenrod: '#b8860b',
832
+ darkgray: '#a9a9a9',
833
+ darkgreen: '#006400',
834
+ darkgrey: '#a9a9a9',
835
+ darkkhaki: '#bdb76b',
836
+ darkmagenta: '#8b008b',
837
+ darkolivegreen: '#556b2f',
838
+ darkorange: '#ff8c00',
839
+ darkorchid: '#9932cc',
840
+ darkred: '#8b0000',
841
+ darksalmon: '#e9967a',
842
+ darkseagreen: '#8fbc8f',
843
+ darkslateblue: '#483d8b',
844
+ darkslategray: '#2f4f4f',
845
+ darkslategrey: '#2f4f4f',
846
+ darkturquoise: '#00ced1',
847
+ darkviolet: '#9400d3',
848
+ deeppink: '#ff1493',
849
+ deepskyblue: '#00bfff',
850
+ dimgray: '#696969',
851
+ dimgrey: '#696969',
852
+ dodgerblue: '#1e90ff',
853
+ firebrick: '#b22222',
854
+ floralwhite: '#fffaf0',
855
+ forestgreen: '#228b22',
856
+ fuchsia: '#ff00ff',
857
+ gainsboro: '#dcdcdc',
858
+ ghostwhite: '#f8f8ff',
859
+ goldenrod: '#daa520',
860
+ gold: '#ffd700',
861
+ gray: '#808080',
862
+ green: '#008000',
863
+ greenyellow: '#adff2f',
864
+ grey: '#808080',
865
+ honeydew: '#f0fff0',
866
+ hotpink: '#ff69b4',
867
+ indianred: '#cd5c5c',
868
+ indigo: '#4b0082',
869
+ ivory: '#fffff0',
870
+ khaki: '#f0e68c',
871
+ lavenderblush: '#fff0f5',
872
+ lavender: '#e6e6fa',
873
+ lawngreen: '#7cfc00',
874
+ lemonchiffon: '#fffacd',
875
+ lightblue: '#add8e6',
876
+ lightcoral: '#f08080',
877
+ lightcyan: '#e0ffff',
878
+ lightgoldenrodyellow: '#fafad2',
879
+ lightgray: '#d3d3d3',
880
+ lightgreen: '#90ee90',
881
+ lightgrey: '#d3d3d3',
882
+ lightpink: '#ffb6c1',
883
+ lightsalmon: '#ffa07a',
884
+ lightseagreen: '#20b2aa',
885
+ lightskyblue: '#87cefa',
886
+ lightslategray: '#778899',
887
+ lightslategrey: '#778899',
888
+ lightsteelblue: '#b0c4de',
889
+ lightyellow: '#ffffe0',
890
+ lime: '#00ff00',
891
+ limegreen: '#32cd32',
892
+ linen: '#faf0e6',
893
+ magenta: '#ff00ff',
894
+ maroon: '#800000',
895
+ mediumaquamarine: '#66cdaa',
896
+ mediumblue: '#0000cd',
897
+ mediumorchid: '#ba55d3',
898
+ mediumpurple: '#9370db',
899
+ mediumseagreen: '#3cb371',
900
+ mediumslateblue: '#7b68ee',
901
+ mediumspringgreen: '#00fa9a',
902
+ mediumturquoise: '#48d1cc',
903
+ mediumvioletred: '#c71585',
904
+ midnightblue: '#191970',
905
+ mintcream: '#f5fffa',
906
+ mistyrose: '#ffe4e1',
907
+ moccasin: '#ffe4b5',
908
+ navajowhite: '#ffdead',
909
+ navy: '#000080',
910
+ oldlace: '#fdf5e6',
911
+ olive: '#808000',
912
+ olivedrab: '#6b8e23',
913
+ orange: '#ffa500',
914
+ orangered: '#ff4500',
915
+ orchid: '#da70d6',
916
+ palegoldenrod: '#eee8aa',
917
+ palegreen: '#98fb98',
918
+ paleturquoise: '#afeeee',
919
+ palevioletred: '#db7093',
920
+ papayawhip: '#ffefd5',
921
+ peachpuff: '#ffdab9',
922
+ peru: '#cd853f',
923
+ pink: '#ffc0cb',
924
+ plum: '#dda0dd',
925
+ powderblue: '#b0e0e6',
926
+ purple: '#800080',
927
+ rebeccapurple: '#663399',
928
+ red: '#ff0000',
929
+ rosybrown: '#bc8f8f',
930
+ royalblue: '#4169e1',
931
+ saddlebrown: '#8b4513',
932
+ salmon: '#fa8072',
933
+ sandybrown: '#f4a460',
934
+ seagreen: '#2e8b57',
935
+ seashell: '#fff5ee',
936
+ sienna: '#a0522d',
937
+ silver: '#c0c0c0',
938
+ skyblue: '#87ceeb',
939
+ slateblue: '#6a5acd',
940
+ slategray: '#708090',
941
+ slategrey: '#708090',
942
+ snow: '#fffafa',
943
+ springgreen: '#00ff7f',
944
+ steelblue: '#4682b4',
945
+ tan: '#d2b48c',
946
+ teal: '#008080',
947
+ thistle: '#d8bfd8',
948
+ tomato: '#ff6347',
949
+ turquoise: '#40e0d0',
950
+ violet: '#ee82ee',
951
+ wheat: '#f5deb3',
952
+ white: '#ffffff',
953
+ whitesmoke: '#f5f5f5',
954
+ yellow: '#ffff00',
955
+ yellowgreen: '#9acd32',
956
+ };
957
+
958
+ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
959
+ /**
960
+ * Given a string or object, convert that input to RGB
961
+ *
962
+ * Possible string inputs:
963
+ * ```
964
+ * "red"
965
+ * "#f00" or "f00"
966
+ * "#ff0000" or "ff0000"
967
+ * "#ff000000" or "ff000000"
968
+ * "rgb 255 0 0" or "rgb (255, 0, 0)"
969
+ * "rgb 1.0 0 0" or "rgb (1, 0, 0)"
970
+ * "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
971
+ * "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
972
+ * "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
973
+ * "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
974
+ * "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
975
+ * ```
976
+ */
977
+ function inputToRGB(color) {
978
+ var rgb = { r: 0, g: 0, b: 0 };
979
+ var a = 1;
980
+ var s = null;
981
+ var v = null;
982
+ var l = null;
983
+ var ok = false;
984
+ var format = false;
985
+ if (typeof color === 'string') {
986
+ color = stringInputToObject(color);
987
+ }
988
+ if (typeof color === 'object') {
989
+ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
990
+ rgb = rgbToRgb(color.r, color.g, color.b);
991
+ ok = true;
992
+ format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
993
+ }
994
+ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
995
+ s = convertToPercentage(color.s);
996
+ v = convertToPercentage(color.v);
997
+ rgb = hsvToRgb(color.h, s, v);
998
+ ok = true;
999
+ format = 'hsv';
1000
+ }
1001
+ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
1002
+ s = convertToPercentage(color.s);
1003
+ l = convertToPercentage(color.l);
1004
+ rgb = hslToRgb(color.h, s, l);
1005
+ ok = true;
1006
+ format = 'hsl';
1007
+ }
1008
+ if (Object.prototype.hasOwnProperty.call(color, 'a')) {
1009
+ a = color.a;
1010
+ }
1011
+ }
1012
+ a = boundAlpha(a);
1013
+ return {
1014
+ ok: ok,
1015
+ format: color.format || format,
1016
+ r: Math.min(255, Math.max(rgb.r, 0)),
1017
+ g: Math.min(255, Math.max(rgb.g, 0)),
1018
+ b: Math.min(255, Math.max(rgb.b, 0)),
1019
+ a: a,
1020
+ };
1021
+ }
1022
+ // <http://www.w3.org/TR/css3-values/#integers>
1023
+ var CSS_INTEGER = '[-\\+]?\\d+%?';
1024
+ // <http://www.w3.org/TR/css3-values/#number-value>
1025
+ var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
1026
+ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
1027
+ var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")");
1028
+ // Actual matching.
1029
+ // Parentheses and commas are optional, but not required.
1030
+ // Whitespace can take the place of commas or opening paren
1031
+ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
1032
+ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
1033
+ var matchers = {
1034
+ CSS_UNIT: new RegExp(CSS_UNIT),
1035
+ rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
1036
+ rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
1037
+ hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
1038
+ hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
1039
+ hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
1040
+ hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
1041
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1042
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1043
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1044
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1045
+ };
1046
+ /**
1047
+ * Permissive string parsing. Take in a number of formats, and output an object
1048
+ * based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
1049
+ */
1050
+ function stringInputToObject(color) {
1051
+ color = color.trim().toLowerCase();
1052
+ if (color.length === 0) {
1053
+ return false;
1054
+ }
1055
+ var named = false;
1056
+ if (names[color]) {
1057
+ color = names[color];
1058
+ named = true;
1059
+ }
1060
+ else if (color === 'transparent') {
1061
+ return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
1062
+ }
1063
+ // Try to match string input using regular expressions.
1064
+ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
1065
+ // Just return an object and let the conversion functions handle that.
1066
+ // This way the result will be the same whether the tinycolor is initialized with string or object.
1067
+ var match = matchers.rgb.exec(color);
1068
+ if (match) {
1069
+ return { r: match[1], g: match[2], b: match[3] };
1070
+ }
1071
+ match = matchers.rgba.exec(color);
1072
+ if (match) {
1073
+ return { r: match[1], g: match[2], b: match[3], a: match[4] };
1074
+ }
1075
+ match = matchers.hsl.exec(color);
1076
+ if (match) {
1077
+ return { h: match[1], s: match[2], l: match[3] };
1078
+ }
1079
+ match = matchers.hsla.exec(color);
1080
+ if (match) {
1081
+ return { h: match[1], s: match[2], l: match[3], a: match[4] };
1082
+ }
1083
+ match = matchers.hsv.exec(color);
1084
+ if (match) {
1085
+ return { h: match[1], s: match[2], v: match[3] };
1086
+ }
1087
+ match = matchers.hsva.exec(color);
1088
+ if (match) {
1089
+ return { h: match[1], s: match[2], v: match[3], a: match[4] };
1090
+ }
1091
+ match = matchers.hex8.exec(color);
1092
+ if (match) {
1093
+ return {
1094
+ r: parseIntFromHex(match[1]),
1095
+ g: parseIntFromHex(match[2]),
1096
+ b: parseIntFromHex(match[3]),
1097
+ a: convertHexToDecimal(match[4]),
1098
+ format: named ? 'name' : 'hex8',
1099
+ };
1100
+ }
1101
+ match = matchers.hex6.exec(color);
1102
+ if (match) {
1103
+ return {
1104
+ r: parseIntFromHex(match[1]),
1105
+ g: parseIntFromHex(match[2]),
1106
+ b: parseIntFromHex(match[3]),
1107
+ format: named ? 'name' : 'hex',
1108
+ };
1109
+ }
1110
+ match = matchers.hex4.exec(color);
1111
+ if (match) {
1112
+ return {
1113
+ r: parseIntFromHex(match[1] + match[1]),
1114
+ g: parseIntFromHex(match[2] + match[2]),
1115
+ b: parseIntFromHex(match[3] + match[3]),
1116
+ a: convertHexToDecimal(match[4] + match[4]),
1117
+ format: named ? 'name' : 'hex8',
1118
+ };
1119
+ }
1120
+ match = matchers.hex3.exec(color);
1121
+ if (match) {
1122
+ return {
1123
+ r: parseIntFromHex(match[1] + match[1]),
1124
+ g: parseIntFromHex(match[2] + match[2]),
1125
+ b: parseIntFromHex(match[3] + match[3]),
1126
+ format: named ? 'name' : 'hex',
1127
+ };
1128
+ }
1129
+ return false;
1130
+ }
1131
+ /**
1132
+ * Check to see if it looks like a CSS unit
1133
+ * (see `matchers` above for definition).
1134
+ */
1135
+ function isValidCSSUnit(color) {
1136
+ return Boolean(matchers.CSS_UNIT.exec(String(color)));
1137
+ }
1138
+
1139
+ var TinyColor = /** @class */ (function () {
1140
+ function TinyColor(color, opts) {
1141
+ if (color === void 0) { color = ''; }
1142
+ if (opts === void 0) { opts = {}; }
1143
+ var _a;
1144
+ // If input is already a tinycolor, return itself
1145
+ if (color instanceof TinyColor) {
1146
+ // eslint-disable-next-line no-constructor-return
1147
+ return color;
1148
+ }
1149
+ if (typeof color === 'number') {
1150
+ color = numberInputToObject(color);
1151
+ }
1152
+ this.originalInput = color;
1153
+ var rgb = inputToRGB(color);
1154
+ this.originalInput = color;
1155
+ this.r = rgb.r;
1156
+ this.g = rgb.g;
1157
+ this.b = rgb.b;
1158
+ this.a = rgb.a;
1159
+ this.roundA = Math.round(100 * this.a) / 100;
1160
+ this.format = (_a = opts.format) !== null && _a !== void 0 ? _a : rgb.format;
1161
+ this.gradientType = opts.gradientType;
1162
+ // Don't let the range of [0,255] come back in [0,1].
1163
+ // Potentially lose a little bit of precision here, but will fix issues where
1164
+ // .5 gets interpreted as half of the total, instead of half of 1
1165
+ // If it was supposed to be 128, this was already taken care of by `inputToRgb`
1166
+ if (this.r < 1) {
1167
+ this.r = Math.round(this.r);
1168
+ }
1169
+ if (this.g < 1) {
1170
+ this.g = Math.round(this.g);
1171
+ }
1172
+ if (this.b < 1) {
1173
+ this.b = Math.round(this.b);
1174
+ }
1175
+ this.isValid = rgb.ok;
1176
+ }
1177
+ TinyColor.prototype.isDark = function () {
1178
+ return this.getBrightness() < 128;
1179
+ };
1180
+ TinyColor.prototype.isLight = function () {
1181
+ return !this.isDark();
1182
+ };
1183
+ /**
1184
+ * Returns the perceived brightness of the color, from 0-255.
1185
+ */
1186
+ TinyColor.prototype.getBrightness = function () {
1187
+ // http://www.w3.org/TR/AERT#color-contrast
1188
+ var rgb = this.toRgb();
1189
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
1190
+ };
1191
+ /**
1192
+ * Returns the perceived luminance of a color, from 0-1.
1193
+ */
1194
+ TinyColor.prototype.getLuminance = function () {
1195
+ // http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
1196
+ var rgb = this.toRgb();
1197
+ var R;
1198
+ var G;
1199
+ var B;
1200
+ var RsRGB = rgb.r / 255;
1201
+ var GsRGB = rgb.g / 255;
1202
+ var BsRGB = rgb.b / 255;
1203
+ if (RsRGB <= 0.03928) {
1204
+ R = RsRGB / 12.92;
1205
+ }
1206
+ else {
1207
+ // eslint-disable-next-line prefer-exponentiation-operator
1208
+ R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
1209
+ }
1210
+ if (GsRGB <= 0.03928) {
1211
+ G = GsRGB / 12.92;
1212
+ }
1213
+ else {
1214
+ // eslint-disable-next-line prefer-exponentiation-operator
1215
+ G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
1216
+ }
1217
+ if (BsRGB <= 0.03928) {
1218
+ B = BsRGB / 12.92;
1219
+ }
1220
+ else {
1221
+ // eslint-disable-next-line prefer-exponentiation-operator
1222
+ B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
1223
+ }
1224
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
1225
+ };
1226
+ /**
1227
+ * Returns the alpha value of a color, from 0-1.
1228
+ */
1229
+ TinyColor.prototype.getAlpha = function () {
1230
+ return this.a;
1231
+ };
1232
+ /**
1233
+ * Sets the alpha value on the current color.
1234
+ *
1235
+ * @param alpha - The new alpha value. The accepted range is 0-1.
1236
+ */
1237
+ TinyColor.prototype.setAlpha = function (alpha) {
1238
+ this.a = boundAlpha(alpha);
1239
+ this.roundA = Math.round(100 * this.a) / 100;
1240
+ return this;
1241
+ };
1242
+ /**
1243
+ * Returns whether the color is monochrome.
1244
+ */
1245
+ TinyColor.prototype.isMonochrome = function () {
1246
+ var s = this.toHsl().s;
1247
+ return s === 0;
1248
+ };
1249
+ /**
1250
+ * Returns the object as a HSVA object.
1251
+ */
1252
+ TinyColor.prototype.toHsv = function () {
1253
+ var hsv = rgbToHsv(this.r, this.g, this.b);
1254
+ return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };
1255
+ };
1256
+ /**
1257
+ * Returns the hsva values interpolated into a string with the following format:
1258
+ * "hsva(xxx, xxx, xxx, xx)".
1259
+ */
1260
+ TinyColor.prototype.toHsvString = function () {
1261
+ var hsv = rgbToHsv(this.r, this.g, this.b);
1262
+ var h = Math.round(hsv.h * 360);
1263
+ var s = Math.round(hsv.s * 100);
1264
+ var v = Math.round(hsv.v * 100);
1265
+ return this.a === 1 ? "hsv(".concat(h, ", ").concat(s, "%, ").concat(v, "%)") : "hsva(".concat(h, ", ").concat(s, "%, ").concat(v, "%, ").concat(this.roundA, ")");
1266
+ };
1267
+ /**
1268
+ * Returns the object as a HSLA object.
1269
+ */
1270
+ TinyColor.prototype.toHsl = function () {
1271
+ var hsl = rgbToHsl(this.r, this.g, this.b);
1272
+ return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };
1273
+ };
1274
+ /**
1275
+ * Returns the hsla values interpolated into a string with the following format:
1276
+ * "hsla(xxx, xxx, xxx, xx)".
1277
+ */
1278
+ TinyColor.prototype.toHslString = function () {
1279
+ var hsl = rgbToHsl(this.r, this.g, this.b);
1280
+ var h = Math.round(hsl.h * 360);
1281
+ var s = Math.round(hsl.s * 100);
1282
+ var l = Math.round(hsl.l * 100);
1283
+ return this.a === 1 ? "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)") : "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(this.roundA, ")");
1284
+ };
1285
+ /**
1286
+ * Returns the hex value of the color.
1287
+ * @param allow3Char will shorten hex value to 3 char if possible
1288
+ */
1289
+ TinyColor.prototype.toHex = function (allow3Char) {
1290
+ if (allow3Char === void 0) { allow3Char = false; }
1291
+ return rgbToHex(this.r, this.g, this.b, allow3Char);
1292
+ };
1293
+ /**
1294
+ * Returns the hex value of the color -with a # prefixed.
1295
+ * @param allow3Char will shorten hex value to 3 char if possible
1296
+ */
1297
+ TinyColor.prototype.toHexString = function (allow3Char) {
1298
+ if (allow3Char === void 0) { allow3Char = false; }
1299
+ return '#' + this.toHex(allow3Char);
1300
+ };
1301
+ /**
1302
+ * Returns the hex 8 value of the color.
1303
+ * @param allow4Char will shorten hex value to 4 char if possible
1304
+ */
1305
+ TinyColor.prototype.toHex8 = function (allow4Char) {
1306
+ if (allow4Char === void 0) { allow4Char = false; }
1307
+ return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
1308
+ };
1309
+ /**
1310
+ * Returns the hex 8 value of the color -with a # prefixed.
1311
+ * @param allow4Char will shorten hex value to 4 char if possible
1312
+ */
1313
+ TinyColor.prototype.toHex8String = function (allow4Char) {
1314
+ if (allow4Char === void 0) { allow4Char = false; }
1315
+ return '#' + this.toHex8(allow4Char);
1316
+ };
1317
+ /**
1318
+ * Returns the shorter hex value of the color depends on its alpha -with a # prefixed.
1319
+ * @param allowShortChar will shorten hex value to 3 or 4 char if possible
1320
+ */
1321
+ TinyColor.prototype.toHexShortString = function (allowShortChar) {
1322
+ if (allowShortChar === void 0) { allowShortChar = false; }
1323
+ return this.a === 1 ? this.toHexString(allowShortChar) : this.toHex8String(allowShortChar);
1324
+ };
1325
+ /**
1326
+ * Returns the object as a RGBA object.
1327
+ */
1328
+ TinyColor.prototype.toRgb = function () {
1329
+ return {
1330
+ r: Math.round(this.r),
1331
+ g: Math.round(this.g),
1332
+ b: Math.round(this.b),
1333
+ a: this.a,
1334
+ };
1335
+ };
1336
+ /**
1337
+ * Returns the RGBA values interpolated into a string with the following format:
1338
+ * "RGBA(xxx, xxx, xxx, xx)".
1339
+ */
1340
+ TinyColor.prototype.toRgbString = function () {
1341
+ var r = Math.round(this.r);
1342
+ var g = Math.round(this.g);
1343
+ var b = Math.round(this.b);
1344
+ return this.a === 1 ? "rgb(".concat(r, ", ").concat(g, ", ").concat(b, ")") : "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(this.roundA, ")");
1345
+ };
1346
+ /**
1347
+ * Returns the object as a RGBA object.
1348
+ */
1349
+ TinyColor.prototype.toPercentageRgb = function () {
1350
+ var fmt = function (x) { return "".concat(Math.round(bound01(x, 255) * 100), "%"); };
1351
+ return {
1352
+ r: fmt(this.r),
1353
+ g: fmt(this.g),
1354
+ b: fmt(this.b),
1355
+ a: this.a,
1356
+ };
1357
+ };
1358
+ /**
1359
+ * Returns the RGBA relative values interpolated into a string
1360
+ */
1361
+ TinyColor.prototype.toPercentageRgbString = function () {
1362
+ var rnd = function (x) { return Math.round(bound01(x, 255) * 100); };
1363
+ return this.a === 1
1364
+ ? "rgb(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%)")
1365
+ : "rgba(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%, ").concat(this.roundA, ")");
1366
+ };
1367
+ /**
1368
+ * The 'real' name of the color -if there is one.
1369
+ */
1370
+ TinyColor.prototype.toName = function () {
1371
+ if (this.a === 0) {
1372
+ return 'transparent';
1373
+ }
1374
+ if (this.a < 1) {
1375
+ return false;
1376
+ }
1377
+ var hex = '#' + rgbToHex(this.r, this.g, this.b, false);
1378
+ for (var _i = 0, _a = Object.entries(names); _i < _a.length; _i++) {
1379
+ var _b = _a[_i], key = _b[0], value = _b[1];
1380
+ if (hex === value) {
1381
+ return key;
1382
+ }
1383
+ }
1384
+ return false;
1385
+ };
1386
+ TinyColor.prototype.toString = function (format) {
1387
+ var formatSet = Boolean(format);
1388
+ format = format !== null && format !== void 0 ? format : this.format;
1389
+ var formattedString = false;
1390
+ var hasAlpha = this.a < 1 && this.a >= 0;
1391
+ var needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith('hex') || format === 'name');
1392
+ if (needsAlphaFormat) {
1393
+ // Special case for "transparent", all other non-alpha formats
1394
+ // will return rgba when there is transparency.
1395
+ if (format === 'name' && this.a === 0) {
1396
+ return this.toName();
1397
+ }
1398
+ return this.toRgbString();
1399
+ }
1400
+ if (format === 'rgb') {
1401
+ formattedString = this.toRgbString();
1402
+ }
1403
+ if (format === 'prgb') {
1404
+ formattedString = this.toPercentageRgbString();
1405
+ }
1406
+ if (format === 'hex' || format === 'hex6') {
1407
+ formattedString = this.toHexString();
1408
+ }
1409
+ if (format === 'hex3') {
1410
+ formattedString = this.toHexString(true);
1411
+ }
1412
+ if (format === 'hex4') {
1413
+ formattedString = this.toHex8String(true);
1414
+ }
1415
+ if (format === 'hex8') {
1416
+ formattedString = this.toHex8String();
1417
+ }
1418
+ if (format === 'name') {
1419
+ formattedString = this.toName();
1420
+ }
1421
+ if (format === 'hsl') {
1422
+ formattedString = this.toHslString();
1423
+ }
1424
+ if (format === 'hsv') {
1425
+ formattedString = this.toHsvString();
1426
+ }
1427
+ return formattedString || this.toHexString();
1428
+ };
1429
+ TinyColor.prototype.toNumber = function () {
1430
+ return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
1431
+ };
1432
+ TinyColor.prototype.clone = function () {
1433
+ return new TinyColor(this.toString());
1434
+ };
1435
+ /**
1436
+ * Lighten the color a given amount. Providing 100 will always return white.
1437
+ * @param amount - valid between 1-100
1438
+ */
1439
+ TinyColor.prototype.lighten = function (amount) {
1440
+ if (amount === void 0) { amount = 10; }
1441
+ var hsl = this.toHsl();
1442
+ hsl.l += amount / 100;
1443
+ hsl.l = clamp01(hsl.l);
1444
+ return new TinyColor(hsl);
1445
+ };
1446
+ /**
1447
+ * Brighten the color a given amount, from 0 to 100.
1448
+ * @param amount - valid between 1-100
1449
+ */
1450
+ TinyColor.prototype.brighten = function (amount) {
1451
+ if (amount === void 0) { amount = 10; }
1452
+ var rgb = this.toRgb();
1453
+ rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
1454
+ rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
1455
+ rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
1456
+ return new TinyColor(rgb);
1457
+ };
1458
+ /**
1459
+ * Darken the color a given amount, from 0 to 100.
1460
+ * Providing 100 will always return black.
1461
+ * @param amount - valid between 1-100
1462
+ */
1463
+ TinyColor.prototype.darken = function (amount) {
1464
+ if (amount === void 0) { amount = 10; }
1465
+ var hsl = this.toHsl();
1466
+ hsl.l -= amount / 100;
1467
+ hsl.l = clamp01(hsl.l);
1468
+ return new TinyColor(hsl);
1469
+ };
1470
+ /**
1471
+ * Mix the color with pure white, from 0 to 100.
1472
+ * Providing 0 will do nothing, providing 100 will always return white.
1473
+ * @param amount - valid between 1-100
1474
+ */
1475
+ TinyColor.prototype.tint = function (amount) {
1476
+ if (amount === void 0) { amount = 10; }
1477
+ return this.mix('white', amount);
1478
+ };
1479
+ /**
1480
+ * Mix the color with pure black, from 0 to 100.
1481
+ * Providing 0 will do nothing, providing 100 will always return black.
1482
+ * @param amount - valid between 1-100
1483
+ */
1484
+ TinyColor.prototype.shade = function (amount) {
1485
+ if (amount === void 0) { amount = 10; }
1486
+ return this.mix('black', amount);
1487
+ };
1488
+ /**
1489
+ * Desaturate the color a given amount, from 0 to 100.
1490
+ * Providing 100 will is the same as calling greyscale
1491
+ * @param amount - valid between 1-100
1492
+ */
1493
+ TinyColor.prototype.desaturate = function (amount) {
1494
+ if (amount === void 0) { amount = 10; }
1495
+ var hsl = this.toHsl();
1496
+ hsl.s -= amount / 100;
1497
+ hsl.s = clamp01(hsl.s);
1498
+ return new TinyColor(hsl);
1499
+ };
1500
+ /**
1501
+ * Saturate the color a given amount, from 0 to 100.
1502
+ * @param amount - valid between 1-100
1503
+ */
1504
+ TinyColor.prototype.saturate = function (amount) {
1505
+ if (amount === void 0) { amount = 10; }
1506
+ var hsl = this.toHsl();
1507
+ hsl.s += amount / 100;
1508
+ hsl.s = clamp01(hsl.s);
1509
+ return new TinyColor(hsl);
1510
+ };
1511
+ /**
1512
+ * Completely desaturates a color into greyscale.
1513
+ * Same as calling `desaturate(100)`
1514
+ */
1515
+ TinyColor.prototype.greyscale = function () {
1516
+ return this.desaturate(100);
1517
+ };
1518
+ /**
1519
+ * Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
1520
+ * Values outside of this range will be wrapped into this range.
1521
+ */
1522
+ TinyColor.prototype.spin = function (amount) {
1523
+ var hsl = this.toHsl();
1524
+ var hue = (hsl.h + amount) % 360;
1525
+ hsl.h = hue < 0 ? 360 + hue : hue;
1526
+ return new TinyColor(hsl);
1527
+ };
1528
+ /**
1529
+ * Mix the current color a given amount with another color, from 0 to 100.
1530
+ * 0 means no mixing (return current color).
1531
+ */
1532
+ TinyColor.prototype.mix = function (color, amount) {
1533
+ if (amount === void 0) { amount = 50; }
1534
+ var rgb1 = this.toRgb();
1535
+ var rgb2 = new TinyColor(color).toRgb();
1536
+ var p = amount / 100;
1537
+ var rgba = {
1538
+ r: (rgb2.r - rgb1.r) * p + rgb1.r,
1539
+ g: (rgb2.g - rgb1.g) * p + rgb1.g,
1540
+ b: (rgb2.b - rgb1.b) * p + rgb1.b,
1541
+ a: (rgb2.a - rgb1.a) * p + rgb1.a,
1542
+ };
1543
+ return new TinyColor(rgba);
1544
+ };
1545
+ TinyColor.prototype.analogous = function (results, slices) {
1546
+ if (results === void 0) { results = 6; }
1547
+ if (slices === void 0) { slices = 30; }
1548
+ var hsl = this.toHsl();
1549
+ var part = 360 / slices;
1550
+ var ret = [this];
1551
+ for (hsl.h = (hsl.h - ((part * results) >> 1) + 720) % 360; --results;) {
1552
+ hsl.h = (hsl.h + part) % 360;
1553
+ ret.push(new TinyColor(hsl));
1554
+ }
1555
+ return ret;
1556
+ };
1557
+ /**
1558
+ * taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js
1559
+ */
1560
+ TinyColor.prototype.complement = function () {
1561
+ var hsl = this.toHsl();
1562
+ hsl.h = (hsl.h + 180) % 360;
1563
+ return new TinyColor(hsl);
1564
+ };
1565
+ TinyColor.prototype.monochromatic = function (results) {
1566
+ if (results === void 0) { results = 6; }
1567
+ var hsv = this.toHsv();
1568
+ var h = hsv.h;
1569
+ var s = hsv.s;
1570
+ var v = hsv.v;
1571
+ var res = [];
1572
+ var modification = 1 / results;
1573
+ while (results--) {
1574
+ res.push(new TinyColor({ h: h, s: s, v: v }));
1575
+ v = (v + modification) % 1;
1576
+ }
1577
+ return res;
1578
+ };
1579
+ TinyColor.prototype.splitcomplement = function () {
1580
+ var hsl = this.toHsl();
1581
+ var h = hsl.h;
1582
+ return [
1583
+ this,
1584
+ new TinyColor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),
1585
+ new TinyColor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l }),
1586
+ ];
1587
+ };
1588
+ /**
1589
+ * Compute how the color would appear on a background
1590
+ */
1591
+ TinyColor.prototype.onBackground = function (background) {
1592
+ var fg = this.toRgb();
1593
+ var bg = new TinyColor(background).toRgb();
1594
+ var alpha = fg.a + bg.a * (1 - fg.a);
1595
+ return new TinyColor({
1596
+ r: (fg.r * fg.a + bg.r * bg.a * (1 - fg.a)) / alpha,
1597
+ g: (fg.g * fg.a + bg.g * bg.a * (1 - fg.a)) / alpha,
1598
+ b: (fg.b * fg.a + bg.b * bg.a * (1 - fg.a)) / alpha,
1599
+ a: alpha,
1600
+ });
1601
+ };
1602
+ /**
1603
+ * Alias for `polyad(3)`
1604
+ */
1605
+ TinyColor.prototype.triad = function () {
1606
+ return this.polyad(3);
1607
+ };
1608
+ /**
1609
+ * Alias for `polyad(4)`
1610
+ */
1611
+ TinyColor.prototype.tetrad = function () {
1612
+ return this.polyad(4);
1613
+ };
1614
+ /**
1615
+ * Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)
1616
+ * monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...
1617
+ */
1618
+ TinyColor.prototype.polyad = function (n) {
1619
+ var hsl = this.toHsl();
1620
+ var h = hsl.h;
1621
+ var result = [this];
1622
+ var increment = 360 / n;
1623
+ for (var i = 1; i < n; i++) {
1624
+ result.push(new TinyColor({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));
1625
+ }
1626
+ return result;
1627
+ };
1628
+ /**
1629
+ * compare color vs current color
1630
+ */
1631
+ TinyColor.prototype.equals = function (color) {
1632
+ return this.toRgbString() === new TinyColor(color).toRgbString();
1633
+ };
1634
+ return TinyColor;
1635
+ }());
1636
+
1637
+ function darken(color, amount = 20) {
1638
+ return color.mix("#141414", amount).toString();
1639
+ }
1640
+ function useButtonCustomStyle(props) {
1641
+ const _disabled = useFormDisabled();
1642
+ const ns = useNamespace("button");
1643
+ return computed(() => {
1644
+ let styles = {};
1645
+ const buttonColor = props.color;
1646
+ if (buttonColor) {
1647
+ const color = new TinyColor(buttonColor);
1648
+ const activeBgColor = props.dark ? color.tint(20).toString() : darken(color, 20);
1649
+ if (props.plain) {
1650
+ styles = ns.cssVarBlock({
1651
+ "bg-color": props.dark ? darken(color, 90) : color.tint(90).toString(),
1652
+ "text-color": buttonColor,
1653
+ "border-color": props.dark ? darken(color, 50) : color.tint(50).toString(),
1654
+ "hover-text-color": `var(${ns.cssVarName("color-white")})`,
1655
+ "hover-bg-color": buttonColor,
1656
+ "hover-border-color": buttonColor,
1657
+ "active-bg-color": activeBgColor,
1658
+ "active-text-color": `var(${ns.cssVarName("color-white")})`,
1659
+ "active-border-color": activeBgColor
1660
+ });
1661
+ if (_disabled.value) {
1662
+ styles[ns.cssVarBlockName("disabled-bg-color")] = props.dark ? darken(color, 90) : color.tint(90).toString();
1663
+ styles[ns.cssVarBlockName("disabled-text-color")] = props.dark ? darken(color, 50) : color.tint(50).toString();
1664
+ styles[ns.cssVarBlockName("disabled-border-color")] = props.dark ? darken(color, 80) : color.tint(80).toString();
1665
+ }
1666
+ } else {
1667
+ const hoverBgColor = props.dark ? darken(color, 30) : color.tint(30).toString();
1668
+ const textColor = color.isDark() ? `var(${ns.cssVarName("color-white")})` : `var(${ns.cssVarName("color-black")})`;
1669
+ styles = ns.cssVarBlock({
1670
+ "bg-color": buttonColor,
1671
+ "text-color": textColor,
1672
+ "border-color": buttonColor,
1673
+ "hover-bg-color": hoverBgColor,
1674
+ "hover-text-color": textColor,
1675
+ "hover-border-color": hoverBgColor,
1676
+ "active-bg-color": activeBgColor,
1677
+ "active-border-color": activeBgColor
1678
+ });
1679
+ if (_disabled.value) {
1680
+ const disabledButtonColor = props.dark ? darken(color, 50) : color.tint(50).toString();
1681
+ styles[ns.cssVarBlockName("disabled-bg-color")] = disabledButtonColor;
1682
+ styles[ns.cssVarBlockName("disabled-text-color")] = props.dark ? "rgba(255, 255, 255, 0.5)" : `var(${ns.cssVarName("color-white")})`;
1683
+ styles[ns.cssVarBlockName("disabled-border-color")] = disabledButtonColor;
1684
+ }
1685
+ }
1686
+ }
1687
+ return styles;
1688
+ });
1689
+ }
1690
+
1691
+ const __default__$1 = defineComponent({
1692
+ name: "ElButton"
1693
+ });
1694
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1695
+ ...__default__$1,
1696
+ props: buttonProps$1,
1697
+ emits: buttonEmits,
1698
+ setup(__props, { expose, emit }) {
1699
+ const props = __props;
1700
+ const buttonStyle = useButtonCustomStyle(props);
1701
+ const ns = useNamespace("button");
1702
+ const { _ref, _size, _type, _disabled, _props, shouldAddSpace, handleClick } = useButton(props, emit);
1703
+ expose({
1704
+ ref: _ref,
1705
+ size: _size,
1706
+ type: _type,
1707
+ disabled: _disabled,
1708
+ shouldAddSpace
1709
+ });
1710
+ return (_ctx, _cache) => {
1711
+ return openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), mergeProps({
1712
+ ref_key: "_ref",
1713
+ ref: _ref
1714
+ }, unref(_props), {
1715
+ class: [
1716
+ unref(ns).b(),
1717
+ unref(ns).m(unref(_type)),
1718
+ unref(ns).m(unref(_size)),
1719
+ unref(ns).is("disabled", unref(_disabled)),
1720
+ unref(ns).is("loading", _ctx.loading),
1721
+ unref(ns).is("plain", _ctx.plain),
1722
+ unref(ns).is("round", _ctx.round),
1723
+ unref(ns).is("circle", _ctx.circle),
1724
+ unref(ns).is("text", _ctx.text),
1725
+ unref(ns).is("link", _ctx.link),
1726
+ unref(ns).is("has-bg", _ctx.bg)
1727
+ ],
1728
+ style: unref(buttonStyle),
1729
+ onClick: unref(handleClick)
1730
+ }), {
1731
+ default: withCtx(() => [
1732
+ _ctx.loading ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1733
+ _ctx.$slots.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }) : (openBlock(), createBlock(unref(ElIcon), {
1734
+ key: 1,
1735
+ class: normalizeClass(unref(ns).is("loading"))
1736
+ }, {
1737
+ default: withCtx(() => [
1738
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.loadingIcon)))
1739
+ ]),
1740
+ _: 1
1741
+ }, 8, ["class"]))
1742
+ ], 64)) : _ctx.icon || _ctx.$slots.icon ? (openBlock(), createBlock(unref(ElIcon), { key: 1 }, {
1743
+ default: withCtx(() => [
1744
+ _ctx.icon ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon), { key: 0 })) : renderSlot(_ctx.$slots, "icon", { key: 1 })
1745
+ ]),
1746
+ _: 3
1747
+ })) : createCommentVNode("v-if", true),
1748
+ _ctx.$slots.default ? (openBlock(), createElementBlock("span", {
1749
+ key: 2,
1750
+ class: normalizeClass({ [unref(ns).em("text", "expand")]: unref(shouldAddSpace) })
1751
+ }, [
1752
+ renderSlot(_ctx.$slots, "default")
1753
+ ], 2)) : createCommentVNode("v-if", true)
1754
+ ]),
1755
+ _: 3
1756
+ }, 16, ["class", "style", "onClick"]);
1757
+ };
1758
+ }
1759
+ });
1760
+ var Button = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/button/src/button.vue"]]);
1761
+
1762
+ const buttonGroupProps = {
1763
+ size: buttonProps$1.size,
1764
+ type: buttonProps$1.type
1765
+ };
1766
+
1767
+ const __default__ = defineComponent({
1768
+ name: "ElButtonGroup"
1769
+ });
1770
+ const _sfc_main = /* @__PURE__ */ defineComponent({
1771
+ ...__default__,
1772
+ props: buttonGroupProps,
1773
+ setup(__props) {
1774
+ const props = __props;
1775
+ provide(buttonGroupContextKey, reactive({
1776
+ size: toRef(props, "size"),
1777
+ type: toRef(props, "type")
1778
+ }));
1779
+ const ns = useNamespace("button");
1780
+ return (_ctx, _cache) => {
1781
+ return openBlock(), createElementBlock("div", {
1782
+ class: normalizeClass(`${unref(ns).b("group")}`)
1783
+ }, [
1784
+ renderSlot(_ctx.$slots, "default")
1785
+ ], 2);
1786
+ };
1787
+ }
1788
+ });
1789
+ var ButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/button/src/button-group.vue"]]);
1790
+
1791
+ const ElButton = withInstall(Button, {
1792
+ ButtonGroup
1793
+ });
1794
+ withNoopInstall(ButtonGroup);
1795
+
1796
+ const buttonProps = {
1797
+ type: {
1798
+ type: String,
1799
+ default: 'text'
1800
+ }
1801
+ };
1802
+
1803
+ var script = defineComponent({
1804
+ name: 'WButton',
1805
+ components: {
1806
+ ElButton
1807
+ },
1808
+ props: buttonProps,
1809
+ setup() {
1810
+ const handlerClick = () => {
1811
+ alert('WQ!!!!!!');
1812
+ };
1813
+ return {
1814
+ handlerClick
1815
+ };
1816
+ }
1817
+ });
1818
+
1819
+ const _hoisted_1 = /*#__PURE__*/createTextVNode("Primary");
1820
+
1821
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
1822
+ const _component_el_button = resolveComponent("el-button");
1823
+
1824
+ return (openBlock(), createBlock(_component_el_button, {
1825
+ type: _ctx.type,
1826
+ onClick: _ctx.handlerClick
1827
+ }, {
1828
+ default: withCtx(() => [
1829
+ _hoisted_1
1830
+ ]),
1831
+ _: 1 /* STABLE */
1832
+ }, 8 /* PROPS */, ["type", "onClick"]))
1833
+ }
1834
+
1835
+ script.render = render;
1836
+ script.__file = "packages/components/RxButton/src/button.vue";
1837
+
1838
+ const WButton = withInstall$1(script);
1839
+
1840
+ var components = /*#__PURE__*/Object.freeze({
1841
+ __proto__: null,
1842
+ WButton: WButton
1843
+ });
1844
+
1845
+ const install = (app) => {
1846
+ Object.entries(components).forEach(([name, component]) => {
1847
+ app.component(name, component);
1848
+ });
1849
+ };
1850
+ var index = {
1851
+ install
1852
+ };
1853
+
1854
+ export { WButton, index as default };