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