sprintify-ui 0.0.0
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/README.md +188 -0
- package/dist/types/src/components/BaseAlert.vue.d.ts +51 -0
- package/dist/types/src/components/BaseAutocomplete.vue.d.ts +268 -0
- package/dist/types/src/components/BaseAutocompleteFetch.vue.d.ts +273 -0
- package/dist/types/src/components/BaseAvatar.vue.d.ts +126 -0
- package/dist/types/src/components/BaseBadge.vue.d.ts +94 -0
- package/dist/types/src/components/BaseBelongsTo.vue.d.ts +268 -0
- package/dist/types/src/components/BaseBoolean.vue.d.ts +64 -0
- package/dist/types/src/components/BaseBreadcrumbs.vue.d.ts +66 -0
- package/dist/types/src/components/BaseButton.vue.d.ts +23 -0
- package/dist/types/src/components/BaseCard.vue.d.ts +74 -0
- package/dist/types/src/components/BaseCardRow.vue.d.ts +16 -0
- package/dist/types/src/components/BaseClipboard.vue.d.ts +74 -0
- package/dist/types/src/components/BaseContainer.vue.d.ts +34 -0
- package/dist/types/src/components/BaseCounter.vue.d.ts +125 -0
- package/dist/types/src/components/BaseDataIterator.vue.d.ts +345 -0
- package/dist/types/src/components/BaseDataTable.vue.d.ts +657 -0
- package/dist/types/src/components/BaseDataTableToggleColumns.vue.d.ts +1281 -0
- package/dist/types/src/components/BaseDatePicker.vue.d.ts +190 -0
- package/dist/types/src/components/BaseDateSelect.vue.d.ts +171 -0
- package/dist/types/src/components/BaseDescriptionList.vue.d.ts +48 -0
- package/dist/types/src/components/BaseDescriptionListItem.vue.d.ts +49 -0
- package/dist/types/src/components/BaseDialog.vue.d.ts +160 -0
- package/dist/types/src/components/BaseFilePicker.vue.d.ts +44 -0
- package/dist/types/src/components/BaseFileUploader.vue.d.ts +220 -0
- package/dist/types/src/components/BaseInput.vue.d.ts +209 -0
- package/dist/types/src/components/BaseInputLabel.vue.d.ts +31 -0
- package/dist/types/src/components/BaseLoadingCover.vue.d.ts +166 -0
- package/dist/types/src/components/BaseLoadingPage.vue.d.ts +2 -0
- package/dist/types/src/components/BaseMediaLibrary.vue.d.ts +269 -0
- package/dist/types/src/components/BaseMediaLibraryItem.vue.d.ts +75 -0
- package/dist/types/src/components/BaseMenu.vue.d.ts +117 -0
- package/dist/types/src/components/BaseMenuItem.vue.d.ts +147 -0
- package/dist/types/src/components/BaseModalCenter.vue.d.ts +141 -0
- package/dist/types/src/components/BaseModalSide.vue.d.ts +141 -0
- package/dist/types/src/components/BaseNavbar.vue.d.ts +79 -0
- package/dist/types/src/components/BaseNavbarItem.vue.d.ts +80 -0
- package/dist/types/src/components/BaseNavbarItemContent.vue.d.ts +127 -0
- package/dist/types/src/components/BasePagination.vue.d.ts +25 -0
- package/dist/types/src/components/BasePaginationSimple.vue.d.ts +25 -0
- package/dist/types/src/components/BasePanel.vue.d.ts +31 -0
- package/dist/types/src/components/BasePassword.vue.d.ts +66 -0
- package/dist/types/src/components/BaseProcessRing.vue.d.ts +36 -0
- package/dist/types/src/components/BaseReadMore.vue.d.ts +74 -0
- package/dist/types/src/components/BaseSelect.vue.d.ts +55 -0
- package/dist/types/src/components/BaseSideNavigation.vue.d.ts +48 -0
- package/dist/types/src/components/BaseSideNavigationItem.vue.d.ts +92 -0
- package/dist/types/src/components/BaseSkeleton.vue.d.ts +93 -0
- package/dist/types/src/components/BaseSpinner.vue.d.ts +2 -0
- package/dist/types/src/components/BaseSwitch.vue.d.ts +39 -0
- package/dist/types/src/components/BaseSystemAlert.vue.d.ts +141 -0
- package/dist/types/src/components/BaseTabItem.vue.d.ts +70 -0
- package/dist/types/src/components/BaseTable.vue.d.ts +467 -0
- package/dist/types/src/components/BaseTableColumn.vue.d.ts +164 -0
- package/dist/types/src/components/BaseTabs.vue.d.ts +48 -0
- package/dist/types/src/components/BaseTagAutocomplete.vue.d.ts +274 -0
- package/dist/types/src/components/BaseTagAutocompleteFetch.vue.d.ts +251 -0
- package/dist/types/src/components/BaseTextarea.vue.d.ts +228 -0
- package/dist/types/src/components/BaseTextareaAutoresize.vue.d.ts +44 -0
- package/dist/types/src/components/BaseTitle.vue.d.ts +45 -0
- package/dist/types/src/components/BaseWordCount.vue.d.ts +31 -0
- package/dist/types/src/components/SlotComponent.d.ts +43 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/composables/breakpoints.d.ts +12 -0
- package/dist/types/src/composables/modal.d.ts +6 -0
- package/dist/types/src/constants/MyConstants.d.ts +1 -0
- package/dist/types/src/constants/index.d.ts +2 -0
- package/dist/types/src/index.d.ts +253 -0
- package/dist/types/src/types/Media.d.ts +8 -0
- package/dist/types/src/types/UploadedFile.d.ts +9 -0
- package/dist/types/src/types/User.d.ts +6 -0
- package/dist/types/src/types/types.d.ts +88 -0
- package/dist/types/src/utils/fileSizeFormat.d.ts +1 -0
- package/dist/types/src/utils/index.d.ts +4 -0
- package/dist/types/src/utils/scrollPreventer.d.ts +4 -0
- package/dist/types/src/utils/toHumanList.d.ts +1 -0
- package/package.json +99 -0
- package/src/assets/button.css +80 -0
- package/src/assets/form.css +15 -0
- package/src/assets/main.css +3 -0
- package/src/assets/pikaday.css +134 -0
- package/src/assets/tailwind.css +5 -0
- package/src/components/BaseAlert.stories.js +52 -0
- package/src/components/BaseAlert.vue +152 -0
- package/src/components/BaseAutocomplete.stories.js +127 -0
- package/src/components/BaseAutocomplete.vue +376 -0
- package/src/components/BaseAutocompleteFetch.stories.js +121 -0
- package/src/components/BaseAutocompleteFetch.vue +185 -0
- package/src/components/BaseAvatar.stories.js +39 -0
- package/src/components/BaseAvatar.vue +92 -0
- package/src/components/BaseBadge.stories.js +61 -0
- package/src/components/BaseBadge.vue +70 -0
- package/src/components/BaseBelongsTo.stories.js +130 -0
- package/src/components/BaseBelongsTo.vue +122 -0
- package/src/components/BaseBoolean.stories.js +35 -0
- package/src/components/BaseBoolean.vue +29 -0
- package/src/components/BaseBreadcrumbs.stories.js +45 -0
- package/src/components/BaseBreadcrumbs.vue +78 -0
- package/src/components/BaseButton.stories.js +80 -0
- package/src/components/BaseButton.vue +39 -0
- package/src/components/BaseCard.stories.js +61 -0
- package/src/components/BaseCard.vue +49 -0
- package/src/components/BaseCardRow.vue +34 -0
- package/src/components/BaseClipboard.stories.js +31 -0
- package/src/components/BaseClipboard.vue +96 -0
- package/src/components/BaseContainer.stories.js +34 -0
- package/src/components/BaseContainer.vue +50 -0
- package/src/components/BaseCounter.stories.js +32 -0
- package/src/components/BaseCounter.vue +72 -0
- package/src/components/BaseDataIterator.stories.js +90 -0
- package/src/components/BaseDataIterator.vue +658 -0
- package/src/components/BaseDataTable.stories.js +95 -0
- package/src/components/BaseDataTable.vue +489 -0
- package/src/components/BaseDataTableToggleColumns.vue +69 -0
- package/src/components/BaseDatePicker.stories.js +53 -0
- package/src/components/BaseDatePicker.vue +166 -0
- package/src/components/BaseDateSelect.vue +192 -0
- package/src/components/BaseDescriptionList.vue +11 -0
- package/src/components/BaseDescriptionListItem.vue +12 -0
- package/src/components/BaseDialog.vue +104 -0
- package/src/components/BaseFilePicker.vue +101 -0
- package/src/components/BaseFileUploader.vue +166 -0
- package/src/components/BaseInput.vue +82 -0
- package/src/components/BaseInputLabel.vue +26 -0
- package/src/components/BaseLoadingCover.vue +84 -0
- package/src/components/BaseLoadingPage.vue +19 -0
- package/src/components/BaseMediaLibrary.vue +281 -0
- package/src/components/BaseMediaLibraryItem.vue +92 -0
- package/src/components/BaseMenu.vue +114 -0
- package/src/components/BaseMenuItem.vue +93 -0
- package/src/components/BaseModalCenter.vue +107 -0
- package/src/components/BaseModalSide.vue +112 -0
- package/src/components/BaseNavbar.vue +72 -0
- package/src/components/BaseNavbarItem.vue +72 -0
- package/src/components/BaseNavbarItemContent.vue +57 -0
- package/src/components/BasePagination.vue +82 -0
- package/src/components/BasePaginationSimple.vue +60 -0
- package/src/components/BasePanel.vue +39 -0
- package/src/components/BasePassword.vue +73 -0
- package/src/components/BaseProcessRing.vue +56 -0
- package/src/components/BaseReadMore.vue +72 -0
- package/src/components/BaseSelect.vue +59 -0
- package/src/components/BaseSideNavigation.vue +7 -0
- package/src/components/BaseSideNavigationItem.vue +42 -0
- package/src/components/BaseSkeleton.vue +24 -0
- package/src/components/BaseSpinner.vue +47 -0
- package/src/components/BaseSwitch.vue +87 -0
- package/src/components/BaseSystemAlert.vue +86 -0
- package/src/components/BaseTabItem.vue +30 -0
- package/src/components/BaseTable.vue +781 -0
- package/src/components/BaseTableColumn.vue +109 -0
- package/src/components/BaseTabs.vue +12 -0
- package/src/components/BaseTagAutocomplete.vue +385 -0
- package/src/components/BaseTagAutocompleteFetch.vue +154 -0
- package/src/components/BaseTextarea.vue +73 -0
- package/src/components/BaseTextareaAutoresize.vue +117 -0
- package/src/components/BaseTitle.vue +80 -0
- package/src/components/BaseWordCount.vue +36 -0
- package/src/components/SlotComponent.ts +37 -0
- package/src/components/index.ts +5 -0
- package/src/composables/breakpoints.ts +6 -0
- package/src/composables/modal.ts +77 -0
- package/src/constants/MyConstants.ts +1 -0
- package/src/constants/index.ts +5 -0
- package/src/env.d.ts +15 -0
- package/src/index.ts +70 -0
- package/src/lang/en.json +56 -0
- package/src/lang/fr.json +56 -0
- package/src/types/Media.ts +9 -0
- package/src/types/UploadedFile.ts +10 -0
- package/src/types/User.ts +7 -0
- package/src/types/types.ts +112 -0
- package/src/utils/fileSizeFormat.ts +15 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/scrollPreventer.ts +21 -0
- package/src/utils/toHumanList.ts +20 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative">
|
|
3
|
+
<div
|
|
4
|
+
class="pointer-events-none absolute top-0 left-0 flex h-full items-center justify-center pl-2.5"
|
|
5
|
+
>
|
|
6
|
+
<Icon
|
|
7
|
+
class="relative -top-px h-5 w-5 text-slate-400"
|
|
8
|
+
icon="heroicons:calendar"
|
|
9
|
+
/>
|
|
10
|
+
</div>
|
|
11
|
+
<input
|
|
12
|
+
ref="datepicker"
|
|
13
|
+
:value="modelValue"
|
|
14
|
+
type="text"
|
|
15
|
+
readonly
|
|
16
|
+
:disabled="disabled"
|
|
17
|
+
class="w-full rounded pl-10 pr-16 disabled:cursor-not-allowed disabled:text-gray-300"
|
|
18
|
+
:class="inputClass"
|
|
19
|
+
:placeholder="$t('sui.click_or_select_date')"
|
|
20
|
+
/>
|
|
21
|
+
<div
|
|
22
|
+
v-if="modelValue && !disabled"
|
|
23
|
+
class="absolute top-0 right-0 flex h-full items-center justify-center p-1"
|
|
24
|
+
>
|
|
25
|
+
<button
|
|
26
|
+
type="button"
|
|
27
|
+
class="flex h-8 items-center rounded p-1 hover:bg-slate-200"
|
|
28
|
+
@click="clear()"
|
|
29
|
+
>
|
|
30
|
+
<Icon class="h-5 w-5 text-slate-600" icon="heroicons:x-mark" />
|
|
31
|
+
</button>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script lang="ts" setup>
|
|
37
|
+
import { PropType, Ref } from 'vue';
|
|
38
|
+
import Pikaday from 'pikaday';
|
|
39
|
+
import { capitalize, padStart } from 'lodash';
|
|
40
|
+
import { DateTime, Info } from 'luxon';
|
|
41
|
+
import { config } from 'src';
|
|
42
|
+
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
modelValue: {
|
|
45
|
+
required: true,
|
|
46
|
+
type: [String, null, undefined] as PropType<string | null | undefined>,
|
|
47
|
+
},
|
|
48
|
+
required: {
|
|
49
|
+
default: false,
|
|
50
|
+
type: Boolean,
|
|
51
|
+
},
|
|
52
|
+
disabled: {
|
|
53
|
+
default: false,
|
|
54
|
+
type: Boolean,
|
|
55
|
+
},
|
|
56
|
+
inputClass: {
|
|
57
|
+
default: '',
|
|
58
|
+
type: String,
|
|
59
|
+
},
|
|
60
|
+
minDate: {
|
|
61
|
+
default: undefined,
|
|
62
|
+
type: Date,
|
|
63
|
+
},
|
|
64
|
+
maxDate: {
|
|
65
|
+
default: undefined,
|
|
66
|
+
type: Date,
|
|
67
|
+
},
|
|
68
|
+
yearRange: {
|
|
69
|
+
default: undefined,
|
|
70
|
+
type: [Number, Array] as PropType<number | [number, number]>,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const emit = defineEmits(['update:modelValue']);
|
|
75
|
+
|
|
76
|
+
const i18n = useI18n();
|
|
77
|
+
|
|
78
|
+
const datepicker = ref(null) as Ref<HTMLInputElement | null>;
|
|
79
|
+
|
|
80
|
+
const months = Info.months('long', { locale: config.i18n.global.locale }).map(
|
|
81
|
+
(m) => capitalize(m)
|
|
82
|
+
);
|
|
83
|
+
const weekdays = arrayRotate(
|
|
84
|
+
Info.weekdays('long', { locale: config.i18n.global.locale }).map((m) =>
|
|
85
|
+
capitalize(m)
|
|
86
|
+
),
|
|
87
|
+
true
|
|
88
|
+
);
|
|
89
|
+
const weekdaysShort = arrayRotate(
|
|
90
|
+
Info.weekdays('short', { locale: config.i18n.global.locale }).map((m) =>
|
|
91
|
+
capitalize(m)
|
|
92
|
+
),
|
|
93
|
+
true
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
let picker = null as Pikaday | null;
|
|
97
|
+
|
|
98
|
+
onMounted(() => {
|
|
99
|
+
if (!datepicker.value) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
picker = new Pikaday({
|
|
104
|
+
theme: 'pikaday-white',
|
|
105
|
+
field: datepicker.value,
|
|
106
|
+
yearRange: props.yearRange,
|
|
107
|
+
i18n: {
|
|
108
|
+
previousMonth: i18n.t('sui.previous_month'),
|
|
109
|
+
nextMonth: i18n.t('sui.next_month'),
|
|
110
|
+
months: months,
|
|
111
|
+
weekdays: weekdays,
|
|
112
|
+
weekdaysShort: weekdaysShort,
|
|
113
|
+
},
|
|
114
|
+
toString(date) {
|
|
115
|
+
const day = padStart(date.getDate() + '', 2, '0');
|
|
116
|
+
const month = padStart(date.getMonth() + 1 + '', 2, '0');
|
|
117
|
+
const year = padStart(date.getFullYear() + '', 4, '0');
|
|
118
|
+
|
|
119
|
+
return `${year}-${month}-${day}`;
|
|
120
|
+
},
|
|
121
|
+
parse(dateString) {
|
|
122
|
+
const datetime = DateTime.fromISO(dateString);
|
|
123
|
+
const year = datetime.year;
|
|
124
|
+
const month = datetime.month - 1;
|
|
125
|
+
const day = datetime.day;
|
|
126
|
+
|
|
127
|
+
return new Date(year, month, day);
|
|
128
|
+
},
|
|
129
|
+
minDate: props.minDate,
|
|
130
|
+
maxDate: props.maxDate,
|
|
131
|
+
onSelect(date) {
|
|
132
|
+
if (!date) {
|
|
133
|
+
clear();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const datetime = DateTime.fromJSDate(date);
|
|
138
|
+
|
|
139
|
+
if (!datetime) {
|
|
140
|
+
clear();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
emit('update:modelValue', datetime.toISODate());
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
onBeforeUnmount(() => {
|
|
150
|
+
if (picker) {
|
|
151
|
+
picker.destroy();
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
function clear() {
|
|
156
|
+
picker?.clear();
|
|
157
|
+
emit('update:modelValue', null);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// https://stackoverflow.com/a/23368052
|
|
161
|
+
function arrayRotate(arr: any[], reverse = false): any[] {
|
|
162
|
+
if (reverse) arr.unshift(arr.pop());
|
|
163
|
+
else arr.push(arr.shift());
|
|
164
|
+
return arr;
|
|
165
|
+
}
|
|
166
|
+
</script>
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="-m-0.5 flex">
|
|
4
|
+
<div class="w-auto p-0.5">
|
|
5
|
+
<select
|
|
6
|
+
v-model="date.year"
|
|
7
|
+
:disabled="disabled"
|
|
8
|
+
:required="required"
|
|
9
|
+
data-cy="year"
|
|
10
|
+
class="w-full rounded"
|
|
11
|
+
:class="[
|
|
12
|
+
{
|
|
13
|
+
'cursor-not-allowed bg-slate-100 text-slate-500': disabled,
|
|
14
|
+
},
|
|
15
|
+
inputClass,
|
|
16
|
+
]"
|
|
17
|
+
:placeholder="$t('sui.year')"
|
|
18
|
+
@change="update()"
|
|
19
|
+
>
|
|
20
|
+
<option disabled selected hidden :value="null">
|
|
21
|
+
{{ $t('sui.year') }}
|
|
22
|
+
</option>
|
|
23
|
+
<option v-for="year in years" :key="year" :value="year">
|
|
24
|
+
{{ year }}
|
|
25
|
+
</option>
|
|
26
|
+
</select>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div class="w-auto p-0.5">
|
|
30
|
+
<select
|
|
31
|
+
v-model="date.month"
|
|
32
|
+
:disabled="disabled"
|
|
33
|
+
:required="required"
|
|
34
|
+
data-cy="month"
|
|
35
|
+
class="w-full rounded capitalize"
|
|
36
|
+
:class="[
|
|
37
|
+
{
|
|
38
|
+
'cursor-not-allowed bg-slate-100 text-slate-500': disabled,
|
|
39
|
+
},
|
|
40
|
+
inputClass,
|
|
41
|
+
]"
|
|
42
|
+
:placeholder="$t('sui.month')"
|
|
43
|
+
@change="update()"
|
|
44
|
+
>
|
|
45
|
+
<option disabled selected hidden :value="null">
|
|
46
|
+
{{ $t('sui.month') }}
|
|
47
|
+
</option>
|
|
48
|
+
<option v-for="(month, i) in months" :key="month" :value="i + 1">
|
|
49
|
+
{{ month }}
|
|
50
|
+
</option>
|
|
51
|
+
</select>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<div class="w-auto p-0.5">
|
|
55
|
+
<select
|
|
56
|
+
v-model="date.day"
|
|
57
|
+
:disabled="disabled"
|
|
58
|
+
:required="required"
|
|
59
|
+
data-cy="day"
|
|
60
|
+
class="w-full rounded capitalize"
|
|
61
|
+
:class="[
|
|
62
|
+
{
|
|
63
|
+
'cursor-not-allowed bg-slate-100 text-slate-500': disabled,
|
|
64
|
+
},
|
|
65
|
+
inputClass,
|
|
66
|
+
]"
|
|
67
|
+
:placeholder="$t('sui.day')"
|
|
68
|
+
@change="update()"
|
|
69
|
+
>
|
|
70
|
+
<option disabled selected hidden :value="null">
|
|
71
|
+
{{ $t('sui.day') }}
|
|
72
|
+
</option>
|
|
73
|
+
<option v-for="day in days" :key="day" :value="day">
|
|
74
|
+
{{ day }}
|
|
75
|
+
</option>
|
|
76
|
+
</select>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<button
|
|
81
|
+
type="button"
|
|
82
|
+
:disabled="disabled"
|
|
83
|
+
class="mt-1 appearance-none border-transparent bg-transparent text-sm text-slate-700 underline outline-none"
|
|
84
|
+
@click="clear()"
|
|
85
|
+
>
|
|
86
|
+
<span>{{ $t('sui.clear') }}</span>
|
|
87
|
+
</button>
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
90
|
+
|
|
91
|
+
<script lang="ts" setup>
|
|
92
|
+
import { PropType } from 'vue';
|
|
93
|
+
import { range, padStart } from 'lodash';
|
|
94
|
+
import { DateTime, Info } from 'luxon';
|
|
95
|
+
|
|
96
|
+
const props = defineProps({
|
|
97
|
+
modelValue: {
|
|
98
|
+
required: true,
|
|
99
|
+
type: [String, null] as PropType<string | null>,
|
|
100
|
+
},
|
|
101
|
+
required: {
|
|
102
|
+
default: false,
|
|
103
|
+
type: Boolean,
|
|
104
|
+
},
|
|
105
|
+
disabled: {
|
|
106
|
+
default: false,
|
|
107
|
+
type: Boolean,
|
|
108
|
+
},
|
|
109
|
+
minYear: {
|
|
110
|
+
default: DateTime.now().year - 90,
|
|
111
|
+
type: Number,
|
|
112
|
+
},
|
|
113
|
+
maxYear: {
|
|
114
|
+
default: DateTime.now().year,
|
|
115
|
+
type: Number,
|
|
116
|
+
},
|
|
117
|
+
inputClass: {
|
|
118
|
+
default: '',
|
|
119
|
+
type: String,
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const emit = defineEmits(['update:modelValue']);
|
|
124
|
+
|
|
125
|
+
const i18n = useI18n();
|
|
126
|
+
|
|
127
|
+
const years = range(props.maxYear, props.minYear) as number[];
|
|
128
|
+
const months = Info.months('short', { locale: i18n.locale.value });
|
|
129
|
+
const days = computed(() => {
|
|
130
|
+
if (!date.value.year) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!date.value.month) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const d = new Date(date.value.year, date.value.month, 0);
|
|
139
|
+
return range(1, d.getDate() + 1);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const date = ref({
|
|
143
|
+
year: null as number | null,
|
|
144
|
+
month: null as number | null,
|
|
145
|
+
day: null as number | null,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
watch(
|
|
149
|
+
() => props.modelValue,
|
|
150
|
+
() => {
|
|
151
|
+
if (props.modelValue) {
|
|
152
|
+
const datetime = DateTime.fromISO(props.modelValue);
|
|
153
|
+
date.value.year = datetime.year;
|
|
154
|
+
date.value.month = datetime.month;
|
|
155
|
+
date.value.day = datetime.day;
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{ immediate: true }
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
function update() {
|
|
162
|
+
const dateTime = getDateTime();
|
|
163
|
+
|
|
164
|
+
if (dateTime) {
|
|
165
|
+
emit('update:modelValue', dateTime.toISODate());
|
|
166
|
+
} else {
|
|
167
|
+
emit('update:modelValue', null);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function clear() {
|
|
172
|
+
date.value.day = null;
|
|
173
|
+
date.value.month = null;
|
|
174
|
+
date.value.year = null;
|
|
175
|
+
|
|
176
|
+
emit('update:modelValue', null);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function getDateTime(): DateTime | null {
|
|
180
|
+
if (!date.value.year || !date.value.month || !date.value.day) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return DateTime.fromISO(
|
|
185
|
+
padStart(date.value.year + '', 4, '0') +
|
|
186
|
+
'-' +
|
|
187
|
+
padStart(date.value.month + '', 2, '0') +
|
|
188
|
+
'-' +
|
|
189
|
+
padStart(date.value.day + '', 2, '0')
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="px-4 py-4 sm:grid sm:grid-cols-3 sm:gap-4 sm:py-5 sm:px-6">
|
|
3
|
+
<dt class="text-sm font-medium text-slate-500">
|
|
4
|
+
<slot name="left" />
|
|
5
|
+
</dt>
|
|
6
|
+
<dd class="mt-1 text-sm text-slate-900 sm:col-span-2 sm:mt-0">
|
|
7
|
+
<slot name="right" />
|
|
8
|
+
</dd>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script lang="ts" setup></script>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6"
|
|
4
|
+
>
|
|
5
|
+
<div class="sm:flex sm:items-start">
|
|
6
|
+
<div
|
|
7
|
+
class="mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full sm:mx-0 sm:h-10 sm:w-10"
|
|
8
|
+
:class="{
|
|
9
|
+
'bg-primary-100': color == 'info',
|
|
10
|
+
'bg-red-100': color == 'danger',
|
|
11
|
+
'bg-yellow-100': color == 'warning',
|
|
12
|
+
'bg-green-100': color == 'success',
|
|
13
|
+
}"
|
|
14
|
+
>
|
|
15
|
+
<Icon
|
|
16
|
+
v-if="color == 'danger'"
|
|
17
|
+
class="h-6 w-6 text-red-600"
|
|
18
|
+
icon="heroicons:exclaimation-triangle"
|
|
19
|
+
/>
|
|
20
|
+
<Icon
|
|
21
|
+
v-else-if="color == 'warning'"
|
|
22
|
+
class="h-6 w-6 text-yellow-600"
|
|
23
|
+
icon="heroicons:exclaimation-circle"
|
|
24
|
+
/>
|
|
25
|
+
<Icon
|
|
26
|
+
v-else-if="color == 'success'"
|
|
27
|
+
class="h-6 w-6 text-green-600"
|
|
28
|
+
icon="heroicons:check-circle"
|
|
29
|
+
/>
|
|
30
|
+
<Icon
|
|
31
|
+
v-else
|
|
32
|
+
class="h-6 w-6 text-primary-600"
|
|
33
|
+
icon="heroicons:information-circle"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
|
|
37
|
+
<slot>
|
|
38
|
+
<h3
|
|
39
|
+
id="modal-title"
|
|
40
|
+
class="text-lg font-medium leading-6 text-slate-900"
|
|
41
|
+
>
|
|
42
|
+
{{ title }}
|
|
43
|
+
</h3>
|
|
44
|
+
<div class="mt-2">
|
|
45
|
+
<p class="text-sm text-slate-500">
|
|
46
|
+
{{ message }}
|
|
47
|
+
</p>
|
|
48
|
+
</div>
|
|
49
|
+
</slot>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
<div class="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
|
53
|
+
<button
|
|
54
|
+
type="button"
|
|
55
|
+
class="btn mb-2 w-full sm:mb-0 sm:w-auto"
|
|
56
|
+
:class="{
|
|
57
|
+
'btn-primary': color == 'info',
|
|
58
|
+
'btn-danger': color == 'danger',
|
|
59
|
+
'btn-warning': color == 'warning',
|
|
60
|
+
'btn-success': color == 'success',
|
|
61
|
+
}"
|
|
62
|
+
@click="$emit('confirm')"
|
|
63
|
+
>
|
|
64
|
+
{{ confirmText ?? $t('sui.confirm') }}
|
|
65
|
+
</button>
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
class="btn w-full sm:mr-2 sm:w-auto"
|
|
69
|
+
@click="$emit('cancel')"
|
|
70
|
+
>
|
|
71
|
+
{{ cancelText ?? $t('sui.cancel') }}
|
|
72
|
+
</button>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</template>
|
|
76
|
+
|
|
77
|
+
<script lang="ts" setup>
|
|
78
|
+
import { PropType } from 'vue';
|
|
79
|
+
|
|
80
|
+
defineProps({
|
|
81
|
+
color: {
|
|
82
|
+
required: true,
|
|
83
|
+
type: String as PropType<'info' | 'success' | 'danger' | 'warning'>,
|
|
84
|
+
},
|
|
85
|
+
title: {
|
|
86
|
+
default: '',
|
|
87
|
+
type: String,
|
|
88
|
+
},
|
|
89
|
+
message: {
|
|
90
|
+
default: '',
|
|
91
|
+
type: String,
|
|
92
|
+
},
|
|
93
|
+
confirmText: {
|
|
94
|
+
default: '',
|
|
95
|
+
type: String,
|
|
96
|
+
},
|
|
97
|
+
cancelText: {
|
|
98
|
+
default: '',
|
|
99
|
+
type: String,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
defineEmits(['cancel', 'confirm']);
|
|
104
|
+
</script>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button
|
|
3
|
+
type="button"
|
|
4
|
+
:class="buttonClass"
|
|
5
|
+
:disabled="disabled"
|
|
6
|
+
@drop.prevent="
|
|
7
|
+
dragging = false;
|
|
8
|
+
handleDrop($event);
|
|
9
|
+
"
|
|
10
|
+
@dragleave.prevent="dragging = false"
|
|
11
|
+
@dragover.prevent="dragging = true"
|
|
12
|
+
@dragenter.prevent="dragging = true"
|
|
13
|
+
@click="pickFile"
|
|
14
|
+
>
|
|
15
|
+
<slot :selecting="selecting" :dragging="dragging" />
|
|
16
|
+
</button>
|
|
17
|
+
<input
|
|
18
|
+
ref="input"
|
|
19
|
+
type="file"
|
|
20
|
+
:accept="accept"
|
|
21
|
+
hidden="true"
|
|
22
|
+
@change="onInputChange"
|
|
23
|
+
/>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script lang="ts">
|
|
27
|
+
import { defineComponent } from 'vue';
|
|
28
|
+
|
|
29
|
+
export default defineComponent({
|
|
30
|
+
props: {
|
|
31
|
+
disabled: {
|
|
32
|
+
default: false,
|
|
33
|
+
type: Boolean,
|
|
34
|
+
},
|
|
35
|
+
buttonClass: {
|
|
36
|
+
default: '',
|
|
37
|
+
type: String,
|
|
38
|
+
},
|
|
39
|
+
accept: {
|
|
40
|
+
default: undefined,
|
|
41
|
+
type: String,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
emits: ['upload'],
|
|
45
|
+
data() {
|
|
46
|
+
return {
|
|
47
|
+
selecting: false,
|
|
48
|
+
dragging: false,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
computed: {
|
|
52
|
+
inputElement(): HTMLInputElement | undefined {
|
|
53
|
+
return this.$refs.input as HTMLInputElement | undefined;
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
methods: {
|
|
57
|
+
async pickFile() {
|
|
58
|
+
if (this.disabled) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
(this.$refs.input as HTMLElement | undefined)?.click();
|
|
63
|
+
},
|
|
64
|
+
onInputChange() {
|
|
65
|
+
const files = (this.inputElement?.files ?? []) as File[];
|
|
66
|
+
this.upload(files);
|
|
67
|
+
},
|
|
68
|
+
handleDrop(e: any) {
|
|
69
|
+
if (this.disabled) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const files = e?.dataTransfer?.files ?? [];
|
|
74
|
+
|
|
75
|
+
this.upload(files);
|
|
76
|
+
},
|
|
77
|
+
async upload(files: File[]) {
|
|
78
|
+
if (this.disabled) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!files || files.length == 0 || !(files[0] instanceof File)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.selecting = true;
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const file = files[0];
|
|
90
|
+
|
|
91
|
+
this.$emit('upload', file);
|
|
92
|
+
} finally {
|
|
93
|
+
if (this.inputElement) {
|
|
94
|
+
this.inputElement.value = '';
|
|
95
|
+
}
|
|
96
|
+
this.selecting = false;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
</script>
|