@dipusevilla/componentes-iu 1.0.8

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 (45) hide show
  1. package/README.md +93 -0
  2. package/dist/index.cjs.js +54 -0
  3. package/dist/index.css +1 -0
  4. package/dist/index.es.js +6148 -0
  5. package/dist/index.umd.js +55 -0
  6. package/dist/types/components/Button.d.ts +15 -0
  7. package/dist/types/components/Checkbox.d.ts +18 -0
  8. package/dist/types/components/CollapsibleSection.d.ts +8 -0
  9. package/dist/types/components/DateInput.d.ts +22 -0
  10. package/dist/types/components/DropdownMenu.d.ts +14 -0
  11. package/dist/types/components/FileUploader.d.ts +20 -0
  12. package/dist/types/components/FormFieldInput.d.ts +22 -0
  13. package/dist/types/components/FormPageLayout.d.ts +13 -0
  14. package/dist/types/components/FormRenderer.d.ts +5 -0
  15. package/dist/types/components/Header.d.ts +21 -0
  16. package/dist/types/components/Icon.d.ts +11 -0
  17. package/dist/types/components/IconButton.d.ts +18 -0
  18. package/dist/types/components/InfoButton.d.ts +12 -0
  19. package/dist/types/components/Input.d.ts +30 -0
  20. package/dist/types/components/InputGroup.d.ts +21 -0
  21. package/dist/types/components/LoadingScreen.d.ts +8 -0
  22. package/dist/types/components/Modal.d.ts +10 -0
  23. package/dist/types/components/OptionGroup.d.ts +26 -0
  24. package/dist/types/components/PageLayout.d.ts +13 -0
  25. package/dist/types/components/Select.d.ts +33 -0
  26. package/dist/types/components/Sidebar.d.ts +23 -0
  27. package/dist/types/components/SidebarNav.d.ts +15 -0
  28. package/dist/types/components/SkeletonLoader.d.ts +28 -0
  29. package/dist/types/components/Table.d.ts +29 -0
  30. package/dist/types/components/Tabs.d.ts +12 -0
  31. package/dist/types/components/TextArea.d.ts +20 -0
  32. package/dist/types/components/ThemeToggle.d.ts +7 -0
  33. package/dist/types/components/Toast.d.ts +10 -0
  34. package/dist/types/components/ToastContainer.d.ts +10 -0
  35. package/dist/types/components/ToggleSwitch.d.ts +18 -0
  36. package/dist/types/hooks/useAsyncSelectOptions.d.ts +6 -0
  37. package/dist/types/hooks/useDisabledMap.d.ts +10 -0
  38. package/dist/types/hooks/useDynamicYupSchema.d.ts +16 -0
  39. package/dist/types/hooks/useFieldsMap.d.ts +2 -0
  40. package/dist/types/index.d.ts +58 -0
  41. package/dist/types/theme/ThemeProvider.d.ts +11 -0
  42. package/dist/types/types/FormTypes.d.ts +187 -0
  43. package/dist/types/utils/scrollToFirstError.d.ts +1 -0
  44. package/dist/vite.svg +1 -0
  45. package/package.json +94 -0
@@ -0,0 +1,187 @@
1
+ import type { AnyObject, ObjectSchema } from "yup";
2
+ import { Size } from "../components/InputGroup";
3
+ /**
4
+ * Tipo de campo atómico admitido.
5
+ */
6
+ export type FieldType = "text" | "email" | "number" | "password" | "select" | "date" | "optionGroup" | "button" | "textarea" | "file" | "checkbox";
7
+ /**
8
+ * Esquema que describe un campo atómico del formulario.
9
+ */
10
+ export interface FieldSchema {
11
+ suffixButton?: React.ReactNode | string;
12
+ /** Nombre único del campo. */
13
+ name: string;
14
+ /** Etiqueta visible. */
15
+ label?: string;
16
+ /** Tipo de campo (sin incluir 'button' ni 'inputGroup'). */
17
+ type: Exclude<FieldType, "button" | "inputGroup">;
18
+ /** Ancho CSS / Tailwind (ej. "flex-1", "w-1/2"). */
19
+ width?: string;
20
+ /** Placeholder para inputs de texto. */
21
+ placeholder?: string;
22
+ /** Tamaño de componente (sm, md, lg). */
23
+ size?: "sm" | "md" | "lg";
24
+ /** Opciones para selects u optionGroup. */
25
+ options?: any[];
26
+ /** Función asíncrona para cargar opciones dinámicas en <Select>. */
27
+ loadOptions?: () => Promise<any[]>;
28
+ /** Información adicional (ReactNode). */
29
+ info?: React.ReactNode;
30
+ /** Reglas de validación para Yup / react-hook-form. */
31
+ validation?: {
32
+ required?: boolean | string;
33
+ minLength?: {
34
+ value: number;
35
+ message: string;
36
+ };
37
+ maxLength?: {
38
+ value: number;
39
+ message: string;
40
+ };
41
+ pattern?: {
42
+ value: RegExp;
43
+ message: string;
44
+ };
45
+ };
46
+ /** Límite de caracteres (solo para textarea). */
47
+ maxLength?: number;
48
+ /** Mostrar contador de caracteres (para textarea). */
49
+ showCounter?: boolean;
50
+ /** Atributos para FileUploader. */
51
+ accept?: string;
52
+ maxFiles?: number;
53
+ multiple?: boolean;
54
+ /** Para optionGroup: disposición vertical. */
55
+ vertical?: boolean;
56
+ /** Etiqueta del grupo (solo para optionGroup). */
57
+ groupLabel?: string;
58
+ /** Variante de estilo (por ejemplo, en botones). */
59
+ variant?: "primary" | "outline" | "ghost";
60
+ /** Icono SVG adjunto. */
61
+ icon?: React.FC<React.SVGProps<SVGSVGElement>>;
62
+ /** Posición del icono (solo para botones o inputs con icono). */
63
+ iconPosition?: "left" | "right";
64
+ /** Etiqueta accesible. */
65
+ ariaLabel?: string;
66
+ /** Condición de habilitación basada en otro campo. */
67
+ disabledWhen?: {
68
+ watchField: string;
69
+ watchValue: unknown | ((allValues: Record<string, unknown>) => boolean);
70
+ };
71
+ /** Deshabilitar manualmente. */
72
+ disabled?: boolean;
73
+ /** Para date: mostrar hora. */
74
+ showTime?: boolean;
75
+ /** Condición de visibilidad basada en otro campo. */
76
+ visibleWhen?: {
77
+ watchField: string;
78
+ watchValue: unknown | ((allValues: Record<string, unknown>) => boolean);
79
+ };
80
+ /** Atributo para saber si hay carga en curso */
81
+ loading?: boolean;
82
+ }
83
+ /**
84
+ * Campo de tipo botón.
85
+ */
86
+ export interface ButtonField extends Omit<FieldSchema, "type"> {
87
+ type: "button";
88
+ /** Función al hacer click. */
89
+ onClick: () => void;
90
+ }
91
+ /**
92
+ * Grupo de inputs.
93
+ */
94
+ export interface InputGroupField {
95
+ type: "inputGroup";
96
+ /** Etiqueta del grupo. */
97
+ groupLabel: string;
98
+ /** Inputs internos (string refiere a FieldSchema global, o FieldSchema inline). */
99
+ inputs: Array<string | FieldSchema>;
100
+ /** Separador visual opcional. */
101
+ separator?: React.ReactNode;
102
+ /** Si true, usa separator; si false, ignora separator. */
103
+ useSeparator?: boolean;
104
+ /** Clase CSS adicional. */
105
+ className?: string;
106
+ /** Si true, muestra los labels de cada campo. */
107
+ showVisibleLabel?: boolean;
108
+ name: string;
109
+ size?: Size;
110
+ disabled?: boolean;
111
+ }
112
+ /**
113
+ * Columna dentro de una fila.
114
+ */
115
+ export interface SectionColumn {
116
+ /** Ancho CSS/Tailwind. */
117
+ width?: string;
118
+ /** Campos en esta columna. */
119
+ fields?: Array<string | FieldSchema | ButtonField | InputGroupField>;
120
+ /** Sub-columnas anidadas. */
121
+ cols?: SectionColumn[];
122
+ /** Sub-filas anidadas. */
123
+ rows?: SectionRow;
124
+ }
125
+ /**
126
+ * Objeto que describe una fila de columnas.
127
+ */
128
+ export interface SectionRowObject {
129
+ /** Título de la fila (ej. "Datos Personales"). */
130
+ title?: string;
131
+ /** Columnas en esta fila. */
132
+ columns: SectionColumn[];
133
+ }
134
+ /**
135
+ * Un conjunto de filas (SectionRowObject[]).
136
+ */
137
+ export type SectionRow = SectionRowObject[];
138
+ /**
139
+ * Bloque colapsable que agrupa varias filas.
140
+ */
141
+ export interface SectionBlock {
142
+ /** Título de la sección colapsable. */
143
+ sectionTitle: string;
144
+ /** Si true, la sección arranca expandida. */
145
+ defaultOpen?: boolean;
146
+ /** Arreglo de filas que pertenecen a esta sección. */
147
+ rows: SectionRow;
148
+ }
149
+ /**
150
+ * Nodo de layout:
151
+ * - "rows": contiene varios bloques colapsables (SectionBlock[]).
152
+ * - "tabs": conjunto de pestañas que a su vez tienen bloques colapsables.
153
+ */
154
+ export type LayoutNode = {
155
+ type: "rows";
156
+ sections: SectionBlock[];
157
+ } | {
158
+ type: "tabs";
159
+ tabs: Array<{
160
+ key: string;
161
+ label: string;
162
+ sections: SectionBlock[];
163
+ }>;
164
+ };
165
+ /**
166
+ * Esquema completo del formulario.
167
+ */
168
+ export interface FormSchema {
169
+ /** Esquema Yup para validación dinámica (opcional). */
170
+ validationSchema?: ObjectSchema<AnyObject>;
171
+ /** Layout principal: array de LayoutNode. */
172
+ layout: LayoutNode[];
173
+ /** Definición global de todos los campos. */
174
+ fields: FieldSchema[];
175
+ /** Función a llamar al hacer submit. */
176
+ onSubmit: (data: unknown) => void | Promise<void>;
177
+ /** Mensaje de éxito a mostrar. */
178
+ successMessage?: string;
179
+ /** Mensaje de error a mostrar. */
180
+ errorMessage?: string;
181
+ /** Botones personalizados al final del formulario. */
182
+ footerButtons?: React.ReactNode;
183
+ /** Valores por defecto sincrónicos. */
184
+ defaultValues?: Record<string, unknown>;
185
+ /** Función asíncrona para obtener defaultValues. */
186
+ loadDefaultValues?: () => Promise<Record<string, unknown>>;
187
+ }
@@ -0,0 +1 @@
1
+ export declare function scrollToFirstError(errors: Record<string, any>): void;
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@dipusevilla/componentes-iu",
3
+ "version": "1.0.8",
4
+ "description": "Librería de componentes React de Dipusevilla",
5
+ "keywords": [
6
+ "react",
7
+ "design-system",
8
+ "component-library",
9
+ "ui",
10
+ "dipusevilla"
11
+ ],
12
+ "author": "Dipusevilla <desarrolloinpro@dipusevilla.es>",
13
+ "main": "dist/index.cjs.js",
14
+ "module": "dist/index.es.js",
15
+ "unpkg": "dist/index.umd.js",
16
+ "types": "dist/types/index.d.ts",
17
+ "scripts": {
18
+ "build:types": "tsc --project tsconfig.build.json",
19
+ "build": "vite build && npm run build:types",
20
+ "prepublishOnly": "npm run build",
21
+ "dev": "vite",
22
+ "lint": "eslint .",
23
+ "preview": "vite preview",
24
+ "storybook": "storybook dev -p 6006",
25
+ "build-storybook": "storybook build"
26
+ },
27
+ "peerDependencies": {
28
+ "react": "^19.1.0",
29
+ "react-dom": "^19.1.0"
30
+ },
31
+ "dependencies": {
32
+ "@headlessui/react": "^2.2.4",
33
+ "@heroicons/react": "^2.2.0",
34
+ "@hookform/resolvers": "^5.0.1",
35
+ "clsx": "^2.1.1",
36
+ "i18next": "^25.2.1",
37
+ "react-hook-form": "^7.56.4",
38
+ "react-i18next": "^15.5.2",
39
+ "yup": "^1.6.1"
40
+ },
41
+ "devDependencies": {
42
+ "@chromatic-com/storybook": "^3.2.6",
43
+ "@eslint/js": "^9.25.0",
44
+ "@storybook/addon-essentials": "^8.6.14",
45
+ "@storybook/addon-onboarding": "^8.6.14",
46
+ "@storybook/blocks": "^8.6.14",
47
+ "@storybook/experimental-addon-test": "^8.6.14",
48
+ "@storybook/react": "^8.6.14",
49
+ "@storybook/react-vite": "^8.6.14",
50
+ "@storybook/test": "^8.6.14",
51
+ "@tailwindcss/postcss": "^4.1.8",
52
+ "@tailwindcss/vite": "^4.1.7",
53
+ "@types/i18next": "^12.1.0",
54
+ "@types/node": "^22.15.29",
55
+ "@types/react": "^19.1.6",
56
+ "@types/react-dom": "^19.1.5",
57
+ "@types/tailwindcss": "^3.0.11",
58
+ "@vitejs/plugin-react": "^4.4.1",
59
+ "@vitest/browser": "^3.1.4",
60
+ "@vitest/coverage-v8": "^3.1.4",
61
+ "autoprefixer": "^10.4.21",
62
+ "eslint": "^9.25.0",
63
+ "eslint-plugin-react-hooks": "^5.2.0",
64
+ "eslint-plugin-react-refresh": "^0.4.19",
65
+ "eslint-plugin-storybook": "^0.12.0",
66
+ "globals": "^16.0.0",
67
+ "playwright": "^1.52.0",
68
+ "postcss": "^8.5.4",
69
+ "storybook": "^8.6.14",
70
+ "storybook-dark-mode": "^4.0.2",
71
+ "tailwindcss": "^4.1.8",
72
+ "typescript": "~5.8.3",
73
+ "typescript-eslint": "^8.30.1",
74
+ "vite": "^6.3.5",
75
+ "vite-plugin-svgr": "^4.3.0",
76
+ "vitest": "^3.1.4"
77
+ },
78
+ "license": "ISC",
79
+ "eslintConfig": {
80
+ "extends": [
81
+ "plugin:storybook/recommended"
82
+ ]
83
+ },
84
+ "exports": {
85
+ ".": {
86
+ "import": "./dist/index.es.js",
87
+ "require": "./dist/index.cjs.js"
88
+ },
89
+ "./style.css": "./dist/index.css"
90
+ },
91
+ "files": [
92
+ "dist"
93
+ ]
94
+ }