@dile/lib 0.1.6 → 0.1.7
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/index.js
CHANGED
|
@@ -20,4 +20,5 @@ export { DileAppNavigate } from './src/lib/DileAppNavigate.js';
|
|
|
20
20
|
|
|
21
21
|
export { DileAppFeedback } from './src/components/DileAppFeedback.js';
|
|
22
22
|
export { DileAppLoading } from './src/components/DileAppLoading.js';
|
|
23
|
-
export { DileAuthGuard } from './src/components/DileAuthGuard.js';
|
|
23
|
+
export { DileAuthGuard } from './src/components/DileAuthGuard.js';
|
|
24
|
+
export { DileRouterLink } from './src/components/DileRouterLink.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/lib",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Common App libraries, mixins and helpers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"@reduxjs/toolkit": "^2.5.1",
|
|
28
28
|
"lit": "^2.7.0 || ^3.0.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "a4f04b0b0b0e56afd4a7da5c7d934c67d2bd6bab"
|
|
31
31
|
}
|
|
@@ -16,12 +16,14 @@ export const DileAuthGuard = (store) => class extends DileAppNavigate(DileState(
|
|
|
16
16
|
return {
|
|
17
17
|
loaded: { type: Boolean },
|
|
18
18
|
pageTitle: { type: String },
|
|
19
|
+
guestRedirectUrl: { type: String },
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
constructor() {
|
|
23
24
|
super();
|
|
24
25
|
this.pageTitle = '';
|
|
26
|
+
this.guestRedirectUrl = '/';
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
render() {
|
|
@@ -45,7 +47,7 @@ export const DileAuthGuard = (store) => class extends DileAppNavigate(DileState(
|
|
|
45
47
|
if(state.user.isLoggedIn && this.validateAdditionalRules(state)) {
|
|
46
48
|
this.loaded = true;
|
|
47
49
|
} else {
|
|
48
|
-
this.goToUrl(
|
|
50
|
+
this.goToUrl(this.guestRedirectUrl, this.pageTitle);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { DileAppNavigate } from '../lib/DileAppNavigate';
|
|
3
|
+
|
|
4
|
+
export class DileRouterLink extends DileAppNavigate(LitElement) {
|
|
5
|
+
static styles = [
|
|
6
|
+
css`
|
|
7
|
+
:host {
|
|
8
|
+
display: inline-block
|
|
9
|
+
}
|
|
10
|
+
a {
|
|
11
|
+
color: var(--dile-router-link-color, inherit);
|
|
12
|
+
text-decoration: var(--dile-router-link-text-decoration, none);
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
static get properties() {
|
|
18
|
+
return {
|
|
19
|
+
href: { type: String },
|
|
20
|
+
title: { type: String },
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
render() {
|
|
25
|
+
return html`
|
|
26
|
+
<a href="${this.href}" @click=${this.handleLink}>
|
|
27
|
+
<slot></slot>
|
|
28
|
+
</a>
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
handleLink(e) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
this.goToUrl(this.href, this.title);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export const DileAppNavigate = (superclass) => class extends superclass {
|
|
2
2
|
goToUrl(url, title = '') {
|
|
3
|
-
console.log('app navigate', url, title)
|
|
4
3
|
document.dispatchEvent(new CustomEvent('dile-lib-navigate', {
|
|
5
4
|
bubbles: true,
|
|
6
5
|
composed: true,
|
|
@@ -10,4 +9,9 @@ export const DileAppNavigate = (superclass) => class extends superclass {
|
|
|
10
9
|
}
|
|
11
10
|
}));
|
|
12
11
|
}
|
|
12
|
+
|
|
13
|
+
routerLinkHandler(e) {
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
this.goToUrl(e.target.getAttribute('href'));
|
|
16
|
+
}
|
|
13
17
|
}
|
package/src/lib/DileAppRouter.js
CHANGED
|
@@ -14,11 +14,17 @@ export const DileAppRouter = (superclass) => class extends superclass {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
programaticNavigation(e) {
|
|
17
|
+
const title = e.detail.title;
|
|
18
|
+
const url = e.detail.url;
|
|
17
19
|
history.pushState(
|
|
18
20
|
null,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
title || 'App',
|
|
22
|
+
url);
|
|
21
23
|
setTimeout(() => this._routes.goto(e.detail.url), 100);
|
|
24
|
+
|
|
25
|
+
if(title) {
|
|
26
|
+
document.title = title;
|
|
27
|
+
}
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
connectedCallback() {
|