@finema/finework-layer 0.0.11 → 0.0.13

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.
@@ -1,29 +1,29 @@
1
- <template>
2
- <Button
3
- size="lg"
4
- variant="ghost"
5
- :icon="icon"
6
- :color="color"
7
- square
8
- :disabled="disabled"
9
- :loading="loading"
10
- :to="to"
11
- @click="$emit('click')"
12
- />
13
- </template>
14
-
15
- <script lang="ts" setup>
16
- defineEmits<{
17
- (e: 'click'): void
18
- }>()
19
-
20
- withDefaults(defineProps<{
21
- to?: string
22
- icon: string
23
- color?: 'neutral' | 'error' | 'primary' | 'success' | 'warning' | 'info'
24
- disabled?: boolean
25
- loading?: boolean
26
- }>(), {
27
- color: 'neutral',
28
- })
29
- </script>
1
+ <template>
2
+ <Button
3
+ size="lg"
4
+ variant="ghost"
5
+ :icon="icon"
6
+ :color="color"
7
+ square
8
+ :disabled="disabled"
9
+ :loading="loading"
10
+ :to="to"
11
+ @click="$emit('click')"
12
+ />
13
+ </template>
14
+
15
+ <script lang="ts" setup>
16
+ defineEmits<{
17
+ (e: 'click'): void
18
+ }>()
19
+
20
+ withDefaults(defineProps<{
21
+ to?: string
22
+ icon: string
23
+ color?: 'neutral' | 'error' | 'primary' | 'success' | 'warning' | 'info'
24
+ disabled?: boolean
25
+ loading?: boolean
26
+ }>(), {
27
+ color: 'neutral',
28
+ })
29
+ </script>
@@ -1,22 +1,22 @@
1
- <template>
2
- <Button
3
- icon="icon-park-outline:left"
4
- variant="outline"
5
- color="neutral"
6
- :to="to"
7
- @click="$emit('click')"
8
- >
9
- {{ label || 'กลับ' }}
10
- </Button>
11
- </template>
12
-
13
- <script lang="ts" setup>
14
- defineEmits<{
15
- (e: 'click'): void
16
- }>()
17
-
18
- defineProps<{
19
- to?: string
20
- label?: string
21
- }>()
22
- </script>
1
+ <template>
2
+ <Button
3
+ icon="icon-park-outline:left"
4
+ variant="outline"
5
+ color="neutral"
6
+ :to="to"
7
+ @click="$emit('click')"
8
+ >
9
+ {{ label || 'กลับ' }}
10
+ </Button>
11
+ </template>
12
+
13
+ <script lang="ts" setup>
14
+ defineEmits<{
15
+ (e: 'click'): void
16
+ }>()
17
+
18
+ defineProps<{
19
+ to?: string
20
+ label?: string
21
+ }>()
22
+ </script>
@@ -1,198 +1,202 @@
1
- <template>
2
- <div
3
- :class="[
4
- 'grid w-full gap-4',
5
- {
6
- 'lg:grid-cols-2': !vertical,
7
- },
8
- customClass,
9
- ]"
10
- >
11
- <div
12
- v-for="item in items"
13
- :key="item.label"
14
- :class="[
15
- 'lg:flex',
16
- {
17
- 'flex-col': !inline,
18
- 'flex-row': inline,
19
- },
20
- item.customClass,
21
-
22
- ]"
23
- >
24
- <p
25
- v-if="item.type !== TYPE_INFO_ITEM.BOOLEAN"
26
- :class="[
27
- 'mb-1',
28
- {
29
- 'mb-2 block text-sm font-bold text-black': !inline,
30
- 'mr-2 font-bold': inline,
31
- },
32
- ]"
33
- >
34
- {{ item.label }}
35
- </p>
36
- <component
37
- :is="item.component"
38
- v-if="item.component"
39
- v-bind="item.props"
40
- />
41
- <slot
42
- v-else-if="item.key && $slots[`${item.key}-item`]"
43
- :name="`${item.key}-item`"
44
- :row="item"
45
- :item="item"
46
- :value="item.value"
47
- :label="item.label"
48
- />
49
- <div
50
- v-else
51
- class="whitespace-pre-line text-gray-900"
52
- >
53
- <span
54
- v-if="shouldTruncateText(item)"
55
- v-show="!expandedItems[item.label]"
56
- >
57
- {{ truncateText(item.value || '-', item.max || 0) }}
58
- <button
59
- class="
60
- text-info-600 ml-1 cursor-pointer text-sm
61
- hover:text-info-800
62
- "
63
- @click="toggleExpanded(item.label)"
64
- >
65
- เพิ่มเติม
66
- </button>
67
- </span>
68
- <span
69
- v-if="shouldTruncateText(item)"
70
- v-show="expandedItems[item.label]"
71
- >
72
- {{ item.value || '-' }}
73
- <button
74
- class="
75
- text-info-600 ml-1 cursor-pointer text-sm
76
- hover:text-info-800
77
- "
78
- @click="toggleExpanded(item.label)"
79
- >
80
- แสดงน้อยลง
81
- </button>
82
- </span>
83
- <!-- <span >
84
- <Icon
85
- class="size-5"
86
- :class="item.value ? 'text-success' : 'text-error'"
87
- :name="item.value
88
- ? 'material-symbols:check-circle-outline-rounded'
89
- : 'material-symbols:cancel-outline-rounded'"
90
- />
91
- </span> -->
92
- <Checkbox
93
- v-if="item.type === TYPE_INFO_ITEM.BOOLEAN"
94
- v-model="item.value"
95
- :label="item.label"
96
- class="pointer-events-none"
97
- />
98
- <span v-else-if="!shouldTruncateText(item)">
99
- {{ getValue(item) }}
100
- </span>
101
- </div>
102
- </div>
103
- </div>
104
- </template>
105
-
106
- <script lang="ts" setup>
107
- import { reactive } from 'vue'
108
- enum TYPE_INFO_ITEM {
109
- TEXT = 'text',
110
- NUMBER = 'number',
111
- CURRENCY = 'currency',
112
- DATE = 'date',
113
- DATE_TIME = 'date_time',
114
- BOOLEAN = 'boolean',
115
- }
116
-
117
- defineProps<{
118
- items: Array<{
119
- label: string
120
- value?: any
121
- component?: any
122
- props?: Record<string, any>
123
- max?: number
124
- key?: string
125
- type?: TYPE_INFO_ITEM
126
- customClass?: string
127
- }>
128
- vertical?: boolean
129
- inline?: boolean
130
- customClass?: string
131
-
132
- }>()
133
-
134
- const expandedItems = reactive<Record<string, boolean>>({})
135
-
136
- const shouldTruncateText = (item: any): boolean => {
137
- return item.max && item.value && item.value.length > item.max
138
- }
139
-
140
- const truncateText = (text: string, maxLength: number): string => {
141
- if (!maxLength || text.length <= maxLength) return text
142
-
143
- return text.slice(0, maxLength) + '...'
144
- }
145
-
146
- const toggleExpanded = (label: string): void => {
147
- expandedItems[label] = !expandedItems[label]
148
- }
149
-
150
- const getValue = (item: any): string => {
151
- if (item.type === TYPE_INFO_ITEM.DATE) {
152
- return item.value
153
- ? new Date(item.value).toLocaleDateString('en', {
154
- year: 'numeric',
155
- month: 'long',
156
- day: 'numeric',
157
- })
158
- : '-'
159
- }
160
-
161
- if (item.type === TYPE_INFO_ITEM.DATE_TIME) {
162
- return item.value
163
- ? new Date(item.value).toLocaleString('en', {
164
- year: 'numeric',
165
- month: 'long',
166
- day: 'numeric',
167
- hour: '2-digit',
168
- minute: '2-digit',
169
- second: '2-digit',
170
- hour12: false,
171
- timeZone: 'UTC',
172
- })
173
- : '-'
174
- }
175
-
176
- if (item.value === undefined || item.value === null) {
177
- return '-'
178
- }
179
-
180
- if (typeof item.value === 'number') {
181
- if (item.type === 'currency') {
182
- return NumberHelper.toCurrency(item.value)
183
- }
184
-
185
- return NumberHelper.withFixed(item.value)
186
- }
187
-
188
- if (item.type === 'currency') {
189
- return NumberHelper.toCurrency(item.value)
190
- }
191
-
192
- if (item.type === 'number') {
193
- return NumberHelper.withFixed(item.value)
194
- }
195
-
196
- return item.value || '-'
197
- }
198
- </script>
1
+ <template>
2
+ <div
3
+ :class="[
4
+ 'grid w-full gap-4',
5
+ {
6
+ 'lg:grid-cols-2': !vertical,
7
+ },
8
+ customClass,
9
+ ]"
10
+ >
11
+ <div
12
+ v-for="item in items"
13
+ :key="item.label"
14
+ :class="[
15
+ 'lg:flex',
16
+ {
17
+ 'flex-col': !inline,
18
+ 'flex-row': inline,
19
+ },
20
+ item.customClass,
21
+
22
+ ]"
23
+ >
24
+ <template v-if="!item.hide">
25
+ <p
26
+ v-if="item.type !== TYPE_INFO_ITEM.BOOLEAN"
27
+ :class="[
28
+ 'mb-1',
29
+ {
30
+ 'mb-2 block text-sm font-bold text-black': !inline,
31
+ 'mr-2 font-bold': inline,
32
+ },
33
+ ]"
34
+ >
35
+ {{ item.label }}
36
+ </p>
37
+ <component
38
+ :is="item.component"
39
+ v-if="item.component"
40
+ v-bind="item.props"
41
+ />
42
+ <slot
43
+ v-else-if="item.key && $slots[`${item.key}-item`]"
44
+ :name="`${item.key}-item`"
45
+ :row="item"
46
+ :item="item"
47
+ :value="item.value"
48
+ :label="item.label"
49
+ />
50
+ <div
51
+ v-else
52
+ class="whitespace-pre-line text-gray-900"
53
+ >
54
+ <span
55
+ v-if="shouldTruncateText(item)"
56
+ v-show="!expandedItems[item.label]"
57
+ >
58
+ {{ truncateText(item.value || '-', item.max || 0) }}
59
+ <button
60
+ class="
61
+ text-info-600 ml-1 cursor-pointer text-sm
62
+ hover:text-info-800
63
+ "
64
+ @click="toggleExpanded(item.label)"
65
+ >
66
+ เพิ่มเติม
67
+ </button>
68
+ </span>
69
+ <span
70
+ v-if="shouldTruncateText(item)"
71
+ v-show="expandedItems[item.label]"
72
+ >
73
+ {{ item.value || '-' }}
74
+ <button
75
+ class="
76
+ text-info-600 ml-1 cursor-pointer text-sm
77
+ hover:text-info-800
78
+ "
79
+ @click="toggleExpanded(item.label)"
80
+ >
81
+ แสดงน้อยลง
82
+ </button>
83
+ </span>
84
+ <!-- <span >
85
+ <Icon
86
+ class="size-5"
87
+ :class="item.value ? 'text-success' : 'text-error'"
88
+ :name="item.value
89
+ ? 'material-symbols:check-circle-outline-rounded'
90
+ : 'material-symbols:cancel-outline-rounded'"
91
+ />
92
+ </span> -->
93
+ <Checkbox
94
+ v-if="item.type === TYPE_INFO_ITEM.BOOLEAN"
95
+ v-model="item.value"
96
+ :label="item.label"
97
+ class="pointer-events-none"
98
+ />
99
+ <span v-else-if="!shouldTruncateText(item)">
100
+ {{ getValue(item) }}
101
+ </span>
102
+ </div>
103
+ </template>
104
+ </div>
105
+ </div>
106
+ </template>
107
+
108
+ <script lang="ts" setup>
109
+ import { reactive } from 'vue'
110
+
111
+ enum TYPE_INFO_ITEM {
112
+ TEXT = 'text',
113
+ NUMBER = 'number',
114
+ CURRENCY = 'currency',
115
+ DATE = 'date',
116
+ DATE_TIME = 'date_time',
117
+ BOOLEAN = 'boolean',
118
+ }
119
+
120
+ defineProps<{
121
+ items: Array<{
122
+ label: string
123
+ value?: any
124
+ component?: any
125
+ props?: Record<string, any>
126
+ max?: number
127
+ key?: string
128
+ type?: TYPE_INFO_ITEM
129
+ customClass?: string
130
+ hide?: boolean
131
+ }>
132
+ vertical?: boolean
133
+ inline?: boolean
134
+ customClass?: string
135
+
136
+ }>()
137
+
138
+ const expandedItems = reactive<Record<string, boolean>>({})
139
+
140
+ const shouldTruncateText = (item: any): boolean => {
141
+ return item.max && item.value && item.value.length > item.max
142
+ }
143
+
144
+ const truncateText = (text: string, maxLength: number): string => {
145
+ if (!maxLength || text.length <= maxLength) return text
146
+
147
+ return text.slice(0, maxLength) + '...'
148
+ }
149
+
150
+ const toggleExpanded = (label: string): void => {
151
+ expandedItems[label] = !expandedItems[label]
152
+ }
153
+
154
+ const getValue = (item: any): string => {
155
+ if (item.type === TYPE_INFO_ITEM.DATE) {
156
+ return item.value
157
+ ? new Date(item.value).toLocaleDateString('en', {
158
+ year: 'numeric',
159
+ month: 'long',
160
+ day: 'numeric',
161
+ })
162
+ : '-'
163
+ }
164
+
165
+ if (item.type === TYPE_INFO_ITEM.DATE_TIME) {
166
+ return item.value
167
+ ? new Date(item.value).toLocaleString('en', {
168
+ year: 'numeric',
169
+ month: 'long',
170
+ day: 'numeric',
171
+ hour: '2-digit',
172
+ minute: '2-digit',
173
+ second: '2-digit',
174
+ hour12: false,
175
+ timeZone: 'UTC',
176
+ })
177
+ : '-'
178
+ }
179
+
180
+ if (item.value === undefined || item.value === null) {
181
+ return '-'
182
+ }
183
+
184
+ if (typeof item.value === 'number') {
185
+ if (item.type === 'currency') {
186
+ return NumberHelper.toCurrency(item.value)
187
+ }
188
+
189
+ return NumberHelper.withFixed(item.value)
190
+ }
191
+
192
+ if (item.type === 'currency') {
193
+ return NumberHelper.toCurrency(item.value)
194
+ }
195
+
196
+ if (item.type === 'number') {
197
+ return NumberHelper.withFixed(item.value)
198
+ }
199
+
200
+ return item.value || '-'
201
+ }
202
+ </script>
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <Popover
3
+ :content="{
4
+ align: 'center',
5
+ side: 'bottom',
6
+ sideOffset: 8,
7
+ }"
8
+ >
9
+ <Button
10
+ icon="mingcute:dot-grid-line"
11
+ variant="ghost"
12
+ class="text-gray-500"
13
+ />
14
+
15
+ <template #content>
16
+ <Card class="w-[300px]">
17
+ <div
18
+ class="grid grid-cols-3 gap-6"
19
+ >
20
+ <Button
21
+ v-for="item in auth.menusNavbar.value"
22
+ :key="item.to"
23
+ class="flex flex-col items-center p-0 text-center"
24
+ variant="link"
25
+ :to="item.to"
26
+ >
27
+ <div class="flex h-[42px] items-center justify-center">
28
+ <img
29
+ :src="item.icon"
30
+ class="h-auto w-[32px]"
31
+ />
32
+ </div>
33
+ <span class="text-sm font-medium text-gray-700">
34
+ {{ item.label }}
35
+ </span>
36
+ </Button>
37
+ </div>
38
+ </Card>
39
+ </template>
40
+ </Popover>
41
+ </template>
42
+
43
+ <script lang="ts" setup>
44
+ const auth = useAuth()
45
+ </script>