@eluan/core 0.5.0 → 0.6.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 +33 -1
- package/dist/{action-popover-D6K9aVFk.cjs → action-popover-DrHKPGqw.cjs} +1 -1
- package/dist/{action-popover-BVJQBuky.js → action-popover-NkXDAHJT.js} +1 -1
- package/dist/action-popover.cjs +1 -1
- package/dist/action-popover.js +1 -1
- package/dist/{avatar-Co-k8KqV.cjs → avatar-B-t3ctR4.cjs} +1 -1
- package/dist/{avatar-CS5f1irF.js → avatar-kDEa0rjF.js} +1 -1
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +1 -1
- package/dist/{badge-D9NYZFWH.js → badge-BLZ8V-KC.js} +10 -10
- package/dist/{badge-DXKWztL-.cjs → badge-D1A0Tc79.cjs} +1 -1
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/{banner-COlEFRuK.cjs → banner-CNdwDPqA.cjs} +1 -1
- package/dist/{banner-CyYFLZXw.js → banner-DzSp5WfQ.js} +9 -9
- 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-BuxXkm6O.cjs} +1 -1
- package/dist/{breadcrumb-Cm1nb9Xj.js → breadcrumb-C6qj-tDx.js} +1 -1
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button--_WI-fM6.cjs +1 -0
- package/dist/{button-ANAPDrvs.js → button-DNSNShUc.js} +28 -26
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/{calendar-BpBsomy5.js → calendar-BA2tSwZD.js} +6 -6
- package/dist/{calendar-7LX5YGGT.cjs → calendar-DS5821-k.cjs} +3 -3
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.js +1 -1
- package/dist/{card-C88--zB4.cjs → card-BNdR5aDa.cjs} +1 -1
- package/dist/{card-BC_4C3ns.js → card-BSgN7WSe.js} +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/{carousel-BfL7oy_q.cjs → carousel-4AERgboz.cjs} +1 -1
- package/dist/{carousel-DuP0hvF-.js → carousel-Bb7jpzep.js} +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/{command-BCl0seLL.cjs → command-D02vvta9.cjs} +1 -1
- package/dist/{command-Chs5VlBL.js → command-sUMAxm8S.js} +1 -1
- package/dist/command.cjs +1 -1
- package/dist/command.js +1 -1
- package/dist/components/box.d.ts +12 -0
- package/dist/components/grid.d.ts +35 -0
- package/dist/components/hover-card.d.ts +14 -2
- package/dist/components/icon.d.ts +26 -0
- package/dist/components/layout-shared.d.ts +307 -0
- package/dist/components/multi-select.d.ts +1 -1
- 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/tone-shared.d.ts +39 -0
- package/dist/components/tooltip.d.ts +14 -2
- package/dist/components/typography.d.ts +22 -2
- package/dist/components/visually-hidden.d.ts +11 -0
- package/dist/{credit-card-input-DN-8vaFj.js → credit-card-input-9VPlzvDm.js} +1 -1
- package/dist/{credit-card-input-CUqA9CX3.cjs → credit-card-input-DppPJBne.cjs} +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-M5hLx_1s.js} +2 -2
- package/dist/{date-picker-DGBsfZXx.cjs → date-picker-hE7cDg2B.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-BeRUPJ7s.cjs} +1 -1
- package/dist/{datetime-picker-DsnHYRK-.js → datetime-picker-CIqBZYMH.js} +3 -3
- package/dist/datetime-picker.cjs +1 -1
- package/dist/datetime-picker.js +1 -1
- package/dist/{decimal-input-yTk35W_5.js → decimal-input-Bg2BPKIr.js} +38 -38
- package/dist/decimal-input-CkTEjo2J.cjs +1 -0
- package/dist/decimal-input.cjs +1 -1
- package/dist/decimal-input.js +1 -1
- package/dist/{dialog-B8eWKqzS.js → dialog-Bsfviqvy.js} +2 -2
- package/dist/dialog-DRAoumvB.cjs +1 -0
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/{email-input-DFI4h_KN.cjs → email-input-CehmtNUq.cjs} +1 -1
- package/dist/{email-input-pX0hlYV3.js → email-input-DIiY9Q3S.js} +1 -1
- package/dist/email-input.cjs +1 -1
- package/dist/email-input.js +1 -1
- package/dist/{footer-DB0_-IwN.cjs → footer-fovIsy-0.cjs} +1 -1
- package/dist/{footer-B3KUIwXW.js → footer-jWaFq3qk.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-CDOWlOAR.js → header-Dnf8AnIx.js} +2 -2
- package/dist/{header-CiZQY_7S.cjs → header-DzItWqW4.cjs} +1 -1
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/hover-card-C5KsTSZR.cjs +1 -0
- package/dist/hover-card-C_FCzE41.js +21 -0
- 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 +612 -541
- package/dist/{input-BrGJn-D9.cjs → input-BcjL2oxv.cjs} +1 -1
- package/dist/{input-Cccufiqn.js → input-CPb9yVU5.js} +8 -8
- package/dist/input-otp-BhJ3ERrY.cjs +1 -0
- package/dist/{input-otp-DmEGB1nu.js → input-otp-CTvJztkH.js} +32 -32
- 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/multi-select-CVxkWW29.js +85 -0
- package/dist/multi-select-DBFINH3F.cjs +1 -0
- package/dist/multi-select.cjs +1 -1
- package/dist/multi-select.js +1 -1
- package/dist/navigation-drawer-BCBFtLEq.cjs +1 -0
- package/dist/navigation-drawer-BMyHXhhX.js +198 -0
- package/dist/navigation-drawer.cjs +1 -1
- package/dist/navigation-drawer.js +1 -1
- package/dist/{number-input-vICbRc2y.js → number-input-Cm9YPBOX.js} +1 -1
- package/dist/{number-input-Bc7jUsu-.cjs → number-input-Dr9MbuRV.cjs} +1 -1
- package/dist/number-input.cjs +1 -1
- package/dist/number-input.js +1 -1
- package/dist/{pagination-DTWRjiOm.js → pagination-D2tjMpVU.js} +2 -2
- package/dist/{pagination-4IuE_APs.cjs → pagination-yKmFlFMR.cjs} +1 -1
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.js +1 -1
- package/dist/{password-input-BwnlHPbX.cjs → password-input-CmHubHuU.cjs} +1 -1
- package/dist/{password-input-B9V45d3Q.js → password-input-ljwdGCO6.js} +2 -2
- package/dist/password-input.cjs +1 -1
- package/dist/password-input.js +1 -1
- package/dist/{phone-input-BQjZj5jI.cjs → phone-input-B8VksCer.cjs} +1 -1
- package/dist/{phone-input-CSBpGHvI.js → phone-input-qTL6K8rT.js} +2 -2
- package/dist/phone-input.cjs +1 -1
- package/dist/phone-input.js +1 -1
- package/dist/progress-BpdmBGaX.cjs +1 -0
- package/dist/{progress-Dz_it5I-.js → progress-ChFf9bIq.js} +1 -1
- package/dist/progress.cjs +1 -1
- package/dist/progress.js +1 -1
- package/dist/providers/create-theme.d.ts +10 -1
- package/dist/providers/eluan-provider.d.ts +2 -1
- package/dist/providers/portal-container.d.ts +1 -1
- 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-DImwK9hN.js} +1 -1
- package/dist/{rich-text-DerWxzdn.cjs → rich-text-DzHLeG7W.cjs} +1 -1
- 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-Dmmo-BEL.cjs → search-input-BKTjebg7.cjs} +1 -1
- package/dist/{search-input-bFNW6oiE.js → search-input-Dgr9kT1a.js} +1 -1
- package/dist/search-input.cjs +1 -1
- package/dist/search-input.js +1 -1
- package/dist/select-Cdh991T-.cjs +1 -0
- package/dist/{select-DDSYjKtj.js → select-Dp5AJ6I-.js} +15 -15
- package/dist/select.cjs +1 -1
- package/dist/select.js +1 -1
- package/dist/sheet-CkXjinUG.cjs +1 -0
- package/dist/{sheet-D5HWF66e.js → sheet-uiyHNKEw.js} +6 -6
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.js +1 -1
- package/dist/{slider-CZQBAXup.js → slider-BQmbh0Nl.js} +1 -1
- package/dist/{slider-DdEOapYP.cjs → slider-DK2yk-YK.cjs} +1 -1
- 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 +935 -59
- package/dist/{switch-KzBijHMJ.cjs → switch-C2OPCq5Z.cjs} +1 -1
- package/dist/{switch-C7EBLT5H.js → switch-CXBWUZcq.js} +3 -3
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +1 -1
- package/dist/{tabs-DztJ2iVc.cjs → tabs-D8p6Tr5i.cjs} +1 -1
- package/dist/{tabs-C9NKBmH0.js → tabs-TV4_2wi1.js} +9 -9
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/{textarea-Dl-daLHR.cjs → textarea-BnpQmE74.cjs} +1 -1
- package/dist/{textarea-DXUk1b_-.js → textarea-CJRmnazN.js} +1 -1
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +1 -1
- package/dist/{time-input-BPoFvoeM.js → time-input-A603mEFQ.js} +38 -38
- package/dist/time-input-qxljhdEb.cjs +1 -0
- package/dist/time-input.cjs +1 -1
- package/dist/time-input.js +1 -1
- package/dist/{toggle-Dv1VZ5Le.js → toggle-Bx3q15Pu.js} +6 -6
- package/dist/{toggle-Bvh1v32T.cjs → toggle-Z3t4jPdv.cjs} +1 -1
- package/dist/{toggle-group-SyHMwO90.cjs → toggle-group-BZIW4wJp.cjs} +1 -1
- package/dist/{toggle-group-DE8BPZih.js → toggle-group-LaZmOMx_.js} +7 -7
- 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 +23 -0
- package/dist/tooltip-faf1dIXp.cjs +1 -0
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/{tree-view-CyeJR7cW.js → tree-view-DRmm6oL6.js} +23 -23
- package/dist/tree-view-DVQyRQDg.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 +8 -8
- package/skills/eluan/DESIGN.md +409 -0
- package/skills/eluan/SKILL.md +166 -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 +270 -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 +207 -0
- package/skills/eluan/components/visually-hidden.md +132 -0
- package/skills/eluan/foundations/colour.md +252 -0
- package/skills/eluan/foundations/elevation.md +57 -0
- package/skills/eluan/foundations/iconography.md +70 -0
- package/skills/eluan/foundations/motion.md +60 -0
- package/skills/eluan/foundations/radius.md +61 -0
- package/skills/eluan/foundations/spacing.md +98 -0
- package/skills/eluan/foundations/theming.md +197 -0
- package/skills/eluan/foundations/typography.md +163 -0
- package/skills/eluan/patterns/empty-states.md +84 -0
- package/skills/eluan/patterns/feedback.md +95 -0
- package/skills/eluan/patterns/forms.md +138 -0
- package/skills/eluan/patterns/navigation.md +95 -0
- package/skills/eluan/patterns/page-layout.md +101 -0
- package/dist/button-Ny6OF8Un.cjs +0 -1
- package/dist/decimal-input-BLmifKF2.cjs +0 -1
- package/dist/dialog-DWYtFhZl.cjs +0 -1
- package/dist/hover-card-BN7Ew2Y1.js +0 -16
- package/dist/hover-card-Dft-08Ha.cjs +0 -1
- package/dist/input-otp-DcZ7wyjs.cjs +0 -1
- package/dist/multi-select-DPoOHWSC.js +0 -74
- package/dist/multi-select-fX5FXYEY.cjs +0 -1
- package/dist/navigation-drawer-BbeDYPhu.js +0 -171
- package/dist/navigation-drawer-DOOHfbY3.cjs +0 -1
- package/dist/progress-DpQjGEyn.cjs +0 -1
- package/dist/select-1Eb3NSrR.cjs +0 -1
- package/dist/sheet-7NP1LuHy.cjs +0 -1
- package/dist/time-input-DR2snTgB.cjs +0 -1
- package/dist/tooltip-BlCQKhUE.js +0 -18
- package/dist/tooltip-Cyu7fWYZ.cjs +0 -1
- package/dist/tree-view-CNvEc1TT.cjs +0 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: NumberInput
|
|
3
|
+
use_when: The user sets a count or small number with a known step, such as a quantity, with optional minus and plus buttons.
|
|
4
|
+
instead_of: DecimalInput for money, percentages and formatted decimals; Slider for approximate values on a range; Input for digits that aren't quantities.
|
|
5
|
+
source: packages/core/src/components/number-input.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# NumberInput
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
NumberInput is a numeric field: an [Input](./input.md) (`type="text"`, `inputMode="decimal"`, monospaced) between a minus and a plus stepper button. It accepts only an optional leading minus, digits and one decimal point, steps with the buttons or ArrowUp and ArrowDown, and clamps to `min` and `max` on blur. It emits a `number`.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Quantities and counts: items in a cart, seats on a plan, retry attempts.
|
|
17
|
+
- Small bounded settings where the exact value matters: page size, number of columns.
|
|
18
|
+
- A free numeric field without steppers (`showControls={false}`) that still filters characters and clamps on blur.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Plain text → use [Input](./input.md).
|
|
23
|
+
- Money, percentages, measurements, or anything that needs thousands separators or fixed decimals → use [DecimalInput](./decimal-input.md).
|
|
24
|
+
- A value on a continuous range where close enough is fine → use [Slider](./slider.md).
|
|
25
|
+
- Digits that aren't quantities (postcodes, account numbers) → use [Input](./input.md) with `inputMode="numeric"`; card numbers → [CreditCardInput](./credit-card-input.md); one-time codes → [InputOTP](./input-otp.md).
|
|
26
|
+
|
|
27
|
+
NumberInput earns its place through character filtering, stepping and clamping. It doesn't format numbers or limit decimal places.
|
|
28
|
+
|
|
29
|
+
## 3. Anatomy
|
|
30
|
+
|
|
31
|
+
1. **Decrease button**: a minus icon button on the left, named "Decrease".
|
|
32
|
+
2. **Field**: Input with centred, monospaced text.
|
|
33
|
+
3. **Increase button**: a plus icon button on the right, named "Increase".
|
|
34
|
+
|
|
35
|
+
The buttons and field share one outline: the borders between them are removed so the group reads as one control. With `showControls={false}` only the field renders, with left-aligned text.
|
|
36
|
+
|
|
37
|
+
## 4. Variants
|
|
38
|
+
|
|
39
|
+
No variant prop. `showControls` shows or hides the stepper buttons.
|
|
40
|
+
|
|
41
|
+
## 5. Sizes
|
|
42
|
+
|
|
43
|
+
No size prop. The field and the square stepper buttons are `--size-lg` and follow density.
|
|
44
|
+
|
|
45
|
+
## 6. States
|
|
46
|
+
|
|
47
|
+
| State | Looks like | Notes |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| Default | `--interactive-bg` surface, `--interactive-border-alt` outline around the group | |
|
|
50
|
+
| Hover (stepper) | `--interactive-bg-hover` on the button | |
|
|
51
|
+
| Focus | Field: border and 1px outline in `--focus-ring`, 1px offset | Never remove or restyle the focus ring. The steppers are out of the Tab order and keep the browser's default focus ring; don't add a focus style to them. |
|
|
52
|
+
| At a limit | The stepper toward the limit is disabled | When the value reaches `min` or `max`. |
|
|
53
|
+
| Disabled | Field in `--interactive-bg-disabled` and `--interactive-fg-disabled`; steppers go transparent with `--interactive-fg-disabled` and ignore hover | The transparent disabled steppers are deliberate; don't restyle them. |
|
|
54
|
+
| Error (`aria-invalid`) | `--destructive-border` border on the field | Set it yourself, with a FormMessage. |
|
|
55
|
+
|
|
56
|
+
## 7. Content guidelines
|
|
57
|
+
|
|
58
|
+
- Label with the thing being counted, with units if any: "Seats", "Retry attempts".
|
|
59
|
+
- State the range in a description: "Between 1 and 50".
|
|
60
|
+
- Use a placeholder only for an example value, or not at all.
|
|
61
|
+
|
|
62
|
+
| Do | Don't |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| Seats | Number |
|
|
65
|
+
| Between 1 and 50 | Enter a valid number |
|
|
66
|
+
|
|
67
|
+
## 8. Rules
|
|
68
|
+
|
|
69
|
+
1. Give the field a visible [Label](./form-label.md) tied with `htmlFor` and `id`.
|
|
70
|
+
2. Control it with `value` (a `number`) and `onValueChange`. Expect `undefined` when the field is empty or holds only a minus sign.
|
|
71
|
+
3. Set `min` and `max` for bounded values. The steppers stop at the bounds and blur clamps, but typing can go out of range until blur, and `onValueChange` reports the typed value meanwhile. Validate on submit.
|
|
72
|
+
4. Don't rely on native `min`, `max` or `step` validation. NumberInput doesn't pass `min` or `max` to the `<input>`.
|
|
73
|
+
5. Use whole-number steps. Fractional steps add without rounding, so `step={0.1}` can show values like `0.30000000000000004`; use DecimalInput for decimals.
|
|
74
|
+
6. Put the allowed range in a FormDescription linked with `aria-describedby`; the field doesn't expose it to assistive tech.
|
|
75
|
+
7. Never pass `className` or `style`; they're dropped. Put width on a wrapper.
|
|
76
|
+
|
|
77
|
+
## 9. Dos and don'ts
|
|
78
|
+
|
|
79
|
+
**Do:** bound the value and describe the range.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<NumberInput
|
|
83
|
+
id="seats"
|
|
84
|
+
min={1}
|
|
85
|
+
max={50}
|
|
86
|
+
value={seats}
|
|
87
|
+
onValueChange={(next) => setSeats(next ?? 1)}
|
|
88
|
+
aria-describedby="seats-range"
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Don't:** use NumberInput for prices with a fractional step.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<NumberInput step={0.01} value={price} onValueChange={setPrice} />
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Do:** keep the stepper group as it is.
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
<NumberInput id="retries" min={0} max={10} value={retries} onValueChange={setRetries} />
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Don't:** split the group with gaps or extra borders, or build your own steppers.
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<div style={{ display: "flex", gap: 8 }}>
|
|
108
|
+
<Button onClick={() => setRetries(retries - 1)}>-</Button>
|
|
109
|
+
<NumberInput showControls={false} value={retries} onValueChange={setRetries} />
|
|
110
|
+
<Button onClick={() => setRetries(retries + 1)}>+</Button>
|
|
111
|
+
</div>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 10. Accessibility
|
|
115
|
+
|
|
116
|
+
- Role: `textbox` (`type="text"` with `inputMode="decimal"`), not `spinbutton`. It has no `aria-valuemin`, `aria-valuemax` or `aria-valuenow`.
|
|
117
|
+
- Label: a Label tied by `htmlFor`/`id`. The steppers are named "Decrease" and "Increase".
|
|
118
|
+
- Keyboard: type digits; ArrowUp and ArrowDown step by `step`, clamped to `min` and `max`. Tab skips the stepper buttons (`tabIndex={-1}`).
|
|
119
|
+
- Focus: stays on the field; stepping with the arrows doesn't move it.
|
|
120
|
+
- Contrast: handled by the theme. Don't override colours. The stepper buttons keep the browser's own focus ring; leave them alone.
|
|
121
|
+
|
|
122
|
+
## 11. Behaviour
|
|
123
|
+
|
|
124
|
+
- Responsive: the group fills its container's width and the field stretches between the buttons. Constrain it with a wrapper.
|
|
125
|
+
- Stepping from an empty field starts at 0.
|
|
126
|
+
- With `clampOnBlur={false}`, an out-of-range typed value stays after blur.
|
|
127
|
+
- `allowNegative={false}` strips the minus sign as the user types.
|
|
128
|
+
- Setting `value` back to `undefined` doesn't clear the field; the component only syncs defined values. Set a number, or remount with a new `key` to reset.
|
|
129
|
+
- Motion: colour transitions over 150ms. Don't add your own.
|
|
130
|
+
|
|
131
|
+
## 12. API
|
|
132
|
+
|
|
133
|
+
<!-- api:start -->
|
|
134
|
+
| Prop | Type | Default | Description |
|
|
135
|
+
| --- | --- | --- | --- |
|
|
136
|
+
| `value` | `number` | | Controlled value. |
|
|
137
|
+
| `onValueChange` | `(value: number \| undefined) => void` | | Fires on typing, stepping and blur clamping; `undefined` when empty or `-`. |
|
|
138
|
+
| `min` | `number` | | Lower bound for stepping and blur clamping. Not passed to the `<input>`. |
|
|
139
|
+
| `max` | `number` | | Upper bound for stepping and blur clamping. Not passed to the `<input>`. |
|
|
140
|
+
| `step` | `number` | `1` | Amount the buttons and arrow keys add or subtract. |
|
|
141
|
+
| `showControls` | `boolean` | `true` | Shows the minus and plus buttons. |
|
|
142
|
+
| `allowNegative` | `boolean` | `true` | Allows a leading minus sign. |
|
|
143
|
+
| `clampOnBlur` | `boolean` | `true` | Clamps the value to `min` and `max` when the field loses focus. |
|
|
144
|
+
| `disabled` | `boolean` | | Disables the field and both buttons. |
|
|
145
|
+
| `...props` | `InputHTMLAttributes` without `className`, `style`, `size`, `type`, `value`, `onChange` | | Native input attributes: `id`, `name`, `placeholder`, `required`, `aria-*`. `ref` reaches the `<input>`. |
|
|
146
|
+
<!-- api:end -->
|
|
147
|
+
|
|
148
|
+
## 13. Examples
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { useState } from "react";
|
|
152
|
+
import { FormDescription, Label, NumberInput } from "@eluan/core";
|
|
153
|
+
|
|
154
|
+
export function SeatCountField({ onChange }: { onChange: (seats: number) => void }) {
|
|
155
|
+
const [seats, setSeats] = useState<number | undefined>(5);
|
|
156
|
+
|
|
157
|
+
function handleChange(next: number | undefined) {
|
|
158
|
+
setSeats(next);
|
|
159
|
+
if (next !== undefined) onChange(next);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
164
|
+
<Label htmlFor="plan-seats" required>Seats</Label>
|
|
165
|
+
<NumberInput
|
|
166
|
+
id="plan-seats"
|
|
167
|
+
name="seats"
|
|
168
|
+
min={1}
|
|
169
|
+
max={50}
|
|
170
|
+
allowNegative={false}
|
|
171
|
+
value={seats}
|
|
172
|
+
onValueChange={handleChange}
|
|
173
|
+
aria-describedby="plan-seats-range"
|
|
174
|
+
/>
|
|
175
|
+
<FormDescription id="plan-seats-range">Between 1 and 50. You can add more later.</FormDescription>
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## 14. Related components
|
|
182
|
+
|
|
183
|
+
- [DecimalInput](./decimal-input.md): formatted decimals, money, percentages and units.
|
|
184
|
+
- [Slider](./slider.md): a value on a range where approximate is fine.
|
|
185
|
+
- [Input](./input.md): the base field.
|
|
186
|
+
- [Forms pattern](../patterns/forms.md): field structure and validation.
|
|
187
|
+
|
|
188
|
+
## 15. Common agent mistakes
|
|
189
|
+
|
|
190
|
+
_Filled from evals._
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Pagination
|
|
3
|
+
use_when: A long list or table is split into numbered pages and the user moves between them.
|
|
4
|
+
instead_of: Tabs to switch views of the same page; Stepper for ordered steps; a "Load more" Button for feeds; Carousel for slides.
|
|
5
|
+
source: packages/core/src/components/pagination.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Pagination
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Pagination is a row of page links inside a `<nav aria-label="pagination">`: numbered pages, Previous and Next, and an ellipsis for skipped ranges. It's stateless. Your code decides the current page and which numbers to show, and gives every link an `href`.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Below a [Table](./table.md) or list of results that is split into pages: invoices, search results, audit logs.
|
|
17
|
+
- When users need to reach a specific page, or share and bookmark a page by URL.
|
|
18
|
+
|
|
19
|
+
### When not to use
|
|
20
|
+
|
|
21
|
+
- Switching between views of the same content → use [Tabs](./tabs.md) or [SegmentedControl](./segmented-control.md).
|
|
22
|
+
- Steps in a flow → use [Stepper](./stepper.md).
|
|
23
|
+
- An activity feed or timeline read top to bottom → use a [Button](./button.md) ("Load more") under the list.
|
|
24
|
+
- Slides or images → use [Carousel](./carousel.md).
|
|
25
|
+
- Fewer items than fit on one page → leave Pagination out.
|
|
26
|
+
|
|
27
|
+
## 3. Anatomy
|
|
28
|
+
|
|
29
|
+
1. **Nav** (`Pagination`): a `<nav>` landmark named "pagination". Takes the full width and centres its content.
|
|
30
|
+
2. **Content** (`PaginationContent`): a `<ul>` laid out as a row, `--spacing-xxs` apart.
|
|
31
|
+
3. **Item** (`PaginationItem`): an `<li>` holding one link or ellipsis.
|
|
32
|
+
4. **Link** (`PaginationLink`): an `<a>` drawn like a ghost button, `--curves-md` radius, `--font-size-sm`. A `--size-lg` square by default, for page numbers. `isActive` marks the current page.
|
|
33
|
+
5. **Previous and next** (`PaginationPrevious`, `PaginationNext`): links with a chevron and the fixed text "Previous" or "Next".
|
|
34
|
+
6. **Ellipsis** (`PaginationEllipsis`): a decorative "…" for a gap, or, with `pages`, a ghost icon Button that opens a [DropdownMenu](./dropdown-menu.md) of the hidden pages.
|
|
35
|
+
|
|
36
|
+
## 4. Variants
|
|
37
|
+
|
|
38
|
+
Pagination has no variants. `isActive` on a `PaginationLink` marks the current page.
|
|
39
|
+
|
|
40
|
+
## 5. Sizes
|
|
41
|
+
|
|
42
|
+
`PaginationLink` takes a `size`:
|
|
43
|
+
|
|
44
|
+
| Size | Use in |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `icon` | Page numbers (default): a `--size-lg` square. |
|
|
47
|
+
| `default` | Text links, `--size-lg` tall. Previous and Next use it. |
|
|
48
|
+
| `sm` | Dense toolbars under compact tables (`--size-md`, `--font-size-xs`). |
|
|
49
|
+
| `lg` | Rarely; a `--size-xl` tall link with `--font-size-base`. |
|
|
50
|
+
|
|
51
|
+
## 6. States
|
|
52
|
+
|
|
53
|
+
| State | Looks like | Notes |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| Default | No fill, `--interactive-fg` text | |
|
|
56
|
+
| Hover | `--interactive-bg-hover` fill | The hover text colour points at an undefined token (`interactive-fg-hover`), so the text keeps its inherited colour. No action needed. |
|
|
57
|
+
| Focus | 1px outline in `--focus-ring`, 1px offset | Never remove or restyle the focus ring. |
|
|
58
|
+
| Active | `--interactive-bg-selected` fill and border, `--interactive-fg-selected` text | Sets `aria-current="page"`. |
|
|
59
|
+
| Disabled | No disabled state | On the first page, leave out `PaginationPrevious`; on the last, leave out `PaginationNext`. |
|
|
60
|
+
|
|
61
|
+
## 7. Content guidelines
|
|
62
|
+
|
|
63
|
+
- Show page numbers as plain digits: "1", "2", "10".
|
|
64
|
+
- Show the first page, the last page, the current page and one page either side; replace each gap with an ellipsis.
|
|
65
|
+
- Previous and Next read "Previous" and "Next" and can't be relabelled; only their `aria-label` can change.
|
|
66
|
+
|
|
67
|
+
| Do | Don't |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| 1 … 4 5 6 … 20 | 1 2 3 4 5 6 7 8 9 10 11 12 … |
|
|
70
|
+
| 5 | Page 5 of 20 (inside the link) |
|
|
71
|
+
|
|
72
|
+
## 8. Rules
|
|
73
|
+
|
|
74
|
+
1. Give every `PaginationLink`, `PaginationPrevious` and `PaginationNext` an `href` for its page, such as `?page=3`. An `<a>` without `href` can't be focused and isn't a link. With a client-side router, keep the `href` and handle the click in `onClick`.
|
|
75
|
+
2. Set `isActive` on the current page's link, and only that one.
|
|
76
|
+
3. Put each link or ellipsis in its own `PaginationItem` inside `PaginationContent`.
|
|
77
|
+
4. Leave `size` at its default for page numbers. Previous and Next set their own size.
|
|
78
|
+
5. `PaginationEllipsis` menu entries aren't links; they call `onPageClick(page)`. Navigate there, and keep real links for the pages you show.
|
|
79
|
+
6. Never pass `className` or `style` to any part. Pagination centres itself in its container's full width.
|
|
80
|
+
|
|
81
|
+
## 9. Dos and don'ts
|
|
82
|
+
|
|
83
|
+
**Do:** give each page a real URL and mark the current one.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<Pagination>
|
|
87
|
+
<PaginationContent>
|
|
88
|
+
<PaginationItem>
|
|
89
|
+
<PaginationPrevious href="?page=4" />
|
|
90
|
+
</PaginationItem>
|
|
91
|
+
<PaginationItem>
|
|
92
|
+
<PaginationLink href="?page=5" isActive>5</PaginationLink>
|
|
93
|
+
</PaginationItem>
|
|
94
|
+
<PaginationItem>
|
|
95
|
+
<PaginationNext href="?page=6" />
|
|
96
|
+
</PaginationItem>
|
|
97
|
+
</PaginationContent>
|
|
98
|
+
</Pagination>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Don't:** drop the `href` and page with click handlers only.
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
<Pagination>
|
|
105
|
+
<PaginationContent>
|
|
106
|
+
<PaginationItem>
|
|
107
|
+
<PaginationLink onClick={() => setPage(5)} isActive={page === 5}>5</PaginationLink>
|
|
108
|
+
</PaginationItem>
|
|
109
|
+
</PaginationContent>
|
|
110
|
+
</Pagination>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Do:** leave out Previous on the first page.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
<PaginationContent>
|
|
117
|
+
<PaginationItem>
|
|
118
|
+
<PaginationLink href="?page=1" isActive>1</PaginationLink>
|
|
119
|
+
</PaginationItem>
|
|
120
|
+
<PaginationItem>
|
|
121
|
+
<PaginationNext href="?page=2" />
|
|
122
|
+
</PaginationItem>
|
|
123
|
+
</PaginationContent>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Don't:** render a Previous link that goes nowhere.
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
<PaginationContent>
|
|
130
|
+
<PaginationItem>
|
|
131
|
+
<PaginationPrevious href="#" />
|
|
132
|
+
</PaginationItem>
|
|
133
|
+
<PaginationItem>
|
|
134
|
+
<PaginationLink href="?page=1" isActive>1</PaginationLink>
|
|
135
|
+
</PaginationItem>
|
|
136
|
+
</PaginationContent>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 10. Accessibility
|
|
140
|
+
|
|
141
|
+
- Role: a `navigation` landmark named "pagination"; page controls are links. The current page carries `aria-current="page"`.
|
|
142
|
+
- Label: page links are named by their number. Previous and Next are named "Go to previous page" and "Go to next page"; pass `aria-label` to localise them. Give page links an `aria-label` such as "Page 5" if your screen-reader testing calls for it.
|
|
143
|
+
- Keyboard: Tab moves through the links; Enter follows one. The ellipsis menu, when it has `pages`, opens from a Button named "Show more pages" and uses DropdownMenu keys.
|
|
144
|
+
- Focus: links show the focus outline.
|
|
145
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
146
|
+
|
|
147
|
+
## 11. Behaviour
|
|
148
|
+
|
|
149
|
+
- Responsive: no breakpoint behaviour. The row doesn't wrap, so on narrow screens show fewer numbers (Previous, the current page, Next).
|
|
150
|
+
- Overflow and truncation: link labels don't wrap.
|
|
151
|
+
- State: Pagination stores nothing. Read the current page from the URL or your data layer and render the links from it.
|
|
152
|
+
- Motion: link colours transition over 150ms. Don't add more.
|
|
153
|
+
|
|
154
|
+
## 12. API
|
|
155
|
+
|
|
156
|
+
<!-- api:start -->
|
|
157
|
+
### Pagination
|
|
158
|
+
|
|
159
|
+
| Prop | Type | Default | Description |
|
|
160
|
+
| --- | --- | --- | --- |
|
|
161
|
+
| `aria-label` | `string` | `"pagination"` | Name of the navigation landmark. |
|
|
162
|
+
| `...props` | `ComponentProps<"nav">` without `className`, `style` | | |
|
|
163
|
+
|
|
164
|
+
### PaginationContent, PaginationItem
|
|
165
|
+
|
|
166
|
+
| Prop | Type | Default | Description |
|
|
167
|
+
| --- | --- | --- | --- |
|
|
168
|
+
| `...props` | `ComponentProps<"ul">` / `ComponentProps<"li">` without `className`, `style` | | |
|
|
169
|
+
|
|
170
|
+
### PaginationLink
|
|
171
|
+
|
|
172
|
+
| Prop | Type | Default | Description |
|
|
173
|
+
| --- | --- | --- | --- |
|
|
174
|
+
| `href` | `string` | | The page's URL. Always set it. |
|
|
175
|
+
| `isActive` | `boolean` | `false` | Marks the current page: selected fill and `aria-current="page"`. |
|
|
176
|
+
| `size` | `"icon" \| "default" \| "sm" \| "lg"` | `"icon"` | Square for numbers, or text sizes. |
|
|
177
|
+
| `edge` | `boolean` | `false` | Tighter gap and start padding for links with a leading chevron. Previous and Next set it. |
|
|
178
|
+
| `...props` | `ComponentProps<"a">` without `className`, `style` | | `onClick`, `aria-label`. |
|
|
179
|
+
|
|
180
|
+
### PaginationPrevious, PaginationNext
|
|
181
|
+
|
|
182
|
+
| Prop | Type | Default | Description |
|
|
183
|
+
| --- | --- | --- | --- |
|
|
184
|
+
| `href` | `string` | | The previous or next page's URL. |
|
|
185
|
+
| `aria-label` | `string` | `"Go to previous page"` / `"Go to next page"` | Accessible name. The visible text is fixed. |
|
|
186
|
+
| `...props` | `PaginationLink` props | | `size` defaults to `"default"` and `edge` to `true`. Children are ignored. |
|
|
187
|
+
|
|
188
|
+
### PaginationEllipsis
|
|
189
|
+
|
|
190
|
+
| Prop | Type | Default | Description |
|
|
191
|
+
| --- | --- | --- | --- |
|
|
192
|
+
| `pages` | `number[]` | | Hidden page numbers. When set, the ellipsis becomes a menu of "Page N" entries. |
|
|
193
|
+
| `onPageClick` | `(page: number) => void` | | Called when a page is chosen from the menu. |
|
|
194
|
+
<!-- api:end -->
|
|
195
|
+
|
|
196
|
+
## 13. Examples
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
import {
|
|
200
|
+
Pagination,
|
|
201
|
+
PaginationContent,
|
|
202
|
+
PaginationEllipsis,
|
|
203
|
+
PaginationItem,
|
|
204
|
+
PaginationLink,
|
|
205
|
+
PaginationNext,
|
|
206
|
+
PaginationPrevious,
|
|
207
|
+
} from "@eluan/core";
|
|
208
|
+
|
|
209
|
+
function pageRange(current: number, total: number): (number | "gap")[] {
|
|
210
|
+
const pages = new Set([1, total, current - 1, current, current + 1]);
|
|
211
|
+
const sorted = [...pages].filter((page) => page >= 1 && page <= total).sort((a, b) => a - b);
|
|
212
|
+
return sorted.flatMap((page, index) => (index > 0 && page - sorted[index - 1] > 1 ? ["gap", page] : [page]));
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function InvoicePagination({ currentPage, totalPages }: { currentPage: number; totalPages: number }) {
|
|
216
|
+
const href = (page: number) => `/invoices?page=${page}`;
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<div style={{ paddingBlock: "var(--spacing-lg)" }}>
|
|
220
|
+
<Pagination aria-label="Invoice pages">
|
|
221
|
+
<PaginationContent>
|
|
222
|
+
{currentPage > 1 && (
|
|
223
|
+
<PaginationItem>
|
|
224
|
+
<PaginationPrevious href={href(currentPage - 1)} />
|
|
225
|
+
</PaginationItem>
|
|
226
|
+
)}
|
|
227
|
+
{pageRange(currentPage, totalPages).map((page, index) =>
|
|
228
|
+
page === "gap" ? (
|
|
229
|
+
<PaginationItem key={`gap-${index}`}>
|
|
230
|
+
<PaginationEllipsis />
|
|
231
|
+
</PaginationItem>
|
|
232
|
+
) : (
|
|
233
|
+
<PaginationItem key={page}>
|
|
234
|
+
<PaginationLink href={href(page)} isActive={page === currentPage}>
|
|
235
|
+
{page}
|
|
236
|
+
</PaginationLink>
|
|
237
|
+
</PaginationItem>
|
|
238
|
+
)
|
|
239
|
+
)}
|
|
240
|
+
{currentPage < totalPages && (
|
|
241
|
+
<PaginationItem>
|
|
242
|
+
<PaginationNext href={href(currentPage + 1)} />
|
|
243
|
+
</PaginationItem>
|
|
244
|
+
)}
|
|
245
|
+
</PaginationContent>
|
|
246
|
+
</Pagination>
|
|
247
|
+
</div>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## 14. Related components
|
|
253
|
+
|
|
254
|
+
- [Table](./table.md): the content Pagination usually sits under.
|
|
255
|
+
- [DropdownMenu](./dropdown-menu.md): what the ellipsis opens when it has `pages`.
|
|
256
|
+
- [Button](./button.md): "Load more" for feeds.
|
|
257
|
+
- [Tabs](./tabs.md): views of one page, not pages of a list.
|
|
258
|
+
- See [navigation patterns](../patterns/navigation.md).
|
|
259
|
+
|
|
260
|
+
## 15. Common agent mistakes
|
|
261
|
+
|
|
262
|
+
_Filled from evals._
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: PasswordInput
|
|
3
|
+
use_when: The user types a password, with an optional strength meter and requirement checklist when they create one.
|
|
4
|
+
instead_of: Input for any other single-line text; InputOTP for one-time codes; EmailInput for the username field.
|
|
5
|
+
source: packages/core/src/components/password-input.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# PasswordInput
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
PasswordInput is an [Input](./input.md) with `type="password"`, which gives it a lock icon and a show/hide toggle. With `showStrengthIndicator` it adds a strength bar, a Weak/Medium/Strong label, a checklist of requirements and a polite live region that announces the strength.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Creating or changing a password, with `showStrengthIndicator` and requirements that match your password policy.
|
|
17
|
+
- Signing in, without the indicator.
|
|
18
|
+
- Any passphrase the user should be able to reveal while typing.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Any other single-line text → use [Input](./input.md).
|
|
23
|
+
- A one-time or verification code → use [InputOTP](./input-otp.md).
|
|
24
|
+
- The account identifier next to the password → use [EmailInput](./email-input.md).
|
|
25
|
+
|
|
26
|
+
PasswordInput earns its place through the strength indicator. `<Input type="password">` already draws the same lock icon and show/hide toggle, so on a sign-in form either renders the same field.
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Field**: Input's surface around a native `<input type="password">`.
|
|
31
|
+
2. **Leading icon**: Input's lock icon, added automatically.
|
|
32
|
+
3. **Visibility toggle**: an eye button at the trailing edge, from Input. It switches the field between password and text.
|
|
33
|
+
4. **Strength bar** (with `showStrengthIndicator`): a small [Progress](./progress.md) whose tone follows the strength.
|
|
34
|
+
5. **Strength label**: "Weak", "Medium" or "Strong" beside the bar.
|
|
35
|
+
6. **Requirements checklist**: a two-column list. Each row shows a check in `--positive-fg` when met or a cross in `--interactive-fg-alt` when not.
|
|
36
|
+
7. **Live region**: visually hidden; announces "Password strength: …".
|
|
37
|
+
|
|
38
|
+
The strength block (4 to 6) appears below the field once it has a value.
|
|
39
|
+
|
|
40
|
+
## 4. Variants
|
|
41
|
+
|
|
42
|
+
No variant prop. `showStrengthIndicator` adds the strength block; `strengthRequirements` chooses which checklist rows appear and how the score is computed.
|
|
43
|
+
|
|
44
|
+
## 5. Sizes
|
|
45
|
+
|
|
46
|
+
No size prop. The field is `--size-lg` tall, from Input, and follows density.
|
|
47
|
+
|
|
48
|
+
## 6. States
|
|
49
|
+
|
|
50
|
+
| State | Looks like | Notes |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| Default | `--interactive-bg` surface, `--interactive-border-alt` border, icon and placeholder in `--interactive-fg-alt` | |
|
|
53
|
+
| Focus | Border and 1px outline in `--focus-ring`, 1px offset | Never remove or restyle the focus ring. The visibility toggle is a separate Tab stop. |
|
|
54
|
+
| Revealed | Text visible, eye-off icon, toggle `aria-pressed="true"` | Stays revealed until toggled back; blur and submit don't reset it. |
|
|
55
|
+
| Disabled | `--interactive-bg-disabled` surface, `--interactive-fg-disabled` text | The visibility toggle stays enabled and clickable. |
|
|
56
|
+
| Weak / Medium / Strong | Label text, bar in `--destructive-fg`, `--cautionary-fg` or `--positive-fg` | The bar renders full-width at every strength, so its length means nothing. Rely on the label and checklist; don't restyle or replace the bar. |
|
|
57
|
+
| Error (`aria-invalid`) | `--destructive-border` border and focus outline | Set it yourself when validation fails, with a FormMessage. |
|
|
58
|
+
|
|
59
|
+
## 7. Content guidelines
|
|
60
|
+
|
|
61
|
+
- Label the field "Password", or "New password" and "Current password" on change-password forms.
|
|
62
|
+
- Write requirements in your own validation message in the same words the checklist uses ("8+ characters", "Number").
|
|
63
|
+
- Don't put the policy in the placeholder; the checklist shows it.
|
|
64
|
+
|
|
65
|
+
| Do | Don't |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| New password | Enter a secure password |
|
|
68
|
+
| Use at least 12 characters | Password does not meet requirements |
|
|
69
|
+
| Current password | Old pw |
|
|
70
|
+
|
|
71
|
+
## 8. Rules
|
|
72
|
+
|
|
73
|
+
1. Give the field a visible [Label](./form-label.md) tied with `htmlFor` and `id`.
|
|
74
|
+
2. Set `autoComplete="current-password"` on sign-in and `autoComplete="new-password"` when creating or changing a password.
|
|
75
|
+
3. Show the strength indicator only where the user creates a password.
|
|
76
|
+
4. Set `strengthRequirements` to match the policy you enforce on submit. The checklist shows only what you configure.
|
|
77
|
+
5. Don't treat `onStrengthChange("strong")` as "valid". Strong means four of five checks pass, and requirements you switch off count as met. Check your own rules on submit.
|
|
78
|
+
6. Don't add an eye button or lock icon; Input already renders both.
|
|
79
|
+
7. Never pass `className` or `style`; they're dropped. Put width on a wrapper.
|
|
80
|
+
|
|
81
|
+
## 9. Dos and don'ts
|
|
82
|
+
|
|
83
|
+
**Do:** show the indicator on a new-password field with your real policy.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<PasswordInput
|
|
87
|
+
id="new-password"
|
|
88
|
+
name="newPassword"
|
|
89
|
+
autoComplete="new-password"
|
|
90
|
+
showStrengthIndicator
|
|
91
|
+
strengthRequirements={{ minLength: 12, requireSpecialChars: false }}
|
|
92
|
+
/>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Don't:** show a strength meter on sign-in, or build your own toggle.
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
<div style={{ position: "relative" }}>
|
|
99
|
+
<PasswordInput autoComplete="current-password" showStrengthIndicator />
|
|
100
|
+
<button onClick={reveal}><Eye /></button>
|
|
101
|
+
</div>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Do:** validate against your own rules.
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
const meetsPolicy = password.length >= 12 && /[0-9]/.test(password);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Don't:** gate submit on the strength bucket.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<Button disabled={strength !== "strong"}>Create account</Button>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 10. Accessibility
|
|
117
|
+
|
|
118
|
+
- Role: password fields have no ARIA role; screen readers announce a protected text field. The visibility toggle is a `button`.
|
|
119
|
+
- Label: a Label tied by `htmlFor`/`id`. The toggle is named "Show password" or "Hide password" and carries `aria-pressed`.
|
|
120
|
+
- Keyboard: standard text input. Tab moves from the field to the toggle; Enter or Space toggles visibility.
|
|
121
|
+
- Focus: focus stays on the toggle after toggling. The field and toggle both show the system outline on `:focus-visible`.
|
|
122
|
+
- Strength: a `role="status"` polite live region announces "Password strength: Weak", "Medium" or "Strong" as it changes. Each checklist row carries hidden "(met)" or "(not met)" text. The strength block isn't linked to the field with `aria-describedby`.
|
|
123
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
124
|
+
|
|
125
|
+
## 11. Behaviour
|
|
126
|
+
|
|
127
|
+
- Layout: a column with the field on top and the strength block below, filling the container's width. The checklist is a two-column grid.
|
|
128
|
+
- The strength block appears when the field has a value and disappears when it's cleared.
|
|
129
|
+
- Scoring: five checks, each passing or failing: at least `minLength` characters (default 8), an uppercase letter, a lowercase letter, a digit, and one of `!@#$%^&*(),.?":{}|<>`. The score is the share that pass: below 40% is Weak, below 80% Medium, otherwise Strong.
|
|
130
|
+
- A requirement you turn off is skipped in the checklist but still counts as passed, so fewer requirements read Strong sooner. With only a length rule, any non-empty value reads Strong.
|
|
131
|
+
- `onStrengthChange` fires on every change while the field has a value, not only when the bucket changes.
|
|
132
|
+
- Motion: the bar animates its fill over 300ms; the field's colours transition over 150ms. Don't add your own.
|
|
133
|
+
|
|
134
|
+
## 12. API
|
|
135
|
+
|
|
136
|
+
<!-- api:start -->
|
|
137
|
+
| Prop | Type | Default | Description |
|
|
138
|
+
| --- | --- | --- | --- |
|
|
139
|
+
| `showStrengthIndicator` | `boolean` | `false` | Shows the strength bar, label, checklist and live region below the field. |
|
|
140
|
+
| `strengthRequirements` | `{ minLength?: number; requireUppercase?: boolean; requireLowercase?: boolean; requireNumbers?: boolean; requireSpecialChars?: boolean }` | `{ minLength: 8 }`, every `require*` `true` | Which checks appear in the checklist and count toward the score. Doesn't set the native `minLength` attribute. |
|
|
141
|
+
| `onStrengthChange` | `(strength: "weak" \| "medium" \| "strong") => void` | | Fires on every change while the field has a value. |
|
|
142
|
+
| `onChange` | `ChangeEventHandler<HTMLInputElement>` | | Native change event; read the value here. |
|
|
143
|
+
| `...props` | `InputHTMLAttributes` without `className`, `style`, `size`, `type` | | Native input attributes: `id`, `name`, `value`, `autoComplete`, `required`, `disabled`, `aria-*`. `ref` reaches the `<input>`. |
|
|
144
|
+
<!-- api:end -->
|
|
145
|
+
|
|
146
|
+
Input's own props (`icon`, `trailing`, `validationTone`, `size`) aren't part of PasswordInput's props.
|
|
147
|
+
|
|
148
|
+
## 13. Examples
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { useState, type FormEvent } from "react";
|
|
152
|
+
import { Button, Label, FormMessage, PasswordInput } from "@eluan/core";
|
|
153
|
+
|
|
154
|
+
export function ChangePasswordForm({ onSave }: { onSave: (current: string, next: string) => void }) {
|
|
155
|
+
const [current, setCurrent] = useState("");
|
|
156
|
+
const [next, setNext] = useState("");
|
|
157
|
+
const [submitted, setSubmitted] = useState(false);
|
|
158
|
+
const meetsPolicy = next.length >= 12 && /[0-9]/.test(next) && /[A-Z]/.test(next) && /[a-z]/.test(next);
|
|
159
|
+
const showError = submitted && !meetsPolicy;
|
|
160
|
+
|
|
161
|
+
function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
setSubmitted(true);
|
|
164
|
+
if (meetsPolicy) onSave(current, next);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const field = { display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" } as const;
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<form onSubmit={handleSubmit} noValidate style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-lg)" }}>
|
|
171
|
+
<div style={field}>
|
|
172
|
+
<Label htmlFor="current-password" required>Current password</Label>
|
|
173
|
+
<PasswordInput
|
|
174
|
+
id="current-password"
|
|
175
|
+
name="currentPassword"
|
|
176
|
+
autoComplete="current-password"
|
|
177
|
+
value={current}
|
|
178
|
+
onChange={(event) => setCurrent(event.target.value)}
|
|
179
|
+
/>
|
|
180
|
+
</div>
|
|
181
|
+
<div style={field}>
|
|
182
|
+
<Label htmlFor="new-password" required>New password</Label>
|
|
183
|
+
<PasswordInput
|
|
184
|
+
id="new-password"
|
|
185
|
+
name="newPassword"
|
|
186
|
+
autoComplete="new-password"
|
|
187
|
+
value={next}
|
|
188
|
+
onChange={(event) => setNext(event.target.value)}
|
|
189
|
+
showStrengthIndicator
|
|
190
|
+
strengthRequirements={{ minLength: 12, requireSpecialChars: false }}
|
|
191
|
+
aria-invalid={showError}
|
|
192
|
+
aria-describedby={showError ? "new-password-error" : undefined}
|
|
193
|
+
/>
|
|
194
|
+
{showError && (
|
|
195
|
+
<FormMessage id="new-password-error">
|
|
196
|
+
Use at least 12 characters with an uppercase letter, a lowercase letter and a number.
|
|
197
|
+
</FormMessage>
|
|
198
|
+
)}
|
|
199
|
+
</div>
|
|
200
|
+
<div style={{ display: "flex", justifyContent: "flex-end" }}>
|
|
201
|
+
<Button type="submit">Update password</Button>
|
|
202
|
+
</div>
|
|
203
|
+
</form>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## 14. Related components
|
|
209
|
+
|
|
210
|
+
- [Input](./input.md): the base field; `type="password"` provides the icon and toggle.
|
|
211
|
+
- [Progress](./progress.md): the strength bar.
|
|
212
|
+
- [EmailInput](./email-input.md): the usual partner on sign-in and sign-up forms.
|
|
213
|
+
- [InputOTP](./input-otp.md): one-time codes, not passwords.
|
|
214
|
+
- [Forms pattern](../patterns/forms.md): field structure, validation timing and error placement.
|
|
215
|
+
|
|
216
|
+
## 15. Common agent mistakes
|
|
217
|
+
|
|
218
|
+
_Filled from evals._
|