waibu-mpa 2.14.3 → 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 CHANGED
@@ -343,7 +343,8 @@ async function factory (pkgName) {
343
343
 
344
344
  if (restOfDataTypes(obj)) {
345
345
  const passQuotes = isString(obj) ? "'" : ''
346
- return `${passQuotes}${obj}${passQuotes}`
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
- const { isString } = this.app.lib._
6
- const item = isString(link) ? { href: link, rel: 'stylesheet', type: 'text/css' } : link
7
- if (item.href) item.href = routePath(item.href)
8
- const attrs = this.stringifyAttribs(item)
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,15 +1,14 @@
1
1
  export function printScript (script) {
2
2
  const { routePath } = this.app.waibu
3
3
  const { stringifyAttribs } = this.app.waibuMpa
4
- const { isString, omit } = this.app.lib._
5
- if (isString(script)) script = { src: script }
6
- const result = `<script src="${routePath(script.src)}" ${stringifyAttribs(omit(script, ['src']))}></script>`
4
+ script.src = routePath(script.src)
5
+ const result = `<script ${stringifyAttribs(script)}></script>`
7
6
  return result
8
7
  }
9
8
 
10
9
  export async function collectRegular (type, transformer, options = {}) {
11
10
  const { runHook } = this.app.bajo
12
- const { map, get, isString, camelCase, uniq } = this.app.lib._
11
+ const { map, get, set, isString, camelCase, uniq } = this.app.lib._
13
12
  const { arrangeArray } = this.app.lib.aneka
14
13
  const { req } = options
15
14
 
@@ -31,8 +30,21 @@ export async function collectRegular (type, transformer, options = {}) {
31
30
  items.push(...fm)
32
31
  // find in options
33
32
  items.push(...options[type])
34
- items = arrangeArray(items)
35
- return uniq(map(items, i => transformer.call(this, i)))
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)))
36
48
  }
37
49
 
38
50
  export async function collectInline (type, options = {}) {
@@ -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.dataValue ?? 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]
@@ -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
- return get(data ?? this.formData, `_ref.${key}.${labelField}`)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-mpa",
3
- "version": "2.14.3",
3
+ "version": "2.15.0",
4
4
  "description": "MPA support for Waibu Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
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()```