@modular-component/default 0.1.7 → 0.2.1
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 +23 -0
- package/README.md +26 -39
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/index.ts +3 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @modular-component/default
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 09b9673: Update readmes
|
|
8
|
+
- Updated dependencies [09b9673]
|
|
9
|
+
- @modular-component/core@0.2.1
|
|
10
|
+
- @modular-component/with-default-props@0.2.1
|
|
11
|
+
- @modular-component/with-lifecycle@0.2.1
|
|
12
|
+
|
|
13
|
+
## 0.2.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 83d453f: Rework API for better TypeScript performance and improved DX
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [83d453f]
|
|
22
|
+
- @modular-component/core@0.2.0
|
|
23
|
+
- @modular-component/with-default-props@0.2.0
|
|
24
|
+
- @modular-component/with-lifecycle@0.2.0
|
|
25
|
+
|
|
3
26
|
## 0.1.7
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,48 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @modular-component/default
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Set of sensible defaults for using `ModularComponent`.
|
|
4
4
|
|
|
5
|
-
Provides two stages:
|
|
6
|
-
|
|
7
|
-
providing default values for props.
|
|
5
|
+
Provides two stages: `with(lifecycle)` for adding a lifecycle hook, and `with(defaultProps)` for
|
|
6
|
+
providing default values for props. It also re-exports `with(render)` from `@modular-component/props` for convenience.
|
|
8
7
|
|
|
9
|
-
It's also possible to import each of them individually through `@modular-component/with-lifecycle`
|
|
10
|
-
and `@modular-component/with-default-props` respectively.
|
|
8
|
+
It's also possible to import each of them individually through [`@modular-component/with-lifecycle`](./with-lifecycle.md)
|
|
9
|
+
and <br /> [`@modular-component/with-default-props`](./with-default-props.md) respectively.
|
|
11
10
|
|
|
12
|
-
##
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
yarn add @modular-component/core @modular-component/default
|
|
16
|
-
```
|
|
11
|
+
## Usage
|
|
17
12
|
|
|
18
13
|
```tsx
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return { someState }
|
|
34
|
-
})
|
|
35
|
-
.withRender(({ props, lifecycle }) => (
|
|
36
|
-
<>
|
|
37
|
-
<h2>
|
|
38
|
-
{props.someLabel}: {props.someValue}
|
|
39
|
-
</h2>
|
|
40
|
-
<p>Value from state: {lifecycle.someState}</p>
|
|
41
|
-
<p>Flag from props: {props.someFlag ? 'true' : 'false'}</p>
|
|
42
|
-
</>
|
|
43
|
-
))
|
|
14
|
+
import { ModularComponent } from '@modular-component/core'
|
|
15
|
+
import { defaultProps, lifecycle, render } from '@modular-component/default'
|
|
16
|
+
|
|
17
|
+
const MyComponent = ModularComponent()
|
|
18
|
+
.with(defaultProps({
|
|
19
|
+
// Define default props here
|
|
20
|
+
}))
|
|
21
|
+
.with(lifecycle(() => {
|
|
22
|
+
// Write component state & logic here
|
|
23
|
+
}))
|
|
24
|
+
.with(render(({ props, lifecycle }) => (
|
|
25
|
+
// Use generated props and lifecycle in the render phase
|
|
26
|
+
)))
|
|
44
27
|
```
|
|
45
28
|
|
|
46
|
-
##
|
|
29
|
+
## Implementation
|
|
30
|
+
|
|
31
|
+
`@modular-component/default` simply merge together the records from two other packages. To see the implementation
|
|
32
|
+
details, refer to the individual packages:
|
|
47
33
|
|
|
48
|
-
|
|
34
|
+
* [`@modular-component/with-default-props`](https://npmjs.com/package/@modular-component/with-default-props): powerful default props capabilities
|
|
35
|
+
* [`@modular-component/with-lifecycle`](https://npmjs.com/package/@modular-component/with-lifecycle): isolate component logic in a dedicated hook
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
export { render } from '@modular-component/core';
|
|
2
|
+
export { defaultProps } from '@modular-component/with-default-props';
|
|
3
|
+
export { lifecycle } from '@modular-component/with-lifecycle';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
...WithDefaultProps,
|
|
5
|
-
...WithLifecycle,
|
|
6
|
-
};
|
|
1
|
+
export { render } from '@modular-component/core';
|
|
2
|
+
export { defaultProps } from '@modular-component/with-default-props';
|
|
3
|
+
export { lifecycle } from '@modular-component/with-lifecycle';
|
|
7
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"Default",
|
|
9
9
|
"Lifecycle"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.1
|
|
11
|
+
"version": "0.2.1",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"publishConfig": {
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
"license": "cp ../../LICENSE ./LICENSE"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@modular-component/
|
|
31
|
-
"@modular-component/with-
|
|
30
|
+
"@modular-component/core": "0.2.1",
|
|
31
|
+
"@modular-component/with-default-props": "0.2.1",
|
|
32
|
+
"@modular-component/with-lifecycle": "0.2.1"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"typescript": "^
|
|
35
|
+
"typescript": "^5.2.2"
|
|
35
36
|
},
|
|
36
37
|
"main": "dist/index.js",
|
|
37
38
|
"types": "dist/index.d.ts"
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const WithDefaultStages: typeof WithDefaultProps & typeof WithLifecycle =
|
|
5
|
-
{
|
|
6
|
-
...WithDefaultProps,
|
|
7
|
-
...WithLifecycle,
|
|
8
|
-
}
|
|
1
|
+
export { render } from '@modular-component/core'
|
|
2
|
+
export { defaultProps } from '@modular-component/with-default-props'
|
|
3
|
+
export { lifecycle } from '@modular-component/with-lifecycle'
|