@bagelink/vue 1.3.5 → 1.3.7

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.
@@ -1,6 +1,6 @@
1
1
  body>div ::-webkit-scrollbar {
2
- width: 0.5em;
3
- height: 0.5rem;
2
+ width: var(--bgl-scrollbar-size);
3
+ height: var(--bgl-scrollbar-size);
4
4
  }
5
5
 
6
6
  body>div ::-webkit-scrollbar-track {}
@@ -33,6 +33,7 @@
33
33
  --bgl-selection-bg: var(--bgl-blue-dark);
34
34
  --bgl-selection-color: var(--bgl-white);
35
35
  --bgl-scrollbar-thumb: var(--bgl-gray);
36
+ --bgl-scrollbar-size: 0.5rem;
36
37
  --pill-btn-color: var(--bgl-white);
37
38
  --pill-btn-bg: var(--placeholder-color);
38
39
  --bgl-selected: var(--bgl-gray-light);
@@ -75,13 +75,13 @@ export type VNodeFn<T, P extends Path<T>> = (props: {
75
75
 
76
76
  export type SchemaChild<
77
77
  T,
78
- P extends Path<T>,
78
+ P extends Path<T, PO>,
79
79
  PO extends PathsOptions = DefaultPathsOptions,
80
80
  > = Field<T, PO> | VNode | VNodeFn<T, P> | string
81
81
 
82
82
  export interface BaseBagelField<
83
83
  T,
84
- P extends Path<T>,
84
+ P extends Path<T, PO>,
85
85
  PO extends PathsOptions = DefaultPathsOptions,
86
86
  > {
87
87
  '$el'?: any
@@ -113,13 +113,13 @@ export type _MappedBaseBagelField<
113
113
 
114
114
  export type MappedBaseBagelFieldP<
115
115
  T,
116
- P extends Path<T>,
116
+ P extends Path<T, PO>,
117
117
  PO extends PathsOptions = DefaultPathsOptions,
118
118
  > = _MappedBaseBagelField<T, PO>[P]
119
119
 
120
120
  export type FieldByP<
121
121
  T,
122
- P extends Path<T>,
122
+ P extends Path<T, PO>,
123
123
  PO extends PathsOptions = DefaultPathsOptions,
124
124
  > = MappedBaseBagelFieldP<T, P, PO>
125
125
 
@@ -143,14 +143,22 @@ export type ShallowBglFormSchemaT<
143
143
  PO extends PathsOptions = ShallowPathsOptions,
144
144
  > = Field<T, PO>[]
145
145
 
146
- export interface InputBagelField<T, P extends Path<T>>
147
- extends BaseBagelField<T, P> {
146
+ export interface InputBagelField<
147
+ T,
148
+ P extends Path<T, PO>,
149
+ PO extends PathsOptions = ShallowPathsOptions
150
+ >
151
+ extends BaseBagelField<T, P, PO> {
148
152
  $el: 'text' | ComponentExposed<typeof TextInput>
149
153
  type?: string
150
154
  }
151
155
 
152
- export interface SelectBagelField<T, P extends Path<T>>
153
- extends BaseBagelField<T, P> {
156
+ export interface SelectBagelField<
157
+ T,
158
+ P extends Path<T, PO>,
159
+ PO extends PathsOptions = ShallowPathsOptions,
160
+ >
161
+ extends BaseBagelField<T, P, PO> {
154
162
  $el: 'select' | ComponentExposed<typeof SelectInput>
155
163
  type?: string
156
164
  }
@@ -1,7 +1,10 @@
1
1
  import type { ArrayFieldVal, Attributes, BaseBagelField, BglFormSchemaT, FieldByP, IconType, InputBagelField, Option, Path, SchemaChild, SelectBagelField, ShallowBglFormSchemaT, UploadInputProps } from '@bagelink/vue'
2
2
  import type { DefaultPathsOptions, PathsOptions } from 'type-fest/source/paths'
3
3
 
4
- interface InputOptions<T, P extends Path<T>> extends Partial<BaseBagelField<T, P>> {
4
+ interface InputOptions<
5
+ T,
6
+ P extends Path<T>
7
+ > extends Partial<BaseBagelField<T, P>> {
5
8
  defaultValue?: string | number
6
9
  autocomplete?: AutoFillField
7
10
  }
@@ -41,22 +44,33 @@ interface NumFieldOptions<T, K extends Path<T>> extends InputOptions<T, K> {
41
44
  useGrouping?: boolean
42
45
  }
43
46
 
44
- type RichTextOptions<T, P extends Path<T>> = InputOptions<T, P>
47
+ type RichTextOptions<
48
+ T,
49
+ P extends Path<T>
50
+ > = InputOptions<T, P>
45
51
 
46
- export function getBaseField<T, P extends Path<T>>(
52
+ export function getBaseField<
53
+ T,
54
+ P extends Path<T, PO>,
55
+ PO extends PathsOptions = DefaultPathsOptions,
56
+ >(
47
57
  id?: P,
48
58
  labelOrRest: string | Partial<BaseBagelField<T, P>> = {},
49
59
  rest: Partial<BaseBagelField<T, P>> = {}
50
- ): BaseBagelField<T, P> {
60
+ ): BaseBagelField<T, P, PO> {
51
61
  if (typeof labelOrRest === 'object') return { id, ...labelOrRest }
52
62
  return { id, label: labelOrRest, ...rest }
53
63
  }
54
64
 
55
- export function richText<T, P extends Path<T>>(
65
+ export function richText<
66
+ T,
67
+ P extends Path<T, PO>,
68
+ PO extends PathsOptions = DefaultPathsOptions,
69
+ >(
56
70
  id?: P,
57
71
  label?: string,
58
72
  options?: RichTextOptions<T, P>,
59
- ): BaseBagelField<T, P> {
73
+ ): BaseBagelField<T, P, PO> {
60
74
  return {
61
75
  $el: 'richtext',
62
76
  class: options?.class,
@@ -71,11 +85,15 @@ export function richText<T, P extends Path<T>>(
71
85
  }
72
86
  }
73
87
 
74
- export function txtField<T, P extends Path<T>>(
88
+ export function txtField<
89
+ T,
90
+ P extends Path<T, PO>,
91
+ PO extends PathsOptions = DefaultPathsOptions,
92
+ >(
75
93
  id?: P,
76
94
  label?: string,
77
95
  options?: TextInputOptions<T, P>,
78
- ): InputBagelField<T, P> {
96
+ ): InputBagelField<T, P, PO> {
79
97
  return {
80
98
  $el: 'text',
81
99
  id,
@@ -102,12 +120,16 @@ export function txtField<T, P extends Path<T>>(
102
120
  }
103
121
  }
104
122
 
105
- export function selectField<T, P extends Path<T>>(
123
+ export function selectField<
124
+ T,
125
+ P extends Path<T, PO>,
126
+ PO extends PathsOptions = DefaultPathsOptions,
127
+ >(
106
128
  id?: P,
107
129
  label?: string,
108
130
  options?: Option[] | (() => Option[]),
109
131
  config?: SlctInputOptions<T, P>,
110
- ): SelectBagelField<T, P> {
132
+ ): SelectBagelField<T, P, PO> {
111
133
  return {
112
134
  $el: 'select',
113
135
  id,
@@ -135,11 +157,15 @@ interface CheckInputOptions<T, K extends Path<T>> extends InputOptions<T, K> {
135
157
  value?: string
136
158
  }
137
159
 
138
- export function checkField<T, P extends Path<T>>(
160
+ export function checkField<
161
+ T,
162
+ P extends Path<T, PO>,
163
+ PO extends PathsOptions = DefaultPathsOptions,
164
+ >(
139
165
  id?: P,
140
166
  label?: string,
141
167
  options?: CheckInputOptions<T, P>,
142
- ): BaseBagelField<T, P> {
168
+ ): BaseBagelField<T, P, PO> {
143
169
  return {
144
170
  $el: 'check',
145
171
  class: options?.class,
@@ -152,14 +178,21 @@ export function checkField<T, P extends Path<T>>(
152
178
  }
153
179
  }
154
180
 
155
- interface EmailInputOptions<T, P extends Path<T>> extends InputOptions<T, P> {
181
+ interface EmailInputOptions<
182
+ T,
183
+ P extends Path<T>
184
+ > extends InputOptions<T, P> {
156
185
  autocorrect?: boolean
157
186
  serverValidate?: boolean
158
187
  preventFakeEmails?: boolean
159
188
  pattern?: string
160
189
  }
161
190
 
162
- export function emailField<T, P extends Path<T>>(id?: P, label?: string, options?: EmailInputOptions<T, P>): BaseBagelField<T, P> {
191
+ export function emailField<
192
+ T,
193
+ P extends Path<T, PO>,
194
+ PO extends PathsOptions = DefaultPathsOptions,
195
+ >(id?: P, label?: string, options?: EmailInputOptions<T, P>): BaseBagelField<T, P, PO> {
163
196
  return {
164
197
  $el: 'email',
165
198
  id,
@@ -176,11 +209,15 @@ export function emailField<T, P extends Path<T>>(id?: P, label?: string, options
176
209
  }
177
210
  }
178
211
 
179
- export function dateField<T, P extends Path<T>>(
212
+ export function dateField<
213
+ T,
214
+ P extends Path<T, PO>,
215
+ PO extends PathsOptions = DefaultPathsOptions,
216
+ >(
180
217
  id?: P,
181
218
  label?: string,
182
219
  options?: DateOptions<T, P>,
183
- ): BaseBagelField<T, P> {
220
+ ): BaseBagelField<T, P, PO> {
184
221
  return {
185
222
  $el: 'date',
186
223
  class: options?.class,
@@ -201,11 +238,15 @@ export function dateField<T, P extends Path<T>>(
201
238
  }
202
239
  }
203
240
 
204
- export function numField<T, P extends Path<T>>(
241
+ export function numField<
242
+ T,
243
+ P extends Path<T, PO>,
244
+ PO extends PathsOptions = DefaultPathsOptions,
245
+ >(
205
246
  id?: P,
206
247
  label?: string,
207
248
  options?: NumFieldOptions<T, P>,
208
- ): BaseBagelField<T, P> {
249
+ ): BaseBagelField<T, P, PO> {
209
250
  return {
210
251
  $el: 'number',
211
252
  class: options?.class,
@@ -230,7 +271,11 @@ export function numField<T, P extends Path<T>>(
230
271
  }
231
272
  }
232
273
 
233
- export function frmRow<T, P extends Path<T>, PO extends PathsOptions = DefaultPathsOptions>(
274
+ export function frmRow<
275
+ T,
276
+ P extends Path<T, PO>,
277
+ PO extends PathsOptions = DefaultPathsOptions,
278
+ >(
234
279
  ...children: SchemaChild<T, P, PO>[]
235
280
  ): FieldByP<T, P, PO> {
236
281
  return {
@@ -242,11 +287,15 @@ export function frmRow<T, P extends Path<T>, PO extends PathsOptions = DefaultPa
242
287
 
243
288
  export interface UploadOptions<T, K extends Path<T>> extends Omit<UploadInputProps, 'id'>, InputOptions<T, K> {}
244
289
 
245
- export function uploadField<T, P extends Path<T>>(
290
+ export function uploadField<
291
+ T,
292
+ P extends Path<T, PO>,
293
+ PO extends PathsOptions = DefaultPathsOptions,
294
+ >(
246
295
  id?: P,
247
296
  label?: string,
248
297
  options?: UploadOptions<T, P>
249
- ): BaseBagelField<T, P> {
298
+ ): BaseBagelField<T, P, PO> {
250
299
  return {
251
300
  $el: 'upload',
252
301
  id,
@@ -267,11 +316,15 @@ interface RangeOptions<T, K extends Path<T>> extends InputOptions<T, K> {
267
316
  formatValue?: (value: number) => string
268
317
  }
269
318
 
270
- export function rangeField<T, P extends Path<T>>(
319
+ export function rangeField<
320
+ T,
321
+ P extends Path<T, PO>,
322
+ PO extends PathsOptions = DefaultPathsOptions,
323
+ >(
271
324
  id?: P,
272
325
  label?: string,
273
326
  options?: RangeOptions <T, P>
274
- ): BaseBagelField<T, P> {
327
+ ): BaseBagelField<T, P, PO> {
275
328
  return {
276
329
  $el: 'range',
277
330
  id,
@@ -307,11 +360,15 @@ export function bglForm<T>(idOrField?: string | FieldByP<T, Path<T>>, ...schema:
307
360
  }
308
361
  }
309
362
 
310
- export function telField<T, P extends Path<T>>(
363
+ export function telField<
364
+ T,
365
+ P extends Path<T, PO>,
366
+ PO extends PathsOptions = DefaultPathsOptions,
367
+ >(
311
368
  id?: P,
312
369
  label?: string,
313
370
  options?: { [key: string]: any }
314
- ): BaseBagelField<T, P> {
371
+ ): BaseBagelField<T, P, PO> {
315
372
  return {
316
373
  $el: 'tel',
317
374
  id,
@@ -322,11 +379,15 @@ export function telField<T, P extends Path<T>>(
322
379
  }
323
380
  }
324
381
 
325
- export function colorField<T, P extends Path<T>>(
382
+ export function colorField<
383
+ T,
384
+ P extends Path<T, PO>,
385
+ PO extends PathsOptions = DefaultPathsOptions,
386
+ >(
326
387
  id?: P,
327
388
  label?: string,
328
389
  options?: { [key: string]: any }
329
- ): BaseBagelField<T, P> {
390
+ ): BaseBagelField<T, P, PO> {
330
391
  return {
331
392
  $el: 'color',
332
393
  id,
@@ -358,12 +419,16 @@ export interface ArrayFieldOptions<T, K extends Path<T>> extends InputOptions<T,
358
419
 
359
420
  export type ArrayType = 'number' | 'text'
360
421
 
361
- export function arrField<T, P extends Path<T>>(
422
+ export function arrField<
423
+ T,
424
+ P extends Path<T, PO>,
425
+ PO extends PathsOptions = DefaultPathsOptions,
426
+ >(
362
427
  id: P,
363
428
  label: string,
364
429
  schemaOrType: BglFormSchemaT<ArrayFieldVal<T, P>> | ArrayType,
365
430
  options?: ArrayFieldOptions<T, P>
366
- ): BaseBagelField<T, P> {
431
+ ): BaseBagelField<T, P, PO> {
367
432
  const attrs: Attributes<T, P> = { delete: true, add: true, ...options }
368
433
 
369
434
  if (typeof schemaOrType === 'string') {