@oslokommune/punkt-react 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/alert/Alert.d.ts +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/punkt-react.es.js +299 -265
- package/dist/punkt-react.umd.js +11 -11
- package/package.json +6 -6
- package/src/components/alert/Alert.tsx +61 -0
- package/src/components/icon/Icon.tsx +1 -1
- package/src/components/index.ts +1 -0
package/dist/punkt-react.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(g,N){typeof exports=="object"&&typeof module<"u"?N(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],N):(g=typeof globalThis<"u"?globalThis:g||self,N(g["punkt-react"]={},g.React))})(this,function(g,N){"use strict";var W={},Fe={get exports(){return W},set exports(i){W=i}},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 ae;function Ae(){if(ae)return Y;ae=1;var
|
|
9
|
+
*/var ae;function Ae(){if(ae)return Y;ae=1;var i=N,f=Symbol.for("react.element"),d=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,v=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function k(_,m,w){var y,T={},O=null,V=null;w!==void 0&&(O=""+w),m.key!==void 0&&(O=""+m.key),m.ref!==void 0&&(V=m.ref);for(y in m)l.call(m,y)&&!u.hasOwnProperty(y)&&(T[y]=m[y]);if(_&&_.defaultProps)for(y in m=_.defaultProps,m)T[y]===void 0&&(T[y]=m[y]);return{$$typeof:f,type:_,key:O,ref:V,props:T,_owner:v.current}}return Y.Fragment=d,Y.jsx=k,Y.jsxs=k,Y}var $={};/**
|
|
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 ne;function Ie(){return ne||(ne=1,process.env.NODE_ENV!=="production"&&function(){var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),h=o.length-1,b=
|
|
21
|
-
`+o[h].replace(" at new "," at ");return e.displayName&&
|
|
17
|
+
*/var ne;function Ie(){return ne||(ne=1,process.env.NODE_ENV!=="production"&&function(){var i=N,f=Symbol.for("react.element"),d=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),k=Symbol.for("react.provider"),_=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),ce=Symbol.iterator,Je="@@iterator";function ze(e){if(e===null||typeof e!="object")return null;var r=ce&&e[ce]||e[Je];return typeof r=="function"?r:null}var F=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),a=1;a<r;a++)t[a-1]=arguments[a];Ke("error",e,t)}}function Ke(e,r,t){{var a=F.ReactDebugCurrentFrame,c=a.getStackAddendum();c!==""&&(r+="%s",t=t.concat([c]));var p=t.map(function(s){return String(s)});p.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,p)}}var qe=!1,Xe=!1,Ze=!1,Qe=!1,er=!1,ue;ue=Symbol.for("react.module.reference");function rr(e){return!!(typeof e=="string"||typeof e=="function"||e===l||e===u||er||e===v||e===w||e===y||Qe||e===V||qe||Xe||Ze||typeof e=="object"&&e!==null&&(e.$$typeof===O||e.$$typeof===T||e.$$typeof===k||e.$$typeof===_||e.$$typeof===m||e.$$typeof===ue||e.getModuleId!==void 0))}function tr(e,r,t){var a=e.displayName;if(a)return a;var c=r.displayName||r.name||"";return c!==""?t+"("+c+")":t}function fe(e){return e.displayName||"Context"}function C(e){if(e==null)return null;if(typeof e.tag=="number"&&R("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 l:return"Fragment";case d:return"Portal";case u:return"Profiler";case v:return"StrictMode";case w:return"Suspense";case y:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case _:var r=e;return fe(r)+".Consumer";case k:var t=e;return fe(t._context)+".Provider";case m:return tr(e,e.render,"ForwardRef");case T:var a=e.displayName||null;return a!==null?a:C(e.type)||"Memo";case O:{var c=e,p=c._payload,s=c._init;try{return C(s(p))}catch{return null}}}return null}var D=Object.assign,L=0,de,pe,ve,me,he,be,_e;function ke(){}ke.__reactDisabledLog=!0;function ar(){{if(L===0){de=console.log,pe=console.info,ve=console.warn,me=console.error,he=console.group,be=console.groupCollapsed,_e=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ke,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}L++}}function nr(){{if(L--,L===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},e,{value:de}),info:D({},e,{value:pe}),warn:D({},e,{value:ve}),error:D({},e,{value:me}),group:D({},e,{value:he}),groupCollapsed:D({},e,{value:be}),groupEnd:D({},e,{value:_e})})}L<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var K=F.ReactCurrentDispatcher,q;function B(e,r,t){{if(q===void 0)try{throw Error()}catch(c){var a=c.stack.trim().match(/\n( *(at )?)/);q=a&&a[1]||""}return`
|
|
18
|
+
`+q+e}}var X=!1,U;{var ir=typeof WeakMap=="function"?WeakMap:Map;U=new ir}function ge(e,r){if(!e||X)return"";{var t=U.get(e);if(t!==void 0)return t}var a;X=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var p;p=K.current,K.current=null,ar();try{if(r){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(j){a=j}Reflect.construct(e,[],s)}else{try{s.call()}catch(j){a=j}e.call(s.prototype)}}else{try{throw Error()}catch(j){a=j}e()}}catch(j){if(j&&a&&typeof j.stack=="string"){for(var o=j.stack.split(`
|
|
19
|
+
`),E=a.stack.split(`
|
|
20
|
+
`),h=o.length-1,b=E.length-1;h>=1&&b>=0&&o[h]!==E[b];)b--;for(;h>=1&&b>=0;h--,b--)if(o[h]!==E[b]){if(h!==1||b!==1)do if(h--,b--,b<0||o[h]!==E[b]){var x=`
|
|
21
|
+
`+o[h].replace(" at new "," at ");return e.displayName&&x.includes("<anonymous>")&&(x=x.replace("<anonymous>",e.displayName)),typeof e=="function"&&U.set(e,x),x}while(h>=1&&b>=0);break}}}finally{X=!1,K.current=p,nr(),Error.prepareStackTrace=c}var I=e?e.displayName||e.name:"",De=I?B(I):"";return typeof e=="function"&&U.set(e,De),De}function or(e,r,t){return ge(e,!1)}function sr(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function G(e,r,t){if(e==null)return"";if(typeof e=="function")return ge(e,sr(e));if(typeof e=="string")return B(e);switch(e){case w:return B("Suspense");case y:return B("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case m:return or(e.render);case T:return G(e.type,r,t);case O:{var a=e,c=a._payload,p=a._init;try{return G(p(c),r,t)}catch{}}}return""}var H=Object.prototype.hasOwnProperty,ye={},Re=F.ReactDebugCurrentFrame;function J(e){if(e){var r=e._owner,t=G(e.type,e._source,r?r.type:null);Re.setExtraStackFrame(t)}else Re.setExtraStackFrame(null)}function lr(e,r,t,a,c){{var p=Function.call.bind(H);for(var s in e)if(p(e,s)){var o=void 0;try{if(typeof e[s]!="function"){var E=Error((a||"React class")+": "+t+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw E.name="Invariant Violation",E}o=e[s](r,s,a,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(h){o=h}o&&!(o instanceof Error)&&(J(c),R("%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).",a||"React class",t,s,typeof o),J(null)),o instanceof Error&&!(o.message in ye)&&(ye[o.message]=!0,J(c),R("Failed %s type: %s",t,o.message),J(null))}}}var cr=Array.isArray;function Z(e){return cr(e)}function ur(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function fr(e){try{return Ee(e),!1}catch{return!0}}function Ee(e){return""+e}function Pe(e){if(fr(e))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ur(e)),Ee(e)}var M=F.ReactCurrentOwner,dr={key:!0,ref:!0,__self:!0,__source:!0},Te,we,Q;Q={};function pr(e){if(H.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function vr(e){if(H.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function mr(e,r){if(typeof e.ref=="string"&&M.current&&r&&M.current.stateNode!==r){var t=C(M.current.type);Q[t]||(R('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(M.current.type),e.ref),Q[t]=!0)}}function hr(e,r){{var t=function(){Te||(Te=!0,R("%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)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function br(e,r){{var t=function(){we||(we=!0,R("%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)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var _r=function(e,r,t,a,c,p,s){var o={$$typeof:f,type:e,key:r,ref:t,props:s,_owner:p};return o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(o,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(o,"_source",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o};function kr(e,r,t,a,c){{var p,s={},o=null,E=null;t!==void 0&&(Pe(t),o=""+t),vr(r)&&(Pe(r.key),o=""+r.key),pr(r)&&(E=r.ref,mr(r,c));for(p in r)H.call(r,p)&&!dr.hasOwnProperty(p)&&(s[p]=r[p]);if(e&&e.defaultProps){var h=e.defaultProps;for(p in h)s[p]===void 0&&(s[p]=h[p])}if(o||E){var b=typeof e=="function"?e.displayName||e.name||"Unknown":e;o&&hr(s,b),E&&br(s,b)}return _r(e,o,E,c,a,M.current,s)}}var ee=F.ReactCurrentOwner,xe=F.ReactDebugCurrentFrame;function A(e){if(e){var r=e._owner,t=G(e.type,e._source,r?r.type:null);xe.setExtraStackFrame(t)}else xe.setExtraStackFrame(null)}var re;re=!1;function te(e){return typeof e=="object"&&e!==null&&e.$$typeof===f}function Ne(){{if(ee.current){var e=C(ee.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 gr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+r+":"+t+"."}return""}}var Se={};function
|
|
25
|
+
Check your code at `+r+":"+t+"."}return""}}var Se={};function yr(e){{var r=Ne();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+t+">.")}return r}}function
|
|
27
|
+
Check the top-level render call using <`+t+">.")}return r}}function Oe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=yr(r);if(Se[t])return;Se[t]=!0;var a="";e&&e._owner&&e._owner!==ee.current&&(a=" It was passed a child from "+C(e._owner.type)+"."),A(e),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,a),A(null)}}function Ce(e,r){{if(typeof e!="object")return;if(Z(e))for(var t=0;t<e.length;t++){var a=e[t];te(a)&&Oe(a,r)}else if(te(e))e._store&&(e._store.validated=!0);else if(e){var c=ze(e);if(typeof c=="function"&&c!==e.entries)for(var p=c.call(e),s;!(s=p.next()).done;)te(s.value)&&Oe(s.value,r)}}}function Rr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===m||r.$$typeof===T))t=r.propTypes;else return;if(t){var a=C(r);lr(t,e.props,"prop",a,e)}else if(r.PropTypes!==void 0&&!re){re=!0;var c=C(r);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",c||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Er(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var a=r[t];if(a!=="children"&&a!=="key"){A(e),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",a),A(null);break}}e.ref!==null&&(A(e),R("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}function je(e,r,t,a,c,p){{var s=rr(e);if(!s){var o="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(o+=" 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 E=gr(c);E?o+=E:o+=Ne();var h;e===null?h="null":Z(e)?h="array":e!==void 0&&e.$$typeof===f?(h="<"+(C(e.type)||"Unknown")+" />",o=" Did you accidentally export a JSX literal instead of a component?"):h=typeof e,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",h,o)}var b=kr(e,r,t,c,p);if(b==null)return b;if(s){var x=r.children;if(x!==void 0)if(a)if(Z(x)){for(var I=0;I<x.length;I++)Ce(x[I],e);Object.freeze&&Object.freeze(x)}else R("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 Ce(x,e)}return e===l?Er(b):Rr(b),b}}function Pr(e,r,t){return je(e,r,t,!0)}function Tr(e,r,t){return je(e,r,t,!1)}var wr=Tr,xr=Pr;$.Fragment=l,$.jsx=wr,$.jsxs=xr}()),$}(function(i){process.env.NODE_ENV==="production"?i.exports=Ae():i.exports=Ie()})(Fe);const ie=W.Fragment,n=W.jsx,P=W.jsxs,S=({className:i,name:f,viewBox:d="0 0 32 32",...l})=>{const v=[i].filter(Boolean).join(" ");return n("svg",{...l,className:v,viewBox:d,children:n("use",{href:`#${f}`})})},We=({children:i,className:f,skin:d="info",closeAlert:l=!1,onClose:v,title:u,date:k,ariaLive:_="polite",...m})=>{const w=[f,"pkt-alert",d&&`pkt-alert--${d}`].filter(Boolean).join(" "),[y,T]=N.useState(!0),O=()=>{T(!1),v&&v()};return y?P("div",{...m,className:w,"aria-live":_,children:[n("div",{className:"pkt-alert__icon",children:n(S,{name:d==="info"?"alert-information":`alert-${d}`})}),l&&n("div",{className:"pkt-alert__close",children:n("button",{className:"pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only",tabIndex:0,"aria-label":"close",onClick:O,children:n(S,{name:"close",className:"pkt-btn__icon","aria-hidden":"true"})})}),u&&n("div",{className:"pkt-alert__title",children:u}),n("div",{className:"pkt-alert__text",children:i}),k&&P("div",{className:"pkt-alert__date",children:["Sist oppdatert: ",k]})]}):null},Ye=({children:i,className:f,iconName:d="user",secondIconName:l="user",size:v="medium",skin:u="primary",type:k="button",variant:_="label-only",...m})=>{const w=[f,"pkt-btn",v&&`pkt-btn--${v}`,u&&`pkt-btn--${u}`,_&&`pkt-btn--${_}`].filter(Boolean).join(" ");return P("button",{...m,className:w,type:k,children:[n(S,{className:"pkt-btn__icon",name:d}),n("span",{className:"pkt-btn__text",children:i}),_==="icons-right-and-left"&&n(S,{className:"pkt-btn__icon",name:l})]})},$e=({children:i,className:f,logoLink:d="https://www.oslo.kommune.no/",isLoggedIn:l=!1,representing:v="",canChangeRepresentation:u=!1,showLogInButton:k=!0,onLogIn:_,onLogOut:m,onChangeRepresentation:w,...y})=>{const T=[f,"pkt-header"].filter(Boolean).join(" ");return P("header",{id:"pkt-header",className:T,"aria-label":"Topp",children:[n("div",{className:"pkt-header__logo",children:n("a",{"aria-label":"Tilbake til forside",className:"pkt-header__logo-link",href:d,children:n(S,{name:"oslologo",className:"pkt-header__logo-svg",viewBox:"0 0 60 31","aria-hidden":"true"})})}),P("div",{className:"pkt-header__actions",children:[l&&u&&P("button",{className:"pkt-btn pkt-btn--secondary pkt-btn--icon-right","aria-label":`Bytt bruker fra ${v}`,onClick:w,children:[n(S,{name:"user",className:"pkt-btn__icon pkt-show-tablet-up"}),n("span",{className:"pkt-header__action-change pkt-hide pkt-show-tablet-up ml-size-15",children:"Endre"}),n("span",{className:"pkt-btn__text pkt-hide-tablet-up",children:"Endre"}),n("span",{className:"pkt-btn__text--representing pkt-hide pkt-show-tablet-up",children:v})]}),l&&!u&&P("div",{className:"pkt-header__action",children:[n("span",{className:"pkt-header__action-text",children:n("span",{className:"pkt-btn__text pkt-header__action-textrow text-row-inline truncate-text",children:v})}),n("span",{className:"pkt-header__action-icon pkt-show-phablet-up",children:n(S,{name:"user"})})]}),k&&l&&P("button",{className:"pkt-btn pkt-btn--tertiary pkt-btn--icon-right","aria-label":"Logg ut",onClick:m,children:[n(S,{className:"pkt-btn__icon pkt-show-tablet-up",name:"exit"}),n("span",{className:"pkt-btn__text",children:"Logg ut"})]}),k&&!l&&P("button",{className:"pkt-btn pkt-btn--tertiary pkt-btn--icon-right","aria-label":"Logg inn",onClick:_,children:[n(S,{className:"pkt-btn__icon",name:"user"}),n("span",{className:"pkt-btn__text",children:"Logg inn"})]})]})]})},oe=N.forwardRef(({label:i,id:f,children:d,...l},v)=>P("div",{className:"pkt-form-group",children:[n("label",{htmlFor:f,className:"pkt-form-label",children:i}),n("input",{className:"pkt-form-input",id:f,...l,ref:v}),d]}));oe.displayName="PktInput";const se=N.forwardRef(({id:i,label:f,...d},l)=>P("div",{className:"pkt-form-group",children:[n("label",{htmlFor:i,className:"pkt-form-label",children:f}),n("textarea",{className:"pkt-form-textarea",id:i,ref:l,...d})]}));se.displayName="PktTextarea";const le=N.forwardRef(({id:i,name:f,label:d,value:l,...v},u)=>P("div",{className:"pkt-form-group",children:[n("input",{type:"radio",className:"pkt-form-check-input",id:i,name:f,value:l,ref:u,...v}),n("label",{className:"pkt-form-label",htmlFor:i,children:d})]}));le.displayName="PktRadio";const Le=({label:i,children:f})=>P(ie,{children:[n("p",{children:i}),n("div",{className:"pkt-form-group",children:f})]});var z={},Me={get exports(){return z},set exports(i){z=i}};/*!
|
|
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(
|
|
31
|
+
*/(function(i){(function(){var f={}.hasOwnProperty;function d(){for(var l=[],v=0;v<arguments.length;v++){var u=arguments[v];if(u){var k=typeof u;if(k==="string"||k==="number")l.push(u);else if(Array.isArray(u)){if(u.length){var _=d.apply(null,u);_&&l.push(_)}}else if(k==="object"){if(u.toString!==Object.prototype.toString&&!u.toString.toString().includes("[native code]")){l.push(u.toString());continue}for(var m in u)f.call(u,m)&&u[m]&&l.push(m)}}}return l.join(" ")}i.exports?(d.default=d,i.exports=d):window.classNames=d})()})(Me);const Ve=z,Be=({isResponsive:i,children:f})=>i?n("div",{className:"pkt-table-container",children:f}):n(ie,{children:f}),Ue=({isResponsive:i,modifiers:{info:f=!1,success:d=!1,strong:l=!1,shadow:v=!1}={},children:u})=>n(Be,{isResponsive:i,children:n("table",{className:Ve("pkt-table",{"pkt-table--info":f,"pkt-table--success":d,"pkt-table--strong":l,"pkt-table--shadow":v}),children:u})}),Ge=({children:i})=>n("td",{className:"pkt-table__th",children:i}),He=({children:i})=>n("th",{className:"pkt-table__th",children:i});g.PktAlert=We,g.PktButton=Ye,g.PktHeader=$e,g.PktInput=oe,g.PktRadio=le,g.PktRadioGroup=Le,g.PktTable=Ue,g.PktTableData=Ge,g.PktTableHeader=He,g.PktTextarea=se,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": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
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",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"preview": "vite preview --outDir dist-app"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@oslokommune/punkt-assets": "^2.0.
|
|
34
|
-
"@oslokommune/punkt-css": "^2.0.
|
|
33
|
+
"@oslokommune/punkt-assets": "^2.0.4",
|
|
34
|
+
"@oslokommune/punkt-css": "^2.0.4",
|
|
35
35
|
"@testing-library/react": "^14.0.0",
|
|
36
36
|
"@types/jest": "^29.4.0",
|
|
37
37
|
"@types/node": "^18.14.1",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"vite-plugin-dts": "^2.0.2"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@oslokommune/punkt-assets": ">=
|
|
54
|
-
"@oslokommune/punkt-css": ">=
|
|
53
|
+
"@oslokommune/punkt-assets": ">=3.0.0",
|
|
54
|
+
"@oslokommune/punkt-css": ">=3.0.0",
|
|
55
55
|
"react": ">=18.0.0",
|
|
56
56
|
"react-dom": ">=18.0.0"
|
|
57
57
|
},
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
81
81
|
},
|
|
82
82
|
"license": "MIT",
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "035f27105ef83f6e175d996e4cd4e09d85fd9a7e"
|
|
84
84
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { PktIcon } from '../icon/Icon'
|
|
3
|
+
|
|
4
|
+
export interface IPktAlert extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
skin?: 'error' | 'success' | 'warning' | 'info'
|
|
6
|
+
closeAlert?: boolean
|
|
7
|
+
onClose?: () => void
|
|
8
|
+
title?: string
|
|
9
|
+
date?: string
|
|
10
|
+
ariaLive?: 'off' | 'polite' | 'assertive'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const PktAlert: React.FC<IPktAlert> = ({
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
skin = 'info',
|
|
17
|
+
closeAlert = false,
|
|
18
|
+
onClose,
|
|
19
|
+
title,
|
|
20
|
+
date,
|
|
21
|
+
ariaLive = 'polite',
|
|
22
|
+
...props
|
|
23
|
+
}) => {
|
|
24
|
+
const classes = [className, 'pkt-alert', skin && `pkt-alert--${skin}`].filter(Boolean).join(' ')
|
|
25
|
+
|
|
26
|
+
const [isDisplayed, setIsDisplayed] = useState(true)
|
|
27
|
+
|
|
28
|
+
const handleClose = () => {
|
|
29
|
+
setIsDisplayed(false)
|
|
30
|
+
if (onClose) {
|
|
31
|
+
onClose()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return isDisplayed ? (
|
|
36
|
+
<div {...props} className={classes} aria-live={ariaLive}>
|
|
37
|
+
<div className="pkt-alert__icon">
|
|
38
|
+
<PktIcon name={skin === 'info' ? 'alert-information' : `alert-${skin}`} />
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
{closeAlert && (
|
|
42
|
+
<div className="pkt-alert__close">
|
|
43
|
+
<button
|
|
44
|
+
className="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
45
|
+
tabIndex={0}
|
|
46
|
+
aria-label="close"
|
|
47
|
+
onClick={handleClose}
|
|
48
|
+
>
|
|
49
|
+
<PktIcon name="close" className="pkt-btn__icon" aria-hidden="true" />
|
|
50
|
+
</button>
|
|
51
|
+
</div>
|
|
52
|
+
)}
|
|
53
|
+
|
|
54
|
+
{title && <div className="pkt-alert__title">{title}</div>}
|
|
55
|
+
|
|
56
|
+
<div className="pkt-alert__text">{children}</div>
|
|
57
|
+
|
|
58
|
+
{date && <div className="pkt-alert__date">Sist oppdatert: {date}</div>}
|
|
59
|
+
</div>
|
|
60
|
+
) : null
|
|
61
|
+
}
|
|
@@ -11,7 +11,7 @@ export const PktIcon: React.FC<IPktIcon> = ({
|
|
|
11
11
|
viewBox = '0 0 32 32',
|
|
12
12
|
...props
|
|
13
13
|
}) => {
|
|
14
|
-
const classes = [className
|
|
14
|
+
const classes = [className].filter(Boolean).join(' ')
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<svg {...props} className={classes} viewBox={viewBox}>
|
package/src/components/index.ts
CHANGED