shadcn_phlexcomponents 0.1.18 → 0.1.19

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 (128) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +321 -23
  3. data/app/javascript/controllers/accordion_controller.js +101 -90
  4. data/app/javascript/controllers/alert_dialog_controller.js +5 -4
  5. data/app/javascript/controllers/avatar_controller.js +12 -11
  6. data/app/javascript/controllers/checkbox_controller.js +26 -26
  7. data/app/javascript/controllers/collapsible_controller.js +35 -36
  8. data/app/javascript/controllers/combobox_controller.js +262 -231
  9. data/app/javascript/controllers/command_controller.js +205 -184
  10. data/app/javascript/controllers/date_picker_controller.js +252 -253
  11. data/app/javascript/controllers/date_range_picker_controller.js +189 -200
  12. data/app/javascript/controllers/dialog_controller.js +79 -78
  13. data/app/javascript/controllers/dropdown_menu_controller.js +229 -208
  14. data/app/javascript/controllers/dropdown_menu_sub_controller.js +111 -97
  15. data/app/javascript/controllers/form_field_controller.js +17 -16
  16. data/app/javascript/controllers/hover_card_controller.js +69 -71
  17. data/app/javascript/controllers/loading_button_controller.js +11 -10
  18. data/app/javascript/controllers/popover_controller.js +85 -78
  19. data/app/javascript/controllers/progress_controller.js +12 -11
  20. data/app/javascript/controllers/radio_group_controller.js +75 -74
  21. data/app/javascript/controllers/select_controller.js +247 -232
  22. data/app/javascript/controllers/sidebar_controller.js +26 -27
  23. data/app/javascript/controllers/sidebar_trigger_controller.js +12 -9
  24. data/app/javascript/controllers/slider_controller.js +74 -74
  25. data/app/javascript/controllers/switch_controller.js +23 -23
  26. data/app/javascript/controllers/tabs_controller.js +61 -61
  27. data/app/javascript/controllers/theme_switcher_controller.js +28 -27
  28. data/app/javascript/controllers/toast_container_controller.js +45 -31
  29. data/app/javascript/controllers/toast_controller.js +19 -18
  30. data/app/javascript/controllers/toggle_controller.js +17 -17
  31. data/app/javascript/controllers/toggle_group_controller.js +17 -17
  32. data/app/javascript/controllers/tooltip_controller.js +75 -77
  33. data/app/javascript/shadcn_phlexcomponents.js +27 -60
  34. data/app/javascript/utils/command.js +390 -334
  35. data/app/javascript/utils/floating_ui.js +139 -107
  36. data/app/javascript/utils/index.js +253 -190
  37. data/app/typescript/controllers/accordion_controller.ts +2 -0
  38. data/app/typescript/controllers/alert_dialog_controller.ts +2 -0
  39. data/app/typescript/controllers/avatar_controller.ts +2 -0
  40. data/app/typescript/controllers/checkbox_controller.ts +2 -0
  41. data/app/typescript/controllers/collapsible_controller.ts +2 -0
  42. data/app/typescript/controllers/combobox_controller.ts +2 -0
  43. data/app/typescript/controllers/command_controller.ts +2 -0
  44. data/app/typescript/controllers/date_picker_controller.ts +2 -0
  45. data/app/typescript/controllers/date_range_picker_controller.ts +2 -0
  46. data/app/typescript/controllers/dialog_controller.ts +2 -0
  47. data/app/typescript/controllers/dropdown_menu_controller.ts +2 -0
  48. data/app/typescript/controllers/dropdown_menu_sub_controller.ts +2 -0
  49. data/app/typescript/controllers/form_field_controller.ts +2 -0
  50. data/app/typescript/controllers/hover_card_controller.ts +2 -0
  51. data/app/typescript/controllers/loading_button_controller.ts +2 -0
  52. data/app/typescript/controllers/popover_controller.ts +2 -0
  53. data/app/typescript/controllers/progress_controller.ts +2 -0
  54. data/app/typescript/controllers/radio_group_controller.ts +2 -0
  55. data/app/typescript/controllers/select_controller.ts +2 -0
  56. data/app/typescript/controllers/slider_controller.ts +2 -0
  57. data/app/typescript/controllers/switch_controller.ts +2 -0
  58. data/app/typescript/controllers/tabs_controller.ts +2 -0
  59. data/app/typescript/controllers/theme_switcher_controller.ts +2 -0
  60. data/app/typescript/controllers/toast_container_controller.ts +2 -0
  61. data/app/typescript/controllers/toast_controller.ts +2 -0
  62. data/app/typescript/controllers/toggle_controller.ts +2 -0
  63. data/app/typescript/controllers/toggle_group_controller.ts +2 -0
  64. data/app/typescript/controllers/tooltip_controller.ts +2 -0
  65. data/app/typescript/shadcn_phlexcomponents.ts +27 -61
  66. data/app/typescript/utils/index.ts +7 -0
  67. data/lib/install/upgrade_shadcn_phlexcomponents.rb +28 -0
  68. data/lib/shadcn_phlexcomponents/components/accordion.rb +55 -12
  69. data/lib/shadcn_phlexcomponents/components/alert.rb +35 -16
  70. data/lib/shadcn_phlexcomponents/components/alert_dialog.rb +52 -12
  71. data/lib/shadcn_phlexcomponents/components/aspect_ratio.rb +33 -2
  72. data/lib/shadcn_phlexcomponents/components/avatar.rb +24 -7
  73. data/lib/shadcn_phlexcomponents/components/badge.rb +23 -18
  74. data/lib/shadcn_phlexcomponents/components/breadcrumb.rb +46 -6
  75. data/lib/shadcn_phlexcomponents/components/button.rb +32 -27
  76. data/lib/shadcn_phlexcomponents/components/card.rb +59 -10
  77. data/lib/shadcn_phlexcomponents/components/checkbox.rb +51 -30
  78. data/lib/shadcn_phlexcomponents/components/checkbox_group.rb +24 -4
  79. data/lib/shadcn_phlexcomponents/components/combobox.rb +212 -69
  80. data/lib/shadcn_phlexcomponents/components/command.rb +156 -52
  81. data/lib/shadcn_phlexcomponents/components/date_picker.rb +134 -48
  82. data/lib/shadcn_phlexcomponents/components/date_range_picker.rb +20 -42
  83. data/lib/shadcn_phlexcomponents/components/dialog.rb +80 -26
  84. data/lib/shadcn_phlexcomponents/components/dropdown_menu.rb +74 -25
  85. data/lib/shadcn_phlexcomponents/components/dropdown_menu_sub.rb +52 -24
  86. data/lib/shadcn_phlexcomponents/components/form/form_checkbox.rb +1 -1
  87. data/lib/shadcn_phlexcomponents/components/form/form_checkbox_group.rb +1 -1
  88. data/lib/shadcn_phlexcomponents/components/form/form_combobox.rb +1 -1
  89. data/lib/shadcn_phlexcomponents/components/form/form_date_picker.rb +1 -1
  90. data/lib/shadcn_phlexcomponents/components/form/form_date_range_picker.rb +1 -1
  91. data/lib/shadcn_phlexcomponents/components/form/form_error.rb +8 -1
  92. data/lib/shadcn_phlexcomponents/components/form/form_helpers.rb +3 -2
  93. data/lib/shadcn_phlexcomponents/components/form/form_hint.rb +8 -1
  94. data/lib/shadcn_phlexcomponents/components/form/form_input.rb +1 -1
  95. data/lib/shadcn_phlexcomponents/components/form/form_radio_group.rb +1 -1
  96. data/lib/shadcn_phlexcomponents/components/form/form_select.rb +1 -1
  97. data/lib/shadcn_phlexcomponents/components/form/form_slider.rb +1 -1
  98. data/lib/shadcn_phlexcomponents/components/form/form_switch.rb +1 -1
  99. data/lib/shadcn_phlexcomponents/components/form/form_textarea.rb +1 -1
  100. data/lib/shadcn_phlexcomponents/components/form.rb +22 -6
  101. data/lib/shadcn_phlexcomponents/components/hover_card.rb +48 -18
  102. data/lib/shadcn_phlexcomponents/components/input.rb +13 -8
  103. data/lib/shadcn_phlexcomponents/components/label.rb +9 -4
  104. data/lib/shadcn_phlexcomponents/components/link.rb +8 -1
  105. data/lib/shadcn_phlexcomponents/components/pagination.rb +34 -6
  106. data/lib/shadcn_phlexcomponents/components/popover.rb +43 -13
  107. data/lib/shadcn_phlexcomponents/components/progress.rb +37 -6
  108. data/lib/shadcn_phlexcomponents/components/radio_group.rb +41 -15
  109. data/lib/shadcn_phlexcomponents/components/select.rb +99 -42
  110. data/lib/shadcn_phlexcomponents/components/separator.rb +9 -4
  111. data/lib/shadcn_phlexcomponents/components/sheet.rb +87 -21
  112. data/lib/shadcn_phlexcomponents/components/skeleton.rb +8 -1
  113. data/lib/shadcn_phlexcomponents/components/switch.rb +45 -17
  114. data/lib/shadcn_phlexcomponents/components/table.rb +84 -17
  115. data/lib/shadcn_phlexcomponents/components/tabs.rb +36 -12
  116. data/lib/shadcn_phlexcomponents/components/textarea.rb +12 -7
  117. data/lib/shadcn_phlexcomponents/components/toast.rb +46 -20
  118. data/lib/shadcn_phlexcomponents/components/toast_container.rb +19 -14
  119. data/lib/shadcn_phlexcomponents/components/toggle.rb +28 -23
  120. data/lib/shadcn_phlexcomponents/components/tooltip.rb +49 -14
  121. data/lib/shadcn_phlexcomponents/configuration.rb +46 -0
  122. data/lib/shadcn_phlexcomponents/initializers/shadcn_phlexcomponents.rb +28 -0
  123. data/lib/shadcn_phlexcomponents/version.rb +1 -1
  124. data/lib/shadcn_phlexcomponents.rb +12 -1
  125. data/lib/tasks/upgrade.rake +10 -0
  126. metadata +15 -14
  127. data/app/typescript/controllers/sidebar_controller.ts +0 -39
  128. data/app/typescript/controllers/sidebar_trigger_controller.ts +0 -21
@@ -1,83 +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 = 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);
4
+ static name = "slider";
5
+ // targets
6
+ static targets = ["slider", "hiddenInput", "endHiddenInput"];
7
+ connect() {
8
+ this.range = this.element.dataset.range === "true";
9
+ this.DOMClickListener = this.onDOMClick.bind(this);
10
+ this.onUpdateValuesListener = this.onUpdateValues.bind(this);
11
+ const options = this.getOptions();
12
+ this.slider = noUiSlider.create(this.sliderTarget, options);
13
+ if (this.element.dataset.disabled === "true") {
14
+ this.slider.disable();
23
15
  }
24
- disconnect() {
25
- document.removeEventListener('click', this.DOMClickListener);
16
+ if (this.element.dataset.id) {
17
+ const lowerHandle =
18
+ this.slider.target.querySelector(".noUi-handle-lower");
19
+ if (lowerHandle) {
20
+ lowerHandle.id = this.element.dataset.id;
21
+ }
26
22
  }
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
- }
23
+ this.slider.on("update", this.onUpdateValuesListener);
24
+ document.addEventListener("click", this.DOMClickListener);
25
+ }
26
+ disconnect() {
27
+ document.removeEventListener("click", this.DOMClickListener);
28
+ }
29
+ getOptions() {
30
+ const defaultOptions = {
31
+ connect: this.range ? true : "lower",
32
+ tooltips: true,
33
+ };
34
+ defaultOptions.range = {
35
+ min: [parseFloat(this.element.dataset.min || "0")],
36
+ max: [parseFloat(this.element.dataset.max || "100")],
37
+ };
38
+ defaultOptions.step = parseFloat(this.element.dataset.step || "1");
39
+ if (this.range) {
40
+ defaultOptions.start = [
41
+ parseFloat(this.element.dataset.value || "0"),
42
+ parseFloat(this.element.dataset.endValue || "0"),
43
+ ];
44
+ defaultOptions.handleAttributes = [
45
+ { "aria-label": "lower" },
46
+ { "aria-label": "upper" },
47
+ ];
48
+ } else {
49
+ defaultOptions.start = [parseFloat(this.element.dataset.value || "0")];
50
+ defaultOptions.handleAttributes = [{ "aria-label": "lower" }];
62
51
  }
63
- onUpdateValues(values) {
64
- this.hiddenInputTarget.value = `${values[0]}`;
65
- if (this.range && this.hasEndHiddenInputTarget) {
66
- this.endHiddenInputTarget.value = `${values[1]}`;
67
- }
52
+ defaultOptions.orientation =
53
+ this.element.dataset.orientation || "horizontal";
54
+ try {
55
+ return {
56
+ ...defaultOptions,
57
+ ...JSON.parse(this.element.dataset.options || ""),
58
+ };
59
+ } catch {
60
+ return defaultOptions;
61
+ }
62
+ }
63
+ onUpdateValues(values) {
64
+ this.hiddenInputTarget.value = `${values[0]}`;
65
+ if (this.range && this.hasEndHiddenInputTarget) {
66
+ this.endHiddenInputTarget.value = `${values[1]}`;
68
67
  }
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
- }
68
+ }
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();
80
78
  }
79
+ }
81
80
  }
81
+ }
82
82
  };
83
83
  export { SliderController };
@@ -1,27 +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
- }
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
- }
3
+ static name = "switch";
4
+ // targets
5
+ static targets = ["input", "thumb"];
6
+ // values
7
+ static values = {
8
+ isChecked: Boolean,
9
+ };
10
+ toggle() {
11
+ this.isCheckedValue = !this.isCheckedValue;
12
+ }
13
+ isCheckedValueChanged(value) {
14
+ if (value) {
15
+ this.element.ariaChecked = "true";
16
+ this.element.dataset.state = "checked";
17
+ this.thumbTarget.dataset.state = "checked";
18
+ this.inputTarget.checked = true;
19
+ } else {
20
+ this.element.ariaChecked = "false";
21
+ this.element.dataset.state = "unchecked";
22
+ this.thumbTarget.dataset.state = "unchecked";
23
+ this.inputTarget.checked = false;
25
24
  }
25
+ }
26
26
  };
27
27
  export { SwitchController };
@@ -1,67 +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;
13
- }
4
+ static name = "tabs";
5
+ // targets
6
+ static targets = ["trigger", "content"];
7
+ // values
8
+ static values = {
9
+ active: String,
10
+ };
11
+ connect() {
12
+ if (!this.activeValue) {
13
+ this.activeValue = this.triggerTargets[0].dataset.value;
14
14
  }
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
- }
15
+ }
16
+ setActiveTab(event) {
17
+ const target = event.currentTarget;
18
+ if (event instanceof MouseEvent) {
19
+ this.activeValue = target.dataset.value;
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
+ } else {
32
+ newIndex = getNextEnabledIndex({
33
+ items: focusableTriggers,
34
+ currentIndex: index,
35
+ wrapAround: true,
64
36
  });
37
+ }
38
+ this.activeValue = focusableTriggers[newIndex].dataset.value;
39
+ focusableTriggers[newIndex].focus();
65
40
  }
41
+ }
42
+ activeValueChanged(value) {
43
+ this.triggerTargets.forEach((trigger) => {
44
+ const triggerValue = trigger.dataset.value;
45
+ const content = this.contentTargets.find((c) => {
46
+ return c.dataset.value === triggerValue;
47
+ });
48
+ if (!content) {
49
+ throw new Error(
50
+ `Could not find TabsContent with value "${triggerValue}"`,
51
+ );
52
+ }
53
+ if (triggerValue === value) {
54
+ trigger.ariaSelected = "true";
55
+ trigger.tabIndex = 0;
56
+ trigger.dataset.state = "active";
57
+ content.classList.remove("hidden");
58
+ } else {
59
+ trigger.ariaSelected = "false";
60
+ trigger.tabIndex = -1;
61
+ trigger.dataset.state = "inactive";
62
+ content.classList.add("hidden");
63
+ }
64
+ });
65
+ }
66
66
  };
67
67
  export { TabsController };
@@ -1,32 +1,33 @@
1
- import { Controller } from '@hotwired/stimulus';
1
+ import { Controller } from "@hotwired/stimulus";
2
2
  const ThemeSwitcherController = class extends Controller {
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
- }
3
+ static name = "theme-switcher";
4
+ initialize() {
5
+ if (
6
+ localStorage.theme === "dark" ||
7
+ (!("theme" in localStorage) &&
8
+ window.matchMedia("(prefers-color-scheme: dark)").matches)
9
+ ) {
10
+ this.setDarkMode();
11
+ } else {
12
+ this.setLightMode();
12
13
  }
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';
14
+ }
15
+ toggle() {
16
+ if (document.documentElement.classList.contains("dark")) {
17
+ this.setLightMode();
18
+ } else {
19
+ this.setDarkMode();
30
20
  }
21
+ }
22
+ setLightMode() {
23
+ localStorage.theme = "light";
24
+ document.documentElement.classList.remove("dark");
25
+ document.documentElement.style.colorScheme = "";
26
+ }
27
+ setDarkMode() {
28
+ localStorage.theme = "dark";
29
+ document.documentElement.classList.add("dark");
30
+ document.documentElement.style.colorScheme = "dark";
31
+ }
31
32
  };
32
33
  export { ThemeSwitcherController };
@@ -1,35 +1,49 @@
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({ 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);
4
+ static name = "toast-container";
5
+ addToast({
6
+ title,
7
+ description,
8
+ action,
9
+ variant = "default",
10
+ duration = 5000,
11
+ }) {
12
+ const template =
13
+ variant === "default"
14
+ ? this.element.querySelector('[data-variant="default"]')
15
+ : this.element.querySelector('[data-variant="destructive"]');
16
+ const clone = template.content.cloneNode(true);
17
+ const toastTemplate = clone.querySelector(
18
+ '[data-shadcn-phlexcomponents="toast"]',
19
+ );
20
+ toastTemplate.dataset.duration = String(duration);
21
+ const titleTemplate = clone.querySelector(
22
+ '[data-shadcn-phlexcomponents="toast-title"]',
23
+ );
24
+ const descriptionTemplate = clone.querySelector(
25
+ '[data-shadcn-phlexcomponents="toast-description"]',
26
+ );
27
+ const actionTemplate = clone.querySelector(
28
+ '[data-shadcn-phlexcomponents="toast-action"]',
29
+ );
30
+ titleTemplate.innerHTML = DOMPurify.sanitize(title);
31
+ if (description) {
32
+ descriptionTemplate.innerHTML = DOMPurify.sanitize(description);
33
+ } else {
34
+ descriptionTemplate.remove();
33
35
  }
36
+ if (action) {
37
+ const element = document.createElement("div");
38
+ element.innerHTML = DOMPurify.sanitize(action);
39
+ const actionElement = element.firstElementChild;
40
+ const classes = actionTemplate.classList;
41
+ actionElement.classList.add(...classes);
42
+ actionTemplate.replaceWith(actionElement);
43
+ } else {
44
+ actionTemplate.remove();
45
+ }
46
+ this.element.append(clone);
47
+ }
34
48
  };
35
49
  export { ToastContainerController };
@@ -1,22 +1,23 @@
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);
19
- }
4
+ static name = "toast";
5
+ connect() {
6
+ this.duration = Number(this.element.dataset.duration);
7
+ this.close();
8
+ }
9
+ cancelClose() {
10
+ window.clearTimeout(this.closeTimeout);
11
+ }
12
+ close() {
13
+ if (this.duration > 0) {
14
+ this.closeTimeout = window.setTimeout(() => {
15
+ this.element.dataset.state = "closed";
16
+ setTimeout(() => {
17
+ this.element.remove();
18
+ }, ANIMATION_OUT_DELAY);
19
+ }, this.duration);
20
20
  }
21
+ }
21
22
  };
22
23
  export { ToastController };
@@ -1,21 +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
- }
15
- else {
16
- this.element.dataset.state = 'off';
17
- this.element.ariaPressed = 'false';
18
- }
3
+ static name = "toggle";
4
+ // values
5
+ static values = {
6
+ isOn: Boolean,
7
+ };
8
+ toggle() {
9
+ this.isOnValue = !this.isOnValue;
10
+ }
11
+ isOnValueChanged(isOn) {
12
+ if (isOn) {
13
+ this.element.dataset.state = "on";
14
+ this.element.ariaPressed = "true";
15
+ } else {
16
+ this.element.dataset.state = "off";
17
+ this.element.ariaPressed = "false";
19
18
  }
19
+ }
20
20
  };
21
21
  export { ToggleController };
@@ -1,21 +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
- }
15
- else {
16
- this.element.dataset.state = 'off';
17
- this.element.ariaPressed = 'false';
18
- }
3
+ static name = "toggle-group";
4
+ // values
5
+ static values = {
6
+ isOn: Boolean,
7
+ };
8
+ toggle() {
9
+ this.isOnValue = !this.isOnValue;
10
+ }
11
+ isOnValueChanged(isOn) {
12
+ if (isOn) {
13
+ this.element.dataset.state = "on";
14
+ this.element.ariaPressed = "true";
15
+ } else {
16
+ this.element.dataset.state = "off";
17
+ this.element.ariaPressed = "false";
19
18
  }
19
+ }
20
20
  };
21
21
  export { ToggleController };