@passui/react 0.1.14 → 0.1.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@passui/react",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Passui: native React controls, design tokens, presentation and appearance.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -90,7 +90,7 @@ function ConfirmCard({ dialog }: { dialog: PendingDialog }) {
90
90
  initial={{ opacity: 0 }}
91
91
  animate={{ opacity: 1 }}
92
92
  exit={{ opacity: 0 }}
93
- transition={{ duration: 0.2 }}
93
+ transition={spring.smooth}
94
94
  onClick={() => settleDialog(false)}
95
95
  />
96
96
  <motion.div
@@ -107,7 +107,7 @@ function ConfirmCard({ dialog }: { dialog: PendingDialog }) {
107
107
  opacity: 0,
108
108
  scale: 0.94,
109
109
  y: 6,
110
- transition: { duration: 0.15 },
110
+ transition: spring.snappy,
111
111
  }}
112
112
  transition={spring.bouncy}
113
113
  >
@@ -7,6 +7,7 @@ import {
7
7
  import { createPortal } from "react-dom"
8
8
  import { Button } from "@passui/react/button"
9
9
  import { cn } from "@passui/react/cn"
10
+ import { spring } from "../../motion/transitions"
10
11
  import {
11
12
  createContext,
12
13
  useContext,
@@ -129,12 +130,11 @@ export function Dialog({
129
130
  : 0,
130
131
  opacity: 0,
131
132
  }}
132
- transition={{
133
- duration: reducedMotion
134
- ? 0
135
- : 0.28,
136
- ease: [0.22, 1, 0.36, 1],
137
- }}
133
+ transition={
134
+ reducedMotion
135
+ ? { duration: 0 }
136
+ : spring.smooth
137
+ }
138
138
  className="overflow-hidden"
139
139
  >
140
140
  {body}
@@ -10,12 +10,18 @@ import { cn } from "../../lib/class-names"
10
10
  export function TabView<Value extends string>({
11
11
  options,
12
12
  defaultValue,
13
+ value: controlledValue,
14
+ onValueChange,
15
+ align = "center",
13
16
  label,
14
17
  children,
15
18
  className,
16
19
  }: {
17
20
  options: readonly { value: Value; label: string }[]
18
21
  defaultValue: Value
22
+ value?: Value
23
+ onValueChange?: (value: Value) => void
24
+ align?: "start" | "center"
19
25
  label: string
20
26
  children: (value: Value) => ReactNode
21
27
  className?: string
@@ -23,10 +29,15 @@ export function TabView<Value extends string>({
23
29
  const id = useId()
24
30
  const buttons = useRef<(HTMLButtonElement | null)[]>([])
25
31
  const [selected, setSelected] = useState(defaultValue)
32
+ const current = controlledValue ?? selected
33
+ function select(next: Value) {
34
+ if (controlledValue === undefined) setSelected(next)
35
+ onValueChange?.(next)
36
+ }
26
37
  const value = options.some(
27
- (option) => option.value === selected
38
+ (option) => option.value === current
28
39
  )
29
- ? selected
40
+ ? current
30
41
  : options[0]?.value
31
42
  if (value === undefined) return null
32
43
 
@@ -40,7 +51,12 @@ export function TabView<Value extends string>({
40
51
  <div
41
52
  role="tablist"
42
53
  aria-label={label}
43
- className="mx-auto inline-flex h-8 max-w-full items-center justify-center gap-5 p-[3px]"
54
+ className={cn(
55
+ "inline-flex h-8 w-fit max-w-full items-center gap-5 p-[3px]",
56
+ align === "start"
57
+ ? "self-start"
58
+ : "mx-auto justify-center"
59
+ )}
44
60
  >
45
61
  {options.map((option, index) => (
46
62
  <button
@@ -56,9 +72,7 @@ export function TabView<Value extends string>({
56
72
  ref={(element) => {
57
73
  buttons.current[index] = element
58
74
  }}
59
- onClick={() =>
60
- setSelected(option.value)
61
- }
75
+ onClick={() => select(option.value)}
62
76
  onKeyDown={(event) => {
63
77
  const rtl =
64
78
  getComputedStyle(
@@ -82,8 +96,7 @@ export function TabView<Value extends string>({
82
96
  (next + options.length) %
83
97
  options.length
84
98
  const option = options[next]
85
- if (option)
86
- setSelected(option.value)
99
+ if (option) select(option.value)
87
100
  buttons.current[next]?.focus()
88
101
  }}
89
102
  className={cn(
@@ -180,7 +180,7 @@ function ToastItem({
180
180
  opacity: 0,
181
181
  y: -18,
182
182
  scale: 0.6,
183
- transition: { duration: 0.22 },
183
+ transition: spring.snappy,
184
184
  }}
185
185
  transition={spring.bouncy}
186
186
  drag="y"
@@ -16,7 +16,7 @@ export const popoverMotion = {
16
16
  opacity: 0,
17
17
  scale: 0.97,
18
18
  y: -4,
19
- transition: { duration: 0.12 },
19
+ transition: spring.snappy,
20
20
  },
21
21
  transition: spring.snappy,
22
22
  } as const