@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.js CHANGED
@@ -341,6 +341,7 @@ __export(index_exports, {
341
341
  cn: () => cn,
342
342
  countryOptions: () => countryOptions,
343
343
  createSelectOptions: () => createSelectOptions,
344
+ createSizes: () => createSizes,
344
345
  dateValueToNativeDate: () => dateValueToNativeDate,
345
346
  defaultTypographyType: () => defaultTypographyType,
346
347
  defaultTypographyTypeClassName: () => defaultTypographyTypeClassName,
@@ -1332,6 +1333,11 @@ var getBaseHTMLProps = (id, htmlPropsOrClassName, htmlPropsOrUnknownProps, unkno
1332
1333
  }
1333
1334
  };
1334
1335
 
1336
+ // src/types/Size.tsx
1337
+ function createSizes(...sizes) {
1338
+ return sizes;
1339
+ }
1340
+
1335
1341
  // src/types/Surface.tsx
1336
1342
  var BORDER_RADII = [
1337
1343
  "button",
@@ -3582,6 +3588,7 @@ var getSize = (iconSize) => {
3582
3588
  return "var(--dds-icon-size-medium)";
3583
3589
  }
3584
3590
  };
3591
+ var ICON_SIZES = createSizes("small", "medium", "large", "inherit");
3585
3592
  function Icon(props) {
3586
3593
  const {
3587
3594
  id,
@@ -7156,6 +7163,7 @@ var useDrawerContext = () => (0, import_react50.useContext)(DrawerContext);
7156
7163
 
7157
7164
  // src/components/Drawer/Drawer.tsx
7158
7165
  var import_jsx_runtime243 = require("react/jsx-runtime");
7166
+ var DRAWER_SIZES = createSizes("small", "medium", "large");
7159
7167
  var Drawer = ({
7160
7168
  children,
7161
7169
  header,
@@ -7406,6 +7414,7 @@ var FavStar_default = {
7406
7414
 
7407
7415
  // src/components/FavStar/FavStar.tsx
7408
7416
  var import_jsx_runtime246 = require("react/jsx-runtime");
7417
+ var FAVSTAR_SIZES = createSizes("medium", "large");
7409
7418
  var FavStar = ({
7410
7419
  id,
7411
7420
  className,
@@ -8916,6 +8925,7 @@ var InlineEdit_default = {
8916
8925
  "inline-input--with-icon": "InlineEdit_inline-input--with-icon",
8917
8926
  "inline-textarea": "InlineEdit_inline-textarea",
8918
8927
  "edit-icon": "InlineEdit_edit-icon",
8928
+ "edit-icon-textarea": "InlineEdit_edit-icon-textarea",
8919
8929
  chevron: "InlineEdit_chevron",
8920
8930
  "clear-button": "InlineEdit_clear-button"
8921
8931
  };
@@ -9053,7 +9063,10 @@ function InlineField(props) {
9053
9063
  {
9054
9064
  iconSize,
9055
9065
  icon,
9056
- className: cn(className2, utilStyles_default["center-absolute-y"])
9066
+ className: cn(
9067
+ className2,
9068
+ elementType === "textarea" ? InlineEdit_default["edit-icon-textarea"] : utilStyles_default["center-absolute-y"]
9069
+ )
9057
9070
  }
9058
9071
  );
9059
9072
  }
@@ -10020,7 +10033,7 @@ var getCustomStyles = (size2, hasError, hasIcon, isReadOnly) => ({
10020
10033
  });
10021
10034
 
10022
10035
  // src/components/Select/SelectComponents.tsx
10023
- var import_react69 = require("react");
10036
+ var import_react69 = __toESM(require("react"));
10024
10037
  var import_react_select = require("react-select");
10025
10038
  var import_jsx_runtime284 = require("react/jsx-runtime");
10026
10039
  var {
@@ -10043,27 +10056,47 @@ var getIndicatorIconSize = (componentSize) => {
10043
10056
  return "small";
10044
10057
  }
10045
10058
  };
10046
- var DDSOption = (props, componentSize) => /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(Option, { ...props, children: [
10059
+ var DDSOption = ({
10060
+ componentSize,
10061
+ ...props
10062
+ }) => /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(Option, { ...props, children: [
10047
10063
  props.isSelected && /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Icon, { icon: CheckIcon, iconSize: getFormInputIconSize(componentSize) }),
10048
10064
  props.children
10049
10065
  ] });
10050
- var CustomOption = (props, Element) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Option, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Element, { ...props }) });
10051
- var CustomSingleValue = (props, id, Element) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(SingleValue, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("div", { id, className: Select_default["inner-single-value"], children: Element ? /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Element, { ...props }) : props.children }) });
10066
+ var CustomOption = (props) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Option, { ...props, children: import_react69.default.createElement(props.customElement, props) });
10067
+ var CustomSingleValue = ({
10068
+ id,
10069
+ Element,
10070
+ ...props
10071
+ }) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(SingleValue, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("div", { id, className: Select_default["inner-single-value"], children: Element ? /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Element, { ...props }) : props.children }) });
10052
10072
  var DDSNoOptionsMessage = (props) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(NoOptionsMessage, { ...props, children: "Ingen treff" });
10053
- var DDSClearIndicator = (props, size2) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(ClearIndicator, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Icon, { icon: CloseSmallIcon, iconSize: getIndicatorIconSize(size2) }) });
10073
+ var DDSClearIndicator = ({
10074
+ size: size2,
10075
+ ...props
10076
+ }) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(ClearIndicator, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Icon, { icon: CloseSmallIcon, iconSize: getIndicatorIconSize(size2) }) });
10054
10077
  var DDSMultiValueRemove = (props) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(MultiValueRemove, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Icon, { icon: CloseSmallIcon, iconSize: "small" }) });
10055
- var DDSDropdownIndicator = (props, size2) => {
10056
- const { className, ...rest } = props;
10078
+ var DDSDropdownIndicator = (props) => {
10079
+ const { className, componentSize, ...rest } = props;
10057
10080
  return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
10058
10081
  DropdownIndicator,
10059
10082
  {
10060
10083
  ...rest,
10061
10084
  className: cn(className, Select_default["dropdown-indicator"]),
10062
- children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Icon, { icon: ChevronDownIcon, iconSize: getIndicatorIconSize(size2) })
10085
+ children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
10086
+ Icon,
10087
+ {
10088
+ icon: ChevronDownIcon,
10089
+ iconSize: getIndicatorIconSize(componentSize)
10090
+ }
10091
+ )
10063
10092
  }
10064
10093
  );
10065
10094
  };
10066
- var DDSInput = (props, ariaInvalid, ariaDescribedby) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
10095
+ var DDSInput = ({
10096
+ ariaInvalid,
10097
+ ariaDescribedby,
10098
+ ...props
10099
+ }) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
10067
10100
  Input2,
10068
10101
  {
10069
10102
  ...props,
@@ -10071,45 +10104,48 @@ var DDSInput = (props, ariaInvalid, ariaDescribedby) => /* @__PURE__ */ (0, impo
10071
10104
  "aria-describedby": ariaDescribedby
10072
10105
  }
10073
10106
  );
10074
- function createDDSControl(componentSize, readOnly, icon, dataTestId) {
10075
- return function DDSControlWrapper(props) {
10076
- const { className, children, innerProps, ...rest } = props;
10077
- return /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(
10078
- Control,
10079
- {
10080
- ...rest,
10081
- innerProps: {
10082
- ...innerProps,
10083
- "data-testid": dataTestId ? dataTestId + "-control" : void 0
10084
- },
10085
- className: cn(
10086
- className,
10087
- Select_default.control,
10088
- rest.isDisabled && Select_default["control--disabled"],
10089
- readOnly && Select_default["control--readonly"]
10107
+ function DDSControl(props) {
10108
+ const {
10109
+ componentSize,
10110
+ readOnly,
10111
+ icon,
10112
+ dataTestId,
10113
+ className,
10114
+ children,
10115
+ innerProps,
10116
+ ...rest
10117
+ } = props;
10118
+ return /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(
10119
+ Control,
10120
+ {
10121
+ ...rest,
10122
+ innerProps: {
10123
+ ...innerProps,
10124
+ "data-testid": dataTestId ? dataTestId + "-control" : void 0
10125
+ },
10126
+ className: cn(
10127
+ className,
10128
+ Select_default.control,
10129
+ rest.isDisabled && Select_default["control--disabled"],
10130
+ readOnly && Select_default["control--readonly"]
10131
+ ),
10132
+ children: [
10133
+ icon && /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
10134
+ Icon,
10135
+ {
10136
+ icon,
10137
+ iconSize: getFormInputIconSize(componentSize),
10138
+ className: cn(
10139
+ Input_default["input-group__absolute-element"],
10140
+ Select_default[`icon--${componentSize}`]
10141
+ )
10142
+ }
10090
10143
  ),
10091
- children: [
10092
- icon && /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(
10093
- Icon,
10094
- {
10095
- icon,
10096
- iconSize: getFormInputIconSize(componentSize),
10097
- className: cn(
10098
- Input_default["input-group__absolute-element"],
10099
- Select_default[`icon--${componentSize}`]
10100
- )
10101
- }
10102
- ),
10103
- children
10104
- ]
10105
- }
10106
- );
10107
- };
10144
+ children
10145
+ ]
10146
+ }
10147
+ );
10108
10148
  }
10109
- var DDSControl = (componentSize, readOnly, icon, dataTestId) => (0, import_react69.useMemo)(
10110
- () => createDDSControl(componentSize, readOnly, icon, dataTestId),
10111
- [componentSize, readOnly, icon, dataTestId]
10112
- );
10113
10149
 
10114
10150
  // src/components/Select/Select.tsx
10115
10151
  var import_jsx_runtime285 = require("react/jsx-runtime");
@@ -10162,6 +10198,66 @@ function Select({
10162
10198
  width,
10163
10199
  componentSize === "xsmall" && "var(--dds-input-default-width-xsmall)"
10164
10200
  );
10201
+ const customInput = (0, import_react70.useCallback)(
10202
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
10203
+ DDSInput,
10204
+ {
10205
+ ...props,
10206
+ readOnly,
10207
+ "aria-required": ariaRequired,
10208
+ "aria-activedescendant": props["aria-activedescendant"] === "" ? void 0 : props["aria-activedescendant"],
10209
+ ariaInvalid: hasErrorMessage,
10210
+ ariaDescribedby: spaceSeparatedIdListGenerator([
10211
+ singleValueId,
10212
+ tip ? tipId : void 0,
10213
+ errorMessage ? errorMessageId : void 0
10214
+ ])
10215
+ }
10216
+ ),
10217
+ []
10218
+ );
10219
+ const customSingleValue = (0, import_react70.useCallback)(
10220
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
10221
+ CustomSingleValue,
10222
+ {
10223
+ ...props,
10224
+ id: singleValueId,
10225
+ Element: customSingleValueElement
10226
+ }
10227
+ ),
10228
+ []
10229
+ );
10230
+ const customClearIndicator = (0, import_react70.useCallback)(
10231
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(DDSClearIndicator, { ...props, size: componentSize }),
10232
+ [componentSize]
10233
+ );
10234
+ const customDropdownIndicator = (0, import_react70.useCallback)(
10235
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(DDSDropdownIndicator, { ...props, componentSize }),
10236
+ [componentSize]
10237
+ );
10238
+ const customControl = (0, import_react70.useCallback)(
10239
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(
10240
+ DDSControl,
10241
+ {
10242
+ ...props,
10243
+ componentSize,
10244
+ readOnly,
10245
+ icon,
10246
+ dataTestId
10247
+ }
10248
+ ),
10249
+ [componentSize, readOnly, icon, dataTestId]
10250
+ );
10251
+ const customOptionComponent = (0, import_react70.useCallback)(
10252
+ (props) => {
10253
+ if (customOptionElement) {
10254
+ return /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(CustomOption, { ...props, customElement: customOptionElement });
10255
+ } else {
10256
+ return /* @__PURE__ */ (0, import_jsx_runtime285.jsx)(DDSOption, { ...props, componentSize });
10257
+ }
10258
+ },
10259
+ [customOptionElement, componentSize]
10260
+ );
10165
10261
  const reactSelectProps = {
10166
10262
  options,
10167
10263
  value,
@@ -10187,27 +10283,14 @@ function Select({
10187
10283
  return searchFilter(label2, inputValue) || inputValue === "";
10188
10284
  },
10189
10285
  components: {
10190
- Option: customOptionElement ? (props) => CustomOption(props, customOptionElement) : (props) => DDSOption(props, componentSize),
10286
+ Option: customOptionComponent,
10191
10287
  NoOptionsMessage: DDSNoOptionsMessage,
10192
- Input: (props) => DDSInput(
10193
- {
10194
- ...props,
10195
- readOnly,
10196
- "aria-required": ariaRequired,
10197
- "aria-activedescendant": props["aria-activedescendant"] === "" ? void 0 : props["aria-activedescendant"]
10198
- },
10199
- hasErrorMessage,
10200
- spaceSeparatedIdListGenerator([
10201
- singleValueId,
10202
- tip ? tipId : void 0,
10203
- errorMessage ? errorMessageId : void 0
10204
- ])
10205
- ),
10206
- SingleValue: (props) => CustomSingleValue(props, singleValueId, customSingleValueElement),
10207
- ClearIndicator: (props) => DDSClearIndicator(props, componentSize),
10208
- DropdownIndicator: (props) => DDSDropdownIndicator(props, componentSize),
10288
+ Input: customInput,
10289
+ SingleValue: customSingleValue,
10290
+ ClearIndicator: customClearIndicator,
10291
+ DropdownIndicator: customDropdownIndicator,
10209
10292
  MultiValueRemove: DDSMultiValueRemove,
10210
- Control: DDSControl(componentSize, readOnly, icon, dataTestId)
10293
+ Control: customControl
10211
10294
  },
10212
10295
  "aria-invalid": hasErrorMessage ? true : void 0,
10213
10296
  required,
@@ -11911,6 +11994,7 @@ var ProgressBar_default = {
11911
11994
 
11912
11995
  // src/components/ProgressBar/ProgressBar.tsx
11913
11996
  var import_jsx_runtime293 = require("react/jsx-runtime");
11997
+ var PROGRESS_BAR_SIZES = createSizes("small", "medium");
11914
11998
  var ProgressBar = ({
11915
11999
  label,
11916
12000
  tip,
@@ -12000,6 +12084,7 @@ var Search_default = {
12000
12084
  };
12001
12085
 
12002
12086
  // src/components/Search/Search.utils.ts
12087
+ var SEARCH_SIZES = createSizes("small", "medium", "large");
12003
12088
  var typographyTypes2 = {
12004
12089
  small: "bodySmall",
12005
12090
  medium: "bodyMedium",
@@ -12944,7 +13029,6 @@ var useTabsContext = () => (0, import_react90.useContext)(TabsContext);
12944
13029
 
12945
13030
  // src/components/Tabs/Tabs.module.css
12946
13031
  var Tabs_default = {
12947
- tabs: "Tabs_tabs",
12948
13032
  "tab-row": "Tabs_tab-row",
12949
13033
  "tab-row--standard-widths": "Tabs_tab-row--standard-widths",
12950
13034
  "tab-row--custom-widths": "Tabs_tab-row--custom-widths",
@@ -13035,6 +13119,7 @@ AddTabButton.displayName = "AddTabButton";
13035
13119
  // src/components/Tabs/Tabs.tsx
13036
13120
  var import_react93 = require("react");
13037
13121
  var import_jsx_runtime313 = require("react/jsx-runtime");
13122
+ var TABS_SIZES = createSizes("small", "medium");
13038
13123
  var Tabs = ({
13039
13124
  id,
13040
13125
  activeTab,
@@ -13081,12 +13166,7 @@ var Tabs = ({
13081
13166
  children: /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
13082
13167
  Box,
13083
13168
  {
13084
- ...getBaseHTMLProps(
13085
- uniqueId,
13086
- cn(className, Tabs_default.tabs),
13087
- htmlProps,
13088
- rest
13089
- ),
13169
+ ...getBaseHTMLProps(uniqueId, className, htmlProps, rest),
13090
13170
  width,
13091
13171
  children
13092
13172
  }
@@ -13627,6 +13707,7 @@ var Toggle_default = {
13627
13707
 
13628
13708
  // src/components/Toggle/Toggle.tsx
13629
13709
  var import_jsx_runtime320 = require("react/jsx-runtime");
13710
+ var TOGGLE_SIZES = createSizes("medium", "large");
13630
13711
  var Toggle = ({
13631
13712
  id,
13632
13713
  children,
@@ -14272,6 +14353,7 @@ ToggleButtonGroup.displayName = "ToggleButtonGroup";
14272
14353
  cn,
14273
14354
  countryOptions,
14274
14355
  createSelectOptions,
14356
+ createSizes,
14275
14357
  dateValueToNativeDate,
14276
14358
  defaultTypographyType,
14277
14359
  defaultTypographyTypeClassName,