@sigil-dev/types 0.9.18 → 0.9.20

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.
Files changed (2) hide show
  1. package/index.d.ts +25 -4
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -76,15 +76,36 @@ interface SigilBindProps {
76
76
  bindChecked?: boolean;
77
77
  }
78
78
 
79
+ /**
80
+ * Sigil hands a handler the browser's own event, not a React synthetic one:
81
+ * `onClick={(e: MouseEvent) => …}`, with `currentTarget` typed as the element.
82
+ */
83
+ type NativeHandler<H> = H extends ((event: infer E) => unknown) | undefined
84
+ ? E extends React.SyntheticEvent<infer Target, infer Native>
85
+ ? ((event: Native & { currentTarget: Target }) => unknown) | undefined
86
+ : H
87
+ : H;
88
+
89
+ type NativeHandlers<T> = {
90
+ [K in keyof T]: K extends `on${string}` ? NativeHandler<T[K]> : T[K];
91
+ };
92
+
93
+ /**
94
+ * HTML's own spelling of every camelCase prop: `onclick`, `spellcheck`,
95
+ * `autocomplete`, `tabindex`, `readonly`. Sigil passes attributes through as
96
+ * written, and the browser reads them case-insensitively.
97
+ */
79
98
  type LowercaseHandlers<T> = {
80
- [K in keyof T as K extends `on${string}`
81
- ? Lowercase<K & string>
82
- : never]?: T[K];
99
+ [K in keyof T as K extends string
100
+ ? Lowercase<K> extends K
101
+ ? never
102
+ : Lowercase<K>
103
+ : never]?: K extends `on${string}` ? NativeHandler<T[K]> : T[K];
83
104
  };
84
105
 
85
106
  type SigilIntrinsicElements = {
86
107
  [K in keyof React.JSX.IntrinsicElements]: Omit<
87
- React.JSX.IntrinsicElements[K],
108
+ NativeHandlers<React.JSX.IntrinsicElements[K]>,
88
109
  "style" | "children"
89
110
  > &
90
111
  SigilBaseProps &
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "url": "git+https://git.cane1712.dev/sigil/sigil.git",
9
9
  "directory": "packages/types"
10
10
  },
11
- "version": "0.9.18",
11
+ "version": "0.9.20",
12
12
  "type": "module",
13
13
  "exports": {
14
14
  ".": "./index.d.ts"