@easyvision/easyvision-ui 1.7.6 → 1.8.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.
- package/README.md +86 -0
- package/dist/easyvision.css +51 -0
- package/dist/index.cjs +254 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -1
- package/dist/index.d.ts +59 -1
- package/dist/index.js +152 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
- [`clearWhen`](#clearwhen)
|
|
22
22
|
- [Labels (i18n)](#labels-i18n)
|
|
23
23
|
- [`EasyVisionCard`](#easyvisioncard)
|
|
24
|
+
- [`EasyVisionAccordion`](#easyvisionaccordion)
|
|
24
25
|
- [`EasyVisionInput`](#easyvisioninput)
|
|
25
26
|
- [`EasyVisionSelector`](#easyvisionselector)
|
|
26
27
|
- [`EasyVisionMultifilter`](#easyvisionmultifilter)
|
|
@@ -190,6 +191,91 @@ import {
|
|
|
190
191
|
|
|
191
192
|
---
|
|
192
193
|
|
|
194
|
+
## `EasyVisionAccordion`
|
|
195
|
+
|
|
196
|
+
A list of **unfoldable questions** (FAQ-style). Holds an indefinite number of
|
|
197
|
+
items and accepts **free-format content** — both the `question` header and the
|
|
198
|
+
body are `ReactNode`, so an answer can be plain text or arbitrary JSX (tables,
|
|
199
|
+
tabs, lists, charts…).
|
|
200
|
+
|
|
201
|
+
Like `EasyVisionCard`, it's self-contained and **does not** use the `id`/slice
|
|
202
|
+
machinery — open/closed is ephemeral UI state held locally (optionally
|
|
203
|
+
controlled). Visuals rely only on the standard Tailwind theme tokens
|
|
204
|
+
(`muted`, `card`, `border`, `foreground`) via `.ev-accordion*` classes.
|
|
205
|
+
|
|
206
|
+
### Minimal usage (data-driven)
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
import { EasyVisionAccordion } from '@easyvision/easyvision-ui';
|
|
210
|
+
|
|
211
|
+
<EasyVisionAccordion
|
|
212
|
+
items={[
|
|
213
|
+
{ id: 'what', question: '¿Qué es NML Vision?', content: <p>…</p> },
|
|
214
|
+
{ id: 'scoring', question: '¿Cómo funciona el scoring?', content: <ScoringTable /> },
|
|
215
|
+
]}
|
|
216
|
+
/>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
The `items` array can be any length and built dynamically (filter/spread for
|
|
220
|
+
conditional questions) — the FAQ list is not fixed at compile time.
|
|
221
|
+
|
|
222
|
+
### Compound usage
|
|
223
|
+
|
|
224
|
+
Equivalent, when you'd rather write the bodies inline as children:
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
import { EasyVisionAccordion, EasyVisionAccordionItem } from '@easyvision/easyvision-ui';
|
|
228
|
+
|
|
229
|
+
<EasyVisionAccordion mode="multiple">
|
|
230
|
+
<EasyVisionAccordionItem id="what" question="¿Qué es NML Vision?">
|
|
231
|
+
<p>…</p>
|
|
232
|
+
</EasyVisionAccordionItem>
|
|
233
|
+
<EasyVisionAccordionItem id="scoring" question="¿Cómo funciona el scoring?">
|
|
234
|
+
<ScoringTable />
|
|
235
|
+
</EasyVisionAccordionItem>
|
|
236
|
+
</EasyVisionAccordion>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
> Mix-and-match is not supported in a single instance: pass **either** `items`
|
|
240
|
+
> **or** `EasyVisionAccordionItem` children. If `items` is provided, children
|
|
241
|
+
> are ignored.
|
|
242
|
+
|
|
243
|
+
### Open behaviour
|
|
244
|
+
|
|
245
|
+
- `mode="single"` (default) — one item open at a time, like the NML Vision Help
|
|
246
|
+
page. `mode="multiple"` — items open independently.
|
|
247
|
+
- Uncontrolled: set `defaultOpenIds={['scoring']}` or per-item `defaultOpen`.
|
|
248
|
+
- Controlled: pass `openIds` + `onOpenChange` to own the state. Use
|
|
249
|
+
`onOpenChange` to lazily fetch a question's data the first time it opens (the
|
|
250
|
+
callback receives the next list of open ids).
|
|
251
|
+
|
|
252
|
+
### Props
|
|
253
|
+
|
|
254
|
+
#### `EasyVisionAccordion`
|
|
255
|
+
|
|
256
|
+
| prop | type | default | notes |
|
|
257
|
+
|---|---|---|---|
|
|
258
|
+
| `items` | `AccordionItem[]` | — | Data-driven items. Omit when using children. |
|
|
259
|
+
| `children` | `ReactNode` | — | `EasyVisionAccordionItem` elements (alternative to `items`). |
|
|
260
|
+
| `mode` | `'single' \| 'multiple'` | `'single'` | Open behaviour. |
|
|
261
|
+
| `openIds` | `string[]` | — | Controlled set of open ids. |
|
|
262
|
+
| `defaultOpenIds` | `string[]` | — | Uncontrolled initial open ids. |
|
|
263
|
+
| `onOpenChange` | `(openIds: string[]) => void` | — | Fired on every open/close. |
|
|
264
|
+
| `className` | `string` | — | Merged with `ev-accordion`. |
|
|
265
|
+
|
|
266
|
+
`AccordionItem` / `EasyVisionAccordionItem` fields: `id` (required, stable key),
|
|
267
|
+
`question` (`ReactNode`), `content` / children (`ReactNode` body), optional
|
|
268
|
+
`defaultOpen` and `disabled`.
|
|
269
|
+
|
|
270
|
+
### Notes
|
|
271
|
+
|
|
272
|
+
- Each item renders an accessible trigger (`<button>` with `aria-expanded` /
|
|
273
|
+
`aria-controls`) and a `role="region"` panel.
|
|
274
|
+
- The chevron rotates on open; collapsed panels are unmounted (not hidden), so
|
|
275
|
+
heavy bodies don't render until first opened.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
193
279
|
## `EasyVisionInput`
|
|
194
280
|
|
|
195
281
|
A debounced text input that persists its value by `id`.
|
package/dist/easyvision.css
CHANGED
|
@@ -838,6 +838,57 @@
|
|
|
838
838
|
padding-top: 0;
|
|
839
839
|
}
|
|
840
840
|
|
|
841
|
+
/* ---------- Accordion (unfoldable questions / FAQ) ---------- */
|
|
842
|
+
.ev-accordion {
|
|
843
|
+
display: flex;
|
|
844
|
+
flex-direction: column;
|
|
845
|
+
gap: 1rem;
|
|
846
|
+
}
|
|
847
|
+
.ev-accordion-item {
|
|
848
|
+
border: 1px solid hsl(var(--border, 220 13% 91%));
|
|
849
|
+
border-radius: 0.375rem;
|
|
850
|
+
overflow: hidden;
|
|
851
|
+
}
|
|
852
|
+
.ev-accordion-trigger {
|
|
853
|
+
width: 100%;
|
|
854
|
+
display: flex;
|
|
855
|
+
align-items: center;
|
|
856
|
+
justify-content: space-between;
|
|
857
|
+
gap: 0.75rem;
|
|
858
|
+
padding: 0.75rem 1rem;
|
|
859
|
+
text-align: left;
|
|
860
|
+
background: hsl(var(--muted, 220 13% 91%));
|
|
861
|
+
color: hsl(var(--foreground, 222 47% 11%));
|
|
862
|
+
border: none;
|
|
863
|
+
cursor: pointer;
|
|
864
|
+
transition: background-color 0.2s ease, opacity 0.2s ease;
|
|
865
|
+
}
|
|
866
|
+
.ev-accordion-trigger:hover {
|
|
867
|
+
background: hsl(var(--muted, 220 13% 91%) / 0.8);
|
|
868
|
+
}
|
|
869
|
+
.ev-accordion-trigger:disabled {
|
|
870
|
+
cursor: not-allowed;
|
|
871
|
+
opacity: 0.6;
|
|
872
|
+
}
|
|
873
|
+
.ev-accordion-question {
|
|
874
|
+
font-weight: 500;
|
|
875
|
+
}
|
|
876
|
+
.ev-accordion-icon {
|
|
877
|
+
height: 1.25rem;
|
|
878
|
+
width: 1.25rem;
|
|
879
|
+
flex-shrink: 0;
|
|
880
|
+
color: hsl(var(--muted-foreground, 215 16% 47%));
|
|
881
|
+
transition: transform 0.2s ease;
|
|
882
|
+
}
|
|
883
|
+
.ev-accordion-trigger-open .ev-accordion-icon {
|
|
884
|
+
transform: rotate(180deg);
|
|
885
|
+
}
|
|
886
|
+
.ev-accordion-panel {
|
|
887
|
+
padding: 0.75rem 1rem;
|
|
888
|
+
background: hsl(var(--card, 0 0% 100%));
|
|
889
|
+
color: hsl(var(--foreground, 222 47% 11%));
|
|
890
|
+
}
|
|
891
|
+
|
|
841
892
|
/* ---------- EasyVisionInput (text + optional search icon + clear) ---------- */
|
|
842
893
|
.ev-input-comp {
|
|
843
894
|
display: flex;
|