@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.
Files changed (210) hide show
  1. package/README.md +300 -171
  2. package/dist/_virtual/_plugin-vue_export-helper.js +8 -0
  3. package/dist/bing-ui.css +1 -1
  4. package/dist/components/BingAnimatedText/BingAnimatedText.js +7 -0
  5. package/dist/components/BingAnimatedText/BingAnimatedText.vue_vue_type_script_setup_true_lang.js +194 -0
  6. package/dist/components/BingAppSwitcherTransition/BingAppSwitcherTransition.js +7 -0
  7. package/dist/components/BingAppSwitcherTransition/BingAppSwitcherTransition.vue_vue_type_script_setup_true_lang.js +244 -0
  8. package/dist/components/BingAutocomplete/BingAutocomplete.js +7 -0
  9. package/dist/components/BingAutocomplete/BingAutocomplete.vue.d.ts +4 -4
  10. package/dist/components/BingAutocomplete/BingAutocomplete.vue_vue_type_script_setup_true_lang.js +560 -0
  11. package/dist/components/BingButton/BingButton.js +7 -0
  12. package/dist/components/BingButton/BingButton.vue.d.ts +2 -2
  13. package/dist/components/BingButton/BingButton.vue_vue_type_script_setup_true_lang.js +200 -0
  14. package/dist/components/BingCard/BingCard.js +7 -0
  15. package/dist/components/BingCard/BingCard.vue_vue_type_script_setup_true_lang.js +481 -0
  16. package/dist/components/BingCarouselTransition/BingCarouselTransition.js +7 -0
  17. package/dist/components/BingCarouselTransition/BingCarouselTransition.vue_vue_type_script_setup_true_lang.js +174 -0
  18. package/dist/components/BingCheckbox/BingCheckbox.js +7 -0
  19. package/dist/components/BingCheckbox/BingCheckbox.vue.d.ts +4 -4
  20. package/dist/components/BingCheckbox/BingCheckbox.vue_vue_type_script_setup_true_lang.js +233 -0
  21. package/dist/components/BingCheckboxGroup/BingCheckboxGroup.context.js +4 -0
  22. package/dist/components/BingCheckboxGroup/BingCheckboxGroup.js +7 -0
  23. package/dist/components/BingCheckboxGroup/BingCheckboxGroup.vue.d.ts +4 -4
  24. package/dist/components/BingCheckboxGroup/BingCheckboxGroup.vue_vue_type_script_setup_true_lang.js +105 -0
  25. package/dist/components/BingCodeBlock/BingCodeBlock.highlight.js +78 -0
  26. package/dist/components/BingCodeBlock/BingCodeBlock.js +7 -0
  27. package/dist/components/BingCodeBlock/BingCodeBlock.vue_vue_type_script_setup_true_lang.js +347 -0
  28. package/dist/components/BingColorPicker/BingColorPicker.js +7 -0
  29. package/dist/components/BingColorPicker/BingColorPicker.utils.d.ts +70 -0
  30. package/dist/components/BingColorPicker/BingColorPicker.utils.js +265 -0
  31. package/dist/components/BingColorPicker/BingColorPicker.vue.d.ts +7 -7
  32. package/dist/components/BingColorPicker/BingColorPicker.vue_vue_type_script_setup_true_lang.js +540 -0
  33. package/dist/components/BingColorPicker/BingColorPickerFormatEditor.js +7 -0
  34. package/dist/components/BingColorPicker/BingColorPickerFormatEditor.vue.d.ts +27 -0
  35. package/dist/components/BingColorPicker/BingColorPickerFormatEditor.vue_vue_type_script_setup_true_lang.js +142 -0
  36. package/dist/components/BingColorPicker/BingColorPickerSpectrum.js +7 -0
  37. package/dist/components/BingColorPicker/BingColorPickerSpectrum.vue.d.ts +26 -0
  38. package/dist/components/BingColorPicker/BingColorPickerSpectrum.vue_vue_type_script_setup_true_lang.js +168 -0
  39. package/dist/components/BingConfigProvider/BingConfigProvider.js +5 -0
  40. package/dist/components/BingConfigProvider/BingConfigProvider.types.d.ts +5 -0
  41. package/dist/components/BingConfigProvider/BingConfigProvider.vue.d.ts +18 -0
  42. package/dist/components/BingConfigProvider/BingConfigProvider.vue_vue_type_script_setup_true_lang.js +18 -0
  43. package/dist/components/BingConfigProvider/index.d.ts +3 -0
  44. package/dist/components/BingCursor/BingCursor.controller.js +240 -0
  45. package/dist/components/BingCursor/BingCursor.js +7 -0
  46. package/dist/components/BingCursor/BingCursor.native.js +20 -0
  47. package/dist/components/BingCursor/BingCursor.presets.js +60 -0
  48. package/dist/components/BingCursor/BingCursor.shapes.js +83 -0
  49. package/dist/components/BingCursor/BingCursor.styleSource.js +83 -0
  50. package/dist/components/BingCursor/BingCursor.vue_vue_type_script_setup_true_lang.js +73 -0
  51. package/dist/components/BingDatePicker/BingDatePicker.js +7 -0
  52. package/dist/components/BingDatePicker/BingDatePicker.utils.d.ts +26 -0
  53. package/dist/components/BingDatePicker/BingDatePicker.utils.js +137 -0
  54. package/dist/components/BingDatePicker/BingDatePicker.vue.d.ts +14 -14
  55. package/dist/components/BingDatePicker/BingDatePicker.vue_vue_type_script_setup_true_lang.js +804 -0
  56. package/dist/components/BingDatePicker/BingDatePickerCalendar.js +7 -0
  57. package/dist/components/BingDatePicker/BingDatePickerCalendar.vue.d.ts +37 -0
  58. package/dist/components/BingDatePicker/BingDatePickerCalendar.vue_vue_type_script_setup_true_lang.js +248 -0
  59. package/dist/components/BingDatePicker/BingDatePickerTimePanel.js +7 -0
  60. package/dist/components/BingDatePicker/BingDatePickerTimePanel.vue.d.ts +26 -0
  61. package/dist/components/BingDatePicker/BingDatePickerTimePanel.vue_vue_type_script_setup_true_lang.js +97 -0
  62. package/dist/components/BingDeckTransition/BingDeckTransition.js +7 -0
  63. package/dist/components/BingDeckTransition/BingDeckTransition.vue_vue_type_script_setup_true_lang.js +187 -0
  64. package/dist/components/BingDialog/BingDialog.js +7 -0
  65. package/dist/components/BingDialog/BingDialog.vue.d.ts +4 -5
  66. package/dist/components/BingDialog/BingDialog.vue_vue_type_script_setup_true_lang.js +558 -0
  67. package/dist/components/BingDropDown/BingDropDown.context.js +4 -0
  68. package/dist/components/BingDropDown/BingDropDown.js +7 -0
  69. package/dist/components/BingDropDown/BingDropDown.vue.d.ts +1 -2
  70. package/dist/components/BingDropDown/BingDropDown.vue_vue_type_script_setup_true_lang.js +649 -0
  71. package/dist/components/BingDropDown/BingDropDownItem.js +7 -0
  72. package/dist/components/BingDropDown/BingDropDownItem.vue.d.ts +1 -1
  73. package/dist/components/BingDropDown/BingDropDownItem.vue_vue_type_script_setup_true_lang.js +308 -0
  74. package/dist/components/BingFilePreview/BingFilePreview.js +7 -0
  75. package/dist/components/BingFilePreview/BingFilePreview.vue.d.ts +4 -5
  76. package/dist/components/BingFilePreview/BingFilePreview.vue_vue_type_script_setup_true_lang.js +589 -0
  77. package/dist/components/BingForm/BingForm.context.js +7 -0
  78. package/dist/components/BingForm/BingForm.js +7 -0
  79. package/dist/components/BingForm/BingForm.vue.d.ts +0 -1
  80. package/dist/components/BingForm/BingForm.vue_vue_type_script_setup_true_lang.js +300 -0
  81. package/dist/components/BingForm/formFocus.js +13 -0
  82. package/dist/components/BingForm/formTabOrder.js +27 -0
  83. package/dist/components/BingForm/useFormControl.d.ts +1 -1
  84. package/dist/components/BingForm/useFormControl.js +24 -0
  85. package/dist/components/BingForm/useFormNextHint.js +135 -0
  86. package/dist/components/BingFormItem/BingFormItem.js +7 -0
  87. package/dist/components/BingFormItem/BingFormItem.vue.d.ts +1 -1
  88. package/dist/components/BingFormItem/BingFormItem.vue_vue_type_script_setup_true_lang.js +252 -0
  89. package/dist/components/BingIcon/BingIcon.js +7 -0
  90. package/dist/components/BingIcon/BingIcon.vue_vue_type_script_setup_true_lang.js +48 -0
  91. package/dist/components/BingImage/BingImage.js +7 -0
  92. package/dist/components/BingImage/BingImage.vue_vue_type_script_setup_true_lang.js +244 -0
  93. package/dist/components/BingImagePreview/BingImagePreview.js +7 -0
  94. package/dist/components/BingImagePreview/BingImagePreview.vue.d.ts +4 -5
  95. package/dist/components/BingImagePreview/BingImagePreview.vue_vue_type_script_setup_true_lang.js +699 -0
  96. package/dist/components/BingInput/BingInput.js +7 -0
  97. package/dist/components/BingInput/BingInput.vue.d.ts +6 -6
  98. package/dist/components/BingInput/BingInput.vue_vue_type_script_setup_true_lang.js +311 -0
  99. package/dist/components/BingRadio/BingRadio.js +7 -0
  100. package/dist/components/BingRadio/BingRadio.vue.d.ts +4 -4
  101. package/dist/components/BingRadio/BingRadio.vue_vue_type_script_setup_true_lang.js +170 -0
  102. package/dist/components/BingRadioGroup/BingRadioGroup.context.js +4 -0
  103. package/dist/components/BingRadioGroup/BingRadioGroup.js +7 -0
  104. package/dist/components/BingRadioGroup/BingRadioGroup.vue.d.ts +4 -4
  105. package/dist/components/BingRadioGroup/BingRadioGroup.vue_vue_type_script_setup_true_lang.js +125 -0
  106. package/dist/components/BingResizable/BingResizable.js +7 -0
  107. package/dist/components/BingResizable/BingResizable.vue.d.ts +1 -1
  108. package/dist/components/BingResizable/BingResizable.vue_vue_type_script_setup_true_lang.js +555 -0
  109. package/dist/components/BingScrollbar/BingScrollbar.js +7 -0
  110. package/dist/components/BingScrollbar/BingScrollbar.vue.d.ts +2 -2
  111. package/dist/components/BingScrollbar/BingScrollbar.vue_vue_type_script_setup_true_lang.js +398 -0
  112. package/dist/components/BingSelect/BingSelect.js +7 -0
  113. package/dist/components/BingSelect/BingSelect.vue.d.ts +7 -7
  114. package/dist/components/BingSelect/BingSelect.vue_vue_type_script_setup_true_lang.js +1066 -0
  115. package/dist/components/BingSlider/BingSlider.js +7 -0
  116. package/dist/components/BingSlider/BingSlider.vue.d.ts +6 -6
  117. package/dist/components/BingSlider/BingSlider.vue_vue_type_script_setup_true_lang.js +130 -0
  118. package/dist/components/BingSortableList/BingSortableList.js +7 -0
  119. package/dist/components/BingSortableList/BingSortableList.vue_vue_type_script_setup_true_lang.js +334 -0
  120. package/dist/components/BingSortableList/BingSortableListItem.js +7 -0
  121. package/dist/components/BingSortableList/BingSortableListItem.vue_vue_type_script_setup_true_lang.js +76 -0
  122. package/dist/components/BingSplitPane/BingSplitPane.js +7 -0
  123. package/dist/components/BingSplitPane/BingSplitPane.vue_vue_type_script_setup_true_lang.js +167 -0
  124. package/dist/components/BingTable/BingTable.js +7 -0
  125. package/dist/components/BingTable/BingTable.measurements.js +72 -0
  126. package/dist/components/BingTable/BingTable.vue.d.ts +1 -2
  127. package/dist/components/BingTable/BingTable.vue_vue_type_script_setup_true_lang.js +1416 -0
  128. package/dist/components/BingTable/BingTableCellValue.js +7 -0
  129. package/dist/components/BingTable/BingTableCellValue.vue_vue_type_script_setup_true_lang.js +68 -0
  130. package/dist/components/BingTable/BingTableHeaderCell.js +5 -0
  131. package/dist/components/BingTable/BingTableHeaderCell.vue_vue_type_script_setup_true_lang.js +45 -0
  132. package/dist/components/BingTable/BingTableHeaderContent.js +7 -0
  133. package/dist/components/BingTable/BingTableHeaderContent.vue_vue_type_script_setup_true_lang.js +110 -0
  134. package/dist/components/BingTable/useTableColumns.js +126 -0
  135. package/dist/components/BingTableColumnControls/BingTableColumnControls.js +7 -0
  136. package/dist/components/BingTableColumnControls/BingTableColumnControls.vue.d.ts +1 -1
  137. package/dist/components/BingTableColumnControls/BingTableColumnControls.vue_vue_type_script_setup_true_lang.js +251 -0
  138. package/dist/components/BingTabs/BingTabs.js +7 -0
  139. package/dist/components/BingTabs/BingTabs.vue.d.ts +2 -3
  140. package/dist/components/BingTabs/BingTabs.vue_vue_type_script_setup_true_lang.js +320 -0
  141. package/dist/components/BingTag/BingTag.js +7 -0
  142. package/dist/components/BingTag/BingTag.vue.d.ts +0 -1
  143. package/dist/components/BingTag/BingTag.vue_vue_type_script_setup_true_lang.js +65 -0
  144. package/dist/components/BingTextarea/BingTextarea.js +7 -0
  145. package/dist/components/BingTextarea/BingTextarea.vue.d.ts +6 -6
  146. package/dist/components/BingTextarea/BingTextarea.vue_vue_type_script_setup_true_lang.js +243 -0
  147. package/dist/components/BingToast/BingToast.js +7 -0
  148. package/dist/components/BingToast/BingToast.service.js +132 -0
  149. package/dist/components/BingToast/BingToast.types.d.ts +1 -1
  150. package/dist/components/BingToast/BingToast.types.js +19 -0
  151. package/dist/components/BingToast/BingToast.vue.d.ts +0 -1
  152. package/dist/components/BingToast/BingToast.vue_vue_type_script_setup_true_lang.js +307 -0
  153. package/dist/components/BingTooltip/BingTooltip.js +7 -0
  154. package/dist/components/BingTooltip/BingTooltip.shared.js +14 -0
  155. package/dist/components/BingTooltip/BingTooltip.vue.d.ts +4 -5
  156. package/dist/components/BingTooltip/BingTooltip.vue_vue_type_script_setup_true_lang.js +572 -0
  157. package/dist/components/BingTreeSelect/BingTreeSelect.js +7 -0
  158. package/dist/components/BingTreeSelect/BingTreeSelect.vue.d.ts +7 -7
  159. package/dist/components/BingTreeSelect/BingTreeSelect.vue_vue_type_script_setup_true_lang.js +1274 -0
  160. package/dist/components/index.d.ts +1 -0
  161. package/dist/icons/LICENSE-lucide.txt +39 -0
  162. package/dist/icons/createIcon.d.ts +8 -0
  163. package/dist/icons/createIcon.js +36 -0
  164. package/dist/icons/icons.d.ts +51 -0
  165. package/dist/icons/icons.js +252 -0
  166. package/dist/icons/index.d.ts +3 -0
  167. package/dist/index.js +48 -0
  168. package/dist/motion/clickParticles.d.ts +1 -1
  169. package/dist/motion/clickParticles2.js +66 -0
  170. package/dist/motion/index.d.ts +1 -1
  171. package/dist/motion/index.js +17 -0
  172. package/dist/motion/liquidHover.js +36 -0
  173. package/dist/motion/optionDetailMotion.d.ts +7 -1
  174. package/dist/motion/optionDetailMotion.js +74 -0
  175. package/dist/motion/panelMotion.js +19 -0
  176. package/dist/motion/reducedMotion.d.ts +16 -0
  177. package/dist/motion/reducedMotion.js +28 -0
  178. package/dist/motion/selectPanelMotion.js +115 -0
  179. package/dist/motion/smoothScroll.d.ts +2 -0
  180. package/dist/motion/smoothScroll.js +276 -0
  181. package/dist/motion/useClickFeedback.js +47 -0
  182. package/dist/motion/useTextControlCaret.js +136 -0
  183. package/dist/utils/clipboard.d.ts +9 -0
  184. package/dist/utils/clipboard.js +16 -0
  185. package/dist/utils/config.d.ts +42 -0
  186. package/dist/utils/config.js +37 -0
  187. package/dist/utils/controlAttrs.js +37 -0
  188. package/dist/utils/floating.d.ts +86 -0
  189. package/dist/utils/floating.js +99 -0
  190. package/dist/utils/glass.js +25 -0
  191. package/dist/utils/overlay.js +94 -0
  192. package/dist/utils/scrollLock.js +44 -0
  193. package/dist/utils/search.d.ts +16 -0
  194. package/dist/utils/search.js +23 -0
  195. package/dist/utils/useClientReady.js +10 -0
  196. package/dist/utils/useDeferredBlurValidation.d.ts +18 -0
  197. package/dist/utils/useDeferredBlurValidation.js +34 -0
  198. package/dist/utils/useKeyboardScrollSync.d.ts +11 -0
  199. package/dist/utils/useKeyboardScrollSync.js +28 -0
  200. package/dist/utils/useOptionDetailPanel.d.ts +50 -0
  201. package/dist/utils/useOptionDetailPanel.js +180 -0
  202. package/dist/utils/useOutsidePointerDown.d.ts +8 -0
  203. package/dist/utils/useOutsidePointerDown.js +17 -0
  204. package/dist/utils/useSearchShortcutFocus.d.ts +18 -0
  205. package/dist/utils/useSearchShortcutFocus.js +47 -0
  206. package/dist/utils/useVirtualList.d.ts +42 -0
  207. package/dist/utils/useVirtualList.js +74 -0
  208. package/package.json +15 -9
  209. package/dist/bing-ui.es.js +0 -31278
  210. package/dist/bing-ui.umd.js +0 -229
@@ -0,0 +1,10 @@
1
+ import { onMounted as e, ref as t } from "vue";
2
+ //#region src/utils/useClientReady.ts
3
+ function n() {
4
+ let n = t(!1);
5
+ return e(() => {
6
+ n.value = !0;
7
+ }), n;
8
+ }
9
+ //#endregion
10
+ export { n as useClientReady };
@@ -0,0 +1,18 @@
1
+ export interface UseDeferredBlurValidationOptions {
2
+ /** 所在表单项;不在表单中时为空,此时不做任何事。 */
3
+ formItem: {
4
+ handleControlBlur: () => void;
5
+ } | null | undefined;
6
+ isOpen: () => boolean;
7
+ /** 焦点仍在组件自身(触发器、浮层、工具栏等)时不算失焦。 */
8
+ isInteractionTarget: (target: EventTarget | null) => boolean;
9
+ }
10
+ /**
11
+ * 弹出类表单控件的失焦校验:焦点可能只是从触发器移到浮层里,
12
+ * 所以等下一帧确认焦点确实离开组件且浮层已关闭后,再通知表单项校验。
13
+ */
14
+ export declare function useDeferredBlurValidation({ formItem, isOpen, isInteractionTarget, }: UseDeferredBlurValidationOptions): {
15
+ schedule: () => void;
16
+ cancel: () => void;
17
+ handleBlur: (event: FocusEvent) => void;
18
+ };
@@ -0,0 +1,34 @@
1
+ import { getCurrentInstance as e, nextTick as t, onBeforeUnmount as n } from "vue";
2
+ //#region src/utils/useDeferredBlurValidation.ts
3
+ function r({ formItem: r, isOpen: i, isInteractionTarget: a }) {
4
+ let o = 0, s = 0;
5
+ function c() {
6
+ !s || typeof window > "u" || (window.cancelAnimationFrame(s), s = 0);
7
+ }
8
+ function l() {
9
+ o += 1, c();
10
+ }
11
+ function u() {
12
+ if (!r) return;
13
+ if (typeof window > "u" || typeof document > "u") {
14
+ r.handleControlBlur();
15
+ return;
16
+ }
17
+ let e = ++o;
18
+ t(() => {
19
+ e === o && (c(), s = window.requestAnimationFrame(() => {
20
+ s = 0, !(e !== o || i() || a(document.activeElement)) && r.handleControlBlur();
21
+ }));
22
+ });
23
+ }
24
+ function d(e) {
25
+ a(e.relatedTarget) || u();
26
+ }
27
+ return e() && n(l), {
28
+ schedule: u,
29
+ cancel: l,
30
+ handleBlur: d
31
+ };
32
+ }
33
+ //#endregion
34
+ export { r as useDeferredBlurValidation };
@@ -0,0 +1,11 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * 键盘导航触发列表滚动期间的标记。滚动事件持续到来时不断顺延,
4
+ * 停止 120ms 后自动结束,组件可据此在滚动中暂停悬停效果。
5
+ */
6
+ export declare function useKeyboardScrollSync(isKeyboardNavigating: Ref<boolean>): {
7
+ isSyncing: Ref<boolean, boolean>;
8
+ start: () => void;
9
+ scheduleEnd: () => void;
10
+ finish: () => void;
11
+ };
@@ -0,0 +1,28 @@
1
+ import { getCurrentInstance as e, onBeforeUnmount as t, ref as n } from "vue";
2
+ //#region src/utils/useKeyboardScrollSync.ts
3
+ var r = 120;
4
+ function i(i) {
5
+ let a = n(!1), o;
6
+ function s() {
7
+ o === void 0 || typeof window > "u" || (window.clearTimeout(o), o = void 0);
8
+ }
9
+ function c() {
10
+ a.value = !1, s();
11
+ }
12
+ function l() {
13
+ typeof window > "u" || !a.value || (s(), o = window.setTimeout(() => {
14
+ o = void 0, a.value = !1;
15
+ }, r));
16
+ }
17
+ function u() {
18
+ typeof window > "u" || !i.value || (a.value = !0, l());
19
+ }
20
+ return e() && t(c), {
21
+ isSyncing: a,
22
+ start: u,
23
+ scheduleEnd: l,
24
+ finish: c
25
+ };
26
+ }
27
+ //#endregion
28
+ export { i as useKeyboardScrollSync };
@@ -0,0 +1,50 @@
1
+ import { Ref } from 'vue';
2
+ export interface OptionDetailItemState {
3
+ disabled?: boolean;
4
+ hasDetail: boolean;
5
+ }
6
+ export interface UseOptionDetailPanelOptions {
7
+ /** 选项列表所在的浮层面板,详情贴在它的左右两侧。 */
8
+ listPanel: Ref<HTMLElement | null>;
9
+ detailPanel: Ref<HTMLElement | null>;
10
+ detailContent: Ref<HTMLElement | null>;
11
+ /** 选项元素选择器,用于根据指针位置找回选项。 */
12
+ itemSelector: string;
13
+ /** 选项元素上记录序号的 `data-*` 属性名(camelCase)。 */
14
+ indexAttribute: string;
15
+ isOpen: () => boolean;
16
+ isKeyboardNavigating: Ref<boolean>;
17
+ /** 返回 `undefined` 表示该序号的选项已不存在。 */
18
+ getItemState: (index: number) => OptionDetailItemState | undefined;
19
+ getItemElement: (index: number) => HTMLElement | null;
20
+ /** 详情纵向对齐的参考元素,默认就是选项元素本身。 */
21
+ getItemSurface?: (element: HTMLElement) => HTMLElement;
22
+ /** 键盘导航时当前激活的序号,-1 表示没有。 */
23
+ getKeyboardIndex: () => number;
24
+ /** 滚动结束后根据指针位置找回选项时调用,用于同步激活态。 */
25
+ onPointerRestore?: (index: number) => void;
26
+ hiddenScale?: number;
27
+ enterEase?: string;
28
+ force3D?: boolean;
29
+ }
30
+ /**
31
+ * Select 与 TreeSelect 的选项详情浮层:悬停或键盘激活时显示,跟随选项移动,
32
+ * 滚动期间先隐藏、停止后按指针位置恢复。
33
+ */
34
+ export declare function useOptionDetailPanel(options: UseOptionDetailPanelOptions): {
35
+ index: Ref<number, number>;
36
+ shouldRender: Ref<boolean, boolean>;
37
+ placement: Ref<"left" | "right", "left" | "right">;
38
+ show: (itemElement: HTMLElement, itemIndex: number) => void;
39
+ showIfAvailable: (itemElement: HTMLElement | null, itemIndex: number) => void;
40
+ hide: (immediate?: boolean) => void;
41
+ scheduleHide: (itemIndex?: number) => void;
42
+ cancelHide: () => void;
43
+ rememberPointer: (event: MouseEvent | PointerEvent | WheelEvent) => void;
44
+ handleListScroll: () => void;
45
+ showForKeyboard: () => void;
46
+ scheduleKeyboardShow: () => void;
47
+ updatePosition: () => void;
48
+ dispose: () => void;
49
+ };
50
+ export type OptionDetailPanel = ReturnType<typeof useOptionDetailPanel>;
@@ -0,0 +1,180 @@
1
+ import { useReducedMotion as e } from "../motion/reducedMotion.js";
2
+ import { getOptionDetailSnapshot as t, moveOptionDetailPanel as n } from "../motion/optionDetailMotion.js";
3
+ import { computeFloatingPosition as r, snapToDevicePixel as i } from "./floating.js";
4
+ import { getCurrentInstance as a, nextTick as o, onBeforeUnmount as s, ref as c } from "vue";
5
+ import { gsap as l } from "gsap";
6
+ //#region src/utils/useOptionDetailPanel.ts
7
+ var u = 12, d = 12, f = 120, p = 150;
8
+ function m() {
9
+ return typeof window < "u" && typeof document < "u";
10
+ }
11
+ function h(h) {
12
+ let g = e(), { listPanel: _, detailPanel: v, detailContent: y, isKeyboardNavigating: b, getItemState: x, getItemElement: S, getItemSurface: C = (e) => e, hiddenScale: w = .96 } = h, T = c(-1), E = c(!1), D = c("right"), O = 0, k, A, j = 0, M, N;
13
+ function P() {
14
+ !m() || !O || (window.cancelAnimationFrame(O), O = 0);
15
+ }
16
+ function F() {
17
+ !m() || k === void 0 || (window.clearTimeout(k), k = void 0);
18
+ }
19
+ function I() {
20
+ !m() || A === void 0 || (window.clearTimeout(A), A = void 0);
21
+ }
22
+ function L(e) {
23
+ let t = _.value, n = v.value;
24
+ if (!t || !n || !m()) return null;
25
+ let a = t.getBoundingClientRect(), o = C(e).getBoundingClientRect(), s = n.getBoundingClientRect(), c = r({
26
+ anchor: {
27
+ left: a.left,
28
+ right: a.right,
29
+ width: a.width,
30
+ top: o.top,
31
+ bottom: o.bottom,
32
+ height: o.height
33
+ },
34
+ floating: {
35
+ width: s.width || 236,
36
+ height: s.height || 132
37
+ },
38
+ side: "right",
39
+ align: "center",
40
+ gap: d,
41
+ padding: u
42
+ });
43
+ return {
44
+ placement: c.side,
45
+ x: i(c.left),
46
+ y: i(c.top)
47
+ };
48
+ }
49
+ function R(e, t = !1, r) {
50
+ if (!m()) return;
51
+ let i = n({
52
+ panel: v.value,
53
+ content: y.value,
54
+ getTarget: () => L(e),
55
+ animateContent: t,
56
+ previousSnapshot: r,
57
+ reducedMotion: g(),
58
+ hiddenScale: w,
59
+ enterEase: h.enterEase,
60
+ force3D: h.force3D
61
+ });
62
+ i && (D.value = i.placement);
63
+ }
64
+ function z(e, t = !1, n) {
65
+ !e || !m() || (P(), O = window.requestAnimationFrame(() => {
66
+ O = 0, R(e, t, n);
67
+ }));
68
+ }
69
+ function B(e, n) {
70
+ if (!x(n)?.hasDetail) return;
71
+ let r = T.value, i = r === n ? void 0 : t(v.value);
72
+ F(), T.value = n, E.value = !0, o(() => {
73
+ z(e, r !== n, i);
74
+ });
75
+ }
76
+ function V() {
77
+ E.value = !1, T.value = -1;
78
+ }
79
+ function H(e = !1) {
80
+ F(), P();
81
+ let t = v.value;
82
+ if (!t) {
83
+ V();
84
+ return;
85
+ }
86
+ if (l.killTweensOf([t, y.value].filter(Boolean)), e || g()) {
87
+ l.set(t, {
88
+ autoAlpha: 0,
89
+ scale: w,
90
+ clearProps: "width,height,overflow",
91
+ willChange: "auto"
92
+ }), V();
93
+ return;
94
+ }
95
+ l.to(t, {
96
+ autoAlpha: 0,
97
+ scale: w,
98
+ x: `+=${D.value === "right" ? -6 : 6}`,
99
+ duration: .14,
100
+ ease: "power2.out",
101
+ overwrite: !0,
102
+ onComplete: V
103
+ });
104
+ }
105
+ function U(e = T.value) {
106
+ !m() || e < 0 || e !== T.value || (F(), k = window.setTimeout(() => {
107
+ k = void 0, H();
108
+ }, f));
109
+ }
110
+ function W(e, t) {
111
+ let n = x(t);
112
+ if (!e || !n || n.disabled || !n.hasDetail) {
113
+ H(!0);
114
+ return;
115
+ }
116
+ B(e, t);
117
+ }
118
+ function G(e) {
119
+ !Number.isFinite(e.clientX) || !Number.isFinite(e.clientY) || (M = e.clientX, N = e.clientY);
120
+ }
121
+ function K() {
122
+ if (!m() || M === void 0 || N === void 0) return null;
123
+ let e = document.elementFromPoint(M, N)?.closest?.(h.itemSelector);
124
+ return !e || !_.value?.contains(e) ? null : e;
125
+ }
126
+ function q() {
127
+ if (b.value) return;
128
+ let e = K(), t = e?.dataset[h.indexAttribute], n = t === void 0 ? NaN : Number(t);
129
+ !e || !Number.isInteger(n) || !x(n) || (b.value = !1, h.onPointerRestore?.(n), W(e, n));
130
+ }
131
+ function J() {
132
+ H(!0), !(!m() || b.value) && (I(), A = window.setTimeout(() => {
133
+ A = void 0, !b.value && o(q);
134
+ }, p));
135
+ }
136
+ function Y() {
137
+ let e = h.isOpen() ? h.getKeyboardIndex() : -1;
138
+ W(e < 0 ? null : S(e), e);
139
+ }
140
+ function X() {
141
+ if (!m() || !h.isOpen()) return;
142
+ j += 1;
143
+ let e = j;
144
+ F(), I(), o(() => {
145
+ !m() || e !== j || window.requestAnimationFrame(() => {
146
+ e === j && Y();
147
+ });
148
+ });
149
+ }
150
+ function Z() {
151
+ if (!E.value || !x(T.value)?.hasDetail) return;
152
+ let e = S(T.value);
153
+ if (!e) {
154
+ H(!0);
155
+ return;
156
+ }
157
+ z(e);
158
+ }
159
+ function Q() {
160
+ P(), F(), I(), j += 1;
161
+ }
162
+ return a() && s(Q), {
163
+ index: T,
164
+ shouldRender: E,
165
+ placement: D,
166
+ show: B,
167
+ showIfAvailable: W,
168
+ hide: H,
169
+ scheduleHide: U,
170
+ cancelHide: F,
171
+ rememberPointer: G,
172
+ handleListScroll: J,
173
+ showForKeyboard: Y,
174
+ scheduleKeyboardShow: X,
175
+ updatePosition: Z,
176
+ dispose: Q
177
+ };
178
+ }
179
+ //#endregion
180
+ export { h as useOptionDetailPanel };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 在捕获阶段监听窗口的 `pointerdown`,用于浮层打开期间检测外部点击。
3
+ * 只在 `start` 和 `stop` 之间生效。
4
+ */
5
+ export declare function useOutsidePointerDown(handler: (event: PointerEvent) => void): {
6
+ start: () => void;
7
+ stop: () => void;
8
+ };
@@ -0,0 +1,17 @@
1
+ import { getCurrentInstance as e, onBeforeUnmount as t } from "vue";
2
+ //#region src/utils/useOutsidePointerDown.ts
3
+ function n(n) {
4
+ let r = !1;
5
+ function i() {
6
+ r || typeof window > "u" || (window.addEventListener("pointerdown", n, !0), r = !0);
7
+ }
8
+ function a() {
9
+ !r || typeof window > "u" || (window.removeEventListener("pointerdown", n, !0), r = !1);
10
+ }
11
+ return e() && t(a), {
12
+ start: i,
13
+ stop: a
14
+ };
15
+ }
16
+ //#endregion
17
+ export { n as useOutsidePointerDown };
@@ -0,0 +1,18 @@
1
+ import { Ref } from 'vue';
2
+ export interface UseSearchShortcutFocusOptions {
3
+ input: Ref<{
4
+ focus: () => void;
5
+ } | null>;
6
+ isOpen: () => boolean;
7
+ isSearchable: () => boolean;
8
+ }
9
+ /**
10
+ * 浮层内搜索框的聚焦:打开动画期间连续尝试几帧,确保焦点最终落在输入框上;
11
+ * 面板打开时在非输入区域按 `/` 也可以聚焦搜索框。
12
+ */
13
+ export declare function useSearchShortcutFocus({ input, isOpen, isSearchable }: UseSearchShortcutFocusOptions): {
14
+ focus: () => Promise<void>;
15
+ handleShortcut: (event: KeyboardEvent) => boolean;
16
+ start: () => void;
17
+ stop: () => void;
18
+ };
@@ -0,0 +1,47 @@
1
+ import { getCurrentInstance as e, nextTick as t, onBeforeUnmount as n } from "vue";
2
+ //#region src/utils/useSearchShortcutFocus.ts
3
+ function r(e) {
4
+ return typeof HTMLElement > "u" || !(e instanceof HTMLElement) ? !1 : e.isContentEditable || [
5
+ "INPUT",
6
+ "TEXTAREA",
7
+ "SELECT"
8
+ ].includes(e.tagName);
9
+ }
10
+ function i() {
11
+ return new Promise((e) => {
12
+ if (typeof window > "u" || typeof window.requestAnimationFrame != "function") {
13
+ e();
14
+ return;
15
+ }
16
+ window.requestAnimationFrame(() => e());
17
+ });
18
+ }
19
+ function a({ input: a, isOpen: o, isSearchable: s }) {
20
+ let c = !1;
21
+ function l() {
22
+ o() && s() && a.value?.focus();
23
+ }
24
+ async function u() {
25
+ s() && (await t(), l(), await i(), l(), await i(), l());
26
+ }
27
+ function d(e) {
28
+ return e.key !== "/" || e.altKey || e.ctrlKey || e.metaKey || !o() || !s() || r(e.target) ? !1 : (e.preventDefault(), u(), !0);
29
+ }
30
+ function f(e) {
31
+ d(e);
32
+ }
33
+ function p() {
34
+ c || typeof window > "u" || (window.addEventListener("keydown", f), c = !0);
35
+ }
36
+ function m() {
37
+ !c || typeof window > "u" || (window.removeEventListener("keydown", f), c = !1);
38
+ }
39
+ return e() && n(m), {
40
+ focus: u,
41
+ handleShortcut: d,
42
+ start: p,
43
+ stop: m
44
+ };
45
+ }
46
+ //#endregion
47
+ export { a as useSearchShortcutFocus };
@@ -0,0 +1,42 @@
1
+ import { CSSProperties, Ref } from 'vue';
2
+ import { BingScrollbarExpose } from '../components/BingScrollbar/BingScrollbar.types';
3
+ /** 虚拟列表上下各留出的内边距总和,和面板内容区的上下 padding 对应。 */
4
+ export declare const VIRTUAL_LIST_PADDING_Y = 18;
5
+ export interface UseVirtualListOptions {
6
+ /** 当前可见条目总数(已过滤)。 */
7
+ count: () => number;
8
+ /** `true` 强制开启,`false` 关闭,`'auto'` 超过阈值后开启。 */
9
+ mode: () => boolean | 'auto';
10
+ threshold: () => number;
11
+ /** 已归一化的固定行高。 */
12
+ itemHeight: () => number;
13
+ overscan: () => number;
14
+ scrollbar: Ref<BingScrollbarExpose | null>;
15
+ /** 面板滚动区域的计算高度,视口还没挂载时用它兜底。 */
16
+ fallbackViewportHeight: Ref<number>;
17
+ /** 写在面板内容区上的行高 CSS 变量名。 */
18
+ itemHeightVar: string;
19
+ }
20
+ /**
21
+ * 固定行高的虚拟列表窗口计算,配合 BingScrollbar 使用。
22
+ */
23
+ export declare function useVirtualList(options: UseVirtualListOptions): {
24
+ enabled: import('vue').ComputedRef<boolean>;
25
+ scrollTop: Ref<number, number>;
26
+ viewportHeight: Ref<number, number>;
27
+ totalHeight: import('vue').ComputedRef<number>;
28
+ startIndex: import('vue').ComputedRef<number>;
29
+ endIndex: import('vue').ComputedRef<number>;
30
+ bodyStyle: import('vue').ComputedRef<CSSProperties | undefined>;
31
+ stackStyle: import('vue').ComputedRef<CSSProperties | undefined>;
32
+ getContentHeight: () => number | undefined;
33
+ readViewport: (viewport: HTMLElement) => void;
34
+ sync: () => void;
35
+ refresh: () => void;
36
+ reset: () => void;
37
+ clampScroll: () => void;
38
+ scrollToIndex: (index: number, { offsetTop, beforeScroll }?: {
39
+ offsetTop?: number;
40
+ beforeScroll?: () => void;
41
+ }) => boolean;
42
+ };
@@ -0,0 +1,74 @@
1
+ import { clampToRange as e } from "./floating.js";
2
+ import { computed as t, nextTick as n, ref as r } from "vue";
3
+ function i(i) {
4
+ let { scrollbar: a, fallbackViewportHeight: o } = i, s = r(0), c = r(0), l = t(() => {
5
+ let e = i.mode(), t = i.count();
6
+ return e === !0 ? t > 0 : e === !1 ? !1 : t > i.threshold();
7
+ }), u = t(() => l.value ? i.count() * i.itemHeight() : 0), d = t(() => l.value ? e(Math.floor(s.value / i.itemHeight()) - i.overscan(), 0, i.count()) : 0), f = t(() => {
8
+ if (!l.value) return i.count();
9
+ let t = c.value || o.value || i.itemHeight();
10
+ return e(Math.ceil((s.value + t) / i.itemHeight()) + i.overscan(), d.value, i.count());
11
+ }), p = t(() => {
12
+ if (l.value) return {
13
+ height: `${u.value + 18}px`,
14
+ [i.itemHeightVar]: `${i.itemHeight()}px`
15
+ };
16
+ }), m = t(() => {
17
+ if (l.value) return { transform: `translate3d(0, ${d.value * i.itemHeight() + 18 / 2}px, 0)` };
18
+ });
19
+ function h() {
20
+ return l.value ? u.value + 18 : void 0;
21
+ }
22
+ function g(e) {
23
+ s.value = e.scrollTop, c.value = e.clientHeight || o.value;
24
+ }
25
+ function _() {
26
+ let e = a.value?.viewport;
27
+ if (!e) {
28
+ c.value = o.value;
29
+ return;
30
+ }
31
+ g(e);
32
+ }
33
+ function v() {
34
+ n(() => {
35
+ _(), a.value?.update();
36
+ });
37
+ }
38
+ function y() {
39
+ s.value = 0, a.value?.stop(), a.value?.scrollTo(0), c.value = a.value?.viewport?.clientHeight || o.value, a.value?.update();
40
+ }
41
+ function b() {
42
+ if (!l.value) {
43
+ s.value = 0;
44
+ return;
45
+ }
46
+ let e = c.value || o.value || i.itemHeight(), t = Math.max(0, u.value - e);
47
+ s.value <= t || (a.value?.scrollTo(t), s.value = t);
48
+ }
49
+ function x(e, { offsetTop: t = 18 / 2, beforeScroll: n } = {}) {
50
+ let r = a.value?.viewport;
51
+ if (!r || e < 0) return !1;
52
+ let s = i.itemHeight(), c = e * s + t, l = c + s, u = r.clientHeight || o.value, d = r.scrollTop, f = d;
53
+ return c < d ? f = c : l > d + u && (f = l - u), Math.abs(f - d) > .5 && (n?.(), a.value?.scrollTo(f)), _(), a.value?.update(), !0;
54
+ }
55
+ return {
56
+ enabled: l,
57
+ scrollTop: s,
58
+ viewportHeight: c,
59
+ totalHeight: u,
60
+ startIndex: d,
61
+ endIndex: f,
62
+ bodyStyle: p,
63
+ stackStyle: m,
64
+ getContentHeight: h,
65
+ readViewport: g,
66
+ sync: _,
67
+ refresh: v,
68
+ reset: y,
69
+ clampScroll: b,
70
+ scrollToIndex: x
71
+ };
72
+ }
73
+ //#endregion
74
+ export { i as useVirtualList };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@moubing/bing-ui",
3
- "version": "0.11.2",
3
+ "version": "0.12.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/"
8
8
  },
9
- "main": "./dist/bing-ui.umd.js",
10
- "module": "./dist/bing-ui.es.js",
9
+ "main": "./dist/index.js",
10
+ "module": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts",
12
12
  "files": [
13
13
  "dist"
@@ -19,16 +19,23 @@
19
19
  "exports": {
20
20
  ".": {
21
21
  "types": "./dist/index.d.ts",
22
- "import": "./dist/bing-ui.es.js"
22
+ "import": "./dist/index.js"
23
23
  },
24
24
  "./style.css": "./dist/bing-ui.css"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "gsap": "^3.15.0",
28
- "vue": "^3.5.0"
28
+ "vue": "^3.5.0",
29
+ "zod": "^4.0.0"
30
+ },
31
+ "peerDependenciesMeta": {
32
+ "zod": {
33
+ "optional": true
34
+ }
29
35
  },
30
36
  "devDependencies": {
31
37
  "@changesets/cli": "^2.31.0",
38
+ "@lucide/vue": "^1.61.0",
32
39
  "@playwright/test": "^1.60.0",
33
40
  "@storybook/addon-docs": "^10.4.1",
34
41
  "@storybook/vue3-vite": "^10.4.1",
@@ -48,15 +55,14 @@
48
55
  "vite-plugin-dts": "^5.0.1",
49
56
  "vitest": "^4.1.7",
50
57
  "vue": "^3.5.35",
51
- "vue-tsc": "^3.2.8"
58
+ "vue-tsc": "^3.2.8",
59
+ "zod": "^4.4.3"
52
60
  },
53
61
  "dependencies": {
54
62
  "@dnd-kit/dom": "^0.5.0",
55
63
  "@dnd-kit/vue": "^0.5.0",
56
64
  "dayjs": "^1.11.21",
57
- "lucide-vue-next": "^1.0.0",
58
- "shiki": "^4.2.0",
59
- "zod": "^4.4.3"
65
+ "shiki": "^4.2.0"
60
66
  },
61
67
  "scripts": {
62
68
  "dev": "vite",