waibu-bootstrap 2.7.0 → 2.7.2
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.
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
import { sizes } from '../method/after-build-tag/_lib.js'
|
|
2
2
|
|
|
3
3
|
async function getInputAttr (group, formControl = true, ro) {
|
|
4
|
-
const { omit, get,
|
|
4
|
+
const { has, omit, forOwn, isPlainObject, isArray, get, isString } = this.app.lib._
|
|
5
|
+
const { callHandler } = this.app.bajo
|
|
6
|
+
const { req } = this.component
|
|
7
|
+
const { escape } = this.app.waibu
|
|
8
|
+
|
|
5
9
|
if (formControl) group._.class.push('form-control')
|
|
6
10
|
const attr = omit(group._, ['hint', 'label', 'wrapper'])
|
|
11
|
+
if (has(attr, 'name') && !has(attr, 'value')) {
|
|
12
|
+
if (ro) attr.value = this.formData[attr.name]
|
|
13
|
+
else {
|
|
14
|
+
const prop = this.getProp(attr.name)
|
|
15
|
+
attr.dataType = attr.dataType ?? prop.type
|
|
16
|
+
attr.dataValue = get(this.formData, `_orig.${attr.name}`, get(this.formData, attr.name))
|
|
17
|
+
if (isPlainObject(attr.dataValue) || isArray(attr.dataValue)) attr.dataValue = JSON.stringify(attr.dataValue)
|
|
18
|
+
attr.dataValue = escape(attr.dataValue)
|
|
19
|
+
attr.value = attr.dataValue
|
|
20
|
+
if (prop.values) {
|
|
21
|
+
const values = (isString(prop.values) ? await callHandler(prop.values) : [...prop.values]).map(v => {
|
|
22
|
+
if (isString(v)) v = { value: v, text: v }
|
|
23
|
+
const { camelCase } = this.app.lib._
|
|
24
|
+
const key = camelCase(`${prop.name} ${v.text}`)
|
|
25
|
+
if (req.te(key)) v.text = req.t(key)
|
|
26
|
+
return v
|
|
27
|
+
})
|
|
28
|
+
attr.options = values
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
7
32
|
if (attr.href) {
|
|
8
|
-
forOwn(
|
|
9
|
-
attr.href = attr.href.replace(
|
|
33
|
+
forOwn(this.formData, (v, k) => {
|
|
34
|
+
attr.href = attr.href.replace(`{${k}}`, v)
|
|
10
35
|
})
|
|
11
36
|
}
|
|
12
37
|
if (sizes.includes(attr.size) && formControl) attr.class.push(`form-control-${attr.size}`)
|
|
@@ -4,8 +4,28 @@ import { build } from './form-input.js'
|
|
|
4
4
|
async function formPlaintext () {
|
|
5
5
|
return class FormPlaintext extends this.app.baseClass.MpaWidget {
|
|
6
6
|
build = async () => {
|
|
7
|
+
const { isEmpty, get } = this.app.lib._
|
|
8
|
+
const { req } = this.component
|
|
9
|
+
const { escape } = this.app.waibu
|
|
7
10
|
this.params.attr.disabled = true
|
|
11
|
+
const { name } = this.params.attr
|
|
8
12
|
if (this.params.attr.labelFloating) this.params.attr.class.push('border', 'rounded')
|
|
13
|
+
if (!isEmpty(name) && isEmpty(this.params.attr.value)) {
|
|
14
|
+
const prop = this.getProp(name)
|
|
15
|
+
const dataValue = get(this.formData, `_orig.${name}`, '')
|
|
16
|
+
let value = get(this.oldData, name, get(this.formData, name, ''))
|
|
17
|
+
const format = get(this.schema, `view.format.${name}`)
|
|
18
|
+
const formatValue = get(this.schema, `view.formatValue.${name}`)
|
|
19
|
+
const labelField = get(this.schema, `view.widget.${name}.attr.labelField`)
|
|
20
|
+
if (formatValue) value = await formatValue.call(this, value, this.formData, { req })
|
|
21
|
+
else if (prop.ref) {
|
|
22
|
+
value = this.getRefValue({ field: name, labelField, refName: this.getRefName(name) })
|
|
23
|
+
if (format && !isEmpty(value)) this.params.attr.href = await format.call(this, value, this.formData, { linkOnly: true })
|
|
24
|
+
} else if (format && !isEmpty(value)) value = await format.call(this, value, this.formData)
|
|
25
|
+
this.params.attr.dataValue = escape(dataValue)
|
|
26
|
+
this.params.attr.value = escape(value)
|
|
27
|
+
this.params.attr.dataType = prop.type
|
|
28
|
+
}
|
|
9
29
|
await build.call(this, buildFormPlaintext, this.params)
|
|
10
30
|
}
|
|
11
31
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-04-18
|
|
4
|
+
|
|
5
|
+
- [2.7.2] Bug fix in ```getInputAttr()``` of ```_lib.js```
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## 2026-04-17
|
|
9
|
+
|
|
10
|
+
- [2.7.1] Bug fix in ```getInputAttr()```
|
|
11
|
+
- [2.7.1] Bug fix in ```FormPlaintext``` widget
|
|
12
|
+
|
|
3
13
|
## 2026-04-13
|
|
4
14
|
|
|
5
15
|
- [2.7.0] Rewrite ```getInputAttr()``` to not dependent to any template data, rather only depend on attributes
|