Skip to content
This repository was archived by the owner on Aug 2, 2024. It is now read-only.

Commit e1b2d3e

Browse files
feat: Added new click-outside-directives
Feat: Added new click outside directives/mixins
1 parent 920e928 commit e1b2d3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+681
-262
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<title>Click Outside Directive</title>
2+
<tip>The `on-click-outside`-directive is private and should not be used by app. It may be properly exposed at some point in the future.</tip>
3+
<docs>You can use the directive `v-on-click-outside` in order to detect clicks outside of a specific component/element.</docs>
4+
<tip>Use `v-is-inside`, in order to mark additional elements/components as being part of the inside. Anything marked with `v-is-inside` won't cause the outside-hanlder to be called.</tip>
5+
6+
<template>
7+
<div>
8+
<FdAlert :dismissible="false">
9+
{{ message }}
10+
</FdAlert>
11+
<br /><br />
12+
<div class="outside">
13+
<p>this is where the <strong>outside</strong> starts</p>
14+
<div
15+
class="inside"
16+
v-on-click-outside="clickOutside"
17+
@click="message = 'Click inside detected.'"
18+
>
19+
<p>
20+
<strong>inside:</strong> Clicks will not trigger a
21+
<em>clickOutside</em>-event.
22+
</p>
23+
</div>
24+
<div
25+
class="inside"
26+
v-is-inside
27+
@click="message = 'Click inside detected.'"
28+
>
29+
<p>
30+
<strong>inside:</strong> even though it is not inside a
31+
<code>v-on-click-outside</code>-container.
32+
</p>
33+
</div>
34+
</div>
35+
</div>
36+
</template>
37+
38+
<script>
39+
export default {
40+
data: () => ({ clickOutsideContext: "context", message: "Click somewhere." }),
41+
methods: {
42+
clickOutside() {
43+
this.message = "Click outside detected.";
44+
}
45+
}
46+
};
47+
</script>
48+
49+
<style scoped>
50+
.outside > * {
51+
margin: 30px 0;
52+
}
53+
54+
.inside {
55+
border: 1px solid #aaaaaa;
56+
background-color: #fefefe;
57+
color: black;
58+
text-align: center;
59+
vertical-align: middle;
60+
padding: 20px;
61+
}
62+
.outside {
63+
border: 1px solid #aaaaaa;
64+
background-color: #fefefe;
65+
color: black;
66+
text-align: center;
67+
vertical-align: middle;
68+
padding: 20px;
69+
}
70+
</style>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ExampleCollectionFunction } from "../types";
2+
3+
export const plugin: ExampleCollectionFunction = () => {
4+
return { icon: "cursor", related: [] };
5+
};

docs/src/pages/pages.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
"FdActionBar"
1111
]
1212
},
13+
{
14+
"id": "./ClickOutside/index.ts",
15+
"status": "inprogress",
16+
"slug": "ClickOutside",
17+
"key": "./ClickOutside/index.ts",
18+
"title": "ClickOutside",
19+
"icon": "cursor",
20+
"related": []
21+
},
1322
{
1423
"id": "./Alert/index.ts",
1524
"status": "stable",

ui/src/components/ClickAwayContainer.ts

Lines changed: 0 additions & 88 deletions
This file was deleted.
File renamed without changes.

ui/src/components/ComboboxBase/ComboboxBase.vue

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,38 @@
2121
</FdPopover>
2222
</template>
2323

24-
<script lang="ts">
25-
import { mixins, Uid } from "@/mixins";
26-
import {
27-
Input as FdInput,
28-
InputGroup as FdInputGroup
29-
} from "@/components/Form";
30-
import FdButton from "@/components/Button/Button.vue";
24+
<script>
25+
import { Uid } from "@/mixins";
26+
import { InputGroup as FdInputGroup } from "@/components/Form";
3127
import FdPopover from "@/components/Popover/Popover.vue";
32-
import { PropValidator } from "vue/types/options";
3328
34-
export default mixins(Uid).extend({
29+
export default {
3530
name: "FdComboboxBase",
31+
mixins: [Uid],
3632
model: {
3733
prop: "value",
3834
event: "update"
3935
},
4036
components: {
41-
FdButton,
4237
FdPopover,
43-
FdInput,
4438
FdInputGroup
4539
},
46-
provide(): object {
40+
provide() {
4741
return {
48-
combobox: this as any
42+
combobox: this
4943
};
5044
},
5145
props: {
52-
value: { type: String, default: null } as PropValidator<string | null>,
53-
placeholder: { type: String, default: "" } as PropValidator<string>,
54-
popoverVisible: { type: Boolean, default: false } as PropValidator<boolean>,
55-
compact: { type: Boolean, default: false } as PropValidator<boolean>
46+
value: { type: String, default: null },
47+
placeholder: { type: String, default: "" },
48+
popoverVisible: { type: Boolean, default: false },
49+
compact: { type: Boolean, default: false }
5650
},
5751
data() {
5852
return {
59-
currentPopoverVisible: this.popoverVisible as boolean,
60-
currentValue: this.value as string | number | null
53+
currentPopoverVisible: this.popoverVisible,
54+
currentValue: this.value
6155
};
6256
}
63-
});
57+
};
6458
</script>

ui/src/components/Layout/ShellBar/ShellBar.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
<div class="fd-shellbar"><slot /></div>
33
</template>
44

5-
<script lang="ts">
6-
import Vue from "vue";
7-
export default Vue.extend({
5+
<script>
6+
export default {
87
name: "FdShellBar"
9-
});
8+
};
109
</script>

0 commit comments

Comments
 (0)