@soyfri/shared-library 1.5.0 → 2.0.0-beta.0

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 (283) hide show
  1. package/dist/components/ActionMenu/ActionMenu.cjs +107 -0
  2. package/dist/components/ActionMenu/ActionMenu.cjs.map +1 -0
  3. package/dist/components/ActionMenu/ActionMenu.d.ts +60 -0
  4. package/dist/components/ActionMenu/ActionMenu.js +107 -0
  5. package/dist/components/ActionMenu/ActionMenu.js.map +1 -0
  6. package/dist/components/ActionMenu/index.d.ts +2 -0
  7. package/dist/components/ActionMenu.d.ts +6 -0
  8. package/dist/components/AppBar/AppBar.cjs +346 -0
  9. package/dist/components/AppBar/AppBar.cjs.map +1 -0
  10. package/dist/components/AppBar/AppBar.d.ts +55 -0
  11. package/dist/components/AppBar/AppBar.js +346 -0
  12. package/dist/components/AppBar/AppBar.js.map +1 -0
  13. package/dist/components/AppBar/AppBar.sx.d.ts +12 -0
  14. package/dist/components/AppBar/AppBarBrand.d.ts +31 -0
  15. package/dist/components/AppBar/AppBarContext.d.ts +18 -0
  16. package/dist/components/AppBar/AppBarMenuToggle.d.ts +39 -0
  17. package/dist/components/AppBar/AppBarUserMenu.d.ts +65 -0
  18. package/dist/components/AppBar/index.d.ts +12 -0
  19. package/dist/components/AppBar.d.ts +6 -0
  20. package/dist/components/Autocomplete/Autocomplete.cjs +259 -54
  21. package/dist/components/Autocomplete/Autocomplete.cjs.map +1 -1
  22. package/dist/components/Autocomplete/Autocomplete.d.ts +64 -9
  23. package/dist/components/Autocomplete/Autocomplete.definitions.d.ts +6 -0
  24. package/dist/components/Autocomplete/Autocomplete.helpers.d.ts +18 -0
  25. package/dist/components/Autocomplete/Autocomplete.js +261 -56
  26. package/dist/components/Autocomplete/Autocomplete.js.map +1 -1
  27. package/dist/components/Autocomplete/Autocomplete.sx.d.ts +7 -0
  28. package/dist/components/Autocomplete/Autocomplete.types.d.ts +1 -0
  29. package/dist/components/Autocomplete/_parts/AutocompleteChips.d.ts +19 -0
  30. package/dist/components/Autocomplete/_parts/AutocompleteLoader.d.ts +9 -0
  31. package/dist/components/Autocomplete/_parts/AutocompleteOption.d.ts +19 -0
  32. package/dist/components/Autocomplete/index.d.ts +2 -1
  33. package/dist/components/Autocomplete.d.ts +4 -0
  34. package/dist/components/Avatar/Avatar.cjs +116 -79
  35. package/dist/components/Avatar/Avatar.cjs.map +1 -1
  36. package/dist/components/Avatar/Avatar.d.ts +16 -2
  37. package/dist/components/Avatar/Avatar.definitions.d.ts +11 -0
  38. package/dist/components/Avatar/Avatar.js +117 -80
  39. package/dist/components/Avatar/Avatar.js.map +1 -1
  40. package/dist/components/Card/Card.cjs +168 -9
  41. package/dist/components/Card/Card.cjs.map +1 -1
  42. package/dist/components/Card/Card.d.ts +78 -8
  43. package/dist/components/Card/Card.js +170 -11
  44. package/dist/components/Card/Card.js.map +1 -1
  45. package/dist/components/Card/Card.sx.d.ts +17 -0
  46. package/dist/components/Card/index.d.ts +4 -1
  47. package/dist/components/Card.d.ts +4 -0
  48. package/dist/components/DatePicker/DatePicker.cjs +201 -3
  49. package/dist/components/DatePicker/DatePicker.cjs.map +1 -1
  50. package/dist/components/DatePicker/DatePicker.d.ts +47 -9
  51. package/dist/components/DatePicker/DatePicker.definitions.d.ts +1 -0
  52. package/dist/components/DatePicker/DatePicker.helpers.d.ts +7 -0
  53. package/dist/components/DatePicker/DatePicker.js +200 -2
  54. package/dist/components/DatePicker/DatePicker.js.map +1 -1
  55. package/dist/components/DatePicker/DatePicker.sx.d.ts +9 -0
  56. package/dist/components/DatePicker/DatePicker.types.d.ts +1 -0
  57. package/dist/components/DatePicker/index.d.ts +2 -1
  58. package/dist/components/DatePicker.d.ts +4 -0
  59. package/dist/components/DateTimePicker/DateTimePicker.cjs +152 -138
  60. package/dist/components/DateTimePicker/DateTimePicker.cjs.map +1 -1
  61. package/dist/components/DateTimePicker/DateTimePicker.d.ts +46 -9
  62. package/dist/components/DateTimePicker/DateTimePicker.definitions.d.ts +1 -0
  63. package/dist/components/DateTimePicker/DateTimePicker.helpers.d.ts +11 -0
  64. package/dist/components/DateTimePicker/DateTimePicker.js +152 -138
  65. package/dist/components/DateTimePicker/DateTimePicker.js.map +1 -1
  66. package/dist/components/DateTimePicker/DateTimePicker.sx.d.ts +7 -0
  67. package/dist/components/DateTimePicker/DateTimePicker.types.d.ts +1 -0
  68. package/dist/components/DateTimePicker/index.d.ts +2 -1
  69. package/dist/components/DateTimePicker.d.ts +4 -0
  70. package/dist/components/Drawer/Drawer.cjs +271 -0
  71. package/dist/components/Drawer/Drawer.cjs.map +1 -0
  72. package/dist/components/Drawer/Drawer.d.ts +51 -0
  73. package/dist/components/Drawer/Drawer.js +271 -0
  74. package/dist/components/Drawer/Drawer.js.map +1 -0
  75. package/dist/components/Drawer/Drawer.sx.d.ts +23 -0
  76. package/dist/components/Drawer/DrawerContext.d.ts +18 -0
  77. package/dist/components/Drawer/DrawerItem.d.ts +35 -0
  78. package/dist/components/Drawer/index.d.ts +6 -0
  79. package/dist/components/Drawer.d.ts +6 -0
  80. package/dist/components/Icon/Icon.cjs +44 -3
  81. package/dist/components/Icon/Icon.cjs.map +1 -1
  82. package/dist/components/Icon/Icon.d.ts +34 -1
  83. package/dist/components/Icon/Icon.js +44 -3
  84. package/dist/components/Icon/Icon.js.map +1 -1
  85. package/dist/components/Input/Input.cjs +173 -3
  86. package/dist/components/Input/Input.cjs.map +1 -1
  87. package/dist/components/Input/Input.d.ts +20 -15
  88. package/dist/components/Input/Input.definitions.d.ts +5 -2
  89. package/dist/components/Input/Input.helpers.d.ts +14 -0
  90. package/dist/components/Input/Input.js +172 -2
  91. package/dist/components/Input/Input.js.map +1 -1
  92. package/dist/components/Input/Input.sx.d.ts +8 -0
  93. package/dist/components/Input/Input.types.d.ts +1 -0
  94. package/dist/components/Input/index.d.ts +2 -1
  95. package/dist/components/Input.d.ts +4 -0
  96. package/dist/components/InputGroup/InputGroup.cjs +104 -91
  97. package/dist/components/InputGroup/InputGroup.cjs.map +1 -1
  98. package/dist/components/InputGroup/InputGroup.d.ts +37 -1
  99. package/dist/components/InputGroup/InputGroup.definitions.d.ts +6 -0
  100. package/dist/components/InputGroup/InputGroup.js +106 -93
  101. package/dist/components/InputGroup/InputGroup.js.map +1 -1
  102. package/dist/components/Modal/Modal.cjs +226 -116
  103. package/dist/components/Modal/Modal.cjs.map +1 -1
  104. package/dist/components/Modal/Modal.d.ts +38 -2
  105. package/dist/components/Modal/Modal.js +227 -117
  106. package/dist/components/Modal/Modal.js.map +1 -1
  107. package/dist/components/Modal/ModalFooter.d.ts +9 -1
  108. package/dist/components/Modal/index.d.ts +5 -0
  109. package/dist/components/PageLoader/PageLoader.cjs +61 -0
  110. package/dist/components/PageLoader/PageLoader.cjs.map +1 -0
  111. package/dist/components/PageLoader/PageLoader.d.ts +38 -0
  112. package/dist/components/PageLoader/PageLoader.js +61 -0
  113. package/dist/components/PageLoader/PageLoader.js.map +1 -0
  114. package/dist/components/PageLoader/index.d.ts +2 -0
  115. package/dist/components/PageLoader.d.ts +6 -0
  116. package/dist/components/ScrollTopButton/ScrollTopButton.cjs +79 -0
  117. package/dist/components/ScrollTopButton/ScrollTopButton.cjs.map +1 -0
  118. package/dist/components/ScrollTopButton/ScrollTopButton.d.ts +48 -0
  119. package/dist/components/ScrollTopButton/ScrollTopButton.js +79 -0
  120. package/dist/components/ScrollTopButton/ScrollTopButton.js.map +1 -0
  121. package/dist/components/ScrollTopButton/index.d.ts +4 -0
  122. package/dist/components/ScrollTopButton/scrollToTop.d.ts +29 -0
  123. package/dist/components/ScrollTopButton.d.ts +6 -0
  124. package/dist/components/Select/Select.cjs +446 -4
  125. package/dist/components/Select/Select.cjs.map +1 -1
  126. package/dist/components/Select/Select.d.ts +33 -13
  127. package/dist/components/Select/Select.definitions.d.ts +3 -0
  128. package/dist/components/Select/Select.helpers.d.ts +28 -0
  129. package/dist/components/Select/Select.js +445 -3
  130. package/dist/components/Select/Select.js.map +1 -1
  131. package/dist/components/Select/Select.sx.d.ts +7 -0
  132. package/dist/components/Select/Select.types.d.ts +1 -0
  133. package/dist/components/Select/_parts/SelectMenuItem.d.ts +20 -0
  134. package/dist/components/Select/_parts/SelectSearchHeader.d.ts +15 -0
  135. package/dist/components/Select/_parts/SelectValue.d.ts +22 -0
  136. package/dist/components/Select/index.d.ts +2 -1
  137. package/dist/components/Select.d.ts +4 -0
  138. package/dist/components/Stat/Stat.cjs +1 -1
  139. package/dist/components/Stat/Stat.js +1 -1
  140. package/dist/components/Stepper/Stepper.cjs +4 -1
  141. package/dist/components/Stepper/Stepper.cjs.map +1 -1
  142. package/dist/components/Stepper/Stepper.d.ts +5 -0
  143. package/dist/components/Stepper/Stepper.js +4 -1
  144. package/dist/components/Stepper/Stepper.js.map +1 -1
  145. package/dist/components/_shared/formField.sx.d.ts +33 -0
  146. package/dist/components/_shared/resolvePreset.d.ts +18 -0
  147. package/dist/formField.sx-CQ1mbk9M.cjs +76 -0
  148. package/dist/formField.sx-CQ1mbk9M.cjs.map +1 -0
  149. package/dist/formField.sx-DfVbMe0V.js +77 -0
  150. package/dist/formField.sx-DfVbMe0V.js.map +1 -0
  151. package/dist/hooks/Wizard/Wizard.cjs +7 -0
  152. package/dist/hooks/Wizard/Wizard.cjs.map +1 -0
  153. package/dist/hooks/Wizard/Wizard.js +7 -0
  154. package/dist/hooks/Wizard/Wizard.js.map +1 -0
  155. package/dist/hooks/Wizard/WizardContext.d.ts +67 -0
  156. package/dist/hooks/Wizard/index.d.ts +3 -0
  157. package/dist/hooks/Wizard/useWizard.d.ts +9 -0
  158. package/dist/hooks/Wizard.d.ts +2 -0
  159. package/dist/index.cjs +99 -1
  160. package/dist/index.cjs.map +1 -1
  161. package/dist/index.d.ts +3 -0
  162. package/dist/index.js +31 -2
  163. package/dist/index.js.map +1 -1
  164. package/dist/mui.d.ts +5 -0
  165. package/dist/resolvePreset-B-IB0ehH.js +15 -0
  166. package/dist/resolvePreset-B-IB0ehH.js.map +1 -0
  167. package/dist/resolvePreset-CT3kU-K2.cjs +14 -0
  168. package/dist/resolvePreset-CT3kU-K2.cjs.map +1 -0
  169. package/dist/styles.css +3 -112
  170. package/dist/theme/componentStyles.d.ts +32 -0
  171. package/dist/theme/tokens.d.ts +28 -0
  172. package/dist/useWizard-CWdIxZzX.cjs +94 -0
  173. package/dist/useWizard-CWdIxZzX.cjs.map +1 -0
  174. package/dist/useWizard-CWq--C3o.js +95 -0
  175. package/dist/useWizard-CWq--C3o.js.map +1 -0
  176. package/package.json +1 -1
  177. package/src/components/ActionMenu/ActionMenu.stories.tsx +230 -0
  178. package/src/components/ActionMenu/ActionMenu.tsx +174 -0
  179. package/src/components/ActionMenu/index.ts +2 -0
  180. package/src/components/AppBar/AppBar.stories.tsx +272 -0
  181. package/src/components/AppBar/AppBar.sx.ts +32 -0
  182. package/src/components/AppBar/AppBar.tsx +123 -0
  183. package/src/components/AppBar/AppBarBrand.tsx +120 -0
  184. package/src/components/AppBar/AppBarContext.ts +25 -0
  185. package/src/components/AppBar/AppBarMenuToggle.tsx +90 -0
  186. package/src/components/AppBar/AppBarUserMenu.tsx +217 -0
  187. package/src/components/AppBar/index.ts +25 -0
  188. package/src/components/Autocomplete/Autocomplete.definitions.ts +223 -0
  189. package/src/components/Autocomplete/Autocomplete.helpers.ts +60 -0
  190. package/src/components/Autocomplete/Autocomplete.stories.tsx +363 -2
  191. package/src/components/Autocomplete/Autocomplete.sx.ts +30 -0
  192. package/src/components/Autocomplete/Autocomplete.tsx +312 -90
  193. package/src/components/Autocomplete/Autocomplete.types.ts +13 -0
  194. package/src/components/Autocomplete/_parts/AutocompleteChips.tsx +55 -0
  195. package/src/components/Autocomplete/_parts/AutocompleteLoader.tsx +17 -0
  196. package/src/components/Autocomplete/_parts/AutocompleteOption.tsx +31 -0
  197. package/src/components/Autocomplete/index.ts +12 -1
  198. package/src/components/Avatar/Avatar.definitions.ts +162 -0
  199. package/src/components/Avatar/Avatar.stories.tsx +205 -1
  200. package/src/components/Avatar/Avatar.tsx +166 -103
  201. package/src/components/Card/Card.stories.tsx +205 -16
  202. package/src/components/Card/Card.sx.ts +104 -0
  203. package/src/components/Card/Card.tsx +191 -35
  204. package/src/components/Card/index.ts +9 -1
  205. package/src/components/DatePicker/DatePicker.definitions.ts +24 -1
  206. package/src/components/DatePicker/DatePicker.helpers.ts +24 -0
  207. package/src/components/DatePicker/DatePicker.stories.tsx +29 -2
  208. package/src/components/DatePicker/DatePicker.sx.ts +33 -0
  209. package/src/components/DatePicker/DatePicker.tsx +163 -139
  210. package/src/components/DatePicker/DatePicker.types.ts +10 -0
  211. package/src/components/DatePicker/index.ts +9 -1
  212. package/src/components/DateTimePicker/DateTimePicker.definitions.ts +24 -0
  213. package/src/components/DateTimePicker/DateTimePicker.helpers.ts +38 -0
  214. package/src/components/DateTimePicker/DateTimePicker.stories.tsx +29 -1
  215. package/src/components/DateTimePicker/DateTimePicker.sx.ts +30 -0
  216. package/src/components/DateTimePicker/DateTimePicker.tsx +200 -166
  217. package/src/components/DateTimePicker/DateTimePicker.types.ts +10 -0
  218. package/src/components/DateTimePicker/index.ts +9 -1
  219. package/src/components/Drawer/Drawer.stories.tsx +270 -0
  220. package/src/components/Drawer/Drawer.sx.ts +106 -0
  221. package/src/components/Drawer/Drawer.tsx +214 -0
  222. package/src/components/Drawer/DrawerContext.ts +26 -0
  223. package/src/components/Drawer/DrawerItem.tsx +110 -0
  224. package/src/components/Drawer/index.ts +10 -0
  225. package/src/components/Flyout/Flyout.stories.tsx +26 -18
  226. package/src/components/Icon/Icon.stories.tsx +68 -1
  227. package/src/components/Icon/Icon.tsx +87 -6
  228. package/src/components/Input/Input.definitions.ts +74 -2
  229. package/src/components/Input/Input.helpers.ts +49 -0
  230. package/src/components/Input/Input.stories.tsx +116 -4
  231. package/src/components/Input/Input.sx.ts +42 -0
  232. package/src/components/Input/Input.tsx +117 -162
  233. package/src/components/Input/Input.types.ts +10 -0
  234. package/src/components/Input/index.ts +9 -1
  235. package/src/components/InputGroup/InputGroup.definitions.ts +158 -0
  236. package/src/components/InputGroup/InputGroup.stories.tsx +159 -28
  237. package/src/components/InputGroup/InputGroup.tsx +159 -116
  238. package/src/components/Modal/Modal.stories.tsx +434 -6
  239. package/src/components/Modal/Modal.tsx +303 -121
  240. package/src/components/Modal/ModalFooter.tsx +22 -12
  241. package/src/components/Modal/index.ts +6 -1
  242. package/src/components/PageLoader/PageLoader.stories.tsx +217 -0
  243. package/src/components/PageLoader/PageLoader.tsx +96 -0
  244. package/src/components/PageLoader/index.ts +2 -0
  245. package/src/components/ScrollTopButton/ScrollTopButton.stories.tsx +158 -0
  246. package/src/components/ScrollTopButton/ScrollTopButton.tsx +135 -0
  247. package/src/components/ScrollTopButton/index.ts +8 -0
  248. package/src/components/ScrollTopButton/scrollToTop.ts +37 -0
  249. package/src/components/Select/Select.definitions.ts +114 -0
  250. package/src/components/Select/Select.helpers.ts +71 -0
  251. package/src/components/Select/Select.stories.tsx +126 -8
  252. package/src/components/Select/Select.sx.ts +14 -0
  253. package/src/components/Select/Select.tsx +246 -285
  254. package/src/components/Select/Select.types.ts +15 -0
  255. package/src/components/Select/_parts/SelectMenuItem.tsx +40 -0
  256. package/src/components/Select/_parts/SelectSearchHeader.tsx +51 -0
  257. package/src/components/Select/_parts/SelectValue.tsx +96 -0
  258. package/src/components/Select/index.ts +14 -1
  259. package/src/components/Stepper/Stepper.tsx +17 -1
  260. package/src/components/Tooltip/Tooltip.stories.tsx +15 -3
  261. package/src/components/_shared/formField.sx.ts +118 -0
  262. package/src/components/_shared/resolvePreset.ts +35 -0
  263. package/src/hooks/Wizard/Wizard.stories.tsx +301 -0
  264. package/src/hooks/Wizard/WizardContext.tsx +166 -0
  265. package/src/hooks/Wizard/index.ts +6 -0
  266. package/src/hooks/Wizard/useWizard.ts +13 -0
  267. package/src/index.ts +17 -1
  268. package/src/mui.ts +44 -0
  269. package/src/theme/componentStyles.ts +47 -0
  270. package/src/theme/tokens.ts +43 -0
  271. package/dist/DatePicker-BSNboVhN.js +0 -201
  272. package/dist/DatePicker-BSNboVhN.js.map +0 -1
  273. package/dist/DatePicker-BoqxWAhj.cjs +0 -200
  274. package/dist/DatePicker-BoqxWAhj.cjs.map +0 -1
  275. package/dist/Input-DFHs7cJ_.js +0 -171
  276. package/dist/Input-DFHs7cJ_.js.map +0 -1
  277. package/dist/Input-c8MwNNPg.cjs +0 -170
  278. package/dist/Input-c8MwNNPg.cjs.map +0 -1
  279. package/dist/Select-BO2N56sm.cjs +0 -411
  280. package/dist/Select-BO2N56sm.cjs.map +0 -1
  281. package/dist/Select-BcLkyHSE.js +0 -412
  282. package/dist/Select-BcLkyHSE.js.map +0 -1
  283. package/dist/index.css +0 -3
@@ -21,6 +21,9 @@ import {
21
21
  InputVariantsDefinition,
22
22
  InputSizesDefinition,
23
23
  FullWidthInputDefinition,
24
+ LabelPositionFloatingDefinition,
25
+ CustomBorderRadiusDefinition,
26
+ CustomStylingDefinition,
24
27
  } from './Input.definitions';
25
28
 
26
29
  // =============================================================================
@@ -63,7 +66,18 @@ const meta: Meta<typeof Input> = {
63
66
  control: 'radio',
64
67
  options: ['small', 'medium'],
65
68
  description: 'El tamaño del campo de entrada.',
66
- defaultValue: 'medium',
69
+ defaultValue: 'small',
70
+ },
71
+ labelPosition: {
72
+ control: 'radio',
73
+ options: ['outside', 'floating'],
74
+ description: '"outside" (default): label arriba del input. "floating": label clásico de MUI dentro del notched outline.',
75
+ defaultValue: 'outside',
76
+ },
77
+ borderRadius: {
78
+ control: { type: 'number' },
79
+ description: 'Border radius del input en px (o string CSS). Default: 10.',
80
+ defaultValue: 10,
67
81
  },
68
82
  fullWidth: { control: 'boolean', description: 'Si es verdadero, el campo de entrada ocupará todo el ancho disponible.', defaultValue: false },
69
83
  },
@@ -362,13 +376,13 @@ export const FullWidthInput: Story = {
362
376
  }
363
377
  };
364
378
 
365
- export const StandardVariant : Story = {
379
+ export const StandardVariant: Story = {
366
380
  render: () => {
367
381
  const [value, setValue] = useState('Ocupa todo el ancho');
368
382
  return (
369
383
  <Box sx={{ width: '100%' }}>
370
384
  <Input
371
-
385
+
372
386
  value={value.toString()}
373
387
  variant='standard'
374
388
  onChange={(value) => setValue(value.toString())}
@@ -382,6 +396,104 @@ export const StandardVariant : Story = {
382
396
  docs: {
383
397
  story: "Un campo de entrada que ocupa todo el ancho disponible de su contenedor."
384
398
  },
385
-
399
+
400
+ }
401
+ };
402
+
403
+ export const LabelPositionFloating: Story = {
404
+ render: () => {
405
+ const [valueOutside, setValueOutside] = useState('Outside (default)');
406
+ const [valueFloating, setValueFloating] = useState('Floating');
407
+ return (
408
+ <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3, width: 300 }}>
409
+ <Input
410
+ label="Label outside"
411
+ value={valueOutside.toString()}
412
+ onChange={(value) => setValueOutside(value.toString())}
413
+ labelPosition="outside"
414
+ />
415
+ <Input
416
+ label="Label floating (MUI clásico)"
417
+ value={valueFloating.toString()}
418
+ onChange={(value) => setValueFloating(value.toString())}
419
+ labelPosition="floating"
420
+ />
421
+ </Box>
422
+ );
423
+ },
424
+ parameters: {
425
+ docs: {
426
+ description: {
427
+ story: "Compara `labelPosition='outside'` (default, label arriba del input) vs `labelPosition='floating'` (label flotante clásico de MUI dentro del notched outline)."
428
+ },
429
+ source: { code: LabelPositionFloatingDefinition.trim() }
430
+ }
431
+ }
432
+ };
433
+
434
+ export const CustomBorderRadius: Story = {
435
+ render: () => {
436
+ const [v0, setV0] = useState('Sin radius');
437
+ const [v4, setV4] = useState('Radius 4px');
438
+ const [v10, setV10] = useState('Radius 10px (default)');
439
+ const [v24, setV24] = useState('Radius 24px (pill)');
440
+ return (
441
+ <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3, width: 300 }}>
442
+ <Input label="borderRadius={0}" value={v0} onChange={(v) => setV0(v.toString())} borderRadius={0} />
443
+ <Input label="borderRadius={4}" value={v4} onChange={(v) => setV4(v.toString())} borderRadius={4} />
444
+ <Input label="borderRadius={10} (default)" value={v10} onChange={(v) => setV10(v.toString())} />
445
+ <Input label="borderRadius={24}" value={v24} onChange={(v) => setV24(v.toString())} borderRadius={24} />
446
+ </Box>
447
+ );
448
+ },
449
+ parameters: {
450
+ docs: {
451
+ description: {
452
+ story: "El prop `borderRadius` acepta un número (px) o un string CSS. Override directo del default `10`."
453
+ },
454
+ source: { code: CustomBorderRadiusDefinition.trim() }
455
+ }
456
+ }
457
+ };
458
+
459
+ export const CustomStyling: Story = {
460
+ render: () => {
461
+ const [bg, setBg] = useState('Fondo gris claro');
462
+ const [color, setColor] = useState('Borde rojo');
463
+ const [combined, setCombined] = useState('Custom completo');
464
+ return (
465
+ <Box sx={{ display: 'flex', flexDirection: 'column', gap: 3, width: 300 }}>
466
+ <Input
467
+ label="Override de background"
468
+ value={bg}
469
+ onChange={(v) => setBg(v.toString())}
470
+ sx={{ '& .MuiOutlinedInput-root': { bgcolor: '#f5f5f5' } }}
471
+ />
472
+ <Input
473
+ label="Override de borderColor"
474
+ value={color}
475
+ onChange={(v) => setColor(v.toString())}
476
+ sx={{ '& .MuiOutlinedInput-notchedOutline': { borderColor: 'red' } }}
477
+ />
478
+ <Input
479
+ label="Combinado: bg + borderColor + label color"
480
+ value={combined}
481
+ onChange={(v) => setCombined(v.toString())}
482
+ sx={{
483
+ '& .MuiInputLabel-root': { color: 'primary.main' },
484
+ '& .MuiOutlinedInput-root': { bgcolor: '#fff7e6' },
485
+ '& .MuiOutlinedInput-notchedOutline': { borderColor: 'warning.main', borderWidth: 2 },
486
+ }}
487
+ />
488
+ </Box>
489
+ );
490
+ },
491
+ parameters: {
492
+ docs: {
493
+ description: {
494
+ story: "Demuestra que el prop `sx` se mergea al final y siempre gana sobre los defaults internos. Antes esto no funcionaba por culpa del `styled()` interno."
495
+ },
496
+ source: { code: CustomStylingDefinition.trim() }
497
+ }
386
498
  }
387
499
  };
@@ -0,0 +1,42 @@
1
+ import type { TextFieldProps } from '@mui/material';
2
+
3
+ import { buildFormFieldSx } from '../_shared/formField.sx';
4
+ import { FIELD_INPUT_PADDING_Y } from '../../theme/tokens';
5
+ import type { LabelPosition } from './Input';
6
+
7
+ /**
8
+ * Builder de sx para el Input. Usa el builder compartido
9
+ * `buildFormFieldSx` y añade overrides específicos de TextField
10
+ * (padding del input base, filled, standard).
11
+ */
12
+ export const buildInputSx = (
13
+ borderRadius: number | string,
14
+ labelPosition: LabelPosition,
15
+ ): TextFieldProps['sx'] => {
16
+ const radius = typeof borderRadius === 'number' ? `${borderRadius}px` : borderRadius;
17
+
18
+ return buildFormFieldSx({
19
+ borderRadius,
20
+ labelPosition,
21
+ extraOutsideSx: {
22
+ '& .MuiInputBase-input': {
23
+ paddingTop: FIELD_INPUT_PADDING_Y,
24
+ paddingBottom: FIELD_INPUT_PADDING_Y,
25
+ },
26
+
27
+ // Filled: quitar el padding-top reservado para el label flotante dentro.
28
+ '& .MuiFilledInput-root': {
29
+ paddingTop: 0,
30
+ borderRadius: `${radius} ${radius} 0 0`,
31
+ },
32
+ '& .MuiFilledInput-input': {
33
+ paddingTop: FIELD_INPUT_PADDING_Y,
34
+ },
35
+
36
+ // Standard: quitar el margin-top reservado para el label flotante.
37
+ '& .MuiInput-root': {
38
+ marginTop: 0,
39
+ },
40
+ },
41
+ });
42
+ };
@@ -1,186 +1,141 @@
1
- import React, { forwardRef } from 'react';
2
- import { TextField, TextFieldProps } from '@mui/material';
3
- import { styled } from '@mui/system';
4
- import { Controller, Control, RegisterOptions } from 'react-hook-form';
5
-
6
-
7
-
8
-
9
- interface BaseInputProps extends Omit<TextFieldProps, 'value' | 'onChange' | 'variant' | 'type' | 'inputProps' | 'slotProps' | 'error' | 'helperText'> {
10
- type?: 'text' | 'number' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'date' | 'datetime-local' | 'month' | 'week' | 'time' | 'color';
11
- variant?: 'outlined' | 'filled' | 'standard';
1
+ import { TextField, type TextFieldProps } from '@mui/material';
2
+ import { useTheme } from '@mui/material/styles';
3
+ import { Controller, type Control, type RegisterOptions } from 'react-hook-form';
4
+
5
+ import { parseValue, buildSlotProps } from './Input.helpers';
6
+ import { buildInputSx } from './Input.sx';
7
+ import { resolvePreset } from '../_shared/resolvePreset';
8
+
9
+ // ── Tipos de dominio ─────────────────────────────────────────────────────
10
+ export type InputType =
11
+ | 'text' | 'number' | 'email' | 'password' | 'tel'
12
+ | 'url' | 'search' | 'date' | 'datetime-local'
13
+ | 'month' | 'week' | 'time' | 'color';
14
+
15
+ export type LabelPosition = 'outside' | 'floating';
16
+
17
+ // ── Props base (todo lo común entre RHF y controlado) ────────────────────
18
+ export interface BaseInputProps
19
+ extends Omit<TextFieldProps, 'value' | 'onChange' | 'type'> {
20
+ type?: InputType;
12
21
  min?: number;
13
22
  max?: number;
14
- inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
15
- slotProps?: TextFieldProps['slotProps'];
16
- disabled?: boolean;
23
+ /** Border radius del input. Default: 10 */
24
+ borderRadius?: number | string;
25
+ /** "outside" = label arriba del campo (default). "floating" = label clásico MUI dentro del borde */
26
+ labelPosition?: LabelPosition;
17
27
  readOnly?: boolean;
18
- error?: boolean;
19
- helperText?: string;
28
+ /**
29
+ * Nombre del preset de estilo registrado en `theme.styles.Input`.
30
+ * - `"default"` (o ausente) = estilo built-in del paquete.
31
+ * - Cualquier otro string = mergea el preset encima del estilo built-in.
32
+ */
33
+ preset?: string;
20
34
  }
21
35
 
22
- interface RHFInputProps extends BaseInputProps {
36
+ // ── Variantes discriminadas (RHF vs controlado) ──────────────────────────
37
+ export interface RHFInputProps extends BaseInputProps {
23
38
  name: string;
24
39
  control: Control<any>;
25
40
  validation?: RegisterOptions;
26
- value?: string | number;
27
- onChange?: (value: string | number) => void;
41
+ value?: never;
42
+ onChange?: never;
28
43
  }
29
44
 
30
- interface StandardInputPropsWithOptionalName extends BaseInputProps {
31
- name?: string;
45
+ export interface ControlledInputProps extends BaseInputProps {
46
+ name?: string;
32
47
  control?: never;
33
48
  validation?: never;
34
49
  value: string | number;
35
50
  onChange: (value: string | number) => void;
36
51
  }
37
52
 
38
- export type InputProps = RHFInputProps | StandardInputPropsWithOptionalName;
39
-
40
-
41
- const StyledTextField = styled(TextField)(({ theme }) => ({
42
- '& .MuiInputBase-root': {
43
- maxHeight: '34px',
44
- padding: '8px 10px',
45
- borderRadius: '10px',
46
- display: 'flex',
47
- alignItems: 'center',
48
- fontSize: '14px',
49
- },
50
- '& .MuiInputBase-input': {
51
- padding: '0 !important',
52
- height: '18px',
53
- display: 'flex',
54
- alignItems: 'center',
55
- marginTop: '-4px'
56
- },
57
- '& .MuiInputLabel-root': {
58
- top: '50%',
59
- transform: 'translate(14px, -50%)',
60
- '&.MuiInputLabel-shrink': {
61
- transform: 'translate(1px, -200%) scale(0.75)',
62
- fontSize: '16px !important',
63
- '> legend': {
64
- display: 'none',
65
- }
66
- }
67
- },
68
- '& .MuiInputLabel-root.Mui-error': {
69
- top: '25%'
70
-
71
- },
72
- '& .MuiInputBase-root > fieldset > legend':{
73
- display: 'none',
74
- },
75
- '& .MuiOutlinedInput-notchedOutline': {
76
- border: '0.7px solid',
77
- borderColor: '#e0e0e0',
78
- },
79
- }));
80
-
81
-
82
- export const Input = forwardRef<HTMLInputElement, InputProps>(({
83
- type = 'text',
84
- variant = 'outlined',
85
- min,
86
- max,
87
- inputProps: customInputProps,
88
- slotProps: customSlotProps,
89
-
90
- value,
91
- onChange,
92
- ...rest
93
- }, ref) => {
94
- const isRHFMode = 'control' in rest && rest.control !== undefined;
95
-
96
-
97
- const htmlInputProps: React.InputHTMLAttributes<HTMLInputElement> = {
98
- ...customInputProps,
99
- };
100
-
101
- if (type === 'number') {
102
- htmlInputProps.min = min !== undefined ? min : Number.NEGATIVE_INFINITY;
103
- if (max !== undefined) {
104
- htmlInputProps.max = max;
105
- }
106
- }
107
-
108
-
109
- const finalSlotProps: TextFieldProps['slotProps'] = {
110
- ...customSlotProps,
111
- htmlInput: {
112
- ...customSlotProps?.htmlInput,
113
- ...htmlInputProps,
114
- },
115
- };
116
-
117
-
118
- const handleChangeInternal = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, rhfOnChange?: (...event: any[]) => void) => {
119
- const rawValue = event.target.value;
120
- let newValue: string | number;
121
-
122
- if (type === 'number') {
123
- newValue = rawValue === '' || rawValue === '-' ? rawValue : parseFloat(rawValue);
124
-
125
- if (isNaN(newValue as number) && rawValue !== '' && rawValue !== '-') newValue = rawValue;
126
- } else {
127
- newValue = rawValue;
128
- }
129
-
130
- if (isRHFMode) {
131
- rhfOnChange?.(newValue);
132
- } else {
133
-
134
- (onChange as (value: string | number) => void)?.(newValue);
135
- }
53
+ // ── API pública final ────────────────────────────────────────────────────
54
+ export type InputProps = RHFInputProps | ControlledInputProps;
55
+
56
+ export const Input: React.FC<InputProps> = (props) => {
57
+ const {
58
+ type = 'text',
59
+ variant = 'outlined',
60
+ size = 'small',
61
+ borderRadius = 10,
62
+ labelPosition = 'outside',
63
+ preset,
64
+ min,
65
+ max,
66
+ readOnly,
67
+ inputProps,
68
+ slotProps,
69
+ sx,
70
+ ...rest
71
+ } = props as ControlledInputProps & {
72
+ control?: Control<any>;
73
+ validation?: RegisterOptions;
74
+ readOnly?: boolean;
75
+ preset?: string;
136
76
  };
137
77
 
138
-
139
- if (isRHFMode) {
140
- const rhfProps = rest as RHFInputProps;
78
+ const theme = useTheme();
79
+ const presetSx = resolvePreset('Input', preset, theme);
80
+
81
+ const finalSlotProps = buildSlotProps(
82
+ type,
83
+ min,
84
+ max,
85
+ slotProps,
86
+ inputProps,
87
+ labelPosition,
88
+ readOnly,
89
+ );
90
+ const mergedSx = [
91
+ buildInputSx(borderRadius, labelPosition),
92
+ ...(presetSx ? [presetSx] : []),
93
+ ...(Array.isArray(sx) ? sx : [sx]),
94
+ ];
95
+
96
+ if ('control' in props && props.control) {
97
+ const { name, control, validation } = props as RHFInputProps;
141
98
  return (
142
99
  <Controller
143
- name={rhfProps.name}
144
- control={rhfProps.control}
145
- rules={rhfProps.validation}
146
- render={({ field, fieldState: { error } }) => {
147
- return (
148
- <StyledTextField
149
- fullWidth={true}
150
- value={field.value ?? ''}
151
- onChange={(e) => handleChangeInternal(e, field.onChange)}
152
- onBlur={field.onBlur}
153
- type={type}
154
- variant={variant}
155
- slotProps={finalSlotProps}
156
- inputRef={field.ref}
157
- error={!!error}
158
- helperText={error?.message}
159
- {...rest}
160
- />
161
- );
162
- }}
163
- />
164
- );
165
- } else {
166
-
167
- const standardProps = rest as StandardInputPropsWithOptionalName;
168
- return (
169
- <StyledTextField
170
- fullWidth={true}
171
- name={standardProps.name}
172
- value={value ?? ''}
173
- onChange={(e) => handleChangeInternal(e)}
174
- type={type}
175
- variant={variant}
176
- slotProps={finalSlotProps}
177
- inputRef={ref}
178
- error={standardProps.error}
179
- helperText={standardProps.helperText}
180
- {...rest}
100
+ name={name}
101
+ control={control}
102
+ rules={validation}
103
+ render={({ field, fieldState: { error } }) => (
104
+ <TextField
105
+ fullWidth
106
+ {...rest}
107
+ name={field.name}
108
+ value={field.value ?? ''}
109
+ onChange={(e) => field.onChange(parseValue(e.target.value, type))}
110
+ onBlur={field.onBlur}
111
+ inputRef={field.ref}
112
+ type={type}
113
+ variant={variant}
114
+ size={size}
115
+ slotProps={finalSlotProps}
116
+ sx={mergedSx}
117
+ error={!!error || rest.error}
118
+ helperText={error?.message ?? rest.helperText}
119
+ />
120
+ )}
181
121
  />
182
122
  );
183
123
  }
184
- });
185
124
 
186
- export default Input;
125
+ const { value, onChange } = props as ControlledInputProps;
126
+ return (
127
+ <TextField
128
+ fullWidth
129
+ {...rest}
130
+ value={value ?? ''}
131
+ onChange={(e) => onChange(parseValue(e.target.value, type))}
132
+ type={type}
133
+ variant={variant}
134
+ size={size}
135
+ slotProps={finalSlotProps}
136
+ sx={mergedSx}
137
+ />
138
+ );
139
+ };
140
+
141
+ export default Input;
@@ -0,0 +1,10 @@
1
+ // Re-export barrel para compatibilidad con imports antiguos.
2
+ // Los tipos ahora viven dentro de Input.tsx.
3
+ export type {
4
+ InputType,
5
+ LabelPosition,
6
+ BaseInputProps,
7
+ RHFInputProps,
8
+ ControlledInputProps,
9
+ InputProps,
10
+ } from './Input';
@@ -1 +1,9 @@
1
- export { default as Input } from './Input';
1
+ export { Input, default } from './Input';
2
+ export type {
3
+ InputProps,
4
+ BaseInputProps,
5
+ RHFInputProps,
6
+ ControlledInputProps,
7
+ InputType,
8
+ LabelPosition,
9
+ } from './Input.types';
@@ -0,0 +1,158 @@
1
+ export const BasicInputGroupDefinition = `
2
+ import { useState } from 'react';
3
+ import { Box, Typography } from '@mui/material';
4
+ import InputGroup from './InputGroup';
5
+ import { Input } from '../Input';
6
+ import { Button } from '../Button';
7
+
8
+ export const BasicInputGroupExample = () => {
9
+ const [text, setText] = useState('');
10
+ return (
11
+ <Box>
12
+ <Typography variant="h6" sx={{ mb: 2 }}>
13
+ Grupo de entrada básico
14
+ </Typography>
15
+ <InputGroup>
16
+ <Input label="Buscar" value={text} onChange={(val) => setText(val as string)} />
17
+ <Button variant="outlined">Buscar</Button>
18
+ </InputGroup>
19
+ </Box>
20
+ );
21
+ };
22
+ `;
23
+
24
+ export const CombinedInputGroupDefinition = `
25
+ import { useState } from 'react';
26
+ import { Box, Typography } from '@mui/material';
27
+ import InputGroup from './InputGroup';
28
+ import { Input } from '../Input';
29
+ import Select, { SelectOption } from '../Select/Select';
30
+ import { Button } from '../Button';
31
+
32
+ const basicOptions: SelectOption[] = [
33
+ { value: '10', label: '10' },
34
+ { value: '25', label: '25' },
35
+ { value: '50', label: '50' },
36
+ { value: '100', label: '100' },
37
+ ];
38
+
39
+ export const CombinedInputGroupExample = () => {
40
+ const [text, setText] = useState('');
41
+ const [selectValue, setSelectValue] = useState('25');
42
+
43
+ return (
44
+ <Box>
45
+ <Typography variant="h6" sx={{ mb: 2 }}>
46
+ Grupo de entrada combinado
47
+ </Typography>
48
+ <InputGroup>
49
+ <Select
50
+ label="Registros"
51
+ options={basicOptions}
52
+ value={selectValue}
53
+ onChange={(val) => setSelectValue(val as string)}
54
+ />
55
+ <Input
56
+ label="Filtrar por nombre"
57
+ value={text}
58
+ onChange={(val) => setText(val as string)}
59
+ />
60
+ <Button variant="contained">Aplicar</Button>
61
+ </InputGroup>
62
+ </Box>
63
+ );
64
+ };
65
+ `;
66
+
67
+ export const DatePickerInputGroupDefinition = `
68
+ import { useState } from 'react';
69
+ import { Box, Typography } from '@mui/material';
70
+ import dayjs, { Dayjs } from 'dayjs';
71
+ import InputGroup from './InputGroup';
72
+ import { DatePicker } from '../DatePicker';
73
+ import { Button } from '../Button';
74
+
75
+ export const DatePickerInputGroupExample = () => {
76
+ const [selectedDate, setSelectedDate] = useState<Dayjs | null>(dayjs());
77
+
78
+ return (
79
+ <Box>
80
+ <Typography variant="h6" sx={{ mb: 2 }}>
81
+ Grupo de entrada con DatePicker
82
+ </Typography>
83
+ <InputGroup>
84
+ <DatePicker
85
+ label="Fecha de inicio"
86
+ selectedDate={selectedDate}
87
+ onDateChange={(date) => setSelectedDate(date)}
88
+ />
89
+ <Button variant="contained">Ver calendario</Button>
90
+ </InputGroup>
91
+ </Box>
92
+ );
93
+ };
94
+ `;
95
+
96
+ export const VerticalInputGroupDefinition = `
97
+ import { useState } from 'react';
98
+ import { Box } from '@mui/material';
99
+ import InputGroup from './InputGroup';
100
+ import { Input } from '../Input';
101
+
102
+ export const VerticalInputGroupExample = () => {
103
+ const [nombre, setNombre] = useState('');
104
+ const [email, setEmail] = useState('');
105
+
106
+ return (
107
+ <Box sx={{ width: 320 }}>
108
+ <InputGroup orientation="vertical">
109
+ <Input label="Nombre" value={nombre} onChange={(val) => setNombre(val as string)} />
110
+ <Input label="Email" value={email} onChange={(val) => setEmail(val as string)} />
111
+ </InputGroup>
112
+ </Box>
113
+ );
114
+ };
115
+ `;
116
+
117
+ export const CustomStylingInputGroupDefinition = `
118
+ import { useState } from 'react';
119
+ import { Box } from '@mui/material';
120
+ import InputGroup from './InputGroup';
121
+ import { Input } from '../Input';
122
+ import { Button } from '../Button';
123
+
124
+ export const CustomStylingInputGroupExample = () => {
125
+ const [q, setQ] = useState('');
126
+
127
+ return (
128
+ <Box sx={{ width: 500 }}>
129
+ <InputGroup
130
+ borderRadius={999}
131
+ sx={{
132
+ bgcolor: 'action.hover',
133
+ borderColor: 'primary.main',
134
+ }}
135
+ >
136
+ <Input label="Búsqueda avanzada" value={q} onChange={(val) => setQ(val as string)} />
137
+ <Button variant="contained" color="primary">Buscar</Button>
138
+ </InputGroup>
139
+ </Box>
140
+ );
141
+ };
142
+ `;
143
+
144
+ export const DisabledInputGroupDefinition = `
145
+ import { Box } from '@mui/material';
146
+ import InputGroup from './InputGroup';
147
+ import { Input } from '../Input';
148
+ import { Button } from '../Button';
149
+
150
+ export const DisabledInputGroupExample = () => (
151
+ <Box sx={{ width: 400 }}>
152
+ <InputGroup disabled>
153
+ <Input label="Búsqueda" value="" onChange={() => {}} disabled />
154
+ <Button variant="outlined" disabled>Buscar</Button>
155
+ </InputGroup>
156
+ </Box>
157
+ );
158
+ `;