reflex_behaviors 0.0.5 → 0.0.7

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.
@@ -0,0 +1,62 @@
1
+ export function template (html) {
2
+ let template = document.createElement('template')
3
+ template.innerHTML = html
4
+ return template
5
+ }
6
+
7
+ export function appendHTML (html, parent) {
8
+ parent = parent || document.body
9
+ const clone = template(html).content.cloneNode(true)
10
+ const child = clone.querySelector('*')
11
+ return parent.appendChild(child)
12
+ }
13
+
14
+ export function addHighlight (element, options = {}) {
15
+ if (!element) return
16
+ removeHighlight(element)
17
+ let { outline, outlineOffset } = options
18
+
19
+ outline = outline || 'dashed 3px red'
20
+ outlineOffset = outlineOffset || '0px'
21
+
22
+ element.originalStyles = element.originalStyles || {
23
+ display: element.style.display,
24
+ minHeight: element.style.minHeight,
25
+ minWidth: element.style.minWidth,
26
+ outline: element.style.outline,
27
+ outlineOffset: element.style.outlineOffset
28
+ }
29
+
30
+ if (
31
+ getComputedStyle(element).display.match(/^inline$/i) &&
32
+ element.offsetWidth === 0 &&
33
+ element.offsetHeight === 0
34
+ ) {
35
+ element.style.display = 'inline-block'
36
+ element.style.minHeight = '2px'
37
+ element.style.minWidth = '2px'
38
+ }
39
+ element.style.outline = outline
40
+ element.style.outlineOffset = outlineOffset
41
+ element.dataset.reflexBehaviorsHighlight = true
42
+ }
43
+
44
+ export function removeHighlight (element) {
45
+ if (!element) return
46
+ if (element.originalStyles) {
47
+ for (const [key, value] of Object.entries(element.originalStyles))
48
+ value ? (element.style[key] = value) : (element.style[key] = '')
49
+ delete element.originalStyles
50
+ }
51
+ delete element.dataset.reflexBehaviorsHighlight
52
+ }
53
+
54
+ export function coordinates (element) {
55
+ const rect = element.getBoundingClientRect()
56
+ return {
57
+ left: rect.left + window.scrollX,
58
+ top: rect.top + window.scrollY,
59
+ width: element.offsetWidth,
60
+ height: element.offsetHeight
61
+ }
62
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReflexBehaviors
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.7"
5
5
  end
data/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "reflex_behaviors",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Pre-built easy to use reactive TurboReflex behaviors for Rails/Hotwire apps.",
5
5
  "main": "app/javascript/index.js",
6
6
  "repository": "https://github.com/hopsoft/reflex_behaviors",
7
7
  "author": "Nate Hopkins (hopsoft) <natehop@gmail.com>",
8
8
  "license": "MIT",
9
9
  "dependencies": {
10
- "turbo_ready": ">= 0.1.2",
11
- "turbo_reflex": ">= 0.0.28"
10
+ "turbo_ready": ">= 0.1.3",
11
+ "turbo_reflex": ">= 0.0.29"
12
12
  },
13
13
  "peerDependencies": {
14
- "@hotwired/turbo": ">= 7.2",
15
14
  "@hotwired/turbo-rails": ">= 7.2"
16
15
  },
17
16
  "devDependencies": {
18
- "esbuild": "^0.15.7",
17
+ "esbuild": "^0.16.1",
19
18
  "eslint": "^8.19.0",
20
19
  "prettier-standard": "^16.4.1"
21
20
  },
@@ -22,8 +22,8 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_dependency "rails", ">= 6.1"
24
24
  s.add_dependency "turbo-rails", ">= 1.1"
25
- s.add_dependency "turbo_ready", ">= 0.1.2"
26
- s.add_dependency "turbo_reflex", ">= 0.0.28"
25
+ s.add_dependency "turbo_ready", ">= 0.1.3"
26
+ s.add_dependency "turbo_reflex", ">= 0.0.29"
27
27
 
28
28
  s.add_development_dependency "magic_frozen_string_literal"
29
29
  s.add_development_dependency "minitest-reporters"