Skip to content

Commit 49b4b57

Browse files
Merge branch 'master' into feat/json-schema
2 parents c71223e + 14114cc commit 49b4b57

File tree

5 files changed

+38
-26
lines changed

5 files changed

+38
-26
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [2.3.1](https://github.com/Draggable/formeo/compare/v2.3.0...v2.3.1) (2024-11-19)
2+
3+
4+
### Bug Fixes
5+
6+
* button options ([3075f1c](https://github.com/Draggable/formeo/commit/3075f1c330034b10d62ba4322ae23a82e68e4b13))
7+
* tab group animations ([399b74a](https://github.com/Draggable/formeo/commit/399b74a0ead36d559c0de36908cdad49f6abc577))
8+
19
# [2.3.0](https://github.com/Draggable/formeo/compare/v2.2.2...v2.3.0) (2024-11-15)
210

311

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "formeo",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"type": "module",
55
"main": "dist/formeo.cjs.js",
66
"module": "dist/formeo.es.js",

src/lib/js/components/fields/edit-panel.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,23 @@ export default class EditPanel {
161161
const metaId = this.field.data.meta.id
162162
const fieldOptionData = this.field.get('options')
163163
const type = metaId === 'select' ? 'option' : metaId
164-
const newOptionLabel = i18n.get(`newOptionLabel`, { type }) || 'New Option'
164+
const newOptionLabel = i18n.get('newOptionLabel', { type }) || 'New Option'
165165
const itemKey = `options.${this.data.length}`
166-
167-
const optionTemplate = fieldOptionData.length ? cleanObj(fieldOptionData[fieldOptionData.length - 1]) : {}
168-
const itemData = { ...optionTemplate, label: newOptionLabel, value: slugify(newOptionLabel) }
166+
167+
const lastOptionData = fieldOptionData[fieldOptionData.length - 1]
168+
const optionTemplate = fieldOptionData.length ? lastOptionData : {}
169+
const itemData = { ...optionTemplate, label: newOptionLabel }
170+
if (metaId !== 'button') {
171+
itemData.value = slugify(newOptionLabel)
172+
}
169173
const newOption = new EditPanelItem({
170174
key: itemKey,
171175
data: itemData,
172176
field: this.field,
173177
index: this.props.children.length,
174178
})
175-
179+
180+
// debugger
176181
this.editPanelItems.push(newOption)
177182
this.props.appendChild(newOption.dom)
178183
this.field.set(itemKey, itemData)

src/lib/js/components/panels.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,8 @@ export default class Panels {
142142
action: {
143143
click: evt => {
144144
const index = indexOfNode(evt.target, evt.target.parentElement)
145-
this.currentPanel = this.panels[index]
146-
const labels = evt.target.parentElement.childNodes
147-
this.nav.refresh(index)
148-
dom.removeClasses(labels, 'active-tab')
149-
evt.target.classList.add('active-tab')
145+
this.nav.setTranslateX(index, false)
146+
this.nav.groupChange(index)
150147
},
151148
},
152149
content: panel.config.label,
@@ -227,19 +224,21 @@ export default class Panels {
227224
const action = {}
228225
const groupParent = this.currentPanel.parentElement
229226
const labelWrap = this.labels.firstChild
227+
const panelTabs = labelWrap.children
230228
const siblingGroups = this.currentPanel.parentElement.childNodes
231229
this.activePanelIndex = indexOfNode(this.currentPanel, groupParent)
232230
let offset = { nav: 0, panel: 0 }
233231
let lastOffset = { ...offset }
234232

235233
action.groupChange = newIndex => {
236-
const labels = labelWrap.children
237-
dom.removeClasses(siblingGroups, 'active-panel')
238-
dom.removeClasses(labels, 'active-tab')
234+
this.activePanelIndex = newIndex
239235
this.currentPanel = siblingGroups[newIndex]
240-
this.currentPanel.classList.add('active-panel')
241236

242-
labels[newIndex].classList.add('active-tab')
237+
dom.removeClasses(siblingGroups, 'active-panel')
238+
dom.removeClasses(panelTabs, 'active-tab')
239+
240+
this.currentPanel.classList.add('active-panel')
241+
panelTabs[newIndex].classList.add('active-tab')
243242

244243
return this.currentPanel
245244
}
@@ -278,6 +277,7 @@ export default class Panels {
278277
lastOffset = offset
279278
}
280279
}
280+
281281
panelTransition.addEventListener('finish', handleFinish)
282282
}
283283

@@ -288,10 +288,9 @@ export default class Panels {
288288

289289
action.refresh = (newIndex = this.activePanelIndex) => {
290290
if (this.activePanelIndex !== newIndex) {
291-
this.activePanelIndex = newIndex
292291
action.groupChange(newIndex)
293292
}
294-
action.setTranslateX(this.activePanelIndex)
293+
action.setTranslateX(this.activePanelIndex, false)
295294
this.resizePanels()
296295
}
297296

@@ -302,13 +301,13 @@ export default class Panels {
302301
action.nextGroup = () => {
303302
const newIndex = this.activePanelIndex + 1
304303
if (newIndex !== siblingGroups.length) {
305-
const curPanel = action.groupChange(newIndex)
304+
const nextPanel = siblingGroups[newIndex]
306305
offset = {
307306
nav: -labelWrap.offsetWidth * newIndex,
308-
panel: -curPanel.offsetLeft,
307+
panel: -nextPanel.offsetLeft,
309308
}
310309
translateX({ offset })
311-
this.activePanelIndex++
310+
action.groupChange(newIndex)
312311
} else {
313312
offset = {
314313
nav: lastOffset.nav - 8,
@@ -323,13 +322,13 @@ export default class Panels {
323322
action.prevGroup = () => {
324323
if (this.activePanelIndex !== 0) {
325324
const newIndex = this.activePanelIndex - 1
326-
const curPanel = action.groupChange(newIndex)
325+
const prevPanel = siblingGroups[newIndex]
327326
offset = {
328327
nav: -labelWrap.offsetWidth * newIndex,
329-
panel: -curPanel.offsetLeft,
328+
panel: -prevPanel.offsetLeft,
330329
}
331330
translateX({ offset })
332-
this.activePanelIndex--
331+
action.groupChange(newIndex)
333332
} else {
334333
offset = {
335334
nav: 8,

0 commit comments

Comments
 (0)