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