sard 1.0.20 → 1.0.22

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.
@@ -5,12 +5,12 @@ declare const __VLS_base: import("vue").DefineComponent<ButtonProps, {}, {}, {},
5
5
  }, string, import("vue").PublicProps, Readonly<ButtonProps> & Readonly<{
6
6
  onClick?: ((event: MouseEvent) => any) | undefined;
7
7
  }>, {
8
+ round: boolean;
8
9
  size: "xs" | "small" | "medium" | "large";
9
10
  loading: boolean;
10
11
  disabled: boolean;
11
12
  color: "primary" | "secondary" | "success" | "warning" | "danger" | "white" | "black";
12
13
  square: boolean;
13
- round: boolean;
14
14
  variant: "solid" | "outlined" | "dashed" | "filled" | "text" | "link";
15
15
  loadingType: "clock" | "circular";
16
16
  block: boolean;
@@ -1,7 +1,7 @@
1
1
  import { type CountToProps } from './common';
2
2
  declare const __VLS_export: import("vue").DefineComponent<CountToProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CountToProps> & Readonly<{}>, {
3
- value: number;
4
3
  duration: number;
4
+ value: number;
5
5
  separator: string;
6
6
  precision: number;
7
7
  separatorDigit: number;
@@ -1,7 +1,7 @@
1
1
  import { addSeparator } from "../../utils/string.js";
2
+ import { animateNumber } from "../../utils/animation.js";
2
3
  import { defaultCountToProps } from "./common.js";
3
4
  import { computed, createElementBlock, defineComponent, mergeDefaults, onUnmounted, openBlock, ref, toDisplayString, watch } from "vue";
4
- import { createAnimation } from "lwa";
5
5
  //#region packages/sard/components/count-to/count-to.vue
6
6
  var count_to_default = /*@__PURE__*/ defineComponent({
7
7
  __name: "count-to",
@@ -30,14 +30,14 @@ var count_to_default = /*@__PURE__*/ defineComponent({
30
30
  setup(__props) {
31
31
  const props = __props;
32
32
  const number = ref(0);
33
- let tl;
33
+ let animation;
34
34
  const renderedNumer = computed(() => {
35
35
  const fixedNum = number.value.toFixed(props.precision);
36
36
  return props.separator ? addSeparator(fixedNum, props.separator, props.separatorDigit) : fixedNum;
37
37
  });
38
38
  watch(() => props.value, () => {
39
- tl?.pause();
40
- tl = createAnimation(number, { value: props.value }, {
39
+ animation?.pause();
40
+ animation = animateNumber(number, props.value, {
41
41
  duration: props.duration,
42
42
  easing: "easeOutQuint",
43
43
  round: Math.pow(10, props.precision)
@@ -47,7 +47,7 @@ var count_to_default = /*@__PURE__*/ defineComponent({
47
47
  immediate: true
48
48
  });
49
49
  onUnmounted(() => {
50
- tl?.pause();
50
+ animation?.pause();
51
51
  });
52
52
  return (_ctx, _cache) => {
53
53
  return openBlock(), createElementBlock("span", null, toDisplayString(renderedNumer.value), 1);
@@ -7,8 +7,8 @@ declare const __VLS_base: import("vue").DefineComponent<FloatingPanelProps, Floa
7
7
  "onUpdate:height"?: ((value: number) => any) | undefined;
8
8
  "onHeight-change"?: ((value: number) => any) | undefined;
9
9
  }>, {
10
- height: number;
11
10
  duration: number;
11
+ height: number;
12
12
  anchors: number[];
13
13
  contentDraggable: boolean;
14
14
  safeAreaInsetBottom: boolean;
@@ -3,8 +3,8 @@ type __VLS_Slots = SkeletonSlots;
3
3
  declare const __VLS_base: import("vue").DefineComponent<SkeletonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<SkeletonProps> & Readonly<{}>, {
4
4
  title: boolean;
5
5
  animated: boolean;
6
- loading: boolean;
7
6
  round: boolean;
7
+ loading: boolean;
8
8
  avatar: boolean;
9
9
  rows: number;
10
10
  avatarSize: string;
@@ -1,14 +1,14 @@
1
+ import { animateNumber } from "../../utils/animation.js";
1
2
  import { withResolvers } from "../../utils/polyfill.js";
2
3
  import { onUnmounted } from "vue";
3
- import { createAnimation } from "lwa";
4
4
  //#region packages/sard/components/swiper/useSwiperAnimation.ts
5
5
  function useSwiperAnimation(target) {
6
- let tl;
6
+ let animation;
7
7
  let promiseWithResolvers;
8
8
  const play = (value, duration, update) => {
9
- tl?.pause();
9
+ animation?.pause();
10
10
  promiseWithResolvers = withResolvers();
11
- tl = createAnimation(target, { value }, {
11
+ animation = animateNumber(target, value, {
12
12
  duration,
13
13
  easing: "easeOutCubic",
14
14
  update,
@@ -19,7 +19,7 @@ function useSwiperAnimation(target) {
19
19
  return promiseWithResolvers.promise;
20
20
  };
21
21
  const pause = () => {
22
- tl?.pause();
22
+ animation?.pause();
23
23
  };
24
24
  onUnmounted(() => {
25
25
  pause();
@@ -7,8 +7,8 @@ declare const __VLS_base: import("vue").DefineComponent<TabbarProps, {}, {}, {},
7
7
  onChange?: ((value: string | number) => any) | undefined;
8
8
  "onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
9
9
  }>, {
10
- fixed: boolean;
11
10
  modelValue: number | string;
11
+ fixed: boolean;
12
12
  color: string;
13
13
  bordered: boolean;
14
14
  safeAreaInsetBottom: boolean;
@@ -8,10 +8,10 @@ declare const __VLS_base: import("vue").DefineComponent<TagProps, {}, {}, {}, {}
8
8
  onClose?: ((event: any) => any) | undefined;
9
9
  }>, {
10
10
  mark: "left" | "right";
11
+ round: boolean;
11
12
  size: "small" | "medium" | "large";
12
13
  color: "default" | "primary" | "success" | "warning" | "danger";
13
14
  closable: boolean;
14
- round: boolean;
15
15
  variant: "filled" | "solid" | "outlined";
16
16
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
17
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
package/index.js CHANGED
@@ -6,9 +6,9 @@ import { chooseFile, getFileName, imageDataToDataURL, isFileUrl, isImageFile, is
6
6
  import { isBoolean, isConfigObject, isDate, isEmptyArray, isFunction, isNoEmptyArray, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isString, isUndefined } from "./utils/is.js";
7
7
  import { addUnit, debounce, getPageRange, isEmptyBinding, isEmptyValue, isRenderVisible, isVisibleEmpty, noop, sleep, splitUnit, throttle } from "./utils/utils.js";
8
8
  import { ALPHANUMERIC_CHARS, ECLList, qrcode } from "./utils/qrcode.js";
9
- import { chainGet, chainSet, deepClone, extend, nestedToMulti, omit, partition, pick, treeToMap } from "./utils/object.js";
9
+ import { assignDeep, chainGet, chainSet, deepClone, extend, nestedToMulti, omit, partition, pick, treeToMap } from "./utils/object.js";
10
10
  import { arrayEqual, arrayMove, shuffle, spreadEach, toArray } from "./utils/array.js";
11
- import { addSeparator, camelCase, capitalize, isKorean, kebabCase, lowerFirst, pascalCase, snakeCase, uniqid, upperFirst } from "./utils/string.js";
11
+ import { addSeparator, camelCase, capitalize, interpolate, isKorean, kebabCase, lowerFirst, pascalCase, snakeCase, uniqid, upperFirst } from "./utils/string.js";
12
12
  import { getAspectFillSize, getAspectFitSize, getRotatedRect, getScrollIntoViewValue, getTouchPoint, getTransformOrigin, getTwoPointsDistance, isRectEqual, isSizeEqual, matchScrollVisible, scrollToTarget } from "./utils/geometry.js";
13
13
  import { getDampingValue, getInBoundValue, getOverflowRangeInArea, getRectDampingValue } from "./utils/physics.js";
14
14
  import { createInertialAnimate } from "./utils/inertialAnimate.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, 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, autoUpdate, barcode, baseLunarYear, calculateBarcodeLayout, camelCase, capitalize, chainGet, chainSet, checkRtl, chooseFile, clamp, clipboard, 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, formatTime, getAllImperatives, getAspectFillSize, getAspectFitSize, getAvailableImperative, getCurrentTime, getDampingValue, getDayOfYear, getDaysAfterLastDay, getDaysBeforeFirstDay, getDaysInMonth, getDaysSinceUnixEpoch, getDecimalsLength, getFileName, getFirstDayWeekday, getGridCenterSize, getGridIndex, getGridPrizeCount, getImperatives, 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, 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, uniqid, updateAncestorsChecked, upperFirst, useClickOutside, useColorScheme, useComposition, useCountDown, useDragPinch, useElementBackTop, useElementScroll, useFormContext, useFormItem, useFormItemContext, useFormPopout, useImperative, 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, 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, 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, formatTime, getAllImperatives, getAspectFillSize, getAspectFitSize, getAvailableImperative, getCurrentTime, getDampingValue, getDayOfYear, getDaysAfterLastDay, getDaysBeforeFirstDay, getDaysInMonth, getDaysSinceUnixEpoch, getDecimalsLength, getFileName, getFirstDayWeekday, getGridCenterSize, getGridIndex, getGridPrizeCount, getImperatives, 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, uniqid, updateAncestorsChecked, upperFirst, useClickOutside, useColorScheme, useComposition, useCountDown, useDragPinch, useElementBackTop, useElementScroll, useFormContext, useFormItem, useFormItemContext, useFormPopout, useImperative, 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/locale/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { chainGet } from "../utils/object.js";
2
+ import { interpolate } from "../utils/string.js";
2
3
  import zh_CN_default from "./lang/zh-CN.js";
3
4
  import { computed, inject, ref, shallowRef, watch } from "vue";
4
5
  //#region packages/sard/locale/index.ts
@@ -11,13 +12,7 @@ function useTranslate(prefix = "") {
11
12
  const chain = typeof chainOrData === "string" ? prefix ? prefix + "." + chainOrData : chainOrData : prefix;
12
13
  data = chainOrData && typeof chainOrData === "object" ? chainOrData : data;
13
14
  const result = chainGet(locale.value, chain);
14
- if (typeof result === "string") {
15
- if (data) return result.replace(/\{([^}]*)\}/g, (match, p1) => {
16
- const value = data[p1];
17
- return value != null ? String(value) : match;
18
- });
19
- return result;
20
- }
15
+ if (typeof result === "string") return data ? interpolate(result, data) : result;
21
16
  return chain;
22
17
  };
23
18
  const select = (chain) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sard",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "sard 是基于 Vue3 的 Web 移动端 UI 组件库",
5
5
  "keywords": [
6
6
  "UI",
@@ -20,12 +20,10 @@
20
20
  "main": "index.js",
21
21
  "devDependencies": {
22
22
  "@sard/icons": "^0.1.0",
23
- "lwa": "^0.3.0",
24
23
  "vue": "^3.5.0"
25
24
  },
26
25
  "peerDependencies": {
27
26
  "@sard/icons": "^0.1.0",
28
- "lwa": "^0.3.0",
29
27
  "vue": "^3.5.0"
30
28
  }
31
29
  }
@@ -1,6 +1,6 @@
1
1
  import { random } from "../utils/number.js";
2
+ import { ticker } from "../utils/animation.js";
2
3
  import { computed, onScopeDispose, ref, unref } from "vue";
3
- import { ticker } from "lwa";
4
4
  //#region packages/sard/use/useLuckyDraw.ts
5
5
  const defaultOptions = {
6
6
  minSpeed: .1,
package/use/usePopper.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { clamp } from "../utils/number.js";
2
2
  import { isRectEqual } from "../utils/geometry.js";
3
+ import { ticker } from "../utils/animation.js";
3
4
  import { onBeforeUnmount, reactive, watch } from "vue";
4
- import { ticker } from "lwa";
5
5
  //#region packages/sard/use/usePopper.ts
6
6
  const directions = [
7
7
  "top",
@@ -0,0 +1,31 @@
1
+ import { type Ref } from 'vue';
2
+ type TickCallback = () => void;
3
+ /**
4
+ * 基于单个 requestAnimationFrame 的共享循环,多个动画共用同一帧循环。
5
+ */
6
+ export declare const ticker: {
7
+ add(callback: TickCallback): void;
8
+ remove(callback: TickCallback): void;
9
+ };
10
+ type EasingName = 'easeOutCubic' | 'easeOutQuint';
11
+ export interface AnimateNumberOptions {
12
+ /** 动画时长,单位毫秒 */
13
+ duration?: number;
14
+ /** 缓动函数名或自定义缓动函数 */
15
+ easing?: EasingName | ((k: number) => number);
16
+ /** 取整因子,每帧值会被舍入为 Math.round(value * round) / round */
17
+ round?: number;
18
+ /** 每帧更新后回调 */
19
+ update?: () => void;
20
+ /** 动画结束回调 */
21
+ complete?: () => void;
22
+ }
23
+ export interface Animation {
24
+ /** 暂停动画,暂停后不会触发 complete */
25
+ pause: () => void;
26
+ }
27
+ /**
28
+ * 将数字 ref 的 value 从当前值缓动到目标值,创建后自动播放。
29
+ */
30
+ export declare function animateNumber(ref: Ref<number>, to: number, options?: AnimateNumberOptions): Animation;
31
+ export {};
@@ -0,0 +1,56 @@
1
+ //#region packages/sard/utils/animation.ts
2
+ const callbacks = /* @__PURE__ */ new Set();
3
+ let rafId = 0;
4
+ function loop() {
5
+ rafId = requestAnimationFrame(loop);
6
+ callbacks.forEach((callback) => callback());
7
+ }
8
+ /**
9
+ * 基于单个 requestAnimationFrame 的共享循环,多个动画共用同一帧循环。
10
+ */
11
+ const ticker = {
12
+ add(callback) {
13
+ callbacks.add(callback);
14
+ if (rafId === 0) rafId = requestAnimationFrame(loop);
15
+ },
16
+ remove(callback) {
17
+ callbacks.delete(callback);
18
+ if (rafId !== 0 && callbacks.size === 0) {
19
+ cancelAnimationFrame(rafId);
20
+ rafId = 0;
21
+ }
22
+ }
23
+ };
24
+ const easings = {
25
+ easeOutCubic: (k) => 1 - Math.pow(1 - k, 3),
26
+ easeOutQuint: (k) => 1 - Math.pow(1 - k, 5)
27
+ };
28
+ /**
29
+ * 将数字 ref 的 value 从当前值缓动到目标值,创建后自动播放。
30
+ */
31
+ function animateNumber(ref, to, options = {}) {
32
+ const { duration = 0, easing = "easeOutCubic", round, update, complete } = options;
33
+ const easingFn = typeof easing === "function" ? easing : easings[easing];
34
+ const from = ref.value;
35
+ const change = to - from;
36
+ const start = performance.now();
37
+ const setValue = (value) => {
38
+ ref.value = round === void 0 ? value : Math.round(value * round) / round;
39
+ };
40
+ const tick = () => {
41
+ const progress = duration > 0 ? Math.min((performance.now() - start) / duration, 1) : 1;
42
+ setValue(from + change * easingFn(progress));
43
+ update?.();
44
+ if (progress >= 1) {
45
+ pause();
46
+ complete?.();
47
+ }
48
+ };
49
+ const pause = () => {
50
+ ticker.remove(tick);
51
+ };
52
+ ticker.add(tick);
53
+ return { pause };
54
+ }
55
+ //#endregion
56
+ export { animateNumber, ticker };
package/utils/index.js CHANGED
@@ -6,9 +6,9 @@ import { chooseFile, getFileName, imageDataToDataURL, isFileUrl, isImageFile, is
6
6
  import { isBoolean, isConfigObject, isDate, isEmptyArray, isFunction, isNoEmptyArray, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isString, isUndefined } from "./is.js";
7
7
  import { addUnit, debounce, getPageRange, isEmptyBinding, isEmptyValue, isRenderVisible, isVisibleEmpty, noop, sleep, splitUnit, throttle } from "./utils.js";
8
8
  import { ALPHANUMERIC_CHARS, ECLList, qrcode } from "./qrcode.js";
9
- import { chainGet, chainSet, deepClone, extend, nestedToMulti, omit, partition, pick, treeToMap } from "./object.js";
9
+ import { assignDeep, chainGet, chainSet, deepClone, extend, nestedToMulti, omit, partition, pick, treeToMap } from "./object.js";
10
10
  import { arrayEqual, arrayMove, shuffle, spreadEach, toArray } from "./array.js";
11
- import { addSeparator, camelCase, capitalize, isKorean, kebabCase, lowerFirst, pascalCase, snakeCase, uniqid, upperFirst } from "./string.js";
11
+ import { addSeparator, camelCase, capitalize, interpolate, isKorean, kebabCase, lowerFirst, pascalCase, snakeCase, uniqid, upperFirst } from "./string.js";
12
12
  import { getAspectFillSize, getAspectFitSize, getRotatedRect, getScrollIntoViewValue, getTouchPoint, getTransformOrigin, getTwoPointsDistance, isRectEqual, isSizeEqual, matchScrollVisible, scrollToTarget } from "./geometry.js";
13
13
  import { getDampingValue, getInBoundValue, getOverflowRangeInArea, getRectDampingValue } from "./physics.js";
14
14
  import { createInertialAnimate } from "./inertialAnimate.js";
@@ -24,4 +24,4 @@ import { Friction } from "./scroller/Friction.js";
24
24
  import { Spring } from "./scroller/Spring.js";
25
25
  import { withResolvers } from "./polyfill.js";
26
26
  import { useScroller } from "./scroller/useScroller.js";
27
- export { ALPHANUMERIC_CHARS, BarcodeFormatList, BarcodeTextPositionList, ECLList, Friction, OnlyChild, Spring, addSeparator, addUnit, arrayEqual, arrayMove, barcode, baseLunarYear, calculateBarcodeLayout, camelCase, capitalize, chainGet, chainSet, checkRtl, chooseFile, clamp, clipboard, createBem, createBemStruct, createInertialAnimate, cssVar, cssVarName, debounce, deepClone, defaultBemConfig, defaultColorPickerPresets, defaultColorPickerValue, defineSetupFnComponent, earthlyBranches, enhanceComponent, extend, flatVNode, formatColor, formatDate, formatNumber, 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, 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, uniqid, updateAncestorsChecked, upperFirst, useScroller, walkAncestor, walkDescendant, walkNodes, withResolvers };
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, createBem, createBemStruct, createInertialAnimate, cssVar, cssVarName, debounce, deepClone, defaultBemConfig, defaultColorPickerPresets, defaultColorPickerValue, defineSetupFnComponent, earthlyBranches, enhanceComponent, extend, flatVNode, formatColor, formatDate, formatNumber, 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, uniqid, updateAncestorsChecked, upperFirst, useScroller, walkAncestor, walkDescendant, walkNodes, withResolvers };
@@ -1,4 +1,4 @@
1
- import { ticker } from "lwa";
1
+ import { ticker } from "./animation.js";
2
2
  //#region packages/sard/utils/inertialAnimate.ts
3
3
  const friction = .95;
4
4
  const minVelocity = .1;
package/utils/object.d.ts CHANGED
@@ -23,6 +23,11 @@ export declare function deepClone(target: any): any;
23
23
  * 深拷贝其他对象到第一个对象
24
24
  */
25
25
  export declare function extend(...args: any[]): any;
26
+ /**
27
+ * 深度合并多个对象并返回新对象:纯对象会递归合并,数组等其他非纯对象会被整体覆盖。
28
+ * 与 `extend` 不同,不会修改传入的任何对象。
29
+ */
30
+ export declare function assignDeep(...objects: Record<string, any>[]): Record<string, any>;
26
31
  export declare function treeToMap(tree: AnyObject[], keyName: string, childrenName: string, parentName: string): {
27
32
  [p: string]: AnyObject;
28
33
  };
package/utils/object.js CHANGED
@@ -71,6 +71,25 @@ function extend(...args) {
71
71
  }
72
72
  return target;
73
73
  }
74
+ /**
75
+ * 深度合并多个对象并返回新对象:纯对象会递归合并,数组等其他非纯对象会被整体覆盖。
76
+ * 与 `extend` 不同,不会修改传入的任何对象。
77
+ */
78
+ function assignDeep(...objects) {
79
+ const result = {};
80
+ for (const object of objects) {
81
+ if (object == null) continue;
82
+ Object.keys(object).forEach((key) => {
83
+ const value = object[key];
84
+ if (value === void 0) return;
85
+ if (isPlainObject(value)) {
86
+ const prev = result[key];
87
+ result[key] = assignDeep(isPlainObject(prev) ? prev : {}, value);
88
+ } else result[key] = value;
89
+ });
90
+ }
91
+ return result;
92
+ }
74
93
  function treeToMap(tree, keyName, childrenName, parentName) {
75
94
  const map = {};
76
95
  function recurse(children, parent) {
@@ -131,4 +150,4 @@ function nestedToMulti(nested, values, { getValue, getChildren }) {
131
150
  return columns;
132
151
  }
133
152
  //#endregion
134
- export { chainGet, chainSet, deepClone, extend, nestedToMulti, omit, partition, pick, treeToMap };
153
+ export { assignDeep, chainGet, chainSet, deepClone, extend, nestedToMulti, omit, partition, pick, treeToMap };
@@ -1,14 +1,14 @@
1
+ import { animateNumber } from "../animation.js";
1
2
  import { withResolvers } from "../polyfill.js";
2
3
  import { onUnmounted } from "vue";
3
- import { createAnimation } from "lwa";
4
4
  //#region packages/sard/utils/scroller/useEasingAnimation.ts
5
5
  function useEasingAnimation(target) {
6
- let tl;
6
+ let animation;
7
7
  let promiseWithResolvers;
8
8
  const play = (value, duration) => {
9
- tl?.pause();
9
+ animation?.pause();
10
10
  promiseWithResolvers = withResolvers();
11
- tl = createAnimation(target, { value }, {
11
+ animation = animateNumber(target, value, {
12
12
  duration,
13
13
  easing: "easeOutCubic",
14
14
  complete() {
@@ -18,7 +18,7 @@ function useEasingAnimation(target) {
18
18
  return promiseWithResolvers.promise;
19
19
  };
20
20
  const pause = () => {
21
- tl?.pause();
21
+ animation?.pause();
22
22
  };
23
23
  onUnmounted(() => {
24
24
  pause();
@@ -1,4 +1,4 @@
1
- import { ticker } from "lwa";
1
+ import { ticker } from "../animation.js";
2
2
  //#region packages/sard/utils/scroller/useScrollAnimation.ts
3
3
  /**
4
4
  * 创建一个基于 requestAnimationFrame 的动画循环。
package/utils/string.d.ts CHANGED
@@ -35,3 +35,9 @@ export declare function uniqid(): string;
35
35
  * 判断是否为韩文字符
36
36
  */
37
37
  export declare function isKorean(text: string): boolean;
38
+ /**
39
+ * 使用 `{key}` 占位符替换模板内容:
40
+ * `data` 为对象时按名匹配(`{name}`),为数组时按下标匹配(`{0}`)。
41
+ * 对应值为 `null`/`undefined` 或不存在时保留占位符原样;不传 `data` 时原样返回。
42
+ */
43
+ export declare function interpolate(template: string, data?: Record<string, any> | any[]): string;
package/utils/string.js CHANGED
@@ -64,5 +64,17 @@ function uniqid() {
64
64
  function isKorean(text) {
65
65
  return /([\uAC00-\uD7AF\u3130-\u318F])+/gi.test(text);
66
66
  }
67
+ /**
68
+ * 使用 `{key}` 占位符替换模板内容:
69
+ * `data` 为对象时按名匹配(`{name}`),为数组时按下标匹配(`{0}`)。
70
+ * 对应值为 `null`/`undefined` 或不存在时保留占位符原样;不传 `data` 时原样返回。
71
+ */
72
+ function interpolate(template, data) {
73
+ if (data == null) return template;
74
+ return template.replace(/\{([^}]*)\}/g, (match, key) => {
75
+ const value = Array.isArray(data) ? data[Number(key)] : data[key];
76
+ return value != null ? String(value) : match;
77
+ });
78
+ }
67
79
  //#endregion
68
- export { addSeparator, camelCase, capitalize, isKorean, kebabCase, lowerFirst, pascalCase, snakeCase, uniqid, upperFirst };
80
+ export { addSeparator, camelCase, capitalize, interpolate, isKorean, kebabCase, lowerFirst, pascalCase, snakeCase, uniqid, upperFirst };