waibu-bootstrap 2.11.0 → 2.12.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.
@@ -3,8 +3,29 @@ import { build } from './form-input.js'
3
3
 
4
4
  async function formPlaintext () {
5
5
  return class FormPlaintext extends this.app.baseClass.MpaWidget {
6
- build = async () => {
6
+ reformat = async (format, value) => {
7
+ if (!format) return value
8
+ const { isPlainObject } = this.app.lib._
7
9
  const { req } = this.component
10
+ const formatted = await format.call(this, value, this.formData, { req })
11
+ if (isPlainObject(formatted)) {
12
+ value = formatted.value
13
+ if (formatted.href) {
14
+ this.params.addons = this.params.addons ?? []
15
+ const position = 'append'
16
+ const attr = {
17
+ icon: formatted.icon ?? 'link',
18
+ 'x-data': true,
19
+ '@click': `location.href='${formatted.href}'`
20
+ }
21
+ const html = await this.component.buildTag({ tag: 'btn', attr })
22
+ this.params.addons.push({ position, html })
23
+ }
24
+ } else value = formatted
25
+ return value
26
+ }
27
+
28
+ build = async () => {
8
29
  const { isEmpty, get } = this.app.lib._
9
30
  const { escape } = this.app.waibu
10
31
  this.params.attr.disabled = true
@@ -19,10 +40,8 @@ async function formPlaintext () {
19
40
  const labelField = get(this.schema, `view.widget.${name}.attr.labelField`)
20
41
  if (prop.ref) {
21
42
  const result = this.getRefValue({ field: name, labelField, refName: this.getRefName(name) })
22
- if (result) {
23
- value = format ? await format.call(this, value, this.formData, { req }) : result
24
- }
25
- } else if (format) value = await format.call(this, value, this.formData, { req })
43
+ if (result) value = await this.reformat(format, result)
44
+ } else if (format) value = await this.reformat(format, value)
26
45
  this.params.attr.dataValue = escape(dataValue)
27
46
  this.params.attr.value = value
28
47
  this.params.attr.dataType = prop.type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-bootstrap",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "Bootstrap suport for Waibu Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  - [2.11.0] Remove ```params``` on all widget since it already there through ```this.params```
6
6
  - [2.11.0] Add feature to add addons on all form inputs through schema
7
+ - [2.12.0] Tranform ```form-plaintext``` html as href addon if it contains link information
7
8
 
8
9
  ## 2026-05-25
9
10