UNPKG

tdesign-mobile-vue

Version:
155 lines (151 loc) 6.11 kB
/** * tdesign v1.7.0 * (c) 2024 TDesign Group * @license MIT */ import { defineComponent, ref, createVNode } from 'vue'; import { useWindowSize, useEventListener } from '@vueuse/core'; import { useTNodeJSX } from '../hooks/tnode.mjs'; import { Loading } from '../loading/index.mjs'; import config from '../config.mjs'; import props from './props.mjs'; import '../shared/index.mjs'; import { usePrefixClass } from '../hooks/useClass.mjs'; import { u as useConfig } from '../_chunks/dep-b9b8ead5.mjs'; import { useScrollParent } from '../shared/useScrollParent/index.mjs'; import '../_chunks/dep-91d696ea.mjs'; import '../_chunks/dep-8bf3054e.mjs'; import '../_chunks/dep-3d249f65.mjs'; import '../_chunks/dep-620d73f7.mjs'; import '../_chunks/dep-e6c129ab.mjs'; import '../_chunks/dep-60cadef8.mjs'; import '../_chunks/dep-8140c29b.mjs'; import '../_chunks/dep-0d52e58f.mjs'; import '../_chunks/dep-019e292f.mjs'; import '../_chunks/dep-32364550.mjs'; import '../_chunks/dep-a836a38c.mjs'; import '../_chunks/dep-9b2de386.mjs'; import '../_chunks/dep-0ea7bbde.mjs'; import '../_chunks/dep-b437ef0b.mjs'; import '../_chunks/dep-6917b9bc.mjs'; import '../hooks/render-tnode.mjs'; import '../_chunks/dep-40507aac.mjs'; import '../_chunks/dep-2bce42ea.mjs'; import '../_chunks/dep-e57d46f3.mjs'; import '../_chunks/dep-4f44985d.mjs'; import '../_chunks/dep-6bc862af.mjs'; import '../_chunks/dep-b84be35c.mjs'; import '../_chunks/dep-08bc7a4c.mjs'; import '../_chunks/dep-6303c50c.mjs'; import '../loading/loading.mjs'; import '../_chunks/dep-219bb5a7.mjs'; import '../loading/icon/gradient.mjs'; import '../_common/js/loading/circle-adapter.mjs'; import '../_common/js/utils/set-style.mjs'; import '../_common/js/utils/helper.mjs'; import '../_chunks/dep-f0f403be.mjs'; import '../_chunks/dep-8d37dbf8.mjs'; import '../_chunks/dep-8ece47c6.mjs'; import '../_chunks/dep-cd74809c.mjs'; import '../_chunks/dep-74a5dff9.mjs'; import '../_chunks/dep-1bbfa76e.mjs'; import '../_chunks/dep-52fdc8e1.mjs'; import '../loading/icon/spinner.mjs'; import '../loading/props.mjs'; import '../shared/dom.mjs'; import './style/css.mjs'; import '../loading/type.mjs'; import '../loading/plugin.mjs'; import '../_chunks/dep-ac139980.mjs'; import '../_chunks/dep-d2161895.mjs'; import '../_chunks/dep-89951f45.mjs'; import '../_chunks/dep-4931819d.mjs'; import '../_chunks/dep-10f4d030.mjs'; import '../_chunks/dep-8ee6f5cd.mjs'; import '../_chunks/dep-933f3a85.mjs'; import '../_chunks/dep-154c1925.mjs'; import '../_chunks/dep-ba131d9c.mjs'; import '../_chunks/dep-007f294e.mjs'; import '../_common/js/global-config/mobile/default-config.mjs'; import '../_common/js/global-config/mobile/locale/zh_CN.mjs'; import '../_chunks/dep-161f0c44.mjs'; import '../_chunks/dep-5fd0eaa4.mjs'; import '../_chunks/dep-3c59bf72.mjs'; import '../_chunks/dep-6c53a3e4.mjs'; import '../config-provider/type.mjs'; import '../shared/component.mjs'; import '../shared/functions.mjs'; import '../shared/util.mjs'; import '../shared/constants.mjs'; import '../shared/render.mjs'; import '../shared/render-tnode.mjs'; import '../shared/useToggle/index.mjs'; import '../shared/useCountDown/index.mjs'; import '../_chunks/dep-80e4de18.mjs'; import '../shared/useCountDown/utils.mjs'; import '../shared/useDefault/index.mjs'; import '../shared/useChildSlots/index.mjs'; import '../shared/useVModel/index.mjs'; import '../shared/useTouch/index.mjs'; import '../shared/useExpose/index.mjs'; import '../shared/useTest/index.mjs'; import '../shared/useClickAway/index.mjs'; import '../shared/useGesture/index.mjs'; import '@use-gesture/vanilla'; import '../shared/hover.mjs'; var prefix = config.prefix; var _List = defineComponent({ name: "".concat(prefix, "-list"), components: { TLoading: Loading }, props: props, emits: ["load-more", "scroll"], setup: function setup(props2, _ref) { var slots = _ref.slots; var listClass = usePrefixClass("list"); var _useConfig = useConfig("list"), globalConfig = _useConfig.globalConfig; var renderTNodeJSX = useTNodeJSX(); var LOADING_TEXT_MAP = { loading: globalConfig.value.loading, "load-more": globalConfig.value.loadingMoreText }; var root = ref(); var scrollParent = useScrollParent(root); var _useWindowSize = useWindowSize(), height = _useWindowSize.height; var onLoadMore = function onLoadMore(e) { if (props2.asyncLoading === "load-more") { var _props2$onLoadMore; (_props2$onLoadMore = props2.onLoadMore) === null || _props2$onLoadMore === void 0 || _props2$onLoadMore.call(props2); } }; var handleScroll = function handleScroll(e) { var _props2$onScroll; var scrollHeight = e.target.scrollHeight || Math.max(document.documentElement.scrollHeight, document.body.scrollHeight); var scrollTop = e.target.scrollTop || document.documentElement.scrollTop || document.body.scrollTop; var offsetHeight = e.target.offsetHeight || height.value; (_props2$onScroll = props2.onScroll) === null || _props2$onScroll === void 0 || _props2$onScroll.call(props2, scrollHeight - (scrollTop + offsetHeight), scrollTop); }; useEventListener(scrollParent, "scroll", handleScroll); return function () { var headerContent = renderTNodeJSX("header"); var footerContent = renderTNodeJSX("footer"); return createVNode("div", { "ref": root, "class": listClass.value, "onScroll": handleScroll }, [headerContent, slots.default && slots.default(), createVNode("div", { "class": "".concat(listClass.value, "__loading--wrapper"), "onClick": onLoadMore }, [typeof props2.asyncLoading === "string" && ["loading", "load-more"].includes(props2.asyncLoading) && createVNode(Loading, { "indicator": props2.asyncLoading === "loading", "text": typeof props2.asyncLoading === "string" ? LOADING_TEXT_MAP[props2.asyncLoading] : "", "class": "".concat(listClass.value, "__loading") }, null)]), footerContent]); }; } }); export { _List as default }; //# sourceMappingURL=list.mjs.map