@bagelink/vue 1.15.205 → 1.15.209
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/components/AddressSearch.vue.d.ts.map +1 -1
- package/dist/components/Swiper.vue.d.ts +2 -2
- package/dist/components/calendar/CalendarPopover.vue.d.ts.map +1 -1
- package/dist/components/charts/MapChart.vue.d.ts +4 -0
- package/dist/components/charts/MapChart.vue.d.ts.map +1 -1
- package/dist/components/dataTable/DataTable.vue.d.ts +4 -2
- package/dist/components/dataTable/DataTable.vue.d.ts.map +1 -1
- package/dist/components/dataTable/useTableVirtualization.d.ts +25 -0
- package/dist/components/dataTable/useTableVirtualization.d.ts.map +1 -0
- package/dist/components/form/inputs/ArrayInput.vue.d.ts +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SignaturePad.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ToggleInput.vue.d.ts +1 -0
- package/dist/components/form/inputs/ToggleInput.vue.d.ts.map +1 -1
- package/dist/form-flow/FormFlow.vue.d.ts.map +1 -1
- package/dist/index.cjs +152 -175
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +37531 -31161
- package/dist/style.css +2 -1
- package/dist/utils/BagelFormUtils.d.ts +111 -0
- package/dist/utils/BagelFormUtils.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/charts/MapChart.vue +191 -24
- package/src/components/dataTable/DataTable.vue +20 -4
- package/src/components/form/inputs/ArrayInput.vue +3 -3
- package/src/components/form/inputs/EmailInput.vue +1 -1
- package/src/components/form/inputs/NumberInput.vue +1 -1
- package/src/components/form/inputs/SelectInput.vue +3 -3
- package/src/components/form/inputs/SignaturePad.vue +0 -7
- package/src/components/form/inputs/TextInput.vue +1 -1
- package/src/components/form/inputs/ToggleInput.vue +8 -0
- package/src/form-flow/FormFlow.vue +9 -4
- package/src/index.ts +1 -0
- package/src/styles/inputs.css +18 -0
- package/src/utils/BagelFormUtils.ts +341 -0
package/src/styles/inputs.css
CHANGED
|
@@ -59,6 +59,24 @@ select {
|
|
|
59
59
|
color: var(--bgl-input-label-active-color);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
.helptext {
|
|
63
|
+
display: block;
|
|
64
|
+
margin: 0.15rem 0 0.25rem;
|
|
65
|
+
line-height: 1.4;
|
|
66
|
+
font-size: var(--bgl-label-font-size);
|
|
67
|
+
font-weight: 300;
|
|
68
|
+
color: var(--bgl-label-color);
|
|
69
|
+
cursor: default;
|
|
70
|
+
user-select: text;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Keep helptext muted even when nested inside a focused/active label */
|
|
74
|
+
.bagel-input:focus-within .helptext,
|
|
75
|
+
.bagel-input.open .helptext,
|
|
76
|
+
.bagel-input:has(:checked) .helptext {
|
|
77
|
+
color: var(--bgl-label-color);
|
|
78
|
+
}
|
|
79
|
+
|
|
62
80
|
.bagel-input input,
|
|
63
81
|
.bagel-input select,
|
|
64
82
|
.custom-select .input {
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BagelFormUtils — legacy `$el`-based schema-builder helpers.
|
|
3
|
+
*
|
|
4
|
+
* These construct `BaseBagelField` descriptors for the object-schema form
|
|
5
|
+
* renderer (`BagelForm` / `BglFormSchemaT`). Retained for backwards
|
|
6
|
+
* compatibility with consumers (e.g. Blox block configs) that author form
|
|
7
|
+
* schemas with `txtField`/`slctField`/`frmRow`/… rather than the newer
|
|
8
|
+
* `defineSchema`/FormFlow API. Pure factory functions, no runtime deps.
|
|
9
|
+
*
|
|
10
|
+
* Re-exported as the `bagelFormUtils` namespace from the package root.
|
|
11
|
+
*/
|
|
12
|
+
import type {
|
|
13
|
+
BaseBagelField,
|
|
14
|
+
BglFormSchemaT,
|
|
15
|
+
Field,
|
|
16
|
+
Path,
|
|
17
|
+
SchemaChild,
|
|
18
|
+
UploadInputProps,
|
|
19
|
+
} from '../types/BagelForm'
|
|
20
|
+
import type { IconType, Option } from '../types'
|
|
21
|
+
|
|
22
|
+
interface InputOptions<T, P extends Path<T>> extends Partial<BaseBagelField<T, P>> {
|
|
23
|
+
defaultValue?: string | number
|
|
24
|
+
autocomplete?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface DateOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
28
|
+
enableTime?: boolean
|
|
29
|
+
mode?: 'day' | 'month' | 'year'
|
|
30
|
+
locale?: string
|
|
31
|
+
timezone?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface TextInputOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
35
|
+
type?: 'text' | 'tel' | 'email' | 'time'
|
|
36
|
+
pattern?: string
|
|
37
|
+
multiline?: boolean
|
|
38
|
+
autoheight?: boolean
|
|
39
|
+
code?: boolean
|
|
40
|
+
rows?: number | string
|
|
41
|
+
icon?: IconType
|
|
42
|
+
iconStart?: IconType
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface SlctInputOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
46
|
+
searchable?: boolean
|
|
47
|
+
multiselect?: boolean
|
|
48
|
+
clearable?: boolean
|
|
49
|
+
onSearch?: (search: string) => any
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface NumFieldOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
53
|
+
max?: number
|
|
54
|
+
min?: number
|
|
55
|
+
step?: number
|
|
56
|
+
layout?: 'default' | 'vertical' | 'horizontal'
|
|
57
|
+
padZero?: number
|
|
58
|
+
center?: boolean
|
|
59
|
+
useGrouping?: boolean
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
type RichTextOptions<T, P extends Path<T>> = InputOptions<T, P>
|
|
63
|
+
|
|
64
|
+
export function getBaseField<T, P extends Path<T>>(
|
|
65
|
+
id?: P,
|
|
66
|
+
labelOrRest: string | Partial<BaseBagelField<T, P>> = {},
|
|
67
|
+
rest: Partial<BaseBagelField<T, P>> = {},
|
|
68
|
+
): BaseBagelField<T, P> {
|
|
69
|
+
if (typeof labelOrRest === 'object') return { id, ...labelOrRest }
|
|
70
|
+
return { id, label: labelOrRest, ...rest }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function richText<T, P extends Path<T>>(id: P, label?: string, options?: RichTextOptions<T, P>): BaseBagelField<T, P> {
|
|
74
|
+
return {
|
|
75
|
+
$el: 'richtext',
|
|
76
|
+
class: options?.class,
|
|
77
|
+
required: options?.required,
|
|
78
|
+
id,
|
|
79
|
+
label,
|
|
80
|
+
vIf: options?.vIf,
|
|
81
|
+
placeholder: options?.placeholder,
|
|
82
|
+
attrs: { autocomplete: options?.autocomplete },
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function txtField<T, P extends Path<T>>(id: P, label?: string, options?: TextInputOptions<T, P>): BaseBagelField<T, P> {
|
|
87
|
+
return {
|
|
88
|
+
$el: 'text',
|
|
89
|
+
id,
|
|
90
|
+
label,
|
|
91
|
+
class: options?.class,
|
|
92
|
+
required: options?.required,
|
|
93
|
+
vIf: options?.vIf,
|
|
94
|
+
disabled: options?.disabled,
|
|
95
|
+
placeholder: options?.placeholder,
|
|
96
|
+
defaultValue: options?.defaultValue,
|
|
97
|
+
validate: options?.validate,
|
|
98
|
+
onUpdate: options?.onUpdate,
|
|
99
|
+
attrs: {
|
|
100
|
+
type: options?.type,
|
|
101
|
+
pattern: options?.pattern,
|
|
102
|
+
multiline: options?.multiline,
|
|
103
|
+
autocomplete: options?.autocomplete,
|
|
104
|
+
rows: options?.rows,
|
|
105
|
+
code: options?.code,
|
|
106
|
+
autoheight: options?.autoheight,
|
|
107
|
+
icon: options?.icon,
|
|
108
|
+
iconStart: options?.iconStart,
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function selectField<T, P extends Path<T>>(
|
|
114
|
+
id: P,
|
|
115
|
+
label?: string,
|
|
116
|
+
options?: Option[] | (() => Option[]),
|
|
117
|
+
config?: SlctInputOptions<T, P>,
|
|
118
|
+
): BaseBagelField<T, P> {
|
|
119
|
+
return {
|
|
120
|
+
$el: 'select',
|
|
121
|
+
id,
|
|
122
|
+
// Runtime renderer also accepts a lazy `() => Option[]` loader, which the
|
|
123
|
+
// static `FieldOptions` type doesn't model — cast to preserve that.
|
|
124
|
+
options: options as BaseBagelField<T, P>['options'],
|
|
125
|
+
class: config?.class,
|
|
126
|
+
placeholder: config?.placeholder,
|
|
127
|
+
required: config?.required,
|
|
128
|
+
label,
|
|
129
|
+
defaultValue: config?.defaultValue,
|
|
130
|
+
vIf: config?.vIf,
|
|
131
|
+
attrs: {
|
|
132
|
+
disabled: config?.disabled,
|
|
133
|
+
searchable: config?.searchable,
|
|
134
|
+
multiselect: config?.multiselect,
|
|
135
|
+
onSearch: config?.onSearch,
|
|
136
|
+
clearable: config?.clearable,
|
|
137
|
+
autocomplete: config?.autocomplete,
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export const slctField = selectField
|
|
143
|
+
|
|
144
|
+
interface CheckInputOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
145
|
+
value?: string
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function checkField<T, P extends Path<T>>(id: P, label?: string, options?: CheckInputOptions<T, P>): BaseBagelField<T, P> {
|
|
149
|
+
return {
|
|
150
|
+
$el: 'check',
|
|
151
|
+
class: options?.class,
|
|
152
|
+
required: options?.required,
|
|
153
|
+
id,
|
|
154
|
+
label,
|
|
155
|
+
attrs: { value: options?.value },
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface EmailInputOptions<T, P extends Path<T>> extends InputOptions<T, P> {
|
|
160
|
+
autocorrect?: boolean
|
|
161
|
+
serverValidate?: boolean
|
|
162
|
+
preventFakeEmails?: boolean
|
|
163
|
+
pattern?: string
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function emailField<T, P extends Path<T>>(id: P, label?: string, options?: EmailInputOptions<T, P>): BaseBagelField<T, P> {
|
|
167
|
+
return {
|
|
168
|
+
$el: 'email',
|
|
169
|
+
id,
|
|
170
|
+
label,
|
|
171
|
+
class: options?.class,
|
|
172
|
+
required: options?.required,
|
|
173
|
+
vIf: options?.vIf,
|
|
174
|
+
attrs: {
|
|
175
|
+
autocorrect: options?.autocorrect,
|
|
176
|
+
serverValidate: options?.serverValidate,
|
|
177
|
+
preventFakeEmails: options?.preventFakeEmails,
|
|
178
|
+
pattern: options?.pattern,
|
|
179
|
+
},
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function dateField<T, P extends Path<T>>(id: P, label?: string, options?: DateOptions<T, P>): BaseBagelField<T, P> {
|
|
184
|
+
return {
|
|
185
|
+
$el: 'date',
|
|
186
|
+
class: options?.class,
|
|
187
|
+
required: options?.required,
|
|
188
|
+
id,
|
|
189
|
+
disabled: options?.disabled,
|
|
190
|
+
label,
|
|
191
|
+
defaultValue: options?.defaultValue,
|
|
192
|
+
vIf: options?.vIf,
|
|
193
|
+
attrs: {
|
|
194
|
+
disabled: options?.disabled,
|
|
195
|
+
autocomplete: options?.autocomplete,
|
|
196
|
+
enableTime: options?.enableTime,
|
|
197
|
+
mode: options?.mode,
|
|
198
|
+
locale: options?.locale,
|
|
199
|
+
timezone: options?.timezone,
|
|
200
|
+
},
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function numField<T, P extends Path<T>>(id: P, label?: string, options?: NumFieldOptions<T, P>): BaseBagelField<T, P> {
|
|
205
|
+
return {
|
|
206
|
+
$el: 'number',
|
|
207
|
+
class: options?.class,
|
|
208
|
+
required: options?.required,
|
|
209
|
+
defaultValue: options?.defaultValue,
|
|
210
|
+
id,
|
|
211
|
+
label,
|
|
212
|
+
disabled: options?.disabled,
|
|
213
|
+
placeholder: options?.placeholder,
|
|
214
|
+
helptext: options?.helptext,
|
|
215
|
+
vIf: options?.vIf,
|
|
216
|
+
attrs: {
|
|
217
|
+
autocomplete: options?.autocomplete,
|
|
218
|
+
step: options?.step,
|
|
219
|
+
min: options?.min,
|
|
220
|
+
max: options?.max,
|
|
221
|
+
layout: options?.layout,
|
|
222
|
+
padZero: options?.padZero,
|
|
223
|
+
center: options?.center,
|
|
224
|
+
useGrouping: options?.useGrouping,
|
|
225
|
+
},
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function frmRow<T, P extends Path<T>>(...children: SchemaChild<T, P>[]): {
|
|
230
|
+
$el: string
|
|
231
|
+
class: string
|
|
232
|
+
children: SchemaChild<T, P>[]
|
|
233
|
+
} {
|
|
234
|
+
return { $el: 'div', class: 'flex gap-1 m_block align-items-end', children }
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export type UploadOptions<T, K extends Path<T>> = UploadInputProps & InputOptions<T, K>
|
|
238
|
+
|
|
239
|
+
export function uploadField<T, P extends Path<T>>(id: P, label?: string, options?: UploadOptions<T, P>): BaseBagelField<T, P> {
|
|
240
|
+
return { $el: 'upload', id, label, vIf: options?.vIf, attrs: { ...options } }
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
interface RangeOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
244
|
+
min?: number
|
|
245
|
+
max?: number
|
|
246
|
+
step?: number
|
|
247
|
+
rtl?: boolean
|
|
248
|
+
multiRange?: boolean
|
|
249
|
+
formatValue?: (value: number) => string
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function rangeField<T, P extends Path<T>>(id: P, label?: string, options?: RangeOptions<T, P>): BaseBagelField<T, P> {
|
|
253
|
+
return {
|
|
254
|
+
$el: 'range',
|
|
255
|
+
id,
|
|
256
|
+
label,
|
|
257
|
+
vIf: options?.vIf,
|
|
258
|
+
attrs: {
|
|
259
|
+
autocomplete: options?.autocomplete,
|
|
260
|
+
min: options?.min,
|
|
261
|
+
max: options?.max,
|
|
262
|
+
step: options?.step,
|
|
263
|
+
rtl: options?.rtl,
|
|
264
|
+
multiRange: options?.multiRange,
|
|
265
|
+
formatValue: options?.formatValue,
|
|
266
|
+
},
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function bglForm<T>(idOrField?: string | Field<T>, ...schema: Field<T>[]): {
|
|
271
|
+
$el: string
|
|
272
|
+
id?: string
|
|
273
|
+
attrs: { schema: (string | Field<T> | undefined)[] }
|
|
274
|
+
} {
|
|
275
|
+
if (typeof idOrField === 'string') {
|
|
276
|
+
return { $el: 'bagelform', id: idOrField, attrs: { schema: [idOrField, ...schema] } }
|
|
277
|
+
}
|
|
278
|
+
return { $el: 'bagelform', attrs: { schema: [idOrField, ...schema] } }
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export function telField<T, P extends Path<T>>(id: P, label?: string, options?: { [key: string]: any }): BaseBagelField<T, P> {
|
|
282
|
+
return { $el: 'tel', id, label, vIf: options?.vIf, attrs: options, class: options?.class }
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export function colorField<T, P extends Path<T>>(id: P, label?: string, options?: { [key: string]: any }): BaseBagelField<T, P> {
|
|
286
|
+
return { $el: 'color', id, label, vIf: options?.vIf, attrs: options, class: options?.class }
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function findBglFieldById<T>(id: string, _schema: BglFormSchemaT<T>): Field<T> | undefined {
|
|
290
|
+
for (const field of _schema) {
|
|
291
|
+
if ((field as BaseBagelField<T, Path<T>>).id === id) return field as Field<T>
|
|
292
|
+
const children = (field as BaseBagelField<T, Path<T>>).children
|
|
293
|
+
if (children && Number(children.length) > 0) {
|
|
294
|
+
const fieldChildren = children.filter(
|
|
295
|
+
(c): c is Field<T> => typeof c === 'object' && c !== null && '$el' in c,
|
|
296
|
+
)
|
|
297
|
+
const child = findBglFieldById(id, fieldChildren as BglFormSchemaT<T>)
|
|
298
|
+
if (child) return child
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return undefined
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export interface ArrayFieldOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
305
|
+
delete?: boolean
|
|
306
|
+
add?: boolean
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export type ArrayType = 'number' | 'text'
|
|
310
|
+
|
|
311
|
+
export function arrField<T, P extends Path<T>>(
|
|
312
|
+
id: P,
|
|
313
|
+
label: string,
|
|
314
|
+
schemaOrType: BglFormSchemaT<any> | ArrayType,
|
|
315
|
+
options?: ArrayFieldOptions<T, P>,
|
|
316
|
+
): BaseBagelField<T, P> {
|
|
317
|
+
const attrs: Record<string, any> = { delete: true, add: true, ...options }
|
|
318
|
+
if (typeof schemaOrType === 'string') attrs.type = schemaOrType
|
|
319
|
+
else attrs.schema = schemaOrType
|
|
320
|
+
return { label, id, class: options?.class, $el: 'array', vIf: options?.vIf, attrs }
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export function useForm() {
|
|
324
|
+
return {
|
|
325
|
+
txtField,
|
|
326
|
+
selectField,
|
|
327
|
+
checkField,
|
|
328
|
+
dateField,
|
|
329
|
+
numField,
|
|
330
|
+
frmRow,
|
|
331
|
+
uploadField,
|
|
332
|
+
rangeField,
|
|
333
|
+
bglForm,
|
|
334
|
+
telField,
|
|
335
|
+
colorField,
|
|
336
|
+
arrField,
|
|
337
|
+
richText,
|
|
338
|
+
findBglFieldById,
|
|
339
|
+
getBaseField,
|
|
340
|
+
}
|
|
341
|
+
}
|