@finema/core 1.4.1 → 1.4.3

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 (38) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +158 -112
  3. package/dist/runtime/components/Core.vue +8 -1
  4. package/dist/runtime/components/Form/FieldWrapper.vue +6 -2
  5. package/dist/runtime/components/Form/InputCheckbox/index.vue +2 -3
  6. package/dist/runtime/components/Form/InputCheckbox/types.d.ts +1 -5
  7. package/dist/runtime/components/Form/InputDateTime/index.vue +15 -13
  8. package/dist/runtime/components/Form/InputRadio/index.vue +2 -2
  9. package/dist/runtime/components/Form/InputRadio/types.d.ts +1 -5
  10. package/dist/runtime/components/Form/InputSelect/index.vue +3 -3
  11. package/dist/runtime/components/Form/InputSelect/types.d.ts +0 -1
  12. package/dist/runtime/components/Form/InputStatic/index.vue +1 -1
  13. package/dist/runtime/components/Form/InputStatic/types.d.ts +1 -1
  14. package/dist/runtime/components/Form/InputText/index.vue +5 -8
  15. package/dist/runtime/components/Form/InputText/types.d.ts +2 -3
  16. package/dist/runtime/components/Form/InputTextarea/index.vue +4 -8
  17. package/dist/runtime/components/Form/InputTextarea/types.d.ts +1 -6
  18. package/dist/runtime/components/Form/InputToggle/index.vue +2 -2
  19. package/dist/runtime/components/Form/InputToggle/types.d.ts +1 -5
  20. package/dist/runtime/components/Form/types.d.ts +7 -7
  21. package/dist/runtime/composables/useForm.d.ts +3 -19
  22. package/dist/runtime/composables/useForm.mjs +3 -29
  23. package/dist/runtime/types/config.d.ts +1 -1
  24. package/dist/runtime/ui.config/checkbox.d.ts +3 -0
  25. package/dist/runtime/ui.config/checkbox.mjs +1 -0
  26. package/dist/runtime/ui.config/formGroup.d.ts +3 -0
  27. package/dist/runtime/ui.config/formGroup.mjs +5 -0
  28. package/dist/runtime/ui.config/input.d.ts +3 -0
  29. package/dist/runtime/ui.config/input.mjs +5 -0
  30. package/dist/runtime/ui.config/select.d.ts +3 -0
  31. package/dist/runtime/ui.config/select.mjs +5 -0
  32. package/dist/runtime/ui.config/selectMenu.d.ts +3 -0
  33. package/dist/runtime/ui.config/selectMenu.mjs +5 -0
  34. package/dist/runtime/ui.config/textarea.d.ts +3 -0
  35. package/dist/runtime/ui.config/textarea.mjs +5 -0
  36. package/dist/runtime/ui.config/toggle.d.ts +3 -0
  37. package/dist/runtime/ui.config/toggle.mjs +5 -0
  38. package/package.json +1 -1
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "configKey": "core",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.7.4"
package/dist/module.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { defineNuxtModule, createResolver, installModule, addPlugin, addComponentsDir, addImportsDir } from '@nuxt/kit';
2
- import { merge } from 'lodash-es';
2
+ import 'lodash-es';
3
3
 
4
4
  const name = "@finema/core";
5
- const version = "1.4.1";
5
+ const version = "1.4.3";
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)
@@ -182,6 +181,139 @@ const button = {
182
181
 
183
182
  const buttonGroup = {};
184
183
 
184
+ const formGroup = {
185
+ default: {
186
+ size: "lg"
187
+ }
188
+ };
189
+
190
+ const checkbox = {};
191
+
192
+ const input = {
193
+ default: {
194
+ size: "lg"
195
+ }
196
+ };
197
+
198
+ const select = {
199
+ default: {
200
+ size: "lg"
201
+ }
202
+ };
203
+
204
+ const selectMenu = {
205
+ default: {
206
+ size: "lg"
207
+ }
208
+ };
209
+
210
+ const textarea = {
211
+ default: {
212
+ size: "lg"
213
+ }
214
+ };
215
+
216
+ const toggle = {
217
+ default: {
218
+ size: "lg"
219
+ }
220
+ };
221
+
222
+ const colorModeOptions = {
223
+ preference: "light"
224
+ };
225
+ const veeValidateNuxtOptions = {
226
+ // disable or enable auto imports
227
+ autoImports: true,
228
+ // Use different names for components
229
+ componentNames: {
230
+ Form: "VForm",
231
+ Field: "VField",
232
+ FieldArray: "VFieldArray",
233
+ ErrorMessage: "VErrorMessage"
234
+ }
235
+ };
236
+ const nuxtSecurityOptions = {
237
+ headers: {
238
+ xXSSProtection: "1; mode=block",
239
+ crossOriginEmbedderPolicy: "unsafe-none",
240
+ contentSecurityPolicy: {
241
+ "img-src": ["*", "'self'", "data:", "https"],
242
+ "script-src": [
243
+ "'self'",
244
+ "'unsafe-inline'",
245
+ "https://www.google-analytics.com",
246
+ "https://www.googletagmanager.com",
247
+ "https://fonts.googleapis.com",
248
+ "https://cdnjs.cloudflare.com"
249
+ ],
250
+ "script-src-attr": [
251
+ "'unsafe-inline'",
252
+ "https://www.google-analytics.com",
253
+ "https://www.googletagmanager.com",
254
+ "https://fonts.googleapis.com",
255
+ "https://cdnjs.cloudflare.com"
256
+ ]
257
+ }
258
+ }
259
+ };
260
+ const nuxtAppOptions = {
261
+ head: {
262
+ htmlAttrs: {
263
+ lang: "en"
264
+ },
265
+ meta: [
266
+ { charset: "utf-8" },
267
+ {
268
+ name: "viewport",
269
+ content: "width=device-width, initial-scale=1"
270
+ },
271
+ {
272
+ id: "description",
273
+ name: "description",
274
+ content: ""
275
+ },
276
+ {
277
+ name: "format-detection",
278
+ content: "telephone=no"
279
+ }
280
+ ],
281
+ link: [
282
+ {
283
+ rel: "preconnect",
284
+ href: "https://fonts.googleapis.com"
285
+ },
286
+ {
287
+ rel: "preconnect",
288
+ href: "https://fonts.gstatic.com",
289
+ crossorigin: ""
290
+ },
291
+ {
292
+ rel: "dns-prefetch",
293
+ href: "https://www.google-analytics.com/"
294
+ },
295
+ {
296
+ rel: "preconnect",
297
+ href: "https://www.google-analytics.com/",
298
+ crossorigin: ""
299
+ },
300
+ {
301
+ rel: "icon",
302
+ type: "image/x-icon",
303
+ href: "/favicon.ico"
304
+ }
305
+ ]
306
+ }
307
+ };
308
+ const nuxtRunTimeConfigOptions = {
309
+ public: {
310
+ baseAPI: process.env.APP_BASE_API,
311
+ baseAPIMock: process.env.APP_BASE_API_MOCK,
312
+ baseInternalAPI: process.env.APP_BASE_INTERNAL_API,
313
+ port: process.env.PORT || "3000"
314
+ }
315
+ };
316
+
185
317
  const module = defineNuxtModule({
186
318
  meta: {
187
319
  name,
@@ -216,122 +348,36 @@ const module = defineNuxtModule({
216
348
  await installModule("@nuxt/ui", {
217
349
  safelistColors: ["secondary", "success", "info", "danger", "warning"]
218
350
  });
219
- nuxt.options.appConfig.ui = _merge(nuxt.options.appConfig.ui || {}, {
220
- table,
221
- pagination,
222
- alert,
223
- button,
224
- buttonGroup
225
- });
226
- nuxt.options.appConfig.ui.strategy = "override";
227
- nuxt.options.runtimeConfig = _deepMerge(
351
+ nuxt.options.appConfig.ui = _deepMerge(
228
352
  {},
229
353
  {
230
- public: {
231
- baseAPI: process.env.APP_BASE_API,
232
- baseAPIMock: process.env.APP_BASE_API_MOCK,
233
- baseInternalAPI: process.env.APP_BASE_INTERNAL_API,
234
- port: process.env.PORT || "3000"
235
- }
354
+ table,
355
+ pagination,
356
+ alert,
357
+ button,
358
+ buttonGroup,
359
+ formGroup,
360
+ checkbox,
361
+ input,
362
+ select,
363
+ selectMenu,
364
+ textarea,
365
+ toggle
236
366
  },
237
- nuxt.options.runtimeConfig
367
+ nuxt.options.appConfig.ui
238
368
  );
239
- nuxt.options.app = _deepMerge(
240
- {},
241
- {
242
- head: {
243
- htmlAttrs: {
244
- lang: "en"
245
- },
246
- meta: [
247
- { charset: "utf-8" },
248
- {
249
- name: "viewport",
250
- content: "width=device-width, initial-scale=1"
251
- },
252
- {
253
- id: "description",
254
- name: "description",
255
- content: ""
256
- },
257
- {
258
- name: "format-detection",
259
- content: "telephone=no"
260
- }
261
- ],
262
- link: [
263
- {
264
- rel: "preconnect",
265
- href: "https://fonts.googleapis.com"
266
- },
267
- {
268
- rel: "preconnect",
269
- href: "https://fonts.gstatic.com",
270
- crossorigin: ""
271
- },
272
- {
273
- rel: "dns-prefetch",
274
- href: "https://www.google-analytics.com/"
275
- },
276
- {
277
- rel: "preconnect",
278
- href: "https://www.google-analytics.com/",
279
- crossorigin: ""
280
- },
281
- {
282
- rel: "icon",
283
- type: "image/x-icon",
284
- href: "/favicon.ico"
285
- }
286
- ]
287
- }
288
- },
289
- nuxt.options.app
290
- );
291
- nuxt.options.colorMode = _deepMerge(
369
+ nuxt.options.appConfig.ui.strategy = "override";
370
+ nuxt.options.app = _deepMerge({}, nuxtAppOptions, nuxt.options.app);
371
+ nuxt.options.colorMode = _deepMerge({}, colorModeOptions, nuxt.options.colorMode);
372
+ nuxt.options.devtools = _deepMerge({}, { enabled: true }, nuxt.options.devtools);
373
+ nuxt.options.runtimeConfig = _deepMerge(
292
374
  {},
293
- {
294
- preference: "light"
295
- },
296
- nuxt.options.colorMode
375
+ nuxtRunTimeConfigOptions,
376
+ nuxt.options.runtimeConfig
297
377
  );
298
- nuxt.options.devtools = _deepMerge({}, { enabled: true }, nuxt.options.devtools);
299
378
  await installModule("@pinia/nuxt");
300
- await installModule("@vee-validate/nuxt", {
301
- // disable or enable auto imports
302
- autoImports: true,
303
- // Use different names for components
304
- componentNames: {
305
- Form: "VForm",
306
- Field: "VField",
307
- FieldArray: "VFieldArray",
308
- ErrorMessage: "VErrorMessage"
309
- }
310
- });
311
- await installModule("nuxt-security", {
312
- headers: {
313
- xXSSProtection: "1; mode=block",
314
- crossOriginEmbedderPolicy: "unsafe-none",
315
- contentSecurityPolicy: {
316
- "img-src": ["*", "'self'", "data:", "https"],
317
- "script-src": [
318
- "'self'",
319
- "'unsafe-inline'",
320
- "https://www.google-analytics.com",
321
- "https://www.googletagmanager.com",
322
- "https://fonts.googleapis.com",
323
- "https://cdnjs.cloudflare.com"
324
- ],
325
- "script-src-attr": [
326
- "'unsafe-inline'",
327
- "https://www.google-analytics.com",
328
- "https://www.googletagmanager.com",
329
- "https://fonts.googleapis.com",
330
- "https://cdnjs.cloudflare.com"
331
- ]
332
- }
333
- }
334
- });
379
+ await installModule("@vee-validate/nuxt", veeValidateNuxtOptions);
380
+ await installModule("nuxt-security", nuxtSecurityOptions);
335
381
  addPlugin({
336
382
  src: resolve(runtimeDir, "plugin")
337
383
  });
@@ -1,4 +1,11 @@
1
1
  <template>
2
+ <NuxtLoadingIndicator :color="color" />
2
3
  <Dialog />
3
4
  </template>
4
- <script lang="ts" setup></script>
5
+ <script lang="ts" setup>
6
+ defineProps({
7
+ color: {
8
+ type: String,
9
+ },
10
+ })
11
+ </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 IFieldWrapperProps } from '#core/composables/useForm'
17
+ import { type IFieldProps } from '#core/components/Form/types'
14
18
 
15
- defineProps<IFieldWrapperProps>()
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="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, disabled, handleChange, isRequired } = useFieldHOC<boolean>(props)
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,18 +2,28 @@
2
2
  <FieldWrapper v-bind="wrapperProps">
3
3
  <Datepicker
4
4
  v-model="value"
5
- :disabled="disabled"
5
+ :disabled="wrapperProps.isDisabled"
6
6
  cancel-text="ยกเลิก"
7
7
  select-text="เลือก"
8
8
  locale="th"
9
9
  :enable-time-picker="!disabledTime"
10
- :placeholder="placeholder || 'เลือกวันที่'"
10
+ :placeholder="wrapperProps.placeholder"
11
11
  :format="format"
12
12
  :min-date="minDate"
13
13
  :max-date="maxDate"
14
14
  :required="isRequired"
15
- @change="handleChange"
16
- />
15
+ >
16
+ <template #dp-input="{ value }">
17
+ <UInput
18
+ icon="i-heroicons-calendar-days"
19
+ type="text"
20
+ :value="value"
21
+ :placeholder="wrapperProps.placeholder"
22
+ :readonly="true"
23
+ input-class="cursor-pointer select-none"
24
+ />
25
+ </template>
26
+ </Datepicker>
17
27
  </FieldWrapper>
18
28
  </template>
19
29
  <script lang="ts" setup>
@@ -24,9 +34,8 @@ import { TimeHelper, useFieldHOC } from '#imports'
24
34
  import '@vuepic/vue-datepicker/dist/main.css'
25
35
 
26
36
  const props = withDefaults(defineProps<IDateTimeFieldProps>(), {})
27
- const emits = defineEmits<(event: 'change', value: string) => void>()
28
37
 
29
- const { value, wrapperProps, onChange, disabled } = useFieldHOC<string>(props)
38
+ const { value, wrapperProps } = useFieldHOC<string>(props)
30
39
 
31
40
  const format = (date: Date) => {
32
41
  if (props.disabledTime) {
@@ -35,11 +44,4 @@ const format = (date: Date) => {
35
44
 
36
45
  return TimeHelper.getDateTimeFormTime(date as any)
37
46
  }
38
-
39
- const handleChange = (e: InputEvent) => {
40
- onChange(e)
41
- const target = e.target as HTMLInputElement
42
-
43
- emits('change', target?.value)
44
- }
45
47
  </script>
@@ -3,7 +3,7 @@
3
3
  <URadioGroup
4
4
  v-model="value"
5
5
  :options="options"
6
- :disabled="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, disabled, handleChange, isRequired } = useFieldHOC<any>(props)
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="disabled"
9
- :loading="isLoading"
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, disabled, handleChange, isRequired } = useFieldHOC<any>(props)
36
+ const { value, wrapperProps } = useFieldHOC<any>(props)
37
37
  </script>
@@ -6,7 +6,6 @@ export interface ISelectFieldProps extends IFieldProps {
6
6
  size?: string;
7
7
  searchablePlaceholder?: string;
8
8
  loading?: boolean;
9
- ui?: object | any;
10
9
  uiMenu?: object | any;
11
10
  options: IOption[];
12
11
  }
@@ -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, label, wrapperProps, disabled } = useFieldHOC<string>(props)
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,13 @@
2
2
  <FieldWrapper v-bind="wrapperProps">
3
3
  <UInput
4
4
  v-model="value"
5
- :disabled="disabled"
5
+ :disabled="wrapperProps.isDisabled"
6
6
  :name="name"
7
- :placeholder="placeholder ?? props.label"
7
+ :placeholder="wrapperProps.placeholder"
8
8
  :type="isShowPassword ? 'text' : props.type || 'text'"
9
9
  :autofocus="!!autoFocus"
10
- :color="color"
10
+ :icon="icon"
11
+ :readonly="isReadonly"
11
12
  :ui="ui"
12
13
  />
13
14
  </FieldWrapper>
@@ -19,12 +20,8 @@ import { useFieldHOC } from '#core/composables/useForm'
19
20
  import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
20
21
 
21
22
  const props = withDefaults(defineProps<ITextFieldProps>(), {})
22
- const emits = defineEmits<{
23
- (event: 'change', value: string): void
24
- (event: 'blur', value: string): void
25
- }>()
26
23
 
27
- const { value, wrapperProps, disabled, handleChange } = useFieldHOC<string>(props)
24
+ const { value, wrapperProps } = useFieldHOC<string>(props)
28
25
 
29
26
  const isShowPassword = ref(false)
30
27
  </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
- color?: string;
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,14 @@
2
2
  <FieldWrapper v-bind="wrapperProps">
3
3
  <UTextarea
4
4
  v-model="value"
5
- :disabled="disabled"
5
+ :disabled="wrapperProps.isDisabled"
6
6
  :name="name"
7
7
  :resize="resize"
8
- :placeholder="placeholder ?? props.label"
8
+ :placeholder="wrapperProps.placeholder"
9
9
  :autofocus="!!autoFocus"
10
10
  :autoresize="autoresize"
11
11
  :rows="rows"
12
- :color="color"
12
+ :readonly="isReadonly"
13
13
  :ui="ui"
14
14
  />
15
15
  </FieldWrapper>
@@ -20,10 +20,6 @@ import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
20
20
  import { type ITextareaFieldProps } from '#core/components/Form/InputTextarea/types'
21
21
 
22
22
  const props = withDefaults(defineProps<ITextareaFieldProps>(), {})
23
- const emits = defineEmits<{
24
- (event: 'change', value: string): void
25
- (event: 'blur', value: string): void
26
- }>()
27
23
 
28
- const { value, wrapperProps, disabled, handleChange } = useFieldHOC<string>(props)
24
+ const { value, wrapperProps } = useFieldHOC<string>(props)
29
25
  </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="disabled" :name="name" :color="color" :ui="ui" />
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, disabled, handleChange } = useFieldHOC<boolean>(props)
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,23 @@ 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;
38
+ isReadonly?: boolean;
35
39
  isRequired?: boolean;
36
- isLoading?: boolean;
37
40
  help?: string;
38
- isHideLabel?: boolean;
39
- customErrorMessage?: string | any;
40
- transform?: (value: any, oldValue: any, e: InputEvent) => any;
41
- getInstance?: (el: HTMLElement) => void;
41
+ ui?: object | any;
42
42
  }
43
- export interface IFormFieldBase<I extends INPUT_TYPES, P, O> {
43
+ export interface IFormFieldBase<I extends INPUT_TYPES, P extends IFieldProps, O> {
44
44
  type: I;
45
45
  component?: Component;
46
46
  class?: any;
@@ -1,24 +1,8 @@
1
- import { type DefineComponent, type ComputedRef } from 'vue';
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
- isRequired: boolean;
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,12 @@ 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
- label: newFormProps.label,
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
+ placeholder: newFormProps.placeholder || newFormProps.label,
14
+ errorMessage: field.errorMessage.value
41
15
  }))
42
16
  };
43
17
  };
@@ -1 +1 @@
1
- export type UIComponentList = 'modal' | 'slideover' | 'dropdown' | 'icon' | 'button' | 'buttonGroup' | 'tabs' | 'card' | 'breadcrumb' | 'badge';
1
+ export type UIComponentList = 'modal' | 'slideover' | 'dropdown' | 'icon' | 'button' | 'buttonGroup' | 'tabs' | 'card' | 'breadcrumb' | 'badge' | 'input';
@@ -0,0 +1,3 @@
1
+ import type { DeepPartial } from '#ui/types';
2
+ import type * as config from '#ui/ui.config';
3
+ export declare const checkbox: DeepPartial<(typeof config)['checkbox']>;
@@ -0,0 +1 @@
1
+ export const checkbox = {};
@@ -0,0 +1,3 @@
1
+ import type { DeepPartial } from '#ui/types';
2
+ import type * as config from '#ui/ui.config';
3
+ export declare const formGroup: DeepPartial<(typeof config)['formGroup']>;
@@ -0,0 +1,5 @@
1
+ export const formGroup = {
2
+ default: {
3
+ size: "lg"
4
+ }
5
+ };
@@ -0,0 +1,3 @@
1
+ import type { DeepPartial } from '#ui/types';
2
+ import type * as config from '#ui/ui.config';
3
+ export declare const input: DeepPartial<(typeof config)['input']>;
@@ -0,0 +1,5 @@
1
+ export const input = {
2
+ default: {
3
+ size: "lg"
4
+ }
5
+ };
@@ -0,0 +1,3 @@
1
+ import type { DeepPartial } from '#ui/types';
2
+ import type * as config from '#ui/ui.config';
3
+ export declare const select: DeepPartial<(typeof config)['select']>;
@@ -0,0 +1,5 @@
1
+ export const select = {
2
+ default: {
3
+ size: "lg"
4
+ }
5
+ };
@@ -0,0 +1,3 @@
1
+ import type { DeepPartial } from '#ui/types';
2
+ import type * as config from '#ui/ui.config';
3
+ export declare const selectMenu: DeepPartial<(typeof config)['selectMenu']>;
@@ -0,0 +1,5 @@
1
+ export const selectMenu = {
2
+ default: {
3
+ size: "lg"
4
+ }
5
+ };
@@ -0,0 +1,3 @@
1
+ import type { DeepPartial } from '#ui/types';
2
+ import type * as config from '#ui/ui.config';
3
+ export declare const textarea: DeepPartial<(typeof config)['textarea']>;
@@ -0,0 +1,5 @@
1
+ export const textarea = {
2
+ default: {
3
+ size: "lg"
4
+ }
5
+ };
@@ -0,0 +1,3 @@
1
+ import type { DeepPartial } from '#ui/types';
2
+ import type * as config from '#ui/ui.config';
3
+ export declare const toggle: DeepPartial<(typeof config)['toggle']>;
@@ -0,0 +1,5 @@
1
+ export const toggle = {
2
+ default: {
3
+ size: "lg"
4
+ }
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",