@zayne-labs/toolkit-react 0.8.55 → 0.8.58
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,5 +1,5 @@
|
|
1
1
|
import { RefCallback } from 'react';
|
2
|
-
import { AnyFunction, AnyObject, Prettify } from '@zayne-labs/toolkit-type-helpers';
|
2
|
+
import { AnyFunction, UnionDiscriminator, AnyObject, Prettify } from '@zayne-labs/toolkit-type-helpers';
|
3
3
|
|
4
4
|
type PossibleRef<TRef> = React.Ref<TRef> | undefined;
|
5
5
|
/**
|
@@ -38,19 +38,21 @@ type ForwardedRefType<TComponent extends HTMLElement | React.ElementType> = TCom
|
|
38
38
|
type InferProps<TComponent extends HTMLElement | React.ElementType> = TComponent extends React.ElementType ? React.ComponentPropsWithRef<TComponent> : React.HTMLAttributes<TComponent>;
|
39
39
|
type StateSetter<TSetter = unknown> = React.Dispatch<React.SetStateAction<TSetter>>;
|
40
40
|
type MyCustomCss<TExtra extends Record<string, string> = NonNullable<unknown>> = React.CSSProperties & Record<`--${string}`, string> & TExtra;
|
41
|
+
type DefaultPossibleMessages = {
|
42
|
+
children: "Hey, Sorry but since you're currently using the render prop, the children prop is therefore redundant";
|
43
|
+
render: "Hey, Sorry but since you're currently using the children prop, the render prop is therefore redundant";
|
44
|
+
};
|
41
45
|
/**
|
42
46
|
* @description Represents a set of props that can be used to render a component conditionally based on a discriminated union type.
|
43
47
|
* This type allows for the use of either a render prop or children prop, but not both at the same time.
|
44
48
|
* If both are provided, a TypeScript error will be thrown.
|
45
|
-
* @template
|
49
|
+
* @template TErrorMessages An object of custom messages to display on the disallowed property.
|
46
50
|
*/
|
47
|
-
type DiscriminatedRenderProps<TRenderPropType,
|
51
|
+
type DiscriminatedRenderProps<TRenderPropType, TErrorMessages extends Record<"children" | "render", string> = DefaultPossibleMessages> = UnionDiscriminator<[{
|
48
52
|
children: TRenderPropType;
|
49
|
-
|
50
|
-
} | {
|
51
|
-
children?: TMessage;
|
53
|
+
}, {
|
52
54
|
render: TRenderPropType;
|
53
|
-
}
|
55
|
+
}], TErrorMessages>;
|
54
56
|
|
55
57
|
type AsProp<TElement extends React.ElementType> = {
|
56
58
|
as?: TElement;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zayne-labs/toolkit-react",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.8.
|
4
|
+
"version": "0.8.58",
|
5
5
|
"description": "A collection of utility functions, types and composables used by my other projects. Nothing too fancy but can be useful.",
|
6
6
|
"author": "Ryan Zayne",
|
7
7
|
"license": "MIT",
|
@@ -50,8 +50,8 @@
|
|
50
50
|
}
|
51
51
|
},
|
52
52
|
"dependencies": {
|
53
|
-
"@zayne-labs/toolkit-core": "0.8.
|
54
|
-
"@zayne-labs/toolkit-type-helpers": "0.8.
|
53
|
+
"@zayne-labs/toolkit-core": "0.8.58",
|
54
|
+
"@zayne-labs/toolkit-type-helpers": "0.8.58"
|
55
55
|
},
|
56
56
|
"devDependencies": {
|
57
57
|
"@arethetypeswrong/cli": "^0.17.4",
|
@@ -99,6 +99,9 @@
|
|
99
99
|
"build:test": "concurrently --prefix-colors \"yellow.bold,#7da4f8.bold,magenta\" --names PUBLINT,TSUP 'pnpm:lint:publint' 'pnpm:build:dev'",
|
100
100
|
"dev": "pnpm build:dev --watch",
|
101
101
|
"lint:attw": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
|
102
|
+
"lint:eslint": "eslint . --max-warnings 0",
|
103
|
+
"lint:eslint:interactive": "pnpx eslint-interactive@latest . --max-warnings 0 --fix",
|
104
|
+
"lint:format": "prettier --write .",
|
102
105
|
"lint:publint": "publint --strict .",
|
103
106
|
"lint:size": "size-limit",
|
104
107
|
"lint:type-check": "tsc --pretty -p tsconfig.json",
|