duck-vue-components 0.0.0

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 (123) hide show
  1. package/README.md +29 -0
  2. package/dist/MyButton-C1krVCi6.cjs +36 -0
  3. package/dist/MyButton-C7riFwH6.js +28 -0
  4. package/dist/_plugin-vue_export-helper-DQXgr64F.cjs +13 -0
  5. package/dist/_plugin-vue_export-helper-DbXABBKy.js +8 -0
  6. package/dist/affix-CYU-9qMr.cjs +71 -0
  7. package/dist/affix-D9EM8_Um.js +66 -0
  8. package/dist/button-CGv1WHzT.cjs +132 -0
  9. package/dist/button-tOWSPPxz.js +126 -0
  10. package/dist/chunk-CZWwpsFl.cjs +43 -0
  11. package/dist/chunk-pbuEa-1d.js +13 -0
  12. package/dist/config.cjs +1 -0
  13. package/dist/config.js +1 -0
  14. package/dist/constants/json.cjs +4 -0
  15. package/dist/constants/json.d.cts +2 -0
  16. package/dist/constants/json.d.ts +2 -0
  17. package/dist/constants/json.js +2 -0
  18. package/dist/constants.cjs +14 -0
  19. package/dist/constants.d.cts +3 -0
  20. package/dist/constants.d.ts +3 -0
  21. package/dist/constants.js +3 -0
  22. package/dist/controls/MyButton.cjs +3 -0
  23. package/dist/controls/MyButton.d.cts +2 -0
  24. package/dist/controls/MyButton.d.ts +2 -0
  25. package/dist/controls/MyButton.js +2 -0
  26. package/dist/controls/affix.cjs +8 -0
  27. package/dist/controls/affix.d.cts +2 -0
  28. package/dist/controls/affix.d.ts +2 -0
  29. package/dist/controls/affix.js +2 -0
  30. package/dist/controls/button.cjs +8 -0
  31. package/dist/controls/button.js +2 -0
  32. package/dist/controls.cjs +18 -0
  33. package/dist/controls.d.cts +10 -0
  34. package/dist/controls.d.ts +10 -0
  35. package/dist/controls.js +5 -0
  36. package/dist/dom-CllENWMY.js +346 -0
  37. package/dist/dom-DS4YqkjW.cjs +580 -0
  38. package/dist/index-1ELDRrC5.d.ts +1397 -0
  39. package/dist/index-5JdIJn1m.d.cts +74 -0
  40. package/dist/index-6KzLtJFy.d.cts +157 -0
  41. package/dist/index-BGkTN1DD.d.cts +15 -0
  42. package/dist/index-BHq-BMCP.d.ts +74 -0
  43. package/dist/index-BI-hrf4t.d.ts +332 -0
  44. package/dist/index-BtOBjeH7.d.ts +10 -0
  45. package/dist/index-C-uY4885.d.cts +23 -0
  46. package/dist/index-C5SJLWEN.d.ts +23 -0
  47. package/dist/index-CSvc8L11.d.cts +51 -0
  48. package/dist/index-CeemHBNT.d.ts +51 -0
  49. package/dist/index-CfkAYIKD.d.cts +80 -0
  50. package/dist/index-CiJC-ieW.d.ts +157 -0
  51. package/dist/index-DamAmum6.d.ts +15 -0
  52. package/dist/index-DhOoJCHW.d.cts +1397 -0
  53. package/dist/index-PhthUD7x.d.cts +10 -0
  54. package/dist/index-oDsyZ3t2.d.cts +332 -0
  55. package/dist/index-x9xs2cbA.d.ts +80 -0
  56. package/dist/json-BkkaM20u.cjs +31034 -0
  57. package/dist/json-D-_zTSK6.js +31023 -0
  58. package/dist/locale-DhlAaV1Q.js +597 -0
  59. package/dist/locale-WzzxOobw.cjs +658 -0
  60. package/dist/locale.cjs +12 -0
  61. package/dist/locale.js +2 -0
  62. package/dist/objects-CLXPNOUW.js +134 -0
  63. package/dist/objects-o7u5s_lI.cjs +272 -0
  64. package/dist/packages/config.cjs +10 -0
  65. package/dist/packages/config.d.cts +2 -0
  66. package/dist/packages/config.d.ts +2 -0
  67. package/dist/packages/config.js +5 -0
  68. package/dist/packages/constants/json.cjs +4 -0
  69. package/dist/packages/constants/json.js +2 -0
  70. package/dist/packages/constants.cjs +78 -0
  71. package/dist/packages/constants.js +67 -0
  72. package/dist/packages/controls/MyButton.cjs +3 -0
  73. package/dist/packages/controls/MyButton.js +2 -0
  74. package/dist/packages/controls/affix.cjs +8 -0
  75. package/dist/packages/controls/affix.js +2 -0
  76. package/dist/packages/controls/button.cjs +8 -0
  77. package/dist/packages/controls/button.d.cts +2 -0
  78. package/dist/packages/controls/button.d.ts +2 -0
  79. package/dist/packages/controls/button.js +2 -0
  80. package/dist/packages/controls.cjs +31 -0
  81. package/dist/packages/controls.js +12 -0
  82. package/dist/packages/locale.cjs +12 -0
  83. package/dist/packages/locale.d.cts +39 -0
  84. package/dist/packages/locale.d.ts +39 -0
  85. package/dist/packages/locale.js +2 -0
  86. package/dist/packages/stores.cjs +337 -0
  87. package/dist/packages/stores.js +320 -0
  88. package/dist/packages/utils/dom.cjs +32 -0
  89. package/dist/packages/utils/dom.d.cts +2 -0
  90. package/dist/packages/utils/dom.d.ts +2 -0
  91. package/dist/packages/utils/dom.js +2 -0
  92. package/dist/packages/utils/vue/props.cjs +63 -0
  93. package/dist/packages/utils/vue/props.d.cts +2 -0
  94. package/dist/packages/utils/vue/props.d.ts +2 -0
  95. package/dist/packages/utils/vue/props.js +56 -0
  96. package/dist/packages/utils/vue.cjs +32 -0
  97. package/dist/packages/utils/vue.d.cts +3 -0
  98. package/dist/packages/utils/vue.d.ts +3 -0
  99. package/dist/packages/utils/vue.js +24 -0
  100. package/dist/packages/utils.cjs +190 -0
  101. package/dist/packages/utils.js +6 -0
  102. package/dist/packages.cjs +15 -0
  103. package/dist/packages.d.cts +3 -0
  104. package/dist/packages.d.ts +3 -0
  105. package/dist/packages.js +3 -0
  106. package/dist/stores.cjs +17 -0
  107. package/dist/stores.d.cts +805 -0
  108. package/dist/stores.d.ts +805 -0
  109. package/dist/stores.js +4 -0
  110. package/dist/style.css +15 -0
  111. package/dist/utils/dom.cjs +32 -0
  112. package/dist/utils/dom.js +2 -0
  113. package/dist/utils/vue/props.cjs +7 -0
  114. package/dist/utils/vue/props.js +2 -0
  115. package/dist/utils/vue.cjs +11 -0
  116. package/dist/utils/vue.js +3 -0
  117. package/dist/utils-DlBKdS0t.js +696 -0
  118. package/dist/utils-egS_3P4w.cjs +850 -0
  119. package/dist/utils.cjs +190 -0
  120. package/dist/utils.d.cts +5 -0
  121. package/dist/utils.d.ts +5 -0
  122. package/dist/utils.js +6 -0
  123. package/package.json +184 -0
@@ -0,0 +1,320 @@
1
+ import { f as rwDecode, h as http, p as rwEncode, u as useAppConfigStore } from "../utils-DlBKdS0t.js";
2
+ import { reactive } from "vue";
3
+ import { useDark, useToggle } from "@vueuse/core";
4
+ import { ElMessage } from "element-plus";
5
+ import { createPinia, defineStore } from "pinia";
6
+ import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
7
+ import elCn from "element-plus/es/locale/lang/zh-cn";
8
+ import elTw from "element-plus/es/locale/lang/zh-tw";
9
+ import elEn from "element-plus/es/locale/lang/en";
10
+ export * from "pinia";
11
+ //#region src/packages/stores/columnsSetting.ts
12
+ const useColumnsSettingStore = defineStore("columnsSetting", () => {
13
+ let columns = reactive({});
14
+ let tableOrderColumns = reactive({});
15
+ let fieldsOrder = reactive({});
16
+ function setFieldsOrder(moduleName, fieldsOrderArr) {
17
+ fieldsOrder[moduleName] = fieldsOrderArr;
18
+ }
19
+ function setOrderColumns(moduleName, orderColumns) {
20
+ tableOrderColumns[moduleName] = orderColumns;
21
+ }
22
+ function clearColumns(moduleName) {
23
+ columns[moduleName] = [];
24
+ }
25
+ function getColumns() {
26
+ return columns;
27
+ }
28
+ function isChecked(moduleName, fieldName) {
29
+ if (columns[moduleName] == void 0) return true;
30
+ if (columns[moduleName].includes(fieldName)) return false;
31
+ else return true;
32
+ }
33
+ function setItem(moduleName, fieldName, checked) {
34
+ if (checked) {
35
+ if (columns[moduleName] == void 0) columns[moduleName] = [];
36
+ if (columns[moduleName].findIndex((model) => model == fieldName) == -1) columns[moduleName].push(fieldName);
37
+ } else {
38
+ if (columns[moduleName] == void 0) return false;
39
+ const findIndex = columns[moduleName].findIndex((model) => model == fieldName);
40
+ columns[moduleName].splice(findIndex, 1);
41
+ }
42
+ return true;
43
+ }
44
+ async function getFromRemote() {
45
+ const conf = { field: "" };
46
+ conf.field = "showcolumns";
47
+ return http.post("?p=index&a=index&apiName=System/getLocalsetting", conf).then((res) => {
48
+ if (res.status == 0) {
49
+ if (res.data) for (const index in res.data) {
50
+ const element = res.data[index];
51
+ columns[index].splice(0, columns[index].length);
52
+ columns[index].push(...element);
53
+ }
54
+ else columns = {};
55
+ ElMessage.success(res.errorMsg);
56
+ return true;
57
+ } else {
58
+ ElMessage.error(res.errorMsg);
59
+ return false;
60
+ }
61
+ });
62
+ }
63
+ function saveToRemote() {
64
+ const conf = {
65
+ conf: { ...columns },
66
+ field: "showcolumns"
67
+ };
68
+ http.post("?p=index&a=index&apiName=System/saveLocalsetting", conf).then((res) => {
69
+ if (res.status == 0) {
70
+ ElMessage.success(res.errorMsg);
71
+ return true;
72
+ } else {
73
+ ElMessage.error(res.errorMsg);
74
+ return false;
75
+ }
76
+ });
77
+ }
78
+ return {
79
+ columns,
80
+ isChecked,
81
+ setItem,
82
+ getFromRemote,
83
+ saveToRemote,
84
+ clearColumns,
85
+ getColumns,
86
+ tableOrderColumns,
87
+ setOrderColumns,
88
+ fieldsOrder,
89
+ setFieldsOrder
90
+ };
91
+ }, { persist: {
92
+ key: "columnsSetting",
93
+ storage: localStorage,
94
+ pick: ["columns", "fieldsOrder"],
95
+ serializer: {
96
+ serialize: (state) => rwEncode(state),
97
+ deserialize: (data) => rwDecode(data)
98
+ }
99
+ } });
100
+ //#endregion
101
+ //#region src/packages/stores/localSetting.ts
102
+ const useLocalSettingStore = defineStore("localSetting", {
103
+ state: () => ({
104
+ system: {
105
+ dark: false,
106
+ locale: "cn",
107
+ langLable: "icon",
108
+ emptyValues: "",
109
+ valueOnClear: "",
110
+ size: "default",
111
+ message: {
112
+ max: 1,
113
+ grouping: false,
114
+ duration: 3e3,
115
+ showClose: true,
116
+ offset: 0,
117
+ plain: false
118
+ },
119
+ button: {
120
+ type: "default",
121
+ autoInsertSpace: false,
122
+ plain: true,
123
+ round: false
124
+ },
125
+ checkBox: "default",
126
+ link: {
127
+ type: "default",
128
+ underline: false
129
+ },
130
+ maxOpenPage: 10
131
+ },
132
+ layout: {
133
+ layout: "tlr",
134
+ fullScreen: false,
135
+ backTop: true
136
+ },
137
+ smallComponents: {
138
+ dark: true,
139
+ lang: false,
140
+ fullScreen: true,
141
+ size: true,
142
+ tabs: true
143
+ },
144
+ page: {
145
+ process: true,
146
+ transition: "el-fade-in",
147
+ waterType: "text",
148
+ dialogType: "center"
149
+ },
150
+ pageTable: {
151
+ showTitle: true,
152
+ margin: 5,
153
+ search: {
154
+ oneLineControl: 4,
155
+ mergeStringControl: true,
156
+ stringControlLocation: "front",
157
+ labelPosition: "left",
158
+ buttonStyle: "button"
159
+ },
160
+ table: {
161
+ deleteConfirmStyle: "bubble",
162
+ showHeader: true,
163
+ showHeadBgColor: false,
164
+ verticalLine: false,
165
+ horizontalLine: true,
166
+ stripe: true,
167
+ highlightCurrentRow: true,
168
+ height: "follow",
169
+ buttonStyle: "text",
170
+ showIndex: true,
171
+ fit: true,
172
+ fixed: "right",
173
+ showMenu: true,
174
+ maxButtons: 3,
175
+ multiLangShowType: "all"
176
+ },
177
+ buttons: {
178
+ groupType: false,
179
+ location: "top",
180
+ buttonStyle: "button"
181
+ },
182
+ pagination: {
183
+ location: "bottom",
184
+ footerFollow: "bottom",
185
+ showBgColor: true
186
+ }
187
+ },
188
+ pageForm: {
189
+ showTitle: true,
190
+ margin: 50,
191
+ form: {
192
+ gutter: 5,
193
+ labelPosition: "right",
194
+ formItemwidth: 200,
195
+ oneLineControl: 2
196
+ },
197
+ buttons: {
198
+ groupType: false,
199
+ location: "center",
200
+ verticalLocation: "bottom",
201
+ buttonStyle: "button"
202
+ },
203
+ autoSaveLocal: true
204
+ },
205
+ pageFormDialog: {
206
+ showTitle: false,
207
+ margin: 20,
208
+ form: {
209
+ gutter: 5,
210
+ formItemwidth: 125,
211
+ labelPosition: "right",
212
+ oneLineControl: 2
213
+ },
214
+ buttons: {
215
+ location: "end",
216
+ verticalLocation: "bottom",
217
+ buttonStyle: "button"
218
+ }
219
+ },
220
+ isCollapse: false
221
+ }),
222
+ getters: {
223
+ getButtonStyle: (state) => (area) => {
224
+ switch (area) {
225
+ case "form": return state.pageForm.buttons.buttonStyle;
226
+ case "table":
227
+ case "operate": return state.pageTable.buttons.buttonStyle;
228
+ case "search": return state.pageTable.search.buttonStyle;
229
+ case "tableLine": return state.pageTable.table.buttonStyle;
230
+ default: return "button";
231
+ }
232
+ },
233
+ getPaginationLocation: (state) => (location) => {
234
+ if (state.pageTable.pagination.location != "bottom" && location == "top" || state.pageTable.pagination.location != "top" && location == "bottom") return true;
235
+ else return false;
236
+ },
237
+ elementPlusLocale: (state) => () => {
238
+ switch (state.system.locale) {
239
+ case "en": return elEn;
240
+ case "tw": return elTw;
241
+ default: return elCn;
242
+ }
243
+ }
244
+ },
245
+ actions: {
246
+ showTitle(pageModel) {
247
+ switch (pageModel) {
248
+ case "form": return this.pageForm.showTitle;
249
+ default: return this.pageTable.showTitle;
250
+ }
251
+ },
252
+ setValue(key, value) {
253
+ const keys = key.split(".");
254
+ let current = this;
255
+ for (let i = 0; i < keys.length - 1; i++) {
256
+ if (!current[keys[i]]) current[keys[i]] = {};
257
+ current = current[keys[i]];
258
+ }
259
+ current[keys[keys.length - 1]] = value;
260
+ },
261
+ isDark() {
262
+ const storeDark = useDark();
263
+ if (storeDark.value != this.system.dark) {
264
+ storeDark.value = this.system.dark;
265
+ useToggle(storeDark);
266
+ }
267
+ return storeDark;
268
+ },
269
+ reset() {
270
+ this.$reset();
271
+ },
272
+ async getFromRemote(url) {
273
+ return await http.post(url, {}).then((res) => {
274
+ if (res.status == 0) {
275
+ this.$patch({ ...res.data });
276
+ ElMessage.success(res.errorMsg);
277
+ return true;
278
+ } else {
279
+ ElMessage.error(res.errorMsg);
280
+ return false;
281
+ }
282
+ });
283
+ },
284
+ saveToRemote(url) {
285
+ const conf = { conf: { ...this.$state } };
286
+ http.post(url, conf).then((res) => {
287
+ if (res.status == 0) {
288
+ ElMessage.success(res.errorMsg);
289
+ return true;
290
+ } else {
291
+ ElMessage.error(res.errorMsg);
292
+ return false;
293
+ }
294
+ });
295
+ },
296
+ toggleCollapse() {
297
+ this.isCollapse = !this.isCollapse;
298
+ }
299
+ },
300
+ persist: {
301
+ key: "localSetting",
302
+ serializer: {
303
+ serialize: (state) => rwEncode(state),
304
+ deserialize: (data) => rwDecode(data)
305
+ },
306
+ storage: localStorage
307
+ }
308
+ });
309
+ //#endregion
310
+ //#region src/packages/stores/error.ts
311
+ const useErrorStore = defineStore("error", { state: () => ({
312
+ err: "",
313
+ instance: null,
314
+ info: ""
315
+ }) });
316
+ //#endregion
317
+ //#region src/packages/stores/index.ts
318
+ const store = createPinia().use(piniaPluginPersistedstate);
319
+ //#endregion
320
+ export { store, useAppConfigStore, useColumnsSettingStore, useErrorStore, useLocalSettingStore };
@@ -0,0 +1,32 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_dom = require("../../dom-DS4YqkjW.cjs");
3
+ exports.addClass = require_dom.addClass;
4
+ exports.addUnit = require_dom.addUnit;
5
+ exports.animateScrollTo = require_dom.animateScrollTo;
6
+ exports.attemptFocus = require_dom.attemptFocus;
7
+ exports.classNameToArray = require_dom.classNameToArray;
8
+ exports.composeEventHandlers = require_dom.composeEventHandlers;
9
+ exports.focusNode = require_dom.focusNode;
10
+ exports.getClientXY = require_dom.getClientXY;
11
+ exports.getElement = require_dom.getElement;
12
+ exports.getOffsetTop = require_dom.getOffsetTop;
13
+ exports.getOffsetTopDistance = require_dom.getOffsetTopDistance;
14
+ exports.getScrollBarWidth = require_dom.getScrollBarWidth;
15
+ exports.getScrollContainer = require_dom.getScrollContainer;
16
+ exports.getScrollElement = require_dom.getScrollElement;
17
+ exports.getScrollTop = require_dom.getScrollTop;
18
+ exports.getSibling = require_dom.getSibling;
19
+ exports.getStyle = require_dom.getStyle;
20
+ exports.hasClass = require_dom.hasClass;
21
+ exports.isFocusable = require_dom.isFocusable;
22
+ exports.isInContainer = require_dom.isInContainer;
23
+ exports.isLeaf = require_dom.isLeaf;
24
+ exports.isScroll = require_dom.isScroll;
25
+ exports.isVisible = require_dom.isVisible;
26
+ exports.obtainAllFocusableElements = require_dom.obtainAllFocusableElements;
27
+ exports.removeClass = require_dom.removeClass;
28
+ exports.removeStyle = require_dom.removeStyle;
29
+ exports.scrollIntoView = require_dom.scrollIntoView;
30
+ exports.setStyle = require_dom.setStyle;
31
+ exports.triggerEvent = require_dom.triggerEvent;
32
+ exports.whenMouse = require_dom.whenMouse;
@@ -0,0 +1,2 @@
1
+ import { A as triggerEvent, C as attemptFocus, D as isLeaf, E as isFocusable, O as isVisible, S as whenMouse, T as getSibling, _ as getClientXY, a as getStyle, b as isInContainer, c as removeStyle, d as getScrollBarWidth, f as getScrollContainer, g as scrollIntoView, h as isScroll, i as classNameToArray, k as obtainAllFocusableElements, l as setStyle, m as getScrollTop, n as addClass, o as hasClass, p as getScrollElement, r as addUnit, s as removeClass, t as getElement, u as animateScrollTo, v as getOffsetTop, w as focusNode, x as composeEventHandlers, y as getOffsetTopDistance } from "../../index-CfkAYIKD.cjs";
2
+ export { addClass, addUnit, animateScrollTo, attemptFocus, classNameToArray, composeEventHandlers, focusNode, getClientXY, getElement, getOffsetTop, getOffsetTopDistance, getScrollBarWidth, getScrollContainer, getScrollElement, getScrollTop, getSibling, getStyle, hasClass, isFocusable, isInContainer, isLeaf, isScroll, isVisible, obtainAllFocusableElements, removeClass, removeStyle, scrollIntoView, setStyle, triggerEvent, whenMouse };
@@ -0,0 +1,2 @@
1
+ import { A as triggerEvent, C as attemptFocus, D as isLeaf, E as isFocusable, O as isVisible, S as whenMouse, T as getSibling, _ as getClientXY, a as getStyle, b as isInContainer, c as removeStyle, d as getScrollBarWidth, f as getScrollContainer, g as scrollIntoView, h as isScroll, i as classNameToArray, k as obtainAllFocusableElements, l as setStyle, m as getScrollTop, n as addClass, o as hasClass, p as getScrollElement, r as addUnit, s as removeClass, t as getElement, u as animateScrollTo, v as getOffsetTop, w as focusNode, x as composeEventHandlers, y as getOffsetTopDistance } from "../../index-x9xs2cbA.js";
2
+ export { addClass, addUnit, animateScrollTo, attemptFocus, classNameToArray, composeEventHandlers, focusNode, getClientXY, getElement, getOffsetTop, getOffsetTopDistance, getScrollBarWidth, getScrollContainer, getScrollElement, getScrollTop, getSibling, getStyle, hasClass, isFocusable, isInContainer, isLeaf, isScroll, isVisible, obtainAllFocusableElements, removeClass, removeStyle, scrollIntoView, setStyle, triggerEvent, whenMouse };
@@ -0,0 +1,2 @@
1
+ import { A as isInContainer, B as isFocusable, D as getClientXY, F as composeEventHandlers, H as isVisible, I as whenMouse, L as attemptFocus, O as getOffsetTop, R as focusNode, U as obtainAllFocusableElements, V as isLeaf, W as triggerEvent, a as getScrollElement, c as scrollIntoView, d as classNameToArray, f as getStyle, g as setStyle, h as removeStyle, i as getScrollContainer, k as getOffsetTopDistance, l as addClass, m as removeClass, n as animateScrollTo, o as getScrollTop, p as hasClass, r as getScrollBarWidth, s as isScroll, t as getElement, u as addUnit, z as getSibling } from "../../dom-CllENWMY.js";
2
+ export { addClass, addUnit, animateScrollTo, attemptFocus, classNameToArray, composeEventHandlers, focusNode, getClientXY, getElement, getOffsetTop, getOffsetTopDistance, getScrollBarWidth, getScrollContainer, getScrollElement, getScrollTop, getSibling, getStyle, hasClass, isFocusable, isInContainer, isLeaf, isScroll, isVisible, obtainAllFocusableElements, removeClass, removeStyle, scrollIntoView, setStyle, triggerEvent, whenMouse };
@@ -0,0 +1,63 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../../../chunk-CZWwpsFl.cjs");
3
+ const require_objects = require("../../../objects-o7u5s_lI.cjs");
4
+ let vue = require("vue");
5
+ let lodash_unified = require("lodash-unified");
6
+ let _vue_shared = require("@vue/shared");
7
+ //#region src/packages/utils/vue/props/runtime.ts
8
+ const epPropKey = "__epPropKey";
9
+ const definePropType = (val) => val;
10
+ const isEpProp = (val) => (0, _vue_shared.isObject)(val) && !!val["__epPropKey"];
11
+ /**
12
+ * @description Build prop. It can better optimize prop types
13
+ * @description 生成 prop,能更好地优化类型
14
+ * @example
15
+ // limited options
16
+ // the type will be PropType<'light' | 'dark'>
17
+ buildProp({
18
+ type: String,
19
+ values: ['light', 'dark'],
20
+ } as const)
21
+ * @example
22
+ // limited options and other types
23
+ // the type will be PropType<'small' | 'large' | number>
24
+ buildProp({
25
+ type: [String, Number],
26
+ values: ['small', 'large'],
27
+ validator: (val: unknown): val is number => typeof val === 'number',
28
+ } as const)
29
+ @link see more: https://github.com/element-plus/element-plus/pull/3341
30
+ */
31
+ const buildProp = (prop, key) => {
32
+ if (!(0, _vue_shared.isObject)(prop) || isEpProp(prop)) return prop;
33
+ const { values, required, default: defaultValue, type, validator } = prop;
34
+ const epProp = {
35
+ type,
36
+ required: !!required,
37
+ validator: values || validator ? (val) => {
38
+ let valid = false;
39
+ let allowedValues = [];
40
+ if (values) {
41
+ allowedValues = Array.from(values);
42
+ if (require_objects.hasOwn(prop, "default")) allowedValues.push(defaultValue);
43
+ valid ||= allowedValues.includes(val);
44
+ }
45
+ if (validator) valid ||= validator(val);
46
+ if (!valid && allowedValues.length > 0) {
47
+ const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", ");
48
+ (0, vue.warn)(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`);
49
+ }
50
+ return valid;
51
+ } : void 0,
52
+ [epPropKey]: true
53
+ };
54
+ if (require_objects.hasOwn(prop, "default")) epProp.default = defaultValue;
55
+ return epProp;
56
+ };
57
+ const buildProps = (props) => (0, lodash_unified.fromPairs)(Object.entries(props).map(([key, option]) => [key, buildProp(option, key)]));
58
+ //#endregion
59
+ exports.buildProp = buildProp;
60
+ exports.buildProps = buildProps;
61
+ exports.definePropType = definePropType;
62
+ exports.epPropKey = epPropKey;
63
+ exports.isEpProp = isEpProp;
@@ -0,0 +1,2 @@
1
+ import { _ as IfNever, a as EpPropInputDefault, b as Writable, c as IfEpProp, d as ResolvePropType, f as buildProp, g as isEpProp, h as epPropKey, i as EpPropInput, l as IfNativePropType, m as definePropType, n as EpPropConvert, o as EpPropMergeType, p as buildProps, r as EpPropFinalized, s as ExtractPropType, t as EpProp, u as NativePropType, v as IfUnknown, x as WritableArray, y as UnknownToNever } from "../../../index-6KzLtJFy.cjs";
2
+ export { EpProp, EpPropConvert, EpPropFinalized, EpPropInput, EpPropInputDefault, EpPropMergeType, ExtractPropType, IfEpProp, IfNativePropType, IfNever, IfUnknown, NativePropType, ResolvePropType, UnknownToNever, Writable, WritableArray, buildProp, buildProps, definePropType, epPropKey, isEpProp };
@@ -0,0 +1,2 @@
1
+ import { _ as IfNever, a as EpPropInputDefault, b as Writable, c as IfEpProp, d as ResolvePropType, f as buildProp, g as isEpProp, h as epPropKey, i as EpPropInput, l as IfNativePropType, m as definePropType, n as EpPropConvert, o as EpPropMergeType, p as buildProps, r as EpPropFinalized, s as ExtractPropType, t as EpProp, u as NativePropType, v as IfUnknown, x as WritableArray, y as UnknownToNever } from "../../../index-CiJC-ieW.js";
2
+ export { EpProp, EpPropConvert, EpPropFinalized, EpPropInput, EpPropInputDefault, EpPropMergeType, ExtractPropType, IfEpProp, IfNativePropType, IfNever, IfUnknown, NativePropType, ResolvePropType, UnknownToNever, Writable, WritableArray, buildProp, buildProps, definePropType, epPropKey, isEpProp };
@@ -0,0 +1,56 @@
1
+ import { o as hasOwn, x as isObject } from "../../../objects-CLXPNOUW.js";
2
+ import { warn } from "vue";
3
+ import { fromPairs } from "lodash-unified";
4
+ //#region src/packages/utils/vue/props/runtime.ts
5
+ const epPropKey = "__epPropKey";
6
+ const definePropType = (val) => val;
7
+ const isEpProp = (val) => isObject(val) && !!val["__epPropKey"];
8
+ /**
9
+ * @description Build prop. It can better optimize prop types
10
+ * @description 生成 prop,能更好地优化类型
11
+ * @example
12
+ // limited options
13
+ // the type will be PropType<'light' | 'dark'>
14
+ buildProp({
15
+ type: String,
16
+ values: ['light', 'dark'],
17
+ } as const)
18
+ * @example
19
+ // limited options and other types
20
+ // the type will be PropType<'small' | 'large' | number>
21
+ buildProp({
22
+ type: [String, Number],
23
+ values: ['small', 'large'],
24
+ validator: (val: unknown): val is number => typeof val === 'number',
25
+ } as const)
26
+ @link see more: https://github.com/element-plus/element-plus/pull/3341
27
+ */
28
+ const buildProp = (prop, key) => {
29
+ if (!isObject(prop) || isEpProp(prop)) return prop;
30
+ const { values, required, default: defaultValue, type, validator } = prop;
31
+ const epProp = {
32
+ type,
33
+ required: !!required,
34
+ validator: values || validator ? (val) => {
35
+ let valid = false;
36
+ let allowedValues = [];
37
+ if (values) {
38
+ allowedValues = Array.from(values);
39
+ if (hasOwn(prop, "default")) allowedValues.push(defaultValue);
40
+ valid ||= allowedValues.includes(val);
41
+ }
42
+ if (validator) valid ||= validator(val);
43
+ if (!valid && allowedValues.length > 0) {
44
+ const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", ");
45
+ warn(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`);
46
+ }
47
+ return valid;
48
+ } : void 0,
49
+ [epPropKey]: true
50
+ };
51
+ if (hasOwn(prop, "default")) epProp.default = defaultValue;
52
+ return epProp;
53
+ };
54
+ const buildProps = (props) => fromPairs(Object.entries(props).map(([key, option]) => [key, buildProp(option, key)]));
55
+ //#endregion
56
+ export { buildProp, buildProps, definePropType, epPropKey, isEpProp };
@@ -0,0 +1,32 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_packages_utils_vue_props = require("./vue/props.cjs");
3
+ //#region src/packages/utils/vue/install.ts
4
+ const withInstall = (main, extra) => {
5
+ main.install = (app) => {
6
+ for (const comp of [main, ...Object.values(extra ?? {})]) app.component(comp.name, comp);
7
+ };
8
+ if (extra) for (const [key, comp] of Object.entries(extra)) main[key] = comp;
9
+ return main;
10
+ };
11
+ const withInstallFunction = (fn, name) => {
12
+ fn.install = (app) => {
13
+ fn._context = app._context;
14
+ app.config.globalProperties[name] = fn;
15
+ };
16
+ return fn;
17
+ };
18
+ const withInstallDirective = (directive, name) => {
19
+ directive.install = (app) => {
20
+ app.directive(name, directive);
21
+ };
22
+ return directive;
23
+ };
24
+ //#endregion
25
+ exports.buildProp = require_packages_utils_vue_props.buildProp;
26
+ exports.buildProps = require_packages_utils_vue_props.buildProps;
27
+ exports.definePropType = require_packages_utils_vue_props.definePropType;
28
+ exports.epPropKey = require_packages_utils_vue_props.epPropKey;
29
+ exports.isEpProp = require_packages_utils_vue_props.isEpProp;
30
+ exports.withInstall = withInstall;
31
+ exports.withInstallDirective = withInstallDirective;
32
+ exports.withInstallFunction = withInstallFunction;
@@ -0,0 +1,3 @@
1
+ import { a as SFCInstallWithContext, i as EmitFn, n as withInstallDirective, o as SFCWithInstall, r as withInstallFunction, t as withInstall } from "../../index-BGkTN1DD.cjs";
2
+ import { _ as IfNever, a as EpPropInputDefault, b as Writable, c as IfEpProp, d as ResolvePropType, f as buildProp, g as isEpProp, h as epPropKey, i as EpPropInput, l as IfNativePropType, m as definePropType, n as EpPropConvert, o as EpPropMergeType, p as buildProps, r as EpPropFinalized, s as ExtractPropType, t as EpProp, u as NativePropType, v as IfUnknown, x as WritableArray, y as UnknownToNever } from "../../index-6KzLtJFy.cjs";
3
+ export { EmitFn, EpProp, EpPropConvert, EpPropFinalized, EpPropInput, EpPropInputDefault, EpPropMergeType, ExtractPropType, IfEpProp, IfNativePropType, IfNever, IfUnknown, NativePropType, ResolvePropType, SFCInstallWithContext, SFCWithInstall, UnknownToNever, Writable, WritableArray, buildProp, buildProps, definePropType, epPropKey, isEpProp, withInstall, withInstallDirective, withInstallFunction };
@@ -0,0 +1,3 @@
1
+ import { a as SFCInstallWithContext, i as EmitFn, n as withInstallDirective, o as SFCWithInstall, r as withInstallFunction, t as withInstall } from "../../index-DamAmum6.js";
2
+ import { _ as IfNever, a as EpPropInputDefault, b as Writable, c as IfEpProp, d as ResolvePropType, f as buildProp, g as isEpProp, h as epPropKey, i as EpPropInput, l as IfNativePropType, m as definePropType, n as EpPropConvert, o as EpPropMergeType, p as buildProps, r as EpPropFinalized, s as ExtractPropType, t as EpProp, u as NativePropType, v as IfUnknown, x as WritableArray, y as UnknownToNever } from "../../index-CiJC-ieW.js";
3
+ export { EmitFn, EpProp, EpPropConvert, EpPropFinalized, EpPropInput, EpPropInputDefault, EpPropMergeType, ExtractPropType, IfEpProp, IfNativePropType, IfNever, IfUnknown, NativePropType, ResolvePropType, SFCInstallWithContext, SFCWithInstall, UnknownToNever, Writable, WritableArray, buildProp, buildProps, definePropType, epPropKey, isEpProp, withInstall, withInstallDirective, withInstallFunction };
@@ -0,0 +1,24 @@
1
+ import { buildProp, buildProps, definePropType, epPropKey, isEpProp } from "./vue/props.js";
2
+ //#region src/packages/utils/vue/install.ts
3
+ const withInstall = (main, extra) => {
4
+ main.install = (app) => {
5
+ for (const comp of [main, ...Object.values(extra ?? {})]) app.component(comp.name, comp);
6
+ };
7
+ if (extra) for (const [key, comp] of Object.entries(extra)) main[key] = comp;
8
+ return main;
9
+ };
10
+ const withInstallFunction = (fn, name) => {
11
+ fn.install = (app) => {
12
+ fn._context = app._context;
13
+ app.config.globalProperties[name] = fn;
14
+ };
15
+ return fn;
16
+ };
17
+ const withInstallDirective = (directive, name) => {
18
+ directive.install = (app) => {
19
+ app.directive(name, directive);
20
+ };
21
+ return directive;
22
+ };
23
+ //#endregion
24
+ export { buildProp, buildProps, definePropType, epPropKey, isEpProp, withInstall, withInstallDirective, withInstallFunction };