@seekalfred/primitives 0.6.0 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +214 -15
- package/dist/activity-heatmap/activity-heatmap.d.ts +92 -0
- package/dist/activity-heatmap/activity-heatmap.js +699 -0
- package/dist/activity-heatmap/activity-heatmap.js.map +1 -0
- package/dist/activity-heatmap/index.d.ts +2 -0
- package/dist/activity-heatmap/index.js +2 -0
- package/dist/alert/alert.d.ts +53 -4
- package/dist/alert/alert.js +100 -11
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert/index.d.ts +2 -2
- package/dist/alert/index.js +2 -2
- package/dist/alert-dialog/alert-dialog.d.ts +58 -18
- package/dist/alert-dialog/alert-dialog.js +152 -9
- package/dist/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/alert-dialog/index.d.ts +2 -2
- package/dist/alert-dialog/index.js +2 -2
- package/dist/animated-counter/animated-counter.d.ts +38 -0
- package/dist/animated-counter/animated-counter.js +230 -0
- package/dist/animated-counter/animated-counter.js.map +1 -0
- package/dist/animated-counter/index.d.ts +2 -0
- package/dist/animated-counter/index.js +2 -0
- package/dist/announcement-bar/announcement-bar.d.ts +67 -0
- package/dist/announcement-bar/announcement-bar.js +364 -0
- package/dist/announcement-bar/announcement-bar.js.map +1 -0
- package/dist/announcement-bar/index.d.ts +2 -0
- package/dist/announcement-bar/index.js +2 -0
- package/dist/badge/badge.d.ts +1 -1
- package/dist/bar-chart/bar-chart.d.ts +51 -0
- package/dist/bar-chart/bar-chart.js +565 -0
- package/dist/bar-chart/bar-chart.js.map +1 -0
- package/dist/bar-chart/index.d.ts +2 -0
- package/dist/bar-chart/index.js +2 -0
- package/dist/breadcrumb/breadcrumb.d.ts +2 -2
- package/dist/breadcrumb/breadcrumb.js +12 -3
- package/dist/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/brush-chart/brush-chart.d.ts +64 -0
- package/dist/brush-chart/brush-chart.js +1056 -0
- package/dist/brush-chart/brush-chart.js.map +1 -0
- package/dist/brush-chart/index.d.ts +2 -0
- package/dist/brush-chart/index.js +2 -0
- package/dist/button/button.d.ts +1 -1
- package/dist/button/button.js +31 -21
- package/dist/button/button.js.map +1 -1
- package/dist/button-group/button-group.js +3 -4
- package/dist/button-group/button-group.js.map +1 -1
- package/dist/calendar/calendar.d.ts +1 -1
- package/dist/card/card.d.ts +22 -1
- package/dist/card/card.js +60 -7
- package/dist/card/card.js.map +1 -1
- package/dist/card-stack/card-stack.d.ts +54 -0
- package/dist/card-stack/card-stack.js +492 -0
- package/dist/card-stack/card-stack.js.map +1 -0
- package/dist/card-stack/index.d.ts +2 -0
- package/dist/card-stack/index.js +2 -0
- package/dist/carousel/carousel.d.ts +77 -0
- package/dist/carousel/carousel.js +415 -0
- package/dist/carousel/carousel.js.map +1 -0
- package/dist/carousel/index.d.ts +2 -0
- package/dist/carousel/index.js +2 -0
- package/dist/checkbox/checkbox.js +4 -4
- package/dist/checkbox/checkbox.js.map +1 -1
- package/dist/chip-group/chip-group.d.ts +37 -0
- package/dist/chip-group/chip-group.js +148 -0
- package/dist/chip-group/chip-group.js.map +1 -0
- package/dist/chip-group/index.d.ts +2 -0
- package/dist/chip-group/index.js +2 -0
- package/dist/copy-button/copy-button.d.ts +18 -2
- package/dist/copy-button/copy-button.js +29 -8
- package/dist/copy-button/copy-button.js.map +1 -1
- package/dist/countdown/countdown.d.ts +45 -0
- package/dist/countdown/countdown.js +298 -0
- package/dist/countdown/countdown.js.map +1 -0
- package/dist/countdown/index.d.ts +2 -0
- package/dist/countdown/index.js +2 -0
- package/dist/date-picker/picker-parts.js +1 -1
- package/dist/date-picker/picker-parts.js.map +1 -1
- package/dist/dialog/dialog.js +1 -1
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/donut-chart/donut-chart.d.ts +86 -0
- package/dist/donut-chart/donut-chart.js +593 -0
- package/dist/donut-chart/donut-chart.js.map +1 -0
- package/dist/donut-chart/index.d.ts +2 -0
- package/dist/donut-chart/index.js +2 -0
- package/dist/empty-state/empty-state.d.ts +42 -10
- package/dist/empty-state/empty-state.js +44 -26
- package/dist/empty-state/empty-state.js.map +1 -1
- package/dist/empty-state/index.d.ts +2 -2
- package/dist/empty-state/index.js +2 -2
- package/dist/file-drop-zone/file-drop-zone.js +1 -1
- package/dist/file-drop-zone/file-drop-zone.js.map +1 -1
- package/dist/filter-bar/filter-bar.d.ts +50 -26
- package/dist/filter-bar/filter-bar.js +317 -157
- package/dist/filter-bar/filter-bar.js.map +1 -1
- package/dist/gauge/gauge.d.ts +45 -0
- package/dist/gauge/gauge.js +219 -0
- package/dist/gauge/gauge.js.map +1 -0
- package/dist/gauge/index.d.ts +2 -0
- package/dist/gauge/index.js +2 -0
- package/dist/in-view-title/in-view-title.d.ts +33 -0
- package/dist/in-view-title/in-view-title.js +119 -0
- package/dist/in-view-title/in-view-title.js.map +1 -0
- package/dist/in-view-title/index.d.ts +2 -0
- package/dist/in-view-title/index.js +2 -0
- package/dist/index.d.ts +53 -10
- package/dist/index.js +52 -12
- package/dist/input/input.js +4 -4
- package/dist/input/input.js.map +1 -1
- package/dist/lib/cn.js +11 -1
- package/dist/lib/cn.js.map +1 -1
- package/dist/lib/field-message.js +28 -10
- package/dist/lib/field-message.js.map +1 -1
- package/dist/lib/field-shell.js +10 -3
- package/dist/lib/field-shell.js.map +1 -1
- package/dist/lib/field-surface.js +31 -9
- package/dist/lib/field-surface.js.map +1 -1
- package/dist/lib/flag-emoji.js +50 -0
- package/dist/lib/flag-emoji.js.map +1 -0
- package/dist/lib/flip.js +11 -3
- package/dist/lib/flip.js.map +1 -1
- package/dist/lib/menu-highlight.js +64 -0
- package/dist/lib/menu-highlight.js.map +1 -0
- package/dist/lib/motion.js +9 -2
- package/dist/lib/motion.js.map +1 -1
- package/dist/lib/rolling-value.js +1 -1
- package/dist/lib/rolling-value.js.map +1 -1
- package/dist/lib/spring-tween.js +500 -0
- package/dist/lib/spring-tween.js.map +1 -0
- package/dist/lib/swap-text.js +3 -1
- package/dist/lib/swap-text.js.map +1 -1
- package/dist/lib/use-copy-feedback.js +17 -3
- package/dist/lib/use-copy-feedback.js.map +1 -1
- package/dist/line-chart/index.d.ts +2 -0
- package/dist/line-chart/index.js +2 -0
- package/dist/line-chart/line-chart.d.ts +116 -0
- package/dist/line-chart/line-chart.js +740 -0
- package/dist/line-chart/line-chart.js.map +1 -0
- package/dist/mention-input/index.d.ts +2 -0
- package/dist/mention-input/index.js +2 -0
- package/dist/mention-input/mention-input.d.ts +98 -0
- package/dist/mention-input/mention-input.js +576 -0
- package/dist/mention-input/mention-input.js.map +1 -0
- package/dist/menu/menu.d.ts +2 -0
- package/dist/menu/menu.js +23 -12
- package/dist/menu/menu.js.map +1 -1
- package/dist/money-input/index.d.ts +2 -0
- package/dist/money-input/index.js +2 -0
- package/dist/money-input/money-input.d.ts +86 -0
- package/dist/money-input/money-input.js +613 -0
- package/dist/money-input/money-input.js.map +1 -0
- package/dist/morph-select/index.d.ts +2 -0
- package/dist/morph-select/index.js +2 -0
- package/dist/morph-select/morph-select.d.ts +89 -0
- package/dist/morph-select/morph-select.js +712 -0
- package/dist/morph-select/morph-select.js.map +1 -0
- package/dist/multi-select/index.d.ts +2 -0
- package/dist/multi-select/index.js +2 -0
- package/dist/multi-select/multi-select.d.ts +77 -0
- package/dist/multi-select/multi-select.js +209 -0
- package/dist/multi-select/multi-select.js.map +1 -0
- package/dist/number-field/index.d.ts +2 -0
- package/dist/number-field/index.js +2 -0
- package/dist/number-field/number-field.d.ts +42 -0
- package/dist/number-field/number-field.js +199 -0
- package/dist/number-field/number-field.js.map +1 -0
- package/dist/onboarding-checklist/index.d.ts +2 -0
- package/dist/onboarding-checklist/index.js +2 -0
- package/dist/onboarding-checklist/onboarding-checklist.d.ts +55 -0
- package/dist/onboarding-checklist/onboarding-checklist.js +577 -0
- package/dist/onboarding-checklist/onboarding-checklist.js.map +1 -0
- package/dist/password-field/password-field.d.ts +16 -0
- package/dist/password-field/password-field.js +39 -10
- package/dist/password-field/password-field.js.map +1 -1
- package/dist/phone-input/index.d.ts +3 -0
- package/dist/phone-input/index.js +3 -0
- package/dist/phone-input/phone-countries.d.ts +29 -0
- package/dist/phone-input/phone-countries.js +170 -0
- package/dist/phone-input/phone-countries.js.map +1 -0
- package/dist/phone-input/phone-input.d.ts +66 -0
- package/dist/phone-input/phone-input.js +440 -0
- package/dist/phone-input/phone-input.js.map +1 -0
- package/dist/popover/index.d.ts +2 -2
- package/dist/popover/index.js +2 -2
- package/dist/popover/popover.d.ts +51 -2
- package/dist/popover/popover.js +59 -8
- package/dist/popover/popover.js.map +1 -1
- package/dist/progress/progress.d.ts +16 -2
- package/dist/progress/progress.js +16 -9
- package/dist/progress/progress.js.map +1 -1
- package/dist/radio-group/index.d.ts +2 -2
- package/dist/radio-group/index.js +2 -2
- package/dist/radio-group/radio-group.d.ts +33 -3
- package/dist/radio-group/radio-group.js +110 -10
- package/dist/radio-group/radio-group.js.map +1 -1
- package/dist/reactions/index.d.ts +2 -0
- package/dist/reactions/index.js +2 -0
- package/dist/reactions/reactions.d.ts +50 -0
- package/dist/reactions/reactions.js +315 -0
- package/dist/reactions/reactions.js.map +1 -0
- package/dist/rich-text-editor/index.d.ts +3 -0
- package/dist/rich-text-editor/index.js +2 -0
- package/dist/rich-text-editor/rich-text-editor.d.ts +70 -0
- package/dist/rich-text-editor/rich-text-editor.js +909 -0
- package/dist/rich-text-editor/rich-text-editor.js.map +1 -0
- package/dist/rich-text-editor/rich-text-engine.d.ts +16 -0
- package/dist/rich-text-editor/rich-text-engine.js +366 -0
- package/dist/rich-text-editor/rich-text-engine.js.map +1 -0
- package/dist/rich-text-editor/rich-text-html.js +174 -0
- package/dist/rich-text-editor/rich-text-html.js.map +1 -0
- package/dist/rich-text-editor/rich-text-icons.js +43 -0
- package/dist/rich-text-editor/rich-text-icons.js.map +1 -0
- package/dist/ridgeline/index.d.ts +2 -0
- package/dist/ridgeline/index.js +2 -0
- package/dist/ridgeline/ridgeline.d.ts +55 -0
- package/dist/ridgeline/ridgeline.js +701 -0
- package/dist/ridgeline/ridgeline.js.map +1 -0
- package/dist/scroll-area/index.d.ts +2 -2
- package/dist/scroll-area/index.js +2 -2
- package/dist/scroll-area/scroll-area.d.ts +68 -31
- package/dist/scroll-area/scroll-area.js +212 -62
- package/dist/scroll-area/scroll-area.js.map +1 -1
- package/dist/scrub-input/evaluate.d.ts +14 -0
- package/dist/scrub-input/evaluate.js +72 -0
- package/dist/scrub-input/evaluate.js.map +1 -0
- package/dist/scrub-input/index.d.ts +3 -0
- package/dist/scrub-input/index.js +3 -0
- package/dist/scrub-input/scrub-input.d.ts +74 -0
- package/dist/scrub-input/scrub-input.js +486 -0
- package/dist/scrub-input/scrub-input.js.map +1 -0
- package/dist/search-field/search-field.d.ts +24 -2
- package/dist/search-field/search-field.js +24 -9
- package/dist/search-field/search-field.js.map +1 -1
- package/dist/select/select.d.ts +3 -1
- package/dist/select/select.js +28 -14
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +22 -10
- package/dist/separator/separator.js +33 -11
- package/dist/separator/separator.js.map +1 -1
- package/dist/sheet/sheet.js +2 -1
- package/dist/sheet/sheet.js.map +1 -1
- package/dist/shortcut-recorder/index.d.ts +3 -0
- package/dist/shortcut-recorder/index.js +3 -0
- package/dist/shortcut-recorder/shortcut-model.d.ts +27 -0
- package/dist/shortcut-recorder/shortcut-model.js +206 -0
- package/dist/shortcut-recorder/shortcut-model.js.map +1 -0
- package/dist/shortcut-recorder/shortcut-recorder.d.ts +93 -0
- package/dist/shortcut-recorder/shortcut-recorder.js +489 -0
- package/dist/shortcut-recorder/shortcut-recorder.js.map +1 -0
- package/dist/slider/index.d.ts +2 -2
- package/dist/slider/slider.d.ts +46 -14
- package/dist/slider/slider.js +151 -67
- package/dist/slider/slider.js.map +1 -1
- package/dist/slope-chart/index.d.ts +2 -0
- package/dist/slope-chart/index.js +2 -0
- package/dist/slope-chart/slope-chart.d.ts +54 -0
- package/dist/slope-chart/slope-chart.js +568 -0
- package/dist/slope-chart/slope-chart.js.map +1 -0
- package/dist/sparkline/index.d.ts +2 -0
- package/dist/sparkline/index.js +2 -0
- package/dist/sparkline/sparkline.d.ts +46 -0
- package/dist/sparkline/sparkline.js +390 -0
- package/dist/sparkline/sparkline.js.map +1 -0
- package/dist/split-bar/index.d.ts +2 -0
- package/dist/split-bar/index.js +2 -0
- package/dist/split-bar/split-bar.d.ts +62 -0
- package/dist/split-bar/split-bar.js +513 -0
- package/dist/split-bar/split-bar.js.map +1 -0
- package/dist/split-button/split-button.d.ts +1 -1
- package/dist/split-button/split-button.js +12 -11
- package/dist/split-button/split-button.js.map +1 -1
- package/dist/stat-card/index.d.ts +2 -2
- package/dist/stat-card/index.js +2 -2
- package/dist/stat-card/stat-card.d.ts +58 -5
- package/dist/stat-card/stat-card.js +144 -17
- package/dist/stat-card/stat-card.js.map +1 -1
- package/dist/stepper/index.d.ts +2 -0
- package/dist/stepper/index.js +2 -0
- package/dist/stepper/stepper.d.ts +51 -0
- package/dist/stepper/stepper.js +215 -0
- package/dist/stepper/stepper.js.map +1 -0
- package/dist/streamgraph/index.d.ts +2 -0
- package/dist/streamgraph/index.js +2 -0
- package/dist/streamgraph/streamgraph.d.ts +70 -0
- package/dist/streamgraph/streamgraph.js +613 -0
- package/dist/streamgraph/streamgraph.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/swipe-actions/index.d.ts +2 -0
- package/dist/swipe-actions/index.js +2 -0
- package/dist/swipe-actions/swipe-actions.d.ts +67 -0
- package/dist/swipe-actions/swipe-actions.js +552 -0
- package/dist/swipe-actions/swipe-actions.js.map +1 -0
- package/dist/switch/switch.js +2 -2
- package/dist/switch/switch.js.map +1 -1
- package/dist/table/index.d.ts +2 -2
- package/dist/table/index.js +2 -2
- package/dist/table/table.d.ts +55 -3
- package/dist/table/table.js +340 -165
- package/dist/table/table.js.map +1 -1
- package/dist/tabs/tabs.js +2 -2
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/tag-input/index.d.ts +2 -0
- package/dist/tag-input/index.js +2 -0
- package/dist/tag-input/tag-input.d.ts +40 -0
- package/dist/tag-input/tag-input.js +269 -0
- package/dist/tag-input/tag-input.js.map +1 -0
- package/dist/text-morph/index.d.ts +2 -0
- package/dist/text-morph/index.js +2 -0
- package/dist/text-morph/text-morph.d.ts +23 -0
- package/dist/text-morph/text-morph.js +21 -0
- package/dist/text-morph/text-morph.js.map +1 -0
- package/dist/text-reveal/index.d.ts +2 -0
- package/dist/text-reveal/index.js +2 -0
- package/dist/text-reveal/text-reveal.d.ts +27 -0
- package/dist/text-reveal/text-reveal.js +51 -0
- package/dist/text-reveal/text-reveal.js.map +1 -0
- package/dist/text-shimmer/index.d.ts +2 -0
- package/dist/text-shimmer/index.js +2 -0
- package/dist/text-shimmer/text-shimmer.d.ts +29 -0
- package/dist/text-shimmer/text-shimmer.js +29 -0
- package/dist/text-shimmer/text-shimmer.js.map +1 -0
- package/dist/time-picker/time-picker.d.ts +36 -1
- package/dist/time-picker/time-picker.js +35 -7
- package/dist/time-picker/time-picker.js.map +1 -1
- package/dist/toast/index.d.ts +2 -2
- package/dist/toast/index.js +2 -2
- package/dist/toast/toast.d.ts +7 -1
- package/dist/toast/toast.js +82 -40
- package/dist/toast/toast.js.map +1 -1
- package/dist/tooltip/tooltip.d.ts +9 -2
- package/dist/tooltip/tooltip.js +7 -7
- package/dist/tooltip/tooltip.js.map +1 -1
- package/dist/treemap/index.d.ts +2 -0
- package/dist/treemap/index.js +2 -0
- package/dist/treemap/treemap.d.ts +53 -0
- package/dist/treemap/treemap.js +699 -0
- package/dist/treemap/treemap.js.map +1 -0
- package/dist/usage-meter/index.d.ts +2 -0
- package/dist/usage-meter/index.js +2 -0
- package/dist/usage-meter/usage-meter.d.ts +80 -0
- package/dist/usage-meter/usage-meter.js +458 -0
- package/dist/usage-meter/usage-meter.js.map +1 -0
- package/dist/waffle-chart/index.d.ts +2 -0
- package/dist/waffle-chart/index.js +2 -0
- package/dist/waffle-chart/waffle-chart.d.ts +57 -0
- package/dist/waffle-chart/waffle-chart.js +426 -0
- package/dist/waffle-chart/waffle-chart.js.map +1 -0
- package/package.json +165 -3
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn, cnAll } from "../lib/cn.js";
|
|
3
|
+
import { fieldSurfaceVariants } from "../lib/field-surface.js";
|
|
4
|
+
import { Label as Label$1 } from "../label/label.js";
|
|
5
|
+
import { FieldMessage, RollingNumber } from "../lib/field-message.js";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { forwardRef, useContext, useId, useRef, useState } from "react";
|
|
8
|
+
import { Button, Group, Input, NumberField, NumberFieldStateContext } from "react-aria-components";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/number-field/number-field.tsx
|
|
11
|
+
const controlVariants = cva([
|
|
12
|
+
fieldSurfaceVariants(),
|
|
13
|
+
"flex items-center gap-0.5 p-0.75",
|
|
14
|
+
"data-[focus-within]:not-data-[invalid]:border-foreground",
|
|
15
|
+
"forced-colors:data-[focus-within]:outline-solid forced-colors:data-[focus-within]:outline-(length:--focus-ring-width) forced-colors:data-[focus-within]:outline-offset-(--focus-ring-offset)"
|
|
16
|
+
], {
|
|
17
|
+
variants: { size: {
|
|
18
|
+
sm: "h-(--density-control-h-sm)",
|
|
19
|
+
md: "h-(--density-control-h-md)",
|
|
20
|
+
lg: "h-(--density-control-h-lg)"
|
|
21
|
+
} },
|
|
22
|
+
defaultVariants: { size: "md" }
|
|
23
|
+
});
|
|
24
|
+
const stepVariants = cva([
|
|
25
|
+
"grid shrink-0 place-items-center rounded-md border-0 bg-transparent p-0",
|
|
26
|
+
"cursor-pointer text-text-secondary outline-none",
|
|
27
|
+
"motion-safe:transition-[background-color,color,scale] motion-safe:duration-(--duration-quick) motion-safe:ease-settle",
|
|
28
|
+
"data-[hovered]:bg-muted data-[hovered]:text-foreground",
|
|
29
|
+
"data-[pressed]:bg-muted data-[pressed]:text-foreground data-[pressed]:scale-95",
|
|
30
|
+
"motion-safe:data-[pressed]:duration-(--duration-instant)",
|
|
31
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-(--opacity-disabled)",
|
|
32
|
+
"[&_svg]:pointer-events-none [&_svg]:size-4"
|
|
33
|
+
], {
|
|
34
|
+
variants: { size: {
|
|
35
|
+
sm: "size-7",
|
|
36
|
+
md: "size-9",
|
|
37
|
+
lg: "size-12"
|
|
38
|
+
} },
|
|
39
|
+
defaultVariants: { size: "md" }
|
|
40
|
+
});
|
|
41
|
+
/** How far, in px, the digits are pushed toward a limit they just met. */
|
|
42
|
+
const STRAIN_PX = 5;
|
|
43
|
+
const decimalsOf = (value) => (String(value).split(".")[1] ?? "").length;
|
|
44
|
+
function Control({ size, placeholder, largeStep, step, min, max, inputRef }) {
|
|
45
|
+
const state = useContext(NumberFieldStateContext);
|
|
46
|
+
const displayRef = useRef(null);
|
|
47
|
+
const [typing, setTyping] = useState(false);
|
|
48
|
+
const value = state?.numberValue ?? NaN;
|
|
49
|
+
const [trail, setTrail] = useState({
|
|
50
|
+
value,
|
|
51
|
+
direction: 1
|
|
52
|
+
});
|
|
53
|
+
if (!Object.is(trail.value, value)) setTrail({
|
|
54
|
+
value,
|
|
55
|
+
direction: !Number.isNaN(value) && !Number.isNaN(trail.value) && value < trail.value ? -1 : 1
|
|
56
|
+
});
|
|
57
|
+
const text = (state?.inputValue ?? "").replace(/ /g, "\xA0");
|
|
58
|
+
function strain(y) {
|
|
59
|
+
const node = displayRef.current;
|
|
60
|
+
if (!node) return;
|
|
61
|
+
node.style.setProperty("--strain-y", `${y}px`);
|
|
62
|
+
node.removeAttribute("data-strain");
|
|
63
|
+
node.offsetWidth;
|
|
64
|
+
node.setAttribute("data-strain", "");
|
|
65
|
+
}
|
|
66
|
+
/** PageUp, PageDown and Shift with an arrow take a large step. Runs in the capture phase, so React Aria's own single step does not also run. */
|
|
67
|
+
function onKeyDownCapture(event) {
|
|
68
|
+
if (!state) return;
|
|
69
|
+
const page = event.key === "PageUp" || event.key === "PageDown";
|
|
70
|
+
const arrow = event.shiftKey && (event.key === "ArrowUp" || event.key === "ArrowDown");
|
|
71
|
+
if (!page && !arrow) return;
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
event.stopPropagation();
|
|
74
|
+
setTyping(false);
|
|
75
|
+
const toward = event.key.endsWith("Up") ? 1 : -1;
|
|
76
|
+
if (toward > 0 ? !state.canIncrement : !state.canDecrement) {
|
|
77
|
+
strain(-toward * STRAIN_PX);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const next = (Number.isNaN(state.numberValue) ? min ?? 0 : state.numberValue) + toward * (largeStep ?? step * 10);
|
|
81
|
+
const places = Math.max(decimalsOf(step), decimalsOf(largeStep ?? step));
|
|
82
|
+
state.setNumberValue(Number(Math.min(max ?? Infinity, Math.max(min ?? -Infinity, next)).toFixed(places)));
|
|
83
|
+
}
|
|
84
|
+
function onKeyDown(event) {
|
|
85
|
+
const up = event.key === "ArrowUp";
|
|
86
|
+
const down = event.key === "ArrowDown";
|
|
87
|
+
if (up || down || event.key === "Home" || event.key === "End") setTyping(false);
|
|
88
|
+
if (!state) return;
|
|
89
|
+
if ((up || event.key === "End") && !state.canIncrement) strain(-5);
|
|
90
|
+
if ((down || event.key === "Home") && !state.canDecrement) strain(STRAIN_PX);
|
|
91
|
+
}
|
|
92
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
93
|
+
role: "presentation",
|
|
94
|
+
"data-slot": "number-field-control",
|
|
95
|
+
className: controlVariants({ size }),
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ jsx(Button, {
|
|
98
|
+
slot: "decrement",
|
|
99
|
+
"data-slot": "number-field-decrement",
|
|
100
|
+
onPressStart: () => setTyping(false),
|
|
101
|
+
className: stepVariants({ size }),
|
|
102
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
viewBox: "0 0 16 16",
|
|
105
|
+
fill: "none",
|
|
106
|
+
stroke: "currentColor",
|
|
107
|
+
strokeWidth: "1.75",
|
|
108
|
+
strokeLinecap: "round",
|
|
109
|
+
children: /* @__PURE__ */ jsx("path", { d: "M3.5 8h9" })
|
|
110
|
+
})
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ jsxs("div", {
|
|
113
|
+
className: "relative grid min-w-0 flex-1 cursor-text place-items-center self-stretch",
|
|
114
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
115
|
+
ref: displayRef,
|
|
116
|
+
"aria-hidden": "true",
|
|
117
|
+
"data-slot": "number-field-display",
|
|
118
|
+
className: "pointer-events-none inline-flex items-center whitespace-nowrap font-sans text-base font-medium tabular-nums text-foreground data-[strain]:motion-safe:animate-field-strain",
|
|
119
|
+
children: text ? /* @__PURE__ */ jsx(RollingNumber, {
|
|
120
|
+
word: text,
|
|
121
|
+
direction: trail.direction,
|
|
122
|
+
still: typing
|
|
123
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
124
|
+
className: "text-muted-foreground",
|
|
125
|
+
children: placeholder
|
|
126
|
+
})
|
|
127
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
128
|
+
ref: inputRef,
|
|
129
|
+
"data-slot": "number-field-input",
|
|
130
|
+
onChange: () => setTyping(true),
|
|
131
|
+
onBlur: () => setTyping(false),
|
|
132
|
+
onKeyDownCapture,
|
|
133
|
+
onKeyDown,
|
|
134
|
+
className: "absolute inset-0 z-10 m-0 h-full w-full min-w-0 border-0 bg-transparent p-0 text-center font-sans text-base font-medium tabular-nums text-transparent caret-foreground outline-none selection:bg-primary/20 selection:text-transparent data-[disabled]:cursor-not-allowed"
|
|
135
|
+
})]
|
|
136
|
+
}),
|
|
137
|
+
/* @__PURE__ */ jsx(Button, {
|
|
138
|
+
slot: "increment",
|
|
139
|
+
"data-slot": "number-field-increment",
|
|
140
|
+
onPressStart: () => setTyping(false),
|
|
141
|
+
className: stepVariants({ size }),
|
|
142
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
143
|
+
"aria-hidden": "true",
|
|
144
|
+
viewBox: "0 0 16 16",
|
|
145
|
+
fill: "none",
|
|
146
|
+
stroke: "currentColor",
|
|
147
|
+
strokeWidth: "1.75",
|
|
148
|
+
strokeLinecap: "round",
|
|
149
|
+
children: /* @__PURE__ */ jsx("path", { d: "M3.5 8h9M8 3.5v9" })
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const NumberField$1 = forwardRef(function NumberField$2({ label, labelHidden, description, error, placeholder, largeStep, size = "md", className, isInvalid, "aria-describedby": describedBy, ...props }, ref) {
|
|
156
|
+
const id = useId();
|
|
157
|
+
const hintId = description ? `${id}-description` : void 0;
|
|
158
|
+
const errorId = error ? `${id}-error` : void 0;
|
|
159
|
+
return /* @__PURE__ */ jsxs(NumberField, {
|
|
160
|
+
...props,
|
|
161
|
+
isInvalid: isInvalid || Boolean(error),
|
|
162
|
+
"aria-describedby": [
|
|
163
|
+
describedBy,
|
|
164
|
+
hintId,
|
|
165
|
+
errorId
|
|
166
|
+
].filter(Boolean).join(" ") || void 0,
|
|
167
|
+
"data-slot": "number-field",
|
|
168
|
+
className: cn("grid w-full min-w-0 max-w-64 font-sans", className),
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ jsx(Label$1, {
|
|
171
|
+
className: cnAll("mb-1.5", labelHidden && "sr-only"),
|
|
172
|
+
children: label
|
|
173
|
+
}),
|
|
174
|
+
/* @__PURE__ */ jsx(Control, {
|
|
175
|
+
size,
|
|
176
|
+
placeholder,
|
|
177
|
+
largeStep,
|
|
178
|
+
step: props.step ?? 1,
|
|
179
|
+
min: props.minValue,
|
|
180
|
+
max: props.maxValue,
|
|
181
|
+
inputRef: ref
|
|
182
|
+
}),
|
|
183
|
+
/* @__PURE__ */ jsx(FieldMessage, {
|
|
184
|
+
id: hintId,
|
|
185
|
+
text: description,
|
|
186
|
+
tone: "description"
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ jsx(FieldMessage, {
|
|
189
|
+
id: errorId,
|
|
190
|
+
text: error,
|
|
191
|
+
tone: "error"
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
//#endregion
|
|
197
|
+
export { NumberField$1 as NumberField };
|
|
198
|
+
|
|
199
|
+
//# sourceMappingURL=number-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field.js","names":["AriaGroup","AriaButton","AriaInput","NumberField","AriaNumberField","Label"],"sources":["../../src/number-field/number-field.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport { forwardRef, useContext, useId, useRef, useState, type KeyboardEvent, type Ref } from \"react\";\nimport {\n Button as AriaButton,\n Group as AriaGroup,\n Input as AriaInput,\n NumberField as AriaNumberField,\n NumberFieldStateContext,\n type NumberFieldProps as AriaNumberFieldProps,\n} from \"react-aria-components\";\n\nimport { Label } from \"../label/label.js\";\nimport { cn, cnAll } from \"../lib/cn.js\";\nimport { FieldMessage, RollingNumber } from \"../lib/field-message.js\";\nimport { fieldSurfaceVariants } from \"../lib/field-surface.js\";\n\n/**\n * NumberField: a number with stepper buttons and rolling digits, on React Aria's\n * `NumberField`. Parsing and formatting follow the locale, the arrow keys, PageUp,\n * PageDown, Home and End step and jump, a held stepper repeats, and the field\n * clamps to `minValue` and `maxValue` and snaps to `step`. A currency, a percent\n * or a unit comes from `formatOptions`.\n *\n * The digits you see are drawn over the real input: each place value is its own\n * column, so 9 to 10 opens a column and rolls the ones, and a gained or lost digit\n * opens or closes its width. While you type, the columns follow the text at once\n * and the caret never lags; the roll returns with the next step. A press at a limit\n * (an arrow key past the maximum) pushes the digits toward it and they spring home.\n *\n * `description` and `error` open under the field on a spring, as Input's do.\n */\nexport interface NumberFieldProps extends Omit<\n AriaNumberFieldProps,\n \"className\" | \"style\" | \"children\"\n> {\n /** What the number is, and the field's accessible name. */\n label: string;\n /** Render the label for screen readers only. */\n labelHidden?: boolean;\n /** Helper text under the field. A string, because the copy is animated word by word. */\n description?: string;\n /** Error text under the field. Sets `aria-invalid` and is announced as an alert. */\n error?: string;\n /** Shown, muted, while the field is empty. */\n placeholder?: string;\n /** PageUp, PageDown and Shift with an arrow move this far. React Aria steps by one on PageUp. Defaults to ten steps. */\n largeStep?: number;\n /**\n * Control scale: the same heights as Input and Button.\n * @default \"md\"\n */\n size?: \"sm\" | \"md\" | \"lg\";\n /** Extra classes for the wrapper. Merged last. */\n className?: string;\n}\n\nconst controlVariants = cva(\n [\n fieldSurfaceVariants(),\n \"flex items-center gap-0.5 p-0.75\",\n // Focus turns the box's own border dark whenever the input holds focus; no separate ring.\n \"data-[focus-within]:not-data-[invalid]:border-foreground\",\n \"forced-colors:data-[focus-within]:outline-solid forced-colors:data-[focus-within]:outline-(length:--focus-ring-width) forced-colors:data-[focus-within]:outline-offset-(--focus-ring-offset)\",\n ],\n {\n variants: {\n size: {\n sm: \"h-(--density-control-h-sm)\",\n md: \"h-(--density-control-h-md)\",\n lg: \"h-(--density-control-h-lg)\",\n },\n },\n defaultVariants: { size: \"md\" },\n },\n);\n\nconst stepVariants = cva(\n [\n \"grid shrink-0 place-items-center rounded-md border-0 bg-transparent p-0\",\n \"cursor-pointer text-text-secondary outline-none\",\n \"motion-safe:transition-[background-color,color,scale] motion-safe:duration-(--duration-quick) motion-safe:ease-settle\",\n \"data-[hovered]:bg-muted data-[hovered]:text-foreground\",\n \"data-[pressed]:bg-muted data-[pressed]:text-foreground data-[pressed]:scale-95\",\n \"motion-safe:data-[pressed]:duration-(--duration-instant)\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-(--opacity-disabled)\",\n \"[&_svg]:pointer-events-none [&_svg]:size-4\",\n ],\n {\n variants: {\n size: { sm: \"size-7\", md: \"size-9\", lg: \"size-12\" },\n },\n defaultVariants: { size: \"md\" },\n },\n);\n\n/** How far, in px, the digits are pushed toward a limit they just met. */\nconst STRAIN_PX = 5;\n\nconst decimalsOf = (value: number) => (String(value).split(\".\")[1] ?? \"\").length;\n\nfunction Control({\n size,\n placeholder,\n largeStep,\n step,\n min,\n max,\n inputRef,\n}: {\n size: \"sm\" | \"md\" | \"lg\";\n placeholder: string | undefined;\n largeStep: number | undefined;\n step: number;\n min: number | undefined;\n max: number | undefined;\n inputRef: Ref<HTMLInputElement>;\n}) {\n const state = useContext(NumberFieldStateContext);\n const displayRef = useRef<HTMLSpanElement>(null);\n // While the text is being typed the digits follow it at once; a step brings the roll back.\n const [typing, setTyping] = useState(false);\n const value = state?.numberValue ?? Number.NaN;\n const [trail, setTrail] = useState({ value, direction: 1 as 1 | -1 });\n // Object.is: an empty field is NaN, which is never equal to itself.\n if (!Object.is(trail.value, value)) {\n const known = !Number.isNaN(value) && !Number.isNaN(trail.value);\n setTrail({ value, direction: known && value < trail.value ? -1 : 1 });\n }\n const text = (state?.inputValue ?? \"\").replace(/ /g, \" \");\n\n function strain(y: number) {\n const node = displayRef.current;\n if (!node) return;\n node.style.setProperty(\"--strain-y\", `${y}px`);\n // Restart the animation: the attribute has to leave and come back across a style recalculation.\n node.removeAttribute(\"data-strain\");\n void node.offsetWidth;\n node.setAttribute(\"data-strain\", \"\");\n }\n\n /** PageUp, PageDown and Shift with an arrow take a large step. Runs in the capture phase, so React Aria's own single step does not also run. */\n function onKeyDownCapture(event: KeyboardEvent<HTMLInputElement>) {\n if (!state) return;\n const page = event.key === \"PageUp\" || event.key === \"PageDown\";\n const arrow = event.shiftKey && (event.key === \"ArrowUp\" || event.key === \"ArrowDown\");\n if (!page && !arrow) return;\n event.preventDefault();\n event.stopPropagation();\n setTyping(false);\n const toward = event.key.endsWith(\"Up\") ? 1 : -1;\n if (toward > 0 ? !state.canIncrement : !state.canDecrement) {\n strain(-toward * STRAIN_PX);\n return;\n }\n const from = Number.isNaN(state.numberValue) ? (min ?? 0) : state.numberValue;\n const next = from + toward * (largeStep ?? step * 10);\n const places = Math.max(decimalsOf(step), decimalsOf(largeStep ?? step));\n state.setNumberValue(Number(Math.min(max ?? Infinity, Math.max(min ?? -Infinity, next)).toFixed(places)));\n }\n\n function onKeyDown(event: KeyboardEvent<HTMLInputElement>) {\n const up = event.key === \"ArrowUp\";\n const down = event.key === \"ArrowDown\";\n if (up || down || event.key === \"Home\" || event.key === \"End\") setTyping(false);\n if (!state) return;\n if ((up || event.key === \"End\") && !state.canIncrement) strain(-STRAIN_PX);\n if ((down || event.key === \"Home\") && !state.canDecrement) strain(STRAIN_PX);\n }\n\n return (\n <AriaGroup\n role=\"presentation\"\n data-slot=\"number-field-control\"\n className={controlVariants({ size })}\n >\n <AriaButton\n slot=\"decrement\"\n data-slot=\"number-field-decrement\"\n onPressStart={() => setTyping(false)}\n className={stepVariants({ size })}\n >\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.75\"\n strokeLinecap=\"round\"\n >\n <path d=\"M3.5 8h9\" />\n </svg>\n </AriaButton>\n <div className=\"relative grid min-w-0 flex-1 cursor-text place-items-center self-stretch\">\n {/* The digits the eye sees. The input above them draws only the caret and the selection. */}\n <span\n ref={displayRef}\n aria-hidden=\"true\"\n data-slot=\"number-field-display\"\n className=\"pointer-events-none inline-flex items-center whitespace-nowrap font-sans text-base font-medium tabular-nums text-foreground data-[strain]:motion-safe:animate-field-strain\"\n >\n {text ? (\n <RollingNumber word={text} direction={trail.direction} still={typing} />\n ) : (\n <span className=\"text-muted-foreground\">{placeholder}</span>\n )}\n </span>\n <AriaInput\n ref={inputRef}\n data-slot=\"number-field-input\"\n onChange={() => setTyping(true)}\n onBlur={() => setTyping(false)}\n onKeyDownCapture={onKeyDownCapture}\n onKeyDown={onKeyDown}\n className=\"absolute inset-0 z-10 m-0 h-full w-full min-w-0 border-0 bg-transparent p-0 text-center font-sans text-base font-medium tabular-nums text-transparent caret-foreground outline-none selection:bg-primary/20 selection:text-transparent data-[disabled]:cursor-not-allowed\"\n />\n </div>\n <AriaButton\n slot=\"increment\"\n data-slot=\"number-field-increment\"\n onPressStart={() => setTyping(false)}\n className={stepVariants({ size })}\n >\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.75\"\n strokeLinecap=\"round\"\n >\n <path d=\"M3.5 8h9M8 3.5v9\" />\n </svg>\n </AriaButton>\n </AriaGroup>\n );\n}\n\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(function NumberField(\n {\n label,\n labelHidden,\n description,\n error,\n placeholder,\n largeStep,\n size = \"md\",\n className,\n isInvalid,\n \"aria-describedby\": describedBy,\n ...props\n },\n ref,\n) {\n const id = useId();\n const hintId = description ? `${id}-description` : undefined;\n const errorId = error ? `${id}-error` : undefined;\n return (\n <AriaNumberField\n {...props}\n isInvalid={isInvalid || Boolean(error)}\n aria-describedby={[describedBy, hintId, errorId].filter(Boolean).join(\" \") || undefined}\n data-slot=\"number-field\"\n className={cn(\"grid w-full min-w-0 max-w-64 font-sans\", className)}\n >\n <Label className={cnAll(\"mb-1.5\", labelHidden && \"sr-only\")}>{label}</Label>\n <Control\n size={size}\n placeholder={placeholder}\n largeStep={largeStep}\n step={props.step ?? 1}\n min={props.minValue}\n max={props.maxValue}\n inputRef={ref}\n />\n <FieldMessage id={hintId} text={description} tone=\"description\" />\n <FieldMessage id={errorId} text={error} tone=\"error\" />\n </AriaNumberField>\n );\n});\n"],"mappings":";;;;;;;;;;AA0DA,MAAM,kBAAkB,IACtB;CACE,qBAAqB;CACrB;CAEA;CACA;AACF,GACA;CACE,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN,EACF;CACA,iBAAiB,EAAE,MAAM,KAAK;AAChC,CACF;AAEA,MAAM,eAAe,IACnB;CACE;CACA;CACA;CACA;CACA;CACA;CACA;CACA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oBAAC,cAAD;IAAc,IAAI;IAAQ,MAAM;IAAa,MAAK;GAAe,CAAA;GACjE,oBAAC,cAAD;IAAc,IAAI;IAAS,MAAM;IAAO,MAAK;GAAS,CAAA;EACvC;;AAErB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/onboarding-checklist/onboarding-checklist.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* OnboardingChecklist: a getting-started card for a new account or workspace,
|
|
4
|
+
* for a short, one-time setup of three to eight loosely ordered steps. (Use a
|
|
5
|
+
* Stepper when the order is strict and steps map to screens.)
|
|
6
|
+
*
|
|
7
|
+
* The progress ring and the count follow every check: the ring fills on the
|
|
8
|
+
* morph spring, the count rolls its digits, and at 100% a tick draws in the
|
|
9
|
+
* ring while the title morphs to `doneTitle`. A checked step fills its circle
|
|
10
|
+
* from the centre, draws its tick and strikes its title through; 720ms later it
|
|
11
|
+
* folds into a "N completed" row that opens again, and the next unfinished step
|
|
12
|
+
* opens and takes focus if the finished one had it. A step with an `actionLabel`
|
|
13
|
+
* runs `onAction`: resolving checks the step, throwing an Error keeps it open
|
|
14
|
+
* and shows the message. The body can be hidden and shown again.
|
|
15
|
+
*
|
|
16
|
+
* Rows and panels open and close their height on a spring that never
|
|
17
|
+
* overshoots, closing a little quicker. Nothing animates on first render, and
|
|
18
|
+
* reduced motion removes the height animation and keeps short fades.
|
|
19
|
+
*
|
|
20
|
+
* Built on plain buttons and the shared swap and rolling-number helpers; the
|
|
21
|
+
* action is the library's ActionButton, whose arrow becomes a spinner and then
|
|
22
|
+
* a tick that draws itself. Keyboard: Up and Down walk the step titles,
|
|
23
|
+
* Home and End jump to the first and last, Enter or Space expands a step,
|
|
24
|
+
* toggles its checkbox or runs its action.
|
|
25
|
+
*/
|
|
26
|
+
export interface OnboardingStep {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
/** Label of the button that does the step. Without it, the step is checked off by hand. */
|
|
31
|
+
actionLabel?: string;
|
|
32
|
+
/** Runs the step. Resolve to check it off; throw an Error to keep it open and show the error's message. */
|
|
33
|
+
onAction?: () => void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export interface OnboardingChecklistProps {
|
|
36
|
+
/** Card title while steps remain. */
|
|
37
|
+
title: string;
|
|
38
|
+
/** Title once every step is done. @default "You’re all set" */
|
|
39
|
+
doneTitle?: string;
|
|
40
|
+
/** Steps in order. */
|
|
41
|
+
steps: OnboardingStep[];
|
|
42
|
+
/** Step ids that start completed. */
|
|
43
|
+
defaultCompleted?: string[];
|
|
44
|
+
/** Called with the completed ids, in step order, whenever they change. */
|
|
45
|
+
onCompletedChange?: (completed: string[]) => void;
|
|
46
|
+
/** Starts with the body collapsed. @default false */
|
|
47
|
+
defaultHidden?: boolean;
|
|
48
|
+
/** Called when the Hide or Show button is used. */
|
|
49
|
+
onHiddenChange?: (hidden: boolean) => void;
|
|
50
|
+
/** Extra classes for the card. Merged last. */
|
|
51
|
+
className?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare const OnboardingChecklist: import("react").ForwardRefExoticComponent<OnboardingChecklistProps & import("react").RefAttributes<HTMLElement>>;
|
|
54
|
+
//#endregion
|
|
55
|
+
//# sourceMappingURL=onboarding-checklist.d.ts.map
|