turbo_material 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/turbo_material/material_chips_input_controller.js +14 -14
- data/app/helpers/turbo_material/chips_input_options_helper.rb +7 -0
- data/app/views/components/_chips_input.html.erb +1 -1
- data/app/views/components/_chips_input_options.html.erb +1 -1
- data/app/views/components/_input.html.erb +2 -2
- data/lib/turbo_material/engine.rb +3 -0
- data/lib/turbo_material/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f904dd4488984f9f96e107e9e32b3809c0884b382ae82facb43261fce9cca428
|
4
|
+
data.tar.gz: 80c47036d39ca75999474289f9ed6b88ccf0a238aece2b95a069b7bc7d2092ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91e7c52c5476509122cc47e5ecb7ddc25d6082fa163f65aa02f03504de8da98adde45e5caebdcc1438ede30f85305462963952a70dd5e3792fe453aa4df1c9e5
|
7
|
+
data.tar.gz: cb79432f223068b3f35a3a736a3e49213943e963dd9204c119f7dcb9c34b28eb5c0b6fff1ea4c217aec2277e3359c780231a14a86ba494e01a04d63307d96ec6
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
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 = [
|
8
|
-
static outlets = [
|
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.
|
48
|
-
|
49
|
-
|
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
|
}
|
@@ -31,6 +31,6 @@
|
|
31
31
|
<span class="mdc-line-ripple"></span>
|
32
32
|
</label>
|
33
33
|
<div class="mdc-menu-surface--anchor">
|
34
|
-
<%=
|
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
|
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.
|
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-
|
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.
|
194
|
+
rubygems_version: 3.4.12
|
194
195
|
signing_key:
|
195
196
|
specification_version: 4
|
196
197
|
summary: Material Web Components for Hotwire Turbo.
|