yc-pro-components 0.0.12 → 0.0.13

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 (103) hide show
  1. package/es/components/dialog-form/index.d.ts +14 -2
  2. package/es/components/dialog-form/src/index.vue.d.ts +14 -2
  3. package/es/components/display-item/index.d.ts +42 -6
  4. package/es/components/display-item/src/index.vue.d.ts +42 -6
  5. package/es/components/drawer-form/index.d.ts +14 -2
  6. package/es/components/drawer-form/src/index.vue.d.ts +14 -2
  7. package/es/components/form/index.d.ts +28 -4
  8. package/es/components/form/src/form-content.vue.d.ts +42 -6
  9. package/es/components/form/src/index.vue.d.ts +28 -4
  10. package/es/components/form-item/index.d.ts +88 -16
  11. package/es/components/form-item/src/index.vue.d.ts +35 -4
  12. package/es/components/form-item/src/index.vue2.mjs +1 -0
  13. package/es/components/page/index.d.ts +224 -32
  14. package/es/components/page/src/index.vue.d.ts +84 -12
  15. package/es/components/page/src/index.vue2.mjs +1 -1
  16. package/es/components/render/index.d.ts +3 -3
  17. package/es/components/render/src/index.vue.d.ts +1 -1
  18. package/es/components/search/index.d.ts +98 -14
  19. package/es/components/search/src/index.vue.d.ts +42 -6
  20. package/es/components/table/src/table-action-bar.vue2.mjs +1 -1
  21. package/es/components/table/src/table-column.vue.d.ts +42 -6
  22. package/es/components/yc-plus-page/src/index.vue.d.ts +154 -22
  23. package/es/constants/dict.d.ts +78 -0
  24. package/es/constants/dict.mjs +3 -0
  25. package/es/constants/index.d.ts +1 -0
  26. package/es/constants/index.mjs +1 -0
  27. package/es/hooks/index.d.ts +1 -0
  28. package/es/hooks/index.mjs +1 -0
  29. package/es/hooks/useDictInjection.d.ts +38 -0
  30. package/es/hooks/useDictInjection.mjs +18 -0
  31. package/es/hooks/useGetOptions.mjs +118 -30
  32. package/es/hooks/usePlusFormReset.d.ts +84 -12
  33. package/es/index.d.ts +1 -1
  34. package/es/index.mjs +2 -0
  35. package/es/types/plus.d.ts +74 -0
  36. package/es/version.d.ts +1 -1
  37. package/es/version.mjs +1 -1
  38. package/es/yc-components/index.d.ts +1 -1
  39. package/es/yc-components/version.d.ts +1 -1
  40. package/index.js +165 -59
  41. package/index.min.js +7 -7
  42. package/index.min.mjs +7 -7
  43. package/index.mjs +165 -61
  44. package/lib/components/dialog-form/index.d.ts +14 -2
  45. package/lib/components/dialog-form/src/index.vue.d.ts +14 -2
  46. package/lib/components/display-item/index.d.ts +42 -6
  47. package/lib/components/display-item/src/index.vue.d.ts +42 -6
  48. package/lib/components/drawer-form/index.d.ts +14 -2
  49. package/lib/components/drawer-form/src/index.vue.d.ts +14 -2
  50. package/lib/components/form/index.d.ts +28 -4
  51. package/lib/components/form/src/form-content.vue.d.ts +42 -6
  52. package/lib/components/form/src/index.vue.d.ts +28 -4
  53. package/lib/components/form-item/index.d.ts +88 -16
  54. package/lib/components/form-item/src/index.vue.d.ts +35 -4
  55. package/lib/components/form-item/src/index.vue2.js +1 -0
  56. package/lib/components/page/index.d.ts +224 -32
  57. package/lib/components/page/src/index.vue.d.ts +84 -12
  58. package/lib/components/page/src/index.vue2.js +1 -1
  59. package/lib/components/render/index.d.ts +3 -3
  60. package/lib/components/render/src/index.vue.d.ts +1 -1
  61. package/lib/components/search/index.d.ts +98 -14
  62. package/lib/components/search/src/index.vue.d.ts +42 -6
  63. package/lib/components/table/src/table-action-bar.vue2.js +1 -1
  64. package/lib/components/table/src/table-column.vue.d.ts +42 -6
  65. package/lib/components/yc-plus-page/src/index.vue.d.ts +154 -22
  66. package/lib/constants/dict.d.ts +78 -0
  67. package/lib/constants/dict.js +5 -0
  68. package/lib/constants/index.d.ts +1 -0
  69. package/lib/constants/index.js +2 -0
  70. package/lib/hooks/index.d.ts +1 -0
  71. package/lib/hooks/index.js +2 -0
  72. package/lib/hooks/useDictInjection.d.ts +38 -0
  73. package/lib/hooks/useDictInjection.js +20 -0
  74. package/lib/hooks/useGetOptions.js +117 -29
  75. package/lib/hooks/usePlusFormReset.d.ts +84 -12
  76. package/lib/index.d.ts +1 -1
  77. package/lib/index.js +4 -0
  78. package/lib/types/plus.d.ts +74 -0
  79. package/lib/version.d.ts +1 -1
  80. package/lib/version.js +1 -1
  81. package/lib/yc-components/index.d.ts +1 -1
  82. package/lib/yc-components/version.d.ts +1 -1
  83. package/locale/en.js +1 -1
  84. package/locale/en.min.js +1 -1
  85. package/locale/en.min.mjs +1 -1
  86. package/locale/en.mjs +1 -1
  87. package/locale/ja.js +1 -1
  88. package/locale/ja.min.js +1 -1
  89. package/locale/ja.min.mjs +1 -1
  90. package/locale/ja.mjs +1 -1
  91. package/locale/ko.js +1 -1
  92. package/locale/ko.min.js +1 -1
  93. package/locale/ko.min.mjs +1 -1
  94. package/locale/ko.mjs +1 -1
  95. package/locale/zh-cn.js +1 -1
  96. package/locale/zh-cn.min.js +1 -1
  97. package/locale/zh-cn.min.mjs +1 -1
  98. package/locale/zh-cn.mjs +1 -1
  99. package/locale/zh-tw.js +1 -1
  100. package/locale/zh-tw.min.js +1 -1
  101. package/locale/zh-tw.min.mjs +1 -1
  102. package/locale/zh-tw.mjs +1 -1
  103. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! yc-pro-components v0.0.12 */
1
+ /*! yc-pro-components v0.0.13 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('element-plus')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'vue', 'element-plus'], factory) :
@@ -4770,6 +4770,36 @@
4770
4770
  return data;
4771
4771
  };
4772
4772
 
4773
+ const DefaultPageSizeList = [10, 20, 30, 40, 50, 100, 200, 300, 400, 500];
4774
+ const DefaultPageInfo = {
4775
+ page: 1,
4776
+ pageSize: 10
4777
+ };
4778
+
4779
+ const TableFormRefInjectionKey = Symbol("tableFormRefInjectionKey");
4780
+ const TableFormFieldRefInjectionKey = Symbol("tableFormFieldRefInjectionKey");
4781
+ const TableFormRowInfoInjectionKey = Symbol("tableFormRowInfoInjectionKey");
4782
+ const DatePickerValueIsArrayList = ["datetimerange", "daterange", "monthrange"];
4783
+ const ValueIsNumberList = ["rate", "input-number", "slider"];
4784
+ const ValueIsBooleanList = ["switch"];
4785
+ const ValueIsArrayList = [
4786
+ "checkbox",
4787
+ "cascader",
4788
+ "plus-date-picker",
4789
+ "plus-input-tag",
4790
+ "transfer"
4791
+ ];
4792
+
4793
+ const selectValueTypeList = [
4794
+ "select",
4795
+ "radio",
4796
+ "checkbox",
4797
+ "select-v2",
4798
+ "plus-radio"
4799
+ ];
4800
+
4801
+ const DictStoreInjectionKey = Symbol("DictStore");
4802
+
4773
4803
  const throwError = (data) => {
4774
4804
  if (!isArray(data)) {
4775
4805
  console.error("Uncaught TypeError: ", `options expected Array but got ${toRawType(data)}`);
@@ -4796,27 +4826,53 @@
4796
4826
  const useGetOptions = (props) => {
4797
4827
  const options = vue.ref([]);
4798
4828
  const optionsIsReady = vue.ref(false);
4799
- if (!props.options) {
4829
+ const injectedDictStore = vue.inject(DictStoreInjectionKey, null);
4830
+ const hasValidOptions = props.options && (!isArray(props.options) || props.options.length > 0);
4831
+ if (hasValidOptions) {
4832
+ handleOptions();
4833
+ } else if (props.autoDict) {
4834
+ handleAutoDict();
4835
+ } else {
4800
4836
  options.value = [];
4801
4837
  optionsIsReady.value = true;
4802
- } else if (vue.isRef(props.options) || vue.isReactive(props.options) || isArray(props.options)) {
4803
- vue.watch(
4804
- () => props.options,
4805
- (val) => {
4806
- const value = vue.isRef(val) ? val.value : val;
4807
- options.value = getOptionsByOptionsMap(value, props);
4838
+ }
4839
+ function handleOptions() {
4840
+ if (!props.options) {
4841
+ options.value = [];
4842
+ optionsIsReady.value = true;
4843
+ return;
4844
+ }
4845
+ if (vue.isRef(props.options) || vue.isReactive(props.options) || isArray(props.options)) {
4846
+ vue.watch(
4847
+ () => props.options,
4848
+ (val) => {
4849
+ const value = vue.isRef(val) ? val.value : val;
4850
+ options.value = getOptionsByOptionsMap(value, props);
4851
+ optionsIsReady.value = true;
4852
+ },
4853
+ {
4854
+ immediate: true,
4855
+ deep: true
4856
+ }
4857
+ );
4858
+ } else if (isFunction(props.options)) {
4859
+ const getValue = props.options;
4860
+ const result = getValue(props);
4861
+ if (isPromise(result)) {
4862
+ result.then((value) => {
4863
+ options.value = getOptionsByOptionsMap(value, props);
4864
+ optionsIsReady.value = true;
4865
+ throwError(options.value);
4866
+ }).catch((err) => {
4867
+ throw err;
4868
+ });
4869
+ } else {
4870
+ options.value = getOptionsByOptionsMap(result, props);
4808
4871
  optionsIsReady.value = true;
4809
- },
4810
- {
4811
- immediate: true,
4812
- deep: true
4813
4872
  }
4814
- );
4815
- } else if (isFunction(props.options)) {
4816
- const getValue = props.options;
4817
- const result = getValue(props);
4818
- if (isPromise(result)) {
4819
- result.then((value) => {
4873
+ } else if (isPromise(props.options)) {
4874
+ const getValue = props.options;
4875
+ getValue.then((value) => {
4820
4876
  options.value = getOptionsByOptionsMap(value, props);
4821
4877
  optionsIsReady.value = true;
4822
4878
  throwError(options.value);
@@ -4824,21 +4880,82 @@
4824
4880
  throw err;
4825
4881
  });
4826
4882
  } else {
4827
- options.value = getOptionsByOptionsMap(result, props);
4828
4883
  optionsIsReady.value = true;
4884
+ throwError(props.options);
4829
4885
  }
4830
- } else if (isPromise(props.options)) {
4831
- const getValue = props.options;
4832
- getValue.then((value) => {
4833
- options.value = getOptionsByOptionsMap(value, props);
4886
+ }
4887
+ function handleAutoDict() {
4888
+ if (isFunction(props.autoDict)) {
4889
+ const autoDictFn = props.autoDict;
4890
+ vue.watch(
4891
+ () => {
4892
+ return autoDictFn(props);
4893
+ },
4894
+ (result) => {
4895
+ if (isPromise(result)) {
4896
+ result.then((value) => {
4897
+ options.value = getOptionsByOptionsMap(value, props);
4898
+ optionsIsReady.value = true;
4899
+ }).catch((err) => {
4900
+ console.error("[yc-components] autoDict function error:", err);
4901
+ options.value = [];
4902
+ optionsIsReady.value = true;
4903
+ });
4904
+ } else {
4905
+ options.value = getOptionsByOptionsMap(result, props);
4906
+ optionsIsReady.value = true;
4907
+ }
4908
+ },
4909
+ { immediate: true }
4910
+ );
4911
+ } else if (typeof props.autoDict === "object" && props.autoDict !== null) {
4912
+ const { store, method = "getDictData", transform, dictCode } = props.autoDict;
4913
+ const dictStore = store || injectedDictStore;
4914
+ const fieldOrCode = dictCode || props.prop;
4915
+ if (dictStore && isFunction(dictStore[method])) {
4916
+ vue.watch(
4917
+ () => dictStore[method](fieldOrCode),
4918
+ (val) => {
4919
+ try {
4920
+ const data = transform && isFunction(transform) ? transform(val) : val;
4921
+ options.value = getOptionsByOptionsMap(data, props);
4922
+ optionsIsReady.value = true;
4923
+ } catch (err) {
4924
+ console.error("[yc-components] autoDict transform error:", err);
4925
+ options.value = [];
4926
+ optionsIsReady.value = true;
4927
+ }
4928
+ },
4929
+ { immediate: true }
4930
+ );
4931
+ } else {
4932
+ console.warn(
4933
+ `[yc-components] autoDict: DictStore or method "${method}" not found for field "${fieldOrCode}"`
4934
+ );
4935
+ options.value = [];
4936
+ optionsIsReady.value = true;
4937
+ }
4938
+ } else if (props.autoDict === true) {
4939
+ if (injectedDictStore && isFunction(injectedDictStore.getDictData)) {
4940
+ vue.watch(
4941
+ () => injectedDictStore.getDictData(props.prop),
4942
+ (val) => {
4943
+ options.value = getOptionsByOptionsMap(val, props);
4944
+ optionsIsReady.value = true;
4945
+ },
4946
+ { immediate: true }
4947
+ );
4948
+ } else {
4949
+ console.warn(
4950
+ `[yc-components] autoDict: DictStore not provided via inject for field "${props.prop}". Please use useDictInjection() in parent component.`
4951
+ );
4952
+ options.value = [];
4953
+ optionsIsReady.value = true;
4954
+ }
4955
+ } else {
4956
+ options.value = [];
4834
4957
  optionsIsReady.value = true;
4835
- throwError(options.value);
4836
- }).catch((err) => {
4837
- throw err;
4838
- });
4839
- } else {
4840
- optionsIsReady.value = true;
4841
- throwError(props.options);
4958
+ }
4842
4959
  }
4843
4960
  return { customOptions: options, customOptionsIsReady: optionsIsReady };
4844
4961
  };
@@ -4937,34 +5054,6 @@
4937
5054
  }));
4938
5055
  };
4939
5056
 
4940
- const DefaultPageSizeList = [10, 20, 30, 40, 50, 100, 200, 300, 400, 500];
4941
- const DefaultPageInfo = {
4942
- page: 1,
4943
- pageSize: 10
4944
- };
4945
-
4946
- const TableFormRefInjectionKey = Symbol("tableFormRefInjectionKey");
4947
- const TableFormFieldRefInjectionKey = Symbol("tableFormFieldRefInjectionKey");
4948
- const TableFormRowInfoInjectionKey = Symbol("tableFormRowInfoInjectionKey");
4949
- const DatePickerValueIsArrayList = ["datetimerange", "daterange", "monthrange"];
4950
- const ValueIsNumberList = ["rate", "input-number", "slider"];
4951
- const ValueIsBooleanList = ["switch"];
4952
- const ValueIsArrayList = [
4953
- "checkbox",
4954
- "cascader",
4955
- "plus-date-picker",
4956
- "plus-input-tag",
4957
- "transfer"
4958
- ];
4959
-
4960
- const selectValueTypeList = [
4961
- "select",
4962
- "radio",
4963
- "checkbox",
4964
- "select-v2",
4965
- "plus-radio"
4966
- ];
4967
-
4968
5057
  function useTable(_pageInfo) {
4969
5058
  const defaultPageInfo = vue.unref(_pageInfo) || DefaultPageInfo;
4970
5059
  const tableData = vue.ref([]);
@@ -8485,6 +8574,20 @@
8485
8574
  };
8486
8575
  }
8487
8576
 
8577
+ function useDictInjection(dictStore) {
8578
+ if (!dictStore) {
8579
+ console.warn("[yc-components] useDictInjection: dictStore is required");
8580
+ return;
8581
+ }
8582
+ if (typeof dictStore.getDictData !== "function") {
8583
+ console.error(
8584
+ "[yc-components] useDictInjection: dictStore must implement getDictData method. Please ensure your dictStore implements DictStoreInterface."
8585
+ );
8586
+ return;
8587
+ }
8588
+ vue.provide(DictStoreInjectionKey, dictStore);
8589
+ }
8590
+
8488
8591
  const _hoisted_1$q = { class: "plus-dialog-body" };
8489
8592
  var _sfc_main$K = /* @__PURE__ */ vue.defineComponent({
8490
8593
  ...{
@@ -15782,6 +15885,7 @@
15782
15885
  fieldChildrenSlot: { type: Function, default: void 0 },
15783
15886
  renderErrorMessage: { type: Function, default: void 0 },
15784
15887
  optionsMap: { default: void 0 },
15888
+ autoDict: { type: [Boolean, Function, Object], default: void 0 },
15785
15889
  index: { default: 0 },
15786
15890
  clearable: { type: Boolean, default: true }
15787
15891
  },
@@ -59639,7 +59743,7 @@
59639
59743
 
59640
59744
  var installer = makeInstaller([...plugins]);
59641
59745
 
59642
- const version = "0.1.30";
59746
+ const version = "0.0.13";
59643
59747
 
59644
59748
  const install = installer.install;
59645
59749
 
@@ -59648,6 +59752,7 @@
59648
59752
  exports.DatePickerValueIsArrayList = DatePickerValueIsArrayList;
59649
59753
  exports.DefaultPageInfo = DefaultPageInfo;
59650
59754
  exports.DefaultPageSizeList = DefaultPageSizeList;
59755
+ exports.DictStoreInjectionKey = DictStoreInjectionKey;
59651
59756
  exports.PlusBreadcrumb = PlusBreadcrumb;
59652
59757
  exports.PlusCheckCard = PlusCheckCard;
59653
59758
  exports.PlusCheckCardGroup = PlusCheckCardGroup;
@@ -59755,6 +59860,7 @@
59755
59860
  exports.selectValueTypeList = selectValueTypeList;
59756
59861
  exports.updateDrawer = updateDrawer;
59757
59862
  exports.useDialogFormConfig = useDialogFormConfig;
59863
+ exports.useDictInjection = useDictInjection;
59758
59864
  exports.useDrawerFormConfig = useDrawerFormConfig;
59759
59865
  exports.useGetOptions = useGetOptions;
59760
59866
  exports.useLocale = useLocale;