administrate-bootstrap-theme 0.1.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +72 -31
- data/app/assets/javascripts/administrate-bootstrap-theme/bootstrap.bundle.js +6780 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/_base.scss +2 -10
- data/app/assets/stylesheets/administrate-bootstrap-theme/_variables.scss +8 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_accordion.scss +4 -2
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_alert.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_badge.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_breadcrumb.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_button-group.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_buttons.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_card.scss +7 -6
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_carousel.scss +2 -2
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_close.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_containers.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_dropdown.scss +11 -17
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_forms.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_functions.scss +94 -3
- data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/_grid.scss +33 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_helpers.scss +2 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_images.scss +1 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_list-group.scss +5 -5
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_mixins.scss +2 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_modal.scss +7 -35
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_nav.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_navbar.scss +30 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_offcanvas.scss +19 -13
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_pagination.scss +0 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/_placeholders.scss +51 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_popover.scss +10 -10
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_progress.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_reboot.scss +12 -8
- data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/_root.scss +53 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_spinners.scss +2 -2
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_tables.scss +1 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_toasts.scss +3 -3
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_tooltip.scss +4 -4
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_transitions.scss +6 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_type.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_utilities.scss +44 -8
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_variables.scss +193 -28
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-grid.scss +1 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-reboot.scss +1 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-utilities.scss +1 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap.scss +2 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_floating-labels.scss +3 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-check.scss +1 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-control.scss +1 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-range.scss +1 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-select.scss +3 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-text.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_input-group.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_labels.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_validation.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_clearfix.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_colored-links.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_position.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_ratio.scss +0 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/helpers/_stacks.scss +15 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_stretched-link.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_text-truncation.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_visually-hidden.scss +0 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/helpers/_vr.scss +8 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_alert.scss +0 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/mixins/_backdrop.scss +14 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_border-radius.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_box-shadow.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_breakpoints.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_buttons.scss +1 -1
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_caret.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_clearfix.scss +0 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/bootstrap/mixins/_color-scheme.scss +7 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_container.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_deprecate.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_forms.scss +15 -5
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_gradients.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_grid.scss +40 -10
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_image.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_list-group.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_lists.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_pagination.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_reset-text.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_resize.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_table-variants.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_text-truncate.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_transition.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_utilities.scss +27 -6
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_visually-hidden.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/utilities/_api.scss +0 -0
- data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/vendor/_rfs.scss +55 -13
- data/app/assets/stylesheets/administrate-bootstrap-theme/colors/_autumn.scss +8 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/colors/_default.scss +8 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/colors/_forest.scss +9 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/colors/_industrial.scss +8 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/colors/_water.scss +8 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/components/_content_body.scss +21 -1
- data/app/assets/stylesheets/administrate-bootstrap-theme/components/_content_header.scss +1 -1
- data/app/assets/stylesheets/administrate-bootstrap-theme/components/_form.scss +2 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/components/_navigation.scss +22 -3
- data/app/assets/stylesheets/administrate-bootstrap-theme/components/_pagination.scss +1 -1
- data/app/assets/stylesheets/administrate-bootstrap-theme/fonts/_lato.scss +5 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/fonts/_montserrat.scss +5 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/fonts/_open_sans.scss +5 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/fonts/_roboto.scss +5 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/fonts/_source_sans_pro.scss +5 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/theme.scss +10 -51
- data/lib/administrate-bootstrap-theme/engine.rb +0 -2
- data/lib/administrate-bootstrap-theme/version.rb +2 -1
- data/lib/generators/administrate_bootstrap_theme/install/USAGE +10 -0
- data/lib/generators/administrate_bootstrap_theme/install/install_generator.rb +33 -0
- data/package.json +10 -0
- metadata +113 -199
- data/Rakefile +0 -16
- data/app/assets/javascripts/administrate-bootstrap-theme/theme.js +0 -2
- data/node_modules/bootstrap/js/src/alert.js +0 -141
- data/node_modules/bootstrap/js/src/base-component.js +0 -46
- data/node_modules/bootstrap/js/src/button.js +0 -95
- data/node_modules/bootstrap/js/src/carousel.js +0 -624
- data/node_modules/bootstrap/js/src/collapse.js +0 -410
- data/node_modules/bootstrap/js/src/dom/data.js +0 -57
- data/node_modules/bootstrap/js/src/dom/event-handler.js +0 -331
- data/node_modules/bootstrap/js/src/dom/manipulator.js +0 -80
- data/node_modules/bootstrap/js/src/dom/selector-engine.js +0 -75
- data/node_modules/bootstrap/js/src/dropdown.js +0 -543
- data/node_modules/bootstrap/js/src/modal.js +0 -582
- data/node_modules/bootstrap/js/src/offcanvas.js +0 -279
- data/node_modules/bootstrap/js/src/popover.js +0 -171
- data/node_modules/bootstrap/js/src/scrollspy.js +0 -319
- data/node_modules/bootstrap/js/src/tab.js +0 -220
- data/node_modules/bootstrap/js/src/toast.js +0 -219
- data/node_modules/bootstrap/js/src/tooltip.js +0 -802
- data/node_modules/bootstrap/js/src/util/index.js +0 -253
- data/node_modules/bootstrap/js/src/util/sanitizer.js +0 -127
- data/node_modules/bootstrap/js/src/util/scrollbar.js +0 -70
- data/node_modules/bootstrap/scss/_grid.scss +0 -22
- data/node_modules/bootstrap/scss/_root.scss +0 -16
@@ -1,543 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* --------------------------------------------------------------------------
|
3
|
-
* Bootstrap (v5.0.0-beta3): dropdown.js
|
4
|
-
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
|
-
* --------------------------------------------------------------------------
|
6
|
-
*/
|
7
|
-
|
8
|
-
import * as Popper from '@popperjs/core'
|
9
|
-
|
10
|
-
import {
|
11
|
-
defineJQueryPlugin,
|
12
|
-
getElementFromSelector,
|
13
|
-
isElement,
|
14
|
-
isVisible,
|
15
|
-
isRTL,
|
16
|
-
noop,
|
17
|
-
typeCheckConfig
|
18
|
-
} from './util/index'
|
19
|
-
import Data from './dom/data'
|
20
|
-
import EventHandler from './dom/event-handler'
|
21
|
-
import Manipulator from './dom/manipulator'
|
22
|
-
import SelectorEngine from './dom/selector-engine'
|
23
|
-
import BaseComponent from './base-component'
|
24
|
-
|
25
|
-
/**
|
26
|
-
* ------------------------------------------------------------------------
|
27
|
-
* Constants
|
28
|
-
* ------------------------------------------------------------------------
|
29
|
-
*/
|
30
|
-
|
31
|
-
const NAME = 'dropdown'
|
32
|
-
const DATA_KEY = 'bs.dropdown'
|
33
|
-
const EVENT_KEY = `.${DATA_KEY}`
|
34
|
-
const DATA_API_KEY = '.data-api'
|
35
|
-
|
36
|
-
const ESCAPE_KEY = 'Escape'
|
37
|
-
const SPACE_KEY = 'Space'
|
38
|
-
const TAB_KEY = 'Tab'
|
39
|
-
const ARROW_UP_KEY = 'ArrowUp'
|
40
|
-
const ARROW_DOWN_KEY = 'ArrowDown'
|
41
|
-
const RIGHT_MOUSE_BUTTON = 2 // MouseEvent.button value for the secondary button, usually the right button
|
42
|
-
|
43
|
-
const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEY}|${ARROW_DOWN_KEY}|${ESCAPE_KEY}`)
|
44
|
-
|
45
|
-
const EVENT_HIDE = `hide${EVENT_KEY}`
|
46
|
-
const EVENT_HIDDEN = `hidden${EVENT_KEY}`
|
47
|
-
const EVENT_SHOW = `show${EVENT_KEY}`
|
48
|
-
const EVENT_SHOWN = `shown${EVENT_KEY}`
|
49
|
-
const EVENT_CLICK = `click${EVENT_KEY}`
|
50
|
-
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
|
51
|
-
const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY}${DATA_API_KEY}`
|
52
|
-
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`
|
53
|
-
|
54
|
-
const CLASS_NAME_DISABLED = 'disabled'
|
55
|
-
const CLASS_NAME_SHOW = 'show'
|
56
|
-
const CLASS_NAME_DROPUP = 'dropup'
|
57
|
-
const CLASS_NAME_DROPEND = 'dropend'
|
58
|
-
const CLASS_NAME_DROPSTART = 'dropstart'
|
59
|
-
const CLASS_NAME_NAVBAR = 'navbar'
|
60
|
-
|
61
|
-
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]'
|
62
|
-
const SELECTOR_MENU = '.dropdown-menu'
|
63
|
-
const SELECTOR_NAVBAR_NAV = '.navbar-nav'
|
64
|
-
const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
|
65
|
-
|
66
|
-
const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start'
|
67
|
-
const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end'
|
68
|
-
const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start'
|
69
|
-
const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end'
|
70
|
-
const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start'
|
71
|
-
const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start'
|
72
|
-
|
73
|
-
const Default = {
|
74
|
-
offset: [0, 2],
|
75
|
-
boundary: 'clippingParents',
|
76
|
-
reference: 'toggle',
|
77
|
-
display: 'dynamic',
|
78
|
-
popperConfig: null
|
79
|
-
}
|
80
|
-
|
81
|
-
const DefaultType = {
|
82
|
-
offset: '(array|string|function)',
|
83
|
-
boundary: '(string|element)',
|
84
|
-
reference: '(string|element|object)',
|
85
|
-
display: 'string',
|
86
|
-
popperConfig: '(null|object|function)'
|
87
|
-
}
|
88
|
-
|
89
|
-
/**
|
90
|
-
* ------------------------------------------------------------------------
|
91
|
-
* Class Definition
|
92
|
-
* ------------------------------------------------------------------------
|
93
|
-
*/
|
94
|
-
|
95
|
-
class Dropdown extends BaseComponent {
|
96
|
-
constructor(element, config) {
|
97
|
-
super(element)
|
98
|
-
|
99
|
-
this._popper = null
|
100
|
-
this._config = this._getConfig(config)
|
101
|
-
this._menu = this._getMenuElement()
|
102
|
-
this._inNavbar = this._detectNavbar()
|
103
|
-
|
104
|
-
this._addEventListeners()
|
105
|
-
}
|
106
|
-
|
107
|
-
// Getters
|
108
|
-
|
109
|
-
static get Default() {
|
110
|
-
return Default
|
111
|
-
}
|
112
|
-
|
113
|
-
static get DefaultType() {
|
114
|
-
return DefaultType
|
115
|
-
}
|
116
|
-
|
117
|
-
static get DATA_KEY() {
|
118
|
-
return DATA_KEY
|
119
|
-
}
|
120
|
-
|
121
|
-
// Public
|
122
|
-
|
123
|
-
toggle() {
|
124
|
-
if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED)) {
|
125
|
-
return
|
126
|
-
}
|
127
|
-
|
128
|
-
const isActive = this._element.classList.contains(CLASS_NAME_SHOW)
|
129
|
-
|
130
|
-
Dropdown.clearMenus()
|
131
|
-
|
132
|
-
if (isActive) {
|
133
|
-
return
|
134
|
-
}
|
135
|
-
|
136
|
-
this.show()
|
137
|
-
}
|
138
|
-
|
139
|
-
show() {
|
140
|
-
if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || this._menu.classList.contains(CLASS_NAME_SHOW)) {
|
141
|
-
return
|
142
|
-
}
|
143
|
-
|
144
|
-
const parent = Dropdown.getParentFromElement(this._element)
|
145
|
-
const relatedTarget = {
|
146
|
-
relatedTarget: this._element
|
147
|
-
}
|
148
|
-
|
149
|
-
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, relatedTarget)
|
150
|
-
|
151
|
-
if (showEvent.defaultPrevented) {
|
152
|
-
return
|
153
|
-
}
|
154
|
-
|
155
|
-
// Totally disable Popper for Dropdowns in Navbar
|
156
|
-
if (this._inNavbar) {
|
157
|
-
Manipulator.setDataAttribute(this._menu, 'popper', 'none')
|
158
|
-
} else {
|
159
|
-
if (typeof Popper === 'undefined') {
|
160
|
-
throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)')
|
161
|
-
}
|
162
|
-
|
163
|
-
let referenceElement = this._element
|
164
|
-
|
165
|
-
if (this._config.reference === 'parent') {
|
166
|
-
referenceElement = parent
|
167
|
-
} else if (isElement(this._config.reference)) {
|
168
|
-
referenceElement = this._config.reference
|
169
|
-
|
170
|
-
// Check if it's jQuery element
|
171
|
-
if (typeof this._config.reference.jquery !== 'undefined') {
|
172
|
-
referenceElement = this._config.reference[0]
|
173
|
-
}
|
174
|
-
} else if (typeof this._config.reference === 'object') {
|
175
|
-
referenceElement = this._config.reference
|
176
|
-
}
|
177
|
-
|
178
|
-
const popperConfig = this._getPopperConfig()
|
179
|
-
const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false)
|
180
|
-
|
181
|
-
this._popper = Popper.createPopper(referenceElement, this._menu, popperConfig)
|
182
|
-
|
183
|
-
if (isDisplayStatic) {
|
184
|
-
Manipulator.setDataAttribute(this._menu, 'popper', 'static')
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
|
-
// If this is a touch-enabled device we add extra
|
189
|
-
// empty mouseover listeners to the body's immediate children;
|
190
|
-
// only needed because of broken event delegation on iOS
|
191
|
-
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
192
|
-
if ('ontouchstart' in document.documentElement &&
|
193
|
-
!parent.closest(SELECTOR_NAVBAR_NAV)) {
|
194
|
-
[].concat(...document.body.children)
|
195
|
-
.forEach(elem => EventHandler.on(elem, 'mouseover', null, noop()))
|
196
|
-
}
|
197
|
-
|
198
|
-
this._element.focus()
|
199
|
-
this._element.setAttribute('aria-expanded', true)
|
200
|
-
|
201
|
-
this._menu.classList.toggle(CLASS_NAME_SHOW)
|
202
|
-
this._element.classList.toggle(CLASS_NAME_SHOW)
|
203
|
-
EventHandler.trigger(this._element, EVENT_SHOWN, relatedTarget)
|
204
|
-
}
|
205
|
-
|
206
|
-
hide() {
|
207
|
-
if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || !this._menu.classList.contains(CLASS_NAME_SHOW)) {
|
208
|
-
return
|
209
|
-
}
|
210
|
-
|
211
|
-
const relatedTarget = {
|
212
|
-
relatedTarget: this._element
|
213
|
-
}
|
214
|
-
|
215
|
-
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE, relatedTarget)
|
216
|
-
|
217
|
-
if (hideEvent.defaultPrevented) {
|
218
|
-
return
|
219
|
-
}
|
220
|
-
|
221
|
-
if (this._popper) {
|
222
|
-
this._popper.destroy()
|
223
|
-
}
|
224
|
-
|
225
|
-
this._menu.classList.toggle(CLASS_NAME_SHOW)
|
226
|
-
this._element.classList.toggle(CLASS_NAME_SHOW)
|
227
|
-
Manipulator.removeDataAttribute(this._menu, 'popper')
|
228
|
-
EventHandler.trigger(this._element, EVENT_HIDDEN, relatedTarget)
|
229
|
-
}
|
230
|
-
|
231
|
-
dispose() {
|
232
|
-
EventHandler.off(this._element, EVENT_KEY)
|
233
|
-
this._menu = null
|
234
|
-
|
235
|
-
if (this._popper) {
|
236
|
-
this._popper.destroy()
|
237
|
-
this._popper = null
|
238
|
-
}
|
239
|
-
|
240
|
-
super.dispose()
|
241
|
-
}
|
242
|
-
|
243
|
-
update() {
|
244
|
-
this._inNavbar = this._detectNavbar()
|
245
|
-
if (this._popper) {
|
246
|
-
this._popper.update()
|
247
|
-
}
|
248
|
-
}
|
249
|
-
|
250
|
-
// Private
|
251
|
-
|
252
|
-
_addEventListeners() {
|
253
|
-
EventHandler.on(this._element, EVENT_CLICK, event => {
|
254
|
-
event.preventDefault()
|
255
|
-
this.toggle()
|
256
|
-
})
|
257
|
-
}
|
258
|
-
|
259
|
-
_getConfig(config) {
|
260
|
-
config = {
|
261
|
-
...this.constructor.Default,
|
262
|
-
...Manipulator.getDataAttributes(this._element),
|
263
|
-
...config
|
264
|
-
}
|
265
|
-
|
266
|
-
typeCheckConfig(NAME, config, this.constructor.DefaultType)
|
267
|
-
|
268
|
-
if (typeof config.reference === 'object' && !isElement(config.reference) &&
|
269
|
-
typeof config.reference.getBoundingClientRect !== 'function'
|
270
|
-
) {
|
271
|
-
// Popper virtual elements require a getBoundingClientRect method
|
272
|
-
throw new TypeError(`${NAME.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`)
|
273
|
-
}
|
274
|
-
|
275
|
-
return config
|
276
|
-
}
|
277
|
-
|
278
|
-
_getMenuElement() {
|
279
|
-
return SelectorEngine.next(this._element, SELECTOR_MENU)[0]
|
280
|
-
}
|
281
|
-
|
282
|
-
_getPlacement() {
|
283
|
-
const parentDropdown = this._element.parentNode
|
284
|
-
|
285
|
-
if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
|
286
|
-
return PLACEMENT_RIGHT
|
287
|
-
}
|
288
|
-
|
289
|
-
if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
|
290
|
-
return PLACEMENT_LEFT
|
291
|
-
}
|
292
|
-
|
293
|
-
// We need to trim the value because custom properties can also include spaces
|
294
|
-
const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end'
|
295
|
-
|
296
|
-
if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
|
297
|
-
return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP
|
298
|
-
}
|
299
|
-
|
300
|
-
return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM
|
301
|
-
}
|
302
|
-
|
303
|
-
_detectNavbar() {
|
304
|
-
return this._element.closest(`.${CLASS_NAME_NAVBAR}`) !== null
|
305
|
-
}
|
306
|
-
|
307
|
-
_getOffset() {
|
308
|
-
const { offset } = this._config
|
309
|
-
|
310
|
-
if (typeof offset === 'string') {
|
311
|
-
return offset.split(',').map(val => Number.parseInt(val, 10))
|
312
|
-
}
|
313
|
-
|
314
|
-
if (typeof offset === 'function') {
|
315
|
-
return popperData => offset(popperData, this._element)
|
316
|
-
}
|
317
|
-
|
318
|
-
return offset
|
319
|
-
}
|
320
|
-
|
321
|
-
_getPopperConfig() {
|
322
|
-
const defaultBsPopperConfig = {
|
323
|
-
placement: this._getPlacement(),
|
324
|
-
modifiers: [{
|
325
|
-
name: 'preventOverflow',
|
326
|
-
options: {
|
327
|
-
boundary: this._config.boundary
|
328
|
-
}
|
329
|
-
},
|
330
|
-
{
|
331
|
-
name: 'offset',
|
332
|
-
options: {
|
333
|
-
offset: this._getOffset()
|
334
|
-
}
|
335
|
-
}]
|
336
|
-
}
|
337
|
-
|
338
|
-
// Disable Popper if we have a static display
|
339
|
-
if (this._config.display === 'static') {
|
340
|
-
defaultBsPopperConfig.modifiers = [{
|
341
|
-
name: 'applyStyles',
|
342
|
-
enabled: false
|
343
|
-
}]
|
344
|
-
}
|
345
|
-
|
346
|
-
return {
|
347
|
-
...defaultBsPopperConfig,
|
348
|
-
...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
|
349
|
-
}
|
350
|
-
}
|
351
|
-
|
352
|
-
// Static
|
353
|
-
|
354
|
-
static dropdownInterface(element, config) {
|
355
|
-
let data = Data.get(element, DATA_KEY)
|
356
|
-
const _config = typeof config === 'object' ? config : null
|
357
|
-
|
358
|
-
if (!data) {
|
359
|
-
data = new Dropdown(element, _config)
|
360
|
-
}
|
361
|
-
|
362
|
-
if (typeof config === 'string') {
|
363
|
-
if (typeof data[config] === 'undefined') {
|
364
|
-
throw new TypeError(`No method named "${config}"`)
|
365
|
-
}
|
366
|
-
|
367
|
-
data[config]()
|
368
|
-
}
|
369
|
-
}
|
370
|
-
|
371
|
-
static jQueryInterface(config) {
|
372
|
-
return this.each(function () {
|
373
|
-
Dropdown.dropdownInterface(this, config)
|
374
|
-
})
|
375
|
-
}
|
376
|
-
|
377
|
-
static clearMenus(event) {
|
378
|
-
if (event) {
|
379
|
-
if (event.button === RIGHT_MOUSE_BUTTON || (event.type === 'keyup' && event.key !== TAB_KEY)) {
|
380
|
-
return
|
381
|
-
}
|
382
|
-
|
383
|
-
if (/input|select|textarea|form/i.test(event.target.tagName)) {
|
384
|
-
return
|
385
|
-
}
|
386
|
-
}
|
387
|
-
|
388
|
-
const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
|
389
|
-
|
390
|
-
for (let i = 0, len = toggles.length; i < len; i++) {
|
391
|
-
const context = Data.get(toggles[i], DATA_KEY)
|
392
|
-
const relatedTarget = {
|
393
|
-
relatedTarget: toggles[i]
|
394
|
-
}
|
395
|
-
|
396
|
-
if (event && event.type === 'click') {
|
397
|
-
relatedTarget.clickEvent = event
|
398
|
-
}
|
399
|
-
|
400
|
-
if (!context) {
|
401
|
-
continue
|
402
|
-
}
|
403
|
-
|
404
|
-
const dropdownMenu = context._menu
|
405
|
-
if (!toggles[i].classList.contains(CLASS_NAME_SHOW)) {
|
406
|
-
continue
|
407
|
-
}
|
408
|
-
|
409
|
-
if (event) {
|
410
|
-
// Don't close the menu if the clicked element or one of its parents is the dropdown button
|
411
|
-
if ([context._element].some(element => event.composedPath().includes(element))) {
|
412
|
-
continue
|
413
|
-
}
|
414
|
-
|
415
|
-
// Tab navigation through the dropdown menu shouldn't close the menu
|
416
|
-
if (event.type === 'keyup' && event.key === TAB_KEY && dropdownMenu.contains(event.target)) {
|
417
|
-
continue
|
418
|
-
}
|
419
|
-
}
|
420
|
-
|
421
|
-
const hideEvent = EventHandler.trigger(toggles[i], EVENT_HIDE, relatedTarget)
|
422
|
-
if (hideEvent.defaultPrevented) {
|
423
|
-
continue
|
424
|
-
}
|
425
|
-
|
426
|
-
// If this is a touch-enabled device we remove the extra
|
427
|
-
// empty mouseover listeners we added for iOS support
|
428
|
-
if ('ontouchstart' in document.documentElement) {
|
429
|
-
[].concat(...document.body.children)
|
430
|
-
.forEach(elem => EventHandler.off(elem, 'mouseover', null, noop()))
|
431
|
-
}
|
432
|
-
|
433
|
-
toggles[i].setAttribute('aria-expanded', 'false')
|
434
|
-
|
435
|
-
if (context._popper) {
|
436
|
-
context._popper.destroy()
|
437
|
-
}
|
438
|
-
|
439
|
-
dropdownMenu.classList.remove(CLASS_NAME_SHOW)
|
440
|
-
toggles[i].classList.remove(CLASS_NAME_SHOW)
|
441
|
-
Manipulator.removeDataAttribute(dropdownMenu, 'popper')
|
442
|
-
EventHandler.trigger(toggles[i], EVENT_HIDDEN, relatedTarget)
|
443
|
-
}
|
444
|
-
}
|
445
|
-
|
446
|
-
static getParentFromElement(element) {
|
447
|
-
return getElementFromSelector(element) || element.parentNode
|
448
|
-
}
|
449
|
-
|
450
|
-
static dataApiKeydownHandler(event) {
|
451
|
-
// If not input/textarea:
|
452
|
-
// - And not a key in REGEXP_KEYDOWN => not a dropdown command
|
453
|
-
// If input/textarea:
|
454
|
-
// - If space key => not a dropdown command
|
455
|
-
// - If key is other than escape
|
456
|
-
// - If key is not up or down => not a dropdown command
|
457
|
-
// - If trigger inside the menu => not a dropdown command
|
458
|
-
if (/input|textarea/i.test(event.target.tagName) ?
|
459
|
-
event.key === SPACE_KEY || (event.key !== ESCAPE_KEY &&
|
460
|
-
((event.key !== ARROW_DOWN_KEY && event.key !== ARROW_UP_KEY) ||
|
461
|
-
event.target.closest(SELECTOR_MENU))) :
|
462
|
-
!REGEXP_KEYDOWN.test(event.key)) {
|
463
|
-
return
|
464
|
-
}
|
465
|
-
|
466
|
-
event.preventDefault()
|
467
|
-
event.stopPropagation()
|
468
|
-
|
469
|
-
if (this.disabled || this.classList.contains(CLASS_NAME_DISABLED)) {
|
470
|
-
return
|
471
|
-
}
|
472
|
-
|
473
|
-
const parent = Dropdown.getParentFromElement(this)
|
474
|
-
const isActive = this.classList.contains(CLASS_NAME_SHOW)
|
475
|
-
|
476
|
-
if (event.key === ESCAPE_KEY) {
|
477
|
-
const button = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0]
|
478
|
-
button.focus()
|
479
|
-
Dropdown.clearMenus()
|
480
|
-
return
|
481
|
-
}
|
482
|
-
|
483
|
-
if (!isActive && (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY)) {
|
484
|
-
const button = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0]
|
485
|
-
button.click()
|
486
|
-
return
|
487
|
-
}
|
488
|
-
|
489
|
-
if (!isActive || event.key === SPACE_KEY) {
|
490
|
-
Dropdown.clearMenus()
|
491
|
-
return
|
492
|
-
}
|
493
|
-
|
494
|
-
const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent).filter(isVisible)
|
495
|
-
|
496
|
-
if (!items.length) {
|
497
|
-
return
|
498
|
-
}
|
499
|
-
|
500
|
-
let index = items.indexOf(event.target)
|
501
|
-
|
502
|
-
// Up
|
503
|
-
if (event.key === ARROW_UP_KEY && index > 0) {
|
504
|
-
index--
|
505
|
-
}
|
506
|
-
|
507
|
-
// Down
|
508
|
-
if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
|
509
|
-
index++
|
510
|
-
}
|
511
|
-
|
512
|
-
// index is -1 if the first keydown is an ArrowUp
|
513
|
-
index = index === -1 ? 0 : index
|
514
|
-
|
515
|
-
items[index].focus()
|
516
|
-
}
|
517
|
-
}
|
518
|
-
|
519
|
-
/**
|
520
|
-
* ------------------------------------------------------------------------
|
521
|
-
* Data Api implementation
|
522
|
-
* ------------------------------------------------------------------------
|
523
|
-
*/
|
524
|
-
|
525
|
-
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown.dataApiKeydownHandler)
|
526
|
-
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler)
|
527
|
-
EventHandler.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus)
|
528
|
-
EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus)
|
529
|
-
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
530
|
-
event.preventDefault()
|
531
|
-
Dropdown.dropdownInterface(this)
|
532
|
-
})
|
533
|
-
|
534
|
-
/**
|
535
|
-
* ------------------------------------------------------------------------
|
536
|
-
* jQuery
|
537
|
-
* ------------------------------------------------------------------------
|
538
|
-
* add .Dropdown to jQuery only if jQuery is present
|
539
|
-
*/
|
540
|
-
|
541
|
-
defineJQueryPlugin(NAME, Dropdown)
|
542
|
-
|
543
|
-
export default Dropdown
|