ui-formatter 0.0.5 → 0.0.6
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 +17 -0
- package/package.json +2 -2
- package/src/index.ts +16 -0
- package/tsconfig.json +2 -1
package/lib/index.js
CHANGED
|
@@ -269,3 +269,20 @@ 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
|
+
}
|
package/package.json
CHANGED
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
|
+
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
|
+
}
|