express-ext 0.4.12 → 0.4.14
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/index.js +14 -3
- package/package.json +1 -1
- package/src/index.ts +11 -4
package/lib/index.js
CHANGED
|
@@ -400,18 +400,29 @@ function escapeHTML(input) {
|
|
|
400
400
|
})
|
|
401
401
|
}
|
|
402
402
|
exports.escapeHTML = escapeHTML
|
|
403
|
-
function generateChip(
|
|
403
|
+
function generateChip(value, text, noClose) {
|
|
404
404
|
var s = noClose ? "" : '<span class="close" onclick="removeChip(event)"></span>'
|
|
405
|
-
return '<div class="chip">' + escapeHTML(
|
|
405
|
+
return '<div class="chip" data-value="' + escapeHTML(value) + '">' + escapeHTML(text) + s + "</div>"
|
|
406
406
|
}
|
|
407
407
|
exports.generateChip = generateChip
|
|
408
|
+
function generateTags(v, noClose) {
|
|
409
|
+
return !v
|
|
410
|
+
? ""
|
|
411
|
+
: "" +
|
|
412
|
+
v
|
|
413
|
+
.map(function (s) {
|
|
414
|
+
return generateChip(s, s, noClose)
|
|
415
|
+
})
|
|
416
|
+
.join("")
|
|
417
|
+
}
|
|
418
|
+
exports.generateTags = generateTags
|
|
408
419
|
function generateChips(v, noClose) {
|
|
409
420
|
return !v
|
|
410
421
|
? ""
|
|
411
422
|
: "" +
|
|
412
423
|
v
|
|
413
424
|
.map(function (s) {
|
|
414
|
-
return generateChip(s, noClose)
|
|
425
|
+
return generateChip(s.value, s.text, noClose)
|
|
415
426
|
})
|
|
416
427
|
.join("")
|
|
417
428
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -384,12 +384,19 @@ export function escapeHTML(input: string): string {
|
|
|
384
384
|
return map[char]
|
|
385
385
|
})
|
|
386
386
|
}
|
|
387
|
-
export function generateChip(
|
|
387
|
+
export function generateChip(value: string, text: string, noClose?: boolean): string {
|
|
388
388
|
const s = noClose ? "" : `<span class="close" onclick="removeChip(event)"></span>`
|
|
389
|
-
return `<div class="chip">${escapeHTML(
|
|
389
|
+
return `<div class="chip" data-value="${escapeHTML(value)}">${escapeHTML(text)}${s}</div>`
|
|
390
390
|
}
|
|
391
|
-
export function
|
|
392
|
-
return !v ? "" : `${v.map((s) => generateChip(s, noClose)).join("")}`
|
|
391
|
+
export function generateTags(v?: string[] | null, noClose?: boolean): string {
|
|
392
|
+
return !v ? "" : `${v.map((s) => generateChip(s, s, noClose)).join("")}`
|
|
393
|
+
}
|
|
394
|
+
export interface Item {
|
|
395
|
+
value: string
|
|
396
|
+
text: string
|
|
397
|
+
}
|
|
398
|
+
export function generateChips(v?: Item[] | null, noClose?: boolean): string {
|
|
399
|
+
return !v ? "" : `${v.map((s) => generateChip(s.value, s.text, noClose)).join("")}`
|
|
393
400
|
}
|
|
394
401
|
|
|
395
402
|
const s = "string"
|