sard 1.1.0 → 1.2.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.
Files changed (99) hide show
  1. package/README.md +1 -2
  2. package/all-components.js +2 -0
  3. package/components/action-sheet/action-sheet-item.vue.js +1 -1
  4. package/components/action-sheet/common.d.ts +1 -1
  5. package/components/button/button.vue.js +1 -1
  6. package/components/calendar-popout/common.d.ts +1 -1
  7. package/components/cascader-popout/common.d.ts +1 -1
  8. package/components/checkbox-popout/common.d.ts +1 -1
  9. package/components/color-picker-popout/common.d.ts +1 -1
  10. package/components/crop-image/common.d.ts +1 -1
  11. package/components/datetime-picker-popout/common.d.ts +1 -1
  12. package/components/datetime-range-picker-popout/common.d.ts +1 -1
  13. package/components/descriptions/common.d.ts +8 -3
  14. package/components/descriptions/descriptions-item.vue.d.ts +0 -2
  15. package/components/descriptions/descriptions-item.vue.js +20 -21
  16. package/components/descriptions/descriptions.vue.js +56 -28
  17. package/components/descriptions/index.css +1 -1
  18. package/components/dialog/common.d.ts +1 -1
  19. package/components/dnd/dnd-item.vue.js +19 -9
  20. package/components/dnd/index.css +1 -1
  21. package/components/dropdown/common.d.ts +1 -1
  22. package/components/ellipsis/ellipsis.vue.js +62 -58
  23. package/components/ellipsis/index.css +1 -1
  24. package/components/image/image.vue.d.ts +1 -1
  25. package/components/index.d.ts +1 -0
  26. package/components/index.js +2 -1
  27. package/components/keyboard/keyboard.vue.d.ts +1 -1
  28. package/components/keyboard-popout/common.d.ts +1 -1
  29. package/components/keyboard-popout/keyboard-popout.vue.d.ts +1 -1
  30. package/components/list/index.css +1 -1
  31. package/components/load-more/load-more.vue.js +2 -2
  32. package/components/loading/loading.vue.js +1 -1
  33. package/components/motion/motion.vue.js +1 -1
  34. package/components/notify/common.d.ts +1 -1
  35. package/components/overlay/overlay.vue.js +6 -5
  36. package/components/picker/picker.vue.js +8 -5
  37. package/components/picker-popout/common.d.ts +1 -1
  38. package/components/picker-view/common.d.ts +22 -2
  39. package/components/picker-view/index.d.ts +2 -2
  40. package/components/picker-view/index.js +2 -2
  41. package/components/picker-view/picker-view-column.vue.d.ts +19 -0
  42. package/components/picker-view/picker-view-column.vue.js +167 -0
  43. package/components/picker-view/picker-view.vue.d.ts +55 -0
  44. package/components/picker-view/picker-view.vue.js +60 -0
  45. package/components/popout/common.d.ts +1 -1
  46. package/components/popout/popout.vue.js +2 -4
  47. package/components/popover/popover.vue.js +11 -10
  48. package/components/popup/popup.vue.js +1 -1
  49. package/components/preview-image/common.d.ts +1 -1
  50. package/components/preview-image/preview-image.vue.js +4 -4
  51. package/components/pull-down-refresh/pull-down-refresh.vue.js +4 -7
  52. package/components/radio-popout/common.d.ts +1 -1
  53. package/components/rate/rate.vue.js +2 -2
  54. package/components/select-popout/common.d.ts +1 -1
  55. package/components/share-sheet/common.d.ts +1 -1
  56. package/components/skeleton/skeleton.vue.js +1 -1
  57. package/components/swiper/index.d.ts +2 -2
  58. package/components/swiper/index.js +2 -2
  59. package/components/swiper/swiper-item.vue.d.ts +11 -0
  60. package/components/swiper/swiper-item.vue.js +32 -0
  61. package/components/swiper/swiper.vue.d.ts +147 -0
  62. package/components/swiper/swiper.vue.js +51 -0
  63. package/components/swiper/useSwiper.d.ts +1 -2
  64. package/components/swiper/useSwiper.js +12 -12
  65. package/components/table/table.vue.js +1 -2
  66. package/components/text-shrink/common.d.ts +28 -0
  67. package/components/text-shrink/common.js +8 -0
  68. package/components/text-shrink/index.css +1 -0
  69. package/components/text-shrink/index.d.ts +5 -0
  70. package/components/text-shrink/index.js +6 -0
  71. package/components/text-shrink/text-shrink.vue.d.ts +16 -0
  72. package/components/text-shrink/text-shrink.vue.js +252 -0
  73. package/components/toast/common.d.ts +1 -1
  74. package/global.d.ts +1 -0
  75. package/index.css +1 -1
  76. package/index.js +2 -2
  77. package/package.json +1 -1
  78. package/utils/createImperativeComponent.d.ts +12 -5
  79. package/utils/createImperativeComponent.js +13 -37
  80. package/utils/imperative/agent-runtime.d.ts +28 -0
  81. package/utils/imperative/agent-runtime.js +33 -0
  82. package/utils/imperative/imperative-agent.vue.d.ts +35 -0
  83. package/utils/imperative/imperative-agent.vue.js +60 -0
  84. package/utils/index.d.ts +0 -1
  85. package/utils/index.js +1 -2
  86. package/utils/is.d.ts +4 -1
  87. package/utils/is.js +5 -3
  88. package/utils/number.d.ts +1 -1
  89. package/utils/number.js +20 -19
  90. package/components/picker-view/picker-view-column.d.ts +0 -3
  91. package/components/picker-view/picker-view-column.js +0 -139
  92. package/components/picker-view/picker-view.d.ts +0 -21
  93. package/components/picker-view/picker-view.js +0 -57
  94. package/components/swiper/swiper-item.d.ts +0 -3
  95. package/components/swiper/swiper-item.js +0 -34
  96. package/components/swiper/swiper.d.ts +0 -57
  97. package/components/swiper/swiper.js +0 -43
  98. package/utils/vnode.d.ts +0 -9
  99. package/utils/vnode.js +0 -69
package/index.js CHANGED
@@ -18,7 +18,6 @@ import { defaultColorPickerPresets, defaultColorPickerValue, formatColor, getPre
18
18
  import { BarcodeFormatList, BarcodeTextPositionList, barcode, calculateBarcodeLayout, normalizeBarcodeOptions } from "./utils/barcode.js";
19
19
  import { measureTextWidth } from "./utils/canvas.js";
20
20
  import { clipboard } from "./utils/clipboard.js";
21
- import { OnlyChild, flatVNode } from "./utils/vnode.js";
22
21
  import { defineSetupFnComponent, enhanceComponent } from "./utils/component.js";
23
22
  import { Friction } from "./utils/scroller/Friction.js";
24
23
  import { Spring } from "./utils/scroller/Spring.js";
@@ -195,6 +194,7 @@ import { Table } from "./components/table/index.js";
195
194
  import { Tab, Tabs } from "./components/tabs/index.js";
196
195
  import { Tag } from "./components/tag/index.js";
197
196
  import { Text } from "./components/text/index.js";
197
+ import { TextShrink } from "./components/text-shrink/index.js";
198
198
  import { Timeline, TimelineItem } from "./components/timeline/index.js";
199
199
  import { createToast, toast } from "./components/toast/imperative.js";
200
200
  import { Toast } from "./components/toast/index.js";
@@ -217,4 +217,4 @@ function prepareEnvironment() {
217
217
  });
218
218
  }
219
219
  //#endregion
220
- export { ADD_SWIPER_CONTEXT_KEY, ALPHANUMERIC_CHARS, Accordion, AccordionItem, ActionSheet, ActionSheetItem, Alert, Avatar, AvatarGroup, BackTop, Badge, Barcode, BarcodeFormatList, BarcodeTextPositionList, Button, Calendar, CalendarInput, CalendarPopout, CancelError, Card, Cascader, CascaderInput, CascaderPopout, Checkbox, CheckboxGroup, CheckboxInput, CheckboxPopout, Col, Collapse, ColorPicker, ColorPickerInput, ColorPickerPopout, Compact, CoolIcon, CountDown, CountTo, CropImage, Danmaku, DateStrip, DatetimePicker, DatetimePickerInput, DatetimePickerPopout, DatetimeRangePicker, DatetimeRangePickerInput, DatetimeRangePickerPopout, Descriptions, DescriptionsItem, Dialog, Divider, Dnd, DndHandle, DndItem, Dropdown, DropdownItem, ECLList, Ellipsis, Empty, Fab, FabItem, Flex, FloatingBubble, FloatingPanel, Form, FormItem, FormItemPlain, FormPlain, Friction, Grid, GridItem, Image, Indexes, IndexesAnchor, IndexesNav, Input, Keyboard, KeyboardPopout, List, ListItem, LoadMore, LoadMoreStatus, Loading, Marquee, Menu, MenuItem, Motion, Navbar, NavbarItem, NavbarPit, NoticeBar, Notify, OnlyChild, Overlay, Pagination, PasswordInput, Picker, PickerInput, PickerPopout, PickerView, PickerViewColumn, Popout, PopoutInput, Popover, Popup, PreviewImage, ProgressBar, ProgressCircle, PullDownRefresh, PuzzleVerify, Qrcode, REMOVE_SWIPER_CONTEXT_KEY, Radio, RadioGroup, RadioInput, RadioPopout, Rate, ReadMore, Result, RotateVerify, Row, SWIPER_AUTO_HEIGHT_KEY, ScrollList, ScrollSpy, ScrollSpyAnchor, Search, Segmented, SegmentedItem, Select, SelectInput, SelectOption, SelectOptionGroup, SelectPopout, ShareSheet, ShareSheetIcon, ShareSheetItem, ShareSheetRow, Sidebar, SidebarItem, Signature, Skeleton, SkeletonAvatar, SkeletonBlock, SkeletonParagraph, SkeletonTitle, SlideVerify, Slider, Spring, StatusBar, Step, Stepper, Steps, Sticky, StickyBox, SwipeAction, Swiper, SwiperItem, Switch, Tab, Tabbar, TabbarItem, TabbarPit, Table, Tabs, Tag, Text, Timeline, TimelineItem, Toast, Tree, TreeBranch, TreeNode, Upload, UploadPreview, Waterfall, WaterfallItem, WaterfallLoad, Watermark, actionSheet, addSeparator, addUnit, arrayEqual, arrayMove, assignDeep, autoUpdate, barcode, baseLunarYear, calculateBarcodeLayout, camelCase, capitalize, chainGet, chainSet, checkRtl, chooseFile, clamp, clipboard, compactNumber, computePosition, createActionSheet, createBem, createBemStruct, createCropImage, createDialog, createInertialAnimate, createNotify, createPreviewImage, createToast, cropImage, cssVar, cssVarName, currentLocale, debounce, deepClone, defaultBemConfig, defaultColorPickerPresets, defaultColorPickerValue, defaultOptionKeys, defineSetupFnComponent, dialog, earthlyBranches, enhanceComponent, extend, flatVNode, flexGap, formatColor, formatDate, formatNumber, formatThousands, formatTime, getAspectFillSize, getAspectFitSize, getCurrentTime, getDampingValue, getDayOfYear, getDaysAfterLastDay, getDaysBeforeFirstDay, getDaysInMonth, getDaysSinceUnixEpoch, getDecimalsLength, getFileName, getFirstDayWeekday, getGridCenterSize, getGridIndex, getGridPrizeCount, getInBoundValue, getLeafNodes, getLunarDayName, getLunarHourName, getLunarLeapMonth, getLunarLeapMonthDays, getLunarMonthDays, getLunarMonthName, getLunarYearDays, getLunarYearName, getNextMonthDate, getNextMonthHeadDays, getNodeLevel, getOverflowRangeInArea, getPageRange, getPrevMonthDate, getPrevMonthTailDays, getPreviewColor, getRectDampingValue, getRotatedRect, getScrollIntoViewValue, getScrollTop, getTouchPoint, getTransformOrigin, getTreeCheckedKeys, getTreeHalfCheckedKeys, getTwoPointsDistance, heavenlyStems, hslToHsv, hslToHwb, hslToRgb, hsvToHsl, hwbToHsl, imageDataToDataURL, inRange, initializeCheckNodes, installer, interpolate, isBoolean, isCancelError, isColorScheme, isConfigObject, isDate, isEmptyArray, isEmptyBinding, isEmptyValue, isFileUrl, isFunction, isImageFile, isImageUrl, isKorean, isLeapYear, isNoEmptyArray, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isRectEqual, isRenderVisible, isSizeEqual, isString, isUndefined, isVideoFile, isVideoUrl, isVisibleEmpty, kebabCase, loadImage, localeContextKey, logError, looseToNumber, lowerFirst, lunarDayNames, lunarInfo, lunarMonthNames, lunarToSolar, lunarYearNames, mapTreeToGrid, matchScrollVisible, measureTextWidth, minmaxDate, mround, nestedToMulti, noop, normalizeBarcodeOptions, normalizeHsla, normalizeHsva, notify, omit, omitFormPopoutProps, parseColor, parseDate, partition, partitionPopoutInputProps, pascalCase, pick, plateEnglishLetterKeys, plateProvinceKeys, plateSuffixKeys, popupManager, prepareEnvironment, previewImage, provideColorScheme, provideLocale, qrcode, random, reactiveComputed, readFileContent, rgbToHsl, round, safeAreaInsets, scrollToTarget, setCheckedRecursively, setLocale, shuffle, sleep, snakeCase, solarToLunar, splitUnit, spreadEach, springFestivals, throttle, toArray, toDate, toDateNumber, toDateString, toMonthNumber, toReactive, toTouchEvent, toast, treeToMap, truncToFixed, uniqid, updateAncestorsChecked, upperFirst, useClickOutside, useColorScheme, useComposition, useCountDown, useDragPinch, useElementBackTop, useElementScroll, useFormContext, useFormItem, useFormItemContext, useFormPopout, useInPopup, useIndeterminate, useInitialVelocity, useIntersectionObserver, useKeyList, useLocale, useLockScroll, useLuckyDraw, useLuckyGrid, useLuckyWheel, useMotioning, useOptionKeys, usePageBackTop, usePageScroll, usePointerDown, usePopoutInput, usePopper, usePopupEnter, usePopupVisibleHookProvide, useReachBottom, useResizeObserver, useRtl, useScrollSide, useScrollSpy, useScroller, useSimulatedClick, useSimulatedDblClick, useSimulatedPress, useSingleTask, useSlotMachine, useStopMovedClick, useTimeout, useTimeoutLoading, useTranslate, useTranslateWithPrefix, useWindowResize, useZIndex, walkAncestor, walkDescendant, walkNodes, windowInfo, withResolvers };
220
+ export { ADD_SWIPER_CONTEXT_KEY, ALPHANUMERIC_CHARS, Accordion, AccordionItem, ActionSheet, ActionSheetItem, Alert, Avatar, AvatarGroup, BackTop, Badge, Barcode, BarcodeFormatList, BarcodeTextPositionList, Button, Calendar, CalendarInput, CalendarPopout, CancelError, Card, Cascader, CascaderInput, CascaderPopout, Checkbox, CheckboxGroup, CheckboxInput, CheckboxPopout, Col, Collapse, ColorPicker, ColorPickerInput, ColorPickerPopout, Compact, CoolIcon, CountDown, CountTo, CropImage, Danmaku, DateStrip, DatetimePicker, DatetimePickerInput, DatetimePickerPopout, DatetimeRangePicker, DatetimeRangePickerInput, DatetimeRangePickerPopout, Descriptions, DescriptionsItem, Dialog, Divider, Dnd, DndHandle, DndItem, Dropdown, DropdownItem, ECLList, Ellipsis, Empty, Fab, FabItem, Flex, FloatingBubble, FloatingPanel, Form, FormItem, FormItemPlain, FormPlain, Friction, Grid, GridItem, Image, Indexes, IndexesAnchor, IndexesNav, Input, Keyboard, KeyboardPopout, List, ListItem, LoadMore, LoadMoreStatus, Loading, Marquee, Menu, MenuItem, Motion, Navbar, NavbarItem, NavbarPit, NoticeBar, Notify, Overlay, Pagination, PasswordInput, Picker, PickerInput, PickerPopout, PickerView, PickerViewColumn, Popout, PopoutInput, Popover, Popup, PreviewImage, ProgressBar, ProgressCircle, PullDownRefresh, PuzzleVerify, Qrcode, REMOVE_SWIPER_CONTEXT_KEY, Radio, RadioGroup, RadioInput, RadioPopout, Rate, ReadMore, Result, RotateVerify, Row, SWIPER_AUTO_HEIGHT_KEY, ScrollList, ScrollSpy, ScrollSpyAnchor, Search, Segmented, SegmentedItem, Select, SelectInput, SelectOption, SelectOptionGroup, SelectPopout, ShareSheet, ShareSheetIcon, ShareSheetItem, ShareSheetRow, Sidebar, SidebarItem, Signature, Skeleton, SkeletonAvatar, SkeletonBlock, SkeletonParagraph, SkeletonTitle, SlideVerify, Slider, Spring, StatusBar, Step, Stepper, Steps, Sticky, StickyBox, SwipeAction, Swiper, SwiperItem, Switch, Tab, Tabbar, TabbarItem, TabbarPit, Table, Tabs, Tag, Text, TextShrink, Timeline, TimelineItem, Toast, Tree, TreeBranch, TreeNode, Upload, UploadPreview, Waterfall, WaterfallItem, WaterfallLoad, Watermark, actionSheet, addSeparator, addUnit, arrayEqual, arrayMove, assignDeep, autoUpdate, barcode, baseLunarYear, calculateBarcodeLayout, camelCase, capitalize, chainGet, chainSet, checkRtl, chooseFile, clamp, clipboard, compactNumber, computePosition, createActionSheet, createBem, createBemStruct, createCropImage, createDialog, createInertialAnimate, createNotify, createPreviewImage, createToast, cropImage, cssVar, cssVarName, currentLocale, debounce, deepClone, defaultBemConfig, defaultColorPickerPresets, defaultColorPickerValue, defaultOptionKeys, defineSetupFnComponent, dialog, earthlyBranches, enhanceComponent, extend, flexGap, formatColor, formatDate, formatNumber, formatThousands, formatTime, getAspectFillSize, getAspectFitSize, getCurrentTime, getDampingValue, getDayOfYear, getDaysAfterLastDay, getDaysBeforeFirstDay, getDaysInMonth, getDaysSinceUnixEpoch, getDecimalsLength, getFileName, getFirstDayWeekday, getGridCenterSize, getGridIndex, getGridPrizeCount, getInBoundValue, getLeafNodes, getLunarDayName, getLunarHourName, getLunarLeapMonth, getLunarLeapMonthDays, getLunarMonthDays, getLunarMonthName, getLunarYearDays, getLunarYearName, getNextMonthDate, getNextMonthHeadDays, getNodeLevel, getOverflowRangeInArea, getPageRange, getPrevMonthDate, getPrevMonthTailDays, getPreviewColor, getRectDampingValue, getRotatedRect, getScrollIntoViewValue, getScrollTop, getTouchPoint, getTransformOrigin, getTreeCheckedKeys, getTreeHalfCheckedKeys, getTwoPointsDistance, heavenlyStems, hslToHsv, hslToHwb, hslToRgb, hsvToHsl, hwbToHsl, imageDataToDataURL, inRange, initializeCheckNodes, installer, interpolate, isBoolean, isCancelError, isColorScheme, isConfigObject, isDate, isEmptyArray, isEmptyBinding, isEmptyValue, isFileUrl, isFunction, isImageFile, isImageUrl, isKorean, isLeapYear, isNoEmptyArray, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isRectEqual, isRenderVisible, isSizeEqual, isString, isUndefined, isVideoFile, isVideoUrl, isVisibleEmpty, kebabCase, loadImage, localeContextKey, logError, looseToNumber, lowerFirst, lunarDayNames, lunarInfo, lunarMonthNames, lunarToSolar, lunarYearNames, mapTreeToGrid, matchScrollVisible, measureTextWidth, minmaxDate, mround, nestedToMulti, noop, normalizeBarcodeOptions, normalizeHsla, normalizeHsva, notify, omit, omitFormPopoutProps, parseColor, parseDate, partition, partitionPopoutInputProps, pascalCase, pick, plateEnglishLetterKeys, plateProvinceKeys, plateSuffixKeys, popupManager, prepareEnvironment, previewImage, provideColorScheme, provideLocale, qrcode, random, reactiveComputed, readFileContent, rgbToHsl, round, safeAreaInsets, scrollToTarget, setCheckedRecursively, setLocale, shuffle, sleep, snakeCase, solarToLunar, splitUnit, spreadEach, springFestivals, throttle, toArray, toDate, toDateNumber, toDateString, toMonthNumber, toReactive, toTouchEvent, toast, treeToMap, truncToFixed, uniqid, updateAncestorsChecked, upperFirst, useClickOutside, useColorScheme, useComposition, useCountDown, useDragPinch, useElementBackTop, useElementScroll, useFormContext, useFormItem, useFormItemContext, useFormPopout, useInPopup, useIndeterminate, useInitialVelocity, useIntersectionObserver, useKeyList, useLocale, useLockScroll, useLuckyDraw, useLuckyGrid, useLuckyWheel, useMotioning, useOptionKeys, usePageBackTop, usePageScroll, usePointerDown, usePopoutInput, usePopper, usePopupEnter, usePopupVisibleHookProvide, useReachBottom, useResizeObserver, useRtl, useScrollSide, useScrollSpy, useScroller, useSimulatedClick, useSimulatedDblClick, useSimulatedPress, useSingleTask, useSlotMachine, useStopMovedClick, useTimeout, useTimeoutLoading, useTranslate, useTranslateWithPrefix, useWindowResize, useZIndex, walkAncestor, walkDescendant, walkNodes, windowInfo, withResolvers };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sard",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "sard 是基于 Vue3 的 Web 移动端 UI 组件库",
5
5
  "keywords": [
6
6
  "UI",
@@ -1,10 +1,17 @@
1
- import { type Component } from 'vue';
1
+ import type { Component } from 'vue';
2
+ interface ImperativeExpose<T> {
3
+ show: (options?: T) => void;
4
+ hide: () => void;
5
+ }
2
6
  interface ImperativeConfig<Expose> {
3
7
  onShow?: (expose: Expose) => void;
4
8
  onHide?: (expose: Expose) => void;
5
9
  }
6
- export declare function createImperativeComponent<Options, Expose>(component: Component, defaultOptions?: Options, config?: ImperativeConfig<Expose>): {
7
- show: (options?: Options) => void;
8
- hide: () => void;
9
- };
10
+ /**
11
+ * 创建一个命令式组件:挂载到 body 上的独立容器里,通过 `show` / `hide` 控制。
12
+ *
13
+ * 具体渲染由 `./imperative/imperative-agent.vue` 负责,挂载方式(vdom / vapor)
14
+ * 由 `./imperative/agent-runtime` 隔离,因此这里不含任何 vdom 专有 API。
15
+ */
16
+ export declare function createImperativeComponent<Options, Expose>(component: Component, defaultOptions?: Options, config?: ImperativeConfig<Expose>): ImperativeExpose<Options>;
10
17
  export {};
@@ -1,44 +1,20 @@
1
- import { createApp, createVNode, defineComponent, ref } from "vue";
1
+ import imperative_agent_default from "./imperative/imperative-agent.vue.js";
2
+ import { mountAgent } from "./imperative/agent-runtime.js";
2
3
  //#region packages/sard/utils/createImperativeComponent.ts
3
- function createAgent(component, defaultOptions, config) {
4
- return defineComponent({ setup(_, { expose }) {
5
- const compRef = ref();
6
- const innerProps = ref({});
7
- const show = (options) => {
8
- innerProps.value = {
9
- ...defaultOptions,
10
- ...options,
11
- visible: true
12
- };
13
- config?.onShow?.(compRef.value);
14
- };
15
- const hide = () => {
16
- innerProps.value = {
17
- ...innerProps.value,
18
- visible: false
19
- };
20
- config?.onHide?.(compRef.value);
21
- };
22
- expose({
23
- show,
24
- hide
25
- });
26
- return () => {
27
- return createVNode(component, {
28
- ref: compRef,
29
- ...innerProps.value,
30
- "onUpdate:visible": (value) => {
31
- innerProps.value.visible = value;
32
- innerProps.value["onUpdate:visible"]?.(value);
33
- }
34
- });
35
- };
36
- } });
37
- }
4
+ /**
5
+ * 创建一个命令式组件:挂载到 body 上的独立容器里,通过 `show` / `hide` 控制。
6
+ *
7
+ * 具体渲染由 `./imperative/imperative-agent.vue` 负责,挂载方式(vdom / vapor)
8
+ * 由 `./imperative/agent-runtime` 隔离,因此这里不含任何 vdom 专有 API。
9
+ */
38
10
  function createImperativeComponent(component, defaultOptions, config) {
39
11
  const container = document.createElement("div");
40
12
  document.body.appendChild(container);
41
- const instance = createApp(createAgent(component, defaultOptions, config)).mount(container);
13
+ const instance = mountAgent(imperative_agent_default, container, {
14
+ component,
15
+ defaultOptions,
16
+ config
17
+ });
42
18
  function show(options) {
43
19
  instance.show(options);
44
20
  }
@@ -0,0 +1,28 @@
1
+ import { type Component } from 'vue';
2
+ /**
3
+ * 挂载命令式组件的 Agent,并返回它 expose 出来的对象(`{ show, hide }`)。
4
+ *
5
+ * 这里是整个命令式体系里**唯一**依赖 vdom 运行时的点。vapor 变体(P0-2 双产物
6
+ * 时新增 `./agent-runtime.vapor.ts`,由构建把 `./agent-runtime` 指过去)只需换
7
+ * 一行 import,函数体完全相同:
8
+ *
9
+ * ```ts
10
+ * import { createVaporApp } from '@vue/runtime-vapor'
11
+ *
12
+ * export const mountAgent = (Agent, container, rootProps) =>
13
+ * createVaporApp(Agent, rootProps).mount(container)
14
+ * ```
15
+ *
16
+ * 依据(已核对 vue 3.6 源码 + 官方测试):
17
+ * - `createVaporApp` 内部是 `createAppAPI(mountApp, unmountApp, getExposed)`,
18
+ * 所以 `mount()` 返回的同样是 expose 代理,与 vdom 一致
19
+ * (`runtime-vapor/__tests__/apiExpose.spec.ts` 的「with mount」用例:
20
+ * `app.mount(host).foo === 1`)。
21
+ * - 根 props 同样支持:`createVaporApp(Comp, { count: () => 1 })`
22
+ * (`apiCreateVaporApp.spec.ts` 的「mount with props」用例)。
23
+ *
24
+ * ⚠️ 唯一语义差异:vapor 把根 props 里的**函数值当作 getter**(动态 props)。
25
+ * 我们传的 `component` 若被传成「函数式组件」会被当成 getter —— 实际用法都是
26
+ * SFC / defineComponent 对象,不受影响,P0-2 时留意即可。
27
+ */
28
+ export declare function mountAgent(Agent: Component, container: HTMLElement, rootProps: Record<string, any>): any;
@@ -0,0 +1,33 @@
1
+ import { createApp } from "vue";
2
+ //#region packages/sard/utils/imperative/agent-runtime.ts
3
+ /**
4
+ * 挂载命令式组件的 Agent,并返回它 expose 出来的对象(`{ show, hide }`)。
5
+ *
6
+ * 这里是整个命令式体系里**唯一**依赖 vdom 运行时的点。vapor 变体(P0-2 双产物
7
+ * 时新增 `./agent-runtime.vapor.ts`,由构建把 `./agent-runtime` 指过去)只需换
8
+ * 一行 import,函数体完全相同:
9
+ *
10
+ * ```ts
11
+ * import { createVaporApp } from '@vue/runtime-vapor'
12
+ *
13
+ * export const mountAgent = (Agent, container, rootProps) =>
14
+ * createVaporApp(Agent, rootProps).mount(container)
15
+ * ```
16
+ *
17
+ * 依据(已核对 vue 3.6 源码 + 官方测试):
18
+ * - `createVaporApp` 内部是 `createAppAPI(mountApp, unmountApp, getExposed)`,
19
+ * 所以 `mount()` 返回的同样是 expose 代理,与 vdom 一致
20
+ * (`runtime-vapor/__tests__/apiExpose.spec.ts` 的「with mount」用例:
21
+ * `app.mount(host).foo === 1`)。
22
+ * - 根 props 同样支持:`createVaporApp(Comp, { count: () => 1 })`
23
+ * (`apiCreateVaporApp.spec.ts` 的「mount with props」用例)。
24
+ *
25
+ * ⚠️ 唯一语义差异:vapor 把根 props 里的**函数值当作 getter**(动态 props)。
26
+ * 我们传的 `component` 若被传成「函数式组件」会被当成 getter —— 实际用法都是
27
+ * SFC / defineComponent 对象,不受影响,P0-2 时留意即可。
28
+ */
29
+ function mountAgent(Agent, container, rootProps) {
30
+ return createApp(Agent, rootProps).mount(container);
31
+ }
32
+ //#endregion
33
+ export { mountAgent };
@@ -0,0 +1,35 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ component: {
3
+ type: null;
4
+ required: true;
5
+ };
6
+ defaultOptions: {
7
+ type: null;
8
+ default: undefined;
9
+ };
10
+ config: {
11
+ type: null;
12
+ default: undefined;
13
+ };
14
+ }>, {
15
+ show: (options?: Record<string, any>) => void;
16
+ hide: () => void;
17
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
18
+ component: {
19
+ type: null;
20
+ required: true;
21
+ };
22
+ defaultOptions: {
23
+ type: null;
24
+ default: undefined;
25
+ };
26
+ config: {
27
+ type: null;
28
+ default: undefined;
29
+ };
30
+ }>> & Readonly<{}>, {
31
+ defaultOptions: any;
32
+ config: any;
33
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
34
+ declare const _default: typeof __VLS_export;
35
+ export default _default;
@@ -0,0 +1,60 @@
1
+ import { computed, createBlock, defineComponent, mergeProps, openBlock, ref, resolveDynamicComponent, useTemplateRef } from "vue";
2
+ //#region packages/sard/utils/imperative/imperative-agent.vue
3
+ var imperative_agent_default = /*@__PURE__*/ defineComponent({
4
+ __name: "imperative-agent",
5
+ props: {
6
+ component: {
7
+ type: null,
8
+ required: true
9
+ },
10
+ defaultOptions: {
11
+ type: null,
12
+ default: void 0
13
+ },
14
+ config: {
15
+ type: null,
16
+ default: void 0
17
+ }
18
+ },
19
+ setup(__props, { expose: __expose }) {
20
+ const props = __props;
21
+ const compRef = useTemplateRef("compRef");
22
+ const innerProps = ref({});
23
+ const boundProps = computed(() => {
24
+ return {
25
+ ...innerProps.value,
26
+ "onUpdate:visible": (value) => {
27
+ innerProps.value.visible = value;
28
+ innerProps.value["onUpdate:visible"]?.(value);
29
+ }
30
+ };
31
+ });
32
+ const show = (options) => {
33
+ innerProps.value = {
34
+ ...props.defaultOptions,
35
+ ...options,
36
+ visible: true
37
+ };
38
+ props.config?.onShow?.(compRef.value);
39
+ };
40
+ const hide = () => {
41
+ innerProps.value = {
42
+ ...innerProps.value,
43
+ visible: false
44
+ };
45
+ props.config?.onHide?.(compRef.value);
46
+ };
47
+ __expose({
48
+ show,
49
+ hide
50
+ });
51
+ return (_ctx, _cache) => {
52
+ return openBlock(), createBlock(resolveDynamicComponent(__props.component), mergeProps({
53
+ ref_key: "compRef",
54
+ ref: compRef
55
+ }, boundProps.value), null, 16);
56
+ };
57
+ }
58
+ });
59
+ //#endregion
60
+ export { imperative_agent_default as default };
package/utils/index.d.ts CHANGED
@@ -18,7 +18,6 @@ export * from './color';
18
18
  export * from './barcode';
19
19
  export * from './canvas';
20
20
  export * from './clipboard';
21
- export * from './vnode';
22
21
  export * from './component';
23
22
  export * from './scroller';
24
23
  export * from './polyfill';
package/utils/index.js CHANGED
@@ -18,10 +18,9 @@ import { defaultColorPickerPresets, defaultColorPickerValue, formatColor, getPre
18
18
  import { BarcodeFormatList, BarcodeTextPositionList, barcode, calculateBarcodeLayout, normalizeBarcodeOptions } from "./barcode.js";
19
19
  import { measureTextWidth } from "./canvas.js";
20
20
  import { clipboard } from "./clipboard.js";
21
- import { OnlyChild, flatVNode } from "./vnode.js";
22
21
  import { defineSetupFnComponent, enhanceComponent } from "./component.js";
23
22
  import { Friction } from "./scroller/Friction.js";
24
23
  import { Spring } from "./scroller/Spring.js";
25
24
  import { withResolvers } from "./polyfill.js";
26
25
  import { useScroller } from "./scroller/useScroller.js";
27
- export { ALPHANUMERIC_CHARS, BarcodeFormatList, BarcodeTextPositionList, ECLList, Friction, OnlyChild, Spring, addSeparator, addUnit, arrayEqual, arrayMove, assignDeep, barcode, baseLunarYear, calculateBarcodeLayout, camelCase, capitalize, chainGet, chainSet, checkRtl, chooseFile, clamp, clipboard, compactNumber, createBem, createBemStruct, createInertialAnimate, cssVar, cssVarName, debounce, deepClone, defaultBemConfig, defaultColorPickerPresets, defaultColorPickerValue, defineSetupFnComponent, earthlyBranches, enhanceComponent, extend, flatVNode, formatColor, formatDate, formatNumber, formatThousands, getAspectFillSize, getAspectFitSize, getDampingValue, getDayOfYear, getDaysAfterLastDay, getDaysBeforeFirstDay, getDaysInMonth, getDaysSinceUnixEpoch, getDecimalsLength, getFileName, getFirstDayWeekday, getInBoundValue, getLeafNodes, getLunarDayName, getLunarHourName, getLunarLeapMonth, getLunarLeapMonthDays, getLunarMonthDays, getLunarMonthName, getLunarYearDays, getLunarYearName, getNextMonthDate, getNextMonthHeadDays, getNodeLevel, getOverflowRangeInArea, getPageRange, getPrevMonthDate, getPrevMonthTailDays, getPreviewColor, getRectDampingValue, getRotatedRect, getScrollIntoViewValue, getScrollTop, getTouchPoint, getTransformOrigin, getTreeCheckedKeys, getTreeHalfCheckedKeys, getTwoPointsDistance, heavenlyStems, hslToHsv, hslToHwb, hslToRgb, hsvToHsl, hwbToHsl, imageDataToDataURL, inRange, initializeCheckNodes, interpolate, isBoolean, isConfigObject, isDate, isEmptyArray, isEmptyBinding, isEmptyValue, isFileUrl, isFunction, isImageFile, isImageUrl, isKorean, isLeapYear, isNoEmptyArray, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isRectEqual, isRenderVisible, isSizeEqual, isString, isUndefined, isVideoFile, isVideoUrl, isVisibleEmpty, kebabCase, loadImage, logError, looseToNumber, lowerFirst, lunarDayNames, lunarInfo, lunarMonthNames, lunarToSolar, lunarYearNames, mapTreeToGrid, matchScrollVisible, measureTextWidth, minmaxDate, mround, nestedToMulti, noop, normalizeBarcodeOptions, normalizeHsla, normalizeHsva, omit, parseColor, parseDate, partition, pascalCase, pick, qrcode, random, readFileContent, rgbToHsl, round, scrollToTarget, setCheckedRecursively, shuffle, sleep, snakeCase, solarToLunar, splitUnit, spreadEach, springFestivals, throttle, toArray, toDate, toDateNumber, toDateString, toMonthNumber, toTouchEvent, treeToMap, truncToFixed, uniqid, updateAncestorsChecked, upperFirst, useScroller, walkAncestor, walkDescendant, walkNodes, withResolvers };
26
+ export { ALPHANUMERIC_CHARS, BarcodeFormatList, BarcodeTextPositionList, ECLList, Friction, Spring, addSeparator, addUnit, arrayEqual, arrayMove, assignDeep, barcode, baseLunarYear, calculateBarcodeLayout, camelCase, capitalize, chainGet, chainSet, checkRtl, chooseFile, clamp, clipboard, compactNumber, createBem, createBemStruct, createInertialAnimate, cssVar, cssVarName, debounce, deepClone, defaultBemConfig, defaultColorPickerPresets, defaultColorPickerValue, defineSetupFnComponent, earthlyBranches, enhanceComponent, extend, formatColor, formatDate, formatNumber, formatThousands, getAspectFillSize, getAspectFitSize, getDampingValue, getDayOfYear, getDaysAfterLastDay, getDaysBeforeFirstDay, getDaysInMonth, getDaysSinceUnixEpoch, getDecimalsLength, getFileName, getFirstDayWeekday, getInBoundValue, getLeafNodes, getLunarDayName, getLunarHourName, getLunarLeapMonth, getLunarLeapMonthDays, getLunarMonthDays, getLunarMonthName, getLunarYearDays, getLunarYearName, getNextMonthDate, getNextMonthHeadDays, getNodeLevel, getOverflowRangeInArea, getPageRange, getPrevMonthDate, getPrevMonthTailDays, getPreviewColor, getRectDampingValue, getRotatedRect, getScrollIntoViewValue, getScrollTop, getTouchPoint, getTransformOrigin, getTreeCheckedKeys, getTreeHalfCheckedKeys, getTwoPointsDistance, heavenlyStems, hslToHsv, hslToHwb, hslToRgb, hsvToHsl, hwbToHsl, imageDataToDataURL, inRange, initializeCheckNodes, interpolate, isBoolean, isConfigObject, isDate, isEmptyArray, isEmptyBinding, isEmptyValue, isFileUrl, isFunction, isImageFile, isImageUrl, isKorean, isLeapYear, isNoEmptyArray, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isRectEqual, isRenderVisible, isSizeEqual, isString, isUndefined, isVideoFile, isVideoUrl, isVisibleEmpty, kebabCase, loadImage, logError, looseToNumber, lowerFirst, lunarDayNames, lunarInfo, lunarMonthNames, lunarToSolar, lunarYearNames, mapTreeToGrid, matchScrollVisible, measureTextWidth, minmaxDate, mround, nestedToMulti, noop, normalizeBarcodeOptions, normalizeHsla, normalizeHsva, omit, parseColor, parseDate, partition, pascalCase, pick, qrcode, random, readFileContent, rgbToHsl, round, scrollToTarget, setCheckedRecursively, shuffle, sleep, snakeCase, solarToLunar, splitUnit, spreadEach, springFestivals, throttle, toArray, toDate, toDateNumber, toDateString, toMonthNumber, toTouchEvent, treeToMap, truncToFixed, uniqid, updateAncestorsChecked, upperFirst, useScroller, walkAncestor, walkDescendant, walkNodes, withResolvers };
package/utils/is.d.ts CHANGED
@@ -73,7 +73,10 @@ export declare function isPrimitive(target: any): target is string | number | bo
73
73
  */
74
74
  export declare function isDate(target: any): target is Date;
75
75
  /**
76
- * 判断是否为配置对象(而非 VNode)
76
+ * 判断是否为配置对象(而非其他类型的值)
77
+ *
78
+ * NOTE: 这里不再用 `isVNode` 排除 VNode —— `message` 之类的内容按文本渲染,
79
+ * 传 VNode 本来就没有意义,且 vapor 下不存在 VNode。
77
80
  * @param {any} target
78
81
  * @return {boolean}
79
82
  */
package/utils/is.js CHANGED
@@ -1,4 +1,3 @@
1
- import { isVNode } from "vue";
2
1
  //#region packages/sard/utils/is.ts
3
2
  /**
4
3
  * @description: 判断是否为纯对象
@@ -97,12 +96,15 @@ function isDate(target) {
97
96
  return target instanceof Date;
98
97
  }
99
98
  /**
100
- * 判断是否为配置对象(而非 VNode)
99
+ * 判断是否为配置对象(而非其他类型的值)
100
+ *
101
+ * NOTE: 这里不再用 `isVNode` 排除 VNode —— `message` 之类的内容按文本渲染,
102
+ * 传 VNode 本来就没有意义,且 vapor 下不存在 VNode。
101
103
  * @param {any} target
102
104
  * @return {boolean}
103
105
  */
104
106
  function isConfigObject(target) {
105
- return isPlainObject(target) && !isVNode(target);
107
+ return isPlainObject(target);
106
108
  }
107
109
  //#endregion
108
110
  export { isBoolean, isConfigObject, isDate, isEmptyArray, isFunction, isNoEmptyArray, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isString, isUndefined };
package/utils/number.d.ts CHANGED
@@ -42,7 +42,7 @@ export declare function truncToFixed(num: number, decimals?: number): string;
42
42
  * @param decimals 小数位数
43
43
  * @param keepZero 是否保留为0时的小数部分
44
44
  */
45
- export declare function compactNumber(num: number | string, decimals?: number, keepZero?: boolean): string;
45
+ export declare function compactNumber(num: number | string | null | undefined, decimals?: number, keepZero?: boolean): string;
46
46
  /**
47
47
  * 将数字格式化为千分位格式
48
48
  * @param num
package/utils/number.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { isNumber } from "./is.js";
1
2
  //#region packages/sard/utils/number.ts
2
3
  /**
3
4
  * 限定数值范围
@@ -67,6 +68,24 @@ function truncToFixed(num, decimals = 0) {
67
68
  const n = Math.pow(10, decimals);
68
69
  return (Math.trunc(num * n) / n).toFixed(decimals);
69
70
  }
71
+ const units = [
72
+ {
73
+ value: 0xe8d4a51000,
74
+ symbol: "T"
75
+ },
76
+ {
77
+ value: 1e9,
78
+ symbol: "B"
79
+ },
80
+ {
81
+ value: 1e6,
82
+ symbol: "M"
83
+ },
84
+ {
85
+ value: 1e3,
86
+ symbol: "K"
87
+ }
88
+ ];
70
89
  /**
71
90
  * 通过添加单位缩写数字
72
91
  * @param num
@@ -75,25 +94,7 @@ function truncToFixed(num, decimals = 0) {
75
94
  */
76
95
  function compactNumber(num, decimals = 1, keepZero = false) {
77
96
  num = typeof num === "string" ? Number.parseFloat(num) : num;
78
- if (!Number.isFinite(num)) return "0";
79
- const units = [
80
- {
81
- value: 0xe8d4a51000,
82
- symbol: "T"
83
- },
84
- {
85
- value: 1e9,
86
- symbol: "B"
87
- },
88
- {
89
- value: 1e6,
90
- symbol: "M"
91
- },
92
- {
93
- value: 1e3,
94
- symbol: "K"
95
- }
96
- ];
97
+ if (!isNumber(num) || !Number.isFinite(num)) return "0";
97
98
  const isNegative = num < 0;
98
99
  if (isNegative) num = Math.abs(num);
99
100
  let formattedNum = truncToFixed(num, decimals);
@@ -1,3 +0,0 @@
1
- import { type PickerViewColumnSlots } from './common';
2
- declare const _default: import("vue").DefineSetupFnComponent<import("vue").ExtractPublicPropTypes<unknown>, {}, PickerViewColumnSlots>;
3
- export default _default;
@@ -1,139 +0,0 @@
1
- import { createBem } from "../../utils/bem.js";
2
- import { flatVNode } from "../../utils/vnode.js";
3
- import { defineSetupFnComponent } from "../../utils/component.js";
4
- import { Friction } from "../../utils/scroller/Friction.js";
5
- import { Spring } from "../../utils/scroller/Spring.js";
6
- import { usePointerDown } from "../../use/usePointerDown.js";
7
- import { useResizeObserver } from "../../use/useResizeObserver.js";
8
- import { useScroller } from "../../utils/scroller/useScroller.js";
9
- import { pickerViewContextKey } from "./common.js";
10
- import { computed, createVNode, getCurrentInstance, inject, ref, watch, watchPostEffect } from "vue";
11
- //#region packages/sard/components/picker-view/picker-view-column.tsx
12
- var picker_view_column_default = defineSetupFnComponent((_props, { slots }) => {
13
- const bem = createBem("picker-view-column");
14
- const instance = getCurrentInstance();
15
- const rootRef = ref(null);
16
- const contentRef = ref(null);
17
- const indicatorRef = ref(null);
18
- const context = inject(pickerViewContextKey);
19
- const columnValue = context.getColumnValue(instance);
20
- const itemCount = ref(0);
21
- const rootSize = useResizeObserver(rootRef);
22
- const contentSize = useResizeObserver(contentRef);
23
- const indicatorSize = useResizeObserver(indicatorRef);
24
- const maskSize = computed(() => (rootSize.height - indicatorSize.height) / 2);
25
- const contentHeight = computed(() => {
26
- return contentSize.height + maskSize.value * 2;
27
- });
28
- const { position, update, scrollTo, isIdle, handleTouchStart, handleTouchMove, handleTouchEnd } = useScroller({
29
- itemSize: indicatorSize.height,
30
- friction: new Friction(1e-4),
31
- spring: new Spring(2, 90, 20),
32
- onSnap: (index) => {
33
- if (!isNaN(index) && index !== columnValue.value) columnValue.value = index;
34
- },
35
- onTap: (event) => {
36
- handleTap(event);
37
- }
38
- });
39
- let updatePending = false;
40
- watch([
41
- () => indicatorSize.height,
42
- columnValue,
43
- itemCount,
44
- () => rootSize.height,
45
- contentHeight
46
- ], () => {
47
- if (updatePending) return;
48
- updatePending = true;
49
- setTimeout(() => {
50
- updatePending = false;
51
- if (indicatorSize.height) {
52
- const current = Math.max(Math.min(columnValue.value, itemCount.value - 1), 0);
53
- update(current * indicatorSize.height, indicatorSize.height, rootSize.height, contentHeight.value);
54
- }
55
- });
56
- }, { flush: "post" });
57
- watchPostEffect(() => {
58
- const el = contentRef.value;
59
- if (!el) return;
60
- const transform = "translateY(" + position.value + "px) translateZ(0)";
61
- el.style.transform = transform;
62
- });
63
- let oldDeltaY = 0;
64
- function handleWheel(event) {
65
- const deltaY = oldDeltaY + event.deltaY;
66
- if (Math.abs(deltaY) > 10) {
67
- oldDeltaY = 0;
68
- let current = Math.min(columnValue.value + (deltaY < 0 ? -1 : 1), itemCount.value - 1);
69
- columnValue.value = current = Math.max(current, 0);
70
- scrollTo(current * indicatorSize.height);
71
- } else oldDeltaY = deltaY;
72
- event.preventDefault();
73
- }
74
- function handleTap({ changedTouches: [{ clientY }] }) {
75
- const el = rootRef.value;
76
- if (isIdle()) {
77
- const r = clientY - el.getBoundingClientRect().top - rootSize.height / 2;
78
- const o = indicatorSize.height / 2;
79
- if (!(Math.abs(r) <= o)) {
80
- const a = Math.ceil((Math.abs(r) - o) / indicatorSize.height);
81
- const s = r < 0 ? -a : a;
82
- let current = Math.min(columnValue.value + s, itemCount.value - 1);
83
- columnValue.value = current = Math.max(current, 0);
84
- scrollTo(current * indicatorSize.height);
85
- }
86
- }
87
- }
88
- const onTouchStart = (event) => {
89
- handleTouchStart(event);
90
- };
91
- const onTouchMove = (event) => {
92
- handleTouchMove(event);
93
- event.stopPropagation();
94
- };
95
- const onTouchEnd = (event) => {
96
- handleTouchEnd(event);
97
- };
98
- const onPointerDown = usePointerDown(onTouchStart, onTouchMove, onTouchEnd);
99
- return () => {
100
- const defaultSlots = slots.default?.();
101
- itemCount.value = flatVNode(defaultSlots).length;
102
- const padding = `${maskSize.value}px 0`;
103
- return createVNode("div", {
104
- "ref": rootRef,
105
- "class": bem.b(),
106
- "onTouchstart": onTouchStart,
107
- "onTouchmove": onTouchMove,
108
- "onTouchend": onTouchEnd,
109
- "onTouchcancel": onTouchEnd,
110
- "onPointerdown": onPointerDown
111
- }, [createVNode("div", {
112
- "class": bem.e("group"),
113
- "onWheel": handleWheel
114
- }, [
115
- createVNode("div", {
116
- "class": [bem.e("mask"), context.maskClass],
117
- "style": [`background-size: 100% ${maskSize.value}px;`, context.maskStyle]
118
- }, null),
119
- createVNode("div", {
120
- "ref": indicatorRef,
121
- "class": [bem.e("indicator"), context.indicatorClass],
122
- "style": context.indicatorStyle
123
- }, null),
124
- createVNode("div", {
125
- "ref": contentRef,
126
- "class": [bem.e("content")],
127
- "style": {
128
- padding,
129
- "--picker-view-indicator-height": `${indicatorSize.height}px`
130
- }
131
- }, [defaultSlots])
132
- ])]);
133
- };
134
- }, {
135
- name: "PickerViewColumn",
136
- slots: null
137
- });
138
- //#endregion
139
- export { picker_view_column_default as default };
@@ -1,21 +0,0 @@
1
- import { type PickerViewEmits, type PickerViewSlots } from './common';
2
- declare const _default: import("vue").DefineSetupFnComponent<import("vue").ExtractPublicPropTypes<{
3
- value: {
4
- type: import("vue").PropType<number[]>;
5
- default(): never[];
6
- validator(val: any): boolean;
7
- };
8
- indicatorStyle: {
9
- type: import("vue").PropType<import("vue").StyleValue>;
10
- };
11
- indicatorClass: {
12
- type: import("vue").PropType<import("vue").ClassValue>;
13
- };
14
- maskStyle: {
15
- type: import("vue").PropType<import("vue").StyleValue>;
16
- };
17
- maskClass: {
18
- type: import("vue").PropType<import("vue").ClassValue>;
19
- };
20
- }>, PickerViewEmits, PickerViewSlots>;
21
- export default _default;
@@ -1,57 +0,0 @@
1
- import { createBem } from "../../utils/bem.js";
2
- import { flatVNode } from "../../utils/vnode.js";
3
- import { defineSetupFnComponent } from "../../utils/component.js";
4
- import { pickerViewContextKey, pickerViewProps } from "./common.js";
5
- import { computed, createVNode, provide, reactive, ref, toRef, watch } from "vue";
6
- //#region packages/sard/components/picker-view/picker-view.tsx
7
- var picker_view_default = defineSetupFnComponent((props, { slots, emit }) => {
8
- const bem = createBem("picker-view");
9
- const innerValue = reactive([...props.value]);
10
- watch(() => props.value, (value) => {
11
- innerValue.length = value.length;
12
- value.forEach((val, index) => {
13
- if (val !== innerValue[index]) innerValue.splice(index, 1, val);
14
- });
15
- });
16
- const columnsRef = ref([]);
17
- function getItemIndex(vnode) {
18
- return columnsRef.value.indexOf(vnode);
19
- }
20
- const getColumnValue = (columnInstance) => {
21
- return computed({
22
- get() {
23
- const index = getItemIndex(columnInstance.vnode);
24
- return innerValue[index] || 0;
25
- },
26
- set(current) {
27
- const index = getItemIndex(columnInstance.vnode);
28
- if (index < 0) return;
29
- if (innerValue[index] !== current) {
30
- innerValue[index] = current;
31
- const value = [...innerValue];
32
- emit("update:value", value);
33
- emit("change", value);
34
- }
35
- }
36
- });
37
- };
38
- provide(pickerViewContextKey, reactive({
39
- maskStyle: toRef(() => props.maskStyle),
40
- maskClass: toRef(() => props.maskClass),
41
- indicatorClass: toRef(() => props.indicatorClass),
42
- indicatorStyle: toRef(() => props.indicatorStyle),
43
- getColumnValue
44
- }));
45
- return () => {
46
- const defaultSlots = slots.default && slots.default();
47
- columnsRef.value = flatVNode(defaultSlots);
48
- return createVNode("div", { "class": bem.b() }, [createVNode("div", { "class": bem.e("wrapper") }, [defaultSlots])]);
49
- };
50
- }, {
51
- name: "PickerView",
52
- props: pickerViewProps,
53
- emits: ["change", "update:value"],
54
- slots: null
55
- });
56
- //#endregion
57
- export { picker_view_default as default };
@@ -1,3 +0,0 @@
1
- import { type SwiperItemSlots } from './common';
2
- declare const _default: import("vue").DefineSetupFnComponent<import("vue").ExtractPublicPropTypes<{}>, {}, SwiperItemSlots>;
3
- export default _default;