erp-pos-ecommerce-shared 0.2.2 → 0.2.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.
@@ -1,7 +1,7 @@
1
1
  import React$1, { ReactNode } from 'react';
2
2
  import { e as IField, b as IButton } from './form.interface-CO6P9ez0.js';
3
3
  import { ReactFormExtendedApi, FormValidateOrFn, FormAsyncValidateOrFn } from '@tanstack/react-form';
4
- import { UseMutationResult, UseQueryOptions } from '@tanstack/react-query';
4
+ import { UseMutationResult, UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
5
5
  import { u as TblProductsImage, q as ITableFilterConfig, i as IFilterSelectOption } from './filters.interface-glhGBJfx.js';
6
6
  import * as z from 'zod';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -375,4 +375,40 @@ interface TablePageProps<TRow> {
375
375
  }
376
376
  declare const TablePage: <TRow>({ getQueryOptions, title, columns, filters, isLoadingExternal, onRowClick, onRowHover, emptyState, table, enableRowSelection, headerBgColor, columnActions, listMenuActions, onSelectionChange, config, CustomHeader, showSearchInput, showBottomPagination, tableHeight, }: TablePageProps<TRow>) => react_jsx_runtime.JSX.Element;
377
377
 
378
- export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, type FilterDateProps, FilterSelect, type FilterSelectProps, FormGenerator, type FormInstance, type FormValues, ImageForm, type PaginatedResponse, SearchInput, SimpleDataTable, TablePage, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
378
+ interface FormPagePropsBase<TData, TVariables = unknown> {
379
+ fields: IField[];
380
+ buttons: IButton[];
381
+ mutationOptions: UseMutationOptions<TData, Error, TVariables>;
382
+ typeOfForm: "create" | "edit";
383
+ dataKey: string;
384
+ loading: boolean;
385
+ cardWidth?: number;
386
+ onSuccess?: (data: TData) => void;
387
+ setData?: (data: TData) => void;
388
+ navigateAway?: boolean;
389
+ showBackButton?: boolean;
390
+ /**
391
+ * Callback when the user clicks "Regresar". Provide your router's go-back logic here.
392
+ * @example React Router: () => navigate(-1)
393
+ * @example TanStack Router: () => router.history.back()
394
+ * @example TanStack Start: () => navigate({ to: '..' })
395
+ */
396
+ onGoBack?: () => void;
397
+ /**
398
+ * Optional icon for the back button. Pass your own icon component so the lib stays router/UI-agnostic.
399
+ * @example <ArrowLeft /> from lucide-react
400
+ */
401
+ backButtonIcon?: ReactNode;
402
+ }
403
+ interface FormPagePropsWithFiles<TData, TVariables = unknown> extends FormPagePropsBase<TData, TVariables> {
404
+ hasFiles: true;
405
+ buildVariables?: (values: FormData) => TVariables;
406
+ }
407
+ interface FormPagePropsWithoutFiles<TData, TVariables = unknown> extends FormPagePropsBase<TData, TVariables> {
408
+ hasFiles?: false;
409
+ buildVariables?: (values: Record<string, unknown>) => TVariables;
410
+ }
411
+ type FormPageProps<TData, TVariables = unknown> = FormPagePropsWithFiles<TData, TVariables> | FormPagePropsWithoutFiles<TData, TVariables>;
412
+ declare const FormPage: <TData, TVariables = unknown>({ fields, buttons, mutationOptions, buildVariables, typeOfForm, dataKey, loading, cardWidth, hasFiles, onSuccess, setData, navigateAway, showBackButton, onGoBack, backButtonIcon, }: FormPageProps<TData, TVariables>) => React.ReactNode;
413
+
414
+ export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, type FilterDateProps, FilterSelect, type FilterSelectProps, FormGenerator, type FormInstance, FormPage, type FormValues, ImageForm, type PaginatedResponse, SearchInput, SimpleDataTable, TablePage, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
@@ -2087,7 +2087,66 @@ var TablePage = ({
2087
2087
  )
2088
2088
  ] });
2089
2089
  };
2090
+ var FormPage = ({
2091
+ fields,
2092
+ buttons,
2093
+ mutationOptions,
2094
+ buildVariables,
2095
+ typeOfForm,
2096
+ dataKey,
2097
+ loading,
2098
+ cardWidth,
2099
+ hasFiles,
2100
+ onSuccess,
2101
+ setData,
2102
+ navigateAway = true,
2103
+ showBackButton = true,
2104
+ onGoBack,
2105
+ backButtonIcon
2106
+ }) => {
2107
+ const showBack = showBackButton && onGoBack != null;
2108
+ const mutation = useMutation(mutationOptions);
2109
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2110
+ showBack && /* @__PURE__ */ jsx(Flex, { justify: "start", children: /* @__PURE__ */ jsxs(
2111
+ Button,
2112
+ {
2113
+ leftSection: backButtonIcon,
2114
+ variant: "transparent",
2115
+ mx: 20,
2116
+ mt: 10,
2117
+ onClick: onGoBack,
2118
+ children: [
2119
+ "Regresar a ",
2120
+ dataKey
2121
+ ]
2122
+ }
2123
+ ) }),
2124
+ /* @__PURE__ */ jsx(Container, { w: cardWidth ?? 500, my: -10, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", children: [
2125
+ /* @__PURE__ */ jsxs(Title, { order: 1, my: 10, children: [
2126
+ typeOfForm === "create" ? "Crear" : "Editar",
2127
+ " ",
2128
+ dataKey
2129
+ ] }),
2130
+ /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsx(
2131
+ FormGenerator,
2132
+ {
2133
+ typeOfForm,
2134
+ name: dataKey,
2135
+ loading,
2136
+ fields,
2137
+ buttons,
2138
+ mutation,
2139
+ buildVariables,
2140
+ hasFiles,
2141
+ onSuccess,
2142
+ setData,
2143
+ navigateAway
2144
+ }
2145
+ ) })
2146
+ ] }) })
2147
+ ] });
2148
+ };
2090
2149
 
2091
- export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, FilterSelect, FormGenerator, ImageForm, SearchInput, SimpleDataTable, TablePage, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
2150
+ export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, FilterSelect, FormGenerator, FormPage, ImageForm, SearchInput, SimpleDataTable, TablePage, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
2092
2151
  //# sourceMappingURL=components.js.map
2093
2152
  //# sourceMappingURL=components.js.map