nuxt-hs-ui 1.0.10 → 2.0.2

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 (112) hide show
  1. package/README.md +11 -4
  2. package/dist/module.d.mts +10 -2
  3. package/dist/module.d.ts +10 -2
  4. package/dist/module.json +5 -2
  5. package/dist/module.mjs +90 -51
  6. package/dist/runtime/assets/flatpickr-dark.css +1 -0
  7. package/dist/runtime/assets/flatpickr-month-select-style.css +1 -0
  8. package/dist/runtime/assets/tabulator-custom.css +1 -0
  9. package/dist/runtime/assets/tabulator.css +1 -0
  10. package/dist/runtime/assets/vue-select.css +1 -0
  11. package/dist/runtime/components/{hs-fc/btn/line-loading.vue → form/btn-line-loading.vue} +28 -42
  12. package/dist/runtime/components/form/btn.vue +488 -0
  13. package/dist/runtime/components/form/check-box.vue +352 -0
  14. package/dist/runtime/components/form/check-list.vue +354 -0
  15. package/dist/runtime/components/form/datepicker copy.vue +770 -0
  16. package/dist/runtime/components/form/datepicker.vue +897 -0
  17. package/dist/runtime/components/form/input-frame.vue +272 -0
  18. package/dist/runtime/components/form/radio.vue +685 -0
  19. package/dist/runtime/components/form/select-img-icon.vue +53 -0
  20. package/dist/runtime/components/form/select.vue +438 -0
  21. package/dist/runtime/components/form/text-box.vue +375 -0
  22. package/dist/runtime/components/form/textarea.vue +466 -0
  23. package/dist/runtime/components/form/value-box.vue +681 -0
  24. package/dist/runtime/components/interactive/alert.vue +113 -0
  25. package/dist/runtime/components/{hs-ui → interactive}/block-loading.vue +42 -59
  26. package/dist/runtime/components/{hs-ui/dialog/index.vue → interactive/dialog.vue} +132 -127
  27. package/dist/runtime/components/interactive/modal-bg.vue +82 -0
  28. package/dist/runtime/components/interactive/modal.vue +143 -0
  29. package/dist/runtime/components/{hs-ui/toast/index.vue → interactive/toast.vue} +76 -109
  30. package/dist/runtime/components/{hs-ui → interactive}/window-loader.vue +12 -9
  31. package/dist/runtime/components/{hs-ui → layout}/accordion.vue +21 -30
  32. package/dist/runtime/components/layout/aspect-box.vue +71 -0
  33. package/dist/runtime/components/layout/card-item.vue +193 -0
  34. package/dist/runtime/components/layout/card.vue +42 -0
  35. package/dist/runtime/components/layout/container.vue +40 -0
  36. package/dist/runtime/components/misc/breadcrumb.vue +96 -0
  37. package/dist/runtime/components/misc/tabulator.vue +187 -0
  38. package/dist/runtime/components/misc/view-name-display-target.vue +39 -0
  39. package/dist/runtime/components/misc/view-name-display.vue +90 -0
  40. package/dist/runtime/composables/use-hs-dialog.d.ts +40 -0
  41. package/dist/runtime/composables/{use-hs-ui-dialog.js → use-hs-dialog.js} +15 -10
  42. package/dist/runtime/composables/{use-hs-form-focus.d.ts → use-hs-focus.d.ts} +1 -1
  43. package/dist/runtime/composables/{use-hs-form-focus.js → use-hs-focus.js} +2 -4
  44. package/dist/runtime/composables/use-hs-misc.d.ts +22 -0
  45. package/dist/runtime/composables/use-hs-misc.js +62 -0
  46. package/dist/runtime/composables/use-hs-modal.d.ts +31 -0
  47. package/dist/runtime/{components/hs-ui/modal/use-ui-modal.js → composables/use-hs-modal.js} +18 -16
  48. package/dist/runtime/composables/use-hs-multi-lang.d.ts +14 -6
  49. package/dist/runtime/composables/use-hs-multi-lang.js +44 -11
  50. package/dist/runtime/composables/{use-hs-ui-toast.d.ts → use-hs-toast.d.ts} +3 -3
  51. package/dist/runtime/composables/{use-hs-ui-toast.js → use-hs-toast.js} +4 -5
  52. package/dist/runtime/composables/{use-hs-ui-window-loader.d.ts → use-hs-window-loader.d.ts} +1 -1
  53. package/dist/runtime/composables/{use-hs-ui-window-loader.js → use-hs-window-loader.js} +1 -2
  54. package/dist/runtime/plugin/v-select.d.ts +2 -0
  55. package/dist/runtime/plugin/v-select.js +5 -0
  56. package/dist/runtime/style.css +22 -1
  57. package/dist/runtime/tailwind.css +78 -0
  58. package/dist/runtime/types/app.config.d.ts +5 -0
  59. package/dist/runtime/{components/hs-ui/dialog/index.type.d.ts → types/dialog.d.ts} +3 -3
  60. package/dist/runtime/{components/hs-ui/toast/index.type.d.ts → types/toast.d.ts} +1 -2
  61. package/dist/runtime/{components/hs-ui/toast/index.type.js → types/toast.js} +0 -1
  62. package/dist/runtime/utils/class-style.d.ts +6 -0
  63. package/dist/runtime/utils/class-style.js +27 -0
  64. package/dist/runtime/utils/com.d.ts +6 -0
  65. package/dist/runtime/{lib → utils}/com.js +1 -4
  66. package/dist/runtime/utils/dayjs.d.ts +53 -0
  67. package/dist/runtime/utils/dayjs.js +124 -0
  68. package/dist/runtime/utils/float.d.ts +2 -0
  69. package/dist/runtime/utils/float.js +35 -0
  70. package/dist/runtime/utils/multi-lang-object.d.ts +17 -0
  71. package/dist/runtime/utils/multi-lang-object.js +34 -0
  72. package/dist/runtime/{lib → utils}/multi-lang.d.ts +1 -1
  73. package/dist/runtime/{lib → utils}/multi-lang.js +31 -27
  74. package/dist/runtime/{lib → utils}/number.d.ts +2 -4
  75. package/dist/runtime/{lib → utils}/number.js +29 -69
  76. package/dist/runtime/utils/object.d.ts +46 -0
  77. package/dist/runtime/utils/object.js +107 -0
  78. package/dist/runtime/utils/select-item.d.ts +31 -0
  79. package/dist/runtime/utils/select.d.ts +14 -0
  80. package/dist/runtime/utils/select.js +36 -0
  81. package/dist/runtime/utils/string.d.ts +39 -0
  82. package/dist/runtime/utils/string.js +125 -0
  83. package/dist/runtime/utils/tabulator.d.ts +108 -0
  84. package/dist/runtime/utils/tabulator.js +296 -0
  85. package/dist/runtime/utils/theme.d.ts +21 -0
  86. package/dist/runtime/utils/theme.js +31 -0
  87. package/dist/runtime/utils/tv.d.ts +101 -0
  88. package/dist/runtime/utils/tv.js +26 -0
  89. package/dist/runtime/utils/wareki.d.ts +3 -0
  90. package/dist/runtime/utils/wareki.js +106 -0
  91. package/dist/types.d.mts +1 -17
  92. package/dist/types.d.ts +1 -17
  93. package/package.json +99 -37
  94. package/dist/runtime/components/hs-fc/btn/index.vue +0 -510
  95. package/dist/runtime/components/hs-ui/aspect-box.vue +0 -83
  96. package/dist/runtime/components/hs-ui/card-item.vue +0 -141
  97. package/dist/runtime/components/hs-ui/card.vue +0 -54
  98. package/dist/runtime/components/hs-ui/container.vue +0 -50
  99. package/dist/runtime/components/hs-ui/modal/bg.vue +0 -94
  100. package/dist/runtime/components/hs-ui/modal/index.vue +0 -206
  101. package/dist/runtime/components/hs-ui/modal/use-ui-modal.d.ts +0 -20
  102. package/dist/runtime/components/v-test.vue +0 -60
  103. package/dist/runtime/composables/use-hs-ui-dialog.d.ts +0 -22
  104. package/dist/runtime/lib/class-style.d.ts +0 -8
  105. package/dist/runtime/lib/class-style.js +0 -59
  106. package/dist/runtime/lib/com.d.ts +0 -14
  107. package/dist/runtime/lib/prefix.d.ts +0 -2
  108. package/dist/runtime/lib/prefix.js +0 -17
  109. package/dist/runtime/lib/theme.d.ts +0 -2
  110. package/dist/runtime/lib/theme.js +0 -21
  111. /package/dist/runtime/{components/hs-ui/dialog/index.type.js → types/dialog.js} +0 -0
  112. /package/dist/runtime/{components/hs-fc/hoge → utils/select-item.js} +0 -0
@@ -0,0 +1,71 @@
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
+
58
+ <style scoped>
59
+ .UiAspectContainer {
60
+ --aspect-rate: 66.66%;
61
+ }
62
+ .UiAspectContainer::before {
63
+ content: "";
64
+ display: block;
65
+ padding-top: var(--aspect-rate);
66
+ }
67
+ .UiAspectContainer > div {
68
+ position: absolute;
69
+ inset: 0 0 0 0;
70
+ }
71
+ </style>
@@ -0,0 +1,193 @@
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>
@@ -0,0 +1,42 @@
1
+ <script setup lang="ts">
2
+ /* ----------------------------------------------------------------------------
3
+ // src\runtime\components\layout\card.vue
4
+ // ----------------------------------------------------------------------------
5
+ // Card
6
+ // CardCard
7
+ ----------------------------------------------------------------------------- */
8
+
9
+ // [ NUXT ]
10
+ import { computed } from "#imports";
11
+ // [ tailwind ]
12
+ import { twMerge } from "tailwind-merge";
13
+ // [ utils ]
14
+ import { type ClassType, ClassTypeToString } from "../../utils/class-style";
15
+ // ----------------------------------------------------------------------------
16
+ // ----------------------------------------------------------------------------
17
+ interface Props {
18
+ class?: ClassType;
19
+ }
20
+ const props = withDefaults(defineProps<Props>(), {
21
+ class: "",
22
+ });
23
+
24
+ const baseClass = [
25
+ //
26
+ "relative",
27
+ "flex",
28
+ "flex-col",
29
+ "border-[2px]",
30
+ "border-white",
31
+ "shadow shadow-[0px_0px_4px_0px_#000]",
32
+ ];
33
+ const classStyle = computed(() => {
34
+ return twMerge(baseClass, ClassTypeToString(props.class));
35
+ });
36
+ </script>
37
+
38
+ <template>
39
+ <div :class="classStyle">
40
+ <slot />
41
+ </div>
42
+ </template>
@@ -0,0 +1,40 @@
1
+ <script setup lang="ts">
2
+ /* ----------------------------------------------------------------------------
3
+ // src\runtime\components\layout\container.vue
4
+ // ----------------------------------------------------------------------------
5
+ // Container
6
+ // ContainerContainer
7
+ ----------------------------------------------------------------------------- */
8
+
9
+ // [ NUXT ]
10
+ import { computed } from "#imports";
11
+ // [ tailwind ]
12
+ import { twMerge } from "tailwind-merge";
13
+ // [ utils ]
14
+ import { type ClassType, ClassTypeToString } from "../../utils/class-style";
15
+ // ----------------------------------------------------------------------------
16
+ // ----------------------------------------------------------------------------
17
+ interface Props {
18
+ class?: ClassType;
19
+ fluid?: boolean;
20
+ }
21
+ const props = withDefaults(defineProps<Props>(), {
22
+ class: "",
23
+ fluid: false,
24
+ });
25
+ const classStyle = computed(() => {
26
+ return twMerge(
27
+ "mx-auto px-2",
28
+ props.fluid
29
+ ? "w-full"
30
+ : "max-w-full xs:max-w-[600px] md:max-w-[700px] lg:max-w-[950px] xl:max-w-[1200px] 2xl:max-w-[1450px]",
31
+ ClassTypeToString(props.class)
32
+ );
33
+ });
34
+ </script>
35
+
36
+ <template>
37
+ <div :class="classStyle">
38
+ <slot />
39
+ </div>
40
+ </template>
@@ -0,0 +1,96 @@
1
+ <script setup lang="ts">
2
+ /* ----------------------------------------------------------------------------
3
+ // src\runtime\components\misc\breadcrumb.vue
4
+ // ----------------------------------------------------------------------------
5
+ // Breadcrumb
6
+ // BreadcrumbBreadcrumb
7
+ ----------------------------------------------------------------------------- */
8
+
9
+ // [ tailwind ]
10
+ import { twMerge } from "tailwind-merge";
11
+ // [ NUXT ]
12
+ import { computed } from "#imports";
13
+ // [ utils ]
14
+ import { type ClassType, ClassTypeToString } from "../../utils/class-style";
15
+
16
+ import Card from "../layout/card.vue";
17
+ import CardItem from "../layout/card-item.vue";
18
+ // ----------------------------------------------------------------------------
19
+
20
+ interface Props {
21
+ class?: ClassType;
22
+ links: { label: string; to?: string }[];
23
+ }
24
+ const props = withDefaults(defineProps<Props>(), {
25
+ class: "",
26
+ });
27
+
28
+ const classStyle = computed(() => {
29
+ return twMerge(`w-full min-w-0`, ClassTypeToString(props.class));
30
+ });
31
+ </script>
32
+
33
+ <template>
34
+ <Card :class="classStyle">
35
+ <CardItem
36
+ class="px-1 py-1 sm:px-4 sm:py-1 min-w-0"
37
+ theme="back"
38
+ variant="body"
39
+ >
40
+ <div class="flex flex-wrap gap-[2px] sm:gap-[4px]">
41
+ <template v-for="(item, index) in props.links" :key="index">
42
+ <div class="truncate min-w-0 w-full sm:w-auto">
43
+ <NuxtLink
44
+ v-if="item.to !== undefined"
45
+ :to="item.to"
46
+ class="text-main1"
47
+ :class="{ hasBefore: index !== 0 }"
48
+ >
49
+ {{ item.label }}
50
+ </NuxtLink>
51
+ <span
52
+ v-else
53
+ class="text-gray-600"
54
+ :class="{ hasBefore: index !== 0 }"
55
+ >
56
+ {{ item.label }}
57
+ </span>
58
+ </div>
59
+ </template>
60
+ </div>
61
+ </CardItem>
62
+ </Card>
63
+ </template>
64
+
65
+ <style scoped>
66
+ .hasBefore {
67
+ padding-left: calc(1em + 4px);
68
+ }
69
+
70
+ .hasBefore::before {
71
+ content: "\f054";
72
+ font-family: "Font Awesome 6 Free";
73
+ font-weight: 900;
74
+ color: #4b5563;
75
+ position: absolute;
76
+ inset: 0 auto 0 0;
77
+ width: 1em;
78
+ display: flex;
79
+ justify-content: center;
80
+ align-items: center;
81
+ }
82
+
83
+ .hov::before {
84
+ content: "";
85
+ position: absolute;
86
+ inset: auto auto 0 0;
87
+ width: 0;
88
+ height: 1px;
89
+ background-color: white;
90
+ transition: all 300ms ease;
91
+ }
92
+
93
+ .hov:hover::before {
94
+ width: 100%;
95
+ }
96
+ </style>
@@ -0,0 +1,187 @@
1
+ <script setup lang="ts">
2
+ /* ----------------------------------------------------------------------------
3
+ // src\runtime\components\misc\tabulator.vue
4
+ // ----------------------------------------------------------------------------
5
+ // Tabulator
6
+ // TabulatorTabulator
7
+ ----------------------------------------------------------------------------- */
8
+
9
+ // ----------------------------------------------------------------------------
10
+ // [ node_modules ]
11
+ import { TabulatorFull as Tabulator } from "tabulator-tables";
12
+ // [ NUXT ]
13
+ import { ref, watch, computed, onMounted, onUnmounted } from "#imports";
14
+ // ----------------------------------------------------------------------------
15
+ // [ utils ]
16
+ import { Option } from "../../utils/tabulator";
17
+ // [ composables ]
18
+ import { useHsMultiLang } from "../../composables/use-hs-multi-lang";
19
+ // ----------------------------------------------------------------------------
20
+ // ----------------------------------------------------------------------------
21
+ const multiLang = useHsMultiLang();
22
+ // ----------------------------------------------------------------------------
23
+ // [ Props ]
24
+ type Props = {
25
+ columns: any[];
26
+ rows: any[];
27
+ rowCountHeight?: number;
28
+ option?: any;
29
+ };
30
+ const props = withDefaults(defineProps<Props>(), {
31
+ rowCountHeight: 0,
32
+ option: () => Option(),
33
+ });
34
+ // [ emit ]
35
+ type Emits = {
36
+ "row-click": [data: any];
37
+ "row-dbl-click": [data: any];
38
+ init: [flag: boolean];
39
+ tabulator: [tabulator: any];
40
+ "table-rebuild": [func: () => void];
41
+ "table-redraw": [func: () => void];
42
+ "table-refresh": [func: () => void];
43
+ "table-refresh-stop-toggle": [func: (flag: boolean) => void];
44
+ };
45
+ const emit = defineEmits<Emits>();
46
+ // [ reactive ]
47
+ const table = ref<HTMLElement | null>(null); // reference to your table element
48
+ const tabulator = ref<any>(null); // variable to hold your table
49
+
50
+ // const data = computed(() => {
51
+ // return [...props.rows];
52
+ // });
53
+ const data = computed(() => {
54
+ return props.rows;
55
+ });
56
+ // ----------------------------------------------------------------------------
57
+
58
+ const refreshStopFlag = ref(false);
59
+ watch(
60
+ () => props.rows,
61
+ () => {
62
+ // console.log(ct, 'watch rows', props.rows);
63
+ if (table.value === null) return;
64
+ if (isInit.value && tabulator.value !== null && !refreshStopFlag.value) {
65
+ tabulator.value.replaceData(data.value as any);
66
+ }
67
+ },
68
+ { deep: true }
69
+ );
70
+
71
+ watch(
72
+ () => multiLang.state.lang,
73
+ () => {
74
+ // console.log(ct, 'watch multiLang', multiLang.lang);
75
+ if (table.value === null) return;
76
+ // console.log('watch > prop.lang', tabulator.value);
77
+ tabulator.value.setLocale(multiLang.state.lang);
78
+ // console.log('watch > prop.lang', tabulator.value.redraw);
79
+ tabulator.value.redraw(true);
80
+ }
81
+ );
82
+
83
+ // [▼ 初期化 ▼]
84
+ Tabulator.extendModule("localize", "langs", Option().langs);
85
+ const isInit = ref(false);
86
+
87
+ watch(isInit, (value) => {
88
+ emit("init", value);
89
+ });
90
+
91
+ watch(
92
+ () => props.columns,
93
+ () => {
94
+ // console.log(ct, 'watch columns', value);
95
+ if (table.value === null) return;
96
+ if (isInit.value) {
97
+ tabulator.value.setColumns(props.columns);
98
+ }
99
+ }
100
+ );
101
+
102
+ const initTabulator = () => {
103
+ // console.log(ct, 'initTabulator');
104
+ if (table.value === null) return;
105
+ let height = 0;
106
+ if (props.rowCountHeight !== 0) {
107
+ height = props.rowCountHeight * 39 + 85 + 2;
108
+ }
109
+ const option = props.option;
110
+ option.height = height === 0 ? "" : height;
111
+ option.columns = props.columns;
112
+ option.data = data.value;
113
+ option.reactiveData = false;
114
+ tabulator.value = new Tabulator(table.value, option);
115
+ tabulator.value.on("rowClick", (e: any, row: any) => {
116
+ emit("row-click", row._row.data);
117
+ e.stopPropagation();
118
+ });
119
+ tabulator.value.on("rowDblClick", (e: any, row: any) => {
120
+ emit("row-dbl-click", row._row.data);
121
+ e.stopPropagation();
122
+ });
123
+ tabulator.value.on("tableBuilding", () => (isInit.value = false));
124
+ const beforeRows = option.data.length;
125
+ let buildingFlag = true;
126
+ tabulator.value.on("tableBuilt", () => {
127
+ // console.log(ct, 'tableBuilt');
128
+ const afterRows = props.rows.length;
129
+ if (buildingFlag && beforeRows !== afterRows) {
130
+ buildingFlag = false;
131
+ tabulator.value.replaceData(data.value as any);
132
+ }
133
+ isInit.value = true;
134
+ });
135
+ tabulator.value.on("tableDestroyed", () => (isInit.value = false));
136
+
137
+ // 親コントロールへtableを伝達
138
+ emit("tabulator", tabulator.value);
139
+ // ----------------------------------------
140
+
141
+ /** 意図的にテーブルを再描画する */
142
+ const reBuild = () => {
143
+ // console.log(ct, 'reBuild');
144
+ if (tabulator.value === null || isInit.value === false) return;
145
+ tabulator.value.destroy();
146
+ tabulator.value = null;
147
+ initTabulator();
148
+ };
149
+ emit("table-rebuild", reBuild);
150
+ // ----------------------------------------
151
+
152
+ /** 意図的にテーブルを再描画する */
153
+ const redraw = () => {
154
+ if (tabulator.value === null || isInit.value === false) return;
155
+ tabulator.value.redraw(true);
156
+ };
157
+ emit("table-redraw", redraw);
158
+ // ----------------------------------------
159
+
160
+ const tableRefreshStopToggle = (flag: boolean) => {
161
+ // console.log('tableRefreshStopToggle', flag);
162
+ refreshStopFlag.value = flag;
163
+ };
164
+ emit("table-refresh-stop-toggle", tableRefreshStopToggle);
165
+
166
+ /** 意図的にテーブルデータをリフレッシュする */
167
+ const refresh = async () => {
168
+ if (tabulator.value === null || isInit.value === false) return;
169
+ await tabulator.value.replaceData(data.value as any);
170
+ };
171
+ emit("table-refresh", refresh);
172
+ };
173
+ // ----------------------------------------
174
+
175
+ onMounted(() => {
176
+ initTabulator();
177
+ });
178
+ onUnmounted(() => {
179
+ tabulator.value.destroy();
180
+ tabulator.value = null;
181
+ });
182
+ // ----------------------------------------------------------------------------
183
+ </script>
184
+
185
+ <template>
186
+ <div ref="table"></div>
187
+ </template>
@@ -0,0 +1,39 @@
1
+ <script setup lang="ts">
2
+ /* ----------------------------------------------------------------------------
3
+ // src\runtime\components\misc\view-name-display-target.vue
4
+ // ----------------------------------------------------------------------------
5
+ // ViewNameDisplayTarget
6
+ // ViewNameDisplayTargetViewNameDisplayTarget
7
+ ----------------------------------------------------------------------------- */
8
+
9
+ // [ NUXT ]
10
+ import { computed } from "#imports";
11
+ // ----------------------------------------------------------------------------
12
+ // [ Props ]
13
+ interface Props {
14
+ // isShow: boolean;
15
+ offset?: number|string;
16
+ target: HTMLElement | null;
17
+ }
18
+ const props = withDefaults(defineProps<Props>(), {
19
+ offset: 10,
20
+ });
21
+ type Emits = {
22
+ "update:target": [e: HTMLElement];
23
+ };
24
+ const emit = defineEmits<Emits>();
25
+ const style = computed(() => {
26
+ return `margin-top:-${props.offset}px;z-index:999;`;
27
+ });
28
+ const setRef = (e: HTMLElement) => {
29
+ emit("update:target", e);
30
+ };
31
+ </script>
32
+
33
+ <template>
34
+ <div
35
+ :ref="(e:any) => setRef(e)"
36
+ class="absolute top-0 pointer-events-none"
37
+ :style="style"
38
+ ></div>
39
+ </template>