@bagelink/vue 1.21.26 → 1.21.32
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-BQEjrMDP.js → StructuredEditor-78Df0ADI.js} +4 -2
- package/dist/{StructuredEditor-UdsxFbg_.cjs → StructuredEditor-MXkv4nok.cjs} +2 -2
- package/dist/StructuredEditor.css +1 -1
- package/dist/components/Card.vue.d.ts +4 -0
- package/dist/components/Card.vue.d.ts.map +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/Checkbox.vue.d.ts +13 -2
- package/dist/components/form/inputs/Checkbox.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/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-C0qYUY7s.js → src-CeEsGKN7.js} +10076 -9882
- package/dist/src-Duj4FrLr.cjs +764 -0
- package/dist/src.css +1 -1
- package/dist/style.css +2 -2
- package/package.json +2 -2
- package/src/components/Card.vue +32 -0
- package/src/components/form/inputs/ArrayInput.vue +274 -73
- package/src/components/form/inputs/Checkbox.vue +75 -22
- package/src/components/form/inputs/CodeEditor/Index.vue +7 -0
- package/src/components/form/inputs/CodeEditor/StructuredEditor.vue +12 -0
- 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-pIF2XEoP.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.32",
|
|
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.32"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@bagelink/sdk": "*",
|
package/src/components/Card.vue
CHANGED
|
@@ -24,6 +24,10 @@ const props = defineProps<{
|
|
|
24
24
|
`#bottom-end` is present. For full control of the header center, use the
|
|
25
25
|
`#header` slot instead of `title`. */
|
|
26
26
|
title?: string
|
|
27
|
+
/** Background for the header row. Tone name (`primary`, `primary-tint`,
|
|
28
|
+
`gray`) or any CSS color / `var(...)`. When set, the header paints
|
|
29
|
+
edge-to-edge (and under the top corners when there is no `label`). */
|
|
30
|
+
headerBg?: string
|
|
27
31
|
thin?: boolean
|
|
28
32
|
outline?: boolean
|
|
29
33
|
h100?: boolean
|
|
@@ -97,6 +101,19 @@ const hasHeader = computed<boolean>(() =>
|
|
|
97
101
|
const hasFooter = computed<boolean>(() =>
|
|
98
102
|
!!(slots.footer || slots['bottom-start'] || slots['bottom-end']),
|
|
99
103
|
)
|
|
104
|
+
|
|
105
|
+
/** Resolve a tone name (`primary-tint`) to `var(--bgl-…)`, pass through CSS colors. */
|
|
106
|
+
function resolveHeaderBg(color?: string) {
|
|
107
|
+
if (!color) { return undefined }
|
|
108
|
+
if (['transparent', 'inherit', 'currentColor'].includes(color)) { return color }
|
|
109
|
+
const tone = color.replace(/^--bgl-|^bgl-/, '')
|
|
110
|
+
return /^[a-z][a-z0-9-]*$/i.test(tone) ? `var(--bgl-${tone})` : color
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const headerStyle = computed(() => {
|
|
114
|
+
const bg = resolveHeaderBg(props.headerBg)
|
|
115
|
+
return bg ? { background: bg } : undefined
|
|
116
|
+
})
|
|
100
117
|
</script>
|
|
101
118
|
|
|
102
119
|
<template>
|
|
@@ -123,6 +140,8 @@ const hasFooter = computed<boolean>(() =>
|
|
|
123
140
|
<div
|
|
124
141
|
v-if="hasHeader"
|
|
125
142
|
class="card_header flex space-between align-items-center w-100p"
|
|
143
|
+
:class="{ 'card_header--bg': !!headerBg, 'card_header--bg-top': !!headerBg && !label }"
|
|
144
|
+
:style="headerStyle"
|
|
126
145
|
>
|
|
127
146
|
<span v-if="$slots['top-start']" class="card_header_start flex align-items-center gap-05">
|
|
128
147
|
<slot name="top-start" />
|
|
@@ -177,6 +196,18 @@ margin-bottom: calc(var(--bgl-card-pad) / 2);
|
|
|
177
196
|
border-bottom: 1px solid var(--bgl-border-color);
|
|
178
197
|
min-height: 0;
|
|
179
198
|
}
|
|
199
|
+
/* Colored header: bleed to the card's inline edges so the paint isn't inset. */
|
|
200
|
+
.card_header--bg {
|
|
201
|
+
margin-inline: calc(var(--bgl-card-pad) * -1);
|
|
202
|
+
padding-inline: var(--bgl-card-pad);
|
|
203
|
+
}
|
|
204
|
+
/* No label above — also bleed under the top corners. */
|
|
205
|
+
.card_header--bg-top {
|
|
206
|
+
margin-top: calc(var(--bgl-card-pad) * -1);
|
|
207
|
+
padding-top: calc(var(--bgl-card-pad) / 2);
|
|
208
|
+
border-start-start-radius: var(--bgl-card-border-radius);
|
|
209
|
+
border-start-end-radius: var(--bgl-card-border-radius);
|
|
210
|
+
}
|
|
180
211
|
.card_header_main {
|
|
181
212
|
text-align: start;
|
|
182
213
|
min-width: 0;
|
|
@@ -219,6 +250,7 @@ padding: var(--bgl-card-pad);
|
|
|
219
250
|
.bgl_card.p-0 .card_header {
|
|
220
251
|
margin-inline: 0; padding-inline: 1rem; padding-block: 0.75rem; margin-bottom: 0;
|
|
221
252
|
}
|
|
253
|
+
.bgl_card.p-0 .card_header--bg-top { margin-top: 0; }
|
|
222
254
|
.bgl_card.p-0 .card_footer {
|
|
223
255
|
margin-inline: 0; padding-inline: 1rem; padding-block: 0.75rem; margin-top: 0;
|
|
224
256
|
}
|
|
@@ -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>
|
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
defineOptions({ name: 'BglCheckbox' })
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(defineProps<{
|
|
6
|
+
/** Checked fill tone (`primary`, `green`) or any CSS color. */
|
|
7
|
+
color?: string
|
|
8
|
+
/** Squared corners instead of the default circle. */
|
|
9
|
+
square?: boolean
|
|
10
|
+
/** Inner mark when checked. `dot` keeps the current ring-fill look. */
|
|
11
|
+
indicator?: 'dot' | 'check'
|
|
12
|
+
}>(), {
|
|
13
|
+
color: 'primary',
|
|
14
|
+
indicator: 'dot',
|
|
15
|
+
})
|
|
16
|
+
|
|
3
17
|
const val = defineModel<boolean>('modelValue', { default: false })
|
|
18
|
+
|
|
19
|
+
function resolveColor(color: string) {
|
|
20
|
+
if (['transparent', 'inherit', 'currentColor'].includes(color)) { return color }
|
|
21
|
+
const tone = color.replace(/^--bgl-|^bgl-/, '')
|
|
22
|
+
return /^[a-z][a-z0-9-]*$/i.test(tone) ? `var(--bgl-${tone})` : color
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const rootStyle = computed(() => ({
|
|
26
|
+
'--bgl-checkbox-color': resolveColor(props.color),
|
|
27
|
+
}))
|
|
4
28
|
</script>
|
|
5
29
|
|
|
6
30
|
<template>
|
|
7
|
-
<label
|
|
31
|
+
<label
|
|
32
|
+
class="primary-checkbox"
|
|
33
|
+
:class="{
|
|
34
|
+
'primary-checkbox--square': square,
|
|
35
|
+
'primary-checkbox--check': indicator === 'check',
|
|
36
|
+
}"
|
|
37
|
+
:style="rootStyle"
|
|
38
|
+
>
|
|
8
39
|
<slot name="label" />
|
|
9
40
|
<input v-model="val" type="checkbox">
|
|
10
41
|
</label>
|
|
@@ -13,41 +44,63 @@ const val = defineModel<boolean>('modelValue', { default: false })
|
|
|
13
44
|
<style scoped>
|
|
14
45
|
|
|
15
46
|
.primary-checkbox input {
|
|
16
|
-
|
|
17
|
-
|
|
47
|
+
appearance: none;
|
|
48
|
+
accent-color: var(--bgl-checkbox-color, var(--bgl-primary));
|
|
18
49
|
height: calc(var(--bgl-input-height) / 1.75);
|
|
19
50
|
width: calc(var(--bgl-input-height) / 1.75);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
51
|
+
min-width: 0;
|
|
52
|
+
display: flex;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
align-items: center;
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
border-radius: 100%;
|
|
57
|
+
background: var(--bgl-box-bg);
|
|
58
|
+
border: 2px solid var(--bgl-gray);
|
|
59
|
+
transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.primary-checkbox--square input {
|
|
63
|
+
border-radius: 0.35rem;
|
|
28
64
|
}
|
|
29
65
|
|
|
30
66
|
.primary-checkbox {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
67
|
+
height: var(--bgl-input-height);
|
|
68
|
+
width: var(--bgl-input-height);
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
align-items: center;
|
|
72
|
+
transition: var(--bgl-transition);
|
|
73
|
+
transform: scale(0.8);
|
|
38
74
|
}
|
|
39
75
|
|
|
40
76
|
.primary-checkbox:hover {
|
|
41
|
-
|
|
77
|
+
filter: brightness(90%);
|
|
42
78
|
}
|
|
43
79
|
|
|
44
80
|
.primary-checkbox:active {
|
|
45
|
-
|
|
81
|
+
filter: brightness(80%);
|
|
46
82
|
}
|
|
47
83
|
|
|
84
|
+
/* Dot (default): solid fill + inset white ring. */
|
|
48
85
|
.primary-checkbox input:checked {
|
|
49
|
-
|
|
50
|
-
|
|
86
|
+
background: var(--bgl-checkbox-color, var(--bgl-primary));
|
|
87
|
+
border-color: var(--bgl-checkbox-color, var(--bgl-primary));
|
|
88
|
+
box-shadow: inset 0 0 0 2px white;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Check: solid fill + CSS checkmark, no ring. */
|
|
92
|
+
.primary-checkbox--check input:checked {
|
|
93
|
+
box-shadow: none;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.primary-checkbox--check input:checked::after {
|
|
97
|
+
content: "";
|
|
98
|
+
width: 28%;
|
|
99
|
+
height: 52%;
|
|
100
|
+
border: solid #fff;
|
|
101
|
+
border-width: 0 2px 2px 0;
|
|
102
|
+
transform: rotate(45deg) translate(-5%, -10%);
|
|
103
|
+
box-sizing: border-box;
|
|
51
104
|
}
|
|
52
105
|
|
|
53
106
|
</style>
|