headmin 0.3.2 → 0.4.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 (186) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +27 -0
  3. data/.gitignore +14 -0
  4. data/.nvmrc +1 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +24 -0
  7. data/Gemfile +8 -5
  8. data/Gemfile.lock +197 -25
  9. data/README.md +9 -1
  10. data/Rakefile +1 -7
  11. data/app/assets/images/document.docx +0 -0
  12. data/app/assets/images/document.pdf +0 -0
  13. data/app/assets/images/image.jpg +0 -0
  14. data/app/assets/images/spreadsheet.xls +0 -0
  15. data/app/assets/images/video.mp4 +0 -0
  16. data/app/assets/javascripts/headmin/config/i18n.js +9 -9
  17. data/app/assets/javascripts/headmin/controllers/autocomplete_controller.js +255 -0
  18. data/app/assets/javascripts/headmin/controllers/blocks_controller.js +74 -79
  19. data/app/assets/javascripts/headmin/controllers/date_range_controller.js +24 -24
  20. data/app/assets/javascripts/headmin/controllers/dropzone_controller.js +23 -25
  21. data/app/assets/javascripts/headmin/controllers/file_preview_controller.js +237 -237
  22. data/app/assets/javascripts/headmin/controllers/filter_controller.js +44 -44
  23. data/app/assets/javascripts/headmin/controllers/filters_controller.js +57 -61
  24. data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +29 -29
  25. data/app/assets/javascripts/headmin/controllers/hello_controller.js +3 -3
  26. data/app/assets/javascripts/headmin/controllers/notification_controller.js +7 -6
  27. data/app/assets/javascripts/headmin/controllers/popup_controller.js +51 -52
  28. data/app/assets/javascripts/headmin/controllers/redactorx_controller.js +36 -9
  29. data/app/assets/javascripts/headmin/controllers/repeater_controller.js +122 -125
  30. data/app/assets/javascripts/headmin/controllers/select_controller.js +40 -39
  31. data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +88 -77
  32. data/app/assets/javascripts/headmin/controllers/table_controller.js +103 -89
  33. data/app/assets/javascripts/headmin/index.js +38 -39
  34. data/app/assets/javascripts/headmin.js +287 -732
  35. data/app/assets/stylesheets/headmin/forms/autocomplete.scss +21 -0
  36. data/app/assets/stylesheets/headmin/forms/file.scss +46 -0
  37. data/app/assets/stylesheets/headmin/forms/repeater.scss +62 -0
  38. data/app/assets/stylesheets/headmin/forms/search.scss +12 -0
  39. data/app/assets/stylesheets/headmin/forms.scss +11 -0
  40. data/app/assets/stylesheets/headmin/general.scss +5 -0
  41. data/app/assets/stylesheets/headmin/overrides/bootstrap.scss +5 -3
  42. data/app/assets/stylesheets/headmin/overrides/redactorx.scss +74 -0
  43. data/app/assets/stylesheets/headmin/popup.scss +1 -0
  44. data/app/assets/stylesheets/headmin/syntax.scss +36 -349
  45. data/app/assets/stylesheets/headmin/table.scss +1 -1
  46. data/app/assets/stylesheets/headmin/utilities/buttons.scss +19 -0
  47. data/app/assets/stylesheets/headmin/utilities/dropzone.scss +72 -0
  48. data/app/assets/stylesheets/headmin/utilities.scss +2 -68
  49. data/app/assets/stylesheets/headmin/vendor/tom-select-bootstrap.css +1 -2
  50. data/app/assets/stylesheets/headmin.css +206 -206
  51. data/app/assets/stylesheets/headmin.scss +1 -1
  52. data/app/controllers/concerns/headmin/authentication.rb +1 -1
  53. data/app/controllers/concerns/headmin/searchable.rb +1 -1
  54. data/app/controllers/concerns/headmin/sortable.rb +7 -7
  55. data/app/helpers/headmin/admin_helper.rb +1 -2
  56. data/app/helpers/headmin/bootstrap_helper.rb +2 -24
  57. data/app/helpers/headmin/filter_helper.rb +1 -1
  58. data/app/helpers/headmin/form_helper.rb +5 -11
  59. data/app/helpers/headmin/notification_helper.rb +21 -21
  60. data/app/helpers/headmin/request_helper.rb +3 -3
  61. data/app/models/concerns/headmin/block.rb +1 -2
  62. data/app/models/concerns/headmin/blockable.rb +2 -2
  63. data/app/models/concerns/headmin/field.rb +2 -1
  64. data/app/models/concerns/headmin/fieldable.rb +8 -8
  65. data/app/models/concerns/headmin/form/autocompletable.rb +38 -0
  66. data/app/models/concerns/headmin/form/hintable.rb +19 -0
  67. data/app/models/concerns/headmin/form/input_groupable.rb +23 -0
  68. data/app/models/concerns/headmin/form/labelable.rb +33 -0
  69. data/app/models/concerns/headmin/form/listable.rb +28 -0
  70. data/app/models/concerns/headmin/form/placeholderable.rb +13 -0
  71. data/app/models/concerns/headmin/form/validatable.rb +40 -0
  72. data/app/models/concerns/headmin/form/wrappable.rb +21 -0
  73. data/app/models/headmin/.DS_Store +0 -0
  74. data/app/models/headmin/blocks_view.rb +15 -0
  75. data/app/models/headmin/form/blocks_view.rb +29 -0
  76. data/app/models/headmin/form/checkbox_view.rb +52 -0
  77. data/app/models/headmin/form/date_range_view.rb +25 -0
  78. data/app/models/headmin/form/date_view.rb +45 -0
  79. data/app/models/headmin/form/email_view.rb +48 -0
  80. data/app/models/headmin/form/file_view.rb +116 -0
  81. data/app/models/headmin/form/flatpickr_range_view.rb +102 -0
  82. data/app/models/headmin/form/flatpickr_view.rb +37 -0
  83. data/app/models/headmin/form/hidden_view.rb +10 -0
  84. data/app/models/headmin/form/hint_view.rb +6 -0
  85. data/app/models/headmin/form/input_group_view.rb +19 -0
  86. data/app/models/headmin/form/label_view.rb +24 -0
  87. data/app/models/headmin/form/number_view.rb +49 -0
  88. data/app/models/headmin/form/password_view.rb +44 -0
  89. data/app/models/headmin/form/redactorx_view.rb +59 -0
  90. data/app/models/headmin/form/search_view.rb +48 -0
  91. data/app/models/headmin/form/select_view.rb +62 -0
  92. data/app/models/headmin/form/switch_view.rb +23 -0
  93. data/app/models/headmin/form/text_view.rb +48 -0
  94. data/app/models/headmin/form/textarea_view.rb +44 -0
  95. data/app/models/headmin/form/url_view.rb +48 -0
  96. data/app/models/headmin/form/wrapper_view.rb +19 -0
  97. data/app/models/headmin/form/wysiwyg_view.rb +17 -0
  98. data/app/models/headmin/thumbnail_view.rb +66 -0
  99. data/app/models/view_model.rb +58 -0
  100. data/app/views/headmin/_blocks.html.erb +13 -9
  101. data/app/views/headmin/_heading.html.erb +7 -1
  102. data/app/views/headmin/_thumbnail.html.erb +5 -39
  103. data/app/views/headmin/dropdown/_item.html.erb +1 -1
  104. data/app/views/headmin/forms/_autocomplete.html.erb +11 -0
  105. data/app/views/headmin/forms/_blocks.html.erb +16 -17
  106. data/app/views/headmin/forms/_checkbox.html.erb +24 -29
  107. data/app/views/headmin/forms/_datalist.html.erb +3 -0
  108. data/app/views/headmin/forms/_date.html.erb +24 -24
  109. data/app/views/headmin/forms/_date_range.html.erb +19 -21
  110. data/app/views/headmin/forms/_email.html.erb +27 -32
  111. data/app/views/headmin/forms/_errors.html.erb +2 -3
  112. data/app/views/headmin/forms/_file.html.erb +84 -181
  113. data/app/views/headmin/forms/_flatpickr.html.erb +19 -20
  114. data/app/views/headmin/forms/_flatpickr_range.html.erb +28 -37
  115. data/app/views/headmin/forms/_hidden.html.erb +9 -10
  116. data/app/views/headmin/forms/_hint.html.erb +16 -0
  117. data/app/views/headmin/forms/_input_group.html.erb +21 -0
  118. data/app/views/headmin/forms/_label.html.erb +5 -13
  119. data/app/views/headmin/forms/_number.html.erb +23 -35
  120. data/app/views/headmin/forms/_password.html.erb +21 -30
  121. data/app/views/headmin/forms/_redactorx.html.erb +21 -40
  122. data/app/views/headmin/forms/_repeater.html.erb +55 -60
  123. data/app/views/headmin/forms/_search.html.erb +43 -0
  124. data/app/views/headmin/forms/_select.html.erb +24 -49
  125. data/app/views/headmin/forms/_switch.html.erb +29 -0
  126. data/app/views/headmin/forms/_text.html.erb +42 -96
  127. data/app/views/headmin/forms/_textarea.html.erb +21 -32
  128. data/app/views/headmin/forms/_url.html.erb +26 -31
  129. data/app/views/headmin/forms/_validation.html.erb +10 -13
  130. data/app/views/headmin/forms/_wrapper.html.erb +9 -0
  131. data/app/views/headmin/forms/_wysiwyg.html.erb +28 -0
  132. data/app/views/headmin/forms/autocomplete/_item.html.erb +3 -0
  133. data/app/views/headmin/forms/autocomplete/_list.html.erb +3 -0
  134. data/app/views/headmin/forms/fields/_group.html.erb +6 -4
  135. data/app/views/headmin/forms/repeater/_row.html.erb +4 -4
  136. data/app/views/headmin/nav/item/_devise.html.erb +1 -1
  137. data/app/views/headmin/table/_actions.html.erb +1 -1
  138. data/app/views/headmin/table/actions/_action.html.erb +2 -1
  139. data/app/views/headmin/table/actions/_delete.html.erb +1 -1
  140. data/app/views/headmin/views/devise/registrations/_edit.html.erb +2 -2
  141. data/bin/console +0 -1
  142. data/config/initializers/customize_input_error.rb +4 -4
  143. data/config/locales/headmin/forms/en.yml +0 -11
  144. data/config/locales/headmin/forms/nl.yml +0 -11
  145. data/esbuild-css.js +18 -18
  146. data/esbuild-js.js +8 -8
  147. data/headmin.gemspec +1 -3
  148. data/lib/generators/headmin/blocks_generator.rb +8 -8
  149. data/lib/generators/headmin/devise_generator.rb +4 -4
  150. data/lib/generators/headmin/fields_generator.rb +9 -9
  151. data/lib/generators/templates/controllers/auth/confirmations_controller.rb +1 -3
  152. data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +1 -3
  153. data/lib/generators/templates/controllers/auth/passwords_controller.rb +1 -3
  154. data/lib/generators/templates/controllers/auth/registrations_controller.rb +1 -3
  155. data/lib/generators/templates/controllers/auth/sessions_controller.rb +1 -3
  156. data/lib/generators/templates/controllers/auth/unlocks_controller.rb +1 -3
  157. data/lib/generators/templates/models/block.rb +1 -1
  158. data/lib/headmin/engine.rb +6 -6
  159. data/lib/headmin/version.rb +1 -3
  160. data/lib/headmin.rb +0 -2
  161. data/package-lock.json +5359 -0
  162. data/package.json +13 -7
  163. data/view_model_benchmark.rb +74 -0
  164. data/yarn-error.log +367 -0
  165. data/yarn.lock +1448 -161
  166. metadata +69 -25
  167. data/.rubocop.yml +0 -13
  168. data/app/assets/stylesheets/headmin/form.scss +0 -132
  169. data/app/assets/stylesheets/headmin/overrides/redactorx.css +0 -3
  170. data/app/helpers/headmin/documentation_helper.rb +0 -35
  171. data/app/models/headmin/documentation_renderer.rb +0 -32
  172. data/app/models/headmin/form/base.rb +0 -79
  173. data/app/models/headmin/form/text.rb +0 -53
  174. data/app/services/block_service.rb +0 -72
  175. data/app/views/headmin/_card.html.erb +0 -52
  176. data/app/views/headmin/forms/_actions.html.erb +0 -28
  177. data/app/views/headmin/forms/_base.html.erb +0 -114
  178. data/app/views/headmin/forms/_image.html.erb +0 -21
  179. data/app/views/headmin/forms/_video.html.erb +0 -21
  180. data/app/views/headmin/forms/actions/_destroy.html.erb +0 -13
  181. data/app/views/headmin/forms/actions/_save.html.erb +0 -12
  182. data/app/views/headmin/forms/actions/_view.html.erb +0 -15
  183. data/docs/blocks-and-fields.md +0 -54
  184. data/docs/blocks.md +0 -48
  185. data/docs/devise.md +0 -41
  186. data/docs/fields.md +0 -79
@@ -3096,680 +3096,6 @@ var require_tom_select_complete = __commonJS({
3096
3096
  }
3097
3097
  });
3098
3098
 
3099
- // node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js
3100
- var require_rails_ujs = __commonJS({
3101
- "node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js"(exports, module) {
3102
- (function() {
3103
- var context = this;
3104
- (function() {
3105
- (function() {
3106
- this.Rails = {
3107
- linkClickSelector: "a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]",
3108
- buttonClickSelector: {
3109
- selector: "button[data-remote]:not([form]), button[data-confirm]:not([form])",
3110
- exclude: "form button"
3111
- },
3112
- inputChangeSelector: "select[data-remote], input[data-remote], textarea[data-remote]",
3113
- formSubmitSelector: "form:not([data-turbo=true])",
3114
- formInputClickSelector: "form:not([data-turbo=true]) input[type=submit], form:not([data-turbo=true]) input[type=image], form:not([data-turbo=true]) button[type=submit], form:not([data-turbo=true]) button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])",
3115
- formDisableSelector: "input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled",
3116
- formEnableSelector: "input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled",
3117
- fileInputSelector: "input[name][type=file]:not([disabled])",
3118
- linkDisableSelector: "a[data-disable-with], a[data-disable]",
3119
- buttonDisableSelector: "button[data-remote][data-disable-with], button[data-remote][data-disable]"
3120
- };
3121
- }).call(this);
3122
- }).call(context);
3123
- var Rails3 = context.Rails;
3124
- (function() {
3125
- (function() {
3126
- var nonce;
3127
- nonce = null;
3128
- Rails3.loadCSPNonce = function() {
3129
- var ref;
3130
- return nonce = (ref = document.querySelector("meta[name=csp-nonce]")) != null ? ref.content : void 0;
3131
- };
3132
- Rails3.cspNonce = function() {
3133
- return nonce != null ? nonce : Rails3.loadCSPNonce();
3134
- };
3135
- }).call(this);
3136
- (function() {
3137
- var expando2, m;
3138
- m = Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector;
3139
- Rails3.matches = function(element, selector) {
3140
- if (selector.exclude != null) {
3141
- return m.call(element, selector.selector) && !m.call(element, selector.exclude);
3142
- } else {
3143
- return m.call(element, selector);
3144
- }
3145
- };
3146
- expando2 = "_ujsData";
3147
- Rails3.getData = function(element, key) {
3148
- var ref;
3149
- return (ref = element[expando2]) != null ? ref[key] : void 0;
3150
- };
3151
- Rails3.setData = function(element, key, value) {
3152
- if (element[expando2] == null) {
3153
- element[expando2] = {};
3154
- }
3155
- return element[expando2][key] = value;
3156
- };
3157
- Rails3.$ = function(selector) {
3158
- return Array.prototype.slice.call(document.querySelectorAll(selector));
3159
- };
3160
- }).call(this);
3161
- (function() {
3162
- var $2, csrfParam, csrfToken;
3163
- $2 = Rails3.$;
3164
- csrfToken = Rails3.csrfToken = function() {
3165
- var meta;
3166
- meta = document.querySelector("meta[name=csrf-token]");
3167
- return meta && meta.content;
3168
- };
3169
- csrfParam = Rails3.csrfParam = function() {
3170
- var meta;
3171
- meta = document.querySelector("meta[name=csrf-param]");
3172
- return meta && meta.content;
3173
- };
3174
- Rails3.CSRFProtection = function(xhr) {
3175
- var token;
3176
- token = csrfToken();
3177
- if (token != null) {
3178
- return xhr.setRequestHeader("X-CSRF-Token", token);
3179
- }
3180
- };
3181
- Rails3.refreshCSRFTokens = function() {
3182
- var param, token;
3183
- token = csrfToken();
3184
- param = csrfParam();
3185
- if (token != null && param != null) {
3186
- return $2('form input[name="' + param + '"]').forEach(function(input) {
3187
- return input.value = token;
3188
- });
3189
- }
3190
- };
3191
- }).call(this);
3192
- (function() {
3193
- var CustomEvent2, fire, matches2, preventDefault;
3194
- matches2 = Rails3.matches;
3195
- CustomEvent2 = window.CustomEvent;
3196
- if (typeof CustomEvent2 !== "function") {
3197
- CustomEvent2 = function(event, params) {
3198
- var evt;
3199
- evt = document.createEvent("CustomEvent");
3200
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
3201
- return evt;
3202
- };
3203
- CustomEvent2.prototype = window.Event.prototype;
3204
- preventDefault = CustomEvent2.prototype.preventDefault;
3205
- CustomEvent2.prototype.preventDefault = function() {
3206
- var result;
3207
- result = preventDefault.call(this);
3208
- if (this.cancelable && !this.defaultPrevented) {
3209
- Object.defineProperty(this, "defaultPrevented", {
3210
- get: function() {
3211
- return true;
3212
- }
3213
- });
3214
- }
3215
- return result;
3216
- };
3217
- }
3218
- fire = Rails3.fire = function(obj, name, data) {
3219
- var event;
3220
- event = new CustomEvent2(name, {
3221
- bubbles: true,
3222
- cancelable: true,
3223
- detail: data
3224
- });
3225
- obj.dispatchEvent(event);
3226
- return !event.defaultPrevented;
3227
- };
3228
- Rails3.stopEverything = function(e) {
3229
- fire(e.target, "ujs:everythingStopped");
3230
- e.preventDefault();
3231
- e.stopPropagation();
3232
- return e.stopImmediatePropagation();
3233
- };
3234
- Rails3.delegate = function(element, selector, eventType, handler) {
3235
- return element.addEventListener(eventType, function(e) {
3236
- var target;
3237
- target = e.target;
3238
- while (!(!(target instanceof Element) || matches2(target, selector))) {
3239
- target = target.parentNode;
3240
- }
3241
- if (target instanceof Element && handler.call(target, e) === false) {
3242
- e.preventDefault();
3243
- return e.stopPropagation();
3244
- }
3245
- });
3246
- };
3247
- }).call(this);
3248
- (function() {
3249
- var AcceptHeaders, CSRFProtection, createXHR, cspNonce, fire, prepareOptions, processResponse;
3250
- cspNonce = Rails3.cspNonce, CSRFProtection = Rails3.CSRFProtection, fire = Rails3.fire;
3251
- AcceptHeaders = {
3252
- "*": "*/*",
3253
- text: "text/plain",
3254
- html: "text/html",
3255
- xml: "application/xml, text/xml",
3256
- json: "application/json, text/javascript",
3257
- script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
3258
- };
3259
- Rails3.ajax = function(options) {
3260
- var xhr;
3261
- options = prepareOptions(options);
3262
- xhr = createXHR(options, function() {
3263
- var ref, response;
3264
- response = processResponse((ref = xhr.response) != null ? ref : xhr.responseText, xhr.getResponseHeader("Content-Type"));
3265
- if (Math.floor(xhr.status / 100) === 2) {
3266
- if (typeof options.success === "function") {
3267
- options.success(response, xhr.statusText, xhr);
3268
- }
3269
- } else {
3270
- if (typeof options.error === "function") {
3271
- options.error(response, xhr.statusText, xhr);
3272
- }
3273
- }
3274
- return typeof options.complete === "function" ? options.complete(xhr, xhr.statusText) : void 0;
3275
- });
3276
- if (options.beforeSend != null && !options.beforeSend(xhr, options)) {
3277
- return false;
3278
- }
3279
- if (xhr.readyState === XMLHttpRequest.OPENED) {
3280
- return xhr.send(options.data);
3281
- }
3282
- };
3283
- prepareOptions = function(options) {
3284
- options.url = options.url || location.href;
3285
- options.type = options.type.toUpperCase();
3286
- if (options.type === "GET" && options.data) {
3287
- if (options.url.indexOf("?") < 0) {
3288
- options.url += "?" + options.data;
3289
- } else {
3290
- options.url += "&" + options.data;
3291
- }
3292
- }
3293
- if (AcceptHeaders[options.dataType] == null) {
3294
- options.dataType = "*";
3295
- }
3296
- options.accept = AcceptHeaders[options.dataType];
3297
- if (options.dataType !== "*") {
3298
- options.accept += ", */*; q=0.01";
3299
- }
3300
- return options;
3301
- };
3302
- createXHR = function(options, done) {
3303
- var xhr;
3304
- xhr = new XMLHttpRequest();
3305
- xhr.open(options.type, options.url, true);
3306
- xhr.setRequestHeader("Accept", options.accept);
3307
- if (typeof options.data === "string") {
3308
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
3309
- }
3310
- if (!options.crossDomain) {
3311
- xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
3312
- CSRFProtection(xhr);
3313
- }
3314
- xhr.withCredentials = !!options.withCredentials;
3315
- xhr.onreadystatechange = function() {
3316
- if (xhr.readyState === XMLHttpRequest.DONE) {
3317
- return done(xhr);
3318
- }
3319
- };
3320
- return xhr;
3321
- };
3322
- processResponse = function(response, type) {
3323
- var parser, script;
3324
- if (typeof response === "string" && typeof type === "string") {
3325
- if (type.match(/\bjson\b/)) {
3326
- try {
3327
- response = JSON.parse(response);
3328
- } catch (error2) {
3329
- }
3330
- } else if (type.match(/\b(?:java|ecma)script\b/)) {
3331
- script = document.createElement("script");
3332
- script.setAttribute("nonce", cspNonce());
3333
- script.text = response;
3334
- document.head.appendChild(script).parentNode.removeChild(script);
3335
- } else if (type.match(/\b(xml|html|svg)\b/)) {
3336
- parser = new DOMParser();
3337
- type = type.replace(/;.+/, "");
3338
- try {
3339
- response = parser.parseFromString(response, type);
3340
- } catch (error2) {
3341
- }
3342
- }
3343
- }
3344
- return response;
3345
- };
3346
- Rails3.href = function(element) {
3347
- return element.href;
3348
- };
3349
- Rails3.isCrossDomain = function(url) {
3350
- var e, originAnchor, urlAnchor;
3351
- originAnchor = document.createElement("a");
3352
- originAnchor.href = location.href;
3353
- urlAnchor = document.createElement("a");
3354
- try {
3355
- urlAnchor.href = url;
3356
- return !((!urlAnchor.protocol || urlAnchor.protocol === ":") && !urlAnchor.host || originAnchor.protocol + "//" + originAnchor.host === urlAnchor.protocol + "//" + urlAnchor.host);
3357
- } catch (error2) {
3358
- e = error2;
3359
- return true;
3360
- }
3361
- };
3362
- }).call(this);
3363
- (function() {
3364
- var matches2, toArray2;
3365
- matches2 = Rails3.matches;
3366
- toArray2 = function(e) {
3367
- return Array.prototype.slice.call(e);
3368
- };
3369
- Rails3.serializeElement = function(element, additionalParam) {
3370
- var inputs, params;
3371
- inputs = [element];
3372
- if (matches2(element, "form")) {
3373
- inputs = toArray2(element.elements);
3374
- }
3375
- params = [];
3376
- inputs.forEach(function(input) {
3377
- if (!input.name || input.disabled) {
3378
- return;
3379
- }
3380
- if (matches2(input, "fieldset[disabled] *")) {
3381
- return;
3382
- }
3383
- if (matches2(input, "select")) {
3384
- return toArray2(input.options).forEach(function(option2) {
3385
- if (option2.selected) {
3386
- return params.push({
3387
- name: input.name,
3388
- value: option2.value
3389
- });
3390
- }
3391
- });
3392
- } else if (input.checked || ["radio", "checkbox", "submit"].indexOf(input.type) === -1) {
3393
- return params.push({
3394
- name: input.name,
3395
- value: input.value
3396
- });
3397
- }
3398
- });
3399
- if (additionalParam) {
3400
- params.push(additionalParam);
3401
- }
3402
- return params.map(function(param) {
3403
- if (param.name != null) {
3404
- return encodeURIComponent(param.name) + "=" + encodeURIComponent(param.value);
3405
- } else {
3406
- return param;
3407
- }
3408
- }).join("&");
3409
- };
3410
- Rails3.formElements = function(form, selector) {
3411
- if (matches2(form, "form")) {
3412
- return toArray2(form.elements).filter(function(el) {
3413
- return matches2(el, selector);
3414
- });
3415
- } else {
3416
- return toArray2(form.querySelectorAll(selector));
3417
- }
3418
- };
3419
- }).call(this);
3420
- (function() {
3421
- var allowAction, fire, stopEverything;
3422
- fire = Rails3.fire, stopEverything = Rails3.stopEverything;
3423
- Rails3.handleConfirm = function(e) {
3424
- if (!allowAction(this)) {
3425
- return stopEverything(e);
3426
- }
3427
- };
3428
- Rails3.confirm = function(message, element) {
3429
- return confirm(message);
3430
- };
3431
- allowAction = function(element) {
3432
- var answer, callback, message;
3433
- message = element.getAttribute("data-confirm");
3434
- if (!message) {
3435
- return true;
3436
- }
3437
- answer = false;
3438
- if (fire(element, "confirm")) {
3439
- try {
3440
- answer = Rails3.confirm(message, element);
3441
- } catch (error2) {
3442
- }
3443
- callback = fire(element, "confirm:complete", [answer]);
3444
- }
3445
- return answer && callback;
3446
- };
3447
- }).call(this);
3448
- (function() {
3449
- var disableFormElement, disableFormElements, disableLinkElement, enableFormElement, enableFormElements, enableLinkElement, formElements, getData, isXhrRedirect, matches2, setData, stopEverything;
3450
- matches2 = Rails3.matches, getData = Rails3.getData, setData = Rails3.setData, stopEverything = Rails3.stopEverything, formElements = Rails3.formElements;
3451
- Rails3.handleDisabledElement = function(e) {
3452
- var element;
3453
- element = this;
3454
- if (element.disabled) {
3455
- return stopEverything(e);
3456
- }
3457
- };
3458
- Rails3.enableElement = function(e) {
3459
- var element;
3460
- if (e instanceof Event) {
3461
- if (isXhrRedirect(e)) {
3462
- return;
3463
- }
3464
- element = e.target;
3465
- } else {
3466
- element = e;
3467
- }
3468
- if (matches2(element, Rails3.linkDisableSelector)) {
3469
- return enableLinkElement(element);
3470
- } else if (matches2(element, Rails3.buttonDisableSelector) || matches2(element, Rails3.formEnableSelector)) {
3471
- return enableFormElement(element);
3472
- } else if (matches2(element, Rails3.formSubmitSelector)) {
3473
- return enableFormElements(element);
3474
- }
3475
- };
3476
- Rails3.disableElement = function(e) {
3477
- var element;
3478
- element = e instanceof Event ? e.target : e;
3479
- if (matches2(element, Rails3.linkDisableSelector)) {
3480
- return disableLinkElement(element);
3481
- } else if (matches2(element, Rails3.buttonDisableSelector) || matches2(element, Rails3.formDisableSelector)) {
3482
- return disableFormElement(element);
3483
- } else if (matches2(element, Rails3.formSubmitSelector)) {
3484
- return disableFormElements(element);
3485
- }
3486
- };
3487
- disableLinkElement = function(element) {
3488
- var replacement;
3489
- if (getData(element, "ujs:disabled")) {
3490
- return;
3491
- }
3492
- replacement = element.getAttribute("data-disable-with");
3493
- if (replacement != null) {
3494
- setData(element, "ujs:enable-with", element.innerHTML);
3495
- element.innerHTML = replacement;
3496
- }
3497
- element.addEventListener("click", stopEverything);
3498
- return setData(element, "ujs:disabled", true);
3499
- };
3500
- enableLinkElement = function(element) {
3501
- var originalText;
3502
- originalText = getData(element, "ujs:enable-with");
3503
- if (originalText != null) {
3504
- element.innerHTML = originalText;
3505
- setData(element, "ujs:enable-with", null);
3506
- }
3507
- element.removeEventListener("click", stopEverything);
3508
- return setData(element, "ujs:disabled", null);
3509
- };
3510
- disableFormElements = function(form) {
3511
- return formElements(form, Rails3.formDisableSelector).forEach(disableFormElement);
3512
- };
3513
- disableFormElement = function(element) {
3514
- var replacement;
3515
- if (getData(element, "ujs:disabled")) {
3516
- return;
3517
- }
3518
- replacement = element.getAttribute("data-disable-with");
3519
- if (replacement != null) {
3520
- if (matches2(element, "button")) {
3521
- setData(element, "ujs:enable-with", element.innerHTML);
3522
- element.innerHTML = replacement;
3523
- } else {
3524
- setData(element, "ujs:enable-with", element.value);
3525
- element.value = replacement;
3526
- }
3527
- }
3528
- element.disabled = true;
3529
- return setData(element, "ujs:disabled", true);
3530
- };
3531
- enableFormElements = function(form) {
3532
- return formElements(form, Rails3.formEnableSelector).forEach(enableFormElement);
3533
- };
3534
- enableFormElement = function(element) {
3535
- var originalText;
3536
- originalText = getData(element, "ujs:enable-with");
3537
- if (originalText != null) {
3538
- if (matches2(element, "button")) {
3539
- element.innerHTML = originalText;
3540
- } else {
3541
- element.value = originalText;
3542
- }
3543
- setData(element, "ujs:enable-with", null);
3544
- }
3545
- element.disabled = false;
3546
- return setData(element, "ujs:disabled", null);
3547
- };
3548
- isXhrRedirect = function(event) {
3549
- var ref, xhr;
3550
- xhr = (ref = event.detail) != null ? ref[0] : void 0;
3551
- return (xhr != null ? xhr.getResponseHeader("X-Xhr-Redirect") : void 0) != null;
3552
- };
3553
- }).call(this);
3554
- (function() {
3555
- var stopEverything;
3556
- stopEverything = Rails3.stopEverything;
3557
- Rails3.handleMethod = function(e) {
3558
- var csrfParam, csrfToken, form, formContent, href, link, method;
3559
- link = this;
3560
- method = link.getAttribute("data-method");
3561
- if (!method) {
3562
- return;
3563
- }
3564
- href = Rails3.href(link);
3565
- csrfToken = Rails3.csrfToken();
3566
- csrfParam = Rails3.csrfParam();
3567
- form = document.createElement("form");
3568
- formContent = "<input name='_method' value='" + method + "' type='hidden' />";
3569
- if (csrfParam != null && csrfToken != null && !Rails3.isCrossDomain(href)) {
3570
- formContent += "<input name='" + csrfParam + "' value='" + csrfToken + "' type='hidden' />";
3571
- }
3572
- formContent += '<input type="submit" />';
3573
- form.method = "post";
3574
- form.action = href;
3575
- form.target = link.target;
3576
- form.innerHTML = formContent;
3577
- form.style.display = "none";
3578
- document.body.appendChild(form);
3579
- form.querySelector('[type="submit"]').click();
3580
- return stopEverything(e);
3581
- };
3582
- }).call(this);
3583
- (function() {
3584
- var ajax, fire, getData, isCrossDomain, isRemote, matches2, serializeElement, setData, stopEverything, slice = [].slice;
3585
- matches2 = Rails3.matches, getData = Rails3.getData, setData = Rails3.setData, fire = Rails3.fire, stopEverything = Rails3.stopEverything, ajax = Rails3.ajax, isCrossDomain = Rails3.isCrossDomain, serializeElement = Rails3.serializeElement;
3586
- isRemote = function(element) {
3587
- var value;
3588
- value = element.getAttribute("data-remote");
3589
- return value != null && value !== "false";
3590
- };
3591
- Rails3.handleRemote = function(e) {
3592
- var button, data, dataType, element, method, url, withCredentials;
3593
- element = this;
3594
- if (!isRemote(element)) {
3595
- return true;
3596
- }
3597
- if (!fire(element, "ajax:before")) {
3598
- fire(element, "ajax:stopped");
3599
- return false;
3600
- }
3601
- withCredentials = element.getAttribute("data-with-credentials");
3602
- dataType = element.getAttribute("data-type") || "script";
3603
- if (matches2(element, Rails3.formSubmitSelector)) {
3604
- button = getData(element, "ujs:submit-button");
3605
- method = getData(element, "ujs:submit-button-formmethod") || element.method;
3606
- url = getData(element, "ujs:submit-button-formaction") || element.getAttribute("action") || location.href;
3607
- if (method.toUpperCase() === "GET") {
3608
- url = url.replace(/\?.*$/, "");
3609
- }
3610
- if (element.enctype === "multipart/form-data") {
3611
- data = new FormData(element);
3612
- if (button != null) {
3613
- data.append(button.name, button.value);
3614
- }
3615
- } else {
3616
- data = serializeElement(element, button);
3617
- }
3618
- setData(element, "ujs:submit-button", null);
3619
- setData(element, "ujs:submit-button-formmethod", null);
3620
- setData(element, "ujs:submit-button-formaction", null);
3621
- } else if (matches2(element, Rails3.buttonClickSelector) || matches2(element, Rails3.inputChangeSelector)) {
3622
- method = element.getAttribute("data-method");
3623
- url = element.getAttribute("data-url");
3624
- data = serializeElement(element, element.getAttribute("data-params"));
3625
- } else {
3626
- method = element.getAttribute("data-method");
3627
- url = Rails3.href(element);
3628
- data = element.getAttribute("data-params");
3629
- }
3630
- ajax({
3631
- type: method || "GET",
3632
- url,
3633
- data,
3634
- dataType,
3635
- beforeSend: function(xhr, options) {
3636
- if (fire(element, "ajax:beforeSend", [xhr, options])) {
3637
- return fire(element, "ajax:send", [xhr]);
3638
- } else {
3639
- fire(element, "ajax:stopped");
3640
- return false;
3641
- }
3642
- },
3643
- success: function() {
3644
- var args;
3645
- args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
3646
- return fire(element, "ajax:success", args);
3647
- },
3648
- error: function() {
3649
- var args;
3650
- args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
3651
- return fire(element, "ajax:error", args);
3652
- },
3653
- complete: function() {
3654
- var args;
3655
- args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
3656
- return fire(element, "ajax:complete", args);
3657
- },
3658
- crossDomain: isCrossDomain(url),
3659
- withCredentials: withCredentials != null && withCredentials !== "false"
3660
- });
3661
- return stopEverything(e);
3662
- };
3663
- Rails3.formSubmitButtonClick = function(e) {
3664
- var button, form;
3665
- button = this;
3666
- form = button.form;
3667
- if (!form) {
3668
- return;
3669
- }
3670
- if (button.name) {
3671
- setData(form, "ujs:submit-button", {
3672
- name: button.name,
3673
- value: button.value
3674
- });
3675
- }
3676
- setData(form, "ujs:formnovalidate-button", button.formNoValidate);
3677
- setData(form, "ujs:submit-button-formaction", button.getAttribute("formaction"));
3678
- return setData(form, "ujs:submit-button-formmethod", button.getAttribute("formmethod"));
3679
- };
3680
- Rails3.preventInsignificantClick = function(e) {
3681
- var data, insignificantMetaClick, link, metaClick, method, nonPrimaryMouseClick;
3682
- link = this;
3683
- method = (link.getAttribute("data-method") || "GET").toUpperCase();
3684
- data = link.getAttribute("data-params");
3685
- metaClick = e.metaKey || e.ctrlKey;
3686
- insignificantMetaClick = metaClick && method === "GET" && !data;
3687
- nonPrimaryMouseClick = e.button != null && e.button !== 0;
3688
- if (nonPrimaryMouseClick || insignificantMetaClick) {
3689
- return e.stopImmediatePropagation();
3690
- }
3691
- };
3692
- }).call(this);
3693
- (function() {
3694
- var $2, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMethod, handleRemote, loadCSPNonce, preventInsignificantClick, refreshCSRFTokens;
3695
- fire = Rails3.fire, delegate = Rails3.delegate, getData = Rails3.getData, $2 = Rails3.$, refreshCSRFTokens = Rails3.refreshCSRFTokens, CSRFProtection = Rails3.CSRFProtection, loadCSPNonce = Rails3.loadCSPNonce, enableElement = Rails3.enableElement, disableElement = Rails3.disableElement, handleDisabledElement = Rails3.handleDisabledElement, handleConfirm = Rails3.handleConfirm, preventInsignificantClick = Rails3.preventInsignificantClick, handleRemote = Rails3.handleRemote, formSubmitButtonClick = Rails3.formSubmitButtonClick, handleMethod = Rails3.handleMethod;
3696
- if (typeof jQuery !== "undefined" && jQuery !== null && jQuery.ajax != null) {
3697
- if (jQuery.rails) {
3698
- throw new Error("If you load both jquery_ujs and rails-ujs, use rails-ujs only.");
3699
- }
3700
- jQuery.rails = Rails3;
3701
- jQuery.ajaxPrefilter(function(options, originalOptions, xhr) {
3702
- if (!options.crossDomain) {
3703
- return CSRFProtection(xhr);
3704
- }
3705
- });
3706
- }
3707
- Rails3.start = function() {
3708
- if (window._rails_loaded) {
3709
- throw new Error("rails-ujs has already been loaded!");
3710
- }
3711
- window.addEventListener("pageshow", function() {
3712
- $2(Rails3.formEnableSelector).forEach(function(el) {
3713
- if (getData(el, "ujs:disabled")) {
3714
- return enableElement(el);
3715
- }
3716
- });
3717
- return $2(Rails3.linkDisableSelector).forEach(function(el) {
3718
- if (getData(el, "ujs:disabled")) {
3719
- return enableElement(el);
3720
- }
3721
- });
3722
- });
3723
- delegate(document, Rails3.linkDisableSelector, "ajax:complete", enableElement);
3724
- delegate(document, Rails3.linkDisableSelector, "ajax:stopped", enableElement);
3725
- delegate(document, Rails3.buttonDisableSelector, "ajax:complete", enableElement);
3726
- delegate(document, Rails3.buttonDisableSelector, "ajax:stopped", enableElement);
3727
- delegate(document, Rails3.linkClickSelector, "click", preventInsignificantClick);
3728
- delegate(document, Rails3.linkClickSelector, "click", handleDisabledElement);
3729
- delegate(document, Rails3.linkClickSelector, "click", handleConfirm);
3730
- delegate(document, Rails3.linkClickSelector, "click", disableElement);
3731
- delegate(document, Rails3.linkClickSelector, "click", handleRemote);
3732
- delegate(document, Rails3.linkClickSelector, "click", handleMethod);
3733
- delegate(document, Rails3.buttonClickSelector, "click", preventInsignificantClick);
3734
- delegate(document, Rails3.buttonClickSelector, "click", handleDisabledElement);
3735
- delegate(document, Rails3.buttonClickSelector, "click", handleConfirm);
3736
- delegate(document, Rails3.buttonClickSelector, "click", disableElement);
3737
- delegate(document, Rails3.buttonClickSelector, "click", handleRemote);
3738
- delegate(document, Rails3.inputChangeSelector, "change", handleDisabledElement);
3739
- delegate(document, Rails3.inputChangeSelector, "change", handleConfirm);
3740
- delegate(document, Rails3.inputChangeSelector, "change", handleRemote);
3741
- delegate(document, Rails3.formSubmitSelector, "submit", handleDisabledElement);
3742
- delegate(document, Rails3.formSubmitSelector, "submit", handleConfirm);
3743
- delegate(document, Rails3.formSubmitSelector, "submit", handleRemote);
3744
- delegate(document, Rails3.formSubmitSelector, "submit", function(e) {
3745
- return setTimeout(function() {
3746
- return disableElement(e);
3747
- }, 13);
3748
- });
3749
- delegate(document, Rails3.formSubmitSelector, "ajax:send", disableElement);
3750
- delegate(document, Rails3.formSubmitSelector, "ajax:complete", enableElement);
3751
- delegate(document, Rails3.formInputClickSelector, "click", preventInsignificantClick);
3752
- delegate(document, Rails3.formInputClickSelector, "click", handleDisabledElement);
3753
- delegate(document, Rails3.formInputClickSelector, "click", handleConfirm);
3754
- delegate(document, Rails3.formInputClickSelector, "click", formSubmitButtonClick);
3755
- document.addEventListener("DOMContentLoaded", refreshCSRFTokens);
3756
- document.addEventListener("DOMContentLoaded", loadCSPNonce);
3757
- return window._rails_loaded = true;
3758
- };
3759
- if (window.Rails === Rails3 && fire(document, "rails:attachBindings")) {
3760
- Rails3.start();
3761
- }
3762
- }).call(this);
3763
- }).call(this);
3764
- if (typeof module === "object" && module.exports) {
3765
- module.exports = Rails3;
3766
- } else if (typeof define === "function" && define.amd) {
3767
- define(Rails3);
3768
- }
3769
- }).call(exports);
3770
- }
3771
- });
3772
-
3773
3099
  // node_modules/@hotwired/stimulus/dist/stimulus.js
3774
3100
  var EventListener = class {
3775
3101
  constructor(eventTarget, eventName, eventOptions) {
@@ -4334,13 +3660,13 @@ var StringMapObserver = class {
4334
3660
  }
4335
3661
  };
4336
3662
  function add(map, key, value) {
4337
- fetch(map, key).add(value);
3663
+ fetch2(map, key).add(value);
4338
3664
  }
4339
3665
  function del(map, key, value) {
4340
- fetch(map, key).delete(value);
3666
+ fetch2(map, key).delete(value);
4341
3667
  prune(map, key);
4342
3668
  }
4343
- function fetch(map, key) {
3669
+ function fetch2(map, key) {
4344
3670
  let values = map.get(key);
4345
3671
  if (!values) {
4346
3672
  values = /* @__PURE__ */ new Set();
@@ -5636,6 +4962,202 @@ Controller.blessings = [ClassPropertiesBlessing, TargetPropertiesBlessing, Value
5636
4962
  Controller.targets = [];
5637
4963
  Controller.values = {};
5638
4964
 
4965
+ // app/assets/javascripts/headmin/controllers/autocomplete_controller.js
4966
+ var autocomplete_controller_default = class extends Controller {
4967
+ static get targets() {
4968
+ return ["input", "dropdown", "dropdownItem"];
4969
+ }
4970
+ static get values() {
4971
+ return {
4972
+ url: String
4973
+ };
4974
+ }
4975
+ connect() {
4976
+ this.inputTarget.addEventListener("focus", (event) => {
4977
+ this.show();
4978
+ });
4979
+ this.inputTarget.addEventListener("keydown", (event) => {
4980
+ this.handleKeydown(event);
4981
+ });
4982
+ document.addEventListener("click", (event) => {
4983
+ this.handleOutsideClick(event);
4984
+ });
4985
+ }
4986
+ handleKeydown(event) {
4987
+ this.show();
4988
+ const keyCode = parseInt(event.keyCode, 10);
4989
+ if (this.isArrowKey(keyCode)) {
4990
+ this.handleArrowKey(keyCode);
4991
+ } else if (this.isEnterKey(keyCode)) {
4992
+ this.selectActiveItem();
4993
+ } else {
4994
+ this.handleTextKey();
4995
+ }
4996
+ }
4997
+ selectActiveItem() {
4998
+ this.activeItem().click();
4999
+ }
5000
+ isEnterKey(keyCode) {
5001
+ return keyCode === 13;
5002
+ }
5003
+ handleArrowKey(keyCode) {
5004
+ switch (keyCode) {
5005
+ case 38:
5006
+ this.handleArrowUp();
5007
+ break;
5008
+ case 40:
5009
+ this.handleArrowDown();
5010
+ break;
5011
+ default:
5012
+ }
5013
+ }
5014
+ handleArrowUp() {
5015
+ this.selectPreviousItem();
5016
+ }
5017
+ handleArrowDown() {
5018
+ this.selectNextItem();
5019
+ }
5020
+ selectNextItem() {
5021
+ const next = this.nextItem();
5022
+ this.deselectAll();
5023
+ next.classList.add("active");
5024
+ }
5025
+ nextItem() {
5026
+ const current = this.activeItem();
5027
+ if (!this.hasSelectedItem()) {
5028
+ return this.firstItem();
5029
+ }
5030
+ if (this.isItemLast(current)) {
5031
+ return this.firstItem();
5032
+ } else {
5033
+ const index2 = this.itemIndex(current);
5034
+ return this.itemAtIndex(index2 + 1);
5035
+ }
5036
+ }
5037
+ selectPreviousItem() {
5038
+ const previous = this.previousItem();
5039
+ this.deselectAll();
5040
+ previous.classList.add("active");
5041
+ }
5042
+ previousItem() {
5043
+ const current = this.activeItem();
5044
+ if (!this.hasSelectedItem()) {
5045
+ return this.lastItem();
5046
+ }
5047
+ if (this.isItemFirst(current)) {
5048
+ return this.lastItem();
5049
+ } else {
5050
+ const index2 = this.itemIndex(current);
5051
+ return this.itemAtIndex(index2 - 1);
5052
+ }
5053
+ }
5054
+ deselectAll() {
5055
+ this.dropdownItemTargets.forEach((dropdownItem) => {
5056
+ dropdownItem.classList.remove("active");
5057
+ });
5058
+ }
5059
+ itemAtIndex(index2) {
5060
+ return this.dropdownItemTargets[index2];
5061
+ }
5062
+ firstItem() {
5063
+ return this.itemAtIndex(0);
5064
+ }
5065
+ lastItem() {
5066
+ return this.itemAtIndex(this.dropdownItemTargets.length - 1);
5067
+ }
5068
+ hasSelectedItem() {
5069
+ return this.activeItem() !== void 0;
5070
+ }
5071
+ activeItem() {
5072
+ return this.dropdownItemTargets.find((item) => {
5073
+ return item.classList.contains("active");
5074
+ });
5075
+ }
5076
+ isItemLast(item) {
5077
+ return this.itemIndex(item) === this.dropdownItemTargets.length - 1;
5078
+ }
5079
+ isItemFirst(item) {
5080
+ return this.itemIndex(item) === 0;
5081
+ }
5082
+ itemIndex(item) {
5083
+ return Array.from(this.dropdownItemTargets).indexOf(item);
5084
+ }
5085
+ handleTextKey() {
5086
+ this.fetchCollection().then((html) => {
5087
+ this.renderCollection(html);
5088
+ }).then(() => {
5089
+ this.highlight();
5090
+ });
5091
+ }
5092
+ show() {
5093
+ if (this.isDropdownEmpty()) {
5094
+ this.dropdownTarget.classList.remove("d-none");
5095
+ } else {
5096
+ this.hide();
5097
+ }
5098
+ }
5099
+ hide() {
5100
+ this.dropdownTarget.classList.add("d-none");
5101
+ }
5102
+ isDropdownEmpty() {
5103
+ return this.dropdownTarget.textContent.trim().length > 0;
5104
+ }
5105
+ isArrowKey(keyCode) {
5106
+ const arrowKeyCodes = [37, 38, 39, 40];
5107
+ return arrowKeyCodes.includes(keyCode);
5108
+ }
5109
+ fetchCollection() {
5110
+ if (this.isRemote()) {
5111
+ return fetch(this.urlValue).then((response) => {
5112
+ return response.text();
5113
+ }).catch((error2) => {
5114
+ console.error("The URL you provided for the autocomplete collection didn't return a successful result", error2);
5115
+ });
5116
+ } else {
5117
+ return Promise.resolve(this.dropdownTarget.innerHTML);
5118
+ }
5119
+ }
5120
+ renderCollection(html) {
5121
+ this.dropdownTarget.innerHTML = html;
5122
+ }
5123
+ isRemote() {
5124
+ return this.hasUrlValue;
5125
+ }
5126
+ highlight() {
5127
+ const query = this.value();
5128
+ this.dropdownItemTargets.forEach((dropdownItem) => {
5129
+ let text = dropdownItem.innerHTML;
5130
+ text = text.replace(/<mark.*?>(.*?)<\/mark>/ig, "$1");
5131
+ const regex2 = new RegExp(`(${query})`, "gi");
5132
+ text = text.replace(regex2, "<mark>$1</mark>");
5133
+ dropdownItem.innerHTML = text;
5134
+ });
5135
+ }
5136
+ select(event) {
5137
+ this.inputTarget.value = event.target.getAttribute("value");
5138
+ this.hide();
5139
+ }
5140
+ value() {
5141
+ return this.inputTarget.value;
5142
+ }
5143
+ numberOfCharacters() {
5144
+ return this.value().length;
5145
+ }
5146
+ handleOutsideClick(event) {
5147
+ if (!this.isClickedInside(event)) {
5148
+ this.hide();
5149
+ }
5150
+ }
5151
+ isClickedInside(event) {
5152
+ if (!event) {
5153
+ return false;
5154
+ }
5155
+ const inInput = this.inputTarget.contains(event.target);
5156
+ const inDropdown = this.dropdownTarget.contains(event.target);
5157
+ return inInput || inDropdown;
5158
+ }
5159
+ };
5160
+
5639
5161
  // node_modules/sortablejs/modular/sortable.esm.js
5640
5162
  function ownKeys(object, enumerableOnly) {
5641
5163
  var keys = Object.keys(object);
@@ -7816,7 +7338,7 @@ var blocks_controller_default = class extends Controller {
7816
7338
  return ["templateBlock", "block", "blocks", "templateEmpty", "button", "buttons"];
7817
7339
  }
7818
7340
  connect() {
7819
- new sortable_esm_default(this.blocksTarget, {
7341
+ sortable_esm_default.create(this.blocksTarget, {
7820
7342
  onEnd: () => {
7821
7343
  this.reorderPositions();
7822
7344
  }
@@ -7845,7 +7367,6 @@ var blocks_controller_default = class extends Controller {
7845
7367
  } else {
7846
7368
  this.blocksTarget.insertAdjacentHTML("afterbegin", html);
7847
7369
  }
7848
- this.blocksTarget.dispatchEvent(new CustomEvent("headmin:reinit", { bubbles: true }));
7849
7370
  this.reorderPositions();
7850
7371
  this.toggleEmpty();
7851
7372
  }
@@ -7864,8 +7385,7 @@ var blocks_controller_default = class extends Controller {
7864
7385
  }
7865
7386
  setPosition(html) {
7866
7387
  const position = this.retrieveLastPosition() + 1;
7867
- const regex = new RegExp("99999", "g");
7868
- return html.replace(regex, position);
7388
+ return html.replace(/99999/g, position);
7869
7389
  }
7870
7390
  retrieveLastPosition() {
7871
7391
  const blocks = Array.from(this.blockTargets);
@@ -7876,7 +7396,7 @@ var blocks_controller_default = class extends Controller {
7876
7396
  return parseInt(lastBlock.querySelector("[name*='position']").value);
7877
7397
  }
7878
7398
  reorderPositions() {
7879
- for (let [index2, block] of this.blockTargets.entries()) {
7399
+ for (const [index2, block] of this.blockTargets.entries()) {
7880
7400
  this.changePositionInfo(block, index2);
7881
7401
  }
7882
7402
  }
@@ -7922,21 +7442,20 @@ var dropzone_controller_default = class extends Controller {
7922
7442
  return ["input"];
7923
7443
  }
7924
7444
  connect() {
7925
- this.element.classList.add("h-dropzone");
7926
7445
  this.inputTarget.addEventListener("dragover", (event) => {
7927
- this.element.classList.add("dragover");
7446
+ this.element.classList.add("focus");
7928
7447
  });
7929
7448
  this.inputTarget.addEventListener("dragleave", (event) => {
7930
- this.element.classList.remove("dragover");
7449
+ this.element.classList.remove("focus");
7931
7450
  });
7932
7451
  this.inputTarget.addEventListener("drop", (event) => {
7933
- this.element.classList.remove("dragover");
7452
+ this.element.classList.remove("focus");
7934
7453
  });
7935
7454
  this.inputTarget.addEventListener("focusin", (event) => {
7936
- this.element.classList.add("active");
7455
+ this.element.classList.add("focus");
7937
7456
  });
7938
7457
  this.inputTarget.addEventListener("focusout", (event) => {
7939
- this.element.classList.remove("active");
7458
+ this.element.classList.remove("focus");
7940
7459
  });
7941
7460
  }
7942
7461
  };
@@ -8036,7 +7555,7 @@ var file_preview_controller_default = class extends Controller {
8036
7555
  addThumbnails() {
8037
7556
  const files = this.inputFiles();
8038
7557
  files.forEach((file) => {
8039
- let thumbnail = this.generateDummyThumbnail();
7558
+ const thumbnail = this.generateDummyThumbnail();
8040
7559
  this.appendThumbnail(thumbnail);
8041
7560
  this.updateThumbnail(this.lastThumbnail(), file);
8042
7561
  });
@@ -8081,7 +7600,7 @@ var file_preview_controller_default = class extends Controller {
8081
7600
  thumbnail.title = title;
8082
7601
  }
8083
7602
  updateThumbnailBackground(thumbnail, url) {
8084
- let thumbnailBackground = thumbnail.querySelector(".h-thumbnail-bg");
7603
+ const thumbnailBackground = thumbnail.querySelector(".h-thumbnail-bg");
8085
7604
  thumbnailBackground.style.backgroundImage = `url('${url}')`;
8086
7605
  }
8087
7606
  removeThumbnailIcon(thumbnail) {
@@ -8104,9 +7623,9 @@ var file_preview_controller_default = class extends Controller {
8104
7623
  zip: ["application/zip application/x-7z-compressed", "application/x-bzip application/x-bzip2 application/gzip application/vnd.rar"],
8105
7624
  pdf: ["application/pdf"]
8106
7625
  };
8107
- const icon_name = Object.keys(typeMap).find((key) => typeMap[key].includes(mimeType));
8108
- const full_icon_name = ["bi", "file", "earmark", icon_name].filter((e) => typeof e === "string" && e !== "").join("-");
8109
- return `<i class="bi ${full_icon_name} h-thumbnail-icon"></i>`;
7626
+ const iconName = Object.keys(typeMap).find((key) => typeMap[key].includes(mimeType));
7627
+ const fullIconName = ["bi", "file", "earmark", iconName].filter((e) => typeof e === "string" && e !== "").join("-");
7628
+ return `<i class="bi ${fullIconName} h-thumbnail-icon"></i>`;
8110
7629
  }
8111
7630
  isImage(file) {
8112
7631
  return file.type.match(/^image/) !== null;
@@ -8142,7 +7661,7 @@ var filter_controller_default = class extends Controller {
8142
7661
  return ["button", "popup"];
8143
7662
  }
8144
7663
  connect() {
8145
- this.element["controller"] = this;
7664
+ this.element.controller = this;
8146
7665
  document.addEventListener("click", (event) => {
8147
7666
  this.handleOutsideClick(event);
8148
7667
  });
@@ -8198,7 +7717,6 @@ var filters_controller_default = class extends Controller {
8198
7717
  let html = this.getTemplateHTML(name);
8199
7718
  html = this.replaceIdsWithTimestamps(html);
8200
7719
  this.listTarget.insertAdjacentHTML("beforeend", html);
8201
- this.menuItemTarget.dispatchEvent(new CustomEvent("headmin:reinit", { bubbles: true }));
8202
7720
  }
8203
7721
  remove(event) {
8204
7722
  const filter = event.currentTarget.closest(".h-filter");
@@ -8227,8 +7745,7 @@ var filters_controller_default = class extends Controller {
8227
7745
  return template.innerHTML;
8228
7746
  }
8229
7747
  replaceIdsWithTimestamps(html) {
8230
- const regex = new RegExp("template_id", "g");
8231
- return html.replace(regex, new Date().getTime());
7748
+ return html.replace(/template_id/g, new Date().getTime());
8232
7749
  }
8233
7750
  };
8234
7751
 
@@ -10420,7 +9937,7 @@ var flatpickr_controller_default = class extends Controller {
10420
9937
  esm_default(this.inputTarget, options);
10421
9938
  }
10422
9939
  options() {
10423
- return JSON.parse(this.inputTarget.getAttribute("data-flatpickr-options"));
9940
+ return JSON.parse(this.inputTarget.getAttribute("data-flatpickr"));
10424
9941
  }
10425
9942
  defaultOptions() {
10426
9943
  return {
@@ -15527,8 +15044,8 @@ var popup_controller_default = class extends Controller {
15527
15044
  }
15528
15045
  open(event) {
15529
15046
  const button = event.target.closest('[data-popup-target="button"]');
15530
- const popup = this.popupById(button.dataset["popupId"]);
15531
- const passThru = button.dataset["popupPassThru"];
15047
+ const popup = this.popupById(button.dataset.popupId);
15048
+ const passThru = button.dataset.popupPassThru;
15532
15049
  if (passThru) {
15533
15050
  const passThruElement = popup.querySelector(passThru);
15534
15051
  passThruElement.click();
@@ -15539,12 +15056,12 @@ var popup_controller_default = class extends Controller {
15539
15056
  }
15540
15057
  close(event) {
15541
15058
  const button = event.target.closest('[data-popup-target="button"]');
15542
- const popup = this.popupById(button.dataset["popupId"]);
15059
+ const popup = this.popupById(button.dataset.popupId);
15543
15060
  this.closePopup(popup);
15544
15061
  }
15545
15062
  popupById(id) {
15546
15063
  return this.popupTargets.find((popup) => {
15547
- return popup.dataset["popupId"] === id;
15064
+ return popup.dataset.popupId === id;
15548
15065
  });
15549
15066
  }
15550
15067
  openPopup(popup) {
@@ -15558,12 +15075,30 @@ var popup_controller_default = class extends Controller {
15558
15075
  // app/assets/javascripts/headmin/controllers/redactorx_controller.js
15559
15076
  var redactorx_controller_default = class extends Controller {
15560
15077
  connect() {
15561
- if (typeof RedactorX == "undefined") {
15078
+ this.initRedactor();
15079
+ }
15080
+ initRedactor() {
15081
+ if (typeof RedactorX === "undefined") {
15562
15082
  console.error("RedactorX is a paid module and is not included in Headmin. Please purchase it and import it as a JS module");
15563
15083
  return false;
15564
15084
  }
15085
+ const defaultOptions = {
15086
+ editor: {
15087
+ minHeight: "57px"
15088
+ },
15089
+ subscribe: {
15090
+ "app.start": () => {
15091
+ this.stylize();
15092
+ }
15093
+ }
15094
+ };
15565
15095
  const options = JSON.parse(this.element.getAttribute("data-redactor-options"));
15566
- RedactorX(this.element, options);
15096
+ RedactorX(this.element, { ...defaultOptions, ...options });
15097
+ }
15098
+ stylize() {
15099
+ const container = this.element.nextElementSibling;
15100
+ const inputClasses = this.element.classList;
15101
+ container.classList.add(...inputClasses);
15567
15102
  }
15568
15103
  };
15569
15104
 
@@ -15578,7 +15113,7 @@ var repeater_controller_default = class extends Controller {
15578
15113
  return ["repeater", "footer", "template", "row", "list", "empty", "addButton"];
15579
15114
  }
15580
15115
  connect() {
15581
- new sortable_esm_default(this.listTarget, {
15116
+ sortable_esm_default.create(this.listTarget, {
15582
15117
  animation: 150,
15583
15118
  ghostClass: "list-group-item-dark",
15584
15119
  draggable: ".repeater-row",
@@ -15609,7 +15144,7 @@ var repeater_controller_default = class extends Controller {
15609
15144
  event.preventDefault();
15610
15145
  const button = event.target;
15611
15146
  const templateName = button.dataset.templateName;
15612
- let rowIndex = button.dataset.rowIndex;
15147
+ const rowIndex = button.dataset.rowIndex;
15613
15148
  const template = this.getTemplate(templateName);
15614
15149
  const html = this.replaceIdsWithTimestamps(template);
15615
15150
  if (rowIndex) {
@@ -15618,7 +15153,6 @@ var repeater_controller_default = class extends Controller {
15618
15153
  } else {
15619
15154
  this.footerTarget.insertAdjacentHTML("beforebegin", html);
15620
15155
  }
15621
- document.dispatchEvent(new CustomEvent("headmin:reinit", { bubbles: true }));
15622
15156
  this.resetIndices();
15623
15157
  this.resetPositions();
15624
15158
  this.toggleEmpty();
@@ -15710,7 +15244,7 @@ var select_controller_default = class extends Controller {
15710
15244
  return defaultOptions[locale];
15711
15245
  }
15712
15246
  hasTags() {
15713
- return this.element.dataset["tags"] === "true";
15247
+ return this.element.dataset.tags === "true";
15714
15248
  }
15715
15249
  initTomSelect() {
15716
15250
  const defaultOptions = this.defaultOptions(i18n_default.locale);
@@ -15735,7 +15269,8 @@ var table_actions_controller_default = class extends Controller {
15735
15269
  event.preventDefault();
15736
15270
  this.updateFormAction();
15737
15271
  this.updateFormMethod();
15738
- this.updateButton();
15272
+ this.updateFormDataAttributes();
15273
+ this.enableButton();
15739
15274
  }
15740
15275
  updateIdFields(ids) {
15741
15276
  this.removeIds();
@@ -15776,15 +15311,24 @@ var table_actions_controller_default = class extends Controller {
15776
15311
  const option2 = this.selectedOption();
15777
15312
  this.methodTarget.value = option2.dataset.method;
15778
15313
  }
15779
- updateButton() {
15314
+ updateFormDataAttributes() {
15780
15315
  const option2 = this.selectedOption();
15781
- const confirm2 = option2.dataset.confirm;
15782
- if (confirm2) {
15783
- this.buttonTarget.dataset.confirm = confirm2;
15316
+ this.updateFormDataConfirm(option2.dataset.turboConfirm);
15317
+ this.updateFormDataTurbo(option2.dataset.turbo);
15318
+ }
15319
+ updateFormDataConfirm(confirm) {
15320
+ if (confirm) {
15321
+ this.formTarget.dataset.turboConfirm = confirm;
15784
15322
  } else {
15785
- this.buttonTarget.removeAttribute("data-confirm");
15323
+ this.formTarget.removeAttribute("data-turbo-confirm");
15324
+ }
15325
+ }
15326
+ updateFormDataTurbo(turbo) {
15327
+ if (turbo) {
15328
+ this.formTarget.dataset.turbo = turbo;
15329
+ } else {
15330
+ this.formTarget.removeAttribute("data-turbo");
15786
15331
  }
15787
- this.enableButton();
15788
15332
  }
15789
15333
  selectedOption() {
15790
15334
  return this.selectTarget.options[this.selectTarget.selectedIndex];
@@ -15805,7 +15349,6 @@ var table_actions_controller_default = class extends Controller {
15805
15349
  };
15806
15350
 
15807
15351
  // app/assets/javascripts/headmin/controllers/table_controller.js
15808
- var import_ujs = __toESM(require_rails_ujs());
15809
15352
  var table_controller_default = class extends Controller {
15810
15353
  static get values() {
15811
15354
  return {
@@ -15817,25 +15360,38 @@ var table_controller_default = class extends Controller {
15817
15360
  return ["table", "body", "actions", "idCheckbox", "idsCheckbox", "row"];
15818
15361
  }
15819
15362
  connect() {
15820
- new sortable_esm_default(this.bodyTarget, {
15363
+ sortable_esm_default.create(this.bodyTarget, {
15821
15364
  handle: ".table-drag-sort-handle",
15822
15365
  onEnd: (event) => {
15823
- import_ujs.default.ajax({
15824
- url: this.urlValue,
15825
- type: "PATCH",
15826
- data: this.getIdsDataString()
15827
- });
15366
+ this.submitPositions();
15828
15367
  }
15829
15368
  });
15830
15369
  }
15831
- getIdsDataString() {
15832
- const table = this.tableTarget;
15833
- let data = "";
15834
- const handles = [...table.querySelectorAll(".table-drag-sort-handle")];
15835
- handles.map((handle) => {
15836
- data += `ids[]=${handle.dataset.id}&`;
15370
+ submitPositions() {
15371
+ fetch(this.urlValue, {
15372
+ method: "PATCH",
15373
+ body: this.idsFormData(),
15374
+ headers: {
15375
+ "X-CSRF-Token": document.querySelector('meta[name="csrf-token"]').content
15376
+ }
15377
+ }).then((response) => {
15378
+ return response.text();
15379
+ }).catch((err) => {
15380
+ console.warn("Fetch went wrong", err);
15381
+ });
15382
+ }
15383
+ positions() {
15384
+ const handles = [...this.tableTarget.querySelectorAll(".table-drag-sort-handle")];
15385
+ return handles.map((handle) => {
15386
+ return handle.dataset.id;
15387
+ });
15388
+ }
15389
+ idsFormData() {
15390
+ const formData = new FormData();
15391
+ this.positions().forEach((id) => {
15392
+ formData.append("ids[]", id);
15837
15393
  });
15838
- return data;
15394
+ return formData;
15839
15395
  }
15840
15396
  toggleIds(event) {
15841
15397
  const checkbox = event.target;
@@ -15896,12 +15452,12 @@ var table_controller_default = class extends Controller {
15896
15452
  };
15897
15453
 
15898
15454
  // app/assets/javascripts/headmin/index.js
15899
- var import_ujs2 = __toESM(require_rails_ujs());
15900
15455
  var Headmin = class {
15901
15456
  static start() {
15902
15457
  window.Stimulus = window.Stimulus || Application.start();
15458
+ Stimulus.register("autocomplete", autocomplete_controller_default);
15903
15459
  Stimulus.register("blocks", blocks_controller_default);
15904
- Stimulus.register("date_range", date_range_controller_default);
15460
+ Stimulus.register("date-range", date_range_controller_default);
15905
15461
  Stimulus.register("dropzone", dropzone_controller_default);
15906
15462
  Stimulus.register("file-preview", file_preview_controller_default);
15907
15463
  Stimulus.register("filter", filter_controller_default);
@@ -15915,7 +15471,6 @@ var Headmin = class {
15915
15471
  Stimulus.register("select", select_controller_default);
15916
15472
  Stimulus.register("table", table_controller_default);
15917
15473
  Stimulus.register("table-actions", table_actions_controller_default);
15918
- import_ujs2.default.start();
15919
15474
  }
15920
15475
  };
15921
15476
  export {