@usevyre/ai-context 1.3.0 → 1.4.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/dist/anti-patterns.json +288 -1
- package/dist/cheat-sheets/carousel.md +50 -0
- package/dist/cheat-sheets/carouselslide.md +22 -0
- package/dist/cheat-sheets/emptystate.md +48 -0
- package/dist/cheat-sheets/form.md +50 -0
- package/dist/cheat-sheets/formfield.md +22 -0
- package/dist/cheat-sheets/index.md +18 -0
- package/dist/cheat-sheets/numberinput.md +41 -0
- package/dist/cheat-sheets/otpinput.md +51 -0
- package/dist/cheat-sheets/stat.md +41 -0
- package/dist/cheat-sheets/statgroup.md +23 -0
- package/dist/cheat-sheets/step.md +8 -0
- package/dist/cheat-sheets/steppanel.md +8 -0
- package/dist/cheat-sheets/stepper.md +59 -0
- package/dist/cheat-sheets/steppernav.md +8 -0
- package/dist/cheat-sheets/timeline.md +40 -0
- package/dist/cheat-sheets/timelineitem.md +28 -0
- package/dist/cheat-sheets/togglegroup.md +55 -0
- package/dist/cheat-sheets/toggleitem.md +29 -0
- package/dist/cheat-sheets/tree.md +48 -0
- package/dist/claude-context.md +601 -1
- package/dist/copilot-instructions.md +601 -1
- package/dist/cursor-rules.md +186 -1
- package/dist/full-context.md +600 -0
- package/dist/index.js +10049 -6006
- package/dist/schema.json +974 -2
- package/dist/tokens.json +1 -1
- package/dist/tokens.md +1 -1
- package/dist/version-info.json +232 -51
- package/dist/windsurf-rules.md +601 -1
- package/package.json +1 -1
package/dist/anti-patterns.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.16.0",
|
|
3
3
|
"rules": [
|
|
4
4
|
{
|
|
5
5
|
"component": "Accordion",
|
|
@@ -610,6 +610,293 @@
|
|
|
610
610
|
"fix": "Use the width / height prop: width=\"full\", width=\"md\", height=\"screen\", etc.",
|
|
611
611
|
"severity": "error"
|
|
612
612
|
},
|
|
613
|
+
{
|
|
614
|
+
"component": "Form",
|
|
615
|
+
"pattern": "Manually tracking each field's error state with useState",
|
|
616
|
+
"reason": "Form already validates and maps errors into Field automatically",
|
|
617
|
+
"fix": "Wrap controls in <FormField name rules> and let Form manage errors",
|
|
618
|
+
"severity": "error"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
"component": "Form",
|
|
622
|
+
"pattern": "Adding a validation library (zod/yup) just for basic rules",
|
|
623
|
+
"reason": "Form ships zero-dependency built-in rules",
|
|
624
|
+
"fix": "Use rules={{ required, minLength, pattern, email, validate }}",
|
|
625
|
+
"severity": "error"
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
"component": "Form",
|
|
629
|
+
"pattern": "<FormField> with multiple control children",
|
|
630
|
+
"reason": "FormField clones a single child to inject name/value/onChange",
|
|
631
|
+
"fix": "Use one control per FormField (Input/Textarea/Select/etc.)",
|
|
632
|
+
"severity": "error"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"component": "Form",
|
|
636
|
+
"pattern": "<FormField> outside a <Form>",
|
|
637
|
+
"reason": "FormField reads form context",
|
|
638
|
+
"fix": "Always nest FormField inside <Form>",
|
|
639
|
+
"severity": "error"
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
"component": "FormField",
|
|
643
|
+
"pattern": "Putting onChange/value manually on the control inside FormField",
|
|
644
|
+
"reason": "FormField already injects them; manual props can desync from form state",
|
|
645
|
+
"fix": "Let FormField wire the control; only pass static props (type, placeholder)",
|
|
646
|
+
"severity": "error"
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
"component": "NumberInput",
|
|
650
|
+
"pattern": "onChange={(e) => set(e.target.value)}",
|
|
651
|
+
"reason": "NumberInput emits a number, not an event — there is no e.target",
|
|
652
|
+
"fix": "onChange={(value) => set(value)} — value is number | null",
|
|
653
|
+
"severity": "error"
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
"component": "NumberInput",
|
|
657
|
+
"pattern": "Using <Input type=\"number\"> for numeric fields",
|
|
658
|
+
"reason": "Native number input has no token-styled stepper, no clamp, returns a string",
|
|
659
|
+
"fix": "Use <NumberInput value onChange min max step />",
|
|
660
|
+
"severity": "error"
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
"component": "NumberInput",
|
|
664
|
+
"pattern": "Parsing the value with Number() in form state",
|
|
665
|
+
"reason": "NumberInput already emits a real number (or null)",
|
|
666
|
+
"fix": "Store the value directly; it is already number | null",
|
|
667
|
+
"severity": "error"
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
"component": "ToggleGroup",
|
|
671
|
+
"pattern": "onChange={(e) => set(e.target.value)}",
|
|
672
|
+
"reason": "ToggleGroup emits the value, not an event",
|
|
673
|
+
"fix": "onChange={(value) => set(value)} — string|null (single) or string[] (multiple)",
|
|
674
|
+
"severity": "error"
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
"component": "ToggleGroup",
|
|
678
|
+
"pattern": "Using ToggleGroup for a single on/off setting",
|
|
679
|
+
"reason": "That is a boolean toggle",
|
|
680
|
+
"fix": "Use <Switch> for on/off; ToggleGroup is for choosing among options",
|
|
681
|
+
"severity": "error"
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
"component": "ToggleGroup",
|
|
685
|
+
"pattern": "type=\"multiple\" with a string value",
|
|
686
|
+
"reason": "multiple mode requires an array value",
|
|
687
|
+
"fix": "value={['a','b']} and onChange receives string[]",
|
|
688
|
+
"severity": "error"
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
"component": "ToggleGroup",
|
|
692
|
+
"pattern": "<ToggleItem> outside <ToggleGroup>",
|
|
693
|
+
"reason": "ToggleItem reads group context",
|
|
694
|
+
"fix": "Always nest ToggleItem inside ToggleGroup (or use options)",
|
|
695
|
+
"severity": "error"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
"component": "ToggleItem",
|
|
699
|
+
"pattern": "Tracking selected state on ToggleItem yourself",
|
|
700
|
+
"reason": "Selection is owned by ToggleGroup",
|
|
701
|
+
"fix": "Only set value; the group controls selected state",
|
|
702
|
+
"severity": "error"
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
"component": "Stepper",
|
|
706
|
+
"pattern": "Using Tabs for a wizard / checkout flow",
|
|
707
|
+
"reason": "Tabs are peer panels; a step flow is ordered with completed/current/upcoming state",
|
|
708
|
+
"fix": "Use <Stepper> with StepperNav + Step + StepPanel",
|
|
709
|
+
"severity": "error"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"component": "Stepper",
|
|
713
|
+
"pattern": "onChange={(e) => set(e.target.value)}",
|
|
714
|
+
"reason": "Stepper emits the index number, not an event",
|
|
715
|
+
"fix": "onChange={(index) => setStep(index)}",
|
|
716
|
+
"severity": "error"
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
"component": "Stepper",
|
|
720
|
+
"pattern": "Manually toggling which panel is visible",
|
|
721
|
+
"reason": "StepPanel renders itself only when its index === active",
|
|
722
|
+
"fix": "Give each StepPanel an index; Stepper shows the active one",
|
|
723
|
+
"severity": "error"
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
"component": "Stepper",
|
|
727
|
+
"pattern": "<Step> or <StepPanel> outside <Stepper>",
|
|
728
|
+
"reason": "They read Stepper context",
|
|
729
|
+
"fix": "Nest Step inside StepperNav, StepPanel inside Stepper",
|
|
730
|
+
"severity": "error"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
"component": "EmptyState",
|
|
734
|
+
"pattern": "Building an empty placeholder with a bare <div> + centered text",
|
|
735
|
+
"reason": "Inconsistent spacing/typography; AI reinvents it each time",
|
|
736
|
+
"fix": "Use <EmptyState title description variant>",
|
|
737
|
+
"severity": "error"
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
"component": "EmptyState",
|
|
741
|
+
"pattern": "action / cta prop",
|
|
742
|
+
"reason": "There is no action prop; the CTA is composed",
|
|
743
|
+
"fix": "Put the Button as children of EmptyState",
|
|
744
|
+
"severity": "error"
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
"component": "EmptyState",
|
|
748
|
+
"pattern": "Using EmptyState for a loading state",
|
|
749
|
+
"reason": "EmptyState is for no-data, not in-progress",
|
|
750
|
+
"fix": "Use <Skeleton> while loading; EmptyState when the result set is empty",
|
|
751
|
+
"severity": "error"
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
"component": "Stat",
|
|
755
|
+
"pattern": "Assuming trend flips the arrow direction",
|
|
756
|
+
"reason": "Arrow direction comes from the delta sign; trend only sets color",
|
|
757
|
+
"fix": "delta=\"-0.4%\" always shows a down arrow; trend=\"up\" just colors it green",
|
|
758
|
+
"severity": "error"
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
"component": "Stat",
|
|
762
|
+
"pattern": "Building a KPI card with Card + manual layout",
|
|
763
|
+
"reason": "Inconsistent value/label/delta styling; AI reinvents it",
|
|
764
|
+
"fix": "Use <Stat label value delta trend />",
|
|
765
|
+
"severity": "error"
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
"component": "Stat",
|
|
769
|
+
"pattern": "Laying out a KPI row with custom flex + dividers",
|
|
770
|
+
"reason": "StatGroup already splits evenly with dividers",
|
|
771
|
+
"fix": "Wrap the Stats in <StatGroup>",
|
|
772
|
+
"severity": "error"
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
"component": "StatGroup",
|
|
776
|
+
"pattern": "Putting non-Stat children in StatGroup",
|
|
777
|
+
"reason": "Dividers/equal-split styling target .vyre-stat",
|
|
778
|
+
"fix": "Only place <Stat> elements inside StatGroup",
|
|
779
|
+
"severity": "error"
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"component": "Timeline",
|
|
783
|
+
"pattern": "Building an activity log with a <ul> + manual dots/lines",
|
|
784
|
+
"reason": "Inconsistent markers/spacing; AI reinvents it each time",
|
|
785
|
+
"fix": "Use <Timeline items={[...]} /> or TimelineItem children",
|
|
786
|
+
"severity": "error"
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
"component": "Timeline",
|
|
790
|
+
"pattern": "Using Stepper for a history/audit feed",
|
|
791
|
+
"reason": "Stepper is an ordered flow with completed/current/upcoming; a feed is just past events",
|
|
792
|
+
"fix": "Use <Timeline> for logs/history; Stepper for wizards",
|
|
793
|
+
"severity": "error"
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
"component": "Timeline",
|
|
797
|
+
"pattern": "Expecting Timeline to sort by time",
|
|
798
|
+
"reason": "Timeline renders items in given order",
|
|
799
|
+
"fix": "Sort the array yourself (newest- or oldest-first)",
|
|
800
|
+
"severity": "error"
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
"component": "TimelineItem",
|
|
804
|
+
"pattern": "<TimelineItem> outside <Timeline>",
|
|
805
|
+
"reason": "Marker/connector layout assumes the Timeline list context",
|
|
806
|
+
"fix": "Always nest TimelineItem inside Timeline",
|
|
807
|
+
"severity": "error"
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
"component": "Tree",
|
|
811
|
+
"pattern": "Rendering a nested <ul> tree by hand with manual expand state",
|
|
812
|
+
"reason": "Reinvents recursion, keyboard nav, and a11y roles every time",
|
|
813
|
+
"fix": "Pass a nested `data` array to <Tree> and control expandedIds/selectedId",
|
|
814
|
+
"severity": "error"
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
"component": "Tree",
|
|
818
|
+
"pattern": "onSelect={(e) => ...}",
|
|
819
|
+
"reason": "Tree emits the node id, not an event",
|
|
820
|
+
"fix": "onSelect={(id) => setSelected(id)}",
|
|
821
|
+
"severity": "error"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
"component": "Tree",
|
|
825
|
+
"pattern": "Mutating the data array to expand/collapse",
|
|
826
|
+
"reason": "Expansion is controlled via expandedIds, not the data",
|
|
827
|
+
"fix": "Track expandedIds in state (or use defaultExpandedIds)",
|
|
828
|
+
"severity": "error"
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
"component": "Tree",
|
|
832
|
+
"pattern": "Using DropdownMenu submenus for a file tree",
|
|
833
|
+
"reason": "Submenus are transient menus; a tree is persistent hierarchical content",
|
|
834
|
+
"fix": "Use <Tree> for file explorers / nested nav",
|
|
835
|
+
"severity": "error"
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
"component": "OTPInput",
|
|
839
|
+
"pattern": "onChange={(e) => set(e.target.value)}",
|
|
840
|
+
"reason": "OTPInput emits the code string, not an event — there is no e.target",
|
|
841
|
+
"fix": "onChange={(value) => setCode(value)}",
|
|
842
|
+
"severity": "error"
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
"component": "OTPInput",
|
|
846
|
+
"pattern": "Six separate <Input> boxes wired by hand",
|
|
847
|
+
"reason": "Reinvents paste, auto-advance, backspace and focus management",
|
|
848
|
+
"fix": "Use <OTPInput length={6} value onChange />",
|
|
849
|
+
"severity": "error"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
"component": "OTPInput",
|
|
853
|
+
"pattern": "Reading completion by comparing length yourself",
|
|
854
|
+
"reason": "onComplete already fires when the code is full",
|
|
855
|
+
"fix": "Use onComplete={(code) => verify(code)}",
|
|
856
|
+
"severity": "error"
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
"component": "OTPInput",
|
|
860
|
+
"pattern": "type=\"password\" to hide digits",
|
|
861
|
+
"reason": "There is no type=password; masking is a dedicated prop",
|
|
862
|
+
"fix": "Use mask (type stays numeric/alphanumeric)",
|
|
863
|
+
"severity": "error"
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
"component": "Carousel",
|
|
867
|
+
"pattern": "onChange={(e) => set(e.target.value)}",
|
|
868
|
+
"reason": "Carousel emits the slide index number, not an event",
|
|
869
|
+
"fix": "onChange={(index) => setIndex(index)}",
|
|
870
|
+
"severity": "error"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
"component": "Carousel",
|
|
874
|
+
"pattern": "Putting raw elements directly in Carousel",
|
|
875
|
+
"reason": "Slides must be CarouselSlide so snap/indices/aria work",
|
|
876
|
+
"fix": "Wrap each slide in <CarouselSlide>",
|
|
877
|
+
"severity": "error"
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
"component": "Carousel",
|
|
881
|
+
"pattern": "Building a slider with manual scroll + dot state",
|
|
882
|
+
"reason": "Reinvents snap, keyboard, autoplay-pause and a11y roles",
|
|
883
|
+
"fix": "Use <Carousel> with CarouselSlide children",
|
|
884
|
+
"severity": "error"
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
"component": "Carousel",
|
|
888
|
+
"pattern": "autoPlay without considering reduced motion / pausing",
|
|
889
|
+
"reason": "Autoplay can be an accessibility problem if it never pauses",
|
|
890
|
+
"fix": "Carousel already pauses on hover/focus; keep interval reasonable or omit autoPlay",
|
|
891
|
+
"severity": "error"
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
"component": "CarouselSlide",
|
|
895
|
+
"pattern": "<CarouselSlide> outside <Carousel>",
|
|
896
|
+
"reason": "Snap/measurement/aria depend on the Carousel context",
|
|
897
|
+
"fix": "Always nest CarouselSlide inside Carousel",
|
|
898
|
+
"severity": "error"
|
|
899
|
+
},
|
|
613
900
|
{
|
|
614
901
|
"component": "DateRangePicker",
|
|
615
902
|
"pattern": "value={[from, to]}",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Carousel — AI Cheat Sheet
|
|
2
|
+
> Quick reference for Claude / Cursor / Copilot
|
|
3
|
+
|
|
4
|
+
**Accessible content slider for galleries, onboarding, and testimonials. CONTROLLED by a 0-based slide index. Compose CarouselSlide children (slide order = index). Snap scrolling, clickable dot indicators, prev/next arrows, ArrowLeft/Right keyboard, optional loop and autoPlay (autoplay pauses on hover/focus). onChange emits the index (not an event).**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { Carousel, CarouselSlide } from "@usevyre/react"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Valid Props
|
|
11
|
+
|
|
12
|
+
| Prop | Values | Default |
|
|
13
|
+
|------|--------|---------|
|
|
14
|
+
| `loop` | `true` \| `false` | `false` |
|
|
15
|
+
| `autoPlay` | `true` \| `false` | `false` |
|
|
16
|
+
| `showArrows` | `true` \| `false` | `true` |
|
|
17
|
+
| `showIndicators` | `true` \| `false` | `true` |
|
|
18
|
+
|
|
19
|
+
## Common AI Mistakes
|
|
20
|
+
|
|
21
|
+
- ❌ `onChange={(e) => set(e.target.value)}`
|
|
22
|
+
→ onChange={(index) => setIndex(index)}
|
|
23
|
+
- ❌ `Putting raw elements directly in Carousel`
|
|
24
|
+
→ Wrap each slide in <CarouselSlide>
|
|
25
|
+
- ❌ `Building a slider with manual scroll + dot state`
|
|
26
|
+
→ Use <Carousel> with CarouselSlide children
|
|
27
|
+
- ❌ `autoPlay without considering reduced motion / pausing`
|
|
28
|
+
→ Carousel already pauses on hover/focus; keep interval reasonable or omit autoPlay
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
**Image gallery with loop**
|
|
33
|
+
```tsx
|
|
34
|
+
const [i, setI] = useState(0);
|
|
35
|
+
|
|
36
|
+
<Carousel value={i} onChange={setI} loop>
|
|
37
|
+
<CarouselSlide><img src="/a.jpg" alt="A" /></CarouselSlide>
|
|
38
|
+
<CarouselSlide><img src="/b.jpg" alt="B" /></CarouselSlide>
|
|
39
|
+
<CarouselSlide><img src="/c.jpg" alt="C" /></CarouselSlide>
|
|
40
|
+
</Carousel>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Onboarding, autoplay, no arrows**
|
|
44
|
+
```tsx
|
|
45
|
+
<Carousel autoPlay interval={4000} showArrows={false}>
|
|
46
|
+
<CarouselSlide><Welcome /></CarouselSlide>
|
|
47
|
+
<CarouselSlide><Features /></CarouselSlide>
|
|
48
|
+
<CarouselSlide><GetStarted /></CarouselSlide>
|
|
49
|
+
</Carousel>
|
|
50
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# CarouselSlide — AI Cheat Sheet
|
|
2
|
+
> Quick reference for Claude / Cursor / Copilot
|
|
3
|
+
|
|
4
|
+
**One slide inside <Carousel>. Holds arbitrary content (image, Card, testimonial). Slide order determines its index.**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { Carousel, CarouselSlide } from "@usevyre/react"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Common AI Mistakes
|
|
11
|
+
|
|
12
|
+
- ❌ `<CarouselSlide> outside <Carousel>`
|
|
13
|
+
→ Always nest CarouselSlide inside Carousel
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
**Card slide**
|
|
18
|
+
```tsx
|
|
19
|
+
<CarouselSlide>
|
|
20
|
+
<Card><CardBody>“Best tool ever.” — Ada</CardBody></Card>
|
|
21
|
+
</CarouselSlide>
|
|
22
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# EmptyState — AI Cheat Sheet
|
|
2
|
+
> Quick reference for Claude / Cursor / Copilot
|
|
3
|
+
|
|
4
|
+
**Presentational placeholder for empty lists, tables, and search results. No state. title/description/variant/size are props; the optional call-to-action goes in children (React) or the default slot (Vue). variant picks a preset icon (default=box, search=magnifier, error=warning); pass `icon` (or #icon slot) to override.**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { EmptyState } from "@usevyre/react"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Valid Props
|
|
11
|
+
|
|
12
|
+
| Prop | Values | Default |
|
|
13
|
+
|------|--------|---------|
|
|
14
|
+
| `variant` | `"default"` \| `"search"` \| `"error"` | `default` |
|
|
15
|
+
| `size` | `"sm"` \| `"md"` \| `"lg"` | `md` |
|
|
16
|
+
|
|
17
|
+
## Common AI Mistakes
|
|
18
|
+
|
|
19
|
+
- ❌ `Building an empty placeholder with a bare <div> + centered text`
|
|
20
|
+
→ Use <EmptyState title description variant>
|
|
21
|
+
- ❌ `action / cta prop`
|
|
22
|
+
→ Put the Button as children of EmptyState
|
|
23
|
+
- ❌ `Using EmptyState for a loading state`
|
|
24
|
+
→ Use <Skeleton> while loading; EmptyState when the result set is empty
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
**Empty search results with a reset CTA**
|
|
29
|
+
```tsx
|
|
30
|
+
<EmptyState
|
|
31
|
+
variant="search"
|
|
32
|
+
title="No results"
|
|
33
|
+
description="Try a different search term."
|
|
34
|
+
>
|
|
35
|
+
<Button variant="secondary" onClick={reset}>Clear filters</Button>
|
|
36
|
+
</EmptyState>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Full-page empty list**
|
|
40
|
+
```tsx
|
|
41
|
+
<EmptyState
|
|
42
|
+
size="lg"
|
|
43
|
+
title="No projects yet"
|
|
44
|
+
description="Create your first project to get started."
|
|
45
|
+
>
|
|
46
|
+
<Button variant="primary">New project</Button>
|
|
47
|
+
</EmptyState>
|
|
48
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Form — AI Cheat Sheet
|
|
2
|
+
> Quick reference for Claude / Cursor / Copilot
|
|
3
|
+
|
|
4
|
+
**Controlled, data-driven form. Zero dependencies. Validation runs on submit and (after the first submit) on blur. Errors map into the wrapped Field automatically (state=error + hint=message). Compose with FormField, which wires name/value/onChange/onBlur into a single control child.**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { Form, FormField } from "@usevyre/react"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Common AI Mistakes
|
|
11
|
+
|
|
12
|
+
- ❌ `Manually tracking each field's error state with useState`
|
|
13
|
+
→ Wrap controls in <FormField name rules> and let Form manage errors
|
|
14
|
+
- ❌ `Adding a validation library (zod/yup) just for basic rules`
|
|
15
|
+
→ Use rules={{ required, minLength, pattern, email, validate }}
|
|
16
|
+
- ❌ `<FormField> with multiple control children`
|
|
17
|
+
→ Use one control per FormField (Input/Textarea/Select/etc.)
|
|
18
|
+
- ❌ `<FormField> outside a <Form>`
|
|
19
|
+
→ Always nest FormField inside <Form>
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
**Controlled sign-in form with built-in rules**
|
|
24
|
+
```tsx
|
|
25
|
+
const [values, setValues] = useState({ email: "", password: "" });
|
|
26
|
+
|
|
27
|
+
<Form values={values} onChange={setValues} onSubmit={(v) => signIn(v)}>
|
|
28
|
+
<FormField name="email" label="Email" rules={{ required: true, email: true }}>
|
|
29
|
+
<Input type="email" />
|
|
30
|
+
</FormField>
|
|
31
|
+
<FormField name="password" label="Password" rules={{ required: true, minLength: 8 }}>
|
|
32
|
+
<Input type="password" />
|
|
33
|
+
</FormField>
|
|
34
|
+
<Button type="submit" variant="primary">Sign in</Button>
|
|
35
|
+
</Form>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Custom cross-field validation**
|
|
39
|
+
```tsx
|
|
40
|
+
<FormField
|
|
41
|
+
name="confirm"
|
|
42
|
+
label="Confirm password"
|
|
43
|
+
rules={{
|
|
44
|
+
required: true,
|
|
45
|
+
validate: (v, all) => v === all.password ? null : "Passwords do not match",
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<Input type="password" />
|
|
49
|
+
</FormField>
|
|
50
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# FormField — AI Cheat Sheet
|
|
2
|
+
> Quick reference for Claude / Cursor / Copilot
|
|
3
|
+
|
|
4
|
+
**A single labelled, validated field inside <Form>. Injects name/value/onChange/onBlur into its one control child and wraps it in <Field> (label + error state + hint).**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { FormField } from "@usevyre/react"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Common AI Mistakes
|
|
11
|
+
|
|
12
|
+
- ❌ `Putting onChange/value manually on the control inside FormField`
|
|
13
|
+
→ Let FormField wire the control; only pass static props (type, placeholder)
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
**Field with a hint**
|
|
18
|
+
```tsx
|
|
19
|
+
<FormField name="bio" label="Bio" hint="Max 200 characters" rules={{ maxLength: 200 }}>
|
|
20
|
+
<Textarea />
|
|
21
|
+
</FormField>
|
|
22
|
+
```
|
|
@@ -49,4 +49,22 @@ Quick reference for AI agents — one file per component.
|
|
|
49
49
|
- [Grid](grid.md) — Two-dimensional CSS grid primitive. Explicit column/row counts (or auto-fit), auto-flow control, token gap. Pair with GridItem for cell spanning/placement. Renders a plain <div> (or `as`).
|
|
50
50
|
- [GridItem](griditem.md) — Child placement inside <Grid>. Sets column/row span and start lines. Renders a plain <div> (or `as`).
|
|
51
51
|
- [Box](box.md) — Spacing-only container plus a controlled escape hatch. Token padding/margin with shorthand, per-axis (X/Y) and per-side (Top/Right/Bottom/Left) overrides. The `style` prop is an explicit anti-pattern escape hatch. Renders a plain <div> (or `as`).
|
|
52
|
+
- [Form](form.md) — Controlled, data-driven form. Zero dependencies. Validation runs on submit and (after the first submit) on blur. Errors map into the wrapped Field automatically (state=error + hint=message). Compose with FormField, which wires name/value/onChange/onBlur into a single control child.
|
|
53
|
+
- [FormField](formfield.md) — A single labelled, validated field inside <Form>. Injects name/value/onChange/onBlur into its one control child and wraps it in <Field> (label + error state + hint).
|
|
54
|
+
- [NumberInput](numberinput.md) — Controlled numeric input with −/+ stepper buttons. onChange emits a NUMBER (or null when empty) — NOT an event. Drops straight into <FormField> (Form handles the non-event value). Clamps to min/max on blur; keyboard ArrowUp/Down ±step, Shift+Arrow ±step×10.
|
|
55
|
+
- [ToggleGroup](togglegroup.md) — Segmented control. CONTROLLED — the group owns the value. onChange emits the VALUE (not an event). type=single → value:string|null; type=multiple → value:string[]. Provide options[] for simple lists or <ToggleItem value> children for custom content. Distinct from Switch (boolean), ButtonGroup (layout only), RadioGroup (form radios, single only).
|
|
56
|
+
- [ToggleItem](toggleitem.md) — A single toggle button inside <ToggleGroup>. Reads selection state from the group via context.
|
|
57
|
+
- [Stepper](stepper.md) — Multi-step flow indicator + controller (onboarding/checkout/wizard). CONTROLLED by a 0-based index. Compose StepperNav (with Step indicators) and StepPanel (content shown when its index == active). Step/StepPanel take an explicit 0-based `index`. Not Tabs — Stepper is an ORDERED linear flow with completed/current/upcoming states.
|
|
58
|
+
- [StepperNav](steppernav.md) — Container for Step indicators inside <Stepper>. Lays them out per the Stepper's orientation.
|
|
59
|
+
- [Step](step.md) — One step indicator inside <StepperNav>. State (completed/current/upcoming) derives from the Stepper's active index automatically.
|
|
60
|
+
- [StepPanel](steppanel.md) — Content for one step. Renders its children only when its index equals the Stepper's active step.
|
|
61
|
+
- [EmptyState](emptystate.md) — Presentational placeholder for empty lists, tables, and search results. No state. title/description/variant/size are props; the optional call-to-action goes in children (React) or the default slot (Vue). variant picks a preset icon (default=box, search=magnifier, error=warning); pass `icon` (or #icon slot) to override.
|
|
62
|
+
- [Stat](stat.md) — Presentational dashboard KPI. No state. The arrow DIRECTION follows the sign of `delta` (the actual change: -0.4% → down arrow). The arrow/delta COLOR is set explicitly by `trend` (up=success, down=danger, neutral=muted) — so 'churn -0.4%, trend=up' shows a green DOWN arrow. Wrap several in StatGroup for an evenly-split row with dividers.
|
|
63
|
+
- [StatGroup](statgroup.md) — Evenly-split row of <Stat> with subtle dividers between items. Each Stat flexes to equal width.
|
|
64
|
+
- [Timeline](timeline.md) — Vertical activity feed for audit logs and history. Presentational — a status dot per item plus a connector line. Pass `items` for plain logs, or TimelineItem children for rich per-item content. Timeline does NOT reorder; pass items in the order you want shown.
|
|
65
|
+
- [TimelineItem](timelineitem.md) — One entry in a <Timeline>. Renders a status-colored dot (or a custom icon), a title, an optional time, and optional rich content.
|
|
66
|
+
- [Tree](tree.md) — Hierarchical tree view for file explorers and nested navigation. DATA-DRIVEN and CONTROLLED — pass a nested `data` array; the Tree renders recursively. Single selection. A node WITH children is a folder (click toggles expand); a leaf fires onSelect. Keyboard: ArrowUp/Down move, ArrowRight/Left expand/collapse, Enter/Space select.
|
|
67
|
+
- [OTPInput](otpinput.md) — Segmented one-time-code input for verification / 2FA. CONTROLLED. onChange emits the STRING value (not an event), and onComplete fires once when every slot is filled. Paste-aware (pasting a full code fills all slots), auto-advance on input, backspace moves to the previous slot, arrow keys navigate. Drops straight into <FormField>.
|
|
68
|
+
- [Carousel](carousel.md) — Accessible content slider for galleries, onboarding, and testimonials. CONTROLLED by a 0-based slide index. Compose CarouselSlide children (slide order = index). Snap scrolling, clickable dot indicators, prev/next arrows, ArrowLeft/Right keyboard, optional loop and autoPlay (autoplay pauses on hover/focus). onChange emits the index (not an event).
|
|
69
|
+
- [CarouselSlide](carouselslide.md) — One slide inside <Carousel>. Holds arbitrary content (image, Card, testimonial). Slide order determines its index.
|
|
52
70
|
- [DateRangePicker](daterangepicker.md) — Start/end date range picker. Built on Calendar (mode=range) with a friendlier { from, to } object API, a two-month side-by-side view, and preset shortcuts. Use this for report/filter date ranges; use DatePicker for a single date.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# NumberInput — AI Cheat Sheet
|
|
2
|
+
> Quick reference for Claude / Cursor / Copilot
|
|
3
|
+
|
|
4
|
+
**Controlled numeric input with −/+ stepper buttons. onChange emits a NUMBER (or null when empty) — NOT an event. Drops straight into <FormField> (Form handles the non-event value). Clamps to min/max on blur; keyboard ArrowUp/Down ±step, Shift+Arrow ±step×10.**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { NumberInput } from "@usevyre/react"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Valid Props
|
|
11
|
+
|
|
12
|
+
| Prop | Values | Default |
|
|
13
|
+
|------|--------|---------|
|
|
14
|
+
| `size` | `"sm"` \| `"md"` \| `"lg"` | `md` |
|
|
15
|
+
| `disabled` | `true` \| `false` | `false` |
|
|
16
|
+
| `readOnly` | `true` \| `false` | `false` |
|
|
17
|
+
|
|
18
|
+
## Common AI Mistakes
|
|
19
|
+
|
|
20
|
+
- ❌ `onChange={(e) => set(e.target.value)}`
|
|
21
|
+
→ onChange={(value) => set(value)} — value is number | null
|
|
22
|
+
- ❌ `Using <Input type="number"> for numeric fields`
|
|
23
|
+
→ Use <NumberInput value onChange min max step />
|
|
24
|
+
- ❌ `Parsing the value with Number() in form state`
|
|
25
|
+
→ Store the value directly; it is already number | null
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
**Quantity selector**
|
|
30
|
+
```tsx
|
|
31
|
+
const [qty, setQty] = useState<number | null>(1);
|
|
32
|
+
|
|
33
|
+
<NumberInput value={qty} onChange={setQty} min={1} max={99} />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Inside a Form**
|
|
37
|
+
```tsx
|
|
38
|
+
<FormField name="age" label="Age" rules={{ required: true, min: 18 }}>
|
|
39
|
+
<NumberInput min={0} max={120} />
|
|
40
|
+
</FormField>
|
|
41
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# OTPInput — AI Cheat Sheet
|
|
2
|
+
> Quick reference for Claude / Cursor / Copilot
|
|
3
|
+
|
|
4
|
+
**Segmented one-time-code input for verification / 2FA. CONTROLLED. onChange emits the STRING value (not an event), and onComplete fires once when every slot is filled. Paste-aware (pasting a full code fills all slots), auto-advance on input, backspace moves to the previous slot, arrow keys navigate. Drops straight into <FormField>.**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { OTPInput } from "@usevyre/react"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Valid Props
|
|
11
|
+
|
|
12
|
+
| Prop | Values | Default |
|
|
13
|
+
|------|--------|---------|
|
|
14
|
+
| `type` | `"numeric"` \| `"alphanumeric"` | `numeric` |
|
|
15
|
+
| `size` | `"sm"` \| `"md"` \| `"lg"` | `md` |
|
|
16
|
+
| `mask` | `true` \| `false` | `false` |
|
|
17
|
+
| `disabled` | `true` \| `false` | `false` |
|
|
18
|
+
| `autoFocus` | `true` \| `false` | `false` |
|
|
19
|
+
|
|
20
|
+
## Common AI Mistakes
|
|
21
|
+
|
|
22
|
+
- ❌ `onChange={(e) => set(e.target.value)}`
|
|
23
|
+
→ onChange={(value) => setCode(value)}
|
|
24
|
+
- ❌ `Six separate <Input> boxes wired by hand`
|
|
25
|
+
→ Use <OTPInput length={6} value onChange />
|
|
26
|
+
- ❌ `Reading completion by comparing length yourself`
|
|
27
|
+
→ Use onComplete={(code) => verify(code)}
|
|
28
|
+
- ❌ `type="password" to hide digits`
|
|
29
|
+
→ Use mask (type stays numeric/alphanumeric)
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
**2FA code with verify on complete**
|
|
34
|
+
```tsx
|
|
35
|
+
const [code, setCode] = useState("");
|
|
36
|
+
|
|
37
|
+
<OTPInput
|
|
38
|
+
value={code}
|
|
39
|
+
onChange={setCode}
|
|
40
|
+
onComplete={(c) => verify(c)}
|
|
41
|
+
autoFocus
|
|
42
|
+
/>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Inside a Form**
|
|
46
|
+
```tsx
|
|
47
|
+
<FormField name="otp" label="Verification code"
|
|
48
|
+
rules={{ required: true, minLength: 6 }}>
|
|
49
|
+
<OTPInput length={6} />
|
|
50
|
+
</FormField>
|
|
51
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Stat — AI Cheat Sheet
|
|
2
|
+
> Quick reference for Claude / Cursor / Copilot
|
|
3
|
+
|
|
4
|
+
**Presentational dashboard KPI. No state. The arrow DIRECTION follows the sign of `delta` (the actual change: -0.4% → down arrow). The arrow/delta COLOR is set explicitly by `trend` (up=success, down=danger, neutral=muted) — so 'churn -0.4%, trend=up' shows a green DOWN arrow. Wrap several in StatGroup for an evenly-split row with dividers.**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { Stat, StatGroup } from "@usevyre/react"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Valid Props
|
|
11
|
+
|
|
12
|
+
| Prop | Values | Default |
|
|
13
|
+
|------|--------|---------|
|
|
14
|
+
| `trend` | `"up"` \| `"down"` \| `"neutral"` | `neutral` |
|
|
15
|
+
| `size` | `"sm"` \| `"md"` \| `"lg"` | `md` |
|
|
16
|
+
|
|
17
|
+
## Common AI Mistakes
|
|
18
|
+
|
|
19
|
+
- ❌ `Assuming trend flips the arrow direction`
|
|
20
|
+
→ delta="-0.4%" always shows a down arrow; trend="up" just colors it green
|
|
21
|
+
- ❌ `Building a KPI card with Card + manual layout`
|
|
22
|
+
→ Use <Stat label value delta trend />
|
|
23
|
+
- ❌ `Laying out a KPI row with custom flex + dividers`
|
|
24
|
+
→ Wrap the Stats in <StatGroup>
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
**KPI row; note churn stays green while going down**
|
|
29
|
+
```tsx
|
|
30
|
+
<StatGroup>
|
|
31
|
+
<Stat label="Revenue" value="$48.2k" delta="+12%" trend="up" deltaLabel="vs last month" />
|
|
32
|
+
<Stat label="Churn" value="2.1%" delta="-0.4%" trend="up" deltaLabel="lower is better" />
|
|
33
|
+
<Stat label="Orders" value="1,204" delta="0%" trend="neutral" />
|
|
34
|
+
</StatGroup>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Single stat with icon**
|
|
38
|
+
```tsx
|
|
39
|
+
<Stat label="Active users" value="12,840" delta="+3.2%" trend="up"
|
|
40
|
+
icon={<UsersIcon />} size="lg" />
|
|
41
|
+
```
|