adminforth 1.6.2-next.3 → 1.6.2-next.4
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/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/spa/.eslintrc.cjs +14 -0
- package/dist/spa/README.md +39 -0
- package/dist/spa/env.d.ts +1 -0
- package/dist/spa/index.html +23 -0
- package/dist/spa/package-lock.json +5062 -0
- package/dist/spa/package.json +58 -0
- package/dist/spa/postcss.config.js +6 -0
- package/dist/spa/public/assets/favicon.png +0 -0
- package/dist/spa/src/App.vue +432 -0
- package/dist/spa/src/adminforth.ts +160 -0
- package/dist/spa/src/afcl/AreaChart.vue +160 -0
- package/dist/spa/src/afcl/BarChart.vue +170 -0
- package/dist/spa/src/afcl/Button.vue +27 -0
- package/dist/spa/src/afcl/Checkbox.vue +24 -0
- package/dist/spa/src/afcl/Dropzone.vue +128 -0
- package/dist/spa/src/afcl/Input.vue +41 -0
- package/dist/spa/src/afcl/Link.vue +17 -0
- package/dist/spa/src/afcl/LinkButton.vue +25 -0
- package/dist/spa/src/afcl/PieChart.vue +175 -0
- package/dist/spa/src/afcl/ProgressBar.vue +57 -0
- package/dist/spa/src/afcl/Select.vue +246 -0
- package/dist/spa/src/afcl/Skeleton.vue +26 -0
- package/dist/spa/src/afcl/Spinner.vue +9 -0
- package/dist/spa/src/afcl/Table.vue +116 -0
- package/dist/spa/src/afcl/Tooltip.vue +43 -0
- package/dist/spa/src/afcl/VerticalTabs.vue +49 -0
- package/dist/spa/src/afcl/index.ts +20 -0
- package/dist/spa/src/assets/base.css +2 -0
- package/dist/spa/src/assets/logo.svg +19 -0
- package/dist/spa/src/components/AcceptModal.vue +44 -0
- package/dist/spa/src/components/Breadcrumbs.vue +41 -0
- package/dist/spa/src/components/BreadcrumbsWithButtons.vue +25 -0
- package/dist/spa/src/components/CustomDatePicker.vue +180 -0
- package/dist/spa/src/components/CustomDateRangePicker.vue +218 -0
- package/dist/spa/src/components/CustomRangePicker.vue +156 -0
- package/dist/spa/src/components/Filters.vue +232 -0
- package/dist/spa/src/components/GroupsTable.vue +218 -0
- package/dist/spa/src/components/HelloWorld.vue +17 -0
- package/dist/spa/src/components/MenuLink.vue +41 -0
- package/dist/spa/src/components/ResourceForm.vue +260 -0
- package/dist/spa/src/components/ResourceListTable.vue +486 -0
- package/dist/spa/src/components/ShowTable.vue +81 -0
- package/dist/spa/src/components/SingleSkeletLoader.vue +13 -0
- package/dist/spa/src/components/SkeleteLoader.vue +18 -0
- package/dist/spa/src/components/ThreeDotsMenu.vue +43 -0
- package/dist/spa/src/components/Toast.vue +78 -0
- package/dist/spa/src/components/ValueRenderer.vue +141 -0
- package/dist/spa/src/components/icons/IconCalendar.vue +5 -0
- package/dist/spa/src/components/icons/IconCommunity.vue +7 -0
- package/dist/spa/src/components/icons/IconDocumentation.vue +7 -0
- package/dist/spa/src/components/icons/IconEcosystem.vue +7 -0
- package/dist/spa/src/components/icons/IconSupport.vue +7 -0
- package/dist/spa/src/components/icons/IconTime.vue +5 -0
- package/dist/spa/src/components/icons/IconTooling.vue +19 -0
- package/dist/spa/src/composables/useFrontendApi.ts +28 -0
- package/dist/spa/src/i18n.ts +54 -0
- package/dist/spa/src/index.scss +34 -0
- package/dist/spa/src/main.ts +22 -0
- package/dist/spa/src/renderers/CompactField.vue +46 -0
- package/dist/spa/src/renderers/CompactUUID.vue +46 -0
- package/dist/spa/src/renderers/CountryFlag.vue +65 -0
- package/dist/spa/src/renderers/HumanNumber.vue +58 -0
- package/dist/spa/src/renderers/RelativeTime.vue +42 -0
- package/dist/spa/src/renderers/URL.vue +18 -0
- package/dist/spa/src/router/index.ts +70 -0
- package/dist/spa/src/spa_types/core.ts +51 -0
- package/dist/spa/src/stores/core.ts +228 -0
- package/dist/spa/src/stores/filters.ts +27 -0
- package/dist/spa/src/stores/modal.ts +48 -0
- package/dist/spa/src/stores/toast.ts +30 -0
- package/dist/spa/src/stores/user.ts +79 -0
- package/dist/spa/src/types/Adapters.ts +26 -0
- package/dist/spa/src/types/Back.ts +1344 -0
- package/dist/spa/src/types/Common.ts +940 -0
- package/dist/spa/src/types/FrontendAPI.ts +189 -0
- package/dist/spa/src/utils.ts +184 -0
- package/dist/spa/src/views/CreateView.vue +167 -0
- package/dist/spa/src/views/EditView.vue +171 -0
- package/dist/spa/src/views/ListView.vue +442 -0
- package/dist/spa/src/views/LoginView.vue +199 -0
- package/dist/spa/src/views/PageNotFound.vue +20 -0
- package/dist/spa/src/views/ResourceParent.vue +50 -0
- package/dist/spa/src/views/ShowView.vue +209 -0
- package/dist/spa/src/websocket.ts +129 -0
- package/dist/spa/tailwind.config.js +19 -0
- package/dist/spa/tsconfig.app.json +14 -0
- package/dist/spa/tsconfig.json +11 -0
- package/dist/spa/tsconfig.node.json +19 -0
- package/dist/spa/vite.config.ts +52 -0
- package/package.json +1 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="-mb-2" ref="chart"></div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import ApexCharts, { type ApexOptions } from 'apexcharts';
|
|
7
|
+
import { ref, type Ref, watch, computed, onUnmounted } from 'vue';
|
|
8
|
+
|
|
9
|
+
const chart: Ref<HTMLDivElement | null> = ref(null);
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
data: {
|
|
13
|
+
label: string,
|
|
14
|
+
amount: number,
|
|
15
|
+
color?: string,
|
|
16
|
+
[key: string]: any,
|
|
17
|
+
}[],
|
|
18
|
+
options?: ApexOptions,
|
|
19
|
+
}>();
|
|
20
|
+
|
|
21
|
+
const SUGGESTED_COLORS = [
|
|
22
|
+
"#4E79A7", "#F28E2B", "#E15759", "#76B7B2", "#59A14F", "#EDC949", "#B07AA1", "#FF9DA6", "#9C755F", "#BAB0AC",
|
|
23
|
+
"#2B8A86", "#CC4D58", "#F7941D", "#F9C232", "#729B33", "#497288", "#16578D", "#5F4D99", "#F9F871", "#F9F871",
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// [ "#2B8A86", "#CC4D58", "#F7941D", "#F9C232", "#729B33", "#497288", "#16578D", "#5F4D99",]
|
|
28
|
+
// ["#4E79A7", "#F28E2B", "#E15759", "#76B7B2", "#59A14F"], // Professional Cool Tones
|
|
29
|
+
// ["#1F77B4", "#FF7F0E", "#2CA02C", "#D62728", "#9467BD"], // Balanced Vibrant Colors
|
|
30
|
+
// ["#6A4C93", "#1982C4", "#8AC926", "#FF595E", "#FFCA3A"], // Bold and Distinct
|
|
31
|
+
// ["#0077B6", "#0096C7", "#00B4D8", "#90E0EF", "#CAF0F8"], // Ocean Blues
|
|
32
|
+
// ["#3A0CA3", "#7209B7", "#F72585", "#4361EE", "#4CC9F0"], // Vivid Purples and Blues
|
|
33
|
+
// ["#FF9F1C", "#FFBF69", "#CBF3F0", "#2EC4B6", "#011627"], // Warm and Cool Mix
|
|
34
|
+
// ["#8338EC", "#3A86FF", "#FB5607", "#FF006E", "#FFBE0B"], // Fun and Playful
|
|
35
|
+
// ["#F94144", "#F3722C", "#F8961E", "#F9844A", "#F9C74F"], // Warm Gradient
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const optionsBase = {
|
|
39
|
+
series: [],
|
|
40
|
+
colors: [],
|
|
41
|
+
labels: [],
|
|
42
|
+
chart: {
|
|
43
|
+
height: 400,
|
|
44
|
+
width: "100%",
|
|
45
|
+
type: "pie",
|
|
46
|
+
},
|
|
47
|
+
stroke: {
|
|
48
|
+
colors: ["transparent"],
|
|
49
|
+
lineCap: "",
|
|
50
|
+
},
|
|
51
|
+
plotOptions: {
|
|
52
|
+
pie: {
|
|
53
|
+
donut: {
|
|
54
|
+
labels: {
|
|
55
|
+
show: true,
|
|
56
|
+
name: {
|
|
57
|
+
show: true,
|
|
58
|
+
fontFamily: "Inter, sans-serif",
|
|
59
|
+
offsetY: 20,
|
|
60
|
+
},
|
|
61
|
+
total: {
|
|
62
|
+
showAlways: true,
|
|
63
|
+
show: false,
|
|
64
|
+
fontFamily: "Inter, sans-serif",
|
|
65
|
+
label: "",
|
|
66
|
+
formatter: function (w) {
|
|
67
|
+
const sum = w.globals.seriesTotals.reduce((a, b) => {
|
|
68
|
+
return a + b
|
|
69
|
+
}, 0)
|
|
70
|
+
return sum
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
value: {
|
|
74
|
+
show: true,
|
|
75
|
+
fontFamily: "Inter, sans-serif",
|
|
76
|
+
offsetY: -20,
|
|
77
|
+
formatter: function (value) {
|
|
78
|
+
return value + "k"
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
size: "80%",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
grid: {
|
|
87
|
+
padding: {
|
|
88
|
+
top: 3,
|
|
89
|
+
left: 3,
|
|
90
|
+
right: 3,
|
|
91
|
+
bottom: 3,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
dataLabels: {
|
|
95
|
+
enabled: false,
|
|
96
|
+
},
|
|
97
|
+
legend: {
|
|
98
|
+
position: "bottom",
|
|
99
|
+
fontFamily: "Inter, sans-serif",
|
|
100
|
+
},
|
|
101
|
+
yaxis: {
|
|
102
|
+
labels: {
|
|
103
|
+
formatter: function (value) {
|
|
104
|
+
return value;
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
xaxis: {
|
|
109
|
+
labels: {
|
|
110
|
+
formatter: function (value) {
|
|
111
|
+
return value;
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
axisTicks: {
|
|
115
|
+
show: false,
|
|
116
|
+
},
|
|
117
|
+
axisBorder: {
|
|
118
|
+
show: false,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const options = computed(() => {
|
|
124
|
+
|
|
125
|
+
const options = {
|
|
126
|
+
...optionsBase,
|
|
127
|
+
|
|
128
|
+
// shade and gradient take from first series
|
|
129
|
+
series: props.data?.map((item) => item.amount) ?? [],
|
|
130
|
+
colors: props.data?.map((item, index) => item.color ?? SUGGESTED_COLORS[index]) ?? [],
|
|
131
|
+
labels: props.data?.map((item) => item.label) ?? [],
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// for each of ...props.options merge on lowest level. so if { chart: {height : 2} }, it should not replace chart level, only height level
|
|
135
|
+
function mergeOptions(options: any, newOptions: any) {
|
|
136
|
+
if (!newOptions) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
for (const key in newOptions) {
|
|
140
|
+
// and is not array
|
|
141
|
+
if (typeof newOptions[key] === 'object' && !Array.isArray(newOptions[key])) {
|
|
142
|
+
if (!options[key]) {
|
|
143
|
+
options[key] = {};
|
|
144
|
+
}
|
|
145
|
+
mergeOptions(options[key], newOptions[key]);
|
|
146
|
+
} else {
|
|
147
|
+
options[key] = newOptions[key];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
mergeOptions(options, props.options);
|
|
152
|
+
|
|
153
|
+
return options;
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
let apexChart: ApexCharts | null = null;
|
|
157
|
+
|
|
158
|
+
watch(() => [options.value, chart.value], (value) => {
|
|
159
|
+
if (!value || !chart.value) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (apexChart) {
|
|
163
|
+
apexChart.updateOptions(options.value);
|
|
164
|
+
} else {
|
|
165
|
+
apexChart = new ApexCharts(chart.value, options.value);
|
|
166
|
+
apexChart.render();
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
onUnmounted(() => {
|
|
171
|
+
if (apexChart) {
|
|
172
|
+
apexChart.destroy();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
</script>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative mt-4 lg:mt-10 w-full max-w-[700px] bg-gray-200 rounded-full h-2.5 dark:bg-gray-700">
|
|
3
|
+
<span class="absolute -top-6 left-0 text-sm text-gray-500">{{ leftLabel }}</span>
|
|
4
|
+
<span class="absolute -top-6 right-0 text-sm text-gray-500">{{ rightLabel }}</span>
|
|
5
|
+
<div
|
|
6
|
+
class="bg-lightPrimary dark:bg-darkPrimary h-2.5 rounded-full"
|
|
7
|
+
:style="{ width: `${percentage}%` }"
|
|
8
|
+
></div>
|
|
9
|
+
<template v-if="showValues">
|
|
10
|
+
<span class="absolute top-4 left-0 text-sm text-gray-500">{{ formatValue(minValue) }}</span>
|
|
11
|
+
<span v-if="showProgress" class="absolute top-4 right-1/2 translate-x-1/2 text-sm text-gray-500">{{ progressText }}</span>
|
|
12
|
+
<span class="absolute top-4 right-0 text-sm text-gray-500">{{ formatValue(maxValue) }}</span>
|
|
13
|
+
</template>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { computed } from 'vue'
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
currentValue: number
|
|
22
|
+
minValue?: number
|
|
23
|
+
maxValue?: number
|
|
24
|
+
leftLabel?: string
|
|
25
|
+
rightLabel?: string
|
|
26
|
+
formatter?: (value: number) => string
|
|
27
|
+
progressFormatter?: (value: number, percentage: number) => string
|
|
28
|
+
showLabels?: boolean
|
|
29
|
+
showValues: boolean
|
|
30
|
+
showProgress: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
34
|
+
minValue: 0,
|
|
35
|
+
maxValue: 100,
|
|
36
|
+
formatter: (value: number) => `${value}`,
|
|
37
|
+
progressFormatter: (value: number, percentage: number) => `${value}`,
|
|
38
|
+
showValues: true,
|
|
39
|
+
showProgress: true
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const percentage = computed((): number => {
|
|
43
|
+
const min = props.minValue
|
|
44
|
+
const max = props.maxValue
|
|
45
|
+
return Math.round(((props.currentValue - min) / (max - min)) * 100)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const progressText = computed((): string => {
|
|
49
|
+
const formatter = props.progressFormatter
|
|
50
|
+
return formatter(props.currentValue, percentage.value)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const formatValue = (value: number): string => {
|
|
54
|
+
const formatter = props.formatter
|
|
55
|
+
return formatter(value)
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative inline-block afcl-select" ref="internalSelect">
|
|
3
|
+
<div class="relative">
|
|
4
|
+
<input
|
|
5
|
+
ref="inputEl"
|
|
6
|
+
type="text"
|
|
7
|
+
:readonly="isReadonly"
|
|
8
|
+
v-model="search"
|
|
9
|
+
@click="inputClick"
|
|
10
|
+
@input="inputInput"
|
|
11
|
+
class="block w-full pl-3 pr-10 py-2.5 border border-gray-300 rounded-md leading-5 bg-gray-50 placeholder-gray-500 sm:text-sm transition duration-150 ease-in-out dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white focus:ring-lightPrimary focus:border-lightPrimary dark:focus:ring-darkPrimary dark:focus:border-darkPrimary"
|
|
12
|
+
autocomplete="off" data-custom="no-autofill"
|
|
13
|
+
:placeholder="
|
|
14
|
+
selectedItems.length && !multiple ? '' : (showDropdown ? $t('Search') : placeholder || $t('Select...'))
|
|
15
|
+
"
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<div v-if="!multiple && selectedItems.length" class="absolute pointer-events-none inset-y-0 left-2 flex items-center pr-2 px-1">
|
|
19
|
+
<slot
|
|
20
|
+
name="selected-item"
|
|
21
|
+
:option="selectedItems[0]"
|
|
22
|
+
></slot>
|
|
23
|
+
<span v-if="!$slots['selected-item']" class="text-lightPrimary dark:text-white font-medium ">
|
|
24
|
+
{{ selectedItems[0]?.label }}
|
|
25
|
+
</span>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<div class="absolute inset-y-0 right-2 flex items-center pointer-events-none">
|
|
29
|
+
<!-- triangle icon -->
|
|
30
|
+
<IconCaretDownSolid class="h-5 w-5 text-lightPrimary dark:text-gray-400 opacity-50 transition duration-150 ease-in"
|
|
31
|
+
:class="{ 'transform rotate-180': showDropdown }"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div v-if="showDropdown" ref="dropdownEl" :style="dropdownStyle" :class="{'shadow-none': isTop}"
|
|
36
|
+
class="absolute z-10 mt-1 w-full bg-white shadow-lg dark:shadow-black dark:bg-gray-700
|
|
37
|
+
dark:border-gray-600 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm max-h-48">
|
|
38
|
+
<div
|
|
39
|
+
v-for="item in filteredItems"
|
|
40
|
+
:key="item.value"
|
|
41
|
+
class="px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400"
|
|
42
|
+
:class="{ 'bg-lightPrimaryOpacity dark:bg-darkPrimaryOpacity': selectedItems.includes(item) }"
|
|
43
|
+
@click="toogleItem(item)"
|
|
44
|
+
>
|
|
45
|
+
<slot name="item" :option="item"></slot>
|
|
46
|
+
<label v-if="!$slots.item" :for="item.value">{{ item.label }}</label>
|
|
47
|
+
</div>
|
|
48
|
+
<div v-if="!filteredItems.length" class="px-4 py-2 cursor-pointer text-gray-400 dark:text-gray-300">
|
|
49
|
+
{{ $t('No results found') }}
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div v-if="$slots['extra-item']" class="px-4 py-2 dark:text-gray-400">
|
|
53
|
+
<slot name="extra-item"></slot>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div v-if="multiple && selectedItems.length"
|
|
59
|
+
class="inset-y-0 left-2 flex items-center pr-2 flex-wrap gap-y-2 py-2"
|
|
60
|
+
>
|
|
61
|
+
<template v-for="item in selectedItems" :key="`afcl-select-${item.value}`">
|
|
62
|
+
<slot name="selected-item" :item="item"></slot>
|
|
63
|
+
<div v-if="!$slots['selected-item']"
|
|
64
|
+
class="bg-lightPrimaryOpacity text-lightPrimary text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-darkPrimaryOpacity dark:text-darkPrimary">
|
|
65
|
+
<span>{{ item.label }}</span>
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
@click="toogleItem(item)"
|
|
69
|
+
class="z-index-100 flex-shrink-0 ml-1 h-4 w-4 -mr-1 rounded-full inline-flex items-center justify-center text-gray-400 hover:text-gray-500 focus:outline-none focus:text-gray-500 focus:bg-gray-100"
|
|
70
|
+
>
|
|
71
|
+
<span class="sr-only">{{ $t('Remove item') }}</span>
|
|
72
|
+
<svg class="h-2 w-2" stroke="currentColor" fill="none" viewBox="0 0 8 8">
|
|
73
|
+
<path
|
|
74
|
+
stroke-linecap="round"
|
|
75
|
+
stroke-linejoin="round"
|
|
76
|
+
stroke-width="1.5"
|
|
77
|
+
d="M1 1l6 6m0-6L1 7"
|
|
78
|
+
/>
|
|
79
|
+
</svg>
|
|
80
|
+
</button>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
|
|
87
|
+
<script setup lang="ts">
|
|
88
|
+
import { ref, computed, onMounted, onUnmounted, watch, type Ref } from 'vue';
|
|
89
|
+
import { IconCaretDownSolid } from '@iconify-prerendered/vue-flowbite';
|
|
90
|
+
import { useElementSize } from '@vueuse/core'
|
|
91
|
+
|
|
92
|
+
const props = defineProps({
|
|
93
|
+
options: Array,
|
|
94
|
+
modelValue: {
|
|
95
|
+
default: undefined,
|
|
96
|
+
},
|
|
97
|
+
multiple: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
default: false,
|
|
100
|
+
},
|
|
101
|
+
placeholder: {
|
|
102
|
+
type: String,
|
|
103
|
+
default: '',
|
|
104
|
+
},
|
|
105
|
+
isReadonly: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
default: false,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const emit = defineEmits(['update:modelValue']);
|
|
112
|
+
|
|
113
|
+
const search = ref('');
|
|
114
|
+
const showDropdown = ref(false);
|
|
115
|
+
const inputEl = ref<HTMLElement | null>(null);
|
|
116
|
+
const dropdownEl = ref<HTMLElement | null>(null);
|
|
117
|
+
const { height: dropdownHeight } = useElementSize(dropdownEl);
|
|
118
|
+
const isTop = ref<boolean>(false);
|
|
119
|
+
|
|
120
|
+
const dropdownStyle = ref<{ top?: string; }>({
|
|
121
|
+
top: "0px",
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const selectedItems: Ref<any[]> = ref([]);
|
|
125
|
+
const internalSelect = ref<HTMLElement | null>(null);
|
|
126
|
+
|
|
127
|
+
function inputInput() {
|
|
128
|
+
if (!props.multiple && selectedItems.value.length) {
|
|
129
|
+
selectedItems.value = [];
|
|
130
|
+
emit('update:modelValue', null);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function updateFromProps() {
|
|
135
|
+
if (props.modelValue !== undefined) {
|
|
136
|
+
if (!props.multiple) {
|
|
137
|
+
const el = props.options.find(item => item.value === props.modelValue);
|
|
138
|
+
if (el) {
|
|
139
|
+
selectedItems.value = [el];
|
|
140
|
+
} else {
|
|
141
|
+
selectedItems.value = [];
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
selectedItems.value = props.options.filter(item => props.modelValue.includes(item.value));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function inputClick() {
|
|
150
|
+
if (props.isReadonly) return;
|
|
151
|
+
// Toggle local dropdown
|
|
152
|
+
showDropdown.value = !showDropdown.value;
|
|
153
|
+
// If the dropdown is about to close, reset the search
|
|
154
|
+
if (!showDropdown.value && !search.value) {
|
|
155
|
+
search.value = '';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
watch(
|
|
160
|
+
() => ({ show: showDropdown.value, dropdownHeight: dropdownHeight.value }),
|
|
161
|
+
(value) => {
|
|
162
|
+
if (value.show && value.dropdownHeight) {
|
|
163
|
+
const inputRect = inputEl.value?.getBoundingClientRect();
|
|
164
|
+
const dropdownTopOverflowed =
|
|
165
|
+
-(value.dropdownHeight ?? 0) - (inputEl.value?.offsetHeight ?? 0)/2 + "px";
|
|
166
|
+
isTop.value =
|
|
167
|
+
(value.dropdownHeight ?? 0) +
|
|
168
|
+
(inputRect?.top ?? 0) +
|
|
169
|
+
(inputRect?.height ?? 0) +
|
|
170
|
+
12 >
|
|
171
|
+
window.innerHeight;
|
|
172
|
+
dropdownStyle.value = isTop.value ? { top: dropdownTopOverflowed } : {};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
onMounted(() => {
|
|
178
|
+
updateFromProps();
|
|
179
|
+
|
|
180
|
+
watch(() => props.modelValue, (value) => {
|
|
181
|
+
updateFromProps();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
watch(() => props.options, () => {
|
|
185
|
+
updateFromProps();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
addClickListener();
|
|
189
|
+
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const filteredItems = computed(() => {
|
|
193
|
+
return props.options.filter(item =>
|
|
194
|
+
item.label.toLowerCase().includes(search.value.toLowerCase())
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
200
|
+
const targetEl = event.target as HTMLElement | null;
|
|
201
|
+
const closestSelect = targetEl?.closest('.afcl-select');
|
|
202
|
+
if (closestSelect !== internalSelect.value)
|
|
203
|
+
showDropdown.value = false;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const addClickListener = () => {
|
|
207
|
+
document.addEventListener('click', handleClickOutside);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const removeClickListener = () => {
|
|
211
|
+
document.removeEventListener('click', handleClickOutside);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const toogleItem = (item) => {
|
|
215
|
+
if (selectedItems.value.includes(item)) {
|
|
216
|
+
selectedItems.value = selectedItems.value.filter(i => i !== item);
|
|
217
|
+
} else {
|
|
218
|
+
if (!props.multiple) {
|
|
219
|
+
selectedItems.value = [item];
|
|
220
|
+
} else {
|
|
221
|
+
selectedItems.value = [...selectedItems.value, item];
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (!props.multiple) {
|
|
225
|
+
showDropdown.value = false;
|
|
226
|
+
}
|
|
227
|
+
if (!props.multiple && search.value) {
|
|
228
|
+
search.value = '';
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const list = selectedItems.value.map(item => item.value);
|
|
232
|
+
const updValue = list.length ? list : null;
|
|
233
|
+
let emitValue;
|
|
234
|
+
if (!props.multiple) {
|
|
235
|
+
emitValue = updValue ? updValue[0] : null;
|
|
236
|
+
} else {
|
|
237
|
+
emitValue = updValue;
|
|
238
|
+
}
|
|
239
|
+
emit('update:modelValue', emitValue);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
onUnmounted(() => {
|
|
243
|
+
removeClickListener();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="type === 'image'" role="status" class="flex animate-pulse items-center justify-center bg-gray-300 rounded dark:bg-gray-700">
|
|
3
|
+
<svg class="w-10 h-10 text-gray-200 dark:text-gray-600" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 18">
|
|
4
|
+
<path d="M18 0H2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm4.376 10.481A1 1 0 0 1 16 15H4a1 1 0 0 1-.895-1.447l3.5-7A1 1 0 0 1 7.468 6a.965.965 0 0 1 .9.5l2.775 4.757 1.546-1.887a1 1 0 0 1 1.618.1l2.541 4a1 1 0 0 1 .028 1.011Z"/>
|
|
5
|
+
</svg>
|
|
6
|
+
</div>
|
|
7
|
+
<div v-else-if="type === 'video'" role="status" class="flex items-center justify-center max-w-sm bg-gray-300 rounded-lg animate-pulse dark:bg-gray-700">
|
|
8
|
+
<svg class="w-10 h-10 text-gray-200 dark:text-gray-600" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 20">
|
|
9
|
+
<path d="M5 5V.13a2.96 2.96 0 0 0-1.293.749L.879 3.707A2.98 2.98 0 0 0 .13 5H5Z"/>
|
|
10
|
+
<path d="M14.066 0H7v5a2 2 0 0 1-2 2H0v11a1.97 1.97 0 0 0 1.934 2h12.132A1.97 1.97 0 0 0 16 18V2a1.97 1.97 0 0 0-1.934-2ZM9 13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2Zm4 .382a1 1 0 0 1-1.447.894L10 13v-2l1.553-1.276a1 1 0 0 1 1.447.894v2.764Z"/>
|
|
11
|
+
</svg>
|
|
12
|
+
<span class="sr-only">Loading...</span>
|
|
13
|
+
</div>
|
|
14
|
+
<svg v-else-if="type === 'avatar'" class="me-3 animate-pulse text-gray-200 dark:text-gray-700" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
15
|
+
<path d="M10 0a10 10 0 1 0 10 10A10.011 10.011 0 0 0 10 0Zm0 5a3 3 0 1 1 0 6 3 3 0 0 1 0-6Zm0 13a8.949 8.949 0 0 1-4.951-1.488A3.987 3.987 0 0 1 9 13h2a3.987 3.987 0 0 1 3.951 3.512A8.949 8.949 0 0 1 10 18Z"/>
|
|
16
|
+
</svg>
|
|
17
|
+
<div v-else role="status" class="flex items-center justify-center animate-pulse bg-gray-200 rounded-full dark:bg-gray-700">
|
|
18
|
+
<span class="sr-only">Loading...</span>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
defineProps<{
|
|
24
|
+
type?: string,
|
|
25
|
+
}>();
|
|
26
|
+
</script>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div role="status">
|
|
3
|
+
<svg aria-hidden="true" class="text-gray-200 animate-spin dark:text-gray-600 fill-lightPrimary dark:fill-darkPrimary" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
|
|
5
|
+
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
|
|
6
|
+
</svg>
|
|
7
|
+
<span class="sr-only">Loading...</span>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
<div class="relative overflow-x-auto shadow-md sm:rounded-lg">
|
|
4
|
+
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
|
|
5
|
+
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
|
|
6
|
+
<tr>
|
|
7
|
+
<th scope="col" class="px-6 py-3"
|
|
8
|
+
v-for="column in columns"
|
|
9
|
+
>
|
|
10
|
+
<slot v-if="$slots[`header:${column.fieldName}`]" :name="`header:${column.fieldName}`" :column="column" />
|
|
11
|
+
|
|
12
|
+
<span v-else>
|
|
13
|
+
{{ column.label }}
|
|
14
|
+
</span>
|
|
15
|
+
</th>
|
|
16
|
+
</tr>
|
|
17
|
+
</thead>
|
|
18
|
+
<tbody>
|
|
19
|
+
<tr
|
|
20
|
+
v-for="(item, index) in dataPage"
|
|
21
|
+
:class="{
|
|
22
|
+
'odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800': evenHighlights,
|
|
23
|
+
'border-b dark:border-gray-700': index !== dataPage.length - 1 || totalPages > 1,
|
|
24
|
+
}"
|
|
25
|
+
>
|
|
26
|
+
<td class="px-6 py-4"
|
|
27
|
+
v-for="column in props.columns"
|
|
28
|
+
>
|
|
29
|
+
<slot v-if="$slots[`cell:${column.fieldName}`]"
|
|
30
|
+
:name="`cell:${column.fieldName}`"
|
|
31
|
+
:item="item" :column="column"
|
|
32
|
+
>
|
|
33
|
+
</slot>
|
|
34
|
+
<span v-else>
|
|
35
|
+
{{ item[column.fieldName] }}
|
|
36
|
+
</span>
|
|
37
|
+
</td>
|
|
38
|
+
</tr>
|
|
39
|
+
</tbody>
|
|
40
|
+
</table>
|
|
41
|
+
<nav class="flex items-center flex-column flex-wrap md:flex-row justify-between p-4"
|
|
42
|
+
v-if="totalPages > 1"
|
|
43
|
+
:aria-label="$t('Table navigation')">
|
|
44
|
+
<i18n-t
|
|
45
|
+
keypath="Showing {from} to {to} of {total}" tag="span" class="text-sm font-normal text-gray-500 dark:text-gray-400 mb-4 md:mb-0 block w-full md:inline md:w-auto"
|
|
46
|
+
>
|
|
47
|
+
<template #from><span class="font-semibold text-gray-900 dark:text-white">{{ Math.min((currentPage - 1) * props.pageSize + 1, props.data.length) }}</span></template>
|
|
48
|
+
<template #to><span class="font-semibold text-gray-900 dark:text-white">{{ Math.min(currentPage * props.pageSize, props.data.length) }}</span></template>
|
|
49
|
+
<template #total><span class="font-semibold text-gray-900 dark:text-white">{{ props.data.length }}</span></template>
|
|
50
|
+
</i18n-t>
|
|
51
|
+
|
|
52
|
+
<ul class="inline-flex -space-x-px rtl:space-x-reverse text-sm h-8">
|
|
53
|
+
<li v-for="page in totalPages" :key="page">
|
|
54
|
+
<a href="#"
|
|
55
|
+
@click.prevent="switchPage(page)"
|
|
56
|
+
:aria-current="page === page ? 'page' : undefined"
|
|
57
|
+
:class='{
|
|
58
|
+
"text-blue-600 bg-lightPrimary text-lightPrimaryContrast dark:bg-darkPrimary dark:text-darkPrimaryContrast hover:opacity-90": page === currentPage,
|
|
59
|
+
"text-gray-500 border bg-white border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white": page !== currentPage,
|
|
60
|
+
"rounded-s-lg ms-0": page === 1,
|
|
61
|
+
"rounded-e-lg": page === totalPages,
|
|
62
|
+
}'
|
|
63
|
+
class="flex items-center justify-center px-3 h-8 leading-tight ">
|
|
64
|
+
{{ page }}
|
|
65
|
+
</a>
|
|
66
|
+
</li>
|
|
67
|
+
</ul>
|
|
68
|
+
</nav>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
</template>
|
|
74
|
+
|
|
75
|
+
<script setup lang="ts">
|
|
76
|
+
import { ref, type Ref, computed } from 'vue';
|
|
77
|
+
|
|
78
|
+
const props = withDefaults(
|
|
79
|
+
defineProps<{
|
|
80
|
+
columns: {
|
|
81
|
+
label: string,
|
|
82
|
+
fieldName: string,
|
|
83
|
+
}[],
|
|
84
|
+
data: {
|
|
85
|
+
[key: string]: any,
|
|
86
|
+
}[],
|
|
87
|
+
evenHighlights?: boolean,
|
|
88
|
+
pageSize?: number,
|
|
89
|
+
}>(), {
|
|
90
|
+
evenHighlights: true,
|
|
91
|
+
pageSize: 10,
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const currentPage = ref(1);
|
|
96
|
+
|
|
97
|
+
const totalPages = computed(() => {
|
|
98
|
+
return Math.ceil(props.data.length / props.pageSize);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const dataPage = computed(() => {
|
|
102
|
+
const start = (currentPage.value - 1) * props.pageSize;
|
|
103
|
+
const end = start + props.pageSize;
|
|
104
|
+
return props.data.slice(start, end);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
function switchPage(p: number) {
|
|
108
|
+
currentPage.value = p;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const emites = defineEmits([
|
|
112
|
+
'update:activeTab',
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
</script>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="triggerEl" class="inline-flex items-center">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
<div
|
|
6
|
+
role="tooltip"
|
|
7
|
+
class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white transition-opacity duration-300 bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700"
|
|
8
|
+
ref="tooltip"
|
|
9
|
+
>
|
|
10
|
+
<slot name="tooltip"></slot>
|
|
11
|
+
<div class="tooltip-arrow" data-popper-arrow></div>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { ref, onMounted, nextTick, onUnmounted, type Ref } from 'vue';
|
|
18
|
+
import { Tooltip } from 'flowbite';
|
|
19
|
+
|
|
20
|
+
const triggerEl = ref(null);
|
|
21
|
+
const tooltip = ref(null);
|
|
22
|
+
|
|
23
|
+
const tp: Ref<Tooltip|null> = ref(null);
|
|
24
|
+
|
|
25
|
+
onMounted(async () => {
|
|
26
|
+
//await one tick when all is mounted
|
|
27
|
+
await nextTick();
|
|
28
|
+
tp.value = new Tooltip(
|
|
29
|
+
tooltip.value,
|
|
30
|
+
triggerEl.value,
|
|
31
|
+
{
|
|
32
|
+
placement: 'bottom',
|
|
33
|
+
triggerType: 'hover',
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
onUnmounted(() => {
|
|
40
|
+
//destroy tooltip
|
|
41
|
+
tp.value?.destroy();
|
|
42
|
+
})
|
|
43
|
+
</script>
|