@bagelink/vue 1.2.143 → 1.2.147

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 (33) hide show
  1. package/dist/components/AddressSearch.vue.d.ts.map +1 -1
  2. package/dist/components/Dropdown.vue.d.ts.map +1 -1
  3. package/dist/components/Icon.vue.d.ts +16 -0
  4. package/dist/components/Icon.vue.d.ts.map +1 -0
  5. package/dist/components/calendar/views/CalendarPopover.vue.d.ts +2 -2
  6. package/dist/components/calendar/views/CalendarPopover.vue.d.ts.map +1 -1
  7. package/dist/components/form/BglFieldSet.vue.d.ts +25 -0
  8. package/dist/components/form/BglFieldSet.vue.d.ts.map +1 -0
  9. package/dist/components/form/FieldArray.vue.d.ts +1 -1
  10. package/dist/components/form/FieldArray.vue.d.ts.map +1 -1
  11. package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
  12. package/dist/components/form/inputs/Upload/useFileUpload.d.ts.map +1 -1
  13. package/dist/iconify-0J3vK-m1.cjs +1693 -0
  14. package/dist/iconify-Bc1B42Ak.cjs +1771 -0
  15. package/dist/iconify-BiLGk5km.js +1693 -0
  16. package/dist/iconify-DVnNdzog.js +1771 -0
  17. package/dist/index.cjs +43 -32
  18. package/dist/index.mjs +43 -32
  19. package/dist/style.css +128 -128
  20. package/dist/types/BagelForm.d.ts +12 -10
  21. package/dist/types/BagelForm.d.ts.map +1 -1
  22. package/dist/types/timeago.d.ts +23 -0
  23. package/dist/types/timeago.d.ts.map +1 -0
  24. package/dist/utils/BagelFormUtils.d.ts +6 -6
  25. package/dist/utils/BagelFormUtils.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/src/components/form/FieldArray.vue +1 -1
  28. package/src/components/form/inputs/Upload/UploadInput.vue +4 -4
  29. package/src/components/form/inputs/Upload/useFileUpload.ts +4 -5
  30. package/src/types/BagelForm.ts +19 -11
  31. package/src/utils/BagelFormUtils.ts +9 -15
  32. package/dist/components/Carousel2.vue.d.ts +0 -89
  33. package/dist/components/Carousel2.vue.d.ts.map +0 -1
@@ -24,7 +24,7 @@ export interface FieldArrayProps<T, P extends Path<T>> {
24
24
  required?: boolean
25
25
  disabled?: boolean
26
26
  helptext?: string
27
- options?: BagelFieldOptions<T>
27
+ options?: BagelFieldOptions<T, P>
28
28
  defaultValue?: any
29
29
  add?: boolean
30
30
  delete?: boolean
@@ -82,7 +82,7 @@ function fileName(pathKey: string) {
82
82
  icon="upload"
83
83
  outline
84
84
  :value="btnPlaceholder || 'Upload'"
85
- @click="browse(true)"
85
+ @click="browse()"
86
86
  />
87
87
 
88
88
  <template v-for="path_key in pathKeys" :key="path_key">
@@ -100,7 +100,7 @@ function fileName(pathKey: string) {
100
100
  color="gray"
101
101
  thin
102
102
  icon="autorenew"
103
- @click="browse(true)"
103
+ @click="browse()"
104
104
  />
105
105
  <Btn
106
106
  icon="download"
@@ -139,7 +139,7 @@ function fileName(pathKey: string) {
139
139
  'bgl_oval-upload': oval,
140
140
  }"
141
141
  :style="{ width, height }"
142
- @click="browse(true)"
142
+ @click="browse()"
143
143
  @dragover="(e) => handleDrag(e, true)"
144
144
  @drop="handleDrop"
145
145
  @dragleave="(e) => handleDrag(e)"
@@ -223,7 +223,7 @@ function fileName(pathKey: string) {
223
223
  color="gray"
224
224
  thin
225
225
  icon="autorenew"
226
- @click="browse(true)"
226
+ @click="browse()"
227
227
  />
228
228
  <Btn
229
229
  v-tooltip="'Download'"
@@ -30,7 +30,7 @@ export function useFileUpload(props: UseFileUploadProps = {}) {
30
30
  // File handling methods
31
31
  const fileToUrl = (file: File) => URL.createObjectURL(file)
32
32
 
33
- const addFile = (file?: File | File[] | FileList | null) => {
33
+ function addFile(file?: File | File[] | FileList | null) {
34
34
  if (!file) return
35
35
 
36
36
  let filesToAdd: File[] = []
@@ -62,7 +62,7 @@ export function useFileUpload(props: UseFileUploadProps = {}) {
62
62
  }
63
63
  }
64
64
 
65
- const removeFile = async (pathKeyOrFile: string | File | QueueFile) => {
65
+ async function removeFile(pathKeyOrFile: string | File | QueueFile) {
66
66
  if (typeof pathKeyOrFile === 'string') {
67
67
  // Remove from both lists
68
68
  storageFiles.value = storageFiles.value.filter(file => file.path_key !== pathKeyOrFile)
@@ -92,8 +92,7 @@ export function useFileUpload(props: UseFileUploadProps = {}) {
92
92
  }
93
93
  }
94
94
  }
95
-
96
- const flushQueue = async () => {
95
+ async function flushQueue() {
97
96
  // Only process files in the current namespace
98
97
  const namespaceQueue = fileQueue.value.filter(file => file.namespace === namespace)
99
98
 
@@ -123,7 +122,7 @@ export function useFileUpload(props: UseFileUploadProps = {}) {
123
122
  }
124
123
 
125
124
  // UI interaction
126
- const browse = (autoFlush = false) => {
125
+ function browse(autoFlush = false) {
127
126
  if (props.disabled) return
128
127
 
129
128
  const input = document.createElement('input')
@@ -1,5 +1,5 @@
1
1
  import type { SelectInput, TextInput } from '@bagelink/vue'
2
- import type { Paths, Get, IterableElement, LiteralUnion } from 'type-fest'
2
+ import type { Paths, Get, IterableElement, LiteralUnion, OmitIndexSignature } from 'type-fest'
3
3
  import type { VNode } from 'vue'
4
4
  import type { ComponentExposed } from 'vue-component-type-helpers'
5
5
 
@@ -17,7 +17,7 @@ export interface Attributes<T, P extends Path<T>> {
17
17
  [key: string]: AttributeValue | AttributeFn<T, P>
18
18
  }
19
19
 
20
- export type BagelFieldOptions<T> = (
20
+ export type BagelFieldOptions<T, P extends Path<T>> = (
21
21
  string
22
22
  | (
23
23
  {
@@ -29,9 +29,8 @@ export type BagelFieldOptions<T> = (
29
29
  | boolean
30
30
  | { [key: string]: any }
31
31
  )[]
32
- | ((val: any, rowData?: T) => void)
32
+ | ((val?: FieldVal<T, P>, rowData?: T) => void)
33
33
  )
34
- // TODO: ^^ replace any with a more specific type (perhaps FieldVal<T, P>)
35
34
 
36
35
  export type VIfType<T, P extends Path<T>> = (
37
36
  string |
@@ -40,14 +39,14 @@ export type VIfType<T, P extends Path<T>> = (
40
39
  )
41
40
 
42
41
  export type ValidationFn<T, P extends Path<T>> = (
43
- val: FieldVal<T, P>,
42
+ val?: FieldVal<T, P>,
44
43
  rowData?: T,
45
44
  ) => string | undefined
46
45
 
47
46
  export type _Path<T> = (
48
47
  ToString<
49
48
  Paths<
50
- T,
49
+ OmitIndexSignature<T>,
51
50
  {
52
51
  bracketNotation: false
53
52
  }
@@ -62,7 +61,12 @@ export type Path<T> = (
62
61
  )
63
62
 
64
63
  /** The value type at path P in object T. */
65
- export type FieldVal<T, P extends Path<T>> = Get<T, P>
64
+ // Fall back to unknown if type resolution fails
65
+ export type FieldVal<T, P extends Path<T>> = (
66
+ unknown extends Get<T, P> ?
67
+ unknown :
68
+ Get<T, P>
69
+ )
66
70
 
67
71
  /** If path P in T is an array, this gives the array's element type. */
68
72
  export type ArrayFieldVal<T, P extends Path<T>> = IterableElement<Get<T, P>>
@@ -81,7 +85,7 @@ export interface BaseBagelField<T, P extends Path<T>> {
81
85
  'required'?: boolean
82
86
  'disabled'?: boolean
83
87
  'helptext'?: string
84
- 'options'?: BagelFieldOptions<T>
88
+ 'options'?: BagelFieldOptions<T, P>
85
89
  'children'?: SchemaChild<T, P>[]
86
90
  'slots'?: { [key: string]: SchemaChild<T, P>[] }
87
91
  'defaultValue'?: any
@@ -92,11 +96,15 @@ export interface BaseBagelField<T, P extends Path<T>> {
92
96
  'validate'?: ValidationFn<T, P>
93
97
  }
94
98
 
95
- export type MappedBaseBagelField<T> = {
99
+ export type _MappedBaseBagelField<T> = {
96
100
  [P in Path<T>]: BaseBagelField<T, P>
97
- }[Path<T>]
101
+ }
102
+
103
+ export type MappedBaseBagelFieldP<T, P extends Path<T>> = _MappedBaseBagelField<T>[P]
104
+
105
+ export type FieldByP<T, P extends Path<T>> = MappedBaseBagelFieldP<T, P>
98
106
 
99
- export type Field<T> = MappedBaseBagelField<T>
107
+ export type Field<T> = MappedBaseBagelFieldP<T, Path<T>>
100
108
 
101
109
  export type BglFieldT<T> = Field<T>
102
110
 
@@ -1,4 +1,4 @@
1
- import type { ArrayFieldVal, Attributes, BaseBagelField, BglFormSchemaT, Field, IconType, InputBagelField, Option, Path, SchemaChild, SelectBagelField, UploadInputProps } from '@bagelink/vue'
1
+ import type { ArrayFieldVal, Attributes, BaseBagelField, BglFormSchemaT, FieldByP, IconType, InputBagelField, Option, Path, SchemaChild, SelectBagelField, UploadInputProps } from '@bagelink/vue'
2
2
 
3
3
  interface InputOptions<T, P extends Path<T>> extends Partial<BaseBagelField<T, P>> {
4
4
  defaultValue?: string | number
@@ -229,25 +229,19 @@ export function numField<T, P extends Path<T>>(
229
229
  }
230
230
  }
231
231
 
232
- export function frmRow<
233
- T,
234
- P extends Path<T>
235
- >(
232
+ export function frmRow<T, P extends Path<T>>(
236
233
  ...children: SchemaChild<T, P>[]
237
- ): Field<T> {
234
+ ): FieldByP<T, P> {
238
235
  return {
239
236
  $el: 'div',
240
237
  class: 'flex gap-1 m_block align-items-end',
241
- children: children as Field<T>[],
238
+ children,
242
239
  }
243
240
  }
244
241
 
245
242
  export interface UploadOptions<T, K extends Path<T>> extends Omit<UploadInputProps, 'id'>, InputOptions<T, K> {}
246
243
 
247
- export function uploadField<
248
- T,
249
- P extends Path<T>
250
- >(
244
+ export function uploadField<T, P extends Path<T>>(
251
245
  id: P,
252
246
  label?: string,
253
247
  options?: UploadOptions<T, P>
@@ -294,7 +288,7 @@ export function rangeField<T, P extends Path<T>>(
294
288
  }
295
289
  }
296
290
 
297
- export function bglForm<T>(idOrField?: string | Field<T>, ...schema: Field<T>[]) {
291
+ export function bglForm<T>(idOrField?: string | FieldByP<T, Path<T>>, ...schema: FieldByP<T, Path<T>>[]) {
298
292
  if (typeof idOrField === 'string') {
299
293
  return {
300
294
  $el: 'bagelform',
@@ -342,15 +336,15 @@ export function colorField<T, P extends Path<T>>(
342
336
  }
343
337
  }
344
338
 
345
- export function findBglFieldById<T>(id: string, _schema: BglFormSchemaT<T>): Field<T> | undefined {
339
+ export function findBglFieldById<T>(id: string, _schema: BglFormSchemaT<T>): FieldByP<T, Path<T>> | undefined {
346
340
  for (const field of _schema) {
347
- if (field.id === id) return field as Field<T> | undefined
341
+ if (field.id === id) return field as FieldByP<T, Path<T>> | undefined
348
342
  if (field.children && Number(field.children.length) > 0) {
349
343
  const fieldChildren = field.children.filter(
350
344
  c => typeof c === 'object' && '$el' in c
351
345
  )
352
346
  const child = findBglFieldById(id, fieldChildren as BglFormSchemaT<T>)
353
- if (child) return child as Field<T> | undefined
347
+ if (child) return child as FieldByP<T, Path<T>> | undefined
354
348
  }
355
349
  }
356
350
  return undefined
@@ -1,89 +0,0 @@
1
- type Easing = 'ease-in-out' | 'ease-in' | 'ease-out' | 'linear';
2
- type AutoplayMode = 'disabled' | 'standard' | 'linear';
3
- type AutoplayValue = boolean | AutoplayMode;
4
- interface CarouselOptions {
5
- duration?: number;
6
- easing?: Easing;
7
- perPage?: number | {
8
- [key: number]: number;
9
- };
10
- startIndex?: number;
11
- draggable?: boolean;
12
- multipleDrag?: boolean;
13
- threshold?: number;
14
- loop?: boolean;
15
- rtl?: boolean;
16
- autoplay?: AutoplayValue;
17
- autoplayInterval?: number;
18
- autoplaySpeed?: number;
19
- pauseOnHover?: boolean;
20
- dots?: boolean;
21
- slideWidth?: number;
22
- onInit?: () => void;
23
- onChange?: () => void;
24
- }
25
- declare function prev(howManySlides?: number): void;
26
- declare function next(howManySlides?: number): void;
27
- declare function goTo(index: number): void;
28
- declare function remove(index: number): void;
29
- declare function insert(item: Element, index: number): void;
30
- declare function prepend(item: Element): void;
31
- declare function append(item: Element): void;
32
- declare function destroy(restoreMarkup?: boolean): void;
33
- declare function pauseAutoplay(): void;
34
- declare function resumeAutoplay(): void;
35
- declare function __VLS_template(): {
36
- attrs: Partial<{}>;
37
- slots: {
38
- default?(_: {}): any;
39
- };
40
- refs: {
41
- carouselRef: HTMLDivElement;
42
- };
43
- rootEl: HTMLDivElement;
44
- };
45
- type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
46
- declare const __VLS_component: import('vue').DefineComponent<CarouselOptions, {
47
- prev: typeof prev;
48
- next: typeof next;
49
- goTo: typeof goTo;
50
- remove: typeof remove;
51
- insert: typeof insert;
52
- prepend: typeof prepend;
53
- append: typeof append;
54
- destroy: typeof destroy;
55
- currentSlide: import('vue').Ref<number, number>;
56
- pauseAutoplay: typeof pauseAutoplay;
57
- resumeAutoplay: typeof resumeAutoplay;
58
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
59
- change: () => any;
60
- init: () => any;
61
- }, string, import('vue').PublicProps, Readonly<CarouselOptions> & Readonly<{
62
- onChange?: (() => any) | undefined;
63
- onInit?: (() => any) | undefined;
64
- }>, {
65
- autoplay: AutoplayValue;
66
- loop: boolean;
67
- duration: number;
68
- easing: Easing;
69
- startIndex: number;
70
- draggable: boolean;
71
- multipleDrag: boolean;
72
- threshold: number;
73
- rtl: boolean;
74
- autoplayInterval: number;
75
- autoplaySpeed: number;
76
- pauseOnHover: boolean;
77
- dots: boolean;
78
- slideWidth: number;
79
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
80
- carouselRef: HTMLDivElement;
81
- }, HTMLDivElement>;
82
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
83
- export default _default;
84
- type __VLS_WithTemplateSlots<T, S> = T & {
85
- new (): {
86
- $slots: S;
87
- };
88
- };
89
- //# sourceMappingURL=Carousel2.vue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Carousel2.vue.d.ts","sourceRoot":"","sources":["../../src/components/Carousel2.vue"],"names":[],"mappings":"AAy/BA,KAAK,MAAM,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;AAC/D,KAAK,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAA;AACtD,KAAK,aAAa,GAAG,OAAO,GAAG,YAAY,CAAA;AAE3C,UAAU,eAAe;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACj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