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.
- package/dist/sprintify-ui.es.js +8375 -8383
- package/dist/types/components/BaseDataIteratorSectionColumns.vue.d.ts +2 -32
- package/dist/types/components/BaseDataTableTemplate.vue.d.ts +7 -13
- package/dist/types/components/BaseJsonReader.vue.d.ts +43 -0
- package/dist/types/components/BaseJsonReaderItem.vue.d.ts +25 -0
- package/dist/types/types/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/components/BaseDataTableTemplate.vue +36 -44
- package/src/components/BaseJsonReader.stories.js +128 -0
- package/src/components/BaseJsonReader.vue +53 -0
- package/src/components/BaseJsonReaderItem.vue +112 -0
- package/src/components/BaseScrollColumn.vue +0 -2
- package/src/components/BaseTimePicker.vue +0 -3
- package/src/types/index.ts +6 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<li>
|
|
3
|
+
<p class="flex items-center gap-1">
|
|
4
|
+
<button
|
|
5
|
+
v-if="variant == 'collapse'"
|
|
6
|
+
type="button"
|
|
7
|
+
class="duration-200 transform"
|
|
8
|
+
:class="[isPrimitive ? 'opacity-0 cursor-default' : '', visible ? 'rotate-0' : '-rotate-90']"
|
|
9
|
+
@click="toggle"
|
|
10
|
+
>
|
|
11
|
+
<BaseIcon
|
|
12
|
+
:class="classSizeChevron"
|
|
13
|
+
icon="ion:caret-down"
|
|
14
|
+
/>
|
|
15
|
+
</button>
|
|
16
|
+
<span :class="[typeof label == 'number' ? '' : 'font-semibold']">
|
|
17
|
+
{{ label }}
|
|
18
|
+
</span>
|
|
19
|
+
|
|
20
|
+
<span
|
|
21
|
+
v-if="isPrimitive"
|
|
22
|
+
class="font-semibold"
|
|
23
|
+
>:</span>
|
|
24
|
+
|
|
25
|
+
<span v-if="isPrimitive">
|
|
26
|
+
{{ modelValue }}
|
|
27
|
+
</span>
|
|
28
|
+
<span
|
|
29
|
+
v-else
|
|
30
|
+
class="opacity-50"
|
|
31
|
+
>{<template v-if="true">{{ count }}</template>}</span>
|
|
32
|
+
</p>
|
|
33
|
+
<ul
|
|
34
|
+
v-show="visible"
|
|
35
|
+
v-if="isIterable"
|
|
36
|
+
class="pl-3"
|
|
37
|
+
>
|
|
38
|
+
<BaseJsonReaderItem
|
|
39
|
+
v-for="(value, key) in modelValue"
|
|
40
|
+
:key="key"
|
|
41
|
+
:label="key"
|
|
42
|
+
:model-value="value"
|
|
43
|
+
:size="size"
|
|
44
|
+
:variant="variant"
|
|
45
|
+
/>
|
|
46
|
+
</ul>
|
|
47
|
+
</li>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script lang="ts" setup>
|
|
51
|
+
import { JsonDataItem } from '@/types';
|
|
52
|
+
import { Size } from '@/utils/sizes';
|
|
53
|
+
import { isBoolean, isNull, isNumber, isString, isArray, isObject } from 'lodash';
|
|
54
|
+
|
|
55
|
+
const props = defineProps<{
|
|
56
|
+
modelValue: JsonDataItem;
|
|
57
|
+
label: string | number;
|
|
58
|
+
size: Size;
|
|
59
|
+
class?: string | string[];
|
|
60
|
+
variant: 'list' | 'collapse';
|
|
61
|
+
}>();
|
|
62
|
+
|
|
63
|
+
const visible = ref(true);
|
|
64
|
+
|
|
65
|
+
function toggle() {
|
|
66
|
+
visible.value = !visible.value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const count = computed(() => {
|
|
70
|
+
if (isArray(props.modelValue)) {
|
|
71
|
+
return props.modelValue.length;
|
|
72
|
+
}
|
|
73
|
+
if (isObject(props.modelValue)) {
|
|
74
|
+
return Object.keys(props.modelValue).length;
|
|
75
|
+
}
|
|
76
|
+
return 0;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const isPrimitive = computed(() => {
|
|
80
|
+
return isString(props.modelValue) || isNumber(props.modelValue) || isBoolean(props.modelValue) || isNull(props.modelValue) || isNumber(props.modelValue);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const isIterable = computed(() => {
|
|
84
|
+
if (isPrimitive.value) return false;
|
|
85
|
+
return isArray(props.modelValue) || isObject(props.modelValue);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const classSizeChevron = computed(() => {
|
|
89
|
+
const chevronSizes = {
|
|
90
|
+
xs: {
|
|
91
|
+
width: 'w-2.5',
|
|
92
|
+
height: 'h-2.5',
|
|
93
|
+
},
|
|
94
|
+
sm: {
|
|
95
|
+
width: 'w-3',
|
|
96
|
+
height: 'h-3',
|
|
97
|
+
},
|
|
98
|
+
md: {
|
|
99
|
+
width: 'w-3.5',
|
|
100
|
+
height: 'h-3.5',
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const sizeConfig = chevronSizes[props.size];
|
|
105
|
+
|
|
106
|
+
return [
|
|
107
|
+
sizeConfig.height,
|
|
108
|
+
sizeConfig.width,
|
|
109
|
+
];
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
</script>
|
package/src/types/index.ts
CHANGED
|
@@ -268,3 +268,9 @@ export interface TimelineItem {
|
|
|
268
268
|
onEdit?: () => void | Promise<void>;
|
|
269
269
|
onDelete?: () => void | Promise<void>;
|
|
270
270
|
}
|
|
271
|
+
|
|
272
|
+
export type JsonDataItem = string | number | null | undefined | JsonData[] | JsonData;
|
|
273
|
+
|
|
274
|
+
export interface JsonData {
|
|
275
|
+
[key: string]: JsonDataItem;
|
|
276
|
+
}
|