eco-vue-js 0.8.22 → 0.8.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,8 +28,8 @@ declare const __VLS_component: import('vue').DefineComponent<{
28
28
  }> & Readonly<{
29
29
  "onUpdate:search"?: ((value: string | undefined) => any) | undefined;
30
30
  }>, {
31
- search: string;
32
31
  title: string;
32
+ search: string;
33
33
  headerPadding: number;
34
34
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
35
35
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
@@ -1 +1 @@
1
- {"version":3,"file":"WHeaderBar.vue.d.ts","sourceRoot":"","sources":["../../../src/components/HeaderBar/WHeaderBar.vue"],"names":[],"mappings":"AAsOA,iBAAS,cAAc;;uBA6OI,GAAG;wBACD,GAAG;wBACH,GAAG;;;;;;;;WAUlB,OAAO,IAA6B;EAEjD;AAsBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;YAxVT,MAAM;aACL,MAAM;oBACC,OAAO;oBACP,MAAM;;;;YAHd,MAAM;aACL,MAAM;oBACC,OAAO;oBACP,MAAM;;;;YAFb,MAAM;WADP,MAAM;mBAGE,MAAM;6EA+VxB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAgBpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"WHeaderBar.vue.d.ts","sourceRoot":"","sources":["../../../src/components/HeaderBar/WHeaderBar.vue"],"names":[],"mappings":"AAsOA,iBAAS,cAAc;;uBA6OI,GAAG;wBACD,GAAG;wBACH,GAAG;;;;;;;;WAUlB,OAAO,IAA6B;EAEjD;AAsBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;YAxVT,MAAM;aACL,MAAM;oBACC,OAAO;oBACP,MAAM;;;;YAHd,MAAM;aACL,MAAM;oBACC,OAAO;oBACP,MAAM;;;;WAHd,MAAM;YACL,MAAM;mBAEC,MAAM;6EA+VxB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAgBpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -1,10 +1,10 @@
1
- import { BulkComponent, FieldComponent, ListField, MenuComponent } from './types';
2
- declare const _default: <Data extends DefaultData, QueryParams>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1
+ import { BulkComponent, FieldComponent, FieldConfigMap, ListField, MenuComponent } from './types';
2
+ declare const _default: <Data extends DefaultData, QueryParams, Fields extends ListField<Data, QueryParams>[]>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
4
  readonly "onUpdate:header-padding"?: ((value: number) => any) | undefined;
5
5
  } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:header-padding"> & {
6
6
  count?: number;
7
- fields: ListField<Data, QueryParams>[];
7
+ fields: Fields;
8
8
  expansion?: FieldComponent<Data>;
9
9
  useQueryFn: UseQueryPaginated<Data, QueryParams>;
10
10
  queryParams: QueryParams;
@@ -18,6 +18,8 @@ declare const _default: <Data extends DefaultData, QueryParams>(__VLS_props: Non
18
18
  selectAllTextGetter: (isUnselect: boolean, count: number) => string;
19
19
  hasBorder?: boolean;
20
20
  moreBottom?: boolean;
21
+ configKey: string;
22
+ defaultConfigMap: FieldConfigMap<Fields>;
21
23
  }> & import('vue').PublicProps;
22
24
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
23
25
  attrs: any;
@@ -1 +1 @@
1
- {"version":3,"file":"WList.vue.d.ts","sourceRoot":"","sources":["../../../src/components/List/WList.vue"],"names":[],"mappings":"AA8RA,OAAO,KAAK,EAAC,aAAa,EAAE,cAAc,EAAe,SAAS,EAAE,aAAa,EAAC,MAAM,SAAS,CAAA;yBAQhF,IAAI,SAAS,WAAW,EAAE,WAAW,eACxC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WAgkBxD,mBAAmB,CAAC;;;gBAxjBpB,MAAM;gBACN,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE;oBAC1B,cAAc,CAAC,IAAI,CAAC;oBACpB,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC;qBACnC,WAAW;6BACH,MAAM;wBACX,MAAM;eACf,aAAa,CAAC,WAAW,CAAC,EAAE;mBACxB,aAAa,CAAC,WAAW,CAAC,EAAE;cACjC,aAAa,CAAC,IAAI,CAAC,EAAE;yBACV,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO;oBAC5B,MAA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,CAAC,IAAI,CAAC,EAAE;yBACV,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO;oBAC5B,MAAM;6BACG,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM;oBACvD,OAAO;qBACN,OAAO;mBACT,MAAM;0BACC,cAAc,CAAC,MAAM,CAAC;KA2iB6C,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;cAxiBP,uBAAuB,SAAS,MAAM,KAAG,IAAI;;;;YA6iBP,OAAO,CAAC,OAAO,WAAW,CAAC;;AA7kBvE,wBA6kB4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, computed, openBlock, createBlock, unref, withCtx, createSlots, createElementBlock, Fragment, renderList, resolveDynamicComponent, normalizeClass, createCommentVNode, createVNode, normalizeStyle } from 'vue';
1
+ import { defineComponent, ref, computed, toRef, openBlock, createBlock, unref, withCtx, createSlots, createElementBlock, Fragment, renderList, resolveDynamicComponent, normalizeClass, createCommentVNode, createVNode, isRef, normalizeStyle } from 'vue';
2
2
  import _sfc_main$1 from '../InfiniteList/WInfiniteList.vue.js';
3
3
  import { getIsMobile } from '../../utils/mobile.js';
4
4
  import { useSelected, getPosition } from '../../utils/useSelected.js';
@@ -8,6 +8,7 @@ import _sfc_main$5 from './WListHeaderItem.vue.js';
8
8
  import { parseOrdering } from '../../utils/order.js';
9
9
  import _sfc_main$2 from '../Button/WButtonSelection.vue.js';
10
10
  import _sfc_main$4 from './components/HeaderSettings.vue.js';
11
+ import { useFieldConfigMap } from './use/useFieldConfigMap.js';
11
12
 
12
13
  const PAGE_LENGTH = 24;
13
14
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -27,7 +28,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
27
28
  cardClass: {},
28
29
  selectAllTextGetter: { type: Function },
29
30
  hasBorder: { type: Boolean },
30
- moreBottom: { type: Boolean }
31
+ moreBottom: { type: Boolean },
32
+ configKey: {},
33
+ defaultConfigMap: {}
31
34
  },
32
35
  emits: ["update:header-padding"],
33
36
  setup(__props) {
@@ -35,18 +38,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
35
38
  const props = __props;
36
39
  const listCount = ref(0);
37
40
  const selectionCount = ref(0);
38
- const fieldsConfig = ref(props.fields.reduce((result, field, index) => {
39
- result[field.label] = {
40
- width: 0,
41
- visible: true,
42
- order: index
43
- };
44
- return result;
45
- }, {}));
46
41
  const fieldsVisible = computed(() => props.fields.filter((field) => field.visibleGetter?.(props.queryParams) ?? true));
42
+ const { fieldConfigMap, hasSaved, reset } = useFieldConfigMap(toRef(props, "configKey"), fieldsVisible, toRef(props, "defaultConfigMap"));
47
43
  const fieldsFiltered = computed(() => {
48
44
  if (isMobile) return fieldsVisible.value;
49
- return fieldsVisible.value.filter((field) => fieldsConfig.value[field.label].visible).sort((a, b) => fieldsConfig.value[a.label].order - fieldsConfig.value[b.label].order);
45
+ return fieldsVisible.value.filter((field) => fieldConfigMap.value[field.label]?.visible).sort((a, b) => fieldConfigMap.value[a.label].order - fieldConfigMap.value[b.label].order);
50
46
  });
51
47
  const allowSelect = computed(() => props.bulk !== void 0);
52
48
  const allowOpen = computed(() => props.expansion !== void 0);
@@ -107,8 +103,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
107
103
  onSelect: unref(setSelected),
108
104
  onSelectReverse: unref(setSelectedReverse),
109
105
  onSelectRange: unref(setSelectedRange),
110
- "onUpdate:headerPadding": _cache[5] || (_cache[5] = ($event) => _ctx.$emit("update:header-padding", $event)),
111
- "onUpdate:count": _cache[6] || (_cache[6] = ($event) => listCount.value = $event)
106
+ "onUpdate:headerPadding": _cache[6] || (_cache[6] = ($event) => _ctx.$emit("update:header-padding", $event)),
107
+ "onUpdate:count": _cache[7] || (_cache[7] = ($event) => listCount.value = $event)
112
108
  }, {
113
109
  header: withCtx(({ selectAllValue }) => [
114
110
  allowSelect.value ? (openBlock(), createBlock(_sfc_main$2, {
@@ -156,15 +152,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
156
152
  "tooltip-text": _ctx.selectAllTextGetter(selectAllValue !== true, _ctx.count ?? listCount.value),
157
153
  count: _ctx.count ?? listCount.value,
158
154
  selection: selectAllValue,
159
- "onToggle:selection": _cache[4] || (_cache[4] = ($event) => $event ? unref(setSelectedReverse)([]) : unref(setSelected)([]))
155
+ "onToggle:selection": _cache[5] || (_cache[5] = ($event) => $event ? unref(setSelectedReverse)([]) : unref(setSelected)([]))
160
156
  }, {
161
157
  settings: withCtx(() => [
162
158
  createVNode(_sfc_main$4, {
163
- fields: _ctx.fields,
164
- "fields-config": fieldsConfig.value,
159
+ "field-config-map": unref(fieldConfigMap),
160
+ "onUpdate:fieldConfigMap": _cache[4] || (_cache[4] = ($event) => isRef(fieldConfigMap) ? fieldConfigMap.value = $event : null),
161
+ fields: fieldsVisible.value,
165
162
  "query-params": _ctx.queryParams,
166
- "onUpdate:fieldsConfig": _cache[3] || (_cache[3] = ($event) => fieldsConfig.value = { ...fieldsConfig.value, ...$event })
167
- }, null, 8, ["fields", "fields-config", "query-params"])
163
+ "has-saved": unref(hasSaved),
164
+ "onClick:reset": unref(reset)
165
+ }, null, 8, ["field-config-map", "fields", "query-params", "has-saved", "onClick:reset"])
168
166
  ]),
169
167
  default: withCtx(() => [
170
168
  (openBlock(true), createElementBlock(Fragment, null, renderList(fieldsFiltered.value, (field) => {
@@ -177,9 +175,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
177
175
  disabled: !field.field,
178
176
  "allow-resize": field.allowResize,
179
177
  style: normalizeStyle({
180
- minWidth: !unref(isMobile) && fieldsConfig.value[field.label]?.width ? fieldsConfig.value[field.label].width + "px" : void 0
178
+ minWidth: !unref(isMobile) && unref(fieldConfigMap)[field.label]?.width ? unref(fieldConfigMap)[field.label].width + "px" : void 0
181
179
  }),
182
- "onUpdate:width": ($event) => fieldsConfig.value[field.label].width = $event
180
+ "onUpdate:width": ($event) => unref(fieldConfigMap)[field.label].width = $event,
181
+ "onSave:width": _cache[3] || (_cache[3] = ($event) => fieldConfigMap.value = unref(fieldConfigMap))
183
182
  }, null, 8, ["title", "field", "class", "ordering", "disabled", "allow-resize", "style", "onUpdate:width"]);
184
183
  }), 128))
185
184
  ]),
@@ -219,7 +218,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
219
218
  mobile: unref(isMobile),
220
219
  class: normalizeClass(field.cssClass),
221
220
  style: normalizeStyle({
222
- minWidth: !unref(isMobile) && fieldsConfig.value[field.label]?.width ? fieldsConfig.value[field.label].width + "px" : void 0
221
+ minWidth: !unref(isMobile) && unref(fieldConfigMap)[field.label]?.width ? unref(fieldConfigMap)[field.label].width + "px" : void 0
223
222
  }),
224
223
  "onUpdate:item": setter,
225
224
  "onDelete:item": ($event) => {
@@ -1,13 +1,17 @@
1
1
  declare const _default: <Field>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
2
2
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
3
3
  readonly "onUpdate:width"?: ((value: number) => any) | undefined;
4
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:width"> & {}> & import('vue').PublicProps;
4
+ readonly "onSave:width"?: (() => any) | undefined;
5
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:width" | "onSave:width"> & {}> & import('vue').PublicProps;
5
6
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
6
7
  attrs: any;
7
8
  slots: {
8
9
  default?(_: {}): any;
9
10
  };
10
- emit: (e: "update:width", value: number) => void;
11
+ emit: {
12
+ (e: "update:width", value: number): void;
13
+ (e: "save:width"): void;
14
+ };
11
15
  }>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
12
16
  [key: string]: any;
13
17
  }> & {
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderItemResizer.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/HeaderItemResizer.vue"],"names":[],"mappings":"yBAmFiB,KAAK,eACR,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WAwIxD,mBAAmB,CAAC;;2IAAyD,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;yBA7BgB,GAAG;;cAzG1B,cAAc,SAAS,MAAM,KAAG,IAAI;;;;YA2IE,OAAO,CAAC,OAAO,WAAW,CAAC;;AAlJvE,wBAkJ4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"HeaderItemResizer.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/HeaderItemResizer.vue"],"names":[],"mappings":"yBAsFiB,KAAK,eACR,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WA6IxD,mBAAmB,CAAC;;;4JAAyD,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;yBA9BgB,GAAG;;;YA7G1B,cAAc,SAAS,MAAM,GAAG,IAAI;YACpC,YAAY,GAAG,IAAI;;;;;YA+ImB,OAAO,CAAC,OAAO,WAAW,CAAC;;AAvJvE,wBAuJ4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -8,7 +8,7 @@ const _hoisted_1 = {
8
8
  };
9
9
  const _sfc_main = /* @__PURE__ */ defineComponent({
10
10
  __name: "HeaderItemResizer",
11
- emits: ["update:width"],
11
+ emits: ["update:width", "save:width"],
12
12
  setup(__props, { emit: __emit }) {
13
13
  const emit = __emit;
14
14
  const listenerContainer = new DOMListenerContainer();
@@ -36,6 +36,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
36
36
  listenerContainer.destroy();
37
37
  started = null;
38
38
  widthSaved = null;
39
+ emit("save:width");
39
40
  };
40
41
  onMounted(() => {
41
42
  setTimeout(() => {
@@ -1,17 +1,22 @@
1
1
  import { FieldConfig, ListField } from '../types';
2
2
  declare const _default: <Data extends DefaultData, QueryParams>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
- readonly "onUpdate:fields-config"?: ((value: Record<string, FieldConfig>) => any) | undefined;
5
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:fields-config"> & {
4
+ readonly "onUpdate:field-config-map"?: ((value: Record<string, FieldConfig>) => any) | undefined;
5
+ readonly "onClick:reset"?: (() => any) | undefined;
6
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:field-config-map" | "onClick:reset"> & {
6
7
  fields: ListField<Data, QueryParams>[];
7
- fieldsConfig: Record<string, FieldConfig>;
8
+ fieldConfigMap: Record<string, FieldConfig>;
8
9
  queryParams: QueryParams;
10
+ hasSaved?: boolean;
9
11
  disabled?: boolean;
10
12
  }> & import('vue').PublicProps;
11
13
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
12
14
  attrs: any;
13
15
  slots: {};
14
- emit: (e: "update:fields-config", value: Record<string, FieldConfig>) => void;
16
+ emit: {
17
+ (e: "update:field-config-map", value: Record<string, FieldConfig>): void;
18
+ (e: "click:reset"): void;
19
+ };
15
20
  }>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
16
21
  [key: string]: any;
17
22
  }> & {
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderSettings.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/HeaderSettings.vue"],"names":[],"mappings":"AA4FA,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,UAAU,CAAA;yBAInC,IAAI,SAAS,WAAW,EAAE,WAAW,eACxC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CA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AAE,CAAC,GAAG,IAAI;WAClD,GAAG;;;YAnNP,yBAAyB,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;YACpE,aAAa,GAAG,IAAI;;;;;YAuNkB,OAAO,CAAC,OAAO,WAAW,CAAC;;AAxOvE,wBAwO4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1,29 +1,31 @@
1
- import { defineComponent, ref, openBlock, createBlock, markRaw, unref, withCtx, createElementVNode, createElementBlock, Fragment, renderList, normalizeStyle } from 'vue';
1
+ import { defineComponent, ref, openBlock, createBlock, markRaw, unref, withCtx, createElementVNode, createElementBlock, Fragment, renderList, normalizeStyle, normalizeClass } from 'vue';
2
2
  import _sfc_main$1 from '../../Button/WButtonMore.vue.js';
3
3
  import IconTableSettings from '../../../assets/icons/sax/IconTableSettings.svg.js';
4
4
  import _sfc_main$2 from './HeaderSettingsItem.vue.js';
5
5
 
6
6
  const _hoisted_1 = { class: "p-4" };
7
7
  const _hoisted_2 = { class: "flex flex-col" };
8
+ const _hoisted_3 = ["disabled"];
8
9
  const _sfc_main = /* @__PURE__ */ defineComponent({
9
10
  __name: "HeaderSettings",
10
11
  props: {
11
12
  fields: {},
12
- fieldsConfig: {},
13
+ fieldConfigMap: {},
13
14
  queryParams: {},
15
+ hasSaved: { type: Boolean },
14
16
  disabled: { type: Boolean }
15
17
  },
16
- emits: ["update:fields-config"],
18
+ emits: ["update:field-config-map", "click:reset"],
17
19
  setup(__props, { emit: __emit }) {
18
20
  const props = __props;
19
21
  const emit = __emit;
20
22
  const dragItem = ref(null);
21
23
  const dragItemNewOrder = ref(null);
22
24
  const getOrder = (field) => {
23
- if (dragItem.value === null || dragItemNewOrder.value === null) return props.fieldsConfig[field.label].order;
25
+ if (dragItem.value === null || dragItemNewOrder.value === null) return props.fieldConfigMap[field.label].order;
24
26
  if (field.label === dragItem.value) return dragItemNewOrder.value;
25
- if (props.fieldsConfig[field.label].order <= dragItemNewOrder.value) return props.fieldsConfig[field.label].order - 1;
26
- return props.fieldsConfig[field.label].order;
27
+ if (props.fieldConfigMap[field.label].order <= dragItemNewOrder.value) return props.fieldConfigMap[field.label].order - 1;
28
+ return props.fieldConfigMap[field.label].order;
27
29
  };
28
30
  const dragEnter = (field) => {
29
31
  dragItemNewOrder.value = getOrder(field);
@@ -34,10 +36,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
34
36
  };
35
37
  const drop = () => {
36
38
  const newConfig = props.fields.reduce((result, field) => {
37
- result[field.label] = { ...props.fieldsConfig[field.label], order: getOrder(field) };
39
+ result[field.label] = { ...props.fieldConfigMap[field.label], order: getOrder(field) };
38
40
  return result;
39
41
  }, {});
40
- if (Object.keys(newConfig).some((key) => props.fieldsConfig[key].order !== newConfig[key].order)) emit("update:fields-config", newConfig);
42
+ if (Object.keys(newConfig).some((key) => props.fieldConfigMap[key].order !== newConfig[key].order)) emit("update:field-config-map", newConfig);
41
43
  dragEnd();
42
44
  };
43
45
  return (_ctx, _cache) => {
@@ -53,7 +55,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
53
55
  return openBlock(), createBlock(_sfc_main$2, {
54
56
  key: field.label,
55
57
  field,
56
- "field-config": _ctx.fieldsConfig[field.label],
58
+ "field-config": _ctx.fieldConfigMap[field.label],
57
59
  "query-params": _ctx.queryParams,
58
60
  disabled: _ctx.disabled,
59
61
  style: normalizeStyle({
@@ -62,12 +64,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
62
64
  "onDrag:start": ($event) => dragItem.value = field.label,
63
65
  "onDrag:enter": ($event) => dragEnter(field),
64
66
  "onDrag:end": drop,
65
- "onUpdate:fieldsConfig": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:fields-config", $event))
67
+ "onUpdate:fieldsConfigMap": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:field-config-map", { ..._ctx.fieldConfigMap, ...$event }))
66
68
  }, null, 8, ["field", "field-config", "query-params", "disabled", "style", "onDrag:start", "onDrag:enter"]);
67
69
  }), 128))
68
70
  ]),
69
- _cache[1] || (_cache[1] = createElementVNode("div", { class: "border-b border-solid border-gray-200 dark:border-gray-700 my-4" }, null, -1)),
70
- _cache[2] || (_cache[2] = createElementVNode("button", { class: "relative py-1 px-2 rounded-lg w-ripple w-ripple-hover bg-gray-100 dark:bg-gray-800" }, " Reset ", -1))
71
+ _cache[2] || (_cache[2] = createElementVNode("div", { class: "border-b border-solid border-gray-200 dark:border-gray-700 my-4" }, null, -1)),
72
+ createElementVNode("button", {
73
+ class: normalizeClass(["relative py-1 px-2 rounded-lg bg-gray-100 dark:bg-gray-800", {
74
+ "w-ripple w-ripple-hover": _ctx.hasSaved,
75
+ "cursor-not-allowed opacity-50": !_ctx.hasSaved
76
+ }]),
77
+ disabled: !_ctx.hasSaved,
78
+ onClick: _cache[1] || (_cache[1] = ($event) => _ctx.hasSaved && _ctx.$emit("click:reset"))
79
+ }, " Reset ", 10, _hoisted_3)
71
80
  ])
72
81
  ]),
73
82
  _: 1
@@ -1,11 +1,11 @@
1
1
  import { FieldConfig, ListField } from '../types';
2
2
  declare const _default: <Data extends DefaultData, QueryParams>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
- readonly "onUpdate:fields-config"?: ((value: Record<string, FieldConfig>) => any) | undefined;
4
+ readonly "onUpdate:fields-config-map"?: ((value: Record<string, FieldConfig>) => any) | undefined;
5
5
  readonly "onDrag:start"?: (() => any) | undefined;
6
6
  readonly "onDrag:enter"?: (() => any) | undefined;
7
7
  readonly "onDrag:end"?: (() => any) | undefined;
8
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:fields-config" | "onDrag:start" | "onDrag:enter" | "onDrag:end"> & {
8
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:fields-config-map" | "onDrag:start" | "onDrag:enter" | "onDrag:end"> & {
9
9
  field: ListField<Data, QueryParams>;
10
10
  fieldConfig: FieldConfig;
11
11
  queryParams: QueryParams;
@@ -15,7 +15,7 @@ declare const _default: <Data extends DefaultData, QueryParams>(__VLS_props: Non
15
15
  attrs: any;
16
16
  slots: {};
17
17
  emit: {
18
- (e: "update:fields-config", value: Record<string, FieldConfig>): void;
18
+ (e: "update:fields-config-map", value: Record<string, FieldConfig>): void;
19
19
  (e: "drag:start"): void;
20
20
  (e: "drag:enter"): void;
21
21
  (e: "drag:end"): void;
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderSettingsItem.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/HeaderSettingsItem.vue"],"names":[],"mappings":"AAiFA,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,UAAU,CAAA;yBAKnC,IAAI,SAAS,WAAW,EAAE,WAAW,eACxC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WA0JxD,mBAAmB,CAAC;;;;;;eAtJrB,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC;qBACtB,WAAW;qBACX,WAAW;mBACb,OAAO;KAmJmE,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;;YAhJP,sBAAsB,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;YACjE,YAAY,GAAG,IAAI;YACnB,YAAY,GAAG,IAAI;YACnB,UAAU,GAAG,IAAI;;;;;YAkJqB,OAAO,CAAC,OAAO,WAAW,CAAC;;AApKvE,wBAoK4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"HeaderSettingsItem.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/HeaderSettingsItem.vue"],"names":[],"mappings":"AAiFA,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,UAAU,CAAA;yBAKnC,IAAI,SAAS,WAAW,EAAE,WAAW,eACxC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WA0JxD,mBAAmB,CAAC;;;;;;eAtJrB,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC;qBACtB,WAAW;qBACX,WAAW;mBACb,OAAO;KAmJmE,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;;YAhJP,0BAA0B,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;YACrE,YAAY,GAAG,IAAI;YACnB,YAAY,GAAG,IAAI;YACnB,UAAU,GAAG,IAAI;;;;;YAkJqB,OAAO,CAAC,OAAO,WAAW,CAAC;;AApKvE,wBAoK4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -13,7 +13,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
13
13
  queryParams: {},
14
14
  disabled: { type: Boolean }
15
15
  },
16
- emits: ["update:fields-config", "drag:start", "drag:enter", "drag:end"],
16
+ emits: ["update:fields-config-map", "drag:start", "drag:enter", "drag:end"],
17
17
  setup(__props, { emit: __emit }) {
18
18
  const emit = __emit;
19
19
  const isDraggable = ref(false);
@@ -52,7 +52,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
52
52
  createElementVNode("div", _hoisted_2, toDisplayString(typeof _ctx.field.title === "string" ? _ctx.field.title : _ctx.field.title(_ctx.queryParams)), 1),
53
53
  createElementVNode("button", {
54
54
  class: "relative w-ripple w-ripple-hover px-2 flex items-center",
55
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:fields-config", { [_ctx.field.label]: { ..._ctx.fieldConfig, visible: !_ctx.fieldConfig.visible } }))
55
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:fields-config-map", { [_ctx.field.label]: { ..._ctx.fieldConfig, visible: !_ctx.fieldConfig.visible } }))
56
56
  }, [
57
57
  (openBlock(), createBlock(resolveDynamicComponent(_ctx.fieldConfig.visible ? unref(IconEye) : unref(IconEyeSlash)), { class: "pointer-events-none" }))
58
58
  ])
@@ -24,8 +24,9 @@ export type BulkComponent<QueryParams> = Component<{
24
24
  disableMessage?: string;
25
25
  }>;
26
26
  export type FieldConfig = {
27
- width: number;
27
+ width: number | null;
28
28
  visible: boolean;
29
29
  order: number;
30
30
  };
31
+ export type FieldConfigMap<Fields extends ListField<any, any>[]> = Record<Fields[number]['label'], FieldConfig>;
31
32
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version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iBAAiB,EAAE,MAAM,WAAW,CAAA;IACpC,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAGD,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { MaybeRef } from 'vue';
2
+ import { FieldConfig, FieldConfigMap, ListField } from '../types';
3
+ export declare const useFieldConfigMap: <Fields extends ListField<any, any>[]>(key: MaybeRef<string>, fields: MaybeRef<Fields>, defaultConfigMap: MaybeRef<FieldConfigMap<Fields>>) => {
4
+ fieldConfigMap: import('vue').WritableComputedRef<Record<string, FieldConfig>, Record<string, FieldConfig>>;
5
+ hasSaved: import('vue').Ref<boolean, boolean>;
6
+ reset: () => void;
7
+ };
8
+ //# sourceMappingURL=useFieldConfigMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFieldConfigMap.d.ts","sourceRoot":"","sources":["../../../../src/components/List/use/useFieldConfigMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,QAAQ,EAAC,MAAM,KAAK,CAAA;AACrE,OAAO,KAAK,EAAC,WAAW,EAAE,cAAc,EAAE,SAAS,EAAC,MAAM,UAAU,CAAA;AAoDpE,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,UAAU,QAAQ,CAAC,MAAM,CAAC,oBAAoB,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;;;;CA6B1K,CAAA"}
@@ -0,0 +1,63 @@
1
+ import { ref, unref, computed, isRef, watch } from 'vue';
2
+
3
+ const fieldConfigKeyLength = 3;
4
+ const isFieldConfig = (value) => {
5
+ return value instanceof Object && Object.keys(value).length <= fieldConfigKeyLength && (!("width" in value) || value.width === null || typeof value.width === "number") && (!("visible" in value) || typeof value.visible === "boolean") && (!("order" in value) || typeof value.order === "number");
6
+ };
7
+ const parseFieldConfigMap = (value, fields, defaultConfigMap) => {
8
+ const configMap = fields.reduce((result, field) => {
9
+ const config = value instanceof Object && field.label in value ? value[field.label] : void 0;
10
+ const defaultConfig = defaultConfigMap[field.label];
11
+ if (!isFieldConfig(config)) {
12
+ result[field.label] = { ...defaultConfig };
13
+ } else {
14
+ result[field.label] = {
15
+ width: config.width ?? null,
16
+ visible: config.visible ?? defaultConfig.visible,
17
+ order: config.order ?? defaultConfig.order
18
+ };
19
+ }
20
+ return result;
21
+ }, {});
22
+ Object.values(configMap).sort((a, b) => a.order - b.order).forEach((item, index) => {
23
+ item.order = index;
24
+ });
25
+ return configMap;
26
+ };
27
+ const getFieldConfigMap = (key) => {
28
+ const value = localStorage.getItem(key);
29
+ if (typeof value !== "string") return void 0;
30
+ try {
31
+ return JSON.parse(value);
32
+ } catch {
33
+ return void 0;
34
+ }
35
+ };
36
+ const useFieldConfigMap = (key, fields, defaultConfigMap) => {
37
+ const value = ref(parseFieldConfigMap(getFieldConfigMap(unref(key)), unref(fields), unref(defaultConfigMap)));
38
+ const hasSaved = ref(localStorage.getItem(unref(key)) !== null);
39
+ const fieldConfigMap = computed({
40
+ get: () => value.value,
41
+ set: (newValue) => {
42
+ value.value = newValue;
43
+ localStorage.setItem(unref(key), JSON.stringify(newValue));
44
+ }
45
+ });
46
+ const reset = () => {
47
+ value.value = parseFieldConfigMap(void 0, unref(fields), unref(defaultConfigMap));
48
+ hasSaved.value = false;
49
+ localStorage.removeItem(unref(key));
50
+ };
51
+ if (isRef(key)) {
52
+ watch(key, (newKey) => {
53
+ value.value = parseFieldConfigMap(getFieldConfigMap(unref(newKey)), unref(fields), unref(defaultConfigMap));
54
+ });
55
+ }
56
+ return {
57
+ fieldConfigMap,
58
+ hasSaved,
59
+ reset
60
+ };
61
+ };
62
+
63
+ export { useFieldConfigMap };
package/dist/main.js CHANGED
@@ -86,5 +86,5 @@ export { getIsMobile, getIsTouchDevice } from './utils/mobile.js';
86
86
  export { useDefaultQuery } from './utils/useDefaultQuery.js';
87
87
  export { paginatedResponseUpdater, useQueryUpdater } from './utils/useQueryUpdater.js';
88
88
  export { useCopy } from './utils/useCopy.js';
89
- export { debounce, genId, get, getAllScrollParents, getScrollParent, hasParent, isClientSide, isEqualArr, isEqualObj, isId, isIndex, isPage, numberCompactFormatter, numberFormatter, parseId, parseIndex, percentCompactFormatter, set, throttle } from './utils/utils.js';
89
+ export { debounce, genId, get, getAllScrollParents, getDefaultFieldConfigMap, getScrollParent, hasParent, isClientSide, isEqualArr, isEqualObj, isId, isIndex, isPage, numberCompactFormatter, numberFormatter, parseId, parseIndex, percentCompactFormatter, set, throttle } from './utils/utils.js';
90
90
  export { validateRequired } from './utils/validate.js';
@@ -1,3 +1,4 @@
1
+ import { FieldConfigMap, ListField } from '../components/List/types';
1
2
  export declare const getScrollParent: (node: Element) => Element | null;
2
3
  export declare const getAllScrollParents: (node?: Element, max?: number) => Array<Element>;
3
4
  export declare const hasParent: (parent: Element, current: Element) => boolean;
@@ -18,5 +19,6 @@ export declare const isIndex: (value: unknown) => value is number;
18
19
  export declare const parseIndex: (value: unknown) => number;
19
20
  export declare const get: <FieldType, Data extends Record<string, unknown>>(data: Data, path: keyof ObjectPaths<Data, FieldType>) => FieldType | undefined;
20
21
  export declare const set: <FieldType, Data extends Record<string, unknown>>(data: Data, path: keyof ObjectPaths<Data, FieldType>, value: FieldType) => Data;
22
+ export declare const getDefaultFieldConfigMap: <Fields extends ListField<any, any>[]>(fields: Fields, visible: Fields[number]["label"][]) => FieldConfigMap<Fields>;
21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AAM,CAKxJ,CAAA"}
@@ -94,5 +94,11 @@ const set = (data, path, value) => {
94
94
  }, data);
95
95
  return data;
96
96
  };
97
+ const getDefaultFieldConfigMap = (fields, visible) => {
98
+ return fields.reduce((result, field, order) => {
99
+ result[field.label] = { width: null, visible: visible.includes(field.label), order };
100
+ return result;
101
+ }, {});
102
+ };
97
103
 
98
- export { debounce, genId, get, getAllScrollParents, getScrollParent, hasParent, isClientSide, isEqualArr, isEqualObj, isId, isIndex, isPage, numberCompactFormatter, numberFormatter, parseId, parseIndex, percentCompactFormatter, set, throttle };
104
+ export { debounce, genId, get, getAllScrollParents, getDefaultFieldConfigMap, getScrollParent, hasParent, isClientSide, isEqualArr, isEqualObj, isId, isIndex, isPage, numberCompactFormatter, numberFormatter, parseId, parseIndex, percentCompactFormatter, set, throttle };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/rsmple/eco-vue-js.git"
6
6
  },
7
- "version": "0.8.22",
7
+ "version": "0.8.23",
8
8
  "scripts": {
9
9
  "dev": "vite",
10
10
  "build": "run-p type-check build-only",