@citruslime/ui 2.0.0-beta.5 → 2.0.0-beta.9
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/.eslintrc.js +2 -0
- package/dist/citrus-lime-ui.es.js +3960 -0
- package/dist/citrus-lime-ui.umd.js +1 -0
- package/dist/src/components/accordion/cl-ui-accordion.vue.d.ts +47 -0
- package/dist/src/components/accordion/index.d.ts +2 -0
- package/dist/{@types/components/accordion/item.d.ts → src/components/accordion/types.d.ts} +0 -0
- package/dist/src/components/app/cl-ui-app.vue.d.ts +44 -0
- package/dist/src/components/app/index.d.ts +1 -0
- package/dist/src/components/button/cl-ui-button.vue.d.ts +40 -0
- package/dist/src/components/button/index.d.ts +2 -0
- package/dist/src/components/button/types.d.ts +4 -0
- package/dist/src/components/calendar/cl-ui-calendar.vue.d.ts +2 -0
- package/dist/src/components/calendar/index.d.ts +2 -0
- package/dist/src/components/calendar/types.d.ts +2 -0
- package/dist/src/components/calendar/utils.d.ts +23 -0
- package/dist/src/components/card/cl-ui-card.vue.d.ts +22 -0
- package/dist/src/components/card/index.d.ts +2 -0
- package/dist/src/components/card/types.d.ts +2 -0
- package/dist/src/components/combo-box/cl-ui-combo-box.vue.d.ts +506 -0
- package/dist/src/components/combo-box/index.d.ts +2 -0
- package/dist/src/components/combo-box/search-container/cl-ui-combo-box-search.vue.d.ts +230 -0
- package/dist/src/components/combo-box/search-container/header/cl-ui-combo-box-header.vue.d.ts +34 -0
- package/dist/src/components/combo-box/search-container/selectable/cl-ui-combo-box-selectable.vue.d.ts +68 -0
- package/dist/{@types/components/combo-box/item.d.ts → src/components/combo-box/types.d.ts} +0 -0
- package/dist/src/components/footer/index.d.ts +1 -0
- package/dist/src/components/grid/cell/cl-ui-grid-cell.vue.d.ts +65 -0
- package/dist/src/components/grid/cl-ui-grid.vue.d.ts +478 -0
- package/dist/src/components/grid/filter/cl-ui-grid-filter.vue.d.ts +64 -0
- package/dist/src/components/grid/footer/cl-ui-grid-footer.vue.d.ts +57 -0
- package/dist/src/components/grid/header/cl-ui-grid-header.vue.d.ts +175 -0
- package/dist/src/components/grid/index.d.ts +2 -0
- package/dist/src/components/grid/types.d.ts +92 -0
- package/dist/src/components/grid/view-manager/cl-ui-grid-view-manager.vue.d.ts +75 -0
- package/dist/src/components/header/index.d.ts +2 -0
- package/dist/src/components/header/menu/cl-ui-header-menu.vue.d.ts +16 -0
- package/dist/src/components/header/menu/index.d.ts +2 -0
- package/dist/src/components/header/menu/types.d.ts +5 -0
- package/dist/src/components/index.d.ts +16 -0
- package/dist/src/components/language-switcher/cl-ui-language-switcher.vue.d.ts +33 -0
- package/dist/src/components/language-switcher/index.d.ts +2 -0
- package/dist/{@types/language.d.ts → src/components/language-switcher/types.d.ts} +1 -1
- package/dist/src/components/loading-spinner/index.d.ts +1 -0
- package/dist/src/components/login/cl-ui-login.vue.d.ts +92 -0
- package/dist/src/components/login/index.d.ts +2 -0
- package/dist/{@types/components/login/authentication.d.ts → src/components/login/types.d.ts} +0 -0
- package/dist/src/components/modal/cl-ui-modal.vue.d.ts +107 -0
- package/dist/src/components/modal/index.d.ts +1 -0
- package/dist/src/components/modal/types.d.ts +2 -0
- package/dist/src/components/navigation/cl-ui-navigation.vue.d.ts +669 -0
- package/dist/src/components/navigation/index.d.ts +2 -0
- package/dist/{@types/components/navigation/index.d.ts → src/components/navigation/types.d.ts} +2 -2
- package/dist/src/components/notification/cl-ui-notification.vue.d.ts +31 -0
- package/dist/src/components/notification/index.d.ts +1 -0
- package/dist/src/components/notification/types.d.ts +9 -0
- package/dist/src/components/slider/cl-ui-slider.vue.d.ts +87 -0
- package/dist/src/components/slider/index.d.ts +1 -0
- package/dist/{composables → src/composables}/index.d.ts +0 -0
- package/dist/{composables → src/composables}/notification.d.ts +1 -1
- package/dist/src/main.d.ts +6 -0
- package/dist/{utils → src/utils}/copy.d.ts +1 -1
- package/dist/{utils → src/utils}/debouncer.d.ts +6 -1
- package/dist/src/utils/extensions/string/index.d.ts +2 -0
- package/dist/{utils/extensions/string-utilities.d.ts → src/utils/extensions/string/utils.d.ts} +0 -0
- package/dist/src/utils/filter-methods.d.ts +5 -0
- package/dist/src/utils/i18n/config.d.ts +33 -0
- package/dist/src/utils/i18n/defaults.d.ts +4 -0
- package/dist/src/utils/i18n/index.d.ts +3 -0
- package/dist/src/utils/i18n/types.d.ts +94 -0
- package/dist/{utils → src/utils}/id.d.ts +0 -0
- package/dist/{utils → src/utils}/index.d.ts +2 -0
- package/dist/{utils → src/utils}/name-of.d.ts +0 -0
- package/dist/{utils → src/utils}/sort.d.ts +0 -0
- package/dist/{utils → src/utils}/url-params.d.ts +0 -0
- package/dist/style.css +1 -1
- package/package.json +23 -12
- package/dist/@types/appUser.d.ts +0 -11
- package/dist/@types/components/accordion/index.d.ts +0 -1
- package/dist/@types/components/combo-box/index.d.ts +0 -2
- package/dist/@types/components/combo-box/localisations.d.ts +0 -19
- package/dist/@types/components/grid/column.d.ts +0 -46
- package/dist/@types/components/grid/index.d.ts +0 -4
- package/dist/@types/components/grid/localisations.d.ts +0 -47
- package/dist/@types/components/grid/request.d.ts +0 -49
- package/dist/@types/components/grid/update.d.ts +0 -4
- package/dist/@types/components/header/index.d.ts +0 -1
- package/dist/@types/components/header/localisations.d.ts +0 -8
- package/dist/@types/components/login/index.d.ts +0 -2
- package/dist/@types/components/login/localisations.d.ts +0 -7
- package/dist/@types/components/notification/index.d.ts +0 -1
- package/dist/@types/components/notification/item.d.ts +0 -7
- package/dist/@types/components/slider/index.d.ts +0 -1
- package/dist/@types/components/slider/localisations.d.ts +0 -3
- package/dist/@types/date-format.d.ts +0 -8
- package/dist/@types/debouncer.d.ts +0 -6
- package/dist/@types/index.d.ts +0 -16
- package/dist/@types/locale.d.ts +0 -10
- package/dist/@types/number-format.d.ts +0 -7
- package/dist/@types/string-format.d.ts +0 -3
- package/dist/@types/string.d.ts +0 -47
- package/dist/components/index.d.ts +0 -17
- package/dist/main.d.ts +0 -8
- package/dist/ui.es.js +0 -1
- package/dist/ui.umd.js +0 -1
- package/dist/utils/extensions/string.d.ts +0 -1
- package/dist/utils/i18n/datetime-formats.d.ts +0 -3
- package/dist/utils/i18n/number-formats.d.ts +0 -3
- package/src/components/accordion/cl-ui-accordion.vue +0 -89
- package/src/components/app/cl-ui-app.vue +0 -29
- package/src/components/button/cl-ui-button.vue +0 -48
- package/src/components/calendar/cl-ui-calendar.vue +0 -277
- package/src/components/card/cl-ui-card.vue +0 -70
- package/src/components/combo-box/cl-ui-combo-box.vue +0 -357
- package/src/components/combo-box/search-container/cl-ui-combo-box-search.vue +0 -279
- package/src/components/combo-box/search-container/header/cl-ui-combo-box-header.vue +0 -36
- package/src/components/combo-box/search-container/selectable/cl-ui-combo-box-selectable.vue +0 -99
- package/src/components/footer/cl-ui-footer.vue +0 -31
- package/src/components/grid/cell/cl-ui-grid-cell.vue +0 -158
- package/src/components/grid/cl-ui-grid.vue +0 -482
- package/src/components/grid/filter/cl-ui-grid-filter.vue +0 -270
- package/src/components/grid/footer/cl-ui-grid-footer.vue +0 -186
- package/src/components/grid/header/cl-ui-grid-header.vue +0 -78
- package/src/components/grid/view-manager/cl-ui-grid-view-manager.vue +0 -145
- package/src/components/header/cl-ui-header.vue +0 -11
- package/src/components/header-helper/cl-ui-header-helper.vue +0 -55
- package/src/components/language-switcher/cl-ui-language-switcher.vue +0 -82
- package/src/components/loading-spinner/cl-ui-loading-spinner.vue +0 -16
- package/src/components/login/cl-ui-login.vue +0 -183
- package/src/components/modal/cl-ui-modal.vue +0 -120
- package/src/components/navigation/cl-ui-navigation.vue +0 -124
- package/src/components/notification/cl-ui-notification.vue +0 -55
- package/src/components/slider/cl-ui-slider.vue +0 -145
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import Flatpickr from 'flatpickr';
|
|
3
|
-
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
4
|
-
import { useI18n } from 'vue-i18n';
|
|
5
|
-
|
|
6
|
-
import { DateFormat } from '../../@types';
|
|
7
|
-
|
|
8
|
-
import { generateFixedDate, getLocale, replaceDateWithPlaceholders } from './calendar-utilities';
|
|
9
|
-
|
|
10
|
-
type CalendarType = 'date' | 'datetime';
|
|
11
|
-
|
|
12
|
-
const props = withDefaults(defineProps<{
|
|
13
|
-
date?: Date | null;
|
|
14
|
-
currentLocale?: string;
|
|
15
|
-
datePlaceholder?: string;
|
|
16
|
-
dateTimePlaceholder?: string;
|
|
17
|
-
type?: CalendarType;
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
}>(), {
|
|
20
|
-
date: () => null,
|
|
21
|
-
currentLocale: 'en-GB',
|
|
22
|
-
datePlaceholder: 'Select date.',
|
|
23
|
-
dateTimePlaceholder: 'Select date & time.',
|
|
24
|
-
type: 'datetime',
|
|
25
|
-
disabled: false
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const emit = defineEmits({
|
|
29
|
-
'update:date': null
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const { d, getDateTimeFormat } = useI18n();
|
|
33
|
-
|
|
34
|
-
const flatpickrInstance = ref<Flatpickr.Instance | null>(null);
|
|
35
|
-
const element = ref<Node | null>(null);
|
|
36
|
-
|
|
37
|
-
const date = computed<string>(() => d(generateFixedDate(), props.type, props.currentLocale));
|
|
38
|
-
const dateFormat = computed(() => getDateTimeFormat(props.currentLocale)[props.type]);
|
|
39
|
-
const format = computed<string>(() => {
|
|
40
|
-
let hourPlaceholder = 'H';
|
|
41
|
-
let yearPlaceholder = 'Y';
|
|
42
|
-
|
|
43
|
-
if (dateFormat.value?.hour12 === true) {
|
|
44
|
-
hourPlaceholder = 'h';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (dateFormat.value.year === '2-digit') {
|
|
48
|
-
yearPlaceholder = 'y';
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const format = replaceDateWithPlaceholders(date.value, hourPlaceholder, yearPlaceholder);
|
|
52
|
-
|
|
53
|
-
return format;
|
|
54
|
-
});
|
|
55
|
-
const options = computed<Flatpickr.Options.Options>(() => {
|
|
56
|
-
const config: Flatpickr.Options.Options = {
|
|
57
|
-
...Flatpickr.defaultConfig,
|
|
58
|
-
allowInput: true,
|
|
59
|
-
dateFormat: format.value,
|
|
60
|
-
disableMobile: true,
|
|
61
|
-
enableTime: props.type === DateFormat.DATETIME,
|
|
62
|
-
locale: getLocale(props.currentLocale),
|
|
63
|
-
minuteIncrement: 1,
|
|
64
|
-
monthSelectorType: 'static',
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
66
|
-
time_24hr: typeof dateFormat.value.hour12 === 'undefined' || dateFormat.value.hour12 === false
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
if (props.date !== null) {
|
|
70
|
-
config.defaultDate = props.date;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return config;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Emits an update to the model value, for the value provided from flatpickr.
|
|
78
|
-
*
|
|
79
|
-
* @param selectedDates List of raw selected values.
|
|
80
|
-
* @param _date Formatted selected value.
|
|
81
|
-
* @param _instance The current flatpickr instance.
|
|
82
|
-
*/
|
|
83
|
-
function onChange (selectedDates: Date[], _date: string, _instance: Flatpickr.Instance): void {
|
|
84
|
-
emit('update:date', selectedDates.length > 0 ? selectedDates[0] : null);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Emits an update to the model value, to reset it.
|
|
89
|
-
*/
|
|
90
|
-
function clearValue (): void {
|
|
91
|
-
emit('update:date', null);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Reset the value to the current day.
|
|
96
|
-
*/
|
|
97
|
-
function resetValue (): void {
|
|
98
|
-
if (flatpickrInstance.value !== null) {
|
|
99
|
-
const date = new Date();
|
|
100
|
-
|
|
101
|
-
date.setHours(12, 0, 0, 0);
|
|
102
|
-
|
|
103
|
-
emit('update:date', date);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Creates a new flatpickr instance and adds an event handler for the OnChange event.
|
|
109
|
-
*/
|
|
110
|
-
function createInstance (): void {
|
|
111
|
-
if (flatpickrInstance.value === null && element.value !== null) {
|
|
112
|
-
flatpickrInstance.value = Flatpickr(element.value as Node, options.value);
|
|
113
|
-
|
|
114
|
-
flatpickrInstance.value.config.onChange.push(onChange);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Updates the current flatpickr instance and re-adds an event handler for the OnChange event.
|
|
120
|
-
*/
|
|
121
|
-
function updateInstance (): void {
|
|
122
|
-
if (flatpickrInstance.value !== null) {
|
|
123
|
-
flatpickrInstance.value.set(options.value);
|
|
124
|
-
|
|
125
|
-
flatpickrInstance.value.config.onChange.push(onChange);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Updates the selected value, in the flatpickr instance.
|
|
131
|
-
*
|
|
132
|
-
* @param value The new value.
|
|
133
|
-
*/
|
|
134
|
-
function updateInstanceValue (value: Date): void {
|
|
135
|
-
if (flatpickrInstance.value !== null) {
|
|
136
|
-
flatpickrInstance.value.setDate(value, true);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Removes the selected value, in the flatpickr instance.
|
|
142
|
-
*/
|
|
143
|
-
function clearInstanceValue (): void {
|
|
144
|
-
if (flatpickrInstance.value !== null) {
|
|
145
|
-
flatpickrInstance.value.clear();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Destroys the current flatpickr instance.
|
|
151
|
-
*/
|
|
152
|
-
function destroyInstance (): void {
|
|
153
|
-
if (flatpickrInstance.value !== null) {
|
|
154
|
-
flatpickrInstance.value.destroy();
|
|
155
|
-
|
|
156
|
-
flatpickrInstance.value = null;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
watch(() => props.date, (newValue, oldValue) => {
|
|
161
|
-
if (newValue !== null && oldValue !== null) {
|
|
162
|
-
if (newValue.getTime() !== oldValue.getTime()) {
|
|
163
|
-
updateInstanceValue(newValue);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
else if (newValue === null && oldValue !== null) {
|
|
167
|
-
clearInstanceValue();
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
deep: true
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
watch(() => options.value, updateInstance, {
|
|
174
|
-
deep: true
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
watch(() => props.type, () => {
|
|
178
|
-
destroyInstance();
|
|
179
|
-
|
|
180
|
-
nextTick(() => createInstance());
|
|
181
|
-
}, {
|
|
182
|
-
immediate: false
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
onMounted(() => createInstance());
|
|
186
|
-
|
|
187
|
-
onUnmounted(() => destroyInstance());
|
|
188
|
-
</script>
|
|
189
|
-
|
|
190
|
-
<style lang="postcss">
|
|
191
|
-
@import 'flatpickr/dist/flatpickr.css';
|
|
192
|
-
|
|
193
|
-
.flatpickr-calendar {
|
|
194
|
-
@apply shadow-lg;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.flatpickr-months {
|
|
198
|
-
@apply border-b border-grey-1 py-2 px-1;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.flatpickr-prev-month,
|
|
202
|
-
.flatpickr-next-month {
|
|
203
|
-
@apply mt-2;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
.flatpickr-months .flatpickr-next-month:hover svg,
|
|
207
|
-
.flatpickr-months .flatpickr-prev-month:hover svg {
|
|
208
|
-
@apply text-primary-default fill-current;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.cur-month {
|
|
212
|
-
@apply mr-1;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.flatpickr-current-month span.cur-month:hover {
|
|
216
|
-
@apply bg-white;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/* stylelint-disable selector-class-pattern */
|
|
220
|
-
|
|
221
|
-
.flatpickr-innerContainer {
|
|
222
|
-
@apply mb-1;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/* stylelint-enable selector-class-pattern */
|
|
226
|
-
|
|
227
|
-
.flatpickr-weekdays {
|
|
228
|
-
@apply bg-off-white mb-1 py-2;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
.flatpickr-day.selected {
|
|
232
|
-
@apply bg-primary-default border-primary-default hover:bg-primary-light hover:border-primary-light;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
.flatpickr-day.today {
|
|
236
|
-
@apply border-primary-default;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
.flatpickr-day.today:hover {
|
|
240
|
-
@apply bg-grey-1 text-grey-7;
|
|
241
|
-
}
|
|
242
|
-
</style>
|
|
243
|
-
|
|
244
|
-
<template>
|
|
245
|
-
<div v-bind="$attrs"
|
|
246
|
-
class="relative">
|
|
247
|
-
<input ref="element"
|
|
248
|
-
v-bind="$attrs"
|
|
249
|
-
class="!text-base !text-sm"
|
|
250
|
-
:class="{
|
|
251
|
-
'!pr-12': date !== null,
|
|
252
|
-
'!pr-8': date === null
|
|
253
|
-
}"
|
|
254
|
-
type="text"
|
|
255
|
-
:placeholder="type === 'date' ? datePlaceholder : dateTimePlaceholder"
|
|
256
|
-
:disabled="disabled">
|
|
257
|
-
|
|
258
|
-
<icon v-show="date === null || disabled"
|
|
259
|
-
class="absolute bg-white right-2 text-grey-4 top-3"
|
|
260
|
-
icon="ph:calendar"
|
|
261
|
-
weight="light"
|
|
262
|
-
:size="18" />
|
|
263
|
-
|
|
264
|
-
<div v-show="date !== null && !disabled"
|
|
265
|
-
class="absolute bg-white flex right-2 text-grey-4 top-3">
|
|
266
|
-
<icon class="cursor-pointer md:mr-1 mr-0.5"
|
|
267
|
-
icon="ph:arrow-counter-clockwise"
|
|
268
|
-
:size="16"
|
|
269
|
-
@click="resetValue" />
|
|
270
|
-
|
|
271
|
-
<icon class="cursor-pointer"
|
|
272
|
-
icon="ph:x"
|
|
273
|
-
:size="16"
|
|
274
|
-
@click="clearValue" />
|
|
275
|
-
</div>
|
|
276
|
-
</div>
|
|
277
|
-
</template>
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
type CardSize = 'small' | 'medium' | 'large';
|
|
3
|
-
|
|
4
|
-
withDefaults(defineProps<{
|
|
5
|
-
size?: CardSize;
|
|
6
|
-
title?: string;
|
|
7
|
-
hover?: boolean;
|
|
8
|
-
shadowSize?: CardSize;
|
|
9
|
-
padImage?: boolean;
|
|
10
|
-
}>(), {
|
|
11
|
-
size: 'medium',
|
|
12
|
-
title: '',
|
|
13
|
-
hover: false,
|
|
14
|
-
shadowSize: 'medium',
|
|
15
|
-
padImage: false
|
|
16
|
-
});
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<template>
|
|
20
|
-
<div class="overflow-hidden relative"
|
|
21
|
-
:class="{
|
|
22
|
-
'shadow': shadowSize === 'small',
|
|
23
|
-
'shadow-md': shadowSize === 'medium',
|
|
24
|
-
'shadow-lg': shadowSize === 'large',
|
|
25
|
-
|
|
26
|
-
'hover:shadow-md': hover && shadowSize === 'small',
|
|
27
|
-
'hover:shadow-lg': hover && shadowSize === 'medium',
|
|
28
|
-
'hover:shadow-xl': hover && shadowSize === 'large'
|
|
29
|
-
}">
|
|
30
|
-
<div v-if="$slots.image"
|
|
31
|
-
:class="{
|
|
32
|
-
'p-2': size === 'small' && padImage,
|
|
33
|
-
'p-4': size === 'medium' && padImage,
|
|
34
|
-
'p-8': size === 'large' && padImage
|
|
35
|
-
}">
|
|
36
|
-
<slot name="image"></slot>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<div v-if="title !== ''"
|
|
40
|
-
class="border-grey-2 font-normal"
|
|
41
|
-
:class="{
|
|
42
|
-
'p-2 text-xl leading-8': size === 'small',
|
|
43
|
-
'p-4 text-2xl leading-9': size === 'medium',
|
|
44
|
-
'p-8 text-4xl leading-10': size === 'large',
|
|
45
|
-
'border-t': $slots.image && padImage
|
|
46
|
-
}">
|
|
47
|
-
{{ title }}
|
|
48
|
-
</div>
|
|
49
|
-
|
|
50
|
-
<div class="border-grey-2"
|
|
51
|
-
:class="{
|
|
52
|
-
'p-2': size === 'small',
|
|
53
|
-
'p-4': size === 'medium',
|
|
54
|
-
'p-8': size === 'large',
|
|
55
|
-
'border-t': ($slots.image && padImage && title === '') || title !== ''
|
|
56
|
-
}">
|
|
57
|
-
<slot></slot>
|
|
58
|
-
</div>
|
|
59
|
-
|
|
60
|
-
<div v-if="$slots.footer"
|
|
61
|
-
class="border-grey-2 border-t"
|
|
62
|
-
:class="{
|
|
63
|
-
'p-2': size === 'small',
|
|
64
|
-
'p-4': size === 'medium',
|
|
65
|
-
'p-8': size === 'large'
|
|
66
|
-
}">
|
|
67
|
-
<slot name="footer"></slot>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
</template>
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, ref, watch } from 'vue';
|
|
3
|
-
|
|
4
|
-
import { ComboBoxItem, ComboBoxCreateRequest, ComboBoxCreateResponse, ComboBoxLocalisations, ComboBoxSearchContainerLocalisations } from '../../@types';
|
|
5
|
-
import { showNotification } from '../../composables/notification';
|
|
6
|
-
|
|
7
|
-
import ClUiComboBoxSearch from './search-container/cl-ui-combo-box-search.vue';
|
|
8
|
-
|
|
9
|
-
const props = withDefaults(defineProps<{
|
|
10
|
-
localisations?: ComboBoxLocalisations & ComboBoxSearchContainerLocalisations;
|
|
11
|
-
loading?: boolean;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
required?: boolean;
|
|
14
|
-
objectType: string;
|
|
15
|
-
objectParentType?: string;
|
|
16
|
-
canCreateNewObject?: boolean;
|
|
17
|
-
canClearSelectedObject?: boolean;
|
|
18
|
-
errorMessage?: string;
|
|
19
|
-
objectCreatedResponse?: ComboBoxCreateResponse | null;
|
|
20
|
-
parentObjectCreatedResponse?: ComboBoxCreateResponse | null;
|
|
21
|
-
results?: ComboBoxItem[];
|
|
22
|
-
parentResults?: ComboBoxItem[];
|
|
23
|
-
currentObject?: ComboBoxItem | null;
|
|
24
|
-
}>(), {
|
|
25
|
-
localisations: () => ({
|
|
26
|
-
emptyHintText: 'Choose a {0}',
|
|
27
|
-
createTitle: 'Create {0}',
|
|
28
|
-
createProperty: 'Name',
|
|
29
|
-
createParentTitle: 'Create {0}',
|
|
30
|
-
createParentyProperty: 'Name',
|
|
31
|
-
parentName: 'Object',
|
|
32
|
-
create: 'Create',
|
|
33
|
-
cancel: 'Cancel',
|
|
34
|
-
createSuccessful: 'Successfully created the {0} \'{1}\'',
|
|
35
|
-
createFailed: 'Could not create \'{0}\' - {1}',
|
|
36
|
-
required: 'Required',
|
|
37
|
-
|
|
38
|
-
searchHintText: 'Enter the {0} name',
|
|
39
|
-
errorMessage: 'An error has occurred: {0}',
|
|
40
|
-
addPrompt: 'Add \'{0}\' as new {1}',
|
|
41
|
-
noResults: '0 matching results for \'{0}\''
|
|
42
|
-
}),
|
|
43
|
-
loading: false,
|
|
44
|
-
disabled: false,
|
|
45
|
-
required: false,
|
|
46
|
-
objectParentType: '',
|
|
47
|
-
canCreateNewObject: false,
|
|
48
|
-
canClearSelectedObject: true,
|
|
49
|
-
errorMessage: '',
|
|
50
|
-
objectCreatedResponse: () => null,
|
|
51
|
-
parentObjectCreatedResponse: () => null,
|
|
52
|
-
results: () => [],
|
|
53
|
-
parentResults: () => [],
|
|
54
|
-
currentObject: () => null
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const emit = defineEmits({
|
|
58
|
-
search: null,
|
|
59
|
-
'search-parent': null,
|
|
60
|
-
'create-object': null,
|
|
61
|
-
'create-parent-object': null,
|
|
62
|
-
'update:current-object': null
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const searchContainerVisible = ref<boolean>(false);
|
|
66
|
-
|
|
67
|
-
const selectedItem = computed<ComboBoxItem | null>({
|
|
68
|
-
get: () => props.currentObject,
|
|
69
|
-
set: (value) => emit('update:current-object', value)
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const parentItem = ref<ComboBoxItem | null>(null);
|
|
73
|
-
const currentText = computed<string>(() => getDisplayName());
|
|
74
|
-
const hintText = computed<string>(() => props.localisations.emptyHintText.replacePlaceholders(props.objectType));
|
|
75
|
-
const createHeader = computed<string>(() => props.localisations.createTitle.replacePlaceholders(props.objectType));
|
|
76
|
-
|
|
77
|
-
const objectToCreateValue = ref<string>('');
|
|
78
|
-
const parentObjectToCreateValue = ref<string>('');
|
|
79
|
-
const createObjectRequest = ref<ComboBoxCreateRequest>();
|
|
80
|
-
const objectToCreateValid = ref<boolean>(true);
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Toggles the visibility of the dropdown.
|
|
84
|
-
*
|
|
85
|
-
* @param {boolean} forcedState - The state to force the visibility to.
|
|
86
|
-
*/
|
|
87
|
-
function toggleDropdown (forcedState?: boolean) : void {
|
|
88
|
-
if (!props.disabled) {
|
|
89
|
-
if (typeof forcedState !== 'undefined') {
|
|
90
|
-
searchContainerVisible.value = forcedState;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
searchContainerVisible.value = !searchContainerVisible.value;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Emit an event to get data filtered by the search term.
|
|
100
|
-
*
|
|
101
|
-
* @param {string} searchTerm - The search term.
|
|
102
|
-
*/
|
|
103
|
-
function search (searchTerm: string) : void {
|
|
104
|
-
objectToCreateValue.value = searchTerm;
|
|
105
|
-
emit('search', searchTerm);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Emit an event to get data for the parent, filtered by the search term.
|
|
110
|
-
*
|
|
111
|
-
* @param searchTerm - The search term.
|
|
112
|
-
*/
|
|
113
|
-
function searchParent (searchTerm: string) : void {
|
|
114
|
-
parentObjectToCreateValue.value = searchTerm;
|
|
115
|
-
emit('search-parent', searchTerm);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Clear the object that is currently set.
|
|
120
|
-
*/
|
|
121
|
-
function clearObject () : void {
|
|
122
|
-
selectedItem.value = null;
|
|
123
|
-
toggleDropdown(false);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Select an object by an id.
|
|
128
|
-
*
|
|
129
|
-
* @param {number} id - The id of the object.
|
|
130
|
-
*/
|
|
131
|
-
function selectObject (id: number) : void {
|
|
132
|
-
const item = getComboBoxItemById(id);
|
|
133
|
-
|
|
134
|
-
selectedItem.value = item;
|
|
135
|
-
toggleDropdown(false);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Get a combo box item by an id.
|
|
140
|
-
*
|
|
141
|
-
* @param {number} id - The id of the item.
|
|
142
|
-
* @returns {ComboBoxItem | null} - The combo box item with the id.
|
|
143
|
-
*/
|
|
144
|
-
function getComboBoxItemById (id: number) : ComboBoxItem | null {
|
|
145
|
-
let currentItem = null;
|
|
146
|
-
|
|
147
|
-
if (props.results !== null) {
|
|
148
|
-
for (let i = 0; i < props.results.length; i++) {
|
|
149
|
-
if (props.results[i].id === id) {
|
|
150
|
-
currentItem = props.results[i];
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return currentItem;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Emit an event to create a new object.
|
|
161
|
-
*/
|
|
162
|
-
function createObject () : void {
|
|
163
|
-
createObjectRequest.value = {
|
|
164
|
-
name: objectToCreateValue.value,
|
|
165
|
-
parentId: parentItem.value?.id ?? 0
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
emit('create-object', createObjectRequest.value);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Emit an event to create a new parent object.
|
|
173
|
-
*/
|
|
174
|
-
function createParentObject () : void {
|
|
175
|
-
createObjectRequest.value = {
|
|
176
|
-
name: parentObjectToCreateValue.value,
|
|
177
|
-
parentId: 0
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
emit('create-parent-object', createObjectRequest.value);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Handle the response after trying to create an object.
|
|
185
|
-
*/
|
|
186
|
-
function handleObjectCreateResponse () : void {
|
|
187
|
-
if (props.objectCreatedResponse?.error) {
|
|
188
|
-
showNotification({
|
|
189
|
-
message: props.localisations.createFailed.replacePlaceholders(objectToCreateValue.value, props.objectCreatedResponse.error),
|
|
190
|
-
colour: 'danger',
|
|
191
|
-
duration: 10000
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
else if (props.objectCreatedResponse?.id) {
|
|
195
|
-
handleSuccessfulObjectCreation();
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Handle the response after creating a parent object.
|
|
201
|
-
*/
|
|
202
|
-
function handleParentObjectCreateResponse (): void {
|
|
203
|
-
if (props.parentObjectCreatedResponse?.id) {
|
|
204
|
-
parentItem.value = {
|
|
205
|
-
id: props.parentObjectCreatedResponse.id,
|
|
206
|
-
name: props.parentObjectCreatedResponse.name ?? ''
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Handle the successful creation of an object.
|
|
213
|
-
*/
|
|
214
|
-
function handleSuccessfulObjectCreation () : void {
|
|
215
|
-
showNotification({
|
|
216
|
-
message: props.localisations.createSuccessful.replacePlaceholders(props.objectType, props.objectCreatedResponse?.name ?? ''),
|
|
217
|
-
colour: 'primary',
|
|
218
|
-
duration: 10000
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
let parentName = '';
|
|
222
|
-
|
|
223
|
-
if (parentItem.value && parentItem.value.id === props.objectCreatedResponse?.parentId) {
|
|
224
|
-
parentName = parentItem.value.name;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
selectedItem.value = {
|
|
228
|
-
id: props.objectCreatedResponse?.id ?? 0,
|
|
229
|
-
name: props.objectCreatedResponse?.name ?? '',
|
|
230
|
-
parentId: props.objectCreatedResponse?.parentId ?? 0,
|
|
231
|
-
parentName
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Get the name of the selected object to display on the root input.
|
|
237
|
-
*
|
|
238
|
-
* @returns {string} - The name to display.
|
|
239
|
-
*/
|
|
240
|
-
function getDisplayName () : string {
|
|
241
|
-
let name = '';
|
|
242
|
-
|
|
243
|
-
if (selectedItem.value) {
|
|
244
|
-
if (selectedItem.value.parentName) {
|
|
245
|
-
name = selectedItem.value.parentName + '; ' + selectedItem.value.name;
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
name = selectedItem.value.name;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return name;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Validate the object that will be created to determine whether
|
|
257
|
-
* a name has been entered and a parent object has been selected.
|
|
258
|
-
*/
|
|
259
|
-
function validateObjectToCreate () : void {
|
|
260
|
-
let valid = true;
|
|
261
|
-
|
|
262
|
-
if (objectToCreateValue.value === '') {
|
|
263
|
-
valid = false;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (props.objectParentType !== '' && parentItem.value === null) {
|
|
267
|
-
valid = false;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
objectToCreateValid.value = valid;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
watch(() => props.objectCreatedResponse, () => handleObjectCreateResponse());
|
|
274
|
-
watch(() => props.parentObjectCreatedResponse, () => handleParentObjectCreateResponse());
|
|
275
|
-
watch(() => objectToCreateValue.value, () => validateObjectToCreate());
|
|
276
|
-
watch(() => parentItem.value, () => validateObjectToCreate());
|
|
277
|
-
</script>
|
|
278
|
-
|
|
279
|
-
<template>
|
|
280
|
-
<div>
|
|
281
|
-
<div class="flex">
|
|
282
|
-
<input v-model="currentText"
|
|
283
|
-
class="!bg-transparent z-10"
|
|
284
|
-
:class="{ 'cursor-pointer': disabled === false }"
|
|
285
|
-
type="text"
|
|
286
|
-
:placeholder="hintText"
|
|
287
|
-
:disabled="disabled"
|
|
288
|
-
@focus="toggleDropdown(true)">
|
|
289
|
-
|
|
290
|
-
<div v-if="required && disabled === false"
|
|
291
|
-
class="relative right-20">
|
|
292
|
-
<div class="absolute flex float-right font-semibold mt-2 text-danger-default text-sm">
|
|
293
|
-
{{ localisations.required }}
|
|
294
|
-
|
|
295
|
-
<icon class="ml-1 mt-1"
|
|
296
|
-
icon="ph:warning" />
|
|
297
|
-
</div>
|
|
298
|
-
</div>
|
|
299
|
-
|
|
300
|
-
<div class="border border-grey-1 float-right hover:bg-primary-default hover:text-white px-1 py-2.5 text-grey-3 w-min"
|
|
301
|
-
:class="{
|
|
302
|
-
'bg-off-white cursor-default hover:bg-off-white hover:text-grey-3': disabled,
|
|
303
|
-
'cursor-pointer': disabled === false
|
|
304
|
-
}"
|
|
305
|
-
@click="toggleDropdown(true)">
|
|
306
|
-
<icon icon="ph:caret-down"
|
|
307
|
-
weight="fill" />
|
|
308
|
-
</div>
|
|
309
|
-
</div>
|
|
310
|
-
|
|
311
|
-
<cl-ui-modal size="x-small"
|
|
312
|
-
:title="createHeader"
|
|
313
|
-
:confirm-button="localisations.create"
|
|
314
|
-
:cancel-button="localisations.cancel"
|
|
315
|
-
:confirm-enabled="objectToCreateValid"
|
|
316
|
-
@confirm="createObject">
|
|
317
|
-
<template #trigger="{toggleModal}">
|
|
318
|
-
<cl-ui-combo-box-search v-show="searchContainerVisible"
|
|
319
|
-
:can-create-new-object="canCreateNewObject"
|
|
320
|
-
:can-clear-selected-object="canClearSelectedObject"
|
|
321
|
-
:localisations="localisations"
|
|
322
|
-
:loading="loading"
|
|
323
|
-
:results="results"
|
|
324
|
-
:object-type="objectType"
|
|
325
|
-
:object-parent-type="objectParentType"
|
|
326
|
-
:error-message="errorMessage"
|
|
327
|
-
:current-object-name="currentText"
|
|
328
|
-
:is-visible="searchContainerVisible"
|
|
329
|
-
@create-object="toggleModal"
|
|
330
|
-
@select-object="selectObject"
|
|
331
|
-
@clear-object="clearObject"
|
|
332
|
-
@search="search"
|
|
333
|
-
@hide-dropdown="toggleDropdown(false)" />
|
|
334
|
-
</template>
|
|
335
|
-
|
|
336
|
-
<cl-ui-combo-box v-if="objectParentType !== ''"
|
|
337
|
-
v-model:current-object="parentItem"
|
|
338
|
-
class="mt-3"
|
|
339
|
-
:results="parentResults"
|
|
340
|
-
:loading="loading"
|
|
341
|
-
:object-type="objectParentType"
|
|
342
|
-
:object-created-response="parentObjectCreatedResponse"
|
|
343
|
-
:can-create-new-object="canCreateNewObject"
|
|
344
|
-
:can-clear-selected-object="canClearSelectedObject"
|
|
345
|
-
:error-message="errorMessage"
|
|
346
|
-
@search="searchParent"
|
|
347
|
-
@create-object="createParentObject" />
|
|
348
|
-
|
|
349
|
-
<label class="mt-3">
|
|
350
|
-
{{ localisations.createProperty }}
|
|
351
|
-
</label>
|
|
352
|
-
|
|
353
|
-
<input v-model="objectToCreateValue"
|
|
354
|
-
type="text">
|
|
355
|
-
</cl-ui-modal>
|
|
356
|
-
</div>
|
|
357
|
-
</template>
|