rx-compo 1.0.53 → 1.0.55

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