@finema/core 1.3.2 → 1.3.5

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 (29) hide show
  1. package/README.md +88 -88
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +4 -31
  4. package/dist/runtime/components/Avatar.vue +27 -0
  5. package/dist/runtime/components/Button/Group.vue +31 -31
  6. package/dist/runtime/components/Button/index.vue +17 -17
  7. package/dist/runtime/components/Core.vue +4 -4
  8. package/dist/runtime/components/Dialog/index.vue +63 -63
  9. package/dist/runtime/components/Dropdown/index.vue +80 -0
  10. package/dist/runtime/components/Dropdown/types.d.ts +2 -0
  11. package/dist/runtime/components/Dropdown/types.mjs +17 -0
  12. package/dist/runtime/components/Form/FieldWrapper.vue +10 -10
  13. package/dist/runtime/components/Form/Fields.vue +41 -41
  14. package/dist/runtime/components/Form/InputSelect/SelectMenu.vue +11 -11
  15. package/dist/runtime/components/Form/InputSelect/index.vue +11 -11
  16. package/dist/runtime/components/Form/InputStatic/index.vue +16 -16
  17. package/dist/runtime/components/Form/InputText/index.vue +30 -28
  18. package/dist/runtime/components/Form/InputText/types.d.ts +2 -0
  19. package/dist/runtime/components/Form/InputToggle/index.vue +14 -14
  20. package/dist/runtime/components/Form/index.vue +6 -6
  21. package/dist/runtime/components/Loader.vue +6 -6
  22. package/dist/runtime/components/Modal/index.vue +145 -145
  23. package/dist/runtime/components/Slideover/index.vue +109 -109
  24. package/dist/runtime/components/Table/index.vue +84 -84
  25. package/dist/runtime/types/config.d.ts +1 -1
  26. package/dist/runtime/ui.css +14 -14
  27. package/dist/runtime/utils/lodash.d.ts +109 -29
  28. package/dist/runtime/utils/lodash.mjs +60 -30
  29. package/package.json +79 -79
package/README.md CHANGED
@@ -1,88 +1,88 @@
1
- # @finema/core Nuxt Module
2
-
3
- [✨  Release Notes](/CHANGELOG.md)
4
-
5
- ## Todos
6
-
7
- - [ ] Loader
8
- - [ ] Button
9
- - [ ] Table
10
- - [ ] Icon
11
- - [ ] Badge
12
- - [ ] Status
13
- - Form
14
- - [ ] Static
15
- - [ ] Input
16
- - [ ] Textarea
17
- - [ ] Select
18
- - [ ] Select multi
19
- - [ ] Checkbox
20
- - [ ] radio
21
- - [ ] toggle
22
- - [ ] datetime
23
- - [ ] upload
24
- - [ ] upload multi
25
- - [ ] Modal
26
- - [ ] Notification
27
- - [ ] Card
28
- - [ ] Tab
29
- - [ ] Alert
30
- - [ ] Container
31
- - [ ] Dropdown
32
-
33
- ## Features
34
-
35
- - UI components
36
- - Useful composables
37
- - Security
38
-
39
- ## Quick Setup
40
-
41
- 1. Add `@finema/core` dependency to your project
42
-
43
- ```bash
44
- # Using pnpm
45
- pnpm add -D @finema/core
46
-
47
- # Using yarn
48
- yarn add --dev @finema/core
49
-
50
- ```
51
-
52
- 1. Add `@finema/core` to the `modules` section of `nuxt.config.ts`
53
-
54
- ```js
55
- export default defineNuxtConfig({
56
- modules: [
57
- '@finema/core'
58
- ]
59
- })
60
- ```
61
-
62
- That's it! You can now use @finema/core in your Nuxt app ✨
63
-
64
- ## Development
65
-
66
- ```bash
67
- # Install dependencies
68
- npm install
69
-
70
- # Generate type stubs
71
- npm run dev:prepare
72
-
73
- # Develop with the playground
74
- npm run dev
75
-
76
- # Build the playground
77
- npm run dev:build
78
-
79
- # Run ESLint
80
- npm run lint
81
-
82
- # Run Vitest
83
- npm run test
84
- npm run test:watch
85
-
86
- # Release new version
87
- npm run release
88
- ```
1
+ # @finema/core Nuxt Module
2
+
3
+ [✨  Release Notes](/CHANGELOG.md)
4
+
5
+ ## Todos
6
+
7
+ - [ ] Loader
8
+ - [ ] Button
9
+ - [ ] Table
10
+ - [ ] Icon
11
+ - [ ] Badge
12
+ - [ ] Status
13
+ - Form
14
+ - [ ] Static
15
+ - [ ] Input
16
+ - [ ] Textarea
17
+ - [ ] Select
18
+ - [ ] Select multi
19
+ - [ ] Checkbox
20
+ - [ ] radio
21
+ - [ ] toggle
22
+ - [ ] datetime
23
+ - [ ] upload
24
+ - [ ] upload multi
25
+ - [ ] Modal
26
+ - [ ] Notification
27
+ - [ ] Card
28
+ - [ ] Tab
29
+ - [ ] Alert
30
+ - [ ] Container
31
+ - [ ] Dropdown
32
+
33
+ ## Features
34
+
35
+ - UI components
36
+ - Useful composables
37
+ - Security
38
+
39
+ ## Quick Setup
40
+
41
+ 1. Add `@finema/core` dependency to your project
42
+
43
+ ```bash
44
+ # Using pnpm
45
+ pnpm add -D @finema/core
46
+
47
+ # Using yarn
48
+ yarn add --dev @finema/core
49
+
50
+ ```
51
+
52
+ 1. Add `@finema/core` to the `modules` section of `nuxt.config.ts`
53
+
54
+ ```js
55
+ export default defineNuxtConfig({
56
+ modules: [
57
+ '@finema/core'
58
+ ]
59
+ })
60
+ ```
61
+
62
+ That's it! You can now use @finema/core in your Nuxt app ✨
63
+
64
+ ## Development
65
+
66
+ ```bash
67
+ # Install dependencies
68
+ npm install
69
+
70
+ # Generate type stubs
71
+ npm run dev:prepare
72
+
73
+ # Develop with the playground
74
+ npm run dev
75
+
76
+ # Build the playground
77
+ npm run dev:build
78
+
79
+ # Run ESLint
80
+ npm run lint
81
+
82
+ # Run Vitest
83
+ npm run test
84
+ npm run test:watch
85
+
86
+ # Release new version
87
+ npm run release
88
+ ```
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.3.2",
3
+ "version": "1.3.5",
4
4
  "configKey": "core",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.7.4"
package/dist/module.mjs CHANGED
@@ -1,37 +1,8 @@
1
1
  import { defineNuxtModule, createResolver, installModule, addPlugin, addComponentsDir, addImportsDir } from '@nuxt/kit';
2
- import lodash from 'lodash';
2
+ import { merge } from 'lodash-es';
3
3
 
4
4
  const name = "@finema/core";
5
- const version = "1.3.2";
6
-
7
- lodash.get;
8
- lodash.range;
9
- lodash.concat;
10
- lodash.toNumber;
11
- lodash.isUndefined;
12
- lodash.dropRight;
13
- lodash.intersection;
14
- lodash.set;
15
- lodash.map;
16
- const _merge = lodash.merge;
17
- lodash.flattenDeep;
18
- lodash.uniq;
19
- lodash.sortBy;
20
- lodash.uniqBy;
21
- lodash.random;
22
- lodash.cloneDeep;
23
- lodash.isEmpty;
24
- lodash.isObject;
25
- lodash.isArray;
26
- lodash.findIndex;
27
- lodash.isEqual;
28
- lodash.difference;
29
- lodash.shuffle;
30
- lodash.size;
31
- lodash.toPairs;
32
- lodash.orderBy;
33
- lodash.fromPairs;
34
- lodash.xor;
5
+ const version = "1.3.5";
35
6
 
36
7
  const colors = {
37
8
  black: "#20243E",
@@ -112,6 +83,8 @@ const ui = {
112
83
  safelistColors: ["secondary"]
113
84
  };
114
85
 
86
+ const _merge = merge;
87
+
115
88
  const module = defineNuxtModule({
116
89
  meta: {
117
90
  name,
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <UAvatar v-bind="$attrs" :src="src" :alt="alt" :size="size" />
3
+ </template>
4
+
5
+ <script lang="ts" setup>
6
+ import { type PropType } from '#imports'
7
+ import { type AvatarSize } from '#ui/types'
8
+
9
+ defineOptions({
10
+ inheritAttrs: true,
11
+ })
12
+
13
+ defineProps({
14
+ src: {
15
+ type: String,
16
+ required: true,
17
+ },
18
+ alt: {
19
+ type: String,
20
+ required: true,
21
+ },
22
+ size: {
23
+ type: String as PropType<AvatarSize>,
24
+ default: 'sm',
25
+ },
26
+ })
27
+ </script>
@@ -1,31 +1,31 @@
1
- <template>
2
- <div>
3
- <UButtonGroup v-bind="$attrs">
4
- <Button label="Button" />
5
- <Button color="blue" size="xs">
6
- <svg
7
- xmlns="http://www.w3.org/2000/svg"
8
- fill="none"
9
- viewBox="0 0 24 24"
10
- stroke-width="1.5"
11
- stroke="currentColor"
12
- class="h-3 w-3"
13
- >
14
- <path
15
- stroke-linecap="round"
16
- stroke-linejoin="round"
17
- d="M19.5 13.5L12 21m0 0l-7.5-7.5M12 21V3"
18
- />
19
- </svg>
20
- </Button>
21
- </UButtonGroup>
22
- </div>
23
- </template>
24
-
25
- <script lang="ts" setup>
26
- defineOptions({
27
- inheritAttrs: true,
28
- })
29
- </script>
30
-
31
- <style></style>
1
+ <template>
2
+ <div>
3
+ <UButtonGroup v-bind="$attrs">
4
+ <Button label="Button" />
5
+ <Button color="blue" size="xs">
6
+ <svg
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ fill="none"
9
+ viewBox="0 0 24 24"
10
+ stroke-width="1.5"
11
+ stroke="currentColor"
12
+ class="h-3 w-3"
13
+ >
14
+ <path
15
+ stroke-linecap="round"
16
+ stroke-linejoin="round"
17
+ d="M19.5 13.5L12 21m0 0l-7.5-7.5M12 21V3"
18
+ />
19
+ </svg>
20
+ </Button>
21
+ </UButtonGroup>
22
+ </div>
23
+ </template>
24
+
25
+ <script lang="ts" setup>
26
+ defineOptions({
27
+ inheritAttrs: true,
28
+ })
29
+ </script>
30
+
31
+ <style></style>
@@ -1,17 +1,17 @@
1
- <template>
2
- <UButton v-bind="$attrs">
3
- <template #leading>
4
- <slot name="leading" />
5
- </template>
6
- <slot />
7
-
8
- <template #trailing>
9
- <slot name="trailing" />
10
- </template>
11
- </UButton>
12
- </template>
13
- <script lang="ts" setup>
14
- defineOptions({
15
- inheritAttrs: true,
16
- })
17
- </script>
1
+ <template>
2
+ <UButton v-bind="$attrs">
3
+ <template #leading>
4
+ <slot name="leading" />
5
+ </template>
6
+ <slot />
7
+
8
+ <template #trailing>
9
+ <slot name="trailing" />
10
+ </template>
11
+ </UButton>
12
+ </template>
13
+ <script lang="ts" setup>
14
+ defineOptions({
15
+ inheritAttrs: true,
16
+ })
17
+ </script>
@@ -1,4 +1,4 @@
1
- <template>
2
- <Dialog />
3
- </template>
4
- <script lang="ts" setup></script>
1
+ <template>
2
+ <Dialog />
3
+ </template>
4
+ <script lang="ts" setup></script>
@@ -1,63 +1,63 @@
1
- <template>
2
- <Modal v-if="dialog.meta?.type" v-model="dialog.isShow" class="dialog" prevent-close>
3
- <div :class="['flex items-center pt-8', { 'flex-col': !dialog.meta.isShowCancelBtn }]">
4
- <div
5
- :class="[
6
- {
7
- 'text-warning': dialog.meta?.type === DialogType.WARNING,
8
- 'text-danger': dialog.meta?.type === DialogType.ERROR,
9
- 'text-info': dialog.meta?.type === DialogType.INFO,
10
- 'text-success': dialog.meta?.type === DialogType.SUCCESS,
11
- 'mr-4': dialog.meta.isShowCancelBtn,
12
- },
13
- ]"
14
- >
15
- <em v-if="dialog.meta?.type === 'success'" class="ic ic-check-circle-solid dialog-icon" />
16
- <em v-if="dialog.meta?.type === 'info'" class="ic ic-info-circle-solid dialog-icon" />
17
- <em
18
- v-if="dialog.meta?.type === 'warning'"
19
- class="ic ic-exclamation-triangle-solid dialog-icon"
20
- />
21
- <em v-if="dialog.meta?.type === 'error'" class="ic ic-x-circle-solid dialog-icon" />
22
- </div>
23
- <div :class="['flex w-full flex-col', { 'mt-4 text-center': !dialog.meta.isShowCancelBtn }]">
24
- <h3 class="dialog-title">
25
- {{ dialog.meta?.title }}
26
- </h3>
27
- <p class="dialog-message">
28
- {{ dialog.meta?.message }}
29
- </p>
30
- </div>
31
- </div>
32
-
33
- <div :class="['mt-5 flex', dialog.meta.isShowCancelBtn ? 'justify-end' : 'justify-center ']">
34
- <Button
35
- v-if="dialog.meta?.isShowCancelBtn"
36
- class="text-gray mr-4"
37
- type="button"
38
- @click="dialog.closeDialogCancel"
39
- >
40
- {{ dialog.meta?.cancelText || 'ยกเลิก' }}
41
- </Button>
42
- <Button
43
- :class="[
44
- {
45
- 'btn-success': dialog.meta?.type === DialogType.SUCCESS,
46
- 'btn-danger': dialog.meta?.type === DialogType.ERROR,
47
- 'btn-info': dialog.meta?.type === DialogType.INFO,
48
- 'btn-warning': dialog.meta?.type === DialogType.WARNING,
49
- 'mr-3': dialog.meta.isShowCancelBtn,
50
- },
51
- ]"
52
- @click="dialog.closeDialogProceed"
53
- >
54
- {{ dialog.meta?.confirmText || 'ตกลง' }}
55
- </Button>
56
- </div>
57
- </Modal>
58
- </template>
59
- <script lang="tsx" setup>
60
- import { DialogType, useDialog } from '#core/composables/useDialog'
61
-
62
- const dialog = useDialog()
63
- </script>
1
+ <template>
2
+ <Modal v-if="dialog.meta?.type" v-model="dialog.isShow" class="dialog" prevent-close>
3
+ <div :class="['flex items-center pt-8', { 'flex-col': !dialog.meta.isShowCancelBtn }]">
4
+ <div
5
+ :class="[
6
+ {
7
+ 'text-warning': dialog.meta?.type === DialogType.WARNING,
8
+ 'text-danger': dialog.meta?.type === DialogType.ERROR,
9
+ 'text-info': dialog.meta?.type === DialogType.INFO,
10
+ 'text-success': dialog.meta?.type === DialogType.SUCCESS,
11
+ 'mr-4': dialog.meta.isShowCancelBtn,
12
+ },
13
+ ]"
14
+ >
15
+ <em v-if="dialog.meta?.type === 'success'" class="ic ic-check-circle-solid dialog-icon" />
16
+ <em v-if="dialog.meta?.type === 'info'" class="ic ic-info-circle-solid dialog-icon" />
17
+ <em
18
+ v-if="dialog.meta?.type === 'warning'"
19
+ class="ic ic-exclamation-triangle-solid dialog-icon"
20
+ />
21
+ <em v-if="dialog.meta?.type === 'error'" class="ic ic-x-circle-solid dialog-icon" />
22
+ </div>
23
+ <div :class="['flex w-full flex-col', { 'mt-4 text-center': !dialog.meta.isShowCancelBtn }]">
24
+ <h3 class="dialog-title">
25
+ {{ dialog.meta?.title }}
26
+ </h3>
27
+ <p class="dialog-message">
28
+ {{ dialog.meta?.message }}
29
+ </p>
30
+ </div>
31
+ </div>
32
+
33
+ <div :class="['mt-5 flex', dialog.meta.isShowCancelBtn ? 'justify-end' : 'justify-center ']">
34
+ <Button
35
+ v-if="dialog.meta?.isShowCancelBtn"
36
+ class="text-gray mr-4"
37
+ type="button"
38
+ @click="dialog.closeDialogCancel"
39
+ >
40
+ {{ dialog.meta?.cancelText || 'ยกเลิก' }}
41
+ </Button>
42
+ <Button
43
+ :class="[
44
+ {
45
+ 'btn-success': dialog.meta?.type === DialogType.SUCCESS,
46
+ 'btn-danger': dialog.meta?.type === DialogType.ERROR,
47
+ 'btn-info': dialog.meta?.type === DialogType.INFO,
48
+ 'btn-warning': dialog.meta?.type === DialogType.WARNING,
49
+ 'mr-3': dialog.meta.isShowCancelBtn,
50
+ },
51
+ ]"
52
+ @click="dialog.closeDialogProceed"
53
+ >
54
+ {{ dialog.meta?.confirmText || 'ตกลง' }}
55
+ </Button>
56
+ </div>
57
+ </Modal>
58
+ </template>
59
+ <script lang="tsx" setup>
60
+ import { DialogType, useDialog } from '#core/composables/useDialog'
61
+
62
+ const dialog = useDialog()
63
+ </script>
@@ -0,0 +1,80 @@
1
+ <template>
2
+ <UDropdown
3
+ v-if="renderOnMounted"
4
+ v-bind="attrs"
5
+ :items="items"
6
+ :mode="mode"
7
+ :open-delay="openDelay"
8
+ :close-delay="closeDelay"
9
+ :popper="{ placement: placement, arrow: arrow, offsetDistance: offset }"
10
+ :ui="ui"
11
+ >
12
+ <slot />
13
+
14
+ <template v-for="(_, slot) of $slots" #[slot]="slotProps">
15
+ <slot :name="slot" v-bind="slotProps || {}" />
16
+ </template>
17
+ </UDropdown>
18
+ </template>
19
+
20
+ <script lang="ts" setup>
21
+ import { type PropType, ref, onMounted, useUiConfig, useUI, toRef } from '#imports'
22
+ import { type DropdownItem } from '#ui/types'
23
+ import type { Strategy } from '#core/types/utils'
24
+ import { dropdown } from '#ui/ui.config'
25
+ import { DropdownPlacementArray, type DropdownPlacement } from './types'
26
+
27
+ const config = useUiConfig<typeof dropdown>(dropdown, 'dropdown')
28
+
29
+ const props = defineProps({
30
+ items: {
31
+ type: Array as PropType<DropdownItem[][]>,
32
+ default: () => [],
33
+ },
34
+ mode: {
35
+ type: String as PropType<'click' | 'hover'>,
36
+ default: 'click',
37
+ validator: (value: string) => ['click', 'hover'].includes(value),
38
+ },
39
+ arrow: {
40
+ type: Boolean,
41
+ default: false,
42
+ },
43
+ offset: {
44
+ type: Number,
45
+ default: 10,
46
+ },
47
+ openDelay: {
48
+ type: Number,
49
+ default: 0,
50
+ },
51
+ closeDelay: {
52
+ type: Number,
53
+ default: 0,
54
+ },
55
+ placement: {
56
+ type: String as PropType<DropdownPlacement>,
57
+ default: 'bottom-start',
58
+ validator: (value: DropdownPlacement) => DropdownPlacementArray.includes(value),
59
+ },
60
+ class: {
61
+ type: [String, Array, Object] as PropType<any>,
62
+ default: () => '',
63
+ },
64
+ ui: {
65
+ type: Object as PropType<Partial<typeof config & { strategy?: Strategy }>>,
66
+ default: () => ({}),
67
+ },
68
+ })
69
+
70
+ const renderOnMounted = ref(false)
71
+
72
+ onMounted(() => {
73
+ renderOnMounted.value = true
74
+ ui.value.item.avatar = {
75
+ base: 'flex-shrink-0',
76
+ } as any
77
+ })
78
+
79
+ const { ui, attrs } = useUI('dropdown', toRef(props, 'ui'), config, toRef(props, 'class'))
80
+ </script>
@@ -0,0 +1,2 @@
1
+ export type DropdownPlacement = 'auto' | 'auto-end' | 'auto-start' | 'bottom' | 'bottom-end' | 'bottom-start' | 'left' | 'left-end' | 'left-start' | 'right' | 'right-end' | 'right-start' | 'top' | 'top-end' | 'top-start';
2
+ export declare const DropdownPlacementArray: DropdownPlacement[];
@@ -0,0 +1,17 @@
1
+ export const DropdownPlacementArray = [
2
+ "auto",
3
+ "auto-end",
4
+ "auto-start",
5
+ "bottom",
6
+ "bottom-end",
7
+ "bottom-start",
8
+ "left",
9
+ "left-end",
10
+ "left-start",
11
+ "right",
12
+ "right-end",
13
+ "right-start",
14
+ "top",
15
+ "top-end",
16
+ "top-start"
17
+ ];
@@ -1,10 +1,10 @@
1
- <template>
2
- <UFormGroup :label="label" :name="name" :error="errorMessage" :required="!!isRequired">
3
- <slot />
4
- </UFormGroup>
5
- </template>
6
- <script lang="ts" setup>
7
- import { type IFieldWrapperProps } from '#core/composables/useForm'
8
-
9
- defineProps<IFieldWrapperProps>()
10
- </script>
1
+ <template>
2
+ <UFormGroup :label="label" :name="name" :error="errorMessage" :required="!!isRequired">
3
+ <slot />
4
+ </UFormGroup>
5
+ </template>
6
+ <script lang="ts" setup>
7
+ import { type IFieldWrapperProps } from '#core/composables/useForm'
8
+
9
+ defineProps<IFieldWrapperProps>()
10
+ </script>