ariadne_view_components 0.0.53-x64-mingw-ucrt → 0.0.55-x64-mingw-ucrt

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/app/components/ariadne/accumulator_controller/accumulator_controller.js +2 -2
  4. data/app/components/ariadne/accumulator_controller/accumulator_controller.ts +2 -2
  5. data/app/components/ariadne/options_controller/options_controller.js +2 -2
  6. data/app/components/ariadne/options_controller/options_controller.ts +2 -2
  7. data/app/components/ariadne/string_match_controller/string_match_controller.js +2 -2
  8. data/app/components/ariadne/string_match_controller/string_match_controller.ts +2 -2
  9. data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts +3 -0
  10. data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.js +38 -4
  11. data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.ts +45 -4
  12. data/app/lib/ariadne/form_builder.rb +6 -0
  13. data/lib/ariadne/view_components/version.rb +1 -1
  14. metadata +2 -21
  15. data/app/assets/javascripts/ariadne_view_components.js +0 -8
  16. data/app/assets/javascripts/ariadne_view_components.js.map +0 -1
  17. data/app/assets/javascripts/components/ariadne/accumulator_controller/accumulator_controller.d.ts +0 -22
  18. data/app/assets/javascripts/components/ariadne/ariadne-form.d.ts +0 -22
  19. data/app/assets/javascripts/components/ariadne/ariadne.d.ts +0 -2
  20. data/app/assets/javascripts/components/ariadne/clipboard_copy_component/clipboard-copy-component.d.ts +0 -4
  21. data/app/assets/javascripts/components/ariadne/dropdown/menu_component.d.ts +0 -1
  22. data/app/assets/javascripts/components/ariadne/events_controller/events_controller.d.ts +0 -4
  23. data/app/assets/javascripts/components/ariadne/options_controller/options_controller.d.ts +0 -39
  24. data/app/assets/javascripts/components/ariadne/outlet_manager_controller/outlet_manager_controller.d.ts +0 -42
  25. data/app/assets/javascripts/components/ariadne/rich_text_area_component/rich-text-area-component.d.ts +0 -6
  26. data/app/assets/javascripts/components/ariadne/slideover_component/slideover-component.d.ts +0 -9
  27. data/app/assets/javascripts/components/ariadne/string_match_controller/string_match_controller.d.ts +0 -27
  28. data/app/assets/javascripts/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts +0 -45
  29. data/app/assets/javascripts/components/ariadne/tab_container_component/tab-container-component.d.ts +0 -1
  30. data/app/assets/javascripts/components/ariadne/tab_nav_component/tab-nav-component.d.ts +0 -9
  31. data/app/assets/javascripts/components/ariadne/time_ago_component/time-ago-component.d.ts +0 -1
  32. data/app/assets/javascripts/components/ariadne/toggleable_controller/toggleable_controller.d.ts +0 -34
  33. data/app/assets/javascripts/components/ariadne/tooltip_component/tooltip-component.d.ts +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10b1f24a95ae21c1218d1c888f63f54a8a57b6ea92bb75243cd74d7c7ef6bce2
4
- data.tar.gz: f76d239e2a4242a463fdb30d824d9b3eb8fcc263a6c2d7f2dbc031f4314fa1bd
3
+ metadata.gz: b436d8e2cc94610e010b29b30493345298ddb96ee6de808758c40cf650ea057b
4
+ data.tar.gz: 60ff7d8365ba73ad2cd0bd1521919231aefbd61889c3a34ec3c2305bb8187391
5
5
  SHA512:
6
- metadata.gz: 5ef362e3f2dab0b0986721f73f8e5676c054b3b9b41fca01654fb47738be74975fe6e60fad493fac2ec004235c4b7acfd1d3db076f318450b5e819d74f1976b4
7
- data.tar.gz: 5c7a5095f5553e7c5215bf117f30f82e906850f5f52380a86b2fb3f412a2224e4c7b38f778882aff1eee412b0705e8dfde97179397dcff3430a0d67eaea5e075
6
+ metadata.gz: d8580d91cff9254e2281eb392810d69c539701aabc1c44c7e0eb88b9a9f7d7a09cd77dcd70f7e17a85807c0b44bf02ad5137607c045059a50746687a04d617e7
7
+ data.tar.gz: 477670d4395d32fac24115fadb6733e74fa855676f3617f3bd601aeb14defa68c92bf1550612965266f799b6405b65a934856351a883440fc8d1ccea330ef210
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [v0.0.54] - 13-07-2023
2
+ null
3
+ ## [v0.0.53] - 11-07-2023
4
+ null
1
5
  ## [v0.0.52] - 07-07-2023
2
6
  null
3
7
  ## [v0.0.51] - 30-06-2023
@@ -5,7 +5,7 @@ class AccumulatorController extends Controller {
5
5
  }
6
6
  accumulate() {
7
7
  let sum = 0;
8
- for (let i in this.sumTargets) {
8
+ for (const i in this.sumTargets) {
9
9
  const target = this.sumTargets[i];
10
10
  const value = Number(target.getAttribute(this.sumAttrValue));
11
11
  if (!isNaN(value)) {
@@ -15,7 +15,7 @@ class AccumulatorController extends Controller {
15
15
  this.setAttributesTo(sum);
16
16
  }
17
17
  setAttributesTo(sum) {
18
- for (let i in this.syncAttrsValue) {
18
+ for (const i in this.syncAttrsValue) {
19
19
  const attr = this.syncAttrsValue[i];
20
20
  this.accumulator.setAttribute(attr, sum.toString());
21
21
  }
@@ -24,7 +24,7 @@ export default class AccumulatorController extends Controller {
24
24
 
25
25
  accumulate() {
26
26
  let sum = 0
27
- for (let i in this.sumTargets) {
27
+ for (const i in this.sumTargets) {
28
28
  const target = this.sumTargets[i]
29
29
  const value = Number(target.getAttribute(this.sumAttrValue))
30
30
  if (!isNaN(value)) {
@@ -36,7 +36,7 @@ export default class AccumulatorController extends Controller {
36
36
  }
37
37
 
38
38
  setAttributesTo(sum: number) {
39
- for (let i in this.syncAttrsValue) {
39
+ for (const i in this.syncAttrsValue) {
40
40
  const attr = this.syncAttrsValue[i]
41
41
  this.accumulator.setAttribute(attr, sum.toString())
42
42
  }
@@ -14,7 +14,7 @@ class OptionsController extends SyncedBooleanAttributesController {
14
14
  select(event, updateTo = {}) {
15
15
  var _a;
16
16
  const activeOptions = updateTo.data;
17
- for (let index in this.optionTargets) {
17
+ for (const index in this.optionTargets) {
18
18
  const target = this.optionTargets[index];
19
19
  const wasSelected = target === event.currentTarget;
20
20
  const isCurrentlyActive = (_a = this.getValueForElement(target)) !== null && _a !== void 0 ? _a : false;
@@ -78,7 +78,7 @@ _OptionsController_instances = new WeakSet(), _OptionsController_shouldChangeSta
78
78
  if (elementValue) {
79
79
  return elementValue;
80
80
  }
81
- return element.innerText.trim();
81
+ return element.textContent.trim();
82
82
  };
83
83
  OptionsController.outlets = SyncedBooleanAttributesController.outlets;
84
84
  OptionsController.targets = ['option'];
@@ -31,7 +31,7 @@ export default class OptionsController
31
31
 
32
32
  select(event: Event, updateTo: TOutletChangeData<TActiveOptions> = {}) {
33
33
  const activeOptions = updateTo.data
34
- for (let index in this.optionTargets) {
34
+ for (const index in this.optionTargets) {
35
35
  const target = this.optionTargets[index]
36
36
  const wasSelected = target === event.currentTarget
37
37
  const isCurrentlyActive = this.getValueForElement(target) ?? false
@@ -101,7 +101,7 @@ export default class OptionsController
101
101
  return elementValue
102
102
  }
103
103
 
104
- return (element as HTMLElement).innerText.trim()
104
+ return (element as HTMLElement).textContent.trim()
105
105
  }
106
106
 
107
107
  getValueForElement(element: Element) {
@@ -23,7 +23,7 @@ class StringMatchController extends SyncedBooleanAttributesController {
23
23
  }
24
24
  getValueForElement(element) {
25
25
  var _a, _b;
26
- return (_b = (_a = element.innerText) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(this.keywordValue.toLowerCase())) !== null && _b !== void 0 ? _b : false;
26
+ return (_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(this.keywordValue.toLowerCase())) !== null && _b !== void 0 ? _b : false;
27
27
  }
28
28
  getState() {
29
29
  return this.keywordValue;
@@ -32,7 +32,7 @@ class StringMatchController extends SyncedBooleanAttributesController {
32
32
  _StringMatchController_instances = new WeakSet(), _StringMatchController_compareKeywordToTargets = function _StringMatchController_compareKeywordToTargets() {
33
33
  if (this.hasMatchTarget) {
34
34
  let foundMatch = false;
35
- for (let index in this.matchTargets) {
35
+ for (const index in this.matchTargets) {
36
36
  const target = this.matchTargets[index];
37
37
  const value = this.getValueForElement(target);
38
38
  this.updateAttributesForElement(target, value);
@@ -34,7 +34,7 @@ export default class StringMatchController
34
34
  #compareKeywordToTargets() {
35
35
  if (this.hasMatchTarget) {
36
36
  let foundMatch = false
37
- for (let index in this.matchTargets) {
37
+ for (const index in this.matchTargets) {
38
38
  const target = this.matchTargets[index]
39
39
  const value = this.getValueForElement(target)
40
40
  this.updateAttributesForElement(target, value)
@@ -54,7 +54,7 @@ export default class StringMatchController
54
54
  }
55
55
 
56
56
  getValueForElement(element: Element) {
57
- return (element as HTMLElement).innerText?.toLowerCase().includes(this.keywordValue.toLowerCase()) ?? false
57
+ return (element as HTMLElement).textContent?.toLowerCase().includes(this.keywordValue.toLowerCase()) ?? false
58
58
  }
59
59
 
60
60
  getState() {
@@ -39,6 +39,9 @@ export default class SyncedBooleanAttributesController<T> extends OutletManagerC
39
39
  getElementsToSync(): Array<Element> | null | undefined;
40
40
  connect(): void;
41
41
  updateAttributesForElement(element: Element, value: boolean): void;
42
+ getSyncedAttrsForElement(element: Element): string[] | null;
43
+ getAntiAttrsForElement(element: Element): string[] | null;
44
+ getParsedAttributeForElement<T>(element: Element, attribute: string): T | null;
42
45
  syncElementAttributes(): void;
43
46
  validateAttrChange(dispatchEvent: TStimulusDispatchEvent<TSyncAttrDetail>): void;
44
47
  doesElementHaveOnAttrs(element: Element): boolean;
@@ -61,11 +61,45 @@ class SyncedBooleanAttributesController extends OutletManagerController {
61
61
  updateAttributesForElement(element, value) {
62
62
  // This is how you should update any synced or anti-synced attrs on your elements
63
63
  // Do not do it manually unless you are very sure of what you're doing
64
+ const syncedAttrs = this.getSyncedAttrsForElement(element);
65
+ if (syncedAttrs === null || syncedAttrs === void 0 ? void 0 : syncedAttrs.length) {
66
+ __classPrivateFieldGet(this, _SyncedBooleanAttributesController_instances, "m", _SyncedBooleanAttributesController_setAttrs).call(this, element, syncedAttrs, value);
67
+ }
68
+ const antiAttrs = this.getAntiAttrsForElement(element);
69
+ if (antiAttrs === null || antiAttrs === void 0 ? void 0 : antiAttrs.length) {
70
+ __classPrivateFieldGet(this, _SyncedBooleanAttributesController_instances, "m", _SyncedBooleanAttributesController_setAttrs).call(this, element, antiAttrs, !value);
71
+ }
72
+ }
73
+ getSyncedAttrsForElement(element) {
74
+ const parsedAttrs = this.getParsedAttributeForElement(element, 'data-options-synced-attrs-value');
75
+ if (parsedAttrs) {
76
+ return parsedAttrs;
77
+ }
64
78
  if (this.hasSyncedAttrsValue) {
65
- __classPrivateFieldGet(this, _SyncedBooleanAttributesController_instances, "m", _SyncedBooleanAttributesController_setAttrs).call(this, element, this.syncedAttrsValue, value);
79
+ return this.syncedAttrsValue;
80
+ }
81
+ return null;
82
+ }
83
+ getAntiAttrsForElement(element) {
84
+ const parsedAttrs = this.getParsedAttributeForElement(element, 'data-options-anti-attrs-value');
85
+ if (parsedAttrs) {
86
+ return parsedAttrs;
66
87
  }
67
88
  if (this.hasAntiAttrsValue) {
68
- __classPrivateFieldGet(this, _SyncedBooleanAttributesController_instances, "m", _SyncedBooleanAttributesController_setAttrs).call(this, element, this.antiAttrsValue, !value);
89
+ return this.antiAttrsValue;
90
+ }
91
+ return null;
92
+ }
93
+ getParsedAttributeForElement(element, attribute) {
94
+ const attr = element.getAttribute(attribute);
95
+ try {
96
+ if (attr === null) {
97
+ throw new Error('Bad attr');
98
+ }
99
+ return JSON.parse(attr);
100
+ }
101
+ catch (err) {
102
+ return null;
69
103
  }
70
104
  }
71
105
  syncElementAttributes() {
@@ -74,7 +108,7 @@ class SyncedBooleanAttributesController extends OutletManagerController {
74
108
  // Essentially just a "sync attrs and anti-attrs on mount" function
75
109
  const elements = this.getElementsToSync();
76
110
  if (elements === null || elements === void 0 ? void 0 : elements.length) {
77
- for (let index in elements) {
111
+ for (const index in elements) {
78
112
  const element = elements[index];
79
113
  const value = (_a = this.getValueForElement(element)) !== null && _a !== void 0 ? _a : false;
80
114
  this.updateAttributesForElement(element, value);
@@ -137,7 +171,7 @@ _SyncedBooleanAttributesController_instances = new WeakSet(), _SyncedBooleanAttr
137
171
  // Attempts to change the attr for an element. However, it'll dispatch an event
138
172
  // first so other controllers get the opportunity to deny it
139
173
  const attrState = JSON.stringify(value);
140
- for (let index in attrs) {
174
+ for (const index in attrs) {
141
175
  const attr = attrs[index];
142
176
  const dispatchEvent = this.dispatch('attrChange', {
143
177
  target: element,
@@ -93,12 +93,53 @@ export default class SyncedBooleanAttributesController<T> extends OutletManagerC
93
93
  updateAttributesForElement(element: Element, value: boolean) {
94
94
  // This is how you should update any synced or anti-synced attrs on your elements
95
95
  // Do not do it manually unless you are very sure of what you're doing
96
+ const syncedAttrs = this.getSyncedAttrsForElement(element)
97
+ if (syncedAttrs?.length) {
98
+ this.#setAttrs(element, syncedAttrs, value)
99
+ }
100
+
101
+ const antiAttrs = this.getAntiAttrsForElement(element)
102
+ if (antiAttrs?.length) {
103
+ this.#setAttrs(element, antiAttrs, !value)
104
+ }
105
+ }
106
+
107
+ getSyncedAttrsForElement(element: Element) {
108
+ const parsedAttrs = this.getParsedAttributeForElement<Array<string>>(element, 'data-options-synced-attrs-value')
109
+ if (parsedAttrs) {
110
+ return parsedAttrs
111
+ }
112
+
96
113
  if (this.hasSyncedAttrsValue) {
97
- this.#setAttrs(element, this.syncedAttrsValue, value)
114
+ return this.syncedAttrsValue
115
+ }
116
+
117
+ return null
118
+ }
119
+
120
+ getAntiAttrsForElement(element: Element) {
121
+ const parsedAttrs = this.getParsedAttributeForElement<Array<string>>(element, 'data-options-anti-attrs-value')
122
+ if (parsedAttrs) {
123
+ return parsedAttrs
98
124
  }
99
125
 
100
126
  if (this.hasAntiAttrsValue) {
101
- this.#setAttrs(element, this.antiAttrsValue, !value)
127
+ return this.antiAttrsValue
128
+ }
129
+
130
+ return null
131
+ }
132
+
133
+ getParsedAttributeForElement<T>(element: Element, attribute: string) {
134
+ const attr = element.getAttribute(attribute)
135
+ try {
136
+ if (attr === null) {
137
+ throw new Error('Bad attr')
138
+ }
139
+
140
+ return JSON.parse(attr) as T
141
+ } catch (err) {
142
+ return null
102
143
  }
103
144
  }
104
145
 
@@ -108,7 +149,7 @@ export default class SyncedBooleanAttributesController<T> extends OutletManagerC
108
149
  const elements = this.getElementsToSync()
109
150
 
110
151
  if (elements?.length) {
111
- for (let index in elements) {
152
+ for (const index in elements) {
112
153
  const element = elements[index]
113
154
  const value = this.getValueForElement(element) ?? false
114
155
  this.updateAttributesForElement(element, value)
@@ -181,7 +222,7 @@ export default class SyncedBooleanAttributesController<T> extends OutletManagerC
181
222
  // Attempts to change the attr for an element. However, it'll dispatch an event
182
223
  // first so other controllers get the opportunity to deny it
183
224
  const attrState = JSON.stringify(value)
184
- for (let index in attrs) {
225
+ for (const index in attrs) {
185
226
  const attr = attrs[index]
186
227
 
187
228
  const dispatchEvent = this.dispatch('attrChange', {
@@ -70,5 +70,11 @@ module Ariadne
70
70
  options[:class] = merge_class_names(DEFAULT_PASSWORD_CLASSES, options.delete(:classes))
71
71
  super(method, **options)
72
72
  end
73
+
74
+ DEFAULT_FILE_FIELD_CLASSES = ""
75
+ def file_field(method, options = {})
76
+ options[:class] = merge_class_names(DEFAULT_FILE_FIELD_CLASSES, options.delete(:classes))
77
+ super(method, **options)
78
+ end
73
79
  end
74
80
  end
@@ -3,6 +3,6 @@
3
3
  # :nocov:
4
4
  module Ariadne
5
5
  module ViewComponents
6
- VERSION = "0.0.53"
6
+ VERSION = "0.0.55"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ariadne_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.53
4
+ version: 0.0.55
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-11 00:00:00.000000000 Z
11
+ date: 2023-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tailwind_merge
@@ -112,25 +112,6 @@ files:
112
112
  - LICENSE.txt
113
113
  - README.md
114
114
  - app/assets/builds/ariadne_view_components.css
115
- - app/assets/javascripts/ariadne_view_components.js
116
- - app/assets/javascripts/ariadne_view_components.js.map
117
- - app/assets/javascripts/components/ariadne/accumulator_controller/accumulator_controller.d.ts
118
- - app/assets/javascripts/components/ariadne/ariadne-form.d.ts
119
- - app/assets/javascripts/components/ariadne/ariadne.d.ts
120
- - app/assets/javascripts/components/ariadne/clipboard_copy_component/clipboard-copy-component.d.ts
121
- - app/assets/javascripts/components/ariadne/dropdown/menu_component.d.ts
122
- - app/assets/javascripts/components/ariadne/events_controller/events_controller.d.ts
123
- - app/assets/javascripts/components/ariadne/options_controller/options_controller.d.ts
124
- - app/assets/javascripts/components/ariadne/outlet_manager_controller/outlet_manager_controller.d.ts
125
- - app/assets/javascripts/components/ariadne/rich_text_area_component/rich-text-area-component.d.ts
126
- - app/assets/javascripts/components/ariadne/slideover_component/slideover-component.d.ts
127
- - app/assets/javascripts/components/ariadne/string_match_controller/string_match_controller.d.ts
128
- - app/assets/javascripts/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts
129
- - app/assets/javascripts/components/ariadne/tab_container_component/tab-container-component.d.ts
130
- - app/assets/javascripts/components/ariadne/tab_nav_component/tab-nav-component.d.ts
131
- - app/assets/javascripts/components/ariadne/time_ago_component/time-ago-component.d.ts
132
- - app/assets/javascripts/components/ariadne/toggleable_controller/toggleable_controller.d.ts
133
- - app/assets/javascripts/components/ariadne/tooltip_component/tooltip-component.d.ts
134
115
  - app/assets/stylesheets/ariadne_view_components.css
135
116
  - app/assets/stylesheets/dropdown.css
136
117
  - app/assets/stylesheets/prosemirror.css