turbo_material 0.2.6 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/turbo_material/material_chips_input_controller.js +23 -15
- data/app/helpers/turbo_material/chips_input_options_helper.rb +7 -0
- data/app/views/components/_chips_input.html.erb +4 -2
- 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 +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6acc440d7f51220ea594251511c1427dc12bfdfcd3089535a6f8c5865301348e
|
4
|
+
data.tar.gz: fd4bab6abf129e3bc7451a885bab1792fa9ef0bd1da1b94230926ab9a5850ff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8bf8d52a2d46cbf0cbd50e980b75b2895fc0dfd63f7e8f1bed6d379a3f6708ec86f411ec2f48f8f3417526aa546b768d5f7a65d49d2e3d48610d729c6339262
|
7
|
+
data.tar.gz: 1460bdf2047d84584c08c870bf58570991c3142f42a726ceb3a779d4a765853eb5b1b2dafa5c22cd6f43d36920d34a23df9d2f5b11dc2b87c8274a1bbc488c1d
|
@@ -1,24 +1,28 @@
|
|
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,
|
12
12
|
suffix: String,
|
13
|
-
name: String
|
13
|
+
name: String,
|
14
|
+
prefetch: Boolean,
|
15
|
+
additionalQueryParams: Object,
|
14
16
|
}
|
15
17
|
|
16
|
-
|
17
18
|
connect() {
|
18
19
|
this.inputEl = this.element.querySelector(".mdc-text-field");
|
19
20
|
this.chipsetEl = this.element.querySelector(".mdc-chip-set");
|
20
|
-
mdc.textField.MDCTextField.attachTo(this.inputEl);
|
21
|
+
this.input = mdc.textField.MDCTextField.attachTo(this.inputEl);
|
21
22
|
this.chips = mdc.chips.MDCChipSet.attachTo(this.chipsetEl);
|
23
|
+
if (this.prefetchValue) {
|
24
|
+
this.search();
|
25
|
+
}
|
22
26
|
useClickOutside(this);
|
23
27
|
}
|
24
28
|
|
@@ -44,9 +48,10 @@ export default class extends Controller {
|
|
44
48
|
event.stopPropagation();
|
45
49
|
event.preventDefault();
|
46
50
|
const chip = this.element.querySelector(`.mdc-chip[data-value="${event.target.dataset.value}"]`);
|
47
|
-
this.
|
48
|
-
|
49
|
-
|
51
|
+
const chipIndex = this.chips.foundation.adapter.getIndexOfChipById(chip.id);
|
52
|
+
this.chips.foundation.adapter.removeChipAtIndex(chipIndex);
|
53
|
+
if (this.chips.foundation.adapter.getChipListCount() === 0) {
|
54
|
+
this.input.foundation.adapter.floatLabel(false);
|
50
55
|
}
|
51
56
|
this.hiddenTarget.value = this.chips.chipsList.map((chip) => chip.root.dataset.value).join(',');
|
52
57
|
this.search();
|
@@ -72,7 +77,7 @@ export default class extends Controller {
|
|
72
77
|
|
73
78
|
this.opened = false;
|
74
79
|
this.panelTarget.classList.remove("mdc-menu-surface--open");
|
75
|
-
if(event) {
|
80
|
+
if (event) {
|
76
81
|
event.preventDefault();
|
77
82
|
event.stopPropagation();
|
78
83
|
}
|
@@ -97,7 +102,7 @@ export default class extends Controller {
|
|
97
102
|
if (!this.opened) return;
|
98
103
|
|
99
104
|
this.materialListOutlet.focusNext();
|
100
|
-
if(event) {
|
105
|
+
if (event) {
|
101
106
|
event.preventDefault();
|
102
107
|
event.stopPropagation();
|
103
108
|
}
|
@@ -107,7 +112,7 @@ export default class extends Controller {
|
|
107
112
|
if (!this.opened) return;
|
108
113
|
|
109
114
|
this.materialListOutlet.focusPrevious();
|
110
|
-
if(event) {
|
115
|
+
if (event) {
|
111
116
|
event.preventDefault();
|
112
117
|
event.stopPropagation();
|
113
118
|
}
|
@@ -117,7 +122,7 @@ export default class extends Controller {
|
|
117
122
|
if (!this.opened) return;
|
118
123
|
|
119
124
|
this.select(this.materialListOutlet.list.listElements[event.detail.index]);
|
120
|
-
if(event) {
|
125
|
+
if (event) {
|
121
126
|
event.preventDefault();
|
122
127
|
event.stopPropagation();
|
123
128
|
}
|
@@ -133,6 +138,9 @@ export default class extends Controller {
|
|
133
138
|
params.append("name", this.nameValue);
|
134
139
|
params.append("opened", this.opened);
|
135
140
|
params.append("exclude", this.hiddenTarget.value);
|
141
|
+
Object.keys(this.additionalQueryParamsValue).forEach((param) => {
|
142
|
+
params.append(param, this.additionalQueryParamsValue[param]);
|
143
|
+
});
|
136
144
|
get(`${this.urlValue}?${params.toString()}`, {
|
137
145
|
responseKind: "turbo-stream",
|
138
146
|
});
|
@@ -1,9 +1,11 @@
|
|
1
|
-
<%# locals: (form:, disabled: false, required: false, name:, label: nil, id:, frame: nil, suffix: nil, type: 'text', url: nil, selected: [], options: [], value: nil, fixed: false) %>
|
1
|
+
<%# locals: (form:, disabled: false, required: false, name:, label: nil, id:, frame: nil, suffix: nil, type: 'text', url: nil, selected: [], options: [], value: nil, fixed: false, prefetch: false, additional_query_params: {}) %>
|
2
2
|
<%- id = [name, suffix].compact_blank.join('-') -%>
|
3
3
|
<div data-controller="material-chips-input"
|
4
4
|
data-material-chips-input-url-value="<%= url %>"
|
5
5
|
data-material-chips-input-name-value="<%= name %>"
|
6
6
|
data-material-chips-input-material-list-outlet="#<%= "#{id}-list" %>"
|
7
|
+
data-material-chips-input-prefetch-value="<%= prefetch.to_s %>"
|
8
|
+
data-material-chips-input-additional-query-params-value="<%= additional_query_params.to_json %>"
|
7
9
|
<% if suffix.present? %>data-material-chips-input-suffix-value="<%= suffix %>"<% end %>
|
8
10
|
data-action="keydown.esc->material-chips-input#close keydown.enter->prevent-default country-select-focus->material-chips-input#confirmSelection"
|
9
11
|
>
|
@@ -31,6 +33,6 @@
|
|
31
33
|
<span class="mdc-line-ripple"></span>
|
32
34
|
</label>
|
33
35
|
<div class="mdc-menu-surface--anchor">
|
34
|
-
<%=
|
36
|
+
<%= material_chips_input_options options: options, suffix: suffix, name: name, label: label, fixed: fixed %>
|
35
37
|
</div>
|
36
38
|
</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.8
|
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-23 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
|