waibu-bootstrap 2.6.5 → 2.7.0
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,25 +1,14 @@
|
|
|
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,
|
|
5
|
-
const { escape } = this.app.waibu
|
|
4
|
+
const { omit, get, forOwn } = this.app.lib._
|
|
6
5
|
if (formControl) group._.class.push('form-control')
|
|
7
6
|
const attr = omit(group._, ['hint', 'label', 'wrapper'])
|
|
8
7
|
if (attr.href) {
|
|
9
|
-
forOwn(this
|
|
8
|
+
forOwn(get(this, 'component.locals.form', {}), (v, k) => {
|
|
10
9
|
attr.href = attr.href.replace(`%7B${k}%7D`, v)
|
|
11
10
|
})
|
|
12
11
|
}
|
|
13
|
-
if (has(attr, 'name') && !has(attr, 'value') && this.component.locals.form) {
|
|
14
|
-
let prop = {}
|
|
15
|
-
const schema = get(this, 'component.locals.schema')
|
|
16
|
-
if (schema) prop = find(schema.properties, { name: attr.name }) ?? {}
|
|
17
|
-
attr.dataType = attr.dataType ?? prop.type
|
|
18
|
-
attr.dataValue = get(this, `component.locals.form._orig.${attr.name}`)
|
|
19
|
-
if (isPlainObject(attr.dataValue) || isArray(attr.dataValue)) attr.dataValue = JSON.stringify(attr.dataValue)
|
|
20
|
-
attr.dataValue = escape(attr.dataValue)
|
|
21
|
-
attr.value = escape(get(this, `component.locals.form.${attr.name}`))
|
|
22
|
-
}
|
|
23
12
|
if (sizes.includes(attr.size) && formControl) attr.class.push(`form-control-${attr.size}`)
|
|
24
13
|
return omit(attr, ['size', 'col'])
|
|
25
14
|
}
|
|
@@ -89,7 +78,6 @@ export async function buildFormRadioToggle (group, params) {
|
|
|
89
78
|
|
|
90
79
|
export async function buildFormPlaintext (group, params) {
|
|
91
80
|
const attr = await getInputAttr.call(this, group, false, true)
|
|
92
|
-
// delete attr.dataValue
|
|
93
81
|
attr.class.push('form-control-plaintext')
|
|
94
82
|
attr.readonly = ''
|
|
95
83
|
if (['object', 'array', 'text'].includes(attr.dataType)) {
|
|
@@ -97,7 +85,7 @@ export async function buildFormPlaintext (group, params) {
|
|
|
97
85
|
return await this.component.buildTag({ tag: 'textarea', attr, html: attr.value })
|
|
98
86
|
}
|
|
99
87
|
if (attr.href) {
|
|
100
|
-
const content = attr.value ? attr.value : attr.href
|
|
88
|
+
const content = attr.value ? this.component.req.t(attr.value) : attr.href
|
|
101
89
|
const html = await this.component.buildTag({ tag: 'a', attr: { href: attr.href, content } })
|
|
102
90
|
return await this.component.buildTag({ tag: 'div', attr, html })
|
|
103
91
|
}
|
package/package.json
CHANGED