sard 1.0.23 → 1.0.25
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/calendar/calendar.vue.d.ts +4 -4
- package/components/calendar-input/calendar-input.vue.d.ts +6 -6
- package/components/calendar-input/calendar-input.vue.js +1 -1
- package/components/calendar-popout/calendar-popout.vue.d.ts +6 -6
- package/components/date-strip/date-strip.vue.d.ts +4 -4
- package/components/datetime-picker/common.js +1 -1
- package/components/datetime-picker-input/datetime-picker-input.vue.js +1 -1
- package/components/datetime-range-picker-input/datetime-range-picker-input.vue.js +1 -1
- package/components/input/input.vue.js +1 -1
- package/components/stepper/stepper.vue.js +1 -1
- package/components/swiper/useSwiper.js +1 -1
- package/components/upload/upload.vue.js +1 -1
- package/index.js +3 -3
- package/package.json +1 -1
- package/utils/date.d.ts +4 -1
- package/utils/date.js +6 -0
- package/utils/index.js +3 -3
- package/utils/number.d.ts +2 -2
- package/utils/number.js +7 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type CalendarProps } from './common';
|
|
2
2
|
declare const __VLS_export: import("vue").DefineComponent<CalendarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
3
|
-
change: (value: string | string[] | Date
|
|
4
|
-
"update:modelValue": (value: string | string[] | Date
|
|
3
|
+
change: (value: string | Date | string[] | Date[]) => any;
|
|
4
|
+
"update:modelValue": (value: string | Date | string[] | Date[]) => any;
|
|
5
5
|
}, string, import("vue").PublicProps, Readonly<CalendarProps> & Readonly<{
|
|
6
|
-
onChange?: ((value: string | string[] | Date
|
|
7
|
-
"onUpdate:modelValue"?: ((value: string | string[] | Date
|
|
6
|
+
onChange?: ((value: string | Date | string[] | Date[]) => any) | undefined;
|
|
7
|
+
"onUpdate:modelValue"?: ((value: string | Date | string[] | Date[]) => any) | undefined;
|
|
8
8
|
}>, {
|
|
9
9
|
min: Date;
|
|
10
10
|
max: Date;
|
|
@@ -2,7 +2,7 @@ import { type CalendarType } from '../calendar/common';
|
|
|
2
2
|
import { type CalendarInputProps, type CalendarInputSlots } from './common';
|
|
3
3
|
type __VLS_Slots = CalendarInputSlots;
|
|
4
4
|
declare const __VLS_base: import("vue").DefineComponent<CalendarInputProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
5
|
-
change: (value: string | string[] | Date
|
|
5
|
+
change: (value: string | Date | string[] | Date[] | undefined) => any;
|
|
6
6
|
"before-enter": (el: Element) => any;
|
|
7
7
|
enter: (el: Element) => any;
|
|
8
8
|
"after-enter": (el: Element) => any;
|
|
@@ -13,10 +13,10 @@ declare const __VLS_base: import("vue").DefineComponent<CalendarInputProps, {},
|
|
|
13
13
|
"leave-cancelled": (el: Element) => any;
|
|
14
14
|
"visible-hook": (name: import("../index.ts").MotionHookName, el: Element) => any;
|
|
15
15
|
"update:visible": (visible: boolean) => any;
|
|
16
|
-
"update:modelValue": (value: string | string[] | Date
|
|
17
|
-
confirm: (value: string | string[] | Date
|
|
16
|
+
"update:modelValue": (value: string | Date | string[] | Date[] | undefined) => any;
|
|
17
|
+
confirm: (value: string | Date | string[] | Date[] | undefined) => any;
|
|
18
18
|
}, string, import("vue").PublicProps, Readonly<CalendarInputProps> & Readonly<{
|
|
19
|
-
onChange?: ((value: string | string[] | Date
|
|
19
|
+
onChange?: ((value: string | Date | string[] | Date[] | undefined) => any) | undefined;
|
|
20
20
|
"onBefore-enter"?: ((el: Element) => any) | undefined;
|
|
21
21
|
onEnter?: ((el: Element) => any) | undefined;
|
|
22
22
|
"onAfter-enter"?: ((el: Element) => any) | undefined;
|
|
@@ -27,8 +27,8 @@ declare const __VLS_base: import("vue").DefineComponent<CalendarInputProps, {},
|
|
|
27
27
|
"onLeave-cancelled"?: ((el: Element) => any) | undefined;
|
|
28
28
|
"onVisible-hook"?: ((name: import("../index.ts").MotionHookName, el: Element) => any) | undefined;
|
|
29
29
|
"onUpdate:visible"?: ((visible: boolean) => any) | undefined;
|
|
30
|
-
"onUpdate:modelValue"?: ((value: string | string[] | Date
|
|
31
|
-
onConfirm?: ((value: string | string[] | Date
|
|
30
|
+
"onUpdate:modelValue"?: ((value: string | Date | string[] | Date[] | undefined) => any) | undefined;
|
|
31
|
+
onConfirm?: ((value: string | Date | string[] | Date[] | undefined) => any) | undefined;
|
|
32
32
|
}>, {
|
|
33
33
|
title: string;
|
|
34
34
|
min: Date;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { formatDate, parseDate } from "../../utils/date.js";
|
|
2
1
|
import { isString } from "../../utils/is.js";
|
|
2
|
+
import { formatDate, parseDate } from "../../utils/date.js";
|
|
3
3
|
import { useTranslateWithPrefix } from "../../locale/index.js";
|
|
4
4
|
import popout_input_default from "../popout-input/popout-input.vue.js";
|
|
5
5
|
import calendar_popout_default from "../calendar-popout/calendar-popout.vue.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CalendarPopoutProps, type CalendarPopoutSlots } from './common';
|
|
2
2
|
type __VLS_Slots = CalendarPopoutSlots;
|
|
3
3
|
declare const __VLS_base: import("vue").DefineComponent<CalendarPopoutProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
4
|
-
change: (value: string | string[] | Date
|
|
4
|
+
change: (value: string | Date | string[] | Date[] | undefined) => any;
|
|
5
5
|
"before-enter": (el: Element) => any;
|
|
6
6
|
enter: (el: Element) => any;
|
|
7
7
|
"after-enter": (el: Element) => any;
|
|
@@ -12,10 +12,10 @@ declare const __VLS_base: import("vue").DefineComponent<CalendarPopoutProps, {},
|
|
|
12
12
|
"leave-cancelled": (el: Element) => any;
|
|
13
13
|
"visible-hook": (name: import("../index.ts").MotionHookName, el: Element) => any;
|
|
14
14
|
"update:visible": (visible: boolean) => any;
|
|
15
|
-
"update:modelValue": (value: string | string[] | Date
|
|
16
|
-
confirm: (value: string | string[] | Date
|
|
15
|
+
"update:modelValue": (value: string | Date | string[] | Date[] | undefined) => any;
|
|
16
|
+
confirm: (value: string | Date | string[] | Date[] | undefined) => any;
|
|
17
17
|
}, string, import("vue").PublicProps, Readonly<CalendarPopoutProps> & Readonly<{
|
|
18
|
-
onChange?: ((value: string | string[] | Date
|
|
18
|
+
onChange?: ((value: string | Date | string[] | Date[] | undefined) => any) | undefined;
|
|
19
19
|
"onBefore-enter"?: ((el: Element) => any) | undefined;
|
|
20
20
|
onEnter?: ((el: Element) => any) | undefined;
|
|
21
21
|
"onAfter-enter"?: ((el: Element) => any) | undefined;
|
|
@@ -26,8 +26,8 @@ declare const __VLS_base: import("vue").DefineComponent<CalendarPopoutProps, {},
|
|
|
26
26
|
"onLeave-cancelled"?: ((el: Element) => any) | undefined;
|
|
27
27
|
"onVisible-hook"?: ((name: import("../index.ts").MotionHookName, el: Element) => any) | undefined;
|
|
28
28
|
"onUpdate:visible"?: ((visible: boolean) => any) | undefined;
|
|
29
|
-
"onUpdate:modelValue"?: ((value: string | string[] | Date
|
|
30
|
-
onConfirm?: ((value: string | string[] | Date
|
|
29
|
+
"onUpdate:modelValue"?: ((value: string | Date | string[] | Date[] | undefined) => any) | undefined;
|
|
30
|
+
onConfirm?: ((value: string | Date | string[] | Date[] | undefined) => any) | undefined;
|
|
31
31
|
}>, {
|
|
32
32
|
title: string;
|
|
33
33
|
min: Date;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type DateStripProps } from './common';
|
|
2
2
|
import { type CalendarDay } from '../calendar';
|
|
3
3
|
declare const __VLS_export: import("vue").DefineComponent<DateStripProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
4
|
-
change: (value: string | string[] | Date
|
|
5
|
-
"update:modelValue": (value: string | string[] | Date
|
|
4
|
+
change: (value: string | Date | string[] | Date[]) => any;
|
|
5
|
+
"update:modelValue": (value: string | Date | string[] | Date[]) => any;
|
|
6
6
|
}, string, import("vue").PublicProps, Readonly<DateStripProps> & Readonly<{
|
|
7
|
-
onChange?: ((value: string | string[] | Date
|
|
8
|
-
"onUpdate:modelValue"?: ((value: string | string[] | Date
|
|
7
|
+
onChange?: ((value: string | Date | string[] | Date[]) => any) | undefined;
|
|
8
|
+
"onUpdate:modelValue"?: ((value: string | Date | string[] | Date[]) => any) | undefined;
|
|
9
9
|
}>, {
|
|
10
10
|
filter: (date: Date) => boolean;
|
|
11
11
|
min: Date;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { isDate } from "../../utils/is.js";
|
|
1
2
|
import { clamp } from "../../utils/number.js";
|
|
2
3
|
import { formatDate, getDaysInMonth, getLunarDayName, getLunarLeapMonth, getLunarLeapMonthDays, getLunarMonthDays, getLunarMonthName, solarToLunar, toDate } from "../../utils/date.js";
|
|
3
|
-
import { isDate } from "../../utils/is.js";
|
|
4
4
|
//#region packages/sard/components/datetime-picker/common.ts
|
|
5
5
|
const defaultDatetimePickerProps = {
|
|
6
6
|
type: "yMd",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { formatDate, parseDate } from "../../utils/date.js";
|
|
2
1
|
import { isString } from "../../utils/is.js";
|
|
2
|
+
import { formatDate, parseDate } from "../../utils/date.js";
|
|
3
3
|
import popout_input_default from "../popout-input/popout-input.vue.js";
|
|
4
4
|
import { partitionPopoutInputProps, usePopoutInput } from "../popout-input/usePopoutInput.js";
|
|
5
5
|
import datetime_picker_popout_default from "../datetime-picker-popout/datetime-picker-popout.vue.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { formatDate, parseDate } from "../../utils/date.js";
|
|
2
1
|
import { isString } from "../../utils/is.js";
|
|
2
|
+
import { formatDate, parseDate } from "../../utils/date.js";
|
|
3
3
|
import { useTranslateWithPrefix } from "../../locale/index.js";
|
|
4
4
|
import popout_input_default from "../popout-input/popout-input.vue.js";
|
|
5
5
|
import { partitionPopoutInputProps, usePopoutInput } from "../popout-input/usePopoutInput.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createBem } from "../../utils/bem.js";
|
|
2
|
-
import { clamp, formatNumber } from "../../utils/number.js";
|
|
3
2
|
import { isNullish } from "../../utils/is.js";
|
|
3
|
+
import { clamp, formatNumber } from "../../utils/number.js";
|
|
4
4
|
import { usePointerDown } from "../../use/usePointerDown.js";
|
|
5
5
|
import { useSimulatedClick } from "../../use/useSimulatedClick.js";
|
|
6
6
|
import { useComposition } from "../../use/useComposition.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createBem } from "../../utils/bem.js";
|
|
2
|
-
import { clamp } from "../../utils/number.js";
|
|
3
2
|
import { isNullish } from "../../utils/is.js";
|
|
3
|
+
import { clamp } from "../../utils/number.js";
|
|
4
4
|
import { usePointerDown } from "../../use/usePointerDown.js";
|
|
5
5
|
import { useSimulatedPress } from "../../use/useSimulatedPress.js";
|
|
6
6
|
import { useFormContext } from "../form/common.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { clamp } from "../../utils/number.js";
|
|
2
1
|
import { isNullish } from "../../utils/is.js";
|
|
2
|
+
import { clamp } from "../../utils/number.js";
|
|
3
3
|
import { usePointerDown } from "../../use/usePointerDown.js";
|
|
4
4
|
import { useInitialVelocity } from "../../use/useInitialVelocity.js";
|
|
5
5
|
import { useResizeObserver } from "../../use/useResizeObserver.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createBem } from "../../utils/bem.js";
|
|
2
|
-
import { chooseFile, isImageFile, isImageUrl } from "../../utils/file.js";
|
|
3
2
|
import { isFunction } from "../../utils/is.js";
|
|
3
|
+
import { chooseFile, isImageFile, isImageUrl } from "../../utils/file.js";
|
|
4
4
|
import { toArray } from "../../utils/array.js";
|
|
5
5
|
import { useFormContext, useFormItemContext } from "../form/common.js";
|
|
6
6
|
import { previewImage } from "../preview-image/imperative.js";
|
package/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createBem, createBemStruct, cssVar, cssVarName, defaultBemConfig } from "./utils/bem.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isBoolean, isConfigObject, isDate, isEmptyArray, isFunction, isNoEmptyArray, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isString, isUndefined } from "./utils/is.js";
|
|
3
|
+
import { clamp, compactNumber, formatNumber, formatThousands, getDecimalsLength, inRange, looseToNumber, mround, random, round, truncToFixed } from "./utils/number.js";
|
|
3
4
|
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
5
|
import { checkRtl, getScrollTop, toTouchEvent } from "./utils/dom.js";
|
|
5
6
|
import { chooseFile, getFileName, imageDataToDataURL, isFileUrl, isImageFile, isImageUrl, isVideoFile, isVideoUrl, loadImage, readFileContent } from "./utils/file.js";
|
|
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
9
|
import { assignDeep, chainGet, chainSet, deepClone, extend, nestedToMulti, omit, partition, pick, treeToMap } from "./utils/object.js";
|
|
@@ -216,4 +216,4 @@ function prepareEnvironment() {
|
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
218
|
//#endregion
|
|
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,
|
|
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/utils/date.d.ts
CHANGED
|
@@ -54,7 +54,10 @@ export declare function formatDate(date: Date, format?: string): string;
|
|
|
54
54
|
* 解析日期的字符串表示形式,并返回 Date 实例对象。
|
|
55
55
|
*/
|
|
56
56
|
export declare function parseDate(value: string, format?: string): Date;
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* 确保返回一个Date对象,可以传递时间戳(10位或13位,字符串或数字),或者传递特定格式的字符串,则使用 parseDate 解析。
|
|
59
|
+
*/
|
|
60
|
+
export declare function toDate(date: Date | string | number, valueFormat?: string): Date;
|
|
58
61
|
export declare function minmaxDate(date: Date, minDate: Date, maxDate: Date): Date;
|
|
59
62
|
export declare function getPrevMonthDate(date: Date): Date;
|
|
60
63
|
export declare function getNextMonthDate(date: Date): Date;
|
package/utils/date.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNumber } from "./is.js";
|
|
1
2
|
import { clamp } from "./number.js";
|
|
2
3
|
import { escapeRegExp } from "./regexp.js";
|
|
3
4
|
//#region packages/sard/utils/date.ts
|
|
@@ -175,8 +176,13 @@ function parseDate(value, format) {
|
|
|
175
176
|
});
|
|
176
177
|
return date;
|
|
177
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* 确保返回一个Date对象,可以传递时间戳(10位或13位,字符串或数字),或者传递特定格式的字符串,则使用 parseDate 解析。
|
|
181
|
+
*/
|
|
178
182
|
function toDate(date, valueFormat) {
|
|
179
183
|
if (date instanceof Date) return date;
|
|
184
|
+
if (isNumber(date)) return new Date(String(date).length === 10 ? date * 1e3 : date);
|
|
185
|
+
if ((date.length === 10 || date.length === 13) && /^\d+$/.test(date)) return /* @__PURE__ */ new Date(date.length === 10 ? +date * 1e3 : +date);
|
|
180
186
|
return parseDate(date, valueFormat);
|
|
181
187
|
}
|
|
182
188
|
function minmaxDate(date, minDate, maxDate) {
|
package/utils/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createBem, createBemStruct, cssVar, cssVarName, defaultBemConfig } from "./bem.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isBoolean, isConfigObject, isDate, isEmptyArray, isFunction, isNoEmptyArray, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isString, isUndefined } from "./is.js";
|
|
3
|
+
import { clamp, compactNumber, formatNumber, formatThousands, getDecimalsLength, inRange, looseToNumber, mround, random, round, truncToFixed } from "./number.js";
|
|
3
4
|
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
5
|
import { checkRtl, getScrollTop, toTouchEvent } from "./dom.js";
|
|
5
6
|
import { chooseFile, getFileName, imageDataToDataURL, isFileUrl, isImageFile, isImageUrl, isVideoFile, isVideoUrl, loadImage, readFileContent } from "./file.js";
|
|
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
9
|
import { assignDeep, chainGet, chainSet, deepClone, extend, nestedToMulti, omit, partition, pick, treeToMap } from "./object.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,
|
|
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
|
@@ -42,9 +42,9 @@ export declare function truncToFixed(num: number, decimals?: number): string;
|
|
|
42
42
|
* @param decimals 小数位数
|
|
43
43
|
* @param keepZero 是否保留为0时的小数部分
|
|
44
44
|
*/
|
|
45
|
-
export declare function
|
|
45
|
+
export declare function compactNumber(num: number | string, decimals?: number, keepZero?: boolean): string;
|
|
46
46
|
/**
|
|
47
47
|
* 将数字格式化为千分位格式
|
|
48
48
|
* @param num
|
|
49
49
|
*/
|
|
50
|
-
export declare function formatThousands(num?: number): string;
|
|
50
|
+
export declare function formatThousands(num?: number | string): string;
|
package/utils/number.js
CHANGED
|
@@ -73,8 +73,9 @@ function truncToFixed(num, decimals = 0) {
|
|
|
73
73
|
* @param decimals 小数位数
|
|
74
74
|
* @param keepZero 是否保留为0时的小数部分
|
|
75
75
|
*/
|
|
76
|
-
function
|
|
77
|
-
|
|
76
|
+
function compactNumber(num, decimals = 1, keepZero = false) {
|
|
77
|
+
num = typeof num === "string" ? Number.parseFloat(num) : num;
|
|
78
|
+
if (!Number.isFinite(num)) return "0";
|
|
78
79
|
const units = [
|
|
79
80
|
{
|
|
80
81
|
value: 0xe8d4a51000,
|
|
@@ -111,8 +112,10 @@ let numberFormat;
|
|
|
111
112
|
* @param num
|
|
112
113
|
*/
|
|
113
114
|
function formatThousands(num = 0) {
|
|
115
|
+
const n = typeof num === "string" ? Number.parseFloat(num) : num;
|
|
116
|
+
if (!Number.isFinite(n)) return "0";
|
|
114
117
|
if (!numberFormat) numberFormat = new Intl.NumberFormat("en-US", { style: "decimal" });
|
|
115
|
-
return numberFormat.format(
|
|
118
|
+
return numberFormat.format(n);
|
|
116
119
|
}
|
|
117
120
|
//#endregion
|
|
118
|
-
export {
|
|
121
|
+
export { clamp, compactNumber, formatNumber, formatThousands, getDecimalsLength, inRange, looseToNumber, mround, random, round, truncToFixed };
|