@passui/react 0.1.30 → 0.1.32

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;
@@ -1,6 +1,9 @@
1
1
  import type { ComponentProps } from "react";
2
+ export type SkeletonSize = "sm" | "md" | "lg";
2
3
  export interface SkeletonProps extends ComponentProps<"div"> {
3
4
  label?: string;
5
+ /** Minimum height and rounding. @default "md" */
6
+ size?: SkeletonSize;
4
7
  }
5
8
  /** A loading placeholder that becomes still when Reduce Motion is enabled. */
6
- export declare function Skeleton({ label, className, ...props }: SkeletonProps): import("react").JSX.Element;
9
+ export declare function Skeleton({ label, size, className, ...props }: SkeletonProps): import("react").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
  export type StatTileTone = "critical";
3
+ export type StatTileSize = "sm" | "md" | "lg";
3
4
  export interface StatTileProps {
4
5
  label: string;
5
6
  value: number;
@@ -12,6 +13,8 @@ export interface StatTileProps {
12
13
  active?: boolean;
13
14
  /** Custom classes for the tile container. */
14
15
  className?: string;
16
+ /** Tile padding and number scale. @default "md" */
17
+ size?: StatTileSize;
15
18
  }
16
19
  /** One number with its label, optionally a toggle. */
17
- export declare function StatTile({ label, value, caption, tone, onClick, active, className, }: StatTileProps): import("react").JSX.Element;
20
+ export declare function StatTile({ label, value, caption, tone, onClick, active, className, size, }: StatTileProps): import("react").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@passui/react",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "Passui: native React controls, design tokens, presentation and appearance.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -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}
@@ -1,17 +1,27 @@
1
1
  import type { ComponentProps } from "react"
2
2
  import { cn } from "../../lib/class-names"
3
3
 
4
+ export type SkeletonSize = "sm" | "md" | "lg"
5
+
6
+ const minHeights: Record<SkeletonSize, string> = {
7
+ sm: "min-h-3 rounded-md",
8
+ md: "min-h-4 rounded-md",
9
+ lg: "min-h-6 rounded-lg",
10
+ }
11
+
4
12
  export interface SkeletonProps extends ComponentProps<"div"> {
5
13
  label?: string
14
+ /** Minimum height and rounding. @default "md" */
15
+ size?: SkeletonSize
6
16
  }
7
17
  /** A loading placeholder that becomes still when Reduce Motion is enabled. */
8
- export function Skeleton({ label, className, ...props }: SkeletonProps) {
18
+ export function Skeleton({ label, size = "md", className, ...props }: SkeletonProps) {
9
19
  return (
10
20
  <div
11
21
  {...props}
12
22
  role={label ? "status" : undefined}
13
23
  aria-hidden={label ? undefined : true}
14
- className={cn("min-h-4 rounded-md bg-fill motion-safe:animate-pulse", className)}
24
+ className={cn("bg-fill motion-safe:animate-pulse", minHeights[size], className)}
15
25
  >
16
26
  {label && <span className="sr-only">{label}</span>}
17
27
  </div>
@@ -2,6 +2,13 @@ import type { ReactNode } from "react"
2
2
  import { cn } from "../../lib/class-names"
3
3
 
4
4
  export type StatTileTone = "critical"
5
+ export type StatTileSize = "sm" | "md" | "lg"
6
+
7
+ const tileSizes: Record<StatTileSize, { padding: string; valueText: string; labelText: string }> = {
8
+ sm: { padding: "p-3", valueText: "text-title3", labelText: "text-caption" },
9
+ md: { padding: "p-4", valueText: "text-title1", labelText: "text-footnote" },
10
+ lg: { padding: "p-5", valueText: "text-title", labelText: "text-subheadline" },
11
+ }
5
12
 
6
13
  export interface StatTileProps {
7
14
  label: string
@@ -15,6 +22,8 @@ export interface StatTileProps {
15
22
  active?: boolean
16
23
  /** Custom classes for the tile container. */
17
24
  className?: string
25
+ /** Tile padding and number scale. @default "md" */
26
+ size?: StatTileSize
18
27
  }
19
28
 
20
29
  /** One number with its label, optionally a toggle. */
@@ -26,18 +35,29 @@ export function StatTile({
26
35
  onClick,
27
36
  active = false,
28
37
  className,
38
+ size = "md",
29
39
  }: StatTileProps) {
40
+ const dims = tileSizes[size]
30
41
  const body = (
31
42
  <>
32
- <span className="text-label-secondary">{label}</span>
33
- <span className={cn("tabular-nums", tone === "critical" && value > 0 && "text-danger")}>
43
+ <span className={cn(dims.labelText, "text-label-secondary")}>{label}</span>
44
+ <span
45
+ className={cn(
46
+ "tabular-nums font-semibold",
47
+ dims.valueText,
48
+ tone === "critical" && value > 0 && "text-danger"
49
+ )}
50
+ >
34
51
  {value.toLocaleString("en-US")}
35
52
  </span>
36
- {caption && <span className="text-label-secondary">{caption}</span>}
53
+ {caption && (
54
+ <span className={cn(dims.labelText, "text-label-tertiary")}>{caption}</span>
55
+ )}
37
56
  </>
38
57
  )
39
58
  const tileClass = cn(
40
- "flex min-w-0 flex-col gap-2 rounded-2xl border border-separator/35 bg-elevated p-4 text-left shadow-xs",
59
+ "flex min-w-0 flex-col gap-2 rounded-2xl border border-separator/35 bg-elevated text-left shadow-xs",
60
+ dims.padding,
41
61
  className
42
62
  )
43
63