@norges-domstoler/dds-components 24.2.2 → 24.3.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.d.cts CHANGED
@@ -16675,7 +16675,7 @@ type SelectProps<Option = unknown, IsMulti extends boolean = false> = {
16675
16675
  customOptionElement?: (props: OptionProps<Option, IsMulti, GroupBase<Option>>) => JSX.Element;
16676
16676
  /** Custom element som vises i listen over alternativer. */
16677
16677
  customSingleValueElement?: (props: SingleValueProps<Option, IsMulti, GroupBase<Option>>) => JSX.Element;
16678
- /** Testid. Legges på control-div med suffiks "control". */
16678
+ /** Testid. Legges på control-div med suffiks "control", samt alternativene på formen `"<data-testid>-option-<option.value>"`. */
16679
16679
  'data-testid'?: string;
16680
16680
  /**Ref til komponenten. */
16681
16681
  ref?: SelectForwardRefType<Option, IsMulti>;
package/dist/index.d.mts CHANGED
@@ -16674,7 +16674,7 @@ type SelectProps<Option = unknown, IsMulti extends boolean = false> = {
16674
16674
  customOptionElement?: (props: OptionProps<Option, IsMulti, GroupBase<Option>>) => JSX.Element;
16675
16675
  /** Custom element som vises i listen over alternativer. */
16676
16676
  customSingleValueElement?: (props: SingleValueProps<Option, IsMulti, GroupBase<Option>>) => JSX.Element;
16677
- /** Testid. Legges på control-div med suffiks "control". */
16677
+ /** Testid. Legges på control-div med suffiks "control", samt alternativene på formen `"<data-testid>-option-<option.value>"`. */
16678
16678
  'data-testid'?: string;
16679
16679
  /**Ref til komponenten. */
16680
16680
  ref?: SelectForwardRefType<Option, IsMulti>;
package/dist/index.mjs CHANGED
@@ -9475,15 +9475,23 @@ const getCustomStyles = (size, hasError, isReadOnly) => ({
9475
9475
  //#endregion
9476
9476
  //#region src/components/Select/SelectComponents.tsx
9477
9477
  const { Option, NoOptionsMessage, Input, SingleValue, ClearIndicator, DropdownIndicator, MultiValueRemove, Control } = components;
9478
- const DDSOption = ({ ...props }) => /* @__PURE__ */ jsxs(Option, {
9478
+ const DDSOption = ({ testId, ...props }) => /* @__PURE__ */ jsxs(Option, {
9479
9479
  ...props,
9480
+ innerProps: {
9481
+ ...props.innerProps,
9482
+ "data-testid": testId
9483
+ },
9480
9484
  children: [props.isSelected && /* @__PURE__ */ jsx(Icon, {
9481
9485
  icon: CheckIcon,
9482
9486
  iconSize: "small"
9483
9487
  }), props.children]
9484
9488
  });
9485
- const CustomOption = (props) => /* @__PURE__ */ jsx(Option, {
9489
+ const CustomOption = ({ testId, ...props }) => /* @__PURE__ */ jsx(Option, {
9486
9490
  ...props,
9491
+ innerProps: {
9492
+ ...props.innerProps,
9493
+ "data-testid": testId
9494
+ },
9487
9495
  children: React.createElement(props.customElement, props)
9488
9496
  });
9489
9497
  const CustomSingleValue = ({ id, Element, ...props }) => /* @__PURE__ */ jsx(SingleValue, {
@@ -9596,12 +9604,21 @@ function Select({ id, label, componentSize = "medium", errorMessage, tip, "aria-
9596
9604
  dataTestId
9597
9605
  ]);
9598
9606
  const customOptionComponent = useCallback((props) => {
9607
+ const optionTestId = dataTestId ? `${dataTestId}-option-${String(rest.getOptionValue?.(props.data) ?? props.data.value)}` : void 0;
9599
9608
  if (customOptionElement) return /* @__PURE__ */ jsx(CustomOption, {
9600
9609
  ...props,
9601
- customElement: customOptionElement
9610
+ customElement: customOptionElement,
9611
+ testId: optionTestId
9612
+ });
9613
+ else return /* @__PURE__ */ jsx(DDSOption, {
9614
+ ...props,
9615
+ testId: optionTestId
9602
9616
  });
9603
- else return /* @__PURE__ */ jsx(DDSOption, { ...props });
9604
- }, [customOptionElement, componentSize]);
9617
+ }, [
9618
+ customOptionElement,
9619
+ dataTestId,
9620
+ rest.getOptionValue
9621
+ ]);
9605
9622
  const reactSelectProps = {
9606
9623
  options,
9607
9624
  value,