@modular-component/default 0.2.3 → 0.3.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 +34 -16
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +20 -11
- package/register.d.ts +3 -0
- package/register.js +3 -0
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/src/index.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @modular-component/default
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6fa514f: Fix exports compatibility with some bundlers
|
|
8
|
+
- Updated dependencies [6fa514f]
|
|
9
|
+
- @modular-component/core@0.3.1
|
|
10
|
+
- @modular-component/with-default-props@0.3.1
|
|
11
|
+
- @modular-component/with-lifecycle@0.3.1
|
|
12
|
+
|
|
13
|
+
## 0.3.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 1784a2b: Add a clean way to extend the ModularComponent API with new dedicated stage functions
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [1784a2b]
|
|
22
|
+
- @modular-component/core@0.3.0
|
|
23
|
+
- @modular-component/with-default-props@0.3.0
|
|
24
|
+
- @modular-component/with-lifecycle@0.3.0
|
|
25
|
+
|
|
3
26
|
## 0.2.3
|
|
4
27
|
|
|
5
28
|
### 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: `
|
|
6
|
-
providing default values for props. It also re-exports `
|
|
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(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
37
|
+
**Stage registration**
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
```tsx
|
|
40
|
+
import { ModularComponent } from '@modular-component/core'
|
|
41
|
+
import '@modular-component/default/register'
|
|
33
42
|
|
|
34
|
-
|
|
35
|
-
|
|
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
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -8,32 +8,41 @@
|
|
|
8
8
|
"Default",
|
|
9
9
|
"Lifecycle"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.3.1",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
|
-
"
|
|
19
|
-
"
|
|
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
|
|
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/
|
|
31
|
-
"@modular-component/with-
|
|
32
|
-
|
|
32
|
+
"@modular-component/with-default-props": "0.3.1",
|
|
33
|
+
"@modular-component/with-lifecycle": "0.3.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@modular-component/core": "0.3.1"
|
|
33
37
|
},
|
|
34
38
|
"devDependencies": {
|
|
35
|
-
"
|
|
39
|
+
"@modular-component/core": "*",
|
|
40
|
+
"typescript": "^5.9.3"
|
|
36
41
|
},
|
|
37
|
-
"main": "
|
|
38
|
-
"types": "
|
|
42
|
+
"main": "index.js",
|
|
43
|
+
"types": "index.d.ts",
|
|
44
|
+
"exports": {
|
|
45
|
+
".": "./dist/index.js",
|
|
46
|
+
"./register": "./register.js"
|
|
47
|
+
}
|
|
39
48
|
}
|
package/register.d.ts
ADDED
package/register.js
ADDED
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -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
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