@bagelink/vue 1.2.81 → 1.2.83

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/dist/components/Btn.vue.d.ts +1 -1
  2. package/dist/components/Btn.vue.d.ts.map +1 -1
  3. package/dist/components/DataPreview.vue.d.ts +16 -5
  4. package/dist/components/DataPreview.vue.d.ts.map +1 -1
  5. package/dist/components/Icon/Icon.vue.d.ts +4 -1
  6. package/dist/components/Icon/Icon.vue.d.ts.map +1 -1
  7. package/dist/components/ModalForm.vue.d.ts +2 -1
  8. package/dist/components/ModalForm.vue.d.ts.map +1 -1
  9. package/dist/components/dataTable/DataTable.vue.d.ts.map +1 -1
  10. package/dist/components/dataTable/useSorting.d.ts +1 -1
  11. package/dist/components/dataTable/useSorting.d.ts.map +1 -1
  12. package/dist/components/dataTable/useTableData.d.ts +7 -6
  13. package/dist/components/dataTable/useTableData.d.ts.map +1 -1
  14. package/dist/components/dataTable/useTableVirtualization.d.ts.map +1 -1
  15. package/dist/components/form/BagelForm.vue.d.ts +4 -10
  16. package/dist/components/form/BagelForm.vue.d.ts.map +1 -1
  17. package/dist/components/form/BglMultiStepForm.vue.d.ts +4 -3
  18. package/dist/components/form/BglMultiStepForm.vue.d.ts.map +1 -1
  19. package/dist/components/form/FieldArray.vue.d.ts +3 -2
  20. package/dist/components/form/FieldArray.vue.d.ts.map +1 -1
  21. package/dist/composables/index.d.ts +5 -5
  22. package/dist/composables/index.d.ts.map +1 -1
  23. package/dist/composables/useSchemaField.d.ts +5 -12
  24. package/dist/composables/useSchemaField.d.ts.map +1 -1
  25. package/dist/index.cjs +142 -228
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.mjs +143 -229
  29. package/dist/plugins/modalTypes.d.ts +3 -2
  30. package/dist/plugins/modalTypes.d.ts.map +1 -1
  31. package/dist/style.css +89 -89
  32. package/dist/types/BagelForm.d.ts +14 -11
  33. package/dist/types/BagelForm.d.ts.map +1 -1
  34. package/dist/types/TableSchema.d.ts +9 -9
  35. package/dist/types/TableSchema.d.ts.map +1 -1
  36. package/dist/utils/BagelFormUtils.d.ts +4 -3
  37. package/dist/utils/BagelFormUtils.d.ts.map +1 -1
  38. package/dist/utils/useSearch.d.ts +44 -0
  39. package/dist/utils/useSearch.d.ts.map +1 -0
  40. package/package.json +1 -1
  41. package/src/components/DataPreview.vue +16 -5
  42. package/src/components/Icon/Icon.vue +12 -3
  43. package/src/components/ModalForm.vue +6 -9
  44. package/src/components/dataTable/DataTable.vue +11 -14
  45. package/src/components/dataTable/useSorting.ts +1 -1
  46. package/src/components/dataTable/useTableData.ts +19 -42
  47. package/src/components/dataTable/useTableVirtualization.ts +4 -8
  48. package/src/components/form/BagelForm.vue +32 -97
  49. package/src/components/form/BglMultiStepForm.vue +7 -6
  50. package/src/components/form/FieldArray.vue +54 -45
  51. package/src/components/form/inputs/RichText/index.vue +1 -1
  52. package/src/composables/index.ts +12 -13
  53. package/src/composables/useSchemaField.ts +37 -35
  54. package/src/index.ts +1 -1
  55. package/src/plugins/modalTypes.ts +3 -2
  56. package/src/types/BagelForm.ts +22 -14
  57. package/src/types/TableSchema.ts +9 -9
  58. package/src/utils/BagelFormUtils.ts +4 -3
  59. package/src/utils/{search.ts → useSearch.ts} +1 -2
@@ -1,9 +1,10 @@
1
- <script setup lang="ts" generic="T extends {[key:string]:any}, P">
2
- import type { BglFormSchemaFnT } from '@bagelink/vue'
1
+ <script setup lang="ts" generic="T extends {[key:string]:any}, P extends Path<T>">
2
+ import type { BglFormSchemaT, Path } from '@bagelink/vue'
3
3
 
4
+ import type { MaybeRefOrGetter } from 'vue'
4
5
  import type { ComponentExposed, ComponentProps } from 'vue-component-type-helpers'
5
6
  import { BagelForm, Btn, useBglSchema, sleep } from '@bagelink/vue'
6
- import { ref, watch, computed, nextTick } from 'vue'
7
+ import { ref, watch, computed, nextTick, toValue } from 'vue'
7
8
 
8
9
  const props = withDefaults(
9
10
  defineProps<{
@@ -13,7 +14,7 @@ const props = withDefaults(
13
14
  'schema' | `${string}modelValue` | `ref${string}` | `onVnode${string}` | 'onSubmit'
14
15
  )
15
16
  >
16
- schema?: BglFormSchemaFnT<T>
17
+ schema?: MaybeRefOrGetter<BglFormSchemaT<T>>
17
18
  showProgress?: boolean
18
19
  rtl?: boolean
19
20
  stepLabels?: string[]
@@ -59,13 +60,13 @@ function reportValidity() {
59
60
  }
60
61
 
61
62
  const computedSchema = computed(
62
- () => useBglSchema({ schema: props.schema })
63
+ () => useBglSchema({ schema: toValue(props.schema) })
63
64
  )
64
65
 
65
66
  // Filter out steps with vIf conditions that evaluate to false
66
67
  const filteredSchema = computed(() => {
67
68
  const schema = computedSchema.value
68
- return schema.filter((step, index) => {
69
+ return schema.filter((step, _index) => {
69
70
  // Skip steps that have vIf or v-if returning false
70
71
  if (step.vIf !== undefined || step['v-if'] !== undefined) {
71
72
  const condition = step.vIf ?? step['v-if']
@@ -5,12 +5,13 @@ import type {
5
5
  Attributes,
6
6
  BagelFieldOptions,
7
7
  BaseBagelField,
8
- BglFormSchemaFnT,
8
+ BglFormSchemaT,
9
9
  Field,
10
10
  Path
11
11
  } from '@bagelink/vue'
12
+ import type { MaybeRefOrGetter } from 'vue'
12
13
  import { BagelForm, Btn, Loading, Icon } from '@bagelink/vue'
13
- import { ref, onMounted, computed, watch } from 'vue'
14
+ import { ref, computed, watch, toValue } from 'vue'
14
15
 
15
16
  export interface FieldArrayProps<T, P extends Path<T>> {
16
17
  el?: any
@@ -28,7 +29,7 @@ export interface FieldArrayProps<T, P extends Path<T>> {
28
29
  add?: boolean
29
30
  delete?: boolean
30
31
  transform?: (value: T) => T
31
- schema?: BglFormSchemaFnT<T>
32
+ schema?: MaybeRefOrGetter<BglFormSchemaT<T>>
32
33
  modelValue: T[]
33
34
  type?: 'object' | 'number' | 'text'
34
35
  }
@@ -53,12 +54,6 @@ const emit = defineEmits(['update:modelValue'])
53
54
  const minimizedItems = ref<boolean[]>([])
54
55
  const internalData = ref<any[]>(props.modelValue || [])
55
56
  const schemaState = ref<'loading' | 'loaded' | 'error'>('loaded')
56
- const resolvedSchemaData = ref<any[]>([])
57
-
58
- // Watch for external changes to modelValue
59
- watch(() => props.modelValue, (newValue) => {
60
- internalData.value = newValue || []
61
- }, { deep: true })
62
57
 
63
58
  // Generate schema for primitive types
64
59
  const primitiveSchema = computed<PrimitiveArrFieldT[]>(() => {
@@ -70,46 +65,57 @@ const primitiveSchema = computed<PrimitiveArrFieldT[]>(() => {
70
65
  return []
71
66
  })
72
67
 
68
+ const resolvedSchemaData = $computed(() => {
69
+ if (props.type !== 'object') return primitiveSchema.value as BglFormSchemaT<T>
70
+
71
+ return toValue(props.schema)
72
+ })
73
+
74
+ // Watch for external changes to modelValue
75
+ watch(() => props.modelValue, (newValue) => {
76
+ internalData.value = newValue || []
77
+ }, { deep: true })
78
+
73
79
  // Resolve schema
74
- async function resolveSchema() {
75
- // For primitive types, use the predefined schemaks
76
- if (props.type !== 'object') {
77
- resolvedSchemaData.value = primitiveSchema.value
78
- schemaState.value = 'loaded'
79
- return
80
- }
80
+ // async function resolveSchema() {
81
+ // // For primitive types, use the predefined schemaks
82
+ // if (props.type !== 'object') {
83
+ // resolvedSchemaData.value = primitiveSchema.value
84
+ // schemaState.value = 'loaded'
85
+ // return
86
+ // }
81
87
 
82
- // For object type without schema
83
- if (!props.schema) {
84
- resolvedSchemaData.value = []
85
- schemaState.value = 'loaded'
86
- return
87
- }
88
+ // // For object type without schema
89
+ // if (!props.schema) {
90
+ // resolvedSchemaData.value = []
91
+ // schemaState.value = 'loaded'
92
+ // return
93
+ // }
88
94
 
89
- // For object type with schema
90
- try {
91
- schemaState.value = 'loading'
92
- const isPromise = (obj: any) => obj && typeof obj.then === 'function'
95
+ // // For object type with schema
96
+ // try {
97
+ // // schemaState.value = 'loading'
98
+ // const isPromise = (obj: any) => obj && typeof obj.then === 'function'
93
99
 
94
- let result: any
95
- if (typeof props.schema === 'function') {
96
- result = props.schema()
97
- result = isPromise(result) ? await result : result
98
- } else {
99
- result = isPromise(props.schema) ? await props.schema : props.schema
100
- }
100
+ // let result: any
101
+ // if (typeof props.schema === 'function') {
102
+ // result = props.schema()
103
+ // result = isPromise(result) ? await result : result
104
+ // } else {
105
+ // result = isPromise(props.schema) ? await props.schema : props.schema
106
+ // }
101
107
 
102
- resolvedSchemaData.value = result
103
- schemaState.value = 'loaded'
104
- } catch (error) {
105
- console.error('Schema error:', error)
106
- schemaState.value = 'error'
107
- resolvedSchemaData.value = []
108
- }
109
- }
108
+ // resolvedSchemaData.value = result
109
+ // schemaState.value = 'loaded'
110
+ // } catch (error) {
111
+ // console.error('Schema error:', error)
112
+ // schemaState.value = 'error'
113
+ // resolvedSchemaData.value = []
114
+ // }
115
+ // }
110
116
 
111
- // Initialize schema on mount
112
- onMounted(resolveSchema)
117
+ // // Initialize schema on mount
118
+ // onMounted(resolveSchema)
113
119
 
114
120
  // Event handlers
115
121
  function emitValue() {
@@ -148,10 +154,13 @@ function updateItem(index: number, value: any) {
148
154
 
149
155
  // Computed properties for rendering
150
156
  const isPrimitiveType = computed(() => props.type === 'text' || props.type === 'number')
151
- const canRenderItems = computed(() => isPrimitiveType.value || (props.type === 'object' && resolvedSchemaData.value.length > 0)
157
+ const canRenderItems = computed(
158
+ () => isPrimitiveType.value || (
159
+ props.type === 'object' && Number(resolvedSchemaData?.length) > 0
160
+ )
152
161
  )
153
162
  const showMinimizeButton = computed(() => {
154
- return resolvedSchemaData.value.length > 2 || resolvedSchemaData.value.some(schema => schema.$el === 'richtext')
163
+ return Number(resolvedSchemaData?.length) > 2 || resolvedSchemaData?.some(schema => schema.$el === 'richtext')
155
164
  })
156
165
  </script>
157
166
 
@@ -147,7 +147,7 @@ watch(() => props.modelValue, (newValue, oldValue) => {
147
147
  })
148
148
 
149
149
  watch(() => editor.state.content, (newValue) => {
150
- if (editor.state.doc?.body.innerHTML) {
150
+ if (editor.state.doc?.body) {
151
151
  editor.state.doc.body.dir = hasRTL ? 'rtl' : 'ltr'
152
152
  }
153
153
  emit('update:modelValue', newValue)
@@ -1,33 +1,32 @@
1
- import type { BglFormSchemaFnT, BglFormSchemaT, IfAny } from '@bagelink/vue'
1
+ import type { BglFormSchemaT, IfAny } from '@bagelink/vue'
2
2
 
3
- import type { Ref, UnwrapRef } from 'vue'
3
+ import type { MaybeRefOrGetter, Ref, UnwrapRef } from 'vue'
4
4
  import { getFallbackSchema } from '@bagelink/vue'
5
- import { ref, watch } from 'vue'
5
+ import { ref, toValue, watch } from 'vue'
6
6
 
7
7
  export { useDevice } from './useDevice'
8
8
  export { usePolling } from './usePolling'
9
9
  export { useValidateFieldValue } from './useValidateFieldValue'
10
10
  interface UseBglSchemaParamsT<T> {
11
- schema?: BglFormSchemaFnT<T>
12
- columns?: string[]
13
- data?: any[]
11
+ schema?: MaybeRefOrGetter<BglFormSchemaT<T>>
12
+ columns?: MaybeRefOrGetter<string[]>
13
+ data?: T[]
14
14
  }
15
15
 
16
16
  export function useBglSchema<T = { [key: string]: unknown }>(
17
17
  { schema, columns, data }: UseBglSchemaParamsT<T> = {}
18
18
  ): BglFormSchemaT<T> {
19
- let _schema = schema
20
- if (typeof _schema === 'function') {
21
- _schema = _schema()
22
- }
19
+ const _schema = $computed(() => toValue(schema))
20
+ const _columns = $computed(() => toValue(columns))
21
+
23
22
  if (_schema) {
24
23
  return (
25
- columns && columns.length > 0
26
- ? _schema.filter(f => columns.includes(f.id as string))
24
+ _columns && _columns.length > 0
25
+ ? _schema.filter(f => _columns.includes(f.id as string))
27
26
  : _schema
28
27
  ) as BglFormSchemaT<T>
29
28
  }
30
- return getFallbackSchema(data, columns)
29
+ return getFallbackSchema(data, _columns)
31
30
  }
32
31
 
33
32
  export function localRef<T>(
@@ -1,5 +1,6 @@
1
1
  import type { VNode } from 'vue'
2
- import type { Field, BglFormSchemaT, SchemaChildrenT, Attributes, Path } from '../types/BagelForm'
2
+
3
+ import type { Field, Attributes, Path, SchemaChild, BaseBagelField, VNodeFn } from '../types/BagelForm'
3
4
  import {
4
5
  TextInput,
5
6
  NumberInput,
@@ -20,26 +21,20 @@ import {
20
21
  RangeInput,
21
22
  EmailInput
22
23
  } from '@bagelink/vue'
23
-
24
24
  import { h, isVNode } from 'vue'
25
25
 
26
26
  const SLOT_VALUE_COMPONENTS = new Set(['div', 'span', 'p'])
27
27
 
28
28
  const SRC_VALUE_COMPONENTS = new Set(['img', 'iframe'])
29
29
 
30
- export interface UseSchemaFieldOptions<T> {
30
+ export interface UseSchemaFieldOptions<T, SFP extends Path<T>> {
31
31
  mode?: 'form' | 'preview' | 'table'
32
32
  getFormData?: () => T
33
- onUpdateModelValue?: (field: Field<T>, value: any) => void
33
+ onUpdateModelValue?: (field: BaseBagelField<T, SFP>, value: any) => void
34
34
  includeUnset?: boolean
35
35
  }
36
36
 
37
- // Add type for supported child types
38
- interface SlotProps<T> { row?: T, field: Field<T> }
39
- type SlotFunction<T> = (props: SlotProps<T>) => any
40
- type SupportedSlot<T> = BglFormSchemaT<T> | VNode | SlotFunction<T>
41
-
42
- export function useSchemaField<T extends { [key: string]: any }, _P>(optns: UseSchemaFieldOptions<T>) {
37
+ export function useSchemaField<T extends { [key: string]: any }, SP extends Path<T>>(optns: UseSchemaFieldOptions<T, SP>) {
43
38
  const { mode = 'form', getFormData, onUpdateModelValue, includeUnset = false } = optns
44
39
 
45
40
  // Helper function to render objects recursively
@@ -101,21 +96,21 @@ export function useSchemaField<T extends { [key: string]: any }, _P>(optns: UseS
101
96
  return typeof field.$el === 'object' ? field.$el : componentMap[field.$el as keyof typeof componentMap] ?? field.$el ?? 'div'
102
97
  }
103
98
 
104
- function renderChild(child: SchemaChildrenT<T>[number], slots?: Record<string, SupportedSlot<T>>): any {
105
- if (typeof child === 'string') return child
99
+ function renderChild(child: SchemaChild<T, SP>, slots?: BaseBagelField<T, SP>['slots']) {
100
+ if (typeof child === 'string') return h(child)
106
101
  if (isVNode(child)) return child
107
102
  return renderField(
108
- child,
103
+ child as BaseBagelField<T, SP>,
109
104
  slots
110
105
  )
111
106
  }
112
107
 
113
108
  function renderField(
114
- field: Field<T>,
115
- slots?: Record<string, SupportedSlot<T>>
116
- ): VNode | null {
117
- const Component = getComponent(field)
118
- if (!Component) return null
109
+ field: BaseBagelField<T, SP>,
110
+ slots?: BaseBagelField<T, SP>['slots']
111
+ ): VNode | undefined {
112
+ const Component = getComponent(field as Field<T>)
113
+ if (!Component) return
119
114
 
120
115
  const rowData = (getFormData?.() || {}) as T | undefined
121
116
 
@@ -129,14 +124,14 @@ export function useSchemaField<T extends { [key: string]: any }, _P>(optns: UseS
129
124
  rowData
130
125
  )
131
126
  ) {
132
- return null
127
+ return
133
128
  }
134
129
  } else if (typeof condition === 'string') {
135
130
  if (!rowData?.[condition]) {
136
- return null
131
+ return
137
132
  }
138
133
  } else if (!condition) {
139
- return null
134
+ return
140
135
  }
141
136
  }
142
137
 
@@ -234,7 +229,8 @@ export function useSchemaField<T extends { [key: string]: any }, _P>(optns: UseS
234
229
  props.class = classify(currentValue, rowData, fieldClass, props.class)
235
230
 
236
231
  // Handle component slots with vIf aware child rendering
237
- const componentSlots: { [key: string]: any } = {}
232
+ // const componentSlots: { [name: string]: Slot } = {}
233
+ const componentSlots: Parameters<typeof h>[1] = {}
238
234
 
239
235
  // Add default slot if there are children
240
236
  if (children?.length) {
@@ -254,29 +250,35 @@ export function useSchemaField<T extends { [key: string]: any }, _P>(optns: UseS
254
250
  componentSlots[name] = () => {
255
251
  if (Array.isArray(slot)) {
256
252
  // Handle BglFormSchemaT array
257
- return slot.map(schemaField => renderField(schemaField, slots))
258
- } if (isVNode(slot)) {
259
- // Handle VNode
260
- return slot
261
- } if (typeof slot === 'function') {
262
- // Handle function slot
263
- const slotFn = slot as (props: SlotProps<T>) => any
264
- return slotFn({ row: rowData, field })
253
+ return slot.map((schemaField) => {
254
+ if (typeof schemaField === 'function') {
255
+ // Handle function slot
256
+ const slotFn = schemaField
257
+ return slotFn({ row: rowData, field })
258
+ }
259
+ if (isVNode(schemaField)) {
260
+ // Handle VNode
261
+ return schemaField
262
+ }
263
+
264
+ return renderField(schemaField as BaseBagelField<T, SP>, slots)
265
+ })
265
266
  }
266
- return slot
267
267
  }
268
268
  })
269
269
  }
270
270
 
271
271
  // Handle custom slot content from parent
272
- const slotContent = field.id && slots?.[field.id]
273
- ? (slots[field.id] as SlotFunction<T>)({ row: rowData, field })
274
- : undefined
272
+
273
+ const slotContent = field.id ? (slots?.[field.id] as VNodeFn<T, SP> | undefined)?.({ row: rowData, field }) : undefined
274
+ // field.id && slots?.[field.id] && typeof slots[field.id] === 'function' && !Array.isArray(slots?.[field.id])
275
+ // ? (slots[field.id])({ row: rowData, field })
276
+ // : undefined
275
277
 
276
278
  if (mode === 'preview') {
277
279
  // Skip rendering if value is unset and includeUnset is false
278
280
  if (!includeUnset && (transformedValue === undefined || transformedValue === null || transformedValue.length === 0)) {
279
- return null
281
+ return
280
282
  }
281
283
 
282
284
  return h('div', { class: 'preview-field' }, [
package/src/index.ts CHANGED
@@ -17,4 +17,4 @@ export * from './utils/calendar/dateUtils'
17
17
  import './styles/bagel.css'
18
18
 
19
19
  export * from './utils/constants'
20
- export * from './utils/search'
20
+ export * from './utils/useSearch'
@@ -1,4 +1,5 @@
1
- import type { BglFormSchemaFnT, BtnOptions, ThemeType } from '@bagelink/vue'
1
+ import type { BglFormSchemaT, BtnOptions, ThemeType } from '@bagelink/vue'
2
+ import type { MaybeRefOrGetter } from 'vue'
2
3
 
3
4
  export interface ModalOptions {
4
5
  title?: string
@@ -37,7 +38,7 @@ export interface ModalFormComponentProps<T extends { [key: string]: any }> exten
37
38
  }
38
39
 
39
40
  export interface ModalFormOptions<T extends { [key: string]: any }> {
40
- 'schema': BglFormSchemaFnT<T>
41
+ 'schema': MaybeRefOrGetter<BglFormSchemaT<T>>
41
42
  'modelValue'?: T
42
43
  'onUpdate:modelValue'?: (val: T) => void
43
44
  'onSubmit'?: (formData: T) => any
@@ -1,6 +1,6 @@
1
1
  import type { SelectInput, TextInput } from '@bagelink/vue'
2
2
  import type { Paths, Get, IterableElement, LiteralUnion } from 'type-fest'
3
- import type { VNode } from 'vue'
3
+ import type { SetupContext, VNode } from 'vue'
4
4
  import type { ComponentExposed } from 'vue-component-type-helpers'
5
5
 
6
6
  export type ToString<T> = T extends string | number ? `${T}` : never
@@ -65,21 +65,23 @@ export type FieldVal<T, P extends Path<T>> = Get<T, P>
65
65
  /** If path P in T is an array, this gives the array's element type. */
66
66
  export type ArrayFieldVal<T, P extends Path<T>> = IterableElement<Get<T, P>>
67
67
 
68
- export type SchemaChildrenT<T> = (Field<T> | string | VNode)[]
68
+ export type VNodeFn<T, P extends Path<T>> = (props: { row?: T, field: BaseBagelField<T, P> }) => VNode
69
+
70
+ export type SchemaChild<T, P extends Path<T>> = Field<T> | VNode | VNodeFn<T, P> | string
69
71
 
70
72
  export interface BaseBagelField<T, P extends Path<T>> {
71
73
  '$el'?: any
72
74
  'id'?: P
73
75
  'label'?: string
74
76
  'placeholder'?: string
75
- 'children'?: SchemaChildrenT<T>
76
77
  'class'?: AttributeValue | AttributeFn<T, P>
77
78
  'attrs'?: Attributes<T, P>
78
79
  'required'?: boolean
79
80
  'disabled'?: boolean
80
81
  'helptext'?: string
81
82
  'options'?: BagelFieldOptions<T>
82
- 'slots'?: { [key: string]: Field<T>[] }
83
+ 'children'?: SchemaChild<T, P>[]
84
+ 'slots'?: { [key: string]: SchemaChild<T, P>[] } | SetupContext['slots']
83
85
  'defaultValue'?: any
84
86
  'vIf'?: VIfType<T, P>
85
87
  'v-if'?: VIfType<T, P>
@@ -92,22 +94,28 @@ export type MappedBaseBagelField<T> = {
92
94
  [P in Path<T>]: BaseBagelField<T, P>
93
95
  }[Path<T>]
94
96
 
95
- export type InputBagelField<T> = MappedBaseBagelField<T> & {
96
- $el: 'text' | ComponentExposed<typeof TextInput>
97
- type?: string
98
- }
99
-
100
- export type SelectBagelField<T> = MappedBaseBagelField<T> & {
101
- $el: 'select' | ComponentExposed<typeof SelectInput>
102
- }
103
-
104
97
  export type Field<T> = MappedBaseBagelField<T>
105
98
 
106
99
  export type BglFieldT<T> = Field<T>
107
100
 
108
101
  export type BglFormSchemaT<T> = Field<T>[]
109
102
 
110
- export type BglFormSchemaFnT<T> = (() => BglFormSchemaT<T>) | BglFormSchemaT<T>
103
+ export type InputBagelField<T> = Field<T> & {
104
+ $el: 'text' | ComponentExposed<typeof TextInput>
105
+ type?: string
106
+ }
107
+ // export interface InputBagelField<T> extends BaseBagelField<T, Path<T>> {
108
+ // $el: 'text' | ComponentExposed<typeof TextInput>
109
+ // type?: string
110
+ // }
111
+
112
+ export type SelectBagelField<T> = Field<T> & {
113
+ $el: 'select' | ComponentExposed<typeof SelectInput>
114
+ }
115
+ // export interface SelectBagelField<T> extends BaseBagelField<T, Path<T>> {
116
+ // $el: 'select' | ComponentExposed<typeof SelectInput>
117
+ // type?: string
118
+ // }
111
119
 
112
120
  export interface ValidateInputBaseT {
113
121
  validate?: ValidationFn<{ [key: string]: unknown }, string>
@@ -1,19 +1,19 @@
1
1
  import type { BglFormSchemaT } from '@bagelink/vue'
2
- import type { Ref, ComputedRef } from 'vue'
2
+ import type { MaybeRefOrGetter, ComputedRef } from 'vue'
3
3
 
4
4
  export type SortDirectionsT = 'ASC' | 'DESC'
5
5
  export type EmitOrderT = `${string} ${SortDirectionsT}`
6
6
 
7
7
  export interface TableSchemaProps<T extends { [key: string]: any } = { [key: string]: any }> {
8
8
  data: T[]
9
- schema?: BglFormSchemaT<T> | (() => BglFormSchemaT<T>)
10
- columns?: string[]
11
- useServerSort?: boolean
9
+ schema?: MaybeRefOrGetter<BglFormSchemaT<T>>
10
+ columns?: MaybeRefOrGetter<string[]>
11
+ useServerSort?: MaybeRefOrGetter<boolean>
12
12
  selectable?: boolean
13
13
  onLastItemVisible?: () => void
14
14
  }
15
15
 
16
- export interface SortingOptions<T> {
16
+ export interface SortingOptions {
17
17
  onSort: (field: string, direction: SortDirectionsT) => void
18
18
  }
19
19
 
@@ -24,15 +24,15 @@ export interface TableSelectionOptions<T> {
24
24
  }
25
25
 
26
26
  export interface TableVirtualizationOptions<T> {
27
- data: Ref<T[]> | ComputedRef<T[]>
27
+ data: ComputedRef<T[]>
28
28
  itemHeight: number
29
29
  onLastItemVisible?: () => void
30
30
  }
31
31
 
32
32
  export interface TableDataOptions<T> {
33
- data: Ref<T[]> | ComputedRef<T[]>
34
- schema?: BglFormSchemaT<T> | (() => BglFormSchemaT<T>) | Promise<BglFormSchemaT<T>> | Promise<() => BglFormSchemaT<T>>
35
- columns?: string[]
33
+ data: MaybeRefOrGetter<T[]>
34
+ schema?: MaybeRefOrGetter<BglFormSchemaT<T>>
35
+ columns?: MaybeRefOrGetter<string[]>
36
36
  sortField: string
37
37
  sortDirection: SortDirectionsT
38
38
  useServerSort?: boolean
@@ -1,4 +1,4 @@
1
- import type { ArrayFieldVal, Attributes, BaseBagelField, BglFormSchemaT, Field, IconType, InputBagelField, Option, Path, SelectBagelField } from '@bagelink/vue'
1
+ import type { ArrayFieldVal, Attributes, BaseBagelField, BglFormSchemaT, Field, IconType, InputBagelField, Option, Path, SchemaChild, SelectBagelField } from '@bagelink/vue'
2
2
  import type { UploadInputProps } from '../components/form/inputs/Upload/upload.types'
3
3
 
4
4
  interface InputOptions<T, P extends Path<T>> extends Partial<BaseBagelField<T, P>> {
@@ -231,7 +231,7 @@ export function numField<T, P extends Path<T>>(
231
231
  }
232
232
 
233
233
  // export function frmRow<T, P extends Path<T>>(...children: SchemaChildrenT<T>): BaseBagelField<T, P> {
234
- export function frmRow<T>(...children: Field<T>[]): Field<T> {
234
+ export function frmRow<T>(...children: SchemaChild<T, Path<T>>[]): Field<T> {
235
235
  return {
236
236
  $el: 'div',
237
237
  class: 'flex gap-1 m_block align-items-end',
@@ -239,7 +239,8 @@ export function frmRow<T>(...children: Field<T>[]): Field<T> {
239
239
  }
240
240
  }
241
241
 
242
- export type UploadOptions<T, K extends Path<T>> = InputOptions<T, K> & UploadInputProps
242
+ // export type UploadOptions<T, K extends Path<T>> = InputOptions<T, K> & UploadInputProps
243
+ export interface UploadOptions<T, K extends Path<T>> extends InputOptions<T, K>, UploadInputProps {}
243
244
 
244
245
  export function uploadField<T, P extends Path<T>>(id: P, label?: string, options?: UploadOptions<T, P>): BaseBagelField<T, P> {
245
246
  return {
@@ -112,7 +112,7 @@ export interface SearchItemParams<T> {
112
112
  }
113
113
 
114
114
  export interface SearchResult<T> {
115
- results: ComputedRef<readonly T[]>
115
+ results: ComputedRef<T[]>
116
116
  resultCount: ComputedRef<number>
117
117
  hasResults: ComputedRef<boolean>
118
118
  isSearching: ComputedRef<boolean>
@@ -378,7 +378,6 @@ export function useSearch<T>(
378
378
  // Otherwise use client-side filtering
379
379
  return searchItems(params)
380
380
  }
381
-
382
381
  // Create computed references
383
382
  const results = computed(() => getFilteredResults())
384
383
  const resultCount = computed(() => results.value.length)