vcard-generator
Version:
VCard v4.0 rfc6350 compliant generator from JSON.
67 lines (47 loc) • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _util = require('./util');
exports.default = function (_ref) {
var pref = _ref.pref,
type = _ref.type,
label = _ref.label,
uri = _ref.uri,
text = _ref.text,
value = _ref.value,
number = _ref.number;
return ['TEL', uri && ';VALUE=uri', (0, _util.formatPref)(pref), (0, _util.formatType)(type || label), ':', (0, _util.encodeText)(uri || text || value || number)].filter(_util.isSet).join('');
}; /*
Cardinality: 0+ (*)
TEL-param = TEL-text-param / TEL-uri-param
TEL-value = TEL-text-value / TEL-uri-value
; Value and parameter MUST match.
TEL-text-param = "VALUE=text"
TEL-text-value = text
TEL-uri-param = "VALUE=uri" / mediatype-param
TEL-uri-value = URI
TEL-param =/ type-param / pid-param / pref-param / altid-param
/ any-param
type-param-tel = "text" / "voice" / "fax" / "cell" / "video"
/ "pager" / "textphone" / iana-token / x-name
; type-param-tel MUST NOT be used with a property other than TEL.
TEL;VALUE=uri;PREF=1;TYPE="voice,home":tel:+1-555-555-5555;ext=5555
TEL;VALUE=uri;TYPE=home:tel:+33-01-23-45-67
TEL;WORK:4121233231
TEL;CELL:1231231234
TEL;WORK;FAX:+821090314331
TEL;type=WORK;type=VOICE;type=pref:1 (234) 567-8901
TEL;type=CELL;type=VOICE:2345678901
item2.TEL:+821012345678
item2.X-ABLabel:CustomPhone
TEL;type=HOME;type=VOICE;type=pref:1 (234) 567-8901
item2.TEL:(456) 789-1234
item2.X-ABLabel:My Phone
TEL;type=HOME;type=VOICE;type=pref:1 (234) 567-8901
TEL;type=WORK;type=VOICE:(345) 678-9012
item1.TEL:+82 10-1234-5678
item1.X-ABLabel:Custom Label
TEL;:1-234-567-89
TEL;PREF:010-910-94494
*/