date-of-birth-js
Advanced tools
Comparing version 1.0.6 to 2.0.0
/*! For license information please see index.concat.js.LICENSE.txt */ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("dobDatepicker",[],t):"object"==typeof exports?exports.dobDatepicker=t():e.dobDatepicker=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=0)}([function(e,t,n){e.exports=n(2)},function(e,t){function n(e,t){for(var n=[],r=0;r<e.length;r++)e[r]===t&&n.push(r);return n}e.exports=function(e,t="string",r=null){let o=function(e){switch(e){case"string":return["Invalid Format","Invalid Date","Valid Date"];case"boolean":return[!1,!1,!0];default:return["Invalid Format","Invalid Date","Valid Date"]}}(t);return null==e?o[0]:function(e,t,r){if(e){if(r||(r=e.includes("-")?"yyyy-mm-dd":"mm/dd/yyyy"),r.length>10||r.length<6)return t[0];const o=e.includes("-")?r.split("-"):r.split("/");if(o.map(e=>/([dmy])\1/i.test(e)).filter(e=>!e).length>0)return t[0];let a=e.includes("-")?"-":"/",i=new RegExp(`(\\d{${o[0].length}})(${a})(\\d{${o[1].length}})(${a})(\\d{${o[2].length}})`),c=n(o,o.filter(e=>/[d]/i.test(e))[0]),s=n(o,o.filter(e=>/[m]/i.test(e))[0]),u=n(o,o.filter(e=>/[y]/i.test(e))[0]);if(1!==c.length||1!==s.length||1!==u.length)return t[0];if(!i.test(e))return t[0];{const n=e.split(a),r=Number(n[c]),o=Number(n[s]),i=Number(n[u]);if(o<=0||o>12||r>function(e,t){return 2===t&&e%4==0?29:[31,28,31,30,31,30,31,31,30,31,30,31][t-1]}(i,o)||r<=0||i<1753)return t[1]}}return t[2]}(e,o,r)}},function(e,t,n){"use strict";n.r(t);var r={},o=[],a=e=>null==e?e:e.key,i=function(e){this.tag[e.type](e)},c=(e,t,n,r,o)=>{"key"===t||("o"===t[0]&&"n"===t[1]?((e.tag||(e.tag={}))[t=t.slice(2)]=r)?n||e.addEventListener(t,i):e.removeEventListener(t,i):!o&&"list"!==t&&"form"!==t&&t in e?e[t]=null==r?"":r:null==r||!1===r?e.removeAttribute(t):e.setAttribute(t,r))},s=(e,t)=>{var n=e.props,r=3===e.tag?document.createTextNode(e.type):(t=t||"svg"===e.type)?document.createElementNS("http://www.w3.org/2000/svg",e.type,{is:n.is}):document.createElement(e.type,{is:n.is});for(var o in n)c(r,o,null,n[o],t);return e.children.map(e=>r.appendChild(s(e=l(e),t))),e.dom=r},u=(e,t,n,r,o)=>{if(n===r);else if(null!=n&&3===n.tag&&3===r.tag)n.type!==r.type&&(t.nodeValue=r.type);else if(null==n||n.type!==r.type)t=e.insertBefore(s(r=l(r),o),t),null!=n&&e.removeChild(n.dom);else{var i,d,p,f,b=n.props,h=r.props,v=n.children,y=r.children,g=0,m=0,_=v.length-1,k=y.length-1;for(var D in o=o||"svg"===r.type,{...b,...h})("value"===D||"selected"===D||"checked"===D?t[D]:b[D])!==h[D]&&c(t,D,b[D],h[D],o);for(;m<=k&&g<=_&&null!=(p=a(v[g]))&&p===a(y[m]);)u(t,v[g].dom,v[g++],y[m]=l(y[m++]),o);for(;m<=k&&g<=_&&null!=(p=a(v[_]))&&p===a(y[k]);)u(t,v[_].dom,v[_--],y[k]=l(y[k--]),o);if(g>_)for(;m<=k;)t.insertBefore(s(y[m]=l(y[m++]),o),(d=v[g])&&d.dom);else if(m>k)for(;g<=_;)t.removeChild(v[g++].dom);else{var w={},O={};for(D=g;D<=_;D++)null!=(p=v[D].key)&&(w[p]=v[D]);for(;m<=k;)p=a(d=v[g]),f=a(y[m]=l(y[m])),O[p]||null!=f&&f===a(v[g+1])?(null==p&&t.removeChild(d.dom),g++):null==f||1===n.tag?(null==p&&(u(t,d&&d.dom,d,y[m],o),m++),g++):(p===f?(u(t,d.dom,d,y[m],o),O[f]=!0,g++):null!=(i=w[f])?(u(t,t.insertBefore(i.dom,d&&d.dom),i,y[m],o),O[f]=!0):u(t,d&&d.dom,null,y[m],o),m++);for(;g<=_;)null==a(d=v[g++])&&t.removeChild(d.dom);for(var D in w)null==O[D]&&t.removeChild(w[D].dom)}}return r.dom=t},l=e=>!0!==e&&!1!==e&&e?e:f(""),d=e=>3===e.nodeType?f(e.nodeValue,e):p(e.nodeName.toLowerCase(),r,o.map.call(e.childNodes,d),e,null,1),p=(e,t,n,r,o,a)=>({type:e,props:t,children:n,dom:r,key:o,tag:a}),f=(e,t)=>p(e,r,o,t,null,3),b=(e,t,n)=>p(e,t,Array.isArray(n)?n:null==n?o:[n],null,t.key),h=n(1);function v(e){return e<10?"0"+e.toString():e.toString()}function y(e){!function(e){e.state.current_page=e.state.current_page+1}(e),function(e){e.state.show_alerts=null}(e),function(e){if(3!==e.state.current_page)return;if(!e.options.enable_built_in_validation)return;(!h(g(e),"boolean","yyyy-mm-dd")||new Date(g(e))>new Date)&&function(e,t){e.state.show_alerts=t,e.resetProcess()}(e,"invalid_date_alert")}(e),function(e){if(3!==e.state.current_page||null!==e.state.show_alerts)return e;var t=e.options.dateFormat?e.options.dateFormat(g(e)):g(e);e.state.selected_date=t,e.datepickerTargetNode.value=t,e.hideDatepicker()}(e)}function g(e){return"".concat(e.state.dob.year,"-").concat(v(e.state.dob.month),"-").concat(v(e.state.dob.day))}function m(e,t,n){n.state.dob[e]=t,y(n)}function _(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return k(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return k(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function D(e){return b("div",{class:"top-arrow ".concat("popup"===e.options.display_mode?"top-arrow--popup":"")})}function w(e){return 0===e.state.current_page?function(e){return b("div",{class:"dob-datepicker__month",tabindex:"0"},e.options[e.options.show_long_month?"long_month":"short_month"].map((function(t,n){return b("button",{key:n+1,value:n+1,class:"dob-datepicker__month__button",onclick:function(){m("month",n+1,e),e.renderDatepicker()}},f(t))})))}(e):1===e.state.current_page?function(e){return b("div",{class:"dob-datepicker__day",tabindex:"0"},_(Array(2===e.state.dob.month?30:32).keys()).map((function(t,n){return 0===t?null:b("button",{key:n,value:n,class:"dob-datepicker__day__button",onclick:function(){m("day",n,e),e.renderDatepicker()}},[f(t),e.options.enable_ordinal_number?b("sup",{class:"dob-datepicker__day__ordinal-number"},j(n)):null])})))}(e):function(e){return b("div",{class:"dob-datepicker__year",tabindex:"0"},function(e){for(var t=(new Date).getFullYear(),n=[],r=[],o=[],a=function(a){r.length<20&&(o.push(a),r.push(b("button",{key:a,value:a,class:"dob-datepicker__year__button",onclick:function(){m("year",a,e),e.renderDatepicker()}},[b("span",{class:"dob-datepicker__year__button__first"},f(a.toString().substring(0,2))),b("span",{class:"dob-datepicker__year__button__last"},f(a.toString().substring(2)))])),20===r.length&&(n.push(P(e,r,o[0],o[o.length-1])),r=[],o=[]),a===t-e.options.year_range&&n.push(P(e,r,o[0],o[o.length-1])))},i=t;i>=t-e.options.year_range;i--)a(i);return n}(e))}(e)}function O(e){return b("div",{class:"dob-datepicker__alert"},f(e.options.alerts[e.state.show_alerts]))}function N(e){return b("div",{class:"dob-datepicker__header"},f(e.options.labels.header_label))}function T(e){return b("div",{class:"dob-datepicker__selection-header"},function(e){return 0===e.state.current_page?f(e.options.labels.select_month_label):1===e.state.current_page?f(e.options.labels.select_day_label):f(e.options.labels.select_year_label)}(e))}function E(e){return b("button",{class:"dob-datepicker__reset"},[b("div",{class:"dob-datepicker__reset-text",onclick:function(){e.resetProcess()}},f(e.options.labels.reset_button_label))])}function j(e){switch(!0){case 1===e||21===e||31===e:return f("st");case 2===e||22===e:return f("nd");case 23===e||23===e:return f("rd");default:return f("th")}}function P(e,t,n,r){return b("div",{class:"dob-datepicker__year__year-section"},[b("div",{class:"dob-datepicker__year__year-section-header"},f("".concat(e.options.labels.date_range_label).concat(r," - ").concat(n))),b("div",{class:"dob-datepicker__year__wrapper"},t),b("div",{class:"dob-datepicker__year__year-section-next"},f("⌄"))])}var S,C=function(e){return b("div",{class:"dob-datepicker__wrapper ".concat(e.state.show_datepicker?"":"dob-datepicker__wrapper--hide"," ")},[b("div",{class:"dob-datepicker__background ".concat("popup"===e.options.display_mode?"dob-datepicker__background--popup":""),style:"z-index: ".concat(e.options.zIndex.invisibleBackground),onclick:function(){e.hideDatepicker()}}),b("div",{id:"datepicker-widget__".concat(e.instance_id),class:"dob-datepicker ".concat("popup"===e.options.display_mode?"dob-datepicker--popup":""),style:"z-index: ".concat(e.options.zIndex.datepickerWidget)},[D(e),N(e),e.state.show_alerts?O(e):b("div",{}),T(e),b("div",{class:"dob-datepicker__options"},w(e)),e.state.current_page>0?E(e):b("div",{})])])},x=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],F=x.join(","),A="undefined"==typeof Element?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,I=function(e,t,n){var r=Array.prototype.slice.apply(e.querySelectorAll(F));return t&&A.call(e,F)&&r.unshift(e),r=r.filter(n)},L=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return isNaN(t)?function(e){return"true"===e.contentEditable}(e)?0:"AUDIO"!==e.nodeName&&"VIDEO"!==e.nodeName&&"DETAILS"!==e.nodeName||null!==e.getAttribute("tabindex")?e.tabIndex:0:t},M=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},B=function(e){return"INPUT"===e.tagName},W=function(e){return function(e){return B(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}((e.form||e.ownerDocument).querySelectorAll('input[type="radio"][name="'+e.name+'"]'),e.form);return!t||t===e}(e)},R=function(e){return!(e.disabled||function(e){return B(e)&&"hidden"===e.type}(e)||function(e){if("hidden"===getComputedStyle(e).visibility)return!0;var t=A.call(e,"details>summary:first-of-type")?e.parentElement:e;if(A.call(t,"details:not([open]) *"))return!0;for(;e;){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(e))},G=function(e){return!(!R(e)||W(e)||L(e)<0)},q=x.concat("iframe").join(","),J=function(e){if(!e)throw new Error("No node provided");return!1!==A.call(e,q)&&R(e)};function U(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var z,V=(z=[],{activateTrap:function(e){if(z.length>0){var t=z[z.length-1];t!==e&&t.pause()}var n=z.indexOf(e);-1===n||z.splice(n,1),z.push(e)},deactivateTrap:function(e){var t=z.indexOf(e);-1!==t&&z.splice(t,1),z.length>0&&z[z.length-1].unpause()}}),Y=function(e){return setTimeout(e,0)},K=function(e,t){var n,r=document,o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$(Object(n),!0).forEach((function(t){U(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},t),a={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},i=function(e){return a.containers.some((function(t){return t.contains(e)}))},c=function(e){var t=o[e];if(!t)return null;var n=t;if("string"==typeof t&&!(n=r.querySelector(t)))throw new Error("`".concat(e,"` refers to no known node"));if("function"==typeof t&&!(n=t()))throw new Error("`".concat(e,"` did not return a node"));return n},s=function(){var e;if(null!==c("initialFocus"))e=c("initialFocus");else if(i(r.activeElement))e=r.activeElement;else{var t=a.tabbableGroups[0];e=t&&t.firstTabbableNode||c("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},u=function(){a.tabbableGroups=a.containers.map((function(e){var t,n,r,o=(n=[],r=[],I(e,(t=t||{}).includeContainer,G).forEach((function(e,t){var o=L(e);0===o?n.push(e):r.push({documentOrder:t,tabIndex:o,node:e})})),r.sort(M).map((function(e){return e.node})).concat(n));return{firstTabbableNode:o[0],lastTabbableNode:o[o.length-1]}}))},l=function e(t){t!==r.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!o.preventScroll}),a.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(s()))},d=function(e){i(e.target)||(o.clickOutsideDeactivates?n.deactivate({returnFocus:o.returnFocusOnDeactivate&&!J(e.target)}):o.allowOutsideClick&&("boolean"==typeof o.allowOutsideClick?o.allowOutsideClick:o.allowOutsideClick(e))||e.preventDefault())},p=function(e){i(e.target)||e.target instanceof Document||(e.stopImmediatePropagation(),l(a.mostRecentlyFocusedNode||s()))},f=function(e){if(!1!==o.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void n.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){u();var t=null;if(e.shiftKey){var n=a.tabbableGroups.findIndex((function(t){var n=t.firstTabbableNode;return e.target===n}));if(n>=0){var r=0===n?a.tabbableGroups.length-1:n-1;t=a.tabbableGroups[r].lastTabbableNode}}else{var o=a.tabbableGroups.findIndex((function(t){var n=t.lastTabbableNode;return e.target===n}));if(o>=0){var i=o===a.tabbableGroups.length-1?0:o+1;t=a.tabbableGroups[i].firstTabbableNode}}t&&(e.preventDefault(),l(t))}(e)},b=function(e){o.clickOutsideDeactivates||i(e.target)||o.allowOutsideClick&&("boolean"==typeof o.allowOutsideClick?o.allowOutsideClick:o.allowOutsideClick(e))||(e.preventDefault(),e.stopImmediatePropagation())},h=function(){if(a.active)return V.activateTrap(n),S=o.delayInitialFocus?Y((function(){l(s())})):l(s()),r.addEventListener("focusin",p,!0),r.addEventListener("mousedown",d,{capture:!0,passive:!1}),r.addEventListener("touchstart",d,{capture:!0,passive:!1}),r.addEventListener("click",b,{capture:!0,passive:!1}),r.addEventListener("keydown",f,{capture:!0,passive:!1}),n},v=function(){if(a.active)return r.removeEventListener("focusin",p,!0),r.removeEventListener("mousedown",d,!0),r.removeEventListener("touchstart",d,!0),r.removeEventListener("click",b,!0),r.removeEventListener("keydown",f,!0),n};return(n={activate:function(e){if(a.active)return this;u(),a.active=!0,a.paused=!1,a.nodeFocusedBeforeActivation=r.activeElement;var t=e&&e.onActivate?e.onActivate:o.onActivate;return t&&t(),h(),this},deactivate:function(e){if(!a.active)return this;clearTimeout(S),v(),a.active=!1,a.paused=!1,V.deactivateTrap(n);var t=e&&void 0!==e.onDeactivate?e.onDeactivate:o.onDeactivate;return t&&t(),(e&&void 0!==e.returnFocus?e.returnFocus:o.returnFocusOnDeactivate)&&Y((function(){var e;l((e=a.nodeFocusedBeforeActivation,c("setReturnFocus")||e))})),this},pause:function(){return a.paused||!a.active||(a.paused=!0,v()),this},unpause:function(){return a.paused&&a.active?(a.paused=!1,u(),h(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return a.containers=t.map((function(e){return"string"==typeof e?r.querySelector(e):e})),a.active&&u(),this}}).updateContainerElements(e),n};function H(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Q(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?H(Object(n),!0).forEach((function(t){X(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):H(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function X(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Z=0,ee={display_mode:"inline",year_range:120,enable_built_in_validation:!0,enable_ordinal_number:!0,show_long_month:!0,dateFormat:null,zIndex:{targetNode:"150",datepickerWidget:"150",invisibleBackground:"100"},long_month:["January","February","March","April","May","June","July","August","September","October","November","December"],short_month:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],labels:{header_label:"When is your birthday?",select_day_label:"Select day",select_month_label:"Select month",select_year_label:"Select year",reset_button_label:"Reset and try again",date_range_label:"Year "},alerts:{invalid_date_alert:"Date is invalid"}};var te={getDatepickerWidgetNode:function(){return this.datepickerWidgetNode?this.datepickerWidgetNode:this.setDatepickerWidgetNode()},setDatepickerWidgetNode:function(){return this.datepickerWidgetNode=document.getElementById("datepicker-widget__".concat(this.instance_id))},getDatepickerTargetNode:function(){return this.datepickerTargetNode?this.datepickerTargetNode:this.setDatepickerTargetNode()},setDatepickerTargetNode:function(){return this.datepickerTargetNode=this.selector instanceof Element?this.selector:document.querySelector(this.getSelector())},getDatepickerTargetParentNode:function(){return this.datepickerTargetParentNode?this.datepickerTargetParentNode:this.setDatepickerTargetParentNode()},setDatepickerTargetParentNode:function(){return this.datepickerTargetParentNode=this.selector instanceof Element?this.selector.parentElement:document.querySelector(this.getSelector()).parentElement},getdatepickerContainerNode:function(){return this.datepickerContainerNode?this.datepickerContainerNode:this.setDatepickerContainerNode()},setDatepickerContainerNode:function(){var e=document.createElement("div");return e.style.setProperty("position","absolute"),this.datepickerContainerNode=e},getSelector:function(){return this.selector},setSelector:function(e){return this.selector=e,this},getFocusTrap:function(){return this.focusTrap?this.focusTrap:this.setFocusTrap()},setFocusTrap:function(){return this.focusTrap=K(this.getDatepickerWidgetNode(),{clickOutsideDeactivates:!0,returnFocusOnDeactivate:!1})},registerUserOptions:function(e){return Object.assign(this.options,e),this},resetProcess:function(){return this.state.dob.day=null,this.state.dob.month=null,this.state.dob.year=null,this.state.current_page=0,this.renderDatepicker(this),this},showDatepicker:function(){return this.state.show_datepicker=!0,this.resetProcess(),this},hideDatepicker:function(){return this.state.show_datepicker=!1,this.renderDatepicker(this),this},attachListenerToTargetNode:function(){var e=this;return this.getDatepickerTargetNode().addEventListener("focus",(function(){e.showDatepicker()})),document.addEventListener("keydown",(function(t){"Escape"===t.key&&e.hideDatepicker()})),this},attachDatepickerContainerToDOM:function(){var e=this.getdatepickerContainerNode();return this.getDatepickerTargetParentNode().style.setProperty("position","relative"),this.getDatepickerTargetParentNode().appendChild(e),this},adjustDatepickerPosition:function(){var e=this.getDatepickerWidgetNode().getBoundingClientRect(),t=this.getDatepickerTargetParentNode().getBoundingClientRect(),n=this.getDatepickerTargetNode().getBoundingClientRect(),r=t.height-(t.bottom-n.bottom),o=n.left-t.left+(n.width/2-e.width/2);return this.getdatepickerContainerNode().style.top="".concat(r+12,"px"),this.getdatepickerContainerNode().style.left="".concat(o,"px"),this},renderDatepicker:function(){return this.getFocusTrap().deactivate(),((e,t)=>{(e=u(e.parentNode,e,e.v||d(e),t)).v=t})(this.getdatepickerContainerNode(),C(this)),this.adjustDatepickerPosition(),this.state.show_datepicker&&this.getFocusTrap().activate(),this},init:function(e,t){this.setSelector(e).registerUserOptions(t).attachDatepickerContainerToDOM().renderDatepicker().attachListenerToTargetNode().adjustDatepickerPosition().setFocusTrap()}};t.default=function(){var e=Object.create(te),t={instance_id:Z++,state:{selected_date:null,show_datepicker:!1,show_alerts:null,current_page:0,dob:{day:null,month:null,year:null}},options:Q({},ee),selector:null,datepickerWidgetNode:null,datepickerContainerNode:null,datepickerTargetNode:null,datepickerTargetParentNode:null,focusTrap:null};return Object.assign(e,t)}}]).default})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("dobDatepicker",[],t):"object"==typeof exports?exports.dobDatepicker=t():e.dobDatepicker=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=0)}([function(e,t,n){e.exports=n(2)},function(e,t){function n(e,t){for(var n=[],r=0;r<e.length;r++)e[r]===t&&n.push(r);return n}e.exports=function(e,t="string",r=null){let o=function(e){switch(e){case"string":return["Invalid Format","Invalid Date","Valid Date"];case"boolean":return[!1,!1,!0];default:return["Invalid Format","Invalid Date","Valid Date"]}}(t);return null==e?o[0]:function(e,t,r){if(e){if(r||(r=e.includes("-")?"yyyy-mm-dd":"mm/dd/yyyy"),r.length>10||r.length<6)return t[0];const o=e.includes("-")?r.split("-"):r.split("/");if(o.map(e=>/([dmy])\1/i.test(e)).filter(e=>!e).length>0)return t[0];let a=e.includes("-")?"-":"/",i=new RegExp(`(\\d{${o[0].length}})(${a})(\\d{${o[1].length}})(${a})(\\d{${o[2].length}})`),c=n(o,o.filter(e=>/[d]/i.test(e))[0]),s=n(o,o.filter(e=>/[m]/i.test(e))[0]),u=n(o,o.filter(e=>/[y]/i.test(e))[0]);if(1!==c.length||1!==s.length||1!==u.length)return t[0];if(!i.test(e))return t[0];{const n=e.split(a),r=Number(n[c]),o=Number(n[s]),i=Number(n[u]);if(o<=0||o>12||r>function(e,t){return 2===t&&e%4==0?29:[31,28,31,30,31,30,31,31,30,31,30,31][t-1]}(i,o)||r<=0||i<1753)return t[1]}}return t[2]}(e,o,r)}},function(e,t,n){"use strict";n.r(t);var r={},o=[],a=e=>null==e?e:e.key,i=function(e){this.tag[e.type](e)},c=(e,t,n,r,o)=>{"key"===t||("o"===t[0]&&"n"===t[1]?((e.tag||(e.tag={}))[t=t.slice(2)]=r)?n||e.addEventListener(t,i):e.removeEventListener(t,i):!o&&"list"!==t&&"form"!==t&&t in e?e[t]=null==r?"":r:null==r||!1===r?e.removeAttribute(t):e.setAttribute(t,r))},s=(e,t)=>{var n=e.props,r=3===e.tag?document.createTextNode(e.type):(t=t||"svg"===e.type)?document.createElementNS("http://www.w3.org/2000/svg",e.type,{is:n.is}):document.createElement(e.type,{is:n.is});for(var o in n)c(r,o,null,n[o],t);return e.children.map(e=>r.appendChild(s(e=l(e),t))),e.dom=r},u=(e,t,n,r,o)=>{if(n===r);else if(null!=n&&3===n.tag&&3===r.tag)n.type!==r.type&&(t.nodeValue=r.type);else if(null==n||n.type!==r.type)t=e.insertBefore(s(r=l(r),o),t),null!=n&&e.removeChild(n.dom);else{var i,d,p,f,b=n.props,h=r.props,v=n.children,y=r.children,g=0,m=0,_=v.length-1,k=y.length-1;for(var D in o=o||"svg"===r.type,{...b,...h})("value"===D||"selected"===D||"checked"===D?t[D]:b[D])!==h[D]&&c(t,D,b[D],h[D],o);for(;m<=k&&g<=_&&null!=(p=a(v[g]))&&p===a(y[m]);)u(t,v[g].dom,v[g++],y[m]=l(y[m++]),o);for(;m<=k&&g<=_&&null!=(p=a(v[_]))&&p===a(y[k]);)u(t,v[_].dom,v[_--],y[k]=l(y[k--]),o);if(g>_)for(;m<=k;)t.insertBefore(s(y[m]=l(y[m++]),o),(d=v[g])&&d.dom);else if(m>k)for(;g<=_;)t.removeChild(v[g++].dom);else{var w={},O={};for(D=g;D<=_;D++)null!=(p=v[D].key)&&(w[p]=v[D]);for(;m<=k;)p=a(d=v[g]),f=a(y[m]=l(y[m])),O[p]||null!=f&&f===a(v[g+1])?(null==p&&t.removeChild(d.dom),g++):null==f||1===n.tag?(null==p&&(u(t,d&&d.dom,d,y[m],o),m++),g++):(p===f?(u(t,d.dom,d,y[m],o),O[f]=!0,g++):null!=(i=w[f])?(u(t,t.insertBefore(i.dom,d&&d.dom),i,y[m],o),O[f]=!0):u(t,d&&d.dom,null,y[m],o),m++);for(;g<=_;)null==a(d=v[g++])&&t.removeChild(d.dom);for(var D in w)null==O[D]&&t.removeChild(w[D].dom)}}return r.dom=t},l=e=>!0!==e&&!1!==e&&e?e:f(""),d=e=>3===e.nodeType?f(e.nodeValue,e):p(e.nodeName.toLowerCase(),r,o.map.call(e.childNodes,d),e,null,1),p=(e,t,n,r,o,a)=>({type:e,props:t,children:n,dom:r,key:o,tag:a}),f=(e,t)=>p(e,r,o,t,null,3),b=(e,t,n)=>p(e,t,Array.isArray(n)?n:null==n?o:[n],null,t.key),h=n(1);function v(e){return e<10?"0"+e.toString():e.toString()}function y(e){!function(e){e.state.current_page=e.state.current_page+1}(e),function(e){e.state.show_alerts=null}(e),function(e){if(3!==e.state.current_page)return;if(!e.options.enable_built_in_validation)return;(!h(g(e),"boolean","yyyy-mm-dd")||new Date(g(e))>new Date)&&function(e,t){e.state.show_alerts=t,e.resetProcess()}(e,"invalid_date_alert")}(e),function(e){if(3!==e.state.current_page||null!==e.state.show_alerts)return e;var t=e.options.dateFormat?e.options.dateFormat(g(e)):g(e);e.state.selected_date=t,e.datepickerTargetNode.value=t,e.hideDatepicker()}(e)}function g(e){return"".concat(e.state.dob.year,"-").concat(v(e.state.dob.month),"-").concat(v(e.state.dob.day))}function m(e,t,n){n.state.dob[e]=t,y(n)}function _(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return k(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return k(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function D(e){return b("div",{class:"top-arrow ".concat("popup"===e.options.display_mode?"top-arrow--popup":"")})}function w(e){return 0===e.state.current_page?function(e){return b("div",{class:"dob-datepicker__month",tabindex:"0"},e.options[e.options.show_long_month?"long_month":"short_month"].map((function(t,n){return b("button",{key:n+1,value:n+1,class:"dob-datepicker__month__button",onclick:function(){m("month",n+1,e),e.renderDatepicker()}},f(t))})))}(e):1===e.state.current_page?function(e){return b("div",{class:"dob-datepicker__day",tabindex:"0"},_(Array(2===e.state.dob.month?30:32).keys()).map((function(t,n){return 0===t?null:b("button",{key:n,value:n,class:"dob-datepicker__day__button",onclick:function(){m("day",n,e),e.renderDatepicker()}},[f(t),e.options.enable_ordinal_number?b("sup",{class:"dob-datepicker__day__ordinal-number"},j(n)):null])})))}(e):function(e){return b("div",{class:"dob-datepicker__year",tabindex:"0"},function(e){for(var t=(new Date).getFullYear(),n=[],r=[],o=[],a=function(a){r.length<20&&(o.push(a),r.push(b("button",{key:a,value:a,class:"dob-datepicker__year__button",onclick:function(){m("year",a,e),e.renderDatepicker()}},[b("span",{class:"dob-datepicker__year__button__first"},f(a.toString().substring(0,2))),b("span",{class:"dob-datepicker__year__button__last"},f(a.toString().substring(2)))])),20===r.length&&(n.push(P(e,r,o[0],o[o.length-1])),r=[],o=[]),a===t-e.options.year_range&&n.push(P(e,r,o[0],o[o.length-1])))},i=t;i>=t-e.options.year_range;i--)a(i);return n}(e))}(e)}function O(e){return b("div",{class:"dob-datepicker__alert"},f(e.options.alerts[e.state.show_alerts]))}function N(e){return b("div",{class:"dob-datepicker__header"},f(e.options.labels.header_label))}function T(e){return b("div",{class:"dob-datepicker__selection-header"},function(e){return 0===e.state.current_page?f(e.options.labels.select_month_label):1===e.state.current_page?f(e.options.labels.select_day_label):f(e.options.labels.select_year_label)}(e))}function E(e){return b("button",{class:"dob-datepicker__reset"},[b("div",{class:"dob-datepicker__reset-text",onclick:function(){e.resetProcess()}},f(e.options.labels.reset_button_label))])}function j(e){switch(!0){case 1===e||21===e||31===e:return f("st");case 2===e||22===e:return f("nd");case 23===e||23===e:return f("rd");default:return f("th")}}function P(e,t,n,r){return b("div",{class:"dob-datepicker__year__year-section"},[b("div",{class:"dob-datepicker__year__year-section-header"},f("".concat(e.options.labels.date_range_label).concat(r," - ").concat(n))),b("div",{class:"dob-datepicker__year__wrapper"},t),b("div",{class:"dob-datepicker__year__year-section-next"},f("⌄"))])}var S,C=function(e){return b("div",{class:"dob-datepicker__wrapper ".concat(e.state.show_datepicker?"":"dob-datepicker__wrapper--hide"," ")},[b("div",{class:"dob-datepicker__background ".concat("popup"===e.options.display_mode?"dob-datepicker__background--popup":""),style:"z-index: ".concat(e.options.zIndex.invisibleBackground),onclick:function(){e.hideDatepicker()}}),b("div",{id:"datepicker-widget__".concat(e.instance_id),class:"dob-datepicker ".concat("popup"===e.options.display_mode?"dob-datepicker--popup":""),style:"z-index: ".concat(e.options.zIndex.datepickerWidget)},[D(e),N(e),e.state.show_alerts?O(e):b("div",{}),T(e),b("div",{class:"dob-datepicker__options"},w(e)),e.state.current_page>0?E(e):b("div",{})])])},x=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],F=x.join(","),A="undefined"==typeof Element?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,I=function(e,t,n){var r=Array.prototype.slice.apply(e.querySelectorAll(F));return t&&A.call(e,F)&&r.unshift(e),r=r.filter(n)},L=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return isNaN(t)?function(e){return"true"===e.contentEditable}(e)?0:"AUDIO"!==e.nodeName&&"VIDEO"!==e.nodeName&&"DETAILS"!==e.nodeName||null!==e.getAttribute("tabindex")?e.tabIndex:0:t},M=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},B=function(e){return"INPUT"===e.tagName},W=function(e){return function(e){return B(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}((e.form||e.ownerDocument).querySelectorAll('input[type="radio"][name="'+e.name+'"]'),e.form);return!t||t===e}(e)},R=function(e){return!(e.disabled||function(e){return B(e)&&"hidden"===e.type}(e)||function(e){if("hidden"===getComputedStyle(e).visibility)return!0;var t=A.call(e,"details>summary:first-of-type")?e.parentElement:e;if(A.call(t,"details:not([open]) *"))return!0;for(;e;){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(e))},G=function(e){return!(!R(e)||W(e)||L(e)<0)},q=x.concat("iframe").join(","),J=function(e){if(!e)throw new Error("No node provided");return!1!==A.call(e,q)&&R(e)};function U(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var z,V=(z=[],{activateTrap:function(e){if(z.length>0){var t=z[z.length-1];t!==e&&t.pause()}var n=z.indexOf(e);-1===n||z.splice(n,1),z.push(e)},deactivateTrap:function(e){var t=z.indexOf(e);-1!==t&&z.splice(t,1),z.length>0&&z[z.length-1].unpause()}}),Y=function(e){return setTimeout(e,0)},K=function(e,t){var n,r=document,o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$(Object(n),!0).forEach((function(t){U(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},t),a={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},i=function(e){return a.containers.some((function(t){return t.contains(e)}))},c=function(e){var t=o[e];if(!t)return null;var n=t;if("string"==typeof t&&!(n=r.querySelector(t)))throw new Error("`".concat(e,"` refers to no known node"));if("function"==typeof t&&!(n=t()))throw new Error("`".concat(e,"` did not return a node"));return n},s=function(){var e;if(null!==c("initialFocus"))e=c("initialFocus");else if(i(r.activeElement))e=r.activeElement;else{var t=a.tabbableGroups[0];e=t&&t.firstTabbableNode||c("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},u=function(){a.tabbableGroups=a.containers.map((function(e){var t,n,r,o=(n=[],r=[],I(e,(t=t||{}).includeContainer,G).forEach((function(e,t){var o=L(e);0===o?n.push(e):r.push({documentOrder:t,tabIndex:o,node:e})})),r.sort(M).map((function(e){return e.node})).concat(n));return{firstTabbableNode:o[0],lastTabbableNode:o[o.length-1]}}))},l=function e(t){t!==r.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!o.preventScroll}),a.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(s()))},d=function(e){i(e.target)||(o.clickOutsideDeactivates?n.deactivate({returnFocus:o.returnFocusOnDeactivate&&!J(e.target)}):o.allowOutsideClick&&("boolean"==typeof o.allowOutsideClick?o.allowOutsideClick:o.allowOutsideClick(e))||e.preventDefault())},p=function(e){i(e.target)||e.target instanceof Document||(e.stopImmediatePropagation(),l(a.mostRecentlyFocusedNode||s()))},f=function(e){if(!1!==o.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void n.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){u();var t=null;if(e.shiftKey){var n=a.tabbableGroups.findIndex((function(t){var n=t.firstTabbableNode;return e.target===n}));if(n>=0){var r=0===n?a.tabbableGroups.length-1:n-1;t=a.tabbableGroups[r].lastTabbableNode}}else{var o=a.tabbableGroups.findIndex((function(t){var n=t.lastTabbableNode;return e.target===n}));if(o>=0){var i=o===a.tabbableGroups.length-1?0:o+1;t=a.tabbableGroups[i].firstTabbableNode}}t&&(e.preventDefault(),l(t))}(e)},b=function(e){o.clickOutsideDeactivates||i(e.target)||o.allowOutsideClick&&("boolean"==typeof o.allowOutsideClick?o.allowOutsideClick:o.allowOutsideClick(e))||(e.preventDefault(),e.stopImmediatePropagation())},h=function(){if(a.active)return V.activateTrap(n),S=o.delayInitialFocus?Y((function(){l(s())})):l(s()),r.addEventListener("focusin",p,!0),r.addEventListener("mousedown",d,{capture:!0,passive:!1}),r.addEventListener("touchstart",d,{capture:!0,passive:!1}),r.addEventListener("click",b,{capture:!0,passive:!1}),r.addEventListener("keydown",f,{capture:!0,passive:!1}),n},v=function(){if(a.active)return r.removeEventListener("focusin",p,!0),r.removeEventListener("mousedown",d,!0),r.removeEventListener("touchstart",d,!0),r.removeEventListener("click",b,!0),r.removeEventListener("keydown",f,!0),n};return(n={activate:function(e){if(a.active)return this;u(),a.active=!0,a.paused=!1,a.nodeFocusedBeforeActivation=r.activeElement;var t=e&&e.onActivate?e.onActivate:o.onActivate;return t&&t(),h(),this},deactivate:function(e){if(!a.active)return this;clearTimeout(S),v(),a.active=!1,a.paused=!1,V.deactivateTrap(n);var t=e&&void 0!==e.onDeactivate?e.onDeactivate:o.onDeactivate;return t&&t(),(e&&void 0!==e.returnFocus?e.returnFocus:o.returnFocusOnDeactivate)&&Y((function(){var e;l((e=a.nodeFocusedBeforeActivation,c("setReturnFocus")||e))})),this},pause:function(){return a.paused||!a.active||(a.paused=!0,v()),this},unpause:function(){return a.paused&&a.active?(a.paused=!1,u(),h(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return a.containers=t.map((function(e){return"string"==typeof e?r.querySelector(e):e})),a.active&&u(),this}}).updateContainerElements(e),n};function H(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Q(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?H(Object(n),!0).forEach((function(t){X(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):H(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function X(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Z=0,ee={display_mode:"inline",year_range:120,enable_built_in_validation:!0,enable_ordinal_number:!0,show_long_month:!0,dateFormat:null,zIndex:{targetNode:"150",datepickerWidget:"150",invisibleBackground:"100"},long_month:["January","February","March","April","May","June","July","August","September","October","November","December"],short_month:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],labels:{header_label:"When is your birthday?",select_day_label:"Select day",select_month_label:"Select month",select_year_label:"Select year",reset_button_label:"Reset and try again",date_range_label:"Year "},alerts:{invalid_date_alert:"Date is invalid"}};var te={getDatepickerWidgetNode:function(){return this.datepickerWidgetNode?this.datepickerWidgetNode:this.setDatepickerWidgetNode()},setDatepickerWidgetNode:function(){return this.datepickerWidgetNode=document.getElementById("datepicker-widget__".concat(this.instance_id))},getDatepickerTargetNode:function(){return this.datepickerTargetNode?this.datepickerTargetNode:this.setDatepickerTargetNode()},setDatepickerTargetNode:function(){return this.datepickerTargetNode=this.selector instanceof Element?this.selector:document.querySelector(this.getSelector())},getDatepickerTargetParentNode:function(){return this.datepickerTargetParentNode?this.datepickerTargetParentNode:this.setDatepickerTargetParentNode()},setDatepickerTargetParentNode:function(){return this.datepickerTargetParentNode=this.selector instanceof Element?this.selector.parentElement:document.querySelector(this.getSelector()).parentElement},getdatepickerContainerNode:function(){return this.datepickerContainerNode?this.datepickerContainerNode:this.setDatepickerContainerNode()},setDatepickerContainerNode:function(){var e=document.createElement("div");return e.style.setProperty("position","absolute"),this.datepickerContainerNode=e},getSelector:function(){return this.selector},setSelector:function(e){return this.selector=e,this},getFocusTrap:function(){return this.focusTrap?this.focusTrap:this.setFocusTrap()},setFocusTrap:function(){return this.focusTrap=K(this.getDatepickerWidgetNode(),{clickOutsideDeactivates:!0,returnFocusOnDeactivate:!1})},registerUserOptions:function(e){return Object.assign(this.options,e),this},resetProcess:function(){return this.state.dob.day=null,this.state.dob.month=null,this.state.dob.year=null,this.state.current_page=0,this.renderDatepicker(this),this},showDatepicker:function(){return this.state.show_datepicker=!0,this.resetProcess(),this},hideDatepicker:function(){return this.state.show_datepicker=!1,this.renderDatepicker(this),this},attachListenerToTargetNode:function(){var e=this;return this.getDatepickerTargetNode().addEventListener("focus",(function(){e.showDatepicker()})),document.addEventListener("keydown",(function(t){"Escape"===t.key&&e.hideDatepicker()})),this},attachDatepickerContainerToDOM:function(){var e=this.getdatepickerContainerNode();return this.getDatepickerTargetParentNode().style.setProperty("position","relative"),this.getDatepickerTargetParentNode().appendChild(e),this},adjustDatepickerPosition:function(){var e=this.getDatepickerWidgetNode().getBoundingClientRect(),t=this.getDatepickerTargetParentNode().getBoundingClientRect(),n=this.getDatepickerTargetNode().getBoundingClientRect(),r=t.height-(t.bottom-n.bottom),o=n.left-t.left+(n.width/2-e.width/2);return this.getdatepickerContainerNode().style.top="".concat(r+12,"px"),this.getdatepickerContainerNode().style.left="".concat(o,"px"),this},renderDatepicker:function(){return this.getFocusTrap().deactivate(),((e,t)=>{(e=u(e.parentNode,e,e.v||d(e),t)).v=t})(this.getdatepickerContainerNode(),C(this)),this.adjustDatepickerPosition(),this.state.show_datepicker&&this.getFocusTrap().activate(),this},init:function(e,t){this.setSelector(e).registerUserOptions(t).attachDatepickerContainerToDOM().renderDatepicker().attachListenerToTargetNode().adjustDatepickerPosition().setFocusTrap()}};t.default=function(e,t){var n=Object.create(te),r={instance_id:Z++,state:{selected_date:null,show_datepicker:!1,show_alerts:null,current_page:0,dob:{day:null,month:null,year:null}},options:Q({},ee),selector:null,datepickerWidgetNode:null,datepickerContainerNode:null,datepickerTargetNode:null,datepickerTargetParentNode:null,focusTrap:null},o=Object.assign(n,r);return o.init(e,t),o}}]).default})); |
@@ -1,1 +0,1 @@ | ||
function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach(function(t){_defineProperty(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _typeof(e){return(_typeof="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})(e)}!function(e,t){"object"==("undefined"==typeof exports?"undefined":_typeof(exports))&&"object"==("undefined"==typeof module?"undefined":_typeof(module))?module.exports=t():"function"==typeof define&&define.amd?define("dobDatepicker",[],t):"object"==("undefined"==typeof exports?"undefined":_typeof(exports))?exports.dobDatepicker=t():e.dobDatepicker=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==_typeof(e)&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=0)}([function(e,t,n){e.exports=n(2)},function(e,t){function n(e,t){for(var n=[],r=0;r<e.length;r++)e[r]===t&&n.push(r);return n}e.exports=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"string",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=function(e){switch(t){case"string":return["Invalid Format","Invalid Date","Valid Date"];case"boolean":return[!1,!1,!0];default:return["Invalid Format","Invalid Date","Valid Date"]}}();return null==e?o[0]:function(e,t,r){if(e){if(r||(r=e.includes("-")?"yyyy-mm-dd":"mm/dd/yyyy"),r.length>10||r.length<6)return t[0];var o=e.includes("-")?r.split("-"):r.split("/");if(o.map(function(e){return/([dmy])\1/i.test(e)}).filter(function(e){return!e}).length>0)return t[0];var i=e.includes("-")?"-":"/",a=new RegExp("(\\d{".concat(o[0].length,"})(").concat(i,")(\\d{").concat(o[1].length,"})(").concat(i,")(\\d{").concat(o[2].length,"})")),c=n(o,o.filter(function(e){return/[d]/i.test(e)})[0]),u=n(o,o.filter(function(e){return/[m]/i.test(e)})[0]),s=n(o,o.filter(function(e){return/[y]/i.test(e)})[0]);if(1!==c.length||1!==u.length||1!==s.length)return t[0];if(!a.test(e))return t[0];var l=e.split(i),d=Number(l[c]),p=Number(l[u]),f=Number(l[s]);if(p<=0||p>12||d>(2===p&&f%4==0?29:[31,28,31,30,31,30,31,31,30,31,30,31][p-1])||d<=0||f<1753)return t[1]}return t[2]}(e,o,r)}},function(e,t,n){"use strict";n.r(t);var r={},o=[],i=function(e){return null==e?e:e.key},a=function(e){this.tag[e.type](e)},c=function(e,t,n,r,o){"key"===t||("o"===t[0]&&"n"===t[1]?((e.tag||(e.tag={}))[t=t.slice(2)]=r)?n||e.addEventListener(t,a):e.removeEventListener(t,a):!o&&"list"!==t&&"form"!==t&&t in e?e[t]=null==r?"":r:null==r||!1===r?e.removeAttribute(t):e.setAttribute(t,r))},u=function e(t,n){var r=t.props,o=3===t.tag?document.createTextNode(t.type):(n=n||"svg"===t.type)?document.createElementNS("http://www.w3.org/2000/svg",t.type,{is:r.is}):document.createElement(t.type,{is:r.is});for(var i in r)c(o,i,null,r[i],n);return t.children.map(function(t){return o.appendChild(e(t=s(t),n))}),t.dom=o},s=function(e){return!0!==e&&!1!==e&&e?e:d("")},l=function(e,t,n,r,o,i){return{type:e,props:t,children:n,dom:r,key:o,tag:i}},d=function(e,t){return l(e,r,o,t,null,3)},p=function(e,t,n){return l(e,t,Array.isArray(n)?n:null==n?o:[n],null,t.key)},f=n(1);function b(e){return e<10?"0"+e.toString():e.toString()}function y(e){return"".concat(e.state.dob.year,"-").concat(b(e.state.dob.month),"-").concat(b(e.state.dob.day))}function h(e,t,n){n.state.dob[e]=t,function(e){!function(e){e.state.current_page=e.state.current_page+1}(e),function(e){e.state.show_alerts=null}(e),function(e){3===e.state.current_page&&e.options.enable_built_in_validation&&(!f(y(e),"boolean","yyyy-mm-dd")||new Date(y(e))>new Date)&&function(e,t){e.state.show_alerts="invalid_date_alert",e.resetProcess()}(e)}(e),function(e){if(3!==e.state.current_page||null!==e.state.show_alerts)return e;var t=e.options.dateFormat?e.options.dateFormat(y(e)):y(e);e.state.selected_date=t,e.datepickerTargetNode.value=t,e.hideDatepicker()}(e)}(n)}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function g(e){return p("div",{class:"top-arrow ".concat("popup"===e.options.display_mode?"top-arrow--popup":"")})}function m(e){return 0===e.state.current_page?function(e){return p("div",{class:"dob-datepicker__month",tabindex:"0"},e.options[e.options.show_long_month?"long_month":"short_month"].map(function(t,n){return p("button",{key:n+1,value:n+1,class:"dob-datepicker__month__button",onclick:function(){h("month",n+1,e),e.renderDatepicker()}},d(t))}))}(e):1===e.state.current_page?function(e){return p("div",{class:"dob-datepicker__day",tabindex:"0"},function(e){return function(e){if(Array.isArray(e))return v(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return v(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(Array(2===e.state.dob.month?30:32).keys()).map(function(t,n){return 0===t?null:p("button",{key:n,value:n,class:"dob-datepicker__day__button",onclick:function(){h("day",n,e),e.renderDatepicker()}},[d(t),e.options.enable_ordinal_number?p("sup",{class:"dob-datepicker__day__ordinal-number"},D(n)):null])}))}(e):function(e){return p("div",{class:"dob-datepicker__year",tabindex:"0"},function(e){for(var t=(new Date).getFullYear(),n=[],r=[],o=[],i=function(i){r.length<20&&(o.push(i),r.push(p("button",{key:i,value:i,class:"dob-datepicker__year__button",onclick:function(){h("year",i,e),e.renderDatepicker()}},[p("span",{class:"dob-datepicker__year__button__first"},d(i.toString().substring(0,2))),p("span",{class:"dob-datepicker__year__button__last"},d(i.toString().substring(2)))])),20===r.length&&(n.push(N(e,r,o[0],o[o.length-1])),r=[],o=[]),i===t-e.options.year_range&&n.push(N(e,r,o[0],o[o.length-1])))},a=t;a>=t-e.options.year_range;a--)i(a);return n}(e))}(e)}function _(e){return p("div",{class:"dob-datepicker__alert"},d(e.options.alerts[e.state.show_alerts]))}function k(e){return p("div",{class:"dob-datepicker__header"},d(e.options.labels.header_label))}function O(e){return p("div",{class:"dob-datepicker__selection-header"},function(e){return 0===e.state.current_page?d(e.options.labels.select_month_label):1===e.state.current_page?d(e.options.labels.select_day_label):d(e.options.labels.select_year_label)}(e))}function w(e){return p("button",{class:"dob-datepicker__reset"},[p("div",{class:"dob-datepicker__reset-text",onclick:function(){e.resetProcess()}},d(e.options.labels.reset_button_label))])}function D(e){switch(!0){case 1===e||21===e||31===e:return d("st");case 2===e||22===e:return d("nd");case 23===e||23===e:return d("rd");default:return d("th")}}function N(e,t,n,r){return p("div",{class:"dob-datepicker__year__year-section"},[p("div",{class:"dob-datepicker__year__year-section-header"},d("".concat(e.options.labels.date_range_label).concat(r," - ").concat(n))),p("div",{class:"dob-datepicker__year__wrapper"},t),p("div",{class:"dob-datepicker__year__year-section-next"},d("⌄"))])}var j,T=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],P=T.join(","),E="undefined"==typeof Element?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,S=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return isNaN(t)?function(e){return"true"===e.contentEditable}(e)?0:"AUDIO"!==e.nodeName&&"VIDEO"!==e.nodeName&&"DETAILS"!==e.nodeName||null!==e.getAttribute("tabindex")?e.tabIndex:0:t},x=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},C=function(e){return"INPUT"===e.tagName},F=function(e){return!(e.disabled||function(e){return C(e)&&"hidden"===e.type}(e)||function(e){if("hidden"===getComputedStyle(e).visibility)return!0;var t=E.call(e,"details>summary:first-of-type")?e.parentElement:e;if(E.call(t,"details:not([open]) *"))return!0;for(;e;){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(e){return"SUMMARY"===e.tagName})}(e))},A=function(e){return!(!F(e)||function(e){return function(e){return C(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}((e.form||e.ownerDocument).querySelectorAll('input[type="radio"][name="'+e.name+'"]'),e.form);return!t||t===e}(e)}(e)||S(e)<0)},I=T.concat("iframe").join(","),L=function(e){if(!e)throw new Error("No node provided");return!1!==E.call(e,I)&&F(e)};function M(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function B(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}var W,R=(W=[],{activateTrap:function(e){if(W.length>0){var t=W[W.length-1];t!==e&&t.pause()}var n=W.indexOf(e);-1===n||W.splice(n,1),W.push(e)},deactivateTrap:function(e){var t=W.indexOf(e);-1!==t&&W.splice(t,1),W.length>0&&W[W.length-1].unpause()}}),G=function(e){return setTimeout(e,0)},q=function(e,t){var n,r=document,o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?B(Object(n),!0).forEach(function(t){M(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):B(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},t),i={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},a=function(e){return i.containers.some(function(t){return t.contains(e)})},c=function(e){var t=o[e];if(!t)return null;var n=t;if("string"==typeof t&&!(n=r.querySelector(t)))throw new Error("`".concat(e,"` refers to no known node"));if("function"==typeof t&&!(n=t()))throw new Error("`".concat(e,"` did not return a node"));return n},u=function(){var e;if(null!==c("initialFocus"))e=c("initialFocus");else if(a(r.activeElement))e=r.activeElement;else{var t=i.tabbableGroups[0];e=t&&t.firstTabbableNode||c("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},s=function(){i.tabbableGroups=i.containers.map(function(e){var t,n,r,o=(n=[],r=[],function(e,t,n){var r=Array.prototype.slice.apply(e.querySelectorAll(P));return t&&E.call(e,P)&&r.unshift(e),r.filter(n)}(e,(t=t||{}).includeContainer,A).forEach(function(e,t){var o=S(e);0===o?n.push(e):r.push({documentOrder:t,tabIndex:o,node:e})}),r.sort(x).map(function(e){return e.node}).concat(n));return{firstTabbableNode:o[0],lastTabbableNode:o[o.length-1]}})},l=function e(t){t!==r.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!o.preventScroll}),i.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(u()))},d=function(e){a(e.target)||(o.clickOutsideDeactivates?n.deactivate({returnFocus:o.returnFocusOnDeactivate&&!L(e.target)}):o.allowOutsideClick&&("boolean"==typeof o.allowOutsideClick?o.allowOutsideClick:o.allowOutsideClick(e))||e.preventDefault())},p=function(e){a(e.target)||e.target instanceof Document||(e.stopImmediatePropagation(),l(i.mostRecentlyFocusedNode||u()))},f=function(e){if(!1!==o.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void n.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){s();var t=null;if(e.shiftKey){var n=i.tabbableGroups.findIndex(function(t){var n=t.firstTabbableNode;return e.target===n});if(n>=0){var r=0===n?i.tabbableGroups.length-1:n-1;t=i.tabbableGroups[r].lastTabbableNode}}else{var o=i.tabbableGroups.findIndex(function(t){var n=t.lastTabbableNode;return e.target===n});if(o>=0){var a=o===i.tabbableGroups.length-1?0:o+1;t=i.tabbableGroups[a].firstTabbableNode}}t&&(e.preventDefault(),l(t))}(e)},b=function(e){o.clickOutsideDeactivates||a(e.target)||o.allowOutsideClick&&("boolean"==typeof o.allowOutsideClick?o.allowOutsideClick:o.allowOutsideClick(e))||(e.preventDefault(),e.stopImmediatePropagation())},y=function(){if(i.active)return R.activateTrap(n),j=o.delayInitialFocus?G(function(){l(u())}):l(u()),r.addEventListener("focusin",p,!0),r.addEventListener("mousedown",d,{capture:!0,passive:!1}),r.addEventListener("touchstart",d,{capture:!0,passive:!1}),r.addEventListener("click",b,{capture:!0,passive:!1}),r.addEventListener("keydown",f,{capture:!0,passive:!1}),n},h=function(){if(i.active)return r.removeEventListener("focusin",p,!0),r.removeEventListener("mousedown",d,!0),r.removeEventListener("touchstart",d,!0),r.removeEventListener("click",b,!0),r.removeEventListener("keydown",f,!0),n};return(n={activate:function(e){if(i.active)return this;s(),i.active=!0,i.paused=!1,i.nodeFocusedBeforeActivation=r.activeElement;var t=e&&e.onActivate?e.onActivate:o.onActivate;return t&&t(),y(),this},deactivate:function(e){if(!i.active)return this;clearTimeout(j),h(),i.active=!1,i.paused=!1,R.deactivateTrap(n);var t=e&&void 0!==e.onDeactivate?e.onDeactivate:o.onDeactivate;return t&&t(),(e&&void 0!==e.returnFocus?e.returnFocus:o.returnFocusOnDeactivate)&&G(function(){var e;l((e=i.nodeFocusedBeforeActivation,c("setReturnFocus")||e))}),this},pause:function(){return i.paused||!i.active||(i.paused=!0,h()),this},unpause:function(){return i.paused&&i.active?(i.paused=!1,s(),y(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return i.containers=t.map(function(e){return"string"==typeof e?r.querySelector(e):e}),i.active&&s(),this}}).updateContainerElements(e),n};function J(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?J(Object(n),!0).forEach(function(t){z(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):J(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var V=0,K={display_mode:"inline",year_range:120,enable_built_in_validation:!0,enable_ordinal_number:!0,show_long_month:!0,dateFormat:null,zIndex:{targetNode:"150",datepickerWidget:"150",invisibleBackground:"100"},long_month:["January","February","March","April","May","June","July","August","September","October","November","December"],short_month:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],labels:{header_label:"When is your birthday?",select_day_label:"Select day",select_month_label:"Select month",select_year_label:"Select year",reset_button_label:"Reset and try again",date_range_label:"Year "},alerts:{invalid_date_alert:"Date is invalid"}},Y={getDatepickerWidgetNode:function(){return this.datepickerWidgetNode?this.datepickerWidgetNode:this.setDatepickerWidgetNode()},setDatepickerWidgetNode:function(){return this.datepickerWidgetNode=document.getElementById("datepicker-widget__".concat(this.instance_id))},getDatepickerTargetNode:function(){return this.datepickerTargetNode?this.datepickerTargetNode:this.setDatepickerTargetNode()},setDatepickerTargetNode:function(){return this.datepickerTargetNode=this.selector instanceof Element?this.selector:document.querySelector(this.getSelector())},getDatepickerTargetParentNode:function(){return this.datepickerTargetParentNode?this.datepickerTargetParentNode:this.setDatepickerTargetParentNode()},setDatepickerTargetParentNode:function(){return this.datepickerTargetParentNode=this.selector instanceof Element?this.selector.parentElement:document.querySelector(this.getSelector()).parentElement},getdatepickerContainerNode:function(){return this.datepickerContainerNode?this.datepickerContainerNode:this.setDatepickerContainerNode()},setDatepickerContainerNode:function(){var e=document.createElement("div");return e.style.setProperty("position","absolute"),this.datepickerContainerNode=e},getSelector:function(){return this.selector},setSelector:function(e){return this.selector=e,this},getFocusTrap:function(){return this.focusTrap?this.focusTrap:this.setFocusTrap()},setFocusTrap:function(){return this.focusTrap=q(this.getDatepickerWidgetNode(),{clickOutsideDeactivates:!0,returnFocusOnDeactivate:!1})},registerUserOptions:function(e){return Object.assign(this.options,e),this},resetProcess:function(){return this.state.dob.day=null,this.state.dob.month=null,this.state.dob.year=null,this.state.current_page=0,this.renderDatepicker(this),this},showDatepicker:function(){return this.state.show_datepicker=!0,this.resetProcess(),this},hideDatepicker:function(){return this.state.show_datepicker=!1,this.renderDatepicker(this),this},attachListenerToTargetNode:function(){var e=this;return this.getDatepickerTargetNode().addEventListener("focus",function(){e.showDatepicker()}),document.addEventListener("keydown",function(t){"Escape"===t.key&&e.hideDatepicker()}),this},attachDatepickerContainerToDOM:function(){var e=this.getdatepickerContainerNode();return this.getDatepickerTargetParentNode().style.setProperty("position","relative"),this.getDatepickerTargetParentNode().appendChild(e),this},adjustDatepickerPosition:function(){var e=this.getDatepickerWidgetNode().getBoundingClientRect(),t=this.getDatepickerTargetParentNode().getBoundingClientRect(),n=this.getDatepickerTargetNode().getBoundingClientRect(),r=t.height-(t.bottom-n.bottom),o=n.left-t.left+(n.width/2-e.width/2);return this.getdatepickerContainerNode().style.top="".concat(r+12,"px"),this.getdatepickerContainerNode().style.left="".concat(o,"px"),this},renderDatepicker:function(){return this.getFocusTrap().deactivate(),function(e,t){(e=function e(t,n,r,o,a){if(r===o);else if(null!=r&&3===r.tag&&3===o.tag)r.type!==o.type&&(n.nodeValue=o.type);else if(null==r||r.type!==o.type)n=t.insertBefore(u(o=s(o),a),n),null!=r&&t.removeChild(r.dom);else{var l,d,p,f,b=r.props,y=o.props,h=r.children,v=o.children,g=0,m=0,_=h.length-1,k=v.length-1;for(var O in a=a||"svg"===o.type,_objectSpread(_objectSpread({},b),y))("value"===O||"selected"===O||"checked"===O?n[O]:b[O])!==y[O]&&c(n,O,b[O],y[O],a);for(;m<=k&&g<=_&&null!=(p=i(h[g]))&&p===i(v[m]);)e(n,h[g].dom,h[g++],v[m]=s(v[m++]),a);for(;m<=k&&g<=_&&null!=(p=i(h[_]))&&p===i(v[k]);)e(n,h[_].dom,h[_--],v[k]=s(v[k--]),a);if(g>_)for(;m<=k;)n.insertBefore(u(v[m]=s(v[m++]),a),(d=h[g])&&d.dom);else if(m>k)for(;g<=_;)n.removeChild(h[g++].dom);else{var w={},D={};for(O=g;O<=_;O++)null!=(p=h[O].key)&&(w[p]=h[O]);for(;m<=k;)p=i(d=h[g]),f=i(v[m]=s(v[m])),D[p]||null!=f&&f===i(h[g+1])?(null==p&&n.removeChild(d.dom),g++):null==f||1===r.tag?(null==p&&(e(n,d&&d.dom,d,v[m],a),m++),g++):(p===f?(e(n,d.dom,d,v[m],a),D[f]=!0,g++):null!=(l=w[f])?(e(n,n.insertBefore(l.dom,d&&d.dom),l,v[m],a),D[f]=!0):e(n,d&&d.dom,null,v[m],a),m++);for(;g<=_;)null==i(d=h[g++])&&n.removeChild(d.dom);for(var O in w)null==D[O]&&n.removeChild(w[O].dom)}}return o.dom=n}(e.parentNode,e,e.v||function e(t){return 3===t.nodeType?d(t.nodeValue,t):l(t.nodeName.toLowerCase(),r,o.map.call(t.childNodes,e),t,null,1)}(e),t)).v=t}(this.getdatepickerContainerNode(),p("div",{class:"dob-datepicker__wrapper ".concat((e=this).state.show_datepicker?"":"dob-datepicker__wrapper--hide"," ")},[p("div",{class:"dob-datepicker__background ".concat("popup"===e.options.display_mode?"dob-datepicker__background--popup":""),style:"z-index: ".concat(e.options.zIndex.invisibleBackground),onclick:function(){e.hideDatepicker()}}),p("div",{id:"datepicker-widget__".concat(e.instance_id),class:"dob-datepicker ".concat("popup"===e.options.display_mode?"dob-datepicker--popup":""),style:"z-index: ".concat(e.options.zIndex.datepickerWidget)},[g(e),k(e),e.state.show_alerts?_(e):p("div",{}),O(e),p("div",{class:"dob-datepicker__options"},m(e)),e.state.current_page>0?w(e):p("div",{})])])),this.adjustDatepickerPosition(),this.state.show_datepicker&&this.getFocusTrap().activate(),this;var e},init:function(e,t){this.setSelector(e).registerUserOptions(t).attachDatepickerContainerToDOM().renderDatepicker().attachListenerToTargetNode().adjustDatepickerPosition().setFocusTrap()}};t.default=function(){var e=Object.create(Y),t={instance_id:V++,state:{selected_date:null,show_datepicker:!1,show_alerts:null,current_page:0,dob:{day:null,month:null,year:null}},options:U({},K),selector:null,datepickerWidgetNode:null,datepickerContainerNode:null,datepickerTargetNode:null,datepickerTargetParentNode:null,focusTrap:null};return Object.assign(e,t)}}]).default}); | ||
function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach(function(t){_defineProperty(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _typeof(e){return(_typeof="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})(e)}!function(e,t){"object"==("undefined"==typeof exports?"undefined":_typeof(exports))&&"object"==("undefined"==typeof module?"undefined":_typeof(module))?module.exports=t():"function"==typeof define&&define.amd?define("dobDatepicker",[],t):"object"==("undefined"==typeof exports?"undefined":_typeof(exports))?exports.dobDatepicker=t():e.dobDatepicker=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==_typeof(e)&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=0)}([function(e,t,n){e.exports=n(2)},function(e,t){function n(e,t){for(var n=[],r=0;r<e.length;r++)e[r]===t&&n.push(r);return n}e.exports=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"string",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=function(e){switch(t){case"string":return["Invalid Format","Invalid Date","Valid Date"];case"boolean":return[!1,!1,!0];default:return["Invalid Format","Invalid Date","Valid Date"]}}();return null==e?o[0]:function(e,t,r){if(e){if(r||(r=e.includes("-")?"yyyy-mm-dd":"mm/dd/yyyy"),r.length>10||r.length<6)return t[0];var o=e.includes("-")?r.split("-"):r.split("/");if(o.map(function(e){return/([dmy])\1/i.test(e)}).filter(function(e){return!e}).length>0)return t[0];var i=e.includes("-")?"-":"/",a=new RegExp("(\\d{".concat(o[0].length,"})(").concat(i,")(\\d{").concat(o[1].length,"})(").concat(i,")(\\d{").concat(o[2].length,"})")),c=n(o,o.filter(function(e){return/[d]/i.test(e)})[0]),u=n(o,o.filter(function(e){return/[m]/i.test(e)})[0]),s=n(o,o.filter(function(e){return/[y]/i.test(e)})[0]);if(1!==c.length||1!==u.length||1!==s.length)return t[0];if(!a.test(e))return t[0];var l=e.split(i),d=Number(l[c]),p=Number(l[u]),f=Number(l[s]);if(p<=0||p>12||d>(2===p&&f%4==0?29:[31,28,31,30,31,30,31,31,30,31,30,31][p-1])||d<=0||f<1753)return t[1]}return t[2]}(e,o,r)}},function(e,t,n){"use strict";n.r(t);var r={},o=[],i=function(e){return null==e?e:e.key},a=function(e){this.tag[e.type](e)},c=function(e,t,n,r,o){"key"===t||("o"===t[0]&&"n"===t[1]?((e.tag||(e.tag={}))[t=t.slice(2)]=r)?n||e.addEventListener(t,a):e.removeEventListener(t,a):!o&&"list"!==t&&"form"!==t&&t in e?e[t]=null==r?"":r:null==r||!1===r?e.removeAttribute(t):e.setAttribute(t,r))},u=function e(t,n){var r=t.props,o=3===t.tag?document.createTextNode(t.type):(n=n||"svg"===t.type)?document.createElementNS("http://www.w3.org/2000/svg",t.type,{is:r.is}):document.createElement(t.type,{is:r.is});for(var i in r)c(o,i,null,r[i],n);return t.children.map(function(t){return o.appendChild(e(t=s(t),n))}),t.dom=o},s=function(e){return!0!==e&&!1!==e&&e?e:d("")},l=function(e,t,n,r,o,i){return{type:e,props:t,children:n,dom:r,key:o,tag:i}},d=function(e,t){return l(e,r,o,t,null,3)},p=function(e,t,n){return l(e,t,Array.isArray(n)?n:null==n?o:[n],null,t.key)},f=n(1);function b(e){return e<10?"0"+e.toString():e.toString()}function y(e){return"".concat(e.state.dob.year,"-").concat(b(e.state.dob.month),"-").concat(b(e.state.dob.day))}function h(e,t,n){n.state.dob[e]=t,function(e){!function(e){e.state.current_page=e.state.current_page+1}(e),function(e){e.state.show_alerts=null}(e),function(e){3===e.state.current_page&&e.options.enable_built_in_validation&&(!f(y(e),"boolean","yyyy-mm-dd")||new Date(y(e))>new Date)&&function(e,t){e.state.show_alerts="invalid_date_alert",e.resetProcess()}(e)}(e),function(e){if(3!==e.state.current_page||null!==e.state.show_alerts)return e;var t=e.options.dateFormat?e.options.dateFormat(y(e)):y(e);e.state.selected_date=t,e.datepickerTargetNode.value=t,e.hideDatepicker()}(e)}(n)}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function g(e){return p("div",{class:"top-arrow ".concat("popup"===e.options.display_mode?"top-arrow--popup":"")})}function m(e){return 0===e.state.current_page?function(e){return p("div",{class:"dob-datepicker__month",tabindex:"0"},e.options[e.options.show_long_month?"long_month":"short_month"].map(function(t,n){return p("button",{key:n+1,value:n+1,class:"dob-datepicker__month__button",onclick:function(){h("month",n+1,e),e.renderDatepicker()}},d(t))}))}(e):1===e.state.current_page?function(e){return p("div",{class:"dob-datepicker__day",tabindex:"0"},function(e){return function(e){if(Array.isArray(e))return v(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return v(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(Array(2===e.state.dob.month?30:32).keys()).map(function(t,n){return 0===t?null:p("button",{key:n,value:n,class:"dob-datepicker__day__button",onclick:function(){h("day",n,e),e.renderDatepicker()}},[d(t),e.options.enable_ordinal_number?p("sup",{class:"dob-datepicker__day__ordinal-number"},D(n)):null])}))}(e):function(e){return p("div",{class:"dob-datepicker__year",tabindex:"0"},function(e){for(var t=(new Date).getFullYear(),n=[],r=[],o=[],i=function(i){r.length<20&&(o.push(i),r.push(p("button",{key:i,value:i,class:"dob-datepicker__year__button",onclick:function(){h("year",i,e),e.renderDatepicker()}},[p("span",{class:"dob-datepicker__year__button__first"},d(i.toString().substring(0,2))),p("span",{class:"dob-datepicker__year__button__last"},d(i.toString().substring(2)))])),20===r.length&&(n.push(N(e,r,o[0],o[o.length-1])),r=[],o=[]),i===t-e.options.year_range&&n.push(N(e,r,o[0],o[o.length-1])))},a=t;a>=t-e.options.year_range;a--)i(a);return n}(e))}(e)}function _(e){return p("div",{class:"dob-datepicker__alert"},d(e.options.alerts[e.state.show_alerts]))}function k(e){return p("div",{class:"dob-datepicker__header"},d(e.options.labels.header_label))}function O(e){return p("div",{class:"dob-datepicker__selection-header"},function(e){return 0===e.state.current_page?d(e.options.labels.select_month_label):1===e.state.current_page?d(e.options.labels.select_day_label):d(e.options.labels.select_year_label)}(e))}function w(e){return p("button",{class:"dob-datepicker__reset"},[p("div",{class:"dob-datepicker__reset-text",onclick:function(){e.resetProcess()}},d(e.options.labels.reset_button_label))])}function D(e){switch(!0){case 1===e||21===e||31===e:return d("st");case 2===e||22===e:return d("nd");case 23===e||23===e:return d("rd");default:return d("th")}}function N(e,t,n,r){return p("div",{class:"dob-datepicker__year__year-section"},[p("div",{class:"dob-datepicker__year__year-section-header"},d("".concat(e.options.labels.date_range_label).concat(r," - ").concat(n))),p("div",{class:"dob-datepicker__year__wrapper"},t),p("div",{class:"dob-datepicker__year__year-section-next"},d("⌄"))])}var j,T=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details"],P=T.join(","),E="undefined"==typeof Element?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,S=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return isNaN(t)?function(e){return"true"===e.contentEditable}(e)?0:"AUDIO"!==e.nodeName&&"VIDEO"!==e.nodeName&&"DETAILS"!==e.nodeName||null!==e.getAttribute("tabindex")?e.tabIndex:0:t},x=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},C=function(e){return"INPUT"===e.tagName},F=function(e){return!(e.disabled||function(e){return C(e)&&"hidden"===e.type}(e)||function(e){if("hidden"===getComputedStyle(e).visibility)return!0;var t=E.call(e,"details>summary:first-of-type")?e.parentElement:e;if(E.call(t,"details:not([open]) *"))return!0;for(;e;){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(e){return"SUMMARY"===e.tagName})}(e))},A=function(e){return!(!F(e)||function(e){return function(e){return C(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}((e.form||e.ownerDocument).querySelectorAll('input[type="radio"][name="'+e.name+'"]'),e.form);return!t||t===e}(e)}(e)||S(e)<0)},I=T.concat("iframe").join(","),L=function(e){if(!e)throw new Error("No node provided");return!1!==E.call(e,I)&&F(e)};function M(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function B(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}var W,R=(W=[],{activateTrap:function(e){if(W.length>0){var t=W[W.length-1];t!==e&&t.pause()}var n=W.indexOf(e);-1===n||W.splice(n,1),W.push(e)},deactivateTrap:function(e){var t=W.indexOf(e);-1!==t&&W.splice(t,1),W.length>0&&W[W.length-1].unpause()}}),G=function(e){return setTimeout(e,0)},q=function(e,t){var n,r=document,o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?B(Object(n),!0).forEach(function(t){M(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):B(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},t),i={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},a=function(e){return i.containers.some(function(t){return t.contains(e)})},c=function(e){var t=o[e];if(!t)return null;var n=t;if("string"==typeof t&&!(n=r.querySelector(t)))throw new Error("`".concat(e,"` refers to no known node"));if("function"==typeof t&&!(n=t()))throw new Error("`".concat(e,"` did not return a node"));return n},u=function(){var e;if(null!==c("initialFocus"))e=c("initialFocus");else if(a(r.activeElement))e=r.activeElement;else{var t=i.tabbableGroups[0];e=t&&t.firstTabbableNode||c("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},s=function(){i.tabbableGroups=i.containers.map(function(e){var t,n,r,o=(n=[],r=[],function(e,t,n){var r=Array.prototype.slice.apply(e.querySelectorAll(P));return t&&E.call(e,P)&&r.unshift(e),r.filter(n)}(e,(t=t||{}).includeContainer,A).forEach(function(e,t){var o=S(e);0===o?n.push(e):r.push({documentOrder:t,tabIndex:o,node:e})}),r.sort(x).map(function(e){return e.node}).concat(n));return{firstTabbableNode:o[0],lastTabbableNode:o[o.length-1]}})},l=function e(t){t!==r.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!o.preventScroll}),i.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(u()))},d=function(e){a(e.target)||(o.clickOutsideDeactivates?n.deactivate({returnFocus:o.returnFocusOnDeactivate&&!L(e.target)}):o.allowOutsideClick&&("boolean"==typeof o.allowOutsideClick?o.allowOutsideClick:o.allowOutsideClick(e))||e.preventDefault())},p=function(e){a(e.target)||e.target instanceof Document||(e.stopImmediatePropagation(),l(i.mostRecentlyFocusedNode||u()))},f=function(e){if(!1!==o.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void n.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){s();var t=null;if(e.shiftKey){var n=i.tabbableGroups.findIndex(function(t){var n=t.firstTabbableNode;return e.target===n});if(n>=0){var r=0===n?i.tabbableGroups.length-1:n-1;t=i.tabbableGroups[r].lastTabbableNode}}else{var o=i.tabbableGroups.findIndex(function(t){var n=t.lastTabbableNode;return e.target===n});if(o>=0){var a=o===i.tabbableGroups.length-1?0:o+1;t=i.tabbableGroups[a].firstTabbableNode}}t&&(e.preventDefault(),l(t))}(e)},b=function(e){o.clickOutsideDeactivates||a(e.target)||o.allowOutsideClick&&("boolean"==typeof o.allowOutsideClick?o.allowOutsideClick:o.allowOutsideClick(e))||(e.preventDefault(),e.stopImmediatePropagation())},y=function(){if(i.active)return R.activateTrap(n),j=o.delayInitialFocus?G(function(){l(u())}):l(u()),r.addEventListener("focusin",p,!0),r.addEventListener("mousedown",d,{capture:!0,passive:!1}),r.addEventListener("touchstart",d,{capture:!0,passive:!1}),r.addEventListener("click",b,{capture:!0,passive:!1}),r.addEventListener("keydown",f,{capture:!0,passive:!1}),n},h=function(){if(i.active)return r.removeEventListener("focusin",p,!0),r.removeEventListener("mousedown",d,!0),r.removeEventListener("touchstart",d,!0),r.removeEventListener("click",b,!0),r.removeEventListener("keydown",f,!0),n};return(n={activate:function(e){if(i.active)return this;s(),i.active=!0,i.paused=!1,i.nodeFocusedBeforeActivation=r.activeElement;var t=e&&e.onActivate?e.onActivate:o.onActivate;return t&&t(),y(),this},deactivate:function(e){if(!i.active)return this;clearTimeout(j),h(),i.active=!1,i.paused=!1,R.deactivateTrap(n);var t=e&&void 0!==e.onDeactivate?e.onDeactivate:o.onDeactivate;return t&&t(),(e&&void 0!==e.returnFocus?e.returnFocus:o.returnFocusOnDeactivate)&&G(function(){var e;l((e=i.nodeFocusedBeforeActivation,c("setReturnFocus")||e))}),this},pause:function(){return i.paused||!i.active||(i.paused=!0,h()),this},unpause:function(){return i.paused&&i.active?(i.paused=!1,s(),y(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return i.containers=t.map(function(e){return"string"==typeof e?r.querySelector(e):e}),i.active&&s(),this}}).updateContainerElements(e),n};function J(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?J(Object(n),!0).forEach(function(t){z(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):J(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var V=0,K={display_mode:"inline",year_range:120,enable_built_in_validation:!0,enable_ordinal_number:!0,show_long_month:!0,dateFormat:null,zIndex:{targetNode:"150",datepickerWidget:"150",invisibleBackground:"100"},long_month:["January","February","March","April","May","June","July","August","September","October","November","December"],short_month:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],labels:{header_label:"When is your birthday?",select_day_label:"Select day",select_month_label:"Select month",select_year_label:"Select year",reset_button_label:"Reset and try again",date_range_label:"Year "},alerts:{invalid_date_alert:"Date is invalid"}},Y={getDatepickerWidgetNode:function(){return this.datepickerWidgetNode?this.datepickerWidgetNode:this.setDatepickerWidgetNode()},setDatepickerWidgetNode:function(){return this.datepickerWidgetNode=document.getElementById("datepicker-widget__".concat(this.instance_id))},getDatepickerTargetNode:function(){return this.datepickerTargetNode?this.datepickerTargetNode:this.setDatepickerTargetNode()},setDatepickerTargetNode:function(){return this.datepickerTargetNode=this.selector instanceof Element?this.selector:document.querySelector(this.getSelector())},getDatepickerTargetParentNode:function(){return this.datepickerTargetParentNode?this.datepickerTargetParentNode:this.setDatepickerTargetParentNode()},setDatepickerTargetParentNode:function(){return this.datepickerTargetParentNode=this.selector instanceof Element?this.selector.parentElement:document.querySelector(this.getSelector()).parentElement},getdatepickerContainerNode:function(){return this.datepickerContainerNode?this.datepickerContainerNode:this.setDatepickerContainerNode()},setDatepickerContainerNode:function(){var e=document.createElement("div");return e.style.setProperty("position","absolute"),this.datepickerContainerNode=e},getSelector:function(){return this.selector},setSelector:function(e){return this.selector=e,this},getFocusTrap:function(){return this.focusTrap?this.focusTrap:this.setFocusTrap()},setFocusTrap:function(){return this.focusTrap=q(this.getDatepickerWidgetNode(),{clickOutsideDeactivates:!0,returnFocusOnDeactivate:!1})},registerUserOptions:function(e){return Object.assign(this.options,e),this},resetProcess:function(){return this.state.dob.day=null,this.state.dob.month=null,this.state.dob.year=null,this.state.current_page=0,this.renderDatepicker(this),this},showDatepicker:function(){return this.state.show_datepicker=!0,this.resetProcess(),this},hideDatepicker:function(){return this.state.show_datepicker=!1,this.renderDatepicker(this),this},attachListenerToTargetNode:function(){var e=this;return this.getDatepickerTargetNode().addEventListener("focus",function(){e.showDatepicker()}),document.addEventListener("keydown",function(t){"Escape"===t.key&&e.hideDatepicker()}),this},attachDatepickerContainerToDOM:function(){var e=this.getdatepickerContainerNode();return this.getDatepickerTargetParentNode().style.setProperty("position","relative"),this.getDatepickerTargetParentNode().appendChild(e),this},adjustDatepickerPosition:function(){var e=this.getDatepickerWidgetNode().getBoundingClientRect(),t=this.getDatepickerTargetParentNode().getBoundingClientRect(),n=this.getDatepickerTargetNode().getBoundingClientRect(),r=t.height-(t.bottom-n.bottom),o=n.left-t.left+(n.width/2-e.width/2);return this.getdatepickerContainerNode().style.top="".concat(r+12,"px"),this.getdatepickerContainerNode().style.left="".concat(o,"px"),this},renderDatepicker:function(){return this.getFocusTrap().deactivate(),function(e,t){(e=function e(t,n,r,o,a){if(r===o);else if(null!=r&&3===r.tag&&3===o.tag)r.type!==o.type&&(n.nodeValue=o.type);else if(null==r||r.type!==o.type)n=t.insertBefore(u(o=s(o),a),n),null!=r&&t.removeChild(r.dom);else{var l,d,p,f,b=r.props,y=o.props,h=r.children,v=o.children,g=0,m=0,_=h.length-1,k=v.length-1;for(var O in a=a||"svg"===o.type,_objectSpread(_objectSpread({},b),y))("value"===O||"selected"===O||"checked"===O?n[O]:b[O])!==y[O]&&c(n,O,b[O],y[O],a);for(;m<=k&&g<=_&&null!=(p=i(h[g]))&&p===i(v[m]);)e(n,h[g].dom,h[g++],v[m]=s(v[m++]),a);for(;m<=k&&g<=_&&null!=(p=i(h[_]))&&p===i(v[k]);)e(n,h[_].dom,h[_--],v[k]=s(v[k--]),a);if(g>_)for(;m<=k;)n.insertBefore(u(v[m]=s(v[m++]),a),(d=h[g])&&d.dom);else if(m>k)for(;g<=_;)n.removeChild(h[g++].dom);else{var w={},D={};for(O=g;O<=_;O++)null!=(p=h[O].key)&&(w[p]=h[O]);for(;m<=k;)p=i(d=h[g]),f=i(v[m]=s(v[m])),D[p]||null!=f&&f===i(h[g+1])?(null==p&&n.removeChild(d.dom),g++):null==f||1===r.tag?(null==p&&(e(n,d&&d.dom,d,v[m],a),m++),g++):(p===f?(e(n,d.dom,d,v[m],a),D[f]=!0,g++):null!=(l=w[f])?(e(n,n.insertBefore(l.dom,d&&d.dom),l,v[m],a),D[f]=!0):e(n,d&&d.dom,null,v[m],a),m++);for(;g<=_;)null==i(d=h[g++])&&n.removeChild(d.dom);for(var O in w)null==D[O]&&n.removeChild(w[O].dom)}}return o.dom=n}(e.parentNode,e,e.v||function e(t){return 3===t.nodeType?d(t.nodeValue,t):l(t.nodeName.toLowerCase(),r,o.map.call(t.childNodes,e),t,null,1)}(e),t)).v=t}(this.getdatepickerContainerNode(),p("div",{class:"dob-datepicker__wrapper ".concat((e=this).state.show_datepicker?"":"dob-datepicker__wrapper--hide"," ")},[p("div",{class:"dob-datepicker__background ".concat("popup"===e.options.display_mode?"dob-datepicker__background--popup":""),style:"z-index: ".concat(e.options.zIndex.invisibleBackground),onclick:function(){e.hideDatepicker()}}),p("div",{id:"datepicker-widget__".concat(e.instance_id),class:"dob-datepicker ".concat("popup"===e.options.display_mode?"dob-datepicker--popup":""),style:"z-index: ".concat(e.options.zIndex.datepickerWidget)},[g(e),k(e),e.state.show_alerts?_(e):p("div",{}),O(e),p("div",{class:"dob-datepicker__options"},m(e)),e.state.current_page>0?w(e):p("div",{})])])),this.adjustDatepickerPosition(),this.state.show_datepicker&&this.getFocusTrap().activate(),this;var e},init:function(e,t){this.setSelector(e).registerUserOptions(t).attachDatepickerContainerToDOM().renderDatepicker().attachListenerToTargetNode().adjustDatepickerPosition().setFocusTrap()}};t.default=function(e,t){var n=Object.create(Y),r={instance_id:V++,state:{selected_date:null,show_datepicker:!1,show_alerts:null,current_page:0,dob:{day:null,month:null,year:null}},options:U({},K),selector:null,datepickerWidgetNode:null,datepickerContainerNode:null,datepickerTargetNode:null,datepickerTargetParentNode:null,focusTrap:null},o=Object.assign(n,r);return o.init(e,t),o}}]).default}); |
{ | ||
"name": "date-of-birth-js", | ||
"version": "1.0.6", | ||
"version": "2.0.0", | ||
"description": "A datepicker specific for date of birth", | ||
@@ -5,0 +5,0 @@ "main": "dist/js/index.js", |
@@ -37,3 +37,3 @@ import { patch } from 'superfine' | ||
// function factory of datepicker | ||
function dobDatepicker() { | ||
function dobDatepicker(selector, options) { | ||
@@ -65,3 +65,6 @@ const datepickerPrototype = Object.create(datepickerMethods) | ||
return Object.assign(datepickerPrototype, datepickerData) | ||
const datepickerInstance = Object.assign(datepickerPrototype, datepickerData) | ||
datepickerInstance.init(selector, options) | ||
return datepickerInstance | ||
} | ||
@@ -68,0 +71,0 @@ |
79425
556