@moubing/bing-ui 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +300 -171
- package/dist/_virtual/_plugin-vue_export-helper.js +8 -0
- package/dist/bing-ui.css +1 -1
- package/dist/components/BingAnimatedText/BingAnimatedText.js +7 -0
- package/dist/components/BingAnimatedText/BingAnimatedText.vue_vue_type_script_setup_true_lang.js +194 -0
- package/dist/components/BingAppSwitcherTransition/BingAppSwitcherTransition.js +7 -0
- package/dist/components/BingAppSwitcherTransition/BingAppSwitcherTransition.vue_vue_type_script_setup_true_lang.js +244 -0
- package/dist/components/BingAutocomplete/BingAutocomplete.js +7 -0
- package/dist/components/BingAutocomplete/BingAutocomplete.vue.d.ts +4 -4
- package/dist/components/BingAutocomplete/BingAutocomplete.vue_vue_type_script_setup_true_lang.js +560 -0
- package/dist/components/BingButton/BingButton.js +7 -0
- package/dist/components/BingButton/BingButton.vue.d.ts +2 -2
- package/dist/components/BingButton/BingButton.vue_vue_type_script_setup_true_lang.js +200 -0
- package/dist/components/BingCard/BingCard.js +7 -0
- package/dist/components/BingCard/BingCard.vue_vue_type_script_setup_true_lang.js +481 -0
- package/dist/components/BingCarouselTransition/BingCarouselTransition.js +7 -0
- package/dist/components/BingCarouselTransition/BingCarouselTransition.vue_vue_type_script_setup_true_lang.js +174 -0
- package/dist/components/BingCheckbox/BingCheckbox.js +7 -0
- package/dist/components/BingCheckbox/BingCheckbox.vue.d.ts +4 -4
- package/dist/components/BingCheckbox/BingCheckbox.vue_vue_type_script_setup_true_lang.js +233 -0
- package/dist/components/BingCheckboxGroup/BingCheckboxGroup.context.js +4 -0
- package/dist/components/BingCheckboxGroup/BingCheckboxGroup.js +7 -0
- package/dist/components/BingCheckboxGroup/BingCheckboxGroup.vue.d.ts +4 -4
- package/dist/components/BingCheckboxGroup/BingCheckboxGroup.vue_vue_type_script_setup_true_lang.js +105 -0
- package/dist/components/BingCodeBlock/BingCodeBlock.highlight.js +78 -0
- package/dist/components/BingCodeBlock/BingCodeBlock.js +7 -0
- package/dist/components/BingCodeBlock/BingCodeBlock.vue_vue_type_script_setup_true_lang.js +347 -0
- package/dist/components/BingColorPicker/BingColorPicker.js +7 -0
- package/dist/components/BingColorPicker/BingColorPicker.utils.d.ts +70 -0
- package/dist/components/BingColorPicker/BingColorPicker.utils.js +265 -0
- package/dist/components/BingColorPicker/BingColorPicker.vue.d.ts +7 -7
- package/dist/components/BingColorPicker/BingColorPicker.vue_vue_type_script_setup_true_lang.js +540 -0
- package/dist/components/BingColorPicker/BingColorPickerFormatEditor.js +7 -0
- package/dist/components/BingColorPicker/BingColorPickerFormatEditor.vue.d.ts +27 -0
- package/dist/components/BingColorPicker/BingColorPickerFormatEditor.vue_vue_type_script_setup_true_lang.js +142 -0
- package/dist/components/BingColorPicker/BingColorPickerSpectrum.js +7 -0
- package/dist/components/BingColorPicker/BingColorPickerSpectrum.vue.d.ts +26 -0
- package/dist/components/BingColorPicker/BingColorPickerSpectrum.vue_vue_type_script_setup_true_lang.js +168 -0
- package/dist/components/BingConfigProvider/BingConfigProvider.js +5 -0
- package/dist/components/BingConfigProvider/BingConfigProvider.types.d.ts +5 -0
- package/dist/components/BingConfigProvider/BingConfigProvider.vue.d.ts +18 -0
- package/dist/components/BingConfigProvider/BingConfigProvider.vue_vue_type_script_setup_true_lang.js +18 -0
- package/dist/components/BingConfigProvider/index.d.ts +3 -0
- package/dist/components/BingCursor/BingCursor.controller.js +240 -0
- package/dist/components/BingCursor/BingCursor.js +7 -0
- package/dist/components/BingCursor/BingCursor.native.js +20 -0
- package/dist/components/BingCursor/BingCursor.presets.js +60 -0
- package/dist/components/BingCursor/BingCursor.shapes.js +83 -0
- package/dist/components/BingCursor/BingCursor.styleSource.js +83 -0
- package/dist/components/BingCursor/BingCursor.vue_vue_type_script_setup_true_lang.js +73 -0
- package/dist/components/BingDatePicker/BingDatePicker.js +7 -0
- package/dist/components/BingDatePicker/BingDatePicker.utils.d.ts +26 -0
- package/dist/components/BingDatePicker/BingDatePicker.utils.js +137 -0
- package/dist/components/BingDatePicker/BingDatePicker.vue.d.ts +14 -14
- package/dist/components/BingDatePicker/BingDatePicker.vue_vue_type_script_setup_true_lang.js +804 -0
- package/dist/components/BingDatePicker/BingDatePickerCalendar.js +7 -0
- package/dist/components/BingDatePicker/BingDatePickerCalendar.vue.d.ts +37 -0
- package/dist/components/BingDatePicker/BingDatePickerCalendar.vue_vue_type_script_setup_true_lang.js +248 -0
- package/dist/components/BingDatePicker/BingDatePickerTimePanel.js +7 -0
- package/dist/components/BingDatePicker/BingDatePickerTimePanel.vue.d.ts +26 -0
- package/dist/components/BingDatePicker/BingDatePickerTimePanel.vue_vue_type_script_setup_true_lang.js +97 -0
- package/dist/components/BingDeckTransition/BingDeckTransition.js +7 -0
- package/dist/components/BingDeckTransition/BingDeckTransition.vue_vue_type_script_setup_true_lang.js +187 -0
- package/dist/components/BingDialog/BingDialog.js +7 -0
- package/dist/components/BingDialog/BingDialog.vue.d.ts +4 -5
- package/dist/components/BingDialog/BingDialog.vue_vue_type_script_setup_true_lang.js +558 -0
- package/dist/components/BingDropDown/BingDropDown.context.js +4 -0
- package/dist/components/BingDropDown/BingDropDown.js +7 -0
- package/dist/components/BingDropDown/BingDropDown.vue.d.ts +1 -2
- package/dist/components/BingDropDown/BingDropDown.vue_vue_type_script_setup_true_lang.js +649 -0
- package/dist/components/BingDropDown/BingDropDownItem.js +7 -0
- package/dist/components/BingDropDown/BingDropDownItem.vue.d.ts +1 -1
- package/dist/components/BingDropDown/BingDropDownItem.vue_vue_type_script_setup_true_lang.js +308 -0
- package/dist/components/BingFilePreview/BingFilePreview.js +7 -0
- package/dist/components/BingFilePreview/BingFilePreview.vue.d.ts +4 -5
- package/dist/components/BingFilePreview/BingFilePreview.vue_vue_type_script_setup_true_lang.js +589 -0
- package/dist/components/BingForm/BingForm.context.js +7 -0
- package/dist/components/BingForm/BingForm.js +7 -0
- package/dist/components/BingForm/BingForm.vue.d.ts +0 -1
- package/dist/components/BingForm/BingForm.vue_vue_type_script_setup_true_lang.js +300 -0
- package/dist/components/BingForm/formFocus.js +13 -0
- package/dist/components/BingForm/formTabOrder.js +27 -0
- package/dist/components/BingForm/useFormControl.d.ts +1 -1
- package/dist/components/BingForm/useFormControl.js +24 -0
- package/dist/components/BingForm/useFormNextHint.js +135 -0
- package/dist/components/BingFormItem/BingFormItem.js +7 -0
- package/dist/components/BingFormItem/BingFormItem.vue.d.ts +1 -1
- package/dist/components/BingFormItem/BingFormItem.vue_vue_type_script_setup_true_lang.js +252 -0
- package/dist/components/BingIcon/BingIcon.js +7 -0
- package/dist/components/BingIcon/BingIcon.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/BingImage/BingImage.js +7 -0
- package/dist/components/BingImage/BingImage.vue_vue_type_script_setup_true_lang.js +244 -0
- package/dist/components/BingImagePreview/BingImagePreview.js +7 -0
- package/dist/components/BingImagePreview/BingImagePreview.vue.d.ts +4 -5
- package/dist/components/BingImagePreview/BingImagePreview.vue_vue_type_script_setup_true_lang.js +699 -0
- package/dist/components/BingInput/BingInput.js +7 -0
- package/dist/components/BingInput/BingInput.vue.d.ts +6 -6
- package/dist/components/BingInput/BingInput.vue_vue_type_script_setup_true_lang.js +311 -0
- package/dist/components/BingRadio/BingRadio.js +7 -0
- package/dist/components/BingRadio/BingRadio.vue.d.ts +4 -4
- package/dist/components/BingRadio/BingRadio.vue_vue_type_script_setup_true_lang.js +170 -0
- package/dist/components/BingRadioGroup/BingRadioGroup.context.js +4 -0
- package/dist/components/BingRadioGroup/BingRadioGroup.js +7 -0
- package/dist/components/BingRadioGroup/BingRadioGroup.vue.d.ts +4 -4
- package/dist/components/BingRadioGroup/BingRadioGroup.vue_vue_type_script_setup_true_lang.js +125 -0
- package/dist/components/BingResizable/BingResizable.js +7 -0
- package/dist/components/BingResizable/BingResizable.vue.d.ts +1 -1
- package/dist/components/BingResizable/BingResizable.vue_vue_type_script_setup_true_lang.js +555 -0
- package/dist/components/BingScrollbar/BingScrollbar.js +7 -0
- package/dist/components/BingScrollbar/BingScrollbar.vue.d.ts +2 -2
- package/dist/components/BingScrollbar/BingScrollbar.vue_vue_type_script_setup_true_lang.js +398 -0
- package/dist/components/BingSelect/BingSelect.js +7 -0
- package/dist/components/BingSelect/BingSelect.vue.d.ts +7 -7
- package/dist/components/BingSelect/BingSelect.vue_vue_type_script_setup_true_lang.js +1066 -0
- package/dist/components/BingSlider/BingSlider.js +7 -0
- package/dist/components/BingSlider/BingSlider.vue.d.ts +6 -6
- package/dist/components/BingSlider/BingSlider.vue_vue_type_script_setup_true_lang.js +130 -0
- package/dist/components/BingSortableList/BingSortableList.js +7 -0
- package/dist/components/BingSortableList/BingSortableList.vue_vue_type_script_setup_true_lang.js +334 -0
- package/dist/components/BingSortableList/BingSortableListItem.js +7 -0
- package/dist/components/BingSortableList/BingSortableListItem.vue_vue_type_script_setup_true_lang.js +76 -0
- package/dist/components/BingSplitPane/BingSplitPane.js +7 -0
- package/dist/components/BingSplitPane/BingSplitPane.vue_vue_type_script_setup_true_lang.js +167 -0
- package/dist/components/BingTable/BingTable.js +7 -0
- package/dist/components/BingTable/BingTable.measurements.js +72 -0
- package/dist/components/BingTable/BingTable.vue.d.ts +1 -2
- package/dist/components/BingTable/BingTable.vue_vue_type_script_setup_true_lang.js +1416 -0
- package/dist/components/BingTable/BingTableCellValue.js +7 -0
- package/dist/components/BingTable/BingTableCellValue.vue_vue_type_script_setup_true_lang.js +68 -0
- package/dist/components/BingTable/BingTableHeaderCell.js +5 -0
- package/dist/components/BingTable/BingTableHeaderCell.vue_vue_type_script_setup_true_lang.js +45 -0
- package/dist/components/BingTable/BingTableHeaderContent.js +7 -0
- package/dist/components/BingTable/BingTableHeaderContent.vue_vue_type_script_setup_true_lang.js +110 -0
- package/dist/components/BingTable/useTableColumns.js +126 -0
- package/dist/components/BingTableColumnControls/BingTableColumnControls.js +7 -0
- package/dist/components/BingTableColumnControls/BingTableColumnControls.vue.d.ts +1 -1
- package/dist/components/BingTableColumnControls/BingTableColumnControls.vue_vue_type_script_setup_true_lang.js +251 -0
- package/dist/components/BingTabs/BingTabs.js +7 -0
- package/dist/components/BingTabs/BingTabs.vue.d.ts +2 -3
- package/dist/components/BingTabs/BingTabs.vue_vue_type_script_setup_true_lang.js +320 -0
- package/dist/components/BingTag/BingTag.js +7 -0
- package/dist/components/BingTag/BingTag.vue.d.ts +0 -1
- package/dist/components/BingTag/BingTag.vue_vue_type_script_setup_true_lang.js +65 -0
- package/dist/components/BingTextarea/BingTextarea.js +7 -0
- package/dist/components/BingTextarea/BingTextarea.vue.d.ts +6 -6
- package/dist/components/BingTextarea/BingTextarea.vue_vue_type_script_setup_true_lang.js +243 -0
- package/dist/components/BingToast/BingToast.js +7 -0
- package/dist/components/BingToast/BingToast.service.js +132 -0
- package/dist/components/BingToast/BingToast.types.d.ts +1 -1
- package/dist/components/BingToast/BingToast.types.js +19 -0
- package/dist/components/BingToast/BingToast.vue.d.ts +0 -1
- package/dist/components/BingToast/BingToast.vue_vue_type_script_setup_true_lang.js +307 -0
- package/dist/components/BingTooltip/BingTooltip.js +7 -0
- package/dist/components/BingTooltip/BingTooltip.shared.js +14 -0
- package/dist/components/BingTooltip/BingTooltip.vue.d.ts +4 -5
- package/dist/components/BingTooltip/BingTooltip.vue_vue_type_script_setup_true_lang.js +572 -0
- package/dist/components/BingTreeSelect/BingTreeSelect.js +7 -0
- package/dist/components/BingTreeSelect/BingTreeSelect.vue.d.ts +7 -7
- package/dist/components/BingTreeSelect/BingTreeSelect.vue_vue_type_script_setup_true_lang.js +1274 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/icons/LICENSE-lucide.txt +39 -0
- package/dist/icons/createIcon.d.ts +8 -0
- package/dist/icons/createIcon.js +36 -0
- package/dist/icons/icons.d.ts +51 -0
- package/dist/icons/icons.js +252 -0
- package/dist/icons/index.d.ts +3 -0
- package/dist/index.js +48 -0
- package/dist/motion/clickParticles.d.ts +1 -1
- package/dist/motion/clickParticles2.js +66 -0
- package/dist/motion/index.d.ts +1 -1
- package/dist/motion/index.js +17 -0
- package/dist/motion/liquidHover.js +36 -0
- package/dist/motion/optionDetailMotion.d.ts +7 -1
- package/dist/motion/optionDetailMotion.js +74 -0
- package/dist/motion/panelMotion.js +19 -0
- package/dist/motion/reducedMotion.d.ts +16 -0
- package/dist/motion/reducedMotion.js +28 -0
- package/dist/motion/selectPanelMotion.js +115 -0
- package/dist/motion/smoothScroll.d.ts +2 -0
- package/dist/motion/smoothScroll.js +276 -0
- package/dist/motion/useClickFeedback.js +47 -0
- package/dist/motion/useTextControlCaret.js +136 -0
- package/dist/utils/clipboard.d.ts +9 -0
- package/dist/utils/clipboard.js +16 -0
- package/dist/utils/config.d.ts +42 -0
- package/dist/utils/config.js +37 -0
- package/dist/utils/controlAttrs.js +37 -0
- package/dist/utils/floating.d.ts +86 -0
- package/dist/utils/floating.js +99 -0
- package/dist/utils/glass.js +25 -0
- package/dist/utils/overlay.js +94 -0
- package/dist/utils/scrollLock.js +44 -0
- package/dist/utils/search.d.ts +16 -0
- package/dist/utils/search.js +23 -0
- package/dist/utils/useClientReady.js +10 -0
- package/dist/utils/useDeferredBlurValidation.d.ts +18 -0
- package/dist/utils/useDeferredBlurValidation.js +34 -0
- package/dist/utils/useKeyboardScrollSync.d.ts +11 -0
- package/dist/utils/useKeyboardScrollSync.js +28 -0
- package/dist/utils/useOptionDetailPanel.d.ts +50 -0
- package/dist/utils/useOptionDetailPanel.js +180 -0
- package/dist/utils/useOutsidePointerDown.d.ts +8 -0
- package/dist/utils/useOutsidePointerDown.js +17 -0
- package/dist/utils/useSearchShortcutFocus.d.ts +18 -0
- package/dist/utils/useSearchShortcutFocus.js +47 -0
- package/dist/utils/useVirtualList.d.ts +42 -0
- package/dist/utils/useVirtualList.js +74 -0
- package/package.json +15 -9
- package/dist/bing-ui.es.js +0 -31276
- package/dist/bing-ui.umd.js +0 -229
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import e from "../BingButton/BingButton.js";
|
|
2
|
+
import { Check as t, Copy as n } from "../../icons/icons.js";
|
|
3
|
+
import r from "../BingIcon/BingIcon.js";
|
|
4
|
+
import i from "../BingScrollbar/BingScrollbar.js";
|
|
5
|
+
import ee from "../BingResizable/BingResizable.js";
|
|
6
|
+
import { highlightCode as te } from "./BingCodeBlock.highlight.js";
|
|
7
|
+
import { writeTextWithClipboardApi as ne, writeTextWithTextareaFallback as re } from "../../utils/clipboard.js";
|
|
8
|
+
import { Fragment as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createVNode as d, defineComponent as f, nextTick as ie, normalizeClass as p, normalizeStyle as m, onBeforeUnmount as ae, onMounted as oe, openBlock as h, ref as g, renderList as _, toDisplayString as v, watch as se, withCtx as y } from "vue";
|
|
9
|
+
//#region src/components/BingCodeBlock/BingCodeBlock.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
+
var ce = ["aria-label"], le = {
|
|
11
|
+
key: 0,
|
|
12
|
+
class: "bing-code-block__header"
|
|
13
|
+
}, ue = { class: "bing-code-block__meta" }, de = {
|
|
14
|
+
key: 0,
|
|
15
|
+
class: "bing-code-block__title"
|
|
16
|
+
}, fe = {
|
|
17
|
+
key: 1,
|
|
18
|
+
class: "bing-code-block__language"
|
|
19
|
+
}, pe = { class: "bing-code-block__copy-label" }, me = { class: "bing-code-block__code" }, he = {
|
|
20
|
+
key: 0,
|
|
21
|
+
class: "bing-code-block__line-number",
|
|
22
|
+
"aria-hidden": "true"
|
|
23
|
+
}, ge = { class: "bing-code-block__line-content" }, _e = ["aria-label"], ve = {
|
|
24
|
+
key: 0,
|
|
25
|
+
class: "bing-code-block__header"
|
|
26
|
+
}, ye = { class: "bing-code-block__meta" }, be = {
|
|
27
|
+
key: 0,
|
|
28
|
+
class: "bing-code-block__title"
|
|
29
|
+
}, xe = {
|
|
30
|
+
key: 1,
|
|
31
|
+
class: "bing-code-block__language"
|
|
32
|
+
}, Se = { class: "bing-code-block__copy-label" }, Ce = { class: "bing-code-block__code" }, we = {
|
|
33
|
+
key: 0,
|
|
34
|
+
class: "bing-code-block__line-number",
|
|
35
|
+
"aria-hidden": "true"
|
|
36
|
+
}, Te = { class: "bing-code-block__line-content" }, b = 1, x = 2, S = 4, C = /* @__PURE__ */ f({
|
|
37
|
+
__name: "BingCodeBlock",
|
|
38
|
+
props: {
|
|
39
|
+
code: {},
|
|
40
|
+
language: { default: "text" },
|
|
41
|
+
theme: { default: "auto" },
|
|
42
|
+
title: { default: void 0 },
|
|
43
|
+
languageLabel: { default: void 0 },
|
|
44
|
+
copyable: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: !0
|
|
47
|
+
},
|
|
48
|
+
copyLabel: { default: "复制代码" },
|
|
49
|
+
copiedLabel: { default: "已复制" },
|
|
50
|
+
copyResetDelay: { default: 1600 },
|
|
51
|
+
lineNumbers: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: !0
|
|
54
|
+
},
|
|
55
|
+
highlightLines: { default: void 0 },
|
|
56
|
+
width: { default: void 0 },
|
|
57
|
+
maxHeight: { default: void 0 },
|
|
58
|
+
smoothScroll: {
|
|
59
|
+
type: [Boolean, Object],
|
|
60
|
+
default: !0
|
|
61
|
+
},
|
|
62
|
+
resizable: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: !1
|
|
65
|
+
},
|
|
66
|
+
resizableOptions: { default: void 0 },
|
|
67
|
+
wrap: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: !1
|
|
70
|
+
},
|
|
71
|
+
ariaLabel: { default: "代码块" }
|
|
72
|
+
},
|
|
73
|
+
emits: [
|
|
74
|
+
"copy",
|
|
75
|
+
"copyError",
|
|
76
|
+
"highlightError"
|
|
77
|
+
],
|
|
78
|
+
setup(f, { emit: C }) {
|
|
79
|
+
let Ee = [
|
|
80
|
+
"right",
|
|
81
|
+
"bottom",
|
|
82
|
+
"bottom-right"
|
|
83
|
+
], w = f, T = C, E = g(J(w.code)), D = g("idle"), O = g(!1), k = g(null), A = 0, j, M, N, P = o(() => w.language.trim() || "text"), F = g(G()), I = o(() => {
|
|
84
|
+
let e = typeof w.theme == "string" ? w.theme.trim() : "";
|
|
85
|
+
return e && e !== "auto" ? e : F.value;
|
|
86
|
+
}), L = o(() => w.languageLabel || (P.value === "text" ? "纯文本" : P.value.toUpperCase())), R = o(() => ["bing-code-block", {
|
|
87
|
+
"is-loading": D.value === "loading",
|
|
88
|
+
"is-error": D.value === "error",
|
|
89
|
+
"is-ready": D.value === "ready",
|
|
90
|
+
"is-wrapped": w.wrap,
|
|
91
|
+
"has-line-numbers": w.lineNumbers
|
|
92
|
+
}]), z = o(() => ({ maxHeight: q(w.maxHeight) })), B = o(() => ({
|
|
93
|
+
width: w.resizable ? "100%" : q(w.width),
|
|
94
|
+
height: w.resizable ? "100%" : void 0
|
|
95
|
+
})), V = o(() => w.resizable ? "100%" : void 0), De = o(() => ({
|
|
96
|
+
width: w.resizableOptions?.defaultSize?.width ?? w.width ?? 640,
|
|
97
|
+
height: w.resizableOptions?.defaultSize?.height ?? 360
|
|
98
|
+
})), Oe = o(() => w.resizableOptions?.directions ?? Ee), ke = o(() => w.resizableOptions?.ariaLabel ?? `${w.ariaLabel}尺寸调整`), Ae = o(() => je(w.highlightLines)), H = o(() => !!(w.title || L.value || w.copyable)), U = o(() => O.value ? w.copiedLabel : w.copyLabel), W = o(() => O.value ? t : n);
|
|
99
|
+
se(() => [
|
|
100
|
+
w.code,
|
|
101
|
+
P.value,
|
|
102
|
+
I.value
|
|
103
|
+
], () => {
|
|
104
|
+
Me();
|
|
105
|
+
}, { immediate: !0 }), oe(() => {
|
|
106
|
+
K(), M = new MutationObserver(K), M.observe(document.documentElement, {
|
|
107
|
+
attributeFilter: ["data-bing-theme"],
|
|
108
|
+
attributes: !0
|
|
109
|
+
}), N = window.matchMedia?.("(prefers-color-scheme: dark)"), N?.addEventListener?.("change", K);
|
|
110
|
+
}), ae(() => {
|
|
111
|
+
A += 1, Z(), M?.disconnect(), N?.removeEventListener?.("change", K), M = void 0, N = void 0;
|
|
112
|
+
});
|
|
113
|
+
function G() {
|
|
114
|
+
if (typeof document > "u") return "vitesse-light";
|
|
115
|
+
let e = document.documentElement.dataset.bingTheme, t = typeof window < "u" && window.matchMedia?.("(prefers-color-scheme: dark)").matches === !0;
|
|
116
|
+
return e === "dark" || e === "system" && t ? "github-dark" : "vitesse-light";
|
|
117
|
+
}
|
|
118
|
+
function K() {
|
|
119
|
+
F.value = G();
|
|
120
|
+
}
|
|
121
|
+
function q(e) {
|
|
122
|
+
return typeof e == "number" ? `${e}px` : e;
|
|
123
|
+
}
|
|
124
|
+
function J(e) {
|
|
125
|
+
return e.split("\n").map((e, t) => ({
|
|
126
|
+
number: t + 1,
|
|
127
|
+
tokens: [{ content: e }]
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
function je(e) {
|
|
131
|
+
let t = /* @__PURE__ */ new Set();
|
|
132
|
+
for (let n of e ?? []) {
|
|
133
|
+
if (typeof n == "number") {
|
|
134
|
+
Number.isInteger(n) && n > 0 && t.add(n);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
let [e, r] = n;
|
|
138
|
+
if (!(!Number.isInteger(e) || !Number.isInteger(r) || e <= 0 || r < e)) for (let n = e; n <= r; n += 1) t.add(n);
|
|
139
|
+
}
|
|
140
|
+
return t;
|
|
141
|
+
}
|
|
142
|
+
function Y(e) {
|
|
143
|
+
return ["bing-code-block__line", { "is-highlighted": Ae.value.has(e) }];
|
|
144
|
+
}
|
|
145
|
+
function X(e) {
|
|
146
|
+
let t = {};
|
|
147
|
+
return e.color && (t.color = e.color), e.fontStyle !== void 0 && ((e.fontStyle & b) === b && (t.fontStyle = "italic"), (e.fontStyle & x) === x && (t.fontWeight = "700"), (e.fontStyle & S) === S && (t.textDecoration = "underline")), t;
|
|
148
|
+
}
|
|
149
|
+
async function Me() {
|
|
150
|
+
let e = A += 1;
|
|
151
|
+
D.value = "loading", E.value = J(w.code);
|
|
152
|
+
try {
|
|
153
|
+
let t = await te(w.code, P.value, I.value);
|
|
154
|
+
if (e !== A) return;
|
|
155
|
+
E.value = t, D.value = "ready";
|
|
156
|
+
} catch (t) {
|
|
157
|
+
if (e !== A) return;
|
|
158
|
+
let n = t instanceof Error ? t : Error(String(t));
|
|
159
|
+
E.value = J(w.code), D.value = "error", T("highlightError", n);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function Z() {
|
|
163
|
+
if (j === void 0 || typeof window > "u") {
|
|
164
|
+
j = void 0;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
window.clearTimeout(j), j = void 0;
|
|
168
|
+
}
|
|
169
|
+
function Ne() {
|
|
170
|
+
Z(), !(typeof window > "u") && (j = window.setTimeout(() => {
|
|
171
|
+
j = void 0, O.value = !1;
|
|
172
|
+
}, Math.max(0, w.copyResetDelay)));
|
|
173
|
+
}
|
|
174
|
+
function Pe(e, t) {
|
|
175
|
+
let n = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;
|
|
176
|
+
return e.deltaMode === WheelEvent.DOM_DELTA_LINE ? n * 16 : e.deltaMode === WheelEvent.DOM_DELTA_PAGE ? n * t.clientWidth : n;
|
|
177
|
+
}
|
|
178
|
+
function Q(e, t) {
|
|
179
|
+
if (e.defaultPrevented || e.ctrlKey) return !1;
|
|
180
|
+
let n = Math.max(0, t.scrollWidth - t.clientWidth), r = Math.min(n, Math.max(0, t.scrollLeft + Pe(e, t)));
|
|
181
|
+
return r === t.scrollLeft ? !1 : (e.preventDefault(), t.scrollLeft = r, t.dispatchEvent(new Event("scroll")), !0);
|
|
182
|
+
}
|
|
183
|
+
function Fe(e) {
|
|
184
|
+
if (!e.shiftKey || e.defaultPrevented) return;
|
|
185
|
+
let t = k.value?.viewport, n = e.target;
|
|
186
|
+
if (!(!t || n instanceof Node && t.contains(n))) {
|
|
187
|
+
if (w.smoothScroll === !1) {
|
|
188
|
+
Q(e, t);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
(k.value?.handleWheel(e) ?? !1) || Q(e, t);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async function $() {
|
|
195
|
+
try {
|
|
196
|
+
if (!(await ne(w.code) || re(w.code))) throw Error("复制功能暂不可用。");
|
|
197
|
+
O.value = !0, T("copy", {
|
|
198
|
+
code: w.code,
|
|
199
|
+
language: P.value
|
|
200
|
+
}), await ie(), Ne();
|
|
201
|
+
} catch (e) {
|
|
202
|
+
T("copyError", e instanceof Error ? e : Error(String(e)));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return (t, n) => f.resizable ? (h(), s(ee, {
|
|
206
|
+
key: 0,
|
|
207
|
+
class: "bing-code-block__resizable",
|
|
208
|
+
"default-size": De.value,
|
|
209
|
+
"min-width": f.resizableOptions?.minWidth ?? 380,
|
|
210
|
+
"min-height": f.resizableOptions?.minHeight ?? 240,
|
|
211
|
+
"max-width": f.resizableOptions?.maxWidth,
|
|
212
|
+
"max-height": f.resizableOptions?.maxHeight,
|
|
213
|
+
mode: f.resizableOptions?.mode ?? "fixed",
|
|
214
|
+
"snap-mode": f.resizableOptions?.snapMode ?? "live",
|
|
215
|
+
directions: Oe.value,
|
|
216
|
+
step: f.resizableOptions?.step ?? 1,
|
|
217
|
+
disabled: f.resizableOptions?.disabled ?? !1,
|
|
218
|
+
"lock-aspect-ratio": f.resizableOptions?.lockAspectRatio ?? !1,
|
|
219
|
+
contain: f.resizableOptions?.contain ?? !1,
|
|
220
|
+
"show-size": f.resizableOptions?.showSize ?? !0,
|
|
221
|
+
"handle-size": f.resizableOptions?.handleSize ?? 12,
|
|
222
|
+
"aria-label": ke.value
|
|
223
|
+
}, {
|
|
224
|
+
default: y(() => [u("section", {
|
|
225
|
+
class: p(R.value),
|
|
226
|
+
style: m(B.value),
|
|
227
|
+
"aria-label": f.ariaLabel,
|
|
228
|
+
onWheel: Fe
|
|
229
|
+
}, [H.value ? (h(), l("header", le, [u("div", ue, [f.title ? (h(), l("span", de, v(f.title), 1)) : c("", !0), L.value ? (h(), l("span", fe, v(L.value), 1)) : c("", !0)]), f.copyable ? (h(), s(e, {
|
|
230
|
+
key: 0,
|
|
231
|
+
class: "bing-code-block__copy",
|
|
232
|
+
variant: "ghost",
|
|
233
|
+
size: "sm",
|
|
234
|
+
"html-type": "button",
|
|
235
|
+
"text-effect": "none",
|
|
236
|
+
throttle: !1,
|
|
237
|
+
"aria-label": U.value,
|
|
238
|
+
onClick: $
|
|
239
|
+
}, {
|
|
240
|
+
prefix: y(() => [d(r, {
|
|
241
|
+
icon: W.value,
|
|
242
|
+
size: "sm"
|
|
243
|
+
}, null, 8, ["icon"])]),
|
|
244
|
+
default: y(() => [u("span", pe, v(U.value), 1)]),
|
|
245
|
+
_: 1
|
|
246
|
+
}, 8, ["aria-label"])) : c("", !0)])) : c("", !0), d(i, {
|
|
247
|
+
ref_key: "scrollbarRef",
|
|
248
|
+
ref: k,
|
|
249
|
+
class: "bing-code-block__scroll",
|
|
250
|
+
height: V.value,
|
|
251
|
+
"max-height": f.maxHeight,
|
|
252
|
+
smooth: f.smoothScroll,
|
|
253
|
+
horizontal: "",
|
|
254
|
+
always: "",
|
|
255
|
+
"aria-label": f.ariaLabel
|
|
256
|
+
}, {
|
|
257
|
+
default: y(() => [u("pre", {
|
|
258
|
+
class: "bing-code-block__pre",
|
|
259
|
+
style: m(z.value)
|
|
260
|
+
}, [u("code", me, [(h(!0), l(a, null, _(E.value, (e) => (h(), l("span", {
|
|
261
|
+
key: e.number,
|
|
262
|
+
class: p(Y(e.number))
|
|
263
|
+
}, [f.lineNumbers ? (h(), l("span", he, v(e.number), 1)) : c("", !0), u("span", ge, [(h(!0), l(a, null, _(e.tokens, (t, n) => (h(), l("span", {
|
|
264
|
+
key: `${e.number}-${n}`,
|
|
265
|
+
class: "bing-code-block__token",
|
|
266
|
+
style: m(X(t))
|
|
267
|
+
}, v(t.content || ""), 5))), 128))])], 2))), 128))])], 4)]),
|
|
268
|
+
_: 1
|
|
269
|
+
}, 8, [
|
|
270
|
+
"height",
|
|
271
|
+
"max-height",
|
|
272
|
+
"smooth",
|
|
273
|
+
"aria-label"
|
|
274
|
+
])], 46, ce)]),
|
|
275
|
+
_: 1
|
|
276
|
+
}, 8, [
|
|
277
|
+
"default-size",
|
|
278
|
+
"min-width",
|
|
279
|
+
"min-height",
|
|
280
|
+
"max-width",
|
|
281
|
+
"max-height",
|
|
282
|
+
"mode",
|
|
283
|
+
"snap-mode",
|
|
284
|
+
"directions",
|
|
285
|
+
"step",
|
|
286
|
+
"disabled",
|
|
287
|
+
"lock-aspect-ratio",
|
|
288
|
+
"contain",
|
|
289
|
+
"show-size",
|
|
290
|
+
"handle-size",
|
|
291
|
+
"aria-label"
|
|
292
|
+
])) : (h(), l("section", {
|
|
293
|
+
key: 1,
|
|
294
|
+
class: p(R.value),
|
|
295
|
+
style: m(B.value),
|
|
296
|
+
"aria-label": f.ariaLabel,
|
|
297
|
+
onWheel: Fe
|
|
298
|
+
}, [H.value ? (h(), l("header", ve, [u("div", ye, [f.title ? (h(), l("span", be, v(f.title), 1)) : c("", !0), L.value ? (h(), l("span", xe, v(L.value), 1)) : c("", !0)]), f.copyable ? (h(), s(e, {
|
|
299
|
+
key: 0,
|
|
300
|
+
class: "bing-code-block__copy",
|
|
301
|
+
variant: "ghost",
|
|
302
|
+
size: "sm",
|
|
303
|
+
"html-type": "button",
|
|
304
|
+
"text-effect": "none",
|
|
305
|
+
throttle: !1,
|
|
306
|
+
"aria-label": U.value,
|
|
307
|
+
onClick: $
|
|
308
|
+
}, {
|
|
309
|
+
prefix: y(() => [d(r, {
|
|
310
|
+
icon: W.value,
|
|
311
|
+
size: "sm"
|
|
312
|
+
}, null, 8, ["icon"])]),
|
|
313
|
+
default: y(() => [u("span", Se, v(U.value), 1)]),
|
|
314
|
+
_: 1
|
|
315
|
+
}, 8, ["aria-label"])) : c("", !0)])) : c("", !0), d(i, {
|
|
316
|
+
ref_key: "scrollbarRef",
|
|
317
|
+
ref: k,
|
|
318
|
+
class: "bing-code-block__scroll",
|
|
319
|
+
height: V.value,
|
|
320
|
+
"max-height": f.maxHeight,
|
|
321
|
+
smooth: f.smoothScroll,
|
|
322
|
+
horizontal: "",
|
|
323
|
+
always: "",
|
|
324
|
+
"aria-label": f.ariaLabel
|
|
325
|
+
}, {
|
|
326
|
+
default: y(() => [u("pre", {
|
|
327
|
+
class: "bing-code-block__pre",
|
|
328
|
+
style: m(z.value)
|
|
329
|
+
}, [u("code", Ce, [(h(!0), l(a, null, _(E.value, (e) => (h(), l("span", {
|
|
330
|
+
key: e.number,
|
|
331
|
+
class: p(Y(e.number))
|
|
332
|
+
}, [f.lineNumbers ? (h(), l("span", we, v(e.number), 1)) : c("", !0), u("span", Te, [(h(!0), l(a, null, _(e.tokens, (t, n) => (h(), l("span", {
|
|
333
|
+
key: `${e.number}-${n}`,
|
|
334
|
+
class: "bing-code-block__token",
|
|
335
|
+
style: m(X(t))
|
|
336
|
+
}, v(t.content || ""), 5))), 128))])], 2))), 128))])], 4)]),
|
|
337
|
+
_: 1
|
|
338
|
+
}, 8, [
|
|
339
|
+
"height",
|
|
340
|
+
"max-height",
|
|
341
|
+
"smooth",
|
|
342
|
+
"aria-label"
|
|
343
|
+
])], 46, _e));
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
//#endregion
|
|
347
|
+
export { C as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import e from "../../_virtual/_plugin-vue_export-helper.js";
|
|
2
|
+
import t from "./BingColorPicker.vue_vue_type_script_setup_true_lang.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
//#region src/components/BingColorPicker/BingColorPicker.vue
|
|
5
|
+
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-52bb4f48"]]);
|
|
6
|
+
//#endregion
|
|
7
|
+
export { n as default };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { BingColorPickerFormat, BingColorPickerHslValue, BingColorPickerPreset, BingColorPickerPresetInput, BingColorPickerRgbValue } from './BingColorPicker.types';
|
|
2
|
+
export interface FormatEntry {
|
|
3
|
+
format: BingColorPickerFormat;
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface NormalizedPreset {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
export interface HsvColor {
|
|
12
|
+
h: number;
|
|
13
|
+
s: number;
|
|
14
|
+
v: number;
|
|
15
|
+
a: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ParsedColor {
|
|
18
|
+
alpha: number;
|
|
19
|
+
hex: string;
|
|
20
|
+
}
|
|
21
|
+
export type ColorValue = ReturnType<typeof createColorValue>;
|
|
22
|
+
export declare const defaultColor = "#ec4899";
|
|
23
|
+
export declare const defaultPresets: BingColorPickerPreset[];
|
|
24
|
+
export declare function normalizeCssLength(value: string | number): string;
|
|
25
|
+
export declare function parseCssSize(value: string | number | undefined, fallback: number): number;
|
|
26
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
27
|
+
export declare function normalizeHue(value: number): number;
|
|
28
|
+
export declare function normalizeChannel(value: number): number;
|
|
29
|
+
export declare function normalizeAlpha(value: number): number;
|
|
30
|
+
export declare function formatAlpha(value: number): string;
|
|
31
|
+
export declare function componentToHex(value: number): string;
|
|
32
|
+
export declare function alphaToHex(value: number): string;
|
|
33
|
+
export declare function rgbToHex(rgb: Pick<BingColorPickerRgbValue, 'r' | 'g' | 'b'>): string;
|
|
34
|
+
export declare function rgbToHexAlpha(rgb: Pick<BingColorPickerRgbValue, 'r' | 'g' | 'b'>, alpha?: number): string;
|
|
35
|
+
export declare function parseAlphaChannel(value: string | undefined, fallback?: number): number;
|
|
36
|
+
export declare function parseRgbChannel(value: string | undefined): number | undefined;
|
|
37
|
+
export declare function parsePercentChannel(value: string | undefined): number | undefined;
|
|
38
|
+
export declare function parseFunctionColorParts(value: string): {
|
|
39
|
+
alphaPart: string;
|
|
40
|
+
channels: string[];
|
|
41
|
+
};
|
|
42
|
+
export declare function parseColorInput(value: string | null | undefined): {
|
|
43
|
+
alpha: number;
|
|
44
|
+
hex: string;
|
|
45
|
+
} | undefined;
|
|
46
|
+
export declare function normalizeHex(value: string | null | undefined): string | undefined;
|
|
47
|
+
export declare function resolveColor(value: string | null | undefined): string;
|
|
48
|
+
export declare function resolveAlpha(value: string | null | undefined): number;
|
|
49
|
+
export declare function hexToRgb(hex: string): BingColorPickerRgbValue;
|
|
50
|
+
export declare function getHueFromHex(hex: string, fallback: number): number;
|
|
51
|
+
export declare function rgbToHsl(rgb: Pick<BingColorPickerRgbValue, 'r' | 'g' | 'b'>): BingColorPickerHslValue;
|
|
52
|
+
export declare function rgbToHsv(rgb: Pick<BingColorPickerRgbValue, 'r' | 'g' | 'b'>): HsvColor;
|
|
53
|
+
export declare function hsvToRgb(hsv: Pick<HsvColor, 'h' | 's' | 'v'>): BingColorPickerRgbValue;
|
|
54
|
+
export declare function hslToRgb(hsl: Pick<BingColorPickerHslValue, 'h' | 's' | 'l'>): BingColorPickerRgbValue;
|
|
55
|
+
export declare function createColorValue(hex: string, alpha?: number): {
|
|
56
|
+
hex: string;
|
|
57
|
+
hexAlpha: string;
|
|
58
|
+
rgba: string;
|
|
59
|
+
hsl: string;
|
|
60
|
+
rgb: {
|
|
61
|
+
a: number;
|
|
62
|
+
r: number;
|
|
63
|
+
g: number;
|
|
64
|
+
b: number;
|
|
65
|
+
};
|
|
66
|
+
hslParts: BingColorPickerHslValue;
|
|
67
|
+
};
|
|
68
|
+
export declare function getFormatLabel(format: BingColorPickerFormat): "HEX" | "RGBA" | "HSL";
|
|
69
|
+
export declare function getColorFormatValue(color: ReturnType<typeof createColorValue>, format: BingColorPickerFormat): string;
|
|
70
|
+
export declare function normalizePreset(preset: BingColorPickerPresetInput): NormalizedPreset | undefined;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
//#region src/components/BingColorPicker/BingColorPicker.utils.ts
|
|
2
|
+
var e = "#ec4899", t = [
|
|
3
|
+
{
|
|
4
|
+
label: "冰粉",
|
|
5
|
+
value: "#ec4899"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
label: "玫瑰红",
|
|
9
|
+
value: "#f43f5e"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: "琥珀橙",
|
|
13
|
+
value: "#f59e0b"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: "柔金",
|
|
17
|
+
value: "#eab308"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: "青柠绿",
|
|
21
|
+
value: "#84cc16"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: "翡翠绿",
|
|
25
|
+
value: "#10b981"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: "青色",
|
|
29
|
+
value: "#06b6d4"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: "天蓝",
|
|
33
|
+
value: "#0ea5e9"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: "亮蓝",
|
|
37
|
+
value: "#3b82f6"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: "靛蓝",
|
|
41
|
+
value: "#6366f1"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: "紫罗兰",
|
|
45
|
+
value: "#8b5cf6"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: "品红",
|
|
49
|
+
value: "#d946ef"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: "蓝灰",
|
|
53
|
+
value: "#334155"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: "石墨黑",
|
|
57
|
+
value: "#111827"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: "瓷白",
|
|
61
|
+
value: "#f8fafc"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
label: "浅粉",
|
|
65
|
+
value: "#fdf2f8"
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
function n(e) {
|
|
69
|
+
if (typeof e == "number") return `${e}px`;
|
|
70
|
+
let t = e.trim();
|
|
71
|
+
return /^-?\d+(\.\d)?\d*$/.test(t) ? `${t}px` : e;
|
|
72
|
+
}
|
|
73
|
+
function r(e, t) {
|
|
74
|
+
if (typeof e == "number") return Math.max(0, e);
|
|
75
|
+
if (typeof e == "string") {
|
|
76
|
+
let n = Number.parseFloat(e);
|
|
77
|
+
return Number.isFinite(n) ? Math.max(0, n) : t;
|
|
78
|
+
}
|
|
79
|
+
return t;
|
|
80
|
+
}
|
|
81
|
+
function i(e, t, n) {
|
|
82
|
+
return n < t ? t : Math.min(n, Math.max(t, e));
|
|
83
|
+
}
|
|
84
|
+
function a(e) {
|
|
85
|
+
return (Math.round(e) % 360 + 360) % 360;
|
|
86
|
+
}
|
|
87
|
+
function o(e) {
|
|
88
|
+
return i(Math.round(e), 0, 255);
|
|
89
|
+
}
|
|
90
|
+
function s(e) {
|
|
91
|
+
return Math.round(i(e, 0, 1) * 100) / 100;
|
|
92
|
+
}
|
|
93
|
+
function c(e) {
|
|
94
|
+
return `${s(e)}`;
|
|
95
|
+
}
|
|
96
|
+
function l(e) {
|
|
97
|
+
return o(e).toString(16).padStart(2, "0");
|
|
98
|
+
}
|
|
99
|
+
function u(e) {
|
|
100
|
+
return l(s(e) * 255);
|
|
101
|
+
}
|
|
102
|
+
function d(e) {
|
|
103
|
+
return `#${l(e.r)}${l(e.g)}${l(e.b)}`;
|
|
104
|
+
}
|
|
105
|
+
function f(e, t = 1) {
|
|
106
|
+
return `${d(e)}${u(t)}`;
|
|
107
|
+
}
|
|
108
|
+
function p(e, t = 1) {
|
|
109
|
+
if (e === void 0 || e.trim() === "") return t;
|
|
110
|
+
let n = e.trim(), r = Number.parseFloat(n);
|
|
111
|
+
return Number.isFinite(r) ? s(n.endsWith("%") ? r / 100 : r) : t;
|
|
112
|
+
}
|
|
113
|
+
function m(e) {
|
|
114
|
+
if (e === void 0 || e.trim() === "") return;
|
|
115
|
+
let t = e.trim(), n = Number.parseFloat(t);
|
|
116
|
+
if (Number.isFinite(n)) return o(t.endsWith("%") ? n / 100 * 255 : n);
|
|
117
|
+
}
|
|
118
|
+
function h(e) {
|
|
119
|
+
if (e === void 0 || e.trim() === "") return;
|
|
120
|
+
let t = e.trim(), n = Number.parseFloat(t);
|
|
121
|
+
if (Number.isFinite(n)) return i(n, 0, 100);
|
|
122
|
+
}
|
|
123
|
+
function g(e) {
|
|
124
|
+
let [t, n] = e.split("/"), r = t.trim().split(/[\s,]+/).filter(Boolean);
|
|
125
|
+
return {
|
|
126
|
+
alphaPart: n?.trim(),
|
|
127
|
+
channels: r
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function _(e) {
|
|
131
|
+
if (!e) return;
|
|
132
|
+
let t = e.trim().toLowerCase(), n = t.replace(/^#/, "");
|
|
133
|
+
if (/^[\da-f]{3}$/.test(n)) return {
|
|
134
|
+
alpha: 1,
|
|
135
|
+
hex: `#${n.split("").map((e) => `${e}${e}`).join("")}`
|
|
136
|
+
};
|
|
137
|
+
if (/^[\da-f]{4}$/.test(n)) {
|
|
138
|
+
let e = n.split("");
|
|
139
|
+
return {
|
|
140
|
+
alpha: s(Number.parseInt(`${e[3]}${e[3]}`, 16) / 255),
|
|
141
|
+
hex: `#${e.slice(0, 3).map((e) => `${e}${e}`).join("")}`
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (/^[\da-f]{6}$/.test(n)) return {
|
|
145
|
+
alpha: 1,
|
|
146
|
+
hex: `#${n}`
|
|
147
|
+
};
|
|
148
|
+
if (/^[\da-f]{8}$/.test(n)) return {
|
|
149
|
+
alpha: s(Number.parseInt(n.slice(6), 16) / 255),
|
|
150
|
+
hex: `#${n.slice(0, 6)}`
|
|
151
|
+
};
|
|
152
|
+
let r = t.match(/^rgba?\((.+)\)$/);
|
|
153
|
+
if (r) {
|
|
154
|
+
let { alphaPart: e, channels: t } = g(r[1]), [n, i, a] = t.map(m), o = p(e ?? t[3], 1);
|
|
155
|
+
if (n !== void 0 && i !== void 0 && a !== void 0) return {
|
|
156
|
+
alpha: o,
|
|
157
|
+
hex: d({
|
|
158
|
+
r: n,
|
|
159
|
+
g: i,
|
|
160
|
+
b: a
|
|
161
|
+
})
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
let i = t.match(/^hsla?\((.+)\)$/);
|
|
165
|
+
if (i) {
|
|
166
|
+
let { alphaPart: e, channels: t } = g(i[1]), n = Number.parseFloat(t[0] ?? ""), r = h(t[1]), a = h(t[2]), o = p(e ?? t[3], 1);
|
|
167
|
+
if (Number.isFinite(n) && r !== void 0 && a !== void 0) return {
|
|
168
|
+
alpha: o,
|
|
169
|
+
hex: d(E({
|
|
170
|
+
h: n,
|
|
171
|
+
s: r,
|
|
172
|
+
l: a
|
|
173
|
+
}))
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function v(e) {
|
|
178
|
+
return _(e)?.hex;
|
|
179
|
+
}
|
|
180
|
+
function y(e) {
|
|
181
|
+
return v(e) ?? "#ec4899";
|
|
182
|
+
}
|
|
183
|
+
function b(e) {
|
|
184
|
+
return _(e)?.alpha ?? 1;
|
|
185
|
+
}
|
|
186
|
+
function x(e) {
|
|
187
|
+
let t = y(e).slice(1), n = Number.parseInt(t, 16);
|
|
188
|
+
return {
|
|
189
|
+
r: n >> 16 & 255,
|
|
190
|
+
g: n >> 8 & 255,
|
|
191
|
+
b: n & 255,
|
|
192
|
+
a: 1
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function S(e, t) {
|
|
196
|
+
let n = w(x(e));
|
|
197
|
+
return n.s > 0 && n.v > 0 ? n.h : t;
|
|
198
|
+
}
|
|
199
|
+
function C(e) {
|
|
200
|
+
let t = e.r / 255, n = e.g / 255, r = e.b / 255, i = Math.max(t, n, r), o = Math.min(t, n, r), s = i - o, c = (i + o) / 2, l = 0, u = 0;
|
|
201
|
+
return s !== 0 && (u = s / (1 - Math.abs(2 * c - 1)), l = i === t ? 60 * ((n - r) / s % 6) : i === n ? 60 * ((r - t) / s + 2) : 60 * ((t - n) / s + 4)), {
|
|
202
|
+
h: a(l),
|
|
203
|
+
s: Math.round(u * 100),
|
|
204
|
+
l: Math.round(c * 100),
|
|
205
|
+
a: 1
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function w(e) {
|
|
209
|
+
let t = e.r / 255, n = e.g / 255, r = e.b / 255, i = Math.max(t, n, r), o = i - Math.min(t, n, r), s = 0;
|
|
210
|
+
return o !== 0 && (s = i === t ? 60 * ((n - r) / o % 6) : i === n ? 60 * ((r - t) / o + 2) : 60 * ((t - n) / o + 4)), {
|
|
211
|
+
h: a(s),
|
|
212
|
+
s: i === 0 ? 0 : Math.round(o / i * 100),
|
|
213
|
+
v: Math.round(i * 100),
|
|
214
|
+
a: 1
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function T(e) {
|
|
218
|
+
let t = a(e.h), n = i(e.s, 0, 100) / 100, r = i(e.v, 0, 100) / 100, s = r * n, c = s * (1 - Math.abs(t / 60 % 2 - 1)), l = r - s, u = 0, d = 0, f = 0;
|
|
219
|
+
return t < 60 ? (u = s, d = c) : t < 120 ? (u = c, d = s) : t < 180 ? (d = s, f = c) : t < 240 ? (d = c, f = s) : t < 300 ? (u = c, f = s) : (u = s, f = c), {
|
|
220
|
+
r: o((u + l) * 255),
|
|
221
|
+
g: o((d + l) * 255),
|
|
222
|
+
b: o((f + l) * 255),
|
|
223
|
+
a: 1
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function E(e) {
|
|
227
|
+
let t = a(e.h), n = i(e.s, 0, 100) / 100, r = i(e.l, 0, 100) / 100, s = (1 - Math.abs(2 * r - 1)) * n, c = s * (1 - Math.abs(t / 60 % 2 - 1)), l = r - s / 2, u = 0, d = 0, f = 0;
|
|
228
|
+
return t < 60 ? (u = s, d = c) : t < 120 ? (u = c, d = s) : t < 180 ? (d = s, f = c) : t < 240 ? (d = c, f = s) : t < 300 ? (u = c, f = s) : (u = s, f = c), {
|
|
229
|
+
r: o((u + l) * 255),
|
|
230
|
+
g: o((d + l) * 255),
|
|
231
|
+
b: o((f + l) * 255),
|
|
232
|
+
a: 1
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function D(e, t = 1) {
|
|
236
|
+
let n = s(t), r = {
|
|
237
|
+
...x(e),
|
|
238
|
+
a: n
|
|
239
|
+
}, i = C(r);
|
|
240
|
+
i.a = n;
|
|
241
|
+
let a = d(r), o = c(n);
|
|
242
|
+
return {
|
|
243
|
+
hex: a,
|
|
244
|
+
hexAlpha: f(r, n),
|
|
245
|
+
rgba: `rgba(${r.r}, ${r.g}, ${r.b}, ${o})`,
|
|
246
|
+
hsl: n >= 1 ? `hsl(${i.h}, ${i.s}%, ${i.l}%)` : `hsla(${i.h}, ${i.s}%, ${i.l}%, ${o})`,
|
|
247
|
+
rgb: r,
|
|
248
|
+
hslParts: i
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function O(e) {
|
|
252
|
+
return e === "hex" ? "HEX" : e === "rgba" ? "RGBA" : "HSL";
|
|
253
|
+
}
|
|
254
|
+
function k(e, t) {
|
|
255
|
+
return t === "hex" ? e.hexAlpha : t === "rgba" ? e.rgba : e.hsl;
|
|
256
|
+
}
|
|
257
|
+
function A(e) {
|
|
258
|
+
let t = v(typeof e == "string" ? e : e.value);
|
|
259
|
+
if (t) return {
|
|
260
|
+
label: typeof e == "string" ? t : e.label ?? t,
|
|
261
|
+
value: t
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
//#endregion
|
|
265
|
+
export { i as clamp, D as createColorValue, e as defaultColor, t as defaultPresets, k as getColorFormatValue, O as getFormatLabel, S as getHueFromHex, x as hexToRgb, T as hsvToRgb, s as normalizeAlpha, n as normalizeCssLength, v as normalizeHex, a as normalizeHue, A as normalizePreset, _ as parseColorInput, r as parseCssSize, b as resolveAlpha, y as resolveColor, d as rgbToHex, w as rgbToHsv };
|