@arbeidstilsynet/design-react 0.4.1 → 0.4.2

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/index.cjs CHANGED
@@ -5,6 +5,7 @@ const require$$0 = require("react");
5
5
  const akselIcons = require("@navikt/aksel-icons");
6
6
  const reactDropzone = require("react-dropzone");
7
7
  const designsystemetReact = require("@digdir/designsystemet-react");
8
+ const reactSlot = require("@radix-ui/react-slot");
8
9
  var jsxRuntime = { exports: {} };
9
10
  var reactJsxRuntime_production = {};
10
11
  var hasRequiredReactJsxRuntime_production;
@@ -1080,8 +1081,105 @@ function HeaderDefaultLogo(t0) {
1080
1081
  }
1081
1082
  return t23;
1082
1083
  }
1084
+ const useIsomorphicLayoutEffect = typeof window !== "undefined" ? require$$0.useLayoutEffect : require$$0.useEffect;
1085
+ const IS_SERVER = typeof window === "undefined";
1086
+ function useMediaQuery(query, t0) {
1087
+ const $ = compilerRuntimeExports.c(17);
1088
+ let t1;
1089
+ if ($[0] !== t0) {
1090
+ t1 = {};
1091
+ $[0] = t0;
1092
+ $[1] = t1;
1093
+ } else {
1094
+ t1 = $[1];
1095
+ }
1096
+ const {
1097
+ defaultValue: t2,
1098
+ initializeWithValue: t3
1099
+ } = t1;
1100
+ const defaultValue = t2 === void 0 ? false : t2;
1101
+ const initializeWithValue = t3 === void 0 ? true : t3;
1102
+ let t4;
1103
+ if ($[2] !== defaultValue) {
1104
+ t4 = (query_0) => {
1105
+ if (IS_SERVER) {
1106
+ return defaultValue;
1107
+ }
1108
+ return window.matchMedia(query_0).matches;
1109
+ };
1110
+ $[2] = defaultValue;
1111
+ $[3] = t4;
1112
+ } else {
1113
+ t4 = $[3];
1114
+ }
1115
+ const getMatches = t4;
1116
+ let t5;
1117
+ if ($[4] !== defaultValue || $[5] !== getMatches || $[6] !== initializeWithValue || $[7] !== query) {
1118
+ t5 = () => {
1119
+ if (initializeWithValue) {
1120
+ return getMatches(query);
1121
+ }
1122
+ return defaultValue;
1123
+ };
1124
+ $[4] = defaultValue;
1125
+ $[5] = getMatches;
1126
+ $[6] = initializeWithValue;
1127
+ $[7] = query;
1128
+ $[8] = t5;
1129
+ } else {
1130
+ t5 = $[8];
1131
+ }
1132
+ const [matches, setMatches] = require$$0.useState(t5);
1133
+ let t6;
1134
+ if ($[9] !== getMatches || $[10] !== query) {
1135
+ t6 = function handleChange2() {
1136
+ setMatches(getMatches(query));
1137
+ };
1138
+ $[9] = getMatches;
1139
+ $[10] = query;
1140
+ $[11] = t6;
1141
+ } else {
1142
+ t6 = $[11];
1143
+ }
1144
+ const handleChange = t6;
1145
+ let t7;
1146
+ if ($[12] !== handleChange || $[13] !== query) {
1147
+ t7 = () => {
1148
+ const matchMedia = window.matchMedia(query);
1149
+ handleChange();
1150
+ if (matchMedia.addListener) {
1151
+ matchMedia.addListener(handleChange);
1152
+ } else {
1153
+ matchMedia.addEventListener("change", handleChange);
1154
+ }
1155
+ return () => {
1156
+ if (matchMedia.removeListener) {
1157
+ matchMedia.removeListener(handleChange);
1158
+ } else {
1159
+ matchMedia.removeEventListener("change", handleChange);
1160
+ }
1161
+ };
1162
+ };
1163
+ $[12] = handleChange;
1164
+ $[13] = query;
1165
+ $[14] = t7;
1166
+ } else {
1167
+ t7 = $[14];
1168
+ }
1169
+ let t8;
1170
+ if ($[15] !== query) {
1171
+ t8 = [query];
1172
+ $[15] = query;
1173
+ $[16] = t8;
1174
+ } else {
1175
+ t8 = $[16];
1176
+ }
1177
+ useIsomorphicLayoutEffect(t7, t8);
1178
+ return matches;
1179
+ }
1083
1180
  function HeaderTitleDropdown(t0) {
1084
- const $ = compilerRuntimeExports.c(42);
1181
+ const $ = compilerRuntimeExports.c(44);
1182
+ let children;
1085
1183
  let className;
1086
1184
  let controls;
1087
1185
  let links;
@@ -1093,43 +1191,46 @@ function HeaderTitleDropdown(t0) {
1093
1191
  controls,
1094
1192
  links,
1095
1193
  userName,
1194
+ children,
1096
1195
  ...rest
1097
1196
  } = t0);
1098
1197
  $[0] = t0;
1099
- $[1] = className;
1100
- $[2] = controls;
1101
- $[3] = links;
1102
- $[4] = rest;
1103
- $[5] = userName;
1198
+ $[1] = children;
1199
+ $[2] = className;
1200
+ $[3] = controls;
1201
+ $[4] = links;
1202
+ $[5] = rest;
1203
+ $[6] = userName;
1104
1204
  } else {
1105
- className = $[1];
1106
- controls = $[2];
1107
- links = $[3];
1108
- rest = $[4];
1109
- userName = $[5];
1205
+ children = $[1];
1206
+ className = $[2];
1207
+ controls = $[3];
1208
+ links = $[4];
1209
+ rest = $[5];
1210
+ userName = $[6];
1110
1211
  }
1111
1212
  const [open, setOpen] = require$$0.useState(false);
1112
1213
  const id = require$$0.useId();
1113
- const isMobile = designsystemetReact.useMediaQuery("(max-width: 768px)");
1214
+ const isMobile = useMediaQuery("(max-width: 768px)");
1114
1215
  let t1;
1115
- if ($[6] !== className) {
1216
+ if ($[7] !== className) {
1116
1217
  t1 = clsx(className);
1117
- $[6] = className;
1118
- $[7] = t1;
1218
+ $[7] = className;
1219
+ $[8] = t1;
1119
1220
  } else {
1120
- t1 = $[7];
1221
+ t1 = $[8];
1121
1222
  }
1122
1223
  let t2;
1123
- if ($[8] !== open) {
1224
+ if ($[9] !== open) {
1124
1225
  t2 = () => setOpen(!open);
1125
- $[8] = open;
1126
- $[9] = t2;
1226
+ $[9] = open;
1227
+ $[10] = t2;
1127
1228
  } else {
1128
- t2 = $[9];
1229
+ t2 = $[10];
1129
1230
  }
1130
1231
  const t3 = isMobile ? "primary" : "tertiary";
1131
1232
  let t4;
1132
- if ($[10] !== isMobile || $[11] !== open || $[12] !== userName) {
1233
+ if ($[11] !== isMobile || $[12] !== open || $[13] !== userName) {
1133
1234
  t4 = isMobile ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1134
1235
  open ? /* @__PURE__ */ jsxRuntimeExports.jsx(akselIcons.XMarkIcon, { "aria-hidden": true }) : /* @__PURE__ */ jsxRuntimeExports.jsx(akselIcons.MenuHamburgerIcon, { "aria-hidden": true }),
1135
1236
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "at-header__title-dropdown-text", children: "Meny" })
@@ -1137,130 +1238,135 @@ function HeaderTitleDropdown(t0) {
1137
1238
  userName,
1138
1239
  open ? /* @__PURE__ */ jsxRuntimeExports.jsx(akselIcons.ChevronUpIcon, { "aria-hidden": true }) : /* @__PURE__ */ jsxRuntimeExports.jsx(akselIcons.ChevronDownIcon, { "aria-hidden": true })
1139
1240
  ] });
1140
- $[10] = isMobile;
1141
- $[11] = open;
1142
- $[12] = userName;
1143
- $[13] = t4;
1241
+ $[11] = isMobile;
1242
+ $[12] = open;
1243
+ $[13] = userName;
1244
+ $[14] = t4;
1144
1245
  } else {
1145
- t4 = $[13];
1246
+ t4 = $[14];
1146
1247
  }
1147
1248
  let t5;
1148
- if ($[14] !== t2 || $[15] !== t3 || $[16] !== t4) {
1249
+ if ($[15] !== t2 || $[16] !== t3 || $[17] !== t4) {
1149
1250
  t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Dropdown.Trigger, { onClick: t2, "data-size": "sm", variant: t3, className: "at-header__title-dropdown-trigger", children: t4 });
1150
- $[14] = t2;
1151
- $[15] = t3;
1152
- $[16] = t4;
1153
- $[17] = t5;
1251
+ $[15] = t2;
1252
+ $[16] = t3;
1253
+ $[17] = t4;
1254
+ $[18] = t5;
1154
1255
  } else {
1155
- t5 = $[17];
1256
+ t5 = $[18];
1156
1257
  }
1157
1258
  let t6;
1158
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
1259
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
1159
1260
  t6 = () => setOpen(false);
1160
- $[18] = t6;
1261
+ $[19] = t6;
1161
1262
  } else {
1162
- t6 = $[18];
1263
+ t6 = $[19];
1163
1264
  }
1164
1265
  let t7;
1165
- if ($[19] !== links) {
1166
- t7 = links?.map(_temp$1);
1167
- $[19] = links;
1168
- $[20] = t7;
1266
+ if ($[20] !== children || $[21] !== links) {
1267
+ t7 = children ? require$$0.Children.map(children, _temp$1) : links?.map(_temp2$1);
1268
+ $[20] = children;
1269
+ $[21] = links;
1270
+ $[22] = t7;
1169
1271
  } else {
1170
- t7 = $[20];
1272
+ t7 = $[22];
1171
1273
  }
1172
1274
  let t8;
1173
- if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
1275
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
1174
1276
  t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Dropdown.Item, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx("at-header__title-dropdown-item-mobile at-header__title-dropdown-controls"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Divider, {}) }) });
1175
- $[21] = t8;
1277
+ $[23] = t8;
1176
1278
  } else {
1177
- t8 = $[21];
1279
+ t8 = $[23];
1178
1280
  }
1179
1281
  let t9;
1180
- if ($[22] !== controls || $[23] !== id) {
1181
- t9 = controls?.map((control, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Dropdown.Item, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "at-header__title-dropdown-controls", children: control }) }, id + "-control-" + index));
1182
- $[22] = controls;
1183
- $[23] = id;
1184
- $[24] = t9;
1282
+ if ($[24] !== controls || $[25] !== id) {
1283
+ t9 = controls?.map((control, index_0) => /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Dropdown.Item, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "at-header__title-dropdown-controls", children: control }) }, id + "-control-" + index_0));
1284
+ $[24] = controls;
1285
+ $[25] = id;
1286
+ $[26] = t9;
1185
1287
  } else {
1186
- t9 = $[24];
1288
+ t9 = $[26];
1187
1289
  }
1188
1290
  let t10;
1189
- if ($[25] !== t7 || $[26] !== t9) {
1291
+ if ($[27] !== t7 || $[28] !== t9) {
1190
1292
  t10 = /* @__PURE__ */ jsxRuntimeExports.jsxs(designsystemetReact.Dropdown.List, { children: [
1191
1293
  t7,
1192
1294
  t8,
1193
1295
  t9
1194
1296
  ] });
1195
- $[25] = t7;
1196
- $[26] = t9;
1197
- $[27] = t10;
1297
+ $[27] = t7;
1298
+ $[28] = t9;
1299
+ $[29] = t10;
1198
1300
  } else {
1199
- t10 = $[27];
1301
+ t10 = $[29];
1200
1302
  }
1201
1303
  let t11;
1202
- if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
1304
+ if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
1203
1305
  t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Dropdown.Item, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "at-header__title-dropdown-close-mobile", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(designsystemetReact.Button, { type: "button", variant: "secondary", onClick: () => setOpen(false), children: [
1204
1306
  /* @__PURE__ */ jsxRuntimeExports.jsx(akselIcons.XMarkIcon, { "aria-hidden": true }),
1205
1307
  "Lukk"
1206
1308
  ] }) }) });
1207
- $[28] = t11;
1309
+ $[30] = t11;
1208
1310
  } else {
1209
- t11 = $[28];
1311
+ t11 = $[30];
1210
1312
  }
1211
1313
  let t12;
1212
- if ($[29] !== open || $[30] !== t10) {
1314
+ if ($[31] !== open || $[32] !== t10) {
1213
1315
  t12 = /* @__PURE__ */ jsxRuntimeExports.jsxs(designsystemetReact.Dropdown, { open, onClose: t6, placement: "bottom", className: "at-header__title-dropdown-content", children: [
1214
1316
  t10,
1215
1317
  t11
1216
1318
  ] });
1217
- $[29] = open;
1218
- $[30] = t10;
1219
- $[31] = t12;
1319
+ $[31] = open;
1320
+ $[32] = t10;
1321
+ $[33] = t12;
1220
1322
  } else {
1221
- t12 = $[31];
1323
+ t12 = $[33];
1222
1324
  }
1223
1325
  let t13;
1224
- if ($[32] !== t12 || $[33] !== t5) {
1326
+ if ($[34] !== t12 || $[35] !== t5) {
1225
1327
  t13 = /* @__PURE__ */ jsxRuntimeExports.jsxs(designsystemetReact.Dropdown.TriggerContext, { children: [
1226
1328
  t5,
1227
1329
  t12
1228
1330
  ] });
1229
- $[32] = t12;
1230
- $[33] = t5;
1231
- $[34] = t13;
1331
+ $[34] = t12;
1332
+ $[35] = t5;
1333
+ $[36] = t13;
1232
1334
  } else {
1233
- t13 = $[34];
1335
+ t13 = $[36];
1234
1336
  }
1235
1337
  let t14;
1236
- if ($[35] !== open) {
1338
+ if ($[37] !== open) {
1237
1339
  t14 = open ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "at-header__title-dropdown-backdrop" }) : null;
1238
- $[35] = open;
1239
- $[36] = t14;
1340
+ $[37] = open;
1341
+ $[38] = t14;
1240
1342
  } else {
1241
- t14 = $[36];
1343
+ t14 = $[38];
1242
1344
  }
1243
1345
  let t15;
1244
- if ($[37] !== rest || $[38] !== t1 || $[39] !== t13 || $[40] !== t14) {
1346
+ if ($[39] !== rest || $[40] !== t1 || $[41] !== t13 || $[42] !== t14) {
1245
1347
  t15 = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: t1, ...rest, children: [
1246
1348
  t13,
1247
1349
  t14
1248
1350
  ] });
1249
- $[37] = rest;
1250
- $[38] = t1;
1251
- $[39] = t13;
1252
- $[40] = t14;
1253
- $[41] = t15;
1351
+ $[39] = rest;
1352
+ $[40] = t1;
1353
+ $[41] = t13;
1354
+ $[42] = t14;
1355
+ $[43] = t15;
1254
1356
  } else {
1255
- t15 = $[41];
1357
+ t15 = $[43];
1256
1358
  }
1257
1359
  return t15;
1258
1360
  }
1259
- function _temp$1(link) {
1361
+ function _temp2$1(link) {
1260
1362
  return /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Dropdown.Item, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx("at-header__title-dropdown-controls", "at-header__title-dropdown-item-mobile"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Link, { href: link.href, className: clsx("at-header__title-link"), children: link.label }) }) }, "nav-" + link.href);
1261
1363
  }
1364
+ function _temp$1(child, index) {
1365
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Dropdown.Item, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx("at-header__title-dropdown-controls", "at-header__title-dropdown-item-mobile"), children: require$$0.isValidElement(child) ? /* @__PURE__ */ jsxRuntimeExports.jsx(reactSlot.Slot, { className: clsx("at-header__title-link", "ds-link"), children: child }) : child }) }, "nav-" + index);
1366
+ }
1262
1367
  function HeaderTitleLinks(t0) {
1263
- const $ = compilerRuntimeExports.c(12);
1368
+ const $ = compilerRuntimeExports.c(14);
1369
+ let children;
1264
1370
  let className;
1265
1371
  let links;
1266
1372
  let rest;
@@ -1268,48 +1374,58 @@ function HeaderTitleLinks(t0) {
1268
1374
  ({
1269
1375
  className,
1270
1376
  links,
1377
+ children,
1271
1378
  ...rest
1272
1379
  } = t0);
1273
1380
  $[0] = t0;
1274
- $[1] = className;
1275
- $[2] = links;
1276
- $[3] = rest;
1381
+ $[1] = children;
1382
+ $[2] = className;
1383
+ $[3] = links;
1384
+ $[4] = rest;
1277
1385
  } else {
1278
- className = $[1];
1279
- links = $[2];
1280
- rest = $[3];
1386
+ children = $[1];
1387
+ className = $[2];
1388
+ links = $[3];
1389
+ rest = $[4];
1281
1390
  }
1282
1391
  let t1;
1283
- if ($[4] !== className) {
1392
+ if ($[5] !== className) {
1284
1393
  t1 = clsx(className);
1285
- $[4] = className;
1286
- $[5] = t1;
1394
+ $[5] = className;
1395
+ $[6] = t1;
1287
1396
  } else {
1288
- t1 = $[5];
1397
+ t1 = $[6];
1289
1398
  }
1290
1399
  let t2;
1291
- if ($[6] !== links) {
1292
- t2 = links?.map(_temp);
1293
- $[6] = links;
1294
- $[7] = t2;
1400
+ if ($[7] !== children || $[8] !== links) {
1401
+ t2 = children ? require$$0.Children.map(children, _temp) : links?.map(_temp2);
1402
+ $[7] = children;
1403
+ $[8] = links;
1404
+ $[9] = t2;
1295
1405
  } else {
1296
- t2 = $[7];
1406
+ t2 = $[9];
1297
1407
  }
1298
1408
  let t3;
1299
- if ($[8] !== rest || $[9] !== t1 || $[10] !== t2) {
1409
+ if ($[10] !== rest || $[11] !== t1 || $[12] !== t2) {
1300
1410
  t3 = /* @__PURE__ */ jsxRuntimeExports.jsx("nav", { className: t1, ...rest, children: t2 });
1301
- $[8] = rest;
1302
- $[9] = t1;
1303
- $[10] = t2;
1304
- $[11] = t3;
1411
+ $[10] = rest;
1412
+ $[11] = t1;
1413
+ $[12] = t2;
1414
+ $[13] = t3;
1305
1415
  } else {
1306
- t3 = $[11];
1416
+ t3 = $[13];
1307
1417
  }
1308
1418
  return t3;
1309
1419
  }
1310
- function _temp(link) {
1420
+ function _temp2(link) {
1311
1421
  return /* @__PURE__ */ jsxRuntimeExports.jsx(designsystemetReact.Link, { href: link.href, className: clsx("at-header__title-link"), children: link.label }, link.href);
1312
1422
  }
1423
+ function _temp(child) {
1424
+ if (require$$0.isValidElement(child)) {
1425
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(reactSlot.Slot, { className: clsx("at-header__title-link", "ds-link"), children: child });
1426
+ }
1427
+ return child;
1428
+ }
1313
1429
  function HeaderTitleLogo(t0) {
1314
1430
  const $ = compilerRuntimeExports.c(17);
1315
1431
  let appName;
@@ -1388,12 +1504,13 @@ function HeaderTitle({
1388
1504
  userName,
1389
1505
  links = [],
1390
1506
  controls = [],
1507
+ children,
1391
1508
  ...rest
1392
1509
  }) {
1393
1510
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx("at-header__title-background", className), ...rest, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: clsx("at-header__title"), children: [
1394
1511
  /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderTitleLogo, { className: clsx("at-header__title-left"), logo, appName }),
1395
- /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderTitleLinks, { className: clsx("at-header__title-center"), links }),
1396
- /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderTitleDropdown, { className: clsx("at-header__title-right"), links, userName, controls })
1512
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderTitleLinks, { className: clsx("at-header__title-center"), links, children }),
1513
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderTitleDropdown, { className: clsx("at-header__title-right"), links, userName, controls, children })
1397
1514
  ] }) });
1398
1515
  }
1399
1516
  const Header = Object.assign(Header$1, {