express-ext 0.4.11 → 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 CHANGED
@@ -400,12 +400,31 @@ function escapeHTML(input) {
400
400
  })
401
401
  }
402
402
  exports.escapeHTML = escapeHTML
403
- function generateChip(v) {
404
- return '<div class="chip">' + escapeHTML(v) + '<span class="close" onclick="removeChip(event)"></span></div>'
403
+ function generateChip(value, text, noClose) {
404
+ var s = noClose ? "" : '<span class="close" onclick="removeChip(event)"></span>'
405
+ return '<div class="chip" data-value="' + escapeHTML(value) + '">' + escapeHTML(text) + s + "</div>"
405
406
  }
406
407
  exports.generateChip = generateChip
407
- function generateChips(v) {
408
- return !v ? "" : "" + v.map(generateChip).join("")
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
419
+ function generateChips(v, noClose) {
420
+ return !v
421
+ ? ""
422
+ : "" +
423
+ v
424
+ .map(function (s) {
425
+ return generateChip(s.value, s.text, noClose)
426
+ })
427
+ .join("")
409
428
  }
410
429
  exports.generateChips = generateChips
411
430
  var s = "string"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-ext",
3
- "version": "0.4.11",
3
+ "version": "0.4.14",
4
4
  "description": "express-ext",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -384,11 +384,19 @@ export function escapeHTML(input: string): string {
384
384
  return map[char]
385
385
  })
386
386
  }
387
- export function generateChip(v: string): string {
388
- return `<div class="chip">${escapeHTML(v)}<span class="close" onclick="removeChip(event)"></span></div>`
387
+ export function generateChip(value: string, text: string, noClose?: boolean): string {
388
+ const s = noClose ? "" : `<span class="close" onclick="removeChip(event)"></span>`
389
+ return `<div class="chip" data-value="${escapeHTML(value)}">${escapeHTML(text)}${s}</div>`
389
390
  }
390
- export function generateChips(v?: string[] | null): string {
391
- return !v ? "" : `${v.map(generateChip).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("")}`
392
400
  }
393
401
 
394
402
  const s = "string"