@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,219 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Fieldset
|
|
3
|
+
use_when: Grouping related form fields under one title in a bordered panel, such as an address or notification preferences.
|
|
4
|
+
instead_of: Card for content that isn't a form; CheckboxGroup or RadioGroup alone for one list of options; Separator to divide form sections without a border.
|
|
5
|
+
source: packages/core/src/components/fieldset.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Fieldset
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Fieldset is a bordered panel that groups related form controls under a FieldsetLegend and an optional FieldsetDescription. It renders a `<div>`, not a native `<fieldset>`, to avoid the legend cutting through the border line, so it has no group semantics or `disabled` behaviour of its own.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A set of fields that belong together: shipping address, personal information, billing details.
|
|
17
|
+
- Splitting a long form into titled sections.
|
|
18
|
+
- Putting a CheckboxGroup, RadioGroup or a few Switches under one title alongside related fields.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- A panel of content that isn't a form → use [Card](./card.md).
|
|
23
|
+
- Dividing form sections without a border → use [Separator](./separator.md) between them.
|
|
24
|
+
- One list of options with nothing else around it → use [CheckboxGroup](./checkbox-group.md) or [RadioGroup](./radio-group.md) with a label; they already group their items.
|
|
25
|
+
- Secondary settings the user can hide → use [Accordion](./accordion.md) or [Collapsible](./collapsible.md).
|
|
26
|
+
|
|
27
|
+
## 3. Anatomy
|
|
28
|
+
|
|
29
|
+
1. **Fieldset**: the container `<div>`. 1px `--container-border-alt` border, `--curves-lg` radius, `--spacing-lg` padding, children stacked in a column with a `--spacing-lg` gap.
|
|
30
|
+
2. **FieldsetLegend**: the group title, a `<div>`. `--font-size-base`, weight 500, line height 1, in `--container-fg`, with a `--spacing-xs` margin below.
|
|
31
|
+
3. **FieldsetDescription** (optional): a `<p>` under the legend, in `--container-fg-alt` at `--font-size-sm`.
|
|
32
|
+
4. **Fields**: one wrapper per field (Label, control, FormDescription, FormMessage) as direct children, so the gap spaces them.
|
|
33
|
+
|
|
34
|
+
## 4. Variants
|
|
35
|
+
|
|
36
|
+
Fieldset has no variants. It always draws the bordered panel.
|
|
37
|
+
|
|
38
|
+
## 5. Sizes
|
|
39
|
+
|
|
40
|
+
Fieldset has no `size` prop. Padding and gap are `--spacing-lg` and follow density.
|
|
41
|
+
|
|
42
|
+
## 6. States
|
|
43
|
+
|
|
44
|
+
| State | Looks like | Notes |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| Default | Bordered panel | Fieldset isn't interactive. |
|
|
47
|
+
| Disabled | No disabled state | There's no `disabled` prop, and the native `<fieldset disabled>` behaviour doesn't apply to a `<div>`. Set `disabled` on each control and its Label. Don't dim a wrapper with opacity, as the Disabled story does. |
|
|
48
|
+
|
|
49
|
+
## 7. Content guidelines
|
|
50
|
+
|
|
51
|
+
- Legend: a short noun phrase in sentence case naming the group: "Shipping address", "Personal information".
|
|
52
|
+
- Description: one sentence on what the group is for: "Where your order should be delivered."
|
|
53
|
+
- Don't repeat the legend in each field label: under "Shipping address", label the fields "Street address" and "City", not "Shipping street address".
|
|
54
|
+
|
|
55
|
+
| Do | Don't |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| Shipping address | SHIPPING ADDRESS: |
|
|
58
|
+
| Notification preferences | Please fill in the following fields |
|
|
59
|
+
| Where your order should be delivered. | This section contains address fields. |
|
|
60
|
+
|
|
61
|
+
## 8. Rules
|
|
62
|
+
|
|
63
|
+
1. Put FieldsetLegend first, then FieldsetDescription, then the fields.
|
|
64
|
+
2. Give the group its semantics yourself: `role="group"` and `aria-labelledby` pointing at the legend's `id`. When the Fieldset holds a single CheckboxGroup or RadioGroup, point that group's `aria-labelledby` at the legend instead and leave the Fieldset without a role.
|
|
65
|
+
3. Label every control inside. The legend names the group, not the fields.
|
|
66
|
+
4. Don't add padding inside the Fieldset or margins between its children; it pads and spaces them. Use a grid wrapper only to put fields side by side.
|
|
67
|
+
5. Disable each control individually; Fieldset can't disable its children.
|
|
68
|
+
6. Don't nest a Fieldset inside another.
|
|
69
|
+
7. Never pass `className` or `style`; they're dropped. Set width on a wrapper.
|
|
70
|
+
|
|
71
|
+
## 9. Dos and don'ts
|
|
72
|
+
|
|
73
|
+
**Do:** title the group, link the legend, and let the gap space the fields.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
<Fieldset role="group" aria-labelledby="contact-legend">
|
|
77
|
+
<FieldsetLegend id="contact-legend">Contact details</FieldsetLegend>
|
|
78
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
79
|
+
<Label htmlFor="contact-email">Email</Label>
|
|
80
|
+
<Input id="contact-email" type="email" />
|
|
81
|
+
</div>
|
|
82
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
83
|
+
<Label htmlFor="contact-phone">Phone</Label>
|
|
84
|
+
<Input id="contact-phone" type="tel" />
|
|
85
|
+
</div>
|
|
86
|
+
</Fieldset>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Don't:** use bare `<label>` elements, add margins, or pad the panel again.
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<Fieldset>
|
|
93
|
+
<FieldsetLegend>Contact details</FieldsetLegend>
|
|
94
|
+
<div style={{ padding: 16, marginTop: 12 }}>
|
|
95
|
+
<label>Email</label>
|
|
96
|
+
<Input type="email" />
|
|
97
|
+
</div>
|
|
98
|
+
</Fieldset>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Do:** disable the controls themselves.
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
<Fieldset role="group" aria-labelledby="sso-legend">
|
|
105
|
+
<FieldsetLegend id="sso-legend">Single sign-on</FieldsetLegend>
|
|
106
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
107
|
+
<Label htmlFor="sso-domain" disabled>Domain</Label>
|
|
108
|
+
<Input id="sso-domain" disabled value="acme.com" />
|
|
109
|
+
</div>
|
|
110
|
+
</Fieldset>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Don't:** fake a disabled group with opacity.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
<div style={{ opacity: 0.5, pointerEvents: "none" }}>
|
|
117
|
+
<Fieldset>
|
|
118
|
+
<FieldsetLegend>Single sign-on</FieldsetLegend>
|
|
119
|
+
<Input value="acme.com" />
|
|
120
|
+
</Fieldset>
|
|
121
|
+
</div>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 10. Accessibility
|
|
125
|
+
|
|
126
|
+
- Role: none by default; Fieldset renders a `<div>`. Add `role="group"` so screen readers announce the group when focus enters it.
|
|
127
|
+
- Label: point `aria-labelledby` at the FieldsetLegend `id`, and `aria-describedby` at the FieldsetDescription `id` if there is one.
|
|
128
|
+
- Keyboard: Fieldset isn't focusable. Tab moves through the controls inside in DOM order.
|
|
129
|
+
- Focus: handled by each control.
|
|
130
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
131
|
+
|
|
132
|
+
## 11. Behaviour
|
|
133
|
+
|
|
134
|
+
- Responsive: the panel fills its container and stacks children in one column. For fields side by side (City and Postal code), wrap them in a grid you own with `gridTemplateColumns: "1fr 1fr"` and a `--spacing-md` gap, as the docs example does.
|
|
135
|
+
- Spacing: the legend's `--spacing-xs` margin adds to the `--spacing-lg` gap, so the space under the legend is slightly larger than between fields. Don't add your own.
|
|
136
|
+
- Overflow: the legend has line height 1; keep it to one line.
|
|
137
|
+
- Motion: none.
|
|
138
|
+
|
|
139
|
+
## 12. API
|
|
140
|
+
|
|
141
|
+
<!-- api:start -->
|
|
142
|
+
### Fieldset
|
|
143
|
+
|
|
144
|
+
| Prop | Type | Default | Description |
|
|
145
|
+
| --- | --- | --- | --- |
|
|
146
|
+
| `role` | `string` | | Set `"group"` to give the panel group semantics. |
|
|
147
|
+
| `aria-labelledby` | `string` | | The FieldsetLegend `id`. |
|
|
148
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | `id`, `aria-describedby`, `children`. `ref` goes to the `<div>`. |
|
|
149
|
+
|
|
150
|
+
### FieldsetLegend
|
|
151
|
+
|
|
152
|
+
| Prop | Type | Default | Description |
|
|
153
|
+
| --- | --- | --- | --- |
|
|
154
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | `id` (reference it from `aria-labelledby`), `children`. |
|
|
155
|
+
|
|
156
|
+
### FieldsetDescription
|
|
157
|
+
|
|
158
|
+
| Prop | Type | Default | Description |
|
|
159
|
+
| --- | --- | --- | --- |
|
|
160
|
+
| `...props` | `HTMLAttributes<HTMLParagraphElement>` without `className`, `style` | | `id` (reference it from `aria-describedby`), `children`. |
|
|
161
|
+
<!-- api:end -->
|
|
162
|
+
|
|
163
|
+
## 13. Examples
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import {
|
|
167
|
+
Fieldset,
|
|
168
|
+
FieldsetDescription,
|
|
169
|
+
FieldsetLegend,
|
|
170
|
+
Input,
|
|
171
|
+
Label,
|
|
172
|
+
} from "@eluan/core";
|
|
173
|
+
|
|
174
|
+
const field = { display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" } as const;
|
|
175
|
+
|
|
176
|
+
export function ShippingAddress() {
|
|
177
|
+
return (
|
|
178
|
+
<Fieldset role="group" aria-labelledby="shipping-legend" aria-describedby="shipping-description">
|
|
179
|
+
<FieldsetLegend id="shipping-legend">Shipping address</FieldsetLegend>
|
|
180
|
+
<FieldsetDescription id="shipping-description">
|
|
181
|
+
Where your order should be delivered.
|
|
182
|
+
</FieldsetDescription>
|
|
183
|
+
|
|
184
|
+
<div style={field}>
|
|
185
|
+
<Label htmlFor="street" required>Street address</Label>
|
|
186
|
+
<Input id="street" name="street" required autoComplete="street-address" placeholder="24 Zhongshan Road" />
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "var(--spacing-md)" }}>
|
|
190
|
+
<div style={field}>
|
|
191
|
+
<Label htmlFor="city" required>City</Label>
|
|
192
|
+
<Input id="city" name="city" required autoComplete="address-level2" placeholder="Hengchun" />
|
|
193
|
+
</div>
|
|
194
|
+
<div style={field}>
|
|
195
|
+
<Label htmlFor="postal-code" required>Postal code</Label>
|
|
196
|
+
<Input id="postal-code" name="postalCode" required autoComplete="postal-code" placeholder="946" />
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
<div style={field}>
|
|
201
|
+
<Label htmlFor="country" required>Country</Label>
|
|
202
|
+
<Input id="country" name="country" required autoComplete="country-name" placeholder="Taiwan" />
|
|
203
|
+
</div>
|
|
204
|
+
</Fieldset>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## 14. Related components
|
|
210
|
+
|
|
211
|
+
- [Label](./form-label.md): Label, FormDescription and FormMessage for each field inside.
|
|
212
|
+
- [CheckboxGroup](./checkbox-group.md) and [RadioGroup](./radio-group.md): option lists that often sit in a Fieldset.
|
|
213
|
+
- [Card](./card.md): a bordered panel for content that isn't a form.
|
|
214
|
+
- [Separator](./separator.md): divides sections without a panel.
|
|
215
|
+
- See [../patterns/forms.md](../patterns/forms.md) for structuring long forms.
|
|
216
|
+
|
|
217
|
+
## 15. Common agent mistakes
|
|
218
|
+
|
|
219
|
+
_Filled from evals._
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: FileInput
|
|
3
|
+
use_when: The user attaches one or more files from their device, such as a receipt, an avatar or a CSV to import.
|
|
4
|
+
instead_of: a bare native file input; ImageInput or DocumentInput (same module) when only images or only documents are allowed.
|
|
5
|
+
source: packages/core/src/components/file-input.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# FileInput
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
FileInput lets the user pick files with a button or by drag and drop, then lists what they picked with a remove control per file. It is controlled: it shows whatever is in `value` and reports every change through `onValueChange`. It has two variants, a compact button and a dropzone. The module also exports `ImageInput`, `DocumentInput`, `formatFileSize` and `getFileType`.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Attaching a file to a form: a receipt, a contract, a profile photo.
|
|
17
|
+
- Importing data from a file, such as a CSV or spreadsheet.
|
|
18
|
+
- Uploading several files at once, with drag and drop (`variant="dropzone"`).
|
|
19
|
+
- Only images or only office documents: use `ImageInput` or `DocumentInput` from this module, which preset `accept`.
|
|
20
|
+
|
|
21
|
+
### When not to use
|
|
22
|
+
|
|
23
|
+
- Showing upload progress → FileInput has none; compose [Progress](./progress.md) under it, as the WithProgress story does.
|
|
24
|
+
- A link to a file hosted elsewhere → use [Input](./input.md) with `type="url"`.
|
|
25
|
+
- Pasting the text of a file → use [Textarea](./textarea.md).
|
|
26
|
+
|
|
27
|
+
## 3. Anatomy
|
|
28
|
+
|
|
29
|
+
`variant="default"`:
|
|
30
|
+
|
|
31
|
+
1. **Native input**: a visually hidden `<input type="file">`. It receives `id`, `name`, `accept`, `aria-*` and the ref.
|
|
32
|
+
2. **Choose button**: a field-style button (`--interactive-bg`, `--interactive-border-alt` border, `--size-lg` tall) with an upload icon and the fixed label "Choose file", or "Choose files" when `maxFiles` is more than 1.
|
|
33
|
+
3. **Preview chips**: one pill per file (`--container-bg-alt`, `--container-border`) with a file icon, the truncated name and a remove button. With `showPreview={false}`, a "N files selected" count replaces them.
|
|
34
|
+
4. **Error**: a `role="alert"` line in `--destructive-fg` under the control.
|
|
35
|
+
|
|
36
|
+
`variant="dropzone"`:
|
|
37
|
+
|
|
38
|
+
1. **Dropzone**: a `<div role="button">` with a dashed 2px `--interactive-border-alt` border and `--curves-lg` corners, holding an upload icon, `dragInactiveText` (or `dragActiveText` while dragging), and hints for `maxSize` ("Max file size: 5 MB") and `maxFiles` ("Max 5 files").
|
|
39
|
+
2. **Preview rows**: one bordered row per file with a type icon (image, document, video, audio, archive or other), the name, the size and a remove button.
|
|
40
|
+
3. **Error**: as above.
|
|
41
|
+
|
|
42
|
+
## 4. Variants
|
|
43
|
+
|
|
44
|
+
| Variant | Use for |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `default` | A file field inside a form, usually one file or a few. |
|
|
47
|
+
| `dropzone` | Upload and import screens, several files, and anywhere drag and drop is expected. |
|
|
48
|
+
|
|
49
|
+
`ImageInput` (JPEG, PNG, GIF, WebP) and `DocumentInput` (PDF, Word, Excel, plain text) take the same props and variants, with `acceptedFormats` in place of `accept`.
|
|
50
|
+
|
|
51
|
+
## 5. Sizes
|
|
52
|
+
|
|
53
|
+
FileInput has no size prop. The Choose button is `--size-lg` tall; the dropzone and preview rows fill the container's width. Set width on a wrapper.
|
|
54
|
+
|
|
55
|
+
## 6. States
|
|
56
|
+
|
|
57
|
+
| State | Looks like | Notes |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| Default | Choose button, or dashed dropzone | |
|
|
60
|
+
| Hover | Choose button, dropzone and remove buttons fill with `--interactive-bg-hover`; the dropzone border doesn't change | |
|
|
61
|
+
| Drag over | Dropzone fills with `--interactive-bg-hover`, the upload icon turns `--action-primary-bg`, and the text switches to `dragActiveText` | Hover and drag-over share one surface on purpose. |
|
|
62
|
+
| Focus | The browser's own focus ring on the Choose button, the dropzone and the remove buttons | Never remove or restyle the focus ring. These controls deliberately keep the browser default, which currently meets contrast where the system outline doesn't; don't add a focus style. |
|
|
63
|
+
| Selected | Chips (default) or rows (dropzone) for each file in `value` | |
|
|
64
|
+
| Error | A `role="alert"` line: `File "name" exceeds maximum size of 5 MB` | The only built-in check is `maxSize`. The message is fixed English text. |
|
|
65
|
+
| Disabled | Default: the Choose button at 50% opacity. Dropzone: `--interactive-bg-disabled` fill, `--interactive-fg-disabled` text, not-allowed cursor, ignores drops, out of the Tab order | Preview remove buttons stay active while disabled. |
|
|
66
|
+
|
|
67
|
+
## 7. Content guidelines
|
|
68
|
+
|
|
69
|
+
- `dragInactiveText` is both the dropzone's visible prompt and its accessible name. Write it as an instruction that names the kind of file: "Drop receipts here, or click to choose".
|
|
70
|
+
- Keep `dragActiveText` short: "Release to upload".
|
|
71
|
+
- Say which types and sizes are allowed in a [FormDescription](./form-label.md) under the field: "PDF, PNG or JPG, up to 10 MB each." The dropzone shows the size and count limits but never the types; the default variant shows neither.
|
|
72
|
+
- The Choose button's label is fixed ("Choose file" or "Choose files"), so name the field with your own label above it.
|
|
73
|
+
|
|
74
|
+
| Do | Don't |
|
|
75
|
+
| --- | --- |
|
|
76
|
+
| Drop receipts here, or click to choose | Drag & drop files here, or click to select |
|
|
77
|
+
| Release to upload | DROP NOW! |
|
|
78
|
+
| PDF, PNG or JPG, up to 10 MB each. | Supported: application/pdf, image/png |
|
|
79
|
+
|
|
80
|
+
## 8. Rules
|
|
81
|
+
|
|
82
|
+
1. Control FileInput with `value` and `onValueChange`. It keeps no selection of its own; without `value`, picked files never appear.
|
|
83
|
+
2. Set `maxFiles` to accept more than one file (default 1). Don't pass `multiple`: at `maxFiles={1}` extra files are dropped. Above 1, new picks append to `value` and anything past `maxFiles` is dropped without a message.
|
|
84
|
+
3. Set `maxSize` in bytes: `10 * 1024 * 1024` for 10 MB.
|
|
85
|
+
4. Check file types in `onValueChange` too. `accept` only filters the browser's picker; dropped files skip it.
|
|
86
|
+
5. Upload from `value` yourself, for example with `FormData`. FileInput clears its native input after every pick, so a native form post sends no files and `required` never passes.
|
|
87
|
+
6. Put a visible [Label](./form-label.md) (`Label`) above the field. Its `htmlFor` reaches the hidden native input through `id`, not the Choose button.
|
|
88
|
+
7. Use `ImageInput` or `DocumentInput` for those file families, and pass MIME types in `acceptedFormats` to narrow them.
|
|
89
|
+
8. Never pass `className` or `style`; they're dropped. Put width on a wrapper.
|
|
90
|
+
|
|
91
|
+
## 9. Dos and don'ts
|
|
92
|
+
|
|
93
|
+
**Do:** control the value, limit count and size, and describe the allowed files.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
97
|
+
<Label htmlFor="receipts">Receipts</Label>
|
|
98
|
+
<FileInput
|
|
99
|
+
id="receipts"
|
|
100
|
+
variant="dropzone"
|
|
101
|
+
value={receipts}
|
|
102
|
+
onValueChange={setReceipts}
|
|
103
|
+
maxFiles={5}
|
|
104
|
+
maxSize={10 * 1024 * 1024}
|
|
105
|
+
accept="application/pdf,image/png,image/jpeg"
|
|
106
|
+
dragInactiveText="Drop receipts here, or click to choose"
|
|
107
|
+
/>
|
|
108
|
+
<FormDescription>PDF, PNG or JPG, up to 10 MB each.</FormDescription>
|
|
109
|
+
</div>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Don't:** leave it uncontrolled, use `multiple`, or rely on a native form post.
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
<form action="/api/receipts" method="post" encType="multipart/form-data">
|
|
116
|
+
<FileInput name="receipts" multiple required />
|
|
117
|
+
<button type="submit">Upload</button>
|
|
118
|
+
</form>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Do:** use the preset for images.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
<ImageInput value={photos} onValueChange={setPhotos} maxFiles={1} maxSize={2 * 1024 * 1024} />
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Don't:** hand-write the image MIME list on a plain FileInput.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<FileInput value={photos} onValueChange={setPhotos} accept="image/jpeg,image/png,image/gif,image/webp" />
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 10. Accessibility
|
|
134
|
+
|
|
135
|
+
- Role: the default variant renders a native `button` ("Choose file") beside a visually hidden native file input. The dropzone is a `<div role="button">` named by `dragInactiveText`, with `aria-disabled` when disabled. Remove buttons are named "Remove {file name}". Errors use `role="alert"` and are announced when they appear.
|
|
136
|
+
- Label: a visible label above the field, tied by `htmlFor` to the hidden input's `id`. The Choose button keeps its own name.
|
|
137
|
+
- Keyboard: Enter or Space on the Choose button or the dropzone opens the file picker. Tab then reaches each remove button. The visually hidden native input also takes a Tab stop, with no visible focus.
|
|
138
|
+
- Focus: the Choose button, the dropzone and the remove buttons show the browser's default focus ring. Don't add or change focus styles on them.
|
|
139
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
140
|
+
|
|
141
|
+
## 11. Behaviour
|
|
142
|
+
|
|
143
|
+
- Responsive: FileInput stacks its parts in a column with a `--spacing-sm` gap. The dropzone and rows fill the container; default-variant chips wrap.
|
|
144
|
+
- Overflow and truncation: file names truncate with an ellipsis, at a fixed width in chips and at the row's width in dropzone rows.
|
|
145
|
+
- Previews: every file shows an icon, including images; there are no thumbnails.
|
|
146
|
+
- Errors: one message at a time. Picking again clears it.
|
|
147
|
+
- Motion: the dropzone's background and border transition over 150ms. Don't add your own.
|
|
148
|
+
|
|
149
|
+
## 12. API
|
|
150
|
+
|
|
151
|
+
<!-- api:start -->
|
|
152
|
+
### FileInput
|
|
153
|
+
|
|
154
|
+
| Prop | Type | Default | Description |
|
|
155
|
+
| --- | --- | --- | --- |
|
|
156
|
+
| `value` | `File[]` | `[]` | The files shown in the preview. Required in practice; see Rules. |
|
|
157
|
+
| `onValueChange` | `(files: File[]) => void` | | Called with the full new list after a pick, drop or remove. |
|
|
158
|
+
| `variant` | `"default" \| "dropzone"` | `"default"` | Compact button or drag-and-drop area. |
|
|
159
|
+
| `maxFiles` | `number` | `1` | Maximum files kept. Above 1, picks append and the native input allows multiple. |
|
|
160
|
+
| `maxSize` | `number` | | Maximum size per file, in bytes. Larger files are rejected with an error. |
|
|
161
|
+
| `accept` | `string` | | Filters the browser's picker (`"application/pdf,image/*"`). Doesn't filter drops. |
|
|
162
|
+
| `showPreview` | `boolean` | `true` | Shows chips or rows for selected files; `false` shows a count (default variant) or nothing (dropzone). |
|
|
163
|
+
| `dragInactiveText` | `string` | `"Drag & drop files here, or click to select"` | Dropzone prompt and accessible name. |
|
|
164
|
+
| `dragActiveText` | `string` | `"Drop files here"` | Dropzone text while a file is dragged over it. |
|
|
165
|
+
| `disabled` | `boolean` | | Disables picking and dropping. |
|
|
166
|
+
| `...props` | `InputHTMLAttributes` without `className`, `style`, `type`, `value`, `onChange` | | Spread onto the hidden native input: `id`, `name`, `aria-*`. The ref points at it too. |
|
|
167
|
+
|
|
168
|
+
### ImageInput, DocumentInput
|
|
169
|
+
|
|
170
|
+
| Prop | Type | Default | Description |
|
|
171
|
+
| --- | --- | --- | --- |
|
|
172
|
+
| `acceptedFormats` | `string[]` | ImageInput: JPEG, PNG, GIF, WebP. DocumentInput: PDF, DOC, DOCX, XLS, XLSX, TXT (as MIME types) | Joined into `accept`. |
|
|
173
|
+
| `...props` | `FileInputProps` without `accept` | | Every FileInput prop. |
|
|
174
|
+
|
|
175
|
+
### Helpers
|
|
176
|
+
|
|
177
|
+
| Prop | Type | Default | Description |
|
|
178
|
+
| --- | --- | --- | --- |
|
|
179
|
+
| `formatFileSize` | `(bytes: number) => string` | | 1024-based size with at most one decimal, in B, KB, MB or GB: `formatFileSize(5242880)` is `"5 MB"`. |
|
|
180
|
+
| `getFileType` | `(file: File) => "image" \| "document" \| "video" \| "audio" \| "archive" \| "other"` | | The file family from its MIME type, as used for the dropzone icons. Exported with the `FileType` and `FileInfo` types. |
|
|
181
|
+
<!-- api:end -->
|
|
182
|
+
|
|
183
|
+
`className` and `style` are omitted; Eluan components are styling-closed.
|
|
184
|
+
|
|
185
|
+
## 13. Examples
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import { useState, type FormEvent } from "react";
|
|
189
|
+
import { Button, FileInput, FormDescription, FormMessage, Label } from "@eluan/core";
|
|
190
|
+
|
|
191
|
+
const allowedTypes = ["application/pdf", "image/png", "image/jpeg"];
|
|
192
|
+
|
|
193
|
+
export function ReceiptUpload({ upload }: { upload: (data: FormData) => Promise<void> }) {
|
|
194
|
+
const [receipts, setReceipts] = useState<File[]>([]);
|
|
195
|
+
const [error, setError] = useState<string | null>(null);
|
|
196
|
+
|
|
197
|
+
function handleFiles(files: File[]) {
|
|
198
|
+
const allowed = files.filter((file) => allowedTypes.includes(file.type));
|
|
199
|
+
setError(allowed.length < files.length ? "Only PDF, PNG and JPG files can be attached." : null);
|
|
200
|
+
setReceipts(allowed);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
if (receipts.length === 0) return setError("Attach at least one receipt.");
|
|
206
|
+
const data = new FormData();
|
|
207
|
+
receipts.forEach((file) => data.append("receipts", file));
|
|
208
|
+
await upload(data);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<form onSubmit={handleSubmit} style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-lg)" }}>
|
|
213
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
214
|
+
<Label htmlFor="expense-receipts">Receipts</Label>
|
|
215
|
+
<FileInput
|
|
216
|
+
id="expense-receipts"
|
|
217
|
+
variant="dropzone"
|
|
218
|
+
value={receipts}
|
|
219
|
+
onValueChange={handleFiles}
|
|
220
|
+
maxFiles={5}
|
|
221
|
+
maxSize={10 * 1024 * 1024}
|
|
222
|
+
accept={allowedTypes.join(",")}
|
|
223
|
+
dragInactiveText="Drop receipts here, or click to choose"
|
|
224
|
+
dragActiveText="Release to upload"
|
|
225
|
+
/>
|
|
226
|
+
{error ? (
|
|
227
|
+
<FormMessage>{error}</FormMessage>
|
|
228
|
+
) : (
|
|
229
|
+
<FormDescription>PDF, PNG or JPG, up to 10 MB each.</FormDescription>
|
|
230
|
+
)}
|
|
231
|
+
</div>
|
|
232
|
+
<div style={{ display: "flex", justifyContent: "flex-end" }}>
|
|
233
|
+
<Button type="submit">Submit expense</Button>
|
|
234
|
+
</div>
|
|
235
|
+
</form>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## 14. Related components
|
|
241
|
+
|
|
242
|
+
- [Progress](./progress.md): upload progress, composed under FileInput.
|
|
243
|
+
- [Label](./form-label.md): `Label`, `FormDescription` and `FormMessage` around the field.
|
|
244
|
+
- [Button](./button.md): the form's submit action.
|
|
245
|
+
- See [forms](../patterns/forms.md) for field structure and errors.
|
|
246
|
+
|
|
247
|
+
## 15. Common agent mistakes
|
|
248
|
+
|
|
249
|
+
_Filled from evals._
|