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 @@
|
|
|
1
|
+
{"version":3,"file":"format-input.mjs","names":[],"sources":["../../../../../../../../../../../node_modules/.pnpm/@ctrl+tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/format-input.js"],"sourcesContent":["import { cmykToRgb, convertHexToDecimal, hslToRgb, hsvToRgb, parseIntFromHex, rgbToRgb, } from './conversion.js';\nimport { names } from './css-color-names.js';\nimport { boundAlpha, convertToPercentage } from './util.js';\n/**\n * Given a string or object, convert that input to RGB\n *\n * Possible string inputs:\n * ```\n * \"red\"\n * \"#f00\" or \"f00\"\n * \"#ff0000\" or \"ff0000\"\n * \"#ff000000\" or \"ff000000\"\n * \"rgb 255 0 0\" or \"rgb (255, 0, 0)\"\n * \"rgb 1.0 0 0\" or \"rgb (1, 0, 0)\"\n * \"rgba (255, 0, 0, 1)\" or \"rgba 255, 0, 0, 1\"\n * \"rgba (1.0, 0, 0, 1)\" or \"rgba 1.0, 0, 0, 1\"\n * \"hsl(0, 100%, 50%)\" or \"hsl 0 100% 50%\"\n * \"hsla(0, 100%, 50%, 1)\" or \"hsla 0 100% 50%, 1\"\n * \"hsv(0, 100%, 100%)\" or \"hsv 0 100% 100%\"\n * \"cmyk(0, 20, 0, 0)\" or \"cmyk 0 20 0 0\"\n * ```\n */\nexport function inputToRGB(color) {\n let rgb = { r: 0, g: 0, b: 0 };\n let a = 1;\n let s = null;\n let v = null;\n let l = null;\n let ok = false;\n let format = false;\n if (typeof color === 'string') {\n color = stringInputToObject(color);\n }\n if (typeof color === 'object') {\n if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {\n rgb = rgbToRgb(color.r, color.g, color.b);\n ok = true;\n format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';\n }\n else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {\n s = convertToPercentage(color.s);\n v = convertToPercentage(color.v);\n rgb = hsvToRgb(color.h, s, v);\n ok = true;\n format = 'hsv';\n }\n else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {\n s = convertToPercentage(color.s);\n l = convertToPercentage(color.l);\n rgb = hslToRgb(color.h, s, l);\n ok = true;\n format = 'hsl';\n }\n else if (isValidCSSUnit(color.c) &&\n isValidCSSUnit(color.m) &&\n isValidCSSUnit(color.y) &&\n isValidCSSUnit(color.k)) {\n rgb = cmykToRgb(color.c, color.m, color.y, color.k);\n ok = true;\n format = 'cmyk';\n }\n if (Object.prototype.hasOwnProperty.call(color, 'a')) {\n a = color.a;\n }\n }\n a = boundAlpha(a);\n return {\n ok,\n format: color.format || format,\n r: Math.min(255, Math.max(rgb.r, 0)),\n g: Math.min(255, Math.max(rgb.g, 0)),\n b: Math.min(255, Math.max(rgb.b, 0)),\n a,\n };\n}\n// <http://www.w3.org/TR/css3-values/#integers>\nconst CSS_INTEGER = '[-\\\\+]?\\\\d+%?';\n// <http://www.w3.org/TR/css3-values/#number-value>\nconst CSS_NUMBER = '[-\\\\+]?\\\\d*\\\\.\\\\d+%?';\n// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.\nconst CSS_UNIT = '(?:' + CSS_NUMBER + ')|(?:' + CSS_INTEGER + ')';\n// Actual matching.\n// Parentheses and commas are optional, but not required.\n// Whitespace can take the place of commas or opening paren\n// eslint-disable-next-line prettier/prettier\nconst PERMISSIVE_MATCH3 = '[\\\\s|\\\\(]+(' + CSS_UNIT + ')[,|\\\\s]+(' + CSS_UNIT + ')[,|\\\\s]+(' + CSS_UNIT + ')\\\\s*\\\\)?';\nconst PERMISSIVE_MATCH4 = \n// eslint-disable-next-line prettier/prettier\n'[\\\\s|\\\\(]+(' + CSS_UNIT + ')[,|\\\\s]+(' + CSS_UNIT + ')[,|\\\\s]+(' + CSS_UNIT + ')[,|\\\\s]+(' + CSS_UNIT + ')\\\\s*\\\\)?';\nconst matchers = {\n CSS_UNIT: new RegExp(CSS_UNIT),\n rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),\n rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),\n hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),\n hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),\n hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),\n hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),\n cmyk: new RegExp('cmyk' + PERMISSIVE_MATCH4),\n hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,\n hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,\n hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,\n hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,\n};\n/**\n * Permissive string parsing. Take in a number of formats, and output an object\n * 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}`\n */\nexport function stringInputToObject(color) {\n color = color.trim().toLowerCase();\n if (color.length === 0) {\n return false;\n }\n let named = false;\n if (names[color]) {\n color = names[color];\n named = true;\n }\n else if (color === 'transparent') {\n return { r: 0, g: 0, b: 0, a: 0, format: 'name' };\n }\n // Try to match string input using regular expressions.\n // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]\n // Just return an object and let the conversion functions handle that.\n // This way the result will be the same whether the tinycolor is initialized with string or object.\n let match = matchers.rgb.exec(color);\n if (match) {\n return { r: match[1], g: match[2], b: match[3] };\n }\n match = matchers.rgba.exec(color);\n if (match) {\n return { r: match[1], g: match[2], b: match[3], a: match[4] };\n }\n match = matchers.hsl.exec(color);\n if (match) {\n return { h: match[1], s: match[2], l: match[3] };\n }\n match = matchers.hsla.exec(color);\n if (match) {\n return { h: match[1], s: match[2], l: match[3], a: match[4] };\n }\n match = matchers.hsv.exec(color);\n if (match) {\n return { h: match[1], s: match[2], v: match[3] };\n }\n match = matchers.hsva.exec(color);\n if (match) {\n return { h: match[1], s: match[2], v: match[3], a: match[4] };\n }\n match = matchers.cmyk.exec(color);\n if (match) {\n return {\n c: match[1],\n m: match[2],\n y: match[3],\n k: match[4],\n };\n }\n match = matchers.hex8.exec(color);\n if (match) {\n return {\n r: parseIntFromHex(match[1]),\n g: parseIntFromHex(match[2]),\n b: parseIntFromHex(match[3]),\n a: convertHexToDecimal(match[4]),\n format: named ? 'name' : 'hex8',\n };\n }\n match = matchers.hex6.exec(color);\n if (match) {\n return {\n r: parseIntFromHex(match[1]),\n g: parseIntFromHex(match[2]),\n b: parseIntFromHex(match[3]),\n format: named ? 'name' : 'hex',\n };\n }\n match = matchers.hex4.exec(color);\n if (match) {\n return {\n r: parseIntFromHex(match[1] + match[1]),\n g: parseIntFromHex(match[2] + match[2]),\n b: parseIntFromHex(match[3] + match[3]),\n a: convertHexToDecimal(match[4] + match[4]),\n format: named ? 'name' : 'hex8',\n };\n }\n match = matchers.hex3.exec(color);\n if (match) {\n return {\n r: parseIntFromHex(match[1] + match[1]),\n g: parseIntFromHex(match[2] + match[2]),\n b: parseIntFromHex(match[3] + match[3]),\n format: named ? 'name' : 'hex',\n };\n }\n return false;\n}\n/**\n * Check to see if it looks like a CSS unit\n * (see `matchers` above for definition).\n */\nexport function isValidCSSUnit(color) {\n if (typeof color === 'number') {\n return !Number.isNaN(color);\n }\n return matchers.CSS_UNIT.test(color);\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,WAAW,OAAO;CAC9B,IAAI,MAAM;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE;CAC7B,IAAI,IAAI;CACR,IAAI,IAAI;CACR,IAAI,IAAI;CACR,IAAI,IAAI;CACR,IAAI,KAAK;CACT,IAAI,SAAS;CACb,IAAI,OAAO,UAAU,UACjB,QAAQ,oBAAoB,KAAK;CAErC,IAAI,OAAO,UAAU,UAAU;EAC3B,IAAI,eAAe,MAAM,CAAC,KAAK,eAAe,MAAM,CAAC,KAAK,eAAe,MAAM,CAAC,GAAG;GAC/E,MAAM,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;GACxC,KAAK;GACL,SAAS,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,MAAM,SAAS;EAC3D,OACK,IAAI,eAAe,MAAM,CAAC,KAAK,eAAe,MAAM,CAAC,KAAK,eAAe,MAAM,CAAC,GAAG;GACpF,IAAI,oBAAoB,MAAM,CAAC;GAC/B,IAAI,oBAAoB,MAAM,CAAC;GAC/B,MAAM,SAAS,MAAM,GAAG,GAAG,CAAC;GAC5B,KAAK;GACL,SAAS;EACb,OACK,IAAI,eAAe,MAAM,CAAC,KAAK,eAAe,MAAM,CAAC,KAAK,eAAe,MAAM,CAAC,GAAG;GACpF,IAAI,oBAAoB,MAAM,CAAC;GAC/B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KAAK,KAAK;CAChC,IAAI,OACA,OAAO;EACH,GAAG,gBAAgB,MAAM,EAAE;EAC3B,GAAG,gBAAgB,MAAM,EAAE;EAC3B,GAAG,gBAAgB,MAAM,EAAE;EAC3B,QAAQ,QAAQ,SAAS;CAC7B;CAEJ,QAAQ,SAAS,KAAK,KAAK,KAAK;CAChC,IAAI,OACA,OAAO;EACH,GAAG,gBAAgB,MAAM,KAAK,MAAM,EAAE;EACtC,GAAG,gBAAgB,MAAM,KAAK,MAAM,EAAE;EACtC,GAAG,gBAAgB,MAAM,KAAK,MAAM,EAAE;EACtC,GAAG,oBAAoB,MAAM,KAAK,MAAM,EAAE;EAC1C,QAAQ,QAAQ,SAAS;CAC7B;CAEJ,QAAQ,SAAS,KAAK,KAAK,KAAK;CAChC,IAAI,OACA,OAAO;EACH,GAAG,gBAAgB,MAAM,KAAK,MAAM,EAAE;EACtC,GAAG,gBAAgB,MAAM,KAAK,MAAM,EAAE;EACtC,GAAG,gBAAgB,MAAM,KAAK,MAAM,EAAE;EACtC,QAAQ,QAAQ,SAAS;CAC7B;CAEJ,OAAO;AACX;;;;;AAKA,SAAgB,eAAe,OAAO;CAClC,IAAI,OAAO,UAAU,UACjB,OAAO,CAAC,OAAO,MAAM,KAAK;CAE9B,OAAO,SAAS,SAAS,KAAK,KAAK;AACvC"}
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import { bound01, boundAlpha, clamp01 } from "./util.mjs";
|
|
2
|
+
import { numberInputToObject, rgbToCmyk, rgbToHex, rgbToHsl, rgbToHsv, rgbaToHex } from "./conversion.mjs";
|
|
3
|
+
import { names } from "./css-color-names.mjs";
|
|
4
|
+
import { inputToRGB } from "./format-input.mjs";
|
|
5
|
+
//#region ../../node_modules/.pnpm/@ctrl+tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/index.js
|
|
6
|
+
var TinyColor = class TinyColor {
|
|
7
|
+
constructor(color = "", opts = {}) {
|
|
8
|
+
if (color instanceof TinyColor) return color;
|
|
9
|
+
if (typeof color === "number") color = numberInputToObject(color);
|
|
10
|
+
this.originalInput = color;
|
|
11
|
+
const rgb = inputToRGB(color);
|
|
12
|
+
this.originalInput = color;
|
|
13
|
+
this.r = rgb.r;
|
|
14
|
+
this.g = rgb.g;
|
|
15
|
+
this.b = rgb.b;
|
|
16
|
+
this.a = rgb.a;
|
|
17
|
+
this.roundA = Math.round(100 * this.a) / 100;
|
|
18
|
+
this.format = opts.format ?? rgb.format;
|
|
19
|
+
this.gradientType = opts.gradientType;
|
|
20
|
+
if (this.r < 1) this.r = Math.round(this.r);
|
|
21
|
+
if (this.g < 1) this.g = Math.round(this.g);
|
|
22
|
+
if (this.b < 1) this.b = Math.round(this.b);
|
|
23
|
+
this.isValid = rgb.ok;
|
|
24
|
+
}
|
|
25
|
+
isDark() {
|
|
26
|
+
return this.getBrightness() < 128;
|
|
27
|
+
}
|
|
28
|
+
isLight() {
|
|
29
|
+
return !this.isDark();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the perceived brightness of the color, from 0-255.
|
|
33
|
+
*/
|
|
34
|
+
getBrightness() {
|
|
35
|
+
const rgb = this.toRgb();
|
|
36
|
+
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1e3;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the perceived luminance of a color, from 0-1.
|
|
40
|
+
*/
|
|
41
|
+
getLuminance() {
|
|
42
|
+
const rgb = this.toRgb();
|
|
43
|
+
let R;
|
|
44
|
+
let G;
|
|
45
|
+
let B;
|
|
46
|
+
const RsRGB = rgb.r / 255;
|
|
47
|
+
const GsRGB = rgb.g / 255;
|
|
48
|
+
const BsRGB = rgb.b / 255;
|
|
49
|
+
if (RsRGB <= .03928) R = RsRGB / 12.92;
|
|
50
|
+
else R = Math.pow((RsRGB + .055) / 1.055, 2.4);
|
|
51
|
+
if (GsRGB <= .03928) G = GsRGB / 12.92;
|
|
52
|
+
else G = Math.pow((GsRGB + .055) / 1.055, 2.4);
|
|
53
|
+
if (BsRGB <= .03928) B = BsRGB / 12.92;
|
|
54
|
+
else B = Math.pow((BsRGB + .055) / 1.055, 2.4);
|
|
55
|
+
return .2126 * R + .7152 * G + .0722 * B;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns the alpha value of a color, from 0-1.
|
|
59
|
+
*/
|
|
60
|
+
getAlpha() {
|
|
61
|
+
return this.a;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Sets the alpha value on the current color.
|
|
65
|
+
*
|
|
66
|
+
* @param alpha - The new alpha value. The accepted range is 0-1.
|
|
67
|
+
*/
|
|
68
|
+
setAlpha(alpha) {
|
|
69
|
+
this.a = boundAlpha(alpha);
|
|
70
|
+
this.roundA = Math.round(100 * this.a) / 100;
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Returns whether the color is monochrome.
|
|
75
|
+
*/
|
|
76
|
+
isMonochrome() {
|
|
77
|
+
const { s } = this.toHsl();
|
|
78
|
+
return s === 0;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the object as a HSVA object.
|
|
82
|
+
*/
|
|
83
|
+
toHsv() {
|
|
84
|
+
const hsv = rgbToHsv(this.r, this.g, this.b);
|
|
85
|
+
return {
|
|
86
|
+
h: hsv.h * 360,
|
|
87
|
+
s: hsv.s,
|
|
88
|
+
v: hsv.v,
|
|
89
|
+
a: this.a
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns the hsva values interpolated into a string with the following format:
|
|
94
|
+
* "hsva(xxx, xxx, xxx, xx)".
|
|
95
|
+
*/
|
|
96
|
+
toHsvString() {
|
|
97
|
+
const hsv = rgbToHsv(this.r, this.g, this.b);
|
|
98
|
+
const h = Math.round(hsv.h * 360);
|
|
99
|
+
const s = Math.round(hsv.s * 100);
|
|
100
|
+
const v = Math.round(hsv.v * 100);
|
|
101
|
+
return this.a === 1 ? `hsv(${h}, ${s}%, ${v}%)` : `hsva(${h}, ${s}%, ${v}%, ${this.roundA})`;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the object as a HSLA object.
|
|
105
|
+
*/
|
|
106
|
+
toHsl() {
|
|
107
|
+
const hsl = rgbToHsl(this.r, this.g, this.b);
|
|
108
|
+
return {
|
|
109
|
+
h: hsl.h * 360,
|
|
110
|
+
s: hsl.s,
|
|
111
|
+
l: hsl.l,
|
|
112
|
+
a: this.a
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Returns the hsla values interpolated into a string with the following format:
|
|
117
|
+
* "hsla(xxx, xxx, xxx, xx)".
|
|
118
|
+
*/
|
|
119
|
+
toHslString() {
|
|
120
|
+
const hsl = rgbToHsl(this.r, this.g, this.b);
|
|
121
|
+
const h = Math.round(hsl.h * 360);
|
|
122
|
+
const s = Math.round(hsl.s * 100);
|
|
123
|
+
const l = Math.round(hsl.l * 100);
|
|
124
|
+
return this.a === 1 ? `hsl(${h}, ${s}%, ${l}%)` : `hsla(${h}, ${s}%, ${l}%, ${this.roundA})`;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns the hex value of the color.
|
|
128
|
+
* @param allow3Char will shorten hex value to 3 char if possible
|
|
129
|
+
*/
|
|
130
|
+
toHex(allow3Char = false) {
|
|
131
|
+
return rgbToHex(this.r, this.g, this.b, allow3Char);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns the hex value of the color -with a # prefixed.
|
|
135
|
+
* @param allow3Char will shorten hex value to 3 char if possible
|
|
136
|
+
*/
|
|
137
|
+
toHexString(allow3Char = false) {
|
|
138
|
+
return "#" + this.toHex(allow3Char);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Returns the hex 8 value of the color.
|
|
142
|
+
* @param allow4Char will shorten hex value to 4 char if possible
|
|
143
|
+
*/
|
|
144
|
+
toHex8(allow4Char = false) {
|
|
145
|
+
return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Returns the hex 8 value of the color -with a # prefixed.
|
|
149
|
+
* @param allow4Char will shorten hex value to 4 char if possible
|
|
150
|
+
*/
|
|
151
|
+
toHex8String(allow4Char = false) {
|
|
152
|
+
return "#" + this.toHex8(allow4Char);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Returns the shorter hex value of the color depends on its alpha -with a # prefixed.
|
|
156
|
+
* @param allowShortChar will shorten hex value to 3 or 4 char if possible
|
|
157
|
+
*/
|
|
158
|
+
toHexShortString(allowShortChar = false) {
|
|
159
|
+
return this.a === 1 ? this.toHexString(allowShortChar) : this.toHex8String(allowShortChar);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Returns the object as a RGBA object.
|
|
163
|
+
*/
|
|
164
|
+
toRgb() {
|
|
165
|
+
return {
|
|
166
|
+
r: Math.round(this.r),
|
|
167
|
+
g: Math.round(this.g),
|
|
168
|
+
b: Math.round(this.b),
|
|
169
|
+
a: this.a
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Returns the RGBA values interpolated into a string with the following format:
|
|
174
|
+
* "RGBA(xxx, xxx, xxx, xx)".
|
|
175
|
+
*/
|
|
176
|
+
toRgbString() {
|
|
177
|
+
const r = Math.round(this.r);
|
|
178
|
+
const g = Math.round(this.g);
|
|
179
|
+
const b = Math.round(this.b);
|
|
180
|
+
return this.a === 1 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${this.roundA})`;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Returns the object as a RGBA object.
|
|
184
|
+
*/
|
|
185
|
+
toPercentageRgb() {
|
|
186
|
+
const fmt = (x) => `${Math.round(bound01(x, 255) * 100)}%`;
|
|
187
|
+
return {
|
|
188
|
+
r: fmt(this.r),
|
|
189
|
+
g: fmt(this.g),
|
|
190
|
+
b: fmt(this.b),
|
|
191
|
+
a: this.a
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Returns the RGBA relative values interpolated into a string
|
|
196
|
+
*/
|
|
197
|
+
toPercentageRgbString() {
|
|
198
|
+
const rnd = (x) => Math.round(bound01(x, 255) * 100);
|
|
199
|
+
return this.a === 1 ? `rgb(${rnd(this.r)}%, ${rnd(this.g)}%, ${rnd(this.b)}%)` : `rgba(${rnd(this.r)}%, ${rnd(this.g)}%, ${rnd(this.b)}%, ${this.roundA})`;
|
|
200
|
+
}
|
|
201
|
+
toCmyk() {
|
|
202
|
+
return { ...rgbToCmyk(this.r, this.g, this.b) };
|
|
203
|
+
}
|
|
204
|
+
toCmykString() {
|
|
205
|
+
const { c, m, y, k } = rgbToCmyk(this.r, this.g, this.b);
|
|
206
|
+
return `cmyk(${c}, ${m}, ${y}, ${k})`;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The 'real' name of the color -if there is one.
|
|
210
|
+
*/
|
|
211
|
+
toName() {
|
|
212
|
+
if (this.a === 0) return "transparent";
|
|
213
|
+
if (this.a < 1) return false;
|
|
214
|
+
const hex = "#" + rgbToHex(this.r, this.g, this.b, false);
|
|
215
|
+
for (const [key, value] of Object.entries(names)) if (hex === value) return key;
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
toString(format) {
|
|
219
|
+
const formatSet = Boolean(format);
|
|
220
|
+
format = format ?? this.format;
|
|
221
|
+
let formattedString = false;
|
|
222
|
+
const hasAlpha = this.a < 1 && this.a >= 0;
|
|
223
|
+
if (!formatSet && hasAlpha && (format.startsWith("hex") || format === "name")) {
|
|
224
|
+
if (format === "name" && this.a === 0) return this.toName();
|
|
225
|
+
return this.toRgbString();
|
|
226
|
+
}
|
|
227
|
+
if (format === "rgb") formattedString = this.toRgbString();
|
|
228
|
+
if (format === "prgb") formattedString = this.toPercentageRgbString();
|
|
229
|
+
if (format === "hex" || format === "hex6") formattedString = this.toHexString();
|
|
230
|
+
if (format === "hex3") formattedString = this.toHexString(true);
|
|
231
|
+
if (format === "hex4") formattedString = this.toHex8String(true);
|
|
232
|
+
if (format === "hex8") formattedString = this.toHex8String();
|
|
233
|
+
if (format === "name") formattedString = this.toName();
|
|
234
|
+
if (format === "hsl") formattedString = this.toHslString();
|
|
235
|
+
if (format === "hsv") formattedString = this.toHsvString();
|
|
236
|
+
if (format === "cmyk") formattedString = this.toCmykString();
|
|
237
|
+
return formattedString || this.toHexString();
|
|
238
|
+
}
|
|
239
|
+
toNumber() {
|
|
240
|
+
return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
|
|
241
|
+
}
|
|
242
|
+
clone() {
|
|
243
|
+
return new TinyColor(this.toString());
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Lighten the color a given amount. Providing 100 will always return white.
|
|
247
|
+
* @param amount - valid between 1-100
|
|
248
|
+
*/
|
|
249
|
+
lighten(amount = 10) {
|
|
250
|
+
const hsl = this.toHsl();
|
|
251
|
+
hsl.l += amount / 100;
|
|
252
|
+
hsl.l = clamp01(hsl.l);
|
|
253
|
+
return new TinyColor(hsl);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Brighten the color a given amount, from 0 to 100.
|
|
257
|
+
* @param amount - valid between 1-100
|
|
258
|
+
*/
|
|
259
|
+
brighten(amount = 10) {
|
|
260
|
+
const rgb = this.toRgb();
|
|
261
|
+
rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
|
|
262
|
+
rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
|
|
263
|
+
rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
|
|
264
|
+
return new TinyColor(rgb);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Darken the color a given amount, from 0 to 100.
|
|
268
|
+
* Providing 100 will always return black.
|
|
269
|
+
* @param amount - valid between 1-100
|
|
270
|
+
*/
|
|
271
|
+
darken(amount = 10) {
|
|
272
|
+
const hsl = this.toHsl();
|
|
273
|
+
hsl.l -= amount / 100;
|
|
274
|
+
hsl.l = clamp01(hsl.l);
|
|
275
|
+
return new TinyColor(hsl);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Mix the color with pure white, from 0 to 100.
|
|
279
|
+
* Providing 0 will do nothing, providing 100 will always return white.
|
|
280
|
+
* @param amount - valid between 1-100
|
|
281
|
+
*/
|
|
282
|
+
tint(amount = 10) {
|
|
283
|
+
return this.mix("white", amount);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Mix the color with pure black, from 0 to 100.
|
|
287
|
+
* Providing 0 will do nothing, providing 100 will always return black.
|
|
288
|
+
* @param amount - valid between 1-100
|
|
289
|
+
*/
|
|
290
|
+
shade(amount = 10) {
|
|
291
|
+
return this.mix("black", amount);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Desaturate the color a given amount, from 0 to 100.
|
|
295
|
+
* Providing 100 will is the same as calling greyscale
|
|
296
|
+
* @param amount - valid between 1-100
|
|
297
|
+
*/
|
|
298
|
+
desaturate(amount = 10) {
|
|
299
|
+
const hsl = this.toHsl();
|
|
300
|
+
hsl.s -= amount / 100;
|
|
301
|
+
hsl.s = clamp01(hsl.s);
|
|
302
|
+
return new TinyColor(hsl);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Saturate the color a given amount, from 0 to 100.
|
|
306
|
+
* @param amount - valid between 1-100
|
|
307
|
+
*/
|
|
308
|
+
saturate(amount = 10) {
|
|
309
|
+
const hsl = this.toHsl();
|
|
310
|
+
hsl.s += amount / 100;
|
|
311
|
+
hsl.s = clamp01(hsl.s);
|
|
312
|
+
return new TinyColor(hsl);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Completely desaturates a color into greyscale.
|
|
316
|
+
* Same as calling `desaturate(100)`
|
|
317
|
+
*/
|
|
318
|
+
greyscale() {
|
|
319
|
+
return this.desaturate(100);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
|
|
323
|
+
* Values outside of this range will be wrapped into this range.
|
|
324
|
+
*/
|
|
325
|
+
spin(amount) {
|
|
326
|
+
const hsl = this.toHsl();
|
|
327
|
+
const hue = (hsl.h + amount) % 360;
|
|
328
|
+
hsl.h = hue < 0 ? 360 + hue : hue;
|
|
329
|
+
return new TinyColor(hsl);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Mix the current color a given amount with another color, from 0 to 100.
|
|
333
|
+
* 0 means no mixing (return current color).
|
|
334
|
+
*/
|
|
335
|
+
mix(color, amount = 50) {
|
|
336
|
+
const rgb1 = this.toRgb();
|
|
337
|
+
const rgb2 = new TinyColor(color).toRgb();
|
|
338
|
+
const p = amount / 100;
|
|
339
|
+
return new TinyColor({
|
|
340
|
+
r: (rgb2.r - rgb1.r) * p + rgb1.r,
|
|
341
|
+
g: (rgb2.g - rgb1.g) * p + rgb1.g,
|
|
342
|
+
b: (rgb2.b - rgb1.b) * p + rgb1.b,
|
|
343
|
+
a: (rgb2.a - rgb1.a) * p + rgb1.a
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
analogous(results = 6, slices = 30) {
|
|
347
|
+
const hsl = this.toHsl();
|
|
348
|
+
const part = 360 / slices;
|
|
349
|
+
const ret = [this];
|
|
350
|
+
for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) {
|
|
351
|
+
hsl.h = (hsl.h + part) % 360;
|
|
352
|
+
ret.push(new TinyColor(hsl));
|
|
353
|
+
}
|
|
354
|
+
return ret;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js
|
|
358
|
+
*/
|
|
359
|
+
complement() {
|
|
360
|
+
const hsl = this.toHsl();
|
|
361
|
+
hsl.h = (hsl.h + 180) % 360;
|
|
362
|
+
return new TinyColor(hsl);
|
|
363
|
+
}
|
|
364
|
+
monochromatic(results = 6) {
|
|
365
|
+
const hsv = this.toHsv();
|
|
366
|
+
const { h } = hsv;
|
|
367
|
+
const { s } = hsv;
|
|
368
|
+
let { v } = hsv;
|
|
369
|
+
const res = [];
|
|
370
|
+
const modification = 1 / results;
|
|
371
|
+
while (results--) {
|
|
372
|
+
res.push(new TinyColor({
|
|
373
|
+
h,
|
|
374
|
+
s,
|
|
375
|
+
v
|
|
376
|
+
}));
|
|
377
|
+
v = (v + modification) % 1;
|
|
378
|
+
}
|
|
379
|
+
return res;
|
|
380
|
+
}
|
|
381
|
+
splitcomplement() {
|
|
382
|
+
const hsl = this.toHsl();
|
|
383
|
+
const { h } = hsl;
|
|
384
|
+
return [
|
|
385
|
+
this,
|
|
386
|
+
new TinyColor({
|
|
387
|
+
h: (h + 72) % 360,
|
|
388
|
+
s: hsl.s,
|
|
389
|
+
l: hsl.l
|
|
390
|
+
}),
|
|
391
|
+
new TinyColor({
|
|
392
|
+
h: (h + 216) % 360,
|
|
393
|
+
s: hsl.s,
|
|
394
|
+
l: hsl.l
|
|
395
|
+
})
|
|
396
|
+
];
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Compute how the color would appear on a background
|
|
400
|
+
*/
|
|
401
|
+
onBackground(background) {
|
|
402
|
+
const fg = this.toRgb();
|
|
403
|
+
const bg = new TinyColor(background).toRgb();
|
|
404
|
+
const alpha = fg.a + bg.a * (1 - fg.a);
|
|
405
|
+
return new TinyColor({
|
|
406
|
+
r: (fg.r * fg.a + bg.r * bg.a * (1 - fg.a)) / alpha,
|
|
407
|
+
g: (fg.g * fg.a + bg.g * bg.a * (1 - fg.a)) / alpha,
|
|
408
|
+
b: (fg.b * fg.a + bg.b * bg.a * (1 - fg.a)) / alpha,
|
|
409
|
+
a: alpha
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Alias for `polyad(3)`
|
|
414
|
+
*/
|
|
415
|
+
triad() {
|
|
416
|
+
return this.polyad(3);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Alias for `polyad(4)`
|
|
420
|
+
*/
|
|
421
|
+
tetrad() {
|
|
422
|
+
return this.polyad(4);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)
|
|
426
|
+
* monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...
|
|
427
|
+
*/
|
|
428
|
+
polyad(n) {
|
|
429
|
+
const hsl = this.toHsl();
|
|
430
|
+
const { h } = hsl;
|
|
431
|
+
const result = [this];
|
|
432
|
+
const increment = 360 / n;
|
|
433
|
+
for (let i = 1; i < n; i++) result.push(new TinyColor({
|
|
434
|
+
h: (h + i * increment) % 360,
|
|
435
|
+
s: hsl.s,
|
|
436
|
+
l: hsl.l
|
|
437
|
+
}));
|
|
438
|
+
return result;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* compare color vs current color
|
|
442
|
+
*/
|
|
443
|
+
equals(color) {
|
|
444
|
+
const comparedColor = new TinyColor(color);
|
|
445
|
+
/**
|
|
446
|
+
* RGB and CMYK do not have the same color gamut, so a CMYK conversion will never be 100%.
|
|
447
|
+
* This means we need to compare CMYK to CMYK to ensure accuracy of the equals function.
|
|
448
|
+
*/
|
|
449
|
+
if (this.format === "cmyk" || comparedColor.format === "cmyk") return this.toCmykString() === comparedColor.toCmykString();
|
|
450
|
+
return this.toRgbString() === comparedColor.toRgbString();
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
//#endregion
|
|
454
|
+
export { TinyColor };
|
|
455
|
+
|
|
456
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../../../../node_modules/.pnpm/@ctrl+tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/index.js"],"sourcesContent":["import { numberInputToObject, rgbaToHex, rgbToCmyk, rgbToHex, rgbToHsl, rgbToHsv, } from './conversion.js';\nimport { names } from './css-color-names.js';\nimport { inputToRGB } from './format-input.js';\nimport { bound01, boundAlpha, clamp01 } from './util.js';\nexport class TinyColor {\n constructor(color = '', opts = {}) {\n // If input is already a tinycolor, return itself\n if (color instanceof TinyColor) {\n // eslint-disable-next-line no-constructor-return\n return color;\n }\n if (typeof color === 'number') {\n color = numberInputToObject(color);\n }\n this.originalInput = color;\n const rgb = inputToRGB(color);\n this.originalInput = color;\n this.r = rgb.r;\n this.g = rgb.g;\n this.b = rgb.b;\n this.a = rgb.a;\n this.roundA = Math.round(100 * this.a) / 100;\n this.format = opts.format ?? rgb.format;\n this.gradientType = opts.gradientType;\n // Don't let the range of [0,255] come back in [0,1].\n // Potentially lose a little bit of precision here, but will fix issues where\n // .5 gets interpreted as half of the total, instead of half of 1\n // If it was supposed to be 128, this was already taken care of by `inputToRgb`\n if (this.r < 1) {\n this.r = Math.round(this.r);\n }\n if (this.g < 1) {\n this.g = Math.round(this.g);\n }\n if (this.b < 1) {\n this.b = Math.round(this.b);\n }\n this.isValid = rgb.ok;\n }\n isDark() {\n return this.getBrightness() < 128;\n }\n isLight() {\n return !this.isDark();\n }\n /**\n * Returns the perceived brightness of the color, from 0-255.\n */\n getBrightness() {\n // http://www.w3.org/TR/AERT#color-contrast\n const rgb = this.toRgb();\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;\n }\n /**\n * Returns the perceived luminance of a color, from 0-1.\n */\n getLuminance() {\n // http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef\n const rgb = this.toRgb();\n let R;\n let G;\n let B;\n const RsRGB = rgb.r / 255;\n const GsRGB = rgb.g / 255;\n const BsRGB = rgb.b / 255;\n if (RsRGB <= 0.03928) {\n R = RsRGB / 12.92;\n }\n else {\n // eslint-disable-next-line prefer-exponentiation-operator\n R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);\n }\n if (GsRGB <= 0.03928) {\n G = GsRGB / 12.92;\n }\n else {\n // eslint-disable-next-line prefer-exponentiation-operator\n G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);\n }\n if (BsRGB <= 0.03928) {\n B = BsRGB / 12.92;\n }\n else {\n // eslint-disable-next-line prefer-exponentiation-operator\n B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);\n }\n return 0.2126 * R + 0.7152 * G + 0.0722 * B;\n }\n /**\n * Returns the alpha value of a color, from 0-1.\n */\n getAlpha() {\n return this.a;\n }\n /**\n * Sets the alpha value on the current color.\n *\n * @param alpha - The new alpha value. The accepted range is 0-1.\n */\n setAlpha(alpha) {\n this.a = boundAlpha(alpha);\n this.roundA = Math.round(100 * this.a) / 100;\n return this;\n }\n /**\n * Returns whether the color is monochrome.\n */\n isMonochrome() {\n const { s } = this.toHsl();\n return s === 0;\n }\n /**\n * Returns the object as a HSVA object.\n */\n toHsv() {\n const hsv = rgbToHsv(this.r, this.g, this.b);\n return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };\n }\n /**\n * Returns the hsva values interpolated into a string with the following format:\n * \"hsva(xxx, xxx, xxx, xx)\".\n */\n toHsvString() {\n const hsv = rgbToHsv(this.r, this.g, this.b);\n const h = Math.round(hsv.h * 360);\n const s = Math.round(hsv.s * 100);\n const v = Math.round(hsv.v * 100);\n return this.a === 1 ? `hsv(${h}, ${s}%, ${v}%)` : `hsva(${h}, ${s}%, ${v}%, ${this.roundA})`;\n }\n /**\n * Returns the object as a HSLA object.\n */\n toHsl() {\n const hsl = rgbToHsl(this.r, this.g, this.b);\n return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };\n }\n /**\n * Returns the hsla values interpolated into a string with the following format:\n * \"hsla(xxx, xxx, xxx, xx)\".\n */\n toHslString() {\n const hsl = rgbToHsl(this.r, this.g, this.b);\n const h = Math.round(hsl.h * 360);\n const s = Math.round(hsl.s * 100);\n const l = Math.round(hsl.l * 100);\n return this.a === 1 ? `hsl(${h}, ${s}%, ${l}%)` : `hsla(${h}, ${s}%, ${l}%, ${this.roundA})`;\n }\n /**\n * Returns the hex value of the color.\n * @param allow3Char will shorten hex value to 3 char if possible\n */\n toHex(allow3Char = false) {\n return rgbToHex(this.r, this.g, this.b, allow3Char);\n }\n /**\n * Returns the hex value of the color -with a # prefixed.\n * @param allow3Char will shorten hex value to 3 char if possible\n */\n toHexString(allow3Char = false) {\n return '#' + this.toHex(allow3Char);\n }\n /**\n * Returns the hex 8 value of the color.\n * @param allow4Char will shorten hex value to 4 char if possible\n */\n toHex8(allow4Char = false) {\n return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);\n }\n /**\n * Returns the hex 8 value of the color -with a # prefixed.\n * @param allow4Char will shorten hex value to 4 char if possible\n */\n toHex8String(allow4Char = false) {\n return '#' + this.toHex8(allow4Char);\n }\n /**\n * Returns the shorter hex value of the color depends on its alpha -with a # prefixed.\n * @param allowShortChar will shorten hex value to 3 or 4 char if possible\n */\n toHexShortString(allowShortChar = false) {\n return this.a === 1 ? this.toHexString(allowShortChar) : this.toHex8String(allowShortChar);\n }\n /**\n * Returns the object as a RGBA object.\n */\n toRgb() {\n return {\n r: Math.round(this.r),\n g: Math.round(this.g),\n b: Math.round(this.b),\n a: this.a,\n };\n }\n /**\n * Returns the RGBA values interpolated into a string with the following format:\n * \"RGBA(xxx, xxx, xxx, xx)\".\n */\n toRgbString() {\n const r = Math.round(this.r);\n const g = Math.round(this.g);\n const b = Math.round(this.b);\n return this.a === 1 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${this.roundA})`;\n }\n /**\n * Returns the object as a RGBA object.\n */\n toPercentageRgb() {\n const fmt = (x) => `${Math.round(bound01(x, 255) * 100)}%`;\n return {\n r: fmt(this.r),\n g: fmt(this.g),\n b: fmt(this.b),\n a: this.a,\n };\n }\n /**\n * Returns the RGBA relative values interpolated into a string\n */\n toPercentageRgbString() {\n const rnd = (x) => Math.round(bound01(x, 255) * 100);\n return this.a === 1\n ? `rgb(${rnd(this.r)}%, ${rnd(this.g)}%, ${rnd(this.b)}%)`\n : `rgba(${rnd(this.r)}%, ${rnd(this.g)}%, ${rnd(this.b)}%, ${this.roundA})`;\n }\n toCmyk() {\n return {\n ...rgbToCmyk(this.r, this.g, this.b),\n };\n }\n toCmykString() {\n const { c, m, y, k } = rgbToCmyk(this.r, this.g, this.b);\n return `cmyk(${c}, ${m}, ${y}, ${k})`;\n }\n /**\n * The 'real' name of the color -if there is one.\n */\n toName() {\n if (this.a === 0) {\n return 'transparent';\n }\n if (this.a < 1) {\n return false;\n }\n const hex = '#' + rgbToHex(this.r, this.g, this.b, false);\n for (const [key, value] of Object.entries(names)) {\n if (hex === value) {\n return key;\n }\n }\n return false;\n }\n toString(format) {\n const formatSet = Boolean(format);\n format = format ?? this.format;\n let formattedString = false;\n const hasAlpha = this.a < 1 && this.a >= 0;\n const needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith('hex') || format === 'name');\n if (needsAlphaFormat) {\n // Special case for \"transparent\", all other non-alpha formats\n // will return rgba when there is transparency.\n if (format === 'name' && this.a === 0) {\n return this.toName();\n }\n return this.toRgbString();\n }\n if (format === 'rgb') {\n formattedString = this.toRgbString();\n }\n if (format === 'prgb') {\n formattedString = this.toPercentageRgbString();\n }\n if (format === 'hex' || format === 'hex6') {\n formattedString = this.toHexString();\n }\n if (format === 'hex3') {\n formattedString = this.toHexString(true);\n }\n if (format === 'hex4') {\n formattedString = this.toHex8String(true);\n }\n if (format === 'hex8') {\n formattedString = this.toHex8String();\n }\n if (format === 'name') {\n formattedString = this.toName();\n }\n if (format === 'hsl') {\n formattedString = this.toHslString();\n }\n if (format === 'hsv') {\n formattedString = this.toHsvString();\n }\n if (format === 'cmyk') {\n formattedString = this.toCmykString();\n }\n return formattedString || this.toHexString();\n }\n toNumber() {\n return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);\n }\n clone() {\n return new TinyColor(this.toString());\n }\n /**\n * Lighten the color a given amount. Providing 100 will always return white.\n * @param amount - valid between 1-100\n */\n lighten(amount = 10) {\n const hsl = this.toHsl();\n hsl.l += amount / 100;\n hsl.l = clamp01(hsl.l);\n return new TinyColor(hsl);\n }\n /**\n * Brighten the color a given amount, from 0 to 100.\n * @param amount - valid between 1-100\n */\n brighten(amount = 10) {\n const rgb = this.toRgb();\n rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));\n rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));\n rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));\n return new TinyColor(rgb);\n }\n /**\n * Darken the color a given amount, from 0 to 100.\n * Providing 100 will always return black.\n * @param amount - valid between 1-100\n */\n darken(amount = 10) {\n const hsl = this.toHsl();\n hsl.l -= amount / 100;\n hsl.l = clamp01(hsl.l);\n return new TinyColor(hsl);\n }\n /**\n * Mix the color with pure white, from 0 to 100.\n * Providing 0 will do nothing, providing 100 will always return white.\n * @param amount - valid between 1-100\n */\n tint(amount = 10) {\n return this.mix('white', amount);\n }\n /**\n * Mix the color with pure black, from 0 to 100.\n * Providing 0 will do nothing, providing 100 will always return black.\n * @param amount - valid between 1-100\n */\n shade(amount = 10) {\n return this.mix('black', amount);\n }\n /**\n * Desaturate the color a given amount, from 0 to 100.\n * Providing 100 will is the same as calling greyscale\n * @param amount - valid between 1-100\n */\n desaturate(amount = 10) {\n const hsl = this.toHsl();\n hsl.s -= amount / 100;\n hsl.s = clamp01(hsl.s);\n return new TinyColor(hsl);\n }\n /**\n * Saturate the color a given amount, from 0 to 100.\n * @param amount - valid between 1-100\n */\n saturate(amount = 10) {\n const hsl = this.toHsl();\n hsl.s += amount / 100;\n hsl.s = clamp01(hsl.s);\n return new TinyColor(hsl);\n }\n /**\n * Completely desaturates a color into greyscale.\n * Same as calling `desaturate(100)`\n */\n greyscale() {\n return this.desaturate(100);\n }\n /**\n * Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.\n * Values outside of this range will be wrapped into this range.\n */\n spin(amount) {\n const hsl = this.toHsl();\n const hue = (hsl.h + amount) % 360;\n hsl.h = hue < 0 ? 360 + hue : hue;\n return new TinyColor(hsl);\n }\n /**\n * Mix the current color a given amount with another color, from 0 to 100.\n * 0 means no mixing (return current color).\n */\n mix(color, amount = 50) {\n const rgb1 = this.toRgb();\n const rgb2 = new TinyColor(color).toRgb();\n const p = amount / 100;\n const rgba = {\n r: (rgb2.r - rgb1.r) * p + rgb1.r,\n g: (rgb2.g - rgb1.g) * p + rgb1.g,\n b: (rgb2.b - rgb1.b) * p + rgb1.b,\n a: (rgb2.a - rgb1.a) * p + rgb1.a,\n };\n return new TinyColor(rgba);\n }\n analogous(results = 6, slices = 30) {\n const hsl = this.toHsl();\n const part = 360 / slices;\n const ret = [this];\n for (hsl.h = (hsl.h - ((part * results) >> 1) + 720) % 360; --results;) {\n hsl.h = (hsl.h + part) % 360;\n ret.push(new TinyColor(hsl));\n }\n return ret;\n }\n /**\n * taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js\n */\n complement() {\n const hsl = this.toHsl();\n hsl.h = (hsl.h + 180) % 360;\n return new TinyColor(hsl);\n }\n monochromatic(results = 6) {\n const hsv = this.toHsv();\n const { h } = hsv;\n const { s } = hsv;\n let { v } = hsv;\n const res = [];\n const modification = 1 / results;\n while (results--) {\n res.push(new TinyColor({ h, s, v }));\n v = (v + modification) % 1;\n }\n return res;\n }\n splitcomplement() {\n const hsl = this.toHsl();\n const { h } = hsl;\n return [\n this,\n new TinyColor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),\n new TinyColor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l }),\n ];\n }\n /**\n * Compute how the color would appear on a background\n */\n onBackground(background) {\n const fg = this.toRgb();\n const bg = new TinyColor(background).toRgb();\n const alpha = fg.a + bg.a * (1 - fg.a);\n return new TinyColor({\n r: (fg.r * fg.a + bg.r * bg.a * (1 - fg.a)) / alpha,\n g: (fg.g * fg.a + bg.g * bg.a * (1 - fg.a)) / alpha,\n b: (fg.b * fg.a + bg.b * bg.a * (1 - fg.a)) / alpha,\n a: alpha,\n });\n }\n /**\n * Alias for `polyad(3)`\n */\n triad() {\n return this.polyad(3);\n }\n /**\n * Alias for `polyad(4)`\n */\n tetrad() {\n return this.polyad(4);\n }\n /**\n * Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)\n * monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...\n */\n polyad(n) {\n const hsl = this.toHsl();\n const { h } = hsl;\n const result = [this];\n const increment = 360 / n;\n for (let i = 1; i < n; i++) {\n result.push(new TinyColor({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));\n }\n return result;\n }\n /**\n * compare color vs current color\n */\n equals(color) {\n const comparedColor = new TinyColor(color);\n /**\n * RGB and CMYK do not have the same color gamut, so a CMYK conversion will never be 100%.\n * This means we need to compare CMYK to CMYK to ensure accuracy of the equals function.\n */\n if (this.format === 'cmyk' || comparedColor.format === 'cmyk') {\n return this.toCmykString() === comparedColor.toCmykString();\n }\n return this.toRgbString() === comparedColor.toRgbString();\n }\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAIA,IAAa,YAAb,MAAa,UAAU;CACnB,YAAY,QAAQ,IAAI,OAAO,CAAC,GAAG;EAE/B,IAAI,iBAAiB,WAEjB,OAAO;EAEX,IAAI,OAAO,UAAU,UACjB,QAAQ,oBAAoB,KAAK;EAErC,KAAK,gBAAgB;EACrB,MAAM,MAAM,WAAW,KAAK;EAC5B,KAAK,gBAAgB;EACrB,KAAK,IAAI,IAAI;EACb,KAAK,IAAI,IAAI;EACb,KAAK,IAAI,IAAI;EACb,KAAK,IAAI,IAAI;EACb,KAAK,SAAS,KAAK,MAAM,MAAM,KAAK,CAAC,IAAI;EACzC,K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AAC;CACxB;;;;;CAKA,OAAO,GAAG;EACN,MAAM,MAAM,KAAK,MAAM;EACvB,MAAM,EAAE,MAAM;EACd,MAAM,SAAS,CAAC,IAAI;EACpB,MAAM,YAAY,MAAM;EACxB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KACnB,OAAO,KAAK,IAAI,UAAU;GAAE,IAAI,IAAI,IAAI,aAAa;GAAK,GAAG,IAAI;GAAG,GAAG,IAAI;EAAE,CAAC,CAAC;EAEnF,OAAO;CACX;;;;CAIA,OAAO,OAAO;EACV,MAAM,gBAAgB,IAAI,UAAU,KAAK;;;;;EAKzC,IAAI,KAAK,WAAW,UAAU,cAAc,WAAW,QACnD,OAAO,KAAK,aAAa,MAAM,cAAc,aAAa;EAE9D,OAAO,KAAK,YAAY,MAAM,cAAc,YAAY;CAC5D;AACJ"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@ctrl+tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/util.js
|
|
2
|
+
/**
|
|
3
|
+
* Take input from [0, n] and return it as [0, 1]
|
|
4
|
+
* @hidden
|
|
5
|
+
*/
|
|
6
|
+
function bound01(n, max) {
|
|
7
|
+
if (isOnePointZero(n)) n = "100%";
|
|
8
|
+
const isPercent = isPercentage(n);
|
|
9
|
+
n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
|
|
10
|
+
if (isPercent) n = parseInt(String(n * max), 10) / 100;
|
|
11
|
+
if (Math.abs(n - max) < 1e-6) return 1;
|
|
12
|
+
if (max === 360) n = (n < 0 ? n % max + max : n % max) / parseFloat(String(max));
|
|
13
|
+
else n = n % max / parseFloat(String(max));
|
|
14
|
+
return n;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Force a number between 0 and 1
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
function clamp01(val) {
|
|
21
|
+
return Math.min(1, Math.max(0, val));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
|
25
|
+
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
|
26
|
+
* @hidden
|
|
27
|
+
*/
|
|
28
|
+
function isOnePointZero(n) {
|
|
29
|
+
return typeof n === "string" && n.indexOf(".") !== -1 && parseFloat(n) === 1;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check to see if string passed in is a percentage
|
|
33
|
+
* @hidden
|
|
34
|
+
*/
|
|
35
|
+
function isPercentage(n) {
|
|
36
|
+
return typeof n === "string" && n.indexOf("%") !== -1;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Return a valid alpha value [0,1] with all invalid values being set to 1
|
|
40
|
+
* @hidden
|
|
41
|
+
*/
|
|
42
|
+
function boundAlpha(a) {
|
|
43
|
+
a = parseFloat(a);
|
|
44
|
+
if (isNaN(a) || a < 0 || a > 1) a = 1;
|
|
45
|
+
return a;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Replace a decimal with it's percentage value
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
51
|
+
function convertToPercentage(n) {
|
|
52
|
+
if (Number(n) <= 1) return `${Number(n) * 100}%`;
|
|
53
|
+
return n;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Force a hex value to have 2 characters
|
|
57
|
+
* @hidden
|
|
58
|
+
*/
|
|
59
|
+
function pad2(c) {
|
|
60
|
+
return c.length === 1 ? "0" + c : String(c);
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { bound01, boundAlpha, clamp01, convertToPercentage, pad2 };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=util.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.mjs","names":[],"sources":["../../../../../../../../../../../node_modules/.pnpm/@ctrl+tinycolor@4.2.0/node_modules/@ctrl/tinycolor/dist/module/util.js"],"sourcesContent":["/**\n * Take input from [0, n] and return it as [0, 1]\n * @hidden\n */\nexport function bound01(n, max) {\n if (isOnePointZero(n)) {\n n = '100%';\n }\n const isPercent = isPercentage(n);\n n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));\n // Automatically convert percentage into number\n if (isPercent) {\n n = parseInt(String(n * max), 10) / 100;\n }\n // Handle floating point rounding errors\n if (Math.abs(n - max) < 0.000001) {\n return 1;\n }\n // Convert into [0, 1] range if it isn't already\n if (max === 360) {\n // If n is a hue given in degrees,\n // wrap around out-of-range values into [0, 360] range\n // then convert into [0, 1].\n n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));\n }\n else {\n // If n not a hue given in degrees\n // Convert into [0, 1] range if it isn't already.\n n = (n % max) / parseFloat(String(max));\n }\n return n;\n}\n/**\n * Force a number between 0 and 1\n * @hidden\n */\nexport function clamp01(val) {\n return Math.min(1, Math.max(0, val));\n}\n/**\n * Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1\n * <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>\n * @hidden\n */\nexport function isOnePointZero(n) {\n return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;\n}\n/**\n * Check to see if string passed in is a percentage\n * @hidden\n */\nexport function isPercentage(n) {\n return typeof n === 'string' && n.indexOf('%') !== -1;\n}\n/**\n * Return a valid alpha value [0,1] with all invalid values being set to 1\n * @hidden\n */\nexport function boundAlpha(a) {\n a = parseFloat(a);\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n return a;\n}\n/**\n * Replace a decimal with it's percentage value\n * @hidden\n */\nexport function convertToPercentage(n) {\n if (Number(n) <= 1) {\n return `${Number(n) * 100}%`;\n }\n return n;\n}\n/**\n * Force a hex value to have 2 characters\n * @hidden\n */\nexport function pad2(c) {\n return c.length === 1 ? '0' + c : String(c);\n}\n"],"x_google_ignoreList":[0],"m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ist/predicate/isPlainObject.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a given value is a plain object.
|
|
4
|
+
*
|
|
5
|
+
* @param {object} value - The value to check.
|
|
6
|
+
* @returns {value is Record<PropertyKey, any>} - True if the value is a plain object, otherwise false.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // ✅👇 True
|
|
11
|
+
*
|
|
12
|
+
* isPlainObject({ }); // ✅
|
|
13
|
+
* isPlainObject({ key: 'value' }); // ✅
|
|
14
|
+
* isPlainObject({ key: new Date() }); // ✅
|
|
15
|
+
* isPlainObject(new Object()); // ✅
|
|
16
|
+
* isPlainObject(Object.create(null)); // ✅
|
|
17
|
+
* isPlainObject({ nested: { key: true} }); // ✅
|
|
18
|
+
* isPlainObject(new Proxy({}, {})); // ✅
|
|
19
|
+
* isPlainObject({ [Symbol('tag')]: 'A' }); // ✅
|
|
20
|
+
*
|
|
21
|
+
* // ✅👇 (cross-realms, node context, workers, ...)
|
|
22
|
+
* const runInNewContext = await import('node:vm').then(
|
|
23
|
+
* (mod) => mod.runInNewContext
|
|
24
|
+
* );
|
|
25
|
+
* isPlainObject(runInNewContext('({})')); // ✅
|
|
26
|
+
*
|
|
27
|
+
* // ❌👇 False
|
|
28
|
+
*
|
|
29
|
+
* class Test { };
|
|
30
|
+
* isPlainObject(new Test()) // ❌
|
|
31
|
+
* isPlainObject(10); // ❌
|
|
32
|
+
* isPlainObject(null); // ❌
|
|
33
|
+
* isPlainObject('hello'); // ❌
|
|
34
|
+
* isPlainObject([]); // ❌
|
|
35
|
+
* isPlainObject(new Date()); // ❌
|
|
36
|
+
* isPlainObject(new Uint8Array([1])); // ❌
|
|
37
|
+
* isPlainObject(Buffer.from('ABC')); // ❌
|
|
38
|
+
* isPlainObject(Promise.resolve({})); // ❌
|
|
39
|
+
* isPlainObject(Object.create({})); // ❌
|
|
40
|
+
* isPlainObject(new (class Cls {})); // ❌
|
|
41
|
+
* isPlainObject(globalThis); // ❌,
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
function isPlainObject(value) {
|
|
45
|
+
if (!value || typeof value !== "object") return false;
|
|
46
|
+
const proto = Object.getPrototypeOf(value);
|
|
47
|
+
if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
|
|
48
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { isPlainObject };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=isPlainObject.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlainObject.mjs","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs"],"sourcesContent":["//#region src/predicate/isPlainObject.ts\n/**\n* Checks if a given value is a plain object.\n*\n* @param {object} value - The value to check.\n* @returns {value is Record<PropertyKey, any>} - True if the value is a plain object, otherwise false.\n*\n* @example\n* ```typescript\n* // ✅👇 True\n*\n* isPlainObject({ }); // ✅\n* isPlainObject({ key: 'value' }); // ✅\n* isPlainObject({ key: new Date() }); // ✅\n* isPlainObject(new Object()); // ✅\n* isPlainObject(Object.create(null)); // ✅\n* isPlainObject({ nested: { key: true} }); // ✅\n* isPlainObject(new Proxy({}, {})); // ✅\n* isPlainObject({ [Symbol('tag')]: 'A' }); // ✅\n*\n* // ✅👇 (cross-realms, node context, workers, ...)\n* const runInNewContext = await import('node:vm').then(\n* (mod) => mod.runInNewContext\n* );\n* isPlainObject(runInNewContext('({})')); // ✅\n*\n* // ❌👇 False\n*\n* class Test { };\n* isPlainObject(new Test()) // ❌\n* isPlainObject(10); // ❌\n* isPlainObject(null); // ❌\n* isPlainObject('hello'); // ❌\n* isPlainObject([]); // ❌\n* isPlainObject(new Date()); // ❌\n* isPlainObject(new Uint8Array([1])); // ❌\n* isPlainObject(Buffer.from('ABC')); // ❌\n* isPlainObject(Promise.resolve({})); // ❌\n* isPlainObject(Object.create({})); // ❌\n* isPlainObject(new (class Cls {})); // ❌\n* isPlainObject(globalThis); // ❌,\n* ```\n*/\nfunction isPlainObject(value) {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst proto = Object.getPrototypeOf(value);\n\tif (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;\n\treturn Object.prototype.toString.call(value) === \"[object Object]\";\n}\n//#endregion\nexport { isPlainObject };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAS,cAAc,OAAO;CAC7B,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,MAAM,QAAQ,OAAO,eAAe,KAAK;CACzC,IAAI,EAAE,UAAU,QAAQ,UAAU,OAAO,aAAa,OAAO,eAAe,KAAK,MAAM,OAAO,OAAO;CACrG,OAAO,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM;AAClD"}
|