adata-ui 3.0.2 → 3.1.0
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.d.mts +2 -0
- package/dist/module.json +5 -1
- package/dist/module.mjs +39 -6
- package/dist/runtime/components/Alert.vue +62 -0
- package/dist/runtime/components/Alert.vue.d.ts +29 -0
- package/dist/runtime/components/Chip.vue +24 -0
- package/dist/runtime/components/Chip.vue.d.ts +19 -0
- package/dist/runtime/components/ColorMode.vue +46 -0
- package/dist/runtime/components/ColorMode.vue.d.ts +2 -0
- package/dist/runtime/components/DigitBadge.vue +58 -0
- package/dist/runtime/components/DigitBadge.vue.d.ts +21 -0
- package/dist/runtime/components/Footer.vue +283 -0
- package/dist/runtime/components/Footer.vue.d.ts +2 -0
- package/dist/runtime/components/FooterAccordion.vue +78 -0
- package/dist/runtime/components/FooterAccordion.vue.d.ts +11 -0
- package/dist/runtime/components/Header.vue +139 -0
- package/dist/runtime/components/Header.vue.d.ts +41 -0
- package/dist/runtime/components/NewFooter.vue +267 -0
- package/dist/runtime/components/NewFooter.vue.d.ts +2 -0
- package/dist/runtime/components/NewFooterAccordion.vue +85 -0
- package/dist/runtime/components/NewFooterAccordion.vue.d.ts +11 -0
- package/dist/runtime/components/OtherServiceFeatures.vue +104 -0
- package/dist/runtime/components/OtherServiceFeatures.vue.d.ts +2 -0
- package/dist/runtime/components/Tag.vue +46 -0
- package/dist/runtime/components/Tag.vue.d.ts +25 -0
- package/dist/runtime/components/Toggle.vue +139 -0
- package/dist/runtime/components/Toggle.vue.d.ts +39 -0
- 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/button/Button.vue +133 -0
- package/dist/runtime/components/button/Button.vue.d.ts +37 -0
- package/dist/runtime/components/button/types.d.ts +21 -0
- package/dist/runtime/components/button/types.js +0 -0
- package/dist/runtime/components/checkbox/Checkbox.vue +124 -0
- package/dist/runtime/components/checkbox/Checkbox.vue.d.ts +45 -0
- package/dist/runtime/components/date-picker/DatePicker.vue +102 -0
- package/dist/runtime/components/date-picker/DatePicker.vue.d.ts +16 -0
- package/dist/runtime/components/floating-label/FloatingLabel.vue +22 -0
- package/dist/runtime/components/floating-label/FloatingLabel.vue.d.ts +16 -0
- package/dist/runtime/components/forms/input/standard/InputStandard.vue +301 -0
- package/dist/runtime/components/forms/input/standard/InputStandard.vue.d.ts +0 -0
- package/dist/runtime/components/forms/input/textarea/ATextarea.vue +158 -0
- package/dist/runtime/components/forms/input/textarea/ATextarea.vue.d.ts +43 -0
- package/dist/runtime/components/forms/need-more-data/NeedMoreData.vue +114 -0
- package/dist/runtime/components/forms/need-more-data/NeedMoreData.vue.d.ts +5 -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 +120 -0
- package/dist/runtime/components/header/AlmatyContacts.vue.d.ts +2 -0
- package/dist/runtime/components/header/AstanaContacts.vue +65 -0
- package/dist/runtime/components/header/AstanaContacts.vue.d.ts +2 -0
- package/dist/runtime/components/header/CardGallery.vue +156 -0
- package/dist/runtime/components/header/CardGallery.vue.d.ts +2 -0
- package/dist/runtime/components/header/ContactMenu.vue +105 -0
- package/dist/runtime/components/header/ContactMenu.vue.d.ts +11 -0
- package/dist/runtime/components/header/HeaderLink.vue +169 -0
- package/dist/runtime/components/header/HeaderLink.vue.d.ts +2 -0
- package/dist/runtime/components/header/LangSwitcher.vue +48 -0
- package/dist/runtime/components/header/LangSwitcher.vue.d.ts +2 -0
- package/dist/runtime/components/header/ListItem.vue +26 -0
- package/dist/runtime/components/header/ListItem.vue.d.ts +7 -0
- package/dist/runtime/components/header/NavCard.vue +40 -0
- package/dist/runtime/components/header/NavCard.vue.d.ts +8 -0
- package/dist/runtime/components/header/NavList.vue +101 -0
- package/dist/runtime/components/header/NavList.vue.d.ts +17 -0
- package/dist/runtime/components/header/ProductMenu.vue +369 -0
- package/dist/runtime/components/header/ProductMenu.vue.d.ts +11 -0
- package/dist/runtime/components/header/ProfileMenu.vue +56 -0
- package/dist/runtime/components/header/ProfileMenu.vue.d.ts +16 -0
- package/dist/runtime/components/header/ProfileMenuContent.vue +228 -0
- package/dist/runtime/components/header/ProfileMenuContent.vue.d.ts +16 -0
- package/dist/runtime/components/header/TopHeader.vue +152 -0
- package/dist/runtime/components/header/TopHeader.vue.d.ts +10 -0
- package/dist/runtime/components/header/types.d.ts +19 -0
- package/dist/runtime/components/header/types.js +0 -0
- package/dist/runtime/components/header-mobile/HeaderMobile.vue +53 -0
- package/dist/runtime/components/header-mobile/HeaderMobile.vue.d.ts +17 -0
- package/dist/runtime/components/mobile-navigation/BottomNavigation.vue +68 -0
- package/dist/runtime/components/mobile-navigation/BottomNavigation.vue.d.ts +29 -0
- package/dist/runtime/components/mobile-navigation/MainButton.vue +16 -0
- package/dist/runtime/components/mobile-navigation/MainButton.vue.d.ts +2 -0
- package/dist/runtime/components/mobile-navigation/MobileProductMenu.vue +261 -0
- package/dist/runtime/components/mobile-navigation/MobileProductMenu.vue.d.ts +2 -0
- package/dist/runtime/components/modals/NoAccessContent.vue +58 -0
- package/dist/runtime/components/modals/NoAccessContent.vue.d.ts +5 -0
- package/dist/runtime/components/pill-tabs/PillTabs.vue +137 -0
- package/dist/runtime/components/pill-tabs/PillTabs.vue.d.ts +38 -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 +69 -0
- package/dist/runtime/components/radio-button/RadioButton.vue.d.ts +40 -0
- package/dist/runtime/components/row-card/RowCard.vue +44 -0
- package/dist/runtime/components/row-card/RowCard.vue.d.ts +26 -0
- package/dist/runtime/components/select-row/index.vue +117 -0
- package/dist/runtime/components/select-row/index.vue.d.ts +31 -0
- package/dist/runtime/components/tree-select/TreeSelect.vue +132 -0
- package/dist/runtime/components/tree-select/TreeSelect.vue.d.ts +22 -0
- package/dist/runtime/components/tree-select/TreeService.d.ts +54 -0
- package/dist/runtime/components/tree-select/TreeService.js +209 -0
- package/dist/runtime/components/tree-select/components/tree-select-nodes.vue +100 -0
- package/dist/runtime/components/tree-select/components/tree-select-nodes.vue.d.ts +9 -0
- package/dist/runtime/components/tree-select/types.d.ts +29 -0
- package/dist/runtime/components/tree-select/types.js +0 -0
- package/dist/runtime/composables/highlight.d.ts +1 -0
- package/dist/runtime/composables/highlight.js +15 -0
- package/dist/runtime/composables/projectState.d.ts +2 -0
- package/dist/runtime/composables/projectState.js +3 -0
- package/dist/runtime/i18n/i18n.config.d.ts +1731 -0
- package/dist/runtime/i18n/i18n.config.js +20 -0
- package/dist/runtime/i18n.d.ts +2 -0
- package/dist/runtime/i18n.js +15 -0
- package/dist/runtime/icons/arrow/arrow-circle-down.vue +30 -0
- package/dist/runtime/icons/arrow/arrow-circle-down.vue.d.ts +2 -0
- package/dist/runtime/icons/arrow/arrow-graph-up.vue +24 -0
- package/dist/runtime/icons/arrow/arrow-graph-up.vue.d.ts +2 -0
- package/dist/runtime/icons/arrow/arrow-right.vue +24 -0
- package/dist/runtime/icons/arrow/arrow-right.vue.d.ts +2 -0
- package/dist/runtime/icons/arrow/arrow-side-up.vue +19 -0
- package/dist/runtime/icons/arrow/arrow-side-up.vue.d.ts +2 -0
- package/dist/runtime/icons/arrow/arrow-top-right-on-square.vue +19 -0
- package/dist/runtime/icons/arrow/arrow-top-right-on-square.vue.d.ts +2 -0
- package/dist/runtime/icons/arrow/chevron-down.vue +19 -0
- package/dist/runtime/icons/arrow/chevron-down.vue.d.ts +2 -0
- package/dist/runtime/icons/avatar.vue +41 -0
- package/dist/runtime/icons/avatar.vue.d.ts +2 -0
- package/dist/runtime/icons/avto/car.vue +17 -0
- package/dist/runtime/icons/avto/car.vue.d.ts +2 -0
- package/dist/runtime/icons/avto/truck.vue +17 -0
- package/dist/runtime/icons/avto/truck.vue.d.ts +2 -0
- package/dist/runtime/icons/block.vue +19 -0
- package/dist/runtime/icons/block.vue.d.ts +2 -0
- package/dist/runtime/icons/bookmark.vue +19 -0
- package/dist/runtime/icons/bookmark.vue.d.ts +2 -0
- package/dist/runtime/icons/calculator.vue +19 -0
- package/dist/runtime/icons/calculator.vue.d.ts +2 -0
- package/dist/runtime/icons/calendar.vue +24 -0
- package/dist/runtime/icons/calendar.vue.d.ts +2 -0
- package/dist/runtime/icons/check-circle.vue +25 -0
- package/dist/runtime/icons/check-circle.vue.d.ts +2 -0
- 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/clipboard-text.vue +17 -0
- package/dist/runtime/icons/clipboard-text.vue.d.ts +2 -0
- package/dist/runtime/icons/clock.vue +25 -0
- package/dist/runtime/icons/clock.vue.d.ts +2 -0
- package/dist/runtime/icons/color-mode/moon.vue +20 -0
- package/dist/runtime/icons/color-mode/moon.vue.d.ts +2 -0
- package/dist/runtime/icons/color-mode/sun.vue +27 -0
- package/dist/runtime/icons/color-mode/sun.vue.d.ts +2 -0
- package/dist/runtime/icons/communication/mail.vue +19 -0
- package/dist/runtime/icons/communication/mail.vue.d.ts +2 -0
- package/dist/runtime/icons/communication/phone.vue +19 -0
- package/dist/runtime/icons/communication/phone.vue.d.ts +2 -0
- package/dist/runtime/icons/company.vue +19 -0
- package/dist/runtime/icons/company.vue.d.ts +2 -0
- package/dist/runtime/icons/currency/dollar.vue +19 -0
- package/dist/runtime/icons/currency/dollar.vue.d.ts +2 -0
- package/dist/runtime/icons/currency/down.vue +22 -0
- package/dist/runtime/icons/currency/down.vue.d.ts +2 -0
- package/dist/runtime/icons/currency/eur.vue +69 -0
- package/dist/runtime/icons/currency/eur.vue.d.ts +2 -0
- package/dist/runtime/icons/currency/rub.vue +25 -0
- package/dist/runtime/icons/currency/rub.vue.d.ts +2 -0
- package/dist/runtime/icons/currency/usd.vue +269 -0
- package/dist/runtime/icons/currency/usd.vue.d.ts +2 -0
- package/dist/runtime/icons/currency/yuan.vue +37 -0
- package/dist/runtime/icons/currency/yuan.vue.d.ts +2 -0
- package/dist/runtime/icons/document/hdocument.vue +17 -0
- package/dist/runtime/icons/document/hdocument.vue.d.ts +2 -0
- package/dist/runtime/icons/document/id.vue +19 -0
- package/dist/runtime/icons/document/id.vue.d.ts +2 -0
- package/dist/runtime/icons/document/profile.vue +19 -0
- package/dist/runtime/icons/document/profile.vue.d.ts +2 -0
- package/dist/runtime/icons/download.vue +26 -0
- package/dist/runtime/icons/download.vue.d.ts +2 -0
- package/dist/runtime/icons/edit.vue +24 -0
- package/dist/runtime/icons/edit.vue.d.ts +2 -0
- package/dist/runtime/icons/file/excel.vue +88 -0
- package/dist/runtime/icons/file/excel.vue.d.ts +2 -0
- package/dist/runtime/icons/file/file.vue +19 -0
- package/dist/runtime/icons/file/file.vue.d.ts +2 -0
- package/dist/runtime/icons/file/files.vue +17 -0
- package/dist/runtime/icons/file/files.vue.d.ts +2 -0
- package/dist/runtime/icons/globe.vue +19 -0
- package/dist/runtime/icons/globe.vue.d.ts +2 -0
- package/dist/runtime/icons/handshake.vue +19 -0
- package/dist/runtime/icons/handshake.vue.d.ts +2 -0
- package/dist/runtime/icons/history.vue +19 -0
- package/dist/runtime/icons/history.vue.d.ts +2 -0
- package/dist/runtime/icons/info/info-circle.vue +29 -0
- package/dist/runtime/icons/info/info-circle.vue.d.ts +2 -0
- package/dist/runtime/icons/invoice.vue +35 -0
- package/dist/runtime/icons/invoice.vue.d.ts +2 -0
- package/dist/runtime/icons/link-chain.vue +31 -0
- package/dist/runtime/icons/link-chain.vue.d.ts +2 -0
- package/dist/runtime/icons/loader-circle.vue +41 -0
- package/dist/runtime/icons/loader-circle.vue.d.ts +2 -0
- package/dist/runtime/icons/lock.vue +19 -0
- package/dist/runtime/icons/lock.vue.d.ts +2 -0
- package/dist/runtime/icons/logo/adata.vue +48 -0
- package/dist/runtime/icons/logo/adata.vue.d.ts +2 -0
- package/dist/runtime/icons/logo/logo.vue +27 -0
- package/dist/runtime/icons/logo/logo.vue.d.ts +2 -0
- package/dist/runtime/icons/medal.vue +17 -0
- package/dist/runtime/icons/medal.vue.d.ts +2 -0
- package/dist/runtime/icons/menu/menu-filled.vue +61 -0
- package/dist/runtime/icons/menu/menu-filled.vue.d.ts +2 -0
- package/dist/runtime/icons/menu/menu.vue +41 -0
- package/dist/runtime/icons/menu/menu.vue.d.ts +2 -0
- package/dist/runtime/icons/message.vue +24 -0
- package/dist/runtime/icons/message.vue.d.ts +2 -0
- package/dist/runtime/icons/modals/door.vue +170 -0
- package/dist/runtime/icons/modals/door.vue.d.ts +2 -0
- package/dist/runtime/icons/moon.vue +10 -0
- package/dist/runtime/icons/moon.vue.d.ts +2 -0
- package/dist/runtime/icons/more.vue +36 -0
- package/dist/runtime/icons/more.vue.d.ts +2 -0
- package/dist/runtime/icons/navigation/expand-window.vue +19 -0
- package/dist/runtime/icons/navigation/expand-window.vue.d.ts +2 -0
- package/dist/runtime/icons/navigation/location.vue +25 -0
- package/dist/runtime/icons/navigation/location.vue.d.ts +2 -0
- package/dist/runtime/icons/navigation/logout.vue +19 -0
- package/dist/runtime/icons/navigation/logout.vue.d.ts +2 -0
- package/dist/runtime/icons/notifications.vue +25 -0
- package/dist/runtime/icons/notifications.vue.d.ts +2 -0
- package/dist/runtime/icons/other-service/arrow-square-down.vue +15 -0
- package/dist/runtime/icons/other-service/arrow-square-down.vue.d.ts +2 -0
- package/dist/runtime/icons/other-service/arrow-top-right-on-square.vue +6 -0
- package/dist/runtime/icons/other-service/arrow-top-right-on-square.vue.d.ts +2 -0
- package/dist/runtime/icons/other-service/block.vue +16 -0
- package/dist/runtime/icons/other-service/block.vue.d.ts +2 -0
- package/dist/runtime/icons/other-service/currency-dollar.vue +16 -0
- package/dist/runtime/icons/other-service/currency-dollar.vue.d.ts +2 -0
- package/dist/runtime/icons/other-service/globe.vue +16 -0
- package/dist/runtime/icons/other-service/globe.vue.d.ts +2 -0
- package/dist/runtime/icons/other-service/link.vue +7 -0
- package/dist/runtime/icons/other-service/link.vue.d.ts +2 -0
- package/dist/runtime/icons/other-service/magnifying-glass.vue +9 -0
- package/dist/runtime/icons/other-service/magnifying-glass.vue.d.ts +2 -0
- package/dist/runtime/icons/other-service/standing-scales.vue +15 -0
- package/dist/runtime/icons/other-service/standing-scales.vue.d.ts +2 -0
- package/dist/runtime/icons/other-service/users-three.vue +7 -0
- package/dist/runtime/icons/other-service/users-three.vue.d.ts +2 -0
- package/dist/runtime/icons/plus-circle.vue +24 -0
- package/dist/runtime/icons/plus-circle.vue.d.ts +2 -0
- package/dist/runtime/icons/plus.vue +24 -0
- package/dist/runtime/icons/plus.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/dist/runtime/icons/receipt/hcheck.vue +27 -0
- package/dist/runtime/icons/receipt/hcheck.vue.d.ts +2 -0
- package/dist/runtime/icons/receipt/receipt.vue +27 -0
- package/dist/runtime/icons/receipt/receipt.vue.d.ts +2 -0
- package/dist/runtime/icons/scale.vue +19 -0
- package/dist/runtime/icons/scale.vue.d.ts +2 -0
- package/dist/runtime/icons/search.vue +27 -0
- package/dist/runtime/icons/search.vue.d.ts +2 -0
- package/dist/runtime/icons/socials/facebook.vue +15 -0
- package/dist/runtime/icons/socials/facebook.vue.d.ts +2 -0
- package/dist/runtime/icons/socials/instagram.vue +19 -0
- package/dist/runtime/icons/socials/instagram.vue.d.ts +2 -0
- package/dist/runtime/icons/socials/linkedin.vue +24 -0
- package/dist/runtime/icons/socials/linkedin.vue.d.ts +2 -0
- package/dist/runtime/icons/socials/telegram.vue +15 -0
- package/dist/runtime/icons/socials/telegram.vue.d.ts +2 -0
- package/dist/runtime/icons/socials/tik-tok.vue +15 -0
- package/dist/runtime/icons/socials/tik-tok.vue.d.ts +2 -0
- package/dist/runtime/icons/socials/whatsapp.vue +21 -0
- package/dist/runtime/icons/socials/whatsapp.vue.d.ts +2 -0
- package/dist/runtime/icons/socials/youtube.vue +16 -0
- package/dist/runtime/icons/socials/youtube.vue.d.ts +2 -0
- package/dist/runtime/icons/sun.vue +14 -0
- package/dist/runtime/icons/sun.vue.d.ts +2 -0
- package/dist/runtime/icons/sviazi.vue +19 -0
- package/dist/runtime/icons/sviazi.vue.d.ts +2 -0
- package/dist/runtime/icons/tenge.vue +22 -0
- package/dist/runtime/icons/tenge.vue.d.ts +2 -0
- package/dist/runtime/icons/trash.vue +24 -0
- package/dist/runtime/icons/trash.vue.d.ts +2 -0
- package/dist/runtime/icons/upload.vue +26 -0
- package/dist/runtime/icons/upload.vue.d.ts +2 -0
- package/dist/runtime/icons/user.vue +30 -0
- package/dist/runtime/icons/user.vue.d.ts +2 -0
- package/dist/runtime/icons/users/users-three.vue +17 -0
- package/dist/runtime/icons/users/users-three.vue.d.ts +2 -0
- package/dist/runtime/icons/users/users.vue +31 -0
- package/dist/runtime/icons/users/users.vue.d.ts +2 -0
- package/dist/runtime/icons/warning-triangle.vue +29 -0
- package/dist/runtime/icons/warning-triangle.vue.d.ts +2 -0
- package/dist/runtime/icons/work-bag.vue +20 -0
- package/dist/runtime/icons/work-bag.vue.d.ts +2 -0
- package/dist/runtime/icons/x-mark.vue +18 -0
- package/dist/runtime/icons/x-mark.vue.d.ts +2 -0
- package/dist/runtime/lang/en.d.ts +4 -0
- package/dist/runtime/lang/en.js +545 -0
- package/dist/runtime/lang/kk.d.ts +4 -0
- package/dist/runtime/lang/kk.js +545 -0
- package/dist/runtime/lang/ru.d.ts +575 -0
- package/dist/runtime/lang/ru.js +607 -0
- package/dist/runtime/shared/constants/pages.d.ts +71 -0
- package/dist/runtime/shared/constants/pages.js +71 -0
- package/package.json +66 -58
- package/dist/runtime/components/header/TheHeader.vue +0 -15
- package/dist/runtime/components/header/TheHeader.vue.d.ts +0 -2
- package/dist/runtime/plugin.d.ts +0 -2
- package/dist/runtime/plugin.js +0 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
leadingColor: { type: String, required: false },
|
|
5
|
+
title: { type: String, required: false },
|
|
6
|
+
value: { type: String, required: false },
|
|
7
|
+
titleClasses: { type: String, required: false },
|
|
8
|
+
cardClasses: { type: String, required: false },
|
|
9
|
+
valueClasses: { type: String, required: false },
|
|
10
|
+
icon: { type: null, required: false }
|
|
11
|
+
});
|
|
12
|
+
const combinedCardClasses = twMerge("flex justify-between items-center rounded-md py-3 px-4 dark:bg-gray-900 bg-white", props.cardClasses);
|
|
13
|
+
const combinedLeadingClasses = twMerge("rounded-full size-4", props.leadingColor);
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div :class="combinedCardClasses">
|
|
18
|
+
<div class="flex gap-3 items-center">
|
|
19
|
+
<slot name="leading">
|
|
20
|
+
<div
|
|
21
|
+
v-if="leadingColor"
|
|
22
|
+
:class="combinedLeadingClasses"
|
|
23
|
+
/>
|
|
24
|
+
<component
|
|
25
|
+
:is="icon"
|
|
26
|
+
v-if="icon"
|
|
27
|
+
/>
|
|
28
|
+
</slot>
|
|
29
|
+
<slot name="title">
|
|
30
|
+
<p :class="titleClasses">
|
|
31
|
+
{{ title }}
|
|
32
|
+
</p>
|
|
33
|
+
</slot>
|
|
34
|
+
</div>
|
|
35
|
+
<slot name="trailing">
|
|
36
|
+
<p
|
|
37
|
+
v-if="value"
|
|
38
|
+
:class="valueClasses"
|
|
39
|
+
>
|
|
40
|
+
{{ value }}
|
|
41
|
+
</p>
|
|
42
|
+
</slot>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
leadingColor?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
titleClasses?: string;
|
|
7
|
+
cardClasses?: string;
|
|
8
|
+
valueClasses?: string;
|
|
9
|
+
icon?: Component;
|
|
10
|
+
};
|
|
11
|
+
declare var __VLS_1: {}, __VLS_7: {}, __VLS_9: {};
|
|
12
|
+
type __VLS_Slots = {} & {
|
|
13
|
+
leading?: (props: typeof __VLS_1) => any;
|
|
14
|
+
} & {
|
|
15
|
+
title?: (props: typeof __VLS_7) => any;
|
|
16
|
+
} & {
|
|
17
|
+
trailing?: (props: typeof __VLS_9) => any;
|
|
18
|
+
};
|
|
19
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
21
|
+
export default _default;
|
|
22
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
23
|
+
new (): {
|
|
24
|
+
$slots: S;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { isEqual } from "lodash-es";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
import { computed, ref } from "#imports";
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
clearable: { type: Boolean, required: false, default: true },
|
|
7
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
8
|
+
deletable: { type: Boolean, required: false, default: false },
|
|
9
|
+
label: { type: String, required: true, default: "select" },
|
|
10
|
+
selectedItems: { type: Array, required: true },
|
|
11
|
+
btnClass: { type: String, required: false, default: "" }
|
|
12
|
+
});
|
|
13
|
+
const items = computed(() => {
|
|
14
|
+
return props.selectedItems;
|
|
15
|
+
});
|
|
16
|
+
const emits = defineEmits(["delete"]);
|
|
17
|
+
const disabledStyles = "disabled:pointer-events-none disabled:opacity-40 disabled:bg-deepblue-50 disabled:text-deepblue-200 disabled:dark:text-gray-500";
|
|
18
|
+
const isOpen = defineModel("isOpen", { type: Boolean });
|
|
19
|
+
const minWidthOfChip = 100;
|
|
20
|
+
const buttonElement = ref();
|
|
21
|
+
const buttonWidth = computed(() => buttonElement.value?.offsetWidth - 50);
|
|
22
|
+
const itemsCount = computed(() => {
|
|
23
|
+
return items.value.length;
|
|
24
|
+
});
|
|
25
|
+
const maxWidthOfChip = computed(() => {
|
|
26
|
+
if (itemsCount.value) {
|
|
27
|
+
const width = (itemsCount.value <= 5 ? buttonWidth.value - itemsCount.value * 8 : buttonWidth.value) / itemsCount.value;
|
|
28
|
+
if (width < minWidthOfChip) {
|
|
29
|
+
return minWidthOfChip;
|
|
30
|
+
}
|
|
31
|
+
return width;
|
|
32
|
+
}
|
|
33
|
+
return "auto";
|
|
34
|
+
});
|
|
35
|
+
const countOfVisibleItems = computed(() => {
|
|
36
|
+
if (!items.value?.length) return void 0;
|
|
37
|
+
const maxCountOfVisibleItems = Math.floor((buttonElement.value?.offsetWidth - 50) / 120);
|
|
38
|
+
if (maxCountOfVisibleItems > items.value.length) return items.value.length;
|
|
39
|
+
else return maxCountOfVisibleItems;
|
|
40
|
+
});
|
|
41
|
+
const visibleItems = computed(() => {
|
|
42
|
+
if (!items.value.length && !countOfVisibleItems.value) return void 0;
|
|
43
|
+
return items.value.slice(0, countOfVisibleItems.value);
|
|
44
|
+
});
|
|
45
|
+
const countOfUnvisibleItems = computed(() => {
|
|
46
|
+
if (!items.value?.length && !countOfVisibleItems.value) return void 0;
|
|
47
|
+
return items.value.length - countOfVisibleItems.value;
|
|
48
|
+
});
|
|
49
|
+
const deleteItem = (item) => {
|
|
50
|
+
emits("delete", item);
|
|
51
|
+
items.value = items.value?.filter((el) => !isEqual(el, item));
|
|
52
|
+
};
|
|
53
|
+
const onClear = () => {
|
|
54
|
+
items.value.length = 0;
|
|
55
|
+
};
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<template>
|
|
59
|
+
<div>
|
|
60
|
+
<button
|
|
61
|
+
ref="buttonElement"
|
|
62
|
+
class="hover:border-blue focus-visible:outline-blue
|
|
63
|
+
relative flex w-full items-center justify-between gap-2 rounded-md
|
|
64
|
+
border border-solid border-deepblue-50 bg-deepblue-50 min-h-[40px] text-gray-500 body-400 px-4 py-1.5
|
|
65
|
+
focus-visible:shadow-[0_0_0_4px#1B64B3] dark:border-gray-900 dark:bg-gray-200/5
|
|
66
|
+
dark:hover:border-blue-700"
|
|
67
|
+
:class="twMerge(disabledStyles, props.btnClass)"
|
|
68
|
+
:disabled="disabled"
|
|
69
|
+
@click="isOpen = !isOpen"
|
|
70
|
+
>
|
|
71
|
+
<div>
|
|
72
|
+
<div
|
|
73
|
+
v-if="visibleItems && visibleItems.length"
|
|
74
|
+
class="flex gap-2"
|
|
75
|
+
>
|
|
76
|
+
<adt-chip
|
|
77
|
+
v-for="item in visibleItems"
|
|
78
|
+
:key="item.id"
|
|
79
|
+
size="md"
|
|
80
|
+
class="text-deepblue-900 dark:text-gray-200 border-gray-500"
|
|
81
|
+
:style="{ 'max-width': maxWidthOfChip + 'px' }"
|
|
82
|
+
>
|
|
83
|
+
<span class="truncate">{{ item.name }}</span>
|
|
84
|
+
<button
|
|
85
|
+
v-if="deletable"
|
|
86
|
+
class="rounded-full bg-deepblue-100 dark:bg-gray-200/10"
|
|
87
|
+
@click.stop="deleteItem(item)"
|
|
88
|
+
>
|
|
89
|
+
<a-icon-x-mark class="size-3 dark:text-gray-300" />
|
|
90
|
+
</button>
|
|
91
|
+
</adt-chip>
|
|
92
|
+
<adt-chip
|
|
93
|
+
v-if="countOfUnvisibleItems"
|
|
94
|
+
class="text-blue-700 dark:text-blue-500 border-blue-700 dark:border-blue-500 whitespace-nowrap"
|
|
95
|
+
size="md"
|
|
96
|
+
>
|
|
97
|
+
+ {{ countOfUnvisibleItems }}
|
|
98
|
+
</adt-chip>
|
|
99
|
+
</div>
|
|
100
|
+
<div v-else>
|
|
101
|
+
{{ label }}
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
<!-- <button -->
|
|
105
|
+
<!-- v-if="visibleItems && countOfVisibleItems && clearable" -->
|
|
106
|
+
<!-- class="absolute right-10 top-1/2 -translate-y-1/2 rounded-full bg-deepblue-100 dark:bg-gray-200/10" -->
|
|
107
|
+
<!-- @click.stop="onClear" -->
|
|
108
|
+
<!-- > -->
|
|
109
|
+
<!-- <a-icon-chevron-down class="!m-0 text-base dark:text-gray-300"/> -->
|
|
110
|
+
<!-- </button> -->
|
|
111
|
+
<a-icon-chevron-down
|
|
112
|
+
class="!m-0 min-w-4 transition-all text-deepblue-900 dark:text-gray-500"
|
|
113
|
+
:class="{ '-rotate-90': !isOpen }"
|
|
114
|
+
/>
|
|
115
|
+
</button>
|
|
116
|
+
</div>
|
|
117
|
+
</template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type Item = {
|
|
2
|
+
id: number | string;
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
interface Props {
|
|
6
|
+
clearable?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
deletable?: boolean;
|
|
9
|
+
label: string;
|
|
10
|
+
selectedItems: Item[];
|
|
11
|
+
btnClass?: string;
|
|
12
|
+
}
|
|
13
|
+
type __VLS_Props = Props;
|
|
14
|
+
type __VLS_PublicProps = __VLS_Props & {
|
|
15
|
+
'isOpen'?: boolean;
|
|
16
|
+
};
|
|
17
|
+
declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
18
|
+
"update:isOpen": (value: boolean | undefined) => any;
|
|
19
|
+
} & {
|
|
20
|
+
delete: (item: Item) => any;
|
|
21
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
22
|
+
onDelete?: ((item: Item) => any) | undefined;
|
|
23
|
+
"onUpdate:isOpen"?: ((value: boolean | undefined) => any) | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
label: string;
|
|
27
|
+
clearable: boolean;
|
|
28
|
+
deletable: boolean;
|
|
29
|
+
btnClass: string;
|
|
30
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
export default _default;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useDebounceFn } from "@vueuse/shared";
|
|
3
|
+
import highlight from "../../composables/highlight";
|
|
4
|
+
import TreeSelectNodes from "./components/tree-select-nodes.vue";
|
|
5
|
+
import { useTreeService } from "./TreeService";
|
|
6
|
+
import { watch, computed, onMounted } from "#imports";
|
|
7
|
+
const emits = defineEmits(["update:modelValue"]);
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
options: { type: Array, required: true },
|
|
10
|
+
modelValue: { type: Array, required: true },
|
|
11
|
+
type: { type: String, required: false, default: "checkbox" },
|
|
12
|
+
isSearch: { type: Boolean, required: false },
|
|
13
|
+
searchText: { type: String, required: false, default: "" },
|
|
14
|
+
asyncSearch: { type: Function, required: false },
|
|
15
|
+
withoutId: { type: Boolean, required: false, default: false }
|
|
16
|
+
});
|
|
17
|
+
const {
|
|
18
|
+
nestedTree,
|
|
19
|
+
tree,
|
|
20
|
+
setState,
|
|
21
|
+
setExpandableClosed,
|
|
22
|
+
initTree,
|
|
23
|
+
collectSelectedIds,
|
|
24
|
+
updateNestedTree,
|
|
25
|
+
searchedData,
|
|
26
|
+
toggleHiddenNodes,
|
|
27
|
+
reset,
|
|
28
|
+
toggleExpandableNodes
|
|
29
|
+
} = useTreeService(props.withoutId);
|
|
30
|
+
const selected = computed({
|
|
31
|
+
get() {
|
|
32
|
+
return props.modelValue;
|
|
33
|
+
},
|
|
34
|
+
set(val) {
|
|
35
|
+
emits("update:modelValue", val);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
initTree(props.options);
|
|
39
|
+
const toggleExpand = (node) => {
|
|
40
|
+
if (node.expandable) {
|
|
41
|
+
setExpandableClosed(node.id, !node.expandableClosed);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const toggleCheckbox = (id, checked) => {
|
|
45
|
+
setState(id, checked ? "checked" : "unchecked");
|
|
46
|
+
};
|
|
47
|
+
function openFounded(nodes) {
|
|
48
|
+
nodes.forEach((node) => {
|
|
49
|
+
node.expandableClosed = false;
|
|
50
|
+
node.text = highlight(node.text, props.searchText);
|
|
51
|
+
if (node.child.length) {
|
|
52
|
+
openFounded(node.child);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function filterOptions(options, search) {
|
|
57
|
+
return options.map((option) => {
|
|
58
|
+
const matches = option.name.toLowerCase().includes(search.toLowerCase());
|
|
59
|
+
const matchesWithId = option.id?.toString().toLowerCase().includes(search.toLowerCase());
|
|
60
|
+
let filteredChildren = [];
|
|
61
|
+
if (option.children) {
|
|
62
|
+
filteredChildren = filterOptions(option.children, search);
|
|
63
|
+
}
|
|
64
|
+
if (matches || matchesWithId || filteredChildren.length > 0) {
|
|
65
|
+
return {
|
|
66
|
+
...option,
|
|
67
|
+
children: filteredChildren
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}).filter(Boolean);
|
|
72
|
+
}
|
|
73
|
+
const debouncedSearch = useDebounceFn(async () => {
|
|
74
|
+
if (props.searchText !== "") {
|
|
75
|
+
if (props?.asyncSearch) {
|
|
76
|
+
const searchData = await props.asyncSearch(props.searchText);
|
|
77
|
+
searchedData(searchData, props.searchText);
|
|
78
|
+
} else {
|
|
79
|
+
const searchData = filterOptions(props.options, props.searchText);
|
|
80
|
+
searchedData(searchData, props.searchText);
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
toggleHiddenNodes(false);
|
|
84
|
+
toggleExpandableNodes(true);
|
|
85
|
+
updateNestedTree();
|
|
86
|
+
}
|
|
87
|
+
}, 300);
|
|
88
|
+
watch(
|
|
89
|
+
() => props.searchText,
|
|
90
|
+
(newVal) => debouncedSearch()
|
|
91
|
+
);
|
|
92
|
+
onMounted(() => {
|
|
93
|
+
if (props.modelValue && props.modelValue.length) {
|
|
94
|
+
props.modelValue.forEach((id) => {
|
|
95
|
+
setState(id, "checked");
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (props.isSearch) {
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
watch(
|
|
102
|
+
tree,
|
|
103
|
+
() => {
|
|
104
|
+
if (tree.value) {
|
|
105
|
+
selected.value = collectSelectedIds(tree.value);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{ deep: true }
|
|
109
|
+
);
|
|
110
|
+
defineExpose({
|
|
111
|
+
reset
|
|
112
|
+
});
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<template>
|
|
116
|
+
<div>
|
|
117
|
+
<ul>
|
|
118
|
+
<template
|
|
119
|
+
v-for="node in nestedTree"
|
|
120
|
+
:key="node.id"
|
|
121
|
+
>
|
|
122
|
+
<TreeSelectNodes
|
|
123
|
+
v-if="!node?.hidden"
|
|
124
|
+
:node="node"
|
|
125
|
+
:toggle-expand="toggleExpand"
|
|
126
|
+
:toggle-checkbox="toggleCheckbox"
|
|
127
|
+
:type="type"
|
|
128
|
+
/>
|
|
129
|
+
</template>
|
|
130
|
+
</ul>
|
|
131
|
+
</div>
|
|
132
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TreeData } from './types.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
options: TreeData[];
|
|
4
|
+
modelValue: (string | number)[];
|
|
5
|
+
type?: 'checkbox' | 'select';
|
|
6
|
+
isSearch?: boolean;
|
|
7
|
+
searchText?: string;
|
|
8
|
+
asyncSearch?: (keyword: string) => TreeData[];
|
|
9
|
+
withoutId?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: import("vue").DefineComponent<Props, {
|
|
12
|
+
reset: () => void;
|
|
13
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
14
|
+
"update:modelValue": (item: (string | number)[]) => any;
|
|
15
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
16
|
+
"onUpdate:modelValue"?: ((item: (string | number)[]) => any) | undefined;
|
|
17
|
+
}>, {
|
|
18
|
+
type: "checkbox" | "select";
|
|
19
|
+
searchText: string;
|
|
20
|
+
withoutId: boolean;
|
|
21
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { TreeData, TreeNestedNode, TreeNode, TreeNodeStateEditable } from './types.js';
|
|
2
|
+
export declare const useTreeService: (withoutId?: boolean) => {
|
|
3
|
+
tree: import("vue").Ref<(Map<string | number, {
|
|
4
|
+
id: string | number;
|
|
5
|
+
name: string;
|
|
6
|
+
state: import("./types.js").TreeNodeState;
|
|
7
|
+
level: number;
|
|
8
|
+
expandable: boolean;
|
|
9
|
+
expandableClosed: boolean;
|
|
10
|
+
parent: string | number | null;
|
|
11
|
+
hidden?: boolean | undefined;
|
|
12
|
+
child: (string | number)[];
|
|
13
|
+
}> & Omit<Map<string | number, TreeNode>, keyof Map<any, any>>) | null, Map<string | number, TreeNode> | (Map<string | number, {
|
|
14
|
+
id: string | number;
|
|
15
|
+
name: string;
|
|
16
|
+
state: import("./types.js").TreeNodeState;
|
|
17
|
+
level: number;
|
|
18
|
+
expandable: boolean;
|
|
19
|
+
expandableClosed: boolean;
|
|
20
|
+
parent: string | number | null;
|
|
21
|
+
hidden?: boolean | undefined;
|
|
22
|
+
child: (string | number)[];
|
|
23
|
+
}> & Omit<Map<string | number, TreeNode>, keyof Map<any, any>>) | null>;
|
|
24
|
+
nestedTree: import("vue").Ref<{
|
|
25
|
+
id: string | number;
|
|
26
|
+
name: string;
|
|
27
|
+
state: import("./types.js").TreeNodeState;
|
|
28
|
+
level: number;
|
|
29
|
+
expandable: boolean;
|
|
30
|
+
expandableClosed: boolean;
|
|
31
|
+
text: string;
|
|
32
|
+
hidden: boolean;
|
|
33
|
+
child: /*elided*/ any[];
|
|
34
|
+
}[], TreeNestedNode[] | {
|
|
35
|
+
id: string | number;
|
|
36
|
+
name: string;
|
|
37
|
+
state: import("./types.js").TreeNodeState;
|
|
38
|
+
level: number;
|
|
39
|
+
expandable: boolean;
|
|
40
|
+
expandableClosed: boolean;
|
|
41
|
+
text: string;
|
|
42
|
+
hidden: boolean;
|
|
43
|
+
child: /*elided*/ any[];
|
|
44
|
+
}[]>;
|
|
45
|
+
initTree: (data: TreeData[]) => void;
|
|
46
|
+
setState: (idNode: string | number, state: TreeNodeStateEditable) => void;
|
|
47
|
+
reset: () => void;
|
|
48
|
+
setExpandableClosed: (idNode: string | number, expandableClosed: boolean) => void;
|
|
49
|
+
collectSelectedIds: (tree: Map<string | number, TreeNode>) => (string | number)[];
|
|
50
|
+
updateNestedTree: (searchText?: string) => void;
|
|
51
|
+
searchedData: (data: TreeData[], searchText: string) => void;
|
|
52
|
+
toggleHiddenNodes: (hidden: boolean) => void;
|
|
53
|
+
toggleExpandableNodes: (expandableClosed: boolean) => void;
|
|
54
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import highlight from "../../composables/highlight.js";
|
|
2
|
+
import { ref } from "#imports";
|
|
3
|
+
export const useTreeService = (withoutId) => {
|
|
4
|
+
const tree = ref(null);
|
|
5
|
+
const nestedTree = ref([]);
|
|
6
|
+
const createdTreeBool = ref(false);
|
|
7
|
+
const initTree = (data) => {
|
|
8
|
+
if (!createdTreeBool.value) {
|
|
9
|
+
tree.value = generateTree(data, 0);
|
|
10
|
+
createdTreeBool.value = true;
|
|
11
|
+
updateNestedTree();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const generateTree = (data, level, parent = null) => {
|
|
15
|
+
const treeMap = /* @__PURE__ */ new Map();
|
|
16
|
+
data.forEach((item) => {
|
|
17
|
+
const id = item.id;
|
|
18
|
+
const child = item.children ? item.children.map((child2) => child2.id) : [];
|
|
19
|
+
treeMap.set(id, {
|
|
20
|
+
id,
|
|
21
|
+
name: item.name,
|
|
22
|
+
level,
|
|
23
|
+
expandable: child.length > 0,
|
|
24
|
+
expandableClosed: true,
|
|
25
|
+
child,
|
|
26
|
+
parent,
|
|
27
|
+
state: "unchecked",
|
|
28
|
+
hidden: false
|
|
29
|
+
});
|
|
30
|
+
if (item.children && item.children.length > 0) {
|
|
31
|
+
const childTreeMap = generateTree(item.children, level + 1, id);
|
|
32
|
+
childTreeMap.forEach((value, key) => treeMap.set(key, value));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return treeMap;
|
|
36
|
+
};
|
|
37
|
+
const updateNestedTree = (searchText = "") => {
|
|
38
|
+
if (!tree.value) return;
|
|
39
|
+
const nodesFromLevel0 = getNodesByLevel(0);
|
|
40
|
+
nestedTree.value = nodesFromLevel0.map((flatNode) => createNestedNode(flatNode));
|
|
41
|
+
highlightTree(nestedTree.value, searchText);
|
|
42
|
+
};
|
|
43
|
+
function highlightTree(nodes, searchText) {
|
|
44
|
+
nodes.forEach((node) => {
|
|
45
|
+
node.text = highlight(node.text, searchText);
|
|
46
|
+
if (node.child.length) {
|
|
47
|
+
highlightTree(node.child, searchText);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const createNestedNode = (node) => {
|
|
52
|
+
return {
|
|
53
|
+
id: node.id,
|
|
54
|
+
name: node.name,
|
|
55
|
+
text: withoutId ? `${node.name}` : `${node.id} - ${node.name}`,
|
|
56
|
+
state: node.state,
|
|
57
|
+
level: node.level,
|
|
58
|
+
expandable: node.expandable,
|
|
59
|
+
expandableClosed: node.expandableClosed,
|
|
60
|
+
hidden: node?.hidden ?? false,
|
|
61
|
+
child: node.child.map((id) => {
|
|
62
|
+
const childNode = getNodeById(id);
|
|
63
|
+
return childNode ? createNestedNode(childNode) : null;
|
|
64
|
+
}).filter((n) => n)
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const getNodeById = (idNode) => {
|
|
68
|
+
if (!tree.value) return null;
|
|
69
|
+
return tree.value.get(idNode) || null;
|
|
70
|
+
};
|
|
71
|
+
const getChildNodesFromNode = (idNode) => {
|
|
72
|
+
if (!tree.value) return [];
|
|
73
|
+
const node = getNodeById(idNode);
|
|
74
|
+
if (!node) return [];
|
|
75
|
+
return node.child.map((id) => getNodeById(id)).filter((n) => n);
|
|
76
|
+
};
|
|
77
|
+
const getParentNode = (idNode) => {
|
|
78
|
+
if (!tree.value) return null;
|
|
79
|
+
const node = getNodeById(idNode);
|
|
80
|
+
if (!node || !node.parent) return null;
|
|
81
|
+
return getNodeById(node.parent);
|
|
82
|
+
};
|
|
83
|
+
const getNodesByLevel = (level) => {
|
|
84
|
+
if (!tree.value) return [];
|
|
85
|
+
const nodes = [];
|
|
86
|
+
tree.value.forEach((node) => {
|
|
87
|
+
if (node.level === level) {
|
|
88
|
+
nodes.push(node);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return nodes;
|
|
92
|
+
};
|
|
93
|
+
const setState = (idNode, state) => {
|
|
94
|
+
if (!tree.value) return;
|
|
95
|
+
const node = getNodeById(idNode);
|
|
96
|
+
if (!node) return;
|
|
97
|
+
node.state = state;
|
|
98
|
+
tree.value.set(idNode, node);
|
|
99
|
+
setStateChildNodes(node, state);
|
|
100
|
+
setStateParentNodes(node);
|
|
101
|
+
updateNestedTree();
|
|
102
|
+
};
|
|
103
|
+
const setStateChildNodes = (node, state) => {
|
|
104
|
+
if (!tree.value) return;
|
|
105
|
+
node.child.forEach((id) => {
|
|
106
|
+
const childNode = getNodeById(id);
|
|
107
|
+
if (childNode) {
|
|
108
|
+
childNode.state = state;
|
|
109
|
+
tree.value.set(id, childNode);
|
|
110
|
+
setStateChildNodes(childNode, state);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const setStateParentNodes = (node) => {
|
|
115
|
+
if (!tree.value) return;
|
|
116
|
+
const parentNode = getParentNode(node.id);
|
|
117
|
+
if (!parentNode) return;
|
|
118
|
+
const childNodes = getChildNodesFromNode(parentNode.id);
|
|
119
|
+
const checkedCount = childNodes.filter((n) => n.state === "checked").length;
|
|
120
|
+
const indeterminateCount = childNodes.filter((n) => n.state === "indeterminate").length;
|
|
121
|
+
if (checkedCount === childNodes.length) {
|
|
122
|
+
parentNode.state = "checked";
|
|
123
|
+
} else if (checkedCount > 0 || indeterminateCount > 0) {
|
|
124
|
+
parentNode.state = "indeterminate";
|
|
125
|
+
} else {
|
|
126
|
+
parentNode.state = "unchecked";
|
|
127
|
+
}
|
|
128
|
+
tree.value.set(parentNode.id, parentNode);
|
|
129
|
+
setStateParentNodes(parentNode);
|
|
130
|
+
};
|
|
131
|
+
const setExpandableClosed = (idNode, expandableClosed) => {
|
|
132
|
+
if (!tree.value) return;
|
|
133
|
+
const node = getNodeById(idNode);
|
|
134
|
+
if (!node) return;
|
|
135
|
+
if (!expandableClosed && node.expandable && node.child.length === 0) {
|
|
136
|
+
}
|
|
137
|
+
node.expandableClosed = expandableClosed;
|
|
138
|
+
tree.value.set(node.id, node);
|
|
139
|
+
updateNestedTree();
|
|
140
|
+
};
|
|
141
|
+
const reset = () => {
|
|
142
|
+
if (!tree.value) return;
|
|
143
|
+
tree.value.forEach((node) => {
|
|
144
|
+
node.state = "unchecked";
|
|
145
|
+
});
|
|
146
|
+
updateNestedTree();
|
|
147
|
+
};
|
|
148
|
+
const collectSelectedIds = (tree2) => {
|
|
149
|
+
const selectedIds = /* @__PURE__ */ new Set();
|
|
150
|
+
const areAllChildrenChecked = (node) => {
|
|
151
|
+
const childNodes = getChildNodesFromNode(node.id);
|
|
152
|
+
return childNodes.length > 0 && childNodes.every((child) => child.state === "checked");
|
|
153
|
+
};
|
|
154
|
+
tree2.forEach((node) => {
|
|
155
|
+
if (node.state === "checked") {
|
|
156
|
+
if (node.parent && getNodeById(node.parent)?.state === "checked") {
|
|
157
|
+
return;
|
|
158
|
+
} else if (areAllChildrenChecked(node)) {
|
|
159
|
+
selectedIds.add(node.id);
|
|
160
|
+
} else {
|
|
161
|
+
selectedIds.add(node.id);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return Array.from(selectedIds);
|
|
166
|
+
};
|
|
167
|
+
function hideSearchedData(data, searchText) {
|
|
168
|
+
data.forEach((node) => {
|
|
169
|
+
const existingNode = tree.value.get(node.id);
|
|
170
|
+
if (existingNode) {
|
|
171
|
+
tree.value.set(node.id, { ...existingNode, hidden: false, expandableClosed: false });
|
|
172
|
+
}
|
|
173
|
+
if (node.children?.length) {
|
|
174
|
+
hideSearchedData(node.children);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function searchedData(data, searchText) {
|
|
179
|
+
if (!tree.value) return;
|
|
180
|
+
toggleHiddenNodes(true);
|
|
181
|
+
hideSearchedData(data, searchText);
|
|
182
|
+
updateNestedTree(searchText);
|
|
183
|
+
}
|
|
184
|
+
const toggleHiddenNodes = (hidden) => {
|
|
185
|
+
if (!tree.value) return;
|
|
186
|
+
tree.value.forEach((node, key) => {
|
|
187
|
+
tree.value.set(key, { ...node, hidden });
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
const toggleExpandableNodes = (expandableClosed) => {
|
|
191
|
+
if (!tree.value) return;
|
|
192
|
+
tree.value.forEach((node, key) => {
|
|
193
|
+
tree.value.set(key, { ...node, expandableClosed });
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
return {
|
|
197
|
+
tree,
|
|
198
|
+
nestedTree,
|
|
199
|
+
initTree,
|
|
200
|
+
setState,
|
|
201
|
+
reset,
|
|
202
|
+
setExpandableClosed,
|
|
203
|
+
collectSelectedIds,
|
|
204
|
+
updateNestedTree,
|
|
205
|
+
searchedData,
|
|
206
|
+
toggleHiddenNodes,
|
|
207
|
+
toggleExpandableNodes
|
|
208
|
+
};
|
|
209
|
+
};
|