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,82 +1,83 @@
1
- import { Controller } from "@hotwired/stimulus";
2
- import noUiSlider from "nouislider";
1
+ import { Controller } from '@hotwired/stimulus';
2
+ import noUiSlider from 'nouislider';
3
3
  const SliderController = class extends Controller {
4
- // targets
5
- static targets = ["slider", "hiddenInput", "endHiddenInput"];
6
- connect() {
7
- this.range = this.element.dataset.range === "true";
8
- this.DOMClickListener = this.onDOMClick.bind(this);
9
- this.onUpdateValuesListener = this.onUpdateValues.bind(this);
10
- const options = this.getOptions();
11
- this.slider = noUiSlider.create(this.sliderTarget, options);
12
- if (this.element.dataset.disabled === "true") {
13
- this.slider.disable();
14
- }
15
- if (this.element.dataset.id) {
16
- const lowerHandle =
17
- this.slider.target.querySelector(".noUi-handle-lower");
18
- if (lowerHandle) {
19
- lowerHandle.id = this.element.dataset.id;
20
- }
4
+ // targets
5
+ static targets = ['slider', 'hiddenInput', 'endHiddenInput'];
6
+ connect() {
7
+ this.range = this.element.dataset.range === 'true';
8
+ this.DOMClickListener = this.onDOMClick.bind(this);
9
+ this.onUpdateValuesListener = this.onUpdateValues.bind(this);
10
+ const options = this.getOptions();
11
+ this.slider = noUiSlider.create(this.sliderTarget, options);
12
+ if (this.element.dataset.disabled === 'true') {
13
+ this.slider.disable();
14
+ }
15
+ if (this.element.dataset.id) {
16
+ const lowerHandle = this.slider.target.querySelector('.noUi-handle-lower');
17
+ if (lowerHandle) {
18
+ lowerHandle.id = this.element.dataset.id;
19
+ }
20
+ }
21
+ this.slider.on('update', this.onUpdateValuesListener);
22
+ document.addEventListener('click', this.DOMClickListener);
21
23
  }
22
- this.slider.on("update", this.onUpdateValuesListener);
23
- document.addEventListener("click", this.DOMClickListener);
24
- }
25
- disconnect() {
26
- document.removeEventListener("click", this.DOMClickListener);
27
- }
28
- getOptions() {
29
- const defaultOptions = {
30
- connect: this.range ? true : "lower",
31
- tooltips: true,
32
- };
33
- defaultOptions.range = {
34
- min: [parseFloat(this.element.dataset.min || "0")],
35
- max: [parseFloat(this.element.dataset.max || "100")],
36
- };
37
- defaultOptions.step = parseFloat(this.element.dataset.step || "1");
38
- if (this.range) {
39
- defaultOptions.start = [
40
- parseFloat(this.element.dataset.value || "0"),
41
- parseFloat(this.element.dataset.endValue || "0"),
42
- ];
43
- defaultOptions.handleAttributes = [
44
- { "aria-label": "lower" },
45
- { "aria-label": "upper" },
46
- ];
47
- } else {
48
- defaultOptions.start = [parseFloat(this.element.dataset.value || "0")];
49
- defaultOptions.handleAttributes = [{ "aria-label": "lower" }];
24
+ disconnect() {
25
+ document.removeEventListener('click', this.DOMClickListener);
50
26
  }
51
- defaultOptions.orientation =
52
- this.element.dataset.orientation || "horizontal";
53
- try {
54
- return {
55
- ...defaultOptions,
56
- ...JSON.parse(this.element.dataset.options || ""),
57
- };
58
- } catch {
59
- return defaultOptions;
27
+ getOptions() {
28
+ const defaultOptions = {
29
+ connect: this.range ? true : 'lower',
30
+ tooltips: true,
31
+ };
32
+ defaultOptions.range = {
33
+ min: [parseFloat(this.element.dataset.min || '0')],
34
+ max: [parseFloat(this.element.dataset.max || '100')],
35
+ };
36
+ defaultOptions.step = parseFloat(this.element.dataset.step || '1');
37
+ if (this.range) {
38
+ defaultOptions.start = [
39
+ parseFloat(this.element.dataset.value || '0'),
40
+ parseFloat(this.element.dataset.endValue || '0'),
41
+ ];
42
+ defaultOptions.handleAttributes = [
43
+ { 'aria-label': 'lower' },
44
+ { 'aria-label': 'upper' },
45
+ ];
46
+ }
47
+ else {
48
+ defaultOptions.start = [parseFloat(this.element.dataset.value || '0')];
49
+ defaultOptions.handleAttributes = [{ 'aria-label': 'lower' }];
50
+ }
51
+ defaultOptions.orientation = (this.element.dataset.orientation ||
52
+ 'horizontal');
53
+ try {
54
+ return {
55
+ ...defaultOptions,
56
+ ...JSON.parse(this.element.dataset.options || ''),
57
+ };
58
+ }
59
+ catch {
60
+ return defaultOptions;
61
+ }
60
62
  }
61
- }
62
- onUpdateValues(values) {
63
- this.hiddenInputTarget.value = `${values[0]}`;
64
- if (this.range && this.hasEndHiddenInputTarget) {
65
- this.endHiddenInputTarget.value = `${values[1]}`;
63
+ onUpdateValues(values) {
64
+ this.hiddenInputTarget.value = `${values[0]}`;
65
+ if (this.range && this.hasEndHiddenInputTarget) {
66
+ this.endHiddenInputTarget.value = `${values[1]}`;
67
+ }
66
68
  }
67
- }
68
- onDOMClick(event) {
69
- const target = event.target;
70
- // Focus handle of slider when label is clicked.
71
- if (target instanceof HTMLLabelElement) {
72
- const id = target.getAttribute("for");
73
- if (id === this.element.dataset.id) {
74
- const handle = document.querySelector(`#${id}`);
75
- if (handle) {
76
- handle.focus();
69
+ onDOMClick(event) {
70
+ const target = event.target;
71
+ // Focus handle of slider when label is clicked.
72
+ if (target instanceof HTMLLabelElement) {
73
+ const id = target.getAttribute('for');
74
+ if (id === this.element.dataset.id) {
75
+ const handle = document.querySelector(`#${id}`);
76
+ if (handle) {
77
+ handle.focus();
78
+ }
79
+ }
77
80
  }
78
- }
79
81
  }
80
- }
81
82
  };
82
83
  export { SliderController };
@@ -1,26 +1,27 @@
1
- import { Controller } from "@hotwired/stimulus";
1
+ import { Controller } from '@hotwired/stimulus';
2
2
  const SwitchController = class extends Controller {
3
- // targets
4
- static targets = ["input", "thumb"];
5
- // values
6
- static values = {
7
- isChecked: Boolean,
8
- };
9
- toggle() {
10
- this.isCheckedValue = !this.isCheckedValue;
11
- }
12
- isCheckedValueChanged(value) {
13
- if (value) {
14
- this.element.ariaChecked = "true";
15
- this.element.dataset.state = "checked";
16
- this.thumbTarget.dataset.state = "checked";
17
- this.inputTarget.checked = true;
18
- } else {
19
- this.element.ariaChecked = "false";
20
- this.element.dataset.state = "unchecked";
21
- this.thumbTarget.dataset.state = "unchecked";
22
- this.inputTarget.checked = false;
3
+ // targets
4
+ static targets = ['input', 'thumb'];
5
+ // values
6
+ static values = {
7
+ isChecked: Boolean,
8
+ };
9
+ toggle() {
10
+ this.isCheckedValue = !this.isCheckedValue;
11
+ }
12
+ isCheckedValueChanged(value) {
13
+ if (value) {
14
+ this.element.ariaChecked = 'true';
15
+ this.element.dataset.state = 'checked';
16
+ this.thumbTarget.dataset.state = 'checked';
17
+ this.inputTarget.checked = true;
18
+ }
19
+ else {
20
+ this.element.ariaChecked = 'false';
21
+ this.element.dataset.state = 'unchecked';
22
+ this.thumbTarget.dataset.state = 'unchecked';
23
+ this.inputTarget.checked = false;
24
+ }
23
25
  }
24
- }
25
26
  };
26
27
  export { SwitchController };
@@ -1,66 +1,67 @@
1
- import { Controller } from "@hotwired/stimulus";
2
- import { getNextEnabledIndex, getPreviousEnabledIndex } from "../utils";
1
+ import { Controller } from '@hotwired/stimulus';
2
+ import { getNextEnabledIndex, getPreviousEnabledIndex } from '../utils';
3
3
  const TabsController = class extends Controller {
4
- // targets
5
- static targets = ["trigger", "content"];
6
- // values
7
- static values = {
8
- active: String,
9
- };
10
- connect() {
11
- if (!this.activeValue) {
12
- this.activeValue = this.triggerTargets[0].dataset.value;
4
+ // targets
5
+ static targets = ['trigger', 'content'];
6
+ // values
7
+ static values = {
8
+ active: String,
9
+ };
10
+ connect() {
11
+ if (!this.activeValue) {
12
+ this.activeValue = this.triggerTargets[0].dataset.value;
13
+ }
13
14
  }
14
- }
15
- setActiveTab(event) {
16
- const target = event.currentTarget;
17
- if (event instanceof MouseEvent) {
18
- this.activeValue = target.dataset.value;
19
- } else {
20
- const key = event.key;
21
- const focusableTriggers = this.triggerTargets.filter((t) => !t.disabled);
22
- const index = focusableTriggers.indexOf(target);
23
- let newIndex = 0;
24
- if (key === "ArrowLeft") {
25
- newIndex = getPreviousEnabledIndex({
26
- items: focusableTriggers,
27
- currentIndex: index,
28
- wrapAround: true,
29
- });
30
- } else {
31
- newIndex = getNextEnabledIndex({
32
- items: focusableTriggers,
33
- currentIndex: index,
34
- wrapAround: true,
15
+ setActiveTab(event) {
16
+ const target = event.currentTarget;
17
+ if (event instanceof MouseEvent) {
18
+ this.activeValue = target.dataset.value;
19
+ }
20
+ else {
21
+ const key = event.key;
22
+ const focusableTriggers = this.triggerTargets.filter((t) => !t.disabled);
23
+ const index = focusableTriggers.indexOf(target);
24
+ let newIndex = 0;
25
+ if (key === 'ArrowLeft') {
26
+ newIndex = getPreviousEnabledIndex({
27
+ items: focusableTriggers,
28
+ currentIndex: index,
29
+ wrapAround: true,
30
+ });
31
+ }
32
+ else {
33
+ newIndex = getNextEnabledIndex({
34
+ items: focusableTriggers,
35
+ currentIndex: index,
36
+ wrapAround: true,
37
+ });
38
+ }
39
+ this.activeValue = focusableTriggers[newIndex].dataset.value;
40
+ focusableTriggers[newIndex].focus();
41
+ }
42
+ }
43
+ activeValueChanged(value) {
44
+ this.triggerTargets.forEach((trigger) => {
45
+ const triggerValue = trigger.dataset.value;
46
+ const content = this.contentTargets.find((c) => {
47
+ return c.dataset.value === triggerValue;
48
+ });
49
+ if (!content) {
50
+ throw new Error(`Could not find TabsContent with value "${triggerValue}"`);
51
+ }
52
+ if (triggerValue === value) {
53
+ trigger.ariaSelected = 'true';
54
+ trigger.tabIndex = 0;
55
+ trigger.dataset.state = 'active';
56
+ content.classList.remove('hidden');
57
+ }
58
+ else {
59
+ trigger.ariaSelected = 'false';
60
+ trigger.tabIndex = -1;
61
+ trigger.dataset.state = 'inactive';
62
+ content.classList.add('hidden');
63
+ }
35
64
  });
36
- }
37
- this.activeValue = focusableTriggers[newIndex].dataset.value;
38
- focusableTriggers[newIndex].focus();
39
65
  }
40
- }
41
- activeValueChanged(value) {
42
- this.triggerTargets.forEach((trigger) => {
43
- const triggerValue = trigger.dataset.value;
44
- const content = this.contentTargets.find((c) => {
45
- return c.dataset.value === triggerValue;
46
- });
47
- if (!content) {
48
- throw new Error(
49
- `Could not find TabsContent with value "${triggerValue}"`,
50
- );
51
- }
52
- if (triggerValue === value) {
53
- trigger.ariaSelected = "true";
54
- trigger.tabIndex = 0;
55
- trigger.dataset.state = "active";
56
- content.classList.remove("hidden");
57
- } else {
58
- trigger.ariaSelected = "false";
59
- trigger.tabIndex = -1;
60
- trigger.dataset.state = "inactive";
61
- content.classList.add("hidden");
62
- }
63
- });
64
- }
65
66
  };
66
67
  export { TabsController };
@@ -1,32 +1,32 @@
1
- import { Controller } from "@hotwired/stimulus";
1
+ import { Controller } from '@hotwired/stimulus';
2
2
  const ThemeSwitcherController = class extends Controller {
3
- initialize() {
4
- if (
5
- localStorage.theme === "dark" ||
6
- (!("theme" in localStorage) &&
7
- window.matchMedia("(prefers-color-scheme: dark)").matches)
8
- ) {
9
- this.setDarkMode();
10
- } else {
11
- this.setLightMode();
3
+ initialize() {
4
+ if (localStorage.theme === 'dark' ||
5
+ (!('theme' in localStorage) &&
6
+ window.matchMedia('(prefers-color-scheme: dark)').matches)) {
7
+ this.setDarkMode();
8
+ }
9
+ else {
10
+ this.setLightMode();
11
+ }
12
12
  }
13
- }
14
- toggle() {
15
- if (document.documentElement.classList.contains("dark")) {
16
- this.setLightMode();
17
- } else {
18
- this.setDarkMode();
13
+ toggle() {
14
+ if (document.documentElement.classList.contains('dark')) {
15
+ this.setLightMode();
16
+ }
17
+ else {
18
+ this.setDarkMode();
19
+ }
20
+ }
21
+ setLightMode() {
22
+ localStorage.theme = 'light';
23
+ document.documentElement.classList.remove('dark');
24
+ document.documentElement.style.colorScheme = '';
25
+ }
26
+ setDarkMode() {
27
+ localStorage.theme = 'dark';
28
+ document.documentElement.classList.add('dark');
29
+ document.documentElement.style.colorScheme = 'dark';
19
30
  }
20
- }
21
- setLightMode() {
22
- localStorage.theme = "light";
23
- document.documentElement.classList.remove("dark");
24
- document.documentElement.style.colorScheme = "";
25
- }
26
- setDarkMode() {
27
- localStorage.theme = "dark";
28
- document.documentElement.classList.add("dark");
29
- document.documentElement.style.colorScheme = "dark";
30
- }
31
31
  };
32
32
  export { ThemeSwitcherController };
@@ -1,48 +1,35 @@
1
- import { Controller } from "@hotwired/stimulus";
2
- import DOMPurify from "dompurify";
1
+ import { Controller } from '@hotwired/stimulus';
2
+ import DOMPurify from 'dompurify';
3
3
  const ToastContainerController = class extends Controller {
4
- addToast({
5
- title,
6
- description,
7
- action,
8
- variant = "default",
9
- duration = 5000,
10
- }) {
11
- const template =
12
- variant === "default"
13
- ? this.element.querySelector('[data-variant="default"]')
14
- : this.element.querySelector('[data-variant="destructive"]');
15
- const clone = template.content.cloneNode(true);
16
- const toastTemplate = clone.querySelector(
17
- '[data-shadcn-phlexcomponents="toast"]',
18
- );
19
- toastTemplate.dataset.duration = String(duration);
20
- const titleTemplate = clone.querySelector(
21
- '[data-shadcn-phlexcomponents="toast-title"]',
22
- );
23
- const descriptionTemplate = clone.querySelector(
24
- '[data-shadcn-phlexcomponents="toast-description"]',
25
- );
26
- const actionTemplate = clone.querySelector(
27
- '[data-shadcn-phlexcomponents="toast-action"]',
28
- );
29
- titleTemplate.innerHTML = DOMPurify.sanitize(title);
30
- if (description) {
31
- descriptionTemplate.innerHTML = DOMPurify.sanitize(description);
32
- } else {
33
- descriptionTemplate.remove();
4
+ addToast({ title, description, action, variant = 'default', duration = 5000, }) {
5
+ const template = (variant === 'default'
6
+ ? this.element.querySelector('[data-variant="default"]')
7
+ : this.element.querySelector('[data-variant="destructive"]'));
8
+ const clone = template.content.cloneNode(true);
9
+ const toastTemplate = clone.querySelector('[data-shadcn-phlexcomponents="toast"]');
10
+ toastTemplate.dataset.duration = String(duration);
11
+ const titleTemplate = clone.querySelector('[data-shadcn-phlexcomponents="toast-title"]');
12
+ const descriptionTemplate = clone.querySelector('[data-shadcn-phlexcomponents="toast-description"]');
13
+ const actionTemplate = clone.querySelector('[data-shadcn-phlexcomponents="toast-action"]');
14
+ titleTemplate.innerHTML = DOMPurify.sanitize(title);
15
+ if (description) {
16
+ descriptionTemplate.innerHTML = DOMPurify.sanitize(description);
17
+ }
18
+ else {
19
+ descriptionTemplate.remove();
20
+ }
21
+ if (action) {
22
+ const element = document.createElement('div');
23
+ element.innerHTML = DOMPurify.sanitize(action);
24
+ const actionElement = element.firstElementChild;
25
+ const classes = actionTemplate.classList;
26
+ actionElement.classList.add(...classes);
27
+ actionTemplate.replaceWith(actionElement);
28
+ }
29
+ else {
30
+ actionTemplate.remove();
31
+ }
32
+ this.element.append(clone);
34
33
  }
35
- if (action) {
36
- const element = document.createElement("div");
37
- element.innerHTML = DOMPurify.sanitize(action);
38
- const actionElement = element.firstElementChild;
39
- const classes = actionTemplate.classList;
40
- actionElement.classList.add(...classes);
41
- actionTemplate.replaceWith(actionElement);
42
- } else {
43
- actionTemplate.remove();
44
- }
45
- this.element.append(clone);
46
- }
47
34
  };
48
35
  export { ToastContainerController };
@@ -1,22 +1,22 @@
1
- import { Controller } from "@hotwired/stimulus";
2
- import { ANIMATION_OUT_DELAY } from "../utils";
1
+ import { Controller } from '@hotwired/stimulus';
2
+ import { ANIMATION_OUT_DELAY } from '../utils';
3
3
  const ToastController = class extends Controller {
4
- connect() {
5
- this.duration = Number(this.element.dataset.duration);
6
- this.close();
7
- }
8
- cancelClose() {
9
- window.clearTimeout(this.closeTimeout);
10
- }
11
- close() {
12
- if (this.duration > 0) {
13
- this.closeTimeout = window.setTimeout(() => {
14
- this.element.dataset.state = "closed";
15
- setTimeout(() => {
16
- this.element.remove();
17
- }, ANIMATION_OUT_DELAY);
18
- }, this.duration);
4
+ connect() {
5
+ this.duration = Number(this.element.dataset.duration);
6
+ this.close();
7
+ }
8
+ cancelClose() {
9
+ window.clearTimeout(this.closeTimeout);
10
+ }
11
+ close() {
12
+ if (this.duration > 0) {
13
+ this.closeTimeout = window.setTimeout(() => {
14
+ this.element.dataset.state = 'closed';
15
+ setTimeout(() => {
16
+ this.element.remove();
17
+ }, ANIMATION_OUT_DELAY);
18
+ }, this.duration);
19
+ }
19
20
  }
20
- }
21
21
  };
22
22
  export { ToastController };
@@ -1,20 +1,21 @@
1
- import { Controller } from "@hotwired/stimulus";
1
+ import { Controller } from '@hotwired/stimulus';
2
2
  const ToggleController = class extends Controller {
3
- // values
4
- static values = {
5
- isOn: Boolean,
6
- };
7
- toggle() {
8
- this.isOnValue = !this.isOnValue;
9
- }
10
- isOnValueChanged(isOn) {
11
- if (isOn) {
12
- this.element.dataset.state = "on";
13
- this.element.ariaPressed = "true";
14
- } else {
15
- this.element.dataset.state = "off";
16
- this.element.ariaPressed = "false";
3
+ // values
4
+ static values = {
5
+ isOn: Boolean,
6
+ };
7
+ toggle() {
8
+ this.isOnValue = !this.isOnValue;
9
+ }
10
+ isOnValueChanged(isOn) {
11
+ if (isOn) {
12
+ this.element.dataset.state = 'on';
13
+ this.element.ariaPressed = 'true';
14
+ }
15
+ else {
16
+ this.element.dataset.state = 'off';
17
+ this.element.ariaPressed = 'false';
18
+ }
17
19
  }
18
- }
19
20
  };
20
21
  export { ToggleController };
@@ -1,20 +1,21 @@
1
- import { Controller } from "@hotwired/stimulus";
1
+ import { Controller } from '@hotwired/stimulus';
2
2
  const ToggleController = class extends Controller {
3
- // values
4
- static values = {
5
- isOn: Boolean,
6
- };
7
- toggle() {
8
- this.isOnValue = !this.isOnValue;
9
- }
10
- isOnValueChanged(isOn) {
11
- if (isOn) {
12
- this.element.dataset.state = "on";
13
- this.element.ariaPressed = "true";
14
- } else {
15
- this.element.dataset.state = "off";
16
- this.element.ariaPressed = "false";
3
+ // values
4
+ static values = {
5
+ isOn: Boolean,
6
+ };
7
+ toggle() {
8
+ this.isOnValue = !this.isOnValue;
9
+ }
10
+ isOnValueChanged(isOn) {
11
+ if (isOn) {
12
+ this.element.dataset.state = 'on';
13
+ this.element.ariaPressed = 'true';
14
+ }
15
+ else {
16
+ this.element.dataset.state = 'off';
17
+ this.element.ariaPressed = 'false';
18
+ }
17
19
  }
18
- }
19
20
  };
20
21
  export { ToggleController };