@norges-domstoler/dds-components 21.9.1 → 21.9.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.mjs CHANGED
@@ -952,6 +952,11 @@ var getBaseHTMLProps = (id, htmlPropsOrClassName, htmlPropsOrUnknownProps, unkno
952
952
  }
953
953
  };
954
954
 
955
+ // src/types/Size.tsx
956
+ function createSizes(...sizes) {
957
+ return sizes;
958
+ }
959
+
955
960
  // src/types/Surface.tsx
956
961
  var BORDER_RADII = [
957
962
  "button",
@@ -3218,6 +3223,7 @@ var getSize = (iconSize) => {
3218
3223
  return "var(--dds-icon-size-medium)";
3219
3224
  }
3220
3225
  };
3226
+ var ICON_SIZES = createSizes("small", "medium", "large", "inherit");
3221
3227
  function Icon(props) {
3222
3228
  const {
3223
3229
  id,
@@ -6833,6 +6839,7 @@ var useDrawerContext = () => useContext14(DrawerContext);
6833
6839
 
6834
6840
  // src/components/Drawer/Drawer.tsx
6835
6841
  import { jsx as jsx243, jsxs as jsxs50 } from "react/jsx-runtime";
6842
+ var DRAWER_SIZES = createSizes("small", "medium", "large");
6836
6843
  var Drawer = ({
6837
6844
  children,
6838
6845
  header,
@@ -7090,6 +7097,7 @@ var FavStar_default = {
7090
7097
 
7091
7098
  // src/components/FavStar/FavStar.tsx
7092
7099
  import { jsx as jsx246, jsxs as jsxs52 } from "react/jsx-runtime";
7100
+ var FAVSTAR_SIZES = createSizes("medium", "large");
7093
7101
  var FavStar = ({
7094
7102
  id,
7095
7103
  className,
@@ -8618,6 +8626,7 @@ var InlineEdit_default = {
8618
8626
  "inline-input--with-icon": "InlineEdit_inline-input--with-icon",
8619
8627
  "inline-textarea": "InlineEdit_inline-textarea",
8620
8628
  "edit-icon": "InlineEdit_edit-icon",
8629
+ "edit-icon-textarea": "InlineEdit_edit-icon-textarea",
8621
8630
  chevron: "InlineEdit_chevron",
8622
8631
  "clear-button": "InlineEdit_clear-button"
8623
8632
  };
@@ -8755,7 +8764,10 @@ function InlineField(props) {
8755
8764
  {
8756
8765
  iconSize,
8757
8766
  icon,
8758
- className: cn(className2, utilStyles_default["center-absolute-y"])
8767
+ className: cn(
8768
+ className2,
8769
+ elementType === "textarea" ? InlineEdit_default["edit-icon-textarea"] : utilStyles_default["center-absolute-y"]
8770
+ )
8759
8771
  }
8760
8772
  );
8761
8773
  }
@@ -9448,6 +9460,7 @@ function PaginationGenerator(pagesAmount, activePage) {
9448
9460
 
9449
9461
  // src/components/Select/Select.tsx
9450
9462
  import {
9463
+ useCallback as useCallback7,
9451
9464
  useContext as useContext18,
9452
9465
  useId as useId17
9453
9466
  } from "react";
@@ -9732,7 +9745,7 @@ var getCustomStyles = (size2, hasError, hasIcon, isReadOnly) => ({
9732
9745
  });
9733
9746
 
9734
9747
  // src/components/Select/SelectComponents.tsx
9735
- import { useMemo as useMemo2 } from "react";
9748
+ import React from "react";
9736
9749
  import {
9737
9750
  components
9738
9751
  } from "react-select";
@@ -9757,27 +9770,47 @@ var getIndicatorIconSize = (componentSize) => {
9757
9770
  return "small";
9758
9771
  }
9759
9772
  };
9760
- var DDSOption = (props, componentSize) => /* @__PURE__ */ jsxs66(Option, { ...props, children: [
9773
+ var DDSOption = ({
9774
+ componentSize,
9775
+ ...props
9776
+ }) => /* @__PURE__ */ jsxs66(Option, { ...props, children: [
9761
9777
  props.isSelected && /* @__PURE__ */ jsx283(Icon, { icon: CheckIcon, iconSize: getFormInputIconSize(componentSize) }),
9762
9778
  props.children
9763
9779
  ] });
9764
- var CustomOption = (props, Element) => /* @__PURE__ */ jsx283(Option, { ...props, children: /* @__PURE__ */ jsx283(Element, { ...props }) });
9765
- var CustomSingleValue = (props, id, Element) => /* @__PURE__ */ jsx283(SingleValue, { ...props, children: /* @__PURE__ */ jsx283("div", { id, className: Select_default["inner-single-value"], children: Element ? /* @__PURE__ */ jsx283(Element, { ...props }) : props.children }) });
9780
+ var CustomOption = (props) => /* @__PURE__ */ jsx283(Option, { ...props, children: React.createElement(props.customElement, props) });
9781
+ var CustomSingleValue = ({
9782
+ id,
9783
+ Element,
9784
+ ...props
9785
+ }) => /* @__PURE__ */ jsx283(SingleValue, { ...props, children: /* @__PURE__ */ jsx283("div", { id, className: Select_default["inner-single-value"], children: Element ? /* @__PURE__ */ jsx283(Element, { ...props }) : props.children }) });
9766
9786
  var DDSNoOptionsMessage = (props) => /* @__PURE__ */ jsx283(NoOptionsMessage, { ...props, children: "Ingen treff" });
9767
- var DDSClearIndicator = (props, size2) => /* @__PURE__ */ jsx283(ClearIndicator, { ...props, children: /* @__PURE__ */ jsx283(Icon, { icon: CloseSmallIcon, iconSize: getIndicatorIconSize(size2) }) });
9787
+ var DDSClearIndicator = ({
9788
+ size: size2,
9789
+ ...props
9790
+ }) => /* @__PURE__ */ jsx283(ClearIndicator, { ...props, children: /* @__PURE__ */ jsx283(Icon, { icon: CloseSmallIcon, iconSize: getIndicatorIconSize(size2) }) });
9768
9791
  var DDSMultiValueRemove = (props) => /* @__PURE__ */ jsx283(MultiValueRemove, { ...props, children: /* @__PURE__ */ jsx283(Icon, { icon: CloseSmallIcon, iconSize: "small" }) });
9769
- var DDSDropdownIndicator = (props, size2) => {
9770
- const { className, ...rest } = props;
9792
+ var DDSDropdownIndicator = (props) => {
9793
+ const { className, componentSize, ...rest } = props;
9771
9794
  return /* @__PURE__ */ jsx283(
9772
9795
  DropdownIndicator,
9773
9796
  {
9774
9797
  ...rest,
9775
9798
  className: cn(className, Select_default["dropdown-indicator"]),
9776
- children: /* @__PURE__ */ jsx283(Icon, { icon: ChevronDownIcon, iconSize: getIndicatorIconSize(size2) })
9799
+ children: /* @__PURE__ */ jsx283(
9800
+ Icon,
9801
+ {
9802
+ icon: ChevronDownIcon,
9803
+ iconSize: getIndicatorIconSize(componentSize)
9804
+ }
9805
+ )
9777
9806
  }
9778
9807
  );
9779
9808
  };
9780
- var DDSInput = (props, ariaInvalid, ariaDescribedby) => /* @__PURE__ */ jsx283(
9809
+ var DDSInput = ({
9810
+ ariaInvalid,
9811
+ ariaDescribedby,
9812
+ ...props
9813
+ }) => /* @__PURE__ */ jsx283(
9781
9814
  Input2,
9782
9815
  {
9783
9816
  ...props,
@@ -9785,45 +9818,48 @@ var DDSInput = (props, ariaInvalid, ariaDescribedby) => /* @__PURE__ */ jsx283(
9785
9818
  "aria-describedby": ariaDescribedby
9786
9819
  }
9787
9820
  );
9788
- function createDDSControl(componentSize, readOnly, icon, dataTestId) {
9789
- return function DDSControlWrapper(props) {
9790
- const { className, children, innerProps, ...rest } = props;
9791
- return /* @__PURE__ */ jsxs66(
9792
- Control,
9793
- {
9794
- ...rest,
9795
- innerProps: {
9796
- ...innerProps,
9797
- "data-testid": dataTestId ? dataTestId + "-control" : void 0
9798
- },
9799
- className: cn(
9800
- className,
9801
- Select_default.control,
9802
- rest.isDisabled && Select_default["control--disabled"],
9803
- readOnly && Select_default["control--readonly"]
9821
+ function DDSControl(props) {
9822
+ const {
9823
+ componentSize,
9824
+ readOnly,
9825
+ icon,
9826
+ dataTestId,
9827
+ className,
9828
+ children,
9829
+ innerProps,
9830
+ ...rest
9831
+ } = props;
9832
+ return /* @__PURE__ */ jsxs66(
9833
+ Control,
9834
+ {
9835
+ ...rest,
9836
+ innerProps: {
9837
+ ...innerProps,
9838
+ "data-testid": dataTestId ? dataTestId + "-control" : void 0
9839
+ },
9840
+ className: cn(
9841
+ className,
9842
+ Select_default.control,
9843
+ rest.isDisabled && Select_default["control--disabled"],
9844
+ readOnly && Select_default["control--readonly"]
9845
+ ),
9846
+ children: [
9847
+ icon && /* @__PURE__ */ jsx283(
9848
+ Icon,
9849
+ {
9850
+ icon,
9851
+ iconSize: getFormInputIconSize(componentSize),
9852
+ className: cn(
9853
+ Input_default["input-group__absolute-element"],
9854
+ Select_default[`icon--${componentSize}`]
9855
+ )
9856
+ }
9804
9857
  ),
9805
- children: [
9806
- icon && /* @__PURE__ */ jsx283(
9807
- Icon,
9808
- {
9809
- icon,
9810
- iconSize: getFormInputIconSize(componentSize),
9811
- className: cn(
9812
- Input_default["input-group__absolute-element"],
9813
- Select_default[`icon--${componentSize}`]
9814
- )
9815
- }
9816
- ),
9817
- children
9818
- ]
9819
- }
9820
- );
9821
- };
9858
+ children
9859
+ ]
9860
+ }
9861
+ );
9822
9862
  }
9823
- var DDSControl = (componentSize, readOnly, icon, dataTestId) => useMemo2(
9824
- () => createDDSControl(componentSize, readOnly, icon, dataTestId),
9825
- [componentSize, readOnly, icon, dataTestId]
9826
- );
9827
9863
 
9828
9864
  // src/components/Select/Select.tsx
9829
9865
  import { jsx as jsx284, jsxs as jsxs67 } from "react/jsx-runtime";
@@ -9876,6 +9912,66 @@ function Select({
9876
9912
  width,
9877
9913
  componentSize === "xsmall" && "var(--dds-input-default-width-xsmall)"
9878
9914
  );
9915
+ const customInput = useCallback7(
9916
+ (props) => /* @__PURE__ */ jsx284(
9917
+ DDSInput,
9918
+ {
9919
+ ...props,
9920
+ readOnly,
9921
+ "aria-required": ariaRequired,
9922
+ "aria-activedescendant": props["aria-activedescendant"] === "" ? void 0 : props["aria-activedescendant"],
9923
+ ariaInvalid: hasErrorMessage,
9924
+ ariaDescribedby: spaceSeparatedIdListGenerator([
9925
+ singleValueId,
9926
+ tip ? tipId : void 0,
9927
+ errorMessage ? errorMessageId : void 0
9928
+ ])
9929
+ }
9930
+ ),
9931
+ []
9932
+ );
9933
+ const customSingleValue = useCallback7(
9934
+ (props) => /* @__PURE__ */ jsx284(
9935
+ CustomSingleValue,
9936
+ {
9937
+ ...props,
9938
+ id: singleValueId,
9939
+ Element: customSingleValueElement
9940
+ }
9941
+ ),
9942
+ []
9943
+ );
9944
+ const customClearIndicator = useCallback7(
9945
+ (props) => /* @__PURE__ */ jsx284(DDSClearIndicator, { ...props, size: componentSize }),
9946
+ [componentSize]
9947
+ );
9948
+ const customDropdownIndicator = useCallback7(
9949
+ (props) => /* @__PURE__ */ jsx284(DDSDropdownIndicator, { ...props, componentSize }),
9950
+ [componentSize]
9951
+ );
9952
+ const customControl = useCallback7(
9953
+ (props) => /* @__PURE__ */ jsx284(
9954
+ DDSControl,
9955
+ {
9956
+ ...props,
9957
+ componentSize,
9958
+ readOnly,
9959
+ icon,
9960
+ dataTestId
9961
+ }
9962
+ ),
9963
+ [componentSize, readOnly, icon, dataTestId]
9964
+ );
9965
+ const customOptionComponent = useCallback7(
9966
+ (props) => {
9967
+ if (customOptionElement) {
9968
+ return /* @__PURE__ */ jsx284(CustomOption, { ...props, customElement: customOptionElement });
9969
+ } else {
9970
+ return /* @__PURE__ */ jsx284(DDSOption, { ...props, componentSize });
9971
+ }
9972
+ },
9973
+ [customOptionElement, componentSize]
9974
+ );
9879
9975
  const reactSelectProps = {
9880
9976
  options,
9881
9977
  value,
@@ -9901,27 +9997,14 @@ function Select({
9901
9997
  return searchFilter(label2, inputValue) || inputValue === "";
9902
9998
  },
9903
9999
  components: {
9904
- Option: customOptionElement ? (props) => CustomOption(props, customOptionElement) : (props) => DDSOption(props, componentSize),
10000
+ Option: customOptionComponent,
9905
10001
  NoOptionsMessage: DDSNoOptionsMessage,
9906
- Input: (props) => DDSInput(
9907
- {
9908
- ...props,
9909
- readOnly,
9910
- "aria-required": ariaRequired,
9911
- "aria-activedescendant": props["aria-activedescendant"] === "" ? void 0 : props["aria-activedescendant"]
9912
- },
9913
- hasErrorMessage,
9914
- spaceSeparatedIdListGenerator([
9915
- singleValueId,
9916
- tip ? tipId : void 0,
9917
- errorMessage ? errorMessageId : void 0
9918
- ])
9919
- ),
9920
- SingleValue: (props) => CustomSingleValue(props, singleValueId, customSingleValueElement),
9921
- ClearIndicator: (props) => DDSClearIndicator(props, componentSize),
9922
- DropdownIndicator: (props) => DDSDropdownIndicator(props, componentSize),
10002
+ Input: customInput,
10003
+ SingleValue: customSingleValue,
10004
+ ClearIndicator: customClearIndicator,
10005
+ DropdownIndicator: customDropdownIndicator,
9923
10006
  MultiValueRemove: DDSMultiValueRemove,
9924
- Control: DDSControl(componentSize, readOnly, icon, dataTestId)
10007
+ Control: customControl
9925
10008
  },
9926
10009
  "aria-invalid": hasErrorMessage ? true : void 0,
9927
10010
  required,
@@ -11371,7 +11454,7 @@ import {
11371
11454
  cloneElement as cloneElement5,
11372
11455
  isValidElement as isValidElement5,
11373
11456
  useEffect as useEffect28,
11374
- useMemo as useMemo4,
11457
+ useMemo as useMemo3,
11375
11458
  useState as useState25
11376
11459
  } from "react";
11377
11460
 
@@ -11408,7 +11491,7 @@ var ProgressTracker_default = {
11408
11491
  };
11409
11492
 
11410
11493
  // src/components/ProgressTracker/ProgressTrackerItem.tsx
11411
- import { useMemo as useMemo3 } from "react";
11494
+ import { useMemo as useMemo2 } from "react";
11412
11495
  import { Fragment as Fragment8, jsx as jsx290, jsxs as jsxs72 } from "react/jsx-runtime";
11413
11496
  var toItemState = (active, completed, disabled) => {
11414
11497
  if (disabled) {
@@ -11450,7 +11533,7 @@ var ProgressTrackerItem = (props) => {
11450
11533
  handleStepChange == null ? void 0 : handleStepChange(index);
11451
11534
  }
11452
11535
  };
11453
- const stepNumberContent = useMemo3(() => {
11536
+ const stepNumberContent = useMemo2(() => {
11454
11537
  if (completed) {
11455
11538
  return /* @__PURE__ */ jsx290(Icon, { icon: CheckIcon, iconSize: "small" });
11456
11539
  }
@@ -11572,7 +11655,7 @@ var ProgressTracker = (() => {
11572
11655
  setActiveStep(activeStep);
11573
11656
  }
11574
11657
  }, [activeStep, thisActiveStep]);
11575
- const steps = useMemo4(() => {
11658
+ const steps = useMemo3(() => {
11576
11659
  const validChildren = removeInvalidChildren(children);
11577
11660
  const itemsWithIndex = passIndexPropToProgressTrackerItem(validChildren);
11578
11661
  return itemsWithIndex;
@@ -11652,6 +11735,7 @@ var ProgressBar_default = {
11652
11735
 
11653
11736
  // src/components/ProgressBar/ProgressBar.tsx
11654
11737
  import { jsx as jsx292, jsxs as jsxs73 } from "react/jsx-runtime";
11738
+ var PROGRESS_BAR_SIZES = createSizes("small", "medium");
11655
11739
  var ProgressBar = ({
11656
11740
  label,
11657
11741
  tip,
@@ -11747,6 +11831,7 @@ var Search_default = {
11747
11831
  };
11748
11832
 
11749
11833
  // src/components/Search/Search.utils.ts
11834
+ var SEARCH_SIZES = createSizes("small", "medium", "large");
11750
11835
  var typographyTypes2 = {
11751
11836
  small: "bodySmall",
11752
11837
  medium: "bodyMedium",
@@ -12707,7 +12792,6 @@ var useTabsContext = () => useContext26(TabsContext);
12707
12792
 
12708
12793
  // src/components/Tabs/Tabs.module.css
12709
12794
  var Tabs_default = {
12710
- tabs: "Tabs_tabs",
12711
12795
  "tab-row": "Tabs_tab-row",
12712
12796
  "tab-row--standard-widths": "Tabs_tab-row--standard-widths",
12713
12797
  "tab-row--custom-widths": "Tabs_tab-row--custom-widths",
@@ -12802,6 +12886,7 @@ AddTabButton.displayName = "AddTabButton";
12802
12886
  // src/components/Tabs/Tabs.tsx
12803
12887
  import { useEffect as useEffect33, useId as useId24, useRef as useRef36, useState as useState31 } from "react";
12804
12888
  import { jsx as jsx312 } from "react/jsx-runtime";
12889
+ var TABS_SIZES = createSizes("small", "medium");
12805
12890
  var Tabs = ({
12806
12891
  id,
12807
12892
  activeTab,
@@ -12848,12 +12933,7 @@ var Tabs = ({
12848
12933
  children: /* @__PURE__ */ jsx312(
12849
12934
  Box,
12850
12935
  {
12851
- ...getBaseHTMLProps(
12852
- uniqueId,
12853
- cn(className, Tabs_default.tabs),
12854
- htmlProps,
12855
- rest
12856
- ),
12936
+ ...getBaseHTMLProps(uniqueId, className, htmlProps, rest),
12857
12937
  width,
12858
12938
  children
12859
12939
  }
@@ -12865,7 +12945,7 @@ Tabs.displayName = "Tabs";
12865
12945
 
12866
12946
  // src/components/Tabs/Tab.tsx
12867
12947
  import {
12868
- useCallback as useCallback7,
12948
+ useCallback as useCallback8,
12869
12949
  useEffect as useEffect34,
12870
12950
  useRef as useRef37
12871
12951
  } from "react";
@@ -12898,7 +12978,7 @@ var Tab = ({
12898
12978
  (_a = itemRef.current) == null ? void 0 : _a.focus();
12899
12979
  }
12900
12980
  }, [focus]);
12901
- const handleSelect = useCallback7(() => {
12981
+ const handleSelect = useCallback8(() => {
12902
12982
  if (setFocus && index) {
12903
12983
  setFocus(index);
12904
12984
  }
@@ -13407,6 +13487,7 @@ var Toggle_default = {
13407
13487
 
13408
13488
  // src/components/Toggle/Toggle.tsx
13409
13489
  import { jsx as jsx319, jsxs as jsxs84 } from "react/jsx-runtime";
13490
+ var TOGGLE_SIZES = createSizes("medium", "large");
13410
13491
  var Toggle = ({
13411
13492
  id,
13412
13493
  children,
@@ -14051,6 +14132,7 @@ export {
14051
14132
  cn,
14052
14133
  countryOptions,
14053
14134
  createSelectOptions,
14135
+ createSizes,
14054
14136
  dateValueToNativeDate,
14055
14137
  defaultTypographyType,
14056
14138
  defaultTypographyTypeClassName,