@forsakringskassan/devindex-menu 2.0.3 → 2.1.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.
- package/README.md +12 -0
- package/dist/cjs/menu.js +53 -6
- package/dist/cjs/pageobjects.js +3 -0
- package/dist/esm/menu.js +53 -6
- package/dist/esm/pageobjects.js +3 -0
- package/dist/types/{index.d.ts → menu.d.ts} +10 -2
- package/dist/types/pageobjects.d.ts +1 -0
- package/package.json +14 -9
package/README.md
CHANGED
|
@@ -107,6 +107,18 @@ Inside the application, the mock is then sent directly to `devindexMenu`.
|
|
|
107
107
|
|
|
108
108
|
```json
|
|
109
109
|
{ title: String, href: String },
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Scenario
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
{
|
|
116
|
+
type: "scenario";
|
|
117
|
+
key: string;
|
|
118
|
+
title: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
cookies: Record<string, string | undefined>;
|
|
121
|
+
},
|
|
110
122
|
|
|
111
123
|
```
|
|
112
124
|
|
package/dist/cjs/menu.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/menu.ts
|
|
21
21
|
var menu_exports = {};
|
|
22
22
|
__export(menu_exports, {
|
|
23
|
+
ONE_MONTH_IN_SECONDS: () => ONE_MONTH_IN_SECONDS,
|
|
23
24
|
default: () => menu_default
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(menu_exports);
|
|
@@ -619,6 +620,9 @@ function setCookie(options) {
|
|
|
619
620
|
const cookieString = `${name}=${encodeURIComponent(value)}; path=/; max-age=${String(timeout)};`;
|
|
620
621
|
document.cookie = cookieString;
|
|
621
622
|
}
|
|
623
|
+
function deleteCookie(name) {
|
|
624
|
+
document.cookie = `${name}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
|
|
625
|
+
}
|
|
622
626
|
function findCookie(name) {
|
|
623
627
|
if (!document?.cookie) {
|
|
624
628
|
return void 0;
|
|
@@ -1111,8 +1115,47 @@ if (typeof document !== "undefined") {
|
|
|
1111
1115
|
createScreenReaderWrapper({ assertive: false });
|
|
1112
1116
|
}
|
|
1113
1117
|
|
|
1114
|
-
// src/settings/
|
|
1118
|
+
// src/settings/scenario.ts
|
|
1115
1119
|
var template = `
|
|
1120
|
+
<template id="devindex-scenario">
|
|
1121
|
+
<span><!-- title --></span>
|
|
1122
|
+
<p><!-- description --></p>
|
|
1123
|
+
<button type="button">Activate scenario</button>
|
|
1124
|
+
</template>
|
|
1125
|
+
`;
|
|
1126
|
+
function createElement(setting) {
|
|
1127
|
+
const template3 = document.querySelector("#devindex-scenario");
|
|
1128
|
+
const clone = document.importNode(template3.content, true);
|
|
1129
|
+
const title = clone.querySelector("span");
|
|
1130
|
+
const description = clone.querySelector("p");
|
|
1131
|
+
const button = clone.querySelector("button");
|
|
1132
|
+
title.textContent = setting.title;
|
|
1133
|
+
if (setting.description) {
|
|
1134
|
+
description.textContent = setting.description;
|
|
1135
|
+
} else {
|
|
1136
|
+
description.remove();
|
|
1137
|
+
}
|
|
1138
|
+
button.id = setting.key;
|
|
1139
|
+
button.addEventListener("click", () => {
|
|
1140
|
+
for (const [key, value] of Object.entries(setting.cookies)) {
|
|
1141
|
+
if (value === void 0) {
|
|
1142
|
+
deleteCookie(key);
|
|
1143
|
+
} else {
|
|
1144
|
+
setCookie({
|
|
1145
|
+
name: key,
|
|
1146
|
+
value,
|
|
1147
|
+
timeLimitSeconds: ONE_MONTH_IN_SECONDS
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
location.reload();
|
|
1152
|
+
});
|
|
1153
|
+
return clone;
|
|
1154
|
+
}
|
|
1155
|
+
var scenario_default = { createElement, template };
|
|
1156
|
+
|
|
1157
|
+
// src/settings/text.ts
|
|
1158
|
+
var template2 = `
|
|
1116
1159
|
<template id="devindex-text">
|
|
1117
1160
|
<span><!-- title --></span>
|
|
1118
1161
|
<p><!-- description --></p>
|
|
@@ -1120,10 +1163,9 @@ var template = `
|
|
|
1120
1163
|
<input type="text"></input>
|
|
1121
1164
|
</template>
|
|
1122
1165
|
`;
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
const
|
|
1126
|
-
const clone = document.importNode(template2.content, true);
|
|
1166
|
+
function createElement2(setting) {
|
|
1167
|
+
const template3 = document.querySelector("#devindex-text");
|
|
1168
|
+
const clone = document.importNode(template3.content, true);
|
|
1127
1169
|
const title = clone.querySelector("span");
|
|
1128
1170
|
const description = clone.querySelector("p");
|
|
1129
1171
|
const input = clone.querySelector("input");
|
|
@@ -1144,7 +1186,7 @@ function createElement(setting) {
|
|
|
1144
1186
|
}
|
|
1145
1187
|
return clone;
|
|
1146
1188
|
}
|
|
1147
|
-
var text_default = { createElement, template };
|
|
1189
|
+
var text_default = { createElement: createElement2, template: template2 };
|
|
1148
1190
|
|
|
1149
1191
|
// src/style.scss
|
|
1150
1192
|
var style_default = `.secret-menu {
|
|
@@ -1232,6 +1274,7 @@ var style_default = `.secret-menu {
|
|
|
1232
1274
|
}`;
|
|
1233
1275
|
|
|
1234
1276
|
// src/menu.ts
|
|
1277
|
+
var ONE_MONTH_IN_SECONDS = 2592e3;
|
|
1235
1278
|
var settingsNodes = [];
|
|
1236
1279
|
function evaluateMock(mock) {
|
|
1237
1280
|
if (typeof mock === "function") {
|
|
@@ -1271,6 +1314,9 @@ function generateOptionMarkup(setting) {
|
|
|
1271
1314
|
return generateOptionMarkupForLink(setting);
|
|
1272
1315
|
case "text":
|
|
1273
1316
|
settingsNodes.push(text_default.createElement(setting));
|
|
1317
|
+
break;
|
|
1318
|
+
case "scenario":
|
|
1319
|
+
settingsNodes.push(scenario_default.createElement(setting));
|
|
1274
1320
|
}
|
|
1275
1321
|
return "";
|
|
1276
1322
|
}
|
|
@@ -1319,6 +1365,7 @@ var menu_default = (userSettingsAndMocks) => {
|
|
|
1319
1365
|
"beforeend",
|
|
1320
1366
|
`
|
|
1321
1367
|
${text_default.template}
|
|
1368
|
+
${scenario_default.template}
|
|
1322
1369
|
`
|
|
1323
1370
|
);
|
|
1324
1371
|
let settingsMarkup = "";
|
package/dist/cjs/pageobjects.js
CHANGED
package/dist/esm/menu.js
CHANGED
|
@@ -593,6 +593,9 @@ function setCookie(options) {
|
|
|
593
593
|
const cookieString = `${name}=${encodeURIComponent(value)}; path=/; max-age=${String(timeout)};`;
|
|
594
594
|
document.cookie = cookieString;
|
|
595
595
|
}
|
|
596
|
+
function deleteCookie(name) {
|
|
597
|
+
document.cookie = `${name}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
|
|
598
|
+
}
|
|
596
599
|
function findCookie(name) {
|
|
597
600
|
if (!document?.cookie) {
|
|
598
601
|
return void 0;
|
|
@@ -1085,8 +1088,47 @@ if (typeof document !== "undefined") {
|
|
|
1085
1088
|
createScreenReaderWrapper({ assertive: false });
|
|
1086
1089
|
}
|
|
1087
1090
|
|
|
1088
|
-
// src/settings/
|
|
1091
|
+
// src/settings/scenario.ts
|
|
1089
1092
|
var template = `
|
|
1093
|
+
<template id="devindex-scenario">
|
|
1094
|
+
<span><!-- title --></span>
|
|
1095
|
+
<p><!-- description --></p>
|
|
1096
|
+
<button type="button">Activate scenario</button>
|
|
1097
|
+
</template>
|
|
1098
|
+
`;
|
|
1099
|
+
function createElement(setting) {
|
|
1100
|
+
const template3 = document.querySelector("#devindex-scenario");
|
|
1101
|
+
const clone = document.importNode(template3.content, true);
|
|
1102
|
+
const title = clone.querySelector("span");
|
|
1103
|
+
const description = clone.querySelector("p");
|
|
1104
|
+
const button = clone.querySelector("button");
|
|
1105
|
+
title.textContent = setting.title;
|
|
1106
|
+
if (setting.description) {
|
|
1107
|
+
description.textContent = setting.description;
|
|
1108
|
+
} else {
|
|
1109
|
+
description.remove();
|
|
1110
|
+
}
|
|
1111
|
+
button.id = setting.key;
|
|
1112
|
+
button.addEventListener("click", () => {
|
|
1113
|
+
for (const [key, value] of Object.entries(setting.cookies)) {
|
|
1114
|
+
if (value === void 0) {
|
|
1115
|
+
deleteCookie(key);
|
|
1116
|
+
} else {
|
|
1117
|
+
setCookie({
|
|
1118
|
+
name: key,
|
|
1119
|
+
value,
|
|
1120
|
+
timeLimitSeconds: ONE_MONTH_IN_SECONDS
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
location.reload();
|
|
1125
|
+
});
|
|
1126
|
+
return clone;
|
|
1127
|
+
}
|
|
1128
|
+
var scenario_default = { createElement, template };
|
|
1129
|
+
|
|
1130
|
+
// src/settings/text.ts
|
|
1131
|
+
var template2 = `
|
|
1090
1132
|
<template id="devindex-text">
|
|
1091
1133
|
<span><!-- title --></span>
|
|
1092
1134
|
<p><!-- description --></p>
|
|
@@ -1094,10 +1136,9 @@ var template = `
|
|
|
1094
1136
|
<input type="text"></input>
|
|
1095
1137
|
</template>
|
|
1096
1138
|
`;
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
const
|
|
1100
|
-
const clone = document.importNode(template2.content, true);
|
|
1139
|
+
function createElement2(setting) {
|
|
1140
|
+
const template3 = document.querySelector("#devindex-text");
|
|
1141
|
+
const clone = document.importNode(template3.content, true);
|
|
1101
1142
|
const title = clone.querySelector("span");
|
|
1102
1143
|
const description = clone.querySelector("p");
|
|
1103
1144
|
const input = clone.querySelector("input");
|
|
@@ -1118,7 +1159,7 @@ function createElement(setting) {
|
|
|
1118
1159
|
}
|
|
1119
1160
|
return clone;
|
|
1120
1161
|
}
|
|
1121
|
-
var text_default = { createElement, template };
|
|
1162
|
+
var text_default = { createElement: createElement2, template: template2 };
|
|
1122
1163
|
|
|
1123
1164
|
// src/style.scss
|
|
1124
1165
|
var style_default = `.secret-menu {
|
|
@@ -1206,6 +1247,7 @@ var style_default = `.secret-menu {
|
|
|
1206
1247
|
}`;
|
|
1207
1248
|
|
|
1208
1249
|
// src/menu.ts
|
|
1250
|
+
var ONE_MONTH_IN_SECONDS = 2592e3;
|
|
1209
1251
|
var settingsNodes = [];
|
|
1210
1252
|
function evaluateMock(mock) {
|
|
1211
1253
|
if (typeof mock === "function") {
|
|
@@ -1245,6 +1287,9 @@ function generateOptionMarkup(setting) {
|
|
|
1245
1287
|
return generateOptionMarkupForLink(setting);
|
|
1246
1288
|
case "text":
|
|
1247
1289
|
settingsNodes.push(text_default.createElement(setting));
|
|
1290
|
+
break;
|
|
1291
|
+
case "scenario":
|
|
1292
|
+
settingsNodes.push(scenario_default.createElement(setting));
|
|
1248
1293
|
}
|
|
1249
1294
|
return "";
|
|
1250
1295
|
}
|
|
@@ -1293,6 +1338,7 @@ var menu_default = (userSettingsAndMocks) => {
|
|
|
1293
1338
|
"beforeend",
|
|
1294
1339
|
`
|
|
1295
1340
|
${text_default.template}
|
|
1341
|
+
${scenario_default.template}
|
|
1296
1342
|
`
|
|
1297
1343
|
);
|
|
1298
1344
|
let settingsMarkup = "";
|
|
@@ -1328,5 +1374,6 @@ var menu_default = (userSettingsAndMocks) => {
|
|
|
1328
1374
|
document.body.appendChild(script);
|
|
1329
1375
|
};
|
|
1330
1376
|
export {
|
|
1377
|
+
ONE_MONTH_IN_SECONDS,
|
|
1331
1378
|
menu_default as default
|
|
1332
1379
|
};
|
package/dist/esm/pageobjects.js
CHANGED
|
@@ -7,7 +7,7 @@ export interface SelectOption {
|
|
|
7
7
|
value: unknown;
|
|
8
8
|
}
|
|
9
9
|
export interface SelectSettings {
|
|
10
|
-
type
|
|
10
|
+
type?: "select";
|
|
11
11
|
key: string;
|
|
12
12
|
title: string;
|
|
13
13
|
reloadOnChange?: boolean;
|
|
@@ -33,7 +33,15 @@ export interface TextSettings {
|
|
|
33
33
|
description?: string;
|
|
34
34
|
options: LinkOption[];
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export interface ScenarioSetting {
|
|
37
|
+
type: "scenario";
|
|
38
|
+
key: string;
|
|
39
|
+
title: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
cookies: Record<string, string | undefined>;
|
|
42
|
+
}
|
|
43
|
+
export type Settings = SelectSettings | LinkSettings | TextSettings | ScenarioSetting;
|
|
44
|
+
export declare const ONE_MONTH_IN_SECONDS = 2592000;
|
|
37
45
|
/**
|
|
38
46
|
* @param userSettingsAndMocks - An array of user settings and/or mocks to generate the menu from.
|
|
39
47
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forsakringskassan/devindex-menu",
|
|
3
|
-
"version": "2.0
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "Menu for local development",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"development",
|
|
7
|
+
"menu"
|
|
8
|
+
],
|
|
5
9
|
"homepage": "https://github.com/Forsakringskassan/devindex-menu",
|
|
6
10
|
"bugs": "https://github.com/Forsakringskassan/devindex-menu/issues",
|
|
7
11
|
"repository": {
|
|
@@ -24,7 +28,7 @@
|
|
|
24
28
|
},
|
|
25
29
|
"main": "dist/cjs/menu.js",
|
|
26
30
|
"module": "dist/esm/menu.js",
|
|
27
|
-
"types": "
|
|
31
|
+
"types": "dist/types/menu.d.ts",
|
|
28
32
|
"files": [
|
|
29
33
|
"dist"
|
|
30
34
|
],
|
|
@@ -32,7 +36,7 @@
|
|
|
32
36
|
"prebuild": "tsc",
|
|
33
37
|
"build": "node ./scripts/generate.mjs",
|
|
34
38
|
"postbuild": "npm run types:main && npm run types:pageobject",
|
|
35
|
-
"types:main": "dts-bundle-generator -o dist/types/
|
|
39
|
+
"types:main": "dts-bundle-generator -o dist/types/menu.d.ts temp/types/menu.d.ts",
|
|
36
40
|
"types:pageobject": "dts-bundle-generator -o dist/types/pageobjects.d.ts temp/types/pageobjects.d.ts",
|
|
37
41
|
"eslint": "eslint --cache .",
|
|
38
42
|
"prettier:check": "prettier --check .",
|
|
@@ -52,20 +56,21 @@
|
|
|
52
56
|
"@babel/preset-env": "7.28.6",
|
|
53
57
|
"@fkui/tsconfig": "6.33.0",
|
|
54
58
|
"@forsakringskassan/apimock-express": "2.12.0",
|
|
55
|
-
"@forsakringskassan/commitlint-config": "3.3.
|
|
59
|
+
"@forsakringskassan/commitlint-config": "3.3.3",
|
|
56
60
|
"@forsakringskassan/eslint-config": "13.2.10",
|
|
57
61
|
"@forsakringskassan/eslint-config-cli": "13.2.0",
|
|
58
62
|
"@forsakringskassan/eslint-config-cypress": "13.2.10",
|
|
59
63
|
"@forsakringskassan/eslint-config-jest": "13.2.9",
|
|
60
|
-
"@forsakringskassan/eslint-config-typescript": "13.2.
|
|
61
|
-
"@forsakringskassan/eslint-config-typescript-typeinfo": "13.2.
|
|
64
|
+
"@forsakringskassan/eslint-config-typescript": "13.2.11",
|
|
65
|
+
"@forsakringskassan/eslint-config-typescript-typeinfo": "13.2.11",
|
|
62
66
|
"@forsakringskassan/prettier-config": "3.3.2",
|
|
63
67
|
"@tsconfig/node22": "22.0.5",
|
|
64
|
-
"@types/node": "22.19.
|
|
65
|
-
"cypress": "15.
|
|
68
|
+
"@types/node": "22.19.7",
|
|
69
|
+
"cypress": "15.9.0",
|
|
66
70
|
"dts-bundle-generator": "9.5.1",
|
|
67
71
|
"esbuild": "0.27.2",
|
|
68
72
|
"esbuild-sass-plugin": "3.6.0",
|
|
73
|
+
"npm-pkg-lint": "4.3.2",
|
|
69
74
|
"sass": "1.97.2",
|
|
70
75
|
"typescript": "5.9.3"
|
|
71
76
|
},
|