adata-ui 4.0.19 → 4.0.21
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/dist/module.json +1 -1
- package/dist/runtime/components/DigitBadge.vue +57 -0
- package/dist/runtime/components/DigitBadge.vue.d.ts +21 -0
- package/dist/runtime/components/Header.vue +3 -2
- package/dist/runtime/components/accordion/Accordion.vue +149 -0
- package/dist/runtime/components/accordion/Accordion.vue.d.ts +41 -0
- package/dist/runtime/components/accordion/types.d.ts +15 -0
- package/dist/runtime/components/accordion/types.js +0 -0
- package/dist/runtime/components/accordion/ui.config.d.ts +22 -0
- package/dist/runtime/components/accordion/ui.config.js +21 -0
- package/dist/runtime/components/checkbox/Checkbox.vue +123 -0
- package/dist/runtime/components/checkbox/Checkbox.vue.d.ts +45 -0
- package/dist/runtime/components/forms/input/standard/InputStandard.vue +300 -0
- package/dist/runtime/components/forms/input/standard/InputStandard.vue.d.ts +0 -0
- package/dist/runtime/components/forms/input/textarea/ATextarea.vue +157 -0
- package/dist/runtime/components/forms/input/textarea/ATextarea.vue.d.ts +43 -0
- package/dist/runtime/components/forms/request-demo/RequestDemo.vue +67 -0
- package/dist/runtime/components/forms/request-demo/RequestDemo.vue.d.ts +23 -0
- package/dist/runtime/components/header/AlmatyContacts.vue +2 -1
- package/dist/runtime/components/header/ContactMenu.vue +47 -6
- package/dist/runtime/components/header/ProductMenu.vue +36 -0
- package/dist/runtime/components/header/TopHeader.vue +1 -1
- package/dist/runtime/components/pill-tabs/PillTabs.vue +134 -0
- package/dist/runtime/components/pill-tabs/PillTabs.vue.d.ts +37 -0
- package/dist/runtime/components/pill-tabs/types.d.ts +18 -0
- package/dist/runtime/components/pill-tabs/types.js +0 -0
- package/dist/runtime/components/radio-button/RadioButton.vue +75 -0
- package/dist/runtime/components/radio-button/RadioButton.vue.d.ts +33 -0
- package/dist/runtime/composables/projectState.d.ts +1 -0
- package/dist/runtime/composables/projectState.js +1 -0
- package/dist/runtime/i18n.d.ts +1 -1
- package/dist/runtime/icons/checkbox/checkbox-active.vue +19 -0
- package/dist/runtime/icons/checkbox/checkbox-active.vue.d.ts +2 -0
- package/dist/runtime/icons/checkbox/checkbox-empty.vue +20 -0
- package/dist/runtime/icons/checkbox/checkbox-empty.vue.d.ts +2 -0
- package/dist/runtime/icons/checkbox/checkbox-intermediate.vue +19 -0
- package/dist/runtime/icons/checkbox/checkbox-intermediate.vue.d.ts +2 -0
- package/dist/runtime/icons/radio/radio-check.vue +24 -0
- package/dist/runtime/icons/radio/radio-check.vue.d.ts +2 -0
- package/dist/runtime/icons/radio/radio-empty.vue +20 -0
- package/dist/runtime/icons/radio/radio-empty.vue.d.ts +2 -0
- package/package.json +3 -1
package/dist/module.json
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
defineOptions({ name: "ADigitBadge" });
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
type: { type: String, required: false, default: "primary" },
|
|
6
|
+
view: { type: String, required: false, default: "default" },
|
|
7
|
+
size: { type: String, required: false, default: "lg" },
|
|
8
|
+
value: { type: [String, Number], required: true },
|
|
9
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
10
|
+
customClasses: { type: String, required: false, default: "" },
|
|
11
|
+
prefix: { type: String, required: false, default: "" }
|
|
12
|
+
});
|
|
13
|
+
const formattedValue = computed(() => {
|
|
14
|
+
return Number(props.value).toLocaleString("ru-RU");
|
|
15
|
+
});
|
|
16
|
+
const classes = computed(() => [
|
|
17
|
+
props.disabled ? "text-gray-500 bg-deepblue-900/5" : typeSwitchValues[props.view][props.type],
|
|
18
|
+
"inline-flex items-center justify-center font-medium rounded-full select-none inline-flex outline-none",
|
|
19
|
+
sizeSwitchValues[props.size],
|
|
20
|
+
props.value && props.value.toString().length > 2 ? "w-auto" : ""
|
|
21
|
+
]);
|
|
22
|
+
const typeSwitchValues = {
|
|
23
|
+
default: {
|
|
24
|
+
primary: "bg-blue-700 text-white dark:bg-blue-500 dark:text-gray-900",
|
|
25
|
+
success: "bg-green-500 text-white dark:bg-green-400 dark:text-gray-900",
|
|
26
|
+
danger: "bg-red-500 text-white dark:bg-red-400 dark:text-gray-900",
|
|
27
|
+
warning: "bg-yellow-400 text-white dark:text-gray-900",
|
|
28
|
+
gray: "bg-gray-50 text-gray-500 dark:text-gray-900",
|
|
29
|
+
orange: "bg-orange-600 text-white dark:bg-orange-500 dark:text-gray-900"
|
|
30
|
+
},
|
|
31
|
+
inverted: {
|
|
32
|
+
primary: "bg-white text-blue-700 dark:text-blue-500 dark:bg-gray-900",
|
|
33
|
+
success: "bg-white text-green-500 dark:text-green-400 dark:bg-gray-900",
|
|
34
|
+
danger: "bg-white text-red-500 dark:text-red-400 dark:bg-gray-900",
|
|
35
|
+
warning: "bg-white text-yellow-400 dark:bg-gray-900",
|
|
36
|
+
gray: "bg-white text-gray-500 dark:text-gray-200 dark:bg-gray-200/10",
|
|
37
|
+
orange: "bg-white text-deepblue-900 dark:text-orange-500 dark:bg-gray-900"
|
|
38
|
+
},
|
|
39
|
+
transparent: {
|
|
40
|
+
success: "bg-green-500/20 text-green-500",
|
|
41
|
+
danger: "bg-red-500/20 text-red-500 dark:text-red-400"
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const sizeSwitchValues = {
|
|
45
|
+
sm: "w-4 h-4 px-1 text-[9.5px]",
|
|
46
|
+
md: "w-5 h-5 px-1 text-[10px]",
|
|
47
|
+
lg: "px-2 w-6 h-6 text-xs font-semibold"
|
|
48
|
+
};
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<div
|
|
53
|
+
:class="twMerge(...classes, customClasses)"
|
|
54
|
+
>
|
|
55
|
+
{{ prefix }}{{ formattedValue }}
|
|
56
|
+
</div>
|
|
57
|
+
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
type?: 'primary' | 'success' | 'danger' | 'gray' | 'orange' | 'warning';
|
|
3
|
+
view?: 'default' | 'inverted';
|
|
4
|
+
size?: 'sm' | 'md' | 'lg';
|
|
5
|
+
value: string | number;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
customClasses?: string;
|
|
8
|
+
prefix?: string;
|
|
9
|
+
}
|
|
10
|
+
export type StateType = {
|
|
11
|
+
[key in 'primary' | 'success' | 'danger' | 'gray' | 'orange' | 'warning']?: string;
|
|
12
|
+
};
|
|
13
|
+
declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
14
|
+
size: "sm" | "md" | "lg";
|
|
15
|
+
type: "primary" | "success" | "danger" | "gray" | "orange" | "warning";
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
view: "default" | "inverted";
|
|
18
|
+
customClasses: string;
|
|
19
|
+
prefix: string;
|
|
20
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
export default _default;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { useContacts } from "../composables/projectState";
|
|
2
3
|
import TopHeader from "./header/TopHeader.vue";
|
|
3
4
|
import HeaderLink from "./header/HeaderLink.vue";
|
|
4
5
|
import ProfileMenu from "./header/ProfileMenu.vue";
|
|
@@ -26,7 +27,7 @@ const { t } = useI18n();
|
|
|
26
27
|
const appConfig = useAppConfig();
|
|
27
28
|
const mode = appConfig.adataUI.mode;
|
|
28
29
|
const langIsOn = false;
|
|
29
|
-
const contacts = ref(
|
|
30
|
+
const contacts = ref(useContacts());
|
|
30
31
|
const goAuth = () => {
|
|
31
32
|
if (window) {
|
|
32
33
|
emit("login");
|
|
@@ -43,7 +44,7 @@ const goToAnotherModule = () => {
|
|
|
43
44
|
const fetchContacts = async () => {
|
|
44
45
|
try {
|
|
45
46
|
const response = await fetch(
|
|
46
|
-
`https://pk-api
|
|
47
|
+
`https://pk-api.adata.kz/api/v1/data/counterparty/contacts/sales-department`
|
|
47
48
|
);
|
|
48
49
|
const { data } = await response.json();
|
|
49
50
|
contacts.value = data;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { twJoin, twMerge } from "tailwind-merge";
|
|
3
|
+
import { AccordionContent, AccordionHeader, AccordionItem, AccordionRoot, AccordionTrigger } from "reka-ui";
|
|
4
|
+
import ui from "./ui.config";
|
|
5
|
+
import { ref, onMounted, onBeforeUnmount, watch, computed, useAttrs } from "#imports";
|
|
6
|
+
defineOptions({
|
|
7
|
+
inheritAttrs: false
|
|
8
|
+
});
|
|
9
|
+
const attrs = useAttrs();
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
label: { type: String, required: true },
|
|
12
|
+
content: { type: null, required: false },
|
|
13
|
+
defaultOpen: { type: Boolean, required: false, default: false },
|
|
14
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
15
|
+
size: { type: String, required: false, default: "md" },
|
|
16
|
+
color: { type: String, required: false, default: "gray" },
|
|
17
|
+
slot: { type: String, required: false, default: void 0 },
|
|
18
|
+
divider: { type: Boolean, required: false, default: false },
|
|
19
|
+
contentClass: { type: String, required: false },
|
|
20
|
+
bodyClass: { type: String, required: false },
|
|
21
|
+
activateOpenBg: { type: Boolean, required: false }
|
|
22
|
+
});
|
|
23
|
+
const emit = defineEmits(["toggle", "open", "close"]);
|
|
24
|
+
const buttonClass = computed(() => twMerge(twJoin(ui.item.color[props.color], ui.ring, ui.item.button, ui.item.size[props.size])));
|
|
25
|
+
const contClass = computed(() => twMerge(twJoin(ui.item.content, props.contentClass)));
|
|
26
|
+
const bodyClassCompute = computed(() => twMerge(twJoin(ui.item.accordion, props.activateOpenBg ? isOpen.value && props.bodyClass : props.bodyClass)));
|
|
27
|
+
const accordion = ref();
|
|
28
|
+
const isOpen = ref();
|
|
29
|
+
function updateState() {
|
|
30
|
+
if (accordion.value) {
|
|
31
|
+
const state = accordion.value?.$el.getAttribute("data-state");
|
|
32
|
+
isOpen.value = state === "open";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
onMounted(() => {
|
|
36
|
+
if (accordion.value) {
|
|
37
|
+
updateState();
|
|
38
|
+
const observer = new MutationObserver(() => {
|
|
39
|
+
updateState();
|
|
40
|
+
});
|
|
41
|
+
observer.observe(accordion.value?.$el, {
|
|
42
|
+
attributes: true,
|
|
43
|
+
attributeFilter: ["data-state"]
|
|
44
|
+
});
|
|
45
|
+
onBeforeUnmount(() => {
|
|
46
|
+
observer.disconnect();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
function emulateButtonClick() {
|
|
51
|
+
if (accordion.value) {
|
|
52
|
+
accordion.value?.$el.click();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const handelOpen = () => {
|
|
56
|
+
if (!isOpen.value) {
|
|
57
|
+
emulateButtonClick();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const handelClose = () => {
|
|
61
|
+
if (isOpen.value) {
|
|
62
|
+
emulateButtonClick();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
watch(isOpen, () => {
|
|
66
|
+
emit("toggle", isOpen.value);
|
|
67
|
+
isOpen.value ? emit("open") : emit("close");
|
|
68
|
+
});
|
|
69
|
+
defineExpose({
|
|
70
|
+
ontoggle: emulateButtonClick,
|
|
71
|
+
handelOpen,
|
|
72
|
+
handelClose
|
|
73
|
+
});
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<accordion-root
|
|
78
|
+
type="single"
|
|
79
|
+
:disabled="disabled"
|
|
80
|
+
collapsible
|
|
81
|
+
:default-value="defaultOpen ? 'accordion' : ''"
|
|
82
|
+
v-bind="attrs"
|
|
83
|
+
>
|
|
84
|
+
<accordion-item
|
|
85
|
+
value="accordion"
|
|
86
|
+
:class="bodyClassCompute"
|
|
87
|
+
>
|
|
88
|
+
<accordion-header class="w-full">
|
|
89
|
+
<accordion-trigger
|
|
90
|
+
ref="accordion"
|
|
91
|
+
class="w-full"
|
|
92
|
+
>
|
|
93
|
+
<slot name="head">
|
|
94
|
+
<button :class="buttonClass">
|
|
95
|
+
<span :class="size === 'md' ? 'text-sm' : 'text-base'">{{ label }}</span>
|
|
96
|
+
<slot name="additional" />
|
|
97
|
+
<i-arrow-chevron-down
|
|
98
|
+
:arrow-attrs="{ class: 'stroke-deepblue-900' }"
|
|
99
|
+
:class="[{ 'rotate-180': isOpen }, 'max-h-[16px] min-h-[16px] min-w-[16px] max-w-[16px]', ui.item.icon]"
|
|
100
|
+
/>
|
|
101
|
+
</button>
|
|
102
|
+
</slot>
|
|
103
|
+
</accordion-trigger>
|
|
104
|
+
</accordion-header>
|
|
105
|
+
<slot name="closedToShow" />
|
|
106
|
+
<accordion-content class="AccordionContent">
|
|
107
|
+
<div :class="[contClass, { 'mt-4 border-t': divider }]">
|
|
108
|
+
<slot
|
|
109
|
+
:name="slot || 'default'"
|
|
110
|
+
:content="content"
|
|
111
|
+
>
|
|
112
|
+
{{ content }}
|
|
113
|
+
</slot>
|
|
114
|
+
</div>
|
|
115
|
+
</accordion-content>
|
|
116
|
+
</accordion-item>
|
|
117
|
+
</accordion-root>
|
|
118
|
+
</template>
|
|
119
|
+
|
|
120
|
+
<style scoped>
|
|
121
|
+
.AccordionContent {
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.AccordionContent[data-state=open] {
|
|
126
|
+
animation: slideDown 200ms ease-out;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.AccordionContent[data-state=closed] {
|
|
130
|
+
animation: slideUp 200ms ease-out;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@keyframes slideDown {
|
|
134
|
+
from {
|
|
135
|
+
height: 0;
|
|
136
|
+
}
|
|
137
|
+
to {
|
|
138
|
+
height: var(--reka-accordion-content-height);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
@keyframes slideUp {
|
|
142
|
+
from {
|
|
143
|
+
height: var(--reka-accordion-content-height);
|
|
144
|
+
}
|
|
145
|
+
to {
|
|
146
|
+
height: 0;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Props } from './types.js';
|
|
2
|
+
declare function emulateButtonClick(): void;
|
|
3
|
+
declare var __VLS_20: {}, __VLS_22: {}, __VLS_28: {}, __VLS_35: any, __VLS_36: {
|
|
4
|
+
content: any;
|
|
5
|
+
};
|
|
6
|
+
type __VLS_Slots = {} & {
|
|
7
|
+
[K in NonNullable<typeof __VLS_35>]?: (props: typeof __VLS_36) => any;
|
|
8
|
+
} & {
|
|
9
|
+
head?: (props: typeof __VLS_20) => any;
|
|
10
|
+
} & {
|
|
11
|
+
additional?: (props: typeof __VLS_22) => any;
|
|
12
|
+
} & {
|
|
13
|
+
closedToShow?: (props: typeof __VLS_28) => any;
|
|
14
|
+
};
|
|
15
|
+
declare const __VLS_component: import("vue").DefineComponent<Props, {
|
|
16
|
+
ontoggle: typeof emulateButtonClick;
|
|
17
|
+
handelOpen: () => void;
|
|
18
|
+
handelClose: () => void;
|
|
19
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
20
|
+
close: () => any;
|
|
21
|
+
toggle: (isOpen: boolean) => any;
|
|
22
|
+
open: () => any;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
24
|
+
onClose?: (() => any) | undefined;
|
|
25
|
+
onToggle?: ((isOpen: boolean) => any) | undefined;
|
|
26
|
+
onOpen?: (() => any) | undefined;
|
|
27
|
+
}>, {
|
|
28
|
+
size: import("./types.js").Size;
|
|
29
|
+
color: import("./types.js").Color;
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
defaultOpen: boolean;
|
|
32
|
+
slot: string;
|
|
33
|
+
divider: boolean;
|
|
34
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
36
|
+
export default _default;
|
|
37
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
38
|
+
new (): {
|
|
39
|
+
$slots: S;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Size = 'md' | 'lg';
|
|
2
|
+
export type Color = 'gray';
|
|
3
|
+
export interface Props {
|
|
4
|
+
label: string;
|
|
5
|
+
content?: any;
|
|
6
|
+
defaultOpen?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
size?: Size;
|
|
9
|
+
color?: Color;
|
|
10
|
+
slot?: string;
|
|
11
|
+
divider?: boolean;
|
|
12
|
+
contentClass?: string;
|
|
13
|
+
bodyClass?: string;
|
|
14
|
+
activateOpenBg?: boolean;
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
wrapper: string;
|
|
3
|
+
ring: string;
|
|
4
|
+
item: {
|
|
5
|
+
size: {
|
|
6
|
+
md: string;
|
|
7
|
+
lg: string;
|
|
8
|
+
};
|
|
9
|
+
color: {
|
|
10
|
+
gray: string;
|
|
11
|
+
};
|
|
12
|
+
icon: string;
|
|
13
|
+
accordion: string;
|
|
14
|
+
content: string;
|
|
15
|
+
button: string;
|
|
16
|
+
};
|
|
17
|
+
transition: {
|
|
18
|
+
enterActiveClass: string;
|
|
19
|
+
leaveActiveClass: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
wrapper: "w-full flex flex-col",
|
|
3
|
+
ring: "focus-visible:ring-2 focus-visible:ring-blue-500 dark:focus-visible:ring-blue-400 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-gray-900",
|
|
4
|
+
item: {
|
|
5
|
+
size: {
|
|
6
|
+
md: "text-md ",
|
|
7
|
+
lg: "text-xl"
|
|
8
|
+
},
|
|
9
|
+
color: {
|
|
10
|
+
gray: "text-deepblue-900 dark:text-gray-200"
|
|
11
|
+
},
|
|
12
|
+
icon: "ms-auto transform transition-transform duration-200",
|
|
13
|
+
accordion: "p-4 rounded bg-white dark:bg-gray-900 transition-colors",
|
|
14
|
+
content: "",
|
|
15
|
+
button: "flex justify-between gap-1 grow w-full items-center text-sm font-semibold text-start"
|
|
16
|
+
},
|
|
17
|
+
transition: {
|
|
18
|
+
enterActiveClass: "overflow-hidden transition-[height] duration-200 ease-out",
|
|
19
|
+
leaveActiveClass: "overflow-hidden transition-[height] duration-200 ease-out"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
defineOptions({ name: "ACheckbox" });
|
|
4
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
size: { type: String, required: false, default: "sm" },
|
|
7
|
+
name: { type: String, required: false, default: "check" },
|
|
8
|
+
modelValue: { type: [String, Number, Array, Object, Boolean, null], required: true, default: () => [] },
|
|
9
|
+
value: { type: [String, Number, Object, null], required: false, default: null },
|
|
10
|
+
intermediate: { type: Boolean, required: false },
|
|
11
|
+
disabled: { type: Boolean, required: false },
|
|
12
|
+
side: { type: [String, null], required: false, default: "left" },
|
|
13
|
+
masterControl: { type: Boolean, required: false, default: false },
|
|
14
|
+
emptyCheckboxClass: { type: String, required: false, default: "" },
|
|
15
|
+
intermediateCheckboxClass: { type: String, required: false, default: "" },
|
|
16
|
+
alwaysIntermediate: { type: Boolean, required: false, default: false },
|
|
17
|
+
checkboxClass: { type: String, required: false, default: "" },
|
|
18
|
+
labelClass: { type: String, required: false, default: "" },
|
|
19
|
+
viewType: { type: String, required: false, default: "checkbox" }
|
|
20
|
+
});
|
|
21
|
+
const slots = useSlots();
|
|
22
|
+
const isChecked = computed(() => {
|
|
23
|
+
if (props.modelValue instanceof Array) {
|
|
24
|
+
return props.modelValue.includes(props.value);
|
|
25
|
+
}
|
|
26
|
+
return props.modelValue === true;
|
|
27
|
+
});
|
|
28
|
+
const isIntermediate = computed(() => {
|
|
29
|
+
if (props.alwaysIntermediate) {
|
|
30
|
+
return props.intermediate;
|
|
31
|
+
} else {
|
|
32
|
+
return isChecked.value && props.intermediate;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const updateInput = (e) => {
|
|
36
|
+
const isChecked2 = e.target.checked;
|
|
37
|
+
if (props.masterControl) {
|
|
38
|
+
emit("update:modelValue", isChecked2);
|
|
39
|
+
} else if (props.modelValue instanceof Array) {
|
|
40
|
+
const newValue = [...props.modelValue];
|
|
41
|
+
if (isChecked2) {
|
|
42
|
+
newValue.push(props.value);
|
|
43
|
+
} else {
|
|
44
|
+
newValue.splice(newValue.indexOf(props.value), 1);
|
|
45
|
+
}
|
|
46
|
+
emit("update:modelValue", newValue);
|
|
47
|
+
} else {
|
|
48
|
+
emit("update:modelValue", !!isChecked2);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const sizeOptions = {
|
|
52
|
+
lg: "min-w-6 min-h-6 max-w-6 max-h-6",
|
|
53
|
+
sm: "min-w-4 min-h-4 max-w-4 max-h-4"
|
|
54
|
+
};
|
|
55
|
+
const textSizeOptions = {
|
|
56
|
+
lg: "text-sm gap-2.5",
|
|
57
|
+
sm: "text-xs gap-2"
|
|
58
|
+
};
|
|
59
|
+
const hasSlotContent = computed(() => {
|
|
60
|
+
return !!slots.default?.().length;
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<template>
|
|
65
|
+
<div
|
|
66
|
+
class="flex items-center"
|
|
67
|
+
:class="[disabled ? 'opacity-20' : '']"
|
|
68
|
+
>
|
|
69
|
+
<input
|
|
70
|
+
:id="name"
|
|
71
|
+
type="checkbox"
|
|
72
|
+
class="hidden"
|
|
73
|
+
:checked="isChecked"
|
|
74
|
+
:disabled="disabled"
|
|
75
|
+
:value="value"
|
|
76
|
+
@change="updateInput"
|
|
77
|
+
>
|
|
78
|
+
<label
|
|
79
|
+
v-if="viewType === 'checkbox'"
|
|
80
|
+
:for="name"
|
|
81
|
+
class="flex items-center text-deepblue-900 dark:text-gray-200"
|
|
82
|
+
:class="twMerge(textSizeOptions[size], disabled ? 'cursor-default' : 'cursor-pointer', labelClass)"
|
|
83
|
+
>
|
|
84
|
+
<span
|
|
85
|
+
v-if="side === 'left' && hasSlotContent"
|
|
86
|
+
class="select-none"
|
|
87
|
+
>
|
|
88
|
+
<slot />
|
|
89
|
+
</span>
|
|
90
|
+
<span :class="[sizeOptions[size]]">
|
|
91
|
+
<i-checkbox-intermediate
|
|
92
|
+
v-if="isIntermediate"
|
|
93
|
+
class="w-full h-full"
|
|
94
|
+
:class="twMerge('text-blue-700 dark:text-blue-500', intermediateCheckboxClass)"
|
|
95
|
+
/>
|
|
96
|
+
<i-checkbox-active
|
|
97
|
+
v-else-if="isChecked"
|
|
98
|
+
class="w-full h-full"
|
|
99
|
+
:class="twMerge('text-blue-700 dark:text-blue-500', checkboxClass)"
|
|
100
|
+
/>
|
|
101
|
+
<i-checkbox-empty
|
|
102
|
+
v-else
|
|
103
|
+
class="w-full h-full"
|
|
104
|
+
:class="twMerge('text-deepblue-900 dark:text-gray-200', emptyCheckboxClass)"
|
|
105
|
+
/>
|
|
106
|
+
</span>
|
|
107
|
+
<span
|
|
108
|
+
v-if="side === 'right' && hasSlotContent"
|
|
109
|
+
class="select-none"
|
|
110
|
+
>
|
|
111
|
+
<slot />
|
|
112
|
+
</span>
|
|
113
|
+
</label>
|
|
114
|
+
<label
|
|
115
|
+
v-else-if="viewType === 'chip'"
|
|
116
|
+
:for="name"
|
|
117
|
+
class="px-[10px] py-[3.5px] text-deepblue-900 border border-gray-500 rounded-full dark:text-gray-200 text-xs"
|
|
118
|
+
:class="[{ 'bg-blue-700 text-white dark:bg-blue-500 dark:border-blue-500 dark:text-gray-900 font-medium': isChecked }]"
|
|
119
|
+
>
|
|
120
|
+
<slot />
|
|
121
|
+
</label>
|
|
122
|
+
</div>
|
|
123
|
+
</template>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
size?: 'lg' | 'sm';
|
|
3
|
+
name?: string;
|
|
4
|
+
modelValue: string | number | Array<any> | object | boolean | null;
|
|
5
|
+
value?: string | number | object | null;
|
|
6
|
+
intermediate?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
side?: 'right' | 'left' | null;
|
|
9
|
+
masterControl?: boolean;
|
|
10
|
+
emptyCheckboxClass?: string;
|
|
11
|
+
intermediateCheckboxClass?: string;
|
|
12
|
+
alwaysIntermediate?: boolean;
|
|
13
|
+
checkboxClass?: string;
|
|
14
|
+
labelClass?: string;
|
|
15
|
+
viewType?: 'checkbox' | 'chip';
|
|
16
|
+
}
|
|
17
|
+
declare var __VLS_1: {}, __VLS_15: {}, __VLS_17: {};
|
|
18
|
+
type __VLS_Slots = {} & {
|
|
19
|
+
default?: (props: typeof __VLS_1) => any;
|
|
20
|
+
} & {
|
|
21
|
+
default?: (props: typeof __VLS_15) => any;
|
|
22
|
+
} & {
|
|
23
|
+
default?: (props: typeof __VLS_17) => any;
|
|
24
|
+
};
|
|
25
|
+
declare const __VLS_component: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any, string, import("vue").PublicProps, any, {
|
|
26
|
+
name: string;
|
|
27
|
+
size: "lg" | "sm";
|
|
28
|
+
modelValue: string | number | Array<any> | object | boolean | null;
|
|
29
|
+
value: string | number | object | null;
|
|
30
|
+
side: "right" | "left" | null;
|
|
31
|
+
masterControl: boolean;
|
|
32
|
+
emptyCheckboxClass: string;
|
|
33
|
+
intermediateCheckboxClass: string;
|
|
34
|
+
alwaysIntermediate: boolean;
|
|
35
|
+
checkboxClass: string;
|
|
36
|
+
labelClass: string;
|
|
37
|
+
viewType: "checkbox" | "chip";
|
|
38
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
39
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
40
|
+
export default _default;
|
|
41
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
42
|
+
new (): {
|
|
43
|
+
$slots: S;
|
|
44
|
+
};
|
|
45
|
+
};
|