anchor_view_components 0.2.0 → 0.4.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: 4c83197ff06cb27fcfdcd466034127bf93227a4d1a31eb336943f92e32613a57
4
- data.tar.gz: 637ab8853d5f94950aa0c5248596e1d9f207f29910a19a43e4cff00b3b370c0a
3
+ metadata.gz: 3a15adaad5fae1588fafe2b1e7faa5e932a94fc038bff53f209af5f750510d69
4
+ data.tar.gz: e21f6066edb78a763e046dafb87a4e480001f2cc8a8ed0a59b65577675946515
5
5
  SHA512:
6
- metadata.gz: 12b154d177c5c3fb8078cd7a9e5426e76c546be22c0f886f431f4b3bc16b6f743c31538c9cc809394d314969b89ba3c583ff932546a12b4cf17c892812aaf52d
7
- data.tar.gz: f08c87c1119a03b8a468772f474c74a9fe9870a19683fe56624ada13b4dd1471b5deb60c6f495e8dfcd34e6f1e8d63b7902cbc8c4999c130855e5c5bfd968724
6
+ metadata.gz: 060b6d4e6660786980c29a22a09c18aa5330b3bebde67551b308a22d6cd21b553df308c48dac077da62e40501629b60fa64a240016a890b8d01f3c3a9f50ed69
7
+ data.tar.gz: 61ec4de1ebcc9e11f8776a9f5d229e8ceb0d0988ce814e6653753f49255edead005672440dc9e728d4fedcc8b295d53009aa970bc50097b408e8f045f031e88f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 - 2023-08-01
4
+
5
+ ### Added
6
+
7
+ - Autocomplete and Loading Indicator now allow more data attributes to be
8
+ passed in
9
+
10
+ ## 0.3.0 - 2023-07-31
11
+
12
+ ### Added
13
+
14
+ - TypeScript configuration and fixes
15
+
3
16
  ## 0.2.0 - 2023-07-31
4
17
 
5
18
  ### Added
@@ -4,8 +4,9 @@ import ActionMenuController from "./action_menu_controller";
4
4
  import AutocompleteController from "./autocomplete_controller";
5
5
  import DialogController from "./dialog_controller";
6
6
  import ToastController from "./toast_controller";
7
+ import { Application } from "@hotwired/stimulus";
7
8
 
8
- export function registerAnchorControllers(application) {
9
+ export function registerAnchorControllers(application: Application) {
9
10
  application.register("action-menu", ActionMenuController);
10
11
  application.register("autocomplete", AutocompleteController);
11
12
  application.register("dialog", DialogController);
@@ -1,6 +1,6 @@
1
- <div
2
- data-controller="autocomplete"
3
- data-autocomplete-url-value="<%= src %>"
1
+ <div
2
+ data-controller="autocomplete"
3
+ data-autocomplete-url-value="<%= src %>"
4
4
  role="combobox"
5
5
  class="group relative"
6
6
  >
@@ -22,11 +22,15 @@
22
22
  data: { autocomplete_target: "hidden" }
23
23
  }) %>
24
24
  </div>
25
- <ul
26
- data-autocomplete-target="results"
27
- class="<%= list_box_classes %> group-data-[empty='true']:hidden group-data-[loading='true']:hidden [&>li]:py-2 [&>li]:px-3 [&>li]:cursor-pointer [&>[aria-selected='true']]:bg-blue-20"
28
- >
29
- </ul>
25
+ <%= tag.ul(
26
+ class: class_names(
27
+ list_box_classes,
28
+ "group-data-[empty='true']:hidden group-data-[loading='true']:hidden [&>li]:py-2 [&>li]:px-3 [&>li]:cursor-pointer [&>[aria-selected='true']]:bg-blue-20",
29
+ ),
30
+ data: {
31
+ autocomplete_target: "results",
32
+ }.merge(list_data),
33
+ ) %>
30
34
  <div class="<%= list_box_classes %> text-center text-gray-500 hidden group-aria-[expanded][data-empty='true'][data-loading='false']:block">
31
35
  <%= t(".no_options") %>
32
36
  </div>
@@ -20,12 +20,14 @@ module Anchor
20
20
  name:,
21
21
  src:,
22
22
  readonly: false,
23
- input_data: {}
23
+ input_data: {},
24
+ list_data: {},
24
25
  )
25
26
  @form_builder = form_builder
26
27
  @name = name
27
28
  @readonly = readonly
28
29
  @input_data = input_data
30
+ @list_data = list_data
29
31
  @src = src
30
32
 
31
33
  super
@@ -37,6 +39,6 @@ module Anchor
37
39
 
38
40
  private
39
41
 
40
- attr_reader :form_builder, :name, :readonly, :input_data, :src
42
+ attr_reader :form_builder, :name, :readonly, :input_data, :list_data, :src
41
43
  end
42
44
  end
@@ -2,6 +2,10 @@ import type { ControllerConstructor } from "@hotwired/stimulus"
2
2
  import BaseAutocompleteController from "stimulus-autocomplete"
3
3
 
4
4
  class AutocompleteController extends BaseAutocompleteController {
5
+ declare readonly element: HTMLDivElement;
6
+ declare readonly inputTarget: HTMLInputElement;
7
+ declare readonly resultsTarget: HTMLUListElement;
8
+
5
9
  connect(): void {
6
10
  super.connect()
7
11
  this.element.addEventListener("loadstart", this.onLoadStart)
@@ -25,12 +29,12 @@ class AutocompleteController extends BaseAutocompleteController {
25
29
  }
26
30
 
27
31
  onLoadStart = (): void => {
28
- this.element.dataset.loading = true
32
+ this.element.dataset.loading = "true"
29
33
  }
30
34
 
31
35
  onLoadEnd = (): void => {
32
- this.element.dataset.loading = false
33
- this.element.dataset.empty = this.resultsTarget.childElementCount === 0
36
+ this.element.dataset.loading = "false"
37
+ this.element.dataset.empty = String(this.resultsTarget.childElementCount === 0)
34
38
  }
35
39
  }
36
40
 
@@ -16,6 +16,6 @@ module Anchor
16
16
 
17
17
  private
18
18
 
19
- attr_reader :classes
19
+ attr_reader :classes, :data
20
20
  end
21
21
  end
@@ -2,5 +2,6 @@
2
2
  class: class_names(
3
3
  "inline-block animate-spin border-grey-100 border-b-transparent rounded-full",
4
4
  variant
5
- )
5
+ ),
6
+ data: data,
6
7
  ) %>
@@ -1,5 +1,5 @@
1
1
  module Anchor
2
2
  module ViewComponents
3
- VERSION = "0.2.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anchor_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buoy Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-31 00:00:00.000000000 Z
11
+ date: 2023-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inline_svg