ywana-core8 0.1.102 → 0.2.1
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.
- package/dist/index.css +4941 -324
- package/dist/index.js +42338 -0
- package/dist/index.js.map +1 -0
- package/dist/index.modern.js +37458 -31678
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +39634 -34010
- package/dist/index.umd.js.map +1 -1
- package/package.json +26 -29
- package/src/Test.stories.jsx +28 -0
- package/src/desktop/Desktop.stories.jsx +110 -0
- package/src/desktop/WindowContext.js +135 -0
- package/src/desktop/WindowManager.js +355 -0
- package/src/desktop/desktop.css +55 -4
- package/src/desktop/desktop.js +312 -6
- package/src/desktop/index.js +7 -0
- package/src/desktop/window.css +229 -36
- package/src/desktop/window.js +254 -20
- package/src/desktop.backup/desktop.css +6 -0
- package/src/desktop.backup/desktop.js +13 -0
- package/src/desktop.backup/window.css +58 -0
- package/src/desktop.backup/window.js +27 -0
- package/src/html/Accordion.stories.jsx +178 -0
- package/src/html/Button.stories.jsx +175 -0
- package/src/html/Checkbox.stories.jsx +131 -0
- package/src/html/Chip.stories.jsx +189 -0
- package/src/html/Color.stories.jsx +234 -0
- package/src/html/Form.stories.jsx +271 -0
- package/src/html/Icon.stories.jsx +233 -0
- package/src/html/Progress.stories.jsx +247 -0
- package/src/html/Radio.stories.jsx +289 -0
- package/src/html/StyleTest.stories.jsx +81 -0
- package/src/html/Switch.stories.jsx +329 -0
- package/src/html/Tab.stories.jsx +239 -0
- package/src/html/Table.stories.jsx +188 -0
- package/src/html/Table2.stories.jsx +238 -0
- package/src/html/TextField2.stories.jsx +337 -0
- package/src/html/Tree.stories.jsx +285 -0
- package/src/html/accordion.example.js +0 -74
- package/src/html/accordion.js +1 -6
- package/src/html/button.js +2 -13
- package/src/html/checkbox.js +1 -9
- package/src/html/chip.js +2 -19
- package/src/html/color.js +1 -14
- package/src/html/form.js +4 -15
- package/src/html/header2.js +1 -12
- package/src/html/icon.js +1 -7
- package/src/html/index.js +1 -1
- package/src/html/list.js +1 -19
- package/src/html/menu.js +9 -5
- package/src/html/progress.js +5 -53
- package/src/html/property.js +6 -22
- package/src/html/radio.js +2 -16
- package/src/html/section.js +1 -6
- package/src/html/selector.js +2 -19
- package/src/html/switch.css +134 -100
- package/src/html/switch.example.js +46 -36
- package/src/html/switch.js +43 -192
- package/src/html/tab.js +3 -24
- package/src/html/text.js +1 -12
- package/src/html/textfield2.js +5 -42
- package/src/html/thumbnail.js +1 -12
- package/src/html/tokenfield.js +2 -21
- package/src/html/tree.js +3 -35
- package/src/index.js +1 -0
- package/__previewjs__/Wrapper.tsx +0 -14
- package/build-doc.sh +0 -10
- package/db/db.json +0 -89
- package/db/routes.json +0 -0
- package/dist/index.cjs +0 -36722
- package/dist/index.cjs.map +0 -1
- package/dist/index.css.map +0 -1
- package/doc/README.md +0 -196
- package/doc/evalulations/ACCORDION_EVALUATION.md +0 -583
- package/doc/evalulations/CHECKBOX_EVALUATION.md +0 -273
- package/doc/evalulations/CHIP_EVALUATION.md +0 -542
- package/doc/evalulations/COLOR_EVALUATION.md +0 -524
- package/doc/evalulations/COMPONENTS_EVALUATION.md +0 -477
- package/doc/evalulations/FORM_EVALUATION.md +0 -459
- package/doc/evalulations/HEADER_EVALUATION.md +0 -436
- package/doc/evalulations/ICON_EVALUATION.md +0 -254
- package/doc/evalulations/LIST_EVALUATION.md +0 -574
- package/doc/evalulations/PROGRESS_EVALUATION.md +0 -450
- package/doc/evalulations/RADIO_EVALUATION.md +0 -439
- package/doc/evalulations/RADIO_VISUAL_FIX.md +0 -183
- package/doc/evalulations/SECTION_IMPROVEMENTS.md +0 -153
- package/doc/evalulations/SWITCH_EVALUATION.md +0 -335
- package/doc/evalulations/SWITCH_VISUAL_FIX.md +0 -232
- package/doc/evalulations/TAB_EVALUATION.md +0 -626
- package/doc/evalulations/TEXTFIELD_EVALUATION.md +0 -747
- package/doc/evalulations/TOOLTIP_FIX.md +0 -157
- package/doc/evalulations/TREE_EVALUATION.md +0 -708
- package/doc/index.html +0 -0
- package/doc/package-lock.json +0 -17298
- package/doc/package.json +0 -34
- package/doc/public/index.html +0 -24
- package/doc/scripts/generate-examples.js +0 -129
- package/doc/src/App.css +0 -171
- package/doc/src/App.js +0 -114
- package/doc/src/components/ExamplePage.js +0 -129
- package/doc/src/components/WelcomePage.js +0 -84
- package/doc/src/index.css +0 -246
- package/doc/src/index.js +0 -17
- package/doc/src/theme.css +0 -256
- package/jest.config.js +0 -24
- package/preview.config.js +0 -38
- package/publish.sh +0 -6
- package/src/desktop/dektop.test.js +0 -11
- package/src/domain/CollectionAPI.test.js +0 -19
- package/src/domain/ContentEditor.test.js +0 -52
- package/src/domain2/CollectionAPI.test.js +0 -19
- package/src/domain2/CollectionContext.test.js +0 -71
- package/src/domain2/CollectionPage.test.js +0 -112
- package/src/domain2/DynamicForm.test.js +0 -47
- package/src/html/accordion.test.js +0 -37
- package/src/html/accordion.unit.test.js +0 -334
- package/src/html/button.example.new.js +0 -416
- package/src/html/button.test.js +0 -422
- package/src/html/checkbox.test.js +0 -285
- package/src/html/chip.test.js +0 -425
- package/src/html/color.example.js.backup +0 -527
- package/src/html/color.test.js +0 -377
- package/src/html/components.example.js.backup +0 -492
- package/src/html/components_enhanced.test.js +0 -581
- package/src/html/form.example.js.backup +0 -385
- package/src/html/form.test.js +0 -369
- package/src/html/header2.example.js.backup +0 -411
- package/src/html/header2.test.js +0 -377
- package/src/html/icon.example.js.backup +0 -268
- package/src/html/icon.test.js +0 -231
- package/src/html/label.test.js +0 -0
- package/src/html/list.example.js.backup +0 -404
- package/src/html/list.test.js +0 -383
- package/src/html/progress.example.js.backup +0 -424
- package/src/html/progress.test.js +0 -313
- package/src/html/property.example.js.backup +0 -553
- package/src/html/property.test.js +0 -371
- package/src/html/radio.example.js.backup +0 -389
- package/src/html/radio.test.js +0 -318
- package/src/html/section.example.js.backup +0 -99
- package/src/html/section.test.js +0 -131
- package/src/html/selector.test.js +0 -20
- package/src/html/switch.example.js.backup +0 -461
- package/src/html/switch.test.js +0 -355
- package/src/html/tab.example.js.backup +0 -446
- package/src/html/tab.test.js +0 -25
- package/src/html/tab_enhanced.test.js +0 -504
- package/src/html/table.test.js +0 -70
- package/src/html/table2.test.js +0 -582
- package/src/html/text.test.js +0 -15
- package/src/html/textfield.test.js +0 -51
- package/src/html/textfield2.example.js.backup +0 -1370
- package/src/html/textfield2.test.js +0 -950
- package/src/html/tokenfield.example.js.backup +0 -503
- package/src/html/tokenfield.test.js +0 -423
- package/src/html/tree.example.js.backup +0 -475
- package/src/html/tree.test.js +0 -43
- package/src/html/tree_enhanced.test.js +0 -495
- package/src/http/token.test.js +0 -50
- package/src/incubator/pdfViewer.js +0 -33
- package/src/incubator/wizard.test.js +0 -127
- package/src/site/site.test.js +0 -230
- package/src/site/view.test.js +0 -41
- package/src/widgets/calendar/Calendar.test.js +0 -28
- package/src/widgets/explorer/Explorer.test.js +0 -121
- package/src/widgets/ide/editor.test.js +0 -33
- package/src/widgets/kanban/Kanban.test.js +0 -78
- package/src/widgets/login/LoginBox.test.js +0 -12
- package/src/widgets/login/ResetPasswordBox.test.js +0 -34
- package/src/widgets/login/validations.test.js +0 -51
- package/src/widgets/planner/Planner.test.js +0 -60
- package/src/widgets/upload/Upload.test.js +0 -32
- package/table2.test.js +0 -454
package/src/desktop/window.js
CHANGED
@@ -1,27 +1,261 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import {
|
1
|
+
import React, { useState, useRef, useEffect } from 'react'
|
2
|
+
import { useWindows } from './WindowContext'
|
3
3
|
import './window.css'
|
4
4
|
|
5
|
-
|
5
|
+
/**
|
6
|
+
* Window component - renders a draggable, resizable window
|
7
|
+
*/
|
8
|
+
export const Window = ({
|
9
|
+
id,
|
10
|
+
title = 'Window',
|
11
|
+
icon,
|
12
|
+
children,
|
13
|
+
toolbar,
|
14
|
+
statusBar,
|
15
|
+
showMinimize = true,
|
16
|
+
showMaximize = true,
|
17
|
+
showClose = true,
|
18
|
+
resizable = true,
|
19
|
+
draggable = true,
|
20
|
+
className = '',
|
21
|
+
...props
|
22
|
+
}) => {
|
23
|
+
const windowRef = useRef(null)
|
24
|
+
const headerRef = useRef(null)
|
25
|
+
|
26
|
+
// Get window data from WindowManager
|
27
|
+
const { getWindow, updateWindowPosition, closeWindow, minimizeWindow, maximizeWindow, focusWindow } = useWindows()
|
28
|
+
const windowData = getWindow(id)
|
29
|
+
|
30
|
+
// Local state for dragging
|
31
|
+
const [isDragging, setIsDragging] = useState(false)
|
32
|
+
const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 })
|
33
|
+
const [dragStartPosition, setDragStartPosition] = useState({ x: 0, y: 0 })
|
6
34
|
|
7
|
-
|
35
|
+
// If window doesn't exist in WindowManager, don't render
|
36
|
+
if (!windowData) {
|
37
|
+
return null
|
38
|
+
}
|
39
|
+
|
40
|
+
const { position, size, minimized, maximized, zIndex } = windowData
|
41
|
+
|
42
|
+
// Handle drag start
|
43
|
+
const handleMouseDown = (e) => {
|
44
|
+
if (!draggable || maximized) return
|
45
|
+
|
46
|
+
e.preventDefault()
|
47
|
+
|
48
|
+
// Get desktop container bounds
|
49
|
+
const desktopContainer = windowRef.current?.parentElement
|
50
|
+
if (!desktopContainer) return
|
51
|
+
|
52
|
+
const windowRect = windowRef.current.getBoundingClientRect()
|
53
|
+
|
54
|
+
// Calculate offset from mouse to window top-left
|
55
|
+
const offset = {
|
56
|
+
x: e.clientX - windowRect.left,
|
57
|
+
y: e.clientY - windowRect.top
|
58
|
+
}
|
59
|
+
|
60
|
+
setDragOffset(offset)
|
61
|
+
setDragStartPosition(position)
|
62
|
+
setIsDragging(true)
|
63
|
+
|
64
|
+
// Focus window
|
65
|
+
focusWindow(id)
|
66
|
+
}
|
67
|
+
|
68
|
+
// Handle drag move
|
69
|
+
const handleMouseMove = (e) => {
|
70
|
+
if (!isDragging) return
|
71
|
+
|
72
|
+
e.preventDefault()
|
73
|
+
|
74
|
+
// Get desktop container bounds
|
75
|
+
const desktopContainer = windowRef.current?.parentElement
|
76
|
+
if (!desktopContainer) return
|
77
|
+
|
78
|
+
const desktopRect = desktopContainer.getBoundingClientRect()
|
79
|
+
|
80
|
+
// Calculate new position relative to desktop container
|
81
|
+
const newPosition = {
|
82
|
+
x: e.clientX - desktopRect.left - dragOffset.x,
|
83
|
+
y: e.clientY - desktopRect.top - dragOffset.y
|
84
|
+
}
|
85
|
+
|
86
|
+
// Constrain to desktop bounds
|
87
|
+
const windowRect = windowRef.current.getBoundingClientRect()
|
88
|
+
const maxX = desktopRect.width - windowRect.width
|
89
|
+
const maxY = desktopRect.height - windowRect.height
|
90
|
+
|
91
|
+
const constrainedPosition = {
|
92
|
+
x: Math.max(0, Math.min(newPosition.x, maxX)),
|
93
|
+
y: Math.max(0, Math.min(newPosition.y, maxY))
|
94
|
+
}
|
95
|
+
|
96
|
+
// Update visual position immediately (local state)
|
97
|
+
if (windowRef.current) {
|
98
|
+
windowRef.current.style.left = `${constrainedPosition.x}px`
|
99
|
+
windowRef.current.style.top = `${constrainedPosition.y}px`
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
// Handle drag end
|
104
|
+
const handleMouseUp = () => {
|
105
|
+
if (!isDragging) return
|
106
|
+
|
107
|
+
setIsDragging(false)
|
108
|
+
|
109
|
+
// Get final position relative to desktop container
|
110
|
+
const desktopContainer = windowRef.current?.parentElement
|
111
|
+
if (!desktopContainer) return
|
112
|
+
|
113
|
+
const windowRect = windowRef.current.getBoundingClientRect()
|
114
|
+
const desktopRect = desktopContainer.getBoundingClientRect()
|
115
|
+
|
116
|
+
const finalPosition = {
|
117
|
+
x: windowRect.left - desktopRect.left,
|
118
|
+
y: windowRect.top - desktopRect.top
|
119
|
+
}
|
120
|
+
|
121
|
+
// Update WindowManager only once at the end
|
122
|
+
updateWindowPosition(id, finalPosition)
|
123
|
+
}
|
124
|
+
|
125
|
+
// Setup drag event listeners
|
126
|
+
useEffect(() => {
|
127
|
+
if (isDragging) {
|
128
|
+
document.addEventListener('mousemove', handleMouseMove)
|
129
|
+
document.addEventListener('mouseup', handleMouseUp)
|
130
|
+
document.body.style.userSelect = 'none'
|
131
|
+
document.body.style.cursor = 'move'
|
132
|
+
|
133
|
+
return () => {
|
134
|
+
document.removeEventListener('mousemove', handleMouseMove)
|
135
|
+
document.removeEventListener('mouseup', handleMouseUp)
|
136
|
+
document.body.style.userSelect = ''
|
137
|
+
document.body.style.cursor = ''
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}, [isDragging])
|
141
|
+
|
142
|
+
// Window control handlers
|
143
|
+
const handleMinimize = (e) => {
|
144
|
+
e.stopPropagation()
|
145
|
+
minimizeWindow(id, !minimized)
|
146
|
+
}
|
147
|
+
|
148
|
+
const handleMaximize = (e) => {
|
149
|
+
e.stopPropagation()
|
150
|
+
maximizeWindow(id, !maximized)
|
151
|
+
}
|
152
|
+
|
153
|
+
const handleClose = (e) => {
|
154
|
+
e.stopPropagation()
|
155
|
+
closeWindow(id)
|
156
|
+
}
|
157
|
+
|
158
|
+
// Double-click header to maximize/restore
|
159
|
+
const handleHeaderDoubleClick = (e) => {
|
160
|
+
if (!showMaximize) return
|
161
|
+
e.preventDefault()
|
162
|
+
maximizeWindow(id, !maximized)
|
163
|
+
}
|
164
|
+
|
165
|
+
const handleFocus = () => {
|
166
|
+
focusWindow(id)
|
167
|
+
}
|
168
|
+
|
169
|
+
// Window styles
|
170
|
+
const windowStyle = {
|
171
|
+
position: 'absolute',
|
172
|
+
left: maximized ? 0 : position.x,
|
173
|
+
top: maximized ? 0 : position.y,
|
174
|
+
width: maximized ? 'calc(100% - 0px)' : size.width,
|
175
|
+
height: maximized ? 'calc(100% - 50px)' : size.height, // Leave space for taskbar
|
176
|
+
zIndex: zIndex,
|
177
|
+
display: minimized ? 'none' : 'block'
|
178
|
+
}
|
179
|
+
|
180
|
+
const windowClasses = [
|
181
|
+
'window',
|
182
|
+
maximized && 'window--maximized',
|
183
|
+
isDragging && 'window--dragging',
|
184
|
+
className
|
185
|
+
].filter(Boolean).join(' ')
|
8
186
|
|
9
187
|
return (
|
10
|
-
<div
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
{
|
22
|
-
|
23
|
-
|
24
|
-
|
188
|
+
<div
|
189
|
+
ref={windowRef}
|
190
|
+
className={windowClasses}
|
191
|
+
style={windowStyle}
|
192
|
+
onClick={handleFocus}
|
193
|
+
{...props}
|
194
|
+
>
|
195
|
+
{/* Window Header */}
|
196
|
+
<div
|
197
|
+
ref={headerRef}
|
198
|
+
className="window__header"
|
199
|
+
onMouseDown={handleMouseDown}
|
200
|
+
onDoubleClick={handleHeaderDoubleClick}
|
201
|
+
style={{ cursor: draggable && !maximized ? 'move' : 'default' }}
|
202
|
+
>
|
203
|
+
{/* Icon and Title */}
|
204
|
+
<div className="window__title-bar">
|
205
|
+
{icon && <div className="window__icon">{icon}</div>}
|
206
|
+
<div className="window__title">{title}</div>
|
207
|
+
</div>
|
208
|
+
|
209
|
+
{/* Window Controls */}
|
210
|
+
<div className="window__controls">
|
211
|
+
{showMinimize && (
|
212
|
+
<button
|
213
|
+
className="window__control window__control--minimize"
|
214
|
+
onClick={handleMinimize}
|
215
|
+
title="Minimize"
|
216
|
+
>
|
217
|
+
−
|
218
|
+
</button>
|
219
|
+
)}
|
220
|
+
{showMaximize && (
|
221
|
+
<button
|
222
|
+
className="window__control window__control--maximize"
|
223
|
+
onClick={handleMaximize}
|
224
|
+
title={maximized ? "Restore" : "Maximize"}
|
225
|
+
>
|
226
|
+
{maximized ? '⧉' : '□'}
|
227
|
+
</button>
|
228
|
+
)}
|
229
|
+
{showClose && (
|
230
|
+
<button
|
231
|
+
className="window__control window__control--close"
|
232
|
+
onClick={handleClose}
|
233
|
+
title="Close"
|
234
|
+
>
|
235
|
+
×
|
236
|
+
</button>
|
237
|
+
)}
|
238
|
+
</div>
|
239
|
+
</div>
|
240
|
+
|
241
|
+
{/* Toolbar */}
|
242
|
+
{toolbar && (
|
243
|
+
<div className="window__toolbar">
|
244
|
+
{toolbar}
|
245
|
+
</div>
|
246
|
+
)}
|
247
|
+
|
248
|
+
{/* Window Content */}
|
249
|
+
<div className="window__content">
|
250
|
+
{children}
|
251
|
+
</div>
|
252
|
+
|
253
|
+
{/* Status Bar */}
|
254
|
+
{statusBar && (
|
255
|
+
<div className="window__status-bar">
|
256
|
+
{statusBar}
|
257
|
+
</div>
|
258
|
+
)}
|
25
259
|
</div>
|
26
260
|
)
|
27
|
-
}
|
261
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
.window {
|
2
|
+
position: absolute;
|
3
|
+
top: 1rem;
|
4
|
+
left: 1rem;
|
5
|
+
min-width: 20rem;
|
6
|
+
min-height: 15rem;
|
7
|
+
resize: both;
|
8
|
+
background-color: rgb(227, 227, 227);
|
9
|
+
display: grid;
|
10
|
+
overflow: hidden;
|
11
|
+
resize: both;
|
12
|
+
}
|
13
|
+
|
14
|
+
.window.normal {
|
15
|
+
grid-template-areas:
|
16
|
+
"header header header"
|
17
|
+
"nav nav nav"
|
18
|
+
"menu main aside"
|
19
|
+
"footer footer footer";
|
20
|
+
grid-template-columns: auto 1fr auto;
|
21
|
+
grid-template-rows: 2rem auto 1fr auto;
|
22
|
+
}
|
23
|
+
|
24
|
+
.window>header {
|
25
|
+
grid-area: header;
|
26
|
+
padding: .3rem .3rem 0 0;
|
27
|
+
display: flex;
|
28
|
+
align-items: center;
|
29
|
+
overflow: hidden;
|
30
|
+
}
|
31
|
+
|
32
|
+
.window>header>label {
|
33
|
+
flex: 1;
|
34
|
+
}
|
35
|
+
|
36
|
+
.window>nav {
|
37
|
+
grid-area: nav;
|
38
|
+
}
|
39
|
+
|
40
|
+
.window>menu {
|
41
|
+
grid-area: menu;
|
42
|
+
padding: 0;
|
43
|
+
}
|
44
|
+
|
45
|
+
.window>main {
|
46
|
+
grid-area: main;
|
47
|
+
padding: .5rem;
|
48
|
+
overflow: hidden;
|
49
|
+
border: solid 1px var(--divider-color);
|
50
|
+
}
|
51
|
+
|
52
|
+
.window>aside {
|
53
|
+
grid-area: aside;
|
54
|
+
}
|
55
|
+
|
56
|
+
.window>footer {
|
57
|
+
grid-area: footer;
|
58
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Button, Icon } from '../html'
|
3
|
+
import './window.css'
|
4
|
+
|
5
|
+
export const Window = (props) => {
|
6
|
+
|
7
|
+
const { id, icon, title, children } = props
|
8
|
+
|
9
|
+
return (
|
10
|
+
<div className="window normal" draggable>
|
11
|
+
<header>
|
12
|
+
<Icon icon={icon} size="small" />
|
13
|
+
<label>{title}</label>
|
14
|
+
<Icon icon="close" clickable size="small" />
|
15
|
+
</header>
|
16
|
+
<nav>
|
17
|
+
|
18
|
+
</nav>
|
19
|
+
<menu></menu>
|
20
|
+
<main>
|
21
|
+
{children}x
|
22
|
+
</main>
|
23
|
+
<aside></aside>
|
24
|
+
<footer>x</footer>
|
25
|
+
</div>
|
26
|
+
)
|
27
|
+
}
|
@@ -0,0 +1,178 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { Accordion } from './accordion.js'
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Accordion básico
|
6
|
+
*/
|
7
|
+
export const BasicAccordion = () => {
|
8
|
+
const basicSections = [
|
9
|
+
{
|
10
|
+
id: 'section-1',
|
11
|
+
title: 'Información Personal',
|
12
|
+
subtitle: 'Datos básicos del usuario',
|
13
|
+
icon: 'person',
|
14
|
+
checked: false,
|
15
|
+
open: true,
|
16
|
+
info: '3 campos',
|
17
|
+
children: (
|
18
|
+
<div style={{ padding: '1rem' }}>
|
19
|
+
<p>Contenido de información personal:</p>
|
20
|
+
<ul>
|
21
|
+
<li>Nombre completo</li>
|
22
|
+
<li>Email</li>
|
23
|
+
<li>Teléfono</li>
|
24
|
+
</ul>
|
25
|
+
</div>
|
26
|
+
)
|
27
|
+
},
|
28
|
+
{
|
29
|
+
id: 'section-2',
|
30
|
+
title: 'Configuración',
|
31
|
+
subtitle: 'Preferencias del sistema',
|
32
|
+
icon: 'settings',
|
33
|
+
checked: true,
|
34
|
+
open: false,
|
35
|
+
info: '5 opciones',
|
36
|
+
children: (
|
37
|
+
<div style={{ padding: '1rem' }}>
|
38
|
+
<p>Opciones de configuración:</p>
|
39
|
+
<ul>
|
40
|
+
<li>Tema oscuro/claro</li>
|
41
|
+
<li>Notificaciones</li>
|
42
|
+
<li>Idioma</li>
|
43
|
+
<li>Zona horaria</li>
|
44
|
+
<li>Privacidad</li>
|
45
|
+
</ul>
|
46
|
+
</div>
|
47
|
+
)
|
48
|
+
},
|
49
|
+
{
|
50
|
+
id: 'section-3',
|
51
|
+
title: 'Seguridad',
|
52
|
+
subtitle: 'Configuración de seguridad',
|
53
|
+
icon: 'security',
|
54
|
+
checked: false,
|
55
|
+
open: false,
|
56
|
+
info: '2 elementos',
|
57
|
+
children: (
|
58
|
+
<div style={{ padding: '1rem' }}>
|
59
|
+
<p>Configuración de seguridad:</p>
|
60
|
+
<ul>
|
61
|
+
<li>Cambiar contraseña</li>
|
62
|
+
<li>Autenticación de dos factores</li>
|
63
|
+
</ul>
|
64
|
+
</div>
|
65
|
+
)
|
66
|
+
}
|
67
|
+
]
|
68
|
+
|
69
|
+
return (
|
70
|
+
<div style={{ padding: '20px' }}>
|
71
|
+
<h3>Accordion Básico</h3>
|
72
|
+
<div style={{
|
73
|
+
background: '#fff',
|
74
|
+
border: '1px solid #ddd',
|
75
|
+
borderRadius: '8px',
|
76
|
+
overflow: 'hidden'
|
77
|
+
}}>
|
78
|
+
<Accordion
|
79
|
+
sections={basicSections}
|
80
|
+
ariaLabel="Accordion de configuración básica"
|
81
|
+
onSectionCheck={(index, checked, sectionId, section) => {
|
82
|
+
console.log('Section checked:', { index, checked, sectionId, section })
|
83
|
+
}}
|
84
|
+
onSectionToggle={(index, open, section) => {
|
85
|
+
console.log('Section toggled:', { index, open, section })
|
86
|
+
}}
|
87
|
+
onSectionChange={(action, index, value, section) => {
|
88
|
+
console.log('Section changed:', { action, index, value, section })
|
89
|
+
}}
|
90
|
+
/>
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
)
|
94
|
+
}
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Accordion con controles
|
98
|
+
*/
|
99
|
+
export const AccordionWithControls = () => {
|
100
|
+
const [isDisabled, setIsDisabled] = useState(false)
|
101
|
+
const [allowMultiple, setAllowMultiple] = useState(true)
|
102
|
+
const [animated, setAnimated] = useState(true)
|
103
|
+
|
104
|
+
const sections = [
|
105
|
+
{
|
106
|
+
id: 'control-1',
|
107
|
+
title: 'Primera Sección',
|
108
|
+
icon: 'folder',
|
109
|
+
open: true,
|
110
|
+
children: <div style={{ padding: '1rem' }}>Contenido de la primera sección</div>
|
111
|
+
},
|
112
|
+
{
|
113
|
+
id: 'control-2',
|
114
|
+
title: 'Segunda Sección',
|
115
|
+
icon: 'description',
|
116
|
+
open: false,
|
117
|
+
children: <div style={{ padding: '1rem' }}>Contenido de la segunda sección</div>
|
118
|
+
}
|
119
|
+
]
|
120
|
+
|
121
|
+
return (
|
122
|
+
<div style={{ padding: '20px' }}>
|
123
|
+
<h3>Accordion con Controles</h3>
|
124
|
+
|
125
|
+
<div style={{ marginBottom: '1rem', display: 'flex', gap: '1rem', flexWrap: 'wrap' }}>
|
126
|
+
<label>
|
127
|
+
<input
|
128
|
+
type="checkbox"
|
129
|
+
checked={isDisabled}
|
130
|
+
onChange={(e) => setIsDisabled(e.target.checked)}
|
131
|
+
/>
|
132
|
+
Deshabilitado
|
133
|
+
</label>
|
134
|
+
<label>
|
135
|
+
<input
|
136
|
+
type="checkbox"
|
137
|
+
checked={allowMultiple}
|
138
|
+
onChange={(e) => setAllowMultiple(e.target.checked)}
|
139
|
+
/>
|
140
|
+
Permitir múltiples abiertos
|
141
|
+
</label>
|
142
|
+
<label>
|
143
|
+
<input
|
144
|
+
type="checkbox"
|
145
|
+
checked={animated}
|
146
|
+
onChange={(e) => setAnimated(e.target.checked)}
|
147
|
+
/>
|
148
|
+
Animado
|
149
|
+
</label>
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<div style={{
|
153
|
+
background: '#fff',
|
154
|
+
border: '1px solid #ddd',
|
155
|
+
borderRadius: '8px',
|
156
|
+
overflow: 'hidden'
|
157
|
+
}}>
|
158
|
+
<Accordion
|
159
|
+
sections={sections}
|
160
|
+
disabled={isDisabled}
|
161
|
+
allowMultiple={allowMultiple}
|
162
|
+
animated={animated}
|
163
|
+
ariaLabel="Accordion con controles"
|
164
|
+
/>
|
165
|
+
</div>
|
166
|
+
</div>
|
167
|
+
)
|
168
|
+
}
|
169
|
+
|
170
|
+
/**
|
171
|
+
* Todos los ejemplos
|
172
|
+
*/
|
173
|
+
export const AllExamples = () => (
|
174
|
+
<div>
|
175
|
+
<BasicAccordion />
|
176
|
+
<AccordionWithControls />
|
177
|
+
</div>
|
178
|
+
)
|