@passui/react 0.1.29 → 0.1.31

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.
@@ -1,2 +1,3 @@
1
+ export type PickerSize = "sm" | "md" | "lg";
1
2
  /** Shared field treatment for the popup-based Picker, date and time controls. */
2
- export declare function pickerTriggerStyle(className?: string): string;
3
+ export declare function pickerTriggerStyle(className?: string, size?: PickerSize): string;
@@ -1,3 +1,4 @@
1
+ import { type PickerSize } from "./picker-trigger";
1
2
  export interface PickerOption<T extends string> {
2
3
  value: T;
3
4
  label: string;
@@ -33,6 +34,8 @@ export interface PickerProps<T extends string> {
33
34
  className?: string;
34
35
  /** Prevents opening or choosing an option. @default false */
35
36
  disabled?: boolean;
37
+ /** Trigger height and text scale. @default "md" */
38
+ size?: PickerSize;
36
39
  }
37
40
  /**
38
41
  * A pop-up button: shows the chosen value and opens a list that floats
@@ -40,4 +43,4 @@ export interface PickerProps<T extends string> {
40
43
  * lists. Replaces the browser's own select, which looks foreign on every
41
44
  * platform.
42
45
  */
43
- export declare function Picker<T extends string>({ value, options, onChange, label, placeholder, searchable, searchPlaceholder, emptyLabel, className, onCreate, createLabel, disabled, }: PickerProps<T>): import("react").JSX.Element;
46
+ export declare function Picker<T extends string>({ value, options, onChange, label, placeholder, searchable, searchPlaceholder, emptyLabel, className, onCreate, createLabel, disabled, size, }: PickerProps<T>): import("react").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@passui/react",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "Passui: native React controls, design tokens, presentation and appearance.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -5,7 +5,7 @@ import { CheckIcon } from "../../icons/icons"
5
5
  import { cn } from "../../lib/class-names"
6
6
  import { belongsToFloatingSurface, registerFloatingLayer } from "../../lib/floating-layers"
7
7
  import { screenEdges } from "../../lib/screen-edges"
8
- import { spring } from "../../motion/transitions"
8
+ import { spring, fluidOvershoot } from "../../motion/transitions"
9
9
  import { concealMenuSource } from "./conceal-menu-source"
10
10
  import { findMenuTypeaheadIndex, isMenuNavigationKey, nextMenuIndex } from "./menu-navigation"
11
11
  import { menuPosition } from "./menu-position"
@@ -288,7 +288,7 @@ function Menu({ menu }: { menu: OpenMenu }) {
288
288
  transition={
289
289
  reducedMotion
290
290
  ? { duration: 0 }
291
- : { ...spring.smooth, opacity: { duration: 0.16 } }
291
+ : { ...fluidOvershoot, opacity: { duration: 0.16 } }
292
292
  }
293
293
  />
294
294
  )}
@@ -305,18 +305,23 @@ function Menu({ menu }: { menu: OpenMenu }) {
305
305
  ? false
306
306
  : {
307
307
  opacity: 0,
308
+ scale: 0.96,
308
309
  y: menu.source && menu.source.top > position.top ? 4 : -4,
309
310
  }
310
311
  }
311
- animate={{ opacity: 1, y: 0 }}
312
+ animate={{ opacity: 1, scale: 1, y: 0 }}
312
313
  exit={{
313
314
  opacity: 0,
315
+ scale: 0.98,
314
316
  transition: {
315
317
  duration: reducedMotion ? 0 : 0.06,
316
318
  },
317
319
  }}
318
320
  transition={{
319
- duration: reducedMotion ? 0 : 0.16,
321
+ duration: reducedMotion ? 0 : 0.2,
322
+ ease: reducedMotion
323
+ ? undefined
324
+ : ([0.4, 0, 0.2, 1] as [number, number, number, number]),
320
325
  delay: reducedMotion || !menu.source ? 0 : 0.06,
321
326
  }}
322
327
  >
@@ -1,10 +1,19 @@
1
1
  import { cn } from "../../lib/class-names"
2
2
 
3
+ export type PickerSize = "sm" | "md" | "lg"
4
+
5
+ const triggerSizes: Record<PickerSize, string> = {
6
+ sm: "px-2.5 py-1.5 text-caption rounded-lg",
7
+ md: "px-3 py-2 text-subheadline rounded-lg",
8
+ lg: "px-4 py-3 text-body rounded-xl",
9
+ }
10
+
3
11
  /** Shared field treatment for the popup-based Picker, date and time controls. */
4
- export function pickerTriggerStyle(className?: string) {
12
+ export function pickerTriggerStyle(className?: string, size: PickerSize = "md") {
5
13
  return cn(
6
- "flex w-full min-w-0 items-center gap-2 rounded-lg control-field px-3 py-2 text-start text-subheadline text-label",
14
+ "flex w-full min-w-0 items-center gap-2 control-field text-start text-label",
7
15
  "disabled:cursor-not-allowed disabled:opacity-40",
16
+ triggerSizes[size],
8
17
  className
9
18
  )
10
19
  }
@@ -5,7 +5,7 @@ import { CheckIcon, SearchIcon, SelectorIcon } from "../../icons/icons"
5
5
  import { cn } from "../../lib/class-names"
6
6
  import { haptic } from "../../lib/haptics"
7
7
  import { AnchoredSurface } from "../popover/anchored-surface"
8
- import { pickerTriggerStyle } from "./picker-trigger"
8
+ import { pickerTriggerStyle, type PickerSize } from "./picker-trigger"
9
9
 
10
10
  export interface PickerOption<T extends string> {
11
11
  value: T
@@ -43,6 +43,8 @@ export interface PickerProps<T extends string> {
43
43
  className?: string
44
44
  /** Prevents opening or choosing an option. @default false */
45
45
  disabled?: boolean
46
+ /** Trigger height and text scale. @default "md" */
47
+ size?: PickerSize
46
48
  }
47
49
 
48
50
  /** Long lists get a filter field, as in the system pickers. */
@@ -67,6 +69,7 @@ export function Picker<T extends string>({
67
69
  onCreate,
68
70
  createLabel,
69
71
  disabled = false,
72
+ size = "md",
70
73
  }: PickerProps<T>) {
71
74
  const panel = useAnchoredDisclosure(disabled)
72
75
  const { open } = panel
@@ -102,7 +105,7 @@ export function Picker<T extends string>({
102
105
  disabled={disabled}
103
106
  onClick={() => panel.toggle()}
104
107
  onKeyDown={onTriggerKey}
105
- className={pickerTriggerStyle(className)}
108
+ className={pickerTriggerStyle(className, size)}
106
109
  >
107
110
  <span
108
111
  lang={selected?.lang}