ywana-core8 0.1.103 → 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 +9 -25
- 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
@@ -1,503 +0,0 @@
|
|
1
|
-
import React, { useState } from 'react'
|
2
|
-
import { TokenField } from './tokenfield'
|
3
|
-
import { Button } from './button'
|
4
|
-
import { Text } from './text'
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Ejemplos del componente TokenField mejorado manteniendo 100% compatibilidad
|
8
|
-
*/
|
9
|
-
export const TokenFieldExamples = () => {
|
10
|
-
const [basicTokens, setBasicTokens] = useState(['React', 'JavaScript'])
|
11
|
-
const [tagTokens, setTagTokens] = useState(['frontend', 'ui', 'components'])
|
12
|
-
const [emailTokens, setEmailTokens] = useState(['user@example.com'])
|
13
|
-
const [skillTokens, setSkillTokens] = useState(['JavaScript'])
|
14
|
-
const [isLoading, setIsLoading] = useState(false)
|
15
|
-
const [showAdvanced, setShowAdvanced] = useState(false)
|
16
|
-
|
17
|
-
const skillOptions = [
|
18
|
-
{ label: 'JavaScript', value: 'javascript' },
|
19
|
-
{ label: 'TypeScript', value: 'typescript' },
|
20
|
-
{ label: 'React', value: 'react' },
|
21
|
-
{ label: 'Vue.js', value: 'vue' },
|
22
|
-
{ label: 'Angular', value: 'angular' },
|
23
|
-
{ label: 'Node.js', value: 'nodejs' },
|
24
|
-
{ label: 'Python', value: 'python' },
|
25
|
-
{ label: 'Java', value: 'java' },
|
26
|
-
{ label: 'C++', value: 'cpp' },
|
27
|
-
{ label: 'Go', value: 'go' }
|
28
|
-
]
|
29
|
-
|
30
|
-
const categoryOptions = [
|
31
|
-
{ label: 'Frontend', value: 'frontend' },
|
32
|
-
{ label: 'Backend', value: 'backend' },
|
33
|
-
{ label: 'Database', value: 'database' },
|
34
|
-
{ label: 'DevOps', value: 'devops' },
|
35
|
-
{ label: 'Mobile', value: 'mobile' },
|
36
|
-
{ label: 'Testing', value: 'testing' }
|
37
|
-
]
|
38
|
-
|
39
|
-
const handleBasicChange = (id, tokens) => {
|
40
|
-
setBasicTokens(tokens)
|
41
|
-
console.log('Basic tokens changed:', tokens)
|
42
|
-
}
|
43
|
-
|
44
|
-
const handleTagChange = (id, tokens) => {
|
45
|
-
setTagTokens(tokens)
|
46
|
-
console.log('Tag tokens changed:', tokens)
|
47
|
-
}
|
48
|
-
|
49
|
-
const handleEmailChange = (id, tokens) => {
|
50
|
-
setEmailTokens(tokens)
|
51
|
-
console.log('Email tokens changed:', tokens)
|
52
|
-
}
|
53
|
-
|
54
|
-
const handleSkillChange = (id, tokens) => {
|
55
|
-
setSkillTokens(tokens)
|
56
|
-
console.log('Skill tokens changed:', tokens)
|
57
|
-
}
|
58
|
-
|
59
|
-
const validateEmail = (token) => {
|
60
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
61
|
-
if (!emailRegex.test(token)) {
|
62
|
-
return { isValid: false, error: 'Invalid email format' }
|
63
|
-
}
|
64
|
-
return { isValid: true }
|
65
|
-
}
|
66
|
-
|
67
|
-
const validateTag = (token) => {
|
68
|
-
if (token.length < 2) {
|
69
|
-
return { isValid: false, error: 'Tag must be at least 2 characters' }
|
70
|
-
}
|
71
|
-
if (token.includes(' ')) {
|
72
|
-
return { isValid: false, error: 'Tags cannot contain spaces' }
|
73
|
-
}
|
74
|
-
return { isValid: true }
|
75
|
-
}
|
76
|
-
|
77
|
-
const simulateLoading = () => {
|
78
|
-
setIsLoading(true)
|
79
|
-
setTimeout(() => setIsLoading(false), 2000)
|
80
|
-
}
|
81
|
-
|
82
|
-
return (
|
83
|
-
<div style={{ padding: '2rem', maxWidth: '1200px', maxHeight: '100vh', overflow: 'auto' }}>
|
84
|
-
<h1>Componente TokenField Mejorado</h1>
|
85
|
-
|
86
|
-
<div style={{
|
87
|
-
background: '#f8f9fa',
|
88
|
-
padding: '1rem',
|
89
|
-
borderRadius: '8px',
|
90
|
-
marginBottom: '2rem',
|
91
|
-
border: '1px solid #e9ecef'
|
92
|
-
}}>
|
93
|
-
<h3>✅ Mejoras Implementadas (100% Compatibilidad):</h3>
|
94
|
-
<ul>
|
95
|
-
<li>🛡️ <strong>PropTypes completos</strong> - Validación y documentación detallada</li>
|
96
|
-
<li>🔢 <strong>Límites de tokens</strong> - minTokens, maxTokens con validación</li>
|
97
|
-
<li>🚫 <strong>Control de duplicados</strong> - allowDuplicates configurable</li>
|
98
|
-
<li>✅ <strong>Validación personalizada</strong> - validateToken function</li>
|
99
|
-
<li>⌨️ <strong>Separadores múltiples</strong> - comma, semicolon, enter</li>
|
100
|
-
<li>📏 <strong>Múltiples tamaños</strong> - small, medium, large</li>
|
101
|
-
<li>🎭 <strong>Variantes visuales</strong> - default, outlined, filled</li>
|
102
|
-
<li>⚠️ <strong>Estados avanzados</strong> - disabled, error, required, loading</li>
|
103
|
-
<li>🧹 <strong>Clear functionality</strong> - Botón para limpiar todos los tokens</li>
|
104
|
-
<li>🔍 <strong>Búsqueda en opciones</strong> - Filtrado en tiempo real</li>
|
105
|
-
<li>📊 <strong>Ordenamiento</strong> - Opciones ordenadas alfabéticamente</li>
|
106
|
-
<li>♿ <strong>Accesibilidad completa</strong> - ARIA, navegación por teclado</li>
|
107
|
-
<li>📱 <strong>Responsive total</strong> - Adaptación móvil y dark mode</li>
|
108
|
-
</ul>
|
109
|
-
</div>
|
110
|
-
|
111
|
-
{/* Controles de demostración */}
|
112
|
-
<section style={{ marginBottom: '2rem' }}>
|
113
|
-
<h3>Controles de Demostración</h3>
|
114
|
-
<div style={{
|
115
|
-
background: '#fff',
|
116
|
-
padding: '1rem',
|
117
|
-
borderRadius: '8px',
|
118
|
-
border: '1px solid #ddd',
|
119
|
-
display: 'flex',
|
120
|
-
gap: '1rem',
|
121
|
-
alignItems: 'center',
|
122
|
-
flexWrap: 'wrap'
|
123
|
-
}}>
|
124
|
-
<Button
|
125
|
-
label="Simulate Loading"
|
126
|
-
icon="refresh"
|
127
|
-
action={simulateLoading}
|
128
|
-
disabled={isLoading}
|
129
|
-
/>
|
130
|
-
<Button
|
131
|
-
label={showAdvanced ? "Hide Advanced" : "Show Advanced"}
|
132
|
-
icon={showAdvanced ? "visibility_off" : "visibility"}
|
133
|
-
action={() => setShowAdvanced(!showAdvanced)}
|
134
|
-
/>
|
135
|
-
<span style={{ marginLeft: 'auto', color: '#666' }}>
|
136
|
-
Total tokens: {basicTokens.length + tagTokens.length + emailTokens.length + skillTokens.length}
|
137
|
-
</span>
|
138
|
-
</div>
|
139
|
-
</section>
|
140
|
-
|
141
|
-
{/* TokenField básico (Compatible) */}
|
142
|
-
<section style={{ marginBottom: '2rem' }}>
|
143
|
-
<h3>🏷️ TokenField Básico (100% Compatible)</h3>
|
144
|
-
<div style={{
|
145
|
-
background: '#fff',
|
146
|
-
padding: '1rem',
|
147
|
-
border: '1px solid #ddd',
|
148
|
-
borderRadius: '8px'
|
149
|
-
}}>
|
150
|
-
<TokenField
|
151
|
-
id="basic"
|
152
|
-
label="Basic Tokens"
|
153
|
-
tokens={basicTokens}
|
154
|
-
onChange={handleBasicChange}
|
155
|
-
/>
|
156
|
-
<Text size="sm" color="muted" style={{ marginTop: '0.5rem' }}>
|
157
|
-
Funcionalidad original: agregar tokens con Enter, eliminar con click
|
158
|
-
</Text>
|
159
|
-
</div>
|
160
|
-
</section>
|
161
|
-
|
162
|
-
{/* TokenField con opciones */}
|
163
|
-
<section style={{ marginBottom: '2rem' }}>
|
164
|
-
<h3>🎯 TokenField con Opciones (Compatible)</h3>
|
165
|
-
<div style={{
|
166
|
-
background: '#fff',
|
167
|
-
padding: '1rem',
|
168
|
-
border: '1px solid #ddd',
|
169
|
-
borderRadius: '8px'
|
170
|
-
}}>
|
171
|
-
<TokenField
|
172
|
-
id="skills"
|
173
|
-
label="Skills"
|
174
|
-
tokens={skillTokens}
|
175
|
-
options={skillOptions}
|
176
|
-
predictive={true}
|
177
|
-
onChange={handleSkillChange}
|
178
|
-
/>
|
179
|
-
<Text size="sm" color="muted" style={{ marginTop: '0.5rem' }}>
|
180
|
-
Dropdown con opciones predefinidas y búsqueda predictiva
|
181
|
-
</Text>
|
182
|
-
</div>
|
183
|
-
</section>
|
184
|
-
|
185
|
-
{/* TokenField mejorado */}
|
186
|
-
<section style={{ marginBottom: '2rem' }}>
|
187
|
-
<h3>🚀 TokenField Mejorado con Nuevas Características</h3>
|
188
|
-
<div style={{
|
189
|
-
background: '#fff',
|
190
|
-
padding: '1rem',
|
191
|
-
border: '1px solid #ddd',
|
192
|
-
borderRadius: '8px',
|
193
|
-
display: 'grid',
|
194
|
-
gridTemplateColumns: '1fr 1fr',
|
195
|
-
gap: '1rem'
|
196
|
-
}}>
|
197
|
-
<TokenField
|
198
|
-
id="tags"
|
199
|
-
label="Tags"
|
200
|
-
tokens={tagTokens}
|
201
|
-
onChange={handleTagChange}
|
202
|
-
placeholder="Add tag..."
|
203
|
-
maxTokens={5}
|
204
|
-
minTokens={1}
|
205
|
-
allowDuplicates={false}
|
206
|
-
validateToken={validateTag}
|
207
|
-
tokenSeparators={[',', ';', ' ']}
|
208
|
-
size="medium"
|
209
|
-
variant="outlined"
|
210
|
-
clearable={true}
|
211
|
-
helperText="Max 5 tags, no duplicates, no spaces"
|
212
|
-
onTokenAdd={(token) => console.log('Tag added:', token)}
|
213
|
-
onTokenRemove={(token) => console.log('Tag removed:', token)}
|
214
|
-
onValidationError={(error, token) => console.log('Validation error:', error, token)}
|
215
|
-
/>
|
216
|
-
<TokenField
|
217
|
-
id="emails"
|
218
|
-
label="Email Addresses"
|
219
|
-
tokens={emailTokens}
|
220
|
-
onChange={handleEmailChange}
|
221
|
-
placeholder="Add email..."
|
222
|
-
validateToken={validateEmail}
|
223
|
-
size="large"
|
224
|
-
variant="filled"
|
225
|
-
required={true}
|
226
|
-
helperText="Enter valid email addresses"
|
227
|
-
disabled={isLoading}
|
228
|
-
/>
|
229
|
-
</div>
|
230
|
-
</section>
|
231
|
-
|
232
|
-
{/* Tamaños y variantes */}
|
233
|
-
<section style={{ marginBottom: '2rem' }}>
|
234
|
-
<h3>📏 Tamaños y Variantes</h3>
|
235
|
-
<div style={{
|
236
|
-
background: '#fff',
|
237
|
-
padding: '1rem',
|
238
|
-
border: '1px solid #ddd',
|
239
|
-
borderRadius: '8px',
|
240
|
-
display: 'grid',
|
241
|
-
gridTemplateColumns: '1fr 1fr 1fr',
|
242
|
-
gap: '1rem'
|
243
|
-
}}>
|
244
|
-
<TokenField
|
245
|
-
id="small"
|
246
|
-
label="Small Size"
|
247
|
-
tokens={['small', 'tokens']}
|
248
|
-
onChange={() => {}}
|
249
|
-
size="small"
|
250
|
-
variant="default"
|
251
|
-
placeholder="Small..."
|
252
|
-
/>
|
253
|
-
<TokenField
|
254
|
-
id="medium"
|
255
|
-
label="Medium Size"
|
256
|
-
tokens={['medium', 'tokens']}
|
257
|
-
onChange={() => {}}
|
258
|
-
size="medium"
|
259
|
-
variant="outlined"
|
260
|
-
placeholder="Medium..."
|
261
|
-
/>
|
262
|
-
<TokenField
|
263
|
-
id="large"
|
264
|
-
label="Large Size"
|
265
|
-
tokens={['large', 'tokens']}
|
266
|
-
onChange={() => {}}
|
267
|
-
size="large"
|
268
|
-
variant="filled"
|
269
|
-
placeholder="Large..."
|
270
|
-
/>
|
271
|
-
</div>
|
272
|
-
</section>
|
273
|
-
|
274
|
-
{/* Estados especiales */}
|
275
|
-
<section style={{ marginBottom: '2rem' }}>
|
276
|
-
<h3>⚠️ Estados Especiales</h3>
|
277
|
-
<div style={{
|
278
|
-
background: '#fff',
|
279
|
-
padding: '1rem',
|
280
|
-
border: '1px solid #ddd',
|
281
|
-
borderRadius: '8px',
|
282
|
-
display: 'grid',
|
283
|
-
gridTemplateColumns: '1fr 1fr',
|
284
|
-
gap: '1rem'
|
285
|
-
}}>
|
286
|
-
<TokenField
|
287
|
-
id="required"
|
288
|
-
label="Required Field"
|
289
|
-
tokens={['required']}
|
290
|
-
onChange={() => {}}
|
291
|
-
required={true}
|
292
|
-
minTokens={1}
|
293
|
-
helperText="This field is required"
|
294
|
-
/>
|
295
|
-
<TokenField
|
296
|
-
id="error"
|
297
|
-
label="Field with Error"
|
298
|
-
tokens={['invalid-token']}
|
299
|
-
onChange={() => {}}
|
300
|
-
error="Invalid token detected"
|
301
|
-
/>
|
302
|
-
<TokenField
|
303
|
-
id="disabled"
|
304
|
-
label="Disabled Field"
|
305
|
-
tokens={['disabled', 'tokens']}
|
306
|
-
onChange={() => {}}
|
307
|
-
disabled={isLoading}
|
308
|
-
helperText="Field is disabled"
|
309
|
-
/>
|
310
|
-
<TokenField
|
311
|
-
id="readonly"
|
312
|
-
label="Read-only Field"
|
313
|
-
tokens={['readonly', 'tokens']}
|
314
|
-
onChange={() => {}}
|
315
|
-
readOnly={true}
|
316
|
-
helperText="Field is read-only"
|
317
|
-
/>
|
318
|
-
</div>
|
319
|
-
</section>
|
320
|
-
|
321
|
-
{/* Características avanzadas */}
|
322
|
-
{showAdvanced && (
|
323
|
-
<section style={{ marginBottom: '2rem' }}>
|
324
|
-
<h3>🔬 Características Avanzadas</h3>
|
325
|
-
<div style={{
|
326
|
-
background: '#fff',
|
327
|
-
padding: '1rem',
|
328
|
-
border: '1px solid #ddd',
|
329
|
-
borderRadius: '8px',
|
330
|
-
display: 'grid',
|
331
|
-
gridTemplateColumns: '1fr 1fr',
|
332
|
-
gap: '1rem'
|
333
|
-
}}>
|
334
|
-
<TokenField
|
335
|
-
id="searchable"
|
336
|
-
label="Searchable Options"
|
337
|
-
tokens={[]}
|
338
|
-
options={categoryOptions}
|
339
|
-
onChange={() => {}}
|
340
|
-
searchable={true}
|
341
|
-
sortable={true}
|
342
|
-
placeholder="Search categories..."
|
343
|
-
helperText="Type to search and filter options"
|
344
|
-
/>
|
345
|
-
<TokenField
|
346
|
-
id="limits"
|
347
|
-
label="With Limits"
|
348
|
-
tokens={['token1', 'token2']}
|
349
|
-
onChange={() => {}}
|
350
|
-
maxTokens={3}
|
351
|
-
minTokens={2}
|
352
|
-
allowDuplicates={false}
|
353
|
-
clearable={false}
|
354
|
-
helperText="2-3 tokens, no duplicates"
|
355
|
-
/>
|
356
|
-
</div>
|
357
|
-
</section>
|
358
|
-
)}
|
359
|
-
|
360
|
-
{/* Separadores y validación */}
|
361
|
-
{showAdvanced && (
|
362
|
-
<section style={{ marginBottom: '2rem' }}>
|
363
|
-
<h3>⌨️ Separadores y Validación</h3>
|
364
|
-
<div style={{
|
365
|
-
background: '#fff',
|
366
|
-
padding: '1rem',
|
367
|
-
border: '1px solid #ddd',
|
368
|
-
borderRadius: '8px'
|
369
|
-
}}>
|
370
|
-
<TokenField
|
371
|
-
id="separators"
|
372
|
-
label="Multiple Separators"
|
373
|
-
tokens={[]}
|
374
|
-
onChange={() => {}}
|
375
|
-
tokenSeparators={[',', ';', '|', '\n']}
|
376
|
-
placeholder="Use comma, semicolon, pipe, or enter..."
|
377
|
-
helperText="Try typing: token1,token2;token3|token4 and press enter"
|
378
|
-
/>
|
379
|
-
<div style={{ marginTop: '1rem' }}>
|
380
|
-
<Text size="sm" color="muted">
|
381
|
-
<strong>Separadores soportados:</strong> Comma (,), Semicolon (;), Pipe (|), Enter
|
382
|
-
</Text>
|
383
|
-
</div>
|
384
|
-
</div>
|
385
|
-
</section>
|
386
|
-
)}
|
387
|
-
|
388
|
-
{/* Comparación antes/después */}
|
389
|
-
<section style={{ marginBottom: '2rem' }}>
|
390
|
-
<h3>Comparación: TokenField Original vs Mejorado</h3>
|
391
|
-
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '1rem' }}>
|
392
|
-
<div style={{
|
393
|
-
background: '#ffebee',
|
394
|
-
padding: '1rem',
|
395
|
-
borderRadius: '4px',
|
396
|
-
border: '1px solid #ffcdd2'
|
397
|
-
}}>
|
398
|
-
<h4>❌ TokenField Original</h4>
|
399
|
-
<ul>
|
400
|
-
<li>Funcionalidad básica de tokens</li>
|
401
|
-
<li>Soporte para opciones dropdown</li>
|
402
|
-
<li>Búsqueda predictiva</li>
|
403
|
-
<li>Sin PropTypes ni validación</li>
|
404
|
-
<li>Sin límites de tokens</li>
|
405
|
-
<li>Sin validación personalizada</li>
|
406
|
-
<li>Sin estados avanzados</li>
|
407
|
-
<li>Sin accesibilidad</li>
|
408
|
-
<li>CSS básico sin responsive</li>
|
409
|
-
</ul>
|
410
|
-
</div>
|
411
|
-
<div style={{
|
412
|
-
background: '#e8f5e8',
|
413
|
-
padding: '1rem',
|
414
|
-
borderRadius: '4px',
|
415
|
-
border: '1px solid #c8e6c9'
|
416
|
-
}}>
|
417
|
-
<h4>✅ TokenField Mejorado</h4>
|
418
|
-
<ul>
|
419
|
-
<li>Mantiene funcionalidad original</li>
|
420
|
-
<li>PropTypes completos y validación</li>
|
421
|
-
<li>Límites min/max con advertencias</li>
|
422
|
-
<li>Validación personalizada de tokens</li>
|
423
|
-
<li>Múltiples separadores configurables</li>
|
424
|
-
<li>Estados disabled, error, required</li>
|
425
|
-
<li>Accesibilidad total (WCAG 2.1 AA)</li>
|
426
|
-
<li>Búsqueda y ordenamiento en opciones</li>
|
427
|
-
<li>CSS responsive con dark mode</li>
|
428
|
-
</ul>
|
429
|
-
</div>
|
430
|
-
</div>
|
431
|
-
</section>
|
432
|
-
|
433
|
-
{/* Garantía de compatibilidad */}
|
434
|
-
<section style={{ marginBottom: '2rem' }}>
|
435
|
-
<h3>🔒 Garantía de Compatibilidad</h3>
|
436
|
-
<div style={{
|
437
|
-
background: '#fff3cd',
|
438
|
-
padding: '1rem',
|
439
|
-
borderRadius: '4px',
|
440
|
-
border: '1px solid #ffeaa7'
|
441
|
-
}}>
|
442
|
-
<p><strong>100% Compatible con Código Existente:</strong></p>
|
443
|
-
<ul>
|
444
|
-
<li>✅ Props originales (id, label, tokens, readOnly, options, predictive, onChange) funcionan idéntico</li>
|
445
|
-
<li>✅ Comportamiento de onChange sin cambios</li>
|
446
|
-
<li>✅ Estructura de tokens y opciones preservada</li>
|
447
|
-
<li>✅ CSS original preservado y mejorado</li>
|
448
|
-
<li>✅ Nuevas características son opcionales</li>
|
449
|
-
<li>✅ No se rompe ningún código existente</li>
|
450
|
-
<li>✅ Migración automática sin cambios</li>
|
451
|
-
</ul>
|
452
|
-
<p style={{ marginTop: '1rem', fontSize: '0.9rem', color: '#856404' }}>
|
453
|
-
<strong>Migración:</strong> Simplemente reemplaza el import y todas las
|
454
|
-
mejoras se aplican automáticamente sin cambiar una línea de código existente.
|
455
|
-
</p>
|
456
|
-
</div>
|
457
|
-
</section>
|
458
|
-
|
459
|
-
{/* Casos de uso */}
|
460
|
-
<section style={{ marginBottom: '2rem' }}>
|
461
|
-
<h3>🎯 Casos de Uso Comunes</h3>
|
462
|
-
<div style={{
|
463
|
-
background: '#fff',
|
464
|
-
padding: '1rem',
|
465
|
-
border: '1px solid #ddd',
|
466
|
-
borderRadius: '8px',
|
467
|
-
display: 'grid',
|
468
|
-
gridTemplateColumns: '1fr 1fr',
|
469
|
-
gap: '1rem'
|
470
|
-
}}>
|
471
|
-
<div>
|
472
|
-
<h4>🏷️ Sistema de Tags</h4>
|
473
|
-
<TokenField
|
474
|
-
id="blog-tags"
|
475
|
-
label="Blog Tags"
|
476
|
-
tokens={['react', 'javascript']}
|
477
|
-
onChange={() => {}}
|
478
|
-
maxTokens={10}
|
479
|
-
allowDuplicates={false}
|
480
|
-
validateToken={(token) => token.length >= 2 ? { isValid: true } : { isValid: false, error: 'Too short' }}
|
481
|
-
placeholder="Add tags..."
|
482
|
-
helperText="Tags for blog post categorization"
|
483
|
-
/>
|
484
|
-
</div>
|
485
|
-
<div>
|
486
|
-
<h4>👥 Gestión de Usuarios</h4>
|
487
|
-
<TokenField
|
488
|
-
id="user-emails"
|
489
|
-
label="Invite Users"
|
490
|
-
tokens={[]}
|
491
|
-
onChange={() => {}}
|
492
|
-
validateToken={validateEmail}
|
493
|
-
placeholder="Enter email addresses..."
|
494
|
-
helperText="Add users to invite to the project"
|
495
|
-
/>
|
496
|
-
</div>
|
497
|
-
</div>
|
498
|
-
</section>
|
499
|
-
</div>
|
500
|
-
)
|
501
|
-
}
|
502
|
-
|
503
|
-
export default TokenFieldExamples
|