@norges-domstoler/dds-components 0.0.0-dev-20250702125907 → 0.0.0-dev-20250715084850

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.d.mts CHANGED
@@ -173,9 +173,7 @@ interface PrimitiveDisplayProps {
173
173
  /** Viser komponenten kun under det angitte brekkpunktet. */
174
174
  showBelow?: Breakpoint;
175
175
  }
176
- type BreakpointBasedProp<T> = {
177
- [k in Breakpoint]?: T;
178
- };
176
+ type BreakpointBasedProp<T> = Partial<Record<Breakpoint, T>>;
179
177
  type ResponsiveProp<T> = T | BreakpointBasedProp<T>;
180
178
  interface PrimitiveLayoutProps {
181
179
  /** CSS `width`. Støtter verdi per brekkpunkt eller samme for alle skjermstørrelser. */
@@ -4035,9 +4033,11 @@ type TooltipProps = BaseComponentProps<HTMLDivElement, {
4035
4033
  delay?: number;
4036
4034
  /**`id` for tooltip. */
4037
4035
  tooltipId?: string;
4036
+ /**Om tooltip skal alltid være i DOM, eller bli rendret først når den skal vises. */
4037
+ keepMounted?: boolean;
4038
4038
  } & PickedHTMLAttributes, Omit<HTMLAttributes<HTMLDivElement>, 'children' | keyof PickedHTMLAttributes>>;
4039
4039
  declare const Tooltip: {
4040
- ({ text, placement, children, tooltipId, delay, style, onMouseLeave, onMouseOver, id, ref, className, htmlProps, ...rest }: TooltipProps): react_jsx_runtime.JSX.Element;
4040
+ ({ text, placement, children, tooltipId, delay, style, onMouseLeave, onMouseOver, keepMounted, id, ref, className, htmlProps, ...rest }: TooltipProps): react_jsx_runtime.JSX.Element;
4041
4041
  displayName: string;
4042
4042
  };
4043
4043
 
package/dist/index.d.ts CHANGED
@@ -173,9 +173,7 @@ interface PrimitiveDisplayProps {
173
173
  /** Viser komponenten kun under det angitte brekkpunktet. */
174
174
  showBelow?: Breakpoint;
175
175
  }
176
- type BreakpointBasedProp<T> = {
177
- [k in Breakpoint]?: T;
178
- };
176
+ type BreakpointBasedProp<T> = Partial<Record<Breakpoint, T>>;
179
177
  type ResponsiveProp<T> = T | BreakpointBasedProp<T>;
180
178
  interface PrimitiveLayoutProps {
181
179
  /** CSS `width`. Støtter verdi per brekkpunkt eller samme for alle skjermstørrelser. */
@@ -4035,9 +4033,11 @@ type TooltipProps = BaseComponentProps<HTMLDivElement, {
4035
4033
  delay?: number;
4036
4034
  /**`id` for tooltip. */
4037
4035
  tooltipId?: string;
4036
+ /**Om tooltip skal alltid være i DOM, eller bli rendret først når den skal vises. */
4037
+ keepMounted?: boolean;
4038
4038
  } & PickedHTMLAttributes, Omit<HTMLAttributes<HTMLDivElement>, 'children' | keyof PickedHTMLAttributes>>;
4039
4039
  declare const Tooltip: {
4040
- ({ text, placement, children, tooltipId, delay, style, onMouseLeave, onMouseOver, id, ref, className, htmlProps, ...rest }: TooltipProps): react_jsx_runtime.JSX.Element;
4040
+ ({ text, placement, children, tooltipId, delay, style, onMouseLeave, onMouseOver, keepMounted, id, ref, className, htmlProps, ...rest }: TooltipProps): react_jsx_runtime.JSX.Element;
4041
4041
  displayName: string;
4042
4042
  };
4043
4043
 
package/dist/index.js CHANGED
@@ -608,8 +608,8 @@ var getTextColor = (color) => {
608
608
  // src/utils/combineHandlers.tsx
609
609
  var combineHandlers = (handler1, handler2) => {
610
610
  const callback = (event) => {
611
- handler1 && handler1(event);
612
- handler2 && handler2(event);
611
+ handler1 == null ? void 0 : handler1(event);
612
+ handler2 == null ? void 0 : handler2(event);
613
613
  };
614
614
  return callback;
615
615
  };
@@ -657,7 +657,7 @@ var readOnlyMouseDownHandler = (readOnly, onMouseDown) => {
657
657
  if (readOnly) {
658
658
  evt.preventDefault();
659
659
  evt.target.focus();
660
- } else onMouseDown && onMouseDown(evt);
660
+ } else onMouseDown == null ? void 0 : onMouseDown(evt);
661
661
  };
662
662
  };
663
663
  var readOnlyKeyDownHandler = (type, readOnly, onKeyDown) => {
@@ -670,7 +670,7 @@ var readOnlyKeyDownHandler = (type, readOnly, onKeyDown) => {
670
670
  } else if (type === "selectionControl" && evt.key === " ") {
671
671
  evt.preventDefault();
672
672
  }
673
- } else onKeyDown && onKeyDown(evt);
673
+ } else onKeyDown == null ? void 0 : onKeyDown(evt);
674
674
  };
675
675
  };
676
676
  var readOnlyChangeHandler = (readOnly, onChange) => {
@@ -678,7 +678,7 @@ var readOnlyChangeHandler = (readOnly, onChange) => {
678
678
  if (readOnly) {
679
679
  return;
680
680
  }
681
- onChange && onChange(evt);
681
+ onChange == null ? void 0 : onChange(evt);
682
682
  };
683
683
  };
684
684
  var readOnlyClickHandler = (readOnly, onClick) => {
@@ -687,7 +687,7 @@ var readOnlyClickHandler = (readOnly, onClick) => {
687
687
  evt.preventDefault();
688
688
  return;
689
689
  }
690
- onClick && onClick(evt);
690
+ onClick == null ? void 0 : onClick(evt);
691
691
  };
692
692
  };
693
693
 
@@ -4691,13 +4691,13 @@ var OverflowMenuGroup = ({
4691
4691
  const combinedMenuRef = useCombinedRef(menuRef, floatingRef);
4692
4692
  const handleClose = () => {
4693
4693
  if (isOpen) {
4694
- onClose && onClose();
4694
+ onClose == null ? void 0 : onClose();
4695
4695
  close();
4696
4696
  }
4697
4697
  };
4698
4698
  const handleToggle = () => {
4699
- !isOpen && (onOpen == null ? void 0 : onOpen());
4700
- isOpen && (onClose == null ? void 0 : onClose());
4699
+ if (!isOpen) onOpen == null ? void 0 : onOpen();
4700
+ if (isOpen) onClose == null ? void 0 : onClose();
4701
4701
  toggle();
4702
4702
  };
4703
4703
  useOnClickOutside([menuRef.current, buttonRef.current], () => {
@@ -4706,7 +4706,7 @@ var OverflowMenuGroup = ({
4706
4706
  useOnKeyDown(["Esc", "Escape"], () => {
4707
4707
  var _a;
4708
4708
  if (isOpen) {
4709
- onClose && onClose();
4709
+ onClose == null ? void 0 : onClose();
4710
4710
  close();
4711
4711
  (_a = buttonRef.current) == null ? void 0 : _a.focus();
4712
4712
  }
@@ -5487,7 +5487,7 @@ var RadioButton = ({
5487
5487
  const radioButtonGroup = useRadioButtonGroup();
5488
5488
  const handleChange = (event) => {
5489
5489
  var _a;
5490
- onChange && onChange(event);
5490
+ onChange == null ? void 0 : onChange(event);
5491
5491
  (_a = radioButtonGroup == null ? void 0 : radioButtonGroup.onChange) == null ? void 0 : _a.call(radioButtonGroup, event, event.target.value);
5492
5492
  };
5493
5493
  const describedByIds = [];
@@ -5863,7 +5863,7 @@ var Chip = ({
5863
5863
  const [isOpen, setIsOpen] = (0, import_react35.useState)(true);
5864
5864
  const onClick = () => {
5865
5865
  setIsOpen(false);
5866
- onClose && onClose();
5866
+ onClose == null ? void 0 : onClose();
5867
5867
  };
5868
5868
  return isOpen ? /* @__PURE__ */ (0, import_jsx_runtime221.jsxs)(
5869
5869
  "div",
@@ -7775,6 +7775,7 @@ var Tooltip = ({
7775
7775
  style,
7776
7776
  onMouseLeave,
7777
7777
  onMouseOver,
7778
+ keepMounted = true,
7778
7779
  id,
7779
7780
  ref,
7780
7781
  className,
@@ -7784,7 +7785,7 @@ var Tooltip = ({
7784
7785
  const generatedId = (0, import_react56.useId)();
7785
7786
  const uniqueTooltipId = tooltipId != null ? tooltipId : `${generatedId}-tooltip`;
7786
7787
  const [open, setOpen] = (0, import_react56.useState)(false);
7787
- const [inView, setInView] = (0, import_react56.useState)(false);
7788
+ const [inView, setInView] = (0, import_react56.useState)(keepMounted ? false : true);
7788
7789
  const [arrowElement, setArrowElement] = (0, import_react56.useState)(null);
7789
7790
  const { refs, styles: positionStyles } = useFloatPosition(arrowElement, {
7790
7791
  placement
@@ -7793,19 +7794,23 @@ var Tooltip = ({
7793
7794
  const combinedRef = useCombinedRef(ref, refs.setFloating, tooltipRef);
7794
7795
  const closeWhenNotInView = (entries) => {
7795
7796
  const [entry] = entries;
7796
- entry.isIntersecting ? setInView(true) : setInView(false);
7797
+ if (entry.isIntersecting) {
7798
+ setInView(true);
7799
+ } else setInView(false);
7797
7800
  };
7798
7801
  (0, import_react56.useEffect)(() => {
7799
- const options = {
7800
- root: null,
7801
- rootMargin: "0px"
7802
- };
7803
- const ref2 = tooltipRef.current;
7804
- const observer = new IntersectionObserver(closeWhenNotInView, options);
7805
- if (ref2) observer.observe(ref2);
7806
- return () => {
7807
- if (ref2) observer.unobserve(ref2);
7808
- };
7802
+ if (keepMounted) {
7803
+ const options = {
7804
+ root: null,
7805
+ rootMargin: "0px"
7806
+ };
7807
+ const ref2 = tooltipRef.current;
7808
+ const observer = new IntersectionObserver(closeWhenNotInView, options);
7809
+ if (ref2) observer.observe(ref2);
7810
+ return () => {
7811
+ if (ref2) observer.unobserve(ref2);
7812
+ };
7813
+ }
7809
7814
  }, [tooltipRef]);
7810
7815
  (0, import_react56.useEffect)(() => {
7811
7816
  if (tooltipRef.current) {
@@ -7838,15 +7843,19 @@ var Tooltip = ({
7838
7843
  timer = setTimeout(() => setOpen(true), delay);
7839
7844
  }
7840
7845
  };
7846
+ const hasTransitionedIn = useMountTransition(open, 500);
7847
+ const isMounted = hasTransitionedIn && open;
7848
+ const isTransientlyMounted = !keepMounted && isMounted;
7841
7849
  const anchorElement = import_react56.Children.only(
7842
7850
  (0, import_react56.cloneElement)(children, {
7843
7851
  ref: refs.setReference,
7844
7852
  onFocus: combineHandlers(openTooltip, children.props.onFocus),
7845
7853
  onBlur: combineHandlers(closeTooltip, children.props.onBlur),
7846
- "aria-describedby": uniqueTooltipId
7854
+ "aria-describedby": isTransientlyMounted || keepMounted ? uniqueTooltipId : void 0
7847
7855
  })
7848
7856
  );
7849
- const openCn = open && inView ? "open" : "closed";
7857
+ const openCn = keepMounted && open && inView || isTransientlyMounted ? "open" : "closed";
7858
+ const ariaHidden = keepMounted ? !open : void 0;
7850
7859
  return /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)(
7851
7860
  "div",
7852
7861
  {
@@ -7861,13 +7870,13 @@ var Tooltip = ({
7861
7870
  onMouseOver: combineHandlers(openTooltip, onMouseOver),
7862
7871
  children: [
7863
7872
  anchorElement,
7864
- /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)(
7873
+ !keepMounted && (open || hasTransitionedIn) || keepMounted ? /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)(
7865
7874
  Paper,
7866
7875
  {
7867
7876
  id: uniqueTooltipId,
7868
7877
  ref: combinedRef,
7869
7878
  role: "tooltip",
7870
- "aria-hidden": !open,
7879
+ "aria-hidden": ariaHidden,
7871
7880
  style: { ...positionStyles.floating },
7872
7881
  elevation: 1,
7873
7882
  border: "border-subtle",
@@ -7899,7 +7908,7 @@ var Tooltip = ({
7899
7908
  ] }) })
7900
7909
  ]
7901
7910
  }
7902
- )
7911
+ ) : null
7903
7912
  ]
7904
7913
  }
7905
7914
  );
@@ -7987,26 +7996,26 @@ var Feedback = ({
7987
7996
  const tThumbUpTooltip = thumbUpTooltip != null ? thumbUpTooltip : t(texts11.good);
7988
7997
  const tThumbDownTooltip = thumbDownTooltip != null ? thumbDownTooltip : t(texts11.bad);
7989
7998
  (0, import_react57.useEffect)(() => {
7990
- ratingProp !== void 0 && setRating(ratingProp);
7999
+ if (ratingProp !== void 0) setRating(ratingProp);
7991
8000
  }, [ratingProp]);
7992
8001
  (0, import_react57.useEffect)(() => {
7993
- feedbackTextProp !== void 0 && setFeedbackText(feedbackTextProp);
8002
+ if (feedbackTextProp !== void 0) setFeedbackText(feedbackTextProp);
7994
8003
  }, [feedbackTextProp]);
7995
8004
  (0, import_react57.useEffect)(() => {
7996
- isSubmittedProp !== void 0 && setIsFeedbackSubmitted(isSubmittedProp);
8005
+ if (isSubmittedProp !== void 0) setIsFeedbackSubmitted(isSubmittedProp);
7997
8006
  }, [isSubmittedProp]);
7998
8007
  const handleRatingChange = (newRating) => {
7999
- onRating && onRating(newRating);
8000
- onSubmit && feedbackTextAreaExcluded && onSubmit(newRating, "");
8001
- ratingProp === void 0 && setRating(newRating);
8008
+ onRating == null ? void 0 : onRating(newRating);
8009
+ if (onSubmit && feedbackTextAreaExcluded) onSubmit(newRating, "");
8010
+ if (ratingProp === void 0) setRating(newRating);
8002
8011
  };
8003
8012
  const handleFeedbackTextChange = (newFeedbackText) => {
8004
- onFeedbackTextChange && onFeedbackTextChange(newFeedbackText);
8005
- feedbackTextProp === void 0 && setFeedbackText(newFeedbackText);
8013
+ onFeedbackTextChange == null ? void 0 : onFeedbackTextChange(newFeedbackText);
8014
+ if (feedbackTextProp === void 0) setFeedbackText(newFeedbackText);
8006
8015
  };
8007
8016
  const handleSubmit = () => {
8008
- onSubmit && onSubmit(rating, feedbackText != null ? feedbackText : "");
8009
- isSubmittedProp === void 0 && setIsFeedbackSubmitted(true);
8017
+ onSubmit == null ? void 0 : onSubmit(rating, feedbackText != null ? feedbackText : "");
8018
+ if (isSubmittedProp === void 0) setIsFeedbackSubmitted(true);
8010
8019
  };
8011
8020
  if (rating === null && !isFeedbackSubmitted) {
8012
8021
  return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)(
@@ -8466,11 +8475,9 @@ var useFileUploader = (props) => {
8466
8475
  () => ({
8467
8476
  onBlur: onRootBlur,
8468
8477
  onFocus: onRootFocus,
8469
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
8470
8478
  onDragEnter: onRootDragEnter,
8471
8479
  onDragOver: onRootDragOver,
8472
8480
  onDragLeave: onRootDragLeave,
8473
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
8474
8481
  onDrop: setFiles,
8475
8482
  ref: rootRef
8476
8483
  }),
@@ -8497,7 +8504,6 @@ var useFileUploader = (props) => {
8497
8504
  style: { display: "none" },
8498
8505
  tabIndex: -1,
8499
8506
  ref: inputRef,
8500
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
8501
8507
  onChange: setFiles,
8502
8508
  multiple: !maxFiles || maxFiles > 1,
8503
8509
  ...accept ? { accept: accept.join(",") } : {}
@@ -8806,7 +8812,7 @@ var GlobalMessage = ({
8806
8812
  purpose: "tertiary",
8807
8813
  onClick: () => {
8808
8814
  setClosed(true);
8809
- onClose && onClose();
8815
+ onClose == null ? void 0 : onClose();
8810
8816
  },
8811
8817
  size: "small",
8812
8818
  "aria-label": t(commonTexts.closeMessage)
@@ -9511,7 +9517,7 @@ var LocalMessage = ({
9511
9517
  purpose: "tertiary",
9512
9518
  onClick: () => {
9513
9519
  setClosed(true);
9514
- onClose && onClose();
9520
+ onClose == null ? void 0 : onClose();
9515
9521
  },
9516
9522
  size: "xsmall",
9517
9523
  "aria-label": t(commonTexts.closeMessage),
@@ -10388,7 +10394,7 @@ var Pagination = ({
10388
10394
  const pagesLength = Math.ceil(itemsAmount / itemsPerPage);
10389
10395
  const items = PaginationGenerator(pagesLength, activePage);
10390
10396
  const onPageChange = (event, page) => {
10391
- page && setActivePage(page);
10397
+ if (page) setActivePage(page);
10392
10398
  if (event && onChange) {
10393
10399
  onChange(event, page);
10394
10400
  }
@@ -11433,7 +11439,7 @@ var Popover = ({
11433
11439
  );
11434
11440
  const multiRef = useCombinedRef(ref, popoverRef, floatingRef);
11435
11441
  (0, import_react75.useEffect)(() => {
11436
- setFloatOptions && setFloatOptions({ placement, offset });
11442
+ setFloatOptions == null ? void 0 : setFloatOptions({ placement, offset });
11437
11443
  }, [placement, offset]);
11438
11444
  useOnClickOutside([popoverRef.current, anchorEl], () => {
11439
11445
  if (isOpen && !hasContext) onClose == null ? void 0 : onClose();
@@ -11522,11 +11528,11 @@ var PopoverGroup = ({
11522
11528
  const { refs, styles: positionStyles } = useFloatPosition(null, floatOptions);
11523
11529
  const handleClose = () => {
11524
11530
  setOpen(false);
11525
- onClose && onClose();
11531
+ onClose == null ? void 0 : onClose();
11526
11532
  };
11527
11533
  const handleOpen = () => {
11528
11534
  setOpen(true);
11529
- onOpen && onOpen();
11535
+ onOpen == null ? void 0 : onOpen();
11530
11536
  };
11531
11537
  const handleToggle = () => {
11532
11538
  if (open) {
@@ -11655,8 +11661,8 @@ var ProgressTrackerItem = (props) => {
11655
11661
  const itemState = toItemState(active, completed, disabled);
11656
11662
  const handleClick = () => {
11657
11663
  if (!disabled) {
11658
- onClick && onClick(index);
11659
- handleStepChange && handleStepChange(index);
11664
+ onClick == null ? void 0 : onClick(index);
11665
+ handleStepChange == null ? void 0 : handleStepChange(index);
11660
11666
  }
11661
11667
  };
11662
11668
  const stepNumberContent = (0, import_react78.useMemo)(() => {
@@ -11774,7 +11780,7 @@ var ProgressTracker = (() => {
11774
11780
  const [thisActiveStep, setActiveStep] = (0, import_react79.useState)(activeStep);
11775
11781
  const handleChange = (step) => {
11776
11782
  setActiveStep(step);
11777
- onStepChange && onStepChange(step);
11783
+ onStepChange == null ? void 0 : onStepChange(step);
11778
11784
  };
11779
11785
  (0, import_react79.useEffect)(() => {
11780
11786
  if (activeStep !== void 0 && activeStep != thisActiveStep) {
@@ -12136,9 +12142,10 @@ var Search = ({
12136
12142
  const context = useAutocompleteSearch();
12137
12143
  const combinedRef = context.inputRef ? useCombinedRef(context.inputRef, ref) : ref;
12138
12144
  const handleChange = (e) => {
12145
+ var _a2;
12139
12146
  setHasValue(e.target.value !== "");
12140
- context.onValueChange && context.onValueChange(e);
12141
- onChange && onChange(e);
12147
+ (_a2 = context == null ? void 0 : context.onValueChange) == null ? void 0 : _a2.call(context, e);
12148
+ onChange == null ? void 0 : onChange(e);
12142
12149
  };
12143
12150
  const clearInput = () => {
12144
12151
  const clearChangeEvent = createClearChangeEvent(uniqueId);
@@ -12325,12 +12332,12 @@ var SearchAutocompleteWrapper = (props) => {
12325
12332
  } else {
12326
12333
  setSuggestions([]);
12327
12334
  }
12328
- onChange && onChange(e);
12335
+ onChange == null ? void 0 : onChange(e);
12329
12336
  };
12330
12337
  const handleSuggestionClick = (e) => {
12331
12338
  setSuggestions([]);
12332
12339
  handleSetInputValue(e.target.innerText);
12333
- onSuggestionSelection && onSuggestionSelection();
12340
+ onSuggestionSelection == null ? void 0 : onSuggestionSelection();
12334
12341
  closeSuggestions();
12335
12342
  };
12336
12343
  const handleSetInputValue = (value2) => {
@@ -12752,7 +12759,7 @@ var CollapsibleRow = ({
12752
12759
  const { isCollapsed, headerValues, definingColumnIndex } = useCollapsibleTableContext();
12753
12760
  const [childrenCollapsed, setChildrenCollapsed] = (0, import_react89.useState)(true);
12754
12761
  (0, import_react89.useEffect)(() => {
12755
- !isCollapsed && setChildrenCollapsed(true);
12762
+ if (!isCollapsed) setChildrenCollapsed(true);
12756
12763
  }, [isCollapsed]);
12757
12764
  const rowProps = (isOpenCollapsibleHeader) => {
12758
12765
  return {
@@ -13006,7 +13013,7 @@ var Tabs = ({
13006
13013
  const tabPanelsRef = (0, import_react93.useRef)(null);
13007
13014
  const handleTabChange = (index) => {
13008
13015
  setActiveTab(index);
13009
- onChange && onChange(index);
13016
+ onChange == null ? void 0 : onChange(index);
13010
13017
  };
13011
13018
  (0, import_react93.useEffect)(() => {
13012
13019
  if (activeTab !== void 0 && activeTab !== thisActiveTab) {
@@ -13167,7 +13174,7 @@ var TabList = ({
13167
13174
  const [widths, setWidths] = (0, import_react95.useState)([]);
13168
13175
  const handleOnFocus = (event) => {
13169
13176
  setHasTabFocus(true);
13170
- onFocus && onFocus(event);
13177
+ onFocus == null ? void 0 : onFocus(event);
13171
13178
  };
13172
13179
  const handleOnBlur = (event) => {
13173
13180
  var _a;
@@ -13780,8 +13787,9 @@ var ToggleRadio = ({
13780
13787
  const uniqueId = id != null ? id : `${generatedId}-ToggleRadio`;
13781
13788
  const group = useToggleBarContext();
13782
13789
  const handleChange = (event) => {
13783
- onChange && onChange(event);
13784
- (group == null ? void 0 : group.onChange) && group.onChange(event);
13790
+ var _a;
13791
+ onChange == null ? void 0 : onChange(event);
13792
+ (_a = group == null ? void 0 : group.onChange) == null ? void 0 : _a.call(group, event);
13785
13793
  };
13786
13794
  const contentTypeCn = label ? "with-text" : "just-icon";
13787
13795
  return /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)("label", { htmlFor: uniqueId, className: ToggleBar_default.label, children: [