siesa-ui-kit 1.0.2 → 1.0.4

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 (189) hide show
  1. package/README.md +115 -115
  2. package/bin/install.cjs +502 -502
  3. package/bin/prepare-publish.cjs +28 -28
  4. package/bin/restore-folders.cjs +28 -28
  5. package/claude/agents/siesa-ui-kit-specialist.md +2445 -0
  6. package/claude/prompts/component-template.md +121 -0
  7. package/claude/prompts/siesa-ui-kit.md +28 -0
  8. package/claude/settings.local.json +67 -2
  9. package/dist/components/Button/icons.d.ts +6 -5
  10. package/dist/components/Button/icons.d.ts.map +1 -1
  11. package/dist/components/DropdownItemCollapsible/DropdownItemCollapsible.d.ts.map +1 -1
  12. package/dist/components/DropdownItemCollapsible/DropdownItemCollapsible.types.d.ts +21 -0
  13. package/dist/components/DropdownItemCollapsible/DropdownItemCollapsible.types.d.ts.map +1 -1
  14. package/dist/components/NavigationRailCommercial/NavigationRailCommercial.d.ts +122 -0
  15. package/dist/components/NavigationRailCommercial/NavigationRailCommercial.d.ts.map +1 -0
  16. package/dist/components/NavigationRailCommercial/NavigationRailCommercial.types.d.ts +139 -0
  17. package/dist/components/NavigationRailCommercial/NavigationRailCommercial.types.d.ts.map +1 -0
  18. package/dist/components/NavigationRailCommercial/icons.d.ts +33 -0
  19. package/dist/components/NavigationRailCommercial/icons.d.ts.map +1 -0
  20. package/dist/components/NavigationRailCommercial/index.d.ts +4 -0
  21. package/dist/components/NavigationRailCommercial/index.d.ts.map +1 -0
  22. package/dist/components/NavigationRailItem/NavigationRailItem.d.ts.map +1 -1
  23. package/dist/components/NavigationRailItem/NavigationRailItem.types.d.ts +7 -0
  24. package/dist/components/NavigationRailItem/NavigationRailItem.types.d.ts.map +1 -1
  25. package/dist/components/NavigationRailTypes/NavigationRailTypes.d.ts.map +1 -1
  26. package/dist/components/NavigationRailTypes/NavigationRailTypes.types.d.ts +41 -0
  27. package/dist/components/NavigationRailTypes/NavigationRailTypes.types.d.ts.map +1 -1
  28. package/dist/components/NavigationRailTypes/icons.d.ts +15 -29
  29. package/dist/components/NavigationRailTypes/icons.d.ts.map +1 -1
  30. package/dist/components/Select/Select.d.ts.map +1 -1
  31. package/dist/components/Select/icons.d.ts +6 -2
  32. package/dist/components/Select/icons.d.ts.map +1 -1
  33. package/dist/index.d.ts +32 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/siesa-ui-kit.cjs +404 -190
  36. package/dist/siesa-ui-kit.cjs.map +1 -1
  37. package/dist/siesa-ui-kit.mjs +6590 -1506
  38. package/dist/siesa-ui-kit.mjs.map +1 -1
  39. package/dist/views/LayoutCommercial/LayoutCommercial.d.ts +48 -0
  40. package/dist/views/LayoutCommercial/LayoutCommercial.d.ts.map +1 -0
  41. package/dist/views/LayoutCommercial/LayoutCommercial.types.d.ts +49 -0
  42. package/dist/views/LayoutCommercial/LayoutCommercial.types.d.ts.map +1 -0
  43. package/dist/views/LayoutCommercial/index.d.ts +3 -0
  44. package/dist/views/LayoutCommercial/index.d.ts.map +1 -0
  45. package/docs/icons.md +12 -31
  46. package/package.json +111 -110
  47. package/src/components/Avatar/Avatar.stories.tsx +494 -494
  48. package/src/components/Button/Button.stories.tsx +950 -950
  49. package/src/components/Button/Button.tsx +337 -337
  50. package/src/components/Button/Button.types.ts +180 -180
  51. package/src/components/Button/icons.tsx +23 -62
  52. package/src/components/DescriptionList/DescriptionList.stories.tsx +250 -250
  53. package/src/components/Divider/Divider.stories.tsx +263 -263
  54. package/src/components/DropdownItemCollapsible/DropdownItemCollapsible.stories.tsx +317 -317
  55. package/src/components/DropdownItemCollapsible/DropdownItemCollapsible.tsx +307 -287
  56. package/src/components/DropdownItemCollapsible/DropdownItemCollapsible.types.ts +136 -111
  57. package/src/components/DropdownItemCollapsible/README.md +264 -264
  58. package/src/components/DropdownItemCollapsible/icons.tsx +57 -57
  59. package/src/components/DropdownItemCollapsible/index.ts +12 -12
  60. package/src/components/DropdownItemHeading/DropdownItemHeading.stories.tsx +386 -386
  61. package/src/components/DropdownItemHeading/DropdownItemHeading.tsx +216 -216
  62. package/src/components/DropdownItemHeading/DropdownItemHeading.types.ts +93 -93
  63. package/src/components/DropdownItemHeading/README.md +573 -573
  64. package/src/components/DropdownItemHeading/icons.tsx +125 -125
  65. package/src/components/DropdownItemHeading/index.ts +3 -3
  66. package/src/components/Input/Input.stories.tsx +583 -583
  67. package/src/components/LoginView/LoginView.stories.tsx +148 -148
  68. package/src/components/LoginView/LoginView.tsx +426 -426
  69. package/src/components/LoginView/LoginView.types.ts +52 -52
  70. package/src/components/LoginView/README.md +396 -396
  71. package/src/components/LoginView/icons.tsx +85 -85
  72. package/src/components/LoginView/index.ts +3 -3
  73. package/src/components/Navbar/Navbar.stories.tsx +810 -810
  74. package/src/components/Navbar/Navbar.tsx +755 -755
  75. package/src/components/Navbar/Navbar.types.ts +219 -219
  76. package/src/components/Navbar/README.md +279 -279
  77. package/src/components/Navbar/index.ts +8 -8
  78. package/src/components/NavigationRailCommercial/NavigationRailCommercial.stories.tsx +464 -0
  79. package/src/components/NavigationRailCommercial/NavigationRailCommercial.tsx +301 -0
  80. package/src/components/NavigationRailCommercial/NavigationRailCommercial.types.ts +162 -0
  81. package/src/components/NavigationRailCommercial/README.md +251 -0
  82. package/src/components/NavigationRailCommercial/icons.tsx +54 -0
  83. package/src/components/NavigationRailCommercial/index.ts +6 -0
  84. package/src/components/NavigationRailItem/NavigationRailItem.stories.tsx +667 -667
  85. package/src/components/NavigationRailItem/NavigationRailItem.tsx +314 -313
  86. package/src/components/NavigationRailItem/NavigationRailItem.types.ts +175 -167
  87. package/src/components/NavigationRailItem/README.md +476 -476
  88. package/src/components/NavigationRailItem/index.ts +2 -2
  89. package/src/components/NavigationRailPanel/NavigationRailPanel.stories.tsx +462 -462
  90. package/src/components/NavigationRailPanel/NavigationRailPanel.tsx +332 -332
  91. package/src/components/NavigationRailPanel/NavigationRailPanel.types.ts +178 -178
  92. package/src/components/NavigationRailPanel/README.md +461 -461
  93. package/src/components/NavigationRailPanel/index.ts +6 -6
  94. package/src/components/NavigationRailTypes/NavigationRailTypes.stories.tsx +682 -528
  95. package/src/components/NavigationRailTypes/NavigationRailTypes.tsx +363 -378
  96. package/src/components/NavigationRailTypes/NavigationRailTypes.types.ts +178 -130
  97. package/src/components/NavigationRailTypes/README.md +573 -573
  98. package/src/components/NavigationRailTypes/icons.tsx +76 -141
  99. package/src/components/NavigationRailTypes/index.ts +7 -7
  100. package/src/components/Notification/Notification.stories.tsx +513 -513
  101. package/src/components/Notification/Notification.tsx +145 -145
  102. package/src/components/Notification/Notification.types.ts +142 -142
  103. package/src/components/Notification/README.md +409 -409
  104. package/src/components/POSConvention/POSConvention.stories.tsx +235 -235
  105. package/src/components/POSConvention/POSConvention.tsx +129 -129
  106. package/src/components/POSConvention/POSConvention.types.ts +38 -38
  107. package/src/components/POSConvention/README.md +123 -123
  108. package/src/components/POSConvention/icons.tsx +45 -45
  109. package/src/components/POSConvention/index.ts +3 -3
  110. package/src/components/POSLocationButton/POSLocationButton.stories.tsx +531 -531
  111. package/src/components/POSLocationButton/POSLocationButton.tsx +247 -247
  112. package/src/components/POSLocationButton/POSLocationButton.types.ts +87 -87
  113. package/src/components/POSLocationButton/README.md +253 -253
  114. package/src/components/POSLocationButton/icons.tsx +120 -120
  115. package/src/components/POSLocationButton/index.ts +14 -14
  116. package/src/components/POSNumberButton/POSNumberButton.stories.tsx +415 -415
  117. package/src/components/POSNumberButton/POSNumberButton.tsx +179 -179
  118. package/src/components/POSNumberButton/POSNumberButton.types.ts +51 -51
  119. package/src/components/POSNumberButton/README.md +321 -321
  120. package/src/components/POSNumberButton/index.ts +3 -3
  121. package/src/components/POSProductButton/POSProductButton.stories.tsx +318 -318
  122. package/src/components/POSProductCard/POSProductCard.stories.tsx +642 -642
  123. package/src/components/POSProductCard/POSProductCard.tsx +208 -208
  124. package/src/components/POSProductCard/POSProductCard.types.ts +76 -76
  125. package/src/components/POSProductCard/README.md +179 -179
  126. package/src/components/POSProductCard/icons.tsx +26 -26
  127. package/src/components/POSProductCard/index.ts +2 -2
  128. package/src/components/POSProductSidebarItems/POSProductSidebarItems.stories.tsx +753 -753
  129. package/src/components/POSProductSidebarItems/POSProductSidebarItems.tsx +332 -332
  130. package/src/components/POSProductSidebarItems/POSProductSidebarItems.types.ts +119 -119
  131. package/src/components/POSProductSidebarItems/README.md +198 -198
  132. package/src/components/POSProductSidebarItems/icons.tsx +21 -21
  133. package/src/components/POSProductSidebarItems/index.ts +3 -3
  134. package/src/components/POSTable/POSTable.stories.tsx +737 -737
  135. package/src/components/POSTable/POSTable.tsx +401 -401
  136. package/src/components/POSTable/README.md +286 -286
  137. package/src/components/Quantity/Quantity.stories.tsx +457 -457
  138. package/src/components/Radio/Radio.stories.tsx +523 -523
  139. package/src/components/Radio/Radio.tsx +1 -1
  140. package/src/components/Select/Select.stories.tsx +32 -0
  141. package/src/components/Select/Select.tsx +457 -454
  142. package/src/components/Select/icons.tsx +16 -41
  143. package/src/components/SignUpView/SignUpView.stories.tsx +129 -129
  144. package/src/components/SignUpView/SignUpView.tsx +503 -503
  145. package/src/components/SignUpView/SignUpView.types.ts +58 -58
  146. package/src/components/SignUpView/icons.tsx +71 -71
  147. package/src/components/SignUpView/index.ts +3 -3
  148. package/src/components/Switch/README.md +112 -112
  149. package/src/components/Switch/Switch.stories.tsx +550 -550
  150. package/src/components/Switch/Switch.tsx +246 -246
  151. package/src/components/Switch/Switch.types.ts +67 -67
  152. package/src/components/Table/Table.stories.tsx +805 -805
  153. package/src/components/Tabs/README.md +201 -201
  154. package/src/components/Tabs/Tabs.stories.tsx +580 -580
  155. package/src/components/Tabs/Tabs.tsx +356 -356
  156. package/src/components/Tabs/Tabs.types.ts +127 -127
  157. package/src/components/Tabs/icons.tsx +129 -129
  158. package/src/components/Tabs/index.ts +11 -11
  159. package/src/components/Textarea/Textarea.stories.tsx +535 -535
  160. package/src/index.ts +133 -102
  161. package/src/views/LayoutCommercial/LayoutCommercial.stories.tsx +374 -0
  162. package/src/views/LayoutCommercial/LayoutCommercial.tsx +125 -0
  163. package/src/views/LayoutCommercial/LayoutCommercial.types.ts +54 -0
  164. package/src/views/LayoutCommercial/README.md +286 -0
  165. package/src/views/LayoutCommercial/index.ts +2 -0
  166. package/src/views/ListView/ListView.stories.tsx +329 -329
  167. package/src/views/ListView/ListView.tsx +570 -570
  168. package/src/views/ListView/ListView.types.ts +211 -211
  169. package/src/views/ListView/icons.tsx +282 -282
  170. package/src/views/ListView/index.ts +11 -11
  171. package/src/views/LoginView/LoginView.tsx +426 -426
  172. package/src/views/ProductsView/ProductsView.stories.tsx +344 -344
  173. package/src/views/ProductsView/ProductsView.tsx +480 -480
  174. package/src/views/ProductsView/ProductsView.types.ts +238 -238
  175. package/src/views/ProductsView/README.md +312 -312
  176. package/src/views/ProductsView/icons.tsx +38 -38
  177. package/src/views/ProductsView/index.ts +8 -8
  178. package/src/views/RecoverPasswordView/RecoverPasswordView.tsx +376 -376
  179. package/src/views/SignUpView/SignUpView.tsx +503 -503
  180. package/src/views/TableLayoutView/README.md +268 -268
  181. package/src/views/TableLayoutView/TableLayoutView.stories.tsx +235 -235
  182. package/src/views/TableLayoutView/TableLayoutView.tsx +461 -461
  183. package/src/views/TableLayoutView/TableLayoutView.types.ts +209 -209
  184. package/src/views/TableLayoutView/icons.tsx +113 -113
  185. package/src/views/TableLayoutView/index.ts +6 -6
  186. package/storybook/main.ts +19 -19
  187. package/storybook/preview.tsx +84 -84
  188. package/storybook/vitest.setup.ts +6 -6
  189. package/tailwind.config.js +128 -128
@@ -1,287 +1,307 @@
1
- import React, { useState } from 'react';
2
- import type {
3
- DropdownItemCollapsibleProps,
4
- DropdownItemCollapsibleChildProps,
5
- } from './DropdownItemCollapsible.types';
6
- import { ChevronDownIcon } from './icons';
7
-
8
- /**
9
- * Componente DropdownItemCollapsible del sistema de diseño Siesa
10
- *
11
- * Item colapsable para uso dentro de Dropdowns que permite agrupar
12
- * items relacionados en secciones expandibles.
13
- *
14
- * **Características:**
15
- * - Soporte completo para expandir/colapsar
16
- * - Iconos personalizables en header y children
17
- * - Items anidados indentados automáticamente
18
- * - Dark mode completo con inversión de colores
19
- * - Estados: default, hover, active, disabled
20
- * - Focus rings adaptativos
21
- * - Animación suave de rotación del chevron
22
- *
23
- * **Estados visuales:**
24
- * - `collapsed`: Muestra solo el header con chevron apuntando down
25
- * - `expanded`: Muestra header y lista de items anidados
26
- * - `disabled`: Opacidad 50%, sin interacción
27
- * - `hover`: Fondo de hover sutil, color primario del icono
28
- * - `active`: Item anidado seleccionado con fondo custom-primary
29
- *
30
- * **Espaciado según Figma:**
31
- * - Header padding: px-4 py-2 (16px horizontal, 8px vertical)
32
- * - Item anidado padding: pl-6 pr-4 py-2 (24px left, 16px right, 8px vertical)
33
- * - Gap entre elementos: gap-3 (12px)
34
- * - Gap interno (icon + text): gap-3 (12px)
35
- * - Indent entre niveles: 8px adicional por nivel
36
- * - Divisor: borde top de 1px con spacing-0.5 (2px) arriba
37
- * - Sección heading: pt-3 pb-1 px-0 (12px top, 4px bottom, sin horizontal)
38
- *
39
- * **Tipografía:**
40
- * - Header: Paragraph/Small (14px, Regular, line-height 20px) - text-content-primary
41
- * - Items anidados: Paragraph/Small (14px, Regular, line-height 20px) - text-content-primary
42
- * - Heading: Paragraph/Tiny (12px, Regular, line-height 16px) - text-content-tertiary
43
- *
44
- * **Colores (Light Mode):**
45
- * - Header text: content-primary (#18181b)
46
- * - Header icon: content-secondary (#a1a1aa)
47
- * - Header hover: bg-background-custom-primary (#dbeefe)
48
- * - Header text hover: content-custom-primary (#0e79fd)
49
- * - Item text: content-primary (#18181b)
50
- * - Item hover: bg-transparent (sin fondo)
51
- * - Divider: border-border-primary (#e4e4e7)
52
- * - Heading text: content-tertiary (#71717a)
53
- *
54
- * **Colores (Dark Mode):**
55
- * - Header text: content-primary/dark (#fafafa)
56
- * - Header icon: content-secondary/dark (#a1a1aa)
57
- * - Header hover: bg-background-custom-primary/dark (#0e5ab0)
58
- * - Header text hover: content-custom-primary/dark (#bfe2fe)
59
- * - Item text: content-primary/dark (#fafafa)
60
- * - Divider: border-border-primary/dark (#3f3f46)
61
- * - Heading text: content-tertiary/dark (#a1a1aa)
62
- *
63
- * **Border radius:**
64
- * - Todos los items: rounded-lg (8px)
65
- *
66
- * **Sombras:**
67
- * - Ninguna (usado dentro de dropdowns)
68
- *
69
- * @see docs/colors.md - Sistema de colores
70
- * @see docs/typography.md - Sistema tipográfico
71
- * @see docs/spacing.md - Sistema de espaciado
72
- * @see https://www.figma.com/design/5XNqf2YTxvwemxwo1LMQ6j/Siesa-UI-Kit?node-id=6135-34374
73
- *
74
- * @example
75
- * ```tsx
76
- * // Item colapsable simple
77
- * <DropdownItemCollapsible
78
- * label="Users"
79
- * icon={<UserIcon />}
80
- * children={[
81
- * { label: "Active Users", icon: <CheckIcon /> },
82
- * { label: "Inactive Users", icon: <CloseIcon /> },
83
- * ]}
84
- * />
85
- *
86
- * // Con encabezado de sección
87
- * <DropdownItemCollapsible
88
- * label="Customers"
89
- * icon={<BuildingIcon />}
90
- * showHeading={true}
91
- * headingLabel="SECTION 1"
92
- * children={[...]}
93
- * />
94
- *
95
- * // Item no colapsable (actúa como botón normal)
96
- * <DropdownItemCollapsible
97
- * label="Single Item"
98
- * icon={<StarIcon />}
99
- * isCollapsible={false}
100
- * onClick={() => console.log('clicked')}
101
- * />
102
- * ```
103
- */
104
- export const DropdownItemCollapsible: React.FC<DropdownItemCollapsibleProps> = ({
105
- label,
106
- icon,
107
- children = [],
108
- defaultOpen = false,
109
- disabled = false,
110
- onOpenChange,
111
- onClick,
112
- isCollapsible = children.length > 0,
113
- showHeading = false,
114
- headingLabel,
115
- showDivider = true,
116
- className = '',
117
- }) => {
118
- const [isOpen, setIsOpen] = useState(defaultOpen);
119
-
120
- const handleToggle = () => {
121
- if (disabled || !isCollapsible) return;
122
-
123
- const newOpen = !isOpen;
124
- setIsOpen(newOpen);
125
- onOpenChange?.(newOpen);
126
- };
127
-
128
- const handleHeaderClick = (e: React.MouseEvent<HTMLButtonElement>) => {
129
- if (disabled) return;
130
-
131
- if (isCollapsible) {
132
- handleToggle();
133
- } else {
134
- onClick?.(e);
135
- }
136
- };
137
-
138
- const handleChildClick = (child: DropdownItemCollapsibleChildProps) => (
139
- e: React.MouseEvent<HTMLDivElement>,
140
- ) => {
141
- if (child.disabled) return;
142
- child.onClick?.(e);
143
- };
144
-
145
- return (
146
- <div className={`flex flex-col gap-0.5 w-full ${className}`}>
147
- {/* Section Heading */}
148
- {showHeading && headingLabel && (
149
- <div className="flex flex-col gap-0 items-start pb-1 pt-3 px-0 w-full">
150
- <p className="font-['Inter:Regular',sans-serif] font-normal leading-4 not-italic text-xs text-content-tertiary dark:text-content-tertiary w-full">
151
- {headingLabel}
152
- </p>
153
- </div>
154
- )}
155
-
156
- {/* Header Button */}
157
- <button
158
- onClick={handleHeaderClick}
159
- disabled={disabled}
160
- className={[
161
- // Base
162
- 'flex items-center gap-3 px-4 py-2 w-full',
163
- 'rounded-lg cursor-pointer',
164
- 'transition-all duration-150',
165
-
166
- // Colores y estados (Light Mode)
167
- !disabled && 'text-content-primary',
168
- !disabled && 'hover:bg-primary-custom-100',
169
- !disabled && 'hover:text-primary-custom-600',
170
-
171
- // Dark Mode
172
- !disabled && 'dark:text-content-primary',
173
- !disabled && 'dark:hover:bg-dark-bg-custom',
174
- !disabled && 'dark:hover:text-dark-content-custom',
175
-
176
- // Focus ring
177
- !disabled && 'focus:outline-none',
178
- !disabled && 'focus:ring-2',
179
- !disabled && 'focus:ring-offset-2',
180
- !disabled && 'focus:ring-primary-custom-400',
181
- !disabled && 'focus:ring-offset-bg-primary',
182
- !disabled && 'dark:focus:ring-offset-dark-bg-primary',
183
-
184
- // Disabled
185
- disabled && 'opacity-50',
186
- disabled && 'cursor-not-allowed',
187
- ]
188
- .filter(Boolean)
189
- .join(' ')}
190
- aria-expanded={isOpen && isCollapsible}
191
- aria-disabled={disabled}
192
- >
193
- {/* Icon Wrapper */}
194
- {icon && (
195
- <div className="flex items-center justify-center w-4 h-4 shrink-0 text-content-secondary dark:text-content-secondary">
196
- {icon}
197
- </div>
198
- )}
199
-
200
- {/* Content Wrapper */}
201
- <div className="flex flex-1 flex-col items-start justify-center gap-0.5">
202
- <p className="font-['Inter:Regular',sans-serif] font-normal leading-5 not-italic text-sm text-left">
203
- {label}
204
- </p>
205
- </div>
206
-
207
- {/* Chevron (solo visible si es colapsable) */}
208
- {isCollapsible && (
209
- <div
210
- className={[
211
- 'flex items-center justify-center w-4 h-4 shrink-0',
212
- 'text-content-secondary dark:text-content-secondary',
213
- 'transition-transform duration-200',
214
- isOpen ? 'rotate-180' : 'rotate-0',
215
- ].join(' ')}
216
- >
217
- <ChevronDownIcon className="w-4 h-4" />
218
- </div>
219
- )}
220
- </button>
221
-
222
- {/* Divider */}
223
- {showDivider && <div className="w-full h-px bg-border-primary dark:bg-dark-border-primary" />}
224
-
225
- {/* Children Container (expanded) */}
226
- {isOpen && isCollapsible && children.length > 0 && (
227
- <div className="flex flex-col gap-0.5 w-full py-2 px-0">
228
- {children.map((child, index) => (
229
- <div
230
- key={index}
231
- onClick={handleChildClick(child)}
232
- className={[
233
- // Base
234
- 'flex gap-3 items-center pl-6 pr-4 py-2 w-full',
235
- 'rounded-lg cursor-pointer',
236
- 'transition-all duration-150',
237
-
238
- // Colores y estados (Light Mode)
239
- !child.disabled && 'text-content-primary',
240
- !child.disabled && 'hover:bg-primary-custom-100',
241
- !child.disabled && 'hover:text-primary-custom-600',
242
-
243
- // Dark Mode
244
- !child.disabled && 'dark:text-content-primary',
245
- !child.disabled && 'dark:hover:bg-dark-bg-custom',
246
- !child.disabled && 'dark:hover:text-dark-content-custom',
247
-
248
- // Focus ring
249
- !child.disabled && 'focus:outline-none',
250
- !child.disabled && 'focus:ring-2',
251
- !child.disabled && 'focus:ring-offset-2',
252
- !child.disabled && 'focus:ring-primary-custom-400',
253
- !child.disabled && 'focus:ring-offset-bg-primary',
254
- !child.disabled && 'dark:focus:ring-offset-dark-bg-primary',
255
-
256
- // Disabled
257
- child.disabled && 'opacity-50',
258
- child.disabled && 'cursor-not-allowed',
259
-
260
- // Custom classes
261
- child.className,
262
- ]
263
- .filter(Boolean)
264
- .join(' ')}
265
- >
266
- {/* Child Icon Wrapper */}
267
- {child.icon && (
268
- <div className="flex items-center justify-center w-4 h-4 shrink-0 text-content-secondary dark:text-content-secondary">
269
- {child.icon}
270
- </div>
271
- )}
272
-
273
- {/* Child Content Wrapper */}
274
- <div className="flex flex-1 flex-col items-start justify-center gap-0.5">
275
- <p className="font-['Inter:Regular',sans-serif] font-normal leading-5 not-italic text-sm text-left">
276
- {child.label}
277
- </p>
278
- </div>
279
- </div>
280
- ))}
281
- </div>
282
- )}
283
- </div>
284
- );
285
- };
286
-
287
- export default DropdownItemCollapsible;
1
+ import React, { useState } from 'react';
2
+ import type {
3
+ DropdownItemCollapsibleProps,
4
+ DropdownItemCollapsibleChildProps,
5
+ } from './DropdownItemCollapsible.types';
6
+ import { ChevronDownIcon } from './icons';
7
+ import { Badge } from '../Badge/Badge';
8
+
9
+ /**
10
+ * Componente DropdownItemCollapsible del sistema de diseño Siesa
11
+ *
12
+ * Item colapsable para uso dentro de Dropdowns que permite agrupar
13
+ * items relacionados en secciones expandibles.
14
+ *
15
+ * **Características:**
16
+ * - Soporte completo para expandir/colapsar
17
+ * - Iconos personalizables en header y children
18
+ * - Items anidados indentados automáticamente
19
+ * - Dark mode completo con inversión de colores
20
+ * - Estados: default, hover, active, disabled
21
+ * - Focus rings adaptativos
22
+ * - Animación suave de rotación del chevron
23
+ *
24
+ * **Estados visuales:**
25
+ * - `collapsed`: Muestra solo el header con chevron apuntando down
26
+ * - `expanded`: Muestra header y lista de items anidados
27
+ * - `disabled`: Opacidad 50%, sin interacción
28
+ * - `hover`: Fondo de hover sutil, color primario del icono
29
+ * - `active`: Item anidado seleccionado con fondo custom-primary
30
+ *
31
+ * **Espaciado según Figma:**
32
+ * - Header padding: px-4 py-2 (16px horizontal, 8px vertical)
33
+ * - Item anidado padding: pl-6 pr-4 py-2 (24px left, 16px right, 8px vertical)
34
+ * - Gap entre elementos: gap-3 (12px)
35
+ * - Gap interno (icon + text): gap-3 (12px)
36
+ * - Indent entre niveles: 8px adicional por nivel
37
+ * - Divisor: borde top de 1px con spacing-0.5 (2px) arriba
38
+ * - Sección heading: pt-3 pb-1 px-0 (12px top, 4px bottom, sin horizontal)
39
+ *
40
+ * **Tipografía:**
41
+ * - Header: Paragraph/Small (14px, Regular, line-height 20px) - text-content-primary
42
+ * - Items anidados: Paragraph/Small (14px, Regular, line-height 20px) - text-content-primary
43
+ * - Heading: Paragraph/Tiny (12px, Regular, line-height 16px) - text-content-tertiary
44
+ *
45
+ * **Colores (Light Mode):**
46
+ * - Header text: content-primary (#18181b)
47
+ * - Header icon: content-secondary (#a1a1aa)
48
+ * - Header hover: bg-background-custom-primary (#dbeefe)
49
+ * - Header text hover: content-custom-primary (#0e79fd)
50
+ * - Item text: content-primary (#18181b)
51
+ * - Item hover: bg-transparent (sin fondo)
52
+ * - Divider: border-border-primary (#e4e4e7)
53
+ * - Heading text: content-tertiary (#71717a)
54
+ *
55
+ * **Colores (Dark Mode):**
56
+ * - Header text: content-primary/dark (#fafafa)
57
+ * - Header icon: content-secondary/dark (#a1a1aa)
58
+ * - Header hover: bg-background-custom-primary/dark (#0e5ab0)
59
+ * - Header text hover: content-custom-primary/dark (#bfe2fe)
60
+ * - Item text: content-primary/dark (#fafafa)
61
+ * - Divider: border-border-primary/dark (#3f3f46)
62
+ * - Heading text: content-tertiary/dark (#a1a1aa)
63
+ *
64
+ * **Border radius:**
65
+ * - Todos los items: rounded-lg (8px)
66
+ *
67
+ * **Sombras:**
68
+ * - Ninguna (usado dentro de dropdowns)
69
+ *
70
+ * @see docs/colors.md - Sistema de colores
71
+ * @see docs/typography.md - Sistema tipográfico
72
+ * @see docs/spacing.md - Sistema de espaciado
73
+ * @see https://www.figma.com/design/5XNqf2YTxvwemxwo1LMQ6j/Siesa-UI-Kit?node-id=6135-34374
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * // Item colapsable simple
78
+ * <DropdownItemCollapsible
79
+ * label="Users"
80
+ * icon={<UserIcon />}
81
+ * children={[
82
+ * { label: "Active Users", icon: <CheckIcon /> },
83
+ * { label: "Inactive Users", icon: <CloseIcon /> },
84
+ * ]}
85
+ * />
86
+ *
87
+ * // Con encabezado de sección
88
+ * <DropdownItemCollapsible
89
+ * label="Customers"
90
+ * icon={<BuildingIcon />}
91
+ * showHeading={true}
92
+ * headingLabel="SECTION 1"
93
+ * children={[...]}
94
+ * />
95
+ *
96
+ * // Item no colapsable (actúa como botón normal)
97
+ * <DropdownItemCollapsible
98
+ * label="Single Item"
99
+ * icon={<StarIcon />}
100
+ * isCollapsible={false}
101
+ * onClick={() => console.log('clicked')}
102
+ * />
103
+ * ```
104
+ */
105
+ export const DropdownItemCollapsible: React.FC<DropdownItemCollapsibleProps> = ({
106
+ label,
107
+ icon,
108
+ children = [],
109
+ defaultOpen = false,
110
+ disabled = false,
111
+ onOpenChange,
112
+ onClick,
113
+ isCollapsible = children.length > 0,
114
+ showHeading = false,
115
+ headingLabel,
116
+ showDivider = true,
117
+ selected = false,
118
+ badge = false,
119
+ badgeCount,
120
+ badgeColor = 'red',
121
+ className = '',
122
+ }) => {
123
+ const [isOpen, setIsOpen] = useState(defaultOpen);
124
+
125
+ const handleToggle = () => {
126
+ if (disabled || !isCollapsible) return;
127
+
128
+ const newOpen = !isOpen;
129
+ setIsOpen(newOpen);
130
+ onOpenChange?.(newOpen);
131
+ };
132
+
133
+ const handleHeaderClick = (e: React.MouseEvent<HTMLButtonElement>) => {
134
+ if (disabled) return;
135
+
136
+ if (isCollapsible) {
137
+ handleToggle();
138
+ } else {
139
+ onClick?.(e);
140
+ }
141
+ };
142
+
143
+ const handleChildClick = (child: DropdownItemCollapsibleChildProps) => (
144
+ e: React.MouseEvent<HTMLDivElement>,
145
+ ) => {
146
+ if (child.disabled) return;
147
+ child.onClick?.(e);
148
+ };
149
+
150
+ return (
151
+ <div className={`flex flex-col gap-0.5 w-full ${className}`}>
152
+ {/* Section Heading */}
153
+ {showHeading && headingLabel && (
154
+ <div className="flex flex-col gap-0 items-start pb-1 pt-3 px-0 w-full">
155
+ <p className="font-['Inter:Regular',sans-serif] font-normal leading-4 not-italic text-xs text-content-tertiary dark:text-content-tertiary w-full">
156
+ {headingLabel}
157
+ </p>
158
+ </div>
159
+ )}
160
+
161
+ {/* Header Button */}
162
+ <button
163
+ onClick={handleHeaderClick}
164
+ disabled={disabled}
165
+ className={[
166
+ // Base
167
+ 'flex items-center gap-3 px-4 py-2 w-full',
168
+ 'rounded-lg cursor-pointer',
169
+ 'transition-all duration-150',
170
+
171
+ // Colores y estados (Light Mode)
172
+ selected && !disabled && 'bg-primary-custom-100 text-primary-custom-600',
173
+ !selected && !disabled && 'text-content-primary',
174
+ !disabled && 'hover:bg-primary-custom-100',
175
+ !disabled && 'hover:text-primary-custom-600',
176
+
177
+ // Dark Mode
178
+ selected && !disabled && 'dark:bg-dark-bg-custom dark:text-dark-content-custom',
179
+ !selected && !disabled && 'dark:text-content-primary',
180
+ !disabled && 'dark:hover:bg-dark-bg-custom',
181
+ !disabled && 'dark:hover:text-dark-content-custom',
182
+
183
+ // Focus ring
184
+ !disabled && 'focus:outline-none',
185
+ !disabled && 'focus:ring-2',
186
+ !disabled && 'focus:ring-offset-2',
187
+ !disabled && 'focus:ring-primary-custom-400',
188
+ !disabled && 'focus:ring-offset-bg-primary',
189
+ !disabled && 'dark:focus:ring-offset-dark-bg-primary',
190
+
191
+ // Disabled
192
+ disabled && 'opacity-50',
193
+ disabled && 'cursor-not-allowed',
194
+ ]
195
+ .filter(Boolean)
196
+ .join(' ')}
197
+ aria-expanded={isOpen && isCollapsible}
198
+ aria-disabled={disabled}
199
+ >
200
+ {/* Icon Wrapper */}
201
+ {icon && (
202
+ <div className="flex items-center justify-center w-4 h-4 shrink-0 text-content-secondary dark:text-content-secondary">
203
+ {icon}
204
+ </div>
205
+ )}
206
+
207
+ {/* Content Wrapper */}
208
+ <div className="flex flex-1 flex-col items-start justify-center gap-0.5">
209
+ <p className="font-['Inter:Regular',sans-serif] font-normal leading-5 not-italic text-sm text-left">
210
+ {label}
211
+ </p>
212
+ </div>
213
+
214
+ {/* Badge */}
215
+ {(badge || badgeCount) && (
216
+ <div className="flex items-center justify-center shrink-0">
217
+ {badgeCount ? (
218
+ <div className="flex items-center justify-center px-1.5 py-0.5 rounded-full bg-red-500 dark:bg-red-600 text-white text-xs font-bold min-w-6 h-6">
219
+ {badgeCount > 99 ? '99+' : badgeCount}
220
+ </div>
221
+ ) : (
222
+ <div className="w-2 h-2 rounded-full bg-red-500 dark:bg-red-600 shrink-0" />
223
+ )}
224
+ </div>
225
+ )}
226
+
227
+ {/* Chevron (solo visible si es colapsable) */}
228
+ {isCollapsible && (
229
+ <div
230
+ className={[
231
+ 'flex items-center justify-center w-4 h-4 shrink-0',
232
+ 'text-content-secondary dark:text-content-secondary',
233
+ 'transition-transform duration-200',
234
+ isOpen ? 'rotate-180' : 'rotate-0',
235
+ ].join(' ')}
236
+ >
237
+ <ChevronDownIcon className="w-4 h-4" />
238
+ </div>
239
+ )}
240
+ </button>
241
+
242
+ {/* Divider */}
243
+ {showDivider && <div className="w-full h-px bg-border-primary dark:bg-dark-border-primary" />}
244
+
245
+ {/* Children Container (expanded) */}
246
+ {isOpen && isCollapsible && children.length > 0 && (
247
+ <div className="flex flex-col gap-0.5 w-full py-2 px-0">
248
+ {children.map((child, index) => (
249
+ <div
250
+ key={index}
251
+ onClick={handleChildClick(child)}
252
+ className={[
253
+ // Base
254
+ 'flex gap-3 items-center pl-6 pr-4 py-2 w-full',
255
+ 'rounded-lg cursor-pointer',
256
+ 'transition-all duration-150',
257
+
258
+ // Colores y estados (Light Mode)
259
+ !child.disabled && 'text-content-primary',
260
+ !child.disabled && 'hover:bg-primary-custom-100',
261
+ !child.disabled && 'hover:text-primary-custom-600',
262
+
263
+ // Dark Mode
264
+ !child.disabled && 'dark:text-content-primary',
265
+ !child.disabled && 'dark:hover:bg-dark-bg-custom',
266
+ !child.disabled && 'dark:hover:text-dark-content-custom',
267
+
268
+ // Focus ring
269
+ !child.disabled && 'focus:outline-none',
270
+ !child.disabled && 'focus:ring-2',
271
+ !child.disabled && 'focus:ring-offset-2',
272
+ !child.disabled && 'focus:ring-primary-custom-400',
273
+ !child.disabled && 'focus:ring-offset-bg-primary',
274
+ !child.disabled && 'dark:focus:ring-offset-dark-bg-primary',
275
+
276
+ // Disabled
277
+ child.disabled && 'opacity-50',
278
+ child.disabled && 'cursor-not-allowed',
279
+
280
+ // Custom classes
281
+ child.className,
282
+ ]
283
+ .filter(Boolean)
284
+ .join(' ')}
285
+ >
286
+ {/* Child Icon Wrapper */}
287
+ {child.icon && (
288
+ <div className="flex items-center justify-center w-4 h-4 shrink-0 text-content-secondary dark:text-content-secondary">
289
+ {child.icon}
290
+ </div>
291
+ )}
292
+
293
+ {/* Child Content Wrapper */}
294
+ <div className="flex flex-1 flex-col items-start justify-center gap-0.5">
295
+ <p className="font-['Inter:Regular',sans-serif] font-normal leading-5 not-italic text-sm text-left">
296
+ {child.label}
297
+ </p>
298
+ </div>
299
+ </div>
300
+ ))}
301
+ </div>
302
+ )}
303
+ </div>
304
+ );
305
+ };
306
+
307
+ export default DropdownItemCollapsible;