sard 1.0.22 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/input/input.vue.d.ts +1 -1
- package/components/progress-bar/progress-bar.vue.d.ts +1 -1
- package/components/progress-circle/progress-circle.vue.d.ts +1 -1
- package/index.js +2 -3
- package/package.json +1 -1
- package/use/index.d.ts +0 -1
- package/use/index.js +1 -2
- package/utils/index.js +2 -2
- package/utils/number.d.ts +18 -0
- package/utils/number.js +60 -1
- package/use/useImperative.d.ts +0 -11
- package/use/useImperative.js +0 -44
|
@@ -32,7 +32,7 @@ declare const __VLS_base: import("vue").DefineComponent<InputProps, InputExpose,
|
|
|
32
32
|
autoHeight: import("./common").InputAutoHeight;
|
|
33
33
|
formatter: (value: string, trigger: "input" | "change") => string;
|
|
34
34
|
placeholder: string;
|
|
35
|
-
inputmode: "text" | "search" | "none" | "url" | "email" | "tel" | "numeric"
|
|
35
|
+
inputmode: "decimal" | "text" | "search" | "none" | "url" | "email" | "tel" | "numeric";
|
|
36
36
|
enterkeyhint: "search" | "done" | "enter" | "next" | "go" | "previous" | "send";
|
|
37
37
|
spellcheck: boolean | "true" | "false";
|
|
38
38
|
modelModifiers: import("./common").InputModelModifiers;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type ProgressBarProps, type ProgressBarSlots } from './common';
|
|
2
2
|
type __VLS_Slots = ProgressBarSlots;
|
|
3
3
|
declare const __VLS_base: import("vue").DefineComponent<ProgressBarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ProgressBarProps> & Readonly<{}>, {
|
|
4
|
+
percent: number;
|
|
4
5
|
animated: boolean;
|
|
5
6
|
color: string;
|
|
6
7
|
status: "success" | "warning" | "error";
|
|
7
8
|
inside: boolean;
|
|
8
|
-
percent: number;
|
|
9
9
|
trackColor: string;
|
|
10
10
|
thickness: string;
|
|
11
11
|
showText: boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type ProgressCircleProps, type ProgressCircleSlots } from './common';
|
|
2
2
|
type __VLS_Slots = ProgressCircleSlots;
|
|
3
3
|
declare const __VLS_base: import("vue").DefineComponent<ProgressCircleProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ProgressCircleProps> & Readonly<{}>, {
|
|
4
|
+
percent: number;
|
|
4
5
|
size: string;
|
|
5
6
|
color: string;
|
|
6
7
|
status: "success" | "warning" | "error";
|
|
7
|
-
percent: number;
|
|
8
8
|
trackColor: string;
|
|
9
9
|
thickness: number;
|
|
10
10
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createBem, createBemStruct, cssVar, cssVarName, defaultBemConfig } from "./utils/bem.js";
|
|
2
|
-
import { clamp, formatNumber, getDecimalsLength, inRange, looseToNumber, mround, random, round } from "./utils/number.js";
|
|
2
|
+
import { clamp, compactNumber, formatNumber, formatThousands, getDecimalsLength, inRange, looseToNumber, mround, random, round, truncToFixed } from "./utils/number.js";
|
|
3
3
|
import { baseLunarYear, earthlyBranches, formatDate, getDayOfYear, getDaysAfterLastDay, getDaysBeforeFirstDay, getDaysInMonth, getDaysSinceUnixEpoch, getFirstDayWeekday, getLunarDayName, getLunarHourName, getLunarLeapMonth, getLunarLeapMonthDays, getLunarMonthDays, getLunarMonthName, getLunarYearDays, getLunarYearName, getNextMonthDate, getNextMonthHeadDays, getPrevMonthDate, getPrevMonthTailDays, heavenlyStems, isLeapYear, lunarDayNames, lunarInfo, lunarMonthNames, lunarToSolar, lunarYearNames, minmaxDate, parseDate, solarToLunar, springFestivals, toDate, toDateNumber, toDateString, toMonthNumber } from "./utils/date.js";
|
|
4
4
|
import { checkRtl, getScrollTop, toTouchEvent } from "./utils/dom.js";
|
|
5
5
|
import { chooseFile, getFileName, imageDataToDataURL, isFileUrl, isImageFile, isImageUrl, isVideoFile, isVideoUrl, loadImage, readFileContent } from "./utils/file.js";
|
|
@@ -24,7 +24,6 @@ import { Friction } from "./utils/scroller/Friction.js";
|
|
|
24
24
|
import { Spring } from "./utils/scroller/Spring.js";
|
|
25
25
|
import { useTimeout } from "./use/useTimeout.js";
|
|
26
26
|
import { useZIndex } from "./use/useZIndex.js";
|
|
27
|
-
import { getAllImperatives, getAvailableImperative, getImperatives, useImperative } from "./use/useImperative.js";
|
|
28
27
|
import { useLuckyDraw } from "./use/useLuckyDraw.js";
|
|
29
28
|
import { getGridCenterSize, getGridIndex, getGridPrizeCount, useLuckyGrid } from "./use/useLuckyGrid.js";
|
|
30
29
|
import { useLuckyWheel } from "./use/useLuckyWheel.js";
|
|
@@ -217,4 +216,4 @@ function prepareEnvironment() {
|
|
|
217
216
|
});
|
|
218
217
|
}
|
|
219
218
|
//#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, 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,
|
|
219
|
+
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, 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 };
|
package/package.json
CHANGED
package/use/index.d.ts
CHANGED
package/use/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useTimeout } from "./useTimeout.js";
|
|
2
2
|
import { useZIndex } from "./useZIndex.js";
|
|
3
|
-
import { getAllImperatives, getAvailableImperative, getImperatives, useImperative } from "./useImperative.js";
|
|
4
3
|
import { useLuckyDraw } from "./useLuckyDraw.js";
|
|
5
4
|
import { getGridCenterSize, getGridIndex, getGridPrizeCount, useLuckyGrid } from "./useLuckyGrid.js";
|
|
6
5
|
import { useLuckyWheel } from "./useLuckyWheel.js";
|
|
@@ -33,4 +32,4 @@ import { useRtl } from "./useRtl.js";
|
|
|
33
32
|
import { autoUpdate, computePosition, usePopper } from "./usePopper.js";
|
|
34
33
|
import { useClickOutside } from "./useClickOutside.js";
|
|
35
34
|
import { isColorScheme, provideColorScheme, useColorScheme } from "./useColorScheme.js";
|
|
36
|
-
export { autoUpdate, computePosition, defaultOptionKeys,
|
|
35
|
+
export { autoUpdate, computePosition, defaultOptionKeys, getGridCenterSize, getGridIndex, getGridPrizeCount, isColorScheme, provideColorScheme, reactiveComputed, toReactive, useClickOutside, useColorScheme, useComposition, useDragPinch, useElementScroll, useIndeterminate, useInitialVelocity, useIntersectionObserver, useKeyList, useLockScroll, useLuckyDraw, useLuckyGrid, useLuckyWheel, useOptionKeys, usePageScroll, usePointerDown, usePopper, useReachBottom, useResizeObserver, useRtl, useScrollSide, useScrollSpy, useSimulatedClick, useSimulatedDblClick, useSimulatedPress, useSingleTask, useSlotMachine, useStopMovedClick, useTimeout, useTimeoutLoading, useWindowResize, useZIndex };
|
package/utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createBem, createBemStruct, cssVar, cssVarName, defaultBemConfig } from "./bem.js";
|
|
2
|
-
import { clamp, formatNumber, getDecimalsLength, inRange, looseToNumber, mround, random, round } from "./number.js";
|
|
2
|
+
import { clamp, compactNumber, formatNumber, formatThousands, getDecimalsLength, inRange, looseToNumber, mround, random, round, truncToFixed } from "./number.js";
|
|
3
3
|
import { baseLunarYear, earthlyBranches, formatDate, getDayOfYear, getDaysAfterLastDay, getDaysBeforeFirstDay, getDaysInMonth, getDaysSinceUnixEpoch, getFirstDayWeekday, getLunarDayName, getLunarHourName, getLunarLeapMonth, getLunarLeapMonthDays, getLunarMonthDays, getLunarMonthName, getLunarYearDays, getLunarYearName, getNextMonthDate, getNextMonthHeadDays, getPrevMonthDate, getPrevMonthTailDays, heavenlyStems, isLeapYear, lunarDayNames, lunarInfo, lunarMonthNames, lunarToSolar, lunarYearNames, minmaxDate, parseDate, solarToLunar, springFestivals, toDate, toDateNumber, toDateString, toMonthNumber } from "./date.js";
|
|
4
4
|
import { checkRtl, getScrollTop, toTouchEvent } from "./dom.js";
|
|
5
5
|
import { chooseFile, getFileName, imageDataToDataURL, isFileUrl, isImageFile, isImageUrl, isVideoFile, isVideoUrl, loadImage, readFileContent } from "./file.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, 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 };
|
|
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 };
|
package/utils/number.d.ts
CHANGED
|
@@ -30,3 +30,21 @@ export declare function looseToNumber(val: any): any;
|
|
|
30
30
|
* 将任意字符的字符串格式化为数字字符串,可以指定是否允许小数和负数
|
|
31
31
|
*/
|
|
32
32
|
export declare function formatNumber(value: string, allowDot?: boolean, allowMinus?: boolean): string;
|
|
33
|
+
/**
|
|
34
|
+
* trunc 版本的 toFixed,避免四舍五入
|
|
35
|
+
* @param num
|
|
36
|
+
* @param decimals 小数位数
|
|
37
|
+
*/
|
|
38
|
+
export declare function truncToFixed(num: number, decimals?: number): string;
|
|
39
|
+
/**
|
|
40
|
+
* 通过添加单位缩写数字
|
|
41
|
+
* @param num
|
|
42
|
+
* @param decimals 小数位数
|
|
43
|
+
* @param keepZero 是否保留为0时的小数部分
|
|
44
|
+
*/
|
|
45
|
+
export declare function compactNumber(num: number | string, decimals?: number, keepZero?: boolean): string;
|
|
46
|
+
/**
|
|
47
|
+
* 将数字格式化为千分位格式
|
|
48
|
+
* @param num
|
|
49
|
+
*/
|
|
50
|
+
export declare function formatThousands(num?: number | string): string;
|
package/utils/number.js
CHANGED
|
@@ -58,5 +58,64 @@ function formatNumber(value, allowDot = true, allowMinus = true) {
|
|
|
58
58
|
else value = value.replace(/-/g, "");
|
|
59
59
|
return value;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* trunc 版本的 toFixed,避免四舍五入
|
|
63
|
+
* @param num
|
|
64
|
+
* @param decimals 小数位数
|
|
65
|
+
*/
|
|
66
|
+
function truncToFixed(num, decimals = 0) {
|
|
67
|
+
const n = Math.pow(10, decimals);
|
|
68
|
+
return (Math.trunc(num * n) / n).toFixed(decimals);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 通过添加单位缩写数字
|
|
72
|
+
* @param num
|
|
73
|
+
* @param decimals 小数位数
|
|
74
|
+
* @param keepZero 是否保留为0时的小数部分
|
|
75
|
+
*/
|
|
76
|
+
function compactNumber(num, decimals = 1, keepZero = false) {
|
|
77
|
+
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
|
+
const isNegative = num < 0;
|
|
98
|
+
if (isNegative) num = Math.abs(num);
|
|
99
|
+
let formattedNum = truncToFixed(num, decimals);
|
|
100
|
+
let selectedSymbol = "";
|
|
101
|
+
for (let i = 0; i < units.length; i++) if (num >= units[i].value) {
|
|
102
|
+
formattedNum = truncToFixed(num / units[i].value, decimals);
|
|
103
|
+
selectedSymbol = units[i].symbol;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
if (!keepZero) formattedNum = formattedNum.replace(/\.0+$/, "");
|
|
107
|
+
return (isNegative ? "-" : "") + formattedNum + selectedSymbol;
|
|
108
|
+
}
|
|
109
|
+
let numberFormat;
|
|
110
|
+
/**
|
|
111
|
+
* 将数字格式化为千分位格式
|
|
112
|
+
* @param num
|
|
113
|
+
*/
|
|
114
|
+
function formatThousands(num = 0) {
|
|
115
|
+
const n = typeof num === "string" ? Number.parseFloat(num) : num;
|
|
116
|
+
if (!Number.isFinite(n)) return "0";
|
|
117
|
+
if (!numberFormat) numberFormat = new Intl.NumberFormat("en-US", { style: "decimal" });
|
|
118
|
+
return numberFormat.format(n);
|
|
119
|
+
}
|
|
61
120
|
//#endregion
|
|
62
|
-
export { clamp, formatNumber, getDecimalsLength, inRange, looseToNumber, mround, random, round };
|
|
121
|
+
export { clamp, compactNumber, formatNumber, formatThousands, getDecimalsLength, inRange, looseToNumber, mround, random, round, truncToFixed };
|
package/use/useImperative.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Ref } from 'vue';
|
|
2
|
-
type ImperativeItem<T = any> = {
|
|
3
|
-
show: boolean;
|
|
4
|
-
imperative: T;
|
|
5
|
-
};
|
|
6
|
-
type AllImperatives<T = any> = Record<string, Record<string, ImperativeItem<T>[] | undefined> | undefined>;
|
|
7
|
-
export declare function useImperative<T = any>(name: string, imperative: T, id: Ref<string>): void;
|
|
8
|
-
export declare function getAvailableImperative<T = any>(name: string, id: string): T | void;
|
|
9
|
-
export declare function getImperatives<T = any>(name: string, id: string): ImperativeItem<T>[] | undefined;
|
|
10
|
-
export declare function getAllImperatives<T = any>(): AllImperatives<T>;
|
|
11
|
-
export {};
|
package/use/useImperative.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { onMounted, onUnmounted } from "vue";
|
|
2
|
-
//#region packages/sard/use/useImperative.ts
|
|
3
|
-
const allImperatives = {};
|
|
4
|
-
function useImperative(name, imperative, id) {
|
|
5
|
-
onMounted(() => {
|
|
6
|
-
if (id.value) {
|
|
7
|
-
const imperativeItems = (allImperatives[name] ??= {})[id.value] ??= [];
|
|
8
|
-
if (imperativeItems.findIndex((item) => item.imperative === imperative) === -1) imperativeItems.push({
|
|
9
|
-
imperative,
|
|
10
|
-
show: true
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
onUnmounted(() => {
|
|
15
|
-
if (id.value) {
|
|
16
|
-
const imperativeItems = allImperatives[name]?.[id.value];
|
|
17
|
-
if (imperativeItems) {
|
|
18
|
-
const index = imperativeItems.findIndex((item) => item.imperative === imperative);
|
|
19
|
-
if (index !== -1) {
|
|
20
|
-
imperativeItems.splice(index, 1);
|
|
21
|
-
if (imperativeItems.length === 0) delete allImperatives[name]?.[id.value];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
function getAvailableImperative(name, id) {
|
|
28
|
-
const imperativeItems = allImperatives[name]?.[id];
|
|
29
|
-
if (imperativeItems) {
|
|
30
|
-
for (let i = imperativeItems.length - 1; i >= 0; i--) {
|
|
31
|
-
const imperativeItem = imperativeItems[i];
|
|
32
|
-
if (imperativeItem && imperativeItem.show) return imperativeItem.imperative;
|
|
33
|
-
}
|
|
34
|
-
return imperativeItems[imperativeItems.length - 1]?.imperative;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function getImperatives(name, id) {
|
|
38
|
-
return allImperatives[name]?.[id];
|
|
39
|
-
}
|
|
40
|
-
function getAllImperatives() {
|
|
41
|
-
return allImperatives;
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
export { getAllImperatives, getAvailableImperative, getImperatives, useImperative };
|