@mattilsynet/design 3.1.5 → 3.1.7

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/mtds/app/app.d.ts CHANGED
@@ -6,7 +6,9 @@ export type AppSidebarProps = React.ComponentPropsWithoutRef<"dialog">;
6
6
  export type AppStickyProps = React.ComponentPropsWithoutRef<"div">;
7
7
  export type AppMainProps = React.ComponentPropsWithoutRef<"main">;
8
8
  export type AppFooterProps = React.ComponentPropsWithoutRef<"footer">;
9
- export type AppProps<As extends React.ElementType = "div"> = PolymorphicComponentPropWithRef<As>;
9
+ export type AppProps<As extends React.ElementType = "div"> = PolymorphicComponentPropWithRef<As, {
10
+ "data-variant"?: "mobilebar";
11
+ }>;
10
12
  type AppComponent = <As extends React.ElementType = "div">(props: AppProps<As>) => JSX.Element;
11
13
  export declare const App: AppComponent & {
12
14
  Header: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import('react').RefAttributes<HTMLElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sources":["../../designsystem/app/app.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport { Button, type ButtonProps } from \"../button/button\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport script from \"./app-toggle.js?raw\";\n\nexport type AppHeaderProps = React.ComponentPropsWithoutRef<\"header\">;\nexport type AppSidebarProps = React.ComponentPropsWithoutRef<\"dialog\">;\nexport type AppStickyProps = React.ComponentPropsWithoutRef<\"div\">;\nexport type AppMainProps = React.ComponentPropsWithoutRef<\"main\">;\nexport type AppFooterProps = React.ComponentPropsWithoutRef<\"footer\">;\nexport type AppProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As>;\n\ntype AppComponent = <As extends React.ElementType = \"div\">(\n\tprops: AppProps<As>,\n) => JSX.Element;\n\nconst AppComp = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.app, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nconst AppSticky = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.sticky, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport const App = Object.assign(AppComp, {\n\tHeader: forwardRef<HTMLElement, AppHeaderProps>(\n\t\tfunction AppHeader(rest, ref) {\n\t\t\treturn <header ref={ref} {...rest} />;\n\t\t},\n\t),\n\tSidebar: forwardRef<HTMLDialogElement, AppSidebarProps>(\n\t\tfunction AppSidebar(rest, ref) {\n\t\t\treturn (\n\t\t\t\t<dialog\n\t\t\t\t\trole=\"navigation\"\n\t\t\t\t\tid=\"mtds-sidebar\"\n\t\t\t\t\tsuppressHydrationWarning // Needed due to closedby polyfill\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...rest}\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t),\n\tSticky: AppSticky,\n\tToggle: forwardRef<HTMLButtonElement, ButtonProps<\"button\">>(\n\t\tfunction AppToggle({ children, ...rest }: ButtonProps<\"button\">, ref) {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tcommand=\"show-modal\"\n\t\t\t\t\tcommandfor=\"mtds-sidebar\"\n\t\t\t\t\tdata-tooltip=\"Vis meny\"\n\t\t\t\t\tref={ref as React.Ref<HTMLAnchorElement>}\n\t\t\t\t\t{...rest}\n\t\t\t\t>\n\t\t\t\t\t{children ?? \"Skjul meny\"}\n\t\t\t\t</Button>\n\t\t\t);\n\t\t},\n\t),\n\tMain: forwardRef<HTMLElement, AppMainProps>(function AppMain(rest, ref) {\n\t\treturn <main ref={ref} {...rest} />;\n\t}),\n\tFooter: forwardRef<HTMLElement, AppFooterProps>(\n\t\tfunction AppFooter(rest, ref) {\n\t\t\treturn <footer ref={ref} {...rest} />;\n\t\t},\n\t),\n\t// Needed to avoid flash of unstyled content and still be Next.js hydration compatible\n\tScript: () => <script id=\"mtds-app-script\">{script}</script>,\n});\n"],"names":["AppComp","forwardRef","as","className","rest","ref","jsx","clsx","styles","AppSticky","App","children","Button","script"],"mappings":";;;;;;AAsBA,MAAMA,IAAUC,EAAiB,SAE/B,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAA,GAAsBC,GAA0B;AAGrE,SAAO,gBAAAC,EAFKJ,KAAM,OAEV,EAAI,WAAWK,EAAKC,EAAO,KAAKL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAA,CAAM;AACzE,CAAC,GAEKK,IAAYR,EAAiB,SAEjC,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAA,GAAsBC,GAA0B;AAGrE,SAAO,gBAAAC,EAFKJ,KAAM,OAEV,EAAI,WAAWK,EAAKC,EAAO,QAAQL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAA,CAAM;AAC5E,CAAC,GAEYM,IAAM,OAAO,OAAOV,GAAS;AAAA,EACzC,QAAQC;AAAA,IACP,SAAmBG,GAAMC,GAAK;AAC7B,aAAO,gBAAAC,EAAC,UAAA,EAAO,KAAAD,GAAW,GAAGD,EAAA,CAAM;AAAA,IACpC;AAAA,EAAA;AAAA,EAED,SAASH;AAAA,IACR,SAAoBG,GAAMC,GAAK;AAC9B,aACC,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACA,MAAK;AAAA,UACL,IAAG;AAAA,UACH,0BAAwB;AAAA,UACxB,KAAAD;AAAA,UACC,GAAGD;AAAA,QAAA;AAAA,MAAA;AAAA,IAGP;AAAA,EAAA;AAAA,EAED,QAAQK;AAAA,EACR,QAAQR;AAAA,IACP,SAAmB,EAAE,UAAAU,GAAU,GAAGP,EAAA,GAA+BC,GAAK;AACrE,aACC,gBAAAC;AAAA,QAACM;AAAA,QAAA;AAAA,UACA,SAAQ;AAAA,UACR,YAAW;AAAA,UACX,gBAAa;AAAA,UACb,KAAAP;AAAA,UACC,GAAGD;AAAA,UAEH,UAAAO,KAAY;AAAA,QAAA;AAAA,MAAA;AAAA,IAGhB;AAAA,EAAA;AAAA,EAED,MAAMV,EAAsC,SAAiBG,GAAMC,GAAK;AACvE,WAAO,gBAAAC,EAAC,QAAA,EAAK,KAAAD,GAAW,GAAGD,EAAA,CAAM;AAAA,EAClC,CAAC;AAAA,EACD,QAAQH;AAAA,IACP,SAAmBG,GAAMC,GAAK;AAC7B,aAAO,gBAAAC,EAAC,UAAA,EAAO,KAAAD,GAAW,GAAGD,EAAA,CAAM;AAAA,IACpC;AAAA,EAAA;AAAA;AAAA,EAGD,QAAQ,MAAM,gBAAAE,EAAC,UAAA,EAAO,IAAG,mBAAmB,UAAAO,EAAA,CAAO;AACpD,CAAC;"}
1
+ {"version":3,"file":"app.js","sources":["../../designsystem/app/app.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport { Button, type ButtonProps } from \"../button/button\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport script from \"./app-toggle.js?raw\";\n\nexport type AppHeaderProps = React.ComponentPropsWithoutRef<\"header\">;\nexport type AppSidebarProps = React.ComponentPropsWithoutRef<\"dialog\">;\nexport type AppStickyProps = React.ComponentPropsWithoutRef<\"div\">;\nexport type AppMainProps = React.ComponentPropsWithoutRef<\"main\">;\nexport type AppFooterProps = React.ComponentPropsWithoutRef<\"footer\">;\nexport type AppProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{\n\t\t\t\"data-variant\"?: \"mobilebar\";\n\t\t}\n\t>;\n\ntype AppComponent = <As extends React.ElementType = \"div\">(\n\tprops: AppProps<As>,\n) => JSX.Element;\n\nconst AppComp = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.app, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nconst AppSticky = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.sticky, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport const App = Object.assign(AppComp, {\n\tHeader: forwardRef<HTMLElement, AppHeaderProps>(\n\t\tfunction AppHeader(rest, ref) {\n\t\t\treturn <header ref={ref} {...rest} />;\n\t\t},\n\t),\n\tSidebar: forwardRef<HTMLDialogElement, AppSidebarProps>(\n\t\tfunction AppSidebar(rest, ref) {\n\t\t\treturn (\n\t\t\t\t<dialog\n\t\t\t\t\trole=\"navigation\"\n\t\t\t\t\tid=\"mtds-sidebar\"\n\t\t\t\t\tsuppressHydrationWarning // Needed due to closedby polyfill\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...rest}\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t),\n\tSticky: AppSticky,\n\tToggle: forwardRef<HTMLButtonElement, ButtonProps<\"button\">>(\n\t\tfunction AppToggle({ children, ...rest }: ButtonProps<\"button\">, ref) {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tcommand=\"show-modal\"\n\t\t\t\t\tcommandfor=\"mtds-sidebar\"\n\t\t\t\t\tdata-tooltip=\"Vis meny\"\n\t\t\t\t\tref={ref as React.Ref<HTMLAnchorElement>}\n\t\t\t\t\t{...rest}\n\t\t\t\t>\n\t\t\t\t\t{children ?? \"Skjul meny\"}\n\t\t\t\t</Button>\n\t\t\t);\n\t\t},\n\t),\n\tMain: forwardRef<HTMLElement, AppMainProps>(function AppMain(rest, ref) {\n\t\treturn <main ref={ref} {...rest} />;\n\t}),\n\tFooter: forwardRef<HTMLElement, AppFooterProps>(\n\t\tfunction AppFooter(rest, ref) {\n\t\t\treturn <footer ref={ref} {...rest} />;\n\t\t},\n\t),\n\t// Needed to avoid flash of unstyled content and still be Next.js hydration compatible\n\tScript: () => <script id=\"mtds-app-script\">{script}</script>,\n});\n"],"names":["AppComp","forwardRef","as","className","rest","ref","jsx","clsx","styles","AppSticky","App","children","Button","script"],"mappings":";;;;;;AA2BA,MAAMA,IAAUC,EAAiB,SAE/B,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAA,GAAsBC,GAA0B;AAGrE,SAAO,gBAAAC,EAFKJ,KAAM,OAEV,EAAI,WAAWK,EAAKC,EAAO,KAAKL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAA,CAAM;AACzE,CAAC,GAEKK,IAAYR,EAAiB,SAEjC,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAA,GAAsBC,GAA0B;AAGrE,SAAO,gBAAAC,EAFKJ,KAAM,OAEV,EAAI,WAAWK,EAAKC,EAAO,QAAQL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAA,CAAM;AAC5E,CAAC,GAEYM,IAAM,OAAO,OAAOV,GAAS;AAAA,EACzC,QAAQC;AAAA,IACP,SAAmBG,GAAMC,GAAK;AAC7B,aAAO,gBAAAC,EAAC,UAAA,EAAO,KAAAD,GAAW,GAAGD,EAAA,CAAM;AAAA,IACpC;AAAA,EAAA;AAAA,EAED,SAASH;AAAA,IACR,SAAoBG,GAAMC,GAAK;AAC9B,aACC,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACA,MAAK;AAAA,UACL,IAAG;AAAA,UACH,0BAAwB;AAAA,UACxB,KAAAD;AAAA,UACC,GAAGD;AAAA,QAAA;AAAA,MAAA;AAAA,IAGP;AAAA,EAAA;AAAA,EAED,QAAQK;AAAA,EACR,QAAQR;AAAA,IACP,SAAmB,EAAE,UAAAU,GAAU,GAAGP,EAAA,GAA+BC,GAAK;AACrE,aACC,gBAAAC;AAAA,QAACM;AAAA,QAAA;AAAA,UACA,SAAQ;AAAA,UACR,YAAW;AAAA,UACX,gBAAa;AAAA,UACb,KAAAP;AAAA,UACC,GAAGD;AAAA,UAEH,UAAAO,KAAY;AAAA,QAAA;AAAA,MAAA;AAAA,IAGhB;AAAA,EAAA;AAAA,EAED,MAAMV,EAAsC,SAAiBG,GAAMC,GAAK;AACvE,WAAO,gBAAAC,EAAC,QAAA,EAAK,KAAAD,GAAW,GAAGD,EAAA,CAAM;AAAA,EAClC,CAAC;AAAA,EACD,QAAQH;AAAA,IACP,SAAmBG,GAAMC,GAAK;AAC7B,aAAO,gBAAAC,EAAC,UAAA,EAAO,KAAAD,GAAW,GAAGD,EAAA,CAAM;AAAA,IACpC;AAAA,EAAA;AAAA;AAAA,EAGD,QAAQ,MAAM,gBAAAE,EAAC,UAAA,EAAO,IAAG,mBAAmB,UAAAO,EAAA,CAAO;AACpD,CAAC;"}
@@ -24,7 +24,7 @@ class m extends C {
24
24
  "style",
25
25
  null,
26
26
  `@layer leaflet{${f}}
27
- @layer mt.v3-1-5design{${b}`
27
+ @layer mt.v3-1-7design{${b}`
28
28
  ),
29
29
  r("figure")
30
30
  );
@@ -4,6 +4,7 @@ import { JSX } from 'react';
4
4
  import { InputProps } from '../input/input';
5
5
  import { CustomReactElementProps, PolymorphicComponentPropWithRef } from '../react-types';
6
6
  type FieldBaseProps = {
7
+ "data-required"?: "hidden";
7
8
  count?: number;
8
9
  description?: React.ReactNode;
9
10
  error?: React.ReactNode;
@@ -1,178 +1,180 @@
1
1
  'use client';
2
- import { jsx as e, Fragment as k, jsxs as W } from "react/jsx-runtime";
3
- import P from "clsx";
4
- import { forwardRef as s, useRef as z, useImperativeHandle as $, useEffect as ee } from "react";
2
+ import { jsx as e, Fragment as P, jsxs as D } from "react/jsx-runtime";
3
+ import T from "clsx";
4
+ import { forwardRef as d, useRef as I, useImperativeHandle as $, useEffect as ee } from "react";
5
5
  import { HelpText as te } from "../helptext/helptext.js";
6
6
  import { Input as ne } from "../input/input.js";
7
- import x from "../styles.module.css.js";
7
+ import v from "../styles.module.css.js";
8
8
  import { toCustomElementProps as N } from "../utils.js";
9
- import { Validation as T } from "../validation/validation.js";
10
- const V = (a) => typeof a == "string" ? { label: a, value: a } : a, ie = s(function({
9
+ import { Validation as V } from "../validation/validation.js";
10
+ const G = (i) => typeof i == "string" ? { label: i, value: i } : i, ie = d(function({
11
11
  "data-size": t,
12
12
  "data-validation": n,
13
- as: i,
14
- className: d,
15
- count: c,
16
- description: m,
17
- error: y,
18
- helpText: g,
19
- helpTextLabel: C,
13
+ "data-required": r,
14
+ as: a,
15
+ className: f,
16
+ count: m,
17
+ description: g,
18
+ error: x,
19
+ helpText: y,
20
+ helpTextLabel: w,
20
21
  label: b,
21
- prefix: p,
22
- style: D,
23
- suffix: h,
24
- validation: O,
22
+ prefix: h,
23
+ style: O,
24
+ suffix: F,
25
+ validation: j,
25
26
  ...o
26
- }, F) {
27
- const v = i || "ds-field", j = !!h || !!p, w = O || y, u = {
27
+ }, c) {
28
+ const H = a || "ds-field", L = !!F || !!h, p = j || x, W = {
28
29
  "data-size": t,
29
30
  "data-validation": n,
30
- class: P(x.field, d),
31
+ "data-required": r,
32
+ class: T(v.field, f),
31
33
  suppressHydrationWarning: !0,
32
- style: D
34
+ style: O
33
35
  };
34
- return i === "select" && !o.children && Object.assign(o, {
36
+ return a === "select" && !o.children && Object.assign(o, {
35
37
  options: void 0,
36
38
  // Ensure options is not passed to DOM
37
- children: /* @__PURE__ */ e(k, { children: o.options?.map(V).map(({ label: L, value: H }) => /* @__PURE__ */ e("option", { value: H, children: L }, H)) })
38
- }), i ? /* @__PURE__ */ W("ds-field", { ...u, children: [
39
- !!b && /* @__PURE__ */ e(M, { children: b }),
40
- !!g && /* @__PURE__ */ e(te, { "aria-label": C, children: g }),
41
- !!m && /* @__PURE__ */ e(Q, { children: m }),
42
- j ? /* @__PURE__ */ W(G, { children: [
43
- !!p && /* @__PURE__ */ e("span", { children: p }),
39
+ children: /* @__PURE__ */ e(P, { children: o.options?.map(G).map(({ label: q, value: C }) => /* @__PURE__ */ e("option", { value: C, children: q }, C)) })
40
+ }), a ? /* @__PURE__ */ D("ds-field", { ...W, children: [
41
+ !!b && /* @__PURE__ */ e(Q, { children: b }),
42
+ !!y && /* @__PURE__ */ e(te, { "aria-label": w, children: y }),
43
+ !!g && /* @__PURE__ */ e(U, { children: g }),
44
+ L ? /* @__PURE__ */ D(J, { children: [
45
+ !!h && /* @__PURE__ */ e("span", { children: h }),
44
46
  /* @__PURE__ */ e(
45
- v,
47
+ H,
46
48
  {
47
- className: typeof i == "string" ? x.input : void 0,
49
+ className: typeof a == "string" ? v.input : void 0,
48
50
  suppressHydrationWarning: !0,
49
- ref: F,
51
+ ref: c,
50
52
  ...o
51
53
  }
52
54
  ),
53
- !!h && /* @__PURE__ */ e("span", { children: h })
55
+ !!F && /* @__PURE__ */ e("span", { children: F })
54
56
  ] }) : /* @__PURE__ */ e(
55
- v,
57
+ H,
56
58
  {
57
- className: typeof i == "string" ? x.input : void 0,
59
+ className: typeof a == "string" ? v.input : void 0,
58
60
  suppressHydrationWarning: !0,
59
- ref: F,
61
+ ref: c,
60
62
  ...o
61
63
  }
62
64
  ),
63
- !!w && /* @__PURE__ */ e(T, { children: w }),
64
- !!c && /* @__PURE__ */ e(U, { "data-limit": c })
65
- ] }) : /* @__PURE__ */ e("ds-field", { ref: F, ...u, ...o });
66
- }), G = s(
67
- function({ className: t, ...n }, i) {
68
- return /* @__PURE__ */ e("div", { className: P(x.affixes, t), ref: i, ...n });
65
+ !!p && /* @__PURE__ */ e(V, { children: p }),
66
+ !!m && /* @__PURE__ */ e(X, { "data-limit": m })
67
+ ] }) : /* @__PURE__ */ e("ds-field", { ref: c, ...W, ...o });
68
+ }), J = d(
69
+ function({ className: t, ...n }, r) {
70
+ return /* @__PURE__ */ e("div", { className: T(v.affixes, t), ref: r, ...n });
69
71
  }
70
- ), J = s(
71
- function({ "data-position": t, "data-nofilter": n, ...i }, d) {
72
+ ), K = d(
73
+ function({ "data-position": t, "data-nofilter": n, ...r }, a) {
72
74
  return /* @__PURE__ */ e(
73
75
  "u-datalist",
74
76
  {
75
77
  "data-placement": t,
76
78
  "data-nofilter": !!n || void 0,
77
- ref: d,
78
- ...N(i)
79
+ ref: a,
80
+ ...N(r)
79
81
  }
80
82
  );
81
83
  }
82
- ), K = s(
84
+ ), M = d(
83
85
  function(t, n) {
84
86
  return /* @__PURE__ */ e("u-option", { ref: n, ...N(t) });
85
87
  }
86
- ), I = s(
88
+ ), k = d(
87
89
  function({
88
90
  "aria-required": t,
89
91
  "data-position": n,
90
- "data-placement": i,
91
- "data-nofilter": d,
92
- "data-multiple": c,
92
+ "data-placement": r,
93
+ "data-nofilter": a,
94
+ "data-multiple": f,
93
95
  onAfterChange: m,
94
96
  // Backwards compatibility
95
- onAfterSelect: y,
96
- onBeforeChange: g,
97
+ onAfterSelect: g,
98
+ onBeforeChange: x,
97
99
  // Backwards compatibility
98
- onBeforeMatch: C,
99
- onBeforeSelect: b,
100
- onSelectedChange: p,
101
- onInput: D,
102
- onChange: h,
103
- children: O,
104
- disabled: o,
105
- name: F,
106
- options: v,
107
- placeholder: j,
108
- readOnly: w,
109
- selected: u,
110
- type: L,
111
- ...H
112
- }, X) {
113
- const B = z(null), E = z(p);
114
- return E.current = p, m && (y = m, window.dsWarnings === !1 || console.warn(
100
+ onBeforeMatch: y,
101
+ onBeforeSelect: w,
102
+ onSelectedChange: b,
103
+ onInput: h,
104
+ onChange: O,
105
+ children: F,
106
+ disabled: j,
107
+ name: o,
108
+ options: c,
109
+ placeholder: H,
110
+ readOnly: L,
111
+ selected: p,
112
+ type: W,
113
+ ...q
114
+ }, C) {
115
+ const B = I(null), E = I(b);
116
+ return E.current = b, m && (g = m, window.dsWarnings === !1 || console.warn(
115
117
  "\x1B[1m@mattilsynet/design - deprecation warning:\x1B[m onAfterChange is deprecated, please use onAfterSelect instead"
116
- )), g && (b = g, window.dsWarnings === !1 || console.warn(
118
+ )), x && (w = x, window.dsWarnings === !1 || console.warn(
117
119
  "\x1B[1m@mattilsynet/design - deprecation warning:\x1B[m onBeforeChange is deprecated, please use onBeforeSelect instead"
118
- )), $(X, () => B.current), ee(() => {
119
- const f = B.current, l = (r) => {
120
+ )), $(C, () => B.current), ee(() => {
121
+ const u = B.current, l = (s) => {
120
122
  const S = E.current;
121
123
  if (!E) return;
122
- r.preventDefault();
123
- const { isConnected: Y, textContent: Z, value: A } = r.detail, R = Z?.trim() || "", q = u || [];
124
- S?.(Y ? q.filter((_) => _.value !== A) : c ? [...q, { value: A, label: R }] : [{ value: A, label: R }]);
124
+ s.preventDefault();
125
+ const { isConnected: Y, textContent: Z, value: A } = s.detail, R = Z?.trim() || "", z = p || [];
126
+ S?.(Y ? z.filter((_) => _.value !== A) : f ? [...z, { value: A, label: R }] : [{ value: A, label: R }]);
125
127
  };
126
- return f?.addEventListener("comboboxbeforeselect", l), () => f?.removeEventListener("comboboxbeforeselect", l);
127
- }, [c, u]), /* @__PURE__ */ W(
128
+ return u?.addEventListener("comboboxbeforeselect", l), () => u?.removeEventListener("comboboxbeforeselect", l);
129
+ }, [f, p]), /* @__PURE__ */ D(
128
130
  "ds-suggestion",
129
131
  {
130
- "data-multiple": c || void 0,
132
+ "data-multiple": f || void 0,
131
133
  ...N(
132
134
  {
133
- oncomboboxbeforeselect: b,
134
- oncomboboxbeforematch: C,
135
- oncomboboxafterselect: y,
135
+ oncomboboxbeforeselect: w,
136
+ oncomboboxbeforematch: y,
137
+ oncomboboxafterselect: g,
136
138
  ref: B,
137
- ...H
139
+ ...q
138
140
  },
139
- x.suggestion
141
+ v.suggestion
140
142
  ),
141
143
  children: [
142
- u?.map(({ children: f, label: l, value: r }) => /* @__PURE__ */ e("data", { value: r, suppressHydrationWarning: !0, children: f ?? l }, r)),
143
- O || /* @__PURE__ */ W(k, { children: [
144
+ p?.map(({ children: u, label: l, value: s }) => /* @__PURE__ */ e("data", { value: s, suppressHydrationWarning: !0, children: u ?? l }, s)),
145
+ F || /* @__PURE__ */ D(P, { children: [
144
146
  /* @__PURE__ */ e(
145
147
  ne,
146
148
  {
147
149
  "aria-required": t,
148
- disabled: o,
149
- name: F,
150
- onInput: D,
151
- onChange: h,
152
- placeholder: j,
153
- readOnly: w,
154
- type: L
150
+ disabled: j,
151
+ name: o,
152
+ onInput: h,
153
+ onChange: O,
154
+ placeholder: H,
155
+ readOnly: L,
156
+ type: W
155
157
  }
156
158
  ),
157
159
  /* @__PURE__ */ e("del", { "aria-label": "Fjern tekst", suppressHydrationWarning: !0 })
158
160
  ] }),
159
- !!v && /* @__PURE__ */ e(
160
- J,
161
+ !!c && /* @__PURE__ */ e(
162
+ K,
161
163
  {
162
- "data-nofilter": d,
163
- "data-placement": i || n,
164
- children: v.map(V).map(({ children: f, label: l, value: r }) => /* @__PURE__ */ e(K, { value: r, label: l, children: f ?? l }, r))
164
+ "data-nofilter": a,
165
+ "data-placement": r || n,
166
+ children: c.map(G).map(({ children: u, label: l, value: s }) => /* @__PURE__ */ e(M, { value: s, label: l, children: u ?? l }, s))
165
167
  }
166
168
  )
167
169
  ]
168
170
  }
169
171
  );
170
172
  }
171
- ), M = s(
173
+ ), Q = d(
172
174
  function(t, n) {
173
175
  return /* @__PURE__ */ e("label", { suppressHydrationWarning: !0, ref: n, ...t });
174
176
  }
175
- ), Q = s(function(t, n) {
177
+ ), U = d(function(t, n) {
176
178
  return /* @__PURE__ */ e(
177
179
  "div",
178
180
  {
@@ -182,31 +184,31 @@ const V = (a) => typeof a == "string" ? { label: a, value: a } : a, ie = s(funct
182
184
  ...t
183
185
  }
184
186
  );
185
- }), U = s(
186
- function({ "data-count": t, "data-limit": n, ...i }, d) {
187
+ }), X = d(
188
+ function({ "data-count": t, "data-limit": n, ...r }, a) {
187
189
  return /* @__PURE__ */ e(
188
- T,
190
+ V,
189
191
  {
190
192
  "data-field": "counter",
191
193
  "data-limit": n || t,
192
- ref: d,
193
- ...i
194
+ ref: a,
195
+ ...r
194
196
  }
195
197
  );
196
198
  }
197
199
  ), ue = Object.assign(ie, {
198
- Affixes: G,
200
+ Affixes: J,
199
201
  /**
200
202
  * @deprecated Use Field.Suggestion instead
201
203
  */
202
- Combobox: I,
204
+ Combobox: k,
203
205
  // Backwards compatibility
204
- Suggestion: I,
205
- Datalist: J,
206
- Option: K,
207
- Description: Q,
208
- Label: M,
209
- Count: U
206
+ Suggestion: k,
207
+ Datalist: K,
208
+ Option: M,
209
+ Description: U,
210
+ Label: Q,
211
+ Count: X
210
212
  });
211
213
  export {
212
214
  ue as Field,
@@ -1 +1 @@
1
- {"version":3,"file":"field.js","sources":["../../designsystem/field/field.tsx"],"sourcesContent":["\"use client\";\nimport type { DSSuggestionElement } from \"@digdir/designsystemet-web\";\nimport type { Placement } from \"@floating-ui/dom\";\nimport clsx from \"clsx\";\nimport type { JSX } from \"react\";\nimport { forwardRef, useEffect, useImperativeHandle, useRef } from \"react\";\nimport { HelpText } from \"../helptext/helptext\";\nimport { Input, type InputProps } from \"../input/input\";\nimport type {\n\tCustomReactElementProps,\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport { toCustomElementProps } from \"../utils\";\nimport { Validation } from \"../validation/validation\";\n\ntype FieldBaseProps = {\n\tcount?: number;\n\tdescription?: React.ReactNode;\n\terror?: React.ReactNode; // Kept for backwards compatibility\n\thelpText?: React.ReactNode;\n\thelpTextLabel?: string;\n\tlabel?: React.ReactNode;\n\toptions?: string[] | FieldSuggestionSelected;\n\tprefix?: string;\n\treadOnly?: boolean; // Allow readoOnly also on <select>\n\tsuffix?: string;\n\tvalidation?: React.ReactNode;\n};\n\nexport type FieldProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, FieldBaseProps>;\n\ntype FieldComponent = <As extends React.ElementType = \"div\">(\n\tprops: FieldProps<As>,\n) => JSX.Element;\n\nconst toOption = (\n\to: FieldSuggestionSelected[number] | string,\n): FieldSuggestionSelected[number] =>\n\ttypeof o === \"string\" ? { label: o, value: o } : o;\n\nexport const FieldComp: FieldComponent = forwardRef<null>(function Field<\n\tAs extends React.ElementType = \"div\",\n>(\n\t{\n\t\t\"data-size\": size,\n\t\t\"data-validation\": dataValidation,\n\t\tas,\n\t\tclassName,\n\t\tcount,\n\t\tdescription,\n\t\terror,\n\t\thelpText,\n\t\thelpTextLabel,\n\t\tlabel,\n\t\tprefix,\n\t\tstyle,\n\t\tsuffix,\n\t\tvalidation: validationContent,\n\t\t...rest\n\t}: FieldProps<As>,\n\tref?: PolymorphicRef<As>,\n) {\n\tconst Tag = as || \"ds-field\";\n\tconst affixes = !!suffix || !!prefix;\n\tconst validation = validationContent || error; // error kept for backwards compatibility\n\tconst shared = {\n\t\t\"data-size\": size,\n\t\t\"data-validation\": dataValidation,\n\t\tclass: clsx(styles.field, className),\n\t\tsuppressHydrationWarning: true,\n\t\tstyle,\n\t};\n\n\t// Render options if select\n\tif (as === \"select\" && !rest.children)\n\t\tObject.assign(rest, {\n\t\t\toptions: undefined, // Ensure options is not passed to DOM\n\t\t\tchildren: (\n\t\t\t\t<>\n\t\t\t\t\t{(rest.options as FieldBaseProps[\"options\"])\n\t\t\t\t\t\t?.map(toOption)\n\t\t\t\t\t\t.map(({ label, value }) => (\n\t\t\t\t\t\t\t<option key={value} value={value}>\n\t\t\t\t\t\t\t\t{label}\n\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t))}\n\t\t\t\t</>\n\t\t\t),\n\t\t});\n\n\t// Using suppressHydrationWarning to avoid Next.js vs field-observer.ts hydration conflict\n\treturn as ? (\n\t\t<ds-field {...shared}>\n\t\t\t{!!label && <FieldLabel>{label}</FieldLabel>}\n\t\t\t{!!helpText && <HelpText aria-label={helpTextLabel}>{helpText}</HelpText>}\n\t\t\t{!!description && <FieldDescription>{description}</FieldDescription>}\n\t\t\t{affixes ? (\n\t\t\t\t<FieldAffixes>\n\t\t\t\t\t{!!prefix && <span>{prefix}</span>}\n\t\t\t\t\t<Tag\n\t\t\t\t\t\tclassName={typeof as === \"string\" ? styles.input : undefined}\n\t\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\t{...rest}\n\t\t\t\t\t/>\n\t\t\t\t\t{!!suffix && <span>{suffix}</span>}\n\t\t\t\t</FieldAffixes>\n\t\t\t) : (\n\t\t\t\t<Tag\n\t\t\t\t\tclassName={typeof as === \"string\" ? styles.input : undefined}\n\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...rest}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{!!validation && <Validation>{validation}</Validation>}\n\t\t\t{!!count && <FieldCount data-limit={count} />}\n\t\t</ds-field>\n\t) : (\n\t\t<ds-field ref={ref} {...shared} {...rest} />\n\t);\n}) as FieldComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport type FieldAffixProps = React.ComponentPropsWithoutRef<\"div\">;\nconst FieldAffixes = forwardRef<HTMLDivElement, FieldAffixProps>(\n\tfunction FieldAffixes({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<div className={clsx(styles.affixes, className)} ref={ref} {...rest} />\n\t\t);\n\t},\n);\n\nexport type FieldDatalistProps = React.ComponentPropsWithoutRef<\"datalist\"> & {\n\t\"data-nofilter\"?: boolean;\n\t/**\n\t * @deprecated Use `data-placement` instead.\n\t */\n\t\"data-position\"?: Placement;\n\t\"data-placement\"?: Placement;\n};\n\nconst FieldDatalist = forwardRef<HTMLDataListElement, FieldDatalistProps>(\n\tfunction FieldDatalist(\n\t\t{ \"data-position\": placement, \"data-nofilter\": filter, ...rest },\n\t\tref,\n\t) {\n\t\treturn (\n\t\t\t<u-datalist\n\t\t\t\tdata-placement={placement} // Backward compatibility\n\t\t\t\tdata-nofilter={!!filter || undefined} // Ensure data-nofilter is set correctly\n\t\t\t\tref={ref}\n\t\t\t\t{...toCustomElementProps(rest)}\n\t\t\t/>\n\t\t);\n\t},\n);\n\nexport type FieldOptionProps = React.ComponentPropsWithoutRef<\"option\">;\nconst FieldOption = forwardRef<HTMLOptionElement, FieldOptionProps>(\n\tfunction FieldOption(props, ref) {\n\t\treturn <u-option ref={ref} {...toCustomElementProps(props)} />;\n\t},\n);\n\nexport type FieldComboboxSelected = FieldSuggestionSelected; // Backwards compatibility\nexport type FieldComboboxProps = FieldSuggestionProps; // Backwards compatibility\n\nexport type FieldSuggestionSelected = {\n\tlabel: string;\n\tvalue: string;\n\tchildren?: React.ReactNode;\n}[];\nexport type FieldSuggestionProps = Omit<\n\tCustomReactElementProps<DSSuggestionElement>,\n\t\"onChange\" | \"onInput\"\n> & {\n\t\"data-creatable\"?: boolean;\n\t\"data-multiple\"?: boolean;\n\t\"data-variant\"?: \"inside\";\n\tonAfterChange?: (e: CustomEvent<HTMLDataElement>) => void; // Backwards compatibility\n\tonAfterSelect?: (e: CustomEvent<HTMLDataElement>) => void; // Custom event to handle before change\n\tonBeforeChange?: (e: CustomEvent<HTMLDataElement>) => void; // Backwards compatibility\n\tonBeforeMatch?: (e: CustomEvent<HTMLOptionElement>) => void; // Custom event to handle before change\n\tonBeforeSelect?: (e: CustomEvent<HTMLDataElement>) => void; // Custom event to handle before change\n\tonSelectedChange?: (selected: FieldSuggestionSelected) => void; // Allow onChange to be a function that returns void\n\toptions?: FieldSuggestionSelected;\n\tselected?: FieldSuggestionSelected; // Allow value to be a string or an array of strings for multiple select\n} & Pick<\n\t\tInputProps,\n\t\t| \"disabled\"\n\t\t| \"name\"\n\t\t| \"onChange\"\n\t\t| \"onInput\"\n\t\t| \"placeholder\"\n\t\t| \"readOnly\"\n\t\t| \"type\"\n\t\t| \"value\"\n\t> & // Allow input props to be passed down\n\tPick<\n\t\tFieldDatalistProps,\n\t\t\"data-position\" | \"data-placement\" | \"data-nofilter\"\n\t>; // Allow datalist props to be passed down\n\nconst FieldSuggestion = forwardRef<DSSuggestionElement, FieldSuggestionProps>(\n\tfunction FieldSuggestion(\n\t\t{\n\t\t\t\"aria-required\": required,\n\t\t\t\"data-position\": position,\n\t\t\t\"data-placement\": placement,\n\t\t\t\"data-nofilter\": nofilter,\n\t\t\t\"data-multiple\": multiple,\n\t\t\tonAfterChange, // Backwards compatibility\n\t\t\tonAfterSelect,\n\t\t\tonBeforeChange, // Backwards compatibility\n\t\t\tonBeforeMatch,\n\t\t\tonBeforeSelect,\n\t\t\tonSelectedChange,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\tchildren,\n\t\t\tdisabled,\n\t\t\tname,\n\t\t\toptions,\n\t\t\tplaceholder,\n\t\t\treadOnly,\n\t\t\tselected,\n\t\t\ttype,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) {\n\t\tconst innerRef = useRef<DSSuggestionElement>(null);\n\t\tconst onSelected = useRef(onSelectedChange);\n\t\tonSelected.current = onSelectedChange; // Sync the latest onSelectedChange function\n\n\t\t// Deprecated props\n\t\tif (onAfterChange) {\n\t\t\tonAfterSelect = onAfterChange;\n\t\t\twindow.dsWarnings === false ||\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`\\x1B[1m@mattilsynet/design - deprecation warning:\\x1B[m onAfterChange is deprecated, please use onAfterSelect instead`,\n\t\t\t\t);\n\t\t}\n\n\t\tif (onBeforeChange) {\n\t\t\tonBeforeSelect = onBeforeChange;\n\t\t\twindow.dsWarnings === false ||\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`\\x1B[1m@mattilsynet/design - deprecation warning:\\x1B[m onBeforeChange is deprecated, please use onBeforeSelect instead`,\n\t\t\t\t);\n\t\t}\n\n\t\t// Using useEffect for React 18 and lower compatibility\n\t\tuseImperativeHandle(ref, () => innerRef.current as DSSuggestionElement); // Forward innerRef\n\t\tuseEffect(() => {\n\t\t\tconst self = innerRef.current;\n\t\t\tconst handleChange = (event: CustomEvent<HTMLDataElement>) => {\n\t\t\t\tconst handleSelected = onSelected.current;\n\t\t\t\tif (!onSelected) return; // No onSelectedChange function provided, let ds-suggestion handle it\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst { isConnected: remove, textContent, value } = event.detail;\n\t\t\t\tconst label = textContent?.trim() || \"\";\n\t\t\t\tconst prev = selected || [];\n\n\t\t\t\tif (remove) handleSelected?.(prev.filter((i) => i.value !== value));\n\t\t\t\telse if (multiple) handleSelected?.([...prev, { value, label }]);\n\t\t\t\telse handleSelected?.([{ value, label }]);\n\t\t\t};\n\n\t\t\tself?.addEventListener(\"comboboxbeforeselect\", handleChange);\n\t\t\treturn () =>\n\t\t\t\tself?.removeEventListener(\"comboboxbeforeselect\", handleChange);\n\t\t}, [multiple, selected]);\n\n\t\treturn (\n\t\t\t<ds-suggestion\n\t\t\t\tdata-multiple={multiple || undefined}\n\t\t\t\t{...toCustomElementProps(\n\t\t\t\t\t{\n\t\t\t\t\t\toncomboboxbeforeselect: onBeforeSelect,\n\t\t\t\t\t\toncomboboxbeforematch: onBeforeMatch,\n\t\t\t\t\t\toncomboboxafterselect: onAfterSelect,\n\t\t\t\t\t\tref: innerRef,\n\t\t\t\t\t\t...props,\n\t\t\t\t\t},\n\t\t\t\t\tstyles.suggestion,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{selected?.map(({ children, label, value }) => (\n\t\t\t\t\t<data key={value} value={value} suppressHydrationWarning>\n\t\t\t\t\t\t{children ?? label}\n\t\t\t\t\t</data>\n\t\t\t\t))}\n\t\t\t\t{children || (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\taria-required={required}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\tname={name}\n\t\t\t\t\t\t\tonInput={onInput}\n\t\t\t\t\t\t\tonChange={onChange}\n\t\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\t\ttype={type}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<del aria-label=\"Fjern tekst\" suppressHydrationWarning />\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t\t{!!options && (\n\t\t\t\t\t<FieldDatalist\n\t\t\t\t\t\tdata-nofilter={nofilter}\n\t\t\t\t\t\tdata-placement={placement || position}\n\t\t\t\t\t>\n\t\t\t\t\t\t{options.map(toOption).map(({ children, label, value }) => (\n\t\t\t\t\t\t\t<FieldOption key={value} value={value} label={label}>\n\t\t\t\t\t\t\t\t{children ?? label}\n\t\t\t\t\t\t\t</FieldOption>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</FieldDatalist>\n\t\t\t\t)}\n\t\t\t</ds-suggestion>\n\t\t);\n\t},\n);\n\nexport type FieldLabelProps = React.ComponentPropsWithoutRef<\"label\">;\nconst FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(\n\tfunction FieldLabel(rest, ref) {\n\t\treturn <label suppressHydrationWarning ref={ref} {...rest} />;\n\t},\n);\n\nexport type FieldDescriptionProps = React.ComponentPropsWithoutRef<\"p\">;\nconst FieldDescription = forwardRef<\n\tHTMLParagraphElement,\n\tFieldDescriptionProps\n>(function FieldDescription(rest, ref) {\n\treturn (\n\t\t<div\n\t\t\tsuppressHydrationWarning\n\t\t\tdata-field=\"description\"\n\t\t\tref={ref}\n\t\t\t{...rest}\n\t\t/>\n\t);\n});\n\nexport type FieldCountProps = React.ComponentPropsWithoutRef<\"p\"> & {\n\t/**\n\t * @deprecated Use \"data-limit\" instead\n\t */\n\t\"data-count\"?: number;\n\t\"data-limit\": number;\n};\nconst FieldCount = forwardRef<HTMLParagraphElement, FieldCountProps>(\n\tfunction FieldCount(\n\t\t{ \"data-count\": count, \"data-limit\": limit, ...rest },\n\t\tref,\n\t) {\n\t\treturn (\n\t\t\t<Validation\n\t\t\t\tdata-field=\"counter\"\n\t\t\t\tdata-limit={limit || count}\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n);\n\nexport const Field = Object.assign(FieldComp, {\n\tAffixes: FieldAffixes,\n\t/**\n\t * @deprecated Use Field.Suggestion instead\n\t */\n\tCombobox: FieldSuggestion, // Backwards compatibility\n\tSuggestion: FieldSuggestion,\n\tDatalist: FieldDatalist,\n\tOption: FieldOption,\n\tDescription: FieldDescription,\n\tLabel: FieldLabel,\n\tCount: FieldCount,\n});\n"],"names":["toOption","o","FieldComp","forwardRef","size","dataValidation","as","className","count","description","error","helpText","helpTextLabel","label","prefix","style","suffix","validationContent","rest","ref","Tag","affixes","validation","shared","clsx","styles","value","jsx","jsxs","FieldLabel","HelpText","FieldDescription","FieldAffixes","Validation","FieldCount","FieldDatalist","placement","filter","toCustomElementProps","FieldOption","props","FieldSuggestion","required","position","nofilter","multiple","onAfterChange","onAfterSelect","onBeforeChange","onBeforeMatch","onBeforeSelect","onSelectedChange","onInput","onChange","children","disabled","name","options","placeholder","readOnly","selected","type","innerRef","useRef","onSelected","useImperativeHandle","useEffect","self","handleChange","event","handleSelected","remove","textContent","prev","i","Fragment","Input","limit","Field"],"mappings":";;;;;;;;AAsCA,MAAMA,IAAW,CAChBC,MAEA,OAAOA,KAAM,WAAW,EAAE,OAAOA,GAAG,OAAOA,EAAA,IAAMA,GAErCC,KAA4BC,EAAiB,SAGzD;AAAA,EACC,aAAaC;AAAA,EACb,mBAAmBC;AAAA,EACnB,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,Y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GAGMG,IAAa1B;AAAA,EAClB,SAAoBe,GAAMC,GAAK;AAC9B,6BAAQ,SAAA,EAAM,0BAAwB,IAAC,KAAAA,GAAW,GAAGD,GAAM;AAAA,EAC5D;AACD,GAGMa,IAAmB5B,EAGvB,SAA0Be,GAAMC,GAAK;AACtC,SACC,gBAAAQ;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,0BAAwB;AAAA,MACxB,cAAW;AAAA,MACX,KAAAR;AAAA,MACC,GAAGD;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC,GASKgB,IAAa/B;AAAA,EAClB,SACC,EAAE,cAAcK,GAAO,cAAcqE,GAAO,GAAG3D,EAAA,GAC/CC,GACC;AACD,WACC,gBAAAQ;AAAA,MAACM;AAAA,MAAA;AAAA,QACA,cAAW;AAAA,QACX,cAAY4C,KAASrE;AAAA,QACrB,KAAAW;AAAA,QACC,GAAGD;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACD,GAEa4D,KAAQ,OAAO,OAAO5E,IAAW;AAAA,EAC7C,SAAS8B;AAAA;AAAA;AAAA;AAAA,EAIT,UAAUS;AAAA;AAAA,EACV,YAAYA;AAAA,EACZ,UAAUN;AAAA,EACV,QAAQI;AAAA,EACR,aAAaR;AAAA,EACb,OAAOF;AAAA,EACP,OAAOK;AACR,CAAC;"}
1
+ {"version":3,"file":"field.js","sources":["../../designsystem/field/field.tsx"],"sourcesContent":["\"use client\";\nimport type { DSSuggestionElement } from \"@digdir/designsystemet-web\";\nimport type { Placement } from \"@floating-ui/dom\";\nimport clsx from \"clsx\";\nimport type { JSX } from \"react\";\nimport { forwardRef, useEffect, useImperativeHandle, useRef } from \"react\";\nimport { HelpText } from \"../helptext/helptext\";\nimport { Input, type InputProps } from \"../input/input\";\nimport type {\n\tCustomReactElementProps,\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport { toCustomElementProps } from \"../utils\";\nimport { Validation } from \"../validation/validation\";\n\ntype FieldBaseProps = {\n\t\"data-required\"?: \"hidden\";\n\tcount?: number;\n\tdescription?: React.ReactNode;\n\terror?: React.ReactNode; // Kept for backwards compatibility\n\thelpText?: React.ReactNode;\n\thelpTextLabel?: string;\n\tlabel?: React.ReactNode;\n\toptions?: string[] | FieldSuggestionSelected;\n\tprefix?: string;\n\treadOnly?: boolean; // Allow readoOnly also on <select>\n\tsuffix?: string;\n\tvalidation?: React.ReactNode;\n};\n\nexport type FieldProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, FieldBaseProps>;\n\ntype FieldComponent = <As extends React.ElementType = \"div\">(\n\tprops: FieldProps<As>,\n) => JSX.Element;\n\nconst toOption = (\n\to: FieldSuggestionSelected[number] | string,\n): FieldSuggestionSelected[number] =>\n\ttypeof o === \"string\" ? { label: o, value: o } : o;\n\nexport const FieldComp: FieldComponent = forwardRef<null>(function Field<\n\tAs extends React.ElementType = \"div\",\n>(\n\t{\n\t\t\"data-size\": size,\n\t\t\"data-validation\": dataValidation,\n\t\t\"data-required\": dataRequired,\n\t\tas,\n\t\tclassName,\n\t\tcount,\n\t\tdescription,\n\t\terror,\n\t\thelpText,\n\t\thelpTextLabel,\n\t\tlabel,\n\t\tprefix,\n\t\tstyle,\n\t\tsuffix,\n\t\tvalidation: validationContent,\n\t\t...rest\n\t}: FieldProps<As>,\n\tref?: PolymorphicRef<As>,\n) {\n\tconst Tag = as || \"ds-field\";\n\tconst affixes = !!suffix || !!prefix;\n\tconst validation = validationContent || error; // error kept for backwards compatibility\n\tconst shared = {\n\t\t\"data-size\": size,\n\t\t\"data-validation\": dataValidation,\n\t\t\"data-required\": dataRequired,\n\t\tclass: clsx(styles.field, className),\n\t\tsuppressHydrationWarning: true,\n\t\tstyle,\n\t};\n\n\t// Render options if select\n\tif (as === \"select\" && !rest.children)\n\t\tObject.assign(rest, {\n\t\t\toptions: undefined, // Ensure options is not passed to DOM\n\t\t\tchildren: (\n\t\t\t\t<>\n\t\t\t\t\t{(rest.options as FieldBaseProps[\"options\"])\n\t\t\t\t\t\t?.map(toOption)\n\t\t\t\t\t\t.map(({ label, value }) => (\n\t\t\t\t\t\t\t<option key={value} value={value}>\n\t\t\t\t\t\t\t\t{label}\n\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t))}\n\t\t\t\t</>\n\t\t\t),\n\t\t});\n\n\t// Using suppressHydrationWarning to avoid Next.js vs field-observer.ts hydration conflict\n\treturn as ? (\n\t\t<ds-field {...shared}>\n\t\t\t{!!label && <FieldLabel>{label}</FieldLabel>}\n\t\t\t{!!helpText && <HelpText aria-label={helpTextLabel}>{helpText}</HelpText>}\n\t\t\t{!!description && <FieldDescription>{description}</FieldDescription>}\n\t\t\t{affixes ? (\n\t\t\t\t<FieldAffixes>\n\t\t\t\t\t{!!prefix && <span>{prefix}</span>}\n\t\t\t\t\t<Tag\n\t\t\t\t\t\tclassName={typeof as === \"string\" ? styles.input : undefined}\n\t\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\t{...rest}\n\t\t\t\t\t/>\n\t\t\t\t\t{!!suffix && <span>{suffix}</span>}\n\t\t\t\t</FieldAffixes>\n\t\t\t) : (\n\t\t\t\t<Tag\n\t\t\t\t\tclassName={typeof as === \"string\" ? styles.input : undefined}\n\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...rest}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{!!validation && <Validation>{validation}</Validation>}\n\t\t\t{!!count && <FieldCount data-limit={count} />}\n\t\t</ds-field>\n\t) : (\n\t\t<ds-field ref={ref} {...shared} {...rest} />\n\t);\n}) as FieldComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport type FieldAffixProps = React.ComponentPropsWithoutRef<\"div\">;\nconst FieldAffixes = forwardRef<HTMLDivElement, FieldAffixProps>(\n\tfunction FieldAffixes({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<div className={clsx(styles.affixes, className)} ref={ref} {...rest} />\n\t\t);\n\t},\n);\n\nexport type FieldDatalistProps = React.ComponentPropsWithoutRef<\"datalist\"> & {\n\t\"data-nofilter\"?: boolean;\n\t/**\n\t * @deprecated Use `data-placement` instead.\n\t */\n\t\"data-position\"?: Placement;\n\t\"data-placement\"?: Placement;\n};\n\nconst FieldDatalist = forwardRef<HTMLDataListElement, FieldDatalistProps>(\n\tfunction FieldDatalist(\n\t\t{ \"data-position\": placement, \"data-nofilter\": filter, ...rest },\n\t\tref,\n\t) {\n\t\treturn (\n\t\t\t<u-datalist\n\t\t\t\tdata-placement={placement} // Backward compatibility\n\t\t\t\tdata-nofilter={!!filter || undefined} // Ensure data-nofilter is set correctly\n\t\t\t\tref={ref}\n\t\t\t\t{...toCustomElementProps(rest)}\n\t\t\t/>\n\t\t);\n\t},\n);\n\nexport type FieldOptionProps = React.ComponentPropsWithoutRef<\"option\">;\nconst FieldOption = forwardRef<HTMLOptionElement, FieldOptionProps>(\n\tfunction FieldOption(props, ref) {\n\t\treturn <u-option ref={ref} {...toCustomElementProps(props)} />;\n\t},\n);\n\nexport type FieldComboboxSelected = FieldSuggestionSelected; // Backwards compatibility\nexport type FieldComboboxProps = FieldSuggestionProps; // Backwards compatibility\n\nexport type FieldSuggestionSelected = {\n\tlabel: string;\n\tvalue: string;\n\tchildren?: React.ReactNode;\n}[];\nexport type FieldSuggestionProps = Omit<\n\tCustomReactElementProps<DSSuggestionElement>,\n\t\"onChange\" | \"onInput\"\n> & {\n\t\"data-creatable\"?: boolean;\n\t\"data-multiple\"?: boolean;\n\t\"data-variant\"?: \"inside\";\n\tonAfterChange?: (e: CustomEvent<HTMLDataElement>) => void; // Backwards compatibility\n\tonAfterSelect?: (e: CustomEvent<HTMLDataElement>) => void; // Custom event to handle before change\n\tonBeforeChange?: (e: CustomEvent<HTMLDataElement>) => void; // Backwards compatibility\n\tonBeforeMatch?: (e: CustomEvent<HTMLOptionElement>) => void; // Custom event to handle before change\n\tonBeforeSelect?: (e: CustomEvent<HTMLDataElement>) => void; // Custom event to handle before change\n\tonSelectedChange?: (selected: FieldSuggestionSelected) => void; // Allow onChange to be a function that returns void\n\toptions?: FieldSuggestionSelected;\n\tselected?: FieldSuggestionSelected; // Allow value to be a string or an array of strings for multiple select\n} & Pick<\n\t\tInputProps,\n\t\t| \"disabled\"\n\t\t| \"name\"\n\t\t| \"onChange\"\n\t\t| \"onInput\"\n\t\t| \"placeholder\"\n\t\t| \"readOnly\"\n\t\t| \"type\"\n\t\t| \"value\"\n\t> & // Allow input props to be passed down\n\tPick<\n\t\tFieldDatalistProps,\n\t\t\"data-position\" | \"data-placement\" | \"data-nofilter\"\n\t>; // Allow datalist props to be passed down\n\nconst FieldSuggestion = forwardRef<DSSuggestionElement, FieldSuggestionProps>(\n\tfunction FieldSuggestion(\n\t\t{\n\t\t\t\"aria-required\": required,\n\t\t\t\"data-position\": position,\n\t\t\t\"data-placement\": placement,\n\t\t\t\"data-nofilter\": nofilter,\n\t\t\t\"data-multiple\": multiple,\n\t\t\tonAfterChange, // Backwards compatibility\n\t\t\tonAfterSelect,\n\t\t\tonBeforeChange, // Backwards compatibility\n\t\t\tonBeforeMatch,\n\t\t\tonBeforeSelect,\n\t\t\tonSelectedChange,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\tchildren,\n\t\t\tdisabled,\n\t\t\tname,\n\t\t\toptions,\n\t\t\tplaceholder,\n\t\t\treadOnly,\n\t\t\tselected,\n\t\t\ttype,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) {\n\t\tconst innerRef = useRef<DSSuggestionElement>(null);\n\t\tconst onSelected = useRef(onSelectedChange);\n\t\tonSelected.current = onSelectedChange; // Sync the latest onSelectedChange function\n\n\t\t// Deprecated props\n\t\tif (onAfterChange) {\n\t\t\tonAfterSelect = onAfterChange;\n\t\t\twindow.dsWarnings === false ||\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`\\x1B[1m@mattilsynet/design - deprecation warning:\\x1B[m onAfterChange is deprecated, please use onAfterSelect instead`,\n\t\t\t\t);\n\t\t}\n\n\t\tif (onBeforeChange) {\n\t\t\tonBeforeSelect = onBeforeChange;\n\t\t\twindow.dsWarnings === false ||\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`\\x1B[1m@mattilsynet/design - deprecation warning:\\x1B[m onBeforeChange is deprecated, please use onBeforeSelect instead`,\n\t\t\t\t);\n\t\t}\n\n\t\t// Using useEffect for React 18 and lower compatibility\n\t\tuseImperativeHandle(ref, () => innerRef.current as DSSuggestionElement); // Forward innerRef\n\t\tuseEffect(() => {\n\t\t\tconst self = innerRef.current;\n\t\t\tconst handleChange = (event: CustomEvent<HTMLDataElement>) => {\n\t\t\t\tconst handleSelected = onSelected.current;\n\t\t\t\tif (!onSelected) return; // No onSelectedChange function provided, let ds-suggestion handle it\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst { isConnected: remove, textContent, value } = event.detail;\n\t\t\t\tconst label = textContent?.trim() || \"\";\n\t\t\t\tconst prev = selected || [];\n\n\t\t\t\tif (remove) handleSelected?.(prev.filter((i) => i.value !== value));\n\t\t\t\telse if (multiple) handleSelected?.([...prev, { value, label }]);\n\t\t\t\telse handleSelected?.([{ value, label }]);\n\t\t\t};\n\n\t\t\tself?.addEventListener(\"comboboxbeforeselect\", handleChange);\n\t\t\treturn () =>\n\t\t\t\tself?.removeEventListener(\"comboboxbeforeselect\", handleChange);\n\t\t}, [multiple, selected]);\n\n\t\treturn (\n\t\t\t<ds-suggestion\n\t\t\t\tdata-multiple={multiple || undefined}\n\t\t\t\t{...toCustomElementProps(\n\t\t\t\t\t{\n\t\t\t\t\t\toncomboboxbeforeselect: onBeforeSelect,\n\t\t\t\t\t\toncomboboxbeforematch: onBeforeMatch,\n\t\t\t\t\t\toncomboboxafterselect: onAfterSelect,\n\t\t\t\t\t\tref: innerRef,\n\t\t\t\t\t\t...props,\n\t\t\t\t\t},\n\t\t\t\t\tstyles.suggestion,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{selected?.map(({ children, label, value }) => (\n\t\t\t\t\t<data key={value} value={value} suppressHydrationWarning>\n\t\t\t\t\t\t{children ?? label}\n\t\t\t\t\t</data>\n\t\t\t\t))}\n\t\t\t\t{children || (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\taria-required={required}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\tname={name}\n\t\t\t\t\t\t\tonInput={onInput}\n\t\t\t\t\t\t\tonChange={onChange}\n\t\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\t\ttype={type}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<del aria-label=\"Fjern tekst\" suppressHydrationWarning />\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t\t{!!options && (\n\t\t\t\t\t<FieldDatalist\n\t\t\t\t\t\tdata-nofilter={nofilter}\n\t\t\t\t\t\tdata-placement={placement || position}\n\t\t\t\t\t>\n\t\t\t\t\t\t{options.map(toOption).map(({ children, label, value }) => (\n\t\t\t\t\t\t\t<FieldOption key={value} value={value} label={label}>\n\t\t\t\t\t\t\t\t{children ?? label}\n\t\t\t\t\t\t\t</FieldOption>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</FieldDatalist>\n\t\t\t\t)}\n\t\t\t</ds-suggestion>\n\t\t);\n\t},\n);\n\nexport type FieldLabelProps = React.ComponentPropsWithoutRef<\"label\">;\nconst FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(\n\tfunction FieldLabel(rest, ref) {\n\t\treturn <label suppressHydrationWarning ref={ref} {...rest} />;\n\t},\n);\n\nexport type FieldDescriptionProps = React.ComponentPropsWithoutRef<\"p\">;\nconst FieldDescription = forwardRef<\n\tHTMLParagraphElement,\n\tFieldDescriptionProps\n>(function FieldDescription(rest, ref) {\n\treturn (\n\t\t<div\n\t\t\tsuppressHydrationWarning\n\t\t\tdata-field=\"description\"\n\t\t\tref={ref}\n\t\t\t{...rest}\n\t\t/>\n\t);\n});\n\nexport type FieldCountProps = React.ComponentPropsWithoutRef<\"p\"> & {\n\t/**\n\t * @deprecated Use \"data-limit\" instead\n\t */\n\t\"data-count\"?: number;\n\t\"data-limit\": number;\n};\nconst FieldCount = forwardRef<HTMLParagraphElement, FieldCountProps>(\n\tfunction FieldCount(\n\t\t{ \"data-count\": count, \"data-limit\": limit, ...rest },\n\t\tref,\n\t) {\n\t\treturn (\n\t\t\t<Validation\n\t\t\t\tdata-field=\"counter\"\n\t\t\t\tdata-limit={limit || count}\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n);\n\nexport const Field = Object.assign(FieldComp, {\n\tAffixes: FieldAffixes,\n\t/**\n\t * @deprecated Use Field.Suggestion instead\n\t */\n\tCombobox: FieldSuggestion, // Backwards compatibility\n\tSuggestion: FieldSuggestion,\n\tDatalist: FieldDatalist,\n\tOption: FieldOption,\n\tDescription: FieldDescription,\n\tLabel: FieldLabel,\n\tCount: FieldCount,\n});\n"],"names":["toOption","o","FieldComp","forwardRef","size","dataValidation","dataRequired","as","className","count","description","error","helpText","helpTextLabel","label","prefix","style","suffix","validationContent","rest","ref","Tag","affixes","validation","shared","clsx","styles","value","jsx","jsxs","FieldLabel","HelpText","FieldDescription","FieldAffixes","Validation","FieldCount","FieldDatalist","placement","filter","toCustomElementProps","FieldOption","props","FieldSuggestion","required","position","nofilter","multiple","onAfterChange","onAfterSelect","onBeforeChange","onBeforeMatch","onBeforeSelect","onSelectedChange","onInput","onChange","children","disabled","name","options","placeholder","readOnly","selected","type","innerRef","useRef","onSelected","useImperativeHandle","useEffect","self","handleChange","event","handleSelected","remove","textContent","prev","i","Fragment","Input","limit","Field"],"mappings":";;;;;;;;AAuCA,MAAMA,IAAW,CAChBC,MAEA,OAAOA,KAAM,WAAW,EAAE,OAAOA,GAAG,OAAOA,EAAA,IAAMA,GAErCC,KAA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