ui-formatter 0.0.5 → 0.0.7

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
@@ -269,3 +269,21 @@ function formatFax(fax) {
269
269
  return formatter.formatFax(fax);
270
270
  }
271
271
  exports.formatFax = formatFax;
272
+ function isChecked(v, s) {
273
+ if (!v) {
274
+ return "";
275
+ }
276
+ if (typeof v === "boolean") {
277
+ return v ? "checked" : "";
278
+ }
279
+ else if (s) {
280
+ if (Array.isArray(s)) {
281
+ return s.includes(v) ? "checked" : "";
282
+ }
283
+ else {
284
+ return s === v ? "checked" : "";
285
+ }
286
+ }
287
+ return "";
288
+ }
289
+ exports.isChecked = isChecked;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ui-formatter",
3
- "version": "0.0.5",
4
- "description": "Validate data",
3
+ "version": "0.0.7",
4
+ "description": "Format web UI",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
7
7
  "scripts": {
package/src/index.ts CHANGED
@@ -247,3 +247,19 @@ export function formatPhone(phone?: string | null): string {
247
247
  export function formatFax(fax?: string | null): string {
248
248
  return formatter.formatFax(fax)
249
249
  }
250
+
251
+ export function isChecked(v: boolean | string | undefined | null, s: string[] | string | undefined): string {
252
+ if (!v) {
253
+ return ""
254
+ }
255
+ if (typeof v === "boolean") {
256
+ return v ? "checked" : ""
257
+ } else if (s) {
258
+ if (Array.isArray(s)) {
259
+ return s.includes(v) ? "checked" : ""
260
+ } else {
261
+ return s === v ? "checked" : ""
262
+ }
263
+ }
264
+ return ""
265
+ }
package/tsconfig.json CHANGED
@@ -14,7 +14,8 @@
14
14
  "removeComments": true,
15
15
  "lib": [
16
16
  "es5",
17
- "es6"
17
+ "es6",
18
+ "ES2016"
18
19
  ]
19
20
  },
20
21
  "include": [