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