sakura-ui-plus 1.0.2 → 1.0.4

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.
Files changed (32) hide show
  1. package/dist/es/index.js +567 -72
  2. package/dist/lib/index.js +561 -66
  3. package/dist/style.css +353 -0
  4. package/dist/types/components/cell/cell-group.vue.d.ts +1 -0
  5. package/dist/types/components/cell/props.d.ts +1 -0
  6. package/dist/types/components/index.d.ts +153 -5
  7. package/dist/types/components/page-container/page-container.vue.d.ts +30 -0
  8. package/dist/types/components/page-container/props.d.ts +15 -0
  9. package/dist/types/components/popconfirm-switch/popconfirm-switch.vue.d.ts +42 -0
  10. package/dist/types/components/popconfirm-switch/props.d.ts +25 -0
  11. package/dist/types/components/register-components.d.ts +15 -0
  12. package/dist/types/components/search-input/props.d.ts +1 -1
  13. package/dist/types/components/search-input/search-input.vue.d.ts +2 -2
  14. package/dist/types/components/select/props.d.ts +1 -1
  15. package/dist/types/components/select/select.vue.d.ts +3 -3
  16. package/dist/types/components/upload/props.d.ts +31 -0
  17. package/dist/types/components/upload/upload.vue.d.ts +19 -0
  18. package/dist/types/components/upload/use-upload.d.ts +8 -0
  19. package/dist/types/components/upload/utils.d.ts +6 -0
  20. package/dist/types/hooks/index.d.ts +2 -0
  21. package/dist/types/hooks/use-form-validate/index.d.ts +366 -0
  22. package/dist/types/hooks/use-visible-value/index.d.ts +8 -0
  23. package/dist/types/types/index.d.ts +2 -1
  24. package/dist/types/utils/index.d.ts +2 -6
  25. package/dist/types/utils/rules/index.d.ts +5 -0
  26. package/dist/types/utils/rules/regex.d.ts +8 -0
  27. package/dist/types/utils/rules/type/type.d.ts +13 -0
  28. package/dist/types/utils/rules/type.d.ts +10 -0
  29. package/dist/types/utils/rules/utils.d.ts +7 -0
  30. package/dist/types/utils/rules/validator.d.ts +16 -0
  31. package/dist/types/utils/utils.d.ts +6 -0
  32. package/package.json +14 -10
package/dist/es/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { unref, getCurrentInstance, defineComponent, mergeModels, computed, useModel, openBlock, createBlock, withCtx, createElementVNode, mergeProps, resolveDynamicComponent, createSlots, renderSlot, createElementBlock, Fragment, renderList, inject, normalizeClass, toDisplayString, createTextVNode, provide, reactive, toRef, createCommentVNode, createVNode, nextTick, withKeys, useTemplateRef, ref, onMounted, onUnmounted, normalizeStyle, render } from "vue";
2
- import { addUnit, isEmpty, extend, computedTextsSize, FILE_TYPE, isFunction, isString, keysOf } from "sakura-utils";
3
- import { ElLoading, ElMessage, ElMessageBox, ElNotification, ElSelectV2, ElSelect, ElConfigProvider, ElOption, ElPagination, CHANGE_EVENT, ElInput, ElButton, ElTabs, ElTabPane, ElTooltip, ElDialog, ElIcon, ElScrollbar, ElDrawer } from "element-plus";
1
+ import { unref, getCurrentInstance, ref, nextTick, reactive, defineComponent, mergeModels, computed, useModel, openBlock, createBlock, withCtx, createElementVNode, mergeProps, resolveDynamicComponent, createSlots, renderSlot, createElementBlock, Fragment, renderList, inject, normalizeClass, toDisplayString, createTextVNode, provide, toRef, createCommentVNode, createVNode, withKeys, useTemplateRef, onMounted, onUnmounted, normalizeStyle, withModifiers, render } from "vue";
2
+ import { sleep, isEmpty, keysOf, isString, isArray, addUnit, extend, computedTextsSize, FILE_TYPE, formatBytes, isFunction, getFileType, extractSuffix, getMultipleFileDotSuffix } from "sakura-utils";
3
+ import { ElLoading, ElMessage, ElMessageBox, ElNotification, ElSelectV2, ElSelect, ElConfigProvider, ElOption, ElPagination, CHANGE_EVENT, ElInput, ElButton, ElTabs, ElTabPane, ElTooltip, ElDialog, ElIcon, ElScrollbar, ElDrawer, ElPopconfirm, ElSwitch } from "element-plus";
4
4
  import { TinyColor } from "@ctrl/tinycolor";
5
- import { useThrottleFn } from "@vueuse/core";
6
- import { Close } from "@element-plus/icons-vue";
5
+ import { useDebounceFn, useThrottleFn } from "@vueuse/core";
6
+ import { Close, ArrowLeft, Upload } from "@element-plus/icons-vue";
7
7
  import DOMPurify from "dompurify";
8
8
  const defaultNamespace = "sakura";
9
9
  const statePrefix = "is-";
@@ -222,6 +222,53 @@ const useNotification = (duration = 8e3, showClose = true, position = "top-right
222
222
  };
223
223
  return notification;
224
224
  };
225
+ const useFormValidate = () => {
226
+ const elFormRef = ref(null);
227
+ const debounceFn = useDebounceFn(() => {
228
+ const errorEl = document.querySelector(".el-form-item.is-error");
229
+ if (!errorEl)
230
+ return;
231
+ const input = errorEl.getElementsByTagName("input")[0];
232
+ const textarea = errorEl.getElementsByTagName("textarea")[0];
233
+ if (input) {
234
+ input.focus();
235
+ } else if (textarea) {
236
+ textarea.focus();
237
+ }
238
+ }, 200);
239
+ const validate = () => {
240
+ return new Promise((resolve) => {
241
+ var _a;
242
+ (_a = elFormRef.value) == null ? void 0 : _a.validate(async (valid) => {
243
+ resolve(valid);
244
+ if (!valid) {
245
+ await sleep(50);
246
+ await nextTick();
247
+ debounceFn();
248
+ }
249
+ });
250
+ });
251
+ };
252
+ const resetFields = () => {
253
+ var _a;
254
+ (_a = elFormRef.value) == null ? void 0 : _a.resetFields();
255
+ };
256
+ const clearValidate = () => {
257
+ var _a;
258
+ (_a = elFormRef.value) == null ? void 0 : _a.clearValidate();
259
+ };
260
+ return {
261
+ elFormRef,
262
+ validate,
263
+ resetFields,
264
+ clearValidate
265
+ };
266
+ };
267
+ const useVisibleValue = (defaultValue = false) => {
268
+ const visible = ref(defaultValue);
269
+ const handleVisible = () => visible.value = !visible.value;
270
+ return { visible, handleVisible };
271
+ };
225
272
  const checkElementIsExist = (id, container = "body") => {
226
273
  if (document.querySelector(`#${id}`)) {
227
274
  return true;
@@ -236,6 +283,64 @@ const checkElementIsExist = (id, container = "body") => {
236
283
  return false;
237
284
  }
238
285
  };
286
+ const phoneRegex = /^1[3-9]\d{9}$/;
287
+ const idCardRegex = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
288
+ const isPhone = (value) => phoneRegex.test(value);
289
+ const isIdCard = (value) => idCardRegex.test(value);
290
+ const phoneValidator = (rules = ["empty", "rule"], emptyTips = "请输入手机号", ruleTips = "请输入正确的手机号") => {
291
+ return (_, value, callback) => {
292
+ if (rules.includes("empty") && isEmpty(value)) {
293
+ return callback(new Error(emptyTips));
294
+ }
295
+ if (rules.includes("rule") && value && !isPhone(value)) {
296
+ return callback(new Error(ruleTips));
297
+ }
298
+ return callback();
299
+ };
300
+ };
301
+ const idCardValidator = (rules = ["empty", "rule"], emptyTips = "请输入身份证号码", ruleTips = "请输入正确的身份证号码") => {
302
+ return (_, value, callback) => {
303
+ if (rules.includes("empty") && isEmpty(value)) {
304
+ return callback(new Error(emptyTips));
305
+ }
306
+ if (rules.includes("rule") && value && !isIdCard(value)) {
307
+ return callback(new Error(ruleTips));
308
+ }
309
+ return callback();
310
+ };
311
+ };
312
+ const getRuleItem = (value) => {
313
+ if (isString(value)) {
314
+ return {
315
+ required: true,
316
+ message: `请输入${value}`,
317
+ trigger: "blur"
318
+ };
319
+ } else if (isArray(value)) {
320
+ const [message, trigger = "blur", required = true] = value;
321
+ return {
322
+ trigger,
323
+ message,
324
+ required: required ?? true
325
+ };
326
+ } else {
327
+ return {
328
+ required: true,
329
+ trigger: "blur",
330
+ ...value
331
+ };
332
+ }
333
+ };
334
+ const createRules = (state) => {
335
+ return reactive(keysOf(state).reduce((data, key) => {
336
+ const value = state[key];
337
+ if (!(key in data)) {
338
+ data[key] = [];
339
+ }
340
+ data[key].push(getRuleItem(value));
341
+ return data;
342
+ }, {}));
343
+ };
239
344
  var EVENT_NAME = /* @__PURE__ */ ((EVENT_NAME2) => {
240
345
  EVENT_NAME2["改变"] = "change";
241
346
  EVENT_NAME2["发送"] = "send";
@@ -447,7 +552,7 @@ var zhCn = {
447
552
  }
448
553
  }
449
554
  };
450
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
555
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
451
556
  ...{
452
557
  name: "SakuraSelect"
453
558
  },
@@ -466,7 +571,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
466
571
  loading: { type: Boolean },
467
572
  virtualized: { type: Boolean },
468
573
  emptyValues: { default: () => [void 0, null] },
469
- stringEmpty: { type: Boolean, default: false },
574
+ stringEmpty: { type: Boolean, default: true },
470
575
  locale: { default: zhCn },
471
576
  maxLength: { default: 50 }
472
577
  }, {
@@ -544,10 +649,10 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
544
649
  } : void 0,
545
650
  _ctx.$slots.default ? {
546
651
  name: "default",
547
- fn: withCtx(({ item }) => [
652
+ fn: withCtx((data) => [
548
653
  isUseVirtualized.value ? renderSlot(_ctx.$slots, "default", {
549
654
  key: 0,
550
- item
655
+ item: data.item
551
656
  }) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(__props.options, (v) => {
552
657
  return openBlock(), createBlock(unref(ElOption), {
553
658
  key: v.value,
@@ -587,7 +692,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
587
692
  }
588
693
  });
589
694
  const CellContextKey = Symbol("CellContextKey");
590
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
695
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
591
696
  ...{
592
697
  name: "SakuraCell"
593
698
  },
@@ -595,6 +700,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
595
700
  props: {
596
701
  labelWidth: {},
597
702
  background: {},
703
+ row: {},
598
704
  label: {},
599
705
  content: {}
600
706
  },
@@ -606,7 +712,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
606
712
  const { labelWidth, background } = props;
607
713
  return ns.cssBlockVar("cell", {
608
714
  "label-width": addUnit(labelWidth || cellContext.labelWidth || 140),
609
- "background": background || cellContext.background || "#F2FAFF"
715
+ "background": background || cellContext.background || "#F2FAFF",
716
+ "width": 100 / (cellContext.row ?? 1) + "%"
610
717
  });
611
718
  });
612
719
  return (_ctx, _cache) => {
@@ -628,32 +735,37 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
628
735
  };
629
736
  }
630
737
  });
631
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
738
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
632
739
  ...{
633
740
  name: "SakuraCellGroup"
634
741
  },
635
742
  __name: "cell-group",
636
743
  props: {
637
744
  labelWidth: { default: 140 },
638
- background: { default: "#F2FAFF" }
745
+ background: { default: "#F2FAFF" },
746
+ row: { default: 1 }
639
747
  },
640
748
  setup(__props) {
641
749
  const ns = useNamespace("cell-group");
642
750
  const props = __props;
643
751
  provide(CellContextKey, reactive({
644
752
  labelWidth: toRef(props, "labelWidth"),
645
- background: toRef(props, "background")
753
+ background: toRef(props, "background"),
754
+ row: toRef(props, "row")
646
755
  }));
647
756
  return (_ctx, _cache) => {
648
757
  return openBlock(), createElementBlock("div", mergeProps({
649
- class: [unref(ns).b()]
758
+ class: [
759
+ unref(ns).b(),
760
+ unref(ns).is(__props.row > 1 ? "row" : "col")
761
+ ]
650
762
  }, _ctx.$attrs), [
651
763
  renderSlot(_ctx.$slots, "default")
652
764
  ], 16);
653
765
  };
654
766
  }
655
767
  });
656
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
768
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
657
769
  ...{
658
770
  name: "SakuraStatus"
659
771
  },
@@ -701,7 +813,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
701
813
  };
702
814
  }
703
815
  });
704
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
816
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
705
817
  ...{
706
818
  name: "SakuraContainer"
707
819
  },
@@ -736,7 +848,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
736
848
  };
737
849
  }
738
850
  });
739
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
851
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
740
852
  ...{
741
853
  name: "SakuraPagination"
742
854
  },
@@ -795,7 +907,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
795
907
  };
796
908
  }
797
909
  });
798
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
910
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
799
911
  ...{
800
912
  name: "SakuraSearchInput"
801
913
  },
@@ -853,7 +965,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
853
965
  }
854
966
  });
855
967
  const FilterGroupContextKey = Symbol("FilterGroupContextKey");
856
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
968
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
857
969
  ...{
858
970
  name: "SakuraFilterItem"
859
971
  },
@@ -924,7 +1036,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
924
1036
  };
925
1037
  }
926
1038
  });
927
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
1039
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
928
1040
  ...{
929
1041
  name: "SakuraFilterGroup"
930
1042
  },
@@ -958,7 +1070,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
958
1070
  };
959
1071
  }
960
1072
  });
961
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1073
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
962
1074
  ...{
963
1075
  name: "SakuraTabs"
964
1076
  },
@@ -1006,7 +1118,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1006
1118
  };
1007
1119
  }
1008
1120
  });
1009
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1121
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
1010
1122
  ...{
1011
1123
  name: "SakuraTooltipText"
1012
1124
  },
@@ -1082,8 +1194,8 @@ const WordFileIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjkiIGhlaWdodD0i
1082
1194
  const ImageFileIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjUiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyNSAyOCIgZmlsbD0ibm9uZSIgeG1sb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TMgMjMuNDEyNyAxMS4yNjk0IDIyLjIwMzggMTEuMzkyIDIwLjcxNTFMMTEuNDIzNSAyMC4zMjc3SDExLjAzODRIOS4zNjUxNUg5LjAyNTZMOS4wMTE1OSAyMC42NzIxQzguOTc2NTkgMjEuNjY5MyA5LjAwMTA5IDIzLjcyNDggOS4zNjg2NSAyNC40Mjc5QzEwLjEyMTMgMjYuMTM1NSAxMS42NDc1IDI3IDEzLjkxMjQgMjdIMTMuOTIyOUgxMy45MzM0QzE3LjE2MDkgMjYuODI3OCAxOC44NTUxIDI1LjE3NDEgMTguOTc0MSAyMi4wODU1QzE5LjE5ODIgMTkuOTQ3NSAxNy45NjYgMTguMzk0MiAxNS4zMDU2IDE3LjQ2NTFaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K";
1085
- const _hoisted_1$1 = ["src"];
1086
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1197
+ const _hoisted_1$2 = ["src"];
1198
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
1087
1199
  ...{
1088
1200
  name: "SakuraFileItem"
1089
1201
  },
@@ -1126,7 +1238,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1126
1238
  if (formatFontSize) {
1127
1239
  return formatFontSize(fileSize);
1128
1240
  }
1129
- return Math.round(fileSize / 1024 / 1024 * 100) / 100 + "MB";
1241
+ return formatBytes(fileSize);
1130
1242
  });
1131
1243
  return (_ctx, _cache) => {
1132
1244
  return openBlock(), createElementBlock("div", mergeProps({
@@ -1136,7 +1248,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1136
1248
  class: normalizeClass([unref(ns).e("icon")]),
1137
1249
  src: fileIcon.value,
1138
1250
  alt: ""
1139
- }, null, 10, _hoisted_1$1),
1251
+ }, null, 10, _hoisted_1$2),
1140
1252
  createElementVNode("div", {
1141
1253
  class: normalizeClass([unref(ns).e("info")])
1142
1254
  }, [
@@ -1153,7 +1265,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1153
1265
  };
1154
1266
  }
1155
1267
  });
1156
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1268
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1157
1269
  ...{
1158
1270
  name: "SakuraFileList"
1159
1271
  },
@@ -1194,7 +1306,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1194
1306
  style: [fileListStyle.value]
1195
1307
  }, _ctx.$attrs), [
1196
1308
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.fileList, (v, i) => {
1197
- return openBlock(), createBlock(_sfc_main$5, {
1309
+ return openBlock(), createBlock(_sfc_main$8, {
1198
1310
  key: v.fileId,
1199
1311
  "file-info": v,
1200
1312
  style: normalizeStyle(fileItemStyle.value(i + 1))
@@ -1204,7 +1316,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1204
1316
  };
1205
1317
  }
1206
1318
  });
1207
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1319
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1208
1320
  ...{
1209
1321
  name: "SakuraCountDown"
1210
1322
  },
@@ -1280,7 +1392,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1280
1392
  };
1281
1393
  }
1282
1394
  });
1283
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1395
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1284
1396
  ...{
1285
1397
  name: "SakuraDialog"
1286
1398
  },
@@ -1446,7 +1558,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1446
1558
  };
1447
1559
  }
1448
1560
  });
1449
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1561
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1450
1562
  ...{
1451
1563
  name: "SakuraDrawer"
1452
1564
  },
@@ -1627,8 +1739,8 @@ const validateHtmlString = (html) => {
1627
1739
  return false;
1628
1740
  }
1629
1741
  };
1630
- const _hoisted_1 = ["innerHTML"];
1631
- const _sfc_main = /* @__PURE__ */ defineComponent({
1742
+ const _hoisted_1$1 = ["innerHTML"];
1743
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1632
1744
  ...{
1633
1745
  name: "SakuraShowModal"
1634
1746
  },
@@ -1744,7 +1856,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1744
1856
  visibleShowModal
1745
1857
  });
1746
1858
  return (_ctx, _cache) => {
1747
- return openBlock(), createBlock(unref(_sfc_main$2), {
1859
+ return openBlock(), createBlock(unref(_sfc_main$5), {
1748
1860
  modelValue: visible.value,
1749
1861
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event),
1750
1862
  class: normalizeClass([unref(ns).b()]),
@@ -1765,7 +1877,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1765
1877
  key: 0,
1766
1878
  class: normalizeClass([unref(ns).e("content")]),
1767
1879
  innerHTML: htmlDomContent.value
1768
- }, null, 10, _hoisted_1)) : (openBlock(), createElementBlock("div", {
1880
+ }, null, 10, _hoisted_1$1)) : (openBlock(), createElementBlock("div", {
1769
1881
  key: 1,
1770
1882
  class: normalizeClass([unref(ns).e("content")])
1771
1883
  }, [
@@ -1779,28 +1891,379 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1779
1891
  };
1780
1892
  }
1781
1893
  });
1894
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1895
+ ...{
1896
+ name: "SakuraPopconfirmSwitch"
1897
+ },
1898
+ __name: "popconfirm-switch",
1899
+ props: /* @__PURE__ */ mergeModels({
1900
+ activeText: { default: "启用" },
1901
+ activeValue: { type: [String, Boolean, Number], default: true },
1902
+ activeColor: { default: "" },
1903
+ inactiveText: { default: "禁用" },
1904
+ inactiveValue: { type: [String, Boolean, Number], default: false },
1905
+ inactiveColor: { default: "" },
1906
+ size: { default: "default" },
1907
+ loading: { type: Boolean, default: false },
1908
+ disabled: { type: Boolean, default: false },
1909
+ width: { default: "" },
1910
+ locale: { default: zhCn },
1911
+ showText: { type: Boolean }
1912
+ }, {
1913
+ "modelValue": { type: [Boolean, Number, String] },
1914
+ "modelModifiers": {}
1915
+ }),
1916
+ emits: /* @__PURE__ */ mergeModels(["confirm", "cancel"], ["update:modelValue"]),
1917
+ setup(__props, { emit: __emit }) {
1918
+ const ns = useNamespace("popconfirm-switch");
1919
+ const props = __props;
1920
+ const emits = __emit;
1921
+ const status = useModel(__props, "modelValue");
1922
+ const title = computed(() => {
1923
+ const { activeText, inactiveText } = props;
1924
+ return status.value ? `确定要${inactiveText}吗?` : `确定要${activeText}吗?`;
1925
+ });
1926
+ return (_ctx, _cache) => {
1927
+ return openBlock(), createBlock(unref(ElConfigProvider), { locale: __props.locale }, {
1928
+ default: withCtx(() => [
1929
+ createVNode(unref(ElPopconfirm), {
1930
+ class: normalizeClass([unref(ns).b()]),
1931
+ title: title.value,
1932
+ onConfirm: _cache[0] || (_cache[0] = ($event) => emits("confirm", !status.value)),
1933
+ onCancel: _cache[1] || (_cache[1] = ($event) => emits("cancel"))
1934
+ }, {
1935
+ reference: withCtx(() => [
1936
+ _ctx.$slots.default ? renderSlot(_ctx.$slots, "default", { key: 0 }) : (openBlock(), createBlock(unref(ElSwitch), {
1937
+ key: 1,
1938
+ size: __props.size,
1939
+ "model-value": status.value,
1940
+ "active-text": __props.showText ? __props.activeText : "",
1941
+ "active-value": __props.activeValue,
1942
+ "active-color": __props.activeColor,
1943
+ "inactive-text": __props.showText ? __props.inactiveText : "",
1944
+ "inactive-value": __props.inactiveValue,
1945
+ "inactive-color": __props.inactiveColor,
1946
+ disabled: __props.disabled,
1947
+ loading: __props.loading,
1948
+ width: __props.width,
1949
+ "inline-prompt": ""
1950
+ }, null, 8, ["size", "model-value", "active-text", "active-value", "active-color", "inactive-text", "inactive-value", "inactive-color", "disabled", "loading", "width"]))
1951
+ ]),
1952
+ _: 3
1953
+ }, 8, ["class", "title"])
1954
+ ]),
1955
+ _: 3
1956
+ }, 8, ["locale"]);
1957
+ };
1958
+ }
1959
+ });
1960
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1961
+ ...{
1962
+ name: "SakuraPageContainer"
1963
+ },
1964
+ __name: "page-container",
1965
+ props: {
1966
+ title: {},
1967
+ back: { type: Boolean, default: true },
1968
+ background: { default: "#F7F7FC" },
1969
+ scroll: { type: Boolean, default: true },
1970
+ type: { default: "default" },
1971
+ plain: { type: Boolean, default: false }
1972
+ },
1973
+ emits: ["back"],
1974
+ setup(__props, { emit: __emit }) {
1975
+ const ns = useNamespace("page-container");
1976
+ const props = __props;
1977
+ const emits = __emit;
1978
+ const pageContainerStyle = computed(() => {
1979
+ const { background } = props;
1980
+ return ns.cssBlockVar("page-container", {
1981
+ background
1982
+ });
1983
+ });
1984
+ return (_ctx, _cache) => {
1985
+ return openBlock(), createElementBlock("div", {
1986
+ class: normalizeClass([
1987
+ unref(ns).b(),
1988
+ unref(ns).is("scroll", __props.scroll)
1989
+ ]),
1990
+ style: normalizeStyle([pageContainerStyle.value])
1991
+ }, [
1992
+ __props.back || __props.title || _ctx.$slots.header ? (openBlock(), createElementBlock("div", {
1993
+ key: 0,
1994
+ class: normalizeClass([unref(ns).e("header")])
1995
+ }, [
1996
+ __props.back ? (openBlock(), createBlock(unref(ElButton), {
1997
+ key: 0,
1998
+ class: normalizeClass([unref(ns).e("back")]),
1999
+ circle: "",
2000
+ icon: unref(ArrowLeft),
2001
+ type: __props.type,
2002
+ plain: __props.plain,
2003
+ onClick: _cache[0] || (_cache[0] = ($event) => emits("back"))
2004
+ }, null, 8, ["class", "icon", "type", "plain"])) : createCommentVNode("", true),
2005
+ __props.title ? (openBlock(), createElementBlock("p", {
2006
+ key: 1,
2007
+ class: normalizeClass([unref(ns).e("title")])
2008
+ }, toDisplayString(__props.title), 3)) : createCommentVNode("", true),
2009
+ renderSlot(_ctx.$slots, "header")
2010
+ ], 2)) : createCommentVNode("", true),
2011
+ createElementVNode("div", {
2012
+ class: normalizeClass([unref(ns).e("body")])
2013
+ }, [
2014
+ __props.scroll ? (openBlock(), createBlock(unref(ElScrollbar), {
2015
+ key: 0,
2016
+ height: "100%"
2017
+ }, {
2018
+ default: withCtx(() => [
2019
+ renderSlot(_ctx.$slots, "default")
2020
+ ]),
2021
+ _: 3
2022
+ })) : renderSlot(_ctx.$slots, "default", { key: 1 })
2023
+ ], 2)
2024
+ ], 6);
2025
+ };
2026
+ }
2027
+ });
2028
+ const UploadIcon = "data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjYuNTU5NiAzNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjI2LjU1OTU3MCIgaGVpZ2h0PSIzNC4wMDAwMDAiIGZpbGw9Im5vbmUiIGN1c3RvbUZyYW1lPSIjMDAwMDAwIj4KCTxnIGlkPSJHcm91cCAxNDY4Ij4KCQk8cGF0aCBpZD0iVmVjdG9yIiBkPSJNMTUuNjggMzRMMCAzNEwwIDBMMTguNTkgMEwyNi41NiA3Ljk3TDI2LjU2IDE1LjEzTDI2LjU2IDM0TDE1LjY4IDM0WiIgZmlsbD0icmdiKDM2LDk0LDI1NSkiIGZpbGwtcnVsZT0ibm9uemVybyIgLz4KCQk8cGF0aCBpZD0iVmVjdG9yIiBkPSJNMTguNTg5OCAwTDI2LjU1OTggNy45N0wxOC41ODk4IDcuOTdMMTguNTg5OCAwWiIgZmlsbD0icmdiKDE5Ny4zOCwyMTIuNjQsMjU1KSIgZmlsbC1ydWxlPSJub256ZXJvIiAvPgoJCTxwYXRoIGlkPSJWZWN0b3IiIGQ9Ik0xMy4wNTk0IDE0LjEwOTlDMTIuOTM5NCAxMy45Njk5IDEyLjcyOTQgMTMuOTY5OSAxMi42MDk0IDE0LjEwOTlMOC44NzkzNyAxOC4zNTk5QzguNzU5MzcgMTguNDk5OSA4LjgwOTM3IDE4LjYxOTkgOC45OTkzNyAxOC42MTk5TDEwLjM5OTQgMTguNjE5OUMxMC41ODk0IDE4LjYxOTkgMTAuNzQ5NCAxOC43Njk5IDEwLjc0OTQgMTguOTU5OUwxMC43NDk0IDIxLjY4OTlDMTAuNzQ5NCAyMS44Nzk5IDEwLjkwOTQgMjIuMDI5OSAxMS4wOTk0IDIyLjAyOTlMMTQuNTg5NCAyMi4wMjk5QzE0Ljc3OTQgMjIuMDI5OSAxNC45Mzk0IDIxLjg3OTkgMTQuOTM5NCAyMS42ODk5TDE0LjkzOTQgMTguOTU5OUMxNC45Mzk0IDE4Ljc2OTkgMTUuMDk5NCAxOC42MTk5IDE1LjI4OTQgMTguNjE5OUwxNi42ODk0IDE4LjYxOTlDMTYuODc5NCAxOC42MTk5IDE2LjkzOTQgMTguNDk5OSAxNi44MDk0IDE4LjM1OTlMMTMuMDU5NCAxNC4xMDk5WiIgZmlsbD0icmdiKDI1NSwyNTUsMjU1KSIgZmlsbC1ydWxlPSJub256ZXJvIiAvPgoJCTxwYXRoIGlkPSJWZWN0b3IiIGQ9Ik0xNC4yMzAyIDIyLjcxTDExLjQ0MDIgMjIuNzFDMTEuMDUwMiAyMi43MSAxMC43NDAyIDIzLjAxIDEwLjc0MDIgMjMuMzlDMTAuNzQwMiAyMy43NyAxMS4wNTAyIDI0LjA3IDExLjQ0MDIgMjQuMDdMMTQuMjMwMiAyNC4wN0MxNC42MjAyIDI0LjA3IDE0LjkzMDIgMjMuNzcgMTQuOTMwMiAyMy4zOUMxNC45MjAyIDIzLjAxIDE0LjYxMDIgMjIuNzEgMTQuMjMwMiAyMi43MVoiIGZpbGw9InJnYigyNTUsMjU1LDI1NSkiIGZpbGwtcnVsZT0ibm9uemVybyIgLz4KCTwvZz4KPC9zdmc+Cg==";
2029
+ const fileTransformFileInfo = (files) => {
2030
+ return files.map((file) => {
2031
+ const { name, size } = file;
2032
+ const fileInfo = {
2033
+ fileId: "",
2034
+ fileSize: size,
2035
+ fileType: getFileType(name),
2036
+ fileName: name,
2037
+ fileSuffix: extractSuffix(name),
2038
+ fileUrl: "",
2039
+ originFile: file
2040
+ };
2041
+ return fileInfo;
2042
+ });
2043
+ };
2044
+ const useUpload = (props) => {
2045
+ const uploadFileTips = computed(() => {
2046
+ const { tips, fileAccepts } = props;
2047
+ if (!isEmpty(tips)) {
2048
+ return tips;
2049
+ }
2050
+ return fileAccepts.map((v) => {
2051
+ const type = v.toLocaleLowerCase();
2052
+ const first = type[0].toLocaleUpperCase();
2053
+ return `${first}${type.slice(1)}`;
2054
+ }).join(", ");
2055
+ });
2056
+ const uploadFileAccepts = computed(() => getMultipleFileDotSuffix(props.fileAccepts));
2057
+ const fileValidate = (fileList) => {
2058
+ const { fileSize, fileLimit } = props;
2059
+ if (fileList.length > fileLimit) {
2060
+ return {
2061
+ success: false,
2062
+ data: `一次性上传文件数量不能超过${fileLimit}份`,
2063
+ message: ""
2064
+ };
2065
+ }
2066
+ if (!fileList.every((v) => Math.round(v.fileSize / 1024 / 1024 * 100) / 100 <= fileSize)) {
2067
+ return {
2068
+ success: false,
2069
+ data: `文件大小超过${fileSize}MB`,
2070
+ message: ""
2071
+ };
2072
+ }
2073
+ if (!fileList.every((v) => uploadFileAccepts.value.includes(extractSuffix(v.fileName)))) {
2074
+ return {
2075
+ success: false,
2076
+ data: "文件格式错误",
2077
+ message: ""
2078
+ };
2079
+ }
2080
+ return {
2081
+ success: true,
2082
+ data: "成功",
2083
+ message: ""
2084
+ };
2085
+ };
2086
+ const getFileResult = (files) => {
2087
+ const { validate } = props;
2088
+ const fileList = fileTransformFileInfo(Array.from(files));
2089
+ if (isEmpty(fileList)) {
2090
+ return {
2091
+ success: false,
2092
+ data: [],
2093
+ message: ""
2094
+ };
2095
+ }
2096
+ if (validate) {
2097
+ const validateRes = fileValidate(fileList);
2098
+ if (!validateRes.success) {
2099
+ return {
2100
+ success: false,
2101
+ data: [],
2102
+ message: validateRes.data
2103
+ };
2104
+ }
2105
+ }
2106
+ return {
2107
+ success: true,
2108
+ data: fileList,
2109
+ message: "成功"
2110
+ };
2111
+ };
2112
+ return {
2113
+ uploadFileTips,
2114
+ uploadFileAccepts,
2115
+ fileValidate,
2116
+ getFileResult
2117
+ };
2118
+ };
2119
+ const _hoisted_1 = ["src"];
2120
+ const _hoisted_2 = ["accept", "multiple"];
2121
+ const _hoisted_3 = ["accept", "multiple"];
2122
+ const _sfc_main = /* @__PURE__ */ defineComponent({
2123
+ ...{
2124
+ name: "SakuraUpload"
2125
+ },
2126
+ __name: "upload",
2127
+ props: {
2128
+ title: { default: "点击或拖拽文件至此处上传" },
2129
+ buttonTitle: { default: "上传附件" },
2130
+ buttonIcon: { default: Upload },
2131
+ tips: { default: "" },
2132
+ uploadIcon: {},
2133
+ fileSize: { default: 50 },
2134
+ fileLimit: { default: 9 },
2135
+ fileAccepts: { default: () => [FILE_TYPE.IMAGE, FILE_TYPE.WORD, FILE_TYPE.PDF, FILE_TYPE.EXCEL] },
2136
+ disabled: { type: Boolean },
2137
+ validate: { type: Boolean, default: true },
2138
+ showMessage: { type: Boolean },
2139
+ type: { default: "upload" },
2140
+ text: { type: Boolean, default: true }
2141
+ },
2142
+ emits: ["change"],
2143
+ setup(__props, { emit: __emit }) {
2144
+ const ns = useNamespace("upload");
2145
+ const props = __props;
2146
+ const emits = __emit;
2147
+ const { uploadFileTips, uploadFileAccepts, getFileResult } = useUpload(props);
2148
+ const isDragging = ref(false);
2149
+ const onDragOver = (e) => {
2150
+ isDragging.value = true;
2151
+ e.dataTransfer.dropEffect = "copy";
2152
+ };
2153
+ const onDragLeave = () => {
2154
+ isDragging.value = false;
2155
+ };
2156
+ const message = useMessage();
2157
+ const onDrop = (e) => {
2158
+ var _a;
2159
+ const { showMessage } = props;
2160
+ isDragging.value = false;
2161
+ const files = (_a = e.dataTransfer) == null ? void 0 : _a.files;
2162
+ const fileResult = getFileResult(files);
2163
+ if (showMessage) {
2164
+ message.info(fileResult.message);
2165
+ }
2166
+ emits("change", fileResult);
2167
+ };
2168
+ const onFileChange = (e) => {
2169
+ const target = e.target;
2170
+ const fileResult = getFileResult(target.files);
2171
+ const { showMessage } = props;
2172
+ target.value = "";
2173
+ if (showMessage) {
2174
+ message.info(fileResult.message);
2175
+ }
2176
+ emits("change", fileResult);
2177
+ };
2178
+ return (_ctx, _cache) => {
2179
+ return __props.type === "upload" ? (openBlock(), createElementBlock("div", {
2180
+ key: 0,
2181
+ class: normalizeClass([
2182
+ unref(ns).b(),
2183
+ unref(ns).is("disabled", __props.disabled),
2184
+ unref(ns).is("active", isDragging.value),
2185
+ unref(ns).m(__props.type)
2186
+ ]),
2187
+ onDragover: withModifiers(onDragOver, ["prevent"]),
2188
+ onDragleave: onDragLeave,
2189
+ onDrop: withModifiers(onDrop, ["prevent"])
2190
+ }, [
2191
+ createElementVNode("img", {
2192
+ class: normalizeClass([unref(ns).e("icon")]),
2193
+ src: unref(UploadIcon),
2194
+ alt: ""
2195
+ }, null, 10, _hoisted_1),
2196
+ createElementVNode("p", {
2197
+ class: normalizeClass([unref(ns).e("title")])
2198
+ }, toDisplayString(__props.title), 3),
2199
+ createElementVNode("p", {
2200
+ class: normalizeClass([unref(ns).e("tips")])
2201
+ }, " 支持格式: " + toDisplayString(unref(uploadFileTips)), 3),
2202
+ createElementVNode("input", {
2203
+ class: normalizeClass([unref(ns).e("file")]),
2204
+ type: "file",
2205
+ alt: "",
2206
+ accept: unref(uploadFileAccepts),
2207
+ multiple: __props.fileLimit > 1,
2208
+ onChange: onFileChange
2209
+ }, null, 42, _hoisted_2)
2210
+ ], 34)) : (openBlock(), createElementBlock("div", {
2211
+ key: 1,
2212
+ class: normalizeClass([
2213
+ unref(ns).b(),
2214
+ unref(ns).m(__props.type)
2215
+ ])
2216
+ }, [
2217
+ createVNode(unref(ElButton), {
2218
+ text: __props.text,
2219
+ icon: __props.buttonIcon,
2220
+ type: "primary"
2221
+ }, {
2222
+ default: withCtx(() => [
2223
+ createTextVNode(toDisplayString(__props.buttonTitle), 1)
2224
+ ]),
2225
+ _: 1
2226
+ }, 8, ["text", "icon"]),
2227
+ createElementVNode("input", {
2228
+ class: normalizeClass([unref(ns).e("file")]),
2229
+ type: "file",
2230
+ alt: "",
2231
+ accept: unref(uploadFileAccepts),
2232
+ multiple: __props.fileLimit > 1,
2233
+ onChange: onFileChange
2234
+ }, null, 42, _hoisted_3)
2235
+ ], 2));
2236
+ };
2237
+ }
2238
+ });
1782
2239
  const components = {
1783
- Select: _sfc_main$g,
1784
- Cell: _sfc_main$f,
1785
- CellGroup: _sfc_main$e,
1786
- Status: _sfc_main$d,
1787
- Container: _sfc_main$c,
1788
- Pagination: _sfc_main$b,
1789
- SearchInput: _sfc_main$a,
1790
- FilterItem: _sfc_main$9,
1791
- FilterGroup: _sfc_main$8,
1792
- Tabs: _sfc_main$7,
1793
- TooltipText: _sfc_main$6,
1794
- FileItem: _sfc_main$5,
1795
- FileList: _sfc_main$4,
1796
- CountDown: _sfc_main$3,
1797
- Dialog: _sfc_main$2,
1798
- Drawer: _sfc_main$1,
1799
- ShowModal: _sfc_main
2240
+ Select: _sfc_main$j,
2241
+ Cell: _sfc_main$i,
2242
+ CellGroup: _sfc_main$h,
2243
+ Status: _sfc_main$g,
2244
+ Container: _sfc_main$f,
2245
+ Pagination: _sfc_main$e,
2246
+ SearchInput: _sfc_main$d,
2247
+ FilterItem: _sfc_main$c,
2248
+ FilterGroup: _sfc_main$b,
2249
+ Tabs: _sfc_main$a,
2250
+ TooltipText: _sfc_main$9,
2251
+ FileItem: _sfc_main$8,
2252
+ FileList: _sfc_main$7,
2253
+ CountDown: _sfc_main$6,
2254
+ Dialog: _sfc_main$5,
2255
+ Drawer: _sfc_main$4,
2256
+ ShowModal: _sfc_main$3,
2257
+ PopconfirmSwitch: _sfc_main$2,
2258
+ PageContainer: _sfc_main$1,
2259
+ Upload: _sfc_main
1800
2260
  };
1801
2261
  const ShowModalInstall = {
1802
2262
  install(vm) {
1803
- const vnode = createVNode(_sfc_main);
2263
+ if (typeof document === "undefined") {
2264
+ return;
2265
+ }
2266
+ const vnode = createVNode(_sfc_main$3);
1804
2267
  checkElementIsExist("u-show-modal");
1805
2268
  render(vnode, document.querySelector("#u-show-modal"));
1806
2269
  vm.config.globalProperties.$showModal = (content, title = "提示", showCancelButton = false, params) => {
@@ -1825,32 +2288,64 @@ const SakuraUiPlus = {
1825
2288
  install
1826
2289
  };
1827
2290
  export {
1828
- _sfc_main$f as Cell,
1829
- _sfc_main$e as CellGroup,
1830
- _sfc_main$c as Container,
1831
- _sfc_main$3 as CountDown,
1832
- _sfc_main$2 as Dialog,
1833
- _sfc_main$1 as Drawer,
2291
+ _sfc_main$i as Cell,
2292
+ _sfc_main$h as CellGroup,
2293
+ _sfc_main$f as Container,
2294
+ _sfc_main$6 as CountDown,
2295
+ _sfc_main$5 as Dialog,
2296
+ _sfc_main$4 as Drawer,
1834
2297
  EVENT_NAME,
1835
- _sfc_main$5 as FileItem,
1836
- _sfc_main$4 as FileList,
1837
- _sfc_main$8 as FilterGroup,
1838
- _sfc_main$9 as FilterItem,
1839
- _sfc_main$b as Pagination,
1840
- _sfc_main$a as SearchInput,
1841
- _sfc_main$g as Select,
1842
- _sfc_main as ShowModal,
1843
- _sfc_main$d as Status,
1844
- _sfc_main$7 as Tabs,
1845
- _sfc_main$6 as TooltipText,
2298
+ _sfc_main$8 as FileItem,
2299
+ _sfc_main$7 as FileList,
2300
+ _sfc_main$b as FilterGroup,
2301
+ _sfc_main$c as FilterItem,
2302
+ _sfc_main$1 as PageContainer,
2303
+ _sfc_main$e as Pagination,
2304
+ _sfc_main$2 as PopconfirmSwitch,
2305
+ _sfc_main$i as SakuraCell,
2306
+ _sfc_main$h as SakuraCellGroup,
2307
+ _sfc_main$f as SakuraContainer,
2308
+ _sfc_main$6 as SakuraCountDown,
2309
+ _sfc_main$5 as SakuraDialog,
2310
+ _sfc_main$4 as SakuraDrawer,
2311
+ _sfc_main$8 as SakuraFileItem,
2312
+ _sfc_main$7 as SakuraFileList,
2313
+ _sfc_main$b as SakuraFilterGroup,
2314
+ _sfc_main$c as SakuraFilterItem,
2315
+ _sfc_main$1 as SakuraPageContainer,
2316
+ _sfc_main$e as SakuraPagination,
2317
+ _sfc_main$2 as SakuraPopconfirmSwitch,
2318
+ _sfc_main$d as SakuraSearchInput,
2319
+ _sfc_main$j as SakuraSelect,
2320
+ _sfc_main$3 as SakuraShowModal,
2321
+ _sfc_main$g as SakuraStatus,
2322
+ _sfc_main$a as SakuraTabs,
2323
+ _sfc_main$9 as SakuraTooltipText,
2324
+ _sfc_main as SakuraUpload,
2325
+ _sfc_main$d as SearchInput,
2326
+ _sfc_main$j as Select,
2327
+ _sfc_main$3 as ShowModal,
2328
+ _sfc_main$g as Status,
2329
+ _sfc_main$a as Tabs,
2330
+ _sfc_main$9 as TooltipText,
2331
+ _sfc_main as Upload,
1846
2332
  checkElementIsExist,
2333
+ createRules,
1847
2334
  SakuraUiPlus as default,
1848
2335
  defaultNamespace,
2336
+ idCardRegex,
2337
+ idCardValidator,
2338
+ isIdCard,
2339
+ isPhone,
2340
+ phoneRegex,
2341
+ phoneValidator,
1849
2342
  useCallbackTrigger,
2343
+ useFormValidate,
1850
2344
  useLoading,
1851
2345
  useMessage,
1852
2346
  useMessageBox,
1853
2347
  useNamespace,
1854
2348
  useNotification,
1855
- useShowModal
2349
+ useShowModal,
2350
+ useVisibleValue
1856
2351
  };