@viewfly/router 0.3.2 → 0.4.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.
@@ -42,11 +42,8 @@ class Navigator {
42
42
  }
43
43
  function formatUrl(pathname, urlFormatParams) {
44
44
  pathname = pathname.replace(/\/+/g, '/');
45
- if (urlFormatParams) {
46
- const { queryParams, fragment } = urlFormatParams;
47
- return pathname + (queryParams ? '?' + formatQueryParams(queryParams) : '') + (fragment ? '#' + fragment : '');
48
- }
49
- return pathname;
45
+ const { queryParams, fragment } = urlFormatParams;
46
+ return pathname + (queryParams ? '?' + formatQueryParams(queryParams) : '') + (fragment ? '#' + fragment : '');
50
47
  }
51
48
  function formatQueryParams(queryParams) {
52
49
  const params = [];
@@ -256,7 +253,11 @@ function Link(props) {
256
253
  }
257
254
  return () => {
258
255
  const Tag = props.tag || 'a';
259
- const attrs = Object.assign({}, props, Object.assign({ onClick: navigate }, props));
256
+ const attrs = Object.assign({}, props, Object.assign({ onClick(ev) {
257
+ var _a;
258
+ navigate(ev);
259
+ (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, ev);
260
+ } }, props));
260
261
  if (Tag === 'a') {
261
262
  attrs.href = navigator.join(props.to, router, props.queryParams, props.fragment);
262
263
  }
package/bundles/index.js CHANGED
@@ -44,11 +44,8 @@ class Navigator {
44
44
  }
45
45
  function formatUrl(pathname, urlFormatParams) {
46
46
  pathname = pathname.replace(/\/+/g, '/');
47
- if (urlFormatParams) {
48
- const { queryParams, fragment } = urlFormatParams;
49
- return pathname + (queryParams ? '?' + formatQueryParams(queryParams) : '') + (fragment ? '#' + fragment : '');
50
- }
51
- return pathname;
47
+ const { queryParams, fragment } = urlFormatParams;
48
+ return pathname + (queryParams ? '?' + formatQueryParams(queryParams) : '') + (fragment ? '#' + fragment : '');
52
49
  }
53
50
  function formatQueryParams(queryParams) {
54
51
  const params = [];
@@ -258,7 +255,11 @@ function Link(props) {
258
255
  }
259
256
  return () => {
260
257
  const Tag = props.tag || 'a';
261
- const attrs = Object.assign({}, props, Object.assign({ onClick: navigate }, props));
258
+ const attrs = Object.assign({}, props, Object.assign({ onClick(ev) {
259
+ var _a;
260
+ navigate(ev);
261
+ (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, ev);
262
+ } }, props));
262
263
  if (Tag === 'a') {
263
264
  attrs.href = navigator.join(props.to, router, props.queryParams, props.fragment);
264
265
  }
@@ -20,7 +20,7 @@ export interface UrlFormatParams {
20
20
  queryParams?: QueryParams;
21
21
  fragment?: string;
22
22
  }
23
- export declare function formatUrl(pathname: string, urlFormatParams?: UrlFormatParams): string;
23
+ export declare function formatUrl(pathname: string, urlFormatParams: UrlFormatParams): string;
24
24
  export declare function formatQueryParams(queryParams: QueryParams): string;
25
25
  export declare class BrowserNavigator extends Navigator {
26
26
  onUrlChanged: Observable<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/router",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "A routing library based on the Viewfly framework that can be run in the browser or Nodejs background.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -13,7 +13,7 @@
13
13
  "keywords": [],
14
14
  "dependencies": {
15
15
  "@tanbo/stream": "^1.2.3",
16
- "@viewfly/core": "^0.3.1",
16
+ "@viewfly/core": "^0.4.0",
17
17
  "url": "^0.11.1"
18
18
  },
19
19
  "devDependencies": {
@@ -34,5 +34,5 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/viewfly/viewfly.git/issues"
36
36
  },
37
- "gitHead": "b66ca589f7662cd518fc2e5955b3e3ff9de83f94"
37
+ "gitHead": "d14b3cd0247a07f72519745933c3070f12adbfa1"
38
38
  }