@hewnui/ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +69 -2
- package/dist/chart/axes.d.ts +31 -0
- package/dist/chart/axes.js +20 -0
- package/dist/chart/colors.d.ts +1 -0
- package/dist/chart/colors.js +13 -0
- package/dist/chart/frame.d.ts +13 -0
- package/dist/chart/frame.js +17 -0
- package/dist/chart/interaction.d.ts +22 -0
- package/dist/chart/interaction.js +22 -0
- package/dist/chart/path.d.ts +10 -0
- package/dist/chart/path.js +24 -0
- package/dist/chart/scales.d.ts +34 -0
- package/dist/chart/scales.js +66 -0
- package/dist/chart/status.d.ts +3 -0
- package/dist/chart/status.js +15 -0
- package/dist/chart/types.d.ts +34 -0
- package/dist/chart/types.js +6 -0
- package/dist/components/area-chart/area-chart.d.ts +17 -0
- package/dist/components/area-chart/area-chart.js +54 -0
- package/dist/components/area-chart/index.d.ts +1 -0
- package/dist/components/area-chart/index.js +1 -0
- package/dist/components/badge/badge.d.ts +2 -0
- package/dist/components/badge/badge.js +5 -0
- package/dist/components/badge/badge.styles.d.ts +8 -0
- package/dist/components/badge/badge.styles.js +57 -0
- package/dist/components/badge/badge.types.d.ts +11 -0
- package/dist/components/badge/badge.types.js +1 -0
- package/dist/components/badge/index.d.ts +3 -0
- package/dist/components/badge/index.js +2 -0
- package/dist/components/bar-chart/bar-chart.d.ts +17 -0
- package/dist/components/bar-chart/bar-chart.js +73 -0
- package/dist/components/bar-chart/index.d.ts +1 -0
- package/dist/components/bar-chart/index.js +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +3 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +13 -0
- package/dist/components/breadcrumbs/breadcrumbs.styles.d.ts +5 -0
- package/dist/components/breadcrumbs/breadcrumbs.styles.js +10 -0
- package/dist/components/breadcrumbs/breadcrumbs.types.d.ts +16 -0
- package/dist/components/breadcrumbs/breadcrumbs.types.js +1 -0
- package/dist/components/breadcrumbs/index.d.ts +2 -0
- package/dist/components/breadcrumbs/index.js +1 -0
- package/dist/components/button/button.d.ts +2 -0
- package/dist/components/button/button.js +18 -0
- package/dist/components/button/button.motion.d.ts +23 -0
- package/dist/components/button/button.motion.js +11 -0
- package/dist/components/button/button.styles.d.ts +10 -0
- package/dist/components/button/button.styles.js +24 -0
- package/dist/components/button/button.types.d.ts +11 -0
- package/dist/components/button/button.types.js +1 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/card/card.d.ts +21 -0
- package/dist/components/card/card.js +19 -0
- package/dist/components/card/card.styles.d.ts +4 -0
- package/dist/components/card/card.styles.js +13 -0
- package/dist/components/card/card.types.d.ts +4 -0
- package/dist/components/card/card.types.js +1 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/checkbox/checkbox.d.ts +2 -0
- package/dist/components/checkbox/checkbox.js +17 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +3 -0
- package/dist/components/checkbox/checkbox.styles.js +6 -0
- package/dist/components/checkbox/checkbox.types.d.ts +6 -0
- package/dist/components/checkbox/checkbox.types.js +1 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts +2 -0
- package/dist/components/checkbox-group/checkbox-group.js +8 -0
- package/dist/components/checkbox-group/checkbox-group.styles.d.ts +2 -0
- package/dist/components/checkbox-group/checkbox-group.styles.js +5 -0
- package/dist/components/checkbox-group/checkbox-group.types.d.ts +9 -0
- package/dist/components/checkbox-group/checkbox-group.types.js +1 -0
- package/dist/components/checkbox-group/index.d.ts +2 -0
- package/dist/components/checkbox-group/index.js +1 -0
- package/dist/components/color-picker/color-picker.d.ts +2 -0
- package/dist/components/color-picker/color-picker.js +27 -0
- package/dist/components/color-picker/color-picker.oklch.d.ts +2 -0
- package/dist/components/color-picker/color-picker.oklch.js +54 -0
- package/dist/components/color-picker/color-picker.panel.d.ts +2 -0
- package/dist/components/color-picker/color-picker.panel.js +15 -0
- package/dist/components/color-picker/color-picker.styles.d.ts +16 -0
- package/dist/components/color-picker/color-picker.styles.js +28 -0
- package/dist/components/color-picker/color-picker.types.d.ts +36 -0
- package/dist/components/color-picker/color-picker.types.js +1 -0
- package/dist/components/color-picker/index.d.ts +4 -0
- package/dist/components/color-picker/index.js +3 -0
- package/dist/components/combobox/combobox.d.ts +15 -0
- package/dist/components/combobox/combobox.js +11 -0
- package/dist/components/combobox/index.d.ts +1 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/command-palette/command-palette-items.d.ts +4 -0
- package/dist/components/command-palette/command-palette-items.js +14 -0
- package/dist/components/command-palette/command-palette.d.ts +15 -0
- package/dist/components/command-palette/command-palette.hotkey.d.ts +8 -0
- package/dist/components/command-palette/command-palette.hotkey.js +51 -0
- package/dist/components/command-palette/command-palette.js +33 -0
- package/dist/components/command-palette/command-palette.styles.d.ts +13 -0
- package/dist/components/command-palette/command-palette.styles.js +25 -0
- package/dist/components/command-palette/command-palette.types.d.ts +65 -0
- package/dist/components/command-palette/command-palette.types.js +1 -0
- package/dist/components/command-palette/index.d.ts +14 -0
- package/dist/components/command-palette/index.js +13 -0
- package/dist/components/data-table/data-table.d.ts +7 -0
- package/dist/components/data-table/data-table.js +31 -0
- package/dist/components/data-table/index.d.ts +1 -0
- package/dist/components/data-table/index.js +1 -0
- package/dist/components/date-picker/date-picker.d.ts +7 -0
- package/dist/components/date-picker/date-picker.js +8 -0
- package/dist/components/date-picker/index.d.ts +1 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/date-range-picker/date-range-picker.calendar.d.ts +5 -0
- package/dist/components/date-range-picker/date-range-picker.calendar.js +21 -0
- package/dist/components/date-range-picker/date-range-picker.d.ts +2 -0
- package/dist/components/date-range-picker/date-range-picker.js +9 -0
- package/dist/components/date-range-picker/date-range-picker.presets.d.ts +3 -0
- package/dist/components/date-range-picker/date-range-picker.presets.js +53 -0
- package/dist/components/date-range-picker/date-range-picker.styles.d.ts +11 -0
- package/dist/components/date-range-picker/date-range-picker.styles.js +14 -0
- package/dist/components/date-range-picker/date-range-picker.types.d.ts +28 -0
- package/dist/components/date-range-picker/date-range-picker.types.js +1 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/date-range-picker/index.js +1 -0
- package/dist/components/dialog/dialog.d.ts +18 -0
- package/dist/components/dialog/dialog.js +16 -0
- package/dist/components/dialog/dialog.styles.d.ts +6 -0
- package/dist/components/dialog/dialog.styles.js +9 -0
- package/dist/components/dialog/index.d.ts +7 -0
- package/dist/components/dialog/index.js +7 -0
- package/dist/components/donut-chart/donut-chart.d.ts +17 -0
- package/dist/components/donut-chart/donut-chart.js +65 -0
- package/dist/components/donut-chart/index.d.ts +1 -0
- package/dist/components/donut-chart/index.js +1 -0
- package/dist/components/drawer/drawer.d.ts +13 -0
- package/dist/components/drawer/drawer.js +14 -0
- package/dist/components/drawer/index.d.ts +1 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/empty/empty.d.ts +7 -0
- package/dist/components/empty/empty.js +5 -0
- package/dist/components/empty/index.d.ts +1 -0
- package/dist/components/empty/index.js +1 -0
- package/dist/components/file-upload/file-upload.d.ts +2 -0
- package/dist/components/file-upload/file-upload.js +44 -0
- package/dist/components/file-upload/file-upload.styles.d.ts +12 -0
- package/dist/components/file-upload/file-upload.styles.js +14 -0
- package/dist/components/file-upload/file-upload.types.d.ts +16 -0
- package/dist/components/file-upload/file-upload.types.js +1 -0
- package/dist/components/file-upload/index.d.ts +2 -0
- package/dist/components/file-upload/index.js +1 -0
- package/dist/components/form/form.d.ts +2 -0
- package/dist/components/form/form.js +7 -0
- package/dist/components/form/form.styles.d.ts +1 -0
- package/dist/components/form/form.styles.js +4 -0
- package/dist/components/form/form.types.d.ts +6 -0
- package/dist/components/form/form.types.js +1 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +1 -0
- package/dist/components/input-group/index.d.ts +2 -0
- package/dist/components/input-group/index.js +1 -0
- package/dist/components/input-group/input-group.d.ts +14 -0
- package/dist/components/input-group/input-group.js +24 -0
- package/dist/components/input-group/input-group.styles.d.ts +8 -0
- package/dist/components/input-group/input-group.styles.js +9 -0
- package/dist/components/input-group/input-group.types.d.ts +22 -0
- package/dist/components/input-group/input-group.types.js +1 -0
- package/dist/components/input-otp/index.d.ts +2 -0
- package/dist/components/input-otp/index.js +1 -0
- package/dist/components/input-otp/input-otp.d.ts +2 -0
- package/dist/components/input-otp/input-otp.js +76 -0
- package/dist/components/input-otp/input-otp.styles.d.ts +8 -0
- package/dist/components/input-otp/input-otp.styles.js +11 -0
- package/dist/components/input-otp/input-otp.types.d.ts +23 -0
- package/dist/components/input-otp/input-otp.types.js +1 -0
- package/dist/components/line-chart/index.d.ts +1 -0
- package/dist/components/line-chart/index.js +1 -0
- package/dist/components/line-chart/line-chart.d.ts +17 -0
- package/dist/components/line-chart/line-chart.js +53 -0
- package/dist/components/link/index.d.ts +2 -0
- package/dist/components/link/index.js +1 -0
- package/dist/components/link/link.d.ts +2 -0
- package/dist/components/link/link.js +7 -0
- package/dist/components/link/link.styles.d.ts +5 -0
- package/dist/components/link/link.styles.js +9 -0
- package/dist/components/link/link.types.d.ts +8 -0
- package/dist/components/link/link.types.js +1 -0
- package/dist/components/menu/index.d.ts +8 -0
- package/dist/components/menu/index.js +8 -0
- package/dist/components/menu/menu.d.ts +20 -0
- package/dist/components/menu/menu.js +26 -0
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/index.js +1 -0
- package/dist/components/number-field/number-field.d.ts +2 -0
- package/dist/components/number-field/number-field.js +14 -0
- package/dist/components/number-field/number-field.styles.d.ts +8 -0
- package/dist/components/number-field/number-field.styles.js +7 -0
- package/dist/components/number-field/number-field.types.d.ts +14 -0
- package/dist/components/number-field/number-field.types.js +1 -0
- package/dist/components/pagination/index.d.ts +3 -0
- package/dist/components/pagination/index.js +2 -0
- package/dist/components/pagination/pagination.d.ts +2 -0
- package/dist/components/pagination/pagination.js +49 -0
- package/dist/components/pagination/pagination.styles.d.ts +8 -0
- package/dist/components/pagination/pagination.styles.js +19 -0
- package/dist/components/pagination/pagination.types.d.ts +35 -0
- package/dist/components/pagination/pagination.types.js +1 -0
- package/dist/components/pagination/pagination.utils.d.ts +6 -0
- package/dist/components/pagination/pagination.utils.js +51 -0
- package/dist/components/password-field/index.d.ts +2 -0
- package/dist/components/password-field/index.js +1 -0
- package/dist/components/password-field/password-field.d.ts +2 -0
- package/dist/components/password-field/password-field.js +17 -0
- package/dist/components/password-field/password-field.styles.d.ts +8 -0
- package/dist/components/password-field/password-field.styles.js +7 -0
- package/dist/components/password-field/password-field.types.d.ts +16 -0
- package/dist/components/password-field/password-field.types.js +1 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/popover/popover.d.ts +10 -0
- package/dist/components/popover/popover.js +16 -0
- package/dist/components/popover/popover.styles.d.ts +3 -0
- package/dist/components/popover/popover.styles.js +7 -0
- package/dist/components/popover/popover.types.d.ts +14 -0
- package/dist/components/popover/popover.types.js +1 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/index.js +1 -0
- package/dist/components/progress/progress.d.ts +12 -0
- package/dist/components/progress/progress.js +26 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/radio-group/radio-group.d.ts +3 -0
- package/dist/components/radio-group/radio-group.js +21 -0
- package/dist/components/radio-group/radio-group.styles.d.ts +5 -0
- package/dist/components/radio-group/radio-group.styles.js +14 -0
- package/dist/components/radio-group/radio-group.types.d.ts +14 -0
- package/dist/components/radio-group/radio-group.types.js +1 -0
- package/dist/components/search-field/index.d.ts +2 -0
- package/dist/components/search-field/index.js +1 -0
- package/dist/components/search-field/search-field.d.ts +2 -0
- package/dist/components/search-field/search-field.js +15 -0
- package/dist/components/search-field/search-field.styles.d.ts +8 -0
- package/dist/components/search-field/search-field.styles.js +7 -0
- package/dist/components/search-field/search-field.types.d.ts +15 -0
- package/dist/components/search-field/search-field.types.js +1 -0
- package/dist/components/select/index.d.ts +5 -0
- package/dist/components/select/index.js +5 -0
- package/dist/components/select/select.d.ts +16 -0
- package/dist/components/select/select.js +11 -0
- package/dist/components/select/select.styles.d.ts +5 -0
- package/dist/components/select/select.styles.js +13 -0
- package/dist/components/skeleton/index.d.ts +1 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/skeleton/skeleton.d.ts +3 -0
- package/dist/components/skeleton/skeleton.js +5 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/slider/slider.d.ts +2 -0
- package/dist/components/slider/slider.js +8 -0
- package/dist/components/slider/slider.styles.d.ts +6 -0
- package/dist/components/slider/slider.styles.js +9 -0
- package/dist/components/slider/slider.types.d.ts +8 -0
- package/dist/components/slider/slider.types.js +1 -0
- package/dist/components/sparkline/index.d.ts +1 -0
- package/dist/components/sparkline/index.js +1 -0
- package/dist/components/sparkline/sparkline.d.ts +11 -0
- package/dist/components/sparkline/sparkline.js +34 -0
- package/dist/components/spinner/index.d.ts +1 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/spinner/spinner.d.ts +4 -0
- package/dist/components/spinner/spinner.js +6 -0
- package/dist/components/stepper/index.d.ts +3 -0
- package/dist/components/stepper/index.js +2 -0
- package/dist/components/stepper/stepper-step.d.ts +15 -0
- package/dist/components/stepper/stepper-step.js +46 -0
- package/dist/components/stepper/stepper.d.ts +4 -0
- package/dist/components/stepper/stepper.js +17 -0
- package/dist/components/stepper/stepper.styles.d.ts +10 -0
- package/dist/components/stepper/stepper.styles.js +37 -0
- package/dist/components/stepper/stepper.types.d.ts +50 -0
- package/dist/components/stepper/stepper.types.js +1 -0
- package/dist/components/stepper/use-stepper.d.ts +6 -0
- package/dist/components/stepper/use-stepper.js +40 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/switch/switch.d.ts +2 -0
- package/dist/components/switch/switch.js +7 -0
- package/dist/components/switch/switch.styles.d.ts +3 -0
- package/dist/components/switch/switch.styles.js +6 -0
- package/dist/components/switch/switch.types.d.ts +6 -0
- package/dist/components/switch/switch.types.js +1 -0
- package/dist/components/table/index.d.ts +11 -0
- package/dist/components/table/index.js +11 -0
- package/dist/components/table/table-sort-glyph.d.ts +3 -0
- package/dist/components/table/table-sort-glyph.js +5 -0
- package/dist/components/table/table.d.ts +33 -0
- package/dist/components/table/table.js +31 -0
- package/dist/components/table/table.styles.d.ts +8 -0
- package/dist/components/table/table.styles.js +19 -0
- package/dist/components/tabs/index.d.ts +7 -0
- package/dist/components/tabs/index.js +7 -0
- package/dist/components/tabs/tabs.d.ts +20 -0
- package/dist/components/tabs/tabs.js +29 -0
- package/dist/components/tabs/tabs.styles.d.ts +5 -0
- package/dist/components/tabs/tabs.styles.js +30 -0
- package/dist/components/tag-field/index.d.ts +2 -0
- package/dist/components/tag-field/index.js +1 -0
- package/dist/components/tag-field/tag-field-icons.d.ts +2 -0
- package/dist/components/tag-field/tag-field-icons.js +7 -0
- package/dist/components/tag-field/tag-field-tags.d.ts +7 -0
- package/dist/components/tag-field/tag-field-tags.js +19 -0
- package/dist/components/tag-field/tag-field.d.ts +6 -0
- package/dist/components/tag-field/tag-field.js +46 -0
- package/dist/components/tag-field/tag-field.styles.d.ts +14 -0
- package/dist/components/tag-field/tag-field.styles.js +42 -0
- package/dist/components/tag-field/tag-field.types.d.ts +32 -0
- package/dist/components/tag-field/tag-field.types.js +1 -0
- package/dist/components/text-area/index.d.ts +2 -0
- package/dist/components/text-area/index.js +1 -0
- package/dist/components/text-area/text-area.d.ts +2 -0
- package/dist/components/text-area/text-area.js +9 -0
- package/dist/components/text-area/text-area.styles.d.ts +6 -0
- package/dist/components/text-area/text-area.styles.js +5 -0
- package/dist/components/text-area/text-area.types.d.ts +16 -0
- package/dist/components/text-area/text-area.types.js +1 -0
- package/dist/components/text-field/index.d.ts +2 -0
- package/dist/components/text-field/index.js +1 -0
- package/dist/components/text-field/text-field.d.ts +2 -0
- package/dist/components/text-field/text-field.js +8 -0
- package/dist/components/text-field/text-field.styles.d.ts +1 -0
- package/dist/components/text-field/text-field.styles.js +1 -0
- package/dist/components/text-field/text-field.types.d.ts +15 -0
- package/dist/components/text-field/text-field.types.js +1 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/toast/toast-glyph.d.ts +4 -0
- package/dist/components/toast/toast-glyph.js +23 -0
- package/dist/components/toast/toast-item.d.ts +14 -0
- package/dist/components/toast/toast-item.js +21 -0
- package/dist/components/toast/toast.d.ts +16 -0
- package/dist/components/toast/toast.js +50 -0
- package/dist/components/toast/toast.styles.d.ts +13 -0
- package/dist/components/toast/toast.styles.js +50 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tooltip/tooltip.d.ts +3 -0
- package/dist/components/tooltip/tooltip.js +10 -0
- package/dist/components/tooltip/tooltip.styles.d.ts +1 -0
- package/dist/components/tooltip/tooltip.styles.js +6 -0
- package/dist/components/tooltip/tooltip.types.d.ts +18 -0
- package/dist/components/tooltip/tooltip.types.js +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +51 -0
- package/dist/providers/material-provider.d.ts +12 -0
- package/dist/providers/material-provider.js +30 -0
- package/dist/providers/motion-provider.d.ts +20 -0
- package/dist/providers/motion-provider.js +45 -0
- package/dist/providers/radius-provider.d.ts +13 -0
- package/dist/providers/radius-provider.js +73 -0
- package/dist/providers/theme-provider.d.ts +25 -0
- package/dist/providers/theme-provider.js +66 -0
- package/dist/styles/field.d.ts +24 -0
- package/dist/styles/field.js +36 -0
- package/dist/styles/overlays.d.ts +3 -0
- package/dist/styles/overlays.js +4 -0
- package/dist/utils/cn.d.ts +1 -0
- package/dist/utils/cn.js +3 -0
- package/package.json +468 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn";
|
|
2
|
+
import { inputSurfaceClassName, } from "../../styles/field";
|
|
3
|
+
export function inputOtpRootClass(className) {
|
|
4
|
+
return cn("flex w-full max-w-sm flex-col gap-1.5 text-sm text-foreground", className);
|
|
5
|
+
}
|
|
6
|
+
export const inputOtpSlotsClass = "flex flex-row flex-nowrap items-center gap-2";
|
|
7
|
+
export function inputOtpSlotClassName({ className, size = "md", variant = "outline", } = {}) {
|
|
8
|
+
// inputSurfaceClassName includes w-full; cn does not conflict-merge, so pin
|
|
9
|
+
// slot size with max/basis so digits stay in a horizontal OTP row.
|
|
10
|
+
return cn(inputSurfaceClassName({ size, variant }), "max-w-11 w-11 min-w-11 shrink-0 grow-0 basis-11 px-0 text-center font-mono text-base tabular-nums", size === "sm" && "max-w-9 w-9 min-w-9 basis-9", size === "lg" && "max-w-12 w-12 min-w-12 basis-12", className);
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { FieldSize, FieldVariant } from "../../styles/field";
|
|
3
|
+
export type InputOtpVariant = FieldVariant;
|
|
4
|
+
export type InputOtpSize = FieldSize;
|
|
5
|
+
export type InputOtpProps = {
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
errorMessage?: ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
length?: number;
|
|
11
|
+
value?: string;
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
onChange?: (value: string) => void;
|
|
14
|
+
onComplete?: (value: string) => void;
|
|
15
|
+
isDisabled?: boolean;
|
|
16
|
+
isInvalid?: boolean;
|
|
17
|
+
isRequired?: boolean;
|
|
18
|
+
name?: string;
|
|
19
|
+
autoFocus?: boolean;
|
|
20
|
+
variant?: InputOtpVariant;
|
|
21
|
+
size?: InputOtpSize;
|
|
22
|
+
"aria-label"?: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LineChart, type LineChartProps } from "./line-chart";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LineChart } from "./line-chart";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { ChartTooltip } from "../../chart/interaction";
|
|
3
|
+
import type { ChartSeries, ChartStatus } from "../../chart/types";
|
|
4
|
+
export type LineChartProps = {
|
|
5
|
+
series: ChartSeries[];
|
|
6
|
+
summary: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
status?: ChartStatus;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
declare function LineChartRoot({ series, summary, className, width, height, status, children, }: LineChartProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const LineChart: typeof LineChartRoot & {
|
|
15
|
+
Tooltip: typeof ChartTooltip;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { drawIn } from "@hewnui/motion";
|
|
4
|
+
import { m } from "motion/react";
|
|
5
|
+
import { AxisLabels, GridLines } from "../../chart/axes";
|
|
6
|
+
import { seriesColor } from "../../chart/colors";
|
|
7
|
+
import { ChartFrame } from "../../chart/frame";
|
|
8
|
+
import { ChartInteractionProvider, ChartTooltip, useChartInteraction, } from "../../chart/interaction";
|
|
9
|
+
import { linePath } from "../../chart/path";
|
|
10
|
+
import { createLinearScales, flattenSeries } from "../../chart/scales";
|
|
11
|
+
import { resolveStatus } from "../../chart/status";
|
|
12
|
+
import { useMotionMode } from "../../providers/motion-provider";
|
|
13
|
+
function LineChartRoot({ series, summary, className, width = 480, height = 240, status, children, }) {
|
|
14
|
+
const resolved = resolveStatus(series, status);
|
|
15
|
+
if (resolved !== "ready") {
|
|
16
|
+
return (_jsx(ChartFrame, { className: className, width: width, height: height, summary: summary, status: resolved }));
|
|
17
|
+
}
|
|
18
|
+
return (_jsx(ChartInteractionProvider, { series: series, children: _jsxs("div", { className: "relative", style: { maxWidth: width }, children: [_jsx(LineChartSvg, { series: series, summary: summary, className: className, width: width, height: height }), children] }) }));
|
|
19
|
+
}
|
|
20
|
+
function LineChartSvg({ series, summary, className, width, height, }) {
|
|
21
|
+
const { motionEnabled } = useMotionMode();
|
|
22
|
+
const { setHover } = useChartInteraction();
|
|
23
|
+
const flat = flattenSeries(series);
|
|
24
|
+
const scales = createLinearScales(flat, { width, height });
|
|
25
|
+
const { x, y, pad, xIsNumeric } = scales;
|
|
26
|
+
return (_jsxs(ChartFrame, { className: className, width: width, height: height, summary: summary, interactive: true, children: [_jsx(GridLines, { x: x, y: y, width: width, height: height, pad: pad }), _jsx(AxisLabels, { x: x, y: y, height: height, pad: pad }), series.map((item, index) => {
|
|
27
|
+
const color = seriesColor(index, item.color);
|
|
28
|
+
const d = linePath(item.data, x, y, xIsNumeric);
|
|
29
|
+
return (_jsxs("g", { children: [motionEnabled ? (_jsx(m.path, { d: d, fill: "none", stroke: color, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", initial: { pathLength: 0 }, animate: { pathLength: 1 }, transition: drawIn })) : (_jsx("path", { d: d, fill: "none", stroke: color, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" })), item.data.map((point) => {
|
|
30
|
+
const raw = xIsNumeric ? point.x : String(point.x);
|
|
31
|
+
const px = x(raw) ?? 0;
|
|
32
|
+
const py = y(point.y) ?? 0;
|
|
33
|
+
return (_jsx("circle", { cx: px, cy: py, r: 4, fill: color, className: "cursor-pointer opacity-0 transition-opacity duration-[var(--kp-motion-duration-fast)] hover:opacity-100 focus-visible:opacity-100", tabIndex: 0, role: "button", "aria-label": `${item.label}: ${String(point.x)}, ${point.y}`, onFocus: () => setHover({
|
|
34
|
+
seriesId: item.id,
|
|
35
|
+
label: item.label,
|
|
36
|
+
point,
|
|
37
|
+
color,
|
|
38
|
+
px,
|
|
39
|
+
py,
|
|
40
|
+
}), onBlur: () => setHover(null), onMouseEnter: () => setHover({
|
|
41
|
+
seriesId: item.id,
|
|
42
|
+
label: item.label,
|
|
43
|
+
point,
|
|
44
|
+
color,
|
|
45
|
+
px,
|
|
46
|
+
py,
|
|
47
|
+
}), onMouseLeave: () => setHover(null) }, `${item.id}-${String(point.x)}`));
|
|
48
|
+
})] }, item.id));
|
|
49
|
+
})] }));
|
|
50
|
+
}
|
|
51
|
+
export const LineChart = Object.assign(LineChartRoot, {
|
|
52
|
+
Tooltip: ChartTooltip,
|
|
53
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Link } from "./link";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Link as AriaLink } from "react-aria-components";
|
|
4
|
+
import { linkClassName } from "./link.styles";
|
|
5
|
+
export function Link({ children, className, variant = "accent", ...props }) {
|
|
6
|
+
return (_jsx(AriaLink, { ...props, className: linkClassName({ className, variant }), children: children }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn";
|
|
2
|
+
const variants = {
|
|
3
|
+
accent: "text-accent hover:brightness-[1.08]",
|
|
4
|
+
muted: "text-muted-foreground hover:text-foreground",
|
|
5
|
+
underline: "text-foreground underline decoration-[color-mix(in_oklch,var(--kp-foreground)_28%,transparent)] underline-offset-4 hover:decoration-foreground",
|
|
6
|
+
};
|
|
7
|
+
export function linkClassName({ className, variant = "accent", } = {}) {
|
|
8
|
+
return cn("inline-flex min-h-10 items-center rounded-[calc(var(--kp-radius-sm)-0.05rem)]", "outline-none transition-[color,transform,text-decoration-color,filter]", "duration-[var(--kp-motion-duration)] ease-[var(--kp-motion-ease-standard)]", "pressed:scale-[0.96] data-[pressed]:scale-[0.96]", "focus-visible:ring-2 focus-visible:ring-ring/40", "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-45", variants[variant], className);
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LinkProps as AriaLinkProps } from "react-aria-components";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export type LinkVariant = "accent" | "muted" | "underline";
|
|
4
|
+
export type LinkProps = Omit<AriaLinkProps, "className" | "children"> & {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
variant?: LinkVariant;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Menu, MenuButton, MenuItem, MenuSeparator, MenuTrigger } from "./menu";
|
|
2
|
+
export declare const MenuRoot: typeof MenuTrigger & {
|
|
3
|
+
Button: typeof MenuButton;
|
|
4
|
+
Content: typeof Menu;
|
|
5
|
+
Item: typeof MenuItem;
|
|
6
|
+
Separator: typeof MenuSeparator;
|
|
7
|
+
};
|
|
8
|
+
export { Menu, MenuButton, MenuItem, MenuSeparator, MenuTrigger };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Menu, MenuButton, MenuItem, MenuSeparator, MenuTrigger, } from "./menu";
|
|
2
|
+
export const MenuRoot = Object.assign(MenuTrigger, {
|
|
3
|
+
Button: MenuButton,
|
|
4
|
+
Content: Menu,
|
|
5
|
+
Item: MenuItem,
|
|
6
|
+
Separator: MenuSeparator,
|
|
7
|
+
});
|
|
8
|
+
export { Menu, MenuButton, MenuItem, MenuSeparator, MenuTrigger };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export declare function MenuTrigger({ children, ...props }: {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
isOpen?: boolean;
|
|
5
|
+
defaultOpen?: boolean;
|
|
6
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function MenuButton({ children }: {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function Menu({ children }: {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function MenuItem({ children, id, isDisabled, onAction, }: {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
id?: string;
|
|
17
|
+
isDisabled?: boolean;
|
|
18
|
+
onAction?: () => void;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function MenuSeparator(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Button, Menu as AriaMenu, MenuItem as AriaMenuItem, MenuTrigger as AriaMenuTrigger, Popover, Separator, } from "react-aria-components";
|
|
4
|
+
import { menuItemClass, popoverSurfaceClass } from "../../styles/overlays";
|
|
5
|
+
import { buttonClassName } from "../button/button.styles";
|
|
6
|
+
import { useMotionMode } from "../../providers/motion-provider";
|
|
7
|
+
export function MenuTrigger({ children, ...props }) {
|
|
8
|
+
return _jsx(AriaMenuTrigger, { ...props, children: children });
|
|
9
|
+
}
|
|
10
|
+
export function MenuButton({ children }) {
|
|
11
|
+
const { motionEnabled } = useMotionMode();
|
|
12
|
+
return (_jsx(Button, { className: buttonClassName({
|
|
13
|
+
pressScale: motionEnabled,
|
|
14
|
+
variant: "secondary",
|
|
15
|
+
size: "md",
|
|
16
|
+
}), children: children }));
|
|
17
|
+
}
|
|
18
|
+
export function Menu({ children }) {
|
|
19
|
+
return (_jsx(Popover, { className: popoverSurfaceClass, "data-kp-surface": true, children: _jsx(AriaMenu, { className: "min-w-44 outline-none", children: children }) }));
|
|
20
|
+
}
|
|
21
|
+
export function MenuItem({ children, id, isDisabled, onAction, }) {
|
|
22
|
+
return (_jsx(AriaMenuItem, { className: menuItemClass, ...(id !== undefined ? { id } : {}), ...(isDisabled !== undefined ? { isDisabled } : {}), ...(onAction !== undefined ? { onAction } : {}), children: children }));
|
|
23
|
+
}
|
|
24
|
+
export function MenuSeparator() {
|
|
25
|
+
return _jsx(Separator, { className: "my-1 border-t" });
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NumberField } from "./number-field";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button, FieldError, Group, Input, Label, NumberField as AriaNumberField, Text, } from "react-aria-components";
|
|
4
|
+
import { cn } from "../../utils/cn";
|
|
5
|
+
import { fieldDescriptionClass, fieldErrorClass, fieldLabelClass, fieldRootClass, fieldSurfaceProps, } from "../../styles/field";
|
|
6
|
+
import { numberGroupClassName, numberInputClass, numberStepperClass, } from "./number-field.styles";
|
|
7
|
+
function StepIcon({ direction }) {
|
|
8
|
+
return (_jsx("svg", { viewBox: "0 0 12 12", className: "size-3.5", "aria-hidden": true, children: _jsx("path", { d: direction === "up"
|
|
9
|
+
? "M2.5 7.5 6 4l3.5 3.5"
|
|
10
|
+
: "M2.5 4.5 6 8l3.5-3.5", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
11
|
+
}
|
|
12
|
+
export function NumberField({ className, description, errorMessage, inputClassName: inputClass, label, size = "md", variant = "outline", ...props }) {
|
|
13
|
+
return (_jsxs(AriaNumberField, { ...props, className: cn(fieldRootClass, className), children: [label ? _jsx(Label, { className: fieldLabelClass, children: label }) : null, _jsxs(Group, { ...fieldSurfaceProps(variant), className: numberGroupClassName({ size, variant }), children: [_jsx(Button, { slot: "decrement", className: numberStepperClass, children: _jsx(StepIcon, { direction: "down" }) }), _jsx(Input, { className: cn(numberInputClass, "text-center", inputClass) }), _jsx(Button, { slot: "increment", className: numberStepperClass, children: _jsx(StepIcon, { direction: "up" }) })] }), description ? (_jsx(Text, { slot: "description", className: fieldDescriptionClass, children: description })) : null, _jsx(FieldError, { className: fieldErrorClass, children: errorMessage })] }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FieldSize, type FieldVariant } from "../../styles/field";
|
|
2
|
+
export declare function numberGroupClassName({ className, size, variant, }?: {
|
|
3
|
+
className?: string | undefined;
|
|
4
|
+
size?: FieldSize | undefined;
|
|
5
|
+
variant?: FieldVariant | undefined;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare const numberInputClass = "min-w-0 flex-1 bg-transparent px-3 py-0 text-foreground outline-none tabular-nums placeholder:text-muted-foreground";
|
|
8
|
+
export declare const numberStepperClass: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn";
|
|
2
|
+
import { inputSurfaceClassName, } from "../../styles/field";
|
|
3
|
+
export function numberGroupClassName({ className, size = "md", variant = "outline", } = {}) {
|
|
4
|
+
return cn(inputSurfaceClassName({ size, variant }), "flex items-stretch gap-0 p-0 tabular-nums", variant !== "flushed" && "overflow-hidden", className);
|
|
5
|
+
}
|
|
6
|
+
export const numberInputClass = "min-w-0 flex-1 bg-transparent px-3 py-0 text-foreground outline-none tabular-nums placeholder:text-muted-foreground";
|
|
7
|
+
export const numberStepperClass = cn("inline-flex size-10 shrink-0 items-center justify-center self-center", "text-muted-foreground outline-none", "transition-[background-color,color,transform]", "duration-[var(--kp-motion-duration)] ease-[var(--kp-motion-ease-standard)]", "hover:bg-muted/70 hover:text-foreground", "pressed:scale-[0.96] data-[pressed]:scale-[0.96]", "disabled:cursor-not-allowed disabled:opacity-45");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NumberFieldProps as AriaNumberFieldProps } from "react-aria-components";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { FieldSize, FieldVariant } from "../../styles/field";
|
|
4
|
+
export type NumberFieldVariant = FieldVariant;
|
|
5
|
+
export type NumberFieldSize = FieldSize;
|
|
6
|
+
export type NumberFieldProps = Omit<AriaNumberFieldProps, "className" | "children"> & {
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
errorMessage?: ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
inputClassName?: string;
|
|
12
|
+
variant?: NumberFieldVariant;
|
|
13
|
+
size?: NumberFieldSize;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { PaginationProps } from "./pagination.types";
|
|
2
|
+
export declare function Pagination({ "aria-label": ariaLabel, boundaryCount, className, defaultPage, getHref, isDisabled, nextLabel, onPageChange, page, previousLabel, siblingCount, size, total, }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Button, Link } from "react-aria-components";
|
|
5
|
+
import { cn } from "../../utils/cn";
|
|
6
|
+
import { paginationEllipsisClass, paginationItemClass, paginationListClass, paginationRootClass, } from "./pagination.styles";
|
|
7
|
+
import { getPaginationItems } from "./pagination.utils";
|
|
8
|
+
function Chevron({ direction }) {
|
|
9
|
+
return (_jsx("svg", { viewBox: "0 0 16 16", className: "size-4", "aria-hidden": true, children: _jsx("path", { d: direction === "prev"
|
|
10
|
+
? "M9.75 4.5 6.25 8l3.5 3.5"
|
|
11
|
+
: "M6.25 4.5 9.75 8l-3.5 3.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
12
|
+
}
|
|
13
|
+
export function Pagination({ "aria-label": ariaLabel = "Pagination", boundaryCount = 1, className, defaultPage = 1, getHref, isDisabled, nextLabel = "Next", onPageChange, page, previousLabel = "Previous", siblingCount = 1, size = "md", total, }) {
|
|
14
|
+
const controlled = page !== undefined;
|
|
15
|
+
const [uncontrolled, setUncontrolled] = useState(defaultPage);
|
|
16
|
+
const safeTotal = Math.max(1, Math.floor(total));
|
|
17
|
+
const current = Math.min(Math.max(1, Math.floor(controlled ? page : uncontrolled)), safeTotal);
|
|
18
|
+
const items = getPaginationItems(current, safeTotal, siblingCount, boundaryCount);
|
|
19
|
+
function goTo(next) {
|
|
20
|
+
const clamped = Math.min(Math.max(1, next), safeTotal);
|
|
21
|
+
if (clamped === current)
|
|
22
|
+
return;
|
|
23
|
+
if (!controlled)
|
|
24
|
+
setUncontrolled(clamped);
|
|
25
|
+
onPageChange?.(clamped);
|
|
26
|
+
}
|
|
27
|
+
function renderControl(target, { children, isCurrent = false, isNav = false, label, }) {
|
|
28
|
+
const itemClass = paginationItemClass(size, { isCurrent, isNav });
|
|
29
|
+
const disabled = Boolean(isDisabled) || (isNav && (target < 1 || target > safeTotal));
|
|
30
|
+
const currentProps = isCurrent ? { "aria-current": "page" } : {};
|
|
31
|
+
if (getHref && !disabled) {
|
|
32
|
+
return (_jsx(Link, { href: getHref(target), className: itemClass, "aria-label": label, onPress: () => goTo(target), ...currentProps, children: children }));
|
|
33
|
+
}
|
|
34
|
+
return (_jsx(Button, { className: itemClass, "aria-label": label, isDisabled: disabled, onPress: () => goTo(target), ...currentProps, children: children }));
|
|
35
|
+
}
|
|
36
|
+
return (_jsxs("nav", { "aria-label": ariaLabel, className: paginationRootClass(className), "data-kp-pagination": "", children: [_jsxs("ul", { className: paginationListClass(), children: [_jsx("li", { children: renderControl(current - 1, {
|
|
37
|
+
label: "Go to previous page",
|
|
38
|
+
isNav: true,
|
|
39
|
+
children: (_jsxs(_Fragment, { children: [_jsx(Chevron, { direction: "prev" }), _jsx("span", { children: previousLabel })] })),
|
|
40
|
+
}) }), items.map((item) => item.type === "ellipsis" ? (_jsx("li", { "aria-hidden": true, children: _jsx("span", { className: paginationEllipsisClass(size), children: "\u2026" }) }, item.key)) : (_jsx("li", { children: renderControl(item.page, {
|
|
41
|
+
label: `Go to page ${item.page}`,
|
|
42
|
+
isCurrent: item.page === current,
|
|
43
|
+
children: item.page,
|
|
44
|
+
}) }, item.page))), _jsx("li", { children: renderControl(current + 1, {
|
|
45
|
+
label: "Go to next page",
|
|
46
|
+
isNav: true,
|
|
47
|
+
children: (_jsxs(_Fragment, { children: [_jsx("span", { children: nextLabel }), _jsx(Chevron, { direction: "next" })] })),
|
|
48
|
+
}) })] }), _jsxs("p", { className: cn("m-0 font-mono text-xs tabular-nums text-muted-foreground"), children: ["Page ", current, " of ", safeTotal] })] }));
|
|
49
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PaginationSize } from "./pagination.types";
|
|
2
|
+
export declare function paginationRootClass(className?: string): string;
|
|
3
|
+
export declare function paginationListClass(): string;
|
|
4
|
+
export declare function paginationItemClass(size?: PaginationSize, { isCurrent, isNav, }?: {
|
|
5
|
+
isCurrent?: boolean;
|
|
6
|
+
isNav?: boolean;
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function paginationEllipsisClass(size?: PaginationSize): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn";
|
|
2
|
+
const sizes = {
|
|
3
|
+
sm: "min-h-10 min-w-10 px-2.5 text-xs rounded-[var(--kp-radius-sm)]",
|
|
4
|
+
md: "min-h-11 min-w-11 px-3 text-sm rounded-[var(--kp-radius-md)]",
|
|
5
|
+
lg: "min-h-12 min-w-12 px-3.5 text-base rounded-[var(--kp-radius-md)]",
|
|
6
|
+
};
|
|
7
|
+
export function paginationRootClass(className) {
|
|
8
|
+
return cn("inline-flex max-w-full flex-col gap-2", className);
|
|
9
|
+
}
|
|
10
|
+
export function paginationListClass() {
|
|
11
|
+
return "flex flex-wrap items-center gap-1.5 m-0 list-none p-0";
|
|
12
|
+
}
|
|
13
|
+
export function paginationItemClass(size = "md", { isCurrent = false, isNav = false, } = {}) {
|
|
14
|
+
return cn("inline-flex items-center justify-center font-medium tabular-nums outline-none", "border border-[color-mix(in_oklch,var(--kp-foreground)_14%,transparent)]", "bg-[color-mix(in_oklch,var(--kp-surface)_90%,var(--kp-foreground)_3%)] text-foreground", "shadow-[var(--kp-shadow-surface),inset_0_1px_0_oklch(1_0_0/35%)]", "transition-[transform,background-color,border-color,color,box-shadow]", "duration-[var(--kp-motion-duration)] ease-[cubic-bezier(0.2,0,0,1)]", "hover:bg-muted data-[pressed]:scale-[0.96] pressed:scale-[0.96]", "focus-visible:ring-2 focus-visible:ring-ring/40", "data-[disabled]:pointer-events-none data-[disabled]:opacity-45", "disabled:pointer-events-none disabled:opacity-45", sizes[size], isNav && "gap-1.5 px-3", isCurrent &&
|
|
15
|
+
cn("border-transparent bg-accent text-accent-foreground", "shadow-[0_1px_2px_oklch(0_0_0/14%),inset_0_1px_0_oklch(1_0_0/28%)]", "hover:brightness-[1.05]"));
|
|
16
|
+
}
|
|
17
|
+
export function paginationEllipsisClass(size = "md") {
|
|
18
|
+
return cn("inline-flex items-center justify-center text-muted-foreground", "font-mono tabular-nums", sizes[size]);
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type PaginationSize = "sm" | "md" | "lg";
|
|
3
|
+
export type PaginationProps = {
|
|
4
|
+
/** Total number of pages (minimum 1). */
|
|
5
|
+
total: number;
|
|
6
|
+
/** Controlled current page (1-indexed). */
|
|
7
|
+
page?: number;
|
|
8
|
+
/** Uncontrolled initial page (1-indexed). */
|
|
9
|
+
defaultPage?: number;
|
|
10
|
+
/** Called when the current page changes. */
|
|
11
|
+
onPageChange?: (page: number) => void;
|
|
12
|
+
/** Pages shown on each side of the current page. */
|
|
13
|
+
siblingCount?: number;
|
|
14
|
+
/** Always-visible pages at the start and end. */
|
|
15
|
+
boundaryCount?: number;
|
|
16
|
+
size?: PaginationSize;
|
|
17
|
+
className?: string;
|
|
18
|
+
/** Accessible name for the nav landmark. */
|
|
19
|
+
"aria-label"?: string;
|
|
20
|
+
/**
|
|
21
|
+
* When provided, page controls render as links using this href builder
|
|
22
|
+
* instead of buttons (useful for SEO-friendly listing pages).
|
|
23
|
+
*/
|
|
24
|
+
getHref?: (page: number) => string;
|
|
25
|
+
previousLabel?: ReactNode;
|
|
26
|
+
nextLabel?: ReactNode;
|
|
27
|
+
isDisabled?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type PaginationItem = {
|
|
30
|
+
type: "page";
|
|
31
|
+
page: number;
|
|
32
|
+
} | {
|
|
33
|
+
type: "ellipsis";
|
|
34
|
+
key: string;
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PaginationItem } from "./pagination.types";
|
|
2
|
+
/**
|
|
3
|
+
* Build a compact page list with ellipsis gaps, matching common sibling /
|
|
4
|
+
* boundary pagination patterns (1-indexed pages).
|
|
5
|
+
*/
|
|
6
|
+
export declare function getPaginationItems(page: number, total: number, siblingCount?: number, boundaryCount?: number): PaginationItem[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function range(start, end) {
|
|
2
|
+
const out = [];
|
|
3
|
+
for (let page = start; page <= end; page += 1)
|
|
4
|
+
out.push(page);
|
|
5
|
+
return out;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Build a compact page list with ellipsis gaps, matching common sibling /
|
|
9
|
+
* boundary pagination patterns (1-indexed pages).
|
|
10
|
+
*/
|
|
11
|
+
export function getPaginationItems(page, total, siblingCount = 1, boundaryCount = 1) {
|
|
12
|
+
const safeTotal = Math.max(1, Math.floor(total));
|
|
13
|
+
const safePage = Math.min(Math.max(1, Math.floor(page)), safeTotal);
|
|
14
|
+
const siblings = Math.max(0, Math.floor(siblingCount));
|
|
15
|
+
const boundaries = Math.max(1, Math.floor(boundaryCount));
|
|
16
|
+
const startPages = range(1, Math.min(boundaries, safeTotal));
|
|
17
|
+
const endPages = range(Math.max(safeTotal - boundaries + 1, boundaries + 1), safeTotal);
|
|
18
|
+
const siblingsStart = Math.max(Math.min(safePage - siblings, safeTotal - boundaries - siblings * 2 - 1), boundaries + 2);
|
|
19
|
+
const siblingsEnd = Math.min(Math.max(safePage + siblings, boundaries + siblings * 2 + 2), endPages.length > 0 ? endPages[0] - 2 : safeTotal - 1);
|
|
20
|
+
const items = startPages.map((value) => ({
|
|
21
|
+
type: "page",
|
|
22
|
+
page: value,
|
|
23
|
+
}));
|
|
24
|
+
if (siblingsStart > boundaries + 2) {
|
|
25
|
+
items.push({ type: "ellipsis", key: "start-ellipsis" });
|
|
26
|
+
}
|
|
27
|
+
else if (boundaries + 1 < safeTotal - boundaries) {
|
|
28
|
+
items.push({ type: "page", page: boundaries + 1 });
|
|
29
|
+
}
|
|
30
|
+
items.push(...range(siblingsStart, siblingsEnd).map((value) => ({
|
|
31
|
+
type: "page",
|
|
32
|
+
page: value,
|
|
33
|
+
})));
|
|
34
|
+
if (siblingsEnd < safeTotal - boundaries - 1) {
|
|
35
|
+
items.push({ type: "ellipsis", key: "end-ellipsis" });
|
|
36
|
+
}
|
|
37
|
+
else if (safeTotal - boundaries > boundaries) {
|
|
38
|
+
items.push({ type: "page", page: safeTotal - boundaries });
|
|
39
|
+
}
|
|
40
|
+
items.push(...endPages.map((value) => ({ type: "page", page: value })));
|
|
41
|
+
// De-dupe pages that can overlap on small totals.
|
|
42
|
+
const seen = new Set();
|
|
43
|
+
return items.filter((item) => {
|
|
44
|
+
if (item.type === "ellipsis")
|
|
45
|
+
return true;
|
|
46
|
+
if (seen.has(item.page))
|
|
47
|
+
return false;
|
|
48
|
+
seen.add(item.page);
|
|
49
|
+
return true;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PasswordField } from "./password-field";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { PasswordFieldProps } from "./password-field.types";
|
|
2
|
+
export declare function PasswordField({ className, defaultVisible, description, errorMessage, inputClassName: inputClass, label, placeholder, size, variant, ...props }: PasswordFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Button, FieldError, Group, Input, Label, Text, TextField as AriaTextField, } from "react-aria-components";
|
|
5
|
+
import { cn } from "../../utils/cn";
|
|
6
|
+
import { fieldDescriptionClass, fieldErrorClass, fieldLabelClass, fieldRootClass, fieldSurfaceProps, } from "../../styles/field";
|
|
7
|
+
import { passwordGroupClassName, passwordInputClass, passwordToggleClass, } from "./password-field.styles";
|
|
8
|
+
function EyeIcon({ open }) {
|
|
9
|
+
if (open) {
|
|
10
|
+
return (_jsxs("svg", { viewBox: "0 0 16 16", className: "size-4", "aria-hidden": true, children: [_jsx("path", { d: "M1.5 8s2.5-4.5 6.5-4.5S14.5 8 14.5 8s-2.5 4.5-6.5 4.5S1.5 8 1.5 8Z", fill: "none", stroke: "currentColor", strokeWidth: "1.4" }), _jsx("circle", { cx: "8", cy: "8", r: "2", fill: "none", stroke: "currentColor", strokeWidth: "1.4" }), _jsx("path", { d: "M2 2.5 14 13.5", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" })] }));
|
|
11
|
+
}
|
|
12
|
+
return (_jsxs("svg", { viewBox: "0 0 16 16", className: "size-4", "aria-hidden": true, children: [_jsx("path", { d: "M1.5 8s2.5-4.5 6.5-4.5S14.5 8 14.5 8s-2.5 4.5-6.5 4.5S1.5 8 1.5 8Z", fill: "none", stroke: "currentColor", strokeWidth: "1.4" }), _jsx("circle", { cx: "8", cy: "8", r: "2", fill: "none", stroke: "currentColor", strokeWidth: "1.4" })] }));
|
|
13
|
+
}
|
|
14
|
+
export function PasswordField({ className, defaultVisible = false, description, errorMessage, inputClassName: inputClass, label, placeholder, size = "md", variant = "outline", ...props }) {
|
|
15
|
+
const [visible, setVisible] = useState(defaultVisible);
|
|
16
|
+
return (_jsxs(AriaTextField, { ...props, className: cn(fieldRootClass, className), children: [label ? _jsx(Label, { className: fieldLabelClass, children: label }) : null, _jsxs(Group, { ...fieldSurfaceProps(variant), className: passwordGroupClassName({ size, variant }), children: [_jsx(Input, { type: visible ? "text" : "password", autoComplete: "current-password", className: cn(passwordInputClass, inputClass), ...(placeholder !== undefined ? { placeholder } : {}) }), _jsx(Button, { type: "button", className: passwordToggleClass, "aria-label": visible ? "Hide password" : "Show password", onPress: () => setVisible((value) => !value), children: _jsx(EyeIcon, { open: visible }) })] }), description ? (_jsx(Text, { slot: "description", className: fieldDescriptionClass, children: description })) : null, _jsx(FieldError, { className: fieldErrorClass, children: errorMessage })] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FieldSize, type FieldVariant } from "../../styles/field";
|
|
2
|
+
export declare function passwordGroupClassName({ className, size, variant, }?: {
|
|
3
|
+
className?: string | undefined;
|
|
4
|
+
size?: FieldSize | undefined;
|
|
5
|
+
variant?: FieldVariant | undefined;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare const passwordInputClass = "min-w-0 flex-1 bg-transparent p-0 text-foreground outline-none placeholder:text-muted-foreground";
|
|
8
|
+
export declare const passwordToggleClass: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn";
|
|
2
|
+
import { inputSurfaceClassName, } from "../../styles/field";
|
|
3
|
+
export function passwordGroupClassName({ className, size = "md", variant = "outline", } = {}) {
|
|
4
|
+
return cn(inputSurfaceClassName({ size, variant }), "flex items-center gap-1", className);
|
|
5
|
+
}
|
|
6
|
+
export const passwordInputClass = "min-w-0 flex-1 bg-transparent p-0 text-foreground outline-none placeholder:text-muted-foreground";
|
|
7
|
+
export const passwordToggleClass = cn("inline-flex size-10 shrink-0 items-center justify-center rounded-[calc(var(--kp-radius-sm)-0.05rem)]", "text-muted-foreground outline-none", "transition-[background-color,color,transform]", "duration-[var(--kp-motion-duration)] ease-[var(--kp-motion-ease-standard)]", "hover:bg-muted/70 hover:text-foreground", "pressed:scale-[0.96] data-[pressed]:scale-[0.96]");
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TextFieldProps as AriaTextFieldProps } from "react-aria-components";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { FieldSize, FieldVariant } from "../../styles/field";
|
|
4
|
+
export type PasswordFieldVariant = FieldVariant;
|
|
5
|
+
export type PasswordFieldSize = FieldSize;
|
|
6
|
+
export type PasswordFieldProps = Omit<AriaTextFieldProps, "className" | "children" | "type"> & {
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
errorMessage?: ReactNode;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
inputClassName?: string;
|
|
13
|
+
variant?: PasswordFieldVariant;
|
|
14
|
+
size?: PasswordFieldSize;
|
|
15
|
+
defaultVisible?: boolean;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Popover, PopoverBody, PopoverTitle, PopoverTrigger, } from "./popover";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { PopoverProps, PopoverTriggerProps } from "./popover.types";
|
|
3
|
+
export declare function PopoverTrigger(props: PopoverTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function Popover({ children, className, offset, placement, }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function PopoverTitle({ children }: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function PopoverBody({ children }: {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Dialog, DialogTrigger, Heading, Popover as AriaPopover, } from "react-aria-components";
|
|
4
|
+
import { popoverBodyClass, popoverClassName, popoverTitleClass, } from "./popover.styles";
|
|
5
|
+
export function PopoverTrigger(props) {
|
|
6
|
+
return _jsx(DialogTrigger, { ...props });
|
|
7
|
+
}
|
|
8
|
+
export function Popover({ children, className, offset = 8, placement = "bottom start", }) {
|
|
9
|
+
return (_jsx(AriaPopover, { placement: placement, offset: offset, className: popoverClassName(className), "data-kp-surface": true, children: _jsx(Dialog, { className: "outline-none", children: children }) }));
|
|
10
|
+
}
|
|
11
|
+
export function PopoverTitle({ children }) {
|
|
12
|
+
return (_jsx(Heading, { slot: "title", className: popoverTitleClass, children: children }));
|
|
13
|
+
}
|
|
14
|
+
export function PopoverBody({ children }) {
|
|
15
|
+
return _jsx("div", { className: popoverBodyClass, children: children });
|
|
16
|
+
}
|