@tripetto/block-date
Version:
Date block for Tripetto.
2 lines • 4.61 kB
JavaScript
/*! Tripetto Date Block 4.0.3 - Copyright (C) 2023 Tripetto B.V. - All Rights Reserved */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("TripettoRunner")):"function"==typeof define&&define.amd?define("TripettoBlockDate",["TripettoRunner"],e):"object"==typeof exports?exports.TripettoBlockDate=e(require("TripettoRunner")):t.TripettoBlockDate=e(t.TripettoRunner)}(this,(function(t){return function(){"use strict";var e={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,u=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,o,r);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(u=(i<3?n(u):i>3?n(e,o,u):n(e,o))||u);return i>3&&u&&Object.defineProperty(e,o,u),u};Object.defineProperty(e,"__esModule",{value:!0}),e.DateTimeCondition=void 0;var u=o(294),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.getValue=function(t,e){if((0,u.isString)(e)&&t instanceof u.Slots.Date){var o=this.variableFor(e);return o&&o.hasValue?t.toValue(o.value):void 0}return t.toValue((0,u.isNumberFinite)(e)?e:u.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,u.isNumberFinite)(e)&&(0,u.isNumberFinite)(o)&&o<e;case"after":return(0,u.isNumberFinite)(e)&&(0,u.isNumberFinite)(o)&&o>e;case"between":case"not-between":var r=this.getValue(t.slot,this.props.to);return(0,u.isNumberFinite)(e)&&(0,u.isNumberFinite)(r)&&((0,u.isNumberFinite)(o)&&o>=u.Num.min(e,r)&&o<=u.Num.max(e,r))===("between"===this.props.mode);case"defined":return t.hasValue;case"undefined":return!t.hasValue}}return!1},i([u.condition],e.prototype,"verify",null),e=i([(0,u.tripetto)({type:"condition",legacyBlock:!0,identifier:"@tripetto/block-date"})],e)}(u.ConditionBlock);e.DateTimeCondition=a},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,u=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,o,r);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(u=(i<3?n(u):i>3?n(e,o,u):n(e,o))||u);return i>3&&u&&Object.defineProperty(e,o,u),u};Object.defineProperty(e,"__esModule",{value:!0}),e.DateTime=void 0;var u=o(294);o(407);var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.dateSlot=(0,u.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,u.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([u.validator],e.prototype,"validate",null),e}(u.NodeBlock);e.DateTime=a},294:function(e){e.exports=t}},o={};var r=function t(r){var n=o[r];if(void 0!==n)return n.exports;var i=o[r]={exports:{}};return e[r].call(i.exports,i,i.exports,t),i.exports}(856);return r}()}));