@norges-domstoler/dds-components 21.2.0 → 21.2.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.js CHANGED
@@ -3043,7 +3043,7 @@ var getLiteralScreenSize = (screenSize) => {
3043
3043
  // src/components/helpers/StylelessList/StylelessList.tsx
3044
3044
  var import_jsx_runtime176 = require("react/jsx-runtime");
3045
3045
  var StylelessList = ({ className, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime176.jsx)("ul", { ...rest, className: cn(className, utilStyles_default["remove-list-styling"]) });
3046
- var StylelessOList = ({ className, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime176.jsx)("ul", { ...rest, className: cn(className, utilStyles_default["remove-list-styling"]) });
3046
+ var StylelessOList = ({ className, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime176.jsx)("ol", { ...rest, className: cn(className, utilStyles_default["remove-list-styling"]) });
3047
3047
 
3048
3048
  // src/components/helpers/styling/utils.ts
3049
3049
  var outlineOffset = "var(--dds-spacing-x0-125)";
@@ -4970,8 +4970,14 @@ var Label2 = ({
4970
4970
  ...rest
4971
4971
  }) => {
4972
4972
  return /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(
4973
- "label",
4973
+ Box,
4974
4974
  {
4975
+ as: "label",
4976
+ position: "relative",
4977
+ display: "flex",
4978
+ alignItems: "center",
4979
+ width: "fit-content",
4980
+ paddingInline: "calc(18px + var(--dds-spacing-x0-5)) 0",
4975
4981
  className: cn(
4976
4982
  className,
4977
4983
  SelectionControl_default.label,
@@ -4987,6 +4993,35 @@ var Label2 = ({
4987
4993
  }
4988
4994
  );
4989
4995
  };
4996
+ var GroupLabel = ({
4997
+ id,
4998
+ showRequiredMarker,
4999
+ readOnly,
5000
+ children
5001
+ }) => {
5002
+ return /* @__PURE__ */ (0, import_jsx_runtime211.jsxs)(
5003
+ Typography,
5004
+ {
5005
+ as: "span",
5006
+ typographyType: "labelMedium",
5007
+ id,
5008
+ className: readOnly ? Label_default["read-only"] : void 0,
5009
+ children: [
5010
+ readOnly && /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(
5011
+ Icon,
5012
+ {
5013
+ icon: LockIcon,
5014
+ className: Label_default["read-only__icon"],
5015
+ iconSize: "small"
5016
+ }
5017
+ ),
5018
+ children,
5019
+ " ",
5020
+ showRequiredMarker && /* @__PURE__ */ (0, import_jsx_runtime211.jsx)(RequiredMarker, {})
5021
+ ]
5022
+ }
5023
+ );
5024
+ };
4990
5025
 
4991
5026
  // src/components/SelectionControl/SelectionControl.utils.tsx
4992
5027
  var selectionControlSizeNumberPx = 18;
@@ -5023,14 +5058,8 @@ var Checkbox = ({
5023
5058
  const hasError = error || (checkboxGroup == null ? void 0 : checkboxGroup.error);
5024
5059
  const isDisabled = disabled || (checkboxGroup == null ? void 0 : checkboxGroup.disabled);
5025
5060
  return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)(
5026
- Box,
5061
+ Label2,
5027
5062
  {
5028
- position: "relative",
5029
- display: "flex",
5030
- alignItems: "center",
5031
- width: "fit-content",
5032
- paddingInline: "calc(18px + var(--dds-spacing-x0-5)) 0",
5033
- as: Label2,
5034
5063
  hasError,
5035
5064
  disabled: isDisabled,
5036
5065
  readOnly: isReadOnly,
@@ -5086,6 +5115,17 @@ Checkbox.displayName = "Checkbox";
5086
5115
  // src/components/SelectionControl/Checkbox/CheckboxGroup.tsx
5087
5116
  var import_react27 = require("react");
5088
5117
 
5118
+ // src/types/Booleanish.ts
5119
+ function convertBooleanishToBoolean(value) {
5120
+ if (value === "true") {
5121
+ return true;
5122
+ } else if (value === "false") {
5123
+ return false;
5124
+ } else {
5125
+ return value;
5126
+ }
5127
+ }
5128
+
5089
5129
  // src/components/InputMessage/InputMessage.module.css
5090
5130
  var InputMessage_default = {
5091
5131
  container: "InputMessage_container",
@@ -5163,7 +5203,7 @@ var CheckboxGroup = (props) => {
5163
5203
  const generatedId = (0, import_react27.useId)();
5164
5204
  const uniqueGroupId = groupId != null ? groupId : `${generatedId}-checkboxGroup`;
5165
5205
  const hasErrorMessage = !!errorMessage;
5166
- const showRequiredMarker = required || ariaRequired;
5206
+ const showRequiredMarker = required || convertBooleanishToBoolean(ariaRequired);
5167
5207
  const errorMessageId = derivativeIdGenerator(uniqueGroupId, "errorMessage");
5168
5208
  const tipId = derivativeIdGenerator(uniqueGroupId, "tip");
5169
5209
  const contextProps = {
@@ -5184,19 +5224,13 @@ var CheckboxGroup = (props) => {
5184
5224
  rest
5185
5225
  ),
5186
5226
  children: [
5187
- label !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(
5188
- Typography,
5227
+ label !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
5228
+ GroupLabel,
5189
5229
  {
5190
- as: "span",
5191
- typographyType: "labelMedium",
5192
5230
  id: uniqueGroupId,
5193
- className: readOnly ? Label_default["read-only"] : void 0,
5194
- children: [
5195
- readOnly && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(Icon, { icon: LockIcon, className: Label_default["read-only__icon"] }),
5196
- label,
5197
- " ",
5198
- showRequiredMarker && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(RequiredMarker, {})
5199
- ]
5231
+ readOnly,
5232
+ showRequiredMarker,
5233
+ children: label
5200
5234
  }
5201
5235
  ) : null,
5202
5236
  renderInputMessage(tip, tipId),
@@ -5345,9 +5379,9 @@ var DateInput_default = {
5345
5379
  popover: "DateInput_popover",
5346
5380
  "modal-close-button-wrapper": "DateInput_modal-close-button-wrapper",
5347
5381
  calendar: "DateInput_calendar",
5348
- calendar__header: "DateInput_calendar__header",
5349
5382
  calendar__header__month: "DateInput_calendar__header__month",
5350
5383
  "calendar__month-button": "DateInput_calendar__month-button",
5384
+ "calendar__grid-element": "DateInput_calendar__grid-element",
5351
5385
  "calendar__week-number": "DateInput_calendar__week-number",
5352
5386
  "calendar__cell-button": "DateInput_calendar__cell-button",
5353
5387
  "calendar__cell-button--today": "DateInput_calendar__cell-button--today",
@@ -5392,6 +5426,7 @@ function CalendarCell({ date, state, onClose }) {
5392
5426
  hidden: isOutsideVisibleRange,
5393
5427
  onKeyDown: closeOnKeyboardBlurForward,
5394
5428
  className: cn(
5429
+ DateInput_default["calendar__grid-element"],
5395
5430
  DateInput_default["calendar__cell-button"],
5396
5431
  (0, import_date.isToday)(date, timezone) && DateInput_default["calendar__cell-button--today"],
5397
5432
  DateInput_default[`calendar__cell-button--${variant}`],
@@ -5579,6 +5614,11 @@ var CalendarPopoverContent = ({
5579
5614
  }
5580
5615
  };
5581
5616
  if (!isOpen) return null;
5617
+ const paperStyleProps = {
5618
+ elevation: 2,
5619
+ border: "border-default",
5620
+ padding: "x0.75"
5621
+ };
5582
5622
  return /* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(import_jsx_runtime220.Fragment, { children: [
5583
5623
  portalTarget && hasBreakpoint && (0, import_react_dom2.createPortal)(
5584
5624
  /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(ShowHide, { showBelow: smallScreenBreakpoint, children: /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(Backdrop, { zIndex: "modal", isMounted, children: /* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(
@@ -5586,9 +5626,7 @@ var CalendarPopoverContent = ({
5586
5626
  {
5587
5627
  ref: modalRef,
5588
5628
  className: cn(DateInput_default.popover, className),
5589
- elevation: 2,
5590
- border: "border-default",
5591
- padding: "x0.5",
5629
+ ...paperStyleProps,
5592
5630
  children: [
5593
5631
  /* @__PURE__ */ (0, import_jsx_runtime220.jsx)("div", { className: DateInput_default["modal-close-button-wrapper"], children: /* @__PURE__ */ (0, import_jsx_runtime220.jsx)(
5594
5632
  Button,
@@ -5615,8 +5653,7 @@ var CalendarPopoverContent = ({
5615
5653
  hideBelow: hasBreakpoint ? smallScreenBreakpoint : void 0,
5616
5654
  className: cn(DateInput_default.popover, className),
5617
5655
  style: floatingStyles.floating,
5618
- elevation: 2,
5619
- border: "border-default",
5656
+ ...paperStyleProps,
5620
5657
  children
5621
5658
  }
5622
5659
  )
@@ -5651,10 +5688,16 @@ function CalendarGrid({ state, ...props }) {
5651
5688
  cellPadding: "0",
5652
5689
  children: [
5653
5690
  /* @__PURE__ */ (0, import_jsx_runtime221.jsx)("thead", { ...headerProps, children: /* @__PURE__ */ (0, import_jsx_runtime221.jsxs)("tr", { children: [
5654
- showWeekNumbers && /* @__PURE__ */ (0, import_jsx_runtime221.jsxs)("th", { className: cn(...typographyCn), children: [
5655
- "# ",
5656
- /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(VisuallyHidden, { as: "span", children: "Ukenummer" })
5657
- ] }),
5691
+ showWeekNumbers && /* @__PURE__ */ (0, import_jsx_runtime221.jsxs)(
5692
+ "th",
5693
+ {
5694
+ className: cn(DateInput_default["calendar__grid-element"], ...typographyCn),
5695
+ children: [
5696
+ "# ",
5697
+ /* @__PURE__ */ (0, import_jsx_runtime221.jsx)(VisuallyHidden, { as: "span", children: "Ukenummer" })
5698
+ ]
5699
+ }
5700
+ ),
5658
5701
  weekDays.map((day, index) => /* @__PURE__ */ (0, import_jsx_runtime221.jsx)("th", { className: cn(...typographyCn), children: day }, index))
5659
5702
  ] }) }),
5660
5703
  /* @__PURE__ */ (0, import_jsx_runtime221.jsx)("tbody", { children: [...new Array(weeksInMonth).keys()].map((weekIndex) => {
@@ -5666,6 +5709,7 @@ function CalendarGrid({ state, ...props }) {
5666
5709
  "td",
5667
5710
  {
5668
5711
  className: cn(
5712
+ DateInput_default["calendar__grid-element"],
5669
5713
  DateInput_default["calendar__week-number"],
5670
5714
  ...typographyCn
5671
5715
  ),
@@ -5724,7 +5768,7 @@ function Calendar(props) {
5724
5768
  }
5725
5769
  };
5726
5770
  return /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)("div", { ...calendarProps, className: DateInput_default.calendar, children: [
5727
- /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)("div", { className: DateInput_default.calendar__header, children: [
5771
+ /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)(HStack, { justifyContent: "space-between", alignItems: "center", children: [
5728
5772
  /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(
5729
5773
  Button,
5730
5774
  {
@@ -10492,7 +10536,8 @@ var import_react70 = require("react");
10492
10536
  var import_react68 = require("react");
10493
10537
  var ProgressTrackerContext = (0, import_react68.createContext)(
10494
10538
  {
10495
- activeStep: 0
10539
+ activeStep: 0,
10540
+ direction: "column"
10496
10541
  }
10497
10542
  );
10498
10543
  var useProgressTrackerContext = () => (0, import_react68.useContext)(ProgressTrackerContext);
@@ -10500,9 +10545,9 @@ var useProgressTrackerContext = () => (0, import_react68.useContext)(ProgressTra
10500
10545
  // src/components/ProgressTracker/ProgressTracker.module.css
10501
10546
  var ProgressTracker_default = {
10502
10547
  list: "ProgressTracker_list",
10503
- "connector--column": "ProgressTracker_connector--column",
10504
- "connector--row": "ProgressTracker_connector--row",
10505
- item: "ProgressTracker_item",
10548
+ "list-item": "ProgressTracker_list-item",
10549
+ "list-item--column": "ProgressTracker_list-item--column",
10550
+ "list-item--row": "ProgressTracker_list-item--row",
10506
10551
  "item-button": "ProgressTracker_item-button",
10507
10552
  "item-number--active-incomplete": "ProgressTracker_item-number--active-incomplete",
10508
10553
  "item-number--inactive-incomplete": "ProgressTracker_item-number--inactive-incomplete",
@@ -10539,7 +10584,8 @@ var itemStateCn = {
10539
10584
  inactiveCompleted: "inactive-completed",
10540
10585
  inactiveIncomplete: "inactive-incomplete"
10541
10586
  };
10542
- var getVisuallyHiddenText = (active, completed, index) => `${index + 1}, ${active ? "" : "Trinn, "}${completed ? "Ferdig, " : "Ikke ferdig, "}`;
10587
+ var getVisuallyHiddenTextBefore = (index) => `${index + 1}. trinn, `;
10588
+ var getVisuallyHiddenTextAfter = (completed) => `, ${completed ? "ferdig" : "ikke ferdig"}`;
10543
10589
  var ProgressTrackerItem = (props) => {
10544
10590
  const {
10545
10591
  id,
@@ -10553,7 +10599,7 @@ var ProgressTrackerItem = (props) => {
10553
10599
  children,
10554
10600
  ...rest
10555
10601
  } = props;
10556
- const { activeStep, handleStepChange } = useProgressTrackerContext();
10602
+ const { activeStep, handleStepChange, direction } = useProgressTrackerContext();
10557
10603
  const active = activeStep === index;
10558
10604
  const itemState = toItemState(active, completed, disabled);
10559
10605
  const handleClick = () => {
@@ -10573,8 +10619,11 @@ var ProgressTrackerItem = (props) => {
10573
10619
  }, [completed, icon, index]);
10574
10620
  const stepContent = /* @__PURE__ */ (0, import_jsx_runtime283.jsxs)(import_jsx_runtime283.Fragment, { children: [
10575
10621
  /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
10576
- "div",
10622
+ Box,
10577
10623
  {
10624
+ display: "flex",
10625
+ alignItems: "center",
10626
+ justifyContent: "center",
10578
10627
  "aria-hidden": true,
10579
10628
  className: cn(
10580
10629
  ProgressTracker_default["item-number"],
@@ -10593,37 +10642,47 @@ var ProgressTrackerItem = (props) => {
10593
10642
  typographyStyles_default["body-medium"]
10594
10643
  ),
10595
10644
  children: [
10596
- /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(VisuallyHidden, { as: "span", children: getVisuallyHiddenText(active, completed, index) }),
10597
- children
10645
+ /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(VisuallyHidden, { as: "span", children: getVisuallyHiddenTextBefore(index) }),
10646
+ children,
10647
+ /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(VisuallyHidden, { as: "span", children: getVisuallyHiddenTextAfter(completed) })
10598
10648
  ]
10599
10649
  }
10600
10650
  )
10601
10651
  ] });
10602
- return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)("li", { "aria-current": active ? "step" : void 0, className: ProgressTracker_default.item, children: handleStepChange ? /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
10603
- "button",
10604
- {
10605
- ...getBaseHTMLProps(
10606
- id,
10607
- cn(className, ProgressTracker_default["item-button"], focusable),
10608
- htmlProps,
10609
- rest
10610
- ),
10611
- onClick: () => handleClick(),
10612
- disabled,
10613
- children: stepContent
10614
- }
10615
- ) : /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
10616
- "div",
10652
+ return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
10653
+ Box,
10617
10654
  {
10618
- ...getBaseHTMLProps(
10619
- id,
10620
- cn(className, cn(ProgressTracker_default["item-button"], ProgressTracker_default["item-div"])),
10621
- htmlProps,
10622
- rest
10623
- ),
10624
- children: stepContent
10655
+ as: "li",
10656
+ display: direction === "row" ? "flex" : void 0,
10657
+ "aria-current": active ? "step" : void 0,
10658
+ className: cn(ProgressTracker_default["list-item"], ProgressTracker_default[`list-item--${direction}`]),
10659
+ children: handleStepChange ? /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
10660
+ "button",
10661
+ {
10662
+ ...getBaseHTMLProps(
10663
+ id,
10664
+ cn(className, ProgressTracker_default["item-button"], focusable),
10665
+ htmlProps,
10666
+ rest
10667
+ ),
10668
+ onClick: () => handleClick(),
10669
+ disabled,
10670
+ children: stepContent
10671
+ }
10672
+ ) : /* @__PURE__ */ (0, import_jsx_runtime283.jsx)(
10673
+ "div",
10674
+ {
10675
+ ...getBaseHTMLProps(
10676
+ id,
10677
+ cn(className, cn(ProgressTracker_default["item-button"], ProgressTracker_default["item-div"])),
10678
+ htmlProps,
10679
+ rest
10680
+ ),
10681
+ children: stepContent
10682
+ }
10683
+ )
10625
10684
  }
10626
- ) });
10685
+ );
10627
10686
  };
10628
10687
  ProgressTrackerItem.displayName = "ProgressTracker.Item";
10629
10688
 
@@ -10637,7 +10696,7 @@ var ProgressTracker = (() => {
10637
10696
  direction = "column",
10638
10697
  children,
10639
10698
  className,
10640
- htmlProps,
10699
+ htmlProps = {},
10641
10700
  ...rest
10642
10701
  }) => {
10643
10702
  const [thisActiveStep, setActiveStep] = (0, import_react70.useState)(activeStep);
@@ -10653,25 +10712,22 @@ var ProgressTracker = (() => {
10653
10712
  const steps = (0, import_react70.useMemo)(() => {
10654
10713
  const validChildren = removeInvalidChildren(children);
10655
10714
  const itemsWithIndex = passIndexPropToProgressTrackerItem(validChildren);
10656
- const itemsWithConnectorsBetween = intersperseItemsWithConnector(
10657
- itemsWithIndex,
10658
- direction
10659
- );
10660
- return itemsWithConnectorsBetween;
10715
+ return itemsWithIndex;
10661
10716
  }, [children]);
10662
10717
  const isRow = direction === "row";
10718
+ const { "aria-label": ariaLabel } = htmlProps;
10663
10719
  return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
10664
10720
  ProgressTrackerContext,
10665
10721
  {
10666
10722
  value: {
10667
10723
  activeStep: thisActiveStep,
10668
- handleStepChange: handleChange
10724
+ handleStepChange: handleChange,
10725
+ direction
10669
10726
  },
10670
10727
  children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
10671
- "div",
10728
+ "nav",
10672
10729
  {
10673
- role: "group",
10674
- "aria-label": "progress",
10730
+ "aria-label": ariaLabel != null ? ariaLabel : "stegprogresjon",
10675
10731
  ...getBaseHTMLProps(id, className, htmlProps, rest),
10676
10732
  children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
10677
10733
  Box,
@@ -10709,15 +10765,6 @@ function passIndexPropToProgressTrackerItem(children) {
10709
10765
  })
10710
10766
  );
10711
10767
  }
10712
- var intersperseItemsWithConnector = (children, direction) => import_react70.Children.map(children, (child, index) => {
10713
- if (index === 0) {
10714
- return child;
10715
- }
10716
- return /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(import_react70.Fragment, { children: [
10717
- /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("div", { "aria-hidden": true, className: ProgressTracker_default[`connector--${direction}`] }),
10718
- child
10719
- ] }, index);
10720
- });
10721
10768
 
10722
10769
  // src/components/ProgressBar/ProgressBar.tsx
10723
10770
  var import_react71 = require("react");
@@ -11387,7 +11434,7 @@ var RadioButtonGroup = ({
11387
11434
  }
11388
11435
  };
11389
11436
  const hasErrorMessage = !!errorMessage;
11390
- const showRequiredMarker = required || ariaRequired;
11437
+ const showRequiredMarker = required || convertBooleanishToBoolean(ariaRequired);
11391
11438
  const tipId = tip && `${uniqueGroupId}-tip`;
11392
11439
  const errorMessageId = errorMessage && `${uniqueGroupId}-errorMessage`;
11393
11440
  const contextProps = {
@@ -11411,21 +11458,15 @@ var RadioButtonGroup = ({
11411
11458
  rest
11412
11459
  ),
11413
11460
  children: [
11414
- /* @__PURE__ */ (0, import_jsx_runtime291.jsxs)(
11415
- Typography,
11461
+ label !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(
11462
+ GroupLabel,
11416
11463
  {
11417
- as: "span",
11418
- typographyType: "labelMedium",
11419
11464
  id: uniqueGroupId,
11420
- className: readOnly ? Label_default["read-only"] : void 0,
11421
- children: [
11422
- readOnly && /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(Icon, { icon: LockIcon, className: Label_default["read-only__icon"] }),
11423
- label,
11424
- " ",
11425
- showRequiredMarker && /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(RequiredMarker, {})
11426
- ]
11465
+ readOnly,
11466
+ showRequiredMarker,
11467
+ children: label
11427
11468
  }
11428
- ),
11469
+ ) : null,
11429
11470
  renderInputMessage(tip, tipId),
11430
11471
  /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(RadioButtonGroupContext, { value: { ...contextProps }, children: /* @__PURE__ */ (0, import_jsx_runtime291.jsx)(
11431
11472
  "div",
@@ -11550,7 +11591,8 @@ var SplitButton = ({
11550
11591
  className: cn(
11551
11592
  SplitButton_default.option,
11552
11593
  purpose === "primary" && SplitButton_default["option--primary"]
11553
- )
11594
+ ),
11595
+ type: "button"
11554
11596
  }
11555
11597
  ),
11556
11598
  /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(OverflowMenu, { placement: "bottom-end", children: /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(OverflowMenuList, { children: secondaryActions.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(OverflowMenuButton, { ...item, children: item.children }, index)) }) })