-
Notifications
You must be signed in to change notification settings - Fork 965
/
state-machine-history.min.js
1 lines (1 loc) · 2.09 KB
/
state-machine-history.min.js
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("StateMachineHistory",[],e):"object"==typeof exports?exports.StateMachineHistory=e():t.StateMachineHistory=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=1)}([function(t,e,n){"use strict";function r(t){if(0===t.length)return t;var e,n,r=t.split(/[_-]/);if(1===r.length&&r[0][0].toLowerCase()===r[0][0])return t;for(n=r[0].toLowerCase(),e=1;e<r.length;e++)n=n+r[e].charAt(0).toUpperCase()+r[e].substring(1).toLowerCase();return n}r.prepended=function(t,e){return e=r(e),t+e[0].toUpperCase()+e.substring(1)},t.exports=r},function(t,e,n){"use strict";var r=n(0);t.exports=function(t){t=t||{};var e=r(t.name||t.past||"history"),n=r(t.future||"future"),o=r.prepended("clear",e),i=r.prepended(e,"back"),s=r.prepended(e,"forward"),u=r.prepended("can",i),p=r.prepended("can",s),c=t.max,f={configure:function(t){t.addTransitionLifecycleNames(i),t.addTransitionLifecycleNames(s)},init:function(t){t[e]=[],t[n]=[]},lifecycle:function(t,r){"onEnterState"===r.event&&(t[e].push(r.to),c&&t[e].length>c&&t[e].shift(),r.transition!==i&&r.transition!==s&&(t[n].length=0))},methods:{},properties:{}};return f.methods[o]=function(){this[e].length=0,this[n].length=0},f.properties[u]={get:function(){return this[e].length>1}},f.properties[p]={get:function(){return this[n].length>0}},f.methods[i]=function(){if(!this[u])throw Error("no history");var t=this[e].pop(),r=this[e].pop();this[n].push(t),this._fsm.transit(i,t,r,[])},f.methods[s]=function(){if(!this[p])throw Error("no history");var t=this.state,e=this[n].pop();this._fsm.transit(s,t,e,[])},f}}])});