brew-js-react 0.4.7 → 0.4.8
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/dist/brew-js-react.js +84 -79
- 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/hooks.js +53 -40
- package/package.json +5 -5
- package/view.js +6 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! brew-js-react v0.4.
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("brew-js"),require("react"),require("react-dom"),function(){try{return require("react-dom/client")}catch(e){}}(),require("zeta-dom"),require("zeta-dom-react"),require("waterpipe")):"function"==typeof define&&define.amd?define("brew-js-react",["brew-js","react","react-dom","react-dom/client","zeta-dom","zeta-dom-react","waterpipe"],t):"object"==typeof exports?exports["brew-js-react"]=t(require("brew-js"),require("react"),require("react-dom"),function(){try{return require("react-dom/client")}catch(e){}}(),require("zeta-dom"),require("zeta-dom-react"),require("waterpipe")):e["brew-js-react"]=t(e.brew,e.React,e.ReactDOM,e["react-dom/client"],e.zeta,e["zeta-dom-react"],e.waterpipe)}(self,(function(e,t,n,r,i,o,a){return(()=>{var s={715:e=>{"use strict";if(void 0===r){var t=new Error("Cannot find module 'react-dom/client'");throw t.code="MODULE_NOT_FOUND",t}e.exports=r},28:e=>{"use strict";e.exports=a},103:e=>{"use strict";e.exports=o},80:t=>{"use strict";t.exports=e},359:e=>{"use strict";e.exports=t},318:e=>{"use strict";e.exports=n},654:e=>{"use strict";e.exports=i},662:(e,t,n)=>{var r,i=n(318);try{r=n(715)}catch(e){r={createRoot:(e,t)=>({render(t){i.render(t,e)},unmount(){i.unmountComponentAtNode(e)}}),hydrateRoot:(e,t,n)=>(i.hydrate(t,e),{render(t){i.render(t,e)},unmount(){i.unmountComponentAtNode(e)}})}}e.exports=r}},c={};function u(e){var t=c[e];if(void 0!==t)return t.exports;var n=c[e]={exports:{}};return s[e](n,n.exports,u),n.exports}u.d=(e,t)=>{for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u.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";u.d(l,{default:()=>sn});var e={};u.r(e),u.d(e,{AnimateMixin:()=>Ot,AnimateSequenceItemMixin:()=>Rt,AnimateSequenceMixin:()=>Vt,ClassNameMixin:()=>Et,Dialog:()=>ye,FlyoutMixin:()=>qt,FlyoutToggleMixin:()=>kt,FocusStateMixin:()=>Ut,LoadingStateMixin:()=>Wt,Mixin:()=>vt,ScrollIntoViewMixin:()=>Zt,ScrollableMixin:()=>Gt,StatefulMixin:()=>St,ViewStateContainer:()=>ct,createDialog:()=>ve,default:()=>an,isViewMatched:()=>Ge,linkTo:()=>Xe,makeTranslation:()=>ht,matchView:()=>Ze,navigateTo:()=>Ye,redirectTo:()=>et,registerErrorView:()=>$e,registerView:()=>Qe,renderView:()=>Je,resolvePath:()=>Ke,useAnimateMixin:()=>Jt,useAnimateSequenceMixin:()=>Kt,useAppReady:()=>it,useAppReadyState:()=>ot,useFlyoutMixin:()=>Xt,useFocusStateMixin:()=>Yt,useLanguage:()=>dt,useLoadingStateMixin:()=>en,useMixin:()=>rn,useMixinRef:()=>on,useRouteParam:()=>at,useRouteState:()=>st,useScrollIntoViewMixin:()=>nn,useScrollableMixin:()=>tn,useViewContainerState:()=>He,useViewContext:()=>He});var t=u(80);const n=t;var r=t.install;t.addExtension,t.addDetect,t.isElementActive;const i=n;var o=u(359),a=u(318);const s=u(662);var c=u(654),f=c.util,p=f.noop,m=f.pipe,d=f.either,h=(f.sameValueZero,f.is,f.isUndefinedOrNull),g=(f.isArray,f.isFunction),v=f.isThenable,y=(f.isPlainObject,f.isArrayLike,f.makeArray),w=f.extend,b=f.each,x=f.map,S=f.grep,C=(f.splice,f.any),P=f.single,E=f.kv,A=(f.fill,f.pick),O=f.exclude,M=(f.mapObject,f.mapGet,f.mapRemove,f.arrRemove),R=f.setAdd,N=f.equal,T=f.combineFn,V=f.executeOnce,F=f.createPrivateStore,k=(f.setTimeout,f.setTimeoutOnce,f.setInterval,f.setIntervalSafe,f.setImmediate),I=f.setImmediateOnce,j=(f.throws,f.throwNotFunction),D=(f.errorWithCode,f.isErrorWithCode,f.keys),q=f.values,L=(f.hasOwnProperty,f.getOwnPropertyDescriptors,f.define),U=f.definePrototype,z=f.defineOwnProperty,W=(f.defineGetterProperty,f.defineHiddenProperty),_=f.defineAliasProperty,B=f.defineObservableProperty,H=f.watch,G=(f.watchOnce,f.watchable),Z=f.inherit,Q=f.freeze,$=(f.deepFreeze,f.iequal,f.randomId),J=(f.repeat,f.camel,f.hyphenate,f.ucfirst,f.lcfirst,f.trim,f.matchWord,f.matchWordMulti,f.htmlDecode,f.resolve,f.reject,f.always),K=f.resolveAll,X=(f.retryable,f.deferrable,f.catchAsync),Y=(f.setPromiseTimeout,f.delay,f.makeAsync),ee=c.util,te=(ee.domReady,ee.tagName,ee.isVisible,ee.matchSelector,ee.comparePosition,ee.connected,ee.containsOrEquals),ne=(ee.acceptNode,ee.combineNodeFilters,ee.iterateNode,ee.iterateNodeToArray,ee.getCommonAncestor,ee.parentsAndSelf,ee.selectIncludeSelf,ee.selectClosestRelative,ee.createNodeIterator,ee.createTreeWalker,ee.bind),re=(ee.bindUntil,ee.dispatchDOMMouseEvent,ee.removeNode),ie=(ee.getClass,ee.setClass),oe=(ee.getSafeAreaInset,ee.getScrollOffset,ee.getScrollParent,ee.getContentRect,ee.scrollBy,ee.scrollIntoView);ee.makeSelection,ee.getRect,ee.getRects,ee.toPlainRect,ee.rectEquals,ee.rectCovers,ee.rectIntersects,ee.pointInRect,ee.mergeRect,ee.elementFromPoint;const ae=c.dom;var se=c.dom;se.textInputAllowed,se.beginDrag,se.beginPinchZoom,se.insertText,se.getShortcut,se.setShortcut,se.focusable,se.focused,se.setTabRoot,se.unsetTabRoot,se.setModal,se.releaseModal,se.retainFocus,se.releaseFocus,se.iterateFocusPath,se.focus,se.blur;const ce=ae;var ue=c.dom,le=ue.lock,fe=(ue.locked,ue.cancelLock,ue.subscribeAsync),pe=ue.notifyAsync,me=ue.preventLeave,de=(t.addAsyncAction,t.isFlyoutOpen,t.closeFlyout),he=t.toggleFlyout,ge=t.openFlyout;function ve(e){var t,n=document.createElement("div"),r=s.createRoot(n),i=de.bind(0,n);return ce.on(n,{flyouthide:function(){re(n),(e.onClose||p)(n),e.onRender&&r.unmount()},asyncStart:function(){ie(n,"loading",!0)},asyncEnd:function(){ie(n,"loading",!1)}}),fe(n),{root:n,close:i,open:function(){if(t)return t;if(n.className=e.className||"",document.body.appendChild(n),ce.retainFocus(ce.activeElement,n),e.modal&&(n.setAttribute("is-modal",""),ce.setModal(n)),e.onRender){var a=w({},e,{closeDialog:function(t){var n=Y(e.onCommit||m)(t);return pe(ce.activeElement,n),n.then(i)}}),s=(0,o.createElement)(e.onRender,a);e.wrapper&&(s=(0,o.createElement)(e.wrapper,a,s)),r.render(s),k((function(){ce.focus(n)}))}return t=ge(n),e.preventLeave?me(n,t):e.preventNavigation&&le(n,t),J(t,(function(){t=null})),(e.onOpen||p)(n),t}}}function ye(e){var t=(0,o.useState)({})[0],n=(0,o.useState)((function(){return ve(t)}))[0];return w(t,e),(0,o.useEffect)((function(){var e=te(ce.root,n.root);d(e,t.isOpen)&&(e?n.close():n.open())}),[t.isOpen]),(0,o.useEffect)((function(){return n.close}),[n]),a.createPortal(e.children,n.root)}var we=u(103),be=c.EventContainer;const xe=t.defaults;var Se,Ce=[];r("react",(function(e){Se=e,T(Ce)(Se)})),xe.react=!0;var Pe,Ee,Ae=t.animateIn,Oe=t.animateOut,Me=(t.addAnimateIn,t.addAnimateOut,t.setBaseUrl,t.combinePath,t.parsePath,t.normalizePath,t.removeQueryAndHash),Re=(t.withBaseUrl,t.toAbsoluteUrl,t.toRelativeUrl,t.isSubPathOf,t.toSegments,F()),Ne=ce.root,Te=new Map,Ve={},Fe=[],ke=new be,Ie=Q(w(new qe(null,null),{container:Ne})),je=o.createContext(Ie),De={};function qe(e,t){var n=this;z(n,"view",e,!0),Re(n,{children:[],setPage:B(n,"page",t,!0),setActive:B(n,"active",!0,!0)}),H(n,"page",(function(e,t){ke.emit("pagechange",n,{previousPage:t})}))}function Le(){o.Component.apply(this,arguments),this.state={}}function Ue(){o.Component.apply(this,arguments)}function ze(e,t,n){var r=Te.get(e);if(!r.maxParams){var i=O(r.matchers,["remainingSegments"]),o=x(Se.routes,(function(e){var t=Se.parseRoute(e),n=t.length&&!C(i,(function(e,n){var r=t.params[n];return(e?!(r>=0):r<t.minLength)||!g(e)&&!t.match(n,e)}));return n?t:null}));if(o[1]&&(o=S(o,(function(e){return!P(e.params,(function(e,t){return Ve[t]&&!i[t]}))}))),o[0]){var a=o.slice(-1)[0];r.maxParams=D(w.apply(0,[{remainingSegments:!0}].concat(o.map((function(e){return e.params}))))),r.minParams=x(a.params,(function(e,t){return r.params[t]||e>=a.minLength?null:t}))}}return A(n||Se.route,t?r.maxParams:r.minParams)}function We(e,t){return(Te.get(t)||{}).matchCount-(Te.get(e)||{}).matchCount}function _e(e,t){var n=Te.get(e);return!!n&&!P(n.matchers,(function(e,n){var r=t[n]||"";return g(e)?!e(r):(e||"")!==r}))}function Be(e){var t;return j(e),e.prototype instanceof o.Component&&(e=o.createElement.bind(null,e)),function(n){var r=n.viewProps,i=!t&&e(r);v(i)&&(t=i,i=null,X(t));var a=(0,we.useAsync)((function(){return t.then((function(e){return o.createElement(e.default,r)}))}),!!t)[1];if((!t||!a.loading)&&(n.onComponentLoaded(),a.error))throw a.error;return i||a.value||o.createElement(o.Fragment)}}function He(){return o.useContext(je)}function Ge(e){return _e(e,Se.route)}function Ze(e,t){var n=Se.route;return"string"==typeof e?n=n.parse(e):t=e,t=t?y(t).sort(We):Fe,C(t,(function(e){return _e(e,n)}))||void 0}function Qe(e,t){var n=Be(e);return t=w({},t),b(t,(function(e,n){Ve[e]=!0,n instanceof RegExp&&(t[e]=n.test.bind(n))})),Te.set(n,{id:$(),matchCount:D(t).length,matchers:t,params:A(t,(function(e){return h(e)||"string"==typeof e}))}),Fe.push(n),Fe.sort(We),n}function $e(e){Pe=Be(e)}function Je(){var e=y(arguments),t=g(e[0])?{}:e.shift(),n=e[0];return b(e,(function(e,t){if(!Te.has(t))throw new Error("Invalid argument to renderView: "+(g(t)?t.name:t))})),e.sort(We),o.createElement(Ue,{rootProps:t,views:e,defaultView:n})}function Ke(e,t){var n=Te.get(e);if(!n)return"/";var r=w(ze(e),ze(e,!0,t||{}),n.params);return Se.route.getPath(r)}function Xe(e,t){return Se.toHref(Ke(e,t))}function Ye(e,t,n,r){return Se.navigate(Ke(e,t),r,n&&Q(w({},n)))}function et(e,t,n){return Ye(e,t,n,!0)}Ee=function(){Se.on("beforepageload",(function(e){De=e,e.waitFor(new Promise((function(e){!function t(n){if(!n[0])return e();K(x(n,(function(e){return new Promise((function(t){e.onRender=t,e.forceUpdate()}))}))).then((function(){t(x(n,(function(e){return e.children})))}))}(Re(Ie).children)}))),Re(Ie).setPage(Se.page)}))},Ce.push(j(Ee)),U(qe,{on:function(e,t){return ke.add(this,e,t)}}),Le.contextType=je,U(Le,o.Component,{componentDidCatch:function(e){var t=this;Pe&&!t.state.error?t.setState({error:e}):k((function(){ce.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?o.createElement(Pe,{onComponentLoaded:n,viewProps:t}):o.createElement(t.view,{onComponentLoaded:n,viewProps:e.props.viewProps})},reset:function(){this.setState({error:null})}}),Ue.contextType=je,U(Ue,o.Component,{componentDidMount:function(){var e=this,t=Re(e.context).children;t.push(e),e.componentWillUnmount=T(H(Se.route,(function(){(e.setActive||p)(e.getViewComponent()===e.currentViewComponent)})),(function(){M(t,e)}))},render:function(){var e=this;return e.context.active&&e.updateView(),(e.onRender||p)(),o.createElement(o.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 r=Ke(t,ze(t,!0));if(r!==Me(Se.path))return void Se.navigate(r,!0)}if(t&&n){var i,a=e.currentElement;a&&(e.setActive(!1),e.prevView=e.currentView,e.currentElement=void 0,Se.emit("pageleave",a,{pathname:e.currentPath},!0),Oe(a,"show").then((function(){e.prevView=void 0,e.forceUpdate()}))),(e.cancelPrevious||p)();var s=new Promise((function(e){i=e})),c=V((function(t){e.currentElement=t,u.container=t,s.then((function(){Ae(t,"show"),Se.emit("pageenter",t,{pathname:Se.path},!0)})),pe(t,s)})),u=new qe(t,Se.page),l=Q({navigationType:De.navigationType,viewContext:u,viewData:De.data||{}}),f=o.createElement(je.Provider,{key:Te.get(t).id,value:u},o.createElement(ct,null,o.createElement("div",w({},e.props.rootProps,{ref:c}),o.createElement(Le,{onComponentLoaded:i,viewProps:l}))));w(e,Re(u),{cancelPrevious:i,currentPath:Se.path,currentView:f,currentViewComponent:t}),(De.waitFor||p)(s)}(e.setPage||p)(Se.page)},getViewComponent:function(){var e=this.props;return C(e.views,Ge)||e.defaultView}});var tt=new be;function nt(){return Se.historyStorage.current}function rt(e,t){this.key=e,this.value=t}function it(){return ot().ready}function ot(){var e=(0,we.useObservableProperty)(Se,"readyState");return{ready:"ready"===e,error:"error"===e}}function at(e,t){var n=He(),r=n.page.params,i=Se.route,a=r[e]||"",s=(0,o.useRef)(a),c=(0,we.useUpdateTrigger)();return(0,o.useEffect)((function(){var t=function t(){var r=i[e]||"";r!==s.current&&(n.active?(s.current=r,c()):H(n,"active",t))};if(t(),e in i)return i.watch(e,(function(){I(t)}));console.error("Route parameter "+e+" does not exist")}),[e,t]),s.current=a,t&&n.active&&(!a||"remainingSegments"===e&&"/"===a)&&Se.navigate(i.getPath(w({},r,E(e,t))),!0),a}function st(e,t,n){var r=He(),i=nt(),a=(0,o.useState)(i.has(e)?i.get(e):t);return r.active&&i.get(e)!==a[0]&&(n&&i.has(e)&&(Se.snapshot(),i=nt()),i.set(e,a[0])),(0,o.useEffect)((function(){if(n)return ne(window,"popstate",(function(){if(r.active){var n=nt();a[1](n.has(e)?n.get(e):t)}}))}),[r,n]),a}function ct(e){var t=He(),n=(0,o.useState)((function(){var e={};return{getState:function(n,r){var i=nt(),o=i.get(r),a=e[n]||(e[n]=new rt(r,o));if(t.active){var s=a.store;s&&(s!==i&&i.has(r)||r!==a.key)&&(tt.emit("popstate",a,{newValue:o}),a.value=o,a.key=r),a.store=i,i.set(r,a.value)}return a}}}))[0];return(0,o.createElement)(we.ViewStateProvider,{value:n},e.children)}U(rt,{get:function(){return this.value},set:function(e){var t=this;t.value=e,t.store.set(t.key,e)},onPopState:function(e){return j(e),tt.add(this,"popstate",(function(t){e.call(this,t.newValue)}))}});const ut=u(28);var lt=Object.create(null),ft="function"==typeof Symbol&&Symbol.toPrimitive;function pt(e){this.toString=e}function mt(e){return w((function(t,n,r){var i=e(t,n,r,!0);return void 0!==i?i:t}),{html:function(t,n,r){return{__html:e(t,n,r)}},lazy:function(t,n,r){return new pt(e.bind(0,t,n,r,!0))}})}function dt(){return(0,we.useObservableProperty)(Se,"language")}function ht(e,t){var n=new RegExp("^("+Object.keys(e[t]).join("|")+")\\."),r={};function i(n,r,o,a,s){var c=((e[s]||lt)[n]||lt)[r];return"string"==typeof c?!c||a&&void 0===o?c:ut(c,o,{noEncode:a}):s!==t?i(n,r,o,a,t):void 0}function o(e,t,r,o){var a=n.test(e)?RegExp.$1:"";return i(a,a?e.slice(RegExp.lastMatch.length):e,t,o,r||Se.language)}function a(){var e=String(this),t=y(arguments),n=e+" "+t.join(" ");return r[n]||(r[n]=t[0]?mt((function(n,r,o,a){return o=o||e||Se.language,P(t,(function(e){return i(e,n,r,a,o)}))})):mt((function(t,n,r,i){return o(t,n,r||e,i)})))}return{translate:mt(o),getTranslation:a.bind(""),useTranslation:function(){var e=dt(),t=a.apply(e,arguments);return{language:e,t}},keys:function(n){return D(e[t][n]||lt)}}}function gt(e){vt.call(this),this.attributes=e||{}}function vt(){}ft&&(pt.prototype[ft]=function(){return this.toString()}),U(gt,vt,{getCustomAttributes:function(){return w({},this.attributes)}}),U(vt,{next:function(){},getRef:function(){return p},getClassNames:function(){return[]},getCustomAttributes:function(){return{}},dispose:function(){}}),G(vt.prototype),L(vt,{get scrollableTarget(){return new gt({"scrollable-target":""})},use:function(){var e=y(arguments),t=e[0],n={},r=e.filter((function(e){return e instanceof vt})),i=r.map((function(e){return e.getRef()}));return!t||t instanceof vt?t||e.shift():("function"!=typeof t?i.push((function(e){t.current=e})):i.push(t),e.shift()),b(r,(function(e,t){w(n,t.getCustomAttributes())})),w(n,{ref:T(i),className:we.classNames.apply(null,e)}),b(r,(function(e,t){t.next()})),n}});var yt=c.dom,wt=(yt.observe,yt.registerCleanup,yt.createAutoCleanupMap,yt.afterDetached,yt.watchElements,yt.watchAttributes,yt.watchOwnAttributes),bt=F();function xt(e){this.mixin=e}function St(){vt.call(this),bt(this,{elements:new WeakSet,flush:H(this,!1),dispose:[],states:{},prefix:"",counter:0})}U(xt,{getMixin:function(){return this.mixin}}),U(St,vt,{get ref(){var e=this,t=e.state;return e.next(),t.ref||(t.ref=new xt(e.clone()))},get state(){var e=bt(this),t=e.prefix+e.counter;return e.states[t]||(e.states[t]=this.initState())},reset:function(){return bt(this).counter=0,this},next:function(){return bt(this).counter++,this},getRef:function(){var e=this,t=e.state;return function(n){t.element=n,n&&R(bt(e).elements,n)&&e.initElement(n,t)}},elements:function(){return q(bt(this).states).map((function(e){return e.element})).filter((function(e){return e}))},onDispose:function(e){bt(this).dispose.push(e)},initState:function(){return{element:null}},initElement:function(e,t){},clone:function(){var e=this,t=Z(Object.getPrototypeOf(e),e);return bt(t,w({},bt(e),{prefix:$()+".",counter:0})),t},dispose:function(){var e=bt(this),t=e.states;T(e.dispose.splice(0))(),e.flush(),e.elements=new WeakSet,b(t,(function(e,n){delete t[e]}))}});var Ct=St.prototype;function Pt(e,t,n,r){var i=n.classNames,o=w({},i);if(b(e.classNames,(function(e,n){i[n]=t.classList.contains(n)})),!N(o,i)){var a=e.onClassNameUpdated.bind(e,t,o,w({},i));r?k(a):a()}}function Et(e){St.call(this),this.classNames=e||[]}U(Et,St,{getClassNames:function(){return[this.state.classNames]},getRef:function(){var e=this,t=e.state.element;return t&&te(ce.root,t)&&Pt(e,t,e.state,!0),Ct.getRef.call(this)},initState:function(){return{element:null,classNames:{}}},initElement:function(e,t){var n=this;wt(e,"class",(function(){Pt(n,e,t)}))},onClassNameUpdated:function(e,t,n){}});var At=Et.prototype;function Ot(){Et.call(this,["tweening-in","tweening-out"])}U(Ot,Et,{next:function(){var e=this;return e.effects=void 0,e.trigger=void 0,At.next.call(e)},with:function(e){var t=this;return t.effects=e.effects,t.trigger=e.trigger,t},withEffects:function(){return this.effects=y(arguments),this},getCustomAttributes:function(){var e=this;return w({},At.getCustomAttributes.call(e),{"animate-in":(e.effects||[]).join(" "),"animate-on":e.trigger||"show"})}});var Mt=Et.prototype;function Rt(e){Et.call(this,["tweening-in","tweening-out"]),this.className=e}U(Rt,Et,{getClassNames:function(){return[this.className].concat(Mt.getClassNames.call(this))}});var Nt=Ot.prototype,Tt=0;function Vt(){var e=this;Ot.call(e),e.className="brew-anim-"+ ++Tt,e.item=new Rt(e.className)}U(Vt,Ot,{withOptions:function(e){return this.selector=e,this},reset:function(){return this.item.reset(),Nt.reset.call(this)},getCustomAttributes:function(){var e=this;return w({},Nt.getCustomAttributes.call(e),{"animate-in":null,"animate-sequence-type":(e.effects||[]).join(" "),"animate-sequence":e.selector||"."+e.className})},clone:function(){return w(Nt.clone.call(this),{item:this.item.ref.getMixin()})}});var Ft=Et.prototype;function kt(e){Et.call(this,["target-opened"]),this.flyoutMixin=e}U(kt,Et,{open:function(e){return this.flyoutMixin.open(e)},close:function(e){return this.flyoutMixin.close(e)},initElement:function(e,t){var n=this;Ft.initElement.call(n,e,t),n.onDispose(ce.on(e,"click",(function(){he(n.flyoutMixin.elements()[0],e)})))}});var It=Et.prototype,jt=new WeakMap,Dt="animating isFlyoutOpened modal tabThrough visible".split(" ");function qt(){var e=this;Et.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.toggle=new kt(e),e.onDispose((function(){e.isFlyoutOpened=!1,e.visible=!1}))}U(qt,Et,{reset:function(){return this.toggle.reset(),It.reset.call(this)},next:function(){return this.effects=void 0,It.next.call(this)},withEffects:function(){return this.effects=y(arguments),this},getCustomAttributes:function(){var e=this;return w({},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){var t=this.elements()[0];return jt.set(t,e),ge(t)},close:function(e){return de(this.elements()[0],e)},onOpen:function(e){var t=this.elements()[0];return this.onToggleState((function(n){if(n)return e(jt.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(Se.on(e,{animationstart:function(){n.animating=!0},animationcomplete:function(){n.animating=!1}},!0))},clone:function(){var e=this,t=w(It.clone.call(e),{toggle:e.toggle.ref.getMixin()});return b(Dt,(function(n,r){_(t,r,e)})),t},onClassNameUpdated:function(e,t,n){this.visible=n.open,this.isFlyoutOpened=n.open&&!n.closing&&!n["tweening-out"]}});var Lt=St.prototype;function Ut(){St.call(this)}U(Ut,St,{for:function(e){return this.state.ref=e,this},initElement:function(e,t){Lt.initElement.call(this,e,t);var n=function(n,r){var i=t.ref,o=i&&("string"==typeof i?e.querySelector(i):i.current);o&&!ce.focused(o)&&n(r||o)};this.onDispose(ce.on(e,{focusin:function(r){t.focused=r.source,ie(e,"focused",r.source),n(ce.focus)},focusout:function(){t.focused=!1,ie(e,"focused",!1)},focuschange:function(){n(ce.blur,e)}}))},getClassNames:function(){var e={},t=this.state.focused;return t&&(e.focused=!0,e["focused-"+t]=!0),[e]}});var zt=St.prototype;function Wt(){St.call(this)}U(Wt,St,{initElement:function(e,t){zt.initElement.call(this,e,t),this.onDispose(fe(e,(function(n){t.loading=n,ie(e,"loading",n)})))},getClassNames:function(){return[{loading:!!this.state.loading}]}});var _t=t.getDirectiveComponent,Bt=(t.registerDirective,Et.prototype),Ht="pageIndex scrolling".split(" ");function Gt(){var e=this;Et.call(e,["scrollable-x","scrollable-x-l","scrollable-x-r","scrollable-y","scrollable-y-d","scrollable-y-u"]),e.target=vt.scrollableTarget,e.pageIndex=0,e.scrolling=!1}function Zt(){St.call(this)}function Qt(e){w(this,e)}function $t(e){return function(){var t=rn(e);return(t.withOptions||Qt).apply(t,arguments),t}}U(Gt,Et,{withOptions:function(e){return this.options=e,this},getCustomAttributes:function(){var e=this.options||{};return w({},Bt.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;n.onDispose(Se.on(e,{scrollIndexChange:function(e){n.pageIndex=e.newIndex},scrollStart:function(){n.scrolling=!0},scrollStop:function(){n.scrolling=!1}},!0))},clone:function(){var e=Bt.clone.call(this);return b(Ht,(function(t,n){_(e,n,self)})),e}}),b("destroy enable disable setOptions setStickyPosition refresh scrollPadding stop scrollLeft scrollTop scrollBy scrollTo scrollByPage scrollToPage scrollToElement",(function(e,t){W(Gt.prototype,t,(function(){var e=_t(this.elements()[0]);return e.scrollable[t].apply(null,arguments)}))})),U(Zt,St,{when:function(e){var t=this.state,n=t.callback||(t.callback=function(){oe(t.element)});return t.deps&&!N(e,t.deps)&&I(n),t.deps=y(e),this}});var Jt=$t(Ot),Kt=$t(Vt),Xt=$t(qt),Yt=$t(Ut),en=$t(Wt),tn=$t(Gt),nn=$t(Zt);function rn(e){return(0,we.useSingleton)((function(){return new e})).reset()}function on(e){return e&&e.getMixin().reset()}const an=i,sn=e;i.react=e})(),l=l.default})()}));
|
|
1
|
+
/*! brew-js-react v0.4.8 | (c) misonou | https://hackmd.io/@misonou/brew-js-react */
|
|
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")):"function"==typeof define&&define.amd?define("brew-js-react",["brew-js","react","react-dom","zeta-dom","zeta-dom-react","waterpipe"],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")):e["brew-js-react"]=t(e.brew,e.React,e.ReactDOM,e.zeta,e["zeta-dom-react"],e.waterpipe)}(self,(function(e,t,n,r,i,o){return(()=>{var a={28:e=>{"use strict";e.exports=o},103:e=>{"use strict";e.exports=i},80:t=>{"use strict";t.exports=e},359:e=>{"use strict";e.exports=t},318:e=>{"use strict";e.exports=n},654:e=>{"use strict";e.exports=r},862:(e,t,n)=>{var r,i=n(318);r=i.createRoot?i:{createRoot:(e,t)=>({render(t){i.render(t,e)},unmount(){i.unmountComponentAtNode(e)}}),hydrateRoot:(e,t,n)=>(i.hydrate(t,e),r.createRoot(e,n))},e.exports=r}},s={};function u(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return a[e](n,n.exports,u),n.exports}u.d=(e,t)=>{for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return(()=>{"use strict";u.d(c,{default:()=>ln});var e={};u.r(e),u.d(e,{AnimateMixin:()=>Nt,AnimateSequenceItemMixin:()=>Vt,AnimateSequenceMixin:()=>It,ClassNameMixin:()=>Ot,Dialog:()=>ye,FlyoutMixin:()=>zt,FlyoutToggleMixin:()=>Dt,FocusStateMixin:()=>Bt,LoadingStateMixin:()=>Ht,Mixin:()=>bt,ScrollIntoViewMixin:()=>Jt,ScrollableMixin:()=>$t,StatefulMixin:()=>Et,ViewStateContainer:()=>ft,createDialog:()=>ve,default:()=>cn,isViewMatched:()=>Ze,linkTo:()=>Ye,makeTranslation:()=>yt,matchView:()=>Qe,navigateTo:()=>et,redirectTo:()=>tt,registerErrorView:()=>Je,registerView:()=>$e,renderView:()=>Ke,resolvePath:()=>Xe,useAnimateMixin:()=>Yt,useAnimateSequenceMixin:()=>en,useAppReady:()=>st,useAppReadyState:()=>ut,useFlyoutMixin:()=>tn,useFocusStateMixin:()=>nn,useLanguage:()=>vt,useLoadingStateMixin:()=>rn,useMixin:()=>sn,useMixinRef:()=>un,useRouteParam:()=>ct,useRouteState:()=>lt,useScrollIntoViewMixin:()=>an,useScrollableMixin:()=>on,useViewContainerState:()=>Ge,useViewContext:()=>Ge});var t=u(80);const n=t;var r=t.install;t.addExtension,t.addDetect,t.isElementActive;const i=n;var o=u(359),a=u(318);const s=u(862);var l=u(654),f=l.util,p=f.noop,m=f.pipe,d=f.either,h=(f.sameValueZero,f.is,f.isUndefinedOrNull),g=(f.isArray,f.isFunction),v=f.isThenable,y=(f.isPlainObject,f.isArrayLike,f.makeArray),w=f.extend,b=f.each,x=f.map,S=f.grep,C=(f.splice,f.any),P=f.single,E=f.kv,A=(f.fill,f.pick),M=f.exclude,O=(f.mapObject,f.mapGet,f.mapRemove,f.arrRemove),R=f.setAdd,N=f.equal,T=f.combineFn,V=f.executeOnce,k=f.createPrivateStore,F=(f.setTimeout,f.setTimeoutOnce,f.setInterval,f.setIntervalSafe,f.setImmediate),I=f.setImmediateOnce,j=(f.throws,f.throwNotFunction),D=(f.errorWithCode,f.isErrorWithCode,f.keys),q=f.values,L=(f.hasOwnProperty,f.getOwnPropertyDescriptors,f.define),U=f.definePrototype,z=f.defineOwnProperty,W=(f.defineGetterProperty,f.defineHiddenProperty),B=f.defineAliasProperty,_=f.defineObservableProperty,H=f.watch,G=(f.watchOnce,f.watchable),Z=f.inherit,Q=f.freeze,$=(f.deepFreeze,f.iequal,f.randomId),J=(f.repeat,f.camel,f.hyphenate,f.ucfirst,f.lcfirst,f.trim,f.matchWord,f.matchWordMulti,f.htmlDecode,f.resolve,f.reject,f.always),K=f.resolveAll,X=(f.retryable,f.deferrable,f.catchAsync),Y=(f.setPromiseTimeout,f.delay),ee=f.makeAsync,te=l.util,ne=(te.domReady,te.tagName,te.isVisible,te.matchSelector,te.comparePosition,te.connected,te.containsOrEquals),re=(te.acceptNode,te.combineNodeFilters,te.iterateNode,te.iterateNodeToArray,te.getCommonAncestor,te.parentsAndSelf,te.selectIncludeSelf,te.selectClosestRelative,te.createNodeIterator,te.createTreeWalker,te.bind,te.bindUntil,te.dispatchDOMMouseEvent,te.removeNode),ie=(te.getClass,te.setClass),oe=(te.getSafeAreaInset,te.getScrollOffset,te.getScrollParent,te.getContentRect,te.scrollBy,te.scrollIntoView);te.makeSelection,te.getRect,te.getRects,te.toPlainRect,te.rectEquals,te.rectCovers,te.rectIntersects,te.pointInRect,te.mergeRect,te.elementFromPoint;const ae=l.dom;var se=l.dom;se.textInputAllowed,se.beginDrag,se.beginPinchZoom,se.insertText,se.getShortcut,se.setShortcut,se.focusable,se.focused,se.setTabRoot,se.unsetTabRoot,se.setModal,se.releaseModal,se.retainFocus,se.releaseFocus,se.iterateFocusPath,se.focus,se.blur;const ue=ae;var ce=l.dom,le=ce.lock,fe=(ce.locked,ce.cancelLock,ce.subscribeAsync),pe=ce.notifyAsync,me=ce.preventLeave,de=(t.addAsyncAction,t.isFlyoutOpen,t.closeFlyout),he=t.toggleFlyout,ge=t.openFlyout;function ve(e){var t,n=document.createElement("div"),r=s.createRoot(n),i=de.bind(0,n);return ue.on(n,{flyouthide:function(){re(n),(e.onClose||p)(n),e.onRender&&r.unmount()},asyncStart:function(){ie(n,"loading",!0)},asyncEnd:function(){ie(n,"loading",!1)}}),fe(n),{root:n,close:i,open:function(){if(t)return t;if(n.className=e.className||"",document.body.appendChild(n),ue.retainFocus(ue.activeElement,n),e.modal&&(n.setAttribute("is-modal",""),ue.setModal(n)),e.onRender){var a=w({},e,{closeDialog:function(t){var n=ee(e.onCommit||m)(t);return pe(ue.activeElement,n),n.then(i)}}),s=(0,o.createElement)(e.onRender,a);e.wrapper&&(s=(0,o.createElement)(e.wrapper,a,s)),r.render(s),F((function(){ue.focus(n)}))}return t=ge(n),e.preventLeave?me(n,t):e.preventNavigation&&le(n,t),J(t,(function(){t=null})),(e.onOpen||p)(n),t}}}function ye(e){var t=(0,o.useState)({})[0],n=(0,o.useState)((function(){return ve(t)}))[0];return w(t,e),(0,o.useEffect)((function(){var e=ne(ue.root,n.root);d(e,t.isOpen)&&(e?n.close():n.open())}),[t.isOpen]),(0,o.useEffect)((function(){return n.close}),[n]),a.createPortal(e.children,n.root)}var we=u(103),be=l.EventContainer;const xe=t.defaults;var Se,Ce=[];r("react",(function(e){Se=e,T(Ce)(Se)})),xe.react=!0;var Pe,Ee,Ae=t.animateIn,Me=t.animateOut,Oe=(t.addAnimateIn,t.addAnimateOut,t.setBaseUrl,t.combinePath,t.parsePath,t.normalizePath,t.removeQueryAndHash),Re=(t.withBaseUrl,t.toAbsoluteUrl,t.toRelativeUrl,t.isSubPathOf,t.toSegments,k()),Ne=ue.root,Te=new Map,Ve={},ke=[],Fe=new be,Ie=Q(w(new Le(null,null),{container:Ne})),je=Re(Ie),De=o.createContext(Ie),qe={};function Le(e,t){var n=this;H(n,!0),z(n,"view",e,!0),Re(n,{children:[],setPage:_(n,"page",t,!0),setActive:_(n,"active",!!t,!0)}),H(n,"page",(function(e,t){Fe.emit("pagechange",n,{previousPage:t})}))}function Ue(){o.Component.apply(this,arguments),this.state={}}function ze(){o.Component.apply(this,arguments)}function We(e,t,n){var r=Te.get(e);if(!r.maxParams){var i=M(r.matchers,["remainingSegments"]),o=x(Se.routes,(function(e){var t=Se.parseRoute(e),n=t.length&&!C(i,(function(e,n){var r=t.params[n];return(e?!(r>=0):r<t.minLength)||!g(e)&&!t.match(n,e)}));return n?t:null}));if(o[1]&&(o=S(o,(function(e){return!P(e.params,(function(e,t){return Ve[t]&&!i[t]}))}))),o[0]){var a=o.slice(-1)[0];r.maxParams=D(w.apply(0,[{remainingSegments:!0}].concat(o.map((function(e){return e.params}))))),r.minParams=x(a.params,(function(e,t){return r.params[t]||e>=a.minLength?null:t}))}}return A(n||Se.route,t?r.maxParams:r.minParams)}function Be(e,t){return(Te.get(t)||{}).matchCount-(Te.get(e)||{}).matchCount}function _e(e,t){var n=Te.get(e);return!!n&&!P(n.matchers,(function(e,n){var r=t[n]||"";return g(e)?!e(r):(e||"")!==r}))}function He(e){var t;return j(e),e.prototype instanceof o.Component&&(e=o.createElement.bind(null,e)),function(n){var r=n.viewProps,i=!t&&e(r);v(i)&&(t=i,i=null,X(t));var a=(0,we.useAsync)((function(){return t.then((function(e){return o.createElement(e.default,r)}))}),!!t)[1];if((!t||!a.loading)&&(n.onComponentLoaded(),a.error))throw a.error;return i||a.value||o.createElement(o.Fragment)}}function Ge(){return o.useContext(De)}function Ze(e){return _e(e,Se.route)}function Qe(e,t){var n=Se.route;return"string"==typeof e?n=n.parse(e):t=e,t=t?y(t).sort(Be):ke,C(t,(function(e){return _e(e,n)}))||void 0}function $e(e,t){var n=He(e);return t=w({},t),b(t,(function(e,n){Ve[e]=!0,n instanceof RegExp&&(t[e]=n.test.bind(n))})),Te.set(n,{id:$(),matchCount:D(t).length,matchers:t,params:A(t,(function(e){return h(e)||"string"==typeof e}))}),ke.push(n),ke.sort(Be),n}function Je(e){Pe=He(e)}function Ke(){var e=y(arguments),t=g(e[0])?{}:e.shift(),n=e[0];return b(e,(function(e,t){if(!Te.has(t))throw new Error("Invalid argument to renderView: "+(g(t)?t.name:t))})),e.sort(Be),o.createElement(ze,{rootProps:t,views:e,defaultView:n})}function Xe(e,t){var n=Te.get(e);if(!n)return"/";var r=w(We(e),We(e,!0,t||{}),n.params);return Se.route.getPath(r)}function Ye(e,t){return Se.toHref(Xe(e,t))}function et(e,t,n,r){return Se.navigate(Xe(e,t),r,n&&Q(w({},n)))}function tt(e,t,n){return et(e,t,n,!0)}Ee=function(){Se.on("beforepageload",(function(e){je.setPage(Se.page),je.setActive(!0),qe=e,e.waitFor(new Promise((function(e){!function t(n){if(!n[0])return e();K(x(n,(function(e){return new Promise((function(t){e.onRender=t,e.forceUpdate()}))}))).then((function(){t(x(n,(function(e){return e.children})))}))}(je.children)})))}))},Ce.push(j(Ee)),U(Le,{on:function(e,t){return Fe.add(this,e,t)}}),Ue.contextType=De,U(Ue,o.Component,{componentDidCatch:function(e){var t=this;Pe&&!t.state.error?t.setState({error:e}):F((function(){ue.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?o.createElement(Pe,{onComponentLoaded:n,viewProps:t}):o.createElement(t.view,{onComponentLoaded:n,viewProps:e.props.viewProps})},reset:function(){this.setState({error:null})}}),ze.contextType=De,U(ze,o.Component,{componentDidMount:function(){var e=this,t=Re(e.context).children;t.push(e),e.componentWillUnmount=T(H(Se.route,(function(){(e.setActive||p)(e.getViewComponent()===e.currentViewComponent)})),(function(){O(t,e)}))},render:function(){var e=this;return e.context.active&&e.updateView(),(e.onRender||p)(),o.createElement(o.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 r=Xe(t,We(t,!0));if(r!==Oe(Se.path))return void Se.navigate(r,!0)}if(t&&n){var i,a=e.currentElement;a&&(e.setActive(!1),e.prevView=e.currentView,e.currentElement=void 0,Se.emit("pageleave",a,{pathname:e.currentPath},!0),Me(a,"show").then((function(){e.prevView=void 0,e.forceUpdate()}))),(e.cancelPrevious||p)();var s=new Promise((function(e){i=e})),u=V((function(t){e.currentElement=t,c.container=t,s.then((function(){Ae(t,"show"),Se.emit("pageenter",t,{pathname:Se.path},!0)})),pe(t,s)})),c=new Le(t,Se.page),l=Q({navigationType:qe.navigationType,viewContext:c,viewData:qe.data||{}}),f=o.createElement(De.Provider,{key:Te.get(t).id,value:c},o.createElement(ft,null,o.createElement("div",w({},e.props.rootProps,{ref:u}),o.createElement(Ue,{onComponentLoaded:i,viewProps:l}))));w(e,Re(c),{cancelPrevious:i,currentPath:Se.path,currentView:f,currentViewComponent:t}),(qe.waitFor||p)(s)}(e.setPage||p)(Se.page)},getViewComponent:function(){var e=this.props;return C(e.views,Ze)||e.defaultView}});var nt=new be;function rt(){return Se.historyStorage.current}function it(e,t){this.key=e,this.store=rt(),this.dispose=t}function ot(e,t,n){var r=e.get();(t!==e.key||n!==e.store&&n.has(t))&&(r=n.get(t),nt.emit("popstate",e,{newValue:r})),e.key=t,e.store=n,n.set(t,r)}function at(e,t){var n=Ge();return(0,o.useEffect)((function(){return Se.on("beforepageload popstate",(function(){n.active&&e(rt())}))}),t),n}function st(){return ut().ready}function ut(){var e=(0,we.useObservableProperty)(Se,"readyState");return{ready:"ready"===e,error:"error"===e}}function ct(e,t){var n=Ge(),r=n.page.params,i=Se.route,a=r[e]||"",s=(0,o.useRef)(a),u=(0,we.useUpdateTrigger)();return(0,o.useEffect)((function(){var t=function t(){var r=i[e]||"";r!==s.current&&(n.active?(s.current=r,u()):H(n,"active",t))};if(t(),e in i)return i.watch(e,(function(){I(t)}));console.error("Route parameter "+e+" does not exist")}),[e,t]),s.current=a,t&&n.active&&(!a||"remainingSegments"===e&&"/"===a)&&Se.navigate(i.getPath(w({},r,E(e,t))),!0),a}function lt(e,t,n){var r=rt(),i=(0,o.useState)(r&&r.has(e)?r.get(e):t),a=at((function(t){i[1]((function(n){return t.has(e)?t.get(e):(t.set(e,n),n)}))}),[e]);return r?a.active&&r.get(e)!==i[0]&&(n&&r.has(e)&&(Se.snapshot(),r=rt()),r.set(e,i[0])):Se.beforeInit(Y(1)),i}function ft(e){var t=(0,o.useState)({})[0],n=at((function(e){b(t,(function(t,n){ot(n,n.key,e)}))}),[]),r=(0,o.useState)((function(){return{getState:function(e,r){var i=t[e];return i&&n.active&&ot(i,r,rt()),i||(t[e]=new it(r,(function(){delete t[e]})))}}}))[0];return(0,o.createElement)(we.ViewStateProvider,{value:r},e.children)}U(it,{get:function(){return this.store.get(this.key)},set:function(e){this.store.set(this.key,e)},onPopState:function(e){return j(e),nt.add(this,"popstate",(function(t){e.call(this,t.newValue)}))}});const pt=u(28);var mt=Object.create(null),dt="function"==typeof Symbol&&Symbol.toPrimitive;function ht(e){this.toString=e}function gt(e){return w((function(t,n,r){var i=e(t,n,r,!0);return void 0!==i?i:t}),{html:function(t,n,r){return{__html:e(t,n,r)}},lazy:function(t,n,r){return new ht(e.bind(0,t,n,r,!0))}})}function vt(){return(0,we.useObservableProperty)(Se,"language")}function yt(e,t){var n=new RegExp("^("+Object.keys(e[t]).join("|")+")\\."),r={};function i(n,r,o,a,s){var u=((e[s]||mt)[n]||mt)[r];return"string"==typeof u?!u||a&&void 0===o?u:pt(u,o,{noEncode:a}):s!==t?i(n,r,o,a,t):void 0}function o(e,t,r,o){var a=n.test(e)?RegExp.$1:"";return i(a,a?e.slice(RegExp.lastMatch.length):e,t,o,r||Se.language)}function a(){var e=String(this),t=y(arguments),n=e+" "+t.join(" ");return r[n]||(r[n]=t[0]?gt((function(n,r,o,a){return o=o||e||Se.language,P(t,(function(e){return i(e,n,r,a,o)}))})):gt((function(t,n,r,i){return o(t,n,r||e,i)})))}return{translate:gt(o),getTranslation:a.bind(""),useTranslation:function(){var e=vt(),t=a.apply(e,arguments);return{language:e,t}},keys:function(n){return D(e[t][n]||mt)}}}function wt(e){bt.call(this),this.attributes=e||{}}function bt(){}dt&&(ht.prototype[dt]=function(){return this.toString()}),U(wt,bt,{getCustomAttributes:function(){return w({},this.attributes)}}),U(bt,{next:function(){},getRef:function(){return p},getClassNames:function(){return[]},getCustomAttributes:function(){return{}},dispose:function(){}}),G(bt.prototype),L(bt,{get scrollableTarget(){return new wt({"scrollable-target":""})},use:function(){var e=y(arguments),t=e[0],n={},r=e.filter((function(e){return e instanceof bt})),i=r.map((function(e){return e.getRef()}));return!t||t instanceof bt?t||e.shift():("function"!=typeof t?i.push((function(e){t.current=e})):i.push(t),e.shift()),b(r,(function(e,t){w(n,t.getCustomAttributes())})),w(n,{ref:T(i),className:we.classNames.apply(null,e)}),b(r,(function(e,t){t.next()})),n}});var xt=l.dom,St=(xt.observe,xt.registerCleanup,xt.createAutoCleanupMap,xt.afterDetached,xt.watchElements,xt.watchAttributes,xt.watchOwnAttributes),Ct=k();function Pt(e){this.mixin=e}function Et(){bt.call(this),Ct(this,{elements:new WeakSet,flush:H(this,!1),dispose:[],states:{},prefix:"",counter:0})}U(Pt,{getMixin:function(){return this.mixin}}),U(Et,bt,{get ref(){var e=this,t=e.state;return e.next(),t.ref||(t.ref=new Pt(e.clone()))},get state(){var e=Ct(this),t=e.prefix+e.counter;return e.states[t]||(e.states[t]=this.initState())},reset:function(){return Ct(this).counter=0,this},next:function(){return Ct(this).counter++,this},getRef:function(){var e=this,t=e.state;return function(n){t.element=n,n&&R(Ct(e).elements,n)&&e.initElement(n,t)}},elements:function(){return q(Ct(this).states).map((function(e){return e.element})).filter((function(e){return e}))},onDispose:function(e){Ct(this).dispose.push(e)},initState:function(){return{element:null}},initElement:function(e,t){},clone:function(){var e=this,t=Z(Object.getPrototypeOf(e),e);return Ct(t,w({},Ct(e),{prefix:$()+".",counter:0})),t},dispose:function(){var e=Ct(this),t=e.states;T(e.dispose.splice(0))(),e.flush(),e.elements=new WeakSet,b(t,(function(e,n){delete t[e]}))}});var At=Et.prototype;function Mt(e,t,n,r){var i=n.classNames,o=w({},i);if(b(e.classNames,(function(e,n){i[n]=t.classList.contains(n)})),!N(o,i)){var a=e.onClassNameUpdated.bind(e,t,o,w({},i));r?F(a):a()}}function Ot(e){Et.call(this),this.classNames=e||[]}U(Ot,Et,{getClassNames:function(){return[this.state.classNames]},getRef:function(){var e=this,t=e.state.element;return t&&ne(ue.root,t)&&Mt(e,t,e.state,!0),At.getRef.call(this)},initState:function(){return{element:null,classNames:{}}},initElement:function(e,t){var n=this;St(e,"class",(function(){Mt(n,e,t)}))},onClassNameUpdated:function(e,t,n){}});var Rt=Ot.prototype;function Nt(){Ot.call(this,["tweening-in","tweening-out"])}U(Nt,Ot,{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=y(arguments),this},getCustomAttributes:function(){var e=this;return w({},Rt.getCustomAttributes.call(e),{"animate-in":(e.effects||[]).join(" "),"animate-on":e.trigger||"show"})}});var Tt=Ot.prototype;function Vt(e){Ot.call(this,["tweening-in","tweening-out"]),this.className=e}U(Vt,Ot,{getClassNames:function(){return[this.className].concat(Tt.getClassNames.call(this))}});var kt=Nt.prototype,Ft=0;function It(){var e=this;Nt.call(e),e.className="brew-anim-"+ ++Ft,e.item=new Vt(e.className)}U(It,Nt,{withOptions:function(e){return this.selector=e,this},reset:function(){return this.item.reset(),kt.reset.call(this)},getCustomAttributes:function(){var e=this;return w({},kt.getCustomAttributes.call(e),{"animate-in":null,"animate-sequence-type":(e.effects||[]).join(" "),"animate-sequence":e.selector||"."+e.className})},clone:function(){return w(kt.clone.call(this),{item:this.item.ref.getMixin()})}});var jt=Ot.prototype;function Dt(e){Ot.call(this,["target-opened"]),this.flyoutMixin=e}U(Dt,Ot,{open:function(e){return this.flyoutMixin.open(e)},close:function(e){return this.flyoutMixin.close(e)},initElement:function(e,t){var n=this;jt.initElement.call(n,e,t),n.onDispose(ue.on(e,"click",(function(){he(n.flyoutMixin.elements()[0],e)})))}});var qt=Ot.prototype,Lt=new WeakMap,Ut="animating isFlyoutOpened modal tabThrough visible".split(" ");function zt(){var e=this;Ot.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.toggle=new Dt(e),e.onDispose((function(){e.isFlyoutOpened=!1,e.visible=!1}))}U(zt,Ot,{reset:function(){return this.toggle.reset(),qt.reset.call(this)},next:function(){return this.effects=void 0,qt.next.call(this)},withEffects:function(){return this.effects=y(arguments),this},getCustomAttributes:function(){var e=this;return w({},qt.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){var t=this.elements()[0];return Lt.set(t,e),ge(t)},close:function(e){return de(this.elements()[0],e)},onOpen:function(e){var t=this.elements()[0];return this.onToggleState((function(n){if(n)return e(Lt.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;qt.initElement.call(n,e,t),n.onDispose(Se.on(e,{animationstart:function(){n.animating=!0},animationcomplete:function(){n.animating=!1}},!0))},clone:function(){var e=this,t=w(qt.clone.call(e),{toggle:e.toggle.ref.getMixin()});return b(Ut,(function(n,r){B(t,r,e)})),t},onClassNameUpdated:function(e,t,n){this.visible=n.open,this.isFlyoutOpened=n.open&&!n.closing&&!n["tweening-out"]}});var Wt=Et.prototype;function Bt(){Et.call(this)}U(Bt,Et,{for:function(e){return this.state.ref=e,this},initElement:function(e,t){Wt.initElement.call(this,e,t);var n=function(n,r){var i=t.ref,o=i&&("string"==typeof i?e.querySelector(i):i.current);o&&!ue.focused(o)&&n(r||o)};this.onDispose(ue.on(e,{focusin:function(r){t.focused=r.source,ie(e,"focused",r.source),n(ue.focus)},focusout:function(){t.focused=!1,ie(e,"focused",!1)},focuschange:function(){n(ue.blur,e)}}))},getClassNames:function(){var e={},t=this.state.focused;return t&&(e.focused=!0,e["focused-"+t]=!0),[e]}});var _t=Et.prototype;function Ht(){Et.call(this)}U(Ht,Et,{initElement:function(e,t){_t.initElement.call(this,e,t),this.onDispose(fe(e,(function(n){t.loading=n,ie(e,"loading",n)})))},getClassNames:function(){return[{loading:!!this.state.loading}]}});var Gt=t.getDirectiveComponent,Zt=(t.registerDirective,Ot.prototype),Qt="pageIndex scrolling".split(" ");function $t(){var e=this;Ot.call(e,["scrollable-x","scrollable-x-l","scrollable-x-r","scrollable-y","scrollable-y-d","scrollable-y-u"]),e.target=bt.scrollableTarget,e.pageIndex=0,e.scrolling=!1}function Jt(){Et.call(this)}function Kt(e){w(this,e)}function Xt(e){return function(){var t=sn(e);return(t.withOptions||Kt).apply(t,arguments),t}}U($t,Ot,{withOptions:function(e){return this.options=e,this},getCustomAttributes:function(){var e=this.options||{};return w({},Zt.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;n.onDispose(Se.on(e,{scrollIndexChange:function(e){n.pageIndex=e.newIndex},scrollStart:function(){n.scrolling=!0},scrollStop:function(){n.scrolling=!1}},!0))},clone:function(){var e=Zt.clone.call(this);return b(Qt,(function(t,n){B(e,n,self)})),e}}),b("destroy enable disable setOptions setStickyPosition refresh scrollPadding stop scrollLeft scrollTop scrollBy scrollTo scrollByPage scrollToPage scrollToElement",(function(e,t){W($t.prototype,t,(function(){var e=Gt(this.elements()[0]);return e.scrollable[t].apply(null,arguments)}))})),U(Jt,Et,{when:function(e){var t=this.state,n=t.callback||(t.callback=function(){oe(t.element)});return t.deps&&!N(e,t.deps)&&I(n),t.deps=y(e),this}});var Yt=Xt(Nt),en=Xt(It),tn=Xt(zt),nn=Xt(Bt),rn=Xt(Ht),on=Xt($t),an=Xt(Jt);function sn(e){return(0,we.useSingleton)((function(){return new e})).reset()}function un(e){return e&&e.getMixin().reset()}const cn=i,ln=e;i.react=e})(),c=c.default})()}));
|
|
3
3
|
//# sourceMappingURL=brew-js-react.min.js.map
|