Skip to content

Commit d264635

Browse files
author
unknown
committed
1.0.0-beta2
1 parent 1cad4f9 commit d264635

14 files changed

+821
-244
lines changed

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 MDBootstrap
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MDB 5 Vue
22

3-
Version: FREE 1.0.0-beta1
3+
Version: FREE 1.0.0-beta2
44

55
Documentation:
66
https://mdbootstrap.com/docs/b5/vue/

Diff for: js/mdb.common.js

+509-221
Large diffs are not rendered by default.

Diff for: js/mdb.common.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: js/mdb.umd.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: js/mdb.umd.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mdb-vue-ui-kit",
3-
"version": "1.0.0-beta1",
3+
"version": "1.0.0-beta2",
44
"main": "js/mdb.umd.min.js",
55
"repository": "https://github.com/mdbootstrap/mdb-vue-ui-kit.git",
66
"author": "MDBootstrap",

Diff for: src/components/free/components/MDBBtn.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export default {
4848
props.outline || props.color === "light" || props.color === "link"
4949
? { color: "dark" }
5050
: true
51-
}
51+
},
52+
picker: Boolean
5253
},
5354
directives: { mdbRipple },
5455
inheritAttrs: false,
@@ -58,7 +59,7 @@ export default {
5859
5960
const className = computed(() => {
6061
return [
61-
"btn",
62+
!props.picker && "btn",
6263
props.color && `btn-${props.color}`,
6364
props.size && `btn-${props.size}`,
6465
props.outline && `btn-outline-${props.outline}`,

Diff for: src/components/free/components/MDBDropdownToggle.vue

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
:is="tag"
44
type="button"
55
:class="className"
6-
data-mdb-toggle="dropdown"
76
:aria-expanded="expanded"
87
aria-haspopup="true"
98
v-bind="attrs"

Diff for: src/components/free/forms/MDBInput.vue

+15-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
<div v-if="!wrap && customInvalidFeedback" :class="invalidFeedbackClassName">
2424
{{ customInvalidFeedback }}
2525
</div>
26+
<div v-if="!wrap && formOutline" class="form-notch">
27+
<div
28+
class="form-notch-leading"
29+
:style="{ width: `${notchLeadingWidth}px` }"
30+
></div>
31+
<div
32+
class="form-notch-middle"
33+
:style="{ width: `${notchMiddleWidth}px` }"
34+
></div>
35+
<div class="form-notch-trailing"></div>
36+
</div>
2637
<component
2738
v-if="wrap"
2839
:is="tag"
@@ -82,7 +93,7 @@ export default {
8293
id: String,
8394
label: String,
8495
labelClass: String,
85-
modelValue: [String, Number],
96+
modelValue: [String, Number, Date],
8697
size: String,
8798
formOutline: {
8899
type: Boolean,
@@ -233,7 +244,9 @@ export default {
233244
off(inputRef.value, props.validationEvent, handleValidation);
234245
});
235246
236-
watchEffect(() => (inputValue.value = props.modelValue));
247+
watchEffect(() => {
248+
inputValue.value = props.modelValue;
249+
});
237250
238251
watch(
239252
() => props.isValidated,

Diff for: src/components/free/navigation/MDBNavbarToggler.vue

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
:is="tag"
44
:class="navTogglerClass"
55
type="button"
6-
data-mdb-toggle="collapse"
7-
:data-mdb-target="target"
86
:aria-controls="target"
97
:aria-expanded="isExpanded"
108
aria-label="Toggle navigation"

Diff for: src/components/utils/MDBEventHandlers.js

+130-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,135 @@
1-
export const on = function(element, event, handler) {
2-
if (element && event && handler) {
3-
document.addEventListener
4-
? element.addEventListener(event, handler, false)
5-
: element.attachEvent("on" + event, handler);
1+
const stripNameRegex = /\..*/;
2+
const customEvents = {
3+
mouseenter: "mouseover",
4+
mouseleave: "mouseout"
5+
};
6+
const nativeEvents = [
7+
"click",
8+
"dblclick",
9+
"mouseup",
10+
"mousedown",
11+
"contextmenu",
12+
"mousewheel",
13+
"DOMMouseScroll",
14+
"mouseover",
15+
"mouseout",
16+
"mousemove",
17+
"selectstart",
18+
"selectend",
19+
"keydown",
20+
"keypress",
21+
"keyup",
22+
"orientationchange",
23+
"touchstart",
24+
"touchmove",
25+
"touchend",
26+
"touchcancel",
27+
"pointerdown",
28+
"pointermove",
29+
"pointerup",
30+
"pointerleave",
31+
"pointercancel",
32+
"gesturestart",
33+
"gesturechange",
34+
"gestureend",
35+
"focus",
36+
"blur",
37+
"change",
38+
"reset",
39+
"select",
40+
"submit",
41+
"focusin",
42+
"focusout",
43+
"load",
44+
"unload",
45+
"beforeunload",
46+
"resize",
47+
"move",
48+
"DOMContentLoaded",
49+
"readystatechange",
50+
"error",
51+
"abort",
52+
"scroll"
53+
];
54+
55+
function normalizeParams(originalTypeEvent, handler, delegationFn) {
56+
const delegation = typeof handler === "string";
57+
const originalHandler = delegation ? delegationFn : handler;
58+
59+
// allow to get the native events from namespaced events ('click.bs.button' --> 'click')
60+
let typeEvent = originalTypeEvent.replace(stripNameRegex, "");
61+
const custom = customEvents[typeEvent];
62+
63+
if (custom) {
64+
typeEvent = custom;
65+
}
66+
67+
const isNative = nativeEvents.indexOf(typeEvent) > -1;
68+
69+
if (!isNative) {
70+
typeEvent = originalTypeEvent;
71+
}
72+
73+
return [delegation, originalHandler, typeEvent];
74+
}
75+
76+
function addHandler(element, originalTypeEvent, handler, delegationFn) {
77+
if (typeof originalTypeEvent !== "string" || !element) {
78+
return;
79+
}
80+
81+
if (!handler) {
82+
handler = delegationFn;
83+
delegationFn = null;
84+
}
85+
86+
const [delegation, originalHandler, typeEvent] = normalizeParams(
87+
originalTypeEvent,
88+
handler,
89+
delegationFn
90+
);
91+
element.addEventListener(typeEvent, originalHandler, delegation);
92+
}
93+
94+
function removeHandler(element, typeEvent, handler, delegationSelector) {
95+
element.removeEventListener(typeEvent, handler, !!delegationSelector);
96+
}
97+
98+
export const on = function(element, event, handler, delegationFn) {
99+
addHandler(element, event, handler, delegationFn);
100+
};
101+
102+
export const off = function(element, event, handler, delegationFn) {
103+
if (typeof event !== "string" || !element) {
104+
return;
105+
}
106+
107+
const [delegation, originalHandler, typeEvent] = normalizeParams(
108+
event,
109+
handler,
110+
delegationFn
111+
);
112+
113+
removeHandler(
114+
element,
115+
typeEvent,
116+
originalHandler,
117+
delegation ? handler : null
118+
);
119+
};
120+
121+
export const onMulti = function(element, eventArray, handler, delegationFn) {
122+
const events = eventArray.split(" ");
123+
124+
for (let i = 0; i < events.length; i++) {
125+
on(element, events[i], handler, delegationFn);
6126
}
7127
};
8128

9-
export const off = function(element, event, handler) {
10-
if (element && event) {
11-
document.removeEventListener
12-
? element.removeEventListener(event, handler, false)
13-
: element.detachEvent("on" + event, handler);
129+
export const offMulti = function(element, eventArray, handler, delegationFn) {
130+
const events = eventArray.split(" ");
131+
132+
for (let i = 0; i < events.length; i++) {
133+
off(element, events[i], handler, delegationFn);
14134
}
15135
};

Diff for: src/components/utils/MDBFocusTrap.js

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { ref } from "vue";
2+
import { on, off } from "./MDBEventHandlers";
3+
4+
function MDBFocusTrap() {
5+
const trapElement = ref(null);
6+
const firstFocusableElement = ref(null);
7+
const lastFocusableElement = ref(null);
8+
9+
function initFocusTrap(element) {
10+
trapElement.value = element;
11+
12+
calculateFocusTrap();
13+
14+
on(window, "keydown", focusFirstElement);
15+
16+
return true;
17+
}
18+
19+
function calculateFocusTrap() {
20+
const focusable = Array.from(
21+
trapElement.value.querySelectorAll(
22+
'button, a, input, select, textarea, [tabindex]:not([tabindex="-1"])'
23+
)
24+
).filter(el => {
25+
return (
26+
!el.classList.contains("ps__thumb-x") &&
27+
!el.classList.contains("ps__thumb-y") &&
28+
!el.disabled
29+
);
30+
});
31+
32+
if (focusable.length === 0) return;
33+
34+
firstFocusableElement.value = focusable[0];
35+
36+
lastFocusableElement.value = focusable[focusable.length - 1];
37+
on(lastFocusableElement.value, "keydown", e =>
38+
handleLastElementKeydown(e, true)
39+
);
40+
}
41+
42+
function handleLastElementKeydown(e) {
43+
if (e.key === "Tab") {
44+
e.preventDefault();
45+
focusTrap();
46+
}
47+
}
48+
49+
function focusTrap() {
50+
if (!firstFocusableElement.value) return;
51+
52+
firstFocusableElement.value.focus();
53+
}
54+
55+
function focusFirstElement(e, trap = false) {
56+
if (e.key === "Tab") {
57+
e.preventDefault();
58+
focusTrap();
59+
}
60+
if (trap) return;
61+
off(window, "keydown", focusFirstElement);
62+
}
63+
64+
function removeFocusTrap() {
65+
off(lastFocusableElement.value, "keydown", handleLastElementKeydown);
66+
}
67+
68+
return {
69+
initFocusTrap,
70+
removeFocusTrap
71+
};
72+
}
73+
74+
export default MDBFocusTrap;

Diff for: src/directives/free/mdbFocusTrap.js

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { on, off } from "@/components/utils/MDBEventHandlers";
2+
3+
export default {
4+
mounted(el) {
5+
if (!el) return;
6+
7+
let firstFocusableElement;
8+
let lastFocusableElement;
9+
10+
el.initFocusTrap = () => {
11+
el.calculateFocusTrap();
12+
13+
on(window, "keydown", el.focusFirstElement);
14+
};
15+
16+
el.calculateFocusTrap = () => {
17+
const focusable = Array.from(
18+
el.querySelectorAll(
19+
'button, a, input, select, textarea, [tabindex]:not([tabindex="-1"])'
20+
)
21+
).filter(item => {
22+
return (
23+
!item.classList.contains("ps__thumb-x") &&
24+
!item.classList.contains("ps__thumb-y") &&
25+
!item.disabled
26+
);
27+
});
28+
29+
if (focusable.length === 0) return;
30+
31+
firstFocusableElement = focusable[0];
32+
33+
lastFocusableElement = focusable[focusable.length - 1];
34+
on(lastFocusableElement, "keydown", e => el.focusFirstElement(e, true));
35+
};
36+
37+
el.focusTrap = () => {
38+
if (!firstFocusableElement) return;
39+
40+
firstFocusableElement.focus();
41+
};
42+
43+
el.focusFirstElement = (e, trap = false) => {
44+
if (e.key === "Tab") {
45+
e.preventDefault();
46+
el.focusTrap();
47+
}
48+
if (trap) return;
49+
off(window, "keydown", el.focusFirstElement);
50+
};
51+
52+
el.removeFocusTrap = () => {
53+
off(lastFocusableElement, "keydown", el.handleLastElementKeydown);
54+
};
55+
56+
el.initFocusTrap();
57+
},
58+
unmounted(el) {
59+
if (!el) return;
60+
61+
el.removeFocusTrap();
62+
}
63+
};

0 commit comments

Comments
 (0)