yc-pro-components 0.0.11 → 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 (194) hide show
  1. package/es/components/check-card/index.d.ts +61 -61
  2. package/es/components/check-card/src/index.vue.d.ts +4 -4
  3. package/es/components/check-card-group/index.d.ts +43 -43
  4. package/es/components/check-card-group/src/index.vue.d.ts +3 -3
  5. package/es/components/date-picker/index.d.ts +10 -10
  6. package/es/components/date-picker/src/index.vue.d.ts +2 -2
  7. package/es/components/dialog/index.d.ts +26 -26
  8. package/es/components/dialog/src/index.vue.d.ts +2 -2
  9. package/es/components/dialog-form/index.d.ts +44 -32
  10. package/es/components/dialog-form/src/index.vue.d.ts +22 -10
  11. package/es/components/display-item/index.d.ts +80 -44
  12. package/es/components/display-item/src/index.vue.d.ts +61 -25
  13. package/es/components/drawer-form/index.d.ts +63 -51
  14. package/es/components/drawer-form/src/index.vue.d.ts +23 -11
  15. package/es/components/form/index.d.ts +71 -47
  16. package/es/components/form/src/form-content.vue.d.ts +60 -24
  17. package/es/components/form/src/index.vue.d.ts +43 -19
  18. package/es/components/form-item/index.d.ts +129 -57
  19. package/es/components/form-item/src/index.vue.d.ts +46 -15
  20. package/es/components/form-item/src/index.vue2.mjs +1 -0
  21. package/es/components/header/index.d.ts +19 -19
  22. package/es/components/header/src/index.vue.d.ts +1 -1
  23. package/es/components/input-tag/index.d.ts +20 -20
  24. package/es/components/input-tag/src/index.vue.d.ts +8 -8
  25. package/es/components/layout/index.d.ts +30 -30
  26. package/es/components/layout/src/index.vue.d.ts +10 -10
  27. package/es/components/page/index.d.ts +751 -469
  28. package/es/components/page/src/index.vue.d.ts +263 -161
  29. package/es/components/page/src/index.vue2.mjs +1 -1
  30. package/es/components/pagination/index.d.ts +42 -42
  31. package/es/components/pagination/src/index.vue.d.ts +3 -3
  32. package/es/components/radio/index.d.ts +35 -35
  33. package/es/components/radio/src/index.vue.d.ts +27 -27
  34. package/es/components/render/index.d.ts +6 -6
  35. package/es/components/render/src/index.vue.d.ts +2 -2
  36. package/es/components/search/index.d.ts +284 -162
  37. package/es/components/search/src/index.vue.d.ts +95 -53
  38. package/es/components/search/src/index.vue2.mjs +14 -4
  39. package/es/components/search/src/type.d.ts +9 -0
  40. package/es/components/sidebar/index.d.ts +15 -15
  41. package/es/components/sidebar/src/index.vue.d.ts +5 -5
  42. package/es/components/steps-form/index.d.ts +23 -23
  43. package/es/components/steps-form/src/index.vue.d.ts +2 -2
  44. package/es/components/table/index.d.ts +54 -54
  45. package/es/components/table/src/index.vue.d.ts +18 -18
  46. package/es/components/table/src/table-action-bar.vue2.mjs +1 -1
  47. package/es/components/table/src/table-column-drag-sort.vue.d.ts +18 -18
  48. package/es/components/table/src/table-column.vue.d.ts +76 -40
  49. package/es/components/utils/index.d.ts +2 -2
  50. package/es/components/yc-dialog/index.d.ts +24 -24
  51. package/es/components/yc-download-dialog/index.d.ts +19 -19
  52. package/es/components/yc-download-dialog/src/index.vue.d.ts +1 -1
  53. package/es/components/yc-form-container-header/index.d.ts +12 -12
  54. package/es/components/yc-more-actions/index.d.ts +46 -46
  55. package/es/components/yc-more-actions/src/index.vue.d.ts +3 -3
  56. package/es/components/yc-plus-page/src/index.vue.d.ts +588 -529
  57. package/es/components/yc-plus-page/src/index.vue.mjs +1 -1
  58. package/es/components/yc-plus-page/src/index.vue2.mjs +8 -2
  59. package/es/components/yc-segmented/index.d.ts +2 -2
  60. package/es/components/yc-segmented/src/index.d.ts +2 -2
  61. package/es/components/yc-select-v2/src/index.vue.d.ts +3 -3
  62. package/es/components/yc-status-dialog/src/index.vue.d.ts +1 -1
  63. package/es/components/yc-tabs-with-filter/index.d.ts +16 -16
  64. package/es/components/yc-text/src/index.vue.d.ts +2 -2
  65. package/es/constants/dict.d.ts +78 -0
  66. package/es/constants/dict.mjs +3 -0
  67. package/es/constants/index.d.ts +1 -0
  68. package/es/constants/index.mjs +1 -0
  69. package/es/hooks/index.d.ts +1 -0
  70. package/es/hooks/index.mjs +1 -0
  71. package/es/hooks/useDictInjection.d.ts +38 -0
  72. package/es/hooks/useDictInjection.mjs +18 -0
  73. package/es/hooks/useGetOptions.mjs +118 -30
  74. package/es/hooks/usePlusFormReset.d.ts +286 -214
  75. package/es/index.css +1 -1
  76. package/es/index.d.ts +1 -1
  77. package/es/index.mjs +2 -0
  78. package/es/types/plus.d.ts +74 -0
  79. package/es/version.d.ts +1 -1
  80. package/es/version.mjs +1 -1
  81. package/es/yc-components/index.d.ts +1 -1
  82. package/es/yc-components/version.d.ts +1 -1
  83. package/index.css +9 -5
  84. package/index.js +187 -65
  85. package/index.min.css +1 -1
  86. package/index.min.js +7 -7
  87. package/index.min.mjs +7 -7
  88. package/index.mjs +187 -67
  89. package/lib/components/check-card/index.d.ts +61 -61
  90. package/lib/components/check-card/src/index.vue.d.ts +4 -4
  91. package/lib/components/check-card-group/index.d.ts +43 -43
  92. package/lib/components/check-card-group/src/index.vue.d.ts +3 -3
  93. package/lib/components/date-picker/index.d.ts +10 -10
  94. package/lib/components/date-picker/src/index.vue.d.ts +2 -2
  95. package/lib/components/dialog/index.d.ts +26 -26
  96. package/lib/components/dialog/src/index.vue.d.ts +2 -2
  97. package/lib/components/dialog-form/index.d.ts +44 -32
  98. package/lib/components/dialog-form/src/index.vue.d.ts +22 -10
  99. package/lib/components/display-item/index.d.ts +80 -44
  100. package/lib/components/display-item/src/index.vue.d.ts +61 -25
  101. package/lib/components/drawer-form/index.d.ts +63 -51
  102. package/lib/components/drawer-form/src/index.vue.d.ts +23 -11
  103. package/lib/components/form/index.d.ts +71 -47
  104. package/lib/components/form/src/form-content.vue.d.ts +60 -24
  105. package/lib/components/form/src/index.vue.d.ts +43 -19
  106. package/lib/components/form-item/index.d.ts +129 -57
  107. package/lib/components/form-item/src/index.vue.d.ts +46 -15
  108. package/lib/components/form-item/src/index.vue2.js +1 -0
  109. package/lib/components/header/index.d.ts +19 -19
  110. package/lib/components/header/src/index.vue.d.ts +1 -1
  111. package/lib/components/input-tag/index.d.ts +20 -20
  112. package/lib/components/input-tag/src/index.vue.d.ts +8 -8
  113. package/lib/components/layout/index.d.ts +30 -30
  114. package/lib/components/layout/src/index.vue.d.ts +10 -10
  115. package/lib/components/page/index.d.ts +751 -469
  116. package/lib/components/page/src/index.vue.d.ts +263 -161
  117. package/lib/components/page/src/index.vue2.js +1 -1
  118. package/lib/components/pagination/index.d.ts +42 -42
  119. package/lib/components/pagination/src/index.vue.d.ts +3 -3
  120. package/lib/components/radio/index.d.ts +35 -35
  121. package/lib/components/radio/src/index.vue.d.ts +27 -27
  122. package/lib/components/render/index.d.ts +6 -6
  123. package/lib/components/render/src/index.vue.d.ts +2 -2
  124. package/lib/components/search/index.d.ts +284 -162
  125. package/lib/components/search/src/index.vue.d.ts +95 -53
  126. package/lib/components/search/src/index.vue2.js +13 -3
  127. package/lib/components/search/src/type.d.ts +9 -0
  128. package/lib/components/sidebar/index.d.ts +15 -15
  129. package/lib/components/sidebar/src/index.vue.d.ts +5 -5
  130. package/lib/components/steps-form/index.d.ts +23 -23
  131. package/lib/components/steps-form/src/index.vue.d.ts +2 -2
  132. package/lib/components/table/index.d.ts +54 -54
  133. package/lib/components/table/src/index.vue.d.ts +18 -18
  134. package/lib/components/table/src/table-action-bar.vue2.js +1 -1
  135. package/lib/components/table/src/table-column-drag-sort.vue.d.ts +18 -18
  136. package/lib/components/table/src/table-column.vue.d.ts +76 -40
  137. package/lib/components/utils/index.d.ts +2 -2
  138. package/lib/components/yc-dialog/index.d.ts +24 -24
  139. package/lib/components/yc-download-dialog/index.d.ts +19 -19
  140. package/lib/components/yc-download-dialog/src/index.vue.d.ts +1 -1
  141. package/lib/components/yc-form-container-header/index.d.ts +12 -12
  142. package/lib/components/yc-more-actions/index.d.ts +46 -46
  143. package/lib/components/yc-more-actions/src/index.vue.d.ts +3 -3
  144. package/lib/components/yc-plus-page/src/index.vue.d.ts +588 -529
  145. package/lib/components/yc-plus-page/src/index.vue.js +1 -1
  146. package/lib/components/yc-plus-page/src/index.vue2.js +8 -2
  147. package/lib/components/yc-segmented/index.d.ts +2 -2
  148. package/lib/components/yc-segmented/src/index.d.ts +2 -2
  149. package/lib/components/yc-select-v2/src/index.vue.d.ts +3 -3
  150. package/lib/components/yc-status-dialog/src/index.vue.d.ts +1 -1
  151. package/lib/components/yc-tabs-with-filter/index.d.ts +16 -16
  152. package/lib/components/yc-text/src/index.vue.d.ts +2 -2
  153. package/lib/constants/dict.d.ts +78 -0
  154. package/lib/constants/dict.js +5 -0
  155. package/lib/constants/index.d.ts +1 -0
  156. package/lib/constants/index.js +2 -0
  157. package/lib/hooks/index.d.ts +1 -0
  158. package/lib/hooks/index.js +2 -0
  159. package/lib/hooks/useDictInjection.d.ts +38 -0
  160. package/lib/hooks/useDictInjection.js +20 -0
  161. package/lib/hooks/useGetOptions.js +117 -29
  162. package/lib/hooks/usePlusFormReset.d.ts +286 -214
  163. package/lib/index.css +1 -1
  164. package/lib/index.d.ts +1 -1
  165. package/lib/index.js +4 -0
  166. package/lib/types/plus.d.ts +74 -0
  167. package/lib/version.d.ts +1 -1
  168. package/lib/version.js +1 -1
  169. package/lib/yc-components/index.d.ts +1 -1
  170. package/lib/yc-components/version.d.ts +1 -1
  171. package/locale/en.js +1 -1
  172. package/locale/en.min.js +1 -1
  173. package/locale/en.min.mjs +1 -1
  174. package/locale/en.mjs +1 -1
  175. package/locale/ja.js +1 -1
  176. package/locale/ja.min.js +1 -1
  177. package/locale/ja.min.mjs +1 -1
  178. package/locale/ja.mjs +1 -1
  179. package/locale/ko.js +1 -1
  180. package/locale/ko.min.js +1 -1
  181. package/locale/ko.min.mjs +1 -1
  182. package/locale/ko.mjs +1 -1
  183. package/locale/zh-cn.js +1 -1
  184. package/locale/zh-cn.min.js +1 -1
  185. package/locale/zh-cn.min.mjs +1 -1
  186. package/locale/zh-cn.mjs +1 -1
  187. package/locale/zh-tw.js +1 -1
  188. package/locale/zh-tw.min.js +1 -1
  189. package/locale/zh-tw.min.mjs +1 -1
  190. package/locale/zh-tw.mjs +1 -1
  191. package/package.json +1 -1
  192. package/theme-chalk/index.css +1 -1
  193. package/theme-chalk/plus-page.css +1 -1
  194. package/theme-chalk/src/page.scss +1 -1
@@ -5,6 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var index_vue_vue_type_script_setup_true_lang = require('./index.vue2.js');
6
6
  var _pluginVue_exportHelper = require('../../../_virtual/_plugin-vue_export-helper.js');
7
7
 
8
- var YcPlusPageComponent = /* @__PURE__ */ _pluginVue_exportHelper.default(index_vue_vue_type_script_setup_true_lang.default, [["__scopeId", "data-v-4486eb75"], ["__file", "index.vue"]]);
8
+ var YcPlusPageComponent = /* @__PURE__ */ _pluginVue_exportHelper.default(index_vue_vue_type_script_setup_true_lang.default, [["__scopeId", "data-v-7c1490fd"], ["__file", "index.vue"]]);
9
9
 
10
10
  exports.default = YcPlusPageComponent;
@@ -150,7 +150,10 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
150
150
  hasUnfold: false,
151
151
  rowProps: { gutter: 0 },
152
152
  colProps: { span: getSpanByCount(searchableFieldsCount.value) },
153
- labelSuffix: ""
153
+ labelSuffix: "",
154
+ labelPosition: "right",
155
+ searchIcon: null,
156
+ resetIcon: null
154
157
  };
155
158
  return lodashEs.merge({}, defaultSearchConfig, props.search);
156
159
  }
@@ -158,7 +161,10 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
158
161
  hasUnfold: false,
159
162
  rowProps: { gutter: 0 },
160
163
  colProps: { span: getSpanByCount(searchableFieldsCount.value) },
161
- labelSuffix: ""
164
+ labelSuffix: "",
165
+ labelPosition: "right",
166
+ searchIcon: null,
167
+ resetIcon: null
162
168
  };
163
169
  });
164
170
  const mergedSearchCardProps = vue.computed(() => {
@@ -54,12 +54,12 @@ export declare const YcSegmentedWithInstall: SFCWithInstall<DefineComponent<{
54
54
  default: boolean;
55
55
  };
56
56
  }>> & {
57
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
58
57
  onChange?: ((...args: any[]) => any) | undefined;
58
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
59
59
  }, {
60
- modelValue: string | number;
61
60
  disabled: boolean;
62
61
  options: YcSegmentedOption[];
62
+ modelValue: string | number;
63
63
  resize: boolean;
64
64
  block: boolean;
65
65
  }, {}>>;
@@ -62,12 +62,12 @@ declare const _default: DefineComponent<{
62
62
  default: boolean;
63
63
  };
64
64
  }>> & {
65
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
66
65
  onChange?: ((...args: any[]) => any) | undefined;
66
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
67
67
  }, {
68
- modelValue: string | number;
69
68
  disabled: boolean;
70
69
  options: YcSegmentedOption[];
70
+ modelValue: string | number;
71
71
  resize: boolean;
72
72
  block: boolean;
73
73
  }, {}>;
@@ -44,14 +44,14 @@ declare const _default: DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRunt
44
44
  initialOptions: () => never[];
45
45
  allSelect: boolean;
46
46
  }>>> & {
47
- "onUpdate:modelValue"?: ((value: FieldValueType) => any) | undefined;
48
47
  onChange?: ((value: SelectValueType) => any) | undefined;
48
+ "onUpdate:modelValue"?: ((value: FieldValueType) => any) | undefined;
49
49
  }, {
50
- modelValue: string | number | boolean | string[] | [string, string] | boolean[] | RecordType | Date | number[] | Date[] | [Date, Date] | [number, number] | string[][] | number[][] | null;
51
- filterable: boolean;
52
50
  disabled: boolean;
51
+ filterable: boolean;
53
52
  options: SelectOption[];
54
53
  pageSize: number;
54
+ modelValue: string | number | boolean | string[] | [string, string] | number[] | Date | RecordType | boolean[] | Date[] | [Date, Date] | [number, number] | string[][] | number[][] | null;
55
55
  multiple: boolean;
56
56
  clearable: boolean;
57
57
  placeholder: string;
@@ -28,9 +28,9 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
28
28
  onCancel?: (() => any) | undefined;
29
29
  onConfirm?: (() => any) | undefined;
30
30
  }, {
31
+ content: string;
31
32
  title: string;
32
33
  width: string | number;
33
- content: string;
34
34
  visible: boolean;
35
35
  status: StatusType;
36
36
  cancelText: string;
@@ -5,14 +5,14 @@ import { default as YcTabsWithFilter } from './src/index.vue';
5
5
  /** 带筛选按钮的 Tabs 组件 */
6
6
  export declare const YcTabsWithFilterWithInstall: SFCWithInstall<{
7
7
  new (...args: any[]): CreateComponentPublicInstance<Readonly< ExtractPropTypes<{
8
- filterText: {
9
- type: PropType<string>;
10
- default: undefined;
11
- };
12
8
  modelValue: {
13
9
  type: PropType<string>;
14
10
  required: true;
15
11
  };
12
+ filterText: {
13
+ type: PropType<string>;
14
+ default: undefined;
15
+ };
16
16
  showFilter: {
17
17
  type: PropType<boolean>;
18
18
  default: boolean;
@@ -38,14 +38,14 @@ export declare const YcTabsWithFilterWithInstall: SFCWithInstall<{
38
38
  "update:modelValue": (value: string) => void;
39
39
  "filter-toggle": (visible: boolean) => void;
40
40
  }, VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly< ExtractPropTypes<{
41
- filterText: {
42
- type: PropType<string>;
43
- default: undefined;
44
- };
45
41
  modelValue: {
46
42
  type: PropType<string>;
47
43
  required: true;
48
44
  };
45
+ filterText: {
46
+ type: PropType<string>;
47
+ default: undefined;
48
+ };
49
49
  showFilter: {
50
50
  type: PropType<boolean>;
51
51
  default: boolean;
@@ -79,14 +79,14 @@ export declare const YcTabsWithFilterWithInstall: SFCWithInstall<{
79
79
  M: {};
80
80
  Defaults: {};
81
81
  }, Readonly< ExtractPropTypes<{
82
- filterText: {
83
- type: PropType<string>;
84
- default: undefined;
85
- };
86
82
  modelValue: {
87
83
  type: PropType<string>;
88
84
  required: true;
89
85
  };
86
+ filterText: {
87
+ type: PropType<string>;
88
+ default: undefined;
89
+ };
90
90
  showFilter: {
91
91
  type: PropType<boolean>;
92
92
  default: boolean;
@@ -119,14 +119,14 @@ export declare const YcTabsWithFilterWithInstall: SFCWithInstall<{
119
119
  __isTeleport?: undefined;
120
120
  __isSuspense?: undefined;
121
121
  } & ComponentOptionsBase<Readonly< ExtractPropTypes<{
122
- filterText: {
123
- type: PropType<string>;
124
- default: undefined;
125
- };
126
122
  modelValue: {
127
123
  type: PropType<string>;
128
124
  required: true;
129
125
  };
126
+ filterText: {
127
+ type: PropType<string>;
128
+ default: undefined;
129
+ };
130
130
  showFilter: {
131
131
  type: PropType<boolean>;
132
132
  default: boolean;
@@ -9,7 +9,7 @@ interface TippyOptions {
9
9
  declare const _default: __VLS_WithTemplateSlots< DefineComponent<{
10
10
  /** 行数限制 */
11
11
  lineClamp: {
12
- type: (NumberConstructor | StringConstructor)[];
12
+ type: (StringConstructor | NumberConstructor)[];
13
13
  };
14
14
  /** Tippy 配置 */
15
15
  tippyProps: {
@@ -19,7 +19,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<{
19
19
  }, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly< ExtractPropTypes<{
20
20
  /** 行数限制 */
21
21
  lineClamp: {
22
- type: (NumberConstructor | StringConstructor)[];
22
+ type: (StringConstructor | NumberConstructor)[];
23
23
  };
24
24
  /** Tippy 配置 */
25
25
  tippyProps: {
@@ -0,0 +1,78 @@
1
+ import { OptionsRow } from 'yc-pro-components/es/types';
2
+ import { InjectionKey } from 'vue';
3
+
4
+ /**
5
+ * 字典 Store 标准接口
6
+ * @description 所有项目的字典 Store 必须实现此接口才能使用自动字典注入功能
7
+ * @version v0.2.0
8
+ * @example
9
+ * ```ts
10
+ * import type { DictStoreInterface } from 'yc-components'
11
+ *
12
+ * export const useDictStore = defineStore('dict', () => {
13
+ * const getDictData = (field: string): OptionsRow[] => {
14
+ * // 返回字典数据
15
+ * return dictData.value[field] || []
16
+ * }
17
+ *
18
+ * const hasDict = (field: string): boolean => {
19
+ * return !!dictData.value[field]
20
+ * }
21
+ *
22
+ * const getDictLabel = (field: string, value: string | number): string => {
23
+ * const items = dictData.value[field] || []
24
+ * const item = items.find(item => item.value === value)
25
+ * return item?.label || String(value)
26
+ * }
27
+ *
28
+ * return { getDictData, hasDict, getDictLabel }
29
+ * })
30
+ * ```
31
+ */
32
+ export interface DictStoreInterface {
33
+ /**
34
+ * 根据字段名或字典 code 获取字典数据
35
+ * @param field 字段名(如 "status")或字典 code(如 "ORDER_STATUS")
36
+ * @returns 字典选项数组
37
+ * @description 此方法是核心方法,必须实现
38
+ */
39
+ getDictData: (field: string) => OptionsRow[];
40
+ /**
41
+ * 检查字段是否有字典映射
42
+ * @param field 字段名或字典 code
43
+ * @returns 是否存在字典数据
44
+ * @description 可选方法,用于优化性能
45
+ */
46
+ hasDict?: (field: string) => boolean;
47
+ /**
48
+ * 获取字典标签
49
+ * @param field 字段名或字典 code
50
+ * @param value 字典值
51
+ * @returns 字典标签
52
+ * @description 可选方法,用于显示字典标签
53
+ */
54
+ getDictLabel?: (field: string, value: string | number) => string;
55
+ }
56
+ /**
57
+ * 字典 Store 注入 Key
58
+ * @description 用于 provide/inject 传递字典 Store 实例
59
+ * @version v0.2.0
60
+ * @example
61
+ * ```ts
62
+ * // 提供字典 Store
63
+ * import { provide } from 'vue'
64
+ * import { DictStoreInjectionKey } from 'yc-components'
65
+ *
66
+ * const dictStore = useDictStore()
67
+ * provide(DictStoreInjectionKey, dictStore)
68
+ * ```
69
+ *
70
+ * ```ts
71
+ * // 注入字典 Store
72
+ * import { inject } from 'vue'
73
+ * import { DictStoreInjectionKey } from 'yc-components'
74
+ *
75
+ * const dictStore = inject(DictStoreInjectionKey)
76
+ * ```
77
+ */
78
+ export declare const DictStoreInjectionKey: InjectionKey<DictStoreInterface>;
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const DictStoreInjectionKey = Symbol("DictStore");
4
+
5
+ exports.DictStoreInjectionKey = DictStoreInjectionKey;
@@ -1,3 +1,4 @@
1
1
  export * from './page';
2
2
  export * from './form';
3
3
  export * from './display-item';
4
+ export * from './dict';
@@ -3,6 +3,7 @@
3
3
  var page = require('./page.js');
4
4
  var form = require('./form.js');
5
5
  var displayItem = require('./display-item.js');
6
+ var dict = require('./dict.js');
6
7
 
7
8
 
8
9
 
@@ -16,3 +17,4 @@ exports.ValueIsArrayList = form.ValueIsArrayList;
16
17
  exports.ValueIsBooleanList = form.ValueIsBooleanList;
17
18
  exports.ValueIsNumberList = form.ValueIsNumberList;
18
19
  exports.selectValueTypeList = displayItem.selectValueTypeList;
20
+ exports.DictStoreInjectionKey = dict.DictStoreInjectionKey;
@@ -6,3 +6,4 @@ export * from './usePlusProConfig';
6
6
  export * from './useSortableDrag';
7
7
  export * from './usePlusFormReset';
8
8
  export * from './useSelectWithPagination';
9
+ export * from './useDictInjection';
@@ -8,6 +8,7 @@ var usePlusProConfig = require('./usePlusProConfig.js');
8
8
  var useSortableDrag = require('./useSortableDrag.js');
9
9
  var usePlusFormReset = require('./usePlusFormReset.js');
10
10
  var useSelectWithPagination = require('./useSelectWithPagination.js');
11
+ var useDictInjection = require('./useDictInjection.js');
11
12
 
12
13
 
13
14
 
@@ -28,3 +29,4 @@ exports.usePlusFormClearValidate = usePlusFormReset.usePlusFormClearValidate;
28
29
  exports.usePlusFormFullReset = usePlusFormReset.usePlusFormFullReset;
29
30
  exports.usePlusFormReset = usePlusFormReset.usePlusFormReset;
30
31
  exports.useSelectWithPagination = useSelectWithPagination.useSelectWithPagination;
32
+ exports.useDictInjection = useDictInjection.useDictInjection;
@@ -0,0 +1,38 @@
1
+ import { DictStoreInterface } from 'yc-pro-components/es/constants';
2
+
3
+ /**
4
+ * 提供字典 Store 给子组件
5
+ * @param dictStore 字典 Store 实例,必须实现 DictStoreInterface 接口
6
+ * @description 在父组件中调用此函数,将字典 Store 提供给所有子组件使用
7
+ * @version v0.2.0
8
+ * @example
9
+ * ```vue
10
+ * <!-- 在父组件中提供字典 Store -->
11
+ * <script setup lang="ts">
12
+ * import { useDictInjection } from 'yc-components'
13
+ * import { useFieldCatalogStore } from '@/store/modules/fieldCatalog'
14
+ *
15
+ * const fieldCatalogStore = useFieldCatalogStore()
16
+ *
17
+ * // 提供字典 Store 给所有子组件
18
+ * useDictInjection(fieldCatalogStore)
19
+ * </script>
20
+ *
21
+ * <template>
22
+ * <PlusPage :columns="columns" />
23
+ * </template>
24
+ * ```
25
+ *
26
+ * ```ts
27
+ * // 子组件中使用 autoDict
28
+ * const columns: PlusColumn[] = [
29
+ * {
30
+ * label: '状态',
31
+ * prop: 'status',
32
+ * valueType: 'select',
33
+ * autoDict: true // 自动从父组件注入的 dictStore 获取
34
+ * }
35
+ * ]
36
+ * ```
37
+ */
38
+ export declare function useDictInjection(dictStore: DictStoreInterface): void;
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var vue = require('vue');
4
+ var dict = require('../constants/dict.js');
5
+
6
+ function useDictInjection(dictStore) {
7
+ if (!dictStore) {
8
+ console.warn("[yc-components] useDictInjection: dictStore is required");
9
+ return;
10
+ }
11
+ if (typeof dictStore.getDictData !== "function") {
12
+ console.error(
13
+ "[yc-components] useDictInjection: dictStore must implement getDictData method. Please ensure your dictStore implements DictStoreInterface."
14
+ );
15
+ return;
16
+ }
17
+ vue.provide(dict.DictStoreInjectionKey, dictStore);
18
+ }
19
+
20
+ exports.useDictInjection = useDictInjection;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var vue = require('vue');
4
+ var dict = require('../constants/dict.js');
4
5
  var is = require('../components/utils/is.js');
5
6
 
6
7
  const throwError = (data) => {
@@ -29,27 +30,53 @@ const getOptionsByOptionsMap = (options, props) => {
29
30
  const useGetOptions = (props) => {
30
31
  const options = vue.ref([]);
31
32
  const optionsIsReady = vue.ref(false);
32
- if (!props.options) {
33
+ const injectedDictStore = vue.inject(dict.DictStoreInjectionKey, null);
34
+ const hasValidOptions = props.options && (!is.isArray(props.options) || props.options.length > 0);
35
+ if (hasValidOptions) {
36
+ handleOptions();
37
+ } else if (props.autoDict) {
38
+ handleAutoDict();
39
+ } else {
33
40
  options.value = [];
34
41
  optionsIsReady.value = true;
35
- } else if (vue.isRef(props.options) || vue.isReactive(props.options) || is.isArray(props.options)) {
36
- vue.watch(
37
- () => props.options,
38
- (val) => {
39
- const value = vue.isRef(val) ? val.value : val;
40
- options.value = getOptionsByOptionsMap(value, props);
42
+ }
43
+ function handleOptions() {
44
+ if (!props.options) {
45
+ options.value = [];
46
+ optionsIsReady.value = true;
47
+ return;
48
+ }
49
+ if (vue.isRef(props.options) || vue.isReactive(props.options) || is.isArray(props.options)) {
50
+ vue.watch(
51
+ () => props.options,
52
+ (val) => {
53
+ const value = vue.isRef(val) ? val.value : val;
54
+ options.value = getOptionsByOptionsMap(value, props);
55
+ optionsIsReady.value = true;
56
+ },
57
+ {
58
+ immediate: true,
59
+ deep: true
60
+ }
61
+ );
62
+ } else if (is.isFunction(props.options)) {
63
+ const getValue = props.options;
64
+ const result = getValue(props);
65
+ if (is.isPromise(result)) {
66
+ result.then((value) => {
67
+ options.value = getOptionsByOptionsMap(value, props);
68
+ optionsIsReady.value = true;
69
+ throwError(options.value);
70
+ }).catch((err) => {
71
+ throw err;
72
+ });
73
+ } else {
74
+ options.value = getOptionsByOptionsMap(result, props);
41
75
  optionsIsReady.value = true;
42
- },
43
- {
44
- immediate: true,
45
- deep: true
46
76
  }
47
- );
48
- } else if (is.isFunction(props.options)) {
49
- const getValue = props.options;
50
- const result = getValue(props);
51
- if (is.isPromise(result)) {
52
- result.then((value) => {
77
+ } else if (is.isPromise(props.options)) {
78
+ const getValue = props.options;
79
+ getValue.then((value) => {
53
80
  options.value = getOptionsByOptionsMap(value, props);
54
81
  optionsIsReady.value = true;
55
82
  throwError(options.value);
@@ -57,21 +84,82 @@ const useGetOptions = (props) => {
57
84
  throw err;
58
85
  });
59
86
  } else {
60
- options.value = getOptionsByOptionsMap(result, props);
61
87
  optionsIsReady.value = true;
88
+ throwError(props.options);
62
89
  }
63
- } else if (is.isPromise(props.options)) {
64
- const getValue = props.options;
65
- getValue.then((value) => {
66
- options.value = getOptionsByOptionsMap(value, props);
90
+ }
91
+ function handleAutoDict() {
92
+ if (is.isFunction(props.autoDict)) {
93
+ const autoDictFn = props.autoDict;
94
+ vue.watch(
95
+ () => {
96
+ return autoDictFn(props);
97
+ },
98
+ (result) => {
99
+ if (is.isPromise(result)) {
100
+ result.then((value) => {
101
+ options.value = getOptionsByOptionsMap(value, props);
102
+ optionsIsReady.value = true;
103
+ }).catch((err) => {
104
+ console.error("[yc-components] autoDict function error:", err);
105
+ options.value = [];
106
+ optionsIsReady.value = true;
107
+ });
108
+ } else {
109
+ options.value = getOptionsByOptionsMap(result, props);
110
+ optionsIsReady.value = true;
111
+ }
112
+ },
113
+ { immediate: true }
114
+ );
115
+ } else if (typeof props.autoDict === "object" && props.autoDict !== null) {
116
+ const { store, method = "getDictData", transform, dictCode } = props.autoDict;
117
+ const dictStore = store || injectedDictStore;
118
+ const fieldOrCode = dictCode || props.prop;
119
+ if (dictStore && is.isFunction(dictStore[method])) {
120
+ vue.watch(
121
+ () => dictStore[method](fieldOrCode),
122
+ (val) => {
123
+ try {
124
+ const data = transform && is.isFunction(transform) ? transform(val) : val;
125
+ options.value = getOptionsByOptionsMap(data, props);
126
+ optionsIsReady.value = true;
127
+ } catch (err) {
128
+ console.error("[yc-components] autoDict transform error:", err);
129
+ options.value = [];
130
+ optionsIsReady.value = true;
131
+ }
132
+ },
133
+ { immediate: true }
134
+ );
135
+ } else {
136
+ console.warn(
137
+ `[yc-components] autoDict: DictStore or method "${method}" not found for field "${fieldOrCode}"`
138
+ );
139
+ options.value = [];
140
+ optionsIsReady.value = true;
141
+ }
142
+ } else if (props.autoDict === true) {
143
+ if (injectedDictStore && is.isFunction(injectedDictStore.getDictData)) {
144
+ vue.watch(
145
+ () => injectedDictStore.getDictData(props.prop),
146
+ (val) => {
147
+ options.value = getOptionsByOptionsMap(val, props);
148
+ optionsIsReady.value = true;
149
+ },
150
+ { immediate: true }
151
+ );
152
+ } else {
153
+ console.warn(
154
+ `[yc-components] autoDict: DictStore not provided via inject for field "${props.prop}". Please use useDictInjection() in parent component.`
155
+ );
156
+ options.value = [];
157
+ optionsIsReady.value = true;
158
+ }
159
+ } else {
160
+ options.value = [];
67
161
  optionsIsReady.value = true;
68
- throwError(options.value);
69
- }).catch((err) => {
70
- throw err;
71
- });
72
- } else {
73
- optionsIsReady.value = true;
74
- throwError(props.options);
162
+ }
75
163
  }
76
164
  return { customOptions: options, customOptionsIsReady: optionsIsReady };
77
165
  };