stimulusjs-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c63f2c8aaa21bd73c621b44a07bd678afd06ac6e
4
+ data.tar.gz: 9c6b77a3ab67d33b54f615d5af8da5cb9d282ea8
5
+ SHA512:
6
+ metadata.gz: ad001a34f571c90c8d2f861ba610b57360264498facdeb9a53f3885faae643264e4acc167471114800b0691758b03a0944dd74db58929e5b6fea78ab56ebd753
7
+ data.tar.gz: 64c1ecf45df8e2c575e450e2b28e041a8af667f206b698e484572bd9fd07b72b46bd5bcadfa081c2c748c8968fe81538d091c195792192d2fcd1873029f02b70
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Brice Sanchez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,34 @@
1
+ # stimulusjs-rails
2
+
3
+ [![Gem](https://img.shields.io/gem/v/stimulusjs-rails.svg)](https://rubygems.org/gems/stimulusjs-rails)
4
+ [![Gem](https://img.shields.io/gem/dt/stimulusjs-rails.svg)](https://rubygems.org/gems/stimulusjs-rails)
5
+
6
+ ### About
7
+
8
+ Rails 4.2+ asset-pipeline gem to provide Stimulus.js
9
+
10
+ ### Package Versions
11
+
12
+ - Stimulus 1.0.1
13
+
14
+ ### Setup
15
+
16
+ Have in your Gemfile:
17
+
18
+ ```ruby
19
+ gem 'stimulusjs-rails'
20
+ ```
21
+
22
+ And in your application.js manifest:
23
+
24
+ ```js
25
+ //= require stimulus
26
+ ```
27
+
28
+ ## Contributing
29
+
30
+ Contributions are welcome, please follow [GitHub Flow](https://guides.github.com/introduction/flow/index.html)
31
+
32
+ ## License
33
+
34
+ [MIT](LICENSE.md)
@@ -0,0 +1,7 @@
1
+ require "stimulusjs-rails/version"
2
+
3
+ module Stimulus
4
+ module Rails
5
+ require "stimulusjs-rails/engine" if defined?(::Rails) and Gem::Requirement.new('>= 4.2').satisfied_by?(Gem::Version.new ::Rails.version)
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module Stimulus
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Stimulus
2
+ module Rails
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'stimulusjs-rails/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'stimulusjs-rails'
7
+ s.version = Stimulus::Rails::VERSION
8
+ s.authors = ['Brice Sanchez']
9
+ s.homepage = 'https://github.com/bricesanchez/stimulusjs-rails'
10
+ s.summary = %q{Stimulus.js asset pipeline provider/wrapper}
11
+ s.description = 'A simple asset-pipeline wrapper for Stimulus.js by Brice Sanchez'
12
+ s.license = 'MIT'
13
+
14
+ s.rubyforge_project = 'stimulusjs-rails'
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ['lib']
20
+ end
@@ -0,0 +1,5 @@
1
+ /*
2
+ Stimulus 1.0.1
3
+ Copyright © 2018 Basecamp, LLC
4
+ */
5
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Stimulus=e():t.Stimulus=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";function r(t){throw new Error(t)}function o(t){return"window"==t?window:"document"==t?document:void 0}function i(t){return t==window?"window":t==document?"document":void 0}function c(t,e,n){u(t,e).add(n)}function s(t,e,n){u(t,e).delete(n),a(t,e)}function u(t,e){var n=t.get(e);return n||(n=new Set,t.set(e,n)),n}function a(t,e){var n=t.get(e);null!=n&&0==n.size&&t.delete(e)}function l(t){return t.toString().replace(/([A-Z])/g,function(t,e){return"-"+e.toLowerCase()})}function f(t,e){return"["+t+'~="'+e+'"]'}function h(t){return{identifier:t.identifier,controllerConstructor:p(t.controllerConstructor)}}function p(t){var e=I(t);return e.bless(),e}function d(t){var e=t.prototype;m(t).forEach(function(t){return b(e,(n={},n[t+"Target"]={get:function(){var e=this.targets.find(t);if(e)return e;throw new Error('Missing target element "'+this.identifier+"."+t+'"')}},n[t+"Targets"]={get:function(){return this.targets.findAll(t)}},n["has"+v(t)+"Target"]={get:function(){return this.targets.has(t)}},n));var n})}function m(t){var e=y(t);return Array.from(e.reduce(function(t,e){return g(e).forEach(function(e){return t.add(e)}),t},new Set))}function y(t){for(var e=[];t;)e.push(t),t=Object.getPrototypeOf(t);return e}function g(t){var e=t.targets;return Array.isArray(e)?e:[]}function b(t,e){Object.keys(e).forEach(function(n){if(!(n in t)){var r=e[n];Object.defineProperty(t,n,r)}})}function v(t){return t.charAt(0).toUpperCase()+t.slice(1)}Object.defineProperty(e,"__esModule",{value:!0});var E=function(){function t(t,e,n){this.context=t,this.descriptor=e,this.eventTarget=n}return t.prototype.connect=function(){this.eventTarget.addEventListener(this.eventName,this,!1)},t.prototype.disconnect=function(){this.eventTarget.removeEventListener(this.eventName,this,!1)},t.prototype.hasSameDescriptorAs=function(t){return null!=t&&t.descriptor.isEqualTo(this.descriptor)},t.prototype.handleEvent=function(t){this.willBeInvokedByEvent(t)&&this.invokeWithEvent(t)},Object.defineProperty(t.prototype,"eventName",{get:function(){return this.descriptor.eventName},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"method",{get:function(){var t=this.controller[this.methodName];if("function"==typeof t)return t;throw new Error('Action "'+this.descriptor+'" references undefined method "'+this.methodName+'"')},enumerable:!0,configurable:!0}),t.prototype.invokeWithEvent=function(t){try{this.method.call(this.controller,t)}catch(e){this.context.handleError(e,'invoking action "'+this.descriptor+'"',{event:t})}},t.prototype.willBeInvokedByEvent=function(t){var e=t.target;return this.element===e||(!(e instanceof Element&&this.element.contains(e))||this.scope.containsElement(e))},Object.defineProperty(t.prototype,"controller",{get:function(){return this.context.controller},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"methodName",{get:function(){return this.descriptor.methodName},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scope",{get:function(){return this.context.scope},enumerable:!0,configurable:!0}),t}(),A=/^((.+?)(@(window|document))?->)?(.+?)#(.+)$/,O=function(){function t(t,e,n,r){this.identifier=t,this.eventName=e,this.methodName=n,this.eventTarget=r}return t.forOptions=function(e){return new t(e.identifier||r("Missing identifier in action descriptor"),e.eventName||r("Missing event name in action descriptor"),e.methodName||r("Missing method name in action descriptor"),e.eventTarget||r("Missing event target in action descriptor"))},t.forElementWithInlineDescriptorString=function(e,n){try{var r=this.parseOptionsFromInlineActionDescriptorString(n);return r.eventName=r.eventName||this.getDefaultEventNameForElement(e),r.eventTarget=r.eventTarget||e,t.forOptions(r)}catch(t){throw new Error('Bad action descriptor "'+n+'": '+t.message)}},t.parseOptionsFromInlineActionDescriptorString=function(t){var e=t.trim(),n=e.match(A)||r("Invalid action descriptor syntax");return{identifier:n[5],eventName:n[2],methodName:n[6],eventTarget:o(n[4])}},t.getDefaultEventNameForElement=function(t){return this.defaultEventNames[t.tagName.toLowerCase()](t)},Object.defineProperty(t.prototype,"eventTargetName",{get:function(){return i(this.eventTarget)},enumerable:!0,configurable:!0}),t.prototype.isEqualTo=function(t){return null!=t&&t.identifier==this.identifier&&t.eventName==this.eventName&&t.methodName==this.methodName&&t.eventTarget==this.eventTarget},t.prototype.toString=function(){var t=this.eventTargetName?"@"+this.eventTargetName:"";return""+this.eventName+t+"->"+this.identifier+"#"+this.methodName},t.defaultEventNames={a:function(t){return"click"},button:function(t){return"click"},form:function(t){return"submit"},input:function(t){return"submit"==t.getAttribute("type")?"click":"change"},select:function(t){return"change"},textarea:function(t){return"change"}},t}(),N=function(){function t(t){this.context=t,this.started=!1,this.actions=new Set}return t.prototype.start=function(){this.started||(this.started=!0,this.connectActions())},t.prototype.stop=function(){this.started&&(this.disconnectActions(),this.started=!1)},t.prototype.add=function(t){this.actions.has(t)||(t.connect(),this.actions.add(t))},t.prototype.delete=function(t){this.actions.has(t)&&(this.actions.delete(t),t.disconnect())},t.prototype.connectActions=function(){this.actions.forEach(function(t){return t.connect()})},t.prototype.disconnectActions=function(){this.actions.forEach(function(t){return t.disconnect()})},t}(),j=function(){function t(){this.valuesByKey=new Map}return Object.defineProperty(t.prototype,"values",{get:function(){return Array.from(this.valuesByKey.values()).reduce(function(t,e){return t.concat(Array.from(e))},[])},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return Array.from(this.valuesByKey.values()).reduce(function(t,e){return t+e.size},0)},enumerable:!0,configurable:!0}),t.prototype.add=function(t,e){c(this.valuesByKey,t,e)},t.prototype.delete=function(t,e){s(this.valuesByKey,t,e)},t.prototype.has=function(t,e){var n=this.valuesByKey.get(t);return null!=n&&n.has(e)},t.prototype.hasKey=function(t){return this.valuesByKey.has(t)},t.prototype.hasValue=function(t){return Array.from(this.valuesByKey.values()).some(function(e){return e.has(t)})},t.prototype.getValuesForKey=function(t){var e=this.valuesByKey.get(t);return e?Array.from(e):[]},t.prototype.getKeysForValue=function(t){return Array.from(this.valuesByKey).filter(function(e){e[0];return e[1].has(t)}).map(function(t){var e=t[0];t[1];return e})},t}(),w=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),P=function(t){function e(){var e=t.call(this)||this;return e.keysByValue=new Map,e}return w(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return Array.from(this.keysByValue.keys())},enumerable:!0,configurable:!0}),e.prototype.add=function(e,n){t.prototype.add.call(this,e,n),c(this.keysByValue,n,e)},e.prototype.delete=function(e,n){t.prototype.delete.call(this,e,n),s(this.keysByValue,n,e)},e.prototype.hasValue=function(t){return this.keysByValue.has(t)},e.prototype.getKeysForValue=function(t){var e=this.keysByValue.get(t);return e?Array.from(e):[]},e}(j),T=function(){function t(t,e){var n=this;this.element=t,this.started=!1,this.delegate=e,this.elements=new Set,this.mutationObserver=new MutationObserver(function(t){return n.processMutations(t)})}return t.prototype.start=function(){this.started||(this.mutationObserver.observe(this.element,{attributes:!0,childList:!0,subtree:!0}),this.started=!0,this.refresh())},t.prototype.stop=function(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)},t.prototype.refresh=function(){if(this.started){for(var t=new Set(this.matchElementsInTree()),e=0,n=Array.from(this.elements);e<n.length;e++){var r=n[e];t.has(r)||this.removeElement(r)}for(var o=0,i=Array.from(t);o<i.length;o++){var r=i[o];this.addElement(r)}}},t.prototype.processMutations=function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];this.processMutation(r)}},t.prototype.processMutation=function(t){"attributes"==t.type?this.processAttributeChange(t.target,t.attributeName):"childList"==t.type&&(this.processRemovedNodes(t.removedNodes),this.processAddedNodes(t.addedNodes))},t.prototype.processAttributeChange=function(t,e){var n=t;this.elements.has(n)?this.delegate.elementAttributeChanged&&this.matchElement(n)?this.delegate.elementAttributeChanged(n,e):this.removeElement(n):this.matchElement(n)&&this.addElement(n)},t.prototype.processRemovedNodes=function(t){for(var e=0,n=Array.from(t);e<n.length;e++){var r=n[e];this.processNode(r,this.removeElement)}},t.prototype.processAddedNodes=function(t){for(var e=0,n=Array.from(t);e<n.length;e++){var r=n[e];this.processNode(r,this.addElement)}},t.prototype.matchElement=function(t){return this.delegate.matchElement(t)},t.prototype.matchElementsInTree=function(t){return void 0===t&&(t=this.element),this.delegate.matchElementsInTree(t)},t.prototype.processNode=function(t,e){var n=this.elementFromNode(t);if(n)for(var r=0,o=this.matchElementsInTree(n);r<o.length;r++){var i=o[r];e.call(this,i)}},t.prototype.elementFromNode=function(t){if(t.nodeType==Node.ELEMENT_NODE)return t},t.prototype.addElement=function(t){this.elements.has(t)||(this.elements.add(t),this.delegate.elementMatched&&this.delegate.elementMatched(t))},t.prototype.removeElement=function(t){this.elements.has(t)&&(this.elements.delete(t),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(t))},t}(),F=(function(){function t(t,e,n){this.attributeName=e,this.delegate=n,this.elementObserver=new T(t,this)}Object.defineProperty(t.prototype,"element",{get:function(){return this.elementObserver.element},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selector",{get:function(){return"["+this.attributeName+"]"},enumerable:!0,configurable:!0}),t.prototype.start=function(){this.elementObserver.start()},t.prototype.stop=function(){this.elementObserver.stop()},t.prototype.matchElement=function(t){return t.hasAttribute(this.attributeName)},t.prototype.matchElementsInTree=function(t){var e=this.matchElement(t)?[t]:[],n=Array.from(t.querySelectorAll(this.selector));return e.concat(n)},t.prototype.elementMatched=function(t){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(t,this.attributeName)},t.prototype.elementUnmatched=function(t){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(t,this.attributeName)},t.prototype.elementAttributeChanged=function(t,e){this.delegate.elementAttributeValueChanged&&this.attributeName==e&&this.delegate.elementAttributeValueChanged(t,e)}}(),function(){function t(t,e,n){this.attributeName=e,this.delegate=n,this.elementObserver=new T(t,this),this.tokensByElement=new P}return Object.defineProperty(t.prototype,"started",{get:function(){return this.elementObserver.started},enumerable:!0,configurable:!0}),t.prototype.start=function(){this.elementObserver.start()},t.prototype.stop=function(){this.elementObserver.stop()},t.prototype.refresh=function(){this.elementObserver.refresh()},Object.defineProperty(t.prototype,"element",{get:function(){return this.elementObserver.element},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selector",{get:function(){return"["+this.attributeName+"]"},enumerable:!0,configurable:!0}),t.prototype.getElementsMatchingToken=function(t){return this.tokensByElement.getKeysForValue(t)},t.prototype.matchElement=function(t){return t.hasAttribute(this.attributeName)},t.prototype.matchElementsInTree=function(t){var e=this.matchElement(t)?[t]:[],n=Array.from(t.querySelectorAll(this.selector));return e.concat(n)},t.prototype.elementMatched=function(t){for(var e=Array.from(this.readTokenSetForElement(t)),n=0,r=e;n<r.length;n++){var o=r[n];this.elementMatchedToken(t,o)}},t.prototype.elementUnmatched=function(t){for(var e=this.getTokensForElement(t),n=0,r=e;n<r.length;n++){var o=r[n];this.elementUnmatchedToken(t,o)}},t.prototype.elementAttributeChanged=function(t){for(var e=this.readTokenSetForElement(t),n=0,r=Array.from(e);n<r.length;n++){var o=r[n];this.elementMatchedToken(t,o)}for(var i=0,c=this.getTokensForElement(t);i<c.length;i++){var o=c[i];e.has(o)||this.elementUnmatchedToken(t,o)}},t.prototype.elementMatchedToken=function(t,e){this.tokensByElement.has(t,e)||(this.tokensByElement.add(t,e),this.delegate.elementMatchedTokenForAttribute&&this.delegate.elementMatchedTokenForAttribute(t,e,this.attributeName))},t.prototype.elementUnmatchedToken=function(t,e){this.tokensByElement.has(t,e)&&(this.tokensByElement.delete(t,e),this.delegate.elementUnmatchedTokenForAttribute&&this.delegate.elementUnmatchedTokenForAttribute(t,e,this.attributeName))},t.prototype.getTokensForElement=function(t){return this.tokensByElement.getValuesForKey(t)},t.prototype.readTokenSetForElement=function(t){for(var e=new Set,n=t.getAttribute(this.attributeName)||"",r=0,o=n.split(/\s+/);r<o.length;r++){var i=o[r];i.length&&e.add(i)}return e},t}()),k=function(){function t(t,e){this.context=t,this.delegate=e,this.tokenListObserver=new F(this.element,this.attributeName,this),this.connectedActions=new j}return Object.defineProperty(t.prototype,"scope",{get:function(){return this.context.scope},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"schema",{get:function(){return this.context.schema},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"attributeName",{get:function(){return this.schema.actionAttribute},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"identifier",{get:function(){return this.scope.identifier},enumerable:!0,configurable:!0}),t.prototype.start=function(){this.tokenListObserver.start()},t.prototype.stop=function(){this.tokenListObserver.stop()},t.prototype.elementMatchedTokenForAttribute=function(t,e,n){if(this.scope.containsElement(t)){var r=this.buildActionForElementWithDescriptorString(t,e);r&&(this.connectedActions.add(t,r),this.delegate.inlineActionConnected(r))}},t.prototype.elementUnmatchedTokenForAttribute=function(t,e,n){var r=this.getConnectedActionForElementWithDescriptorString(t,e);r&&(this.connectedActions.delete(t,r),this.delegate.inlineActionDisconnected(r))},t.prototype.getConnectedActionForElementWithDescriptorString=function(t,e){var n=this.buildActionForElementWithDescriptorString(t,e);if(n){return this.connectedActions.getValuesForKey(t).find(function(t){return t.hasSameDescriptorAs(n)})}},t.prototype.buildActionForElementWithDescriptorString=function(t,e){try{var n=O.forElementWithInlineDescriptorString(t,e);if(n.identifier==this.identifier)return new E(this.context,n,n.eventTarget)}catch(n){this.context.handleError(n,'parsing descriptor string "'+e+'"',{element:t})}},t}(),x=function(){function t(t){this.scope=t}return Object.defineProperty(t.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"identifier",{get:function(){return this.scope.identifier},enumerable:!0,configurable:!0}),t.prototype.get=function(t){return t=this.getFormattedKey(t),this.element.getAttribute(t)},t.prototype.set=function(t,e){return t=this.getFormattedKey(t),this.element.setAttribute(t,e),this.get(t)},t.prototype.has=function(t){return t=this.getFormattedKey(t),this.element.hasAttribute(t)},t.prototype.delete=function(t){return!!this.has(t)&&(t=this.getFormattedKey(t),this.element.removeAttribute(t),!0)},t.prototype.getFormattedKey=function(t){return"data-"+this.identifier+"-"+l(t)},t}(),B=function(){function t(t){this.scope=t}return Object.defineProperty(t.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"identifier",{get:function(){return this.scope.identifier},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"schema",{get:function(){return this.scope.schema},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return null!=this.find(t)},t.prototype.find=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.getSelectorForTargetNames(t);return this.scope.findElement(n)},t.prototype.findAll=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this.getSelectorForTargetNames(t);return this.scope.findAllElements(n)},t.prototype.getSelectorForTargetNames=function(t){var e=this;return t.map(function(t){return e.getSelectorForTargetName(t)}).join(", ")},t.prototype.getSelectorForTargetName=function(t){var e=this.identifier+"."+t;return f(this.schema.targetAttribute,e)},t}(),M=function(){function t(t,e,n){this.schema=t,this.identifier=e,this.element=n,this.targets=new B(this),this.data=new x(this)}return t.prototype.findElement=function(t){return this.findAllElements(t)[0]},t.prototype.findAllElements=function(t){var e=this.element.matches(t)?[this.element]:[],n=this.filterElements(Array.from(this.element.querySelectorAll(t)));return e.concat(n)},t.prototype.filterElements=function(t){var e=this;return t.filter(function(t){return e.containsElement(t)})},t.prototype.containsElement=function(t){return t.closest(this.controllerSelector)===this.element},Object.defineProperty(t.prototype,"controllerSelector",{get:function(){return f(this.schema.controllerAttribute,this.identifier)},enumerable:!0,configurable:!0}),t}(),C=function(){function t(t,e){this.module=t,this.scope=new M(this.schema,this.identifier,e),this.actions=new N(this),this.inlineActionObserver=new k(this,this);try{this.controller=new t.controllerConstructor(this),this.controller.initialize()}catch(t){this.handleError(t,"initializing controller")}}return t.prototype.connect=function(){this.actions.start(),this.inlineActionObserver.start();try{this.controller.connect()}catch(t){this.handleError(t,"connecting controller")}},t.prototype.disconnect=function(){try{this.controller.disconnect()}catch(t){this.handleError(t,"disconnecting controller")}this.inlineActionObserver.stop(),this.actions.stop()},Object.defineProperty(t.prototype,"application",{get:function(){return this.module.application},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"identifier",{get:function(){return this.module.identifier},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"schema",{get:function(){return this.application.schema},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parentElement",{get:function(){return this.element.parentElement},enumerable:!0,configurable:!0}),t.prototype.inlineActionConnected=function(t){this.actions.add(t)},t.prototype.inlineActionDisconnected=function(t){this.actions.delete(t)},t.prototype.handleError=function(t,e,n){void 0===n&&(n={});var r=this,o=r.identifier,i=r.controller,c=r.element;n=Object.assign({identifier:o,controller:i,element:c},n),this.application.handleError(t,"Error "+e,n)},t}(),S=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),I=function(){function t(t){function e(){var n=this&&this instanceof e?this.constructor:void 0;return Reflect.construct(t,arguments,n)}return e.prototype=Object.create(t.prototype,{constructor:{value:e}}),Reflect.setPrototypeOf(e,t),e}try{return function(){var e=function(){this.a.call(this)},n=t(e);n.prototype.a=function(){},new n}(),t}catch(t){return function(t){return function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return S(e,t),e}(t)}}}(),_=function(){function t(t,e){this.application=t,this.definition=h(e),this.contextsByElement=new WeakMap,this.connectedContexts=new Set}return Object.defineProperty(t.prototype,"identifier",{get:function(){return this.definition.identifier},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"controllerConstructor",{get:function(){return this.definition.controllerConstructor},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contexts",{get:function(){return Array.from(this.connectedContexts)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this.connectedContexts.size},enumerable:!0,configurable:!0}),t.prototype.connectElement=function(t){var e=this.fetchContextForElement(t);e&&!this.connectedContexts.has(e)&&(this.connectedContexts.add(e),e.connect())},t.prototype.disconnectElement=function(t){var e=this.fetchContextForElement(t);e&&this.connectedContexts.has(e)&&(this.connectedContexts.delete(e),e.disconnect())},t.prototype.getContextForElement=function(t){return this.contextsByElement.get(t)},t.prototype.fetchContextForElement=function(t){var e=this.contextsByElement.get(t);return e||(e=new C(this,t),this.contextsByElement.set(t,e)),e},t}(),K=function(){function t(t){this.application=t,this.tokenListObserver=new F(this.element,this.controllerAttribute,this),this.modulesByIdentifier=new Map}return Object.defineProperty(t.prototype,"schema",{get:function(){return this.application.schema},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this.application.element},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"controllerAttribute",{get:function(){return this.schema.controllerAttribute},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"modules",{get:function(){return Array.from(this.modulesByIdentifier.values())},enumerable:!0,configurable:!0}),t.prototype.start=function(){this.tokenListObserver.start()},t.prototype.stop=function(){this.tokenListObserver.stop()},t.prototype.loadDefinition=function(t){var e=t.identifier;this.unloadIdentifier(e);var n=new _(this.application,t);this.modulesByIdentifier.set(e,n),this.connectModule(n)},t.prototype.unloadIdentifier=function(t){var e=this.modulesByIdentifier.get(t);e&&(this.disconnectModule(e),this.modulesByIdentifier.delete(t))},t.prototype.elementMatchedTokenForAttribute=function(t,e,n){this.connectModuleForIdentifierToElement(e,t)},t.prototype.elementUnmatchedTokenForAttribute=function(t,e,n){this.disconnectModuleForIdentifierFromElement(e,t)},Object.defineProperty(t.prototype,"contexts",{get:function(){return this.modules.reduce(function(t,e){return t.concat(Array.from(e.contexts))},[])},enumerable:!0,configurable:!0}),t.prototype.getContextForElementAndIdentifier=function(t,e){var n=this.modulesByIdentifier.get(e);if(n)return n.getContextForElement(t)},t.prototype.connectModule=function(t){for(var e=this.tokenListObserver.getElementsMatchingToken(t.identifier),n=0,r=e;n<r.length;n++){var o=r[n];t.connectElement(o)}},t.prototype.disconnectModule=function(t){for(var e=t.contexts,n=0,r=e;n<r.length;n++){var o=r[n].element;t.disconnectElement(o)}},t.prototype.connectModuleForIdentifierToElement=function(t,e){var n=this.modulesByIdentifier.get(t);n&&n.connectElement(e)},t.prototype.disconnectModuleForIdentifierFromElement=function(t,e){var n=this.modulesByIdentifier.get(t);n&&n.disconnectElement(e)},t}(),D={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target"},V=function(){function t(t,e){void 0===t&&(t=document.documentElement),void 0===e&&(e=D),this.element=t,this.schema=e,this.router=new K(this)}return t.start=function(e,n){var r=new t(e,n);return r.start(),r},t.prototype.start=function(){this.router.start()},t.prototype.stop=function(){this.router.stop()},t.prototype.register=function(t,e){this.load({identifier:t,controllerConstructor:e})},t.prototype.load=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(Array.isArray(t)?t:[t].concat(n)).forEach(function(t){return e.router.loadDefinition(t)})},t.prototype.unload=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(Array.isArray(t)?t:[t].concat(n)).forEach(function(t){return e.router.unloadIdentifier(t)})},Object.defineProperty(t.prototype,"controllers",{get:function(){return this.router.contexts.map(function(t){return t.controller})},enumerable:!0,configurable:!0}),t.prototype.getControllerForElementAndIdentifier=function(t,e){var n=this.router.getContextForElementAndIdentifier(t,e);return n?n.controller:null},t.prototype.handleError=function(t,e,n){console.error("%s\n\n%o\n\n%o",e,t,n)},t}(),L=function(){function t(t){this.context=t}return t.bless=function(){d(this)},Object.defineProperty(t.prototype,"application",{get:function(){return this.context.application},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scope",{get:function(){return this.context.scope},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"identifier",{get:function(){return this.scope.identifier},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"targets",{get:function(){return this.scope.targets},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"data",{get:function(){return this.scope.data},enumerable:!0,configurable:!0}),t.prototype.initialize=function(){},t.prototype.connect=function(){},t.prototype.disconnect=function(){},t.targets=[],t}();n.d(e,"Action",function(){return E}),n.d(e,"ActionDescriptor",function(){return O}),n.d(e,"Application",function(){return V}),n.d(e,"Context",function(){return C}),n.d(e,"Controller",function(){return L}),n.d(e,"defaultSchema",function(){return D})}])});
@@ -0,0 +1 @@
1
+ <%= require_asset 'dist/stimulus.umd.js' %>
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stimulusjs-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brice Sanchez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple asset-pipeline wrapper for Stimulus.js by Brice Sanchez
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - Gemfile
21
+ - LICENSE.md
22
+ - Rakefile
23
+ - Readme.md
24
+ - lib/stimulusjs-rails.rb
25
+ - lib/stimulusjs-rails/engine.rb
26
+ - lib/stimulusjs-rails/version.rb
27
+ - stimulusjs-rails.gemspec
28
+ - vendor/assets/javascripts/dist/stimulus.umd.js
29
+ - vendor/assets/javascripts/stimulus.js.erb
30
+ homepage: https://github.com/bricesanchez/stimulusjs-rails
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project: stimulusjs-rails
50
+ rubygems_version: 2.6.13
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Stimulus.js asset pipeline provider/wrapper
54
+ test_files: []