@easyvision/easyvision-ui 1.7.5 → 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 +56 -13
- package/dist/index.cjs +281 -151
- 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 +181 -53
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
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
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
.ev-checkbox::before {
|
|
234
234
|
content: "";
|
|
235
235
|
position: absolute;
|
|
236
|
-
inset: -0.
|
|
236
|
+
inset: -0.75rem;
|
|
237
237
|
}
|
|
238
238
|
.ev-checkbox:focus-visible {
|
|
239
239
|
outline: 2px solid hsl(var(--ring, 215 20% 65%));
|
|
@@ -320,16 +320,12 @@
|
|
|
320
320
|
overflow: hidden;
|
|
321
321
|
text-overflow: ellipsis;
|
|
322
322
|
white-space: nowrap;
|
|
323
|
-
/* The trigger is the <button>; children should never swallow the click so
|
|
324
|
-
* the entire visible button area always behaves as the hit target. */
|
|
325
|
-
pointer-events: none;
|
|
326
323
|
}
|
|
327
324
|
.ev-select-trigger-icon {
|
|
328
325
|
height: 1rem;
|
|
329
326
|
width: 1rem;
|
|
330
327
|
opacity: 0.5;
|
|
331
328
|
flex-shrink: 0;
|
|
332
|
-
pointer-events: none;
|
|
333
329
|
}
|
|
334
330
|
|
|
335
331
|
/* Bare trigger variant used inside chips */
|
|
@@ -842,6 +838,57 @@
|
|
|
842
838
|
padding-top: 0;
|
|
843
839
|
}
|
|
844
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
|
+
|
|
845
892
|
/* ---------- EasyVisionInput (text + optional search icon + clear) ---------- */
|
|
846
893
|
.ev-input-comp {
|
|
847
894
|
display: flex;
|
|
@@ -1181,6 +1228,10 @@
|
|
|
1181
1228
|
color: hsl(var(--muted-foreground, 215 16% 47%));
|
|
1182
1229
|
white-space: nowrap;
|
|
1183
1230
|
}
|
|
1231
|
+
.ev-mf-chip-label.is-clickable {
|
|
1232
|
+
cursor: pointer;
|
|
1233
|
+
user-select: none;
|
|
1234
|
+
}
|
|
1184
1235
|
.ev-mf-chip-required {
|
|
1185
1236
|
margin-left: 0.125rem;
|
|
1186
1237
|
color: hsl(var(--destructive, 0 84% 60%));
|
|
@@ -1217,7 +1268,6 @@
|
|
|
1217
1268
|
outline: none;
|
|
1218
1269
|
}
|
|
1219
1270
|
.ev-mf-chip-select-trigger {
|
|
1220
|
-
position: relative;
|
|
1221
1271
|
height: auto;
|
|
1222
1272
|
width: auto;
|
|
1223
1273
|
min-width: 0;
|
|
@@ -1230,13 +1280,6 @@
|
|
|
1230
1280
|
line-height: 1rem;
|
|
1231
1281
|
color: hsl(var(--muted-foreground, 215 16% 47%));
|
|
1232
1282
|
}
|
|
1233
|
-
/* The chip trigger has no padding so the visible click area is just text+icon.
|
|
1234
|
-
* Extend the hit target without changing visual size. */
|
|
1235
|
-
.ev-mf-chip-select-trigger::before {
|
|
1236
|
-
content: "";
|
|
1237
|
-
position: absolute;
|
|
1238
|
-
inset: -0.375rem -0.25rem;
|
|
1239
|
-
}
|
|
1240
1283
|
.ev-mf-chip-select-trigger:focus {
|
|
1241
1284
|
outline: none;
|
|
1242
1285
|
}
|