refine-rails 2.9.5 → 2.9.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40c314d4829c5c14ed3734c58f3fa00f6d48dffdb792c653f7be6baae19047a7
4
- data.tar.gz: '096fbf9bc50779fa1cfd216f1e47d8f7429d0e1971c1516209a50759ab4774dd'
3
+ metadata.gz: f48cb1ff6dea99293bd848f04f892c7dadf1fcc3fff3a6d9ef6accdf824b260a
4
+ data.tar.gz: 3282e69fdef72d6a2f9bd666728e8906f023a7c278633ac8e3cc6e8863dda552
5
5
  SHA512:
6
- metadata.gz: 63b4ea7e912c91fe2c360ad3aea673b8d5312d8a5ae8217749547e4e85f06d161e6dbf52c7489693a93ed35b639862464d59153ea2ba4d4c20e836e1e0ef3e36
7
- data.tar.gz: ac9045b44e88dcdd2d98643d832fe7ffd03c7bebf1e1c7d853f06604a37a5144ef8ff55d735cbdd170661d6f8e43066109a125b3c43507ffdfd0610f0cdf331e
6
+ metadata.gz: 9602d66ade646f51670d9114d823dc39842f19e9dabf0e1f9be8fd93da069dbbecd109e2eedfafbda590337ed38e38dded9fc978ad83c69e8f58329c64748883
7
+ data.tar.gz: 6e385cd33aa25009d394a35632f3027142cff7c250fcb987fe7d3cc71fdb30011ebbf3f7b369b44a7bac3a48985cf47dd12a457f3d8797869f91a777e3c1d57c
data/README.md CHANGED
@@ -19,15 +19,15 @@ Instead of importing the plain `index.css`, include the raw tailwind file in you
19
19
 
20
20
  ```css
21
21
  /* in application.css */
22
- @import '@hammerstone/refine-stimulus/app/assets/stylesheets/index.tailwind.css';
22
+ @import '@clickfunnels/refine-stimulus/app/assets/stylesheets/index.tailwind.css';
23
23
  ```
24
24
 
25
25
  ### Errors
26
26
  You may have to restart your server if you encounter the error:
27
27
  ```
28
- NameError (uninitialized constant ApplicationController::Hammerstone
28
+ NameError (uninitialized constant ApplicationController::Refine
29
29
  web |
30
- web | include Hammerstone::FilterApplicationController
30
+ web | include Refine::FilterApplicationController
31
31
  ```
32
32
 
33
33
  ## Custom configuration
@@ -91,7 +91,7 @@ event.detail includes the following properties:
91
91
 
92
92
  #### filter-stored: This event is emitted when the filter has been saved to the database (i.e. the user clicked "Save Filter").
93
93
  event.detail includes the following properties
94
- storedFilterId: the primary key of the associated record in the hammerstone_refine_stored_filters_table
94
+ storedFilterId: the primary key of the associated record in the refine_stored_filters_table
95
95
 
96
96
  ## Forcing validations
97
97
  To force validations, make a POST request to /refine/blueprints with the following JSON payload:
@@ -120,7 +120,7 @@ const response = await fetch('/refine/blueprints', {
120
120
  ```
121
121
 
122
122
  #### Fetching a stable_id from the server
123
- If you need to get a URL-encoded stable_id for a filter without relying on the filter-stabilized event, you can make a PUT request to /hammerstone/update_stable_id with the following JSON payload:
123
+ If you need to get a URL-encoded stable_id for a filter without relying on the filter-stabilized event, you can make a PUT request to /refine/update_stable_id with the following JSON payload:
124
124
  - filter: the ruby class name of the filter
125
125
  - blueprint: JSON stringified version of the current blueprint
126
126
 
@@ -144,52 +144,6 @@ const response = await fetch(this.updateStableIdUrlValue, {
144
144
  If the filter is valid, the server responds 200 OK with the stable_id in the JSON response
145
145
  If the filter is not valid, the server responds 422 Unprocessable Entity with an errors array in the JSON response
146
146
 
147
- ## Customizing the datepicker
148
- By default date filters use [flatpickr](https://flatpickr.js.org/getting-started/). End users can specify an alternative datepicker in their application javascript. Here's an example using the daterangepicker that ships with Bullet Train:
149
-
150
- ```javascript
151
- import $ from 'jquery' // ensure jquery is loaded before daterangepicker
152
- import 'daterangepicker'
153
- import 'daterangepicker/daterangepicker.css'
154
-
155
- window.HammerstoneRefine ||= {}
156
- window.HammerstoneRefine.datePicker = {
157
- connect: function() {
158
- $(this.fieldTarget).daterangepicker({
159
- singleDatePicker: true,
160
- autoUpdateInput: false,
161
- minDate: this.futureOnlyValue ? new Date() : false,
162
- locale: {
163
- cancelLabel: "Cancel",
164
- applyLabel: "Apply",
165
- format: 'MM/DD/YYYY',
166
- },
167
- parentEl: $(this.element),
168
- drops: this.dropsValue ? this.dropsValue : 'down',
169
- })
170
-
171
- $(this.fieldTarget).on('apply.daterangepicker', (event, picker) => {
172
- const format =
173
- $(this.fieldTarget).val(picker.startDate.format('MM/DD/YYYY'))
174
- $(this.hiddenFieldTarget).val(picker.startDate.format('YYYY-MM-DD'))
175
- this.hiddenFieldTarget.dispatchEvent(new Event('change', {bubbles: true}))
176
- })
177
-
178
- this.plugin = $(this.fieldTarget).data('daterangepicker')
179
- },
180
- disconnect: function() {
181
- if (this.plugin === undefined) {
182
- return
183
- }
184
-
185
- $(this.fieldTarget).off('apply.daterangepicker')
186
-
187
- // revert to original markup, remove any event listeners
188
- this.plugin.remove()
189
- }
190
- }
191
- ````
192
-
193
147
  ## Customizing Available Stored Filters
194
148
 
195
149
  By default the list of available stored filters is scoped to the type of the current filter. You can add additional scoping by assigning a Proc to `Refine::Rails.configuration.stored_filter_scope` in an initializer.
@@ -247,14 +201,14 @@ yarn build --watch # leave this running to automatically rebuild when you change
247
201
  2. From your application's folder run:
248
202
 
249
203
  ```sh
250
- yarn link "@hammerstone/refine-stimulus"
204
+ yarn link "@clickfunnels/refine-stimulus"
251
205
  ```
252
206
 
253
207
  3. Restart your asset build server (webpacker/esbuild/etc)
254
208
 
255
209
  When you're ready to switch back to the published npm package, run:
256
210
  ```sh
257
- yarn unlink "@hammerstone/refine-stimulus"
211
+ yarn unlink "@clickfunnels/refine-stimulus"
258
212
  ```
259
213
 
260
214
  #### Troubleshooting yarn link
@@ -267,7 +221,7 @@ Note that theoretically, any changes you make to the javascript and css assets s
267
221
  5. Run `bin/rails assets:clean` from your app's directory and restart servers
268
222
 
269
223
  If none of the above steps work, try tearing down the package link and setting it up again:
270
- 1. Run `yarn link "@hammerstone-stimulus"` from your app's directory and shut down all servers.
224
+ 1. Run `yarn link "@clickfunnels-stimulus"` from your app's directory and shut down all servers.
271
225
  2. Run `yarn unlink` from the gem directory.
272
226
  3. Redo the steps listed in this section for setting up the linked package
273
227
  4. Start up your web and asset servers
@@ -293,7 +247,7 @@ From the directory of the project including this package:
293
247
 
294
248
  ```bash
295
249
 
296
- yalc link @hammerstone/refine-stimulus
250
+ yalc link @clickfunnels/refine-stimulus
297
251
  ```
298
252
 
299
253
  When you make local updates to the package:
@@ -312,30 +266,34 @@ Running `yarn` again from your project's directory will revert back to the publi
312
266
  3. in `refine-rails` repo follow all yalc steps below -> you should see this message if successful
313
267
 
314
268
  ```
269
+ <<<<<<< HEAD
315
270
  @hammerstone/refine-stimulus@2.4.2 published in store.
316
- Pushing @hammerstone/refine-stimulus@2.4.2 in /Users/colleenschnettler/Documents/Documents/Developer/Hammerstone/berry-refine-demo-clean
317
- Package @hammerstone/refine-stimulus@2.4.2 linked ==> /Users/colleenschnettler/Documents/Documents/Developer/Hammerstone/berry-refine-demo-clean/node_modules/@hammerstone/refine-stimulus
271
+ Pushing @hammerstone/refine-stimulus@2.4.2 in [path]
272
+ Package @hammerstone/refine-stimulus@2.4.2 linked ==> [path]
273
+ =======
274
+ @clickfunnels/refine-stimulus@2.4.2 published in store.
275
+ Pushing @clickfunnels/refine-stimulus@2.4.2 in /Users/colleenschnettler/Documents/Documents/Developer/Hammerstone/berry-refine-demo-clean
276
+ Package @clickfunnels/refine-stimulus@2.4.2 linked ==> /Users/colleenschnettler/Documents/Documents/Developer/Hammerstone/berry-refine-demo-clean/node_modules/@clickfunnels/refine-stimulus
277
+ >>>>>>> c30f86b (readme updates)
318
278
  ```
319
279
  4. Restart server
320
280
 
321
281
  ## Bullet Train Installation
322
282
  Add ruby gem
323
283
  ```
324
- source "https://yourAPIKey@gem.fury.io/hammerstonedev" do
325
- gem "refine-rails"
326
- end
284
+ gem "refine-rails"
327
285
  ```
328
286
 
329
287
  Installing the JavaScript package:
330
288
 
331
289
  ```bash
332
- $ yarn add @hammerstone/refine-stimulus
290
+ $ yarn add @clickfunnels/refine-stimulus
333
291
  ```
334
292
 
335
293
  In `app/javascript/controllers/index.js` add
336
294
 
337
295
  ```js
338
- import { controllerDefinitions as refineControllers } from "@hammerstone/refine-stimulus"
296
+ import { controllerDefinitions as refineControllers } from "@clickfunnels/refine-stimulus"
339
297
  application.load(refineControllers)
340
298
  ```
341
299
 
@@ -1,2 +1,2 @@
1
- import{Controller as e}from"@hotwired/stimulus";import{FetchRequest as t}from"@rails/request.js";import{useClickOutside as r}from"stimulus-use";import{delegate as i,abnegate as n}from"jquery-events-to-dom-events";import{isEqual as s,debounce as l}from"lodash";import o from"moment";import a from"jquery";import"daterangepicker";function d(e){const t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class u 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:{"refine_filters_builder[filter_class]":r.state.filterName,"refine_filters_builder[blueprint_json]":JSON.stringify(r.state.blueprint),"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 u{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:{"refine_filters_builder[filter_class]":e.state.filterName,"refine_filters_builder[blueprint_json]":JSON.stringify(e.state.blueprint),"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{refresh(e){try{const e=this,r=document.getElementById(e.formIdValue),i=new FormData(r),n=new t("GET",e.urlValue,{query:i,responseKind:"turbo-stream"});return Promise.resolve(n.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}h.values={url:String,formId: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 m extends u{criterion(){const{state:e,criterionIdValue:t}=this;e.deleteCriterion(t),this.refreshFromServer()}}m.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 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({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{connect(){r(this),this.boundHandleKeyUp=this.handleKeyUp.bind(this),document.addEventListener("keyup",this.boundHandleKeyUp)}disconnect(){document.removeEventListener("keyup",this.boundHandleKeyUp)}show(e){e.preventDefault(),this.frameTarget.src=this.srcValue,this.isOpenValue=!0}hide(e){this.isOpenValue&&(null==e||e.preventDefault(),this.frameTarget.innerHTML="",this.isOpenValue=!1)}clickOutside(e){this.hide(e)}handleKeyUp(e){"Escape"!==e.key&&"Esc"!==e.key||this.hide(e)}}g.targets=["frame"],g.values={src:String,isOpen:{type:Boolean,default:!1}};class b 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({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)},y=(e,t,r)=>{var i;const n=null==r?void 0:r.component,s=(null==r?void 0:r.meta)||{clauses:[],options:{}},l=(null==r?void 0:r.refinements)||[],{clauses:o,options:a}=s;let d;d="option-condition"===n?a[0]?[a[0].id]:[]:void 0;let u={clause:null==(i=o[0])?void 0:i.id,selected:d};return l.forEach(e=>{const{meta:t,component:r}=e,{clauses:i,options:n}=t;let s;s="option-condition"===r?n[0]?[n[0].id]:[]:void 0,u[e.id]={clause:i[0].id,selected:s}}),{depth:t,type:"criterion",condition_id:e,input:u}};class w 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(){n("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(y(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"},y(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,s=i&&"or"===i.word||!i,l=n||!r,o=l&&s;r||i?t.splice(o&&n?e-1:o&&!r||l&&!s?e:e-1,2):this.blueprint=[],v(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(y));const n=this.blueprint[e],l=y(t,i.depth,r);return!s(n,l)&&(this.blueprint[e]=l,v(this.element,{blueprint:this.blueprint,formId:this.formIdValue}),!0)}updateInput(e,t,r){const{blueprint:i}=this,n=i[e],s=(r=r||"input").split(", ");s.length>1?n[s[0]][s[1]]={...n[s[0]][s[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{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{submit(e){e.preventDefault(),this.element.submit()}}class S extends e{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}S.targets=["content"];class T extends e{submit(e){try{const r=this;e.preventDefault();const i=new t(r.element.method||"POST",r.element.action,{responseKind:"turbo-stream",body:new FormData(r.element)});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class V extends e{visit(e){try{const r=this;e.preventDefault();const i=new t(r.element.dataset.turboMethod||"GET",r.element.href,{responseKind:"turbo-stream"});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class P extends e{filter(e){const t=e.currentTarget.value.toLowerCase(),r=new Set;this.listItemTargets.forEach(e=>{e.dataset.listItemValue.toLowerCase().includes(t)?(e.hidden=!1,r.add(e.dataset.category)):e.hidden=!0}),this.categoryTargets.forEach(e=>{e.hidden=!r.has(e.innerHTML)})}}P.targets=["listItem","category"];class E extends u{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,s=e.target.dataset;n.updateInput(i,{[r=r||s.inputKey||"value"]:t=t||e.target.value},s.inputId)}condition(e){const{criterionIdValue:t,state:r}=this,i=e.target;let n=i.value;n||(n=i.querySelector("select").value);const s=this.state.conditionConfigFor(n);r.replaceCriterion(t,n,s)&&this.refreshFromServer()}cancelEnter(e){"Enter"===e.code&&(e.preventDefault(),e.stopPropagation())}}E.values={criterionId:Number},require("daterangepicker/daterangepicker.css");class F 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),s=this.includeTimeValue?i.toISOString(!0):i.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:a(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(this.pluginMainEl).data("daterangepicker"),this.inlineValue&&this.element.classList.add("date-input--inline")}teardownPluginInstance(){void 0!==this.plugin&&(a(this.pluginMainEl).off("apply.daterangepicker"),a(this.pluginMainEl).off("cancel.daterangepicker"),a(this.pluginMainEl).off("showCalendar.daterangepicker"),this.plugin.remove())}showCalendar(){this.dispatch("show-calendar")}}F.targets=["field","hiddenField","clearButton"],F.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 j=[[c,"refine/add-controller.js"],[h,"refine/criterion-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"],[u,"refine/server-refresh-controller.js"],[w,"refine/state-controller.js"],[I,"refine/stored-filter-controller.js"],[C,"refine/submit-form-controller.js"],[S,"refine/toggle-controller.js"],[T,"refine/turbo-stream-form-controller.js"],[V,"refine/turbo-stream-link-controller.js"],[P,"./refine/typeahead-list-controller.js"],[E,"refine/update-controller.js"],[F,"refine/date-controller.js"]].map(function(e){const t=e[0];return{identifier:d(e[1]),controllerConstructor:t}});export{c as AddController,h as CriterionFormController,F as DateController,p as DefaultsController,m as DeleteController,f as FilterPillsController,g as PopupController,b as SearchFilterController,u as ServerRefreshController,w as StateController,I as StoredFilterController,C as SubmitForm,S as ToggleController,T as TurboStreamFormController,V as TurboStreamLinkController,P as TypeaheadListController,E as UpdateController,j as controllerDefinitions};
1
+ import{Controller as e}from"@hotwired/stimulus";import{FetchRequest as t}from"@rails/request.js";import{useClickOutside as r}from"stimulus-use";import{delegate as i,abnegate as n}from"jquery-events-to-dom-events";import{isEqual as s,debounce as l}from"lodash";import o from"moment";import a from"jquery";import"daterangepicker";function d(e){const t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class u 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:{"refine_filters_builder[filter_class]":r.state.filterName,"refine_filters_builder[blueprint_json]":JSON.stringify(r.state.blueprint),"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 u{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:{"refine_filters_builder[filter_class]":e.state.filterName,"refine_filters_builder[blueprint_json]":JSON.stringify(e.state.blueprint),"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{refresh(e){try{const e=this,r=document.getElementById(e.formIdValue),i=new FormData(r);console.log("in criterion-form refresh event"),console.log(e),console.log(i);const n=new t("GET",e.urlValue,{query:i,responseKind:"turbo-stream"});return Promise.resolve(n.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}h.values={url:String,formId: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 m extends u{criterion(){const{state:e,criterionIdValue:t}=this;e.deleteCriterion(t),this.refreshFromServer()}}m.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 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({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{connect(){r(this),this.boundHandleKeyUp=this.handleKeyUp.bind(this),document.addEventListener("keyup",this.boundHandleKeyUp)}disconnect(){document.removeEventListener("keyup",this.boundHandleKeyUp)}show(e){console.log("In Popup Show"),e.preventDefault(),this.frameTarget.src=this.srcValue,this.isOpenValue=!0}hide(e){this.isOpenValue&&(null==e||e.preventDefault(),this.frameTarget.innerHTML="",this.isOpenValue=!1)}clickOutside(e){this.hide(e)}handleKeyUp(e){"Escape"!==e.key&&"Esc"!==e.key||this.hide(e)}}g.targets=["frame"],g.values={src:String,isOpen:{type:Boolean,default:!1}};class b 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({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)},y=(e,t,r)=>{var i;const n=null==r?void 0:r.component,s=(null==r?void 0:r.meta)||{clauses:[],options:{}},l=(null==r?void 0:r.refinements)||[],{clauses:o,options:a}=s;let d;d="option-condition"===n?a[0]?[a[0].id]:[]:void 0;let u={clause:null==(i=o[0])?void 0:i.id,selected:d};return l.forEach(e=>{const{meta:t,component:r}=e,{clauses:i,options:n}=t;let s;s="option-condition"===r?n[0]?[n[0].id]:[]:void 0,u[e.id]={clause:i[0].id,selected:s}}),{depth:t,type:"criterion",condition_id:e,input:u}};class w 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(){n("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(y(t.id,1,t)),v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}addCriterion(e){console.log("Add criteria");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"},y(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,s=i&&"or"===i.word||!i,l=n||!r,o=l&&s;r||i?t.splice(o&&n?e-1:o&&!r||l&&!s?e:e-1,2):this.blueprint=[],v(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(y));const n=this.blueprint[e],l=y(t,i.depth,r);return!s(n,l)&&(this.blueprint[e]=l,v(this.element,{blueprint:this.blueprint,formId:this.formIdValue}),!0)}updateInput(e,t,r){const{blueprint:i}=this,n=i[e],s=(r=r||"input").split(", ");s.length>1?n[s[0]][s[1]]={...n[s[0]][s[1]],...t}:n[r]={...n[r],...t},v(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}clearCriteria(){console.log("In clearCriteria"),v(this.element,{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{submit(e){e.preventDefault(),this.element.submit()}}class S extends e{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}S.targets=["content"];class T extends e{submit(e){try{const r=this;e.preventDefault();const i=new t(r.element.method||"POST",r.element.action,{responseKind:"turbo-stream",body:new FormData(r.element)});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class V extends e{visit(e){try{const r=this;e.preventDefault();const i=new t(r.element.dataset.turboMethod||"GET",r.element.href,{responseKind:"turbo-stream"});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class P extends e{filter(e){const t=e.currentTarget.value.toLowerCase(),r=new Set;this.listItemTargets.forEach(e=>{e.dataset.listItemValue.toLowerCase().includes(t)?(e.hidden=!1,r.add(e.dataset.category)):e.hidden=!0}),this.categoryTargets.forEach(e=>{e.hidden=!r.has(e.innerHTML)})}}P.targets=["listItem","category"];class E extends u{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,s=e.target.dataset;n.updateInput(i,{[r=r||s.inputKey||"value"]:t=t||e.target.value},s.inputId)}condition(e){const{criterionIdValue:t,state:r}=this,i=e.target;let n=i.value;n||(n=i.querySelector("select").value);const s=this.state.conditionConfigFor(n);r.replaceCriterion(t,n,s)&&this.refreshFromServer()}cancelEnter(e){"Enter"===e.code&&(e.preventDefault(),e.stopPropagation())}}E.values={criterionId:Number},require("daterangepicker/daterangepicker.css");class F 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),s=this.includeTimeValue?i.toISOString(!0):i.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:a(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(this.pluginMainEl).data("daterangepicker"),this.inlineValue&&this.element.classList.add("date-input--inline")}teardownPluginInstance(){void 0!==this.plugin&&(a(this.pluginMainEl).off("apply.daterangepicker"),a(this.pluginMainEl).off("cancel.daterangepicker"),a(this.pluginMainEl).off("showCalendar.daterangepicker"),this.plugin.remove())}showCalendar(){this.dispatch("show-calendar")}}F.targets=["field","hiddenField","clearButton"],F.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:{}}};class j extends e{clear(){console.log("Clearing criteria");const{state:e}=this;e.clearCriteria(),this.refreshFromServer()}}const _=[[c,"refine/add-controller.js"],[h,"refine/criterion-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"],[u,"refine/server-refresh-controller.js"],[w,"refine/state-controller.js"],[I,"refine/stored-filter-controller.js"],[C,"refine/submit-form-controller.js"],[S,"refine/toggle-controller.js"],[T,"refine/turbo-stream-form-controller.js"],[V,"refine/turbo-stream-link-controller.js"],[P,"./refine/typeahead-list-controller.js"],[E,"refine/update-controller.js"],[F,"refine/date-controller.js"],[j,"refine/clear-criteria-controller.js"]].map(function(e){const t=e[0];return{identifier:d(e[1]),controllerConstructor:t}});export{c as AddController,j as ClearCriteriaController,h as CriterionFormController,F as DateController,p as DefaultsController,m as DeleteController,f as FilterPillsController,g as PopupController,b as SearchFilterController,u as ServerRefreshController,w as StateController,I as StoredFilterController,C as SubmitForm,S as ToggleController,T as TurboStreamFormController,V as TurboStreamLinkController,P as TypeaheadListController,E as UpdateController,_ as controllerDefinitions};
2
2
  //# sourceMappingURL=refine-stimulus.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"refine-stimulus.esm.js","sources":["../../../node_modules/@hotwired/stimulus-webpack-helpers/dist/stimulus-webpack-helpers.js","../../javascript/controllers/refine/server-refresh-controller.js","../../javascript/controllers/refine/add-controller.js","../../javascript/controllers/refine/criterion-form-controller.js","../../javascript/controllers/refine/defaults-controller.js","../../javascript/controllers/refine/delete-controller.js","../../javascript/controllers/refine/filter-pills-controller.js","../../javascript/controllers/refine/popup-controller.js","../../javascript/controllers/refine/search-filter-controller.js","../../javascript/refine/helpers/index.js","../../javascript/controllers/refine/state-controller.js","../../javascript/controllers/refine/stored-filter-controller.js","../../javascript/controllers/refine/submit-form-controller.js","../../javascript/controllers/refine/toggle-controller.js","../../javascript/controllers/refine/turbo-stream-form-controller.js","../../javascript/controllers/refine/turbo-stream-link-controller.js","../../javascript/controllers/refine/typeahead-list-controller.js","../../javascript/controllers/refine/update-controller.js","../../javascript/controllers/refine/date-controller.js","../../javascript/controllers/index.js"],"sourcesContent":["/*\nStimulus Webpack Helpers 1.0.0\nCopyright © 2021 Basecamp, LLC\n */\nfunction definitionsFromContext(context) {\n return context.keys()\n .map((key) => definitionForModuleWithContextAndKey(context, key))\n .filter((value) => value);\n}\nfunction definitionForModuleWithContextAndKey(context, key) {\n const identifier = identifierForContextKey(key);\n if (identifier) {\n return definitionForModuleAndIdentifier(context(key), identifier);\n }\n}\nfunction definitionForModuleAndIdentifier(module, identifier) {\n const controllerConstructor = module.default;\n if (typeof controllerConstructor == \"function\") {\n return { identifier, controllerConstructor };\n }\n}\nfunction identifierForContextKey(key) {\n const logicalName = (key.match(/^(?:\\.\\/)?(.+)(?:[_-]controller\\..+?)$/) || [])[1];\n if (logicalName) {\n return logicalName.replace(/_/g, \"-\").replace(/\\//g, \"--\");\n }\n}\n\nexport { definitionForModuleAndIdentifier, definitionForModuleWithContextAndKey, definitionsFromContext, identifierForContextKey };\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\n\n// Base class for controllers that reload form content from the server\nexport default class extends Controller {\n connect() {\n this.state.finishUpdate()\n }\n\n get state() {\n let currentElement = this.element\n\n while(currentElement !== document.body) {\n if (currentElement.matches('[data-controller~=\"refine--state\"]'))\n return this.application.getControllerForElementAndIdentifier(currentElement, 'refine--state')\n else {\n currentElement = currentElement.parentNode\n }\n }\n\n return null\n }\n\n async refreshFromServer(options = {}) {\n const { includeErrors } = options\n this.state.startUpdate()\n const request = new FetchRequest(\n \"GET\",\n this.state.refreshUrlValue,\n {\n responseKind: \"turbo-stream\",\n query: {\n \"refine_filters_builder[filter_class]\": this.state.filterName,\n \"refine_filters_builder[blueprint_json]\": JSON.stringify(this.state.blueprint),\n \"refine_filters_builder[client_id]\": this.state.clientIdValue,\n include_errors: !!includeErrors\n }\n }\n )\n await request.perform()\n }\n}\n","import ServerRefreshController from './server-refresh-controller'\nimport { FetchRequest } from '@rails/request.js'\n\nexport default class extends ServerRefreshController {\n static values = {\n previousCriterionId: Number,\n }\n\n async criterion() {\n const isValid = await this.validateBlueprint()\n if (isValid) {\n this.state.addCriterion(this.previousCriterionIdValue)\n }\n this.refreshFromServer({includeErrors: !isValid})\n }\n\n async group() {\n const isValid = await this.validateBlueprint()\n if (isValid) {\n this.state.addGroup()\n }\n this.refreshFromServer({includeErrors: !isValid})\n }\n\n async validateBlueprint(blueprint) {\n const { state } = this\n\n const request = new FetchRequest(\n \"GET\",\n this.state.validateBlueprintUrlValue,\n {\n query: {\n \"refine_filters_builder[filter_class]\": this.state.filterName,\n \"refine_filters_builder[blueprint_json]\": JSON.stringify(this.state.blueprint),\n \"refine_filters_builder[client_id]\": this.state.clientIdValue\n }\n }\n )\n const response = await request.perform()\n return response.ok\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\n/*\n This controller handles criteria forms\n (refine/inline/criteria/new|edit)\n*/\nexport default class extends Controller {\n static values = {\n url: String,\n formId: String\n }\n\n async refresh(_event) {\n // update the url with params from the form\n const formElement = document.getElementById(this.formIdValue)\n const formData = new FormData(formElement)\n\n const request = new FetchRequest(\n \"GET\",\n this.urlValue,\n {\n query: formData,\n responseKind: \"turbo-stream\"\n }\n )\n const response = await request.perform()\n }\n\n\n\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n static values = {\n criterionId: Number,\n input: Object,\n };\n\n connect() {\n this.state = this.getStateController()\n\n this.state.updateInput(\n this.criterionIdValue,\n this.inputValue,\n );\n }\n\n getStateController() {\n let currentElement = this.element\n\n while(currentElement !== document.body) {\n const controller = this.application.getControllerForElementAndIdentifier(currentElement, 'refine--state')\n if (controller) {\n return controller\n } else {\n currentElement = currentElement.parentNode\n }\n }\n\n return null\n }\n}\n","import ServerRefreshController from './server-refresh-controller';\n\nexport default class extends ServerRefreshController {\n static values = {\n criterionId: Number,\n }\n\n criterion() {\n const { state, criterionIdValue } = this;\n state.deleteCriterion(criterionIdValue);\n this.refreshFromServer()\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\nexport default class extends Controller {\n static values = {\n submitUrl: String\n }\n\n connect() {\n const urlParams = new URLSearchParams(window.location.search)\n this.existingParams = urlParams\n this.existingParams.delete('stable_id')\n }\n\n delete(event) {\n const { criterionId } = event.currentTarget.dataset\n var index = parseInt(criterionId)\n this.stateController.deleteCriterion(index)\n this.reloadPage()\n }\n\n async reloadPage() {\n const {blueprint} = this.stateController\n const request = new FetchRequest(\n \"POST\",\n this.submitUrlValue,\n {\n responseKind: \"turbo-stream\",\n body: JSON.stringify({\n refine_filters_builder: {\n filter_class: this.stateController.filterName,\n blueprint_json: JSON.stringify(blueprint),\n client_id: this.stateController.clientIdValue\n }\n })\n }\n )\n await request.perform()\n }\n\n redirectToStableId(stableId) {\n const params = new URLSearchParams()\n if (stableId) {\n params.append('stable_id', stableId)\n }\n const allParams = new URLSearchParams({\n ...Object.fromEntries(this.existingParams),\n ...Object.fromEntries(params),\n }).toString()\n const url = `${window.location.pathname}?${allParams}`\n\n history.pushState({}, document.title, url)\n window.location.reload()\n }\n\n get stateController() {\n return this.element.refineStateController\n }\n\n get stabilizeFilterController() {\n return this.element.stabilizeFilterController\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { useClickOutside } from 'stimulus-use'\n\n// simple controller to hide/show the filter modal\nexport default class extends Controller {\n static targets = [\"frame\"]\n\n static values = {\n src: String,\n isOpen: {type: Boolean, default: false}\n }\n\n connect() {\n useClickOutside(this)\n this.boundHandleKeyUp = this.handleKeyUp.bind(this)\n document.addEventListener(\"keyup\", this.boundHandleKeyUp)\n }\n\n disconnect() {\n document.removeEventListener(\"keyup\", this.boundHandleKeyUp)\n }\n\n show(event) {\n event.preventDefault()\n this.frameTarget.src = this.srcValue;\n this.isOpenValue = true\n }\n\n hide(event) {\n if (this.isOpenValue) {\n event?.preventDefault()\n this.frameTarget.innerHTML = \"\";\n this.isOpenValue = false\n }\n }\n\n clickOutside(event) {\n this.hide(event)\n }\n\n handleKeyUp(event) {\n if (event.key === \"Escape\" || event.key === \"Esc\") {\n this.hide(event)\n }\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\nexport default class extends Controller {\n static values = {\n submitUrl: String\n }\n\n\n search(event) {\n event.preventDefault()\n this.submitFilter()\n document.activeElement.blur()\n }\n\n async submitFilter() {\n const {blueprint} = this.stateController\n const request = new FetchRequest(\n \"POST\",\n this.submitUrlValue,\n {\n responseKind: \"turbo-stream\",\n body: JSON.stringify({\n refine_filters_builder: {\n filter_class: this.stateController.filterName,\n blueprint_json: JSON.stringify(blueprint),\n client_id: this.stateController.clientIdValue\n }\n })\n }\n )\n await request.perform()\n }\n\n get stateController() {\n return this\n .element\n .querySelector('[data-controller~=\"refine--state\"]')\n .refineStateController\n }\n\n loadResults({detail: {url}}) {\n console.log(\"filter submit success\")\n if (window.Turbo) {\n window.Turbo.visit(url)\n } else {\n window.location.href = url\n }\n }\n}\n","// Polyfill for custom events in IE9-11\n// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#polyfill\n;(function () {\n if (typeof window.CustomEvent === 'function') return false\n\n function CustomEvent(event, params) {\n params = params || { bubbles: false, cancelable: false, detail: undefined }\n var evt = document.createEvent('CustomEvent')\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)\n return evt\n }\n\n CustomEvent.prototype = window.Event.prototype\n\n window.CustomEvent = CustomEvent\n\n // eslint expects a return here\n return true\n})()\n\nexport const filterStabilizedEvent = (element, stableId, filterName) => {\n const event = new CustomEvent('filter-stabilized', {\n bubbles: true,\n cancelable: true,\n detail: {\n stableId,\n filterName,\n },\n })\n element.dispatchEvent(event)\n}\n\nexport const filterUnstableEvent = (blueprint) => {\n const event = new CustomEvent('filter-unstable', {\n bubbles: true,\n cancelable: true,\n detail: {\n blueprint,\n },\n })\n window.dispatchEvent(event)\n}\n\nexport const filterInvalidEvent = ({blueprint, errors}) => {\n const event = new CustomEvent('filter-invalid', {\n bubbles: true,\n cancelable: true,\n detail: {\n blueprint,\n errors,\n },\n })\n window.dispatchEvent(event)\n}\n\nexport const filterStoredEvent = (storedFilterId) => {\n const event = new CustomEvent('filter-stored', {\n bubbles: true,\n cancelable: true,\n detail: {\n storedFilterId,\n },\n })\n window.dispatchEvent(event)\n}\n\nexport const blueprintUpdatedEvent = (element, {blueprint, formId}) => {\n const event = new CustomEvent('blueprint-updated', {\n bubbles: true,\n cancelable: true,\n detail: {\n blueprint,\n formId\n },\n })\n element.dispatchEvent(event)\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { delegate, abnegate } from 'jquery-events-to-dom-events'\nimport { blueprintUpdatedEvent } from '../../refine/helpers'\nimport { isEqual } from 'lodash'\n\nconst criterion = (id, depth, condition) => {\n const component = condition?.component\n const meta = condition?.meta || { clauses: [], options: {}}\n const refinements = condition?.refinements || []\n const { clauses, options } = meta\n let selected\n if (component === 'option-condition') {\n selected = options[0] ? [options[0].id] : []\n } else {\n selected = undefined\n }\n // Set newInput based on component\n\n let newInput = {\n clause: clauses[0]?.id,\n selected: selected,\n }\n\n // If refinements are present, add to input array\n refinements.forEach((refinement) => {\n const { meta, component } = refinement\n const { clauses, options } = meta\n let selected\n if (component === 'option-condition') {\n selected = options[0] ? [options[0].id] : []\n } else {\n selected = undefined\n }\n newInput[refinement.id] = {\n clause: clauses[0].id,\n selected: selected,\n }\n })\n\n return {\n depth,\n type: 'criterion',\n condition_id: id,\n input: newInput,\n }\n}\n\nconst or = function (depth) {\n depth = depth === undefined ? 0 : depth\n return {\n depth,\n type: 'conjunction',\n word: 'or',\n }\n}\n\nconst and = function (depth) {\n depth = depth === undefined ? 1 : depth\n return {\n depth,\n type: 'conjunction',\n word: 'and',\n }\n}\nexport default class extends Controller {\n static values = {\n blueprint: Array,\n conditions: Array,\n className: String,\n refreshUrl: String,\n clientId: String,\n validateBlueprintUrl: String,\n defaultConditionId: String\n }\n static targets = ['loading']\n\n\n connect() {\n // for select2 jquery events and datepicker\n this.element.refineStateController = this\n this.changeDelegate = delegate('change', ['event', 'picker'])\n this.blueprint = this.blueprintValue\n this.conditions = this.conditionsValue\n this.filterName = this.classNameValue\n this.conditionsLookup = this.conditions.reduce((lookup, condition) => {\n lookup[condition.id] = condition\n return lookup\n }, {})\n this.loadingTimeout = null\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n }\n\n disconnect() {\n abnegate('change', this.changeDelegate)\n }\n\n startUpdate() {\n if (this.loadingTimeout) {\n window.clearTimeout(this.loadingTimeout)\n }\n // only show the loading overlay if it's taking a long time\n // to render the updates\n this.loadingTimeout = window.setTimeout(() => {\n this.loadingTarget.classList.remove('hidden')\n }, 1000)\n }\n\n finishUpdate() {\n if (this.loadingTimeout) {\n window.clearTimeout(this.loadingTimeout)\n }\n this.loadingTarget.classList.add('hidden')\n }\n\n conditionConfigFor(conditionId) {\n return this.conditionsLookup[conditionId]\n }\n\n addGroup() {\n const { blueprint, conditions } = this\n const condition = ( conditions.find(c => c.id == this.defaultConditionIdValue) || conditions[0] )\n const { meta } = condition\n\n if (this.blueprint.length > 0) {\n this.blueprint.push(or())\n }\n this.blueprint.push(criterion(condition.id, 1, condition))\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n }\n\n addCriterion(previousCriterionId) {\n const { blueprint, conditions } = this\n const condition = ( conditions.find(c => c.id == this.defaultConditionIdValue) || conditions[0] )\n const { meta } = condition\n blueprint.splice(previousCriterionId + 1, 0, and(), criterion(condition.id, 1, condition))\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n }\n\n deleteCriterion(criterionId) {\n /**\n To support 'groups' there is some complicated logic for deleting criterion.\n\n Imagine this simplified blueprint: [eq, and, sw, or, eq]\n\n User clicks to delete the last eq. We also have to delete the preceding or\n otherwise we're left with a hanging empty group\n\n What if the user deletes the sw? We have to clean up the preceding and.\n\n Imagine another scenario: [eq or sw and ew]\n Now we delete the first eq but this time we need to clean up the or.\n\n These conditionals cover these cases.\n **/\n const { blueprint } = this\n const previous = blueprint[criterionId - 1]\n const next = blueprint[criterionId + 1]\n\n const nextIsOr = next && next.word === 'or'\n const previousIsOr = previous && previous.word === 'or'\n\n const nextIsRightParen = nextIsOr || !next\n const previousIsLeftParen = previousIsOr || !previous\n\n const isFirstInGroup = previousIsLeftParen && !nextIsRightParen\n const isLastInGroup = previousIsLeftParen && nextIsRightParen\n const isLastCriterion = !previous && !next\n\n if (isLastCriterion) {\n this.blueprint = []\n } else if (isLastInGroup && previousIsOr) {\n blueprint.splice(criterionId - 1, 2)\n } else if (isLastInGroup && !previous) {\n blueprint.splice(criterionId, 2)\n } else if (isFirstInGroup) {\n blueprint.splice(criterionId, 2)\n } else {\n blueprint.splice(criterionId - 1, 2)\n }\n\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n }\n\n /*\n Updates a criterion in the blueprint\n Returns true if an update was actually performed, or false if no-op\n */\n replaceCriterion(criterionId, conditionId, condition) {\n const criterionRow = this.blueprint[criterionId]\n if (criterionRow.type !== 'criterion') {\n throw new Error(\n `You can't call updateConditionId on a non-criterion type. Trying to update ${JSON.stringify(criterion)}`\n )\n }\n const existingCriterion = this.blueprint[criterionId]\n const newCriterion = criterion(conditionId, criterionRow.depth, condition)\n if (isEqual(existingCriterion, newCriterion)) {\n return false\n } else {\n this.blueprint[criterionId] = newCriterion\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n return true\n }\n }\n\n updateInput(criterionId, input, inputId) {\n // Input id is an array of hash keys that define the path for this input such as [\"input\", \"date_refinement\"]\n const { blueprint } = this\n const criterion = blueprint[criterionId]\n inputId = inputId || 'input'\n const blueprintPath = inputId.split(', ')\n // If the inputId contains more than one element, add input at appropriate depth\n if (blueprintPath.length > 1) {\n criterion[blueprintPath[0]][blueprintPath[1]] = { ...criterion[blueprintPath[0]][blueprintPath[1]], ...input }\n } else {\n criterion[inputId] = { ...criterion[inputId], ...input }\n }\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { filterStoredEvent } from '../../refine/helpers'\n\nexport default class extends Controller {\n static targets = ['blueprintField']\n static values = { formId: String, stateDomId: String }\n\n connect() {\n const stateController = document\n .getElementById(this.stateDomIdValue)\n .refineStateController\n this.blueprintFieldTarget.value = JSON.stringify(stateController.blueprint)\n console.log(\"connect\", this.blueprintFieldTarget.value)\n }\n\n updateBlueprintField(event) {\n if (event.detail.formId != this.formIdValue) { return null }\n const { detail } = event\n const { blueprint } = detail\n this.blueprintFieldTarget.value = JSON.stringify(blueprint)\n console.log(\"update blueprint\", this.blueprintFieldTarget.value)\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n submit(event) {\n event.preventDefault()\n this.element.submit()\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\n// simple controller to hide/show the filter modal\nexport default class extends Controller {\n static targets = [\"content\"]\n\n toggle(_event) {\n this.contentTargets.forEach(node => {\n node.toggleAttribute(\"hidden\")\n })\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\n/*\n attach to a form element to have it submit to a turbo-stream endpoint\n\n <form action=\"/contacts\" data-controller=\"refine--turbo-stream-form\" data-action=\"submit->refine--turbo-stream-form#submit\">\n\n Turbo is supposed to handle this natively but we're seeing issues when the form is inside an iframe\n*/\nexport default class extends Controller {\n async submit(event) {\n event.preventDefault()\n const request = new FetchRequest(\n (this.element.method || \"POST\"),\n this.element.action,\n {\n responseKind: \"turbo-stream\",\n body: new FormData(this.element)\n }\n )\n await request.perform()\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\n/*\n attach to a link element to have it request turbo stream responses\n\n <a href=\"/contacts\" data-controller=\"refine--turbo-stream-link\" data-action=\"refine--turbo-stream-link#get\">Click me</a>\n\n Turbo is supposed to handle this natively with data-turbo-stream but we're\n seeing issues using that attribute inside iframes\n*/\nexport default class extends Controller {\n async visit(event) {\n event.preventDefault()\n const request = new FetchRequest(\n (this.element.dataset.turboMethod || \"GET\"),\n this.element.href,\n {\n responseKind: \"turbo-stream\",\n }\n )\n await request.perform()\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n\n static targets = ['listItem', 'category']\n\n filter(event) {\n const query = event.currentTarget.value.toLowerCase()\n const visibleCategories = new Set()\n\n // hide / show listItem links that match the query and note which\n // categories should be visible\n this.listItemTargets.forEach(listItemNode => {\n const listItemName = listItemNode.dataset.listItemValue.toLowerCase()\n if (listItemName.includes(query)) {\n listItemNode.hidden = false\n visibleCategories.add(listItemNode.dataset.category)\n } else {\n listItemNode.hidden = true\n }\n })\n\n // hide / show category headers that have\n this.categoryTargets.forEach(categoryNode => {\n const categoryName = categoryNode.innerHTML\n if (visibleCategories.has(categoryName)) {\n categoryNode.hidden = false\n } else {\n categoryNode.hidden = true\n }\n })\n }\n}\n","import ServerRefreshController from './server-refresh-controller'\nimport { debounce } from 'lodash'\n\nexport default class extends ServerRefreshController {\n static values = {\n criterionId: Number,\n }\n\n initialize() {\n this.updateBlueprint = debounce((event, value, inputKey) => {\n this.value(event, value, inputKey)\n }, 500)\n }\n\n refinedFilter(event) {\n const { criterionIdValue, state } = this\n const dataset = event.target.dataset\n const inputId = dataset.inputId\n\n state.updateInput(\n criterionIdValue,\n {\n id: event.target.value,\n },\n inputId\n )\n this.refreshFromServer()\n }\n\n clause(event) {\n const { criterionIdValue, state } = this\n const dataset = event.target.dataset\n const inputId = dataset.inputId\n state.updateInput(\n criterionIdValue,\n {\n clause: event.target.value,\n },\n inputId\n )\n this.refreshFromServer()\n }\n\n selected(event) {\n const { target: select } = event\n const options = Array.prototype.slice.call(select.options)\n const selectedOptions = options.filter((option) => option.selected)\n const selected = selectedOptions.map((option) => option.value)\n this.value(event, selected, 'selected')\n }\n\n value(event, value, inputKey) {\n const { criterionIdValue, state } = this\n const dataset = event.target.dataset\n const inputId = dataset.inputId\n inputKey = inputKey || dataset.inputKey || 'value'\n value = value || event.target.value\n state.updateInput(\n criterionIdValue,\n {\n [inputKey]: value,\n },\n inputId\n )\n }\n\n condition(event) {\n const { criterionIdValue, state } = this\n const element = event.target\n let newConditionId = element.value\n if (!newConditionId) newConditionId = element.querySelector('select').value \n const config = this.state.conditionConfigFor(newConditionId)\n const updatePerformed = state.replaceCriterion(criterionIdValue, newConditionId, config)\n if (updatePerformed) {\n this.refreshFromServer()\n }\n }\n\n // Prevent form submission when hitting enter in a text box\n cancelEnter(event) {\n if (event.code === \"Enter\") {\n event.preventDefault()\n event.stopPropagation()\n }\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport moment from 'moment'\nrequire('daterangepicker/daterangepicker.css')\n\n// requires jQuery, moment, might want to consider a vanilla JS alternative\nimport $ from 'jquery' // ensure jquery is loaded before daterangepicker\nimport 'daterangepicker'\n\nexport default class extends Controller {\n static targets = [\n 'field',\n 'hiddenField',\n 'clearButton',\n ]\n\n static values = {\n includeTime: Boolean,\n futureOnly: Boolean,\n drops: String,\n inline: Boolean,\n dateFormat: String,\n timeFormat: String,\n isAmPm: Boolean,\n locale: { type: String, default: 'en' },\n datetimeFormat: { type: String, default: 'MM/DD/YYYY h:mm A' },\n pickerLocale: { type: Object, default: {} },\n }\n\n connect() {\n this.initPluginInstance()\n }\n\n disconnect() {\n this.teardownPluginInstance()\n }\n\n clearDate(event) {\n // don't submit the form, unless it originated from the cancel/clear button\n event.preventDefault()\n\n window.$(this.fieldTarget).val('')\n\n this.dispatch('value-cleared')\n }\n\n applyDateToField(event, picker) {\n const format = this.includeTimeValue ? this.timeFormatValue : this.dateFormatValue\n\n const momentVal = picker\n ? moment(picker.startDate.toISOString())\n : moment(this.fieldTarget.value, 'YYYY-MM-DDTHH:mm').format('YYYY-MM-DDTHH:mm')\n const displayVal = momentVal.format(format)\n const dataVal = this.includeTimeValue ? momentVal.toISOString(true) : momentVal.format('YYYY-MM-DD')\n\n this.fieldTarget.value = displayVal\n this.hiddenFieldTarget.value = dataVal\n // bubble up a change event when the input is updated for other listeners\n window.$(this.fieldTarget).trigger('change', picker)\n\n // emit native change event\n this.hiddenFieldTarget.dispatchEvent(new Event('change', { detail: picker, bubbles: true }))\n }\n\n initPluginInstance() {\n const localeValues = this.pickerLocaleValue\n const isAmPm = this.isAmPmValue\n localeValues['format'] = this.includeTimeValue ? this.timeFormatValue : this.dateFormatValue\n\n window.$(this.fieldTarget).daterangepicker({\n singleDatePicker: true,\n timePicker: this.includeTimeValue,\n timePickerIncrement: 5,\n autoUpdateInput: false,\n autoApply: true,\n minDate: this.futureOnlyValue ? new Date() : false,\n locale: localeValues,\n parentEl: $(this.element),\n drops: this.dropsValue ? this.dropsValue : 'down',\n timePicker24Hour: !isAmPm,\n })\n\n window.$(this.fieldTarget).on('apply.daterangepicker', this.applyDateToField.bind(this))\n window.$(this.fieldTarget).on('cancel.daterangepicker', this.clearDate.bind(this))\n window.$(this.fieldTarget).on('showCalendar.daterangepicker', this.showCalendar.bind(this))\n\n this.pluginMainEl = this.fieldTarget\n this.plugin = $(this.pluginMainEl).data('daterangepicker') // weird\n\n if (this.inlineValue) {\n this.element.classList.add('date-input--inline')\n }\n\n }\n \n teardownPluginInstance() {\n if (this.plugin === undefined) {\n return\n }\n\n $(this.pluginMainEl).off('apply.daterangepicker')\n $(this.pluginMainEl).off('cancel.daterangepicker')\n $(this.pluginMainEl).off('showCalendar.daterangepicker')\n\n // revert to original markup, remove any event listeners\n this.plugin.remove()\n\n }\n\n showCalendar() {\n this.dispatch('show-calendar')\n }\n\n}\n","import { identifierForContextKey } from \"@hotwired/stimulus-webpack-helpers\"\n\nimport AddController from './refine/add-controller'\nimport CriterionFormController from './refine/criterion-form-controller'\nimport DefaultsController from './refine/defaults-controller'\nimport DeleteController from './refine/delete-controller'\nimport FilterPillsController from './refine/filter-pills-controller'\nimport PopupController from './refine/popup-controller'\nimport SearchFilterController from './refine/search-filter-controller'\nimport ServerRefreshController from './refine/server-refresh-controller'\nimport StateController from './refine/state-controller'\nimport StoredFilterController from './refine/stored-filter-controller'\nimport SubmitForm from './refine/submit-form-controller'\nimport ToggleController from './refine/toggle-controller'\nimport TurboStreamFormController from './refine/turbo-stream-form-controller'\nimport TurboStreamLinkController from './refine/turbo-stream-link-controller'\nimport TypeaheadListController from './refine/typeahead-list-controller'\nimport UpdateController from './refine/update-controller'\nimport DateController from './refine/date-controller'\n\nexport const controllerDefinitions = [\n [AddController, 'refine/add-controller.js'],\n [CriterionFormController, 'refine/criterion-form-controller.js'],\n [DefaultsController, 'refine/defaults-controller.js'],\n [DeleteController, 'refine/delete-controller.js'],\n [FilterPillsController, 'refine/filter-pills-controller.js'],\n [PopupController, 'refine/popup-controller.js'],\n [SearchFilterController, 'refine/search-filter-controller.js'],\n [ServerRefreshController, 'refine/server-refresh-controller.js'],\n [StateController, 'refine/state-controller.js'],\n [StoredFilterController, 'refine/stored-filter-controller.js'],\n [SubmitForm, 'refine/submit-form-controller.js'],\n [ToggleController, 'refine/toggle-controller.js'],\n [TurboStreamFormController, 'refine/turbo-stream-form-controller.js'],\n [TurboStreamLinkController, 'refine/turbo-stream-link-controller.js'],\n [TypeaheadListController, './refine/typeahead-list-controller.js'],\n [UpdateController, 'refine/update-controller.js'],\n [DateController, 'refine/date-controller.js']\n].map(function(d) {\n const key = d[1]\n const controller = d[0]\n return {\n identifier: identifierForContextKey(key),\n controllerConstructor: controller\n }\n})\n\nexport {\n AddController,\n CriterionFormController,\n DefaultsController,\n DeleteController,\n FilterPillsController,\n PopupController,\n SearchFilterController,\n ServerRefreshController,\n StateController,\n StoredFilterController,\n SubmitForm,\n ToggleController,\n TurboStreamFormController,\n TurboStreamLinkController,\n TypeaheadListController,\n UpdateController,\n DateController\n}\n"],"names":["identifierForContextKey","key","logicalName","match","replace","Controller","connect","this","state","finishUpdate","currentElement","element","document","body","matches","application","getControllerForElementAndIdentifier","parentNode","refreshFromServer","options","_this","includeErrors","startUpdate","request","FetchRequest","refreshUrlValue","responseKind","query","filterName","JSON","stringify","blueprint","clientIdValue","include_errors","perform","then","e","Promise","reject","ServerRefreshController","criterion","resolve","validateBlueprint","isValid","addCriterion","previousCriterionIdValue","group","_this2","addGroup","_this3","validateBlueprintUrlValue","response","ok","values","previousCriterionId","Number","refresh","_event","formElement","getElementById","formIdValue","formData","FormData","urlValue","url","String","formId","getStateController","updateInput","criterionIdValue","inputValue","controller","criterionId","input","Object","deleteCriterion","urlParams","URLSearchParams","window","location","search","existingParams","delete","event","currentTarget","dataset","index","parseInt","stateController","reloadPage","submitUrlValue","refine_filters_builder","filter_class","blueprint_json","client_id","redirectToStableId","stableId","params","append","allParams","fromEntries","toString","pathname","history","pushState","title","reload","refineStateController","stabilizeFilterController","submitUrl","useClickOutside","boundHandleKeyUp","handleKeyUp","bind","addEventListener","disconnect","removeEventListener","show","preventDefault","frameTarget","src","srcValue","isOpenValue","hide","innerHTML","clickOutside","targets","isOpen","type","Boolean","default","_class","submitFilter","activeElement","blur","querySelector","loadResults","_ref","detail","console","log","Turbo","visit","href","CustomEvent","bubbles","cancelable","undefined","evt","createEvent","initCustomEvent","prototype","Event","blueprintUpdatedEvent","_ref2","dispatchEvent","id","depth","condition","_clauses$","component","meta","clauses","refinements","selected","newInput","clause","forEach","refinement","condition_id","changeDelegate","delegate","blueprintValue","conditions","conditionsValue","classNameValue","conditionsLookup","reduce","lookup","loadingTimeout","abnegate","clearTimeout","setTimeout","loadingTarget","classList","remove","add","conditionConfigFor","conditionId","find","c","defaultConditionIdValue","length","push","word","splice","previous","next","previousIsOr","nextIsRightParen","previousIsLeftParen","isLastInGroup","replaceCriterion","criterionRow","Error","existingCriterion","newCriterion","isEqual","inputId","blueprintPath","split","Array","className","refreshUrl","clientId","validateBlueprintUrl","defaultConditionId","stateDomIdValue","blueprintFieldTarget","value","updateBlueprintField","stateDomId","submit","toggle","contentTargets","node","toggleAttribute","TurboStreamFormController","method","action","turboMethod","filter","toLowerCase","visibleCategories","Set","listItemTargets","listItemNode","listItemValue","includes","hidden","category","categoryTargets","categoryNode","has","initialize","updateBlueprint","debounce","inputKey","refinedFilter","target","select","slice","call","option","map","newConditionId","config","cancelEnter","code","stopPropagation","require","initPluginInstance","teardownPluginInstance","clearDate","$","fieldTarget","val","dispatch","applyDateToField","picker","format","includeTimeValue","timeFormatValue","dateFormatValue","momentVal","moment","startDate","toISOString","displayVal","dataVal","hiddenFieldTarget","trigger","localeValues","pickerLocaleValue","isAmPm","isAmPmValue","daterangepicker","singleDatePicker","timePicker","timePickerIncrement","autoUpdateInput","autoApply","minDate","futureOnlyValue","Date","locale","parentEl","drops","dropsValue","timePicker24Hour","on","showCalendar","pluginMainEl","plugin","data","inlineValue","off","includeTime","futureOnly","inline","dateFormat","timeFormat","datetimeFormat","pickerLocale","controllerDefinitions","AddController","CriterionFormController","DefaultsController","DeleteController","FilterPillsController","PopupController","SearchFilterController","StateController","StoredFilterController","SubmitForm","ToggleController","TurboStreamLinkController","TypeaheadListController","UpdateController","DateController","d","identifier","controllerConstructor"],"mappings":"wUAqBA,SAASA,EAAwBC,GAC7B,MAAMC,GAAeD,EAAIE,MAAM,2CAA6C,IAAI,GAChF,GAAID,EACA,OAAOA,EAAYE,QAAQ,KAAM,KAAKA,QAAQ,MAAO,sBCnBhCC,EAC3BC,UACEC,KAAKC,MAAMC,eAGTD,YACF,IAAIE,EAAiBH,KAAKI,QAE1B,KAAMD,IAAmBE,SAASC,MAAM,CACtC,GAAIH,EAAeI,QAAQ,sCACzB,OAAYC,KAAAA,YAAYC,qCAAqCN,EAAgB,iBAE7EA,EAAiBA,EAAeO,WAIpC,OACD,KAEKC,kBAAkBC,QAAD,IAACA,IAAAA,EAAU,IAAI,IAAA,MAAAC,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QiE,QAAS,MACjCsL,eAAgB,CAAExL,KAAM/D,OAAQiE,QAAU,qBAC1CuL,aAAc,CAAEzL,KAAMtD,OAAQwD,QAAS,KCL9BwL,MAAAA,EAAwB,CACnC,CAACC,EAAe,4BAChB,CAACC,EAAyB,uCAC1B,CAACC,EAAoB,iCACrB,CAACC,EAAkB,+BACnB,CAACC,EAAuB,qCACxB,CAACC,EAAiB,8BAClB,CAACC,EAAwB,sCACzB,CAAC1R,EAAyB,uCAC1B,CAAC2R,EAAiB,8BAClB,CAACC,EAAwB,sCACzB,CAACC,EAAY,oCACb,CAACC,EAAkB,+BACnB,CAAClG,EAA2B,0CAC5B,CAACmG,EAA2B,0CAC5B,CAACC,EAAyB,yCAC1B,CAACC,EAAkB,+BACnB,CAACC,EAAgB,8BACjB3E,IAAI,SAAS4E,GACb,MACMnQ,EAAamQ,EAAE,GACrB,MAAO,CACLC,WAAY3U,EAHF0U,EAAE,IAIZE,sBAAuBrQ"}
1
+ {"version":3,"file":"refine-stimulus.esm.js","sources":["../../../node_modules/@hotwired/stimulus-webpack-helpers/dist/stimulus-webpack-helpers.js","../../javascript/controllers/refine/server-refresh-controller.js","../../javascript/controllers/refine/add-controller.js","../../javascript/controllers/refine/criterion-form-controller.js","../../javascript/controllers/refine/defaults-controller.js","../../javascript/controllers/refine/delete-controller.js","../../javascript/controllers/refine/filter-pills-controller.js","../../javascript/controllers/refine/popup-controller.js","../../javascript/controllers/refine/search-filter-controller.js","../../javascript/refine/helpers/index.js","../../javascript/controllers/refine/state-controller.js","../../javascript/controllers/refine/stored-filter-controller.js","../../javascript/controllers/refine/submit-form-controller.js","../../javascript/controllers/refine/toggle-controller.js","../../javascript/controllers/refine/turbo-stream-form-controller.js","../../javascript/controllers/refine/turbo-stream-link-controller.js","../../javascript/controllers/refine/typeahead-list-controller.js","../../javascript/controllers/refine/update-controller.js","../../javascript/controllers/refine/date-controller.js","../../javascript/controllers/refine/clear-criteria-controller.js","../../javascript/controllers/index.js"],"sourcesContent":["/*\nStimulus Webpack Helpers 1.0.0\nCopyright © 2021 Basecamp, LLC\n */\nfunction definitionsFromContext(context) {\n return context.keys()\n .map((key) => definitionForModuleWithContextAndKey(context, key))\n .filter((value) => value);\n}\nfunction definitionForModuleWithContextAndKey(context, key) {\n const identifier = identifierForContextKey(key);\n if (identifier) {\n return definitionForModuleAndIdentifier(context(key), identifier);\n }\n}\nfunction definitionForModuleAndIdentifier(module, identifier) {\n const controllerConstructor = module.default;\n if (typeof controllerConstructor == \"function\") {\n return { identifier, controllerConstructor };\n }\n}\nfunction identifierForContextKey(key) {\n const logicalName = (key.match(/^(?:\\.\\/)?(.+)(?:[_-]controller\\..+?)$/) || [])[1];\n if (logicalName) {\n return logicalName.replace(/_/g, \"-\").replace(/\\//g, \"--\");\n }\n}\n\nexport { definitionForModuleAndIdentifier, definitionForModuleWithContextAndKey, definitionsFromContext, identifierForContextKey };\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\n\n// Base class for controllers that reload form content from the server\nexport default class extends Controller {\n connect() {\n this.state.finishUpdate()\n }\n\n get state() {\n let currentElement = this.element\n\n while(currentElement !== document.body) {\n if (currentElement.matches('[data-controller~=\"refine--state\"]'))\n return this.application.getControllerForElementAndIdentifier(currentElement, 'refine--state')\n else {\n currentElement = currentElement.parentNode\n }\n }\n\n return null\n }\n\n async refreshFromServer(options = {}) {\n const { includeErrors } = options\n this.state.startUpdate()\n const request = new FetchRequest(\n \"GET\",\n this.state.refreshUrlValue,\n {\n responseKind: \"turbo-stream\",\n query: {\n \"refine_filters_builder[filter_class]\": this.state.filterName,\n \"refine_filters_builder[blueprint_json]\": JSON.stringify(this.state.blueprint),\n \"refine_filters_builder[client_id]\": this.state.clientIdValue,\n include_errors: !!includeErrors\n }\n }\n )\n await request.perform()\n }\n}\n","import ServerRefreshController from './server-refresh-controller'\nimport { FetchRequest } from '@rails/request.js'\n\nexport default class extends ServerRefreshController {\n static values = {\n previousCriterionId: Number,\n }\n\n async criterion() {\n const isValid = await this.validateBlueprint()\n if (isValid) {\n this.state.addCriterion(this.previousCriterionIdValue)\n }\n this.refreshFromServer({includeErrors: !isValid})\n }\n\n async group() {\n const isValid = await this.validateBlueprint()\n if (isValid) {\n this.state.addGroup()\n }\n this.refreshFromServer({includeErrors: !isValid})\n }\n\n async validateBlueprint(blueprint) {\n const { state } = this\n\n const request = new FetchRequest(\n \"GET\",\n this.state.validateBlueprintUrlValue,\n {\n query: {\n \"refine_filters_builder[filter_class]\": this.state.filterName,\n \"refine_filters_builder[blueprint_json]\": JSON.stringify(this.state.blueprint),\n \"refine_filters_builder[client_id]\": this.state.clientIdValue\n }\n }\n )\n const response = await request.perform()\n return response.ok\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\n/*\n This controller handles criteria forms\n (refine/inline/criteria/new|edit)\n*/\nexport default class extends Controller {\n static values = {\n url: String,\n formId: String\n }\n\n async refresh(_event) {\n // update the url with params from the form\n const formElement = document.getElementById(this.formIdValue)\n const formData = new FormData(formElement)\n console.log(\"in criterion-form refresh event\")\n console.log(this)\n console.log(formData)\n\n const request = new FetchRequest(\n \"GET\",\n this.urlValue,\n {\n query: formData,\n responseKind: \"turbo-stream\"\n }\n )\n const response = await request.perform()\n }\n\n\n\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n static values = {\n criterionId: Number,\n input: Object,\n };\n\n connect() {\n this.state = this.getStateController()\n\n this.state.updateInput(\n this.criterionIdValue,\n this.inputValue,\n );\n }\n\n getStateController() {\n let currentElement = this.element\n\n while(currentElement !== document.body) {\n const controller = this.application.getControllerForElementAndIdentifier(currentElement, 'refine--state')\n if (controller) {\n return controller\n } else {\n currentElement = currentElement.parentNode\n }\n }\n\n return null\n }\n}\n","import ServerRefreshController from './server-refresh-controller';\n\nexport default class extends ServerRefreshController {\n static values = {\n criterionId: Number,\n }\n\n criterion() {\n const { state, criterionIdValue } = this;\n state.deleteCriterion(criterionIdValue);\n this.refreshFromServer()\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\nexport default class extends Controller {\n static values = {\n submitUrl: String\n }\n\n connect() {\n const urlParams = new URLSearchParams(window.location.search)\n this.existingParams = urlParams\n this.existingParams.delete('stable_id')\n }\n\n delete(event) {\n const { criterionId } = event.currentTarget.dataset\n var index = parseInt(criterionId)\n this.stateController.deleteCriterion(index)\n this.reloadPage()\n }\n\n async reloadPage() {\n const {blueprint} = this.stateController\n const request = new FetchRequest(\n \"POST\",\n this.submitUrlValue,\n {\n responseKind: \"turbo-stream\",\n body: JSON.stringify({\n refine_filters_builder: {\n filter_class: this.stateController.filterName,\n blueprint_json: JSON.stringify(blueprint),\n client_id: this.stateController.clientIdValue\n }\n })\n }\n )\n await request.perform()\n }\n\n redirectToStableId(stableId) {\n const params = new URLSearchParams()\n if (stableId) {\n params.append('stable_id', stableId)\n }\n const allParams = new URLSearchParams({\n ...Object.fromEntries(this.existingParams),\n ...Object.fromEntries(params),\n }).toString()\n const url = `${window.location.pathname}?${allParams}`\n\n history.pushState({}, document.title, url)\n window.location.reload()\n }\n\n get stateController() {\n return this.element.refineStateController\n }\n\n get stabilizeFilterController() {\n return this.element.stabilizeFilterController\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { useClickOutside } from 'stimulus-use'\n\n// simple controller to hide/show the filter modal\nexport default class extends Controller {\n static targets = [\"frame\"]\n\n static values = {\n src: String,\n isOpen: {type: Boolean, default: false}\n }\n\n connect() {\n useClickOutside(this)\n this.boundHandleKeyUp = this.handleKeyUp.bind(this)\n document.addEventListener(\"keyup\", this.boundHandleKeyUp)\n }\n\n disconnect() {\n document.removeEventListener(\"keyup\", this.boundHandleKeyUp)\n }\n\n show(event) {\n console.log(\"In Popup Show\")\n event.preventDefault()\n this.frameTarget.src = this.srcValue;\n this.isOpenValue = true\n }\n\n hide(event) {\n if (this.isOpenValue) {\n event?.preventDefault()\n this.frameTarget.innerHTML = \"\";\n this.isOpenValue = false\n }\n }\n\n clickOutside(event) {\n this.hide(event)\n }\n\n handleKeyUp(event) {\n if (event.key === \"Escape\" || event.key === \"Esc\") {\n this.hide(event)\n }\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\nexport default class extends Controller {\n static values = {\n submitUrl: String\n }\n\n\n search(event) {\n event.preventDefault()\n this.submitFilter()\n document.activeElement.blur()\n }\n\n async submitFilter() {\n const {blueprint} = this.stateController\n const request = new FetchRequest(\n \"POST\",\n this.submitUrlValue,\n {\n responseKind: \"turbo-stream\",\n body: JSON.stringify({\n refine_filters_builder: {\n filter_class: this.stateController.filterName,\n blueprint_json: JSON.stringify(blueprint),\n client_id: this.stateController.clientIdValue\n }\n })\n }\n )\n await request.perform()\n }\n\n get stateController() {\n return this\n .element\n .querySelector('[data-controller~=\"refine--state\"]')\n .refineStateController\n }\n\n loadResults({detail: {url}}) {\n console.log(\"filter submit success\")\n if (window.Turbo) {\n window.Turbo.visit(url)\n } else {\n window.location.href = url\n }\n }\n}\n","// Polyfill for custom events in IE9-11\n// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#polyfill\n;(function () {\n if (typeof window.CustomEvent === 'function') return false\n\n function CustomEvent(event, params) {\n params = params || { bubbles: false, cancelable: false, detail: undefined }\n var evt = document.createEvent('CustomEvent')\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)\n return evt\n }\n\n CustomEvent.prototype = window.Event.prototype\n\n window.CustomEvent = CustomEvent\n\n // eslint expects a return here\n return true\n})()\n\nexport const filterStabilizedEvent = (element, stableId, filterName) => {\n const event = new CustomEvent('filter-stabilized', {\n bubbles: true,\n cancelable: true,\n detail: {\n stableId,\n filterName,\n },\n })\n element.dispatchEvent(event)\n}\n\nexport const filterUnstableEvent = (blueprint) => {\n const event = new CustomEvent('filter-unstable', {\n bubbles: true,\n cancelable: true,\n detail: {\n blueprint,\n },\n })\n window.dispatchEvent(event)\n}\n\nexport const filterInvalidEvent = ({blueprint, errors}) => {\n const event = new CustomEvent('filter-invalid', {\n bubbles: true,\n cancelable: true,\n detail: {\n blueprint,\n errors,\n },\n })\n window.dispatchEvent(event)\n}\n\nexport const filterStoredEvent = (storedFilterId) => {\n const event = new CustomEvent('filter-stored', {\n bubbles: true,\n cancelable: true,\n detail: {\n storedFilterId,\n },\n })\n window.dispatchEvent(event)\n}\n\nexport const blueprintUpdatedEvent = (element, {blueprint, formId}) => {\n const event = new CustomEvent('blueprint-updated', {\n bubbles: true,\n cancelable: true,\n detail: {\n blueprint,\n formId\n },\n })\n element.dispatchEvent(event)\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { delegate, abnegate } from 'jquery-events-to-dom-events'\nimport { blueprintUpdatedEvent } from '../../refine/helpers'\nimport { isEqual } from 'lodash'\n\nconst criterion = (id, depth, condition) => {\n const component = condition?.component\n const meta = condition?.meta || { clauses: [], options: {}}\n const refinements = condition?.refinements || []\n const { clauses, options } = meta\n let selected\n if (component === 'option-condition') {\n selected = options[0] ? [options[0].id] : []\n } else {\n selected = undefined\n }\n // Set newInput based on component\n\n let newInput = {\n clause: clauses[0]?.id,\n selected: selected,\n }\n\n // If refinements are present, add to input array\n refinements.forEach((refinement) => {\n const { meta, component } = refinement\n const { clauses, options } = meta\n let selected\n if (component === 'option-condition') {\n selected = options[0] ? [options[0].id] : []\n } else {\n selected = undefined\n }\n newInput[refinement.id] = {\n clause: clauses[0].id,\n selected: selected,\n }\n })\n\n return {\n depth,\n type: 'criterion',\n condition_id: id,\n input: newInput,\n }\n}\n\nconst or = function (depth) {\n depth = depth === undefined ? 0 : depth\n return {\n depth,\n type: 'conjunction',\n word: 'or',\n }\n}\n\nconst and = function (depth) {\n depth = depth === undefined ? 1 : depth\n return {\n depth,\n type: 'conjunction',\n word: 'and',\n }\n}\nexport default class extends Controller {\n static values = {\n blueprint: Array,\n conditions: Array,\n className: String,\n refreshUrl: String,\n clientId: String,\n validateBlueprintUrl: String,\n defaultConditionId: String\n }\n static targets = ['loading']\n\n\n connect() {\n // for select2 jquery events and datepicker\n this.element.refineStateController = this\n this.changeDelegate = delegate('change', ['event', 'picker'])\n this.blueprint = this.blueprintValue\n this.conditions = this.conditionsValue\n this.filterName = this.classNameValue\n this.conditionsLookup = this.conditions.reduce((lookup, condition) => {\n lookup[condition.id] = condition\n return lookup\n }, {})\n this.loadingTimeout = null\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n }\n\n disconnect() {\n abnegate('change', this.changeDelegate)\n }\n\n startUpdate() {\n if (this.loadingTimeout) {\n window.clearTimeout(this.loadingTimeout)\n }\n // only show the loading overlay if it's taking a long time\n // to render the updates\n this.loadingTimeout = window.setTimeout(() => {\n this.loadingTarget.classList.remove('hidden')\n }, 1000)\n }\n\n finishUpdate() {\n if (this.loadingTimeout) {\n window.clearTimeout(this.loadingTimeout)\n }\n this.loadingTarget.classList.add('hidden')\n }\n\n conditionConfigFor(conditionId) {\n return this.conditionsLookup[conditionId]\n }\n\n addGroup() {\n const { blueprint, conditions } = this\n const condition = ( conditions.find(c => c.id == this.defaultConditionIdValue) || conditions[0] )\n const { meta } = condition\n\n if (this.blueprint.length > 0) {\n this.blueprint.push(or())\n }\n this.blueprint.push(criterion(condition.id, 1, condition))\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n }\n\n addCriterion(previousCriterionId) {\n console.log(\"Add criteria\")\n const { blueprint, conditions } = this\n const condition = ( conditions.find(c => c.id == this.defaultConditionIdValue) || conditions[0] )\n const { meta } = condition\n blueprint.splice(previousCriterionId + 1, 0, and(), criterion(condition.id, 1, condition))\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n }\n\n deleteCriterion(criterionId) {\n /**\n To support 'groups' there is some complicated logic for deleting criterion.\n\n Imagine this simplified blueprint: [eq, and, sw, or, eq]\n\n User clicks to delete the last eq. We also have to delete the preceding or\n otherwise we're left with a hanging empty group\n\n What if the user deletes the sw? We have to clean up the preceding and.\n\n Imagine another scenario: [eq or sw and ew]\n Now we delete the first eq but this time we need to clean up the or.\n\n These conditionals cover these cases.\n **/\n const { blueprint } = this\n const previous = blueprint[criterionId - 1]\n const next = blueprint[criterionId + 1]\n\n const nextIsOr = next && next.word === 'or'\n const previousIsOr = previous && previous.word === 'or'\n\n const nextIsRightParen = nextIsOr || !next\n const previousIsLeftParen = previousIsOr || !previous\n\n const isFirstInGroup = previousIsLeftParen && !nextIsRightParen\n const isLastInGroup = previousIsLeftParen && nextIsRightParen\n const isLastCriterion = !previous && !next\n\n if (isLastCriterion) {\n this.blueprint = []\n } else if (isLastInGroup && previousIsOr) {\n blueprint.splice(criterionId - 1, 2)\n } else if (isLastInGroup && !previous) {\n blueprint.splice(criterionId, 2)\n } else if (isFirstInGroup) {\n blueprint.splice(criterionId, 2)\n } else {\n blueprint.splice(criterionId - 1, 2)\n }\n\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n }\n\n /*\n Updates a criterion in the blueprint\n Returns true if an update was actually performed, or false if no-op\n */\n replaceCriterion(criterionId, conditionId, condition) {\n const criterionRow = this.blueprint[criterionId]\n if (criterionRow.type !== 'criterion') {\n throw new Error(\n `You can't call updateConditionId on a non-criterion type. Trying to update ${JSON.stringify(criterion)}`\n )\n }\n const existingCriterion = this.blueprint[criterionId]\n const newCriterion = criterion(conditionId, criterionRow.depth, condition)\n if (isEqual(existingCriterion, newCriterion)) {\n return false\n } else {\n this.blueprint[criterionId] = newCriterion\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n return true\n }\n }\n\n updateInput(criterionId, input, inputId) {\n // Input id is an array of hash keys that define the path for this input such as [\"input\", \"date_refinement\"]\n const { blueprint } = this\n const criterion = blueprint[criterionId]\n inputId = inputId || 'input'\n const blueprintPath = inputId.split(', ')\n // If the inputId contains more than one element, add input at appropriate depth\n if (blueprintPath.length > 1) {\n criterion[blueprintPath[0]][blueprintPath[1]] = { ...criterion[blueprintPath[0]][blueprintPath[1]], ...input }\n } else {\n criterion[inputId] = { ...criterion[inputId], ...input }\n }\n blueprintUpdatedEvent(this.element, {blueprint: this.blueprint, formId: this.formIdValue})\n }\n\n clearCriteria() {\n console.log(\"In clearCriteria\")\n blueprintUpdatedEvent(this.element, {blueprint: [], formId: this.formIdValue})\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { filterStoredEvent } from '../../refine/helpers'\n\nexport default class extends Controller {\n static targets = ['blueprintField']\n static values = { formId: String, stateDomId: String }\n\n connect() {\n const stateController = document\n .getElementById(this.stateDomIdValue)\n .refineStateController\n this.blueprintFieldTarget.value = JSON.stringify(stateController.blueprint)\n console.log(\"connect\", this.blueprintFieldTarget.value)\n }\n\n updateBlueprintField(event) {\n if (event.detail.formId != this.formIdValue) { return null }\n const { detail } = event\n const { blueprint } = detail\n this.blueprintFieldTarget.value = JSON.stringify(blueprint)\n console.log(\"update blueprint\", this.blueprintFieldTarget.value)\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n submit(event) {\n event.preventDefault()\n this.element.submit()\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\n// simple controller to hide/show the filter modal\nexport default class extends Controller {\n static targets = [\"content\"]\n\n toggle(_event) {\n this.contentTargets.forEach(node => {\n node.toggleAttribute(\"hidden\")\n })\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\n/*\n attach to a form element to have it submit to a turbo-stream endpoint\n\n <form action=\"/contacts\" data-controller=\"refine--turbo-stream-form\" data-action=\"submit->refine--turbo-stream-form#submit\">\n\n Turbo is supposed to handle this natively but we're seeing issues when the form is inside an iframe\n*/\nexport default class extends Controller {\n async submit(event) {\n event.preventDefault()\n const request = new FetchRequest(\n (this.element.method || \"POST\"),\n this.element.action,\n {\n responseKind: \"turbo-stream\",\n body: new FormData(this.element)\n }\n )\n await request.perform()\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport { FetchRequest } from '@rails/request.js'\n\n/*\n attach to a link element to have it request turbo stream responses\n\n <a href=\"/contacts\" data-controller=\"refine--turbo-stream-link\" data-action=\"refine--turbo-stream-link#get\">Click me</a>\n\n Turbo is supposed to handle this natively with data-turbo-stream but we're\n seeing issues using that attribute inside iframes\n*/\nexport default class extends Controller {\n async visit(event) {\n event.preventDefault()\n const request = new FetchRequest(\n (this.element.dataset.turboMethod || \"GET\"),\n this.element.href,\n {\n responseKind: \"turbo-stream\",\n }\n )\n await request.perform()\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n\n static targets = ['listItem', 'category']\n\n filter(event) {\n const query = event.currentTarget.value.toLowerCase()\n const visibleCategories = new Set()\n\n // hide / show listItem links that match the query and note which\n // categories should be visible\n this.listItemTargets.forEach(listItemNode => {\n const listItemName = listItemNode.dataset.listItemValue.toLowerCase()\n if (listItemName.includes(query)) {\n listItemNode.hidden = false\n visibleCategories.add(listItemNode.dataset.category)\n } else {\n listItemNode.hidden = true\n }\n })\n\n // hide / show category headers that have\n this.categoryTargets.forEach(categoryNode => {\n const categoryName = categoryNode.innerHTML\n if (visibleCategories.has(categoryName)) {\n categoryNode.hidden = false\n } else {\n categoryNode.hidden = true\n }\n })\n }\n}\n","import ServerRefreshController from './server-refresh-controller'\nimport { debounce } from 'lodash'\n\nexport default class extends ServerRefreshController {\n static values = {\n criterionId: Number,\n }\n\n initialize() {\n this.updateBlueprint = debounce((event, value, inputKey) => {\n this.value(event, value, inputKey)\n }, 500)\n }\n\n refinedFilter(event) {\n const { criterionIdValue, state } = this\n const dataset = event.target.dataset\n const inputId = dataset.inputId\n\n state.updateInput(\n criterionIdValue,\n {\n id: event.target.value,\n },\n inputId\n )\n this.refreshFromServer()\n }\n\n clause(event) {\n const { criterionIdValue, state } = this\n const dataset = event.target.dataset\n const inputId = dataset.inputId\n state.updateInput(\n criterionIdValue,\n {\n clause: event.target.value,\n },\n inputId\n )\n this.refreshFromServer()\n }\n\n selected(event) {\n const { target: select } = event\n const options = Array.prototype.slice.call(select.options)\n const selectedOptions = options.filter((option) => option.selected)\n const selected = selectedOptions.map((option) => option.value)\n this.value(event, selected, 'selected')\n }\n\n value(event, value, inputKey) {\n const { criterionIdValue, state } = this\n const dataset = event.target.dataset\n const inputId = dataset.inputId\n inputKey = inputKey || dataset.inputKey || 'value'\n value = value || event.target.value\n state.updateInput(\n criterionIdValue,\n {\n [inputKey]: value,\n },\n inputId\n )\n }\n\n condition(event) {\n const { criterionIdValue, state } = this\n const element = event.target\n let newConditionId = element.value\n if (!newConditionId) newConditionId = element.querySelector('select').value \n const config = this.state.conditionConfigFor(newConditionId)\n const updatePerformed = state.replaceCriterion(criterionIdValue, newConditionId, config)\n if (updatePerformed) {\n this.refreshFromServer()\n }\n }\n\n // Prevent form submission when hitting enter in a text box\n cancelEnter(event) {\n if (event.code === \"Enter\") {\n event.preventDefault()\n event.stopPropagation()\n }\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\nimport moment from 'moment'\nrequire('daterangepicker/daterangepicker.css')\n\n// requires jQuery, moment, might want to consider a vanilla JS alternative\nimport $ from 'jquery' // ensure jquery is loaded before daterangepicker\nimport 'daterangepicker'\n\nexport default class extends Controller {\n static targets = [\n 'field',\n 'hiddenField',\n 'clearButton',\n ]\n\n static values = {\n includeTime: Boolean,\n futureOnly: Boolean,\n drops: String,\n inline: Boolean,\n dateFormat: String,\n timeFormat: String,\n isAmPm: Boolean,\n locale: { type: String, default: 'en' },\n datetimeFormat: { type: String, default: 'MM/DD/YYYY h:mm A' },\n pickerLocale: { type: Object, default: {} },\n }\n\n connect() {\n this.initPluginInstance()\n }\n\n disconnect() {\n this.teardownPluginInstance()\n }\n\n clearDate(event) {\n // don't submit the form, unless it originated from the cancel/clear button\n event.preventDefault()\n\n window.$(this.fieldTarget).val('')\n\n this.dispatch('value-cleared')\n }\n\n applyDateToField(event, picker) {\n const format = this.includeTimeValue ? this.timeFormatValue : this.dateFormatValue\n\n const momentVal = picker\n ? moment(picker.startDate.toISOString())\n : moment(this.fieldTarget.value, 'YYYY-MM-DDTHH:mm').format('YYYY-MM-DDTHH:mm')\n const displayVal = momentVal.format(format)\n const dataVal = this.includeTimeValue ? momentVal.toISOString(true) : momentVal.format('YYYY-MM-DD')\n\n this.fieldTarget.value = displayVal\n this.hiddenFieldTarget.value = dataVal\n // bubble up a change event when the input is updated for other listeners\n window.$(this.fieldTarget).trigger('change', picker)\n\n // emit native change event\n this.hiddenFieldTarget.dispatchEvent(new Event('change', { detail: picker, bubbles: true }))\n }\n\n initPluginInstance() {\n const localeValues = this.pickerLocaleValue\n const isAmPm = this.isAmPmValue\n localeValues['format'] = this.includeTimeValue ? this.timeFormatValue : this.dateFormatValue\n\n window.$(this.fieldTarget).daterangepicker({\n singleDatePicker: true,\n timePicker: this.includeTimeValue,\n timePickerIncrement: 5,\n autoUpdateInput: false,\n autoApply: true,\n minDate: this.futureOnlyValue ? new Date() : false,\n locale: localeValues,\n parentEl: $(this.element),\n drops: this.dropsValue ? this.dropsValue : 'down',\n timePicker24Hour: !isAmPm,\n })\n\n window.$(this.fieldTarget).on('apply.daterangepicker', this.applyDateToField.bind(this))\n window.$(this.fieldTarget).on('cancel.daterangepicker', this.clearDate.bind(this))\n window.$(this.fieldTarget).on('showCalendar.daterangepicker', this.showCalendar.bind(this))\n\n this.pluginMainEl = this.fieldTarget\n this.plugin = $(this.pluginMainEl).data('daterangepicker') // weird\n\n if (this.inlineValue) {\n this.element.classList.add('date-input--inline')\n }\n\n }\n \n teardownPluginInstance() {\n if (this.plugin === undefined) {\n return\n }\n\n $(this.pluginMainEl).off('apply.daterangepicker')\n $(this.pluginMainEl).off('cancel.daterangepicker')\n $(this.pluginMainEl).off('showCalendar.daterangepicker')\n\n // revert to original markup, remove any event listeners\n this.plugin.remove()\n\n }\n\n showCalendar() {\n this.dispatch('show-calendar')\n }\n\n}\n","// import ServerRefreshController from './server-refresh-controller';\nimport { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n clear() {\n console.log(\"Clearing criteria\")\n const { state } = this;\n state.clearCriteria();\n this.refreshFromServer()\n }\n}\n","import { identifierForContextKey } from \"@hotwired/stimulus-webpack-helpers\"\n\nimport AddController from './refine/add-controller'\nimport CriterionFormController from './refine/criterion-form-controller'\nimport DefaultsController from './refine/defaults-controller'\nimport DeleteController from './refine/delete-controller'\nimport FilterPillsController from './refine/filter-pills-controller'\nimport PopupController from './refine/popup-controller'\nimport SearchFilterController from './refine/search-filter-controller'\nimport ServerRefreshController from './refine/server-refresh-controller'\nimport StateController from './refine/state-controller'\nimport StoredFilterController from './refine/stored-filter-controller'\nimport SubmitForm from './refine/submit-form-controller'\nimport ToggleController from './refine/toggle-controller'\nimport TurboStreamFormController from './refine/turbo-stream-form-controller'\nimport TurboStreamLinkController from './refine/turbo-stream-link-controller'\nimport TypeaheadListController from './refine/typeahead-list-controller'\nimport UpdateController from './refine/update-controller'\nimport DateController from './refine/date-controller'\nimport ClearCriteriaController from \"./refine/clear-criteria-controller\"\n\nexport const controllerDefinitions = [\n [AddController, 'refine/add-controller.js'],\n [CriterionFormController, 'refine/criterion-form-controller.js'],\n [DefaultsController, 'refine/defaults-controller.js'],\n [DeleteController, 'refine/delete-controller.js'],\n [FilterPillsController, 'refine/filter-pills-controller.js'],\n [PopupController, 'refine/popup-controller.js'],\n [SearchFilterController, 'refine/search-filter-controller.js'],\n [ServerRefreshController, 'refine/server-refresh-controller.js'],\n [StateController, 'refine/state-controller.js'],\n [StoredFilterController, 'refine/stored-filter-controller.js'],\n [SubmitForm, 'refine/submit-form-controller.js'],\n [ToggleController, 'refine/toggle-controller.js'],\n [TurboStreamFormController, 'refine/turbo-stream-form-controller.js'],\n [TurboStreamLinkController, 'refine/turbo-stream-link-controller.js'],\n [TypeaheadListController, './refine/typeahead-list-controller.js'],\n [UpdateController, 'refine/update-controller.js'],\n [DateController, 'refine/date-controller.js'],\n [ClearCriteriaController, 'refine/clear-criteria-controller.js']\n].map(function(d) {\n const key = d[1]\n const controller = d[0]\n return {\n identifier: identifierForContextKey(key),\n controllerConstructor: controller\n }\n})\n\nexport {\n AddController,\n CriterionFormController,\n DefaultsController,\n DeleteController,\n FilterPillsController,\n PopupController,\n SearchFilterController,\n ServerRefreshController,\n StateController,\n StoredFilterController,\n SubmitForm,\n ToggleController,\n TurboStreamFormController,\n TurboStreamLinkController,\n TypeaheadListController,\n UpdateController,\n DateController,\n ClearCriteriaController\n}\n"],"names":["identifierForContextKey","key","logicalName","match","replace","Controller","connect","this","state","finishUpdate","currentElement","element","document","body","matches","application","getControllerForElementAndIdentifier","parentNode","refreshFromServer","options","_this","includeErrors","startUpdate","request","FetchRequest","refreshUrlValue","responseKind","query","filterName","JSON","stringify","blueprint","clientIdValue","include_errors","perform","then","e","Promise","reject","ServerRefreshController","criterion","resolve","validateBlueprint","isValid","addCriterion","previousCriterionIdValue","group","_this2","addGroup","_this3","validateBlueprintUrlValue","response","ok","values","previousCriterionId","Number","_class","refresh","_event","formElement","getElementById","formIdValue","formData","FormData","console","log","urlValue","url","String","formId","getStateController","updateInput","criterionIdValue","inputValue","controller","criterionId","input","Object","deleteCriterion","urlParams","URLSearchParams","window","location","search","existingParams","delete","event","currentTarget","dataset","index","parseInt","stateController","reloadPage","submitUrlValue","refine_filters_builder","filter_class","blueprint_json","client_id","redirectToStableId","stableId","params","append","allParams","fromEntries","toString","pathname","history","pushState","title","reload","refineStateController","stabilizeFilterController","submitUrl","useClickOutside","boundHandleKeyUp","handleKeyUp","bind","addEventListener","disconnect","removeEventListener","show","preventDefault","frameTarget","src","srcValue","isOpenValue","hide","innerHTML","clickOutside","targets","isOpen","type","Boolean","default","submitFilter","activeElement","blur","querySelector","loadResults","_ref","detail","Turbo","visit","href","CustomEvent","bubbles","cancelable","undefined","evt","createEvent","initCustomEvent","prototype","Event","blueprintUpdatedEvent","_ref2","dispatchEvent","id","depth","condition","_clauses$","component","meta","clauses","refinements","selected","newInput","clause","forEach","refinement","condition_id","changeDelegate","delegate","blueprintValue","conditions","conditionsValue","classNameValue","conditionsLookup","reduce","lookup","loadingTimeout","abnegate","clearTimeout","setTimeout","loadingTarget","classList","remove","add","conditionConfigFor","conditionId","find","c","defaultConditionIdValue","length","push","word","splice","previous","next","previousIsOr","nextIsRightParen","previousIsLeftParen","isLastInGroup","replaceCriterion","criterionRow","Error","existingCriterion","newCriterion","isEqual","inputId","blueprintPath","split","clearCriteria","Array","className","refreshUrl","clientId","validateBlueprintUrl","defaultConditionId","stateDomIdValue","blueprintFieldTarget","value","updateBlueprintField","stateDomId","submit","toggle","contentTargets","node","toggleAttribute","TurboStreamFormController","method","action","turboMethod","filter","toLowerCase","visibleCategories","Set","listItemTargets","listItemNode","listItemValue","includes","hidden","category","categoryTargets","categoryNode","has","initialize","updateBlueprint","debounce","inputKey","refinedFilter","target","select","slice","call","option","map","newConditionId","config","cancelEnter","code","stopPropagation","require","initPluginInstance","teardownPluginInstance","clearDate","$","fieldTarget","val","dispatch","applyDateToField","picker","format","includeTimeValue","timeFormatValue","dateFormatValue","momentVal","moment","startDate","toISOString","displayVal","dataVal","hiddenFieldTarget","trigger","localeValues","pickerLocaleValue","isAmPm","isAmPmValue","daterangepicker","singleDatePicker","timePicker","timePickerIncrement","autoUpdateInput","autoApply","minDate","futureOnlyValue","Date","locale","parentEl","drops","dropsValue","timePicker24Hour","on","showCalendar","pluginMainEl","plugin","data","inlineValue","off","includeTime","futureOnly","inline","dateFormat","timeFormat","datetimeFormat","pickerLocale","ClearCriteriaController","clear","controllerDefinitions","AddController","CriterionFormController","DefaultsController","DeleteController","FilterPillsController","PopupController","SearchFilterController","StateController","StoredFilterController","SubmitForm","ToggleController","TurboStreamLinkController","TypeaheadListController","UpdateController","DateController","d","identifier","controllerConstructor"],"mappings":"wUAqBA,SAASA,EAAwBC,GAC7B,MAAMC,GAAeD,EAAIE,MAAM,2CAA6C,IAAI,GAChF,GAAID,EACA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AAI,SAAS8E,GACb,MACMnQ,EAAamQ,EAAE,GACrB,MAAO,CACLC,WAAY9U,EAHF6U,EAAE,IAIZE,sBAAuBrQ"}
@@ -1,2 +1,2 @@
1
- var e=require("@hotwired/stimulus"),t=require("@rails/request.js"),r=require("stimulus-use"),i=require("jquery-events-to-dom-events"),n=require("lodash"),l=require("moment"),o=require("jquery");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("daterangepicker");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 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:{"refine_filters_builder[filter_class]":r.state.filterName,"refine_filters_builder[blueprint_json]":JSON.stringify(r.state.blueprint),"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 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,r=new t.FetchRequest("GET",e.state.validateBlueprintUrlValue,{query:{"refine_filters_builder[filter_class]":e.state.filterName,"refine_filters_builder[blueprint_json]":JSON.stringify(e.state.blueprint),"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)}}}h.values={previousCriterionId:Number};class p extends e.Controller{refresh(e){try{const e=this,r=document.getElementById(e.formIdValue),i=new FormData(r),n=new t.FetchRequest("GET",e.urlValue,{query:i,responseKind:"turbo-stream"});return Promise.resolve(n.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}p.values={url:String,formId:String};class m 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}}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 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({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}}g.values={submitUrl:String};class b extends e.Controller{connect(){r.useClickOutside(this),this.boundHandleKeyUp=this.handleKeyUp.bind(this),document.addEventListener("keyup",this.boundHandleKeyUp)}disconnect(){document.removeEventListener("keyup",this.boundHandleKeyUp)}show(e){e.preventDefault(),this.frameTarget.src=this.srcValue,this.isOpenValue=!0}hide(e){this.isOpenValue&&(null==e||e.preventDefault(),this.frameTarget.innerHTML="",this.isOpenValue=!1)}clickOutside(e){this.hide(e)}handleKeyUp(e){"Escape"!==e.key&&"Esc"!==e.key||this.hide(e)}}b.targets=["frame"],b.values={src:String,isOpen:{type:Boolean,default:!1}};class v 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({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}}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)},y=(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=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(y(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"},y(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(y));const l=this.blueprint[e],o=y(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})}}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{submit(e){e.preventDefault(),this.element.submit()}}class T extends e.Controller{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}T.targets=["content"];class V extends e.Controller{submit(e){try{const r=this;e.preventDefault();const i=new t.FetchRequest(r.element.method||"POST",r.element.action,{responseKind:"turbo-stream",body:new FormData(r.element)});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class F extends e.Controller{visit(e){try{const r=this;e.preventDefault();const i=new t.FetchRequest(r.element.dataset.turboMethod||"GET",r.element.href,{responseKind:"turbo-stream"});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class E extends e.Controller{filter(e){const t=e.currentTarget.value.toLowerCase(),r=new Set;this.listItemTargets.forEach(e=>{e.dataset.listItemValue.toLowerCase().includes(t)?(e.hidden=!1,r.add(e.dataset.category)):e.hidden=!0}),this.categoryTargets.forEach(e=>{e.hidden=!r.has(e.innerHTML)})}}E.targets=["listItem","category"];class P 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())}}P.values={criterionId:Number},require("daterangepicker/daterangepicker.css");class j 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?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")}}j.targets=["field","hiddenField","clearButton"],j.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 x=[[h,"refine/add-controller.js"],[p,"refine/criterion-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"],[w,"refine/state-controller.js"],[I,"refine/stored-filter-controller.js"],[S,"refine/submit-form-controller.js"],[T,"refine/toggle-controller.js"],[V,"refine/turbo-stream-form-controller.js"],[F,"refine/turbo-stream-link-controller.js"],[E,"./refine/typeahead-list-controller.js"],[P,"refine/update-controller.js"],[j,"refine/date-controller.js"]].map(function(e){const t=e[0];return{identifier:d(e[1]),controllerConstructor:t}});exports.AddController=h,exports.CriterionFormController=p,exports.DateController=j,exports.DefaultsController=m,exports.DeleteController=f,exports.FilterPillsController=g,exports.PopupController=b,exports.SearchFilterController=v,exports.ServerRefreshController=c,exports.StateController=w,exports.StoredFilterController=I,exports.SubmitForm=S,exports.ToggleController=T,exports.TurboStreamFormController=V,exports.TurboStreamLinkController=F,exports.TypeaheadListController=E,exports.UpdateController=P,exports.controllerDefinitions=x;
1
+ var e=require("@hotwired/stimulus"),t=require("@rails/request.js"),r=require("stimulus-use"),i=require("jquery-events-to-dom-events"),n=require("lodash"),l=require("moment"),o=require("jquery");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("daterangepicker");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 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:{"refine_filters_builder[filter_class]":r.state.filterName,"refine_filters_builder[blueprint_json]":JSON.stringify(r.state.blueprint),"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 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,r=new t.FetchRequest("GET",e.state.validateBlueprintUrlValue,{query:{"refine_filters_builder[filter_class]":e.state.filterName,"refine_filters_builder[blueprint_json]":JSON.stringify(e.state.blueprint),"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)}}}h.values={previousCriterionId:Number};class p extends e.Controller{refresh(e){try{const e=this,r=document.getElementById(e.formIdValue),i=new FormData(r);console.log("in criterion-form refresh event"),console.log(e),console.log(i);const n=new t.FetchRequest("GET",e.urlValue,{query:i,responseKind:"turbo-stream"});return Promise.resolve(n.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}p.values={url:String,formId:String};class m 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}}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 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({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}}g.values={submitUrl:String};class b extends e.Controller{connect(){r.useClickOutside(this),this.boundHandleKeyUp=this.handleKeyUp.bind(this),document.addEventListener("keyup",this.boundHandleKeyUp)}disconnect(){document.removeEventListener("keyup",this.boundHandleKeyUp)}show(e){console.log("In Popup Show"),e.preventDefault(),this.frameTarget.src=this.srcValue,this.isOpenValue=!0}hide(e){this.isOpenValue&&(null==e||e.preventDefault(),this.frameTarget.innerHTML="",this.isOpenValue=!1)}clickOutside(e){this.hide(e)}handleKeyUp(e){"Escape"!==e.key&&"Esc"!==e.key||this.hide(e)}}b.targets=["frame"],b.values={src:String,isOpen:{type:Boolean,default:!1}};class v 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({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}}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)},y=(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=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(y(t.id,1,t)),C(this.element,{blueprint:this.blueprint,formId:this.formIdValue})}addCriterion(e){console.log("Add criteria");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"},y(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(y));const l=this.blueprint[e],o=y(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})}clearCriteria(){console.log("In clearCriteria"),C(this.element,{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{submit(e){e.preventDefault(),this.element.submit()}}class T extends e.Controller{toggle(e){this.contentTargets.forEach(e=>{e.toggleAttribute("hidden")})}}T.targets=["content"];class V extends e.Controller{submit(e){try{const r=this;e.preventDefault();const i=new t.FetchRequest(r.element.method||"POST",r.element.action,{responseKind:"turbo-stream",body:new FormData(r.element)});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class F extends e.Controller{visit(e){try{const r=this;e.preventDefault();const i=new t.FetchRequest(r.element.dataset.turboMethod||"GET",r.element.href,{responseKind:"turbo-stream"});return Promise.resolve(i.perform()).then(function(){})}catch(e){return Promise.reject(e)}}}class P extends e.Controller{filter(e){const t=e.currentTarget.value.toLowerCase(),r=new Set;this.listItemTargets.forEach(e=>{e.dataset.listItemValue.toLowerCase().includes(t)?(e.hidden=!1,r.add(e.dataset.category)):e.hidden=!0}),this.categoryTargets.forEach(e=>{e.hidden=!r.has(e.innerHTML)})}}P.targets=["listItem","category"];class E 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())}}E.values={criterionId:Number},require("daterangepicker/daterangepicker.css");class j 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?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")}}j.targets=["field","hiddenField","clearButton"],j.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:{}}};class x extends e.Controller{clear(){console.log("Clearing criteria");const{state:e}=this;e.clearCriteria(),this.refreshFromServer()}}const D=[[h,"refine/add-controller.js"],[p,"refine/criterion-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"],[w,"refine/state-controller.js"],[I,"refine/stored-filter-controller.js"],[S,"refine/submit-form-controller.js"],[T,"refine/toggle-controller.js"],[V,"refine/turbo-stream-form-controller.js"],[F,"refine/turbo-stream-link-controller.js"],[P,"./refine/typeahead-list-controller.js"],[E,"refine/update-controller.js"],[j,"refine/date-controller.js"],[x,"refine/clear-criteria-controller.js"]].map(function(e){const t=e[0];return{identifier:d(e[1]),controllerConstructor:t}});exports.AddController=h,exports.ClearCriteriaController=x,exports.CriterionFormController=p,exports.DateController=j,exports.DefaultsController=m,exports.DeleteController=f,exports.FilterPillsController=g,exports.PopupController=b,exports.SearchFilterController=v,exports.ServerRefreshController=c,exports.StateController=w,exports.StoredFilterController=I,exports.SubmitForm=S,exports.ToggleController=T,exports.TurboStreamFormController=V,exports.TurboStreamLinkController=F,exports.TypeaheadListController=P,exports.UpdateController=E,exports.controllerDefinitions=D;
2
2
  //# sourceMappingURL=refine-stimulus.js.map