@questwork/vue-q-list-vue3 3.1.3 → 3.1.4
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/lib/helpers/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { checkIfUsingTemplateCompiler } = require('./checkIfUsingTemplateCompiler')
|
|
1
2
|
const { getPopupPosition } = require('./getPopupPosition')
|
|
2
3
|
const { getTitle } = require('./getTitle')
|
|
3
4
|
const { getTooltipPosition } = require('./getTooltipPosition')
|
|
@@ -5,6 +6,7 @@ const { getValidation } = require('./getValidation')
|
|
|
5
6
|
const { getValue } = require('./getValue')
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
9
|
+
checkIfUsingTemplateCompiler,
|
|
8
10
|
getPopupPosition,
|
|
9
11
|
getTitle,
|
|
10
12
|
getTooltipPosition,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const { getValidation } = require('../../helpers')
|
|
1
|
+
const { getValidation, getValue, checkIfUsingTemplateCompiler } = require('../../helpers')
|
|
3
2
|
const { KeyValueObject } = require('../keyValueObject')
|
|
3
|
+
const { TemplateCompiler } = require('@questwork/q-utilities')
|
|
4
|
+
|
|
4
5
|
class QListButton {
|
|
5
6
|
constructor(options = {}) {
|
|
6
7
|
options = options || {}
|
|
@@ -12,7 +13,6 @@ class QListButton {
|
|
|
12
13
|
this.endpoint = options.endpoint
|
|
13
14
|
this.httpMethod = options.httpMethod
|
|
14
15
|
this.icon = options.icon
|
|
15
|
-
this.label = options.label
|
|
16
16
|
this.linkTarget = options.linkTarget
|
|
17
17
|
this.onClick = options.onClick
|
|
18
18
|
this.owner = options.owner
|
|
@@ -23,6 +23,8 @@ class QListButton {
|
|
|
23
23
|
this.showLabel = options.showLabel
|
|
24
24
|
this.title = options.title
|
|
25
25
|
this.url = options.url
|
|
26
|
+
this._templateCompiler = TemplateCompiler.init(this.qRow)
|
|
27
|
+
this.label = this.getLabel(options.label)
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
static init(options) {
|
|
@@ -77,6 +79,13 @@ class QListButton {
|
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
getLabel(label = '') {
|
|
83
|
+
if (checkIfUsingTemplateCompiler(label)) {
|
|
84
|
+
return this._templateCompiler.pipe(label)
|
|
85
|
+
}
|
|
86
|
+
return label
|
|
87
|
+
}
|
|
88
|
+
|
|
80
89
|
makeCss() {
|
|
81
90
|
return `__q-list-button ${this.css.element || ''}`
|
|
82
91
|
}
|
package/lib/models/qRow/qRow.js
CHANGED
|
@@ -84,8 +84,17 @@ class QRow {
|
|
|
84
84
|
// return this[realKey]
|
|
85
85
|
}
|
|
86
86
|
// check if regular expr
|
|
87
|
-
if (
|
|
88
|
-
|
|
87
|
+
if (_hasTemplateDelimiters(key)) {
|
|
88
|
+
const regex = /(\{\{ \w+\((['"])(.*?)\2\) \}\})|([^{]+)/g
|
|
89
|
+
const result = key.match(regex)?.filter(Boolean) || [key]
|
|
90
|
+
return result.reduce((acc, k) => {
|
|
91
|
+
if (_hasTemplateDelimiters(k)) {
|
|
92
|
+
acc += this._templateCompiler.pipe(k)
|
|
93
|
+
} else {
|
|
94
|
+
acc += k
|
|
95
|
+
}
|
|
96
|
+
return acc
|
|
97
|
+
}, '')
|
|
89
98
|
}
|
|
90
99
|
if (key.includes('.')) {
|
|
91
100
|
const arr = key.split('.')
|
|
@@ -227,9 +236,14 @@ function setShouldBeVisible(shouldBeVisible) {
|
|
|
227
236
|
}
|
|
228
237
|
}
|
|
229
238
|
|
|
230
|
-
function
|
|
239
|
+
function _hasTemplateDelimiters(key) {
|
|
231
240
|
key = key.trim()
|
|
232
|
-
|
|
241
|
+
// Check for {{ }} pattern
|
|
242
|
+
const doubleCurlyRegex = /\{\{.*?\}\}/
|
|
243
|
+
// Check for <% %> pattern
|
|
244
|
+
const anglePercentRegex = /<%.*?%>/
|
|
245
|
+
|
|
246
|
+
return doubleCurlyRegex.test(key) || anglePercentRegex.test(key)
|
|
233
247
|
}
|
|
234
248
|
|
|
235
249
|
module.exports = {
|