@bagelink/vue 1.4.109 → 1.4.115
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/bin/generateFormSchema.ts +12 -12
- package/dist/components/Card.vue.d.ts.map +1 -1
- package/dist/components/ImportData.vue.d.ts.map +1 -1
- package/dist/components/ListItem.vue.d.ts +6 -1
- package/dist/components/ListItem.vue.d.ts.map +1 -1
- package/dist/components/analytics/BarChart.vue.d.ts +39 -0
- package/dist/components/analytics/BarChart.vue.d.ts.map +1 -0
- package/dist/components/analytics/KpiCard.vue.d.ts +24 -0
- package/dist/components/analytics/KpiCard.vue.d.ts.map +1 -0
- package/dist/components/analytics/LineChart.vue.d.ts +26 -0
- package/dist/components/analytics/LineChart.vue.d.ts.map +1 -0
- package/dist/components/analytics/PieChart.vue.d.ts +24 -0
- package/dist/components/analytics/PieChart.vue.d.ts.map +1 -0
- package/dist/components/analytics/index.d.ts +5 -0
- package/dist/components/analytics/index.d.ts.map +1 -0
- package/dist/components/calendar/Index.vue.d.ts.map +1 -1
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.d.ts.map +1 -0
- package/dist/components/calendar/views/MonthView.vue.d.ts.map +1 -1
- package/dist/components/calendar/views/WeekView.vue.d.ts.map +1 -1
- package/dist/components/dataTable/DataTable.vue.d.ts.map +1 -1
- package/dist/components/form/BagelForm.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DatePicker.vue.d.ts +2 -0
- package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RadioGroup.vue.d.ts +6 -10
- package/dist/components/form/inputs/RadioGroup.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/utils/media.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts +2 -2
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/layout/AppContent.vue.d.ts +34 -0
- package/dist/components/layout/AppContent.vue.d.ts.map +1 -0
- package/dist/components/layout/AppLayout.vue.d.ts +27 -0
- package/dist/components/layout/AppLayout.vue.d.ts.map +1 -0
- package/dist/components/layout/AppSidebar.vue.d.ts +44 -0
- package/dist/components/layout/AppSidebar.vue.d.ts.map +1 -0
- package/dist/components/layout/index.d.ts +3 -0
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/composables/useFormField.d.ts.map +1 -1
- package/dist/composables/useSchemaField.d.ts +2 -2
- package/dist/composables/useSchemaField.d.ts.map +1 -1
- package/dist/index.cjs +19 -19
- package/dist/index.mjs +10 -10
- package/dist/style.css +1 -1
- package/dist/types/BagelForm.d.ts +25 -13
- package/dist/types/BagelForm.d.ts.map +1 -1
- package/dist/utils/BagelFormUtils.d.ts +11 -8
- package/dist/utils/BagelFormUtils.d.ts.map +1 -1
- package/dist/utils/calendar/dateUtils.d.ts +21 -0
- package/dist/utils/calendar/dateUtils.d.ts.map +1 -1
- package/dist/utils/elementUtils.d.ts +5 -0
- package/dist/utils/elementUtils.d.ts.map +1 -1
- package/dist/utils/useSearch.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Card.vue +1 -2
- package/src/components/DataPreview.vue +1 -1
- package/src/components/ImportData.vue +94 -88
- package/src/components/ListItem.vue +32 -24
- package/src/components/analytics/BarChart.vue +153 -0
- package/src/components/analytics/KpiCard.vue +84 -0
- package/src/components/analytics/LineChart.vue +267 -0
- package/src/components/analytics/PieChart.vue +183 -0
- package/src/components/analytics/index.ts +4 -0
- package/src/components/calendar/Index.vue +15 -35
- package/src/components/calendar/views/MonthView.vue +84 -88
- package/src/components/calendar/views/WeekView.vue +143 -89
- package/src/components/dataTable/DataTable.vue +2 -3
- package/src/components/form/BagelForm.vue +27 -6
- package/src/components/form/inputs/DateInput.vue +2 -2
- package/src/components/form/inputs/DatePicker.vue +42 -48
- package/src/components/form/inputs/RadioGroup.vue +60 -35
- package/src/components/form/inputs/RichText/utils/media.ts +1 -2
- package/src/components/form/inputs/SelectInput.vue +94 -101
- package/src/components/form/inputs/Upload/upload.css +135 -138
- package/src/components/layout/AppContent.vue +125 -0
- package/src/components/layout/AppLayout.vue +124 -0
- package/src/components/layout/AppSidebar.vue +271 -0
- package/src/components/layout/index.ts +5 -0
- package/src/composables/useFormField.ts +6 -0
- package/src/composables/useSchemaField.ts +38 -10
- package/src/styles/inputs.css +9 -0
- package/src/styles/theme.css +2 -2
- package/src/types/BagelForm.ts +68 -13
- package/src/utils/BagelFormUtils.ts +49 -52
- package/src/utils/calendar/dateUtils.ts +71 -17
- package/src/utils/elementUtils.ts +23 -4
- package/src/utils/useSearch.ts +14 -7
- /package/src/components/{dialog → calendar}/index.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArrayBagelField, ArrayFieldVal, Attributes, BaseBagelField, BglFormSchemaT, FieldByP, IconType, InputBagelField,
|
|
1
|
+
import type { ArrayBagelField, ArrayFieldVal, Attributes, BaseBagelField, BglFormSchemaT, FieldByP, IconType, InputBagelField, Path, SchemaChild, SelectBagelField, ShallowBglFormSchemaT, UploadInputProps } from '@bagelink/vue'
|
|
2
2
|
import type { DefaultPathsOptions, PathsOptions } from 'type-fest/source/paths'
|
|
3
3
|
import type { InputTypeHTMLAttribute, MaybeRefOrGetter } from 'vue'
|
|
4
4
|
|
|
@@ -33,7 +33,6 @@ export interface SlctInputOptions<T, K extends Path<T>> extends InputOptions<T,
|
|
|
33
33
|
searchable?: boolean
|
|
34
34
|
multiselect?: boolean
|
|
35
35
|
clearable?: boolean
|
|
36
|
-
onSearch?: (search: string) => any
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
export interface NumFieldOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
@@ -86,71 +85,64 @@ export function richText<
|
|
|
86
85
|
|
|
87
86
|
export function txtField<
|
|
88
87
|
T,
|
|
89
|
-
P extends Path<T, PO>,
|
|
90
88
|
PO extends PathsOptions = DefaultPathsOptions,
|
|
91
89
|
>(
|
|
92
|
-
id?:
|
|
90
|
+
id?: Path<T, PO>,
|
|
93
91
|
label?: string,
|
|
94
|
-
options?: TextInputOptions<T,
|
|
95
|
-
): InputBagelField<T,
|
|
92
|
+
options?: TextInputOptions<T, Path<T, PO>>,
|
|
93
|
+
): InputBagelField<T, Path<T, PO>, PO> {
|
|
96
94
|
return {
|
|
97
95
|
$el: 'text',
|
|
98
96
|
id,
|
|
99
97
|
label,
|
|
100
98
|
class: options?.class,
|
|
101
99
|
required: options?.required,
|
|
102
|
-
vIf: options?.vIf,
|
|
103
|
-
disabled: options?.disabled,
|
|
104
100
|
placeholder: options?.placeholder,
|
|
105
|
-
defaultValue: options?.defaultValue,
|
|
106
|
-
validate: options?.validate,
|
|
107
|
-
onUpdate: options?.onUpdate,
|
|
108
101
|
helptext: options?.helptext,
|
|
102
|
+
disabled: options?.disabled,
|
|
103
|
+
defaultValue: options?.defaultValue,
|
|
104
|
+
vIf: options?.vIf,
|
|
109
105
|
transform: options?.transform,
|
|
110
106
|
attrs: {
|
|
111
|
-
|
|
107
|
+
autocomplete: options?.autocomplete,
|
|
112
108
|
pattern: options?.pattern,
|
|
113
109
|
multiline: options?.multiline,
|
|
114
|
-
autocomplete: options?.autocomplete,
|
|
115
|
-
rows: options?.rows,
|
|
116
|
-
code: options?.code,
|
|
117
110
|
autoheight: options?.autoheight,
|
|
111
|
+
code: options?.code,
|
|
112
|
+
rows: options?.rows,
|
|
118
113
|
icon: options?.icon,
|
|
119
114
|
iconStart: options?.iconStart,
|
|
115
|
+
type: options?.type,
|
|
120
116
|
},
|
|
121
117
|
}
|
|
122
118
|
}
|
|
123
119
|
|
|
124
120
|
export function selectField<
|
|
125
121
|
T,
|
|
126
|
-
P extends Path<T, PO>,
|
|
127
122
|
PO extends PathsOptions = DefaultPathsOptions,
|
|
128
123
|
>(
|
|
129
|
-
id?:
|
|
124
|
+
id?: Path<T, PO>,
|
|
130
125
|
label?: string,
|
|
131
|
-
options?:
|
|
132
|
-
|
|
133
|
-
): SelectBagelField<T,
|
|
126
|
+
options?: any[],
|
|
127
|
+
fieldOptions?: SlctInputOptions<T, Path<T, PO>>,
|
|
128
|
+
): SelectBagelField<T, Path<T, PO>, PO> {
|
|
134
129
|
return {
|
|
135
130
|
$el: 'select',
|
|
136
131
|
id,
|
|
137
|
-
options,
|
|
138
|
-
class: config?.class,
|
|
139
|
-
placeholder: config?.placeholder,
|
|
140
|
-
required: config?.required,
|
|
141
132
|
label,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
133
|
+
class: fieldOptions?.class,
|
|
134
|
+
required: fieldOptions?.required,
|
|
135
|
+
helptext: fieldOptions?.helptext,
|
|
136
|
+
disabled: fieldOptions?.disabled,
|
|
137
|
+
defaultValue: fieldOptions?.defaultValue,
|
|
138
|
+
vIf: fieldOptions?.vIf,
|
|
139
|
+
transform: fieldOptions?.transform,
|
|
140
|
+
options,
|
|
147
141
|
attrs: {
|
|
148
|
-
|
|
149
|
-
searchable:
|
|
150
|
-
multiselect:
|
|
151
|
-
|
|
152
|
-
clearable: config?.clearable,
|
|
153
|
-
autocomplete: config?.autocomplete,
|
|
142
|
+
...fieldOptions?.attrs,
|
|
143
|
+
searchable: fieldOptions?.searchable,
|
|
144
|
+
multiselect: fieldOptions?.multiselect,
|
|
145
|
+
clearable: fieldOptions?.clearable,
|
|
154
146
|
},
|
|
155
147
|
}
|
|
156
148
|
}
|
|
@@ -164,22 +156,25 @@ interface CheckInputOptions<T, K extends Path<T>> extends Omit<InputOptions<T, K
|
|
|
164
156
|
|
|
165
157
|
export function checkField<
|
|
166
158
|
T,
|
|
167
|
-
P extends Path<T, PO>,
|
|
168
159
|
PO extends PathsOptions = DefaultPathsOptions,
|
|
169
160
|
>(
|
|
170
|
-
id?:
|
|
161
|
+
id?: Path<T, PO>,
|
|
171
162
|
label?: string,
|
|
172
|
-
options?: CheckInputOptions<T,
|
|
173
|
-
): BaseBagelField<T,
|
|
163
|
+
options?: CheckInputOptions<T, Path<T, PO>>,
|
|
164
|
+
): BaseBagelField<T, Path<T, PO>, PO> {
|
|
174
165
|
return {
|
|
175
166
|
$el: 'check',
|
|
167
|
+
id,
|
|
168
|
+
label,
|
|
176
169
|
class: options?.class,
|
|
177
170
|
required: options?.required,
|
|
171
|
+
helptext: options?.helptext,
|
|
172
|
+
disabled: options?.disabled,
|
|
178
173
|
defaultValue: options?.defaultValue,
|
|
179
|
-
|
|
180
|
-
label,
|
|
174
|
+
vIf: options?.vIf,
|
|
181
175
|
transform: options?.transform,
|
|
182
176
|
attrs: {
|
|
177
|
+
...options?.attrs,
|
|
183
178
|
value: options?.value,
|
|
184
179
|
},
|
|
185
180
|
}
|
|
@@ -249,13 +244,12 @@ export function dateField<
|
|
|
249
244
|
|
|
250
245
|
export function numField<
|
|
251
246
|
T,
|
|
252
|
-
P extends Path<T, PO>,
|
|
253
247
|
PO extends PathsOptions = DefaultPathsOptions,
|
|
254
248
|
>(
|
|
255
|
-
id?:
|
|
249
|
+
id?: Path<T, PO>,
|
|
256
250
|
label?: string,
|
|
257
|
-
options?: NumFieldOptions<T,
|
|
258
|
-
): BaseBagelField<T,
|
|
251
|
+
options?: NumFieldOptions<T, Path<T, PO>>,
|
|
252
|
+
): BaseBagelField<T, Path<T, PO>, PO> {
|
|
259
253
|
return {
|
|
260
254
|
$el: 'number',
|
|
261
255
|
class: options?.class,
|
|
@@ -283,11 +277,10 @@ export function numField<
|
|
|
283
277
|
|
|
284
278
|
export function frmRow<
|
|
285
279
|
T,
|
|
286
|
-
P extends Path<T, PO>,
|
|
287
280
|
PO extends PathsOptions = DefaultPathsOptions,
|
|
288
281
|
>(
|
|
289
|
-
...children: SchemaChild<T,
|
|
290
|
-
):
|
|
282
|
+
...children: SchemaChild<T, Path<T, PO>, PO>[]
|
|
283
|
+
): { $el: string, class: string, children: SchemaChild<T, Path<T, PO>, PO>[] } {
|
|
291
284
|
return {
|
|
292
285
|
$el: 'div',
|
|
293
286
|
class: 'flex gap-1 m_block align-items-end',
|
|
@@ -299,17 +292,21 @@ export interface UploadOptions<T, K extends Path<T>> extends Omit<UploadInputPro
|
|
|
299
292
|
|
|
300
293
|
export function uploadField<
|
|
301
294
|
T,
|
|
302
|
-
P extends Path<T, PO>,
|
|
303
295
|
PO extends PathsOptions = DefaultPathsOptions,
|
|
304
296
|
>(
|
|
305
|
-
id?:
|
|
297
|
+
id?: Path<T, PO>,
|
|
306
298
|
label?: string,
|
|
307
|
-
options?: UploadOptions<T,
|
|
308
|
-
): BaseBagelField<T,
|
|
299
|
+
options?: UploadOptions<T, Path<T, PO>>,
|
|
300
|
+
): BaseBagelField<T, Path<T, PO>, PO> {
|
|
309
301
|
return {
|
|
310
302
|
$el: 'upload',
|
|
311
303
|
id,
|
|
312
304
|
label,
|
|
305
|
+
class: options?.class,
|
|
306
|
+
required: options?.required,
|
|
307
|
+
helptext: options?.helptext,
|
|
308
|
+
disabled: options?.disabled,
|
|
309
|
+
defaultValue: options?.defaultValue,
|
|
313
310
|
vIf: options?.vIf,
|
|
314
311
|
transform: options?.transform,
|
|
315
312
|
attrs: {
|
|
@@ -9,31 +9,53 @@ interface TimeDeltaOptions {
|
|
|
9
9
|
Week?: number
|
|
10
10
|
Month?: number
|
|
11
11
|
Year?: number
|
|
12
|
+
days?: number
|
|
13
|
+
hours?: number
|
|
14
|
+
minutes?: number
|
|
15
|
+
seconds?: number
|
|
16
|
+
weeks?: number
|
|
17
|
+
months?: number
|
|
18
|
+
years?: number
|
|
19
|
+
day?: number
|
|
20
|
+
hour?: number
|
|
21
|
+
minute?: number
|
|
22
|
+
second?: number
|
|
23
|
+
week?: number
|
|
24
|
+
month?: number
|
|
25
|
+
year?: number
|
|
12
26
|
}
|
|
13
27
|
|
|
14
28
|
export function timeDelta(date: string | Date, options: TimeDeltaOptions) {
|
|
29
|
+
console.log('date', date)
|
|
15
30
|
date = new Date(date)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
31
|
+
console.log('date', date)
|
|
32
|
+
const day = options.Day || options.day || options.days || 0
|
|
33
|
+
const hour = options.Hour || options.hour || options.hours || 0
|
|
34
|
+
const minute = options.Minute || options.minute || options.minutes || 0
|
|
35
|
+
const second = options.Second || options.second || options.seconds || 0
|
|
36
|
+
const week = options.Week || options.week || options.weeks || 0
|
|
37
|
+
const month = options.Month || options.month || options.months || 0
|
|
38
|
+
const year = options.Year || options.year || options.years || 0
|
|
39
|
+
if (day) {
|
|
40
|
+
date.setDate(date.getDate() + day)
|
|
19
41
|
}
|
|
20
|
-
if (
|
|
21
|
-
date.setHours(date.getHours() +
|
|
42
|
+
if (hour) {
|
|
43
|
+
date.setHours(date.getHours() + hour)
|
|
22
44
|
}
|
|
23
|
-
if (
|
|
24
|
-
date.setMinutes(date.getMinutes() +
|
|
45
|
+
if (minute) {
|
|
46
|
+
date.setMinutes(date.getMinutes() + minute)
|
|
25
47
|
}
|
|
26
|
-
if (
|
|
27
|
-
date.setSeconds(date.getSeconds() +
|
|
48
|
+
if (second) {
|
|
49
|
+
date.setSeconds(date.getSeconds() + second)
|
|
28
50
|
}
|
|
29
|
-
if (
|
|
30
|
-
date.setDate(date.getDate() +
|
|
51
|
+
if (week) {
|
|
52
|
+
date.setDate(date.getDate() + week * 7)
|
|
31
53
|
}
|
|
32
|
-
if (
|
|
33
|
-
date.setMonth(date.getMonth() +
|
|
54
|
+
if (month) {
|
|
55
|
+
date.setMonth(date.getMonth() + month)
|
|
34
56
|
}
|
|
35
|
-
if (
|
|
36
|
-
date.setFullYear(date.getFullYear() +
|
|
57
|
+
if (year) {
|
|
58
|
+
date.setFullYear(date.getFullYear() + year)
|
|
37
59
|
}
|
|
38
60
|
return date
|
|
39
61
|
}
|
|
@@ -247,20 +269,52 @@ export interface FormatDateOptions extends Partial<Pick<Intl.DateTimeFormatOptio
|
|
|
247
269
|
locale?: Intl.LocalesArgument
|
|
248
270
|
tz?: string
|
|
249
271
|
}
|
|
272
|
+
|
|
250
273
|
/**
|
|
251
274
|
* Formats a date based on the provided format string, locale, and timezone.
|
|
252
275
|
* @param date The date to format (string or Date object).
|
|
276
|
+
* @param format The format string (default is 'DD.MM.YY').
|
|
277
|
+
* @returns Formatted date string.
|
|
278
|
+
*/
|
|
279
|
+
export function formatDate(date?: DateLike, format?: DateTimeAcceptedFormats): string
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Formats a date based on the provided options.
|
|
283
|
+
* @param date The date to format (string or Date object).
|
|
253
284
|
* @param opts Options for formatting the date.
|
|
254
285
|
* @param opts.fmt The format string (default is 'DD.MM.YY').
|
|
255
286
|
* @param opts.locale The locale to use for formatting (default is browser's locale).
|
|
256
287
|
* @param opts.tz The timezone to use for formatting (default is local timezone).
|
|
257
288
|
* @returns Formatted date string.
|
|
258
289
|
*/
|
|
290
|
+
export function formatDate(date?: DateLike, opts?: FormatDateOptions): string
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Formats a date based on the provided format string, locale, and timezone.
|
|
294
|
+
* @param date The date to format (string or Date object).
|
|
295
|
+
* @param formatOrOpts The format string or options object.
|
|
296
|
+
* @returns Formatted date string.
|
|
297
|
+
*/
|
|
259
298
|
export function formatDate(
|
|
260
299
|
date?: DateLike,
|
|
261
|
-
|
|
300
|
+
formatOrOpts?: DateTimeAcceptedFormats | FormatDateOptions,
|
|
262
301
|
): string {
|
|
263
|
-
let
|
|
302
|
+
let format: DateTimeAcceptedFormats | undefined
|
|
303
|
+
let locale: Intl.LocalesArgument | undefined
|
|
304
|
+
let timeZone: string | undefined
|
|
305
|
+
let rest: Partial<Pick<Intl.DateTimeFormatOptions, 'hour12'>> = {}
|
|
306
|
+
|
|
307
|
+
// Handle both overloads
|
|
308
|
+
if (typeof formatOrOpts === 'string') {
|
|
309
|
+
// First overload: format string directly
|
|
310
|
+
format = formatOrOpts
|
|
311
|
+
} else if (formatOrOpts && typeof formatOrOpts === 'object') {
|
|
312
|
+
// Second overload: options object
|
|
313
|
+
format = formatOrOpts.fmt
|
|
314
|
+
locale = formatOrOpts.locale
|
|
315
|
+
timeZone = formatOrOpts.tz
|
|
316
|
+
rest = formatOrOpts
|
|
317
|
+
}
|
|
264
318
|
|
|
265
319
|
if (!date) return ''
|
|
266
320
|
format = format || 'DD.MM.YY'
|
|
@@ -22,6 +22,14 @@ export interface BtnElementOptions<
|
|
|
22
22
|
target?: '_blank' | '_self' | '_parent' | '_top'
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export interface PillElementOptions<
|
|
26
|
+
T = any,
|
|
27
|
+
PO extends PathsOptions = DefaultPathsOptions
|
|
28
|
+
> extends Partial<BaseElementField<T, PO>> {
|
|
29
|
+
color?: string
|
|
30
|
+
icon?: IconType
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
export interface TxtElementOptions<
|
|
26
34
|
T = any,
|
|
27
35
|
PO extends PathsOptions = DefaultPathsOptions
|
|
@@ -345,20 +353,17 @@ export function img<
|
|
|
345
353
|
): BaseElementField<T, PO> {
|
|
346
354
|
// Handle different overload patterns
|
|
347
355
|
let id: Path<T, PO> | undefined
|
|
348
|
-
let finalSrc: string = ''
|
|
349
356
|
let finalOptions: ImgElementOptions<T, PO> = {}
|
|
350
357
|
|
|
351
358
|
if (typeof idOrOptions === 'object' && idOrOptions !== null) {
|
|
352
359
|
// img(options)
|
|
353
360
|
finalOptions = idOrOptions
|
|
354
|
-
const { id: optionId
|
|
361
|
+
const { id: optionId } = finalOptions
|
|
355
362
|
id = optionId as Path<T, PO> | undefined
|
|
356
|
-
finalSrc = optionSrc ?? ''
|
|
357
363
|
} else {
|
|
358
364
|
// img(id, ...) patterns
|
|
359
365
|
id = idOrOptions
|
|
360
366
|
if (src != null) {
|
|
361
|
-
finalSrc = src
|
|
362
367
|
if (typeof altOrOptions === 'string') {
|
|
363
368
|
// img(id, src, alt)
|
|
364
369
|
finalOptions = { alt: altOrOptions }
|
|
@@ -388,6 +393,20 @@ export function img<
|
|
|
388
393
|
}
|
|
389
394
|
}
|
|
390
395
|
|
|
396
|
+
export function pill<
|
|
397
|
+
T = any,
|
|
398
|
+
PO extends PathsOptions = DefaultPathsOptions
|
|
399
|
+
>(options: PillElementOptions<T, PO>): BaseElementField<T, PO> {
|
|
400
|
+
return {
|
|
401
|
+
$el: 'pill',
|
|
402
|
+
id: options?.id,
|
|
403
|
+
class: options?.class,
|
|
404
|
+
vIf: options?.vIf,
|
|
405
|
+
style: options?.style,
|
|
406
|
+
attrs: options?.attrs || {},
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
391
410
|
export function dropdown<
|
|
392
411
|
T = any,
|
|
393
412
|
PO extends PathsOptions = DefaultPathsOptions
|
package/src/utils/useSearch.ts
CHANGED
|
@@ -372,8 +372,10 @@ export function useSearch<T>(
|
|
|
372
372
|
clearTimeout(debounceTimeout)
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
|
|
376
|
-
|
|
375
|
+
const term = typeof newTerm === 'string' ? newTerm : ''
|
|
376
|
+
|
|
377
|
+
// Allow initial/default fetch when minChars === 0 (including empty term)
|
|
378
|
+
if (term.length < minChars && minChars > 0) {
|
|
377
379
|
serverResults.value = []
|
|
378
380
|
return
|
|
379
381
|
}
|
|
@@ -382,7 +384,7 @@ export function useSearch<T>(
|
|
|
382
384
|
debounceTimeout = window.setTimeout(async () => {
|
|
383
385
|
try {
|
|
384
386
|
isLoading.value = true
|
|
385
|
-
serverResults.value = await serverSearch(
|
|
387
|
+
serverResults.value = await serverSearch(term)
|
|
386
388
|
} catch (error) {
|
|
387
389
|
console.error('Server search error:', error)
|
|
388
390
|
serverResults.value = []
|
|
@@ -390,7 +392,8 @@ export function useSearch<T>(
|
|
|
390
392
|
isLoading.value = false
|
|
391
393
|
}
|
|
392
394
|
}, debounceMs)
|
|
393
|
-
}
|
|
395
|
+
},
|
|
396
|
+
{ immediate: true }
|
|
394
397
|
)
|
|
395
398
|
}
|
|
396
399
|
|
|
@@ -401,9 +404,13 @@ export function useSearch<T>(
|
|
|
401
404
|
const getFilteredResults = (): T[] => {
|
|
402
405
|
const term = getSearchTermValue()
|
|
403
406
|
|
|
404
|
-
// If using server-side search
|
|
405
|
-
if (serverSearch
|
|
406
|
-
|
|
407
|
+
// If using server-side search
|
|
408
|
+
if (serverSearch) {
|
|
409
|
+
if (term && typeof term === 'string' && term.length >= minChars) {
|
|
410
|
+
return serverResults.value as T[]
|
|
411
|
+
}
|
|
412
|
+
// If minChars is 0, allow default server results when empty
|
|
413
|
+
if (minChars === 0) return serverResults.value as T[]
|
|
407
414
|
}
|
|
408
415
|
|
|
409
416
|
// Otherwise use client-side filtering
|
|
File without changes
|