poulet 0.0.6 → 0.1.1
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/README.md +268 -4
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +117 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.global.js +2 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +2 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +16 -0
- package/dist/react.d.ts +16 -0
- package/dist/react.global.js +25 -0
- package/dist/react.global.js.map +1 -0
- package/dist/react.js +2 -0
- package/dist/react.js.map +1 -0
- package/package.json +70 -52
- package/LICENSE +0 -22
- package/dist/.gitkeep +0 -0
- package/dist/poulet.common.js +0 -959
- package/dist/poulet.js +0 -962
- package/dist/poulet.min.js +0 -7
- package/dist/poulet.mjs +0 -957
- package/lib/Core/Component/_copyAccessor.js +0 -3
- package/lib/Core/Component/_defineReactive.js +0 -46
- package/lib/Core/Component/_mergeMixins.js +0 -53
- package/lib/Core/Component/index.js +0 -139
- package/lib/Core/Directive/_stringParser.js +0 -61
- package/lib/Core/Directive/index.js +0 -93
- package/lib/Core/Observer.js +0 -32
- package/lib/Core/index.js +0 -140
- package/lib/Directives/Class.js +0 -26
- package/lib/Directives/Html.js +0 -7
- package/lib/Directives/Model.js +0 -57
- package/lib/Directives/On.js +0 -13
- package/lib/Directives/Show.js +0 -9
- package/lib/Directives/Style.js +0 -7
- package/lib/Directives/Text.js +0 -7
- package/lib/Directives/index.js +0 -6
- package/lib/Mixins/index.js +0 -0
- package/lib/get.js +0 -10
- package/lib/index.js +0 -6
- package/lib/set.js +0 -10
package/dist/poulet.min.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Poulet.js v0.0.6
|
|
3
|
-
* (c) 2017 Alex Toudic
|
|
4
|
-
* Released under MIT License.
|
|
5
|
-
**/
|
|
6
|
-
|
|
7
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("lodash"),require("chirashi")):"function"==typeof define&&define.amd?define(["lodash","chirashi"],t):e.Poulet=t(e._,e.Chirashi)}(this,function(e,t){"use strict";function n(e,t,n){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}function i(e,n,o,r,s){n+=r,e[n]={},Object.defineProperty(o,r,{get:function(){return s},set:function(c){t.forIn(e[n],function(e,t){return t.beforeChange()}),s=c,"object"===("undefined"==typeof c?"undefined":a(c))&&t.forIn(c,i.bind(null,e,n+".",o[r])),t.forIn(e[n],function(e,t){return t.afterChange()}),s instanceof Array&&t.forEach(m,function(i){s[i]=function(){t.forIn(e[n],function(e,t){t.deep&&t.beforeChange()});var o=Array.prototype[i].apply(this,arguments);return t.forIn(e[n],function(e,t){t.deep&&t.afterChange()}),o}})}}),o[r]=s}function o(e,t){return e?(e instanceof Array||(e=[e]),t instanceof Array||(t=[t]),[].concat($(e),$(t))):t}function r(e,n){t.forIn(n,function(t,n){t in _?e[t]=_[t](e[t],n):e[t]=_.default(e[t],n)})}function s(e){var n=l({},e);return t.forEach(n.mixins,function(t,i){"string"==typeof t&&(t=g[t]),"mixins"in e&&(t=s(t)),r(n,t)}),n}function c(e){var n=[],i=!1,o=!1,r=!1,s=0,c=e.split(/\s/g);return t.forEach(c,function(e,t){var a=e.match(j);if(!i&&a&&(i=!0),o||e.indexOf("{")===-1||(o=!0,r=!0),o&&0===e.indexOf(",")&&(r=!0),!i&&!r){var u=e.match(w);u&&(u=u[0],isNaN(+u)&&(n.push(u),c[t]=e.replace(u,"$scope."+u)))}a&&(s+=a.length),a&&s%2===0&&(i=!1),o&&e.indexOf(":")!==-1&&(r=!1),o&&e.indexOf(",")!==-1&&(r=!0),o&&e.indexOf("}")!==-1&&(o=!1)}),{template:c.join(" "),props:n}}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},f=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),h=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},d=function e(t,n,i){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var r=Object.getPrototypeOf(t);return null===r?void 0:e(r,n,i)}if("value"in o)return o.value;var s=o.get;if(void 0!==s)return s.call(i)},p=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},v=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},$=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},b=function(){function e(t){u(this,e),this._observer=new MutationObserver(this._update.bind(this)),this._observer.observe(t,{childList:!0,subtree:!0}),this._listeners=[]}return f(e,[{key:"on",value:function(e){this._listeners.push(e)}},{key:"off",value:function(e){this._listeners.splice(this._listeners.indexOf(e),1)}},{key:"_update",value:function(){t.forEach(this._listeners,function(e){try{e()}catch(e){console.error(e)}})}}]),e}(),y=function(e,t){var n=t.split(".");t=n.pop();for(var i=n.length,o=0;o<i;++o)e=e[n[o]];return e[t]},m=["push","splice","unshift"],g=Object.freeze({}),_={mounted:o,beforeDestroy:o,default:function(e,t){return"object"===("undefined"==typeof e?"undefined":a(e))&&"object"===("undefined"==typeof t?"undefined":a(t))?l({},t,e):e||t},mixins:function(e){return e}},k=["mounted","beforeDestroy"],O=function(){function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};u(this,o),Object.assign(this,e),this.$options=t,this.$id=this._generateId(),this.$options=s(this.$options),this.$scope={},this._bindLifeCycle(),this._bindData(),this._bindMethods()}return f(o,[{key:"_bindData",value:function(){var e=this;this.$data={},this._watchers={},t.forIn(this.$options.data,function(t,o){i(e._watchers,"",e.$data,t,o),n(t,e,e.$data),n(t,e.$scope,e.$data)})}},{key:"_bindMethods",value:function(){var e=this;this.$methods={},t.forIn(this.$options.methods,function(t,n){e.$methods[t]=n.bind(e)}),Object.assign(this,this.$methods),Object.assign(this.$scope,this.$methods)}},{key:"_generateId",value:function(){return e.uniqueId(""+this.$prefix+this.$options.name+"-")}},{key:"_bindLifeCycle",value:function(){var e=this;t.forEach(k,function(n){e[n]=function(){for(var i=arguments.length,o=Array(i),r=0;r<i;r++)o[r]=arguments[r];t.forEach(e.$options[n],function(t){return t.apply(e,o)})}})}},{key:"$watch",value:function(n,i){var o=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{deep:!1,immediate:!1},s=e.uniqueId(this.$id+"-"+n+"-");"string"==typeof i&&(i=this.$scope[i]);var c={value:null};if(r.beforeChange=function(){var e=y(o.$scope,n);e instanceof Array?c.value=[].concat($(e)):"object"===("undefined"==typeof e?"undefined":a(e))?c.value=l({},e):c.value=e},r.afterChange=function(){i(y(o.$scope,n),c.value)},n in this._watchers&&(this._watchers[n][s]=r,r.deep)){var u=n+".";"object"===a(y(this.$scope,n))&&t.forIn(this._watchers,function(e,t){0===e.indexOf(u)&&(o._watchers[e][s]=r)})}return r.immediate&&r.afterChange(),function(){r.deep?"object"===a(y(o.$scope,n))&&t.forIn(o._watchers,function(e,t){delete o._watchers[e][s]}):n in o._watchers&&delete o._watchers[n][s]}}},{key:"$mount",value:function(e){this.$el=t.getElement(e),this.$el[this.$marker]=this.$id;try{this.mounted(e)}catch(e){console.error(e)}}},{key:"$destroy",value:function(){try{this.beforeDestroy()}catch(e){console.error(e)}}}]),o}(),w=/([\w-_.\s]+)/g,j=/["']/g,C=["bind","update","unbind"],x=function(){function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};u(this,n),Object.assign(this,e),this.$options=t,this.$update=this.$update.bind(this),this.$id=this._generateId(),this._bindLifeCycle()}return f(n,[{key:"_generateId",value:function(){return e.uniqueId(""+this.$prefix+this.$options.name+"-")}},{key:"_bindLifeCycle",value:function(){var e=this;t.forEach(C,function(n){e[n]=function(){for(var i=arguments.length,o=Array(i),r=0;r<i;r++)o[r]=arguments[r];t.forEach(e.$options[n],function(t){return t.apply(e,o)})}})}},{key:"_eval",value:function(e){return(0,eval)("(function ($scope) { return "+e+"; })")(this.$scope)}},{key:"$bind",value:function(e,n){var i=this;this.$el=t.getElement(e),this.$option=c(n);for(var o=[this.$el].concat($(t.parents(this.$el))),r=void 0,s=0;(r=o[s++])&&!(this.$marker in r););if(this.$component=this.$components[r[this.$marker]],this.bind)try{this.bind(e)}catch(e){console.error(e)}this.unwatchers=[],this.$option.props.length?t.forEach(this.$option.props,function(e){i.unwatchers.push(i.$component.$watch(e,i.$update,{immediate:!0}))}):this.$update()}},{key:"$update",value:function(){if(this.update)try{this.update(this._eval(this.$option.template))}catch(e){console.error(e)}}},{key:"$unbind",value:function(){if(t.forEach(this.unwatchers,function(e){e()}),this.unbind)try{this.unbind()}catch(e){console.error(e)}}},{key:"$scope",get:function(){return this.$component.$scope}}]),n}(),P={bind:function(){this.currentClasses=[]},update:function(e){var n=void 0;"string"==typeof e?n=[e]:"length"in e?n=e:"object"===("undefined"==typeof e?"undefined":a(e))&&(n=Object.keys(e).filter(function(t){return e[t]}));var i=this.currentClasses.filter(function(e){return n.indexOf(e)===-1});n.length&&t.addClass.apply(void 0,[this.$el].concat($(n))),i.length&&t.removeClass.apply(void 0,[this.$el].concat($(i))),this.currentClasses=n}},I={update:function(e){t.setProp(this.$el,{innerHTML:e})}},E=function(e,t,n){var i=t.split(".");t=i.pop();for(var o=i.length,r=0;r<o;++r)e=e[i[r]];return e[t]=n},A={bind:function(e){var n=this;this.type=t.getProp(e,"type"),this.inputChanged=function(){var e=void 0;switch(n.type){case"checkbox":e=t.getProp(n.$el,"checked");break;default:e=t.getProp(n.$el,"value")}e!==n.currentValue&&(n.currentValue=e,E(n.$scope,n.model,n.currentValue))},this.offObj=t.on(e,{"keyup blur change":this.inputChanged})},update:function(e){if(e!==this.currentValue)switch(this.model=this.$option.props[0],this.currentValue=e,this.type){case"checkbox":t.setProp(this.$el,{checked:e});break;case"radio":var n=this.$options.selector.slice(0,-1)+'="'+this.model+'"]';t.setProp(n,{checked:!1}),t.setProp(n+'[value="'+e+'"]',{checked:!0});break;default:t.setProp(this.$el,{value:e})}},unbind:function(){this.offObj.off()}},D={unbind:function(){this.off&&this.off()},update:function(e){this.off&&this.off(),t.on(this.$el,e)}},M={update:function(e){t.setStyleProp(this.$el,{display:e?"block":"none"})}},S={update:function(e){t.setProp(this.$el,{textContent:e})}},L=Object.freeze({Class:P,Html:I,Model:A,On:D,Show:M,Text:S}),q={$prefix:"p-"},V={name:"root"},T=function(n){function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};u(this,i),e=l({},q,e),n=l({},V,n);var o=v(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,n));return o.$components=h({},o.$id,o),o.$directives={},o.$gobals=l({},e,n,{$root:o,$components:o.$components,$directives:o.$directives}),o.$gobals.$marker=o.$marker="_"+o.$prefix+"id",o.$directivesMarker="_"+o.$prefix+"directives",o._components=[],o._directives=[],t.forIn(L,o.directive.bind(o)),o}return p(i,n),f(i,[{key:"component",value:function(t,n){t=e.kebabCase(t);var i="selector"in n?n.selector:"["+this.$prefix+t+"]";this._components.push({selector:i,options:l({name:t,selector:i},n)})}},{key:"directive",value:function(t,n){t=e.kebabCase(t);var i="selector"in n?n.selector:"["+this.$prefix+t+"]";this._directives.push({selector:i,options:l({name:t,selector:i},n)})}},{key:"$mount",value:function(e){d(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"$mount",this).call(this,e),this._observer=new b(this.$el),this._observer.on(this._domChanged.bind(this)),this._domChanged()}},{key:"_domChanged",value:function(){this._unbindComponents(),this._unbindDirectives(),this._bindComponents(),this._bindDirectives()}},{key:"_unbindComponents",value:function(){var e=this;t.forIn(this.$components,function(n,i){t.closest(i.$el,document.body)||(i.$destroy(),delete e.$components[n])})}},{key:"_bindComponents",value:function(){var e=this;t.forEach(this._components,function(n){t.forEach(t.find(e.$el,n.selector),function(t){if(!(e.$marker in t)){var i=new O(e.$gobals,n.options);i.$mount(t),e.$components[i.$id]=i}})})}},{key:"_unbindDirectives",value:function(){var e=this;t.forIn(this.$directives,function(n,i){t.closest(i.$el,document.body)||(i.$unbind(),delete e.$directives[n])})}},{key:"_bindDirectives",value:function(){var e=this;t.forEach(this._directives,function(n){t.forEach(t.find(e.$el,n.selector),function(i){if(e.$directivesMarker in i){if(i[e.$directivesMarker].indexOf(n.options.name)!==-1)return}else i[e.$directivesMarker]=[];i[e.$directivesMarker].push(n.options.name);var o=new x(e.$gobals,n.options);o.$bind(i,t.getAttr(i,""+e.$gobals.$prefix+n.options.name)),e.$directives[o.$id]=o})})}}]),i}(O),z=Object.assign(T,{get:y,set:E});return z});
|