@bagelink/vue 1.4.111 → 1.4.118

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 (59) hide show
  1. package/bin/generateFormSchema.ts +14 -14
  2. package/dist/components/Card.vue.d.ts.map +1 -1
  3. package/dist/components/ImportData.vue.d.ts.map +1 -1
  4. package/dist/components/analytics/PieChart.vue.d.ts.map +1 -1
  5. package/dist/components/calendar/Index.vue.d.ts.map +1 -1
  6. package/dist/components/calendar/index.d.ts +2 -0
  7. package/dist/components/calendar/index.d.ts.map +1 -0
  8. package/dist/components/calendar/views/MonthView.vue.d.ts.map +1 -1
  9. package/dist/components/calendar/views/WeekView.vue.d.ts.map +1 -1
  10. package/dist/components/dataTable/DataTable.vue.d.ts.map +1 -1
  11. package/dist/components/form/BagelForm.vue.d.ts.map +1 -1
  12. package/dist/components/form/inputs/DatePicker.vue.d.ts +1 -0
  13. package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
  14. package/dist/components/form/inputs/RichText/composables/useEditor.d.ts.map +1 -1
  15. package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
  16. package/dist/components/form/inputs/RichText/utils/media.d.ts.map +1 -1
  17. package/dist/components/layout/AppContent.vue.d.ts.map +1 -1
  18. package/dist/composables/useSchemaField.d.ts +2 -2
  19. package/dist/composables/useSchemaField.d.ts.map +1 -1
  20. package/dist/index.cjs +5 -5
  21. package/dist/index.mjs +5 -5
  22. package/dist/plugins/modalTypes.d.ts +2 -1
  23. package/dist/plugins/modalTypes.d.ts.map +1 -1
  24. package/dist/plugins/useModal.d.ts +1 -1
  25. package/dist/plugins/useModal.d.ts.map +1 -1
  26. package/dist/style.css +1 -1
  27. package/dist/types/BagelForm.d.ts +40 -19
  28. package/dist/types/BagelForm.d.ts.map +1 -1
  29. package/dist/types/NavLink.d.ts +1 -1
  30. package/dist/types/NavLink.d.ts.map +1 -1
  31. package/dist/utils/BagelFormUtils.d.ts +20 -5
  32. package/dist/utils/BagelFormUtils.d.ts.map +1 -1
  33. package/dist/utils/elementUtils.d.ts.map +1 -1
  34. package/dist/utils/index.d.ts +1 -1
  35. package/dist/utils/index.d.ts.map +1 -1
  36. package/package.json +1 -1
  37. package/src/components/Card.vue +1 -2
  38. package/src/components/DataPreview.vue +1 -1
  39. package/src/components/ImportData.vue +94 -88
  40. package/src/components/analytics/PieChart.vue +21 -34
  41. package/src/components/calendar/Index.vue +15 -35
  42. package/src/components/calendar/views/MonthView.vue +84 -88
  43. package/src/components/calendar/views/WeekView.vue +143 -89
  44. package/src/components/dataTable/DataTable.vue +2 -3
  45. package/src/components/form/BagelForm.vue +3 -6
  46. package/src/components/form/inputs/DateInput.vue +2 -2
  47. package/src/components/form/inputs/DatePicker.vue +40 -47
  48. package/src/components/form/inputs/RichText/utils/media.ts +8 -9
  49. package/src/components/layout/AppContent.vue +21 -1
  50. package/src/composables/useSchemaField.ts +7 -7
  51. package/src/plugins/modalTypes.ts +10 -2
  52. package/src/plugins/useModal.ts +23 -7
  53. package/src/styles/layout.css +6 -0
  54. package/src/types/BagelForm.ts +97 -22
  55. package/src/types/NavLink.ts +1 -1
  56. package/src/utils/BagelFormUtils.ts +63 -34
  57. package/src/utils/elementUtils.ts +1 -4
  58. package/src/utils/index.ts +7 -5
  59. /package/src/components/{dialog → calendar}/index.ts +0 -0
@@ -1,6 +1,27 @@
1
- import type { ArrayBagelField, ArrayFieldVal, Attributes, BaseBagelField, BglFormSchemaT, FieldByP, IconType, InputBagelField, Option, Path, SchemaChild, SelectBagelField, ShallowBglFormSchemaT, UploadInputProps } from '@bagelink/vue'
1
+ // Import types from type-fest first
2
2
  import type { DefaultPathsOptions, PathsOptions } from 'type-fest/source/paths'
3
- import type { InputTypeHTMLAttribute, MaybeRefOrGetter } from 'vue'
3
+
4
+ // Import types from local types file
5
+ import type {
6
+ Path,
7
+ BaseBagelField,
8
+ InputBagelField,
9
+ SelectBagelField,
10
+ ArrayBagelField,
11
+ ArrayFieldVal,
12
+ Attributes,
13
+ BglFormSchemaT,
14
+ FieldByP,
15
+ SchemaChild,
16
+ ShallowBglFormSchemaT,
17
+ UploadInputProps
18
+ } from '../types/BagelForm'
19
+
20
+ // Local type definitions for internal use only
21
+ interface IconType { name: string }
22
+ interface AutoFillField { name: string }
23
+ interface InputTypeHTMLAttribute { type: string }
24
+ type MaybeRefOrGetter<T> = T | (() => T) | { value: T }
4
25
 
5
26
  export interface InputOptions<
6
27
  T,
@@ -19,7 +40,7 @@ export interface DateOptions<T, K extends Path<T>> extends InputOptions<T, K> {
19
40
  }
20
41
 
21
42
  export interface TextInputOptions<T, K extends Path<T>> extends InputOptions<T, K> {
22
- type?: InputTypeHTMLAttribute
43
+ type?: InputTypeHTMLAttribute['type']
23
44
  pattern?: string
24
45
  multiline?: boolean
25
46
  autoheight?: boolean
@@ -98,28 +119,30 @@ export function txtField<
98
119
  label,
99
120
  class: options?.class,
100
121
  required: options?.required,
101
- vIf: options?.vIf,
102
- disabled: options?.disabled,
103
122
  placeholder: options?.placeholder,
104
- defaultValue: options?.defaultValue,
105
- validate: options?.validate,
106
- onUpdate: options?.onUpdate,
107
123
  helptext: options?.helptext,
124
+ disabled: options?.disabled,
125
+ defaultValue: options?.defaultValue,
126
+ vIf: options?.vIf,
108
127
  transform: options?.transform,
109
128
  attrs: {
110
- type: options?.type,
129
+ autocomplete: options?.autocomplete,
111
130
  pattern: options?.pattern,
112
131
  multiline: options?.multiline,
113
- autocomplete: options?.autocomplete,
114
- rows: options?.rows,
115
- code: options?.code,
116
132
  autoheight: options?.autoheight,
133
+ code: options?.code,
134
+ rows: options?.rows,
117
135
  icon: options?.icon,
118
136
  iconStart: options?.iconStart,
137
+ type: options?.type,
119
138
  },
120
139
  }
121
140
  }
122
141
 
142
+ // import type { Option } from '@bagelink/vue'
143
+
144
+ // type OptionsSource = Option[] | ((query: string) => Promise<Option[]>)
145
+
123
146
  export function selectField<
124
147
  T,
125
148
  P extends Path<T, PO>,
@@ -127,28 +150,26 @@ export function selectField<
127
150
  >(
128
151
  id?: P,
129
152
  label?: string,
130
- options?: Option[] | ((query: string) => Promise<Option[]>) | ((val?: any, row?: T) => Option[] | ((query: string) => Promise<Option[]>)) | ((query: string, val?: any, row?: T) => Promise<Option[]>),
131
- config?: SlctInputOptions<T, P>,
153
+ options?: any,
154
+ fieldOptions?: SlctInputOptions<T, P>,
132
155
  ): SelectBagelField<T, P, PO> {
133
156
  return {
134
157
  $el: 'select',
135
158
  id,
136
- options,
137
- class: config?.class,
138
- placeholder: config?.placeholder,
139
- required: config?.required,
140
159
  label,
141
- defaultValue: config?.defaultValue,
142
- vIf: config?.vIf,
143
- validate: config?.validate,
144
- onUpdate: config?.onUpdate,
145
- transform: config?.transform,
160
+ class: fieldOptions?.class,
161
+ required: fieldOptions?.required,
162
+ helptext: fieldOptions?.helptext,
163
+ disabled: fieldOptions?.disabled,
164
+ defaultValue: fieldOptions?.defaultValue,
165
+ vIf: fieldOptions?.vIf,
166
+ transform: fieldOptions?.transform,
167
+ options,
146
168
  attrs: {
147
- disabled: config?.disabled,
148
- searchable: config?.searchable,
149
- multiselect: config?.multiselect,
150
- clearable: config?.clearable,
151
- autocomplete: config?.autocomplete,
169
+ ...fieldOptions?.attrs,
170
+ searchable: fieldOptions?.searchable,
171
+ multiselect: fieldOptions?.multiselect,
172
+ clearable: fieldOptions?.clearable,
152
173
  },
153
174
  }
154
175
  }
@@ -171,13 +192,17 @@ export function checkField<
171
192
  ): BaseBagelField<T, P, PO> {
172
193
  return {
173
194
  $el: 'check',
195
+ id,
196
+ label,
174
197
  class: options?.class,
175
198
  required: options?.required,
199
+ helptext: options?.helptext,
200
+ disabled: options?.disabled,
176
201
  defaultValue: options?.defaultValue,
177
- id,
178
- label,
202
+ vIf: options?.vIf,
179
203
  transform: options?.transform,
180
204
  attrs: {
205
+ ...options?.attrs,
181
206
  value: options?.value,
182
207
  },
183
208
  }
@@ -281,11 +306,10 @@ export function numField<
281
306
 
282
307
  export function frmRow<
283
308
  T,
284
- P extends Path<T, PO>,
285
309
  PO extends PathsOptions = DefaultPathsOptions,
286
310
  >(
287
- ...children: SchemaChild<T, P, PO>[]
288
- ): FieldByP<T, P, PO> {
311
+ ...children: SchemaChild<T, Path<T, PO>, PO>[]
312
+ ): { $el: string, class: string, children: SchemaChild<T, Path<T, PO>, PO>[] } {
289
313
  return {
290
314
  $el: 'div',
291
315
  class: 'flex gap-1 m_block align-items-end',
@@ -302,12 +326,17 @@ export function uploadField<
302
326
  >(
303
327
  id?: P,
304
328
  label?: string,
305
- options?: UploadOptions<T, P>
329
+ options?: UploadOptions<T, P>,
306
330
  ): BaseBagelField<T, P, PO> {
307
331
  return {
308
332
  $el: 'upload',
309
333
  id,
310
334
  label,
335
+ class: options?.class,
336
+ required: options?.required,
337
+ helptext: options?.helptext,
338
+ disabled: options?.disabled,
339
+ defaultValue: options?.defaultValue,
311
340
  vIf: options?.vIf,
312
341
  transform: options?.transform,
313
342
  attrs: {
@@ -353,20 +353,17 @@ export function img<
353
353
  ): BaseElementField<T, PO> {
354
354
  // Handle different overload patterns
355
355
  let id: Path<T, PO> | undefined
356
- let finalSrc: string = ''
357
356
  let finalOptions: ImgElementOptions<T, PO> = {}
358
357
 
359
358
  if (typeof idOrOptions === 'object' && idOrOptions !== null) {
360
359
  // img(options)
361
360
  finalOptions = idOrOptions
362
- const { id: optionId, src: optionSrc } = finalOptions
361
+ const { id: optionId } = finalOptions
363
362
  id = optionId as Path<T, PO> | undefined
364
- finalSrc = optionSrc ?? ''
365
363
  } else {
366
364
  // img(id, ...) patterns
367
365
  id = idOrOptions
368
366
  if (src != null) {
369
- finalSrc = src
370
367
  if (typeof altOrOptions === 'string') {
371
368
  // img(id, src, alt)
372
369
  finalOptions = { alt: altOrOptions }
@@ -1,4 +1,4 @@
1
- import type { Attributes, BglFormSchemaT, Path } from '@bagelink/vue'
1
+ import type { Attributes, BglFormSchemaT, Path } from '../types/BagelForm'
2
2
 
3
3
  const debouncers = new Map<() => void, ReturnType<typeof setTimeout>>()
4
4
 
@@ -93,7 +93,7 @@ export function iffer(field: any, itemData: any) {
93
93
  }
94
94
 
95
95
  export function denullify(itemData?: { [key: string]: any }, fieldID?: string) {
96
- if (!fieldID) return
96
+ if (!fieldID) return undefined
97
97
  return itemData ? itemData[fieldID] : undefined
98
98
  }
99
99
 
@@ -132,7 +132,8 @@ export async function appendScript(src: string, options?: { id?: string }): Prom
132
132
  await sleep(1)
133
133
  // If this script is already loading, return the existing promise
134
134
  if (scriptsLoading.has(scriptId)) {
135
- return scriptsLoading.get(scriptId)!
135
+ const existingPromise = scriptsLoading.get(scriptId)
136
+ if (existingPromise) return existingPromise
136
137
  }
137
138
 
138
139
  // Check if script is already in the document
@@ -157,7 +158,7 @@ export async function appendScript(src: string, options?: { id?: string }): Prom
157
158
  }
158
159
 
159
160
  script.onerror = (err) => {
160
- reject(err)
161
+ reject(new Error(String(err)))
161
162
  // Remove from loading scripts map on error
162
163
  scriptsLoading.delete(scriptId)
163
164
  }
@@ -241,7 +242,8 @@ export function downloadFile(source: string | Blob, fileName?: string) {
241
242
 
242
243
  if (typeof source === 'string') {
243
244
  link.href = upgradeHeaders(source)
244
- link.download = fileName || source.split('/').pop() || 'download'
245
+ const fileNameFromSource = source.split('/').pop()
246
+ link.download = fileName || fileNameFromSource || 'download'
245
247
  } else {
246
248
  const url = URL.createObjectURL(source)
247
249
  link.href = url
File without changes