@oslokommune/punkt-react 4.3.2 → 5.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 +18 -0
- package/dist/icon/Icon.d.ts +5 -5
- package/dist/punkt-react.es.js +445 -430
- package/dist/punkt-react.umd.js +11 -11
- package/package.json +4 -4
- package/src/components/alert/Alert.tsx +4 -3
- package/src/components/footer/Footer.tsx +10 -6
- package/src/components/header/Header.tsx +2 -9
- package/src/components/icon/Icon.tsx +55 -14
package/dist/punkt-react.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(g,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],E):(g=typeof globalThis<"u"?globalThis:g||self,E(g["punkt-react"]={},g.React))})(this,function(g,E){"use strict";function Me(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var z={exports:{}},Y={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var ne;function $e(){if(ne)return Y;ne=1;var o=E,l=Symbol.for("react.element"),i=Symbol.for("react.fragment"),c=Object.prototype.hasOwnProperty,f=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n={key:!0,ref:!0,__self:!0,__source:!0};function _(k,h,T){var R,j={},S=null,D=null;T!==void 0&&(S=""+T),h.key!==void 0&&(S=""+h.key),h.ref!==void 0&&(D=h.ref);for(R in h)c.call(h,R)&&!n.hasOwnProperty(R)&&(j[R]=h[R]);if(k&&k.defaultProps)for(R in h=k.defaultProps,h)j[R]===void 0&&(j[R]=h[R]);return{$$typeof:l,type:k,key:S,ref:D,props:j,_owner:f.current}}return Y.Fragment=i,Y.jsx=_,Y.jsxs=_,Y}var M={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var oe;function Le(){return oe||(oe=1,process.env.NODE_ENV!=="production"&&function(){var o=E,l=Symbol.for("react.element"),i=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),_=Symbol.for("react.provider"),k=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),me=Symbol.iterator,tt="@@iterator";function rt(e){if(e===null||typeof e!="object")return null;var t=me&&e[me]||e[tt];return typeof t=="function"?t:null}var I=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(e){{for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];at("error",e,r)}}function at(e,t,r){{var s=I.ReactDebugCurrentFrame,m=s.getStackAddendum();m!==""&&(t+="%s",r=r.concat([m]));var v=r.map(function(p){return String(p)});v.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,v)}}var nt=!1,ot=!1,lt=!1,it=!1,st=!1,he;he=Symbol.for("react.module.reference");function ct(e){return!!(typeof e=="string"||typeof e=="function"||e===c||e===n||st||e===f||e===T||e===R||it||e===D||nt||ot||lt||typeof e=="object"&&e!==null&&(e.$$typeof===S||e.$$typeof===j||e.$$typeof===_||e.$$typeof===k||e.$$typeof===h||e.$$typeof===he||e.getModuleId!==void 0))}function ut(e,t,r){var s=e.displayName;if(s)return s;var m=t.displayName||t.name||"";return m!==""?r+"("+m+")":r}function _e(e){return e.displayName||"Context"}function C(e){if(e==null)return null;if(typeof e.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case c:return"Fragment";case i:return"Portal";case n:return"Profiler";case f:return"StrictMode";case T:return"Suspense";case R:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case k:var t=e;return _e(t)+".Consumer";case _:var r=e;return _e(r._context)+".Provider";case h:return ut(e,e.render,"ForwardRef");case j:var s=e.displayName||null;return s!==null?s:C(e.type)||"Memo";case S:{var m=e,v=m._payload,p=m._init;try{return C(p(v))}catch{return null}}}return null}var F=Object.assign,$=0,ve,ke,be,ge,Ne,ye,Re;function Ee(){}Ee.__reactDisabledLog=!0;function ft(){{if($===0){ve=console.log,ke=console.info,be=console.warn,ge=console.error,Ne=console.group,ye=console.groupCollapsed,Re=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ee,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}$++}}function pt(){{if($--,$===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:F({},e,{value:ve}),info:F({},e,{value:ke}),warn:F({},e,{value:be}),error:F({},e,{value:ge}),group:F({},e,{value:Ne}),groupCollapsed:F({},e,{value:ye}),groupEnd:F({},e,{value:Re})})}$<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var X=I.ReactCurrentDispatcher,Z;function B(e,t,r){{if(Z===void 0)try{throw Error()}catch(m){var s=m.stack.trim().match(/\n( *(at )?)/);Z=s&&s[1]||""}return`
|
|
18
|
+
`+Z+e}}var Q=!1,V;{var dt=typeof WeakMap=="function"?WeakMap:Map;V=new dt}function we(e,t){if(!e||Q)return"";{var r=V.get(e);if(r!==void 0)return r}var s;Q=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var v;v=X.current,X.current=null,ft();try{if(t){var p=function(){throw Error()};if(Object.defineProperty(p.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(p,[])}catch(O){s=O}Reflect.construct(e,[],p)}else{try{p.call()}catch(O){s=O}e.call(p.prototype)}}else{try{throw Error()}catch(O){s=O}e()}}catch(O){if(O&&s&&typeof O.stack=="string"){for(var u=O.stack.split(`
|
|
19
|
+
`),P=s.stack.split(`
|
|
20
|
+
`),b=u.length-1,N=P.length-1;b>=1&&N>=0&&u[b]!==P[N];)N--;for(;b>=1&&N>=0;b--,N--)if(u[b]!==P[N]){if(b!==1||N!==1)do if(b--,N--,N<0||u[b]!==P[N]){var x=`
|
|
21
|
+
`+u[b].replace(" at new "," at ");return e.displayName&&x.includes("<anonymous>")&&(x=x.replace("<anonymous>",e.displayName)),typeof e=="function"&&V.set(e,x),x}while(b>=1&&N>=0);break}}}finally{Q=!1,X.current=v,pt(),Error.prepareStackTrace=m}var W=e?e.displayName||e.name:"",Ye=W?B(W):"";return typeof e=="function"&&V.set(e,Ye),Ye}function mt(e,t,r){return we(e,!1)}function ht(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function U(e,t,r){if(e==null)return"";if(typeof e=="function")return we(e,ht(e));if(typeof e=="string")return B(e);switch(e){case T:return B("Suspense");case R:return B("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case h:return mt(e.render);case j:return U(e.type,t,r);case S:{var s=e,m=s._payload,v=s._init;try{return U(v(m),t,r)}catch{}}}return""}var H=Object.prototype.hasOwnProperty,Pe={},Te=I.ReactDebugCurrentFrame;function G(e){if(e){var t=e._owner,r=U(e.type,e._source,t?t.type:null);Te.setExtraStackFrame(r)}else Te.setExtraStackFrame(null)}function _t(e,t,r,s,m){{var v=Function.call.bind(H);for(var p in e)if(v(e,p)){var u=void 0;try{if(typeof e[p]!="function"){var P=Error((s||"React class")+": "+r+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw P.name="Invariant Violation",P}u=e[p](t,p,s,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(b){u=b}u&&!(u instanceof Error)&&(G(m),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",r,p,typeof u),G(null)),u instanceof Error&&!(u.message in Pe)&&(Pe[u.message]=!0,G(m),w("Failed %s type: %s",r,u.message),G(null))}}}var vt=Array.isArray;function q(e){return vt(e)}function kt(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,r=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r}}function bt(e){try{return xe(e),!1}catch{return!0}}function xe(e){return""+e}function je(e){if(bt(e))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",kt(e)),xe(e)}var L=I.ReactCurrentOwner,gt={key:!0,ref:!0,__self:!0,__source:!0},Se,Ce,ee;ee={};function Nt(e){if(H.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function yt(e){if(H.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function Rt(e,t){if(typeof e.ref=="string"&&L.current&&t&&L.current.stateNode!==t){var r=C(L.current.type);ee[r]||(w('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',C(L.current.type),e.ref),ee[r]=!0)}}function Et(e,t){{var r=function(){Se||(Se=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}}function wt(e,t){{var r=function(){Ce||(Ce=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}}var Pt=function(e,t,r,s,m,v,p){var u={$$typeof:l,type:e,key:t,ref:r,props:p,_owner:v};return u._store={},Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(u,"_self",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.defineProperty(u,"_source",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u};function Tt(e,t,r,s,m){{var v,p={},u=null,P=null;r!==void 0&&(je(r),u=""+r),yt(t)&&(je(t.key),u=""+t.key),Nt(t)&&(P=t.ref,Rt(t,m));for(v in t)H.call(t,v)&&!gt.hasOwnProperty(v)&&(p[v]=t[v]);if(e&&e.defaultProps){var b=e.defaultProps;for(v in b)p[v]===void 0&&(p[v]=b[v])}if(u||P){var N=typeof e=="function"?e.displayName||e.name||"Unknown":e;u&&Et(p,N),P&&wt(p,N)}return Pt(e,u,P,m,s,L.current,p)}}var te=I.ReactCurrentOwner,Oe=I.ReactDebugCurrentFrame;function A(e){if(e){var t=e._owner,r=U(e.type,e._source,t?t.type:null);Oe.setExtraStackFrame(r)}else Oe.setExtraStackFrame(null)}var re;re=!1;function ae(e){return typeof e=="object"&&e!==null&&e.$$typeof===l}function Fe(){{if(te.current){var e=C(te.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function xt(e){{if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,""),r=e.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+t+":"+
|
|
25
|
+
Check your code at `+t+":"+r+"."}return""}}var De={};function jt(e){{var t=Fe();if(!t){var r=typeof e=="string"?e:e.displayName||e.name;r&&(t=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+a+">.")}return t}}function Fe(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var a=Pt(t);if(Oe[a])return;Oe[a]=!0;var i="";e&&e._owner&&e._owner!==ee.current&&(i=" It was passed a child from "+C(e._owner.type)+"."),A(e),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',a,i),A(null)}}function De(e,t){{if(typeof e!="object")return;if(Q(e))for(var a=0;a<e.length;a++){var i=e[a];re(i)&&Fe(i,t)}else if(re(e))e._store&&(e._store.validated=!0);else if(e){var m=qe(e);if(typeof m=="function"&&m!==e.entries)for(var _=m.call(e),u;!(u=_.next()).done;)re(u.value)&&Fe(u.value,t)}}}function Tt(e){{var t=e.type;if(t==null||typeof t=="string")return;var a;if(typeof t=="function")a=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===h||t.$$typeof===j))a=t.propTypes;else return;if(a){var i=C(t);dt(a,e.props,"prop",i,e)}else if(t.PropTypes!==void 0&&!te){te=!0;var m=C(t);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",m||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xt(e){{for(var t=Object.keys(e.props),a=0;a<t.length;a++){var i=t[a];if(i!=="children"&&i!=="key"){A(e),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",i),A(null);break}}e.ref!==null&&(A(e),E("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}function Ie(e,t,a,i,m,_){{var u=it(e);if(!u){var f="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(f+=" 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 w=wt(m);w?f+=w:f+=Ce();var k;e===null?k="null":Q(e)?k="array":e!==void 0&&e.$$typeof===l?(k="<"+(C(e.type)||"Unknown")+" />",f=" Did you accidentally export a JSX literal instead of a component?"):k=typeof e,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",k,f)}var N=Et(e,t,a,m,_);if(N==null)return N;if(u){var x=t.children;if(x!==void 0)if(i)if(Q(x)){for(var $=0;$<x.length;$++)De(x[$],e);Object.freeze&&Object.freeze(x)}else E("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 De(x,e)}return e===c?xt(N):Tt(N),N}}function jt(e,t,a){return Ie(e,t,a,!0)}function St(e,t,a){return Ie(e,t,a,!1)}var Ct=St,Ot=jt;Y.Fragment=c,Y.jsx=Ct,Y.jsxs=Ot}()),Y}process.env.NODE_ENV==="production"?H.exports=We():H.exports=Ye();var J=H.exports;const oe=J.Fragment,r=J.jsx,p=J.jsxs,y=({className:o,name:l,viewBox:s="0 0 32 32",...c})=>{const d=[o].filter(Boolean).join(" ");return r("svg",{...c,className:d,viewBox:s,children:r("use",{href:`#${l}`})})},Be=P.forwardRef(({children:o,className:l,skin:s="info",closeAlert:c=!1,onClose:d,title:n,date:v,ariaLive:g="polite",...h},T)=>{const R=[l,"pkt-alert",s&&`pkt-alert--${s}`].filter(Boolean).join(" "),[j,S]=P.useState(!0),D=()=>{S(!1),d&&d()};return j?p("div",{...h,className:R,"aria-live":g,ref:T,children:[r("div",{className:"pkt-alert__icon",children:r(y,{name:s==="info"?"alert-information":`alert-${s}`})}),c&&r("div",{className:"pkt-alert__close",children:r("button",{type:"button",className:"pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only",tabIndex:0,"aria-label":"close",onClick:D,children:r(y,{name:"close",className:"pkt-btn__icon","aria-hidden":"true"})})}),n&&r("div",{className:"pkt-alert__title",children:n}),r("div",{className:"pkt-alert__text",children:o}),v&&p("div",{className:"pkt-alert__date",children:["Sist oppdatert: ",v]})]}):null}),ie=P.forwardRef(({children:o,className:l,iconName:s="user",secondIconName:c="user",size:d="medium",skin:n="primary",type:v="button",variant:g="label-only",...h},T)=>{const R=[l,"pkt-btn",d&&`pkt-btn--${d}`,n&&`pkt-btn--${n}`,g&&`pkt-btn--${g}`].filter(Boolean).join(" ");return p("button",{...h,className:R,type:v,ref:T,children:[r(y,{className:"pkt-btn__icon",name:s}),r("span",{className:"pkt-btn__text",children:o}),g==="icons-right-and-left"&&r(y,{className:"pkt-btn__icon",name:c})]})});ie.displayName="PktButton";const Me=({columnOne:o,columnTwo:l,socialLinks:s})=>{var c,d;return r("footer",{className:"pkt-footer","data-mode":"dark",children:p("div",{className:"pkt-footer__container",children:[p("div",{className:"pkt-grid pkt-grid--rowgap-size-32 pkt-grid--gap-size-16",children:[p("div",{className:"pkt-footer__column pkt-cell pkt-cell--span12 pkt-cell--span4-laptop-up",children:[r("h2",{className:"pkt-footer__title",children:o.title}),p("ul",{className:"pkt-footer__list",children:[o.text&&r("li",{className:"pkt-footer__text",children:o.text}),(c=o.links)==null?void 0:c.map((n,v)=>r("li",{className:"pkt-footer__list-item",children:p("a",{className:`pkt-footer__link ${n.external?"pkt-link--external":""}`,href:n.href,target:n.openInNewTab?"_blank":"_self",rel:n.openInNewTab?"noopener noreferrer":void 0,children:[r(y,{className:"pkt-footer__link-icon",name:"chevron-right"}),n.text]})},`links-${v}`))]})]}),p("div",{className:"pkt-footer__column pkt-cell pkt-cell--span12 pkt-cell--span4-laptop-up",children:[r("h2",{className:"pkt-footer__title",children:l.title}),p("ul",{className:"pkt-footer__list",children:[l.text&&r("li",{className:"pkt-footer__text",children:l.text}),(d=l.links)==null?void 0:d.map((n,v)=>r("li",{className:"pkt-footer__list-item",children:p("a",{className:`pkt-footer__link ${n.external?"pkt-link--external":""}`,href:n.href,target:n.openInNewTab?"_blank":"_self",rel:n.openInNewTab?"noopener noreferrer":void 0,children:[r(y,{className:"pkt-footer__link-icon",name:"chevron-right"}),n.text]})},`links-${v}`))]})]}),p("div",{className:"pkt-footer__column pkt-cell pkt-cell--span12 pkt-cell--span4-laptop-up",children:[r("h2",{className:"pkt-footer__title",children:"Om nettstedet"}),p("ul",{className:"pkt-footer__list",children:[r("li",{className:"pkt-footer__list-item",children:p("a",{className:"pkt-footer__link",href:"https://www.oslo.kommune.no/personvern-og-informasjonskapsler/",children:[r(y,{className:"pkt-footer__link-icon",name:"chevron-right"}),"Personvern og informasjonskapsler"]})}),r("li",{className:"pkt-footer__list-item",children:p("a",{className:"pkt-footer__link",href:"https://www.oslo.kommune.no/tilgjengelighet/",children:[r(y,{className:"pkt-footer__link-icon",name:"chevron-right"}),"Tilgjengelighet"]})})]})]})]}),s&&p("div",{className:"pkt-footer__social","aria-label":"standard lenker",children:[r("div",{className:"pkt-footer__social-languages",children:s.filter(n=>n.language).map((n,v)=>r("div",{className:"pkt-footer__social-language",children:r("a",{href:n.href,"aria-label":`til ${n.language} versjon av nettsiden`,target:n.openInNewTab?"_blank":"_self",rel:n.openInNewTab?"noopener noreferrer":void 0,children:n.language})},`sociallinks-language-${v}`))}),r("div",{className:"pkt-footer__social-icons",children:s.filter(n=>n.iconName).map((n,v)=>r(P.Fragment,{children:r("a",{href:n.href,"aria-label":`til ${n.iconName}`,className:"pkt-footer__social-icon-link",target:n.openInNewTab?"_blank":"_self",rel:n.openInNewTab?"noopener noreferrer":void 0,children:r("svg",{className:"pkt-footer__social-icon",viewBox:"0 0 32 32","aria-hidden":"true",children:r("use",{href:`#${n.iconName}`})})})},`sociallinks-${v}`))})]})]})})},Le=({links:o=[]})=>r("footer",{className:"pkt-footer-simple","data-mode":"dark",children:r("div",{className:"pkt-footer-simple__container",children:p("ul",{className:"pkt-footer-simple__list",children:[o.map((l,s)=>r("li",{className:"pkt-footer-simple__list-item",children:p("a",{className:`pkt-footer-simple__link ${l.external?" pkt-link--external":""}`,href:l.href,target:l.openInNewTab?"_blank":"_self",rel:l.openInNewTab?"noopener noreferrer":void 0,children:[r(y,{className:"pkt-footer-simple__link-icon",name:"chevron-right"}),l.text]})},s)),r("li",{className:"pkt-footer-simple__list-item",children:p("a",{className:"pkt-footer-simple__link",href:"https://www.oslo.kommune.no/personvern-og-informasjonskapsler/",children:[r(y,{className:"pkt-footer-simple__link-icon",name:"chevron-right"}),"Personvern og informasjonskapsler"]})}),r("li",{className:"pkt-footer-simple__list-item",children:p("a",{className:"pkt-footer-simple__link",href:"https://www.oslo.kommune.no/tilgjengelighet/",children:[r(y,{className:"pkt-footer-simple__link-icon",name:"chevron-right"}),"Tilgjengelighet"]})})]})})}),Ve=({className:o,logoLink:l="https://www.oslo.kommune.no/",isLoggedIn:s=!1,representing:c="",canChangeRepresentation:d=!1,showLogInButton:n=!0,onLogIn:v,onLogOut:g,onChangeRepresentation:h})=>{const T=[o,"pkt-header"].filter(Boolean).join(" ");return p("header",{id:"pkt-header",className:T,"aria-label":"Topp",children:[r("div",{className:"pkt-header__logo",children:r("a",{"aria-label":"Tilbake til forside",className:"pkt-header__logo-link",href:l,children:r(y,{name:"oslologo",className:"pkt-header__logo-svg",viewBox:"0 0 60 31","aria-hidden":"true"})})}),p("div",{className:"pkt-header__actions",children:[s&&d&&p("button",{className:"pkt-btn pkt-btn--secondary pkt-btn--icon-right","aria-label":`Bytt bruker fra ${c}`,onClick:h,children:[r(y,{name:"user",className:"pkt-btn__icon pkt-show-tablet-up"}),r("span",{className:"pkt-header__action-change pkt-hide pkt-show-tablet-up ml-size-15",children:"Endre"}),r("span",{className:"pkt-btn__text pkt-hide-tablet-up",children:"Endre"}),r("span",{className:"pkt-btn__text--representing pkt-hide pkt-show-tablet-up",children:c})]}),s&&!d&&p("div",{className:"pkt-header__action",children:[r("span",{className:"pkt-header__action-text",children:r("span",{className:"pkt-btn__text pkt-header__action-textrow text-row-inline pkt-truncate-text",children:c})}),r("span",{className:"pkt-header__action-icon pkt-show-phablet-up",children:r(y,{name:"user"})})]}),n&&s&&p("button",{className:"pkt-btn pkt-btn--tertiary pkt-btn--icon-right","aria-label":"Logg ut",onClick:g,children:[r(y,{className:"pkt-btn__icon pkt-show-tablet-up",name:"exit"}),r("span",{className:"pkt-btn__text",children:"Logg ut"})]}),n&&!s&&p("button",{className:"pkt-btn pkt-btn--tertiary pkt-btn--icon-right","aria-label":"Logg inn",onClick:v,children:[r(y,{className:"pkt-btn__icon",name:"user"}),r("span",{className:"pkt-btn__text",children:"Logg inn"})]})]})]})},le=P.forwardRef(({label:o,id:l,children:s,...c},d)=>p("div",{className:"pkt-form-group",children:[r("label",{htmlFor:l,className:"pkt-form-label",children:o}),r("input",{className:"pkt-form-input",id:l,...c,ref:d}),s]}));le.displayName="PktInput";const se=P.forwardRef(({children:o,className:l,iconName:s="user",openInNewTab:c=!1,skin:d="normal",href:n="#",external:v=!1,title:g},h)=>{const T=[l,"pkt-linkcard",d&&`pkt-linkcard--${d}`].filter(Boolean).join(" ");return p("a",{href:n,className:`pkt-linkcard pkt-link ${T}`,target:c?"_blank":"_self",rel:c?"noopener noreferrer":void 0,ref:h,children:[r(y,{className:"pkt-link__icon",name:s}),p("div",{className:"pkt-linkcard__content",children:[r("div",{className:`pkt-linkcard__title ${v?"pkt-link pkt-link--external":""}`,children:g}),r("div",{className:"pkt-linkcard__text",children:o})]})]})});se.displayName="PktLinkCard";const Ue=({children:o,skin:l="beige",title:s,...c})=>{const d=["pkt-messagebox",l&&`pkt-messagebox--${l}`].filter(Boolean).join(" ");return p("div",{...c,className:d,children:[r("div",{className:"pkt-messagebox__title",children:s}),r("div",{className:"pkt-messagebox__text",children:o})]})},ce=P.forwardRef(({id:o,name:l,label:s,value:c,...d},n)=>p("div",{className:"pkt-form-group",children:[r("input",{type:"radio",className:"pkt-form-check-input",id:o,name:l,value:c,ref:n,...d}),r("label",{className:"pkt-form-label",htmlFor:o,children:s})]}));ce.displayName="PktRadio";const Ge=({label:o,children:l})=>p(oe,{children:[r("p",{children:o}),r("div",{className:"pkt-form-group",children:l})]});var fe={exports:{}};/*!
|
|
27
|
+
Check the top-level render call using <`+r+">.")}return t}}function Ie(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=jt(t);if(De[r])return;De[r]=!0;var s="";e&&e._owner&&e._owner!==te.current&&(s=" It was passed a child from "+C(e._owner.type)+"."),A(e),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,s),A(null)}}function Ae(e,t){{if(typeof e!="object")return;if(q(e))for(var r=0;r<e.length;r++){var s=e[r];ae(s)&&Ie(s,t)}else if(ae(e))e._store&&(e._store.validated=!0);else if(e){var m=rt(e);if(typeof m=="function"&&m!==e.entries)for(var v=m.call(e),p;!(p=v.next()).done;)ae(p.value)&&Ie(p.value,t)}}}function St(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===h||t.$$typeof===j))r=t.propTypes;else return;if(r){var s=C(t);_t(r,e.props,"prop",s,e)}else if(t.PropTypes!==void 0&&!re){re=!0;var m=C(t);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",m||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ct(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var s=t[r];if(s!=="children"&&s!=="key"){A(e),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),A(null);break}}e.ref!==null&&(A(e),w("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}function We(e,t,r,s,m,v){{var p=ct(e);if(!p){var u="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(u+=" 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 P=xt(m);P?u+=P:u+=Fe();var b;e===null?b="null":q(e)?b="array":e!==void 0&&e.$$typeof===l?(b="<"+(C(e.type)||"Unknown")+" />",u=" Did you accidentally export a JSX literal instead of a component?"):b=typeof e,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",b,u)}var N=Tt(e,t,r,m,v);if(N==null)return N;if(p){var x=t.children;if(x!==void 0)if(s)if(q(x)){for(var W=0;W<x.length;W++)Ae(x[W],e);Object.freeze&&Object.freeze(x)}else w("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 Ae(x,e)}return e===c?Ct(N):St(N),N}}function Ot(e,t,r){return We(e,t,r,!0)}function Ft(e,t,r){return We(e,t,r,!1)}var Dt=Ft,It=Ot;M.Fragment=c,M.jsx=Dt,M.jsxs=It}()),M}process.env.NODE_ENV==="production"?z.exports=$e():z.exports=Le();var J=z.exports;const le=J.Fragment,a=J.jsx,d=J.jsxs,K={},ie='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>';function Be(o,l){return K[o]?Promise.resolve(K[o]):fetch(l+o+".svg").then(i=>i.ok?i.text():(console.error("Missing icon: "+l+o+".svg"),ie)).then(i=>(i!==ie&&(K[o]=i),i))}const y=({name:o,path:l,className:i="",...c})=>{const f="https://punkt-cdn.oslo.kommune.no/5.0/icons/",[n,_]=E.useState(null);return E.useEffect(()=>{if(!o)return;Be(o,l||f).then(h=>_(h))},[o,l,f]),n?a("span",{className:`pkt-icon ${i}`,dangerouslySetInnerHTML:{__html:n},...c}):null},Ve=E.forwardRef(({children:o,className:l,skin:i="info",closeAlert:c=!1,onClose:f,title:n,date:_,ariaLive:k="polite",...h},T)=>{const R=[l,"pkt-alert",i&&`pkt-alert--${i}`].filter(Boolean).join(" "),[j,S]=E.useState(!0),D=()=>{S(!1),f&&f()};return j?d("div",{...h,className:R,"aria-live":k,ref:T,children:[a(y,{className:"pkt-alert__icon",name:i==="info"?"alert-information":`alert-${i}`}),c&&a("div",{className:"pkt-alert__close",children:a("button",{type:"button",className:"pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only",tabIndex:0,"aria-label":"close",onClick:D,children:a(y,{name:"close",className:"pkt-btn__icon","aria-hidden":"true"})})}),n&&a("div",{className:"pkt-alert__title",children:n}),a("div",{className:"pkt-alert__text",children:o}),_&&d("div",{className:"pkt-alert__date",children:["Sist oppdatert: ",_]})]}):null}),se=E.forwardRef(({children:o,className:l,iconName:i="user",secondIconName:c="user",size:f="medium",skin:n="primary",type:_="button",variant:k="label-only",...h},T)=>{const R=[l,"pkt-btn",f&&`pkt-btn--${f}`,n&&`pkt-btn--${n}`,k&&`pkt-btn--${k}`].filter(Boolean).join(" ");return d("button",{...h,className:R,type:_,ref:T,children:[a(y,{className:"pkt-btn__icon",name:i}),a("span",{className:"pkt-btn__text",children:o}),k==="icons-right-and-left"&&a(y,{className:"pkt-btn__icon",name:c})]})});se.displayName="PktButton";const Ue=({columnOne:o,columnTwo:l,socialLinks:i})=>{var c,f;return a("footer",{className:"pkt-footer","data-mode":"dark",children:d("div",{className:"pkt-footer__container",children:[d("div",{className:"pkt-grid pkt-grid--rowgap-size-32 pkt-grid--gap-size-16",children:[d("div",{className:"pkt-footer__column pkt-cell pkt-cell--span12 pkt-cell--span4-laptop-up",children:[a("h2",{className:"pkt-footer__title",children:o.title}),d("ul",{className:"pkt-footer__list",children:[o.text&&a("li",{className:"pkt-footer__text",children:o.text}),(c=o.links)==null?void 0:c.map((n,_)=>a("li",{className:"pkt-footer__list-item",children:d("a",{className:`pkt-footer__link ${n.external?"pkt-link--external":""}`,href:n.href,target:n.openInNewTab?"_blank":"_self",rel:n.openInNewTab?"noopener noreferrer":void 0,children:[a(y,{className:"pkt-footer__link-icon",name:"chevron-right"}),n.text]})},`links-${_}`))]})]}),d("div",{className:"pkt-footer__column pkt-cell pkt-cell--span12 pkt-cell--span4-laptop-up",children:[a("h2",{className:"pkt-footer__title",children:l.title}),d("ul",{className:"pkt-footer__list",children:[l.text&&a("li",{className:"pkt-footer__text",children:l.text}),(f=l.links)==null?void 0:f.map((n,_)=>a("li",{className:"pkt-footer__list-item",children:d("a",{className:`pkt-footer__link ${n.external?"pkt-link--external":""}`,href:n.href,target:n.openInNewTab?"_blank":"_self",rel:n.openInNewTab?"noopener noreferrer":void 0,children:[a(y,{className:"pkt-footer__link-icon",name:"chevron-right"}),n.text]})},`links-${_}`))]})]}),d("div",{className:"pkt-footer__column pkt-cell pkt-cell--span12 pkt-cell--span4-laptop-up",children:[a("h2",{className:"pkt-footer__title",children:"Om nettstedet"}),d("ul",{className:"pkt-footer__list",children:[a("li",{className:"pkt-footer__list-item",children:d("a",{className:"pkt-footer__link",href:"https://www.oslo.kommune.no/personvern-og-informasjonskapsler/",children:[a(y,{className:"pkt-footer__link-icon",name:"chevron-right"}),"Personvern og informasjonskapsler"]})}),a("li",{className:"pkt-footer__list-item",children:d("a",{className:"pkt-footer__link",href:"https://www.oslo.kommune.no/tilgjengelighet/",children:[a(y,{className:"pkt-footer__link-icon",name:"chevron-right"}),"Tilgjengelighet"]})})]})]})]}),i&&d("div",{className:"pkt-footer__social","aria-label":"standard lenker",children:[a("div",{className:"pkt-footer__social-languages",children:i.filter(n=>n.language).map((n,_)=>a("div",{className:"pkt-footer__social-language",children:a("a",{href:n.href,"aria-label":`til ${n.language} versjon av nettsiden`,target:n.openInNewTab?"_blank":"_self",rel:n.openInNewTab?"noopener noreferrer":void 0,children:n.language})},`sociallinks-language-${_}`))}),a("div",{className:"pkt-footer__social-icons",children:i.filter(n=>n.iconName).map((n,_)=>a(E.Fragment,{children:a("a",{href:n.href,"aria-label":`til ${n.iconName}`,className:"pkt-footer__social-icon-link",target:n.openInNewTab?"_blank":"_self",rel:n.openInNewTab?"noopener noreferrer":void 0,children:a(y,{className:"pkt-footer__social-icon",name:n.iconName})})},`sociallinks-${_}`))})]})]})})},He=({links:o=[]})=>a("footer",{className:"pkt-footer-simple","data-mode":"dark",children:a("div",{className:"pkt-footer-simple__container",children:d("ul",{className:"pkt-footer-simple__list",children:[o.map((l,i)=>a("li",{className:"pkt-footer-simple__list-item",children:d("a",{className:`pkt-footer-simple__link ${l.external?" pkt-link--external":""}`,href:l.href,target:l.openInNewTab?"_blank":"_self",rel:l.openInNewTab?"noopener noreferrer":void 0,children:[a(y,{className:"pkt-footer-simple__link-icon",name:"chevron-right"}),l.text]})},i)),a("li",{className:"pkt-footer-simple__list-item",children:d("a",{className:"pkt-footer-simple__link",href:"https://www.oslo.kommune.no/personvern-og-informasjonskapsler/",children:[a(y,{className:"pkt-footer-simple__link-icon",name:"chevron-right"}),"Personvern og informasjonskapsler"]})}),a("li",{className:"pkt-footer-simple__list-item",children:d("a",{className:"pkt-footer-simple__link",href:"https://www.oslo.kommune.no/tilgjengelighet/",children:[a(y,{className:"pkt-footer-simple__link-icon",name:"chevron-right"}),"Tilgjengelighet"]})})]})})}),Ge=({className:o,logoLink:l="https://www.oslo.kommune.no/",isLoggedIn:i=!1,representing:c="",canChangeRepresentation:f=!1,showLogInButton:n=!0,onLogIn:_,onLogOut:k,onChangeRepresentation:h})=>{const T=[o,"pkt-header"].filter(Boolean).join(" ");return d("header",{id:"pkt-header",className:T,"aria-label":"Topp",children:[a("div",{className:"pkt-header__logo",children:a("a",{"aria-label":"Tilbake til forside",className:"pkt-header__logo-link",href:l,children:a(y,{name:"oslologo",className:"pkt-header__logo-svg","aria-hidden":"true"})})}),d("div",{className:"pkt-header__actions",children:[i&&f&&d("button",{className:"pkt-btn pkt-btn--secondary pkt-btn--icon-right","aria-label":`Bytt bruker fra ${c}`,onClick:h,children:[a(y,{name:"user",className:"pkt-btn__icon pkt-show-tablet-up"}),a("span",{className:"pkt-header__action-change pkt-hide pkt-show-tablet-up ml-size-15",children:"Endre"}),a("span",{className:"pkt-btn__text pkt-hide-tablet-up",children:"Endre"}),a("span",{className:"pkt-btn__text--representing pkt-hide pkt-show-tablet-up",children:c})]}),i&&!f&&d("div",{className:"pkt-header__action",children:[a("span",{className:"pkt-header__action-text",children:a("span",{className:"pkt-btn__text pkt-header__action-textrow text-row-inline pkt-truncate-text",children:c})}),a(y,{className:"pkt-header__action-icon pkt-show-phablet-up",name:"user"})]}),n&&i&&d("button",{className:"pkt-btn pkt-btn--tertiary pkt-btn--icon-right","aria-label":"Logg ut",onClick:k,children:[a(y,{className:"pkt-btn__icon pkt-show-tablet-up",name:"exit"}),a("span",{className:"pkt-btn__text",children:"Logg ut"})]}),n&&!i&&d("button",{className:"pkt-btn pkt-btn--tertiary pkt-btn--icon-right","aria-label":"Logg inn",onClick:_,children:[a(y,{className:"pkt-btn__icon",name:"user"}),a("span",{className:"pkt-btn__text",children:"Logg inn"})]})]})]})},ce=E.forwardRef(({label:o,id:l,children:i,...c},f)=>d("div",{className:"pkt-form-group",children:[a("label",{htmlFor:l,className:"pkt-form-label",children:o}),a("input",{className:"pkt-form-input",id:l,...c,ref:f}),i]}));ce.displayName="PktInput";const ue=E.forwardRef(({children:o,className:l,iconName:i="user",openInNewTab:c=!1,skin:f="normal",href:n="#",external:_=!1,title:k},h)=>{const T=[l,"pkt-linkcard",f&&`pkt-linkcard--${f}`].filter(Boolean).join(" ");return d("a",{href:n,className:`pkt-linkcard pkt-link ${T}`,target:c?"_blank":"_self",rel:c?"noopener noreferrer":void 0,ref:h,children:[a(y,{className:"pkt-link__icon",name:i}),d("div",{className:"pkt-linkcard__content",children:[a("div",{className:`pkt-linkcard__title ${_?"pkt-link pkt-link--external":""}`,children:k}),a("div",{className:"pkt-linkcard__text",children:o})]})]})});ue.displayName="PktLinkCard";const ze=({children:o,skin:l="beige",title:i,...c})=>{const f=["pkt-messagebox",l&&`pkt-messagebox--${l}`].filter(Boolean).join(" ");return d("div",{...c,className:f,children:[a("div",{className:"pkt-messagebox__title",children:i}),a("div",{className:"pkt-messagebox__text",children:o})]})},fe=E.forwardRef(({id:o,name:l,label:i,value:c,...f},n)=>d("div",{className:"pkt-form-group",children:[a("input",{type:"radio",className:"pkt-form-check-input",id:o,name:l,value:c,ref:n,...f}),a("label",{className:"pkt-form-label",htmlFor:o,children:i})]}));fe.displayName="PktRadio";const Je=({label:o,children:l})=>d(le,{children:[a("p",{children:o}),a("div",{className:"pkt-form-group",children:l})]});var pe={exports:{}};/*!
|
|
28
28
|
Copyright (c) 2018 Jed Watson.
|
|
29
29
|
Licensed under the MIT License (MIT), see
|
|
30
30
|
http://jedwatson.github.io/classnames
|
|
31
|
-
*/(function(o){(function(){var l={}.hasOwnProperty;function
|
|
31
|
+
*/(function(o){(function(){var l={}.hasOwnProperty;function i(){for(var c=[],f=0;f<arguments.length;f++){var n=arguments[f];if(n){var _=typeof n;if(_==="string"||_==="number")c.push(n);else if(Array.isArray(n)){if(n.length){var k=i.apply(null,n);k&&c.push(k)}}else if(_==="object"){if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]")){c.push(n.toString());continue}for(var h in n)l.call(n,h)&&n[h]&&c.push(h)}}}return c.join(" ")}o.exports?(i.default=i,o.exports=i):window.classNames=i})()})(pe);var Ke=pe.exports;const Xe=Me(Ke),Ze=({isResponsive:o,children:l})=>o?a("div",{className:"pkt-table-container",children:l}):a(le,{children:l}),Qe=({isResponsive:o,modifiers:{info:l=!1,success:i=!1,strong:c=!1,shadow:f=!1}={},children:n})=>a(Ze,{isResponsive:o,children:a("table",{className:Xe("pkt-table",{"pkt-table--info":l,"pkt-table--success":i,"pkt-table--strong":c,"pkt-table--shadow":f}),children:n})}),qe=({children:o})=>a("td",{className:"pkt-table__th",children:o}),et=({children:o})=>a("th",{className:"pkt-table__th",children:o}),de=E.forwardRef(({id:o,label:l,...i},c)=>d("div",{className:"pkt-form-group",children:[a("label",{htmlFor:o,className:"pkt-form-label",children:l}),a("textarea",{className:"pkt-form-textarea",id:o,ref:c,...i})]}));de.displayName="PktTextarea",g.PktAlert=Ve,g.PktButton=se,g.PktFooter=Ue,g.PktFooterSimple=He,g.PktHeader=Ge,g.PktInput=ce,g.PktLinkCard=ue,g.PktMessagebox=ze,g.PktRadio=fe,g.PktRadioGroup=Je,g.PktTable=Qe,g.PktTableData=qe,g.PktTableHeader=et,g.PktTextarea=de,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.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": "^5.0.0",
|
|
35
|
+
"@oslokommune/punkt-css": "^5.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": "daf55cf54c75d6f3a0e1f80f76c23cd6b0da75ee"
|
|
94
94
|
}
|
|
@@ -39,9 +39,10 @@ export const PktAlert = forwardRef(
|
|
|
39
39
|
|
|
40
40
|
return isDisplayed ? (
|
|
41
41
|
<div {...props} className={classes} aria-live={ariaLive} ref={ref}>
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
<PktIcon
|
|
43
|
+
className="pkt-alert__icon"
|
|
44
|
+
name={skin === 'info' ? 'alert-information' : `alert-${skin}`}
|
|
45
|
+
/>
|
|
45
46
|
|
|
46
47
|
{closeAlert && (
|
|
47
48
|
<div className="pkt-alert__close">
|
|
@@ -98,10 +98,16 @@ export const PktFooter: React.FC<IPktFooter> = ({ columnOne, columnTwo, socialLi
|
|
|
98
98
|
{socialLinks
|
|
99
99
|
.filter((link) => link.language)
|
|
100
100
|
.map((link, index) => (
|
|
101
|
-
<div
|
|
102
|
-
|
|
101
|
+
<div
|
|
102
|
+
key={`sociallinks-language-${index}`}
|
|
103
|
+
className="pkt-footer__social-language"
|
|
104
|
+
>
|
|
105
|
+
<a
|
|
106
|
+
href={link.href}
|
|
107
|
+
aria-label={`til ${link.language} versjon av nettsiden`}
|
|
103
108
|
target={link.openInNewTab ? '_blank' : '_self'}
|
|
104
|
-
rel={link.openInNewTab ? 'noopener noreferrer' : undefined}
|
|
109
|
+
rel={link.openInNewTab ? 'noopener noreferrer' : undefined}
|
|
110
|
+
>
|
|
105
111
|
{link.language}
|
|
106
112
|
</a>
|
|
107
113
|
</div>
|
|
@@ -119,9 +125,7 @@ export const PktFooter: React.FC<IPktFooter> = ({ columnOne, columnTwo, socialLi
|
|
|
119
125
|
target={link.openInNewTab ? '_blank' : '_self'}
|
|
120
126
|
rel={link.openInNewTab ? 'noopener noreferrer' : undefined}
|
|
121
127
|
>
|
|
122
|
-
<
|
|
123
|
-
<use href={`#${link.iconName}`}></use>
|
|
124
|
-
</svg>
|
|
128
|
+
<PktIcon className="pkt-footer__social-icon" name={link.iconName} />
|
|
125
129
|
</a>
|
|
126
130
|
</React.Fragment>
|
|
127
131
|
))}
|
|
@@ -29,12 +29,7 @@ export const PktHeader: React.FC<HeaderProps> = ({
|
|
|
29
29
|
<header id="pkt-header" className={classNames} aria-label="Topp">
|
|
30
30
|
<div className="pkt-header__logo">
|
|
31
31
|
<a aria-label="Tilbake til forside" className="pkt-header__logo-link" href={logoLink}>
|
|
32
|
-
<PktIcon
|
|
33
|
-
name="oslologo"
|
|
34
|
-
className="pkt-header__logo-svg"
|
|
35
|
-
viewBox="0 0 60 31"
|
|
36
|
-
aria-hidden="true"
|
|
37
|
-
/>
|
|
32
|
+
<PktIcon name="oslologo" className="pkt-header__logo-svg" aria-hidden="true" />
|
|
38
33
|
</a>
|
|
39
34
|
</div>
|
|
40
35
|
<div className="pkt-header__actions">
|
|
@@ -64,9 +59,7 @@ export const PktHeader: React.FC<HeaderProps> = ({
|
|
|
64
59
|
{representing}
|
|
65
60
|
</span>
|
|
66
61
|
</span>
|
|
67
|
-
<
|
|
68
|
-
<PktIcon name="user" />
|
|
69
|
-
</span>
|
|
62
|
+
<PktIcon className="pkt-header__action-icon pkt-show-phablet-up" name="user" />
|
|
70
63
|
</div>
|
|
71
64
|
)}
|
|
72
65
|
|
|
@@ -1,21 +1,62 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
// Cache is a dictionary of promises that each resolves to an svg icon
|
|
4
|
+
const iconCache: { [name: string]: string } = {}
|
|
5
|
+
|
|
6
|
+
const errorSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>'
|
|
7
|
+
|
|
8
|
+
function getIcon(name: string, path: string): Promise<string> {
|
|
9
|
+
// Download and cache icon if not in cache
|
|
10
|
+
if (!iconCache[name]) {
|
|
11
|
+
return fetch(path + name + '.svg')
|
|
12
|
+
.then((response) => {
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
console.error('Missing icon: ' + path + name + '.svg')
|
|
15
|
+
return errorSvg
|
|
16
|
+
}
|
|
17
|
+
return response.text()
|
|
18
|
+
})
|
|
19
|
+
.then((text) => {
|
|
20
|
+
// Only cache the icon if it isn't the errorSvg
|
|
21
|
+
if (text !== errorSvg) {
|
|
22
|
+
iconCache[name] = text
|
|
23
|
+
}
|
|
24
|
+
return text
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Return the svg promise
|
|
29
|
+
return Promise.resolve(iconCache[name])
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface PktIconProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
33
|
+
name?: string // name is now optional
|
|
34
|
+
path?: string
|
|
6
35
|
}
|
|
7
36
|
|
|
8
|
-
export const PktIcon: React.FC<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
37
|
+
export const PktIcon: React.FC<PktIconProps> = ({ name, path, className = '', ...props }) => {
|
|
38
|
+
const defaultSvgPath = 'https://punkt-cdn.oslo.kommune.no/latest/icons/'
|
|
39
|
+
const [innerHtml, setInnerHtml] = useState<string | null>(null)
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!name) {
|
|
43
|
+
// If name is not provided, don't try to fetch an icon.
|
|
44
|
+
// You could set innerHtml to a default icon or placeholder here.
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
const iconPath = path || defaultSvgPath
|
|
48
|
+
getIcon(name, iconPath).then((svg) => setInnerHtml(svg))
|
|
49
|
+
}, [name, path, defaultSvgPath])
|
|
50
|
+
|
|
51
|
+
if (!innerHtml) return null
|
|
15
52
|
|
|
16
53
|
return (
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
54
|
+
<span
|
|
55
|
+
className={`pkt-icon ${className}`}
|
|
56
|
+
dangerouslySetInnerHTML={{ __html: innerHtml }}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
20
59
|
)
|
|
21
60
|
}
|
|
61
|
+
|
|
62
|
+
export default PktIcon
|