Skip to content

Commit 1cad4f9

Browse files
author
unknown
committed
1.0.0-beta1
1 parent 3219b63 commit 1cad4f9

32 files changed

+2543
-633
lines changed

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-alpha4
3+
Version: FREE 1.0.0-beta1
44

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

Diff for: css/mdb.min.css

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

Diff for: css/mdb.min.css.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.common.js

+1,517-459
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-alpha4",
3+
"version": "1.0.0-beta1",
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/MDBDropdown.vue

+8-3
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ export default {
8686
// controls if DropdownMenu has been mounted into DOM and its element
8787
// can be targeted by the Popper setup function
8888
const isMenuMounted = ref(false);
89-
const setMenuMountedState = boolean => {
89+
const dropdownMenu = ref(null);
90+
const setMenuMountedState = (boolean, menuRef) => {
9091
isMenuMounted.value = boolean;
92+
dropdownMenu.value = menuRef;
9193
};
9294
provide("setMenuMountedState", setMenuMountedState);
9395
@@ -124,6 +126,7 @@ export default {
124126
});
125127
126128
provide("isPopperActive", isPopperActive);
129+
provide("externalTarget", props.target);
127130
128131
// ------------------- handleEscAndOutsideClick -------------------
129132
// mimics toggling modelValue when user click outside the toggle button
@@ -147,7 +150,7 @@ export default {
147150
triggerEl.value = props.target
148151
? document.querySelector(props.target)
149152
: root.value.querySelector("[data-trigger]");
150-
popperEl.value = root.value.querySelector("[data-popper]");
153+
popperEl.value = dropdownMenu.value;
151154
152155
if (typeof props.align === "string") {
153156
menuAlignClasses.value = `dropdown-menu-${props.align}`;
@@ -174,7 +177,9 @@ export default {
174177
modifiers: {
175178
offset: {
176179
offset: props.offset || "0"
177-
}
180+
},
181+
preventOverflow: { enabled: true },
182+
flip: { enabled: true }
178183
}
179184
};
180185

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

+33-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<transition>
2+
<transition v-if="!shouldTeleport">
33
<component
44
v-if="isMounted"
55
:is="tag"
@@ -12,10 +12,25 @@
1212
<slot />
1313
</component>
1414
</transition>
15+
<teleport v-else :to="externalTarget">
16+
<transition>
17+
<component
18+
v-if="isMounted"
19+
:is="tag"
20+
:class="className"
21+
:style="staticStyle"
22+
v-bind="attrs"
23+
:data-popper="externalTarget"
24+
ref="root"
25+
>
26+
<slot />
27+
</component>
28+
</transition>
29+
</teleport>
1530
</template>
1631

1732
<script>
18-
import { computed, inject, ref, watch } from "vue";
33+
import { computed, inject, onMounted, ref, watch } from "vue";
1934
import { on, off } from "../../utils/MDBEventHandlers.js";
2035
2136
export default {
@@ -86,8 +101,8 @@ export default {
86101
cur => {
87102
if (cur) {
88103
setTimeout(() => {
89-
setMenuMountedState(true);
90-
}, 10);
104+
setMenuMountedState(true, root.value);
105+
}, 100);
91106
} else if (!cur && isPopperActive) {
92107
setInactive();
93108
@@ -123,6 +138,18 @@ export default {
123138
}
124139
});
125140
141+
const externalTarget = inject("externalTarget", false);
142+
const shouldTeleport = ref(false);
143+
144+
onMounted(() => {
145+
if (externalTarget) {
146+
const target = document.body.querySelector(externalTarget);
147+
if (target) {
148+
shouldTeleport.value = true;
149+
}
150+
}
151+
});
152+
126153
// ------------------- isPopperActive -------------------
127154
// controls if DropdownMenu is visible for user or not
128155
// controls show class and animation
@@ -205,6 +232,8 @@ export default {
205232
showClass,
206233
className,
207234
isMounted,
235+
shouldTeleport,
236+
externalTarget,
208237
root,
209238
attrs,
210239
props

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import mdbClickOutside from "@/directives/free/mdbClickOutside.js";
2323
2424
export default {
2525
name: "MDBDropdownToggle",
26-
2726
components: { MDBBtn },
2827
inheritAttrs: false,
2928
emits: ["toggle-dropdown"],
@@ -33,10 +32,6 @@ export default {
3332
type: String,
3433
default: "button"
3534
},
36-
color: {
37-
type: String,
38-
default: "primary"
39-
},
4035
href: [String, null],
4136
split: {
4237
type: Boolean,
@@ -52,15 +47,20 @@ export default {
5247
btnClass.value,
5348
"dropdown-toggle",
5449
props.split && "dropdown-toggle-split",
55-
props.size && `btn-${props.size}`
50+
props.size && `btn-${props.size}`,
51+
props.outline && `btn-outline-${props.outline}`
5652
];
5753
});
5854
5955
const btnClass = computed(() => {
60-
if (props.tag === "button") {
61-
const color = props.color ? `btn-${props.color}` : "";
62-
return `btn ${color}`;
63-
}
56+
if (props.tag !== "button") return;
57+
const color =
58+
props.color && !props.outline
59+
? `btn-${props.color}`
60+
: props.outline
61+
? ""
62+
: "btn-primary";
63+
return `btn ${color}`;
6464
});
6565
6666
const expanded = ref(false);

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

+6-9
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
<label v-if="label" :class="labelClassName" :for="uid">
1515
{{ label }}
1616
</label>
17-
<div :class="validFeedbackClassName">
17+
<div v-if="validFeedback" :class="validFeedbackClassName">
1818
{{ validFeedback }}
1919
</div>
20-
<div :class="invalidFeedbackClassName">
20+
<div v-if="invalidFeedback" :class="invalidFeedbackClassName">
2121
{{ invalidFeedback }}
2222
</div>
2323
</component>
@@ -36,10 +36,10 @@
3636
<label v-if="!wrap && label" :class="labelClassName" :for="uid">
3737
{{ label }}
3838
</label>
39-
<div v-if="!wrap" :class="validFeedbackClassName">
39+
<div v-if="!wrap && validFeedback" :class="validFeedbackClassName">
4040
{{ validFeedback }}
4141
</div>
42-
<div v-if="!wrap" :class="invalidFeedbackClassName">
42+
<div v-if="!wrap && invalidFeedback" :class="invalidFeedbackClassName">
4343
{{ invalidFeedback }}
4444
</div>
4545
</template>
@@ -64,7 +64,6 @@ export default {
6464
validateOnChange: Boolean,
6565
isValidated: Boolean,
6666
isValid: Boolean,
67-
isInvalid: Boolean,
6867
validFeedback: String,
6968
invalidFeedback: String,
7069
tooltipFeedback: {
@@ -101,10 +100,8 @@ export default {
101100
return [
102101
props.btnCheck ? "btn-check" : "form-check-input",
103102
props.inputClass && props.inputClass,
104-
((isInputValidated.value && isInputValid.value) || props.isValid) &&
105-
"is-valid",
106-
((isInputValidated.value && !isInputValid.value) || props.isInvalid) &&
107-
"is-invalid"
103+
isInputValidated.value && isInputValid.value && "is-valid",
104+
isInputValidated.value && !isInputValid.value && "is-invalid"
108105
];
109106
});
110107
const labelClassName = computed(() => {

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

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<template>
2+
<label v-if="label" :class="labelClassName" :for="uid">{{ label }}</label>
3+
<input
4+
type="file"
5+
:class="inputClassName"
6+
v-bind="attrs"
7+
:id="uid"
8+
@change="handleChange"
9+
/>
10+
<div v-if="validFeedback" :class="validFeedbackClassName">
11+
{{ validFeedback }}
12+
</div>
13+
<div v-if="invalidFeedback" :class="invalidFeedbackClassName">
14+
{{ invalidFeedback }}
15+
</div>
16+
</template>
17+
18+
<script>
19+
import { computed, ref, watch } from "vue";
20+
import { getUID } from "../../utils/getUID";
21+
22+
export default {
23+
name: "MDBFile",
24+
props: {
25+
id: String,
26+
inputClass: String,
27+
invalidFeedback: String,
28+
isInvalid: Boolean,
29+
isValid: Boolean,
30+
isValidated: Boolean,
31+
label: String,
32+
labelClass: String,
33+
modelValue: {
34+
type: [FileList, Array],
35+
default: () => []
36+
},
37+
size: String,
38+
tooltipFeedback: Boolean,
39+
validFeedback: String,
40+
validateOnChange: Boolean
41+
},
42+
emits: ["update:modelValue"],
43+
setup(props, { attrs, emit }) {
44+
const uid = props.id || getUID("MDBFile-");
45+
const inputValue = ref(props.modelValue);
46+
47+
const inputClassName = computed(() => {
48+
return [
49+
"form-control",
50+
props.size && `form-control-${props.size}`,
51+
isInputValidated.value && isInputValid.value && "is-valid",
52+
isInputValidated.value && !isInputValid.value && "is-invalid",
53+
props.inputClass
54+
];
55+
});
56+
const labelClassName = computed(() => {
57+
return ["form-label", props.labelClass];
58+
});
59+
const validFeedbackClassName = computed(() => {
60+
return props.tooltipFeedback ? "valid-tooltip" : "valid-feedback";
61+
});
62+
const invalidFeedbackClassName = computed(() => {
63+
return props.tooltipFeedback ? "invalid-tooltip" : "invalid-feedback";
64+
});
65+
66+
// Validation ------------------------
67+
const isInputValidated = ref(props.isValidated);
68+
const isInputValid = ref(props.isValid);
69+
70+
const handleValidation = event => {
71+
isInputValid.value = event.target.files.length > 0;
72+
isInputValidated.value = true;
73+
};
74+
75+
const handleChange = event => {
76+
inputValue.value = event.target.files;
77+
emit("update:modelValue", inputValue.value);
78+
79+
if (props.validateOnChange) {
80+
handleValidation(event);
81+
}
82+
};
83+
84+
watch(
85+
() => props.modelValue,
86+
value => (inputValue.value = value)
87+
);
88+
89+
watch(
90+
() => props.isValidated,
91+
value => (isInputValidated.value = value)
92+
);
93+
94+
watch(
95+
() => props.isValid,
96+
value => {
97+
isInputValid.value = value;
98+
}
99+
);
100+
101+
return {
102+
attrs,
103+
uid,
104+
inputClassName,
105+
labelClassName,
106+
validFeedbackClassName,
107+
invalidFeedbackClassName,
108+
handleChange
109+
};
110+
}
111+
};
112+
</script>

0 commit comments

Comments
 (0)