polaris_view_components 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75b9c5e7b5a31ce1a5a549b0315fdbefc308206fd89085a19c8feac044f2884f
4
- data.tar.gz: c858f559b97a7dfe14c6c303d3f7b000ca428ddc12ee603511f03ebe4ad4ffcc
3
+ metadata.gz: 1eda78e6803a1783585a9912d600193f29bba781d019204be62bd1cab484e97a
4
+ data.tar.gz: 5b9ba5de1405b1eb089991c7a2db6117d00bddc7787b6484515e35ecddd4b55e
5
5
  SHA512:
6
- metadata.gz: 0577b317bffc512104e90a023eab9d2a674b9f6ce852eb2e8324a77e1723f97029d30545053e29f72ad7da1da14ebb5c2c1f3eee5afa2a50f4ed7bca7afce4b7
7
- data.tar.gz: 1cfb3676d22713e1e6f5d47a4a521683faa1d5a7bc2f94db6731da47e0834b359bdd7f91670c294b6f20e11445089ad08c51111c226c7f77ba2563f417a9b4d3
6
+ metadata.gz: c433aa42655eacf3e55eccb3709d25356e6219a61f9f5880d529dd2c51f41ca8fe019a1f699675f0832efabdae104e2a0e26fb4a0100b1c8e0d0005b7917f0b5
7
+ data.tar.gz: 44ad24c6ff886a6bb9cb11d5fdce9936218f66337924c6474dcd78b4e68357fa08871492f38affb31dac7f19cce81ea4d7151179bba38ef656910ef49b2e0a72
data/README.md CHANGED
@@ -46,6 +46,16 @@ Define Polaris style on your `<body>` tag:
46
46
  <body style="<%= polaris_body_styles %>">
47
47
  ```
48
48
 
49
+ ### Importmaps
50
+
51
+ Add to `config/importmap.rb`:
52
+
53
+ ```rb
54
+ pin "polaris-view-components", to: "polaris_view_components.js"
55
+ ```
56
+
57
+ ### NPM
58
+
49
59
  Install NPM package:
50
60
  ```bash
51
61
  yarn add polaris-view-components
@@ -55,7 +65,7 @@ Add to `app/javascript/controllers/index.js`:
55
65
  ```javascript
56
66
  // Polaris ViewComponents
57
67
  import { registerPolarisControllers } from "polaris-view-components"
58
- registerPolarisControllers(application)
68
+ registerPolarisControllers(Stimulus)
59
69
  ```
60
70
 
61
71
  ## Dependencies
@@ -1,20 +1,7 @@
1
- import { Controller } from "stimulus";
1
+ import { Controller } from "@hotwired/stimulus";
2
2
 
3
- function _defineProperty(obj, key, value) {
4
- if (key in obj) {
5
- Object.defineProperty(obj, key, {
6
- value: value,
7
- enumerable: true,
8
- configurable: true,
9
- writable: true
10
- });
11
- } else {
12
- obj[key] = value;
13
- }
14
- return obj;
15
- }
16
-
17
- class _class$2 extends Controller {
3
+ class ResourceItem extends Controller {
4
+ static targets=[ "link" ];
18
5
  open(event) {
19
6
  if (this.hasLinkTarget && this.targetNotClickable(event.target)) {
20
7
  this.linkTarget.click();
@@ -25,9 +12,8 @@ class _class$2 extends Controller {
25
12
  }
26
13
  }
27
14
 
28
- _defineProperty(_class$2, "targets", [ "link" ]);
29
-
30
- class _class$1 extends Controller {
15
+ class Select extends Controller {
16
+ static targets=[ "selectedOption" ];
31
17
  update(event) {
32
18
  const select = event.currentTarget;
33
19
  const option = select.options[select.selectedIndex];
@@ -35,9 +21,17 @@ class _class$1 extends Controller {
35
21
  }
36
22
  }
37
23
 
38
- _defineProperty(_class$1, "targets", [ "selectedOption" ]);
39
-
40
- class _class extends Controller {
24
+ class TextField extends Controller {
25
+ static targets=[ "input", "clearButton", "characterCount" ];
26
+ static classes=[ "hasValue", "clearButtonHidden" ];
27
+ static values={
28
+ value: String,
29
+ labelTemplate: String,
30
+ textTemplate: String,
31
+ step: Number,
32
+ min: Number,
33
+ max: Number
34
+ };
41
35
  connect() {
42
36
  this.syncValue();
43
37
  this.stepValue = this.inputTarget.getAttribute("step");
@@ -104,23 +98,10 @@ class _class extends Controller {
104
98
  }
105
99
  }
106
100
 
107
- _defineProperty(_class, "targets", [ "input", "clearButton", "characterCount" ]);
108
-
109
- _defineProperty(_class, "classes", [ "hasValue", "clearButtonHidden" ]);
110
-
111
- _defineProperty(_class, "values", {
112
- value: String,
113
- labelTemplate: String,
114
- textTemplate: String,
115
- step: Number,
116
- min: Number,
117
- max: Number
118
- });
119
-
120
101
  function registerPolarisControllers(application) {
121
- application.register("polaris-resource-item", _class$2);
122
- application.register("polaris-select", _class$1);
123
- application.register("polaris-text-field", _class);
102
+ application.register("polaris-resource-item", ResourceItem);
103
+ application.register("polaris-select", Select);
104
+ application.register("polaris-text-field", TextField);
124
105
  }
125
106
 
126
- export { _class$2 as ResourceItem, _class$1 as Select, _class as TextField, registerPolarisControllers };
107
+ export { ResourceItem, Select, TextField, registerPolarisControllers };
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  import { fileAccepted, getDataTransferFiles } from './utils'
4
4
 
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ['link']
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ['selectedOption']
@@ -1,4 +1,4 @@
1
- import { Controller } from 'stimulus'
1
+ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = ['input', 'clearButton', 'characterCount']
@@ -24,7 +24,7 @@ module PolarisViewComponents
24
24
  end
25
25
 
26
26
  append_to_file file_path do
27
- "import { registerPolarisControllers } from 'polaris-view-components'\nregisterPolarisControllers(application)"
27
+ "import { registerPolarisControllers } from \"polaris-view-components\"\nregisterPolarisControllers(Stimulus)"
28
28
  end
29
29
  end
30
30
 
@@ -1,7 +1,6 @@
1
- import { Application } from 'stimulus'
2
- import { definitionsFromContext } from 'stimulus/webpack-helpers'
3
-
4
- const application = Application.start(document.documentElement)
5
- const context = require.context('.', true, /_controller\.js$/)
6
- application.load(definitionsFromContext(context))
1
+ import { Application } from "@hotwired/stimulus"
2
+ import { definitionsFromContext } from "@hotwired/stimulus-webpack-helpers"
7
3
 
4
+ window.Stimulus = Application.start()
5
+ const context = require.context("./", true, /\.js$/)
6
+ Stimulus.load(definitionsFromContext(context))
@@ -13,7 +13,9 @@ module Polaris
13
13
 
14
14
  initializer "polaris_view_components.assets" do |app|
15
15
  if app.config.respond_to?(:assets)
16
- app.config.assets.precompile += %w[polaris_view_components.css]
16
+ app.config.assets.precompile += %w[
17
+ polaris_view_components.js polaris_view_components.css
18
+ ]
17
19
  end
18
20
  end
19
21
 
@@ -1,5 +1,5 @@
1
1
  module Polaris
2
2
  module ViewComponents
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polaris_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Gamble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-09-08 00:00:00.000000000 Z
12
+ date: 2021-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: 5.0.0
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: 7.0.0
23
+ version: 8.0.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: 5.0.0
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: 7.0.0
33
+ version: 8.0.0
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: view_component
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -447,7 +447,7 @@ files:
447
447
  - app/assets/icons/polaris/WearableMajor.svg
448
448
  - app/assets/icons/polaris/WholesaleMajor.svg
449
449
  - app/assets/icons/polaris/WifiMajor.svg
450
- - app/assets/javascripts/polaris.js
450
+ - app/assets/javascripts/polaris_view_components.js
451
451
  - app/assets/stylesheets/polaris_view_components.css
452
452
  - app/components/polaris/action.rb
453
453
  - app/components/polaris/application_component.rb
@@ -563,10 +563,10 @@ files:
563
563
  - app/helpers/polaris/option_helper.rb
564
564
  - app/helpers/polaris/url_helper.rb
565
565
  - app/helpers/polaris/view_helper.rb
566
- - app/javascript/polaris/index.js
567
- - app/javascript/polaris/resource_item_controller.js
568
- - app/javascript/polaris/select_controller.js
569
- - app/javascript/polaris/text_field_controller.js
566
+ - app/javascript/polaris_view_components/index.js
567
+ - app/javascript/polaris_view_components/resource_item_controller.js
568
+ - app/javascript/polaris_view_components/select_controller.js
569
+ - app/javascript/polaris_view_components/text_field_controller.js
570
570
  - app/validators/type_validator.rb
571
571
  - lib/generators/polaris_view_components/USAGE
572
572
  - lib/generators/polaris_view_components/install_generator.rb