waibu-bootstrap 2.12.0 → 2.12.1

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.
@@ -19,11 +19,13 @@ async function getInputAttr (group, formControl = true, ro) {
19
19
  if (has(attr, 'name') && !has(attr, 'value')) {
20
20
  if (ro) attr.value = this.formData[attr.name]
21
21
  else {
22
- const prop = this.getProp(attr.name)
22
+ const prop = this.getProp(attr.name) ?? {}
23
23
  attr.dataType = attr.dataType ?? prop.type
24
24
  attr.dataValue = this.formData[attr.name]
25
25
  if (prop.values) {
26
- attr.options = (isString(prop.values) ? await callHandler(prop.values) : [...prop.values]).map(v => buildOptions(v, prop))
26
+ if (this.model) attr.options = await this.model.buildPropValues(prop, { req })
27
+ else attr.options = (isString(prop.values) ? await callHandler(prop.values) : [...prop.values]).map(v => buildOptions(v, prop))
28
+ attr.options = attr.options.map(v => buildOptions(v, prop))
27
29
  } else if (isPlainObject(attr.dataValue)) {
28
30
  attr.dataValue = JSON.stringify(attr.dataValue)
29
31
  attr.value = attr.dataValue
@@ -2,7 +2,7 @@ import { buildFormHint, buildFormLabel, buildFormInput } from './_lib.js'
2
2
  import { sizes } from '../method/after-build-tag/_lib.js'
3
3
 
4
4
  export async function handleInput ({ handler, group } = {}) {
5
- const { trim, filter, has, omit, pull, find, get } = this.app.lib._
5
+ const { trim, filter, has, omit, pull, find, get, isEmpty } = this.app.lib._
6
6
  const { attrToArray } = this.app.waibu
7
7
  const { $ } = this.component
8
8
  const addons = [...(this.params.addons ?? [])]
@@ -13,6 +13,14 @@ export async function handleInput ({ handler, group } = {}) {
13
13
  group._.placeholder = group._.label
14
14
  group._ = omit(group._, ['rows'])
15
15
  }
16
+ let errMsg = ''
17
+ if (group._.name) {
18
+ const details = get(this, 'component.locals.error.details', [])
19
+ const err = find(details, { field: group._.name })
20
+ if (err) {
21
+ errMsg = `\n<div class="invalid-feedback d-block">${err.error}</div>`
22
+ }
23
+ }
16
24
  $(`<div>${trim(this.params.html ?? '')}</div>`).find('[addon]').each(function () {
17
25
  const position = this.attribs.addon
18
26
  let html = trim($(this).html())
@@ -25,14 +33,7 @@ export async function handleInput ({ handler, group } = {}) {
25
33
  append: [],
26
34
  input: await handler.call(this, group)
27
35
  }
28
- if (group._.name) {
29
- const details = get(this, 'component.locals.error.details', [])
30
- const err = find(details, { field: group._.name })
31
- if (err) {
32
- result.input = $(result.input).addClass('is-invalid').prop('outerHTML')
33
- result.input += `\n<div class="invalid-feedback">${err.error}</div>`
34
- }
35
- }
36
+ if (!isEmpty(errMsg)) result.input = $(result.input).addClass('is-invalid').prop('outerHTML')
36
37
  const el = {
37
38
  prepend: filter(addons, { position: 'prepend' }),
38
39
  append: filter(addons, { position: 'append' })
@@ -62,6 +63,7 @@ export async function handleInput ({ handler, group } = {}) {
62
63
  if (isLabelFloating) {
63
64
  pull(group.wrapper.class, 'form-floating')
64
65
  group.wrapper.class.push('input-group')
66
+ if (!isEmpty(errMsg)) group.wrapper.class.push('has-validation')
65
67
  if (group._.size && sizes.includes(group._.size)) group.wrapper.class.push(`input-group-${group._.size}`)
66
68
  const _attr = { class: ['form-floating'] }
67
69
  const html = []
@@ -69,15 +71,18 @@ export async function handleInput ({ handler, group } = {}) {
69
71
  if (result.prepend.length > 0) html.push(result.prepend.join('\n'))
70
72
  html.push(await this.component.render({ tag: 'div', attr: _attr, html: `${result.input}\n${label}\n${hint}` }))
71
73
  if (result.append.length > 0) html.push(result.append.join('\n'))
74
+ html.push(errMsg)
72
75
  contents.push(html.join('\n'))
73
76
  } else {
74
77
  const _attr = { class: ['input-group'] }
78
+ if (!isEmpty(errMsg)) _attr.class.push('has-validation')
75
79
  if (group._.size && sizes.includes(group._.size)) _attr.class.push(`input-group-${group._.size}`)
76
80
  const html = []
77
81
  if (result.prepend.length > 0) html.push(result.prepend.join('\n'))
78
82
  html.push(result.input)
79
83
  if (result.append.length > 0) html.push(result.append.join('\n'))
80
- contents.push(await this.component.render({ tag: 'div', attr: _attr, html: html.join('\n') }), hint)
84
+ const item = await this.component.render({ tag: 'div', attr: _attr, html: html.join('\n') + '\n' + hint })
85
+ contents.push(item, errMsg)
81
86
  }
82
87
  return contents
83
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-bootstrap",
3
- "version": "2.12.0",
3
+ "version": "2.12.1",
4
4
  "description": "Bootstrap suport for Waibu Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-06-03
4
+
5
+ - [2.12.1] Bug fix in ```_lib.getInputAttr()```
6
+ - [2.12.1] Bug fix in ```form-input``` widget
7
+
3
8
  ## 2026-06-01
4
9
 
5
10
  - [2.11.0] Remove ```params``` on all widget since it already there through ```this.params```