lightning_ui_kit 0.2.5 → 0.3.0
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +2 -9
- data/app/assets/builds/lightning_ui_kit.css +31 -588
- data/app/assets/builds/lightning_ui_kit.js +2 -9
- data/app/assets/builds/lightning_ui_kit.js.map +4 -4
- data/app/assets/vendor/lightning_ui_kit.css +88 -582
- data/app/assets/vendor/lightning_ui_kit.js +2 -9
- data/app/components/lightning_ui_kit/button_component.html.erb +0 -4
- data/app/components/lightning_ui_kit/button_component.rb +3 -24
- data/app/components/lightning_ui_kit/checkbox_component.html.erb +7 -2
- data/app/components/lightning_ui_kit/checkbox_component.rb +0 -13
- data/app/components/lightning_ui_kit/dropdown_component.html.erb +1 -1
- data/app/components/lightning_ui_kit/dropdown_component.rb +1 -1
- data/app/components/lightning_ui_kit/dropzone_component.html.erb +38 -13
- data/app/components/lightning_ui_kit/dropzone_component.rb +16 -43
- data/app/components/lightning_ui_kit/file_input_component.html.erb +34 -4
- data/app/components/lightning_ui_kit/file_input_component.rb +20 -54
- data/app/components/lightning_ui_kit/input_component.html.erb +98 -14
- data/app/components/lightning_ui_kit/input_component.rb +19 -154
- data/app/components/lightning_ui_kit/modal_component.html.erb +2 -2
- data/app/components/lightning_ui_kit/select_component.html.erb +27 -6
- data/app/components/lightning_ui_kit/select_component.rb +23 -65
- data/app/components/lightning_ui_kit/textarea_component.html.erb +37 -5
- data/app/components/lightning_ui_kit/textarea_component.rb +17 -50
- data/app/javascript/lightning_ui_kit/controllers/modal_controller.js +1 -7
- data/app/javascript/lightning_ui_kit/index.js +0 -8
- data/config/deploy.yml +5 -2
- data/lib/lightning_ui_kit/engine.rb +6 -1
- data/lib/lightning_ui_kit/version.rb +1 -1
- metadata +17 -17
- data/app/components/lightning_ui_kit/combobox_component.html.erb +0 -137
- data/app/components/lightning_ui_kit/combobox_component.rb +0 -205
- data/app/components/lightning_ui_kit/layout_component.html.erb +0 -118
- data/app/components/lightning_ui_kit/layout_component.rb +0 -26
- data/app/components/lightning_ui_kit/sidebar_link_component.html.erb +0 -6
- data/app/components/lightning_ui_kit/sidebar_link_component.rb +0 -33
- data/app/components/lightning_ui_kit/sidebar_section_component.html.erb +0 -8
- data/app/components/lightning_ui_kit/sidebar_section_component.rb +0 -18
- data/app/components/lightning_ui_kit/tooltip_component.html.erb +0 -15
- data/app/components/lightning_ui_kit/tooltip_component.rb +0 -26
- data/app/javascript/lightning_ui_kit/controllers/combobox_controller.js +0 -704
- data/app/javascript/lightning_ui_kit/controllers/field_controller.js +0 -23
- data/app/javascript/lightning_ui_kit/controllers/layout_controller.js +0 -19
- data/app/javascript/lightning_ui_kit/controllers/tooltip_controller.js +0 -235
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Controller } from "@hotwired/stimulus"
|
|
2
|
-
|
|
3
|
-
export default class extends Controller {
|
|
4
|
-
static targets = ["field"]
|
|
5
|
-
|
|
6
|
-
fieldTargetConnected(element) {
|
|
7
|
-
element.addEventListener("mouseenter", this.handleMouseEnter)
|
|
8
|
-
element.addEventListener("mouseleave", this.handleMouseLeave)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
fieldTargetDisconnected(element) {
|
|
12
|
-
element.removeEventListener("mouseenter", this.handleMouseEnter)
|
|
13
|
-
element.removeEventListener("mouseleave", this.handleMouseLeave)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
handleMouseEnter = (event) => {
|
|
17
|
-
event.target.dataset.hover = ""
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
handleMouseLeave = (event) => {
|
|
21
|
-
delete event.target.dataset.hover
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Controller } from "@hotwired/stimulus"
|
|
2
|
-
|
|
3
|
-
export default class extends Controller {
|
|
4
|
-
static targets = ["overlay"]
|
|
5
|
-
|
|
6
|
-
openSidebar() {
|
|
7
|
-
this.overlayTarget.dataset.open = ""
|
|
8
|
-
document.body.style.overflow = "hidden"
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
closeSidebar() {
|
|
12
|
-
delete this.overlayTarget.dataset.open
|
|
13
|
-
document.body.style.overflow = ""
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
disconnect() {
|
|
17
|
-
document.body.style.overflow = ""
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { Controller } from "@hotwired/stimulus"
|
|
2
|
-
import { computePosition, autoUpdate, offset, flip, shift, arrow, size } from "@floating-ui/dom"
|
|
3
|
-
|
|
4
|
-
export default class extends Controller {
|
|
5
|
-
static targets = ["template"]
|
|
6
|
-
static values = {
|
|
7
|
-
active: Boolean,
|
|
8
|
-
position: String,
|
|
9
|
-
delay: { type: Number, default: 0 },
|
|
10
|
-
offset: { type: Number, default: 8 }
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
connect() {
|
|
14
|
-
this.showTimeout = null
|
|
15
|
-
this.hideTimeout = null
|
|
16
|
-
this.cleanup = null
|
|
17
|
-
|
|
18
|
-
// Handle ESC key to close tooltip
|
|
19
|
-
this.handleKeydown = this.handleKeydown.bind(this)
|
|
20
|
-
|
|
21
|
-
// Handle touch devices - click to toggle
|
|
22
|
-
if ('ontouchstart' in window) {
|
|
23
|
-
this.element.addEventListener('click', this.toggle.bind(this))
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
disconnect() {
|
|
28
|
-
this.hide()
|
|
29
|
-
this.clearTimeouts()
|
|
30
|
-
|
|
31
|
-
if ('ontouchstart' in window) {
|
|
32
|
-
this.element.removeEventListener('click', this.toggle.bind(this))
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
show(event) {
|
|
37
|
-
if (!this.activeValue) return
|
|
38
|
-
|
|
39
|
-
// Prevent multiple tooltips
|
|
40
|
-
this.hideOtherTooltips()
|
|
41
|
-
|
|
42
|
-
// Clear any pending hide
|
|
43
|
-
this.clearTimeouts()
|
|
44
|
-
|
|
45
|
-
if (this.delayValue > 0) {
|
|
46
|
-
this.showTimeout = setTimeout(() => this.createTooltip(event), this.delayValue)
|
|
47
|
-
} else {
|
|
48
|
-
this.createTooltip(event)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
hide() {
|
|
53
|
-
this.clearTimeouts()
|
|
54
|
-
|
|
55
|
-
if (this.delayValue > 0) {
|
|
56
|
-
this.hideTimeout = setTimeout(() => this.destroyTooltip(), this.delayValue)
|
|
57
|
-
} else {
|
|
58
|
-
this.destroyTooltip()
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
toggle(event) {
|
|
63
|
-
if (this.tooltip) {
|
|
64
|
-
this.hide()
|
|
65
|
-
} else {
|
|
66
|
-
this.show(event)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
createTooltip(event) {
|
|
71
|
-
if (this.tooltip) return
|
|
72
|
-
|
|
73
|
-
const triggerElement = event?.currentTarget || this.element
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
// Create tooltip element
|
|
77
|
-
const tooltip = document.createElement("div")
|
|
78
|
-
tooltip.innerHTML = this.templateTarget.innerHTML
|
|
79
|
-
tooltip.style.position = "absolute"
|
|
80
|
-
tooltip.style.zIndex = "9999"
|
|
81
|
-
tooltip.setAttribute('role', 'tooltip')
|
|
82
|
-
tooltip.setAttribute('data-lui-tooltip-instance', 'true')
|
|
83
|
-
document.body.appendChild(tooltip)
|
|
84
|
-
this.tooltip = tooltip
|
|
85
|
-
|
|
86
|
-
// Find the actual tooltip content (first child)
|
|
87
|
-
const tooltipContent = tooltip.firstElementChild
|
|
88
|
-
const arrowElement = tooltipContent?.querySelector("[data-tooltip-arrow]")
|
|
89
|
-
|
|
90
|
-
if (tooltipContent) {
|
|
91
|
-
// Set up auto-updating position
|
|
92
|
-
this.cleanup = autoUpdate(
|
|
93
|
-
triggerElement,
|
|
94
|
-
tooltipContent,
|
|
95
|
-
() => this.updatePosition(triggerElement, tooltipContent, arrowElement)
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
// Trigger fade-in animation
|
|
99
|
-
requestAnimationFrame(() => {
|
|
100
|
-
tooltipContent.style.opacity = '1'
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
// Add keyboard listener
|
|
104
|
-
document.addEventListener('keydown', this.handleKeydown)
|
|
105
|
-
}
|
|
106
|
-
} catch (error) {
|
|
107
|
-
console.warn('Tooltip positioning failed:', error)
|
|
108
|
-
this.destroyTooltip()
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
destroyTooltip() {
|
|
113
|
-
if (this.cleanup) {
|
|
114
|
-
this.cleanup()
|
|
115
|
-
this.cleanup = null
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (this.tooltip) {
|
|
119
|
-
const tooltipContent = this.tooltip.firstElementChild
|
|
120
|
-
|
|
121
|
-
if (tooltipContent) {
|
|
122
|
-
// Fade out animation
|
|
123
|
-
tooltipContent.style.opacity = '0'
|
|
124
|
-
|
|
125
|
-
// Remove after transition completes
|
|
126
|
-
setTimeout(() => {
|
|
127
|
-
if (this.tooltip) {
|
|
128
|
-
this.tooltip.remove()
|
|
129
|
-
this.tooltip = null
|
|
130
|
-
}
|
|
131
|
-
}, 200) // Match the transition duration
|
|
132
|
-
} else {
|
|
133
|
-
this.tooltip.remove()
|
|
134
|
-
this.tooltip = null
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
document.removeEventListener('keydown', this.handleKeydown)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
updatePosition(triggerElement, tooltipContent, arrowElement) {
|
|
142
|
-
if (!tooltipContent) return
|
|
143
|
-
|
|
144
|
-
computePosition(triggerElement, tooltipContent, {
|
|
145
|
-
placement: this.positionValue || "bottom",
|
|
146
|
-
middleware: [
|
|
147
|
-
offset(this.offsetValue),
|
|
148
|
-
size(),
|
|
149
|
-
flip(),
|
|
150
|
-
shift({ padding: 5 }),
|
|
151
|
-
...(arrowElement ? [arrow({ element: arrowElement })] : [])
|
|
152
|
-
],
|
|
153
|
-
}).then(({ x, y, placement, middlewareData }) => {
|
|
154
|
-
Object.assign(tooltipContent.style, {
|
|
155
|
-
left: `${x}px`,
|
|
156
|
-
top: `${y}px`,
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
if (arrowElement && middlewareData.arrow) {
|
|
160
|
-
this.positionArrow(arrowElement, placement, middlewareData.arrow)
|
|
161
|
-
}
|
|
162
|
-
}).catch(error => {
|
|
163
|
-
console.warn('Tooltip positioning update failed:', error)
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
positionArrow(arrowElement, placement, arrowData) {
|
|
168
|
-
const { x: arrowX, y: arrowY } = arrowData
|
|
169
|
-
const primaryPlacement = placement.split('-')[0]
|
|
170
|
-
|
|
171
|
-
// Reset arrow styles
|
|
172
|
-
Object.assign(arrowElement.style, {
|
|
173
|
-
left: '',
|
|
174
|
-
top: '',
|
|
175
|
-
right: '',
|
|
176
|
-
bottom: '',
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
const arrowOffset = '-4px'
|
|
180
|
-
|
|
181
|
-
switch (primaryPlacement) {
|
|
182
|
-
case 'top':
|
|
183
|
-
Object.assign(arrowElement.style, {
|
|
184
|
-
left: arrowX != null ? `${arrowX}px` : '',
|
|
185
|
-
bottom: arrowOffset,
|
|
186
|
-
})
|
|
187
|
-
break
|
|
188
|
-
case 'bottom':
|
|
189
|
-
Object.assign(arrowElement.style, {
|
|
190
|
-
left: arrowX != null ? `${arrowX}px` : '',
|
|
191
|
-
top: arrowOffset,
|
|
192
|
-
})
|
|
193
|
-
break
|
|
194
|
-
case 'left':
|
|
195
|
-
Object.assign(arrowElement.style, {
|
|
196
|
-
top: arrowY != null ? `${arrowY}px` : '',
|
|
197
|
-
right: arrowOffset,
|
|
198
|
-
})
|
|
199
|
-
break
|
|
200
|
-
case 'right':
|
|
201
|
-
Object.assign(arrowElement.style, {
|
|
202
|
-
top: arrowY != null ? `${arrowY}px` : '',
|
|
203
|
-
left: arrowOffset,
|
|
204
|
-
})
|
|
205
|
-
break
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
handleKeydown(event) {
|
|
210
|
-
if (event.key === 'Escape' && this.tooltip) {
|
|
211
|
-
this.hide()
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
hideOtherTooltips() {
|
|
216
|
-
// Hide any other active tooltips
|
|
217
|
-
document.querySelectorAll('[data-lui-tooltip-instance="true"]').forEach(tooltip => {
|
|
218
|
-
if (tooltip !== this.tooltip) {
|
|
219
|
-
tooltip.remove()
|
|
220
|
-
}
|
|
221
|
-
})
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
clearTimeouts() {
|
|
225
|
-
if (this.showTimeout) {
|
|
226
|
-
clearTimeout(this.showTimeout)
|
|
227
|
-
this.showTimeout = null
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (this.hideTimeout) {
|
|
231
|
-
clearTimeout(this.hideTimeout)
|
|
232
|
-
this.hideTimeout = null
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|