@avakhula/ui 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc.json +14 -0
- package/.eslintrc.cjs +15 -0
- package/.nvmrc +1 -0
- package/.prettierrc.json +1 -0
- package/.storybook/intelliboardTheme.js +10 -0
- package/.storybook/main.js +25 -0
- package/.storybook/manager.js +7 -0
- package/.storybook/preview-head.html +11 -0
- package/.storybook/preview.js +24 -0
- package/.storybook/scss-loader.scss +6 -0
- package/.storybook/withSource.js +97 -0
- package/README.md +35 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.mjs +19366 -0
- package/dist/index.umd.js +209 -0
- package/dist/style.css +1 -0
- package/index.html +21 -0
- package/package.json +63 -0
- package/public/favicon.ico +0 -0
- package/src/App.vue +37 -0
- package/src/EventEmmiter.js +19 -0
- package/src/assets/scss/mixins/dropdown-list-item.scss +45 -0
- package/src/assets/scss/mixins/tooltip-position.scss +147 -0
- package/src/assets/scss/mixins.scss +21 -0
- package/src/assets/scss/reset.scss +12 -0
- package/src/assets/scss/style.scss +73 -0
- package/src/assets/scss/typography.scss +155 -0
- package/src/assets/scss/variables/colors.scss +115 -0
- package/src/assets/scss/variables/shadows.scss +17 -0
- package/src/components/Accordion/Accordion.scss +94 -0
- package/src/components/Accordion/Accordion.stories.js +41 -0
- package/src/components/Accordion/Accordion.vue +104 -0
- package/src/components/Accordion/readme.mdx +38 -0
- package/src/components/Alert/Alert.stories.js +69 -0
- package/src/components/Alert/Alert.vue +131 -0
- package/src/components/Alert/alert.scss +166 -0
- package/src/components/Alert/constants.js +6 -0
- package/src/components/Alert/readme.mdx +63 -0
- package/src/components/Badge/Badge.stories.js +53 -0
- package/src/components/Badge/Badge.vue +58 -0
- package/src/components/Badge/readme.mdx +38 -0
- package/src/components/Breadcrumbs/Breadcrumbs.vue +98 -0
- package/src/components/Breadcrumbs/breadcrumbs.scss +77 -0
- package/src/components/Breadcrumbs/breadcrumbs.stories.js +37 -0
- package/src/components/Button/Button.stories.js +124 -0
- package/src/components/Button/Button.vue +165 -0
- package/src/components/Button/button.scss +217 -0
- package/src/components/Button/constants.js +8 -0
- package/src/components/Button/readme.mdx +118 -0
- package/src/components/ButtonGroup/ButtonGroup.stories.js +27 -0
- package/src/components/ButtonGroup/ButtonGroup.vue +24 -0
- package/src/components/ButtonGroup/readme.mdx +10 -0
- package/src/components/Dropdown/Dropdown.spec.js +90 -0
- package/src/components/Dropdown/Dropdown.stories.js +48 -0
- package/src/components/Dropdown/Dropdown.vue +313 -0
- package/src/components/Dropdown/DropdownDivider.vue +15 -0
- package/src/components/Dropdown/DropdownItem.vue +59 -0
- package/src/components/Dropdown/DropdownList.stories.js +174 -0
- package/src/components/Dropdown/DropdownList.vue +93 -0
- package/src/components/Dropdown/constants.js +10 -0
- package/src/components/Dropdown/readme.mdx +88 -0
- package/src/components/Form/CharactersCount.vue +55 -0
- package/src/components/Form/Checkbox/Checkbox.scss +226 -0
- package/src/components/Form/Checkbox/Checkbox.stories.js +63 -0
- package/src/components/Form/Checkbox/Checkbox.vue +128 -0
- package/src/components/Form/Checkbox/readme.mdx +69 -0
- package/src/components/Form/CheckboxGroup/CheckboxGroup.stories.js +64 -0
- package/src/components/Form/CheckboxGroup/CheckboxGroup.vue +87 -0
- package/src/components/Form/CheckboxGroup/readme.mdx +56 -0
- package/src/components/Form/DatePicker/DatePicker.scss +479 -0
- package/src/components/Form/DatePicker/DatePicker.stories.js +78 -0
- package/src/components/Form/DatePicker/DatePicker.vue +284 -0
- package/src/components/Form/DatePicker/Icons/chevron-back.js +5 -0
- package/src/components/Form/DatePicker/Icons/chevron-forward.js +5 -0
- package/src/components/Form/DatePicker/readme.mdx +115 -0
- package/src/components/Form/FormGroup/FormGroup.stories.js +48 -0
- package/src/components/Form/FormGroup/FormGroup.vue +61 -0
- package/src/components/Form/FormGroup/FormGroupSet.stories.js +32 -0
- package/src/components/Form/FormGroup/FormGroupSet.vue +75 -0
- package/src/components/Form/Input/Input.stories.js +137 -0
- package/src/components/Form/Input/Input.vue +231 -0
- package/src/components/Form/Input/constants.js +5 -0
- package/src/components/Form/Input/input.scss +133 -0
- package/src/components/Form/Input/readme.mdx +68 -0
- package/src/components/Form/Label/Label.stories.js +29 -0
- package/src/components/Form/Label/Label.vue +87 -0
- package/src/components/Form/Label/readme.mdx +25 -0
- package/src/components/Form/PhoneInput/PhoneInput.stories.js +43 -0
- package/src/components/Form/PhoneInput/PhoneInput.vue +105 -0
- package/src/components/Form/PhoneInput/phoneInput.scss +197 -0
- package/src/components/Form/PhoneInput/readme.mdx +37 -0
- package/src/components/Form/Radio/Radio.stories.js +34 -0
- package/src/components/Form/Radio/Radio.vue +109 -0
- package/src/components/Form/Radio/radio.scss +187 -0
- package/src/components/Form/Radio/readme.mdx +48 -0
- package/src/components/Form/TextEditor/TextEditor.stories.js +58 -0
- package/src/components/Form/TextEditor/TextEditor.vue +305 -0
- package/src/components/Form/TextEditor/icons/svg/chevron-down.svg +3 -0
- package/src/components/Form/TextEditor/icons/toolbarIcons.js +111 -0
- package/src/components/Form/TextEditor/plugins/alphabetList.js +43 -0
- package/src/components/Form/TextEditor/readme.mdx +59 -0
- package/src/components/Form/TextEditor/textEditor.scss +684 -0
- package/src/components/Form/Textarea/Textarea.spec.js +107 -0
- package/src/components/Form/Textarea/Textarea.stories.js +68 -0
- package/src/components/Form/Textarea/Textarea.vue +102 -0
- package/src/components/Form/Textarea/readme.mdx +45 -0
- package/src/components/Form/Textarea/textarea.scss +84 -0
- package/src/components/Form/Toggle/Toggle.stories.js +44 -0
- package/src/components/Form/Toggle/Toggle.vue +122 -0
- package/src/components/Form/Toggle/readme.mdx +39 -0
- package/src/components/Form/Toggle/toggle.scss +166 -0
- package/src/components/Icon.vue +41 -0
- package/src/components/IconButton/IconButton.scss +91 -0
- package/src/components/IconButton/IconButton.stories.js +115 -0
- package/src/components/IconButton/IconButton.vue +100 -0
- package/src/components/IconButton/constants.js +14 -0
- package/src/components/IconButton/readme.mdx +66 -0
- package/src/components/List.vue +150 -0
- package/src/components/Modal/Modal.stories.js +48 -0
- package/src/components/Modal/Modal.vue +231 -0
- package/src/components/Modal/readme.mdx +76 -0
- package/src/components/Pagination/LimitSelector.vue +73 -0
- package/src/components/Pagination/Pagination.stories.js +54 -0
- package/src/components/Pagination/Pagination.vue +227 -0
- package/src/components/Pagination/pagination.scss +189 -0
- package/src/components/Popover/Popover.stories.js +46 -0
- package/src/components/Popover/Popover.vue +81 -0
- package/src/components/Popover/constants.js +14 -0
- package/src/components/Popover/popover.scss +26 -0
- package/src/components/Popover/readme.mdx +42 -0
- package/src/components/ProgressBar/ProgressBar.stories.js +90 -0
- package/src/components/ProgressBar/ProgressBar.vue +58 -0
- package/src/components/ProgressBar/constants.js +6 -0
- package/src/components/ProgressBar/progressBar.scss +116 -0
- package/src/components/ProgressBar/readme.mdx +67 -0
- package/src/components/Sorting/Sorting.stories.js +35 -0
- package/src/components/Sorting/Sorting.vue +128 -0
- package/src/components/Sorting/constants.js +10 -0
- package/src/components/Sorting/sorting.scss +87 -0
- package/src/components/SplitButton/SplitButton.stories.js +39 -0
- package/src/components/SplitButton/SplitButton.vue +132 -0
- package/src/components/SplitButton/SplitButtonItem.vue +34 -0
- package/src/components/SplitButton/constants.js +4 -0
- package/src/components/SplitButton/readme.mdx +77 -0
- package/src/components/SplitButton/splitButton.scss +161 -0
- package/src/components/StatusIndicator/StatusIndicator.stories.js +40 -0
- package/src/components/StatusIndicator/StatusIndicator.vue +52 -0
- package/src/components/StatusIndicator/constants.js +10 -0
- package/src/components/StatusIndicator/icons.js +48 -0
- package/src/components/StatusIndicator/readme.mdx +21 -0
- package/src/components/Table/Cells/Cell.vue +71 -0
- package/src/components/Table/Cells/CheckboxCell.vue +48 -0
- package/src/components/Table/Row.vue +26 -0
- package/src/components/Table/Table.stories.js +59 -0
- package/src/components/Table/Table.vue +36 -0
- package/src/components/Tabs/Tab.vue +37 -0
- package/src/components/Tabs/TabDropdown.vue +93 -0
- package/src/components/Tabs/Tabs.stories.js +57 -0
- package/src/components/Tabs/Tabs.vue +94 -0
- package/src/components/Tabs/tabs.scss +157 -0
- package/src/components/TagPill/TagPill.stories.js +30 -0
- package/src/components/TagPill/TagPill.vue +133 -0
- package/src/components/TagPill/constants.js +9 -0
- package/src/components/TagPill/readme.mdx +37 -0
- package/src/components/ToggleTip/ToggleTip.stories.js +98 -0
- package/src/components/ToggleTip/ToggleTip.vue +112 -0
- package/src/components/ToggleTip/constants.js +14 -0
- package/src/components/ToggleTip/readme.mdx +46 -0
- package/src/components/ToggleTip/toggleTip.scss +55 -0
- package/src/components/Tooltip/Tooltip.stories.js +56 -0
- package/src/components/Tooltip/Tooltip.vue +49 -0
- package/src/components/Tooltip/readme.mdx +43 -0
- package/src/components/TreeSelect/Option.vue +325 -0
- package/src/components/TreeSelect/Select.stories.js +349 -0
- package/src/components/TreeSelect/Select.vue +909 -0
- package/src/components/TreeSelect/TreeSelect.stories.js +270 -0
- package/src/components/TreeSelect/scss/option.scss +204 -0
- package/src/components/TreeSelect/scss/select.scss +166 -0
- package/src/constants/events.js +2 -0
- package/src/constants/keyCodes.js +8 -0
- package/src/directives/outside/outside.js +81 -0
- package/src/directives/outside/outside.stories.js +29 -0
- package/src/directives/outside/readme.mdx +24 -0
- package/src/helpers/generateUID.js +3 -0
- package/src/helpers/getHrefFromID.js +3 -0
- package/src/helpers/multiLineOverflows.js +3 -0
- package/src/helpers/removeEvents.js +9 -0
- package/src/index.js +49 -0
- package/src/main.js +12 -0
- package/src/stories/link.readme.mdx +57 -0
- package/src/stories/link.stories.js +59 -0
- package/static/Logo.svg +25 -0
- package/static/docks/button.pdf +147566 -0
- package/vite.config.js +47 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { horizontalPosition, verticalPosition } from "./constants";
|
|
2
|
+
import IbDropdown from "./Dropdown.vue";
|
|
3
|
+
import IbButton from "../Button/Button.vue";
|
|
4
|
+
import readme from "./readme.mdx";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: "Dropdown",
|
|
8
|
+
component: IbDropdown,
|
|
9
|
+
parameters: {
|
|
10
|
+
docs: {
|
|
11
|
+
page: readme,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
argTypes: {
|
|
15
|
+
vertical: {
|
|
16
|
+
control: { type: "select" },
|
|
17
|
+
options: Object.values(verticalPosition),
|
|
18
|
+
},
|
|
19
|
+
horizontal: {
|
|
20
|
+
control: { type: "select" },
|
|
21
|
+
options: Object.values(horizontalPosition),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const Template = (args) => ({
|
|
27
|
+
components: { IbDropdown, IbButton },
|
|
28
|
+
setup() {
|
|
29
|
+
return { args };
|
|
30
|
+
},
|
|
31
|
+
template: `
|
|
32
|
+
<ib-dropdown v-bind="args">
|
|
33
|
+
<template #trigger>
|
|
34
|
+
<ib-button>
|
|
35
|
+
Default dropdown
|
|
36
|
+
</ib-button>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<template #body>
|
|
40
|
+
<div style="padding: 10px;">
|
|
41
|
+
Content...
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
</ib-dropdown>
|
|
45
|
+
`,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const Default = Template.bind({});
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ib-dropdown" v-outside="close">
|
|
3
|
+
<span
|
|
4
|
+
class="dropdown-trigger"
|
|
5
|
+
:class="triggerClasses"
|
|
6
|
+
ref="dropdown"
|
|
7
|
+
@keydown="onKeydown"
|
|
8
|
+
@click.prevent.stop="toggle"
|
|
9
|
+
v-if="hasTrigger && triggerType === 'click'"
|
|
10
|
+
>
|
|
11
|
+
<slot name="trigger" v-bind:is-opened="isOpenedState"></slot>
|
|
12
|
+
</span>
|
|
13
|
+
|
|
14
|
+
<span
|
|
15
|
+
class="dropdown-trigger"
|
|
16
|
+
:class="triggerClasses"
|
|
17
|
+
@mouseenter="debouncedOpen"
|
|
18
|
+
@mouseleave="debouncedClose"
|
|
19
|
+
v-if="hasTrigger && triggerType === 'hover'"
|
|
20
|
+
>
|
|
21
|
+
<slot name="trigger" v-bind:is-opened="isOpenedState"></slot>
|
|
22
|
+
</span>
|
|
23
|
+
|
|
24
|
+
<div
|
|
25
|
+
ref="body"
|
|
26
|
+
:class="'ib-dropdown-menu ' + classes"
|
|
27
|
+
v-if="!destroyOnHide || isOpenedState"
|
|
28
|
+
v-show="isOpenedState"
|
|
29
|
+
>
|
|
30
|
+
<div class="dropdown-body" @click="closeOnClickIfRequired">
|
|
31
|
+
<slot name="body" v-bind:is-opened-state="isOpenedState"></slot>
|
|
32
|
+
|
|
33
|
+
<span class="close" @click="close" v-if="showCloseIcon">
|
|
34
|
+
<slot name="close"></slot>
|
|
35
|
+
</span>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="footer-slot">
|
|
38
|
+
<slot name="footerslot"></slot>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div class="before" @click="close">
|
|
43
|
+
<slot name="before"></slot>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script>
|
|
49
|
+
import {
|
|
50
|
+
ENTER_KEY_CODE,
|
|
51
|
+
ARROW_DOWN_KEY_CODE,
|
|
52
|
+
SPACE_KEY_CODE,
|
|
53
|
+
ESC_KEY_CODE,
|
|
54
|
+
} from "../../constants/keyCodes";
|
|
55
|
+
import { EVENT_NAME_CLICK } from "../../constants/events";
|
|
56
|
+
import { OutsideDirective as Outside } from "../../directives/outside/outside";
|
|
57
|
+
import { verticalPosition, horizontalPosition } from "./constants";
|
|
58
|
+
|
|
59
|
+
export default {
|
|
60
|
+
name: "IbDropdown",
|
|
61
|
+
directives: { Outside },
|
|
62
|
+
props: {
|
|
63
|
+
vertical: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: verticalPosition.bottom,
|
|
66
|
+
},
|
|
67
|
+
horizontal: {
|
|
68
|
+
type: String,
|
|
69
|
+
default: horizontalPosition.left,
|
|
70
|
+
},
|
|
71
|
+
triggerClass: {
|
|
72
|
+
default: "",
|
|
73
|
+
},
|
|
74
|
+
isOpened: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false,
|
|
77
|
+
},
|
|
78
|
+
showCloseIcon: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false,
|
|
81
|
+
},
|
|
82
|
+
closeOnClick: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: false,
|
|
85
|
+
},
|
|
86
|
+
disabled: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false,
|
|
89
|
+
},
|
|
90
|
+
triggerType: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: EVENT_NAME_CLICK,
|
|
93
|
+
},
|
|
94
|
+
destroyOnHide: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: false,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
watch: {
|
|
100
|
+
isOpened(value) {
|
|
101
|
+
if (value) {
|
|
102
|
+
this.open();
|
|
103
|
+
} else {
|
|
104
|
+
this.close();
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
mounted() {
|
|
109
|
+
this.$globalEvents.$on("dropdown:open", (event) => {
|
|
110
|
+
if (!this.$el.contains(event.$el)) {
|
|
111
|
+
this.close();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
document.addEventListener("focus", this.closeOnEventOutside, true);
|
|
116
|
+
document.addEventListener("keyup", this.onKeyupDocument);
|
|
117
|
+
},
|
|
118
|
+
data() {
|
|
119
|
+
return {
|
|
120
|
+
isOpenedState: this.isOpened,
|
|
121
|
+
timeout: null,
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
methods: {
|
|
125
|
+
onKeydown(e) {
|
|
126
|
+
if (e.keyCode === ENTER_KEY_CODE || e.keyCode === SPACE_KEY_CODE) {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
this.toggle();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (e.keyCode === ARROW_DOWN_KEY_CODE) {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
this.open();
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
onKeyupDocument(e) {
|
|
137
|
+
if (e.keyCode === ESC_KEY_CODE) {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
this.close();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
toggle() {
|
|
143
|
+
if (this.isOpenedState) {
|
|
144
|
+
this.close();
|
|
145
|
+
} else {
|
|
146
|
+
this.open();
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
open() {
|
|
150
|
+
if (this.disabled) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.isOpenedState = true;
|
|
155
|
+
this.$emit("open");
|
|
156
|
+
this.$globalEvents.$emit("dropdown:open", this);
|
|
157
|
+
},
|
|
158
|
+
close() {
|
|
159
|
+
if (this.disabled) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this.isOpenedState = false;
|
|
163
|
+
this.$emit("close");
|
|
164
|
+
},
|
|
165
|
+
debouncedOpen() {
|
|
166
|
+
this.timeout = setTimeout(() => {
|
|
167
|
+
this.open();
|
|
168
|
+
}, 300);
|
|
169
|
+
},
|
|
170
|
+
debouncedClose() {
|
|
171
|
+
this.close();
|
|
172
|
+
clearTimeout(this.timeout);
|
|
173
|
+
},
|
|
174
|
+
closeOnClickIfRequired() {
|
|
175
|
+
if (this.closeOnClick) {
|
|
176
|
+
this.close();
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
closeOnEventOutside(e) {
|
|
180
|
+
if (!this.$el.contains(e.target)) {
|
|
181
|
+
this.close();
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
computed: {
|
|
186
|
+
classes() {
|
|
187
|
+
const verticalClass =
|
|
188
|
+
this.vertical === verticalPosition.bottom
|
|
189
|
+
? " dropdown-bottom"
|
|
190
|
+
: " dropdown-top",
|
|
191
|
+
horizontalClass =
|
|
192
|
+
this.horizontal === horizontalPosition.left
|
|
193
|
+
? " dropdown-left"
|
|
194
|
+
: this.horizontal === horizontalPosition.right
|
|
195
|
+
? " dropdown-right"
|
|
196
|
+
: " dropdown-center",
|
|
197
|
+
activeClass = this.isOpenedState ? " active" : "";
|
|
198
|
+
|
|
199
|
+
return verticalClass + horizontalClass + activeClass;
|
|
200
|
+
},
|
|
201
|
+
triggerClasses() {
|
|
202
|
+
let activeClass = this.isOpenedState ? "active" : "";
|
|
203
|
+
|
|
204
|
+
if (this.disabled) {
|
|
205
|
+
activeClass += " dropdown-trigger-disabled";
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return this.triggerClass + activeClass;
|
|
209
|
+
},
|
|
210
|
+
hasTrigger() {
|
|
211
|
+
return !!this.$slots.trigger;
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
beforeUnmount() {
|
|
215
|
+
document.removeEventListener("focus", this.closeOnEventOutside, true);
|
|
216
|
+
document.removeEventListener("keypress", this.onKeydownDocument);
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
</script>
|
|
220
|
+
|
|
221
|
+
<style scoped lang="scss">
|
|
222
|
+
@import "../../assets/scss/variables/colors.scss";
|
|
223
|
+
@import "../../assets/scss/variables/shadows.scss";
|
|
224
|
+
|
|
225
|
+
$menu-shadow: $ib-shadow-3;
|
|
226
|
+
$menu-bg: $white;
|
|
227
|
+
|
|
228
|
+
.ib-dropdown {
|
|
229
|
+
position: relative;
|
|
230
|
+
display: inline-block;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.dropdown-trigger {
|
|
234
|
+
cursor: pointer;
|
|
235
|
+
outline: none;
|
|
236
|
+
user-select: none;
|
|
237
|
+
|
|
238
|
+
&.dropdown-trigger-disabled {
|
|
239
|
+
pointer-events: none;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.ib-dropdown-menu {
|
|
244
|
+
z-index: 9998;
|
|
245
|
+
box-shadow: $menu-shadow;
|
|
246
|
+
border-radius: 4px;
|
|
247
|
+
overflow: visible;
|
|
248
|
+
position: absolute;
|
|
249
|
+
display: block;
|
|
250
|
+
background-color: $menu-bg;
|
|
251
|
+
min-width: 100%;
|
|
252
|
+
width: fit-content;
|
|
253
|
+
|
|
254
|
+
.dropdown-body {
|
|
255
|
+
width: max-content;
|
|
256
|
+
min-width: 100%;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
&.dropdown-top {
|
|
260
|
+
bottom: calc(100% + 3px);
|
|
261
|
+
top: auto;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
&.dropdown-bottom {
|
|
265
|
+
bottom: auto;
|
|
266
|
+
top: calc(100% + 3px);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
&.dropdown-left {
|
|
270
|
+
right: auto;
|
|
271
|
+
left: 0;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
&.dropdown-right {
|
|
275
|
+
left: auto;
|
|
276
|
+
right: 0;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
&.dropdown-center {
|
|
280
|
+
left: 50%;
|
|
281
|
+
right: 0;
|
|
282
|
+
transform: translateX(-50%);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
</style>
|
|
286
|
+
<style lang="scss">
|
|
287
|
+
@import "../../assets/scss/variables/colors.scss";
|
|
288
|
+
|
|
289
|
+
.dropdown-trigger {
|
|
290
|
+
&.active {
|
|
291
|
+
.ib-icon-button:not(.button-clear) {
|
|
292
|
+
color: $blue-900;
|
|
293
|
+
background: $blue-200;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
.dropdown-trigger {
|
|
298
|
+
.icon-chevron-down-outline,
|
|
299
|
+
.icon-chevron-down {
|
|
300
|
+
margin-left: 5px;
|
|
301
|
+
font-size: 16px;
|
|
302
|
+
transition: all 0.3s;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
&.active {
|
|
306
|
+
.icon-chevron-down-outline,
|
|
307
|
+
.icon-chevron-down {
|
|
308
|
+
visibility: visible;
|
|
309
|
+
transform: rotate(180deg);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="dropdown-divider"></div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script></script>
|
|
6
|
+
|
|
7
|
+
<style lang="scss" scoped>
|
|
8
|
+
@import "../../assets/scss/variables/colors.scss";
|
|
9
|
+
|
|
10
|
+
.dropdown-divider {
|
|
11
|
+
height: 1px;
|
|
12
|
+
width: 100%;
|
|
13
|
+
background-color: $gray-200;
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<li class="dropdown-item-wrapper">
|
|
3
|
+
<component
|
|
4
|
+
:is="href ? 'a' : 'div'"
|
|
5
|
+
:class="checked ? 'active' : ''"
|
|
6
|
+
v-bind="attrs"
|
|
7
|
+
tabindex="0"
|
|
8
|
+
>
|
|
9
|
+
<slot ref="slot"></slot>
|
|
10
|
+
</component>
|
|
11
|
+
</li>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
export default {
|
|
16
|
+
props: {
|
|
17
|
+
checked: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
href: {
|
|
22
|
+
type: String,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
computed: {
|
|
26
|
+
attrs() {
|
|
27
|
+
const attrs = {
|
|
28
|
+
class: "ib-dropdown-item",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (this.href) {
|
|
32
|
+
attrs.href = this.href;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return attrs;
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<style lang="scss">
|
|
42
|
+
@import "../../assets/scss/mixins/dropdown-list-item.scss";
|
|
43
|
+
@include DropdownListItem;
|
|
44
|
+
|
|
45
|
+
.dropdown-item-wrapper {
|
|
46
|
+
list-style: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ib-dropdown-item p {
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
|
|
53
|
+
.ib-icon {
|
|
54
|
+
font-size: 16px;
|
|
55
|
+
color: inherit;
|
|
56
|
+
margin-right: 15px;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
</style>
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { horizontalPosition, verticalPosition } from "./constants";
|
|
2
|
+
import readme from "./readme.mdx";
|
|
3
|
+
import IbDropdownList from "./DropdownList.vue";
|
|
4
|
+
import IbDropdownItem from "./DropdownItem.vue";
|
|
5
|
+
import IbDropdownDivider from "./DropdownDivider.vue";
|
|
6
|
+
import IbButton from "../Button/Button.vue";
|
|
7
|
+
import IbIconButton from "../IconButton/IconButton.vue";
|
|
8
|
+
import IbIcon from "../Icon.vue";
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: "Dropdown",
|
|
12
|
+
component: IbDropdownList,
|
|
13
|
+
parameters: {
|
|
14
|
+
docs: {
|
|
15
|
+
page: readme,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
argTypes: {
|
|
19
|
+
vertical: {
|
|
20
|
+
control: { type: "select" },
|
|
21
|
+
options: verticalPosition,
|
|
22
|
+
},
|
|
23
|
+
horizontal: {
|
|
24
|
+
control: { type: "select" },
|
|
25
|
+
options: horizontalPosition,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const DropdownListTemplate = (args) => ({
|
|
31
|
+
components: { IbDropdownList, IbButton, IbDropdownItem },
|
|
32
|
+
setup() {
|
|
33
|
+
return { args };
|
|
34
|
+
},
|
|
35
|
+
template: `
|
|
36
|
+
<ib-dropdown-list v-bind="args">
|
|
37
|
+
<template #trigger>
|
|
38
|
+
<ib-button :disabled="args.disabled">
|
|
39
|
+
Dropdown list
|
|
40
|
+
<ib-icon name="chevron-down-outline"></ib-icon>
|
|
41
|
+
</ib-button>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<template #body>
|
|
45
|
+
<ib-dropdown-item checked>Item 1</ib-dropdown-item>
|
|
46
|
+
<ib-dropdown-item>Item 2</ib-dropdown-item>
|
|
47
|
+
<ib-dropdown-item>Item 3</ib-dropdown-item>
|
|
48
|
+
</template>
|
|
49
|
+
</ib-dropdown-list>
|
|
50
|
+
`,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const DropdownList = DropdownListTemplate.bind({});
|
|
54
|
+
DropdownList.parameters = {
|
|
55
|
+
docs: {
|
|
56
|
+
description: {
|
|
57
|
+
story:
|
|
58
|
+
"In the dropdown list, you need to use such elements as a `<ib-dropdown-item />`",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const DropdownListWithIconsTemplate = (args) => ({
|
|
64
|
+
components: {
|
|
65
|
+
IbDropdownList,
|
|
66
|
+
IbButton,
|
|
67
|
+
IbDropdownItem,
|
|
68
|
+
IbIcon,
|
|
69
|
+
IbDropdownDivider,
|
|
70
|
+
},
|
|
71
|
+
setup() {
|
|
72
|
+
return { args };
|
|
73
|
+
},
|
|
74
|
+
template: `
|
|
75
|
+
<ib-dropdown-list v-bind="args">
|
|
76
|
+
<template #trigger>
|
|
77
|
+
<ib-button :disabled="args.disabled">
|
|
78
|
+
Dropdown list
|
|
79
|
+
<ib-icon name="chevron-down-outline"></ib-icon>
|
|
80
|
+
</ib-button>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<template #body>
|
|
84
|
+
<ib-dropdown-item checked>
|
|
85
|
+
<ib-icon icon="print-outline" />
|
|
86
|
+
Item 1
|
|
87
|
+
</ib-dropdown-item>
|
|
88
|
+
<ib-dropdown-item>
|
|
89
|
+
<ib-icon icon="mail-outline" />
|
|
90
|
+
Item 2
|
|
91
|
+
</ib-dropdown-item>
|
|
92
|
+
<ib-dropdown-divider />
|
|
93
|
+
<ib-dropdown-item>
|
|
94
|
+
<ib-icon icon="cloud-upload-outline" />
|
|
95
|
+
Item 3
|
|
96
|
+
</ib-dropdown-item>
|
|
97
|
+
</template>
|
|
98
|
+
</ib-dropdown-list>
|
|
99
|
+
`,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export const DropdownListItemWithIcon = DropdownListWithIconsTemplate.bind({});
|
|
103
|
+
|
|
104
|
+
const DropdownRightPosition = (args) => ({
|
|
105
|
+
components: { IbDropdownList, IbButton, IbDropdownItem },
|
|
106
|
+
setup() {
|
|
107
|
+
return { args };
|
|
108
|
+
},
|
|
109
|
+
template: `
|
|
110
|
+
<ib-dropdown-list v-bind="args">
|
|
111
|
+
<template #trigger>
|
|
112
|
+
<ib-button :disabled="args.disabled">
|
|
113
|
+
Dropdown
|
|
114
|
+
</ib-button>
|
|
115
|
+
</template>
|
|
116
|
+
|
|
117
|
+
<template #body>
|
|
118
|
+
<p style="padding: 5px">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
|
|
119
|
+
</template>
|
|
120
|
+
</ib-dropdown-list>
|
|
121
|
+
`,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
export const DropdownPosition = DropdownRightPosition.bind({});
|
|
125
|
+
DropdownPosition.args = {
|
|
126
|
+
horizontal: horizontalPosition.right,
|
|
127
|
+
};
|
|
128
|
+
DropdownPosition.parameters = {
|
|
129
|
+
docs: {
|
|
130
|
+
description: {
|
|
131
|
+
story:
|
|
132
|
+
"In the dropdown list, you need to use such elements as a `<ib-dropdown-item />`, `<ib-checkbox />`, `<ib-toggle />`",
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
DropdownPosition.decorators = [
|
|
137
|
+
() => ({
|
|
138
|
+
template:
|
|
139
|
+
'<div style="display: flex; align-items:center; justify-content: center; width: 400px; height: 400px; margin: 0 auto"><story /></div>',
|
|
140
|
+
}),
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
const DropdownContextMenuTemplate = (args) => ({
|
|
144
|
+
components: { IbDropdownList, IbIconButton, IbIcon, IbDropdownItem },
|
|
145
|
+
setup() {
|
|
146
|
+
return { args };
|
|
147
|
+
},
|
|
148
|
+
template: `
|
|
149
|
+
<ib-dropdown-list v-bind="args">
|
|
150
|
+
<template #trigger>
|
|
151
|
+
<ib-icon-button kind="ghost" :disabled="args.disabled">
|
|
152
|
+
<ib-icon name="ellipsis-horizontal-sharp" />
|
|
153
|
+
</ib-icon-button>
|
|
154
|
+
</template>
|
|
155
|
+
|
|
156
|
+
<template #body>
|
|
157
|
+
<ib-dropdown-item>Page 1</ib-dropdown-item>
|
|
158
|
+
<ib-dropdown-item>Page 2</ib-dropdown-item>
|
|
159
|
+
<ib-dropdown-item>Page 3</ib-dropdown-item>
|
|
160
|
+
</template>
|
|
161
|
+
</ib-dropdown-list>
|
|
162
|
+
`,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export const ContextMenu = DropdownContextMenuTemplate.bind({});
|
|
166
|
+
ContextMenu.args = {
|
|
167
|
+
horizontal: horizontalPosition.center,
|
|
168
|
+
};
|
|
169
|
+
ContextMenu.decorators = [
|
|
170
|
+
() => ({
|
|
171
|
+
template:
|
|
172
|
+
'<div style="display: flex; align-items:center; justify-content: center; width: 400px; height: 400px; margin: 0 auto"><story /></div>',
|
|
173
|
+
}),
|
|
174
|
+
];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="dropdown-list-wrapper">
|
|
3
|
+
<ib-dropdown
|
|
4
|
+
:horizontal="horizontal"
|
|
5
|
+
:vertical="vertical"
|
|
6
|
+
:isOpened="isOpened"
|
|
7
|
+
:closeOnClick="closeOnClick"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
ref="dropdown"
|
|
11
|
+
@all="proxyEvents"
|
|
12
|
+
>
|
|
13
|
+
<template v-slot:trigger="{ isOpened }" v-if="hasTrigger">
|
|
14
|
+
<slot name="trigger" v-bind:is-opened="isOpened"> </slot>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<template v-slot:body="{ isOpened }">
|
|
18
|
+
<ib-list ref="list" class="list">
|
|
19
|
+
<slot name="body" v-bind:is-opened-state="isOpened"></slot>
|
|
20
|
+
</ib-list>
|
|
21
|
+
</template>
|
|
22
|
+
</ib-dropdown>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import IbDropdown from "./Dropdown.vue";
|
|
28
|
+
import IbList from "../List.vue";
|
|
29
|
+
import { verticalPosition, horizontalPosition } from "./constants";
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
props: {
|
|
33
|
+
vertical: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: verticalPosition.bottom,
|
|
36
|
+
},
|
|
37
|
+
horizontal: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: horizontalPosition.left,
|
|
40
|
+
},
|
|
41
|
+
isOpened: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
closeOnClick: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: false,
|
|
48
|
+
},
|
|
49
|
+
disabled: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
methods: {
|
|
55
|
+
proxyEvents(eventInfo) {
|
|
56
|
+
this.$emit(eventInfo.event, ...eventInfo.args);
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
data() {
|
|
60
|
+
return {
|
|
61
|
+
list: this.$refs.list,
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
computed: {
|
|
65
|
+
hasTrigger() {
|
|
66
|
+
return !!this.$slots.trigger;
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
components: {
|
|
70
|
+
IbDropdown,
|
|
71
|
+
IbList,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
</script>
|
|
75
|
+
<style lang="scss">
|
|
76
|
+
@import "../../assets/scss/variables/colors.scss";
|
|
77
|
+
|
|
78
|
+
.dropdown-list-wrapper {
|
|
79
|
+
.list {
|
|
80
|
+
width: fit-content;
|
|
81
|
+
max-width: 220px;
|
|
82
|
+
min-width: 100%;
|
|
83
|
+
max-height: 360px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ib-toggle-container,
|
|
87
|
+
.ib-checkbox {
|
|
88
|
+
min-width: 100%;
|
|
89
|
+
width: max-content;
|
|
90
|
+
max-width: inherit;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
</style>
|