@agility/app-sdk
Advanced tools
Comparing version 2.0.5-rc1 to 2.0.5-rc2
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("react"),t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};function r(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function n(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function i(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function a(e){return"function"==typeof e}function s(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var u=s((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function c(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var p=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,s,c;if(!this.closed){this.closed=!0;var p=this._parentage;if(p)if(this._parentage=null,Array.isArray(p))try{for(var l=n(p),f=l.next();!f.done;f=l.next()){f.value.remove(this)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}else p.remove(this);var d=this.initialTeardown;if(a(d))try{d()}catch(e){c=e instanceof u?e.errors:[e]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var h=n(b),y=h.next();!y.done;y=h.next()){var I=y.value;try{v(I)}catch(e){c=null!=c?c:[],e instanceof u?c=i(i([],o(c)),o(e.errors)):c.push(e)}}}catch(e){r={error:e}}finally{try{y&&!y.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(c)throw new u(c)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)v(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&c(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&c(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),l=p.EMPTY;function f(e){return e instanceof p||e&&"closed"in e&&a(e.remove)&&a(e.add)&&a(e.unsubscribe)}function v(e){a(e)?e():e.unsubscribe()}var d={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},b={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var a=b.delegate;return(null==a?void 0:a.setTimeout)?a.setTimeout.apply(a,i([e,t],o(r))):setTimeout.apply(void 0,i([e,t],o(r)))},clearTimeout:function(e){var t=b.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function h(){}function y(e){e()}var I=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,f(t)&&t.add(r)):r.destination=S,r}return r(t,e),t.create=function(e,t,r){return new w(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(p),m=Function.prototype.bind;function D(e,t){return m.call(e,t)}var g=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){_(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){_(e)}else _(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){_(e)}},e}(),w=function(e){function t(t,r,n){var o,i,s=e.call(this)||this;a(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:s&&d.useDeprecatedNextContext?((i=Object.create(t)).unsubscribe=function(){return s.unsubscribe()},o={next:t.next&&D(t.next,i),error:t.error&&D(t.error,i),complete:t.complete&&D(t.complete,i)}):o=t;return s.destination=new g(o),s}return r(t,e),t}(I);function _(e){var t;t=e,b.setTimeout((function(){throw t}))}var S={closed:!0,next:h,error:function(e){throw e},complete:h},x="function"==typeof Symbol&&Symbol.observable||"@@observable";function T(e){return e}var P=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,i=(n=e)&&n instanceof I||function(e){return e&&a(e.next)&&a(e.error)&&a(e.complete)}(n)&&f(n)?e:new w(e,t,r);return y((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=O(t))((function(t,n){var o=new w({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[x]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?T:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=O(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function O(e){var t;return null!==(t=null!=e?e:d.Promise)&&void 0!==t?t:Promise}var E=s((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),A=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r(t,e),t.prototype.lift=function(e){var t=new C(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new E},t.prototype.next=function(e){var t=this;y((function(){var r,o;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=n(t.currentObservers),a=i.next();!a.done;a=i.next()){a.value.next(e)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;y((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;y((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,i=r.observers;return n||o?l:(this.currentObservers=null,i.push(e),new p((function(){t.currentObservers=null,c(i,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new P;return e.source=this,e},t.create=function(e,t){return new C(e,t)},t}(P),C=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return r(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:l},t}(A),M=0;var z=function(){return"operation-".concat(++M)},k={},j=function(e){var t=e.operationID,r=e.operation,n=e.autoDelete,o=void 0===n||n;return k[t]={operation:r,autoDelete:o},r},L=function(e){delete k[e]},V=function(e){var t=e.data,r=t.operationID;if(r){var n=function(e){var t=k[e];if(t){var r=t.operation;return t.autoDelete&&delete k[e],r||null}return null}(r);n&&n.next(t.arg||(null==t?void 0:t.error))}},F=function(e){window.parent.postMessage(e,"*")},N=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("appID"))&&void 0!==e?e:null},R=function(e){var t=e.fieldName,r=e.onChange,n=N();if(n){var o="".concat(t,"-").concat(n),i=o,a=function(e){var t=k[e];if(t){var r=t.operation;return t.autoDelete,r}return null}(o);if(a)a.subscribe((function(e){var t=e.fieldValue;r(t)}));else{var s={appID:n,operationID:i,operationType:"addFieldListener",arg:{fieldName:t,operationID:o,operationType:"onFieldChanged"}},u=new A;u.subscribe((function(e){var t=e.fieldValue;r(t)})),j({operationID:o,operation:u,autoDelete:!1}),F(s)}}},U=Object.freeze({__proto__:null,addFieldListener:R,addSelectedItemListener:function(e){var t=e.onChange,r=N();if(r){var n=z(),o="selectedItem-".concat(r),i={appID:r,operationID:n,operationType:"addSelectedItemListener",arg:{operationID:o,operationType:"onSelectedItemChange"}},a=new A;j({operationID:n,operation:a});var s=new A;s.subscribe((function(e){var r=e.selectedItems;t(r)})),j({operationID:o,operation:s,autoDelete:!1}),F(i)}},getContentItem:function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"getContentItem"},n=new A,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),F(r),o}},getSelectedItems:function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"getSelectedItems"},n=new A,o=new Promise((function(e){n.subscribe((function(t){var r=t.selectedItems;e(r),n.unsubscribe()}))}));return j({operationID:t,operation:n}),F(r),o}},removeFieldListener:function(e){var t=e.fieldName,r=N();if(r){var n=z(),o={appID:r,operationID:n,operationType:"removeFieldListener",arg:{fieldName:t,operationID:"".concat(t,"-").concat(r)}},i=new A;i.subscribe((function(e){var t=e.removeOperationID;L(t),i.unsubscribe()})),j({operationID:n,operation:i}),F(o)}},removeSelectedItemListener:function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"removeSelectedItemListener",arg:{operationID:"selectedItem-".concat(e)}},n=new A;n.subscribe((function(e){var t=e.removeOperationID;L(t),n.unsubscribe()})),j({operationID:t,operation:n}),F(r)}},setFieldValue:function(e){var t=e.name,r=e.value,n=N();if(n){var o=z(),i={appID:n,operationID:o,operationType:"setFieldValue",arg:{name:t,value:r}},a=new A;j({operationID:o,operation:a}),F(i)}}}),B=Object.freeze({__proto__:null,persistData:function(e){var t=e.key,r=e.value,n=N();if(n){var o=z(),i={appID:n,operationID:o,operationType:"persistData",arg:{key:t,value:r}},a=new A,s=new Promise((function(e,t){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return j({operationID:o,operation:a}),F(i),s}},updateConfigurationValue:function(e){var t=e.name,r=e.value,n=N();if(n){var o=z(),i={appID:n,operationID:o,operationType:"updateConfigurationValue",arg:{name:t,value:r}},a=new A,s=new Promise((function(e){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return j({operationID:o,operation:a}),F(i),s}}}),H=Object.freeze({__proto__:null,selectAssets:function(e){var t=e.title,r=e.singleSelectOnly,n=e.callback,o=N();if(o){var i=z(),a=z(),s={appID:o,operationID:i,operationType:"selectAssets",arg:{closeModalID:a,title:t,singleSelectOnly:r}},u=new A;j({operationID:i,operation:u});var c=new A;c.subscribe((function(e){var t=e.assets;n(t),c.unsubscribe()})),j({operationID:a,operation:c}),F(s)}}}),K=Object.freeze({__proto__:null,getPageItem:function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"getPageItem"},n=new A,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),F(r),o}}}),Y=function(e){var t=e.height,r=N();if(r){var n=z(),o={appID:r,operationID:n,operationType:"setHeight",arg:{height:t}},i=new A;j({operationID:n,operation:i}),F(o)}};exports.assetsMethods=H,exports.closeModal=function(e){var t=N(),r=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("closeModalID"))&&void 0!==e?e:null}();if(t&&r){var n=z();F({appID:t,operationID:n,operationType:"closeModal",arg:{closeModalID:r,props:e}})}},exports.configMethods=B,exports.contentItemMethods=U,exports.getAPIKey=function(e){var t=e.apiType,r=N();if(r){var n=z(),o={appID:r,operationID:n,operationType:"getAPIKey",arg:{apiType:t}},i=new A,a=new Promise((function(e){i.subscribe((function(t){var r=t.apiKey;e(r),i.unsubscribe()}))}));return j({operationID:n,operation:i}),F(o),a}},exports.getAppInstall=function(){var e=N();if(!e)return null;var t=z(),r={appID:e,operationID:t,operationType:"getAppInstall"},n=new A,o=new Promise((function(e,t){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),F(r),o},exports.getManagementAPIToken=function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"getManagementAPIToken"},n=new A,o=new Promise((function(e){n.subscribe((function(t){var r=t.token;e(r),n.unsubscribe()}))}));return j({operationID:t,operation:n}),F(r),o}},exports.openAlertModal=function(e){var t=e.title,r=e.message,n=e.okButtonText,o=e.cancelButtonText,i=e.iconName,a=void 0===i?"":i,s=e.iconColor,u=void 0===s?"":s,c=e.callback,p=N();if(p){var l=z(),f=z(),v={appID:p,operationID:l,operationType:"openAlertModal",arg:{closeModalID:f,title:t,message:r,okButtonText:n,cancelButtonText:o,iconName:a,iconColor:u}},d=new A;j({operationID:l,operation:d});var b=new A;b.subscribe((function(e){c(null==e?void 0:e.ok),b.unsubscribe()})),j({operationID:f,operation:b}),F(v)}},exports.openModal=function(e){var t=e.name,r=e.title,n=e.props,o=e.callback,i=N();if(i){var a=z(),s=z(),u={appID:i,operationID:a,operationType:"openModal",arg:{closeModalID:s,title:r||null,name:t,props:n}},c=new A;j({operationID:a,operation:c});var p=new A;p.subscribe((function(e){o(null==e?void 0:e.props),p.unsubscribe()})),j({operationID:s,operation:p}),F(u)}},exports.pageMethods=K,exports.refresh=function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"refresh"},n=new A;j({operationID:t,operation:n}),F(r)}},exports.setExtraConfigValues=function(e){var t=N();if(t){var r=z(),n={appID:t,operationID:r,operationType:"setExtraConfigValues",arg:e},o=new A,i=new Promise((function(e,t){o.subscribe((function(t){e(t),o.unsubscribe()}))}));return j({operationID:r,operation:o}),F(n),i}},exports.setHeight=Y,exports.setVisibility=function(e){var t=e.fieldID,r=e.visibility,n=N();if(n){var o=z(),i={appID:n,operationID:o,operationType:"setVisibility",arg:{fieldID:t,visibility:r}},a=new A;j({operationID:o,operation:a}),F(i)}},exports.useAgilityAppSDK=function(){var t=e.useState(!0),r=t[0],n=t[1],o=e.useState(null),i=o[0],a=o[1],s=e.useState(null),u=s[0],c=s[1],p=e.useState(null),l=p[0],f=p[1],v=e.useState(null),d=v[0],b=v[1],h=e.useState(null),y=h[0],I=h[1],m=e.useState(null),D=m[0],g=m[1],w=e.useState(null),_=w[0];w[1];var S=e.useState(""),x=S[0],T=S[1],P=e.useState(null),O=P[0],E=P[1];return e.useEffect((function(){var e=N();if(e){var t=new A;t.subscribe((function(e){var r;e&&(a(e.app),c(e.instance),f(e.locale),b(e.field||null),g(e.contentItem||null),I(e.contentModel||null),E(e.modalProps||null),e.field&&(T((null===(r=e.contentItem)||void 0===r?void 0:r.values[e.field.name])||""),R({fieldName:e.field.name,onChange:function(e){T(e||"")}})),n(!1),t.unsubscribe())}));var r=z();return j({operationID:r,operation:t}),window.addEventListener("message",V,!1),F({appID:e,operationID:r,operationType:"initialize"}),function(){removeEventListener("message",V,!1)}}}),[]),{initializing:r,appInstallContext:i,instance:u,locale:l,field:d,contentItem:D,contentModel:y,pageItem:_,modalProps:O,fieldValue:x}},exports.useAgilityPreInstall=function(){var t=e.useState(!0),r=t[0],n=t[1],o=e.useState(null),i=o[0],a=o[1],s=e.useState(null),u=s[0];s[1];var c=e.useState(null),p=c[0];return c[1],e.useEffect((function(){var e=N();if(e){var t=new A;t.subscribe((function(e){e&&(a(e.app),n(!1),t.unsubscribe())}));var r=z();return j({operationID:r,operation:t}),window.addEventListener("message",V,!1),F({appID:e,operationID:r,operationType:"preInstall"}),function(){removeEventListener("message",V,!1)}}}),[]),{initializing:r,appInstallContext:i,instance:u,locale:p}},exports.useResizeHeight=function(t){return e.useCallback((function(e){null!==e&&new ResizeObserver((function(e){var r=e[0];if(r){var n=null!=t?t:0;Y({height:r.contentRect.height+n})}})).observe(e)}),[])}; | ||
"use strict";var e=require("react"),t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};function r(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function n(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function i(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function a(e){return"function"==typeof e}function s(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var u=s((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function c(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var p=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,s,c;if(!this.closed){this.closed=!0;var p=this._parentage;if(p)if(this._parentage=null,Array.isArray(p))try{for(var l=n(p),f=l.next();!f.done;f=l.next()){f.value.remove(this)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}else p.remove(this);var d=this.initialTeardown;if(a(d))try{d()}catch(e){c=e instanceof u?e.errors:[e]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var h=n(b),y=h.next();!y.done;y=h.next()){var I=y.value;try{v(I)}catch(e){c=null!=c?c:[],e instanceof u?c=i(i([],o(c)),o(e.errors)):c.push(e)}}}catch(e){r={error:e}}finally{try{y&&!y.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(c)throw new u(c)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)v(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&c(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&c(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),l=p.EMPTY;function f(e){return e instanceof p||e&&"closed"in e&&a(e.remove)&&a(e.add)&&a(e.unsubscribe)}function v(e){a(e)?e():e.unsubscribe()}var d={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},b={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var a=b.delegate;return(null==a?void 0:a.setTimeout)?a.setTimeout.apply(a,i([e,t],o(r))):setTimeout.apply(void 0,i([e,t],o(r)))},clearTimeout:function(e){var t=b.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function h(){}function y(e){e()}var I=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,f(t)&&t.add(r)):r.destination=S,r}return r(t,e),t.create=function(e,t,r){return new w(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(p),m=Function.prototype.bind;function D(e,t){return m.call(e,t)}var g=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){_(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){_(e)}else _(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){_(e)}},e}(),w=function(e){function t(t,r,n){var o,i,s=e.call(this)||this;a(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:s&&d.useDeprecatedNextContext?((i=Object.create(t)).unsubscribe=function(){return s.unsubscribe()},o={next:t.next&&D(t.next,i),error:t.error&&D(t.error,i),complete:t.complete&&D(t.complete,i)}):o=t;return s.destination=new g(o),s}return r(t,e),t}(I);function _(e){var t;t=e,b.setTimeout((function(){throw t}))}var S={closed:!0,next:h,error:function(e){throw e},complete:h},x="function"==typeof Symbol&&Symbol.observable||"@@observable";function T(e){return e}var P=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,i=(n=e)&&n instanceof I||function(e){return e&&a(e.next)&&a(e.error)&&a(e.complete)}(n)&&f(n)?e:new w(e,t,r);return y((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=O(t))((function(t,n){var o=new w({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[x]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?T:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=O(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function O(e){var t;return null!==(t=null!=e?e:d.Promise)&&void 0!==t?t:Promise}var C=s((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),E=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r(t,e),t.prototype.lift=function(e){var t=new A(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new C},t.prototype.next=function(e){var t=this;y((function(){var r,o;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=n(t.currentObservers),a=i.next();!a.done;a=i.next()){a.value.next(e)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;y((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;y((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,i=r.observers;return n||o?l:(this.currentObservers=null,i.push(e),new p((function(){t.currentObservers=null,c(i,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new P;return e.source=this,e},t.create=function(e,t){return new A(e,t)},t}(P),A=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return r(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:l},t}(E),M=0;var z=function(){return"operation-".concat(++M)},k={},j=function(e){var t=e.operationID,r=e.operation,n=e.autoDelete,o=void 0===n||n;return k[t]={operation:r,autoDelete:o},r},L=function(e){delete k[e]},V=function(e){var t=e.data,r=t.operationID;if(r){var n=function(e){var t=k[e];if(t){var r=t.operation;return t.autoDelete&&delete k[e],r||null}return null}(r);n&&n.next(t.arg||(null==t?void 0:t.error))}},F=function(e){window.parent.postMessage(e,"*")},N=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("appID"))&&void 0!==e?e:null},R=function(e){var t=e.fieldName,r=e.onChange,n=N();if(n){var o="".concat(t,"-").concat(n),i=o,a=function(e){var t=k[e];if(t){var r=t.operation;return t.autoDelete,r}return null}(o);if(a)a.subscribe((function(e){var t=e.fieldValue;r(t)}));else{var s={appID:n,operationID:i,operationType:"addFieldListener",arg:{fieldName:t,operationID:o,operationType:"onFieldChanged"}},u=new E;u.subscribe((function(e){var t=e.fieldValue;r(t)})),j({operationID:o,operation:u,autoDelete:!1}),F(s)}}},U=Object.freeze({__proto__:null,addFieldListener:R,addSelectedItemListener:function(e){var t=e.onChange,r=N();if(r){var n=z(),o="selectedItem-".concat(r),i={appID:r,operationID:n,operationType:"addSelectedItemListener",arg:{operationID:o,operationType:"onSelectedItemChange"}},a=new E;j({operationID:n,operation:a});var s=new E;s.subscribe((function(e){var r=e.selectedItems;t(r)})),j({operationID:o,operation:s,autoDelete:!1}),F(i)}},getContentItem:function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"getContentItem"},n=new E,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),F(r),o}},getSelectedItems:function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"getSelectedItems"},n=new E,o=new Promise((function(e){n.subscribe((function(t){var r=t.selectedItems;e(r),n.unsubscribe()}))}));return j({operationID:t,operation:n}),F(r),o}},removeFieldListener:function(e){var t=e.fieldName,r=N();if(r){var n=z(),o={appID:r,operationID:n,operationType:"removeFieldListener",arg:{fieldName:t,operationID:"".concat(t,"-").concat(r)}},i=new E;i.subscribe((function(e){var t=e.removeOperationID;L(t),i.unsubscribe()})),j({operationID:n,operation:i}),F(o)}},removeSelectedItemListener:function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"removeSelectedItemListener",arg:{operationID:"selectedItem-".concat(e)}},n=new E;n.subscribe((function(e){var t=e.removeOperationID;L(t),n.unsubscribe()})),j({operationID:t,operation:n}),F(r)}},saveContentItem:function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"saveContentItem"},n=new E;j({operationID:t,operation:n}),F(r)}},setFieldValue:function(e){var t=e.name,r=e.value,n=N();if(n){var o=z(),i={appID:n,operationID:o,operationType:"setFieldValue",arg:{name:t,value:r}},a=new E;j({operationID:o,operation:a}),F(i)}}}),B=Object.freeze({__proto__:null,persistData:function(e){var t=e.key,r=e.value,n=N();if(n){var o=z(),i={appID:n,operationID:o,operationType:"persistData",arg:{key:t,value:r}},a=new E,s=new Promise((function(e,t){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return j({operationID:o,operation:a}),F(i),s}},updateConfigurationValue:function(e){var t=e.name,r=e.value,n=N();if(n){var o=z(),i={appID:n,operationID:o,operationType:"updateConfigurationValue",arg:{name:t,value:r}},a=new E,s=new Promise((function(e){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return j({operationID:o,operation:a}),F(i),s}}}),H=Object.freeze({__proto__:null,selectAssets:function(e){var t=e.title,r=e.singleSelectOnly,n=e.callback,o=N();if(o){var i=z(),a=z(),s={appID:o,operationID:i,operationType:"selectAssets",arg:{closeModalID:a,title:t,singleSelectOnly:r}},u=new E;j({operationID:i,operation:u});var c=new E;c.subscribe((function(e){var t=e.assets;n(t),c.unsubscribe()})),j({operationID:a,operation:c}),F(s)}}}),K=Object.freeze({__proto__:null,getPageItem:function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"getPageItem"},n=new E,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),F(r),o}}}),Y=function(e){var t=e.height,r=N();if(r){var n=z(),o={appID:r,operationID:n,operationType:"setHeight",arg:{height:t}},i=new E;j({operationID:n,operation:i}),F(o)}};exports.assetsMethods=H,exports.closeModal=function(e){var t=N(),r=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("closeModalID"))&&void 0!==e?e:null}();if(t&&r){var n=z();F({appID:t,operationID:n,operationType:"closeModal",arg:{closeModalID:r,props:e}})}},exports.configMethods=B,exports.contentItemMethods=U,exports.getAPIKey=function(e){var t=e.apiType,r=N();if(r){var n=z(),o={appID:r,operationID:n,operationType:"getAPIKey",arg:{apiType:t}},i=new E,a=new Promise((function(e){i.subscribe((function(t){var r=t.apiKey;e(r),i.unsubscribe()}))}));return j({operationID:n,operation:i}),F(o),a}},exports.getAppInstall=function(){var e=N();if(!e)return null;var t=z(),r={appID:e,operationID:t,operationType:"getAppInstall"},n=new E,o=new Promise((function(e,t){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return j({operationID:t,operation:n}),F(r),o},exports.getManagementAPIToken=function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"getManagementAPIToken"},n=new E,o=new Promise((function(e){n.subscribe((function(t){var r=t.token;e(r),n.unsubscribe()}))}));return j({operationID:t,operation:n}),F(r),o}},exports.openAlertModal=function(e){var t=e.title,r=e.message,n=e.okButtonText,o=e.cancelButtonText,i=e.iconName,a=void 0===i?"":i,s=e.iconColor,u=void 0===s?"":s,c=e.callback,p=N();if(p){var l=z(),f=z(),v={appID:p,operationID:l,operationType:"openAlertModal",arg:{closeModalID:f,title:t,message:r,okButtonText:n,cancelButtonText:o,iconName:a,iconColor:u}},d=new E;j({operationID:l,operation:d});var b=new E;b.subscribe((function(e){c(null==e?void 0:e.ok),b.unsubscribe()})),j({operationID:f,operation:b}),F(v)}},exports.openModal=function(e){var t=e.name,r=e.title,n=e.props,o=e.callback,i=N();if(i){var a=z(),s=z(),u={appID:i,operationID:a,operationType:"openModal",arg:{closeModalID:s,title:r||null,name:t,props:n}},c=new E;j({operationID:a,operation:c});var p=new E;p.subscribe((function(e){o(null==e?void 0:e.props),p.unsubscribe()})),j({operationID:s,operation:p}),F(u)}},exports.pageMethods=K,exports.refresh=function(){var e=N();if(e){var t=z(),r={appID:e,operationID:t,operationType:"refresh"},n=new E;j({operationID:t,operation:n}),F(r)}},exports.setExtraConfigValues=function(e){var t=N();if(t){var r=z(),n={appID:t,operationID:r,operationType:"setExtraConfigValues",arg:e},o=new E,i=new Promise((function(e,t){o.subscribe((function(t){e(t),o.unsubscribe()}))}));return j({operationID:r,operation:o}),F(n),i}},exports.setHeight=Y,exports.setVisibility=function(e){var t=e.fieldID,r=e.visibility,n=N();if(n){var o=z(),i={appID:n,operationID:o,operationType:"setVisibility",arg:{fieldID:t,visibility:r}},a=new E;j({operationID:o,operation:a}),F(i)}},exports.useAgilityAppSDK=function(){var t=e.useState(!0),r=t[0],n=t[1],o=e.useState(null),i=o[0],a=o[1],s=e.useState(null),u=s[0],c=s[1],p=e.useState(null),l=p[0],f=p[1],v=e.useState(null),d=v[0],b=v[1],h=e.useState(null),y=h[0],I=h[1],m=e.useState(null),D=m[0],g=m[1],w=e.useState(null),_=w[0];w[1];var S=e.useState(""),x=S[0],T=S[1],P=e.useState(null),O=P[0],C=P[1];return e.useEffect((function(){var e=N();if(e){var t=new E;t.subscribe((function(e){var r;e&&(a(e.app),c(e.instance),f(e.locale),b(e.field||null),g(e.contentItem||null),I(e.contentModel||null),C(e.modalProps||null),e.field&&(T((null===(r=e.contentItem)||void 0===r?void 0:r.values[e.field.name])||""),R({fieldName:e.field.name,onChange:function(e){T(e||"")}})),n(!1),t.unsubscribe())}));var r=z();return j({operationID:r,operation:t}),window.addEventListener("message",V,!1),F({appID:e,operationID:r,operationType:"initialize"}),function(){removeEventListener("message",V,!1)}}}),[]),{initializing:r,appInstallContext:i,instance:u,locale:l,field:d,contentItem:D,contentModel:y,pageItem:_,modalProps:O,fieldValue:x}},exports.useAgilityPreInstall=function(){var t=e.useState(!0),r=t[0],n=t[1],o=e.useState(null),i=o[0],a=o[1],s=e.useState(null),u=s[0];s[1];var c=e.useState(null),p=c[0];return c[1],e.useEffect((function(){var e=N();if(e){var t=new E;t.subscribe((function(e){e&&(a(e.app),n(!1),t.unsubscribe())}));var r=z();return j({operationID:r,operation:t}),window.addEventListener("message",V,!1),F({appID:e,operationID:r,operationType:"preInstall"}),function(){removeEventListener("message",V,!1)}}}),[]),{initializing:r,appInstallContext:i,instance:u,locale:p}},exports.useResizeHeight=function(t){return e.useCallback((function(e){null!==e&&new ResizeObserver((function(e){var r=e[0];if(r){var n=null!=t?t:0;Y({height:r.contentRect.height+n})}})).observe(e)}),[])}; | ||
//# sourceMappingURL=index.js.map |
@@ -8,1 +8,2 @@ export * from "./getContentItem"; | ||
export * from "./removeSelectedItemListener"; | ||
export * from "./saveContentItem"; |
@@ -1,2 +0,2 @@ | ||
import{useState as e,useEffect as t,useCallback as r}from"react";var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function i(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function s(e){return"function"==typeof e}function c(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var p=c((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function l(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var f=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var l=i(c),f=l.next();!f.done;f=l.next()){f.value.remove(this)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}else c.remove(this);var v=this.initialTeardown;if(s(v))try{v()}catch(e){o=e instanceof p?e.errors:[e]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var h=i(d),y=h.next();!y.done;y=h.next()){var I=y.value;try{b(I)}catch(e){o=null!=o?o:[],e instanceof p?o=u(u([],a(o)),a(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{y&&!y.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}}if(o)throw new p(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)b(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&l(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&l(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),v=f.EMPTY;function d(e){return e instanceof f||e&&"closed"in e&&s(e.remove)&&s(e.add)&&s(e.unsubscribe)}function b(e){s(e)?e():e.unsubscribe()}var h={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},y={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=y.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,u([e,t],a(r))):setTimeout.apply(void 0,u([e,t],a(r)))},clearTimeout:function(e){var t=y.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function I(){}function m(e){e()}var D=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,d(t)&&t.add(r)):r.destination=x,r}return o(t,e),t.create=function(e,t,r){return new S(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(f),w=Function.prototype.bind;function g(e,t){return w.call(e,t)}var _=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){T(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){T(e)}else T(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){T(e)}},e}(),S=function(e){function t(t,r,n){var o,i,a=e.call(this)||this;s(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:a&&h.useDeprecatedNextContext?((i=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},o={next:t.next&&g(t.next,i),error:t.error&&g(t.error,i),complete:t.complete&&g(t.complete,i)}):o=t;return a.destination=new _(o),a}return o(t,e),t}(D);function T(e){var t;t=e,y.setTimeout((function(){throw t}))}var x={closed:!0,next:I,error:function(e){throw e},complete:I},O="function"==typeof Symbol&&Symbol.observable||"@@observable";function P(e){return e}var E=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,i=(n=e)&&n instanceof D||function(e){return e&&s(e.next)&&s(e.error)&&s(e.complete)}(n)&&d(n)?e:new S(e,t,r);return m((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=C(t))((function(t,n){var o=new S({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[O]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?P:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=C(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function C(e){var t;return null!==(t=null!=e?e:h.Promise)&&void 0!==t?t:Promise}var A=c((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),M=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return o(t,e),t.prototype.lift=function(e){var t=new z(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new A},t.prototype.next=function(e){var t=this;m((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=i(t.currentObservers),a=o.next();!a.done;a=o.next()){a.value.next(e)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;m((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;m((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,i=r.observers;return n||o?v:(this.currentObservers=null,i.push(e),new f((function(){t.currentObservers=null,l(i,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new E;return e.source=this,e},t.create=function(e,t){return new z(e,t)},t}(E),z=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return o(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:v},t}(M),j=0;var k=function(){return"operation-".concat(++j)},L={},F=function(e){var t=e.operationID,r=e.operation,n=e.autoDelete,o=void 0===n||n;return L[t]={operation:r,autoDelete:o},r},N=function(e){delete L[e]},V=function(e){var t=e.data,r=t.operationID;if(r){var n=function(e){var t=L[e];if(t){var r=t.operation;return t.autoDelete&&delete L[e],r||null}return null}(r);n&&n.next(t.arg||(null==t?void 0:t.error))}},U=function(e){window.parent.postMessage(e,"*")},B=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("appID"))&&void 0!==e?e:null},R=function(e){var t=e.fieldName,r=e.onChange,n=B();if(n){var o="".concat(t,"-").concat(n),i=o,a=function(e){var t=L[e];if(t){var r=t.operation;return t.autoDelete,r}return null}(o);if(a)a.subscribe((function(e){var t=e.fieldValue;r(t)}));else{var u={appID:n,operationID:i,operationType:"addFieldListener",arg:{fieldName:t,operationID:o,operationType:"onFieldChanged"}},s=new M;s.subscribe((function(e){var t=e.fieldValue;r(t)})),F({operationID:o,operation:s,autoDelete:!1}),U(u)}}},H=Object.freeze({__proto__:null,addFieldListener:R,addSelectedItemListener:function(e){var t=e.onChange,r=B();if(r){var n=k(),o="selectedItem-".concat(r),i={appID:r,operationID:n,operationType:"addSelectedItemListener",arg:{operationID:o,operationType:"onSelectedItemChange"}},a=new M;F({operationID:n,operation:a});var u=new M;u.subscribe((function(e){var r=e.selectedItems;t(r)})),F({operationID:o,operation:u,autoDelete:!1}),U(i)}},getContentItem:function(){var e=B();if(e){var t=k(),r={appID:e,operationID:t,operationType:"getContentItem"},n=new M,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return F({operationID:t,operation:n}),U(r),o}},getSelectedItems:function(){var e=B();if(e){var t=k(),r={appID:e,operationID:t,operationType:"getSelectedItems"},n=new M,o=new Promise((function(e){n.subscribe((function(t){var r=t.selectedItems;e(r),n.unsubscribe()}))}));return F({operationID:t,operation:n}),U(r),o}},removeFieldListener:function(e){var t=e.fieldName,r=B();if(r){var n=k(),o={appID:r,operationID:n,operationType:"removeFieldListener",arg:{fieldName:t,operationID:"".concat(t,"-").concat(r)}},i=new M;i.subscribe((function(e){var t=e.removeOperationID;N(t),i.unsubscribe()})),F({operationID:n,operation:i}),U(o)}},removeSelectedItemListener:function(){var e=B();if(e){var t=k(),r={appID:e,operationID:t,operationType:"removeSelectedItemListener",arg:{operationID:"selectedItem-".concat(e)}},n=new M;n.subscribe((function(e){var t=e.removeOperationID;N(t),n.unsubscribe()})),F({operationID:t,operation:n}),U(r)}},setFieldValue:function(e){var t=e.name,r=e.value,n=B();if(n){var o=k(),i={appID:n,operationID:o,operationType:"setFieldValue",arg:{name:t,value:r}},a=new M;F({operationID:o,operation:a}),U(i)}}}),K=function(){var r=e(!0),n=r[0],o=r[1],i=e(null),a=i[0],u=i[1],s=e(null),c=s[0],p=s[1],l=e(null),f=l[0],v=l[1],d=e(null),b=d[0],h=d[1],y=e(null),I=y[0],m=y[1],D=e(null),w=D[0],g=D[1],_=e(null),S=_[0];_[1];var T=e(""),x=T[0],O=T[1],P=e(null),E=P[0],C=P[1];return t((function(){var e=B();if(e){var t=new M;t.subscribe((function(e){var r;e&&(u(e.app),p(e.instance),v(e.locale),h(e.field||null),g(e.contentItem||null),m(e.contentModel||null),C(e.modalProps||null),e.field&&(O((null===(r=e.contentItem)||void 0===r?void 0:r.values[e.field.name])||""),R({fieldName:e.field.name,onChange:function(e){O(e||"")}})),o(!1),t.unsubscribe())}));var r=k();return F({operationID:r,operation:t}),window.addEventListener("message",V,!1),U({appID:e,operationID:r,operationType:"initialize"}),function(){removeEventListener("message",V,!1)}}}),[]),{initializing:n,appInstallContext:a,instance:c,locale:f,field:b,contentItem:w,contentModel:I,pageItem:S,modalProps:E,fieldValue:x}},Y=function(){var r=e(!0),n=r[0],o=r[1],i=e(null),a=i[0],u=i[1],s=e(null),c=s[0];s[1];var p=e(null),l=p[0];return p[1],t((function(){var e=B();if(e){var t=new M;t.subscribe((function(e){e&&(u(e.app),o(!1),t.unsubscribe())}));var r=k();return F({operationID:r,operation:t}),window.addEventListener("message",V,!1),U({appID:e,operationID:r,operationType:"preInstall"}),function(){removeEventListener("message",V,!1)}}}),[]),{initializing:n,appInstallContext:a,instance:c,locale:l}},q=Object.freeze({__proto__:null,persistData:function(e){var t=e.key,r=e.value,n=B();if(n){var o=k(),i={appID:n,operationID:o,operationType:"persistData",arg:{key:t,value:r}},a=new M,u=new Promise((function(e,t){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return F({operationID:o,operation:a}),U(i),u}},updateConfigurationValue:function(e){var t=e.name,r=e.value,n=B();if(n){var o=k(),i={appID:n,operationID:o,operationType:"updateConfigurationValue",arg:{name:t,value:r}},a=new M,u=new Promise((function(e){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return F({operationID:o,operation:a}),U(i),u}}}),G=Object.freeze({__proto__:null,selectAssets:function(e){var t=e.title,r=e.singleSelectOnly,n=e.callback,o=B();if(o){var i=k(),a=k(),u={appID:o,operationID:i,operationType:"selectAssets",arg:{closeModalID:a,title:t,singleSelectOnly:r}},s=new M;F({operationID:i,operation:s});var c=new M;c.subscribe((function(e){var t=e.assets;n(t),c.unsubscribe()})),F({operationID:a,operation:c}),U(u)}}}),J=Object.freeze({__proto__:null,getPageItem:function(){var e=B();if(e){var t=k(),r={appID:e,operationID:t,operationType:"getPageItem"},n=new M,o=new Promise((function(e){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return F({operationID:t,operation:n}),U(r),o}}}),Q=function(e){var t=e.height,r=B();if(r){var n=k(),o={appID:r,operationID:n,operationType:"setHeight",arg:{height:t}},i=new M;F({operationID:n,operation:i}),U(o)}},W=function(e){var t=e.title,r=e.message,n=e.okButtonText,o=e.cancelButtonText,i=e.iconName,a=void 0===i?"":i,u=e.iconColor,s=void 0===u?"":u,c=e.callback,p=B();if(p){var l=k(),f=k(),v={appID:p,operationID:l,operationType:"openAlertModal",arg:{closeModalID:f,title:t,message:r,okButtonText:n,cancelButtonText:o,iconName:a,iconColor:s}},d=new M;F({operationID:l,operation:d});var b=new M;b.subscribe((function(e){c(null==e?void 0:e.ok),b.unsubscribe()})),F({operationID:f,operation:b}),U(v)}},X=function(e){var t=e.name,r=e.title,n=e.props,o=e.callback,i=B();if(i){var a=k(),u=k(),s={appID:i,operationID:a,operationType:"openModal",arg:{closeModalID:u,title:r||null,name:t,props:n}},c=new M;F({operationID:a,operation:c});var p=new M;p.subscribe((function(e){o(null==e?void 0:e.props),p.unsubscribe()})),F({operationID:u,operation:p}),U(s)}},Z=function(e){var t=B(),r=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("closeModalID"))&&void 0!==e?e:null}();if(t&&r){var n=k();U({appID:t,operationID:n,operationType:"closeModal",arg:{closeModalID:r,props:e}})}},$=function(){var e=B();if(!e)return null;var t=k(),r={appID:e,operationID:t,operationType:"getAppInstall"},n=new M,o=new Promise((function(e,t){n.subscribe((function(t){e(t),n.unsubscribe()}))}));return F({operationID:t,operation:n}),U(r),o},ee=function(){var e=B();if(e){var t=k(),r={appID:e,operationID:t,operationType:"refresh"},n=new M;F({operationID:t,operation:n}),U(r)}},te=function(e){var t=e.fieldID,r=e.visibility,n=B();if(n){var o=k(),i={appID:n,operationID:o,operationType:"setVisibility",arg:{fieldID:t,visibility:r}},a=new M;F({operationID:o,operation:a}),U(i)}},re=function(e){var t=B();if(t){var r=k(),n={appID:t,operationID:r,operationType:"setExtraConfigValues",arg:e},o=new M,i=new Promise((function(e,t){o.subscribe((function(t){e(t),o.unsubscribe()}))}));return F({operationID:r,operation:o}),U(n),i}},ne=function(){var e=B();if(e){var t=k(),r={appID:e,operationID:t,operationType:"getManagementAPIToken"},n=new M,o=new Promise((function(e){n.subscribe((function(t){var r=t.token;e(r),n.unsubscribe()}))}));return F({operationID:t,operation:n}),U(r),o}},oe=function(e){var t=e.apiType,r=B();if(r){var n=k(),o={appID:r,operationID:n,operationType:"getAPIKey",arg:{apiType:t}},i=new M,a=new Promise((function(e){i.subscribe((function(t){var r=t.apiKey;e(r),i.unsubscribe()}))}));return F({operationID:n,operation:i}),U(o),a}},ie=function(e){return r((function(t){null!==t&&new ResizeObserver((function(t){var r=t[0];if(r){var n=null!=e?e:0;Q({height:r.contentRect.height+n})}})).observe(t)}),[])};export{G as assetsMethods,Z as closeModal,q as configMethods,H as contentItemMethods,oe as getAPIKey,$ as getAppInstall,ne as getManagementAPIToken,W as openAlertModal,X as openModal,J as pageMethods,ee as refresh,re as setExtraConfigValues,Q as setHeight,te as setVisibility,K as useAgilityAppSDK,Y as useAgilityPreInstall,ie as useResizeHeight}; | ||
import{useState as e,useEffect as t,useCallback as n}from"react";var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function s(e){return"function"==typeof e}function c(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var p=c((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function l(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var f=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,n,r,o;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var l=i(c),f=l.next();!f.done;f=l.next()){f.value.remove(this)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}else c.remove(this);var v=this.initialTeardown;if(s(v))try{v()}catch(e){o=e instanceof p?e.errors:[e]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var h=i(d),y=h.next();!y.done;y=h.next()){var I=y.value;try{b(I)}catch(e){o=null!=o?o:[],e instanceof p?o=u(u([],a(o)),a(e.errors)):o.push(e)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}}if(o)throw new p(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)b(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&l(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&l(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),v=f.EMPTY;function d(e){return e instanceof f||e&&"closed"in e&&s(e.remove)&&s(e.add)&&s(e.unsubscribe)}function b(e){s(e)?e():e.unsubscribe()}var h={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},y={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=y.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,u([e,t],a(n))):setTimeout.apply(void 0,u([e,t],a(n)))},clearTimeout:function(e){var t=y.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function I(){}function m(e){e()}var D=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,d(t)&&t.add(n)):n.destination=x,n}return o(t,e),t.create=function(e,t,n){return new T(e,t,n)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(f),w=Function.prototype.bind;function g(e,t){return w.call(e,t)}var _=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){S(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){S(e)}else S(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){S(e)}},e}(),T=function(e){function t(t,n,r){var o,i,a=e.call(this)||this;s(t)||!t?o={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:a&&h.useDeprecatedNextContext?((i=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},o={next:t.next&&g(t.next,i),error:t.error&&g(t.error,i),complete:t.complete&&g(t.complete,i)}):o=t;return a.destination=new _(o),a}return o(t,e),t}(D);function S(e){var t;t=e,y.setTimeout((function(){throw t}))}var x={closed:!0,next:I,error:function(e){throw e},complete:I},O="function"==typeof Symbol&&Symbol.observable||"@@observable";function P(e){return e}var C=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r,o=this,i=(r=e)&&r instanceof D||function(e){return e&&s(e.next)&&s(e.error)&&s(e.complete)}(r)&&d(r)?e:new T(e,t,n);return m((function(){var e=o,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?o._subscribe(i):o._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=E(t))((function(t,r){var o=new T({next:function(t){try{e(t)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t});n.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[O]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(0===(e=t).length?P:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=E(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function E(e){var t;return null!==(t=null!=e?e:h.Promise)&&void 0!==t?t:Promise}var A=c((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),M=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return o(t,e),t.prototype.lift=function(e){var t=new z(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new A},t.prototype.next=function(e){var t=this;m((function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=i(t.currentObservers),a=o.next();!a.done;a=o.next()){a.value.next(e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;m((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}}))},t.prototype.complete=function(){var e=this;m((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,o=n.isStopped,i=n.observers;return r||o?v:(this.currentObservers=null,i.push(e),new f((function(){t.currentObservers=null,l(i,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new C;return e.source=this,e},t.create=function(e,t){return new z(e,t)},t}(C),z=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return o(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:v},t}(M),j=0;var k=function(){return"operation-".concat(++j)},L={},F=function(e){var t=e.operationID,n=e.operation,r=e.autoDelete,o=void 0===r||r;return L[t]={operation:n,autoDelete:o},n},N=function(e){delete L[e]},V=function(e){var t=e.data,n=t.operationID;if(n){var r=function(e){var t=L[e];if(t){var n=t.operation;return t.autoDelete&&delete L[e],n||null}return null}(n);r&&r.next(t.arg||(null==t?void 0:t.error))}},U=function(e){window.parent.postMessage(e,"*")},B=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("appID"))&&void 0!==e?e:null},R=function(e){var t=e.fieldName,n=e.onChange,r=B();if(r){var o="".concat(t,"-").concat(r),i=o,a=function(e){var t=L[e];if(t){var n=t.operation;return t.autoDelete,n}return null}(o);if(a)a.subscribe((function(e){var t=e.fieldValue;n(t)}));else{var u={appID:r,operationID:i,operationType:"addFieldListener",arg:{fieldName:t,operationID:o,operationType:"onFieldChanged"}},s=new M;s.subscribe((function(e){var t=e.fieldValue;n(t)})),F({operationID:o,operation:s,autoDelete:!1}),U(u)}}},H=Object.freeze({__proto__:null,addFieldListener:R,addSelectedItemListener:function(e){var t=e.onChange,n=B();if(n){var r=k(),o="selectedItem-".concat(n),i={appID:n,operationID:r,operationType:"addSelectedItemListener",arg:{operationID:o,operationType:"onSelectedItemChange"}},a=new M;F({operationID:r,operation:a});var u=new M;u.subscribe((function(e){var n=e.selectedItems;t(n)})),F({operationID:o,operation:u,autoDelete:!1}),U(i)}},getContentItem:function(){var e=B();if(e){var t=k(),n={appID:e,operationID:t,operationType:"getContentItem"},r=new M,o=new Promise((function(e){r.subscribe((function(t){e(t),r.unsubscribe()}))}));return F({operationID:t,operation:r}),U(n),o}},getSelectedItems:function(){var e=B();if(e){var t=k(),n={appID:e,operationID:t,operationType:"getSelectedItems"},r=new M,o=new Promise((function(e){r.subscribe((function(t){var n=t.selectedItems;e(n),r.unsubscribe()}))}));return F({operationID:t,operation:r}),U(n),o}},removeFieldListener:function(e){var t=e.fieldName,n=B();if(n){var r=k(),o={appID:n,operationID:r,operationType:"removeFieldListener",arg:{fieldName:t,operationID:"".concat(t,"-").concat(n)}},i=new M;i.subscribe((function(e){var t=e.removeOperationID;N(t),i.unsubscribe()})),F({operationID:r,operation:i}),U(o)}},removeSelectedItemListener:function(){var e=B();if(e){var t=k(),n={appID:e,operationID:t,operationType:"removeSelectedItemListener",arg:{operationID:"selectedItem-".concat(e)}},r=new M;r.subscribe((function(e){var t=e.removeOperationID;N(t),r.unsubscribe()})),F({operationID:t,operation:r}),U(n)}},saveContentItem:function(){var e=B();if(e){var t=k(),n={appID:e,operationID:t,operationType:"saveContentItem"},r=new M;F({operationID:t,operation:r}),U(n)}},setFieldValue:function(e){var t=e.name,n=e.value,r=B();if(r){var o=k(),i={appID:r,operationID:o,operationType:"setFieldValue",arg:{name:t,value:n}},a=new M;F({operationID:o,operation:a}),U(i)}}}),K=function(){var n=e(!0),r=n[0],o=n[1],i=e(null),a=i[0],u=i[1],s=e(null),c=s[0],p=s[1],l=e(null),f=l[0],v=l[1],d=e(null),b=d[0],h=d[1],y=e(null),I=y[0],m=y[1],D=e(null),w=D[0],g=D[1],_=e(null),T=_[0];_[1];var S=e(""),x=S[0],O=S[1],P=e(null),C=P[0],E=P[1];return t((function(){var e=B();if(e){var t=new M;t.subscribe((function(e){var n;e&&(u(e.app),p(e.instance),v(e.locale),h(e.field||null),g(e.contentItem||null),m(e.contentModel||null),E(e.modalProps||null),e.field&&(O((null===(n=e.contentItem)||void 0===n?void 0:n.values[e.field.name])||""),R({fieldName:e.field.name,onChange:function(e){O(e||"")}})),o(!1),t.unsubscribe())}));var n=k();return F({operationID:n,operation:t}),window.addEventListener("message",V,!1),U({appID:e,operationID:n,operationType:"initialize"}),function(){removeEventListener("message",V,!1)}}}),[]),{initializing:r,appInstallContext:a,instance:c,locale:f,field:b,contentItem:w,contentModel:I,pageItem:T,modalProps:C,fieldValue:x}},Y=function(){var n=e(!0),r=n[0],o=n[1],i=e(null),a=i[0],u=i[1],s=e(null),c=s[0];s[1];var p=e(null),l=p[0];return p[1],t((function(){var e=B();if(e){var t=new M;t.subscribe((function(e){e&&(u(e.app),o(!1),t.unsubscribe())}));var n=k();return F({operationID:n,operation:t}),window.addEventListener("message",V,!1),U({appID:e,operationID:n,operationType:"preInstall"}),function(){removeEventListener("message",V,!1)}}}),[]),{initializing:r,appInstallContext:a,instance:c,locale:l}},q=Object.freeze({__proto__:null,persistData:function(e){var t=e.key,n=e.value,r=B();if(r){var o=k(),i={appID:r,operationID:o,operationType:"persistData",arg:{key:t,value:n}},a=new M,u=new Promise((function(e,t){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return F({operationID:o,operation:a}),U(i),u}},updateConfigurationValue:function(e){var t=e.name,n=e.value,r=B();if(r){var o=k(),i={appID:r,operationID:o,operationType:"updateConfigurationValue",arg:{name:t,value:n}},a=new M,u=new Promise((function(e){a.subscribe((function(t){e(t),a.unsubscribe()}))}));return F({operationID:o,operation:a}),U(i),u}}}),G=Object.freeze({__proto__:null,selectAssets:function(e){var t=e.title,n=e.singleSelectOnly,r=e.callback,o=B();if(o){var i=k(),a=k(),u={appID:o,operationID:i,operationType:"selectAssets",arg:{closeModalID:a,title:t,singleSelectOnly:n}},s=new M;F({operationID:i,operation:s});var c=new M;c.subscribe((function(e){var t=e.assets;r(t),c.unsubscribe()})),F({operationID:a,operation:c}),U(u)}}}),J=Object.freeze({__proto__:null,getPageItem:function(){var e=B();if(e){var t=k(),n={appID:e,operationID:t,operationType:"getPageItem"},r=new M,o=new Promise((function(e){r.subscribe((function(t){e(t),r.unsubscribe()}))}));return F({operationID:t,operation:r}),U(n),o}}}),Q=function(e){var t=e.height,n=B();if(n){var r=k(),o={appID:n,operationID:r,operationType:"setHeight",arg:{height:t}},i=new M;F({operationID:r,operation:i}),U(o)}},W=function(e){var t=e.title,n=e.message,r=e.okButtonText,o=e.cancelButtonText,i=e.iconName,a=void 0===i?"":i,u=e.iconColor,s=void 0===u?"":u,c=e.callback,p=B();if(p){var l=k(),f=k(),v={appID:p,operationID:l,operationType:"openAlertModal",arg:{closeModalID:f,title:t,message:n,okButtonText:r,cancelButtonText:o,iconName:a,iconColor:s}},d=new M;F({operationID:l,operation:d});var b=new M;b.subscribe((function(e){c(null==e?void 0:e.ok),b.unsubscribe()})),F({operationID:f,operation:b}),U(v)}},X=function(e){var t=e.name,n=e.title,r=e.props,o=e.callback,i=B();if(i){var a=k(),u=k(),s={appID:i,operationID:a,operationType:"openModal",arg:{closeModalID:u,title:n||null,name:t,props:r}},c=new M;F({operationID:a,operation:c});var p=new M;p.subscribe((function(e){o(null==e?void 0:e.props),p.unsubscribe()})),F({operationID:u,operation:p}),U(s)}},Z=function(e){var t=B(),n=function(){var e;if("undefined"==typeof window)return null;var t=window.location.search;return null!==(e=new URLSearchParams(t).get("closeModalID"))&&void 0!==e?e:null}();if(t&&n){var r=k();U({appID:t,operationID:r,operationType:"closeModal",arg:{closeModalID:n,props:e}})}},$=function(){var e=B();if(!e)return null;var t=k(),n={appID:e,operationID:t,operationType:"getAppInstall"},r=new M,o=new Promise((function(e,t){r.subscribe((function(t){e(t),r.unsubscribe()}))}));return F({operationID:t,operation:r}),U(n),o},ee=function(){var e=B();if(e){var t=k(),n={appID:e,operationID:t,operationType:"refresh"},r=new M;F({operationID:t,operation:r}),U(n)}},te=function(e){var t=e.fieldID,n=e.visibility,r=B();if(r){var o=k(),i={appID:r,operationID:o,operationType:"setVisibility",arg:{fieldID:t,visibility:n}},a=new M;F({operationID:o,operation:a}),U(i)}},ne=function(e){var t=B();if(t){var n=k(),r={appID:t,operationID:n,operationType:"setExtraConfigValues",arg:e},o=new M,i=new Promise((function(e,t){o.subscribe((function(t){e(t),o.unsubscribe()}))}));return F({operationID:n,operation:o}),U(r),i}},re=function(){var e=B();if(e){var t=k(),n={appID:e,operationID:t,operationType:"getManagementAPIToken"},r=new M,o=new Promise((function(e){r.subscribe((function(t){var n=t.token;e(n),r.unsubscribe()}))}));return F({operationID:t,operation:r}),U(n),o}},oe=function(e){var t=e.apiType,n=B();if(n){var r=k(),o={appID:n,operationID:r,operationType:"getAPIKey",arg:{apiType:t}},i=new M,a=new Promise((function(e){i.subscribe((function(t){var n=t.apiKey;e(n),i.unsubscribe()}))}));return F({operationID:r,operation:i}),U(o),a}},ie=function(e){return n((function(t){null!==t&&new ResizeObserver((function(t){var n=t[0];if(n){var r=null!=e?e:0;Q({height:n.contentRect.height+r})}})).observe(t)}),[])};export{G as assetsMethods,Z as closeModal,q as configMethods,H as contentItemMethods,oe as getAPIKey,$ as getAppInstall,re as getManagementAPIToken,W as openAlertModal,X as openModal,J as pageMethods,ee as refresh,ne as setExtraConfigValues,Q as setHeight,te as setVisibility,K as useAgilityAppSDK,Y as useAgilityPreInstall,ie as useResizeHeight}; | ||
//# sourceMappingURL=index.js.map |
@@ -8,1 +8,2 @@ export * from "./getContentItem"; | ||
export * from "./removeSelectedItemListener"; | ||
export * from "./saveContentItem"; |
@@ -496,2 +496,9 @@ interface IAppConfigValue { | ||
/** | ||
* Saves the currently open content item. | ||
* Only available from the Content Item Sidebar surfaces. | ||
* @returns | ||
*/ | ||
declare const saveContentItem: () => void; | ||
declare const index_d$2_addFieldListener: typeof addFieldListener; | ||
@@ -503,2 +510,3 @@ declare const index_d$2_addSelectedItemListener: typeof addSelectedItemListener; | ||
declare const index_d$2_removeSelectedItemListener: typeof removeSelectedItemListener; | ||
declare const index_d$2_saveContentItem: typeof saveContentItem; | ||
declare const index_d$2_setFieldValue: typeof setFieldValue; | ||
@@ -513,2 +521,3 @@ declare namespace index_d$2 { | ||
index_d$2_removeSelectedItemListener as removeSelectedItemListener, | ||
index_d$2_saveContentItem as saveContentItem, | ||
index_d$2_setFieldValue as setFieldValue, | ||
@@ -515,0 +524,0 @@ }; |
{ | ||
"name": "@agility/app-sdk", | ||
"version": "2.0.5-rc1", | ||
"version": "2.0.5-rc2", | ||
"description": "JavaScript library for building Agility CMS apps.", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
261910
185
2621