administrate-bootstrap-theme 0.1.0 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -11
- data/Rakefile +10 -14
- data/app/assets/config/administrate-bootstrap-theme_manifest.js +1 -0
- data/app/assets/javascripts/administrate-bootstrap-theme/theme.js +2 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/_base.scss +17 -1
- data/app/assets/stylesheets/administrate-bootstrap-theme/components/_content_body.scss +17 -3
- data/app/assets/stylesheets/administrate-bootstrap-theme/components/_form.scss +52 -16
- data/app/assets/stylesheets/administrate-bootstrap-theme/theme.scss +12 -0
- data/lib/administrate-bootstrap-theme/engine.rb +2 -0
- data/lib/administrate-bootstrap-theme/version.rb +1 -1
- data/node_modules/bootstrap/js/src/alert.js +141 -0
- data/node_modules/bootstrap/js/src/base-component.js +46 -0
- data/node_modules/bootstrap/js/src/button.js +95 -0
- data/node_modules/bootstrap/js/src/carousel.js +624 -0
- data/node_modules/bootstrap/js/src/collapse.js +410 -0
- data/node_modules/bootstrap/js/src/dom/data.js +57 -0
- data/node_modules/bootstrap/js/src/dom/event-handler.js +331 -0
- data/node_modules/bootstrap/js/src/dom/manipulator.js +80 -0
- data/node_modules/bootstrap/js/src/dom/selector-engine.js +75 -0
- data/node_modules/bootstrap/js/src/dropdown.js +543 -0
- data/node_modules/bootstrap/js/src/modal.js +582 -0
- data/node_modules/bootstrap/js/src/offcanvas.js +279 -0
- data/node_modules/bootstrap/js/src/popover.js +171 -0
- data/node_modules/bootstrap/js/src/scrollspy.js +319 -0
- data/node_modules/bootstrap/js/src/tab.js +220 -0
- data/node_modules/bootstrap/js/src/toast.js +219 -0
- data/node_modules/bootstrap/js/src/tooltip.js +802 -0
- data/node_modules/bootstrap/js/src/util/index.js +253 -0
- data/node_modules/bootstrap/js/src/util/sanitizer.js +127 -0
- data/node_modules/bootstrap/js/src/util/scrollbar.js +70 -0
- data/node_modules/bootstrap/scss/_accordion.scss +116 -0
- data/node_modules/bootstrap/scss/_alert.scss +57 -0
- data/node_modules/bootstrap/scss/_badge.scss +29 -0
- data/node_modules/bootstrap/scss/_breadcrumb.scss +28 -0
- data/node_modules/bootstrap/scss/_button-group.scss +139 -0
- data/node_modules/bootstrap/scss/_buttons.scss +111 -0
- data/node_modules/bootstrap/scss/_card.scss +215 -0
- data/node_modules/bootstrap/scss/_carousel.scss +229 -0
- data/node_modules/bootstrap/scss/_close.scss +40 -0
- data/node_modules/bootstrap/scss/_containers.scss +41 -0
- data/node_modules/bootstrap/scss/_dropdown.scss +246 -0
- data/node_modules/bootstrap/scss/_forms.scss +9 -0
- data/node_modules/bootstrap/scss/_functions.scss +205 -0
- data/node_modules/bootstrap/scss/_grid.scss +22 -0
- data/node_modules/bootstrap/scss/_helpers.scss +7 -0
- data/node_modules/bootstrap/scss/_images.scss +42 -0
- data/node_modules/bootstrap/scss/_list-group.scss +174 -0
- data/node_modules/bootstrap/scss/_mixins.scss +41 -0
- data/node_modules/bootstrap/scss/_modal.scss +237 -0
- data/node_modules/bootstrap/scss/_nav.scss +139 -0
- data/node_modules/bootstrap/scss/_navbar.scss +306 -0
- data/node_modules/bootstrap/scss/_offcanvas.scss +77 -0
- data/node_modules/bootstrap/scss/_pagination.scss +64 -0
- data/node_modules/bootstrap/scss/_popover.scss +158 -0
- data/node_modules/bootstrap/scss/_progress.scss +48 -0
- data/node_modules/bootstrap/scss/_reboot.scss +621 -0
- data/node_modules/bootstrap/scss/_root.scss +16 -0
- data/node_modules/bootstrap/scss/_spinners.scss +69 -0
- data/node_modules/bootstrap/scss/_tables.scss +150 -0
- data/node_modules/bootstrap/scss/_toasts.scss +51 -0
- data/node_modules/bootstrap/scss/_tooltip.scss +115 -0
- data/node_modules/bootstrap/scss/_transitions.scss +21 -0
- data/node_modules/bootstrap/scss/_type.scss +104 -0
- data/node_modules/bootstrap/scss/_utilities.scss +594 -0
- data/node_modules/bootstrap/scss/_variables.scss +1464 -0
- data/node_modules/bootstrap/scss/bootstrap-grid.scss +65 -0
- data/node_modules/bootstrap/scss/bootstrap-reboot.scss +15 -0
- data/node_modules/bootstrap/scss/bootstrap-utilities.scss +18 -0
- data/node_modules/bootstrap/scss/bootstrap.scss +52 -0
- data/node_modules/bootstrap/scss/forms/_floating-labels.scss +61 -0
- data/node_modules/bootstrap/scss/forms/_form-check.scss +152 -0
- data/node_modules/bootstrap/scss/forms/_form-control.scss +219 -0
- data/node_modules/bootstrap/scss/forms/_form-range.scss +91 -0
- data/node_modules/bootstrap/scss/forms/_form-select.scss +67 -0
- data/node_modules/bootstrap/scss/forms/_form-text.scss +11 -0
- data/node_modules/bootstrap/scss/forms/_input-group.scss +121 -0
- data/node_modules/bootstrap/scss/forms/_labels.scss +36 -0
- data/node_modules/bootstrap/scss/forms/_validation.scss +12 -0
- data/node_modules/bootstrap/scss/helpers/_clearfix.scss +3 -0
- data/node_modules/bootstrap/scss/helpers/_colored-links.scss +12 -0
- data/node_modules/bootstrap/scss/helpers/_position.scss +30 -0
- data/node_modules/bootstrap/scss/helpers/_ratio.scss +26 -0
- data/node_modules/bootstrap/scss/helpers/_stretched-link.scss +15 -0
- data/node_modules/bootstrap/scss/helpers/_text-truncation.scss +7 -0
- data/node_modules/bootstrap/scss/helpers/_visually-hidden.scss +8 -0
- data/node_modules/bootstrap/scss/mixins/_alert.scss +11 -0
- data/node_modules/bootstrap/scss/mixins/_border-radius.scss +78 -0
- data/node_modules/bootstrap/scss/mixins/_box-shadow.scss +18 -0
- data/node_modules/bootstrap/scss/mixins/_breakpoints.scss +127 -0
- data/node_modules/bootstrap/scss/mixins/_buttons.scss +133 -0
- data/node_modules/bootstrap/scss/mixins/_caret.scss +64 -0
- data/node_modules/bootstrap/scss/mixins/_clearfix.scss +9 -0
- data/node_modules/bootstrap/scss/mixins/_container.scss +9 -0
- data/node_modules/bootstrap/scss/mixins/_deprecate.scss +10 -0
- data/node_modules/bootstrap/scss/mixins/_forms.scss +134 -0
- data/node_modules/bootstrap/scss/mixins/_gradients.scss +47 -0
- data/node_modules/bootstrap/scss/mixins/_grid.scss +120 -0
- data/node_modules/bootstrap/scss/mixins/_image.scss +16 -0
- data/node_modules/bootstrap/scss/mixins/_list-group.scss +24 -0
- data/node_modules/bootstrap/scss/mixins/_lists.scss +7 -0
- data/node_modules/bootstrap/scss/mixins/_pagination.scss +31 -0
- data/node_modules/bootstrap/scss/mixins/_reset-text.scss +17 -0
- data/node_modules/bootstrap/scss/mixins/_resize.scss +6 -0
- data/node_modules/bootstrap/scss/mixins/_table-variants.scss +21 -0
- data/node_modules/bootstrap/scss/mixins/_text-truncate.scss +8 -0
- data/node_modules/bootstrap/scss/mixins/_transition.scss +26 -0
- data/node_modules/bootstrap/scss/mixins/_utilities.scss +68 -0
- data/node_modules/bootstrap/scss/mixins/_visually-hidden.scss +29 -0
- data/node_modules/bootstrap/scss/utilities/_api.scss +47 -0
- data/node_modules/bootstrap/scss/vendor/_rfs.scss +312 -0
- metadata +106 -19
@@ -0,0 +1,331 @@
|
|
1
|
+
/**
|
2
|
+
* --------------------------------------------------------------------------
|
3
|
+
* Bootstrap (v5.0.0-beta3): dom/event-handler.js
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
|
+
* --------------------------------------------------------------------------
|
6
|
+
*/
|
7
|
+
|
8
|
+
import { getjQuery } from '../util/index'
|
9
|
+
|
10
|
+
/**
|
11
|
+
* ------------------------------------------------------------------------
|
12
|
+
* Constants
|
13
|
+
* ------------------------------------------------------------------------
|
14
|
+
*/
|
15
|
+
|
16
|
+
const namespaceRegex = /[^.]*(?=\..*)\.|.*/
|
17
|
+
const stripNameRegex = /\..*/
|
18
|
+
const stripUidRegex = /::\d+$/
|
19
|
+
const eventRegistry = {} // Events storage
|
20
|
+
let uidEvent = 1
|
21
|
+
const customEvents = {
|
22
|
+
mouseenter: 'mouseover',
|
23
|
+
mouseleave: 'mouseout'
|
24
|
+
}
|
25
|
+
const nativeEvents = new Set([
|
26
|
+
'click',
|
27
|
+
'dblclick',
|
28
|
+
'mouseup',
|
29
|
+
'mousedown',
|
30
|
+
'contextmenu',
|
31
|
+
'mousewheel',
|
32
|
+
'DOMMouseScroll',
|
33
|
+
'mouseover',
|
34
|
+
'mouseout',
|
35
|
+
'mousemove',
|
36
|
+
'selectstart',
|
37
|
+
'selectend',
|
38
|
+
'keydown',
|
39
|
+
'keypress',
|
40
|
+
'keyup',
|
41
|
+
'orientationchange',
|
42
|
+
'touchstart',
|
43
|
+
'touchmove',
|
44
|
+
'touchend',
|
45
|
+
'touchcancel',
|
46
|
+
'pointerdown',
|
47
|
+
'pointermove',
|
48
|
+
'pointerup',
|
49
|
+
'pointerleave',
|
50
|
+
'pointercancel',
|
51
|
+
'gesturestart',
|
52
|
+
'gesturechange',
|
53
|
+
'gestureend',
|
54
|
+
'focus',
|
55
|
+
'blur',
|
56
|
+
'change',
|
57
|
+
'reset',
|
58
|
+
'select',
|
59
|
+
'submit',
|
60
|
+
'focusin',
|
61
|
+
'focusout',
|
62
|
+
'load',
|
63
|
+
'unload',
|
64
|
+
'beforeunload',
|
65
|
+
'resize',
|
66
|
+
'move',
|
67
|
+
'DOMContentLoaded',
|
68
|
+
'readystatechange',
|
69
|
+
'error',
|
70
|
+
'abort',
|
71
|
+
'scroll'
|
72
|
+
])
|
73
|
+
|
74
|
+
/**
|
75
|
+
* ------------------------------------------------------------------------
|
76
|
+
* Private methods
|
77
|
+
* ------------------------------------------------------------------------
|
78
|
+
*/
|
79
|
+
|
80
|
+
function getUidEvent(element, uid) {
|
81
|
+
return (uid && `${uid}::${uidEvent++}`) || element.uidEvent || uidEvent++
|
82
|
+
}
|
83
|
+
|
84
|
+
function getEvent(element) {
|
85
|
+
const uid = getUidEvent(element)
|
86
|
+
|
87
|
+
element.uidEvent = uid
|
88
|
+
eventRegistry[uid] = eventRegistry[uid] || {}
|
89
|
+
|
90
|
+
return eventRegistry[uid]
|
91
|
+
}
|
92
|
+
|
93
|
+
function bootstrapHandler(element, fn) {
|
94
|
+
return function handler(event) {
|
95
|
+
event.delegateTarget = element
|
96
|
+
|
97
|
+
if (handler.oneOff) {
|
98
|
+
EventHandler.off(element, event.type, fn)
|
99
|
+
}
|
100
|
+
|
101
|
+
return fn.apply(element, [event])
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
function bootstrapDelegationHandler(element, selector, fn) {
|
106
|
+
return function handler(event) {
|
107
|
+
const domElements = element.querySelectorAll(selector)
|
108
|
+
|
109
|
+
for (let { target } = event; target && target !== this; target = target.parentNode) {
|
110
|
+
for (let i = domElements.length; i--;) {
|
111
|
+
if (domElements[i] === target) {
|
112
|
+
event.delegateTarget = target
|
113
|
+
|
114
|
+
if (handler.oneOff) {
|
115
|
+
// eslint-disable-next-line unicorn/consistent-destructuring
|
116
|
+
EventHandler.off(element, event.type, fn)
|
117
|
+
}
|
118
|
+
|
119
|
+
return fn.apply(target, [event])
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
// To please ESLint
|
125
|
+
return null
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
function findHandler(events, handler, delegationSelector = null) {
|
130
|
+
const uidEventList = Object.keys(events)
|
131
|
+
|
132
|
+
for (let i = 0, len = uidEventList.length; i < len; i++) {
|
133
|
+
const event = events[uidEventList[i]]
|
134
|
+
|
135
|
+
if (event.originalHandler === handler && event.delegationSelector === delegationSelector) {
|
136
|
+
return event
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
return null
|
141
|
+
}
|
142
|
+
|
143
|
+
function normalizeParams(originalTypeEvent, handler, delegationFn) {
|
144
|
+
const delegation = typeof handler === 'string'
|
145
|
+
const originalHandler = delegation ? delegationFn : handler
|
146
|
+
|
147
|
+
// allow to get the native events from namespaced events ('click.bs.button' --> 'click')
|
148
|
+
let typeEvent = originalTypeEvent.replace(stripNameRegex, '')
|
149
|
+
const custom = customEvents[typeEvent]
|
150
|
+
|
151
|
+
if (custom) {
|
152
|
+
typeEvent = custom
|
153
|
+
}
|
154
|
+
|
155
|
+
const isNative = nativeEvents.has(typeEvent)
|
156
|
+
|
157
|
+
if (!isNative) {
|
158
|
+
typeEvent = originalTypeEvent
|
159
|
+
}
|
160
|
+
|
161
|
+
return [delegation, originalHandler, typeEvent]
|
162
|
+
}
|
163
|
+
|
164
|
+
function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) {
|
165
|
+
if (typeof originalTypeEvent !== 'string' || !element) {
|
166
|
+
return
|
167
|
+
}
|
168
|
+
|
169
|
+
if (!handler) {
|
170
|
+
handler = delegationFn
|
171
|
+
delegationFn = null
|
172
|
+
}
|
173
|
+
|
174
|
+
const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn)
|
175
|
+
const events = getEvent(element)
|
176
|
+
const handlers = events[typeEvent] || (events[typeEvent] = {})
|
177
|
+
const previousFn = findHandler(handlers, originalHandler, delegation ? handler : null)
|
178
|
+
|
179
|
+
if (previousFn) {
|
180
|
+
previousFn.oneOff = previousFn.oneOff && oneOff
|
181
|
+
|
182
|
+
return
|
183
|
+
}
|
184
|
+
|
185
|
+
const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, ''))
|
186
|
+
const fn = delegation ?
|
187
|
+
bootstrapDelegationHandler(element, handler, delegationFn) :
|
188
|
+
bootstrapHandler(element, handler)
|
189
|
+
|
190
|
+
fn.delegationSelector = delegation ? handler : null
|
191
|
+
fn.originalHandler = originalHandler
|
192
|
+
fn.oneOff = oneOff
|
193
|
+
fn.uidEvent = uid
|
194
|
+
handlers[uid] = fn
|
195
|
+
|
196
|
+
element.addEventListener(typeEvent, fn, delegation)
|
197
|
+
}
|
198
|
+
|
199
|
+
function removeHandler(element, events, typeEvent, handler, delegationSelector) {
|
200
|
+
const fn = findHandler(events[typeEvent], handler, delegationSelector)
|
201
|
+
|
202
|
+
if (!fn) {
|
203
|
+
return
|
204
|
+
}
|
205
|
+
|
206
|
+
element.removeEventListener(typeEvent, fn, Boolean(delegationSelector))
|
207
|
+
delete events[typeEvent][fn.uidEvent]
|
208
|
+
}
|
209
|
+
|
210
|
+
function removeNamespacedHandlers(element, events, typeEvent, namespace) {
|
211
|
+
const storeElementEvent = events[typeEvent] || {}
|
212
|
+
|
213
|
+
Object.keys(storeElementEvent).forEach(handlerKey => {
|
214
|
+
if (handlerKey.includes(namespace)) {
|
215
|
+
const event = storeElementEvent[handlerKey]
|
216
|
+
|
217
|
+
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
|
218
|
+
}
|
219
|
+
})
|
220
|
+
}
|
221
|
+
|
222
|
+
const EventHandler = {
|
223
|
+
on(element, event, handler, delegationFn) {
|
224
|
+
addHandler(element, event, handler, delegationFn, false)
|
225
|
+
},
|
226
|
+
|
227
|
+
one(element, event, handler, delegationFn) {
|
228
|
+
addHandler(element, event, handler, delegationFn, true)
|
229
|
+
},
|
230
|
+
|
231
|
+
off(element, originalTypeEvent, handler, delegationFn) {
|
232
|
+
if (typeof originalTypeEvent !== 'string' || !element) {
|
233
|
+
return
|
234
|
+
}
|
235
|
+
|
236
|
+
const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn)
|
237
|
+
const inNamespace = typeEvent !== originalTypeEvent
|
238
|
+
const events = getEvent(element)
|
239
|
+
const isNamespace = originalTypeEvent.startsWith('.')
|
240
|
+
|
241
|
+
if (typeof originalHandler !== 'undefined') {
|
242
|
+
// Simplest case: handler is passed, remove that listener ONLY.
|
243
|
+
if (!events || !events[typeEvent]) {
|
244
|
+
return
|
245
|
+
}
|
246
|
+
|
247
|
+
removeHandler(element, events, typeEvent, originalHandler, delegation ? handler : null)
|
248
|
+
return
|
249
|
+
}
|
250
|
+
|
251
|
+
if (isNamespace) {
|
252
|
+
Object.keys(events).forEach(elementEvent => {
|
253
|
+
removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1))
|
254
|
+
})
|
255
|
+
}
|
256
|
+
|
257
|
+
const storeElementEvent = events[typeEvent] || {}
|
258
|
+
Object.keys(storeElementEvent).forEach(keyHandlers => {
|
259
|
+
const handlerKey = keyHandlers.replace(stripUidRegex, '')
|
260
|
+
|
261
|
+
if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
|
262
|
+
const event = storeElementEvent[keyHandlers]
|
263
|
+
|
264
|
+
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
|
265
|
+
}
|
266
|
+
})
|
267
|
+
},
|
268
|
+
|
269
|
+
trigger(element, event, args) {
|
270
|
+
if (typeof event !== 'string' || !element) {
|
271
|
+
return null
|
272
|
+
}
|
273
|
+
|
274
|
+
const $ = getjQuery()
|
275
|
+
const typeEvent = event.replace(stripNameRegex, '')
|
276
|
+
const inNamespace = event !== typeEvent
|
277
|
+
const isNative = nativeEvents.has(typeEvent)
|
278
|
+
|
279
|
+
let jQueryEvent
|
280
|
+
let bubbles = true
|
281
|
+
let nativeDispatch = true
|
282
|
+
let defaultPrevented = false
|
283
|
+
let evt = null
|
284
|
+
|
285
|
+
if (inNamespace && $) {
|
286
|
+
jQueryEvent = $.Event(event, args)
|
287
|
+
|
288
|
+
$(element).trigger(jQueryEvent)
|
289
|
+
bubbles = !jQueryEvent.isPropagationStopped()
|
290
|
+
nativeDispatch = !jQueryEvent.isImmediatePropagationStopped()
|
291
|
+
defaultPrevented = jQueryEvent.isDefaultPrevented()
|
292
|
+
}
|
293
|
+
|
294
|
+
if (isNative) {
|
295
|
+
evt = document.createEvent('HTMLEvents')
|
296
|
+
evt.initEvent(typeEvent, bubbles, true)
|
297
|
+
} else {
|
298
|
+
evt = new CustomEvent(event, {
|
299
|
+
bubbles,
|
300
|
+
cancelable: true
|
301
|
+
})
|
302
|
+
}
|
303
|
+
|
304
|
+
// merge custom information in our event
|
305
|
+
if (typeof args !== 'undefined') {
|
306
|
+
Object.keys(args).forEach(key => {
|
307
|
+
Object.defineProperty(evt, key, {
|
308
|
+
get() {
|
309
|
+
return args[key]
|
310
|
+
}
|
311
|
+
})
|
312
|
+
})
|
313
|
+
}
|
314
|
+
|
315
|
+
if (defaultPrevented) {
|
316
|
+
evt.preventDefault()
|
317
|
+
}
|
318
|
+
|
319
|
+
if (nativeDispatch) {
|
320
|
+
element.dispatchEvent(evt)
|
321
|
+
}
|
322
|
+
|
323
|
+
if (evt.defaultPrevented && typeof jQueryEvent !== 'undefined') {
|
324
|
+
jQueryEvent.preventDefault()
|
325
|
+
}
|
326
|
+
|
327
|
+
return evt
|
328
|
+
}
|
329
|
+
}
|
330
|
+
|
331
|
+
export default EventHandler
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/**
|
2
|
+
* --------------------------------------------------------------------------
|
3
|
+
* Bootstrap (v5.0.0-beta3): dom/manipulator.js
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
|
+
* --------------------------------------------------------------------------
|
6
|
+
*/
|
7
|
+
|
8
|
+
function normalizeData(val) {
|
9
|
+
if (val === 'true') {
|
10
|
+
return true
|
11
|
+
}
|
12
|
+
|
13
|
+
if (val === 'false') {
|
14
|
+
return false
|
15
|
+
}
|
16
|
+
|
17
|
+
if (val === Number(val).toString()) {
|
18
|
+
return Number(val)
|
19
|
+
}
|
20
|
+
|
21
|
+
if (val === '' || val === 'null') {
|
22
|
+
return null
|
23
|
+
}
|
24
|
+
|
25
|
+
return val
|
26
|
+
}
|
27
|
+
|
28
|
+
function normalizeDataKey(key) {
|
29
|
+
return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`)
|
30
|
+
}
|
31
|
+
|
32
|
+
const Manipulator = {
|
33
|
+
setDataAttribute(element, key, value) {
|
34
|
+
element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value)
|
35
|
+
},
|
36
|
+
|
37
|
+
removeDataAttribute(element, key) {
|
38
|
+
element.removeAttribute(`data-bs-${normalizeDataKey(key)}`)
|
39
|
+
},
|
40
|
+
|
41
|
+
getDataAttributes(element) {
|
42
|
+
if (!element) {
|
43
|
+
return {}
|
44
|
+
}
|
45
|
+
|
46
|
+
const attributes = {}
|
47
|
+
|
48
|
+
Object.keys(element.dataset)
|
49
|
+
.filter(key => key.startsWith('bs'))
|
50
|
+
.forEach(key => {
|
51
|
+
let pureKey = key.replace(/^bs/, '')
|
52
|
+
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length)
|
53
|
+
attributes[pureKey] = normalizeData(element.dataset[key])
|
54
|
+
})
|
55
|
+
|
56
|
+
return attributes
|
57
|
+
},
|
58
|
+
|
59
|
+
getDataAttribute(element, key) {
|
60
|
+
return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`))
|
61
|
+
},
|
62
|
+
|
63
|
+
offset(element) {
|
64
|
+
const rect = element.getBoundingClientRect()
|
65
|
+
|
66
|
+
return {
|
67
|
+
top: rect.top + document.body.scrollTop,
|
68
|
+
left: rect.left + document.body.scrollLeft
|
69
|
+
}
|
70
|
+
},
|
71
|
+
|
72
|
+
position(element) {
|
73
|
+
return {
|
74
|
+
top: element.offsetTop,
|
75
|
+
left: element.offsetLeft
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
export default Manipulator
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/**
|
2
|
+
* --------------------------------------------------------------------------
|
3
|
+
* Bootstrap (v5.0.0-beta3): dom/selector-engine.js
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
|
+
* --------------------------------------------------------------------------
|
6
|
+
*/
|
7
|
+
|
8
|
+
/**
|
9
|
+
* ------------------------------------------------------------------------
|
10
|
+
* Constants
|
11
|
+
* ------------------------------------------------------------------------
|
12
|
+
*/
|
13
|
+
|
14
|
+
const NODE_TEXT = 3
|
15
|
+
|
16
|
+
const SelectorEngine = {
|
17
|
+
find(selector, element = document.documentElement) {
|
18
|
+
return [].concat(...Element.prototype.querySelectorAll.call(element, selector))
|
19
|
+
},
|
20
|
+
|
21
|
+
findOne(selector, element = document.documentElement) {
|
22
|
+
return Element.prototype.querySelector.call(element, selector)
|
23
|
+
},
|
24
|
+
|
25
|
+
children(element, selector) {
|
26
|
+
return [].concat(...element.children)
|
27
|
+
.filter(child => child.matches(selector))
|
28
|
+
},
|
29
|
+
|
30
|
+
parents(element, selector) {
|
31
|
+
const parents = []
|
32
|
+
|
33
|
+
let ancestor = element.parentNode
|
34
|
+
|
35
|
+
while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
|
36
|
+
if (ancestor.matches(selector)) {
|
37
|
+
parents.push(ancestor)
|
38
|
+
}
|
39
|
+
|
40
|
+
ancestor = ancestor.parentNode
|
41
|
+
}
|
42
|
+
|
43
|
+
return parents
|
44
|
+
},
|
45
|
+
|
46
|
+
prev(element, selector) {
|
47
|
+
let previous = element.previousElementSibling
|
48
|
+
|
49
|
+
while (previous) {
|
50
|
+
if (previous.matches(selector)) {
|
51
|
+
return [previous]
|
52
|
+
}
|
53
|
+
|
54
|
+
previous = previous.previousElementSibling
|
55
|
+
}
|
56
|
+
|
57
|
+
return []
|
58
|
+
},
|
59
|
+
|
60
|
+
next(element, selector) {
|
61
|
+
let next = element.nextElementSibling
|
62
|
+
|
63
|
+
while (next) {
|
64
|
+
if (next.matches(selector)) {
|
65
|
+
return [next]
|
66
|
+
}
|
67
|
+
|
68
|
+
next = next.nextElementSibling
|
69
|
+
}
|
70
|
+
|
71
|
+
return []
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
export default SelectorEngine
|