@modular-component/with-default-props 0.2.1 → 0.2.3
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 +15 -0
- package/README.md +8 -9
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @modular-component/with-default-props
|
|
2
2
|
|
|
3
|
+
## 0.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [208e156]
|
|
8
|
+
- @modular-component/core@0.2.3
|
|
9
|
+
|
|
10
|
+
## 0.2.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 77c46f4: Fix an issue in core rendering system
|
|
15
|
+
- Updated dependencies [77c46f4]
|
|
16
|
+
- @modular-component/core@0.2.2
|
|
17
|
+
|
|
3
18
|
## 0.2.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -19,10 +19,10 @@ const MyComponent = ModularComponent<{ someFlag?: boolean }>()
|
|
|
19
19
|
// props is inferred as { someFlag: boolean; someNewProp: string } at this point
|
|
20
20
|
)))
|
|
21
21
|
|
|
22
|
-
const MyDynamicProps = ModularComponent<{
|
|
23
|
-
role: 'user' | 'owner' | 'admin',
|
|
24
|
-
canEdit?: boolean,
|
|
25
|
-
canDelete?: boolean
|
|
22
|
+
const MyDynamicProps = ModularComponent<{
|
|
23
|
+
role: 'user' | 'owner' | 'admin',
|
|
24
|
+
canEdit?: boolean,
|
|
25
|
+
canDelete?: boolean
|
|
26
26
|
}>()
|
|
27
27
|
.with(defaultProps(({ props }) => ({
|
|
28
28
|
canEdit: ['owner', 'admin'].includes(props.role),
|
|
@@ -59,15 +59,14 @@ export function defaultProps<
|
|
|
59
59
|
DefaultProps extends Partial<Props>,
|
|
60
60
|
>(
|
|
61
61
|
defaultProps: DefaultProps | ((args: Args) => DefaultProps),
|
|
62
|
-
): ModularStage<
|
|
63
|
-
'props',
|
|
64
|
-
(args: Args) => Merge<Props, DefaultProps>
|
|
65
|
-
> {
|
|
62
|
+
): ModularStage<'props', (args: Args) => Merge<Props, DefaultProps>> {
|
|
66
63
|
return {
|
|
67
64
|
field: 'props',
|
|
68
65
|
useStage: (args: Args) =>
|
|
69
66
|
({
|
|
70
|
-
...(typeof defaultProps === 'function'
|
|
67
|
+
...(typeof defaultProps === 'function'
|
|
68
|
+
? defaultProps(args)
|
|
69
|
+
: defaultProps),
|
|
71
70
|
...args.props,
|
|
72
71
|
} as Merge<Props, DefaultProps>),
|
|
73
72
|
}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"Default",
|
|
9
9
|
"Conditional"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.2.
|
|
11
|
+
"version": "0.2.3",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"publishConfig": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"license": "cp ../../LICENSE ./LICENSE"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@modular-component/core": "0.2.
|
|
29
|
+
"@modular-component/core": "0.2.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"typescript": "^5.2.2"
|