@oslokommune/punkt-react 7.2.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/punkt-react.es.js +11 -11
- package/dist/punkt-react.umd.js +2 -2
- package/package.json +4 -4
- package/src/components/select/Select.test.tsx +62 -0
- package/src/components/select/Select.tsx +79 -0
- package/src/components/textarea/Textarea.tsx +3 -5
- package/src/components/textinput/Textinput.tsx +6 -10
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,26 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [8.0.0](https://github.com/oslokommune/punkt/compare/7.2.0...8.0.0) (2023-09-19)
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
* PktSelect (#1163). Helt ny PktSelect, samt forbedring av hvordan de forskjellige inputene deler stiler.
|
|
12
|
+
|
|
13
|
+
BREAKING CHANGE: Gammel klasse `.pkt-select` vil ikke lenger virke som ønsket. Anbefales å enten bruke komponent PktSelect eller bruke ny klasse `.pkt-input`
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
Ingen
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
Ingen
|
|
21
|
+
|
|
22
|
+
### Chores
|
|
23
|
+
Ingen
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
|
|
8
28
|
## [7.2.0](https://github.com/oslokommune/punkt/compare/7.1.7...7.2.0) (2023-09-13)
|
|
9
29
|
|
|
10
30
|
### ⚠ BREAKING CHANGES
|
package/dist/punkt-react.es.js
CHANGED
|
@@ -635,7 +635,7 @@ function pn(e, n) {
|
|
|
635
635
|
return !je[e] && typeof window.fetch == "function" && (je[e] = window.fetch(n + e + ".svg").then((r) => r.ok ? r.text() : (console.error("Missing icon: " + n + e + ".svg"), fn)).then((r) => r)), Promise.resolve(je[e]);
|
|
636
636
|
}
|
|
637
637
|
const y = ({ name: e, path: n, className: r = "", ...l }) => {
|
|
638
|
-
const a = "https://punkt-cdn.oslo.kommune.no/
|
|
638
|
+
const a = "https://punkt-cdn.oslo.kommune.no/8.0/icons/", [i, s] = ie(null);
|
|
639
639
|
return yt(() => {
|
|
640
640
|
if (!e)
|
|
641
641
|
return;
|
|
@@ -1637,7 +1637,7 @@ const Lt = /* @__PURE__ */ sn(Kn), lr = H(
|
|
|
1637
1637
|
name: "oslologo",
|
|
1638
1638
|
className: "pkt-header__logo-svg",
|
|
1639
1639
|
"aria-hidden": "true",
|
|
1640
|
-
path: "https://punkt-cdn.oslo.kommune.no/
|
|
1640
|
+
path: "https://punkt-cdn.oslo.kommune.no/8.0/logos/"
|
|
1641
1641
|
}
|
|
1642
1642
|
) }) : /* @__PURE__ */ o(
|
|
1643
1643
|
"button",
|
|
@@ -1651,7 +1651,7 @@ const Lt = /* @__PURE__ */ sn(Kn), lr = H(
|
|
|
1651
1651
|
name: "oslologo",
|
|
1652
1652
|
className: "pkt-header__logo-svg",
|
|
1653
1653
|
"aria-hidden": "true",
|
|
1654
|
-
path: "https://punkt-cdn.oslo.kommune.no/
|
|
1654
|
+
path: "https://punkt-cdn.oslo.kommune.no/8.0/logos/"
|
|
1655
1655
|
}
|
|
1656
1656
|
)
|
|
1657
1657
|
}
|
|
@@ -2050,7 +2050,7 @@ const pr = H(
|
|
|
2050
2050
|
"textarea",
|
|
2051
2051
|
{
|
|
2052
2052
|
ref: W,
|
|
2053
|
-
className: `pkt-
|
|
2053
|
+
className: `pkt-input ${a && J > a ? "pkt-input--counter-error" : ""}`,
|
|
2054
2054
|
name: O || e,
|
|
2055
2055
|
id: e,
|
|
2056
2056
|
placeholder: T,
|
|
@@ -2063,7 +2063,7 @@ const pr = H(
|
|
|
2063
2063
|
onChange: b
|
|
2064
2064
|
}
|
|
2065
2065
|
),
|
|
2066
|
-
l && /* @__PURE__ */ m("div", { className: "pkt-
|
|
2066
|
+
l && /* @__PURE__ */ m("div", { className: "pkt-input__counter", "aria-live": "polite", "aria-atomic": !0, children: [
|
|
2067
2067
|
J || 0,
|
|
2068
2068
|
a && `/${a}`
|
|
2069
2069
|
] })
|
|
@@ -2116,13 +2116,13 @@ const pr = H(
|
|
|
2116
2116
|
optional: P,
|
|
2117
2117
|
required: g,
|
|
2118
2118
|
useWrapper: M,
|
|
2119
|
-
children: /* @__PURE__ */ m("div", { className: "pkt-
|
|
2120
|
-
R && /* @__PURE__ */ o("div", { className: "pkt-
|
|
2119
|
+
children: /* @__PURE__ */ m("div", { className: "pkt-input__container", children: [
|
|
2120
|
+
R && /* @__PURE__ */ o("div", { className: "pkt-input-prefix", children: R }),
|
|
2121
2121
|
/* @__PURE__ */ o(
|
|
2122
2122
|
"input",
|
|
2123
2123
|
{
|
|
2124
2124
|
ref: V,
|
|
2125
|
-
className: "pkt-
|
|
2125
|
+
className: "pkt-input",
|
|
2126
2126
|
type: $,
|
|
2127
2127
|
name: O || e,
|
|
2128
2128
|
id: e,
|
|
@@ -2136,11 +2136,11 @@ const pr = H(
|
|
|
2136
2136
|
...z
|
|
2137
2137
|
}
|
|
2138
2138
|
),
|
|
2139
|
-
j && /* @__PURE__ */ m("p", { className: "pkt-
|
|
2139
|
+
j && /* @__PURE__ */ m("p", { className: "pkt-input-suffix", children: [
|
|
2140
2140
|
j,
|
|
2141
|
-
v && /* @__PURE__ */ o(y, { className: "pkt-
|
|
2141
|
+
v && /* @__PURE__ */ o(y, { className: "pkt-input-suffix-icon", name: v })
|
|
2142
2142
|
] }),
|
|
2143
|
-
!j && v && /* @__PURE__ */ o(y, { className: "pkt-
|
|
2143
|
+
!j && v && /* @__PURE__ */ o(y, { className: "pkt-input-icon", name: v })
|
|
2144
2144
|
] })
|
|
2145
2145
|
}
|
|
2146
2146
|
);
|
package/dist/punkt-react.umd.js
CHANGED
|
@@ -24,7 +24,7 @@ Check the render method of \``+t+"`."}return""}}function rr(t){{if(t!==void 0){v
|
|
|
24
24
|
|
|
25
25
|
Check your code at `+u+":"+d+"."}return""}}var Dt={};function ar(t){{var u=jt();if(!u){var d=typeof t=="string"?t:t.displayName||t.name;d&&(u=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+d+">.")}return u}}function Lt(t,u){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var d=ar(u);if(Dt[d])return;Dt[d]=!0;var k="";t&&t._owner&&t._owner!==Ye.current&&(k=" It was passed a child from "+I(t._owner.type)+"."),ne(t),g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,k),ne(null)}}function It(t,u){{if(typeof t!="object")return;if(Me(t))for(var d=0;d<t.length;d++){var k=t[d];He(k)&&Lt(k,u)}else if(He(t))t._store&&(t._store.validated=!0);else if(t){var C=D(t);if(typeof C=="function"&&C!==t.entries)for(var O=C.call(t),w;!(w=O.next()).done;)He(w.value)&&Lt(w.value,u)}}}function or(t){{var u=t.type;if(u==null||typeof u=="string")return;var d;if(typeof u=="function")d=u.propTypes;else if(typeof u=="object"&&(u.$$typeof===f||u.$$typeof===v))d=u.propTypes;else return;if(d){var k=I(u);Jn(d,t.props,"prop",k,t)}else if(u.PropTypes!==void 0&&!Je){Je=!0;var C=I(u);g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",C||"Unknown")}typeof u.getDefaultProps=="function"&&!u.getDefaultProps.isReactClassApproved&&g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lr(t){{for(var u=Object.keys(t.props),d=0;d<u.length;d++){var k=u[d];if(k!=="children"&&k!=="key"){ne(t),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",k),ne(null);break}}t.ref!==null&&(ne(t),g("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}}function Ft(t,u,d,k,C,O){{var w=z(t);if(!w){var y="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var V=rr(C);V?y+=V:y+=jt();var F;t===null?F="null":Me(t)?F="array":t!==void 0&&t.$$typeof===n?(F="<"+(I(t.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):F=typeof t,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",F,y)}var $=nr(t,u,d,C,O);if($==null)return $;if(w){var H=u.children;if(H!==void 0)if(k)if(Me(H)){for(var re=0;re<H.length;re++)It(H[re],t);Object.freeze&&Object.freeze(H)}else g("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else It(H,t)}return t===l?lr($):or($),$}}function ir(t,u,d){return Ft(t,u,d,!0)}function sr(t,u,d){return Ft(t,u,d,!1)}var cr=sr,ur=ir;oe.Fragment=l,oe.jsx=cr,oe.jsxs=ur}()),oe}process.env.NODE_ENV==="production"?we.exports=Wt():we.exports=Vt();var xe=we.exports;const q=xe.Fragment,o=xe.jsx,p=xe.jsxs,Ce={},Mt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>';function Bt(e,n){return!Ce[e]&&typeof window.fetch=="function"&&(Ce[e]=window.fetch(n+e+".svg").then(r=>r.ok?r.text():(console.error("Missing icon: "+n+e+".svg"),Mt)).then(r=>r)),Promise.resolve(Ce[e])}const N=({name:e,path:n,className:r="",...l})=>{const a="https://punkt-cdn.oslo.kommune.no/
|
|
27
|
+
Check the top-level render call using <`+d+">.")}return u}}function Lt(t,u){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var d=ar(u);if(Dt[d])return;Dt[d]=!0;var k="";t&&t._owner&&t._owner!==Ye.current&&(k=" It was passed a child from "+I(t._owner.type)+"."),ne(t),g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,k),ne(null)}}function It(t,u){{if(typeof t!="object")return;if(Me(t))for(var d=0;d<t.length;d++){var k=t[d];He(k)&&Lt(k,u)}else if(He(t))t._store&&(t._store.validated=!0);else if(t){var C=D(t);if(typeof C=="function"&&C!==t.entries)for(var O=C.call(t),w;!(w=O.next()).done;)He(w.value)&&Lt(w.value,u)}}}function or(t){{var u=t.type;if(u==null||typeof u=="string")return;var d;if(typeof u=="function")d=u.propTypes;else if(typeof u=="object"&&(u.$$typeof===f||u.$$typeof===v))d=u.propTypes;else return;if(d){var k=I(u);Jn(d,t.props,"prop",k,t)}else if(u.PropTypes!==void 0&&!Je){Je=!0;var C=I(u);g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",C||"Unknown")}typeof u.getDefaultProps=="function"&&!u.getDefaultProps.isReactClassApproved&&g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lr(t){{for(var u=Object.keys(t.props),d=0;d<u.length;d++){var k=u[d];if(k!=="children"&&k!=="key"){ne(t),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",k),ne(null);break}}t.ref!==null&&(ne(t),g("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}}function Ft(t,u,d,k,C,O){{var w=z(t);if(!w){var y="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var V=rr(C);V?y+=V:y+=jt();var F;t===null?F="null":Me(t)?F="array":t!==void 0&&t.$$typeof===n?(F="<"+(I(t.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):F=typeof t,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",F,y)}var $=nr(t,u,d,C,O);if($==null)return $;if(w){var H=u.children;if(H!==void 0)if(k)if(Me(H)){for(var re=0;re<H.length;re++)It(H[re],t);Object.freeze&&Object.freeze(H)}else g("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else It(H,t)}return t===l?lr($):or($),$}}function ir(t,u,d){return Ft(t,u,d,!0)}function sr(t,u,d){return Ft(t,u,d,!1)}var cr=sr,ur=ir;oe.Fragment=l,oe.jsx=cr,oe.jsxs=ur}()),oe}process.env.NODE_ENV==="production"?we.exports=Wt():we.exports=Vt();var xe=we.exports;const q=xe.Fragment,o=xe.jsx,p=xe.jsxs,Ce={},Mt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>';function Bt(e,n){return!Ce[e]&&typeof window.fetch=="function"&&(Ce[e]=window.fetch(n+e+".svg").then(r=>r.ok?r.text():(console.error("Missing icon: "+n+e+".svg"),Mt)).then(r=>r)),Promise.resolve(Ce[e])}const N=({name:e,path:n,className:r="",...l})=>{const a="https://punkt-cdn.oslo.kommune.no/8.0/icons/",[i,s]=E.useState(null);return E.useEffect(()=>{if(!e)return;Bt(e,n||a).then(f=>s(f))},[e,n,a]),i?o("span",{className:`pkt-icon ${r}`,dangerouslySetInnerHTML:{__html:i},...l}):null},qe=E.forwardRef(({children:e,className:n,skin:r="info",closeAlert:l=!1,onClose:a,title:i,date:s,ariaLive:c="polite",...f},m)=>{const h=[n,"pkt-alert",r&&`pkt-alert--${r}`].filter(Boolean).join(" "),[v,x]=E.useState(!0),P=()=>{x(!1),a&&a()};return v?p("div",{...f,className:h,"aria-live":c,ref:m,children:[o(N,{className:"pkt-alert__icon",name:r==="info"?"alert-information":`alert-${r}`}),l&&o("div",{className:"pkt-alert__close",children:o("button",{type:"button",className:"pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only",tabIndex:0,"aria-label":"close",onClick:P,children:o(N,{name:"close",className:"pkt-btn__icon","aria-hidden":"true"})})}),i&&o("div",{className:"pkt-alert__title",children:i}),o("div",{className:"pkt-alert__text",children:e}),s&&p("div",{className:"pkt-alert__date",children:["Sist oppdatert: ",s]})]}):null}),Yt=E.forwardRef(({href:e,text:n,onClick:r,className:l,...a},i)=>{const s=[l,"pkt-back-link"].filter(Boolean).join(" ");return o("nav",{ref:i,className:s,"aria-label":"Gå tilbake et steg",children:p("a",{href:e||"/",className:"pkt-link pkt-link--icon-left",onClick:()=>{r&&r()},...a,children:[o(N,{className:"pkt-back-link__icon pkt-icon pkt-link__icon",name:"chevron-thin-left","aria-hidden":"true"}),o("span",{className:"pkt-back-link__text",children:n||"Forsiden"})]})})});/**
|
|
28
28
|
* @remix-run/router v1.7.1
|
|
29
29
|
*
|
|
30
30
|
* Copyright (c) Remix Software Inc.
|
|
@@ -55,4 +55,4 @@ Check the top-level render call using <`+d+">.")}return u}}function Lt(t,u){{if(
|
|
|
55
55
|
Copyright (c) 2018 Jed Watson.
|
|
56
56
|
Licensed under the MIT License (MIT), see
|
|
57
57
|
http://jedwatson.github.io/classnames
|
|
58
|
-
*/(function(e){(function(){var n={}.hasOwnProperty;function r(){for(var l=[],a=0;a<arguments.length;a++){var i=arguments[a];if(i){var s=typeof i;if(s==="string"||s==="number")l.push(i);else if(Array.isArray(i)){if(i.length){var c=r.apply(null,i);c&&l.push(c)}}else if(s==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){l.push(i.toString());continue}for(var f in i)n.call(i,f)&&i[f]&&l.push(f)}}}return l.join(" ")}e.exports?(r.default=r,e.exports=r):window.classNames=r})()})(ut);var On=ut.exports;const ft=Ut(On),Tn=E.forwardRef(({logoLink:e="https://www.oslo.kommune.no/",serviceName:n,fixed:r=!0,scrollToHide:l=!0,user:a,userMenu:i,representing:s,userOptions:c,userMenuFooter:f,canChangeRepresentation:m=!0,showMenuButton:h=!1,showLogOutButton:v=!1,openMenu:x,logOut:P,changeRepresentation:j,...S},D)=>{const R=E.useMemo(()=>typeof(a==null?void 0:a.lastLoggedIn)=="string"?a.lastLoggedIn:a!=null&&a.lastLoggedIn?new Date(a.lastLoggedIn).toLocaleString("nb-NO",{year:"numeric",month:"long",day:"numeric"}):"",[a]),[g,L]=E.useState(!1),[U,Y]=E.useState(0),[W,G]=E.useState(!1),M=E.useRef(null);E.useEffect(()=>(document.addEventListener("mouseup",z),window.addEventListener("scroll",K),()=>{document.removeEventListener("mouseup",z),window.removeEventListener("scroll",K)}));const B=()=>{G(!W)},z=b=>{M.current&&!M.current.contains(b.target)&&G(!1)},K=()=>{if(l){const b=window.pageYOffset||document.documentElement.scrollTop;if(b<0||Math.abs(b-U)<60)return;L(b>U),Y(b)}};return p("header",{...S,id:"pkt-header","data-testid":"pkt-header","aria-label":"Topp",className:ft("pkt-header",{"pkt-header--fixed":r,"pkt-header--scroll-to-hide":l,"pkt-header--hidden":g}),ref:D,children:[p("div",{className:"pkt-header__logo",children:[typeof e=="string"?o("a",{"aria-label":"Tilbake til forside",className:"pkt-header__logo-link",href:e,children:o(N,{name:"oslologo",className:"pkt-header__logo-svg","aria-hidden":"true",path:"https://punkt-cdn.oslo.kommune.no/7.2/logos/"})}):o("button",{"aria-label":"Tilbake til forside",className:"pkt-link-button pkt-link pkt-header__logo-link",onClick:e,children:o(N,{name:"oslologo",className:"pkt-header__logo-svg","aria-hidden":"true",path:"https://punkt-cdn.oslo.kommune.no/7.2/logos/"})}),o("span",{className:"pkt-header__logo-service",children:n})]}),o("nav",{className:"pkt-header__actions",children:p("ul",{className:"pkt-header__actions-row",children:[h&&o("li",{children:o(ie,{className:"pkt-header__menu-btn",skin:"secondary",variant:"icon-right",iconName:"menu",onClick:x,children:"Meny"})}),(a||s)&&p("li",{"data-testid":"usermenu",className:`pkt-header--has-dropdown ${W&&!g?"pkt-header--open-dropdown":""}`,ref:M,children:[p("button",{className:"pkt-header__user-btn pkt-btn pkt-btn--secondary pkt-btn--icons-right-and-left",type:"button",role:"button","aria-controls":"pktUserDropdown","aria-expanded":W,onClick:B,children:[o(N,{name:"user",className:"pkt-btn__icon"}),o("span",{className:"pkt-header__user-fullname",children:(s==null?void 0:s.name)||(a==null?void 0:a.name)}),o("span",{className:"pkt-header__user-shortname",children:(s==null?void 0:s.shortname)||(a==null?void 0:a.shortname)}),o(N,{name:"chevron-thin-down",className:"pkt-btn--closed"}),o(N,{name:"chevron-thin-up",className:"pkt-btn--open"})]}),p("ul",{id:"pktUserDropdown",className:"pkt-header__dropdown pkt-user-menu",children:[a&&p("li",{children:[o("div",{className:"pkt-user-menu__label",children:"Pålogget som"}),o("div",{className:"pkt-user-menu__name",children:a.name}),a.lastLoggedIn&&p("div",{className:"pkt-user-menu__last-logged-in",children:["Sist pålogget: ",o("time",{children:R})]})]}),i&&o("li",{children:o("ul",{className:"pkt-list",children:i.map((b,I)=>o("li",{children:typeof b.target=="string"?p("a",{href:b.target,className:"pkt-link",children:[b.iconName&&o(N,{name:b.iconName,className:"pkt-link__icon"}),b.title]}):p("button",{className:"pkt-link-button pkt-link",onClick:b.target,children:[b.iconName&&o(N,{name:b.iconName,className:"pkt-link__icon"}),b.title]})},`userMenu-${I}`))})}),(s||m)&&p("li",{children:[s&&p(q,{children:[o("div",{className:"pkt-user-menu__label",children:"Representerer"}),o("div",{className:"pkt-user-menu__name",children:s.name}),s.orgNumber&&p("div",{className:"pkt-user-menu__org-number",children:["Org.nr. ",s.orgNumber]})]}),o("ul",{className:"pkt-list mt-size-16",children:m&&o("li",{children:p("button",{className:"pkt-link-button pkt-link",onClick:j,children:[o(N,{name:"cogwheel",className:"pkt-link__icon"}),"Endre organisasjon"]})})})]}),o("li",{children:o("ul",{className:"pkt-list",children:(c||!v)&&p(q,{children:[c==null?void 0:c.map((b,I)=>o("li",{children:typeof b.target=="string"?p("a",{href:b.target,className:"pkt-link",children:[b.iconName&&o(N,{name:b.iconName,className:"pkt-link__icon"}),b.title]}):p("button",{className:"pkt-link-button pkt-link",onClick:b.target,children:[b.iconName&&o(N,{name:b.iconName,className:"pkt-link__icon"}),b.title]})},`userOptions-${I}`)),!v&&o("li",{children:p("button",{className:"pkt-link-button pkt-link",onClick:P,children:[o(N,{name:"exit",className:"pkt-link__icon"}),"Logg ut"]})})]})})}),f&&o("li",{className:"footer",children:o("ul",{className:"pkt-list-horizontal bordered",children:f.map((b,I)=>o("li",{children:typeof b.target=="string"?o("a",{href:b.target,className:"pkt-link",children:b.title}):o("button",{className:"pkt-link-button pkt-link",onClick:b.target,children:b.title})},`userMenuFooter-${I}`))})})]})]}),v&&o("li",{children:o(ie,{className:"pkt-header__user-btn pkt-header__user-btn-logout",iconName:"exit",role:"button",onClick:P,skin:"secondary",variant:"icon-right",children:"Logg ut"})})]})})]})}),dt=E.forwardRef(({label:e,id:n,children:r,...l},a)=>p("div",{className:"pkt-form-group",children:[o("label",{htmlFor:n,className:"pkt-form-label",children:e}),o("input",{className:"pkt-form-input",id:n,...l,ref:a}),r]}));dt.displayName="PktInput";const _e=E.forwardRef(({forId:e,label:n,helptext:r,helptextDropdown:l,helptextDropdownButton:a,optional:i,required:s,hasError:c,errorMessage:f,disabled:m,inline:h,ariaDescribedby:v,useWrapper:x=!0,children:P,className:j},S)=>{const[D,R]=E.useState(!1),g=()=>{R(!D)},L=()=>i?"pkt-tag pkt-tag--small pkt-tag--thin-text pkt-tag--blue-light":s?"pkt-tag pkt-tag--small pkt-tag--thin-text pkt-tag--beige":"",U=i?"Valgfritt":s?"Må fylles ut":"",Y=m?"pkt-inputwrapper--disabled":"",W=h?"pkt-inputwrapper--inline":"",G=c?"pkt-inputwrapper--error":"",M=!!l&&l!=="",B=a||'Les mer <span class="pkt-sr-only">om inputfeltet</span>',z=M?"div":"label",K=M?"h2":"span",b=v||(r?`${e}-helptext`:void 0);return p("div",{className:["pkt-inputwrapper",j,Y,W,G].join(" "),ref:S,children:[x?p(q,{children:[o(z,{htmlFor:e,className:"pkt-inputwrapper__label","aria-describedby":M?"":v,children:p(K,{id:`${e}-label`,children:[n,U!==""&&o("span",{className:L(),children:U})]})}),r&&o("div",{className:"pkt-inputwrapper__helptext",id:`${e}-helptext`,children:r}),M&&l!==""&&p("div",{children:[o(ie,{skin:"tertiary",size:"small",variant:"icon-right",iconName:D?"chevron-thin-up":"chevron-thin-down",className:"pkt-inputwrapper__helptext-expandable pkt-link pkt-link--icon-right",onClick:g,children:o("span",{dangerouslySetInnerHTML:{__html:B}})}),o("div",{className:`pkt-inputwrapper__helptext ${D?"pkt-inputwrapper__helptext-expandable-open":"pkt-inputwrapper__helptext-expandable-closed"}`,children:o("span",{dangerouslySetInnerHTML:{__html:l}})}),o("label",{htmlFor:e,className:"pkt-sr-only","aria-describedby":b,children:n})]}),o(q,{children:P})]}):p(q,{children:[o("label",{htmlFor:e,className:"pkt-sr-only","aria-describedby":b,id:`${e}-label`,children:n}),P]}),c&&o("div",{children:o(qe,{skin:"error","aria-live":"assertive",children:f})})]})});_e.displayName="PktInputWrapper";const pt=E.forwardRef(({children:e,className:n,iconName:r="user",openInNewTab:l=!1,skin:a="normal",href:i="#",external:s=!1,title:c},f)=>{const m=[n,"pkt-linkcard",a&&`pkt-linkcard--${a}`].filter(Boolean).join(" ");return p("a",{href:i,className:`pkt-linkcard pkt-link ${m}`,target:l?"_blank":"_self",rel:l?"noopener noreferrer":void 0,ref:f,children:[o(N,{className:"pkt-link__icon",name:r}),p("div",{className:"pkt-linkcard__content",children:[o("div",{className:`pkt-linkcard__title ${s?"pkt-link pkt-link--external":""}`,children:c}),o("div",{className:"pkt-linkcard__text",children:e})]})]})});pt.displayName="PktLinkCard";const jn=({children:e,skin:n="beige",title:r,className:l,...a})=>{const i=["pkt-messagebox",n&&`pkt-messagebox--${n}`,l].filter(Boolean).join(" ");return p("div",{...a,className:i,children:[o("div",{className:"pkt-messagebox__title",children:r}),o("div",{className:"pkt-messagebox__text",children:e})]})},mt=E.forwardRef(({id:e,name:n,label:r,value:l,...a},i)=>p("div",{className:"pkt-form-group",children:[o("input",{type:"radio",className:"pkt-form-check-input",id:e,name:n,value:l,ref:i,...a}),o("label",{className:"pkt-form-label",htmlFor:e,children:r})]}));mt.displayName="PktRadio";const Dn=({label:e,children:n})=>p(q,{children:[o("p",{children:e}),o("div",{className:"pkt-form-group",children:n})]}),Ln=({isResponsive:e,children:n})=>e?o("div",{className:"pkt-table-container",children:n}):o(q,{children:n}),In=({isResponsive:e,modifiers:{info:n=!1,success:r=!1,strong:l=!1,shadow:a=!1}={},children:i})=>o(Ln,{isResponsive:e,children:o("table",{className:ft("pkt-table",{"pkt-table--info":n,"pkt-table--success":r,"pkt-table--strong":l,"pkt-table--shadow":a}),children:i})}),Fn=({children:e})=>o("td",{className:"pkt-table__th",children:e}),$n=({children:e})=>o("th",{className:"pkt-table__th",children:e}),ht=E.forwardRef(({children:e,className:n,skin:r="blue",textStyle:l="normal-text",size:a="medium",closeTag:i=!1,iconName:s="",type:c="button",ariaLabel:f="close",onClick:m=()=>{}},h)=>{const[v,x]=E.useState(!1),P=R=>{x(!0),m(R)},j=["pkt-tag",a&&`pkt-tag--${a}`,r&&`pkt-tag--${r}`,l&&`pkt-tag--${l}`,n].filter(Boolean).join(" "),S=["pkt-tag","pkt-btn","pkt-btn--tertiary",a&&`pkt-tag--${a}`,r&&`pkt-tag--${r}`,l&&`pkt-tag--${l}`,s&&i?"pkt-btn--icons-right-and-left":null,i&&!s?"pkt-btn--icon-right":null,n].filter(Boolean).join(" "),D=!v;return i&&s?o(q,{children:D&&p("button",{className:S,type:c,"aria-label":f,onClick:P,ref:h,children:[o(N,{className:"pkt-tag__icon",name:s}),e,o(N,{className:"pkt-tag__close-btn",name:"close"})]})}):i?o(q,{children:D&&p("button",{className:S,type:c,"aria-label":f,onClick:P,ref:h,children:[o(N,{className:"pkt-tag__close-btn",name:"close"}),e]})}):s?p("span",{className:j,children:[o(N,{className:"pkt-tag__icon",name:s}),e]}):o("span",{className:j,children:e})});ht.displayName="PktTag";const An=E.forwardRef(({id:e,ariaDescribedby:n,ariaLabelledby:r,counter:l,counterMaxLength:a,className:i,disabled:s,errorMessage:c,hasError:f,helptext:m,helptextDropdown:h,helptextDropdownButton:v,inline:x,label:P,name:j,optional:S,placeholder:D,required:R,rows:g,useWrapper:L,onChange:U,...Y},W)=>{const G=[i,"pkt-textinput","pkt-textarea"].join(" "),M=r||`${e}-label`,B=E.useRef(null),[z,K]=E.useState(0),b=I=>{var J,Q;if(l&&K(((Q=(J=I.currentTarget)==null?void 0:J.value)==null?void 0:Q.length)||0),U)return U(I)};return E.useEffect(()=>{var I,J;typeof W=="function"&&W(B.current),l&&K(((J=(I=B==null?void 0:B.current)==null?void 0:I.value)==null?void 0:J.length)||0)},[W]),p(_e,{ariaDescribedby:n,className:G,disabled:s,errorMessage:c,forId:e,hasError:f,helptext:m,helptextDropdown:h,helptextDropdownButton:v,inline:x,label:P,optional:S,required:R,useWrapper:L,children:[o("textarea",{ref:B,className:`pkt-textinput__input ${a&&z>a?"pkt-textinput__input--counter-error":""}`,name:j||e,id:e,placeholder:D,disabled:s,rows:g,"aria-labelledby":M,"aria-invalid":f,"aria-required":R,...Y,onChange:b}),l&&p("div",{className:"pkt-textinput__counter","aria-live":"polite","aria-atomic":!0,children:[z||0,a&&`/${a}`]})]})}),Un=E.forwardRef(({id:e,ariaDescribedby:n,ariaLabelledby:r,autocomplete:l="off",className:a,disabled:i=!1,errorMessage:s,hasError:c=!1,helptext:f,helptextDropdown:m,helptextDropdownButton:h,iconNameRight:v,inline:x=!1,label:P,name:j,optional:S=!1,placeholder:D,prefix:R,required:g=!1,suffix:L,type:U="text",useWrapper:Y=!0,value:W,...G},M)=>{const B=[a,"pkt-textinput"].join(" "),z=r||`${e}-label`;return o(_e,{ariaDescribedby:n,className:B,disabled:i,errorMessage:s,forId:e,hasError:c,helptext:f,helptextDropdown:m,helptextDropdownButton:h,inline:x,label:P,optional:S,required:g,useWrapper:Y,children:p("div",{className:"pkt-textinput__container",children:[R&&o("div",{className:"pkt-textinput__input-prefix",children:R}),o("input",{ref:M,className:"pkt-textinput__input",type:U,name:j||e,id:e,placeholder:D,autoComplete:l,value:W,disabled:i,"aria-required":g,"aria-invalid":c,"aria-labelledby":z,...G}),L&&p("p",{className:"pkt-textinput__input-suffix",children:[L,v&&o(N,{className:"pkt-textinput__input-suffix-icon",name:v})]}),!L&&v&&o(N,{className:"pkt-textinput__input-icon",name:v})]})})});T.PktAlert=qe,T.PktBackLink=Yt,T.PktBreadcrumbs=Pn,T.PktButton=ie,T.PktFooter=Rn,T.PktFooterSimple=Sn,T.PktHeader=Tn,T.PktIcon=N,T.PktInput=dt,T.PktInputWrapper=_e,T.PktLinkCard=pt,T.PktMessagebox=jn,T.PktRadio=mt,T.PktRadioGroup=Dn,T.PktTable=In,T.PktTableData=Fn,T.PktTableHeader=$n,T.PktTag=ht,T.PktTextarea=An,T.PktTextinput=Un,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
|
58
|
+
*/(function(e){(function(){var n={}.hasOwnProperty;function r(){for(var l=[],a=0;a<arguments.length;a++){var i=arguments[a];if(i){var s=typeof i;if(s==="string"||s==="number")l.push(i);else if(Array.isArray(i)){if(i.length){var c=r.apply(null,i);c&&l.push(c)}}else if(s==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){l.push(i.toString());continue}for(var f in i)n.call(i,f)&&i[f]&&l.push(f)}}}return l.join(" ")}e.exports?(r.default=r,e.exports=r):window.classNames=r})()})(ut);var On=ut.exports;const ft=Ut(On),Tn=E.forwardRef(({logoLink:e="https://www.oslo.kommune.no/",serviceName:n,fixed:r=!0,scrollToHide:l=!0,user:a,userMenu:i,representing:s,userOptions:c,userMenuFooter:f,canChangeRepresentation:m=!0,showMenuButton:h=!1,showLogOutButton:v=!1,openMenu:x,logOut:P,changeRepresentation:j,...S},D)=>{const R=E.useMemo(()=>typeof(a==null?void 0:a.lastLoggedIn)=="string"?a.lastLoggedIn:a!=null&&a.lastLoggedIn?new Date(a.lastLoggedIn).toLocaleString("nb-NO",{year:"numeric",month:"long",day:"numeric"}):"",[a]),[g,L]=E.useState(!1),[U,Y]=E.useState(0),[W,G]=E.useState(!1),M=E.useRef(null);E.useEffect(()=>(document.addEventListener("mouseup",z),window.addEventListener("scroll",K),()=>{document.removeEventListener("mouseup",z),window.removeEventListener("scroll",K)}));const B=()=>{G(!W)},z=b=>{M.current&&!M.current.contains(b.target)&&G(!1)},K=()=>{if(l){const b=window.pageYOffset||document.documentElement.scrollTop;if(b<0||Math.abs(b-U)<60)return;L(b>U),Y(b)}};return p("header",{...S,id:"pkt-header","data-testid":"pkt-header","aria-label":"Topp",className:ft("pkt-header",{"pkt-header--fixed":r,"pkt-header--scroll-to-hide":l,"pkt-header--hidden":g}),ref:D,children:[p("div",{className:"pkt-header__logo",children:[typeof e=="string"?o("a",{"aria-label":"Tilbake til forside",className:"pkt-header__logo-link",href:e,children:o(N,{name:"oslologo",className:"pkt-header__logo-svg","aria-hidden":"true",path:"https://punkt-cdn.oslo.kommune.no/8.0/logos/"})}):o("button",{"aria-label":"Tilbake til forside",className:"pkt-link-button pkt-link pkt-header__logo-link",onClick:e,children:o(N,{name:"oslologo",className:"pkt-header__logo-svg","aria-hidden":"true",path:"https://punkt-cdn.oslo.kommune.no/8.0/logos/"})}),o("span",{className:"pkt-header__logo-service",children:n})]}),o("nav",{className:"pkt-header__actions",children:p("ul",{className:"pkt-header__actions-row",children:[h&&o("li",{children:o(ie,{className:"pkt-header__menu-btn",skin:"secondary",variant:"icon-right",iconName:"menu",onClick:x,children:"Meny"})}),(a||s)&&p("li",{"data-testid":"usermenu",className:`pkt-header--has-dropdown ${W&&!g?"pkt-header--open-dropdown":""}`,ref:M,children:[p("button",{className:"pkt-header__user-btn pkt-btn pkt-btn--secondary pkt-btn--icons-right-and-left",type:"button",role:"button","aria-controls":"pktUserDropdown","aria-expanded":W,onClick:B,children:[o(N,{name:"user",className:"pkt-btn__icon"}),o("span",{className:"pkt-header__user-fullname",children:(s==null?void 0:s.name)||(a==null?void 0:a.name)}),o("span",{className:"pkt-header__user-shortname",children:(s==null?void 0:s.shortname)||(a==null?void 0:a.shortname)}),o(N,{name:"chevron-thin-down",className:"pkt-btn--closed"}),o(N,{name:"chevron-thin-up",className:"pkt-btn--open"})]}),p("ul",{id:"pktUserDropdown",className:"pkt-header__dropdown pkt-user-menu",children:[a&&p("li",{children:[o("div",{className:"pkt-user-menu__label",children:"Pålogget som"}),o("div",{className:"pkt-user-menu__name",children:a.name}),a.lastLoggedIn&&p("div",{className:"pkt-user-menu__last-logged-in",children:["Sist pålogget: ",o("time",{children:R})]})]}),i&&o("li",{children:o("ul",{className:"pkt-list",children:i.map((b,I)=>o("li",{children:typeof b.target=="string"?p("a",{href:b.target,className:"pkt-link",children:[b.iconName&&o(N,{name:b.iconName,className:"pkt-link__icon"}),b.title]}):p("button",{className:"pkt-link-button pkt-link",onClick:b.target,children:[b.iconName&&o(N,{name:b.iconName,className:"pkt-link__icon"}),b.title]})},`userMenu-${I}`))})}),(s||m)&&p("li",{children:[s&&p(q,{children:[o("div",{className:"pkt-user-menu__label",children:"Representerer"}),o("div",{className:"pkt-user-menu__name",children:s.name}),s.orgNumber&&p("div",{className:"pkt-user-menu__org-number",children:["Org.nr. ",s.orgNumber]})]}),o("ul",{className:"pkt-list mt-size-16",children:m&&o("li",{children:p("button",{className:"pkt-link-button pkt-link",onClick:j,children:[o(N,{name:"cogwheel",className:"pkt-link__icon"}),"Endre organisasjon"]})})})]}),o("li",{children:o("ul",{className:"pkt-list",children:(c||!v)&&p(q,{children:[c==null?void 0:c.map((b,I)=>o("li",{children:typeof b.target=="string"?p("a",{href:b.target,className:"pkt-link",children:[b.iconName&&o(N,{name:b.iconName,className:"pkt-link__icon"}),b.title]}):p("button",{className:"pkt-link-button pkt-link",onClick:b.target,children:[b.iconName&&o(N,{name:b.iconName,className:"pkt-link__icon"}),b.title]})},`userOptions-${I}`)),!v&&o("li",{children:p("button",{className:"pkt-link-button pkt-link",onClick:P,children:[o(N,{name:"exit",className:"pkt-link__icon"}),"Logg ut"]})})]})})}),f&&o("li",{className:"footer",children:o("ul",{className:"pkt-list-horizontal bordered",children:f.map((b,I)=>o("li",{children:typeof b.target=="string"?o("a",{href:b.target,className:"pkt-link",children:b.title}):o("button",{className:"pkt-link-button pkt-link",onClick:b.target,children:b.title})},`userMenuFooter-${I}`))})})]})]}),v&&o("li",{children:o(ie,{className:"pkt-header__user-btn pkt-header__user-btn-logout",iconName:"exit",role:"button",onClick:P,skin:"secondary",variant:"icon-right",children:"Logg ut"})})]})})]})}),dt=E.forwardRef(({label:e,id:n,children:r,...l},a)=>p("div",{className:"pkt-form-group",children:[o("label",{htmlFor:n,className:"pkt-form-label",children:e}),o("input",{className:"pkt-form-input",id:n,...l,ref:a}),r]}));dt.displayName="PktInput";const _e=E.forwardRef(({forId:e,label:n,helptext:r,helptextDropdown:l,helptextDropdownButton:a,optional:i,required:s,hasError:c,errorMessage:f,disabled:m,inline:h,ariaDescribedby:v,useWrapper:x=!0,children:P,className:j},S)=>{const[D,R]=E.useState(!1),g=()=>{R(!D)},L=()=>i?"pkt-tag pkt-tag--small pkt-tag--thin-text pkt-tag--blue-light":s?"pkt-tag pkt-tag--small pkt-tag--thin-text pkt-tag--beige":"",U=i?"Valgfritt":s?"Må fylles ut":"",Y=m?"pkt-inputwrapper--disabled":"",W=h?"pkt-inputwrapper--inline":"",G=c?"pkt-inputwrapper--error":"",M=!!l&&l!=="",B=a||'Les mer <span class="pkt-sr-only">om inputfeltet</span>',z=M?"div":"label",K=M?"h2":"span",b=v||(r?`${e}-helptext`:void 0);return p("div",{className:["pkt-inputwrapper",j,Y,W,G].join(" "),ref:S,children:[x?p(q,{children:[o(z,{htmlFor:e,className:"pkt-inputwrapper__label","aria-describedby":M?"":v,children:p(K,{id:`${e}-label`,children:[n,U!==""&&o("span",{className:L(),children:U})]})}),r&&o("div",{className:"pkt-inputwrapper__helptext",id:`${e}-helptext`,children:r}),M&&l!==""&&p("div",{children:[o(ie,{skin:"tertiary",size:"small",variant:"icon-right",iconName:D?"chevron-thin-up":"chevron-thin-down",className:"pkt-inputwrapper__helptext-expandable pkt-link pkt-link--icon-right",onClick:g,children:o("span",{dangerouslySetInnerHTML:{__html:B}})}),o("div",{className:`pkt-inputwrapper__helptext ${D?"pkt-inputwrapper__helptext-expandable-open":"pkt-inputwrapper__helptext-expandable-closed"}`,children:o("span",{dangerouslySetInnerHTML:{__html:l}})}),o("label",{htmlFor:e,className:"pkt-sr-only","aria-describedby":b,children:n})]}),o(q,{children:P})]}):p(q,{children:[o("label",{htmlFor:e,className:"pkt-sr-only","aria-describedby":b,id:`${e}-label`,children:n}),P]}),c&&o("div",{children:o(qe,{skin:"error","aria-live":"assertive",children:f})})]})});_e.displayName="PktInputWrapper";const pt=E.forwardRef(({children:e,className:n,iconName:r="user",openInNewTab:l=!1,skin:a="normal",href:i="#",external:s=!1,title:c},f)=>{const m=[n,"pkt-linkcard",a&&`pkt-linkcard--${a}`].filter(Boolean).join(" ");return p("a",{href:i,className:`pkt-linkcard pkt-link ${m}`,target:l?"_blank":"_self",rel:l?"noopener noreferrer":void 0,ref:f,children:[o(N,{className:"pkt-link__icon",name:r}),p("div",{className:"pkt-linkcard__content",children:[o("div",{className:`pkt-linkcard__title ${s?"pkt-link pkt-link--external":""}`,children:c}),o("div",{className:"pkt-linkcard__text",children:e})]})]})});pt.displayName="PktLinkCard";const jn=({children:e,skin:n="beige",title:r,className:l,...a})=>{const i=["pkt-messagebox",n&&`pkt-messagebox--${n}`,l].filter(Boolean).join(" ");return p("div",{...a,className:i,children:[o("div",{className:"pkt-messagebox__title",children:r}),o("div",{className:"pkt-messagebox__text",children:e})]})},mt=E.forwardRef(({id:e,name:n,label:r,value:l,...a},i)=>p("div",{className:"pkt-form-group",children:[o("input",{type:"radio",className:"pkt-form-check-input",id:e,name:n,value:l,ref:i,...a}),o("label",{className:"pkt-form-label",htmlFor:e,children:r})]}));mt.displayName="PktRadio";const Dn=({label:e,children:n})=>p(q,{children:[o("p",{children:e}),o("div",{className:"pkt-form-group",children:n})]}),Ln=({isResponsive:e,children:n})=>e?o("div",{className:"pkt-table-container",children:n}):o(q,{children:n}),In=({isResponsive:e,modifiers:{info:n=!1,success:r=!1,strong:l=!1,shadow:a=!1}={},children:i})=>o(Ln,{isResponsive:e,children:o("table",{className:ft("pkt-table",{"pkt-table--info":n,"pkt-table--success":r,"pkt-table--strong":l,"pkt-table--shadow":a}),children:i})}),Fn=({children:e})=>o("td",{className:"pkt-table__th",children:e}),$n=({children:e})=>o("th",{className:"pkt-table__th",children:e}),ht=E.forwardRef(({children:e,className:n,skin:r="blue",textStyle:l="normal-text",size:a="medium",closeTag:i=!1,iconName:s="",type:c="button",ariaLabel:f="close",onClick:m=()=>{}},h)=>{const[v,x]=E.useState(!1),P=R=>{x(!0),m(R)},j=["pkt-tag",a&&`pkt-tag--${a}`,r&&`pkt-tag--${r}`,l&&`pkt-tag--${l}`,n].filter(Boolean).join(" "),S=["pkt-tag","pkt-btn","pkt-btn--tertiary",a&&`pkt-tag--${a}`,r&&`pkt-tag--${r}`,l&&`pkt-tag--${l}`,s&&i?"pkt-btn--icons-right-and-left":null,i&&!s?"pkt-btn--icon-right":null,n].filter(Boolean).join(" "),D=!v;return i&&s?o(q,{children:D&&p("button",{className:S,type:c,"aria-label":f,onClick:P,ref:h,children:[o(N,{className:"pkt-tag__icon",name:s}),e,o(N,{className:"pkt-tag__close-btn",name:"close"})]})}):i?o(q,{children:D&&p("button",{className:S,type:c,"aria-label":f,onClick:P,ref:h,children:[o(N,{className:"pkt-tag__close-btn",name:"close"}),e]})}):s?p("span",{className:j,children:[o(N,{className:"pkt-tag__icon",name:s}),e]}):o("span",{className:j,children:e})});ht.displayName="PktTag";const An=E.forwardRef(({id:e,ariaDescribedby:n,ariaLabelledby:r,counter:l,counterMaxLength:a,className:i,disabled:s,errorMessage:c,hasError:f,helptext:m,helptextDropdown:h,helptextDropdownButton:v,inline:x,label:P,name:j,optional:S,placeholder:D,required:R,rows:g,useWrapper:L,onChange:U,...Y},W)=>{const G=[i,"pkt-textinput","pkt-textarea"].join(" "),M=r||`${e}-label`,B=E.useRef(null),[z,K]=E.useState(0),b=I=>{var J,Q;if(l&&K(((Q=(J=I.currentTarget)==null?void 0:J.value)==null?void 0:Q.length)||0),U)return U(I)};return E.useEffect(()=>{var I,J;typeof W=="function"&&W(B.current),l&&K(((J=(I=B==null?void 0:B.current)==null?void 0:I.value)==null?void 0:J.length)||0)},[W]),p(_e,{ariaDescribedby:n,className:G,disabled:s,errorMessage:c,forId:e,hasError:f,helptext:m,helptextDropdown:h,helptextDropdownButton:v,inline:x,label:P,optional:S,required:R,useWrapper:L,children:[o("textarea",{ref:B,className:`pkt-input ${a&&z>a?"pkt-input--counter-error":""}`,name:j||e,id:e,placeholder:D,disabled:s,rows:g,"aria-labelledby":M,"aria-invalid":f,"aria-required":R,...Y,onChange:b}),l&&p("div",{className:"pkt-input__counter","aria-live":"polite","aria-atomic":!0,children:[z||0,a&&`/${a}`]})]})}),Un=E.forwardRef(({id:e,ariaDescribedby:n,ariaLabelledby:r,autocomplete:l="off",className:a,disabled:i=!1,errorMessage:s,hasError:c=!1,helptext:f,helptextDropdown:m,helptextDropdownButton:h,iconNameRight:v,inline:x=!1,label:P,name:j,optional:S=!1,placeholder:D,prefix:R,required:g=!1,suffix:L,type:U="text",useWrapper:Y=!0,value:W,...G},M)=>{const B=[a,"pkt-textinput"].join(" "),z=r||`${e}-label`;return o(_e,{ariaDescribedby:n,className:B,disabled:i,errorMessage:s,forId:e,hasError:c,helptext:f,helptextDropdown:m,helptextDropdownButton:h,inline:x,label:P,optional:S,required:g,useWrapper:Y,children:p("div",{className:"pkt-input__container",children:[R&&o("div",{className:"pkt-input-prefix",children:R}),o("input",{ref:M,className:"pkt-input",type:U,name:j||e,id:e,placeholder:D,autoComplete:l,value:W,disabled:i,"aria-required":g,"aria-invalid":c,"aria-labelledby":z,...G}),L&&p("p",{className:"pkt-input-suffix",children:[L,v&&o(N,{className:"pkt-input-suffix-icon",name:v})]}),!L&&v&&o(N,{className:"pkt-input-icon",name:v})]})})});T.PktAlert=qe,T.PktBackLink=Yt,T.PktBreadcrumbs=Pn,T.PktButton=ie,T.PktFooter=Rn,T.PktFooterSimple=Sn,T.PktHeader=Tn,T.PktIcon=N,T.PktInput=dt,T.PktInputWrapper=_e,T.PktLinkCard=pt,T.PktMessagebox=jn,T.PktRadio=mt,T.PktRadioGroup=Dn,T.PktTable=In,T.PktTableData=Fn,T.PktTableHeader=$n,T.PktTag=ht,T.PktTextarea=An,T.PktTextinput=Un,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"test": "react-scripts test --env=jsdom"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@oslokommune/punkt-assets": "^
|
|
35
|
-
"@oslokommune/punkt-css": "^
|
|
34
|
+
"@oslokommune/punkt-assets": "^8.0.0",
|
|
35
|
+
"@oslokommune/punkt-css": "^8.0.0",
|
|
36
36
|
"@testing-library/jest-dom": "^5.16.5",
|
|
37
37
|
"@testing-library/react": "^14.0.0",
|
|
38
38
|
"@testing-library/user-event": "^14.4.3",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
91
91
|
},
|
|
92
92
|
"license": "MIT",
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "802717c2facf5f2d3688cf39f1c448ee75f75f8e"
|
|
94
94
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect'
|
|
2
|
+
|
|
3
|
+
import { fireEvent, render } from '@testing-library/react'
|
|
4
|
+
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
5
|
+
import React from 'react'
|
|
6
|
+
|
|
7
|
+
import { PktSelect } from './Select'
|
|
8
|
+
|
|
9
|
+
expect.extend(toHaveNoViolations)
|
|
10
|
+
|
|
11
|
+
describe('PktSelect', () => {
|
|
12
|
+
test('renders select field with correct props', () => {
|
|
13
|
+
const { getByLabelText } = render(<PktSelect label="Input Label" id="inputId" />)
|
|
14
|
+
|
|
15
|
+
const selectElement = getByLabelText('Input Label')
|
|
16
|
+
expect(selectElement).toBeInTheDocument()
|
|
17
|
+
expect(selectElement.tagName).toBe('SELECT')
|
|
18
|
+
expect(selectElement.id).toBe('inputId')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('renders error message when hasError prop is true', () => {
|
|
22
|
+
const { getByText } = render(
|
|
23
|
+
<PktSelect label="Input Label" id="inputId" hasError errorMessage="Input error" />,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const errorMessage = getByText('Input error')
|
|
27
|
+
expect(errorMessage).toBeInTheDocument()
|
|
28
|
+
expect(errorMessage).toHaveClass('pkt-alert__text')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
describe('PktSelect', () => {
|
|
32
|
+
test('toggles helptext class', () => {
|
|
33
|
+
const { getByText, container } = render(
|
|
34
|
+
<PktSelect
|
|
35
|
+
label="Input Label"
|
|
36
|
+
id="inputId"
|
|
37
|
+
helptext="Help Text"
|
|
38
|
+
helptextDropdown="Help Text"
|
|
39
|
+
/>,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
const expandButton = getByText('Les mer')
|
|
43
|
+
const helptextElement = container.querySelector(
|
|
44
|
+
'.pkt-inputwrapper__helptext-expandable-closed',
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
fireEvent.click(expandButton)
|
|
48
|
+
expect(helptextElement).toHaveClass('pkt-inputwrapper__helptext-expandable-open')
|
|
49
|
+
|
|
50
|
+
fireEvent.click(expandButton)
|
|
51
|
+
expect(helptextElement).toHaveClass('pkt-inputwrapper__helptext-expandable-closed')
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
describe('accessibility', () => {
|
|
56
|
+
it('renders with no wcag errors with axe', async () => {
|
|
57
|
+
const { container } = render(<PktSelect label="Input Label" id="inputId" />)
|
|
58
|
+
const results = await axe(container)
|
|
59
|
+
expect(results).toHaveNoViolations()
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
})
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, { ForwardedRef, forwardRef, ReactNode, SelectHTMLAttributes } from 'react'
|
|
2
|
+
|
|
3
|
+
import { PktInputWrapper } from '../inputwrapper/InputWrapper'
|
|
4
|
+
|
|
5
|
+
export interface IPktSelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
|
|
6
|
+
ariaDescribedby?: string
|
|
7
|
+
ariaLabelledby?: string
|
|
8
|
+
children?: ReactNode
|
|
9
|
+
disabled?: boolean
|
|
10
|
+
errorMessage?: string
|
|
11
|
+
hasError?: boolean
|
|
12
|
+
helptext?: string
|
|
13
|
+
helptextDropdown?: string
|
|
14
|
+
helptextDropdownButton?: string
|
|
15
|
+
id: string
|
|
16
|
+
inline?: boolean
|
|
17
|
+
label: string
|
|
18
|
+
name?: string
|
|
19
|
+
optional?: boolean
|
|
20
|
+
required?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const PktSelect = forwardRef(
|
|
24
|
+
(
|
|
25
|
+
{
|
|
26
|
+
ariaDescribedby,
|
|
27
|
+
ariaLabelledby,
|
|
28
|
+
children,
|
|
29
|
+
className,
|
|
30
|
+
disabled = false,
|
|
31
|
+
errorMessage,
|
|
32
|
+
hasError,
|
|
33
|
+
helptext,
|
|
34
|
+
helptextDropdown,
|
|
35
|
+
helptextDropdownButton,
|
|
36
|
+
id,
|
|
37
|
+
inline = false,
|
|
38
|
+
label,
|
|
39
|
+
name,
|
|
40
|
+
optional = false,
|
|
41
|
+
required = false,
|
|
42
|
+
...props
|
|
43
|
+
}: IPktSelectProps,
|
|
44
|
+
ref: ForwardedRef<HTMLSelectElement>,
|
|
45
|
+
) => {
|
|
46
|
+
const classNames = [className, 'pkt-select'].join(' ')
|
|
47
|
+
return (
|
|
48
|
+
<PktInputWrapper
|
|
49
|
+
className={classNames}
|
|
50
|
+
forId={id}
|
|
51
|
+
label={label}
|
|
52
|
+
helptext={helptext}
|
|
53
|
+
helptextDropdown={helptextDropdown}
|
|
54
|
+
helptextDropdownButton={helptextDropdownButton}
|
|
55
|
+
optional={optional}
|
|
56
|
+
required={required}
|
|
57
|
+
hasError={hasError}
|
|
58
|
+
errorMessage={errorMessage}
|
|
59
|
+
disabled={disabled}
|
|
60
|
+
inline={inline}
|
|
61
|
+
ariaDescribedby={ariaDescribedby}
|
|
62
|
+
>
|
|
63
|
+
<select
|
|
64
|
+
ref={ref}
|
|
65
|
+
className="pkt-input"
|
|
66
|
+
aria-invalid={hasError}
|
|
67
|
+
aria-labelledby={ariaLabelledby || `${id}-label`}
|
|
68
|
+
aria-required={required}
|
|
69
|
+
disabled={disabled}
|
|
70
|
+
id={id}
|
|
71
|
+
name={name || id}
|
|
72
|
+
{...props}
|
|
73
|
+
>
|
|
74
|
+
{children}
|
|
75
|
+
</select>
|
|
76
|
+
</PktInputWrapper>
|
|
77
|
+
)
|
|
78
|
+
},
|
|
79
|
+
)
|
|
@@ -98,10 +98,8 @@ export const PktTextarea = forwardRef(
|
|
|
98
98
|
>
|
|
99
99
|
<textarea
|
|
100
100
|
ref={internalRef}
|
|
101
|
-
className={`pkt-
|
|
102
|
-
counterMaxLength && counterCurrent > counterMaxLength
|
|
103
|
-
? 'pkt-textinput__input--counter-error'
|
|
104
|
-
: ''
|
|
101
|
+
className={`pkt-input ${
|
|
102
|
+
counterMaxLength && counterCurrent > counterMaxLength ? 'pkt-input--counter-error' : ''
|
|
105
103
|
}`}
|
|
106
104
|
name={name || id}
|
|
107
105
|
id={id}
|
|
@@ -115,7 +113,7 @@ export const PktTextarea = forwardRef(
|
|
|
115
113
|
onChange={handleChange}
|
|
116
114
|
/>
|
|
117
115
|
{counter && (
|
|
118
|
-
<div className="pkt-
|
|
116
|
+
<div className="pkt-input__counter" aria-live="polite" aria-atomic={true}>
|
|
119
117
|
{counterCurrent || 0}
|
|
120
118
|
{counterMaxLength && `/${counterMaxLength}`}
|
|
121
119
|
</div>
|
|
@@ -77,11 +77,11 @@ export const PktTextinput = forwardRef(
|
|
|
77
77
|
required={required}
|
|
78
78
|
useWrapper={useWrapper}
|
|
79
79
|
>
|
|
80
|
-
<div className="pkt-
|
|
81
|
-
{prefix && <div className="pkt-
|
|
80
|
+
<div className="pkt-input__container">
|
|
81
|
+
{prefix && <div className="pkt-input-prefix">{prefix}</div>}
|
|
82
82
|
<input
|
|
83
83
|
ref={ref}
|
|
84
|
-
className="pkt-
|
|
84
|
+
className="pkt-input"
|
|
85
85
|
type={type}
|
|
86
86
|
name={name || id}
|
|
87
87
|
id={id}
|
|
@@ -95,17 +95,13 @@ export const PktTextinput = forwardRef(
|
|
|
95
95
|
{...props}
|
|
96
96
|
/>
|
|
97
97
|
{suffix && (
|
|
98
|
-
<p className="pkt-
|
|
98
|
+
<p className="pkt-input-suffix">
|
|
99
99
|
{suffix}
|
|
100
|
-
{iconNameRight &&
|
|
101
|
-
<PktIcon className="pkt-textinput__input-suffix-icon" name={iconNameRight} />
|
|
102
|
-
)}
|
|
100
|
+
{iconNameRight && <PktIcon className="pkt-input-suffix-icon" name={iconNameRight} />}
|
|
103
101
|
</p>
|
|
104
102
|
)}
|
|
105
103
|
|
|
106
|
-
{!suffix && iconNameRight &&
|
|
107
|
-
<PktIcon className="pkt-textinput__input-icon" name={iconNameRight} />
|
|
108
|
-
)}
|
|
104
|
+
{!suffix && iconNameRight && <PktIcon className="pkt-input-icon" name={iconNameRight} />}
|
|
109
105
|
</div>
|
|
110
106
|
</PktInputWrapper>
|
|
111
107
|
)
|