@modular-component/default 0.2.3 → 0.3.0

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @modular-component/default
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1784a2b: Add a clean way to extend the ModularComponent API with new dedicated stage functions
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [1784a2b]
12
+ - @modular-component/core@0.3.0
13
+ - @modular-component/with-default-props@0.3.0
14
+ - @modular-component/with-lifecycle@0.3.0
15
+
3
16
  ## 0.2.3
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -2,34 +2,52 @@
2
2
 
3
3
  Set of sensible defaults for using `ModularComponent`.
4
4
 
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.
5
+ Provides two stages: `lifecycle()` for adding a lifecycle hook, and `defaultProps()` for
6
+ providing default values for props. It also re-exports `render()` from `@modular-component/props` for convenience.
7
7
 
8
8
  It's also possible to import each of them individually through [`@modular-component/with-lifecycle`](https://npmjs.com/package/@modular-component/with-lifecycle)
9
9
  and <br /> [`@modular-component/with-default-props`](https://npmjs.com/package/@modular-component/with-default-props) respectively.
10
10
 
11
11
  ## Usage
12
12
 
13
+ **Stage function imports**
14
+
13
15
  ```tsx
14
16
  import { ModularComponent } from '@modular-component/core'
15
17
  import { defaultProps, lifecycle, render } from '@modular-component/default'
16
18
 
17
19
  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
- )))
20
+ .with(
21
+ defaultProps({
22
+ // Define default props here
23
+ }),
24
+ )
25
+ .with(
26
+ lifecycle(() => {
27
+ // Write component state & logic here
28
+ }),
29
+ )
30
+ .with(
31
+ render(({ props, lifecycle }) => {
32
+ // Use generated props and lifecycle in the render phase
33
+ }),
34
+ )
27
35
  ```
28
36
 
29
- ## Implementation
37
+ **Stage registration**
30
38
 
31
- `@modular-component/default` simply merge together the records from two other packages. To see the implementation
32
- details, refer to the individual packages:
39
+ ```tsx
40
+ import { ModularComponent } from '@modular-component/core'
41
+ import '@modular-component/default/register'
33
42
 
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
43
+ const MyComponent = ModularComponent()
44
+ .withDefaultProps({
45
+ // Define default props here
46
+ })
47
+ .withLifecycle(() => {
48
+ // Write component state & logic here
49
+ })
50
+ .withRender(({ props, lifecycle }) => {
51
+ // Use generated props and lifecycle in the render phase
52
+ })
53
+ ```
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from '@modular-component/core'
2
+ export * from '@modular-component/with-lifecycle'
3
+ export * from '@modular-component/with-default-props'
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from '@modular-component/core'
2
+ export * from '@modular-component/with-lifecycle'
3
+ export * from '@modular-component/with-default-props'
package/package.json CHANGED
@@ -8,32 +8,37 @@
8
8
  "Default",
9
9
  "Lifecycle"
10
10
  ],
11
- "version": "0.2.3",
11
+ "version": "0.3.0",
12
12
  "type": "module",
13
13
  "license": "MIT",
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  },
17
17
  "files": [
18
- "src",
19
- "dist",
18
+ "index.js",
19
+ "index.d.ts",
20
+ "register.js",
21
+ "register.d.ts",
20
22
  "CHANGELOG.md"
21
23
  ],
22
24
  "scripts": {
23
- "build": "yarn build:with-default-props && yarn build:with-lifecycle && yarn build:self",
25
+ "build": "yarn build:with-default-props && yarn build:with-lifecycle",
26
+ "build:self": "tsc --noEmit index register",
24
27
  "build:with-default-props": "yarn workspace @modular-component/with-default-props build",
25
28
  "build:with-lifecycle": "yarn workspace @modular-component/with-lifecycle build",
26
- "build:self": "tsc",
27
29
  "license": "cp ../../LICENSE ./LICENSE"
28
30
  },
29
31
  "dependencies": {
30
- "@modular-component/core": "0.2.3",
31
- "@modular-component/with-default-props": "0.2.3",
32
- "@modular-component/with-lifecycle": "0.2.3"
32
+ "@modular-component/with-default-props": "0.3.0",
33
+ "@modular-component/with-lifecycle": "0.3.0"
34
+ },
35
+ "peerDependencies": {
36
+ "@modular-component/core": "0.3.0"
33
37
  },
34
38
  "devDependencies": {
35
- "typescript": "^5.2.2"
39
+ "@modular-component/core": "*",
40
+ "typescript": "^5.9.3"
36
41
  },
37
- "main": "dist/index.js",
38
- "types": "dist/index.d.ts"
42
+ "main": "index.js",
43
+ "types": "index.d.ts"
39
44
  }
package/register.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import '@modular-component/core/register'
2
+ import '@modular-component/with-lifecycle/register'
3
+ import '@modular-component/with-default-props/register'
package/register.js ADDED
@@ -0,0 +1,3 @@
1
+ import '@modular-component/core/register.js'
2
+ import '@modular-component/with-lifecycle/register.js'
3
+ import '@modular-component/with-default-props/register.js'
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
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
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,4 +0,0 @@
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
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
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/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export { render } from '@modular-component/core'
2
- export { defaultProps } from '@modular-component/with-default-props'
3
- export { lifecycle } from '@modular-component/with-lifecycle'