@oslokommune/punkt-react 11.9.0 → 11.9.2

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 CHANGED
@@ -5,6 +5,24 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [11.9.1](https://github.com/oslokommune/punkt/compare/11.9.0...11.9.1) (2024-03-12)
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+ Ingen
12
+
13
+ ### Features
14
+ Ingen
15
+
16
+ ### Bug Fixes
17
+ Ingen
18
+
19
+ ### Chores
20
+ * Ny modus for Alert (#1581). Kode: PÅSKEFIGUR
21
+
22
+
23
+ ---
24
+
25
+
8
26
  ## [11.9.0](https://github.com/oslokommune/punkt/compare/11.8.2...11.9.0) (2024-03-11)
9
27
 
10
28
  ### ⚠ BREAKING CHANGES
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  export interface IPktAlert extends React.HTMLAttributes<HTMLDivElement> {
3
- skin?: 'error' | 'success' | 'warning' | 'info';
3
+ skin?: 'error' | 'success' | 'warning' | 'info' | '🐣';
4
4
  closeAlert?: boolean;
5
5
  onClose?: () => void;
6
6
  title?: string;
@@ -669,22 +669,11 @@ const Ue = {}, bn = async (e, n) => {
669
669
  compact: p = !1,
670
670
  ...u
671
671
  }, d) => {
672
- const k = [
673
- n,
674
- "pkt-alert",
675
- a && `pkt-alert--${a}`,
676
- p && "pkt-alert--compact"
677
- ].filter(Boolean).join(" "), [v, R] = le(!0), x = () => {
672
+ const k = [n, "pkt-alert", a && `pkt-alert--${a}`, p && "pkt-alert--compact"].filter(Boolean).join(" "), [v, R] = le(!0), x = () => {
678
673
  R(!1), r && r();
679
674
  };
680
675
  return v ? /* @__PURE__ */ h("div", { ...u, className: k, "aria-live": c, ref: d, children: [
681
- /* @__PURE__ */ i(
682
- E,
683
- {
684
- className: "pkt-alert__icon",
685
- name: a === "info" ? "alert-information" : `alert-${a}`
686
- }
687
- ),
676
+ a === "🐣" ? /* @__PURE__ */ i("span", { className: "pkt-icon pkt-alert__icon", children: "🐣" }) : /* @__PURE__ */ i(E, { className: "pkt-alert__icon", name: a === "info" ? "alert-information" : `alert-${a}` }),
688
677
  l && /* @__PURE__ */ i("div", { className: "pkt-alert__close", children: /* @__PURE__ */ i(
689
678
  "button",
690
679
  {
@@ -24,7 +24,7 @@ Check the render method of \``+t+"`."}return""}}function _r(t){{if(t!==void 0){v
24
24
 
25
25
  Check your code at `+p+":"+m+"."}return""}}var Ft={};function br(t){{var p=Lt();if(!p){var m=typeof t=="string"?t:t.displayName||t.name;m&&(p=`
26
26
 
27
- Check the top-level render call using <`+m+">.")}return p}}function Ut(t,p){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var m=br(p);if(Ft[m])return;Ft[m]=!0;var g="";t&&t._owner&&t._owner!==qe.current&&(g=" It was passed a child from "+L(t._owner.type)+"."),ie(t),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',m,g),ie(null)}}function At(t,p){{if(typeof t!="object")return;if(Je(t))for(var m=0;m<t.length;m++){var g=t[m];He(g)&&Ut(g,p)}else if(He(t))t._store&&(t._store.validated=!0);else if(t){var O=I(t);if(typeof O=="function"&&O!==t.entries)for(var D=O.call(t),R;!(R=D.next()).done;)He(R.value)&&Ut(R.value,p)}}}function gr(t){{var p=t.type;if(p==null||typeof p=="string")return;var m;if(typeof p=="function")m=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===f||p.$$typeof===k))m=p.propTypes;else return;if(m){var g=L(p);ir(m,t.props,"prop",g,t)}else if(p.PropTypes!==void 0&&!Ge){Ge=!0;var O=L(p);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",O||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Nr(t){{for(var p=Object.keys(t.props),m=0;m<p.length;m++){var g=p[m];if(g!=="children"&&g!=="key"){ie(t),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),ie(null);break}}t.ref!==null&&(ie(t),C("Invalid attribute `ref` supplied to `React.Fragment`."),ie(null))}}function Vt(t,p,m,g,O,D){{var R=G(t);if(!R){var P="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(P+=" 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 Y=_r(O);Y?P+=Y:P+=Lt();var U;t===null?U="null":Je(t)?U="array":t!==void 0&&t.$$typeof===n?(U="<"+(L(t.type)||"Unknown")+" />",P=" Did you accidentally export a JSX literal instead of a component?"):U=typeof t,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",U,P)}var A=vr(t,p,m,O,D);if(A==null)return A;if(R){var H=p.children;if(H!==void 0)if(g)if(Je(H)){for(var oe=0;oe<H.length;oe++)At(H[oe],t);Object.freeze&&Object.freeze(H)}else C("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 At(H,t)}return t===l?Nr(A):gr(A),A}}function yr(t,p,m){return Vt(t,p,m,!0)}function wr(t,p,m){return Vt(t,p,m,!1)}var Er=wr,Cr=yr;ce.Fragment=l,ce.jsx=Er,ce.jsxs=Cr}()),ce}process.env.NODE_ENV==="production"?Re.exports=Yt():Re.exports=Kt();var Te=Re.exports;const X=Te.Fragment,i=Te.jsx,h=Te.jsxs,Oe='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>',Jt="https://punkt-cdn.oslo.kommune.no/11.9/icons/";function zt(e){return new Promise(n=>setTimeout(n,e))}const $e={},qt=async(e,n)=>{let a=0;for(;$e[n+e+".svg"]==="fetching"&&(a++,!(a>50));)await zt(50);return localStorage.getItem(n+e+".svg")?Promise.resolve(localStorage.getItem(n+e+".svg")):typeof window.fetch=="function"?($e[n+e+".svg"]="fetching",Promise.resolve(fetch(n+e+".svg").then(l=>l.ok?l.text():(console.error("Missing icon: "+n+e+".svg"),Oe)).then(l=>(l!==Oe&&localStorage.setItem(n+e+".svg",l),$e[n+e+".svg"]="fetched",l)))):Promise.resolve(Oe)},Gt={fetchIcon:async(e,n)=>qt(e,n||Jt)},Qe=b.createContext(Gt),w=({name:e,path:n,className:a="",...l})=>{const[r,o]=b.useState(null),s=b.useContext(Qe);return b.useEffect(()=>{e?s.fetchIcon(e,n).then(o):o(null)},[e,n]),r?i("span",{className:`pkt-icon ${a}`,dangerouslySetInnerHTML:{__html:r},...l}):null},et=b.forwardRef(({children:e,className:n,skin:a="info",closeAlert:l=!1,onClose:r,title:o,date:s,ariaLive:c="polite",compact:f=!1,...u},d)=>{const k=[n,"pkt-alert",a&&`pkt-alert--${a}`,f&&"pkt-alert--compact"].filter(Boolean).join(" "),[v,S]=b.useState(!0),x=()=>{S(!1),r&&r()};return v?h("div",{...u,className:k,"aria-live":c,ref:d,children:[i(w,{className:"pkt-alert__icon",name:a==="info"?"alert-information":`alert-${a}`}),l&&i("div",{className:"pkt-alert__close",children:i("button",{type:"button",className:"pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only",tabIndex:0,"aria-label":"close",onClick:x,children:i(w,{name:"close",className:"pkt-btn__icon","aria-hidden":"true"})})}),o&&i("div",{className:"pkt-alert__title",children:o}),i("div",{className:"pkt-alert__text",children:e}),s&&h("div",{className:"pkt-alert__date",children:["Sist oppdatert: ",s]})]}):null}),Ht=b.forwardRef(({href:e,text:n,onClick:a,className:l,...r},o)=>{const s=[l,"pkt-back-link"].filter(Boolean).join(" ");return i("nav",{ref:o,className:s,"aria-label":"Gå tilbake et steg",children:h("a",{href:e||"/",className:"pkt-link pkt-link--icon-left",onClick:f=>{a&&a(f)},...r,children:[i(w,{className:"pkt-back-link__icon pkt-icon pkt-link__icon",name:"chevron-thin-left","aria-hidden":"true"}),i("span",{className:"pkt-back-link__text",children:n||"Forsiden"})]})})});/**
27
+ Check the top-level render call using <`+m+">.")}return p}}function Ut(t,p){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var m=br(p);if(Ft[m])return;Ft[m]=!0;var g="";t&&t._owner&&t._owner!==qe.current&&(g=" It was passed a child from "+L(t._owner.type)+"."),ie(t),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',m,g),ie(null)}}function At(t,p){{if(typeof t!="object")return;if(Je(t))for(var m=0;m<t.length;m++){var g=t[m];He(g)&&Ut(g,p)}else if(He(t))t._store&&(t._store.validated=!0);else if(t){var O=I(t);if(typeof O=="function"&&O!==t.entries)for(var D=O.call(t),R;!(R=D.next()).done;)He(R.value)&&Ut(R.value,p)}}}function gr(t){{var p=t.type;if(p==null||typeof p=="string")return;var m;if(typeof p=="function")m=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===f||p.$$typeof===k))m=p.propTypes;else return;if(m){var g=L(p);ir(m,t.props,"prop",g,t)}else if(p.PropTypes!==void 0&&!Ge){Ge=!0;var O=L(p);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",O||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Nr(t){{for(var p=Object.keys(t.props),m=0;m<p.length;m++){var g=p[m];if(g!=="children"&&g!=="key"){ie(t),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),ie(null);break}}t.ref!==null&&(ie(t),C("Invalid attribute `ref` supplied to `React.Fragment`."),ie(null))}}function Vt(t,p,m,g,O,D){{var R=G(t);if(!R){var P="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(P+=" 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 Y=_r(O);Y?P+=Y:P+=Lt();var U;t===null?U="null":Je(t)?U="array":t!==void 0&&t.$$typeof===n?(U="<"+(L(t.type)||"Unknown")+" />",P=" Did you accidentally export a JSX literal instead of a component?"):U=typeof t,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",U,P)}var A=vr(t,p,m,O,D);if(A==null)return A;if(R){var H=p.children;if(H!==void 0)if(g)if(Je(H)){for(var oe=0;oe<H.length;oe++)At(H[oe],t);Object.freeze&&Object.freeze(H)}else C("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 At(H,t)}return t===l?Nr(A):gr(A),A}}function yr(t,p,m){return Vt(t,p,m,!0)}function wr(t,p,m){return Vt(t,p,m,!1)}var Er=wr,Cr=yr;ce.Fragment=l,ce.jsx=Er,ce.jsxs=Cr}()),ce}process.env.NODE_ENV==="production"?Re.exports=Yt():Re.exports=Kt();var Te=Re.exports;const X=Te.Fragment,i=Te.jsx,h=Te.jsxs,Oe='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>',Jt="https://punkt-cdn.oslo.kommune.no/11.9/icons/";function zt(e){return new Promise(n=>setTimeout(n,e))}const $e={},qt=async(e,n)=>{let a=0;for(;$e[n+e+".svg"]==="fetching"&&(a++,!(a>50));)await zt(50);return localStorage.getItem(n+e+".svg")?Promise.resolve(localStorage.getItem(n+e+".svg")):typeof window.fetch=="function"?($e[n+e+".svg"]="fetching",Promise.resolve(fetch(n+e+".svg").then(l=>l.ok?l.text():(console.error("Missing icon: "+n+e+".svg"),Oe)).then(l=>(l!==Oe&&localStorage.setItem(n+e+".svg",l),$e[n+e+".svg"]="fetched",l)))):Promise.resolve(Oe)},Gt={fetchIcon:async(e,n)=>qt(e,n||Jt)},Qe=b.createContext(Gt),w=({name:e,path:n,className:a="",...l})=>{const[r,o]=b.useState(null),s=b.useContext(Qe);return b.useEffect(()=>{e?s.fetchIcon(e,n).then(o):o(null)},[e,n]),r?i("span",{className:`pkt-icon ${a}`,dangerouslySetInnerHTML:{__html:r},...l}):null},et=b.forwardRef(({children:e,className:n,skin:a="info",closeAlert:l=!1,onClose:r,title:o,date:s,ariaLive:c="polite",compact:f=!1,...u},d)=>{const k=[n,"pkt-alert",a&&`pkt-alert--${a}`,f&&"pkt-alert--compact"].filter(Boolean).join(" "),[v,S]=b.useState(!0),x=()=>{S(!1),r&&r()};return v?h("div",{...u,className:k,"aria-live":c,ref:d,children:[a==="🐣"?i("span",{className:"pkt-icon pkt-alert__icon",children:"🐣"}):i(w,{className:"pkt-alert__icon",name:a==="info"?"alert-information":`alert-${a}`}),l&&i("div",{className:"pkt-alert__close",children:i("button",{type:"button",className:"pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only",tabIndex:0,"aria-label":"close",onClick:x,children:i(w,{name:"close",className:"pkt-btn__icon","aria-hidden":"true"})})}),o&&i("div",{className:"pkt-alert__title",children:o}),i("div",{className:"pkt-alert__text",children:e}),s&&h("div",{className:"pkt-alert__date",children:["Sist oppdatert: ",s]})]}):null}),Ht=b.forwardRef(({href:e,text:n,onClick:a,className:l,...r},o)=>{const s=[l,"pkt-back-link"].filter(Boolean).join(" ");return i("nav",{ref:o,className:s,"aria-label":"Gå tilbake et steg",children:h("a",{href:e||"/",className:"pkt-link pkt-link--icon-left",onClick:f=>{a&&a(f)},...r,children:[i(w,{className:"pkt-back-link__icon pkt-icon pkt-link__icon",name:"chevron-thin-left","aria-hidden":"true"}),i("span",{className:"pkt-back-link__text",children:n||"Forsiden"})]})})});/**
28
28
  * @remix-run/router v1.14.0
29
29
  *
30
30
  * Copyright (c) Remix Software Inc.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "11.9.0",
3
+ "version": "11.9.2",
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",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@oslokommune/punkt-assets": "^11.5.0",
36
- "@oslokommune/punkt-css": "^11.9.0",
36
+ "@oslokommune/punkt-css": "^11.9.2",
37
37
  "@testing-library/jest-dom": "^5.16.5",
38
38
  "@testing-library/react": "^14.0.0",
39
39
  "@testing-library/user-event": "^14.4.3",
@@ -91,5 +91,5 @@
91
91
  "url": "https://github.com/oslokommune/punkt/issues"
92
92
  },
93
93
  "license": "MIT",
94
- "gitHead": "f9c10e09713a41530c52b4a836c9801dd1f527ac"
94
+ "gitHead": "4f8705ba802178b8f6089e3be360bd04e893de71"
95
95
  }
@@ -3,7 +3,8 @@ import React, { ForwardedRef, forwardRef, useState } from 'react'
3
3
  import { PktIcon } from '../icon/Icon'
4
4
 
5
5
  export interface IPktAlert extends React.HTMLAttributes<HTMLDivElement> {
6
- skin?: 'error' | 'success' | 'warning' | 'info'
6
+ // 🐣-kode: PÅSKEFIGUR
7
+ skin?: 'error' | 'success' | 'warning' | 'info' | '🐣'
7
8
  closeAlert?: boolean
8
9
  onClose?: () => void
9
10
  title?: string
@@ -28,12 +29,7 @@ export const PktAlert = forwardRef(
28
29
  }: IPktAlert,
29
30
  ref: ForwardedRef<HTMLDivElement>,
30
31
  ) => {
31
- const classes = [
32
- className,
33
- 'pkt-alert',
34
- skin && `pkt-alert--${skin}`,
35
- compact && 'pkt-alert--compact',
36
- ]
32
+ const classes = [className, 'pkt-alert', skin && `pkt-alert--${skin}`, compact && 'pkt-alert--compact']
37
33
  .filter(Boolean)
38
34
  .join(' ')
39
35
 
@@ -48,10 +44,11 @@ export const PktAlert = forwardRef(
48
44
 
49
45
  return isDisplayed ? (
50
46
  <div {...props} className={classes} aria-live={ariaLive} ref={ref}>
51
- <PktIcon
52
- className="pkt-alert__icon"
53
- name={skin === 'info' ? 'alert-information' : `alert-${skin}`}
54
- />
47
+ {skin === '🐣' ? (
48
+ <span className="pkt-icon pkt-alert__icon">🐣</span>
49
+ ) : (
50
+ <PktIcon className="pkt-alert__icon" name={skin === 'info' ? 'alert-information' : `alert-${skin}`} />
51
+ )}
55
52
 
56
53
  {closeAlert && (
57
54
  <div className="pkt-alert__close">