sard 1.0.13 → 1.0.14
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/all-components.js +0 -2
- package/components/badge/index.css +1 -1
- package/components/index.d.ts +0 -1
- package/components/index.js +2 -3
- package/components/infinite-list/common.d.ts +5 -10
- package/components/infinite-list/common.js +1 -1
- package/components/infinite-list/index.css +0 -1
- package/components/infinite-list/infinite-list.vue.d.ts +5 -6
- package/components/infinite-list/infinite-list.vue.js +41 -82
- package/components/load-more/common.d.ts +9 -3
- package/components/load-more/common.js +9 -2
- package/components/load-more/index.d.ts +3 -2
- package/components/load-more/index.js +2 -2
- package/components/load-more/load-more.vue.d.ts +6 -6
- package/components/load-more/load-more.vue.js +33 -5
- package/components/pull-down-refresh/common.d.ts +1 -0
- package/components/pull-down-refresh/common.js +1 -1
- package/components/pull-down-refresh/pull-down-refresh.vue.d.ts +1 -0
- package/components/pull-down-refresh/pull-down-refresh.vue.js +27 -9
- package/components/select/common.d.ts +4 -4
- package/components/select/common.js +0 -1
- package/components/select/index.css +1 -1
- package/components/select/select.vue.d.ts +3 -5
- package/components/select/select.vue.js +14 -51
- package/components/select-input/common.d.ts +2 -2
- package/components/select-input/select-input.vue.d.ts +5 -3
- package/components/select-input/select-input.vue.js +29 -19
- package/components/select-popout/common.d.ts +3 -5
- package/components/select-popout/select-popout.vue.d.ts +5 -3
- package/components/select-popout/select-popout.vue.js +27 -20
- package/global.d.ts +0 -1
- package/index.css +1 -1
- package/index.js +2 -3
- package/package.json +1 -1
- package/use/useIntersectionObserver.d.ts +1 -0
- package/use/useIntersectionObserver.js +4 -1
- package/components/load-more/useLoadMore.d.ts +0 -22
- package/components/load-more/useLoadMore.js +0 -71
package/index.js
CHANGED
|
@@ -122,14 +122,13 @@ import { FormItemPlain, FormPlain } from "./components/form-plain/index.js";
|
|
|
122
122
|
import { Grid, GridItem } from "./components/grid/index.js";
|
|
123
123
|
import { Image } from "./components/image/index.js";
|
|
124
124
|
import { Indexes, IndexesAnchor, IndexesNav } from "./components/indexes/index.js";
|
|
125
|
-
import { useLoadMore } from "./components/load-more/useLoadMore.js";
|
|
126
|
-
import { InfiniteList } from "./components/infinite-list/index.js";
|
|
127
125
|
import { Input } from "./components/input/index.js";
|
|
128
126
|
import { plateEnglishLetterKeys, plateProvinceKeys, plateSuffixKeys } from "./components/keyboard/common.js";
|
|
129
127
|
import { Keyboard } from "./components/keyboard/index.js";
|
|
130
128
|
import { KeyboardPopout } from "./components/keyboard-popout/index.js";
|
|
131
129
|
import { Col, Row } from "./components/layout/index.js";
|
|
132
130
|
import { List, ListItem } from "./components/list/index.js";
|
|
131
|
+
import { LoadMoreStatus } from "./components/load-more/common.js";
|
|
133
132
|
import { LoadMore } from "./components/load-more/index.js";
|
|
134
133
|
import { Loading } from "./components/loading/index.js";
|
|
135
134
|
import { Marquee } from "./components/marquee/index.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, 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, FloatingBubble, FloatingPanel, Form, FormItem, FormItemPlain, FormPlain, Friction, Grid, GridItem, Image, Indexes, IndexesAnchor, IndexesNav,
|
|
219
|
+
export { ADD_SWIPER_CONTEXT_KEY, ALPHANUMERIC_CHARS, Accordion, AccordionItem, ActionSheet, ActionSheetItem, Alert, Avatar, AvatarGroup, BackTop, Badge, Barcode, BarcodeFormatList, BarcodeTextPositionList, Button, Calendar, CalendarInput, CalendarPopout, 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, 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, Space, 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, 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, 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, spaceSizes, 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/package.json
CHANGED
|
@@ -4,6 +4,7 @@ export interface UseIntersectionObserverOptions {
|
|
|
4
4
|
root?: MaybeRefOrGetter<Element | Document | Window | null | undefined>;
|
|
5
5
|
rootMargin?: MaybeRefOrGetter<string>;
|
|
6
6
|
threshold?: MaybeRefOrGetter<number | number[]>;
|
|
7
|
+
disabled?: MaybeRefOrGetter<boolean | null | undefined>;
|
|
7
8
|
}
|
|
8
9
|
export interface UseIntersectionObserverReturn {
|
|
9
10
|
isIntersecting: Ref<boolean>;
|
|
@@ -9,6 +9,7 @@ function useIntersectionObserver(options = {}) {
|
|
|
9
9
|
const rootMargin = computed(() => toValue(options.rootMargin));
|
|
10
10
|
const threshold = computed(() => toValue(options.threshold));
|
|
11
11
|
const target = computed(() => toValue(options.target));
|
|
12
|
+
const disabled = computed(() => toValue(options.disabled));
|
|
12
13
|
const isIntersecting = ref(false);
|
|
13
14
|
const intersectionRatio = ref(0);
|
|
14
15
|
let observer = null;
|
|
@@ -26,6 +27,7 @@ function useIntersectionObserver(options = {}) {
|
|
|
26
27
|
};
|
|
27
28
|
const createObserver = () => {
|
|
28
29
|
destroyObserver();
|
|
30
|
+
if (disabled.value) return;
|
|
29
31
|
observer = new IntersectionObserver(callback, {
|
|
30
32
|
root: root.value,
|
|
31
33
|
rootMargin: rootMargin.value,
|
|
@@ -49,7 +51,8 @@ function useIntersectionObserver(options = {}) {
|
|
|
49
51
|
watch([
|
|
50
52
|
root,
|
|
51
53
|
rootMargin,
|
|
52
|
-
threshold
|
|
54
|
+
threshold,
|
|
55
|
+
disabled
|
|
53
56
|
], () => {
|
|
54
57
|
createObserver();
|
|
55
58
|
}, {
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 以 hook 的方式组织 LoadMore 的逻辑
|
|
3
|
-
*/
|
|
4
|
-
import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
|
|
5
|
-
import type { LoadMoreStatus } from './common';
|
|
6
|
-
export interface UseLoadMoreOptions {
|
|
7
|
-
request: (page: number, isRefresh: boolean) => Promise<boolean>;
|
|
8
|
-
rootMargin?: MaybeRefOrGetter<string>;
|
|
9
|
-
root?: MaybeRefOrGetter<Element | Document | Window | null | undefined>;
|
|
10
|
-
target?: MaybeRefOrGetter<Element | null>;
|
|
11
|
-
disabled?: MaybeRefOrGetter<boolean>;
|
|
12
|
-
}
|
|
13
|
-
export interface UseLoadMoreReturn {
|
|
14
|
-
status: Ref<LoadMoreStatus>;
|
|
15
|
-
isLoading: ComputedRef<boolean>;
|
|
16
|
-
isRefreshing: ComputedRef<boolean>;
|
|
17
|
-
onLoadMore: () => void;
|
|
18
|
-
onReload: () => void;
|
|
19
|
-
currentPage: Ref<number, number>;
|
|
20
|
-
refresh: (force?: boolean) => Promise<void | null>;
|
|
21
|
-
}
|
|
22
|
-
export declare function useLoadMore(options: UseLoadMoreOptions): UseLoadMoreReturn;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { useIntersectionObserver } from "../../use/useIntersectionObserver.js";
|
|
2
|
-
import { computed, ref, toValue, watch } from "vue";
|
|
3
|
-
//#region packages/sard/components/load-more/useLoadMore.ts
|
|
4
|
-
/**
|
|
5
|
-
* 以 hook 的方式组织 LoadMore 的逻辑
|
|
6
|
-
*/
|
|
7
|
-
function useLoadMore(options) {
|
|
8
|
-
const status = ref("incomplete");
|
|
9
|
-
const currentPage = ref(1);
|
|
10
|
-
const isRefreshing = ref(false);
|
|
11
|
-
const disabled = computed(() => toValue(options.disabled));
|
|
12
|
-
const { rootMargin = "0px 0px 100px", root, target } = options;
|
|
13
|
-
let firstTime = false;
|
|
14
|
-
let currentPromise = null;
|
|
15
|
-
const loadMoreFetch = async (page) => {
|
|
16
|
-
if (status.value === "loading") return currentPromise;
|
|
17
|
-
firstTime = true;
|
|
18
|
-
status.value = "loading";
|
|
19
|
-
currentPage.value = page;
|
|
20
|
-
return currentPromise = options.request(page, isRefreshing.value).then((loaded) => {
|
|
21
|
-
isRefreshing.value = false;
|
|
22
|
-
status.value = loaded ? "complete" : "incomplete";
|
|
23
|
-
if (!loaded) setTimeout(() => {
|
|
24
|
-
if (status.value === "incomplete" && isIntersecting.value) onLoadMore();
|
|
25
|
-
}, 30);
|
|
26
|
-
}).catch(() => {
|
|
27
|
-
isRefreshing.value = false;
|
|
28
|
-
status.value = "error";
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
const refresh = async (force) => {
|
|
32
|
-
if (!disabled.value) {
|
|
33
|
-
if (force || status.value !== "loading") {
|
|
34
|
-
isRefreshing.value = true;
|
|
35
|
-
return loadMoreFetch(1);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const onLoadMore = () => {
|
|
40
|
-
if (!disabled.value) loadMoreFetch(currentPage.value + 1);
|
|
41
|
-
};
|
|
42
|
-
const onReload = () => {
|
|
43
|
-
if (!disabled.value) loadMoreFetch(currentPage.value);
|
|
44
|
-
};
|
|
45
|
-
const { isIntersecting } = useIntersectionObserver({
|
|
46
|
-
root,
|
|
47
|
-
rootMargin,
|
|
48
|
-
threshold: 0,
|
|
49
|
-
target
|
|
50
|
-
});
|
|
51
|
-
watch([
|
|
52
|
-
disabled,
|
|
53
|
-
status,
|
|
54
|
-
isIntersecting
|
|
55
|
-
], () => {
|
|
56
|
-
setTimeout(() => {
|
|
57
|
-
if (!disabled.value && status.value === "incomplete" && isIntersecting.value) loadMoreFetch(firstTime ? currentPage.value + 1 : currentPage.value);
|
|
58
|
-
}, 30);
|
|
59
|
-
});
|
|
60
|
-
return {
|
|
61
|
-
status,
|
|
62
|
-
isLoading: computed(() => status.value === "loading"),
|
|
63
|
-
isRefreshing: computed(() => isRefreshing.value),
|
|
64
|
-
onLoadMore,
|
|
65
|
-
onReload,
|
|
66
|
-
currentPage,
|
|
67
|
-
refresh
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
export { useLoadMore };
|