rails-active-ui 0.1.0

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 (167) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +6 -0
  3. data/app/assets/stylesheets.css +73555 -0
  4. data/app/components/accordion_component.rb +34 -0
  5. data/app/components/ad_component.rb +28 -0
  6. data/app/components/api_component.rb +24 -0
  7. data/app/components/breadcrumb_component.rb +26 -0
  8. data/app/components/button_component.rb +49 -0
  9. data/app/components/calendar_component.rb +34 -0
  10. data/app/components/card_component.rb +56 -0
  11. data/app/components/checkbox_component.rb +41 -0
  12. data/app/components/column_component.rb +62 -0
  13. data/app/components/comment_component.rb +45 -0
  14. data/app/components/concerns/alignable.rb +21 -0
  15. data/app/components/concerns/attachable.rb +16 -0
  16. data/app/components/concerns/orientable.rb +21 -0
  17. data/app/components/concerns/positionable.rb +21 -0
  18. data/app/components/concerns/sizeable.rb +18 -0
  19. data/app/components/container_component.rb +23 -0
  20. data/app/components/dimmer_component.rb +30 -0
  21. data/app/components/divider_component.rb +30 -0
  22. data/app/components/dropdown_component.rb +63 -0
  23. data/app/components/embed_component.rb +32 -0
  24. data/app/components/emoji_component.rb +15 -0
  25. data/app/components/feed_component.rb +22 -0
  26. data/app/components/flag_component.rb +15 -0
  27. data/app/components/flyout_component.rb +41 -0
  28. data/app/components/form_component.rb +39 -0
  29. data/app/components/grid_component.rb +85 -0
  30. data/app/components/h_stack_component.rb +67 -0
  31. data/app/components/header_component.rb +60 -0
  32. data/app/components/icon_component.rb +41 -0
  33. data/app/components/image_component.rb +46 -0
  34. data/app/components/input_component.rb +52 -0
  35. data/app/components/item_component.rb +39 -0
  36. data/app/components/item_group_component.rb +30 -0
  37. data/app/components/label_component.rb +49 -0
  38. data/app/components/link_component.rb +23 -0
  39. data/app/components/list_component.rb +39 -0
  40. data/app/components/loader_component.rb +33 -0
  41. data/app/components/menu_component.rb +64 -0
  42. data/app/components/menu_item_component.rb +52 -0
  43. data/app/components/message_component.rb +54 -0
  44. data/app/components/modal_component.rb +50 -0
  45. data/app/components/nag_component.rb +25 -0
  46. data/app/components/overlay_component.rb +16 -0
  47. data/app/components/placeholder_component.rb +39 -0
  48. data/app/components/popup_component.rb +31 -0
  49. data/app/components/progress_component.rb +48 -0
  50. data/app/components/pusher_component.rb +18 -0
  51. data/app/components/rail_component.rb +31 -0
  52. data/app/components/rating_component.rb +41 -0
  53. data/app/components/reset_component.rb +12 -0
  54. data/app/components/reveal_component.rb +39 -0
  55. data/app/components/row_component.rb +39 -0
  56. data/app/components/search_component.rb +44 -0
  57. data/app/components/segment_component.rb +57 -0
  58. data/app/components/segment_group_component.rb +36 -0
  59. data/app/components/shape_component.rb +25 -0
  60. data/app/components/sidebar_component.rb +33 -0
  61. data/app/components/site_component.rb +12 -0
  62. data/app/components/slider_component.rb +46 -0
  63. data/app/components/state_component.rb +25 -0
  64. data/app/components/statistic_component.rb +43 -0
  65. data/app/components/step_component.rb +56 -0
  66. data/app/components/step_group_component.rb +38 -0
  67. data/app/components/sticky_component.rb +22 -0
  68. data/app/components/sub_header_component.rb +15 -0
  69. data/app/components/sub_menu_component.rb +24 -0
  70. data/app/components/tab_component.rb +24 -0
  71. data/app/components/table_cell_component.rb +60 -0
  72. data/app/components/table_component.rb +160 -0
  73. data/app/components/table_row_component.rb +43 -0
  74. data/app/components/text_component.rb +73 -0
  75. data/app/components/toast_component.rb +36 -0
  76. data/app/components/transition_component.rb +32 -0
  77. data/app/components/v_stack_component.rb +31 -0
  78. data/app/components/visibility_component.rb +22 -0
  79. data/app/helpers/component_helper.rb +109 -0
  80. data/app/helpers/fui_helper.rb +53 -0
  81. data/app/javascript/accordion.js +547 -0
  82. data/app/javascript/accordion.min.js +11 -0
  83. data/app/javascript/api.js +1112 -0
  84. data/app/javascript/api.min.js +11 -0
  85. data/app/javascript/calendar.js +1960 -0
  86. data/app/javascript/calendar.min.js +11 -0
  87. data/app/javascript/checkbox.js +819 -0
  88. data/app/javascript/checkbox.min.js +11 -0
  89. data/app/javascript/dimmer.js +686 -0
  90. data/app/javascript/dimmer.min.js +11 -0
  91. data/app/javascript/dropdown.js +4019 -0
  92. data/app/javascript/dropdown.min.js +11 -0
  93. data/app/javascript/embed.js +646 -0
  94. data/app/javascript/embed.min.js +11 -0
  95. data/app/javascript/flyout.js +1405 -0
  96. data/app/javascript/flyout.min.js +11 -0
  97. data/app/javascript/form.js +2070 -0
  98. data/app/javascript/form.min.js +11 -0
  99. data/app/javascript/jquery.js +10716 -0
  100. data/app/javascript/jquery.min.js +2 -0
  101. data/app/javascript/modal.js +1507 -0
  102. data/app/javascript/modal.min.js +11 -0
  103. data/app/javascript/nag.js +522 -0
  104. data/app/javascript/nag.min.js +11 -0
  105. data/app/javascript/popup.js +1457 -0
  106. data/app/javascript/popup.min.js +11 -0
  107. data/app/javascript/progress.js +922 -0
  108. data/app/javascript/progress.min.js +11 -0
  109. data/app/javascript/rating.js +496 -0
  110. data/app/javascript/rating.min.js +11 -0
  111. data/app/javascript/search.js +1519 -0
  112. data/app/javascript/search.min.js +11 -0
  113. data/app/javascript/shape.js +721 -0
  114. data/app/javascript/shape.min.js +11 -0
  115. data/app/javascript/sidebar.js +952 -0
  116. data/app/javascript/sidebar.min.js +11 -0
  117. data/app/javascript/site.js +415 -0
  118. data/app/javascript/site.min.js +11 -0
  119. data/app/javascript/slider.js +1449 -0
  120. data/app/javascript/slider.min.js +11 -0
  121. data/app/javascript/state.js +653 -0
  122. data/app/javascript/state.min.js +11 -0
  123. data/app/javascript/sticky.js +852 -0
  124. data/app/javascript/sticky.min.js +11 -0
  125. data/app/javascript/tab.js +867 -0
  126. data/app/javascript/tab.min.js +11 -0
  127. data/app/javascript/toast.js +916 -0
  128. data/app/javascript/toast.min.js +11 -0
  129. data/app/javascript/transition.js +955 -0
  130. data/app/javascript/transition.min.js +11 -0
  131. data/app/javascript/ui/controllers/fui_accordion_controller.js +45 -0
  132. data/app/javascript/ui/controllers/fui_api_controller.js +80 -0
  133. data/app/javascript/ui/controllers/fui_calendar_controller.js +66 -0
  134. data/app/javascript/ui/controllers/fui_checkbox_controller.js +48 -0
  135. data/app/javascript/ui/controllers/fui_dimmer_controller.js +45 -0
  136. data/app/javascript/ui/controllers/fui_dropdown_controller.js +68 -0
  137. data/app/javascript/ui/controllers/fui_embed_controller.js +49 -0
  138. data/app/javascript/ui/controllers/fui_flyout_controller.js +49 -0
  139. data/app/javascript/ui/controllers/fui_form_controller.js +62 -0
  140. data/app/javascript/ui/controllers/fui_modal_controller.js +61 -0
  141. data/app/javascript/ui/controllers/fui_nag_controller.js +52 -0
  142. data/app/javascript/ui/controllers/fui_popup_controller.js +58 -0
  143. data/app/javascript/ui/controllers/fui_progress_controller.js +60 -0
  144. data/app/javascript/ui/controllers/fui_rating_controller.js +49 -0
  145. data/app/javascript/ui/controllers/fui_search_controller.js +76 -0
  146. data/app/javascript/ui/controllers/fui_shape_controller.js +45 -0
  147. data/app/javascript/ui/controllers/fui_sidebar_controller.js +48 -0
  148. data/app/javascript/ui/controllers/fui_site_controller.js +29 -0
  149. data/app/javascript/ui/controllers/fui_slider_controller.js +53 -0
  150. data/app/javascript/ui/controllers/fui_state_controller.js +63 -0
  151. data/app/javascript/ui/controllers/fui_sticky_controller.js +50 -0
  152. data/app/javascript/ui/controllers/fui_tab_controller.js +57 -0
  153. data/app/javascript/ui/controllers/fui_toast_controller.js +60 -0
  154. data/app/javascript/ui/controllers/fui_transition_controller.js +60 -0
  155. data/app/javascript/ui/controllers/fui_visibility_controller.js +55 -0
  156. data/app/javascript/ui/index.js +114 -0
  157. data/app/javascript/visibility.js +1196 -0
  158. data/app/javascript/visibility.min.js +11 -0
  159. data/app/lib/component.rb +63 -0
  160. data/config/importmap.rb +27 -0
  161. data/config/initializers/ruby_template_handler.rb +31 -0
  162. data/config/routes.rb +2 -0
  163. data/lib/tasks/ui_tasks.rake +4 -0
  164. data/lib/ui/engine.rb +27 -0
  165. data/lib/ui/version.rb +3 -0
  166. data/lib/ui.rb +6 -0
  167. metadata +220 -0
@@ -0,0 +1,58 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Popup — tooltips and popup content.
4
+ // Bridges: $.fn.popup
5
+ //
6
+ // Usage:
7
+ // <span data-controller="fui-popup"
8
+ // data-fui-popup-content-value="Tooltip text"
9
+ // data-fui-popup-position-value="top center">
10
+ // Hover me
11
+ // </span>
12
+ //
13
+ export default class extends Controller {
14
+ static values = {
15
+ content: { type: String, default: "" },
16
+ title: { type: String, default: "" },
17
+ html: { type: String, default: "" },
18
+ position: { type: String, default: "top center" },
19
+ on: { type: String, default: "hover" },
20
+ hoverable: { type: Boolean, default: false },
21
+ closable: { type: Boolean, default: true },
22
+ variation: { type: String, default: "" },
23
+ }
24
+
25
+ connect() {
26
+ $(this.element).popup(this._options())
27
+ }
28
+
29
+ disconnect() {
30
+ $(this.element).popup("destroy")
31
+ }
32
+
33
+ show() { $(this.element).popup("show") }
34
+ hide() { $(this.element).popup("hide") }
35
+ toggle() { $(this.element).popup("toggle") }
36
+
37
+ // -- Private --
38
+
39
+ _options() {
40
+ const opts = {
41
+ position: this.positionValue,
42
+ on: this.onValue,
43
+ hoverable: this.hoverableValue,
44
+ closable: this.closableValue,
45
+ variation: this.variationValue || false,
46
+ onShow: () => { this.dispatch("show") },
47
+ onVisible: () => { this.dispatch("visible") },
48
+ onHide: () => { this.dispatch("hide") },
49
+ onHidden: () => { this.dispatch("hidden") },
50
+ }
51
+
52
+ if (this.contentValue) opts.content = this.contentValue
53
+ if (this.titleValue) opts.title = this.titleValue
54
+ if (this.htmlValue) opts.html = this.htmlValue
55
+
56
+ return opts
57
+ }
58
+ }
@@ -0,0 +1,60 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Progress — progress bars with labels.
4
+ // Bridges: $.fn.progress
5
+ //
6
+ // Usage:
7
+ // <div class="ui progress" data-controller="fui-progress"
8
+ // data-percent="45">
9
+ // <div class="bar">
10
+ // <div class="progress"></div>
11
+ // </div>
12
+ // </div>
13
+ //
14
+ export default class extends Controller {
15
+ static values = {
16
+ percent: { type: Number, default: 0 },
17
+ total: { type: Number, default: 0 },
18
+ value: { type: Number, default: 0 },
19
+ autoSuccess: { type: Boolean, default: true },
20
+ showActivity: { type: Boolean, default: true },
21
+ label: { type: String, default: "percent" },
22
+ precision: { type: Number, default: 0 },
23
+ }
24
+
25
+ connect() {
26
+ $(this.element).progress(this._options())
27
+ }
28
+
29
+ disconnect() {
30
+ $(this.element).progress("destroy")
31
+ }
32
+
33
+ setPercent(pct) { $(this.element).progress("set percent", pct) }
34
+ setValue(val) { $(this.element).progress("set progress", val) }
35
+ increment(amt) { $(this.element).progress("increment", amt) }
36
+ decrement(amt) { $(this.element).progress("decrement", amt) }
37
+ complete() { $(this.element).progress("complete") }
38
+ reset() { $(this.element).progress("reset") }
39
+
40
+ // -- Private --
41
+
42
+ _options() {
43
+ const opts = {
44
+ autoSuccess: this.autoSuccessValue,
45
+ showActivity: this.showActivityValue,
46
+ label: this.labelValue,
47
+ precision: this.precisionValue,
48
+ onChange: (percent, value, total) => {
49
+ this.dispatch("change", { detail: { percent, value, total } })
50
+ },
51
+ onSuccess: (total) => { this.dispatch("success", { detail: { total } }) },
52
+ }
53
+
54
+ if (this.totalValue > 0) opts.total = this.totalValue
55
+ if (this.valueValue > 0) opts.value = this.valueValue
56
+ if (this.percentValue > 0) opts.percent = this.percentValue
57
+
58
+ return opts
59
+ }
60
+ }
@@ -0,0 +1,49 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Rating — star/heart rating widget.
4
+ // Bridges: $.fn.rating
5
+ //
6
+ // Usage:
7
+ // <div class="ui star rating" data-controller="fui-rating"
8
+ // data-fui-rating-max-rating-value="5"
9
+ // data-fui-rating-initial-rating-value="3">
10
+ // </div>
11
+ //
12
+ export default class extends Controller {
13
+ static values = {
14
+ maxRating: { type: Number, default: 5 },
15
+ initialRating: { type: Number, default: 0 },
16
+ interactive: { type: Boolean, default: true },
17
+ clearable: { type: Boolean, default: false },
18
+ fireOnInit: { type: Boolean, default: false },
19
+ }
20
+
21
+ connect() {
22
+ $(this.element).rating(this._options())
23
+ }
24
+
25
+ disconnect() {
26
+ $(this.element).rating("destroy")
27
+ }
28
+
29
+ getRating() { return $(this.element).rating("get rating") }
30
+ setRating(rating) { $(this.element).rating("set rating", rating) }
31
+ clearRating() { $(this.element).rating("clear rating") }
32
+ enable() { $(this.element).rating("enable") }
33
+ disable() { $(this.element).rating("disable") }
34
+
35
+ // -- Private --
36
+
37
+ _options() {
38
+ return {
39
+ maxRating: this.maxRatingValue,
40
+ initialRating: this.initialRatingValue,
41
+ interactive: this.interactiveValue,
42
+ clearable: this.clearableValue,
43
+ fireOnInit: this.fireOnInitValue,
44
+ onRate: (rating) => {
45
+ this.dispatch("rate", { detail: { rating } })
46
+ },
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,76 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Search — search with local or remote data sources.
4
+ // Bridges: $.fn.search
5
+ //
6
+ // Usage:
7
+ // <div class="ui search" data-controller="fui-search">
8
+ // <div class="ui icon input">
9
+ // <input class="prompt" type="text">
10
+ // <i class="search icon"></i>
11
+ // </div>
12
+ // <div class="results"></div>
13
+ // </div>
14
+ //
15
+ export default class extends Controller {
16
+ static values = {
17
+ minCharacters: { type: Number, default: 1 },
18
+ searchDelay: { type: Number, default: 200 },
19
+ maxResults: { type: Number, default: 7 },
20
+ showNoResults: { type: Boolean, default: true },
21
+ url: { type: String, default: "" },
22
+ searchFields: { type: Array, default: ["title", "description"] },
23
+ source: { type: Array, default: [] },
24
+ noResultsMessage: { type: String, default: "No results found." },
25
+ apiSettings: { type: String, default: "" },
26
+ }
27
+
28
+ connect() {
29
+ $(this.element).search(this._options())
30
+ }
31
+
32
+ disconnect() {
33
+ $(this.element).search("destroy")
34
+ }
35
+
36
+ query() { $(this.element).search("query") }
37
+ showResults() { $(this.element).search("show results") }
38
+ hideResults() { $(this.element).search("hide results") }
39
+ getValue() { return $(this.element).search("get value") }
40
+
41
+ // -- Private --
42
+
43
+ _options() {
44
+ const opts = {
45
+ minCharacters: this.minCharactersValue,
46
+ searchDelay: this.searchDelayValue,
47
+ maxResults: this.maxResultsValue,
48
+ showNoResults: this.showNoResultsValue,
49
+ searchFields: this.searchFieldsValue,
50
+ error: {
51
+ noResults: this.noResultsMessageValue,
52
+ },
53
+ onSelect: (result, response) => {
54
+ this.dispatch("select", { detail: { result, response } })
55
+ },
56
+ onResults: (response) => {
57
+ this.dispatch("results", { detail: { response } })
58
+ },
59
+ onResultsOpen: () => { this.dispatch("resultsOpen") },
60
+ onResultsClose: () => { this.dispatch("resultsClose") },
61
+ }
62
+
63
+ if (this.urlValue) {
64
+ opts.apiSettings = { url: this.urlValue }
65
+ } else if (this.apiSettingsValue) {
66
+ try { opts.apiSettings = JSON.parse(this.apiSettingsValue) }
67
+ catch (e) { /* invalid JSON */ }
68
+ }
69
+
70
+ if (this.sourceValue.length > 0) {
71
+ opts.source = this.sourceValue
72
+ }
73
+
74
+ return opts
75
+ }
76
+ }
@@ -0,0 +1,45 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Shape — 3D CSS shape transformations.
4
+ // Bridges: $.fn.shape
5
+ //
6
+ // Usage:
7
+ // <div class="ui shape" data-controller="fui-shape">
8
+ // <div class="sides">
9
+ // <div class="side active">Side 1</div>
10
+ // <div class="side">Side 2</div>
11
+ // </div>
12
+ // </div>
13
+ //
14
+ export default class extends Controller {
15
+ static values = {
16
+ duration: { type: Number, default: 700 },
17
+ allowRepeats: { type: Boolean, default: false },
18
+ }
19
+
20
+ connect() {
21
+ $(this.element).shape(this._options())
22
+ }
23
+
24
+ disconnect() {
25
+ $(this.element).shape("destroy")
26
+ }
27
+
28
+ flipUp() { $(this.element).shape("flip up") }
29
+ flipDown() { $(this.element).shape("flip down") }
30
+ flipLeft() { $(this.element).shape("flip left") }
31
+ flipRight() { $(this.element).shape("flip right") }
32
+ flipOver() { $(this.element).shape("flip over") }
33
+ flipBack() { $(this.element).shape("flip back") }
34
+
35
+ // -- Private --
36
+
37
+ _options() {
38
+ return {
39
+ duration: this.durationValue,
40
+ allowRepeats: this.allowRepeatsValue,
41
+ onBeforeChange: () => { this.dispatch("beforeChange") },
42
+ onChange: () => { this.dispatch("change") },
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,48 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Sidebar — slide-out navigation panel.
4
+ // Bridges: $.fn.sidebar
5
+ //
6
+ // Usage:
7
+ // <div class="ui sidebar" data-controller="fui-sidebar">
8
+ // <a class="item">Menu Item 1</a>
9
+ // <a class="item">Menu Item 2</a>
10
+ // </div>
11
+ // <div class="pusher">Main content</div>
12
+ //
13
+ export default class extends Controller {
14
+ static values = {
15
+ transition: { type: String, default: "overlay" },
16
+ closable: { type: Boolean, default: true },
17
+ dimPage: { type: Boolean, default: true },
18
+ scrollLock: { type: Boolean, default: false },
19
+ }
20
+
21
+ connect() {
22
+ $(this.element).sidebar(this._options())
23
+ }
24
+
25
+ disconnect() {
26
+ $(this.element).sidebar("destroy")
27
+ }
28
+
29
+ show() { $(this.element).sidebar("show") }
30
+ hide() { $(this.element).sidebar("hide") }
31
+ toggle() { $(this.element).sidebar("toggle") }
32
+
33
+ // -- Private --
34
+
35
+ _options() {
36
+ return {
37
+ transition: this.transitionValue,
38
+ closable: this.closableValue,
39
+ dimPage: this.dimPageValue,
40
+ scrollLock: this.scrollLockValue,
41
+ onShow: () => { this.dispatch("show") },
42
+ onVisible: () => { this.dispatch("visible") },
43
+ onHide: () => { this.dispatch("hide") },
44
+ onHidden: () => { this.dispatch("hidden") },
45
+ onChange: () => { this.dispatch("change") },
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,29 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Site — base utility module.
4
+ // Bridges: $.site
5
+ //
6
+ // Usage:
7
+ // <body data-controller="fui-site">
8
+ //
9
+ export default class extends Controller {
10
+ static values = {
11
+ debug: { type: Boolean, default: false },
12
+ }
13
+
14
+ connect() {
15
+ $(this.element).site(this._options())
16
+ }
17
+
18
+ disconnect() {
19
+ // $.site has no destroy method
20
+ }
21
+
22
+ // -- Private --
23
+
24
+ _options() {
25
+ return {
26
+ debug: this.debugValue,
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,53 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Slider — range slider control.
4
+ // Bridges: $.fn.slider
5
+ //
6
+ // Usage:
7
+ // <div class="ui slider" data-controller="fui-slider"
8
+ // data-fui-slider-min-value="0"
9
+ // data-fui-slider-max-value="100"
10
+ // data-fui-slider-step-value="1"
11
+ // data-fui-slider-start-value="50">
12
+ // </div>
13
+ //
14
+ export default class extends Controller {
15
+ static values = {
16
+ min: { type: Number, default: 0 },
17
+ max: { type: Number, default: 100 },
18
+ step: { type: Number, default: 1 },
19
+ start: { type: Number, default: 0 },
20
+ smooth: { type: Boolean, default: false },
21
+ vertical: { type: Boolean, default: false },
22
+ }
23
+
24
+ connect() {
25
+ $(this.element).slider(this._options())
26
+ }
27
+
28
+ disconnect() {
29
+ $(this.element).slider("destroy")
30
+ }
31
+
32
+ getValue() { return $(this.element).slider("get value") }
33
+ setValue(val) { $(this.element).slider("set value", val) }
34
+
35
+ // -- Private --
36
+
37
+ _options() {
38
+ return {
39
+ min: this.minValue,
40
+ max: this.maxValue,
41
+ step: this.stepValue,
42
+ start: this.startValue,
43
+ smooth: this.smoothValue,
44
+ vertical: this.verticalValue,
45
+ onChange: (value) => {
46
+ this.dispatch("change", { detail: { value } })
47
+ },
48
+ onMove: (value) => {
49
+ this.dispatch("move", { detail: { value } })
50
+ },
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,63 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI State — UI state management for elements.
4
+ // Bridges: $.fn.state
5
+ //
6
+ // Usage:
7
+ // <button data-controller="fui-state"
8
+ // data-fui-state-active-text-value="Following"
9
+ // data-fui-state-inactive-text-value="Follow"
10
+ // data-action="click->fui-state#toggle">
11
+ // Follow
12
+ // </button>
13
+ //
14
+ export default class extends Controller {
15
+ static values = {
16
+ activeText: { type: String, default: "" },
17
+ inactiveText: { type: String, default: "" },
18
+ activateText: { type: String, default: "" },
19
+ deactivateText: { type: String, default: "" },
20
+ flashText: { type: String, default: "" },
21
+ flashDuration: { type: Number, default: 1000 },
22
+ }
23
+
24
+ connect() {
25
+ $(this.element).state(this._options())
26
+ }
27
+
28
+ disconnect() {
29
+ $(this.element).state("destroy")
30
+ }
31
+
32
+ toggle() { $(this.element).state("toggle") }
33
+ activate() { $(this.element).state("activate") }
34
+ deactivate() { $(this.element).state("deactivate") }
35
+ enable() { $(this.element).state("enable") }
36
+ disable() { $(this.element).state("disable") }
37
+
38
+ flash(text) {
39
+ $(this.element).state("flash text", text || this.flashTextValue)
40
+ }
41
+
42
+ // -- Private --
43
+
44
+ _options() {
45
+ const opts = {}
46
+
47
+ const text = {}
48
+ if (this.activeTextValue) text.active = this.activeTextValue
49
+ if (this.inactiveTextValue) text.inactive = this.inactiveTextValue
50
+ if (this.activateTextValue) text.activate = this.activateTextValue
51
+ if (this.deactivateTextValue) text.deactivate = this.deactivateTextValue
52
+ if (this.flashTextValue) text.flash = this.flashTextValue
53
+ if (Object.keys(text).length > 0) opts.text = text
54
+
55
+ if (this.flashDurationValue !== 1000) opts.flashDuration = this.flashDurationValue
56
+
57
+ opts.onChange = () => { this.dispatch("change") }
58
+ opts.onActivate = () => { this.dispatch("activate") }
59
+ opts.onDeactivate = () => { this.dispatch("deactivate") }
60
+
61
+ return opts
62
+ }
63
+ }
@@ -0,0 +1,50 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Sticky — stick elements to viewport on scroll.
4
+ // Bridges: $.fn.sticky
5
+ //
6
+ // Usage:
7
+ // <div data-controller="fui-sticky"
8
+ // data-fui-sticky-offset-value="14">
9
+ // This content becomes sticky on scroll
10
+ // </div>
11
+ //
12
+ export default class extends Controller {
13
+ static values = {
14
+ offset: { type: Number, default: 0 },
15
+ bottomOffset: { type: Number, default: 0 },
16
+ pushing: { type: Boolean, default: false },
17
+ jitter: { type: Number, default: 5 },
18
+ context: { type: String, default: "" },
19
+ }
20
+
21
+ connect() {
22
+ $(this.element).sticky(this._options())
23
+ }
24
+
25
+ disconnect() {
26
+ $(this.element).sticky("destroy")
27
+ }
28
+
29
+ refresh() { $(this.element).sticky("refresh") }
30
+ reset() { $(this.element).sticky("reset") }
31
+
32
+ // -- Private --
33
+
34
+ _options() {
35
+ const opts = {
36
+ offset: this.offsetValue,
37
+ bottomOffset: this.bottomOffsetValue,
38
+ pushing: this.pushingValue,
39
+ jitter: this.jitterValue,
40
+ onStick: () => { this.dispatch("stick") },
41
+ onUnstick: () => { this.dispatch("unstick") },
42
+ onTop: () => { this.dispatch("top") },
43
+ onBottom: () => { this.dispatch("bottom") },
44
+ }
45
+
46
+ if (this.contextValue) opts.context = this.contextValue
47
+
48
+ return opts
49
+ }
50
+ }
@@ -0,0 +1,57 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Tab — tab navigation with content panels.
4
+ // Bridges: $.fn.tab
5
+ //
6
+ // Usage:
7
+ // <div data-controller="fui-tab">
8
+ // <div class="ui tabular menu">
9
+ // <a class="item active" data-tab="first">First</a>
10
+ // <a class="item" data-tab="second">Second</a>
11
+ // </div>
12
+ // <div class="ui tab segment active" data-tab="first">
13
+ // First tab content
14
+ // </div>
15
+ // <div class="ui tab segment" data-tab="second">
16
+ // Second tab content
17
+ // </div>
18
+ // </div>
19
+ //
20
+ export default class extends Controller {
21
+ static values = {
22
+ history: { type: Boolean, default: false },
23
+ historyType: { type: String, default: "hash" },
24
+ }
25
+
26
+ connect() {
27
+ // Fomantic tab needs to be initialized on the menu items, not the container.
28
+ // Find tabular menu items within this controller's element.
29
+ const $items = $(this.element).find(".item[data-tab]")
30
+ if ($items.length > 0) {
31
+ $items.tab(this._options())
32
+ }
33
+ }
34
+
35
+ disconnect() {
36
+ const $items = $(this.element).find(".item[data-tab]")
37
+ if ($items.length > 0) {
38
+ $items.tab("destroy")
39
+ }
40
+ }
41
+
42
+ changeTab(tabPath) {
43
+ $(this.element).find(".item[data-tab]").tab("change tab", tabPath)
44
+ }
45
+
46
+ // -- Private --
47
+
48
+ _options() {
49
+ return {
50
+ history: this.historyValue,
51
+ historyType: this.historyTypeValue,
52
+ onVisible: (tabPath) => {
53
+ this.dispatch("change", { detail: { tab: tabPath } })
54
+ },
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,60 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Fomantic-UI Toast — toast notifications.
4
+ // Bridges: $.fn.toast
5
+ //
6
+ // Usage:
7
+ // <div data-controller="fui-toast"
8
+ // data-fui-toast-title-value="Success"
9
+ // data-fui-toast-message-value="Item saved."
10
+ // data-fui-toast-class-value="success">
11
+ // </div>
12
+ //
13
+ export default class extends Controller {
14
+ static values = {
15
+ position: { type: String, default: "top right" },
16
+ displayTime: { type: Number, default: 3000 },
17
+ closeOnClick: { type: Boolean, default: true },
18
+ closeIcon: { type: Boolean, default: false },
19
+ class: { type: String, default: "neutral" },
20
+ title: { type: String, default: "" },
21
+ message: { type: String, default: "" },
22
+ showProgress: { type: Boolean, default: false },
23
+ progressUp: { type: Boolean, default: false },
24
+ pauseOnHover: { type: Boolean, default: true },
25
+ newestOnTop: { type: Boolean, default: false },
26
+ compact: { type: Boolean, default: true },
27
+ }
28
+
29
+ connect() {
30
+ // Toast is typically triggered imperatively, not on connect.
31
+ // The element serves as a configuration holder.
32
+ }
33
+
34
+ disconnect() {}
35
+
36
+ show() {
37
+ $("body").toast(this._options())
38
+ }
39
+
40
+ // -- Private --
41
+
42
+ _options() {
43
+ return {
44
+ position: this.positionValue,
45
+ displayTime: this.displayTimeValue,
46
+ closeOnClick: this.closeOnClickValue,
47
+ closeIcon: this.closeIconValue,
48
+ class: this.classValue,
49
+ title: this.titleValue,
50
+ message: this.messageValue,
51
+ showProgress: this.showProgressValue ? (this.progressUpValue ? "top" : "bottom") : false,
52
+ pauseOnHover: this.pauseOnHoverValue,
53
+ newestOnTop: this.newestOnTopValue,
54
+ compact: this.compactValue,
55
+ onShow: () => { this.dispatch("show") },
56
+ onHide: () => { this.dispatch("hide") },
57
+ onRemove: () => { this.dispatch("remove") },
58
+ }
59
+ }
60
+ }