hotwire_combobox 0.2.5 → 0.3.0

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: 64ee128886d148aa44b82aaeefcd88f298c393fa9097d28c9ee343df356f31de
4
- data.tar.gz: c0eb83875bc403d94e930a0ed9e2f43e17f9c77c05bd28b341d0684086aa17ae
3
+ metadata.gz: 7895a50977941ed0bb1de0a39c1fce94e0852d00ca19e3727e39de8906c1195f
4
+ data.tar.gz: cb25d8a8466aa4f0d744c071532e23070d6dbdda12913d778d7591b8d3a9f6e4
5
5
  SHA512:
6
- metadata.gz: 8454420c02a2fc8d894c75063286d1eb7613a9d3533030f48b607d9a95317fa262744c413529b218c5ff5166810fd8dad6e051b704cda660bfd02013b8b4721e
7
- data.tar.gz: 33713116699c659f3a0d4a6a2510ad878b59894bb2bc140becc5e7543aece05563b01da82c6e6a9f1a20336dc6b89f9120eb11845af1b2b5a01ab9034bffc67b
6
+ metadata.gz: 2a76bda92289fa0213210ba83668ed8f3e965fbfa90f8624d1f28e87d727a5a282eb417a16fd5c7b9cc81295d95f22802763f1e15dcd348fcc6ad854b00534f6
7
+ data.tar.gz: 1c6ae0f949b507cb068bf8df011cab34442628fb9829c52edb99037f857d25b605125ce20c1e09936be1ff65c744b56d88c602f39dc31e3b2629b769fc804ec0
@@ -1,5 +1,5 @@
1
1
  /*!
2
- HotwireCombobox 0.2.5
2
+ HotwireCombobox 0.3.0
3
3
  */
4
4
  import { Controller } from '@hotwired/stimulus';
5
5
 
@@ -557,6 +557,11 @@ async function get(url, options) {
557
557
  return request.perform();
558
558
  }
559
559
 
560
+ async function post(url, options) {
561
+ const request = new FetchRequest("post", url, options);
562
+ return request.perform();
563
+ }
564
+
560
565
  // Copyright (c) 2021 Marcelo Lauxen
561
566
 
562
567
  // Permission is hereby granted, free of charge, to any person obtaining
@@ -800,7 +805,7 @@ Combobox.Multiselect = Base => class extends Base {
800
805
  }
801
806
 
802
807
  async _requestChips(values) {
803
- await get(this.selectionChipSrcValue, {
808
+ await post(this.selectionChipSrcValue, {
804
809
  responseKind: "turbo-stream",
805
810
  query: {
806
811
  for_id: this.element.dataset.asyncId,
@@ -1463,7 +1468,8 @@ Combobox.Toggle = Base => class extends Base {
1463
1468
  this._isSync &&
1464
1469
  !this._isSmallViewport &&
1465
1470
  inputType != "hw:clickOutside" &&
1466
- inputType != "hw:focusOutside";
1471
+ inputType != "hw:focusOutside" &&
1472
+ inputType != "hw:asyncCloser";
1467
1473
 
1468
1474
  this._lockInSelection();
1469
1475
  this._clearInvalidQuery();
@@ -1,5 +1,5 @@
1
1
  /*!
2
- HotwireCombobox 0.2.5
2
+ HotwireCombobox 0.3.0
3
3
  */
4
4
  (function (global, factory) {
5
5
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@hotwired/stimulus')) :
@@ -561,6 +561,11 @@ HotwireCombobox 0.2.5
561
561
  return request.perform();
562
562
  }
563
563
 
564
+ async function post(url, options) {
565
+ const request = new FetchRequest("post", url, options);
566
+ return request.perform();
567
+ }
568
+
564
569
  // Copyright (c) 2021 Marcelo Lauxen
565
570
 
566
571
  // Permission is hereby granted, free of charge, to any person obtaining
@@ -804,7 +809,7 @@ HotwireCombobox 0.2.5
804
809
  }
805
810
 
806
811
  async _requestChips(values) {
807
- await get(this.selectionChipSrcValue, {
812
+ await post(this.selectionChipSrcValue, {
808
813
  responseKind: "turbo-stream",
809
814
  query: {
810
815
  for_id: this.element.dataset.asyncId,
@@ -1467,7 +1472,8 @@ HotwireCombobox 0.2.5
1467
1472
  this._isSync &&
1468
1473
  !this._isSmallViewport &&
1469
1474
  inputType != "hw:clickOutside" &&
1470
- inputType != "hw:focusOutside";
1475
+ inputType != "hw:focusOutside" &&
1476
+ inputType != "hw:asyncCloser";
1471
1477
 
1472
1478
  this._lockInSelection();
1473
1479
  this._clearInvalidQuery();
@@ -1,6 +1,6 @@
1
1
  import Combobox from "hw_combobox/models/combobox/base"
2
2
  import { cancel, nextRepaint } from "hw_combobox/helpers"
3
- import { get } from "hw_combobox/vendor/requestjs"
3
+ import { post } from "hw_combobox/vendor/requestjs"
4
4
 
5
5
  Combobox.Multiselect = Base => class extends Base {
6
6
  navigateChip(event) {
@@ -79,7 +79,7 @@ Combobox.Multiselect = Base => class extends Base {
79
79
  }
80
80
 
81
81
  async _requestChips(values) {
82
- await get(this.selectionChipSrcValue, {
82
+ await post(this.selectionChipSrcValue, {
83
83
  responseKind: "turbo-stream",
84
84
  query: {
85
85
  for_id: this.element.dataset.asyncId,
@@ -16,7 +16,8 @@ Combobox.Toggle = Base => class extends Base {
16
16
  this._isSync &&
17
17
  !this._isSmallViewport &&
18
18
  inputType != "hw:clickOutside" &&
19
- inputType != "hw:focusOutside"
19
+ inputType != "hw:focusOutside" &&
20
+ inputType != "hw:asyncCloser"
20
21
 
21
22
  this._lockInSelection()
22
23
  this._clearInvalidQuery()
@@ -16,6 +16,7 @@ class HotwireCombobox::Component
16
16
  data: {},
17
17
  dialog_label: nil,
18
18
  form: nil,
19
+ free_text: false,
19
20
  id: nil,
20
21
  input: {},
21
22
  label: nil,
@@ -26,9 +27,9 @@ class HotwireCombobox::Component
26
27
  options: [],
27
28
  value: nil,
28
29
  **rest
29
- @view, @autocomplete, @id, @name, @value, @form, @async_src, @label,
30
+ @view, @autocomplete, @id, @name, @value, @form, @async_src, @label, @free_text,
30
31
  @name_when_new, @open, @data, @mobile_at, @multiselect_chip_src, @options, @dialog_label =
31
- view, autocomplete, id, name.to_s, value, form, async_src, label,
32
+ view, autocomplete, id, name.to_s, value, form, async_src, label, free_text,
32
33
  name_when_new, open, data, mobile_at, multiselect_chip_src, options, dialog_label
33
34
 
34
35
  @combobox_attrs = input.reverse_merge(rest).deep_symbolize_keys
@@ -189,9 +190,17 @@ class HotwireCombobox::Component
189
190
 
190
191
  private
191
192
  attr_reader :view, :autocomplete, :id, :name, :value, :form,
192
- :name_when_new, :open, :data, :combobox_attrs, :mobile_at,
193
+ :free_text, :open, :data, :combobox_attrs, :mobile_at,
193
194
  :association_name, :multiselect_chip_src
194
195
 
196
+ def name_when_new
197
+ if free_text && @name_when_new.blank?
198
+ hidden_field_name
199
+ else
200
+ @name_when_new
201
+ end
202
+ end
203
+
195
204
  def name_when_new_on_multiselect_must_match_original_name
196
205
  return unless multiselect? && name_when_new.present?
197
206
 
@@ -37,7 +37,7 @@ module HotwireCombobox
37
37
  def hw_paginated_combobox_options(
38
38
  options,
39
39
  for_id: params[:for_id],
40
- src: request.fullpath,
40
+ src: hw_fullpath_for_pagination,
41
41
  next_page: nil,
42
42
  render_in: {},
43
43
  include_blank: {},
@@ -168,6 +168,11 @@ module HotwireCombobox
168
168
  end
169
169
 
170
170
  private
171
+ def hw_fullpath_for_pagination
172
+ transient_params = %w[ input_type ]
173
+ hw_uri_with_params request.path, **request.query_parameters.except(*transient_params)
174
+ end
175
+
171
176
  def hw_combobox_next_page_uri(uri, next_page, for_id)
172
177
  return unless next_page
173
178
 
@@ -1,3 +1,3 @@
1
1
  module HotwireCombobox
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwire_combobox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Farias