@forsakringskassan/devindex-menu 2.3.7 → 2.3.9
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/cjs/menu.js +30 -25
- package/dist/esm/menu.js +30 -25
- package/dist/types/menu.d.ts +1 -1
- package/package.json +17 -17
package/dist/cjs/menu.js
CHANGED
|
@@ -1129,13 +1129,14 @@ var ElementIdServiceImpl = class {
|
|
|
1129
1129
|
var ElementIdService = /* @__PURE__ */ new ElementIdServiceImpl();
|
|
1130
1130
|
var wrapper;
|
|
1131
1131
|
function createScreenReaderWrapper(options) {
|
|
1132
|
-
if (
|
|
1133
|
-
|
|
1134
|
-
wrapper.id = "fkui-alert-screen-reader";
|
|
1135
|
-
wrapper.className = "sr-only";
|
|
1136
|
-
updateProperties(options);
|
|
1137
|
-
document.body.append(wrapper);
|
|
1132
|
+
if (getWrapper()) {
|
|
1133
|
+
return;
|
|
1138
1134
|
}
|
|
1135
|
+
wrapper = document.createElement("div");
|
|
1136
|
+
wrapper.id = "fkui-alert-screen-reader";
|
|
1137
|
+
wrapper.className = "sr-only";
|
|
1138
|
+
updateProperties(options);
|
|
1139
|
+
document.body.append(wrapper);
|
|
1139
1140
|
}
|
|
1140
1141
|
function updateProperties(options) {
|
|
1141
1142
|
const wrapper2 = getWrapper();
|
|
@@ -1330,10 +1331,10 @@ var style_default = `.secret-menu {
|
|
|
1330
1331
|
// src/menu.ts
|
|
1331
1332
|
var ONE_MONTH_IN_SECONDS = 2592e3;
|
|
1332
1333
|
var settingsNodes = [];
|
|
1333
|
-
function evaluateMock(mock) {
|
|
1334
|
+
async function evaluateMock(mock) {
|
|
1334
1335
|
if (typeof mock === "function") {
|
|
1335
1336
|
const req = {};
|
|
1336
|
-
return mock(req);
|
|
1337
|
+
return await mock(req);
|
|
1337
1338
|
}
|
|
1338
1339
|
return mock;
|
|
1339
1340
|
}
|
|
@@ -1381,7 +1382,7 @@ function getFirstCookie(matcher) {
|
|
|
1381
1382
|
const [key, value] = entries[0];
|
|
1382
1383
|
return { key, value };
|
|
1383
1384
|
}
|
|
1384
|
-
function entryFromMock(mock) {
|
|
1385
|
+
async function entryFromMock(mock) {
|
|
1385
1386
|
if (!mock.responses || mock.responses.length === 0) {
|
|
1386
1387
|
throw new Error(
|
|
1387
1388
|
"Mock must have at least one response to generate entry from."
|
|
@@ -1389,24 +1390,26 @@ function entryFromMock(mock) {
|
|
|
1389
1390
|
}
|
|
1390
1391
|
const { key } = getFirstCookie(mock.responses[0]);
|
|
1391
1392
|
const title = mock.meta?.title ?? key;
|
|
1393
|
+
const defaultResponse = await evaluateMock(mock.defaultResponse);
|
|
1392
1394
|
const defaultEntry = {
|
|
1393
|
-
title:
|
|
1395
|
+
title: defaultResponse.label ?? "Default",
|
|
1394
1396
|
value: "default"
|
|
1395
1397
|
};
|
|
1398
|
+
const responses = await Promise.all(
|
|
1399
|
+
mock.responses.map(async (entry) => {
|
|
1400
|
+
const { value } = getFirstCookie(entry);
|
|
1401
|
+
const response = await evaluateMock(entry.response);
|
|
1402
|
+
return {
|
|
1403
|
+
title: response.label ?? value,
|
|
1404
|
+
value
|
|
1405
|
+
};
|
|
1406
|
+
})
|
|
1407
|
+
);
|
|
1396
1408
|
return {
|
|
1397
1409
|
type: "select",
|
|
1398
1410
|
key,
|
|
1399
1411
|
title,
|
|
1400
|
-
options: [
|
|
1401
|
-
defaultEntry,
|
|
1402
|
-
...mock.responses.map((entry) => {
|
|
1403
|
-
const { value } = getFirstCookie(entry);
|
|
1404
|
-
return {
|
|
1405
|
-
title: evaluateMock(entry.response).label ?? value,
|
|
1406
|
-
value
|
|
1407
|
-
};
|
|
1408
|
-
})
|
|
1409
|
-
]
|
|
1412
|
+
options: [defaultEntry, ...responses]
|
|
1410
1413
|
};
|
|
1411
1414
|
}
|
|
1412
1415
|
var defaultSetting = {
|
|
@@ -1415,7 +1418,7 @@ var defaultSetting = {
|
|
|
1415
1418
|
var defaultOptions = {
|
|
1416
1419
|
position: "left"
|
|
1417
1420
|
};
|
|
1418
|
-
|
|
1421
|
+
async function menu_default(userSettingsAndMocks, menuOptions) {
|
|
1419
1422
|
const options = { ...defaultOptions, ...menuOptions };
|
|
1420
1423
|
document.head.insertAdjacentHTML("beforeend", `<style>${style_default}</style>`);
|
|
1421
1424
|
document.body.insertAdjacentHTML(
|
|
@@ -1426,9 +1429,11 @@ var menu_default = (userSettingsAndMocks, menuOptions) => {
|
|
|
1426
1429
|
`
|
|
1427
1430
|
);
|
|
1428
1431
|
let settingsMarkup = "";
|
|
1429
|
-
const userSettings =
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
+
const userSettings = await Promise.all(
|
|
1433
|
+
userSettingsAndMocks.map(async (userSettingOrMock) => {
|
|
1434
|
+
return isMock(userSettingOrMock) ? entryFromMock(userSettingOrMock) : userSettingOrMock;
|
|
1435
|
+
})
|
|
1436
|
+
);
|
|
1432
1437
|
for (const userSetting of userSettings) {
|
|
1433
1438
|
const setting = { ...defaultSetting, ...userSetting };
|
|
1434
1439
|
settingsMarkup += generateOptionMarkup(setting);
|
|
@@ -1457,4 +1462,4 @@ var menu_default = (userSettingsAndMocks, menuOptions) => {
|
|
|
1457
1462
|
const script = document.createElement("script");
|
|
1458
1463
|
script.textContent = client_default;
|
|
1459
1464
|
document.body.append(script);
|
|
1460
|
-
}
|
|
1465
|
+
}
|
package/dist/esm/menu.js
CHANGED
|
@@ -1104,13 +1104,14 @@ var ElementIdServiceImpl = class {
|
|
|
1104
1104
|
var ElementIdService = /* @__PURE__ */ new ElementIdServiceImpl();
|
|
1105
1105
|
var wrapper;
|
|
1106
1106
|
function createScreenReaderWrapper(options) {
|
|
1107
|
-
if (
|
|
1108
|
-
|
|
1109
|
-
wrapper.id = "fkui-alert-screen-reader";
|
|
1110
|
-
wrapper.className = "sr-only";
|
|
1111
|
-
updateProperties(options);
|
|
1112
|
-
document.body.append(wrapper);
|
|
1107
|
+
if (getWrapper()) {
|
|
1108
|
+
return;
|
|
1113
1109
|
}
|
|
1110
|
+
wrapper = document.createElement("div");
|
|
1111
|
+
wrapper.id = "fkui-alert-screen-reader";
|
|
1112
|
+
wrapper.className = "sr-only";
|
|
1113
|
+
updateProperties(options);
|
|
1114
|
+
document.body.append(wrapper);
|
|
1114
1115
|
}
|
|
1115
1116
|
function updateProperties(options) {
|
|
1116
1117
|
const wrapper2 = getWrapper();
|
|
@@ -1305,10 +1306,10 @@ var style_default = `.secret-menu {
|
|
|
1305
1306
|
// src/menu.ts
|
|
1306
1307
|
var ONE_MONTH_IN_SECONDS = 2592e3;
|
|
1307
1308
|
var settingsNodes = [];
|
|
1308
|
-
function evaluateMock(mock) {
|
|
1309
|
+
async function evaluateMock(mock) {
|
|
1309
1310
|
if (typeof mock === "function") {
|
|
1310
1311
|
const req = {};
|
|
1311
|
-
return mock(req);
|
|
1312
|
+
return await mock(req);
|
|
1312
1313
|
}
|
|
1313
1314
|
return mock;
|
|
1314
1315
|
}
|
|
@@ -1356,7 +1357,7 @@ function getFirstCookie(matcher) {
|
|
|
1356
1357
|
const [key, value] = entries[0];
|
|
1357
1358
|
return { key, value };
|
|
1358
1359
|
}
|
|
1359
|
-
function entryFromMock(mock) {
|
|
1360
|
+
async function entryFromMock(mock) {
|
|
1360
1361
|
if (!mock.responses || mock.responses.length === 0) {
|
|
1361
1362
|
throw new Error(
|
|
1362
1363
|
"Mock must have at least one response to generate entry from."
|
|
@@ -1364,24 +1365,26 @@ function entryFromMock(mock) {
|
|
|
1364
1365
|
}
|
|
1365
1366
|
const { key } = getFirstCookie(mock.responses[0]);
|
|
1366
1367
|
const title = mock.meta?.title ?? key;
|
|
1368
|
+
const defaultResponse = await evaluateMock(mock.defaultResponse);
|
|
1367
1369
|
const defaultEntry = {
|
|
1368
|
-
title:
|
|
1370
|
+
title: defaultResponse.label ?? "Default",
|
|
1369
1371
|
value: "default"
|
|
1370
1372
|
};
|
|
1373
|
+
const responses = await Promise.all(
|
|
1374
|
+
mock.responses.map(async (entry) => {
|
|
1375
|
+
const { value } = getFirstCookie(entry);
|
|
1376
|
+
const response = await evaluateMock(entry.response);
|
|
1377
|
+
return {
|
|
1378
|
+
title: response.label ?? value,
|
|
1379
|
+
value
|
|
1380
|
+
};
|
|
1381
|
+
})
|
|
1382
|
+
);
|
|
1371
1383
|
return {
|
|
1372
1384
|
type: "select",
|
|
1373
1385
|
key,
|
|
1374
1386
|
title,
|
|
1375
|
-
options: [
|
|
1376
|
-
defaultEntry,
|
|
1377
|
-
...mock.responses.map((entry) => {
|
|
1378
|
-
const { value } = getFirstCookie(entry);
|
|
1379
|
-
return {
|
|
1380
|
-
title: evaluateMock(entry.response).label ?? value,
|
|
1381
|
-
value
|
|
1382
|
-
};
|
|
1383
|
-
})
|
|
1384
|
-
]
|
|
1387
|
+
options: [defaultEntry, ...responses]
|
|
1385
1388
|
};
|
|
1386
1389
|
}
|
|
1387
1390
|
var defaultSetting = {
|
|
@@ -1390,7 +1393,7 @@ var defaultSetting = {
|
|
|
1390
1393
|
var defaultOptions = {
|
|
1391
1394
|
position: "left"
|
|
1392
1395
|
};
|
|
1393
|
-
|
|
1396
|
+
async function menu_default(userSettingsAndMocks, menuOptions) {
|
|
1394
1397
|
const options = { ...defaultOptions, ...menuOptions };
|
|
1395
1398
|
document.head.insertAdjacentHTML("beforeend", `<style>${style_default}</style>`);
|
|
1396
1399
|
document.body.insertAdjacentHTML(
|
|
@@ -1401,9 +1404,11 @@ var menu_default = (userSettingsAndMocks, menuOptions) => {
|
|
|
1401
1404
|
`
|
|
1402
1405
|
);
|
|
1403
1406
|
let settingsMarkup = "";
|
|
1404
|
-
const userSettings =
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
+
const userSettings = await Promise.all(
|
|
1408
|
+
userSettingsAndMocks.map(async (userSettingOrMock) => {
|
|
1409
|
+
return isMock(userSettingOrMock) ? entryFromMock(userSettingOrMock) : userSettingOrMock;
|
|
1410
|
+
})
|
|
1411
|
+
);
|
|
1407
1412
|
for (const userSetting of userSettings) {
|
|
1408
1413
|
const setting = { ...defaultSetting, ...userSetting };
|
|
1409
1414
|
settingsMarkup += generateOptionMarkup(setting);
|
|
@@ -1432,7 +1437,7 @@ var menu_default = (userSettingsAndMocks, menuOptions) => {
|
|
|
1432
1437
|
const script = document.createElement("script");
|
|
1433
1438
|
script.textContent = client_default;
|
|
1434
1439
|
document.body.append(script);
|
|
1435
|
-
}
|
|
1440
|
+
}
|
|
1436
1441
|
export {
|
|
1437
1442
|
ONE_MONTH_IN_SECONDS,
|
|
1438
1443
|
menu_default as default
|
package/dist/types/menu.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare const ONE_MONTH_IN_SECONDS = 2592000;
|
|
|
48
48
|
/**
|
|
49
49
|
* @param userSettingsAndMocks - An array of user settings and/or mocks to generate the menu from.
|
|
50
50
|
*/
|
|
51
|
-
declare function _default(userSettingsAndMocks: Array<Settings | Mock>, menuOptions?: MenuOptions): void
|
|
51
|
+
declare function _default(userSettingsAndMocks: Array<Settings | Mock>, menuOptions?: MenuOptions): Promise<void>;
|
|
52
52
|
|
|
53
53
|
export {
|
|
54
54
|
_default as default,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forsakringskassan/devindex-menu",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.9",
|
|
4
4
|
"description": "Menu for local development",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"development",
|
|
@@ -53,31 +53,31 @@
|
|
|
53
53
|
"extends": "@forsakringskassan/semantic-release-config"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@fkui/logic": "6.
|
|
56
|
+
"@fkui/logic": "6.54.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@babel/core": "8.0.1",
|
|
60
60
|
"@babel/preset-env": "8.0.2",
|
|
61
|
-
"@fkui/tsconfig": "6.
|
|
62
|
-
"@forsakringskassan/apimock-express": "3.
|
|
63
|
-
"@forsakringskassan/commitlint-config": "4.2.
|
|
64
|
-
"@forsakringskassan/eslint-config": "15.
|
|
65
|
-
"@forsakringskassan/eslint-config-cli": "15.
|
|
66
|
-
"@forsakringskassan/eslint-config-cypress": "15.
|
|
67
|
-
"@forsakringskassan/eslint-config-jest": "15.
|
|
68
|
-
"@forsakringskassan/eslint-config-typescript": "15.
|
|
69
|
-
"@forsakringskassan/eslint-config-typescript-typeinfo": "15.
|
|
70
|
-
"@forsakringskassan/prettier-config": "3.7.
|
|
71
|
-
"@tsconfig/node22": "22.0.
|
|
61
|
+
"@fkui/tsconfig": "6.54.0",
|
|
62
|
+
"@forsakringskassan/apimock-express": "3.1.0",
|
|
63
|
+
"@forsakringskassan/commitlint-config": "4.2.8",
|
|
64
|
+
"@forsakringskassan/eslint-config": "15.8.9",
|
|
65
|
+
"@forsakringskassan/eslint-config-cli": "15.8.9",
|
|
66
|
+
"@forsakringskassan/eslint-config-cypress": "15.8.9",
|
|
67
|
+
"@forsakringskassan/eslint-config-jest": "15.8.9",
|
|
68
|
+
"@forsakringskassan/eslint-config-typescript": "15.8.9",
|
|
69
|
+
"@forsakringskassan/eslint-config-typescript-typeinfo": "15.8.9",
|
|
70
|
+
"@forsakringskassan/prettier-config": "3.7.8",
|
|
71
|
+
"@tsconfig/node22": "22.0.6",
|
|
72
72
|
"@types/node": "22.20.1",
|
|
73
73
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
74
|
-
"cypress": "15.
|
|
74
|
+
"cypress": "15.20.1",
|
|
75
75
|
"cypress-html-validate": "9.0.0",
|
|
76
76
|
"dts-bundle-generator": "9.5.1",
|
|
77
|
-
"esbuild": "0.28.
|
|
77
|
+
"esbuild": "0.28.2",
|
|
78
78
|
"esbuild-sass-plugin": "3.7.0",
|
|
79
|
-
"npm-pkg-lint": "5.
|
|
80
|
-
"sass": "1.
|
|
79
|
+
"npm-pkg-lint": "5.2.2",
|
|
80
|
+
"sass": "1.102.0",
|
|
81
81
|
"typescript": "npm:@typescript/typescript6@6.0.2"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|