23f3e6f0109d7412ddb1a07ff6453d61e3172cd0f031e2b626c144e0447c5aabf77ad748497096856abb7a418b1fccff306998d8a185bed64498fb13257f36 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { defineComponent, ref, watch, computed, openBlock, createElementBlock, normalizeClass, unref, createVNode, withCtx, Fragment, renderList, createBlock } from 'vue';
  2. import { isEqual } from 'lodash-unified';
  3. import { ElSelect, ElOption } from '../../../select/index.mjs';
  4. import { usePagination } from '../usePagination.mjs';
  5. import { paginationSizesProps } from './sizes2.mjs';
  6. import _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs';
  7. import { useLocale } from '../../../../hooks/use-locale/index.mjs';
  8. import { useNamespace } from '../../../../hooks/use-namespace/index.mjs';
  9. import { isArray } from '@vue/shared';
  10. const __default__ = defineComponent({
  11. name: "ElPaginationSizes"
  12. });
  13. const _sfc_main = /* @__PURE__ */ defineComponent({
  14. ...__default__,
  15. props: paginationSizesProps,
  16. emits: ["page-size-change"],
  17. setup(__props, { emit }) {
  18. const props = __props;
  19. const { t } = useLocale();
  20. const ns = useNamespace("pagination");
  21. const pagination = usePagination();
  22. const innerPageSize = ref(props.pageSize);
  23. watch(() => props.pageSizes, (newVal, oldVal) => {
  24. if (isEqual(newVal, oldVal))
  25. return;
  26. if (isArray(newVal)) {
  27. const pageSize = newVal.includes(props.pageSize) ? props.pageSize : props.pageSizes[0];
  28. emit("page-size-change", pageSize);
  29. }
  30. });
  31. watch(() => props.pageSize, (newVal) => {
  32. innerPageSize.value = newVal;
  33. });
  34. const innerPageSizes = computed(() => props.pageSizes);
  35. function handleChange(val) {
  36. var _a;
  37. if (val !== innerPageSize.value) {
  38. innerPageSize.value = val;
  39. (_a = pagination.handleSizeChange) == null ? void 0 : _a.call(pagination, Number(val));
  40. }
  41. }
  42. return (_ctx, _cache) => {
  43. return openBlock(), createElementBlock("span", {
  44. class: normalizeClass(unref(ns).e("sizes"))
  45. }, [
  46. createVNode(unref(ElSelect), {
  47. "model-value": innerPageSize.value,
  48. disabled: _ctx.disabled,
  49. "popper-class": _ctx.popperClass,
  50. size: _ctx.size,
  51. teleported: _ctx.teleported,
  52. "validate-event": false,
  53. "append-to": _ctx.appendSizeTo,
  54. onChange: handleChange
  55. }, {
  56. default: withCtx(() => [
  57. (openBlock(true), createElementBlock(Fragment, null, renderList(unref(innerPageSizes), (item) => {
  58. return openBlock(), createBlock(unref(ElOption), {
  59. key: item,
  60. value: item,
  61. label: item + unref(t)("el.pagination.pagesize")
  62. }, null, 8, ["value", "label"]);
  63. }), 128))
  64. ]),
  65. _: 1
  66. }, 8, ["model-value", "disabled", "popper-class", "size", "teleported", "append-to"])
  67. ], 2);
  68. };
  69. }
  70. });
  71. var Sizes = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "sizes.vue"]]);
  72. export { Sizes as default };
  73. //# sourceMappingURL=sizes.mjs.map