@thom1729/react-utils 0.0.3 → 0.0.5
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,6 +1,8 @@
|
|
|
1
1
|
export * from './helpers.js';
|
|
2
2
|
export * from './input.js';
|
|
3
3
|
export * from './select.js';
|
|
4
|
-
import {
|
|
4
|
+
import type { FC, ReactNode } from 'react';
|
|
5
5
|
import type { ExtendBuiltin } from './helpers.js';
|
|
6
|
-
export declare const Button: FC<ExtendBuiltin<'button'
|
|
6
|
+
export declare const Button: FC<ExtendBuiltin<'button', {
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
}>>;
|
package/dist/esm/index.js
CHANGED
|
@@ -65,7 +65,12 @@ function SelectOptions({ options, }) {
|
|
|
65
65
|
}) });
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const Button = ({ type = 'button', ...rest }) =>
|
|
68
|
+
const Button = ({ type = 'button', label, children, ...rest }) => {
|
|
69
|
+
if (label !== undefined && label !== null && children !== null) {
|
|
70
|
+
throw new TypeError(`can't provide both label prop and children`);
|
|
71
|
+
}
|
|
72
|
+
return jsx("button", { type: type, children: label ?? children, ...rest });
|
|
73
|
+
};
|
|
69
74
|
|
|
70
75
|
function useEventListener(target, type, listener, dependencies) {
|
|
71
76
|
const callback = useMemo(() => listener, dependencies);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thom1729/react-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"typescript": "^5.6.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"react": "^18.3.1",
|
|
35
34
|
"tslib": "^2.7.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": "^18.3.1"
|
|
36
38
|
}
|
|
37
39
|
}
|
package/src/components/index.tsx
CHANGED
|
@@ -2,10 +2,21 @@ export * from './helpers.js';
|
|
|
2
2
|
export * from './input.js';
|
|
3
3
|
export * from './select.js';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import type { FC, ReactNode } from 'react';
|
|
6
6
|
import type { ExtendBuiltin } from './helpers.js';
|
|
7
7
|
|
|
8
|
-
export const Button: FC<ExtendBuiltin<'button'>> = ({
|
|
8
|
+
export const Button: FC<ExtendBuiltin<'button', { label?: ReactNode }>> = ({
|
|
9
9
|
type = 'button',
|
|
10
|
+
label,
|
|
11
|
+
children,
|
|
10
12
|
...rest
|
|
11
|
-
}) =>
|
|
13
|
+
}) => {
|
|
14
|
+
if (label !== undefined && label !== null && children !== null ) {
|
|
15
|
+
throw new TypeError(`can't provide both label prop and children`);
|
|
16
|
+
}
|
|
17
|
+
return <button
|
|
18
|
+
type={type}
|
|
19
|
+
children={label ?? children}
|
|
20
|
+
{...rest}
|
|
21
|
+
/>;
|
|
22
|
+
}
|