una-nuxt-module 1.0.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.
Files changed (131) hide show
  1. package/README.md +84 -0
  2. package/dist/module.cjs +5 -0
  3. package/dist/module.d.mts +6 -0
  4. package/dist/module.d.ts +6 -0
  5. package/dist/module.json +9 -0
  6. package/dist/module.mjs +105 -0
  7. package/dist/runtime/assets/scss/styles.css +1249 -0
  8. package/dist/runtime/classes/FetchClient.d.ts +61 -0
  9. package/dist/runtime/classes/FetchClient.js +71 -0
  10. package/dist/runtime/components/layout/footer/Footer.vue +16 -0
  11. package/dist/runtime/components/layout/header/BtnExtendMenu.vue +29 -0
  12. package/dist/runtime/components/layout/header/Header.vue +7 -0
  13. package/dist/runtime/components/layout/header/HeaderMenu.vue +41 -0
  14. package/dist/runtime/components/layout/header/HeaderMenuTabs.vue +102 -0
  15. package/dist/runtime/components/layout/sidebar/NavCollapse.vue +38 -0
  16. package/dist/runtime/components/layout/sidebar/NavGroup.vue +9 -0
  17. package/dist/runtime/components/layout/sidebar/NavItem.vue +25 -0
  18. package/dist/runtime/components/layout/sidebar/SideBar.vue +74 -0
  19. package/dist/runtime/components/layout/sidebar/SideBarFooter.vue +69 -0
  20. package/dist/runtime/components/layout/sidebar/TopSideBarLogo.vue +25 -0
  21. package/dist/runtime/components/shared/authorization/AuthorizedRenderer.vue +41 -0
  22. package/dist/runtime/components/shared/buttons/BtnBack.vue +19 -0
  23. package/dist/runtime/components/shared/buttons/BtnCancel.vue +13 -0
  24. package/dist/runtime/components/shared/buttons/BtnConfirm.vue +14 -0
  25. package/dist/runtime/components/shared/containers/JsonViewer.vue +13 -0
  26. package/dist/runtime/components/shared/dates/DatePicker.vue +91 -0
  27. package/dist/runtime/components/shared/dialogs/DialogConfirmDelete.vue +32 -0
  28. package/dist/runtime/components/shared/dialogs/DialogExportTable.vue +42 -0
  29. package/dist/runtime/components/shared/feedback/LoadingSession.vue +17 -0
  30. package/dist/runtime/components/shared/feedback/SnackBar.vue +36 -0
  31. package/dist/runtime/components/shared/forms/FormBuilder/FieldBuilder.vue +251 -0
  32. package/dist/runtime/components/shared/forms/FormBuilder/FieldSlotMissed.vue +20 -0
  33. package/dist/runtime/components/shared/forms/FormBuilder/FormBuilder.vue +213 -0
  34. package/dist/runtime/components/shared/forms/FormBuilder/SteppersBuilder.vue +32 -0
  35. package/dist/runtime/components/shared/forms/FormBuilder/TabsBuilder.vue +30 -0
  36. package/dist/runtime/components/shared/forms/FormDialogWrapper.vue +48 -0
  37. package/dist/runtime/components/shared/forms/FormPageWrapper.vue +19 -0
  38. package/dist/runtime/components/shared/forms/FormSubmitSection.vue +48 -0
  39. package/dist/runtime/components/shared/navigation/BreadCrumbs.vue +21 -0
  40. package/dist/runtime/components/shared/tables/CustomTable.vue +261 -0
  41. package/dist/runtime/components/shared/tables/CustomTableHeader.vue +25 -0
  42. package/dist/runtime/components/shared/tables/NoDataMessage.vue +12 -0
  43. package/dist/runtime/components/shared/tables/TableSearchBar.vue +22 -0
  44. package/dist/runtime/components/shared/tables/buttons/BtnAdd.vue +25 -0
  45. package/dist/runtime/components/shared/tables/buttons/BtnDelete.vue +32 -0
  46. package/dist/runtime/components/shared/tables/buttons/BtnEdit.vue +30 -0
  47. package/dist/runtime/components/shared/tables/buttons/BtnExport.vue +17 -0
  48. package/dist/runtime/components/shared/tables/buttons/BtnFilter.vue +21 -0
  49. package/dist/runtime/components/shared/tables/pagination/ItemsPerPageCombo.vue +24 -0
  50. package/dist/runtime/components/shared/tables/pagination/ItemsPerPageLabel.vue +5 -0
  51. package/dist/runtime/components/shared/tables/pagination/PageSelector.vue +16 -0
  52. package/dist/runtime/components/shared/tables/pagination/PaginationInfo.vue +31 -0
  53. package/dist/runtime/composables/useAuthorization.d.ts +32 -0
  54. package/dist/runtime/composables/useAuthorization.js +95 -0
  55. package/dist/runtime/constants/form.d.ts +44 -0
  56. package/dist/runtime/constants/form.js +58 -0
  57. package/dist/runtime/constants/index.d.ts +4 -0
  58. package/dist/runtime/constants/index.js +4 -0
  59. package/dist/runtime/constants/pagination.d.ts +13 -0
  60. package/dist/runtime/constants/pagination.js +8 -0
  61. package/dist/runtime/constants/request.d.ts +5 -0
  62. package/dist/runtime/constants/request.js +6 -0
  63. package/dist/runtime/constants/tables.d.ts +4 -0
  64. package/dist/runtime/constants/tables.js +15 -0
  65. package/dist/runtime/enums/EAsyncDataRequestStatus.d.ts +9 -0
  66. package/dist/runtime/enums/EAsyncDataRequestStatus.js +7 -0
  67. package/dist/runtime/enums/EAuthorization.d.ts +8 -0
  68. package/dist/runtime/enums/EAuthorization.js +6 -0
  69. package/dist/runtime/enums/EFormField.d.ts +14 -0
  70. package/dist/runtime/enums/EFormField.js +12 -0
  71. package/dist/runtime/enums/EFormMode.d.ts +7 -0
  72. package/dist/runtime/enums/EFormMode.js +5 -0
  73. package/dist/runtime/enums/ERequestMethod.d.ts +9 -0
  74. package/dist/runtime/enums/ERequestMethod.js +7 -0
  75. package/dist/runtime/enums/ETheme.d.ts +7 -0
  76. package/dist/runtime/enums/ETheme.js +5 -0
  77. package/dist/runtime/enums/EVuetifyDateFormats.d.ts +32 -0
  78. package/dist/runtime/enums/EVuetifyDateFormats.js +30 -0
  79. package/dist/runtime/enums/index.d.ts +6 -0
  80. package/dist/runtime/enums/index.js +6 -0
  81. package/dist/runtime/i18n/config.d.ts +61 -0
  82. package/dist/runtime/i18n/config.js +10 -0
  83. package/dist/runtime/i18n/locales/es.json +55 -0
  84. package/dist/runtime/i18n/service.d.ts +72 -0
  85. package/dist/runtime/i18n/service.js +3 -0
  86. package/dist/runtime/i18n/vueI18n.d.ts +5 -0
  87. package/dist/runtime/i18n/vueI18n.js +3 -0
  88. package/dist/runtime/index.d.ts +9 -0
  89. package/dist/runtime/layouts/default.vue +31 -0
  90. package/dist/runtime/layouts/empty.vue +12 -0
  91. package/dist/runtime/middleware/authentication.d.ts +10 -0
  92. package/dist/runtime/middleware/authentication.js +30 -0
  93. package/dist/runtime/middleware/authorization.d.ts +7 -0
  94. package/dist/runtime/middleware/authorization.js +39 -0
  95. package/dist/runtime/pages/401.vue +34 -0
  96. package/dist/runtime/pages/403.vue +35 -0
  97. package/dist/runtime/pages/ssoCallback.vue +14 -0
  98. package/dist/runtime/plugins/auth.d.ts +12 -0
  99. package/dist/runtime/plugins/auth.js +83 -0
  100. package/dist/runtime/plugins/vue-json.d.ts +12 -0
  101. package/dist/runtime/plugins/vue-json.js +5 -0
  102. package/dist/runtime/public/images/logos/UNA_LogoMark_Black.png +0 -0
  103. package/dist/runtime/public/images/logos/UNA_LogoType_LogoMark_Red.png +0 -0
  104. package/dist/runtime/server/tsconfig.json +3 -0
  105. package/dist/runtime/stores/UiCustomizer.d.ts +22 -0
  106. package/dist/runtime/stores/UiCustomizer.js +34 -0
  107. package/dist/runtime/stores/appStatus.d.ts +63 -0
  108. package/dist/runtime/stores/appStatus.js +101 -0
  109. package/dist/runtime/stores/auth.d.ts +76 -0
  110. package/dist/runtime/stores/auth.js +66 -0
  111. package/dist/runtime/stores/formModeTracker.d.ts +14 -0
  112. package/dist/runtime/stores/formModeTracker.js +10 -0
  113. package/dist/runtime/types/index.d.ts +584 -0
  114. package/dist/runtime/types/index.js +1 -0
  115. package/dist/runtime/utils/buildSortQueryParams.d.ts +10 -0
  116. package/dist/runtime/utils/buildSortQueryParams.js +3 -0
  117. package/dist/runtime/utils/getCurrentPath.d.ts +7 -0
  118. package/dist/runtime/utils/getCurrentPath.js +4 -0
  119. package/dist/runtime/utils/getDateTimeInISO8601.d.ts +11 -0
  120. package/dist/runtime/utils/getDateTimeInISO8601.js +3 -0
  121. package/dist/runtime/utils/getFromLocalStorage.d.ts +9 -0
  122. package/dist/runtime/utils/getFromLocalStorage.js +6 -0
  123. package/dist/runtime/utils/isNumberInRange.d.ts +11 -0
  124. package/dist/runtime/utils/isNumberInRange.js +5 -0
  125. package/dist/runtime/utils/onlyNumbers.d.ts +9 -0
  126. package/dist/runtime/utils/onlyNumbers.js +3 -0
  127. package/dist/runtime/utils/stringToBoolean.d.ts +9 -0
  128. package/dist/runtime/utils/stringToBoolean.js +3 -0
  129. package/dist/types.d.mts +7 -0
  130. package/dist/types.d.ts +7 -0
  131. package/package.json +69 -0
@@ -0,0 +1,12 @@
1
+ <template>
2
+ <span v-if="textToSearch" class="text-body-1">
3
+ {{ $t("Components.Table.NoDataMessage.WhenNoMatches") }}
4
+ </span>
5
+ <span v-else class="text-body-1">
6
+ {{ $t("Components.Table.NoDataMessage.WhenNoData") }}
7
+ </span>
8
+ </template>
9
+
10
+ <script lang="ts" setup>
11
+ const textToSearch = defineModel<string>("textToSearch", { required: true });
12
+ </script>
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <v-text-field
3
+ :label="$t('Components.Table.SearchBar.Label')"
4
+ :placeholder="$t('Components.Table.SearchBar.Placeholder')"
5
+ :title="$t('Components.Table.SearchBar.Title')"
6
+ @click:append-inner="emit('on-search')"
7
+ @keyup.enter="emit('on-search')"
8
+ append-inner-icon="mdi-magnify"
9
+ clearable
10
+ color="secondary"
11
+ density="compact"
12
+ hide-details
13
+ style="max-width: 20rem"
14
+ v-model="textToSearch"
15
+ variant="outlined"
16
+ />
17
+ </template>
18
+
19
+ <script lang="ts" setup>
20
+ const emit = defineEmits(["on-search"]);
21
+ const textToSearch = defineModel<string>("textToSearch", { required: true });
22
+ </script>
@@ -0,0 +1,25 @@
1
+ <template>
2
+ <v-btn
3
+ v-if="canCreate"
4
+ :text="$t('Actions.New')"
5
+ @click.stop="emit('on-create')"
6
+ class="text-none text-subtitle-1"
7
+ color="primary"
8
+ variant="flat"
9
+ >
10
+ <template v-slot:prepend>
11
+ <v-icon icon="mdi-plus" start size="x-large" class="mx-0" />
12
+ </template>
13
+ </v-btn>
14
+ </template>
15
+
16
+ <script lang="ts" setup>
17
+ import { EAuthorization } from "../../../../enums";
18
+ import { useAuthorization } from "../../../../composables/useAuthorization";
19
+
20
+ const authorization = useAuthorization();
21
+
22
+ const emit = defineEmits(["on-create"]);
23
+
24
+ const canCreate = authorization.hasAuthorization(EAuthorization.CREATE);
25
+ </script>
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <v-btn
3
+ v-if="canDelete"
4
+ :title="$t('Actions.Delete')"
5
+ @click.stop="emit('on-delete')"
6
+ class="ml-5"
7
+ color="error"
8
+ density="compact"
9
+ elevation="1"
10
+ icon="mdi-delete"
11
+ rounded="lg"
12
+ variant="text"
13
+ >
14
+ </v-btn>
15
+ </template>
16
+
17
+ <script lang="ts" setup>
18
+ import { useAuthorization } from "../../../../composables/useAuthorization";
19
+ import { EAuthorization } from "../../../../enums";
20
+
21
+ const authorization = useAuthorization();
22
+
23
+ const emit = defineEmits(["on-delete"]);
24
+
25
+ const props = defineProps({
26
+ validateAuthorization: { type: Boolean, required: false, default: true },
27
+ });
28
+
29
+ const canDelete = props.validateAuthorization
30
+ ? authorization.hasAuthorization(EAuthorization.EDIT)
31
+ : true;
32
+ </script>
@@ -0,0 +1,30 @@
1
+ <template>
2
+ <v-btn
3
+ v-if="canEdit"
4
+ :title="$t('Actions.Edit')"
5
+ @click.stop="emit('on-edit')"
6
+ color="info"
7
+ density="compact"
8
+ elevation="1"
9
+ icon="mdi-pencil"
10
+ rounded="lg"
11
+ variant="text"
12
+ />
13
+ </template>
14
+
15
+ <script lang="ts" setup>
16
+ import { useAuthorization } from "../../../../composables/useAuthorization";
17
+ import { EAuthorization } from "../../../../enums";
18
+
19
+ const authorization = useAuthorization();
20
+
21
+ const emit = defineEmits(["on-edit"]);
22
+
23
+ const props = defineProps({
24
+ validateAuthorization: { type: Boolean, required: false, default: true },
25
+ });
26
+
27
+ const canEdit = props.validateAuthorization
28
+ ? authorization.hasAuthorization(EAuthorization.EDIT)
29
+ : true;
30
+ </script>
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <v-btn
3
+ :text="$t('Actions.Export')"
4
+ @click.stop="emit('on-export')"
5
+ class="text-none text-subtitle-1 ml-4"
6
+ color="secondary"
7
+ variant="outlined"
8
+ >
9
+ <template v-slot:prepend>
10
+ <v-icon icon="mdi-arrow-collapse-down" start class="mx-0" />
11
+ </template>
12
+ </v-btn>
13
+ </template>
14
+
15
+ <script lang="ts" setup>
16
+ const emit = defineEmits(["on-export"]);
17
+ </script>
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <v-btn
3
+ :title="$t('Actions.MoreFilters')"
4
+ class="ml-4"
5
+ color="primary"
6
+ density="compact"
7
+ icon="mdi-tune-variant"
8
+ rounded="lg"
9
+ size="large"
10
+ v-bind="props.activator"
11
+ variant="flat"
12
+ />
13
+ </template>
14
+
15
+ <script lang="ts" setup>
16
+ import type { PropType } from "vue";
17
+
18
+ const props = defineProps({
19
+ activator: { type: Object as PropType<Record<string, any>>, required: true },
20
+ });
21
+ </script>
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <v-combobox
3
+ :items="props.items"
4
+ class="d-flex align-center"
5
+ color="primary"
6
+ density="compact"
7
+ style="max-width: 9.1rem"
8
+ type="text"
9
+ v-model="itemsPerPage"
10
+ variant="outlined"
11
+ />
12
+ </template>
13
+
14
+ <script lang="ts" setup>
15
+ import type { IItemsPerPage } from "../../../../types";
16
+ import type { PropType } from "vue";
17
+
18
+ const itemsPerPage = defineModel<IItemsPerPage>("itemsPerPage", {
19
+ required: true,
20
+ });
21
+ const props = defineProps({
22
+ items: { type: Array as PropType<IItemsPerPage[]>, required: true },
23
+ });
24
+ </script>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <span class="pr-2">
3
+ {{ $t("Components.Table.Pagination.ItemsPerPageLabel") }}
4
+ </span>
5
+ </template>
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <v-pagination
3
+ :length="props.totalPages"
4
+ :show-first-last-page="true"
5
+ :total-visible="3"
6
+ activeColor="primary"
7
+ density="compact"
8
+ size="largue"
9
+ v-model="page"
10
+ />
11
+ </template>
12
+
13
+ <script lang="ts" setup>
14
+ const page = defineModel<number>("page", { type: Number, required: true });
15
+ const props = defineProps({ totalPages: { type: Number, required: true } });
16
+ </script>
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <span class="mr-2">{{ paginationMessagge }}</span>
3
+ </template>
4
+
5
+ <script lang="ts" setup>
6
+ import { computed, type PropType } from "vue";
7
+ import { useI18n } from "#imports";
8
+
9
+ const { t } = useI18n();
10
+
11
+ interface IPaginationInfoProps {
12
+ page: number;
13
+ totalPages: number;
14
+ totalElements: number;
15
+ }
16
+
17
+ const props = defineProps({
18
+ paginationInfo: {
19
+ type: Object as PropType<IPaginationInfoProps>,
20
+ required: true,
21
+ },
22
+ });
23
+
24
+ const paginationMessagge = computed(() => {
25
+ return t("Components.Table.Pagination.PaginationInfo", {
26
+ page: props.paginationInfo.page,
27
+ totalPages: props.paginationInfo.totalPages,
28
+ totalElements: props.paginationInfo.totalElements,
29
+ });
30
+ });
31
+ </script>
@@ -0,0 +1,32 @@
1
+ import type { IHasAuthorizationInResourceParams, IMenuItem, IResource, TAuthorization } from "../types/index.js";
2
+ /**
3
+ * Composable encargado de exponer los métodos de autorización.
4
+ */
5
+ export declare const useAuthorization: () => {
6
+ hasAccess: () => boolean;
7
+ hasAccessTo: (resource: string) => boolean;
8
+ getResources: (token: string) => Promise<IResource[]>;
9
+ currentResource: import("vue").Ref<string, string>;
10
+ hasAuthorization: (authorization: TAuthorization) => boolean;
11
+ isPageUnprotected: (page: string) => boolean;
12
+ hasAuthorizationIn: (params: IHasAuthorizationInResourceParams) => boolean;
13
+ getAuthorizedPaths: () => ({
14
+ header: any;
15
+ title?: string;
16
+ icon?: string;
17
+ to?: string;
18
+ divider?: boolean;
19
+ children?: IMenuItem[];
20
+ disabled?: boolean;
21
+ description?: string;
22
+ } | {
23
+ title: any;
24
+ header?: string;
25
+ icon?: string;
26
+ to?: string;
27
+ divider?: boolean;
28
+ children?: IMenuItem[];
29
+ disabled?: boolean;
30
+ description?: string;
31
+ })[];
32
+ };
@@ -0,0 +1,95 @@
1
+ import { DEFAULT_ERROR_RESPONSE } from "../constants/index.js";
2
+ import { ERequestMethod } from "../enums/index.js";
3
+ import { ref } from "vue";
4
+ import { useAsyncData, useRuntimeConfig } from "#app";
5
+ import { useAuthStore, useI18n } from "#imports";
6
+ import getCurrentPath from "../utils/getCurrentPath.js";
7
+ export const useAuthorization = () => {
8
+ const currentResource = ref(getCurrentPath());
9
+ const isPageUnprotected = (page) => {
10
+ const runtimeConfig = useRuntimeConfig();
11
+ return runtimeConfig.public.unaNuxtModule.config.unprotectedPages.includes(
12
+ page
13
+ );
14
+ };
15
+ const hasAccess = () => {
16
+ return useAuthStore().hasResource(currentResource.value);
17
+ };
18
+ const hasAccessTo = (resource) => {
19
+ return useAuthStore().hasResource(resource);
20
+ };
21
+ const hasAuthorization = (authorization) => {
22
+ return useAuthStore().hasAuthorizationInResource({
23
+ resource: currentResource.value,
24
+ authorization
25
+ });
26
+ };
27
+ const hasAuthorizationIn = (params) => {
28
+ return useAuthStore().hasAuthorizationInResource(params);
29
+ };
30
+ const getResources = async (token) => {
31
+ const runtimeConfig = useRuntimeConfig();
32
+ const authStore = useAuthStore();
33
+ if (authStore.authData) {
34
+ authStore.authData.accessToken = token;
35
+ }
36
+ let requestResponse = DEFAULT_ERROR_RESPONSE;
37
+ const API = runtimeConfig.public.unaNuxtModule.apis.authorization;
38
+ await useAsyncData(
39
+ () => $fetch(API.endpoints.getResources, {
40
+ baseURL: API.baseUrl,
41
+ method: ERequestMethod.GET,
42
+ headers: {
43
+ // Se agrega el token de la sesión
44
+ Authorization: `Bearer ${token}`
45
+ },
46
+ // Hook que se ejecuta cuando el servidor da respuesta
47
+ onResponse({ response }) {
48
+ if (response._data) {
49
+ requestResponse = response._data;
50
+ }
51
+ }
52
+ }).catch((error) => {
53
+ console.error("Error obteniendo recursos:", error);
54
+ })
55
+ );
56
+ return requestResponse.data;
57
+ };
58
+ const removeUnathorizedPaths = (navigationMenu) => {
59
+ const { t } = useI18n();
60
+ return navigationMenu.map((menuItem) => {
61
+ if (menuItem?.header) {
62
+ return { ...menuItem, header: t(menuItem.header) };
63
+ }
64
+ if (menuItem?.to && menuItem?.title) {
65
+ if (isPageUnprotected(menuItem?.to) || hasAccessTo(menuItem.to)) {
66
+ return { ...menuItem, title: t(menuItem.title) };
67
+ }
68
+ }
69
+ if (menuItem?.children && menuItem?.title) {
70
+ menuItem.children = removeUnathorizedPaths(
71
+ menuItem.children
72
+ );
73
+ return { ...menuItem, title: t(menuItem.title) };
74
+ }
75
+ }).filter((menuItem) => {
76
+ return menuItem !== void 0;
77
+ });
78
+ };
79
+ const getAuthorizedPaths = () => {
80
+ const runtimeConfig = useRuntimeConfig();
81
+ return removeUnathorizedPaths(
82
+ runtimeConfig.public.unaNuxtModule.config.navigationMenu
83
+ );
84
+ };
85
+ return {
86
+ hasAccess,
87
+ hasAccessTo,
88
+ getResources,
89
+ currentResource,
90
+ hasAuthorization,
91
+ isPageUnprotected,
92
+ hasAuthorizationIn,
93
+ getAuthorizedPaths
94
+ };
95
+ };
@@ -0,0 +1,44 @@
1
+ import type { IFormState } from "../types/index.js";
2
+ export declare const INITIAL_FORM_STATE: IFormState;
3
+ /**
4
+ * Contiene métodos para validación de formularios
5
+ */
6
+ export declare const FORM_RULES: {
7
+ /**
8
+ * Valida que un campo no este vacío.
9
+ *
10
+ * @param [any] value - Campo a validar
11
+ *
12
+ * @return *boolean* - Retorna *true* si el campo no esta vacío
13
+ * @error *string* - Mensaje de error si el campo esta vacío
14
+ */
15
+ requiredField: (value: any) => string | true;
16
+ /**
17
+ * Valida que un campo de texto no este vacío.
18
+ *
19
+ * @param [string] value - Campo a validar
20
+ *
21
+ * @return *boolean* - Retorna *true* si el campo no esta vacío
22
+ * @error *string* - Mensaje de error si el campo esta vacío
23
+ */
24
+ requiredString: (value: string) => string | true;
25
+ /**
26
+ * Valida que un campo de texto sea un email valido.
27
+ *
28
+ * @param [string] value - Campo a validar
29
+ *
30
+ * @return *boolean* - Retorna *true* si el campo es un email valido
31
+ * @error *string* - Mensaje de error si el campo no es un email valido
32
+ */
33
+ isEmail: (value: string) => string | true;
34
+ /**
35
+ * Valida que un campo numérico este dentro de un rango.
36
+ *
37
+ * @param [number] min - Rango inferior - *null*
38
+ * @param [number] max - Rango superior - *null*
39
+ *
40
+ * @return *boolean* - Retorna *true* si el campo esta dentro del rango
41
+ * @error *string* - Mensaje de error si el campo no esta dentro del rango
42
+ */
43
+ isNumberInRange: (min?: number | null, max?: number | null) => (value: number) => string | true;
44
+ };
@@ -0,0 +1,58 @@
1
+ import { EFormMode } from "../enums/index.js";
2
+ import { i18nService } from "../i18n/service.js";
3
+ import isNumberInRange from "../utils/isNumberInRange.js";
4
+ export const INITIAL_FORM_STATE = {
5
+ formMode: EFormMode.CREATE,
6
+ openForm: false
7
+ };
8
+ export const FORM_RULES = {
9
+ /**
10
+ * Valida que un campo no este vacío.
11
+ *
12
+ * @param [any] value - Campo a validar
13
+ *
14
+ * @return *boolean* - Retorna *true* si el campo no esta vacío
15
+ * @error *string* - Mensaje de error si el campo esta vacío
16
+ */
17
+ requiredField: (value) => {
18
+ return !!value || i18nService.global.t("Rules.RequiredField");
19
+ },
20
+ /**
21
+ * Valida que un campo de texto no este vacío.
22
+ *
23
+ * @param [string] value - Campo a validar
24
+ *
25
+ * @return *boolean* - Retorna *true* si el campo no esta vacío
26
+ * @error *string* - Mensaje de error si el campo esta vacío
27
+ */
28
+ requiredString: (value) => {
29
+ return !!value.trim() || i18nService.global.t("Rules.RequiredField");
30
+ },
31
+ /**
32
+ * Valida que un campo de texto sea un email valido.
33
+ *
34
+ * @param [string] value - Campo a validar
35
+ *
36
+ * @return *boolean* - Retorna *true* si el campo es un email valido
37
+ * @error *string* - Mensaje de error si el campo no es un email valido
38
+ */
39
+ isEmail: (value) => {
40
+ return /.+@.+\..+/.test(value) || i18nService.global.t("Rules.IsEmail");
41
+ },
42
+ /**
43
+ * Valida que un campo numérico este dentro de un rango.
44
+ *
45
+ * @param [number] min - Rango inferior - *null*
46
+ * @param [number] max - Rango superior - *null*
47
+ *
48
+ * @return *boolean* - Retorna *true* si el campo esta dentro del rango
49
+ * @error *string* - Mensaje de error si el campo no esta dentro del rango
50
+ */
51
+ isNumberInRange: (min = null, max = null) => (value) => {
52
+ return isNumberInRange(value, min, max) || i18nService.global.t("Rules.numberInRange", {
53
+ number: value,
54
+ min,
55
+ max
56
+ });
57
+ }
58
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./request.js";
2
+ export * from "./form.js";
3
+ export * from "./pagination.js";
4
+ export * from "./tables.js";
@@ -0,0 +1,4 @@
1
+ export * from "./request.js";
2
+ export * from "./form.js";
3
+ export * from "./pagination.js";
4
+ export * from "./tables.js";
@@ -0,0 +1,13 @@
1
+ import type { IItemsPerPage } from "../types/index.js";
2
+ /**
3
+ * Número de la primer página en la paginación.
4
+ */
5
+ export declare const PAGINATION_FIRST_PAGE = 1;
6
+ /**
7
+ * Paginación por defecto.
8
+ */
9
+ export declare const DEFAULT_ITEMS_PER_PAGE: IItemsPerPage;
10
+ /**
11
+ * Opciones de paginación.
12
+ */
13
+ export declare const PAGINATION_OPTIONS: IItemsPerPage[];
@@ -0,0 +1,8 @@
1
+ export const PAGINATION_FIRST_PAGE = 1;
2
+ export const DEFAULT_ITEMS_PER_PAGE = { title: "10", value: 10 };
3
+ export const PAGINATION_OPTIONS = [
4
+ { title: "10", value: 10 },
5
+ { title: "20", value: 20 },
6
+ { title: "50", value: 50 },
7
+ { title: "Todos", value: 0 }
8
+ ];
@@ -0,0 +1,5 @@
1
+ import type { IRequestResponse } from "../types/index.js";
2
+ /**
3
+ * Mensaje de error por defecto al realizar una petición.
4
+ */
5
+ export declare const DEFAULT_ERROR_RESPONSE: IRequestResponse;
@@ -0,0 +1,6 @@
1
+ export const DEFAULT_ERROR_RESPONSE = {
2
+ title: "Error",
3
+ description: "Ha ocurrido un error inesperado",
4
+ statusCode: 500,
5
+ success: false
6
+ };
@@ -0,0 +1,4 @@
1
+ import type { ITableHeader, ITableState } from "../types/index.js";
2
+ export declare const KEY_FOR_ACTIONS_COLUMN = "actions";
3
+ export declare const HEADER_FOR_ACTIONS_COLUMN: ITableHeader;
4
+ export declare const INITIAL_TABLE_STATE: ITableState;
@@ -0,0 +1,15 @@
1
+ import { DEFAULT_ITEMS_PER_PAGE, PAGINATION_FIRST_PAGE } from "./pagination.js";
2
+ export const KEY_FOR_ACTIONS_COLUMN = "actions";
3
+ export const HEADER_FOR_ACTIONS_COLUMN = {
4
+ title: "Acciones",
5
+ align: "center",
6
+ key: KEY_FOR_ACTIONS_COLUMN,
7
+ sortable: false
8
+ };
9
+ export const INITIAL_TABLE_STATE = {
10
+ page: PAGINATION_FIRST_PAGE,
11
+ itemsPerPage: DEFAULT_ITEMS_PER_PAGE,
12
+ textToSearch: null,
13
+ totalElements: 0,
14
+ totalPages: 0
15
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Enum que contiene los posibles estados de una peticion HTTP.
3
+ */
4
+ export declare enum EAsyncDataRequestStatus {
5
+ IDLE = "idle",
6
+ PENDING = "pending",
7
+ SUCCESS = "success",
8
+ ERROR = "error"
9
+ }
@@ -0,0 +1,7 @@
1
+ export var EAsyncDataRequestStatus = /* @__PURE__ */ ((EAsyncDataRequestStatus2) => {
2
+ EAsyncDataRequestStatus2["IDLE"] = "idle";
3
+ EAsyncDataRequestStatus2["PENDING"] = "pending";
4
+ EAsyncDataRequestStatus2["SUCCESS"] = "success";
5
+ EAsyncDataRequestStatus2["ERROR"] = "error";
6
+ return EAsyncDataRequestStatus2;
7
+ })(EAsyncDataRequestStatus || {});
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Enum que contiene los tipos de autorizaciones a recursos.
3
+ */
4
+ export declare const enum EAuthorization {
5
+ CREATE = "CREATE",
6
+ DELETE = "DELETE",
7
+ EDIT = "EDIT"
8
+ }
@@ -0,0 +1,6 @@
1
+ export var EAuthorization = /* @__PURE__ */ ((EAuthorization2) => {
2
+ EAuthorization2["CREATE"] = "CREATE";
3
+ EAuthorization2["DELETE"] = "DELETE";
4
+ EAuthorization2["EDIT"] = "EDIT";
5
+ return EAuthorization2;
6
+ })(EAuthorization || {});
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Enum que contiene los tipos de campos de formulario.
3
+ */
4
+ export declare const enum EFormField {
5
+ CHECKBOX = "CHECKBOX",
6
+ DATE = "DATE",
7
+ NUMBER = "NUMBER",
8
+ RADIOBUTTON = "RADIOBUTTON",
9
+ SELECT = "SELECT",
10
+ SLOT = "SLOT",
11
+ SWITCH = "SWITCH",
12
+ TEXT = "TEXT",
13
+ TEXTAREA = "TEXTAREA"
14
+ }
@@ -0,0 +1,12 @@
1
+ export var EFormField = /* @__PURE__ */ ((EFormField2) => {
2
+ EFormField2["CHECKBOX"] = "CHECKBOX";
3
+ EFormField2["DATE"] = "DATE";
4
+ EFormField2["NUMBER"] = "NUMBER";
5
+ EFormField2["RADIOBUTTON"] = "RADIOBUTTON";
6
+ EFormField2["SELECT"] = "SELECT";
7
+ EFormField2["SLOT"] = "SLOT";
8
+ EFormField2["SWITCH"] = "SWITCH";
9
+ EFormField2["TEXT"] = "TEXT";
10
+ EFormField2["TEXTAREA"] = "TEXTAREA";
11
+ return EFormField2;
12
+ })(EFormField || {});
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Enum que contiene los tipos de modo de edición de formulario.
3
+ */
4
+ export declare const enum EFormMode {
5
+ CREATE = "CREATE",
6
+ EDIT = "EDIT"
7
+ }
@@ -0,0 +1,5 @@
1
+ export var EFormMode = /* @__PURE__ */ ((EFormMode2) => {
2
+ EFormMode2["CREATE"] = "CREATE";
3
+ EFormMode2["EDIT"] = "EDIT";
4
+ return EFormMode2;
5
+ })(EFormMode || {});
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Enum que contiene los tipos de métodos para las peticiones.
3
+ */
4
+ export declare const enum ERequestMethod {
5
+ GET = "GET",
6
+ PUT = "PUT",
7
+ POST = "POST",
8
+ DELETE = "DELETE"
9
+ }
@@ -0,0 +1,7 @@
1
+ export var ERequestMethod = /* @__PURE__ */ ((ERequestMethod2) => {
2
+ ERequestMethod2["GET"] = "GET";
3
+ ERequestMethod2["PUT"] = "PUT";
4
+ ERequestMethod2["POST"] = "POST";
5
+ ERequestMethod2["DELETE"] = "DELETE";
6
+ return ERequestMethod2;
7
+ })(ERequestMethod || {});
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Enum que contiene los tipos de temas de la aplicación.
3
+ */
4
+ export declare const enum ETheme {
5
+ DARK = "dark",
6
+ LIGHT = "light"
7
+ }