@moubing/bing-ui 0.11.2 → 0.12.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/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 -31278
- package/dist/bing-ui.umd.js +0 -229
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { onBeforeUnmount as e, onMounted as t, onUpdated as n } from "vue";
|
|
2
|
+
import { gsap as r } from "gsap";
|
|
3
|
+
//#region src/motion/useTextControlCaret.ts
|
|
4
|
+
var i = "(prefers-reduced-motion: reduce), (forced-colors: active), (pointer: coarse)", a = new Set([
|
|
5
|
+
"text",
|
|
6
|
+
"search",
|
|
7
|
+
"tel",
|
|
8
|
+
"url"
|
|
9
|
+
]), o = /[\u0590-\u08ff\u200e\u200f\u202a-\u202e\u2066-\u2069\ufb1d-\ufdff\ufe70-\ufeff]/u, s = [
|
|
10
|
+
"fontFamily",
|
|
11
|
+
"fontSize",
|
|
12
|
+
"fontWeight",
|
|
13
|
+
"fontStyle",
|
|
14
|
+
"fontStretch",
|
|
15
|
+
"fontVariant",
|
|
16
|
+
"fontKerning",
|
|
17
|
+
"fontFeatureSettings",
|
|
18
|
+
"fontVariationSettings",
|
|
19
|
+
"letterSpacing",
|
|
20
|
+
"wordSpacing",
|
|
21
|
+
"textTransform"
|
|
22
|
+
];
|
|
23
|
+
function c(c, l, u, ee) {
|
|
24
|
+
let d = () => {}, f = () => {};
|
|
25
|
+
n(() => d()), e(() => f()), t(() => {
|
|
26
|
+
let e = c.value, t = l.value, n = u.value;
|
|
27
|
+
if (!e || !t || !n) return;
|
|
28
|
+
let p = e.tagName === "TEXTAREA", m = () => p || a.has(e.type), h = e.ownerDocument, g = h.defaultView, _ = g.matchMedia(i), v = !1, y = !1, b = !1, x = !1, S = !1, C = 0, w = !1, T = !1, E, D, O, k = "", A = NaN, j = NaN, M = 0, N = 0, P = 0, F, I, L, R = h.createRange();
|
|
29
|
+
function z() {
|
|
30
|
+
S && (e.removeAttribute("data-smooth-caret"), n.removeAttribute("data-active")), S = !1, n.classList.contains("is-idle") && n.classList.remove("is-idle"), clearTimeout(E), I?.tween.pause(), L?.tween.pause();
|
|
31
|
+
}
|
|
32
|
+
function B() {
|
|
33
|
+
clearTimeout(E), n.classList.remove("is-idle"), E = setTimeout(() => {
|
|
34
|
+
S && !x && n.classList.add("is-idle");
|
|
35
|
+
}, 600);
|
|
36
|
+
}
|
|
37
|
+
function V() {
|
|
38
|
+
C = 0;
|
|
39
|
+
let i = w, a = T;
|
|
40
|
+
if (w = T = !1, x) return;
|
|
41
|
+
let c = y && e.selectionDirection !== "backward" ? e.selectionEnd : e.selectionStart;
|
|
42
|
+
if (!v || !ee() || e.disabled || e.readOnly || b || _.matches || h.hidden || !h.hasFocus() || h.activeElement !== e || !m() || c === null || !y && c !== e.selectionEnd || o.test(e.value)) {
|
|
43
|
+
z(), O && !m() && (O.data = "");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
let l = g.getComputedStyle(e);
|
|
47
|
+
if (l.direction !== "ltr" || l.writingMode !== "horizontal-tb" || !["start", "left"].includes(l.textAlign) || parseFloat(l.textIndent) !== 0 || !e.clientWidth) {
|
|
48
|
+
z();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
D || (D = h.createElement("span"), D.setAttribute("aria-hidden", "true"), D.style.cssText = "position:absolute;left:0;top:0;visibility:hidden;white-space:pre;width:max-content;pointer-events:none;", p && (D.style.cssText = "position:fixed;left:0;top:0;display:block;visibility:hidden;pointer-events:none;box-sizing:content-box;margin:0;padding:0;border:0;direction:ltr;", D.dataset.bingTextareaMeasure = ""), O = h.createTextNode(""), D.append(O), (p ? h.body : t).append(D));
|
|
52
|
+
let u = s.map((e) => l[e]).join("|");
|
|
53
|
+
if (k !== u && (s.forEach((e) => {
|
|
54
|
+
D.style[e] = l[e];
|
|
55
|
+
}), k = u), p) {
|
|
56
|
+
let t = e.clientWidth - parseFloat(l.paddingLeft) - parseFloat(l.paddingRight);
|
|
57
|
+
if (t <= 0) {
|
|
58
|
+
z();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
for (let e of [
|
|
62
|
+
"lineHeight",
|
|
63
|
+
"whiteSpace",
|
|
64
|
+
"overflowWrap",
|
|
65
|
+
"wordBreak",
|
|
66
|
+
"tabSize"
|
|
67
|
+
]) D.style[e] !== l[e] && (D.style[e] = l[e]);
|
|
68
|
+
D.style.width !== `${t}px` && (D.style.width = `${t}px`);
|
|
69
|
+
}
|
|
70
|
+
let d = p ? e.value + "" : e.value || "";
|
|
71
|
+
O.data !== d && (O.data = d), R.setStart(O, c), R.collapse(!0);
|
|
72
|
+
let f = R.getClientRects();
|
|
73
|
+
if (!f.length) {
|
|
74
|
+
z();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let E = D.getBoundingClientRect(), V = p ? 1 : t.getBoundingClientRect().width / t.clientWidth || 1, H = parseFloat(l.paddingLeft) || 0, U = f[0], W = e.offsetLeft + H + (U.left - E.left) / V - e.scrollLeft, G = Math.min(e.clientHeight, parseFloat(l.fontSize) * 1.2), K = parseFloat(l.lineHeight) || U.height, q = Math.max(0, Math.round((U.top - E.top) / K)), J = p ? e.offsetTop + parseFloat(l.paddingTop) + q * K + (K - G) / 2 - e.scrollTop : e.offsetTop + (e.clientHeight - G) / 2;
|
|
78
|
+
if (W < e.offsetLeft - 1 || W > e.offsetLeft + e.clientWidth + 1 || J + G <= e.offsetTop || J >= e.offsetTop + e.clientHeight) {
|
|
79
|
+
z();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let Y = Math.max(e.offsetLeft, Math.min(e.offsetLeft + e.clientWidth - 2, W)), X = !S || Math.abs(A - Y) > .1 || Math.abs(j - J) > .1, Z = M !== e.scrollLeft || N !== e.scrollTop || P !== e.clientWidth;
|
|
83
|
+
I || (F = r.context(() => {
|
|
84
|
+
I = r.quickTo(n, "x", {
|
|
85
|
+
duration: .09,
|
|
86
|
+
ease: "power2.out"
|
|
87
|
+
}), p && (L = r.quickTo(n, "y", {
|
|
88
|
+
duration: .09,
|
|
89
|
+
ease: "power2.out"
|
|
90
|
+
}));
|
|
91
|
+
}, t)), !S || i || Z ? (I(Y, Y), I.tween.progress(1).pause(), L && (L(J, J), L.tween.progress(1).pause())) : X && (I(Y), L?.(J)), n.style.height !== `${G}px` && (n.style.height = `${G}px`);
|
|
92
|
+
let Q = p ? "0px" : `${J}px`;
|
|
93
|
+
n.style.top !== Q && (n.style.top = Q), n.style.color !== l.color && (n.style.color = l.color), S || (n.setAttribute("data-active", ""), e.setAttribute("data-smooth-caret", "")), S = !0, A = Y, j = J, M = e.scrollLeft, N = e.scrollTop, P = e.clientWidth, (X || a) && B();
|
|
94
|
+
}
|
|
95
|
+
function H(e = !1, t = !1) {
|
|
96
|
+
x || !v || (w ||= e, T ||= t, C ||= g.requestAnimationFrame(V));
|
|
97
|
+
}
|
|
98
|
+
function U() {
|
|
99
|
+
x || !v || (g.cancelAnimationFrame(C), w = T = !0, V());
|
|
100
|
+
}
|
|
101
|
+
let W = () => H(), G = () => H(!0), K = () => H(!1, !0), q = () => z(), J = () => h.hidden ? z() : H(!0), Y = () => U(), X = new ResizeObserver(() => H());
|
|
102
|
+
function Z() {
|
|
103
|
+
v || (v = !0, h.addEventListener("selectionchange", W), h.addEventListener("pointerup", Y), h.addEventListener("pointercancel", Y), h.addEventListener("visibilitychange", J), g.addEventListener("blur", q), g.addEventListener("focus", G), g.addEventListener("resize", G), _.addEventListener("change", G), h.fonts?.addEventListener("loadingdone", G), X.observe(e), U(), H(!0, !0));
|
|
104
|
+
}
|
|
105
|
+
function Q() {
|
|
106
|
+
v = y = b = !1, z(), g.cancelAnimationFrame(C), C = 0, w = T = !1, h.removeEventListener("selectionchange", W), h.removeEventListener("pointerup", Y), h.removeEventListener("pointercancel", Y), h.removeEventListener("visibilitychange", J), g.removeEventListener("blur", q), g.removeEventListener("focus", G), g.removeEventListener("resize", G), _.removeEventListener("change", G), h.fonts?.removeEventListener("loadingdone", G), X.disconnect(), F?.revert(), F = I = L = void 0, D?.remove(), D = O = void 0, k = "";
|
|
107
|
+
}
|
|
108
|
+
let $ = {
|
|
109
|
+
focus: Z,
|
|
110
|
+
blur: Q,
|
|
111
|
+
input: K,
|
|
112
|
+
keydown: K,
|
|
113
|
+
keyup: W,
|
|
114
|
+
select: W,
|
|
115
|
+
scroll: G,
|
|
116
|
+
pointerdown: (e) => {
|
|
117
|
+
b ||= e.pointerType === "touch", b ? z() : H(!0, !0);
|
|
118
|
+
},
|
|
119
|
+
compositionstart: () => {
|
|
120
|
+
y = !0, H(!1, !0);
|
|
121
|
+
},
|
|
122
|
+
compositionupdate: K,
|
|
123
|
+
compositionend: () => {
|
|
124
|
+
y = !1, H(!1, !0);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
for (let [t, n] of Object.entries($)) e.addEventListener(t, n);
|
|
128
|
+
d = () => H(), f = () => {
|
|
129
|
+
x = !0, Q();
|
|
130
|
+
for (let [t, n] of Object.entries($)) e.removeEventListener(t, n);
|
|
131
|
+
d = () => {};
|
|
132
|
+
}, h.activeElement === e && Z();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
export { c as useTextControlCaret };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通过 Clipboard API 写入文本。环境不支持时返回 false;写入被拒绝时抛出原始错误,
|
|
3
|
+
* 由调用方决定是否回退。
|
|
4
|
+
*/
|
|
5
|
+
export declare function writeTextWithClipboardApi(value: string): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* 使用隐藏 textarea + execCommand('copy') 的兼容方案写入文本。
|
|
8
|
+
*/
|
|
9
|
+
export declare function writeTextWithTextareaFallback(value: string): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/utils/clipboard.ts
|
|
2
|
+
async function e(e) {
|
|
3
|
+
return typeof navigator > "u" || !navigator.clipboard?.writeText ? !1 : (await navigator.clipboard.writeText(e), !0);
|
|
4
|
+
}
|
|
5
|
+
function t(e) {
|
|
6
|
+
if (typeof document > "u") return !1;
|
|
7
|
+
let t = document.createElement("textarea");
|
|
8
|
+
t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.inset = "0 auto auto 0", t.style.width = "1px", t.style.height = "1px", t.style.opacity = "0", t.style.pointerEvents = "none", document.body.appendChild(t), t.select(), t.setSelectionRange(0, t.value.length);
|
|
9
|
+
try {
|
|
10
|
+
return document.execCommand?.("copy") === !0;
|
|
11
|
+
} finally {
|
|
12
|
+
t.remove();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { e as writeTextWithClipboardApi, t as writeTextWithTextareaFallback };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
+
export type BingConfigSize = 'sm' | 'md' | 'lg';
|
|
3
|
+
/**
|
|
4
|
+
* - `user`:跟随系统的 `prefers-reduced-motion` 设置(默认)。
|
|
5
|
+
* - `always`:始终减少动效,适合应用内提供“关闭动画”开关。
|
|
6
|
+
* - `never`:忽略系统设置,始终播放完整动效。
|
|
7
|
+
*/
|
|
8
|
+
export type BingReducedMotion = 'user' | 'always' | 'never';
|
|
9
|
+
export interface BingConfig {
|
|
10
|
+
/** 支持尺寸的组件在未显式传入 `size` 时使用的默认尺寸。 */
|
|
11
|
+
size?: BingConfigSize;
|
|
12
|
+
/** 浮层层级基准,默认 2000;各类浮层在此基础上保持固定的相对顺序。 */
|
|
13
|
+
zIndex?: number;
|
|
14
|
+
/** JS 驱动动效的减弱策略。 */
|
|
15
|
+
reducedMotion?: BingReducedMotion;
|
|
16
|
+
}
|
|
17
|
+
export interface BingConfigContext {
|
|
18
|
+
size: ComputedRef<BingConfigSize | undefined>;
|
|
19
|
+
zIndex: ComputedRef<number>;
|
|
20
|
+
reducedMotion: ComputedRef<BingReducedMotion>;
|
|
21
|
+
}
|
|
22
|
+
export declare const defaultBingZIndex = 2000;
|
|
23
|
+
/** 各浮层相对 `zIndex` 基准的偏移,与引入全局配置前的默认层级一致。 */
|
|
24
|
+
export declare const bingZIndexOffset: {
|
|
25
|
+
readonly dialog: 0;
|
|
26
|
+
readonly toast: 100;
|
|
27
|
+
readonly filePreview: 300;
|
|
28
|
+
readonly imagePreview: 400;
|
|
29
|
+
readonly colorPicker: 900;
|
|
30
|
+
readonly popover: 1000;
|
|
31
|
+
readonly datePicker: 1100;
|
|
32
|
+
readonly tooltip: 1200;
|
|
33
|
+
};
|
|
34
|
+
export type BingZIndexLayer = keyof typeof bingZIndexOffset;
|
|
35
|
+
export declare const bingConfigKey: InjectionKey<BingConfigContext>;
|
|
36
|
+
/** 在当前组件下提供全局配置;未设置的字段继承上层配置。 */
|
|
37
|
+
export declare function provideBingConfig(config: () => BingConfig): BingConfigContext;
|
|
38
|
+
export declare function useBingConfig(): BingConfigContext;
|
|
39
|
+
/** 组件 `size` 优先,其次全局配置,最后回落到 `md`。 */
|
|
40
|
+
export declare function useConfigSize<Size extends string>(getSize: () => Size | undefined): ComputedRef<Size | BingConfigSize>;
|
|
41
|
+
/** 组件显式传入的 `zIndex` 优先,否则使用全局基准加上该类浮层的偏移。 */
|
|
42
|
+
export declare function useConfigZIndex(layer: BingZIndexLayer, getZIndex?: () => number | undefined): ComputedRef<number>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { computed as e, inject as t, provide as n } from "vue";
|
|
2
|
+
//#region src/utils/config.ts
|
|
3
|
+
var r = 2e3, i = {
|
|
4
|
+
dialog: 0,
|
|
5
|
+
toast: 100,
|
|
6
|
+
filePreview: 300,
|
|
7
|
+
imagePreview: 400,
|
|
8
|
+
colorPicker: 900,
|
|
9
|
+
popover: 1e3,
|
|
10
|
+
datePicker: 1100,
|
|
11
|
+
tooltip: 1200
|
|
12
|
+
}, a = Symbol("BingConfig"), o = {
|
|
13
|
+
size: e(() => void 0),
|
|
14
|
+
zIndex: e(() => r),
|
|
15
|
+
reducedMotion: e(() => "user")
|
|
16
|
+
};
|
|
17
|
+
function s(r) {
|
|
18
|
+
let i = t(a, o), s = {
|
|
19
|
+
size: e(() => r().size ?? i.size.value),
|
|
20
|
+
zIndex: e(() => r().zIndex ?? i.zIndex.value),
|
|
21
|
+
reducedMotion: e(() => r().reducedMotion ?? i.reducedMotion.value)
|
|
22
|
+
};
|
|
23
|
+
return n(a, s), s;
|
|
24
|
+
}
|
|
25
|
+
function c() {
|
|
26
|
+
return t(a, o);
|
|
27
|
+
}
|
|
28
|
+
function l(t) {
|
|
29
|
+
let n = c();
|
|
30
|
+
return e(() => t() ?? n.size.value ?? "md");
|
|
31
|
+
}
|
|
32
|
+
function u(t, n = () => void 0) {
|
|
33
|
+
let r = c();
|
|
34
|
+
return e(() => n() ?? r.zIndex.value + i[t]);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { s as provideBingConfig, c as useBingConfig, l as useConfigSize, u as useConfigZIndex };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useAttrs as e } from "vue";
|
|
2
|
+
//#region src/utils/controlAttrs.ts
|
|
3
|
+
var t = new Set([
|
|
4
|
+
"role",
|
|
5
|
+
"readonly",
|
|
6
|
+
"required",
|
|
7
|
+
"form",
|
|
8
|
+
"maxlength",
|
|
9
|
+
"minlength",
|
|
10
|
+
"pattern",
|
|
11
|
+
"inputmode",
|
|
12
|
+
"autofocus",
|
|
13
|
+
"enterkeyhint",
|
|
14
|
+
"tabindex",
|
|
15
|
+
"list",
|
|
16
|
+
"autocapitalize",
|
|
17
|
+
"autocorrect",
|
|
18
|
+
"dirname",
|
|
19
|
+
"wrap",
|
|
20
|
+
"cols",
|
|
21
|
+
"onChange",
|
|
22
|
+
"onBeforeinput",
|
|
23
|
+
"onCompositionstart",
|
|
24
|
+
"onCompositionupdate",
|
|
25
|
+
"onCompositionend",
|
|
26
|
+
"onSelect",
|
|
27
|
+
"onInvalid"
|
|
28
|
+
]);
|
|
29
|
+
function n() {
|
|
30
|
+
let n = e(), r = (e) => t.has(e) || e.startsWith("aria-");
|
|
31
|
+
return {
|
|
32
|
+
rootAttrs: () => Object.fromEntries(Object.entries(n).filter(([e]) => !r(e))),
|
|
33
|
+
controlAttrs: () => Object.fromEntries(Object.entries(n).filter(([e]) => r(e)))
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { n as useControlAttrs };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 浮层定位的公共几何计算与视口跟随。
|
|
3
|
+
*
|
|
4
|
+
* 几何部分是纯函数:给定锚点矩形、浮层尺寸与视口,求出方向和左上角坐标。
|
|
5
|
+
* 各组件只负责测量自身尺寸、决定首选方向,并在结果上叠加各自的派生状态
|
|
6
|
+
* (最大高度、变换原点、侧边工具栏等)。
|
|
7
|
+
*/
|
|
8
|
+
export type FloatingSide = 'top' | 'bottom' | 'left' | 'right';
|
|
9
|
+
export type FloatingAlign = 'start' | 'center' | 'end';
|
|
10
|
+
/**
|
|
11
|
+
* - `none`:始终使用首选方向。
|
|
12
|
+
* - `opposite`:首选方向放不下且对侧空间更大时翻到对侧。
|
|
13
|
+
* - `best`:依次尝试首选、对侧及其余方向,取第一个放得下的;都放不下时取空间最大的。
|
|
14
|
+
*/
|
|
15
|
+
export type FloatingFlip = 'none' | 'opposite' | 'best';
|
|
16
|
+
export interface FloatingRect {
|
|
17
|
+
top: number;
|
|
18
|
+
right: number;
|
|
19
|
+
bottom: number;
|
|
20
|
+
left: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}
|
|
24
|
+
export interface FloatingSize {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}
|
|
28
|
+
export interface FloatingLayoutOptions {
|
|
29
|
+
/** 锚点与浮层的间距。 */
|
|
30
|
+
gap?: number;
|
|
31
|
+
/** 浮层与视口边缘保留的最小距离。 */
|
|
32
|
+
padding?: number;
|
|
33
|
+
/** 默认读取当前窗口尺寸。 */
|
|
34
|
+
viewport?: FloatingSize;
|
|
35
|
+
}
|
|
36
|
+
export interface ResolveFloatingSideOptions extends FloatingLayoutOptions {
|
|
37
|
+
anchor: FloatingRect;
|
|
38
|
+
floating: FloatingSize;
|
|
39
|
+
side: FloatingSide;
|
|
40
|
+
flip?: FloatingFlip;
|
|
41
|
+
}
|
|
42
|
+
export interface ComputeFloatingPositionOptions extends ResolveFloatingSideOptions {
|
|
43
|
+
align?: FloatingAlign;
|
|
44
|
+
/**
|
|
45
|
+
* 主轴方向是否把整个浮层推回视口。默认 `true`;
|
|
46
|
+
* 为 `false` 时只保证浮层起点不越过视口边距,浮层可以向外延伸。
|
|
47
|
+
*/
|
|
48
|
+
shiftMainAxis?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface FloatingPosition {
|
|
51
|
+
side: FloatingSide;
|
|
52
|
+
left: number;
|
|
53
|
+
top: number;
|
|
54
|
+
}
|
|
55
|
+
export declare function getOppositeSide(side: FloatingSide): FloatingSide;
|
|
56
|
+
export declare function isVerticalSide(side: FloatingSide): side is "top" | "bottom";
|
|
57
|
+
export declare function getViewportSize(): FloatingSize;
|
|
58
|
+
/** 限制在区间内;区间无效时取下限。 */
|
|
59
|
+
export declare function clampToRange(value: number, min: number, max: number): number;
|
|
60
|
+
/** 对齐到设备像素,避免半像素模糊。 */
|
|
61
|
+
export declare function snapToDevicePixel(value: number): number;
|
|
62
|
+
/** 锚点某一侧到视口边距之间的可用空间,可能为负数。 */
|
|
63
|
+
export declare function getAvailableSpace(anchor: FloatingRect, side: FloatingSide, { gap, padding, viewport }?: FloatingLayoutOptions): number;
|
|
64
|
+
export declare function resolveFloatingSide({ anchor, floating, side, flip, ...layout }: ResolveFloatingSideOptions): FloatingSide;
|
|
65
|
+
export declare function computeFloatingPosition(options: ComputeFloatingPositionOptions): FloatingPosition;
|
|
66
|
+
export interface FloatingAutoUpdateOptions {
|
|
67
|
+
/** 返回 `false` 时忽略本次调度,例如浮层已经关闭。 */
|
|
68
|
+
enabled?: () => boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface FloatingAutoUpdate {
|
|
71
|
+
/** 开始监听窗口尺寸变化与任意祖先滚动。重复调用无副作用。 */
|
|
72
|
+
start: () => void;
|
|
73
|
+
/** 停止监听。 */
|
|
74
|
+
stop: () => void;
|
|
75
|
+
/** 在下一帧执行更新,同一帧内的多次调度会合并。 */
|
|
76
|
+
schedule: () => void;
|
|
77
|
+
/** 取消尚未执行的更新。 */
|
|
78
|
+
cancel: () => void;
|
|
79
|
+
/** 停止监听并取消待执行的更新。 */
|
|
80
|
+
dispose: () => void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 浮层打开期间跟随视口变化重新定位。
|
|
84
|
+
* 在组件 setup 中调用时会在卸载前自动释放。
|
|
85
|
+
*/
|
|
86
|
+
export declare function useFloatingAutoUpdate(update: () => void, { enabled }?: FloatingAutoUpdateOptions): FloatingAutoUpdate;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { getCurrentInstance as e, onBeforeUnmount as t } from "vue";
|
|
2
|
+
//#region src/utils/floating.ts
|
|
3
|
+
var n = {
|
|
4
|
+
top: "bottom",
|
|
5
|
+
bottom: "top",
|
|
6
|
+
left: "right",
|
|
7
|
+
right: "left"
|
|
8
|
+
};
|
|
9
|
+
function r(e) {
|
|
10
|
+
return n[e];
|
|
11
|
+
}
|
|
12
|
+
function i(e) {
|
|
13
|
+
return e === "top" || e === "bottom";
|
|
14
|
+
}
|
|
15
|
+
function a() {
|
|
16
|
+
return typeof window > "u" ? {
|
|
17
|
+
width: 0,
|
|
18
|
+
height: 0
|
|
19
|
+
} : {
|
|
20
|
+
width: window.innerWidth,
|
|
21
|
+
height: window.innerHeight
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function o(e, t, n) {
|
|
25
|
+
return n < t ? t : Math.min(n, Math.max(t, e));
|
|
26
|
+
}
|
|
27
|
+
function s(e) {
|
|
28
|
+
if (typeof window > "u") return Math.round(e);
|
|
29
|
+
let t = window.devicePixelRatio || 1;
|
|
30
|
+
return Math.round(e * t) / t;
|
|
31
|
+
}
|
|
32
|
+
function c(e, t, { gap: n = 0, padding: r = 0, viewport: i = a() } = {}) {
|
|
33
|
+
return t === "top" ? e.top - n - r : t === "bottom" ? i.height - e.bottom - n - r : t === "left" ? e.left - n - r : i.width - e.right - n - r;
|
|
34
|
+
}
|
|
35
|
+
function l(e, t) {
|
|
36
|
+
return i(e) ? t.height : t.width;
|
|
37
|
+
}
|
|
38
|
+
function u({ anchor: e, floating: t, side: n, flip: i = "opposite", ...a }) {
|
|
39
|
+
if (i === "none") return n;
|
|
40
|
+
let o = (t) => c(e, t, a);
|
|
41
|
+
if (i === "opposite") {
|
|
42
|
+
let e = r(n), i = o(n);
|
|
43
|
+
return i >= l(n, t) || i >= o(e) ? n : e;
|
|
44
|
+
}
|
|
45
|
+
let s = [
|
|
46
|
+
n,
|
|
47
|
+
r(n),
|
|
48
|
+
"top",
|
|
49
|
+
"bottom",
|
|
50
|
+
"right",
|
|
51
|
+
"left"
|
|
52
|
+
].filter((e, t, n) => n.indexOf(e) === t), u = (e) => Math.max(0, o(e));
|
|
53
|
+
return s.find((e) => u(e) >= l(e, t)) || s.reduce((e, t) => u(t) > u(e) ? t : e);
|
|
54
|
+
}
|
|
55
|
+
function d(e, t, n, r) {
|
|
56
|
+
return e === "end" ? t + n - r : e === "center" ? t + n / 2 - r / 2 : t;
|
|
57
|
+
}
|
|
58
|
+
function f(e) {
|
|
59
|
+
let { anchor: t, floating: n, align: r = "start", gap: s = 0, padding: c = 0, viewport: l = a(), shiftMainAxis: f = !0 } = e, p = u({
|
|
60
|
+
...e,
|
|
61
|
+
gap: s,
|
|
62
|
+
padding: c,
|
|
63
|
+
viewport: l
|
|
64
|
+
}), m = i(p), h = m ? d(r, t.left, t.width, n.width) : p === "left" ? t.left - s - n.width : t.right + s, g = m ? p === "top" ? t.top - s - n.height : t.bottom + s : d(r, t.top, t.height, n.height), _ = !m && !f ? l.width - c : Math.max(c, l.width - c - n.width), v = m && !f ? l.height - c : Math.max(c, l.height - c - n.height);
|
|
65
|
+
return {
|
|
66
|
+
side: p,
|
|
67
|
+
left: o(h, c, _),
|
|
68
|
+
top: o(g, c, v)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function p(n, { enabled: r } = {}) {
|
|
72
|
+
let i = !1, a = 0;
|
|
73
|
+
function o() {
|
|
74
|
+
!a || typeof window > "u" || (window.cancelAnimationFrame(a), a = 0);
|
|
75
|
+
}
|
|
76
|
+
function s() {
|
|
77
|
+
typeof window > "u" || r && !r() || (o(), a = window.requestAnimationFrame(() => {
|
|
78
|
+
a = 0, n();
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
function c() {
|
|
82
|
+
i || typeof window > "u" || (window.addEventListener("resize", s), window.addEventListener("scroll", s, !0), i = !0);
|
|
83
|
+
}
|
|
84
|
+
function l() {
|
|
85
|
+
!i || typeof window > "u" || (window.removeEventListener("resize", s), window.removeEventListener("scroll", s, !0), i = !1);
|
|
86
|
+
}
|
|
87
|
+
function u() {
|
|
88
|
+
l(), o();
|
|
89
|
+
}
|
|
90
|
+
return e() && t(u), {
|
|
91
|
+
start: c,
|
|
92
|
+
stop: l,
|
|
93
|
+
schedule: s,
|
|
94
|
+
cancel: o,
|
|
95
|
+
dispose: u
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { o as clampToRange, f as computeFloatingPosition, c as getAvailableSpace, i as isVerticalSide, u as resolveFloatingSide, s as snapToDevicePixel, p as useFloatingAutoUpdate };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/utils/glass.ts
|
|
2
|
+
var e = {
|
|
3
|
+
glass: !0,
|
|
4
|
+
glassBlur: 16,
|
|
5
|
+
glassOpacity: .85,
|
|
6
|
+
glassSaturation: 1.28
|
|
7
|
+
};
|
|
8
|
+
function t(e, t, n) {
|
|
9
|
+
return Math.min(n, Math.max(t, e));
|
|
10
|
+
}
|
|
11
|
+
function n(e) {
|
|
12
|
+
if (typeof e == "number") return `${Math.max(0, e)}px`;
|
|
13
|
+
let t = e.trim();
|
|
14
|
+
return /^-?\d+(\.\d+)?$/.test(t) ? `${Math.max(0, Number(t))}px` : e;
|
|
15
|
+
}
|
|
16
|
+
function r(e, r) {
|
|
17
|
+
let i = r.glass !== !1, a = i ? r.glassBlur === void 0 ? "var(--bing-glass-blur, 16px)" : n(r.glassBlur) : "0px", o = i ? r.glassOpacity === void 0 ? "var(--bing-glass-opacity, 0.85)" : t(r.glassOpacity, 0, 1) : 1, s = i ? r.glassSaturation === void 0 ? "var(--bing-glass-saturation, 1.05)" : Math.max(0, r.glassSaturation) : 1;
|
|
18
|
+
return {
|
|
19
|
+
[`--${e}-glass-blur`]: a,
|
|
20
|
+
[`--${e}-glass-opacity`]: String(o),
|
|
21
|
+
[`--${e}-glass-saturation`]: String(s)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { r as createGlassCssVariables, e as defaultGlassEffect, n as normalizeGlassCssLength };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { computed as e, inject as t, nextTick as n, onBeforeUnmount as r, provide as i, ref as a, watch as o } from "vue";
|
|
2
|
+
//#region src/utils/overlay.ts
|
|
3
|
+
var s = Symbol("BingOverlay"), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function u(e, t) {
|
|
5
|
+
let n = l.get(e);
|
|
6
|
+
return n || (n = /* @__PURE__ */ new Set(), l.set(e, n)), n.add(t), () => {
|
|
7
|
+
n.delete(t), n.size || l.delete(e);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
var d = "a[href],button,input,select,textarea,[tabindex],[contenteditable=\"true\"]";
|
|
11
|
+
function f(e, t) {
|
|
12
|
+
return e === t || !!(e.parent && f(e.parent, t));
|
|
13
|
+
}
|
|
14
|
+
function p(e) {
|
|
15
|
+
let t = [], r = /* @__PURE__ */ new WeakMap(), i = () => t.at(-1), a = () => [...t].reverse().find((e) => e.modal), o = (e, n) => !!n && t.some((t) => f(t, e) && t.elements().some((e) => e?.contains(n)));
|
|
16
|
+
function s() {
|
|
17
|
+
let e = 0;
|
|
18
|
+
for (let n of t) n.zIndex.value = Math.max(n.minimumZIndex(), e + 2), e = n.zIndex.value;
|
|
19
|
+
}
|
|
20
|
+
function u(n) {
|
|
21
|
+
let r = t.filter((e) => f(e, n)).flatMap((e) => e.elements());
|
|
22
|
+
return [...new Set(r.flatMap((e) => e ? [e, ...e.querySelectorAll(d)] : []))].filter((t) => t.matches(d) && t.tabIndex >= 0 && !t.matches(":disabled") && !t.closest("[inert]") && t.getClientRects().length > 0 && e.defaultView?.getComputedStyle(t).visibility !== "hidden");
|
|
23
|
+
}
|
|
24
|
+
function p(e) {
|
|
25
|
+
(u(e)[0] ?? e.elements().find(Boolean))?.focus({ preventScroll: !0 });
|
|
26
|
+
}
|
|
27
|
+
function m(t) {
|
|
28
|
+
r.set(t, i());
|
|
29
|
+
let n = a();
|
|
30
|
+
if (t.key !== "Tab" || !n) return;
|
|
31
|
+
let o = u(n), s = o.indexOf(e.activeElement);
|
|
32
|
+
(!o.length || s < 0 || (t.shiftKey ? s === 0 : s === o.length - 1)) && (t.preventDefault(), o.length ? o[t.shiftKey ? o.length - 1 : 0]?.focus() : p(n));
|
|
33
|
+
}
|
|
34
|
+
function h(e) {
|
|
35
|
+
let t = r.get(e);
|
|
36
|
+
e.key === "Escape" && !e.defaultPrevented && t?.closeOnEscape() && (e.preventDefault(), r.set(e, void 0), t.onEscape?.(e));
|
|
37
|
+
}
|
|
38
|
+
function g(e) {
|
|
39
|
+
let t = a();
|
|
40
|
+
t && !o(t, e.target) && p(t);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
contains: o,
|
|
44
|
+
allowsFocus: (e) => !i() || o(i(), e),
|
|
45
|
+
isTop: (e, t) => (t && r.has(t) ? r.get(t) : i()) === e,
|
|
46
|
+
add(r) {
|
|
47
|
+
if (t.includes(r)) {
|
|
48
|
+
s();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
r.previousFocus = e.activeElement, t.push(r), s(), l.get(e)?.forEach((e) => e()), t.length === 1 && (e.defaultView?.addEventListener("keydown", m, !0), e.defaultView?.addEventListener("keydown", h), e.addEventListener("focusin", g)), r.modal && n(() => {
|
|
52
|
+
a() === r && !o(r, e.activeElement) && p(r);
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
remove(r) {
|
|
56
|
+
let i = t.indexOf(r);
|
|
57
|
+
if (i < 0) return;
|
|
58
|
+
let s = a() === r;
|
|
59
|
+
t.splice(i, 1), s && n(() => {
|
|
60
|
+
let e = a(), t = r.previousFocus;
|
|
61
|
+
t?.isConnected && (!e || o(e, t)) ? t.focus({ preventScroll: !0 }) : e && p(e);
|
|
62
|
+
}), t.length || (e.defaultView?.removeEventListener("keydown", m, !0), e.defaultView?.removeEventListener("keydown", h), e.removeEventListener("focusin", g), c.delete(e)), l.get(e)?.forEach((e) => e());
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function m(e) {
|
|
67
|
+
return c.get(e.ownerDocument)?.allowsFocus(e) ?? !0;
|
|
68
|
+
}
|
|
69
|
+
function h(n) {
|
|
70
|
+
let l = {
|
|
71
|
+
parent: t(s, null),
|
|
72
|
+
elements: n.elements,
|
|
73
|
+
modal: n.modal ?? !1,
|
|
74
|
+
minimumZIndex: n.zIndex,
|
|
75
|
+
zIndex: a(n.zIndex()),
|
|
76
|
+
closeOnEscape: n.closeOnEscape ?? (() => !0),
|
|
77
|
+
onEscape: n.onEscape,
|
|
78
|
+
previousFocus: null
|
|
79
|
+
};
|
|
80
|
+
i(s, l);
|
|
81
|
+
let u;
|
|
82
|
+
return o([n.open, n.zIndex], ([e]) => {
|
|
83
|
+
typeof document > "u" || (e ? (u = c.get(document), u || (u = p(document), c.set(document, u)), u.add(l)) : u?.remove(l));
|
|
84
|
+
}, {
|
|
85
|
+
immediate: !0,
|
|
86
|
+
flush: "post"
|
|
87
|
+
}), r(() => u?.remove(l)), {
|
|
88
|
+
zIndex: e(() => Math.max(n.zIndex(), l.zIndex.value)),
|
|
89
|
+
isTop: (e) => u?.isTop(l, e) ?? !1,
|
|
90
|
+
contains: (e) => u?.contains(l, e) ?? !1
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { m as isInActiveOverlayScope, u as onOverlayScopeChange, h as useOverlay };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/utils/scrollLock.ts
|
|
2
|
+
var e = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function t() {
|
|
4
|
+
let t = Symbol("scroll-lock"), n;
|
|
5
|
+
function r() {
|
|
6
|
+
if (!n) return;
|
|
7
|
+
let r = e.get(n);
|
|
8
|
+
r?.owners.delete(t), r && r.owners.size === 0 && (r.restore(), e.delete(n)), n = void 0;
|
|
9
|
+
}
|
|
10
|
+
function i(i = document) {
|
|
11
|
+
if (n === i) return;
|
|
12
|
+
r();
|
|
13
|
+
let { body: a, documentElement: o, defaultView: s } = i;
|
|
14
|
+
if (!a || !s) return;
|
|
15
|
+
let c = e.get(i);
|
|
16
|
+
if (!c) {
|
|
17
|
+
let t = [a, o], n = [
|
|
18
|
+
"overflow",
|
|
19
|
+
"overscroll-behavior",
|
|
20
|
+
"padding-right"
|
|
21
|
+
], r = t.map((e) => n.map((t) => ({
|
|
22
|
+
property: t,
|
|
23
|
+
value: e.style.getPropertyValue(t),
|
|
24
|
+
priority: e.style.getPropertyPriority(t)
|
|
25
|
+
})));
|
|
26
|
+
c = {
|
|
27
|
+
owners: /* @__PURE__ */ new Set(),
|
|
28
|
+
restore: () => t.forEach((e, t) => r[t]?.forEach(({ property: t, value: n, priority: r }) => {
|
|
29
|
+
n ? e.style.setProperty(t, n, r) : e.style.removeProperty(t);
|
|
30
|
+
}))
|
|
31
|
+
}, e.set(i, c);
|
|
32
|
+
let l = Math.max(0, s.innerWidth - o.clientWidth), u = Number.parseFloat(s.getComputedStyle(a).paddingRight) || 0;
|
|
33
|
+
l > 0 && (a.style.paddingRight = `${u + l}px`);
|
|
34
|
+
for (let e of t) e.style.overflow = "hidden", e.style.overscrollBehavior = "contain";
|
|
35
|
+
}
|
|
36
|
+
c.owners.add(t), n = i;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
lock: i,
|
|
40
|
+
unlock: r
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { t as createScrollLock };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 选项类组件共用的本地搜索匹配。
|
|
3
|
+
*
|
|
4
|
+
* 文本先做归一化:拆分驼峰、去除变音符号、下划线与连字符视作空格、统一小写。
|
|
5
|
+
* 查询按空白拆成多个关键词,每个关键词都需命中;不含数字的关键词还可以匹配单词首字母。
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeSearchText(value: unknown): string;
|
|
8
|
+
export declare function getSearchInitials(value: string): string;
|
|
9
|
+
export declare function searchTokenMatches(token: string, haystack: string): boolean;
|
|
10
|
+
/** `haystack` 需已归一化;`query` 为归一化后的查询。 */
|
|
11
|
+
export declare function searchQueryMatches(haystack: string, query: string): boolean;
|
|
12
|
+
/** 过滤空值后的元信息键值对,用于详情展示和搜索。 */
|
|
13
|
+
export declare function getMetaEntries(meta: Record<string, unknown> | undefined): {
|
|
14
|
+
key: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/utils/search.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return String(e ?? "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[_-]+/g, " ").toLowerCase().replace(/\s+/g, " ").trim();
|
|
4
|
+
}
|
|
5
|
+
function t(e) {
|
|
6
|
+
return e.split(/\s+/).filter(Boolean).map((e) => e[0]).join("");
|
|
7
|
+
}
|
|
8
|
+
function n(e, n) {
|
|
9
|
+
if (!e) return !0;
|
|
10
|
+
let r = e.replace(/\s+/g, ""), i = n.replace(/\s+/g, "");
|
|
11
|
+
return /\d/.test(r) ? n.includes(r) || i.includes(r) : n.includes(r) || i.includes(r) || t(n).includes(r);
|
|
12
|
+
}
|
|
13
|
+
function r(e, t) {
|
|
14
|
+
return t.split(/\s+/).filter(Boolean).every((t) => n(t, e));
|
|
15
|
+
}
|
|
16
|
+
function i(e) {
|
|
17
|
+
return e ? Object.entries(e).filter(([, e]) => e != null && e !== "").map(([e, t]) => ({
|
|
18
|
+
key: e,
|
|
19
|
+
value: String(t)
|
|
20
|
+
})) : [];
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { i as getMetaEntries, e as normalizeSearchText, r as searchQueryMatches };
|