stimulus_reflex 3.5.0.pre8 → 3.5.0.pre10

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of stimulus_reflex might be problematic. Click here for more details.

Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -1218
  3. data/Gemfile +0 -1
  4. data/Gemfile.lock +145 -193
  5. data/README.md +48 -20
  6. data/Rakefile +0 -8
  7. data/app/assets/javascripts/stimulus_reflex.js +1174 -0
  8. data/app/assets/javascripts/stimulus_reflex.min.js +2 -0
  9. data/app/assets/javascripts/stimulus_reflex.min.js.map +1 -0
  10. data/app/assets/javascripts/stimulus_reflex.umd.js +1064 -0
  11. data/app/assets/javascripts/stimulus_reflex.umd.min.js +1065 -0
  12. data/app/assets/javascripts/stimulus_reflex.umd.min.js.map +1 -0
  13. data/app/channels/stimulus_reflex/channel.rb +28 -7
  14. data/bin/console +0 -2
  15. data/bin/standardize +2 -1
  16. data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +72 -7
  17. data/lib/generators/stimulus_reflex/templates/app/controllers/examples_controller.rb.tt +9 -0
  18. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/consumer.js.tt +6 -0
  19. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.esbuild.tt +4 -0
  20. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.importmap.tt +2 -0
  21. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.shakapacker.tt +5 -0
  22. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.vite.tt +1 -0
  23. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.webpacker.tt +5 -0
  24. data/lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt +4 -0
  25. data/lib/generators/stimulus_reflex/templates/app/javascript/config/index.js.tt +2 -0
  26. data/lib/generators/stimulus_reflex/templates/app/javascript/config/mrujs.js.tt +9 -0
  27. data/lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt +5 -0
  28. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +114 -74
  29. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt +11 -0
  30. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt +49 -35
  31. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.esbuild.tt +7 -0
  32. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.importmap.tt +5 -0
  33. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.shakapacker.tt +5 -0
  34. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.vite.tt +5 -0
  35. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.webpacker.tt +5 -0
  36. data/lib/generators/stimulus_reflex/templates/app/reflexes/%file_name%_reflex.rb.tt +38 -7
  37. data/lib/generators/stimulus_reflex/templates/app/reflexes/application_reflex.rb.tt +10 -2
  38. data/lib/generators/stimulus_reflex/templates/app/views/examples/show.html.erb.tt +207 -0
  39. data/lib/generators/stimulus_reflex/templates/config/initializers/cable_ready.rb +22 -0
  40. data/lib/generators/stimulus_reflex/templates/config/initializers/stimulus_reflex.rb +18 -13
  41. data/lib/generators/stimulus_reflex/templates/esbuild.config.mjs.tt +94 -0
  42. data/lib/install/action_cable.rb +155 -0
  43. data/lib/install/broadcaster.rb +90 -0
  44. data/lib/install/bundle.rb +56 -0
  45. data/lib/install/compression.rb +41 -0
  46. data/lib/install/config.rb +87 -0
  47. data/lib/install/development.rb +110 -0
  48. data/lib/install/esbuild.rb +114 -0
  49. data/lib/install/example.rb +22 -0
  50. data/lib/install/importmap.rb +133 -0
  51. data/lib/install/initializers.rb +25 -0
  52. data/lib/install/mrujs.rb +133 -0
  53. data/lib/install/npm_packages.rb +25 -0
  54. data/lib/install/reflexes.rb +25 -0
  55. data/lib/install/shakapacker.rb +64 -0
  56. data/lib/install/spring.rb +54 -0
  57. data/lib/install/updatable.rb +34 -0
  58. data/lib/install/vite.rb +64 -0
  59. data/lib/install/webpacker.rb +90 -0
  60. data/lib/install/yarn.rb +55 -0
  61. data/lib/stimulus_reflex/broadcasters/broadcaster.rb +15 -8
  62. data/lib/stimulus_reflex/broadcasters/page_broadcaster.rb +7 -8
  63. data/lib/stimulus_reflex/broadcasters/selector_broadcaster.rb +10 -10
  64. data/lib/stimulus_reflex/broadcasters/update.rb +3 -0
  65. data/lib/stimulus_reflex/cable_readiness.rb +29 -0
  66. data/lib/stimulus_reflex/cable_ready_channels.rb +5 -5
  67. data/lib/stimulus_reflex/callbacks.rb +17 -1
  68. data/lib/stimulus_reflex/concern_enhancer.rb +6 -4
  69. data/lib/stimulus_reflex/configuration.rb +12 -2
  70. data/lib/stimulus_reflex/dataset.rb +11 -1
  71. data/lib/stimulus_reflex/engine.rb +40 -0
  72. data/lib/stimulus_reflex/html/document.rb +59 -0
  73. data/lib/stimulus_reflex/html/document_fragment.rb +13 -0
  74. data/lib/stimulus_reflex/importmap.rb +7 -0
  75. data/lib/stimulus_reflex/installer.rb +274 -0
  76. data/lib/stimulus_reflex/open_struct_fix.rb +31 -0
  77. data/lib/stimulus_reflex/reflex.rb +32 -25
  78. data/lib/stimulus_reflex/reflex_data.rb +18 -2
  79. data/lib/stimulus_reflex/reflex_factory.rb +6 -3
  80. data/lib/stimulus_reflex/request_parameters.rb +2 -0
  81. data/lib/stimulus_reflex/utils/logger.rb +12 -0
  82. data/lib/stimulus_reflex/utils/sanity_checker.rb +8 -106
  83. data/lib/stimulus_reflex/version.rb +1 -1
  84. data/lib/stimulus_reflex.rb +4 -6
  85. data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +252 -0
  86. data/package.json +73 -0
  87. data/rollup.config.mjs +86 -0
  88. data/stimulus_reflex.gemspec +60 -0
  89. data/web-test-runner.config.mjs +12 -0
  90. data/yarn.lock +5098 -0
  91. metadata +191 -78
  92. data/LATEST +0 -1
  93. data/lib/generators/USAGE +0 -14
  94. data/lib/generators/stimulus_reflex/initializer_generator.rb +0 -14
  95. data/lib/tasks/stimulus_reflex/install.rake +0 -116
  96. data/test/broadcasters/broadcaster_test.rb +0 -11
  97. data/test/broadcasters/broadcaster_test_case.rb +0 -39
  98. data/test/broadcasters/nothing_broadcaster_test.rb +0 -30
  99. data/test/broadcasters/page_broadcaster_test.rb +0 -77
  100. data/test/broadcasters/selector_broadcaster_test.rb +0 -167
  101. data/test/callbacks_test.rb +0 -652
  102. data/test/concern_enhancer_test.rb +0 -54
  103. data/test/element_test.rb +0 -254
  104. data/test/generators/stimulus_reflex_generator_test.rb +0 -58
  105. data/test/reflex_test.rb +0 -43
  106. data/test/test_helper.rb +0 -71
  107. data/test/tmp/app/reflexes/application_reflex.rb +0 -19
  108. data/test/tmp/app/reflexes/demo_reflex.rb +0 -35
@@ -0,0 +1,2 @@
1
+ import{Controller as e}from"@hotwired/stimulus";import{createConsumer as t}from"@rails/actioncable";import r,{Utils as l}from"cable_ready";let n=!0;var o={get enabled(){return n},get disabled(){return!n},get value(){return n},set(e){n=!!e},set deprecate(e){n=!!e}};let s=!1;var i={get enabled(){return s},get disabled(){return!s},get value(){return s},set(e){s=!!e},set debug(e){s=!!e}};const a={reflexAttribute:"data-reflex",reflexPermanentAttribute:"data-reflex-permanent",reflexRootAttribute:"data-reflex-root",reflexSuppressLoggingAttribute:"data-reflex-suppress-logging",reflexDatasetAttribute:"data-reflex-dataset",reflexDatasetAllAttribute:"data-reflex-dataset-all",reflexSerializeFormAttribute:"data-reflex-serialize-form",reflexFormSelectorAttribute:"data-reflex-form-selector",reflexIncludeInnerHtmlAttribute:"data-reflex-include-inner-html",reflexIncludeTextContentAttribute:"data-reflex-include-text-content"};let d={};var c={set(e){d={...a,...e.schema};for(const e in d){const t=e.slice(0,-9);Object.defineProperty(this,t,{get:()=>d[e],configurable:!0})}}};const{debounce:u,dispatch:m,xpathToElement:f,xpathToElementArray:p}=l,h=()=>{const e=window.crypto||window.msCrypto;return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(t=>(t^e.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)))},g=(e,t=!0)=>"string"!=typeof e?"":(e=e.replace(/[\s_](.)/g,(e=>e.toUpperCase())).replace(/[\s_]/g,"").replace(/^(.)/,(e=>e.toLowerCase())),t&&(e=e.substr(0,1).toUpperCase()+e.substr(1)),e),x=f,b=p,v=(e,t={})=>m(document,e,t),y=e=>{if(""!==e.id)return"//*[@id='"+e.id+"']";if(e===document.body)return"/html/body";if("HTML"===e.nodeName)return"/html";let t=0;const r=e&&e.parentNode?e.parentNode.childNodes:[];for(var l=0;l<r.length;l++){const n=r[l];if(n===e){return`${y(e.parentNode)}/${e.tagName.toLowerCase()}[${t+1}]`}1===n.nodeType&&n.tagName===e.tagName&&t++}},E=["created","before","delivered","queued","after","finalized","success","error","halted","forbidden"];let w;const L=new Proxy({},{get:function(e,t){return E.includes(t)?Object.fromEntries(Object.entries(e).filter((([e,r])=>r.stage===t))):"last"===t?w:"all"===t?e:Reflect.get(...arguments)},set:function(e,t,r){return e[t]=r,w=r,!0}}),R=(e,t)=>{const r=e.controller[["before","after","finalize"].includes(t)?`${t}${g(e.action)}`:`${g(e.action,!1)}${g(t)}`],l=e.controller[["before","after","finalize"].includes(t)?`${t}Reflex`:`reflex${g(t)}`];"function"==typeof r&&r.call(e.controller,e.element,e.target,e.error,e.id,e.payload),"function"==typeof l&&l.call(e.controller,e.element,e.target,e.error,e.id,e.payload)},$=(e,t)=>{if(!e.controller.element.parentElement)return void(i.enabled&&!e.warned&&(console.warn(`StimulusReflex was not able execute callbacks or emit events for "${t}" or later life-cycle stages for this Reflex. The StimulusReflex Controller Element is no longer present in the DOM. Could you move the StimulusReflex Controller to an element higher in your DOM?`),e.warned=!0));e.stage=t,e.lifecycle.push(t);const r=`stimulus-reflex:${t}`,l=`${r}:${e.action}`,n={reflex:e.target,controller:e.controller,id:e.id,element:e.element,payload:e.payload},o={bubbles:!0,cancelable:!1,detail:n};e.controller.element.dispatchEvent(new CustomEvent(r,o)),e.controller.element.dispatchEvent(new CustomEvent(l,o)),window.jQuery&&(window.jQuery(e.controller.element).trigger(r,n),window.jQuery(e.controller.element).trigger(l,n))};document.addEventListener("stimulus-reflex:before",(e=>R(L[e.detail.id],"before")),!0),document.addEventListener("stimulus-reflex:queued",(e=>R(L[e.detail.id],"queued")),!0),document.addEventListener("stimulus-reflex:delivered",(e=>R(L[e.detail.id],"delivered")),!0),document.addEventListener("stimulus-reflex:success",(e=>{const t=L[e.detail.id];R(t,"success"),$(t,"after")}),!0),document.addEventListener("stimulus-reflex:nothing",(e=>$(L[e.detail.id],"success")),!0),document.addEventListener("stimulus-reflex:error",(e=>{const t=L[e.detail.id];R(t,"error"),$(t,"after")}),!0),document.addEventListener("stimulus-reflex:halted",(e=>R(L[e.detail.id],"halted")),!0),document.addEventListener("stimulus-reflex:forbidden",(e=>R(L[e.detail.id],"forbidden")),!0),document.addEventListener("stimulus-reflex:after",(e=>R(L[e.detail.id],"after")),!0),document.addEventListener("stimulus-reflex:finalize",(e=>R(L[e.detail.id],"finalize")),!0);let A={};var S={get app(){return A},set(e){A=e}};let C=!1;var O={get disabled(){return!C},set(e){C=e,o.enabled&&!C&&document.addEventListener("DOMContentLoaded",(()=>console.warn("Deprecation warning: the next version of StimulusReflex will standardize isolation mode, and the isolate option will be removed.\nPlease update your applications to assume that every tab will be isolated. Use CableReady operations to broadcast updates to other tabs and users.")),{once:!0})}};class _{constructor(e,t){this.data=e.valueOf(),this.controller=t,this.element=e.reflexElement,this.id=e.id,this.error=null,this.payload=null,this.stage="created",this.lifecycle=["created"],this.warned=!1,this.target=e.target,this.action=e.target.split("#")[1],this.selector=null,this.morph=null,this.operation=null,this.timestamp=new Date,this.cloned=!1}get getPromise(){const e=new Promise(((e,t)=>{this.promise={resolve:e,reject:t,data:this.data}}));return e.id=this.id,Object.defineProperty(e,"reflexId",{get(){return o.enabled&&console.warn("reflexId is deprecated and will be removed from v4. Use id instead."),this.id}}),e.reflex=this,i.enabled&&e.catch((()=>{})),e}}const j=e=>{if(!e.cableReady)return;if(e.version.replace(".pre","-pre")!==r.version)return void(i.enabled&&console.error(`Reflex failed due to cable_ready gem/NPM package version mismatch. Package versions must match exactly.\nNote that if you are using pre-release builds, gems use the "x.y.z.preN" version format, while NPM packages use "x.y.z-preN".\n\ncable_ready gem: ${e.version}\ncable_ready NPM: ${r.version}`));let t,l=[];for(let t=e.operations.length-1;t>=0;t--)e.operations[t].stimulusReflex&&(l.push(e.operations[t]),e.operations.splice(t,1));if(l.some((e=>e.stimulusReflex.url!==location.href))&&i.enabled)console.error("Reflex failed due to mismatched URL.");else if(l.length&&(t=l[0].stimulusReflex,t.payload=l[0].payload),t){const{id:n,payload:o}=t;let s;if(!L[n]&&O.disabled){const e=x(t.xpathController),r=x(t.xpathElement);e.reflexController=e.reflexController||{},e.reflexData=e.reflexData||{},e.reflexError=e.reflexError||{};const l=S.app.getControllerForElementAndIdentifier(e,t.reflexController);e.reflexController[n]=l,e.reflexData[n]=t,s=new _(t,l),L[n]=s,s.cloned=!0,s.element=r,l.lastReflex=s,$(s,"before"),s.getPromise}else s=L[n];s&&(s.payload=o,s.totalOperations=l.length,s.pendingOperations=l.length,s.completedOperations=0,s.piggybackOperations=e.operations,r.perform(l))}else e.operations.length&&L[e.operations[0].reflexId]&&r.perform(e.operations)};let I,D,T,N;const k=()=>{N=!0,P(),v("stimulus-reflex:connected"),Object.values(L.queued).forEach((e=>{T.send(e.data),$(e,"delivered")}))},z=()=>{N=!1,P(),v("stimulus-reflex:rejected"),Debug.enabled&&console.warn("Channel subscription was rejected.")},F=e=>{N=!1,P(),v("stimulus-reflex:disconnected",e)},P=()=>{const e=document.body.classList;e.contains("stimulus-reflex-connected")||e.contains("stimulus-reflex-disconnected")?N?e.replace("stimulus-reflex-disconnected","stimulus-reflex-connected"):e.replace("stimulus-reflex-connected","stimulus-reflex-disconnected"):e.add(N?"stimulus-reflex-connected":"stimulus-reflex-disconnected")};var M={subscribe:e=>{if(T)return;I=I||e.application.consumer||t();const{channel:r}=e.StimulusReflex,l={channel:r,...D},n=JSON.stringify(l);T=I.subscriptions.findAll(n)[0]||I.subscriptions.create(l,{received:j,connected:k,rejected:z,disconnected:F})},deliver:e=>{N?(T.send(e.data),$(e,"delivered")):$(e,"queued")},initialize:(e,t)=>{I=e,D=t,document.addEventListener("DOMContentLoaded",(()=>{N=!1,P(),o.enabled&&e&&console.warn("Deprecation warning: the next version of StimulusReflex will obtain a reference to consumer via the Stimulus application object.\nPlease add 'application.consumer = consumer' to your index.js after your Stimulus application has been established, and remove the consumer key from your StimulusReflex initialize() options object.")})),document.addEventListener("turbolinks:load",P),document.addEventListener("turbo:load",P)}};const q=e=>e.cloned?"CLONED":`in ${new Date-e.timestamp}ms`,U=e=>e.totalOperations>1?` ${e.completedOperations}/${e.totalOperations}`:"";var H=e=>{i.disabled||e.data.suppressLogging||console.log(`↑ stimulus ↑ ${e.target}`,{id:e.id,args:e.data.args,controller:e.controller.identifier,element:e.element,controllerElement:e.controller.element})},B=e=>{if(i.disabled||e.data.suppressLogging)return;const t={id:e.id,morph:e.morph,payload:e.payload};"dispatch_event"!==e.operation&&(t.operation=e.operation),console.log(`↓ reflex ↓ ${e.target} → ${e.selector||"∞"}${U(e)} ${q(e)}`,t)},Q=e=>{i.disabled||e.data.suppressLogging||console.log(`↓ reflex ↓ ${e.target} ${q(e)} %cHALTED`,"color: #ffa500;",{id:e.id,payload:e.payload})},J=e=>{i.disabled||e.data.suppressLogging||console.log(`↓ reflex ↓ ${e.target} ${q(e)} %cFORBIDDEN`,"color: #BF40BF;",{id:e.id,payload:e.payload})},V=e=>{i.disabled||e.data.suppressLogging||console.log(`↓ reflex ↓ ${e.target} ${q(e)} %cERROR: ${e.error}`,"color: #f00;",{id:e.id,payload:e.payload})};const W=(e=[])=>{const t=Array.from(new Set(e.filter((e=>e&&String(e).length)).map((e=>e.trim())))).join(" ").trim();return t.length>0?t:null},Z=e=>e&&e.length?e.split(" ").filter((e=>e.trim().length)):[],G=e=>{let t=Array.from(e.attributes).reduce(((e,t)=>(e[t.name]=t.value,e)),{});if(t.checked=!!e.checked,t.selected=!!e.selected,t.tag_name=e.tagName,e.tagName.match(/select/i)||(e=>!!["checkbox","radio"].includes(e.type)&&document.querySelectorAll(`input[type="${e.type}"][name="${e.name}"]`).length>1)(e)){const r=(e=>Array.from(e.querySelectorAll("option:checked")).concat(Array.from(document.querySelectorAll(`input[type="${e.type}"][name="${e.name}"]`)).filter((e=>e.checked))).map((e=>e.value)))(e);t.values=r,t.value=r.join(",")}else t.value=e.value;return t},K=(e,t)=>{if(!t||0===t.length)return[];let r=[e];const l=y(e);return t.forEach((e=>{try{switch(e){case"combined":o.enabled&&console.warn("In the next version of StimulusReflex, the 'combined' option to data-reflex-dataset will become 'ancestors'."),r=[...r,...b(`${l}/ancestor::*`,!0)];break;case"ancestors":r=[...r,...b(`${l}/ancestor::*`,!0)];break;case"parent":r=[...r,...b(`${l}/parent::*`)];break;case"siblings":r=[...r,...b(`${l}/preceding-sibling::*|${l}/following-sibling::*`)];break;case"children":r=[...r,...b(`${l}/child::*`)];break;case"descendants":r=[...r,...b(`${l}/descendant::*`)];break;default:r=[...r,...document.querySelectorAll(e)]}}catch(e){i.enabled&&console.error(e)}})),r},X=e=>{let t={};return e&&e.attributes&&Array.from(e.attributes).forEach((e=>{e.name.startsWith("data-")&&(t[e.name]=e.value)})),t};var Y="3.5.0-pre10";class ee{constructor(e,t,r,l,n,o,s,i,a){this.options=e,this.reflexElement=t,this.controllerElement=r,this.reflexController=l,this.permanentAttributeName=n,this.target=o,this.args=s,this.url=i,this.tabId=a}get attrs(){return this._attrs=this._attrs||this.options.attrs||G(this.reflexElement),this._attrs}get id(){return this._id=this._id||this.options.id||h(),this._id}get selectors(){return this._selectors=this._selectors||this.options.selectors||(e=>{let t=[];for(;0===t.length&&e;){let r=e.getAttribute(c.reflexRoot);if(r){0===r.length&&e.id&&(r=`#${e.id}`);const l=r.split(",").filter((e=>e.trim().length));i.enabled&&0===l.length&&console.error(`No value found for ${c.reflexRoot}. Add an #id to the element or provide a value for ${c.reflexRoot}.`,e),t=t.concat(l.filter((e=>document.querySelector(e))))}e=e.parentElement?e.parentElement.closest(`[${c.reflexRoot}]`):null}return t})(this.reflexElement),"string"==typeof this._selectors?[this._selectors]:this._selectors}get resolveLate(){return this.options.resolveLate||!1}get dataset(){return this._dataset=this._dataset||(e=>{const t=e.attributes[c.reflexDataset],r=e.attributes[c.reflexDatasetAll],l=t&&t.value.split(" ")||[],n=r&&r.value.split(" ")||[],o=K(e,l),s=K(e,n),i=o.reduce(((e,t)=>({...X(t),...e})),{}),a={dataset:{...X(e),...i},datasetAll:{}};return s.forEach((e=>{const t=X(e);Object.keys(t).forEach((e=>{const r=t[e];a.datasetAll[e]&&Array.isArray(a.datasetAll[e])?a.datasetAll[e].push(r):a.datasetAll[e]=[r]}))})),a})(this.reflexElement),this._dataset}get innerHTML(){return this.includeInnerHtml?this.reflexElement.innerHTML:""}get textContent(){return this.includeTextContent?this.reflexElement.textContent:""}get xpathController(){return y(this.controllerElement)}get xpathElement(){return y(this.reflexElement)}get formSelector(){const e=this.reflexElement.attributes[c.reflexFormSelector]?this.reflexElement.attributes[c.reflexFormSelector].value:void 0;return this.options.formSelector||e}get includeInnerHtml(){const e=this.reflexElement.attributes[c.reflexIncludeInnerHtml]||!1;return!(!this.options.includeInnerHTML&&!e)&&"false"!==e.value}get includeTextContent(){const e=this.reflexElement.attributes[c.reflexIncludeTextContent]||!1;return!(!this.options.includeTextContent&&!e)&&"false"!==e.value}get suppressLogging(){return this.options.suppressLogging||this.reflexElement.attributes[c.reflexSuppressLogging]||!1}valueOf(){return{attrs:this.attrs,dataset:this.dataset,selectors:this.selectors,id:this.id,resolveLate:this.resolveLate,suppressLogging:this.suppressLogging,xpathController:this.xpathController,xpathElement:this.xpathElement,inner_html:this.innerHTML,text_content:this.textContent,formSelector:this.formSelector,reflexController:this.reflexController,permanentAttributeName:this.permanentAttributeName,target:this.target,args:this.args,url:this.url,tabId:this.tabId,version:Y}}}let te={};var re={get plugin(){return te},set(e){te=e}};const le=e=>{const{stimulusReflex:t}=e.detail||{};if(!t)return;const r=L[t.id];r.pendingOperations--,r.pendingOperations>0||(t.resolveLate||setTimeout((()=>r.promise.resolve({element:r.element,event:e,data:r.data,payload:r.payload,id:r.id,toString:()=>""}))),setTimeout((()=>$(r,"success"))))},ne=e=>{const{stimulusReflex:t}=e.detail||{};if(!t)return;const l=L[t.id];l.completedOperations++,l.selector=e.detail.selector,l.morph=e.detail.stimulusReflex.morph,l.operation=e.type.split(":")[1].split("-").slice(1).join("_"),B(l),l.completedOperations<l.totalOperations||(t.resolveLate&&setTimeout((()=>l.promise.resolve({element:l.element,event:e,data:l.data,payload:l.payload,id:l.id,toString:()=>""}))),setTimeout((()=>$(l,"finalize"))),l.piggybackOperations.length&&r.perform(l.piggybackOperations))},oe=(e,t)=>{B(e),setTimeout((()=>e.promise.resolve({data:e.data,element:e.element,event:t,payload:e.payload,id:e.id,toString:()=>""})))},se=(e,t)=>{Q(e,t),setTimeout((()=>e.promise.resolve({data:e.data,element:e.element,event:t,payload:e.payload,id:e.id,toString:()=>""})))},ie=(e,t)=>{J(e,t),setTimeout((()=>e.promise.resolve({data:e.data,element:e.element,event:t,payload:e.payload,id:e.id,toString:()=>""})))},ae=(e,t)=>{V(e,t),setTimeout((()=>e.promise.reject({data:e.data,element:e.element,event:t,payload:e.payload,id:e.id,error:e.error,toString:()=>e.error})))},de=e=>Z(e.getAttribute(c.controller)).reduce(((t,r)=>{const l=S.app.getControllerForElementAndIdentifier(e,r);return l&&l.StimulusReflex&&t.push(l),t}),[]),ce=u((()=>{document.querySelectorAll(`[${c.reflex}]`).forEach((e=>ue(e)))}),20),ue=e=>{const t=e.getAttribute(c.controller),r=Z(t),l=e.getAttribute(c.reflex),n=Z(l),o=e.getAttribute(c.action),s=Z(o).filter((e=>!e.includes("#__perform")));n.forEach((t=>{const l=((e,t)=>t.find((t=>{if(t.identifier)return(e=>{const t=e.match(/(?:.*->)?(.*?)(?:Reflex)?#/);return t?t[1]:""})(e).replace(/([a-z0–9])([A-Z])/g,"$1-$2").replace(/(::)/g,"--").toLowerCase()===t.identifier}))||t[0])(t,(e=>{let t=[];for(;e;)t=t.concat(de(e)),e=e.parentElement;return t})(e)),n=l?l.identifier:"stimulus-reflex";s.push(`${t.split("->")[0]}->${n}#__perform`),r.push(n)}));const i=W(r),a=W(s);let d=!1;i&&e.getAttribute(c.controller)!=i&&(e.setAttribute(c.controller,i),d=!0),a&&e.getAttribute(c.action)!=a&&(e.setAttribute(c.action,a),d=!0),d&&m(e,"stimulus-reflex:ready",{reflex:l,controller:i,action:a,element:e})};class me extends e{constructor(...e){super(...e),he(this)}}const fe=h(),pe=(e,{controller:t,consumer:r,debug:l,params:n,isolate:s,deprecate:a,transport:d}={})=>{re.set(d||M),re.plugin.initialize(r,n),O.set(!!s),S.set(e),c.set(e),S.app.register("stimulus-reflex",t||me),i.set(!!l),void 0!==a&&o.set(a);new MutationObserver(ce).observe(document.documentElement,{attributeFilter:[c.reflex,c.action],childList:!0,subtree:!0}),v("stimulus-reflex:initialized")},he=(e,t={})=>{e.StimulusReflex={...t,channel:"StimulusReflex::Channel"},re.plugin.subscribe(e),Object.assign(e,{stimulate(){const e=location.href,t=this.element,r=Array.from(arguments),l=r.shift()||"StimulusReflex::Reflex#default_reflex",n=((e,t)=>e[0]&&e[0].nodeType===Node.ELEMENT_NODE?e.shift():t)(r,t);if("number"===(s=n).type&&s.validity&&s.validity.badInput)return void(i.enabled&&console.warn("Reflex aborted: invalid numeric input"));var s;const a=(e=>{const t={};if(e[0]&&"object"==typeof e[0]&&Object.keys(e[0]).filter((e=>["id","attrs","selectors","reflexId","resolveLate","serializeForm","suppressLogging","includeInnerHTML","includeTextContent"].includes(e))).length){const r=e.shift();Object.keys(r).forEach((e=>{"reflexId"===e?(o.enabled&&console.warn("reflexId option will be removed in v4. Use id instead."),t.id=r.reflexId):t[e]=r[e]}))}return t})(r),d=new ee(a,n,t,this.identifier,c.reflexPermanent,l,r,e,fe),u=d.id;t.reflexController=t.reflexController||{},t.reflexData=t.reflexData||{},t.reflexError=t.reflexError||{},t.reflexController[u]=this,t.reflexData[u]=d.valueOf();const m=new _(d,this);return L[u]=m,this.lastReflex=m,$(m,"before"),setTimeout((()=>{const{params:e}=t.reflexData[u]||{},r=n.attributes[c.reflexSerializeForm];r&&(a.serializeForm="false"!==r.value);const l=n.closest(d.formSelector)||document.querySelector(d.formSelector)||n.closest("form");o.enabled&&void 0===a.serializeForm&&l&&console.warn(`Deprecation warning: the next version of StimulusReflex will not serialize forms by default.\nPlease set ${c.reflexSerializeForm}="true" on your Reflex Controller Element or pass { serializeForm: true } as an option to stimulate.`);const s=!1===a.serializeForm?"":((e,t={})=>{if(!e)return"";const r=t.w||window,{element:l}=t,n=new r.FormData(e),o=Array.from(n,(e=>e.map(encodeURIComponent).join("="))),s=e.querySelector("input[type=submit]");return l&&l.name&&"INPUT"===l.nodeName&&"submit"===l.type?o.push(`${encodeURIComponent(l.name)}=${encodeURIComponent(l.value)}`):s&&s.name&&o.push(`${encodeURIComponent(s.name)}=${encodeURIComponent(s.value)}`),Array.from(o).join("&")})(l,{element:n});m.data={...d.valueOf(),params:e,formData:s},t.reflexData[u]=m.data,re.plugin.deliver(m)})),H(m),m.getPromise},__perform(e){let t,r=e.target;for(;r&&!t;)t=r.getAttribute(c.reflex),t&&t.trim().length||(r=r.parentElement);const l=Z(t).find((t=>t.split("->")[0]===e.type));l&&(e.preventDefault(),e.stopPropagation(),this.stimulate(l.split("->")[1],r))}}),e.reflexes||Object.defineProperty(e,"reflexes",{get(){return new Proxy(L,{get:function(e,t){return"last"===t?this.lastReflex:Object.fromEntries(Object.entries(e[t]).filter((([e,t])=>t.controller===this)))}.bind(this)})}}),ue(e.element),v("stimulus-reflex:controller-registered",{detail:{controller:e}})},ge=(e,t={})=>{he(e,t)};document.addEventListener("cable-ready:after-dispatch-event",(e=>{const{stimulusReflex:t,name:l}=e.detail||{},n=l.split("-")[2],o={nothing:oe,halted:se,forbidden:ie,error:ae};if(!t||!Object.keys(o).includes(n))return;const s=L[t.id];s.completedOperations++,s.pendingOperations--,s.selector=e.detail.selector,s.morph=e.detail.stimulusReflex.morph,s.operation=e.type.split(":")[1].split("-").slice(1).join("_"),"error"===n&&(s.error=e.detail.error),o[n](s,e),setTimeout((()=>$(s,n))),s.piggybackOperations.length&&r.perform(s.piggybackOperations)})),document.addEventListener("cable-ready:before-inner-html",le),document.addEventListener("cable-ready:before-morph",le),document.addEventListener("cable-ready:after-inner-html",ne),document.addEventListener("cable-ready:after-morph",ne),document.addEventListener("readystatechange",(()=>{"complete"===document.readyState&&ce()}));const xe={version:Y,...Object.freeze({__proto__:null,initialize:pe,reflexes:L,register:he,scanForReflexes:ce,scanForReflexesOnElement:ue,useReflex:ge}),get debug(){return i.value},set debug(e){i.set(!!e)},get deprecate(){return o.value},set deprecate(e){o.set(!!e)}};window.StimulusReflex=xe;export{xe as default,pe as initialize,L as reflexes,he as register,ce as scanForReflexes,ue as scanForReflexesOnElement,ge as useReflex};
2
+ //# sourceMappingURL=stimulus_reflex.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stimulus_reflex.min.js","sources":["../../../javascript/deprecate.js","../../../javascript/debug.js","../../../javascript/schema.js","../../../javascript/utils.js","../../../javascript/reflexes.js","../../../javascript/lifecycle.js","../../../javascript/app.js","../../../javascript/isolation_mode.js","../../../javascript/reflex.js","../../../javascript/process.js","../../../javascript/transports/action_cable.js","../../../javascript/log.js","../../../javascript/attributes.js","../../../javascript/reflex_data.js","../../../javascript/transport.js","../../../javascript/callbacks.js","../../../javascript/controllers.js","../../../javascript/scanner.js","../../../javascript/stimulus_reflex.js","../../../javascript/index.js"],"sourcesContent":["let deprecationWarnings = true\n\nexport default {\n get enabled () {\n return deprecationWarnings\n },\n get disabled () {\n return !deprecationWarnings\n },\n get value () {\n return deprecationWarnings\n },\n set (value) {\n deprecationWarnings = !!value\n },\n set deprecate (value) {\n deprecationWarnings = !!value\n }\n}\n","let debugging = false\n\nexport default {\n get enabled () {\n return debugging\n },\n get disabled () {\n return !debugging\n },\n get value () {\n return debugging\n },\n set (value) {\n debugging = !!value\n },\n set debug (value) {\n debugging = !!value\n }\n}\n","const defaultSchema = {\n reflexAttribute: 'data-reflex',\n reflexPermanentAttribute: 'data-reflex-permanent',\n reflexRootAttribute: 'data-reflex-root',\n reflexSuppressLoggingAttribute: 'data-reflex-suppress-logging',\n reflexDatasetAttribute: 'data-reflex-dataset',\n reflexDatasetAllAttribute: 'data-reflex-dataset-all',\n reflexSerializeFormAttribute: 'data-reflex-serialize-form',\n reflexFormSelectorAttribute: 'data-reflex-form-selector',\n reflexIncludeInnerHtmlAttribute: 'data-reflex-include-inner-html',\n reflexIncludeTextContentAttribute: 'data-reflex-include-text-content'\n}\n\nlet schema = {}\n\nexport { schema, defaultSchema }\n\nexport default {\n set (application) {\n schema = { ...defaultSchema, ...application.schema }\n for (const attribute in schema) {\n const attributeName = attribute.slice(0, -9)\n\n Object.defineProperty(this, attributeName, {\n get: () => {\n return schema[attribute]\n },\n configurable: true\n })\n }\n }\n}\n","import Debug from './debug'\nimport Deprecate from './deprecate'\nimport Schema from './schema'\n\nimport { Utils } from 'cable_ready'\n\nconst { debounce, dispatch, xpathToElement, xpathToElementArray } = Utils\n\n// uuid4 function taken from stackoverflow\n// https://stackoverflow.com/a/2117523/554903\n\nconst uuidv4 = () => {\n const crypto = window.crypto || window.msCrypto\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>\n (\n c ^\n (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))\n ).toString(16)\n )\n}\n\nconst serializeForm = (form, options = {}) => {\n if (!form) return ''\n\n const w = options.w || window\n const { element } = options\n const formData = new w.FormData(form)\n const data = Array.from(formData, e => e.map(encodeURIComponent).join('='))\n const submitButton = form.querySelector('input[type=submit]')\n if (\n element &&\n element.name &&\n element.nodeName === 'INPUT' &&\n element.type === 'submit'\n ) {\n data.push(\n `${encodeURIComponent(element.name)}=${encodeURIComponent(element.value)}`\n )\n } else if (submitButton && submitButton.name) {\n data.push(\n `${encodeURIComponent(submitButton.name)}=${encodeURIComponent(\n submitButton.value\n )}`\n )\n }\n return Array.from(data).join('&')\n}\n\nconst camelize = (value, uppercaseFirstLetter = true) => {\n if (typeof value !== 'string') return ''\n value = value\n .replace(/[\\s_](.)/g, $1 => $1.toUpperCase())\n .replace(/[\\s_]/g, '')\n .replace(/^(.)/, $1 => $1.toLowerCase())\n\n if (uppercaseFirstLetter)\n value = value.substr(0, 1).toUpperCase() + value.substr(1)\n\n return value\n}\n\n// TODO: remove this in v4 (potentially!)\nconst XPathToElement = xpathToElement\nconst XPathToArray = xpathToElementArray\nconst emitEvent = (name, detail = {}) => dispatch(document, name, detail)\n\nconst extractReflexName = reflexString => {\n const match = reflexString.match(/(?:.*->)?(.*?)(?:Reflex)?#/)\n\n return match ? match[1] : ''\n}\n\n// construct a valid xPath for an element in the DOM\nconst elementToXPath = element => {\n if (element.id !== '') return \"//*[@id='\" + element.id + \"']\"\n if (element === document.body) return '/html/body'\n if (element.nodeName === 'HTML') return '/html'\n\n let ix = 0\n const siblings =\n element && element.parentNode ? element.parentNode.childNodes : []\n\n for (var i = 0; i < siblings.length; i++) {\n const sibling = siblings[i]\n if (sibling === element) {\n const computedPath = elementToXPath(element.parentNode)\n const tagName = element.tagName.toLowerCase()\n const ixInc = ix + 1\n return `${computedPath}/${tagName}[${ixInc}]`\n }\n\n if (sibling.nodeType === 1 && sibling.tagName === element.tagName) {\n ix++\n }\n }\n}\n\nconst elementInvalid = element => {\n return (\n element.type === 'number' && element.validity && element.validity.badInput\n )\n}\n\nconst getReflexElement = (args, element) => {\n return args[0] && args[0].nodeType === Node.ELEMENT_NODE\n ? args.shift()\n : element\n}\n\nconst getReflexOptions = args => {\n const options = {}\n // TODO: remove reflexId in v4\n if (\n args[0] &&\n typeof args[0] === 'object' &&\n Object.keys(args[0]).filter(key =>\n [\n 'id',\n 'attrs',\n 'selectors',\n 'reflexId',\n 'resolveLate',\n 'serializeForm',\n 'suppressLogging',\n 'includeInnerHTML',\n 'includeTextContent'\n ].includes(key)\n ).length\n ) {\n const opts = args.shift()\n // TODO: in v4, all promises resolve during finalize stage\n // if they specify resolveLate, console.warn to say that the option will be ignored\n // deprecation warning in 3.5 is not required as it's still required until v4\n Object.keys(opts).forEach(o => {\n // TODO: no need to check for reflexId in v4\n if (o === 'reflexId') {\n if (Deprecate.enabled)\n console.warn('reflexId option will be removed in v4. Use id instead.')\n options['id'] = opts['reflexId']\n } else options[o] = opts[o]\n })\n }\n return options\n}\n\n// compute the DOM element(s) which will be the morph root\n// use the data-reflex-root attribute on the reflex or the controller\n// optional value is a CSS selector(s); comma-separated list\n// order of preference is data-reflex, data-controller, document body (default)\nconst getReflexRoots = element => {\n let list = []\n while (list.length === 0 && element) {\n let reflexRoot = element.getAttribute(Schema.reflexRoot)\n if (reflexRoot) {\n if (reflexRoot.length === 0 && element.id) reflexRoot = `#${element.id}`\n const selectors = reflexRoot.split(',').filter(s => s.trim().length)\n if (Debug.enabled && selectors.length === 0) {\n console.error(\n `No value found for ${Schema.reflexRoot}. Add an #id to the element or provide a value for ${Schema.reflexRoot}.`,\n element\n )\n }\n list = list.concat(selectors.filter(s => document.querySelector(s)))\n }\n element = element.parentElement\n ? element.parentElement.closest(`[${Schema.reflexRoot}]`)\n : null\n }\n return list\n}\n\nexport {\n uuidv4,\n serializeForm,\n camelize,\n debounce,\n dispatch,\n extractReflexName,\n emitEvent,\n elementToXPath,\n XPathToElement,\n XPathToArray,\n elementInvalid,\n getReflexElement,\n getReflexOptions,\n getReflexRoots\n}\n","const stages = [\n 'created',\n 'before',\n 'delivered',\n 'queued',\n 'after',\n 'finalized',\n 'success',\n 'error',\n 'halted',\n 'forbidden'\n]\nlet lastReflex\n\nexport const reflexes = new Proxy(\n {}, // You are standing in an open field west of a white house, with a boarded front door.\n {\n get: function (target, prop) {\n if (stages.includes(prop))\n return Object.fromEntries(\n Object.entries(target).filter(([_, reflex]) => reflex.stage === prop)\n )\n else if (prop === 'last') return lastReflex\n else if (prop === 'all') return target\n return Reflect.get(...arguments)\n },\n set: function (target, prop, value) {\n target[prop] = value\n lastReflex = value\n return true\n }\n }\n)\n","import Debug from './debug'\n\nimport { camelize } from './utils'\nimport { reflexes } from './reflexes'\n\n// lifecycle stages\n// * created (at initialization)\n// * before\n// * delivered\n// * queued\n// * success\n// * error\n// * halted\n// * forbidden\n// * after\n// * finalize\n\n// Invokes a lifecycle method on a StimulusReflex controller.\n// - reflex - the Reflex object\n// - stage - the lifecycle stage\n//\nconst invokeLifecycleMethod = (reflex, stage) => {\n // TODO: v4 reevaluate benefit of naming complexity vs semantic payoff\n const specificLifecycleMethod =\n reflex.controller[\n ['before', 'after', 'finalize'].includes(stage)\n ? `${stage}${camelize(reflex.action)}`\n : `${camelize(reflex.action, false)}${camelize(stage)}`\n ]\n\n const genericLifecycleMethod =\n reflex.controller[\n ['before', 'after', 'finalize'].includes(stage)\n ? `${stage}Reflex`\n : `reflex${camelize(stage)}`\n ]\n\n // TODO: v4 just pass reflex into the lifecycle method\n if (typeof specificLifecycleMethod === 'function') {\n specificLifecycleMethod.call(\n reflex.controller,\n reflex.element,\n reflex.target,\n reflex.error,\n reflex.id,\n reflex.payload\n )\n }\n\n // TODO: v4 just pass reflex into the lifecycle method\n if (typeof genericLifecycleMethod === 'function') {\n genericLifecycleMethod.call(\n reflex.controller,\n reflex.element,\n reflex.target,\n reflex.error,\n reflex.id,\n reflex.payload\n )\n }\n}\n\n// Dispatches a lifecycle event on document\n// - reflex - the Reflex object\n// - stage - the lifecycle stage\n//\nconst dispatchLifecycleEvent = (reflex, stage) => {\n if (!reflex.controller.element.parentElement) {\n if (Debug.enabled && !reflex.warned) {\n console.warn(\n `StimulusReflex was not able execute callbacks or emit events for \"${stage}\" or later life-cycle stages for this Reflex. The StimulusReflex Controller Element is no longer present in the DOM. Could you move the StimulusReflex Controller to an element higher in your DOM?`\n )\n reflex.warned = true\n }\n return\n }\n\n reflex.stage = stage\n reflex.lifecycle.push(stage)\n\n const event = `stimulus-reflex:${stage}`\n const action = `${event}:${reflex.action}`\n // TODO: v4 detail = reflex\n const detail = {\n reflex: reflex.target,\n controller: reflex.controller,\n id: reflex.id,\n element: reflex.element,\n payload: reflex.payload\n }\n const options = { bubbles: true, cancelable: false, detail }\n\n reflex.controller.element.dispatchEvent(new CustomEvent(event, options))\n reflex.controller.element.dispatchEvent(new CustomEvent(action, options))\n\n if (window.jQuery) {\n window.jQuery(reflex.controller.element).trigger(event, detail)\n window.jQuery(reflex.controller.element).trigger(action, detail)\n }\n}\n\ndocument.addEventListener(\n 'stimulus-reflex:before',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'before'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:queued',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'queued'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:delivered',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'delivered'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:success',\n event => {\n const reflex = reflexes[event.detail.id]\n invokeLifecycleMethod(reflex, 'success')\n dispatchLifecycleEvent(reflex, 'after')\n },\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:nothing',\n event => dispatchLifecycleEvent(reflexes[event.detail.id], 'success'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:error',\n event => {\n const reflex = reflexes[event.detail.id]\n invokeLifecycleMethod(reflex, 'error')\n // TODO: v4 remove after events on error; behave like halted and forbidden\n dispatchLifecycleEvent(reflex, 'after')\n },\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:halted',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'halted'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:forbidden',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'forbidden'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:after',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'after'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:finalize',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'finalize'),\n true\n)\n\nexport { dispatchLifecycleEvent }\n","let app = {}\n\nexport default {\n get app () {\n return app\n },\n set (application) {\n app = application\n }\n}\n","import Deprecate from './deprecate'\n\nlet isolationMode = false\n\nexport default {\n get disabled () {\n return !isolationMode\n },\n set (value) {\n isolationMode = value\n if (Deprecate.enabled && !isolationMode) {\n document.addEventListener(\n 'DOMContentLoaded',\n () =>\n console.warn(\n 'Deprecation warning: the next version of StimulusReflex will standardize isolation mode, and the isolate option will be removed.\\nPlease update your applications to assume that every tab will be isolated. Use CableReady operations to broadcast updates to other tabs and users.'\n ),\n { once: true }\n )\n }\n }\n}\n","import Debug from './debug'\nimport Deprecate from './deprecate'\n\nexport default class Reflex {\n constructor (data, controller) {\n this.data = data.valueOf()\n this.controller = controller\n this.element = data.reflexElement\n this.id = data.id\n this.error = null\n this.payload = null\n this.stage = 'created'\n this.lifecycle = ['created']\n this.warned = false\n this.target = data.target\n this.action = data.target.split('#')[1]\n this.selector = null\n this.morph = null\n this.operation = null\n this.timestamp = new Date()\n this.cloned = false // TODO: v4 remove\n }\n\n get getPromise () {\n const promise = new Promise((resolve, reject) => {\n this.promise = {\n resolve,\n reject,\n data: this.data\n }\n })\n promise.id = this.id\n // TODO: v4 remove\n Object.defineProperty(promise, 'reflexId', {\n get () {\n if (Deprecate.enabled)\n console.warn(\n 'reflexId is deprecated and will be removed from v4. Use id instead.'\n )\n return this.id\n }\n })\n // END TODO: v4 remove\n promise.reflex = this\n if (Debug.enabled) promise.catch(() => {})\n return promise\n }\n}\n","import CableReady from 'cable_ready'\n\nimport App from './app'\nimport Debug from './debug'\nimport IsolationMode from './isolation_mode'\nimport Reflex from './reflex'\n\nimport { dispatchLifecycleEvent } from './lifecycle'\nimport { reflexes } from './reflexes'\nimport { XPathToElement } from './utils'\n\nexport const received = data => {\n if (!data.cableReady) return\n\n if (data.version.replace('.pre', '-pre') !== CableReady.version) {\n if (Debug.enabled)\n console.error(\n `Reflex failed due to cable_ready gem/NPM package version mismatch. Package versions must match exactly.\\nNote that if you are using pre-release builds, gems use the \"x.y.z.preN\" version format, while NPM packages use \"x.y.z-preN\".\\n\\ncable_ready gem: ${data.version}\\ncable_ready NPM: ${CableReady.version}`\n )\n return\n }\n\n let reflexOperations = []\n\n for (let i = data.operations.length - 1; i >= 0; i--) {\n if (data.operations[i].stimulusReflex) {\n reflexOperations.push(data.operations[i])\n data.operations.splice(i, 1)\n }\n }\n\n if (\n reflexOperations.some(\n operation => operation.stimulusReflex.url !== location.href\n )\n ) {\n if (Debug.enabled) {\n console.error('Reflex failed due to mismatched URL.')\n return\n }\n }\n\n let reflexData\n\n if (reflexOperations.length) {\n reflexData = reflexOperations[0].stimulusReflex\n reflexData.payload = reflexOperations[0].payload\n }\n\n if (reflexData) {\n const { id, payload } = reflexData\n let reflex\n\n // TODO: remove this in v4\n if (!reflexes[id] && IsolationMode.disabled) {\n const controllerElement = XPathToElement(reflexData.xpathController)\n const reflexElement = XPathToElement(reflexData.xpathElement)\n\n controllerElement.reflexController =\n controllerElement.reflexController || {}\n controllerElement.reflexData = controllerElement.reflexData || {}\n controllerElement.reflexError = controllerElement.reflexError || {}\n\n const controller = App.app.getControllerForElementAndIdentifier(\n controllerElement,\n reflexData.reflexController\n )\n\n controllerElement.reflexController[id] = controller\n controllerElement.reflexData[id] = reflexData\n\n reflex = new Reflex(reflexData, controller)\n reflexes[id] = reflex\n reflex.cloned = true\n reflex.element = reflexElement\n controller.lastReflex = reflex\n\n dispatchLifecycleEvent(reflex, 'before')\n reflex.getPromise\n } else {\n // v4 keep this, make it a const\n reflex = reflexes[id]\n }\n // END TODO: remove\n\n if (reflex) {\n reflex.payload = payload\n reflex.totalOperations = reflexOperations.length\n reflex.pendingOperations = reflexOperations.length\n reflex.completedOperations = 0\n reflex.piggybackOperations = data.operations\n CableReady.perform(reflexOperations)\n }\n } else {\n if (data.operations.length && reflexes[data.operations[0].reflexId]) {\n CableReady.perform(data.operations)\n }\n }\n}\n","import Deprecate from '../deprecate'\n\nimport { createConsumer } from '@rails/actioncable'\nimport { dispatchLifecycleEvent } from '../lifecycle'\nimport { emitEvent } from '../utils'\nimport { received } from '../process'\nimport { reflexes } from '../reflexes'\n\nlet consumer\nlet params\nlet subscription\nlet active\n\nconst initialize = (consumerValue, paramsValue) => {\n consumer = consumerValue\n params = paramsValue\n document.addEventListener('DOMContentLoaded', () => {\n active = false\n connectionStatusClass()\n if (Deprecate.enabled && consumerValue)\n console.warn(\n \"Deprecation warning: the next version of StimulusReflex will obtain a reference to consumer via the Stimulus application object.\\nPlease add 'application.consumer = consumer' to your index.js after your Stimulus application has been established, and remove the consumer key from your StimulusReflex initialize() options object.\"\n )\n })\n document.addEventListener('turbolinks:load', connectionStatusClass)\n document.addEventListener('turbo:load', connectionStatusClass)\n}\n\nconst subscribe = controller => {\n if (subscription) return\n consumer = consumer || controller.application.consumer || createConsumer()\n const { channel } = controller.StimulusReflex\n const request = { channel, ...params }\n const identifier = JSON.stringify(request)\n\n subscription =\n consumer.subscriptions.findAll(identifier)[0] ||\n consumer.subscriptions.create(request, {\n received,\n connected,\n rejected,\n disconnected\n })\n}\n\nconst connected = () => {\n active = true\n connectionStatusClass()\n emitEvent('stimulus-reflex:connected')\n Object.values(reflexes.queued).forEach(reflex => {\n subscription.send(reflex.data)\n dispatchLifecycleEvent(reflex, 'delivered')\n })\n}\n\nconst rejected = () => {\n active = false\n connectionStatusClass()\n emitEvent('stimulus-reflex:rejected')\n if (Debug.enabled) console.warn('Channel subscription was rejected.')\n}\n\nconst disconnected = willAttemptReconnect => {\n active = false\n connectionStatusClass()\n emitEvent('stimulus-reflex:disconnected', willAttemptReconnect)\n}\n\nconst deliver = reflex => {\n if (active) {\n subscription.send(reflex.data)\n dispatchLifecycleEvent(reflex, 'delivered')\n } else dispatchLifecycleEvent(reflex, 'queued')\n}\n\nconst connectionStatusClass = () => {\n const list = document.body.classList\n if (\n !(\n list.contains('stimulus-reflex-connected') ||\n list.contains('stimulus-reflex-disconnected')\n )\n ) {\n list.add(\n active ? 'stimulus-reflex-connected' : 'stimulus-reflex-disconnected'\n )\n return\n }\n if (active) {\n list.replace('stimulus-reflex-disconnected', 'stimulus-reflex-connected')\n } else {\n list.replace('stimulus-reflex-connected', 'stimulus-reflex-disconnected')\n }\n}\n\nexport default {\n subscribe,\n deliver,\n initialize\n}\n","import Debug from './debug'\n\nconst request = reflex => {\n if (Debug.disabled || reflex.data.suppressLogging) return\n console.log(`\\u2191 stimulus \\u2191 ${reflex.target}`, {\n id: reflex.id,\n args: reflex.data.args,\n controller: reflex.controller.identifier,\n element: reflex.element,\n controllerElement: reflex.controller.element\n })\n}\n\nconst success = reflex => {\n if (Debug.disabled || reflex.data.suppressLogging) return\n const output = {\n id: reflex.id,\n morph: reflex.morph,\n payload: reflex.payload\n }\n if (reflex.operation !== 'dispatch_event') output.operation = reflex.operation\n console.log(\n `\\u2193 reflex \\u2193 ${reflex.target} \\u2192 ${reflex.selector ||\n '\\u221E'}${progress(reflex)} ${duration(reflex)}`,\n output\n )\n}\n\nconst halted = reflex => {\n if (Debug.disabled || reflex.data.suppressLogging) return\n console.log(\n `\\u2193 reflex \\u2193 ${reflex.target} ${duration(reflex)} %cHALTED`,\n 'color: #ffa500;',\n { id: reflex.id, payload: reflex.payload }\n )\n}\n\nconst forbidden = reflex => {\n if (Debug.disabled || reflex.data.suppressLogging) return\n console.log(\n `\\u2193 reflex \\u2193 ${reflex.target} ${duration(reflex)} %cFORBIDDEN`,\n 'color: #BF40BF;',\n { id: reflex.id, payload: reflex.payload }\n )\n}\n\nconst error = reflex => {\n if (Debug.disabled || reflex.data.suppressLogging) return\n console.log(\n `\\u2193 reflex \\u2193 ${reflex.target} ${duration(reflex)} %cERROR: ${\n reflex.error\n }`,\n 'color: #f00;',\n { id: reflex.id, payload: reflex.payload }\n )\n}\n\nconst duration = reflex => {\n return !reflex.cloned ? `in ${new Date() - reflex.timestamp}ms` : 'CLONED'\n}\n\nconst progress = reflex => {\n return reflex.totalOperations > 1\n ? ` ${reflex.completedOperations}/${reflex.totalOperations}`\n : ''\n}\n\nexport default { request, success, halted, forbidden, error }\n","import Debug from './debug'\nimport Deprecate from './deprecate'\nimport Schema from './schema'\n\nimport { elementToXPath, XPathToArray } from './utils'\n\nconst multipleInstances = element => {\n if (['checkbox', 'radio'].includes(element.type)) {\n return (\n document.querySelectorAll(\n `input[type=\"${element.type}\"][name=\"${element.name}\"]`\n ).length > 1\n )\n }\n return false\n}\nconst collectCheckedOptions = element => {\n return Array.from(element.querySelectorAll('option:checked'))\n .concat(\n Array.from(\n document.querySelectorAll(\n `input[type=\"${element.type}\"][name=\"${element.name}\"]`\n )\n ).filter(elem => elem.checked)\n )\n .map(o => o.value)\n}\n\n// Returns a string value for the passed array.\n//\n// attributeValue(['', 'one', null, 'two', 'three ']) // 'one two three'\n//\nconst attributeValue = (values = []) => {\n const value = Array.from(\n new Set(\n values\n .filter(v => v && String(v).length)\n .map(v => v.trim())\n )\n ).join(' ').trim()\n\n return value.length > 0 ? value : null\n}\n\n// Returns an array for the passed string value by splitting on whitespace.\n//\n// attributeValues('one two three ') // ['one', 'two', 'three']\n//\nconst attributeValues = value => {\n if (!value) return []\n if (!value.length) return []\n return value.split(' ').filter(v => v.trim().length)\n}\n\n// Extracts attributes from a DOM element.\n//\nconst extractElementAttributes = element => {\n let attrs = Array.from(element.attributes).reduce((memo, attr) => {\n memo[attr.name] = attr.value\n return memo\n }, {})\n\n attrs.checked = !!element.checked\n attrs.selected = !!element.selected\n attrs.tag_name = element.tagName\n\n if (element.tagName.match(/select/i) || multipleInstances(element)) {\n const collectedOptions = collectCheckedOptions(element)\n attrs.values = collectedOptions\n attrs.value = collectedOptions.join(',')\n } else {\n attrs.value = element.value\n }\n return attrs\n}\n\n// Returns an array of elements for the provided tokens.\n// Tokens is an array of space separated string coming from the `data-reflex-dataset`\n// or `data-reflex-dataset-all` attribute.\n//\nconst getElementsFromTokens = (element, tokens) => {\n if (!tokens || tokens.length === 0) return []\n\n let elements = [element]\n\n const xPath = elementToXPath(element)\n\n tokens.forEach(token => {\n try {\n switch (token) {\n case 'combined':\n if (Deprecate.enabled)\n console.warn(\n \"In the next version of StimulusReflex, the 'combined' option to data-reflex-dataset will become 'ancestors'.\"\n )\n elements = [\n ...elements,\n ...XPathToArray(`${xPath}/ancestor::*`, true)\n ]\n break\n case 'ancestors':\n elements = [\n ...elements,\n ...XPathToArray(`${xPath}/ancestor::*`, true)\n ]\n break\n case 'parent':\n elements = [...elements, ...XPathToArray(`${xPath}/parent::*`)]\n break\n case 'siblings':\n elements = [\n ...elements,\n ...XPathToArray(\n `${xPath}/preceding-sibling::*|${xPath}/following-sibling::*`\n )\n ]\n break\n case 'children':\n elements = [...elements, ...XPathToArray(`${xPath}/child::*`)]\n break\n case 'descendants':\n elements = [...elements, ...XPathToArray(`${xPath}/descendant::*`)]\n break\n default:\n elements = [...elements, ...document.querySelectorAll(token)]\n }\n } catch (error) {\n if (Debug.enabled) console.error(error)\n }\n })\n\n return elements\n}\n\n// Extracts the dataset of an element and combines it with the data attributes from all specified tokens\n//\nconst extractElementDataset = element => {\n const dataset = element.attributes[Schema.reflexDataset]\n const allDataset = element.attributes[Schema.reflexDatasetAll]\n\n const tokens = (dataset && dataset.value.split(' ')) || []\n const allTokens = (allDataset && allDataset.value.split(' ')) || []\n\n const datasetElements = getElementsFromTokens(element, tokens)\n const datasetAllElements = getElementsFromTokens(element, allTokens)\n\n const datasetAttributes = datasetElements.reduce((acc, ele) => {\n return { ...extractDataAttributes(ele), ...acc }\n }, {})\n\n const reflexElementAttributes = extractDataAttributes(element)\n\n const elementDataset = {\n dataset: { ...reflexElementAttributes, ...datasetAttributes },\n datasetAll: {}\n }\n\n datasetAllElements.forEach(element => {\n const elementAttributes = extractDataAttributes(element)\n\n Object.keys(elementAttributes).forEach(key => {\n const value = elementAttributes[key]\n\n if (\n elementDataset.datasetAll[key] &&\n Array.isArray(elementDataset.datasetAll[key])\n ) {\n elementDataset.datasetAll[key].push(value)\n } else {\n elementDataset.datasetAll[key] = [value]\n }\n })\n })\n\n return elementDataset\n}\n\n// Extracts all data attributes from a DOM element.\n//\nconst extractDataAttributes = element => {\n let attrs = {}\n\n if (element && element.attributes) {\n Array.from(element.attributes).forEach(attr => {\n if (attr.name.startsWith('data-')) {\n attrs[attr.name] = attr.value\n }\n })\n }\n\n return attrs\n}\n\nexport {\n attributeValue,\n attributeValues,\n extractElementAttributes,\n extractElementDataset,\n extractDataAttributes\n}\n","import Schema from './schema'\n\nimport { extractElementAttributes, extractElementDataset } from './attributes'\nimport { uuidv4, getReflexRoots, elementToXPath } from './utils'\n\nimport packageInfo from '../package.json'\n\nexport default class ReflexData {\n constructor (\n options,\n reflexElement,\n controllerElement,\n reflexController,\n permanentAttributeName,\n target,\n args,\n url,\n tabId\n ) {\n this.options = options\n this.reflexElement = reflexElement\n this.controllerElement = controllerElement\n this.reflexController = reflexController\n this.permanentAttributeName = permanentAttributeName\n this.target = target\n this.args = args\n this.url = url\n this.tabId = tabId\n }\n\n get attrs () {\n this._attrs =\n this._attrs ||\n this.options['attrs'] ||\n extractElementAttributes(this.reflexElement)\n\n return this._attrs\n }\n\n get id () {\n this._id = this._id || this.options['id'] || uuidv4()\n return this._id\n }\n\n get selectors () {\n this._selectors =\n this._selectors ||\n this.options['selectors'] ||\n getReflexRoots(this.reflexElement)\n\n return typeof this._selectors === 'string'\n ? [this._selectors]\n : this._selectors\n }\n\n // TODO: v4 always resolve late\n get resolveLate () {\n return this.options['resolveLate'] || false\n }\n\n get dataset () {\n this._dataset = this._dataset || extractElementDataset(this.reflexElement)\n return this._dataset\n }\n\n get innerHTML () {\n return this.includeInnerHtml ? this.reflexElement.innerHTML : ''\n }\n\n get textContent () {\n return this.includeTextContent ? this.reflexElement.textContent : ''\n }\n\n // TODO: remove this in v4\n get xpathController () {\n return elementToXPath(this.controllerElement)\n }\n\n get xpathElement () {\n return elementToXPath(this.reflexElement)\n }\n // END TODO remove\n\n get formSelector () {\n const attr = this.reflexElement.attributes[Schema.reflexFormSelector]\n ? this.reflexElement.attributes[Schema.reflexFormSelector].value\n : undefined\n return this.options['formSelector'] || attr\n }\n\n get includeInnerHtml () {\n const attr =\n this.reflexElement.attributes[Schema.reflexIncludeInnerHtml] || false\n return this.options['includeInnerHTML'] || attr\n ? attr.value !== 'false'\n : false\n }\n\n get includeTextContent () {\n const attr =\n this.reflexElement.attributes[Schema.reflexIncludeTextContent] || false\n return this.options['includeTextContent'] || attr\n ? attr.value !== 'false'\n : false\n }\n\n get suppressLogging () {\n return (\n this.options['suppressLogging'] ||\n this.reflexElement.attributes[Schema.reflexSuppressLogging] ||\n false\n )\n }\n\n valueOf () {\n return {\n attrs: this.attrs,\n dataset: this.dataset,\n selectors: this.selectors,\n id: this.id,\n resolveLate: this.resolveLate,\n suppressLogging: this.suppressLogging,\n xpathController: this.xpathController,\n xpathElement: this.xpathElement,\n inner_html: this.innerHTML,\n text_content: this.textContent,\n formSelector: this.formSelector,\n reflexController: this.reflexController,\n permanentAttributeName: this.permanentAttributeName,\n target: this.target,\n args: this.args,\n url: this.url,\n tabId: this.tabId,\n version: packageInfo.version\n }\n }\n}\n","let transport = {}\n\nexport default {\n get plugin () {\n return transport\n },\n set (newTransport) {\n transport = newTransport\n }\n}\n","import CableReady from 'cable_ready'\n\nimport Log from './log'\n\nimport { reflexes } from './reflexes'\nimport { dispatchLifecycleEvent } from './lifecycle'\n\nconst beforeDOMUpdate = event => {\n const { stimulusReflex } = event.detail || {}\n if (!stimulusReflex) return\n const reflex = reflexes[stimulusReflex.id]\n\n reflex.pendingOperations--\n\n if (reflex.pendingOperations > 0) return\n\n // TODO: remove in v4 - always resolve late\n if (!stimulusReflex.resolveLate)\n setTimeout(() =>\n reflex.promise.resolve({\n element: reflex.element,\n event,\n data: reflex.data,\n payload: reflex.payload,\n id: reflex.id,\n toString: () => ''\n })\n )\n // END TODO: remove\n\n setTimeout(() => dispatchLifecycleEvent(reflex, 'success'))\n}\n\nconst afterDOMUpdate = event => {\n const { stimulusReflex } = event.detail || {}\n if (!stimulusReflex) return\n const reflex = reflexes[stimulusReflex.id]\n\n reflex.completedOperations++\n reflex.selector = event.detail.selector\n reflex.morph = event.detail.stimulusReflex.morph\n reflex.operation = event.type\n .split(':')[1]\n .split('-')\n .slice(1)\n .join('_')\n\n Log.success(reflex)\n\n if (reflex.completedOperations < reflex.totalOperations) return\n\n // TODO: v4 always resolve late (remove if)\n // TODO: v4 simplify to {reflex, toString}\n if (stimulusReflex.resolveLate)\n setTimeout(() =>\n reflex.promise.resolve({\n element: reflex.element,\n event,\n data: reflex.data,\n payload: reflex.payload,\n id: reflex.id,\n toString: () => ''\n })\n )\n\n setTimeout(() => dispatchLifecycleEvent(reflex, 'finalize'))\n\n if (reflex.piggybackOperations.length)\n CableReady.perform(reflex.piggybackOperations)\n}\n\nconst routeReflexEvent = event => {\n const { stimulusReflex, name } = event.detail || {}\n const eventType = name.split('-')[2]\n\n const eventTypes = { nothing, halted, forbidden, error }\n\n if (!stimulusReflex || !Object.keys(eventTypes).includes(eventType)) return\n\n const reflex = reflexes[stimulusReflex.id]\n reflex.completedOperations++\n reflex.pendingOperations--\n reflex.selector = event.detail.selector\n reflex.morph = event.detail.stimulusReflex.morph\n reflex.operation = event.type\n .split(':')[1]\n .split('-')\n .slice(1)\n .join('_')\n if (eventType === 'error') reflex.error = event.detail.error\n\n eventTypes[eventType](reflex, event)\n\n setTimeout(() => dispatchLifecycleEvent(reflex, eventType))\n\n if (reflex.piggybackOperations.length)\n CableReady.perform(reflex.piggybackOperations)\n}\n\nconst nothing = (reflex, event) => {\n Log.success(reflex)\n\n // TODO: v4 simplify to {reflex, toString}\n setTimeout(() =>\n reflex.promise.resolve({\n data: reflex.data,\n element: reflex.element,\n event,\n payload: reflex.payload,\n id: reflex.id,\n toString: () => ''\n })\n )\n}\n\nconst halted = (reflex, event) => {\n Log.halted(reflex, event)\n\n // TODO: v4 simplify to {reflex, toString}\n setTimeout(() =>\n reflex.promise.resolve({\n data: reflex.data,\n element: reflex.element,\n event,\n payload: reflex.payload,\n id: reflex.id,\n toString: () => ''\n })\n )\n}\n\nconst forbidden = (reflex, event) => {\n Log.forbidden(reflex, event)\n\n // TODO: v4 simplify to {reflex, toString}\n setTimeout(() =>\n reflex.promise.resolve({\n data: reflex.data,\n element: reflex.element,\n event,\n payload: reflex.payload,\n id: reflex.id,\n toString: () => ''\n })\n )\n}\n\nconst error = (reflex, event) => {\n Log.error(reflex, event)\n\n // TODO: v4 simplify to {reflex, toString}\n // TODO: v4 convert to resolve?\n setTimeout(() =>\n reflex.promise.reject({\n data: reflex.data,\n element: reflex.element,\n event,\n payload: reflex.payload,\n id: reflex.id,\n error: reflex.error,\n toString: () => reflex.error\n })\n )\n}\n\nexport { beforeDOMUpdate, afterDOMUpdate, routeReflexEvent }\n","import App from './app'\nimport Schema from './schema'\n\nimport { attributeValues } from './attributes'\nimport { extractReflexName } from './utils'\n\n// Returns StimulusReflex controllers local to the passed element based on the data-controller attribute.\n//\nconst localReflexControllers = element => {\n return attributeValues(element.getAttribute(Schema.controller)).reduce(\n (memo, name) => {\n const controller = App.app.getControllerForElementAndIdentifier(\n element,\n name\n )\n if (controller && controller.StimulusReflex) memo.push(controller)\n return memo\n },\n []\n )\n}\n\n// Returns all StimulusReflex controllers for the passed element.\n// Traverses DOM ancestors starting with element.\n//\nconst allReflexControllers = element => {\n let controllers = []\n while (element) {\n controllers = controllers.concat(localReflexControllers(element))\n element = element.parentElement\n }\n return controllers\n}\n\n// Given a reflex string such as 'click->TestReflex#create' and a list of\n// controllers. It will find the matching controller based on the controller's\n// identifier. e.g. Given these controller identifiers ['foo', 'bar', 'test'],\n// it would select the 'test' controller.\nconst findControllerByReflexName = (reflexName, controllers) => {\n const controller = controllers.find(controller => {\n if (!controller.identifier) return\n\n return (\n extractReflexName(reflexName)\n .replace(/([a-z0–9])([A-Z])/g, '$1-$2')\n .replace(/(::)/g, '--')\n .toLowerCase() === controller.identifier\n )\n })\n\n return controller || controllers[0]\n}\n\nexport { allReflexControllers, findControllerByReflexName }\n","import Schema from './schema'\n\nimport { attributeValues, attributeValue } from './attributes'\nimport { debounce, dispatch } from './utils'\nimport { findControllerByReflexName, allReflexControllers } from './controllers'\nimport { reflexes } from './reflexes'\n\n// Sets up declarative reflex behavior.\n// Any elements that define data-reflex will automatically be wired up with the default StimulusReflexController.\n//\nconst scanForReflexes = debounce(() => {\n const reflexElements = document.querySelectorAll(`[${Schema.reflex}]`)\n reflexElements.forEach(element => scanForReflexesOnElement(element))\n}, 20)\n\nconst scanForReflexesOnElement = element => {\n const controllerAttribute = element.getAttribute(Schema.controller)\n const controllers = attributeValues(controllerAttribute)\n\n const reflexAttribute = element.getAttribute(Schema.reflex)\n const reflexAttributeNames = attributeValues(reflexAttribute)\n\n const actionAttribute = element.getAttribute(Schema.action)\n const actions = attributeValues(actionAttribute).filter(\n action => !action.includes('#__perform')\n )\n\n reflexAttributeNames.forEach(reflexName => {\n const controller = findControllerByReflexName(\n reflexName,\n allReflexControllers(element)\n )\n const controllerName = controller\n ? controller.identifier\n : 'stimulus-reflex'\n\n actions.push(`${reflexName.split('->')[0]}->${controllerName}#__perform`)\n controllers.push(controllerName)\n })\n\n const controllerValue = attributeValue(controllers)\n const actionValue = attributeValue(actions)\n\n let emitReadyEvent = false\n\n if (\n controllerValue &&\n element.getAttribute(Schema.controller) != controllerValue\n ) {\n element.setAttribute(Schema.controller, controllerValue)\n emitReadyEvent = true\n }\n\n if (actionValue && element.getAttribute(Schema.action) != actionValue) {\n element.setAttribute(Schema.action, actionValue)\n emitReadyEvent = true\n }\n\n if (emitReadyEvent) {\n dispatch(element, 'stimulus-reflex:ready', {\n reflex: reflexAttribute,\n controller: controllerValue,\n action: actionValue,\n element\n })\n }\n}\nexport { scanForReflexes, scanForReflexesOnElement }\n","import { Controller } from '@hotwired/stimulus'\n\nimport ActionCableTransport from './transports/action_cable'\nimport App from './app'\nimport Debug from './debug'\nimport Deprecate from './deprecate'\nimport IsolationMode from './isolation_mode'\nimport Log from './log'\nimport Reflex from './reflex'\nimport ReflexData from './reflex_data'\nimport Schema from './schema'\nimport Transport from './transport'\n\nimport { attributeValues } from './attributes'\nimport { beforeDOMUpdate, afterDOMUpdate, routeReflexEvent } from './callbacks'\nimport { dispatchLifecycleEvent } from './lifecycle'\nimport { reflexes } from './reflexes'\nimport { scanForReflexes, scanForReflexesOnElement } from './scanner'\n\nimport {\n uuidv4,\n serializeForm,\n elementInvalid,\n getReflexElement,\n getReflexOptions,\n emitEvent\n} from './utils'\n\n// Default StimulusReflexController that is implicitly wired up as data-controller for any DOM elements\n// that have configured data-reflex. Note that this default can be overridden when initializing the application.\n// i.e. StimulusReflex.initialize(myStimulusApplication, MyCustomDefaultController)\n//\nclass StimulusReflexController extends Controller {\n constructor (...args) {\n super(...args)\n register(this)\n }\n}\n\n// Uniquely identify this browser tab in each Reflex\nconst tabId = uuidv4()\n\n// Initializes StimulusReflex by registering the default Stimulus controller with the passed Stimulus application.\n//\n// - application - the Stimulus application\n// - options\n// * controller - [optional] the default StimulusReflexController\n// * consumer - [optional] the ActionCable consumer\n// * debug - [false] log all Reflexes to the console\n// * params - [{}] key/value parameters to send during channel subscription\n// * isolate - [false] restrict Reflex playback to the tab which initiated it\n// * deprecate - [true] show warnings regarding upcoming changes to the library\n// * transport - [optional] defaults to ActionCableTransport\n//\nconst initialize = (\n application,\n { controller, consumer, debug, params, isolate, deprecate, transport } = {}\n) => {\n Transport.set(transport || ActionCableTransport)\n Transport.plugin.initialize(consumer, params)\n IsolationMode.set(!!isolate)\n App.set(application)\n Schema.set(application)\n App.app.register(\n 'stimulus-reflex',\n controller || StimulusReflexController\n )\n Debug.set(!!debug)\n if (typeof deprecate !== 'undefined') Deprecate.set(deprecate)\n const observer = new MutationObserver(scanForReflexes)\n observer.observe(document.documentElement, {\n attributeFilter: [Schema.reflex, Schema.action],\n childList: true,\n subtree: true\n })\n emitEvent('stimulus-reflex:initialized')\n}\n\n// Registers a Stimulus controller and extends it with StimulusReflex behavior\n//\n// controller - the Stimulus controller\n// options - [optional] configuration\n//\nconst register = (controller, options = {}) => {\n const channel = 'StimulusReflex::Channel'\n controller.StimulusReflex = { ...options, channel }\n Transport.plugin.subscribe(controller)\n Object.assign(controller, {\n // Invokes a server side reflex method.\n //\n // - target - the reflex target (full name of the server side reflex) i.e. 'ReflexClassName#method'\n // - reflexElement - [optional] the element that triggered the reflex, defaults to this.element\n // - options - [optional] an object that contains at least one of attrs, id, selectors, resolveLate, serializeForm\n // - *args - remaining arguments are forwarded to the server side reflex method\n //\n stimulate () {\n const url = location.href\n const controllerElement = this.element\n const args = Array.from(arguments)\n const target = args.shift() || 'StimulusReflex::Reflex#default_reflex'\n const reflexElement = getReflexElement(args, controllerElement)\n\n if (elementInvalid(reflexElement)) {\n if (Debug.enabled) console.warn('Reflex aborted: invalid numeric input')\n return\n }\n\n const options = getReflexOptions(args)\n\n const reflexData = new ReflexData(\n options,\n reflexElement,\n controllerElement,\n this.identifier,\n Schema.reflexPermanent,\n target,\n args,\n url,\n tabId\n )\n\n const id = reflexData.id\n\n // TODO: remove this in v4\n controllerElement.reflexController =\n controllerElement.reflexController || {}\n controllerElement.reflexData = controllerElement.reflexData || {}\n controllerElement.reflexError = controllerElement.reflexError || {}\n\n controllerElement.reflexController[id] = this\n controllerElement.reflexData[id] = reflexData.valueOf()\n // END TODO: remove\n\n const reflex = new Reflex(reflexData, this)\n reflexes[id] = reflex\n this.lastReflex = reflex\n\n dispatchLifecycleEvent(reflex, 'before')\n\n setTimeout(() => {\n // TODO: in v4, params will be set on the reflex.data object\n const { params } = controllerElement.reflexData[id] || {}\n\n const check = reflexElement.attributes[Schema.reflexSerializeForm]\n if (check) {\n options['serializeForm'] = check.value !== 'false'\n }\n\n const form =\n reflexElement.closest(reflexData.formSelector) ||\n document.querySelector(reflexData.formSelector) ||\n reflexElement.closest('form')\n\n // TODO: remove this in v4\n if (Deprecate.enabled && options['serializeForm'] === undefined && form)\n console.warn(\n `Deprecation warning: the next version of StimulusReflex will not serialize forms by default.\\nPlease set ${Schema.reflexSerializeForm}=\\\"true\\\" on your Reflex Controller Element or pass { serializeForm: true } as an option to stimulate.`\n )\n // END TODO: remove\n\n const formData =\n options['serializeForm'] === false\n ? ''\n : serializeForm(form, {\n element: reflexElement\n })\n\n reflex.data = {\n ...reflexData.valueOf(),\n params,\n formData\n }\n\n // TODO: remove this in v4\n controllerElement.reflexData[id] = reflex.data\n // END TODO: remove\n\n Transport.plugin.deliver(reflex)\n })\n\n Log.request(reflex)\n\n return reflex.getPromise\n },\n\n // Wraps the call to stimulate for any data-reflex elements.\n // This is internal and should not be invoked directly.\n __perform (event) {\n let element = event.target\n let reflex\n\n while (element && !reflex) {\n reflex = element.getAttribute(Schema.reflex)\n if (!reflex || !reflex.trim().length) element = element.parentElement\n }\n\n const match = attributeValues(reflex).find(\n reflex => reflex.split('->')[0] === event.type\n )\n\n if (match) {\n event.preventDefault()\n event.stopPropagation()\n this.stimulate(match.split('->')[1], element)\n }\n }\n })\n\n // Access the reflexes created by the current controller instance\n // reflexes is a Proxy to an object, keyed by id\n // this.reflexes.all and this.reflexes.last are scoped to this controller instance\n // Reflexes can also be scoped by stage eg. this.reflexes.queued\n if (!controller.reflexes)\n Object.defineProperty(controller, 'reflexes', {\n get () {\n return new Proxy(reflexes, {\n get: function (target, prop) {\n if (prop === 'last') return this.lastReflex\n return Object.fromEntries(\n Object.entries(target[prop]).filter(\n ([_, reflex]) => reflex.controller === this\n )\n )\n }.bind(this)\n })\n }\n })\n\n scanForReflexesOnElement(controller.element)\n\n emitEvent('stimulus-reflex:controller-registered', { detail: { controller } })\n}\n\nconst useReflex = (controller, options = {}) => {\n register(controller, options)\n}\n\ndocument.addEventListener('cable-ready:after-dispatch-event', routeReflexEvent)\ndocument.addEventListener('cable-ready:before-inner-html', beforeDOMUpdate)\ndocument.addEventListener('cable-ready:before-morph', beforeDOMUpdate)\ndocument.addEventListener('cable-ready:after-inner-html', afterDOMUpdate)\ndocument.addEventListener('cable-ready:after-morph', afterDOMUpdate)\ndocument.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n scanForReflexes()\n }\n})\n\nexport {\n initialize,\n register,\n useReflex,\n reflexes,\n scanForReflexes,\n scanForReflexesOnElement\n}\n","export * from './stimulus_reflex'\n\nimport * as StimulusReflex from './stimulus_reflex'\n\nimport Debug from './debug'\nimport Deprecate from './deprecate'\n\nimport packageInfo from '../package.json'\n\nconst global = {\n version: packageInfo.version,\n ...StimulusReflex,\n get debug () {\n return Debug.value\n },\n set debug (value) {\n Debug.set(!!value)\n },\n get deprecate () {\n return Deprecate.value\n },\n set deprecate (value) {\n Deprecate.set(!!value)\n }\n}\n\nwindow.StimulusReflex = global\n\nexport default global\n"],"names":["deprecationWarnings","Deprecate","enabled","disabled","value","set","deprecate","debugging","Debug$1","debug","defaultSchema","reflexAttribute","reflexPermanentAttribute","reflexRootAttribute","reflexSuppressLoggingAttribute","reflexDatasetAttribute","reflexDatasetAllAttribute","reflexSerializeFormAttribute","reflexFormSelectorAttribute","reflexIncludeInnerHtmlAttribute","reflexIncludeTextContentAttribute","schema","Schema","application","attribute","attributeName","slice","Object","defineProperty","this","get","configurable","debounce","dispatch","xpathToElement","xpathToElementArray","Utils","uuidv4","crypto","window","msCrypto","replace","c","getRandomValues","Uint8Array","toString","camelize","uppercaseFirstLetter","$1","toUpperCase","toLowerCase","substr","XPathToElement","XPathToArray","emitEvent","name","detail","document","elementToXPath","element","id","body","nodeName","ix","siblings","parentNode","childNodes","i","length","sibling","tagName","nodeType","stages","lastReflex","reflexes","Proxy","target","prop","includes","fromEntries","entries","filter","_","reflex","stage","Reflect","arguments","invokeLifecycleMethod","specificLifecycleMethod","controller","action","genericLifecycleMethod","call","error","payload","dispatchLifecycleEvent","parentElement","Debug","warned","console","warn","lifecycle","push","event","options","bubbles","cancelable","dispatchEvent","CustomEvent","jQuery","trigger","addEventListener","app","App","isolationMode","IsolationMode","once","Reflex","constructor","data","valueOf","reflexElement","split","selector","morph","operation","timestamp","Date","cloned","getPromise","promise","Promise","resolve","reject","catch","received","cableReady","version","CableReady","reflexData","reflexOperations","operations","stimulusReflex","splice","some","url","location","href","controllerElement","xpathController","xpathElement","reflexController","reflexError","getControllerForElementAndIdentifier","totalOperations","pendingOperations","completedOperations","piggybackOperations","perform","reflexId","consumer","params","subscription","active","connected","connectionStatusClass","values","queued","forEach","send","rejected","disconnected","willAttemptReconnect","list","classList","contains","add","ActionCableTransport","subscribe","createConsumer","channel","StimulusReflex","request","identifier","JSON","stringify","subscriptions","findAll","create","deliver","initialize","consumerValue","paramsValue","duration","progress","Log","suppressLogging","log","args","output","attributeValue","Array","from","Set","v","String","map","trim","join","attributeValues","extractElementAttributes","attrs","attributes","reduce","memo","attr","checked","selected","tag_name","match","type","querySelectorAll","multipleInstances","collectedOptions","concat","elem","o","collectCheckedOptions","getElementsFromTokens","tokens","elements","xPath","token","extractDataAttributes","startsWith","ReflexData","permanentAttributeName","tabId","_attrs","_id","selectors","_selectors","reflexRoot","getAttribute","s","querySelector","closest","getReflexRoots","resolveLate","dataset","_dataset","reflexDataset","allDataset","reflexDatasetAll","allTokens","datasetElements","datasetAllElements","datasetAttributes","acc","ele","elementDataset","datasetAll","elementAttributes","keys","key","isArray","extractElementDataset","innerHTML","includeInnerHtml","textContent","includeTextContent","formSelector","reflexFormSelector","undefined","reflexIncludeInnerHtml","reflexIncludeTextContent","reflexSuppressLogging","inner_html","text_content","packageInfo","transport","Transport","plugin","newTransport","beforeDOMUpdate","setTimeout","afterDOMUpdate","nothing","halted","forbidden","localReflexControllers","scanForReflexes","scanForReflexesOnElement","controllerAttribute","controllers","reflexAttributeNames","actionAttribute","actions","reflexName","find","reflexString","extractReflexName","findControllerByReflexName","allReflexControllers","controllerName","controllerValue","actionValue","emitReadyEvent","setAttribute","StimulusReflexController","Controller","super","register","isolate","MutationObserver","observe","documentElement","attributeFilter","childList","subtree","assign","stimulate","shift","Node","ELEMENT_NODE","getReflexElement","validity","badInput","opts","getReflexOptions","reflexPermanent","check","reflexSerializeForm","form","formData","w","FormData","e","encodeURIComponent","submitButton","serializeForm","__perform","preventDefault","stopPropagation","bind","useReflex","eventType","eventTypes","readyState","global"],"mappings":"2IAAA,IAAIA,GAAsB,EAE1B,IAAeC,EAAA,CACTC,cACF,OAAOF,CACR,EACGG,eACF,OAAQH,CACT,EACGI,YACF,OAAOJ,CACR,EACDK,IAAKD,GACHJ,IAAwBI,CACzB,EACGE,cAAWF,GACbJ,IAAwBI,CACzB,GCjBH,IAAIG,GAAY,EAEhB,IAAeC,EAAA,CACTN,cACF,OAAOK,CACR,EACGJ,eACF,OAAQI,CACT,EACGH,YACF,OAAOG,CACR,EACDF,IAAKD,GACHG,IAAcH,CACf,EACGK,UAAOL,GACTG,IAAcH,CACf,GCjBH,MAAMM,EAAgB,CACpBC,gBAAiB,cACjBC,yBAA0B,wBAC1BC,oBAAqB,mBACrBC,+BAAgC,+BAChCC,uBAAwB,sBACxBC,0BAA2B,0BAC3BC,6BAA8B,6BAC9BC,4BAA6B,4BAC7BC,gCAAiC,iCACjCC,kCAAmC,oCAGrC,IAAIC,EAAS,CAAE,EAIf,IAAeC,EAAA,CACbjB,IAAKkB,GACHF,EAAS,IAAKX,KAAkBa,EAAYF,QAC5C,IAAK,MAAMG,KAAaH,EAAQ,CAC9B,MAAMI,EAAgBD,EAAUE,MAAM,GAAI,GAE1CC,OAAOC,eAAeC,KAAMJ,EAAe,CACzCK,IAAK,IACIT,EAAOG,GAEhBO,cAAc,GAEjB,CACF,GCxBH,MAAMC,SAAEA,EAAQC,SAAEA,EAAQC,eAAEA,EAAcC,oBAAEA,GAAwBC,EAK9DC,EAAS,KACb,MAAMC,EAASC,OAAOD,QAAUC,OAAO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