@bagelink/vue 1.2.79 → 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.
- package/bin/experimentalGenTypedRoutes.ts +13 -2
- package/dist/components/Btn.vue.d.ts +1 -1
- package/dist/components/Btn.vue.d.ts.map +1 -1
- package/dist/components/DataPreview.vue.d.ts +16 -5
- package/dist/components/DataPreview.vue.d.ts.map +1 -1
- package/dist/components/Icon/Icon.vue.d.ts +4 -1
- package/dist/components/Icon/Icon.vue.d.ts.map +1 -1
- package/dist/components/ModalForm.vue.d.ts +2 -1
- package/dist/components/ModalForm.vue.d.ts.map +1 -1
- package/dist/components/dataTable/DataTable.vue.d.ts.map +1 -1
- package/dist/components/dataTable/useSorting.d.ts +1 -1
- package/dist/components/dataTable/useSorting.d.ts.map +1 -1
- package/dist/components/dataTable/useTableData.d.ts +7 -6
- package/dist/components/dataTable/useTableData.d.ts.map +1 -1
- package/dist/components/dataTable/useTableVirtualization.d.ts.map +1 -1
- package/dist/components/form/BagelForm.vue.d.ts +5 -10
- package/dist/components/form/BagelForm.vue.d.ts.map +1 -1
- package/dist/components/form/BglMultiStepForm.vue.d.ts +10 -6
- package/dist/components/form/BglMultiStepForm.vue.d.ts.map +1 -1
- package/dist/components/form/FieldArray.vue.d.ts +3 -2
- package/dist/components/form/FieldArray.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts +14 -6
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
- package/dist/composables/index.d.ts +5 -5
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/useSchemaField.d.ts +5 -12
- package/dist/composables/useSchemaField.d.ts.map +1 -1
- package/dist/index.cjs +298 -357
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +299 -358
- package/dist/plugins/modalTypes.d.ts +3 -2
- package/dist/plugins/modalTypes.d.ts.map +1 -1
- package/dist/style.css +165 -135
- package/dist/types/BagelForm.d.ts +14 -11
- package/dist/types/BagelForm.d.ts.map +1 -1
- package/dist/types/TableSchema.d.ts +9 -9
- package/dist/types/TableSchema.d.ts.map +1 -1
- package/dist/utils/BagelFormUtils.d.ts +4 -3
- package/dist/utils/BagelFormUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/useSearch.d.ts +44 -0
- package/dist/utils/useSearch.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/DataPreview.vue +16 -5
- package/src/components/Icon/Icon.vue +12 -3
- package/src/components/ModalForm.vue +6 -9
- package/src/components/dataTable/DataTable.vue +11 -14
- package/src/components/dataTable/useSorting.ts +1 -1
- package/src/components/dataTable/useTableData.ts +19 -42
- package/src/components/dataTable/useTableVirtualization.ts +4 -8
- package/src/components/form/BagelForm.vue +33 -97
- package/src/components/form/BglMultiStepForm.vue +52 -36
- package/src/components/form/FieldArray.vue +54 -45
- package/src/components/form/inputs/CodeEditor/Index.vue +160 -98
- package/src/components/form/inputs/RichText/index.vue +13 -12
- package/src/composables/index.ts +12 -13
- package/src/composables/useSchemaField.ts +37 -35
- package/src/index.ts +1 -1
- package/src/plugins/modalTypes.ts +3 -2
- package/src/types/BagelForm.ts +22 -14
- package/src/types/TableSchema.ts +9 -9
- package/src/utils/BagelFormUtils.ts +4 -3
- package/src/utils/index.ts +38 -13
- package/src/utils/{search.ts → useSearch.ts} +1 -2
package/src/types/BagelForm.ts
CHANGED
|
@@ -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
|
|
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
|
-
'
|
|
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
|
|
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>
|
package/src/types/TableSchema.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { BglFormSchemaT } from '@bagelink/vue'
|
|
2
|
-
import type {
|
|
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?:
|
|
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
|
|
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:
|
|
27
|
+
data: ComputedRef<T[]>
|
|
28
28
|
itemHeight: number
|
|
29
29
|
onLastItemVisible?: () => void
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface TableDataOptions<T> {
|
|
33
|
-
data:
|
|
34
|
-
schema?:
|
|
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:
|
|
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 {
|
package/src/utils/index.ts
CHANGED
|
@@ -124,26 +124,51 @@ export function sleep(ms: number = 100) {
|
|
|
124
124
|
return new Promise(resolve => setTimeout(resolve, ms))
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
127
|
+
// Keep track of loading scripts
|
|
128
|
+
const scriptsLoading = new Map<string, Promise<void>>()
|
|
129
|
+
|
|
130
|
+
export async function appendScript(src: string, options?: { id?: string }): Promise<void> {
|
|
131
|
+
const scriptId = options?.id || src
|
|
132
|
+
await sleep(1)
|
|
133
|
+
// If this script is already loading, return the existing promise
|
|
134
|
+
if (scriptsLoading.has(scriptId)) {
|
|
135
|
+
return scriptsLoading.get(scriptId)!
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Check if script is already in the document
|
|
139
|
+
if (options?.id && document.getElementById(options.id)) {
|
|
140
|
+
return Promise.resolve()
|
|
141
|
+
} else if (document.querySelector(`script[src="${src}"]`)) {
|
|
142
|
+
return Promise.resolve()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Create a new loading promise for this script
|
|
146
|
+
const loadingPromise = new Promise<void>((resolve, reject) => {
|
|
138
147
|
const script = document.createElement('script')
|
|
139
148
|
script.src = src
|
|
140
149
|
if (options?.id) {
|
|
141
150
|
script.id = options.id
|
|
142
151
|
}
|
|
143
|
-
|
|
144
|
-
script.
|
|
152
|
+
|
|
153
|
+
script.onload = () => {
|
|
154
|
+
resolve()
|
|
155
|
+
// Remove from loading scripts map when done
|
|
156
|
+
scriptsLoading.delete(scriptId)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
script.onerror = (err) => {
|
|
160
|
+
reject(err)
|
|
161
|
+
// Remove from loading scripts map on error
|
|
162
|
+
scriptsLoading.delete(scriptId)
|
|
163
|
+
}
|
|
164
|
+
|
|
145
165
|
document.head.append(script)
|
|
146
166
|
})
|
|
167
|
+
|
|
168
|
+
// Store the loading promise for this script
|
|
169
|
+
scriptsLoading.set(scriptId, loadingPromise)
|
|
170
|
+
|
|
171
|
+
return loadingPromise
|
|
147
172
|
}
|
|
148
173
|
|
|
149
174
|
export function appendStyle(src: string): Promise<void> {
|
|
@@ -112,7 +112,7 @@ export interface SearchItemParams<T> {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
export interface SearchResult<T> {
|
|
115
|
-
results: ComputedRef<
|
|
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)
|