piral-core 1.10.2-beta.dc71cd5 → 1.10.2

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.
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement, ReactNode } from 'react';
2
- import type { RouteComponentProps } from 'react-router';
2
+ import type { History, Location } from 'history';
3
3
  import type { PiletApi, Pilet, PiletEntry, PiletEntries, PiletMetadata, EventEmitter, PiletLoader, PiletLoadingStrategy } from 'piral-base';
4
4
  import type { PiletCustomApi } from './custom';
5
5
  import type { AnyComponent, PiralPageMeta } from './components';
@@ -38,19 +38,54 @@ export interface ExtensionComponentProps<T> extends BaseComponentProps {
38
38
  */
39
39
  children?: ReactNode;
40
40
  }
41
+ /**
42
+ * The match object determining what exactly has been matched for the current navigation.
43
+ */
44
+ export interface RouteMatch<Params extends {
45
+ [K in keyof Params]?: string;
46
+ } = {}> {
47
+ /**
48
+ * The parameters extracted from the current navigation.
49
+ */
50
+ params: Params;
51
+ /**
52
+ * Indicates if the parameters have been matched exactly.
53
+ */
54
+ isExact: boolean;
55
+ /**
56
+ * The relative path.
57
+ */
58
+ path: string;
59
+ /**
60
+ * The fully qualified URL.
61
+ */
62
+ url: string;
63
+ }
41
64
  /**
42
65
  * The props that every registered page component obtains.
43
66
  */
44
67
  export interface RouteBaseProps<UrlParams extends {
45
68
  [K in keyof UrlParams]?: string;
46
- } = {}, UrlState = any> extends RouteComponentProps<UrlParams, {}, UrlState>, BaseComponentProps {
69
+ } = {}, UrlState = any> extends BaseComponentProps {
70
+ /**
71
+ * The history API to navigate.
72
+ */
73
+ history: History<UrlState>;
74
+ /**
75
+ * Information about the current location.
76
+ */
77
+ location: Location<UrlState>;
78
+ /**
79
+ * Information about the matching of the current route.
80
+ */
81
+ match: RouteMatch<UrlParams>;
47
82
  }
48
83
  /**
49
84
  * The props used by a page component.
50
85
  */
51
- export interface PageComponentProps<T extends {
52
- [K in keyof T]?: string;
53
- } = {}, S = any> extends RouteBaseProps<T, S> {
86
+ export interface PageComponentProps<UrlParams extends {
87
+ [K in keyof UrlParams]?: string;
88
+ } = Record<string, string>, UrlState = any> extends RouteBaseProps<UrlParams, UrlState> {
54
89
  /**
55
90
  * The meta data registered with the page.
56
91
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-core",
3
- "version": "1.10.2-beta.dc71cd5",
3
+ "version": "1.10.2",
4
4
  "description": "The core library for creating a Piral instance.",
5
5
  "keywords": [
6
6
  "portal",
@@ -63,8 +63,8 @@
63
63
  "test": "echo \"Error: run tests from root\" && exit 1"
64
64
  },
65
65
  "dependencies": {
66
- "piral-base": "1.10.2-beta.dc71cd5",
67
- "piral-debug-utils": "1.10.2-beta.dc71cd5",
66
+ "piral-base": "^1.10.2",
67
+ "piral-debug-utils": "^1.10.2",
68
68
  "zustand": "^3.0.0"
69
69
  },
70
70
  "devDependencies": {
@@ -84,5 +84,5 @@
84
84
  "react-router-dom",
85
85
  "tslib"
86
86
  ],
87
- "gitHead": "dc71cd52424153bf2a1b56e05ccf03d6ad2a3fd8"
87
+ "gitHead": "296a540a6f2af0f39d7e086d7f437ded81a0d256"
88
88
  }
package/src/types/api.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement, ReactNode } from 'react';
2
- import type { RouteComponentProps } from 'react-router';
2
+ import type { History, Location } from 'history';
3
3
  import type {
4
4
  PiletApi,
5
5
  Pilet,
@@ -53,17 +53,54 @@ export interface ExtensionComponentProps<T> extends BaseComponentProps {
53
53
  children?: ReactNode;
54
54
  }
55
55
 
56
+ /**
57
+ * The match object determining what exactly has been matched for the current navigation.
58
+ */
59
+ export interface RouteMatch<Params extends { [K in keyof Params]?: string } = {}> {
60
+ /**
61
+ * The parameters extracted from the current navigation.
62
+ */
63
+ params: Params;
64
+ /**
65
+ * Indicates if the parameters have been matched exactly.
66
+ */
67
+ isExact: boolean;
68
+ /**
69
+ * The relative path.
70
+ */
71
+ path: string;
72
+ /**
73
+ * The fully qualified URL.
74
+ */
75
+ url: string;
76
+ }
77
+
56
78
  /**
57
79
  * The props that every registered page component obtains.
58
80
  */
59
81
  export interface RouteBaseProps<UrlParams extends { [K in keyof UrlParams]?: string } = {}, UrlState = any>
60
- extends RouteComponentProps<UrlParams, {}, UrlState>,
61
- BaseComponentProps {}
82
+ extends BaseComponentProps {
83
+ /**
84
+ * The history API to navigate.
85
+ */
86
+ history: History<UrlState>;
87
+ /**
88
+ * Information about the current location.
89
+ */
90
+ location: Location<UrlState>;
91
+ /**
92
+ * Information about the matching of the current route.
93
+ */
94
+ match: RouteMatch<UrlParams>;
95
+ }
62
96
 
63
97
  /**
64
98
  * The props used by a page component.
65
99
  */
66
- export interface PageComponentProps<T extends { [K in keyof T]?: string } = {}, S = any> extends RouteBaseProps<T, S> {
100
+ export interface PageComponentProps<
101
+ UrlParams extends { [K in keyof UrlParams]?: string } = Record<string, string>,
102
+ UrlState = any,
103
+ > extends RouteBaseProps<UrlParams, UrlState> {
67
104
  /**
68
105
  * The meta data registered with the page.
69
106
  */
@@ -80,8 +117,8 @@ export interface PageComponentProps<T extends { [K in keyof T]?: string } = {},
80
117
  export type AnyExtensionComponent<TName> = TName extends keyof PiralExtensionSlotMap
81
118
  ? AnyComponent<ExtensionComponentProps<TName>>
82
119
  : TName extends string
83
- ? AnyComponent<ExtensionComponentProps<any>>
84
- : AnyComponent<ExtensionComponentProps<TName>>;
120
+ ? AnyComponent<ExtensionComponentProps<any>>
121
+ : AnyComponent<ExtensionComponentProps<TName>>;
85
122
 
86
123
  /**
87
124
  * Defines the Pilet API from piral-core.