turbo_material 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e7bbed44ed9064ad71ffcbf477fd9cd7f1f3280b3cf299826424165bce6d2a6
4
- data.tar.gz: 2abd0a679e2bb51f2e233ce1867344acc9a066daa8ffa8b9b273d8b0005b65c4
3
+ metadata.gz: f904dd4488984f9f96e107e9e32b3809c0884b382ae82facb43261fce9cca428
4
+ data.tar.gz: 80c47036d39ca75999474289f9ed6b88ccf0a238aece2b95a069b7bc7d2092ae
5
5
  SHA512:
6
- metadata.gz: 864e6a811042ebc6f5e5d623a9ecdca174562b28c87abf627c613e3d26569225185ebae5cb477dce980070235dc2d44d589d78e42c18dd480d1c18f3020abad5
7
- data.tar.gz: cb5c7c8bd7b6ceccbae90c674f65e5aad0e644ecad2410cdecd6667cc99b6b52b6c8ebb5681c94b0ae8625bdfc5a72359c46e8ff2c0a6a727d8bf2ab6d870158
6
+ metadata.gz: 91e7c52c5476509122cc47e5ecb7ddc25d6082fa163f65aa02f03504de8da98adde45e5caebdcc1438ede30f85305462963952a70dd5e3792fe453aa4df1c9e5
7
+ data.tar.gz: cb79432f223068b3f35a3a736a3e49213943e963dd9204c119f7dcb9c34b28eb5c0b6fff1ea4c217aec2277e3359c780231a14a86ba494e01a04d63307d96ec6
@@ -1,11 +1,11 @@
1
- import { Controller } from "@hotwired/stimulus";
2
- import { get } from "@rails/request.js";
3
- import { useClickOutside } from 'stimulus-use';
1
+ import {Controller} from "@hotwired/stimulus";
2
+ import {get} from "@rails/request.js";
3
+ import {useClickOutside} from 'stimulus-use';
4
4
 
5
5
  export default class extends Controller {
6
6
  opened = false;
7
- static targets = [ "input", "hidden", "field", "panel" ];
8
- static outlets = [ "material-list" ];
7
+ static targets = ["input", "hidden", "field", "panel"];
8
+ static outlets = ["material-list"];
9
9
 
10
10
  static values = {
11
11
  url: String,
@@ -13,11 +13,10 @@ export default class extends Controller {
13
13
  name: String
14
14
  }
15
15
 
16
-
17
16
  connect() {
18
17
  this.inputEl = this.element.querySelector(".mdc-text-field");
19
18
  this.chipsetEl = this.element.querySelector(".mdc-chip-set");
20
- mdc.textField.MDCTextField.attachTo(this.inputEl);
19
+ this.input = mdc.textField.MDCTextField.attachTo(this.inputEl);
21
20
  this.chips = mdc.chips.MDCChipSet.attachTo(this.chipsetEl);
22
21
  useClickOutside(this);
23
22
  }
@@ -44,9 +43,10 @@ export default class extends Controller {
44
43
  event.stopPropagation();
45
44
  event.preventDefault();
46
45
  const chip = this.element.querySelector(`.mdc-chip[data-value="${event.target.dataset.value}"]`);
47
- this.chipsetEl.removeChild(chip);
48
- if (this.chipsetEl.children.length === 0) {
49
- this.inputEl.foundation.adapter.floatLabel(false);
46
+ const chipIndex = this.chips.foundation.adapter.getIndexOfChipById(chip.id);
47
+ this.chips.foundation.adapter.removeChipAtIndex(chipIndex);
48
+ if (this.chips.foundation.adapter.getChipListCount() === 0) {
49
+ this.input.foundation.adapter.floatLabel(false);
50
50
  }
51
51
  this.hiddenTarget.value = this.chips.chipsList.map((chip) => chip.root.dataset.value).join(',');
52
52
  this.search();
@@ -72,7 +72,7 @@ export default class extends Controller {
72
72
 
73
73
  this.opened = false;
74
74
  this.panelTarget.classList.remove("mdc-menu-surface--open");
75
- if(event) {
75
+ if (event) {
76
76
  event.preventDefault();
77
77
  event.stopPropagation();
78
78
  }
@@ -97,7 +97,7 @@ export default class extends Controller {
97
97
  if (!this.opened) return;
98
98
 
99
99
  this.materialListOutlet.focusNext();
100
- if(event) {
100
+ if (event) {
101
101
  event.preventDefault();
102
102
  event.stopPropagation();
103
103
  }
@@ -107,7 +107,7 @@ export default class extends Controller {
107
107
  if (!this.opened) return;
108
108
 
109
109
  this.materialListOutlet.focusPrevious();
110
- if(event) {
110
+ if (event) {
111
111
  event.preventDefault();
112
112
  event.stopPropagation();
113
113
  }
@@ -117,7 +117,7 @@ export default class extends Controller {
117
117
  if (!this.opened) return;
118
118
 
119
119
  this.select(this.materialListOutlet.list.listElements[event.detail.index]);
120
- if(event) {
120
+ if (event) {
121
121
  event.preventDefault();
122
122
  event.stopPropagation();
123
123
  }
@@ -0,0 +1,7 @@
1
+ module TurboMaterial
2
+ module ChipsInputOptionsHelper
3
+ def material_chips_input_options(kwargs = {})
4
+ render "components/chips_input_options", **kwargs
5
+ end
6
+ end
7
+ end
@@ -31,6 +31,6 @@
31
31
  <span class="mdc-line-ripple"></span>
32
32
  </label>
33
33
  <div class="mdc-menu-surface--anchor">
34
- <%= render partial: 'components/chips_input_options', locals: { options: options, suffix: suffix, name: name, label: label, fixed: fixed } %>
34
+ <%= material_chips_input_options options: options, suffix: suffix, name: name, label: label, fixed: fixed %>
35
35
  </div>
36
36
  </div>
@@ -1,7 +1,7 @@
1
1
  <%# locals: (suffix:, options: [], label:, name:, opened: 'false', fixed: false) %>
2
2
  <%- id = [name, suffix].compact_blank.join('-') -%>
3
3
  <div id="<%= "#{id}-panel" %>"
4
- class="mdc-menu-surface <%= (opened != 'true' || options.size.zero?) ? '' : 'mdc-menu-surface--open' %> !z-100 <%= fixed ? 'mdc-menu-surface--fixed' : 'mdc-menu-surface--fullwidth' %>"
4
+ class="mdc-menu-surface <%= ((opened != 'true') || options.size.zero?) ? '' : 'mdc-menu-surface--open' %> !z-100 <%= fixed ? 'mdc-menu-surface--fixed' : 'mdc-menu-surface--fullwidth' %>"
5
5
  data-controller="material-menu-surface"
6
6
  data-material-chips-input-target="panel" data-size="<%= options.size %>">
7
7
  <ul class="mdc-deprecated-list max-h-64 overflow-y-auto"
@@ -1,9 +1,9 @@
1
1
  <%# locals: (form:, custom_controller: nil, custom_css: nil, disabled: false, required: false, name:, label: nil, id:, checked: false, frame: nil, provide_hidden: false, value: nil, type: 'text', data: {}, min: nil, max: nil, helper: nil, parent: nil, style: 'filled') %>
2
- <label class="mdc-text-field <%= style == 'filled' ? 'mdc-text-field--filled' : 'mdc-text-field--outlined' %> w-full <%= custom_css %>"
2
+ <label class="mdc-text-field rounded-none <%= style == 'filled' ? 'mdc-text-field--filled' : 'mdc-text-field--outlined' %> <%= value || form&.object&.[](name.to_sym) ? 'mdc-text-field--label-floating' : '' %> w-full <%= custom_css %>"
3
3
  data-controller="<%= custom_controller || 'material-input' %>" <% if frame %>data-frame="<%= frame %>"<% end %>>
4
4
  <%- if style == 'filled' -%>
5
5
  <span class="mdc-text-field__ripple"></span>
6
- <span class="mdc-floating-label" id="<%= id %>-label">
6
+ <span class="mdc-floating-label <%= value || form&.object&.[](name.to_sym) ? 'mdc-floating-label--float-above' : '' %>" id="<%= id %>-label">
7
7
  <%= label || name.capitalize %>
8
8
  </span>
9
9
  <%- else -%>
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "importmap-rails"
2
4
 
3
5
  module TurboMaterial
@@ -11,6 +13,7 @@ module TurboMaterial
11
13
  helper TurboMaterial::CheckboxHelper
12
14
  helper TurboMaterial::ChipSetHelper
13
15
  helper TurboMaterial::ChipsInputHelper
16
+ helper TurboMaterial::ChipsInputOptionsHelper
14
17
  helper TurboMaterial::ChipsSelectHelper
15
18
  helper TurboMaterial::DataTableHelper
16
19
  helper TurboMaterial::MenuButtonHelper
@@ -1,3 +1,3 @@
1
1
  module TurboMaterial
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_material
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Moiseev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-16 00:00:00.000000000 Z
11
+ date: 2024-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -114,6 +114,7 @@ files:
114
114
  - app/helpers/turbo_material/checkbox_helper.rb
115
115
  - app/helpers/turbo_material/chip_set_helper.rb
116
116
  - app/helpers/turbo_material/chips_input_helper.rb
117
+ - app/helpers/turbo_material/chips_input_options_helper.rb
117
118
  - app/helpers/turbo_material/chips_select_helper.rb
118
119
  - app/helpers/turbo_material/data_table_helper.rb
119
120
  - app/helpers/turbo_material/input_helper.rb
@@ -190,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  - !ruby/object:Gem::Version
191
192
  version: '0'
192
193
  requirements: []
193
- rubygems_version: 3.5.3
194
+ rubygems_version: 3.4.12
194
195
  signing_key:
195
196
  specification_version: 4
196
197
  summary: Material Web Components for Hotwire Turbo.