@yetuzi/vue3-query-components 1.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.
package/dist/index.js ADDED
@@ -0,0 +1,963 @@
1
+ import { defineComponent, useAttrs, reactive, provide, watchEffect, renderSlot, useTemplateRef, createElementBlock, openBlock, Fragment, renderList, normalizeClass, createBlock, withDirectives, unref, isRef, createSlots, withCtx, mergeProps, mergeModels, useCssVars, useModel, withModifiers, createVNode, resolveDynamicComponent, h, createTextVNode, toDisplayString, watch, computed, withKeys, normalizeProps, guardReactiveProps, inject, ref, useSlots } from "vue";
2
+ import { useRequest } from "vue-hooks-plus";
3
+ import { ElLoading, ElForm, ElFormItem, ElButton, ElTable, ElTableColumn, ElEmpty, ElPagination, ElSelect, ElOption, ElInput, ElDatePicker, ElRadioGroup, ElCheckboxGroup, ElSwitch } from "element-plus";
4
+ import { merge, cloneDeep, kebabCase, camelCase } from "lodash-es";
5
+ import dayjs from "dayjs";
6
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
7
+ ...{
8
+ name: "CommonConfigProvider",
9
+ inheritAttrs: false
10
+ },
11
+ __name: "index",
12
+ setup(__props) {
13
+ const config2 = getCommonProviderConfig();
14
+ const attrs = useAttrs();
15
+ const currentConfig = reactive(merge(cloneDeep(config2), attrs));
16
+ provide(configInjectKey, currentConfig);
17
+ watchEffect(() => {
18
+ Object.assign(currentConfig, merge(cloneDeep(config2), attrs));
19
+ });
20
+ return (_ctx, _cache) => {
21
+ return renderSlot(_ctx.$slots, "default");
22
+ };
23
+ }
24
+ });
25
+ const _hoisted_1$1 = { class: "common-query-table" };
26
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
27
+ ...{
28
+ name: "CommonQueryTable"
29
+ },
30
+ __name: "index",
31
+ props: {
32
+ fetch: {},
33
+ form: { default() {
34
+ return [];
35
+ } },
36
+ columns: {},
37
+ layouts: { default() {
38
+ return ["form", "table", "pagination"];
39
+ } }
40
+ },
41
+ setup(__props) {
42
+ const vLoading = ElLoading.directive;
43
+ const props = __props;
44
+ const CommonFormRef = useTemplateRef("CommonFormRef");
45
+ const childrenSlots = useGetComponentsChildrenSlots(["table", "form", "pagination"]);
46
+ const initFetchParams = Object.fromEntries(props.form.map((item) => [item.prop, item.initialValue]));
47
+ const config2 = getCommonProviderConfig();
48
+ const [page, resetPage] = useResettableReactive({
49
+ pageNo: config2.component.pagination.defaultPageCount,
50
+ pageSize: config2.component.pagination.defaultPageSize
51
+ });
52
+ const { data, loading, run } = useRequest(props.fetch, {
53
+ /** 默认请求参数,包含分页和表单初始值 */
54
+ defaultParams: [
55
+ {
56
+ ...page,
57
+ ...initFetchParams
58
+ }
59
+ ],
60
+ /** 初始数据,避免undefined问题 */
61
+ initialData: {
62
+ list: [],
63
+ total: 0
64
+ },
65
+ /** 错误处理,重置数据 */
66
+ onError() {
67
+ data.value.total = 0;
68
+ data.value.list = [];
69
+ }
70
+ });
71
+ function handleFormSubmit() {
72
+ fetchListData();
73
+ }
74
+ function handleFormReset() {
75
+ if (page.pageNo === config2.component.pagination.defaultPageCount && page.pageSize === config2.component.pagination.defaultPageSize) {
76
+ fetchListData();
77
+ } else {
78
+ resetPage();
79
+ }
80
+ }
81
+ function handlePaginationChange(event) {
82
+ page.pageNo = event.pageNo;
83
+ page.pageSize = event.pageSize;
84
+ fetchListData();
85
+ }
86
+ function fetchListData() {
87
+ var _a, _b;
88
+ const formData = ((_b = (_a = CommonFormRef.value) == null ? void 0 : _a[0]) == null ? void 0 : _b.formData) || {};
89
+ run(
90
+ filterNullAndUndefined({
91
+ ...page,
92
+ ...formData
93
+ })
94
+ );
95
+ }
96
+ return (_ctx, _cache) => {
97
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [
98
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.layouts, (layout) => {
99
+ return openBlock(), createElementBlock("div", {
100
+ class: normalizeClass([`common-query-table-${layout}`]),
101
+ key: layout
102
+ }, [
103
+ renderSlot(_ctx.$slots, layout, {}, () => {
104
+ var _a, _b, _c, _d, _e;
105
+ return [
106
+ layout === "form" ? (openBlock(), createBlock(unref(index$1), {
107
+ key: 0,
108
+ ref_for: true,
109
+ ref_key: "CommonFormRef",
110
+ ref: CommonFormRef,
111
+ inline: "",
112
+ form: __props.form,
113
+ loading: unref(loading),
114
+ "onUpdate:loading": _cache[0] || (_cache[0] = ($event) => isRef(loading) ? loading.value = $event : null),
115
+ onSubmit: handleFormSubmit,
116
+ onReset: handleFormReset
117
+ }, createSlots({ _: 2 }, [
118
+ renderList((_a = unref(childrenSlots)) == null ? void 0 : _a[layout], (name, key) => {
119
+ return {
120
+ name: key,
121
+ fn: withCtx((scoped) => [
122
+ renderSlot(_ctx.$slots, name, mergeProps({ ref_for: true }, scoped), void 0, true)
123
+ ])
124
+ };
125
+ })
126
+ ]), 1032, ["form", "loading"])) : layout === "table" ? withDirectives((openBlock(), createBlock(unref(index), {
127
+ key: 1,
128
+ columns: __props.columns,
129
+ data: (_b = unref(data)) == null ? void 0 : _b.list
130
+ }, createSlots({ _: 2 }, [
131
+ renderList((_c = unref(childrenSlots)) == null ? void 0 : _c[layout], (name, key) => {
132
+ return {
133
+ name: key,
134
+ fn: withCtx((scoped) => [
135
+ renderSlot(_ctx.$slots, name, mergeProps({ ref_for: true }, scoped), void 0, true)
136
+ ])
137
+ };
138
+ })
139
+ ]), 1032, ["columns", "data"])), [
140
+ [unref(vLoading), unref(loading)]
141
+ ]) : layout === "pagination" ? (openBlock(), createBlock(unref(_sfc_main$6), {
142
+ key: 2,
143
+ "page-no": unref(page).pageNo,
144
+ "onUpdate:pageNo": _cache[1] || (_cache[1] = ($event) => unref(page).pageNo = $event),
145
+ "page-size": unref(page).pageSize,
146
+ "onUpdate:pageSize": _cache[2] || (_cache[2] = ($event) => unref(page).pageSize = $event),
147
+ total: Number((_d = unref(data)) == null ? void 0 : _d.total),
148
+ onChange: handlePaginationChange
149
+ }, createSlots({ _: 2 }, [
150
+ renderList((_e = unref(childrenSlots)) == null ? void 0 : _e[layout], (name, key) => {
151
+ return {
152
+ name: key,
153
+ fn: withCtx((scoped) => [
154
+ renderSlot(_ctx.$slots, name, mergeProps({ ref_for: true }, scoped), void 0, true)
155
+ ])
156
+ };
157
+ })
158
+ ]), 1032, ["page-no", "page-size", "total"])) : renderSlot(_ctx.$slots, layout, { key: 3 }, void 0, true)
159
+ ];
160
+ }, true)
161
+ ], 2);
162
+ }), 128))
163
+ ]);
164
+ };
165
+ }
166
+ });
167
+ const _export_sfc = (sfc, props) => {
168
+ const target = sfc.__vccOpts || sfc;
169
+ for (const [key, val] of props) {
170
+ target[key] = val;
171
+ }
172
+ return target;
173
+ };
174
+ const index$2 = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-36a95823"]]);
175
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
176
+ ...{
177
+ name: "CommonForm"
178
+ },
179
+ __name: "index",
180
+ props: /* @__PURE__ */ mergeModels({
181
+ form: { default() {
182
+ return [];
183
+ } },
184
+ model: {},
185
+ rules: {},
186
+ labelPosition: {},
187
+ requireAsteriskPosition: {},
188
+ labelWidth: {},
189
+ labelSuffix: {},
190
+ inline: {},
191
+ inlineMessage: {},
192
+ statusIcon: {},
193
+ showMessage: {},
194
+ validateOnRuleChange: {},
195
+ hideRequiredAsterisk: {},
196
+ scrollToError: {},
197
+ scrollIntoViewOptions: {},
198
+ size: {},
199
+ disabled: {}
200
+ }, {
201
+ "loading": {
202
+ default: false
203
+ },
204
+ "loadingModifiers": {}
205
+ }),
206
+ emits: /* @__PURE__ */ mergeModels(["submit", "reset"], ["update:loading"]),
207
+ setup(__props, { expose: __expose, emit: __emit }) {
208
+ useCssVars((_ctx) => ({
209
+ "v58512696": unref(config2).component.form.formItem.components.width
210
+ }));
211
+ const props = __props;
212
+ const emit = __emit;
213
+ const elFormRef = useTemplateRef("elFormRef");
214
+ const formData = reactive(
215
+ Object.fromEntries(props.form.map((item) => [item.prop, item.initialValue]))
216
+ );
217
+ const config2 = getCommonProviderConfig();
218
+ const loading = useModel(__props, "loading");
219
+ const commonComponents = {
220
+ select: _sfc_main$5,
221
+ input: _sfc_main$4,
222
+ "date-picker": _sfc_main$3,
223
+ radio: _sfc_main$2,
224
+ "check-box": _sfc_main$1,
225
+ switch: _sfc_main
226
+ };
227
+ async function handleSubmit() {
228
+ var _a;
229
+ await ((_a = elFormRef.value) == null ? void 0 : _a.validate());
230
+ emit("submit", formData);
231
+ }
232
+ function handleReset() {
233
+ var _a;
234
+ (_a = elFormRef.value) == null ? void 0 : _a.resetFields();
235
+ emit("reset", formData);
236
+ }
237
+ __expose({
238
+ formData
239
+ });
240
+ return (_ctx, _cache) => {
241
+ return openBlock(), createBlock(unref(ElForm), mergeProps({
242
+ ref_key: "elFormRef",
243
+ ref: elFormRef
244
+ }, props, {
245
+ model: formData,
246
+ onSubmit: _cache[0] || (_cache[0] = withModifiers(() => {
247
+ }, ["prevent"]))
248
+ }), {
249
+ default: withCtx(() => [
250
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.form, (item) => {
251
+ return openBlock(), createBlock(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItem, {
252
+ prop: String(item.prop),
253
+ key: item.prop
254
+ }), {
255
+ default: withCtx(() => [
256
+ typeof item.is === "string" ? (openBlock(), createBlock(resolveDynamicComponent(
257
+ h(commonComponents[item.is], {
258
+ ...item.props || {},
259
+ modelValue: formData[item.prop],
260
+ "onUpdate:modelValue": (val) => formData[item.prop] = val
261
+ })
262
+ ), { key: 0 })) : (openBlock(), createBlock(resolveDynamicComponent(
263
+ h(item.is, {
264
+ ...item.props || {},
265
+ modelValue: formData[item.prop],
266
+ "onUpdate:modelValue": (val) => formData[item.prop] = val
267
+ })
268
+ ), { key: 1 }))
269
+ ]),
270
+ _: 2
271
+ }, 1040, ["prop"]);
272
+ }), 128)),
273
+ createVNode(unref(ElFormItem), { label: "" }, {
274
+ default: withCtx(() => [
275
+ createVNode(unref(ElButton), {
276
+ type: "primary",
277
+ loading: loading.value,
278
+ onClick: handleSubmit
279
+ }, {
280
+ default: withCtx(() => [
281
+ createTextVNode(toDisplayString(unref(config2).component.form.submitText), 1)
282
+ ]),
283
+ _: 1
284
+ }, 8, ["loading"]),
285
+ createVNode(unref(ElButton), {
286
+ loading: loading.value,
287
+ onClick: handleReset
288
+ }, {
289
+ default: withCtx(() => [
290
+ createTextVNode(toDisplayString(unref(config2).component.form.resetText), 1)
291
+ ]),
292
+ _: 1
293
+ }, 8, ["loading"])
294
+ ]),
295
+ _: 1
296
+ })
297
+ ]),
298
+ _: 1
299
+ }, 16, ["model"]);
300
+ };
301
+ }
302
+ });
303
+ const index$1 = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-6b862115"]]);
304
+ const columnSupplementType = {
305
+ index: {},
306
+ selection: {},
307
+ expand: {},
308
+ date: {
309
+ width: "140px",
310
+ formatter(row, column, cellValue) {
311
+ return dayjs(cellValue).format("YYYY-MM-DD");
312
+ }
313
+ },
314
+ dateTime: {
315
+ width: "180px",
316
+ formatter(row, column, cellValue) {
317
+ return dayjs(cellValue).format("YYYY-MM-DD HH:mm:ss");
318
+ }
319
+ }
320
+ };
321
+ const _hoisted_1 = { class: "common-table" };
322
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
323
+ ...{
324
+ name: "ConnomTable"
325
+ },
326
+ __name: "index",
327
+ props: {
328
+ columns: {},
329
+ data: { default() {
330
+ return [];
331
+ } },
332
+ size: {},
333
+ width: {},
334
+ height: {},
335
+ maxHeight: {},
336
+ fit: {},
337
+ stripe: {},
338
+ border: {},
339
+ rowKey: {},
340
+ context: {},
341
+ showHeader: {},
342
+ showSummary: {},
343
+ sumText: {},
344
+ summaryMethod: {},
345
+ rowClassName: {},
346
+ rowStyle: {},
347
+ cellClassName: {},
348
+ cellStyle: {},
349
+ headerRowClassName: {},
350
+ headerRowStyle: {},
351
+ headerCellClassName: {},
352
+ highlightCurrentRow: {},
353
+ currentRowKey: {},
354
+ emptyText: {},
355
+ expandRowKeys: {},
356
+ defaultExpandAll: {},
357
+ defaultSort: {},
358
+ tooltipEffect: {},
359
+ tooltipOptions: {},
360
+ spanMethod: {},
361
+ selectOnIndeterminate: {},
362
+ indent: {},
363
+ treeProps: {},
364
+ lazy: {},
365
+ load: {},
366
+ className: {},
367
+ style: {},
368
+ tableLayout: {},
369
+ scrollbarAlwaysOn: {},
370
+ flexible: {},
371
+ showOverflowTooltip: {},
372
+ tooltipFormatter: {},
373
+ appendFilterPanelTo: {},
374
+ scrollbarTabindex: {},
375
+ nativeScrollbar: {}
376
+ },
377
+ setup(__props) {
378
+ const config2 = getCommonProviderConfig();
379
+ const props = __props;
380
+ const ElTableRef = useTemplateRef("ElTableRef");
381
+ watch(props.data, () => {
382
+ var _a;
383
+ (_a = ElTableRef.value) == null ? void 0 : _a.scrollTo({
384
+ top: 0,
385
+ left: 0,
386
+ behavior: "smooth"
387
+ });
388
+ });
389
+ const arrayColumns = computed(() => {
390
+ let columns = cloneDeep(props.columns);
391
+ if (!Array.isArray(columns)) {
392
+ columns = Object.entries(columns).map(([key, value]) => {
393
+ return {
394
+ ...value,
395
+ prop: key
396
+ };
397
+ });
398
+ }
399
+ return columns.map((item) => {
400
+ if ("type" in item) {
401
+ return Object.assign(columnSupplementType[item.type], {
402
+ ...item,
403
+ prop: item.prop
404
+ });
405
+ }
406
+ return {
407
+ ...item,
408
+ prop: item.prop
409
+ };
410
+ });
411
+ });
412
+ return (_ctx, _cache) => {
413
+ return openBlock(), createElementBlock("div", _hoisted_1, [
414
+ createVNode(unref(ElTable), mergeProps(props, {
415
+ headerCellStyle: unref(config2).component.table.headerCellStyle,
416
+ height: "100%",
417
+ ref_key: "ElTableRef",
418
+ ref: ElTableRef
419
+ }), {
420
+ empty: withCtx(() => [
421
+ renderSlot(_ctx.$slots, "empty", {}, () => [
422
+ createVNode(unref(ElEmpty), { description: "暂无数据" })
423
+ ], true)
424
+ ]),
425
+ default: withCtx(() => [
426
+ (openBlock(true), createElementBlock(Fragment, null, renderList(arrayColumns.value, (column) => {
427
+ return openBlock(), createBlock(unref(ElTableColumn), mergeProps({
428
+ key: column.prop,
429
+ ref_for: true
430
+ }, column), createSlots({ _: 2 }, [
431
+ !column.formatter ? {
432
+ name: "default",
433
+ fn: withCtx((scoped) => [
434
+ renderSlot(_ctx.$slots, column.prop, {
435
+ row: scoped.row,
436
+ column: scoped.column,
437
+ index: scoped.$index,
438
+ value: scoped.row[column.prop]
439
+ }, () => [
440
+ createTextVNode(toDisplayString(unref(getFirstValidValue)(scoped.row[column.prop], unref(config2).component.placeholder)), 1)
441
+ ], true)
442
+ ]),
443
+ key: "0"
444
+ } : void 0
445
+ ]), 1040);
446
+ }), 128))
447
+ ]),
448
+ _: 3
449
+ }, 16, ["headerCellStyle"])
450
+ ]);
451
+ };
452
+ }
453
+ });
454
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-5da80890"]]);
455
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
456
+ ...{
457
+ name: "CommonPagination"
458
+ },
459
+ __name: "index",
460
+ props: /* @__PURE__ */ mergeModels({
461
+ pageSize: {},
462
+ defaultPageSize: {},
463
+ total: { default: 0 },
464
+ pageCount: {},
465
+ pagerCount: {},
466
+ currentPage: {},
467
+ defaultCurrentPage: {},
468
+ layout: { default: "slot, ->, total, sizes, prev, pager, next, jumper" },
469
+ pageSizes: { default: () => [10, 20, 30, 40, 50] },
470
+ popperClass: {},
471
+ popperStyle: {},
472
+ prevText: {},
473
+ prevIcon: {},
474
+ nextText: {},
475
+ nextIcon: {},
476
+ teleported: { type: Boolean, default: true },
477
+ small: { type: Boolean },
478
+ size: {},
479
+ background: { type: Boolean, default: true },
480
+ disabled: { type: Boolean },
481
+ hideOnSinglePage: { type: Boolean },
482
+ appendSizeTo: {}
483
+ }, {
484
+ "pageNo": {
485
+ /** 数值类型 */
486
+ type: Number,
487
+ /** 必填项 */
488
+ required: true
489
+ },
490
+ "pageNoModifiers": {},
491
+ "pageSize": {
492
+ /** 数值类型 */
493
+ type: Number,
494
+ /** 必填项 */
495
+ required: true
496
+ },
497
+ "pageSizeModifiers": {}
498
+ }),
499
+ emits: /* @__PURE__ */ mergeModels(["change"], ["update:pageNo", "update:pageSize"]),
500
+ setup(__props, { emit: __emit }) {
501
+ const props = __props;
502
+ const emit = __emit;
503
+ const pageNo = useModel(__props, "pageNo");
504
+ const pageSize = useModel(__props, "pageSize");
505
+ watch(
506
+ () => pageSize.value,
507
+ () => {
508
+ pageNo.value = 1;
509
+ }
510
+ );
511
+ watch(
512
+ () => pageNo.value,
513
+ () => {
514
+ emit("change", {
515
+ pageNo: pageNo.value,
516
+ pageSize: pageSize.value
517
+ });
518
+ }
519
+ );
520
+ return (_ctx, _cache) => {
521
+ return openBlock(), createBlock(unref(ElPagination), mergeProps(props, {
522
+ "page-size": pageSize.value,
523
+ "onUpdate:pageSize": _cache[0] || (_cache[0] = ($event) => pageSize.value = $event),
524
+ "current-page": pageNo.value,
525
+ "onUpdate:currentPage": _cache[1] || (_cache[1] = ($event) => pageNo.value = $event)
526
+ }), {
527
+ default: withCtx(() => [
528
+ renderSlot(_ctx.$slots, "default")
529
+ ]),
530
+ _: 3
531
+ }, 16, ["page-size", "current-page"]);
532
+ };
533
+ }
534
+ });
535
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
536
+ ...{
537
+ name: "CommonSelect"
538
+ },
539
+ __name: "index",
540
+ props: /* @__PURE__ */ mergeModels({
541
+ ariaLabel: {},
542
+ emptyValues: {},
543
+ valueOnClear: {},
544
+ name: {},
545
+ id: {},
546
+ modelValue: {},
547
+ autocomplete: {},
548
+ automaticDropdown: { type: Boolean },
549
+ size: {},
550
+ effect: {},
551
+ disabled: { type: Boolean },
552
+ clearable: { type: Boolean, default: true },
553
+ filterable: { type: Boolean },
554
+ allowCreate: { type: Boolean },
555
+ loading: { type: Boolean },
556
+ popperClass: {},
557
+ popperStyle: {},
558
+ popperOptions: {},
559
+ remote: { type: Boolean },
560
+ debounce: {},
561
+ loadingText: {},
562
+ noMatchText: {},
563
+ noDataText: {},
564
+ remoteMethod: {},
565
+ filterMethod: {},
566
+ multiple: { type: Boolean },
567
+ multipleLimit: {},
568
+ placeholder: {},
569
+ defaultFirstOption: { type: Boolean },
570
+ reserveKeyword: { type: Boolean },
571
+ valueKey: {},
572
+ collapseTags: { type: Boolean },
573
+ collapseTagsTooltip: { type: Boolean },
574
+ maxCollapseTags: {},
575
+ teleported: { type: Boolean },
576
+ persistent: { type: Boolean },
577
+ clearIcon: {},
578
+ fitInputWidth: { type: Boolean },
579
+ suffixIcon: {},
580
+ tagType: {},
581
+ tagEffect: {},
582
+ validateEvent: { type: Boolean, default: true },
583
+ remoteShowSuffix: { type: Boolean },
584
+ showArrow: { type: Boolean },
585
+ offset: {},
586
+ placement: {},
587
+ fallbackPlacements: {},
588
+ tabindex: {},
589
+ appendTo: {},
590
+ options: { default() {
591
+ return [];
592
+ } },
593
+ props: {}
594
+ }, {
595
+ "modelValue": {},
596
+ "modelModifiers": {}
597
+ }),
598
+ emits: ["update:modelValue"],
599
+ setup(__props) {
600
+ const props = __props;
601
+ const model = useModel(__props, "modelValue");
602
+ return (_ctx, _cache) => {
603
+ return openBlock(), createBlock(unref(ElSelect), mergeProps(props, {
604
+ modelValue: model.value,
605
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event)
606
+ }), {
607
+ default: withCtx(() => [
608
+ renderSlot(_ctx.$slots, "default", {}, () => [
609
+ (openBlock(true), createElementBlock(Fragment, null, renderList(props.options, (item) => {
610
+ return openBlock(), createBlock(unref(ElOption), {
611
+ key: item.label,
612
+ value: item.value,
613
+ label: item.label,
614
+ disabled: item.disabled
615
+ }, null, 8, ["value", "label", "disabled"]);
616
+ }), 128))
617
+ ])
618
+ ]),
619
+ _: 3
620
+ }, 16, ["modelValue"]);
621
+ };
622
+ }
623
+ });
624
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
625
+ ...{
626
+ name: "CommonInput"
627
+ },
628
+ __name: "index",
629
+ props: {
630
+ "modelValue": {
631
+ /** 默认空字符串 */
632
+ default: ""
633
+ },
634
+ "modelModifiers": {}
635
+ },
636
+ emits: /* @__PURE__ */ mergeModels(["enter"], ["update:modelValue"]),
637
+ setup(__props, { emit: __emit }) {
638
+ const props = __props;
639
+ const emit = __emit;
640
+ const modelValue = useModel(__props, "modelValue");
641
+ function handleEnter(e) {
642
+ if ("isComposing" in e) {
643
+ if (e.isComposing) return;
644
+ } else {
645
+ return;
646
+ }
647
+ emit("enter", e);
648
+ }
649
+ return (_ctx, _cache) => {
650
+ return openBlock(), createBlock(unref(ElInput), mergeProps(props, {
651
+ modelValue: modelValue.value,
652
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event),
653
+ onKeydown: withKeys(handleEnter, ["enter"])
654
+ }), createSlots({ _: 2 }, [
655
+ renderList(_ctx.$slots, (_, name) => {
656
+ return {
657
+ name,
658
+ fn: withCtx((scoped) => [
659
+ renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(scoped)))
660
+ ])
661
+ };
662
+ })
663
+ ]), 1040, ["modelValue"]);
664
+ };
665
+ }
666
+ });
667
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
668
+ ...{
669
+ name: "CommonDatePicker"
670
+ },
671
+ __name: "index",
672
+ props: /* @__PURE__ */ mergeModels({
673
+ type: {},
674
+ showNow: { type: Boolean },
675
+ showConfirm: { type: Boolean },
676
+ showFooter: { type: Boolean, default: true },
677
+ showWeekNumber: { type: Boolean },
678
+ ariaLabel: {},
679
+ emptyValues: {},
680
+ valueOnClear: {},
681
+ disabledDate: {},
682
+ cellClassName: {},
683
+ shortcuts: {},
684
+ arrowControl: { type: Boolean },
685
+ tabindex: {},
686
+ validateEvent: { type: Boolean, default: true },
687
+ unlinkPanels: { type: Boolean },
688
+ placement: {},
689
+ fallbackPlacements: {},
690
+ disabledHours: {},
691
+ disabledMinutes: {},
692
+ disabledSeconds: {},
693
+ automaticDropdown: { type: Boolean },
694
+ id: {},
695
+ name: {},
696
+ popperClass: {},
697
+ popperStyle: {},
698
+ format: {},
699
+ valueFormat: { default: "YYYY-MM-DD" },
700
+ dateFormat: {},
701
+ timeFormat: {},
702
+ clearable: { type: Boolean, default: true },
703
+ clearIcon: {},
704
+ editable: { type: Boolean },
705
+ prefixIcon: {},
706
+ size: {},
707
+ readonly: { type: Boolean },
708
+ disabled: { type: Boolean },
709
+ placeholder: { default: "请选择日期" },
710
+ popperOptions: {},
711
+ modelValue: {},
712
+ rangeSeparator: {},
713
+ startPlaceholder: { default: "开始日期" },
714
+ endPlaceholder: { default: "结束日期" },
715
+ defaultValue: {},
716
+ defaultTime: {},
717
+ isRange: { type: Boolean }
718
+ }, {
719
+ "modelValue": {},
720
+ "modelModifiers": {}
721
+ }),
722
+ emits: ["update:modelValue"],
723
+ setup(__props) {
724
+ const props = __props;
725
+ const modelValue = useModel(__props, "modelValue");
726
+ return (_ctx, _cache) => {
727
+ return openBlock(), createBlock(unref(ElDatePicker), mergeProps(props, {
728
+ modelValue: modelValue.value,
729
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event)
730
+ }), null, 16, ["modelValue"]);
731
+ };
732
+ }
733
+ });
734
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
735
+ ...{
736
+ name: "CommonRadio"
737
+ },
738
+ __name: "index",
739
+ props: /* @__PURE__ */ mergeModels({
740
+ ariaLabel: {},
741
+ id: {},
742
+ size: {},
743
+ disabled: {},
744
+ modelValue: {},
745
+ fill: {},
746
+ textColor: {},
747
+ name: {},
748
+ validateEvent: {},
749
+ options: {},
750
+ props: {},
751
+ type: {}
752
+ }, {
753
+ "modelValue": {},
754
+ "modelModifiers": {}
755
+ }),
756
+ emits: ["update:modelValue"],
757
+ setup(__props) {
758
+ const props = __props;
759
+ const modelValue = useModel(__props, "modelValue");
760
+ return (_ctx, _cache) => {
761
+ return openBlock(), createBlock(unref(ElRadioGroup), mergeProps(props, {
762
+ modelValue: modelValue.value,
763
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event)
764
+ }), null, 16, ["modelValue"]);
765
+ };
766
+ }
767
+ });
768
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
769
+ ...{
770
+ name: "CommonCheckbox"
771
+ },
772
+ __name: "index",
773
+ props: /* @__PURE__ */ mergeModels({
774
+ ariaLabel: {},
775
+ modelValue: {},
776
+ disabled: {},
777
+ min: {},
778
+ max: {},
779
+ size: {},
780
+ fill: {},
781
+ textColor: {},
782
+ tag: {},
783
+ validateEvent: {},
784
+ options: {},
785
+ props: {},
786
+ type: {}
787
+ }, {
788
+ "modelValue": {},
789
+ "modelModifiers": {}
790
+ }),
791
+ emits: ["update:modelValue"],
792
+ setup(__props) {
793
+ const props = __props;
794
+ const modelValue = useModel(__props, "modelValue");
795
+ return (_ctx, _cache) => {
796
+ return openBlock(), createBlock(unref(ElCheckboxGroup), mergeProps(props, {
797
+ modelValue: modelValue.value,
798
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event)
799
+ }), null, 16, ["modelValue"]);
800
+ };
801
+ }
802
+ });
803
+ const _sfc_main = /* @__PURE__ */ defineComponent({
804
+ ...{
805
+ name: "CommonCheckbox"
806
+ },
807
+ __name: "index",
808
+ props: /* @__PURE__ */ mergeModels({
809
+ activeColor: {},
810
+ inactiveColor: {},
811
+ borderColor: {},
812
+ ariaLabel: {},
813
+ modelValue: {},
814
+ disabled: {},
815
+ loading: {},
816
+ size: {},
817
+ width: {},
818
+ inlinePrompt: {},
819
+ inactiveActionIcon: {},
820
+ activeActionIcon: {},
821
+ activeIcon: {},
822
+ inactiveIcon: {},
823
+ activeText: {},
824
+ inactiveText: {},
825
+ activeValue: {},
826
+ inactiveValue: {},
827
+ name: {},
828
+ validateEvent: {},
829
+ beforeChange: {},
830
+ id: {},
831
+ tabindex: {}
832
+ }, {
833
+ "modelValue": {},
834
+ "modelModifiers": {}
835
+ }),
836
+ emits: ["update:modelValue"],
837
+ setup(__props) {
838
+ const props = __props;
839
+ const modelValue = useModel(__props, "modelValue");
840
+ const style = computed(() => {
841
+ const css = {};
842
+ if (props.activeColor) {
843
+ css["--el-switch-on-color"] = props.activeColor;
844
+ }
845
+ if (props.inactiveColor) {
846
+ css["--el-switch-off-color"] = props.inactiveColor;
847
+ }
848
+ if (props.borderColor) {
849
+ css["--el-switch-border-color"] = props.borderColor;
850
+ }
851
+ return css;
852
+ });
853
+ return (_ctx, _cache) => {
854
+ return openBlock(), createBlock(unref(ElSwitch), mergeProps({ class: "common-switch" }, props, {
855
+ modelValue: modelValue.value,
856
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event),
857
+ style: style.value
858
+ }), null, 16, ["modelValue", "style"]);
859
+ };
860
+ }
861
+ });
862
+ function getFirstValidValue(...args) {
863
+ return args.find((arg) => arg !== null && arg !== void 0 && arg !== "");
864
+ }
865
+ function filterNullAndUndefined(obj) {
866
+ return Object.fromEntries(
867
+ Object.entries(obj).filter(
868
+ ([_, value]) => value !== null && value !== void 0 && value !== ""
869
+ )
870
+ );
871
+ }
872
+ const configInjectKey = Symbol();
873
+ function getCommonProviderConfig() {
874
+ return inject(configInjectKey, config);
875
+ }
876
+ function useResettableRef(value, clone = cloneDeep) {
877
+ const initialValue = clone(value);
878
+ const state = ref(value);
879
+ const reset = () => {
880
+ state.value = clone(initialValue);
881
+ };
882
+ return [state, reset];
883
+ }
884
+ function useResettableReactive(value, clone = cloneDeep) {
885
+ const state = reactive(clone(value));
886
+ const reset = () => {
887
+ Object.keys(state).forEach((key) => {
888
+ Reflect.deleteProperty(state, key);
889
+ });
890
+ Object.assign(state, clone(value));
891
+ };
892
+ return [state, reset];
893
+ }
894
+ function useGetComponentsChildrenSlots(keys) {
895
+ const slots = useSlots();
896
+ return computed(() => {
897
+ const o = Object.fromEntries(keys.map((item) => [item, {}]));
898
+ for (const key in slots) {
899
+ if (!Object.prototype.hasOwnProperty.call(slots, key) && !keys.some((i) => i.startsWith(key)))
900
+ continue;
901
+ const k = kebabCase(key);
902
+ const value = slots[key];
903
+ const index2 = k.indexOf("-");
904
+ if (index2 === -1 && !value) return;
905
+ const name = k.slice(0, index2);
906
+ const slotKey = k.slice(index2 + 1);
907
+ merge(o, {
908
+ [name]: {
909
+ [camelCase(slotKey)]: key
910
+ }
911
+ });
912
+ }
913
+ return o;
914
+ });
915
+ }
916
+ const config = reactive({
917
+ component: {
918
+ placeholder: "-",
919
+ pagination: {
920
+ defaultPageCount: 1,
921
+ defaultPageSize: 10
922
+ },
923
+ table: {
924
+ headerCellStyle: {
925
+ color: "#000000",
926
+ fontWeight: "normal",
927
+ height: "48px",
928
+ backgroundColor: "#f1f6ff"
929
+ }
930
+ },
931
+ form: {
932
+ submitText: "搜索",
933
+ resetText: "重置",
934
+ formItem: {
935
+ components: {
936
+ width: "200px"
937
+ }
938
+ }
939
+ }
940
+ }
941
+ });
942
+ export {
943
+ _sfc_main$1 as CommonCheckbox,
944
+ _sfc_main$a as CommonConfigProvider,
945
+ _sfc_main$3 as CommonDatePicker,
946
+ index$1 as CommonForm,
947
+ _sfc_main$4 as CommonInput,
948
+ _sfc_main$6 as CommonPagination,
949
+ index$2 as CommonQueryTable,
950
+ _sfc_main$2 as CommonRadio,
951
+ _sfc_main$5 as CommonSelect,
952
+ _sfc_main as CommonSwitch,
953
+ index as CommonTable,
954
+ config,
955
+ configInjectKey,
956
+ filterNullAndUndefined,
957
+ getCommonProviderConfig,
958
+ getFirstValidValue,
959
+ useGetComponentsChildrenSlots,
960
+ useResettableReactive,
961
+ useResettableRef
962
+ };
963
+ //# sourceMappingURL=index.js.map