brew-js-react 0.5.4 → 0.5.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/brew.d.ts +9 -0
- package/dist/brew-js-react.js +267 -194
- package/dist/brew-js-react.js.map +1 -1
- package/dist/brew-js-react.min.js +2 -2
- package/dist/brew-js-react.min.js.map +1 -1
- package/entry.js +7 -4
- package/hooks.d.ts +22 -0
- package/hooks.js +63 -19
- package/mixin.js +9 -9
- package/mixins/FlyoutMixin.js +13 -15
- package/package.json +3 -3
- package/view.d.ts +43 -0
- package/view.js +73 -50
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! brew-js-react v0.5.
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("brew-js"),require("react"),require("react-dom"),require("zeta-dom"),require("zeta-dom-react"),require("waterpipe"),require("jquery")):"function"==typeof define&&define.amd?define("brew-js-react",["brew-js","react","react-dom","zeta-dom","zeta-dom-react","waterpipe","jquery"],t):"object"==typeof exports?exports["brew-js-react"]=t(require("brew-js"),require("react"),require("react-dom"),require("zeta-dom"),require("zeta-dom-react"),require("waterpipe"),require("jquery")):e["brew-js-react"]=t(e.brew,e.React,e.ReactDOM,e.zeta,e["zeta-dom-react"],e.waterpipe,e.jQuery)}(self,((e,t,n,i,r,o,a)=>(()=>{var s={87:e=>{"use strict";e.exports=o},9:e=>{"use strict";e.exports=r},760:t=>{"use strict";t.exports=e},914:e=>{"use strict";e.exports=a},12:e=>{"use strict";e.exports=t},33:e=>{"use strict";e.exports=n},231:e=>{"use strict";e.exports=i},621:(e,t,n)=>{var i,r=n(33);i=r.createRoot?r:{createRoot:(e,t)=>({render(t){r.render(t,e)},unmount(){r.unmountComponentAtNode(e)}}),hydrateRoot:(e,t,n)=>(r.hydrate(t,e),i.createRoot(e,n))},e.exports=i}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return s[e](n,n.exports,c),n.exports}c.d=(e,t)=>{for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{"use strict";c.d(l,{default:()=>fn});var e={};c.r(e),c.d(e,{AnimateMixin:()=>At,AnimateSequenceItemMixin:()=>Vt,AnimateSequenceMixin:()=>jt,ClassNameMixin:()=>Mt,ClassNameToggleMixin:()=>Ft,Dialog:()=>de,FlyoutMixin:()=>Ut,FlyoutToggleMixin:()=>Lt,FocusStateMixin:()=>Bt,LoadingStateMixin:()=>Wt,Mixin:()=>wt,ScrollIntoViewMixin:()=>Gt,ScrollableMixin:()=>$t,StatefulMixin:()=>Et,UnmanagedClassNameMixin:()=>Jt,ViewStateContainer:()=>ct,createDialog:()=>he,default:()=>ln,isViewMatched:()=>He,linkTo:()=>Ke,makeTranslation:()=>gt,matchView:()=>We,navigateTo:()=>Xe,redirectTo:()=>Ye,registerErrorView:()=>$e,registerView:()=>Qe,renderView:()=>Ge,resolvePath:()=>Je,useAnimateMixin:()=>Yt,useAnimateSequenceMixin:()=>Zt,useAppReady:()=>ot,useAppReadyState:()=>at,useClassNameToggleMixin:()=>en,useFlyoutMixin:()=>tn,useFocusStateMixin:()=>nn,useLanguage:()=>dt,useLoadingStateMixin:()=>rn,useMixin:()=>un,useMixinRef:()=>cn,useRouteParam:()=>st,useRouteState:()=>ut,useScrollIntoViewMixin:()=>an,useScrollableMixin:()=>on,useUnmanagedClassNameMixin:()=>sn,useViewContainerState:()=>_e,useViewContext:()=>_e});var t=c(760);const n=t;var i=t.install,r=c(12),o=c(33),a=c(621),s=c(231),u=s.util,f=u.any,p=u.arrRemove,m=u.catchAsync,h=u.combineFn,d=u.createPrivateStore,g=u.define,v=u.defineHiddenProperty,w=u.defineObservableProperty,y=u.defineOwnProperty,b=u.definePrototype,x=u.delay,C=u.each,S=u.either,E=u.equal,P=u.exclude,M=u.executeOnce,O=u.extend,A=u.fill,N=u.freeze,V=u.grep,R=u.isFunction,T=u.isPlainObject,q=u.isThenable,j=u.isUndefinedOrNull,F=u.keys,k=u.kv,L=u.makeArray,I=u.makeAsync,D=u.map,U=u.noop,z=u.pick,B=u.pipe,_=u.randomId,H=u.resolve,W=u.resolveAll,Q=u.setImmediate,$=u.setImmediateOnce,G=u.single,J=u.throwNotFunction,K=u.watch,X=u.watchable,Y=s.util,Z=Y.containsOrEquals,ee=Y.getClass,te=Y.removeNode,ne=Y.scrollIntoView,ie=Y.setClass;const re=s.dom;var oe=s.dom,ae=oe.lock,se=oe.notifyAsync,ue=oe.preventLeave,ce=oe.subscribeAsync,le=t.closeFlyout,fe=t.isFlyoutOpen,pe=t.openFlyout,me=t.toggleFlyout;function he(e){var t,n=document.createElement("div"),i=a.createRoot(n),o=le.bind(0,n);return re.on(n,{flyoutshow:function(){(e.onOpen||U)(n)},flyouthide:function(){t=null,te(n),(e.onClose||U)(n),e.onRender&&i.unmount()}}),n.setAttribute("loading-class",""),ce(n,!0),{root:n,close:o,open:function(){if(t)return t;if(n.className=e.className||"",document.body.appendChild(n),re.retainFocus(re.activeElement,n),e.modal&&n.setAttribute("is-modal",""),e.onRender){var a=O({},e,{closeDialog:function(t){var n=I(e.onCommit||B)(t);return se(re.activeElement,n),n.then(o)}}),s=(0,r.createElement)(e.onRender,a);e.wrapper&&(s=(0,r.createElement)(e.wrapper,a,s)),i.render(s)}return t=H().then((function(){return pe(n,null,z(e,["focus"]))})),e.preventLeave?ue(n,t):e.preventNavigation&&ae(n,t),t}}}function de(e){var t=(0,r.useState)({})[0],n=(0,r.useState)((function(){return he(t)}))[0];return O(t,e),(0,r.useEffect)((function(){var e=Z(re.root,n.root);S(e,t.isOpen)&&(e?n.close():n.open())}),[t.isOpen]),(0,r.useEffect)((function(){return n.close}),[n]),o.createPortal(e.children,n.root)}var ge=c(9),ve=s.EventContainer;const we=t.defaults;var ye,be=[];i("react",(function(e){ye=e,h(be)(ye)})),we.react=!0;var xe,Ce,Se=t.animateIn,Ee=t.animateOut,Pe=t.removeQueryAndHash,Me=d(),Oe=re.root,Ae=new Map,Ne={},Ve=[],Re=new ve,Te=N(O(new ke(null,null),{container:Oe})),qe=Me(Te),je=r.createContext(Te),Fe={};function ke(e,t){var n=this;K(n,!0),y(n,"view",e,!0),Me(n,{children:[],setPage:w(n,"page",t,!0),setActive:w(n,"active",!!t,!0)}),K(n,"page",(function(e,t){Re.emit("pagechange",n,{previousPage:t})}))}function Le(){r.Component.apply(this,arguments),this.state={}}function Ie(){r.Component.apply(this,arguments)}function De(e,t,n){var i=Ae.get(e);if(!i.maxParams){var r=P(i.matchers,["remainingSegments"]),o=D(ye.routes,(function(e){var t=ye.parseRoute(e),n=t.length&&!f(r,(function(e,n){var i=t.params[n];return(e?!(i>=0):i<t.minLength)||!R(e)&&!t.match(n,e)}));return n?t:null}));if(o[1]&&(o=V(o,(function(e){return!G(e.params,(function(e,t){return Ne[t]&&!r[t]}))}))),o[0]){var a=o.slice(-1)[0];i.maxParams=F(O.apply(0,[{remainingSegments:!0}].concat(o.map((function(e){return e.params}))))),i.minParams=D(a.params,(function(e,t){return i.params[t]||e>=a.minLength?null:t}))}}return z(n||ye.route,t?i.maxParams:i.minParams)}function Ue(e,t){return(Ae.get(t)||{}).matchCount-(Ae.get(e)||{}).matchCount}function ze(e,t){var n=Ae.get(e);return!!n&&!G(n.matchers,(function(e,n){var i=t[n]||"";return R(e)?!e(i):(e||"")!==i}))}function Be(e){var t;return J(e),e.prototype instanceof r.Component&&(e=r.createElement.bind(null,e)),function(n){var i=n.viewProps,o=!t&&e(i);q(o)&&(t=o,o=null,m(t));var a=(0,ge.useAsync)((function(){return t.then((function(e){return r.createElement(e.default,i)}))}),!!t)[1];if((!t||!a.loading)&&(n.onComponentLoaded(),a.error))throw a.error;return o||a.value||r.createElement(r.Fragment)}}function _e(){return r.useContext(je)}function He(e){return ze(e,ye.route)}function We(e,t){var n=ye.route;return"string"==typeof e?n=n.parse(e):t=e,t=t?L(t).sort(Ue):Ve,f(t,(function(e){return ze(e,n)}))||void 0}function Qe(e,t){var n=Be(e);return t=O({},t),C(t,(function(e,n){Ne[e]=!0,n instanceof RegExp&&(t[e]=n.test.bind(n))})),Ae.set(n,{id:_(),matchCount:F(t).length,matchers:t,params:z(t,(function(e){return j(e)||"string"==typeof e}))}),Ve.push(n),Ve.sort(Ue),n}function $e(e){xe=Be(e)}function Ge(){var e=L(arguments),t=R(e[0])?{}:e.shift(),n=e[0];return C(e,(function(e,t){if(!Ae.has(t))throw new Error("Invalid argument to renderView: "+(R(t)?t.name:t))})),e.sort(Ue),r.createElement(Ie,{rootProps:t,views:e,defaultView:n})}function Je(e,t){var n=Ae.get(e);if(!n)return"/";var i=O(De(e),De(e,!0,t||{}),n.params);return ye.route.getPath(i)}function Ke(e,t){return ye.toHref(Je(e,t))}function Xe(e,t,n,i){return ye.navigate(Je(e,t),i,n&&N(O({},n)))}function Ye(e,t,n){return Xe(e,t,n,!0)}Ce=function(){ye.on("beforepageload",(function(e){qe.setPage(ye.page),qe.setActive(!0),Fe=e,e.waitFor(new Promise((function(e){!function t(n){if(!n[0])return e();W(D(n,(function(e){return new Promise((function(t){e.onRender=t,e.forceUpdate()}))}))).then((function(){t(D(n,(function(e){return e.children})))}))}(qe.children)})))}))},be.push(J(Ce)),b(ke,{on:function(e,t){return Re.add(this,e,t)}}),Le.contextType=je,b(Le,r.Component,{componentDidCatch:function(e){var t=this;xe&&!t.state.error?t.setState({error:e}):Q((function(){re.emit("error",t.context.container,{error:e},!0)}))},render:function(){var e=this,t={view:e.context.view,error:e.state.error,reset:e.reset.bind(e)},n=e.props.onComponentLoaded;return t.error?r.createElement(xe,{onComponentLoaded:n,viewProps:t}):r.createElement(t.view,{onComponentLoaded:n,viewProps:e.props.viewProps})},reset:function(){this.setState({error:null})}}),Ie.contextType=je,b(Ie,r.Component,{componentDidMount:function(){var e=this,t=Me(e.context).children;t.push(e),e.componentWillUnmount=h(K(ye.route,(function(){(e.setActive||U)(e.getViewComponent()===e.currentViewComponent)})),(function(){p(t,e)}))},render:function(){var e=this;return e.context.active&&e.updateView(),(e.onRender||U)(),r.createElement(r.Fragment,null,e.prevView,e.currentView)},updateView:function(){var e=this,t=e.getViewComponent(),n=t!==e.currentViewComponent;if(t&&(n||!(e.children||"")[0])){var i=Je(t,De(t,!0));if(i!==Pe(ye.path))return void ye.navigate(i,!0)}if(t&&n){var o,a=e.currentElement;a&&(e.setActive(!1),e.prevView=e.currentView,e.currentElement=void 0,ye.emit("pageleave",a,{pathname:e.currentPath},!0),Ee(a,"show").then((function(){e.prevView=void 0,e.forceUpdate()}))),(e.cancelPrevious||U)();var s=new Promise((function(e){o=e})),u=M((function(t){e.currentElement=t,c.container=t,s.then((function(){Se(t,"show","[brew-view]",!0),ye.emit("pageenter",t,{pathname:ye.path},!0)})),se(t,s)})),c=new ke(t,ye.page),l=N({navigationType:Fe.navigationType,viewContext:c,viewData:Fe.data||{}}),f=r.createElement(je.Provider,{key:Ae.get(t).id,value:c},r.createElement(ct,null,r.createElement("div",O({},e.props.rootProps,{ref:u,"brew-view":""}),r.createElement(Le,{onComponentLoaded:o,viewProps:l}))));O(e,Me(c),{cancelPrevious:o,currentPath:ye.path,currentView:f,currentViewComponent:t}),(Fe.waitFor||U)(s)}(e.setPage||U)(ye.page)},getViewComponent:function(){var e=this.props;return f(e.views,He)||e.defaultView}});var Ze=new ve;function et(){return ye.historyStorage.current}function tt(e,t){this.key=e,this.store=et(),this.dispose=t}function nt(e,t,n,i){return e.get(t)!==n&&(i&&e.has(t)&&(ye.snapshot(),e=et()),e.set(t,n)),e}function it(e,t,n){var i=e.get();(t!==e.key||n!==e.store&&n.has(t))&&(i=n.get(t),Ze.emit("popstate",e,{newValue:i})),e.key=t,e.store=n,n.set(t,i)}function rt(e,t){var n=_e();return(0,r.useEffect)((function(){return ye.on("beforepageload popstate",(function(){n.active&&e(et())}))}),t),n}function ot(){return at().ready}function at(){var e=(0,ge.useObservableProperty)(ye,"readyState");return{ready:"ready"===e,error:"error"===e}}function st(e,t){var n=_e(),i=n.page.params,o=ye.route,a=i[e]||"",s=(0,r.useRef)(a),u=(0,ge.useUpdateTrigger)();return(0,r.useEffect)((function(){var t=function t(){var i=o[e]||"";i!==s.current&&(n.active?(s.current=i,u()):K(n,"active",t))};if(t(),e in o)return o.watch(e,(function(){$(t)}));console.error("Route parameter "+e+" does not exist")}),[e,t]),s.current=a,t&&n.active&&(!a||"remainingSegments"===e&&"/"===a)&&ye.navigate(o.getPath(O({},i,k(e,t))),!0),a}function ut(e,t,n){var i=et(),o=(0,r.useState)(i&&i.has(e)?i.get(e):t),a=rt((function(t){o[1]((function(n){return t.has(e)?t.get(e):(t.set(e,n),n)}))}),[e]);return i?a.active&&nt(i,e,o[0],n):ye.beforeInit(x(1)),o}function ct(e){var t=(0,r.useState)({})[0],n=rt((function(e){C(t,(function(t,n){it(n,n.key,e)}))}),[]),i=(0,r.useState)((function(){return{getState:function(e,i){var r=t[e];return r&&n.active&&it(r,i,et()),r||(t[e]=new tt(i,(function(){delete t[e]})))}}}))[0];return(0,r.createElement)(ge.ViewStateProvider,{value:i},e.children)}b(tt,{get:function(){return this.store.get(this.key)},set:function(e,t){this.store=nt(this.store,this.key,e,t)},onPopState:function(e){return J(e),Ze.add(this,"popstate",(function(t){e.call(this,t.newValue)}))}});var lt=c(87),ft=Object.create(null),pt="function"==typeof Symbol&&Symbol.toPrimitive;function mt(e){this.toString=e}function ht(e){return O((function(t,n,i){var r=e(t,n,i,!0);return void 0!==r?r:t}),{html:function(t,n,i){return{__html:e(t,n,i)}},lazy:function(t,n,i){return new mt(e.bind(0,t,n,i,!0))}})}function dt(){return(0,ge.useObservableProperty)(ye,"language")}function gt(e,t){var n=new RegExp("^("+Object.keys(e[t]).join("|")+")\\."),i={};function r(n,i,o,a,s){var u=((e[s]||ft)[n]||ft)[i];return"string"==typeof u?!u||a&&void 0===o?u:lt(u,o,{noEncode:a}):s!==t?r(n,i,o,a,t):void 0}function o(e,t,i,o){var a=n.test(e)?RegExp.$1:"";return r(a,a?e.slice(RegExp.lastMatch.length):e,t,o,i||ye.language)}function a(){var e=String(this),t=L(arguments),n=e+" "+t.join(" ");return i[n]||(i[n]=t[0]?ht((function(n,i,o,a){return o=o||e||ye.language,G(t,(function(e){return r(e,n,i,a,o)}))})):ht((function(t,n,i,r){return o(t,n,i||e,r)})))}return{translate:ht(o),getTranslation:a.bind(""),useTranslation:function(){var e=dt();return{language:e,t:a.apply(e,arguments)}},keys:function(n){return F(e[t][n]||ft)}}}function vt(e,t){wt.call(this),this.attributes=T(e)||k(e,t||"")}function wt(){}pt&&(mt.prototype[pt]=function(){return this.toString()}),b(vt,wt,{getCustomAttributes:function(){return O({},this.attributes)}}),b(wt,{reset:function(){return this},next:function(){},getRef:function(){return U},getClassNames:function(){return[]},getCustomAttributes:function(){return{}},dispose:function(){}}),X(wt.prototype),g(wt,{get scrollableTarget(){return new vt("scrollable-target")},get tabRoot(){return new vt("tab-root")},use:function(){var e=L(arguments),t=e[0],n={},i=e.filter((function(e){return e instanceof wt})),r=i.map((function(e){return e.getRef()}));return!t||t instanceof wt?t||e.shift():("function"!=typeof t?r.push((function(e){t.current=e})):r.push(t),e.shift()),C(i,(function(e,t){O(n,t.getCustomAttributes())})),O(n,{ref:h(r),className:ge.classNames.apply(null,e)}),C(i,(function(e,t){t.next()})),n}});var yt=s.dom,bt=yt.watchElements,xt=yt.watchOwnAttributes,Ct=d();function St(e){this.mixin=e}function Et(){wt.call(this),Ct(this,{elements:new Set,states:new WeakMap,flush:K(this,!1),dispose:[]})}function Pt(e,t,n,i){var r=n.classNames,o=O({},r);C(r,(function(e){r[e]=t.classList.contains(e)})),i&&!E(n.prev||o,r)&&(n.prev=o,e.onClassNameUpdated(t,o,O({},r)))}function Mt(e){Et.call(this),this.classNames=e||[]}b(St,{getMixin:function(){return this.mixin}}),b(Et,wt,{get ref(){var e=Ct(this);return e.ref||(e.ref=new St(this))},get state(){return Ct(this).pending},reset:function(){return Ct(this).pending={},this},next:function(){return Ct(this).pending={},this},getRef:function(){var e,t=this,n=Ct(t),i=n.pending;return function(r){if(r)(e=n.states.get(r)||O(t.initState(),i)).element!==r?(e.element=r,t.initElement(r,e),n.states.set(r,e)):F(i)[0]&&t.mergeState(r,e,i),t.onLayoutEffect(r,e),n.elements.add(r);else if(e){var o=e.element;t.onBeforeUpdate(o,e),n.elements.delete(o)}}},elements:function(){return D(Ct(this).elements,B)},onDispose:function(e){Ct(this).dispose.push(e)},initState:function(){return{element:null}},initElement:function(e,t){},mergeState:function(e,t,n){O(t,n)},onLayoutEffect:function(e,t){},onBeforeUpdate:function(e,t){},clone:function(){return this},dispose:function(){var e=Ct(this);h(e.dispose.splice(0))(),e.flush(),e.states={},e.pending={}}}),b(Mt,Et,{initState:function(){return{element:null,classNames:A(this.classNames,!1)}},initElement:function(e,t){var n=this;Pt(n,e,t),xt(e,"class",(function(){Pt(n,e,t,!0)}))},onLayoutEffect:function(e,t){ie(e,t.classNames)},onBeforeUpdate:function(e,t){Pt(this,e,t)},onClassNameUpdated:function(e,t,n){}});var Ot=Mt.prototype;function At(){Mt.call(this,["tweening-in","tweening-out"])}b(At,Mt,{next:function(){var e=this;return e.effects=void 0,e.trigger=void 0,Ot.next.call(e)},with:function(e){var t=this;return t.effects=e.effects,t.trigger=e.trigger,t},withEffects:function(){return this.effects=L(arguments),this},getCustomAttributes:function(){var e=this;return O(Ot.getCustomAttributes.call(e),{"animate-in":(e.effects||[]).join(" "),"animate-on":e.trigger||"show"})}});var Nt=Mt.prototype;function Vt(e){Mt.call(this,["tweening-in","tweening-out"]),this.className=e}b(Vt,Mt,{getCustomAttributes:function(){return O(Nt.getCustomAttributes.call(this),{"is-animate-sequence":""})},getClassNames:function(){return[this.className].concat(Nt.getClassNames.call(this))}});var Rt=c(914),Tt=At.prototype,qt=0;function jt(){var e=this;At.call(e),e.className="brew-anim-"+ ++qt,e.item=new Vt(e.className)}function Ft(){Et.call(this)}b(jt,At,{withOptions:function(e){return this.selector=e,this},getCustomAttributes:function(){var e=this;return O(Tt.getCustomAttributes.call(e),{"animate-in":null,"animate-sequence-type":(e.effects||[]).join(" "),"animate-sequence":e.selector||"."+e.className})},initElement:function(e,t){var n=this;Tt.initElement.call(n,e,t),n.selector&&n.onDispose(bt(e,n.selector,(function(e){Rt(e).attr("is-animate-sequence","")})))}}),b(Ft,Et,{withOptions:function(e){this.classes=O({},e)},getClassNames:function(){return this.classes},set:function(e,t){t=T(e)||k(e,t),C(this.elements(),(function(e,n){ie(n,t)})),O(this.classes,t)}});var kt=Mt.prototype;function Lt(e){Mt.call(this,["target-opened"]),this.flyoutMixin=e}b(Lt,Mt,{open:function(e,t){return this.flyoutMixin.open(e,t)},close:function(e){return this.flyoutMixin.close(e)},initElement:function(e,t){var n=this;kt.initElement.call(n,e,t),n.onDispose(re.on(e,"click",(function(){me(n.flyoutMixin.elements()[0],e,n.flyoutMixin.getOptions())})))}});var It=Mt.prototype,Dt=new WeakMap;function Ut(){var e=this;Mt.call(e,["open","closing","visible","tweening-in","tweening-out"]),e.modal=!1,e.tabThrough=!1,e.isFlyoutOpened=!1,e.animating=!1,e.visible=!1,e.initialFocus=void 0,e.toggle=new Lt(e),e.onDispose((function(){e.isFlyoutOpened=!1,e.visible=!1,e.toggle.dispose()}))}b(Ut,Mt,{getOptions:function(){var e=this,t=z(e,["closeOnBlur"]);return void 0!==e.initialFocus&&(t.focus=e.initialFocus),t},next:function(){return this.effects=void 0,It.next.call(this)},withEffects:function(){return this.effects=L(arguments),this},getCustomAttributes:function(){var e=this;return O(It.getCustomAttributes.call(e),{"is-flyout":"","swipe-dismiss":e.swipeToDismiss},e.modal&&{"is-modal":""},e.tabThrough&&{"tab-through":""},e.effects&&{"animate-on":"open","animate-in":e.effects.join(" "),"animate-out":""})},open:function(e,t){var n=this.elements()[0];return fe(n)||Dt.set(n,e),pe(n,t,this.getOptions())},close:function(e){return le(this.elements()[0],e)},onOpen:function(e){var t=this.elements()[0];return this.onToggleState((function(n){if(n)return e(Dt.get(t))}))},onToggleState:function(e){return this.watch("isFlyoutOpened",e)},onVisibilityChanged:function(e){return this.watch("visible",e)},initElement:function(e,t){var n=this;It.initElement.call(n,e,t),n.onDispose(ye.on(e,{animationstart:function(){n.animating=!0},animationcomplete:function(){n.animating=!1}},!0))},onClassNameUpdated:function(e,t,n){var i=fe(e);i||Dt.delete(e),this.visible=n.open,this.isFlyoutOpened=i}});var zt=Et.prototype;function Bt(){Et.call(this)}b(Bt,Et,{for:function(e){return this.state.ref=e,this},initElement:function(e,t){zt.initElement.call(this,e,t);var n=function(n,i){var r=t.ref,o=r&&("string"==typeof r?e.querySelector(r):r.current);o&&!re.focused(o)&&n(i||o)};this.onDispose(re.on(e,{focusin:function(i){t.focused=i.source,ie(e,"focused",i.source),n(re.focus)},focusout:function(){t.focused=!1,ie(e,"focused",!1)},focuschange:function(){n(re.blur,e)}}))},onLayoutEffect:function(e,t){ie(e,"focused",t.focused)}});var _t=t.getDirectiveComponent,Ht=Mt.prototype;function Wt(){Mt.call(this,["loading","loading-complete"]),this.loading=!1}b(Wt,Mt,{initElement:function(e,t){var n=this;Ht.initElement.call(n,e,t),_t(e).enableLoadingClass=!0,n.onDispose(ce(e,(function(t){n.loading=t||!!f(n.elements(),(function(t){return t!==e&&!0===ee(t,"loading")}))})))}});var Qt=Mt.prototype;function $t(){var e=this;Mt.call(e,["scrollable-x","scrollable-x-l","scrollable-x-r","scrollable-y","scrollable-y-d","scrollable-y-u"]),e.target=wt.scrollableTarget,e.pageIndex=0,e.scrolling=!1}function Gt(){Et.call(this)}function Jt(){Mt.call(this)}function Kt(e){O(this,e)}function Xt(e){return function(){var t=un(e);return(t.withOptions||Kt).apply(t,arguments),t}}b($t,Mt,{withOptions:function(e){return this.options=e,this},getCustomAttributes:function(){var e=this.options||{};return O(Qt.getCustomAttributes.call(this),{scrollable:[e.direction||"both",e.handle||"auto"].join(" ")},e.pagedItemSelector&&{"scroller-snap-page":e.paged,"scroller-page":e.pagedItemSelector},e.persistScroll&&{"persist-scroll":""})},onPageIndexChanged:function(e){return this.watch("pageIndex",e)},initElement:function(e,t){var n=this;Qt.initElement.call(n,e,t),n.onDispose(ye.on(e,{scrollIndexChange:function(e){n.pageIndex=e.newIndex},scrollStart:function(){n.scrolling=!0},scrollStop:function(){n.scrolling=!1}},!0))}}),C("destroy enable disable setOptions setStickyPosition refresh scrollPadding stop scrollLeft scrollTop scrollBy scrollTo scrollByPage scrollToPage scrollToElement",(function(e,t){v($t.prototype,t,(function(){return _t(this.elements()[0]).scrollable[t].apply(null,arguments)}))})),b(Gt,Et,{when:function(e){return this.state.deps=e,this},initElement:function(e,t){t.callback=function(){ne(e)}},mergeState:function(e,t,n){n.deps&&!E(n.deps,t.deps)&&$(t.callback),O(t,n)}}),b(Jt,Mt,{memorize:function(){return this.classNames=L(arguments),this}});var Yt=Xt(At),Zt=Xt(jt),en=Xt(Ft),tn=Xt(Ut),nn=Xt(Bt),rn=Xt(Wt),on=Xt($t),an=Xt(Gt),sn=Xt(Jt);function un(e){return(0,ge.useSingleton)((function(){return new e})).reset()}function cn(e){return e&&e.getMixin().reset()}const ln=n,fn=e;n.react=e})(),l=l.default})()));
|
|
1
|
+
/*! brew-js-react v0.5.6 | (c) misonou | https://misonou.github.io */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("zeta-dom"),require("react"),require("react-dom"),require("brew-js"),require("zeta-dom-react"),require("waterpipe"),require("jquery")):"function"==typeof define&&define.amd?define("brew-js-react",["zeta-dom","react","react-dom","brew-js","zeta-dom-react","waterpipe","jquery"],t):"object"==typeof exports?exports["brew-js-react"]=t(require("zeta-dom"),require("react"),require("react-dom"),require("brew-js"),require("zeta-dom-react"),require("waterpipe"),require("jquery")):(e.brew=e.brew||{},e.brew.react=t(e.zeta,e.React,e.ReactDOM,e.brew,e.zeta.react,e.waterpipe,e.jQuery))}(self,((e,t,n,i,r,o,a)=>(()=>{var s={87:e=>{"use strict";e.exports=o},760:e=>{"use strict";e.exports=i},942:e=>{"use strict";e.exports=a},12:e=>{"use strict";e.exports=t},311:e=>{"use strict";e.exports=n},231:t=>{"use strict";t.exports=e},402:e=>{"use strict";e.exports=r},621:(e,t,n)=>{var i,r=n(311);i=r.createRoot?r:{createRoot:(e,t)=>({render(t){r.render(t,e)},unmount(){r.unmountComponentAtNode(e)}}),hydrateRoot:(e,t,n)=>(r.hydrate(t,e),i.createRoot(e,n))},e.exports=i}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return s[e](n,n.exports,c),n.exports}c.d=(e,t)=>{for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{"use strict";c.r(l),c.d(l,{AnimateMixin:()=>jt,AnimateSequenceItemMixin:()=>qt,AnimateSequenceMixin:()=>It,ClassNameMixin:()=>Nt,ClassNameToggleMixin:()=>Dt,Dialog:()=>he,FlyoutMixin:()=>_t,FlyoutToggleMixin:()=>Ut,FocusStateMixin:()=>Wt,LoadingStateMixin:()=>Jt,Mixin:()=>Ct,ScrollIntoViewMixin:()=>Yt,ScrollableMixin:()=>Xt,StatefulMixin:()=>Ot,UnmanagedClassNameMixin:()=>Zt,ViewStateContainer:()=>mt,createDialog:()=>me,isViewMatched:()=>We,isViewRendered:()=>Ge,linkTo:()=>Ze,makeTranslation:()=>bt,matchView:()=>$e,navigateTo:()=>et,redirectTo:()=>tt,registerErrorView:()=>Ke,registerView:()=>Je,renderView:()=>Xe,resolvePath:()=>Ye,useAnimateMixin:()=>nn,useAnimateSequenceMixin:()=>rn,useAppReady:()=>ut,useAppReadyState:()=>ct,useClassNameToggleMixin:()=>on,useFlyoutMixin:()=>an,useFocusStateMixin:()=>sn,useLanguage:()=>yt,useLoadingStateMixin:()=>un,useMixin:()=>pn,useMixinRef:()=>mn,useQueryParam:()=>pt,useRouteParam:()=>lt,useRouteState:()=>ft,useScrollIntoViewMixin:()=>ln,useScrollableMixin:()=>cn,useUnmanagedClassNameMixin:()=>fn,useViewContainerState:()=>He,useViewContext:()=>He});var e=c(231),t=e.util,n=t.any,i=t.arrRemove,r=t.catchAsync,o=t.combineFn,a=t.createPrivateStore,s=t.define,u=t.defineGetterProperty,f=t.defineHiddenProperty,p=t.defineObservableProperty,m=t.defineOwnProperty,h=t.definePrototype,d=t.delay,g=t.each,v=t.either,w=t.equal,y=t.exclude,b=t.executeOnce,x=t.extend,C=t.fill,S=t.freeze,E=t.grep,P=t.isArray,M=t.isFunction,A=t.isPlainObject,O=t.isThenable,V=t.isUndefinedOrNull,N=t.keys,R=t.kv,j=t.makeArray,T=t.makeAsync,q=t.map,F=t.mapObject,k=t.noop,L=t.pick,I=t.pipe,D=t.randomId,z=t.resolve,U=t.resolveAll,B=t.setImmediate,Q=t.setImmediateOnce,_=t.single,H=t.throwNotFunction,W=t.watch,G=t.watchable,$=c(12),J=c(311),K=c(621),X=e.util,Y=X.containsOrEquals,Z=X.getClass,ee=X.removeNode,te=X.scrollIntoView,ne=X.setClass;const ie=e.dom;var re=e.dom,oe=re.lock,ae=re.notifyAsync,se=re.preventLeave,ue=re.subscribeAsync,ce=c(760),le=ce.closeFlyout,fe=ce.openFlyout,pe=ce.toggleFlyout;function me(e){var t,n=document.createElement("div"),i=K.createRoot(n),r=le.bind(0,n);return ie.on(n,{flyoutshow:function(){(e.onOpen||k)(n)},flyouthide:function(){t=null,ee(n),(e.onClose||k)(n),e.onRender&&i.unmount()}}),n.setAttribute("loading-class",""),ue(n,!0),{root:n,close:r,open:function(){if(t)return t;if(n.className=e.className||"",document.body.appendChild(n),ie.retainFocus(ie.activeElement,n),e.modal&&n.setAttribute("is-modal",""),e.onRender){var o=x({},e,{closeDialog:function(t){var n=T(e.onCommit||I)(t);return ae(ie.activeElement,n),n.then(r)}}),a=(0,$.createElement)(e.onRender,o);e.wrapper&&(a=(0,$.createElement)(e.wrapper,o,a)),i.render(a)}return t=z().then((function(){return fe(n,null,L(e,["focus"]))})),e.preventLeave?se(n,t):e.preventNavigation&&oe(n,t),t}}}function he(e){var t=(0,$.useState)({})[0],n=(0,$.useState)((function(){return me(t)}))[0];return x(t,e),(0,$.useEffect)((function(){var e=Y(ie.root,n.root);v(e,t.isOpen)&&(e?n.close():n.open())}),[t.isOpen]),(0,$.useEffect)((function(){return n.close}),[n]),J.createPortal(e.children,n.root)}var de=c(402),ge=e.EventContainer,ve=ce.getQueryParam,we=ce.setQueryParam,ye=ce.parsePath,be=ce.removeQueryAndHash;var xe=ce.install;const Ce=ce.defaults;var Se,Ee=[];xe("react",(function(e){Se=e,o(Ee)(Se)})),Ce.react=!0;var Pe,Me,Ae=ce.animateIn,Oe=ce.animateOut,Ve=a(),Ne=ie.root,Re=new Map,je={},Te=[],qe=new ge,Fe=S(x(new De,{container:Ne})),ke=Ve(Fe),Le=$.createContext(Fe),Ie={};function De(e,t,n){var i=this;m(i,"view",e||null,!0),m(i,"parent",n||null,!0),Ve(i,{children:[],setPage:p(i,"page",t||null,!0),setActive:p(i,"active",!!t,!0)}),W(i,"page",(function(e,t){qe.emit("pagechange",i,{previousPage:t})}))}function ze(){$.Component.apply(this,arguments),this.state={}}function Ue(){$.Component.apply(this,arguments)}function Be(e,t){return(Re.get(t)||{}).matchCount-(Re.get(e)||{}).matchCount}function Qe(e,t){var n=Re.get(e);return!!n&&!_(n.matchers,(function(e,n){var i=t[n]||"";return M(e)?!e(i):(e||"")!==i}))}function _e(e){var t;return H(e),e.prototype instanceof $.Component&&(e=$.createElement.bind(null,e)),function(n){var i=n.viewProps,o=!t&&e(i);O(o)&&(t=o,o=null,r(t));var a=(0,de.useAsync)((function(){return t.then((function(e){return $.createElement(e.default,i)}))}),!!t)[1],s=!t||!a.loading;if($.useEffect((function(){s&&B(n.onComponentLoaded)}),[s]),a.error)throw a.error;return o||a.value||$.createElement($.Fragment)}}function He(){return $.useContext(Le)}function We(e){return Qe(e,Se.route)}function Ge(e){return!!(Re.get(e)||"").rendered}function $e(){var e=j(arguments),t=Se.route;return"string"==typeof e[0]&&(t=t.parse(e.shift())),e=e[0]?(P(e[0])?j(e[0]):e).sort(Be):Te,n(e,(function(e){return Qe(e,t)}))||void 0}function Je(e,t){var n=_e(e);return t=x({},t),g(t,(function(e,n){je[e]=!0,n instanceof RegExp&&(t[e]=n.test.bind(n))})),Re.set(n,{id:D(),rendered:0,matchCount:N(t).length,matchers:t,params:L(t,(function(e){return V(e)||"string"==typeof e}))}),Te.push(n),Te.sort(Be),n}function Ke(e){Pe=_e(e)}function Xe(){var e=j(arguments),t=M(e[0])?{}:e.shift(),n=e[0];return g(e,(function(e,t){if(!Re.has(t))throw new Error("Invalid argument to renderView: "+(M(t)?t.name:t))})),e.sort(Be),$.createElement(Ue,{rootProps:t,views:e,defaultView:n})}function Ye(e,t){return Re.has(e)?Se.route.getPath(function(e,t){var i=Re.get(e);if(!i.maxParams){var r=y(i.matchers,["remainingSegments"]),o=q(Se.routes,(function(e){var t=Se.parseRoute(e),i=t.length&&!n(r,(function(e,n){var i=t.params[n];return(e?!(i>=0):i<t.minLength)||!M(e)&&!t.match(n,e)}));return i?t:null}));if(o[1]&&(o=E(o,(function(e){return!_(e.params,(function(e,t){return je[t]&&!r[t]}))}))),o[0]){var a=o.slice(-1)[0];i.maxParams=N(x.apply(0,[{remainingSegments:!0}].concat(o.map((function(e){return e.params}))))),i.minParams=q(a.params,(function(e,t){return i.params[t]||e>=a.minLength?null:t}))}}return x(L(Se.route,i.minParams),t&&L(t,i.maxParams),i.params)}(e,t)):"/"}function Ze(e,t){return Se.toHref(Ye(e,t))}function et(e,t,n,i){return Se.navigate(Ye(e,t),i,n&&S(x({},n)))}function tt(e,t,n){return et(e,t,n,!0)}Me=function(){Se.on("beforepageload",(function(e){ke.setPage(Se.page),ke.setActive(!0),Ie=e,e.waitFor(new Promise((function(e){!function t(n){if(!n[0])return e();U(q(n,(function(e){return new Promise((function(t){e.onRender=t,e.forceUpdate()}))}))).then((function(){t(q(n,(function(e){return e.children})))}))}(ke.children)})))}))},Ee.push(H(Me)),h(De,{getChildren:function(){return q(Ve(this).children,(function(e){return e.currentState}))},on:function(e,t){return qe.add(this,e,t)}}),ze.contextType=Le,h(ze,$.Component,{componentDidCatch:function(e){var t=this;Pe&&!t.state.error?t.setState({error:e}):(B((function(){ie.emit("error",t.context.container,{error:e},!0)})),t.props.onComponentLoaded())},render:function(){var e=this,t={view:e.context.view,error:e.state.error,reset:e.reset.bind(e)},n=e.props.onComponentLoaded;return t.error?$.createElement(Pe,{onComponentLoaded:n,viewProps:t}):$.createElement(t.view,{onComponentLoaded:n,viewProps:e.props.viewProps})},reset:function(){this.setState({error:null})}}),Ue.contextType=Le,h(Ue,$.Component,{setActive:k,componentDidMount:function(){var e=this,t=Ve(e.context).children,n=W(Se.route,(function(){e.setActive(e.getViewComponent()===e.currentViewComponent)}));e.componentWillUnmount=function(){e.setActive(!1),i(t,e),n(),B((function(){e.unmountView&&!e.currentState.active&&e.unmountView()}))},t.push(e),e.setActive(!0)},render:function(){var e=this;return e.context.active&&e.updateView(),(e.onRender||k)(),$.createElement($.Fragment,null,e.prevView,e.currentView)},updateView:function(){var e=this,t=e.getViewComponent(),n=t!==e.currentViewComponent;if(t&&(n||!(e.children||"")[0])){var i=Ye(t,Se.route);if(i!==be(Se.path))return void Se.navigate(i,!0)}if(t&&n){(e.unmountView||k)(!0);var r,o=new De(t,Se.page,e.context),a=new Promise((function(e){r=e})),s=r,u=b((function(n){o.container=n,a.then((function(){e.currentState===o&&(s=function(){e.prevView=e.currentView,Se.emit("pageleave",n,{pathname:o.page.path,view:t},!0),Oe(n,"show").then((function(){e.prevView=void 0,e.forceUpdate()}))},Ae(n,"show","[brew-view]",!0),Se.emit("pageenter",n,{pathname:o.page.path,view:t},!0))})),ae(n,a)})),c=S({navigationType:Ie.navigationType,viewContext:o,viewData:Ie.data||{}}),l=$.createElement(Le.Provider,{key:Re.get(t).id,value:o},$.createElement(mt,null,$.createElement("div",x({},e.props.rootProps,{ref:u,"brew-view":""}),$.createElement(ze,{onComponentLoaded:r,viewProps:c}))));x(e,Ve(o),{currentState:o,currentView:l,currentViewComponent:t,unmountView:b((function(){e.setActive(!1),Re.get(t).rendered--,s()}))}),Re.get(t).rendered++,(Ie.waitFor||k)(a)}(e.setPage||k)(Se.page)},getViewComponent:function(){var e=this.props;return n(e.views,We)||e.defaultView}});var nt=new ge;function it(){return Se.historyStorage.current}function rt(e,t){this.key=e,this.store=it(),this.dispose=t}function ot(e,t,n,i){return e.get(t)!==n&&(i&&e.has(t)&&(Se.snapshot(),e=it()),e.set(t,n)),e}function at(e,t,n){var i=e.get();(t!==e.key||n!==e.store&&n.has(t))&&(i=n.get(t),nt.emit("popstate",e,{newValue:i})),e.key=t,e.store=n,n.set(t,i)}function st(e,t){var n=He();return(0,$.useEffect)((function(){return Se.on("beforepageload popstate",(function(){n.active&&e(it())}))}),t),n}function ut(){return ct().ready}function ct(){var e=(0,de.useObservableProperty)(Se,"readyState");return{ready:"ready"===e,error:"error"===e}}function lt(e,t){var n=He(),i=n.page.params,r=i[e]||"",o=(0,$.useRef)(r),a=(0,de.useUpdateTrigger)();return(0,$.useEffect)((function(){var t=function(){(n.page.params[e]||"")!==o.current&&a()};return t(),n.on("pagechange",t)}),[e]),o.current=r,t&&n.active&&(!r||"remainingSegments"===e&&"/"===r)&&Se.navigate(Se.route.getPath(x({},i,R(e,t))),!0),r}function ft(e,t,n){var i=it(),r=(0,$.useState)(i&&i.has(e)?i.get(e):t),o=st((function(t){r[1]((function(n){return t.has(e)?t.get(e):(t.set(e,n),n)}))}),[e]);return i?o.active&&ot(i,e,r[0],n):Se.beforeInit(d(1)),r}function pt(e,t,n){A(e)&&(n=t,t=e,e=!1);var i=He(),o=function(){return F(!1===e?t:R(e,t),(function(e,t){return ve(t,Se.path)||e||""}))},a=(0,$.useState)([]);(0,$.useMemo)((function(){a[0].splice(0,2,o())}),[e]);var s=a[0][0],u=function(e){w(e,s)||(x(s,e),a[1]([s]))},c=(0,de.useMemoizedFunction)((function(t){if(!1!==e?t=R(e,M(t)?t(s[e]):t):M(t)&&(t=t(x({},s))),i.active){var a=ye(Se.path),c=N(t).reduce((function(e,n){return t[n]!==s[n]?we(n,t[n]||null,e):e}),a.search);c!==a.search&&(n&&Se.snapshot(),r(Se.navigate(c+a.hash,!0)),u(o()))}}));return(0,$.useEffect)((function(){return Se.watch("path",(function(){i.active&&u(o())}))}),[e]),[!1!==e?s[e]:a[0][1]||(a[0][1]=S(x({},s))),c]}function mt(e){var t=(0,$.useState)({})[0],n=st((function(e){g(t,(function(t,n){at(n,n.key,e)}))}),[]),i=(0,$.useState)((function(){return{getState:function(e,i){var r=t[e];return r&&n.active&&at(r,i,it()),r||(t[e]=new rt(i,(function(){delete t[e]})))}}}))[0];return(0,$.createElement)(de.ViewStateProvider,{value:i},e.children)}h(rt,{get:function(){return this.store.get(this.key)},set:function(e,t){this.store=ot(this.store,this.key,e,t)},onPopState:function(e){return H(e),nt.add(this,"popstate",(function(t){e.call(this,t.newValue)}))}});var ht=c(87),dt=Object.create(null),gt="function"==typeof Symbol&&Symbol.toPrimitive;function vt(e){this.toString=e}function wt(e){return x((function(t,n,i){var r=e(t,n,i,!0);return void 0!==r?r:t}),{html:function(t,n,i){return{__html:e(t,n,i)}},lazy:function(t,n,i){return new vt(e.bind(0,t,n,i,!0))}})}function yt(){return(0,de.useObservableProperty)(Se,"language")}function bt(e,t){var n=new RegExp("^("+Object.keys(e[t]).join("|")+")\\."),i={};function r(n,i,o,a,s){var u=((e[s]||dt)[n]||dt)[i];return"string"==typeof u?!u||a&&void 0===o?u:ht(u,o,{noEncode:a}):s!==t?r(n,i,o,a,t):void 0}function o(e,t,i,o){var a=n.test(e)?RegExp.$1:"";return r(a,a?e.slice(RegExp.lastMatch.length):e,t,o,i||Se.language)}function a(){var e=String(this),t=j(arguments),n=e+" "+t.join(" ");return i[n]||(i[n]=t[0]?wt((function(n,i,o,a){return o=o||e||Se.language,_(t,(function(e){return r(e,n,i,a,o)}))})):wt((function(t,n,i,r){return o(t,n,i||e,r)})))}return{translate:wt(o),getTranslation:a.bind(""),useTranslation:function(){var e=yt();return{language:e,t:a.apply(e,arguments)}},keys:function(n){return N(e[t][n]||dt)}}}function xt(e,t){Ct.call(this),this.attributes=A(e)||R(e,t||"")}function Ct(){}gt&&(vt.prototype[gt]=function(){return this.toString()}),h(xt,Ct,{getCustomAttributes:function(){return x({},this.attributes)}}),h(Ct,{reset:function(){return this},next:function(){},getRef:function(){return k},getClassNames:function(){return[]},getCustomAttributes:function(){return{}},dispose:function(){}}),G(Ct.prototype),s(Ct,{get scrollableTarget(){return new xt("scrollable-target")},get tabRoot(){return new xt("tab-root")},use:function(){var e=j(arguments),t=e[0],n={},i=e.filter((function(e){return e instanceof Ct})),r=i.map((function(e){return e.getRef()}));return!t||t instanceof Ct?t||e.shift():("function"!=typeof t?r.push((function(e){t.current=e})):r.push(t),e.shift()),g(i,(function(e,t){x(n,t.getCustomAttributes())})),x(n,{ref:o(r),className:de.classNames.apply(null,e)}),g(i,(function(e,t){t.next()})),n}});var St=e.dom,Et=St.watchElements,Pt=St.watchOwnAttributes,Mt=a();function At(e){this.mixin=e}function Ot(){Ct.call(this),Mt(this,{elements:new Set,states:new WeakMap,flush:W(this,!1),dispose:[]})}function Vt(e,t,n,i){var r=n.classNames,o=x({},r);g(r,(function(e){r[e]=t.classList.contains(e)})),i&&!w(n.prev||o,r)&&(n.prev=o,e.onClassNameUpdated(t,o,x({},r)))}function Nt(e){Ot.call(this),this.classNames=e||[]}h(At,{getMixin:function(){return this.mixin}}),h(Ot,Ct,{get ref(){var e=Mt(this);return e.ref||(e.ref=new At(this))},get state(){return Mt(this).pending},reset:function(){return Mt(this).pending={},this},next:function(){return Mt(this).pending={},this},getRef:function(){var e,t=this,n=Mt(t),i=n.pending;return function(r){if(r)(e=n.states.get(r)||x(t.initState(),i)).element!==r?(e.element=r,t.initElement(r,e),n.states.set(r,e)):N(i)[0]&&t.mergeState(r,e,i),t.onLayoutEffect(r,e),n.elements.add(r);else if(e){var o=e.element;t.onBeforeUpdate(o,e),n.elements.delete(o)}}},elements:function(){return q(Mt(this).elements,I)},onDispose:function(e){Mt(this).dispose.push(e)},initState:function(){return{element:null}},initElement:function(e,t){},mergeState:function(e,t,n){x(t,n)},onLayoutEffect:function(e,t){},onBeforeUpdate:function(e,t){},clone:function(){return this},dispose:function(){var e=Mt(this);o(e.dispose.splice(0))(),e.flush(),e.states={},e.pending={}}}),h(Nt,Ot,{initState:function(){return{element:null,classNames:C(this.classNames,!1)}},initElement:function(e,t){var n=this;Vt(n,e,t),Pt(e,"class",(function(){Vt(n,e,t,!0)}))},onLayoutEffect:function(e,t){ne(e,t.classNames)},onBeforeUpdate:function(e,t){Vt(this,e,t)},onClassNameUpdated:function(e,t,n){}});var Rt=Nt.prototype;function jt(){Nt.call(this,["tweening-in","tweening-out"])}h(jt,Nt,{next:function(){var e=this;return e.effects=void 0,e.trigger=void 0,Rt.next.call(e)},with:function(e){var t=this;return t.effects=e.effects,t.trigger=e.trigger,t},withEffects:function(){return this.effects=j(arguments),this},getCustomAttributes:function(){var e=this;return x(Rt.getCustomAttributes.call(e),{"animate-in":(e.effects||[]).join(" "),"animate-on":e.trigger||"show"})}});var Tt=Nt.prototype;function qt(e){Nt.call(this,["tweening-in","tweening-out"]),this.className=e}h(qt,Nt,{getCustomAttributes:function(){return x(Tt.getCustomAttributes.call(this),{"is-animate-sequence":""})},getClassNames:function(){return[this.className].concat(Tt.getClassNames.call(this))}});var Ft=c(942),kt=jt.prototype,Lt=0;function It(){var e=this;jt.call(e),e.className="brew-anim-"+ ++Lt,e.item=new qt(e.className)}function Dt(){Ot.call(this)}h(It,jt,{withOptions:function(e){return this.selector=e,this},getCustomAttributes:function(){var e=this;return x(kt.getCustomAttributes.call(e),{"animate-in":null,"animate-sequence-type":(e.effects||[]).join(" "),"animate-sequence":e.selector||"."+e.className})},initElement:function(e,t){var n=this;kt.initElement.call(n,e,t),n.selector&&n.onDispose(Et(e,n.selector,(function(e){Ft(e).attr("is-animate-sequence","")})))}}),h(Dt,Ot,{withOptions:function(e){this.classes=x({},e)},getClassNames:function(){return this.classes},set:function(e,t){t=A(e)||R(e,t),g(this.elements(),(function(e,n){ne(n,t)})),x(this.classes,t)}});var zt=Nt.prototype;function Ut(e){Nt.call(this,["target-opened"]),this.flyoutMixin=e}h(Ut,Nt,{open:function(e,t){return this.flyoutMixin.open(e,t)},close:function(e){return this.flyoutMixin.close(e)},initElement:function(e,t){var n=this;zt.initElement.call(n,e,t),n.onDispose(ie.on(e,"click",(function(){pe(n.flyoutMixin.elements()[0],e,n.flyoutMixin.getOptions())})))}});var Bt=Nt.prototype,Qt=new WeakMap;function _t(){var e=this;Nt.call(e,["open","closing","visible","tweening-in","tweening-out"]),e.modal=!1,e.tabThrough=!1,e.isFlyoutOpened=!1,e.animating=!1,e.visible=!1,e.initialFocus=void 0,e.toggle=new Ut(e),e.onDispose((function(){e.isFlyoutOpened=!1,e.visible=!1,e.toggle.dispose()}))}h(_t,Nt,{getOptions:function(){var e=this,t=L(e,["closeOnBlur"]);return void 0!==e.initialFocus&&(t.focus=e.initialFocus),t},next:function(){return this.effects=void 0,Bt.next.call(this)},withEffects:function(){return this.effects=j(arguments),this},getCustomAttributes:function(){var e=this;return x(Bt.getCustomAttributes.call(e),{"is-flyout":"","swipe-dismiss":e.swipeToDismiss},e.modal&&{"is-modal":""},e.tabThrough&&{"tab-through":""},e.effects&&{"animate-on":"open","animate-in":e.effects.join(" "),"animate-out":""})},open:function(e,t){return fe(this.elements()[0],e,t,this.getOptions())},close:function(e){return le(this.elements()[0],e)},onOpen:function(e){var t=this.elements()[0];return this.onToggleState((function(n){if(n)return e(Qt.get(t))}))},onToggleState:function(e){return this.watch("isFlyoutOpened",e)},onVisibilityChanged:function(e){return this.watch("visible",e)},initElement:function(e,t){var n=this;Bt.initElement.call(n,e,t),n.onDispose(Se.on(e,{flyoutshow:function(t){Qt.set(e,t.data),n.isFlyoutOpened=!0,n.visible=!0},flyoutclose:function(){n.isFlyoutOpened=!1},flyouthide:function(){n.visible=!1},animationstart:function(){n.animating=!0},animationcomplete:function(){n.animating=!1}},!0))}});var Ht=Ot.prototype;function Wt(){Ot.call(this)}h(Wt,Ot,{for:function(e){return this.state.ref=e,this},initElement:function(e,t){Ht.initElement.call(this,e,t);var n=function(n,i){var r=t.ref,o=r&&("string"==typeof r?e.querySelector(r):r.current);o&&!ie.focused(o)&&n(i||o)};this.onDispose(ie.on(e,{focusin:function(i){t.focused=i.source,ne(e,"focused",i.source),n(ie.focus)},focusout:function(){t.focused=!1,ne(e,"focused",!1)},focuschange:function(){n(ie.blur,e)}}))},onLayoutEffect:function(e,t){ne(e,"focused",t.focused)}});var Gt=ce.getDirectiveComponent,$t=Nt.prototype;function Jt(){Nt.call(this,["loading","loading-complete"]),this.loading=!1}h(Jt,Nt,{initElement:function(e,t){var i=this;$t.initElement.call(i,e,t),Gt(e).enableLoadingClass=!0,i.onDispose(ue(e,(function(t){i.loading=t||!!n(i.elements(),(function(t){return t!==e&&!0===Z(t,"loading")}))})))}});var Kt=Nt.prototype;function Xt(){var e=this;Nt.call(e,["scrollable-x","scrollable-x-l","scrollable-x-r","scrollable-y","scrollable-y-d","scrollable-y-u"]),e.target=Ct.scrollableTarget,e.pageIndex=0,e.scrolling=!1}function Yt(){Ot.call(this)}function Zt(){Nt.call(this)}function en(e){x(this,e)}function tn(e){return function(){var t=pn(e);return(t.withOptions||en).apply(t,arguments),t}}h(Xt,Nt,{withOptions:function(e){return this.options=e,this},getCustomAttributes:function(){var e=this.options||{};return x(Kt.getCustomAttributes.call(this),{scrollable:[e.direction||"both",e.handle||"auto"].join(" ")},e.pagedItemSelector&&{"scroller-snap-page":e.paged,"scroller-page":e.pagedItemSelector},e.persistScroll&&{"persist-scroll":""})},onPageIndexChanged:function(e){return this.watch("pageIndex",e)},initElement:function(e,t){var n=this;Kt.initElement.call(n,e,t),n.onDispose(Se.on(e,{scrollIndexChange:function(e){n.pageIndex=e.newIndex},scrollStart:function(){n.scrolling=!0},scrollStop:function(){n.scrolling=!1}},!0))}}),g("destroy enable disable setOptions setStickyPosition refresh scrollPadding stop scrollLeft scrollTop scrollBy scrollTo scrollByPage scrollToPage scrollToElement",(function(e,t){f(Xt.prototype,t,(function(){return Gt(this.elements()[0]).scrollable[t].apply(null,arguments)}))})),h(Yt,Ot,{when:function(e){return this.state.deps=e,this},initElement:function(e,t){t.callback=function(){te(e)}},mergeState:function(e,t,n){n.deps&&!w(n.deps,t.deps)&&Q(t.callback),x(t,n)}}),h(Zt,Nt,{memorize:function(){return this.classNames=j(arguments),this}});var nn=tn(jt),rn=tn(It),on=tn(Dt),an=tn(_t),sn=tn(Wt),un=tn(Jt),cn=tn(Xt),ln=tn(Yt),fn=tn(Zt);function pn(e){return(0,de.useSingleton)((function(){return new e})).reset()}function mn(e){return e&&e.getMixin().reset()}u(window,"brew-js-react",(function(){return console.warn('window["brew-js-react"] is deprecated, access brew.react instead.'),brew.react}))})(),l})()));
|
|
3
3
|
//# sourceMappingURL=brew-js-react.min.js.map
|