sprintify-ui 0.6.82 → 0.6.84

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.
@@ -19,7 +19,6 @@ declare const _default: import("vue").DefineComponent<{
19
19
  data: import("@/types/index.js").Row[];
20
20
  visibleColumns: number[];
21
21
  checkboxPosition: "right" | "left";
22
- rowKey: string;
23
22
  detailTransition: string;
24
23
  }> & Omit<{
25
24
  readonly size: "xs" | "sm" | "md";
@@ -33,7 +32,6 @@ declare const _default: import("vue").DefineComponent<{
33
32
  readonly isRowCheckable: Function;
34
33
  readonly data: import("@/types/index.js").Row[];
35
34
  readonly checkboxPosition: "right" | "left";
36
- readonly rowKey: string;
37
35
  readonly detailTransition: string;
38
36
  readonly maxHeight?: number | undefined;
39
37
  readonly visibleColumns?: number[] | undefined;
@@ -90,10 +88,6 @@ declare const _default: import("vue").DefineComponent<{
90
88
  type: FunctionConstructor;
91
89
  default: () => boolean;
92
90
  };
93
- rowKey: {
94
- type: StringConstructor;
95
- default: string;
96
- };
97
91
  detailTransition: {
98
92
  type: StringConstructor;
99
93
  default: string;
@@ -115,7 +109,7 @@ declare const _default: import("vue").DefineComponent<{
115
109
  "onDetails-open"?: ((...args: any[]) => any) | undefined;
116
110
  "onDetails-close"?: ((...args: any[]) => any) | undefined;
117
111
  "onUpdate:openedDetailed"?: ((...args: any[]) => any) | undefined;
118
- }, "size" | "loading" | "sortField" | "sortDirection" | "detailed" | "hasDetailedVisible" | "checkable" | "checkedRows" | "isRowCheckable" | "maxHeight" | "data" | "visibleColumns" | "checkboxPosition" | "rowKey" | "detailTransition">;
112
+ }, "size" | "loading" | "sortField" | "sortDirection" | "detailed" | "hasDetailedVisible" | "checkable" | "checkedRows" | "isRowCheckable" | "maxHeight" | "data" | "visibleColumns" | "checkboxPosition" | "detailTransition">;
119
113
  $attrs: {
120
114
  [x: string]: unknown;
121
115
  };
@@ -174,10 +168,6 @@ declare const _default: import("vue").DefineComponent<{
174
168
  type: FunctionConstructor;
175
169
  default: () => boolean;
176
170
  };
177
- rowKey: {
178
- type: StringConstructor;
179
- default: string;
180
- };
181
171
  detailTransition: {
182
172
  type: StringConstructor;
183
173
  default: string;
@@ -245,7 +235,6 @@ declare const _default: import("vue").DefineComponent<{
245
235
  data: import("@/types/index.js").Row[];
246
236
  visibleColumns: number[];
247
237
  checkboxPosition: "right" | "left";
248
- rowKey: string;
249
238
  detailTransition: string;
250
239
  }, {}, string, {}> & {
251
240
  beforeCreate?: ((() => void) | (() => void)[]) | undefined;
@@ -312,10 +301,6 @@ declare const _default: import("vue").DefineComponent<{
312
301
  type: FunctionConstructor;
313
302
  default: () => boolean;
314
303
  };
315
- rowKey: {
316
- type: StringConstructor;
317
- default: string;
318
- };
319
304
  detailTransition: {
320
305
  type: StringConstructor;
321
306
  default: string;
@@ -398,7 +383,6 @@ declare const _default: import("vue").DefineComponent<{
398
383
  data: import("@/types/index.js").Row[];
399
384
  visibleColumns: number[];
400
385
  checkboxPosition: "right" | "left";
401
- rowKey: string;
402
386
  detailTransition: string;
403
387
  }> & Omit<{
404
388
  readonly size: "xs" | "sm" | "md";
@@ -412,7 +396,6 @@ declare const _default: import("vue").DefineComponent<{
412
396
  readonly isRowCheckable: Function;
413
397
  readonly data: import("@/types/index.js").Row[];
414
398
  readonly checkboxPosition: "right" | "left";
415
- readonly rowKey: string;
416
399
  readonly detailTransition: string;
417
400
  readonly maxHeight?: number | undefined;
418
401
  readonly visibleColumns?: number[] | undefined;
@@ -469,10 +452,6 @@ declare const _default: import("vue").DefineComponent<{
469
452
  type: FunctionConstructor;
470
453
  default: () => boolean;
471
454
  };
472
- rowKey: {
473
- type: StringConstructor;
474
- default: string;
475
- };
476
455
  detailTransition: {
477
456
  type: StringConstructor;
478
457
  default: string;
@@ -494,7 +473,7 @@ declare const _default: import("vue").DefineComponent<{
494
473
  "onDetails-open"?: ((...args: any[]) => any) | undefined;
495
474
  "onDetails-close"?: ((...args: any[]) => any) | undefined;
496
475
  "onUpdate:openedDetailed"?: ((...args: any[]) => any) | undefined;
497
- }, "size" | "loading" | "sortField" | "sortDirection" | "detailed" | "hasDetailedVisible" | "checkable" | "checkedRows" | "isRowCheckable" | "maxHeight" | "data" | "visibleColumns" | "checkboxPosition" | "rowKey" | "detailTransition">;
476
+ }, "size" | "loading" | "sortField" | "sortDirection" | "detailed" | "hasDetailedVisible" | "checkable" | "checkedRows" | "isRowCheckable" | "maxHeight" | "data" | "visibleColumns" | "checkboxPosition" | "detailTransition">;
498
477
  $attrs: {
499
478
  [x: string]: unknown;
500
479
  };
@@ -553,10 +532,6 @@ declare const _default: import("vue").DefineComponent<{
553
532
  type: FunctionConstructor;
554
533
  default: () => boolean;
555
534
  };
556
- rowKey: {
557
- type: StringConstructor;
558
- default: string;
559
- };
560
535
  detailTransition: {
561
536
  type: StringConstructor;
562
537
  default: string;
@@ -624,7 +599,6 @@ declare const _default: import("vue").DefineComponent<{
624
599
  data: import("@/types/index.js").Row[];
625
600
  visibleColumns: number[];
626
601
  checkboxPosition: "right" | "left";
627
- rowKey: string;
628
602
  detailTransition: string;
629
603
  }, {}, string, {}> & {
630
604
  beforeCreate?: ((() => void) | (() => void)[]) | undefined;
@@ -691,10 +665,6 @@ declare const _default: import("vue").DefineComponent<{
691
665
  type: FunctionConstructor;
692
666
  default: () => boolean;
693
667
  };
694
- rowKey: {
695
- type: StringConstructor;
696
- default: string;
697
- };
698
668
  detailTransition: {
699
669
  type: StringConstructor;
700
670
  default: string;
@@ -1,5 +1,10 @@
1
1
  import { PropType } from 'vue';
2
2
  import { BaseTableColumn, Row } from '@/types';
3
+ /**
4
+ * Remove all rows in current page.
5
+ */
6
+ declare function uncheckAll(): void;
7
+ declare function scrollTop(): void;
3
8
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
4
9
  /** Table data */
5
10
  data: {
@@ -61,11 +66,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
61
66
  type: FunctionConstructor;
62
67
  default: () => boolean;
63
68
  };
64
- /** Use a unique key of your data Object when use detailed or opened detailed. (id recommended) */
65
- rowKey: {
66
- type: StringConstructor;
67
- default: string;
68
- };
69
69
  detailTransition: {
70
70
  type: StringConstructor;
71
71
  default: string;
@@ -99,8 +99,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
99
99
  thAttrs: (column: BaseTableColumn) => Record<string, any>;
100
100
  tdAttrs: (row: Row, column: BaseTableColumn) => Record<string, any>;
101
101
  }[]>;
102
- uncheckAll: () => void;
103
- scrollTop: () => void;
102
+ uncheckAll: typeof uncheckAll;
103
+ scrollTop: typeof scrollTop;
104
104
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
105
105
  sort: (...args: any[]) => void;
106
106
  check: (...args: any[]) => void;
@@ -171,11 +171,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
171
171
  type: FunctionConstructor;
172
172
  default: () => boolean;
173
173
  };
174
- /** Use a unique key of your data Object when use detailed or opened detailed. (id recommended) */
175
- rowKey: {
176
- type: StringConstructor;
177
- default: string;
178
- };
179
174
  detailTransition: {
180
175
  type: StringConstructor;
181
176
  default: string;
@@ -211,7 +206,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
211
206
  data: Row[];
212
207
  visibleColumns: number[];
213
208
  checkboxPosition: "right" | "left";
214
- rowKey: string;
215
209
  detailTransition: string;
216
210
  }, {}>, {
217
211
  default?(_: {}): any;
@@ -0,0 +1,43 @@
1
+ import { Size } from '@/utils/sizes';
2
+ import { JsonData } from '@/types';
3
+ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<{
4
+ modelValue: JsonData;
5
+ size?: "xs" | "sm" | "md" | undefined;
6
+ variant?: "list" | "collapse" | undefined;
7
+ class?: string | string[] | undefined;
8
+ }>, {
9
+ size: string;
10
+ variant: string;
11
+ class: undefined;
12
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
13
+ modelValue: JsonData;
14
+ size?: "xs" | "sm" | "md" | undefined;
15
+ variant?: "list" | "collapse" | undefined;
16
+ class?: string | string[] | undefined;
17
+ }>, {
18
+ size: string;
19
+ variant: string;
20
+ class: undefined;
21
+ }>>>, {
22
+ class: string | string[];
23
+ size: Size;
24
+ variant: 'list' | 'collapse';
25
+ }, {}>;
26
+ export default _default;
27
+ type __VLS_WithDefaults<P, D> = {
28
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
29
+ default: D[K];
30
+ }> : P[K];
31
+ };
32
+ type __VLS_Prettify<T> = {
33
+ [K in keyof T]: T[K];
34
+ } & {};
35
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
36
+ type __VLS_TypePropsToOption<T> = {
37
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
38
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
39
+ } : {
40
+ type: import('vue').PropType<T[K]>;
41
+ required: true;
42
+ };
43
+ };
@@ -0,0 +1,25 @@
1
+ import { JsonDataItem } from '@/types';
2
+ import { Size } from '@/utils/sizes';
3
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
4
+ modelValue: JsonDataItem;
5
+ label: string | number;
6
+ size: Size;
7
+ class?: string | string[] | undefined;
8
+ variant: 'list' | 'collapse';
9
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<{
10
+ modelValue: JsonDataItem;
11
+ label: string | number;
12
+ size: Size;
13
+ class?: string | string[] | undefined;
14
+ variant: 'list' | 'collapse';
15
+ }>>>, {}, {}>;
16
+ export default _default;
17
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
18
+ type __VLS_TypePropsToOption<T> = {
19
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
20
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
21
+ } : {
22
+ type: import('vue').PropType<T[K]>;
23
+ required: true;
24
+ };
25
+ };
@@ -220,3 +220,7 @@ export interface TimelineItem {
220
220
  onEdit?: () => void | Promise<void>;
221
221
  onDelete?: () => void | Promise<void>;
222
222
  }
223
+ export type JsonDataItem = string | number | null | undefined | JsonData[] | JsonData;
224
+ export interface JsonData {
225
+ [key: string]: JsonDataItem;
226
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.6.82",
3
+ "version": "0.6.84",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -125,7 +125,7 @@
125
125
  <tbody class="bg-white">
126
126
  <template
127
127
  v-for="(row, index) in data"
128
- :key="getRowIndex(row, index)"
128
+ :key="getRowKey(row)"
129
129
  >
130
130
  <tr class="item-row">
131
131
  <td
@@ -220,7 +220,7 @@
220
220
  <transition :name="detailTransition">
221
221
  <tr
222
222
  v-if="isActiveDetailRow(row)"
223
- :key="getRowIndex(row, index) + 'detail'"
223
+ :key="getRowKey(row) + 'detail'"
224
224
  >
225
225
  <td
226
226
  :colspan="columnCount"
@@ -272,27 +272,26 @@
272
272
  </div>
273
273
  </template>
274
274
 
275
- <script lang="ts">
276
- export default {
277
- name: 'BaseDataTableTemplate',
278
- inheritAttrs: false,
279
- };
280
- </script>
281
-
282
275
  <script lang="ts" setup>
283
- import { PropType, ref } from 'vue';
276
+ import { PropType, StyleValue, ref } from 'vue';
284
277
  import { BaseTableColumn, Row } from '@/types';
285
278
  import SlotComponent from './SlotComponent';
286
279
  import { useResizeObserver, useScroll } from '@vueuse/core';
287
280
  import { debounce, isArray } from 'lodash';
288
281
  import BaseSpinnerLarge from '../svg/BaseSpinnerLarge.vue';
289
282
  import { Size } from '@/utils/sizes';
283
+ import objectHash from 'object-hash';
290
284
 
291
285
  const checkboxStyle =
292
286
  'disabled:bg-slate-100 group-hover:shadow-md disabled:border-slate-300 disabled:cursor-not-allowed duration-300 cursor-pointer focus:ring-blue-300 border border-slate-300 shadow h-[18px] w-[18px] rounded';
293
287
  const DETAIL_ROW_WIDTH = 36;
294
288
  const CHECK_ROW_WIDTH = 36;
295
289
 
290
+ defineOptions({
291
+ name: 'BaseDataTableTemplate',
292
+ inheritAttrs: false,
293
+ });
294
+
296
295
  provide('table', getCurrentInstance());
297
296
 
298
297
  const props = defineProps({
@@ -356,11 +355,6 @@ const props = defineProps({
356
355
  type: Function,
357
356
  default: () => true,
358
357
  },
359
- /** Use a unique key of your data Object when use detailed or opened detailed. (id recommended) */
360
- rowKey: {
361
- type: String,
362
- default: 'id',
363
- },
364
358
  /* Transition name to use when toggling row details. */
365
359
  detailTransition: {
366
360
  type: String,
@@ -388,7 +382,7 @@ const emit = defineEmits([
388
382
  'cell-click',
389
383
  ]);
390
384
 
391
- const visibleDetailRows = ref<Row[]>([]);
385
+ const visibleDetailRows = ref<string[]>([]);
392
386
  // eslint-disable-next-line vue/no-setup-props-destructure
393
387
  const newCheckedRows = ref<Row[]>([...props.checkedRows]);
394
388
  const lastCheckedRowIndex = ref<number | null>(null);
@@ -521,10 +515,13 @@ function sort(column: BaseTableColumn, updatingData = false, event = null) {
521
515
  * Check if the row is checked (is added to the array).
522
516
  */
523
517
  function isRowChecked(row: Row): boolean {
524
- return (
525
- newCheckedRows.value.find((r) => r[props.rowKey] == row[props.rowKey]) !==
526
- undefined
527
- );
518
+ const found = newCheckedRows.value.find((r) => {
519
+ const key1 = getRowKey(r);
520
+ const key2 = getRowKey(row);
521
+ return key1 == key2
522
+ });
523
+
524
+ return found !== undefined;
528
525
  }
529
526
 
530
527
  /**
@@ -555,9 +552,13 @@ const isAllChecked = computed(() => {
555
552
  });
556
553
 
557
554
  function getCheckedRowIndex(row: Row) {
558
- return newCheckedRows.value.findIndex(
559
- (r) => r[props.rowKey] == row[props.rowKey]
560
- );
555
+ const foundIndex = newCheckedRows.value.findIndex((r) => {
556
+ const key1 = getRowKey(r);
557
+ const key2 = getRowKey(row);
558
+ return key1 == key2
559
+ });
560
+
561
+ return foundIndex;
561
562
  }
562
563
 
563
564
  /**
@@ -668,36 +669,27 @@ function toggleDetails(row: Row) {
668
669
  }
669
670
 
670
671
  function openDetailRow(row: Row) {
671
- const index = getDetailedIndex(row);
672
- visibleDetailRows.value.push(index);
672
+ const key = getRowKey(row);
673
+ visibleDetailRows.value.push(key);
673
674
  }
674
675
 
675
676
  function closeDetailRow(row: Row) {
676
- const index = getDetailedIndex(row);
677
- const i = visibleDetailRows.value.indexOf(index);
677
+ const key = getRowKey(row);
678
+ const i = visibleDetailRows.value.indexOf(key);
678
679
  if (i >= 0) {
679
680
  visibleDetailRows.value.splice(i, 1);
680
681
  }
681
682
  }
682
683
 
683
684
  function isVisibleDetailRow(row: Row) {
684
- const index = getDetailedIndex(row);
685
- return visibleDetailRows.value.indexOf(index) >= 0;
685
+ const key = getRowKey(row);
686
+ return visibleDetailRows.value.indexOf(key) >= 0;
686
687
  }
687
688
 
688
689
  function isActiveDetailRow(row: Row) {
689
690
  return props.detailed && isVisibleDetailRow(row);
690
691
  }
691
692
 
692
- /**
693
- * When the rowKey is defined we use the object[rowKey] as index.
694
- * If not, use the object reference by default.
695
- */
696
- function getDetailedIndex(row: Row) {
697
- const key = props.rowKey;
698
- return !key.length || !row ? row : row[key];
699
- }
700
-
701
693
  /**
702
694
  * Update sort state
703
695
  */
@@ -759,7 +751,7 @@ function removeColumn(column: BaseTableColumn) {
759
751
 
760
752
  const borderClasses = 'border-b border-slate-200';
761
753
 
762
- function borderBottomClasses(index: number, row: Record<string, any>): string {
754
+ function borderBottomClasses(index: number, row: Row): string {
763
755
  if (index < props.data.length - 1) {
764
756
  return borderClasses;
765
757
  }
@@ -795,7 +787,7 @@ function nextSequence() {
795
787
  return sequence.value++;
796
788
  }
797
789
 
798
- function getRowIndex(row: Row, index: number): string {
790
+ function getRowKey(row: Row): string {
799
791
  if (row.id) {
800
792
  return row.id;
801
793
  }
@@ -805,7 +797,7 @@ function getRowIndex(row: Row, index: number): string {
805
797
  if (row.uuid) {
806
798
  return row.uuid;
807
799
  }
808
- return index + '';
800
+ return objectHash(row);
809
801
  }
810
802
 
811
803
  // Sticky styles
@@ -825,7 +817,7 @@ function zIndex(th: boolean) {
825
817
  return 1;
826
818
  }
827
819
 
828
- function detailsStyles(th: boolean): any {
820
+ function detailsStyles(th: boolean): StyleValue {
829
821
  if (props.detailed) {
830
822
  return {
831
823
  zIndex: zIndex(th) + 1,
@@ -839,7 +831,7 @@ function detailsStyles(th: boolean): any {
839
831
  return {};
840
832
  }
841
833
 
842
- function checkStyles(th: boolean): any {
834
+ function checkStyles(th: boolean): StyleValue {
843
835
  if (props.checkable) {
844
836
  return {
845
837
  zIndex: zIndex(th) + 1,
@@ -853,7 +845,7 @@ function checkStyles(th: boolean): any {
853
845
  return {};
854
846
  }
855
847
 
856
- function firstColStyles(th: boolean): any {
848
+ function firstColStyles(th: boolean): StyleValue {
857
849
  let left = 0;
858
850
  if (props.checkable) {
859
851
  left += CHECK_ROW_WIDTH;
@@ -0,0 +1,128 @@
1
+ import BaseJsonReader from './BaseJsonReader.vue';
2
+ import ShowValue from '@/../.storybook/components/ShowValue.vue';
3
+
4
+ const sizes = ['xs', 'sm', 'md'];
5
+
6
+ export default {
7
+ title: 'Components/BaseJsonReader',
8
+ component: BaseJsonReader,
9
+ argTypes: {
10
+ size: {
11
+ control: { type: 'select' },
12
+ options: sizes,
13
+ }
14
+ },
15
+ };
16
+
17
+ const Template = (args) => ({
18
+ components: { BaseJsonReader, ShowValue },
19
+ setup() {
20
+ const object = {
21
+ "user": {
22
+ "name": "John Doe",
23
+ "email": "john@witify.io",
24
+ "permissions": [
25
+ "read",
26
+ "create",
27
+ "delete"
28
+ ],
29
+ comments: [
30
+ {
31
+ comment: "First comment",
32
+ replies: [
33
+ {
34
+ comment: "sub-comment 1 for comment 1",
35
+ replies: [
36
+ {
37
+ comment: "sub-sub-comment 1",
38
+ replies: [
39
+ {
40
+ comment: "sub-sub-sub-comment 1",
41
+ },
42
+ {
43
+ comment: {
44
+ name: "sub-sub-sub-comment 2",
45
+ desc: "test desc"
46
+ }
47
+ },
48
+ {
49
+ comment: {
50
+ name: "sub-sub-sub-comment 3",
51
+ desc: "test desc2"
52
+ }
53
+ },
54
+ ],
55
+ },
56
+ { comment: "sub-sub-comment 2" },
57
+ ],
58
+ },
59
+ { comment: "sub-comment 2 for comment 1" },
60
+ ],
61
+ },
62
+
63
+ {
64
+ comment: "Second comment",
65
+ replies: [
66
+ {
67
+ comment: "sub-comment 1 for comment 2",
68
+ replies: [
69
+ { comment: "sub-sub-comment 1" },
70
+ { comment: "sub-sub-comment 2" },
71
+ ],
72
+ },
73
+ { comment: "sub-comment 2 for comment 2" },
74
+ ],
75
+ },
76
+ ],
77
+ "category": {
78
+ "id": 1,
79
+ "name": "Other"
80
+ },
81
+ "tags": {
82
+ "id": [
83
+ "create",
84
+ "delete"
85
+ ],
86
+ "name": {
87
+ "id": {
88
+ "read": {
89
+ "id": {
90
+ "create": {
91
+ "id": {
92
+ "delete": {
93
+ "id": {
94
+ "update": {
95
+ "id": {
96
+ "name": "Read"
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
105
+ },
106
+ "name": "Read"
107
+ },
108
+ }
109
+ },
110
+ "foo": "bar",
111
+ };
112
+
113
+ const value = ref(object);
114
+ return { value, args };
115
+ },
116
+ template: `
117
+ <BaseJsonReader v-model="value" v-bind="args" class="bg-red-50 border p-5 text-red-900 rounded-none">
118
+ </BaseJsonReader>
119
+ <ShowValue :value="value" />
120
+ `,
121
+ });
122
+
123
+ export const Demo = Template.bind({});
124
+
125
+ export const VariantCollapse = Template.bind({});
126
+ VariantCollapse.args = {
127
+ variant: 'collapse',
128
+ };
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <div
3
+ :class="classes"
4
+ >
5
+ <ul>
6
+ <BaseJsonReaderItem
7
+ v-for="(value, key) in modelValue"
8
+ :key="key"
9
+ :size="size"
10
+ :label="key"
11
+ :variant="variant"
12
+ :model-value="value"
13
+ />
14
+ </ul>
15
+ </div>
16
+ </template>
17
+
18
+ <script lang="ts" setup>
19
+ import { Size, sizes } from '@/utils/sizes';
20
+ import { twMerge } from 'tailwind-merge';
21
+ import { defineProps } from 'vue';
22
+ import BaseJsonReaderItem from './BaseJsonReaderItem.vue';
23
+ import { JsonData } from '@/types';
24
+
25
+ defineOptions({
26
+ inheritAttrs: false,
27
+ })
28
+
29
+ const props = withDefaults(
30
+ defineProps<{
31
+ modelValue: JsonData;
32
+ size?: Size;
33
+ variant?: 'list' | 'collapse';
34
+ class?: string | string[];
35
+ }>(),
36
+ {
37
+ size: 'sm',
38
+ variant: 'list',
39
+ class: undefined,
40
+ }
41
+ );
42
+
43
+ const classes = computed(() => {
44
+ const base = 'bg-slate-100 p-2 rounded-md text-sm text-slate-800';
45
+ const sizeConfig = sizes[props.size];
46
+
47
+ return twMerge(
48
+ base,
49
+ sizeConfig.fontSize,
50
+ props.class,
51
+ );
52
+ });
53
+ </script>