@eluan/core 0.5.1 → 0.7.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 +41 -3
- package/bin/eluan.mjs +75 -0
- package/bin/lib/check.mjs +271 -0
- package/bin/lib/skill.mjs +123 -0
- package/dist/{action-popover-D6K9aVFk.cjs → action-popover-Bt7U0g8y.cjs} +1 -1
- package/dist/{action-popover-BVJQBuky.js → action-popover-jEeycwXM.js} +2 -2
- package/dist/action-popover.cjs +1 -1
- package/dist/action-popover.js +1 -1
- package/dist/{avatar-CS5f1irF.js → avatar-C1LUOzjw.js} +1 -1
- package/dist/{avatar-Co-k8KqV.cjs → avatar-SwIO4oyt.cjs} +1 -1
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +1 -1
- package/dist/badge-BLInSFM-.cjs +1 -0
- package/dist/{badge-D9NYZFWH.js → badge-Bj7i1Xf5.js} +20 -18
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/{banner-CyYFLZXw.js → banner-BqEziMp4.js} +11 -12
- package/dist/banner-C8OECYHz.cjs +1 -0
- package/dist/banner.cjs +1 -1
- package/dist/banner.js +1 -1
- package/dist/box-DG-tkaYi.cjs +1 -0
- package/dist/box-DKbNgGGG.js +17 -0
- package/dist/box.cjs +1 -0
- package/dist/box.d.ts +1 -0
- package/dist/box.js +5 -0
- package/dist/{breadcrumb-NWXeCH5q.cjs → breadcrumb-BGH_YhOZ.cjs} +1 -1
- package/dist/{breadcrumb-Cm1nb9Xj.js → breadcrumb-BVXSOA4Z.js} +2 -2
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button-BUHQOcAo.cjs +1 -0
- package/dist/{button-ANAPDrvs.js → button-fCYiYUPE.js} +69 -60
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar-2s_jGUBa.cjs +76 -0
- package/dist/{calendar-BpBsomy5.js → calendar-BN9BkjO_.js} +22 -22
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.js +1 -1
- package/dist/card-CfSvhkGH.js +81 -0
- package/dist/card-DlP39QSZ.cjs +1 -0
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/{carousel-DuP0hvF-.js → carousel-BO6KUdP8.js} +1 -1
- package/dist/{carousel-BfL7oy_q.cjs → carousel-dypuabh8.cjs} +1 -1
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.js +1 -1
- package/dist/{checkbox-Bi0Kmuut.js → checkbox-CGUTGery.js} +1 -1
- package/dist/{checkbox-M8DmWKiC.cjs → checkbox-Cq9sHU_S.cjs} +1 -1
- package/dist/{checkbox-group-KBwPhjmW.cjs → checkbox-group-DGXZ4o2-.cjs} +1 -1
- package/dist/{checkbox-group-CQMEJnhD.js → checkbox-group-Tkio3IhK.js} +1 -1
- package/dist/checkbox-group.cjs +1 -1
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/{code-block-C9u140Ob.js → code-block-CAXUOKNI.js} +10 -10
- package/dist/{code-block-_dFw7Su1.cjs → code-block-Co8uGXiG.cjs} +2 -2
- package/dist/code-block.cjs +1 -1
- package/dist/code-block.js +1 -1
- package/dist/command-C50Jkuv7.js +132 -0
- package/dist/command-DqNgPVsf.cjs +9 -0
- package/dist/command.cjs +1 -1
- package/dist/command.js +1 -1
- package/dist/components/box.d.ts +12 -0
- package/dist/components/card.d.ts +7 -2
- package/dist/components/grid.d.ts +35 -0
- package/dist/components/icon.d.ts +26 -0
- package/dist/components/input.d.ts +1 -1
- package/dist/components/layout-shared.d.ts +307 -0
- package/dist/components/navigation-drawer.d.ts +25 -5
- package/dist/components/row.d.ts +18 -0
- package/dist/components/stack.d.ts +14 -0
- package/dist/components/table.d.ts +8 -4
- package/dist/components/tone-shared.d.ts +39 -0
- package/dist/components/typography.d.ts +22 -2
- package/dist/components/visually-hidden.d.ts +11 -0
- package/dist/{context-menu-Bd6m1RYU.js → context-menu-CTyczUjx.js} +34 -34
- package/dist/context-menu-oQ6xMN6t.cjs +1 -0
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.js +1 -1
- package/dist/{credit-card-input-CUqA9CX3.cjs → credit-card-input-C6oNQBAl.cjs} +1 -1
- package/dist/{credit-card-input-DN-8vaFj.js → credit-card-input-aYftFdRo.js} +1 -1
- package/dist/credit-card-input.cjs +1 -1
- package/dist/credit-card-input.js +1 -1
- package/dist/{date-picker-ni8td8Ru.js → date-picker-DK-G61Nn.js} +3 -3
- package/dist/{date-picker-DGBsfZXx.cjs → date-picker-D_aU_P3A.cjs} +1 -1
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/{datetime-picker-C1d63MaA.cjs → datetime-picker-897BvwxW.cjs} +1 -1
- package/dist/{datetime-picker-DsnHYRK-.js → datetime-picker-CECtSobs.js} +4 -4
- package/dist/datetime-picker.cjs +1 -1
- package/dist/datetime-picker.js +1 -1
- package/dist/decimal-input-B7IHYVXP.cjs +1 -0
- package/dist/decimal-input-ohejnbQg.js +177 -0
- package/dist/decimal-input.cjs +1 -1
- package/dist/decimal-input.js +1 -1
- package/dist/dialog-DIGW7qln.cjs +1 -0
- package/dist/dialog-DVhnZFqE.js +64 -0
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dropdown-menu-BV2rX_ow.cjs +1 -0
- package/dist/dropdown-menu-C6NPtU9J.js +115 -0
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/{email-input-pX0hlYV3.js → email-input-CRd87a_c.js} +1 -1
- package/dist/{email-input-DFI4h_KN.cjs → email-input-Dvj1xSzJ.cjs} +1 -1
- package/dist/email-input.cjs +1 -1
- package/dist/email-input.js +1 -1
- package/dist/{fieldset-5V8wx-KE.js → fieldset-BxINrO_H.js} +6 -6
- package/dist/fieldset-C6cahGeV.cjs +1 -0
- package/dist/fieldset.cjs +1 -1
- package/dist/fieldset.js +1 -1
- package/dist/file-input-BzYcnore.cjs +1 -0
- package/dist/{file-input-B_aBgxmT.js → file-input-Ch16hNA1.js} +55 -55
- package/dist/file-input.cjs +1 -1
- package/dist/file-input.js +1 -1
- package/dist/{footer-DB0_-IwN.cjs → footer-B-fRLhqP.cjs} +1 -1
- package/dist/{footer-B3KUIwXW.js → footer-BiiV6-ZD.js} +9 -9
- package/dist/footer.cjs +1 -1
- package/dist/footer.js +1 -1
- package/dist/grid-BDz4Xs6M.cjs +1 -0
- package/dist/grid-BX5vZjDo.js +612 -0
- package/dist/grid.cjs +1 -0
- package/dist/grid.d.ts +1 -0
- package/dist/grid.js +5 -0
- package/dist/header-CvhqGcuo.cjs +1 -0
- package/dist/{header-CDOWlOAR.js → header-DwvyTpRi.js} +22 -22
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/hover-card-BQpzaazK.js +21 -0
- package/dist/{hover-card-C5KsTSZR.cjs → hover-card-V5A1HzEu.cjs} +1 -1
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.js +1 -1
- package/dist/icon-BmLOodCQ.cjs +1 -0
- package/dist/icon-BwDfkIdR.js +153 -0
- package/dist/icon.cjs +1 -0
- package/dist/icon.d.ts +1 -0
- package/dist/icon.js +5 -0
- package/dist/index.cjs +10 -5
- package/dist/index.d.ts +6 -0
- package/dist/index.js +593 -516
- package/dist/input-Dtr0tlf7.cjs +1 -0
- package/dist/input-Zs45H33i.js +131 -0
- package/dist/input-otp-D-T32R3O.cjs +1 -0
- package/dist/{input-otp-DmEGB1nu.js → input-otp-DwdX6VlR.js} +33 -33
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +1 -1
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/layout-shared-B_1iX4Hj.js +319 -0
- package/dist/layout-shared-CsBZcT4V.cjs +1 -0
- package/dist/{menubar-F1_bhmku.js → menubar-CodcV4b7.js} +28 -28
- package/dist/menubar-bOYi1jKo.cjs +1 -0
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.js +1 -1
- package/dist/multi-select-ChfbxrG3.js +85 -0
- package/dist/multi-select-D573XqUT.cjs +1 -0
- package/dist/multi-select.cjs +1 -1
- package/dist/multi-select.js +1 -1
- package/dist/navigation-drawer-C7YYtBXz.js +198 -0
- package/dist/navigation-drawer-Cu2q1NMn.cjs +1 -0
- package/dist/navigation-drawer.cjs +1 -1
- package/dist/navigation-drawer.js +1 -1
- package/dist/{navigation-menu-BjA-PdMY.js → navigation-menu-BEp603xA.js} +16 -16
- package/dist/{navigation-menu-BtpLfxHN.cjs → navigation-menu-tw5cD7mL.cjs} +2 -2
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.js +1 -1
- package/dist/number-input-C1RS-p2C.js +66 -0
- package/dist/number-input-N3-IvxZT.cjs +1 -0
- package/dist/number-input.cjs +1 -1
- package/dist/number-input.js +1 -1
- package/dist/{pagination-4IuE_APs.cjs → pagination-C6e9oVes.cjs} +1 -1
- package/dist/{pagination-DTWRjiOm.js → pagination-XlaE-Plb.js} +32 -32
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.js +1 -1
- package/dist/{password-input-B9V45d3Q.js → password-input-CR6FT6Rh.js} +2 -2
- package/dist/{password-input-BwnlHPbX.cjs → password-input-CZ19HPZd.cjs} +1 -1
- package/dist/password-input.cjs +1 -1
- package/dist/password-input.js +1 -1
- package/dist/{phone-input-BQjZj5jI.cjs → phone-input-BZhkLmI6.cjs} +1 -1
- package/dist/{phone-input-CSBpGHvI.js → phone-input-CT9W87M7.js} +2 -2
- package/dist/phone-input.cjs +1 -1
- package/dist/phone-input.js +1 -1
- package/dist/popover-CE0n5BQv.cjs +1 -0
- package/dist/popover-CguR4kP7.js +70 -0
- package/dist/popover.cjs +1 -1
- package/dist/popover.js +1 -1
- package/dist/{progress-Dz_it5I-.js → progress-BpUNvswZ.js} +8 -7
- package/dist/progress-DSy_jRee.cjs +1 -0
- package/dist/progress.cjs +1 -1
- package/dist/progress.js +1 -1
- package/dist/providers/create-theme.d.ts +11 -2
- package/dist/providers/eluan-provider.d.ts +8 -6
- package/dist/{radio-group-C--1neiq.cjs → radio-group-9gozRouT.cjs} +1 -1
- package/dist/{radio-group-CNMPZx_2.js → radio-group-Bs9933bk.js} +6 -6
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +1 -1
- package/dist/{rich-text-BZSyuYSo.js → rich-text-CuAa5WkV.js} +21 -21
- package/dist/{rich-text-DerWxzdn.cjs → rich-text-p7H-0qE7.cjs} +2 -2
- package/dist/rich-text.cjs +1 -1
- package/dist/rich-text.js +1 -1
- package/dist/row-BYAk7G5d.js +37 -0
- package/dist/row-Bjn-GQAC.cjs +1 -0
- package/dist/row.cjs +1 -0
- package/dist/row.d.ts +1 -0
- package/dist/row.js +5 -0
- package/dist/{search-input-bFNW6oiE.js → search-input-CxKLBmii.js} +53 -53
- package/dist/{search-input-Dmmo-BEL.cjs → search-input-XmoL2YjY.cjs} +1 -1
- package/dist/search-input.cjs +1 -1
- package/dist/search-input.js +1 -1
- package/dist/select-BCDam7PR.cjs +1 -0
- package/dist/select-QgjG43ye.js +119 -0
- package/dist/select.cjs +1 -1
- package/dist/select.js +1 -1
- package/dist/sheet-BxNmBMti.cjs +1 -0
- package/dist/{sheet-D5HWF66e.js → sheet-D0hVuH9a.js} +7 -7
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.js +1 -1
- package/dist/slider-Cv7uIp4z.js +16 -0
- package/dist/slider-Dci7KGjg.cjs +1 -0
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +1 -1
- package/dist/stack-Ck1w2iJu.cjs +1 -0
- package/dist/stack-D2btWM1t.js +27 -0
- package/dist/stack.cjs +1 -0
- package/dist/stack.d.ts +1 -0
- package/dist/stack.js +5 -0
- package/dist/{stepper-D5nDwJUz.cjs → stepper-ByYKX7qw.cjs} +1 -1
- package/dist/{stepper-BtlKiHtd.js → stepper-Copsj87A.js} +4 -4
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +1 -1
- package/dist/styles.css +1205 -189
- package/dist/switch-DQ4R-gjR.cjs +1 -0
- package/dist/switch-WaESqUuN.js +9 -0
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +1 -1
- package/dist/table-YKEWGYnI.js +149 -0
- package/dist/table-zbkgP43L.cjs +1 -0
- package/dist/table.cjs +1 -1
- package/dist/table.js +1 -1
- package/dist/tabs-BwNIi7Dl.js +22 -0
- package/dist/tabs-DItFd2o9.cjs +1 -0
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/textarea-BWAPWDRt.js +8 -0
- package/dist/textarea-CniUTipL.cjs +1 -0
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +1 -1
- package/dist/{time-input-BPoFvoeM.js → time-input-CeJVQKWO.js} +68 -68
- package/dist/time-input-eVFFYo10.cjs +1 -0
- package/dist/time-input.cjs +1 -1
- package/dist/time-input.js +1 -1
- package/dist/{toast-BK0ulAzi.cjs → toast-84RpQJtn.cjs} +1 -1
- package/dist/{toast-hI3pdZ2X.js → toast-BGKaAZwf.js} +1 -1
- package/dist/toast.cjs +1 -1
- package/dist/toast.js +1 -1
- package/dist/{toggle-Dv1VZ5Le.js → toggle-CxHqX2-V.js} +11 -11
- package/dist/toggle-DrJJAflI.cjs +1 -0
- package/dist/toggle-group-DvoxSJMq.cjs +1 -0
- package/dist/{toggle-group-DE8BPZih.js → toggle-group-k-kiBnEe.js} +21 -21
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.js +1 -1
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +1 -1
- package/dist/{tooltip-DZqn4wKl.js → tooltip-1Biy6A0m.js} +3 -3
- package/dist/{tooltip-faf1dIXp.cjs → tooltip-DIerl2vz.cjs} +1 -1
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/{tree-view-CyeJR7cW.js → tree-view-Bswh2RGr.js} +37 -37
- package/dist/tree-view-DDX9QjzF.cjs +1 -0
- package/dist/tree-view.cjs +1 -1
- package/dist/tree-view.js +1 -1
- package/dist/visually-hidden-BQMRYGxP.js +14 -0
- package/dist/visually-hidden-DzxxOswl.cjs +1 -0
- package/dist/visually-hidden.cjs +1 -0
- package/dist/visually-hidden.d.ts +1 -0
- package/dist/visually-hidden.js +5 -0
- package/package.json +12 -8
- package/skills/eluan/DESIGN.md +411 -0
- package/skills/eluan/SKILL.md +202 -0
- package/skills/eluan/components/accordion.md +212 -0
- package/skills/eluan/components/action-popover.md +266 -0
- package/skills/eluan/components/aspect-ratio.md +169 -0
- package/skills/eluan/components/avatar.md +277 -0
- package/skills/eluan/components/badge.md +190 -0
- package/skills/eluan/components/banner.md +247 -0
- package/skills/eluan/components/box.md +166 -0
- package/skills/eluan/components/breadcrumb.md +240 -0
- package/skills/eluan/components/button.md +214 -0
- package/skills/eluan/components/calendar.md +192 -0
- package/skills/eluan/components/card.md +271 -0
- package/skills/eluan/components/carousel.md +274 -0
- package/skills/eluan/components/checkbox-group.md +228 -0
- package/skills/eluan/components/checkbox.md +226 -0
- package/skills/eluan/components/code-block.md +193 -0
- package/skills/eluan/components/collapsible.md +240 -0
- package/skills/eluan/components/command.md +359 -0
- package/skills/eluan/components/context-menu.md +296 -0
- package/skills/eluan/components/credit-card-input.md +217 -0
- package/skills/eluan/components/date-picker.md +255 -0
- package/skills/eluan/components/date-time-picker.md +196 -0
- package/skills/eluan/components/decimal-input.md +232 -0
- package/skills/eluan/components/dialog.md +322 -0
- package/skills/eluan/components/drawer.md +292 -0
- package/skills/eluan/components/dropdown-menu.md +450 -0
- package/skills/eluan/components/email-input.md +200 -0
- package/skills/eluan/components/fieldset.md +219 -0
- package/skills/eluan/components/file-input.md +249 -0
- package/skills/eluan/components/footer.md +290 -0
- package/skills/eluan/components/form-label.md +254 -0
- package/skills/eluan/components/grid.md +192 -0
- package/skills/eluan/components/header.md +242 -0
- package/skills/eluan/components/hover-card.md +215 -0
- package/skills/eluan/components/icon.md +161 -0
- package/skills/eluan/components/input-otp.md +227 -0
- package/skills/eluan/components/input.md +249 -0
- package/skills/eluan/components/kbd.md +216 -0
- package/skills/eluan/components/media.md +244 -0
- package/skills/eluan/components/menubar.md +300 -0
- package/skills/eluan/components/multi-select.md +221 -0
- package/skills/eluan/components/navigation-drawer.md +297 -0
- package/skills/eluan/components/navigation-menu.md +291 -0
- package/skills/eluan/components/number-input.md +190 -0
- package/skills/eluan/components/pagination.md +262 -0
- package/skills/eluan/components/password-input.md +218 -0
- package/skills/eluan/components/phone-input.md +205 -0
- package/skills/eluan/components/popover.md +250 -0
- package/skills/eluan/components/progress.md +185 -0
- package/skills/eluan/components/radio-group.md +232 -0
- package/skills/eluan/components/rich-text.md +195 -0
- package/skills/eluan/components/row.md +174 -0
- package/skills/eluan/components/scroll-area.md +203 -0
- package/skills/eluan/components/search-input.md +281 -0
- package/skills/eluan/components/segmented-control.md +201 -0
- package/skills/eluan/components/select.md +296 -0
- package/skills/eluan/components/separator.md +179 -0
- package/skills/eluan/components/sheet.md +326 -0
- package/skills/eluan/components/skeleton.md +202 -0
- package/skills/eluan/components/slider.md +195 -0
- package/skills/eluan/components/spinner.md +187 -0
- package/skills/eluan/components/stack.md +158 -0
- package/skills/eluan/components/stepper.md +236 -0
- package/skills/eluan/components/switch.md +218 -0
- package/skills/eluan/components/table.md +348 -0
- package/skills/eluan/components/tabs.md +277 -0
- package/skills/eluan/components/textarea.md +202 -0
- package/skills/eluan/components/time-input.md +181 -0
- package/skills/eluan/components/toast.md +251 -0
- package/skills/eluan/components/toggle-group.md +241 -0
- package/skills/eluan/components/toggle.md +198 -0
- package/skills/eluan/components/tooltip.md +222 -0
- package/skills/eluan/components/tree-view.md +213 -0
- package/skills/eluan/components/typography.md +210 -0
- package/skills/eluan/components/visually-hidden.md +132 -0
- package/skills/eluan/foundations/colour.md +257 -0
- package/skills/eluan/foundations/elevation.md +86 -0
- package/skills/eluan/foundations/iconography.md +70 -0
- package/skills/eluan/foundations/look.md +135 -0
- package/skills/eluan/foundations/motion.md +60 -0
- package/skills/eluan/foundations/radius.md +73 -0
- package/skills/eluan/foundations/spacing.md +98 -0
- package/skills/eluan/foundations/theming.md +212 -0
- package/skills/eluan/foundations/typography.md +169 -0
- package/skills/eluan/patterns/app-shell.md +222 -0
- package/skills/eluan/patterns/dashboard.md +249 -0
- package/skills/eluan/patterns/empty-states.md +78 -0
- package/skills/eluan/patterns/feedback.md +95 -0
- package/skills/eluan/patterns/forms.md +138 -0
- package/skills/eluan/patterns/navigation.md +96 -0
- package/skills/eluan/patterns/page-layout.md +185 -0
- package/dist/badge-DXKWztL-.cjs +0 -1
- package/dist/banner-COlEFRuK.cjs +0 -1
- package/dist/button-Ny6OF8Un.cjs +0 -1
- package/dist/calendar-7LX5YGGT.cjs +0 -76
- package/dist/card-BC_4C3ns.js +0 -70
- package/dist/card-C88--zB4.cjs +0 -1
- package/dist/command-BCl0seLL.cjs +0 -9
- package/dist/command-Chs5VlBL.js +0 -132
- package/dist/context-menu-1WehRCpR.cjs +0 -1
- package/dist/decimal-input-BLmifKF2.cjs +0 -1
- package/dist/decimal-input-yTk35W_5.js +0 -177
- package/dist/dialog-B8eWKqzS.js +0 -64
- package/dist/dialog-DWYtFhZl.cjs +0 -1
- package/dist/dropdown-menu-_h_fqgvS.cjs +0 -1
- package/dist/dropdown-menu-p0NkOoTP.js +0 -115
- package/dist/fieldset-C3aAINhi.cjs +0 -1
- package/dist/file-input-D62FEnKg.cjs +0 -1
- package/dist/header-CiZQY_7S.cjs +0 -1
- package/dist/hover-card-C_FCzE41.js +0 -21
- package/dist/input-BrGJn-D9.cjs +0 -1
- package/dist/input-Cccufiqn.js +0 -128
- package/dist/input-otp-DcZ7wyjs.cjs +0 -1
- package/dist/menubar-CKWQEl7c.cjs +0 -1
- package/dist/multi-select-B6NBbDCW.js +0 -85
- package/dist/multi-select-kcoUbSwE.cjs +0 -1
- package/dist/navigation-drawer-BbeDYPhu.js +0 -171
- package/dist/navigation-drawer-DOOHfbY3.cjs +0 -1
- package/dist/number-input-Bc7jUsu-.cjs +0 -1
- package/dist/number-input-vICbRc2y.js +0 -66
- package/dist/popover-DPc4rRsR.js +0 -70
- package/dist/popover-Db6VOysz.cjs +0 -1
- package/dist/progress-DpQjGEyn.cjs +0 -1
- package/dist/select-1Eb3NSrR.cjs +0 -1
- package/dist/select-DDSYjKtj.js +0 -119
- package/dist/sheet-7NP1LuHy.cjs +0 -1
- package/dist/slider-CZQBAXup.js +0 -16
- package/dist/slider-DdEOapYP.cjs +0 -1
- package/dist/switch-C7EBLT5H.js +0 -9
- package/dist/switch-KzBijHMJ.cjs +0 -1
- package/dist/table-DopzfXYj.js +0 -101
- package/dist/table-xNu_KUaU.cjs +0 -1
- package/dist/tabs-C9NKBmH0.js +0 -22
- package/dist/tabs-DztJ2iVc.cjs +0 -1
- package/dist/textarea-DXUk1b_-.js +0 -8
- package/dist/textarea-Dl-daLHR.cjs +0 -1
- package/dist/time-input-DR2snTgB.cjs +0 -1
- package/dist/toggle-Bvh1v32T.cjs +0 -1
- package/dist/toggle-group-SyHMwO90.cjs +0 -1
- package/dist/tree-view-CNvEc1TT.cjs +0 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ContextMenu
|
|
3
|
+
use_when: Right-click or long-press on a surface (a file tile, canvas or row) should offer actions for that thing.
|
|
4
|
+
instead_of: DropdownMenu or ActionPopover for a visible actions button; Menubar for an app-wide File/Edit bar; Select to pick a value.
|
|
5
|
+
source: packages/core/src/components/context-menu.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# ContextMenu
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
ContextMenu opens a floating list of actions where the user right-clicks, or after a 700ms long-press on touch. It wraps Radix ContextMenu: the panel portals out of the page and supports items, checkbox and radio items, labels, separators, shortcut hints and submenus. It's a shortcut to actions, so the same actions must also be reachable another way. For choosing between menus, see the chooser in [DropdownMenu](./dropdown-menu.md).
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Right-click actions on an object in a workspace: a file or folder tile, a canvas layer, a kanban card.
|
|
17
|
+
- Power-user shortcuts that mirror a visible actions menu or toolbar.
|
|
18
|
+
|
|
19
|
+
### When not to use
|
|
20
|
+
|
|
21
|
+
- The only way to reach an action → use [DropdownMenu](./dropdown-menu.md) or [ActionPopover](./action-popover.md) on a visible button. Add a ContextMenu alongside it if you want.
|
|
22
|
+
- A row actions menu in a table → use [DropdownMenu](./dropdown-menu.md) or [ActionPopover](./action-popover.md) in the row.
|
|
23
|
+
- File/Edit/View menus for the whole app → use [Menubar](./menubar.md).
|
|
24
|
+
- Picking a value → use [Select](./select.md).
|
|
25
|
+
- Ordinary page text or links, where users expect the browser's own menu → leave the native menu alone.
|
|
26
|
+
|
|
27
|
+
## 3. Anatomy
|
|
28
|
+
|
|
29
|
+
1. **Root** (`ContextMenu`): holds open state. Renders no element.
|
|
30
|
+
2. **Trigger** (`ContextMenuTrigger`): the area that opens the menu on right-click or long-press. Use `asChild` around an element you own and style.
|
|
31
|
+
3. **Content** (`ContextMenuContent`): the floating panel at the pointer, portalled to the nearest `PortalContainerProvider` container or `document.body`. `--container-bg` surface, `--container-border` border, `--curves-md` radius, `--spacing-xxs` padding, minimum width 8rem.
|
|
32
|
+
4. **Item** (`ContextMenuItem`): one action row, `--font-size-sm`, `--curves-sm` radius.
|
|
33
|
+
5. **Checkbox item** (`ContextMenuCheckboxItem`): shows a tick in a leading indicator slot when checked.
|
|
34
|
+
6. **Radio group and radio item** (`ContextMenuRadioGroup`, `ContextMenuRadioItem`): single choice, with a filled dot in the leading slot.
|
|
35
|
+
7. **Label** (`ContextMenuLabel`): a non-interactive group heading, weight 600, `--interactive-fg`.
|
|
36
|
+
8. **Separator** (`ContextMenuSeparator`): a 1px `--container-border` line between groups.
|
|
37
|
+
9. **Shortcut** (`ContextMenuShortcut`): trailing hint text at `--font-size-xs` in `--interactive-fg-alt`. Display only; it binds no keys.
|
|
38
|
+
10. **Group** (`ContextMenuGroup`): wraps related items.
|
|
39
|
+
11. **Submenu** (`ContextMenuSub`, `ContextMenuSubTrigger`, `ContextMenuSubContent`): a nested panel; the sub-trigger adds a trailing chevron.
|
|
40
|
+
12. **Portal** (`ContextMenuPortal`): the Radix portal, re-exported. Content already portals.
|
|
41
|
+
|
|
42
|
+
## 4. Variants
|
|
43
|
+
|
|
44
|
+
ContextMenu has no variants. Items have no `tone`; only `DropdownMenuItem` has a destructive tone.
|
|
45
|
+
|
|
46
|
+
## 5. Sizes
|
|
47
|
+
|
|
48
|
+
ContextMenu has no size prop. Item text is `--font-size-sm` and padding comes from `--spacing-*`, so the menu follows the density axis.
|
|
49
|
+
|
|
50
|
+
## 6. States
|
|
51
|
+
|
|
52
|
+
| State | Looks like | Notes |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| Default | Items inherit `--container-fg` on `--container-bg` | |
|
|
55
|
+
| Hover | Item row fills `--interactive-bg-hover` with `--interactive-fg` text | Pointing at an item focuses it, so hover and keyboard focus look the same. |
|
|
56
|
+
| Focus | The highlighted row, no outline | Never remove or restyle the focus ring. |
|
|
57
|
+
| Open | A sub-trigger with its submenu open keeps the `--interactive-bg-hover` fill | |
|
|
58
|
+
| Checked | A tick (checkbox) or filled dot (radio) in the leading slot | Checkbox and radio items reserve the leading slot even when unchecked. |
|
|
59
|
+
| Disabled | `--interactive-bg-disabled` fill, `--interactive-fg-disabled` text, no pointer events | Arrow keys skip disabled items. |
|
|
60
|
+
|
|
61
|
+
## 7. Content guidelines
|
|
62
|
+
|
|
63
|
+
- Start action labels with a verb: "Rename…", "Duplicate", "Move to trash".
|
|
64
|
+
- Use sentence case and keep labels to one to four words.
|
|
65
|
+
- Match the labels of the visible actions menu exactly, so both routes read the same.
|
|
66
|
+
- End a label with an ellipsis (…) only when it opens a dialog that asks for more input.
|
|
67
|
+
- Put destructive actions last, after a separator.
|
|
68
|
+
- Show a shortcut only if it works elsewhere in the app: "⌘C", "⌫".
|
|
69
|
+
|
|
70
|
+
| Do | Don't |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| Move to trash | Trash it |
|
|
73
|
+
| Rename… | Edit name of this file |
|
|
74
|
+
| Copy link | Link |
|
|
75
|
+
|
|
76
|
+
## 8. Rules
|
|
77
|
+
|
|
78
|
+
1. Offer every ContextMenu action somewhere visible too: a [DropdownMenu](./dropdown-menu.md), [ActionPopover](./action-popover.md) or toolbar Button inside or next to the target. Right-click is hidden from touch-only and keyboard users.
|
|
79
|
+
2. Wrap the target with `<ContextMenuTrigger asChild>` around an element you own, and style that element. Don't pass `style` to the trigger.
|
|
80
|
+
3. Put destructive actions last, after a separator, and confirm them in a [Dialog](./dialog.md). ContextMenu has no destructive tone; don't colour the item yourself.
|
|
81
|
+
4. Run actions in `onSelect`. Call `event.preventDefault()` in `onSelect` to keep the menu open while toggling checkbox or radio items.
|
|
82
|
+
5. Never pass `className` or `style` to any part. Pass `container` on `ContextMenuContent` when a scoped theme must reach the panel (see [theming](../foundations/theming.md)).
|
|
83
|
+
|
|
84
|
+
## 9. Dos and don'ts
|
|
85
|
+
|
|
86
|
+
**Do:** put the target in an element you own and mirror the actions on a visible button.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
<ContextMenu>
|
|
90
|
+
<ContextMenuTrigger asChild>
|
|
91
|
+
<div style={{ display: "flex", gap: "var(--spacing-sm)", padding: "var(--spacing-md)", borderRadius: "var(--curves-md)" }}>
|
|
92
|
+
<span>Q3 report.pdf</span>
|
|
93
|
+
<ActionPopover aria-label="Actions for Q3 report.pdf" items={fileActions} />
|
|
94
|
+
</div>
|
|
95
|
+
</ContextMenuTrigger>
|
|
96
|
+
<ContextMenuContent>
|
|
97
|
+
<ContextMenuItem onSelect={onRename}>Rename…</ContextMenuItem>
|
|
98
|
+
</ContextMenuContent>
|
|
99
|
+
</ContextMenu>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Don't:** style the trigger directly or make right-click the only route.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<ContextMenu>
|
|
106
|
+
<ContextMenuTrigger style={{ height: "8rem", border: "1px dashed #ccc" }}>
|
|
107
|
+
Right-click here
|
|
108
|
+
</ContextMenuTrigger>
|
|
109
|
+
<ContextMenuContent>
|
|
110
|
+
<ContextMenuItem>Rename</ContextMenuItem>
|
|
111
|
+
</ContextMenuContent>
|
|
112
|
+
</ContextMenu>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Do:** separate destructive actions at the end.
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
<ContextMenuContent>
|
|
119
|
+
<ContextMenuItem onSelect={onDuplicate}>Duplicate</ContextMenuItem>
|
|
120
|
+
<ContextMenuSeparator />
|
|
121
|
+
<ContextMenuItem onSelect={() => setConfirmOpen(true)}>Move to trash</ContextMenuItem>
|
|
122
|
+
</ContextMenuContent>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Don't:** mix them in and recolour them.
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<ContextMenuContent>
|
|
129
|
+
<ContextMenuItem onSelect={trashFile}>
|
|
130
|
+
<span style={{ color: "var(--destructive-fg)" }}>Move to trash</span>
|
|
131
|
+
</ContextMenuItem>
|
|
132
|
+
<ContextMenuItem onSelect={onDuplicate}>Duplicate</ContextMenuItem>
|
|
133
|
+
</ContextMenuContent>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## 10. Accessibility
|
|
137
|
+
|
|
138
|
+
- Role: the content is `menu`; items are `menuitem`, `menuitemcheckbox` or `menuitemradio`. The trigger adds no role; it keeps your element's role.
|
|
139
|
+
- Label: items are named by their text.
|
|
140
|
+
- Keyboard: the menu opens on the trigger's `contextmenu` event; give keyboard users the visible actions menu (Rule 1). Inside the menu, ArrowUp and ArrowDown move between items, Home and End jump to the ends, typing a letter jumps to a matching item, Enter or Space selects, ArrowRight opens a submenu, ArrowLeft closes it and Escape closes the menu.
|
|
141
|
+
- Focus: opening moves focus into the menu. The menu is modal by default (`modal`), so outside pointer interaction is blocked while it is open.
|
|
142
|
+
- Touch: a 700ms long-press opens the menu; moving the finger cancels it.
|
|
143
|
+
- Contrast: handled by the theme. Don't override colours. The focused item is shown only by its `--interactive-bg-hover` fill, which is faint by design; don't patch it per menu.
|
|
144
|
+
|
|
145
|
+
## 11. Behaviour
|
|
146
|
+
|
|
147
|
+
- Positioning: the panel opens at the pointer and flips to stay on screen.
|
|
148
|
+
- Responsive: no breakpoint behaviour. The panel is at least 8rem wide.
|
|
149
|
+
- Overflow and truncation: no maximum height or scroll. Keep menus short.
|
|
150
|
+
- Closing: selecting an item closes the menu unless `onSelect` calls `event.preventDefault()`. Escape and outside clicks close it.
|
|
151
|
+
- Disabled trigger: `disabled` on `ContextMenuTrigger` restores the browser's native menu.
|
|
152
|
+
- Motion: none. Don't add any.
|
|
153
|
+
|
|
154
|
+
## 12. API
|
|
155
|
+
|
|
156
|
+
<!-- api:start -->
|
|
157
|
+
### ContextMenu
|
|
158
|
+
|
|
159
|
+
| Prop | Type | Default | Description |
|
|
160
|
+
| --- | --- | --- | --- |
|
|
161
|
+
| `onOpenChange` | `(open: boolean) => void` | | Called when the menu opens or closes. |
|
|
162
|
+
| `modal` | `boolean` | `true` | Blocks outside interaction while open. |
|
|
163
|
+
| `...props` | Radix `ContextMenu.Root` props | | `dir`. There is no controlled `open`; the pointer opens it. |
|
|
164
|
+
|
|
165
|
+
### ContextMenuTrigger
|
|
166
|
+
|
|
167
|
+
| Prop | Type | Default | Description |
|
|
168
|
+
| --- | --- | --- | --- |
|
|
169
|
+
| `asChild` | `boolean` | `false` | Renders your child as the trigger area. |
|
|
170
|
+
| `disabled` | `boolean` | `false` | Turns the custom menu off; the native menu shows instead. |
|
|
171
|
+
| `...props` | Radix `ContextMenu.Trigger` props | | Re-exported Radix part; renders a `<span>` without `asChild`. |
|
|
172
|
+
|
|
173
|
+
### ContextMenuContent
|
|
174
|
+
|
|
175
|
+
| Prop | Type | Default | Description |
|
|
176
|
+
| --- | --- | --- | --- |
|
|
177
|
+
| `container` | `HTMLElement \| null` | provider container, then `document.body` | Element to portal into. |
|
|
178
|
+
| `loop` | `boolean` | `false` | Wraps arrow-key focus from last to first item. |
|
|
179
|
+
| `...props` | Radix `ContextMenu.Content` props without `className`, `style` | | `alignOffset`, `collisionPadding`, `onEscapeKeyDown`, `onCloseAutoFocus`. |
|
|
180
|
+
|
|
181
|
+
### ContextMenuItem, ContextMenuLabel, ContextMenuSubTrigger
|
|
182
|
+
|
|
183
|
+
| Prop | Type | Default | Description |
|
|
184
|
+
| --- | --- | --- | --- |
|
|
185
|
+
| `inset` | `boolean` | `false` | Adds left padding to line up with checkbox and radio items. |
|
|
186
|
+
| `onSelect` (Item) | `(event: Event) => void` | | Runs the action; `event.preventDefault()` keeps the menu open. |
|
|
187
|
+
| `disabled` (Item, SubTrigger) | `boolean` | `false` | Skipped by the keyboard, not clickable. |
|
|
188
|
+
| `...props` | Radix `Item` / `Label` / `SubTrigger` props without `className`, `style` | | `asChild`, `textValue`. |
|
|
189
|
+
|
|
190
|
+
### ContextMenuCheckboxItem, ContextMenuRadioGroup, ContextMenuRadioItem
|
|
191
|
+
|
|
192
|
+
| Prop | Type | Default | Description |
|
|
193
|
+
| --- | --- | --- | --- |
|
|
194
|
+
| `checked` (CheckboxItem) | `boolean \| "indeterminate"` | | Checked state. |
|
|
195
|
+
| `onCheckedChange` (CheckboxItem) | `(checked: boolean) => void` | | Called when toggled. |
|
|
196
|
+
| `value`, `onValueChange` (RadioGroup) | `string`, `(value: string) => void` | | Selected value and change handler. |
|
|
197
|
+
| `value` (RadioItem) | `string` | | Required. The item's value. |
|
|
198
|
+
| `...props` | Radix props without `className`, `style` | | `disabled`, `onSelect`. |
|
|
199
|
+
|
|
200
|
+
### ContextMenuSub, ContextMenuSubContent, ContextMenuSeparator, ContextMenuShortcut, ContextMenuGroup, ContextMenuPortal
|
|
201
|
+
|
|
202
|
+
| Prop | Type | Default | Description |
|
|
203
|
+
| --- | --- | --- | --- |
|
|
204
|
+
| `open`, `defaultOpen`, `onOpenChange` (Sub) | `boolean`, `boolean`, `(open: boolean) => void` | | Submenu open state. |
|
|
205
|
+
| `...props` (SubContent, Separator) | Radix props without `className`, `style` | | `sideOffset`, `loop` on SubContent. |
|
|
206
|
+
| `...props` (Shortcut) | `HTMLAttributes<HTMLSpanElement>` without `className`, `style` | | Renders a `<span>`. |
|
|
207
|
+
| `...props` (Group, Portal) | Radix `Group` / `Portal` props | | Re-exported Radix parts. |
|
|
208
|
+
|
|
209
|
+
`className` and `style` are omitted from every wrapped part. The re-exported Radix parts (Trigger, Group, Portal, Sub, RadioGroup) still forward them; don't pass them there either.
|
|
210
|
+
<!-- api:end -->
|
|
211
|
+
|
|
212
|
+
## 13. Examples
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import * as React from "react";
|
|
216
|
+
import {
|
|
217
|
+
ActionPopover,
|
|
218
|
+
ContextMenu,
|
|
219
|
+
ContextMenuCheckboxItem,
|
|
220
|
+
ContextMenuContent,
|
|
221
|
+
ContextMenuItem,
|
|
222
|
+
ContextMenuSeparator,
|
|
223
|
+
ContextMenuShortcut,
|
|
224
|
+
ContextMenuTrigger,
|
|
225
|
+
} from "@eluan/core";
|
|
226
|
+
|
|
227
|
+
export function FileTile({
|
|
228
|
+
name,
|
|
229
|
+
pinned,
|
|
230
|
+
onOpen,
|
|
231
|
+
onRename,
|
|
232
|
+
onTogglePin,
|
|
233
|
+
onTrash,
|
|
234
|
+
}: {
|
|
235
|
+
name: string;
|
|
236
|
+
pinned: boolean;
|
|
237
|
+
onOpen: () => void;
|
|
238
|
+
onRename: () => void;
|
|
239
|
+
onTogglePin: (pinned: boolean) => void;
|
|
240
|
+
onTrash: () => void;
|
|
241
|
+
}) {
|
|
242
|
+
return (
|
|
243
|
+
<ContextMenu>
|
|
244
|
+
<ContextMenuTrigger asChild>
|
|
245
|
+
<div
|
|
246
|
+
style={{
|
|
247
|
+
display: "flex",
|
|
248
|
+
alignItems: "center",
|
|
249
|
+
justifyContent: "space-between",
|
|
250
|
+
gap: "var(--spacing-sm)",
|
|
251
|
+
padding: "var(--spacing-md)",
|
|
252
|
+
borderRadius: "var(--curves-md)",
|
|
253
|
+
backgroundColor: "var(--container-bg-alt)",
|
|
254
|
+
color: "var(--container-fg)",
|
|
255
|
+
fontSize: "var(--font-size-sm)",
|
|
256
|
+
}}
|
|
257
|
+
>
|
|
258
|
+
<span>{name}</span>
|
|
259
|
+
<ActionPopover
|
|
260
|
+
aria-label={`Actions for ${name}`}
|
|
261
|
+
items={[
|
|
262
|
+
{ label: "Open", onClick: onOpen },
|
|
263
|
+
{ label: "Rename…", onClick: onRename },
|
|
264
|
+
{ label: "Move to trash", onClick: onTrash, destructive: true },
|
|
265
|
+
]}
|
|
266
|
+
/>
|
|
267
|
+
</div>
|
|
268
|
+
</ContextMenuTrigger>
|
|
269
|
+
<ContextMenuContent>
|
|
270
|
+
<ContextMenuItem onSelect={onOpen}>
|
|
271
|
+
Open
|
|
272
|
+
<ContextMenuShortcut>⌘O</ContextMenuShortcut>
|
|
273
|
+
</ContextMenuItem>
|
|
274
|
+
<ContextMenuItem onSelect={onRename}>Rename…</ContextMenuItem>
|
|
275
|
+
<ContextMenuSeparator />
|
|
276
|
+
<ContextMenuCheckboxItem checked={pinned} onCheckedChange={onTogglePin}>
|
|
277
|
+
Pin to top
|
|
278
|
+
</ContextMenuCheckboxItem>
|
|
279
|
+
<ContextMenuSeparator />
|
|
280
|
+
<ContextMenuItem onSelect={onTrash}>Move to trash</ContextMenuItem>
|
|
281
|
+
</ContextMenuContent>
|
|
282
|
+
</ContextMenu>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## 14. Related components
|
|
288
|
+
|
|
289
|
+
- [DropdownMenu](./dropdown-menu.md): the same actions on a visible trigger, and the chooser for all menus.
|
|
290
|
+
- [ActionPopover](./action-popover.md): a compact visible actions button to pair with a ContextMenu.
|
|
291
|
+
- [Menubar](./menubar.md): app-wide menus in a persistent bar.
|
|
292
|
+
- [Dialog](./dialog.md): confirms destructive actions.
|
|
293
|
+
|
|
294
|
+
## 15. Common agent mistakes
|
|
295
|
+
|
|
296
|
+
_Filled from evals._
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: CreditCardInput
|
|
3
|
+
use_when: Your app collects card number, expiry and security code in its own fields and needs formatting and brand detection.
|
|
4
|
+
instead_of: Your payment provider's hosted card fields when it offers them; Input for any other text; NumberInput for quantities.
|
|
5
|
+
source: packages/core/src/components/credit-card-input.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# CreditCardInput
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
CreditCardInput is a labelled group of three [Input](./input.md)-based fields: card number (grouped by brand, with the detected brand's logo), expiry (MM/YY) and security code (3 digits, 4 for American Express). It reports all three, the brand and a length-based `isValid` through `onCardChange`. The three fields are also exported on their own for custom layouts.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A checkout or billing form where your app collects card details in its own fields.
|
|
17
|
+
- A custom layout of the same fields, with visible labels, using CreditCardNumberInput, CreditCardExpiryInput and CreditCardCVVInput.
|
|
18
|
+
|
|
19
|
+
### When not to use
|
|
20
|
+
|
|
21
|
+
- Your payment provider offers hosted or embedded card fields → use those, so raw card data never passes through your app.
|
|
22
|
+
- Any other text → use [Input](./input.md).
|
|
23
|
+
- A numeric amount to charge → use [DecimalInput](./decimal-input.md) (`CurrencyInput`).
|
|
24
|
+
|
|
25
|
+
CreditCardInput earns its place through masking and formatting: brand-specific digit groups, the MM/YY slash, brand detection and per-brand length limits. Its validation only checks lengths.
|
|
26
|
+
|
|
27
|
+
## 3. Anatomy
|
|
28
|
+
|
|
29
|
+
1. **Group**: a `role="group"` container named "Credit card details". The number field spans the full width; expiry and security code share a two-column row below. Gaps are `--spacing-md`.
|
|
30
|
+
2. **Card number field**: leading card icon, digits in groups, trailing brand logo (or a generic card icon until a brand is detected).
|
|
31
|
+
3. **Expiry field**: leading calendar icon, MM/YY.
|
|
32
|
+
4. **Security code field**: leading lock icon, 3 or 4 digits.
|
|
33
|
+
5. **Error messages**: one visually hidden `role="alert"` message per field ("Enter a valid card number", "Enter a valid expiration date", "Enter a valid security code").
|
|
34
|
+
|
|
35
|
+
The composite shows no visible labels; each field is named with `aria-label` and shows a placeholder.
|
|
36
|
+
|
|
37
|
+
## 4. Variants
|
|
38
|
+
|
|
39
|
+
| Export | Use for |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| `CreditCardInput` | The complete group, with validation and one `onCardChange`. |
|
|
42
|
+
| `CreditCardNumberInput` | Card number on its own: formatting, brand detection and logo. |
|
|
43
|
+
| `CreditCardExpiryInput` | Expiry on its own: MM/YY formatting. |
|
|
44
|
+
| `CreditCardCVVInput` | Security code on its own; pass `cardType` so its length follows the brand. |
|
|
45
|
+
|
|
46
|
+
## 5. Sizes
|
|
47
|
+
|
|
48
|
+
No size prop. Each field is `--size-lg` tall, from Input, and follows density.
|
|
49
|
+
|
|
50
|
+
## 6. States
|
|
51
|
+
|
|
52
|
+
| State | Looks like | Notes |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| Default | Three Input fields with icons and placeholders | |
|
|
55
|
+
| Focus | Border and 1px outline in `--focus-ring`, 1px offset | Never remove or restyle the focus ring. |
|
|
56
|
+
| Brand detected | The trailing icon becomes the brand logo, drawn in `currentColor` | Visa, Mastercard, American Express, Discover, Diners Club, JCB, UnionPay. |
|
|
57
|
+
| Invalid (composite) | `--destructive-border` border, `aria-invalid`, hidden message announced | Only after the user leaves a field that has content failing its length check. Sighted users see only the border colour. |
|
|
58
|
+
| Disabled | All three fields disabled | `disabled` on the composite reaches every field. |
|
|
59
|
+
|
|
60
|
+
## 7. Content guidelines
|
|
61
|
+
|
|
62
|
+
- Introduce the group with a heading or a Fieldset legend: "Payment details" or "Card".
|
|
63
|
+
- In a custom layout, label the fields "Card number", "Expiry date" and "Security code".
|
|
64
|
+
- Write card errors that say what to check: "Check the card number".
|
|
65
|
+
|
|
66
|
+
| Do | Don't |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| Card number | CC # |
|
|
69
|
+
| Security code | CVV2/CVC2/CID |
|
|
70
|
+
| Check the expiry date | Payment error |
|
|
71
|
+
|
|
72
|
+
## 8. Rules
|
|
73
|
+
|
|
74
|
+
1. Never log card data or send it anywhere but your payment provider. `onCardChange` carries the full number and security code.
|
|
75
|
+
2. Don't trust `isValid` for payment. It checks lengths only: no Luhn checksum, no month range, no past-date check. Let the provider validate.
|
|
76
|
+
3. Read card data from `onCardChange` (or each part's `onValueChange`). The fields have no `name`, so native form submission doesn't include them.
|
|
77
|
+
4. Put the composite under a heading or in a [Fieldset](./fieldset.md) with a legend. When you need visible field labels, compose the parts with Label instead.
|
|
78
|
+
5. When composing parts, pass the brand from the number field's `onValueChange` to CreditCardCVVInput's `cardType`.
|
|
79
|
+
6. Treat the parts as uncontrolled. They ignore `value`; don't pass `defaultValue`.
|
|
80
|
+
7. Keep the default `autoComplete` values (`cc-number`, `cc-exp`, `cc-csc`) so browsers and password managers can fill the card.
|
|
81
|
+
8. Never pass `className` or `style`; they're dropped. Put width on a wrapper.
|
|
82
|
+
|
|
83
|
+
## 9. Dos and don'ts
|
|
84
|
+
|
|
85
|
+
**Do:** keep card data in memory and hand it to the provider on submit.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
<CreditCardInput onCardChange={(card) => { cardRef.current = card; }} />
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Don't:** log or persist the payload.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<CreditCardInput onCardChange={(card) => console.log(card)} />
|
|
95
|
+
<CreditCardInput onCardChange={(card) => localStorage.setItem("card", JSON.stringify(card))} />
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Do:** link the brand to the security code when composing parts.
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
<CreditCardNumberInput id="card-number" onValueChange={(digits, type) => { setNumber(digits); setCardType(type); }} />
|
|
102
|
+
<CreditCardCVVInput id="card-cvc" cardType={cardType} onValueChange={setCvc} />
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Don't:** use a plain Input for card numbers.
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
<Input placeholder="Card number" maxLength={19} />
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## 10. Accessibility
|
|
112
|
+
|
|
113
|
+
- Role: the composite is a `group` named "Credit card details"; each field is a `textbox` with `inputMode="numeric"`.
|
|
114
|
+
- Labels: the fields are named "Card number", "Expiration date (MM/YY)" and "Security code (CVV)" by default. A passed `aria-label` or `aria-labelledby` replaces the default. Because the default `aria-label` outranks `<label htmlFor>`, pass `aria-labelledby` pointing at your Label's `id` when composing parts with visible labels.
|
|
115
|
+
- Errors (composite): after blur, an invalid field gets `aria-invalid` and `aria-describedby` pointing at its message, which is announced through `role="alert"`.
|
|
116
|
+
- Keyboard: standard text input; Tab moves number, expiry, security code.
|
|
117
|
+
- Brand logos and field icons are `aria-hidden`.
|
|
118
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
119
|
+
|
|
120
|
+
## 11. Behaviour
|
|
121
|
+
|
|
122
|
+
- Card number: non-digits are removed. Digits are grouped 4-4-4-4, or 4-6-5 for American Express and 4-6-4 for Diners Club, and capped at the brand's longest length (19 when unknown).
|
|
123
|
+
- Expiry: non-digits are removed and a slash is added after the month. Backspacing from just after the slash puts it straight back, so the user has to move the caret or select to delete the month.
|
|
124
|
+
- Security code: digits only, capped at 4 for American Express and 3 otherwise.
|
|
125
|
+
- Values reported are digits only: the number without spaces, the expiry as `MMYY`.
|
|
126
|
+
- `onCardChange` fires on each edit, never on mount.
|
|
127
|
+
- Responsive: the expiry and security code row stays two columns at every width.
|
|
128
|
+
- Motion: colour transitions over 150ms, from Input. Don't add your own.
|
|
129
|
+
|
|
130
|
+
## 12. API
|
|
131
|
+
|
|
132
|
+
<!-- api:start -->
|
|
133
|
+
### CreditCardInput
|
|
134
|
+
|
|
135
|
+
| Prop | Type | Default | Description |
|
|
136
|
+
| --- | --- | --- | --- |
|
|
137
|
+
| `onCardChange` | `(data: { number: string; expiry: string; cvv: string; cardType: CardType; isValid: boolean }) => void` | | Fires on every edit with digits-only values, the brand and length-based validity. |
|
|
138
|
+
| `disabled` | `boolean` | | Disables all three fields. |
|
|
139
|
+
|
|
140
|
+
Takes no other props. `ref` reaches the group `<div>`. `CardType` is `"visa" \| "mastercard" \| "amex" \| "discover" \| "diners" \| "jcb" \| "unionpay" \| "unknown"`.
|
|
141
|
+
|
|
142
|
+
### CreditCardNumberInput
|
|
143
|
+
|
|
144
|
+
| Prop | Type | Default | Description |
|
|
145
|
+
| --- | --- | --- | --- |
|
|
146
|
+
| `onValueChange` | `(value: string, cardType: CardType) => void` | | Digits without spaces, and the detected brand. |
|
|
147
|
+
| `...props` | `InputHTMLAttributes` without `className`, `style`, `size`, `type`, `onChange` | | Native attributes: `id`, `onBlur`, `required`, `aria-*`. Defaults `aria-label="Card number"`, `autoComplete="cc-number"`, a sample placeholder. `value` is ignored. |
|
|
148
|
+
|
|
149
|
+
### CreditCardExpiryInput
|
|
150
|
+
|
|
151
|
+
| Prop | Type | Default | Description |
|
|
152
|
+
| --- | --- | --- | --- |
|
|
153
|
+
| `onValueChange` | `(value: string) => void` | | Digits only, as `MMYY`. |
|
|
154
|
+
| `...props` | `InputHTMLAttributes` without `className`, `style`, `size`, `type`, `onChange` | | Defaults `aria-label="Expiration date (MM/YY)"`, `autoComplete="cc-exp"`, placeholder `MM/YY`. `value` is ignored. |
|
|
155
|
+
|
|
156
|
+
### CreditCardCVVInput
|
|
157
|
+
|
|
158
|
+
| Prop | Type | Default | Description |
|
|
159
|
+
| --- | --- | --- | --- |
|
|
160
|
+
| `cardType` | `CardType` | `"unknown"` | `"amex"` allows 4 digits; anything else allows 3. |
|
|
161
|
+
| `onValueChange` | `(value: string) => void` | | Digits only. |
|
|
162
|
+
| `...props` | `InputHTMLAttributes` without `className`, `style`, `size`, `type`, `onChange` | | Defaults `aria-label="Security code (CVV)"`, `autoComplete="cc-csc"`, `maxLength` from `cardType`. `value` is ignored. |
|
|
163
|
+
<!-- api:end -->
|
|
164
|
+
|
|
165
|
+
## 13. Examples
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import { useRef, useState, type FormEvent } from "react";
|
|
169
|
+
import { Banner, Button, CreditCardInput, Fieldset, FieldsetLegend } from "@eluan/core";
|
|
170
|
+
|
|
171
|
+
type Card = { number: string; expiry: string; cvv: string; cardType: string; isValid: boolean };
|
|
172
|
+
|
|
173
|
+
export function PaymentForm({ onPay }: { onPay: (card: Card) => Promise<string | null> }) {
|
|
174
|
+
const cardRef = useRef<Card | null>(null);
|
|
175
|
+
const [error, setError] = useState<string | null>(null);
|
|
176
|
+
|
|
177
|
+
async function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
const card = cardRef.current;
|
|
180
|
+
if (!card?.isValid) return setError("Check the card number, expiry date and security code.");
|
|
181
|
+
setError(await onPay(card));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<form onSubmit={handleSubmit} noValidate style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-lg)" }}>
|
|
186
|
+
{error && (
|
|
187
|
+
<Banner variant="destructive" position="inline" role="alert">
|
|
188
|
+
{error}
|
|
189
|
+
</Banner>
|
|
190
|
+
)}
|
|
191
|
+
<Fieldset>
|
|
192
|
+
<FieldsetLegend>Payment details</FieldsetLegend>
|
|
193
|
+
<CreditCardInput
|
|
194
|
+
onCardChange={(card) => {
|
|
195
|
+
cardRef.current = card;
|
|
196
|
+
}}
|
|
197
|
+
/>
|
|
198
|
+
</Fieldset>
|
|
199
|
+
<div style={{ display: "flex", justifyContent: "flex-end" }}>
|
|
200
|
+
<Button type="submit">Pay $49.00</Button>
|
|
201
|
+
</div>
|
|
202
|
+
</form>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## 14. Related components
|
|
208
|
+
|
|
209
|
+
- [Input](./input.md): the base field for all three parts.
|
|
210
|
+
- [Fieldset](./fieldset.md): groups the card fields under a legend.
|
|
211
|
+
- [Banner](./banner.md): a payment error for the whole form.
|
|
212
|
+
- [DecimalInput](./decimal-input.md): amounts, with CurrencyInput.
|
|
213
|
+
- [Forms pattern](../patterns/forms.md): field structure, errors and submit.
|
|
214
|
+
|
|
215
|
+
## 15. Common agent mistakes
|
|
216
|
+
|
|
217
|
+
_Filled from evals._
|