@qin-ui/element-plus-pro 1.0.0 → 1.0.2

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.
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, provide, renderSlot } from "vue";
2
- import { g as getObject } from "../core/index-VQxpXgLX.js";
2
+ import { g as getObject } from "../core/index-DVXUNE-L.js";
3
3
  const INJECT_CONFIG = {
4
4
  "pro-table": {
5
5
  injectionKey: Symbol(""),
@@ -268,8 +268,6 @@ const useTable = (params) => {
268
268
  } else if (columnItem.dataIndex) {
269
269
  const dataIndexKey = Array.isArray(columnItem.dataIndex) ? columnItem.dataIndex.join(".") : columnItem.dataIndex;
270
270
  matched = dataIndexKey === key;
271
- } else {
272
- matched = key === i;
273
271
  }
274
272
  if (matched) {
275
273
  updater({
@@ -34,33 +34,33 @@
34
34
  .pro-table_size-control_button[data-v-7af52d04] svg {
35
35
  transform: scale(1.3);
36
36
  }
37
- .pro-table_column-control_button[data-v-e45d2d29] {
37
+ .pro-table_column-control_button[data-v-ce445821] {
38
38
  display: flex;
39
39
  align-items: center;
40
40
  padding-right: 12px;
41
41
  padding-left: 12px;
42
42
  }
43
- .pro-table_column-control_button[data-v-e45d2d29] svg {
43
+ .pro-table_column-control_button[data-v-ce445821] svg {
44
44
  transform: scale(1.2, 1.4);
45
45
  }
46
- .pro-table_header[data-v-c5989f58] {
46
+ .pro-table_header[data-v-890fd0f5] {
47
47
  display: flex;
48
48
  align-items: center;
49
49
  justify-content: flex-end;
50
50
  }
51
- .pro-table_header[data-v-c5989f58]:empty {
51
+ .pro-table_header[data-v-890fd0f5]:empty {
52
52
  display: none;
53
53
  }
54
- .pro-table_header + .pro-table_header_content[data-v-c5989f58] {
54
+ .pro-table_header + .pro-table_header_content[data-v-890fd0f5] {
55
55
  margin-top: 16px;
56
56
  }
57
- .pro-table_header_button-bar[data-v-c5989f58] {
57
+ .pro-table_header_button-bar[data-v-890fd0f5] {
58
58
  flex: 1;
59
59
  }
60
- .pro-table_header_toolbar[data-v-c5989f58] {
60
+ .pro-table_header_toolbar[data-v-890fd0f5] {
61
61
  margin-left: 12px;
62
62
  }
63
- .pro-table_pagination[data-v-c5989f58] {
63
+ .pro-table_pagination[data-v-890fd0f5] {
64
64
  justify-content: flex-end;
65
65
  padding: 16px 0;
66
66
  }
@@ -1,7 +1,7 @@
1
1
  import { inject, computed, provide, toValue, defineComponent, useAttrs, useSlots, watchEffect, createBlock, openBlock, unref, mergeProps, withModifiers, withCtx, createVNode, renderSlot, normalizeProps, guardReactiveProps, resolveComponent, createElementBlock, Fragment, renderList, createSlots, ref, createCommentVNode, resolveDynamicComponent, isVNode, createTextVNode, toDisplayString } from "vue";
2
2
  import { ElFormItem, ElCol, ElTable, ElPagination, useFormDisabled, ElForm, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput, ElRow } from "element-plus";
3
3
  import { INJECT_CONFIG, getInjectConfig, INJECT_COMPONENTS } from "../component-provider/index.js";
4
- import { I as InjectionFormKey, c as camelizeProperties, a as InjectionPathKey, g as getObject, u as useForm$1, b as useFields$1, d as useFormRef$1 } from "../core/index-VQxpXgLX.js";
4
+ import { I as InjectionFormKey, c as camelizeProperties, a as InjectionPathKey, g as getObject, u as useForm$1, b as useFields$1, d as useFormRef$1 } from "../core/index-DVXUNE-L.js";
5
5
  import { i as isPlainObject, t as toPath, o as omit, c as cloneDeep } from "../vendor/utils/lodash-es-p6jau26B.js";
6
6
  const tableProps = () => ElTable.props || {};
7
7
  const paginationProps = () => ElPagination.props || {};
@@ -10,10 +10,16 @@ const formItemProps = () => ElFormItem.props || {};
10
10
  const DisabledContextKey = Symbol("pro-form-disabled-context");
11
11
  const useDisabledContext = () => {
12
12
  const formDisabled = useFormDisabled();
13
- return inject(DisabledContextKey, computed(() => !!formDisabled.value));
13
+ return inject(
14
+ DisabledContextKey,
15
+ computed(() => !!formDisabled.value)
16
+ );
14
17
  };
15
18
  const useDisabledContextProvider = (disabled) => {
16
- provide(DisabledContextKey, computed(() => !!toValue(disabled)));
19
+ provide(
20
+ DisabledContextKey,
21
+ computed(() => !!toValue(disabled))
22
+ );
17
23
  };
18
24
  const _sfc_main$6 = /* @__PURE__ */ defineComponent({
19
25
  ...{ name: "ProForm", inheritAttrs: false },
package/es/form/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { c, a, B, b, F, d, T, e, a as a2, h, f, u, g } from "./index-BvqMIOZ8.js";
2
- import { I, a as a3, e as e2 } from "../core/index-VQxpXgLX.js";
1
+ import { c, a, B, b, F, d, T, e, a as a2, h, f, u, g } from "./index-CWHWUZhj.js";
2
+ import { I, a as a3, e as e2 } from "../core/index-DVXUNE-L.js";
3
3
  export {
4
4
  c as BaseField,
5
5
  a as BaseForm,
package/es/index.d.ts CHANGED
@@ -106,8 +106,8 @@ declare type AdditionalMethods<FormItemInstance> = {
106
106
  };
107
107
 
108
108
  declare type AllowStringKey<T, Prefix extends string = ''> = {
109
- [K in keyof T]: K extends string ? T[K] extends (infer U)[] ? `${Prefix}${K}` | (IsRecord<U> extends true ? AllowStringKey<U, `${Prefix}${K}[index].`> : never) : IsRecord<T[K]> extends true ? `${Prefix}${K}` | AllowStringKey<T[K], `${Prefix}${K}.`> : `${Prefix}${K}` : never;
110
- }[keyof T];
109
+ [K in keyof T as string extends K ? never : number extends K ? never : K extends string ? K : never]: T[K] extends (infer U)[] ? `${Prefix}${K & string}` | (IsRecord<U> extends true ? AllowStringKey<U, `${Prefix}${K & string}[index].`> : never) : IsRecord<T[K]> extends true ? `${Prefix}${K & string}` | AllowStringKey<T[K], `${Prefix}${K & string}.`> : `${Prefix}${K & string}`;
110
+ } extends infer Obj ? Obj[keyof Obj] : never;
111
111
 
112
112
  /**
113
113
  * @type {Object} Base - 基础公共字段类型
@@ -316,16 +316,19 @@ declare type BaseWithoutFields<D extends Data = Data> = BaseCommon<D> & {
316
316
  modelProp?: string;
317
317
  };
318
318
 
319
+ declare type BivariantRender<D extends Data = Data> = {
320
+ bivarianceHack(scope: ColumnScope<D>): any;
321
+ }['bivarianceHack'];
322
+
319
323
  declare type ButtonProps = {
320
324
  onClick: () => void;
321
325
  };
322
326
 
323
- export declare type Column<D extends Data = Data> = Partial<Omit<TableColumnCtx<ExtendWithAny<D>>, 'prop' | 'property' | 'children'>> & {
327
+ export declare type Column<D extends Data = Data> = Partial<Omit<TableColumnCtx<any>, 'prop' | 'property' | 'children' | 'render'>> & {
324
328
  key?: Path<D>;
325
329
  prop?: KeyExpandString<Extract<keyof D, string>> | Paths<D>;
326
330
  hidden?: boolean;
327
- children?: Columns<D>;
328
- render?: (scope: ColumnScope<D>) => any;
331
+ render?: BivariantRender<D>;
329
332
  };
330
333
 
331
334
  declare type ColumnFindBy<D extends Data, C extends BaseColumn<D> = BaseColumn<D>> = (column: Readonly<C>) => boolean;
@@ -908,8 +911,8 @@ declare type WithCommonBase<T = unknown> = T & Omit<FormItemProps, 'label'> & Co
908
911
  * @template D - 数据对象类型
909
912
  */
910
913
  declare type WithComponent<T extends abstract new (...args: any) => any, D extends Data = Data> = WithCommon<{
911
- slots?: ComponentSlots<T>;
912
- } & Omit<ComponentProps<T>, keyof VNodeProps>, D>;
914
+ slots?: Partial<ComponentSlots<T>>;
915
+ } & Partial<Omit<ComponentProps<T>, keyof VNodeProps>>, D>;
913
916
 
914
917
  declare type WithFields<D extends Data = Data> = WithRef<WithCommonBase & BaseWithFields<D>>;
915
918
 
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./element-plus-pro.css";
2
- import { a as _sfc_main } from "./form/index-BvqMIOZ8.js";
3
- import { c, B, b, F, d, T, e, h, f, u, g } from "./form/index-BvqMIOZ8.js";
4
- import { I, a, e as e2 } from "./core/index-VQxpXgLX.js";
2
+ import { a as _sfc_main } from "./form/index-CWHWUZhj.js";
3
+ import { c, B, b, F, d, T, e, h, f, u, g } from "./form/index-CWHWUZhj.js";
4
+ import { I, a, e as e2 } from "./core/index-DVXUNE-L.js";
5
5
  import BaseTable from "./table/index.js";
6
6
  import { useTable } from "./table/index.js";
7
7
  import _sfc_main$1 from "./component-provider/index.js";
package/es/table/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { createElementBlock, openBlock, createElementVNode, defineComponent, ref, computed, watch, watchEffect, createBlock, unref, mergeProps, withKeys, withCtx, createVNode, renderSlot, resolveDynamicComponent, createTextVNode, createCommentVNode, Fragment, toDisplayString, normalizeStyle, useModel, renderList, withModifiers, resolveComponent, mergeModels, inject, useAttrs, useSlots, onMounted, resolveDirective, normalizeClass, withDirectives, createSlots, normalizeProps, guardReactiveProps, nextTick } from "vue";
1
+ import { createElementBlock, openBlock, createElementVNode, defineComponent, ref, computed, watch, watchEffect, createBlock, unref, mergeProps, withKeys, withCtx, createVNode, renderSlot, resolveDynamicComponent, createTextVNode, createCommentVNode, Fragment, toDisplayString, normalizeStyle, useModel, renderList, withModifiers, mergeModels, inject, useAttrs, useSlots, onMounted, resolveDirective, normalizeClass, withDirectives, createSlots, normalizeProps, guardReactiveProps, nextTick } from "vue";
2
2
  import { ElSpace, ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElCheckbox, ElTableColumn, ElTable, ElPagination } from "element-plus";
3
- import { _ as _export_sfc, a as _sfc_main$a, t as tableProps, p as paginationProps, b as _sfc_main$b } from "../form/index-BvqMIOZ8.js";
3
+ import { _ as _export_sfc, a as _sfc_main$a, t as tableProps, p as paginationProps, b as _sfc_main$b } from "../form/index-CWHWUZhj.js";
4
4
  import { INJECT_CONFIG } from "../component-provider/index.js";
5
- import { c as camelizeProperties, g as getObject, f as useTable$1 } from "../core/index-VQxpXgLX.js";
5
+ import { c as camelizeProperties, g as getObject, f as useTable$1 } from "../core/index-DVXUNE-L.js";
6
6
  import { g as get, t as toPath, p as pick } from "../vendor/utils/lodash-es-p6jau26B.js";
7
7
  const _sfc_main$9 = {};
8
8
  const _hoisted_1$5 = {
@@ -337,22 +337,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
337
337
  const open = ref(false);
338
338
  const checkAll = ref(false);
339
339
  const indeterminate = ref(false);
340
- const flattenColumns = (cols) => {
341
- return cols.flatMap((item) => {
342
- var _a;
343
- if ((_a = item.children) == null ? void 0 : _a.length) {
344
- return flattenColumns(item.children);
345
- }
346
- return item;
347
- });
348
- };
349
340
  const getColumnKey = (column, index) => {
350
341
  const key = column.key ?? column.prop;
351
342
  if (key === void 0 || key === null) return `__idx_${index}`;
352
343
  return Array.isArray(key) ? key.join(".") : String(key);
353
344
  };
354
345
  const checkedColumnsOptions = computed(
355
- () => flattenColumns(__props.columns).map((item, index) => ({
346
+ () => __props.columns.map((item, index) => ({
356
347
  label: String(item.label ?? item.prop ?? `列${index + 1}`),
357
348
  value: getColumnKey(item, index),
358
349
  checked: !item.hidden,
@@ -368,12 +359,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
368
359
  set(val) {
369
360
  checkedColumnsOptions.value.forEach((item) => {
370
361
  var _a;
371
- (_a = __props.table) == null ? void 0 : _a.setColumn(
372
- item.value,
373
- {
374
- hidden: !val.includes(item.value)
375
- }
376
- );
362
+ (_a = __props.table) == null ? void 0 : _a.setColumn(item.value, {
363
+ hidden: !val.includes(item.value)
364
+ });
377
365
  });
378
366
  }
379
367
  });
@@ -385,7 +373,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
385
373
  };
386
374
  const toggleColumnsItem = (val) => {
387
375
  if (checkedColumnKeys.value.includes(val)) {
388
- checkedColumnKeys.value = checkedColumnKeys.value.filter((item) => item !== val);
376
+ checkedColumnKeys.value = checkedColumnKeys.value.filter(
377
+ (item) => item !== val
378
+ );
389
379
  } else {
390
380
  checkedColumnKeys.value = [...checkedColumnKeys.value, val];
391
381
  }
@@ -466,7 +456,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
466
456
  };
467
457
  }
468
458
  });
469
- const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-e45d2d29"]]);
459
+ const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-ce445821"]]);
470
460
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
471
461
  ...{ name: "TableColumnRenderer" },
472
462
  __name: "TableColumnRenderer",
@@ -485,19 +475,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
485
475
  return get(row, toPath(path));
486
476
  };
487
477
  const normalizedColumns = computed(() => {
488
- const loop = (source) => {
489
- return source.flatMap((column) => {
490
- if (column.hidden) return [];
491
- const children = column.children || [];
492
- const visibleChildren = children.length > 0 ? loop(children) : [];
493
- if (children.length > 0 && visibleChildren.length === 0) return [];
494
- return [{ ...column, children: visibleChildren }];
495
- });
496
- };
497
- return loop(__props.columns);
478
+ return __props.columns.filter((column) => !column.hidden);
498
479
  });
499
480
  const getColumnProps = (column) => {
500
- const { children, hidden, render, key, ...rest } = column;
481
+ const { hidden, render, key, ...rest } = column;
501
482
  const prop = Array.isArray(column.prop) ? column.prop.join(".") : column.prop ? String(column.prop) : void 0;
502
483
  return {
503
484
  ...rest,
@@ -506,7 +487,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
506
487
  };
507
488
  };
508
489
  return (_ctx, _cache) => {
509
- const _component_TableColumnRenderer = resolveComponent("TableColumnRenderer", true);
510
490
  return openBlock(true), createElementBlock(Fragment, null, renderList(normalizedColumns.value, (column, index) => {
511
491
  return openBlock(), createBlock(unref(ElTableColumn), mergeProps({
512
492
  key: getColumnKey(column, index),
@@ -515,16 +495,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
515
495
  default: withCtx((scope) => {
516
496
  var _a;
517
497
  return [
518
- (column.children || []).length > 0 ? (openBlock(), createBlock(_component_TableColumnRenderer, {
519
- key: 0,
520
- columns: column.children || []
521
- }, null, 8, ["columns"])) : typeof column.render === "function" ? (openBlock(), createBlock(resolveDynamicComponent(
498
+ typeof column.render === "function" ? (openBlock(), createBlock(resolveDynamicComponent(
522
499
  (_a = column.render) == null ? void 0 : _a.call(column, {
523
500
  ...scope,
524
501
  column,
525
502
  cellValue: getCellValue(scope.row, column)
526
503
  })
527
- ), { key: 1 })) : createCommentVNode("", true)
504
+ ), { key: 0 })) : createCommentVNode("", true)
528
505
  ];
529
506
  }),
530
507
  _: 2
@@ -692,25 +669,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
692
669
  });
693
670
  const normalizedRawColumns = computed(() => {
694
671
  const source = __props.columns ?? (tableColumns == null ? void 0 : tableColumns.value) ?? [];
695
- const normalize = (list, prefix = "col") => {
696
- return list.map((item, index) => {
697
- const current = { ...item };
698
- if (current.label === void 0 && current.title !== void 0) {
699
- current.label = current.title;
700
- }
701
- if (current.prop === void 0 && current.dataIndex !== void 0) {
702
- current.prop = Array.isArray(current.dataIndex) ? current.dataIndex.join(".") : current.dataIndex;
703
- }
704
- if (current.key === void 0) {
705
- current.key = current.prop ?? (typeof current.columnKey === "string" ? current.columnKey : void 0) ?? `${prefix}-${index}`;
706
- }
707
- if (Array.isArray(current.children)) {
708
- current.children = normalize(current.children, `${prefix}-${index}`);
709
- }
710
- return current;
711
- });
712
- };
713
- const normalized = normalize(source);
672
+ const normalized = source.map((item, index) => {
673
+ const current = { ...item };
674
+ if (current.label === void 0 && current.title !== void 0) {
675
+ current.label = current.title;
676
+ }
677
+ if (current.prop === void 0 && current.dataIndex !== void 0) {
678
+ current.prop = Array.isArray(current.dataIndex) ? current.dataIndex.join(".") : current.dataIndex;
679
+ }
680
+ if (current.key === void 0) {
681
+ current.key = current.prop ?? (typeof current.columnKey === "string" ? current.columnKey : void 0) ?? `col-${index}`;
682
+ }
683
+ return current;
684
+ });
714
685
  if (__props.addIndexColumn ?? injectProps.addIndexColumn) {
715
686
  return [
716
687
  {
@@ -860,7 +831,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
860
831
  };
861
832
  }
862
833
  });
863
- const BaseTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c5989f58"]]);
834
+ const BaseTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-890fd0f5"]]);
864
835
  const useTable = (params = {}) => {
865
836
  const { data, ...rest } = params;
866
837
  const coreTable = useTable$1({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qin-ui/element-plus-pro",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "基于 element-plus 的二次封装组件",
5
5
  "type": "module",
6
6
  "module": "es/index.js",