@norges-domstoler/dds-components 21.9.0 → 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";
@@ -9855,6 +9891,7 @@ function Select({
9855
9891
  onKeyDown,
9856
9892
  openMenuOnClick,
9857
9893
  ref,
9894
+ instanceId,
9858
9895
  ...rest
9859
9896
  }) {
9860
9897
  const themeContext = useContext18(ThemeContext);
@@ -9875,6 +9912,66 @@ function Select({
9875
9912
  width,
9876
9913
  componentSize === "xsmall" && "var(--dds-input-default-width-xsmall)"
9877
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
+ );
9878
9975
  const reactSelectProps = {
9879
9976
  options,
9880
9977
  value,
@@ -9884,6 +9981,7 @@ function Select({
9884
9981
  placeholder: placeholder ? placeholder : "",
9885
9982
  closeMenuOnSelect: closeMenuOnSelect ? closeMenuOnSelect : isMulti ? false : true,
9886
9983
  isMulti,
9984
+ instanceId: instanceId != null ? instanceId : useId17(),
9887
9985
  inputId: uniqueId,
9888
9986
  name: uniqueId,
9889
9987
  menuPortalTarget: portalTarget,
@@ -9899,26 +9997,14 @@ function Select({
9899
9997
  return searchFilter(label2, inputValue) || inputValue === "";
9900
9998
  },
9901
9999
  components: {
9902
- Option: customOptionElement ? (props) => CustomOption(props, customOptionElement) : (props) => DDSOption(props, componentSize),
10000
+ Option: customOptionComponent,
9903
10001
  NoOptionsMessage: DDSNoOptionsMessage,
9904
- Input: (props) => DDSInput(
9905
- {
9906
- ...props,
9907
- readOnly,
9908
- "aria-required": ariaRequired
9909
- },
9910
- hasErrorMessage,
9911
- spaceSeparatedIdListGenerator([
9912
- singleValueId,
9913
- tip ? tipId : void 0,
9914
- errorMessage ? errorMessageId : void 0
9915
- ])
9916
- ),
9917
- SingleValue: (props) => CustomSingleValue(props, singleValueId, customSingleValueElement),
9918
- ClearIndicator: (props) => DDSClearIndicator(props, componentSize),
9919
- DropdownIndicator: (props) => DDSDropdownIndicator(props, componentSize),
10002
+ Input: customInput,
10003
+ SingleValue: customSingleValue,
10004
+ ClearIndicator: customClearIndicator,
10005
+ DropdownIndicator: customDropdownIndicator,
9920
10006
  MultiValueRemove: DDSMultiValueRemove,
9921
- Control: DDSControl(componentSize, readOnly, icon, dataTestId)
10007
+ Control: customControl
9922
10008
  },
9923
10009
  "aria-invalid": hasErrorMessage ? true : void 0,
9924
10010
  required,
@@ -11368,7 +11454,7 @@ import {
11368
11454
  cloneElement as cloneElement5,
11369
11455
  isValidElement as isValidElement5,
11370
11456
  useEffect as useEffect28,
11371
- useMemo as useMemo4,
11457
+ useMemo as useMemo3,
11372
11458
  useState as useState25
11373
11459
  } from "react";
11374
11460
 
@@ -11405,7 +11491,7 @@ var ProgressTracker_default = {
11405
11491
  };
11406
11492
 
11407
11493
  // src/components/ProgressTracker/ProgressTrackerItem.tsx
11408
- import { useMemo as useMemo3 } from "react";
11494
+ import { useMemo as useMemo2 } from "react";
11409
11495
  import { Fragment as Fragment8, jsx as jsx290, jsxs as jsxs72 } from "react/jsx-runtime";
11410
11496
  var toItemState = (active, completed, disabled) => {
11411
11497
  if (disabled) {
@@ -11447,7 +11533,7 @@ var ProgressTrackerItem = (props) => {
11447
11533
  handleStepChange == null ? void 0 : handleStepChange(index);
11448
11534
  }
11449
11535
  };
11450
- const stepNumberContent = useMemo3(() => {
11536
+ const stepNumberContent = useMemo2(() => {
11451
11537
  if (completed) {
11452
11538
  return /* @__PURE__ */ jsx290(Icon, { icon: CheckIcon, iconSize: "small" });
11453
11539
  }
@@ -11569,7 +11655,7 @@ var ProgressTracker = (() => {
11569
11655
  setActiveStep(activeStep);
11570
11656
  }
11571
11657
  }, [activeStep, thisActiveStep]);
11572
- const steps = useMemo4(() => {
11658
+ const steps = useMemo3(() => {
11573
11659
  const validChildren = removeInvalidChildren(children);
11574
11660
  const itemsWithIndex = passIndexPropToProgressTrackerItem(validChildren);
11575
11661
  return itemsWithIndex;
@@ -11649,6 +11735,7 @@ var ProgressBar_default = {
11649
11735
 
11650
11736
  // src/components/ProgressBar/ProgressBar.tsx
11651
11737
  import { jsx as jsx292, jsxs as jsxs73 } from "react/jsx-runtime";
11738
+ var PROGRESS_BAR_SIZES = createSizes("small", "medium");
11652
11739
  var ProgressBar = ({
11653
11740
  label,
11654
11741
  tip,
@@ -11744,6 +11831,7 @@ var Search_default = {
11744
11831
  };
11745
11832
 
11746
11833
  // src/components/Search/Search.utils.ts
11834
+ var SEARCH_SIZES = createSizes("small", "medium", "large");
11747
11835
  var typographyTypes2 = {
11748
11836
  small: "bodySmall",
11749
11837
  medium: "bodyMedium",
@@ -12704,7 +12792,6 @@ var useTabsContext = () => useContext26(TabsContext);
12704
12792
 
12705
12793
  // src/components/Tabs/Tabs.module.css
12706
12794
  var Tabs_default = {
12707
- tabs: "Tabs_tabs",
12708
12795
  "tab-row": "Tabs_tab-row",
12709
12796
  "tab-row--standard-widths": "Tabs_tab-row--standard-widths",
12710
12797
  "tab-row--custom-widths": "Tabs_tab-row--custom-widths",
@@ -12799,6 +12886,7 @@ AddTabButton.displayName = "AddTabButton";
12799
12886
  // src/components/Tabs/Tabs.tsx
12800
12887
  import { useEffect as useEffect33, useId as useId24, useRef as useRef36, useState as useState31 } from "react";
12801
12888
  import { jsx as jsx312 } from "react/jsx-runtime";
12889
+ var TABS_SIZES = createSizes("small", "medium");
12802
12890
  var Tabs = ({
12803
12891
  id,
12804
12892
  activeTab,
@@ -12845,12 +12933,7 @@ var Tabs = ({
12845
12933
  children: /* @__PURE__ */ jsx312(
12846
12934
  Box,
12847
12935
  {
12848
- ...getBaseHTMLProps(
12849
- uniqueId,
12850
- cn(className, Tabs_default.tabs),
12851
- htmlProps,
12852
- rest
12853
- ),
12936
+ ...getBaseHTMLProps(uniqueId, className, htmlProps, rest),
12854
12937
  width,
12855
12938
  children
12856
12939
  }
@@ -12862,7 +12945,7 @@ Tabs.displayName = "Tabs";
12862
12945
 
12863
12946
  // src/components/Tabs/Tab.tsx
12864
12947
  import {
12865
- useCallback as useCallback7,
12948
+ useCallback as useCallback8,
12866
12949
  useEffect as useEffect34,
12867
12950
  useRef as useRef37
12868
12951
  } from "react";
@@ -12895,7 +12978,7 @@ var Tab = ({
12895
12978
  (_a = itemRef.current) == null ? void 0 : _a.focus();
12896
12979
  }
12897
12980
  }, [focus]);
12898
- const handleSelect = useCallback7(() => {
12981
+ const handleSelect = useCallback8(() => {
12899
12982
  if (setFocus && index) {
12900
12983
  setFocus(index);
12901
12984
  }
@@ -13404,6 +13487,7 @@ var Toggle_default = {
13404
13487
 
13405
13488
  // src/components/Toggle/Toggle.tsx
13406
13489
  import { jsx as jsx319, jsxs as jsxs84 } from "react/jsx-runtime";
13490
+ var TOGGLE_SIZES = createSizes("medium", "large");
13407
13491
  var Toggle = ({
13408
13492
  id,
13409
13493
  children,
@@ -14048,6 +14132,7 @@ export {
14048
14132
  cn,
14049
14133
  countryOptions,
14050
14134
  createSelectOptions,
14135
+ createSizes,
14051
14136
  dateValueToNativeDate,
14052
14137
  defaultTypographyType,
14053
14138
  defaultTypographyTypeClassName,