@bagelink/vue 1.21.22 → 1.21.30
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/{StructuredEditor-CBut_alq.cjs → StructuredEditor-CSpZb-WA.cjs} +2 -2
- package/dist/{StructuredEditor-DVWSlCuv.js → StructuredEditor-Vwn0_hXR.js} +4 -2
- package/dist/StructuredEditor.css +1 -1
- package/dist/components/form/inputs/ArrayInput.vue.d.ts +15 -0
- package/dist/components/form/inputs/ArrayInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CodeEditor/StructuredEditor.vue.d.ts.map +1 -1
- package/dist/components/layout/AppSidebar.vue.d.ts.map +1 -1
- package/dist/core.css +2 -2
- package/dist/form-flow/FormFlow.vue.d.ts +2 -0
- package/dist/form-flow/FormFlow.vue.d.ts.map +1 -1
- package/dist/form-flow/form-flow.d.ts +34 -0
- package/dist/form-flow/form-flow.d.ts.map +1 -1
- package/dist/i18n/index.d.ts +30 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/src-CbQepE2Q.cjs +764 -0
- package/dist/{src-C2dddU0t.js → src-FXpWQVAW.js} +9744 -9589
- package/dist/src.css +1 -1
- package/dist/style.css +2 -2
- package/package.json +2 -2
- package/src/components/form/inputs/ArrayInput.vue +274 -73
- package/src/components/form/inputs/CodeEditor/Index.vue +7 -0
- package/src/components/form/inputs/CodeEditor/StructuredEditor.vue +12 -0
- package/src/components/layout/AppSidebar.vue +3 -2
- package/src/components/layout/SidebarNavItem.vue +3 -3
- package/src/form-flow/FormFlow.vue +31 -3
- package/src/form-flow/form-flow.ts +34 -0
- package/src/i18n/locales/en.json +6 -1
- package/src/i18n/locales/es.json +6 -1
- package/src/i18n/locales/fr.json +6 -1
- package/src/i18n/locales/he.json +6 -1
- package/src/i18n/locales/it.json +6 -1
- package/src/i18n/locales/ru.json +6 -1
- package/dist/src-CF4KCA4n.cjs +0 -764
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.21.
|
|
4
|
+
"version": "1.21.30",
|
|
5
5
|
"description": "Bagel core sdk packages",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Bagel Studio",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@types/signature_pad": "^4.0.0",
|
|
64
64
|
"vue": "^3.5.45",
|
|
65
65
|
"vue-component-type-helpers": "^2.2.12",
|
|
66
|
-
"@bagelink/sdk": "1.21.
|
|
66
|
+
"@bagelink/sdk": "1.21.30"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@bagelink/sdk": "*",
|
|
@@ -4,7 +4,7 @@ import type { Ref, WritableComputedRef } from 'vue'
|
|
|
4
4
|
import type { DraggableEvent } from '../../draggable/useDraggable'
|
|
5
5
|
import { reorderItems } from '../../draggable/reorder'
|
|
6
6
|
|
|
7
|
-
import { Btn, resolveI18n, useI18n, pathKeyToURL, richTextToPlainText } from '../../../index'
|
|
7
|
+
import { Btn, EmptyState, resolveI18n, useI18n, pathKeyToURL, richTextToPlainText } from '../../../index'
|
|
8
8
|
import { computed, ref, watch, useSlots, type VNode } from 'vue'
|
|
9
9
|
import Draggable from '../../draggable/Draggable.vue'
|
|
10
10
|
import type { BagelInputShellProps } from './bagelInputShell'
|
|
@@ -24,6 +24,18 @@ const props = withDefaults(defineProps<{
|
|
|
24
24
|
simple?: boolean
|
|
25
25
|
/** Shows fixed item labels with drag handles, without editable row content. */
|
|
26
26
|
reorderOnly?: boolean
|
|
27
|
+
/** Show `(n)` next to the field label. Opt-in. */
|
|
28
|
+
showCount?: boolean
|
|
29
|
+
/** Show per-row numbers/labels in non-collapsible mode. Opt-in. */
|
|
30
|
+
showItemNumbers?: boolean
|
|
31
|
+
/** Light border around each non-collapsible row. Opt-in. */
|
|
32
|
+
separated?: boolean
|
|
33
|
+
/** Show EmptyState when the list has no items. Opt-in. */
|
|
34
|
+
showEmptyState?: boolean
|
|
35
|
+
/** Derive Add label from `itemLabel` / “add another…”. Opt-in. */
|
|
36
|
+
smartAddText?: boolean
|
|
37
|
+
/** Override empty-state title (used when `showEmptyState` is on). */
|
|
38
|
+
emptyText?: string
|
|
27
39
|
/** Factory for new rows. Prefer this over pushing `undefined` (which becomes `null` after JSON sync). */
|
|
28
40
|
createItem?: () => T
|
|
29
41
|
/**
|
|
@@ -33,11 +45,22 @@ const props = withDefaults(defineProps<{
|
|
|
33
45
|
* `oldest-first`: renders in array order, with the Add button below the list.
|
|
34
46
|
*/
|
|
35
47
|
sortOrder?: 'newest-first' | 'oldest-first'
|
|
48
|
+
/** Block adding, removing, reordering, and editing rows. */
|
|
49
|
+
disabled?: boolean
|
|
50
|
+
readonly?: boolean
|
|
36
51
|
} & BagelInputShellProps>(), {
|
|
37
52
|
sortOrder: 'newest-first',
|
|
53
|
+
showCount: false,
|
|
54
|
+
showItemNumbers: false,
|
|
55
|
+
separated: false,
|
|
56
|
+
showEmptyState: false,
|
|
57
|
+
smartAddText: false,
|
|
38
58
|
})
|
|
39
59
|
|
|
40
|
-
|
|
60
|
+
// Style only (min/max width, label colors). Do NOT apply shellClass (`bgl-outline` /
|
|
61
|
+
// `frame`) on the root — those cascade to nested fields (e.g. TelInput) via global
|
|
62
|
+
// `.bagel-input.bgl-outline …` selectors. The list border lives on `.array-input-shell`.
|
|
63
|
+
const { shellStyle } = useBagelInputShell(props)
|
|
41
64
|
|
|
42
65
|
const emit = defineEmits(['update:modelValue'])
|
|
43
66
|
defineSlots<{
|
|
@@ -51,6 +74,7 @@ const items = ref(Array.isArray(props.modelValue) ? [...props.modelValue] : [])
|
|
|
51
74
|
const minimizedItems = ref(Array.from({ length: items.value.length }, () => true))
|
|
52
75
|
|
|
53
76
|
const hasValue = computed(() => items.value.some(item => item !== undefined && item !== null && item !== ''))
|
|
77
|
+
const isEmpty = computed(() => items.value.length === 0)
|
|
54
78
|
|
|
55
79
|
const itemLabelPrefix = computed(() => {
|
|
56
80
|
const resolvedCustomLabel = resolveI18n(props.itemLabel)
|
|
@@ -60,6 +84,43 @@ const itemLabelPrefix = computed(() => {
|
|
|
60
84
|
return $t('arrayInput.item')
|
|
61
85
|
})
|
|
62
86
|
|
|
87
|
+
const customItemNoun = computed(() => {
|
|
88
|
+
const resolvedCustomLabel = resolveI18n(props.itemLabel)
|
|
89
|
+
if (typeof resolvedCustomLabel === 'string' && resolvedCustomLabel.length > 0) {
|
|
90
|
+
return resolvedCustomLabel
|
|
91
|
+
}
|
|
92
|
+
return null
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
/** Add button label. Smart variants only when `smartAddText` is on. */
|
|
96
|
+
const addLabel = computed(() => {
|
|
97
|
+
if (props.addText) {
|
|
98
|
+
return resolveI18n(props.addText) || props.addText
|
|
99
|
+
}
|
|
100
|
+
// Keep the historical default (`'Add'`) unless smart labels are opted in.
|
|
101
|
+
if (!props.smartAddText) {
|
|
102
|
+
return resolveI18n('Add') || 'Add'
|
|
103
|
+
}
|
|
104
|
+
const noun = customItemNoun.value
|
|
105
|
+
const hasItems = items.value.length > 0
|
|
106
|
+
if (noun) {
|
|
107
|
+
return hasItems
|
|
108
|
+
? $t('arrayInput.addAnotherItem', { item: noun })
|
|
109
|
+
: $t('arrayInput.addItem', { item: noun })
|
|
110
|
+
}
|
|
111
|
+
return hasItems ? $t('arrayInput.addAnother') : $t('arrayInput.add')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
/** Tighter list spacing only when a list shell (outline/frame) is active. */
|
|
115
|
+
const hasListShell = computed(() => !!props.outline || !!props.frame)
|
|
116
|
+
|
|
117
|
+
const showEmptyPlaceholder = computed(() => isEmpty.value && props.showEmptyState)
|
|
118
|
+
|
|
119
|
+
const emptyTitle = computed(() => {
|
|
120
|
+
if (props.emptyText) return resolveI18n(props.emptyText) || props.emptyText
|
|
121
|
+
return $t('arrayInput.empty')
|
|
122
|
+
})
|
|
123
|
+
|
|
63
124
|
const IDENTIFIER_FIELDS = ['title', 'name', 'type', 'key', 'label', 'displayName', 'display_name', 'heading', 'caption', 'text']
|
|
64
125
|
const IMAGE_FIELDS = ['image', 'thumbnail', 'avatar', 'photo', 'picture', 'profilePic', 'profile_pic', 'icon', 'logo']
|
|
65
126
|
|
|
@@ -99,6 +160,10 @@ interface ViewRow {
|
|
|
99
160
|
}
|
|
100
161
|
|
|
101
162
|
const isNewestFirst = computed(() => props.sortOrder === 'newest-first')
|
|
163
|
+
const locked = computed(() => props.disabled || props.readonly)
|
|
164
|
+
const canAdd = computed(() => !!props.allowAdd && !locked.value)
|
|
165
|
+
const canDelete = computed(() => !!props.allowDelete && !locked.value)
|
|
166
|
+
const canReorder = computed(() => !!props.allowReorder && !locked.value)
|
|
102
167
|
|
|
103
168
|
/**
|
|
104
169
|
* Rows in visual order. `newest-first` keeps the model array untouched and only
|
|
@@ -122,6 +187,10 @@ function getItemLabel(row: ViewRow) {
|
|
|
122
187
|
: `${itemLabelPrefix.value} ${number}`
|
|
123
188
|
}
|
|
124
189
|
|
|
190
|
+
function getRowNumberLabel(row: ViewRow) {
|
|
191
|
+
return `${itemLabelPrefix.value} ${row.index + 1}`
|
|
192
|
+
}
|
|
193
|
+
|
|
125
194
|
watch(
|
|
126
195
|
() => props.modelValue,
|
|
127
196
|
(newVal) => {
|
|
@@ -135,6 +204,7 @@ watch(
|
|
|
135
204
|
)
|
|
136
205
|
|
|
137
206
|
function addItem() {
|
|
207
|
+
if (locked.value) return
|
|
138
208
|
const next = props.createItem ? props.createItem() : ({} as T)
|
|
139
209
|
// Always append: the model keeps chronological order and `newest-first`
|
|
140
210
|
// simply renders the last element on top.
|
|
@@ -145,6 +215,7 @@ function addItem() {
|
|
|
145
215
|
}
|
|
146
216
|
|
|
147
217
|
function deleteItem(i: number) {
|
|
218
|
+
if (locked.value) return
|
|
148
219
|
items.value.splice(i, 1)
|
|
149
220
|
minimizedItems.value.splice(i, 1)
|
|
150
221
|
updateModel()
|
|
@@ -155,6 +226,7 @@ function toggleItem(i: number) {
|
|
|
155
226
|
}
|
|
156
227
|
|
|
157
228
|
function onDraggableEnd(event: DraggableEvent) {
|
|
229
|
+
if (locked.value) return
|
|
158
230
|
const { oldIndex, newIndex } = event
|
|
159
231
|
if (newIndex < 0 || newIndex >= viewRows.value.length || oldIndex === newIndex) {
|
|
160
232
|
return
|
|
@@ -174,6 +246,7 @@ function updateModel() {
|
|
|
174
246
|
}
|
|
175
247
|
|
|
176
248
|
function onUpdate(value: T, i: number) {
|
|
249
|
+
if (locked.value) return
|
|
177
250
|
items.value[i] = value
|
|
178
251
|
updateModel()
|
|
179
252
|
}
|
|
@@ -200,6 +273,8 @@ const isSimple = computed(() => {
|
|
|
200
273
|
return content.length === 1
|
|
201
274
|
})
|
|
202
275
|
|
|
276
|
+
const showRowNumbers = computed(() => !!props.showItemNumbers)
|
|
277
|
+
|
|
203
278
|
// Create a writable computed ref for each item
|
|
204
279
|
function getItemRef(i: number) {
|
|
205
280
|
return computed({
|
|
@@ -213,89 +288,153 @@ function getItemRef(i: number) {
|
|
|
213
288
|
|
|
214
289
|
<template>
|
|
215
290
|
<div
|
|
216
|
-
class="bagel-input array-input
|
|
291
|
+
class="bagel-input array-input" :class="{ 'has-value': hasValue }" :style="shellStyle"
|
|
217
292
|
>
|
|
218
293
|
<label v-if="label" class="txt12 txt-gray-90 mb-025 block">
|
|
219
|
-
{{ resolveI18n(label) }}
|
|
294
|
+
{{ resolveI18n(label) }}<template v-if="showCount"> ({{ items.length }})</template>
|
|
220
295
|
</label>
|
|
221
296
|
<p v-if="helptext" class="helptext">
|
|
222
297
|
{{ helptext }}
|
|
223
298
|
</p>
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
299
|
+
<!-- When outline/frame is on, Add + list share one shell so the control reads as one unit
|
|
300
|
+
and the Add button does not jump when leaving the empty state. -->
|
|
301
|
+
<div
|
|
302
|
+
class="array-input-body"
|
|
303
|
+
:class="{
|
|
304
|
+
'array-input-shell': hasListShell,
|
|
305
|
+
'array-input-shell--outline': !!outline,
|
|
306
|
+
'array-input-shell--frame': !!frame,
|
|
307
|
+
}"
|
|
308
|
+
>
|
|
309
|
+
<Btn
|
|
310
|
+
v-if="canAdd && sortOrder === 'newest-first'"
|
|
311
|
+
class="radius-1 array-input-add" :class="hasListShell ? 'mb-025' : 'mb-05'" thin icon="add"
|
|
312
|
+
:value="addLabel" @click="addItem"
|
|
313
|
+
/>
|
|
314
|
+
|
|
315
|
+
<Transition name="array-body-swap" mode="out-in">
|
|
316
|
+
<div v-if="showEmptyPlaceholder" key="empty" class="array-input-list array-input-empty">
|
|
317
|
+
<!-- Extra CTA inside the empty area; the persistent Add above stays mounted so layout does not jump. -->
|
|
318
|
+
<EmptyState
|
|
319
|
+
compact
|
|
320
|
+
icon="format_list_bulleted_add"
|
|
321
|
+
:title="emptyTitle"
|
|
322
|
+
>
|
|
323
|
+
<template v-if="canAdd" #action>
|
|
324
|
+
<Btn class="radius-1" thin flat icon="add" :value="addLabel" @click="addItem" />
|
|
325
|
+
</template>
|
|
326
|
+
</EmptyState>
|
|
238
327
|
</div>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
class="grab"
|
|
248
|
-
/>
|
|
249
|
-
<slot :item="getItemRef(row.index)" :index="row.index" />
|
|
250
|
-
<div v-if="allowDelete" class="h-100p" :class="{ 'border-start ps-025 ms-075': !simple }">
|
|
328
|
+
|
|
329
|
+
<Draggable
|
|
330
|
+
v-else-if="reorderOnly" key="reorder" :model-value="viewRows" handle=".grab"
|
|
331
|
+
:disabled="!canReorder" class="array-input-list grid gap-05" :class="{ 'mb-05': !hasListShell }"
|
|
332
|
+
@end="onDraggableEnd"
|
|
333
|
+
>
|
|
334
|
+
<template #default="{ item: row }">
|
|
335
|
+
<div class="grid gap-0 grid-array-line-reorder align-items-center pe-025 border radius-1 overflow-hidden">
|
|
251
336
|
<Btn
|
|
252
|
-
v-tooltip="resolveI18n(
|
|
253
|
-
|
|
337
|
+
v-if="canReorder" v-tooltip="resolveI18n('Drag to reorder')" flat xs icon="drag_indicator"
|
|
338
|
+
class="grab"
|
|
254
339
|
/>
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
</template>
|
|
258
|
-
</Draggable>
|
|
259
|
-
</template>
|
|
260
|
-
<Draggable v-if="collapsible" :model-value="viewRows" handle=".grab" :disabled="!allowReorder" class="grid gap-05 mb-05" @end="onDraggableEnd">
|
|
261
|
-
<template #default="{ item: row }">
|
|
262
|
-
<div class="border radius-1 overflow-hidden">
|
|
263
|
-
<div class="grid gap-0 grid-array-line align-items-center pe-025 hover">
|
|
264
|
-
<Btn
|
|
265
|
-
v-if="allowReorder" v-tooltip="resolveI18n('Drag to reorder')" flat thin icon="drag_indicator"
|
|
266
|
-
class="grab"
|
|
267
|
-
/>
|
|
268
|
-
<div v-else />
|
|
269
|
-
<Btn
|
|
270
|
-
full-width align-txt="start" class="px-025 bg-transparent color-inherit w-100p overflow-hidden" :ripple="false"
|
|
271
|
-
:icon="minimizedItems[row.index] ? 'expand_more' : 'expand_less'" @click="toggleItem(row.index)"
|
|
272
|
-
>
|
|
273
|
-
<div class="flex align-items-center gap-05 w-100p overflow-hidden">
|
|
274
|
-
<img
|
|
275
|
-
v-if="getItemThumbnail(row.item)"
|
|
276
|
-
:src="pathKeyToURL(getItemThumbnail(row.item)!)"
|
|
277
|
-
class="array-item-thumb"
|
|
278
|
-
@error="($event.target as HTMLImageElement).style.display = 'none'"
|
|
279
|
-
>
|
|
280
|
-
<p class="ellipsis-1">
|
|
281
|
-
{{ getItemLabel(row) }}
|
|
340
|
+
<p class="ellipsis-1 txt12 line-height-1">
|
|
341
|
+
{{ getItemIdentifier(row.item) ?? getItemLabel(row) }}
|
|
282
342
|
</p>
|
|
283
343
|
</div>
|
|
284
|
-
</
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
344
|
+
</template>
|
|
345
|
+
</Draggable>
|
|
346
|
+
|
|
347
|
+
<Draggable
|
|
348
|
+
v-else-if="!collapsible" key="flat" :model-value="viewRows" handle=".grab"
|
|
349
|
+
:disabled="!canReorder" class="array-input-list grid"
|
|
350
|
+
:class="{
|
|
351
|
+
'mb-05': !hasListShell,
|
|
352
|
+
'gap-05': !isSimple || separated,
|
|
353
|
+
'gap-025': isSimple && !separated && hasListShell,
|
|
354
|
+
}"
|
|
355
|
+
@end="onDraggableEnd"
|
|
356
|
+
>
|
|
357
|
+
<template #default="{ item: row }">
|
|
358
|
+
<div
|
|
359
|
+
class="array-input-row grid align-items-center"
|
|
360
|
+
:class="{
|
|
361
|
+
'array-input-row-reorder': canReorder,
|
|
362
|
+
'array-input-row-numbered': showRowNumbers && isSimple,
|
|
363
|
+
'array-input-row-separated': separated,
|
|
364
|
+
'simpleArray mb-025': isSimple && !separated && !hasListShell,
|
|
365
|
+
'pb-1': !isSimple && !separated && !hasListShell,
|
|
366
|
+
simpleArray: isSimple && (separated || hasListShell),
|
|
367
|
+
}"
|
|
368
|
+
>
|
|
369
|
+
<Btn
|
|
370
|
+
v-if="canReorder" v-tooltip="resolveI18n('Drag to reorder')" flat thin icon="drag_indicator"
|
|
371
|
+
class="grab"
|
|
372
|
+
/>
|
|
373
|
+
<span v-if="showRowNumbers && isSimple" class="array-row-number txt12 opacity-5" aria-hidden="true">
|
|
374
|
+
{{ row.index + 1 }}.
|
|
375
|
+
</span>
|
|
376
|
+
<div class="array-input-row-body min-w-0 w-100p">
|
|
377
|
+
<p v-if="showRowNumbers && !isSimple" class="array-row-label txt12 opacity-5 mb-025 line-height-1">
|
|
378
|
+
{{ getRowNumberLabel(row) }}
|
|
379
|
+
</p>
|
|
380
|
+
<slot :item="getItemRef(row.index)" :index="row.index" />
|
|
381
|
+
</div>
|
|
382
|
+
<div v-if="canDelete" class="h-100p" :class="{ 'border-start ps-025 ms-075': !simple }">
|
|
383
|
+
<Btn
|
|
384
|
+
v-tooltip="resolveI18n(deleteTooltip || 'Delete')" flat icon="delete"
|
|
385
|
+
@click="deleteItem(row.index)"
|
|
386
|
+
/>
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
</template>
|
|
390
|
+
</Draggable>
|
|
391
|
+
|
|
392
|
+
<Draggable
|
|
393
|
+
v-else key="collapsible" :model-value="viewRows" handle=".grab" :disabled="!canReorder"
|
|
394
|
+
class="array-input-list grid gap-05" :class="{ 'mb-05': !hasListShell }" @end="onDraggableEnd"
|
|
395
|
+
>
|
|
396
|
+
<template #default="{ item: row }">
|
|
397
|
+
<div class="border radius-1 overflow-hidden">
|
|
398
|
+
<div class="grid gap-0 grid-array-line align-items-center pe-025 hover">
|
|
399
|
+
<Btn
|
|
400
|
+
v-if="canReorder" v-tooltip="resolveI18n('Drag to reorder')" flat thin icon="drag_indicator"
|
|
401
|
+
class="grab"
|
|
402
|
+
/>
|
|
403
|
+
<div v-else />
|
|
404
|
+
<Btn
|
|
405
|
+
full-width align-txt="start" class="px-025 bg-transparent color-inherit w-100p overflow-hidden" :ripple="false"
|
|
406
|
+
:icon="minimizedItems[row.index] ? 'expand_more' : 'expand_less'" @click="toggleItem(row.index)"
|
|
407
|
+
>
|
|
408
|
+
<div class="flex align-items-center gap-05 w-100p overflow-hidden">
|
|
409
|
+
<img
|
|
410
|
+
v-if="getItemThumbnail(row.item)"
|
|
411
|
+
:src="pathKeyToURL(getItemThumbnail(row.item)!)"
|
|
412
|
+
class="array-item-thumb"
|
|
413
|
+
@error="($event.target as HTMLImageElement).style.display = 'none'"
|
|
414
|
+
>
|
|
415
|
+
<p class="ellipsis-1">
|
|
416
|
+
{{ getItemLabel(row) }}
|
|
417
|
+
</p>
|
|
418
|
+
</div>
|
|
419
|
+
</Btn>
|
|
420
|
+
<Btn v-if="canDelete" v-tooltip="resolveI18n(deleteTooltip || 'Delete')" flat icon="delete" thin :confirm="resolveI18n('Are you sure you want to delete this item?')" @click="deleteItem(row.index)" icon-size="0.8" />
|
|
421
|
+
</div>
|
|
422
|
+
<Transition name="array-collapse">
|
|
423
|
+
<div v-if="!minimizedItems[row.index]" class="array-input-row grid align-items-center px-05">
|
|
424
|
+
<slot :item="getItemRef(row.index)" :index="row.index" />
|
|
425
|
+
</div>
|
|
426
|
+
</Transition>
|
|
290
427
|
</div>
|
|
291
|
-
</
|
|
292
|
-
</
|
|
293
|
-
</
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
428
|
+
</template>
|
|
429
|
+
</Draggable>
|
|
430
|
+
</Transition>
|
|
431
|
+
|
|
432
|
+
<Btn
|
|
433
|
+
v-if="canAdd && sortOrder === 'oldest-first'"
|
|
434
|
+
class="radius-1 array-input-add" :class="{ 'mt-025': hasListShell }" thin icon="add"
|
|
435
|
+
:value="addLabel" @click="addItem"
|
|
436
|
+
/>
|
|
437
|
+
</div>
|
|
299
438
|
</div>
|
|
300
439
|
</template>
|
|
301
440
|
|
|
@@ -310,6 +449,27 @@ grid-template-columns: 1fr auto;
|
|
|
310
449
|
.array-input-row-reorder {
|
|
311
450
|
grid-template-columns: auto 1fr auto;
|
|
312
451
|
}
|
|
452
|
+
/* Side index (simple rows): number | content | delete */
|
|
453
|
+
.array-input-row-numbered {
|
|
454
|
+
grid-template-columns: auto 1fr auto;
|
|
455
|
+
}
|
|
456
|
+
.array-input-row-numbered.array-input-row-reorder {
|
|
457
|
+
grid-template-columns: auto auto 1fr auto;
|
|
458
|
+
}
|
|
459
|
+
.array-input-row-body {
|
|
460
|
+
min-width: 0;
|
|
461
|
+
}
|
|
462
|
+
.array-row-number {
|
|
463
|
+
flex-shrink: 0;
|
|
464
|
+
user-select: none;
|
|
465
|
+
padding-inline-end: 0.25rem;
|
|
466
|
+
}
|
|
467
|
+
.array-input-row-separated {
|
|
468
|
+
border: 1px solid var(--bgl-border-color);
|
|
469
|
+
border-radius: var(--bgl-input-border-radius);
|
|
470
|
+
padding: 0.5rem;
|
|
471
|
+
margin-bottom: 0;
|
|
472
|
+
}
|
|
313
473
|
|
|
314
474
|
.array-collapse-enter-active,
|
|
315
475
|
.array-collapse-leave-active {
|
|
@@ -367,4 +527,45 @@ object-fit: cover;
|
|
|
367
527
|
flex-shrink: 0;
|
|
368
528
|
}
|
|
369
529
|
|
|
530
|
+
/* Local shell border — never put `bgl-outline`/`frame` on the ArrayInput root, or
|
|
531
|
+
global rules like `.bagel-input.bgl-outline .tel-input` paint nested fields. */
|
|
532
|
+
.array-input-shell--outline,
|
|
533
|
+
.array-input-shell--frame {
|
|
534
|
+
outline: 1.5px solid var(--bgl-border-color);
|
|
535
|
+
outline-offset: -1px;
|
|
536
|
+
border-radius: var(--bgl-input-border-radius);
|
|
537
|
+
padding: 0.25rem;
|
|
538
|
+
height: fit-content;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/* Nested fields inherit `.bagel-input { margin-bottom: 0.5rem }` — only strip it
|
|
542
|
+
under a list shell so the outline hugs the last item. */
|
|
543
|
+
.array-input-shell .bagel-input,
|
|
544
|
+
.array-input-shell .array-input-row .bagel-input {
|
|
545
|
+
margin-bottom: 0;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
.array-input-shell--frame {
|
|
549
|
+
transition: outline-color 0.2s ease, box-shadow 0.2s ease;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.array-input-shell--frame:focus-within {
|
|
553
|
+
outline-color: var(--bgl-input-label-active-color, var(--bgl-primary));
|
|
554
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--bgl-input-label-active-color, var(--bgl-primary)) 12%, transparent);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/* Empty ↔ list content swap (Add button stays mounted above/below). */
|
|
558
|
+
.array-body-swap-enter-active,
|
|
559
|
+
.array-body-swap-leave-active {
|
|
560
|
+
transition: opacity 0.18s ease, transform 0.18s ease;
|
|
561
|
+
}
|
|
562
|
+
.array-body-swap-enter-from,
|
|
563
|
+
.array-body-swap-leave-to {
|
|
564
|
+
opacity: 0;
|
|
565
|
+
transform: translateY(4px);
|
|
566
|
+
}
|
|
567
|
+
.array-input-empty .bgl-empty--compact {
|
|
568
|
+
padding: 0.75rem 0.5rem;
|
|
569
|
+
}
|
|
570
|
+
|
|
370
571
|
</style>
|
|
@@ -135,12 +135,19 @@ watch(() => props.modelValue, value => {
|
|
|
135
135
|
<style scoped>
|
|
136
136
|
.code-editor-container {
|
|
137
137
|
margin-bottom: 0.5rem;
|
|
138
|
+
width: 100%;
|
|
139
|
+
max-width: 100%;
|
|
138
140
|
height: 100%;
|
|
141
|
+
min-width: 0;
|
|
139
142
|
min-height: 0;
|
|
143
|
+
/* Keep long unwrapped lines inside the host — don't let content widen the parent. */
|
|
144
|
+
overflow: hidden;
|
|
140
145
|
}
|
|
141
146
|
.code-editor-container > :deep(.structured-editor) {
|
|
142
147
|
flex: 1;
|
|
148
|
+
min-width: 0;
|
|
143
149
|
min-height: 0;
|
|
150
|
+
width: 100%;
|
|
144
151
|
}
|
|
145
152
|
/* Focus ring only while the CodeMirror surface is focused — not toolbar buttons (e.g. Copy). */
|
|
146
153
|
.code-editor-container:not(.frame):not(.bgl-outline):not(.terminal):not(.single-line) > :deep(.structured-editor:not(.toolbar-hover):has(.cm-focused) .structured-editor-host),
|
|
@@ -123,6 +123,8 @@ function extensions(): Extension[] {
|
|
|
123
123
|
EditorView.theme({
|
|
124
124
|
'&': {
|
|
125
125
|
height: '100%',
|
|
126
|
+
width: '100%',
|
|
127
|
+
maxWidth: '100%',
|
|
126
128
|
...(props.terminal ? { backgroundColor: 'transparent' } : {}),
|
|
127
129
|
},
|
|
128
130
|
'.cm-scroller': {
|
|
@@ -335,7 +337,9 @@ onBeforeUnmount(() => {
|
|
|
335
337
|
position: relative;
|
|
336
338
|
display: flex;
|
|
337
339
|
flex-direction: column;
|
|
340
|
+
width: 100%;
|
|
338
341
|
height: 100%;
|
|
342
|
+
min-width: 0;
|
|
339
343
|
min-height: 0;
|
|
340
344
|
max-height: var(--code-max-height, none);
|
|
341
345
|
overflow: hidden;
|
|
@@ -344,9 +348,17 @@ onBeforeUnmount(() => {
|
|
|
344
348
|
}
|
|
345
349
|
.structured-editor-host {
|
|
346
350
|
flex: 1;
|
|
351
|
+
min-width: 0;
|
|
347
352
|
min-height: 0;
|
|
353
|
+
width: 100%;
|
|
348
354
|
overflow: auto;
|
|
349
355
|
}
|
|
356
|
+
/* CodeMirror grows with long lines by default; pin it to the host width. */
|
|
357
|
+
.structured-editor-host :deep(.cm-editor) {
|
|
358
|
+
width: 100%;
|
|
359
|
+
max-width: 100%;
|
|
360
|
+
height: 100%;
|
|
361
|
+
}
|
|
350
362
|
/* Bar mode: chrome (label/language/actions) sits above; the code surface is the rounded input. */
|
|
351
363
|
.structured-editor:not(.toolbar-hover):not(.terminal):not(.single-line) .structured-editor-host {
|
|
352
364
|
border-radius: var(--code-border-radius, 0.25rem);
|
|
@@ -162,7 +162,8 @@ const sidebarStyles = computed(() => {
|
|
|
162
162
|
>
|
|
163
163
|
<div
|
|
164
164
|
:style="{
|
|
165
|
-
backgroundColor
|
|
165
|
+
/* `background` (not backgroundColor) so gradients via bgColor work */
|
|
166
|
+
background: props.bgColor,
|
|
166
167
|
color: props.textColor,
|
|
167
168
|
...(props.card && { borderRadius: 'var(--bgl-card-border-radius)' }),
|
|
168
169
|
}" :class="{
|
|
@@ -218,7 +219,7 @@ const sidebarStyles = computed(() => {
|
|
|
218
219
|
v-for="link in props.footerLinks" :key="link.to || link.label"
|
|
219
220
|
:title="!isOpen && !isMobile ? resolveI18n(link.label) : ''"
|
|
220
221
|
:style="{
|
|
221
|
-
|
|
222
|
+
background: isActiveRoute(link) ? props.activeColor : 'transparent',
|
|
222
223
|
color: isActiveRoute(link) ? 'white' : props.textColor,
|
|
223
224
|
}"
|
|
224
225
|
fullWidth alignTxt="start" class="sidebar-link-btn flex-shrink-0 px-075" :class="[link.class, { 'nav-btn-active': isActiveRoute(link) }]"
|
|
@@ -68,7 +68,7 @@ function onParentClick() {
|
|
|
68
68
|
fullWidth alignTxt="start" class="sidebar-link-btn flex-shrink-0 px-075"
|
|
69
69
|
:class="[link.class, { 'nav-btn-active': selfActive }]"
|
|
70
70
|
:style="{
|
|
71
|
-
|
|
71
|
+
background: selfActive ? activeColor : 'transparent',
|
|
72
72
|
color: selfActive ? 'white' : textColor,
|
|
73
73
|
}"
|
|
74
74
|
:to="link.to || undefined" @click="link.action"
|
|
@@ -96,8 +96,8 @@ function onParentClick() {
|
|
|
96
96
|
'nav-btn-active': !open && !isMobile && isActive,
|
|
97
97
|
}"
|
|
98
98
|
:style="{
|
|
99
|
-
|
|
100
|
-
? (isActive ? activeColor :
|
|
99
|
+
background: !open && !isMobile
|
|
100
|
+
? (isActive ? activeColor : 'transparent')
|
|
101
101
|
: undefined,
|
|
102
102
|
color: isActive
|
|
103
103
|
? (!open && !isMobile ? 'white' : activeColor)
|
|
@@ -42,6 +42,8 @@ export interface Props<T extends Record<string, any> = Record<string, any>> {
|
|
|
42
42
|
errors?: Record<string, string>
|
|
43
43
|
/** Async submit handler — FormFlow awaits it and manages formState. */
|
|
44
44
|
onSubmit?: (data: T) => Promise<void> | void
|
|
45
|
+
/** Disable every field. Nested array rows inherit this. */
|
|
46
|
+
disabled?: boolean
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
type FormFlowSlots<T> = {
|
|
@@ -419,6 +421,10 @@ const mergedErrors = computed(() => {
|
|
|
419
421
|
return resolved
|
|
420
422
|
})
|
|
421
423
|
|
|
424
|
+
function fieldLocked(field: FieldBuilder): boolean {
|
|
425
|
+
return Boolean(props.disabled || field._config.disabled || field._config.readonly)
|
|
426
|
+
}
|
|
427
|
+
|
|
422
428
|
function getFieldProps(field: FieldBuilder, key: string) {
|
|
423
429
|
const label = generateLabel(key, field)
|
|
424
430
|
const { helpText, ...configRest } = field._config
|
|
@@ -476,6 +482,11 @@ function getFieldProps(field: FieldBuilder, key: string) {
|
|
|
476
482
|
baseProps.language = baseProps.language ?? 'json'
|
|
477
483
|
}
|
|
478
484
|
|
|
485
|
+
if (props.disabled) {
|
|
486
|
+
baseProps.disabled = true
|
|
487
|
+
baseProps.readonly = true
|
|
488
|
+
}
|
|
489
|
+
|
|
479
490
|
if (field._type === 'array') {
|
|
480
491
|
// `default` / `schema` are form-schema metadata — never pass them through to ArrayInput
|
|
481
492
|
// (and the earlier config spread may have already set them).
|
|
@@ -493,6 +504,10 @@ function getFieldProps(field: FieldBuilder, key: string) {
|
|
|
493
504
|
baseProps['onUpdate:modelValue'] = (val: any) => { updateField(key, val, field) }
|
|
494
505
|
baseProps.allowAdd = baseProps.allowAdd ?? true
|
|
495
506
|
baseProps.allowDelete = baseProps.allowDelete ?? true
|
|
507
|
+
if (props.disabled) {
|
|
508
|
+
baseProps.disabled = true
|
|
509
|
+
baseProps.readonly = true
|
|
510
|
+
}
|
|
496
511
|
}
|
|
497
512
|
return baseProps
|
|
498
513
|
}
|
|
@@ -651,14 +666,21 @@ defineExpose({
|
|
|
651
666
|
>
|
|
652
667
|
<!-- Array field with nested schema -->
|
|
653
668
|
<template v-if="field._type === 'array' && field._config.schema?._isSchema">
|
|
654
|
-
<!--
|
|
655
|
-
|
|
669
|
+
<!-- Nested FormFlow defaults to simple=false (keep inner field labels),
|
|
670
|
+
but honor an explicit schema `simple: true` for single-field rows
|
|
671
|
+
(e.g. emails/phones) that should render as one compact line. -->
|
|
672
|
+
<ArrayInput
|
|
673
|
+
v-bind="getFieldProps(field, key)"
|
|
674
|
+
:simple="field._config.simple ?? false"
|
|
675
|
+
:create-item="() => createArrayItem(field)"
|
|
676
|
+
>
|
|
656
677
|
<template #default="{ item }">
|
|
657
678
|
<!-- @vue-ignore -->
|
|
658
679
|
<FormFlow
|
|
659
680
|
:model-value="(item.value as any)"
|
|
660
681
|
:schema="(field._config.schema as any)"
|
|
661
682
|
:components="components"
|
|
683
|
+
:disabled="fieldLocked(field)"
|
|
662
684
|
@update:model-value="(val: any) => { item.value = val }"
|
|
663
685
|
/>
|
|
664
686
|
</template>
|
|
@@ -672,6 +694,7 @@ defineExpose({
|
|
|
672
694
|
<component
|
|
673
695
|
:is="getFieldComponent(field._config.schema as string)"
|
|
674
696
|
:model-value="(item.value as string | number | undefined)"
|
|
697
|
+
:disabled="fieldLocked(field)"
|
|
675
698
|
@update:model-value="(val: any) => { item.value = val }"
|
|
676
699
|
/>
|
|
677
700
|
</template>
|
|
@@ -682,7 +705,11 @@ defineExpose({
|
|
|
682
705
|
<template v-else-if="field._type === 'array' && field._config.schema">
|
|
683
706
|
<ArrayInput v-bind="getFieldProps(field, key)" :create-item="() => createArrayItem(field)">
|
|
684
707
|
<template #default="{ item }">
|
|
685
|
-
<component
|
|
708
|
+
<component
|
|
709
|
+
:is="resolveComponent(field._config.schema)"
|
|
710
|
+
v-model="item.value"
|
|
711
|
+
:disabled="fieldLocked(field)"
|
|
712
|
+
/>
|
|
686
713
|
</template>
|
|
687
714
|
</ArrayInput>
|
|
688
715
|
</template>
|
|
@@ -694,6 +721,7 @@ defineExpose({
|
|
|
694
721
|
<component
|
|
695
722
|
:is="getFieldComponent(field._config.itemType)"
|
|
696
723
|
:model-value="(item.value as string | number | undefined)"
|
|
724
|
+
:disabled="fieldLocked(field)"
|
|
697
725
|
@update:model-value="(val: any) => { item.value = val }"
|
|
698
726
|
/>
|
|
699
727
|
</template>
|