UNPKG

tdesign-mobile-vue

Version:
150 lines (146 loc) 5.64 kB
/** * tdesign v1.13.2 * (c) 2026 TDesign Group * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, toRefs, computed, createVNode, isVNode, Fragment, h } from 'vue'; import { Button } from '../button/index.js'; import { Badge } from '../badge/index.js'; import { useTNodeDefault } from '../hooks/tnode.js'; import { usePrefixClass } from '../hooks/useClass.js'; import '../button/button.js'; import '../loading/index.js'; import '../loading/loading.js'; import '../loading/icon/gradient.js'; import '../_common/js/loading/circle-adapter.js'; import '../_common/js/utils/setStyle.js'; import '../_common/js/utils/helper.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/objectWithoutProperties'; import '@babel/runtime/helpers/slicedToArray'; import 'lodash-es'; import '../config.js'; import '../loading/icon/spinner.js'; import '../loading/props.js'; import '../shared/dom.js'; import '../hooks/render-tnode.js'; import '../_common/js/utils/general.js'; import '../config-provider/useConfig.js'; import '../config-provider/context.js'; import '../_common/js/global-config/mobile/default-config.js'; import '../_common/js/global-config/mobile/locale/zh_CN.js'; import '../_chunks/dep-4412ff17.js'; import '@babel/runtime/helpers/typeof'; import '../_chunks/dep-8e82f508.js'; import 'dayjs'; import '../loading/plugin.js'; import '../shared/component.js'; import '../button/props.js'; import '../form/hooks.js'; import '../shared/hover.js'; import '../badge/badge.js'; import '../badge/props.js'; function _isSlot(s) { return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s); } var TActionSheetList = defineComponent({ props: { items: { type: Array, required: true } }, emits: ["selected"], setup: function setup(props, _ref) { var emit = _ref.emit; var actionSheetClass = usePrefixClass("action-sheet"); var renderTNodeJSX = useTNodeDefault(); var _toRefs = toRefs(props), items = _toRefs.items; var handleSelected = function handleSelected(index) { emit("selected", index); }; var itemClasses = computed(function () { return _defineProperty({}, "".concat(actionSheetClass.value, "__list-item"), true); }); var renderTNode = function renderTNode(node) { if (!node) return null; if (typeof node === "function") { return node(h); } return node; }; return function () { var renderButtonNode = function renderButtonNode() { var renderContent = function renderContent(item) { var renderLabel = function renderLabel() { if (item.badge) { if (item.badge.dot || item.badge.count) { return createVNode(Badge, { "count": item.badge.count, "max-count": item.badge.maxCount || 99, "dot": item.badge.dot, "content": item.badge.content, "size": item.badge.size, "offset": item.badge.offset }, { default: function _default() { return [createVNode("span", { "class": "".concat(actionSheetClass.value, "__list-item-text") }, [" ", item.label])]; } }); } return renderTNodeJSX("badge", { defaultNode: createVNode("span", { "class": "".concat(actionSheetClass.value, "__list-item-text") }, [item.label]) }); } return createVNode("span", { "class": "".concat(actionSheetClass.value, "__list-item-text") }, [item.label]); }; var iconContent = renderTNode(item.icon); var suffixIconContent = renderTNode(item.suffixIcon); return createVNode(Fragment, null, [createVNode("div", { "class": "".concat(actionSheetClass.value, "__list-item-content") }, [iconContent && createVNode("span", { "class": "".concat(actionSheetClass.value, "__list-item-icon") }, [iconContent]), renderLabel(), suffixIconContent && createVNode("span", { "class": "".concat(actionSheetClass.value, "__list-item-icon ").concat(actionSheetClass.value, "__list-item-icon--suffix") }, [suffixIconContent])]), item.description && createVNode("div", { "class": "".concat(actionSheetClass.value, "__list-item-desc") }, [item.description])]); }; var buttonList = items.value.map(function (item, index) { var _slot; return createVNode(Button, { "key": index, "variant": "text", "block": true, "class": [itemClasses.value, _defineProperty({}, "".concat(actionSheetClass.value, "__list-item--disabled"), item.disabled)], "disabled": item.disabled, "style": { color: item.color }, "onClick": function onClick() { return handleSelected(index); } }, _isSlot(_slot = renderContent(item)) ? _slot : { default: function _default() { return [_slot]; } }); }); return buttonList; }; return createVNode("div", { "class": "".concat(actionSheetClass.value, "__list") }, [renderButtonNode()]); }; } }); export { TActionSheetList as default }; //# sourceMappingURL=action-sheet-list.js.map