xdesign-vue-next
Version:
XDesign Component for vue-next
598 lines (580 loc) • 22.2 kB
JavaScript
/**
* xdesign v1.0.6
* (c) 2023 xdesign
* @license MIT
*/
import { createElementVNode, openBlock, createElementBlock, defineComponent, toRefs, ref, computed, watch, createVNode, mergeProps } from 'vue';
import { _ as __unplugin_components_3 } from '../_chunks/dep-8b4428a1.mjs';
import { _ as __unplugin_components_5 } from '../_chunks/dep-a2289dc5.mjs';
import { _ as __unplugin_components_2$1 } from '../_chunks/dep-6af44080.mjs';
import { _ as _objectWithoutProperties } from '../_chunks/dep-53e379cd.mjs';
import { _ as _slicedToArray } from '../_chunks/dep-32d4c595.mjs';
import '../_chunks/dep-10a947a6.mjs';
import { i as isNumber_1 } from '../_chunks/dep-23f91684.mjs';
import { usePrefixClass } from '../hooks/useConfig.mjs';
import { InputNumber } from '../input-number/index.mjs';
import { Select } from '../select/index.mjs';
import { InputAdornment } from '../input-adornment/index.mjs';
import props from './props.mjs';
import usePaginationClasses from './usePaginationClasses.mjs';
import useMoreAction from './useMoreAction.mjs';
import useVModel from '../hooks/useVModel.mjs';
import useDefaultValue from '../hooks/useDefaultValue.mjs';
import { useTNodeJSX } from '../hooks/tnode.mjs';
import { i as isObject_1 } from '../_chunks/dep-6ad18815.mjs';
import { useConfig } from '../config-provider/useConfig.mjs';
import '../_chunks/dep-89b966f4.mjs';
import '../_chunks/dep-b75d8d74.mjs';
import '../_chunks/dep-82805301.mjs';
import '../_chunks/dep-addc2a84.mjs';
import '../input-number/input-number.mjs';
import '../_chunks/dep-35169507.mjs';
import '../_chunks/dep-c4f9949a.mjs';
import '../_chunks/dep-cf7b0304.mjs';
import '../_chunks/dep-f9e836af.mjs';
import '../button/index.mjs';
import '../button/button.mjs';
import '../_chunks/dep-5bec687c.mjs';
import '../loading/index.mjs';
import '../loading/directive.mjs';
import '../loading/plugin.mjs';
import '../loading/loading.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-11fa9c2c.mjs';
import '../_chunks/dep-a95026f2.mjs';
import '../_chunks/dep-068e912d.mjs';
import '../_chunks/dep-5a2ce53e.mjs';
import '../_chunks/dep-1bae6a97.mjs';
import '../utils/dom.mjs';
import '../_chunks/dep-1cc1c24f.mjs';
import '../utils/easing.mjs';
import '../utils/render-tnode.mjs';
import '../_chunks/dep-9d7ebc32.mjs';
import '../_chunks/dep-69963a8c.mjs';
import '../_chunks/dep-6e7b37b8.mjs';
import '../_chunks/dep-e1ab85c5.mjs';
import '../_chunks/dep-5f0e0453.mjs';
import '../_chunks/dep-db381ece.mjs';
import '../_chunks/dep-5755c21c.mjs';
import '../_chunks/dep-8d1c9a23.mjs';
import '../_chunks/dep-dafada74.mjs';
import '../_chunks/dep-0e832fc7.mjs';
import '../_chunks/dep-a628549d.mjs';
import '../_chunks/dep-4903a8a8.mjs';
import '../_chunks/dep-7dcfa37a.mjs';
import '../_chunks/dep-f4eba04c.mjs';
import '../_chunks/dep-735bcd0d.mjs';
import '../_chunks/dep-765678ef.mjs';
import '../_chunks/dep-8db27830.mjs';
import '../_chunks/dep-ae4bffa5.mjs';
import '../loading/props.mjs';
import '../hooks/useTeleport.mjs';
import '../_chunks/dep-91ac8f71.mjs';
import '../_chunks/dep-c4737535.mjs';
import '../_chunks/dep-81c83986.mjs';
import '../_chunks/dep-6aa0223b.mjs';
import '../_chunks/dep-7f239c43.mjs';
import '../_chunks/dep-6f04869e.mjs';
import '../_chunks/dep-d32fbbb3.mjs';
import '../_chunks/dep-71f84cf2.mjs';
import '../_chunks/dep-03412fab.mjs';
import '../_chunks/dep-205ff58d.mjs';
import '../_chunks/dep-b09f48fa.mjs';
import '../_chunks/dep-26bf361a.mjs';
import '../_chunks/dep-3ec3335a.mjs';
import '../_chunks/dep-ed4e7c50.mjs';
import '../_chunks/dep-a666b9ad.mjs';
import '../_common/js/global-config/default-config.mjs';
import '../_common/js/global-config/locale/en_US.mjs';
import '../config-provider/type.mjs';
import '../utils/withInstall.mjs';
import './style/css.mjs';
import '../loading/type.mjs';
import '../button/props.mjs';
import '../hooks/useRipple.mjs';
import '../hooks/useKeepAnimation.mjs';
import '../utils/set-style.mjs';
import '../hooks/useDisabled.mjs';
import '../_chunks/dep-b9fae426.mjs';
import '../button/type.mjs';
import '../input/index.mjs';
import '../input/input.mjs';
import '../_chunks/dep-8b0014b3.mjs';
import '../_chunks/dep-84ddb5ec.mjs';
import '../input/props.mjs';
import '../form/hooks.mjs';
import '../input/useInput.mjs';
import '../form/const.mjs';
import '../hooks/index.mjs';
import '../hooks/icon.mjs';
import '../hooks/slot.mjs';
import '../hooks/useCommonClassName.mjs';
import '../hooks/useDestroyOnClose.mjs';
import '../hooks/useVirtualScroll.mjs';
import '../hooks/useImagePreviewUrl.mjs';
import '../_common/js/upload/utils.mjs';
import '../_common/js/log/log.mjs';
import '../input/useLengthLimit.mjs';
import '../_common/js/log/index.mjs';
import '../input/useInputEventHandler.mjs';
import '../input/useInputWidth.mjs';
import '../input/input-group.mjs';
import '../input/input-group-props.mjs';
import '../input/type.mjs';
import '../input-number/props.mjs';
import '../input-number/useInputNumber.mjs';
import '../_common/js/input-number/number.mjs';
import '../_common/js/input-number/large-number.mjs';
import '../input-number/type.mjs';
import '../select/select.mjs';
import '../_chunks/dep-abf7f90d.mjs';
import '../_chunks/dep-fa6608fd.mjs';
import '../_chunks/dep-cc9bfda3.mjs';
import '../_chunks/dep-b57a2815.mjs';
import '../_chunks/dep-983ce253.mjs';
import '../_chunks/dep-0c786bea.mjs';
import '../_chunks/dep-e727a519.mjs';
import '../_chunks/dep-7fa157cd.mjs';
import '../_chunks/dep-6269eaa3.mjs';
import '../_chunks/dep-4265f69a.mjs';
import '../common-components/fake-arrow.mjs';
import '../select-input/index.mjs';
import '../select-input/select-input.mjs';
import '../popup/index.mjs';
import '../popup/popup.mjs';
import '@popperjs/core';
import '../popup/container.mjs';
import '../popup/props.mjs';
import '../hooks/useResizeObserver.mjs';
import '../popup/type.mjs';
import '../select-input/props.mjs';
import '../select-input/useSingle.mjs';
import '../select-input/useMultiple.mjs';
import '../tag-input/index.mjs';
import '../tag-input/tag-input.mjs';
import '../tag-input/props.mjs';
import '../tag-input/hooks/useTagScroll.mjs';
import '../tag-input/useTagList.mjs';
import '../tag/index.mjs';
import '../tag/tag.mjs';
import '../_chunks/dep-7f8588b1.mjs';
import '../tag/props.mjs';
import '../tag/check-tag.mjs';
import '../tag/check-tag-props.mjs';
import '../tag/type.mjs';
import '../tag-input/hooks/useHover.mjs';
import '../tag-input/hooks/useDragSorter.mjs';
import '../tag-input/type.mjs';
import '../select-input/useOverlayInnerStyle.mjs';
import '../select-input/type.mjs';
import '../select/select-panel.mjs';
import '../_chunks/dep-60f1d7ee.mjs';
import '../_chunks/dep-e901316d.mjs';
import '../select/option.mjs';
import '../select/option-props.mjs';
import '../checkbox/index.mjs';
import '../checkbox/checkbox.mjs';
import '../checkbox/props.mjs';
import '../checkbox/constants.mjs';
import '../checkbox/hooks/useCheckboxLazyLoad.mjs';
import '../_common/js/utils/observe.mjs';
import '../checkbox/hooks/useKeyboard.mjs';
import '../checkbox/group.mjs';
import '../checkbox/checkbox-group-props.mjs';
import '../checkbox/type.mjs';
import '../select/helper.mjs';
import '../select/optionGroup.mjs';
import '../select/option-group-props.mjs';
import '../select/props.mjs';
import '../select/hooks/usePanelVirtualScroll.mjs';
import '../select/hooks/useSelectOptions.mjs';
import '../select/type.mjs';
import '../input-adornment/input-adornment.mjs';
import '../input-adornment/props.mjs';
import '../input-adornment/type.mjs';
const _hoisted_1$3 = {
class: "x-icon",
viewBox: "0 0 24 24",
width: "1.1em",
height: "1.1em"
};
const _hoisted_2$3 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "m10.086 12l-4.793 4.793l1.414 1.414L12.914 12L6.707 5.793L5.293 7.207L10.086 12ZM17 6v12h-2V6h2Z"
}, null, -1 /* HOISTED */);
const _hoisted_3$3 = [
_hoisted_2$3
];
function render$3(_ctx, _cache) {
return (openBlock(), createElementBlock("svg", _hoisted_1$3, _hoisted_3$3))
}
var __unplugin_components_7 = { name: 'ri-skip-right-line', render: render$3 };
/* vite-plugin-components disabled */
const _hoisted_1$2 = {
class: "x-icon",
viewBox: "0 0 24 24",
width: "1.1em",
height: "1.1em"
};
const _hoisted_2$2 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "m19.164 12l-6.207-6.207l-1.414 1.414L16.336 12l-4.793 4.793l1.414 1.414L19.164 12Zm-5.65 0L7.307 5.793L5.893 7.207L10.686 12l-4.793 4.793l1.414 1.414L13.514 12Z"
}, null, -1 /* HOISTED */);
const _hoisted_3$2 = [
_hoisted_2$2
];
function render$2(_ctx, _cache) {
return (openBlock(), createElementBlock("svg", _hoisted_1$2, _hoisted_3$2))
}
var __unplugin_components_4 = { name: 'ri-arrow-right-double-line', render: render$2 };
/* vite-plugin-components disabled */
const _hoisted_1$1 = {
class: "x-icon",
viewBox: "0 0 24 24",
width: "1.1em",
height: "1.1em"
};
const _hoisted_2$1 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "m4.836 12l6.207 6.207l1.414-1.414L7.664 12l4.793-4.793l-1.414-1.414L4.836 12Zm5.65 0l6.207 6.207l1.414-1.414L13.314 12l4.793-4.793l-1.414-1.414L10.486 12Z"
}, null, -1 /* HOISTED */);
const _hoisted_3$1 = [
_hoisted_2$1
];
function render$1(_ctx, _cache) {
return (openBlock(), createElementBlock("svg", _hoisted_1$1, _hoisted_3$1))
}
var __unplugin_components_2 = { name: 'ri-arrow-left-double-line', render: render$1 };
/* vite-plugin-components disabled */
const _hoisted_1 = {
class: "x-icon",
viewBox: "0 0 24 24",
width: "1.1em",
height: "1.1em"
};
const _hoisted_2 = /*#__PURE__*/createElementVNode("path", {
fill: "currentColor",
d: "m13.914 12l4.793-4.793l-1.414-1.414L11.086 12l6.207 6.207l1.414-1.414L13.914 12ZM7 18V6h2v12H7Z"
}, null, -1 /* HOISTED */);
const _hoisted_3 = [
_hoisted_2
];
function render(_ctx, _cache) {
return (openBlock(), createElementBlock("svg", _hoisted_1, _hoisted_3))
}
var __unplugin_components_0 = { name: 'ri-skip-left-line', render };
/* vite-plugin-components disabled */
var isNumber = isNumber_1;
/**
* Checks if `value` is `NaN`.
*
* **Note:** This method is based on
* [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
* global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
* `undefined` and other non-number values.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
* @example
*
* _.isNaN(NaN);
* // => true
*
* _.isNaN(new Number(NaN));
* // => true
*
* isNaN(undefined);
* // => true
*
* _.isNaN(undefined);
* // => false
*/
function isNaN(value) {
// An `NaN` primitive is the only value that is not equal to itself.
// Perform the `toStringTag` check first to avoid errors with some
// ActiveX objects in IE.
return isNumber(value) && value != +value;
}
var _isNaN = isNaN;
var _excluded = ["pageCount"];
var min = 1;
var _Pagination = defineComponent({
name: "XPagination",
props: props,
setup: function setup(props2) {
var _toRefs = toRefs(props2),
modelValue = _toRefs.modelValue,
pageSize = _toRefs.pageSize,
current = _toRefs.current;
var renderTNodeJSX = useTNodeJSX();
var _useVModel = useVModel(current, modelValue, props2.defaultCurrent, props2.onCurrentChange, "current"),
_useVModel2 = _slicedToArray(_useVModel, 2),
innerCurrent = _useVModel2[0],
setInnerCurrent = _useVModel2[1];
var _useDefaultValue = useDefaultValue(pageSize, props2.defaultPageSize, props2.onPageSizeChange, "pageSize"),
_useDefaultValue2 = _slicedToArray(_useDefaultValue, 2),
innerPageSize = _useDefaultValue2[0],
setInnerPageSize = _useDefaultValue2[1];
var _useConfig = useConfig("pagination"),
t = _useConfig.t,
globalConfig = _useConfig.globalConfig;
var COMPONENT_NAME = usePrefixClass("pagination");
var _usePaginationClasses = usePaginationClasses(props2, innerCurrent, innerPageSize, COMPONENT_NAME),
pageCount = _usePaginationClasses.pageCount,
CLASS_MAP = _objectWithoutProperties(_usePaginationClasses, _excluded);
var _useMoreAction = useMoreAction(props2, pageCount, innerCurrent),
prevMore = _useMoreAction.prevMore,
isPrevMoreShow = _useMoreAction.isPrevMoreShow,
curPageLeftCount = _useMoreAction.curPageLeftCount,
nextMore = _useMoreAction.nextMore,
isNextMoreShow = _useMoreAction.isNextMoreShow,
curPageRightCount = _useMoreAction.curPageRightCount;
var jumpIndex = ref(innerCurrent.value);
var isFolded = computed(function () {
return pageCount.value > props2.maxPageBtn;
});
var sizeOptions = computed(function () {
var pageSizeOptions = props2.pageSizeOptions;
var options = pageSizeOptions.map(function (option) {
return isObject_1(option) ? option : {
label: t(globalConfig.value.itemsPerPage, {
size: option
}),
value: Number(option)
};
});
return options.sort(function (a, b) {
return a.value - b.value;
});
});
var isMidEllipsis = computed(function () {
return props2.pageEllipsisMode === "mid";
});
var pages = computed(function () {
var array = [];
var start;
var end;
if (isFolded.value) {
if (isPrevMoreShow.value && isNextMoreShow.value) {
start = innerCurrent.value - curPageLeftCount.value;
end = innerCurrent.value + curPageRightCount.value;
} else {
var foldedStart = isMidEllipsis.value ? 2 : 1;
var foldedEnd = isMidEllipsis.value ? pageCount.value - 1 : pageCount.value;
start = isPrevMoreShow.value ? pageCount.value - props2.foldedMaxPageBtn + 1 : foldedStart;
end = isPrevMoreShow.value ? foldedEnd : props2.foldedMaxPageBtn;
}
} else {
start = 1;
end = pageCount.value;
}
for (var i = start; i <= end; i++) {
array.push(i);
}
return array;
});
watch(function () {
return pageCount.value;
}, function () {
if (innerCurrent.value > pageCount.value) innerCurrent.value = 1;
});
watch(function () {
return innerCurrent.value;
}, function (val) {
return jumpIndex.value = val;
});
var toPage = function toPage(pageIndex, isTriggerChange) {
if (props2.disabled) {
return;
}
var current2 = pageIndex;
if (pageIndex < min) {
current2 = min;
} else if (pageIndex > pageCount.value) {
current2 = pageCount.value;
}
if (innerCurrent.value !== current2) {
var prev = innerCurrent.value;
var pageInfo = {
current: current2,
previous: prev,
pageSize: innerPageSize.value
};
setInnerCurrent(current2, pageInfo);
if (isTriggerChange !== false) {
var _props2$onChange;
(_props2$onChange = props2.onChange) === null || _props2$onChange === void 0 ? void 0 : _props2$onChange.call(props2, pageInfo);
}
}
};
var handlePageChange = function handlePageChange(type) {
var pageChangeMap = {
prevPage: function prevPage() {
return toPage(innerCurrent.value - 1);
},
nextPage: function nextPage() {
return toPage(innerCurrent.value + 1);
},
prevMorePage: function prevMorePage() {
return toPage(innerCurrent.value - props2.foldedMaxPageBtn);
},
nextMorePage: function nextMorePage() {
return toPage(innerCurrent.value + props2.foldedMaxPageBtn);
}
};
pageChangeMap[type]();
};
var onSelectorChange = function onSelectorChange(e) {
var _props2$onChange2;
if (props2.disabled) {
return;
}
var pageSize2 = parseInt(e, 10);
var pageCount2 = 1;
if (pageSize2 > 0) {
pageCount2 = Math.max(Math.ceil(props2.total / pageSize2), 1);
}
var isIndexChange = false;
if (innerCurrent.value > pageCount2) {
isIndexChange = true;
}
var pageInfo = {
current: isIndexChange ? pageCount2 : innerCurrent.value,
previous: innerCurrent.value,
pageSize: pageSize2
};
(_props2$onChange2 = props2.onChange) === null || _props2$onChange2 === void 0 ? void 0 : _props2$onChange2.call(props2, pageInfo);
setInnerPageSize(pageSize2, pageInfo);
if (isIndexChange) {
toPage(pageCount2, false);
}
};
var onJumperChange = function onJumperChange(val) {
var currentIndex = Math.trunc(+val);
if (_isNaN(currentIndex)) return;
jumpIndex.value = currentIndex;
toPage(currentIndex);
};
return function () {
var total = props2.total,
pageSizeOptions = props2.pageSizeOptions,
size = props2.size,
disabled = props2.disabled,
showPageSize = props2.showPageSize;
if (pageCount.value < 1) return null;
var Jumper = createVNode("div", {
"class": CLASS_MAP.jumperClass.value
}, [t(globalConfig.value.jumpTo), createVNode(InputAdornment, {
"append": "/ ".concat(pageCount.value, " ").concat(t(globalConfig.value.page))
}, {
"default": function _default() {
return [createVNode(InputNumber, {
"class": CLASS_MAP.jumperInputClass.value,
"modelValue": jumpIndex.value,
"onUpdate:modelValue": function onUpdateModelValue($event) {
return jumpIndex.value = $event;
},
"onBlur": onJumperChange,
"onEnter": onJumperChange,
"max": pageCount.value,
"min": min,
"size": size,
"disabled": disabled,
"theme": "normal",
"placeholder": ""
}, null)];
}
})]);
return createVNode("div", {
"class": CLASS_MAP.paginationClass.value
}, [renderTNodeJSX("totalContent", createVNode("div", {
"class": CLASS_MAP.totalClass.value
}, [t(globalConfig.value.total, {
total: total
})])), showPageSize && pageSizeOptions.length > 0 && createVNode(Select, mergeProps({
"size": size,
"value": innerPageSize,
"disabled": disabled,
"class": CLASS_MAP.sizerClass.value,
"autoWidth": true,
"onChange": onSelectorChange,
"options": sizeOptions.value
}, props2.selectProps), null), props2.showFirstAndLastPageBtn ? createVNode("div", {
"class": CLASS_MAP.preBtnClass.value,
"onClick": function onClick() {
return toPage(1);
},
"disabled": props2.disabled || props2.current === min
}, [createVNode(__unplugin_components_0, null, null)]) : null, props2.showPreviousAndNextBtn ? createVNode("div", {
"class": CLASS_MAP.preBtnClass.value,
"onClick": function onClick() {
return handlePageChange("prevPage");
},
"disabled": disabled || innerCurrent.value === min
}, [createVNode(__unplugin_components_2$1, null, null)]) : null, props2.showPageNumber && props2.theme === "default" ? createVNode("ul", {
"class": CLASS_MAP.btnWrapClass.value
}, [isFolded.value && isMidEllipsis.value && createVNode("li", {
"class": CLASS_MAP.getButtonClass(1),
"onClick": function onClick() {
return toPage(min);
}
}, [min]), isFolded.value && isPrevMoreShow.value && isMidEllipsis.value ? createVNode("li", {
"class": CLASS_MAP.btnMoreClass.value,
"onClick": function onClick() {
return handlePageChange("prevMorePage");
},
"onMouseOver": function onMouseOver() {
return prevMore.value = true;
},
"onMouseOut": function onMouseOut() {
return prevMore.value = false;
}
}, [prevMore.value ? createVNode(__unplugin_components_2, null, null) : createVNode(__unplugin_components_5, null, null)]) : null, pages.value.map(function (i) {
return createVNode("li", {
"class": CLASS_MAP.getButtonClass(i),
"key": i,
"onClick": function onClick() {
return toPage(i);
}
}, [i]);
}), isFolded.value && isNextMoreShow.value && isMidEllipsis.value ? createVNode("li", {
"class": CLASS_MAP.btnMoreClass.value,
"onClick": function onClick() {
return handlePageChange("nextMorePage");
},
"onMouseOver": function onMouseOver() {
return nextMore.value = true;
},
"onMouseOut": function onMouseOut() {
return nextMore.value = false;
}
}, [nextMore.value ? createVNode(__unplugin_components_4, null, null) : createVNode(__unplugin_components_5, null, null)]) : null, isFolded.value && isMidEllipsis.value ? createVNode("li", {
"class": CLASS_MAP.getButtonClass(pageCount.value),
"onClick": function onClick() {
return toPage(pageCount.value);
}
}, [pageCount.value]) : null]) : null, props2.theme === "simple" && Jumper, props2.showPreviousAndNextBtn ? createVNode("div", {
"class": CLASS_MAP.nextBtnClass.value,
"onClick": function onClick() {
return handlePageChange("nextPage");
},
"disabled": disabled || innerCurrent.value === pageCount.value
}, [createVNode(__unplugin_components_3, null, null)]) : null, props2.showFirstAndLastPageBtn ? createVNode("div", {
"class": CLASS_MAP.nextBtnClass.value,
"onClick": function onClick() {
return toPage(pageCount.value);
},
"disabled": disabled || innerCurrent.value === pageCount.value
}, [createVNode(__unplugin_components_7, null, null)]) : null, props2.theme === "default" && props2.showJumper && Jumper]);
};
}
});
export { _Pagination as default };
//# sourceMappingURL=pagination.mjs.map