@teammodlr/ui-kit 2.2.2 → 2.3.1

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.
@@ -1,151 +1,116 @@
1
- <template>
2
- <component
3
- :is="computedType"
4
- :href="href"
5
- ref="wrapper"
6
- :class="computedWrapperClasses"
7
- role="menuitem"
8
- tabindex="0"
9
- @click="handleSelect"
10
- v-bind="$attrs">
11
- <div v-if="hasIconLeft" :class="style.menuItemIcon">
12
- <slot name="icon-left" />
13
- </div>
14
- <div :class="style.menuItemTextContainer">
15
- <span :class="style.menuItemText"><slot /></span>
16
- </div>
17
- <!-- <div v-if="hotkey" class="m-dropdown__hotkeys">
18
- <template v-for="key in hotkey.split('+')">
19
- <kbd>{{ key }}</kbd>
20
- </template>
21
- </div> -->
22
- <div v-if="hasIconRight" :class="style.menuItemIcon">
23
- <slot name="icon-right" />
24
- </div>
25
- </component>
26
- </template>
27
-
28
- <script lang="ts">
29
- import {
30
- computed,
31
- defineComponent,
32
- inject,
33
- type PropType,
34
- ref,
35
- toRef
36
- } from 'vue';
37
- import { useLabel } from './hooks';
38
- import * as style from './style';
39
- import type { Variant } from '../../types/props';
40
-
41
- export default defineComponent({
42
- name: 'DropdownItem',
43
- props: {
44
- label: {
45
- type: [String, Number],
46
- default: null
47
- },
48
- disabled: {
49
- type: Boolean,
50
- default: false
51
- },
52
- reference: {
53
- type: Boolean,
54
- default: false
55
- },
56
- onSelect: {
57
- type: Function as PropType<(label: string | number) => void>,
58
- default: () => {}
59
- },
60
- hotkey: {
61
- type: String,
62
- default: null
63
- },
64
- description: {
65
- type: String,
66
- default: null
67
- },
68
- href: {
69
- type: String,
70
- default: null
71
- },
72
- variant: {
73
- type: String as PropType<Variant>,
74
- default: 'default'
75
- }
76
- },
77
- emits: [],
78
- setup(props, { slots }) {
79
- const parentSelect = inject('dropdown-select', null);
80
- // const state = inject(DROPDOWN_STATE, null);
81
- // const keys = useMagicKeys({
82
- // passive: false,
83
- // onEventFired: (event) => {
84
-
85
- // // only fire when the dropdown is open
86
- // if (state?.isOpen.value) {
87
- // event.preventDefault();
88
- // }
89
- // }
90
- // });
91
-
92
- const hasIconLeft = computed(() => !!slots['icon-left']);
93
- const hasIconRight = computed(() => !!slots['icon-right']);
94
-
95
- const wrapper = ref(null);
96
- const label = toRef(props, 'label');
97
- const isReference = ref(props.reference);
98
- const currentLabel = useLabel(label, wrapper);
99
- function handleSelect() {
100
- if (props.disabled || isReference.value) {
101
- return;
102
- }
103
-
104
- if (typeof parentSelect === 'function') {
105
- // @ts-ignore
106
- parentSelect([currentLabel.value!]);
107
- }
108
-
109
- props.onSelect(currentLabel.value!);
110
- }
111
-
112
- // const isOpen = computed(() => {
113
- // return state?.isOpen.value;
114
- // });
115
-
116
- const computedWrapperClasses = computed(() => {
117
- return [style.menuItem, style.variant[props.variant]];
118
- });
119
-
120
- const computedType = computed(() => {
121
- if (props.href) {
122
- return 'a';
123
- }
124
-
125
- return 'li';
126
- });
127
-
128
- // onMounted(() => {
129
- // if (props.hotkey) {
130
- // const combination = keys[props.hotkey];
131
-
132
- // whenever(combination, (v) => {
133
- // if (v && isOpen.value) {
134
- // handleSelect();
135
- // }
136
- // })
137
- // }
138
- // })
139
-
140
- return {
141
- wrapper,
142
- hasIconLeft,
143
- hasIconRight,
144
- handleSelect,
145
- computedWrapperClasses,
146
- style,
147
- computedType
148
- };
149
- }
150
- });
151
- </script>
1
+ <template>
2
+ <DropdownMenuItem :class="computedWrapperClasses" :as="computedType" :href="href">
3
+ <div :class="style.menuItemIcon">
4
+ <slot name="icon-left" />
5
+ </div>
6
+ <div :class="style.menuItemTextContainer">
7
+ <span :class="style.menuItemText"><slot /></span>
8
+ </div>
9
+ <slot name="keyboard" />
10
+ </DropdownMenuItem>
11
+ <!-- <component
12
+ :is="computedType"
13
+ :href="href"
14
+ ref="wrapper"
15
+ :class="computedWrapperClasses"
16
+ role="menuitem"
17
+ tabindex="0"
18
+ @click="handleSelect"
19
+ v-bind="$attrs">
20
+ <div v-if="hasIconLeft" :class="style.menuItemIcon">
21
+ <slot name="icon-left" />
22
+ </div>
23
+ <div :class="style.menuItemTextContainer">
24
+ <span :class="style.menuItemText"><slot /></span>
25
+ </div>
26
+ <!-- <div v-if="hotkey" class="m-dropdown__hotkeys">
27
+ <template v-for="key in hotkey.split('+')">
28
+ <kbd>{{ key }}</kbd>
29
+ </template>
30
+ </div> -->
31
+ <!-- <div v-if="hasIconRight" :class="style.menuItemIcon">
32
+ <slot name="icon-right" />
33
+ </div>
34
+ </component> -->
35
+ </template>
36
+
37
+ <script lang="ts">
38
+ import {
39
+ computed,
40
+ defineComponent,
41
+ type PropType,
42
+ ref
43
+ } from 'vue';
44
+ import { DropdownMenuItem } from "radix-vue";
45
+ import * as style from './style';
46
+ import type { Variant } from '../../types/props';
47
+
48
+ export default defineComponent({
49
+ name: 'DropdownItem',
50
+ components: {
51
+ DropdownMenuItem
52
+ },
53
+ props: {
54
+ label: {
55
+ type: [String, Number],
56
+ default: null
57
+ },
58
+ disabled: {
59
+ type: Boolean,
60
+ default: false
61
+ },
62
+ reference: {
63
+ type: Boolean,
64
+ default: false
65
+ },
66
+ onSelect: {
67
+ type: Function as PropType<(label: string | number) => void>,
68
+ default: () => {}
69
+ },
70
+ hotkey: {
71
+ type: String,
72
+ default: null
73
+ },
74
+ description: {
75
+ type: String,
76
+ default: null
77
+ },
78
+ href: {
79
+ type: String,
80
+ default: null
81
+ },
82
+ variant: {
83
+ type: String as PropType<Variant>,
84
+ default: 'default'
85
+ }
86
+ },
87
+ emits: [],
88
+ setup(props, { slots }) {
89
+
90
+ const hasIconLeft = computed(() => !!slots['icon-left']);
91
+ const hasIconRight = computed(() => !!slots['icon-right']);
92
+
93
+ const wrapper = ref(null);
94
+ const computedWrapperClasses = computed(() => {
95
+ return [style.menuItem, style.variant[props.variant]];
96
+ });
97
+
98
+ const computedType = computed(() => {
99
+ if (props.href) {
100
+ return 'a';
101
+ }
102
+
103
+ return 'div';
104
+ });
105
+
106
+ return {
107
+ wrapper,
108
+ hasIconLeft,
109
+ hasIconRight,
110
+ computedWrapperClasses,
111
+ style,
112
+ computedType
113
+ };
114
+ }
115
+ });
116
+ </script>
@@ -1,23 +1,26 @@
1
- <template>
2
- <li :class="computedClasses"></li>
3
- </template>
4
-
5
- <script lang="ts">
6
- import {computed, defineComponent} from "vue";
7
- import * as style from "./style";
8
-
9
- export default defineComponent({
10
- name: "DropdownSeperator",
11
- setup() {
12
- const computedClasses = computed(() => {
13
- return [
14
- style.menuSeperator
15
- ]
16
- });
17
-
18
- return {
19
- computedClasses
20
- }
21
- }
22
- })
23
- </script>
1
+ <template>
2
+ <DropdownMenuSeparator :class="computedClasses" />
3
+ </template>
4
+
5
+ <script lang="ts">
6
+ import {computed, defineComponent} from "vue";
7
+ import * as style from "./style";
8
+ import { DropdownMenuSeparator } from 'radix-vue';
9
+ export default defineComponent({
10
+ name: "DropdownSeperator",
11
+ components: {
12
+ DropdownMenuSeparator
13
+ },
14
+ setup() {
15
+ const computedClasses = computed(() => {
16
+ return [
17
+ style.menuSeperator
18
+ ]
19
+ });
20
+
21
+ return {
22
+ computedClasses
23
+ }
24
+ }
25
+ })
26
+ </script>