turbo_material 0.3.2 → 0.3.4
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/README.md +2 -2
- data/app/assets/javascripts/turbo_material/drawer_button_controller.js +2 -1
- data/app/assets/javascripts/turbo_material/material_checkbox_controller.js +5 -3
- data/app/assets/javascripts/turbo_material/material_chips_input_controller.js +16 -11
- data/app/assets/javascripts/turbo_material/material_chips_select_controller.js +26 -14
- data/app/assets/javascripts/turbo_material/material_data_table_controller.js +1 -3
- data/app/assets/javascripts/turbo_material/material_dialog_controller.js +4 -1
- data/app/assets/javascripts/turbo_material/material_drawer_controller.js +1 -0
- data/app/assets/javascripts/turbo_material/material_input_controller.js +2 -1
- data/app/assets/javascripts/turbo_material/material_list_controller.js +2 -1
- data/app/assets/javascripts/turbo_material/material_menu_button_controller.js +3 -1
- data/app/assets/javascripts/turbo_material/material_menu_surface_controller.js +2 -1
- data/app/assets/javascripts/turbo_material/material_radio_controller.js +2 -1
- data/app/assets/javascripts/turbo_material/material_ripple_controller.js +1 -0
- data/app/assets/javascripts/turbo_material/material_select_controller.js +6 -4
- data/app/assets/javascripts/turbo_material/material_switch_controller.js +4 -3
- data/app/assets/javascripts/turbo_material/material_tooltip_controller.js +2 -1
- data/app/helpers/turbo_material/application_helper.rb +1 -1
- data/app/helpers/turbo_material/tooltip_helper.rb +2 -2
- data/app/views/components/_chips_input.html.erb +4 -4
- data/app/views/components/_input.html.erb +2 -2
- data/app/views/components/_modal.html.erb +5 -5
- data/app/views/components/_select.html.erb +1 -1
- data/app/views/components/_textarea.html.erb +3 -3
- data/app/views/layouts/turbo_material/lookbook.html.erb +2 -2
- data/config/routes.rb +1 -0
- data/lib/generators/turbo_material/install_generator.rb +5 -7
- data/lib/lookbook/chips_input_preview.rb +2 -3
- data/lib/lookbook/menu_button_preview.rb +2 -1
- data/lib/lookbook/modal_preview.rb +2 -1
- data/lib/turbo_material/engine.rb +3 -17
- data/lib/turbo_material/version.rb +2 -1
- data/lib/turbo_material.rb +0 -15
- metadata +9 -9
- data/lib/turbo_material/configuration.rb +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5436c04600eefdcd816509e6f3c38aa151e8f5f300cc96c1ce3e3d0e2f061c99
|
|
4
|
+
data.tar.gz: 52125dac78b16be46ef3ecab2253e2fe1672ba199217434844567d642d117c5d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a92f919545af6764804dc49bd2fc985f24968043460ee02729d5633e129c1483b4d6821ecbbd921286ba1de1471bc22d48b55e402389d61c74d2505cd3f7eba
|
|
7
|
+
data.tar.gz: 82af28e5dd25bd21c8452568cfcc61df9845492e850f249560946d195c005f1b29585b3442771a82b452748e14de292cba5116645894cf443859b2b59f32fb59
|
data/README.md
CHANGED
|
@@ -30,8 +30,8 @@ eagerLoadControllersFrom("turbo_material", application)
|
|
|
30
30
|
Add following to your `app/view/layouts/application.html.erb` in `<head>` section:
|
|
31
31
|
|
|
32
32
|
```erb
|
|
33
|
-
<link href="//cdn.jsdelivr.net/npm/material-components-web@
|
|
34
|
-
<script src="//cdn.jsdelivr.net/npm/material-components-web@
|
|
33
|
+
<link href="//cdn.jsdelivr.net/npm/material-components-web@14.0.0/dist/material-components-web.min.css" rel="stylesheet">
|
|
34
|
+
<script src="//cdn.jsdelivr.net/npm/material-components-web@14.0.0/dist/material-components-web.min.js"></script>
|
|
35
35
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -7,7 +7,7 @@ export default class extends Controller {
|
|
|
7
7
|
if(!document.querySelector('.mdc-drawer--dismissible.mdc-drawer--right')) {
|
|
8
8
|
this.element.style.display = 'none';
|
|
9
9
|
} else {
|
|
10
|
-
mdc.ripple.MDCRipple.attachTo(this.element);
|
|
10
|
+
this.ripple = mdc.ripple.MDCRipple.attachTo(this.element);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -16,5 +16,6 @@ export default class extends Controller {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
disconnect() {
|
|
19
|
+
this.ripple?.destroy();
|
|
19
20
|
}
|
|
20
21
|
}
|
|
@@ -2,11 +2,13 @@ import { Controller } from "@hotwired/stimulus";
|
|
|
2
2
|
|
|
3
3
|
export default class extends Controller {
|
|
4
4
|
connect() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
formField.input = checkbox;
|
|
5
|
+
this.checkbox = mdc.checkbox.MDCCheckbox.attachTo(this.element.querySelector('.mdc-checkbox'));
|
|
6
|
+
this.formField = mdc.formField.MDCFormField.attachTo(this.element);
|
|
7
|
+
this.formField.input = this.checkbox;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
disconnect() {
|
|
11
|
+
this.formField?.destroy();
|
|
12
|
+
this.checkbox?.destroy();
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -26,18 +26,21 @@ export default class extends Controller {
|
|
|
26
26
|
useClickOutside(this);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
return `<div class="mdc-chip__text">${label}</div><i data-action="click->material-chips-input#removeChip" data-value="${value}" class="material-icons mdc-chip__icon mdc-chip__icon--trailing" tabindex="0" role="button">cancel</i>`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
addChip(content, value) {
|
|
29
|
+
addChip(label, value) {
|
|
34
30
|
const chipEl = document.createElement('div');
|
|
35
31
|
chipEl.classList.add('mdc-chip');
|
|
36
|
-
if (this.chipCssValue) {
|
|
37
|
-
chipEl.classList.add(this.chipCssValue);
|
|
38
|
-
}
|
|
39
32
|
chipEl.dataset.value = value;
|
|
40
|
-
|
|
33
|
+
const text = document.createElement('div');
|
|
34
|
+
text.className = 'mdc-chip__text';
|
|
35
|
+
text.textContent = label;
|
|
36
|
+
const icon = document.createElement('i');
|
|
37
|
+
icon.className = 'material-icons mdc-chip__icon mdc-chip__icon--trailing';
|
|
38
|
+
icon.tabIndex = 0;
|
|
39
|
+
icon.setAttribute('role', 'button');
|
|
40
|
+
icon.dataset.action = 'click->material-chips-input#removeChip';
|
|
41
|
+
icon.dataset.value = value;
|
|
42
|
+
icon.textContent = 'cancel';
|
|
43
|
+
chipEl.append(text, icon);
|
|
41
44
|
this.chipsetEl.insertBefore(chipEl, this.hiddenTarget);
|
|
42
45
|
this.chips.addChip(chipEl);
|
|
43
46
|
this.hiddenTarget.value = this.chips.chipsList.map((chip) => chip.root.dataset.value).join(',');
|
|
@@ -47,7 +50,7 @@ export default class extends Controller {
|
|
|
47
50
|
removeChip(event) {
|
|
48
51
|
event.stopPropagation();
|
|
49
52
|
event.preventDefault();
|
|
50
|
-
const chip = this.element.querySelector(`.mdc-chip[data-value="${event.target.dataset.value}"]`);
|
|
53
|
+
const chip = this.element.querySelector(`.mdc-chip[data-value="${CSS.escape(event.target.dataset.value)}"]`);
|
|
51
54
|
const chipIndex = this.chips.foundation.adapter.getIndexOfChipById(chip.id);
|
|
52
55
|
this.chips.foundation.adapter.removeChipAtIndex(chipIndex);
|
|
53
56
|
if (this.chips.foundation.adapter.getChipListCount() === 0) {
|
|
@@ -95,7 +98,7 @@ export default class extends Controller {
|
|
|
95
98
|
select(user) {
|
|
96
99
|
this.close();
|
|
97
100
|
this.inputTarget.value = "";
|
|
98
|
-
this.addChip(
|
|
101
|
+
this.addChip(user.dataset.name, user.dataset.value);
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
focusNext(event) {
|
|
@@ -129,6 +132,8 @@ export default class extends Controller {
|
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
disconnect() {
|
|
135
|
+
this.chips?.destroy();
|
|
136
|
+
this.input?.destroy();
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
search() {
|
|
@@ -21,19 +21,23 @@ export default class extends Controller {
|
|
|
21
21
|
if (this.selectedValue.length > 0) {
|
|
22
22
|
this.select.foundation.adapter.floatLabel(true);
|
|
23
23
|
this.selectedValue.forEach(item => {
|
|
24
|
-
let listItem = this.
|
|
25
|
-
this.addChip(
|
|
24
|
+
let listItem = this.listItem(item);
|
|
25
|
+
this.addChip(listItem.dataset.label, listItem.dataset.value, listItem.dataset.confirmed);
|
|
26
26
|
listItem.classList.add('!hidden');
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
this.select.listen('MDCSelect:change', (event) => {
|
|
30
|
-
const selected = this.
|
|
30
|
+
const selected = this.listItem(event.detail.value);
|
|
31
31
|
selected.classList.add('!hidden');
|
|
32
|
-
this.addChip(
|
|
32
|
+
this.addChip(selected.dataset.label, selected.dataset.value, selected.dataset.confirmed);
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
listItem(value) {
|
|
37
|
+
return this.element.querySelector(`.mdc-deprecated-list-item[data-value="${CSS.escape(value)}"]`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
addChip(label, value, confirmed) {
|
|
37
41
|
const chipEl = document.createElement('div');
|
|
38
42
|
chipEl.role = 'row';
|
|
39
43
|
chipEl.classList.add('mdc-chip');
|
|
@@ -41,7 +45,18 @@ export default class extends Controller {
|
|
|
41
45
|
chipEl.classList.add(this.chipCssValue);
|
|
42
46
|
}
|
|
43
47
|
chipEl.dataset.value = value;
|
|
44
|
-
|
|
48
|
+
const text = document.createElement('div');
|
|
49
|
+
text.className = 'mdc-chip__text';
|
|
50
|
+
text.dataset.action = 'click->material-chips-select#toggle';
|
|
51
|
+
text.textContent = (confirmed === 'false' && this.confirmableValue) ? `${label} (unconfirmed)` : label;
|
|
52
|
+
const icon = document.createElement('i');
|
|
53
|
+
icon.className = 'material-icons mdc-chip__icon mdc-chip__icon--trailing';
|
|
54
|
+
icon.tabIndex = 0;
|
|
55
|
+
icon.setAttribute('role', 'button');
|
|
56
|
+
icon.dataset.action = 'click->material-chips-select#removeChip';
|
|
57
|
+
icon.dataset.value = value;
|
|
58
|
+
icon.textContent = 'cancel';
|
|
59
|
+
chipEl.append(text, icon);
|
|
45
60
|
this.chipsetEl.appendChild(chipEl);
|
|
46
61
|
this.materialChipset.addChip(chipEl);
|
|
47
62
|
if (this.hasHiddenTarget) {
|
|
@@ -60,12 +75,12 @@ export default class extends Controller {
|
|
|
60
75
|
removeChip(event) {
|
|
61
76
|
event.stopPropagation();
|
|
62
77
|
event.preventDefault();
|
|
63
|
-
const chip = this.element.querySelector(`.mdc-chip[data-value="${event.target.dataset.value}"]`);
|
|
78
|
+
const chip = this.element.querySelector(`.mdc-chip[data-value="${CSS.escape(event.target.dataset.value)}"]`);
|
|
64
79
|
this.chipsetEl.removeChild(chip);
|
|
65
80
|
if (this.hasHiddenTarget) {
|
|
66
81
|
this.hiddenTarget.value = this.materialChipset.chipsList.map((chip) => chip.root.dataset.value).join(',');
|
|
67
82
|
}
|
|
68
|
-
const selected = this.
|
|
83
|
+
const selected = this.listItem(event.target.dataset.value);
|
|
69
84
|
selected.classList.remove('!hidden');
|
|
70
85
|
if (this.urlValue) {
|
|
71
86
|
destroy(`${this.urlValue}/${event.target.dataset.value}`, {
|
|
@@ -81,7 +96,7 @@ export default class extends Controller {
|
|
|
81
96
|
if (this.confirmableValue) {
|
|
82
97
|
event.stopPropagation();
|
|
83
98
|
event.preventDefault();
|
|
84
|
-
const item = this.
|
|
99
|
+
const item = this.listItem(event.target.parentElement.dataset.value);
|
|
85
100
|
item.dataset.confirmed = item.dataset.confirmed === 'true' ? 'false' : 'true';
|
|
86
101
|
if (item.dataset.confirmed === 'true') {
|
|
87
102
|
let params = new URLSearchParams(this.queryStringValue);
|
|
@@ -102,11 +117,8 @@ export default class extends Controller {
|
|
|
102
117
|
}
|
|
103
118
|
}
|
|
104
119
|
|
|
105
|
-
chipTemplate(label, value, confirmed) {
|
|
106
|
-
const confirm_label = (confirmed === 'false' && this.confirmableValue) ? ' (unconfirmed)' : '';
|
|
107
|
-
return `<div class="mdc-chip__text" data-action="click->material-chips-select#toggle">${label}${confirm_label}</div><i data-action="click->material-chips-select#removeChip" data-value="${value}" class="material-icons mdc-chip__icon mdc-chip__icon--trailing" tabindex="0" role="button">cancel</i>`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
120
|
disconnect() {
|
|
121
|
+
this.materialChipset?.destroy();
|
|
122
|
+
this.select?.destroy();
|
|
111
123
|
}
|
|
112
124
|
}
|
|
@@ -20,10 +20,7 @@ export default class extends Controller {
|
|
|
20
20
|
params.delete("reverse");
|
|
21
21
|
params.append("order", event.detail.columnId);
|
|
22
22
|
params.append("reverse", event.detail.sortValue === "descending" ? "true" : "false");
|
|
23
|
-
let frame = this.element.querySelector('turbo-frame#pupils-table-data');
|
|
24
23
|
Turbo.visit(`${this.urlValue}?${params.toString()}`);
|
|
25
|
-
// , { action: 'advance', frame: this.bodyValue }
|
|
26
|
-
// FIXME: get this back as soon as https://github.com/hotwired/turbo/issues/489 is fixed
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
select(event) {
|
|
@@ -52,5 +49,6 @@ export default class extends Controller {
|
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
disconnect() {
|
|
52
|
+
this.dataTable?.destroy();
|
|
55
53
|
}
|
|
56
54
|
}
|
|
@@ -2,6 +2,7 @@ import { Controller } from "@hotwired/stimulus";
|
|
|
2
2
|
|
|
3
3
|
export default class extends Controller {
|
|
4
4
|
dialog = undefined;
|
|
5
|
+
ripples = [];
|
|
5
6
|
|
|
6
7
|
static values = {
|
|
7
8
|
opened: Boolean,
|
|
@@ -12,7 +13,7 @@ export default class extends Controller {
|
|
|
12
13
|
this.dialog = mdc.dialog.MDCDialog.attachTo(this.element);
|
|
13
14
|
this.dialog.listen('MDCDialog:opened', () => {
|
|
14
15
|
this.element.querySelectorAll('.mdc-icon-button').forEach((button) => {
|
|
15
|
-
mdc.ripple.MDCRipple.attachTo(button);
|
|
16
|
+
this.ripples.push(mdc.ripple.MDCRipple.attachTo(button));
|
|
16
17
|
});
|
|
17
18
|
});
|
|
18
19
|
if (this.openedValue) {
|
|
@@ -32,5 +33,7 @@ export default class extends Controller {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
disconnect() {
|
|
36
|
+
this.ripples.forEach((ripple) => ripple.destroy());
|
|
37
|
+
this.dialog?.destroy();
|
|
35
38
|
}
|
|
36
39
|
}
|
|
@@ -2,9 +2,10 @@ import { Controller } from "@hotwired/stimulus";
|
|
|
2
2
|
|
|
3
3
|
export default class extends Controller {
|
|
4
4
|
connect() {
|
|
5
|
-
mdc.textField.MDCTextField.attachTo(this.element);
|
|
5
|
+
this.textField = mdc.textField.MDCTextField.attachTo(this.element);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
disconnect() {
|
|
9
|
+
this.textField?.destroy();
|
|
9
10
|
}
|
|
10
11
|
}
|
|
@@ -5,7 +5,7 @@ export default class extends Controller {
|
|
|
5
5
|
this.list = mdc.list.MDCList.attachTo(this.element);
|
|
6
6
|
this.list.listen('MDCList:action', (event) => {
|
|
7
7
|
this.focusElement(event.detail.index);
|
|
8
|
-
this.element.dispatchEvent(new CustomEvent('
|
|
8
|
+
this.element.dispatchEvent(new CustomEvent('material-list:action', {
|
|
9
9
|
bubbles: true,
|
|
10
10
|
cancelable: true,
|
|
11
11
|
detail: {
|
|
@@ -53,5 +53,6 @@ export default class extends Controller {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
disconnect() {
|
|
56
|
+
this.list?.destroy();
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -6,7 +6,7 @@ export default class extends Controller {
|
|
|
6
6
|
static values = { logoutPath: String };
|
|
7
7
|
|
|
8
8
|
connect() {
|
|
9
|
-
mdc.ripple.MDCRipple.attachTo(this.element);
|
|
9
|
+
this.ripple = mdc.ripple.MDCRipple.attachTo(this.element);
|
|
10
10
|
this.menu = mdc.menu.MDCMenu.attachTo(this.element.querySelector('.mdc-menu-surface'));
|
|
11
11
|
const button = this.element.querySelector('.menu-button');
|
|
12
12
|
this.menu.setAnchorElement(button);
|
|
@@ -15,6 +15,8 @@ export default class extends Controller {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
disconnect() {
|
|
18
|
+
this.menu?.destroy();
|
|
19
|
+
this.ripple?.destroy();
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
toggleMenu(event) {
|
|
@@ -3,9 +3,10 @@ import { Controller } from "@hotwired/stimulus";
|
|
|
3
3
|
export default class extends Controller {
|
|
4
4
|
|
|
5
5
|
connect() {
|
|
6
|
-
this.menuSurface =
|
|
6
|
+
this.menuSurface = mdc.menuSurface.MDCMenuSurface.attachTo(this.element);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
disconnect() {
|
|
10
|
+
this.menuSurface?.destroy();
|
|
10
11
|
}
|
|
11
12
|
}
|
|
@@ -2,9 +2,10 @@ import { Controller } from "@hotwired/stimulus";
|
|
|
2
2
|
|
|
3
3
|
export default class extends Controller {
|
|
4
4
|
connect() {
|
|
5
|
-
|
|
5
|
+
this.radio = mdc.radio.MDCRadio.attachTo(this.element);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
disconnect() {
|
|
9
|
+
this.radio?.destroy();
|
|
9
10
|
}
|
|
10
11
|
}
|
|
@@ -2,9 +2,9 @@ import { Controller } from "@hotwired/stimulus";
|
|
|
2
2
|
|
|
3
3
|
export default class extends Controller {
|
|
4
4
|
connect() {
|
|
5
|
-
|
|
6
|
-
select.listen("MDCSelect:change", () => {
|
|
7
|
-
select.root.dispatchEvent(
|
|
5
|
+
this.select = mdc.select.MDCSelect.attachTo(this.element);
|
|
6
|
+
this.select.listen("MDCSelect:change", () => {
|
|
7
|
+
this.select.root.dispatchEvent(
|
|
8
8
|
new CustomEvent("submit-now", {
|
|
9
9
|
bubbles: true,
|
|
10
10
|
cancelable: true,
|
|
@@ -13,5 +13,7 @@ export default class extends Controller {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
disconnect() {
|
|
16
|
+
disconnect() {
|
|
17
|
+
this.select?.destroy();
|
|
18
|
+
}
|
|
17
19
|
}
|
|
@@ -2,13 +2,14 @@ import { Controller } from "@hotwired/stimulus";
|
|
|
2
2
|
|
|
3
3
|
export default class extends Controller {
|
|
4
4
|
connect() {
|
|
5
|
-
|
|
5
|
+
this.switchControl = mdc.switchControl.MDCSwitch.attachTo(this.element.querySelector('.mdc-switch'));
|
|
6
6
|
const hidden = this.element.querySelector('input[type=hidden]');
|
|
7
|
-
switchControl.listen('click', () => {
|
|
8
|
-
hidden.value = switchControl.selected;
|
|
7
|
+
this.switchControl.listen('click', () => {
|
|
8
|
+
hidden.value = this.switchControl.selected;
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
disconnect() {
|
|
13
|
+
this.switchControl?.destroy();
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -2,9 +2,10 @@ import { Controller } from "@hotwired/stimulus";
|
|
|
2
2
|
|
|
3
3
|
export default class extends Controller {
|
|
4
4
|
connect() {
|
|
5
|
-
mdc.tooltip.MDCTooltip.attachTo(this.element);
|
|
5
|
+
this.tooltip = mdc.tooltip.MDCTooltip.attachTo(this.element);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
disconnect() {
|
|
9
|
+
this.tooltip?.destroy();
|
|
9
10
|
}
|
|
10
11
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module TurboMaterial
|
|
4
4
|
module TooltipHelper
|
|
5
|
-
def material_tooltip(kwargs = {}, &
|
|
6
|
-
content = block_given? ? capture(&
|
|
5
|
+
def material_tooltip(kwargs = {}, &)
|
|
6
|
+
content = block_given? ? capture(&) : nil
|
|
7
7
|
render 'components/tooltip', **kwargs, content: content
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
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: {}) %>
|
|
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: {}, autocomplete: 'off') %>
|
|
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 %>"
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
data-material-chips-input-prefetch-value="<%= prefetch.to_s %>"
|
|
8
8
|
data-material-chips-input-additional-query-params-value="<%= additional_query_params.to_json %>"
|
|
9
9
|
<% if suffix.present? %>data-material-chips-input-suffix-value="<%= suffix %>"<% end %>
|
|
10
|
-
data-action="keydown.esc->material-chips-input#close keydown.enter->prevent
|
|
10
|
+
data-action="keydown.esc->material-chips-input#close keydown.enter->material-chips-input#confirmSelection:prevent material-list:action->material-chips-input#confirmSelection"
|
|
11
11
|
>
|
|
12
12
|
<label class="mdc-text-field mdc-text-field--filled w-full h-max! h-full!">
|
|
13
13
|
<span class="mdc-text-field__ripple"></span>
|
|
14
|
-
<span class="mdc-floating-label top-6!"><%= label %></span>
|
|
14
|
+
<span id="<%= id %>-label" class="mdc-floating-label top-6!"><%= label %></span>
|
|
15
15
|
<div class="mdc-chip-set mdc-chip-set--input pt-8! w-full" role="grid">
|
|
16
16
|
<%- selected.each do |chip| -%>
|
|
17
17
|
<div class="mdc-chip">
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
id: id, 'aria-labelledby' => id + '-label',
|
|
26
26
|
required: required,
|
|
27
27
|
disabled: disabled,
|
|
28
|
-
type: type, autocomplete:
|
|
28
|
+
type: type, autocomplete: autocomplete,
|
|
29
29
|
data: { 'material-chips-input-target': 'input',
|
|
30
30
|
action: 'input->material-chips-input#search mousedown->material-chips-input#toggle keydown.down->material-chips-input#focusNext keydown.up->material-chips-input#focusPrevious keydown.enter->material-chips-input#confirmSelection keydown->material-chips-input#open' }
|
|
31
31
|
%>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%# locals: (form:, custom_controller: nil, custom_css: nil, disabled: false, required: false, name:, label: nil, id:, frame: nil, provide_hidden: false, value: nil, type: 'text', data: {}, min: nil, max: nil, helper: nil, parent: nil, style: 'filled', leading_icon: nil, trailing_icon: nil, leading_icon_data: {}, trailing_icon_data: {}) %>
|
|
1
|
+
<%# locals: (form:, custom_controller: nil, custom_css: nil, disabled: false, required: false, name:, label: nil, id:, frame: nil, provide_hidden: false, value: nil, type: 'text', data: {}, min: nil, max: nil, helper: nil, parent: nil, style: 'filled', leading_icon: nil, trailing_icon: nil, leading_icon_data: {}, trailing_icon_data: {}, autocomplete: nil) %>
|
|
2
2
|
<label class="mdc-text-field rounded-none <%= style == 'filled' ? 'mdc-text-field--filled' : 'mdc-text-field--outlined' %> <%= (value || form&.object&.[](name.to_sym)).present? ? 'mdc-text-field--label-floating' : '' %> w-full <%= leading_icon ? 'mdc-text-field--with-leading-icon' : '' %> <%= trailing_icon ? 'mdc-text-field--with-trailing-icon' : '' %> <%= custom_css %>"
|
|
3
3
|
data-controller="<%= custom_controller || 'material-input' %>" <% if frame %>data-frame="<%= frame %>"<% end %>>
|
|
4
4
|
<%- if style == 'filled' -%>
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
class: 'mdc-text-field__input', value: value || form&.object&.[](name.to_sym),
|
|
25
25
|
id: id, 'aria-labelledby' => id + '-label',
|
|
26
26
|
required: required, disabled: disabled,
|
|
27
|
-
type: type, autocomplete:
|
|
27
|
+
type: type, autocomplete: autocomplete, data: { frame: frame, **(data) }.compact,
|
|
28
28
|
min: min, max: max
|
|
29
29
|
%>
|
|
30
30
|
<%- if trailing_icon -%>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<%# locals: (title:, contents_partial: nil, cancel_button_text: 'Cancel', ok_button_text: 'OK', opened: true, dialog_surface_custom_css: '!min-w-[36rem] !min-h-[14rem]', close_action_url: nil, form: nil) %>
|
|
1
|
+
<%# locals: (title:, contents_partial: nil, cancel_button_text: 'Cancel', ok_button_text: 'OK', opened: true, dialog_surface_custom_css: '!min-w-[36rem] !min-h-[14rem]', close_action_url: nil, form: nil, id: "material-dialog-#{SecureRandom.hex(4)}", title_css: 'bg-secondary') %>
|
|
2
2
|
<div class="mdc-dialog" data-controller="material-dialog" data-material-dialog-opened-value="<%= opened %>"
|
|
3
3
|
data-material-dialog-close-action-url-value="<%= close_action_url %>">
|
|
4
4
|
<div class="mdc-dialog__container">
|
|
5
5
|
<div class="mdc-dialog__surface <%= dialog_surface_custom_css %>"
|
|
6
6
|
role="alertdialog"
|
|
7
7
|
aria-modal="true"
|
|
8
|
-
aria-labelledby="
|
|
9
|
-
aria-describedby="
|
|
10
|
-
<h2 class="mdc-dialog__title
|
|
8
|
+
aria-labelledby="<%= id %>-title"
|
|
9
|
+
aria-describedby="<%= id %>-content">
|
|
10
|
+
<h2 id="<%= id %>-title" class="mdc-dialog__title <%= title_css %>">
|
|
11
11
|
<div class="text-white! flex items-center justify-between">
|
|
12
12
|
<span><%= title %></span>
|
|
13
13
|
<button type="button" class="mdc-icon-button mdc-dialog__close" data-mdc-ripple-is-unbounded data-action="click->material-dialog#close">
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
</button>
|
|
18
18
|
</div>
|
|
19
19
|
</h2>
|
|
20
|
-
<div class="mdc-dialog__content">
|
|
20
|
+
<div id="<%= id %>-content" class="mdc-dialog__content">
|
|
21
21
|
<%- if block_given? -%>
|
|
22
22
|
<%= yield %>
|
|
23
23
|
<%- else -%>
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<span class="mdc-notched-outline">
|
|
18
18
|
<span class="mdc-notched-outline__leading"></span>
|
|
19
19
|
<span class="mdc-notched-outline__notch">
|
|
20
|
-
<%- if label -%><span id="
|
|
20
|
+
<%- if label -%><span id="<%= id %>-label" class="mdc-floating-label"><%= label || name.capitalize %></span><%- end -%>
|
|
21
21
|
</span>
|
|
22
22
|
<span class="mdc-notched-outline__trailing"></span>
|
|
23
23
|
</span>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%# locals: (form:, custom_controller: nil, custom_css: nil, disabled: false, required: false, name:, label: nil, id:, frame: nil, provide_hidden: false, value: nil, type: 'text', data: {}, rows: 8, cols: 40, maxlength: 140, helper: nil, parent: nil) %>
|
|
1
|
+
<%# locals: (form:, custom_controller: nil, custom_css: nil, disabled: false, required: false, name:, label: nil, id:, frame: nil, provide_hidden: false, value: nil, type: 'text', data: {}, rows: 8, cols: 40, maxlength: 140, helper: nil, parent: nil, autocomplete: nil) %>
|
|
2
2
|
<label class="mdc-text-field mdc-text-field--filled mdc-text-field--textarea mdc-text-field--no-label w-full! p-2"
|
|
3
3
|
data-controller="<%= custom_controller || 'material-input' %>" <% if frame %>data-frame="<%= frame %>"<% end %>>
|
|
4
4
|
<span class="mdc-notched-outline">
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
<%= form.text_area provide_hidden ? "#{name}_".to_sym : name.to_sym,
|
|
10
10
|
class: 'mdc-text-field__input', value: value || form&.object&.[](name.to_sym),
|
|
11
|
-
id: id, 'aria-
|
|
12
|
-
autocomplete:
|
|
11
|
+
id: id, 'aria-label' => label || name.capitalize, required: required, disabled: disabled,
|
|
12
|
+
autocomplete: autocomplete, data: { frame: frame }.compact, rows: rows, cols: cols, maxlength: maxlength
|
|
13
13
|
%>
|
|
14
14
|
<span class="mdc-text-field-character-counter">0 / <%= maxlength %></span>
|
|
15
15
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<title>Turbo material</title>
|
|
5
5
|
<%= csrf_meta_tags %>
|
|
6
6
|
<%= csp_meta_tag %>
|
|
7
|
-
<link href="//cdn.jsdelivr.net/npm/material-components-web
|
|
8
|
-
<script src="//cdn.jsdelivr.net/npm/material-components-web
|
|
7
|
+
<link href="//cdn.jsdelivr.net/npm/material-components-web@<%= TurboMaterial::MDC_VERSION %>/dist/material-components-web.min.css" rel="stylesheet">
|
|
8
|
+
<script src="//cdn.jsdelivr.net/npm/material-components-web@<%= TurboMaterial::MDC_VERSION %>/dist/material-components-web.min.js"></script>
|
|
9
9
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
|
10
10
|
<%= stylesheet_link_tag "turbo_material/tailwind", "data-turbo-track": "reload" %>
|
|
11
11
|
<%= javascript_importmap_tags %>
|
data/config/routes.rb
CHANGED
|
@@ -7,20 +7,18 @@ module TurboMaterial
|
|
|
7
7
|
HEAD_LINKS = <<-HTML.rstrip.freeze
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
<link href="//cdn.jsdelivr.net/npm/material-components-web
|
|
11
|
-
<script src="//cdn.jsdelivr.net/npm/material-components-web
|
|
10
|
+
<link href="//cdn.jsdelivr.net/npm/material-components-web@#{MDC_VERSION}/dist/material-components-web.min.css" rel="stylesheet">
|
|
11
|
+
<script src="//cdn.jsdelivr.net/npm/material-components-web@#{MDC_VERSION}/dist/material-components-web.min.js"></script>
|
|
12
12
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">#{' '}
|
|
13
13
|
HTML
|
|
14
14
|
|
|
15
|
-
IMPORT = '@import "../builds/tailwind/turbo_material.css";'
|
|
15
|
+
IMPORT = '@import "../builds/tailwind/turbo_material.css";'
|
|
16
16
|
|
|
17
17
|
def add_turbo_material_tailwind
|
|
18
18
|
return if options[:update_tailwind_only]
|
|
19
19
|
|
|
20
20
|
tailwind_path = Rails.root.join('app/assets/tailwind/application.css')
|
|
21
|
-
unless tailwind_path.exist?
|
|
22
|
-
raise '`app/assets/tailwind/application.css` does not exist'
|
|
23
|
-
end
|
|
21
|
+
raise '`app/assets/tailwind/application.css` does not exist' unless tailwind_path.exist?
|
|
24
22
|
|
|
25
23
|
if tailwind_path.read.include?(IMPORT)
|
|
26
24
|
puts "`app/assets/tailwind/application.css` already contains `#{IMPORT}`"
|
|
@@ -56,7 +54,7 @@ module TurboMaterial
|
|
|
56
54
|
raise '`app/views/layouts/application.html.erb` does not exist or does not contain `<%= csp_meta_tag %>`'
|
|
57
55
|
end
|
|
58
56
|
|
|
59
|
-
if layout_path.read.include?('
|
|
57
|
+
if layout_path.read.include?('//cdn.jsdelivr.net/npm/material-components-web@')
|
|
60
58
|
puts '`app/views/layouts/application.html.erb` head already contains material components web links'
|
|
61
59
|
else
|
|
62
60
|
insert_into_file layout_path, after: '<%= csp_meta_tag %>' do
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class ChipsInputPreview < Lookbook::Preview
|
|
4
|
-
|
|
5
4
|
# @param label text
|
|
6
5
|
# @param disabled toggle
|
|
7
6
|
# @param required toggle
|
|
8
7
|
def default(label: 'Chips Input', disabled: false, required: false)
|
|
9
8
|
render 'common/form', helper_name: 'material_chips_input',
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
url: '/countries', name: 'countries', label:, id: 'Input', disabled:, required:,
|
|
10
|
+
options: Carmen::Country.all.map { |c| { id: c.alpha_3_code, label: c.name } }
|
|
12
11
|
end
|
|
13
12
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
class MenuButtonPreview < Lookbook::Preview
|
|
3
4
|
# @param button_text text
|
|
4
5
|
def default(button_text: 'Menu')
|
|
5
6
|
render 'common/standalone', helper_name: 'material_menu_button', button_text:, menu_contents_partial: 'common/menu_contents'
|
|
@@ -7,32 +7,18 @@ module TurboMaterial
|
|
|
7
7
|
isolate_namespace TurboMaterial
|
|
8
8
|
|
|
9
9
|
initializer 'local_helper.action_controller' do
|
|
10
|
+
helper_paths = Dir[root.join('app/helpers/turbo_material/*_helper.rb')]
|
|
10
11
|
ActiveSupport.on_load :action_controller do
|
|
11
|
-
helper TurboMaterial
|
|
12
|
-
helper TurboMaterial::InputHelper
|
|
13
|
-
helper TurboMaterial::CheckboxHelper
|
|
14
|
-
helper TurboMaterial::ChipSetHelper
|
|
15
|
-
helper TurboMaterial::ChipsInputHelper
|
|
16
|
-
helper TurboMaterial::ChipsInputOptionsHelper
|
|
17
|
-
helper TurboMaterial::ChipsSelectHelper
|
|
18
|
-
helper TurboMaterial::DataTableHelper
|
|
19
|
-
helper TurboMaterial::MenuButtonHelper
|
|
20
|
-
helper TurboMaterial::ModalHelper
|
|
21
|
-
helper TurboMaterial::RadioHelper
|
|
22
|
-
helper TurboMaterial::SelectHelper
|
|
23
|
-
helper TurboMaterial::SwitchHelper
|
|
24
|
-
helper TurboMaterial::TextareaHelper
|
|
25
|
-
helper TurboMaterial::TooltipHelper
|
|
12
|
+
helper_paths.each { |path| helper "TurboMaterial::#{File.basename(path, '.rb').camelize}".constantize }
|
|
26
13
|
end
|
|
27
14
|
end
|
|
28
15
|
|
|
29
|
-
initializer 'turbo_material.tailwindcss' do
|
|
16
|
+
initializer 'turbo_material.tailwindcss' do
|
|
30
17
|
ActiveSupport.on_load(:tailwindcss_rails) do
|
|
31
18
|
config.tailwindcss_rails.engines << TurboMaterial::Engine.engine_name
|
|
32
19
|
end
|
|
33
20
|
end
|
|
34
21
|
|
|
35
|
-
|
|
36
22
|
initializer 'turbo_material.importmap', before: 'importmap' do |app|
|
|
37
23
|
# NOTE: this will add pins from this engine to the main app
|
|
38
24
|
# https://github.com/rails/importmap-rails#composing-import-maps
|
data/lib/turbo_material.rb
CHANGED
|
@@ -2,18 +2,3 @@
|
|
|
2
2
|
|
|
3
3
|
require 'turbo_material/version'
|
|
4
4
|
require 'turbo_material/engine'
|
|
5
|
-
require 'turbo_material/configuration'
|
|
6
|
-
|
|
7
|
-
module TurboMaterial
|
|
8
|
-
class << self
|
|
9
|
-
attr_accessor :configuration
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def self.configuration
|
|
13
|
-
@configuration ||= Configuration.new
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def self.configure
|
|
17
|
-
yield(configuration)
|
|
18
|
-
end
|
|
19
|
-
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: turbo_material
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sergey Moiseev
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 2.0
|
|
18
|
+
version: '2.0'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 2.0
|
|
25
|
+
version: '2.0'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: rails
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -61,16 +61,16 @@ dependencies:
|
|
|
61
61
|
name: tailwindcss-rails
|
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
|
63
63
|
requirements:
|
|
64
|
-
- -
|
|
64
|
+
- - ">="
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: 4.3.0
|
|
66
|
+
version: 4.3.0
|
|
67
67
|
type: :runtime
|
|
68
68
|
prerelease: false
|
|
69
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
|
71
|
-
- -
|
|
71
|
+
- - ">="
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: 4.3.0
|
|
73
|
+
version: 4.3.0
|
|
74
74
|
email:
|
|
75
75
|
- moiseev.sergey@gmail.com
|
|
76
76
|
executables: []
|
|
@@ -162,7 +162,6 @@ files:
|
|
|
162
162
|
- lib/tasks/install.rake
|
|
163
163
|
- lib/tasks/turbo_material_tasks.rake
|
|
164
164
|
- lib/turbo_material.rb
|
|
165
|
-
- lib/turbo_material/configuration.rb
|
|
166
165
|
- lib/turbo_material/engine.rb
|
|
167
166
|
- lib/turbo_material/post_install.rb
|
|
168
167
|
- lib/turbo_material/version.rb
|
|
@@ -174,6 +173,7 @@ metadata:
|
|
|
174
173
|
homepage_uri: https://github.com/full-stack-biz/turbo_material
|
|
175
174
|
source_code_uri: https://github.com/full-stack-biz/turbo_material
|
|
176
175
|
changelog_uri: https://github.com/full-stack-biz/turbo_material/blob/main/CHANGELOG.md
|
|
176
|
+
rubygems_mfa_required: 'true'
|
|
177
177
|
post_install_message: |
|
|
178
178
|
Installing `turbo_material` gem. Please, follow the instructions in the README.md file.
|
|
179
179
|
|
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
192
192
|
- !ruby/object:Gem::Version
|
|
193
193
|
version: '0'
|
|
194
194
|
requirements: []
|
|
195
|
-
rubygems_version: 3.6.
|
|
195
|
+
rubygems_version: 3.6.9
|
|
196
196
|
specification_version: 4
|
|
197
197
|
summary: Material Web Components for Hotwire Turbo.
|
|
198
198
|
test_files: []
|