@hammerstone/refine-stimulus
Advanced tools
Comparing version 2.6.14 to 2.6.15
@@ -1,2 +0,2 @@ | ||
import{Controller as e}from"@hotwired/stimulus";import{FetchRequest as t}from"@rails/request.js";import{delegate as r,abnegate as i}from"jquery-events-to-dom-events";import{isEqual as n,debounce as o}from"lodash";import l from"flatpickr";import s from"moment";import{english as a}from"flatpickr/dist/l10n/default.js";import{Spanish as d}from"flatpickr/dist/l10n/es.js";import{Portuguese as u}from"flatpickr/dist/l10n/pt.js";function c(e){const t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class h extends e{connect(){this.state.finishUpdate()}get state(){let e=this.element;for(;e!==document.body;){if(e.matches('[data-controller~="refine--state"]'))return this.application.getControllerForElementAndIdentifier(e,"refine--state");e=e.parentNode}return null}refreshFromServer(e){void 0===e&&(e={});try{const r=this,{includeErrors:i}=e;r.state.startUpdate();const n=new t("GET",r.state.refreshUrlValue,{responseKind:"turbo-stream",query:{"hammerstone_refine_filters_builder[filter_class]":r.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(r.state.blueprint),"hammerstone_refine_filters_builder[client_id]":r.state.clientIdValue,include_errors:!!i}});return Promise.resolve(n.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class m extends h{criterion(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addCriterion(e.previousCriterionIdValue),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}group(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addGroup(),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}validateBlueprint(e){try{const e=this,r=new t("GET",e.state.validateBlueprintUrlValue,{query:{"hammerstone_refine_filters_builder[filter_class]":e.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(e.state.blueprint),"hammerstone_refine_filters_builder[client_id]":e.state.clientIdValue}});return Promise.resolve(r.perform()).then(function(e){return e.ok})}catch(e){return Promise.reject(e)}}}m.values={previousCriterionId:Number};class f extends e{refresh(e){const t=new FormData(this.element),r=new URL(this.urlValue);for(const[e,i]of t.entries())console.log(e,i),r.searchParams.set(e,i);window.Turbo.visit(r.toString(),{frame:this.turboFrameValue})}}f.values={url:String,turboFrame:String};class p extends e{connect(){this.state=this.getStateController(),this.state.updateInput(this.criterionIdValue,this.inputValue)}getStateController(){let e=this.element;for(;e!==document.body;){const t=this.application.getControllerForElementAndIdentifier(e,"refine--state");if(t)return t;e=e.parentNode}return null}}p.values={criterionId:Number,input:Object};class g extends h{criterion(){const{state:e,criterionIdValue:t}=this;e.deleteCriterion(t),this.refreshFromServer()}}g.values={criterionId:Number};class b extends e{connect(){const e=new URLSearchParams(window.location.search);this.existingParams=e,this.existingParams.delete("stable_id")}delete(e){const{criterionId:t}=e.currentTarget.dataset;var r=parseInt(t);this.stateController.deleteCriterion(r),this.reloadPage()}reloadPage(){try{const e=this,{blueprint:r}=e.stateController,i=new t("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(r),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}redirectToStableId(e){const t=new URLSearchParams;e&&t.append("stable_id",e);const r=new URLSearchParams({...Object.fromEntries(this.existingParams),...Object.fromEntries(t)}).toString(),i=window.location.pathname+"?"+r;history.pushState({},document.title,i),window.location.reload()}get stateController(){return this.element.refineStateController}get stabilizeFilterController(){return this.element.stabilizeFilterController}}b.values={submitUrl:String};class v extends e{show(e){this.frameTarget.src=this.srcValue}hide(e){this.frameTarget.innerHTML=""}}v.targets=["frame"],v.values={src:String};class C extends e{search(e){e.preventDefault(),this.submitFilter(),document.activeElement.blur()}submitFilter(){try{const e=this,{blueprint:r}=e.stateController,i=new t("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(r),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}get stateController(){return this.element.querySelector('[data-controller~="refine--state"]').refineStateController}loadResults(e){let{detail:{url:t}}=e;console.log("filter submit success"),window.Turbo?window.Turbo.visit(t):window.location.href=t}}C.values={submitUrl:String},function(){if("function"==typeof window.CustomEvent)return!1;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),r}e.prototype=window.Event.prototype,window.CustomEvent=e}();const w=(e,t)=>{let{blueprint:r,formId:i}=t;const n=new CustomEvent("blueprint-updated",{bubbles:!0,cancelable:!0,detail:{blueprint:r,formId:i}});e.dispatchEvent(n)},I=(e,t,r)=>{var i;const n=null==r?void 0:r.component,o=(null==r?void 0:r.meta)||{clauses:[],options:{}},l=(null==r?void 0:r.refinements)||[],{clauses:s,options:a}=o;let d;d="option-condition"===n?a[0]?[a[0].id]:[]:void 0;let u={clause:null==(i=s[0])?void 0:i.id,selected:d};return l.forEach(e=>{const{meta:t,component:r}=e,{clauses:i,options:n}=t;let o;o="option-condition"===r?n[0]?[n[0].id]:[]:void 0,u[e.id]={clause:i[0].id,selected:o}}),{depth:t,type:"criterion",condition_id:e,input:u}};class S extends e{connect(){this.element.refineStateController=this,this.changeDelegate=r("change",["event","picker"]),this.blueprint=this.blueprintValue,this.conditions=this.conditionsValue,this.filterName=this.classNameValue,this.conditionsLookup=this.conditions.reduce((e,t)=>(e[t.id]=t,e),{}),this.loadingTimeout=null,w(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}disconnect(){i("change",this.changeDelegate)}startUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTimeout=window.setTimeout(()=>{this.loadingTarget.classList.remove("hidden")},1e3)}finishUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTarget.classList.add("hidden")}conditionConfigFor(e){return this.conditionsLookup[e]}addGroup(){const{conditions:e}=this,t=e.find(e=>e.id==this.defaultConditionIdValue)||e[0];var r;this.blueprint.length>0&&this.blueprint.push({depth:r=void 0===r?0:r,type:"conjunction",word:"or"}),this.blueprint.push(I(t.id,1,t)),w(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}addCriterion(e){const{blueprint:t,conditions:r}=this,i=r.find(e=>e.id==this.defaultConditionIdValue)||r[0];var n;t.splice(e+1,0,{depth:n=void 0===n?1:n,type:"conjunction",word:"and"},I(i.id,1,i)),w(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}deleteCriterion(e){const{blueprint:t}=this,r=t[e-1],i=t[e+1],n=r&&"or"===r.word,o=i&&"or"===i.word||!i,l=n||!r,s=l&&o;r||i?t.splice(s&&n?e-1:s&&!r||l&&!o?e:e-1,2):this.blueprint=[],w(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}replaceCriterion(e,t,r){const i=this.blueprint[e];if("criterion"!==i.type)throw new Error("You can't call updateConditionId on a non-criterion type. Trying to update "+JSON.stringify(I));const o=this.blueprint[e],l=I(t,i.depth,r);return!n(o,l)&&(this.blueprint[e]=l,w(this.element,{blueprint:this.blueprint,formId:this.formIdValue}),!0)}updateInput(e,t,r){const{blueprint:i}=this,n=i[e],o=(r=r||"input").split(", ");o.length>1?n[o[0]][o[1]]={...n[o[0]][o[1]],...t}:n[r]={...n[r],...t},w(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}}S.values={blueprint:Array,conditions:Array,className:String,refreshUrl:String,clientId:String,validateBlueprintUrl:String,defaultConditionId:String},S.targets=["loading"];class y extends e{connect(){const e=document.getElementById(this.stateDomIdValue).refineStateController;this.blueprintFieldTarget.value=JSON.stringify(e.blueprint),console.log("connect",this.blueprintFieldTarget.value)}updateBlueprintField(e){if(e.detail.formId!=this.formIdValue)return null;const{detail:t}=e,{blueprint:r}=t;this.blueprintFieldTarget.value=JSON.stringify(r),console.log("update blueprint",this.blueprintFieldTarget.value)}}y.targets=["blueprintField"],y.values={formId:String,stateDomId:String};class _ extends e{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}_.targets=["content"];class F extends h{initialize(){this.updateBlueprint=o((e,t,r)=>{this.value(e,t,r)},500)}refinedFilter(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{id:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}clause(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{clause:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}selected(e){const{target:t}=e,r=Array.prototype.slice.call(t.options).filter(e=>e.selected).map(e=>e.value);this.value(e,r,"selected")}value(e,t,r){const{criterionIdValue:i,state:n}=this,o=e.target.dataset;n.updateInput(i,{[r=r||o.inputKey||"value"]:t=t||e.target.value},o.inputId)}condition(e){const{criterionIdValue:t,state:r}=this,i=e.target;let n=i.value;n||(n=i.querySelector("select").value);const o=this.state.conditionConfigFor(n);r.replaceCriterion(t,n,o)&&this.refreshFromServer()}cancelEnter(e){"Enter"===e.code&&(e.preventDefault(),e.stopPropagation())}}F.values={criterionId:Number},require("flatpickr/dist/flatpickr.css");const V={en:a,es:d,pt:u};class T extends e{connect(){var e;null!=(e=window.HammerstoneRefine)&&e.datePicker?window.HammerstoneRefine.datePicker.connect.bind(this)():this.defaultConnect()}disconnect(){var e;null!=(e=window.HammerstoneRefine)&&e.datePicker?window.HammerstoneRefine.datePicker.disconnect.bind(this)():this.defaultDisconnect()}defaultConnect(){var e;const t=(null==(e=this.localeValue)?void 0:e.slice(0,2))||"en";this.plugin=l(this.fieldTarget,{minDate:this.futureOnlyValue?new Date:null,dateFormat:"YYYY-MM-DD",locale:V[t],defaultDate:this.hiddenFieldTarget.value,parseDate:(e,t)=>s(e,t,!0).toDate(),formatDate:(e,t)=>s(e).format(t),onChange:(e,t,r)=>{this.fieldTarget.value=r.formatDate(e[0],this.includeTimeValue?this.datetimeFormatValue:this.dateFormatValue),this.hiddenFieldTarget.value=r.formatDate(e[0],"YYYY-MM-DD"),this.hiddenFieldTarget.dispatchEvent(new Event("change",{bubbles:!0}))},onReady:[()=>{const e=s(this.hiddenFieldTarget.value);e.isValid()&&(this.fieldTarget.value=e.format(this.includeTimeValue?this.datetimeFormatValue:this.dateFormatValue))}]})}defaultDisconnect(){this.plugin.destroy()}}T.targets=["field","hiddenField"],T.values={locale:{type:String,default:"en"},dateFormat:{type:String,default:"MM/DD/YYYY"},datetimeFormat:{type:String,default:"MM/DD/YYYY h:mm A"}};const j=[[m,"refine/add-controller.js"],[f,"refine/condition-form-controller.js"],[p,"refine/defaults-controller.js"],[g,"refine/delete-controller.js"],[b,"refine/filter-pills-controller.js"],[v,"refine/popup-controller.js"],[C,"refine/search-filter-controller.js"],[h,"refine/server-refresh-controller.js"],[S,"refine/state-controller.js"],[y,"refine/stored-filter-controller.js"],[_,"refine/toggle-controller.js"],[F,"refine/update-controller.js"],[T,"refine/date-controller.js"]].map(function(e){const t=e[0];return{identifier:c(e[1]),controllerConstructor:t}});export{m as AddController,f as ConditionFormController,T as DateController,p as DefaultsController,g as DeleteController,b as FilterPillsController,v as PopupController,C as SearchFilterController,h as ServerRefreshController,S as StateController,y as StoredFilterController,_ as ToggleController,F as UpdateController,j as controllerDefinitions}; | ||
import{Controller as e}from"@hotwired/stimulus";import{FetchRequest as t}from"@rails/request.js";import{delegate as r,abnegate as i}from"jquery-events-to-dom-events";import{isEqual as n,debounce as l}from"lodash";import o from"moment";import s from"jquery";import"daterangepicker";function a(e){const t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class d extends e{connect(){this.state.finishUpdate()}get state(){let e=this.element;for(;e!==document.body;){if(e.matches('[data-controller~="refine--state"]'))return this.application.getControllerForElementAndIdentifier(e,"refine--state");e=e.parentNode}return null}refreshFromServer(e){void 0===e&&(e={});try{const r=this,{includeErrors:i}=e;r.state.startUpdate();const n=new t("GET",r.state.refreshUrlValue,{responseKind:"turbo-stream",query:{"hammerstone_refine_filters_builder[filter_class]":r.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(r.state.blueprint),"hammerstone_refine_filters_builder[client_id]":r.state.clientIdValue,include_errors:!!i}});return Promise.resolve(n.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class u extends d{criterion(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addCriterion(e.previousCriterionIdValue),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}group(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addGroup(),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}validateBlueprint(e){try{const e=this,r=new t("GET",e.state.validateBlueprintUrlValue,{query:{"hammerstone_refine_filters_builder[filter_class]":e.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(e.state.blueprint),"hammerstone_refine_filters_builder[client_id]":e.state.clientIdValue}});return Promise.resolve(r.perform()).then(function(e){return e.ok})}catch(e){return Promise.reject(e)}}}u.values={previousCriterionId:Number};class c extends e{refresh(e){const t=new FormData(this.element),r=new URL(this.urlValue);for(const[e,i]of t.entries())console.log(e,i),r.searchParams.set(e,i);window.Turbo.visit(r.toString(),{frame:this.turboFrameValue})}}c.values={url:String,turboFrame:String};class h extends e{connect(){this.state=this.getStateController(),this.state.updateInput(this.criterionIdValue,this.inputValue)}getStateController(){let e=this.element;for(;e!==document.body;){const t=this.application.getControllerForElementAndIdentifier(e,"refine--state");if(t)return t;e=e.parentNode}return null}}h.values={criterionId:Number,input:Object};class p extends d{criterion(){const{state:e,criterionIdValue:t}=this;e.deleteCriterion(t),this.refreshFromServer()}}p.values={criterionId:Number};class m extends e{connect(){const e=new URLSearchParams(window.location.search);this.existingParams=e,this.existingParams.delete("stable_id")}delete(e){const{criterionId:t}=e.currentTarget.dataset;var r=parseInt(t);this.stateController.deleteCriterion(r),this.reloadPage()}reloadPage(){try{const e=this,{blueprint:r}=e.stateController,i=new t("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(r),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}redirectToStableId(e){const t=new URLSearchParams;e&&t.append("stable_id",e);const r=new URLSearchParams({...Object.fromEntries(this.existingParams),...Object.fromEntries(t)}).toString(),i=window.location.pathname+"?"+r;history.pushState({},document.title,i),window.location.reload()}get stateController(){return this.element.refineStateController}get stabilizeFilterController(){return this.element.stabilizeFilterController}}m.values={submitUrl:String};class f extends e{show(e){this.frameTarget.src=this.srcValue}hide(e){this.frameTarget.innerHTML=""}}f.targets=["frame"],f.values={src:String};class g extends e{search(e){e.preventDefault(),this.submitFilter(),document.activeElement.blur()}submitFilter(){try{const e=this,{blueprint:r}=e.stateController,i=new t("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(r),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}get stateController(){return this.element.querySelector('[data-controller~="refine--state"]').refineStateController}loadResults(e){let{detail:{url:t}}=e;console.log("filter submit success"),window.Turbo?window.Turbo.visit(t):window.location.href=t}}g.values={submitUrl:String},function(){if("function"==typeof window.CustomEvent)return!1;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),r}e.prototype=window.Event.prototype,window.CustomEvent=e}();const b=(e,t)=>{let{blueprint:r,formId:i}=t;const n=new CustomEvent("blueprint-updated",{bubbles:!0,cancelable:!0,detail:{blueprint:r,formId:i}});e.dispatchEvent(n)},v=(e,t,r)=>{var i;const n=null==r?void 0:r.component,l=(null==r?void 0:r.meta)||{clauses:[],options:{}},o=(null==r?void 0:r.refinements)||[],{clauses:s,options:a}=l;let d;d="option-condition"===n?a[0]?[a[0].id]:[]:void 0;let u={clause:null==(i=s[0])?void 0:i.id,selected:d};return o.forEach(e=>{const{meta:t,component:r}=e,{clauses:i,options:n}=t;let l;l="option-condition"===r?n[0]?[n[0].id]:[]:void 0,u[e.id]={clause:i[0].id,selected:l}}),{depth:t,type:"criterion",condition_id:e,input:u}};class w extends e{connect(){this.element.refineStateController=this,this.changeDelegate=r("change",["event","picker"]),this.blueprint=this.blueprintValue,this.conditions=this.conditionsValue,this.filterName=this.classNameValue,this.conditionsLookup=this.conditions.reduce((e,t)=>(e[t.id]=t,e),{}),this.loadingTimeout=null,b(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}disconnect(){i("change",this.changeDelegate)}startUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTimeout=window.setTimeout(()=>{this.loadingTarget.classList.remove("hidden")},1e3)}finishUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTarget.classList.add("hidden")}conditionConfigFor(e){return this.conditionsLookup[e]}addGroup(){const{conditions:e}=this,t=e.find(e=>e.id==this.defaultConditionIdValue)||e[0];var r;this.blueprint.length>0&&this.blueprint.push({depth:r=void 0===r?0:r,type:"conjunction",word:"or"}),this.blueprint.push(v(t.id,1,t)),b(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}addCriterion(e){const{blueprint:t,conditions:r}=this,i=r.find(e=>e.id==this.defaultConditionIdValue)||r[0];var n;t.splice(e+1,0,{depth:n=void 0===n?1:n,type:"conjunction",word:"and"},v(i.id,1,i)),b(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}deleteCriterion(e){const{blueprint:t}=this,r=t[e-1],i=t[e+1],n=r&&"or"===r.word,l=i&&"or"===i.word||!i,o=n||!r,s=o&&l;r||i?t.splice(s&&n?e-1:s&&!r||o&&!l?e:e-1,2):this.blueprint=[],b(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}replaceCriterion(e,t,r){const i=this.blueprint[e];if("criterion"!==i.type)throw new Error("You can't call updateConditionId on a non-criterion type. Trying to update "+JSON.stringify(v));const l=this.blueprint[e],o=v(t,i.depth,r);return!n(l,o)&&(this.blueprint[e]=o,b(this.element,{blueprint:this.blueprint,formId:this.formIdValue}),!0)}updateInput(e,t,r){const{blueprint:i}=this,n=i[e],l=(r=r||"input").split(", ");l.length>1?n[l[0]][l[1]]={...n[l[0]][l[1]],...t}:n[r]={...n[r],...t},b(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}}w.values={blueprint:Array,conditions:Array,className:String,refreshUrl:String,clientId:String,validateBlueprintUrl:String,defaultConditionId:String},w.targets=["loading"];class I extends e{connect(){const e=document.getElementById(this.stateDomIdValue).refineStateController;this.blueprintFieldTarget.value=JSON.stringify(e.blueprint),console.log("connect",this.blueprintFieldTarget.value)}updateBlueprintField(e){if(e.detail.formId!=this.formIdValue)return null;const{detail:t}=e,{blueprint:r}=t;this.blueprintFieldTarget.value=JSON.stringify(r),console.log("update blueprint",this.blueprintFieldTarget.value)}}I.targets=["blueprintField"],I.values={formId:String,stateDomId:String};class C extends e{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}C.targets=["content"];class S extends d{initialize(){this.updateBlueprint=l((e,t,r)=>{this.value(e,t,r)},500)}refinedFilter(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{id:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}clause(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{clause:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}selected(e){const{target:t}=e,r=Array.prototype.slice.call(t.options).filter(e=>e.selected).map(e=>e.value);this.value(e,r,"selected")}value(e,t,r){const{criterionIdValue:i,state:n}=this,l=e.target.dataset;n.updateInput(i,{[r=r||l.inputKey||"value"]:t=t||e.target.value},l.inputId)}condition(e){const{criterionIdValue:t,state:r}=this,i=e.target;let n=i.value;n||(n=i.querySelector("select").value);const l=this.state.conditionConfigFor(n);r.replaceCriterion(t,n,l)&&this.refreshFromServer()}cancelEnter(e){"Enter"===e.code&&(e.preventDefault(),e.stopPropagation())}}S.values={criterionId:Number},require("daterangepicker/daterangepicker.css");class y extends e{connect(){this.initPluginInstance()}disconnect(){this.teardownPluginInstance()}clearDate(e){e.preventDefault(),window.$(this.fieldTarget).val(""),this.dispatch("value-cleared")}applyDateToField(e,t){const r=this.includeTimeValue?this.timeFormatValue:this.dateFormatValue,i=t?o(t.startDate.toISOString()):o(this.fieldTarget.value,"YYYY-MM-DDTHH:mm").format("YYYY-MM-DDTHH:mm"),n=i.format(r),l=this.includeTimeValue?i.toISOString(!0):i.format("YYYY-MM-DD");this.fieldTarget.value=n,this.hiddenFieldTarget.value=l,window.$(this.fieldTarget).trigger("change",t),this.hiddenFieldTarget.dispatchEvent(new Event("change",{detail:t,bubbles:!0}))}initPluginInstance(){const e=this.pickerLocaleValue,t=this.isAmPmValue;e.format=this.includeTimeValue?this.timeFormatValue:this.dateFormatValue,window.$(this.fieldTarget).daterangepicker({singleDatePicker:!0,timePicker:this.includeTimeValue,timePickerIncrement:5,autoUpdateInput:!1,autoApply:!0,minDate:!!this.futureOnlyValue&&new Date,locale:e,parentEl:s(this.element),drops:this.dropsValue?this.dropsValue:"down",timePicker24Hour:!t}),window.$(this.fieldTarget).on("apply.daterangepicker",this.applyDateToField.bind(this)),window.$(this.fieldTarget).on("cancel.daterangepicker",this.clearDate.bind(this)),window.$(this.fieldTarget).on("showCalendar.daterangepicker",this.showCalendar.bind(this)),this.pluginMainEl=this.fieldTarget,this.plugin=s(this.pluginMainEl).data("daterangepicker"),this.inlineValue&&this.element.classList.add("date-input--inline")}teardownPluginInstance(){void 0!==this.plugin&&(s(this.pluginMainEl).off("apply.daterangepicker"),s(this.pluginMainEl).off("cancel.daterangepicker"),s(this.pluginMainEl).off("showCalendar.daterangepicker"),this.plugin.remove())}showCalendar(){this.dispatch("show-calendar")}}y.targets=["field","hiddenField","clearButton"],y.values={includeTime:Boolean,futureOnly:Boolean,drops:String,inline:Boolean,dateFormat:String,timeFormat:String,isAmPm:Boolean,locale:{type:String,default:"en"},datetimeFormat:{type:String,default:"MM/DD/YYYY h:mm A"},pickerLocale:{type:Object,default:{}}};const T=[[u,"refine/add-controller.js"],[c,"refine/condition-form-controller.js"],[h,"refine/defaults-controller.js"],[p,"refine/delete-controller.js"],[m,"refine/filter-pills-controller.js"],[f,"refine/popup-controller.js"],[g,"refine/search-filter-controller.js"],[d,"refine/server-refresh-controller.js"],[w,"refine/state-controller.js"],[I,"refine/stored-filter-controller.js"],[C,"refine/toggle-controller.js"],[S,"refine/update-controller.js"],[y,"refine/date-controller.js"]].map(function(e){const t=e[0];return{identifier:a(e[1]),controllerConstructor:t}});export{u as AddController,c as ConditionFormController,y as DateController,h as DefaultsController,p as DeleteController,m as FilterPillsController,f as PopupController,g as SearchFilterController,d as ServerRefreshController,w as StateController,I as StoredFilterController,C as ToggleController,S as UpdateController,T as controllerDefinitions}; | ||
//# sourceMappingURL=refine-stimulus.esm.js.map |
@@ -1,2 +0,2 @@ | ||
var e=require("@hotwired/stimulus"),t=require("@rails/request.js"),r=require("jquery-events-to-dom-events"),i=require("lodash"),n=require("flatpickr"),o=require("moment"),l=require("flatpickr/dist/l10n/default.js"),s=require("flatpickr/dist/l10n/es.js"),a=require("flatpickr/dist/l10n/pt.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=u(n),c=u(o);function h(e){const t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class p extends e.Controller{connect(){this.state.finishUpdate()}get state(){let e=this.element;for(;e!==document.body;){if(e.matches('[data-controller~="refine--state"]'))return this.application.getControllerForElementAndIdentifier(e,"refine--state");e=e.parentNode}return null}refreshFromServer(e){void 0===e&&(e={});try{const r=this,{includeErrors:i}=e;r.state.startUpdate();const n=new t.FetchRequest("GET",r.state.refreshUrlValue,{responseKind:"turbo-stream",query:{"hammerstone_refine_filters_builder[filter_class]":r.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(r.state.blueprint),"hammerstone_refine_filters_builder[client_id]":r.state.clientIdValue,include_errors:!!i}});return Promise.resolve(n.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class f extends p{criterion(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addCriterion(e.previousCriterionIdValue),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}group(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addGroup(),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}validateBlueprint(e){try{const e=this,r=new t.FetchRequest("GET",e.state.validateBlueprintUrlValue,{query:{"hammerstone_refine_filters_builder[filter_class]":e.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(e.state.blueprint),"hammerstone_refine_filters_builder[client_id]":e.state.clientIdValue}});return Promise.resolve(r.perform()).then(function(e){return e.ok})}catch(e){return Promise.reject(e)}}}f.values={previousCriterionId:Number};class m extends e.Controller{refresh(e){const t=new FormData(this.element),r=new URL(this.urlValue);for(const[e,i]of t.entries())console.log(e,i),r.searchParams.set(e,i);window.Turbo.visit(r.toString(),{frame:this.turboFrameValue})}}m.values={url:String,turboFrame:String};class g extends e.Controller{connect(){this.state=this.getStateController(),this.state.updateInput(this.criterionIdValue,this.inputValue)}getStateController(){let e=this.element;for(;e!==document.body;){const t=this.application.getControllerForElementAndIdentifier(e,"refine--state");if(t)return t;e=e.parentNode}return null}}g.values={criterionId:Number,input:Object};class b extends p{criterion(){const{state:e,criterionIdValue:t}=this;e.deleteCriterion(t),this.refreshFromServer()}}b.values={criterionId:Number};class v extends e.Controller{connect(){const e=new URLSearchParams(window.location.search);this.existingParams=e,this.existingParams.delete("stable_id")}delete(e){const{criterionId:t}=e.currentTarget.dataset;var r=parseInt(t);this.stateController.deleteCriterion(r),this.reloadPage()}reloadPage(){try{const e=this,{blueprint:r}=e.stateController,i=new t.FetchRequest("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(r),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}redirectToStableId(e){const t=new URLSearchParams;e&&t.append("stable_id",e);const r=new URLSearchParams({...Object.fromEntries(this.existingParams),...Object.fromEntries(t)}).toString(),i=window.location.pathname+"?"+r;history.pushState({},document.title,i),window.location.reload()}get stateController(){return this.element.refineStateController}get stabilizeFilterController(){return this.element.stabilizeFilterController}}v.values={submitUrl:String};class C extends e.Controller{show(e){this.frameTarget.src=this.srcValue}hide(e){this.frameTarget.innerHTML=""}}C.targets=["frame"],C.values={src:String};class w extends e.Controller{search(e){e.preventDefault(),this.submitFilter(),document.activeElement.blur()}submitFilter(){try{const e=this,{blueprint:r}=e.stateController,i=new t.FetchRequest("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(r),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}get stateController(){return this.element.querySelector('[data-controller~="refine--state"]').refineStateController}loadResults(e){let{detail:{url:t}}=e;console.log("filter submit success"),window.Turbo?window.Turbo.visit(t):window.location.href=t}}w.values={submitUrl:String},function(){if("function"==typeof window.CustomEvent)return!1;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),r}e.prototype=window.Event.prototype,window.CustomEvent=e}();const I=(e,t)=>{let{blueprint:r,formId:i}=t;const n=new CustomEvent("blueprint-updated",{bubbles:!0,cancelable:!0,detail:{blueprint:r,formId:i}});e.dispatchEvent(n)},S=(e,t,r)=>{var i;const n=null==r?void 0:r.component,o=(null==r?void 0:r.meta)||{clauses:[],options:{}},l=(null==r?void 0:r.refinements)||[],{clauses:s,options:a}=o;let u;u="option-condition"===n?a[0]?[a[0].id]:[]:void 0;let d={clause:null==(i=s[0])?void 0:i.id,selected:u};return l.forEach(e=>{const{meta:t,component:r}=e,{clauses:i,options:n}=t;let o;o="option-condition"===r?n[0]?[n[0].id]:[]:void 0,d[e.id]={clause:i[0].id,selected:o}}),{depth:t,type:"criterion",condition_id:e,input:d}};class y extends e.Controller{connect(){this.element.refineStateController=this,this.changeDelegate=r.delegate("change",["event","picker"]),this.blueprint=this.blueprintValue,this.conditions=this.conditionsValue,this.filterName=this.classNameValue,this.conditionsLookup=this.conditions.reduce((e,t)=>(e[t.id]=t,e),{}),this.loadingTimeout=null,I(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}disconnect(){r.abnegate("change",this.changeDelegate)}startUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTimeout=window.setTimeout(()=>{this.loadingTarget.classList.remove("hidden")},1e3)}finishUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTarget.classList.add("hidden")}conditionConfigFor(e){return this.conditionsLookup[e]}addGroup(){const{conditions:e}=this,t=e.find(e=>e.id==this.defaultConditionIdValue)||e[0];var r;this.blueprint.length>0&&this.blueprint.push({depth:r=void 0===r?0:r,type:"conjunction",word:"or"}),this.blueprint.push(S(t.id,1,t)),I(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}addCriterion(e){const{blueprint:t,conditions:r}=this,i=r.find(e=>e.id==this.defaultConditionIdValue)||r[0];var n;t.splice(e+1,0,{depth:n=void 0===n?1:n,type:"conjunction",word:"and"},S(i.id,1,i)),I(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}deleteCriterion(e){const{blueprint:t}=this,r=t[e-1],i=t[e+1],n=r&&"or"===r.word,o=i&&"or"===i.word||!i,l=n||!r,s=l&&o;r||i?t.splice(s&&n?e-1:s&&!r||l&&!o?e:e-1,2):this.blueprint=[],I(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}replaceCriterion(e,t,r){const n=this.blueprint[e];if("criterion"!==n.type)throw new Error("You can't call updateConditionId on a non-criterion type. Trying to update "+JSON.stringify(S));const o=this.blueprint[e],l=S(t,n.depth,r);return!i.isEqual(o,l)&&(this.blueprint[e]=l,I(this.element,{blueprint:this.blueprint,formId:this.formIdValue}),!0)}updateInput(e,t,r){const{blueprint:i}=this,n=i[e],o=(r=r||"input").split(", ");o.length>1?n[o[0]][o[1]]={...n[o[0]][o[1]],...t}:n[r]={...n[r],...t},I(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}}y.values={blueprint:Array,conditions:Array,className:String,refreshUrl:String,clientId:String,validateBlueprintUrl:String,defaultConditionId:String},y.targets=["loading"];class F extends e.Controller{connect(){const e=document.getElementById(this.stateDomIdValue).refineStateController;this.blueprintFieldTarget.value=JSON.stringify(e.blueprint),console.log("connect",this.blueprintFieldTarget.value)}updateBlueprintField(e){if(e.detail.formId!=this.formIdValue)return null;const{detail:t}=e,{blueprint:r}=t;this.blueprintFieldTarget.value=JSON.stringify(r),console.log("update blueprint",this.blueprintFieldTarget.value)}}F.targets=["blueprintField"],F.values={formId:String,stateDomId:String};class _ extends e.Controller{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}_.targets=["content"];class V extends p{initialize(){this.updateBlueprint=i.debounce((e,t,r)=>{this.value(e,t,r)},500)}refinedFilter(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{id:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}clause(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{clause:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}selected(e){const{target:t}=e,r=Array.prototype.slice.call(t.options).filter(e=>e.selected).map(e=>e.value);this.value(e,r,"selected")}value(e,t,r){const{criterionIdValue:i,state:n}=this,o=e.target.dataset;n.updateInput(i,{[r=r||o.inputKey||"value"]:t=t||e.target.value},o.inputId)}condition(e){const{criterionIdValue:t,state:r}=this,i=e.target;let n=i.value;n||(n=i.querySelector("select").value);const o=this.state.conditionConfigFor(n);r.replaceCriterion(t,n,o)&&this.refreshFromServer()}cancelEnter(e){"Enter"===e.code&&(e.preventDefault(),e.stopPropagation())}}V.values={criterionId:Number},require("flatpickr/dist/flatpickr.css");const T={en:l.english,es:s.Spanish,pt:a.Portuguese};class j extends e.Controller{connect(){var e;null!=(e=window.HammerstoneRefine)&&e.datePicker?window.HammerstoneRefine.datePicker.connect.bind(this)():this.defaultConnect()}disconnect(){var e;null!=(e=window.HammerstoneRefine)&&e.datePicker?window.HammerstoneRefine.datePicker.disconnect.bind(this)():this.defaultDisconnect()}defaultConnect(){var e;const t=(null==(e=this.localeValue)?void 0:e.slice(0,2))||"en";this.plugin=d.default(this.fieldTarget,{minDate:this.futureOnlyValue?new Date:null,dateFormat:"YYYY-MM-DD",locale:T[t],defaultDate:this.hiddenFieldTarget.value,parseDate:(e,t)=>c.default(e,t,!0).toDate(),formatDate:(e,t)=>c.default(e).format(t),onChange:(e,t,r)=>{this.fieldTarget.value=r.formatDate(e[0],this.includeTimeValue?this.datetimeFormatValue:this.dateFormatValue),this.hiddenFieldTarget.value=r.formatDate(e[0],"YYYY-MM-DD"),this.hiddenFieldTarget.dispatchEvent(new Event("change",{bubbles:!0}))},onReady:[()=>{const e=c.default(this.hiddenFieldTarget.value);e.isValid()&&(this.fieldTarget.value=e.format(this.includeTimeValue?this.datetimeFormatValue:this.dateFormatValue))}]})}defaultDisconnect(){this.plugin.destroy()}}j.targets=["field","hiddenField"],j.values={locale:{type:String,default:"en"},dateFormat:{type:String,default:"MM/DD/YYYY"},datetimeFormat:{type:String,default:"MM/DD/YYYY h:mm A"}};const P=[[f,"refine/add-controller.js"],[m,"refine/condition-form-controller.js"],[g,"refine/defaults-controller.js"],[b,"refine/delete-controller.js"],[v,"refine/filter-pills-controller.js"],[C,"refine/popup-controller.js"],[w,"refine/search-filter-controller.js"],[p,"refine/server-refresh-controller.js"],[y,"refine/state-controller.js"],[F,"refine/stored-filter-controller.js"],[_,"refine/toggle-controller.js"],[V,"refine/update-controller.js"],[j,"refine/date-controller.js"]].map(function(e){const t=e[0];return{identifier:h(e[1]),controllerConstructor:t}});exports.AddController=f,exports.ConditionFormController=m,exports.DateController=j,exports.DefaultsController=g,exports.DeleteController=b,exports.FilterPillsController=v,exports.PopupController=C,exports.SearchFilterController=w,exports.ServerRefreshController=p,exports.StateController=y,exports.StoredFilterController=F,exports.ToggleController=_,exports.UpdateController=V,exports.controllerDefinitions=P; | ||
var e=require("@hotwired/stimulus"),t=require("@rails/request.js"),r=require("jquery-events-to-dom-events"),i=require("lodash"),n=require("moment"),l=require("jquery");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("daterangepicker");var s=o(n),a=o(l);function u(e){const t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class d extends e.Controller{connect(){this.state.finishUpdate()}get state(){let e=this.element;for(;e!==document.body;){if(e.matches('[data-controller~="refine--state"]'))return this.application.getControllerForElementAndIdentifier(e,"refine--state");e=e.parentNode}return null}refreshFromServer(e){void 0===e&&(e={});try{const r=this,{includeErrors:i}=e;r.state.startUpdate();const n=new t.FetchRequest("GET",r.state.refreshUrlValue,{responseKind:"turbo-stream",query:{"hammerstone_refine_filters_builder[filter_class]":r.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(r.state.blueprint),"hammerstone_refine_filters_builder[client_id]":r.state.clientIdValue,include_errors:!!i}});return Promise.resolve(n.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class c extends d{criterion(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addCriterion(e.previousCriterionIdValue),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}group(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addGroup(),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}validateBlueprint(e){try{const e=this,r=new t.FetchRequest("GET",e.state.validateBlueprintUrlValue,{query:{"hammerstone_refine_filters_builder[filter_class]":e.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(e.state.blueprint),"hammerstone_refine_filters_builder[client_id]":e.state.clientIdValue}});return Promise.resolve(r.perform()).then(function(e){return e.ok})}catch(e){return Promise.reject(e)}}}c.values={previousCriterionId:Number};class h extends e.Controller{refresh(e){const t=new FormData(this.element),r=new URL(this.urlValue);for(const[e,i]of t.entries())console.log(e,i),r.searchParams.set(e,i);window.Turbo.visit(r.toString(),{frame:this.turboFrameValue})}}h.values={url:String,turboFrame:String};class p extends e.Controller{connect(){this.state=this.getStateController(),this.state.updateInput(this.criterionIdValue,this.inputValue)}getStateController(){let e=this.element;for(;e!==document.body;){const t=this.application.getControllerForElementAndIdentifier(e,"refine--state");if(t)return t;e=e.parentNode}return null}}p.values={criterionId:Number,input:Object};class m extends d{criterion(){const{state:e,criterionIdValue:t}=this;e.deleteCriterion(t),this.refreshFromServer()}}m.values={criterionId:Number};class f extends e.Controller{connect(){const e=new URLSearchParams(window.location.search);this.existingParams=e,this.existingParams.delete("stable_id")}delete(e){const{criterionId:t}=e.currentTarget.dataset;var r=parseInt(t);this.stateController.deleteCriterion(r),this.reloadPage()}reloadPage(){try{const e=this,{blueprint:r}=e.stateController,i=new t.FetchRequest("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(r),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}redirectToStableId(e){const t=new URLSearchParams;e&&t.append("stable_id",e);const r=new URLSearchParams({...Object.fromEntries(this.existingParams),...Object.fromEntries(t)}).toString(),i=window.location.pathname+"?"+r;history.pushState({},document.title,i),window.location.reload()}get stateController(){return this.element.refineStateController}get stabilizeFilterController(){return this.element.stabilizeFilterController}}f.values={submitUrl:String};class g extends e.Controller{show(e){this.frameTarget.src=this.srcValue}hide(e){this.frameTarget.innerHTML=""}}g.targets=["frame"],g.values={src:String};class b extends e.Controller{search(e){e.preventDefault(),this.submitFilter(),document.activeElement.blur()}submitFilter(){try{const e=this,{blueprint:r}=e.stateController,i=new t.FetchRequest("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(r),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}get stateController(){return this.element.querySelector('[data-controller~="refine--state"]').refineStateController}loadResults(e){let{detail:{url:t}}=e;console.log("filter submit success"),window.Turbo?window.Turbo.visit(t):window.location.href=t}}b.values={submitUrl:String},function(){if("function"==typeof window.CustomEvent)return!1;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),r}e.prototype=window.Event.prototype,window.CustomEvent=e}();const v=(e,t)=>{let{blueprint:r,formId:i}=t;const n=new CustomEvent("blueprint-updated",{bubbles:!0,cancelable:!0,detail:{blueprint:r,formId:i}});e.dispatchEvent(n)},C=(e,t,r)=>{var i;const n=null==r?void 0:r.component,l=(null==r?void 0:r.meta)||{clauses:[],options:{}},o=(null==r?void 0:r.refinements)||[],{clauses:s,options:a}=l;let u;u="option-condition"===n?a[0]?[a[0].id]:[]:void 0;let d={clause:null==(i=s[0])?void 0:i.id,selected:u};return o.forEach(e=>{const{meta:t,component:r}=e,{clauses:i,options:n}=t;let l;l="option-condition"===r?n[0]?[n[0].id]:[]:void 0,d[e.id]={clause:i[0].id,selected:l}}),{depth:t,type:"criterion",condition_id:e,input:d}};class w extends e.Controller{connect(){this.element.refineStateController=this,this.changeDelegate=r.delegate("change",["event","picker"]),this.blueprint=this.blueprintValue,this.conditions=this.conditionsValue,this.filterName=this.classNameValue,this.conditionsLookup=this.conditions.reduce((e,t)=>(e[t.id]=t,e),{}),this.loadingTimeout=null,v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}disconnect(){r.abnegate("change",this.changeDelegate)}startUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTimeout=window.setTimeout(()=>{this.loadingTarget.classList.remove("hidden")},1e3)}finishUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTarget.classList.add("hidden")}conditionConfigFor(e){return this.conditionsLookup[e]}addGroup(){const{conditions:e}=this,t=e.find(e=>e.id==this.defaultConditionIdValue)||e[0];var r;this.blueprint.length>0&&this.blueprint.push({depth:r=void 0===r?0:r,type:"conjunction",word:"or"}),this.blueprint.push(C(t.id,1,t)),v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}addCriterion(e){const{blueprint:t,conditions:r}=this,i=r.find(e=>e.id==this.defaultConditionIdValue)||r[0];var n;t.splice(e+1,0,{depth:n=void 0===n?1:n,type:"conjunction",word:"and"},C(i.id,1,i)),v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}deleteCriterion(e){const{blueprint:t}=this,r=t[e-1],i=t[e+1],n=r&&"or"===r.word,l=i&&"or"===i.word||!i,o=n||!r,s=o&&l;r||i?t.splice(s&&n?e-1:s&&!r||o&&!l?e:e-1,2):this.blueprint=[],v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}replaceCriterion(e,t,r){const n=this.blueprint[e];if("criterion"!==n.type)throw new Error("You can't call updateConditionId on a non-criterion type. Trying to update "+JSON.stringify(C));const l=this.blueprint[e],o=C(t,n.depth,r);return!i.isEqual(l,o)&&(this.blueprint[e]=o,v(this.element,{blueprint:this.blueprint,formId:this.formIdValue}),!0)}updateInput(e,t,r){const{blueprint:i}=this,n=i[e],l=(r=r||"input").split(", ");l.length>1?n[l[0]][l[1]]={...n[l[0]][l[1]],...t}:n[r]={...n[r],...t},v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}}w.values={blueprint:Array,conditions:Array,className:String,refreshUrl:String,clientId:String,validateBlueprintUrl:String,defaultConditionId:String},w.targets=["loading"];class I extends e.Controller{connect(){const e=document.getElementById(this.stateDomIdValue).refineStateController;this.blueprintFieldTarget.value=JSON.stringify(e.blueprint),console.log("connect",this.blueprintFieldTarget.value)}updateBlueprintField(e){if(e.detail.formId!=this.formIdValue)return null;const{detail:t}=e,{blueprint:r}=t;this.blueprintFieldTarget.value=JSON.stringify(r),console.log("update blueprint",this.blueprintFieldTarget.value)}}I.targets=["blueprintField"],I.values={formId:String,stateDomId:String};class S extends e.Controller{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}S.targets=["content"];class y extends d{initialize(){this.updateBlueprint=i.debounce((e,t,r)=>{this.value(e,t,r)},500)}refinedFilter(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{id:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}clause(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{clause:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}selected(e){const{target:t}=e,r=Array.prototype.slice.call(t.options).filter(e=>e.selected).map(e=>e.value);this.value(e,r,"selected")}value(e,t,r){const{criterionIdValue:i,state:n}=this,l=e.target.dataset;n.updateInput(i,{[r=r||l.inputKey||"value"]:t=t||e.target.value},l.inputId)}condition(e){const{criterionIdValue:t,state:r}=this,i=e.target;let n=i.value;n||(n=i.querySelector("select").value);const l=this.state.conditionConfigFor(n);r.replaceCriterion(t,n,l)&&this.refreshFromServer()}cancelEnter(e){"Enter"===e.code&&(e.preventDefault(),e.stopPropagation())}}y.values={criterionId:Number},require("daterangepicker/daterangepicker.css");class T extends e.Controller{connect(){this.initPluginInstance()}disconnect(){this.teardownPluginInstance()}clearDate(e){e.preventDefault(),window.$(this.fieldTarget).val(""),this.dispatch("value-cleared")}applyDateToField(e,t){const r=this.includeTimeValue?this.timeFormatValue:this.dateFormatValue,i=t?s.default(t.startDate.toISOString()):s.default(this.fieldTarget.value,"YYYY-MM-DDTHH:mm").format("YYYY-MM-DDTHH:mm"),n=i.format(r),l=this.includeTimeValue?i.toISOString(!0):i.format("YYYY-MM-DD");this.fieldTarget.value=n,this.hiddenFieldTarget.value=l,window.$(this.fieldTarget).trigger("change",t),this.hiddenFieldTarget.dispatchEvent(new Event("change",{detail:t,bubbles:!0}))}initPluginInstance(){const e=this.pickerLocaleValue,t=this.isAmPmValue;e.format=this.includeTimeValue?this.timeFormatValue:this.dateFormatValue,window.$(this.fieldTarget).daterangepicker({singleDatePicker:!0,timePicker:this.includeTimeValue,timePickerIncrement:5,autoUpdateInput:!1,autoApply:!0,minDate:!!this.futureOnlyValue&&new Date,locale:e,parentEl:a.default(this.element),drops:this.dropsValue?this.dropsValue:"down",timePicker24Hour:!t}),window.$(this.fieldTarget).on("apply.daterangepicker",this.applyDateToField.bind(this)),window.$(this.fieldTarget).on("cancel.daterangepicker",this.clearDate.bind(this)),window.$(this.fieldTarget).on("showCalendar.daterangepicker",this.showCalendar.bind(this)),this.pluginMainEl=this.fieldTarget,this.plugin=a.default(this.pluginMainEl).data("daterangepicker"),this.inlineValue&&this.element.classList.add("date-input--inline")}teardownPluginInstance(){void 0!==this.plugin&&(a.default(this.pluginMainEl).off("apply.daterangepicker"),a.default(this.pluginMainEl).off("cancel.daterangepicker"),a.default(this.pluginMainEl).off("showCalendar.daterangepicker"),this.plugin.remove())}showCalendar(){this.dispatch("show-calendar")}}T.targets=["field","hiddenField","clearButton"],T.values={includeTime:Boolean,futureOnly:Boolean,drops:String,inline:Boolean,dateFormat:String,timeFormat:String,isAmPm:Boolean,locale:{type:String,default:"en"},datetimeFormat:{type:String,default:"MM/DD/YYYY h:mm A"},pickerLocale:{type:Object,default:{}}};const V=[[c,"refine/add-controller.js"],[h,"refine/condition-form-controller.js"],[p,"refine/defaults-controller.js"],[m,"refine/delete-controller.js"],[f,"refine/filter-pills-controller.js"],[g,"refine/popup-controller.js"],[b,"refine/search-filter-controller.js"],[d,"refine/server-refresh-controller.js"],[w,"refine/state-controller.js"],[I,"refine/stored-filter-controller.js"],[S,"refine/toggle-controller.js"],[y,"refine/update-controller.js"],[T,"refine/date-controller.js"]].map(function(e){const t=e[0];return{identifier:u(e[1]),controllerConstructor:t}});exports.AddController=c,exports.ConditionFormController=h,exports.DateController=T,exports.DefaultsController=p,exports.DeleteController=m,exports.FilterPillsController=f,exports.PopupController=g,exports.SearchFilterController=b,exports.ServerRefreshController=d,exports.StateController=w,exports.StoredFilterController=I,exports.ToggleController=S,exports.UpdateController=y,exports.controllerDefinitions=V; | ||
//# sourceMappingURL=refine-stimulus.js.map |
@@ -1,2 +0,2 @@ | ||
import{Controller as e}from"@hotwired/stimulus";import{FetchRequest as t}from"@rails/request.js";import{delegate as i,abnegate as r}from"jquery-events-to-dom-events";import{isEqual as n,debounce as s}from"lodash";import l from"flatpickr";import o from"moment";import{english as a}from"flatpickr/dist/l10n/default.js";import{Spanish as d}from"flatpickr/dist/l10n/es.js";import{Portuguese as u}from"flatpickr/dist/l10n/pt.js";function c(e){const t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class h extends e{connect(){this.state.finishUpdate()}get state(){let e=this.element;for(;e!==document.body;){if(e.matches('[data-controller~="refine--state"]'))return this.application.getControllerForElementAndIdentifier(e,"refine--state");e=e.parentNode}return null}async refreshFromServer(e={}){const{includeErrors:i}=e;this.state.startUpdate();const r=new t("GET",this.state.refreshUrlValue,{responseKind:"turbo-stream",query:{"hammerstone_refine_filters_builder[filter_class]":this.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(this.state.blueprint),"hammerstone_refine_filters_builder[client_id]":this.state.clientIdValue,include_errors:!!i}});await r.perform()}}class m extends h{async criterion(){const e=await this.validateBlueprint();e&&this.state.addCriterion(this.previousCriterionIdValue),this.refreshFromServer({includeErrors:!e})}async group(){const e=await this.validateBlueprint();e&&this.state.addGroup(),this.refreshFromServer({includeErrors:!e})}async validateBlueprint(e){const i=new t("GET",this.state.validateBlueprintUrlValue,{query:{"hammerstone_refine_filters_builder[filter_class]":this.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(this.state.blueprint),"hammerstone_refine_filters_builder[client_id]":this.state.clientIdValue}});return(await i.perform()).ok}}m.values={previousCriterionId:Number};class p extends e{refresh(e){const t=new FormData(this.element),i=new URL(this.urlValue);for(const[e,r]of t.entries())console.log(e,r),i.searchParams.set(e,r);window.Turbo.visit(i.toString(),{frame:this.turboFrameValue})}}p.values={url:String,turboFrame:String};class f extends e{connect(){this.state=this.getStateController(),this.state.updateInput(this.criterionIdValue,this.inputValue)}getStateController(){let e=this.element;for(;e!==document.body;){const t=this.application.getControllerForElementAndIdentifier(e,"refine--state");if(t)return t;e=e.parentNode}return null}}f.values={criterionId:Number,input:Object};class g extends h{criterion(){const{state:e,criterionIdValue:t}=this;e.deleteCriterion(t),this.refreshFromServer()}}function b(){return b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},b.apply(this,arguments)}g.values={criterionId:Number};class v extends e{connect(){const e=new URLSearchParams(window.location.search);this.existingParams=e,this.existingParams.delete("stable_id")}delete(e){const{criterionId:t}=e.currentTarget.dataset;var i=parseInt(t);this.stateController.deleteCriterion(i),this.reloadPage()}async reloadPage(){const{blueprint:e}=this.stateController,i=new t("POST",this.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:this.stateController.filterName,blueprint_json:JSON.stringify(e),client_id:this.stateController.clientIdValue}})});await i.perform()}redirectToStableId(e){const t=new URLSearchParams;e&&t.append("stable_id",e);const i=new URLSearchParams(b({},Object.fromEntries(this.existingParams),Object.fromEntries(t))).toString(),r=`${window.location.pathname}?${i}`;history.pushState({},document.title,r),window.location.reload()}get stateController(){return this.element.refineStateController}get stabilizeFilterController(){return this.element.stabilizeFilterController}}v.values={submitUrl:String};class w extends e{show(e){this.frameTarget.src=this.srcValue}hide(e){this.frameTarget.innerHTML=""}}w.targets=["frame"],w.values={src:String};class C extends e{search(e){e.preventDefault(),this.submitFilter(),document.activeElement.blur()}async submitFilter(){const{blueprint:e}=this.stateController,i=new t("POST",this.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:this.stateController.filterName,blueprint_json:JSON.stringify(e),client_id:this.stateController.clientIdValue}})});await i.perform()}get stateController(){return this.element.querySelector('[data-controller~="refine--state"]').refineStateController}loadResults({detail:{url:e}}){console.log("filter submit success"),window.Turbo?window.Turbo.visit(e):window.location.href=e}}C.values={submitUrl:String},function(){if("function"==typeof window.CustomEvent)return!1;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i}e.prototype=window.Event.prototype,window.CustomEvent=e}();const I=(e,{blueprint:t,formId:i})=>{const r=new CustomEvent("blueprint-updated",{bubbles:!0,cancelable:!0,detail:{blueprint:t,formId:i}});e.dispatchEvent(r)},S=(e,t,i)=>{var r;const n=null==i?void 0:i.component,s=(null==i?void 0:i.meta)||{clauses:[],options:{}},l=(null==i?void 0:i.refinements)||[],{clauses:o,options:a}=s;let d;d="option-condition"===n?a[0]?[a[0].id]:[]:void 0;let u={clause:null==(r=o[0])?void 0:r.id,selected:d};return l.forEach(e=>{const{meta:t,component:i}=e,{clauses:r,options:n}=t;let s;s="option-condition"===i?n[0]?[n[0].id]:[]:void 0,u[e.id]={clause:r[0].id,selected:s}}),{depth:t,type:"criterion",condition_id:e,input:u}};class y extends e{connect(){this.element.refineStateController=this,this.changeDelegate=i("change",["event","picker"]),this.blueprint=this.blueprintValue,this.conditions=this.conditionsValue,this.filterName=this.classNameValue,this.conditionsLookup=this.conditions.reduce((e,t)=>(e[t.id]=t,e),{}),this.loadingTimeout=null,I(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}disconnect(){r("change",this.changeDelegate)}startUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTimeout=window.setTimeout(()=>{this.loadingTarget.classList.remove("hidden")},1e3)}finishUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTarget.classList.add("hidden")}conditionConfigFor(e){return this.conditionsLookup[e]}addGroup(){const{conditions:e}=this,t=e.find(e=>e.id==this.defaultConditionIdValue)||e[0];var i;this.blueprint.length>0&&this.blueprint.push({depth:i=void 0===i?0:i,type:"conjunction",word:"or"}),this.blueprint.push(S(t.id,1,t)),I(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}addCriterion(e){const{blueprint:t,conditions:i}=this,r=i.find(e=>e.id==this.defaultConditionIdValue)||i[0];var n;t.splice(e+1,0,{depth:n=void 0===n?1:n,type:"conjunction",word:"and"},S(r.id,1,r)),I(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}deleteCriterion(e){const{blueprint:t}=this,i=t[e-1],r=t[e+1],n=i&&"or"===i.word,s=r&&"or"===r.word||!r,l=n||!i,o=l&&s;i||r?t.splice(o&&n?e-1:o&&!i||l&&!s?e:e-1,2):this.blueprint=[],I(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}replaceCriterion(e,t,i){const r=this.blueprint[e];if("criterion"!==r.type)throw new Error(`You can't call updateConditionId on a non-criterion type. Trying to update ${JSON.stringify(S)}`);const s=this.blueprint[e],l=S(t,r.depth,i);return!n(s,l)&&(this.blueprint[e]=l,I(this.element,{blueprint:this.blueprint,formId:this.formIdValue}),!0)}updateInput(e,t,i){const{blueprint:r}=this,n=r[e],s=(i=i||"input").split(", ");s.length>1?n[s[0]][s[1]]=b({},n[s[0]][s[1]],t):n[i]=b({},n[i],t),I(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}}y.values={blueprint:Array,conditions:Array,className:String,refreshUrl:String,clientId:String,validateBlueprintUrl:String,defaultConditionId:String},y.targets=["loading"];class _ extends e{connect(){const e=document.getElementById(this.stateDomIdValue).refineStateController;this.blueprintFieldTarget.value=JSON.stringify(e.blueprint),console.log("connect",this.blueprintFieldTarget.value)}updateBlueprintField(e){if(e.detail.formId!=this.formIdValue)return null;const{detail:t}=e,{blueprint:i}=t;this.blueprintFieldTarget.value=JSON.stringify(i),console.log("update blueprint",this.blueprintFieldTarget.value)}}_.targets=["blueprintField"],_.values={formId:String,stateDomId:String};class F extends e{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}F.targets=["content"];class V extends h{initialize(){this.updateBlueprint=s((e,t,i)=>{this.value(e,t,i)},500)}refinedFilter(e){const{criterionIdValue:t,state:i}=this;i.updateInput(t,{id:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}clause(e){const{criterionIdValue:t,state:i}=this;i.updateInput(t,{clause:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}selected(e){const{target:t}=e,i=Array.prototype.slice.call(t.options).filter(e=>e.selected).map(e=>e.value);this.value(e,i,"selected")}value(e,t,i){const{criterionIdValue:r,state:n}=this,s=e.target.dataset;n.updateInput(r,{[i=i||s.inputKey||"value"]:t=t||e.target.value},s.inputId)}condition(e){const{criterionIdValue:t,state:i}=this,r=e.target;let n=r.value;n||(n=r.querySelector("select").value);const s=this.state.conditionConfigFor(n);i.replaceCriterion(t,n,s)&&this.refreshFromServer()}cancelEnter(e){"Enter"===e.code&&(e.preventDefault(),e.stopPropagation())}}V.values={criterionId:Number},require("flatpickr/dist/flatpickr.css");const T={en:a,es:d,pt:u};class j extends e{connect(){var e;null!=(e=window.HammerstoneRefine)&&e.datePicker?window.HammerstoneRefine.datePicker.connect.bind(this)():this.defaultConnect()}disconnect(){var e;null!=(e=window.HammerstoneRefine)&&e.datePicker?window.HammerstoneRefine.datePicker.disconnect.bind(this)():this.defaultDisconnect()}defaultConnect(){var e;const t=(null==(e=this.localeValue)?void 0:e.slice(0,2))||"en";this.plugin=l(this.fieldTarget,{minDate:this.futureOnlyValue?new Date:null,dateFormat:"YYYY-MM-DD",locale:T[t],defaultDate:this.hiddenFieldTarget.value,parseDate:(e,t)=>o(e,t,!0).toDate(),formatDate:(e,t)=>o(e).format(t),onChange:(e,t,i)=>{this.fieldTarget.value=i.formatDate(e[0],this.includeTimeValue?this.datetimeFormatValue:this.dateFormatValue),this.hiddenFieldTarget.value=i.formatDate(e[0],"YYYY-MM-DD"),this.hiddenFieldTarget.dispatchEvent(new Event("change",{bubbles:!0}))},onReady:[()=>{const e=o(this.hiddenFieldTarget.value);e.isValid()&&(this.fieldTarget.value=e.format(this.includeTimeValue?this.datetimeFormatValue:this.dateFormatValue))}]})}defaultDisconnect(){this.plugin.destroy()}}j.targets=["field","hiddenField"],j.values={locale:{type:String,default:"en"},dateFormat:{type:String,default:"MM/DD/YYYY"},datetimeFormat:{type:String,default:"MM/DD/YYYY h:mm A"}};const D=[[m,"refine/add-controller.js"],[p,"refine/condition-form-controller.js"],[f,"refine/defaults-controller.js"],[g,"refine/delete-controller.js"],[v,"refine/filter-pills-controller.js"],[w,"refine/popup-controller.js"],[C,"refine/search-filter-controller.js"],[h,"refine/server-refresh-controller.js"],[y,"refine/state-controller.js"],[_,"refine/stored-filter-controller.js"],[F,"refine/toggle-controller.js"],[V,"refine/update-controller.js"],[j,"refine/date-controller.js"]].map(function(e){const t=e[0];return{identifier:c(e[1]),controllerConstructor:t}});export{m as AddController,p as ConditionFormController,j as DateController,f as DefaultsController,g as DeleteController,v as FilterPillsController,w as PopupController,C as SearchFilterController,h as ServerRefreshController,y as StateController,_ as StoredFilterController,F as ToggleController,V as UpdateController,D as controllerDefinitions}; | ||
import{Controller as e}from"@hotwired/stimulus";import{FetchRequest as t}from"@rails/request.js";import{delegate as i,abnegate as r}from"jquery-events-to-dom-events";import{isEqual as n,debounce as s}from"lodash";import l from"moment";import o from"jquery";import"daterangepicker";function a(e){const t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class d extends e{connect(){this.state.finishUpdate()}get state(){let e=this.element;for(;e!==document.body;){if(e.matches('[data-controller~="refine--state"]'))return this.application.getControllerForElementAndIdentifier(e,"refine--state");e=e.parentNode}return null}async refreshFromServer(e={}){const{includeErrors:i}=e;this.state.startUpdate();const r=new t("GET",this.state.refreshUrlValue,{responseKind:"turbo-stream",query:{"hammerstone_refine_filters_builder[filter_class]":this.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(this.state.blueprint),"hammerstone_refine_filters_builder[client_id]":this.state.clientIdValue,include_errors:!!i}});await r.perform()}}class u extends d{async criterion(){const e=await this.validateBlueprint();e&&this.state.addCriterion(this.previousCriterionIdValue),this.refreshFromServer({includeErrors:!e})}async group(){const e=await this.validateBlueprint();e&&this.state.addGroup(),this.refreshFromServer({includeErrors:!e})}async validateBlueprint(e){const i=new t("GET",this.state.validateBlueprintUrlValue,{query:{"hammerstone_refine_filters_builder[filter_class]":this.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(this.state.blueprint),"hammerstone_refine_filters_builder[client_id]":this.state.clientIdValue}});return(await i.perform()).ok}}u.values={previousCriterionId:Number};class c extends e{refresh(e){const t=new FormData(this.element),i=new URL(this.urlValue);for(const[e,r]of t.entries())console.log(e,r),i.searchParams.set(e,r);window.Turbo.visit(i.toString(),{frame:this.turboFrameValue})}}c.values={url:String,turboFrame:String};class h extends e{connect(){this.state=this.getStateController(),this.state.updateInput(this.criterionIdValue,this.inputValue)}getStateController(){let e=this.element;for(;e!==document.body;){const t=this.application.getControllerForElementAndIdentifier(e,"refine--state");if(t)return t;e=e.parentNode}return null}}h.values={criterionId:Number,input:Object};class p extends d{criterion(){const{state:e,criterionIdValue:t}=this;e.deleteCriterion(t),this.refreshFromServer()}}function m(){return m=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},m.apply(this,arguments)}p.values={criterionId:Number};class f extends e{connect(){const e=new URLSearchParams(window.location.search);this.existingParams=e,this.existingParams.delete("stable_id")}delete(e){const{criterionId:t}=e.currentTarget.dataset;var i=parseInt(t);this.stateController.deleteCriterion(i),this.reloadPage()}async reloadPage(){const{blueprint:e}=this.stateController,i=new t("POST",this.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:this.stateController.filterName,blueprint_json:JSON.stringify(e),client_id:this.stateController.clientIdValue}})});await i.perform()}redirectToStableId(e){const t=new URLSearchParams;e&&t.append("stable_id",e);const i=new URLSearchParams(m({},Object.fromEntries(this.existingParams),Object.fromEntries(t))).toString(),r=`${window.location.pathname}?${i}`;history.pushState({},document.title,r),window.location.reload()}get stateController(){return this.element.refineStateController}get stabilizeFilterController(){return this.element.stabilizeFilterController}}f.values={submitUrl:String};class g extends e{show(e){this.frameTarget.src=this.srcValue}hide(e){this.frameTarget.innerHTML=""}}g.targets=["frame"],g.values={src:String};class b extends e{search(e){e.preventDefault(),this.submitFilter(),document.activeElement.blur()}async submitFilter(){const{blueprint:e}=this.stateController,i=new t("POST",this.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:this.stateController.filterName,blueprint_json:JSON.stringify(e),client_id:this.stateController.clientIdValue}})});await i.perform()}get stateController(){return this.element.querySelector('[data-controller~="refine--state"]').refineStateController}loadResults({detail:{url:e}}){console.log("filter submit success"),window.Turbo?window.Turbo.visit(e):window.location.href=e}}b.values={submitUrl:String},function(){if("function"==typeof window.CustomEvent)return!1;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i}e.prototype=window.Event.prototype,window.CustomEvent=e}();const v=(e,{blueprint:t,formId:i})=>{const r=new CustomEvent("blueprint-updated",{bubbles:!0,cancelable:!0,detail:{blueprint:t,formId:i}});e.dispatchEvent(r)},w=(e,t,i)=>{var r;const n=null==i?void 0:i.component,s=(null==i?void 0:i.meta)||{clauses:[],options:{}},l=(null==i?void 0:i.refinements)||[],{clauses:o,options:a}=s;let d;d="option-condition"===n?a[0]?[a[0].id]:[]:void 0;let u={clause:null==(r=o[0])?void 0:r.id,selected:d};return l.forEach(e=>{const{meta:t,component:i}=e,{clauses:r,options:n}=t;let s;s="option-condition"===i?n[0]?[n[0].id]:[]:void 0,u[e.id]={clause:r[0].id,selected:s}}),{depth:t,type:"criterion",condition_id:e,input:u}};class I extends e{connect(){this.element.refineStateController=this,this.changeDelegate=i("change",["event","picker"]),this.blueprint=this.blueprintValue,this.conditions=this.conditionsValue,this.filterName=this.classNameValue,this.conditionsLookup=this.conditions.reduce((e,t)=>(e[t.id]=t,e),{}),this.loadingTimeout=null,v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}disconnect(){r("change",this.changeDelegate)}startUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTimeout=window.setTimeout(()=>{this.loadingTarget.classList.remove("hidden")},1e3)}finishUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTarget.classList.add("hidden")}conditionConfigFor(e){return this.conditionsLookup[e]}addGroup(){const{conditions:e}=this,t=e.find(e=>e.id==this.defaultConditionIdValue)||e[0];var i;this.blueprint.length>0&&this.blueprint.push({depth:i=void 0===i?0:i,type:"conjunction",word:"or"}),this.blueprint.push(w(t.id,1,t)),v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}addCriterion(e){const{blueprint:t,conditions:i}=this,r=i.find(e=>e.id==this.defaultConditionIdValue)||i[0];var n;t.splice(e+1,0,{depth:n=void 0===n?1:n,type:"conjunction",word:"and"},w(r.id,1,r)),v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}deleteCriterion(e){const{blueprint:t}=this,i=t[e-1],r=t[e+1],n=i&&"or"===i.word,s=r&&"or"===r.word||!r,l=n||!i,o=l&&s;i||r?t.splice(o&&n?e-1:o&&!i||l&&!s?e:e-1,2):this.blueprint=[],v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}replaceCriterion(e,t,i){const r=this.blueprint[e];if("criterion"!==r.type)throw new Error(`You can't call updateConditionId on a non-criterion type. Trying to update ${JSON.stringify(w)}`);const s=this.blueprint[e],l=w(t,r.depth,i);return!n(s,l)&&(this.blueprint[e]=l,v(this.element,{blueprint:this.blueprint,formId:this.formIdValue}),!0)}updateInput(e,t,i){const{blueprint:r}=this,n=r[e],s=(i=i||"input").split(", ");s.length>1?n[s[0]][s[1]]=m({},n[s[0]][s[1]],t):n[i]=m({},n[i],t),v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}}I.values={blueprint:Array,conditions:Array,className:String,refreshUrl:String,clientId:String,validateBlueprintUrl:String,defaultConditionId:String},I.targets=["loading"];class C extends e{connect(){const e=document.getElementById(this.stateDomIdValue).refineStateController;this.blueprintFieldTarget.value=JSON.stringify(e.blueprint),console.log("connect",this.blueprintFieldTarget.value)}updateBlueprintField(e){if(e.detail.formId!=this.formIdValue)return null;const{detail:t}=e,{blueprint:i}=t;this.blueprintFieldTarget.value=JSON.stringify(i),console.log("update blueprint",this.blueprintFieldTarget.value)}}C.targets=["blueprintField"],C.values={formId:String,stateDomId:String};class S extends e{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}S.targets=["content"];class y extends d{initialize(){this.updateBlueprint=s((e,t,i)=>{this.value(e,t,i)},500)}refinedFilter(e){const{criterionIdValue:t,state:i}=this;i.updateInput(t,{id:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}clause(e){const{criterionIdValue:t,state:i}=this;i.updateInput(t,{clause:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}selected(e){const{target:t}=e,i=Array.prototype.slice.call(t.options).filter(e=>e.selected).map(e=>e.value);this.value(e,i,"selected")}value(e,t,i){const{criterionIdValue:r,state:n}=this,s=e.target.dataset;n.updateInput(r,{[i=i||s.inputKey||"value"]:t=t||e.target.value},s.inputId)}condition(e){const{criterionIdValue:t,state:i}=this,r=e.target;let n=r.value;n||(n=r.querySelector("select").value);const s=this.state.conditionConfigFor(n);i.replaceCriterion(t,n,s)&&this.refreshFromServer()}cancelEnter(e){"Enter"===e.code&&(e.preventDefault(),e.stopPropagation())}}y.values={criterionId:Number},require("daterangepicker/daterangepicker.css");class T extends e{connect(){this.initPluginInstance()}disconnect(){this.teardownPluginInstance()}clearDate(e){e.preventDefault(),window.$(this.fieldTarget).val(""),this.dispatch("value-cleared")}applyDateToField(e,t){const i=this.includeTimeValue?this.timeFormatValue:this.dateFormatValue,r=t?l(t.startDate.toISOString()):l(this.fieldTarget.value,"YYYY-MM-DDTHH:mm").format("YYYY-MM-DDTHH:mm"),n=r.format(i),s=this.includeTimeValue?r.toISOString(!0):r.format("YYYY-MM-DD");this.fieldTarget.value=n,this.hiddenFieldTarget.value=s,window.$(this.fieldTarget).trigger("change",t),this.hiddenFieldTarget.dispatchEvent(new Event("change",{detail:t,bubbles:!0}))}initPluginInstance(){const e=this.pickerLocaleValue,t=this.isAmPmValue;e.format=this.includeTimeValue?this.timeFormatValue:this.dateFormatValue,window.$(this.fieldTarget).daterangepicker({singleDatePicker:!0,timePicker:this.includeTimeValue,timePickerIncrement:5,autoUpdateInput:!1,autoApply:!0,minDate:!!this.futureOnlyValue&&new Date,locale:e,parentEl:o(this.element),drops:this.dropsValue?this.dropsValue:"down",timePicker24Hour:!t}),window.$(this.fieldTarget).on("apply.daterangepicker",this.applyDateToField.bind(this)),window.$(this.fieldTarget).on("cancel.daterangepicker",this.clearDate.bind(this)),window.$(this.fieldTarget).on("showCalendar.daterangepicker",this.showCalendar.bind(this)),this.pluginMainEl=this.fieldTarget,this.plugin=o(this.pluginMainEl).data("daterangepicker"),this.inlineValue&&this.element.classList.add("date-input--inline")}teardownPluginInstance(){void 0!==this.plugin&&(o(this.pluginMainEl).off("apply.daterangepicker"),o(this.pluginMainEl).off("cancel.daterangepicker"),o(this.pluginMainEl).off("showCalendar.daterangepicker"),this.plugin.remove())}showCalendar(){this.dispatch("show-calendar")}}T.targets=["field","hiddenField","clearButton"],T.values={includeTime:Boolean,futureOnly:Boolean,drops:String,inline:Boolean,dateFormat:String,timeFormat:String,isAmPm:Boolean,locale:{type:String,default:"en"},datetimeFormat:{type:String,default:"MM/DD/YYYY h:mm A"},pickerLocale:{type:Object,default:{}}};const V=[[u,"refine/add-controller.js"],[c,"refine/condition-form-controller.js"],[h,"refine/defaults-controller.js"],[p,"refine/delete-controller.js"],[f,"refine/filter-pills-controller.js"],[g,"refine/popup-controller.js"],[b,"refine/search-filter-controller.js"],[d,"refine/server-refresh-controller.js"],[I,"refine/state-controller.js"],[C,"refine/stored-filter-controller.js"],[S,"refine/toggle-controller.js"],[y,"refine/update-controller.js"],[T,"refine/date-controller.js"]].map(function(e){const t=e[0];return{identifier:a(e[1]),controllerConstructor:t}});export{u as AddController,c as ConditionFormController,T as DateController,h as DefaultsController,p as DeleteController,f as FilterPillsController,g as PopupController,b as SearchFilterController,d as ServerRefreshController,I as StateController,C as StoredFilterController,S as ToggleController,y as UpdateController,V as controllerDefinitions}; | ||
//# sourceMappingURL=refine-stimulus.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@hotwired/stimulus"),require("@rails/request.js"),require("jquery-events-to-dom-events"),require("lodash"),require("flatpickr"),require("moment"),require("flatpickr/dist/l10n/default.js"),require("flatpickr/dist/l10n/es.js"),require("flatpickr/dist/l10n/pt.js")):"function"==typeof define&&define.amd?define(["exports","@hotwired/stimulus","@rails/request.js","jquery-events-to-dom-events","lodash","flatpickr","moment","flatpickr/dist/l10n/default.js","flatpickr/dist/l10n/es.js","flatpickr/dist/l10n/pt.js"],t):t((e||self).refineStimulus={},e.Stimulus,e.request_js,e.jqueryEventsToDomEvents,e.lodash,e.flatpickr,e.moment,e.default_js,e.es_js,e.pt_js)}(this,function(e,t,r,i,n,l,o,s,a,u){function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(l),h=d(o);function f(e){const t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class m extends t.Controller{connect(){this.state.finishUpdate()}get state(){let e=this.element;for(;e!==document.body;){if(e.matches('[data-controller~="refine--state"]'))return this.application.getControllerForElementAndIdentifier(e,"refine--state");e=e.parentNode}return null}refreshFromServer(e){void 0===e&&(e={});try{const t=this,{includeErrors:i}=e;t.state.startUpdate();const n=new r.FetchRequest("GET",t.state.refreshUrlValue,{responseKind:"turbo-stream",query:{"hammerstone_refine_filters_builder[filter_class]":t.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(t.state.blueprint),"hammerstone_refine_filters_builder[client_id]":t.state.clientIdValue,include_errors:!!i}});return Promise.resolve(n.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class p extends m{criterion(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addCriterion(e.previousCriterionIdValue),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}group(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addGroup(),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}validateBlueprint(e){try{const e=this,t=new r.FetchRequest("GET",e.state.validateBlueprintUrlValue,{query:{"hammerstone_refine_filters_builder[filter_class]":e.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(e.state.blueprint),"hammerstone_refine_filters_builder[client_id]":e.state.clientIdValue}});return Promise.resolve(t.perform()).then(function(e){return e.ok})}catch(e){return Promise.reject(e)}}}p.values={previousCriterionId:Number};class g extends t.Controller{refresh(e){const t=new FormData(this.element),r=new URL(this.urlValue);for(const[e,i]of t.entries())console.log(e,i),r.searchParams.set(e,i);window.Turbo.visit(r.toString(),{frame:this.turboFrameValue})}}g.values={url:String,turboFrame:String};class b extends t.Controller{connect(){this.state=this.getStateController(),this.state.updateInput(this.criterionIdValue,this.inputValue)}getStateController(){let e=this.element;for(;e!==document.body;){const t=this.application.getControllerForElementAndIdentifier(e,"refine--state");if(t)return t;e=e.parentNode}return null}}b.values={criterionId:Number,input:Object};class v extends m{criterion(){const{state:e,criterionIdValue:t}=this;e.deleteCriterion(t),this.refreshFromServer()}}v.values={criterionId:Number};class C extends t.Controller{connect(){const e=new URLSearchParams(window.location.search);this.existingParams=e,this.existingParams.delete("stable_id")}delete(e){const{criterionId:t}=e.currentTarget.dataset;var r=parseInt(t);this.stateController.deleteCriterion(r),this.reloadPage()}reloadPage(){try{const e=this,{blueprint:t}=e.stateController,i=new r.FetchRequest("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(t),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}redirectToStableId(e){const t=new URLSearchParams;e&&t.append("stable_id",e);const r=new URLSearchParams({...Object.fromEntries(this.existingParams),...Object.fromEntries(t)}).toString(),i=window.location.pathname+"?"+r;history.pushState({},document.title,i),window.location.reload()}get stateController(){return this.element.refineStateController}get stabilizeFilterController(){return this.element.stabilizeFilterController}}C.values={submitUrl:String};class w extends t.Controller{show(e){this.frameTarget.src=this.srcValue}hide(e){this.frameTarget.innerHTML=""}}w.targets=["frame"],w.values={src:String};class S extends t.Controller{search(e){e.preventDefault(),this.submitFilter(),document.activeElement.blur()}submitFilter(){try{const e=this,{blueprint:t}=e.stateController,i=new r.FetchRequest("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(t),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}get stateController(){return this.element.querySelector('[data-controller~="refine--state"]').refineStateController}loadResults(e){let{detail:{url:t}}=e;console.log("filter submit success"),window.Turbo?window.Turbo.visit(t):window.location.href=t}}S.values={submitUrl:String},function(){if("function"==typeof window.CustomEvent)return!1;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),r}e.prototype=window.Event.prototype,window.CustomEvent=e}();const y=(e,t)=>{let{blueprint:r,formId:i}=t;const n=new CustomEvent("blueprint-updated",{bubbles:!0,cancelable:!0,detail:{blueprint:r,formId:i}});e.dispatchEvent(n)},I=(e,t,r)=>{var i;const n=null==r?void 0:r.component,l=(null==r?void 0:r.meta)||{clauses:[],options:{}},o=(null==r?void 0:r.refinements)||[],{clauses:s,options:a}=l;let u;u="option-condition"===n?a[0]?[a[0].id]:[]:void 0;let d={clause:null==(i=s[0])?void 0:i.id,selected:u};return o.forEach(e=>{const{meta:t,component:r}=e,{clauses:i,options:n}=t;let l;l="option-condition"===r?n[0]?[n[0].id]:[]:void 0,d[e.id]={clause:i[0].id,selected:l}}),{depth:t,type:"criterion",condition_id:e,input:d}};class _ extends t.Controller{connect(){this.element.refineStateController=this,this.changeDelegate=i.delegate("change",["event","picker"]),this.blueprint=this.blueprintValue,this.conditions=this.conditionsValue,this.filterName=this.classNameValue,this.conditionsLookup=this.conditions.reduce((e,t)=>(e[t.id]=t,e),{}),this.loadingTimeout=null,y(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}disconnect(){i.abnegate("change",this.changeDelegate)}startUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTimeout=window.setTimeout(()=>{this.loadingTarget.classList.remove("hidden")},1e3)}finishUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTarget.classList.add("hidden")}conditionConfigFor(e){return this.conditionsLookup[e]}addGroup(){const{conditions:e}=this,t=e.find(e=>e.id==this.defaultConditionIdValue)||e[0];var r;this.blueprint.length>0&&this.blueprint.push({depth:r=void 0===r?0:r,type:"conjunction",word:"or"}),this.blueprint.push(I(t.id,1,t)),y(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}addCriterion(e){const{blueprint:t,conditions:r}=this,i=r.find(e=>e.id==this.defaultConditionIdValue)||r[0];var n;t.splice(e+1,0,{depth:n=void 0===n?1:n,type:"conjunction",word:"and"},I(i.id,1,i)),y(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}deleteCriterion(e){const{blueprint:t}=this,r=t[e-1],i=t[e+1],n=r&&"or"===r.word,l=i&&"or"===i.word||!i,o=n||!r,s=o&&l;r||i?t.splice(s&&n?e-1:s&&!r||o&&!l?e:e-1,2):this.blueprint=[],y(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}replaceCriterion(e,t,r){const i=this.blueprint[e];if("criterion"!==i.type)throw new Error("You can't call updateConditionId on a non-criterion type. Trying to update "+JSON.stringify(I));const l=this.blueprint[e],o=I(t,i.depth,r);return!n.isEqual(l,o)&&(this.blueprint[e]=o,y(this.element,{blueprint:this.blueprint,formId:this.formIdValue}),!0)}updateInput(e,t,r){const{blueprint:i}=this,n=i[e],l=(r=r||"input").split(", ");l.length>1?n[l[0]][l[1]]={...n[l[0]][l[1]],...t}:n[r]={...n[r],...t},y(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}}_.values={blueprint:Array,conditions:Array,className:String,refreshUrl:String,clientId:String,validateBlueprintUrl:String,defaultConditionId:String},_.targets=["loading"];class j extends t.Controller{connect(){const e=document.getElementById(this.stateDomIdValue).refineStateController;this.blueprintFieldTarget.value=JSON.stringify(e.blueprint),console.log("connect",this.blueprintFieldTarget.value)}updateBlueprintField(e){if(e.detail.formId!=this.formIdValue)return null;const{detail:t}=e,{blueprint:r}=t;this.blueprintFieldTarget.value=JSON.stringify(r),console.log("update blueprint",this.blueprintFieldTarget.value)}}j.targets=["blueprintField"],j.values={formId:String,stateDomId:String};class F extends t.Controller{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}F.targets=["content"];class T extends m{initialize(){this.updateBlueprint=n.debounce((e,t,r)=>{this.value(e,t,r)},500)}refinedFilter(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{id:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}clause(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{clause:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}selected(e){const{target:t}=e,r=Array.prototype.slice.call(t.options).filter(e=>e.selected).map(e=>e.value);this.value(e,r,"selected")}value(e,t,r){const{criterionIdValue:i,state:n}=this,l=e.target.dataset;n.updateInput(i,{[r=r||l.inputKey||"value"]:t=t||e.target.value},l.inputId)}condition(e){const{criterionIdValue:t,state:r}=this,i=e.target;let n=i.value;n||(n=i.querySelector("select").value);const l=this.state.conditionConfigFor(n);r.replaceCriterion(t,n,l)&&this.refreshFromServer()}cancelEnter(e){"Enter"===e.code&&(e.preventDefault(),e.stopPropagation())}}T.values={criterionId:Number},require("flatpickr/dist/flatpickr.css");const V={en:s.english,es:a.Spanish,pt:u.Portuguese};class P extends t.Controller{connect(){var e;null!=(e=window.HammerstoneRefine)&&e.datePicker?window.HammerstoneRefine.datePicker.connect.bind(this)():this.defaultConnect()}disconnect(){var e;null!=(e=window.HammerstoneRefine)&&e.datePicker?window.HammerstoneRefine.datePicker.disconnect.bind(this)():this.defaultDisconnect()}defaultConnect(){var e;const t=(null==(e=this.localeValue)?void 0:e.slice(0,2))||"en";this.plugin=c.default(this.fieldTarget,{minDate:this.futureOnlyValue?new Date:null,dateFormat:"YYYY-MM-DD",locale:V[t],defaultDate:this.hiddenFieldTarget.value,parseDate:(e,t)=>h.default(e,t,!0).toDate(),formatDate:(e,t)=>h.default(e).format(t),onChange:(e,t,r)=>{this.fieldTarget.value=r.formatDate(e[0],this.includeTimeValue?this.datetimeFormatValue:this.dateFormatValue),this.hiddenFieldTarget.value=r.formatDate(e[0],"YYYY-MM-DD"),this.hiddenFieldTarget.dispatchEvent(new Event("change",{bubbles:!0}))},onReady:[()=>{const e=h.default(this.hiddenFieldTarget.value);e.isValid()&&(this.fieldTarget.value=e.format(this.includeTimeValue?this.datetimeFormatValue:this.dateFormatValue))}]})}defaultDisconnect(){this.plugin.destroy()}}P.targets=["field","hiddenField"],P.values={locale:{type:String,default:"en"},dateFormat:{type:String,default:"MM/DD/YYYY"},datetimeFormat:{type:String,default:"MM/DD/YYYY h:mm A"}};const D=[[p,"refine/add-controller.js"],[g,"refine/condition-form-controller.js"],[b,"refine/defaults-controller.js"],[v,"refine/delete-controller.js"],[C,"refine/filter-pills-controller.js"],[w,"refine/popup-controller.js"],[S,"refine/search-filter-controller.js"],[m,"refine/server-refresh-controller.js"],[_,"refine/state-controller.js"],[j,"refine/stored-filter-controller.js"],[F,"refine/toggle-controller.js"],[T,"refine/update-controller.js"],[P,"refine/date-controller.js"]].map(function(e){const t=e[0];return{identifier:f(e[1]),controllerConstructor:t}});e.AddController=p,e.ConditionFormController=g,e.DateController=P,e.DefaultsController=b,e.DeleteController=v,e.FilterPillsController=C,e.PopupController=w,e.SearchFilterController=S,e.ServerRefreshController=m,e.StateController=_,e.StoredFilterController=j,e.ToggleController=F,e.UpdateController=T,e.controllerDefinitions=D}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@hotwired/stimulus"),require("@rails/request.js"),require("jquery-events-to-dom-events"),require("lodash"),require("moment"),require("jquery"),require("daterangepicker")):"function"==typeof define&&define.amd?define(["exports","@hotwired/stimulus","@rails/request.js","jquery-events-to-dom-events","lodash","moment","jquery","daterangepicker"],t):t((e||self).refineStimulus={},e.Stimulus,e.request_js,e.jqueryEventsToDomEvents,e.lodash,e.moment,e.jquery)}(this,function(e,t,r,i,n,l,o){function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=s(l),u=s(o);function d(e){const t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class c extends t.Controller{connect(){this.state.finishUpdate()}get state(){let e=this.element;for(;e!==document.body;){if(e.matches('[data-controller~="refine--state"]'))return this.application.getControllerForElementAndIdentifier(e,"refine--state");e=e.parentNode}return null}refreshFromServer(e){void 0===e&&(e={});try{const t=this,{includeErrors:i}=e;t.state.startUpdate();const n=new r.FetchRequest("GET",t.state.refreshUrlValue,{responseKind:"turbo-stream",query:{"hammerstone_refine_filters_builder[filter_class]":t.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(t.state.blueprint),"hammerstone_refine_filters_builder[client_id]":t.state.clientIdValue,include_errors:!!i}});return Promise.resolve(n.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class h extends c{criterion(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addCriterion(e.previousCriterionIdValue),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}group(){try{const e=this;return Promise.resolve(e.validateBlueprint()).then(function(t){t&&e.state.addGroup(),e.refreshFromServer({includeErrors:!t})})}catch(e){return Promise.reject(e)}}validateBlueprint(e){try{const e=this,t=new r.FetchRequest("GET",e.state.validateBlueprintUrlValue,{query:{"hammerstone_refine_filters_builder[filter_class]":e.state.filterName,"hammerstone_refine_filters_builder[blueprint_json]":JSON.stringify(e.state.blueprint),"hammerstone_refine_filters_builder[client_id]":e.state.clientIdValue}});return Promise.resolve(t.perform()).then(function(e){return e.ok})}catch(e){return Promise.reject(e)}}}h.values={previousCriterionId:Number};class p extends t.Controller{refresh(e){const t=new FormData(this.element),r=new URL(this.urlValue);for(const[e,i]of t.entries())console.log(e,i),r.searchParams.set(e,i);window.Turbo.visit(r.toString(),{frame:this.turboFrameValue})}}p.values={url:String,turboFrame:String};class m extends t.Controller{connect(){this.state=this.getStateController(),this.state.updateInput(this.criterionIdValue,this.inputValue)}getStateController(){let e=this.element;for(;e!==document.body;){const t=this.application.getControllerForElementAndIdentifier(e,"refine--state");if(t)return t;e=e.parentNode}return null}}m.values={criterionId:Number,input:Object};class f extends c{criterion(){const{state:e,criterionIdValue:t}=this;e.deleteCriterion(t),this.refreshFromServer()}}f.values={criterionId:Number};class g extends t.Controller{connect(){const e=new URLSearchParams(window.location.search);this.existingParams=e,this.existingParams.delete("stable_id")}delete(e){const{criterionId:t}=e.currentTarget.dataset;var r=parseInt(t);this.stateController.deleteCriterion(r),this.reloadPage()}reloadPage(){try{const e=this,{blueprint:t}=e.stateController,i=new r.FetchRequest("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(t),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}redirectToStableId(e){const t=new URLSearchParams;e&&t.append("stable_id",e);const r=new URLSearchParams({...Object.fromEntries(this.existingParams),...Object.fromEntries(t)}).toString(),i=window.location.pathname+"?"+r;history.pushState({},document.title,i),window.location.reload()}get stateController(){return this.element.refineStateController}get stabilizeFilterController(){return this.element.stabilizeFilterController}}g.values={submitUrl:String};class b extends t.Controller{show(e){this.frameTarget.src=this.srcValue}hide(e){this.frameTarget.innerHTML=""}}b.targets=["frame"],b.values={src:String};class v extends t.Controller{search(e){e.preventDefault(),this.submitFilter(),document.activeElement.blur()}submitFilter(){try{const e=this,{blueprint:t}=e.stateController,i=new r.FetchRequest("POST",e.submitUrlValue,{responseKind:"turbo-stream",body:JSON.stringify({hammerstone_refine_filters_builder:{filter_class:e.stateController.filterName,blueprint_json:JSON.stringify(t),client_id:e.stateController.clientIdValue}})});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}get stateController(){return this.element.querySelector('[data-controller~="refine--state"]').refineStateController}loadResults(e){let{detail:{url:t}}=e;console.log("filter submit success"),window.Turbo?window.Turbo.visit(t):window.location.href=t}}v.values={submitUrl:String},function(){if("function"==typeof window.CustomEvent)return!1;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),r}e.prototype=window.Event.prototype,window.CustomEvent=e}();const C=(e,t)=>{let{blueprint:r,formId:i}=t;const n=new CustomEvent("blueprint-updated",{bubbles:!0,cancelable:!0,detail:{blueprint:r,formId:i}});e.dispatchEvent(n)},w=(e,t,r)=>{var i;const n=null==r?void 0:r.component,l=(null==r?void 0:r.meta)||{clauses:[],options:{}},o=(null==r?void 0:r.refinements)||[],{clauses:s,options:a}=l;let u;u="option-condition"===n?a[0]?[a[0].id]:[]:void 0;let d={clause:null==(i=s[0])?void 0:i.id,selected:u};return o.forEach(e=>{const{meta:t,component:r}=e,{clauses:i,options:n}=t;let l;l="option-condition"===r?n[0]?[n[0].id]:[]:void 0,d[e.id]={clause:i[0].id,selected:l}}),{depth:t,type:"criterion",condition_id:e,input:d}};class I extends t.Controller{connect(){this.element.refineStateController=this,this.changeDelegate=i.delegate("change",["event","picker"]),this.blueprint=this.blueprintValue,this.conditions=this.conditionsValue,this.filterName=this.classNameValue,this.conditionsLookup=this.conditions.reduce((e,t)=>(e[t.id]=t,e),{}),this.loadingTimeout=null,C(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}disconnect(){i.abnegate("change",this.changeDelegate)}startUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTimeout=window.setTimeout(()=>{this.loadingTarget.classList.remove("hidden")},1e3)}finishUpdate(){this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),this.loadingTarget.classList.add("hidden")}conditionConfigFor(e){return this.conditionsLookup[e]}addGroup(){const{conditions:e}=this,t=e.find(e=>e.id==this.defaultConditionIdValue)||e[0];var r;this.blueprint.length>0&&this.blueprint.push({depth:r=void 0===r?0:r,type:"conjunction",word:"or"}),this.blueprint.push(w(t.id,1,t)),C(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}addCriterion(e){const{blueprint:t,conditions:r}=this,i=r.find(e=>e.id==this.defaultConditionIdValue)||r[0];var n;t.splice(e+1,0,{depth:n=void 0===n?1:n,type:"conjunction",word:"and"},w(i.id,1,i)),C(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}deleteCriterion(e){const{blueprint:t}=this,r=t[e-1],i=t[e+1],n=r&&"or"===r.word,l=i&&"or"===i.word||!i,o=n||!r,s=o&&l;r||i?t.splice(s&&n?e-1:s&&!r||o&&!l?e:e-1,2):this.blueprint=[],C(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}replaceCriterion(e,t,r){const i=this.blueprint[e];if("criterion"!==i.type)throw new Error("You can't call updateConditionId on a non-criterion type. Trying to update "+JSON.stringify(w));const l=this.blueprint[e],o=w(t,i.depth,r);return!n.isEqual(l,o)&&(this.blueprint[e]=o,C(this.element,{blueprint:this.blueprint,formId:this.formIdValue}),!0)}updateInput(e,t,r){const{blueprint:i}=this,n=i[e],l=(r=r||"input").split(", ");l.length>1?n[l[0]][l[1]]={...n[l[0]][l[1]],...t}:n[r]={...n[r],...t},C(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}}I.values={blueprint:Array,conditions:Array,className:String,refreshUrl:String,clientId:String,validateBlueprintUrl:String,defaultConditionId:String},I.targets=["loading"];class y extends t.Controller{connect(){const e=document.getElementById(this.stateDomIdValue).refineStateController;this.blueprintFieldTarget.value=JSON.stringify(e.blueprint),console.log("connect",this.blueprintFieldTarget.value)}updateBlueprintField(e){if(e.detail.formId!=this.formIdValue)return null;const{detail:t}=e,{blueprint:r}=t;this.blueprintFieldTarget.value=JSON.stringify(r),console.log("update blueprint",this.blueprintFieldTarget.value)}}y.targets=["blueprintField"],y.values={formId:String,stateDomId:String};class S extends t.Controller{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}S.targets=["content"];class T extends c{initialize(){this.updateBlueprint=n.debounce((e,t,r)=>{this.value(e,t,r)},500)}refinedFilter(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{id:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}clause(e){const{criterionIdValue:t,state:r}=this;r.updateInput(t,{clause:e.target.value},e.target.dataset.inputId),this.refreshFromServer()}selected(e){const{target:t}=e,r=Array.prototype.slice.call(t.options).filter(e=>e.selected).map(e=>e.value);this.value(e,r,"selected")}value(e,t,r){const{criterionIdValue:i,state:n}=this,l=e.target.dataset;n.updateInput(i,{[r=r||l.inputKey||"value"]:t=t||e.target.value},l.inputId)}condition(e){const{criterionIdValue:t,state:r}=this,i=e.target;let n=i.value;n||(n=i.querySelector("select").value);const l=this.state.conditionConfigFor(n);r.replaceCriterion(t,n,l)&&this.refreshFromServer()}cancelEnter(e){"Enter"===e.code&&(e.preventDefault(),e.stopPropagation())}}T.values={criterionId:Number},require("daterangepicker/daterangepicker.css");class V extends t.Controller{connect(){this.initPluginInstance()}disconnect(){this.teardownPluginInstance()}clearDate(e){e.preventDefault(),window.$(this.fieldTarget).val(""),this.dispatch("value-cleared")}applyDateToField(e,t){const r=this.includeTimeValue?this.timeFormatValue:this.dateFormatValue,i=t?a.default(t.startDate.toISOString()):a.default(this.fieldTarget.value,"YYYY-MM-DDTHH:mm").format("YYYY-MM-DDTHH:mm"),n=i.format(r),l=this.includeTimeValue?i.toISOString(!0):i.format("YYYY-MM-DD");this.fieldTarget.value=n,this.hiddenFieldTarget.value=l,window.$(this.fieldTarget).trigger("change",t),this.hiddenFieldTarget.dispatchEvent(new Event("change",{detail:t,bubbles:!0}))}initPluginInstance(){const e=this.pickerLocaleValue,t=this.isAmPmValue;e.format=this.includeTimeValue?this.timeFormatValue:this.dateFormatValue,window.$(this.fieldTarget).daterangepicker({singleDatePicker:!0,timePicker:this.includeTimeValue,timePickerIncrement:5,autoUpdateInput:!1,autoApply:!0,minDate:!!this.futureOnlyValue&&new Date,locale:e,parentEl:u.default(this.element),drops:this.dropsValue?this.dropsValue:"down",timePicker24Hour:!t}),window.$(this.fieldTarget).on("apply.daterangepicker",this.applyDateToField.bind(this)),window.$(this.fieldTarget).on("cancel.daterangepicker",this.clearDate.bind(this)),window.$(this.fieldTarget).on("showCalendar.daterangepicker",this.showCalendar.bind(this)),this.pluginMainEl=this.fieldTarget,this.plugin=u.default(this.pluginMainEl).data("daterangepicker"),this.inlineValue&&this.element.classList.add("date-input--inline")}teardownPluginInstance(){void 0!==this.plugin&&(u.default(this.pluginMainEl).off("apply.daterangepicker"),u.default(this.pluginMainEl).off("cancel.daterangepicker"),u.default(this.pluginMainEl).off("showCalendar.daterangepicker"),this.plugin.remove())}showCalendar(){this.dispatch("show-calendar")}}V.targets=["field","hiddenField","clearButton"],V.values={includeTime:Boolean,futureOnly:Boolean,drops:String,inline:Boolean,dateFormat:String,timeFormat:String,isAmPm:Boolean,locale:{type:String,default:"en"},datetimeFormat:{type:String,default:"MM/DD/YYYY h:mm A"},pickerLocale:{type:Object,default:{}}};const F=[[h,"refine/add-controller.js"],[p,"refine/condition-form-controller.js"],[m,"refine/defaults-controller.js"],[f,"refine/delete-controller.js"],[g,"refine/filter-pills-controller.js"],[b,"refine/popup-controller.js"],[v,"refine/search-filter-controller.js"],[c,"refine/server-refresh-controller.js"],[I,"refine/state-controller.js"],[y,"refine/stored-filter-controller.js"],[S,"refine/toggle-controller.js"],[T,"refine/update-controller.js"],[V,"refine/date-controller.js"]].map(function(e){const t=e[0];return{identifier:d(e[1]),controllerConstructor:t}});e.AddController=h,e.ConditionFormController=p,e.DateController=V,e.DefaultsController=m,e.DeleteController=f,e.FilterPillsController=g,e.PopupController=b,e.SearchFilterController=v,e.ServerRefreshController=c,e.StateController=I,e.StoredFilterController=y,e.ToggleController=S,e.UpdateController=T,e.controllerDefinitions=F}); | ||
//# sourceMappingURL=refine-stimulus.umd.js.map |
import { Controller } from "@hotwired/stimulus" | ||
import moment from 'moment' | ||
import flatpickr from "flatpickr" | ||
require("flatpickr/dist/flatpickr.css") | ||
import { english } from "flatpickr/dist/l10n/default.js" | ||
import { Spanish } from "flatpickr/dist/l10n/es.js" | ||
import { Portuguese } from "flatpickr/dist/l10n/pt.js" | ||
require('daterangepicker/daterangepicker.css') | ||
const locales = { | ||
"en": english, | ||
"es": Spanish, | ||
"pt": Portuguese | ||
} | ||
// requires jQuery, moment, might want to consider a vanilla JS alternative | ||
import $ from 'jquery' // ensure jquery is loaded before daterangepicker | ||
import 'daterangepicker' | ||
/* | ||
Stimulus controller for initializing the datepicker. | ||
It defaults to flatpickr, but end-users can customize it by specifying the following: | ||
window.HammerstoneRefine.datePicker = { | ||
connect: function() {}, // runs bound to the Stimulus Controller instance at connect | ||
disconnect: function() {}, // runs bound to the Stimulus Controller instance at disconnect | ||
} | ||
*/ | ||
export default class extends Controller { | ||
static targets = [ | ||
'field', | ||
'hiddenField' | ||
'hiddenField', | ||
'clearButton', | ||
] | ||
static values = { | ||
includeTime: Boolean, | ||
futureOnly: Boolean, | ||
drops: String, | ||
inline: Boolean, | ||
dateFormat: String, | ||
timeFormat: String, | ||
isAmPm: Boolean, | ||
locale: { type: String, default: 'en' }, | ||
dateFormat: { type: String, default: 'MM/DD/YYYY' }, | ||
datetimeFormat: { type: String, default: 'MM/DD/YYYY h:mm A' }, | ||
pickerLocale: { type: Object, default: {} }, | ||
} | ||
connect() { | ||
if (window.HammerstoneRefine?.datePicker) { | ||
window.HammerstoneRefine.datePicker.connect.bind(this)() | ||
} else { | ||
this.defaultConnect() | ||
} | ||
this.initPluginInstance() | ||
} | ||
disconnect() { | ||
if (window.HammerstoneRefine?.datePicker) { | ||
window.HammerstoneRefine.datePicker.disconnect.bind(this)() | ||
} else { | ||
this.defaultDisconnect() | ||
} | ||
this.teardownPluginInstance() | ||
} | ||
defaultConnect() { | ||
const localeCode = ( this.localeValue?.slice(0,2) || "en" ) | ||
this.plugin = flatpickr(this.fieldTarget, { | ||
minDate: this.futureOnlyValue ? new Date() : null, | ||
dateFormat: 'YYYY-MM-DD', | ||
locale: locales[localeCode], | ||
defaultDate: this.hiddenFieldTarget.value, | ||
parseDate: (datestr, format) => { | ||
return moment(datestr, format, true).toDate() | ||
}, | ||
formatDate: (date, format) => { | ||
const momentDate = moment(date) | ||
return momentDate.format(format) | ||
}, | ||
onChange: (selectedDates, dateStr, instance) => { | ||
const format = this.includeTimeValue ? this.datetimeFormatValue : this.dateFormatValue | ||
// display format | ||
this.fieldTarget.value = instance.formatDate(selectedDates[0], format) | ||
// internal format saved in db | ||
this.hiddenFieldTarget.value = instance.formatDate(selectedDates[0], 'YYYY-MM-DD') | ||
this.hiddenFieldTarget.dispatchEvent(new Event('change', { bubbles: true })) | ||
}, | ||
onReady: [ | ||
() => { | ||
const momentDate = moment(this.hiddenFieldTarget.value) | ||
if (momentDate.isValid()) { | ||
const format = this.includeTimeValue ? this.datetimeFormatValue : this.dateFormatValue | ||
this.fieldTarget.value = momentDate.format(format) | ||
} | ||
}, | ||
], | ||
clearDate(event) { | ||
// don't submit the form, unless it originated from the cancel/clear button | ||
event.preventDefault() | ||
window.$(this.fieldTarget).val('') | ||
this.dispatch('value-cleared') | ||
} | ||
applyDateToField(event, picker) { | ||
const format = this.includeTimeValue ? this.timeFormatValue : this.dateFormatValue | ||
const momentVal = picker | ||
? moment(picker.startDate.toISOString()) | ||
: moment(this.fieldTarget.value, 'YYYY-MM-DDTHH:mm').format('YYYY-MM-DDTHH:mm') | ||
const displayVal = momentVal.format(format) | ||
const dataVal = this.includeTimeValue ? momentVal.toISOString(true) : momentVal.format('YYYY-MM-DD') | ||
this.fieldTarget.value = displayVal | ||
this.hiddenFieldTarget.value = dataVal | ||
// bubble up a change event when the input is updated for other listeners | ||
window.$(this.fieldTarget).trigger('change', picker) | ||
// emit native change event | ||
this.hiddenFieldTarget.dispatchEvent(new Event('change', { detail: picker, bubbles: true })) | ||
} | ||
initPluginInstance() { | ||
const localeValues = this.pickerLocaleValue | ||
const isAmPm = this.isAmPmValue | ||
localeValues['format'] = this.includeTimeValue ? this.timeFormatValue : this.dateFormatValue | ||
window.$(this.fieldTarget).daterangepicker({ | ||
singleDatePicker: true, | ||
timePicker: this.includeTimeValue, | ||
timePickerIncrement: 5, | ||
autoUpdateInput: false, | ||
autoApply: true, | ||
minDate: this.futureOnlyValue ? new Date() : false, | ||
locale: localeValues, | ||
parentEl: $(this.element), | ||
drops: this.dropsValue ? this.dropsValue : 'down', | ||
timePicker24Hour: !isAmPm, | ||
}) | ||
window.$(this.fieldTarget).on('apply.daterangepicker', this.applyDateToField.bind(this)) | ||
window.$(this.fieldTarget).on('cancel.daterangepicker', this.clearDate.bind(this)) | ||
window.$(this.fieldTarget).on('showCalendar.daterangepicker', this.showCalendar.bind(this)) | ||
this.pluginMainEl = this.fieldTarget | ||
this.plugin = $(this.pluginMainEl).data('daterangepicker') // weird | ||
if (this.inlineValue) { | ||
this.element.classList.add('date-input--inline') | ||
} | ||
} | ||
teardownPluginInstance() { | ||
if (this.plugin === undefined) { | ||
return | ||
} | ||
defaultDisconnect() { | ||
this.plugin.destroy() | ||
$(this.pluginMainEl).off('apply.daterangepicker') | ||
$(this.pluginMainEl).off('cancel.daterangepicker') | ||
$(this.pluginMainEl).off('showCalendar.daterangepicker') | ||
// revert to original markup, remove any event listeners | ||
this.plugin.remove() | ||
} | ||
showCalendar() { | ||
this.dispatch('show-calendar') | ||
} | ||
} |
import ServerRefreshController from './server-refresh-controller' | ||
import { debounce } from 'lodash' | ||
import flatpickr from 'flatpickr' | ||
@@ -5,0 +4,0 @@ export default class extends ServerRefreshController { |
{ | ||
"name": "@hammerstone/refine-stimulus", | ||
"version": "2.6.14", | ||
"version": "2.6.15", | ||
"description": "Refine is a flexible query builder for your apps. It lets your users filter down to exactly what they're looking for. Completely configured on the backend.", | ||
@@ -70,8 +70,9 @@ "browserslist": [ | ||
"@rails/request.js": "^0.0.6", | ||
"flatpickr": "^4.6.13", | ||
"daterangepicker": "^3.1.0", | ||
"jquery": "^3.5.1", | ||
"jquery-events-to-dom-events": "^1.1.0", | ||
"moment": "2.29.1", | ||
"lodash": "^4.0.8" | ||
"lodash": "^4.0.8", | ||
"moment": "^2.29.4" | ||
}, | ||
"peerDependencies": {} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
331987
2966
7
+ Addeddaterangepicker@^3.1.0
+ Addedjquery@^3.5.1
+ Addeddaterangepicker@3.1.0(transitive)
+ Addedjquery@3.7.1(transitive)
+ Addedmoment@2.30.1(transitive)
- Removedflatpickr@^4.6.13
- Removedflatpickr@4.6.13(transitive)
- Removedmoment@2.29.1(transitive)
Updatedmoment@^2.29.4