@entur/utils 0.4.8 → 0.4.9
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.
- package/CHANGELOG.md +8 -0
- package/dist/PolymorphicComponent.d.ts +41 -2
- package/package.json +2 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.4.9](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.8...@entur/utils@0.4.9) (2023-01-19)
|
|
7
|
+
|
|
8
|
+
### Performance Improvements
|
|
9
|
+
|
|
10
|
+
- **button:** remove usage of react-polymorphic-types in favor of own implementation in button packa ([d15d852](https://bitbucket.org/enturas/design-system/commits/d15d85245d7f7273f0700fafcef3201d4fa2e0ff))
|
|
11
|
+
- **layout:** remove usage of react-polymorphic-types in favor of own implementation in layout packa ([b7ada6d](https://bitbucket.org/enturas/design-system/commits/b7ada6d7b9776cce86dea51f58c4b7ea0300451b))
|
|
12
|
+
- **packages:** remove all referenves to react-polymorphic-types npm-package ([e47a304](https://bitbucket.org/enturas/design-system/commits/e47a304d87eb77adae5dd002e89f03026c7eadce))
|
|
13
|
+
|
|
6
14
|
## [0.4.8](https://bitbucket.org/enturas/design-system/compare/@entur/utils@0.4.5...@entur/utils@0.4.8) (2022-12-09)
|
|
7
15
|
|
|
8
16
|
### Bug Fixes
|
|
@@ -1,2 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/** These polymorphic types are derrived from Ben Ilegbodu's article available at the following link:
|
|
2
|
+
* https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export declare type PropsOf<C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>;
|
|
6
|
+
declare type AsProp<C extends React.ElementType> = {
|
|
7
|
+
/**
|
|
8
|
+
* An override of the default HTML tag.
|
|
9
|
+
* Can also be another React component.
|
|
10
|
+
*/
|
|
11
|
+
as?: C;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Allows for extending a set of props (`ExtendedProps`) by an overriding set of props
|
|
15
|
+
* (`OverrideProps`), ensuring that any duplicates are overridden by the overriding
|
|
16
|
+
* set of props.
|
|
17
|
+
*/
|
|
18
|
+
export declare type ExtendableProps<ExtendedProps = Record<string, unknown>, OverrideProps = Record<string, unknown>> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>;
|
|
19
|
+
/**
|
|
20
|
+
* Allows for inheriting the props from the specified element type so that
|
|
21
|
+
* props like children, className & style work, as well as element-specific
|
|
22
|
+
* attributes like aria roles. The component (`C`) must be passed in.
|
|
23
|
+
*/
|
|
24
|
+
export declare type InheritableElementProps<C extends React.ElementType, Props = Record<string, unknown>> = ExtendableProps<PropsOf<C>, Props>;
|
|
25
|
+
/**
|
|
26
|
+
* A more sophisticated version of `InheritableElementProps` where
|
|
27
|
+
* the passed in `as` prop will determine which props can be included
|
|
28
|
+
*/
|
|
29
|
+
export declare type PolymorphicComponentProps<C extends React.ElementType, Props = Record<string, unknown>> = InheritableElementProps<C, Props & AsProp<C>>;
|
|
30
|
+
/**
|
|
31
|
+
* Utility type to extract the `ref` prop from a polymorphic component
|
|
32
|
+
*/
|
|
33
|
+
export declare type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref'];
|
|
34
|
+
/**
|
|
35
|
+
* A wrapper of `PolymorphicComponentProps` that also includes the `ref`
|
|
36
|
+
* prop for the polymorphic component
|
|
37
|
+
*/
|
|
38
|
+
export declare type PolymorphicComponentPropsWithRef<C extends React.ElementType, Props = Record<string, unknown>> = PolymorphicComponentProps<C, Props> & {
|
|
39
|
+
ref?: PolymorphicRef<C>;
|
|
40
|
+
};
|
|
41
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur/utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/utils.esm.js",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"start": "dts watch --noClean",
|
|
21
21
|
"build": "dts build && cp src/*.scss dist",
|
|
22
|
-
"test": "dts test --env=jsdom",
|
|
23
22
|
"lint": "dts lint"
|
|
24
23
|
},
|
|
25
24
|
"peerDependencies": {
|
|
@@ -27,8 +26,7 @@
|
|
|
27
26
|
"react-dom": ">=16.8.0"
|
|
28
27
|
},
|
|
29
28
|
"dependencies": {
|
|
30
|
-
"react-polymorphic-types": "^1.1.0",
|
|
31
29
|
"tiny-warning": "^1.0.3"
|
|
32
30
|
},
|
|
33
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "de71e205560a699e2dce301e133966dc9348c459"
|
|
34
32
|
}
|