@teammodlr/ui-kit 2.1.49 → 2.1.52
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/lib/components/avatar/Avatar.vue.d.ts +1 -1
- package/lib/components/badge/style/Badge.css.d.ts +2 -2
- package/lib/components/button/Button.vue.d.ts +5 -5
- package/lib/components/button/style/Button.css.d.ts +3 -3
- package/lib/components/checkbox/Checkbox.vue.d.ts +4 -4
- package/lib/components/collapse/Collapse.vue.d.ts +82 -0
- package/lib/components/collapse/CollapseItem.vue.d.ts +43 -0
- package/lib/components/collapse/CollapseItemContent.vue.d.ts +29 -0
- package/lib/components/collapse/interface.d.ts +9 -0
- package/lib/components/collapse/style/Collapse.css.d.ts +8 -0
- package/lib/components/collapse/style/index.d.ts +1 -0
- package/lib/components/configprovider/ConfigProvider.vue.d.ts +11 -11
- package/lib/components/confirm/ConfirmProvider.vue.d.ts +10 -10
- package/lib/components/dialog/Dialog.vue.d.ts +1 -1
- package/lib/components/dropdown/Dropdown.vue.d.ts +2 -2
- package/lib/components/dropdown/DropdownItem.vue.d.ts +3 -3
- package/lib/components/dropdown/style/Dropdown.css.d.ts +1 -1
- package/lib/components/index.d.ts +3 -0
- package/lib/components/input/Input.vue.d.ts +7 -7
- package/lib/components/link/Link.vue.d.ts +2 -2
- package/lib/components/messageprovider/Message.vue.d.ts +2 -2
- package/lib/components/messageprovider/MessageProvider.vue.d.ts +5 -5
- package/lib/components/messageprovider/style/Message.css.d.ts +1 -1
- package/lib/components/modal/Modal.vue.d.ts +2 -2
- package/lib/components/radio/Radio.vue.d.ts +7 -7
- package/lib/components/radiobutton/RadioButton.vue.d.ts +6 -6
- package/lib/components/renderer/renderer.d.ts +1 -1
- package/lib/components/select/Select.vue.d.ts +21 -20
- package/lib/components/switch/Switch.vue.d.ts +4 -4
- package/lib/components/tab/Tab.vue.d.ts +4 -6
- package/lib/components/tab/TabGroup.vue.d.ts +17 -3
- package/lib/components/tab/style/Tab.css.d.ts +7 -0
- package/lib/components/tab/style/index.d.ts +1 -0
- package/lib/components/table/Table.vue.d.ts +2 -2
- package/lib/components/textarea/Textarea.vue.d.ts +6 -6
- package/lib/components/tree/Tree.vue.d.ts +1 -1
- package/lib/composables/useInput.d.ts +1 -1
- package/lib/index.cjs.js +10 -13
- package/lib/index.es.js +3151 -2955
- package/lib/install.d.ts +1 -1
- package/lib/style.css +1 -1
- package/lib/styles/theme.css.d.ts +1 -1
- package/package.json +76 -89
- package/src/call.ts +34 -34
- package/src/components/avatar/examples/index.stories.ts +25 -25
- package/src/components/avatargroup/examples/index.stories.ts +19 -19
- package/src/components/badge/examples/index.stories.ts +19 -19
- package/src/components/breadcrumb/examples/index.stories.ts +16 -16
- package/src/components/button/examples/index.stories.ts +37 -37
- package/src/components/buttongroup/examples/index.stories.ts +17 -17
- package/src/components/checkbox/examples/index.stories.ts +16 -16
- package/src/components/collapse/Collapse.vue +143 -0
- package/src/components/collapse/CollapseItem.vue +123 -0
- package/src/components/collapse/CollapseItemContent.vue +58 -0
- package/src/components/collapse/examples/basic.vue +13 -0
- package/src/components/collapse/examples/index.stories.ts +18 -0
- package/src/components/collapse/examples/index.ts +1 -0
- package/src/components/collapse/interface.ts +38 -0
- package/src/components/collapse/style/Collapse.css.ts +87 -0
- package/src/components/collapse/style/index.ts +1 -0
- package/src/components/colorpicker/examples/index.stories.ts +12 -12
- package/src/components/configprovider/ConfigProvider.vue +38 -38
- package/src/components/confirm/ConfirmProvider.vue +82 -82
- package/src/components/confirm/examples/index.stories.ts +26 -26
- package/src/components/dialog/examples/index.stories.ts +14 -14
- package/src/components/dropdown/examples/index.stories.ts +26 -26
- package/src/components/form/examples/index.stories.ts +23 -23
- package/src/components/image/examples/index.stories.ts +10 -10
- package/src/components/index.ts +51 -48
- package/src/components/input/examples/index.stories.ts +26 -26
- package/src/components/link/examples/index.stories.ts +15 -15
- package/src/components/messageprovider/examples/index.stories.ts +26 -26
- package/src/components/modal/examples/index.stories.ts +16 -16
- package/src/components/pagination/examples/index.stories.ts +11 -11
- package/src/components/radio/examples/index.stories.ts +16 -16
- package/src/components/radiobuttongroup/examples/index.stories.ts +18 -18
- package/src/components/renderer/examlpes/index.stories.ts +14 -14
- package/src/components/select/Select.vue +755 -755
- package/src/components/select/examples/basic.vue +26 -26
- package/src/components/select/examples/index.stories.ts +16 -16
- package/src/components/select/types.ts +27 -27
- package/src/components/skeleton/examples/index.stories.ts +13 -13
- package/src/components/switch/examples/index.stories.ts +15 -15
- package/src/components/switch/style/Switch.css.ts +135 -135
- package/src/components/tab/Tab.vue +85 -98
- package/src/components/tab/TabGroup.vue +96 -90
- package/src/components/tab/examples/index.stories.ts +21 -10
- package/src/components/tab/style/Tab.css.ts +137 -0
- package/src/components/tab/style/index.ts +1 -0
- package/src/components/table/examples/index.stories.ts +17 -17
- package/src/components/tag/examples/index.stories.ts +16 -16
- package/src/components/textarea/examples/index.stories.ts +14 -14
- package/src/components/tooltip/examples/index.stories.ts +17 -17
- package/src/components/transfer/examples/index.stories.ts +12 -12
- package/src/components/tree/examples/index.stories.ts +12 -12
- package/src/components/virtualscroll/examples/index.stories.ts +11 -11
- package/src/composables/useCachedUid.ts +15 -15
- package/src/composables/useInput.ts +151 -151
- package/src/examples/cards/cards.stories.ts +9 -9
- package/src/examples/modal/modal.stories.ts +9 -9
- package/src/types/props.ts +21 -21
- package/src/utils/call.ts +34 -34
- package/src/utils/injection.ts +45 -45
- package/src/components/tab/Tab.css +0 -113
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
// inspired by indielayer ui
|
|
2
|
-
import type { PropType } from 'vue';
|
|
3
|
-
import { ref, watch, inject, computed, onMounted, onUnmounted } from 'vue';
|
|
4
|
-
import { useId } from './useCachedUid';
|
|
5
|
-
import { FORM_STATE } from '../components/form/symbol';
|
|
6
|
-
|
|
7
|
-
export interface FormInput {
|
|
8
|
-
focus: () => void;
|
|
9
|
-
validate: (value: any) => void;
|
|
10
|
-
setError: (value: string) => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const useInput = (
|
|
14
|
-
props: any,
|
|
15
|
-
{
|
|
16
|
-
focus,
|
|
17
|
-
emit,
|
|
18
|
-
withListeners = true
|
|
19
|
-
}: {
|
|
20
|
-
focus: () => void;
|
|
21
|
-
emit: any;
|
|
22
|
-
withListeners?: boolean;
|
|
23
|
-
}
|
|
24
|
-
) => {
|
|
25
|
-
const isFirstValidation = ref(true);
|
|
26
|
-
const formError = ref(props.error);
|
|
27
|
-
|
|
28
|
-
const id = useId(null, 'input');
|
|
29
|
-
const name = props.name ? props.name : id;
|
|
30
|
-
const _name = ref(name);
|
|
31
|
-
|
|
32
|
-
watch(
|
|
33
|
-
() => props.error,
|
|
34
|
-
value => (formError.value = value)
|
|
35
|
-
);
|
|
36
|
-
watch(
|
|
37
|
-
() => props.name,
|
|
38
|
-
value => (name.value = value)
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const form = inject(FORM_STATE, null);
|
|
42
|
-
|
|
43
|
-
const reset = () => {
|
|
44
|
-
formError.value = '';
|
|
45
|
-
isFirstValidation.value = true;
|
|
46
|
-
emit('update:modelValue', '');
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const setError = (value: string) => {
|
|
50
|
-
formError.value = value;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const validate = (value: any): boolean => {
|
|
54
|
-
value = value || props.modelValue;
|
|
55
|
-
|
|
56
|
-
isFirstValidation.value = false;
|
|
57
|
-
|
|
58
|
-
for (let i = 0; i < props.rules.length; i++) {
|
|
59
|
-
const item = props.rules[i];
|
|
60
|
-
|
|
61
|
-
let valid = true;
|
|
62
|
-
|
|
63
|
-
if (typeof item === 'function') {
|
|
64
|
-
valid = item(value);
|
|
65
|
-
} else if (Array.isArray(item) && item.length === 2) {
|
|
66
|
-
const { 0: rule, 1: options } = item;
|
|
67
|
-
valid = rule(value, options);
|
|
68
|
-
} else {
|
|
69
|
-
const rule = item.fn;
|
|
70
|
-
const { options } = item;
|
|
71
|
-
|
|
72
|
-
valid = rule(value, options);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (valid !== true) {
|
|
76
|
-
formError.value = valid;
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
formError.value = '';
|
|
82
|
-
return true;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const inputListeners = withListeners
|
|
86
|
-
? computed(() => {
|
|
87
|
-
return {
|
|
88
|
-
blur: (event: Event) => emit('blur', event),
|
|
89
|
-
focus: (event: Event) => emit('focus', event),
|
|
90
|
-
input: (event: Event) => {
|
|
91
|
-
emit(
|
|
92
|
-
'update:modelValue',
|
|
93
|
-
(event.target as HTMLInputElement).value
|
|
94
|
-
);
|
|
95
|
-
},
|
|
96
|
-
change: (event: Event) => emit('change', event)
|
|
97
|
-
};
|
|
98
|
-
})
|
|
99
|
-
: {};
|
|
100
|
-
|
|
101
|
-
onMounted(() => {
|
|
102
|
-
form?.add(
|
|
103
|
-
_name.value,
|
|
104
|
-
focus,
|
|
105
|
-
// @ts-ignore
|
|
106
|
-
validate,
|
|
107
|
-
// @ts-ignore
|
|
108
|
-
setError
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
onUnmounted(() => {
|
|
113
|
-
form?.remove(_name.value);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
id,
|
|
118
|
-
isFirstValidation,
|
|
119
|
-
formError,
|
|
120
|
-
insideForm: form?.insideForm ?? false,
|
|
121
|
-
inputListeners,
|
|
122
|
-
reset,
|
|
123
|
-
validate,
|
|
124
|
-
setError,
|
|
125
|
-
//@ts-ignore
|
|
126
|
-
formDisabled: form?.disabled.value || false,
|
|
127
|
-
//@ts-ignore
|
|
128
|
-
formLoading: form?.loading.value || false
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
useInput.emits = (withListeners = true): string[] => {
|
|
133
|
-
return withListeners
|
|
134
|
-
? ['update:modelValue', 'blur', 'focus', 'input', 'change']
|
|
135
|
-
: ['update:modelValue'];
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
useInput.props = () =>
|
|
139
|
-
({
|
|
140
|
-
modelValue: [String, Number, Boolean, Object, Array] as PropType<
|
|
141
|
-
string | number | boolean | object | any[] | any[] | undefined
|
|
142
|
-
>,
|
|
143
|
-
name: String,
|
|
144
|
-
readonly: Boolean,
|
|
145
|
-
required: Boolean,
|
|
146
|
-
error: String,
|
|
147
|
-
rules: {
|
|
148
|
-
type: Array,
|
|
149
|
-
default: () => []
|
|
150
|
-
}
|
|
151
|
-
}) as const;
|
|
1
|
+
// inspired by indielayer ui
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
import { ref, watch, inject, computed, onMounted, onUnmounted } from 'vue';
|
|
4
|
+
import { useId } from './useCachedUid';
|
|
5
|
+
import { FORM_STATE } from '../components/form/symbol';
|
|
6
|
+
|
|
7
|
+
export interface FormInput {
|
|
8
|
+
focus: () => void;
|
|
9
|
+
validate: (value: any) => void;
|
|
10
|
+
setError: (value: string) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const useInput = (
|
|
14
|
+
props: any,
|
|
15
|
+
{
|
|
16
|
+
focus,
|
|
17
|
+
emit,
|
|
18
|
+
withListeners = true
|
|
19
|
+
}: {
|
|
20
|
+
focus: () => void;
|
|
21
|
+
emit: any;
|
|
22
|
+
withListeners?: boolean;
|
|
23
|
+
}
|
|
24
|
+
) => {
|
|
25
|
+
const isFirstValidation = ref(true);
|
|
26
|
+
const formError = ref(props.error);
|
|
27
|
+
|
|
28
|
+
const id = useId(null, 'input');
|
|
29
|
+
const name = props.name ? props.name : id;
|
|
30
|
+
const _name = ref(name);
|
|
31
|
+
|
|
32
|
+
watch(
|
|
33
|
+
() => props.error,
|
|
34
|
+
value => (formError.value = value)
|
|
35
|
+
);
|
|
36
|
+
watch(
|
|
37
|
+
() => props.name,
|
|
38
|
+
value => (name.value = value)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const form = inject(FORM_STATE, null);
|
|
42
|
+
|
|
43
|
+
const reset = () => {
|
|
44
|
+
formError.value = '';
|
|
45
|
+
isFirstValidation.value = true;
|
|
46
|
+
emit('update:modelValue', '');
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const setError = (value: string) => {
|
|
50
|
+
formError.value = value;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const validate = (value: any): boolean => {
|
|
54
|
+
value = value || props.modelValue;
|
|
55
|
+
|
|
56
|
+
isFirstValidation.value = false;
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < props.rules.length; i++) {
|
|
59
|
+
const item = props.rules[i];
|
|
60
|
+
|
|
61
|
+
let valid = true;
|
|
62
|
+
|
|
63
|
+
if (typeof item === 'function') {
|
|
64
|
+
valid = item(value);
|
|
65
|
+
} else if (Array.isArray(item) && item.length === 2) {
|
|
66
|
+
const { 0: rule, 1: options } = item;
|
|
67
|
+
valid = rule(value, options);
|
|
68
|
+
} else {
|
|
69
|
+
const rule = item.fn;
|
|
70
|
+
const { options } = item;
|
|
71
|
+
|
|
72
|
+
valid = rule(value, options);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (valid !== true) {
|
|
76
|
+
formError.value = valid;
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
formError.value = '';
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const inputListeners = withListeners
|
|
86
|
+
? computed(() => {
|
|
87
|
+
return {
|
|
88
|
+
blur: (event: Event) => emit('blur', event),
|
|
89
|
+
focus: (event: Event) => emit('focus', event),
|
|
90
|
+
input: (event: Event) => {
|
|
91
|
+
emit(
|
|
92
|
+
'update:modelValue',
|
|
93
|
+
(event.target as HTMLInputElement).value
|
|
94
|
+
);
|
|
95
|
+
},
|
|
96
|
+
change: (event: Event) => emit('change', event)
|
|
97
|
+
};
|
|
98
|
+
})
|
|
99
|
+
: {};
|
|
100
|
+
|
|
101
|
+
onMounted(() => {
|
|
102
|
+
form?.add(
|
|
103
|
+
_name.value,
|
|
104
|
+
focus,
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
validate,
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
setError
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
onUnmounted(() => {
|
|
113
|
+
form?.remove(_name.value);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
id,
|
|
118
|
+
isFirstValidation,
|
|
119
|
+
formError,
|
|
120
|
+
insideForm: form?.insideForm ?? false,
|
|
121
|
+
inputListeners,
|
|
122
|
+
reset,
|
|
123
|
+
validate,
|
|
124
|
+
setError,
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
formDisabled: form?.disabled.value || false,
|
|
127
|
+
//@ts-ignore
|
|
128
|
+
formLoading: form?.loading.value || false
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
useInput.emits = (withListeners = true): string[] => {
|
|
133
|
+
return withListeners
|
|
134
|
+
? ['update:modelValue', 'blur', 'focus', 'input', 'change']
|
|
135
|
+
: ['update:modelValue'];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
useInput.props = () =>
|
|
139
|
+
({
|
|
140
|
+
modelValue: [String, Number, Boolean, Object, Array] as PropType<
|
|
141
|
+
string | number | boolean | object | any[] | any[] | undefined
|
|
142
|
+
>,
|
|
143
|
+
name: String,
|
|
144
|
+
readonly: Boolean,
|
|
145
|
+
required: Boolean,
|
|
146
|
+
error: String,
|
|
147
|
+
rules: {
|
|
148
|
+
type: Array,
|
|
149
|
+
default: () => []
|
|
150
|
+
}
|
|
151
|
+
}) as const;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Sidebar from './sidebar.vue';
|
|
2
|
-
import { createStory } from '../../__storybook__';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
component: Sidebar,
|
|
6
|
-
title: 'Examples/Cards/Sidebar'
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const Basic = createStory(Sidebar);
|
|
1
|
+
import Sidebar from './sidebar.vue';
|
|
2
|
+
import { createStory } from '../../__storybook__';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
component: Sidebar,
|
|
6
|
+
title: 'Examples/Cards/Sidebar'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Basic = createStory(Sidebar);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Modal from './modal.vue';
|
|
2
|
-
import { createStory } from '../../__storybook__';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
component: Modal,
|
|
6
|
-
title: 'Examples/Modals'
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const Basic = createStory(Modal);
|
|
1
|
+
import Modal from './modal.vue';
|
|
2
|
+
import { createStory } from '../../__storybook__';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
component: Modal,
|
|
6
|
+
title: 'Examples/Modals'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Basic = createStory(Modal);
|
package/src/types/props.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
2
|
-
|
|
3
|
-
export type Color =
|
|
4
|
-
| 'white'
|
|
5
|
-
| 'black'
|
|
6
|
-
| 'blue'
|
|
7
|
-
| 'green'
|
|
8
|
-
| 'red'
|
|
9
|
-
| 'yellow'
|
|
10
|
-
| 'gray';
|
|
11
|
-
|
|
12
|
-
export type Variant =
|
|
13
|
-
| 'default'
|
|
14
|
-
| 'tertiary'
|
|
15
|
-
| 'primary'
|
|
16
|
-
| 'dark'
|
|
17
|
-
| 'success'
|
|
18
|
-
| 'warning'
|
|
19
|
-
| 'error';
|
|
20
|
-
|
|
21
|
-
export type MaybeArray<T> = T | T[];
|
|
1
|
+
export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
2
|
+
|
|
3
|
+
export type Color =
|
|
4
|
+
| 'white'
|
|
5
|
+
| 'black'
|
|
6
|
+
| 'blue'
|
|
7
|
+
| 'green'
|
|
8
|
+
| 'red'
|
|
9
|
+
| 'yellow'
|
|
10
|
+
| 'gray';
|
|
11
|
+
|
|
12
|
+
export type Variant =
|
|
13
|
+
| 'default'
|
|
14
|
+
| 'tertiary'
|
|
15
|
+
| 'primary'
|
|
16
|
+
| 'dark'
|
|
17
|
+
| 'success'
|
|
18
|
+
| 'warning'
|
|
19
|
+
| 'error';
|
|
20
|
+
|
|
21
|
+
export type MaybeArray<T> = T | T[];
|
package/src/utils/call.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
type AnyFunction = (...args: any[]) => any
|
|
2
|
-
|
|
3
|
-
function call(funcs: MaybeArray<() => void>): void
|
|
4
|
-
function call<A1>(funcs: MaybeArray<(a1: A1) => void>, a1: A1): void
|
|
5
|
-
function call<A1, A2>(
|
|
6
|
-
funcs: MaybeArray<(a1: A1, a2: A2) => void>,
|
|
7
|
-
a1: A1,
|
|
8
|
-
a2: A2
|
|
9
|
-
): void
|
|
10
|
-
function call<A1, A2, A3>(
|
|
11
|
-
funcs: MaybeArray<(a1: A1, a2: A2, a3: A3) => void>,
|
|
12
|
-
a1: A1,
|
|
13
|
-
a2: A2,
|
|
14
|
-
a3: A3
|
|
15
|
-
): void
|
|
16
|
-
function call<A1, A2, A3, A4>(
|
|
17
|
-
funcs: MaybeArray<(a1: A1, a2: A2, a3: A3, a4: A4) => void>,
|
|
18
|
-
a1: A1,
|
|
19
|
-
a2: A2,
|
|
20
|
-
a3: A3,
|
|
21
|
-
a4: A4
|
|
22
|
-
): void
|
|
23
|
-
function call<A extends any[]>(
|
|
24
|
-
funcs: AnyFunction[] | AnyFunction,
|
|
25
|
-
...args: A
|
|
26
|
-
): void {
|
|
27
|
-
if (Array.isArray(funcs)) {
|
|
28
|
-
funcs.forEach((func) => (call as any)(func, ...args))
|
|
29
|
-
} else return funcs(...args)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { call }
|
|
33
|
-
|
|
34
|
-
export type MaybeArray<T> = T | T[]
|
|
1
|
+
type AnyFunction = (...args: any[]) => any
|
|
2
|
+
|
|
3
|
+
function call(funcs: MaybeArray<() => void>): void
|
|
4
|
+
function call<A1>(funcs: MaybeArray<(a1: A1) => void>, a1: A1): void
|
|
5
|
+
function call<A1, A2>(
|
|
6
|
+
funcs: MaybeArray<(a1: A1, a2: A2) => void>,
|
|
7
|
+
a1: A1,
|
|
8
|
+
a2: A2
|
|
9
|
+
): void
|
|
10
|
+
function call<A1, A2, A3>(
|
|
11
|
+
funcs: MaybeArray<(a1: A1, a2: A2, a3: A3) => void>,
|
|
12
|
+
a1: A1,
|
|
13
|
+
a2: A2,
|
|
14
|
+
a3: A3
|
|
15
|
+
): void
|
|
16
|
+
function call<A1, A2, A3, A4>(
|
|
17
|
+
funcs: MaybeArray<(a1: A1, a2: A2, a3: A3, a4: A4) => void>,
|
|
18
|
+
a1: A1,
|
|
19
|
+
a2: A2,
|
|
20
|
+
a3: A3,
|
|
21
|
+
a4: A4
|
|
22
|
+
): void
|
|
23
|
+
function call<A extends any[]>(
|
|
24
|
+
funcs: AnyFunction[] | AnyFunction,
|
|
25
|
+
...args: A
|
|
26
|
+
): void {
|
|
27
|
+
if (Array.isArray(funcs)) {
|
|
28
|
+
funcs.forEach((func) => (call as any)(func, ...args))
|
|
29
|
+
} else return funcs(...args)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { call }
|
|
33
|
+
|
|
34
|
+
export type MaybeArray<T> = T | T[]
|
package/src/utils/injection.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { type InjectionKey, inject, provide } from 'vue';
|
|
2
|
-
|
|
3
|
-
export function createInjectionKey<T>(key: string): InjectionKey<T> {
|
|
4
|
-
return key as any;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function createContext<ContextValue>(
|
|
8
|
-
providerComponentName: string | string[],
|
|
9
|
-
contextName?: string,
|
|
10
|
-
) {
|
|
11
|
-
const symbolDescription
|
|
12
|
-
= typeof providerComponentName === 'string' && !contextName
|
|
13
|
-
? `${providerComponentName}Context`
|
|
14
|
-
: contextName
|
|
15
|
-
|
|
16
|
-
const injectionKey: InjectionKey<ContextValue | null> = Symbol(symbolDescription)
|
|
17
|
-
const injectContext = <
|
|
18
|
-
T extends ContextValue | null | undefined = ContextValue,
|
|
19
|
-
>(
|
|
20
|
-
fallback?: T,
|
|
21
|
-
): T extends null ? ContextValue | null : ContextValue => {
|
|
22
|
-
const context = inject(injectionKey, fallback)
|
|
23
|
-
if (context)
|
|
24
|
-
return context
|
|
25
|
-
|
|
26
|
-
if (context === null)
|
|
27
|
-
return context as any
|
|
28
|
-
|
|
29
|
-
throw new Error(
|
|
30
|
-
`Injection \`${injectionKey.toString()}\` not found. Component must be used within ${Array.isArray(providerComponentName)
|
|
31
|
-
? `one of the following components: ${providerComponentName.join(
|
|
32
|
-
', ',
|
|
33
|
-
)}`
|
|
34
|
-
: `\`${providerComponentName}\``
|
|
35
|
-
}`,
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const provideContext = (contextValue: ContextValue) => {
|
|
40
|
-
provide(injectionKey, contextValue)
|
|
41
|
-
return contextValue
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return [injectContext, provideContext] as const
|
|
45
|
-
}
|
|
1
|
+
import { type InjectionKey, inject, provide } from 'vue';
|
|
2
|
+
|
|
3
|
+
export function createInjectionKey<T>(key: string): InjectionKey<T> {
|
|
4
|
+
return key as any;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function createContext<ContextValue>(
|
|
8
|
+
providerComponentName: string | string[],
|
|
9
|
+
contextName?: string,
|
|
10
|
+
) {
|
|
11
|
+
const symbolDescription
|
|
12
|
+
= typeof providerComponentName === 'string' && !contextName
|
|
13
|
+
? `${providerComponentName}Context`
|
|
14
|
+
: contextName
|
|
15
|
+
|
|
16
|
+
const injectionKey: InjectionKey<ContextValue | null> = Symbol(symbolDescription)
|
|
17
|
+
const injectContext = <
|
|
18
|
+
T extends ContextValue | null | undefined = ContextValue,
|
|
19
|
+
>(
|
|
20
|
+
fallback?: T,
|
|
21
|
+
): T extends null ? ContextValue | null : ContextValue => {
|
|
22
|
+
const context = inject(injectionKey, fallback)
|
|
23
|
+
if (context)
|
|
24
|
+
return context
|
|
25
|
+
|
|
26
|
+
if (context === null)
|
|
27
|
+
return context as any
|
|
28
|
+
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Injection \`${injectionKey.toString()}\` not found. Component must be used within ${Array.isArray(providerComponentName)
|
|
31
|
+
? `one of the following components: ${providerComponentName.join(
|
|
32
|
+
', ',
|
|
33
|
+
)}`
|
|
34
|
+
: `\`${providerComponentName}\``
|
|
35
|
+
}`,
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const provideContext = (contextValue: ContextValue) => {
|
|
40
|
+
provide(injectionKey, contextValue)
|
|
41
|
+
return contextValue
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return [injectContext, provideContext] as const
|
|
45
|
+
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
.m-tab-group {
|
|
2
|
-
--tabs-gap: 14px;
|
|
3
|
-
--tabs-background: transparent;
|
|
4
|
-
--tabs-border-radius: 0;
|
|
5
|
-
--tabs-padding: 0;
|
|
6
|
-
--tabs-border: 1px solid var(--gray-200);
|
|
7
|
-
|
|
8
|
-
--tab-background: var(transparent);
|
|
9
|
-
--tab-color: var(--gray-600);
|
|
10
|
-
--tab-font-size: 15px;
|
|
11
|
-
--tab-padding: 12px 8px;
|
|
12
|
-
--tab-border-radius: 0px;
|
|
13
|
-
--tab-font-weight: 500;
|
|
14
|
-
--tab-box-shadow: none;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.m-tab-group__tabs {
|
|
18
|
-
background: var(--tabs-background);
|
|
19
|
-
border-radius: var(--tabs-border-radius);
|
|
20
|
-
position: relative;
|
|
21
|
-
border-bottom: var(--tabs-border);
|
|
22
|
-
display: flex;
|
|
23
|
-
min-width: 100%;
|
|
24
|
-
width: fit-content;
|
|
25
|
-
list-style: none;
|
|
26
|
-
padding: var(--tabs-padding);
|
|
27
|
-
margin: 0;
|
|
28
|
-
gap: var(--tabs-gap);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.m-tab-group__tabs .m-tab {
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.m-tab-group__tabs .m-tab .m-tabs__button {
|
|
36
|
-
display: flex;
|
|
37
|
-
align-items: center;
|
|
38
|
-
justify-content: center;
|
|
39
|
-
font-size: var(--tab-font-size);
|
|
40
|
-
font-weight: var(--tab-font-weight);
|
|
41
|
-
color: var(--tab-color);
|
|
42
|
-
background-color: var(--tab-background);
|
|
43
|
-
padding: var(--tab-padding);
|
|
44
|
-
border-radius: var(--tab-border-radius);
|
|
45
|
-
box-shadow: var(--tab-box-shadow);
|
|
46
|
-
cursor: pointer;
|
|
47
|
-
transition: all 0.2s ease-in-out;
|
|
48
|
-
border: none;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.m-tab-group__tabs .m-tab:not(.m-tab--disabled) .m-tabs__button:hover {
|
|
52
|
-
--tab-background: var(transparent);
|
|
53
|
-
--tab-color: var(--blue);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.m-tab-group__tabs .m-tab.m-tab--active .m-tabs__button {
|
|
57
|
-
--tab-background: var(--white);
|
|
58
|
-
--tab-color: var(--blue);
|
|
59
|
-
--tab-box-shadow: inset 0px -2px 0px var(--blue);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.m-tab-group__tabs .m-tab.m-tab--disabled .m-tabs__button {
|
|
63
|
-
--tab-color: var(--gray-400);
|
|
64
|
-
cursor: not-allowed;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.m-tab-group.m-tab-group--xs {
|
|
68
|
-
--tabs-background: transparent;
|
|
69
|
-
--tabs-border-radius: 0;
|
|
70
|
-
--tabs-padding: 0;
|
|
71
|
-
--tabs-gap: 8px;
|
|
72
|
-
|
|
73
|
-
--tab-font-size: 12px;
|
|
74
|
-
--tab-padding: 10px 6px;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.m-tab-group.m-tab-group--sm {
|
|
78
|
-
--tabs-background: transparent;
|
|
79
|
-
--tabs-border-radius: 0;
|
|
80
|
-
--tabs-padding: 0;
|
|
81
|
-
--tabs-gap: 10px;
|
|
82
|
-
|
|
83
|
-
--tab-font-size: 13px;
|
|
84
|
-
--tab-padding: 13px 6px;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.m-tab-group.m-tab-group--lg {
|
|
88
|
-
--tabs-background: transparent;
|
|
89
|
-
--tabs-border-radius: 0;
|
|
90
|
-
--tabs-padding: 0;
|
|
91
|
-
|
|
92
|
-
--tab-font-size: 16px;
|
|
93
|
-
--tab-padding: 20px 12px;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.m-tab-group.m-tab-group--xl {
|
|
97
|
-
--tabs-background: transparent;
|
|
98
|
-
--tabs-border-radius: 0;
|
|
99
|
-
--tabs-padding: 0;
|
|
100
|
-
|
|
101
|
-
--tab-font-size: 18px;
|
|
102
|
-
--tab-padding: 24px 16px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.m-tab-group.m-tab-group--vertical {
|
|
106
|
-
flex-direction: column;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.m-tab-group.m-tab-group--vertical .m-tab-group__tabs {
|
|
110
|
-
flex-direction: column;
|
|
111
|
-
gap: 0;
|
|
112
|
-
width: 200px;
|
|
113
|
-
}
|