@bagelink/vue 1.20.17 → 1.20.19
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/form/inputs/ArrayInput.vue.d.ts +7 -0
- package/dist/components/form/inputs/ArrayInput.vue.d.ts.map +1 -1
- package/dist/components/layout/TabsNav.vue.d.ts.map +1 -1
- package/dist/core.css +1 -1
- package/dist/form-flow/form-flow.d.ts +5 -0
- package/dist/form-flow/form-flow.d.ts.map +1 -1
- package/dist/index.cjs +38 -38
- package/dist/index.css +1 -1
- package/dist/index.mjs +5950 -5907
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/components/form/inputs/ArrayInput.vue +68 -32
- package/src/components/layout/TabsNav.vue +103 -20
- package/src/form-flow/form-flow.ts +6 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.20.
|
|
4
|
+
"version": "1.20.19",
|
|
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.43",
|
|
65
65
|
"vue-component-type-helpers": "^2.2.12",
|
|
66
|
-
"@bagelink/sdk": "1.20.
|
|
66
|
+
"@bagelink/sdk": "1.20.19"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@bagelink/sdk": "*",
|
|
@@ -10,7 +10,7 @@ import Draggable from '../../draggable/Draggable.vue'
|
|
|
10
10
|
import type { BagelInputShellProps } from './bagelInputShell'
|
|
11
11
|
import { useBagelInputShell } from './bagelInputShell'
|
|
12
12
|
|
|
13
|
-
const props = defineProps<{
|
|
13
|
+
const props = withDefaults(defineProps<{
|
|
14
14
|
label?: string
|
|
15
15
|
helptext?: string
|
|
16
16
|
modelValue: T[]
|
|
@@ -26,7 +26,16 @@ const props = defineProps<{
|
|
|
26
26
|
reorderOnly?: boolean
|
|
27
27
|
/** Factory for new rows. Prefer this over pushing `undefined` (which becomes `null` after JSON sync). */
|
|
28
28
|
createItem?: () => T
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Visual order of the rows. The model array is never re-sorted.
|
|
31
|
+
* `newest-first` (default): renders the array back-to-front, so the last element
|
|
32
|
+
* (the newest one) appears at the top, and the Add button sits above the list.
|
|
33
|
+
* `oldest-first`: renders in array order, with the Add button below the list.
|
|
34
|
+
*/
|
|
35
|
+
sortOrder?: 'newest-first' | 'oldest-first'
|
|
36
|
+
} & BagelInputShellProps>(), {
|
|
37
|
+
sortOrder: 'newest-first',
|
|
38
|
+
})
|
|
30
39
|
|
|
31
40
|
const { shellClass, shellStyle } = useBagelInputShell(props)
|
|
32
41
|
|
|
@@ -83,11 +92,28 @@ function getItemThumbnail(item: T): string | null {
|
|
|
83
92
|
return null
|
|
84
93
|
}
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
interface ViewRow {
|
|
96
|
+
item: T
|
|
97
|
+
/** Index of the item in the model array (not the rendered position). */
|
|
98
|
+
index: number
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const isNewestFirst = computed(() => props.sortOrder === 'newest-first')
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Rows in visual order. `newest-first` keeps the model array untouched and only
|
|
105
|
+
* renders it back-to-front, so the last array element (the newest one) shows on top.
|
|
106
|
+
*/
|
|
107
|
+
const viewRows = computed<ViewRow[]>(() => {
|
|
108
|
+
const rows = items.value.map((item, index) => ({ item, index }))
|
|
109
|
+
return isNewestFirst.value ? rows.reverse() : rows
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
function getItemLabel(row: ViewRow, position: number) {
|
|
113
|
+
const identifier = getItemIdentifier(row.item)
|
|
88
114
|
return identifier != null
|
|
89
|
-
? `${
|
|
90
|
-
: `${itemLabelPrefix.value} ${
|
|
115
|
+
? `${position + 1}. ${identifier}`
|
|
116
|
+
: `${itemLabelPrefix.value} ${position + 1}`
|
|
91
117
|
}
|
|
92
118
|
|
|
93
119
|
watch(
|
|
@@ -104,6 +130,8 @@ watch(
|
|
|
104
130
|
|
|
105
131
|
function addItem() {
|
|
106
132
|
const next = props.createItem ? props.createItem() : ({} as T)
|
|
133
|
+
// Always append: the model keeps chronological order and `newest-first`
|
|
134
|
+
// simply renders the last element on top.
|
|
107
135
|
items.value.push(next)
|
|
108
136
|
// Open the new row so nested FormFlow mounts and the user can edit immediately.
|
|
109
137
|
minimizedItems.value.push(false)
|
|
@@ -120,20 +148,21 @@ function toggleItem(i: number) {
|
|
|
120
148
|
minimizedItems.value[i] = !minimizedItems.value[i]
|
|
121
149
|
}
|
|
122
150
|
|
|
123
|
-
function
|
|
124
|
-
|
|
151
|
+
function onDraggableEnd(event: DraggableEvent) {
|
|
152
|
+
const { oldIndex, newIndex } = event
|
|
153
|
+
if (newIndex < 0 || newIndex >= viewRows.value.length || oldIndex === newIndex) {
|
|
125
154
|
return
|
|
126
155
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
156
|
+
const reorderedRows = reorderItems(viewRows.value, oldIndex, newIndex) as ViewRow[]
|
|
157
|
+
// Map the visual order back to model order so the array stays untouched
|
|
158
|
+
// except for the actual move.
|
|
159
|
+
const modelOrder = isNewestFirst.value ? [...reorderedRows].reverse() : reorderedRows
|
|
160
|
+
const prevMinimized = minimizedItems.value
|
|
161
|
+
items.value = modelOrder.map(row => row.item)
|
|
162
|
+
minimizedItems.value = modelOrder.map(row => prevMinimized[row.index] ?? true)
|
|
130
163
|
updateModel()
|
|
131
164
|
}
|
|
132
165
|
|
|
133
|
-
function onDraggableEnd(event: DraggableEvent) {
|
|
134
|
-
moveItem(event.oldIndex, event.newIndex)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
166
|
function updateModel() {
|
|
138
167
|
emit('update:modelValue', [...items.value])
|
|
139
168
|
}
|
|
@@ -172,40 +201,44 @@ function getItemRef(i: number) {
|
|
|
172
201
|
<p v-if="helptext" class="helptext">
|
|
173
202
|
{{ helptext }}
|
|
174
203
|
</p>
|
|
175
|
-
<
|
|
176
|
-
|
|
204
|
+
<Btn
|
|
205
|
+
v-if="allowAdd && sortOrder === 'newest-first'" class="radius-1 mb-05" thin icon="add"
|
|
206
|
+
:value="resolveI18n(addText || 'Add')" @click="addItem"
|
|
207
|
+
/>
|
|
208
|
+
<Draggable v-if="reorderOnly" :model-value="viewRows" handle=".grab" :disabled="!allowReorder" class="grid gap-05 mb-05" @end="onDraggableEnd">
|
|
209
|
+
<template #default="{ item: row, index: i }">
|
|
177
210
|
<div class="grid gap-0 grid-array-line-reorder align-items-center pe-025 border radius-1 overflow-hidden">
|
|
178
211
|
<Btn
|
|
179
212
|
v-if="allowReorder" v-tooltip="resolveI18n('Drag to reorder')" flat xs icon="drag_indicator"
|
|
180
213
|
class="grab"
|
|
181
214
|
/>
|
|
182
215
|
<p class="ellipsis-1 txt12 line-height-1">
|
|
183
|
-
{{ getItemIdentifier(
|
|
216
|
+
{{ getItemIdentifier(row.item) ?? getItemLabel(row, i) }}
|
|
184
217
|
</p>
|
|
185
218
|
</div>
|
|
186
219
|
</template>
|
|
187
220
|
</Draggable>
|
|
188
221
|
<template v-else-if="!collapsible">
|
|
189
|
-
<Draggable :model-value="
|
|
190
|
-
<template #default="{ index: i }">
|
|
222
|
+
<Draggable :model-value="viewRows" handle=".grab" :disabled="!allowReorder" class="grid gap-05 mb-05" @end="onDraggableEnd">
|
|
223
|
+
<template #default="{ item: row, index: i }">
|
|
191
224
|
<div class="array-input-row grid align-items-center" :class="{ 'array-input-row-reorder': allowReorder, 'simpleArray mb-025': isSimple, 'pb-1': !isSimple }">
|
|
192
225
|
<Btn
|
|
193
226
|
v-if="allowReorder" v-tooltip="resolveI18n('Drag to reorder')" flat thin icon="drag_indicator"
|
|
194
227
|
class="grab"
|
|
195
228
|
/>
|
|
196
|
-
<slot :item="getItemRef(
|
|
229
|
+
<slot :item="getItemRef(row.index)" :index="i" />
|
|
197
230
|
<div v-if="allowDelete" class="h-100p" :class="{ 'border-start ps-025 ms-075': !simple }">
|
|
198
231
|
<Btn
|
|
199
232
|
v-tooltip="resolveI18n(deleteTooltip || 'Delete')" flat icon="delete"
|
|
200
|
-
@click="deleteItem(
|
|
233
|
+
@click="deleteItem(row.index)"
|
|
201
234
|
/>
|
|
202
235
|
</div>
|
|
203
236
|
</div>
|
|
204
237
|
</template>
|
|
205
238
|
</Draggable>
|
|
206
239
|
</template>
|
|
207
|
-
<Draggable v-if="collapsible" :model-value="
|
|
208
|
-
<template #default="{ index: i }">
|
|
240
|
+
<Draggable v-if="collapsible" :model-value="viewRows" handle=".grab" :disabled="!allowReorder" class="grid gap-05 mb-05" @end="onDraggableEnd">
|
|
241
|
+
<template #default="{ item: row, index: i }">
|
|
209
242
|
<div class="border radius-1 overflow-hidden">
|
|
210
243
|
<div class="grid gap-0 grid-array-line align-items-center pe-025 hover">
|
|
211
244
|
<Btn
|
|
@@ -215,31 +248,34 @@ function getItemRef(i: number) {
|
|
|
215
248
|
<div v-else />
|
|
216
249
|
<Btn
|
|
217
250
|
full-width align-txt="start" class="px-025 bg-transparent color-inherit w-100p overflow-hidden" :ripple="false"
|
|
218
|
-
:icon="minimizedItems[
|
|
251
|
+
:icon="minimizedItems[row.index] ? 'expand_more' : 'expand_less'" @click="toggleItem(row.index)"
|
|
219
252
|
>
|
|
220
253
|
<div class="flex align-items-center gap-05 w-100p overflow-hidden">
|
|
221
254
|
<img
|
|
222
|
-
v-if="getItemThumbnail(
|
|
223
|
-
:src="pathKeyToURL(getItemThumbnail(
|
|
255
|
+
v-if="getItemThumbnail(row.item)"
|
|
256
|
+
:src="pathKeyToURL(getItemThumbnail(row.item)!)"
|
|
224
257
|
class="array-item-thumb"
|
|
225
258
|
@error="($event.target as HTMLImageElement).style.display = 'none'"
|
|
226
259
|
>
|
|
227
260
|
<p class="ellipsis-1">
|
|
228
|
-
{{ getItemLabel(i) }}
|
|
261
|
+
{{ getItemLabel(row, i) }}
|
|
229
262
|
</p>
|
|
230
263
|
</div>
|
|
231
264
|
</Btn>
|
|
232
|
-
<Btn v-if="allowDelete" v-tooltip="resolveI18n(deleteTooltip || 'Delete')" flat icon="delete" thin :confirm="resolveI18n('Are you sure you want to delete this item?')" @click="deleteItem(
|
|
265
|
+
<Btn v-if="allowDelete" 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" />
|
|
233
266
|
</div>
|
|
234
267
|
<Transition name="array-collapse">
|
|
235
|
-
<div v-if="!minimizedItems[
|
|
236
|
-
<slot :item="getItemRef(
|
|
268
|
+
<div v-if="!minimizedItems[row.index]" class="array-input-row grid align-items-center px-05">
|
|
269
|
+
<slot :item="getItemRef(row.index)" :index="i" />
|
|
237
270
|
</div>
|
|
238
271
|
</Transition>
|
|
239
272
|
</div>
|
|
240
273
|
</template>
|
|
241
274
|
</Draggable>
|
|
242
|
-
<Btn
|
|
275
|
+
<Btn
|
|
276
|
+
v-if="allowAdd && sortOrder === 'oldest-first'" class="radius-1" thin icon="add"
|
|
277
|
+
:value="resolveI18n(addText || 'Add')" @click="addItem"
|
|
278
|
+
/>
|
|
243
279
|
</div>
|
|
244
280
|
</template>
|
|
245
281
|
|
|
@@ -41,18 +41,80 @@ const tabsWrap = ref<HTMLElement | undefined>(undefined)
|
|
|
41
41
|
const tabEls = ref<HTMLElement[]>([])
|
|
42
42
|
|
|
43
43
|
let resizeObserver: ResizeObserver | undefined
|
|
44
|
+
let indicatorPlaced = false
|
|
45
|
+
const observedTabs = new Set<HTMLElement>()
|
|
46
|
+
|
|
47
|
+
/** Keep the observer on the current tabs only (`tabs` can change on the fly). */
|
|
48
|
+
function observeTabs(tabs: HTMLElement[]) {
|
|
49
|
+
if (!resizeObserver) { return }
|
|
50
|
+
const next = new Set(tabs)
|
|
51
|
+
observedTabs.forEach((tab) => {
|
|
52
|
+
if (!next.has(tab)) {
|
|
53
|
+
resizeObserver?.unobserve(tab)
|
|
54
|
+
observedTabs.delete(tab)
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
next.forEach((tab) => {
|
|
58
|
+
if (!observedTabs.has(tab)) {
|
|
59
|
+
resizeObserver?.observe(tab)
|
|
60
|
+
observedTabs.add(tab)
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
}
|
|
44
64
|
|
|
45
|
-
/**
|
|
46
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Geometry of the active tab in the wrapper's layout space.
|
|
67
|
+
*
|
|
68
|
+
* Uses offsetLeft/offsetWidth on purpose: getBoundingClientRect is multiplied by
|
|
69
|
+
* every ancestor transform / zoom (enter animations, scaled panels or previews),
|
|
70
|
+
* which placed and sized the pill wrong — the error grows with the tab's offset,
|
|
71
|
+
* so the first tab looked fine while any later tab did not. offset* is also
|
|
72
|
+
* scroll-independent, and the ::before scrolls with the wrapper content anyway.
|
|
73
|
+
*/
|
|
74
|
+
function measureActiveTab(wrap: HTMLElement, activeTab: HTMLElement) {
|
|
75
|
+
const width = activeTab.offsetWidth
|
|
76
|
+
if (!width) { return undefined }
|
|
77
|
+
|
|
78
|
+
// offsetLeft is relative to the wrapper's padding box — the same origin the
|
|
79
|
+
// absolutely positioned ::before uses for `left`.
|
|
80
|
+
if (activeTab.offsetParent === wrap) {
|
|
81
|
+
return { left: activeTab.offsetLeft, width }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Unexpected offsetParent (custom markup): fall back to rect math, scaled back
|
|
85
|
+
// into layout pixels so ancestor transforms / zoom still cancel out.
|
|
47
86
|
const wrapRect = wrap.getBoundingClientRect()
|
|
48
87
|
const tabRect = activeTab.getBoundingClientRect()
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
88
|
+
const scale = tabRect.width ? width / tabRect.width : 1
|
|
89
|
+
const left = (tabRect.left - wrapRect.left) / scale + wrap.scrollLeft - wrap.clientLeft
|
|
90
|
+
return { left, width }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function placeIndicator(wrap: HTMLElement, left: number, width: number) {
|
|
94
|
+
if (!indicatorPlaced) {
|
|
95
|
+
// First placement must not animate in from the wrapper's left edge when a
|
|
96
|
+
// non-first tab is already active on open.
|
|
97
|
+
indicatorPlaced = true
|
|
98
|
+
wrap.classList.add('bgl_tabs-indicator-snap')
|
|
99
|
+
requestAnimationFrame(() => wrap.classList.remove('bgl_tabs-indicator-snap'))
|
|
55
100
|
}
|
|
101
|
+
wrap.style.setProperty('--indicator-left', `${left}px`)
|
|
102
|
+
wrap.style.setProperty('--indicator-width', `${width}px`)
|
|
103
|
+
wrap.style.setProperty('--indicator-opacity', '1')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function applyIndicator(wrap: HTMLElement) {
|
|
107
|
+
tabEls.value = Array.from(wrap.querySelectorAll<HTMLElement>('.bgl_tab'))
|
|
108
|
+
observeTabs(tabEls.value)
|
|
109
|
+
|
|
110
|
+
const activeTab = tabEls.value.find(tab => tab.classList.contains('active'))
|
|
111
|
+
if (!activeTab) {
|
|
112
|
+
wrap.style.setProperty('--indicator-opacity', '0')
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const box = measureActiveTab(wrap, activeTab)
|
|
117
|
+
if (box) { placeIndicator(wrap, box.left, box.width) }
|
|
56
118
|
}
|
|
57
119
|
|
|
58
120
|
function updateIndicator() {
|
|
@@ -60,23 +122,26 @@ function updateIndicator() {
|
|
|
60
122
|
const wrap = tabsWrap.value
|
|
61
123
|
if (!wrap) { return }
|
|
62
124
|
|
|
63
|
-
const apply = () => {
|
|
64
|
-
tabEls.value = Array.from(wrap.querySelectorAll<HTMLElement>('.bgl_tab'))
|
|
65
|
-
const activeTab = tabEls.value.find(tab => tab.classList.contains('active'))
|
|
66
|
-
if (!activeTab) {
|
|
67
|
-
wrap.style.setProperty('--indicator-opacity', '0')
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
measureActiveTabIndicator(wrap, activeTab)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
125
|
// Double rAF: layout + media-query / font metrics often settle after one frame (e.g. mobile ↔ desktop).
|
|
74
126
|
requestAnimationFrame(() => {
|
|
75
|
-
requestAnimationFrame(
|
|
127
|
+
requestAnimationFrame(() => applyIndicator(wrap))
|
|
76
128
|
})
|
|
77
129
|
})
|
|
78
130
|
}
|
|
79
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Enter animations (dialog / panel scale, slide, ...) change the wrapper's visual
|
|
134
|
+
* box without resizing anything the ResizeObserver could see. Re-measure once an
|
|
135
|
+
* ancestor animation finishes; unrelated transitions are ignored.
|
|
136
|
+
*/
|
|
137
|
+
function handleMotionEnd(event: Event) {
|
|
138
|
+
const wrap = tabsWrap.value
|
|
139
|
+
const target = event.target
|
|
140
|
+
if (!wrap || !(target instanceof Element)) { return }
|
|
141
|
+
if (target === wrap || !target.contains(wrap)) { return }
|
|
142
|
+
updateIndicator()
|
|
143
|
+
}
|
|
144
|
+
|
|
80
145
|
function selectTab(tab: Tab) {
|
|
81
146
|
currentTab.value = typeof tab === 'string' ? tab : tab.value
|
|
82
147
|
emit('update:modelValue', currentTab.value)
|
|
@@ -119,9 +184,18 @@ onMounted(() => {
|
|
|
119
184
|
resizeObserver.observe(tabsWrap.value)
|
|
120
185
|
// The active tab can finish sizing after the wrapper (webfonts, a direct
|
|
121
186
|
// deep link). Wrapper observation misses that, so the indicator stays at 0.
|
|
122
|
-
|
|
187
|
+
observeTabs(tabEls.value)
|
|
123
188
|
}
|
|
124
189
|
|
|
190
|
+
// Webfonts can swap in without a ResizeObserver resize (metrics round the same).
|
|
191
|
+
if (typeof document !== 'undefined' && document.fonts) {
|
|
192
|
+
document.fonts.ready.then(() => updateIndicator()).catch(() => {})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Catch ancestor enter/exit animations that page/dialog wrappers run on open.
|
|
196
|
+
document.addEventListener('transitionend', handleMotionEnd, true)
|
|
197
|
+
document.addEventListener('animationend', handleMotionEnd, true)
|
|
198
|
+
|
|
125
199
|
if (typeof window !== 'undefined' && window.visualViewport) {
|
|
126
200
|
// Mobile browser chrome / zoom — window "resize" alone can miss this.
|
|
127
201
|
window.visualViewport.addEventListener('resize', updateIndicator)
|
|
@@ -139,8 +213,11 @@ watch(
|
|
|
139
213
|
onBeforeUnmount(() => {
|
|
140
214
|
window.removeEventListener('resize', updateIndicator)
|
|
141
215
|
tabsWrap.value?.removeEventListener('scroll', updateIndicator)
|
|
216
|
+
document.removeEventListener('transitionend', handleMotionEnd, true)
|
|
217
|
+
document.removeEventListener('animationend', handleMotionEnd, true)
|
|
142
218
|
resizeObserver?.disconnect()
|
|
143
219
|
resizeObserver = undefined
|
|
220
|
+
observedTabs.clear()
|
|
144
221
|
if (typeof window !== 'undefined' && window.visualViewport) {
|
|
145
222
|
window.visualViewport.removeEventListener('resize', updateIndicator)
|
|
146
223
|
}
|
|
@@ -260,6 +337,12 @@ z-index: 0;
|
|
|
260
337
|
opacity: var(--indicator-opacity, 0);
|
|
261
338
|
}
|
|
262
339
|
|
|
340
|
+
/* First placement (e.g. a non-first tab active on open) snaps into place instead
|
|
341
|
+
of sliding across the wrapper from its left edge. */
|
|
342
|
+
.bgl_tabs_wrap.bgl_tabs-indicator-snap::before {
|
|
343
|
+
transition: none;
|
|
344
|
+
}
|
|
345
|
+
|
|
263
346
|
.bgl_flat-tabs.bgl_tabs_wrap {
|
|
264
347
|
background: transparent;
|
|
265
348
|
box-shadow: none;
|
|
@@ -454,6 +454,8 @@ export const $ = {
|
|
|
454
454
|
max?: number
|
|
455
455
|
simple?: boolean
|
|
456
456
|
reorderOnly?: boolean
|
|
457
|
+
/** Row insertion order and Add button placement: 'newest-first' (default) or 'oldest-first'. */
|
|
458
|
+
sortOrder?: 'newest-first' | 'oldest-first'
|
|
457
459
|
}),
|
|
458
460
|
maybeConfig?: BaseFieldConfig & {
|
|
459
461
|
allowAdd?: boolean
|
|
@@ -464,6 +466,8 @@ export const $ = {
|
|
|
464
466
|
max?: number
|
|
465
467
|
simple?: boolean
|
|
466
468
|
reorderOnly?: boolean
|
|
469
|
+
/** Row insertion order and Add button placement: 'newest-first' (default) or 'oldest-first'. */
|
|
470
|
+
sortOrder?: 'newest-first' | 'oldest-first'
|
|
467
471
|
}
|
|
468
472
|
): FieldBuilder<any[]> {
|
|
469
473
|
// Label-first: $.array('Items', schema) or $.array('Items', schema, { min: 1 })
|
|
@@ -852,6 +856,7 @@ type JSONSchemaProperty = Omit<
|
|
|
852
856
|
hidden?: boolean
|
|
853
857
|
allowAdd?: boolean
|
|
854
858
|
allowDelete?: boolean
|
|
859
|
+
sortOrder?: 'newest-first' | 'oldest-first'
|
|
855
860
|
component?: string
|
|
856
861
|
componentProps?: Record<string, any>
|
|
857
862
|
radioAlign?: 'start' | 'center' | 'end'
|
|
@@ -1262,6 +1267,7 @@ function createFieldFromProperty(
|
|
|
1262
1267
|
const arrayConfig: Record<string, any> = { ...config }
|
|
1263
1268
|
if (xUi.allowAdd !== undefined) arrayConfig.allowAdd = xUi.allowAdd
|
|
1264
1269
|
if (xUi.allowDelete !== undefined) arrayConfig.allowDelete = xUi.allowDelete
|
|
1270
|
+
if (xUi.sortOrder !== undefined) arrayConfig.sortOrder = xUi.sortOrder
|
|
1265
1271
|
const itemSchema = resolvedProp.items?.type === 'object'
|
|
1266
1272
|
? fromJSONSchema(resolvedProp.items as JSONSchemaObject, { loadOptionsSource })
|
|
1267
1273
|
: undefined
|