nuxt-hs-ui 2.12.7 → 4.0.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.
Files changed (131) hide show
  1. package/README.md +202 -14
  2. package/dist/module.d.mts +3 -4
  3. package/dist/module.json +9 -6
  4. package/dist/module.mjs +109 -99
  5. package/dist/runtime/assets/flatpickr-dark.css +1 -1
  6. package/dist/runtime/assets/main.css +1 -0
  7. package/dist/runtime/assets/tabulator-custom.css +1 -1
  8. package/dist/runtime/components/form/_select/hidden-item-toggle.vue +28 -0
  9. package/dist/runtime/components/form/_select/hidden-item-toggle.vue.d.ts +10 -0
  10. package/dist/runtime/components/form/_select/item-container.vue +63 -0
  11. package/dist/runtime/components/form/_select/item-container.vue.d.ts +19 -0
  12. package/dist/runtime/components/form/_select/item-label.vue +31 -0
  13. package/dist/runtime/components/form/_select/item-label.vue.d.ts +13 -0
  14. package/dist/runtime/components/form/_select/item-row.vue +62 -0
  15. package/dist/runtime/components/form/_select/item-row.vue.d.ts +34 -0
  16. package/dist/runtime/components/form/btn-line-loading.vue +62 -81
  17. package/dist/runtime/components/form/btn-line-loading.vue.d.ts +14 -0
  18. package/dist/runtime/components/form/btn.vue +411 -494
  19. package/dist/runtime/components/form/btn.vue.d.ts +0 -0
  20. package/dist/runtime/components/form/check-box.vue +200 -315
  21. package/dist/runtime/components/form/check-box.vue.d.ts +71 -0
  22. package/dist/runtime/components/form/check-list.vue +234 -364
  23. package/dist/runtime/components/form/check-list.vue.d.ts +99 -0
  24. package/dist/runtime/components/form/combo-box.vue +340 -0
  25. package/dist/runtime/components/form/combo-box.vue.d.ts +69 -0
  26. package/dist/runtime/components/form/datepicker.vue +717 -883
  27. package/dist/runtime/components/form/datepicker.vue.d.ts +122 -0
  28. package/dist/runtime/components/form/input-frame.vue +174 -258
  29. package/dist/runtime/components/form/input-frame.vue.d.ts +88 -0
  30. package/dist/runtime/components/form/radio.vue +451 -614
  31. package/dist/runtime/components/form/radio.vue.d.ts +62 -0
  32. package/dist/runtime/components/form/select-img-icon.vue +38 -53
  33. package/dist/runtime/components/form/select-img-icon.vue.d.ts +15 -0
  34. package/dist/runtime/components/form/select.vue +733 -579
  35. package/dist/runtime/components/form/select.vue.d.ts +63 -0
  36. package/dist/runtime/components/form/text-box.vue +266 -365
  37. package/dist/runtime/components/form/text-box.vue.d.ts +105 -0
  38. package/dist/runtime/components/form/textarea.vue +338 -421
  39. package/dist/runtime/components/form/textarea.vue.d.ts +98 -0
  40. package/dist/runtime/components/form/value-box.vue +512 -641
  41. package/dist/runtime/components/form/value-box.vue.d.ts +128 -0
  42. package/dist/runtime/components/interactive/alert.vue +49 -113
  43. package/dist/runtime/components/interactive/alert.vue.d.ts +30 -0
  44. package/dist/runtime/components/interactive/block-loading.vue +91 -119
  45. package/dist/runtime/components/interactive/block-loading.vue.d.ts +22 -0
  46. package/dist/runtime/components/interactive/dialog.vue +252 -407
  47. package/dist/runtime/components/interactive/dialog.vue.d.ts +3 -0
  48. package/dist/runtime/components/interactive/modal-bg.vue +72 -82
  49. package/dist/runtime/components/interactive/modal-bg.vue.d.ts +11 -0
  50. package/dist/runtime/components/interactive/modal.vue +121 -169
  51. package/dist/runtime/components/interactive/modal.vue.d.ts +38 -0
  52. package/dist/runtime/components/interactive/toast.vue +164 -206
  53. package/dist/runtime/components/interactive/toast.vue.d.ts +3 -0
  54. package/dist/runtime/components/interactive/window-loader.vue +61 -84
  55. package/dist/runtime/components/interactive/window-loader.vue.d.ts +3 -0
  56. package/dist/runtime/components/layout/accordion-down.vue +72 -0
  57. package/dist/runtime/components/layout/accordion-down.vue.d.ts +26 -0
  58. package/dist/runtime/components/layout/accordion.vue +47 -78
  59. package/dist/runtime/components/layout/accordion.vue.d.ts +22 -0
  60. package/dist/runtime/components/layout/aspect-box.vue +29 -58
  61. package/dist/runtime/components/layout/aspect-box.vue.d.ts +29 -0
  62. package/dist/runtime/components/layout/card-item.vue +148 -193
  63. package/dist/runtime/components/layout/card-item.vue.d.ts +0 -0
  64. package/dist/runtime/components/layout/card.vue +27 -42
  65. package/dist/runtime/components/layout/card.vue.d.ts +23 -0
  66. package/dist/runtime/components/layout/container.vue +25 -40
  67. package/dist/runtime/components/layout/container.vue.d.ts +35 -0
  68. package/dist/runtime/components/layout/divider-h.vue +30 -50
  69. package/dist/runtime/components/layout/divider-h.vue.d.ts +18 -0
  70. package/dist/runtime/components/misc/breadcrumb.vue +47 -95
  71. package/dist/runtime/components/misc/breadcrumb.vue.d.ts +22 -0
  72. package/dist/runtime/components/misc/tabulator.vue +122 -190
  73. package/dist/runtime/components/misc/tabulator.vue.d.ts +28 -0
  74. package/dist/runtime/components/misc/view-name-display.vue +53 -68
  75. package/dist/runtime/components/misc/view-name-display.vue.d.ts +14 -0
  76. package/dist/runtime/components/test.vue +13 -0
  77. package/dist/runtime/components/test.vue.d.ts +3 -0
  78. package/dist/runtime/composables/test.d.ts +8 -0
  79. package/dist/runtime/composables/test.js +12 -0
  80. package/dist/runtime/composables/use-hs-dialog.d.ts +3 -20
  81. package/dist/runtime/composables/use-hs-dialog.js +3 -9
  82. package/dist/runtime/composables/use-hs-is-mobile.d.ts +8 -2
  83. package/dist/runtime/composables/use-hs-is-mobile.js +43 -25
  84. package/dist/runtime/composables/use-hs-misc.d.ts +8 -38
  85. package/dist/runtime/composables/use-hs-misc.js +9 -61
  86. package/dist/runtime/composables/use-hs-modal.js +1 -3
  87. package/dist/runtime/composables/use-hs-multi-lang.d.ts +23 -40
  88. package/dist/runtime/composables/use-hs-multi-lang.js +30 -74
  89. package/dist/runtime/composables/use-hs-scroll-lock.d.ts +1 -1
  90. package/dist/runtime/composables/use-hs-scroll-lock.js +2 -1
  91. package/dist/runtime/composables/use-hs-toast.d.ts +2 -2
  92. package/dist/runtime/composables/use-hs-toast.js +12 -4
  93. package/dist/runtime/composables/use-pinia.d.ts +1 -0
  94. package/dist/runtime/composables/use-pinia.js +2 -0
  95. package/dist/runtime/plugin.d.ts +2 -0
  96. package/dist/runtime/plugin.js +4 -0
  97. package/dist/runtime/server/tsconfig.json +3 -3
  98. package/dist/runtime/types/dialog.d.ts +11 -20
  99. package/dist/runtime/types/dialog.js +2 -1
  100. package/dist/runtime/types/flatpickr/default.js +2 -23
  101. package/dist/runtime/types/flatpickr/ja.js +3 -37
  102. package/dist/runtime/types/toast.d.ts +1 -1
  103. package/dist/runtime/utils/dayjs.d.ts +8 -6
  104. package/dist/runtime/utils/dayjs.js +12 -5
  105. package/dist/runtime/utils/modal.d.ts +9 -28
  106. package/dist/runtime/utils/modal.js +7 -36
  107. package/dist/runtime/utils/multi-lang-object.d.ts +2 -2
  108. package/dist/runtime/utils/multi-lang-object.js +1 -5
  109. package/dist/runtime/utils/multi-lang.js +12 -22
  110. package/dist/runtime/utils/object.js +1 -1
  111. package/dist/runtime/utils/select-item.d.ts +3 -1
  112. package/dist/runtime/utils/stop-watch.js +6 -4
  113. package/dist/runtime/utils/string.js +4 -4
  114. package/dist/runtime/utils/tabulator.d.ts +1 -42
  115. package/dist/runtime/utils/tabulator.js +2 -99
  116. package/dist/runtime/utils/theme.d.ts +20 -20
  117. package/dist/runtime/utils/theme.js +180 -30
  118. package/dist/runtime/utils/tv.d.ts +1 -101
  119. package/dist/runtime/utils/tv.js +0 -22
  120. package/dist/types.d.mts +3 -1
  121. package/package.json +61 -119
  122. package/dist/module.cjs +0 -5
  123. package/dist/module.d.ts +0 -16
  124. package/dist/runtime/assets/vue-select.css +0 -1
  125. package/dist/runtime/components/misc/view-name-display-target.vue +0 -39
  126. package/dist/runtime/plugin/v-select.d.ts +0 -2
  127. package/dist/runtime/plugin/v-select.js +0 -5
  128. package/dist/runtime/style.css +0 -22
  129. package/dist/runtime/tailwind.css +0 -78
  130. package/dist/runtime/types/app.config.d.ts +0 -5
  131. package/dist/types.d.ts +0 -1
@@ -0,0 +1,26 @@
1
+ import { type ClassType } from '../../utils/class-style.js';
2
+ type Props = {
3
+ class?: ClassType;
4
+ open: boolean;
5
+ span?: number;
6
+ };
7
+ declare var __VLS_1: {};
8
+ type __VLS_Slots = {} & {
9
+ default?: (props: typeof __VLS_1) => any;
10
+ };
11
+ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
+ closed: () => any;
13
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
14
+ onClosed?: (() => any) | undefined;
15
+ }>, {
16
+ class: ClassType;
17
+ span: number;
18
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -1,86 +1,55 @@
1
- <script setup lang="ts">
2
- /* ----------------------------------------------------------------------------
3
- // src\runtime\components\layout\accordion.vue
4
- // ----------------------------------------------------------------------------
5
- // Accordion
6
- // AccordionAccordion
7
- ----------------------------------------------------------------------------- */
8
-
9
- // [ NUXT ]
10
- import { computed, ref, watch, nextTick } from "#imports";
11
- // [ tailwind ]
12
- import { twMerge } from "tailwind-merge";
13
- // [ utils ]
14
- import { type ClassType, ClassTypeToString } from "../../utils/class-style";
15
- // ----------------------------------------------------------------------------
16
- // ----------------------------------------------------------------------------
17
- // [ Props ]
18
- type Props = {
19
- class?: ClassType;
20
- open: boolean;
21
- span?: number;
22
- };
23
- const props = withDefaults(defineProps<Props>(), {
24
- class: "",
25
- span: 300,
26
- });
27
-
28
- const innerHidden = ref(!props.open);
29
- watch(
30
- () => props.open,
31
- (v) => {
32
- //
33
- if (v) {
34
- setTimeout(() => {
35
- if (props.open) {
36
- innerHidden.value = !v;
37
- }
38
- }, props.span);
39
- } else {
40
- nextTick(() => {
41
- innerHidden.value = !v;
42
- });
43
- }
44
- }
45
- );
46
-
47
- const baseClass = [
48
- //
49
- "w-full",
50
- ];
51
-
52
- const classStyle = computed(() => {
53
- return twMerge(baseClass, ClassTypeToString(props.class));
54
- });
55
- const classOverflow = [
56
- //
57
- "overflow-y-hidden",
58
- ];
59
- const overflowClass = computed(() => {
60
- if (innerHidden.value) return classOverflow;
61
- return "";
62
- });
63
- // ----------------------------------------------------------------------------
64
- </script>
65
-
66
- <template>
67
- <div
68
- class="Accordion"
69
- :class="[{ open: open }, classStyle]"
70
- :style="`--hsui-accordion-span:${props.span}ms`"
71
- >
72
- <!-- :aria-hidden="!props.open" -->
73
- <div :class="overflowClass"><slot /></div>
74
- </div>
75
- </template>
76
-
1
+ <script setup>
2
+ import { computed, ref, watch, nextTick } from "#imports";
3
+ import { twMerge } from "tailwind-merge";
4
+ import { ClassTypeToString } from "../../utils/class-style";
5
+ const props = defineProps({
6
+ class: { type: [String, Object, Array], required: false, default: "" },
7
+ open: { type: Boolean, required: true },
8
+ span: { type: Number, required: false, default: 300 }
9
+ });
10
+ const innerHidden = ref(!props.open);
11
+ watch(
12
+ () => props.open,
13
+ (v) => {
14
+ if (v) {
15
+ setTimeout(() => {
16
+ if (props.open) {
17
+ innerHidden.value = !v;
18
+ }
19
+ }, props.span);
20
+ } else {
21
+ nextTick(() => {
22
+ innerHidden.value = !v;
23
+ });
24
+ }
25
+ }
26
+ );
27
+ const classStyle = computed(() => {
28
+ return twMerge([props.open ? "open" : ""], ClassTypeToString(props.class));
29
+ });
30
+ const overflowClass = computed(() => {
31
+ return [innerHidden.value ? "overflow-y-hidden" : ""];
32
+ });
33
+ </script>
34
+
35
+ <template>
36
+ <div
37
+ class="Accordion"
38
+ :class="classStyle"
39
+ :style="`--hsui-accordion-span:${props.span}ms`"
40
+ :inert="!props.open"
41
+ >
42
+ <div :class="overflowClass" class="overflow-y-hidden"><slot /></div>
43
+ </div>
44
+ </template>
45
+
77
46
  <style scoped>
78
47
  .Accordion {
79
48
  display: grid;
80
49
  grid-template-rows: 0fr;
81
- transition: grid-template-rows var(--hsui-accordion-span);
50
+ transition: grid-template-rows var(--hsui-accordion-span) ease-in-out;
82
51
  }
83
52
  .Accordion.open {
84
53
  grid-template-rows: 1fr;
85
54
  }
86
- </style>
55
+ </style>
@@ -0,0 +1,22 @@
1
+ import { type ClassType } from '../../utils/class-style.js';
2
+ type Props = {
3
+ class?: ClassType;
4
+ open: boolean;
5
+ span?: number;
6
+ };
7
+ declare var __VLS_1: {};
8
+ type __VLS_Slots = {} & {
9
+ default?: (props: typeof __VLS_1) => any;
10
+ };
11
+ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
12
+ class: ClassType;
13
+ span: number;
14
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
16
+ declare const _default: typeof __VLS_export;
17
+ export default _default;
18
+ type __VLS_WithSlots<T, S> = T & {
19
+ new (): {
20
+ $slots: S;
21
+ };
22
+ };
@@ -1,60 +1,31 @@
1
- <script setup lang="ts">
2
- /* ----------------------------------------------------------------------------
3
- // src\runtime\components\layout\aspect-box.vue
4
- // ----------------------------------------------------------------------------
5
- // AspectBox
6
- // AspectBoxAspectBox
7
- ----------------------------------------------------------------------------- */
8
- // [ tailwind ]
9
- import { twMerge } from "tailwind-merge";
10
- // [ NUXT ]
11
- import { computed } from "#imports";
12
- // [ utils ]
13
- import { type ClassType, ClassTypeToString } from "../../utils/class-style";
14
- import { Int } from "../../utils/number";
15
- // ----------------------------------------------------------------------------
16
- // ----------------------------------------------------------------------------
17
- type Props = {
18
- class?: ClassType;
19
- /**
20
- * Aspect ratio
21
- * - Example:
22
- * - 1:1
23
- * - 3:2 <- Default
24
- * - 4:3
25
- * - 16:9
26
- */
27
- rate?: string;
28
- };
29
-
30
- const props = withDefaults(defineProps<Props>(), {
31
- class: "",
32
- rate: "3:2",
33
- });
34
- const aspectRate = computed(() => {
35
- const left = Int(props.rate.replace(/^(\d*):(\d*)$/, "$1"));
36
- const right = Int(props.rate.replace(/^(\d*):(\d*)$/, "$2"));
37
- if (left === 0 || right === 0) return "100";
38
- return ((right / left) * 100).toFixed(3);
39
- });
40
-
41
- const classStyle = computed(() => {
42
- return twMerge(`relative block`, ClassTypeToString(props.class));
43
- });
44
- </script>
45
-
46
- <template>
47
- <div
48
- class="UiAspectContainer"
49
- :class="classStyle"
50
- :style="` --aspect-rate: ${aspectRate}%;`"
51
- >
52
- <div>
53
- <slot />
54
- </div>
55
- </div>
56
- </template>
57
-
1
+ <script setup>
2
+ import { twMerge } from "tailwind-merge";
3
+ import { computed } from "#imports";
4
+ import { ClassTypeToString } from "../../utils/class-style";
5
+ import { Int } from "../../utils/number";
6
+ const props = defineProps({
7
+ class: { type: [String, Object, Array], required: false, default: "" },
8
+ rate: { type: String, required: false, default: "3:2" }
9
+ });
10
+ const aspectRate = computed(() => {
11
+ const left = Int(props.rate.replace(/^(\d*):(\d*)$/, "$1"));
12
+ const right = Int(props.rate.replace(/^(\d*):(\d*)$/, "$2"));
13
+ if (left === 0 || right === 0) return "100";
14
+ return (right / left * 100).toFixed(3);
15
+ });
16
+ const classStyle = computed(() => {
17
+ return twMerge(`relative block`, ClassTypeToString(props.class));
18
+ });
19
+ </script>
20
+
21
+ <template>
22
+ <div class="UiAspectContainer" :class="classStyle" :style="` --aspect-rate: ${aspectRate}%;`">
23
+ <div>
24
+ <slot />
25
+ </div>
26
+ </div>
27
+ </template>
28
+
58
29
  <style scoped>
59
30
  .UiAspectContainer {
60
31
  --aspect-rate: 66.66%;
@@ -68,4 +39,4 @@ const classStyle = computed(() => {
68
39
  position: absolute;
69
40
  inset: 0 0 0 0;
70
41
  }
71
- </style>
42
+ </style>
@@ -0,0 +1,29 @@
1
+ import { type ClassType } from '../../utils/class-style.js';
2
+ type Props = {
3
+ class?: ClassType;
4
+ /**
5
+ * Aspect ratio
6
+ * - Example:
7
+ * - 1:1
8
+ * - 3:2 <- Default
9
+ * - 4:3
10
+ * - 16:9
11
+ */
12
+ rate?: string;
13
+ };
14
+ declare var __VLS_1: {};
15
+ type __VLS_Slots = {} & {
16
+ default?: (props: typeof __VLS_1) => any;
17
+ };
18
+ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
19
+ class: ClassType;
20
+ rate: string;
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
23
+ declare const _default: typeof __VLS_export;
24
+ export default _default;
25
+ type __VLS_WithSlots<T, S> = T & {
26
+ new (): {
27
+ $slots: S;
28
+ };
29
+ };
@@ -1,193 +1,148 @@
1
- <script lang="ts">
2
- /* ----------------------------------------------------------------------------
3
- // src\runtime\components\layout\card-item.vue
4
- // ----------------------------------------------------------------------------
5
- // CardItem
6
- // CardItemCardItem
7
- ----------------------------------------------------------------------------- */
8
-
9
- // [ utils ]
10
- import { tv } from "../../utils/tv";
11
- import { Theme } from "../../utils/theme";
12
- import { ObjectKeyToMap } from "../../utils/object";
13
- const cardItemTv = tv({
14
- slots: {
15
- base: [
16
- //
17
- `p-2`,
18
- "bg-[var(--main-color)]",
19
- ],
20
- btn: [`border-[1px]`],
21
- },
22
- variants: {
23
- variant: {
24
- header: {
25
- base: [`flex justify-between items-center`],
26
- },
27
- body: {
28
- base: [``],
29
- },
30
- footer: {
31
- base: [`flex justify-between items-center`],
32
- },
33
- },
34
- scroll: {
35
- true: {
36
- base: "overflow-y-auto overflow-x-hidden flex-1",
37
- },
38
- false: {
39
- base: "flex-y-none",
40
- },
41
- },
42
- size: {
43
- xs: {
44
- base: [`p-1`],
45
- btn: ["text-sm h-[30px] w-[30px]"],
46
- },
47
- s: {
48
- base: [`p-1 ps-2`],
49
- btn: ["text-sm h-[36px] w-[36px]"],
50
- },
51
- m: { btn: ["text-base h-[44px] w-[44px]"] },
52
- l: { btn: ["text-base h-[48px] w-[48px]"] },
53
- xl: { btn: ["text-lg h-[60px] w-[60px]"] },
54
- },
55
- theme: ObjectKeyToMap(Theme, ""),
56
- },
57
- compoundVariants: [
58
- ...Object.keys(Theme).map((theme) => {
59
- return {
60
- theme: theme,
61
- class: {
62
- base: [
63
- ["back", "white", "warn"].includes(theme)
64
- ? `text-black `
65
- : "text-white ",
66
- ],
67
- },
68
- } as any;
69
- }),
70
- ],
71
- });
72
- </script>
73
-
74
- <script setup lang="ts">
75
- /* ----------------------------------------------------------------------------
76
- // src\runtime\components\layout\card-item.vue
77
- // ----------------------------------------------------------------------------
78
- // CardItem
79
- // CardItemCardItem
80
- ----------------------------------------------------------------------------- */
81
-
82
- // [ NUXT ]
83
- import { computed } from "#imports";
84
- // [ utils ]
85
- import { type ClassType, ClassTypeToString } from "../../utils/class-style";
86
- import { GetGolorCode } from "../../utils/theme";
87
- // [ Components ]
88
- import Btn from "../form/btn.vue";
89
- import Accordion from "./accordion.vue";
90
- // ----------------------------------------------------------------------------
91
- // ----------------------------------------------------------------------------
92
- interface Props {
93
- class?: ClassType;
94
- variant?: "header" | "body" | "footer";
95
- size?: "xs" | "s" | "m" | "l" | "xl";
96
- accordion?: boolean | undefined;
97
- theme?: Theme | undefined;
98
- scroll?: boolean;
99
- open?: boolean | undefined;
100
- cross?: boolean;
101
- // btn?: "cross" | "accordion" | undefined;
102
- }
103
- const props = withDefaults(defineProps<Props>(), {
104
- class: "",
105
- variant: "body",
106
- size: "m",
107
- theme: undefined,
108
- scroll: false,
109
- accordion: undefined,
110
- open: undefined,
111
- btn: undefined,
112
- cross: false,
113
- });
114
- type Emits = {
115
- ref: [e: HTMLElement];
116
- "update:open": [value: boolean];
117
- "bg-click": [];
118
- toggle: [];
119
- };
120
- const emit = defineEmits<Emits>();
121
-
122
- // ----------------------------------------------------------------------------
123
- const bgTheme = computed(() => {
124
- if (props.theme !== undefined) return props.theme;
125
- if (props.variant == "header") return Theme.main1;
126
- if (props.variant == "footer") return Theme.main2;
127
- return Theme.back;
128
- });
129
- const styleMain = computed(() => {
130
- return [
131
- //
132
- `--main-color:${GetGolorCode(bgTheme.value)};`,
133
- ];
134
- });
135
- const classTv = computed(() => {
136
- return cardItemTv({
137
- variant: props.variant,
138
- scroll: props.scroll,
139
- theme: bgTheme.value,
140
- size: props.size,
141
- });
142
- });
143
- const classTvBase = computed(() => {
144
- return classTv.value.base({
145
- class: ClassTypeToString(props.class),
146
- });
147
- });
148
- const classTvBtn = computed(() => {
149
- return classTv.value.btn();
150
- });
151
- </script>
152
-
153
- <template>
154
- <template v-if="props.accordion === undefined">
155
- <div
156
- :ref="(e:any) => emit('ref', e)"
157
- :style="styleMain"
158
- :class="classTvBase"
159
- @click.stop="emit('bg-click')"
160
- >
161
- <slot />
162
- <Btn
163
- v-if="props.open !== undefined || props.cross"
164
- theme="white"
165
- variant="outlined"
166
- :class="classTvBtn"
167
- :size="props.size"
168
- @click.stop="
169
- emit('update:open', !props.open);
170
- emit('toggle');
171
- "
172
- >
173
- <i
174
- v-if="props.open !== undefined && !props.cross"
175
- class="fa-solid fa-chevron-down"
176
- :class="{ 'rotate-180': props.open }"
177
- />
178
- <i v-else-if="props.cross" class="fa-solid fa-xmark" />
179
- </Btn>
180
- </div>
181
- </template>
182
- <template v-else>
183
- <Accordion :open="props.accordion">
184
- <div
185
- :ref="(e:any) => emit('ref', e)"
186
- :style="styleMain"
187
- :class="classTvBase"
188
- >
189
- <slot />
190
- </div>
191
- </Accordion>
192
- </template>
193
- </template>
1
+ <script>
2
+ import { tv } from "../../utils/tv";
3
+ import { Theme } from "../../utils/theme";
4
+ import { ObjectKeyToMap } from "../../utils/object";
5
+ const cardItemTv = tv({
6
+ slots: {
7
+ base: [
8
+ //
9
+ `p-2 relative`,
10
+ "bg-[var(--main-color)]"
11
+ ],
12
+ btn: [`border-[1px]`]
13
+ },
14
+ variants: {
15
+ variant: {
16
+ header: {
17
+ base: [`flex justify-between items-center`]
18
+ },
19
+ body: {
20
+ base: [``]
21
+ },
22
+ footer: {
23
+ base: [`flex justify-between items-center`]
24
+ }
25
+ },
26
+ scroll: {
27
+ true: {
28
+ base: "overflow-y-auto overflow-x-hidden flex-1"
29
+ },
30
+ false: {
31
+ base: "flex-y-none"
32
+ }
33
+ },
34
+ size: {
35
+ xs: {
36
+ base: [`p-1`],
37
+ btn: ["text-sm h-[30px] w-[30px]"]
38
+ },
39
+ s: {
40
+ base: [`p-1 ps-2`],
41
+ btn: ["text-sm h-[36px] w-[36px]"]
42
+ },
43
+ m: { btn: ["text-base h-[44px] w-[44px]"] },
44
+ l: { btn: ["text-base h-[48px] w-[48px]"] },
45
+ xl: { btn: ["text-lg h-[60px] w-[60px]"] }
46
+ },
47
+ theme: ObjectKeyToMap(Theme, "")
48
+ },
49
+ compoundVariants: [
50
+ ...Object.keys(Theme).map((theme) => {
51
+ return {
52
+ theme,
53
+ class: {
54
+ base: [["back1", "white", "warn"].includes(theme) ? `` : "text-white "]
55
+ }
56
+ };
57
+ })
58
+ ]
59
+ });
60
+ </script>
61
+
62
+ <script setup>
63
+ import { computed, useId } from "#imports";
64
+ import { ClassTypeToString } from "../../utils/class-style";
65
+ import { GetColorCode } from "../../utils/theme";
66
+ import { useHsFocus } from "../../composables/use-hs-focus";
67
+ import { useHsPinia } from "../../composables/use-pinia";
68
+ import Btn from "../form/btn.vue";
69
+ import Accordion from "./accordion.vue";
70
+ const props = defineProps({
71
+ class: { type: [String, Object, Array], required: false, default: "" },
72
+ variant: { type: String, required: false, default: "body" },
73
+ size: { type: String, required: false, default: "m" },
74
+ accordion: { type: Boolean, required: false, skipCheck: true, default: void 0 },
75
+ theme: { type: null, required: false, default: void 0 },
76
+ scroll: { type: Boolean, required: false, default: false },
77
+ open: { type: Boolean, required: false, skipCheck: true, default: void 0 },
78
+ cross: { type: Boolean, required: false, default: false }
79
+ });
80
+ const emit = defineEmits(["ref", "update:open", "toggle"]);
81
+ const uid = useId();
82
+ const hsFocus = useHsFocus(useHsPinia());
83
+ const bgTheme = computed(() => {
84
+ if (props.theme !== void 0) return props.theme;
85
+ if (props.variant == "header") return Theme.main1;
86
+ if (props.variant == "footer") return Theme.main2;
87
+ return Theme.back1;
88
+ });
89
+ const styleMain = computed(() => {
90
+ return [
91
+ //
92
+ `--main-color:${GetColorCode(bgTheme.value)};`
93
+ ];
94
+ });
95
+ const classTv = computed(() => {
96
+ return cardItemTv({
97
+ variant: props.variant,
98
+ scroll: props.scroll,
99
+ theme: bgTheme.value,
100
+ size: props.size
101
+ });
102
+ });
103
+ const classTvBase = computed(() => {
104
+ return classTv.value.base({
105
+ class: ClassTypeToString(props.class)
106
+ });
107
+ });
108
+ const classTvBtn = computed(() => {
109
+ return classTv.value.btn();
110
+ });
111
+ const toggleOpen = () => {
112
+ if (hsFocus.state.id !== uid) {
113
+ hsFocus.state.id = uid;
114
+ }
115
+ emit("update:open", !props.open);
116
+ emit("toggle");
117
+ };
118
+ </script>
119
+
120
+ <template>
121
+ <template v-if="props.accordion === void 0">
122
+ <div :ref="(e) => emit('ref', e)" :style="styleMain" :class="classTvBase">
123
+ <slot />
124
+ <Btn
125
+ v-if="props.open !== void 0 || props.cross"
126
+ theme="white"
127
+ variant="outlined"
128
+ :class="classTvBtn"
129
+ :size="props.size"
130
+ @click.stop="toggleOpen"
131
+ >
132
+ <i
133
+ v-if="props.open !== void 0 && !props.cross"
134
+ class="fa-solid fa-chevron-down"
135
+ :class="{ 'rotate-180': props.open }"
136
+ />
137
+ <i v-else-if="props.cross" class="fa-solid fa-xmark" />
138
+ </Btn>
139
+ </div>
140
+ </template>
141
+ <template v-else>
142
+ <Accordion :open="props.accordion">
143
+ <div :ref="(e) => emit('ref', e)" :style="styleMain" :class="classTvBase">
144
+ <slot />
145
+ </div>
146
+ </Accordion>
147
+ </template>
148
+ </template>