@norges-domstoler/dds-components 23.1.0 → 23.1.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
@@ -4456,7 +4456,7 @@ var Button = ({
4456
4456
  as: propAs,
4457
4457
  children,
4458
4458
  purpose = "primary",
4459
- size: size2 = "medium",
4459
+ size: propSize = "medium",
4460
4460
  iconPosition = "left",
4461
4461
  loading,
4462
4462
  loadingTooltip,
@@ -4483,11 +4483,12 @@ var Button = ({
4483
4483
  const isIconButton = !hasLabel && hasIcon;
4484
4484
  const isTextButton = hasLabel && !hasIcon;
4485
4485
  const noContent = !hasLabel && !hasIcon;
4486
+ const size2 = groupSize != null ? groupSize : propSize;
4486
4487
  const buttonCn = cn(
4487
4488
  className,
4488
4489
  Button_default.button,
4489
4490
  Button_default[`button--${groupPurpose ? groupPurpose : purpose}`],
4490
- Button_default[`button--${groupSize ? groupSize : size2}`],
4491
+ Button_default[`button--${size2}`],
4491
4492
  isTextButton && Button_default["just-text"],
4492
4493
  ...hasLabelAndIcon ? [Button_default["with-text-and-icon"], Button_default[`with-icon-${iconPosition}`]] : [],
4493
4494
  isIconButton && Button_default["just-icon"],
@@ -6414,7 +6415,6 @@ var DateInput_default = {
6414
6415
  segment: "DateInput_segment",
6415
6416
  segment__placeholder: "DateInput_segment__placeholder",
6416
6417
  "segment__placeholder--invisible": "DateInput_segment__placeholder--invisible",
6417
- "clear-button--inactive": "DateInput_clear-button--inactive",
6418
6418
  "icon-wrapper--disabled": "DateInput_icon-wrapper--disabled",
6419
6419
  "popover-button": "DateInput_popover-button",
6420
6420
  "icon-wrapper--readonly": "DateInput_icon-wrapper--readonly",
@@ -6430,8 +6430,8 @@ var DateInput_default = {
6430
6430
  "calendar__cell-button": "DateInput_calendar__cell-button",
6431
6431
  "calendar__cell-button--today": "DateInput_calendar__cell-button--today",
6432
6432
  "calendar__cell-button--default": "DateInput_calendar__cell-button--default",
6433
- "calendar__cell-button--selected": "DateInput_calendar__cell-button--selected",
6434
6433
  "calendar__cell-button--unavailable": "DateInput_calendar__cell-button--unavailable",
6434
+ "calendar__cell-button--selected": "DateInput_calendar__cell-button--selected",
6435
6435
  "calendar__cell-button--unavailable--today": "DateInput_calendar__cell-button--unavailable--today"
6436
6436
  };
6437
6437
 
@@ -6458,28 +6458,31 @@ function CalendarCell({ date, state, onClose }) {
6458
6458
  isDisabled,
6459
6459
  isUnavailable
6460
6460
  } = useCalendarCell({ date }, state, ref);
6461
- if (isDisabled) {
6461
+ if (isOutsideVisibleRange) {
6462
6462
  return /* @__PURE__ */ jsx241("td", { ...cellProps });
6463
6463
  }
6464
- const variant = isSelected ? "selected" : isUnavailable || isDisabled ? "unavailable" : "default";
6465
6464
  const closeOnKeyboardBlurForward = (event) => {
6466
6465
  if (event.key === "Tab" && event.shiftKey === false) {
6467
6466
  onClose();
6468
6467
  }
6469
6468
  };
6469
+ const isEffectivelyUnavailable = isUnavailable || isDisabled;
6470
+ const isUnavailableToday = isEffectivelyUnavailable && isToday(date, timezone);
6470
6471
  return /* @__PURE__ */ jsx241("td", { ...cellProps, children: /* @__PURE__ */ jsx241(
6471
6472
  "button",
6472
6473
  {
6473
6474
  ...buttonProps,
6474
6475
  type: "button",
6475
6476
  ref,
6476
- hidden: isOutsideVisibleRange,
6477
6477
  onKeyDown: closeOnKeyboardBlurForward,
6478
6478
  className: cn(
6479
6479
  DateInput_default["calendar__grid-element"],
6480
6480
  DateInput_default["calendar__cell-button"],
6481
6481
  isToday(date, timezone) && DateInput_default["calendar__cell-button--today"],
6482
- DateInput_default[`calendar__cell-button--${variant}`],
6482
+ DateInput_default[`calendar__cell-button--default`],
6483
+ isSelected && DateInput_default[`calendar__cell-button--selected`],
6484
+ isEffectivelyUnavailable && DateInput_default[`calendar__cell-button--unavailable`],
6485
+ isUnavailableToday && DateInput_default["calendar__cell-button--unavailable--today"],
6483
6486
  typographyStyles_default["body-short-small"],
6484
6487
  focusable
6485
6488
  ),
@@ -6861,6 +6864,8 @@ function Calendar(props) {
6861
6864
  nextButtonProps: { onPress: onNext },
6862
6865
  title
6863
6866
  } = useCalendar(props, state);
6867
+ const isPrevDisabled = !!props.minValue && state.visibleRange.start.compare(props.minValue) <= 0;
6868
+ const isNextDisabled = !!props.maxValue && state.visibleRange.end.compare(props.maxValue) >= 0;
6864
6869
  const { onClose, closeButtonRef } = useContext12(CalendarPopoverContext);
6865
6870
  const closeOnKeyboardBlurBack = (event) => {
6866
6871
  var _a;
@@ -6875,6 +6880,7 @@ function Calendar(props) {
6875
6880
  /* @__PURE__ */ jsx244(
6876
6881
  Button,
6877
6882
  {
6883
+ "aria-hidden": optAttr(isPrevDisabled),
6878
6884
  type: "button",
6879
6885
  "aria-label": t(texts7.previousMonth),
6880
6886
  onClick: (e) => onPrev == null ? void 0 : onPrev(e),
@@ -6882,7 +6888,10 @@ function Calendar(props) {
6882
6888
  purpose: "tertiary",
6883
6889
  icon: ArrowLeftIcon,
6884
6890
  htmlProps: { onKeyDown: closeOnKeyboardBlurBack },
6885
- className: DateInput_default["calendar__month-button"]
6891
+ className: cn(
6892
+ DateInput_default["calendar__month-button"],
6893
+ isPrevDisabled && utilStyles_default.invisible
6894
+ )
6886
6895
  }
6887
6896
  ),
6888
6897
  /* @__PURE__ */ jsx244(
@@ -6898,12 +6907,16 @@ function Calendar(props) {
6898
6907
  Button,
6899
6908
  {
6900
6909
  type: "button",
6910
+ "aria-hidden": optAttr(isNextDisabled),
6901
6911
  "aria-label": t(texts7.nextMonth),
6902
6912
  onClick: (e) => onNext == null ? void 0 : onNext(e),
6903
6913
  size: "small",
6904
6914
  purpose: "tertiary",
6905
6915
  icon: ArrowRightIcon,
6906
- className: DateInput_default["calendar__month-button"]
6916
+ className: cn(
6917
+ DateInput_default["calendar__month-button"],
6918
+ isNextDisabled && utilStyles_default.invisible
6919
+ )
6907
6920
  }
6908
6921
  )
6909
6922
  ] }),
@@ -7119,9 +7132,13 @@ function DateSegment({
7119
7132
  const ref = useRef15(null);
7120
7133
  const { segmentProps } = useDateSegment(segment, state, ref);
7121
7134
  return /* @__PURE__ */ jsxs90(
7122
- "div",
7135
+ Box,
7123
7136
  {
7124
7137
  ...segmentProps,
7138
+ padding: "0 0.05rem",
7139
+ width: "max-content",
7140
+ height: "max-content",
7141
+ marginBlock: "auto",
7125
7142
  "aria-describedby": spaceSeparatedIdListGenerator([
7126
7143
  errorMessageId ? errorMessageId : void 0,
7127
7144
  tipId ? tipId : void 0
@@ -7130,8 +7147,7 @@ function DateSegment({
7130
7147
  className: cn(
7131
7148
  segmentProps.className,
7132
7149
  DateInput_default.segment,
7133
- typographyStyles_default[`body-short-${componentSize}`],
7134
- Input_default[`input--${componentSize}`]
7150
+ typographyStyles_default[`body-short-${componentSize}`]
7135
7151
  ),
7136
7152
  style: {
7137
7153
  ...segmentProps.style,
@@ -7398,7 +7414,7 @@ function DateField({
7398
7414
  absolute: true,
7399
7415
  "aria-label": t(texts9.clearDate),
7400
7416
  "aria-hidden": !hasValue,
7401
- className: cn(!hasValue && DateInput_default["clear-button--inactive"]),
7417
+ className: cn(!hasValue && utilStyles_default.invisible),
7402
7418
  size: componentSize,
7403
7419
  onClick: clearDate
7404
7420
  }
@@ -10147,6 +10163,7 @@ var inlineInputCns = (hasErrorState, showEditingIcon) => [
10147
10163
  var inlineTextareaCns = (hasErrorState, showEditingIcon) => [
10148
10164
  ...inlineInputCns(hasErrorState, showEditingIcon),
10149
10165
  typographyStyles_default["body-long-medium"],
10166
+ InlineEdit_default["inline-textarea"],
10150
10167
  utilStyles_default.scrollbar
10151
10168
  ];
10152
10169
  var inlineSelectCns = (hasErrorState, showEditingIcon, hasValue) => [
@@ -11073,7 +11090,6 @@ import { useState as useState23 } from "react";
11073
11090
  var Pagination_default = {
11074
11091
  list: "Pagination_list",
11075
11092
  list__item: "Pagination_list__item",
11076
- "list__item--hidden": "Pagination_list__item--hidden",
11077
11093
  indicators: "Pagination_indicators",
11078
11094
  "truncation-icon": "Pagination_truncation-icon"
11079
11095
  };
@@ -11275,12 +11291,16 @@ var getCustomStyles = (size2, hasError, isReadOnly) => ({
11275
11291
  textOverflow: "ellipsis",
11276
11292
  whiteSpace: "nowrap",
11277
11293
  boxSizing: "border-box",
11278
- paddingInline: "var(--dds-spacing-x0-25)",
11294
+ paddingInlineStart: "var(--dds-spacing-x0-25)",
11295
+ paddingBlock: "var(--dds-spacing-x0-125)",
11279
11296
  ...state.selectProps.isDisabled && {
11280
11297
  color: "var(--dds-color-text-subtle)"
11281
11298
  },
11282
11299
  ...isReadOnly && {
11283
11300
  color: "var(--dds-color-text-medium)"
11301
+ },
11302
+ ...(state.selectProps.isDisabled || isReadOnly) && {
11303
+ paddingInlineEnd: "var(--dds-spacing-x0-25)"
11284
11304
  }
11285
11305
  }),
11286
11306
  multiValueRemove: (provided, state) => state.selectProps.isDisabled || isReadOnly ? {
@@ -11968,7 +11988,7 @@ var Pagination = ({
11968
11988
  {
11969
11989
  className: cn(
11970
11990
  Pagination_default.list__item,
11971
- isOnFirstPage && Pagination_default["list__item--hidden"]
11991
+ isOnFirstPage && utilStyles_default.invisible
11972
11992
  ),
11973
11993
  "aria-hidden": isOnFirstPage,
11974
11994
  children: previousPageButton
@@ -11980,7 +12000,7 @@ var Pagination = ({
11980
12000
  {
11981
12001
  className: cn(
11982
12002
  Pagination_default.list__item,
11983
- isOnLastPage && Pagination_default["list__item--hidden"]
12003
+ isOnLastPage && utilStyles_default.invisible
11984
12004
  ),
11985
12005
  "aria-hidden": isOnLastPage,
11986
12006
  children: nextPageButton
@@ -12001,7 +12021,7 @@ var Pagination = ({
12001
12021
  {
12002
12022
  className: cn(
12003
12023
  Pagination_default.list__item,
12004
- isOnFirstPage && Pagination_default["list__item--hidden"]
12024
+ isOnFirstPage && utilStyles_default.invisible
12005
12025
  ),
12006
12026
  "aria-hidden": isOnFirstPage,
12007
12027
  children: /* @__PURE__ */ jsx309(
@@ -12023,7 +12043,7 @@ var Pagination = ({
12023
12043
  {
12024
12044
  className: cn(
12025
12045
  Pagination_default.list__item,
12026
- isOnFirstPage && Pagination_default["list__item--hidden"]
12046
+ isOnFirstPage && utilStyles_default.invisible
12027
12047
  ),
12028
12048
  "aria-hidden": isOnFirstPage,
12029
12049
  children: previousPageButton
@@ -12044,7 +12064,7 @@ var Pagination = ({
12044
12064
  {
12045
12065
  className: cn(
12046
12066
  Pagination_default.list__item,
12047
- isOnLastPage && Pagination_default["list__item--hidden"]
12067
+ isOnLastPage && utilStyles_default.invisible
12048
12068
  ),
12049
12069
  "aria-hidden": isOnLastPage,
12050
12070
  children: nextPageButton
@@ -12055,7 +12075,7 @@ var Pagination = ({
12055
12075
  {
12056
12076
  className: cn(
12057
12077
  Pagination_default.list__item,
12058
- isOnLastPage && Pagination_default["list__item--hidden"]
12078
+ isOnLastPage && utilStyles_default.invisible
12059
12079
  ),
12060
12080
  "aria-hidden": isOnLastPage,
12061
12081
  children: /* @__PURE__ */ jsx309(
@@ -12579,7 +12599,8 @@ var PhoneInput_default = {
12579
12599
  "inputs-container--small-screen-md": "PhoneInput_inputs-container--small-screen-md",
12580
12600
  "inputs-container--small-screen-lg": "PhoneInput_inputs-container--small-screen-lg",
12581
12601
  "inputs-container--small-screen-xl": "PhoneInput_inputs-container--small-screen-xl",
12582
- "calling-code": "PhoneInput_calling-code"
12602
+ "calling-code": "PhoneInput_calling-code",
12603
+ "calling-code--disabled": "PhoneInput_calling-code--disabled"
12583
12604
  };
12584
12605
 
12585
12606
  // src/components/PhoneInput/PhoneInput.tsx
@@ -12774,7 +12795,8 @@ var PhoneInput = ({
12774
12795
  className: cn(
12775
12796
  typographyStyles_default[`body-short-${componentSize}`],
12776
12797
  Input_default["input-group__absolute-el"],
12777
- PhoneInput_default["calling-code"]
12798
+ PhoneInput_default["calling-code"],
12799
+ (commonProps.disabled || commonProps.readOnly) && PhoneInput_default["calling-code--disabled"]
12778
12800
  ),
12779
12801
  ref: callingCodeRef,
12780
12802
  children: callingCode
@@ -15204,12 +15226,6 @@ ToggleBar.displayName = "ToggleBar";
15204
15226
  // src/components/ToggleBar/ToggleRadio.tsx
15205
15227
  import { useId as useId31 } from "react";
15206
15228
  import { jsx as jsx343, jsxs as jsxs133 } from "react/jsx-runtime";
15207
- var typographyTypes = {
15208
- large: "bodyShortLarge",
15209
- medium: "bodyShortMedium",
15210
- small: "bodyShortSmall",
15211
- xsmall: "bodyShortXsmall"
15212
- };
15213
15229
  var calculateChecked = (value, group, checked) => {
15214
15230
  if (typeof checked !== "undefined") return checked;
15215
15231
  if (typeof value !== "undefined" && value !== null && group) {
@@ -15272,11 +15288,13 @@ var ToggleRadio = ({
15272
15288
  }
15273
15289
  ),
15274
15290
  /* @__PURE__ */ jsxs133(
15275
- Typography,
15291
+ HStack,
15276
15292
  {
15277
15293
  as: "span",
15278
- typographyType: typographyTypes[group.size],
15294
+ justifyContent: "center",
15295
+ alignItems: "center",
15279
15296
  className: cn(
15297
+ typographyStyles_default[`body-short-${group.size}`],
15280
15298
  ToggleBar_default.content,
15281
15299
  Button_default[contentTypeCn],
15282
15300
  hasLabel && hasIcon && Button_default["with-icon-left"],
@@ -15300,10 +15318,7 @@ import { useId as useId32 } from "react";
15300
15318
 
15301
15319
  // src/components/ToggleButton/ToggleButton.module.css
15302
15320
  var ToggleButton_default = {
15303
- content: "ToggleButton_content",
15304
- small: "ToggleButton_small",
15305
- xsmall: "ToggleButton_xsmall",
15306
- "content--with-icon": "ToggleButton_content--with-icon"
15321
+ content: "ToggleButton_content"
15307
15322
  };
15308
15323
 
15309
15324
  // src/components/ToggleButton/ToggleButton.tsx
@@ -15336,19 +15351,29 @@ var ToggleButton = ({
15336
15351
  }
15337
15352
  ),
15338
15353
  /* @__PURE__ */ jsxs134(
15339
- "span",
15354
+ Paper,
15340
15355
  {
15356
+ as: "span",
15357
+ border: "border-default",
15358
+ background: "surface-default",
15359
+ borderRadius: "rounded",
15360
+ width: "fit-content",
15361
+ display: "inline-flex",
15362
+ alignItems: "center",
15341
15363
  className: cn(
15342
15364
  ToggleButton_default.content,
15343
- ToggleButton_default[size2],
15344
- hasIcon && ToggleButton_default["content--with-icon"],
15345
15365
  typographyStyles_default[`body-short-${size2}`],
15346
- focus_default["focus-styled-sibling"]
15366
+ focus_default["focus-styled-sibling"],
15367
+ Button_default[`button--${size2}`],
15368
+ Button_default["just-text"],
15369
+ ...hasIcon ? [
15370
+ Button_default["with-text-and-icon"],
15371
+ Button_default["with-icon-left"]
15372
+ ] : []
15347
15373
  ),
15348
15374
  children: [
15349
15375
  hasIcon && /* @__PURE__ */ jsx344(Icon, { icon, iconSize: "component" }),
15350
- " ",
15351
- label
15376
+ /* @__PURE__ */ jsx344("span", { children: label })
15352
15377
  ]
15353
15378
  }
15354
15379
  )
@@ -15763,7 +15788,6 @@ export {
15763
15788
  removeListStyling,
15764
15789
  renderInputMessage,
15765
15790
  scrollbarStyling,
15766
- typographyTypes,
15767
15791
  useAccordion,
15768
15792
  useAccordionContext,
15769
15793
  useCallbackRef,