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