bullet_train-fields 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cb1ea56c420a20ce741816c549c2a3065c42cd6ed2a1885862c258530224db9
4
- data.tar.gz: de265f0e2413c59cd834d08b900d2ad0fa2ceaf82eed04101660a4df8492cea4
3
+ metadata.gz: b7e36c0391062be37e5e99bb86c4530bb521ca12af05711908fe71660105375b
4
+ data.tar.gz: bc7058c82ff2274cee54feffec5316a3dd6331ecce05b8fd163577b925d61667
5
5
  SHA512:
6
- metadata.gz: 2d7a3a2f146aa2d0af82531edcef465b83531c67560ebff199a8ff66644c64be561a2894e1c88f4743972fdf99369f7a2ed9e5fbd3e872a6cc59891d070e7557
7
- data.tar.gz: 2016bb83be877b8cd1024c5283bdbea4df3613787bf70a69d48179dd787db9d0a0517bee8819f08e9b22c443d389e0ca6a881ac148afb9c4a8525c402d1cd188
6
+ metadata.gz: 3d446b9291fe87f42a1313220809ef82f4074d9c1dc66dc0805e8443c63d5b13550b9d6fe4b8429da81e2fe169af3a810d9a909264c683487f24536ec0ec4b9a
7
+ data.tar.gz: 2b3fd34c528d2c800b10ce6940472205b113e48a767a4b9300b62fe101303265418f386cb966f0d8fb77644f5b462bde0ccd86bca72d93fa9509978966516c16
data/README.md CHANGED
@@ -22,7 +22,7 @@ $ gem install bullet_train-fields
22
22
  ```
23
23
 
24
24
  ## Contributing
25
- Contribution directions go here.
25
+ See [`RELEASE.md` in bullet_train-base](https://github.com/bullet-train-co/bullet_train-base/blob/main/RELEASE.md) for instructions on local development and for publishing both the gem and the npm package.
26
26
 
27
27
  ## License
28
28
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,4 +1,4 @@
1
- import { Controller } from "stimulus"
1
+ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = [ "shadowField" ]
@@ -1,4 +1,4 @@
1
- import { Controller } from "stimulus"
1
+ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = [ "uploadButton", "hiddenField", "thumbnail" ]
@@ -1,4 +1,4 @@
1
- import { Controller } from "stimulus"
1
+ import { Controller } from "@hotwired/stimulus"
2
2
  import '@simonwep/pickr/dist/themes/monolith.min.css'
3
3
 
4
4
  import Pickr from '@simonwep/pickr';
@@ -1,4 +1,4 @@
1
- import { Controller } from "stimulus"
1
+ import { Controller } from "@hotwired/stimulus"
2
2
  require("daterangepicker/daterangepicker.css");
3
3
 
4
4
  // requires jQuery, moment, might want to consider a vanilla JS alternative
@@ -9,8 +9,8 @@ export default class extends Controller {
9
9
  static values = {
10
10
  includeTime: Boolean,
11
11
  defaultTimeZones: Array,
12
- cancelButtonLabel: String,
13
- applyButtonLabel: String
12
+ cancelButtonLabel: { type: String, default: "Cancel" },
13
+ applyButtonLabel: { type: String, default: "Apply" }
14
14
  }
15
15
 
16
16
  connect() {
@@ -86,8 +86,8 @@ export default class extends Controller {
86
86
  timePickerIncrement: 5,
87
87
  autoUpdateInput: false,
88
88
  locale: {
89
- cancelLabel: (this.hasCancelButtonLabelValue)? this.cancelButtonLabelValue: "cancel",
90
- applyLabel: (this.hasApplyButtonLabelValue)? this.applyButtonLabelValue: "apply",
89
+ cancelLabel: this.cancelButtonLabelValue,
90
+ applyLabel: this.applyButtonLabelValue,
91
91
  format: this.includeTimeValue ? 'MM/DD/YYYY h:mm A' : 'MM/DD/YYYY'
92
92
  }
93
93
  })
@@ -1,4 +1,4 @@
1
- import { Controller } from "stimulus";
1
+ import { Controller } from "@hotwired/stimulus";
2
2
 
3
3
  export default class extends Controller {
4
4
  static targets = [
@@ -0,0 +1,17 @@
1
+ import { Controller } from "stimulus";
2
+ import zxcvbn from "zxcvbn";
3
+
4
+ export default class extends Controller {
5
+ static targets = ["strengthIndicator"];
6
+
7
+ estimateStrength(e) {
8
+ const result = zxcvbn(e.target.value);
9
+
10
+ if (result.feedback) {
11
+ this.strengthIndicatorTarget.innerText = result.feedback.warning;
12
+ this.strengthIndicatorTarget.classList.remove("hidden");
13
+ } else {
14
+ this.strengthIndicatorTarget.classList.add("hidden");
15
+ }
16
+ }
17
+ }
@@ -1,4 +1,4 @@
1
- import { Controller } from "stimulus"
1
+ import { Controller } from "@hotwired/stimulus"
2
2
  require("intl-tel-input/build/css/intlTelInput.css");
3
3
  import intlTelInput from 'intl-tel-input';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Controller } from "stimulus"
1
+ import { Controller } from "@hotwired/stimulus"
2
2
  require("select2/dist/css/select2.min.css");
3
3
  import select2 from "select2";
4
4
 
@@ -9,8 +9,13 @@ export default class extends Controller {
9
9
  enableSearch: Boolean,
10
10
  searchUrl: String,
11
11
  }
12
+
13
+ // will be reissued as native dom events name prepended with '$' e.g. '$change', '$select2:closing', etc
14
+ static jQueryEventsToReissue = [ "change", "select2:closing", "select2:close", "select2:opening", "select2:open", "select2:selecting", "select2:select", "select2:unselecting", "select2:unselect", "select2:clearing", "select2:clear" ]
15
+
12
16
 
13
17
  initialize() {
18
+ this.dispatchNativeEvent = this.dispatchNativeEvent.bind(this)
14
19
  if (this.isSelect2LoadedOnWindowJquery) {
15
20
  select2(window.$)
16
21
  }
@@ -66,15 +71,37 @@ export default class extends Controller {
66
71
  this.cleanupBeforeInit() // in case improperly torn down
67
72
  this.pluginMainEl = this.selectTarget // required because this.selectTarget is unavailable on disconnect()
68
73
  $(this.pluginMainEl).select2(options);
74
+
75
+ this.initReissuePluginEventsAsNativeEvents()
69
76
  }
70
77
 
71
78
  teardownPluginInstance() {
72
79
  if (this.pluginMainEl === undefined) { return }
73
80
 
81
+ // ensure there are no orphaned event handlers
82
+ this.teardownPluginEventsAsNativeEvents()
83
+
74
84
  // revert to original markup, remove any event listeners
75
85
  $(this.pluginMainEl).select2('destroy');
76
86
  }
77
87
 
88
+ initReissuePluginEventsAsNativeEvents() {
89
+ this.constructor.jQueryEventsToReissue.forEach((eventName) => {
90
+ $(this.pluginMainEl).on(eventName, this.dispatchNativeEvent)
91
+ })
92
+ }
93
+
94
+ teardownPluginEventsAsNativeEvents() {
95
+ this.constructor.jQueryEventsToReissue.forEach((eventName) => {
96
+ $(this.pluginMainEl).off(eventName)
97
+ })
98
+ }
99
+
100
+ dispatchNativeEvent(event) {
101
+ const nativeEventName = '$' + event.type // e.g. '$change.select2'
102
+ this.element.dispatchEvent(new CustomEvent(nativeEventName, { detail: { event: event }, bubbles: true, cancelable: false }))
103
+ }
104
+
78
105
  // https://stackoverflow.com/questions/29290389/select2-add-image-icon-to-option-dynamically
79
106
  formatState(opt) {
80
107
  var imageUrl = $(opt.element).attr('data-image');
@@ -82,6 +109,13 @@ export default class extends Controller {
82
109
  if (imageUrl) {
83
110
  imageHtml = '<img src="' + imageUrl + '" /> ';
84
111
  }
85
- return $('<span>' + imageHtml + opt.text + '</span>');
112
+ return $('<span>' + imageHtml + sanitizeHTML(opt.text) + '</span>');
86
113
  }
87
114
  }
115
+
116
+ // https://portswigger.net/web-security/cross-site-scripting/preventing
117
+ function sanitizeHTML(str) {
118
+ return str.replace(/[^\w. ]/gi, function (c) {
119
+ return '&#' + c.charCodeAt(0) + ';';
120
+ });
121
+ };
@@ -1,10 +1,11 @@
1
- import { identifierForContextKey } from "@stimulus/webpack-helpers"
1
+ import { identifierForContextKey } from "@hotwired/stimulus-webpack-helpers"
2
2
 
3
3
  import ButtonToggleController from './fields/button_toggle_controller'
4
4
  import CloudinaryImageController from './fields/cloudinary_image_controller'
5
5
  import ColorPickerController from './fields/color_picker_controller'
6
6
  import DateController from './fields/date_controller'
7
7
  import FileFieldController from './fields/file_field_controller'
8
+ import PasswordController from './fields/password_controller'
8
9
  import PhoneController from './fields/phone_controller'
9
10
  import SuperSelectController from './fields/super_select_controller'
10
11
 
@@ -14,8 +15,9 @@ export const controllerDefinitions = [
14
15
  [ColorPickerController, 'fields/color_picker_controller.js'],
15
16
  [DateController, 'fields/date_controller.js'],
16
17
  [FileFieldController, 'fields/file_field_controller.js'],
18
+ [PasswordController, 'fields/password_controller.js'],
17
19
  [PhoneController, 'fields/phone_controller.js'],
18
- [SuperSelectController, 'fields/super_select_controller.js']
20
+ [SuperSelectController, 'fields/super_select_controller.js'],
19
21
  ].map(function(d) {
20
22
  const key = d[1]
21
23
  const controller = d[0]
@@ -31,6 +33,7 @@ export {
31
33
  ColorPickerController,
32
34
  DateController,
33
35
  FileFieldController,
36
+ PasswordController,
34
37
  PhoneController,
35
- SuperSelectController
38
+ SuperSelectController,
36
39
  }
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Fields
3
- VERSION = "1.0.7"
3
+ VERSION = "1.0.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-31 00:00:00.000000000 Z
11
+ date: 2022-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -77,15 +77,6 @@ files:
77
77
  - README.md
78
78
  - Rakefile
79
79
  - app/assets/config/bullet_train_fields_manifest.js
80
- - app/assets/javascripts/fields.esm.js
81
- - app/assets/javascripts/fields.esm.js.map
82
- - app/assets/javascripts/fields.js
83
- - app/assets/javascripts/fields.js.map
84
- - app/assets/javascripts/fields.modern.js
85
- - app/assets/javascripts/fields.modern.js.map
86
- - app/assets/javascripts/fields.umd.js
87
- - app/assets/javascripts/fields.umd.js.map
88
- - app/assets/javascripts/intl-tel-input-utils.js
89
80
  - app/controllers/account/cloudinary/upload_signatures_controller.rb
90
81
  - app/controllers/concerns/fields/boolean_support.rb
91
82
  - app/controllers/concerns/fields/controller_support.rb
@@ -103,6 +94,7 @@ files:
103
94
  - app/javascript/controllers/fields/color_picker_controller.js
104
95
  - app/javascript/controllers/fields/date_controller.js
105
96
  - app/javascript/controllers/fields/file_field_controller.js
97
+ - app/javascript/controllers/fields/password_controller.js
106
98
  - app/javascript/controllers/fields/phone_controller.js
107
99
  - app/javascript/controllers/fields/super_select_controller.js
108
100
  - app/javascript/controllers/index.js
@@ -1,2 +0,0 @@
1
- import{Controller as e}from"stimulus";import"@simonwep/pickr/dist/themes/monolith.min.css";import t from"@simonwep/pickr";import"daterangepicker";import i from"intl-tel-input";import n from"select2";import r from"tributejs";function a(e){var t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t)}function l(e,t){return l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},l(e,t)}var s=function(e){function t(){return e.apply(this,arguments)||this}return o(t,e),t.prototype.clickShadowField=function(e){e.preventDefault(),this.shadowFieldTarget.click()},t}(e);s.targets=["shadowField"];var u=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var i=t.prototype;return i.pickImageAndUpload=function(e){e.preventDefault();var t=["local","url","camera"];this.hasGoogleApiKeyValue&&t.push("image_search");var i={cloud_name:this.cloudNameValue,apiKey:this.apiKeyValue,upload_preset:this.uploadPresetValue,upload_signature:this.getCloudinarySignature.bind(this),multiple:!1,sources:this.hasSourcesValue?this.sourcesValue.split(","):t,search_by_rights:!this.hasSearchByRightsValue||!1!==this.searchByRightsValue};this.hasGoogleApiKeyValue&&(i.google_api_key=this.googleApiKeyValue),cloudinary.openUploadWidget(i,this.handleWidgetResponse.bind(this))},i.clearImage=function(e){e.preventDefault(),this.hiddenFieldTarget.value=null,this.removeThumbnail()},i.getCloudinarySignature=function(e,t){$.ajax({url:this.signaturesUrlValue,type:"GET",dataType:"text",data:{data:t},complete:function(){console.log("complete")},success:function(t,i,n){e(t)},error:function(e,t,i){console.log(e,t,i)}})},i.handleWidgetResponse=function(e,t){if(!e&&t&&"success"===t.event){var i=t.info;this.hiddenFieldTarget.value=i.public_id,this.removeThumbnail(),this.addThumbnail(this.urlFormatValue.replace("CLOUDINARY_ID",i.public_id))}},i.addThumbnail=function(e){var t=$('<img src="'+e+'" width="'+this.widthValue+'" height="'+this.heightValue+'" data-'+this.identifier+'-target="thumbnail" />');$(this.uploadButtonTarget).prepend(t),this.uploadButtonTarget.classList.add(this.thumbnailShownClass)},i.removeThumbnail=function(){this.hasThumbnailTarget&&(this.uploadButtonTarget.removeChild(this.thumbnailTarget),this.uploadButtonTarget.classList.remove(this.thumbnailShownClass))},t}(e);u.targets=["uploadButton","hiddenField","thumbnail"],u.values={signaturesUrl:String,height:Number,width:Number,cloudName:String,apiKey:String,googleApiKey:String,urlFormat:String,sources:String,searchByRights:Boolean},u.classes=["thumbnailShown"];var c=function(e){function i(){return e.apply(this,arguments)||this}o(i,e);var n=i.prototype;return n.connect=function(){this.initPluginInstance(),this.colorOptions=$(this.colorOptionsTarget).find("button").map(function(e,t){return $(t).attr("data-color")}).get()},n.disconnect=function(){this.teardownPluginInstance()},n.pickColor=function(e){e.preventDefault();var t=e.target,i=t.dataset.color;$(this.colorInputTarget).val(i),$(this.colorPickerValueTarget).val(i),$(this.userSelectedColorTarget).data("color",i),$(".button-color").removeClass("ring-2 ring-offset-2"),this.pickr.setColor(i),t.classList.add("ring-2","ring-offset-2")},n.pickRandomColor=function(e){e.preventDefault();var t=Math.floor(256*Math.random()),i=Math.floor(256*Math.random()),n=Math.floor(256*Math.random());this.pickr.setColor("rgb "+t+" "+i+" "+n);var r=this.pickr.getColor().toHEXA().toString();this.pickr.setColor(r),this.showUserSelectedColor(r)},n.showUserSelectedColor=function(e){$(this.colorInputTarget).val(e),$(this.colorPickerValueTarget).val(e),$(".button-color").removeClass("ring-2 ring-offset-2"),$(this.userSelectedColorTarget).addClass("ring-2").addClass("ring-offset-2").css("background-color",e).css("--tw-ring-color",e).attr("data-color",e).show()},n.unpickColor=function(e){e.preventDefault(),$(this.colorPickerValueTarget).val(""),$(this.colorInputTarget).val(""),$(this.userSelectedColorTarget).hide(),$(".button-color").removeClass("ring-2 ring-offset-2")},n.togglePickr=function(e){e.preventDefault()},n.initPluginInstance=function(){var e=this;this.pickr=t.create({el:".btn-pickr",theme:"monolith",useAsButton:!0,default:this.initialColorValue||"#1E90FF",components:{preview:!0,hue:!0,interaction:{input:!0,save:!0}}}),this.pickr.on("save",function(t,i){var n=t.toHEXA().toString();e.colorOptions.includes(n)||e.showUserSelectedColor(n),e.pickr.hide()});var i=this;$('input[type="text"].pcr-result').on("keydown",function(e){"Enter"===e.key&&i.pickr.applyColor(!1)})},n.teardownPluginInstance=function(){this.pickr.destroy()},i}(e);c.targets=["colorPickerValue","colorField","colorInput","userSelectedColor","colorOptions"],c.values={initialColor:String},require("daterangepicker/daterangepicker.css");var d=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var i=t.prototype;return i.connect=function(){this.initPluginInstance()},i.disconnect=function(){this.teardownPluginInstance()},i.clearDate=function(e){e.preventDefault(),$(this.fieldTarget).val("")},i.applyDateToField=function(e,t){var i=this.includeTimeValue?"MM/DD/YYYY h:mm A":"MM/DD/YYYY";$(this.fieldTarget).val(t.startDate.format(i))},i.showTimeZoneButtons=function(e){e.preventDefault(),$(this.currentTimeZoneWrapperTarget).toggleClass("hidden"),$(this.timeZoneButtonsTarget).toggleClass("hidden")},i.showTimeZoneSelectWrapper=function(e){e.preventDefault(),$(this.timeZoneButtonsTarget).toggleClass("hidden"),this.hasTimeZoneSelectWrapperTarget&&$(this.timeZoneSelectWrapperTarget).toggleClass("hidden")},i.resetTimeZoneUI=function(e){e&&e.preventDefault(),$(this.currentTimeZoneWrapperTarget).removeClass("hidden"),$(this.timeZoneButtonsTarget).addClass("hidden"),this.hasTimeZoneSelectWrapperTarget&&$(this.timeZoneSelectWrapperTarget).addClass("hidden")},i.setTimeZone=function(e){e.preventDefault();var t=this.currentTimeZoneWrapperTarget.querySelector("a"),i=e.target.dataset.value;$(this.timeZoneFieldTarget).val(i),$(t).text(i),$(".time-zone-button").removeClass("button").addClass("button-alternative"),$(e.target).removeClass("button-alternative").addClass("button"),this.resetTimeZoneUI()},i.initPluginInstance=function(){if($(this.fieldTarget).daterangepicker({singleDatePicker:!0,timePicker:this.includeTimeValue,timePickerIncrement:5,autoUpdateInput:!1,locale:{cancelLabel:this.hasCancelButtonLabelValue?this.cancelButtonLabelValue:"cancel",applyLabel:this.hasApplyButtonLabelValue?this.applyButtonLabelValue:"apply",format:this.includeTimeValue?"MM/DD/YYYY h:mm A":"MM/DD/YYYY"}}),$(this.fieldTarget).on("apply.daterangepicker",this.applyDateToField.bind(this)),$(this.fieldTarget).on("cancel.daterangepicker",this.clearDate.bind(this)),this.pluginMainEl=this.fieldTarget,this.plugin=$(this.pluginMainEl).data("daterangepicker"),this.includeTimeValue&&this.hasTimeZoneSelectWrapperTarget){this.timeZoneSelect=this.timeZoneSelectWrapperTarget.querySelector("select.select2"),$(this.timeZoneSelect).select2({width:"style"});var e=this;$(this.timeZoneSelect).on("change.select2",function(t){var i=e.currentTimeZoneWrapperTarget.querySelector("a"),n=t.target.value;$(e.timeZoneFieldTarget).val(n),$(i).text(n);var r=$(".selected-option-time-zone-button");e.defaultTimeZonesValue.includes(n)?($(".time-zone-button").removeClass("button").addClass("button-alternative"),r.addClass("hidden").attr("hidden",!0),$('a[data-value="'+n+'"').removeClass("button-alternative").addClass("button")):($(".time-zone-button").removeClass("button").addClass("button-alternative"),r.text(n),r.attr("data-value",n).removeAttr("hidden"),r.removeClass(["hidden","button-alternative"]).addClass("button")),e.resetTimeZoneUI()})}},i.teardownPluginInstance=function(){void 0!==this.plugin&&($(this.pluginMainEl).off("apply.daterangepicker"),$(this.pluginMainEl).off("cancel.daterangepicker"),this.plugin.remove(),this.includeTimeValue&&$(this.timeZoneSelect).select2("destroy"))},t}(e);d.targets=["field","clearButton","currentTimeZoneWrapper","timeZoneButtons","timeZoneSelectWrapper","timeZoneField"],d.values={includeTime:Boolean,defaultTimeZones:Array,cancelButtonLabel:String,applyButtonLabel:String};var h=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var i=t.prototype;return i.connect=function(){var e=this,t=document.addEventListener("direct-upload:initialize",function(t){e.selectFileButtonTarget.classList.add("hidden"),e.progressBarTarget.innerText="0%",e.progressBarTarget.style.width="0%",e.progressBarTarget.setAttribute("aria-valuenow",0),e.progressBarTarget.parentNode.classList.remove("hidden")}),i=document.addEventListener("direct-upload:progress",function(t){var i=t.detail.progress,n=i.toFixed(1)+"%";e.progressBarTarget.innerText=n,e.progressBarTarget.setAttribute("aria-valuenow",i),e.progressBarTarget.style.width=n}),n=document.addEventListener("direct-upload:error",function(t){t.preventDefault(),e.progressBarTarget.innerText=t.detail.error});this.uploadListeners={"direct-upload:initialize":t,"direct-upload:progress":i,"direct-upload:error":n}},i.disconnect=function(){for(var e in this.uploadListeners)document.removeEventListener(e,this.uploadListeners[e])},i.uploadFile=function(){this.fileFieldTarget.click()},i.removeFile=function(){this.hasDownloadFileButtonTarget&&this.downloadFileButtonTarget.classList.add("hidden"),this.removeFileButtonTarget.classList.add("hidden"),this.removeFileFlagTarget.value=!0},i.handleFileSelected=function(){var e=this.selectFileButtonTarget.querySelector("span"),t=this.selectFileButtonTarget.querySelector("i");this.hasDownloadFileButtonTarget&&this.downloadFileButtonTarget.remove(),e.innerText="Select Another File",t.classList.remove("ti-upload"),t.classList.add("ti-check")},t}(e);h.targets=["fileField","removeFileFlag","downloadFileButton","removeFileButton","selectFileButton","progressBar"],require("intl-tel-input/build/css/intlTelInput.css");var p=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var n=t.prototype;return n.connect=function(){this.initPluginInstance()},n.disconnect=function(){this.teardownPluginInstance()},n.initPluginInstance=function(){var e,t={hiddenInput:this.fieldTarget.dataset.method,customContainer:"w-full"},n=(e=document.head.querySelector('meta[name="intl_tel_input_utils_path"]'))&&e.content;n&&(t.utilsScript=n),this.plugin=i(this.fieldTarget,t)},n.teardownPluginInstance=function(){void 0!==this.plugin&&this.plugin.destroy()},t}(e);p.targets=["field"],require("select2/dist/css/select2.min.css");var g=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var i,r,a=t.prototype;return a.initialize=function(){this.isSelect2LoadedOnWindowJquery&&n(window.$)},a.connect=function(){this.isSelect2LoadedOnWindowJquery&&this.initPluginInstance()},a.disconnect=function(){this.teardownPluginInstance()},a.cleanupBeforeInit=function(){$(this.element).find(".select2-container--default").remove()},a.initPluginInstance=function(){var e={};this.enableSearchValue||(e.minimumResultsForSearch=-1),e.tags=this.acceptsNewValue,this.searchUrlValue&&(e.ajax={url:this.searchUrlValue,dataType:"json",data:function(e){return{search:e.term,page:e.page||1}}}),e.templateResult=this.formatState,e.templateSelection=this.formatState,e.width="style",this.cleanupBeforeInit(),this.pluginMainEl=this.selectTarget,$(this.pluginMainEl).select2(e)},a.teardownPluginInstance=function(){void 0!==this.pluginMainEl&&$(this.pluginMainEl).select2("destroy")},a.formatState=function(e){var t=$(e.element).attr("data-image"),i="";return t&&(i='<img src="'+t+'" /> '),$("<span>"+i+e.text+"</span>")},i=t,(r=[{key:"isSelect2LoadedOnWindowJquery",get:function(){return void 0!==window.$&&void 0===window.$.select2}}])&&function(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),t}(e);g.targets=["select"],g.values={acceptsNew:Boolean,enableSearch:Boolean,searchUrl:String};var m=[[s,"fields/button_toggle_controller.js"],[u,"fields/cloudinary_image_controller.js"],[c,"fields/color_picker_controller.js"],[d,"fields/date_controller.js"],[h,"fields/file_field_controller.js"],[p,"fields/phone_controller.js"],[g,"fields/super_select_controller.js"]].map(function(e){var t=e[0];return{identifier:a(e[1]),controllerConstructor:t}});function f(){document.addEventListener("trix-initialize",function(){addEventListener("trix-focus",v),addEventListener("trix-blur",v),v(),document.querySelectorAll("trix-editor").forEach(function(e,t){var i=e.editor,n={trigger:"@",values:JSON.parse(i.element.dataset.mentions),selectTemplate:function(e){return'<a href="'+(e=e.original).protocol+"://"+e.model+"/"+e.id+'">'+e.label+"</a>"},menuItemTemplate:function(e){return'<img src="'+e.original.photo+'" /> '+e.string},requireLeadingSpace:!0,replaceTextSuffix:""},a={trigger:"#",values:JSON.parse(i.element.dataset.topics),selectTemplate:function(e){return'<a href="'+(e=e.original).protocol+"://"+e.model+"/"+e.id+'">'+e.label+"</a>"},menuItemTemplate:function(e){return'<img src="'+e.original.photo+'" /> '+e.string},requireLeadingSpace:!0,replaceTextSuffix:""};new r({collection:[a,n]}).attach(e)})})}function v(){document.querySelectorAll("trix-editor").forEach(function(e,t){var i=e.toolbarElement;e==document.activeElement?i.classList.add("visible"):i.contains(document.activeElement)||i.classList.remove("visible")})}require("trix/dist/trix.css"),require("trix"),require("@rails/actiontext");export{s as ButtonToggleController,u as CloudinaryImageController,c as ColorPickerController,d as DateController,h as FileFieldController,p as PhoneController,g as SuperSelectController,m as controllerDefinitions,f as trixEditor};
2
- //# sourceMappingURL=fields.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fields.esm.js","sources":["../../../node_modules/@stimulus/webpack-helpers/dist/index.js","../../javascript/controllers/fields/button_toggle_controller.js","../../javascript/controllers/fields/cloudinary_image_controller.js","../../javascript/controllers/fields/color_picker_controller.js","../../javascript/controllers/fields/date_controller.js","../../javascript/controllers/fields/file_field_controller.js","../../javascript/controllers/fields/phone_controller.js","../../javascript/controllers/fields/super_select_controller.js","../../javascript/controllers/index.js","../../javascript/trix_editor.js"],"sourcesContent":["export function definitionsFromContext(context) {\n return context.keys()\n .map(function (key) { return definitionForModuleWithContextAndKey(context, key); })\n .filter(function (value) { return value; });\n}\nfunction definitionForModuleWithContextAndKey(context, key) {\n var identifier = identifierForContextKey(key);\n if (identifier) {\n return definitionForModuleAndIdentifier(context(key), identifier);\n }\n}\nfunction definitionForModuleAndIdentifier(module, identifier) {\n var controllerConstructor = module.default;\n if (typeof controllerConstructor == \"function\") {\n return { identifier: identifier, controllerConstructor: controllerConstructor };\n }\n}\nexport function identifierForContextKey(key) {\n var logicalName = (key.match(/^(?:\\.\\/)?(.+)(?:[_-]controller\\..+?)$/) || [])[1];\n if (logicalName) {\n return logicalName.replace(/_/g, \"-\").replace(/\\//g, \"--\");\n }\n}\n//# sourceMappingURL=index.js.map","import { Controller } from \"stimulus\"\n\nexport default class extends Controller {\n static targets = [ \"shadowField\" ]\n\n clickShadowField(event) {\n // we have to stop safari from doing what we originally expected.\n event.preventDefault();\n\n // then we need to manually click the hidden checkbox or radio button ourselves.\n this.shadowFieldTarget.click()\n }\n}","import { Controller } from \"stimulus\"\n\nexport default class extends Controller {\n static targets = [ \"uploadButton\", \"hiddenField\", \"thumbnail\" ]\n static values = { \n signaturesUrl: String,\n height: Number,\n width: Number,\n cloudName: String,\n apiKey: String,\n googleApiKey: String,\n urlFormat: String,\n sources: String,\n searchByRights: Boolean\n }\n static classes = [ \"thumbnailShown\" ]\n\n pickImageAndUpload(event) {\n // don't submit the form.\n event.preventDefault()\n\n // prepare the list of default sources a user can upload an image from.\n var defaultSources = ['local', 'url', 'camera']\n if (this.hasGoogleApiKeyValue) {\n defaultSources.push('image_search')\n }\n\n // configure cloudinary's uploader's options.\n // many of these are configurable at the point where the `shared/fields/cloudinary_image` partial is included.\n var options = {\n cloud_name: this.cloudNameValue,\n apiKey: this.apiKeyValue,\n upload_preset: this.uploadPresetValue,\n upload_signature: this.getCloudinarySignature.bind(this),\n multiple: false,\n sources: this.hasSourcesValue ? this.sourcesValue.split(',') : defaultSources,\n search_by_rights: this.hasSearchByRightsValue && this.searchByRightsValue === false ? false : true // default to true.\n }\n \n if (this.hasGoogleApiKeyValue) {\n options['google_api_key'] = this.googleApiKeyValue\n }\n \n // open cloudinary's upload widget.\n cloudinary.openUploadWidget(options, this.handleWidgetResponse.bind(this))\n }\n \n clearImage(event) {\n // don't submit the form.\n event.preventDefault()\n\n // clear the cloudinary id.\n this.hiddenFieldTarget.value = null\n \n // remove any existing image from the button.\n this.removeThumbnail()\n }\n \n getCloudinarySignature(callback, paramsToSign) {\n $.ajax({\n url: this.signaturesUrlValue,\n type: \"GET\",\n dataType: \"text\",\n data: {data: paramsToSign},\n complete: function() { console.log(\"complete\") },\n success: function(signature, textStatus, xhr) { callback(signature) },\n error: function(xhr, status, error) { console.log(xhr, status, error) }\n })\n }\n \n handleWidgetResponse(error, response) {\n // after the user has successfully uploaded a single file ..\n if (!error && response && response.event === \"success\") { \n const data = response.info\n \n // update the cloudinary id field in the form.\n this.hiddenFieldTarget.value = data.public_id\n\n // remove any existing image.\n this.removeThumbnail()\n\n // generate a new image preview url.\n this.addThumbnail(this.urlFormatValue.replace('CLOUDINARY_ID', data.public_id))\n }\n }\n \n addThumbnail(url) {\n var $imageElement = $(`<img src=\"${url}\" width=\"${this.widthValue}\" height=\"${this.heightValue}\" data-${this.identifier}-target=\"thumbnail\" />`)\n $(this.uploadButtonTarget).prepend($imageElement)\n\n // mark the image as present.\n this.uploadButtonTarget.classList.add(this.thumbnailShownClass)\n }\n \n removeThumbnail() {\n if (!this.hasThumbnailTarget) { return }\n this.uploadButtonTarget.removeChild(this.thumbnailTarget)\n this.uploadButtonTarget.classList.remove(this.thumbnailShownClass)\n }\n}\n","import { Controller } from \"stimulus\"\nimport '@simonwep/pickr/dist/themes/monolith.min.css'\n\nimport Pickr from '@simonwep/pickr';\n\nexport default class extends Controller {\n static targets = [ \"colorPickerValue\", \"colorField\", \"colorInput\", \"userSelectedColor\", \"colorOptions\" ];\n static values = { initialColor: String }\n\n connect() {\n this.initPluginInstance()\n this.colorOptions = $(this.colorOptionsTarget).find('button').map(function (_, button) { return $(button).attr('data-color'); }).get()\n }\n\n disconnect() {\n this.teardownPluginInstance()\n }\n\n pickColor(event) {\n event.preventDefault();\n\n const targetEl = event.target;\n const color = targetEl.dataset.color;\n\n $(this.colorInputTarget).val(color);\n $(this.colorPickerValueTarget).val(color);\n $(this.userSelectedColorTarget).data('color', color);\n $('.button-color').removeClass('ring-2 ring-offset-2');\n\n this.pickr.setColor(color);\n\n targetEl.classList.add('ring-2', 'ring-offset-2');\n }\n\n pickRandomColor(event) {\n event.preventDefault();\n\n const r = Math.floor(Math.random() * 256);\n const g = Math.floor(Math.random() * 256);\n const b = Math.floor(Math.random() * 256);\n\n this.pickr.setColor(`rgb ${r} ${g} ${b}`);\n const hexColor = this.pickr.getColor().toHEXA().toString();\n this.pickr.setColor(hexColor);\n\n this.showUserSelectedColor(hexColor);\n }\n\n showUserSelectedColor(color) {\n $(this.colorInputTarget).val(color);\n $(this.colorPickerValueTarget).val(color);\n\n $('.button-color').removeClass('ring-2 ring-offset-2');\n\n $(this.userSelectedColorTarget)\n .addClass('ring-2')\n .addClass('ring-offset-2')\n .css('background-color', color)\n .css('--tw-ring-color', color)\n .attr('data-color', color)\n .show();\n }\n\n unpickColor(event) {\n event.preventDefault();\n $(this.colorPickerValueTarget).val('');\n $(this.colorInputTarget).val('');\n $(this.userSelectedColorTarget).hide();\n $('.button-color').removeClass('ring-2 ring-offset-2');\n }\n\n togglePickr(event) {\n event.preventDefault();\n }\n\n initPluginInstance() {\n this.pickr = Pickr.create({\n el: '.btn-pickr',\n theme: 'monolith',\n useAsButton: true,\n default: this.initialColorValue || '#1E90FF',\n components: {\n // Main components\n preview: true,\n hue: true,\n\n // Input / output Options\n interaction: {\n input: true,\n save: true,\n },\n }\n });\n\n this.pickr.on('save', (color, _instance) => {\n const hexaColor = color.toHEXA().toString()\n if (!this.colorOptions.includes(hexaColor)) {\n this.showUserSelectedColor(hexaColor);\n }\n this.pickr.hide();\n });\n\n const that = this\n\n $('input[type=\"text\"].pcr-result').on('keydown', function (e) {\n if (e.key === 'Enter') {\n that.pickr.applyColor(false)\n }\n })\n }\n\n teardownPluginInstance() {\n this.pickr.destroy()\n }\n}\n","import { Controller } from \"stimulus\"\nrequire(\"daterangepicker/daterangepicker.css\");\n\n// requires jQuery, moment, might want to consider a vanilla JS alternative\nimport 'daterangepicker';\n\nexport default class extends Controller {\n static targets = [ \"field\", \"clearButton\", \"currentTimeZoneWrapper\", \"timeZoneButtons\", \"timeZoneSelectWrapper\", \"timeZoneField\" ]\n static values = {\n includeTime: Boolean,\n defaultTimeZones: Array,\n cancelButtonLabel: String,\n applyButtonLabel: String\n }\n\n connect() {\n this.initPluginInstance()\n }\n\n disconnect() {\n this.teardownPluginInstance()\n }\n\n clearDate(event) {\n // don't submit the form, unless it originated from the cancel/clear button\n event.preventDefault()\n\n $(this.fieldTarget).val('')\n }\n\n applyDateToField(event, picker) {\n const format = this.includeTimeValue ? 'MM/DD/YYYY h:mm A' : 'MM/DD/YYYY'\n $(this.fieldTarget).val(picker.startDate.format(format))\n }\n\n showTimeZoneButtons(event) {\n // don't follow the anchor\n event.preventDefault()\n\n $(this.currentTimeZoneWrapperTarget).toggleClass('hidden')\n $(this.timeZoneButtonsTarget).toggleClass('hidden')\n }\n\n showTimeZoneSelectWrapper(event) {\n // don't follow the anchor\n event.preventDefault()\n\n $(this.timeZoneButtonsTarget).toggleClass('hidden')\n\n if (this.hasTimeZoneSelectWrapperTarget) {\n $(this.timeZoneSelectWrapperTarget).toggleClass('hidden')\n }\n }\n\n resetTimeZoneUI(e) {\n e && e.preventDefault()\n\n $(this.currentTimeZoneWrapperTarget).removeClass('hidden')\n $(this.timeZoneButtonsTarget).addClass('hidden')\n\n if (this.hasTimeZoneSelectWrapperTarget) {\n $(this.timeZoneSelectWrapperTarget).addClass('hidden')\n }\n }\n\n setTimeZone(event) {\n // don't follow the anchor\n event.preventDefault()\n\n const currentTimeZoneEl = this.currentTimeZoneWrapperTarget.querySelector('a')\n const {value} = event.target.dataset\n\n $(this.timeZoneFieldTarget).val(value)\n $(currentTimeZoneEl).text(value)\n\n $('.time-zone-button').removeClass('button').addClass('button-alternative')\n $(event.target).removeClass('button-alternative').addClass('button')\n\n this.resetTimeZoneUI()\n }\n\n initPluginInstance() {\n $(this.fieldTarget).daterangepicker({\n singleDatePicker: true,\n timePicker: this.includeTimeValue,\n timePickerIncrement: 5,\n autoUpdateInput: false,\n locale: {\n cancelLabel: (this.hasCancelButtonLabelValue)? this.cancelButtonLabelValue: \"cancel\",\n applyLabel: (this.hasApplyButtonLabelValue)? this.applyButtonLabelValue: \"apply\",\n format: this.includeTimeValue ? 'MM/DD/YYYY h:mm A' : 'MM/DD/YYYY'\n }\n })\n\n $(this.fieldTarget).on('apply.daterangepicker', this.applyDateToField.bind(this))\n $(this.fieldTarget).on('cancel.daterangepicker', this.clearDate.bind(this))\n\n this.pluginMainEl = this.fieldTarget\n this.plugin = $(this.pluginMainEl).data('daterangepicker') // weird\n\n // Init time zone select\n if (this.includeTimeValue && this.hasTimeZoneSelectWrapperTarget) {\n this.timeZoneSelect = this.timeZoneSelectWrapperTarget.querySelector('select.select2')\n\n $(this.timeZoneSelect).select2({\n width: 'style'\n })\n\n const self = this\n\n $(this.timeZoneSelect).on('change.select2', function(event) {\n const currentTimeZoneEl = self.currentTimeZoneWrapperTarget.querySelector('a')\n const {value} = event.target\n\n $(self.timeZoneFieldTarget).val(value)\n $(currentTimeZoneEl).text(value)\n\n const selectedOptionTimeZoneButton = $('.selected-option-time-zone-button')\n\n if (self.defaultTimeZonesValue.includes(value)) {\n $('.time-zone-button').removeClass('button').addClass('button-alternative')\n selectedOptionTimeZoneButton.addClass('hidden').attr('hidden', true)\n $(`a[data-value=\"${value}\"`).removeClass('button-alternative').addClass('button')\n } else {\n // deselect any selected button\n $('.time-zone-button').removeClass('button').addClass('button-alternative')\n\n selectedOptionTimeZoneButton.text(value)\n selectedOptionTimeZoneButton.attr('data-value', value).removeAttr('hidden')\n selectedOptionTimeZoneButton.removeClass(['hidden', 'button-alternative']).addClass('button')\n }\n\n self.resetTimeZoneUI()\n })\n }\n }\n\n teardownPluginInstance() {\n if (this.plugin === undefined) { return }\n\n $(this.pluginMainEl).off('apply.daterangepicker')\n $(this.pluginMainEl).off('cancel.daterangepicker')\n\n // revert to original markup, remove any event listeners\n this.plugin.remove()\n\n if (this.includeTimeValue) {\n $(this.timeZoneSelect).select2('destroy');\n }\n }\n}\n","import { Controller } from \"stimulus\";\n\nexport default class extends Controller {\n static targets = [\n \"fileField\",\n \"removeFileFlag\",\n \"downloadFileButton\",\n \"removeFileButton\",\n \"selectFileButton\",\n \"progressBar\",\n ];\n\n connect() {\n // Add upload event listeners\n const initializeListener = document.addEventListener(\n \"direct-upload:initialize\",\n (event) => {\n this.selectFileButtonTarget.classList.add(\"hidden\");\n this.progressBarTarget.innerText = \"0%\";\n this.progressBarTarget.style.width = \"0%\";\n this.progressBarTarget.setAttribute(\"aria-valuenow\", 0);\n this.progressBarTarget.parentNode.classList.remove(\"hidden\");\n }\n );\n\n const progressListener = document.addEventListener(\n \"direct-upload:progress\",\n (event) => {\n const { progress } = event.detail;\n const width = `${progress.toFixed(1)}%`;\n\n this.progressBarTarget.innerText = width;\n this.progressBarTarget.setAttribute(\"aria-valuenow\", progress);\n this.progressBarTarget.style.width = width;\n }\n );\n\n const errorListener = document.addEventListener(\n \"direct-upload:error\",\n (event) => {\n event.preventDefault();\n\n const { error } = event.detail;\n this.progressBarTarget.innerText = error;\n }\n );\n\n this.uploadListeners = {\n \"direct-upload:initialize\": initializeListener,\n \"direct-upload:progress\": progressListener,\n \"direct-upload:error\": errorListener,\n };\n }\n\n disconnect() {\n // Teardown event listeners\n for (const event in this.uploadListeners) {\n document.removeEventListener(event, this.uploadListeners[event]);\n }\n }\n\n uploadFile() {\n this.fileFieldTarget.click();\n }\n\n removeFile() {\n if (this.hasDownloadFileButtonTarget) {\n this.downloadFileButtonTarget.classList.add(\"hidden\");\n }\n\n this.removeFileButtonTarget.classList.add(\"hidden\");\n this.removeFileFlagTarget.value = true;\n }\n\n handleFileSelected() {\n const statusText = this.selectFileButtonTarget.querySelector(\"span\");\n const icon = this.selectFileButtonTarget.querySelector(\"i\");\n\n if (this.hasDownloadFileButtonTarget) {\n this.downloadFileButtonTarget.remove();\n }\n\n statusText.innerText = \"Select Another File\";\n icon.classList.remove(\"ti-upload\");\n icon.classList.add(\"ti-check\");\n }\n}\n","import { Controller } from \"stimulus\"\nrequire(\"intl-tel-input/build/css/intlTelInput.css\");\nimport intlTelInput from 'intl-tel-input';\n\nexport default class extends Controller {\n static targets = [ \"field\" ]\n\n connect() {\n this.initPluginInstance()\n }\n\n disconnect() {\n this.teardownPluginInstance()\n }\n\n initPluginInstance() {\n let options = {\n hiddenInput: this.fieldTarget.dataset.method,\n customContainer: \"w-full\"\n }\n\n // TODO: add instructions on how to copy this asset into the application's assets path and write the meta tag into the head (via the engine?)\n const utilsScriptPath = metaContent(\"intl_tel_input_utils_path\")\n if (utilsScriptPath) {\n options['utilsScript'] = utilsScriptPath\n }\n\n this.plugin = intlTelInput(this.fieldTarget, options);\n }\n\n teardownPluginInstance() {\n if (this.plugin === undefined) { return }\n\n // revert to original markup, remove any event listeners\n this.plugin.destroy()\n }\n}\n\nfunction metaContent (name) {\n const element = document.head.querySelector(`meta[name=\"${name}\"]`)\n return element && element.content\n}","import { Controller } from \"stimulus\"\nrequire(\"select2/dist/css/select2.min.css\");\nimport select2 from \"select2\";\n\nexport default class extends Controller {\n static targets = [ \"select\" ]\n static values = {\n acceptsNew: Boolean,\n enableSearch: Boolean,\n searchUrl: String,\n }\n\n initialize() {\n if (this.isSelect2LoadedOnWindowJquery) {\n select2(window.$)\n }\n }\n\n get isSelect2LoadedOnWindowJquery() {\n return (window.$ !== undefined && window.$.select2 === undefined)\n }\n\n connect() {\n if (this.isSelect2LoadedOnWindowJquery) {\n this.initPluginInstance()\n }\n }\n\n disconnect() {\n this.teardownPluginInstance()\n }\n\n cleanupBeforeInit() {\n $(this.element).find('.select2-container--default').remove()\n }\n\n initPluginInstance() {\n let options = {};\n\n if (!this.enableSearchValue) {\n options.minimumResultsForSearch = -1;\n }\n\n options.tags = this.acceptsNewValue\n\n if (this.searchUrlValue) {\n options.ajax = {\n url: this.searchUrlValue,\n dataType: 'json',\n // We enable pagination by default here\n data: function(params) {\n var query = {\n search: params.term,\n page: params.page || 1\n }\n return query\n }\n // Any additional params go here...\n }\n }\n\n options.templateResult = this.formatState;\n options.templateSelection = this.formatState;\n options.width = 'style';\n\n this.cleanupBeforeInit() // in case improperly torn down\n this.pluginMainEl = this.selectTarget // required because this.selectTarget is unavailable on disconnect()\n $(this.pluginMainEl).select2(options);\n }\n\n teardownPluginInstance() {\n if (this.pluginMainEl === undefined) { return }\n\n // revert to original markup, remove any event listeners\n $(this.pluginMainEl).select2('destroy');\n }\n\n // https://stackoverflow.com/questions/29290389/select2-add-image-icon-to-option-dynamically\n formatState(opt) {\n var imageUrl = $(opt.element).attr('data-image');\n var imageHtml = \"\";\n if (imageUrl) {\n imageHtml = '<img src=\"' + imageUrl + '\" /> ';\n }\n return $('<span>' + imageHtml + opt.text + '</span>');\n }\n}\n","import { identifierForContextKey } from \"@stimulus/webpack-helpers\"\n\nimport ButtonToggleController from './fields/button_toggle_controller'\nimport CloudinaryImageController from './fields/cloudinary_image_controller'\nimport ColorPickerController from './fields/color_picker_controller'\nimport DateController from './fields/date_controller'\nimport FileFieldController from './fields/file_field_controller'\nimport PhoneController from './fields/phone_controller'\nimport SuperSelectController from './fields/super_select_controller'\n\nexport const controllerDefinitions = [\n [ButtonToggleController, 'fields/button_toggle_controller.js'],\n [CloudinaryImageController, 'fields/cloudinary_image_controller.js'],\n [ColorPickerController, 'fields/color_picker_controller.js'],\n [DateController, 'fields/date_controller.js'],\n [FileFieldController, 'fields/file_field_controller.js'],\n [PhoneController, 'fields/phone_controller.js'],\n [SuperSelectController, 'fields/super_select_controller.js']\n].map(function(d) {\n const key = d[1]\n const controller = d[0]\n return {\n identifier: identifierForContextKey(key),\n controllerConstructor: controller\n }\n})\n\nexport {\n ButtonToggleController,\n CloudinaryImageController,\n ColorPickerController,\n DateController,\n FileFieldController,\n PhoneController,\n SuperSelectController\n}","import Tribute from 'tributejs'\nrequire(\"trix/dist/trix.css\");\n\nrequire(\"trix\")\nrequire(\"@rails/actiontext\")\n\n// only show the editor tool bar when the user is editing the field.\n// inspired by https://github.com/basecamp/trix/issues/343 and `app/assets/stylesheets/account/fields/trix_editor.scss`\n\nexport function trixEditor() {\n document.addEventListener('trix-initialize', function() {\n addEventListener(\"trix-focus\", updateTrixToolbarVisability);\n addEventListener(\"trix-blur\", updateTrixToolbarVisability);\n updateTrixToolbarVisability();\n initializeTribute();\n })\n}\n\nfunction updateTrixToolbarVisability() {\n document.querySelectorAll(\"trix-editor\").forEach((editorElement, index) => {\n var toolbarElement = editorElement.toolbarElement;\n if (editorElement == document.activeElement) {\n toolbarElement.classList.add('visible');\n } else {\n // don't hide the toolbar if we've unfocused to focus on the link dialog.\n if (!toolbarElement.contains(document.activeElement)) {\n toolbarElement.classList.remove('visible');\n }\n }\n })\n}\n\nfunction initializeTribute() {\n document.querySelectorAll(\"trix-editor\").forEach((el, index) => {\n var editor = el.editor;\n \n var mentionConfig = {\n trigger: '@',\n values: JSON.parse(editor.element.dataset.mentions),\n selectTemplate: function (item) {\n item = item.original;\n return '<a href=\"' + item.protocol + '://' + item.model + '/' + item.id + '\">' + item.label + '</a>';\n },\n menuItemTemplate: function (item) {\n return '<img src=\"' + item.original.photo + '\" /> ' + item.string;\n },\n requireLeadingSpace: true,\n replaceTextSuffix: ''\n }\n \n var topicConfig = {\n trigger: '#',\n values: JSON.parse(editor.element.dataset.topics),\n selectTemplate: function (item) {\n item = item.original;\n return '<a href=\"' + item.protocol + '://' + item.model + '/' + item.id + '\">' + item.label + '</a>';\n },\n menuItemTemplate: function (item) {\n return '<img src=\"' + item.original.photo + '\" /> ' + item.string;\n },\n requireLeadingSpace: true,\n replaceTextSuffix: ''\n }\n \n var tribute = new Tribute({\n collection: [topicConfig, mentionConfig],\n });\n \n tribute.attach(el);\n })\n}\n"],"names":["identifierForContextKey","key","logicalName","match","replace","clickShadowField","event","preventDefault","this","shadowFieldTarget","click","Controller","targets","pickImageAndUpload","defaultSources","hasGoogleApiKeyValue","push","options","cloud_name","cloudNameValue","apiKey","apiKeyValue","upload_preset","uploadPresetValue","upload_signature","getCloudinarySignature","bind","multiple","sources","hasSourcesValue","sourcesValue","split","search_by_rights","hasSearchByRightsValue","searchByRightsValue","googleApiKeyValue","cloudinary","openUploadWidget","handleWidgetResponse","clearImage","hiddenFieldTarget","value","removeThumbnail","callback","paramsToSign","$","ajax","url","signaturesUrlValue","type","dataType","data","complete","console","log","success","signature","textStatus","xhr","error","status","response","info","public_id","addThumbnail","urlFormatValue","$imageElement","widthValue","heightValue","identifier","uploadButtonTarget","prepend","classList","add","thumbnailShownClass","hasThumbnailTarget","removeChild","thumbnailTarget","remove","values","signaturesUrl","String","height","Number","width","cloudName","googleApiKey","urlFormat","searchByRights","Boolean","classes","connect","initPluginInstance","colorOptions","colorOptionsTarget","find","map","_","button","attr","get","disconnect","teardownPluginInstance","pickColor","targetEl","target","color","dataset","colorInputTarget","val","colorPickerValueTarget","userSelectedColorTarget","removeClass","pickr","setColor","pickRandomColor","r","Math","floor","random","g","b","hexColor","getColor","toHEXA","toString","showUserSelectedColor","addClass","css","show","unpickColor","hide","togglePickr","Pickr","create","el","theme","useAsButton","default","initialColorValue","components","preview","hue","interaction","input","save","on","_instance","hexaColor","_this","includes","that","e","applyColor","destroy","initialColor","require","clearDate","fieldTarget","applyDateToField","picker","format","includeTimeValue","startDate","showTimeZoneButtons","currentTimeZoneWrapperTarget","toggleClass","timeZoneButtonsTarget","showTimeZoneSelectWrapper","hasTimeZoneSelectWrapperTarget","timeZoneSelectWrapperTarget","resetTimeZoneUI","setTimeZone","currentTimeZoneEl","querySelector","timeZoneFieldTarget","text","daterangepicker","singleDatePicker","timePicker","timePickerIncrement","autoUpdateInput","locale","cancelLabel","hasCancelButtonLabelValue","cancelButtonLabelValue","applyLabel","hasApplyButtonLabelValue","applyButtonLabelValue","pluginMainEl","plugin","timeZoneSelect","select2","self","selectedOptionTimeZoneButton","defaultTimeZonesValue","removeAttr","undefined","off","includeTime","defaultTimeZones","Array","cancelButtonLabel","applyButtonLabel","initializeListener","document","addEventListener","selectFileButtonTarget","progressBarTarget","innerText","style","setAttribute","parentNode","progressListener","progress","detail","toFixed","errorListener","uploadListeners","removeEventListener","uploadFile","fileFieldTarget","removeFile","hasDownloadFileButtonTarget","downloadFileButtonTarget","removeFileButtonTarget","removeFileFlagTarget","handleFileSelected","statusText","icon","element","hiddenInput","method","customContainer","utilsScriptPath","head","content","intlTelInput","initialize","isSelect2LoadedOnWindowJquery","window","cleanupBeforeInit","enableSearchValue","minimumResultsForSearch","tags","acceptsNewValue","searchUrlValue","params","search","term","page","templateResult","formatState","templateSelection","selectTarget","opt","imageUrl","imageHtml","acceptsNew","enableSearch","searchUrl","controllerDefinitions","ButtonToggleController","CloudinaryImageController","ColorPickerController","DateController","FileFieldController","PhoneController","SuperSelectController","d","controller","controllerConstructor","trixEditor","updateTrixToolbarVisability","querySelectorAll","forEach","index","editor","mentionConfig","trigger","JSON","parse","mentions","selectTemplate","item","original","protocol","model","id","label","menuItemTemplate","photo","string","requireLeadingSpace","replaceTextSuffix","topicConfig","topics","Tribute","collection","attach","editorElement","toolbarElement","activeElement","contains"],"mappings":"gOAiBO,SAASA,EAAwBC,GACpC,IAAIC,GAAeD,EAAIE,MAAM,2CAA6C,IAAI,GAC9E,GAAID,EACA,OAAOA,EAAYE,QAAQ,KAAM,KAAKA,QAAQ,MAAO,yRCf3DC,iBAAA,SAAiBC,GAEfA,EAAMC,iBAGNC,KAAKC,kBAAkBC,YAREC,KACpBC,QAAU,CAAE,qHCcnBC,mBAAA,SAAmBP,GAEjBA,EAAMC,iBAGN,IAAIO,EAAiB,CAAC,QAAS,MAAO,UAClCN,KAAKO,sBACPD,EAAeE,KAAK,gBAKtB,IAAIC,EAAU,CACZC,WAAYV,KAAKW,eACjBC,OAAQZ,KAAKa,YACbC,cAAed,KAAKe,kBACpBC,iBAAkBhB,KAA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,MAAO,aADPA,EAAOA,EAAKC,UACcC,SAAW,MAAQF,EAAKG,MAAQ,IAAMH,EAAKI,GAAK,KAAOJ,EAAKK,MAAQ,QAEhGC,iBAAkB,SAAUN,GAC1B,MAAO,aAAeA,EAAKC,SAASM,MAAQ,QAAUP,EAAKQ,QAE7DC,qBAAqB,EACrBC,kBAAmB,IAGP,IAAIG,EAAQ,CACxBC,WAAY,CAACH,EAAajB,KAGpBqB,OAAOpK,OAlDnB,SAAS0I,IACPpE,SAASqE,iBAAiB,eAAeC,QAAQ,SAACyB,EAAexB,GAC/D,IAAIyB,EAAiBD,EAAcC,eAC/BD,GAAiB/F,SAASiG,cAC5BD,EAAerO,UAAUC,IAAI,WAGxBoO,EAAeE,SAASlG,SAASiG,gBACpCD,EAAerO,UAAUM,OAAO,aAzBxC8E,QAAQ,sBAERA,QAAQ,QACRA,QAAQ"}
@@ -1,2 +0,0 @@
1
- var e=require("stimulus");require("@simonwep/pickr/dist/themes/monolith.min.css");var t=require("@simonwep/pickr");require("daterangepicker");var i=require("intl-tel-input"),r=require("select2"),n=require("tributejs");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(t),l=a(i),s=a(r),u=a(n);function c(e){var t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}function d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t)}function h(e,t){return h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},h(e,t)}var p=function(e){function t(){return e.apply(this,arguments)||this}return d(t,e),t.prototype.clickShadowField=function(e){e.preventDefault(),this.shadowFieldTarget.click()},t}(e.Controller);p.targets=["shadowField"];var g=function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var i=t.prototype;return i.pickImageAndUpload=function(e){e.preventDefault();var t=["local","url","camera"];this.hasGoogleApiKeyValue&&t.push("image_search");var i={cloud_name:this.cloudNameValue,apiKey:this.apiKeyValue,upload_preset:this.uploadPresetValue,upload_signature:this.getCloudinarySignature.bind(this),multiple:!1,sources:this.hasSourcesValue?this.sourcesValue.split(","):t,search_by_rights:!this.hasSearchByRightsValue||!1!==this.searchByRightsValue};this.hasGoogleApiKeyValue&&(i.google_api_key=this.googleApiKeyValue),cloudinary.openUploadWidget(i,this.handleWidgetResponse.bind(this))},i.clearImage=function(e){e.preventDefault(),this.hiddenFieldTarget.value=null,this.removeThumbnail()},i.getCloudinarySignature=function(e,t){$.ajax({url:this.signaturesUrlValue,type:"GET",dataType:"text",data:{data:t},complete:function(){console.log("complete")},success:function(t,i,r){e(t)},error:function(e,t,i){console.log(e,t,i)}})},i.handleWidgetResponse=function(e,t){if(!e&&t&&"success"===t.event){var i=t.info;this.hiddenFieldTarget.value=i.public_id,this.removeThumbnail(),this.addThumbnail(this.urlFormatValue.replace("CLOUDINARY_ID",i.public_id))}},i.addThumbnail=function(e){var t=$('<img src="'+e+'" width="'+this.widthValue+'" height="'+this.heightValue+'" data-'+this.identifier+'-target="thumbnail" />');$(this.uploadButtonTarget).prepend(t),this.uploadButtonTarget.classList.add(this.thumbnailShownClass)},i.removeThumbnail=function(){this.hasThumbnailTarget&&(this.uploadButtonTarget.removeChild(this.thumbnailTarget),this.uploadButtonTarget.classList.remove(this.thumbnailShownClass))},t}(e.Controller);g.targets=["uploadButton","hiddenField","thumbnail"],g.values={signaturesUrl:String,height:Number,width:Number,cloudName:String,apiKey:String,googleApiKey:String,urlFormat:String,sources:String,searchByRights:Boolean},g.classes=["thumbnailShown"];var f=function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var i=t.prototype;return i.connect=function(){this.initPluginInstance(),this.colorOptions=$(this.colorOptionsTarget).find("button").map(function(e,t){return $(t).attr("data-color")}).get()},i.disconnect=function(){this.teardownPluginInstance()},i.pickColor=function(e){e.preventDefault();var t=e.target,i=t.dataset.color;$(this.colorInputTarget).val(i),$(this.colorPickerValueTarget).val(i),$(this.userSelectedColorTarget).data("color",i),$(".button-color").removeClass("ring-2 ring-offset-2"),this.pickr.setColor(i),t.classList.add("ring-2","ring-offset-2")},i.pickRandomColor=function(e){e.preventDefault();var t=Math.floor(256*Math.random()),i=Math.floor(256*Math.random()),r=Math.floor(256*Math.random());this.pickr.setColor("rgb "+t+" "+i+" "+r);var n=this.pickr.getColor().toHEXA().toString();this.pickr.setColor(n),this.showUserSelectedColor(n)},i.showUserSelectedColor=function(e){$(this.colorInputTarget).val(e),$(this.colorPickerValueTarget).val(e),$(".button-color").removeClass("ring-2 ring-offset-2"),$(this.userSelectedColorTarget).addClass("ring-2").addClass("ring-offset-2").css("background-color",e).css("--tw-ring-color",e).attr("data-color",e).show()},i.unpickColor=function(e){e.preventDefault(),$(this.colorPickerValueTarget).val(""),$(this.colorInputTarget).val(""),$(this.userSelectedColorTarget).hide(),$(".button-color").removeClass("ring-2 ring-offset-2")},i.togglePickr=function(e){e.preventDefault()},i.initPluginInstance=function(){var e=this;this.pickr=o.default.create({el:".btn-pickr",theme:"monolith",useAsButton:!0,default:this.initialColorValue||"#1E90FF",components:{preview:!0,hue:!0,interaction:{input:!0,save:!0}}}),this.pickr.on("save",function(t,i){var r=t.toHEXA().toString();e.colorOptions.includes(r)||e.showUserSelectedColor(r),e.pickr.hide()});var t=this;$('input[type="text"].pcr-result').on("keydown",function(e){"Enter"===e.key&&t.pickr.applyColor(!1)})},i.teardownPluginInstance=function(){this.pickr.destroy()},t}(e.Controller);f.targets=["colorPickerValue","colorField","colorInput","userSelectedColor","colorOptions"],f.values={initialColor:String},require("daterangepicker/daterangepicker.css");var m=function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var i=t.prototype;return i.connect=function(){this.initPluginInstance()},i.disconnect=function(){this.teardownPluginInstance()},i.clearDate=function(e){e.preventDefault(),$(this.fieldTarget).val("")},i.applyDateToField=function(e,t){var i=this.includeTimeValue?"MM/DD/YYYY h:mm A":"MM/DD/YYYY";$(this.fieldTarget).val(t.startDate.format(i))},i.showTimeZoneButtons=function(e){e.preventDefault(),$(this.currentTimeZoneWrapperTarget).toggleClass("hidden"),$(this.timeZoneButtonsTarget).toggleClass("hidden")},i.showTimeZoneSelectWrapper=function(e){e.preventDefault(),$(this.timeZoneButtonsTarget).toggleClass("hidden"),this.hasTimeZoneSelectWrapperTarget&&$(this.timeZoneSelectWrapperTarget).toggleClass("hidden")},i.resetTimeZoneUI=function(e){e&&e.preventDefault(),$(this.currentTimeZoneWrapperTarget).removeClass("hidden"),$(this.timeZoneButtonsTarget).addClass("hidden"),this.hasTimeZoneSelectWrapperTarget&&$(this.timeZoneSelectWrapperTarget).addClass("hidden")},i.setTimeZone=function(e){e.preventDefault();var t=this.currentTimeZoneWrapperTarget.querySelector("a"),i=e.target.dataset.value;$(this.timeZoneFieldTarget).val(i),$(t).text(i),$(".time-zone-button").removeClass("button").addClass("button-alternative"),$(e.target).removeClass("button-alternative").addClass("button"),this.resetTimeZoneUI()},i.initPluginInstance=function(){if($(this.fieldTarget).daterangepicker({singleDatePicker:!0,timePicker:this.includeTimeValue,timePickerIncrement:5,autoUpdateInput:!1,locale:{cancelLabel:this.hasCancelButtonLabelValue?this.cancelButtonLabelValue:"cancel",applyLabel:this.hasApplyButtonLabelValue?this.applyButtonLabelValue:"apply",format:this.includeTimeValue?"MM/DD/YYYY h:mm A":"MM/DD/YYYY"}}),$(this.fieldTarget).on("apply.daterangepicker",this.applyDateToField.bind(this)),$(this.fieldTarget).on("cancel.daterangepicker",this.clearDate.bind(this)),this.pluginMainEl=this.fieldTarget,this.plugin=$(this.pluginMainEl).data("daterangepicker"),this.includeTimeValue&&this.hasTimeZoneSelectWrapperTarget){this.timeZoneSelect=this.timeZoneSelectWrapperTarget.querySelector("select.select2"),$(this.timeZoneSelect).select2({width:"style"});var e=this;$(this.timeZoneSelect).on("change.select2",function(t){var i=e.currentTimeZoneWrapperTarget.querySelector("a"),r=t.target.value;$(e.timeZoneFieldTarget).val(r),$(i).text(r);var n=$(".selected-option-time-zone-button");e.defaultTimeZonesValue.includes(r)?($(".time-zone-button").removeClass("button").addClass("button-alternative"),n.addClass("hidden").attr("hidden",!0),$('a[data-value="'+r+'"').removeClass("button-alternative").addClass("button")):($(".time-zone-button").removeClass("button").addClass("button-alternative"),n.text(r),n.attr("data-value",r).removeAttr("hidden"),n.removeClass(["hidden","button-alternative"]).addClass("button")),e.resetTimeZoneUI()})}},i.teardownPluginInstance=function(){void 0!==this.plugin&&($(this.pluginMainEl).off("apply.daterangepicker"),$(this.pluginMainEl).off("cancel.daterangepicker"),this.plugin.remove(),this.includeTimeValue&&$(this.timeZoneSelect).select2("destroy"))},t}(e.Controller);m.targets=["field","clearButton","currentTimeZoneWrapper","timeZoneButtons","timeZoneSelectWrapper","timeZoneField"],m.values={includeTime:Boolean,defaultTimeZones:Array,cancelButtonLabel:String,applyButtonLabel:String};var v=function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var i=t.prototype;return i.connect=function(){var e=this,t=document.addEventListener("direct-upload:initialize",function(t){e.selectFileButtonTarget.classList.add("hidden"),e.progressBarTarget.innerText="0%",e.progressBarTarget.style.width="0%",e.progressBarTarget.setAttribute("aria-valuenow",0),e.progressBarTarget.parentNode.classList.remove("hidden")}),i=document.addEventListener("direct-upload:progress",function(t){var i=t.detail.progress,r=i.toFixed(1)+"%";e.progressBarTarget.innerText=r,e.progressBarTarget.setAttribute("aria-valuenow",i),e.progressBarTarget.style.width=r}),r=document.addEventListener("direct-upload:error",function(t){t.preventDefault(),e.progressBarTarget.innerText=t.detail.error});this.uploadListeners={"direct-upload:initialize":t,"direct-upload:progress":i,"direct-upload:error":r}},i.disconnect=function(){for(var e in this.uploadListeners)document.removeEventListener(e,this.uploadListeners[e])},i.uploadFile=function(){this.fileFieldTarget.click()},i.removeFile=function(){this.hasDownloadFileButtonTarget&&this.downloadFileButtonTarget.classList.add("hidden"),this.removeFileButtonTarget.classList.add("hidden"),this.removeFileFlagTarget.value=!0},i.handleFileSelected=function(){var e=this.selectFileButtonTarget.querySelector("span"),t=this.selectFileButtonTarget.querySelector("i");this.hasDownloadFileButtonTarget&&this.downloadFileButtonTarget.remove(),e.innerText="Select Another File",t.classList.remove("ti-upload"),t.classList.add("ti-check")},t}(e.Controller);v.targets=["fileField","removeFileFlag","downloadFileButton","removeFileButton","selectFileButton","progressBar"],require("intl-tel-input/build/css/intlTelInput.css");var T=function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var i=t.prototype;return i.connect=function(){this.initPluginInstance()},i.disconnect=function(){this.teardownPluginInstance()},i.initPluginInstance=function(){var e,t={hiddenInput:this.fieldTarget.dataset.method,customContainer:"w-full"},i=(e=document.head.querySelector('meta[name="intl_tel_input_utils_path"]'))&&e.content;i&&(t.utilsScript=i),this.plugin=l.default(this.fieldTarget,t)},i.teardownPluginInstance=function(){void 0!==this.plugin&&this.plugin.destroy()},t}(e.Controller);T.targets=["field"],require("select2/dist/css/select2.min.css");var y=function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var i,r,n=t.prototype;return n.initialize=function(){this.isSelect2LoadedOnWindowJquery&&s.default(window.$)},n.connect=function(){this.isSelect2LoadedOnWindowJquery&&this.initPluginInstance()},n.disconnect=function(){this.teardownPluginInstance()},n.cleanupBeforeInit=function(){$(this.element).find(".select2-container--default").remove()},n.initPluginInstance=function(){var e={};this.enableSearchValue||(e.minimumResultsForSearch=-1),e.tags=this.acceptsNewValue,this.searchUrlValue&&(e.ajax={url:this.searchUrlValue,dataType:"json",data:function(e){return{search:e.term,page:e.page||1}}}),e.templateResult=this.formatState,e.templateSelection=this.formatState,e.width="style",this.cleanupBeforeInit(),this.pluginMainEl=this.selectTarget,$(this.pluginMainEl).select2(e)},n.teardownPluginInstance=function(){void 0!==this.pluginMainEl&&$(this.pluginMainEl).select2("destroy")},n.formatState=function(e){var t=$(e.element).attr("data-image"),i="";return t&&(i='<img src="'+t+'" /> '),$("<span>"+i+e.text+"</span>")},i=t,(r=[{key:"isSelect2LoadedOnWindowJquery",get:function(){return void 0!==window.$&&void 0===window.$.select2}}])&&function(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),t}(e.Controller);y.targets=["select"],y.values={acceptsNew:Boolean,enableSearch:Boolean,searchUrl:String};var b=[[p,"fields/button_toggle_controller.js"],[g,"fields/cloudinary_image_controller.js"],[f,"fields/color_picker_controller.js"],[m,"fields/date_controller.js"],[v,"fields/file_field_controller.js"],[T,"fields/phone_controller.js"],[y,"fields/super_select_controller.js"]].map(function(e){var t=e[0];return{identifier:c(e[1]),controllerConstructor:t}});function S(){document.querySelectorAll("trix-editor").forEach(function(e,t){var i=e.toolbarElement;e==document.activeElement?i.classList.add("visible"):i.contains(document.activeElement)||i.classList.remove("visible")})}require("trix/dist/trix.css"),require("trix"),require("@rails/actiontext"),exports.ButtonToggleController=p,exports.CloudinaryImageController=g,exports.ColorPickerController=f,exports.DateController=m,exports.FileFieldController=v,exports.PhoneController=T,exports.SuperSelectController=y,exports.controllerDefinitions=b,exports.trixEditor=function(){document.addEventListener("trix-initialize",function(){addEventListener("trix-focus",S),addEventListener("trix-blur",S),S(),document.querySelectorAll("trix-editor").forEach(function(e,t){var i=e.editor,r={trigger:"@",values:JSON.parse(i.element.dataset.mentions),selectTemplate:function(e){return'<a href="'+(e=e.original).protocol+"://"+e.model+"/"+e.id+'">'+e.label+"</a>"},menuItemTemplate:function(e){return'<img src="'+e.original.photo+'" /> '+e.string},requireLeadingSpace:!0,replaceTextSuffix:""},n={trigger:"#",values:JSON.parse(i.element.dataset.topics),selectTemplate:function(e){return'<a href="'+(e=e.original).protocol+"://"+e.model+"/"+e.id+'">'+e.label+"</a>"},menuItemTemplate:function(e){return'<img src="'+e.original.photo+'" /> '+e.string},requireLeadingSpace:!0,replaceTextSuffix:""};new u.default({collection:[n,r]}).attach(e)})})};
2
- //# sourceMappingURL=fields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fields.js","sources":["../../../node_modules/@stimulus/webpack-helpers/dist/index.js","../../javascript/controllers/fields/button_toggle_controller.js","../../javascript/controllers/fields/cloudinary_image_controller.js","../../javascript/controllers/fields/color_picker_controller.js","../../javascript/controllers/fields/date_controller.js","../../javascript/controllers/fields/file_field_controller.js","../../javascript/controllers/fields/phone_controller.js","../../javascript/controllers/fields/super_select_controller.js","../../javascript/controllers/index.js","../../javascript/trix_editor.js"],"sourcesContent":["export function definitionsFromContext(context) {\n return context.keys()\n .map(function (key) { return definitionForModuleWithContextAndKey(context, key); })\n .filter(function (value) { return value; });\n}\nfunction definitionForModuleWithContextAndKey(context, key) {\n var identifier = identifierForContextKey(key);\n if (identifier) {\n return definitionForModuleAndIdentifier(context(key), identifier);\n }\n}\nfunction definitionForModuleAndIdentifier(module, identifier) {\n var controllerConstructor = module.default;\n if (typeof controllerConstructor == \"function\") {\n return { identifier: identifier, controllerConstructor: controllerConstructor };\n }\n}\nexport function identifierForContextKey(key) {\n var logicalName = (key.match(/^(?:\\.\\/)?(.+)(?:[_-]controller\\..+?)$/) || [])[1];\n if (logicalName) {\n return logicalName.replace(/_/g, \"-\").replace(/\\//g, \"--\");\n }\n}\n//# sourceMappingURL=index.js.map","import { Controller } from \"stimulus\"\n\nexport default class extends Controller {\n static targets = [ \"shadowField\" ]\n\n clickShadowField(event) {\n // we have to stop safari from doing what we originally expected.\n event.preventDefault();\n\n // then we need to manually click the hidden checkbox or radio button ourselves.\n this.shadowFieldTarget.click()\n }\n}","import { Controller } from \"stimulus\"\n\nexport default class extends Controller {\n static targets = [ \"uploadButton\", \"hiddenField\", \"thumbnail\" ]\n static values = { \n signaturesUrl: String,\n height: Number,\n width: Number,\n cloudName: String,\n apiKey: String,\n googleApiKey: String,\n urlFormat: String,\n sources: String,\n searchByRights: Boolean\n }\n static classes = [ \"thumbnailShown\" ]\n\n pickImageAndUpload(event) {\n // don't submit the form.\n event.preventDefault()\n\n // prepare the list of default sources a user can upload an image from.\n var defaultSources = ['local', 'url', 'camera']\n if (this.hasGoogleApiKeyValue) {\n defaultSources.push('image_search')\n }\n\n // configure cloudinary's uploader's options.\n // many of these are configurable at the point where the `shared/fields/cloudinary_image` partial is included.\n var options = {\n cloud_name: this.cloudNameValue,\n apiKey: this.apiKeyValue,\n upload_preset: this.uploadPresetValue,\n upload_signature: this.getCloudinarySignature.bind(this),\n multiple: false,\n sources: this.hasSourcesValue ? this.sourcesValue.split(',') : defaultSources,\n search_by_rights: this.hasSearchByRightsValue && this.searchByRightsValue === false ? false : true // default to true.\n }\n \n if (this.hasGoogleApiKeyValue) {\n options['google_api_key'] = this.googleApiKeyValue\n }\n \n // open cloudinary's upload widget.\n cloudinary.openUploadWidget(options, this.handleWidgetResponse.bind(this))\n }\n \n clearImage(event) {\n // don't submit the form.\n event.preventDefault()\n\n // clear the cloudinary id.\n this.hiddenFieldTarget.value = null\n \n // remove any existing image from the button.\n this.removeThumbnail()\n }\n \n getCloudinarySignature(callback, paramsToSign) {\n $.ajax({\n url: this.signaturesUrlValue,\n type: \"GET\",\n dataType: \"text\",\n data: {data: paramsToSign},\n complete: function() { console.log(\"complete\") },\n success: function(signature, textStatus, xhr) { callback(signature) },\n error: function(xhr, status, error) { console.log(xhr, status, error) }\n })\n }\n \n handleWidgetResponse(error, response) {\n // after the user has successfully uploaded a single file ..\n if (!error && response && response.event === \"success\") { \n const data = response.info\n \n // update the cloudinary id field in the form.\n this.hiddenFieldTarget.value = data.public_id\n\n // remove any existing image.\n this.removeThumbnail()\n\n // generate a new image preview url.\n this.addThumbnail(this.urlFormatValue.replace('CLOUDINARY_ID', data.public_id))\n }\n }\n \n addThumbnail(url) {\n var $imageElement = $(`<img src=\"${url}\" width=\"${this.widthValue}\" height=\"${this.heightValue}\" data-${this.identifier}-target=\"thumbnail\" />`)\n $(this.uploadButtonTarget).prepend($imageElement)\n\n // mark the image as present.\n this.uploadButtonTarget.classList.add(this.thumbnailShownClass)\n }\n \n removeThumbnail() {\n if (!this.hasThumbnailTarget) { return }\n this.uploadButtonTarget.removeChild(this.thumbnailTarget)\n this.uploadButtonTarget.classList.remove(this.thumbnailShownClass)\n }\n}\n","import { Controller } from \"stimulus\"\nimport '@simonwep/pickr/dist/themes/monolith.min.css'\n\nimport Pickr from '@simonwep/pickr';\n\nexport default class extends Controller {\n static targets = [ \"colorPickerValue\", \"colorField\", \"colorInput\", \"userSelectedColor\", \"colorOptions\" ];\n static values = { initialColor: String }\n\n connect() {\n this.initPluginInstance()\n this.colorOptions = $(this.colorOptionsTarget).find('button').map(function (_, button) { return $(button).attr('data-color'); }).get()\n }\n\n disconnect() {\n this.teardownPluginInstance()\n }\n\n pickColor(event) {\n event.preventDefault();\n\n const targetEl = event.target;\n const color = targetEl.dataset.color;\n\n $(this.colorInputTarget).val(color);\n $(this.colorPickerValueTarget).val(color);\n $(this.userSelectedColorTarget).data('color', color);\n $('.button-color').removeClass('ring-2 ring-offset-2');\n\n this.pickr.setColor(color);\n\n targetEl.classList.add('ring-2', 'ring-offset-2');\n }\n\n pickRandomColor(event) {\n event.preventDefault();\n\n const r = Math.floor(Math.random() * 256);\n const g = Math.floor(Math.random() * 256);\n const b = Math.floor(Math.random() * 256);\n\n this.pickr.setColor(`rgb ${r} ${g} ${b}`);\n const hexColor = this.pickr.getColor().toHEXA().toString();\n this.pickr.setColor(hexColor);\n\n this.showUserSelectedColor(hexColor);\n }\n\n showUserSelectedColor(color) {\n $(this.colorInputTarget).val(color);\n $(this.colorPickerValueTarget).val(color);\n\n $('.button-color').removeClass('ring-2 ring-offset-2');\n\n $(this.userSelectedColorTarget)\n .addClass('ring-2')\n .addClass('ring-offset-2')\n .css('background-color', color)\n .css('--tw-ring-color', color)\n .attr('data-color', color)\n .show();\n }\n\n unpickColor(event) {\n event.preventDefault();\n $(this.colorPickerValueTarget).val('');\n $(this.colorInputTarget).val('');\n $(this.userSelectedColorTarget).hide();\n $('.button-color').removeClass('ring-2 ring-offset-2');\n }\n\n togglePickr(event) {\n event.preventDefault();\n }\n\n initPluginInstance() {\n this.pickr = Pickr.create({\n el: '.btn-pickr',\n theme: 'monolith',\n useAsButton: true,\n default: this.initialColorValue || '#1E90FF',\n components: {\n // Main components\n preview: true,\n hue: true,\n\n // Input / output Options\n interaction: {\n input: true,\n save: true,\n },\n }\n });\n\n this.pickr.on('save', (color, _instance) => {\n const hexaColor = color.toHEXA().toString()\n if (!this.colorOptions.includes(hexaColor)) {\n this.showUserSelectedColor(hexaColor);\n }\n this.pickr.hide();\n });\n\n const that = this\n\n $('input[type=\"text\"].pcr-result').on('keydown', function (e) {\n if (e.key === 'Enter') {\n that.pickr.applyColor(false)\n }\n })\n }\n\n teardownPluginInstance() {\n this.pickr.destroy()\n }\n}\n","import { Controller } from \"stimulus\"\nrequire(\"daterangepicker/daterangepicker.css\");\n\n// requires jQuery, moment, might want to consider a vanilla JS alternative\nimport 'daterangepicker';\n\nexport default class extends Controller {\n static targets = [ \"field\", \"clearButton\", \"currentTimeZoneWrapper\", \"timeZoneButtons\", \"timeZoneSelectWrapper\", \"timeZoneField\" ]\n static values = {\n includeTime: Boolean,\n defaultTimeZones: Array,\n cancelButtonLabel: String,\n applyButtonLabel: String\n }\n\n connect() {\n this.initPluginInstance()\n }\n\n disconnect() {\n this.teardownPluginInstance()\n }\n\n clearDate(event) {\n // don't submit the form, unless it originated from the cancel/clear button\n event.preventDefault()\n\n $(this.fieldTarget).val('')\n }\n\n applyDateToField(event, picker) {\n const format = this.includeTimeValue ? 'MM/DD/YYYY h:mm A' : 'MM/DD/YYYY'\n $(this.fieldTarget).val(picker.startDate.format(format))\n }\n\n showTimeZoneButtons(event) {\n // don't follow the anchor\n event.preventDefault()\n\n $(this.currentTimeZoneWrapperTarget).toggleClass('hidden')\n $(this.timeZoneButtonsTarget).toggleClass('hidden')\n }\n\n showTimeZoneSelectWrapper(event) {\n // don't follow the anchor\n event.preventDefault()\n\n $(this.timeZoneButtonsTarget).toggleClass('hidden')\n\n if (this.hasTimeZoneSelectWrapperTarget) {\n $(this.timeZoneSelectWrapperTarget).toggleClass('hidden')\n }\n }\n\n resetTimeZoneUI(e) {\n e && e.preventDefault()\n\n $(this.currentTimeZoneWrapperTarget).removeClass('hidden')\n $(this.timeZoneButtonsTarget).addClass('hidden')\n\n if (this.hasTimeZoneSelectWrapperTarget) {\n $(this.timeZoneSelectWrapperTarget).addClass('hidden')\n }\n }\n\n setTimeZone(event) {\n // don't follow the anchor\n event.preventDefault()\n\n const currentTimeZoneEl = this.currentTimeZoneWrapperTarget.querySelector('a')\n const {value} = event.target.dataset\n\n $(this.timeZoneFieldTarget).val(value)\n $(currentTimeZoneEl).text(value)\n\n $('.time-zone-button').removeClass('button').addClass('button-alternative')\n $(event.target).removeClass('button-alternative').addClass('button')\n\n this.resetTimeZoneUI()\n }\n\n initPluginInstance() {\n $(this.fieldTarget).daterangepicker({\n singleDatePicker: true,\n timePicker: this.includeTimeValue,\n timePickerIncrement: 5,\n autoUpdateInput: false,\n locale: {\n cancelLabel: (this.hasCancelButtonLabelValue)? this.cancelButtonLabelValue: \"cancel\",\n applyLabel: (this.hasApplyButtonLabelValue)? this.applyButtonLabelValue: \"apply\",\n format: this.includeTimeValue ? 'MM/DD/YYYY h:mm A' : 'MM/DD/YYYY'\n }\n })\n\n $(this.fieldTarget).on('apply.daterangepicker', this.applyDateToField.bind(this))\n $(this.fieldTarget).on('cancel.daterangepicker', this.clearDate.bind(this))\n\n this.pluginMainEl = this.fieldTarget\n this.plugin = $(this.pluginMainEl).data('daterangepicker') // weird\n\n // Init time zone select\n if (this.includeTimeValue && this.hasTimeZoneSelectWrapperTarget) {\n this.timeZoneSelect = this.timeZoneSelectWrapperTarget.querySelector('select.select2')\n\n $(this.timeZoneSelect).select2({\n width: 'style'\n })\n\n const self = this\n\n $(this.timeZoneSelect).on('change.select2', function(event) {\n const currentTimeZoneEl = self.currentTimeZoneWrapperTarget.querySelector('a')\n const {value} = event.target\n\n $(self.timeZoneFieldTarget).val(value)\n $(currentTimeZoneEl).text(value)\n\n const selectedOptionTimeZoneButton = $('.selected-option-time-zone-button')\n\n if (self.defaultTimeZonesValue.includes(value)) {\n $('.time-zone-button').removeClass('button').addClass('button-alternative')\n selectedOptionTimeZoneButton.addClass('hidden').attr('hidden', true)\n $(`a[data-value=\"${value}\"`).removeClass('button-alternative').addClass('button')\n } else {\n // deselect any selected button\n $('.time-zone-button').removeClass('button').addClass('button-alternative')\n\n selectedOptionTimeZoneButton.text(value)\n selectedOptionTimeZoneButton.attr('data-value', value).removeAttr('hidden')\n selectedOptionTimeZoneButton.removeClass(['hidden', 'button-alternative']).addClass('button')\n }\n\n self.resetTimeZoneUI()\n })\n }\n }\n\n teardownPluginInstance() {\n if (this.plugin === undefined) { return }\n\n $(this.pluginMainEl).off('apply.daterangepicker')\n $(this.pluginMainEl).off('cancel.daterangepicker')\n\n // revert to original markup, remove any event listeners\n this.plugin.remove()\n\n if (this.includeTimeValue) {\n $(this.timeZoneSelect).select2('destroy');\n }\n }\n}\n","import { Controller } from \"stimulus\";\n\nexport default class extends Controller {\n static targets = [\n \"fileField\",\n \"removeFileFlag\",\n \"downloadFileButton\",\n \"removeFileButton\",\n \"selectFileButton\",\n \"progressBar\",\n ];\n\n connect() {\n // Add upload event listeners\n const initializeListener = document.addEventListener(\n \"direct-upload:initialize\",\n (event) => {\n this.selectFileButtonTarget.classList.add(\"hidden\");\n this.progressBarTarget.innerText = \"0%\";\n this.progressBarTarget.style.width = \"0%\";\n this.progressBarTarget.setAttribute(\"aria-valuenow\", 0);\n this.progressBarTarget.parentNode.classList.remove(\"hidden\");\n }\n );\n\n const progressListener = document.addEventListener(\n \"direct-upload:progress\",\n (event) => {\n const { progress } = event.detail;\n const width = `${progress.toFixed(1)}%`;\n\n this.progressBarTarget.innerText = width;\n this.progressBarTarget.setAttribute(\"aria-valuenow\", progress);\n this.progressBarTarget.style.width = width;\n }\n );\n\n const errorListener = document.addEventListener(\n \"direct-upload:error\",\n (event) => {\n event.preventDefault();\n\n const { error } = event.detail;\n this.progressBarTarget.innerText = error;\n }\n );\n\n this.uploadListeners = {\n \"direct-upload:initialize\": initializeListener,\n \"direct-upload:progress\": progressListener,\n \"direct-upload:error\": errorListener,\n };\n }\n\n disconnect() {\n // Teardown event listeners\n for (const event in this.uploadListeners) {\n document.removeEventListener(event, this.uploadListeners[event]);\n }\n }\n\n uploadFile() {\n this.fileFieldTarget.click();\n }\n\n removeFile() {\n if (this.hasDownloadFileButtonTarget) {\n this.downloadFileButtonTarget.classList.add(\"hidden\");\n }\n\n this.removeFileButtonTarget.classList.add(\"hidden\");\n this.removeFileFlagTarget.value = true;\n }\n\n handleFileSelected() {\n const statusText = this.selectFileButtonTarget.querySelector(\"span\");\n const icon = this.selectFileButtonTarget.querySelector(\"i\");\n\n if (this.hasDownloadFileButtonTarget) {\n this.downloadFileButtonTarget.remove();\n }\n\n statusText.innerText = \"Select Another File\";\n icon.classList.remove(\"ti-upload\");\n icon.classList.add(\"ti-check\");\n }\n}\n","import { Controller } from \"stimulus\"\nrequire(\"intl-tel-input/build/css/intlTelInput.css\");\nimport intlTelInput from 'intl-tel-input';\n\nexport default class extends Controller {\n static targets = [ \"field\" ]\n\n connect() {\n this.initPluginInstance()\n }\n\n disconnect() {\n this.teardownPluginInstance()\n }\n\n initPluginInstance() {\n let options = {\n hiddenInput: this.fieldTarget.dataset.method,\n customContainer: \"w-full\"\n }\n\n // TODO: add instructions on how to copy this asset into the application's assets path and write the meta tag into the head (via the engine?)\n const utilsScriptPath = metaContent(\"intl_tel_input_utils_path\")\n if (utilsScriptPath) {\n options['utilsScript'] = utilsScriptPath\n }\n\n this.plugin = intlTelInput(this.fieldTarget, options);\n }\n\n teardownPluginInstance() {\n if (this.plugin === undefined) { return }\n\n // revert to original markup, remove any event listeners\n this.plugin.destroy()\n }\n}\n\nfunction metaContent (name) {\n const element = document.head.querySelector(`meta[name=\"${name}\"]`)\n return element && element.content\n}","import { Controller } from \"stimulus\"\nrequire(\"select2/dist/css/select2.min.css\");\nimport select2 from \"select2\";\n\nexport default class extends Controller {\n static targets = [ \"select\" ]\n static values = {\n acceptsNew: Boolean,\n enableSearch: Boolean,\n searchUrl: String,\n }\n\n initialize() {\n if (this.isSelect2LoadedOnWindowJquery) {\n select2(window.$)\n }\n }\n\n get isSelect2LoadedOnWindowJquery() {\n return (window.$ !== undefined && window.$.select2 === undefined)\n }\n\n connect() {\n if (this.isSelect2LoadedOnWindowJquery) {\n this.initPluginInstance()\n }\n }\n\n disconnect() {\n this.teardownPluginInstance()\n }\n\n cleanupBeforeInit() {\n $(this.element).find('.select2-container--default').remove()\n }\n\n initPluginInstance() {\n let options = {};\n\n if (!this.enableSearchValue) {\n options.minimumResultsForSearch = -1;\n }\n\n options.tags = this.acceptsNewValue\n\n if (this.searchUrlValue) {\n options.ajax = {\n url: this.searchUrlValue,\n dataType: 'json',\n // We enable pagination by default here\n data: function(params) {\n var query = {\n search: params.term,\n page: params.page || 1\n }\n return query\n }\n // Any additional params go here...\n }\n }\n\n options.templateResult = this.formatState;\n options.templateSelection = this.formatState;\n options.width = 'style';\n\n this.cleanupBeforeInit() // in case improperly torn down\n this.pluginMainEl = this.selectTarget // required because this.selectTarget is unavailable on disconnect()\n $(this.pluginMainEl).select2(options);\n }\n\n teardownPluginInstance() {\n if (this.pluginMainEl === undefined) { return }\n\n // revert to original markup, remove any event listeners\n $(this.pluginMainEl).select2('destroy');\n }\n\n // https://stackoverflow.com/questions/29290389/select2-add-image-icon-to-option-dynamically\n formatState(opt) {\n var imageUrl = $(opt.element).attr('data-image');\n var imageHtml = \"\";\n if (imageUrl) {\n imageHtml = '<img src=\"' + imageUrl + '\" /> ';\n }\n return $('<span>' + imageHtml + opt.text + '</span>');\n }\n}\n","import { identifierForContextKey } from \"@stimulus/webpack-helpers\"\n\nimport ButtonToggleController from './fields/button_toggle_controller'\nimport CloudinaryImageController from './fields/cloudinary_image_controller'\nimport ColorPickerController from './fields/color_picker_controller'\nimport DateController from './fields/date_controller'\nimport FileFieldController from './fields/file_field_controller'\nimport PhoneController from './fields/phone_controller'\nimport SuperSelectController from './fields/super_select_controller'\n\nexport const controllerDefinitions = [\n [ButtonToggleController, 'fields/button_toggle_controller.js'],\n [CloudinaryImageController, 'fields/cloudinary_image_controller.js'],\n [ColorPickerController, 'fields/color_picker_controller.js'],\n [DateController, 'fields/date_controller.js'],\n [FileFieldController, 'fields/file_field_controller.js'],\n [PhoneController, 'fields/phone_controller.js'],\n [SuperSelectController, 'fields/super_select_controller.js']\n].map(function(d) {\n const key = d[1]\n const controller = d[0]\n return {\n identifier: identifierForContextKey(key),\n controllerConstructor: controller\n }\n})\n\nexport {\n ButtonToggleController,\n CloudinaryImageController,\n ColorPickerController,\n DateController,\n FileFieldController,\n PhoneController,\n SuperSelectController\n}","import Tribute from 'tributejs'\nrequire(\"trix/dist/trix.css\");\n\nrequire(\"trix\")\nrequire(\"@rails/actiontext\")\n\n// only show the editor tool bar when the user is editing the field.\n// inspired by https://github.com/basecamp/trix/issues/343 and `app/assets/stylesheets/account/fields/trix_editor.scss`\n\nexport function trixEditor() {\n document.addEventListener('trix-initialize', function() {\n addEventListener(\"trix-focus\", updateTrixToolbarVisability);\n addEventListener(\"trix-blur\", updateTrixToolbarVisability);\n updateTrixToolbarVisability();\n initializeTribute();\n })\n}\n\nfunction updateTrixToolbarVisability() {\n document.querySelectorAll(\"trix-editor\").forEach((editorElement, index) => {\n var toolbarElement = editorElement.toolbarElement;\n if (editorElement == document.activeElement) {\n toolbarElement.classList.add('visible');\n } else {\n // don't hide the toolbar if we've unfocused to focus on the link dialog.\n if (!toolbarElement.contains(document.activeElement)) {\n toolbarElement.classList.remove('visible');\n }\n }\n })\n}\n\nfunction initializeTribute() {\n document.querySelectorAll(\"trix-editor\").forEach((el, index) => {\n var editor = el.editor;\n \n var mentionConfig = {\n trigger: '@',\n values: JSON.parse(editor.element.dataset.mentions),\n selectTemplate: function (item) {\n item = item.original;\n return '<a href=\"' + item.protocol + '://' + item.model + '/' + item.id + '\">' + item.label + '</a>';\n },\n menuItemTemplate: function (item) {\n return '<img src=\"' + item.original.photo + '\" /> ' + item.string;\n },\n requireLeadingSpace: true,\n replaceTextSuffix: ''\n }\n \n var topicConfig = {\n trigger: '#',\n values: JSON.parse(editor.element.dataset.topics),\n selectTemplate: function (item) {\n item = item.original;\n return '<a href=\"' + item.protocol + '://' + item.model + '/' + item.id + '\">' + item.label + '</a>';\n },\n menuItemTemplate: function (item) {\n return '<img src=\"' + item.original.photo + '\" /> ' + item.string;\n },\n requireLeadingSpace: true,\n replaceTextSuffix: ''\n }\n \n var tribute = new Tribute({\n collection: [topicConfig, mentionConfig],\n });\n \n tribute.attach(el);\n })\n}\n"],"names":["identifierForContextKey","key","logicalName","match","replace","clickShadowField","event","preventDefault","this","shadowFieldTarget","click","Controller","targets","pickImageAndUpload","defaultSources","hasGoogleApiKeyValue","push","options","cloud_name","cloudNameValue","apiKey","apiKeyValue","upload_preset","uploadPresetValue","upload_signature","getCloudinarySignature","bind","multiple","sources","hasSourcesValue","sourcesValue","split","search_by_rights","hasSearchByRightsValue","searchByRightsValue","googleApiKeyValue","cloudinary","openUploadWidget","handleWidgetResponse","clearImage","hiddenFieldTarget","value","removeThumbnail","callback","paramsToSign","$","ajax","url","signaturesUrlValue","type","dataType","data","complete","console","log","success","signature","textStatus","xhr","error","status","response","info","public_id","addThumbnail","urlFormatValue","$imageElement","widthValue","heightValue","identifier","uploadButtonTarget","prepend","classList","add","thumbnailShownClass","hasThumbnailTarget","removeChild","thumbnailTarget","remove","values","signaturesUrl","String","height","Number","width","cloudName","googleApiKey","urlFormat","searchByRights","Boolean","classes","connect","initPluginInstance","colorOptions","colorOptionsTarget","find","map","_","button","attr","get","disconnect","teardownPluginInstance","pickColor","targetEl","target","color","dataset","colorInputTarget","val","colorPickerValueTarget","userSelectedColorTarget","removeClass","pickr","setColor","pickRandomColor","r","Math","floor","random","g","b","hexColor","getColor","toHEXA","toString","showUserSelectedColor","addClass","css","show","unpickColor","hide","togglePickr","Pickr","create","el","theme","useAsButton","default","initialColorValue","components","preview","hue","interaction","input","save","on","_instance","hexaColor","_this","includes","that","e","applyColor","destroy","initialColor","require","clearDate","fieldTarget","applyDateToField","picker","format","includeTimeValue","startDate","showTimeZoneButtons","currentTimeZoneWrapperTarget","toggleClass","timeZoneButtonsTarget","showTimeZoneSelectWrapper","hasTimeZoneSelectWrapperTarget","timeZoneSelectWrapperTarget","resetTimeZoneUI","setTimeZone","currentTimeZoneEl","querySelector","timeZoneFieldTarget","text","daterangepicker","singleDatePicker","timePicker","timePickerIncrement","autoUpdateInput","locale","cancelLabel","hasCancelButtonLabelValue","cancelButtonLabelValue","applyLabel","hasApplyButtonLabelValue","applyButtonLabelValue","pluginMainEl","plugin","timeZoneSelect","select2","self","selectedOptionTimeZoneButton","defaultTimeZonesValue","removeAttr","undefined","off","includeTime","defaultTimeZones","Array","cancelButtonLabel","applyButtonLabel","initializeListener","document","addEventListener","selectFileButtonTarget","progressBarTarget","innerText","style","setAttribute","parentNode","progressListener","progress","detail","toFixed","errorListener","uploadListeners","removeEventListener","uploadFile","fileFieldTarget","removeFile","hasDownloadFileButtonTarget","downloadFileButtonTarget","removeFileButtonTarget","removeFileFlagTarget","handleFileSelected","statusText","icon","element","hiddenInput","method","customContainer","utilsScriptPath","head","content","intlTelInput","initialize","isSelect2LoadedOnWindowJquery","window","cleanupBeforeInit","enableSearchValue","minimumResultsForSearch","tags","acceptsNewValue","searchUrlValue","params","search","term","page","templateResult","formatState","templateSelection","selectTarget","opt","imageUrl","imageHtml","acceptsNew","enableSearch","searchUrl","controllerDefinitions","ButtonToggleController","CloudinaryImageController","ColorPickerController","DateController","FileFieldController","PhoneController","SuperSelectController","d","controller","controllerConstructor","updateTrixToolbarVisability","querySelectorAll","forEach","editorElement","index","toolbarElement","activeElement","contains","editor","mentionConfig","trigger","JSON","parse","mentions","selectTemplate","item","original","protocol","model","id","label","menuItemTemplate","photo","string","requireLeadingSpace","replaceTextSuffix","topicConfig","topics","Tribute","collection","attach"],"mappings":"kU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AASyE,gBACpCD,EAAe7M,UAAUM,OAAO,aAzBxC8E,QAAQ,sBAERA,QAAQ,QACRA,QAAQ,ySAMNiD,SAASC,iBAAiB,kBAAmB,WAC3CA,iBAAiB,aAAckE,GAC/BlE,iBAAiB,YAAakE,GAC9BA,IAoBFnE,SAASoE,iBAAiB,eAAeC,QAAQ,SAAC3I,EAAI6I,GACpD,IAAII,EAASjJ,EAAGiJ,OAEZC,EAAgB,CAClBC,QAAS,IACT3M,OAAQ4M,KAAKC,MAAMJ,EAAOlD,QAAQ3H,QAAQkL,UAC1CC,eAAgB,SAAUC,GAExB,MAAO,aADPA,EAAOA,EAAKC,UACcC,SAAW,MAAQF,EAAKG,MAAQ,IAAMH,EAAKI,GAAK,KAAOJ,EAAKK,MAAQ,QAEhGC,iBAAkB,SAAUN,GAC1B,MAAO,aAAeA,EAAKC,SAASM,MAAQ,QAAUP,EAAKQ,QAE7DC,qBAAqB,EACrBC,kBAAmB,IAGjBC,EAAc,CAChBhB,QAAS,IACT3M,OAAQ4M,KAAKC,MAAMJ,EAAOlD,QAAQ3H,QAAQgM,QAC1Cb,eAAgB,SAAUC,GAExB,MAAO,aADPA,EAAOA,EAAKC,UACcC,SAAW,MAAQF,EAAKG,MAAQ,IAAMH,EAAKI,GAAK,KAAOJ,EAAKK,MAAQ,QAEhGC,iBAAkB,SAAUN,GAC1B,MAAO,aAAeA,EAAKC,SAASM,MAAQ,QAAUP,EAAKQ,QAE7DC,qBAAqB,EACrBC,kBAAmB,IAGP,IAAIG,UAAQ,CACxBC,WAAY,CAACH,EAAajB,KAGpBqB,OAAOvK"}
@@ -1,2 +0,0 @@
1
- import{Controller as e}from"stimulus";import"@simonwep/pickr/dist/themes/monolith.min.css";import t from"@simonwep/pickr";import"daterangepicker";import i from"intl-tel-input";import a from"select2";import r from"tributejs";function n(e){var t=(e.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(t)return t.replace(/_/g,"-").replace(/\//g,"--")}class s extends e{clickShadowField(e){e.preventDefault(),this.shadowFieldTarget.click()}}s.targets=["shadowField"];class l extends e{pickImageAndUpload(e){e.preventDefault();var t=["local","url","camera"];this.hasGoogleApiKeyValue&&t.push("image_search");var i={cloud_name:this.cloudNameValue,apiKey:this.apiKeyValue,upload_preset:this.uploadPresetValue,upload_signature:this.getCloudinarySignature.bind(this),multiple:!1,sources:this.hasSourcesValue?this.sourcesValue.split(","):t,search_by_rights:!this.hasSearchByRightsValue||!1!==this.searchByRightsValue};this.hasGoogleApiKeyValue&&(i.google_api_key=this.googleApiKeyValue),cloudinary.openUploadWidget(i,this.handleWidgetResponse.bind(this))}clearImage(e){e.preventDefault(),this.hiddenFieldTarget.value=null,this.removeThumbnail()}getCloudinarySignature(e,t){$.ajax({url:this.signaturesUrlValue,type:"GET",dataType:"text",data:{data:t},complete:function(){console.log("complete")},success:function(t,i,a){e(t)},error:function(e,t,i){console.log(e,t,i)}})}handleWidgetResponse(e,t){if(!e&&t&&"success"===t.event){const e=t.info;this.hiddenFieldTarget.value=e.public_id,this.removeThumbnail(),this.addThumbnail(this.urlFormatValue.replace("CLOUDINARY_ID",e.public_id))}}addThumbnail(e){var t=$(`<img src="${e}" width="${this.widthValue}" height="${this.heightValue}" data-${this.identifier}-target="thumbnail" />`);$(this.uploadButtonTarget).prepend(t),this.uploadButtonTarget.classList.add(this.thumbnailShownClass)}removeThumbnail(){this.hasThumbnailTarget&&(this.uploadButtonTarget.removeChild(this.thumbnailTarget),this.uploadButtonTarget.classList.remove(this.thumbnailShownClass))}}l.targets=["uploadButton","hiddenField","thumbnail"],l.values={signaturesUrl:String,height:Number,width:Number,cloudName:String,apiKey:String,googleApiKey:String,urlFormat:String,sources:String,searchByRights:Boolean},l.classes=["thumbnailShown"];class o extends e{connect(){this.initPluginInstance(),this.colorOptions=$(this.colorOptionsTarget).find("button").map(function(e,t){return $(t).attr("data-color")}).get()}disconnect(){this.teardownPluginInstance()}pickColor(e){e.preventDefault();const t=e.target,i=t.dataset.color;$(this.colorInputTarget).val(i),$(this.colorPickerValueTarget).val(i),$(this.userSelectedColorTarget).data("color",i),$(".button-color").removeClass("ring-2 ring-offset-2"),this.pickr.setColor(i),t.classList.add("ring-2","ring-offset-2")}pickRandomColor(e){e.preventDefault();const t=Math.floor(256*Math.random()),i=Math.floor(256*Math.random()),a=Math.floor(256*Math.random());this.pickr.setColor(`rgb ${t} ${i} ${a}`);const r=this.pickr.getColor().toHEXA().toString();this.pickr.setColor(r),this.showUserSelectedColor(r)}showUserSelectedColor(e){$(this.colorInputTarget).val(e),$(this.colorPickerValueTarget).val(e),$(".button-color").removeClass("ring-2 ring-offset-2"),$(this.userSelectedColorTarget).addClass("ring-2").addClass("ring-offset-2").css("background-color",e).css("--tw-ring-color",e).attr("data-color",e).show()}unpickColor(e){e.preventDefault(),$(this.colorPickerValueTarget).val(""),$(this.colorInputTarget).val(""),$(this.userSelectedColorTarget).hide(),$(".button-color").removeClass("ring-2 ring-offset-2")}togglePickr(e){e.preventDefault()}initPluginInstance(){this.pickr=t.create({el:".btn-pickr",theme:"monolith",useAsButton:!0,default:this.initialColorValue||"#1E90FF",components:{preview:!0,hue:!0,interaction:{input:!0,save:!0}}}),this.pickr.on("save",(e,t)=>{const i=e.toHEXA().toString();this.colorOptions.includes(i)||this.showUserSelectedColor(i),this.pickr.hide()});const e=this;$('input[type="text"].pcr-result').on("keydown",function(t){"Enter"===t.key&&e.pickr.applyColor(!1)})}teardownPluginInstance(){this.pickr.destroy()}}o.targets=["colorPickerValue","colorField","colorInput","userSelectedColor","colorOptions"],o.values={initialColor:String},require("daterangepicker/daterangepicker.css");class c extends e{connect(){this.initPluginInstance()}disconnect(){this.teardownPluginInstance()}clearDate(e){e.preventDefault(),$(this.fieldTarget).val("")}applyDateToField(e,t){const i=this.includeTimeValue?"MM/DD/YYYY h:mm A":"MM/DD/YYYY";$(this.fieldTarget).val(t.startDate.format(i))}showTimeZoneButtons(e){e.preventDefault(),$(this.currentTimeZoneWrapperTarget).toggleClass("hidden"),$(this.timeZoneButtonsTarget).toggleClass("hidden")}showTimeZoneSelectWrapper(e){e.preventDefault(),$(this.timeZoneButtonsTarget).toggleClass("hidden"),this.hasTimeZoneSelectWrapperTarget&&$(this.timeZoneSelectWrapperTarget).toggleClass("hidden")}resetTimeZoneUI(e){e&&e.preventDefault(),$(this.currentTimeZoneWrapperTarget).removeClass("hidden"),$(this.timeZoneButtonsTarget).addClass("hidden"),this.hasTimeZoneSelectWrapperTarget&&$(this.timeZoneSelectWrapperTarget).addClass("hidden")}setTimeZone(e){e.preventDefault();const t=this.currentTimeZoneWrapperTarget.querySelector("a"),{value:i}=e.target.dataset;$(this.timeZoneFieldTarget).val(i),$(t).text(i),$(".time-zone-button").removeClass("button").addClass("button-alternative"),$(e.target).removeClass("button-alternative").addClass("button"),this.resetTimeZoneUI()}initPluginInstance(){if($(this.fieldTarget).daterangepicker({singleDatePicker:!0,timePicker:this.includeTimeValue,timePickerIncrement:5,autoUpdateInput:!1,locale:{cancelLabel:this.hasCancelButtonLabelValue?this.cancelButtonLabelValue:"cancel",applyLabel:this.hasApplyButtonLabelValue?this.applyButtonLabelValue:"apply",format:this.includeTimeValue?"MM/DD/YYYY h:mm A":"MM/DD/YYYY"}}),$(this.fieldTarget).on("apply.daterangepicker",this.applyDateToField.bind(this)),$(this.fieldTarget).on("cancel.daterangepicker",this.clearDate.bind(this)),this.pluginMainEl=this.fieldTarget,this.plugin=$(this.pluginMainEl).data("daterangepicker"),this.includeTimeValue&&this.hasTimeZoneSelectWrapperTarget){this.timeZoneSelect=this.timeZoneSelectWrapperTarget.querySelector("select.select2"),$(this.timeZoneSelect).select2({width:"style"});const e=this;$(this.timeZoneSelect).on("change.select2",function(t){const i=e.currentTimeZoneWrapperTarget.querySelector("a"),{value:a}=t.target;$(e.timeZoneFieldTarget).val(a),$(i).text(a);const r=$(".selected-option-time-zone-button");e.defaultTimeZonesValue.includes(a)?($(".time-zone-button").removeClass("button").addClass("button-alternative"),r.addClass("hidden").attr("hidden",!0),$(`a[data-value="${a}"`).removeClass("button-alternative").addClass("button")):($(".time-zone-button").removeClass("button").addClass("button-alternative"),r.text(a),r.attr("data-value",a).removeAttr("hidden"),r.removeClass(["hidden","button-alternative"]).addClass("button")),e.resetTimeZoneUI()})}}teardownPluginInstance(){void 0!==this.plugin&&($(this.pluginMainEl).off("apply.daterangepicker"),$(this.pluginMainEl).off("cancel.daterangepicker"),this.plugin.remove(),this.includeTimeValue&&$(this.timeZoneSelect).select2("destroy"))}}c.targets=["field","clearButton","currentTimeZoneWrapper","timeZoneButtons","timeZoneSelectWrapper","timeZoneField"],c.values={includeTime:Boolean,defaultTimeZones:Array,cancelButtonLabel:String,applyButtonLabel:String};class u extends e{connect(){const e=document.addEventListener("direct-upload:initialize",e=>{this.selectFileButtonTarget.classList.add("hidden"),this.progressBarTarget.innerText="0%",this.progressBarTarget.style.width="0%",this.progressBarTarget.setAttribute("aria-valuenow",0),this.progressBarTarget.parentNode.classList.remove("hidden")}),t=document.addEventListener("direct-upload:progress",e=>{const{progress:t}=e.detail,i=`${t.toFixed(1)}%`;this.progressBarTarget.innerText=i,this.progressBarTarget.setAttribute("aria-valuenow",t),this.progressBarTarget.style.width=i}),i=document.addEventListener("direct-upload:error",e=>{e.preventDefault();const{error:t}=e.detail;this.progressBarTarget.innerText=t});this.uploadListeners={"direct-upload:initialize":e,"direct-upload:progress":t,"direct-upload:error":i}}disconnect(){for(const e in this.uploadListeners)document.removeEventListener(e,this.uploadListeners[e])}uploadFile(){this.fileFieldTarget.click()}removeFile(){this.hasDownloadFileButtonTarget&&this.downloadFileButtonTarget.classList.add("hidden"),this.removeFileButtonTarget.classList.add("hidden"),this.removeFileFlagTarget.value=!0}handleFileSelected(){const e=this.selectFileButtonTarget.querySelector("span"),t=this.selectFileButtonTarget.querySelector("i");this.hasDownloadFileButtonTarget&&this.downloadFileButtonTarget.remove(),e.innerText="Select Another File",t.classList.remove("ti-upload"),t.classList.add("ti-check")}}u.targets=["fileField","removeFileFlag","downloadFileButton","removeFileButton","selectFileButton","progressBar"],require("intl-tel-input/build/css/intlTelInput.css");class d extends e{connect(){this.initPluginInstance()}disconnect(){this.teardownPluginInstance()}initPluginInstance(){let e={hiddenInput:this.fieldTarget.dataset.method,customContainer:"w-full"};const t=function(e){const t=document.head.querySelector('meta[name="intl_tel_input_utils_path"]');return t&&t.content}();t&&(e.utilsScript=t),this.plugin=i(this.fieldTarget,e)}teardownPluginInstance(){void 0!==this.plugin&&this.plugin.destroy()}}d.targets=["field"],require("select2/dist/css/select2.min.css");class h extends e{initialize(){this.isSelect2LoadedOnWindowJquery&&a(window.$)}get isSelect2LoadedOnWindowJquery(){return void 0!==window.$&&void 0===window.$.select2}connect(){this.isSelect2LoadedOnWindowJquery&&this.initPluginInstance()}disconnect(){this.teardownPluginInstance()}cleanupBeforeInit(){$(this.element).find(".select2-container--default").remove()}initPluginInstance(){let e={};this.enableSearchValue||(e.minimumResultsForSearch=-1),e.tags=this.acceptsNewValue,this.searchUrlValue&&(e.ajax={url:this.searchUrlValue,dataType:"json",data:function(e){return{search:e.term,page:e.page||1}}}),e.templateResult=this.formatState,e.templateSelection=this.formatState,e.width="style",this.cleanupBeforeInit(),this.pluginMainEl=this.selectTarget,$(this.pluginMainEl).select2(e)}teardownPluginInstance(){void 0!==this.pluginMainEl&&$(this.pluginMainEl).select2("destroy")}formatState(e){var t=$(e.element).attr("data-image"),i="";return t&&(i='<img src="'+t+'" /> '),$("<span>"+i+e.text+"</span>")}}h.targets=["select"],h.values={acceptsNew:Boolean,enableSearch:Boolean,searchUrl:String};const p=[[s,"fields/button_toggle_controller.js"],[l,"fields/cloudinary_image_controller.js"],[o,"fields/color_picker_controller.js"],[c,"fields/date_controller.js"],[u,"fields/file_field_controller.js"],[d,"fields/phone_controller.js"],[h,"fields/super_select_controller.js"]].map(function(e){const t=e[0];return{identifier:n(e[1]),controllerConstructor:t}});function g(){document.addEventListener("trix-initialize",function(){addEventListener("trix-focus",m),addEventListener("trix-blur",m),m(),document.querySelectorAll("trix-editor").forEach((e,t)=>{var i=e.editor,a={trigger:"@",values:JSON.parse(i.element.dataset.mentions),selectTemplate:function(e){return'<a href="'+(e=e.original).protocol+"://"+e.model+"/"+e.id+'">'+e.label+"</a>"},menuItemTemplate:function(e){return'<img src="'+e.original.photo+'" /> '+e.string},requireLeadingSpace:!0,replaceTextSuffix:""},n={trigger:"#",values:JSON.parse(i.element.dataset.topics),selectTemplate:function(e){return'<a href="'+(e=e.original).protocol+"://"+e.model+"/"+e.id+'">'+e.label+"</a>"},menuItemTemplate:function(e){return'<img src="'+e.original.photo+'" /> '+e.string},requireLeadingSpace:!0,replaceTextSuffix:""};new r({collection:[n,a]}).attach(e)})})}function m(){document.querySelectorAll("trix-editor").forEach((e,t)=>{var i=e.toolbarElement;e==document.activeElement?i.classList.add("visible"):i.contains(document.activeElement)||i.classList.remove("visible")})}require("trix/dist/trix.css"),require("trix"),require("@rails/actiontext");export{s as ButtonToggleController,l as CloudinaryImageController,o as ColorPickerController,c as DateController,u as FileFieldController,d as PhoneController,h as SuperSelectController,p as controllerDefinitions,g as trixEditor};
2
- //# sourceMappingURL=fields.modern.js.map