@fremtind/jokul 4.5.1 → 4.6.1

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.
Files changed (92) hide show
  1. package/build/build-stats.html +1 -1
  2. package/build/cjs/components/icon/Icon.cjs +1 -1
  3. package/build/cjs/components/icon/Icon.cjs.map +1 -1
  4. package/build/cjs/components/icon/Icon.d.cts +2 -2
  5. package/build/cjs/components/icon/icons/GreenCheckIcon.cjs +1 -1
  6. package/build/cjs/components/icon/icons/GreenCheckIcon.cjs.map +1 -1
  7. package/build/cjs/components/icon/icons/GreenCheckIcon.d.cts +2 -3
  8. package/build/cjs/components/icon/icons/RedCrossIcon.cjs +1 -1
  9. package/build/cjs/components/icon/icons/RedCrossIcon.cjs.map +1 -1
  10. package/build/cjs/components/icon/icons/RedCrossIcon.d.cts +2 -3
  11. package/build/cjs/components/number-input/NumberInput.cjs +2 -0
  12. package/build/cjs/components/number-input/NumberInput.cjs.map +1 -0
  13. package/build/cjs/components/number-input/NumberInput.d.cts +7 -0
  14. package/build/cjs/components/number-input/index.cjs +2 -0
  15. package/build/cjs/components/number-input/index.cjs.map +1 -0
  16. package/build/cjs/components/number-input/index.d.cts +2 -0
  17. package/build/cjs/components/number-input/types.cjs +2 -0
  18. package/build/cjs/components/number-input/types.cjs.map +1 -0
  19. package/build/cjs/components/number-input/types.d.cts +20 -0
  20. package/build/cjs/components/text-area/BaseTextArea.cjs +1 -1
  21. package/build/cjs/components/text-area/BaseTextArea.cjs.map +1 -1
  22. package/build/cjs/components/text-area/counter.cjs +2 -0
  23. package/build/cjs/components/text-area/counter.cjs.map +1 -0
  24. package/build/cjs/components/text-area/counter.d.cts +2 -0
  25. package/build/cjs/components/text-area/types.d.cts +21 -1
  26. package/build/es/components/icon/Icon.d.ts +2 -2
  27. package/build/es/components/icon/Icon.js +1 -1
  28. package/build/es/components/icon/Icon.js.map +1 -1
  29. package/build/es/components/icon/icons/GreenCheckIcon.d.ts +2 -3
  30. package/build/es/components/icon/icons/GreenCheckIcon.js +1 -1
  31. package/build/es/components/icon/icons/GreenCheckIcon.js.map +1 -1
  32. package/build/es/components/icon/icons/RedCrossIcon.d.ts +2 -3
  33. package/build/es/components/icon/icons/RedCrossIcon.js +1 -1
  34. package/build/es/components/icon/icons/RedCrossIcon.js.map +1 -1
  35. package/build/es/components/number-input/NumberInput.d.ts +7 -0
  36. package/build/es/components/number-input/NumberInput.js +2 -0
  37. package/build/es/components/number-input/NumberInput.js.map +1 -0
  38. package/build/es/components/number-input/index.d.ts +2 -0
  39. package/build/es/components/number-input/index.js +2 -0
  40. package/build/es/components/number-input/index.js.map +1 -0
  41. package/build/es/components/number-input/types.d.ts +20 -0
  42. package/build/es/components/number-input/types.js +2 -0
  43. package/build/es/components/number-input/types.js.map +1 -0
  44. package/build/es/components/text-area/BaseTextArea.js +1 -1
  45. package/build/es/components/text-area/BaseTextArea.js.map +1 -1
  46. package/build/es/components/text-area/counter.d.ts +2 -0
  47. package/build/es/components/text-area/counter.js +2 -0
  48. package/build/es/components/text-area/counter.js.map +1 -0
  49. package/build/es/components/text-area/types.d.ts +21 -1
  50. package/package.json +13 -1
  51. package/styles/components/button/button.css +2 -1
  52. package/styles/components/button/button.min.css +1 -1
  53. package/styles/components/button/button.scss +3 -2
  54. package/styles/components/countdown/countdown.css +2 -2
  55. package/styles/components/countdown/countdown.min.css +1 -1
  56. package/styles/components/feedback/feedback.css +2 -2
  57. package/styles/components/feedback/feedback.min.css +1 -1
  58. package/styles/components/file/file.css +1 -1
  59. package/styles/components/file/file.min.css +1 -1
  60. package/styles/components/file/file.scss +2 -1
  61. package/styles/components/file-input/file-input.css +12 -11
  62. package/styles/components/file-input/file-input.min.css +1 -1
  63. package/styles/components/icon/icon.css +28 -14
  64. package/styles/components/icon/icon.min.css +1 -1
  65. package/styles/components/icon/icon.scss +26 -20
  66. package/styles/components/input-group/input-group.css +2 -2
  67. package/styles/components/input-group/input-group.min.css +1 -1
  68. package/styles/components/list/list.css +34 -40
  69. package/styles/components/list/list.min.css +1 -1
  70. package/styles/components/list/list.scss +23 -25
  71. package/styles/components/loader/loader.css +6 -6
  72. package/styles/components/loader/loader.min.css +1 -1
  73. package/styles/components/loader/skeleton-loader.css +3 -3
  74. package/styles/components/loader/skeleton-loader.min.css +1 -1
  75. package/styles/components/message/message.css +2 -2
  76. package/styles/components/message/message.min.css +1 -1
  77. package/styles/components/number-input/_index.scss +2 -0
  78. package/styles/components/number-input/number-input.css +222 -0
  79. package/styles/components/number-input/number-input.min.css +1 -0
  80. package/styles/components/number-input/number-input.scss +121 -0
  81. package/styles/components/progress-bar/progress-bar.css +1 -1
  82. package/styles/components/progress-bar/progress-bar.min.css +1 -1
  83. package/styles/components/segmented-control/segmented-control.css +30 -16
  84. package/styles/components/segmented-control/segmented-control.min.css +1 -1
  85. package/styles/components/system-message/system-message.css +2 -2
  86. package/styles/components/system-message/system-message.min.css +1 -1
  87. package/styles/components/toast/toast.css +4 -4
  88. package/styles/components/toast/toast.min.css +1 -1
  89. package/styles/core/jkl/_convert.scss +15 -6
  90. package/styles/styles.css +308 -80
  91. package/styles/styles.min.css +1 -1
  92. package/styles/styles.scss +1 -0
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("../../../clsx-E3yX_9sL.cjs"),c=require("react").forwardRef(function(c,i){const{bold:l,children:n,className:o,filled:s,variant:t,...a}=c;return e.jsx("span",{"aria-hidden":!0,ref:i,className:r.clsx("jkl-icon",o,{"jkl-icon--filled":s,"jkl-icon--bold":l}),...a,children:n})});exports.Icon=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("../../../clsx-E3yX_9sL.cjs"),i=require("react").forwardRef(function(i,s){const{as:a="span",bold:c,children:l,className:n,filled:d,variant:o,...t}=i,u=r.clsx("jkl-icon",n,{"jkl-icon--filled":d,"jkl-icon--bold":c});return"div"===a?e.jsx("div",{"aria-hidden":!0,ref:s,className:u,...t,children:l}):e.jsx("span",{"aria-hidden":!0,ref:s,className:u,...t,children:l})});exports.Icon=i;
2
2
  //# sourceMappingURL=Icon.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.cjs","sources":["../../../../src/components/icon/Icon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport type {\n PolymorphicPropsWithRef,\n PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport type { IconVariant } from \"./types.js\";\n\ntype IconComponentProps<\n ElementType extends Extract<React.ElementType, \"span\" | \"div\">,\n> = PolymorphicPropsWithRef<\n ElementType,\n {\n \"data-testid\"?: string;\n /**\n * Størrelsesvarianten til ikonet. `\"small\"` er 16px med 20px bounding box, og `\"medium\"` er 20px med 24px bounding box.\n * `\"inherit\"` setter størrelsen til ikonet (ikke bounding box) lik skriftstørrelsen (1em).\n */\n variant?: IconVariant;\n /**\n * Angir om ikonet skal vises i fet versjon\n * @default false\n */\n bold?: boolean;\n filled?: boolean;\n className?: string;\n style?: React.CSSProperties;\n }\n>;\n\nexport type IconComponent = (<\n ElementType extends Extract<React.ElementType, \"span\" | \"div\"> = \"span\",\n>(\n props: IconComponentProps<ElementType>,\n) => React.ReactElement | null) & { displayName?: string };\n\nexport const Icon: IconComponent = React.forwardRef(function Icon<\n ElementType extends Extract<React.ElementType, \"span\" | \"div\"> = \"span\",\n>(props: IconComponentProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const { bold, children, className, filled, variant, ...iconProps } = props;\n\n return (\n <span\n aria-hidden\n ref={ref}\n className={clsx(\"jkl-icon\", className, {\n \"jkl-icon--filled\": filled,\n \"jkl-icon--bold\": bold,\n })}\n {...iconProps}\n >\n {children}\n </span>\n );\n}) as IconComponent;\n"],"names":["Icon","forwardRef","props","ref","bold","children","className","filled","variant","iconProps","jsx","clsx"],"mappings":"6JAoCaA,mBAA4BC,WAAW,SAElDC,EAAwCC,GACtC,MAAQC,KAAAA,EAAMC,SAAAA,EAAUC,UAAAA,EAAWC,OAAAA,EAAQC,QAAAA,KAAYC,GAAcP,EAErE,OACIQ,EAAAA,IAAC,OAAA,CACG,eAAW,EACXP,IAAAA,EACAG,UAAWK,EAAAA,KAAK,WAAYL,EAAW,CACnC,mBAAoBC,EACpB,iBAAkBH,OAElBK,EAEHJ,SAAAA,GAGb"}
1
+ {"version":3,"file":"Icon.cjs","sources":["../../../../src/components/icon/Icon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport type {\n PolymorphicPropsWithRef,\n PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport type { IconVariant } from \"./types.js\";\n\ntype IconComponentProps<\n ElementType extends \"span\" | \"div\",\n> = PolymorphicPropsWithRef<\n ElementType,\n {\n \"data-testid\"?: string;\n /**\n * Størrelsesvarianten til ikonet. `\"small\"` er 16px med 20px bounding box, og `\"medium\"` er 20px med 24px bounding box.\n * `\"inherit\"` setter størrelsen til ikonet (ikke bounding box) lik skriftstørrelsen (1em).\n */\n variant?: IconVariant;\n /**\n * Angir om ikonet skal vises i fet versjon\n * @default false\n */\n bold?: boolean;\n filled?: boolean;\n className?: string;\n style?: React.CSSProperties;\n }\n>;\n\nexport type IconComponent = (<\n ElementType extends \"span\" | \"div\" = \"span\",\n>(\n props: IconComponentProps<ElementType>,\n) => React.ReactElement | null) & { displayName?: string };\n\nexport const Icon: IconComponent = React.forwardRef(function Icon<\n ElementType extends \"span\" | \"div\" = \"span\",\n>(props: IconComponentProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n as = \"span\",\n bold,\n children,\n className,\n filled,\n variant,\n ...iconProps\n } = props;\n const iconClassName = clsx(\"jkl-icon\", className, {\n \"jkl-icon--filled\": filled,\n \"jkl-icon--bold\": bold,\n });\n\n if (as === \"div\") {\n return (\n <div\n aria-hidden\n ref={ref as PolymorphicRef<\"div\">}\n className={iconClassName}\n {...(iconProps as React.HTMLAttributes<HTMLDivElement>)}\n >\n {children}\n </div>\n );\n }\n\n return (\n <span\n aria-hidden\n ref={ref as PolymorphicRef<\"span\">}\n className={iconClassName}\n {...(iconProps as React.HTMLAttributes<HTMLSpanElement>)}\n >\n {children}\n </span>\n );\n}) as IconComponent;\n"],"names":["Icon","forwardRef","props","ref","as","bold","children","className","filled","variant","iconProps","iconClassName","clsx","jsx"],"mappings":"6JAoCaA,mBAA4BC,WAAW,SAElDC,EAAwCC,GACtC,MACIC,GAAAA,EAAK,OACLC,KAAAA,EACAC,SAAAA,EACAC,UAAAA,EACAC,OAAAA,EACAC,QAAAA,KACGC,GACHR,EACES,EAAgBC,EAAAA,KAAK,WAAYL,EAAW,CAC9C,mBAAoBC,EACpB,iBAAkBH,IAGtB,MAAW,QAAPD,EAEIS,EAAAA,IAAC,MAAA,CACG,eAAW,EACXV,IAAAA,EACAI,UAAWI,KACND,EAEJJ,SAAAA,IAMTO,EAAAA,IAAC,OAAA,CACG,eAAW,EACXV,IAAAA,EACAI,UAAWI,KACND,EAEJJ,SAAAA,GAGb"}
@@ -1,7 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  import { PolymorphicPropsWithRef } from '../../utilities/polymorphism/polymorphism.cjs';
3
3
  import { IconVariant } from './types.cjs';
4
- type IconComponentProps<ElementType extends Extract<React.ElementType, "span" | "div">> = PolymorphicPropsWithRef<ElementType, {
4
+ type IconComponentProps<ElementType extends "span" | "div"> = PolymorphicPropsWithRef<ElementType, {
5
5
  "data-testid"?: string;
6
6
  /**
7
7
  * Størrelsesvarianten til ikonet. `"small"` er 16px med 20px bounding box, og `"medium"` er 20px med 24px bounding box.
@@ -17,7 +17,7 @@ type IconComponentProps<ElementType extends Extract<React.ElementType, "span" |
17
17
  className?: string;
18
18
  style?: React.CSSProperties;
19
19
  }>;
20
- export type IconComponent = (<ElementType extends Extract<React.ElementType, "span" | "div"> = "span">(props: IconComponentProps<ElementType>) => React.ReactElement | null) & {
20
+ export type IconComponent = (<ElementType extends "span" | "div" = "span">(props: IconComponentProps<ElementType>) => React.ReactElement | null) & {
21
21
  displayName?: string;
22
22
  };
23
23
  export declare const Icon: IconComponent;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../../../clsx-E3yX_9sL.cjs");require("react");const c=({as:c="div",bold:r=!1,className:s,variant:i="inherit","data-testid":l,style:n,...o})=>{const a=c;return e.jsx(a,{className:t.clsx(s,"jkl-icon","jkl-icon-green-check",`jkl-icon--${i}`,{"jkl-icon--bold":r}),"aria-hidden":"true",style:n,"data-testid":l,...o,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24px",height:"24px",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{fillRule:"evenodd",d:"M17.52 9.54 10.7 16.2l-4.21-4.1 1.04-1.08 3.17 3.09 5.79-5.65 1.04 1.08Z",clipRule:"evenodd"})]})})};c.displayName="GreenCheckIcon",exports.GreenCheckIcon=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("../../../../clsx-E3yX_9sL.cjs");require("react");const r=require("../Icon.cjs"),s=s=>e.jsx(r.Icon,{...s,className:c.clsx("jkl-icon-green-check",s.className),children:""});s.displayName="GreenCheckIcon",exports.GreenCheckIcon=s;
2
2
  //# sourceMappingURL=GreenCheckIcon.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"GreenCheckIcon.cjs","sources":["../../../../../src/components/icon/icons/GreenCheckIcon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type FC } from \"react\";\nimport type { IconProps } from \"../types.js\";\n\n/*\n * NOTE: The green-check and red-cross icons also exists as a copy in the jkl-list package.\n * If you're here to change them, consider changing them there as well, or\n * finding a technical solution to sharing the SVG markup\n */\nexport const GreenCheckIcon: FC<IconProps> = ({\n as = \"div\",\n bold = false,\n className,\n variant = \"inherit\",\n \"data-testid\": testId,\n style,\n ...rest\n}) => {\n const El = as;\n\n return (\n <El\n className={clsx(\n className,\n \"jkl-icon\",\n \"jkl-icon-green-check\",\n `jkl-icon--${variant}`,\n {\n \"jkl-icon--bold\": bold,\n },\n )}\n aria-hidden=\"true\"\n style={style}\n data-testid={testId}\n {...rest}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n width=\"24px\"\n height=\"24px\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path\n fillRule=\"evenodd\"\n d=\"M17.52 9.54 10.7 16.2l-4.21-4.1 1.04-1.08 3.17 3.09 5.79-5.65 1.04 1.08Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </El>\n );\n};\nGreenCheckIcon.displayName = \"GreenCheckIcon\";\n"],"names":["GreenCheckIcon","as","bold","className","variant","testId","style","rest","El","jsx","clsx","children","jsxs","xmlns","viewBox","width","height","cx","cy","r","fillRule","d","clipRule","displayName"],"mappings":"iLASO,MAAMA,EAAgC,EACzCC,GAAAA,EAAK,MACLC,KAAAA,GAAO,EACPC,UAAAA,EACAC,QAAAA,EAAU,UACV,cAAeC,EACfC,MAAAA,KACGC,MAEH,MAAMC,EAAKP,EAEX,OACIQ,EAAAA,IAACD,EAAA,CACGL,UAAWO,EAAAA,KACPP,EACA,WACA,uBACA,aAAaC,IACb,CACI,iBAAkBF,IAG1B,cAAY,OACZI,MAAAA,EACA,cAAaD,KACTE,EAEJI,SAAAC,EAAAA,KAAC,MAAA,CACGC,MAAM,6BACNC,QAAQ,YACRC,MAAM,OACNC,OAAO,OAEPL,SAAA,CAAAF,MAAC,UAAOQ,GAAG,KAAKC,GAAG,KAAKC,EAAE,OAC1BV,EAAAA,IAAC,OAAA,CACGW,SAAS,UACTC,EAAE,2EACFC,SAAS,kBAM7BtB,EAAeuB,YAAc"}
1
+ {"version":3,"file":"GreenCheckIcon.cjs","sources":["../../../../../src/components/icon/icons/GreenCheckIcon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport { Icon, type IconComponent } from \"../Icon.js\";\nimport type { IconProps } from \"../types.js\";\n\nexport const GreenCheckIcon: IconComponent = (props: IconProps) => (\n <Icon {...props} className={clsx(\"jkl-icon-green-check\", props.className)}>\n {\"\\ue5ca\"}\n </Icon>\n);\nGreenCheckIcon.displayName = \"GreenCheckIcon\";\n"],"names":["GreenCheckIcon","props","jsx","Icon","className","clsx","children","displayName"],"mappings":"gNAKaA,EAAiCC,GAC1CC,EAAAA,IAACC,EAAAA,KAAA,IAASF,EAAOG,UAAWC,EAAAA,KAAK,uBAAwBJ,EAAMG,WAC1DE,SAAA,MAGTN,EAAeO,YAAc"}
@@ -1,3 +1,2 @@
1
- import { FC } from 'react';
2
- import { IconProps } from '../types.cjs';
3
- export declare const GreenCheckIcon: FC<IconProps>;
1
+ import { IconComponent } from '../Icon.cjs';
2
+ export declare const GreenCheckIcon: IconComponent;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("../../../../clsx-E3yX_9sL.cjs");require("react");const t=({as:t="div",bold:r=!1,className:i,variant:c="inherit","data-testid":o,style:a,...l})=>{const d=t;return e.jsx(d,{className:s.clsx(i,"jkl-icon","jkl-icon-red-cross",`jkl-icon--${c}`,{"jkl-icon--bold":r}),"aria-hidden":"true",style:a,"data-testid":o,...l,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24px",height:"24px",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"m15.71 7.23 1.06 1.06-8.48 8.48-1.06-1.06 8.48-8.48Z"}),e.jsx("path",{d:"m8.29 7.23 8.48 8.48-1.06 1.06L7.23 8.3l1.06-1.06Z"})]})})};t.displayName="RedCrossIcon",exports.RedCrossIcon=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("../../../../clsx-E3yX_9sL.cjs");require("react");const r=require("../Icon.cjs"),c=c=>e.jsx(r.Icon,{...c,className:s.clsx("jkl-icon-red-cross",c.className),children:""});c.displayName="RedCrossIcon",exports.RedCrossIcon=c;
2
2
  //# sourceMappingURL=RedCrossIcon.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RedCrossIcon.cjs","sources":["../../../../../src/components/icon/icons/RedCrossIcon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type FC } from \"react\";\nimport type { IconProps } from \"../types.js\";\n\n/*\n * NOTE: The green-check and red-cross icons also exists as a copy in the jkl-list package.\n * If you're here to change them, consider changing them there as well, or\n * finding a technical solution to sharing the SVG markup\n */\nexport const RedCrossIcon: FC<IconProps> = ({\n as = \"div\",\n bold = false,\n className,\n variant = \"inherit\",\n \"data-testid\": testId,\n style,\n ...rest\n}) => {\n const El = as;\n\n return (\n <El\n className={clsx(\n className,\n \"jkl-icon\",\n \"jkl-icon-red-cross\",\n `jkl-icon--${variant}`,\n {\n \"jkl-icon--bold\": bold,\n },\n )}\n aria-hidden=\"true\"\n style={style}\n data-testid={testId}\n {...rest}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n width=\"24px\"\n height=\"24px\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"m15.71 7.23 1.06 1.06-8.48 8.48-1.06-1.06 8.48-8.48Z\" />\n <path d=\"m8.29 7.23 8.48 8.48-1.06 1.06L7.23 8.3l1.06-1.06Z\" />\n </svg>\n </El>\n );\n};\nRedCrossIcon.displayName = \"RedCrossIcon\";\n"],"names":["RedCrossIcon","as","bold","className","variant","testId","style","rest","El","jsx","clsx","children","jsxs","xmlns","viewBox","width","height","cx","cy","r","d","displayName"],"mappings":"iLASO,MAAMA,EAA8B,EACvCC,GAAAA,EAAK,MACLC,KAAAA,GAAO,EACPC,UAAAA,EACAC,QAAAA,EAAU,UACV,cAAeC,EACfC,MAAAA,KACGC,MAEH,MAAMC,EAAKP,EAEX,OACIQ,EAAAA,IAACD,EAAA,CACGL,UAAWO,EAAAA,KACPP,EACA,WACA,qBACA,aAAaC,IACb,CACI,iBAAkBF,IAG1B,cAAY,OACZI,MAAAA,EACA,cAAaD,KACTE,EAEJI,SAAAC,EAAAA,KAAC,MAAA,CACGC,MAAM,6BACNC,QAAQ,YACRC,MAAM,OACNC,OAAO,OAEPL,SAAA,CAAAF,MAAC,UAAOQ,GAAG,KAAKC,GAAG,KAAKC,EAAE,OAC1BV,EAAAA,IAAC,OAAA,CAAKW,EAAE,yDACRX,EAAAA,IAAC,OAAA,CAAKW,EAAE,6DAKxBpB,EAAaqB,YAAc"}
1
+ {"version":3,"file":"RedCrossIcon.cjs","sources":["../../../../../src/components/icon/icons/RedCrossIcon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport { Icon, type IconComponent } from \"../Icon.js\";\nimport type { IconProps } from \"../types.js\";\n\nexport const RedCrossIcon: IconComponent = (props: IconProps) => (\n <Icon {...props} className={clsx(\"jkl-icon-red-cross\", props.className)}>\n {\"\\ue5cd\"}\n </Icon>\n);\nRedCrossIcon.displayName = \"RedCrossIcon\";\n"],"names":["RedCrossIcon","props","jsx","Icon","className","clsx","children","displayName"],"mappings":"gNAKaA,EAA+BC,GACxCC,EAAAA,IAACC,EAAAA,KAAA,IAASF,EAAOG,UAAWC,EAAAA,KAAK,qBAAsBJ,EAAMG,WACxDE,SAAA,MAGTN,EAAaO,YAAc"}
@@ -1,3 +1,2 @@
1
- import { FC } from 'react';
2
- import { IconProps } from '../types.cjs';
3
- export declare const RedCrossIcon: FC<IconProps>;
1
+ import { IconComponent } from '../Icon.cjs';
2
+ export declare const RedCrossIcon: IconComponent;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("../../../clsx-E3yX_9sL.cjs"),i=require("react"),r=require("../../utilities/mergeRefs.cjs");require("../icon/Icon.cjs"),require("../icon/icons/animated/ArrowVerticalAnimated.cjs"),require("../icon/icons/animated/ArrowHorizontalAnimated.cjs"),require("../icon/icons/animated/PlusRemoveAnimated.cjs"),require("../icon/icons/ArrowDownIcon.cjs"),require("../icon/icons/ArrowLeftIcon.cjs"),require("../icon/icons/ArrowNorthEastIcon.cjs"),require("../icon/icons/ArrowRightIcon.cjs"),require("../icon/icons/ArrowUpIcon.cjs"),require("../icon/icons/CalendarIcon.cjs"),require("../icon/icons/CheckIcon.cjs"),require("../icon/icons/ChevronDownIcon.cjs"),require("../icon/icons/ChevronLeftIcon.cjs"),require("../icon/icons/ChevronRightIcon.cjs"),require("../icon/icons/ChevronUpIcon.cjs"),require("../icon/icons/CloseIcon.cjs"),require("../icon/icons/CopyIcon.cjs"),require("../icon/icons/DotsIcon.cjs"),require("../icon/icons/DragIcon.cjs"),require("../icon/icons/ErrorIcon.cjs"),require("../icon/icons/GreenCheckIcon.cjs"),require("../icon/icons/HamburgerIcon.cjs"),require("../icon/icons/InfoIcon.cjs"),require("../icon/icons/LinkIcon.cjs");const c=require("../icon/icons/MinusIcon.cjs");require("../icon/icons/OpenInNewIcon.cjs"),require("../icon/icons/PenIcon.cjs");const o=require("../icon/icons/PlusIcon.cjs");require("../icon/icons/QuestionIcon.cjs"),require("../icon/icons/RedCrossIcon.cjs"),require("../icon/icons/SearchIcon.cjs"),require("../icon/icons/SuccessIcon.cjs"),require("../icon/icons/ThumbDownIcon.cjs"),require("../icon/icons/ThumbUpIcon.cjs"),require("../icon/icons/TrashCanIcon.cjs"),require("../icon/icons/WarningIcon.cjs");const s=require("../input-group/InputGroup.cjs"),t={decrement:{label:"Senk verdien",Icon:c.MinusIcon},increment:{label:"Øk verdien",Icon:o.PlusIcon}};function u({direction:n,disabled:i,onClick:r}){const{label:c,Icon:o}=t[n];return e.jsx("button",{type:"button",className:"jkl-button jkl-button--ghost","aria-label":c,"data-direction":n,onPointerDown:e=>e.preventDefault(),onClick:r,disabled:i,children:e.jsx("span",{"aria-hidden":"true",children:e.jsx(o,{})})})}const a=i.forwardRef((c,o)=>{const{"data-size":t,"data-testautoid":a,"data-testid":l,align:d="left",id:p,label:j,className:m,style:b,errorLabel:I,helpLabel:q,inputClassName:h,labelProps:N,supportLabelProps:v,stepper:f=!1,tooltip:g,description:w,width:k,onChange:C,...x}=c,y=i.useRef(null),A=r.mergeRefs(y,o),[P,_]=i.useState(x.defaultValue),L=void 0!==x.value?x.value:P,D=e=>{void 0===x.value&&_(e.target.value),C?.(e)},R=function(e){return"number"==typeof e?e:"string"==typeof e&&""!==e.trim()?Number(e):Number.NaN}(L),S=void 0!==x.min?Number(x.min):Number.NaN,E=void 0!==x.max?Number(x.max):Number.NaN,F=Number.isFinite(R)&&Number.isFinite(S)&&R<=S,O=Number.isFinite(R)&&Number.isFinite(E)&&R>=E,T=b||k?{...b,...k?{width:k}:void 0}:void 0,U={id:p,label:j,errorLabel:I,helpLabel:q,labelProps:N,supportLabelProps:v,tooltip:g,description:w},z=e=>{const n=y.current;if(!n||n.disabled||n.readOnly)return;const i=n.value;n.focus();try{"increment"===e?n.stepUp():n.stepDown()}catch{return}n.value!==i&&n.dispatchEvent(new Event("input",{bubbles:!0}))},G=x.disabled||x.readOnly;return e.jsx(s.InputGroup,{...U,className:n.clsx(m,"jkl-number-input"),"data-size":t,"data-testid":l??"jkl-number-input",render:i=>e.jsxs("div",{className:n.clsx("jkl-number-input__wrapper",{"jkl-number-input__wrapper--stepper":f}),"data-invalid":i["aria-invalid"],style:T,children:[f&&e.jsx(u,{direction:"decrement",disabled:G||F,onClick:()=>z("decrement")}),e.jsx("input",{...i,...x,ref:A,type:"number",onChange:D,className:n.clsx("jkl-number-input__input",{"jkl-number-input__input--stepper":f,"jkl-number-input__input--align-right":!f&&"right"===d},h),"data-testautoid":a}),f&&e.jsx(u,{direction:"increment",disabled:G||O,onClick:()=>z("increment")})]})})});a.displayName="NumberInput",exports.NumberInput=a;
2
+ //# sourceMappingURL=NumberInput.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberInput.cjs","sources":["../../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n type ComponentType,\n forwardRef,\n useRef,\n useState,\n} from \"react\";\nimport { mergeRefs } from \"../../utilities/mergeRefs.js\";\nimport { MinusIcon, PlusIcon } from \"../icon/index.js\";\nimport { InputGroup } from \"../input-group/InputGroup.js\";\nimport type { NumberInputProps } from \"./types.js\";\n\ntype NumberInputValue = string | number | readonly string[] | undefined;\n\ntype StepDirection = \"increment\" | \"decrement\";\n\nconst stepperConfig: Record<\n StepDirection,\n { label: string; Icon: ComponentType }\n> = {\n decrement: { label: \"Senk verdien\", Icon: MinusIcon },\n increment: { label: \"Øk verdien\", Icon: PlusIcon },\n};\n\nfunction toNumeric(value: NumberInputValue): number {\n if (typeof value === \"number\") {\n return value;\n }\n if (typeof value === \"string\" && value.trim() !== \"\") {\n return Number(value);\n }\n return Number.NaN;\n}\n\ntype StepperButtonProps = {\n direction: StepDirection;\n disabled: boolean;\n onClick: () => void;\n};\n\nfunction StepperButton({ direction, disabled, onClick }: StepperButtonProps) {\n const { label, Icon } = stepperConfig[direction];\n\n return (\n <button\n type=\"button\"\n className=\"jkl-button jkl-button--ghost\"\n aria-label={label}\n data-direction={direction}\n onPointerDown={(event) => event.preventDefault()}\n onClick={onClick}\n disabled={disabled}\n >\n <span aria-hidden=\"true\">\n <Icon />\n </span>\n </button>\n );\n}\n\nexport const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(\n (props, ref) => {\n const {\n \"data-size\": dataSize,\n \"data-testautoid\": testAutoId,\n \"data-testid\": dataTestId,\n align = \"left\",\n id,\n label,\n className,\n style,\n errorLabel,\n helpLabel,\n inputClassName,\n labelProps,\n supportLabelProps,\n stepper = false,\n tooltip,\n description,\n width,\n onChange,\n ...rest\n } = props;\n const internalRef = useRef<HTMLInputElement>(null);\n const mergedRef = mergeRefs(internalRef, ref);\n const [uncontrolledValue, setUncontrolledValue] =\n useState<NumberInputValue>(rest.defaultValue);\n\n // I kontrollert bruk må vi lese direkte fra `value` for at disabled-\n // state på stepper-knappene skal følge prop-en i samme render. Bruker\n // intern state som fallback for ukontrollert bruk.\n const effectiveValue =\n rest.value !== undefined ? rest.value : uncontrolledValue;\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (rest.value === undefined) {\n setUncontrolledValue(event.target.value);\n }\n onChange?.(event);\n };\n\n const numericValue = toNumeric(effectiveValue);\n const minNumeric =\n rest.min !== undefined ? Number(rest.min) : Number.NaN;\n const maxNumeric =\n rest.max !== undefined ? Number(rest.max) : Number.NaN;\n const isAtOrBelowMin =\n Number.isFinite(numericValue) &&\n Number.isFinite(minNumeric) &&\n numericValue <= minNumeric;\n const isAtOrAboveMax =\n Number.isFinite(numericValue) &&\n Number.isFinite(maxNumeric) &&\n numericValue >= maxNumeric;\n\n const inputWrapperStyle =\n style || width\n ? {\n ...style,\n ...(width ? { width } : undefined),\n }\n : undefined;\n const inputGroupProps = {\n id,\n label,\n errorLabel,\n helpLabel,\n labelProps,\n supportLabelProps,\n tooltip,\n description,\n };\n\n const triggerStep = (direction: StepDirection) => {\n const input = internalRef.current;\n\n if (!input || input.disabled || input.readOnly) {\n return;\n }\n\n const previousValue = input.value;\n input.focus();\n\n try {\n if (direction === \"increment\") {\n input.stepUp();\n } else {\n input.stepDown();\n }\n } catch {\n return;\n }\n\n if (input.value === previousValue) {\n return;\n }\n\n input.dispatchEvent(new Event(\"input\", { bubbles: true }));\n };\n\n const stepperDisabled = rest.disabled || rest.readOnly;\n\n return (\n <InputGroup\n {...inputGroupProps}\n className={clsx(className, \"jkl-number-input\")}\n data-size={dataSize}\n data-testid={dataTestId ?? \"jkl-number-input\"}\n render={(inputProps) => (\n <div\n className={clsx(\"jkl-number-input__wrapper\", {\n \"jkl-number-input__wrapper--stepper\": stepper,\n })}\n data-invalid={inputProps[\"aria-invalid\"]}\n style={inputWrapperStyle}\n >\n {stepper && (\n <StepperButton\n direction=\"decrement\"\n disabled={stepperDisabled || isAtOrBelowMin}\n onClick={() => triggerStep(\"decrement\")}\n />\n )}\n <input\n {...inputProps}\n {...rest}\n ref={mergedRef}\n type=\"number\"\n onChange={handleChange}\n className={clsx(\n \"jkl-number-input__input\",\n {\n \"jkl-number-input__input--stepper\": stepper,\n \"jkl-number-input__input--align-right\":\n !stepper && align === \"right\",\n },\n inputClassName,\n )}\n data-testautoid={testAutoId}\n />\n {stepper && (\n <StepperButton\n direction=\"increment\"\n disabled={stepperDisabled || isAtOrAboveMax}\n onClick={() => triggerStep(\"increment\")}\n />\n )}\n </div>\n )}\n />\n );\n },\n);\n\nNumberInput.displayName = \"NumberInput\";\n"],"names":["stepperConfig","decrement","label","Icon","MinusIcon","increment","PlusIcon","StepperButton","direction","disabled","onClick","jsx","type","className","onPointerDown","event","preventDefault","children","NumberInput","forwardRef","props","ref","dataSize","testAutoId","dataTestId","align","id","style","errorLabel","helpLabel","inputClassName","labelProps","supportLabelProps","stepper","tooltip","description","width","onChange","rest","internalRef","useRef","mergedRef","mergeRefs","uncontrolledValue","setUncontrolledValue","useState","defaultValue","effectiveValue","value","handleChange","target","numericValue","trim","Number","NaN","toNumeric","minNumeric","min","maxNumeric","max","isAtOrBelowMin","isFinite","isAtOrAboveMax","inputWrapperStyle","inputGroupProps","triggerStep","input","current","readOnly","previousValue","focus","stepUp","stepDown","dispatchEvent","Event","bubbles","stepperDisabled","InputGroup","clsx","render","inputProps","jsxs","displayName"],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ export declare const NumberInput: React.ForwardRefExoticComponent<Omit<import('../input-group/types.js').InputGroupProps, "children" | "inline" | "render"> & Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "children"> & {
3
+ align?: "left" | "right";
4
+ width?: string;
5
+ inputClassName?: string;
6
+ stepper?: boolean;
7
+ } & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./NumberInput.cjs");exports.NumberInput=e.NumberInput;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { NumberInput } from './NumberInput.cjs';
2
+ export type { NumberInputProps } from './types.cjs';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+ import { InputGroupProps } from '../input-group/types.cjs';
3
+ export type NumberInputProps = Omit<InputGroupProps, "children" | "inline" | "render"> & Omit<InputHTMLAttributes<HTMLInputElement>, "children" | "type"> & {
4
+ /**
5
+ * Justerer teksten i inputfeltet.
6
+ * @default "left"
7
+ */
8
+ align?: "left" | "right";
9
+ /**
10
+ * CSS-verdi for bredden til input-feltet.
11
+ */
12
+ width?: string;
13
+ inputClassName?: string;
14
+ /**
15
+ * Viser knapper på hver side av feltet som bruker native stepping.
16
+ * Respekterer `min`, `max` og `step`.
17
+ * @default false
18
+ */
19
+ stepper?: boolean;
20
+ };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=t.forwardRef((a,r)=>{const{autoExpand:s,counter:n,onBlur:o,onFocus:l,rows:i=7,placeholder:u=" ",startOpen:c,style:d,value:h,"aria-invalid":x,onChange:g,...v}=a,[f,p]=t.useState(()=>typeof h>"u"?0:"number"==typeof h?String(h).length:h.length),[j,y]=t.useState(!1),m=t.useRef(null),_=r||m;t.useEffect(()=>{const e=_.current;if(e){if(!s)return void(e.style.height="");j||h?(e.style.height="auto",e.style.height=`${e.scrollHeight}px`):e.style.height=""}},[s,_,h,j,f]);const k=n?.maxLength||0,w=k-f;const N=!(!x&&!(n&&f>k?`Du har skrevet ${f-k} tegn for mye`:void 0)),S={overflowX:s?"hidden":void 0};return e.jsxs("div",{className:"jkl-text-area-wrapper","data-invalid":N,"data-has-content":f>0,children:[e.jsx("textarea",{"aria-invalid":N,className:`jkl-text-area__text-area jkl-text-area__text-area--${i}-rows`,onBlur:function(e){y(!1),o&&o(e)},onFocus:function(e){y(!0),l&&l(e)},onChange:function(e){p(e.target.value.length),g&&g(e)},ref:_,style:{...d,...S},placeholder:u,value:h,...v}),n&&e.jsxs("div",{className:"jkl-text-area__counter","aria-hidden":"true",children:[e.jsxs("div",{className:"jkl-text-area__counter-count",children:[f," / ",k]}),!n.hideProgress&&e.jsx("div",{className:"jkl-text-area__counter-progress",style:{"--progress-width":(B=w,b=k,B<=0||0===b?0:100*B/b)+"%"}})]})]});var B,b});a.displayName="BaseTextArea",exports.BaseTextArea=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("./counter.cjs"),r=t.forwardRef((r,s)=>{const{autoExpand:l,counter:n,defaultValue:o,onBlur:u,onFocus:i,rows:c=7,placeholder:d=" ",startOpen:h,style:x,value:f,"aria-invalid":g,onChange:v,...j}=r,p=n?.strategy??"characters",y=typeof f<"u",[_,m]=t.useState(o),[k,w]=t.useState(!1),N=t.useRef(null),B=s||N,S=y?f:_,q=y?{value:f}:{defaultValue:o},C=a.getCounterValue(S,p),T=n?.maxLength||0,V=T-C,b=!(!g&&!!!(n&&C>T));t.useEffect(()=>{const e=B.current;if(e){if(!l)return void(e.style.height="");k||S?(e.style.height="auto",e.style.height=`${e.scrollHeight}px`):e.style.height=""}},[l,B,S,k,C]);const A={overflowX:l?"hidden":void 0};return e.jsxs("div",{className:"jkl-text-area-wrapper","data-invalid":b,"data-has-content":C>0,children:[e.jsx("textarea",{"aria-invalid":b,className:`jkl-text-area__text-area jkl-text-area__text-area--${c}-rows`,onBlur:function(e){w(!1),u&&u(e)},onFocus:function(e){w(!0),i&&i(e)},onChange:function(e){y||m(e.target.value),v&&v(e)},ref:B,style:{...x,...A},placeholder:d,...q,...j}),n&&e.jsxs("div",{className:"jkl-text-area__counter","aria-hidden":"true",children:[e.jsxs("div",{className:"jkl-text-area__counter-count",children:[C," / ",T]}),!n.hideProgress&&e.jsx("div",{className:"jkl-text-area__counter-progress",style:{"--progress-width":(E=V,F=T,E<=0||0===F?0:100*E/F)+"%"}})]})]});var E,F});r.displayName="BaseTextArea",exports.BaseTextArea=r;
2
2
  //# sourceMappingURL=BaseTextArea.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseTextArea.cjs","sources":["../../../../src/components/text-area/BaseTextArea.tsx"],"sourcesContent":["import React, {\n type ChangeEvent,\n type FocusEvent,\n forwardRef,\n type RefObject,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport type { BaseTextAreaProps } from \"./types.js\";\n\nexport const BaseTextArea = forwardRef<HTMLTextAreaElement, BaseTextAreaProps>(\n (props, ref) => {\n const {\n autoExpand,\n counter,\n onBlur,\n onFocus,\n rows = 7,\n placeholder = \" \", // This space intentionally left blank. Denne + rows trengs for å få den ekspanderende effekten.\n startOpen,\n style,\n value,\n \"aria-invalid\": ariaInvalid,\n onChange,\n ...rest\n } = props;\n\n const [counterCurrent, setCounterCurrent] = useState(() => {\n if (typeof value === \"undefined\") {\n return 0;\n }\n\n if (typeof value === \"number\") {\n return String(value).length;\n }\n\n return value.length;\n });\n const [textAreaFocused, setTextAreaFocused] = useState(false);\n const internalRef = useRef<HTMLTextAreaElement>(null);\n const textAreaRef =\n (ref as RefObject<HTMLTextAreaElement>) || internalRef;\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: counterCurrent trengs for å lytte på tekstendringer i textarea for auto-expand funksjonalitet\n useEffect(() => {\n const textAreaElement = textAreaRef.current;\n if (textAreaElement) {\n if (!autoExpand) {\n textAreaElement.style.height = \"\";\n return;\n }\n\n if (textAreaFocused || value) {\n textAreaElement.style.height = \"auto\"; // Sett til auto før scrollhøyden leses, sånn at redusering av høyde ved sletting av tekst fungerer\n textAreaElement.style.height = `${textAreaElement.scrollHeight}px`;\n } else {\n textAreaElement.style.height = \"\";\n }\n }\n }, [autoExpand, textAreaRef, value, textAreaFocused, counterCurrent]);\n\n function handleOnFocus(e: FocusEvent<HTMLTextAreaElement>) {\n setTextAreaFocused(true);\n if (onFocus) {\n onFocus(e);\n }\n }\n\n function handleOnBlur(e: FocusEvent<HTMLTextAreaElement>) {\n setTextAreaFocused(false);\n if (onBlur) {\n onBlur(e);\n }\n }\n\n function handleOnChange(e: ChangeEvent<HTMLTextAreaElement>) {\n setCounterCurrent(e.target.value.length);\n if (onChange) {\n onChange(e);\n }\n }\n\n const counterTotal: number = counter?.maxLength || 0;\n const progressCurrent: number = counterTotal - counterCurrent;\n function calculatePercentage(current: number, total: number): number {\n if (current <= 0) {\n return 0;\n }\n return total === 0 ? 0 : (current * 100) / total;\n }\n const counterLabel =\n counter && counterCurrent > counterTotal\n ? `Du har skrevet ${counterCurrent - counterTotal} tegn for mye`\n : undefined;\n\n const invalid = Boolean(ariaInvalid || counterLabel);\n\n const overflowStyle = {\n overflowX: autoExpand ? \"hidden\" : undefined, // Must set overflowX hidden for Firefox https://stackoverflow.com/a/22700700\n } as React.CSSProperties;\n\n return (\n <div\n className=\"jkl-text-area-wrapper\"\n data-invalid={invalid}\n data-has-content={counterCurrent > 0}\n >\n <textarea\n aria-invalid={invalid}\n className={`jkl-text-area__text-area jkl-text-area__text-area--${rows}-rows`}\n onBlur={handleOnBlur}\n onFocus={handleOnFocus}\n onChange={handleOnChange}\n ref={textAreaRef}\n style={{ ...style, ...overflowStyle }}\n placeholder={placeholder}\n value={value}\n {...rest}\n />\n {counter && (\n <div className=\"jkl-text-area__counter\" aria-hidden=\"true\">\n <div className=\"jkl-text-area__counter-count\">\n {counterCurrent}&nbsp;/&nbsp;{counterTotal}\n </div>\n {!counter.hideProgress && (\n <div\n className=\"jkl-text-area__counter-progress\"\n style={{\n [\"--progress-width\" as string]: `${calculatePercentage(\n progressCurrent,\n counterTotal,\n )}%`,\n }}\n />\n )}\n </div>\n )}\n </div>\n );\n },\n);\nBaseTextArea.displayName = \"BaseTextArea\";\n"],"names":["BaseTextArea","forwardRef","props","ref","autoExpand","counter","onBlur","onFocus","rows","placeholder","startOpen","style","value","ariaInvalid","onChange","rest","counterCurrent","setCounterCurrent","useState","String","length","textAreaFocused","setTextAreaFocused","internalRef","useRef","textAreaRef","useEffect","textAreaElement","current","height","scrollHeight","counterTotal","maxLength","progressCurrent","invalid","overflowStyle","overflowX","jsxs","className","children","jsx","e","target","hideProgress","total","displayName"],"mappings":"wIAWaA,EAAeC,EAAAA,WACxB,CAACC,EAAOC,KACJ,MACIC,WAAAA,EACAC,QAAAA,EACAC,OAAAA,EACAC,QAAAA,EACAC,KAAAA,EAAO,EACPC,YAAAA,EAAc,IACdC,UAAAA,EACAC,MAAAA,EACAC,MAAAA,EACA,eAAgBC,EAChBC,SAAAA,KACGC,GACHb,GAEGc,EAAgBC,GAAqBC,EAAAA,SAAS,WACtCN,EAAU,IACV,EAGU,iBAAVA,EACAO,OAAOP,GAAOQ,OAGlBR,EAAMQ,SAEVC,EAAiBC,GAAsBJ,EAAAA,UAAS,GACjDK,EAAcC,EAAAA,OAA4B,MAC1CC,EACDtB,GAA0CoB,EAG/CG,EAAAA,UAAU,KACN,MAAMC,EAAkBF,EAAYG,QACpC,GAAID,EAAiB,CACjB,IAAKvB,EAED,YADAuB,EAAgBhB,MAAMkB,OAAS,IAI/BR,GAAmBT,GACnBe,EAAgBhB,MAAMkB,OAAS,OAC/BF,EAAgBhB,MAAMkB,OAAS,GAAGF,EAAgBG,kBAElDH,EAAgBhB,MAAMkB,OAAS,EAEvC,GACD,CAACzB,EAAYqB,EAAab,EAAOS,EAAiBL,IAuBrD,MAAMe,EAAuB1B,GAAS2B,WAAa,EAC7CC,EAA0BF,EAAef,EAO/C,MAKMkB,KAAkBrB,KAJpBR,GAAWW,EAAiBe,EACtB,kBAAkBf,EAAiBe,sBACnC,IAIJI,EAAgB,CAClBC,UAAWhC,EAAa,cAAW,GAGvC,OACIiC,EAAAA,KAAC,MAAA,CACGC,UAAU,wBACV,eAAcJ,EACd,mBAAkBlB,EAAiB,EAEnCuB,SAAA,CAAAC,EAAAA,IAAC,WAAA,CACG,eAAcN,EACdI,UAAW,sDAAsD9B,SACjEF,OA1CZ,SAAsBmC,GAClBnB,GAAmB,GACfhB,GACAA,EAAOmC,EAEf,EAsCYlC,QAlDZ,SAAuBkC,GACnBnB,GAAmB,GACff,GACAA,EAAQkC,EAEhB,EA8CY3B,SArCZ,SAAwB2B,GACpBxB,EAAkBwB,EAAEC,OAAO9B,MAAMQ,QAC7BN,GACAA,EAAS2B,EAEjB,EAiCYtC,IAAKsB,EACLd,MAAO,IAAKA,KAAUwB,GACtB1B,YAAAA,EACAG,MAAAA,KACIG,IAEPV,GACGgC,EAAAA,KAAC,MAAA,CAAIC,UAAU,yBAAyB,cAAY,OAChDC,SAAA,CAAAF,EAAAA,KAAC,MAAA,CAAIC,UAAU,+BACVC,SAAA,CAAAvB,EAAe,MAAce,MAEhC1B,EAAQsC,cACNH,EAAAA,IAAC,MAAA,CACGF,UAAU,kCACV3B,MAAO,CACF,oBA5CAiB,EA6CGK,EA7CcW,EA8Cdb,EA7CxBH,GAAW,GAGE,IAAVgB,EAFI,EAEyB,IAAVhB,EAAiBgB,GAwCa,aA5C5D,IAA6BhB,EAAiBgB,IAyDtD5C,EAAa6C,YAAc"}
1
+ {"version":3,"file":"BaseTextArea.cjs","sources":["../../../../src/components/text-area/BaseTextArea.tsx"],"sourcesContent":["import React, {\n type ChangeEvent,\n type FocusEvent,\n forwardRef,\n type RefObject,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { getCounterValue } from \"./counter.js\";\nimport type { BaseTextAreaProps } from \"./types.js\";\n\nexport const BaseTextArea = forwardRef<HTMLTextAreaElement, BaseTextAreaProps>(\n (props, ref) => {\n const {\n autoExpand,\n counter,\n defaultValue,\n onBlur,\n onFocus,\n rows = 7,\n placeholder = \" \", // This space intentionally left blank. Denne + rows trengs for å få den ekspanderende effekten.\n startOpen,\n style,\n value,\n \"aria-invalid\": ariaInvalid,\n onChange,\n ...rest\n } = props;\n\n const strategy = counter?.strategy ?? \"characters\";\n const isControlled = typeof value !== \"undefined\";\n\n const [uncontrolledValue, setUncontrolledValue] =\n useState(defaultValue);\n const [textAreaFocused, setTextAreaFocused] = useState(false);\n const internalRef = useRef<HTMLTextAreaElement>(null);\n const textAreaRef =\n (ref as RefObject<HTMLTextAreaElement>) || internalRef;\n\n // Hvis feltet styres utenfra bruker vi `value`, ellers holder vi styr på verdien selv.\n const textAreaValue = isControlled ? value : uncontrolledValue;\n const textAreaValueProps = isControlled ? { value } : { defaultValue };\n\n const counterCurrent = getCounterValue(textAreaValue, strategy);\n const counterTotal: number = counter?.maxLength || 0;\n const progressCurrent: number = counterTotal - counterCurrent;\n const isOverLimit = Boolean(counter && counterCurrent > counterTotal);\n const invalid = Boolean(ariaInvalid || isOverLimit);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: counterCurrent trengs for å lytte på tekstendringer i textarea for auto-expand funksjonalitet\n useEffect(() => {\n const textAreaElement = textAreaRef.current;\n if (textAreaElement) {\n if (!autoExpand) {\n textAreaElement.style.height = \"\";\n return;\n }\n\n if (textAreaFocused || textAreaValue) {\n textAreaElement.style.height = \"auto\"; // Sett til auto før scrollhøyden leses, sånn at redusering av høyde ved sletting av tekst fungerer\n textAreaElement.style.height = `${textAreaElement.scrollHeight}px`;\n } else {\n textAreaElement.style.height = \"\";\n }\n }\n }, [\n autoExpand,\n textAreaRef,\n textAreaValue,\n textAreaFocused,\n counterCurrent,\n ]);\n\n function handleOnFocus(e: FocusEvent<HTMLTextAreaElement>) {\n setTextAreaFocused(true);\n if (onFocus) {\n onFocus(e);\n }\n }\n\n function handleOnBlur(e: FocusEvent<HTMLTextAreaElement>) {\n setTextAreaFocused(false);\n if (onBlur) {\n onBlur(e);\n }\n }\n\n function handleOnChange(e: ChangeEvent<HTMLTextAreaElement>) {\n if (!isControlled) {\n setUncontrolledValue(e.target.value);\n }\n\n if (onChange) {\n onChange(e);\n }\n }\n function calculatePercentage(current: number, total: number): number {\n if (current <= 0) {\n return 0;\n }\n return total === 0 ? 0 : (current * 100) / total;\n }\n\n const overflowStyle = {\n overflowX: autoExpand ? \"hidden\" : undefined, // Must set overflowX hidden for Firefox https://stackoverflow.com/a/22700700\n } as React.CSSProperties;\n\n return (\n <div\n className=\"jkl-text-area-wrapper\"\n data-invalid={invalid}\n data-has-content={counterCurrent > 0}\n >\n <textarea\n aria-invalid={invalid}\n className={`jkl-text-area__text-area jkl-text-area__text-area--${rows}-rows`}\n onBlur={handleOnBlur}\n onFocus={handleOnFocus}\n onChange={handleOnChange}\n ref={textAreaRef}\n style={{ ...style, ...overflowStyle }}\n placeholder={placeholder}\n {...textAreaValueProps}\n {...rest}\n />\n {counter && (\n <div className=\"jkl-text-area__counter\" aria-hidden=\"true\">\n <div className=\"jkl-text-area__counter-count\">\n {counterCurrent}&nbsp;/&nbsp;{counterTotal}\n </div>\n {!counter.hideProgress && (\n <div\n className=\"jkl-text-area__counter-progress\"\n style={{\n [\"--progress-width\" as string]: `${calculatePercentage(\n progressCurrent,\n counterTotal,\n )}%`,\n }}\n />\n )}\n </div>\n )}\n </div>\n );\n },\n);\nBaseTextArea.displayName = \"BaseTextArea\";\n"],"names":["BaseTextArea","forwardRef","props","ref","autoExpand","counter","defaultValue","onBlur","onFocus","rows","placeholder","startOpen","style","value","ariaInvalid","onChange","rest","strategy","isControlled","uncontrolledValue","setUncontrolledValue","useState","textAreaFocused","setTextAreaFocused","internalRef","useRef","textAreaRef","textAreaValue","textAreaValueProps","counterCurrent","getCounterValue","counterTotal","maxLength","progressCurrent","invalid","useEffect","textAreaElement","current","height","scrollHeight","overflowStyle","overflowX","jsxs","className","children","jsx","e","target","hideProgress","total","displayName"],"mappings":"mKAYaA,EAAeC,EAAAA,WACxB,CAACC,EAAOC,KACJ,MACIC,WAAAA,EACAC,QAAAA,EACAC,aAAAA,EACAC,OAAAA,EACAC,QAAAA,EACAC,KAAAA,EAAO,EACPC,YAAAA,EAAc,IACdC,UAAAA,EACAC,MAAAA,EACAC,MAAAA,EACA,eAAgBC,EAChBC,SAAAA,KACGC,GACHd,EAEEe,EAAWZ,GAASY,UAAY,aAChCC,SAAsBL,EAAU,KAE/BM,EAAmBC,GACtBC,EAAAA,SAASf,IACNgB,EAAiBC,GAAsBF,EAAAA,UAAS,GACjDG,EAAcC,EAAAA,OAA4B,MAC1CC,EACDvB,GAA0CqB,EAGzCG,EAAgBT,EAAeL,EAAQM,EACvCS,EAAqBV,EAAe,CAAEL,MAAAA,GAAU,CAAEP,aAAAA,GAElDuB,EAAiBC,EAAAA,gBAAgBH,EAAeV,GAChDc,EAAuB1B,GAAS2B,WAAa,EAC7CC,EAA0BF,EAAeF,EAEzCK,KAAkBpB,OADIT,GAAWwB,EAAiBE,IAIxDI,EAAAA,UAAU,KACN,MAAMC,EAAkBV,EAAYW,QACpC,GAAID,EAAiB,CACjB,IAAKhC,EAED,YADAgC,EAAgBxB,MAAM0B,OAAS,IAI/BhB,GAAmBK,GACnBS,EAAgBxB,MAAM0B,OAAS,OAC/BF,EAAgBxB,MAAM0B,OAAS,GAAGF,EAAgBG,kBAElDH,EAAgBxB,MAAM0B,OAAS,EAEvC,GACD,CACClC,EACAsB,EACAC,EACAL,EACAO,IAiCJ,MAAMW,EAAgB,CAClBC,UAAWrC,EAAa,cAAW,GAGvC,OACIsC,EAAAA,KAAC,MAAA,CACGC,UAAU,wBACV,eAAcT,EACd,mBAAkBL,EAAiB,EAEnCe,SAAA,CAAAC,EAAAA,IAAC,WAAA,CACG,eAAcX,EACdS,UAAW,sDAAsDlC,SACjEF,OApCZ,SAAsBuC,GAClBvB,GAAmB,GACfhB,GACAA,EAAOuC,EAEf,EAgCYtC,QA5CZ,SAAuBsC,GACnBvB,GAAmB,GACff,GACAA,EAAQsC,EAEhB,EAwCY/B,SA/BZ,SAAwB+B,GACf5B,GACDE,EAAqB0B,EAAEC,OAAOlC,OAG9BE,GACAA,EAAS+B,EAEjB,EAwBY3C,IAAKuB,EACLd,MAAO,IAAKA,KAAU4B,GACtB9B,YAAAA,KACIkB,KACAZ,IAEPX,GACGqC,EAAAA,KAAC,MAAA,CAAIC,UAAU,yBAAyB,cAAY,OAChDC,SAAA,CAAAF,EAAAA,KAAC,MAAA,CAAIC,UAAU,+BACVC,SAAA,CAAAf,EAAe,MAAcE,MAEhC1B,EAAQ2C,cACNH,EAAAA,IAAC,MAAA,CACGF,UAAU,kCACV/B,MAAO,CACF,oBAtCAyB,EAuCGJ,EAvCcgB,EAwCdlB,EAvCxBM,GAAW,GAGE,IAAVY,EAFI,EAEyB,IAAVZ,EAAiBY,GAkCa,aAtC5D,IAA6BZ,EAAiBY,IAmDtDjD,EAAakD,YAAc"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=new TextEncoder;exports.getCounterValue=function(t,r="characters"){if(typeof t>"u")return 0;const n="string"==typeof t?t:Array.isArray(t)?t.join(""):String(t);return"bytes"===r?e.encode(n).length:n.length};
2
+ //# sourceMappingURL=counter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"counter.cjs","sources":["../../../../src/components/text-area/counter.ts"],"sourcesContent":["import type { CounterStrategy } from \"./types.js\";\n\nconst textEncoder = new TextEncoder();\n\nexport function getCounterValue(\n value: string | number | readonly string[] | undefined,\n strategy: CounterStrategy = \"characters\",\n): number {\n if (typeof value === \"undefined\") {\n return 0;\n }\n\n const normalizedValue =\n typeof value === \"string\"\n ? value\n : Array.isArray(value)\n ? value.join(\"\")\n : String(value);\n\n if (strategy === \"bytes\") {\n return textEncoder.encode(normalizedValue).length;\n }\n\n return normalizedValue.length;\n}\n"],"names":["textEncoder","TextEncoder","value","strategy","normalizedValue","Array","isArray","join","String","encode","length"],"mappings":"gFAEA,MAAMA,EAAc,IAAIC,oCAEjB,SACHC,EACAC,EAA4B,cAE5B,UAAWD,EAAU,IACjB,OAAO,EAGX,MAAME,EACe,iBAAVF,EACDA,EACAG,MAAMC,QAAQJ,GACZA,EAAMK,KAAK,IACXC,OAAON,GAEnB,MAAiB,UAAbC,EACOH,EAAYS,OAAOL,GAAiBM,OAGxCN,EAAgBM,MAC3B"}
@@ -0,0 +1,2 @@
1
+ import { CounterStrategy } from './types.cjs';
2
+ export declare function getCounterValue(value: string | number | readonly string[] | undefined, strategy?: CounterStrategy): number;
@@ -1,8 +1,28 @@
1
1
  import { TextareaHTMLAttributes } from 'react';
2
2
  import { InputGroupProps } from '../input-group/types.cjs';
3
+ export type CounterStrategy = "characters" | "bytes";
3
4
  export type Counter = {
4
- /** Antall tegn før telleren når maksimum og vi viser en feilmelding */
5
+ /**
6
+ * Maksverdi for telleren.
7
+ *
8
+ * Enheten avhenger av `strategy`:
9
+ * - `"characters"`: antall tegn
10
+ * - `"bytes"`: antall UTF-8-bytes
11
+ */
5
12
  maxLength: number;
13
+ /**
14
+ * Bestemmer hva telleren måler.
15
+ *
16
+ * - "characters" teller tekst på samme måte som i dag og er standard
17
+ * - "bytes" teller antall UTF-8-bytes, for usecaser der backend eller API
18
+ * håndhever en bytegrense
19
+ *
20
+ * Unngå å kombinere `strategy="bytes"` med native `maxLength` på
21
+ * `<textarea>`, siden nettleseren fortsatt håndhever `maxLength` som tegn.
22
+ *
23
+ * @default "characters"
24
+ */
25
+ strategy?: CounterStrategy;
6
26
  /**
7
27
  * Med teller vises en progress-bar i bunnen av tekstfeltet som krymper
8
28
  * ned fra 100% (null tegn skrevet) til 0% (maks antall tegn skrevet).
@@ -1,7 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  import { PolymorphicPropsWithRef } from '../../utilities/polymorphism/polymorphism.js';
3
3
  import { IconVariant } from './types.js';
4
- type IconComponentProps<ElementType extends Extract<React.ElementType, "span" | "div">> = PolymorphicPropsWithRef<ElementType, {
4
+ type IconComponentProps<ElementType extends "span" | "div"> = PolymorphicPropsWithRef<ElementType, {
5
5
  "data-testid"?: string;
6
6
  /**
7
7
  * Størrelsesvarianten til ikonet. `"small"` er 16px med 20px bounding box, og `"medium"` er 20px med 24px bounding box.
@@ -17,7 +17,7 @@ type IconComponentProps<ElementType extends Extract<React.ElementType, "span" |
17
17
  className?: string;
18
18
  style?: React.CSSProperties;
19
19
  }>;
20
- export type IconComponent = (<ElementType extends Extract<React.ElementType, "span" | "div"> = "span">(props: IconComponentProps<ElementType>) => React.ReactElement | null) & {
20
+ export type IconComponent = (<ElementType extends "span" | "div" = "span">(props: IconComponentProps<ElementType>) => React.ReactElement | null) & {
21
21
  displayName?: string;
22
22
  };
23
23
  export declare const Icon: IconComponent;
@@ -1,2 +1,2 @@
1
- import{jsx as r}from"react/jsx-runtime";import{c as o}from"../../../clsx-BeLtu-UY.js";import a from"react";const c=a.forwardRef(function(a,c){const{bold:i,children:n,className:e,filled:l,variant:s,...t}=a;return r("span",{"aria-hidden":!0,ref:c,className:o("jkl-icon",e,{"jkl-icon--filled":l,"jkl-icon--bold":i}),...t,children:n})});export{c as Icon};
1
+ import{jsx as r}from"react/jsx-runtime";import{c as a}from"../../../clsx-BeLtu-UY.js";import i from"react";const o=i.forwardRef(function(i,o){const{as:n="span",bold:s,children:c,className:e,filled:l,variant:t,...d}=i,f=a("jkl-icon",e,{"jkl-icon--filled":l,"jkl-icon--bold":s});return r("div"===n?"div":"span",{"aria-hidden":!0,ref:o,className:f,...d,children:c})});export{o as Icon};
2
2
  //# sourceMappingURL=Icon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","sources":["../../../../src/components/icon/Icon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport type {\n PolymorphicPropsWithRef,\n PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport type { IconVariant } from \"./types.js\";\n\ntype IconComponentProps<\n ElementType extends Extract<React.ElementType, \"span\" | \"div\">,\n> = PolymorphicPropsWithRef<\n ElementType,\n {\n \"data-testid\"?: string;\n /**\n * Størrelsesvarianten til ikonet. `\"small\"` er 16px med 20px bounding box, og `\"medium\"` er 20px med 24px bounding box.\n * `\"inherit\"` setter størrelsen til ikonet (ikke bounding box) lik skriftstørrelsen (1em).\n */\n variant?: IconVariant;\n /**\n * Angir om ikonet skal vises i fet versjon\n * @default false\n */\n bold?: boolean;\n filled?: boolean;\n className?: string;\n style?: React.CSSProperties;\n }\n>;\n\nexport type IconComponent = (<\n ElementType extends Extract<React.ElementType, \"span\" | \"div\"> = \"span\",\n>(\n props: IconComponentProps<ElementType>,\n) => React.ReactElement | null) & { displayName?: string };\n\nexport const Icon: IconComponent = React.forwardRef(function Icon<\n ElementType extends Extract<React.ElementType, \"span\" | \"div\"> = \"span\",\n>(props: IconComponentProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const { bold, children, className, filled, variant, ...iconProps } = props;\n\n return (\n <span\n aria-hidden\n ref={ref}\n className={clsx(\"jkl-icon\", className, {\n \"jkl-icon--filled\": filled,\n \"jkl-icon--bold\": bold,\n })}\n {...iconProps}\n >\n {children}\n </span>\n );\n}) as IconComponent;\n"],"names":["Icon","React","forwardRef","props","ref","bold","children","className","filled","variant","iconProps","jsx","clsx"],"mappings":"2GAoCO,MAAMA,EAAsBC,EAAMC,WAAW,SAElDC,EAAwCC,GACtC,MAAQC,KAAAA,EAAMC,SAAAA,EAAUC,UAAAA,EAAWC,OAAAA,EAAQC,QAAAA,KAAYC,GAAcP,EAErE,OACIQ,EAAC,OAAA,CACG,eAAW,EACXP,IAAAA,EACAG,UAAWK,EAAK,WAAYL,EAAW,CACnC,mBAAoBC,EACpB,iBAAkBH,OAElBK,EAEHJ,SAAAA,GAGb"}
1
+ {"version":3,"file":"Icon.js","sources":["../../../../src/components/icon/Icon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport type {\n PolymorphicPropsWithRef,\n PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport type { IconVariant } from \"./types.js\";\n\ntype IconComponentProps<\n ElementType extends \"span\" | \"div\",\n> = PolymorphicPropsWithRef<\n ElementType,\n {\n \"data-testid\"?: string;\n /**\n * Størrelsesvarianten til ikonet. `\"small\"` er 16px med 20px bounding box, og `\"medium\"` er 20px med 24px bounding box.\n * `\"inherit\"` setter størrelsen til ikonet (ikke bounding box) lik skriftstørrelsen (1em).\n */\n variant?: IconVariant;\n /**\n * Angir om ikonet skal vises i fet versjon\n * @default false\n */\n bold?: boolean;\n filled?: boolean;\n className?: string;\n style?: React.CSSProperties;\n }\n>;\n\nexport type IconComponent = (<\n ElementType extends \"span\" | \"div\" = \"span\",\n>(\n props: IconComponentProps<ElementType>,\n) => React.ReactElement | null) & { displayName?: string };\n\nexport const Icon: IconComponent = React.forwardRef(function Icon<\n ElementType extends \"span\" | \"div\" = \"span\",\n>(props: IconComponentProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n as = \"span\",\n bold,\n children,\n className,\n filled,\n variant,\n ...iconProps\n } = props;\n const iconClassName = clsx(\"jkl-icon\", className, {\n \"jkl-icon--filled\": filled,\n \"jkl-icon--bold\": bold,\n });\n\n if (as === \"div\") {\n return (\n <div\n aria-hidden\n ref={ref as PolymorphicRef<\"div\">}\n className={iconClassName}\n {...(iconProps as React.HTMLAttributes<HTMLDivElement>)}\n >\n {children}\n </div>\n );\n }\n\n return (\n <span\n aria-hidden\n ref={ref as PolymorphicRef<\"span\">}\n className={iconClassName}\n {...(iconProps as React.HTMLAttributes<HTMLSpanElement>)}\n >\n {children}\n </span>\n );\n}) as IconComponent;\n"],"names":["Icon","React","forwardRef","props","ref","as","bold","children","className","filled","variant","iconProps","iconClassName","clsx","jsx"],"mappings":"2GAoCO,MAAMA,EAAsBC,EAAMC,WAAW,SAElDC,EAAwCC,GACtC,MACIC,GAAAA,EAAK,OACLC,KAAAA,EACAC,SAAAA,EACAC,UAAAA,EACAC,OAAAA,EACAC,QAAAA,KACGC,GACHR,EACES,EAAgBC,EAAK,WAAYL,EAAW,CAC9C,mBAAoBC,EACpB,iBAAkBH,IAGtB,OAEQQ,EAFG,QAAPT,EAEK,MAYJ,OAZI,CACG,eAAW,EACXD,IAAAA,EACAI,UAAWI,KACND,EAEJJ,SAAAA,GAejB"}
@@ -1,3 +1,2 @@
1
- import { FC } from 'react';
2
- import { IconProps } from '../types.js';
3
- export declare const GreenCheckIcon: FC<IconProps>;
1
+ import { IconComponent } from '../Icon.js';
2
+ export declare const GreenCheckIcon: IconComponent;
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as i}from"react/jsx-runtime";import{c}from"../../../../clsx-BeLtu-UY.js";import"react";const s=({as:s="div",bold:t=!1,className:a,variant:l="inherit","data-testid":r,style:n,...o})=>e(s,{className:c(a,"jkl-icon","jkl-icon-green-check",`jkl-icon--${l}`,{"jkl-icon--bold":t}),"aria-hidden":"true",style:n,"data-testid":r,...o,children:i("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24px",height:"24px",children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("path",{fillRule:"evenodd",d:"M17.52 9.54 10.7 16.2l-4.21-4.1 1.04-1.08 3.17 3.09 5.79-5.65 1.04 1.08Z",clipRule:"evenodd"})]})});s.displayName="GreenCheckIcon";export{s as GreenCheckIcon};
1
+ import{jsx as c}from"react/jsx-runtime";import{c as e}from"../../../../clsx-BeLtu-UY.js";import"react";import{Icon as r}from"../Icon.js";const s=s=>c(r,{...s,className:e("jkl-icon-green-check",s.className),children:""});s.displayName="GreenCheckIcon";export{s as GreenCheckIcon};
2
2
  //# sourceMappingURL=GreenCheckIcon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GreenCheckIcon.js","sources":["../../../../../src/components/icon/icons/GreenCheckIcon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type FC } from \"react\";\nimport type { IconProps } from \"../types.js\";\n\n/*\n * NOTE: The green-check and red-cross icons also exists as a copy in the jkl-list package.\n * If you're here to change them, consider changing them there as well, or\n * finding a technical solution to sharing the SVG markup\n */\nexport const GreenCheckIcon: FC<IconProps> = ({\n as = \"div\",\n bold = false,\n className,\n variant = \"inherit\",\n \"data-testid\": testId,\n style,\n ...rest\n}) => {\n const El = as;\n\n return (\n <El\n className={clsx(\n className,\n \"jkl-icon\",\n \"jkl-icon-green-check\",\n `jkl-icon--${variant}`,\n {\n \"jkl-icon--bold\": bold,\n },\n )}\n aria-hidden=\"true\"\n style={style}\n data-testid={testId}\n {...rest}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n width=\"24px\"\n height=\"24px\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path\n fillRule=\"evenodd\"\n d=\"M17.52 9.54 10.7 16.2l-4.21-4.1 1.04-1.08 3.17 3.09 5.79-5.65 1.04 1.08Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </El>\n );\n};\nGreenCheckIcon.displayName = \"GreenCheckIcon\";\n"],"names":["GreenCheckIcon","as","bold","className","variant","testId","style","rest","jsx","clsx","children","jsxs","xmlns","viewBox","width","height","cx","cy","r","fillRule","d","clipRule","displayName"],"mappings":"4GASO,MAAMA,EAAgC,EACzCC,GAAAA,EAAK,MACLC,KAAAA,GAAO,EACPC,UAAAA,EACAC,QAAAA,EAAU,UACV,cAAeC,EACfC,MAAAA,KACGC,KAKCC,EAHOP,EAGN,CACGE,UAAWM,EACPN,EACA,WACA,uBACA,aAAaC,IACb,CACI,iBAAkBF,IAG1B,cAAY,OACZI,MAAAA,EACA,cAAaD,KACTE,EAEJG,SAAAC,EAAC,MAAA,CACGC,MAAM,6BACNC,QAAQ,YACRC,MAAM,OACNC,OAAO,OAEPL,SAAA,CAAAF,EAAC,UAAOQ,GAAG,KAAKC,GAAG,KAAKC,EAAE,OAC1BV,EAAC,OAAA,CACGW,SAAS,UACTC,EAAE,2EACFC,SAAS,iBAM7BrB,EAAesB,YAAc"}
1
+ {"version":3,"file":"GreenCheckIcon.js","sources":["../../../../../src/components/icon/icons/GreenCheckIcon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport { Icon, type IconComponent } from \"../Icon.js\";\nimport type { IconProps } from \"../types.js\";\n\nexport const GreenCheckIcon: IconComponent = (props: IconProps) => (\n <Icon {...props} className={clsx(\"jkl-icon-green-check\", props.className)}>\n {\"\\ue5ca\"}\n </Icon>\n);\nGreenCheckIcon.displayName = \"GreenCheckIcon\";\n"],"names":["GreenCheckIcon","props","jsx","Icon","className","clsx","children","displayName"],"mappings":"yIAKO,MAAMA,EAAiCC,GAC1CC,EAACC,EAAA,IAASF,EAAOG,UAAWC,EAAK,uBAAwBJ,EAAMG,WAC1DE,SAAA,MAGTN,EAAeO,YAAc"}
@@ -1,3 +1,2 @@
1
- import { FC } from 'react';
2
- import { IconProps } from '../types.js';
3
- export declare const RedCrossIcon: FC<IconProps>;
1
+ import { IconComponent } from '../Icon.js';
2
+ export declare const RedCrossIcon: IconComponent;
@@ -1,2 +1,2 @@
1
- import{jsx as s,jsxs as t}from"react/jsx-runtime";import{c as a}from"../../../../clsx-BeLtu-UY.js";import"react";const i=({as:i="div",bold:e=!1,className:r,variant:c="inherit","data-testid":o,style:d,...l})=>s(i,{className:a(r,"jkl-icon","jkl-icon-red-cross",`jkl-icon--${c}`,{"jkl-icon--bold":e}),"aria-hidden":"true",style:d,"data-testid":o,...l,children:t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24px",height:"24px",children:[s("circle",{cx:"12",cy:"12",r:"10"}),s("path",{d:"m15.71 7.23 1.06 1.06-8.48 8.48-1.06-1.06 8.48-8.48Z"}),s("path",{d:"m8.29 7.23 8.48 8.48-1.06 1.06L7.23 8.3l1.06-1.06Z"})]})});i.displayName="RedCrossIcon";export{i as RedCrossIcon};
1
+ import{jsx as s}from"react/jsx-runtime";import{c as o}from"../../../../clsx-BeLtu-UY.js";import"react";import{Icon as r}from"../Icon.js";const c=c=>s(r,{...c,className:o("jkl-icon-red-cross",c.className),children:""});c.displayName="RedCrossIcon";export{c as RedCrossIcon};
2
2
  //# sourceMappingURL=RedCrossIcon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RedCrossIcon.js","sources":["../../../../../src/components/icon/icons/RedCrossIcon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { type FC } from \"react\";\nimport type { IconProps } from \"../types.js\";\n\n/*\n * NOTE: The green-check and red-cross icons also exists as a copy in the jkl-list package.\n * If you're here to change them, consider changing them there as well, or\n * finding a technical solution to sharing the SVG markup\n */\nexport const RedCrossIcon: FC<IconProps> = ({\n as = \"div\",\n bold = false,\n className,\n variant = \"inherit\",\n \"data-testid\": testId,\n style,\n ...rest\n}) => {\n const El = as;\n\n return (\n <El\n className={clsx(\n className,\n \"jkl-icon\",\n \"jkl-icon-red-cross\",\n `jkl-icon--${variant}`,\n {\n \"jkl-icon--bold\": bold,\n },\n )}\n aria-hidden=\"true\"\n style={style}\n data-testid={testId}\n {...rest}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n width=\"24px\"\n height=\"24px\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"m15.71 7.23 1.06 1.06-8.48 8.48-1.06-1.06 8.48-8.48Z\" />\n <path d=\"m8.29 7.23 8.48 8.48-1.06 1.06L7.23 8.3l1.06-1.06Z\" />\n </svg>\n </El>\n );\n};\nRedCrossIcon.displayName = \"RedCrossIcon\";\n"],"names":["RedCrossIcon","as","bold","className","variant","testId","style","rest","jsx","clsx","children","jsxs","xmlns","viewBox","width","height","cx","cy","r","d","displayName"],"mappings":"iHASO,MAAMA,EAA8B,EACvCC,GAAAA,EAAK,MACLC,KAAAA,GAAO,EACPC,UAAAA,EACAC,QAAAA,EAAU,UACV,cAAeC,EACfC,MAAAA,KACGC,KAKCC,EAHOP,EAGN,CACGE,UAAWM,EACPN,EACA,WACA,qBACA,aAAaC,IACb,CACI,iBAAkBF,IAG1B,cAAY,OACZI,MAAAA,EACA,cAAaD,KACTE,EAEJG,SAAAC,EAAC,MAAA,CACGC,MAAM,6BACNC,QAAQ,YACRC,MAAM,OACNC,OAAO,OAEPL,SAAA,CAAAF,EAAC,UAAOQ,GAAG,KAAKC,GAAG,KAAKC,EAAE,OAC1BV,EAAC,OAAA,CAAKW,EAAE,yDACRX,EAAC,OAAA,CAAKW,EAAE,4DAKxBnB,EAAaoB,YAAc"}
1
+ {"version":3,"file":"RedCrossIcon.js","sources":["../../../../../src/components/icon/icons/RedCrossIcon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport { Icon, type IconComponent } from \"../Icon.js\";\nimport type { IconProps } from \"../types.js\";\n\nexport const RedCrossIcon: IconComponent = (props: IconProps) => (\n <Icon {...props} className={clsx(\"jkl-icon-red-cross\", props.className)}>\n {\"\\ue5cd\"}\n </Icon>\n);\nRedCrossIcon.displayName = \"RedCrossIcon\";\n"],"names":["RedCrossIcon","props","jsx","Icon","className","clsx","children","displayName"],"mappings":"yIAKO,MAAMA,EAA+BC,GACxCC,EAACC,EAAA,IAASF,EAAOG,UAAWC,EAAK,qBAAsBJ,EAAMG,WACxDE,SAAA,MAGTN,EAAaO,YAAc"}
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ export declare const NumberInput: React.ForwardRefExoticComponent<Omit<import('../input-group/types.js').InputGroupProps, "children" | "inline" | "render"> & Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "children"> & {
3
+ align?: "left" | "right";
4
+ width?: string;
5
+ inputClassName?: string;
6
+ stepper?: boolean;
7
+ } & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,2 @@
1
+ import{jsx as n,jsxs as o}from"react/jsx-runtime";import{c as i}from"../../../clsx-BeLtu-UY.js";import{forwardRef as e,useRef as r,useState as t}from"react";import{mergeRefs as s}from"../../utilities/mergeRefs.js";import"../icon/Icon.js";import"../icon/icons/animated/ArrowVerticalAnimated.js";import"../icon/icons/animated/ArrowHorizontalAnimated.js";import"../icon/icons/animated/PlusRemoveAnimated.js";import"../icon/icons/ArrowDownIcon.js";import"../icon/icons/ArrowLeftIcon.js";import"../icon/icons/ArrowNorthEastIcon.js";import"../icon/icons/ArrowRightIcon.js";import"../icon/icons/ArrowUpIcon.js";import"../icon/icons/CalendarIcon.js";import"../icon/icons/CheckIcon.js";import"../icon/icons/ChevronDownIcon.js";import"../icon/icons/ChevronLeftIcon.js";import"../icon/icons/ChevronRightIcon.js";import"../icon/icons/ChevronUpIcon.js";import"../icon/icons/CloseIcon.js";import"../icon/icons/CopyIcon.js";import"../icon/icons/DotsIcon.js";import"../icon/icons/DragIcon.js";import"../icon/icons/ErrorIcon.js";import"../icon/icons/GreenCheckIcon.js";import"../icon/icons/HamburgerIcon.js";import"../icon/icons/InfoIcon.js";import"../icon/icons/LinkIcon.js";import{MinusIcon as c}from"../icon/icons/MinusIcon.js";import"../icon/icons/OpenInNewIcon.js";import"../icon/icons/PenIcon.js";import{PlusIcon as a}from"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import"../icon/icons/SuccessIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import"../icon/icons/TrashCanIcon.js";import"../icon/icons/WarningIcon.js";import{InputGroup as p}from"../input-group/InputGroup.js";const m={decrement:{label:"Senk verdien",Icon:c},increment:{label:"Øk verdien",Icon:a}};function l({direction:o,disabled:i,onClick:e}){const{label:r,Icon:t}=m[o];return n("button",{type:"button",className:"jkl-button jkl-button--ghost","aria-label":r,"data-direction":o,onPointerDown:n=>n.preventDefault(),onClick:e,disabled:i,children:n("span",{"aria-hidden":"true",children:n(t,{})})})}const u=e((e,c)=>{const{"data-size":a,"data-testautoid":m,"data-testid":u,align:d="left",id:b,label:j,className:I,style:h,errorLabel:N,helpLabel:f,inputClassName:v,labelProps:w,supportLabelProps:k,stepper:C=!1,tooltip:g,description:y,width:A,onChange:_,...L}=e,P=r(null),D=s(P,c),[R,x]=t(L.defaultValue),E=void 0!==L.value?L.value:R,F=n=>{void 0===L.value&&x(n.target.value),_?.(n)},S=function(n){return"number"==typeof n?n:"string"==typeof n&&""!==n.trim()?Number(n):Number.NaN}(E),U=void 0!==L.min?Number(L.min):Number.NaN,z=void 0!==L.max?Number(L.max):Number.NaN,G=Number.isFinite(S)&&Number.isFinite(U)&&S<=U,O=Number.isFinite(S)&&Number.isFinite(z)&&S>=z,T=h||A?{...h,...A?{width:A}:void 0}:void 0,H={id:b,label:j,errorLabel:N,helpLabel:f,labelProps:w,supportLabelProps:k,tooltip:g,description:y},M=n=>{const o=P.current;if(!o||o.disabled||o.readOnly)return;const i=o.value;o.focus();try{"increment"===n?o.stepUp():o.stepDown()}catch{return}o.value!==i&&o.dispatchEvent(new Event("input",{bubbles:!0}))},V=L.disabled||L.readOnly;return n(p,{...H,className:i(I,"jkl-number-input"),"data-size":a,"data-testid":u??"jkl-number-input",render:e=>o("div",{className:i("jkl-number-input__wrapper",{"jkl-number-input__wrapper--stepper":C}),"data-invalid":e["aria-invalid"],style:T,children:[C&&n(l,{direction:"decrement",disabled:V||G,onClick:()=>M("decrement")}),n("input",{...e,...L,ref:D,type:"number",onChange:F,className:i("jkl-number-input__input",{"jkl-number-input__input--stepper":C,"jkl-number-input__input--align-right":!C&&"right"===d},v),"data-testautoid":m}),C&&n(l,{direction:"increment",disabled:V||O,onClick:()=>M("increment")})]})})});u.displayName="NumberInput";export{u as NumberInput};
2
+ //# sourceMappingURL=NumberInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberInput.js","sources":["../../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n type ComponentType,\n forwardRef,\n useRef,\n useState,\n} from \"react\";\nimport { mergeRefs } from \"../../utilities/mergeRefs.js\";\nimport { MinusIcon, PlusIcon } from \"../icon/index.js\";\nimport { InputGroup } from \"../input-group/InputGroup.js\";\nimport type { NumberInputProps } from \"./types.js\";\n\ntype NumberInputValue = string | number | readonly string[] | undefined;\n\ntype StepDirection = \"increment\" | \"decrement\";\n\nconst stepperConfig: Record<\n StepDirection,\n { label: string; Icon: ComponentType }\n> = {\n decrement: { label: \"Senk verdien\", Icon: MinusIcon },\n increment: { label: \"Øk verdien\", Icon: PlusIcon },\n};\n\nfunction toNumeric(value: NumberInputValue): number {\n if (typeof value === \"number\") {\n return value;\n }\n if (typeof value === \"string\" && value.trim() !== \"\") {\n return Number(value);\n }\n return Number.NaN;\n}\n\ntype StepperButtonProps = {\n direction: StepDirection;\n disabled: boolean;\n onClick: () => void;\n};\n\nfunction StepperButton({ direction, disabled, onClick }: StepperButtonProps) {\n const { label, Icon } = stepperConfig[direction];\n\n return (\n <button\n type=\"button\"\n className=\"jkl-button jkl-button--ghost\"\n aria-label={label}\n data-direction={direction}\n onPointerDown={(event) => event.preventDefault()}\n onClick={onClick}\n disabled={disabled}\n >\n <span aria-hidden=\"true\">\n <Icon />\n </span>\n </button>\n );\n}\n\nexport const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(\n (props, ref) => {\n const {\n \"data-size\": dataSize,\n \"data-testautoid\": testAutoId,\n \"data-testid\": dataTestId,\n align = \"left\",\n id,\n label,\n className,\n style,\n errorLabel,\n helpLabel,\n inputClassName,\n labelProps,\n supportLabelProps,\n stepper = false,\n tooltip,\n description,\n width,\n onChange,\n ...rest\n } = props;\n const internalRef = useRef<HTMLInputElement>(null);\n const mergedRef = mergeRefs(internalRef, ref);\n const [uncontrolledValue, setUncontrolledValue] =\n useState<NumberInputValue>(rest.defaultValue);\n\n // I kontrollert bruk må vi lese direkte fra `value` for at disabled-\n // state på stepper-knappene skal følge prop-en i samme render. Bruker\n // intern state som fallback for ukontrollert bruk.\n const effectiveValue =\n rest.value !== undefined ? rest.value : uncontrolledValue;\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (rest.value === undefined) {\n setUncontrolledValue(event.target.value);\n }\n onChange?.(event);\n };\n\n const numericValue = toNumeric(effectiveValue);\n const minNumeric =\n rest.min !== undefined ? Number(rest.min) : Number.NaN;\n const maxNumeric =\n rest.max !== undefined ? Number(rest.max) : Number.NaN;\n const isAtOrBelowMin =\n Number.isFinite(numericValue) &&\n Number.isFinite(minNumeric) &&\n numericValue <= minNumeric;\n const isAtOrAboveMax =\n Number.isFinite(numericValue) &&\n Number.isFinite(maxNumeric) &&\n numericValue >= maxNumeric;\n\n const inputWrapperStyle =\n style || width\n ? {\n ...style,\n ...(width ? { width } : undefined),\n }\n : undefined;\n const inputGroupProps = {\n id,\n label,\n errorLabel,\n helpLabel,\n labelProps,\n supportLabelProps,\n tooltip,\n description,\n };\n\n const triggerStep = (direction: StepDirection) => {\n const input = internalRef.current;\n\n if (!input || input.disabled || input.readOnly) {\n return;\n }\n\n const previousValue = input.value;\n input.focus();\n\n try {\n if (direction === \"increment\") {\n input.stepUp();\n } else {\n input.stepDown();\n }\n } catch {\n return;\n }\n\n if (input.value === previousValue) {\n return;\n }\n\n input.dispatchEvent(new Event(\"input\", { bubbles: true }));\n };\n\n const stepperDisabled = rest.disabled || rest.readOnly;\n\n return (\n <InputGroup\n {...inputGroupProps}\n className={clsx(className, \"jkl-number-input\")}\n data-size={dataSize}\n data-testid={dataTestId ?? \"jkl-number-input\"}\n render={(inputProps) => (\n <div\n className={clsx(\"jkl-number-input__wrapper\", {\n \"jkl-number-input__wrapper--stepper\": stepper,\n })}\n data-invalid={inputProps[\"aria-invalid\"]}\n style={inputWrapperStyle}\n >\n {stepper && (\n <StepperButton\n direction=\"decrement\"\n disabled={stepperDisabled || isAtOrBelowMin}\n onClick={() => triggerStep(\"decrement\")}\n />\n )}\n <input\n {...inputProps}\n {...rest}\n ref={mergedRef}\n type=\"number\"\n onChange={handleChange}\n className={clsx(\n \"jkl-number-input__input\",\n {\n \"jkl-number-input__input--stepper\": stepper,\n \"jkl-number-input__input--align-right\":\n !stepper && align === \"right\",\n },\n inputClassName,\n )}\n data-testautoid={testAutoId}\n />\n {stepper && (\n <StepperButton\n direction=\"increment\"\n disabled={stepperDisabled || isAtOrAboveMax}\n onClick={() => triggerStep(\"increment\")}\n />\n )}\n </div>\n )}\n />\n );\n },\n);\n\nNumberInput.displayName = \"NumberInput\";\n"],"names":["stepperConfig","decrement","label","Icon","MinusIcon","increment","PlusIcon","StepperButton","direction","disabled","onClick","jsx","type","className","onPointerDown","event","preventDefault","children","NumberInput","forwardRef","props","ref","dataSize","testAutoId","dataTestId","align","id","style","errorLabel","helpLabel","inputClassName","labelProps","supportLabelProps","stepper","tooltip","description","width","onChange","rest","internalRef","useRef","mergedRef","mergeRefs","uncontrolledValue","setUncontrolledValue","useState","defaultValue","effectiveValue","value","handleChange","target","numericValue","trim","Number","NaN","toNumeric","minNumeric","min","maxNumeric","max","isAtOrBelowMin","isFinite","isAtOrAboveMax","inputWrapperStyle","inputGroupProps","triggerStep","input","current","readOnly","previousValue","focus","stepUp","stepDown","dispatchEvent","Event","bubbles","stepperDisabled","InputGroup","clsx","render","inputProps","jsxs","displayName"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export { NumberInput } from './NumberInput.js';
2
+ export type { NumberInputProps } from './types.js';
@@ -0,0 +1,2 @@
1
+ import{NumberInput as r}from"./NumberInput.js";export{r as NumberInput};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+ import { InputGroupProps } from '../input-group/types.js';
3
+ export type NumberInputProps = Omit<InputGroupProps, "children" | "inline" | "render"> & Omit<InputHTMLAttributes<HTMLInputElement>, "children" | "type"> & {
4
+ /**
5
+ * Justerer teksten i inputfeltet.
6
+ * @default "left"
7
+ */
8
+ align?: "left" | "right";
9
+ /**
10
+ * CSS-verdi for bredden til input-feltet.
11
+ */
12
+ width?: string;
13
+ inputClassName?: string;
14
+ /**
15
+ * Viser knapper på hver side av feltet som bruker native stepping.
16
+ * Respekterer `min`, `max` og `step`.
17
+ * @default false
18
+ */
19
+ stepper?: boolean;
20
+ };
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{forwardRef as a,useState as r,useRef as s,useEffect as n}from"react";const o=a((a,o)=>{const{autoExpand:l,counter:i,onBlur:c,onFocus:u,rows:d=7,placeholder:h=" ",startOpen:x,style:f,value:g,"aria-invalid":v,onChange:p,...m}=a,[y,_]=r(()=>typeof g>"u"?0:"number"==typeof g?String(g).length:g.length),[j,k]=r(!1),w=s(null),N=o||w;n(()=>{const e=N.current;if(e){if(!l)return void(e.style.height="");j||g?(e.style.height="auto",e.style.height=`${e.scrollHeight}px`):e.style.height=""}},[l,N,g,j,y]);const B=i?.maxLength||0,$=B-y;const A=!(!v&&!(i&&y>B?`Du har skrevet ${y-B} tegn for mye`:void 0));return e("div",{className:"jkl-text-area-wrapper","data-invalid":A,"data-has-content":y>0,children:[t("textarea",{"aria-invalid":A,className:`jkl-text-area__text-area jkl-text-area__text-area--${d}-rows`,onBlur:function(e){k(!1),c&&c(e)},onFocus:function(e){k(!0),u&&u(e)},onChange:function(e){_(e.target.value.length),p&&p(e)},ref:N,style:{...f,...{overflowX:l?"hidden":void 0}},placeholder:h,value:g,...m}),i&&e("div",{className:"jkl-text-area__counter","aria-hidden":"true",children:[e("div",{className:"jkl-text-area__counter-count",children:[y," / ",B]}),!i.hideProgress&&t("div",{className:"jkl-text-area__counter-progress",style:{"--progress-width":(C=$,E=B,C<=0||0===E?0:100*C/E)+"%"}})]})]});var C,E});o.displayName="BaseTextArea";export{o as BaseTextArea};
1
+ import{jsxs as e,jsx as a}from"react/jsx-runtime";import{forwardRef as t,useState as r,useRef as s,useEffect as o}from"react";import{getCounterValue as l}from"./counter.js";const n=t((t,n)=>{const{autoExpand:i,counter:u,defaultValue:c,onBlur:d,onFocus:h,rows:f=7,placeholder:x=" ",startOpen:p,style:g,value:m,"aria-invalid":v,onChange:j,...y}=t,_=u?.strategy??"characters",k=typeof m<"u",[w,N]=r(c),[B,C]=r(!1),V=s(null),A=n||V,E=k?m:w,F=k?{value:m}:{defaultValue:c},R=l(E,_),T=u?.maxLength||0,$=T-R,H=!(!v&&!!!(u&&R>T));o(()=>{const e=A.current;if(e){if(!i)return void(e.style.height="");B||E?(e.style.height="auto",e.style.height=`${e.scrollHeight}px`):e.style.height=""}},[i,A,E,B,R]);return e("div",{className:"jkl-text-area-wrapper","data-invalid":H,"data-has-content":R>0,children:[a("textarea",{"aria-invalid":H,className:`jkl-text-area__text-area jkl-text-area__text-area--${f}-rows`,onBlur:function(e){C(!1),d&&d(e)},onFocus:function(e){C(!0),h&&h(e)},onChange:function(e){k||N(e.target.value),j&&j(e)},ref:A,style:{...g,...{overflowX:i?"hidden":void 0}},placeholder:x,...F,...y}),u&&e("div",{className:"jkl-text-area__counter","aria-hidden":"true",children:[e("div",{className:"jkl-text-area__counter-count",children:[R," / ",T]}),!u.hideProgress&&a("div",{className:"jkl-text-area__counter-progress",style:{"--progress-width":(L=$,O=T,L<=0||0===O?0:100*L/O)+"%"}})]})]});var L,O});n.displayName="BaseTextArea";export{n as BaseTextArea};
2
2
  //# sourceMappingURL=BaseTextArea.js.map