@bagelink/vue 1.14.13 → 1.15.0
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/dist/components/AddressSearch.vue.d.ts +6 -7
- package/dist/components/Alert.vue.d.ts.map +1 -1
- package/dist/components/Avatar.vue.d.ts.map +1 -1
- package/dist/components/Badge.vue.d.ts.map +1 -1
- package/dist/components/Btn.vue.d.ts +1 -1
- package/dist/components/Btn.vue.d.ts.map +1 -1
- package/dist/components/Card.vue.d.ts.map +1 -1
- package/dist/components/Carousel.vue.d.ts +0 -11
- package/dist/components/Dropdown.vue.d.ts +0 -2
- package/dist/components/Dropdown.vue.d.ts.map +1 -1
- package/dist/components/Filter.vue.d.ts +30 -0
- package/dist/components/Filter.vue.d.ts.map +1 -0
- package/dist/components/FilterQuery.vue.d.ts +8 -3
- package/dist/components/Image.vue.d.ts.map +1 -1
- package/dist/components/ImportData.vue.d.ts.map +1 -1
- package/dist/components/ListItem.vue.d.ts.map +1 -1
- package/dist/components/MapEmbed/Index.vue.d.ts.map +1 -1
- package/dist/components/Modal.vue.d.ts +0 -1
- package/dist/components/Pagination.vue.d.ts.map +1 -1
- package/dist/components/Pill.vue.d.ts.map +1 -1
- package/dist/components/QueryFilter.vue.d.ts +30 -0
- package/dist/components/QueryFilter.vue.d.ts.map +1 -0
- package/dist/components/Swiper.vue.d.ts +6 -12
- package/dist/components/Swiper.vue.d.ts.map +1 -1
- package/dist/components/Toast.vue.d.ts.map +1 -1
- package/dist/components/analytics/PieChart.vue.d.ts +2 -2
- package/dist/components/calendar/CalendarPopover.vue.d.ts +8 -4
- package/dist/components/calendar/CalendarPopover.vue.d.ts.map +1 -1
- package/dist/components/calendar/CalendarTypes.d.ts +0 -10
- package/dist/components/calendar/Index.vue.d.ts +4 -20
- package/dist/components/calendar/views/WeekView.vue.d.ts +1 -9
- package/dist/components/dataTable/DataTable.vue.d.ts.map +1 -1
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/inputs/ArrayInput.vue.d.ts +2 -4
- package/dist/components/form/inputs/CheckInput.vue.d.ts +1 -2
- package/dist/components/form/inputs/Checkbox.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts +0 -54
- package/dist/components/form/inputs/ColorInput.vue.d.ts +1 -3
- package/dist/components/form/inputs/DateInput.vue.d.ts +1 -2
- package/dist/components/form/inputs/DatePicker.vue.d.ts +0 -1
- package/dist/components/form/inputs/EmailInput.vue.d.ts +2 -5
- package/dist/components/form/inputs/JSONInput.vue.d.ts +1 -2
- package/dist/components/form/inputs/MarkdownEditor.vue.d.ts +2 -7
- package/dist/components/form/inputs/NumberInput.vue.d.ts +1 -2
- package/dist/components/form/inputs/OTP.vue.d.ts +1 -2
- package/dist/components/form/inputs/PasswordInput.vue.d.ts +10 -16
- package/dist/components/form/inputs/RadioGroup.vue.d.ts +1 -3
- package/dist/components/form/inputs/RangeInput.vue.d.ts +1 -6
- package/dist/components/form/inputs/RichText/index.vue.d.ts +1 -2
- package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/utils/media.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectBtn.vue.d.ts +2 -2
- package/dist/components/form/inputs/SelectInput.vue.d.ts +13 -20
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SignaturePad.vue.d.ts +1 -6
- package/dist/components/form/inputs/TableField.vue.d.ts +1 -2
- package/dist/components/form/inputs/TelInput.vue.d.ts +1 -2
- package/dist/components/form/inputs/TextInput.vue.d.ts +2 -3
- package/dist/components/form/inputs/ToggleInput.vue.d.ts +1 -2
- package/dist/components/form/inputs/Upload/UploadInput.vue.d.ts +6 -27
- package/dist/components/form/inputs/Upload/upload.d.ts +1 -1
- package/dist/components/form/inputs/index.d.ts +0 -1
- package/dist/components/index.d.ts +1 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/layout/AppContent.vue.d.ts +1 -1
- package/dist/components/layout/AppContent.vue.d.ts.map +1 -1
- package/dist/components/layout/AppLayout.vue.d.ts +0 -2
- package/dist/components/layout/AppLayout.vue.d.ts.map +1 -1
- package/dist/components/layout/AppSidebar.vue.d.ts +1 -5
- package/dist/components/layout/AppSidebar.vue.d.ts.map +1 -1
- package/dist/components/layout/Panel.vue.d.ts.map +1 -1
- package/dist/components/layout/Resizable.vue.d.ts.map +1 -1
- package/dist/components/layout/Skeleton.vue.d.ts.map +1 -1
- package/dist/components/layout/TabsNav.vue.d.ts +1 -12
- package/dist/components/layout/TabsNav.vue.d.ts.map +1 -1
- package/dist/components/layout/appLayoutContext.d.ts +24 -0
- package/dist/components/layout/appLayoutContext.d.ts.map +1 -0
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/components/lightbox/Lightbox.vue.d.ts.map +1 -1
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/useDevice.d.ts.map +1 -1
- package/dist/composables/useEscapeKey.d.ts +12 -0
- package/dist/composables/useEscapeKey.d.ts.map +1 -0
- package/dist/composables/useSchemaField.d.ts.map +1 -1
- package/dist/composables/useTheme.d.ts.map +1 -1
- package/dist/dialog/Dialog.vue.d.ts.map +1 -1
- package/dist/dialog/DialogConfirm.vue.d.ts.map +1 -1
- package/dist/form-flow/FormFlow.vue.d.ts.map +1 -1
- package/dist/form-flow/MultiStepForm.vue.d.ts +1 -6
- package/dist/form-flow/form-flow.d.ts +1 -24
- package/dist/form-flow/form-flow.d.ts.map +1 -1
- package/dist/i18n/index.d.ts +0 -838
- package/dist/index.cjs +245 -222
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +42201 -51162
- package/dist/plugins/bagel.d.ts.map +1 -1
- package/dist/style.css +1 -2
- package/dist/types/BagelForm.d.ts +1 -10
- package/dist/types/BagelForm.d.ts.map +1 -1
- package/dist/types/BtnOptions.d.ts.map +1 -1
- package/dist/types/NavLink.d.ts +1 -2
- package/dist/types/TableSchema.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/BagelFormUtils.d.ts +0 -1
- package/dist/utils/calendar/dateUtils.d.ts +2 -2
- package/dist/utils/calendar/dateUtils.d.ts.map +1 -1
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/date.d.ts +116 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/fetch.d.ts +29 -0
- package/dist/utils/fetch.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/string.d.ts +7 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/useSearch.d.ts +1 -1
- package/package.json +3 -10
- package/src/components/AccordionItem.vue +5 -5
- package/src/components/Alert.vue +37 -16
- package/src/components/Avatar.vue +2 -1
- package/src/components/Badge.vue +145 -22
- package/src/components/BglVideo.vue +4 -4
- package/src/components/Btn.vue +81 -69
- package/src/components/Card.vue +7 -6
- package/src/components/Dropdown.vue +7 -14
- package/src/components/FieldSetVue.vue +2 -2
- package/src/components/FilterQuery.vue +3 -3
- package/src/components/Image.vue +5 -3
- package/src/components/JSONSchema.vue +4 -4
- package/src/components/JsonBuilder.vue +3 -3
- package/src/components/ListItem.vue +2 -4
- package/src/components/MapEmbed/Index.vue +18 -17
- package/src/components/NavBar.vue +2 -2
- package/src/components/Spreadsheet/Index.vue +4 -4
- package/src/components/Spreadsheet/SpreadsheetTable.vue +10 -10
- package/src/components/Swiper.vue +3 -1
- package/src/components/Toast.vue +57 -36
- package/src/components/calendar/CalendarPopover.vue +1 -1
- package/src/components/calendar/Index.vue +5 -5
- package/src/components/calendar/views/AgendaView.vue +2 -2
- package/src/components/calendar/views/DayView.vue +1 -1
- package/src/components/calendar/views/MonthView.vue +8 -8
- package/src/components/dataTable/DataTable.vue +68 -10
- package/src/components/form/index.ts +0 -4
- package/src/components/form/inputs/ArrayInput.vue +1 -1
- package/src/components/form/inputs/CheckInput.vue +6 -6
- package/src/components/form/inputs/Checkbox.vue +5 -4
- package/src/components/form/inputs/CodeEditor/Index.vue +1 -1
- package/src/components/form/inputs/ColorInput.vue +5 -5
- package/src/components/form/inputs/DatePicker.vue +3 -3
- package/src/components/form/inputs/EmailInput.vue +15 -15
- package/src/components/form/inputs/NumberInput.vue +11 -11
- package/src/components/form/inputs/OTP.vue +4 -4
- package/src/components/form/inputs/PasswordInput.vue +3 -3
- package/src/components/form/inputs/RadioGroup.vue +1 -1
- package/src/components/form/inputs/RichText/editor.css +4 -4
- package/src/components/form/inputs/RichText/index.vue +39 -39
- package/src/components/form/inputs/RichText/utils/media.ts +1 -92
- package/src/components/form/inputs/RichText/utils/table.ts +4 -4
- package/src/components/form/inputs/SelectBtn.vue +1 -1
- package/src/components/form/inputs/SelectInput.vue +16 -16
- package/src/components/form/inputs/SignaturePad.vue +6 -6
- package/src/components/form/inputs/TableField.vue +7 -7
- package/src/components/form/inputs/TelInput.vue +12 -12
- package/src/components/form/inputs/TextInput.vue +11 -11
- package/src/components/form/inputs/ToggleInput.vue +11 -11
- package/src/components/form/inputs/Upload/upload.css +16 -16
- package/src/components/index.ts +2 -9
- package/src/components/layout/AppContent.vue +5 -19
- package/src/components/layout/AppLayout.vue +47 -18
- package/src/components/layout/AppSidebar.vue +19 -36
- package/src/components/layout/BottomMenu.vue +1 -1
- package/src/components/layout/Resizable.vue +5 -2
- package/src/components/layout/Skeleton.vue +5 -4
- package/src/components/layout/TabsNav.vue +23 -23
- package/src/components/layout/appLayoutContext.ts +44 -0
- package/src/components/layout/index.ts +2 -0
- package/src/components/lightbox/Lightbox.vue +3 -9
- package/src/composables/index.ts +1 -0
- package/src/composables/useDevice.ts +2 -1
- package/src/composables/useEscapeKey.ts +56 -0
- package/src/composables/useSchemaField.ts +2 -17
- package/src/composables/useTheme.ts +23 -19
- package/src/form-flow/FormFlow.vue +2 -0
- package/src/form-flow/form-flow.ts +7 -0
- package/src/index.ts +0 -3
- package/src/plugins/bagel.ts +0 -15
- package/src/styles/app-layout.css +231 -0
- package/src/styles/appearance.css +179 -21
- package/src/styles/bagel.css +103 -97
- package/src/styles/buttons.css +8 -8
- package/src/styles/colors.css +0 -103
- package/src/styles/dark.css +25 -26
- package/src/styles/input-variants.css +11 -11
- package/src/styles/inputs.css +44 -61
- package/src/styles/layout.css +445 -1258
- package/src/styles/loginCard.css +1 -1
- package/src/styles/mobilLayout.css +153 -28
- package/src/styles/text.css +500 -1508
- package/src/styles/theme.css +199 -435
- package/src/styles/transitions.css +4 -4
- package/src/types/BagelForm.ts +46 -151
- package/src/types/BtnOptions.ts +5 -3
- package/src/types/TableSchema.ts +1 -0
- package/src/types/index.ts +0 -5
- package/src/utils/calendar/dateUtils.ts +2 -3
- package/src/utils/constants.ts +7 -0
- package/src/utils/date.ts +482 -0
- package/src/utils/fetch.ts +128 -0
- package/src/utils/index.ts +54 -3
- package/src/utils/sizeParsing.ts +5 -5
- package/src/utils/string.ts +56 -0
- package/vite.config.ts +5 -1
- package/bin/generateFormSchema.ts +0 -1035
- package/bin/utils.ts +0 -223
- package/src/components/Carousel.vue +0 -724
- package/src/components/ImportData.vue +0 -1749
- package/src/components/Modal.vue +0 -184
- package/src/components/ModalConfirm.vue +0 -42
- package/src/components/ModalForm.vue +0 -102
- package/src/components/Pill.vue +0 -149
- package/src/components/Slider.vue +0 -1446
- package/src/components/Title.vue +0 -23
- package/src/components/ToolBar.vue +0 -9
- package/src/components/form/BagelForm.vue +0 -219
- package/src/components/form/BglFieldSet.vue +0 -14
- package/src/components/form/BglMultiStepForm.vue +0 -469
- package/src/components/form/FieldArray.vue +0 -422
- package/src/components/form/useBagelFormState.ts +0 -76
- package/src/composables/useFormField.ts +0 -38
- package/src/dialog/DialogOLD.vue +0 -358
- package/src/plugins/modalTypes.ts +0 -61
- package/src/plugins/useModal.ts +0 -225
- package/src/styles/modal.css +0 -120
- package/src/styles/pillColors.css +0 -0
- package/src/utils/BagelFormUtils.ts +0 -684
|
@@ -1,684 +0,0 @@
|
|
|
1
|
-
// Import types from type-fest first
|
|
2
|
-
import type { DefaultPathsOptions, PathsOptions } from 'type-fest/source/paths'
|
|
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
|
-
ShallowBglFormSchemaT,
|
|
16
|
-
UploadInputProps
|
|
17
|
-
} from '../types/BagelForm'
|
|
18
|
-
|
|
19
|
-
// Local type definitions for internal use only
|
|
20
|
-
interface IconType { name: string }
|
|
21
|
-
interface AutoFillField { name: string }
|
|
22
|
-
interface InputTypeHTMLAttribute { type: string }
|
|
23
|
-
type MaybeRefOrGetter<T> = T | (() => T) | { value: T }
|
|
24
|
-
|
|
25
|
-
export interface InputOptions<
|
|
26
|
-
T,
|
|
27
|
-
P extends Path<T>
|
|
28
|
-
> extends Partial<BaseBagelField<T, P>> {
|
|
29
|
-
defaultValue?: string | number
|
|
30
|
-
autocomplete?: AutoFillField
|
|
31
|
-
helpText?: string
|
|
32
|
-
title?: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface DateOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
36
|
-
enableTime?: boolean
|
|
37
|
-
mode?: 'day' | 'month' | 'year'
|
|
38
|
-
locale?: string
|
|
39
|
-
timezone?: string
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface TextInputOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
43
|
-
type?: InputTypeHTMLAttribute['type']
|
|
44
|
-
pattern?: string
|
|
45
|
-
multiline?: boolean
|
|
46
|
-
autoheight?: boolean
|
|
47
|
-
code?: boolean
|
|
48
|
-
rows?: number | string
|
|
49
|
-
icon?: IconType
|
|
50
|
-
iconStart?: IconType
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface SlctInputOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
54
|
-
searchable?: boolean
|
|
55
|
-
multiselect?: boolean
|
|
56
|
-
clearable?: boolean
|
|
57
|
-
placeholder?: string
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface NumFieldOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
61
|
-
max?: number
|
|
62
|
-
min?: number
|
|
63
|
-
step?: number
|
|
64
|
-
layout?: 'default' | 'vertical' | 'horizontal'
|
|
65
|
-
padZero?: number
|
|
66
|
-
center?: boolean
|
|
67
|
-
useGrouping?: boolean
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface RichTextOptions<T, P extends Path<T>> extends InputOptions<T, P> {
|
|
71
|
-
height?: number | string
|
|
72
|
-
basic?: boolean
|
|
73
|
-
simple?: boolean
|
|
74
|
-
debug?: boolean
|
|
75
|
-
// Manual hide options
|
|
76
|
-
hideToolbar?: boolean
|
|
77
|
-
hideInlineToolbar?: boolean
|
|
78
|
-
hideImages?: boolean
|
|
79
|
-
hideVideos?: boolean
|
|
80
|
-
hideEmbed?: boolean
|
|
81
|
-
hideTables?: boolean
|
|
82
|
-
hideAlignment?: boolean
|
|
83
|
-
hideDirections?: boolean
|
|
84
|
-
hideH5H6?: boolean
|
|
85
|
-
// Simple array-based hide option
|
|
86
|
-
hide?: string[]
|
|
87
|
-
// Control autofocus behavior
|
|
88
|
-
autofocus?: boolean
|
|
89
|
-
// Text color
|
|
90
|
-
textColor?: string
|
|
91
|
-
// Font size
|
|
92
|
-
fontSize?: number | string
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface TelInputOptions<T, P extends Path<T>> extends InputOptions<T, P> {
|
|
96
|
-
pattern?: string
|
|
97
|
-
autocomplete?: AutoFillField
|
|
98
|
-
onlyCountries?: string[]
|
|
99
|
-
defaultCountry?: string
|
|
100
|
-
excludeCountries?: string[]
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function getBaseField<T, P extends Path<T, PO>, PO extends PathsOptions = DefaultPathsOptions>(
|
|
104
|
-
id?: P,
|
|
105
|
-
labelOrRest: string | Partial<BaseBagelField<T, P>> = {},
|
|
106
|
-
rest: Partial<BaseBagelField<T, P>> = {}
|
|
107
|
-
): BaseBagelField<T, P, PO> {
|
|
108
|
-
if (typeof labelOrRest === 'object') { return { id, ...labelOrRest } }
|
|
109
|
-
return { id, label: labelOrRest, ...rest }
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function richText<
|
|
113
|
-
T,
|
|
114
|
-
P extends Path<T, PO>,
|
|
115
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
116
|
-
>(
|
|
117
|
-
id?: P,
|
|
118
|
-
label?: string,
|
|
119
|
-
options?: RichTextOptions<T, P>,
|
|
120
|
-
): BaseBagelField<T, P, PO> {
|
|
121
|
-
return {
|
|
122
|
-
$el: 'richtext',
|
|
123
|
-
class: options?.class,
|
|
124
|
-
required: options?.required,
|
|
125
|
-
id,
|
|
126
|
-
label,
|
|
127
|
-
helptext: options?.helpText,
|
|
128
|
-
disabled: options?.disabled,
|
|
129
|
-
defaultValue: options?.defaultValue,
|
|
130
|
-
vIf: options?.vIf,
|
|
131
|
-
transform: options?.transform,
|
|
132
|
-
placeholder: options?.placeholder,
|
|
133
|
-
attrs: {
|
|
134
|
-
height: options?.height,
|
|
135
|
-
basic: options?.basic,
|
|
136
|
-
simple: options?.simple,
|
|
137
|
-
debug: options?.debug,
|
|
138
|
-
hideToolbar: options?.hideToolbar,
|
|
139
|
-
hideInlineToolbar: options?.hideInlineToolbar,
|
|
140
|
-
hideImages: options?.hideImages,
|
|
141
|
-
hideVideos: options?.hideVideos,
|
|
142
|
-
hideEmbed: options?.hideEmbed,
|
|
143
|
-
hideTables: options?.hideTables,
|
|
144
|
-
hideAlignment: options?.hideAlignment,
|
|
145
|
-
hideDirections: options?.hideDirections,
|
|
146
|
-
hideH5H6: options?.hideH5H6,
|
|
147
|
-
hide: options?.hide,
|
|
148
|
-
autofocus: options?.autofocus,
|
|
149
|
-
textColor: options?.textColor,
|
|
150
|
-
fontSize: options?.fontSize,
|
|
151
|
-
autocomplete: options?.autocomplete,
|
|
152
|
-
},
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export function txtField<
|
|
157
|
-
T,
|
|
158
|
-
P extends Path<T, PO>,
|
|
159
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
160
|
-
>(
|
|
161
|
-
id?: P,
|
|
162
|
-
label?: string,
|
|
163
|
-
options?: TextInputOptions<T, P>,
|
|
164
|
-
): InputBagelField<T, P, PO> {
|
|
165
|
-
return {
|
|
166
|
-
$el: 'text',
|
|
167
|
-
id,
|
|
168
|
-
label,
|
|
169
|
-
class: options?.class,
|
|
170
|
-
required: options?.required,
|
|
171
|
-
placeholder: options?.placeholder,
|
|
172
|
-
helptext: options?.helptext,
|
|
173
|
-
disabled: options?.disabled,
|
|
174
|
-
defaultValue: options?.defaultValue,
|
|
175
|
-
vIf: options?.vIf,
|
|
176
|
-
transform: options?.transform,
|
|
177
|
-
attrs: {
|
|
178
|
-
title: options?.title,
|
|
179
|
-
autocomplete: options?.autocomplete,
|
|
180
|
-
pattern: options?.pattern,
|
|
181
|
-
multiline: options?.multiline,
|
|
182
|
-
autoheight: options?.autoheight,
|
|
183
|
-
code: options?.code,
|
|
184
|
-
rows: options?.rows,
|
|
185
|
-
icon: options?.icon,
|
|
186
|
-
iconStart: options?.iconStart,
|
|
187
|
-
type: options?.type,
|
|
188
|
-
},
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// import type { Option } from '@bagelink/vue'
|
|
193
|
-
|
|
194
|
-
// type OptionsSource = Option[] | ((query: string) => Promise<Option[]>)
|
|
195
|
-
|
|
196
|
-
export function selectField<
|
|
197
|
-
T,
|
|
198
|
-
P extends Path<T, PO>,
|
|
199
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
200
|
-
>(
|
|
201
|
-
id?: P,
|
|
202
|
-
label?: string,
|
|
203
|
-
options?: any,
|
|
204
|
-
fieldOptions?: SlctInputOptions<T, P>,
|
|
205
|
-
): SelectBagelField<T, P, PO> {
|
|
206
|
-
return {
|
|
207
|
-
$el: 'select',
|
|
208
|
-
id,
|
|
209
|
-
label,
|
|
210
|
-
class: fieldOptions?.class,
|
|
211
|
-
required: fieldOptions?.required,
|
|
212
|
-
helptext: fieldOptions?.helptext,
|
|
213
|
-
disabled: fieldOptions?.disabled,
|
|
214
|
-
defaultValue: fieldOptions?.defaultValue,
|
|
215
|
-
vIf: fieldOptions?.vIf,
|
|
216
|
-
transform: fieldOptions?.transform,
|
|
217
|
-
placeholder: fieldOptions?.placeholder,
|
|
218
|
-
options,
|
|
219
|
-
attrs: {
|
|
220
|
-
...fieldOptions?.attrs,
|
|
221
|
-
title: fieldOptions?.title,
|
|
222
|
-
searchable: fieldOptions?.searchable,
|
|
223
|
-
multiselect: fieldOptions?.multiselect,
|
|
224
|
-
clearable: fieldOptions?.clearable,
|
|
225
|
-
},
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export const slctField = selectField
|
|
230
|
-
|
|
231
|
-
interface CheckInputOptions<T, K extends Path<T>> extends Omit<InputOptions<T, K>, 'defaultValue'> {
|
|
232
|
-
value?: string | number | boolean
|
|
233
|
-
defaultValue?: string | number | boolean
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export function checkField<
|
|
237
|
-
T,
|
|
238
|
-
P extends Path<T, PO>,
|
|
239
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
240
|
-
>(
|
|
241
|
-
id?: P,
|
|
242
|
-
label?: string,
|
|
243
|
-
options?: CheckInputOptions<T, P>,
|
|
244
|
-
): BaseBagelField<T, P, PO> {
|
|
245
|
-
return {
|
|
246
|
-
$el: 'check',
|
|
247
|
-
id,
|
|
248
|
-
label,
|
|
249
|
-
class: options?.class,
|
|
250
|
-
required: options?.required,
|
|
251
|
-
helptext: options?.helptext,
|
|
252
|
-
disabled: options?.disabled,
|
|
253
|
-
defaultValue: options?.defaultValue,
|
|
254
|
-
vIf: options?.vIf,
|
|
255
|
-
transform: options?.transform,
|
|
256
|
-
attrs: {
|
|
257
|
-
...options?.attrs,
|
|
258
|
-
value: options?.value,
|
|
259
|
-
},
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
interface EmailInputOptions<
|
|
264
|
-
T,
|
|
265
|
-
P extends Path<T>
|
|
266
|
-
> extends InputOptions<T, P> {
|
|
267
|
-
autocorrect?: boolean
|
|
268
|
-
serverValidate?: boolean
|
|
269
|
-
preventFakeEmails?: boolean
|
|
270
|
-
pattern?: string
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export function emailField<
|
|
274
|
-
T,
|
|
275
|
-
P extends Path<T, PO>,
|
|
276
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
277
|
-
>(id?: P, label?: string, options?: EmailInputOptions<T, P>): BaseBagelField<T, P, PO> {
|
|
278
|
-
return {
|
|
279
|
-
$el: 'email',
|
|
280
|
-
id,
|
|
281
|
-
label,
|
|
282
|
-
class: options?.class,
|
|
283
|
-
required: options?.required,
|
|
284
|
-
vIf: options?.vIf,
|
|
285
|
-
transform: options?.transform,
|
|
286
|
-
attrs: {
|
|
287
|
-
title: options?.title,
|
|
288
|
-
autocorrect: options?.autocorrect,
|
|
289
|
-
serverValidate: options?.serverValidate,
|
|
290
|
-
preventFakeEmails: options?.preventFakeEmails,
|
|
291
|
-
pattern: options?.pattern,
|
|
292
|
-
},
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export function dateField<
|
|
297
|
-
T,
|
|
298
|
-
P extends Path<T, PO>,
|
|
299
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
300
|
-
>(
|
|
301
|
-
id?: P,
|
|
302
|
-
label?: string,
|
|
303
|
-
options?: DateOptions<T, P>,
|
|
304
|
-
): BaseBagelField<T, P, PO> {
|
|
305
|
-
return {
|
|
306
|
-
$el: 'date',
|
|
307
|
-
class: options?.class,
|
|
308
|
-
required: options?.required,
|
|
309
|
-
id,
|
|
310
|
-
disabled: options?.disabled,
|
|
311
|
-
label,
|
|
312
|
-
...(options?.defaultValue !== undefined && { defaultValue: options.defaultValue }),
|
|
313
|
-
vIf: options?.vIf,
|
|
314
|
-
transform: options?.transform,
|
|
315
|
-
attrs: {
|
|
316
|
-
title: options?.title,
|
|
317
|
-
disabled: options?.disabled,
|
|
318
|
-
autocomplete: options?.autocomplete,
|
|
319
|
-
enableTime: options?.enableTime,
|
|
320
|
-
mode: options?.mode,
|
|
321
|
-
locale: options?.locale,
|
|
322
|
-
timezone: options?.timezone,
|
|
323
|
-
},
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
export function numField<
|
|
328
|
-
T,
|
|
329
|
-
P extends Path<T, PO>,
|
|
330
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
331
|
-
>(
|
|
332
|
-
id?: P,
|
|
333
|
-
label?: string,
|
|
334
|
-
options?: NumFieldOptions<T, P>,
|
|
335
|
-
): BaseBagelField<T, P, PO> {
|
|
336
|
-
return {
|
|
337
|
-
$el: 'number',
|
|
338
|
-
class: options?.class,
|
|
339
|
-
required: options?.required,
|
|
340
|
-
defaultValue: options?.defaultValue,
|
|
341
|
-
id,
|
|
342
|
-
label,
|
|
343
|
-
disabled: options?.disabled,
|
|
344
|
-
placeholder: options?.placeholder,
|
|
345
|
-
helptext: options?.helptext,
|
|
346
|
-
vIf: options?.vIf,
|
|
347
|
-
transform: options?.transform,
|
|
348
|
-
attrs: {
|
|
349
|
-
title: options?.title,
|
|
350
|
-
autocomplete: options?.autocomplete,
|
|
351
|
-
step: options?.step,
|
|
352
|
-
min: options?.min,
|
|
353
|
-
max: options?.max,
|
|
354
|
-
layout: options?.layout,
|
|
355
|
-
padZero: options?.padZero,
|
|
356
|
-
center: options?.center,
|
|
357
|
-
useGrouping: options?.useGrouping,
|
|
358
|
-
},
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
export function frmRow<
|
|
363
|
-
T,
|
|
364
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
365
|
-
>(
|
|
366
|
-
...children: Array<BaseBagelField<T, any, PO>>
|
|
367
|
-
): { $el: string, class: string, children: Array<BaseBagelField<T, any, PO>> } {
|
|
368
|
-
return {
|
|
369
|
-
$el: 'div',
|
|
370
|
-
class: 'flex gap-1 m_block align-items-end',
|
|
371
|
-
children,
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
export interface UploadOptions<T, K extends Path<T>> extends Omit<UploadInputProps, 'id'>, InputOptions<T, K> {}
|
|
376
|
-
|
|
377
|
-
export function uploadField<
|
|
378
|
-
T,
|
|
379
|
-
P extends Path<T, PO>,
|
|
380
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
381
|
-
>(
|
|
382
|
-
id?: P,
|
|
383
|
-
label?: string,
|
|
384
|
-
options?: UploadOptions<T, P>,
|
|
385
|
-
): BaseBagelField<T, P, PO> {
|
|
386
|
-
return {
|
|
387
|
-
$el: 'upload',
|
|
388
|
-
id,
|
|
389
|
-
label,
|
|
390
|
-
placeholder: options?.placeholder ?? options?.dropPlaceholder,
|
|
391
|
-
class: options?.class,
|
|
392
|
-
required: options?.required,
|
|
393
|
-
helptext: options?.helptext,
|
|
394
|
-
disabled: options?.disabled,
|
|
395
|
-
defaultValue: options?.defaultValue,
|
|
396
|
-
vIf: options?.vIf,
|
|
397
|
-
transform: options?.transform,
|
|
398
|
-
attrs: {
|
|
399
|
-
...options,
|
|
400
|
-
},
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
interface RangeOptions<T, K extends Path<T>> extends InputOptions<T, K> {
|
|
405
|
-
min?: number
|
|
406
|
-
max?: number
|
|
407
|
-
step?: number
|
|
408
|
-
rtl?: boolean
|
|
409
|
-
multiRange?: boolean
|
|
410
|
-
formatValue?: (value: number) => string
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
export function rangeField<
|
|
414
|
-
T,
|
|
415
|
-
P extends Path<T, PO>,
|
|
416
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
417
|
-
>(
|
|
418
|
-
id?: P,
|
|
419
|
-
label?: string,
|
|
420
|
-
options?: RangeOptions <T, P>
|
|
421
|
-
): BaseBagelField<T, P, PO> {
|
|
422
|
-
return {
|
|
423
|
-
$el: 'range',
|
|
424
|
-
id,
|
|
425
|
-
label,
|
|
426
|
-
vIf: options?.vIf,
|
|
427
|
-
transform: options?.transform,
|
|
428
|
-
attrs: {
|
|
429
|
-
autocomplete: options?.autocomplete,
|
|
430
|
-
min: options?.min,
|
|
431
|
-
max: options?.max,
|
|
432
|
-
step: options?.step,
|
|
433
|
-
rtl: options?.rtl,
|
|
434
|
-
multiRange: options?.multiRange,
|
|
435
|
-
formatValue: options?.formatValue,
|
|
436
|
-
},
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
export function bglForm<T>(idOrField?: string | FieldByP<T, Path<T>>, ...schema: FieldByP<T, Path<T>>[]) {
|
|
441
|
-
if (typeof idOrField === 'string') {
|
|
442
|
-
return {
|
|
443
|
-
$el: 'bagelform',
|
|
444
|
-
id: idOrField,
|
|
445
|
-
attrs: {
|
|
446
|
-
schema: [idOrField, ...schema],
|
|
447
|
-
},
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
return {
|
|
451
|
-
$el: 'bagelform',
|
|
452
|
-
attrs: {
|
|
453
|
-
schema: [idOrField, ...schema]
|
|
454
|
-
},
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
export function telField<
|
|
459
|
-
T,
|
|
460
|
-
P extends Path<T, PO>,
|
|
461
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
462
|
-
>(
|
|
463
|
-
id?: P,
|
|
464
|
-
label?: string,
|
|
465
|
-
options?: TelInputOptions<T, P>
|
|
466
|
-
): BaseBagelField<T, P, PO> {
|
|
467
|
-
return {
|
|
468
|
-
$el: 'tel',
|
|
469
|
-
id,
|
|
470
|
-
label,
|
|
471
|
-
class: options?.class,
|
|
472
|
-
required: options?.required,
|
|
473
|
-
placeholder: options?.placeholder,
|
|
474
|
-
helptext: options?.helptext,
|
|
475
|
-
disabled: options?.disabled,
|
|
476
|
-
defaultValue: options?.defaultValue,
|
|
477
|
-
vIf: options?.vIf,
|
|
478
|
-
transform: options?.transform,
|
|
479
|
-
attrs: {
|
|
480
|
-
...options?.attrs,
|
|
481
|
-
title: options?.title,
|
|
482
|
-
pattern: options?.pattern,
|
|
483
|
-
autocomplete: options?.autocomplete,
|
|
484
|
-
},
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
export function colorField<
|
|
489
|
-
T,
|
|
490
|
-
P extends Path<T, PO>,
|
|
491
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
492
|
-
>(
|
|
493
|
-
id?: P,
|
|
494
|
-
label?: string,
|
|
495
|
-
options?: { [key: string]: any }
|
|
496
|
-
): BaseBagelField<T, P, PO> {
|
|
497
|
-
return {
|
|
498
|
-
$el: 'color',
|
|
499
|
-
id,
|
|
500
|
-
label,
|
|
501
|
-
vIf: options?.vIf,
|
|
502
|
-
attrs: options,
|
|
503
|
-
class: options?.class,
|
|
504
|
-
transform: options?.transform,
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
export function findBglFieldById<T>(id: string, _schema: ShallowBglFormSchemaT<T>): FieldByP<T, Path<T>> | undefined {
|
|
509
|
-
for (const field of _schema) {
|
|
510
|
-
if (field.id === id) { return field as FieldByP<T, Path<T>> | undefined }
|
|
511
|
-
if (field.children && Number(field.children.length) > 0) {
|
|
512
|
-
const fieldChildren = field.children.filter(
|
|
513
|
-
c => typeof c === 'object' && '$el' in c
|
|
514
|
-
)
|
|
515
|
-
const child = findBglFieldById(id, fieldChildren as ShallowBglFormSchemaT<T>)
|
|
516
|
-
if (child) { return child as FieldByP<T, Path<T>> | undefined }
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
return undefined
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
export interface ArrayAttrs<T, P extends Path<T>> extends Attributes<T, P> {
|
|
523
|
-
delete?: boolean
|
|
524
|
-
add?: boolean
|
|
525
|
-
schema?: MaybeRefOrGetter<BglFormSchemaT<ArrayFieldVal<T, P>>>
|
|
526
|
-
type?: ArrayType
|
|
527
|
-
simple?: boolean
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
export interface ArrayFieldOptions<T, K extends Path<T>> extends InputOptions<T, K>, ArrayAttrs<T, K> {}
|
|
531
|
-
|
|
532
|
-
export type ArrayType = 'number' | 'text'
|
|
533
|
-
|
|
534
|
-
export function arrField<
|
|
535
|
-
T,
|
|
536
|
-
P extends Path<T, PO>,
|
|
537
|
-
PO extends PathsOptions = DefaultPathsOptions,
|
|
538
|
-
>(
|
|
539
|
-
id: P,
|
|
540
|
-
label: string,
|
|
541
|
-
schemaOrType: BglFormSchemaT<ArrayFieldVal<T, P>> | ArrayType,
|
|
542
|
-
options?: ArrayFieldOptions<T, P>
|
|
543
|
-
): ArrayBagelField<T, P, PO> {
|
|
544
|
-
const arraySpecificAttrs = (
|
|
545
|
-
typeof schemaOrType === 'string'
|
|
546
|
-
? { type: schemaOrType }
|
|
547
|
-
: { schema: schemaOrType }
|
|
548
|
-
)
|
|
549
|
-
|
|
550
|
-
const attrs: ArrayAttrs<T, P> = {
|
|
551
|
-
delete: true,
|
|
552
|
-
add: true,
|
|
553
|
-
...options,
|
|
554
|
-
...arraySpecificAttrs,
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
return {
|
|
558
|
-
label,
|
|
559
|
-
id,
|
|
560
|
-
class: options?.class,
|
|
561
|
-
$el: 'array',
|
|
562
|
-
vIf: options?.vIf,
|
|
563
|
-
transform: options?.transform,
|
|
564
|
-
attrs,
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
// export function updateBagelSchemaWithErrorResponse<T>(
|
|
568
|
-
// schema: BglFormSchemaT<T>,
|
|
569
|
-
// invalidFieldId: Record<string, string[]>,
|
|
570
|
-
// ) {
|
|
571
|
-
// return schema.map((f) => {
|
|
572
|
-
// if (f.id === invalidFieldId) {
|
|
573
|
-
// f.class = 'bagel-input-error'
|
|
574
|
-
// }
|
|
575
|
-
// if (f.id === undefined && f.children) {
|
|
576
|
-
// f.children = f.children.map((c) => {
|
|
577
|
-
// if (c.id === invalidFieldId) {
|
|
578
|
-
// c.class = 'bagel-input-error'
|
|
579
|
-
// }
|
|
580
|
-
// return c
|
|
581
|
-
// })
|
|
582
|
-
// }
|
|
583
|
-
// return f
|
|
584
|
-
// })
|
|
585
|
-
// }
|
|
586
|
-
|
|
587
|
-
// Schema builder function that provides type context
|
|
588
|
-
export function createSchema<T, PO extends PathsOptions = DefaultPathsOptions>() {
|
|
589
|
-
return {
|
|
590
|
-
txtField: <P extends Path<T, PO>>(
|
|
591
|
-
id?: P,
|
|
592
|
-
label?: string,
|
|
593
|
-
options?: TextInputOptions<T, P>
|
|
594
|
-
) => txtField<T, P, PO>(id, label, options),
|
|
595
|
-
|
|
596
|
-
selectField: <P extends Path<T, PO>>(
|
|
597
|
-
id?: P,
|
|
598
|
-
label?: string,
|
|
599
|
-
options?: any,
|
|
600
|
-
fieldOptions?: SlctInputOptions<T, P>
|
|
601
|
-
) => selectField<T, P, PO>(id, label, options, fieldOptions),
|
|
602
|
-
|
|
603
|
-
dateField: <P extends Path<T, PO>>(
|
|
604
|
-
id?: P,
|
|
605
|
-
label?: string,
|
|
606
|
-
options?: DateOptions<T, P>
|
|
607
|
-
) => dateField<T, P, PO>(id, label, options),
|
|
608
|
-
|
|
609
|
-
telField: <P extends Path<T, PO>>(
|
|
610
|
-
id?: P,
|
|
611
|
-
label?: string,
|
|
612
|
-
options?: TelInputOptions<T, P>
|
|
613
|
-
) => telField<T, P, PO>(id, label, options),
|
|
614
|
-
|
|
615
|
-
frmRow: (
|
|
616
|
-
...children: Array<BaseBagelField<T, any, PO>>
|
|
617
|
-
) => frmRow<T, PO>(...children),
|
|
618
|
-
|
|
619
|
-
// Add other field functions as needed
|
|
620
|
-
numField: <P extends Path<T, PO>>(
|
|
621
|
-
id?: P,
|
|
622
|
-
label?: string,
|
|
623
|
-
options?: NumFieldOptions<T, P>
|
|
624
|
-
) => numField<T, P, PO>(id, label, options),
|
|
625
|
-
|
|
626
|
-
checkField: <P extends Path<T, PO>>(
|
|
627
|
-
id?: P,
|
|
628
|
-
label?: string,
|
|
629
|
-
options?: CheckInputOptions<T, P>
|
|
630
|
-
) => checkField<T, P, PO>(id, label, options),
|
|
631
|
-
|
|
632
|
-
emailField: <P extends Path<T, PO>>(
|
|
633
|
-
id?: P,
|
|
634
|
-
label?: string,
|
|
635
|
-
options?: EmailInputOptions<T, P>
|
|
636
|
-
) => emailField<T, P, PO>(id, label, options),
|
|
637
|
-
|
|
638
|
-
uploadField: <P extends Path<T, PO>>(
|
|
639
|
-
id?: P,
|
|
640
|
-
label?: string,
|
|
641
|
-
options?: UploadOptions<T, P>
|
|
642
|
-
) => uploadField<T, P, PO>(id, label, options),
|
|
643
|
-
|
|
644
|
-
rangeField: <P extends Path<T, PO>>(
|
|
645
|
-
id?: P,
|
|
646
|
-
label?: string,
|
|
647
|
-
options?: RangeOptions<T, P>
|
|
648
|
-
) => rangeField<T, P, PO>(id, label, options),
|
|
649
|
-
|
|
650
|
-
colorField: <P extends Path<T, PO>>(
|
|
651
|
-
id?: P,
|
|
652
|
-
label?: string,
|
|
653
|
-
options?: { [key: string]: any }
|
|
654
|
-
) => colorField<T, P, PO>(id, label, options),
|
|
655
|
-
|
|
656
|
-
richText: <P extends Path<T, PO>>(
|
|
657
|
-
id?: P,
|
|
658
|
-
label?: string,
|
|
659
|
-
options?: RichTextOptions<T, P>
|
|
660
|
-
) => richText<T, P, PO>(id, label, options),
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
export function useForm() {
|
|
665
|
-
return {
|
|
666
|
-
txtField,
|
|
667
|
-
selectField,
|
|
668
|
-
checkField,
|
|
669
|
-
dateField,
|
|
670
|
-
numField,
|
|
671
|
-
emailField,
|
|
672
|
-
frmRow,
|
|
673
|
-
uploadField,
|
|
674
|
-
rangeField,
|
|
675
|
-
bglForm,
|
|
676
|
-
telField,
|
|
677
|
-
colorField,
|
|
678
|
-
arrField,
|
|
679
|
-
richText,
|
|
680
|
-
findBglFieldById,
|
|
681
|
-
getBaseField,
|
|
682
|
-
createSchema
|
|
683
|
-
}
|
|
684
|
-
}
|