@finema/core 1.3.40 → 1.4.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.
- package/dist/module.json +1 -1
- package/dist/module.mjs +125 -111
- package/dist/runtime/components/Alert.vue +49 -61
- package/dist/runtime/components/Button/Group.vue +5 -15
- package/dist/runtime/components/Button/index.vue +9 -58
- package/dist/runtime/components/Form/FieldWrapper.vue +6 -2
- package/dist/runtime/components/Form/InputCheckbox/index.vue +2 -3
- package/dist/runtime/components/Form/InputCheckbox/types.d.ts +1 -5
- package/dist/runtime/components/Form/InputDateTime/index.vue +2 -11
- package/dist/runtime/components/Form/InputRadio/index.vue +2 -2
- package/dist/runtime/components/Form/InputRadio/types.d.ts +1 -5
- package/dist/runtime/components/Form/InputSelect/index.vue +3 -3
- package/dist/runtime/components/Form/InputSelect/types.d.ts +0 -1
- package/dist/runtime/components/Form/InputStatic/index.vue +1 -1
- package/dist/runtime/components/Form/InputStatic/types.d.ts +1 -1
- package/dist/runtime/components/Form/InputText/index.vue +3 -7
- package/dist/runtime/components/Form/InputText/types.d.ts +2 -3
- package/dist/runtime/components/Form/InputTextarea/index.vue +2 -7
- package/dist/runtime/components/Form/InputTextarea/types.d.ts +1 -6
- package/dist/runtime/components/Form/InputToggle/index.vue +2 -2
- package/dist/runtime/components/Form/InputToggle/types.d.ts +1 -5
- package/dist/runtime/components/Form/types.d.ts +6 -7
- package/dist/runtime/composables/useForm.d.ts +3 -19
- package/dist/runtime/composables/useForm.mjs +2 -29
- package/dist/runtime/ui.config/button.d.ts +3 -1
- package/dist/runtime/ui.config/button.mjs +0 -2
- package/dist/runtime/ui.config/buttonGroup.d.ts +3 -1
- package/dist/runtime/ui.config/buttonGroup.mjs +1 -8
- package/package.json +3 -3
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, installModule, addPlugin, addComponentsDir, addImportsDir } from '@nuxt/kit';
|
|
2
|
-
import
|
|
2
|
+
import 'lodash-es';
|
|
3
3
|
|
|
4
4
|
const name = "@finema/core";
|
|
5
|
-
const version = "1.
|
|
5
|
+
const version = "1.4.2";
|
|
6
6
|
|
|
7
7
|
const colors = {
|
|
8
8
|
black: "#20243E",
|
|
@@ -67,7 +67,6 @@ const colors = {
|
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
const _merge = merge;
|
|
71
70
|
const isObj = (item) => item && typeof item === "object" && !Array.isArray(item);
|
|
72
71
|
const _deepMerge = (target, ...sources) => {
|
|
73
72
|
if (!sources.length)
|
|
@@ -171,6 +170,112 @@ const alert = {
|
|
|
171
170
|
}
|
|
172
171
|
};
|
|
173
172
|
|
|
173
|
+
const button = {
|
|
174
|
+
default: {
|
|
175
|
+
size: "md",
|
|
176
|
+
variant: "solid",
|
|
177
|
+
color: "primary",
|
|
178
|
+
loadingIcon: "i-heroicons-arrow-path-20-solid"
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const buttonGroup = {};
|
|
183
|
+
|
|
184
|
+
const colorModeOptions = {
|
|
185
|
+
preference: "light"
|
|
186
|
+
};
|
|
187
|
+
const veeValidateNuxtOptions = {
|
|
188
|
+
// disable or enable auto imports
|
|
189
|
+
autoImports: true,
|
|
190
|
+
// Use different names for components
|
|
191
|
+
componentNames: {
|
|
192
|
+
Form: "VForm",
|
|
193
|
+
Field: "VField",
|
|
194
|
+
FieldArray: "VFieldArray",
|
|
195
|
+
ErrorMessage: "VErrorMessage"
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const nuxtSecurityOptions = {
|
|
199
|
+
headers: {
|
|
200
|
+
xXSSProtection: "1; mode=block",
|
|
201
|
+
crossOriginEmbedderPolicy: "unsafe-none",
|
|
202
|
+
contentSecurityPolicy: {
|
|
203
|
+
"img-src": ["*", "'self'", "data:", "https"],
|
|
204
|
+
"script-src": [
|
|
205
|
+
"'self'",
|
|
206
|
+
"'unsafe-inline'",
|
|
207
|
+
"https://www.google-analytics.com",
|
|
208
|
+
"https://www.googletagmanager.com",
|
|
209
|
+
"https://fonts.googleapis.com",
|
|
210
|
+
"https://cdnjs.cloudflare.com"
|
|
211
|
+
],
|
|
212
|
+
"script-src-attr": [
|
|
213
|
+
"'unsafe-inline'",
|
|
214
|
+
"https://www.google-analytics.com",
|
|
215
|
+
"https://www.googletagmanager.com",
|
|
216
|
+
"https://fonts.googleapis.com",
|
|
217
|
+
"https://cdnjs.cloudflare.com"
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
const nuxtAppOptions = {
|
|
223
|
+
head: {
|
|
224
|
+
htmlAttrs: {
|
|
225
|
+
lang: "en"
|
|
226
|
+
},
|
|
227
|
+
meta: [
|
|
228
|
+
{ charset: "utf-8" },
|
|
229
|
+
{
|
|
230
|
+
name: "viewport",
|
|
231
|
+
content: "width=device-width, initial-scale=1"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
id: "description",
|
|
235
|
+
name: "description",
|
|
236
|
+
content: ""
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: "format-detection",
|
|
240
|
+
content: "telephone=no"
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
link: [
|
|
244
|
+
{
|
|
245
|
+
rel: "preconnect",
|
|
246
|
+
href: "https://fonts.googleapis.com"
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
rel: "preconnect",
|
|
250
|
+
href: "https://fonts.gstatic.com",
|
|
251
|
+
crossorigin: ""
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
rel: "dns-prefetch",
|
|
255
|
+
href: "https://www.google-analytics.com/"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
rel: "preconnect",
|
|
259
|
+
href: "https://www.google-analytics.com/",
|
|
260
|
+
crossorigin: ""
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
rel: "icon",
|
|
264
|
+
type: "image/x-icon",
|
|
265
|
+
href: "/favicon.ico"
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
const nuxtRunTimeConfigOptions = {
|
|
271
|
+
public: {
|
|
272
|
+
baseAPI: process.env.APP_BASE_API,
|
|
273
|
+
baseAPIMock: process.env.APP_BASE_API_MOCK,
|
|
274
|
+
baseInternalAPI: process.env.APP_BASE_INTERNAL_API,
|
|
275
|
+
port: process.env.PORT || "3000"
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
174
279
|
const module = defineNuxtModule({
|
|
175
280
|
meta: {
|
|
176
281
|
name,
|
|
@@ -203,122 +308,31 @@ const module = defineNuxtModule({
|
|
|
203
308
|
};
|
|
204
309
|
});
|
|
205
310
|
await installModule("@nuxt/ui", {
|
|
206
|
-
safelistColors: ["
|
|
311
|
+
safelistColors: ["secondary", "success", "info", "danger", "warning"]
|
|
207
312
|
});
|
|
208
|
-
nuxt.options.appConfig.ui =
|
|
209
|
-
table,
|
|
210
|
-
pagination,
|
|
211
|
-
alert
|
|
212
|
-
});
|
|
213
|
-
nuxt.options.appConfig.ui.strategy = "override";
|
|
214
|
-
nuxt.options.runtimeConfig = _deepMerge(
|
|
215
|
-
{},
|
|
216
|
-
{
|
|
217
|
-
public: {
|
|
218
|
-
baseAPI: process.env.APP_BASE_API,
|
|
219
|
-
baseAPIMock: process.env.APP_BASE_API_MOCK,
|
|
220
|
-
baseInternalAPI: process.env.APP_BASE_INTERNAL_API,
|
|
221
|
-
port: process.env.PORT || "3000"
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
nuxt.options.runtimeConfig
|
|
225
|
-
);
|
|
226
|
-
nuxt.options.app = _deepMerge(
|
|
313
|
+
nuxt.options.appConfig.ui = _deepMerge(
|
|
227
314
|
{},
|
|
228
315
|
{
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
{ charset: "utf-8" },
|
|
235
|
-
{
|
|
236
|
-
name: "viewport",
|
|
237
|
-
content: "width=device-width, initial-scale=1"
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
id: "description",
|
|
241
|
-
name: "description",
|
|
242
|
-
content: ""
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
name: "format-detection",
|
|
246
|
-
content: "telephone=no"
|
|
247
|
-
}
|
|
248
|
-
],
|
|
249
|
-
link: [
|
|
250
|
-
{
|
|
251
|
-
rel: "preconnect",
|
|
252
|
-
href: "https://fonts.googleapis.com"
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
rel: "preconnect",
|
|
256
|
-
href: "https://fonts.gstatic.com",
|
|
257
|
-
crossorigin: ""
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
rel: "dns-prefetch",
|
|
261
|
-
href: "https://www.google-analytics.com/"
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
rel: "preconnect",
|
|
265
|
-
href: "https://www.google-analytics.com/",
|
|
266
|
-
crossorigin: ""
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
rel: "icon",
|
|
270
|
-
type: "image/x-icon",
|
|
271
|
-
href: "/favicon.ico"
|
|
272
|
-
}
|
|
273
|
-
]
|
|
274
|
-
}
|
|
316
|
+
table,
|
|
317
|
+
pagination,
|
|
318
|
+
alert,
|
|
319
|
+
button,
|
|
320
|
+
buttonGroup
|
|
275
321
|
},
|
|
276
|
-
nuxt.options.
|
|
322
|
+
nuxt.options.appConfig.ui
|
|
277
323
|
);
|
|
278
|
-
nuxt.options.
|
|
324
|
+
nuxt.options.appConfig.ui.strategy = "override";
|
|
325
|
+
nuxt.options.app = _deepMerge({}, nuxtAppOptions, nuxt.options.app);
|
|
326
|
+
nuxt.options.colorMode = _deepMerge({}, colorModeOptions, nuxt.options.colorMode);
|
|
327
|
+
nuxt.options.devtools = _deepMerge({}, { enabled: true }, nuxt.options.devtools);
|
|
328
|
+
nuxt.options.runtimeConfig = _deepMerge(
|
|
279
329
|
{},
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
},
|
|
283
|
-
nuxt.options.colorMode
|
|
330
|
+
nuxtRunTimeConfigOptions,
|
|
331
|
+
nuxt.options.runtimeConfig
|
|
284
332
|
);
|
|
285
|
-
nuxt.options.devtools = _deepMerge({}, { enabled: true }, nuxt.options.devtools);
|
|
286
333
|
await installModule("@pinia/nuxt");
|
|
287
|
-
await installModule("@vee-validate/nuxt",
|
|
288
|
-
|
|
289
|
-
autoImports: true,
|
|
290
|
-
// Use different names for components
|
|
291
|
-
componentNames: {
|
|
292
|
-
Form: "VForm",
|
|
293
|
-
Field: "VField",
|
|
294
|
-
FieldArray: "VFieldArray",
|
|
295
|
-
ErrorMessage: "VErrorMessage"
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
await installModule("nuxt-security", {
|
|
299
|
-
headers: {
|
|
300
|
-
xXSSProtection: "1; mode=block",
|
|
301
|
-
crossOriginEmbedderPolicy: "unsafe-none",
|
|
302
|
-
contentSecurityPolicy: {
|
|
303
|
-
"img-src": ["*", "'self'", "data:", "https"],
|
|
304
|
-
"script-src": [
|
|
305
|
-
"'self'",
|
|
306
|
-
"'unsafe-inline'",
|
|
307
|
-
"https://www.google-analytics.com",
|
|
308
|
-
"https://www.googletagmanager.com",
|
|
309
|
-
"https://fonts.googleapis.com",
|
|
310
|
-
"https://cdnjs.cloudflare.com"
|
|
311
|
-
],
|
|
312
|
-
"script-src-attr": [
|
|
313
|
-
"'unsafe-inline'",
|
|
314
|
-
"https://www.google-analytics.com",
|
|
315
|
-
"https://www.googletagmanager.com",
|
|
316
|
-
"https://fonts.googleapis.com",
|
|
317
|
-
"https://cdnjs.cloudflare.com"
|
|
318
|
-
]
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
});
|
|
334
|
+
await installModule("@vee-validate/nuxt", veeValidateNuxtOptions);
|
|
335
|
+
await installModule("nuxt-security", nuxtSecurityOptions);
|
|
322
336
|
addPlugin({
|
|
323
337
|
src: resolve(runtimeDir, "plugin")
|
|
324
338
|
});
|
|
@@ -1,61 +1,49 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<UAlert v-bind="$props">
|
|
3
|
-
<template #title><slot name="title" /></template>
|
|
4
|
-
<template #description><slot name="description" /></template>
|
|
5
|
-
</UAlert>
|
|
6
|
-
</template>
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
import { type PropType } from 'vue'
|
|
9
|
-
import { type AlertColor, type AlertVariant, type Avatar, type Button } from '#ui/types'
|
|
10
|
-
import type { Strategy } from '#core/types/utils'
|
|
11
|
-
import { alert } from '#ui/ui.config'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
].includes(value)
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
class: {
|
|
54
|
-
type: [String, Object, Array] as PropType<any>,
|
|
55
|
-
},
|
|
56
|
-
ui: {
|
|
57
|
-
type: Object as PropType<Partial<typeof alert> & { strategy?: Strategy }>,
|
|
58
|
-
default: () => ({}),
|
|
59
|
-
},
|
|
60
|
-
})
|
|
61
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<UAlert v-bind="$props">
|
|
3
|
+
<template #title><slot name="title" :title="title" /></template>
|
|
4
|
+
<template #description><slot name="description" :description="description" /></template>
|
|
5
|
+
</UAlert>
|
|
6
|
+
</template>
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { type PropType } from 'vue'
|
|
9
|
+
import { type AlertColor, type AlertVariant, type Avatar, type Button } from '#ui/types'
|
|
10
|
+
import type { Strategy } from '#core/types/utils'
|
|
11
|
+
import { type alert } from '#ui/ui.config'
|
|
12
|
+
|
|
13
|
+
defineProps({
|
|
14
|
+
title: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
description: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: null,
|
|
21
|
+
},
|
|
22
|
+
icon: {
|
|
23
|
+
type: String,
|
|
24
|
+
},
|
|
25
|
+
avatar: {
|
|
26
|
+
type: Object as PropType<Avatar>,
|
|
27
|
+
default: null,
|
|
28
|
+
},
|
|
29
|
+
closeButton: {
|
|
30
|
+
type: Object as PropType<Button>,
|
|
31
|
+
},
|
|
32
|
+
actions: {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
34
|
+
type: Array as PropType<Array<Button & { click?: Function }>>,
|
|
35
|
+
},
|
|
36
|
+
color: {
|
|
37
|
+
type: String as PropType<AlertColor>,
|
|
38
|
+
},
|
|
39
|
+
variant: {
|
|
40
|
+
type: String as PropType<AlertVariant>,
|
|
41
|
+
},
|
|
42
|
+
class: {
|
|
43
|
+
type: [String, Object, Array] as PropType<any>,
|
|
44
|
+
},
|
|
45
|
+
ui: {
|
|
46
|
+
type: Object as PropType<Partial<typeof alert> & { strategy?: Strategy }>,
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
</script>
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<UButtonGroup
|
|
3
|
-
v-bind="attrs"
|
|
4
|
-
:class="$props.class"
|
|
5
|
-
:size="size"
|
|
6
|
-
:orientation="orientation"
|
|
7
|
-
:ui="ui"
|
|
8
|
-
>
|
|
2
|
+
<UButtonGroup v-bind="$props">
|
|
9
3
|
<slot />
|
|
10
4
|
</UButtonGroup>
|
|
11
5
|
</template>
|
|
12
6
|
|
|
13
7
|
<script lang="ts" setup>
|
|
14
|
-
import { type PropType
|
|
15
|
-
import { button, buttonGroup } from '#core/ui.config'
|
|
8
|
+
import { type PropType } from '#imports'
|
|
16
9
|
import { type ButtonSize } from '#ui/types/button'
|
|
17
10
|
import { type Strategy } from '#core/types/utils'
|
|
11
|
+
import { type buttonGroup, button } from '#ui/ui.config'
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const props = defineProps({
|
|
13
|
+
defineProps({
|
|
22
14
|
size: {
|
|
23
15
|
type: String as PropType<ButtonSize>,
|
|
24
16
|
default: () => button.default.size,
|
|
@@ -38,10 +30,8 @@ const props = defineProps({
|
|
|
38
30
|
default: undefined,
|
|
39
31
|
},
|
|
40
32
|
ui: {
|
|
41
|
-
type: Object as PropType<Partial<typeof
|
|
33
|
+
type: Object as PropType<Partial<typeof buttonGroup> & { strategy?: Strategy }>,
|
|
42
34
|
default: undefined,
|
|
43
35
|
},
|
|
44
36
|
})
|
|
45
|
-
|
|
46
|
-
const { ui, attrs } = useUI('buttonGroup', toRef(props, 'ui'), config, toRef(props, 'class'))
|
|
47
37
|
</script>
|
|
@@ -1,65 +1,34 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<UButton
|
|
3
|
-
|
|
4
|
-
:class="$props.class"
|
|
5
|
-
:label="label"
|
|
6
|
-
:type="type"
|
|
7
|
-
:block="block"
|
|
8
|
-
:loading="loading"
|
|
9
|
-
:disabled="disabled"
|
|
10
|
-
:padded="padded"
|
|
11
|
-
:size="size"
|
|
12
|
-
:color="color"
|
|
13
|
-
:variant="variant"
|
|
14
|
-
:icon="icon"
|
|
15
|
-
:loading-icon="loadingIcon"
|
|
16
|
-
:leading-icon="leadingIcon"
|
|
17
|
-
:trailing-icon="trailingIcon"
|
|
18
|
-
:trailing="trailing"
|
|
19
|
-
:leading="leading"
|
|
20
|
-
:square="square"
|
|
21
|
-
:truncate="truncate"
|
|
22
|
-
:ui="ui"
|
|
23
|
-
>
|
|
24
|
-
<template #leading><slot name="leading" /></template>
|
|
25
|
-
|
|
2
|
+
<UButton v-bind="$props">
|
|
3
|
+
<template #leading><slot name="leading" :disabled="disabled" :loading="loading" /></template>
|
|
26
4
|
<slot />
|
|
27
|
-
<template #trailing><slot name="trailing" /></template>
|
|
5
|
+
<template #trailing><slot name="trailing" :disabled="disabled" :loading="loading" /></template>
|
|
28
6
|
</UButton>
|
|
29
7
|
</template>
|
|
30
8
|
|
|
31
9
|
<script lang="ts" setup>
|
|
32
|
-
import {
|
|
33
|
-
import { button } from '#core/ui.config'
|
|
10
|
+
import { type PropType } from '#imports'
|
|
34
11
|
import { type ButtonSize, type ButtonColor, type ButtonVariant } from '#ui/types/button'
|
|
35
12
|
import { type Strategy } from '#core/types/utils'
|
|
13
|
+
import { type button } from '#ui/ui.config'
|
|
14
|
+
import { UButton } from '#components'
|
|
36
15
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
defineOptions({
|
|
40
|
-
inheritAttrs: true,
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
const props = defineProps({
|
|
16
|
+
defineProps({
|
|
17
|
+
...UButton.props,
|
|
44
18
|
label: {
|
|
45
19
|
type: String,
|
|
46
|
-
default: '',
|
|
47
20
|
},
|
|
48
21
|
type: {
|
|
49
22
|
type: String as PropType<'button' | 'submit' | 'reset'>,
|
|
50
|
-
default: 'button',
|
|
51
23
|
},
|
|
52
24
|
block: {
|
|
53
25
|
type: Boolean,
|
|
54
|
-
default: false,
|
|
55
26
|
},
|
|
56
27
|
loading: {
|
|
57
28
|
type: Boolean,
|
|
58
|
-
default: false,
|
|
59
29
|
},
|
|
60
30
|
disabled: {
|
|
61
31
|
type: Boolean,
|
|
62
|
-
default: false,
|
|
63
32
|
},
|
|
64
33
|
padded: {
|
|
65
34
|
type: Boolean,
|
|
@@ -67,60 +36,42 @@ const props = defineProps({
|
|
|
67
36
|
},
|
|
68
37
|
size: {
|
|
69
38
|
type: String as PropType<ButtonSize>,
|
|
70
|
-
default: () => button.default.size,
|
|
71
|
-
validator(value: string) {
|
|
72
|
-
return Object.keys(button.size).includes(value)
|
|
73
|
-
},
|
|
74
39
|
},
|
|
75
40
|
color: {
|
|
76
41
|
type: String as PropType<ButtonColor>,
|
|
77
|
-
default: () => button.default.color,
|
|
78
42
|
},
|
|
79
43
|
variant: {
|
|
80
44
|
type: String as PropType<ButtonVariant>,
|
|
81
|
-
default: () => button.default.variant,
|
|
82
45
|
},
|
|
83
46
|
loadingIcon: {
|
|
84
47
|
type: String,
|
|
85
|
-
default: () => button.default.loadingIcon,
|
|
86
48
|
},
|
|
87
49
|
icon: {
|
|
88
50
|
type: String,
|
|
89
|
-
default: null,
|
|
90
51
|
},
|
|
91
52
|
leadingIcon: {
|
|
92
53
|
type: String,
|
|
93
|
-
default: null,
|
|
94
54
|
},
|
|
95
55
|
trailingIcon: {
|
|
96
56
|
type: String,
|
|
97
|
-
default: null,
|
|
98
57
|
},
|
|
99
58
|
trailing: {
|
|
100
59
|
type: Boolean,
|
|
101
|
-
default: false,
|
|
102
60
|
},
|
|
103
61
|
leading: {
|
|
104
62
|
type: Boolean,
|
|
105
|
-
default: false,
|
|
106
63
|
},
|
|
107
64
|
square: {
|
|
108
65
|
type: Boolean,
|
|
109
|
-
default: false,
|
|
110
66
|
},
|
|
111
67
|
truncate: {
|
|
112
68
|
type: Boolean,
|
|
113
|
-
default: false,
|
|
114
69
|
},
|
|
115
70
|
class: {
|
|
116
71
|
type: [String, Array, Object] as PropType<any>,
|
|
117
|
-
default: undefined,
|
|
118
72
|
},
|
|
119
73
|
ui: {
|
|
120
|
-
type: Object as PropType<Partial<typeof
|
|
121
|
-
default: undefined,
|
|
74
|
+
type: Object as PropType<Partial<typeof button & { strategy?: Strategy }>>,
|
|
122
75
|
},
|
|
123
76
|
})
|
|
124
|
-
|
|
125
|
-
const { ui, attrs } = useUI('button', toRef(props, 'ui'), config, toRef(props, 'class'))
|
|
126
77
|
</script>
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
<UFormGroup
|
|
3
3
|
:label="label"
|
|
4
4
|
:name="name"
|
|
5
|
+
:description="description"
|
|
6
|
+
:hint="hint"
|
|
7
|
+
:size="size"
|
|
8
|
+
:data-testid="name"
|
|
5
9
|
:help="help"
|
|
6
10
|
:error="errorMessage"
|
|
7
11
|
:required="!!isRequired"
|
|
@@ -10,7 +14,7 @@
|
|
|
10
14
|
</UFormGroup>
|
|
11
15
|
</template>
|
|
12
16
|
<script lang="ts" setup>
|
|
13
|
-
import { type
|
|
17
|
+
import { type IFieldProps } from '#core/components/Form/types'
|
|
14
18
|
|
|
15
|
-
defineProps<
|
|
19
|
+
defineProps<IFieldProps>()
|
|
16
20
|
</script>
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
<FieldWrapper v-bind="wrapperProps" label="">
|
|
3
3
|
<UCheckbox
|
|
4
4
|
v-model="value"
|
|
5
|
-
:disabled="
|
|
5
|
+
:disabled="wrapperProps.isDisabled"
|
|
6
6
|
:name="name"
|
|
7
7
|
:label="props.label"
|
|
8
8
|
:required="isRequired"
|
|
9
|
-
:color="color"
|
|
10
9
|
:ui="ui"
|
|
11
10
|
/>
|
|
12
11
|
</FieldWrapper>
|
|
@@ -18,5 +17,5 @@ import { type ICheckboxFieldProps } from '#core/components/Form/InputCheckbox/ty
|
|
|
18
17
|
|
|
19
18
|
const props = withDefaults(defineProps<ICheckboxFieldProps>(), {})
|
|
20
19
|
|
|
21
|
-
const { value, wrapperProps
|
|
20
|
+
const { value, wrapperProps } = useFieldHOC<boolean>(props)
|
|
22
21
|
</script>
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { type IFieldProps, type IFormFieldBase, type INPUT_TYPES } from '#core/components/Form/types';
|
|
2
2
|
export interface ICheckboxFieldProps extends IFieldProps {
|
|
3
|
-
color?: string;
|
|
4
|
-
ui?: object | any;
|
|
5
3
|
}
|
|
6
|
-
export type ICheckboxField = IFormFieldBase<INPUT_TYPES.CHECKBOX, ICheckboxFieldProps,
|
|
7
|
-
change?: (value: string) => void;
|
|
8
|
-
}>;
|
|
4
|
+
export type ICheckboxField = IFormFieldBase<INPUT_TYPES.CHECKBOX, ICheckboxFieldProps, never>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<FieldWrapper v-bind="wrapperProps">
|
|
3
3
|
<Datepicker
|
|
4
4
|
v-model="value"
|
|
5
|
-
:disabled="
|
|
5
|
+
:disabled="wrapperProps.isDisabled"
|
|
6
6
|
cancel-text="ยกเลิก"
|
|
7
7
|
select-text="เลือก"
|
|
8
8
|
locale="th"
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
:min-date="minDate"
|
|
13
13
|
:max-date="maxDate"
|
|
14
14
|
:required="isRequired"
|
|
15
|
-
@change="handleChange"
|
|
16
15
|
/>
|
|
17
16
|
</FieldWrapper>
|
|
18
17
|
</template>
|
|
@@ -24,9 +23,8 @@ import { TimeHelper, useFieldHOC } from '#imports'
|
|
|
24
23
|
import '@vuepic/vue-datepicker/dist/main.css'
|
|
25
24
|
|
|
26
25
|
const props = withDefaults(defineProps<IDateTimeFieldProps>(), {})
|
|
27
|
-
const emits = defineEmits<(event: 'change', value: string) => void>()
|
|
28
26
|
|
|
29
|
-
const { value, wrapperProps
|
|
27
|
+
const { value, wrapperProps } = useFieldHOC<string>(props)
|
|
30
28
|
|
|
31
29
|
const format = (date: Date) => {
|
|
32
30
|
if (props.disabledTime) {
|
|
@@ -35,11 +33,4 @@ const format = (date: Date) => {
|
|
|
35
33
|
|
|
36
34
|
return TimeHelper.getDateTimeFormTime(date as any)
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
const handleChange = (e: InputEvent) => {
|
|
40
|
-
onChange(e)
|
|
41
|
-
const target = e.target as HTMLInputElement
|
|
42
|
-
|
|
43
|
-
emits('change', target?.value)
|
|
44
|
-
}
|
|
45
36
|
</script>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<URadioGroup
|
|
4
4
|
v-model="value"
|
|
5
5
|
:options="options"
|
|
6
|
-
:disabled="
|
|
6
|
+
:disabled="wrapperProps.isDisabled"
|
|
7
7
|
:required="isRequired"
|
|
8
8
|
value-attribute="value"
|
|
9
9
|
option-attribute="label"
|
|
@@ -23,5 +23,5 @@ import { type ISelectFieldProps } from '#core/components/Form/InputSelect/types'
|
|
|
23
23
|
|
|
24
24
|
const props = withDefaults(defineProps<ISelectFieldProps>(), {})
|
|
25
25
|
|
|
26
|
-
const { value, wrapperProps
|
|
26
|
+
const { value, wrapperProps } = useFieldHOC<any>(props)
|
|
27
27
|
</script>
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { IFieldProps, IFormFieldBase, INPUT_TYPES } from '#core/components/Form/types';
|
|
2
2
|
import { type IOption } from '#core/types/common';
|
|
3
3
|
export interface IRadioFieldProps extends IFieldProps {
|
|
4
|
-
color?: string;
|
|
5
4
|
icon?: string;
|
|
6
5
|
size?: string;
|
|
7
|
-
ui?: object | any;
|
|
8
6
|
options: IOption[];
|
|
9
7
|
}
|
|
10
|
-
export type IRadioField = IFormFieldBase<INPUT_TYPES.RADIO, IRadioFieldProps,
|
|
11
|
-
change?: (value: string) => void;
|
|
12
|
-
}>;
|
|
8
|
+
export type IRadioField = IFormFieldBase<INPUT_TYPES.RADIO, IRadioFieldProps, never>;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
searchable
|
|
6
6
|
:options="options"
|
|
7
7
|
:placeholder="placeholder || label"
|
|
8
|
-
:disabled="
|
|
9
|
-
:loading="
|
|
8
|
+
:disabled="wrapperProps.isDisabled"
|
|
9
|
+
:loading="loading"
|
|
10
10
|
:searchable-placeholder="searchablePlaceholder"
|
|
11
11
|
value-attribute="value"
|
|
12
12
|
option-attribute="label"
|
|
@@ -33,5 +33,5 @@ import { type ISelectFieldProps } from '#core/components/Form/InputSelect/types'
|
|
|
33
33
|
|
|
34
34
|
const props = withDefaults(defineProps<ISelectFieldProps>(), {})
|
|
35
35
|
|
|
36
|
-
const { value, wrapperProps
|
|
36
|
+
const { value, wrapperProps } = useFieldHOC<any>(props)
|
|
37
37
|
</script>
|
|
@@ -12,5 +12,5 @@ import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
|
12
12
|
|
|
13
13
|
const props = withDefaults(defineProps<IStaticFieldProps>(), {})
|
|
14
14
|
|
|
15
|
-
const { value,
|
|
15
|
+
const { value, wrapperProps } = useFieldHOC<string>(props)
|
|
16
16
|
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type IFieldProps, type IFormFieldBase, type INPUT_TYPES } from '#core/components/Form/types';
|
|
2
2
|
export interface IStaticFieldProps extends IFieldProps {
|
|
3
3
|
}
|
|
4
|
-
export type IStaticField = IFormFieldBase<INPUT_TYPES.STATIC, IStaticFieldProps>;
|
|
4
|
+
export type IStaticField = IFormFieldBase<INPUT_TYPES.STATIC, IStaticFieldProps, never>;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
<FieldWrapper v-bind="wrapperProps">
|
|
3
3
|
<UInput
|
|
4
4
|
v-model="value"
|
|
5
|
-
:disabled="
|
|
5
|
+
:disabled="wrapperProps.isDisabled"
|
|
6
6
|
:name="name"
|
|
7
7
|
:placeholder="placeholder ?? props.label"
|
|
8
8
|
:type="isShowPassword ? 'text' : props.type || 'text'"
|
|
9
9
|
:autofocus="!!autoFocus"
|
|
10
|
-
:
|
|
10
|
+
:icon="icon"
|
|
11
11
|
:ui="ui"
|
|
12
12
|
/>
|
|
13
13
|
</FieldWrapper>
|
|
@@ -19,12 +19,8 @@ import { useFieldHOC } from '#core/composables/useForm'
|
|
|
19
19
|
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
20
20
|
|
|
21
21
|
const props = withDefaults(defineProps<ITextFieldProps>(), {})
|
|
22
|
-
const emits = defineEmits<{
|
|
23
|
-
(event: 'change', value: string): void
|
|
24
|
-
(event: 'blur', value: string): void
|
|
25
|
-
}>()
|
|
26
22
|
|
|
27
|
-
const { value, wrapperProps
|
|
23
|
+
const { value, wrapperProps } = useFieldHOC<string>(props)
|
|
28
24
|
|
|
29
25
|
const isShowPassword = ref(false)
|
|
30
26
|
</script>
|
|
@@ -3,10 +3,9 @@ export interface ITextFieldProps extends IFieldProps {
|
|
|
3
3
|
type?: 'text' | 'password' | 'email';
|
|
4
4
|
prependIcon?: any;
|
|
5
5
|
appendIcon?: any;
|
|
6
|
-
|
|
7
|
-
ui?: object | any;
|
|
6
|
+
icon?: string;
|
|
8
7
|
}
|
|
9
|
-
export type ITextField = IFormFieldBase<INPUT_TYPES.TEXT | INPUT_TYPES.PASSWORD, ITextFieldProps, {
|
|
8
|
+
export type ITextField = IFormFieldBase<INPUT_TYPES.TEXT | INPUT_TYPES.PASSWORD | INPUT_TYPES.EMAIL, ITextFieldProps, {
|
|
10
9
|
change?: (value: string) => void;
|
|
11
10
|
blur?: (value: string) => void;
|
|
12
11
|
}>;
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
<FieldWrapper v-bind="wrapperProps">
|
|
3
3
|
<UTextarea
|
|
4
4
|
v-model="value"
|
|
5
|
-
:disabled="
|
|
5
|
+
:disabled="wrapperProps.isDisabled"
|
|
6
6
|
:name="name"
|
|
7
7
|
:resize="resize"
|
|
8
8
|
:placeholder="placeholder ?? props.label"
|
|
9
9
|
:autofocus="!!autoFocus"
|
|
10
10
|
:autoresize="autoresize"
|
|
11
11
|
:rows="rows"
|
|
12
|
-
:color="color"
|
|
13
12
|
:ui="ui"
|
|
14
13
|
/>
|
|
15
14
|
</FieldWrapper>
|
|
@@ -20,10 +19,6 @@ import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
|
20
19
|
import { type ITextareaFieldProps } from '#core/components/Form/InputTextarea/types'
|
|
21
20
|
|
|
22
21
|
const props = withDefaults(defineProps<ITextareaFieldProps>(), {})
|
|
23
|
-
const emits = defineEmits<{
|
|
24
|
-
(event: 'change', value: string): void
|
|
25
|
-
(event: 'blur', value: string): void
|
|
26
|
-
}>()
|
|
27
22
|
|
|
28
|
-
const { value, wrapperProps
|
|
23
|
+
const { value, wrapperProps } = useFieldHOC<string>(props)
|
|
29
24
|
</script>
|
|
@@ -3,10 +3,5 @@ export interface ITextareaFieldProps extends IFieldProps {
|
|
|
3
3
|
autoresize?: boolean;
|
|
4
4
|
resize?: boolean;
|
|
5
5
|
rows?: number;
|
|
6
|
-
color?: string;
|
|
7
|
-
ui?: object | any;
|
|
8
6
|
}
|
|
9
|
-
export type ITextareaField = IFormFieldBase<INPUT_TYPES.TEXTAREA, ITextareaFieldProps,
|
|
10
|
-
change?: (value: string) => void;
|
|
11
|
-
blur?: (value: string) => void;
|
|
12
|
-
}>;
|
|
7
|
+
export type ITextareaField = IFormFieldBase<INPUT_TYPES.TEXTAREA, ITextareaFieldProps, never>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
-
<UToggle v-model="value" :disabled="
|
|
3
|
+
<UToggle v-model="value" :disabled="wrapperProps.isDisabled" :name="name" :ui="ui" />
|
|
4
4
|
</FieldWrapper>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
@@ -10,5 +10,5 @@ import { type IToggleFieldProps } from '#core/components/Form/InputToggle/types'
|
|
|
10
10
|
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
11
11
|
|
|
12
12
|
const props = withDefaults(defineProps<IToggleFieldProps>(), {})
|
|
13
|
-
const { value, wrapperProps
|
|
13
|
+
const { value, wrapperProps } = useFieldHOC<boolean>(props)
|
|
14
14
|
</script>
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { type IFieldProps, type IFormFieldBase, type INPUT_TYPES } from '#core/components/Form/types';
|
|
2
2
|
export interface IToggleFieldProps extends IFieldProps {
|
|
3
|
-
color?: string;
|
|
4
|
-
ui?: object | any;
|
|
5
3
|
}
|
|
6
|
-
export type IToggleField = IFormFieldBase<INPUT_TYPES.TOGGLE, IToggleFieldProps,
|
|
7
|
-
change?: (value: string) => void;
|
|
8
|
-
}>;
|
|
4
|
+
export type IToggleField = IFormFieldBase<INPUT_TYPES.TOGGLE, IToggleFieldProps, never>;
|
|
@@ -24,23 +24,22 @@ export declare const enum INPUT_TYPES {
|
|
|
24
24
|
export interface IFieldProps {
|
|
25
25
|
form?: FormContext;
|
|
26
26
|
name: string;
|
|
27
|
+
errorMessage?: string;
|
|
27
28
|
label?: string | any;
|
|
29
|
+
description?: string;
|
|
30
|
+
hint?: string;
|
|
31
|
+
size?: string;
|
|
28
32
|
rules?: any;
|
|
29
33
|
autoFocus?: boolean;
|
|
30
34
|
class?: any;
|
|
31
35
|
classInner?: any;
|
|
32
|
-
classInputInner?: any;
|
|
33
36
|
placeholder?: string;
|
|
34
37
|
isDisabled?: boolean;
|
|
35
38
|
isRequired?: boolean;
|
|
36
|
-
isLoading?: boolean;
|
|
37
39
|
help?: string;
|
|
38
|
-
|
|
39
|
-
customErrorMessage?: string | any;
|
|
40
|
-
transform?: (value: any, oldValue: any, e: InputEvent) => any;
|
|
41
|
-
getInstance?: (el: HTMLElement) => void;
|
|
40
|
+
ui?: object | any;
|
|
42
41
|
}
|
|
43
|
-
export interface IFormFieldBase<I extends INPUT_TYPES, P, O> {
|
|
42
|
+
export interface IFormFieldBase<I extends INPUT_TYPES, P extends IFieldProps, O> {
|
|
44
43
|
type: I;
|
|
45
44
|
component?: Component;
|
|
46
45
|
class?: any;
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComputedRef } from 'vue';
|
|
2
2
|
import { type FieldContext, type FieldOptions } from 'vee-validate';
|
|
3
|
-
import { type IFormField } from '#core/components/Form/types';
|
|
4
|
-
export interface IFieldWrapperProps {
|
|
5
|
-
errorMessage?: string;
|
|
6
|
-
label?: string | any;
|
|
7
|
-
className?: any;
|
|
8
|
-
classInner?: any;
|
|
9
|
-
classInputInner?: any;
|
|
10
|
-
isRequired?: boolean;
|
|
11
|
-
isHideLabel?: boolean;
|
|
12
|
-
customErrorMessage?: string | DefineComponent;
|
|
13
|
-
name: string;
|
|
14
|
-
help?: string;
|
|
15
|
-
}
|
|
3
|
+
import { type IFieldProps, type IFormField } from '#core/components/Form/types';
|
|
16
4
|
interface IFieldContext<TValue> extends FieldContext<TValue> {
|
|
17
|
-
|
|
18
|
-
onChange: (e: InputEvent) => void;
|
|
19
|
-
fieldClassName: ComputedRef<any[]>;
|
|
20
|
-
disabled: boolean;
|
|
21
|
-
wrapperProps: ComputedRef<IFieldWrapperProps>;
|
|
5
|
+
wrapperProps: ComputedRef<IFieldProps>;
|
|
22
6
|
}
|
|
23
7
|
export declare const useFieldHOC: <TValue = unknown>(newFormProps: IFieldProps, opts?: Partial<FieldOptions<TValue>> | undefined) => IFieldContext<TValue>;
|
|
24
8
|
export declare const createFormFields: (fields: () => IFormField[]) => any;
|
|
@@ -6,38 +6,11 @@ export const useFieldHOC = (newFormProps, opts) => {
|
|
|
6
6
|
form: newFormProps.form,
|
|
7
7
|
...opts
|
|
8
8
|
});
|
|
9
|
-
const onChange = (e) => {
|
|
10
|
-
const target = e.target;
|
|
11
|
-
const newValue = newFormProps.transform ? newFormProps.transform(target.value, field.value, e) : target.value;
|
|
12
|
-
target.value = newValue;
|
|
13
|
-
field.handleChange(newValue);
|
|
14
|
-
};
|
|
15
|
-
const fieldClassName = computed(() => {
|
|
16
|
-
return [
|
|
17
|
-
"form-control peer",
|
|
18
|
-
{
|
|
19
|
-
"input-error": !field.meta.valid && field.meta.dirty,
|
|
20
|
-
"input-success": field.meta.valid && field.meta.dirty
|
|
21
|
-
}
|
|
22
|
-
];
|
|
23
|
-
});
|
|
24
9
|
return {
|
|
25
10
|
...field,
|
|
26
|
-
isRequired: !!newFormProps.isRequired,
|
|
27
|
-
onChange,
|
|
28
|
-
fieldClassName,
|
|
29
|
-
disabled: !!newFormProps.isDisabled,
|
|
30
11
|
wrapperProps: computed(() => ({
|
|
31
|
-
|
|
32
|
-
errorMessage: field.errorMessage.value
|
|
33
|
-
className: newFormProps.class,
|
|
34
|
-
classInner: newFormProps.classInner,
|
|
35
|
-
classInputInner: newFormProps.classInputInner,
|
|
36
|
-
isRequired: newFormProps.isRequired,
|
|
37
|
-
isHideLabel: newFormProps.isHideLabel,
|
|
38
|
-
customErrorMessage: newFormProps.customErrorMessage,
|
|
39
|
-
name: newFormProps.name,
|
|
40
|
-
help: newFormProps.help
|
|
12
|
+
...newFormProps,
|
|
13
|
+
errorMessage: field.errorMessage.value
|
|
41
14
|
}))
|
|
42
15
|
};
|
|
43
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finema/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Finema Dev Core Team",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@vee-validate/nuxt": "^4.12.3",
|
|
40
40
|
"@vee-validate/zod": "^4.12.3",
|
|
41
41
|
"@vuepic/vue-datepicker": "^7.4.0",
|
|
42
|
-
"axios": "^1.
|
|
42
|
+
"axios": "^1.6.2",
|
|
43
43
|
"date-fns": "^3.0.6",
|
|
44
44
|
"i18next": "^23.7.11",
|
|
45
45
|
"lodash-es": "^4.17.21",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"eslint": "^8.56.0",
|
|
64
64
|
"husky": "^8.0.3",
|
|
65
65
|
"lint-staged": "^15.2.0",
|
|
66
|
-
"nuxt": "^3.
|
|
66
|
+
"nuxt": "^3.8.2",
|
|
67
67
|
"prettier": "^3.1.1",
|
|
68
68
|
"release-it": "^17.0.1",
|
|
69
69
|
"sass": "^1.69.5",
|