@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.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");
@@ -10141,6 +10177,7 @@ function Select({
10141
10177
  onKeyDown,
10142
10178
  openMenuOnClick,
10143
10179
  ref,
10180
+ instanceId,
10144
10181
  ...rest
10145
10182
  }) {
10146
10183
  const themeContext = (0, import_react70.useContext)(ThemeContext);
@@ -10161,6 +10198,66 @@ function Select({
10161
10198
  width,
10162
10199
  componentSize === "xsmall" && "var(--dds-input-default-width-xsmall)"
10163
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
+ );
10164
10261
  const reactSelectProps = {
10165
10262
  options,
10166
10263
  value,
@@ -10170,6 +10267,7 @@ function Select({
10170
10267
  placeholder: placeholder ? placeholder : "",
10171
10268
  closeMenuOnSelect: closeMenuOnSelect ? closeMenuOnSelect : isMulti ? false : true,
10172
10269
  isMulti,
10270
+ instanceId: instanceId != null ? instanceId : (0, import_react70.useId)(),
10173
10271
  inputId: uniqueId,
10174
10272
  name: uniqueId,
10175
10273
  menuPortalTarget: portalTarget,
@@ -10185,26 +10283,14 @@ function Select({
10185
10283
  return searchFilter(label2, inputValue) || inputValue === "";
10186
10284
  },
10187
10285
  components: {
10188
- Option: customOptionElement ? (props) => CustomOption(props, customOptionElement) : (props) => DDSOption(props, componentSize),
10286
+ Option: customOptionComponent,
10189
10287
  NoOptionsMessage: DDSNoOptionsMessage,
10190
- Input: (props) => DDSInput(
10191
- {
10192
- ...props,
10193
- readOnly,
10194
- "aria-required": ariaRequired
10195
- },
10196
- hasErrorMessage,
10197
- spaceSeparatedIdListGenerator([
10198
- singleValueId,
10199
- tip ? tipId : void 0,
10200
- errorMessage ? errorMessageId : void 0
10201
- ])
10202
- ),
10203
- SingleValue: (props) => CustomSingleValue(props, singleValueId, customSingleValueElement),
10204
- ClearIndicator: (props) => DDSClearIndicator(props, componentSize),
10205
- DropdownIndicator: (props) => DDSDropdownIndicator(props, componentSize),
10288
+ Input: customInput,
10289
+ SingleValue: customSingleValue,
10290
+ ClearIndicator: customClearIndicator,
10291
+ DropdownIndicator: customDropdownIndicator,
10206
10292
  MultiValueRemove: DDSMultiValueRemove,
10207
- Control: DDSControl(componentSize, readOnly, icon, dataTestId)
10293
+ Control: customControl
10208
10294
  },
10209
10295
  "aria-invalid": hasErrorMessage ? true : void 0,
10210
10296
  required,
@@ -11908,6 +11994,7 @@ var ProgressBar_default = {
11908
11994
 
11909
11995
  // src/components/ProgressBar/ProgressBar.tsx
11910
11996
  var import_jsx_runtime293 = require("react/jsx-runtime");
11997
+ var PROGRESS_BAR_SIZES = createSizes("small", "medium");
11911
11998
  var ProgressBar = ({
11912
11999
  label,
11913
12000
  tip,
@@ -11997,6 +12084,7 @@ var Search_default = {
11997
12084
  };
11998
12085
 
11999
12086
  // src/components/Search/Search.utils.ts
12087
+ var SEARCH_SIZES = createSizes("small", "medium", "large");
12000
12088
  var typographyTypes2 = {
12001
12089
  small: "bodySmall",
12002
12090
  medium: "bodyMedium",
@@ -12941,7 +13029,6 @@ var useTabsContext = () => (0, import_react90.useContext)(TabsContext);
12941
13029
 
12942
13030
  // src/components/Tabs/Tabs.module.css
12943
13031
  var Tabs_default = {
12944
- tabs: "Tabs_tabs",
12945
13032
  "tab-row": "Tabs_tab-row",
12946
13033
  "tab-row--standard-widths": "Tabs_tab-row--standard-widths",
12947
13034
  "tab-row--custom-widths": "Tabs_tab-row--custom-widths",
@@ -13032,6 +13119,7 @@ AddTabButton.displayName = "AddTabButton";
13032
13119
  // src/components/Tabs/Tabs.tsx
13033
13120
  var import_react93 = require("react");
13034
13121
  var import_jsx_runtime313 = require("react/jsx-runtime");
13122
+ var TABS_SIZES = createSizes("small", "medium");
13035
13123
  var Tabs = ({
13036
13124
  id,
13037
13125
  activeTab,
@@ -13078,12 +13166,7 @@ var Tabs = ({
13078
13166
  children: /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
13079
13167
  Box,
13080
13168
  {
13081
- ...getBaseHTMLProps(
13082
- uniqueId,
13083
- cn(className, Tabs_default.tabs),
13084
- htmlProps,
13085
- rest
13086
- ),
13169
+ ...getBaseHTMLProps(uniqueId, className, htmlProps, rest),
13087
13170
  width,
13088
13171
  children
13089
13172
  }
@@ -13624,6 +13707,7 @@ var Toggle_default = {
13624
13707
 
13625
13708
  // src/components/Toggle/Toggle.tsx
13626
13709
  var import_jsx_runtime320 = require("react/jsx-runtime");
13710
+ var TOGGLE_SIZES = createSizes("medium", "large");
13627
13711
  var Toggle = ({
13628
13712
  id,
13629
13713
  children,
@@ -14269,6 +14353,7 @@ ToggleButtonGroup.displayName = "ToggleButtonGroup";
14269
14353
  cn,
14270
14354
  countryOptions,
14271
14355
  createSelectOptions,
14356
+ createSizes,
14272
14357
  dateValueToNativeDate,
14273
14358
  defaultTypographyType,
14274
14359
  defaultTypographyTypeClassName,