waibu-mpa 2.3.0 → 2.4.1

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.
@@ -0,0 +1,4 @@
1
+ <c:div flex="justify-content:between" margin="top-4 bottom-4">
2
+ <c:heading type="4" content="<%= attr.title ? _t(attr.title) : page.title %>" />
3
+ <c:div id="heading-end"></c:div>
4
+ </c:div>
@@ -8,6 +8,7 @@ const mapping = {
8
8
  alignMiddle: '',
9
9
  alignStart: '',
10
10
  alignTop: '',
11
+ anchor: '',
11
12
  archive: '',
12
13
  arrowCcw: 'arrow-counterclockwise',
13
14
  arrowCw: 'arrow-clockwise',
package/index.js CHANGED
@@ -584,7 +584,7 @@ async function factory (pkgName) {
584
584
  return subPath(pages, subPath)
585
585
  }
586
586
 
587
- parseAttribs = (text = '', delimiter = ' ', kvDelimiter = '=', camelCasedKey = true) => {
587
+ parseAttribs = (text, { delimiter = ' ', kvDelimiter = '=', camelCasedKey = true, trimValue = true } = {}) => {
588
588
  const { trim, camelCase, map, isPlainObject, forOwn } = this.app.lib._
589
589
  let attrs = []
590
590
  if (isPlainObject(text)) {
@@ -597,7 +597,7 @@ async function factory (pkgName) {
597
597
  for (const attr of attrs) {
598
598
  let [k, ...v] = map(attr.split(kvDelimiter), a => trim(a))
599
599
  v = v.join(kvDelimiter)
600
- v = v.slice(1, v.length - 1)
600
+ if (trimValue) v = v.slice(1, v.length - 1)
601
601
  if (v === 'undefined') continue
602
602
  if (k !== 'content' && v === '') v = true
603
603
  // check for retainAttrKey on ALL plugins
@@ -1,6 +1,6 @@
1
1
  async function parseAttr ({ $, el, req } = {}) {
2
2
  const { routePath } = this.app.waibu
3
- const { map, isString } = this.app.lib._
3
+ const { map, isString, isEmpty } = this.app.lib._
4
4
  const { attrToArray } = this.app.waibuMpa
5
5
 
6
6
  // const ns = get(req, 'routeOptions.config.ns')
@@ -19,8 +19,11 @@ async function parseAttr ({ $, el, req } = {}) {
19
19
  !(val.slice(1, 3) === '%=' && val[val.length - 2] === '%')) {
20
20
  el.attribs['o' + key] = val
21
21
  try {
22
- el.attribs[key] = routePath(val)
23
- } catch (err) {}
22
+ let [link, params] = val.split('|')
23
+ if (!isEmpty(params)) params = this.parseAttribs(params, { trimValue: false, delimiter: ';' })
24
+ el.attribs[key] = routePath(link, { params })
25
+ } catch (err) {
26
+ }
24
27
  }
25
28
  // translate
26
29
  if (key.slice(0, 2) === 't:') {
@@ -9,6 +9,7 @@ async function injectElements (options) {
9
9
  const { runHook } = this.app.bajo
10
10
  const { get, isString, isFunction, isEmpty } = this.app.lib._
11
11
  $('html').attr('lang', req.lang)
12
+ if (req.darkMode) $('body').attr('data-bs-theme', 'dark')
12
13
  const rsc = {}
13
14
  for (const tag of reply.ctags ?? []) {
14
15
  let Builder = get(cmp, `widget.${tag}`)
@@ -101,7 +101,7 @@ async function componentFactory () {
101
101
  let html
102
102
  if (params.attr.content.includes('%s')) html = sprintf(params.attr.content, params.html)
103
103
  else if (isEmpty(params.html)) html = params.attr.content
104
- if (!isEmpty(html)) params.html = params.noEscape ? html : escape(html)
104
+ if (!isEmpty(html)) params.html = (params.noEscape || params.attr.noEscape) ? html : escape(html)
105
105
  await this.iconAttr(params, method)
106
106
  await this.beforeBuildTag(method, params)
107
107
  const Widget = await this.getWidget(method)
@@ -7,6 +7,7 @@ export default {
7
7
  alignEnd: {},
8
8
  alignCenter: {},
9
9
  alignMiddle: {},
10
+ anchor: {},
10
11
  archive: {},
11
12
  arrowCw: {},
12
13
  arrowCcw: {},
@@ -210,8 +211,8 @@ export default {
210
211
  moon: {},
211
212
  mouse: {},
212
213
  music: {},
213
- newspaper: {},
214
214
  navigation: {},
215
+ newspaper: {},
215
216
  outlet: {},
216
217
  palette: {},
217
218
  paperclip: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu-mpa",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "MPA support for Waibu Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -8,6 +8,11 @@
8
8
  - [2.3.0] Bug fix on ```loadResource()```
9
9
  - [2.3.0] Bug fix on ```<link />``` injection
10
10
  - [2.3.0] Bug fix on order of metas, links & scripts
11
+ - [2.4.0] Add ```anchor``` and ```navigation``` icons
12
+ - [2.4.0] Add dark mode auto detect right at inject elements
13
+ - [2.4.1] Bug fix on ```parseAttribs()```
14
+ - [2.4.1] Attribute mutations (href, src, action) now accept url with parameter
15
+
11
16
 
12
17
  ## 2026-02-05
13
18