@zag-js/types 0.9.2 → 0.10.1

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.
@@ -0,0 +1,64 @@
1
+ import type { JSX } from "./jsx"
2
+
3
+ type Dict<T = any> = Record<string, T>
4
+
5
+ type Booleanish = boolean | "true" | "false"
6
+
7
+ type DataAttr = {
8
+ "data-selected"?: Booleanish
9
+ "data-expanded"?: Booleanish
10
+ "data-highlighted"?: Booleanish
11
+ "data-readonly"?: Booleanish
12
+ "data-indeterminate"?: Booleanish
13
+ "data-invalid"?: Booleanish
14
+ "data-hover"?: Booleanish
15
+ "data-active"?: Booleanish
16
+ "data-focus"?: Booleanish
17
+ "data-disabled"?: Booleanish
18
+ "data-open"?: Booleanish
19
+ "data-checked"?: Booleanish
20
+ "data-pressed"?: Booleanish
21
+ "data-complete"?: Booleanish
22
+ "data-empty"?: Booleanish
23
+ "data-placeholder-shown"?: Booleanish
24
+ "data-half"?: Booleanish
25
+ "data-scope"?: string
26
+
27
+ "data-uid"?: string
28
+ "data-name"?: string
29
+ "data-ownedby"?: string
30
+ "data-type"?: string
31
+ "data-valuetext"?: string
32
+ "data-placement"?: string
33
+ "data-controls"?: string
34
+ "data-part"?: string
35
+ "data-label"?: string
36
+ "data-state"?: string | null
37
+ "data-value"?: string | number
38
+
39
+ "data-orientation"?: "horizontal" | "vertical"
40
+
41
+ "data-count"?: number
42
+ "data-index"?: number
43
+ } & {
44
+ [key in `data-${string}`]?: string | number | Booleanish
45
+ }
46
+
47
+ export type PropTypes<T = Dict> = Record<
48
+ "button" | "label" | "input" | "img" | "output" | "element" | "select" | "style",
49
+ T
50
+ >
51
+
52
+ export type NormalizeProps<T extends PropTypes> = {
53
+ [K in keyof T]: (props: K extends keyof JSX.IntrinsicElements ? DataAttr & JSX.IntrinsicElements[K] : never) => T[K]
54
+ } & {
55
+ element(props: DataAttr & JSX.HTMLAttributes<HTMLElement>): T["element"]
56
+ style: JSX.CSSProperties
57
+ }
58
+ export function createNormalizer<T extends PropTypes>(fn: (props: Dict) => Dict): NormalizeProps<T> {
59
+ return new Proxy({} as any, {
60
+ get() {
61
+ return fn
62
+ },
63
+ })
64
+ }