shadcn_phlexcomponents 0.1.16 → 0.1.18

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/app/javascript/controllers/accordion_controller.js +90 -100
  3. data/app/javascript/controllers/alert_dialog_controller.js +4 -4
  4. data/app/javascript/controllers/avatar_controller.js +11 -11
  5. data/app/javascript/controllers/checkbox_controller.js +26 -25
  6. data/app/javascript/controllers/collapsible_controller.js +36 -34
  7. data/app/javascript/controllers/combobox_controller.js +231 -262
  8. data/app/javascript/controllers/command_controller.js +184 -204
  9. data/app/javascript/controllers/date_picker_controller.js +257 -240
  10. data/app/javascript/controllers/date_range_picker_controller.js +200 -188
  11. data/app/javascript/controllers/dialog_controller.js +78 -78
  12. data/app/javascript/controllers/dropdown_menu_controller.js +208 -228
  13. data/app/javascript/controllers/dropdown_menu_sub_controller.js +97 -110
  14. data/app/javascript/controllers/form_field_controller.js +16 -16
  15. data/app/javascript/controllers/hover_card_controller.js +71 -68
  16. data/app/javascript/controllers/loading_button_controller.js +10 -10
  17. data/app/javascript/controllers/popover_controller.js +78 -84
  18. data/app/javascript/controllers/progress_controller.js +11 -11
  19. data/app/javascript/controllers/radio_group_controller.js +74 -74
  20. data/app/javascript/controllers/select_controller.js +232 -246
  21. data/app/javascript/controllers/sidebar_controller.js +27 -26
  22. data/app/javascript/controllers/sidebar_trigger_controller.js +9 -12
  23. data/app/javascript/controllers/slider_controller.js +74 -73
  24. data/app/javascript/controllers/switch_controller.js +23 -22
  25. data/app/javascript/controllers/tabs_controller.js +61 -60
  26. data/app/javascript/controllers/theme_switcher_controller.js +27 -27
  27. data/app/javascript/controllers/toast_container_controller.js +31 -44
  28. data/app/javascript/controllers/toast_controller.js +18 -18
  29. data/app/javascript/controllers/toggle_controller.js +17 -16
  30. data/app/javascript/controllers/toggle_group_controller.js +17 -16
  31. data/app/javascript/controllers/tooltip_controller.js +77 -74
  32. data/app/javascript/shadcn_phlexcomponents.js +58 -58
  33. data/app/javascript/utils/command.js +334 -392
  34. data/app/javascript/utils/floating_ui.js +108 -147
  35. data/app/javascript/utils/index.js +190 -253
  36. data/app/stylesheets/date_picker.css +1 -1
  37. data/app/stylesheets/shadcn_phlexcomponents.css +173 -0
  38. data/app/typescript/controllers/combobox_controller.ts +0 -1
  39. data/app/typescript/controllers/date_picker_controller.ts +25 -7
  40. data/app/typescript/controllers/tooltip_controller.ts +1 -1
  41. data/app/typescript/utils/command.ts +0 -2
  42. data/app/typescript/utils/floating_ui.ts +11 -20
  43. data/app/typescript/utils/index.ts +0 -7
  44. data/lib/shadcn_phlexcomponents/components/accordion.rb +1 -1
  45. data/lib/shadcn_phlexcomponents/components/alert_dialog.rb +6 -6
  46. data/lib/shadcn_phlexcomponents/components/base.rb +2 -2
  47. data/lib/shadcn_phlexcomponents/components/combobox.rb +15 -19
  48. data/lib/shadcn_phlexcomponents/components/command.rb +13 -13
  49. data/lib/shadcn_phlexcomponents/components/date_picker.rb +18 -12
  50. data/lib/shadcn_phlexcomponents/components/date_range_picker.rb +7 -3
  51. data/lib/shadcn_phlexcomponents/components/dialog.rb +6 -6
  52. data/lib/shadcn_phlexcomponents/components/sheet.rb +7 -7
  53. data/lib/shadcn_phlexcomponents/components/toggle.rb +1 -1
  54. data/lib/shadcn_phlexcomponents/version.rb +1 -1
  55. metadata +2 -1
@@ -1,265 +1,251 @@
1
- import { useClickOutside } from "stimulus-use";
2
- import { onKeydown, focusItemByIndex } from "./dropdown_menu_controller";
3
- import { initFloatingUi } from "../utils/floating_ui";
4
- import {
5
- getSameLevelItems,
6
- focusTrigger,
7
- hideContent,
8
- showContent,
9
- lockScroll,
10
- unlockScroll,
11
- onClickOutside,
12
- setGroupLabelsId,
13
- getNextEnabledIndex,
14
- getPreviousEnabledIndex,
15
- focusElement,
16
- } from "../utils";
17
- import { Controller } from "@hotwired/stimulus";
1
+ import { useClickOutside } from 'stimulus-use';
2
+ import { onKeydown, focusItemByIndex } from './dropdown_menu_controller';
3
+ import { initFloatingUi } from '../utils/floating_ui';
4
+ import { getSameLevelItems, focusTrigger, hideContent, showContent, lockScroll, unlockScroll, onClickOutside, setGroupLabelsId, getNextEnabledIndex, getPreviousEnabledIndex, focusElement, } from '../utils';
5
+ import { Controller } from '@hotwired/stimulus';
18
6
  const SelectController = class extends Controller {
19
- // targets
20
- static targets = [
21
- "trigger",
22
- "contentContainer",
23
- "content",
24
- "item",
25
- "triggerText",
26
- "group",
27
- "select",
28
- ];
29
- // values
30
- static values = {
31
- isOpen: Boolean,
32
- selected: String,
33
- };
34
- connect() {
35
- this.items = getSameLevelItems({
36
- content: this.contentTarget,
37
- items: this.itemTargets,
38
- closestContentSelector: '[data-select-target="content"]',
39
- });
40
- this.itemsInnerText = this.items.map((i) => i.innerText.trim());
41
- this.searchString = "";
42
- useClickOutside(this, {
43
- element: this.contentTarget,
44
- dispatchEvent: false,
45
- });
46
- this.DOMKeydownListener = this.onDOMKeydown.bind(this);
47
- setGroupLabelsId(this);
48
- }
49
- toggle(event) {
50
- if (this.isOpenValue) {
51
- this.close();
52
- } else {
53
- this.open(event);
7
+ // targets
8
+ static targets = [
9
+ 'trigger',
10
+ 'contentContainer',
11
+ 'content',
12
+ 'item',
13
+ 'triggerText',
14
+ 'group',
15
+ 'select',
16
+ ];
17
+ // values
18
+ static values = {
19
+ isOpen: Boolean,
20
+ selected: String,
21
+ };
22
+ connect() {
23
+ this.items = getSameLevelItems({
24
+ content: this.contentTarget,
25
+ items: this.itemTargets,
26
+ closestContentSelector: '[data-select-target="content"]',
27
+ });
28
+ this.itemsInnerText = this.items.map((i) => i.innerText.trim());
29
+ this.searchString = '';
30
+ useClickOutside(this, { element: this.contentTarget, dispatchEvent: false });
31
+ this.DOMKeydownListener = this.onDOMKeydown.bind(this);
32
+ setGroupLabelsId(this);
54
33
  }
55
- }
56
- open(event) {
57
- this.isOpenValue = true;
58
- let elementToFocus = null;
59
- if (this.selectedValue) {
60
- const item = this.itemTargets.find(
61
- (i) => i.dataset.value === this.selectedValue,
62
- );
63
- if (item && !item.dataset.disabled) {
64
- elementToFocus = item;
65
- }
34
+ toggle(event) {
35
+ if (this.isOpenValue) {
36
+ this.close();
37
+ }
38
+ else {
39
+ this.open(event);
40
+ }
66
41
  }
67
- if (!elementToFocus) {
68
- if (event instanceof KeyboardEvent) {
69
- const key = event.key;
70
- if (["ArrowDown", "Enter", " "].includes(key)) {
71
- elementToFocus = this.items[0];
42
+ open(event) {
43
+ this.isOpenValue = true;
44
+ let elementToFocus = null;
45
+ if (this.selectedValue) {
46
+ const item = this.itemTargets.find((i) => i.dataset.value === this.selectedValue);
47
+ if (item && !item.dataset.disabled) {
48
+ elementToFocus = item;
49
+ }
72
50
  }
73
- } else {
74
- elementToFocus = this.contentTarget;
75
- }
51
+ if (!elementToFocus) {
52
+ if (event instanceof KeyboardEvent) {
53
+ const key = event.key;
54
+ if (['ArrowDown', 'Enter', ' '].includes(key)) {
55
+ elementToFocus = this.items[0];
56
+ }
57
+ }
58
+ else {
59
+ elementToFocus = this.contentTarget;
60
+ }
61
+ }
62
+ focusElement(elementToFocus);
76
63
  }
77
- focusElement(elementToFocus);
78
- }
79
- close() {
80
- this.isOpenValue = false;
81
- }
82
- onItemFocus(event) {
83
- const item = event.currentTarget;
84
- item.tabIndex = 0;
85
- }
86
- onItemBlur(event) {
87
- const item = event.currentTarget;
88
- item.tabIndex = -1;
89
- }
90
- focusItemByIndex(event = null, index = null) {
91
- focusItemByIndex(this, event, index);
92
- }
93
- focusItem(event) {
94
- const item = event.currentTarget;
95
- const index = this.items.indexOf(item);
96
- if (event instanceof KeyboardEvent) {
97
- const key = event.key;
98
- let newIndex = 0;
99
- if (key === "ArrowUp") {
100
- newIndex = getPreviousEnabledIndex({
101
- items: this.items,
102
- currentIndex: index,
103
- wrapAround: false,
104
- });
105
- } else {
106
- newIndex = getNextEnabledIndex({
107
- items: this.items,
108
- currentIndex: index,
109
- wrapAround: false,
110
- });
111
- }
112
- this.items[newIndex].focus();
113
- } else {
114
- // item mouseover event
115
- this.items[index].focus();
64
+ close() {
65
+ this.isOpenValue = false;
66
+ }
67
+ onItemFocus(event) {
68
+ const item = event.currentTarget;
69
+ item.tabIndex = 0;
70
+ }
71
+ onItemBlur(event) {
72
+ const item = event.currentTarget;
73
+ item.tabIndex = -1;
74
+ }
75
+ focusItemByIndex(event = null, index = null) {
76
+ focusItemByIndex(this, event, index);
77
+ }
78
+ focusItem(event) {
79
+ const item = event.currentTarget;
80
+ const index = this.items.indexOf(item);
81
+ if (event instanceof KeyboardEvent) {
82
+ const key = event.key;
83
+ let newIndex = 0;
84
+ if (key === 'ArrowUp') {
85
+ newIndex = getPreviousEnabledIndex({
86
+ items: this.items,
87
+ currentIndex: index,
88
+ wrapAround: false,
89
+ });
90
+ }
91
+ else {
92
+ newIndex = getNextEnabledIndex({
93
+ items: this.items,
94
+ currentIndex: index,
95
+ wrapAround: false,
96
+ });
97
+ }
98
+ this.items[newIndex].focus();
99
+ }
100
+ else {
101
+ // item mouseover event
102
+ this.items[index].focus();
103
+ }
104
+ }
105
+ focusContent() {
106
+ this.contentTarget.focus();
116
107
  }
117
- }
118
- focusContent() {
119
- this.contentTarget.focus();
120
- }
121
- select(event) {
122
- const item = event.currentTarget;
123
- const value = item.dataset.value;
124
- this.selectedValue = value;
125
- this.close();
126
- }
127
- clickOutside(event) {
128
- onClickOutside(this, event);
129
- }
130
- isOpenValueChanged(isOpen, previousIsOpen) {
131
- if (isOpen) {
132
- lockScroll(this.contentTarget.id);
133
- showContent({
134
- trigger: this.triggerTarget,
135
- content: this.contentTarget,
136
- contentContainer: this.contentContainerTarget,
137
- setEqualWidth: true,
138
- });
139
- this.cleanup = initFloatingUi({
140
- referenceElement: this.triggerTarget,
141
- floatingElement: this.contentContainerTarget,
142
- side: this.contentTarget.dataset.side,
143
- align: this.contentTarget.dataset.align,
144
- sideOffset: 4,
145
- });
146
- this.setupEventListeners();
147
- } else {
148
- unlockScroll(this.contentTarget.id);
149
- hideContent({
150
- trigger: this.triggerTarget,
151
- content: this.contentTarget,
152
- contentContainer: this.contentContainerTarget,
153
- });
154
- if (previousIsOpen) {
155
- focusTrigger(this.triggerTarget);
156
- }
157
- this.cleanupEventListeners();
108
+ select(event) {
109
+ const item = event.currentTarget;
110
+ const value = item.dataset.value;
111
+ this.selectedValue = value;
112
+ this.close();
158
113
  }
159
- }
160
- selectedValueChanged(value) {
161
- const item = this.itemTargets.find((i) => i.dataset.value === value);
162
- if (item) {
163
- this.triggerTextTarget.textContent = item.textContent;
164
- this.itemTargets.forEach((i) => {
165
- if (i.dataset.value === value) {
166
- i.setAttribute("aria-selected", "true");
167
- } else {
168
- i.setAttribute("aria-selected", "false");
114
+ clickOutside(event) {
115
+ onClickOutside(this, event);
116
+ }
117
+ isOpenValueChanged(isOpen, previousIsOpen) {
118
+ if (isOpen) {
119
+ lockScroll(this.contentTarget.id);
120
+ showContent({
121
+ trigger: this.triggerTarget,
122
+ content: this.contentTarget,
123
+ contentContainer: this.contentContainerTarget,
124
+ setEqualWidth: true,
125
+ });
126
+ this.cleanup = initFloatingUi({
127
+ referenceElement: this.triggerTarget,
128
+ floatingElement: this.contentContainerTarget,
129
+ side: this.contentTarget.dataset.side,
130
+ align: this.contentTarget.dataset.align,
131
+ sideOffset: 4,
132
+ });
133
+ this.setupEventListeners();
134
+ }
135
+ else {
136
+ unlockScroll(this.contentTarget.id);
137
+ hideContent({
138
+ trigger: this.triggerTarget,
139
+ content: this.contentTarget,
140
+ contentContainer: this.contentContainerTarget,
141
+ });
142
+ if (previousIsOpen) {
143
+ focusTrigger(this.triggerTarget);
144
+ }
145
+ this.cleanupEventListeners();
169
146
  }
170
- });
171
- this.selectTarget.value = value;
172
147
  }
173
- this.triggerTarget.dataset.hasValue = `${!!value && value.length > 0}`;
174
- const placeholder = this.triggerTarget.dataset.placeholder;
175
- if (placeholder && this.triggerTarget.dataset.hasValue === "false") {
176
- this.triggerTextTarget.textContent = placeholder;
148
+ selectedValueChanged(value) {
149
+ const item = this.itemTargets.find((i) => i.dataset.value === value);
150
+ if (item) {
151
+ this.triggerTextTarget.textContent = item.textContent;
152
+ this.itemTargets.forEach((i) => {
153
+ if (i.dataset.value === value) {
154
+ i.setAttribute('aria-selected', 'true');
155
+ }
156
+ else {
157
+ i.setAttribute('aria-selected', 'false');
158
+ }
159
+ });
160
+ this.selectTarget.value = value;
161
+ }
162
+ this.triggerTarget.dataset.hasValue = `${!!value && value.length > 0}`;
163
+ const placeholder = this.triggerTarget.dataset.placeholder;
164
+ if (placeholder && this.triggerTarget.dataset.hasValue === 'false') {
165
+ this.triggerTextTarget.textContent = placeholder;
166
+ }
177
167
  }
178
- }
179
- disconnect() {
180
- this.cleanupEventListeners();
181
- }
182
- onDOMKeydown(event) {
183
- if (!this.isOpenValue) return;
184
- onKeydown(this, event);
185
- const { key, altKey, ctrlKey, metaKey } = event;
186
- if (
187
- key === "Backspace" ||
188
- key === "Clear" ||
189
- (key.length === 1 && key !== " " && !altKey && !ctrlKey && !metaKey)
190
- ) {
191
- this.handleSearch(key);
168
+ disconnect() {
169
+ this.cleanupEventListeners();
192
170
  }
193
- }
194
- setupEventListeners() {
195
- document.addEventListener("keydown", this.DOMKeydownListener);
196
- }
197
- cleanupEventListeners() {
198
- if (this.cleanup) this.cleanup();
199
- document.removeEventListener("keydown", this.DOMKeydownListener);
200
- }
201
- // https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/
202
- handleSearch(char) {
203
- const searchString = this.getSearchString(char);
204
- const focusedItem = this.items.find(
205
- (item) => document.activeElement === item,
206
- );
207
- const focusedIndex = focusedItem ? this.items.indexOf(focusedItem) : 0;
208
- const searchIndex = this.getIndexByLetter(searchString, focusedIndex + 1);
209
- // if a match was found, go to it
210
- if (searchIndex >= 0) {
211
- this.focusItemByIndex(null, searchIndex);
171
+ onDOMKeydown(event) {
172
+ if (!this.isOpenValue)
173
+ return;
174
+ onKeydown(this, event);
175
+ const { key, altKey, ctrlKey, metaKey } = event;
176
+ if (key === 'Backspace' ||
177
+ key === 'Clear' ||
178
+ (key.length === 1 && key !== ' ' && !altKey && !ctrlKey && !metaKey)) {
179
+ this.handleSearch(key);
180
+ }
212
181
  }
213
- // if no matches, clear the timeout and search string
214
- else {
215
- window.clearTimeout(this.searchTimeout);
216
- this.searchString = "";
182
+ setupEventListeners() {
183
+ document.addEventListener('keydown', this.DOMKeydownListener);
217
184
  }
218
- }
219
- filterItemsInnerText(items, filter) {
220
- return items.filter((item) => {
221
- const matches = item.toLowerCase().indexOf(filter.toLowerCase()) === 0;
222
- return matches;
223
- });
224
- }
225
- getSearchString(char) {
226
- // reset typing timeout and start new timeout
227
- // this allows us to make multiple-letter matches, like a native select
228
- if (typeof this.searchTimeout === "number") {
229
- window.clearTimeout(this.searchTimeout);
185
+ cleanupEventListeners() {
186
+ if (this.cleanup)
187
+ this.cleanup();
188
+ document.removeEventListener('keydown', this.DOMKeydownListener);
230
189
  }
231
- this.searchTimeout = window.setTimeout(() => {
232
- this.searchString = "";
233
- }, 500);
234
- // add most recent letter to saved search string
235
- this.searchString += char;
236
- return this.searchString;
237
- }
238
- // return the index of an option from an array of options, based on a search string
239
- // if the filter is multiple iterations of the same letter (e.g "aaa"), then cycle through first-letter matches
240
- getIndexByLetter(filter, startIndex) {
241
- const orderedItems = [
242
- ...this.itemsInnerText.slice(startIndex),
243
- ...this.itemsInnerText.slice(0, startIndex),
244
- ];
245
- const firstMatch = this.filterItemsInnerText(orderedItems, filter)[0];
246
- const allSameLetter = (array) =>
247
- array.every((letter) => letter === array[0]);
248
- // first check if there is an exact match for the typed string
249
- if (firstMatch) {
250
- const index = this.itemsInnerText.indexOf(firstMatch);
251
- return index;
190
+ // https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/
191
+ handleSearch(char) {
192
+ const searchString = this.getSearchString(char);
193
+ const focusedItem = this.items.find((item) => document.activeElement === item);
194
+ const focusedIndex = focusedItem ? this.items.indexOf(focusedItem) : 0;
195
+ const searchIndex = this.getIndexByLetter(searchString, focusedIndex + 1);
196
+ // if a match was found, go to it
197
+ if (searchIndex >= 0) {
198
+ this.focusItemByIndex(null, searchIndex);
199
+ }
200
+ // if no matches, clear the timeout and search string
201
+ else {
202
+ window.clearTimeout(this.searchTimeout);
203
+ this.searchString = '';
204
+ }
205
+ }
206
+ filterItemsInnerText(items, filter) {
207
+ return items.filter((item) => {
208
+ const matches = item.toLowerCase().indexOf(filter.toLowerCase()) === 0;
209
+ return matches;
210
+ });
252
211
  }
253
- // if the same letter is being repeated, cycle through first-letter matches
254
- else if (allSameLetter(filter.split(""))) {
255
- const matches = this.filterItemsInnerText(orderedItems, filter[0]);
256
- const index = this.itemsInnerText.indexOf(matches[0]);
257
- return index;
212
+ getSearchString(char) {
213
+ // reset typing timeout and start new timeout
214
+ // this allows us to make multiple-letter matches, like a native select
215
+ if (typeof this.searchTimeout === 'number') {
216
+ window.clearTimeout(this.searchTimeout);
217
+ }
218
+ this.searchTimeout = window.setTimeout(() => {
219
+ this.searchString = '';
220
+ }, 500);
221
+ // add most recent letter to saved search string
222
+ this.searchString += char;
223
+ return this.searchString;
258
224
  }
259
- // if no matches, return -1
260
- else {
261
- return -1;
225
+ // return the index of an option from an array of options, based on a search string
226
+ // if the filter is multiple iterations of the same letter (e.g "aaa"), then cycle through first-letter matches
227
+ getIndexByLetter(filter, startIndex) {
228
+ const orderedItems = [
229
+ ...this.itemsInnerText.slice(startIndex),
230
+ ...this.itemsInnerText.slice(0, startIndex),
231
+ ];
232
+ const firstMatch = this.filterItemsInnerText(orderedItems, filter)[0];
233
+ const allSameLetter = (array) => array.every((letter) => letter === array[0]);
234
+ // first check if there is an exact match for the typed string
235
+ if (firstMatch) {
236
+ const index = this.itemsInnerText.indexOf(firstMatch);
237
+ return index;
238
+ }
239
+ // if the same letter is being repeated, cycle through first-letter matches
240
+ else if (allSameLetter(filter.split(''))) {
241
+ const matches = this.filterItemsInnerText(orderedItems, filter[0]);
242
+ const index = this.itemsInnerText.indexOf(matches[0]);
243
+ return index;
244
+ }
245
+ // if no matches, return -1
246
+ else {
247
+ return -1;
248
+ }
262
249
  }
263
- }
264
250
  };
265
251
  export { SelectController };
@@ -1,29 +1,30 @@
1
- import { Controller } from "@hotwired/stimulus";
1
+ import { Controller } from '@hotwired/stimulus';
2
2
  export default class default_1 extends Controller {
3
- static targets = ["panel", "panelOffset"];
4
- connect() {
5
- this.width = this.element.offsetWidth;
6
- }
7
- toggle() {
8
- if (this.isOpen()) {
9
- this.close();
10
- } else {
11
- this.open();
3
+ static targets = ['panel', 'panelOffset'];
4
+ connect() {
5
+ this.width = this.element.offsetWidth;
6
+ }
7
+ toggle() {
8
+ if (this.isOpen()) {
9
+ this.close();
10
+ }
11
+ else {
12
+ this.open();
13
+ }
14
+ }
15
+ open() {
16
+ this.element.dataset.state = 'expanded';
17
+ this.element.dataset.collapsible = '';
18
+ this.panelTarget.style.removeProperty('left');
19
+ this.panelOffsetTarget.style.removeProperty('width');
20
+ }
21
+ close() {
22
+ this.element.dataset.state = 'collapsed';
23
+ this.element.dataset.collapsible = 'offcanvas';
24
+ this.panelTarget.style.left = `-${this.width}px`;
25
+ this.panelOffsetTarget.style.width = `${0}`;
26
+ }
27
+ isOpen() {
28
+ return this.element.dataset.state === 'expanded';
12
29
  }
13
- }
14
- open() {
15
- this.element.dataset.state = "expanded";
16
- this.element.dataset.collapsible = "";
17
- this.panelTarget.style.removeProperty("left");
18
- this.panelOffsetTarget.style.removeProperty("width");
19
- }
20
- close() {
21
- this.element.dataset.state = "collapsed";
22
- this.element.dataset.collapsible = "offcanvas";
23
- this.panelTarget.style.left = `-${this.width}px`;
24
- this.panelOffsetTarget.style.width = `${0}`;
25
- }
26
- isOpen() {
27
- return this.element.dataset.state === "expanded";
28
- }
29
30
  }
@@ -1,15 +1,12 @@
1
- import { Controller } from "@hotwired/stimulus";
1
+ import { Controller } from '@hotwired/stimulus';
2
2
  export default class extends Controller {
3
- connect() {
4
- this.sidebarId = this.element.dataset.sidebarId;
5
- }
6
- toggle() {
7
- const sidebar = this.application.getControllerForElementAndIdentifier(
8
- document.querySelector(`#${this.sidebarId}`),
9
- "sidebar",
10
- );
11
- if (sidebar) {
12
- sidebar.toggle();
3
+ connect() {
4
+ this.sidebarId = this.element.dataset.sidebarId;
5
+ }
6
+ toggle() {
7
+ const sidebar = this.application.getControllerForElementAndIdentifier(document.querySelector(`#${this.sidebarId}`), 'sidebar');
8
+ if (sidebar) {
9
+ sidebar.toggle();
10
+ }
13
11
  }
14
- }
15
12
  }