@modular-component/with-default-props 0.1.3 → 0.1.4
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 +9 -0
- package/dist/index.d.ts +21 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +25 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @modular-component/with-default-props
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 820a836: Refactor tuple system for better typescript performance
|
|
8
|
+
- Updated dependencies [f7af9ea]
|
|
9
|
+
- Updated dependencies [820a836]
|
|
10
|
+
- @modular-component/core@0.1.4
|
|
11
|
+
|
|
3
12
|
## 0.1.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
declare const withDefaultProps: unique symbol;
|
|
2
|
+
declare module '@modular-component/core' {
|
|
3
|
+
interface ModularStages<Args, Value> {
|
|
4
|
+
[withDefaultProps]: {
|
|
5
|
+
restrict: Partial<Args extends {
|
|
6
|
+
props: infer P;
|
|
7
|
+
} ? P : {}> | ((args: Args) => Partial<Args extends {
|
|
8
|
+
props: infer P;
|
|
9
|
+
} ? P : {}>);
|
|
10
|
+
transform: Value extends ((args: Args) => infer T) | infer T ? Args extends {
|
|
11
|
+
props: infer P;
|
|
12
|
+
} ? {
|
|
13
|
+
[key in keyof T]: key extends keyof P ? NonNullable<P[key]> : T[key];
|
|
14
|
+
} : Value : never;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
1
18
|
export declare const WithDefaultProps: {
|
|
2
|
-
readonly
|
|
19
|
+
readonly DefaultProps: {
|
|
20
|
+
readonly symbol: typeof withDefaultProps;
|
|
3
21
|
readonly field: "props";
|
|
4
22
|
readonly transform: <A extends {
|
|
5
23
|
props: {};
|
|
6
|
-
}, P>(args: A,
|
|
7
|
-
readonly restrict: Record<string, unknown>;
|
|
24
|
+
}, P>(args: A, useProps: P) => any;
|
|
8
25
|
};
|
|
9
26
|
};
|
|
27
|
+
export {};
|
|
10
28
|
//# 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":"AAEA,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,gBAAgB,eAAW,CAAA;AAEjC,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAiB,aAAa,CAAC,IAAI,EAAE,KAAK;QACxC,CAAC,gBAAgB,CAAC,EAAE;YAClB,QAAQ,EACJ,OAAO,CAAC,IAAI,SAAS;gBAAE,KAAK,EAAE,MAAM,CAAC,CAAA;aAAE,GAAG,CAAC,GAAG,EAAE,CAAC,GACjD,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,SAAS;gBAAE,KAAK,EAAE,MAAM,CAAC,CAAA;aAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;YACvE,SAAS,EAAE,KAAK,SAAS,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,GACxD,IAAI,SAAS;gBAAE,KAAK,EAAE,MAAM,CAAC,CAAA;aAAE,GAC7B;iBACG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,SAAS,MAAM,CAAC,GACjC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GACnB,CAAC,CAAC,GAAG,CAAC;aACX,GACD,KAAK,GACP,KAAK,CAAA;SACV,CAAA;KACF;CACF;AAED,eAAO,MAAM,gBAAgB;;;;;mBAIM,EAAE;;;CAK1B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createMethodRecord } from '@modular-component/core';
|
|
2
|
+
const withDefaultProps = Symbol();
|
|
2
3
|
export const WithDefaultProps = createMethodRecord({
|
|
3
|
-
|
|
4
|
+
DefaultProps: {
|
|
5
|
+
symbol: withDefaultProps,
|
|
4
6
|
field: 'props',
|
|
5
|
-
transform: (args,
|
|
6
|
-
...(typeof
|
|
7
|
+
transform: (args, useProps) => ({
|
|
8
|
+
...(typeof useProps === 'function' ? useProps(args) : useProps),
|
|
7
9
|
...args.props,
|
|
8
10
|
}),
|
|
9
|
-
restrict: {},
|
|
10
11
|
},
|
|
11
12
|
});
|
|
12
13
|
//# 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,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;IACjD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,MAAM,gBAAgB,GAAG,MAAM,EAAE,CAAA;AAqBjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;IACjD,YAAY,EAAE;QACZ,MAAM,EAAE,gBAAgB;QACxB,KAAK,EAAE,OAAO;QACd,SAAS,EAAE,CAA6B,IAAO,EAAE,QAAW,EAAE,EAAE,CAAC,CAAC;YAChE,GAAG,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YAC/D,GAAG,IAAI,CAAC,KAAK;SACd,CAAC;KACH;CACO,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"Default",
|
|
9
9
|
"Conditional"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.1.
|
|
11
|
+
"version": "0.1.4",
|
|
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.1.
|
|
29
|
+
"@modular-component/core": "0.1.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"typescript": "^4.6.4"
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
import { createMethodRecord } from '@modular-component/core'
|
|
2
2
|
|
|
3
|
+
const withDefaultProps = Symbol()
|
|
4
|
+
|
|
5
|
+
declare module '@modular-component/core' {
|
|
6
|
+
export interface ModularStages<Args, Value> {
|
|
7
|
+
[withDefaultProps]: {
|
|
8
|
+
restrict:
|
|
9
|
+
| Partial<Args extends { props: infer P } ? P : {}>
|
|
10
|
+
| ((args: Args) => Partial<Args extends { props: infer P } ? P : {}>)
|
|
11
|
+
transform: Value extends ((args: Args) => infer T) | infer T
|
|
12
|
+
? Args extends { props: infer P }
|
|
13
|
+
? {
|
|
14
|
+
[key in keyof T]: key extends keyof P
|
|
15
|
+
? NonNullable<P[key]>
|
|
16
|
+
: T[key]
|
|
17
|
+
}
|
|
18
|
+
: Value
|
|
19
|
+
: never
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
3
24
|
export const WithDefaultProps = createMethodRecord({
|
|
4
|
-
|
|
25
|
+
DefaultProps: {
|
|
26
|
+
symbol: withDefaultProps,
|
|
5
27
|
field: 'props',
|
|
6
|
-
transform: <A extends { props: {} }, P>(args: A,
|
|
7
|
-
...(typeof
|
|
28
|
+
transform: <A extends { props: {} }, P>(args: A, useProps: P) => ({
|
|
29
|
+
...(typeof useProps === 'function' ? useProps(args) : useProps),
|
|
8
30
|
...args.props,
|
|
9
31
|
}),
|
|
10
|
-
restrict: {} as Record<string, unknown>,
|
|
11
32
|
},
|
|
12
33
|
} as const)
|