cck-ui 0.0.1
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/LICENSE +13 -0
- package/README.md +3 -0
- package/dist/index.css +1 -0
- package/dist/index.full.js +2957 -0
- package/dist/index.full.min.js +21 -0
- package/dist/index.full.min.js.map +1 -0
- package/dist/index.full.min.mjs +21 -0
- package/dist/index.full.min.mjs.map +1 -0
- package/dist/index.full.mjs +2945 -0
- package/es/_virtual/_rolldown/runtime.mjs +27 -0
- package/es/component.d.ts +6 -0
- package/es/component.mjs +8 -0
- package/es/component.mjs.map +1 -0
- package/es/components/base/style/css.mjs +1 -0
- package/es/components/base/style/index.mjs +1 -0
- package/es/components/button/index.d.ts +8 -0
- package/es/components/button/src/button-custom.d.ts +6 -0
- package/es/components/button/src/button.types.d.ts +77 -0
- package/es/components/button/src/button.vue.d.ts +28 -0
- package/es/components/button/src/use-button.d.ts +14 -0
- package/es/components/button/style/css.mjs +2 -0
- package/es/components/form/index.d.ts +4 -0
- package/es/components/form/src/constants.d.ts +7 -0
- package/es/components/form/src/form.types.d.ts +10 -0
- package/es/components/form/src/hooks/index.d.ts +2 -0
- package/es/components/form/src/hooks/use-form-common-props.d.ts +7 -0
- package/es/components/icon/index.d.ts +26 -0
- package/es/components/icon/src/icon.types.d.ts +13 -0
- package/es/components/icon/src/icon.vue.d.ts +17 -0
- package/es/components/icon/style/css.mjs +1 -0
- package/es/components/icon/style/index.mjs +1 -0
- package/es/components/index.d.ts +5 -0
- package/es/constants/index.d.ts +3 -0
- package/es/constants/key.d.ts +4 -0
- package/es/constants/sizes.d.ts +12 -0
- package/es/defaults.d.ts +6 -0
- package/es/defaults.mjs +9 -0
- package/es/defaults.mjs.map +1 -0
- package/es/hooks/index.d.ts +4 -0
- package/es/hooks/use-namespace/index.d.ts +27 -0
- package/es/hooks/use-prop/index.d.ts +6 -0
- package/es/hooks/use-theme/index.d.ts +5 -0
- package/es/index.d.ts +11 -0
- package/es/index.mjs +11 -0
- package/es/index.mjs.map +1 -0
- package/es/make-installer.d.ts +8 -0
- package/es/make-installer.mjs +14 -0
- package/es/make-installer.mjs.map +1 -0
- package/es/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/conversion.mjs +268 -0
- package/es/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/conversion.mjs.map +1 -0
- package/es/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/css-color-names.mjs +158 -0
- package/es/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/css-color-names.mjs.map +1 -0
- package/es/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/format-input.mjs +192 -0
- package/es/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/format-input.mjs.map +1 -0
- package/es/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/index.mjs +456 -0
- package/es/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/index.mjs.map +1 -0
- package/es/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/util.mjs +65 -0
- package/es/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/util.mjs.map +1 -0
- package/es/node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs +53 -0
- package/es/node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs.map +1 -0
- package/es/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.runtime.esm-bundler.mjs +22 -0
- package/es/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.runtime.esm-bundler.mjs.map +1 -0
- package/es/packages/components/button/index.mjs +8 -0
- package/es/packages/components/button/index.mjs.map +1 -0
- package/es/packages/components/button/src/button-custom.mjs +121 -0
- package/es/packages/components/button/src/button-custom.mjs.map +1 -0
- package/es/packages/components/button/src/button.mjs +7 -0
- package/es/packages/components/button/src/button.mjs.map +1 -0
- package/es/packages/components/button/src/button.types.mjs +0 -0
- package/es/packages/components/button/src/button.vue_vue_type_script_setup_true_lang.mjs +139 -0
- package/es/packages/components/button/src/button.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/es/packages/components/button/src/use-button.mjs +41 -0
- package/es/packages/components/button/src/use-button.mjs.map +1 -0
- package/es/packages/components/form/index.mjs +3 -0
- package/es/packages/components/form/src/constants.mjs +6 -0
- package/es/packages/components/form/src/constants.mjs.map +1 -0
- package/es/packages/components/form/src/form.types.mjs +0 -0
- package/es/packages/components/form/src/hooks/index.mjs +2 -0
- package/es/packages/components/form/src/hooks/use-form-common-props.mjs +16 -0
- package/es/packages/components/form/src/hooks/use-form-common-props.mjs.map +1 -0
- package/es/packages/components/icon/index.mjs +8 -0
- package/es/packages/components/icon/index.mjs.map +1 -0
- package/es/packages/components/icon/src/icon.mjs +7 -0
- package/es/packages/components/icon/src/icon.mjs.map +1 -0
- package/es/packages/components/icon/src/icon.types.mjs +0 -0
- package/es/packages/components/icon/src/icon.vue_vue_type_script_setup_true_lang.mjs +42 -0
- package/es/packages/components/icon/src/icon.vue_vue_type_script_setup_true_lang.mjs.map +1 -0
- package/es/packages/components/index.mjs +3 -0
- package/es/packages/constants/index.mjs +3 -0
- package/es/packages/constants/key.mjs +6 -0
- package/es/packages/constants/key.mjs.map +1 -0
- package/es/packages/constants/sizes.mjs +24 -0
- package/es/packages/constants/sizes.mjs.map +1 -0
- package/es/packages/hooks/index.mjs +4 -0
- package/es/packages/hooks/use-namespace/index.mjs +63 -0
- package/es/packages/hooks/use-namespace/index.mjs.map +1 -0
- package/es/packages/hooks/use-prop/index.mjs +10 -0
- package/es/packages/hooks/use-prop/index.mjs.map +1 -0
- package/es/packages/hooks/use-theme/index.mjs +19 -0
- package/es/packages/hooks/use-theme/index.mjs.map +1 -0
- package/es/packages/utils/colors.mjs +109 -0
- package/es/packages/utils/colors.mjs.map +1 -0
- package/es/packages/utils/dom/index.mjs +2 -0
- package/es/packages/utils/dom/style.mjs +11 -0
- package/es/packages/utils/dom/style.mjs.map +1 -0
- package/es/packages/utils/index.mjs +5 -0
- package/es/packages/utils/types.mjs +12 -0
- package/es/packages/utils/types.mjs.map +1 -0
- package/es/packages/utils/vue/index.mjs +2 -0
- package/es/packages/utils/vue/install.mjs +38 -0
- package/es/packages/utils/vue/install.mjs.map +1 -0
- package/es/packages/utils/vue/typescript.mjs +0 -0
- package/es/plugin.d.ts +6 -0
- package/es/plugin.mjs +6 -0
- package/es/plugin.mjs.map +1 -0
- package/es/utils/colors.d.ts +14 -0
- package/es/utils/dom/index.d.ts +2 -0
- package/es/utils/dom/style.d.ts +4 -0
- package/es/utils/index.d.ts +6 -0
- package/es/utils/types.d.ts +8 -0
- package/es/utils/vue/index.d.ts +3 -0
- package/es/utils/vue/install.d.ts +7 -0
- package/es/utils/vue/typescript.d.ts +19 -0
- package/global.d.ts +8 -0
- package/lib/_virtual/_rolldown/runtime.js +37 -0
- package/lib/component.d.ts +6 -0
- package/lib/component.js +12 -0
- package/lib/component.js.map +1 -0
- package/lib/components/base/style/css.js +2 -0
- package/lib/components/base/style/index.js +2 -0
- package/lib/components/button/index.d.ts +8 -0
- package/lib/components/button/src/button-custom.d.ts +6 -0
- package/lib/components/button/src/button.types.d.ts +77 -0
- package/lib/components/button/src/button.vue.d.ts +28 -0
- package/lib/components/button/src/use-button.d.ts +14 -0
- package/lib/components/button/style/css.js +3 -0
- package/lib/components/form/index.d.ts +4 -0
- package/lib/components/form/src/constants.d.ts +7 -0
- package/lib/components/form/src/form.types.d.ts +10 -0
- package/lib/components/form/src/hooks/index.d.ts +2 -0
- package/lib/components/form/src/hooks/use-form-common-props.d.ts +7 -0
- package/lib/components/icon/index.d.ts +26 -0
- package/lib/components/icon/src/icon.types.d.ts +13 -0
- package/lib/components/icon/src/icon.vue.d.ts +17 -0
- package/lib/components/icon/style/css.js +2 -0
- package/lib/components/icon/style/index.js +2 -0
- package/lib/components/index.d.ts +5 -0
- package/lib/constants/index.d.ts +3 -0
- package/lib/constants/key.d.ts +4 -0
- package/lib/constants/sizes.d.ts +12 -0
- package/lib/defaults.d.ts +6 -0
- package/lib/defaults.js +13 -0
- package/lib/defaults.js.map +1 -0
- package/lib/hooks/index.d.ts +4 -0
- package/lib/hooks/use-namespace/index.d.ts +27 -0
- package/lib/hooks/use-prop/index.d.ts +6 -0
- package/lib/hooks/use-theme/index.d.ts +5 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -0
- package/lib/make-installer.d.ts +8 -0
- package/lib/make-installer.js +15 -0
- package/lib/make-installer.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/conversion.js +309 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/conversion.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/css-color-names.js +168 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/css-color-names.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/format-input.js +209 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/format-input.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/from-ratio.js +43 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/from-ratio.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/index.js +471 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/index.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/interfaces.js +14 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/interfaces.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/public_api.js +50 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/public_api.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/random.js +255 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/random.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/readability.js +96 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/readability.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/to-ms-filter.js +35 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/to-ms-filter.js.map +1 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/util.js +82 -0
- package/lib/node_modules/.pnpm/@ctrl_tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/util.js.map +1 -0
- package/lib/node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isPlainObject.js +53 -0
- package/lib/node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isPlainObject.js.map +1 -0
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.cjs.js +66 -0
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.cjs.js.map +1 -0
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.cjs.prod.js +56 -0
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/dist/vue.cjs.prod.js.map +1 -0
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/index.js +18 -0
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/index.js.map +1 -0
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/index2.js +14 -0
- package/lib/node_modules/.pnpm/vue@3.5.35_typescript@6.0.3/node_modules/vue/index2.js.map +1 -0
- package/lib/packages/components/button/index.js +13 -0
- package/lib/packages/components/button/index.js.map +1 -0
- package/lib/packages/components/button/src/button-custom.js +122 -0
- package/lib/packages/components/button/src/button-custom.js.map +1 -0
- package/lib/packages/components/button/src/button.js +10 -0
- package/lib/packages/components/button/src/button.js.map +1 -0
- package/lib/packages/components/button/src/button.types.js +1 -0
- package/lib/packages/components/button/src/button.vue_vue_type_script_setup_true_lang.js +139 -0
- package/lib/packages/components/button/src/button.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/lib/packages/components/button/src/use-button.js +42 -0
- package/lib/packages/components/button/src/use-button.js.map +1 -0
- package/lib/packages/components/form/index.js +6 -0
- package/lib/packages/components/form/src/constants.js +7 -0
- package/lib/packages/components/form/src/constants.js.map +1 -0
- package/lib/packages/components/form/src/form.types.js +1 -0
- package/lib/packages/components/form/src/hooks/index.js +4 -0
- package/lib/packages/components/form/src/hooks/use-form-common-props.js +18 -0
- package/lib/packages/components/form/src/hooks/use-form-common-props.js.map +1 -0
- package/lib/packages/components/icon/index.js +13 -0
- package/lib/packages/components/icon/index.js.map +1 -0
- package/lib/packages/components/icon/src/icon.js +10 -0
- package/lib/packages/components/icon/src/icon.js.map +1 -0
- package/lib/packages/components/icon/src/icon.types.js +1 -0
- package/lib/packages/components/icon/src/icon.vue_vue_type_script_setup_true_lang.js +42 -0
- package/lib/packages/components/icon/src/icon.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/lib/packages/components/index.js +5 -0
- package/lib/packages/constants/index.js +6 -0
- package/lib/packages/constants/key.js +7 -0
- package/lib/packages/constants/key.js.map +1 -0
- package/lib/packages/constants/sizes.js +26 -0
- package/lib/packages/constants/sizes.js.map +1 -0
- package/lib/packages/hooks/index.js +10 -0
- package/lib/packages/hooks/use-namespace/index.js +67 -0
- package/lib/packages/hooks/use-namespace/index.js.map +1 -0
- package/lib/packages/hooks/use-prop/index.js +11 -0
- package/lib/packages/hooks/use-prop/index.js.map +1 -0
- package/lib/packages/hooks/use-theme/index.js +20 -0
- package/lib/packages/hooks/use-theme/index.js.map +1 -0
- package/lib/packages/utils/colors.js +112 -0
- package/lib/packages/utils/colors.js.map +1 -0
- package/lib/packages/utils/dom/index.js +3 -0
- package/lib/packages/utils/dom/style.js +13 -0
- package/lib/packages/utils/dom/style.js.map +1 -0
- package/lib/packages/utils/index.js +21 -0
- package/lib/packages/utils/types.js +21 -0
- package/lib/packages/utils/types.js.map +1 -0
- package/lib/packages/utils/vue/index.js +4 -0
- package/lib/packages/utils/vue/install.js +40 -0
- package/lib/packages/utils/vue/install.js.map +1 -0
- package/lib/packages/utils/vue/typescript.js +1 -0
- package/lib/plugin.d.ts +6 -0
- package/lib/plugin.js +10 -0
- package/lib/plugin.js.map +1 -0
- package/lib/utils/colors.d.ts +14 -0
- package/lib/utils/dom/index.d.ts +2 -0
- package/lib/utils/dom/style.d.ts +4 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/types.d.ts +8 -0
- package/lib/utils/vue/index.d.ts +3 -0
- package/lib/utils/vue/install.d.ts +7 -0
- package/lib/utils/vue/typescript.d.ts +19 -0
- package/package.json +69 -0
- package/theme-slate/base.css +1 -0
- package/theme-slate/cu-button.css +1 -0
- package/theme-slate/cu-common.css +1 -0
- package/theme-slate/cu-icon.css +1 -0
- package/theme-slate/cu-var.css +1 -0
- package/theme-slate/dark/css-vars.css +0 -0
- package/theme-slate/index.css +1 -0
- package/theme-slate/src/base.scss +2 -0
- package/theme-slate/src/button.scss +317 -0
- package/theme-slate/src/common/var.scss +179 -0
- package/theme-slate/src/common.scss +9 -0
- package/theme-slate/src/dark/css-vars.scss +0 -0
- package/theme-slate/src/icon.scss +43 -0
- package/theme-slate/src/index.scss +4 -0
- package/theme-slate/src/mixins/_var.scss +9 -0
- package/theme-slate/src/mixins/config.scss +5 -0
- package/theme-slate/src/mixins/function.scss +11 -0
- package/theme-slate/src/mixins/mixins.scss +19 -0
- package/theme-slate/src/var.scss +297 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { bound01, pad2 } from "./util.mjs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@ctrl+tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/conversion.js
|
|
3
|
+
/**
|
|
4
|
+
* Handle bounds / percentage checking to conform to CSS color spec
|
|
5
|
+
* <http://www.w3.org/TR/css3-color/>
|
|
6
|
+
* *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
7
|
+
* *Returns:* { r, g, b } in [0, 255]
|
|
8
|
+
*/
|
|
9
|
+
function rgbToRgb(r, g, b) {
|
|
10
|
+
return {
|
|
11
|
+
r: bound01(r, 255) * 255,
|
|
12
|
+
g: bound01(g, 255) * 255,
|
|
13
|
+
b: bound01(b, 255) * 255
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Converts an RGB color value to HSL.
|
|
18
|
+
* *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
|
|
19
|
+
* *Returns:* { h, s, l } in [0,1]
|
|
20
|
+
*/
|
|
21
|
+
function rgbToHsl(r, g, b) {
|
|
22
|
+
r = bound01(r, 255);
|
|
23
|
+
g = bound01(g, 255);
|
|
24
|
+
b = bound01(b, 255);
|
|
25
|
+
const max = Math.max(r, g, b);
|
|
26
|
+
const min = Math.min(r, g, b);
|
|
27
|
+
let h = 0;
|
|
28
|
+
let s = 0;
|
|
29
|
+
const l = (max + min) / 2;
|
|
30
|
+
if (max === min) {
|
|
31
|
+
s = 0;
|
|
32
|
+
h = 0;
|
|
33
|
+
} else {
|
|
34
|
+
const d = max - min;
|
|
35
|
+
s = l > .5 ? d / (2 - max - min) : d / (max + min);
|
|
36
|
+
switch (max) {
|
|
37
|
+
case r:
|
|
38
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
39
|
+
break;
|
|
40
|
+
case g:
|
|
41
|
+
h = (b - r) / d + 2;
|
|
42
|
+
break;
|
|
43
|
+
case b:
|
|
44
|
+
h = (r - g) / d + 4;
|
|
45
|
+
break;
|
|
46
|
+
default: break;
|
|
47
|
+
}
|
|
48
|
+
h /= 6;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
h,
|
|
52
|
+
s,
|
|
53
|
+
l
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function hue2rgb(p, q, t) {
|
|
57
|
+
if (t < 0) t += 1;
|
|
58
|
+
if (t > 1) t -= 1;
|
|
59
|
+
if (t < 1 / 6) return p + (q - p) * (6 * t);
|
|
60
|
+
if (t < 1 / 2) return q;
|
|
61
|
+
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
62
|
+
return p;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Converts an HSL color value to RGB.
|
|
66
|
+
*
|
|
67
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
68
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
69
|
+
*/
|
|
70
|
+
function hslToRgb(h, s, l) {
|
|
71
|
+
let r;
|
|
72
|
+
let g;
|
|
73
|
+
let b;
|
|
74
|
+
h = bound01(h, 360);
|
|
75
|
+
s = bound01(s, 100);
|
|
76
|
+
l = bound01(l, 100);
|
|
77
|
+
if (s === 0) {
|
|
78
|
+
g = l;
|
|
79
|
+
b = l;
|
|
80
|
+
r = l;
|
|
81
|
+
} else {
|
|
82
|
+
const q = l < .5 ? l * (1 + s) : l + s - l * s;
|
|
83
|
+
const p = 2 * l - q;
|
|
84
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
85
|
+
g = hue2rgb(p, q, h);
|
|
86
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
r: r * 255,
|
|
90
|
+
g: g * 255,
|
|
91
|
+
b: b * 255
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Converts an RGB color value to HSV
|
|
96
|
+
*
|
|
97
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
98
|
+
* *Returns:* { h, s, v } in [0,1]
|
|
99
|
+
*/
|
|
100
|
+
function rgbToHsv(r, g, b) {
|
|
101
|
+
r = bound01(r, 255);
|
|
102
|
+
g = bound01(g, 255);
|
|
103
|
+
b = bound01(b, 255);
|
|
104
|
+
const max = Math.max(r, g, b);
|
|
105
|
+
const min = Math.min(r, g, b);
|
|
106
|
+
let h = 0;
|
|
107
|
+
const v = max;
|
|
108
|
+
const d = max - min;
|
|
109
|
+
const s = max === 0 ? 0 : d / max;
|
|
110
|
+
if (max === min) h = 0;
|
|
111
|
+
else {
|
|
112
|
+
switch (max) {
|
|
113
|
+
case r:
|
|
114
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
115
|
+
break;
|
|
116
|
+
case g:
|
|
117
|
+
h = (b - r) / d + 2;
|
|
118
|
+
break;
|
|
119
|
+
case b:
|
|
120
|
+
h = (r - g) / d + 4;
|
|
121
|
+
break;
|
|
122
|
+
default: break;
|
|
123
|
+
}
|
|
124
|
+
h /= 6;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
h,
|
|
128
|
+
s,
|
|
129
|
+
v
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Converts an HSV color value to RGB.
|
|
134
|
+
*
|
|
135
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
136
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
137
|
+
*/
|
|
138
|
+
function hsvToRgb(h, s, v) {
|
|
139
|
+
h = bound01(h, 360) * 6;
|
|
140
|
+
s = bound01(s, 100);
|
|
141
|
+
v = bound01(v, 100);
|
|
142
|
+
const i = Math.floor(h);
|
|
143
|
+
const f = h - i;
|
|
144
|
+
const p = v * (1 - s);
|
|
145
|
+
const q = v * (1 - f * s);
|
|
146
|
+
const t = v * (1 - (1 - f) * s);
|
|
147
|
+
const mod = i % 6;
|
|
148
|
+
const r = [
|
|
149
|
+
v,
|
|
150
|
+
q,
|
|
151
|
+
p,
|
|
152
|
+
p,
|
|
153
|
+
t,
|
|
154
|
+
v
|
|
155
|
+
][mod];
|
|
156
|
+
const g = [
|
|
157
|
+
t,
|
|
158
|
+
v,
|
|
159
|
+
v,
|
|
160
|
+
q,
|
|
161
|
+
p,
|
|
162
|
+
p
|
|
163
|
+
][mod];
|
|
164
|
+
const b = [
|
|
165
|
+
p,
|
|
166
|
+
p,
|
|
167
|
+
t,
|
|
168
|
+
v,
|
|
169
|
+
v,
|
|
170
|
+
q
|
|
171
|
+
][mod];
|
|
172
|
+
return {
|
|
173
|
+
r: r * 255,
|
|
174
|
+
g: g * 255,
|
|
175
|
+
b: b * 255
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Converts an RGB color to hex
|
|
180
|
+
*
|
|
181
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255]
|
|
182
|
+
* *Returns:* a 3 or 6 character hex
|
|
183
|
+
*/
|
|
184
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
185
|
+
const hex = [
|
|
186
|
+
pad2(Math.round(r).toString(16)),
|
|
187
|
+
pad2(Math.round(g).toString(16)),
|
|
188
|
+
pad2(Math.round(b).toString(16))
|
|
189
|
+
];
|
|
190
|
+
if (allow3Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1))) return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
191
|
+
return hex.join("");
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Converts an RGBA color plus alpha transparency to hex
|
|
195
|
+
*
|
|
196
|
+
* *Assumes:* r, g, b are contained in the set [0, 255] and a in [0, 1]
|
|
197
|
+
* *Returns:* a 4 or 8 character rgba hex
|
|
198
|
+
*/
|
|
199
|
+
function rgbaToHex(r, g, b, a, allow4Char) {
|
|
200
|
+
const hex = [
|
|
201
|
+
pad2(Math.round(r).toString(16)),
|
|
202
|
+
pad2(Math.round(g).toString(16)),
|
|
203
|
+
pad2(Math.round(b).toString(16)),
|
|
204
|
+
pad2(convertDecimalToHex(a))
|
|
205
|
+
];
|
|
206
|
+
if (allow4Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1)) && hex[3].startsWith(hex[3].charAt(1))) return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
|
|
207
|
+
return hex.join("");
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Converts CMYK to RBG
|
|
211
|
+
* Assumes c, m, y, k are in the set [0, 100]
|
|
212
|
+
*/
|
|
213
|
+
function cmykToRgb(c, m, y, k) {
|
|
214
|
+
const cConv = c / 100;
|
|
215
|
+
const mConv = m / 100;
|
|
216
|
+
const yConv = y / 100;
|
|
217
|
+
const kConv = k / 100;
|
|
218
|
+
return {
|
|
219
|
+
r: 255 * (1 - cConv) * (1 - kConv),
|
|
220
|
+
g: 255 * (1 - mConv) * (1 - kConv),
|
|
221
|
+
b: 255 * (1 - yConv) * (1 - kConv)
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function rgbToCmyk(r, g, b) {
|
|
225
|
+
let c = 1 - r / 255;
|
|
226
|
+
let m = 1 - g / 255;
|
|
227
|
+
let y = 1 - b / 255;
|
|
228
|
+
let k = Math.min(c, m, y);
|
|
229
|
+
if (k === 1) {
|
|
230
|
+
c = 0;
|
|
231
|
+
m = 0;
|
|
232
|
+
y = 0;
|
|
233
|
+
} else {
|
|
234
|
+
c = (c - k) / (1 - k) * 100;
|
|
235
|
+
m = (m - k) / (1 - k) * 100;
|
|
236
|
+
y = (y - k) / (1 - k) * 100;
|
|
237
|
+
}
|
|
238
|
+
k *= 100;
|
|
239
|
+
return {
|
|
240
|
+
c: Math.round(c),
|
|
241
|
+
m: Math.round(m),
|
|
242
|
+
y: Math.round(y),
|
|
243
|
+
k: Math.round(k)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/** Converts a decimal to a hex value */
|
|
247
|
+
function convertDecimalToHex(d) {
|
|
248
|
+
return Math.round(parseFloat(d) * 255).toString(16);
|
|
249
|
+
}
|
|
250
|
+
/** Converts a hex value to a decimal */
|
|
251
|
+
function convertHexToDecimal(h) {
|
|
252
|
+
return parseIntFromHex(h) / 255;
|
|
253
|
+
}
|
|
254
|
+
/** Parse a base-16 hex value into a base-10 integer */
|
|
255
|
+
function parseIntFromHex(val) {
|
|
256
|
+
return parseInt(val, 16);
|
|
257
|
+
}
|
|
258
|
+
function numberInputToObject(color) {
|
|
259
|
+
return {
|
|
260
|
+
r: color >> 16,
|
|
261
|
+
g: (color & 65280) >> 8,
|
|
262
|
+
b: color & 255
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
export { cmykToRgb, convertHexToDecimal, hslToRgb, hsvToRgb, numberInputToObject, parseIntFromHex, rgbToCmyk, rgbToHex, rgbToHsl, rgbToHsv, rgbToRgb, rgbaToHex };
|
|
267
|
+
|
|
268
|
+
//# sourceMappingURL=conversion.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversion.mjs","names":[],"sources":["../../../../../../../../../../../node_modules/.pnpm/@ctrl+tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/conversion.js"],"sourcesContent":["import { bound01, pad2 } from './util.js';\n// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:\n// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>\n/**\n * Handle bounds / percentage checking to conform to CSS color spec\n * <http://www.w3.org/TR/css3-color/>\n * *Assumes:* r, g, b in [0, 255] or [0, 1]\n * *Returns:* { r, g, b } in [0, 255]\n */\nexport function rgbToRgb(r, g, b) {\n return {\n r: bound01(r, 255) * 255,\n g: bound01(g, 255) * 255,\n b: bound01(b, 255) * 255,\n };\n}\n/**\n * Converts an RGB color value to HSL.\n * *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]\n * *Returns:* { h, s, l } in [0,1]\n */\nexport function rgbToHsl(r, g, b) {\n r = bound01(r, 255);\n g = bound01(g, 255);\n b = bound01(b, 255);\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h = 0;\n let s = 0;\n const l = (max + min) / 2;\n if (max === min) {\n s = 0;\n h = 0; // achromatic\n }\n else {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n default:\n break;\n }\n h /= 6;\n }\n return { h, s, l };\n}\nfunction hue2rgb(p, q, t) {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * (6 * t);\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n}\n/**\n * Converts an HSL color value to RGB.\n *\n * *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]\n * *Returns:* { r, g, b } in the set [0, 255]\n */\nexport function hslToRgb(h, s, l) {\n let r;\n let g;\n let b;\n h = bound01(h, 360);\n s = bound01(s, 100);\n l = bound01(l, 100);\n if (s === 0) {\n // achromatic\n g = l;\n b = l;\n r = l;\n }\n else {\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n return { r: r * 255, g: g * 255, b: b * 255 };\n}\n/**\n * Converts an RGB color value to HSV\n *\n * *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]\n * *Returns:* { h, s, v } in [0,1]\n */\nexport function rgbToHsv(r, g, b) {\n r = bound01(r, 255);\n g = bound01(g, 255);\n b = bound01(b, 255);\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h = 0;\n const v = max;\n const d = max - min;\n const s = max === 0 ? 0 : d / max;\n if (max === min) {\n h = 0; // achromatic\n }\n else {\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n default:\n break;\n }\n h /= 6;\n }\n return { h, s, v };\n}\n/**\n * Converts an HSV color value to RGB.\n *\n * *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]\n * *Returns:* { r, g, b } in the set [0, 255]\n */\nexport function hsvToRgb(h, s, v) {\n h = bound01(h, 360) * 6;\n s = bound01(s, 100);\n v = bound01(v, 100);\n const i = Math.floor(h);\n const f = h - i;\n const p = v * (1 - s);\n const q = v * (1 - f * s);\n const t = v * (1 - (1 - f) * s);\n const mod = i % 6;\n const r = [v, q, p, p, t, v][mod];\n const g = [t, v, v, q, p, p][mod];\n const b = [p, p, t, v, v, q][mod];\n return { r: r * 255, g: g * 255, b: b * 255 };\n}\n/**\n * Converts an RGB color to hex\n *\n * *Assumes:* r, g, and b are contained in the set [0, 255]\n * *Returns:* a 3 or 6 character hex\n */\nexport function rgbToHex(r, g, b, allow3Char) {\n const hex = [\n pad2(Math.round(r).toString(16)),\n pad2(Math.round(g).toString(16)),\n pad2(Math.round(b).toString(16)),\n ];\n // Return a 3 character hex if possible\n if (allow3Char &&\n hex[0].startsWith(hex[0].charAt(1)) &&\n hex[1].startsWith(hex[1].charAt(1)) &&\n hex[2].startsWith(hex[2].charAt(1))) {\n return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);\n }\n return hex.join('');\n}\n/**\n * Converts an RGBA color plus alpha transparency to hex\n *\n * *Assumes:* r, g, b are contained in the set [0, 255] and a in [0, 1]\n * *Returns:* a 4 or 8 character rgba hex\n */\n// eslint-disable-next-line max-params\nexport function rgbaToHex(r, g, b, a, allow4Char) {\n const hex = [\n pad2(Math.round(r).toString(16)),\n pad2(Math.round(g).toString(16)),\n pad2(Math.round(b).toString(16)),\n pad2(convertDecimalToHex(a)),\n ];\n // Return a 4 character hex if possible\n if (allow4Char &&\n hex[0].startsWith(hex[0].charAt(1)) &&\n hex[1].startsWith(hex[1].charAt(1)) &&\n hex[2].startsWith(hex[2].charAt(1)) &&\n hex[3].startsWith(hex[3].charAt(1))) {\n return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);\n }\n return hex.join('');\n}\n/**\n * Converts an RGBA color to an ARGB Hex8 string\n * Rarely used, but required for \"toFilter()\"\n *\n * *Assumes:* r, g, b are contained in the set [0, 255] and a in [0, 1]\n * *Returns:* a 8 character argb hex\n */\nexport function rgbaToArgbHex(r, g, b, a) {\n const hex = [\n pad2(convertDecimalToHex(a)),\n pad2(Math.round(r).toString(16)),\n pad2(Math.round(g).toString(16)),\n pad2(Math.round(b).toString(16)),\n ];\n return hex.join('');\n}\n/**\n * Converts CMYK to RBG\n * Assumes c, m, y, k are in the set [0, 100]\n */\nexport function cmykToRgb(c, m, y, k) {\n const cConv = c / 100;\n const mConv = m / 100;\n const yConv = y / 100;\n const kConv = k / 100;\n const r = 255 * (1 - cConv) * (1 - kConv);\n const g = 255 * (1 - mConv) * (1 - kConv);\n const b = 255 * (1 - yConv) * (1 - kConv);\n return { r, g, b };\n}\nexport function rgbToCmyk(r, g, b) {\n let c = 1 - r / 255;\n let m = 1 - g / 255;\n let y = 1 - b / 255;\n let k = Math.min(c, m, y);\n if (k === 1) {\n c = 0;\n m = 0;\n y = 0;\n }\n else {\n c = ((c - k) / (1 - k)) * 100;\n m = ((m - k) / (1 - k)) * 100;\n y = ((y - k) / (1 - k)) * 100;\n }\n k *= 100;\n return {\n c: Math.round(c),\n m: Math.round(m),\n y: Math.round(y),\n k: Math.round(k),\n };\n}\n/** Converts a decimal to a hex value */\nexport function convertDecimalToHex(d) {\n return Math.round(parseFloat(d) * 255).toString(16);\n}\n/** Converts a hex value to a decimal */\nexport function convertHexToDecimal(h) {\n return parseIntFromHex(h) / 255;\n}\n/** Parse a base-16 hex value into a base-10 integer */\nexport function parseIntFromHex(val) {\n return parseInt(val, 16);\n}\nexport function numberInputToObject(color) {\n return {\n r: color >> 16,\n g: (color & 0xff00) >> 8,\n b: color & 0xff,\n };\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AASA,SAAgB,SAAS,GAAG,GAAG,GAAG;CAC9B,OAAO;EACH,GAAG,QAAQ,GAAG,GAAG,IAAI;EACrB,GAAG,QAAQ,GAAG,GAAG,IAAI;EACrB,GAAG,QAAQ,GAAG,GAAG,IAAI;CACzB;AACJ;;;;;;AAMA,SAAgB,SAAS,G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AC;CACnB;AACJ;;AAEA,SAAgB,oBAAoB,GAAG;CACnC,OAAO,KAAK,MAAM,WAAW,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE;AACtD;;AAEA,SAAgB,oBAAoB,GAAG;CACnC,OAAO,gBAAgB,CAAC,IAAI;AAChC;;AAEA,SAAgB,gBAAgB,KAAK;CACjC,OAAO,SAAS,KAAK,EAAE;AAC3B;AACA,SAAgB,oBAAoB,OAAO;CACvC,OAAO;EACH,GAAG,SAAS;EACZ,IAAI,QAAQ,UAAW;EACvB,GAAG,QAAQ;CACf;AACJ"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@ctrl+tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/css-color-names.js
|
|
2
|
+
/**
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
const names = {
|
|
6
|
+
aliceblue: "#f0f8ff",
|
|
7
|
+
antiquewhite: "#faebd7",
|
|
8
|
+
aqua: "#00ffff",
|
|
9
|
+
aquamarine: "#7fffd4",
|
|
10
|
+
azure: "#f0ffff",
|
|
11
|
+
beige: "#f5f5dc",
|
|
12
|
+
bisque: "#ffe4c4",
|
|
13
|
+
black: "#000000",
|
|
14
|
+
blanchedalmond: "#ffebcd",
|
|
15
|
+
blue: "#0000ff",
|
|
16
|
+
blueviolet: "#8a2be2",
|
|
17
|
+
brown: "#a52a2a",
|
|
18
|
+
burlywood: "#deb887",
|
|
19
|
+
cadetblue: "#5f9ea0",
|
|
20
|
+
chartreuse: "#7fff00",
|
|
21
|
+
chocolate: "#d2691e",
|
|
22
|
+
coral: "#ff7f50",
|
|
23
|
+
cornflowerblue: "#6495ed",
|
|
24
|
+
cornsilk: "#fff8dc",
|
|
25
|
+
crimson: "#dc143c",
|
|
26
|
+
cyan: "#00ffff",
|
|
27
|
+
darkblue: "#00008b",
|
|
28
|
+
darkcyan: "#008b8b",
|
|
29
|
+
darkgoldenrod: "#b8860b",
|
|
30
|
+
darkgray: "#a9a9a9",
|
|
31
|
+
darkgreen: "#006400",
|
|
32
|
+
darkgrey: "#a9a9a9",
|
|
33
|
+
darkkhaki: "#bdb76b",
|
|
34
|
+
darkmagenta: "#8b008b",
|
|
35
|
+
darkolivegreen: "#556b2f",
|
|
36
|
+
darkorange: "#ff8c00",
|
|
37
|
+
darkorchid: "#9932cc",
|
|
38
|
+
darkred: "#8b0000",
|
|
39
|
+
darksalmon: "#e9967a",
|
|
40
|
+
darkseagreen: "#8fbc8f",
|
|
41
|
+
darkslateblue: "#483d8b",
|
|
42
|
+
darkslategray: "#2f4f4f",
|
|
43
|
+
darkslategrey: "#2f4f4f",
|
|
44
|
+
darkturquoise: "#00ced1",
|
|
45
|
+
darkviolet: "#9400d3",
|
|
46
|
+
deeppink: "#ff1493",
|
|
47
|
+
deepskyblue: "#00bfff",
|
|
48
|
+
dimgray: "#696969",
|
|
49
|
+
dimgrey: "#696969",
|
|
50
|
+
dodgerblue: "#1e90ff",
|
|
51
|
+
firebrick: "#b22222",
|
|
52
|
+
floralwhite: "#fffaf0",
|
|
53
|
+
forestgreen: "#228b22",
|
|
54
|
+
fuchsia: "#ff00ff",
|
|
55
|
+
gainsboro: "#dcdcdc",
|
|
56
|
+
ghostwhite: "#f8f8ff",
|
|
57
|
+
goldenrod: "#daa520",
|
|
58
|
+
gold: "#ffd700",
|
|
59
|
+
gray: "#808080",
|
|
60
|
+
green: "#008000",
|
|
61
|
+
greenyellow: "#adff2f",
|
|
62
|
+
grey: "#808080",
|
|
63
|
+
honeydew: "#f0fff0",
|
|
64
|
+
hotpink: "#ff69b4",
|
|
65
|
+
indianred: "#cd5c5c",
|
|
66
|
+
indigo: "#4b0082",
|
|
67
|
+
ivory: "#fffff0",
|
|
68
|
+
khaki: "#f0e68c",
|
|
69
|
+
lavenderblush: "#fff0f5",
|
|
70
|
+
lavender: "#e6e6fa",
|
|
71
|
+
lawngreen: "#7cfc00",
|
|
72
|
+
lemonchiffon: "#fffacd",
|
|
73
|
+
lightblue: "#add8e6",
|
|
74
|
+
lightcoral: "#f08080",
|
|
75
|
+
lightcyan: "#e0ffff",
|
|
76
|
+
lightgoldenrodyellow: "#fafad2",
|
|
77
|
+
lightgray: "#d3d3d3",
|
|
78
|
+
lightgreen: "#90ee90",
|
|
79
|
+
lightgrey: "#d3d3d3",
|
|
80
|
+
lightpink: "#ffb6c1",
|
|
81
|
+
lightsalmon: "#ffa07a",
|
|
82
|
+
lightseagreen: "#20b2aa",
|
|
83
|
+
lightskyblue: "#87cefa",
|
|
84
|
+
lightslategray: "#778899",
|
|
85
|
+
lightslategrey: "#778899",
|
|
86
|
+
lightsteelblue: "#b0c4de",
|
|
87
|
+
lightyellow: "#ffffe0",
|
|
88
|
+
lime: "#00ff00",
|
|
89
|
+
limegreen: "#32cd32",
|
|
90
|
+
linen: "#faf0e6",
|
|
91
|
+
magenta: "#ff00ff",
|
|
92
|
+
maroon: "#800000",
|
|
93
|
+
mediumaquamarine: "#66cdaa",
|
|
94
|
+
mediumblue: "#0000cd",
|
|
95
|
+
mediumorchid: "#ba55d3",
|
|
96
|
+
mediumpurple: "#9370db",
|
|
97
|
+
mediumseagreen: "#3cb371",
|
|
98
|
+
mediumslateblue: "#7b68ee",
|
|
99
|
+
mediumspringgreen: "#00fa9a",
|
|
100
|
+
mediumturquoise: "#48d1cc",
|
|
101
|
+
mediumvioletred: "#c71585",
|
|
102
|
+
midnightblue: "#191970",
|
|
103
|
+
mintcream: "#f5fffa",
|
|
104
|
+
mistyrose: "#ffe4e1",
|
|
105
|
+
moccasin: "#ffe4b5",
|
|
106
|
+
navajowhite: "#ffdead",
|
|
107
|
+
navy: "#000080",
|
|
108
|
+
oldlace: "#fdf5e6",
|
|
109
|
+
olive: "#808000",
|
|
110
|
+
olivedrab: "#6b8e23",
|
|
111
|
+
orange: "#ffa500",
|
|
112
|
+
orangered: "#ff4500",
|
|
113
|
+
orchid: "#da70d6",
|
|
114
|
+
palegoldenrod: "#eee8aa",
|
|
115
|
+
palegreen: "#98fb98",
|
|
116
|
+
paleturquoise: "#afeeee",
|
|
117
|
+
palevioletred: "#db7093",
|
|
118
|
+
papayawhip: "#ffefd5",
|
|
119
|
+
peachpuff: "#ffdab9",
|
|
120
|
+
peru: "#cd853f",
|
|
121
|
+
pink: "#ffc0cb",
|
|
122
|
+
plum: "#dda0dd",
|
|
123
|
+
powderblue: "#b0e0e6",
|
|
124
|
+
purple: "#800080",
|
|
125
|
+
rebeccapurple: "#663399",
|
|
126
|
+
red: "#ff0000",
|
|
127
|
+
rosybrown: "#bc8f8f",
|
|
128
|
+
royalblue: "#4169e1",
|
|
129
|
+
saddlebrown: "#8b4513",
|
|
130
|
+
salmon: "#fa8072",
|
|
131
|
+
sandybrown: "#f4a460",
|
|
132
|
+
seagreen: "#2e8b57",
|
|
133
|
+
seashell: "#fff5ee",
|
|
134
|
+
sienna: "#a0522d",
|
|
135
|
+
silver: "#c0c0c0",
|
|
136
|
+
skyblue: "#87ceeb",
|
|
137
|
+
slateblue: "#6a5acd",
|
|
138
|
+
slategray: "#708090",
|
|
139
|
+
slategrey: "#708090",
|
|
140
|
+
snow: "#fffafa",
|
|
141
|
+
springgreen: "#00ff7f",
|
|
142
|
+
steelblue: "#4682b4",
|
|
143
|
+
tan: "#d2b48c",
|
|
144
|
+
teal: "#008080",
|
|
145
|
+
thistle: "#d8bfd8",
|
|
146
|
+
tomato: "#ff6347",
|
|
147
|
+
turquoise: "#40e0d0",
|
|
148
|
+
violet: "#ee82ee",
|
|
149
|
+
wheat: "#f5deb3",
|
|
150
|
+
white: "#ffffff",
|
|
151
|
+
whitesmoke: "#f5f5f5",
|
|
152
|
+
yellow: "#ffff00",
|
|
153
|
+
yellowgreen: "#9acd32"
|
|
154
|
+
};
|
|
155
|
+
//#endregion
|
|
156
|
+
export { names };
|
|
157
|
+
|
|
158
|
+
//# sourceMappingURL=css-color-names.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-color-names.mjs","names":[],"sources":["../../../../../../../../../../../node_modules/.pnpm/@ctrl+tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/css-color-names.js"],"sourcesContent":["// https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json\n/**\n * @hidden\n */\nexport const names = {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkgrey: '#a9a9a9',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkslategrey: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n goldenrod: '#daa520',\n gold: '#ffd700',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n grey: '#808080',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n indianred: '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n lavenderblush: '#fff0f5',\n lavender: '#e6e6fa',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrodyellow: '#fafad2',\n lightgray: '#d3d3d3',\n lightgreen: '#90ee90',\n lightgrey: '#d3d3d3',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightslategrey: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370db',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#db7093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n rebeccapurple: '#663399',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32',\n};\n"],"x_google_ignoreList":[0],"mappings":";;;;AAIA,MAAa,QAAQ;CACjB,WAAW;CACX,cAAc;CACd,MAAM;CACN,YAAY;CACZ,OAAO;CACP,OAAO;CACP,QAAQ;CACR,OAAO;CACP,gBAAgB;CAChB,MAAM;CACN,YAAY;CACZ,OAAO;CACP,WAAW;CACX,WAAW;CACX,YAAY;CACZ,WAAW;CACX,OAAO;CACP,gBAAgB;CAChB,UAAU;CACV,SAAS;CACT,MAAM;CACN,UAAU;CACV,UAAU;CACV,eAAe;CACf,UAAU;CACV,WAAW;CACX,UAAU;CACV,WAAW;CACX,aAAa;CACb,gBAAgB;CAChB,YAAY;CACZ,YAAY;CACZ,SAAS;CACT,YAAY;CACZ,cAAc;CACd,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,YAAY;CACZ,UAAU;CACV,aAAa;CACb,SAAS;CACT,SAAS;CACT,YAAY;CACZ,WAAW;CACX,aAAa;CACb,aAAa;CACb,SAAS;CACT,WAAW;CACX,YAAY;CACZ,WAAW;CACX,MAAM;CACN,MAAM;CACN,OAAO;CACP,aAAa;CACb,MAAM;CACN,UAAU;CACV,SAAS;CACT,WAAW;CACX,QAAQ;CACR,OAAO;CACP,OAAO;CACP,eAAe;CACf,UAAU;CACV,WAAW;CACX,cAAc;CACd,WAAW;CACX,YAAY;CACZ,WAAW;CACX,sBAAsB;CACtB,WAAW;CACX,YAAY;CACZ,WAAW;CACX,WAAW;CACX,aAAa;CACb,eAAe;CACf,cAAc;CACd,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,aAAa;CACb,MAAM;CACN,WAAW;CACX,OAAO;CACP,SAAS;CACT,QAAQ;CACR,kBAAkB;CAClB,YAAY;CACZ,cAAc;CACd,cAAc;CACd,gBAAgB;CAChB,iBAAiB;CACjB,mBAAmB;CACnB,iBAAiB;CACjB,iBAAiB;CACjB,cAAc;CACd,WAAW;CACX,WAAW;CACX,UAAU;CACV,aAAa;CACb,MAAM;CACN,SAAS;CACT,OAAO;CACP,WAAW;CACX,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,eAAe;CACf,WAAW;CACX,eAAe;CACf,eAAe;CACf,YAAY;CACZ,WAAW;CACX,MAAM;CACN,MAAM;CACN,MAAM;CACN,YAAY;CACZ,QAAQ;CACR,eAAe;CACf,KAAK;CACL,WAAW;CACX,WAAW;CACX,aAAa;CACb,QAAQ;CACR,YAAY;CACZ,UAAU;CACV,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,WAAW;CACX,WAAW;CACX,WAAW;CACX,MAAM;CACN,aAAa;CACb,WAAW;CACX,KAAK;CACL,MAAM;CACN,SAAS;CACT,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,OAAO;CACP,OAAO;CACP,YAAY;CACZ,QAAQ;CACR,aAAa;AACjB"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { boundAlpha, convertToPercentage } from "./util.mjs";
|
|
2
|
+
import { cmykToRgb, convertHexToDecimal, hslToRgb, hsvToRgb, parseIntFromHex, rgbToRgb } from "./conversion.mjs";
|
|
3
|
+
import { names } from "./css-color-names.mjs";
|
|
4
|
+
//#region ../../node_modules/.pnpm/@ctrl+tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/format-input.js
|
|
5
|
+
/**
|
|
6
|
+
* Given a string or object, convert that input to RGB
|
|
7
|
+
*
|
|
8
|
+
* Possible string inputs:
|
|
9
|
+
* ```
|
|
10
|
+
* "red"
|
|
11
|
+
* "#f00" or "f00"
|
|
12
|
+
* "#ff0000" or "ff0000"
|
|
13
|
+
* "#ff000000" or "ff000000"
|
|
14
|
+
* "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
15
|
+
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
16
|
+
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
17
|
+
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
18
|
+
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
19
|
+
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
20
|
+
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
21
|
+
* "cmyk(0, 20, 0, 0)" or "cmyk 0 20 0 0"
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function inputToRGB(color) {
|
|
25
|
+
let rgb = {
|
|
26
|
+
r: 0,
|
|
27
|
+
g: 0,
|
|
28
|
+
b: 0
|
|
29
|
+
};
|
|
30
|
+
let a = 1;
|
|
31
|
+
let s = null;
|
|
32
|
+
let v = null;
|
|
33
|
+
let l = null;
|
|
34
|
+
let ok = false;
|
|
35
|
+
let format = false;
|
|
36
|
+
if (typeof color === "string") color = stringInputToObject(color);
|
|
37
|
+
if (typeof color === "object") {
|
|
38
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
39
|
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
40
|
+
ok = true;
|
|
41
|
+
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
|
|
42
|
+
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
43
|
+
s = convertToPercentage(color.s);
|
|
44
|
+
v = convertToPercentage(color.v);
|
|
45
|
+
rgb = hsvToRgb(color.h, s, v);
|
|
46
|
+
ok = true;
|
|
47
|
+
format = "hsv";
|
|
48
|
+
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
49
|
+
s = convertToPercentage(color.s);
|
|
50
|
+
l = convertToPercentage(color.l);
|
|
51
|
+
rgb = hslToRgb(color.h, s, l);
|
|
52
|
+
ok = true;
|
|
53
|
+
format = "hsl";
|
|
54
|
+
} else if (isValidCSSUnit(color.c) && isValidCSSUnit(color.m) && isValidCSSUnit(color.y) && isValidCSSUnit(color.k)) {
|
|
55
|
+
rgb = cmykToRgb(color.c, color.m, color.y, color.k);
|
|
56
|
+
ok = true;
|
|
57
|
+
format = "cmyk";
|
|
58
|
+
}
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(color, "a")) a = color.a;
|
|
60
|
+
}
|
|
61
|
+
a = boundAlpha(a);
|
|
62
|
+
return {
|
|
63
|
+
ok,
|
|
64
|
+
format: color.format || format,
|
|
65
|
+
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
66
|
+
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
67
|
+
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
68
|
+
a
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const matchers = {
|
|
72
|
+
CSS_UNIT: /* @__PURE__ */ new RegExp("(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)"),
|
|
73
|
+
rgb: /* @__PURE__ */ new RegExp("rgb[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?"),
|
|
74
|
+
rgba: /* @__PURE__ */ new RegExp("rgba[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\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)?"),
|
|
79
|
+
cmyk: /* @__PURE__ */ new RegExp("cmyk[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?"),
|
|
80
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
81
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
82
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
83
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Permissive string parsing. Take in a number of formats, and output an object
|
|
87
|
+
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` or `{c, m, y, k}` or `{c, m, y, k, a}`
|
|
88
|
+
*/
|
|
89
|
+
function stringInputToObject(color) {
|
|
90
|
+
color = color.trim().toLowerCase();
|
|
91
|
+
if (color.length === 0) return false;
|
|
92
|
+
let named = false;
|
|
93
|
+
if (names[color]) {
|
|
94
|
+
color = names[color];
|
|
95
|
+
named = true;
|
|
96
|
+
} else if (color === "transparent") return {
|
|
97
|
+
r: 0,
|
|
98
|
+
g: 0,
|
|
99
|
+
b: 0,
|
|
100
|
+
a: 0,
|
|
101
|
+
format: "name"
|
|
102
|
+
};
|
|
103
|
+
let match = matchers.rgb.exec(color);
|
|
104
|
+
if (match) return {
|
|
105
|
+
r: match[1],
|
|
106
|
+
g: match[2],
|
|
107
|
+
b: match[3]
|
|
108
|
+
};
|
|
109
|
+
match = matchers.rgba.exec(color);
|
|
110
|
+
if (match) return {
|
|
111
|
+
r: match[1],
|
|
112
|
+
g: match[2],
|
|
113
|
+
b: match[3],
|
|
114
|
+
a: match[4]
|
|
115
|
+
};
|
|
116
|
+
match = matchers.hsl.exec(color);
|
|
117
|
+
if (match) return {
|
|
118
|
+
h: match[1],
|
|
119
|
+
s: match[2],
|
|
120
|
+
l: match[3]
|
|
121
|
+
};
|
|
122
|
+
match = matchers.hsla.exec(color);
|
|
123
|
+
if (match) return {
|
|
124
|
+
h: match[1],
|
|
125
|
+
s: match[2],
|
|
126
|
+
l: match[3],
|
|
127
|
+
a: match[4]
|
|
128
|
+
};
|
|
129
|
+
match = matchers.hsv.exec(color);
|
|
130
|
+
if (match) return {
|
|
131
|
+
h: match[1],
|
|
132
|
+
s: match[2],
|
|
133
|
+
v: match[3]
|
|
134
|
+
};
|
|
135
|
+
match = matchers.hsva.exec(color);
|
|
136
|
+
if (match) return {
|
|
137
|
+
h: match[1],
|
|
138
|
+
s: match[2],
|
|
139
|
+
v: match[3],
|
|
140
|
+
a: match[4]
|
|
141
|
+
};
|
|
142
|
+
match = matchers.cmyk.exec(color);
|
|
143
|
+
if (match) return {
|
|
144
|
+
c: match[1],
|
|
145
|
+
m: match[2],
|
|
146
|
+
y: match[3],
|
|
147
|
+
k: match[4]
|
|
148
|
+
};
|
|
149
|
+
match = matchers.hex8.exec(color);
|
|
150
|
+
if (match) return {
|
|
151
|
+
r: parseIntFromHex(match[1]),
|
|
152
|
+
g: parseIntFromHex(match[2]),
|
|
153
|
+
b: parseIntFromHex(match[3]),
|
|
154
|
+
a: convertHexToDecimal(match[4]),
|
|
155
|
+
format: named ? "name" : "hex8"
|
|
156
|
+
};
|
|
157
|
+
match = matchers.hex6.exec(color);
|
|
158
|
+
if (match) return {
|
|
159
|
+
r: parseIntFromHex(match[1]),
|
|
160
|
+
g: parseIntFromHex(match[2]),
|
|
161
|
+
b: parseIntFromHex(match[3]),
|
|
162
|
+
format: named ? "name" : "hex"
|
|
163
|
+
};
|
|
164
|
+
match = matchers.hex4.exec(color);
|
|
165
|
+
if (match) return {
|
|
166
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
167
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
168
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
169
|
+
a: convertHexToDecimal(match[4] + match[4]),
|
|
170
|
+
format: named ? "name" : "hex8"
|
|
171
|
+
};
|
|
172
|
+
match = matchers.hex3.exec(color);
|
|
173
|
+
if (match) return {
|
|
174
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
175
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
176
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
177
|
+
format: named ? "name" : "hex"
|
|
178
|
+
};
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Check to see if it looks like a CSS unit
|
|
183
|
+
* (see `matchers` above for definition).
|
|
184
|
+
*/
|
|
185
|
+
function isValidCSSUnit(color) {
|
|
186
|
+
if (typeof color === "number") return !Number.isNaN(color);
|
|
187
|
+
return matchers.CSS_UNIT.test(color);
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
export { inputToRGB };
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=format-input.mjs.map
|