@bagelink/vue 1.4.79 → 1.4.85

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.
Files changed (43) hide show
  1. package/dist/components/Badge.vue.d.ts +2 -2
  2. package/dist/components/Badge.vue.d.ts.map +1 -1
  3. package/dist/components/Btn.vue.d.ts +10 -4
  4. package/dist/components/Btn.vue.d.ts.map +1 -1
  5. package/dist/components/Modal.vue.d.ts.map +1 -1
  6. package/dist/components/ModalForm.vue.d.ts +3 -1
  7. package/dist/components/ModalForm.vue.d.ts.map +1 -1
  8. package/dist/components/Pill.vue.d.ts.map +1 -1
  9. package/dist/components/Slider.vue.d.ts +4 -4
  10. package/dist/components/Slider.vue.d.ts.map +1 -1
  11. package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
  12. package/dist/index.cjs +6 -6
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.mjs +6 -6
  16. package/dist/style.css +1 -1
  17. package/dist/types/index.d.ts +2 -1
  18. package/dist/types/index.d.ts.map +1 -1
  19. package/dist/utils/elementUtils.d.ts +104 -0
  20. package/dist/utils/elementUtils.d.ts.map +1 -0
  21. package/package.json +1 -1
  22. package/src/components/Avatar.vue +1 -1
  23. package/src/components/Badge.vue +1059 -26
  24. package/src/components/Btn.vue +113 -88
  25. package/src/components/Card.vue +1 -1
  26. package/src/components/Modal.vue +11 -29
  27. package/src/components/ModalForm.vue +8 -24
  28. package/src/components/Pill.vue +203 -8
  29. package/src/components/Slider.vue +2 -2
  30. package/src/components/dataTable/DataTable.vue +1 -1
  31. package/src/components/form/inputs/DatePicker.vue +1 -1
  32. package/src/components/form/inputs/SelectInput.vue +1 -1
  33. package/src/index.ts +1 -0
  34. package/src/styles/appearance.css +202 -1356
  35. package/src/styles/bagel.css +2 -0
  36. package/src/styles/btnColors.css +847 -0
  37. package/src/styles/colors.css +3739 -0
  38. package/src/styles/dark.css +2 -2
  39. package/src/styles/mobileColors.css +3741 -0
  40. package/src/styles/text.css +2294 -783
  41. package/src/styles/theme.css +211 -18
  42. package/src/types/index.ts +46 -11
  43. package/src/utils/elementUtils.ts +531 -0
@@ -0,0 +1,531 @@
1
+ import type { BaseBagelField, IconType, Option, Path } from '@bagelink/vue'
2
+
3
+ export type DefaultPathsOptions = Record<string, any>
4
+ export type PathsOptions = Record<string, any>
5
+
6
+ export interface BaseElementField<
7
+ T,
8
+ PO extends PathsOptions = DefaultPathsOptions
9
+ > extends Partial<BaseBagelField<T, any, PO>> {
10
+ $el: string
11
+ id?: any
12
+ class?: string
13
+ vIf?: boolean | (() => boolean)
14
+ style?: Record<string, any>
15
+ attrs?: Record<string, any>
16
+ onClick?: () => void
17
+ children?: BaseElementField<T, PO>[]
18
+ }
19
+
20
+ export interface BtnElementOptions<
21
+ T = any,
22
+ PO extends PathsOptions = DefaultPathsOptions
23
+ > extends Partial<BaseElementField<T, PO>> {
24
+ text?: string
25
+ variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger'
26
+ size?: 'sm' | 'md' | 'lg'
27
+ disabled?: boolean
28
+ loading?: boolean
29
+ icon?: IconType
30
+ iconPosition?: 'left' | 'right'
31
+ href?: string
32
+ target?: '_blank' | '_self' | '_parent' | '_top'
33
+ }
34
+
35
+ export interface TxtElementOptions<
36
+ T = any,
37
+ PO extends PathsOptions = DefaultPathsOptions
38
+ > extends Partial<BaseElementField<T, PO>> {
39
+ text?: string
40
+ tag?: 'p' | 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'div'
41
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'
42
+ weight?: 'light' | 'normal' | 'medium' | 'semibold' | 'bold'
43
+ color?: string
44
+ align?: 'left' | 'center' | 'right' | 'justify'
45
+ }
46
+
47
+ export interface ImgElementOptions<
48
+ T = any,
49
+ PO extends PathsOptions = DefaultPathsOptions
50
+ > extends Partial<BaseElementField<T, PO>> {
51
+ src?: string
52
+ alt?: string
53
+ width?: number | string
54
+ height?: number | string
55
+ loading?: 'lazy' | 'eager'
56
+ fit?: 'cover' | 'contain' | 'fill' | 'scale-down' | 'none'
57
+ rounded?: boolean | 'sm' | 'md' | 'lg' | 'full'
58
+ fallback?: string
59
+ }
60
+
61
+ export interface DropdownElementOptions<
62
+ T = any,
63
+ PO extends PathsOptions = DefaultPathsOptions
64
+ > extends Partial<BaseElementField<T, PO>> {
65
+ options?: Option[] | (() => Option[])
66
+ placeholder?: string
67
+ searchable?: boolean
68
+ multiselect?: boolean
69
+ clearable?: boolean
70
+ onSelect?: (value: any) => void
71
+ onSearch?: (search: string) => any
72
+ }
73
+
74
+ export interface ListItemElementOptions<
75
+ T = any,
76
+ PO extends PathsOptions = DefaultPathsOptions
77
+ > extends Partial<BaseElementField<T, PO>> {
78
+ title?: string
79
+ subtitle?: string
80
+ icon?: IconType
81
+ avatar?: string
82
+ badge?: string | number
83
+ actions?: Array<{ label: string, onClick: () => void, icon?: IconType }>
84
+ clickable?: boolean
85
+ divider?: boolean
86
+ }
87
+
88
+ // Magical button overloads with schema support
89
+ export function btn<
90
+ T = any,
91
+ PO extends PathsOptions = DefaultPathsOptions
92
+ >(options: BtnElementOptions<T, PO>): BaseElementField<T, PO>
93
+ export function btn<
94
+ T = any,
95
+ P extends Path<T, PO> = any,
96
+ PO extends PathsOptions = DefaultPathsOptions
97
+ >(id: P): BaseElementField<T, PO>
98
+ export function btn<
99
+ T = any,
100
+ P extends Path<T, PO> = any,
101
+ PO extends PathsOptions = DefaultPathsOptions
102
+ >(id: P, text: string): BaseElementField<T, PO>
103
+ export function btn<
104
+ T = any,
105
+ P extends Path<T, PO> = any,
106
+ PO extends PathsOptions = DefaultPathsOptions
107
+ >(id: P, icon: IconType): BaseElementField<T, PO>
108
+ export function btn<
109
+ T = any,
110
+ P extends Path<T, PO> = any,
111
+ PO extends PathsOptions = DefaultPathsOptions
112
+ >(
113
+ id: P,
114
+ text: string,
115
+ options: BtnElementOptions<T, PO>
116
+ ): BaseElementField<T, PO>
117
+ export function btn<
118
+ T = any,
119
+ P extends Path<T, PO> = any,
120
+ PO extends PathsOptions = DefaultPathsOptions
121
+ >(
122
+ id: P,
123
+ icon: IconType,
124
+ options: BtnElementOptions<T, PO>
125
+ ): BaseElementField<T, PO>
126
+ export function btn<
127
+ T = any,
128
+ P extends Path<T, PO> = any,
129
+ PO extends PathsOptions = DefaultPathsOptions
130
+ >(
131
+ id: P,
132
+ textOrIcon: string | IconType,
133
+ options: BtnElementOptions<T, PO>
134
+ ): BaseElementField<T, PO>
135
+ export function btn<
136
+ T = any,
137
+ P extends Path<T, PO> = any,
138
+ PO extends PathsOptions = DefaultPathsOptions
139
+ >(
140
+ idOrOptions?: P | BtnElementOptions<T, PO>,
141
+ textOrIcon?: string | IconType,
142
+ options?: BtnElementOptions<T, PO>,
143
+ ): BaseElementField<T, PO> {
144
+ // Handle different overload patterns
145
+ let id: Path<T, PO> | undefined
146
+ let text: string = ''
147
+ let icon: IconType | undefined
148
+ let finalOptions: BtnElementOptions<T, PO> = {}
149
+
150
+ if (typeof idOrOptions === 'object' && idOrOptions !== null) {
151
+ // btn(options)
152
+ finalOptions = idOrOptions
153
+ const { id: optionId, text: optionText, icon: optionIcon } = finalOptions
154
+ id = optionId
155
+ text = optionText ?? ''
156
+ icon = optionIcon
157
+ } else {
158
+ // btn(id, ...) patterns
159
+ id = idOrOptions
160
+ if (textOrIcon != null) {
161
+ // Check if textOrIcon is likely an icon vs text
162
+ // Icons are typically: lowercase, contain hyphens/underscores, no spaces, shorter length
163
+ const isLikelyIcon = typeof textOrIcon === 'string'
164
+ && textOrIcon.length <= 30
165
+ && !textOrIcon.includes(' ')
166
+ && (textOrIcon.includes('-')
167
+ || textOrIcon.includes('_')
168
+ || textOrIcon.length <= 12)
169
+ && textOrIcon === textOrIcon.toLowerCase()
170
+
171
+ if (isLikelyIcon) {
172
+ icon = textOrIcon as IconType
173
+ if (options) {
174
+ finalOptions = options
175
+ }
176
+ } else {
177
+ text = textOrIcon
178
+ if (options) {
179
+ finalOptions = options
180
+ }
181
+ }
182
+ }
183
+ }
184
+
185
+ return {
186
+ $el: 'btn',
187
+ id,
188
+ class: finalOptions.class,
189
+ vIf: finalOptions.vIf,
190
+ style: finalOptions.style,
191
+ onClick: finalOptions.onClick,
192
+ attrs: {
193
+ value: text || (finalOptions.text ?? '') || '',
194
+ variant: finalOptions.variant,
195
+ size: finalOptions.size,
196
+ disabled: finalOptions.disabled,
197
+ loading: finalOptions.loading,
198
+ icon: icon ?? finalOptions.icon,
199
+ iconPosition: finalOptions.iconPosition,
200
+ href: finalOptions.href,
201
+ target: finalOptions.target,
202
+ },
203
+ }
204
+ }
205
+
206
+ export function getBaseElementField<
207
+ T = any,
208
+ PO extends PathsOptions = DefaultPathsOptions
209
+ >(
210
+ elementType: string,
211
+ id?: Path<T, PO>,
212
+ options: Partial<BaseElementField<T, PO>> = {}
213
+ ): BaseElementField<T, PO> {
214
+ return {
215
+ $el: elementType,
216
+ id,
217
+ class: options.class,
218
+ vIf: options.vIf,
219
+ style: options.style,
220
+ attrs: options.attrs || {},
221
+ onClick: options.onClick,
222
+ }
223
+ }
224
+
225
+ // Icon button shorthand
226
+ export function iconBtn<
227
+ T = any,
228
+ P extends Path<T, PO> = any,
229
+ PO extends PathsOptions = DefaultPathsOptions
230
+ >(
231
+ id?: P,
232
+ icon?: IconType,
233
+ options?: BtnElementOptions<T, PO>,
234
+ ): BaseElementField<T, PO> {
235
+ if (icon != null && id != null) {
236
+ return btn(id, icon, options || {})
237
+ }
238
+ return btn({ id, icon, ...options } as BtnElementOptions<T, PO>)
239
+ }
240
+
241
+ // Magical text overloads with schema support
242
+ export function txt<
243
+ T = any,
244
+ PO extends PathsOptions = DefaultPathsOptions
245
+ >(options: TxtElementOptions<T, PO>): BaseElementField<T, PO>
246
+ export function txt<
247
+ T = any,
248
+ P extends Path<T, PO> = any,
249
+ PO extends PathsOptions = DefaultPathsOptions
250
+ >(id: P): BaseElementField<T, PO>
251
+ export function txt<
252
+ T = any,
253
+ P extends Path<T, PO> = any,
254
+ PO extends PathsOptions = DefaultPathsOptions
255
+ >(id: P, text: string): BaseElementField<T, PO>
256
+ export function txt<
257
+ T = any,
258
+ P extends Path<T, PO> = any,
259
+ PO extends PathsOptions = DefaultPathsOptions
260
+ >(
261
+ id: P,
262
+ text: string,
263
+ tag: 'p' | 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'div'
264
+ ): BaseElementField<T, PO>
265
+ export function txt<
266
+ T = any,
267
+ P extends Path<T, PO> = any,
268
+ PO extends PathsOptions = DefaultPathsOptions
269
+ >(id: P, text: string, options: TxtElementOptions<T, PO>): BaseElementField<T, PO>
270
+ export function txt<
271
+ T = any,
272
+ P extends Path<T, PO> = any,
273
+ PO extends PathsOptions = DefaultPathsOptions
274
+ >(
275
+ idOrOptions?: P | TxtElementOptions<T, PO>,
276
+ text?: string,
277
+ tagOrOptions?: string | TxtElementOptions<T, PO>,
278
+ ): BaseElementField<T, PO> {
279
+ // Handle different overload patterns
280
+ let id: Path<T, PO> | undefined
281
+ let finalOptions: TxtElementOptions<T, PO> = {}
282
+
283
+ if (typeof idOrOptions === 'object' && idOrOptions !== null) {
284
+ // txt(options)
285
+ finalOptions = idOrOptions
286
+ const { id: optionId } = finalOptions
287
+ id = optionId
288
+ } else {
289
+ // txt(id, ...) patterns
290
+ id = idOrOptions
291
+ if (text != null) {
292
+ if (typeof tagOrOptions === 'string') {
293
+ // txt(id, text, tag)
294
+ finalOptions = { tag: tagOrOptions as any, text }
295
+ } else if (tagOrOptions) {
296
+ // txt(id, text, options)
297
+ finalOptions = { ...tagOrOptions, text }
298
+ } else {
299
+ finalOptions = { text }
300
+ }
301
+ }
302
+ }
303
+
304
+ return {
305
+ $el: finalOptions.tag || 'p',
306
+ id,
307
+ class: finalOptions.class,
308
+ vIf: finalOptions.vIf,
309
+ style: finalOptions.style,
310
+ attrs: {
311
+ text: finalOptions.text ?? '',
312
+ size: finalOptions.size,
313
+ weight: finalOptions.weight,
314
+ color: finalOptions.color,
315
+ align: finalOptions.align,
316
+ },
317
+ }
318
+ }
319
+
320
+ // Magical image overloads with schema support
321
+ export function img<
322
+ T = any,
323
+ PO extends PathsOptions = DefaultPathsOptions
324
+ >(options: ImgElementOptions<T, PO>): BaseElementField<T, PO>
325
+ export function img<
326
+ T = any,
327
+ P extends Path<T, PO> = any,
328
+ PO extends PathsOptions = DefaultPathsOptions
329
+ >(id: P): BaseElementField<T, PO>
330
+ export function img<
331
+ T = any,
332
+ P extends Path<T, PO> = any,
333
+ PO extends PathsOptions = DefaultPathsOptions
334
+ >(id: P, src: string): BaseElementField<T, PO>
335
+ export function img<
336
+ T = any,
337
+ P extends Path<T, PO> = any,
338
+ PO extends PathsOptions = DefaultPathsOptions
339
+ >(id: P, src: string, alt: string): BaseElementField<T, PO>
340
+ export function img<
341
+ T = any,
342
+ P extends Path<T, PO> = any,
343
+ PO extends PathsOptions = DefaultPathsOptions
344
+ >(id: P, src: string, options: ImgElementOptions<T, PO>): BaseElementField<T, PO>
345
+ export function img<
346
+ T = any,
347
+ P extends Path<T, PO> = any,
348
+ PO extends PathsOptions = DefaultPathsOptions
349
+ >(
350
+ idOrOptions?: P | ImgElementOptions<T, PO>,
351
+ src?: string,
352
+ altOrOptions?: string | ImgElementOptions<T, PO>,
353
+ ): BaseElementField<T, PO> {
354
+ // Handle different overload patterns
355
+ let id: Path<T, PO> | undefined
356
+ let finalSrc: string = ''
357
+ let finalOptions: ImgElementOptions<T, PO> = {}
358
+
359
+ if (typeof idOrOptions === 'object' && idOrOptions !== null) {
360
+ // img(options)
361
+ finalOptions = idOrOptions
362
+ const { id: optionId, src: optionSrc } = finalOptions
363
+ id = optionId
364
+ finalSrc = optionSrc ?? ''
365
+ } else {
366
+ // img(id, ...) patterns
367
+ id = idOrOptions
368
+ if (src != null) {
369
+ finalSrc = src
370
+ if (typeof altOrOptions === 'string') {
371
+ // img(id, src, alt)
372
+ finalOptions = { alt: altOrOptions }
373
+ } else if (altOrOptions) {
374
+ // img(id, src, options)
375
+ finalOptions = altOrOptions
376
+ }
377
+ }
378
+ }
379
+
380
+ return {
381
+ $el: 'img',
382
+ id,
383
+ class: finalOptions.class,
384
+ vIf: finalOptions.vIf,
385
+ style: finalOptions.style,
386
+ attrs: {
387
+ src: finalSrc || (finalOptions.src ?? '') || '',
388
+ alt: finalOptions.alt,
389
+ width: finalOptions.width,
390
+ height: finalOptions.height,
391
+ loading: finalOptions.loading,
392
+ fit: finalOptions.fit,
393
+ rounded: finalOptions.rounded,
394
+ fallback: finalOptions.fallback,
395
+ },
396
+ }
397
+ }
398
+
399
+ // Dropdown element function following BagelForm pattern
400
+ export function dropdownElement<
401
+ T = any,
402
+ PO extends PathsOptions = DefaultPathsOptions
403
+ >(
404
+ id?: Path<T, PO>,
405
+ options?: Option[] | (() => Option[]),
406
+ config?: DropdownElementOptions<T, PO>,
407
+ ): BaseElementField<T, PO> {
408
+ return {
409
+ $el: 'dropdown',
410
+ id,
411
+ class: config?.class,
412
+ vIf: config?.vIf,
413
+ style: config?.style,
414
+ attrs: {
415
+ options: options || config?.options,
416
+ placeholder: config?.placeholder,
417
+ searchable: config?.searchable,
418
+ multiselect: config?.multiselect,
419
+ clearable: config?.clearable,
420
+ onSelect: config?.onSelect,
421
+ onSearch: config?.onSearch,
422
+ },
423
+ }
424
+ }
425
+
426
+ // ListItem element function following BagelForm pattern
427
+ export function listItemElement<
428
+ T = any,
429
+ PO extends PathsOptions = DefaultPathsOptions
430
+ >(
431
+ id?: Path<T, PO>,
432
+ title?: string,
433
+ options?: ListItemElementOptions<T, PO>,
434
+ ): BaseElementField<T, PO> {
435
+ return {
436
+ $el: 'listItem',
437
+ id,
438
+ class: options?.class,
439
+ vIf: options?.vIf,
440
+ style: options?.style,
441
+ onClick: options?.onClick,
442
+ attrs: {
443
+ title: title ?? options?.title ?? '',
444
+ subtitle: options?.subtitle,
445
+ icon: options?.icon,
446
+ avatar: options?.avatar,
447
+ badge: options?.badge,
448
+ actions: options?.actions,
449
+ clickable: options?.clickable,
450
+ divider: options?.divider,
451
+ },
452
+ }
453
+ }
454
+
455
+ // Container element function following BagelForm pattern
456
+ export function containerElement<
457
+ T = any,
458
+ PO extends PathsOptions = DefaultPathsOptions
459
+ >(
460
+ id?: Path<T, PO>,
461
+ children?: BaseElementField<T, any>[],
462
+ options?: Partial<BaseElementField<T, PO>>,
463
+ ): BaseElementField<T, PO> {
464
+ return {
465
+ $el: 'div',
466
+ id,
467
+ class: options?.class ?? 'flex gap-2',
468
+ vIf: options?.vIf,
469
+ style: options?.style,
470
+ attrs: options?.attrs || {},
471
+ children: children as any,
472
+ }
473
+ }
474
+
475
+ export function findElementById<T>(
476
+ id: string,
477
+ elements: BaseElementField<T, any>[]
478
+ ): BaseElementField<T, any> | undefined {
479
+ for (const element of elements) {
480
+ if (element.id === id) return element
481
+ if (element.children && element.children.length > 0) {
482
+ const child = findElementById(id, element.children)
483
+ if (child) return child
484
+ }
485
+ }
486
+ return undefined
487
+ }
488
+
489
+ export function column<T = any, P extends Path<T, PO> = any, PO extends PathsOptions = DefaultPathsOptions>(
490
+ id?: P,
491
+ labelOrOptions?: string | Partial<BaseElementField<T, PO>>,
492
+ options?: Partial<BaseElementField<T, PO>>,
493
+ ): BaseElementField<T, PO> {
494
+ let label: string | undefined
495
+ if (typeof labelOrOptions === 'string') {
496
+ label = labelOrOptions
497
+ } else {
498
+ options = labelOrOptions
499
+ }
500
+
501
+ return {
502
+ $el: 'div',
503
+ id,
504
+ class: options?.class ?? 'column-class',
505
+ vIf: options?.vIf,
506
+ style: options?.style,
507
+ attrs: {
508
+ ...options?.attrs,
509
+ label: label ?? options?.attrs?.label ?? '',
510
+ },
511
+ children: options?.children as any,
512
+ }
513
+ }
514
+
515
+ export const col = column
516
+
517
+ export function useElements() {
518
+ return {
519
+ btn,
520
+ iconBtn,
521
+ txt,
522
+ img,
523
+ dropdownElement,
524
+ listItemElement,
525
+ containerElement,
526
+ findElementById,
527
+ getBaseElementField,
528
+ col,
529
+ column,
530
+ }
531
+ }