@norges-domstoler/dds-components 21.14.0 → 21.16.0

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
@@ -407,6 +407,7 @@ var typographyStyles_default = {
407
407
  "a--nested__child": "typographyStyles_a--nested__child",
408
408
  "a--margins": "typographyStyles_a--margins",
409
409
  "a--external": "typographyStyles_a--external",
410
+ a__icon: "typographyStyles_a__icon",
410
411
  "a--visited": "typographyStyles_a--visited",
411
412
  "body-xsmall": "typographyStyles_body-xsmall",
412
413
  "body-xsmall--margins": "typographyStyles_body-xsmall--margins",
@@ -3770,32 +3771,50 @@ var Label = ({
3770
3771
  className,
3771
3772
  htmlProps,
3772
3773
  children,
3774
+ afterLabelContent,
3773
3775
  ...rest
3774
3776
  }) => {
3775
- return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(
3777
+ const content = /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_jsx_runtime184.Fragment, { children: [
3778
+ readOnly && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
3779
+ Icon,
3780
+ {
3781
+ icon: LockIcon,
3782
+ iconSize: "small",
3783
+ className: Label_default["read-only__icon"]
3784
+ }
3785
+ ),
3786
+ children,
3787
+ showRequiredStyling && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(RequiredMarker, {})
3788
+ ] });
3789
+ const labelProps = {
3790
+ ...getBaseHTMLProps(
3791
+ id,
3792
+ cn(className, readOnly && Label_default["read-only"]),
3793
+ htmlProps,
3794
+ rest
3795
+ )
3796
+ };
3797
+ const render = afterLabelContent ? /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(
3776
3798
  Typography,
3777
3799
  {
3778
- ...getBaseHTMLProps(
3779
- id,
3780
- cn(className, readOnly && Label_default["read-only"]),
3781
- htmlProps,
3782
- rest
3783
- ),
3784
3800
  typographyType: "labelMedium",
3801
+ as: "div",
3802
+ withMargins: rest.withMargins,
3785
3803
  children: [
3786
- readOnly && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
3787
- Icon,
3804
+ /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
3805
+ Typography,
3788
3806
  {
3789
- icon: LockIcon,
3790
- iconSize: "small",
3791
- className: Label_default["read-only__icon"]
3807
+ ...labelProps,
3808
+ typographyType: "labelMedium",
3809
+ withMargins: false,
3810
+ children: content
3792
3811
  }
3793
3812
  ),
3794
- children,
3795
- showRequiredStyling && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(RequiredMarker, {})
3813
+ afterLabelContent
3796
3814
  ]
3797
3815
  }
3798
- );
3816
+ ) : /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(Typography, { ...labelProps, typographyType: "labelMedium", children: content });
3817
+ return render;
3799
3818
  };
3800
3819
  Label.displayName = "Label";
3801
3820
 
@@ -3824,7 +3843,7 @@ var import_jsx_runtime186 = require("react/jsx-runtime");
3824
3843
  var Link = ({
3825
3844
  id,
3826
3845
  className,
3827
- htmlProps = {},
3846
+ htmlProps,
3828
3847
  children,
3829
3848
  typographyType,
3830
3849
  withMargins,
@@ -3833,12 +3852,14 @@ var Link = ({
3833
3852
  target,
3834
3853
  style,
3835
3854
  color,
3855
+ as: propAs,
3836
3856
  ...rest
3837
3857
  }) => {
3838
- const { style: htmlPropsStyle, ...restHtmlProps } = htmlProps;
3858
+ const as = propAs ? propAs : "a";
3839
3859
  return /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(
3840
- "a",
3860
+ ElementAs,
3841
3861
  {
3862
+ as,
3842
3863
  ...getBaseHTMLProps(
3843
3864
  id,
3844
3865
  cn(
@@ -3851,14 +3872,13 @@ var Link = ({
3851
3872
  focusable,
3852
3873
  getColorCn(color)
3853
3874
  ),
3854
- restHtmlProps,
3875
+ htmlProps,
3855
3876
  rest
3856
3877
  ),
3857
- ...rest,
3858
3878
  rel: "noopener noreferer",
3859
3879
  target: external ? "_blank" : target,
3860
3880
  style: {
3861
- ...htmlPropsStyle,
3881
+ ...htmlProps == null ? void 0 : htmlProps.style,
3862
3882
  ...style,
3863
3883
  color: color && !isTextColor(color) ? getTextColor(color) : void 0
3864
3884
  },
@@ -3999,12 +4019,28 @@ var BackLink_default = {
3999
4019
 
4000
4020
  // src/components/BackLink/BackLink.tsx
4001
4021
  var import_jsx_runtime190 = require("react/jsx-runtime");
4002
- var BackLink = ({ label, ref, ...rest }) => {
4022
+ var BackLink = ({ label, ref, as = "a", ...rest }) => {
4003
4023
  const { t } = useTranslation();
4004
- return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("nav", { ref, "aria-label": t(texts.goBack), children: /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(Link, { ...rest, children: [
4005
- /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(Icon, { icon: ArrowLeftIcon, iconSize: "inherit", className: BackLink_default.icon }),
4006
- label
4007
- ] }) });
4024
+ return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)("nav", { ref, "aria-label": t(texts.goBack), children: /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(
4025
+ ElementAs,
4026
+ {
4027
+ as,
4028
+ className: cn(typographyStyles_default.a, focusable),
4029
+ rel: "noopener noreferer",
4030
+ ...rest,
4031
+ children: [
4032
+ /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
4033
+ Icon,
4034
+ {
4035
+ icon: ArrowLeftIcon,
4036
+ iconSize: "inherit",
4037
+ className: cn(typographyStyles_default.a__icon, BackLink_default.icon)
4038
+ }
4039
+ ),
4040
+ label
4041
+ ]
4042
+ }
4043
+ ) });
4008
4044
  };
4009
4045
  BackLink.displayName = "BackLink";
4010
4046
  var texts = createTexts({
@@ -4233,10 +4269,10 @@ var Button = ({
4233
4269
  {
4234
4270
  ref,
4235
4271
  ...getBaseHTMLProps(id, buttonCn, htmlProps, rest),
4236
- onClick: loading ? void 0 : onClick,
4272
+ onClick,
4237
4273
  onFocus,
4238
4274
  onBlur,
4239
- "aria-disabled": loading,
4275
+ disabled: loading != null ? loading : rest.disabled,
4240
4276
  children: content
4241
4277
  }
4242
4278
  );
@@ -6762,6 +6798,7 @@ function DateInput({
6762
6798
  width,
6763
6799
  clearable,
6764
6800
  ref,
6801
+ afterLabelContent,
6765
6802
  ...props
6766
6803
  }) {
6767
6804
  var _a;
@@ -6780,7 +6817,8 @@ function DateInput({
6780
6817
  ...labelProps,
6781
6818
  label: props.label,
6782
6819
  showRequiredStyling: required,
6783
- readOnly
6820
+ readOnly,
6821
+ afterLabelContent
6784
6822
  }),
6785
6823
  /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(
6786
6824
  Box,
@@ -6923,14 +6961,14 @@ var texts7 = createTexts({
6923
6961
  });
6924
6962
 
6925
6963
  // src/components/date-inputs/utils/useFocusManagerRef.ts
6926
- var import_focus17 = require("@react-aria/focus");
6964
+ var import_focus18 = require("@react-aria/focus");
6927
6965
  var import_react46 = require("react");
6928
6966
  function useFocusManagerRef(ref) {
6929
6967
  const domRef = (0, import_react46.useRef)(null);
6930
6968
  (0, import_react46.useImperativeHandle)(ref, () => ({
6931
6969
  ...createDOMRef(domRef),
6932
6970
  focus() {
6933
- (0, import_focus17.createFocusManager)(domRef).focusFirst({ tabbable: true });
6971
+ (0, import_focus18.createFocusManager)(domRef).focusFirst({ tabbable: true });
6934
6972
  }
6935
6973
  }));
6936
6974
  return domRef;
@@ -8688,6 +8726,7 @@ var FileUploader = (props) => {
8688
8726
  errorMessage,
8689
8727
  hideFileList,
8690
8728
  className,
8729
+ afterLabelContent,
8691
8730
  ...rest
8692
8731
  } = props;
8693
8732
  const { t } = useTranslation();
@@ -8782,7 +8821,8 @@ var FileUploader = (props) => {
8782
8821
  id: labelId,
8783
8822
  showRequiredStyling: required,
8784
8823
  htmlFor: inputId,
8785
- readOnly
8824
+ readOnly,
8825
+ afterLabelContent
8786
8826
  }),
8787
8827
  hasTip && /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(InputMessage, { id: tipId, message: tip, messageType: "tip" }),
8788
8828
  inactive ? input : withDragAndDrop ? /* @__PURE__ */ (0, import_jsx_runtime260.jsxs)(
@@ -9022,6 +9062,8 @@ var import_jsx_runtime270 = require("react/jsx-runtime");
9022
9062
  var InlineButton = ({
9023
9063
  className,
9024
9064
  color,
9065
+ icon,
9066
+ children,
9025
9067
  ...rest
9026
9068
  }) => /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(
9027
9069
  StylelessButton,
@@ -9033,7 +9075,8 @@ var InlineButton = ({
9033
9075
  InlineButton_default.button,
9034
9076
  getColorCn(color)
9035
9077
  ),
9036
- ...rest
9078
+ ...rest,
9079
+ children: icon ? /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(Icon, { icon, iconSize: "inherit" }) : children
9037
9080
  }
9038
9081
  );
9039
9082
 
@@ -10177,7 +10220,7 @@ var getCustomStyles = (size2, hasError, hasIcon, isReadOnly) => ({
10177
10220
  cursor: "pointer",
10178
10221
  display: "flex",
10179
10222
  alignItems: "center",
10180
- gap: "var(--dds-spacing-x0-5)",
10223
+ gap: "var(--dds-spacing-x0-25)",
10181
10224
  padding: "var(--dds-spacing-x0-75)",
10182
10225
  backgroundColor: "var(--dds-color-surface-default)",
10183
10226
  ...typography.option[size2],
@@ -10243,10 +10286,9 @@ var getIndicatorIconSize = (componentSize) => {
10243
10286
  }
10244
10287
  };
10245
10288
  var DDSOption = ({
10246
- componentSize,
10247
10289
  ...props
10248
10290
  }) => /* @__PURE__ */ (0, import_jsx_runtime285.jsxs)(Option, { ...props, children: [
10249
- props.isSelected && /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(Icon, { icon: CheckIcon, iconSize: getFormInputIconSize(componentSize) }),
10291
+ props.isSelected && /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(Icon, { icon: CheckIcon, iconSize: "small" }),
10250
10292
  props.children
10251
10293
  ] });
10252
10294
  var CustomOption = (props) => /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(Option, { ...props, children: import_react70.default.createElement(props.customElement, props) });
@@ -10363,6 +10405,7 @@ function Select({
10363
10405
  openMenuOnClick,
10364
10406
  ref,
10365
10407
  instanceId,
10408
+ afterLabelContent,
10366
10409
  ...rest
10367
10410
  }) {
10368
10411
  const themeContext = (0, import_react71.useContext)(ThemeContext);
@@ -10437,7 +10480,7 @@ function Select({
10437
10480
  if (customOptionElement) {
10438
10481
  return /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(CustomOption, { ...props, customElement: customOptionElement });
10439
10482
  } else {
10440
- return /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(DDSOption, { ...props, componentSize });
10483
+ return /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(DDSOption, { ...props });
10441
10484
  }
10442
10485
  },
10443
10486
  [customOptionElement, componentSize]
@@ -10498,7 +10541,8 @@ function Select({
10498
10541
  label,
10499
10542
  htmlFor: uniqueId,
10500
10543
  showRequiredStyling,
10501
- readOnly
10544
+ readOnly,
10545
+ afterLabelContent
10502
10546
  }),
10503
10547
  /* @__PURE__ */ (0, import_jsx_runtime286.jsx)(import_react_select2.default, { ...reactSelectProps, ref }),
10504
10548
  renderInputMessage(tip, tipId, errorMessage, errorMessageId)
@@ -10547,6 +10591,7 @@ var NativeSelect = ({
10547
10591
  onKeyDown,
10548
10592
  onMouseDown,
10549
10593
  clearable,
10594
+ afterLabelContent,
10550
10595
  onChange,
10551
10596
  ...rest
10552
10597
  }) => {
@@ -10598,7 +10643,8 @@ var NativeSelect = ({
10598
10643
  label,
10599
10644
  htmlFor: uniqueId,
10600
10645
  showRequiredStyling,
10601
- readOnly
10646
+ readOnly,
10647
+ afterLabelContent
10602
10648
  }),
10603
10649
  /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(Box, { position: "relative", width: inputWidth, children: [
10604
10650
  /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(
@@ -10672,6 +10718,7 @@ var Pagination = ({
10672
10718
  itemsAmount,
10673
10719
  defaultItemsPerPage = 10,
10674
10720
  defaultActivePage = 1,
10721
+ activePage: activePageProp,
10675
10722
  withPagination = true,
10676
10723
  withCounter,
10677
10724
  withSelect,
@@ -10691,7 +10738,15 @@ var Pagination = ({
10691
10738
  ...rest
10692
10739
  }) => {
10693
10740
  const { t } = useTranslation();
10694
- const [activePage, setActivePage] = (0, import_react73.useState)(defaultActivePage);
10741
+ if (withSelect && !selectOptions.some((o) => o.value === defaultItemsPerPage)) {
10742
+ console.warn(
10743
+ `[Pagination] defaultItemsPerPage prop value (${defaultItemsPerPage}) is not included in customOptions prop. Please add it to ensure it appears in the dropdown.`
10744
+ );
10745
+ }
10746
+ const [activePage, setActivePage] = useControllableState({
10747
+ value: activePageProp,
10748
+ defaultValue: defaultActivePage
10749
+ });
10695
10750
  const [itemsPerPage, setItemsPerPage] = (0, import_react73.useState)(defaultItemsPerPage);
10696
10751
  const pagesLength = Math.ceil(itemsAmount / itemsPerPage);
10697
10752
  const items = PaginationGenerator(pagesLength, activePage);
@@ -10909,7 +10964,7 @@ var Pagination = ({
10909
10964
  {
10910
10965
  options: selectOptions,
10911
10966
  isSearchable: false,
10912
- width: "74px",
10967
+ width: "90px",
10913
10968
  defaultValue: {
10914
10969
  label: itemsPerPage.toString(),
10915
10970
  value: itemsPerPage
@@ -11446,6 +11501,7 @@ var PhoneInput = ({
11446
11501
  "aria-required": ariaRequired,
11447
11502
  "aria-describedby": ariaDescribedby,
11448
11503
  groupLabel = "Landskode og telefonnummer",
11504
+ afterLabelContent,
11449
11505
  ref,
11450
11506
  ...props
11451
11507
  }) => {
@@ -11534,7 +11590,8 @@ var PhoneInput = ({
11534
11590
  label,
11535
11591
  htmlFor: phoneNumberId,
11536
11592
  showRequiredStyling,
11537
- readOnly
11593
+ readOnly,
11594
+ afterLabelContent
11538
11595
  }),
11539
11596
  /* @__PURE__ */ (0, import_jsx_runtime289.jsxs)(
11540
11597
  Box,
@@ -13657,6 +13714,7 @@ var TextInput_default = {
13657
13714
  var import_jsx_runtime320 = require("react/jsx-runtime");
13658
13715
  var TextInput = ({
13659
13716
  label,
13717
+ afterLabelContent,
13660
13718
  disabled,
13661
13719
  readOnly,
13662
13720
  errorMessage,
@@ -13834,7 +13892,13 @@ var TextInput = ({
13834
13892
  ),
13835
13893
  style,
13836
13894
  children: [
13837
- renderLabel({ label, htmlFor: uniqueId, showRequiredStyling, readOnly }),
13895
+ renderLabel({
13896
+ label,
13897
+ htmlFor: uniqueId,
13898
+ showRequiredStyling,
13899
+ readOnly,
13900
+ afterLabelContent
13901
+ }),
13838
13902
  extendedInput ? extendedInput : /* @__PURE__ */ (0, import_jsx_runtime320.jsx)(Box, { as: StatefulInput, width: inputWidth, ...generalInputProps }),
13839
13903
  hasBottomContainer && /* @__PURE__ */ (0, import_jsx_runtime320.jsxs)(
13840
13904
  Box,
@@ -13928,8 +13992,7 @@ var Toggle = ({
13928
13992
  type: "checkbox",
13929
13993
  checked,
13930
13994
  onChange: (e) => setChecked(e.target.checked),
13931
- disabled,
13932
- "aria-disabled": isLoading,
13995
+ disabled: isLoading != null ? isLoading : disabled,
13933
13996
  "aria-readonly": readOnly,
13934
13997
  onKeyDown: readOnlyKeyDownHandler(
13935
13998
  "selectionControl",