@finema/finework-layer 0.0.12 → 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,202 +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
- <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>
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>