@andreyfedkovich/cozy-ui 0.1.2 → 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/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ ## 0.2.1
4
+
5
+ - **fix:** Published `dist-lib/index.d.ts` is now the real rolled-up declaration bundle (no broken stub pointing at `../dist/lib/index`). `vite-plugin-dts` writes types to the same `outDir` as the library build (`dist-lib`).
6
+ - **fix:** Ship `dist-lib/svg-react-shim.d.ts` and a `/// <reference />` in `index.d.ts` so consumers typecheck `*.svg?react` imports from the bundle without missing-module errors (including with `skipLibCheck: false`).
package/README.md CHANGED
@@ -200,19 +200,23 @@ A block with a header that expands and collapses its content.
200
200
  ```tsx
201
201
  import { CollapsableBlock } from "@andreyfedkovich/cozy-ui";
202
202
 
203
- <CollapsableBlock title="Advanced settings">
204
- {/* hidden by default */}
205
- </CollapsableBlock>;
203
+ <CollapsableBlock
204
+ header="Advanced settings"
205
+ content={<div>{/* hidden by default */}</div>}
206
+ />;
206
207
  ```
207
208
 
208
209
  #### `Collapse`
209
210
 
210
- Low-level animated open/close primitive give it `isOpen` and children.
211
+ Animated expandable section with explicit `header` and `content`.
211
212
 
212
- | Prop | Type | Default | Description |
213
- | --------- | --------- | ------- | --------------------------------- |
214
- | `isOpen` | `boolean` | `false` | Controls expansion. |
215
- | `children`| `ReactNode` | — | Collapsible content. |
213
+ | Prop | Type | Default | Description |
214
+ | ------------- | ----------- | ------- | ---------------------------------------- |
215
+ | `header` | `ReactNode` | | Header row content. |
216
+ | `content` | `ReactNode` | — | Expandable body content. |
217
+ | `isOpen` | `boolean` | — | Controlled open state. |
218
+ | `defaultOpen` | `boolean` | `false` | Initial open state (uncontrolled mode). |
219
+ | `onToggle` | `() => void`| — | Toggle callback. |
216
220
 
217
221
  ```tsx
218
222
  import { Collapse } from "@andreyfedkovich/cozy-ui";
@@ -220,10 +224,12 @@ import { useState } from "react";
220
224
 
221
225
  const [open, setOpen] = useState(false);
222
226
 
223
- <>
224
- <button onClick={() => setOpen((v) => !v)}>Toggle</button>
225
- <Collapse isOpen={open}>Hidden content</Collapse>
226
- </>;
227
+ <Collapse
228
+ header="Toggle"
229
+ content="Hidden content"
230
+ isOpen={open}
231
+ onToggle={() => setOpen((v) => !v)}
232
+ />;
227
233
  ```
228
234
 
229
235
  #### `Carousel`
@@ -359,7 +365,7 @@ import { DialogSelect } from "@andreyfedkovich/cozy-ui";
359
365
  const { items, total } = await res.json();
360
366
  return { options: items.map((p) => ({ value: p.id, label: p.name })), total };
361
367
  }}
362
- onSelect={(opt) => console.log(opt)}
368
+ onChange={(opt) => console.log(opt)}
363
369
  />;
364
370
  ```
365
371
 
@@ -372,9 +378,12 @@ import { TreeDialogSelect } from "@andreyfedkovich/cozy-ui";
372
378
 
373
379
  <TreeDialogSelect
374
380
  title="Pick a department"
375
- loadNodes={async ({ parentId }) => ({ nodes: await fetchChildren(parentId) })}
376
- searchNodes={async ({ search }) => ({ nodes: await searchTree(search) })}
377
- onSelect={(node) => console.log(node)}
381
+ placeholder="Choose department"
382
+ loadNodes={async ({ parentId, search }) => ({
383
+ nodes: await fetchChildren(parentId, search),
384
+ })}
385
+ searchNodes={async (search) => ({ matches: await searchTreeWithPath(search) })}
386
+ onChange={(node) => console.log(node)}
378
387
  />;
379
388
  ```
380
389
 
@@ -385,7 +394,7 @@ Small caption row under an input — supports neutral, error, and success tones.
385
394
  ```tsx
386
395
  import { InputCaption } from "@andreyfedkovich/cozy-ui";
387
396
 
388
- <InputCaption type="error">Email is required.</InputCaption>;
397
+ <InputCaption variant="error">Email is required.</InputCaption>;
389
398
  ```
390
399
 
391
400
  #### `Label`
@@ -414,7 +423,7 @@ const [tab, setTab] = useState("overview");
414
423
 
415
424
  <Tabs
416
425
  value={tab}
417
- onChange={setTab}
426
+ onValueChange={setTab}
418
427
  items={[
419
428
  { value: "overview", label: "Overview" },
420
429
  { value: "activity", label: "Activity" },
@@ -431,7 +440,7 @@ import { TabsRounded } from "@andreyfedkovich/cozy-ui";
431
440
 
432
441
  <TabsRounded
433
442
  value="all"
434
- onChange={(v) => console.log(v)}
443
+ onValueChange={(v) => console.log(v)}
435
444
  items={[
436
445
  { value: "all", label: "All" },
437
446
  { value: "open", label: "Open" },
@@ -448,17 +457,18 @@ Linear, numbered progress for multi-step flows.
448
457
  | --------- | ---------------- | ------- | --------------------------------------------- |
449
458
  | `items` | `StepperItem[]` | — | Step definitions. |
450
459
  | `current` | `number` | `0` | Index of the active step. |
451
- | `onStepClick` | `(index) => void` | — | Optional click handler for completed steps. |
460
+ | `onChange` | `(index) => void` | — | Optional click handler for step buttons. |
452
461
 
453
462
  ```tsx
454
463
  import { Stepper } from "@andreyfedkovich/cozy-ui";
455
464
 
456
465
  <Stepper
457
466
  current={1}
467
+ onChange={(index) => console.log(index)}
458
468
  items={[
459
- { title: "Account" },
460
- { title: "Profile" },
461
- { title: "Review" },
469
+ { label: "Account" },
470
+ { label: "Profile" },
471
+ { label: "Review" },
462
472
  ]}
463
473
  />;
464
474
  ```
@@ -518,8 +528,18 @@ Wraps any element to copy a string to clipboard, with built-in feedback.
518
528
 
519
529
  ```tsx
520
530
  import { CopyTextTrigger } from "@andreyfedkovich/cozy-ui";
531
+ import { useState } from "react";
532
+
533
+ const [copied, setCopied] = useState(false);
521
534
 
522
- <CopyTextTrigger text="cozy-ui">
535
+ <CopyTextTrigger
536
+ copied={copied}
537
+ onClick={() => {
538
+ navigator.clipboard.writeText("cozy-ui");
539
+ setCopied(true);
540
+ setTimeout(() => setCopied(false), 1000);
541
+ }}
542
+ >
523
543
  <button>Copy package name</button>
524
544
  </CopyTextTrigger>;
525
545
  ```
@@ -608,12 +628,14 @@ Edit mode:
608
628
 
609
629
  Tracks the size of a DOM element via `ResizeObserver`.
610
630
 
611
- ```ts
631
+ ```tsx
612
632
  import { useMeasureElement } from "@andreyfedkovich/cozy-ui";
633
+ import { useState } from "react";
613
634
 
614
- const { ref, width, height } = useMeasureElement<HTMLDivElement>();
635
+ const [element, setElement] = useState<HTMLDivElement | null>(null);
636
+ const { width, height } = useMeasureElement(element);
615
637
 
616
- <div ref={ref}>{width} × {height}</div>;
638
+ <div ref={setElement}>{width} × {height}</div>;
617
639
  ```
618
640
 
619
641
  ### `useDropdownPosition`