@kodaris/krubble-app-components 1.0.2 → 1.0.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/dist/krubble-app.bundled.js +6 -68
- package/dist/krubble-app.bundled.js.map +1 -1
- package/dist/krubble-app.bundled.min.js +80 -80
- package/dist/krubble-app.bundled.min.js.map +1 -1
- package/dist/krubble-app.umd.js +69 -132
- package/dist/krubble-app.umd.js.map +1 -1
- package/dist/krubble-app.umd.min.js +80 -80
- package/dist/krubble-app.umd.min.js.map +1 -1
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +6 -1
- package/dist/scaffold.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { KRContextMenu, KRDialog } from '@kodaris/krubble-components';
|
|
2
|
+
import { KRClient } from '@kodaris/krubble-data';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @license
|
|
@@ -919,74 +920,6 @@ KRShell = __decorate$5([
|
|
|
919
920
|
t$1('kr-shell')
|
|
920
921
|
], KRShell);
|
|
921
922
|
|
|
922
|
-
class KRClient {
|
|
923
|
-
constructor() {
|
|
924
|
-
this._url = `https://content.kodaris.com`;
|
|
925
|
-
}
|
|
926
|
-
static getInstance() {
|
|
927
|
-
if (!KRClient._instance) {
|
|
928
|
-
KRClient._instance = new KRClient();
|
|
929
|
-
}
|
|
930
|
-
return KRClient._instance;
|
|
931
|
-
}
|
|
932
|
-
fetch(options) {
|
|
933
|
-
let url = options.url;
|
|
934
|
-
// Add on the default base url if user
|
|
935
|
-
// has not provided the full url
|
|
936
|
-
if (url.indexOf('http') !== 0) {
|
|
937
|
-
url = this._url + url;
|
|
938
|
-
}
|
|
939
|
-
if (options.params) {
|
|
940
|
-
url += '?';
|
|
941
|
-
Object.keys(options.params).forEach((key, keyIdx) => {
|
|
942
|
-
if (keyIdx > 0) {
|
|
943
|
-
url += '&';
|
|
944
|
-
}
|
|
945
|
-
url += `${key}=${options.params[key]}`;
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
// fixme
|
|
949
|
-
if (!options) {
|
|
950
|
-
options = {};
|
|
951
|
-
}
|
|
952
|
-
if (!options.headers) {
|
|
953
|
-
options.headers = {};
|
|
954
|
-
}
|
|
955
|
-
if (!options.headers['Content-Type']) {
|
|
956
|
-
options.headers['Content-Type'] = 'application/json';
|
|
957
|
-
}
|
|
958
|
-
options.credentials = 'include';
|
|
959
|
-
// User and Customer apis require CSRF tokens on non-GET reequests
|
|
960
|
-
let token;
|
|
961
|
-
if (url.indexOf('/api/user/') > -1 || url.indexOf('/api/customer/') > -1) {
|
|
962
|
-
token = fetch(`${this._url}/api/user/customer/authToken`, { credentials: 'include' });
|
|
963
|
-
}
|
|
964
|
-
else {
|
|
965
|
-
token = Promise.resolve(null);
|
|
966
|
-
}
|
|
967
|
-
let response;
|
|
968
|
-
return token
|
|
969
|
-
.then(res => res?.json())
|
|
970
|
-
.then(res => {
|
|
971
|
-
if (res?.data) {
|
|
972
|
-
options.headers['X-CSRF-TOKEN'] = res.data;
|
|
973
|
-
}
|
|
974
|
-
return fetch(url, options);
|
|
975
|
-
})
|
|
976
|
-
.then(res => {
|
|
977
|
-
response = res;
|
|
978
|
-
return res.json();
|
|
979
|
-
})
|
|
980
|
-
.then(json => {
|
|
981
|
-
if (!response?.ok) {
|
|
982
|
-
return Promise.reject(json);
|
|
983
|
-
}
|
|
984
|
-
return Promise.resolve(json);
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
KRClient._instance = null;
|
|
989
|
-
|
|
990
923
|
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
991
924
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
992
925
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1564,9 +1497,14 @@ let KRScaffold = class KRScaffold extends i$1 {
|
|
|
1564
1497
|
});
|
|
1565
1498
|
this.dispatchEvent(navEvent);
|
|
1566
1499
|
// If a listener called preventDefault(), prevent the native navigation
|
|
1500
|
+
// (e.g., Angular router handles it and will call updateActiveNavItem() after route change)
|
|
1567
1501
|
if (navEvent.defaultPrevented) {
|
|
1568
1502
|
e.preventDefault();
|
|
1569
1503
|
}
|
|
1504
|
+
else {
|
|
1505
|
+
// Native browser navigation - set active item immediately for visual feedback
|
|
1506
|
+
this.activeNavItemId = item.id;
|
|
1507
|
+
}
|
|
1570
1508
|
}
|
|
1571
1509
|
}
|
|
1572
1510
|
/**
|