waibu-bootstrap 2.6.3 → 2.6.5
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/extend/waibuMpa/theme/component/method/after-build-tag/_lib.js +2 -2
- package/extend/waibuMpa/theme/component/widget/_lib.js +9 -31
- package/extend/waibuMpa/theme/component/widget/container.js +1 -1
- package/extend/waibuMpa/theme/component/widget/form-select-ext.js +12 -4
- package/package.json +1 -1
- package/wiki/CHANGES.md +13 -0
|
@@ -28,7 +28,7 @@ export const colorVariants = ['outline']
|
|
|
28
28
|
export const placements = ['top', 'bottom', 'left', 'right']
|
|
29
29
|
|
|
30
30
|
export function parseVariant ({ cls = '', value = '', values = [], variants = [], prepend } = {}) {
|
|
31
|
-
const { isEmpty } = this.app.lib._
|
|
31
|
+
const { isEmpty } = this.plugin.app.lib._
|
|
32
32
|
if (value === true) return cls
|
|
33
33
|
const [core, variant] = value.split('-')
|
|
34
34
|
const items = []
|
|
@@ -41,7 +41,7 @@ export function parseVariant ({ cls = '', value = '', values = [], variants = []
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export function parseSimple ({ cls = '', value = '', values = [], acceptTrue } = {}) {
|
|
44
|
-
const { isEmpty } = this.app.lib._
|
|
44
|
+
const { isEmpty } = this.plugin.app.lib._
|
|
45
45
|
if (values.includes(value) || (acceptTrue && value === true)) {
|
|
46
46
|
if (isEmpty(cls)) return value
|
|
47
47
|
return acceptTrue && value === true ? cls : `${cls}-${value}`
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { sizes } from '../method/after-build-tag/_lib.js'
|
|
2
2
|
|
|
3
|
-
const trueValues = ['true', 'on', 'yes', '1', 1, true]
|
|
4
|
-
|
|
5
3
|
async function getInputAttr (group, formControl = true, ro) {
|
|
6
|
-
const { omit, get,
|
|
4
|
+
const { omit, get, isPlainObject, isArray, has, forOwn, find } = this.app.lib._
|
|
7
5
|
const { escape } = this.app.waibu
|
|
8
|
-
const { req } = this.component
|
|
9
6
|
if (formControl) group._.class.push('form-control')
|
|
10
7
|
const attr = omit(group._, ['hint', 'label', 'wrapper'])
|
|
11
8
|
if (attr.href) {
|
|
@@ -17,31 +14,11 @@ async function getInputAttr (group, formControl = true, ro) {
|
|
|
17
14
|
let prop = {}
|
|
18
15
|
const schema = get(this, 'component.locals.schema')
|
|
19
16
|
if (schema) prop = find(schema.properties, { name: attr.name }) ?? {}
|
|
20
|
-
attr.dataType = attr.dataType ?? prop.type
|
|
21
|
-
|
|
22
|
-
if (attr.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
if (isPlainObject(val) || isArray(val)) attr.dataValue = escape(JSON.stringify(val))
|
|
27
|
-
else if (isString(val)) attr.dataValue = escape(val)
|
|
28
|
-
else attr.dataValue = val
|
|
29
|
-
if (ro) {
|
|
30
|
-
if (attr.ref) {
|
|
31
|
-
const [ref, fieldName = 'id'] = attr.ref.split(':')
|
|
32
|
-
attr.value = get(this, `component.locals.form._ref.${ref}.${fieldName}`, val)
|
|
33
|
-
} else if (attr.dataType === 'boolean') attr.value = req.t(val ? 'true' : 'false')
|
|
34
|
-
else if (has(attr, 'name') === 'lat') attr.value = escape(req.format(val, attr.dataType, { latitude: true }))
|
|
35
|
-
else if (has(attr, 'name') === 'lng') attr.value = escape(req.format(val, attr.dataType, { longitude: true }))
|
|
36
|
-
else if (prop.values) {
|
|
37
|
-
let items = prop.values
|
|
38
|
-
if (typeof prop.values === 'string') items = await this.app.bajo.callHandler(prop.values)
|
|
39
|
-
const item = find(items, { value: val }) ?? {}
|
|
40
|
-
const ttext = camelCase(`${prop.name} ${item.text}`)
|
|
41
|
-
attr.value = escape(req.format(!isEmpty(item) ? (req.te(ttext) ? req.t(ttext) : item.text) : val, attr.dataType))
|
|
42
|
-
} else attr.value = escape(req.format(val, attr.dataType))
|
|
43
|
-
} else attr.value = attr.dataValue
|
|
44
|
-
if (isArray(val)) attr.value = val.join(' ')
|
|
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}`))
|
|
45
22
|
}
|
|
46
23
|
if (sizes.includes(attr.size) && formControl) attr.class.push(`form-control-${attr.size}`)
|
|
47
24
|
return omit(attr, ['size', 'col'])
|
|
@@ -112,7 +89,7 @@ export async function buildFormRadioToggle (group, params) {
|
|
|
112
89
|
|
|
113
90
|
export async function buildFormPlaintext (group, params) {
|
|
114
91
|
const attr = await getInputAttr.call(this, group, false, true)
|
|
115
|
-
delete attr.dataValue
|
|
92
|
+
// delete attr.dataValue
|
|
116
93
|
attr.class.push('form-control-plaintext')
|
|
117
94
|
attr.readonly = ''
|
|
118
95
|
if (['object', 'array', 'text'].includes(attr.dataType)) {
|
|
@@ -151,9 +128,10 @@ export async function buildFormTextarea (group, params) {
|
|
|
151
128
|
|
|
152
129
|
export async function buildFormSelect (group, params) {
|
|
153
130
|
const { omit, trim } = this.app.lib._
|
|
131
|
+
const { isSet } = this.app.lib.aneka
|
|
154
132
|
const { $ } = this.component
|
|
155
133
|
let attr = await getInputAttr.call(this, group, false)
|
|
156
|
-
attr.value = attr.value + ''
|
|
134
|
+
attr.value = isSet(attr.value) ? (attr.value + '') : undefined
|
|
157
135
|
attr.class.push('form-select')
|
|
158
136
|
let html = params.html
|
|
159
137
|
if (sizes.includes(attr.size)) attr.class.push(`form-select-${attr.size}`)
|
|
@@ -12,7 +12,7 @@ async function container () {
|
|
|
12
12
|
build = async () => {
|
|
13
13
|
const { has, omit } = this.app.lib._
|
|
14
14
|
if (has(this.params.attr, 'responsive')) this.params.attr.class.push(`${cls}-fluid`)
|
|
15
|
-
else if (has(this.params.attr, 'breakpoint')) this.params.attr.class.push(parseSimple({ cls, value: this.params.attr.breakpoint, values: breakpoints }))
|
|
15
|
+
else if (has(this.params.attr, 'breakpoint')) this.params.attr.class.push(parseSimple.call(this, { cls, value: this.params.attr.breakpoint, values: breakpoints }))
|
|
16
16
|
else this.params.attr.class.push(cls)
|
|
17
17
|
this.params.attr = omit(this.params.attr, ['responsive', 'breakpoint'])
|
|
18
18
|
}
|
|
@@ -14,7 +14,7 @@ async function formSelectExt () {
|
|
|
14
14
|
|
|
15
15
|
build = async () => {
|
|
16
16
|
const { generateId } = this.app.lib.aneka
|
|
17
|
-
const { omit, merge, has } = this.app.lib._
|
|
17
|
+
const { omit, merge, has, isString } = this.app.lib._
|
|
18
18
|
const { routePath } = this.app.waibu
|
|
19
19
|
const { jsonStringify, groupAttrs } = this.app.waibuMpa
|
|
20
20
|
const { base64JsonDecode } = this.app.waibu
|
|
@@ -55,6 +55,13 @@ async function formSelectExt () {
|
|
|
55
55
|
group.remote.searchField = group.remote.searchField ?? 'id'
|
|
56
56
|
group.remote.labelField = group.remote.labelField ?? 'id'
|
|
57
57
|
group.remote.valueField = group.remote.valueField ?? 'id'
|
|
58
|
+
let query = `${group.remote.searchField}:~\\'{searchItem}\\'`
|
|
59
|
+
if (isString(group.remote.query)) {
|
|
60
|
+
const q = base64JsonDecode(group.remote.query)
|
|
61
|
+
const u = new URLSearchParams()
|
|
62
|
+
u.set('q', JSON.stringify(q))
|
|
63
|
+
query = u.toString().slice(2)
|
|
64
|
+
}
|
|
58
65
|
if (has(group.remote, 'apiKey')) {
|
|
59
66
|
if (group.remote.apiKey === true) fetchOpts.headers.Authorization = `Bearer ${apiKey}` // TODO: get it from wmpa
|
|
60
67
|
else fetchOpts.headers.Authorization = `Bearer ${group.remote.apiKey}`
|
|
@@ -63,8 +70,9 @@ async function formSelectExt () {
|
|
|
63
70
|
searchField: '${group.remote.searchField}',
|
|
64
71
|
labelField: '${group.remote.labelField}',
|
|
65
72
|
valueField: '${group.remote.valueField}',
|
|
66
|
-
load: (
|
|
67
|
-
|
|
73
|
+
load: (search, callback) => {
|
|
74
|
+
const query = '${query}'.replace('{searchItem}', search).replace('%7BsearchItem%7D', search)
|
|
75
|
+
fetch('${group.remote.url}?query=' + query, ${jsonStringify(fetchOpts, true)})
|
|
68
76
|
.then(resp => resp.json())
|
|
69
77
|
.then(json => {
|
|
70
78
|
callback(json.data)
|
|
@@ -131,7 +139,7 @@ async function formSelectExt () {
|
|
|
131
139
|
// this.params.attr['@load.window'] = 'onLoad()'
|
|
132
140
|
this.params.attr['x-init'] = 'onLoad()'
|
|
133
141
|
if (options.length > 0) this.params.attr.options = options
|
|
134
|
-
this.params.attr = omit(this.params.attr, ['noDropdownInput', 'removeBtn', 'clearBtn', 'c-opts', 'remoteUrl', 'remoteSearchField', 'remoteLabelField', 'remoteValueField'])
|
|
142
|
+
this.params.attr = omit(this.params.attr, ['noDropdownInput', 'removeBtn', 'clearBtn', 'c-opts', 'remoteUrl', 'remoteSearchField', 'remoteLabelField', 'remoteValueField', 'remoteQuery', 'remoteApiKey'])
|
|
135
143
|
await build.call(this, buildFormSelect, this.params)
|
|
136
144
|
}
|
|
137
145
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-04-11
|
|
4
|
+
|
|
5
|
+
- [2.6.5] Bug fix in ```form-select-ext``` widget
|
|
6
|
+
- [2.6.5] Bug fix in ```container``` widget
|
|
7
|
+
- [2.6.5] Bug fix in ```getInputAttr()```
|
|
8
|
+
- [2.6.5] Bug fix in ```parseVariant()```
|
|
9
|
+
- [2.6.5] Bug fix in ```parseSimple()```
|
|
10
|
+
|
|
11
|
+
## 2026-04-07
|
|
12
|
+
|
|
13
|
+
- [2.6.4] Bug fix on widget ```form-select-ext```
|
|
14
|
+
- [2.6.4] Bug fix on ```buildFormSelect()```
|
|
15
|
+
|
|
3
16
|
## 2026-04-01
|
|
4
17
|
|
|
5
18
|
- [2.6.3] Bug fix on widget ```form-datetime```
|