@norges-domstoler/dds-components 21.3.0 → 21.4.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
@@ -348,6 +348,7 @@ __export(index_exports, {
348
348
  focusVisibleInset: () => focusVisibleInset,
349
349
  focusVisibleTransitionValue: () => focusVisibleTransitionValue,
350
350
  getBaseHTMLProps: () => getBaseHTMLProps,
351
+ getColorCn: () => getColorCn,
351
352
  getDefaultText: () => getDefaultText,
352
353
  getElementType: () => getElementType,
353
354
  getInputWidth: () => getInputWidth,
@@ -438,7 +439,30 @@ var typographyStyles_default = {
438
439
  "text-color--default": "typographyStyles_text-color--default",
439
440
  "text-color--medium": "typographyStyles_text-color--medium",
440
441
  "text-color--subtle": "typographyStyles_text-color--subtle",
441
- "text-color--on-inverse": "typographyStyles_text-color--on-inverse"
442
+ "text-color--requiredfield": "typographyStyles_text-color--requiredfield",
443
+ "text-color--action-resting": "typographyStyles_text-color--action-resting",
444
+ "text-color--action-hover": "typographyStyles_text-color--action-hover",
445
+ "text-color--action-visited": "typographyStyles_text-color--action-visited",
446
+ "text-color--on-action": "typographyStyles_text-color--on-action",
447
+ "text-color--on-status-default": "typographyStyles_text-color--on-status-default",
448
+ "text-color--on-status-strong": "typographyStyles_text-color--on-status-strong",
449
+ "text-color--on-notification": "typographyStyles_text-color--on-notification",
450
+ "text-color--on-inverse": "typographyStyles_text-color--on-inverse",
451
+ "icon-color--default": "typographyStyles_icon-color--default",
452
+ "icon-color--medium": "typographyStyles_icon-color--medium",
453
+ "icon-color--subtle": "typographyStyles_icon-color--subtle",
454
+ "icon-color--on-action": "typographyStyles_icon-color--on-action",
455
+ "icon-color--action-resting": "typographyStyles_icon-color--action-resting",
456
+ "icon-color--action-hover": "typographyStyles_icon-color--action-hover",
457
+ "icon-color--on-info-default": "typographyStyles_icon-color--on-info-default",
458
+ "icon-color--on-info-strong": "typographyStyles_icon-color--on-info-strong",
459
+ "icon-color--on-success-default": "typographyStyles_icon-color--on-success-default",
460
+ "icon-color--on-success-strong": "typographyStyles_icon-color--on-success-strong",
461
+ "icon-color--on-danger-default": "typographyStyles_icon-color--on-danger-default",
462
+ "icon-color--on-danger-strong": "typographyStyles_icon-color--on-danger-strong",
463
+ "icon-color--on-warning-default": "typographyStyles_icon-color--on-warning-default",
464
+ "icon-color--on-warning-strong": "typographyStyles_icon-color--on-warning-strong",
465
+ "icon-color--on-inverse": "typographyStyles_icon-color--on-inverse"
442
466
  };
443
467
 
444
468
  // src/components/helpers/styling/utilStyles.module.css
@@ -493,36 +517,36 @@ var Backdrop_default = {
493
517
  };
494
518
 
495
519
  // src/utils/color.tsx
496
- var textColors = {
497
- textOnAction: "var(--dds-color-text-on-action)",
498
- textOnInverse: "var(--dds-color-text-on-inverse)",
499
- textOnStatusDefault: "var(--dds-color-text-on-status-default)",
500
- textOnStatusStrong: "var(--dds-color-text-on-status-strong)",
501
- textActionResting: "var(--dds-color-text-action-resting)",
502
- textActionHover: "var(--dds-color-text-action-hover)",
503
- textActionVisited: "var(--dds-color-text-action-visited)",
504
- textDefault: "var(--dds-color-text-default)",
505
- textRequiredfield: "var(--dds-color-text-requiredfield)",
506
- textSubtle: "var(--dds-color-text-subtle)",
507
- textMedium: "var(--dds-color-text-medium)",
508
- textOnNotification: "var(--dds-color-text-on-notification)",
509
- iconOnAction: "var(--dds-color-icon-on-action)",
510
- iconOnInfoDefault: "var(--dds-color-icon-on-info-default)",
511
- iconOnSuccessDefault: "var(--dds-color-icon-on-success-default)",
512
- iconOnDangerDefault: "var(--dds-color-icon-on-danger-default)",
513
- iconOnWarningDefault: "var(--dds-color-icon-on-warning-default)",
514
- iconOnInfoStrong: "var(--dds-color-icon-on-info-strong)",
515
- iconOnSuccessStrong: "var(--dds-color-icon-on-success-strong)",
516
- iconOnDangerStrong: "var(--dds-color-icon-on-danger-strong)",
517
- iconOnWarningStrong: "var(--dds-color-icon-on-warning-strong)",
518
- iconOnInverse: "var(--dds-color-icon-on-inverse)",
519
- iconActionResting: "var(--dds-color-icon-action-resting)",
520
- iconActionHover: "var(--dds-color-icon-action-hover)",
521
- iconDefault: "var(--dds-color-icon-default)",
522
- iconSubtle: "var(--dds-color-icon-subtle)",
523
- iconMedium: "var(--dds-color-icon-medium)"
524
- };
525
- var textColorsArray = [
520
+ var TEXT_COLORS = [
521
+ "text-on-action",
522
+ "text-on-inverse",
523
+ "text-on-status-default",
524
+ "text-on-status-strong",
525
+ "text-action-resting",
526
+ "text-action-hover",
527
+ "text-action-visited",
528
+ "text-default",
529
+ "text-requiredfield",
530
+ "text-subtle",
531
+ "text-medium",
532
+ "text-on-notification",
533
+ "icon-on-action",
534
+ "icon-on-info-default",
535
+ "icon-on-success-default",
536
+ "icon-on-danger-default",
537
+ "icon-on-warning-default",
538
+ "icon-on-info-strong",
539
+ "icon-on-success-strong",
540
+ "icon-on-danger-strong",
541
+ "icon-on-warning-strong",
542
+ "icon-on-inverse",
543
+ "icon-action-resting",
544
+ "icon-action-hover",
545
+ "icon-default",
546
+ "icon-subtle",
547
+ "icon-medium"
548
+ ];
549
+ var TEXT_COLORS_CAMEL = [
526
550
  "textOnAction",
527
551
  "textOnInverse",
528
552
  "textOnStatusDefault",
@@ -551,11 +575,30 @@ var textColorsArray = [
551
575
  "iconSubtle",
552
576
  "iconMedium"
553
577
  ];
554
- function isTextColor(color) {
555
- return textColorsArray.indexOf(color) !== -1;
556
- }
578
+ var TEXT_COLOR_VALUES_CAMEL = TEXT_COLORS_CAMEL.reduce(
579
+ (acc, key) => {
580
+ const kebab = key.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
581
+ acc[key] = `var(--dds-color-${kebab})`;
582
+ return acc;
583
+ },
584
+ {}
585
+ );
586
+ var TEXT_COLOR_VALUES_KEBAB = TEXT_COLORS.reduce(
587
+ (acc, key) => {
588
+ acc[key] = `var(--dds-color-${key})`;
589
+ return acc;
590
+ },
591
+ {}
592
+ );
593
+ var isTextColorCamel = (value) => {
594
+ return typeof value === "string" && TEXT_COLORS_CAMEL.includes(value);
595
+ };
596
+ var isTextColor = (value) => {
597
+ return typeof value === "string" && TEXT_COLORS.includes(value);
598
+ };
557
599
  var getTextColor = (color) => {
558
- if (isTextColor(color)) return textColors[color];
600
+ if (isTextColorCamel(color)) return TEXT_COLOR_VALUES_CAMEL[color];
601
+ if (isTextColor(color)) return TEXT_COLOR_VALUES_KEBAB[color];
559
602
  return color;
560
603
  };
561
604
 
@@ -1051,6 +1094,12 @@ var isInlineElement = (as) => inlineElements.indexOf(as) !== -1;
1051
1094
  function getTypographyCn(value) {
1052
1095
  return convertCamelToHyphen(value);
1053
1096
  }
1097
+ var getColorCn = (color) => {
1098
+ if (!isTextColor(color)) return null;
1099
+ const [prefix2] = color.split("-", 1);
1100
+ const key = `${prefix2}-color--${color.slice(prefix2.length + 1)}`;
1101
+ return typographyStyles_default[key] || null;
1102
+ };
1054
1103
 
1055
1104
  // src/components/Icon/Icon.tsx
1056
1105
  var getSize = (iconSize) => {
@@ -2422,6 +2471,7 @@ var Typography = (props) => {
2422
2471
  id,
2423
2472
  cn(
2424
2473
  className,
2474
+ getColorCn(color),
2425
2475
  Typography_default.container,
2426
2476
  externalLinkProp && typographyStyles_default["a--external"],
2427
2477
  typographyStyles_default[typographyCn],
@@ -2440,7 +2490,7 @@ var Typography = (props) => {
2440
2490
  style: {
2441
2491
  ...htmlPropsStyle,
2442
2492
  ...style,
2443
- color: color && getTextColor(color)
2493
+ color: color && !isTextColor(color) ? getTextColor(color) : void 0
2444
2494
  },
2445
2495
  rel: relProp,
2446
2496
  target: targetProp,
@@ -2587,15 +2637,18 @@ var import_jsx_runtime173 = require("react/jsx-runtime");
2587
2637
  var Link = ({
2588
2638
  id,
2589
2639
  className,
2590
- htmlProps,
2640
+ htmlProps = {},
2591
2641
  children,
2592
2642
  typographyType,
2593
2643
  withMargins,
2594
2644
  withVisited,
2595
2645
  external,
2596
2646
  target,
2647
+ style,
2648
+ color,
2597
2649
  ...rest
2598
2650
  }) => {
2651
+ const { style: htmlPropsStyle, ...restHtmlProps } = htmlProps;
2599
2652
  return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(
2600
2653
  "a",
2601
2654
  {
@@ -2608,14 +2661,20 @@ var Link = ({
2608
2661
  withVisited && typographyStyles_default["a--visited"],
2609
2662
  typographyType && typographyStyles_default[getTypographyCn(typographyType)],
2610
2663
  typographyType && withMargins && typographyStyles_default[`${getTypographyCn(typographyType)}--margins`],
2611
- focusable
2664
+ focusable,
2665
+ getColorCn(color)
2612
2666
  ),
2613
- htmlProps,
2667
+ restHtmlProps,
2614
2668
  rest
2615
2669
  ),
2616
2670
  ...rest,
2617
2671
  rel: "noopener noreferer",
2618
2672
  target: external ? "_blank" : target,
2673
+ style: {
2674
+ ...htmlPropsStyle,
2675
+ ...style,
2676
+ color: color && !isTextColor(color) ? getTextColor(color) : void 0
2677
+ },
2619
2678
  children: [
2620
2679
  children,
2621
2680
  external && /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(Icon, { iconSize: "inherit", icon: OpenExternalIcon })
@@ -4635,9 +4694,6 @@ var Card_default = {
4635
4694
  "container--border": "Card_container--border",
4636
4695
  "container--navigation": "Card_container--navigation",
4637
4696
  "container--selection-control": "Card_container--selection-control",
4638
- "container--selection-control--disabled": "Card_container--selection-control--disabled",
4639
- "container--selection-control--readonly": "Card_container--selection-control--readonly",
4640
- "container--selection-control--error": "Card_container--selection-control--error",
4641
4697
  "container--expandable": "Card_container--expandable"
4642
4698
  };
4643
4699
 
@@ -4873,11 +4929,8 @@ var SelectionControl_default = {
4873
4929
  "group--column": "SelectionControl_group--column",
4874
4930
  label: "SelectionControl_label",
4875
4931
  "selection-control": "SelectionControl_selection-control",
4876
- "label--readonly": "SelectionControl_label--readonly",
4877
4932
  "label--checkbox": "SelectionControl_label--checkbox",
4878
4933
  "label--radio": "SelectionControl_label--radio",
4879
- "label--disabled": "SelectionControl_label--disabled",
4880
- "label--error": "SelectionControl_label--error",
4881
4934
  "label--no-text": "SelectionControl_label--no-text",
4882
4935
  "selection-control--radio": "SelectionControl_selection-control--radio"
4883
4936
  };
@@ -4901,8 +4954,6 @@ var SelectionControl = ({
4901
4954
  );
4902
4955
  var Label2 = ({
4903
4956
  disabled,
4904
- readOnly,
4905
- hasError,
4906
4957
  hasText,
4907
4958
  controlType,
4908
4959
  className,
@@ -4923,10 +4974,7 @@ var Label2 = ({
4923
4974
  SelectionControl_default[`label--${controlType}`],
4924
4975
  !hasText && SelectionControl_default["label--no-text"],
4925
4976
  typographyStyles_default["text-color--default"],
4926
- disabled && SelectionControl_default["label--disabled"],
4927
- disabled && typographyStyles_default["text-color--subtle"],
4928
- readOnly && SelectionControl_default["label--readonly"],
4929
- hasError && SelectionControl_default["label--error"]
4977
+ disabled && typographyStyles_default["text-color--subtle"]
4930
4978
  ),
4931
4979
  ...rest
4932
4980
  }
@@ -4999,9 +5047,7 @@ var Checkbox = ({
4999
5047
  return /* @__PURE__ */ (0, import_jsx_runtime209.jsxs)(
5000
5048
  Label2,
5001
5049
  {
5002
- hasError,
5003
5050
  disabled: isDisabled,
5004
- readOnly: isReadOnly,
5005
5051
  htmlFor: uniqueId,
5006
5052
  hasText: hasLabel || hasChildren,
5007
5053
  controlType: "checkbox",
@@ -5259,9 +5305,7 @@ var RadioButton = ({
5259
5305
  return /* @__PURE__ */ (0, import_jsx_runtime212.jsxs)(
5260
5306
  Label2,
5261
5307
  {
5262
- hasError,
5263
5308
  disabled: isDisabled,
5264
- readOnly: isReadOnly,
5265
5309
  style,
5266
5310
  className: cn(className, htmlPropsClassName),
5267
5311
  hasText: hasLabel || hasChildren,
@@ -5473,6 +5517,10 @@ var CardSelectable = (props) => {
5473
5517
  const { cardType: cardTypeContext, tipId } = useCardSelectableContext();
5474
5518
  const cardType = cardTypeProp != null ? cardTypeProp : cardTypeContext;
5475
5519
  const group = cardTypeContext === "radio" ? radioGroup : checkboxGroup;
5520
+ if (!cardType)
5521
+ throw new Error(`
5522
+ Error: <CardSelectable> requires a \`cardType\` prop.
5523
+ Provide \`cardType\` either via a parent <CardSelectableGroup> or directly on the component.`);
5476
5524
  const {
5477
5525
  disabled = group == null ? void 0 : group.disabled,
5478
5526
  readOnly = group == null ? void 0 : group.readOnly,
@@ -5487,9 +5535,6 @@ var CardSelectable = (props) => {
5487
5535
  Card_default.container,
5488
5536
  Card_default[`container--${appearance}`],
5489
5537
  Card_default[`container--selection-control`],
5490
- readOnly && Card_default[`container--selection-control--readonly`],
5491
- disabled && Card_default[`container--selection-control--disabled`],
5492
- error && Card_default[`container--selection-control--error`],
5493
5538
  focus_default["has-focusable-input"]
5494
5539
  );
5495
5540
  const radioContextProps = {
@@ -5867,13 +5912,26 @@ CalendarCell.displayName = "CalendarCell";
5867
5912
 
5868
5913
  // src/components/VisuallyHidden/VisuallyHidden.tsx
5869
5914
  var import_jsx_runtime222 = require("react/jsx-runtime");
5870
- var VisuallyHidden = (props) => {
5871
- const { id, className, htmlProps, as, ...rest } = props;
5872
- const cl = cn(className, utilStyles_default["visually-hidden"]);
5873
- if (as === "div") {
5874
- return /* @__PURE__ */ (0, import_jsx_runtime222.jsx)("div", { ...getBaseHTMLProps(id, cl, htmlProps, rest) });
5875
- }
5876
- return /* @__PURE__ */ (0, import_jsx_runtime222.jsx)("span", { ...getBaseHTMLProps(id, cl, htmlProps, rest) });
5915
+ var VisuallyHidden = ({
5916
+ id,
5917
+ as: asProp,
5918
+ className,
5919
+ htmlProps,
5920
+ ...rest
5921
+ }) => {
5922
+ const as = asProp != null ? asProp : "span";
5923
+ return /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(
5924
+ ElementAs,
5925
+ {
5926
+ as,
5927
+ ...getBaseHTMLProps(
5928
+ id,
5929
+ cn(className, utilStyles_default["visually-hidden"]),
5930
+ htmlProps,
5931
+ rest
5932
+ )
5933
+ }
5934
+ );
5877
5935
  };
5878
5936
  VisuallyHidden.displayName = "VisuallyHidden";
5879
5937
 
@@ -6120,7 +6178,7 @@ function CalendarGrid({ state, ...props }) {
6120
6178
  className: cn(DateInput_default["calendar__grid-element"], ...typographyCn),
6121
6179
  children: [
6122
6180
  "# ",
6123
- /* @__PURE__ */ (0, import_jsx_runtime225.jsx)(VisuallyHidden, { as: "span", children: "Ukenummer" })
6181
+ /* @__PURE__ */ (0, import_jsx_runtime225.jsx)(VisuallyHidden, { children: "Ukenummer" })
6124
6182
  ]
6125
6183
  }
6126
6184
  ),
@@ -8176,7 +8234,7 @@ var FileUploader = (props) => {
8176
8234
  }
8177
8235
  ),
8178
8236
  dropAreaLabel,
8179
- /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(VisuallyHidden, { as: "span", children: "velg fil med p\xE5f\xF8lgende knapp" }),
8237
+ /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(VisuallyHidden, { children: "velg fil med p\xE5f\xF8lgende knapp" }),
8180
8238
  button
8181
8239
  ]
8182
8240
  }
@@ -8442,7 +8500,7 @@ var InlineEdit_default = {
8442
8500
 
8443
8501
  // src/components/InlineEdit/InlineEdit.utils.tsx
8444
8502
  var import_jsx_runtime267 = require("react/jsx-runtime");
8445
- var inlineEditVisuallyHidden = (id, emptiable) => /* @__PURE__ */ (0, import_jsx_runtime267.jsxs)(VisuallyHidden, { id, as: "span", children: [
8503
+ var inlineEditVisuallyHidden = (id, emptiable) => /* @__PURE__ */ (0, import_jsx_runtime267.jsxs)(VisuallyHidden, { id, children: [
8446
8504
  "Escape, Enter eller Tab for \xE5 lagre.",
8447
8505
  " ",
8448
8506
  !emptiable && "Inputfeltet er ikke t\xF8mmbar."
@@ -11031,9 +11089,9 @@ var ProgressTrackerItem = (props) => {
11031
11089
  typographyStyles_default["body-medium"]
11032
11090
  ),
11033
11091
  children: [
11034
- /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(VisuallyHidden, { as: "span", children: getVisuallyHiddenTextBefore(index) }),
11092
+ /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(VisuallyHidden, { children: getVisuallyHiddenTextBefore(index) }),
11035
11093
  children,
11036
- /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(VisuallyHidden, { as: "span", children: getVisuallyHiddenTextAfter(completed) })
11094
+ /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(VisuallyHidden, { children: getVisuallyHiddenTextAfter(completed) })
11037
11095
  ]
11038
11096
  }
11039
11097
  )
@@ -11535,7 +11593,7 @@ var Search = ({
11535
11593
  componentSize
11536
11594
  }
11537
11595
  ),
11538
- /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(VisuallyHidden, { id: suggestionsDescriptionId, as: "span", children: "Bla i s\xF8keforslag med piltaster n\xE5r listen er utvidet." })
11596
+ /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(VisuallyHidden, { id: suggestionsDescriptionId, children: "Bla i s\xF8keforslag med piltaster n\xE5r listen er utvidet." })
11539
11597
  ] }),
11540
11598
  hasValue && /* @__PURE__ */ (0, import_jsx_runtime292.jsx)(
11541
11599
  Button,
@@ -12090,7 +12148,7 @@ var CollapsibleRow = ({
12090
12148
  definingColumnCells,
12091
12149
  /* @__PURE__ */ (0, import_jsx_runtime305.jsxs)(Table2.Cell, { type: "head", layout: "center", children: [
12092
12150
  "Utvid",
12093
- /* @__PURE__ */ (0, import_jsx_runtime305.jsx)(VisuallyHidden, { as: "span", children: "raden" })
12151
+ /* @__PURE__ */ (0, import_jsx_runtime305.jsx)(VisuallyHidden, { children: "raden" })
12094
12152
  ] })
12095
12153
  ] }) });
12096
12154
  };
@@ -12944,7 +13002,7 @@ var Toggle = ({
12944
13002
  ),
12945
13003
  children,
12946
13004
  " ",
12947
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(VisuallyHidden, { as: "span", children: "Innlastning p\xE5g\xE5r" })
13005
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(VisuallyHidden, { children: "Innlastning p\xE5g\xE5r" })
12948
13006
  ] })
12949
13007
  ]
12950
13008
  }
@@ -13526,6 +13584,7 @@ ToggleButtonGroup.displayName = "ToggleButtonGroup";
13526
13584
  focusVisibleInset,
13527
13585
  focusVisibleTransitionValue,
13528
13586
  getBaseHTMLProps,
13587
+ getColorCn,
13529
13588
  getDefaultText,
13530
13589
  getElementType,
13531
13590
  getInputWidth,