UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

460 lines (457 loc) • 14 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var index_native_exports = {}; __export(index_native_exports, { CNContactStore: () => CNContactStore, CNContactViewController: () => CNContactViewController, CNMutableContact: () => CNMutableContact }); module.exports = __toCommonJS(index_native_exports); var import_react_native_nitro_modules = require("react-native-nitro-modules"); var import_nativeError = require("../nativeError.native.js"); function _assert_this_initialized(self) { if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return self; } function _call_super(_this, derived, args) { derived = _get_prototype_of(derived); return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args)); } function _class_call_check(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _create_class(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true }); } else obj[key] = value; return obj; } function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) _get = Reflect.get; else { _get = function get(target2, property2, receiver2) { var base = _super_prop_base(target2, property2); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property2); if (desc.get) return desc.get.call(receiver2 || target2); return desc.value; }; } return _get(target, property, receiver || target); } function _get_prototype_of(o) { _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) { return o2.__proto__ || Object.getPrototypeOf(o2); }; return _get_prototype_of(o); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _set_prototype_of(subClass, superClass); } function _is_native_reflect_construct() { try { var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); } catch (_) {} return (_is_native_reflect_construct = function() { return !!result; })(); } function _possible_constructor_return(self, call) { if (call && (_type_of(call) === "object" || typeof call === "function")) return call; return _assert_this_initialized(self); } function _set_prototype_of(o, p) { _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) { o2.__proto__ = p2; return o2; }; return _set_prototype_of(o, p); } function _super_prop_base(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _get_prototype_of(object); if (object === null) break; } return object; } function _type_of(obj) { "@swc/helpers - typeof"; return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } function create(name) { if (!import_react_native_nitro_modules.NitroModules.hasHybridObject(name)) throw new Error("ContactsUI needs an iOS build"); return import_react_native_nitro_modules.NitroModules.createHybridObject(name); } var contacts = /* @__PURE__ */ new WeakMap(); var stores = /* @__PURE__ */ new WeakMap(); var contactWrappers = /* @__PURE__ */ new WeakMap(); var storeWrappers = /* @__PURE__ */ new WeakMap(); function wrapContact(native) { var _contactWrappers_get; return (_contactWrappers_get = contactWrappers.get(native)) !== null && _contactWrappers_get !== void 0 ? _contactWrappers_get : new CNContact(native); } function nativeContact(contact) { var value = contacts.get(contact); if (!value) throw new TypeError("ContactsUI requires a native CNContact"); return value; } var CNContact = /* @__PURE__ */ (function() { "use strict"; function CNContact2(native) { _class_call_check(this, CNContact2); _define_property(this, "native", void 0); this.native = native; contacts.set(this, native); contactWrappers.set(native, this); } _create_class(CNContact2, [ { key: "identifier", get: function get() { return this.native.identifier; } }, { key: "namePrefix", get: function get() { return this.native.getContactName("namePrefix"); } }, { key: "givenName", get: function get() { return this.native.getContactName("givenName"); } }, { key: "middleName", get: function get() { return this.native.getContactName("middleName"); } }, { key: "familyName", get: function get() { return this.native.getContactName("familyName"); } }, { key: "nameSuffix", get: function get() { return this.native.getContactName("nameSuffix"); } }, { key: "nickname", get: function get() { return this.native.getContactName("nickname"); } }, { key: "organizationName", get: function get() { return this.native.getContactName("organizationName"); } }, { key: "jobTitle", get: function get() { return this.native.getContactName("jobTitle"); } }, { key: "isKeyAvailable", value: function isKeyAvailable(key) { return this.native.isKeyAvailable(key); } }, { key: "mutableCopy", value: function mutableCopy() { var copy = Object.create(CNMutableContact.prototype); copy.native = this.native.mutableCopy(); contacts.set(copy, copy.native); contactWrappers.set(copy.native, copy); return copy; } } ]); return CNContact2; })(); var CNMutableContact = /* @__PURE__ */ (function(CNContact2) { "use strict"; _inherits(CNMutableContact2, CNContact2); function CNMutableContact2() { _class_call_check(this, CNMutableContact2); return _call_super(this, CNMutableContact2, [create("NativeCNContact")]); } _create_class(CNMutableContact2, [ { key: "namePrefix", get: function get() { return _get(_get_prototype_of(CNMutableContact2.prototype), "namePrefix", this); }, set: function set(value) { this.native.setName("namePrefix", value); } }, { key: "givenName", get: function get() { return _get(_get_prototype_of(CNMutableContact2.prototype), "givenName", this); }, set: function set(value) { this.native.setName("givenName", value); } }, { key: "middleName", get: function get() { return _get(_get_prototype_of(CNMutableContact2.prototype), "middleName", this); }, set: function set(value) { this.native.setName("middleName", value); } }, { key: "familyName", get: function get() { return _get(_get_prototype_of(CNMutableContact2.prototype), "familyName", this); }, set: function set(value) { this.native.setName("familyName", value); } }, { key: "nameSuffix", get: function get() { return _get(_get_prototype_of(CNMutableContact2.prototype), "nameSuffix", this); }, set: function set(value) { this.native.setName("nameSuffix", value); } }, { key: "nickname", get: function get() { return _get(_get_prototype_of(CNMutableContact2.prototype), "nickname", this); }, set: function set(value) { this.native.setName("nickname", value); } }, { key: "organizationName", get: function get() { return _get(_get_prototype_of(CNMutableContact2.prototype), "organizationName", this); }, set: function set(value) { this.native.setName("organizationName", value); } }, { key: "jobTitle", get: function get() { return _get(_get_prototype_of(CNMutableContact2.prototype), "jobTitle", this); }, set: function set(value) { this.native.setName("jobTitle", value); } } ]); return CNMutableContact2; })(CNContact); var CNContactStore = /* @__PURE__ */ (function() { "use strict"; function CNContactStore2() { _class_call_check(this, CNContactStore2); var native = create("NativeCNContactStore"); stores.set(this, native); storeWrappers.set(native, this); } _create_class(CNContactStore2, [{ key: "native", get: function get() { return stores.get(this); } }, { key: "unifiedContact", value: function unifiedContact(options) { return this.native.unifiedContact(options.withIdentifier, options.keysToFetch.filter(function(key) { return typeof key === "string"; }), options.keysToFetch.filter(function(key) { return typeof key !== "string"; })).then(wrapContact).catch(import_nativeError.rethrowNativeError); } }]); return CNContactStore2; })(); var capabilities; var CNContactViewController = /* @__PURE__ */ (function() { "use strict"; function CNContactViewController2(options) { _class_call_check(this, CNContactViewController2); _define_property(this, "native", create("OneContactUI")); _define_property(this, "delegate", null); if ("forContact" in options) this.native.configure("contact", nativeContact(options.forContact)); else if ("forUnknownContact" in options) this.native.configure("unknownContact", nativeContact(options.forUnknownContact)); else this.native.configure("newContact", options.forNewContact ? nativeContact(options.forNewContact) : void 0); } _create_class(CNContactViewController2, [ { key: "contact", get: function get() { return wrapContact(this.native.contact); } }, { key: "contactStore", get: function get() { var value = this.native.getContactStore(); if (!value) return void 0; var existing = storeWrappers.get(value); if (existing) return existing; var store = Object.create(CNContactStore.prototype); stores.set(store, value); storeWrappers.set(value, store); return store; }, set: function set(value) { var native = value === void 0 ? void 0 : stores.get(value); if (value !== void 0 && !native) throw new TypeError("ContactsUI requires a native CNContactStore"); this.native.setContactStore(native); } }, { key: "displayedPropertyKeys", get: function get() { return this.native.displayedPropertyKeys; }, set: function set(value) { this.native.displayedPropertyKeys = value; } }, { key: "alternateName", get: function get() { return this.native.alternateName; }, set: function set(value) { this.native.alternateName = value; } }, { key: "message", get: function get() { return this.native.message; }, set: function set(value) { this.native.message = value; } }, { key: "allowsEditing", get: function get() { return this.native.allowsEditing; }, set: function set(value) { this.native.allowsEditing = value; } }, { key: "allowsActions", get: function get() { return this.native.allowsActions; }, set: function set(value) { this.native.allowsActions = value; } }, { key: "shouldShowLinkedContacts", get: function get() { return this.native.shouldShowLinkedContacts; }, set: function set(value) { this.native.shouldShowLinkedContacts = value; } }, { key: "highlightProperty", value: function highlightProperty(withKey, identifier) { this.native.highlightProperty(withKey, identifier); } }, { key: "present", value: function present() { var _this = this; var animated = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true; return this.native.present(animated, function(contact) { var _this_delegate_contactViewController, _this_delegate; return (_this_delegate = _this.delegate) === null || _this_delegate === void 0 ? void 0 : (_this_delegate_contactViewController = _this_delegate.contactViewController) === null || _this_delegate_contactViewController === void 0 ? void 0 : _this_delegate_contactViewController.call(_this_delegate, _this, { didCompleteWith: contact ? wrapContact(contact) : void 0 }); }).catch(import_nativeError.rethrowNativeError); } }, { key: "dismiss", value: function dismiss() { var animated = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true; return this.native.dismiss(animated).catch(import_nativeError.rethrowNativeError); } } ], [{ key: "descriptorForRequiredKeys", value: function descriptorForRequiredKeys() { return (capabilities !== null && capabilities !== void 0 ? capabilities : capabilities = create("OneContactUI")).descriptorForRequiredKeys(); } }]); return CNContactViewController2; })(); //# sourceMappingURL=index.native.js.map