@passui/react 0.1.30 → 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,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
|
|
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}
|