@modular-component/with-default-props 0.1.3 → 0.1.5

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,21 @@
1
1
  # @modular-component/with-default-props
2
2
 
3
+ ## 0.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [bf87a1c]
8
+ - @modular-component/core@0.1.5
9
+
10
+ ## 0.1.4
11
+
12
+ ### Patch Changes
13
+
14
+ - 820a836: Refactor tuple system for better typescript performance
15
+ - Updated dependencies [f7af9ea]
16
+ - Updated dependencies [820a836]
17
+ - @modular-component/core@0.1.4
18
+
3
19
  ## 0.1.3
4
20
 
5
21
  ### 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 withDefaultProps: {
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, props: P) => any;
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;;;;mBAGM,EAAE;;;;CAM1B,CAAA"}
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
- withDefaultProps: {
4
+ DefaultProps: {
5
+ symbol: withDefaultProps,
4
6
  field: 'props',
5
- transform: (args, props) => ({
6
- ...(typeof props == 'function' ? props(args) : props),
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,gBAAgB,EAAE;QAChB,KAAK,EAAE,OAAO;QACd,SAAS,EAAE,CAA6B,IAAO,EAAE,KAAQ,EAAE,EAAE,CAAC,CAAC;YAC7D,GAAG,CAAC,OAAO,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACrD,GAAG,IAAI,CAAC,KAAK;SACd,CAAC;QACF,QAAQ,EAAE,EAA6B;KACxC;CACO,CAAC,CAAA"}
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.3",
11
+ "version": "0.1.5",
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.3"
29
+ "@modular-component/core": "0.1.5"
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
- withDefaultProps: {
25
+ DefaultProps: {
26
+ symbol: withDefaultProps,
5
27
  field: 'props',
6
- transform: <A extends { props: {} }, P>(args: A, props: P) => ({
7
- ...(typeof props == 'function' ? props(args) : props),
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)