@bagelink/vue 0.0.1033 → 0.0.1037
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/Accordion.d.ts +12 -0
- package/dist/components/Accordion.d.ts.map +1 -0
- package/dist/components/AccordionItem.d.ts +34 -0
- package/dist/components/AccordionItem.d.ts.map +1 -0
- package/dist/components/Alert.d.ts +34 -0
- package/dist/components/Alert.d.ts.map +1 -0
- package/dist/components/Avatar.d.ts +36 -0
- package/dist/components/Avatar.d.ts.map +1 -0
- package/dist/components/Badge.d.ts +22 -0
- package/dist/components/Badge.d.ts.map +1 -0
- package/dist/components/BglComponent.vue.d.ts +24 -0
- package/dist/components/BglComponent.vue.d.ts.map +1 -0
- package/dist/components/BglVideo.d.ts +20 -0
- package/dist/components/BglVideo.d.ts.map +1 -0
- package/dist/components/Btn.d.ts +99 -0
- package/dist/components/Btn.d.ts.map +1 -0
- package/dist/components/Card.d.ts +39 -0
- package/dist/components/Card.d.ts.map +1 -0
- package/dist/components/Carousel.d.ts +74 -0
- package/dist/components/Carousel.d.ts.map +1 -0
- package/dist/components/ComboBox.vue.d.ts +3 -3
- package/dist/components/Comments.vue.d.ts +2 -2
- package/dist/components/ContactSubmissions.vue.d.ts +2 -2
- package/dist/components/DataPreview.d.ts +42 -0
- package/dist/components/DataPreview.d.ts.map +1 -0
- package/dist/components/Drop.vue.d.ts +34 -0
- package/dist/components/Drop.vue.d.ts.map +1 -0
- package/dist/components/FieldSetVue.vue.d.ts +22 -0
- package/dist/components/FieldSetVue.vue.d.ts.map +1 -0
- package/dist/components/FileUploader.vue.d.ts +60 -0
- package/dist/components/FileUploader.vue.d.ts.map +1 -0
- package/dist/components/Flag.d.ts +20 -0
- package/dist/components/Flag.d.ts.map +1 -0
- package/dist/components/FormSchema.vue.d.ts +5 -4
- package/dist/components/Image.vue.d.ts +2 -1
- package/dist/components/Image.vue.d.ts.map +1 -1
- package/dist/components/LangText.vue.d.ts +2 -2
- package/dist/components/ListItem.d.ts +34 -0
- package/dist/components/ListItem.d.ts.map +1 -0
- package/dist/components/ListView.d.ts +13 -0
- package/dist/components/ListView.d.ts.map +1 -0
- package/dist/components/MapEmbed.d.ts +3 -0
- package/dist/components/MapEmbed.d.ts.map +1 -0
- package/dist/components/MaterialIcon.d.ts +26 -0
- package/dist/components/MaterialIcon.d.ts.map +1 -0
- package/dist/components/Modal.d.ts +46 -0
- package/dist/components/Modal.d.ts.map +1 -0
- package/dist/components/ModalBglForm.vue.d.ts +21 -20
- package/dist/components/ModalConfirm.d.ts +24 -0
- package/dist/components/ModalConfirm.d.ts.map +1 -0
- package/dist/components/ModalForm.d.ts +78 -0
- package/dist/components/ModalForm.d.ts.map +1 -0
- package/dist/components/NavBar.d.ts +64 -0
- package/dist/components/NavBar.d.ts.map +1 -0
- package/dist/components/PageTitle.d.ts +24 -0
- package/dist/components/PageTitle.d.ts.map +1 -0
- package/dist/components/PersonPreview.vue.d.ts +5 -4
- package/dist/components/PersonPreviewFormkit.vue.d.ts +4 -3
- package/dist/components/Pill.vue.d.ts +1 -0
- package/dist/components/Pill.vue.d.ts.map +1 -1
- package/dist/components/RTXEditor.vue.d.ts +3 -3
- package/dist/components/RouterWrapper.d.ts +3 -0
- package/dist/components/RouterWrapper.d.ts.map +1 -0
- package/dist/components/TabbedLayout.vue.d.ts +5 -4
- package/dist/components/TableSchema.d.ts +35 -0
- package/dist/components/TableSchema.d.ts.map +1 -0
- package/dist/components/TableSchema.vue.d.ts.map +1 -1
- package/dist/components/Title.d.ts +42 -0
- package/dist/components/Title.d.ts.map +1 -0
- package/dist/components/TopBar.d.ts +12 -0
- package/dist/components/TopBar.d.ts.map +1 -0
- package/dist/components/charts/BarChart.vue.d.ts +2 -2
- package/dist/components/dashboard/Lineart.d.ts +20 -0
- package/dist/components/dashboard/Lineart.d.ts.map +1 -0
- package/dist/components/form/BglField.d.ts +25 -0
- package/dist/components/form/BglField.d.ts.map +1 -0
- package/dist/components/form/BglField.vue.d.ts +8 -6
- package/dist/components/form/BglField.vue.d.ts.map +1 -1
- package/dist/components/form/BglForm.d.ts +75 -0
- package/dist/components/form/BglForm.d.ts.map +1 -0
- package/dist/components/form/BglForm.vue.d.ts +5 -4
- package/dist/components/form/BglForm.vue.d.ts.map +1 -1
- package/dist/components/form/BglMultiStepForm.vue.d.ts +2 -2
- package/dist/components/form/FieldArray.vue.d.ts +1 -0
- package/dist/components/form/FieldArray.vue.d.ts.map +1 -1
- package/dist/components/form/ItemRef.vue.d.ts +5 -3
- package/dist/components/form/ItemRef.vue.d.ts.map +1 -1
- package/dist/components/form/MaterialIcon.vue.d.ts +4 -3
- package/dist/components/form/PlainInputField.vue.d.ts +3 -3
- package/dist/components/form/inputs/CheckInput.d.ts +56 -0
- package/dist/components/form/inputs/CheckInput.d.ts.map +1 -0
- package/dist/components/form/inputs/Checkbox.d.ts +16 -0
- package/dist/components/form/inputs/Checkbox.d.ts.map +1 -0
- package/dist/components/form/inputs/ColorPicker.d.ts +48 -0
- package/dist/components/form/inputs/ColorPicker.d.ts.map +1 -0
- package/dist/components/form/inputs/CurrencyInput.vue.d.ts +3 -3
- package/dist/components/form/inputs/DateInput.d.ts +64 -0
- package/dist/components/form/inputs/DateInput.d.ts.map +1 -0
- package/dist/components/form/inputs/DatePicker.d.ts +33 -0
- package/dist/components/form/inputs/DatePicker.d.ts.map +1 -0
- package/dist/components/form/inputs/DatetimeInput.vue.d.ts +3 -3
- package/dist/components/form/inputs/DurationInput.vue.d.ts +3 -3
- package/dist/components/form/inputs/DynamicLinkField.vue.d.ts +3 -3
- package/dist/components/form/inputs/EmailInput.vue.d.ts +3 -3
- package/dist/components/form/inputs/FileUpload.d.ts +108 -0
- package/dist/components/form/inputs/FileUpload.d.ts.map +1 -0
- package/dist/components/form/inputs/FloatInput.vue.d.ts +3 -3
- package/dist/components/form/inputs/IntInput.vue.d.ts +3 -3
- package/dist/components/form/inputs/JSONInput.d.ts +53 -0
- package/dist/components/form/inputs/JSONInput.d.ts.map +1 -0
- package/dist/components/form/inputs/LinkField.vue.d.ts +3 -3
- package/dist/components/form/inputs/NumberInput.vue.d.ts +1 -1
- package/dist/components/form/inputs/NumberInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Password.vue.d.ts +3 -3
- package/dist/components/form/inputs/PlainText.vue.d.ts +3 -3
- package/dist/components/form/inputs/RadioGroup.d.ts +42 -0
- package/dist/components/form/inputs/RadioGroup.d.ts.map +1 -0
- package/dist/components/form/inputs/RadioPillsInput.d.ts +48 -0
- package/dist/components/form/inputs/RadioPillsInput.d.ts.map +1 -0
- package/dist/components/form/inputs/RangeInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ReadOnlyInput.vue.d.ts +2 -2
- package/dist/components/form/inputs/RichText.d.ts +20 -0
- package/dist/components/form/inputs/RichText.d.ts.map +1 -0
- package/dist/components/form/inputs/RichText2/Toolbar.d.ts +22 -0
- package/dist/components/form/inputs/RichText2/Toolbar.d.ts.map +1 -0
- package/dist/components/form/inputs/RichText2/Toolbar.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText2/index.d.ts +24 -0
- package/dist/components/form/inputs/RichText2/index.d.ts.map +1 -0
- package/dist/components/form/inputs/RichText2/index.vue.d.ts +1 -0
- package/dist/components/form/inputs/RichText2/index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichTextEditor.vue.d.ts +3 -3
- package/dist/components/form/inputs/SelectField.vue.d.ts +6 -8
- package/dist/components/form/inputs/SelectField.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.d.ts +55 -0
- package/dist/components/form/inputs/SelectInput.d.ts.map +1 -0
- package/dist/components/form/inputs/SignaturePad.d.ts +72 -0
- package/dist/components/form/inputs/SignaturePad.d.ts.map +1 -0
- package/dist/components/form/inputs/TableField.d.ts +45 -0
- package/dist/components/form/inputs/TableField.d.ts.map +1 -0
- package/dist/components/form/inputs/TelInput.d.ts +241 -0
- package/dist/components/form/inputs/TelInput.d.ts.map +1 -0
- package/dist/components/form/inputs/TextArea.vue.d.ts +3 -3
- package/dist/components/form/inputs/TextInput.d.ts +90 -0
- package/dist/components/form/inputs/TextInput.d.ts.map +1 -0
- package/dist/components/form/inputs/ToggleInput.d.ts +58 -0
- package/dist/components/form/inputs/ToggleInput.d.ts.map +1 -0
- package/dist/components/form/inputs/Upload/{UploadFile.vue.d.ts → UploadInput.vue.d.ts} +1 -1
- package/dist/components/form/inputs/Upload/UploadInput.vue.d.ts.map +1 -0
- package/dist/components/form/inputs/index.d.ts +1 -1
- package/dist/components/form/inputs/index.d.ts.map +1 -1
- package/dist/components/form/useBagelFormState.d.ts +11 -0
- package/dist/components/form/useBagelFormState.d.ts.map +1 -0
- package/dist/components/formkit/AddressArray.vue.d.ts +2 -2
- package/dist/components/formkit/BankDetailsArray.vue.d.ts +2 -2
- package/dist/components/formkit/ContactArrayFormKit.vue.d.ts +2 -2
- package/dist/components/formkit/FileUploader.vue.d.ts +2 -2
- package/dist/components/formkit/MiscFields.vue.d.ts +2 -2
- package/dist/components/formkit/Toggle.vue.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/layout/BottomMenu.d.ts +27 -0
- package/dist/components/layout/BottomMenu.d.ts.map +1 -0
- package/dist/components/layout/Layout.d.ts +58 -0
- package/dist/components/layout/Layout.d.ts.map +1 -0
- package/dist/components/layout/SidebarMenu.d.ts +38 -0
- package/dist/components/layout/SidebarMenu.d.ts.map +1 -0
- package/dist/components/layout/TabbedLayout.d.ts +42 -0
- package/dist/components/layout/TabbedLayout.d.ts.map +1 -0
- package/dist/components/layout/Tabs.d.ts +31 -0
- package/dist/components/layout/Tabs.d.ts.map +1 -0
- package/dist/components/layout/TabsBody.d.ts +23 -0
- package/dist/components/layout/TabsBody.d.ts.map +1 -0
- package/dist/components/layout/TabsNav.d.ts +35 -0
- package/dist/components/layout/TabsNav.d.ts.map +1 -0
- package/dist/components/whatsapp/form/MsgTemplate.vue.d.ts +4 -3
- package/dist/components/whatsapp/form/TextVariableExamples.vue.d.ts +2 -2
- package/dist/index.cjs +7078 -9121
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +7084 -9127
- package/dist/style.css +500 -494
- package/dist/styles.css +14073 -0
- package/dist/utils/BagelFormUtils.d.ts +39 -16
- package/dist/utils/BagelFormUtils.d.ts.map +1 -1
- package/dist/utils/objects.d.ts +1 -0
- package/dist/vue.css +14073 -0
- package/package.json +1 -1
- package/src/components/BglComponent.vue +174 -0
- package/src/components/FieldSetVue.vue +23 -0
- package/src/components/Image.vue +18 -11
- package/src/components/ModalForm.vue +1 -1
- package/src/components/Pill.vue +3 -2
- package/src/components/TableSchema.vue +3 -2
- package/src/components/form/BglField.vue +54 -77
- package/src/components/form/BglForm.vue +44 -31
- package/src/components/form/FieldArray.vue +25 -19
- package/src/components/form/inputs/NumberInput.vue +10 -11
- package/src/components/form/inputs/RangeInput.vue +9 -0
- package/src/components/form/inputs/Upload/{UploadFile.vue → UploadInput.vue} +24 -19
- package/src/components/form/inputs/index.ts +1 -1
- package/src/components/form/useBagelFormState.ts +87 -0
- package/src/components/index.ts +5 -2
- package/src/index.ts +3 -1
- package/src/utils/BagelFormUtils.ts +28 -7
- package/dist/common-C_IH8b5S.cjs +0 -12580
- package/dist/common-DoeNgx31.js +0 -12579
- package/dist/components/AddressSaerch.vue.d.ts +0 -7
- package/dist/components/AddressSaerch.vue.d.ts.map +0 -1
- package/dist/components/Popover.vue.d.ts +0 -10
- package/dist/components/Popover.vue.d.ts.map +0 -1
- package/dist/components/form/inputs/RichText/Toolbar.vue.d.ts +0 -14
- package/dist/components/form/inputs/RichText/Toolbar.vue.d.ts.map +0 -1
- package/dist/components/form/inputs/RichText/formatting.d.ts +0 -11
- package/dist/components/form/inputs/RichText/formatting.d.ts.map +0 -1
- package/dist/components/form/inputs/RichText/richtext-types.d.ts +0 -3
- package/dist/components/form/inputs/RichText/richtext-types.d.ts.map +0 -1
- package/dist/components/form/inputs/Upload/UploadFile.vue.d.ts.map +0 -1
- package/dist/components/sortable/Animation.d.ts +0 -43
- package/dist/components/sortable/Animation.d.ts.map +0 -1
- package/dist/components/sortable/BrowserInfo.d.ts +0 -7
- package/dist/components/sortable/BrowserInfo.d.ts.map +0 -1
- package/dist/components/sortable/EventDispatcher.d.ts +0 -13
- package/dist/components/sortable/EventDispatcher.d.ts.map +0 -1
- package/dist/components/sortable/PluginManager.d.ts +0 -27
- package/dist/components/sortable/PluginManager.d.ts.map +0 -1
- package/dist/components/sortable/Sortable.d.ts +0 -81
- package/dist/components/sortable/Sortable.d.ts.map +0 -1
- package/dist/components/sortable/index.d.ts +0 -5
- package/dist/components/sortable/index.d.ts.map +0 -1
- package/dist/components/sortable/utils.d.ts +0 -49
- package/dist/components/sortable/utils.d.ts.map +0 -1
- package/dist/composables/drag-n-drop/useDraggable.d.ts +0 -2
- package/dist/composables/drag-n-drop/useDraggable.d.ts.map +0 -1
- package/dist/editor-CUDRLdmS.js +0 -4
- package/dist/editor-Cu374vEW.cjs +0 -4
- package/dist/editor-a8DSbb6P.js +0 -4
- package/dist/editor-xBt_vIha.cjs +0 -4
- package/dist/heic2any-8wMqMfB_.js +0 -933
- package/dist/heic2any-BrqcNzfV.js +0 -935
- package/dist/heic2any-C8KwH72N.cjs +0 -934
- package/dist/heic2any-k9wDCKka.cjs +0 -932
- package/dist/index-DiG-xM9T.cjs +0 -35016
- package/dist/index-nGuSAiY2.js +0 -35017
- package/dist/plugins/drag-n-drop/draggable.d.ts +0 -4
- package/dist/plugins/drag-n-drop/draggable.d.ts.map +0 -1
- package/dist/plugins/drag-n-drop/droppable.d.ts +0 -4
- package/dist/plugins/drag-n-drop/droppable.d.ts.map +0 -1
- package/dist/plugins/drag-n-drop/index.d.ts +0 -5
- package/dist/plugins/drag-n-drop/index.d.ts.map +0 -1
- package/dist/plugins/drag-n-drop/useDraggable.d.ts +0 -8
- package/dist/plugins/drag-n-drop/useDraggable.d.ts.map +0 -1
- package/dist/plugins/drag-n-drop/useDroppable.d.ts +0 -7
- package/dist/plugins/drag-n-drop/useDroppable.d.ts.map +0 -1
- package/dist/types/materialIcon.d.ts +0 -2
- package/dist/types/materialIcon.d.ts.map +0 -1
- package/src/components/FieldSet.vue +0 -15
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
BglFormSchemaFnT,
|
|
8
8
|
Field,
|
|
9
9
|
} from '@bagelink/vue'
|
|
10
|
-
import { BglForm, Btn } from '@bagelink/vue'
|
|
10
|
+
import { BglForm, BglField, Btn } from '@bagelink/vue'
|
|
11
11
|
|
|
12
12
|
const props = withDefaults(
|
|
13
13
|
defineProps<{
|
|
@@ -25,6 +25,7 @@ const props = withDefaults(
|
|
|
25
25
|
defaultValue?: any
|
|
26
26
|
add?: boolean
|
|
27
27
|
delete?: boolean
|
|
28
|
+
transform?: (value: T) => T
|
|
28
29
|
schema: BglFormSchemaFnT
|
|
29
30
|
modelValue: T[]
|
|
30
31
|
}>(),
|
|
@@ -53,31 +54,33 @@ function addItem() {
|
|
|
53
54
|
emitValue()
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
const computedField = $computed(
|
|
58
|
+
() => ({
|
|
59
|
+
label: props.label,
|
|
60
|
+
placeholder: props.placeholder,
|
|
61
|
+
children: props.children,
|
|
62
|
+
// class: props.class,
|
|
63
|
+
attrs: props.attrs,
|
|
64
|
+
required: props.required,
|
|
65
|
+
disabled: props.disabled,
|
|
66
|
+
helptext: props.helptext,
|
|
67
|
+
options: props.options,
|
|
68
|
+
defaultValue: props.defaultValue,
|
|
69
|
+
transform: props.transform,
|
|
70
|
+
$el: props.el,
|
|
71
|
+
}) as Field<T>
|
|
72
|
+
) as Field<Record<string, any>>
|
|
71
73
|
</script>
|
|
72
74
|
|
|
73
75
|
<template>
|
|
74
|
-
<div>
|
|
76
|
+
<div :class="props.class">
|
|
75
77
|
<p class="label mb-05">
|
|
76
78
|
{{ label }}
|
|
77
79
|
</p>
|
|
78
|
-
|
|
80
|
+
|
|
81
|
+
<div v-if="schema" class="-ms-05 ps-05 border-start">
|
|
79
82
|
<div v-for="(_, i) in data" :key="i" outline thin class="mb-05 itemBox transition p-05">
|
|
80
|
-
<BglForm v-
|
|
83
|
+
<BglForm v-model="data[i]" :schema="schema" @update:model-value="emitValue" />
|
|
81
84
|
<Btn
|
|
82
85
|
v-if="props.delete"
|
|
83
86
|
icon="delete"
|
|
@@ -92,6 +95,9 @@ function addItem() {
|
|
|
92
95
|
<p>Add {{ label }}</p>
|
|
93
96
|
</Btn>
|
|
94
97
|
</div>
|
|
98
|
+
<template v-else>
|
|
99
|
+
<BglField v-for="(_, i) in data" :key="i" v-model="data[i]" :field="computedField" @update:model-value="emitValue" />
|
|
100
|
+
</template>
|
|
95
101
|
</div>
|
|
96
102
|
</template>
|
|
97
103
|
|
|
@@ -14,7 +14,7 @@ interface NumberInputProps {
|
|
|
14
14
|
icon?: MaterialIcons
|
|
15
15
|
label?: string
|
|
16
16
|
placeholder?: string
|
|
17
|
-
disabled
|
|
17
|
+
disabled?: boolean
|
|
18
18
|
required?: boolean
|
|
19
19
|
id?: string
|
|
20
20
|
helptext?: string
|
|
@@ -47,17 +47,16 @@ const btnLayouts: NumberLayout[] = ['horizontal', 'vertical']
|
|
|
47
47
|
|
|
48
48
|
// Methods
|
|
49
49
|
function increment() {
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
50
|
+
if (max !== undefined && (numberValue + step) > max) return
|
|
51
|
+
numberValue = (numberValue || 0) + step
|
|
52
|
+
emit('update:modelValue', numberValue)
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
function decrement() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
numberValue = numberValue || 0
|
|
57
|
+
if (min !== undefined && (numberValue - step) < min) return
|
|
58
|
+
numberValue = numberValue - step
|
|
59
|
+
emit('update:modelValue', numberValue)
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
function formatNumber(num: number) {
|
|
@@ -97,7 +96,7 @@ watch(() => modelValue, (newVal) => {
|
|
|
97
96
|
<label :for="id">
|
|
98
97
|
{{ label }}
|
|
99
98
|
<div class="gap-025" :class="{ 'column flex': layout === 'vertical', 'flex': layout === 'horizontal' }">
|
|
100
|
-
<Btn v-if="layout && btnLayouts.includes(layout)" icon="add" class="radius" :class="[{ 'bgl-big-ctrl-num-btn': layout === 'vertical' }]" @click="increment" />
|
|
99
|
+
<Btn v-if="layout && btnLayouts.includes(layout)" flat icon="add" class="radius" :class="[{ 'bgl-big-ctrl-num-btn': layout === 'vertical' }]" @click="increment" />
|
|
101
100
|
|
|
102
101
|
<input
|
|
103
102
|
:id
|
|
@@ -131,7 +130,7 @@ watch(() => modelValue, (newVal) => {
|
|
|
131
130
|
v-if="icon"
|
|
132
131
|
:icon
|
|
133
132
|
/>
|
|
134
|
-
<Btn v-if="layout && btnLayouts.includes(layout)" icon="remove" class="radius" :class="[{ 'bgl-big-ctrl-num-btn': layout === 'vertical' }]" @click="decrement" />
|
|
133
|
+
<Btn v-if="layout && btnLayouts.includes(layout)" flat icon="remove" class="radius" :class="[{ 'bgl-big-ctrl-num-btn': layout === 'vertical' }]" @click="decrement" />
|
|
135
134
|
|
|
136
135
|
<div v-if="spinner && (!layout || !btnLayouts.includes(layout))" class="flex column spinner">
|
|
137
136
|
<Btn icon="add" flat thin class="bgl-ctrl-num-btn" @click="increment" />
|
|
@@ -45,6 +45,15 @@ const rangeStyle = $computed(() => {
|
|
|
45
45
|
if (rtl) return { left: `${width}%`, width: `${fromPercentage}%` }
|
|
46
46
|
return { right: `${width}%`, width: `${fromPercentage}%` }
|
|
47
47
|
})
|
|
48
|
+
|
|
49
|
+
watch(() => modelValue, (newVal) => {
|
|
50
|
+
if (Array.isArray(newVal)) {
|
|
51
|
+
from = newVal[0]
|
|
52
|
+
to = newVal[1]
|
|
53
|
+
} else {
|
|
54
|
+
from = newVal
|
|
55
|
+
}
|
|
56
|
+
}, { immediate: true })
|
|
48
57
|
</script>
|
|
49
58
|
|
|
50
59
|
<template>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { MaterialIcons } from '@bagelink/vue'
|
|
3
2
|
import type { BglFile, QueueFile } from './upload.types'
|
|
4
3
|
import { Btn, IMAGE_FORMATS_REGEXP, Icon, useBagel, Card, Image } from '@bagelink/vue'
|
|
5
4
|
import { watch } from 'vue'
|
|
@@ -27,10 +26,11 @@ const props = withDefaults(defineProps<{
|
|
|
27
26
|
|
|
28
27
|
const emit = defineEmits(['update:modelValue', 'addFileStart'])
|
|
29
28
|
const bagel = useBagel()
|
|
30
|
-
const fileBaseUrl = $computed(() => (props.baseURL || bagel.fileBaseUrl || 'https://files.bagel.design').replace(/\/$/, ''))
|
|
31
29
|
|
|
32
30
|
files.setBaseUrl(bagel.host)
|
|
33
31
|
|
|
32
|
+
const fileBaseUrl = $computed(() => (props.baseURL || bagel.fileBaseUrl || 'https://files.bagel.design').replace(/\/$/, ''))
|
|
33
|
+
const pathToUrl = (path_key: string) => `${fileBaseUrl}/${path_key}`
|
|
34
34
|
const fileQueue = $ref<QueueFile[]>([])
|
|
35
35
|
let storageFiles = $ref<BglFile[]>([])
|
|
36
36
|
const pk = $ref<string[]>([props.modelValue].flat().filter(Boolean) as string[])
|
|
@@ -46,7 +46,6 @@ watch(() => pk, (value) => {
|
|
|
46
46
|
}, { deep: true })
|
|
47
47
|
|
|
48
48
|
const isImage = (str: string) => IMAGE_FORMATS_REGEXP.test(str)
|
|
49
|
-
const pathToUrl = (path_key: string) => `${fileBaseUrl}/${path_key}`
|
|
50
49
|
const fileToUrl = (file: File) => URL.createObjectURL(file)
|
|
51
50
|
|
|
52
51
|
let isDragOver = $ref(false)
|
|
@@ -165,18 +164,25 @@ watch(() => props.dirPath, () => {
|
|
|
165
164
|
<div class="txt-gray txt-12 flex">
|
|
166
165
|
<div class="m-05 flex opacity-7 z-99">
|
|
167
166
|
<Btn
|
|
168
|
-
v-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
167
|
+
v-tooltip="'Delete'"
|
|
168
|
+
color="gray"
|
|
169
|
+
thin
|
|
170
|
+
icon="delete"
|
|
171
|
+
@click="removeFile(path_key)"
|
|
172
|
+
/>
|
|
173
|
+
<Btn
|
|
174
|
+
v-tooltip="'Replace'"
|
|
175
175
|
color="gray"
|
|
176
176
|
thin
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
icon="autorenew"
|
|
178
|
+
@click="browse"
|
|
179
|
+
/>
|
|
180
|
+
<Btn
|
|
181
|
+
icon="download"
|
|
182
|
+
flat
|
|
183
|
+
thin
|
|
184
|
+
:href="pathToUrl(path_key)"
|
|
185
|
+
:download="path_key.split('/').pop()"
|
|
180
186
|
/>
|
|
181
187
|
<p
|
|
182
188
|
v-lightbox="{ src: pathToUrl(path_key), download: true }"
|
|
@@ -219,12 +225,11 @@ watch(() => props.dirPath, () => {
|
|
|
219
225
|
class="multi-image-item-preview"
|
|
220
226
|
:class="{ 'bgl_fill-image': fill }"
|
|
221
227
|
>
|
|
222
|
-
<
|
|
228
|
+
<Image
|
|
223
229
|
v-if="isImage(path_key)"
|
|
230
|
+
:pathKey="path_key"
|
|
224
231
|
class="multi-preview"
|
|
225
|
-
|
|
226
|
-
alt=""
|
|
227
|
-
>
|
|
232
|
+
/>
|
|
228
233
|
<Icon v-else icon="description" class="multi-preview" />
|
|
229
234
|
<p class="m-0">
|
|
230
235
|
{{ path_key.split('/').pop() }}
|
|
@@ -234,7 +239,7 @@ watch(() => props.dirPath, () => {
|
|
|
234
239
|
flat
|
|
235
240
|
icon="delete"
|
|
236
241
|
color="red"
|
|
237
|
-
@click
|
|
242
|
+
@click="removeFile(path_key)"
|
|
238
243
|
/>
|
|
239
244
|
</div>
|
|
240
245
|
<div
|
|
@@ -304,7 +309,7 @@ watch(() => props.dirPath, () => {
|
|
|
304
309
|
<div v-if="isImage(path_key)" class="h-100">
|
|
305
310
|
<Image
|
|
306
311
|
class="single-preview"
|
|
307
|
-
:
|
|
312
|
+
:pathKey="path_key"
|
|
308
313
|
alt=""
|
|
309
314
|
/>
|
|
310
315
|
</div>
|
|
@@ -19,4 +19,4 @@ export { default as TableField } from './TableField.vue'
|
|
|
19
19
|
export { default as TelInput } from './TelInput.vue'
|
|
20
20
|
export { default as TextInput } from './TextInput.vue'
|
|
21
21
|
export { default as ToggleInput } from './ToggleInput.vue'
|
|
22
|
-
export { default as
|
|
22
|
+
export { default as UploadInput } from './Upload/UploadInput.vue'
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { inject, provide, ref, type Ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
export const FORM_STATE_KEY = Symbol('bagelFormState')
|
|
4
|
+
|
|
5
|
+
export interface BagelFormState<T = any> {
|
|
6
|
+
data: Ref<T>
|
|
7
|
+
getFieldData: (path?: string) => any
|
|
8
|
+
updateField: (path: string, value: any) => void
|
|
9
|
+
isDirty: Ref<boolean>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Helper function to safely clone objects without circular references
|
|
13
|
+
function safeClone(obj: any): any {
|
|
14
|
+
if (obj === null || typeof obj !== 'object') return obj
|
|
15
|
+
|
|
16
|
+
const seen = new WeakSet()
|
|
17
|
+
return JSON.parse(JSON.stringify(obj, (key, value) => {
|
|
18
|
+
if (typeof value === 'object' && value !== null) {
|
|
19
|
+
if (seen.has(value)) {
|
|
20
|
+
return undefined // Remove circular reference
|
|
21
|
+
}
|
|
22
|
+
seen.add(value)
|
|
23
|
+
}
|
|
24
|
+
return value
|
|
25
|
+
}))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function provideBagelFormState<T>(initialData: T) {
|
|
29
|
+
const data = ref(initialData) as Ref<T>
|
|
30
|
+
const isDirty = ref(false)
|
|
31
|
+
|
|
32
|
+
const getFieldData = (path?: string) => {
|
|
33
|
+
if (!path) return ''
|
|
34
|
+
const keys = path.split(/[.[]/)
|
|
35
|
+
let current = data.value as any
|
|
36
|
+
|
|
37
|
+
for (let i = 0; i < keys.length; i++) {
|
|
38
|
+
const key = keys[i]
|
|
39
|
+
if (!current || typeof current !== 'object' || !(key in current)) {
|
|
40
|
+
return ''
|
|
41
|
+
}
|
|
42
|
+
current = current[key]
|
|
43
|
+
}
|
|
44
|
+
return current ?? ''
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const updateField = (path: string, value: any) => {
|
|
48
|
+
const keys = path.split(/[.[]/)
|
|
49
|
+
|
|
50
|
+
// Initialize the root if it's not an object
|
|
51
|
+
if (typeof data.value !== 'object' || data.value === null) {
|
|
52
|
+
data.value = {} as T
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let current = data.value as any
|
|
56
|
+
|
|
57
|
+
// Build the path, ensuring each level is an object
|
|
58
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
59
|
+
const key = keys[i]
|
|
60
|
+
if (!(key in current) || typeof current[key] !== 'object' || current[key] === null) {
|
|
61
|
+
current[key] = {}
|
|
62
|
+
}
|
|
63
|
+
current = current[key]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Safely clone the value to remove circular references
|
|
67
|
+
const safeValue = safeClone(value)
|
|
68
|
+
current[keys[keys.length - 1]] = safeValue
|
|
69
|
+
isDirty.value = true
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const state: BagelFormState<T> = {
|
|
73
|
+
data,
|
|
74
|
+
getFieldData,
|
|
75
|
+
updateField,
|
|
76
|
+
isDirty
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
provide(FORM_STATE_KEY, state)
|
|
80
|
+
return state
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function useBagelFormState<T>() {
|
|
84
|
+
const state = inject<BagelFormState<T>>(FORM_STATE_KEY)
|
|
85
|
+
if (!state) throw new Error('BagelFormState must be provided')
|
|
86
|
+
return state
|
|
87
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { default as AddressSearch } from './AddressSearch.vue'
|
|
|
4
4
|
export { default as Alert } from './Alert.vue'
|
|
5
5
|
export { default as Avatar } from './Avatar.vue'
|
|
6
6
|
export { default as Badge } from './Badge.vue'
|
|
7
|
+
export { default as BglComponent } from './BglComponent.vue'
|
|
7
8
|
export { default as BglVideo } from './BglVideo.vue'
|
|
8
9
|
export { default as Btn } from './Btn.vue'
|
|
9
10
|
export { default as Card } from './Card.vue'
|
|
@@ -11,6 +12,7 @@ export { default as Carousel } from './Carousel.vue'
|
|
|
11
12
|
export * from './dashboard'
|
|
12
13
|
export { default as DataPreview } from './DataPreview.vue'
|
|
13
14
|
export { default as Dropdown } from './Dropdown.vue'
|
|
15
|
+
export { default as FieldSetVue } from './FieldSetVue.vue'
|
|
14
16
|
export { default as Flag } from './Flag.vue'
|
|
15
17
|
export * from './form'
|
|
16
18
|
export { default as IframeVue } from './IframeVue.vue'
|
|
@@ -22,17 +24,18 @@ export { default as Loading } from './Loading.vue'
|
|
|
22
24
|
export { default as MapEmbed } from './MapEmbed.vue'
|
|
23
25
|
export { default as MaterialIcon } from './MaterialIcon.vue'
|
|
24
26
|
export { default as Icon } from './MaterialIcon.vue'
|
|
27
|
+
|
|
25
28
|
export { default as Modal } from './Modal.vue'
|
|
26
29
|
export { default as ModalConfirm } from './ModalConfirm.vue'
|
|
27
30
|
export { default as ModalForm } from './ModalForm.vue'
|
|
28
|
-
|
|
29
31
|
export { default as NavBar } from './NavBar.vue'
|
|
30
32
|
export { default as PageTitle } from './PageTitle.vue'
|
|
31
33
|
export { default as Pill } from './Pill.vue'
|
|
32
34
|
export { default as RouterWrapper } from './RouterWrapper.vue'
|
|
33
35
|
export { default as TableSchema } from './TableSchema.vue'
|
|
36
|
+
|
|
34
37
|
export { default as Title } from './Title.vue'
|
|
35
38
|
export { default as ToolBar } from './ToolBar.vue'
|
|
36
|
-
export { default as TopBar } from './TopBar.vue'
|
|
37
39
|
|
|
40
|
+
export { default as TopBar } from './TopBar.vue'
|
|
38
41
|
export { default as Zoomer } from './Zoomer.vue'
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './components'
|
|
2
|
+
export * from './components/form/useBagelFormState'
|
|
2
3
|
export * from './composables'
|
|
3
4
|
export {
|
|
4
5
|
bagelInjectionKey,
|
|
@@ -13,5 +14,6 @@ export * from './types'
|
|
|
13
14
|
export * from './utils'
|
|
14
15
|
export * from './utils/allCountries'
|
|
15
16
|
export * from './utils/constants'
|
|
16
|
-
export * from './utils/timeAgo'
|
|
17
17
|
import './styles/bagel.css'
|
|
18
|
+
|
|
19
|
+
export * from './utils/timeAgo'
|
|
@@ -8,6 +8,7 @@ interface InputOptions {
|
|
|
8
8
|
defaultValue?: string
|
|
9
9
|
disabled?: boolean
|
|
10
10
|
helptext?: string
|
|
11
|
+
vIf?: boolean | ((item: any, row: any) => boolean)
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
type DateOptions = InputOptions
|
|
@@ -50,6 +51,7 @@ export function richText(
|
|
|
50
51
|
required: options?.required,
|
|
51
52
|
id,
|
|
52
53
|
label,
|
|
54
|
+
vIf: options?.vIf,
|
|
53
55
|
placeholder: options?.placeholder,
|
|
54
56
|
attrs: {},
|
|
55
57
|
}
|
|
@@ -66,6 +68,7 @@ export function txtField(
|
|
|
66
68
|
required: options?.required,
|
|
67
69
|
id,
|
|
68
70
|
label,
|
|
71
|
+
vIf: options?.vIf,
|
|
69
72
|
disabled: options?.disabled,
|
|
70
73
|
placeholder: options?.placeholder,
|
|
71
74
|
defaultValue: options?.defaultValue,
|
|
@@ -93,6 +96,7 @@ export function slctField(
|
|
|
93
96
|
required: config?.required,
|
|
94
97
|
label,
|
|
95
98
|
defaultValue: config?.defaultValue,
|
|
99
|
+
vIf: config?.vIf,
|
|
96
100
|
attrs: {
|
|
97
101
|
disabled: config?.disabled,
|
|
98
102
|
searchable: config?.searchable,
|
|
@@ -130,6 +134,7 @@ export function dateField(
|
|
|
130
134
|
disabled: options?.disabled,
|
|
131
135
|
label,
|
|
132
136
|
defaultValue: options?.defaultValue,
|
|
137
|
+
vIf: options?.vIf,
|
|
133
138
|
attrs: {
|
|
134
139
|
disabled: options?.disabled,
|
|
135
140
|
},
|
|
@@ -142,7 +147,7 @@ export function numField(
|
|
|
142
147
|
options?: NumFieldOptions,
|
|
143
148
|
): Field {
|
|
144
149
|
return {
|
|
145
|
-
$el: '
|
|
150
|
+
$el: 'number',
|
|
146
151
|
class: options?.class,
|
|
147
152
|
required: options?.required,
|
|
148
153
|
defaultValue: options?.defaultValue,
|
|
@@ -151,13 +156,11 @@ export function numField(
|
|
|
151
156
|
disabled: options?.disabled,
|
|
152
157
|
placeholder: options?.placeholder,
|
|
153
158
|
helptext: options?.helptext,
|
|
159
|
+
vIf: options?.vIf,
|
|
154
160
|
attrs: {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
min: options?.min,
|
|
159
|
-
max: options?.max,
|
|
160
|
-
},
|
|
161
|
+
step: options?.step,
|
|
162
|
+
min: options?.min,
|
|
163
|
+
max: options?.max,
|
|
161
164
|
},
|
|
162
165
|
}
|
|
163
166
|
}
|
|
@@ -170,6 +173,22 @@ export function frmRow(...children: Field[]) {
|
|
|
170
173
|
}
|
|
171
174
|
}
|
|
172
175
|
|
|
176
|
+
interface UploadOptions extends InputOptions {
|
|
177
|
+
multiple?: boolean
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function uploadField(id: string, label?: string, options?: UploadOptions) {
|
|
181
|
+
return {
|
|
182
|
+
$el: 'upload',
|
|
183
|
+
id,
|
|
184
|
+
label,
|
|
185
|
+
vIf: options?.vIf,
|
|
186
|
+
attrs: {
|
|
187
|
+
...options,
|
|
188
|
+
},
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
173
192
|
export function bglForm(idOrField?: string | Field, ...schema: Field[]) {
|
|
174
193
|
if (typeof idOrField === 'string') {
|
|
175
194
|
return {
|
|
@@ -193,6 +212,7 @@ export function telField(id: string, label?: string, options?: { [key: string]:
|
|
|
193
212
|
$el: markRaw(TelInput),
|
|
194
213
|
id,
|
|
195
214
|
label,
|
|
215
|
+
vIf: options?.vIf,
|
|
196
216
|
attrs: options,
|
|
197
217
|
}
|
|
198
218
|
}
|
|
@@ -218,6 +238,7 @@ export function arrField(id: string, label: string, schema: BglFormSchemaT, opti
|
|
|
218
238
|
label,
|
|
219
239
|
id,
|
|
220
240
|
$el: 'array',
|
|
241
|
+
vIf: options?.vIf,
|
|
221
242
|
attrs: { schema, delete: true, add: true, ...options },
|
|
222
243
|
}
|
|
223
244
|
}
|