Skip to content

Commit 2058af6

Browse files
committed
fix: loader content props validation
1 parent 10aeb7d commit 2058af6

File tree

4 files changed

+109
-4
lines changed

4 files changed

+109
-4
lines changed

packages/components-vue/src/components/loader/ContentFetch.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
4040
import type { iUseThemeProps } from "../../types/props";
4141
42-
type tDataPromise<Ti, Pi extends any[]> = (...args: Pi) => Promise<Ti>;
43-
4442
interface iLoaderContentFetchProps<Ti, Pi extends any[]> extends iUseThemeProps {
4543
/**
4644
* Loader label
@@ -53,8 +51,8 @@
5351
fallback?: Ti;
5452
unwrap?: boolean;
5553
url?: false | string;
56-
promise?: false | tDataPromise<Ti, Pi>;
57-
hydratablePromise?: false | ((hydrate: tHydrate<Ti>) => tDataPromise<Ti, Pi>);
54+
promise?: false | ((...args: Pi) => Promise<Ti>);
55+
hydratablePromise?: false | ((hydrate: tHydrate<Ti>) => (...args: Pi) => Promise<Ti>);
5856
payload?: Pi;
5957
/**
6058
* Component or tag to render

packages/components-vue/src/screens/ModalWithFormStages.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
<script setup lang="ts">
4444
import { computed } from "vue";
45+
4546
import type { iInvalidInput } from "@open-xamu-co/ui-common-types";
4647
import { FormInput, useForm, type iForm } from "@open-xamu-co/ui-common-helpers";
4748
@@ -55,6 +56,8 @@
5556
5657
/**
5758
* Modal with form stages
59+
*
60+
* @screen
5861
*/
5962
6063
const stages = computed<iForm[][]>(() => {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Meta, StoryObj } from "@storybook/vue3";
2+
3+
import PaginationContentWithTable from "./PaginationContentWithTable.vue";
4+
5+
const meta = {
6+
title: "Screens/Pagination Content with Table",
7+
component: PaginationContentWithTable as Record<
8+
keyof typeof PaginationContentWithTable,
9+
unknown
10+
>,
11+
args: {},
12+
tags: ["!autodocs"],
13+
} satisfies Meta<typeof PaginationContentWithTable>;
14+
15+
type Story = StoryObj<typeof PaginationContentWithTable>;
16+
17+
export const Sample: Story = {
18+
args: {},
19+
};
20+
21+
export default meta;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<template>
2+
<PaginationContent
3+
v-slot="{ content }"
4+
:page="page"
5+
:transform="getPageFromResponse"
6+
with-route
7+
class="flx --flxColumn --flx-start-end --gap-5 --width"
8+
>
9+
<Table
10+
:nodes="content"
11+
can-sort
12+
:modal-props="{ theme: [eColors.LIGHT, eColors.SECONDARY], class: '--txtColor' }"
13+
/>
14+
</PaginationContent>
15+
</template>
16+
17+
<script setup lang="ts">
18+
import type { iFormResponse, iPage, iPagination } from "@open-xamu-co/ui-common-types";
19+
import { eColors } from "@open-xamu-co/ui-common-enums";
20+
21+
import PaginationContent from "../components/pagination/Content.vue";
22+
import Table from "../components/table/Simple.vue";
23+
24+
export interface iSector {
25+
id: number;
26+
categories: Record<string, any>[];
27+
name: string;
28+
description: string;
29+
}
30+
31+
/**
32+
* Pagination Content with Table
33+
*
34+
* @screen
35+
*/
36+
37+
const page = async (_params?: iPagination): Promise<iFormResponse<iPage<iSector, number>>> => {
38+
const data = {
39+
response: {
40+
edges: [
41+
{
42+
cursor: 2,
43+
node: {
44+
id: 2,
45+
name: "Agropecuario",
46+
description: "Este es el sector agropecuario",
47+
categories: [],
48+
},
49+
},
50+
{
51+
cursor: 1,
52+
node: {
53+
id: 1,
54+
name: "Tecnológico",
55+
description:
56+
"Este sector incluye todo tipo de electrodomésticos y dispositivos.",
57+
categories: [],
58+
},
59+
},
60+
],
61+
pageInfo: {
62+
hasNextPage: false,
63+
hasPreviousPage: false,
64+
},
65+
totalCount: 2,
66+
},
67+
invalidInputs: [],
68+
withErrors: false,
69+
requestHadErrors: false,
70+
validationHadErrors: false,
71+
};
72+
73+
return new Promise((resolve) => {
74+
setTimeout(() => {
75+
resolve(data);
76+
}, 3000);
77+
});
78+
};
79+
80+
const getPageFromResponse = ({ response }: iFormResponse<iPage<iSector, number>>) => {
81+
return response;
82+
};
83+
</script>

0 commit comments

Comments
 (0)