@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,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { coerceMotionMode, loadMotionFeatures, motionConfigReduced, parseMotionPreference, resolveMotionMode, } from "@hewnui/motion";
|
|
4
|
+
import { LazyMotion, MotionConfig } from "motion/react";
|
|
5
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from "react";
|
|
6
|
+
const HewnMotionContext = createContext(null);
|
|
7
|
+
const STORAGE_KEY = "kp-motion";
|
|
8
|
+
export function MotionProvider({ children, defaultMotion = "full", }) {
|
|
9
|
+
const [motion, setMotionState] = useState(() => coerceMotionMode(defaultMotion));
|
|
10
|
+
const [reducedMotion, setReducedMotion] = useState(false);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const stored = parseMotionPreference(localStorage.getItem(STORAGE_KEY));
|
|
13
|
+
if (stored)
|
|
14
|
+
setMotionState(stored);
|
|
15
|
+
const query = matchMedia("(prefers-reduced-motion: reduce)");
|
|
16
|
+
const sync = () => setReducedMotion(query.matches);
|
|
17
|
+
sync();
|
|
18
|
+
query.addEventListener("change", sync);
|
|
19
|
+
return () => query.removeEventListener("change", sync);
|
|
20
|
+
}, []);
|
|
21
|
+
const effectiveMode = resolveMotionMode(motion, reducedMotion);
|
|
22
|
+
const motionEnabled = effectiveMode === "full";
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
document.documentElement.dataset.motion = effectiveMode;
|
|
25
|
+
localStorage.setItem(STORAGE_KEY, motion);
|
|
26
|
+
}, [motion, effectiveMode]);
|
|
27
|
+
const setMotion = useCallback((next) => {
|
|
28
|
+
setMotionState(next);
|
|
29
|
+
}, []);
|
|
30
|
+
const value = useMemo(() => ({
|
|
31
|
+
motion,
|
|
32
|
+
effectiveMode,
|
|
33
|
+
motionEnabled,
|
|
34
|
+
reducedMotion,
|
|
35
|
+
setMotion,
|
|
36
|
+
}), [motion, effectiveMode, motionEnabled, reducedMotion, setMotion]);
|
|
37
|
+
return (_jsx(HewnMotionContext.Provider, { value: value, children: _jsx(LazyMotion, { features: loadMotionFeatures, strict: true, children: _jsx(MotionConfig, { reducedMotion: motionConfigReduced(effectiveMode), children: children }) }) }));
|
|
38
|
+
}
|
|
39
|
+
export function useMotionMode() {
|
|
40
|
+
const value = useContext(HewnMotionContext);
|
|
41
|
+
if (!value) {
|
|
42
|
+
throw new Error("useMotionMode must be used within MotionProvider");
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export declare const radiusScales: readonly ["sharp", "soft", "rounded", "pill"];
|
|
3
|
+
export type RadiusScale = (typeof radiusScales)[number];
|
|
4
|
+
type RadiusContextValue = {
|
|
5
|
+
radius: RadiusScale;
|
|
6
|
+
setRadius: (radius: RadiusScale) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function RadiusProvider({ children, defaultRadius, }: {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
defaultRadius?: RadiusScale;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function useRadius(): RadiusContextValue;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from "react";
|
|
4
|
+
export const radiusScales = ["sharp", "soft", "rounded", "pill"];
|
|
5
|
+
const radiusTokens = {
|
|
6
|
+
sharp: {
|
|
7
|
+
sm: "0.125rem",
|
|
8
|
+
md: "0.2rem",
|
|
9
|
+
lg: "0.3rem",
|
|
10
|
+
panel: "0.25rem",
|
|
11
|
+
},
|
|
12
|
+
rounded: {
|
|
13
|
+
sm: "0.85rem",
|
|
14
|
+
md: "1.15rem",
|
|
15
|
+
lg: "1.5rem",
|
|
16
|
+
panel: "1.25rem",
|
|
17
|
+
},
|
|
18
|
+
pill: {
|
|
19
|
+
sm: "9999px",
|
|
20
|
+
md: "9999px",
|
|
21
|
+
lg: "1.5rem",
|
|
22
|
+
panel: "1.15rem",
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const radiusVars = [
|
|
26
|
+
"--kp-radius-sm",
|
|
27
|
+
"--kp-radius-md",
|
|
28
|
+
"--kp-radius-lg",
|
|
29
|
+
"--kp-radius-panel",
|
|
30
|
+
];
|
|
31
|
+
const RadiusContext = createContext(null);
|
|
32
|
+
const STORAGE_KEY = "kp-radius";
|
|
33
|
+
function isRadius(value) {
|
|
34
|
+
return radiusScales.includes(value);
|
|
35
|
+
}
|
|
36
|
+
function applyRadiusTokens(radius) {
|
|
37
|
+
const root = document.documentElement;
|
|
38
|
+
root.dataset.radius = radius;
|
|
39
|
+
if (radius === "soft") {
|
|
40
|
+
for (const key of radiusVars)
|
|
41
|
+
root.style.removeProperty(key);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const tokens = radiusTokens[radius];
|
|
45
|
+
root.style.setProperty("--kp-radius-sm", tokens.sm);
|
|
46
|
+
root.style.setProperty("--kp-radius-md", tokens.md);
|
|
47
|
+
root.style.setProperty("--kp-radius-lg", tokens.lg);
|
|
48
|
+
root.style.setProperty("--kp-radius-panel", tokens.panel);
|
|
49
|
+
}
|
|
50
|
+
export function RadiusProvider({ children, defaultRadius = "soft", }) {
|
|
51
|
+
const [radius, setRadiusState] = useState(defaultRadius);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
54
|
+
if (stored && isRadius(stored))
|
|
55
|
+
setRadiusState(stored);
|
|
56
|
+
}, []);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
applyRadiusTokens(radius);
|
|
59
|
+
localStorage.setItem(STORAGE_KEY, radius);
|
|
60
|
+
}, [radius]);
|
|
61
|
+
const setRadius = useCallback((next) => {
|
|
62
|
+
setRadiusState(next);
|
|
63
|
+
}, []);
|
|
64
|
+
const value = useMemo(() => ({ radius, setRadius }), [radius, setRadius]);
|
|
65
|
+
return (_jsx(RadiusContext.Provider, { value: value, children: children }));
|
|
66
|
+
}
|
|
67
|
+
export function useRadius() {
|
|
68
|
+
const value = useContext(RadiusContext);
|
|
69
|
+
if (!value) {
|
|
70
|
+
throw new Error("useRadius must be used within RadiusProvider");
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export declare const themePacks: {
|
|
3
|
+
readonly forest: readonly ["light", "dark"];
|
|
4
|
+
readonly tide: readonly ["light", "dark"];
|
|
5
|
+
readonly graphite: readonly ["light", "dark"];
|
|
6
|
+
readonly dune: readonly ["light"];
|
|
7
|
+
readonly clay: readonly ["light"];
|
|
8
|
+
readonly ember: readonly ["dark"];
|
|
9
|
+
};
|
|
10
|
+
export type ThemeName = keyof typeof themePacks;
|
|
11
|
+
export type ThemeMode = "light" | "dark";
|
|
12
|
+
type ThemeContextValue = {
|
|
13
|
+
theme: ThemeName;
|
|
14
|
+
mode: ThemeMode;
|
|
15
|
+
supportedModes: readonly ThemeMode[];
|
|
16
|
+
setTheme: (theme: ThemeName) => void;
|
|
17
|
+
setMode: (mode: ThemeMode) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare function ThemeProvider({ children, defaultTheme, defaultMode, }: {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
defaultTheme?: ThemeName;
|
|
22
|
+
defaultMode?: ThemeMode;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function useTheme(): ThemeContextValue;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from "react";
|
|
4
|
+
export const themePacks = {
|
|
5
|
+
forest: ["light", "dark"],
|
|
6
|
+
tide: ["light", "dark"],
|
|
7
|
+
graphite: ["light", "dark"],
|
|
8
|
+
dune: ["light"],
|
|
9
|
+
clay: ["light"],
|
|
10
|
+
ember: ["dark"],
|
|
11
|
+
};
|
|
12
|
+
const ThemeContext = createContext(null);
|
|
13
|
+
const THEME_KEY = "kp-theme";
|
|
14
|
+
const MODE_KEY = "kp-mode";
|
|
15
|
+
function isTheme(value) {
|
|
16
|
+
return value in themePacks;
|
|
17
|
+
}
|
|
18
|
+
function normalizeMode(theme, mode) {
|
|
19
|
+
const modes = themePacks[theme];
|
|
20
|
+
return modes.includes(mode) ? mode : modes[0];
|
|
21
|
+
}
|
|
22
|
+
export function ThemeProvider({ children, defaultTheme = "forest", defaultMode = "light", }) {
|
|
23
|
+
const [theme, setThemeState] = useState(defaultTheme);
|
|
24
|
+
const [mode, setModeState] = useState(normalizeMode(defaultTheme, defaultMode));
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const storedTheme = localStorage.getItem(THEME_KEY);
|
|
27
|
+
const storedMode = localStorage.getItem(MODE_KEY);
|
|
28
|
+
const nextTheme = storedTheme && isTheme(storedTheme) ? storedTheme : defaultTheme;
|
|
29
|
+
const parsedMode = storedMode === "dark" || storedMode === "light"
|
|
30
|
+
? storedMode
|
|
31
|
+
: defaultMode;
|
|
32
|
+
const nextMode = normalizeMode(nextTheme, parsedMode);
|
|
33
|
+
setThemeState(nextTheme);
|
|
34
|
+
setModeState(nextMode);
|
|
35
|
+
}, [defaultMode, defaultTheme]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const root = document.documentElement;
|
|
38
|
+
root.dataset.theme = theme;
|
|
39
|
+
root.dataset.mode = mode;
|
|
40
|
+
root.classList.toggle("dark", mode === "dark");
|
|
41
|
+
root.style.colorScheme = mode;
|
|
42
|
+
localStorage.setItem(THEME_KEY, theme);
|
|
43
|
+
localStorage.setItem(MODE_KEY, mode);
|
|
44
|
+
}, [mode, theme]);
|
|
45
|
+
const setTheme = useCallback((nextTheme) => {
|
|
46
|
+
setThemeState(nextTheme);
|
|
47
|
+
setModeState((current) => normalizeMode(nextTheme, current));
|
|
48
|
+
}, []);
|
|
49
|
+
const setMode = useCallback((nextMode) => {
|
|
50
|
+
setModeState(normalizeMode(theme, nextMode));
|
|
51
|
+
}, [theme]);
|
|
52
|
+
const value = useMemo(() => ({
|
|
53
|
+
theme,
|
|
54
|
+
mode,
|
|
55
|
+
supportedModes: themePacks[theme],
|
|
56
|
+
setTheme,
|
|
57
|
+
setMode,
|
|
58
|
+
}), [mode, setMode, setTheme, theme]);
|
|
59
|
+
return (_jsx(ThemeContext.Provider, { value: value, children: children }));
|
|
60
|
+
}
|
|
61
|
+
export function useTheme() {
|
|
62
|
+
const value = useContext(ThemeContext);
|
|
63
|
+
if (!value)
|
|
64
|
+
throw new Error("useTheme must be used within ThemeProvider");
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type FieldVariant = "outline" | "filled" | "flushed" | "glass";
|
|
2
|
+
export type FieldSize = "sm" | "md" | "lg";
|
|
3
|
+
export declare const fieldRootClass = "flex w-full max-w-sm flex-col gap-1.5 text-sm text-foreground";
|
|
4
|
+
export declare const fieldLabelClass = "font-medium tracking-tight text-foreground";
|
|
5
|
+
export declare const fieldDescriptionClass = "text-xs leading-relaxed text-muted-foreground";
|
|
6
|
+
export declare const fieldErrorClass = "text-xs leading-relaxed text-danger";
|
|
7
|
+
export declare function inputSurfaceClassName({ className, size, variant, }?: {
|
|
8
|
+
className?: string | undefined;
|
|
9
|
+
size?: FieldSize | undefined;
|
|
10
|
+
variant?: FieldVariant | undefined;
|
|
11
|
+
}): string;
|
|
12
|
+
/** @deprecated Prefer inputSurfaceClassName — kept for TextField call sites */
|
|
13
|
+
export declare const inputClassName: typeof inputSurfaceClassName;
|
|
14
|
+
/**
|
|
15
|
+
* Under glass material, boxed field variants inherit panel glass.
|
|
16
|
+
* Flushed stays underline-only and must never receive the panel inset ring.
|
|
17
|
+
*/
|
|
18
|
+
export declare function fieldSurfaceProps(variant?: FieldVariant): {
|
|
19
|
+
readonly "data-kp-field": "flushed";
|
|
20
|
+
readonly "data-kp-surface"?: never;
|
|
21
|
+
} | {
|
|
22
|
+
readonly "data-kp-surface": true;
|
|
23
|
+
readonly "data-kp-field"?: never;
|
|
24
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { cn } from "../utils/cn";
|
|
2
|
+
export const fieldRootClass = "flex w-full max-w-sm flex-col gap-1.5 text-sm text-foreground";
|
|
3
|
+
export const fieldLabelClass = "font-medium tracking-tight text-foreground";
|
|
4
|
+
export const fieldDescriptionClass = "text-xs leading-relaxed text-muted-foreground";
|
|
5
|
+
export const fieldErrorClass = "text-xs leading-relaxed text-danger";
|
|
6
|
+
const variants = {
|
|
7
|
+
outline: cn("border border-[color-mix(in_oklch,var(--kp-foreground)_16%,transparent)]", "bg-[color-mix(in_oklch,var(--kp-surface)_88%,var(--kp-foreground)_4%)]", "shadow-[var(--kp-shadow-surface),inset_0_1px_0_oklch(1_0_0/35%)]", "focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30", "focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30"),
|
|
8
|
+
filled: cn("border border-transparent", "bg-[color-mix(in_oklch,var(--kp-muted)_72%,transparent)]", "shadow-[inset_0_1px_0_oklch(1_0_0/18%)]", "hover:bg-[color-mix(in_oklch,var(--kp-muted)_88%,transparent)]", "focus-visible:border-ring focus-visible:bg-surface focus-visible:ring-2 focus-visible:ring-ring/30", "focus-within:border-ring focus-within:bg-surface focus-within:ring-2 focus-within:ring-ring/30"),
|
|
9
|
+
flushed: cn("rounded-none border-0 border-b-2 border-solid bg-transparent px-0", "border-b-[color-mix(in_oklch,var(--kp-foreground)_32%,transparent)]", "shadow-none", "focus-visible:border-b-ring focus-visible:ring-0", "focus-within:border-b-ring focus-within:ring-0", "focus-within:shadow-[0_1px_0_0_color-mix(in_oklch,var(--kp-ring)_55%,transparent)]"),
|
|
10
|
+
glass: cn("border border-[color-mix(in_oklch,var(--kp-foreground)_14%,transparent)]", "bg-[color-mix(in_oklch,var(--kp-surface)_42%,transparent)]", "backdrop-blur-md backdrop-saturate-150", "shadow-[inset_0_1px_0_oklch(1_0_0/42%),inset_0_0_0_1px_oklch(1_0_0/8%),0_8px_24px_-14px_oklch(0_0_0/28%)]", "focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30", "focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30"),
|
|
11
|
+
};
|
|
12
|
+
const sizes = {
|
|
13
|
+
sm: "min-h-9 px-2.5 text-xs rounded-[var(--kp-radius-sm)]",
|
|
14
|
+
md: "min-h-11 px-3 text-sm rounded-[var(--kp-radius-md)]",
|
|
15
|
+
lg: "min-h-12 px-4 text-base rounded-[var(--kp-radius-md)]",
|
|
16
|
+
};
|
|
17
|
+
export function inputSurfaceClassName({ className, size = "md", variant = "outline", } = {}) {
|
|
18
|
+
return cn("w-full text-foreground outline-none", "transition-[border-color,box-shadow,background-color,backdrop-filter]", "duration-[var(--kp-motion-duration)] ease-[var(--kp-motion-ease-standard)]", "placeholder:text-muted-foreground", "disabled:cursor-not-allowed disabled:opacity-45", "invalid:border-danger", variants[variant], variant !== "flushed"
|
|
19
|
+
? sizes[size]
|
|
20
|
+
: size === "sm"
|
|
21
|
+
? "min-h-8 text-xs"
|
|
22
|
+
: size === "lg"
|
|
23
|
+
? "min-h-11 text-base"
|
|
24
|
+
: "min-h-10 text-sm", className);
|
|
25
|
+
}
|
|
26
|
+
/** @deprecated Prefer inputSurfaceClassName — kept for TextField call sites */
|
|
27
|
+
export const inputClassName = inputSurfaceClassName;
|
|
28
|
+
/**
|
|
29
|
+
* Under glass material, boxed field variants inherit panel glass.
|
|
30
|
+
* Flushed stays underline-only and must never receive the panel inset ring.
|
|
31
|
+
*/
|
|
32
|
+
export function fieldSurfaceProps(variant = "outline") {
|
|
33
|
+
return variant === "flushed"
|
|
34
|
+
? { "data-kp-field": "flushed" }
|
|
35
|
+
: { "data-kp-surface": true };
|
|
36
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { cn } from "../utils/cn";
|
|
2
|
+
export const popoverSurfaceClass = cn("overflow-auto rounded-[var(--kp-radius-panel)] border bg-surface-raised p-1", "shadow-[var(--kp-shadow-surface)] outline-none");
|
|
3
|
+
export const menuItemClass = cn("flex cursor-default items-center gap-2 rounded-[var(--kp-radius-sm)]", "px-3 py-2 text-sm outline-none", "data-[focused]:bg-muted data-[disabled]:opacity-45");
|
|
4
|
+
export const fieldTriggerClass = cn("inline-flex min-h-11 w-full max-w-sm items-center justify-between gap-2", "rounded-[var(--kp-radius-md)] border bg-surface px-3 text-sm", "shadow-[var(--kp-shadow-surface)] outline-none", "transition-[transform,background-color,border-color]", "duration-[var(--kp-motion-duration)] ease-[var(--kp-motion-ease-standard)]", "data-[pressed]:scale-[0.96] data-[disabled]:opacity-45", "data-[focus-within]:ring-2 data-[focus-within]:ring-ring", "data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cn(...parts: Array<string | false | null | undefined>): string;
|
package/dist/utils/cn.js
ADDED