@forsakringskassan/devindex-menu 2.1.2 → 2.1.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/cjs/menu.js CHANGED
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
19
21
 
20
22
  // src/menu.ts
21
23
  var menu_exports = {};
@@ -1093,6 +1095,38 @@ var formatter = {
1093
1095
  [DateFormat.YYYYMMDD]: "YYYYMMDD"
1094
1096
  }
1095
1097
  };
1098
+ var ElementIdServiceImpl = class {
1099
+ constructor() {
1100
+ __publicField(this, "elementIdMap", /* @__PURE__ */ new Map());
1101
+ }
1102
+ generateElementId(prefix = "fkui") {
1103
+ const id = this.nextId(prefix);
1104
+ if (document.getElementById(id) === null) {
1105
+ return id;
1106
+ }
1107
+ return this.generateElementId(prefix);
1108
+ }
1109
+ nextId(prefix) {
1110
+ let elementIdWithPadding = String(this.getIdFromMap(prefix));
1111
+ while (elementIdWithPadding.length < 4) {
1112
+ elementIdWithPadding = `0${elementIdWithPadding}`;
1113
+ }
1114
+ return `${prefix}-vue-element-${elementIdWithPadding}`;
1115
+ }
1116
+ getIdFromMap(prefix) {
1117
+ const elementId = this.elementIdMap.get(prefix);
1118
+ if (!elementId) {
1119
+ this.elementIdMap.set(prefix, { count: 1 });
1120
+ return 1;
1121
+ }
1122
+ elementId.count++;
1123
+ return elementId.count;
1124
+ }
1125
+ reset() {
1126
+ this.elementIdMap = /* @__PURE__ */ new Map();
1127
+ }
1128
+ };
1129
+ var ElementIdService = /* @__PURE__ */ new ElementIdServiceImpl();
1096
1130
  var wrapper;
1097
1131
  function createScreenReaderWrapper(options) {
1098
1132
  if (!getWrapper()) {
@@ -1120,7 +1154,7 @@ var template = `
1120
1154
  <template id="devindex-scenario">
1121
1155
  <span><!-- title --></span>
1122
1156
  <p><!-- description --></p>
1123
- <button type="button">Activate scenario</button>
1157
+ <button type="button" tabindex="-1">Activate scenario</button>
1124
1158
  </template>
1125
1159
  `;
1126
1160
  function createElement(setting) {
@@ -1157,20 +1191,22 @@ var scenario_default = { createElement, template };
1157
1191
  // src/settings/text.ts
1158
1192
  var template2 = `
1159
1193
  <template id="devindex-text">
1160
- <span><!-- title --></span>
1161
- <p><!-- description --></p>
1194
+ <label for="devindex-text-input">dummy-label</label>
1195
+ <span><!-- description --></span>
1162
1196
  <br />
1163
- <input type="text"></input>
1197
+ <input type="text" id="devindex-text-input" tabindex="-1"></input>
1164
1198
  </template>
1165
1199
  `;
1166
1200
  function createElement2(setting) {
1167
1201
  const template3 = document.querySelector("#devindex-text");
1168
1202
  const clone = document.importNode(template3.content, true);
1169
- const title = clone.querySelector("span");
1170
- const description = clone.querySelector("p");
1203
+ const label = clone.querySelector("label");
1204
+ const description = clone.querySelector("span");
1171
1205
  const input = clone.querySelector("input");
1206
+ const id = ElementIdService.generateElementId();
1172
1207
  input.name = setting.key;
1173
1208
  input.value = findCookie(input.name) ?? "";
1209
+ input.id = id;
1174
1210
  input.addEventListener("input", () => {
1175
1211
  setCookie({
1176
1212
  name: input.name,
@@ -1178,7 +1214,8 @@ function createElement2(setting) {
1178
1214
  timeLimitSeconds: ONE_MONTH_IN_SECONDS
1179
1215
  });
1180
1216
  });
1181
- title.textContent = setting.title;
1217
+ label.textContent = setting.title;
1218
+ label.setAttribute("for", id);
1182
1219
  if (setting.description) {
1183
1220
  description.textContent = setting.description;
1184
1221
  } else {
@@ -1301,7 +1338,7 @@ function generateOptionMarkupForLink(setting) {
1301
1338
  const description = setting.description ? `<p>${setting.description}</p>` : "";
1302
1339
  let markup = `${setting.title} ${description}<ul>`;
1303
1340
  setting.options.forEach((option) => {
1304
- markup += `<li><a href="${option.href}">${option.title}</a></li>`;
1341
+ markup += `<li><a href="${option.href}" tabindex="-1">${option.title}</a></li>`;
1305
1342
  });
1306
1343
  markup = `${markup}</ul>`;
1307
1344
  return markup;
@@ -1379,7 +1416,7 @@ var menu_default = (userSettingsAndMocks) => {
1379
1416
  "beforeend",
1380
1417
  `
1381
1418
  <div class="secret-menu" aria-hidden="true">
1382
- <button type="button" class="toggle" onclick="toggleMenu()">
1419
+ <button type="button" class="toggle" tabindex="-1" onclick="toggleMenu()">
1383
1420
  <span></span>
1384
1421
  <span></span>
1385
1422
  <span></span>
package/dist/esm/menu.js CHANGED
@@ -1,3 +1,7 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
1
5
  // raw-loader:./client.js?raw
2
6
  var client_default = '/**\n * @param {string} cookieName\n * @param {string} cookieValue\n * @param {number} exdays\n * @returns {void}\n */\nfunction setCookie(cookieName, cookieValue, exdays) {\n var d = new Date();\n d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);\n var expires = "expires=".concat(d.toUTCString());\n document.cookie = "".concat(cookieName, "=").concat(cookieValue, ";").concat(expires, ";path=/");\n}\n\n/**\n * @param {string} cookieName\n * @returns {string | undefined}\n */\nfunction getCookie(cookieName) {\n var name = "".concat(cookieName, "=");\n var decodedCookie = decodeURIComponent(document.cookie);\n var ca = decodedCookie.split(";");\n for (var i = 0; i < ca.length; i++) {\n var c = ca[i];\n while (c.charAt(0) === " ") {\n c = c.substring(1);\n }\n if (c.indexOf(name) === 0) {\n return c.substring(name.length, c.length);\n }\n }\n return undefined;\n}\n(function () {\n /** @type {NodeListOf<HTMLSelectElement>} */\n var selections = document.querySelectorAll(".secret-menu select");\n for (var i = 0; i < selections.length; i++) {\n var select = selections[i];\n select.value = getCookie(select.name) ? getCookie(select.name) : "default";\n if (select.getAttribute("data-sessionStorage") === "true") {\n var cookieValue = getCookie(select.name);\n if (cookieValue) {\n sessionStorage.setItem(select.name, atob(cookieValue));\n }\n }\n select.onchange = function (event) {\n var element = event.target;\n setCookie(element.name, element.value, 30);\n if (element.getAttribute("data-exec-on-change")) {\n window[element.getAttribute("data-exec-on-change")]();\n }\n if (element.getAttribute("data-reload") === "true") {\n location.reload(true);\n }\n if (element.getAttribute("data-sessionStorage") === "true") {\n var sessionKey = element.id;\n if (element.value) {\n var value = atob(element.value);\n console.log("Laddar sessionstorage ".concat(sessionKey, " med \\n ").concat(value));\n sessionStorage.setItem(sessionKey, value);\n } else {\n console.log("T\\xF6mmer sessionstorage");\n sessionStorage.removeItem(sessionKey);\n }\n location.reload(true);\n }\n };\n }\n\n /* Forcerar att sidan laddas om, \xE4ven n\xE4r l\xE4nken \xE4r av typen: /#/granska/8 */\n /** @type {NodeListOf<HTMLAnchorElement>} */\n var links = document.querySelectorAll(".secret-menu ul li a");\n for (var _i = 0; _i < links.length; _i++) {\n var link = links[_i];\n if (link.getAttribute("href").startsWith("/#")) {\n /**\n * @param {MouseEvent} event\n */\n link.onclick = function (event) {\n event.preventDefault();\n window.location.href = event.target.getAttribute("href");\n setTimeout(function () {\n console.log("Reload after click on hash-link.");\n location.reload();\n }, "500");\n };\n }\n }\n})();\nfunction toggleMenu() {\n var menu = document.querySelector(".secret-menu");\n menu.classList.toggle("open");\n}\nwindow.toggleMenu = toggleMenu;';
3
7
 
@@ -1066,6 +1070,38 @@ var formatter = {
1066
1070
  [DateFormat.YYYYMMDD]: "YYYYMMDD"
1067
1071
  }
1068
1072
  };
1073
+ var ElementIdServiceImpl = class {
1074
+ constructor() {
1075
+ __publicField(this, "elementIdMap", /* @__PURE__ */ new Map());
1076
+ }
1077
+ generateElementId(prefix = "fkui") {
1078
+ const id = this.nextId(prefix);
1079
+ if (document.getElementById(id) === null) {
1080
+ return id;
1081
+ }
1082
+ return this.generateElementId(prefix);
1083
+ }
1084
+ nextId(prefix) {
1085
+ let elementIdWithPadding = String(this.getIdFromMap(prefix));
1086
+ while (elementIdWithPadding.length < 4) {
1087
+ elementIdWithPadding = `0${elementIdWithPadding}`;
1088
+ }
1089
+ return `${prefix}-vue-element-${elementIdWithPadding}`;
1090
+ }
1091
+ getIdFromMap(prefix) {
1092
+ const elementId = this.elementIdMap.get(prefix);
1093
+ if (!elementId) {
1094
+ this.elementIdMap.set(prefix, { count: 1 });
1095
+ return 1;
1096
+ }
1097
+ elementId.count++;
1098
+ return elementId.count;
1099
+ }
1100
+ reset() {
1101
+ this.elementIdMap = /* @__PURE__ */ new Map();
1102
+ }
1103
+ };
1104
+ var ElementIdService = /* @__PURE__ */ new ElementIdServiceImpl();
1069
1105
  var wrapper;
1070
1106
  function createScreenReaderWrapper(options) {
1071
1107
  if (!getWrapper()) {
@@ -1093,7 +1129,7 @@ var template = `
1093
1129
  <template id="devindex-scenario">
1094
1130
  <span><!-- title --></span>
1095
1131
  <p><!-- description --></p>
1096
- <button type="button">Activate scenario</button>
1132
+ <button type="button" tabindex="-1">Activate scenario</button>
1097
1133
  </template>
1098
1134
  `;
1099
1135
  function createElement(setting) {
@@ -1130,20 +1166,22 @@ var scenario_default = { createElement, template };
1130
1166
  // src/settings/text.ts
1131
1167
  var template2 = `
1132
1168
  <template id="devindex-text">
1133
- <span><!-- title --></span>
1134
- <p><!-- description --></p>
1169
+ <label for="devindex-text-input">dummy-label</label>
1170
+ <span><!-- description --></span>
1135
1171
  <br />
1136
- <input type="text"></input>
1172
+ <input type="text" id="devindex-text-input" tabindex="-1"></input>
1137
1173
  </template>
1138
1174
  `;
1139
1175
  function createElement2(setting) {
1140
1176
  const template3 = document.querySelector("#devindex-text");
1141
1177
  const clone = document.importNode(template3.content, true);
1142
- const title = clone.querySelector("span");
1143
- const description = clone.querySelector("p");
1178
+ const label = clone.querySelector("label");
1179
+ const description = clone.querySelector("span");
1144
1180
  const input = clone.querySelector("input");
1181
+ const id = ElementIdService.generateElementId();
1145
1182
  input.name = setting.key;
1146
1183
  input.value = findCookie(input.name) ?? "";
1184
+ input.id = id;
1147
1185
  input.addEventListener("input", () => {
1148
1186
  setCookie({
1149
1187
  name: input.name,
@@ -1151,7 +1189,8 @@ function createElement2(setting) {
1151
1189
  timeLimitSeconds: ONE_MONTH_IN_SECONDS
1152
1190
  });
1153
1191
  });
1154
- title.textContent = setting.title;
1192
+ label.textContent = setting.title;
1193
+ label.setAttribute("for", id);
1155
1194
  if (setting.description) {
1156
1195
  description.textContent = setting.description;
1157
1196
  } else {
@@ -1274,7 +1313,7 @@ function generateOptionMarkupForLink(setting) {
1274
1313
  const description = setting.description ? `<p>${setting.description}</p>` : "";
1275
1314
  let markup = `${setting.title} ${description}<ul>`;
1276
1315
  setting.options.forEach((option) => {
1277
- markup += `<li><a href="${option.href}">${option.title}</a></li>`;
1316
+ markup += `<li><a href="${option.href}" tabindex="-1">${option.title}</a></li>`;
1278
1317
  });
1279
1318
  markup = `${markup}</ul>`;
1280
1319
  return markup;
@@ -1352,7 +1391,7 @@ var menu_default = (userSettingsAndMocks) => {
1352
1391
  "beforeend",
1353
1392
  `
1354
1393
  <div class="secret-menu" aria-hidden="true">
1355
- <button type="button" class="toggle" onclick="toggleMenu()">
1394
+ <button type="button" class="toggle" tabindex="-1" onclick="toggleMenu()">
1356
1395
  <span></span>
1357
1396
  <span></span>
1358
1397
  <span></span>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/devindex-menu",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "Menu for local development",
5
5
  "keywords": [
6
6
  "development",
@@ -54,21 +54,22 @@
54
54
  "devDependencies": {
55
55
  "@babel/core": "7.29.0",
56
56
  "@babel/preset-env": "7.29.0",
57
- "@fkui/tsconfig": "6.35.0",
57
+ "@fkui/tsconfig": "6.36.0",
58
58
  "@forsakringskassan/apimock-express": "2.13.0",
59
59
  "@forsakringskassan/commitlint-config": "3.3.3",
60
- "@forsakringskassan/eslint-config": "13.3.1",
61
- "@forsakringskassan/eslint-config-cli": "13.3.1",
60
+ "@forsakringskassan/eslint-config": "13.3.2",
61
+ "@forsakringskassan/eslint-config-cli": "13.3.2",
62
62
  "@forsakringskassan/eslint-config-cypress": "13.3.0",
63
- "@forsakringskassan/eslint-config-jest": "13.3.0",
63
+ "@forsakringskassan/eslint-config-jest": "13.3.3",
64
64
  "@forsakringskassan/eslint-config-typescript": "13.3.0",
65
65
  "@forsakringskassan/eslint-config-typescript-typeinfo": "13.3.0",
66
66
  "@forsakringskassan/prettier-config": "3.3.4",
67
67
  "@tsconfig/node22": "22.0.5",
68
- "@types/node": "22.19.7",
69
- "cypress": "15.9.0",
68
+ "@types/node": "22.19.10",
69
+ "cypress": "15.10.0",
70
+ "cypress-html-validate": "8.1.0",
70
71
  "dts-bundle-generator": "9.5.1",
71
- "esbuild": "0.27.2",
72
+ "esbuild": "0.27.3",
72
73
  "esbuild-sass-plugin": "3.6.0",
73
74
  "npm-pkg-lint": "4.3.4",
74
75
  "sass": "1.97.3",
@@ -78,6 +79,6 @@
78
79
  "node": ">= 22.0.0"
79
80
  },
80
81
  "dependencies": {
81
- "@fkui/logic": "6.35.0"
82
+ "@fkui/logic": "6.36.0"
82
83
  }
83
84
  }