@tripetto/block-date
Version:
Date block for Tripetto.
2 lines • 4.3 kB
JavaScript
/*! Tripetto Date Block 4.0.3 - Copyright (C) 2023 Tripetto B.V. - All Rights Reserved */
!function(){"use strict";var t={407:function(t,e,o){var r,n=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}),i=this&&this.__decorate||function(t,e,o,r){var n,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,r);else for(var u=t.length-1;u>=0;u--)(n=t[u])&&(a=(i<3?n(a):i>3?n(e,o,a):n(e,o))||a);return i>3&&a&&Object.defineProperty(e,o,a),a};Object.defineProperty(e,"__esModule",{value:!0}),e.DateTimeCondition=void 0;var a=o(226),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.getValue=function(t,e){if((0,a.isString)(e)&&t instanceof a.Slots.Date){var o=this.variableFor(e);return o&&o.hasValue?t.toValue(o.value):void 0}return t.toValue((0,a.isNumberFinite)(e)?e:a.DateTime.UTC)},e.prototype.verify=function(){var t=this.valueOf();if(t){var e=this.getValue(t.slot,this.props.value),o=t.hasValue?t.slot.toValue(t.value):void 0;switch(this.props.mode){case"equal":return o===e;case"not-equal":return o!==e;case"before":return(0,a.isNumberFinite)(e)&&(0,a.isNumberFinite)(o)&&o<e;case"after":return(0,a.isNumberFinite)(e)&&(0,a.isNumberFinite)(o)&&o>e;case"between":case"not-between":var r=this.getValue(t.slot,this.props.to);return(0,a.isNumberFinite)(e)&&(0,a.isNumberFinite)(r)&&((0,a.isNumberFinite)(o)&&o>=a.Num.min(e,r)&&o<=a.Num.max(e,r))===("between"===this.props.mode);case"defined":return t.hasValue;case"undefined":return!t.hasValue}}return!1},i([a.condition],e.prototype,"verify",null),e=i([(0,a.tripetto)({type:"condition",legacyBlock:!0,identifier:"@tripetto/block-date"})],e)}(a.ConditionBlock);e.DateTimeCondition=u},856:function(t,e,o){var r,n=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}),i=this&&this.__decorate||function(t,e,o,r){var n,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,r);else for(var u=t.length-1;u>=0;u--)(n=t[u])&&(a=(i<3?n(a):i>3?n(e,o,a):n(e,o))||a);return i>3&&a&&Object.defineProperty(e,o,a),a};Object.defineProperty(e,"__esModule",{value:!0}),e.DateTime=void 0;var a=o(226);o(407);var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.dateSlot=(0,a.assert)(e.valueOf("date")),e.toSlot=e.valueOf("to"),e.required=e.dateSlot.slot.required||!1,e}return n(e,t),Object.defineProperty(e.prototype,"fromError",{get:function(){return!this.dateSlot.hasValue||!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"toError",{get:function(){return!this.toSlot||!this.toSlot.hasValue||this.toSlot.value<this.dateSlot.value},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"toPlaceholder",{get:function(){return(0,a.markdownifyToString)(this.props.placeholder||"",this.context)||""},enumerable:!1,configurable:!0}),e.prototype.validate=function(){return!this.props.range||(this.toSlot&&this.dateSlot.hasValue===this.toSlot.hasValue&&this.toSlot.value>=this.dateSlot.value||!1)},i([a.validator],e.prototype,"validate",null),e}(a.NodeBlock);e.DateTime=u},226:function(t){t.exports=require("@tripetto/runner")}},e={};var o=function o(r){var n=e[r];if(void 0!==n)return n.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,o),i.exports}(856);module.exports=o}();