@mattilsynet/design 1.0.3 → 1.0.4

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.
@@ -1,6 +1,7 @@
1
1
  import { StoryObj } from '@storybook/react';
2
2
  declare const meta: {
3
3
  title: string;
4
+ id: string;
4
5
  parameters: {
5
6
  layout: string;
6
7
  };
@@ -2,7 +2,6 @@ import { JSX } from 'react';
2
2
  import { InputProps } from '../input/input';
3
3
  import { PolymorphicComponentPropWithRef } from '../react-types';
4
4
  type FieldBaseProps = InputProps & {
5
- "data-size"?: string;
6
5
  className?: InputProps["className"];
7
6
  style?: InputProps["style"];
8
7
  label?: React.ReactNode;
@@ -1,44 +1,45 @@
1
1
  import { jsx as i, jsxs as v } from "react/jsx-runtime";
2
- import { clsx as u } from "../external/clsx/dist/clsx.js";
3
- import { forwardRef as x } from "react";
2
+ import { clsx as x } from "../external/clsx/dist/clsx.js";
3
+ import { forwardRef as F } from "react";
4
4
  import a from "../styles.module.css.js";
5
- const g = x(function c({
6
- "data-size": e,
7
- as: n,
8
- className: s,
9
- count: o,
10
- description: r,
11
- error: d,
12
- label: f,
5
+ const z = F(function({
6
+ "data-size": n,
7
+ as: s,
8
+ className: d,
9
+ count: l,
10
+ description: o,
11
+ error: e,
12
+ label: m,
13
13
  prefix: t,
14
14
  style: j,
15
- suffix: l,
16
- ...m
17
- }, p) {
18
- const A = n || "div";
19
- if (!n)
20
- return /* @__PURE__ */ i("div", { className: u(a.field, s), ref: p, ...m });
21
- const N = !!l || !!t, h = /* @__PURE__ */ i(A, { className: a.input, "aria-invalid": !!d, ref: p, ...m });
22
- return /* @__PURE__ */ v(c, { className: s, "data-size": e, style: j, children: [
23
- !!f && /* @__PURE__ */ i("label", { children: f }),
24
- !!r && /* @__PURE__ */ i("p", { children: r }),
25
- N ? /* @__PURE__ */ v(F, { children: [
15
+ suffix: c,
16
+ ...r
17
+ }, f) {
18
+ const A = s || "div", p = {
19
+ "data-size": n,
20
+ className: x(a.field, d),
21
+ style: j
22
+ }, g = !!c || !!t, h = /* @__PURE__ */ i(A, { className: a.input, "aria-invalid": !!e, ref: f, ...r });
23
+ return s ? /* @__PURE__ */ v("div", { ...p, children: [
24
+ !!m && /* @__PURE__ */ i("label", { children: m }),
25
+ !!o && /* @__PURE__ */ i("p", { children: o }),
26
+ g ? /* @__PURE__ */ v(u, { children: [
26
27
  !!t && /* @__PURE__ */ i("span", { children: t }),
27
28
  h,
28
- !!l && /* @__PURE__ */ i("span", { children: l })
29
+ !!c && /* @__PURE__ */ i("span", { children: c })
29
30
  ] }) : h,
30
- !!d && /* @__PURE__ */ i("div", { className: a.validation, children: d }),
31
- !!o && /* @__PURE__ */ i("p", { "data-count": o })
32
- ] });
33
- }), F = x(
34
- function({ className: e, ...n }, s) {
35
- return /* @__PURE__ */ i("div", { className: u(a.affixes, e), ref: s, ...n });
31
+ !!e && /* @__PURE__ */ i("div", { className: a.validation, children: e }),
32
+ !!l && /* @__PURE__ */ i("p", { "data-count": l })
33
+ ] }) : /* @__PURE__ */ i("div", { ref: f, ...p, ...r });
34
+ }), u = F(
35
+ function({ className: n, ...s }, d) {
36
+ return /* @__PURE__ */ i("div", { className: x(a.affixes, n), ref: d, ...s });
36
37
  }
37
- ), C = Object.assign(g, {
38
- Affixes: F
38
+ ), O = Object.assign(z, {
39
+ Affixes: u
39
40
  });
40
41
  export {
41
- C as Field,
42
- g as FieldComp
42
+ O as Field,
43
+ z as FieldComp
43
44
  };
44
45
  //# sourceMappingURL=field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"field.js","sources":["../../designsystem/field/field.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type JSX, forwardRef } from \"react\";\nimport type { InputProps } from \"../input/input\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\ntype FieldBaseProps = InputProps & {\n\t\"data-size\"?: string;\n\tclassName?: InputProps[\"className\"];\n\tstyle?: InputProps[\"style\"];\n\tlabel?: React.ReactNode;\n\tdescription?: React.ReactNode;\n\tprefix?: string;\n\tsuffix?: string;\n\terror?: React.ReactNode;\n\tcount?: number;\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\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\tas,\n\t\tclassName,\n\t\tcount,\n\t\tdescription,\n\t\terror,\n\t\tlabel,\n\t\tprefix,\n\t\tstyle,\n\t\tsuffix,\n\t\t...rest\n\t}: FieldProps<As>,\n\tref?: PolymorphicRef<As>,\n) {\n\tconst Tag = as || \"div\";\n\n\tif (!as)\n\t\treturn (\n\t\t\t<div className={clsx(styles.field, className)} ref={ref} {...rest} />\n\t\t);\n\n\tconst affixes = !!suffix || !!prefix;\n\tconst input = (\n\t\t<Tag className={styles.input} aria-invalid={!!error} ref={ref} {...rest} />\n\t);\n\n\treturn (\n\t\t<Field className={className} data-size={size} style={style}>\n\t\t\t{!!label && <label>{label}</label>}\n\t\t\t{!!description && <p>{description}</p>}\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{input}\n\t\t\t\t\t{!!suffix && <span>{suffix}</span>}\n\t\t\t\t</FieldAffixes>\n\t\t\t) : (\n\t\t\t\tinput\n\t\t\t)}\n\t\t\t{!!error && <div className={styles.validation}>{error}</div>}\n\t\t\t{!!count && <p data-count={count} />}\n\t\t</Field>\n\t);\n}) as FieldComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nconst FieldAffixes = forwardRef<HTMLDivElement, FieldProps>(\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 const Field = Object.assign(FieldComp, {\n\tAffixes: FieldAffixes,\n});\n"],"names":["FieldComp","forwardRef","Field","size","as","className","count","description","error","label","prefix","style","suffix","rest","ref","Tag","jsx","clsx","styles","affixes","input","FieldAffixes"],"mappings":";;;;AA4Ba,MAAAA,IAA4BC,EAAiB,SAASC,EAGlE;AAAA,EACC,aAAaC;AAAA,EACb,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,GAAGC;AACJ,GACAC,GACC;AACD,QAAMC,IAAMX,KAAM;AAElB,MAAI,CAACA;AAEH,WAAA,gBAAAY,EAAC,OAAI,EAAA,WAAWC,EAAKC,EAAO,OAAOb,CAAS,GAAG,KAAAS,GAAW,GAAGD,EAAM,CAAA;AAGrE,QAAMM,IAAU,CAAC,CAACP,KAAU,CAAC,CAACF,GACxBU,IACL,gBAAAJ,EAACD,GAAI,EAAA,WAAWG,EAAO,OAAO,gBAAc,CAAC,CAACV,GAAO,KAAAM,GAAW,GAAGD,EAAM,CAAA;AAG1E,2BACEX,GAAA,EAAM,WAAAG,GAAsB,aAAWF,GAAM,OAAAQ,GAC5C,UAAA;AAAA,IAAA,CAAC,CAACF,KAAU,gBAAAO,EAAA,SAAA,EAAO,UAAMP,GAAA;AAAA,IACzB,CAAC,CAACF,KAAe,gBAAAS,EAAC,OAAG,UAAYT,GAAA;AAAA,IACjCY,sBACCE,GACC,EAAA,UAAA;AAAA,MAAA,CAAC,CAACX,KAAW,gBAAAM,EAAA,QAAA,EAAM,UAAON,GAAA;AAAA,MAC1BU;AAAA,MACA,CAAC,CAACR,KAAU,gBAAAI,EAAC,UAAM,UAAOJ,EAAA,CAAA;AAAA,IAAA,EAAA,CAC5B,IAEAQ;AAAA,IAEA,CAAC,CAACZ,KAAS,gBAAAQ,EAAC,SAAI,WAAWE,EAAO,YAAa,UAAMV,GAAA;AAAA,IACrD,CAAC,CAACF,KAAU,gBAAAU,EAAA,KAAA,EAAE,cAAYV,EAAO,CAAA;AAAA,EAAA,GACnC;AAEF,CAAC,GAEKe,IAAepB;AAAA,EACpB,SAAsB,EAAE,WAAAI,GAAW,GAAGQ,EAAA,GAAQC,GAAK;AAEjD,WAAA,gBAAAE,EAAC,OAAI,EAAA,WAAWC,EAAKC,EAAO,SAASb,CAAS,GAAG,KAAAS,GAAW,GAAGD,EAAM,CAAA;AAAA,EAAA;AAGxE,GAEaX,IAAQ,OAAO,OAAOF,GAAW;AAAA,EAC7C,SAASqB;AACV,CAAC;"}
1
+ {"version":3,"file":"field.js","sources":["../../designsystem/field/field.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type JSX, forwardRef } from \"react\";\nimport type { InputProps } from \"../input/input\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\ntype FieldBaseProps = InputProps & {\n\tclassName?: InputProps[\"className\"];\n\tstyle?: InputProps[\"style\"];\n\tlabel?: React.ReactNode;\n\tdescription?: React.ReactNode;\n\tprefix?: string;\n\tsuffix?: string;\n\terror?: React.ReactNode;\n\tcount?: number;\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\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\tas,\n\t\tclassName,\n\t\tcount,\n\t\tdescription,\n\t\terror,\n\t\tlabel,\n\t\tprefix,\n\t\tstyle,\n\t\tsuffix,\n\t\t...rest\n\t}: FieldProps<As>,\n\tref?: PolymorphicRef<As>,\n) {\n\tconst Tag = as || \"div\";\n\tconst shared = {\n\t\t\"data-size\": size,\n\t\tclassName: clsx(styles.field, className),\n\t\tstyle,\n\t};\n\tconst affixes = !!suffix || !!prefix;\n\tconst input = (\n\t\t<Tag className={styles.input} aria-invalid={!!error} ref={ref} {...rest} />\n\t);\n\n\treturn as ? (\n\t\t<div {...shared}>\n\t\t\t{!!label && <label>{label}</label>}\n\t\t\t{!!description && <p>{description}</p>}\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{input}\n\t\t\t\t\t{!!suffix && <span>{suffix}</span>}\n\t\t\t\t</FieldAffixes>\n\t\t\t) : (\n\t\t\t\tinput\n\t\t\t)}\n\t\t\t{!!error && <div className={styles.validation}>{error}</div>}\n\t\t\t{!!count && <p data-count={count} />}\n\t\t</div>\n\t) : (\n\t\t<div ref={ref} {...shared} {...rest} />\n\t);\n}) as FieldComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nconst FieldAffixes = forwardRef<HTMLDivElement, FieldProps>(\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 const Field = Object.assign(FieldComp, {\n\tAffixes: FieldAffixes,\n});\n"],"names":["FieldComp","forwardRef","size","as","className","count","description","error","label","prefix","style","suffix","rest","ref","Tag","shared","clsx","styles","affixes","input","jsx","jsxs","FieldAffixes","Field"],"mappings":";;;;AA2Ba,MAAAA,IAA4BC,EAAiB,SAGzD;AAAA,EACC,aAAaC;AAAA,EACb,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,GAAGC;AACJ,GACAC,GACC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7C,SAASsB;AACV,CAAC;"}
@@ -6,3 +6,4 @@ export default meta;
6
6
  type Story = StoryObj<typeof meta>;
7
7
  export declare const Default: Story;
8
8
  export declare const React: Story;
9
+ export declare const WithIcon: Story;