You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
33 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, ref, reactive, computed, onMounted, watch, nextTick, provide, openBlock, createBlock, unref, withCtx, withDirectives, createElementBlock, withKeys, createElementVNode, normalizeClass, createVNode, createCommentVNode, createTextVNode, toDisplayString, mergeProps, normalizeStyle, vShow } from 'vue';\nimport { debounce } from 'lodash-unified';\nimport { ElButton } from '../../button/index.mjs';\nimport { ElIcon } from '../../icon/index.mjs';\nimport { ElTooltip } from '../../tooltip/index.mjs';\nimport { ElInput } from '../../input/index.mjs';\nimport { ArrowDown, Close } from '@element-plus/icons-vue';\nimport AlphaSlider from './components/alpha-slider.mjs';\nimport HueSlider from './components/hue-slider.mjs';\nimport Predefine from './components/predefine.mjs';\nimport SvPanel from './components/sv-panel.mjs';\nimport Color from './utils/color.mjs';\nimport { colorPickerProps, colorPickerEmits, colorPickerContextKey } from './color-picker2.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport ClickOutside from '../../../directives/click-outside/index.mjs';\nimport { useLocale } from '../../../hooks/use-locale/index.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { useFormItem, useFormItemInputId } from '../../form/src/hooks/use-form-item.mjs';\nimport { useFormSize, useFormDisabled } from '../../form/src/hooks/use-form-common-props.mjs';\nimport { useFocusController } from '../../../hooks/use-focus-controller/index.mjs';\nimport { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';\nimport { debugWarn } from '../../../utils/error.mjs';\nimport { EVENT_CODE } from '../../../constants/aria.mjs';\nconst __default__ = defineComponent({\n name: \"ElColorPicker\"\n});\nconst _sfc_main = /* @__PURE__ */defineComponent({\n ...__default__,\n props: colorPickerProps,\n emits: colorPickerEmits,\n setup(__props, {\n expose,\n emit\n }) {\n const props = __props;\n const {\n t\n } = useLocale();\n const ns = useNamespace(\"color\");\n const {\n formItem\n } = useFormItem();\n const colorSize = useFormSize();\n const colorDisabled = useFormDisabled();\n const {\n inputId: buttonId,\n isLabeledByFormItem\n } = useFormItemInputId(props, {\n formItemContext: formItem\n });\n const hue = ref();\n const sv = ref();\n const alpha = ref();\n const popper = ref();\n const triggerRef = ref();\n const inputRef = ref();\n const {\n isFocused,\n handleFocus,\n handleBlur\n } = useFocusController(triggerRef, {\n beforeFocus() {\n return colorDisabled.value;\n },\n beforeBlur(event) {\n var _a;\n return (_a = popper.value) == null ? void 0 : _a.isFocusInsideContent(event);\n },\n afterBlur() {\n setShowPicker(false);\n resetColor();\n }\n });\n let shouldActiveChange = true;\n const color = reactive(new Color({\n enableAlpha: props.showAlpha,\n format: props.colorFormat || \"\",\n value: props.modelValue\n }));\n const showPicker = ref(false);\n const showPanelColor = ref(false);\n const customInput = ref(\"\");\n const displayedColor = computed(() => {\n if (!props.modelValue && !showPanelColor.value) {\n return \"transparent\";\n }\n return displayedRgb(color, props.showAlpha);\n });\n const currentColor = computed(() => {\n return !props.modelValue && !showPanelColor.value ? \"\" : color.value;\n });\n const buttonAriaLabel = computed(() => {\n return !isLabeledByFormItem.value ? props.ariaLabel || t(\"el.colorpicker.defaultLabel\") : void 0;\n });\n const buttonAriaLabelledby = computed(() => {\n return isLabeledByFormItem.value ? formItem == null ? void 0 : formItem.labelId : void 0;\n });\n const btnKls = computed(() => {\n return [ns.b(\"picker\"), ns.is(\"disabled\", colorDisabled.value), ns.bm(\"picker\", colorSize.value), ns.is(\"focused\",