waibu-mpa 2.14.2 → 2.15.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.
- package/index.js +2 -1
- package/lib/build-page/inject-elements/css.js +1 -1
- package/lib/build-page/inject-elements/link.js +4 -4
- package/lib/build-page/inject-elements/script.js +19 -6
- package/lib/class/component.js +1 -1
- package/lib/class/widget/page-end.js +1 -1
- package/lib/class/widget/page-start.js +1 -1
- package/lib/class/widget.js +15 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +7 -0
package/index.js
CHANGED
|
@@ -343,7 +343,8 @@ async function factory (pkgName) {
|
|
|
343
343
|
|
|
344
344
|
if (restOfDataTypes(obj)) {
|
|
345
345
|
const passQuotes = isString(obj) ? "'" : ''
|
|
346
|
-
|
|
346
|
+
const item = isString(obj) ? obj.replaceAll("'", "\\'") : obj
|
|
347
|
+
return `${passQuotes}${item}${passQuotes}`
|
|
347
348
|
}
|
|
348
349
|
|
|
349
350
|
if (isArray(obj)) {
|
|
@@ -2,7 +2,7 @@ import { collectInline, collectRegular } from './script.js'
|
|
|
2
2
|
|
|
3
3
|
export function printLink (link) {
|
|
4
4
|
const { routePath } = this.app.waibu
|
|
5
|
-
return `<link href="${routePath(link)}" rel="stylesheet" type="text/css" />`
|
|
5
|
+
return `<link href="${routePath(link.href)}" rel="stylesheet" type="text/css" />`
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
async function css (options) {
|
|
@@ -2,10 +2,10 @@ import { collectRegular } from './script.js'
|
|
|
2
2
|
|
|
3
3
|
export function printLink (link) {
|
|
4
4
|
const { routePath } = this.app.waibu
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const attrs = this.stringifyAttribs(
|
|
5
|
+
link.rel = link.rel ?? 'stylesheet'
|
|
6
|
+
link.type = link.type ?? 'text/css'
|
|
7
|
+
link.href = routePath(link.href)
|
|
8
|
+
const attrs = this.stringifyAttribs(link)
|
|
9
9
|
return `<link ${attrs} />`
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export function printScript (script) {
|
|
2
2
|
const { routePath } = this.app.waibu
|
|
3
3
|
const { stringifyAttribs } = this.app.waibuMpa
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return
|
|
4
|
+
script.src = routePath(script.src)
|
|
5
|
+
const result = `<script ${stringifyAttribs(script)}></script>`
|
|
6
|
+
return result
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export async function collectRegular (type, transformer, options = {}) {
|
|
10
10
|
const { runHook } = this.app.bajo
|
|
11
|
-
const { map, get, isString, camelCase, uniq } = this.app.lib._
|
|
11
|
+
const { map, get, set, isString, camelCase, uniq } = this.app.lib._
|
|
12
12
|
const { arrangeArray } = this.app.lib.aneka
|
|
13
13
|
const { req } = options
|
|
14
14
|
|
|
@@ -30,8 +30,21 @@ export async function collectRegular (type, transformer, options = {}) {
|
|
|
30
30
|
items.push(...fm)
|
|
31
31
|
// find in options
|
|
32
32
|
items.push(...options[type])
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const key = type === 'scripts' ? 'src' : 'href'
|
|
34
|
+
items = items.map(item => {
|
|
35
|
+
if (isString(item)) return set({}, key, item)
|
|
36
|
+
return item
|
|
37
|
+
})
|
|
38
|
+
// arrange
|
|
39
|
+
let tmp = items.map(item => item[key])
|
|
40
|
+
tmp = arrangeArray(tmp)
|
|
41
|
+
const newItems = []
|
|
42
|
+
for (const t of tmp) {
|
|
43
|
+
const item = items.find(i => i[key].endsWith(t))
|
|
44
|
+
item[key] = t
|
|
45
|
+
newItems.push(item)
|
|
46
|
+
}
|
|
47
|
+
return uniq(map(newItems, i => transformer.call(this, i)))
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
export async function collectInline (type, options = {}) {
|
package/lib/class/component.js
CHANGED
|
@@ -216,7 +216,7 @@ async function componentFactory () {
|
|
|
216
216
|
if (!has(params.attr, 'options')) return
|
|
217
217
|
const items = []
|
|
218
218
|
let input = params.attr.options
|
|
219
|
-
let values = attrToArray(params.attr.value)
|
|
219
|
+
let values = attrToArray(params.attr.dataValue ?? params.attr.value, '|')
|
|
220
220
|
if (!has(params.attr, 'multiple')) {
|
|
221
221
|
if (values.length > 0) values = [values[0]]
|
|
222
222
|
else if (prop.default) values = [prop.default]
|
|
@@ -13,7 +13,7 @@ async function pageStartFactory () {
|
|
|
13
13
|
const groups = groupAttrs(this.params.attr, ['body'])
|
|
14
14
|
this.params.attr = groups._
|
|
15
15
|
this.params.attr.c = 'page-start'
|
|
16
|
-
this.params.attr.id = generateId()
|
|
16
|
+
this.params.attr.id = generateId('alpha')
|
|
17
17
|
const body = `<body ${stringifyAttribs(groups.body)}>`
|
|
18
18
|
this.params.attr.prepend = escape('<!DOCTYPE html><html><head>')
|
|
19
19
|
this.params.attr.append = escape(`</head>${body}`)
|
package/lib/class/widget.js
CHANGED
|
@@ -118,10 +118,24 @@ async function widgetFactory () {
|
|
|
118
118
|
|
|
119
119
|
getRefValue = ({ field, data, labelField, refName } = {}) => {
|
|
120
120
|
const { get, isEmpty } = this.app.lib._
|
|
121
|
+
const { routePath, getPluginPrefix } = this.app.waibu
|
|
121
122
|
const { ref, key } = this.getRef({ field, refName, returning: 'all' })
|
|
123
|
+
|
|
124
|
+
const format = (value, rValue) => {
|
|
125
|
+
let refUrl = get(this.schema, `view.widget.${field}.attr.refUrl`)
|
|
126
|
+
if (!refUrl) return value
|
|
127
|
+
refUrl = refUrl
|
|
128
|
+
.replaceAll('{prefix}', getPluginPrefix(this.schema.ns))
|
|
129
|
+
.replaceAll('{id}', rValue.id)
|
|
130
|
+
return `<a href="${routePath(refUrl)}">${value}</a>`
|
|
131
|
+
}
|
|
132
|
+
|
|
122
133
|
if (isEmpty(ref)) return undefined
|
|
123
134
|
labelField = labelField ?? ref.labelField ?? 'id'
|
|
124
|
-
|
|
135
|
+
const item = get(data ?? this.formData, `_ref.${key}`)
|
|
136
|
+
if (isEmpty(item)) return undefined
|
|
137
|
+
if (!Array.isArray(item)) return format(item[labelField], item)
|
|
138
|
+
return item.map(i => format(i[labelField], i)).join(', ')
|
|
125
139
|
}
|
|
126
140
|
|
|
127
141
|
getRefName = (field) => {
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-05-11
|
|
4
|
+
|
|
5
|
+
- [2.15.0] Updates to match ```dobo@2.23.0``` specs
|
|
6
|
+
- [2.15.0] Bug fix in ```jsonStringify()```
|
|
7
|
+
- [2.15.0] Bug fix in ```component.js```
|
|
8
|
+
- [2.15.0] Bug fix in ```widget.js```
|
|
9
|
+
|
|
3
10
|
## 2026-04-21
|
|
4
11
|
|
|
5
12
|
- [2.14.2] Bug fix in ```Component.beforeBuildTag()``` and ```Component.afterBuildTag()```
|