eco-vue-js 0.8.23 → 0.8.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. package/dist/components/Button/WButtonMore.vue.d.ts.map +1 -1
  2. package/dist/components/Button/WButtonMore.vue.js +1 -1
  3. package/dist/components/List/WList.vue.d.ts +3 -2
  4. package/dist/components/List/WList.vue.d.ts.map +1 -1
  5. package/dist/components/List/WList.vue.js +64 -49
  6. package/dist/components/List/WListCardField.vue.js +1 -1
  7. package/dist/components/List/components/HeaderFieldNested.vue.d.ts +37 -0
  8. package/dist/components/List/components/HeaderFieldNested.vue.d.ts.map +1 -0
  9. package/dist/components/List/components/HeaderFieldNested.vue.js +46 -0
  10. package/dist/components/List/components/HeaderFieldNested.vue2.js +5 -0
  11. package/dist/components/List/components/HeaderSettings.vue.d.ts +2 -2
  12. package/dist/components/List/components/HeaderSettings.vue.d.ts.map +1 -1
  13. package/dist/components/List/components/HeaderSettings.vue.js +47 -25
  14. package/dist/components/List/components/HeaderSettingsItem.vue.d.ts +6 -4
  15. package/dist/components/List/components/HeaderSettingsItem.vue.d.ts.map +1 -1
  16. package/dist/components/List/components/HeaderSettingsItem.vue.js +18 -13
  17. package/dist/components/List/components/ListCardFieldNested.vue.d.ts +30 -0
  18. package/dist/components/List/components/ListCardFieldNested.vue.d.ts.map +1 -0
  19. package/dist/components/List/components/ListCardFieldNested.vue.js +63 -0
  20. package/dist/components/List/components/ListCardFieldNested.vue2.js +5 -0
  21. package/dist/components/List/types.d.ts +28 -1
  22. package/dist/components/List/types.d.ts.map +1 -1
  23. package/dist/components/List/use/useFieldConfigMap.d.ts +4 -2
  24. package/dist/components/List/use/useFieldConfigMap.d.ts.map +1 -1
  25. package/dist/components/List/use/useFieldConfigMap.js +35 -15
  26. package/dist/utils/utils.d.ts +2 -2
  27. package/dist/utils/utils.d.ts.map +1 -1
  28. package/dist/utils/utils.js +11 -4
  29. package/package.json +1 -1
  30. package/tailwind-base/plugins/default.cjs +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"WButtonMore.vue.d.ts","sourceRoot":"","sources":["../../../src/components/Button/WButtonMore.vue"],"names":[],"mappings":"AAqGA,iBAAS,cAAc;;;yBATL,IAAI;YA6GQ,GAAG;;;WASnB,OAAO,IAA6B;EAEjD;AAeD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;WArJZ,YAAY;eACR,OAAO;;WADX,YAAY;eACR,OAAO;iGA0JlB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAWpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"WButtonMore.vue.d.ts","sourceRoot":"","sources":["../../../src/components/Button/WButtonMore.vue"],"names":[],"mappings":"AAqGA,iBAAS,cAAc;;;yBATL,IAAI;YA4GQ,GAAG;;;WASnB,OAAO,IAA6B;EAEjD;AAeD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;WApJZ,YAAY;eACR,OAAO;;WADX,YAAY;eACR,OAAO;iGAyJlB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAWpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -27,7 +27,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
27
27
  class: normalizeClass([{
28
28
  "w-hover-circle-trigger cursor-pointer": !_ctx.disabled,
29
29
  "cursor-not-allowed opacity-50": _ctx.disabled
30
- }, "outline-none flex items-center justify-center"]),
30
+ }, "outline-none flex justify-center"]),
31
31
  onClick: toggle
32
32
  }, [
33
33
  createVNode(_sfc_main$1, {
@@ -1,5 +1,5 @@
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<{
1
+ import { BulkComponent, FieldComponent, FieldConfigMap, ListFields, MenuComponent } from './types';
2
+ declare const _default: <Data extends DefaultData, QueryParams, Fields extends ListFields<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"> & {
@@ -20,6 +20,7 @@ declare const _default: <Data extends DefaultData, QueryParams, Fields extends L
20
20
  moreBottom?: boolean;
21
21
  configKey: string;
22
22
  defaultConfigMap: FieldConfigMap<Fields>;
23
+ alignTop?: boolean;
23
24
  }> & import('vue').PublicProps;
24
25
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
25
26
  attrs: any;
@@ -1 +1 @@
1
- {"version":3,"file":"WList.vue.d.ts","sourceRoot":"","sources":["../../../src/components/List/WList.vue"],"names":[],"mappings":"AA2RA,OAAO,KAAK,EAAC,aAAa,EAAE,cAAc,EAA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AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1,14 +1,16 @@
1
- import { defineComponent, ref, computed, toRef, openBlock, createBlock, unref, withCtx, createSlots, createElementBlock, Fragment, renderList, resolveDynamicComponent, normalizeClass, createCommentVNode, createVNode, isRef, normalizeStyle } from 'vue';
1
+ import { defineComponent, ref, computed, toRef, openBlock, createBlock, unref, withCtx, createSlots, createElementBlock, Fragment, renderList, resolveDynamicComponent, normalizeClass, createCommentVNode, createVNode, normalizeStyle, isRef } 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';
5
- import _sfc_main$6 from './WListCard.vue.js';
5
+ import _sfc_main$7 from './WListCard.vue.js';
6
6
  import _sfc_main$3 from './WListHeader.vue.js';
7
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
- import _sfc_main$4 from './components/HeaderSettings.vue.js';
11
- import { useFieldConfigMap } from './use/useFieldConfigMap.js';
10
+ import _sfc_main$6 from './components/HeaderSettings.vue.js';
11
+ import { filterFields, useFieldConfigMap, getFirstFieldLabel } from './use/useFieldConfigMap.js';
12
+ import _sfc_main$8 from './components/ListCardFieldNested.vue.js';
13
+ import _sfc_main$4 from './components/HeaderFieldNested.vue.js';
12
14
 
13
15
  const PAGE_LENGTH = 24;
14
16
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -30,7 +32,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
30
32
  hasBorder: { type: Boolean },
31
33
  moreBottom: { type: Boolean },
32
34
  configKey: {},
33
- defaultConfigMap: {}
35
+ defaultConfigMap: {},
36
+ alignTop: { type: Boolean }
34
37
  },
35
38
  emits: ["update:header-padding"],
36
39
  setup(__props) {
@@ -38,11 +41,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
38
41
  const props = __props;
39
42
  const listCount = ref(0);
40
43
  const selectionCount = ref(0);
41
- const fieldsVisible = computed(() => props.fields.filter((field) => field.visibleGetter?.(props.queryParams) ?? true));
44
+ const fieldsVisible = computed(() => filterFields(props.fields, (field) => field.visibleGetter?.(props.queryParams) ?? true));
42
45
  const { fieldConfigMap, hasSaved, reset } = useFieldConfigMap(toRef(props, "configKey"), fieldsVisible, toRef(props, "defaultConfigMap"));
43
46
  const fieldsFiltered = computed(() => {
44
47
  if (isMobile) return fieldsVisible.value;
45
- return fieldsVisible.value.filter((field) => fieldConfigMap.value[field.label]?.visible).sort((a, b) => fieldConfigMap.value[a.label].order - fieldConfigMap.value[b.label].order);
48
+ return filterFields(fieldsVisible.value, (field) => fieldConfigMap.value[field.label]?.visible).sort((a, b) => fieldConfigMap.value[getFirstFieldLabel(a)].order - fieldConfigMap.value[getFirstFieldLabel(b)].order);
46
49
  });
47
50
  const allowSelect = computed(() => props.bulk !== void 0);
48
51
  const allowOpen = computed(() => props.expansion !== void 0);
@@ -154,8 +157,28 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
154
157
  selection: selectAllValue,
155
158
  "onToggle:selection": _cache[5] || (_cache[5] = ($event) => $event ? unref(setSelectedReverse)([]) : unref(setSelected)([]))
156
159
  }, {
160
+ default: withCtx(() => [
161
+ createVNode(_sfc_main$4, { fields: fieldsFiltered.value }, {
162
+ default: withCtx(({ field }) => [
163
+ createVNode(_sfc_main$5, {
164
+ title: typeof field.title === "string" ? field.title : field.title(_ctx.queryParams),
165
+ field: typeof field.field === "string" ? field.field : field.field?.(_ctx.queryParams),
166
+ class: normalizeClass(field.cssClass),
167
+ ordering: ordering.value,
168
+ disabled: !field.field,
169
+ "allow-resize": field.allowResize,
170
+ style: normalizeStyle({
171
+ minWidth: !unref(isMobile) && unref(fieldConfigMap)[field.label]?.width ? unref(fieldConfigMap)[field.label].width + "px" : void 0
172
+ }),
173
+ "onUpdate:width": ($event) => unref(fieldConfigMap)[field.label].width = $event,
174
+ "onSave:width": _cache[3] || (_cache[3] = ($event) => fieldConfigMap.value = unref(fieldConfigMap))
175
+ }, null, 8, ["title", "field", "class", "ordering", "disabled", "allow-resize", "style", "onUpdate:width"])
176
+ ]),
177
+ _: 1
178
+ }, 8, ["fields"])
179
+ ]),
157
180
  settings: withCtx(() => [
158
- createVNode(_sfc_main$4, {
181
+ createVNode(_sfc_main$6, {
159
182
  "field-config-map": unref(fieldConfigMap),
160
183
  "onUpdate:fieldConfigMap": _cache[4] || (_cache[4] = ($event) => isRef(fieldConfigMap) ? fieldConfigMap.value = $event : null),
161
184
  fields: fieldsVisible.value,
@@ -164,36 +187,48 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
164
187
  "onClick:reset": unref(reset)
165
188
  }, null, 8, ["field-config-map", "fields", "query-params", "has-saved", "onClick:reset"])
166
189
  ]),
167
- default: withCtx(() => [
168
- (openBlock(true), createElementBlock(Fragment, null, renderList(fieldsFiltered.value, (field) => {
169
- return openBlock(), createBlock(_sfc_main$5, {
170
- key: field.label,
171
- title: typeof field.title === "string" ? field.title : field.title(_ctx.queryParams),
172
- field: typeof field.field === "string" ? field.field : field.field?.(_ctx.queryParams),
173
- class: normalizeClass(field.cssClass),
174
- ordering: ordering.value,
175
- disabled: !field.field,
176
- "allow-resize": field.allowResize,
177
- style: normalizeStyle({
178
- minWidth: !unref(isMobile) && unref(fieldConfigMap)[field.label]?.width ? unref(fieldConfigMap)[field.label].width + "px" : void 0
179
- }),
180
- "onUpdate:width": ($event) => unref(fieldConfigMap)[field.label].width = $event,
181
- "onSave:width": _cache[3] || (_cache[3] = ($event) => fieldConfigMap.value = unref(fieldConfigMap))
182
- }, null, 8, ["title", "field", "class", "ordering", "disabled", "allow-resize", "style", "onUpdate:width"]);
183
- }), 128))
184
- ]),
185
190
  _: 2
186
191
  }, 1032, ["query-params", "allow-select", "tooltip-text", "count", "selection"])) : createCommentVNode("", true)
187
192
  ]),
188
193
  default: withCtx(({ item, skeleton, setter, refetch }) => [
189
- createVNode(_sfc_main$6, {
194
+ createVNode(_sfc_main$7, {
190
195
  disabled: skeleton,
191
196
  mobile: unref(isMobile),
192
197
  "card-class": _ctx.cardClass,
193
198
  "has-border": _ctx.hasBorder,
194
199
  "more-bottom": _ctx.moreBottom,
195
- "allow-open": allowOpen.value && !skeleton
200
+ "allow-open": allowOpen.value && !skeleton,
201
+ "align-top": _ctx.alignTop
196
202
  }, createSlots({
203
+ default: withCtx(() => [
204
+ createVNode(_sfc_main$8, {
205
+ fields: fieldsFiltered.value,
206
+ item
207
+ }, {
208
+ default: withCtx((defaultScope) => [
209
+ (openBlock(), createBlock(resolveDynamicComponent(defaultScope.field.component), {
210
+ item: defaultScope.item,
211
+ readonly: _ctx.readonlyGetter?.(defaultScope.item),
212
+ skeleton,
213
+ mobile: unref(isMobile),
214
+ class: normalizeClass({
215
+ [defaultScope.field.cssClass ?? ""]: true,
216
+ "items-center": !_ctx.alignTop,
217
+ "items-start": _ctx.alignTop
218
+ }),
219
+ style: normalizeStyle({
220
+ minWidth: !unref(isMobile) && unref(fieldConfigMap)[defaultScope.field.label]?.width ? unref(fieldConfigMap)[defaultScope.field.label].width + "px" : void 0
221
+ }),
222
+ "onUpdate:item": setter,
223
+ "onDelete:item": ($event) => {
224
+ setter();
225
+ refetch();
226
+ }
227
+ }, null, 40, ["item", "readonly", "skeleton", "mobile", "class", "style", "onUpdate:item", "onDelete:item"]))
228
+ ]),
229
+ _: 2
230
+ }, 1032, ["fields", "item"])
231
+ ]),
197
232
  more: withCtx(() => [
198
233
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menu, (menuItem, menuIndex) => {
199
234
  return openBlock(), createBlock(resolveDynamicComponent(menuItem), {
@@ -208,26 +243,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
208
243
  }, null, 40, ["item", "readonly", "onUpdate:item", "onDelete:item"]);
209
244
  }), 128))
210
245
  ]),
211
- default: withCtx(() => [
212
- (openBlock(true), createElementBlock(Fragment, null, renderList(fieldsFiltered.value, (field) => {
213
- return openBlock(), createBlock(resolveDynamicComponent(field.component), {
214
- key: field.label,
215
- item,
216
- readonly: _ctx.readonlyGetter?.(item),
217
- skeleton,
218
- mobile: unref(isMobile),
219
- class: normalizeClass(field.cssClass),
220
- style: normalizeStyle({
221
- minWidth: !unref(isMobile) && unref(fieldConfigMap)[field.label]?.width ? unref(fieldConfigMap)[field.label].width + "px" : void 0
222
- }),
223
- "onUpdate:item": setter,
224
- "onDelete:item": ($event) => {
225
- setter();
226
- refetch();
227
- }
228
- }, null, 40, ["item", "readonly", "skeleton", "mobile", "class", "style", "onUpdate:item", "onDelete:item"]);
229
- }), 128))
230
- ]),
231
246
  _: 2
232
247
  }, [
233
248
  _ctx.expansion ? {
@@ -247,7 +262,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
247
262
  ]),
248
263
  key: "0"
249
264
  } : void 0
250
- ]), 1032, ["disabled", "mobile", "card-class", "has-border", "more-bottom", "allow-open"])
265
+ ]), 1032, ["disabled", "mobile", "card-class", "has-border", "more-bottom", "allow-open", "align-top"])
251
266
  ]),
252
267
  _: 1
253
268
  }, 8, ["use-query-fn", "query-params", "skeleton-length", "header-margin", "allow-select", "selected", "reverse", "selected-range", "count", "onSelect", "onSelectReverse", "onSelectRange"]);
@@ -12,7 +12,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
12
12
  setup(__props) {
13
13
  return (_ctx, _cache) => {
14
14
  return openBlock(), createElementBlock("div", {
15
- class: normalizeClass(["grid grid-cols-1 items-center sm:h-16 sm:pr-6", { "pointer-events-none": _ctx.allowOpen }])
15
+ class: normalizeClass(["grid grid-cols-1 sm:min-h-16 sm:pr-6 sm:last:-mr-6", { "pointer-events-none": _ctx.allowOpen }])
16
16
  }, [
17
17
  _ctx.skeleton ? (openBlock(), createBlock(WSkeleton, { key: 0 })) : renderSlot(_ctx.$slots, "default", { key: 1 }, () => [
18
18
  createElementVNode("div", _hoisted_1, [
@@ -0,0 +1,37 @@
1
+ import { ListField, ListFields } from '../types';
2
+ declare const _default: <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
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & {
4
+ fields: ListFields<Data, QueryParams>;
5
+ }> & import('vue').PublicProps;
6
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
7
+ attrs: any;
8
+ slots: Readonly<{
9
+ default: (props: {
10
+ field: ListField<Data, QueryParams>;
11
+ nested: boolean;
12
+ index: number;
13
+ length: number;
14
+ first: boolean;
15
+ last: boolean;
16
+ }) => void;
17
+ }> & {
18
+ default: (props: {
19
+ field: ListField<Data, QueryParams>;
20
+ nested: boolean;
21
+ index: number;
22
+ length: number;
23
+ first: boolean;
24
+ last: boolean;
25
+ }) => void;
26
+ };
27
+ emit: {};
28
+ }>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
29
+ [key: string]: any;
30
+ }> & {
31
+ __ctx?: Awaited<typeof __VLS_setup>;
32
+ };
33
+ export default _default;
34
+ type __VLS_PrettifyLocal<T> = {
35
+ [K in keyof T]: T[K];
36
+ } & {};
37
+ //# sourceMappingURL=HeaderFieldNested.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeaderFieldNested.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/HeaderFieldNested.vue"],"names":[],"mappings":"AAsDA,OAAO,KAAK,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,UA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, Fragment, renderList, unref, createBlock, withCtx, renderSlot } from 'vue';
2
+ import { getFirstFieldLabel } from '../use/useFieldConfigMap.js';
3
+
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ __name: "HeaderFieldNested",
6
+ props: {
7
+ fields: {}
8
+ },
9
+ setup(__props) {
10
+ return (_ctx, _cache) => {
11
+ const _component_HeaderFieldNested = resolveComponent("HeaderFieldNested", true);
12
+ return openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.fields, (field, index) => {
13
+ return openBlock(), createElementBlock(Fragment, {
14
+ key: unref(getFirstFieldLabel)(field)
15
+ }, [
16
+ "fields" in field ? (openBlock(), createBlock(_component_HeaderFieldNested, {
17
+ key: 0,
18
+ fields: field.fields
19
+ }, {
20
+ default: withCtx((defaultScope) => [
21
+ renderSlot(_ctx.$slots, "default", {
22
+ field: defaultScope.field,
23
+ nested: true,
24
+ index: defaultScope.index,
25
+ length: defaultScope.length,
26
+ first: defaultScope.first,
27
+ last: defaultScope.last
28
+ })
29
+ ]),
30
+ _: 2
31
+ }, 1032, ["fields"])) : renderSlot(_ctx.$slots, "default", {
32
+ key: 1,
33
+ field,
34
+ nested: false,
35
+ index,
36
+ length: _ctx.fields.length,
37
+ first: index === 0,
38
+ last: index === _ctx.fields.length - 1
39
+ })
40
+ ], 64);
41
+ }), 128);
42
+ };
43
+ }
44
+ });
45
+
46
+ export { _sfc_main as default };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from './HeaderFieldNested.vue.js';
2
+
3
+
4
+
5
+ export { _sfc_main as default };
@@ -1,10 +1,10 @@
1
- import { FieldConfig, ListField } from '../types';
1
+ import { FieldConfig, ListFields } 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
4
  readonly "onUpdate:field-config-map"?: ((value: Record<string, FieldConfig>) => any) | undefined;
5
5
  readonly "onClick:reset"?: (() => any) | undefined;
6
6
  } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:field-config-map" | "onClick:reset"> & {
7
- fields: ListField<Data, QueryParams>[];
7
+ fields: ListFields<Data, QueryParams>;
8
8
  fieldConfigMap: Record<string, FieldConfig>;
9
9
  queryParams: QueryParams;
10
10
  hasSaved?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderSettings.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/HeaderSettings.vue"],"names":[],"mappings":"AAoGA,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,CAAC,CAAC,CAAC,QAAQ,CAAC;WA8NxD,mBAAmB,CAAC;;;;gBA1NpB,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE;wBACtB,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;qBAC9B,WAAW;mBACb,OAAO;mBACP,OAAO;KAsNmE,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,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
+ {"version":3,"file":"HeaderSettings.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/HeaderSettings.vue"],"names":[],"mappings":"AAqIA,OAAO,KAAK,EAAC,WAAW,EAAa,UAAU,EAAC,MAAM,UAAU,CAAA;yBAK/C,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;WAqQxD,mBAAmB,CAAC;;;;gBAjQpB,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC;wBACrB,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;qBAC9B,WAAW;mBACb,OAAO;mBACP,OAAO;KA6PmE,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;;YA1PP,yBAAyB,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;YACpE,aAAa,GAAG,IAAI;;;;;YA8PkB,OAAO,CAAC,OAAO,WAAW,CAAC;;AA/QvE,wBA+Q4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1,7 +1,8 @@
1
- import { defineComponent, ref, openBlock, createBlock, markRaw, unref, withCtx, createElementVNode, createElementBlock, Fragment, renderList, normalizeStyle, normalizeClass } from 'vue';
1
+ import { defineComponent, ref, openBlock, createBlock, markRaw, unref, withCtx, createElementVNode, createVNode, 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
- import _sfc_main$2 from './HeaderSettingsItem.vue.js';
4
+ import _sfc_main$3 from './HeaderSettingsItem.vue.js';
5
+ import _sfc_main$2 from './HeaderFieldNested.vue.js';
5
6
 
6
7
  const _hoisted_1 = { class: "p-4" };
7
8
  const _hoisted_2 = { class: "flex flex-col" };
@@ -27,18 +28,38 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
27
28
  if (props.fieldConfigMap[field.label].order <= dragItemNewOrder.value) return props.fieldConfigMap[field.label].order - 1;
28
29
  return props.fieldConfigMap[field.label].order;
29
30
  };
30
- const dragEnter = (field) => {
31
- dragItemNewOrder.value = getOrder(field);
31
+ const dragStart = (label, order) => {
32
+ dragItem.value = label;
33
+ dragItemNewOrder.value = order;
34
+ };
35
+ const dragEnter = (order, nested, first, last) => {
36
+ if (nested) {
37
+ if (dragItemNewOrder.value === null) return;
38
+ if (first) {
39
+ if (order < dragItemNewOrder.value) dragItemNewOrder.value = order;
40
+ } else if (last) {
41
+ if (order > dragItemNewOrder.value) dragItemNewOrder.value = order;
42
+ }
43
+ return;
44
+ }
45
+ dragItemNewOrder.value = order;
32
46
  };
33
47
  const dragEnd = () => {
34
48
  dragItem.value = null;
35
49
  dragItemNewOrder.value = null;
36
50
  };
37
51
  const drop = () => {
38
- const newConfig = props.fields.reduce((result, field) => {
39
- result[field.label] = { ...props.fieldConfigMap[field.label], order: getOrder(field) };
40
- return result;
41
- }, {});
52
+ const newConfig = {};
53
+ const processConfig = (fields) => {
54
+ fields.forEach((field) => {
55
+ if ("label" in field) newConfig[field.label] = { ...props.fieldConfigMap[field.label], order: getOrder(field) };
56
+ if ("fields" in field) processConfig(field.fields);
57
+ }, {});
58
+ };
59
+ processConfig(props.fields);
60
+ Object.values(newConfig).sort((a, b) => a.order - b.order).forEach((item, index) => {
61
+ item.order = index;
62
+ });
42
63
  if (Object.keys(newConfig).some((key) => props.fieldConfigMap[key].order !== newConfig[key].order)) emit("update:field-config-map", newConfig);
43
64
  dragEnd();
44
65
  };
@@ -46,27 +67,28 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
46
67
  return openBlock(), createBlock(_sfc_main$1, {
47
68
  icon: markRaw(unref(IconTableSettings)),
48
69
  disabled: _ctx.disabled,
49
- class: "h-full w-full"
70
+ class: "h-full w-full items-center"
50
71
  }, {
51
72
  default: withCtx(() => [
52
73
  createElementVNode("div", _hoisted_1, [
53
74
  createElementVNode("div", _hoisted_2, [
54
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.fields, (field) => {
55
- return openBlock(), createBlock(_sfc_main$2, {
56
- key: field.label,
57
- field,
58
- "field-config": _ctx.fieldConfigMap[field.label],
59
- "query-params": _ctx.queryParams,
60
- disabled: _ctx.disabled,
61
- style: normalizeStyle({
62
- order: getOrder(field)
63
- }),
64
- "onDrag:start": ($event) => dragItem.value = field.label,
65
- "onDrag:enter": ($event) => dragEnter(field),
66
- "onDrag:end": drop,
67
- "onUpdate:fieldsConfigMap": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:field-config-map", { ..._ctx.fieldConfigMap, ...$event }))
68
- }, null, 8, ["field", "field-config", "query-params", "disabled", "style", "onDrag:start", "onDrag:enter"]);
69
- }), 128))
75
+ createVNode(_sfc_main$2, { fields: _ctx.fields }, {
76
+ default: withCtx(({ field, nested, first, last }) => [
77
+ createVNode(_sfc_main$3, {
78
+ field,
79
+ "field-config": _ctx.fieldConfigMap[field.label],
80
+ "query-params": _ctx.queryParams,
81
+ disabled: _ctx.disabled,
82
+ "disabled-drag": nested,
83
+ order: getOrder(field),
84
+ "onDrag:start": ($event) => dragStart(field.label, $event),
85
+ "onDrag:enter": ($event) => dragEnter($event, nested, first, last),
86
+ "onDrag:end": drop,
87
+ "onUpdate:fieldsConfigMap": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:field-config-map", { ..._ctx.fieldConfigMap, ...$event }))
88
+ }, null, 8, ["field", "field-config", "query-params", "disabled", "disabled-drag", "order", "onDrag:start", "onDrag:enter"])
89
+ ]),
90
+ _: 1
91
+ }, 8, ["fields"])
70
92
  ]),
71
93
  _cache[2] || (_cache[2] = createElementVNode("div", { class: "border-b border-solid border-gray-200 dark:border-gray-700 my-4" }, null, -1)),
72
94
  createElementVNode("button", {
@@ -2,22 +2,24 @@ 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
4
  readonly "onUpdate:fields-config-map"?: ((value: Record<string, FieldConfig>) => any) | undefined;
5
- readonly "onDrag:start"?: (() => any) | undefined;
6
- readonly "onDrag:enter"?: (() => any) | undefined;
5
+ readonly "onDrag:start"?: ((order: number) => any) | undefined;
6
+ readonly "onDrag:enter"?: ((order: number) => any) | undefined;
7
7
  readonly "onDrag:end"?: (() => any) | undefined;
8
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;
12
12
  disabled?: boolean;
13
+ disabledDrag?: boolean;
14
+ order: number;
13
15
  }> & import('vue').PublicProps;
14
16
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
15
17
  attrs: any;
16
18
  slots: {};
17
19
  emit: {
18
20
  (e: "update:fields-config-map", value: Record<string, FieldConfig>): void;
19
- (e: "drag:start"): void;
20
- (e: "drag:enter"): void;
21
+ (e: "drag:start", order: number): void;
22
+ (e: "drag:enter", order: number): void;
21
23
  (e: "drag:end"): void;
22
24
  };
23
25
  }>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
@@ -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,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"}
1
+ {"version":3,"file":"HeaderSettingsItem.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/HeaderSettingsItem.vue"],"names":[],"mappings":"AAqFA,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;WAmKxD,mBAAmB,CAAC;;;;;;eA/JrB,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC;qBACtB,WAAW;qBACX,WAAW;mBACb,OAAO;uBACH,OAAO;eACf,MAAM;KA0JwE,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;;YAvJP,0BAA0B,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;YACrE,YAAY,SAAS,MAAM,GAAG,IAAI;YAClC,YAAY,SAAS,MAAM,GAAG,IAAI;YAClC,UAAU,GAAG,IAAI;;;;;YAyJqB,OAAO,CAAC,OAAO,WAAW,CAAC;;AA7KvE,wBA6K4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1,20 +1,23 @@
1
- import { defineComponent, ref, openBlock, createElementBlock, normalizeClass, withModifiers, createElementVNode, createVNode, unref, toDisplayString, createBlock, resolveDynamicComponent } from 'vue';
1
+ import { defineComponent, ref, openBlock, createElementBlock, normalizeClass, normalizeStyle, withModifiers, createVNode, unref, createCommentVNode, createElementVNode, toDisplayString, createBlock, resolveDynamicComponent } from 'vue';
2
2
  import IconDrag from '../../../assets/icons/sax/IconDrag.svg.js';
3
3
  import IconEye from '../../../assets/icons/sax/IconEye.svg.js';
4
4
  import IconEyeSlash from '../../../assets/icons/sax/IconEyeSlash.svg.js';
5
5
 
6
6
  const _hoisted_1 = ["draggable"];
7
- const _hoisted_2 = { class: "px-2 py-1 self-center font-semibold" };
7
+ const _hoisted_2 = { class: "px-2 py-1 self-center font-semibold col-start-2" };
8
8
  const _sfc_main = /* @__PURE__ */ defineComponent({
9
9
  __name: "HeaderSettingsItem",
10
10
  props: {
11
11
  field: {},
12
12
  fieldConfig: {},
13
13
  queryParams: {},
14
- disabled: { type: Boolean }
14
+ disabled: { type: Boolean },
15
+ disabledDrag: { type: Boolean },
16
+ order: {}
15
17
  },
16
18
  emits: ["update:fields-config-map", "drag:start", "drag:enter", "drag:end"],
17
19
  setup(__props, { emit: __emit }) {
20
+ const props = __props;
18
21
  const emit = __emit;
19
22
  const isDraggable = ref(false);
20
23
  const isDragging = ref(false);
@@ -23,7 +26,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
23
26
  };
24
27
  const startDrag = () => {
25
28
  isDragging.value = true;
26
- emit("drag:start");
29
+ emit("drag:start", props.order);
27
30
  };
28
31
  const endDrag = () => {
29
32
  isDraggable.value = false;
@@ -33,22 +36,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
33
36
  return (_ctx, _cache) => {
34
37
  return openBlock(), createElementBlock("div", {
35
38
  draggable: isDraggable.value,
36
- class: normalizeClass(["grid grid-cols-[auto,1fr,auto] text-description select-none bg-default dark:bg-default-dark", {
39
+ class: normalizeClass(["grid grid-cols-[1.75rem,1fr,auto] text-description select-none bg-default dark:bg-default-dark", {
37
40
  "opacity-[0.001]": isDragging.value,
38
41
  "opacity-50": !_ctx.fieldConfig.visible && !isDragging.value
39
42
  }]),
40
- onDragstart: startDrag,
41
- onDragend: endDrag,
42
- onDragenter: _cache[1] || (_cache[1] = ($event) => !isDraggable.value && _ctx.$emit("drag:enter")),
43
- onDragover: _cache[2] || (_cache[2] = withModifiers(() => {
43
+ style: normalizeStyle({ order: _ctx.order }),
44
+ onDragstart: _cache[1] || (_cache[1] = ($event) => !_ctx.disabledDrag && startDrag()),
45
+ onDragend: _cache[2] || (_cache[2] = ($event) => !_ctx.disabledDrag && endDrag()),
46
+ onDragenter: _cache[3] || (_cache[3] = ($event) => !isDraggable.value && _ctx.$emit("drag:enter", _ctx.order)),
47
+ onDragover: _cache[4] || (_cache[4] = withModifiers(() => {
44
48
  }, ["stop", "prevent"]))
45
49
  }, [
46
- createElementVNode("button", {
47
- class: "relative w-ripple w-ripple-hover px-2 flex items-center",
50
+ !_ctx.disabledDrag ? (openBlock(), createElementBlock("button", {
51
+ key: 0,
52
+ class: "relative w-ripple w-ripple-hover flex items-center justify-center",
48
53
  onMousedown: initDrag
49
54
  }, [
50
55
  createVNode(unref(IconDrag), { class: "rotate-90" })
51
- ], 32),
56
+ ], 32)) : createCommentVNode("", true),
52
57
  createElementVNode("div", _hoisted_2, toDisplayString(typeof _ctx.field.title === "string" ? _ctx.field.title : _ctx.field.title(_ctx.queryParams)), 1),
53
58
  createElementVNode("button", {
54
59
  class: "relative w-ripple w-ripple-hover px-2 flex items-center",
@@ -56,7 +61,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
56
61
  }, [
57
62
  (openBlock(), createBlock(resolveDynamicComponent(_ctx.fieldConfig.visible ? unref(IconEye) : unref(IconEyeSlash)), { class: "pointer-events-none" }))
58
63
  ])
59
- ], 42, _hoisted_1);
64
+ ], 46, _hoisted_1);
60
65
  };
61
66
  }
62
67
  });
@@ -0,0 +1,30 @@
1
+ import { ListField, ListFields } 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<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & {
4
+ fields: ListFields<Data, QueryParams>;
5
+ item: Data;
6
+ }> & import('vue').PublicProps;
7
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
8
+ attrs: any;
9
+ slots: Readonly<{
10
+ default: (props: {
11
+ field: ListField<Data, QueryParams>;
12
+ item: Data;
13
+ }) => void;
14
+ }> & {
15
+ default: (props: {
16
+ field: ListField<Data, QueryParams>;
17
+ item: Data;
18
+ }) => void;
19
+ };
20
+ emit: {};
21
+ }>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
22
+ [key: string]: any;
23
+ }> & {
24
+ __ctx?: Awaited<typeof __VLS_setup>;
25
+ };
26
+ export default _default;
27
+ type __VLS_PrettifyLocal<T> = {
28
+ [K in keyof T]: T[K];
29
+ } & {};
30
+ //# sourceMappingURL=ListCardFieldNested.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListCardFieldNested.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/List/components/ListCardFieldNested.vue"],"names":[],"mappings":"AAoEA,OAAO,KAAK,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,UAAU,CAAA;yBAIlC,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;WA6GxD,mBAAmB,CAAC;gBAzGpB,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC;cAC/B,IAAI;KAwG2E,CAAC,4BAA2B;oBAChG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;iBArGF,CAAC,KAAK,EAAE;YAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAAC,IAAI,EAAE,IAAI,CAAA;SAAC,KAAK,IAAI;;iBAAlE,CAAC,KAAK,EAAE;YAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAAC,IAAI,EAAE,IAAI,CAAA;SAAC,KAAK,IAAI;;UAuGpE,EAAE;;;;YAGiC,OAAO,CAAC,OAAO,WAAW,CAAC;;AAvHvE,wBAuH4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { defineComponent, resolveComponent, openBlock, createElementBlock, Fragment, renderList, unref, normalizeClass, createVNode, withCtx, renderSlot, mergeProps } from 'vue';
2
+ import { getFirstFieldLabel } from '../use/useFieldConfigMap.js';
3
+
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ __name: "ListCardFieldNested",
6
+ props: {
7
+ fields: {},
8
+ item: {}
9
+ },
10
+ setup(__props) {
11
+ return (_ctx, _cache) => {
12
+ const _component_ListCardFieldNested = resolveComponent("ListCardFieldNested", true);
13
+ return openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.fields, (field) => {
14
+ return openBlock(), createElementBlock(Fragment, {
15
+ key: unref(getFirstFieldLabel)(field)
16
+ }, [
17
+ "fields" in field ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
18
+ "keyArray" in field ? (openBlock(), createElementBlock("div", {
19
+ key: 0,
20
+ class: normalizeClass([field.cssClassArray, "sm:mr-6"])
21
+ }, [
22
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.item[field.keyArray], (inner) => {
23
+ return openBlock(), createElementBlock("div", {
24
+ key: inner.id,
25
+ class: normalizeClass([field.cssClass, "flex"])
26
+ }, [
27
+ createVNode(_component_ListCardFieldNested, {
28
+ fields: field.fields,
29
+ item: inner
30
+ }, {
31
+ default: withCtx((defaultScope) => [
32
+ renderSlot(_ctx.$slots, "default", mergeProps({ ref_for: true }, defaultScope))
33
+ ]),
34
+ _: 2
35
+ }, 1032, ["fields", "item"])
36
+ ], 2);
37
+ }), 128))
38
+ ], 2)) : (openBlock(), createElementBlock("div", {
39
+ key: 1,
40
+ class: normalizeClass([field.cssClass, "flex sm:mr-6"])
41
+ }, [
42
+ createVNode(_component_ListCardFieldNested, {
43
+ fields: field.fields,
44
+ item: "keyEntity" in field ? _ctx.item[field.keyEntity] : _ctx.item
45
+ }, {
46
+ default: withCtx((defaultScope) => [
47
+ renderSlot(_ctx.$slots, "default", mergeProps({ ref_for: true }, defaultScope))
48
+ ]),
49
+ _: 2
50
+ }, 1032, ["fields", "item"])
51
+ ], 2))
52
+ ], 64)) : renderSlot(_ctx.$slots, "default", {
53
+ key: 1,
54
+ field,
55
+ item: _ctx.item
56
+ })
57
+ ], 64);
58
+ }), 128);
59
+ };
60
+ }
61
+ });
62
+
63
+ export { _sfc_main as default };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from './ListCardFieldNested.vue.js';
2
+
3
+
4
+
5
+ export { _sfc_main as default };
@@ -14,6 +14,26 @@ export type ListField<Data, QueryParams = unknown> = {
14
14
  visibleGetter?: (params: QueryParams) => boolean;
15
15
  allowResize?: boolean;
16
16
  };
17
+ export type ListFieldNested<Data, QueryParams = unknown> = {
18
+ cssClass?: string;
19
+ fields: ListFields<Data, QueryParams>;
20
+ };
21
+ type FieldNestedEntity<Data, QueryParams = unknown, Key extends keyof PickByType<Data, NonNullable<unknown>> = keyof PickByType<Data, NonNullable<unknown>>> = {
22
+ keyEntity: Key;
23
+ fields: ListFields<Data[Key], QueryParams>;
24
+ };
25
+ export interface ListFieldNestedEntity<Data, QueryParams = unknown> extends FieldNestedEntity<Data, QueryParams> {
26
+ cssClass?: string;
27
+ }
28
+ type FieldNestedArray<Data, QueryParams = unknown, Key extends keyof PickByType<Data, Array<unknown>> = keyof PickByType<Data, Array<unknown>>> = {
29
+ keyArray: Key;
30
+ fields: Data[Key] extends Array<infer Inner> ? ListFields<Inner, QueryParams> : [];
31
+ };
32
+ export interface ListFieldNestedArray<Data, QueryParams = unknown> extends FieldNestedArray<Data, QueryParams> {
33
+ cssClass?: string;
34
+ cssClassArray?: string;
35
+ }
36
+ export type ListFields<Data, QueryParams = unknown> = (ListField<Data, QueryParams> | ListFieldNested<Data, QueryParams> | ListFieldNestedEntity<Data, QueryParams> | ListFieldNestedArray<Data, QueryParams>)[];
17
37
  export type MenuComponent<Data> = Component<{
18
38
  item: Data;
19
39
  readonly?: boolean;
@@ -28,5 +48,12 @@ export type FieldConfig = {
28
48
  visible: boolean;
29
49
  order: number;
30
50
  };
31
- export type FieldConfigMap<Fields extends ListField<any, any>[]> = Record<Fields[number]['label'], FieldConfig>;
51
+ type GetFieldLabelsTuple<Fields> = Fields extends [infer Head, ...infer Tail] ? Head extends {
52
+ label: infer Label;
53
+ } ? [Label, ...GetFieldLabelsTuple<Tail>] : Head extends {
54
+ fields: infer InnerFields;
55
+ } ? [...GetFieldLabelsTuple<InnerFields>, ...GetFieldLabelsTuple<Tail>] : GetFieldLabelsTuple<Tail> : [];
56
+ export type GetFieldLabels<Fields extends ListFields<unknown>> = GetFieldLabelsTuple<Fields>[number];
57
+ export type FieldConfigMap<Fields extends ListFields<any, any>> = Record<GetFieldLabels<Fields>, FieldConfig>;
58
+ export {};
32
59
  //# sourceMappingURL=types.d.ts.map
@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AC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAGpG,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAA"}
@@ -1,6 +1,8 @@
1
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>>) => {
2
+ import { FieldConfig, FieldConfigMap, ListField, ListFields } from '../types';
3
+ export declare const filterFields: <F extends ListFields<any, any>>(fields: F, method: (field: ListField<unknown>) => boolean) => F;
4
+ export declare const getFirstFieldLabel: <F extends ListFields<any, any>[number]>(field: F) => string;
5
+ export declare const useFieldConfigMap: <Fields extends ListFields<any, any>>(key: MaybeRef<string>, fields: MaybeRef<Fields>, defaultConfigMap: MaybeRef<FieldConfigMap<Fields>>) => {
4
6
  fieldConfigMap: import('vue').WritableComputedRef<Record<string, FieldConfig>, Record<string, FieldConfig>>;
5
7
  hasSaved: import('vue').Ref<boolean, boolean>;
6
8
  reset: () => void;
@@ -1 +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"}
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,EAAE,UAAU,EAAC,MAAM,UAAU,CAAA;AA6DhF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,OAAO,KAAG,CAUxH,CAAA;AAGD,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,KAAG,MAErF,CAAA;AAGD,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,QAAQ,CAAC,MAAM,CAAC,UAAU,QAAQ,CAAC,MAAM,CAAC,oBAAoB,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;;;;CA8BzK,CAAA"}
@@ -5,20 +5,27 @@ const isFieldConfig = (value) => {
5
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
6
  };
7
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
- }, {});
8
+ const configMap = {};
9
+ const processFields = (fieldList) => {
10
+ fieldList.forEach((field) => {
11
+ if ("fields" in field) {
12
+ processFields(field.fields);
13
+ return;
14
+ }
15
+ const config = value instanceof Object && field.label in value ? value[field.label] : void 0;
16
+ const defaultConfig = defaultConfigMap[field.label];
17
+ if (!isFieldConfig(config)) {
18
+ configMap[field.label] = { ...defaultConfig };
19
+ } else {
20
+ configMap[field.label] = {
21
+ width: config.width ?? null,
22
+ visible: config.visible ?? defaultConfig.visible,
23
+ order: config.order ?? defaultConfig.order
24
+ };
25
+ }
26
+ });
27
+ };
28
+ processFields(fields);
22
29
  Object.values(configMap).sort((a, b) => a.order - b.order).forEach((item, index) => {
23
30
  item.order = index;
24
31
  });
@@ -33,6 +40,18 @@ const getFieldConfigMap = (key) => {
33
40
  return void 0;
34
41
  }
35
42
  };
43
+ const filterFields = (fields, method) => {
44
+ return fields.reduce((result, field) => {
45
+ if ("fields" in field) {
46
+ const fields2 = filterFields(field.fields, method);
47
+ if (fields2.length) result.push({ ...field, fields: fields2 });
48
+ } else if (method(field)) result.push(field);
49
+ return result;
50
+ }, []);
51
+ };
52
+ const getFirstFieldLabel = (field) => {
53
+ return "label" in field ? field.label : getFirstFieldLabel(field.fields[0]);
54
+ };
36
55
  const useFieldConfigMap = (key, fields, defaultConfigMap) => {
37
56
  const value = ref(parseFieldConfigMap(getFieldConfigMap(unref(key)), unref(fields), unref(defaultConfigMap)));
38
57
  const hasSaved = ref(localStorage.getItem(unref(key)) !== null);
@@ -40,6 +59,7 @@ const useFieldConfigMap = (key, fields, defaultConfigMap) => {
40
59
  get: () => value.value,
41
60
  set: (newValue) => {
42
61
  value.value = newValue;
62
+ hasSaved.value = true;
43
63
  localStorage.setItem(unref(key), JSON.stringify(newValue));
44
64
  }
45
65
  });
@@ -60,4 +80,4 @@ const useFieldConfigMap = (key, fields, defaultConfigMap) => {
60
80
  };
61
81
  };
62
82
 
63
- export { useFieldConfigMap };
83
+ export { filterFields, getFirstFieldLabel, useFieldConfigMap };
@@ -1,4 +1,4 @@
1
- import { FieldConfigMap, ListField } from '../components/List/types';
1
+ import { FieldConfigMap, GetFieldLabels, ListFields } from '../components/List/types';
2
2
  export declare const getScrollParent: (node: Element) => Element | null;
3
3
  export declare const getAllScrollParents: (node?: Element, max?: number) => Array<Element>;
4
4
  export declare const hasParent: (parent: Element, current: Element) => boolean;
@@ -19,6 +19,6 @@ export declare const isIndex: (value: unknown) => value is number;
19
19
  export declare const parseIndex: (value: unknown) => number;
20
20
  export declare const get: <FieldType, Data extends Record<string, unknown>>(data: Data, path: keyof ObjectPaths<Data, FieldType>) => FieldType | undefined;
21
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>;
22
+ export declare const getDefaultFieldConfigMap: <Fields extends ListFields<any, any>>(fields: Fields, visible: GetFieldLabels<Fields>[]) => FieldConfigMap<Fields>;
23
23
  export {};
24
24
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,cAAc,EAAE,SAAS,EAAC,MAAM,yBAAyB,CAAA;AAYnF,eAAO,MAAM,eAAe,SAAU,OAAO,KAAG,OAAO,GAAG,IAKhD,CAAA;AAEV,eAAO,MAAM,mBAAmB,UAAW,OAAO,mBAAa,KAAK,CAAC,OAAO,CAa3E,CAAA;AAED,eAAO,MAAM,SAAS,WAAY,OAAO,WAAW,OAAO,KAAG,OAI7D,CAAA;AAGD,KAAK,UAAU,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;AAE1C,wBAAgB,QAAQ,CAAC,CAAC,SAAS,UAAU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A;AACpF,eAAO,MAAM,eAAe,mBAA0B,CAAA;AAEtD,eAAO,MAAM,YAAY,EAAE,OAAuC,CAAA;AAIlE,eAAO,MAAM,KAAK,cAEjB,CAAA;AAED,eAAO,MAAM,IAAI,UAAW,OAAO,KAAG,KAAK,IAAI,MAE9C,CAAA;AAED,eAAO,MAAM,OAAO,UAAW,OAAO,KAAG,MAUxC,CAAA;AAED,eAAO,MAAM,MAAM,UAAW,OAAO,KAAG,KAAK,IAAI,MAAqB,CAAA;AAEtE,eAAO,MAAM,OAAO,UAAW,OAAO,KAAG,KAAK,IAAI,MAEjD,CAAA;AAED,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,MAU3C,CAAA;AAED,eAAO,MAAM,GAAG,GAAI,SAAS,EAAE,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,IAAI,QAAQ,MAAM,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,KAAG,SAAS,GAAG,SAA8H,CAAA;AAEtQ,eAAO,MAAM,GAAG,GAAI,SAAS,EAAE,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,IAAI,QAAQ,MAAM,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,SAAS,KAAG,IAe7I,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,MAAM,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,UAAU,MAAM,WAAW,cAAc,CAAC,MAAM,CAAC,EAAE,KAAG,cAAc,CAAC,MAAM,CAiBtJ,CAAA"}
@@ -95,10 +95,17 @@ const set = (data, path, value) => {
95
95
  return data;
96
96
  };
97
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
- }, {});
98
+ const result = {};
99
+ let order = 0;
100
+ const processFields = (fieldList) => {
101
+ fieldList.forEach((field) => {
102
+ if ("fields" in field) processFields(field.fields);
103
+ else result[field.label] = { width: null, visible: visible.includes(field.label), order };
104
+ order++;
105
+ });
106
+ };
107
+ processFields(fields);
108
+ return result;
102
109
  };
103
110
 
104
111
  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.23",
7
+ "version": "0.8.24",
8
8
  "scripts": {
9
9
  "dev": "vite",
10
10
  "build": "run-p type-check build-only",
@@ -119,6 +119,8 @@ module.exports = plugin(function ({matchUtilities, addVariant, addUtilities, add
119
119
  addVariant('touch-not', '.touch-not &')
120
120
  addVariant('focus-within-not', '&:not(:focus-within)')
121
121
  addVariant('resizer', '&::-webkit-resizer')
122
+ addVariant('last-not', '&:not(:last-child)')
123
+ addVariant('first-not', '&:not(:first-child)')
122
124
 
123
125
  addBase({
124
126
  '.w-input': {