@equinor/roma-ui 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/number.js CHANGED
@@ -1,15 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Le=require("react/jsx-runtime"),E=require("react"),Ye=require("react-aria"),qe=require("@equinor/eds-core-react"),ze=require("./useControlledState-D0L6S_5r.js");function We(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const I=We(E);function re(r,t=-1/0,e=1/0){return Math.min(Math.max(r,t),e)}function B(r,t){let e=r,i=t.toString(),o=i.indexOf("."),a=o>=0?i.length-o:0;if(a>0){let s=Math.pow(10,a);e=Math.round(e*s)/s}return e}function V(r,t,e,i){t=Number(t),e=Number(e);let o=(r-(isNaN(t)?0:t))%i,a=B(Math.abs(o)*2>=i?r+Math.sign(o)*(i-Math.abs(o)):r-o,i);return isNaN(t)?!isNaN(e)&&a>e&&(a=Math.floor(B(e/i,i))*i):a<t?a=t:!isNaN(e)&&a>e&&(a=t+Math.floor(B((e-t)/i,i))*i),a=B(a,i),a}const xe={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!0},Re={...xe,customError:!0,valid:!1},j={isInvalid:!1,validationDetails:xe,validationErrors:[]},Ue=E.createContext({}),ve="__formValidationState"+Date.now();function Ge(r){if(r[ve]){let{realtimeValidation:t,displayValidation:e,updateValidation:i,resetValidation:o,commitValidation:a}=r[ve];return{realtimeValidation:t,displayValidation:e,updateValidation:i,resetValidation:o,commitValidation:a}}return Be(r)}function Be(r){let{isInvalid:t,validationState:e,name:i,value:o,builtinValidation:a,validate:s,validationBehavior:u="aria"}=r;e&&(t||(t=e==="invalid"));let f=t!==void 0?{isInvalid:t,validationErrors:[],validationDetails:Re}:null,g=E.useMemo(()=>{if(!s||o==null)return null;let c=Ze(s,o);return he(c)},[s,o]);a!=null&&a.validationDetails.valid&&(a=void 0);let $=E.useContext(Ue),y=E.useMemo(()=>i?Array.isArray(i)?i.flatMap(c=>le($[c])):le($[i]):[],[$,i]),[P,h]=E.useState($),[m,S]=E.useState(!1);$!==P&&(h($),S(!1));let x=E.useMemo(()=>he(m?[]:y),[m,y]),T=E.useRef(j),[R,p]=E.useState(j),d=E.useRef(j),n=()=>{if(!_)return;C(!1);let c=g||a||T.current;ie(c,d.current)||(d.current=c,p(c))},[_,C]=E.useState(!1);return E.useEffect(n),{realtimeValidation:f||x||g||a||j,displayValidation:u==="native"?f||x||R:f||x||g||a||R,updateValidation(c){u==="aria"&&!ie(R,c)?p(c):T.current=c},resetValidation(){let c=j;ie(c,d.current)||(d.current=c,p(c)),u==="native"&&C(!1),S(!0)},commitValidation(){u==="native"&&C(!0),S(!0)}}}function le(r){return r?Array.isArray(r)?r:[r]:[]}function Ze(r,t){if(typeof r=="function"){let e=r(t);if(e&&typeof e!="boolean")return le(e)}return[]}function he(r){return r.length?{isInvalid:!0,validationErrors:r,validationDetails:Re}:null}function ie(r,t){return r===t?!0:!!r&&!!t&&r.isInvalid===t.isInvalid&&r.validationErrors.length===t.validationErrors.length&&r.validationErrors.every((e,i)=>e===t.validationErrors[i])&&Object.entries(r.validationDetails).every(([e,i])=>t.validationDetails[e]===i)}let ae=new Map,ue=!1;try{ue=new Intl.NumberFormat("de-DE",{signDisplay:"exceptZero"}).resolvedOptions().signDisplay==="exceptZero"}catch{}let X=!1;try{X=new Intl.NumberFormat("de-DE",{style:"unit",unit:"degree"}).resolvedOptions().style==="unit"}catch{}const we={degree:{narrow:{default:"°","ja-JP":" 度","zh-TW":"度","sl-SI":" °"}}};class ce{format(t){let e="";if(!ue&&this.options.signDisplay!=null?e=He(this.numberFormatter,this.options.signDisplay,t):e=this.numberFormatter.format(t),this.options.style==="unit"&&!X){var i;let{unit:o,unitDisplay:a="short",locale:s}=this.resolvedOptions();if(!o)return e;let u=(i=we[o])===null||i===void 0?void 0:i[a];e+=u[s]||u.default}return e}formatToParts(t){return this.numberFormatter.formatToParts(t)}formatRange(t,e){if(typeof this.numberFormatter.formatRange=="function")return this.numberFormatter.formatRange(t,e);if(e<t)throw new RangeError("End date must be >= start date");return`${this.format(t)} – ${this.format(e)}`}formatRangeToParts(t,e){if(typeof this.numberFormatter.formatRangeToParts=="function")return this.numberFormatter.formatRangeToParts(t,e);if(e<t)throw new RangeError("End date must be >= start date");let i=this.numberFormatter.formatToParts(t),o=this.numberFormatter.formatToParts(e);return[...i.map(a=>({...a,source:"startRange"})),{type:"literal",value:" – ",source:"shared"},...o.map(a=>({...a,source:"endRange"}))]}resolvedOptions(){let t=this.numberFormatter.resolvedOptions();return!ue&&this.options.signDisplay!=null&&(t={...t,signDisplay:this.options.signDisplay}),!X&&this.options.style==="unit"&&(t={...t,style:"unit",unit:this.options.unit,unitDisplay:this.options.unitDisplay}),t}constructor(t,e={}){this.numberFormatter=Xe(t,e),this.options=e}}function Xe(r,t={}){let{numberingSystem:e}=t;if(e&&r.includes("-nu-")&&(r.includes("-u-")||(r+="-u-"),r+=`-nu-${e}`),t.style==="unit"&&!X){var i;let{unit:s,unitDisplay:u="short"}=t;if(!s)throw new Error('unit option must be provided with style: "unit"');if(!(!((i=we[s])===null||i===void 0)&&i[u]))throw new Error(`Unsupported unit ${s} with unitDisplay = ${u}`);t={...t,style:"decimal"}}let o=r+(t?Object.entries(t).sort((s,u)=>s[0]<u[0]?-1:1).join():"");if(ae.has(o))return ae.get(o);let a=new Intl.NumberFormat(r,t);return ae.set(o,a),a}function He(r,t,e){if(t==="auto")return r.format(e);if(t==="never")return r.format(Math.abs(e));{let i=!1;if(t==="always"?i=e>0||Object.is(e,0):t==="exceptZero"&&(Object.is(e,-0)||Object.is(e,0)?e=Math.abs(e):i=e>0),i){let o=r.format(-e),a=r.format(e),s=o.replace(a,"").replace(/\u200e|\u061C/,"");return[...s].length!==1&&console.warn("@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case"),o.replace(a,"!!!").replace(s,"+").replace("!!!",a)}else return r.format(e)}}const Ke=new RegExp("^.*\\(.*\\).*$"),Qe=["latn","arab","hanidec","deva","beng"];class Ce{parse(t){return ne(this.locale,this.options,t).parse(t)}isValidPartialNumber(t,e,i){return ne(this.locale,this.options,t).isValidPartialNumber(t,e,i)}getNumberingSystem(t){return ne(this.locale,this.options,t).options.numberingSystem}constructor(t,e={}){this.locale=t,this.options=e}}const ge=new Map;function ne(r,t,e){let i=$e(r,t);if(!r.includes("-nu-")&&!i.isValidPartialNumber(e)){for(let o of Qe)if(o!==i.options.numberingSystem){let a=$e(r+(r.includes("-u-")?"-nu-":"-u-nu-")+o,t);if(a.isValidPartialNumber(e))return a}}return i}function $e(r,t){let e=r+(t?Object.entries(t).sort((o,a)=>o[0]<a[0]?-1:1).join():""),i=ge.get(e);return i||(i=new Je(r,t),ge.set(e,i)),i}class Je{parse(t){let e=this.sanitize(t);if(this.symbols.group&&(e=L(e,this.symbols.group,"")),this.symbols.decimal&&(e=e.replace(this.symbols.decimal,".")),this.symbols.minusSign&&(e=e.replace(this.symbols.minusSign,"-")),e=e.replace(this.symbols.numeral,this.symbols.index),this.options.style==="percent"){let s=e.indexOf("-");e=e.replace("-",""),e=e.replace("+","");let u=e.indexOf(".");u===-1&&(u=e.length),e=e.replace(".",""),u-2===0?e=`0.${e}`:u-2===-1?e=`0.0${e}`:u-2===-2?e="0.00":e=`${e.slice(0,u-2)}.${e.slice(u-2)}`,s>-1&&(e=`-${e}`)}let i=e?+e:NaN;if(isNaN(i))return NaN;if(this.options.style==="percent"){var o,a;let s={...this.options,style:"decimal",minimumFractionDigits:Math.min(((o=this.options.minimumFractionDigits)!==null&&o!==void 0?o:0)+2,20),maximumFractionDigits:Math.min(((a=this.options.maximumFractionDigits)!==null&&a!==void 0?a:0)+2,20)};return new Ce(this.locale,s).parse(new ce(this.locale,s).format(i))}return this.options.currencySign==="accounting"&&Ke.test(t)&&(i=-1*i),i}sanitize(t){return t=t.replace(this.symbols.literals,""),this.symbols.minusSign&&(t=t.replace("-",this.symbols.minusSign)),this.options.numberingSystem==="arab"&&(this.symbols.decimal&&(t=t.replace(",",this.symbols.decimal),t=t.replace("،",this.symbols.decimal)),this.symbols.group&&(t=L(t,".",this.symbols.group))),this.options.locale==="fr-FR"&&this.symbols.group&&(t=L(t," ",this.symbols.group),t=L(t,/\u00A0/g,this.symbols.group)),t}isValidPartialNumber(t,e=-1/0,i=1/0){return t=this.sanitize(t),this.symbols.minusSign&&t.startsWith(this.symbols.minusSign)&&e<0?t=t.slice(this.symbols.minusSign.length):this.symbols.plusSign&&t.startsWith(this.symbols.plusSign)&&i>0&&(t=t.slice(this.symbols.plusSign.length)),this.symbols.group&&t.startsWith(this.symbols.group)||this.symbols.decimal&&t.indexOf(this.symbols.decimal)>-1&&this.options.maximumFractionDigits===0?!1:(this.symbols.group&&(t=L(t,this.symbols.group,"")),t=t.replace(this.symbols.numeral,""),this.symbols.decimal&&(t=t.replace(this.symbols.decimal,"")),t.length===0)}constructor(t,e={}){this.locale=t,e.roundingIncrement!==1&&e.roundingIncrement!=null&&(e.maximumFractionDigits==null&&e.minimumFractionDigits==null?(e.maximumFractionDigits=0,e.minimumFractionDigits=0):e.maximumFractionDigits==null?e.maximumFractionDigits=e.minimumFractionDigits:e.minimumFractionDigits==null&&(e.minimumFractionDigits=e.maximumFractionDigits)),this.formatter=new Intl.NumberFormat(t,e),this.options=this.formatter.resolvedOptions(),this.symbols=et(t,this.formatter,this.options,e);var i,o;this.options.style==="percent"&&(((i=this.options.minimumFractionDigits)!==null&&i!==void 0?i:0)>18||((o=this.options.maximumFractionDigits)!==null&&o!==void 0?o:0)>18)&&console.warn("NumberParser cannot handle percentages with greater than 18 decimal places, please reduce the number in your options.")}}const Se=new Set(["decimal","fraction","integer","minusSign","plusSign","group"]),ke=[0,4,2,1,11,20,3,7,100,21,.1,1.1];function et(r,t,e,i){var o,a,s,u;let f=new Intl.NumberFormat(r,{...e,minimumSignificantDigits:1,maximumSignificantDigits:21,roundingIncrement:1,roundingPriority:"auto",roundingMode:"halfExpand"}),g=f.formatToParts(-10000.111),$=f.formatToParts(10000.111),y=ke.map(c=>f.formatToParts(c));var P;let h=(P=(o=g.find(c=>c.type==="minusSign"))===null||o===void 0?void 0:o.value)!==null&&P!==void 0?P:"-",m=(a=$.find(c=>c.type==="plusSign"))===null||a===void 0?void 0:a.value;!m&&((i==null?void 0:i.signDisplay)==="exceptZero"||(i==null?void 0:i.signDisplay)==="always")&&(m="+");let x=(s=new Intl.NumberFormat(r,{...e,minimumFractionDigits:2,maximumFractionDigits:2}).formatToParts(.001).find(c=>c.type==="decimal"))===null||s===void 0?void 0:s.value,T=(u=g.find(c=>c.type==="group"))===null||u===void 0?void 0:u.value,R=g.filter(c=>!Se.has(c.type)).map(c=>Ee(c.value)),p=y.flatMap(c=>c.filter(M=>!Se.has(M.type)).map(M=>Ee(M.value))),d=[...new Set([...R,...p])].sort((c,M)=>M.length-c.length),n=d.length===0?new RegExp("[\\p{White_Space}]","gu"):new RegExp(`${d.join("|")}|[\\p{White_Space}]`,"gu"),_=[...new Intl.NumberFormat(e.locale,{useGrouping:!1}).format(9876543210)].reverse(),C=new Map(_.map((c,M)=>[c,M])),D=new RegExp(`[${_.join("")}]`,"g");return{minusSign:h,plusSign:m,decimal:x,group:T,literals:n,numeral:D,index:c=>String(C.get(c))}}function L(r,t,e){return r.replaceAll?r.replaceAll(t,e):r.split(t).join(e)}function Ee(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tt(r){let{minValue:t,maxValue:e,step:i,formatOptions:o,value:a,defaultValue:s=NaN,onChange:u,locale:f,isDisabled:g,isReadOnly:$}=r;a===null&&(a=NaN),a!==void 0&&!isNaN(a)&&(i!==void 0&&!isNaN(i)?a=V(a,t,e,i):a=re(a,t,e)),isNaN(s)||(i!==void 0&&!isNaN(i)?s=V(s,t,e,i):s=re(s,t,e));let[y,P]=ze.$458b0a5536c1a7cf$export$40bfa8c7b0832715(a,isNaN(s)?NaN:s,u),[h,m]=E.useState(()=>isNaN(y)?"":new ce(f,o).format(y)),S=E.useMemo(()=>new Ce(f,o),[f,o]),x=E.useMemo(()=>S.getNumberingSystem(h),[S,h]),T=E.useMemo(()=>new ce(f,{...o,numberingSystem:x}),[f,o,x]),R=E.useMemo(()=>T.resolvedOptions(),[T]),p=E.useCallback(N=>isNaN(N)||N===null?"":T.format(N),[T]),d=Ge({...r,value:y}),n=i!==void 0&&!isNaN(i)?i:1;R.style==="percent"&&(i===void 0||isNaN(i))&&(n=.01);let[_,C]=E.useState(y),[D,A]=E.useState(f),[c,M]=E.useState(o);(!Object.is(y,_)||f!==D||o!==c)&&(m(p(y)),C(y),A(f),M(o));let w=E.useMemo(()=>S.parse(h),[S,h]),K=()=>{if(!h.length){P(NaN),m(a===void 0?"":p(y));return}if(isNaN(w)){m(p(y));return}let N;i===void 0||isNaN(i)?N=re(w,t,e):N=V(w,t,e,i),N=S.parse(p(N)),P(N),m(p(a===void 0?N:y))},q=(N,U=0)=>{let O=w;if(isNaN(O)){let F=isNaN(U)?0:U;return V(F,t,e,n)}else{let F=V(O,t,e,n);return N==="+"&&F>O||N==="-"&&F<O?F:V(oe(N,O,n),t,e,n)}},Q=()=>{let N=q("+",t);N===y&&m(p(N)),P(N),d.commitValidation()},J=()=>{let N=q("-",e);N===y&&m(p(N)),P(N),d.commitValidation()},k=()=>{e!=null&&(P(V(e,t,e,n)),d.commitValidation())},z=()=>{t!=null&&(P(t),d.commitValidation())},ee=E.useMemo(()=>!g&&!$&&(isNaN(w)||e===void 0||isNaN(e)||V(w,t,e,n)>w||oe("+",w,n)<=e),[g,$,t,e,n,w]),W=E.useMemo(()=>!g&&!$&&(isNaN(w)||t===void 0||isNaN(t)||V(w,t,e,n)<w||oe("-",w,n)>=t),[g,$,t,e,n,w]);return{...d,validate:N=>S.isValidPartialNumber(N,t,e),increment:Q,incrementToMax:k,decrement:J,decrementToMin:z,canIncrement:ee,canDecrement:W,minValue:t,maxValue:e,numberValue:w,setNumberValue:P,setInputValue:m,inputValue:h,commit:K}}function oe(r,t,e){let i=r==="+"?t+e:t-e;if(t%1!==0||e%1!==0){const o=t.toString().split("."),a=e.toString().split("."),s=o[1]&&o[1].length||0,u=a[1]&&a[1].length||0,f=Math.pow(10,Math.max(s,u));t=Math.round(t*f),e=Math.round(e*f),i=r==="+"?t+e:t-e,i/=f}return i}var H=function(){return H=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++){e=arguments[i];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},H.apply(this,arguments)};function Me(r,t){var e={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(r);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(r,i[o])&&(e[i[o]]=r[i[o]]);return e}var Z={exports:{}},b={};/** @license React v16.13.1
2
- * react-is.production.min.js
3
- *
4
- * Copyright (c) Facebook, Inc. and its affiliates.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */var Ne;function rt(){if(Ne)return b;Ne=1;var r=typeof Symbol=="function"&&Symbol.for,t=r?Symbol.for("react.element"):60103,e=r?Symbol.for("react.portal"):60106,i=r?Symbol.for("react.fragment"):60107,o=r?Symbol.for("react.strict_mode"):60108,a=r?Symbol.for("react.profiler"):60114,s=r?Symbol.for("react.provider"):60109,u=r?Symbol.for("react.context"):60110,f=r?Symbol.for("react.async_mode"):60111,g=r?Symbol.for("react.concurrent_mode"):60111,$=r?Symbol.for("react.forward_ref"):60112,y=r?Symbol.for("react.suspense"):60113,P=r?Symbol.for("react.suspense_list"):60120,h=r?Symbol.for("react.memo"):60115,m=r?Symbol.for("react.lazy"):60116,S=r?Symbol.for("react.block"):60121,x=r?Symbol.for("react.fundamental"):60117,T=r?Symbol.for("react.responder"):60118,R=r?Symbol.for("react.scope"):60119;function p(n){if(typeof n=="object"&&n!==null){var _=n.$$typeof;switch(_){case t:switch(n=n.type,n){case f:case g:case i:case a:case o:case y:return n;default:switch(n=n&&n.$$typeof,n){case u:case $:case m:case h:case s:return n;default:return _}}case e:return _}}}function d(n){return p(n)===g}return b.AsyncMode=f,b.ConcurrentMode=g,b.ContextConsumer=u,b.ContextProvider=s,b.Element=t,b.ForwardRef=$,b.Fragment=i,b.Lazy=m,b.Memo=h,b.Portal=e,b.Profiler=a,b.StrictMode=o,b.Suspense=y,b.isAsyncMode=function(n){return d(n)||p(n)===f},b.isConcurrentMode=d,b.isContextConsumer=function(n){return p(n)===u},b.isContextProvider=function(n){return p(n)===s},b.isElement=function(n){return typeof n=="object"&&n!==null&&n.$$typeof===t},b.isForwardRef=function(n){return p(n)===$},b.isFragment=function(n){return p(n)===i},b.isLazy=function(n){return p(n)===m},b.isMemo=function(n){return p(n)===h},b.isPortal=function(n){return p(n)===e},b.isProfiler=function(n){return p(n)===a},b.isStrictMode=function(n){return p(n)===o},b.isSuspense=function(n){return p(n)===y},b.isValidElementType=function(n){return typeof n=="string"||typeof n=="function"||n===i||n===g||n===a||n===o||n===y||n===P||typeof n=="object"&&n!==null&&(n.$$typeof===m||n.$$typeof===h||n.$$typeof===s||n.$$typeof===u||n.$$typeof===$||n.$$typeof===x||n.$$typeof===T||n.$$typeof===R||n.$$typeof===S)},b.typeOf=p,b}var v={};/** @license React v16.13.1
9
- * react-is.development.js
10
- *
11
- * Copyright (c) Facebook, Inc. and its affiliates.
12
- *
13
- * This source code is licensed under the MIT license found in the
14
- * LICENSE file in the root directory of this source tree.
15
- */var Pe;function it(){return Pe||(Pe=1,process.env.NODE_ENV!=="production"&&function(){var r=typeof Symbol=="function"&&Symbol.for,t=r?Symbol.for("react.element"):60103,e=r?Symbol.for("react.portal"):60106,i=r?Symbol.for("react.fragment"):60107,o=r?Symbol.for("react.strict_mode"):60108,a=r?Symbol.for("react.profiler"):60114,s=r?Symbol.for("react.provider"):60109,u=r?Symbol.for("react.context"):60110,f=r?Symbol.for("react.async_mode"):60111,g=r?Symbol.for("react.concurrent_mode"):60111,$=r?Symbol.for("react.forward_ref"):60112,y=r?Symbol.for("react.suspense"):60113,P=r?Symbol.for("react.suspense_list"):60120,h=r?Symbol.for("react.memo"):60115,m=r?Symbol.for("react.lazy"):60116,S=r?Symbol.for("react.block"):60121,x=r?Symbol.for("react.fundamental"):60117,T=r?Symbol.for("react.responder"):60118,R=r?Symbol.for("react.scope"):60119;function p(l){return typeof l=="string"||typeof l=="function"||l===i||l===g||l===a||l===o||l===y||l===P||typeof l=="object"&&l!==null&&(l.$$typeof===m||l.$$typeof===h||l.$$typeof===s||l.$$typeof===u||l.$$typeof===$||l.$$typeof===x||l.$$typeof===T||l.$$typeof===R||l.$$typeof===S)}function d(l){if(typeof l=="object"&&l!==null){var te=l.$$typeof;switch(te){case t:var G=l.type;switch(G){case f:case g:case i:case a:case o:case y:return G;default:var be=G&&G.$$typeof;switch(be){case u:case $:case m:case h:case s:return be;default:return te}}case e:return te}}}var n=f,_=g,C=u,D=s,A=t,c=$,M=i,w=m,K=h,q=e,Q=a,J=o,k=y,z=!1;function ee(l){return z||(z=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),W(l)||d(l)===f}function W(l){return d(l)===g}function ye(l){return d(l)===u}function N(l){return d(l)===s}function U(l){return typeof l=="object"&&l!==null&&l.$$typeof===t}function O(l){return d(l)===$}function F(l){return d(l)===i}function De(l){return d(l)===m}function Oe(l){return d(l)===h}function Fe(l){return d(l)===e}function Ie(l){return d(l)===a}function Ae(l){return d(l)===o}function je(l){return d(l)===y}v.AsyncMode=n,v.ConcurrentMode=_,v.ContextConsumer=C,v.ContextProvider=D,v.Element=A,v.ForwardRef=c,v.Fragment=M,v.Lazy=w,v.Memo=K,v.Portal=q,v.Profiler=Q,v.StrictMode=J,v.Suspense=k,v.isAsyncMode=ee,v.isConcurrentMode=W,v.isContextConsumer=ye,v.isContextProvider=N,v.isElement=U,v.isForwardRef=O,v.isFragment=F,v.isLazy=De,v.isMemo=Oe,v.isPortal=Fe,v.isProfiler=Ie,v.isStrictMode=Ae,v.isSuspense=je,v.isValidElementType=p,v.typeOf=d}()),v}var Te;function at(){return Te||(Te=1,process.env.NODE_ENV==="production"?Z.exports=rt():Z.exports=it()),Z.exports}var se,_e;function nt(){if(_e)return se;_e=1;var r=at(),t={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},e={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},o={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},a={};a[r.ForwardRef]=i,a[r.Memo]=o;function s(m){return r.isMemo(m)?o:a[m.$$typeof]||t}var u=Object.defineProperty,f=Object.getOwnPropertyNames,g=Object.getOwnPropertySymbols,$=Object.getOwnPropertyDescriptor,y=Object.getPrototypeOf,P=Object.prototype;function h(m,S,x){if(typeof S!="string"){if(P){var T=y(S);T&&T!==P&&h(m,T,x)}var R=f(S);g&&(R=R.concat(g(S)));for(var p=s(m),d=s(S),n=0;n<R.length;++n){var _=R[n];if(!e[_]&&!(x&&x[_])&&!(d&&d[_])&&!(p&&p[_])){var C=$(S,_);try{u(m,_,C)}catch{}}}}return m}return se=h,se}nt();function ot(r,t,e){if(e===void 0&&(e=Error),!r)throw new e(t)}var st=function(r){process.env.NODE_ENV!=="production"&&console.error(r)},lt=function(r){process.env.NODE_ENV!=="production"&&console.warn(r)},ut={formats:{},messages:{},timeZone:void 0,defaultLocale:"en",defaultFormats:{},fallbackOnEmptyString:!0,onError:st,onWarn:lt};function ct(r){ot(r,"[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.")}H(H({},ut),{textComponent:I.Fragment});var de=typeof window<"u"&&!window.__REACT_INTL_BYPASS_GLOBAL_CONTEXT__?window.__REACT_INTL_CONTEXT__||(window.__REACT_INTL_CONTEXT__=I.createContext(null)):I.createContext(null);de.Consumer;de.Provider;var ft=de;function pe(){var r=I.useContext(ft);return ct(r),r}var fe;(function(r){r.formatDate="FormattedDate",r.formatTime="FormattedTime",r.formatNumber="FormattedNumber",r.formatList="FormattedList",r.formatDisplayName="FormattedDisplayName"})(fe||(fe={}));var me;(function(r){r.formatDate="FormattedDateParts",r.formatTime="FormattedTimeParts",r.formatNumber="FormattedNumberParts",r.formatList="FormattedListParts"})(me||(me={}));function Ve(r){var t=function(e){var i=pe(),o=e.value,a=e.children,s=Me(e,["value","children"]),u=typeof o=="string"?new Date(o||0):o,f=r==="formatDate"?i.formatDateToParts(u,s):i.formatTimeToParts(u,s);return a(f)};return t.displayName=me[r],t}function Y(r){var t=function(e){var i=pe(),o=e.value,a=e.children,s=Me(e,["value","children"]),u=i[r](o,s);if(typeof a=="function")return a(u);var f=i.textComponent||I.Fragment;return I.createElement(f,null,u)};return t.displayName=fe[r],t}Y("formatDate");Y("formatTime");Y("formatNumber");Y("formatList");Y("formatDisplayName");Ve("formatDate");Ve("formatTime");const mt=E.forwardRef(({placeholder:r,variant:t,disabled:e,type:i,readOnly:o,leftAdornments:a,rightAdornments:s,leftAdornmentsProps:u,rightAdornmentsProps:f,leftAdornmentsWidth:g,rightAdornmentsWidth:$,className:y,style:P,label:h,value:m,...S},x)=>{const{locale:T}=pe(),R=tt({...S,label:h,value:m,onChange:n=>{S.onChange&&S.onChange(n)},locale:T}),p=E.useRef(null),{inputProps:d}=Ye.useNumberField({...S,label:h,value:m},R,p);return Le.jsx(qe.Input,{placeholder:r,variant:t,disabled:e,type:i,readOnly:o,leftAdornments:a,rightAdornments:s,leftAdornmentsProps:u,rightAdornmentsProps:f,leftAdornmentsWidth:g,rightAdornmentsWidth:$,className:y,style:P,"data-testid":`number-field-${h}`,...d,ref:x,"aria-label":h})});exports.NumberField=mt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const me=require("react/jsx-runtime"),u=require("react"),de=require("react-aria"),fe=require("@equinor/eds-core-react"),pe=require("./useControlledState-D0L6S_5r.js");function L(r,e=-1/0,t=1/0){return Math.min(Math.max(r,e),t)}function A(r,e){let t=r,i=e.toString(),n=i.indexOf("."),a=n>=0?i.length-n:0;if(a>0){let l=Math.pow(10,a);t=Math.round(t*l)/l}return t}function M(r,e,t,i){e=Number(e),t=Number(t);let n=(r-(isNaN(e)?0:e))%i,a=A(Math.abs(n)*2>=i?r+Math.sign(n)*(i-Math.abs(n)):r-n,i);return isNaN(e)?!isNaN(t)&&a>t&&(a=Math.floor(A(t/i,i))*i):a<e?a=e:!isNaN(t)&&a>t&&(a=e+Math.floor(A((t-e)/i,i))*i),a=A(a,i),a}const ee={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!0},te={...ee,customError:!0,valid:!1},O={isInvalid:!1,validationDetails:ee,validationErrors:[]},be=u.createContext({}),Y="__formValidationState"+Date.now();function he(r){if(r[Y]){let{realtimeValidation:e,displayValidation:t,updateValidation:i,resetValidation:n,commitValidation:a}=r[Y];return{realtimeValidation:e,displayValidation:t,updateValidation:i,resetValidation:n,commitValidation:a}}return ge(r)}function ge(r){let{isInvalid:e,validationState:t,name:i,value:n,builtinValidation:a,validate:l,validationBehavior:o="aria"}=r;t&&(e||(e=t==="invalid"));let m=e!==void 0?{isInvalid:e,validationErrors:[],validationDetails:te}:null,V=u.useMemo(()=>{if(!l||n==null)return null;let s=$e(l,n);return k(s)},[l,n]);a!=null&&a.validationDetails.valid&&(a=void 0);let h=u.useContext(be),f=u.useMemo(()=>i?Array.isArray(i)?i.flatMap(s=>G(h[s])):G(h[i]):[],[h,i]),[g,$]=u.useState(h),[p,b]=u.useState(!1);h!==g&&($(h),b(!1));let D=u.useMemo(()=>k(p?[]:f),[p,f]),w=u.useRef(O),[x,y]=u.useState(O),v=u.useRef(O),d=()=>{if(!P)return;S(!1);let s=V||a||w.current;q(s,v.current)||(v.current=s,y(s))},[P,S]=u.useState(!1);return u.useEffect(d),{realtimeValidation:m||D||V||a||O,displayValidation:o==="native"?m||D||x:m||D||V||a||x,updateValidation(s){o==="aria"&&!q(x,s)?y(s):w.current=s},resetValidation(){let s=O;q(s,v.current)||(v.current=s,y(s)),o==="native"&&S(!1),b(!0)},commitValidation(){o==="native"&&S(!0),b(!0)}}}function G(r){return r?Array.isArray(r)?r:[r]:[]}function $e(r,e){if(typeof r=="function"){let t=r(e);if(t&&typeof t!="boolean")return G(t)}return[]}function k(r){return r.length?{isInvalid:!0,validationErrors:r,validationDetails:te}:null}function q(r,e){return r===e?!0:!!r&&!!e&&r.isInvalid===e.isInvalid&&r.validationErrors.length===e.validationErrors.length&&r.validationErrors.every((t,i)=>t===e.validationErrors[i])&&Object.entries(r.validationDetails).every(([t,i])=>e.validationDetails[t]===i)}let z=new Map,U=!1;try{U=new Intl.NumberFormat("de-DE",{signDisplay:"exceptZero"}).resolvedOptions().signDisplay==="exceptZero"}catch{}let j=!1;try{j=new Intl.NumberFormat("de-DE",{style:"unit",unit:"degree"}).resolvedOptions().style==="unit"}catch{}const ie={degree:{narrow:{default:"°","ja-JP":" 度","zh-TW":"度","sl-SI":" °"}}};class Z{format(e){let t="";if(!U&&this.options.signDisplay!=null?t=ve(this.numberFormatter,this.options.signDisplay,e):t=this.numberFormatter.format(e),this.options.style==="unit"&&!j){var i;let{unit:n,unitDisplay:a="short",locale:l}=this.resolvedOptions();if(!n)return t;let o=(i=ie[n])===null||i===void 0?void 0:i[a];t+=o[l]||o.default}return t}formatToParts(e){return this.numberFormatter.formatToParts(e)}formatRange(e,t){if(typeof this.numberFormatter.formatRange=="function")return this.numberFormatter.formatRange(e,t);if(t<e)throw new RangeError("End date must be >= start date");return`${this.format(e)} – ${this.format(t)}`}formatRangeToParts(e,t){if(typeof this.numberFormatter.formatRangeToParts=="function")return this.numberFormatter.formatRangeToParts(e,t);if(t<e)throw new RangeError("End date must be >= start date");let i=this.numberFormatter.formatToParts(e),n=this.numberFormatter.formatToParts(t);return[...i.map(a=>({...a,source:"startRange"})),{type:"literal",value:" – ",source:"shared"},...n.map(a=>({...a,source:"endRange"}))]}resolvedOptions(){let e=this.numberFormatter.resolvedOptions();return!U&&this.options.signDisplay!=null&&(e={...e,signDisplay:this.options.signDisplay}),!j&&this.options.style==="unit"&&(e={...e,style:"unit",unit:this.options.unit,unitDisplay:this.options.unitDisplay}),e}constructor(e,t={}){this.numberFormatter=ye(e,t),this.options=t}}function ye(r,e={}){let{numberingSystem:t}=e;if(t&&r.includes("-nu-")&&(r.includes("-u-")||(r+="-u-"),r+=`-nu-${t}`),e.style==="unit"&&!j){var i;let{unit:l,unitDisplay:o="short"}=e;if(!l)throw new Error('unit option must be provided with style: "unit"');if(!(!((i=ie[l])===null||i===void 0)&&i[o]))throw new Error(`Unsupported unit ${l} with unitDisplay = ${o}`);e={...e,style:"decimal"}}let n=r+(e?Object.entries(e).sort((l,o)=>l[0]<o[0]?-1:1).join():"");if(z.has(n))return z.get(n);let a=new Intl.NumberFormat(r,e);return z.set(n,a),a}function ve(r,e,t){if(e==="auto")return r.format(t);if(e==="never")return r.format(Math.abs(t));{let i=!1;if(e==="always"?i=t>0||Object.is(t,0):e==="exceptZero"&&(Object.is(t,-0)||Object.is(t,0)?t=Math.abs(t):i=t>0),i){let n=r.format(-t),a=r.format(t),l=n.replace(a,"").replace(/\u200e|\u061C/,"");return[...l].length!==1&&console.warn("@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case"),n.replace(a,"!!!").replace(l,"+").replace("!!!",a)}else return r.format(t)}}const Ne=new RegExp("^.*\\(.*\\).*$"),Ve=["latn","arab","hanidec","deva","beng"];class re{parse(e){return W(this.locale,this.options,e).parse(e)}isValidPartialNumber(e,t,i){return W(this.locale,this.options,e).isValidPartialNumber(e,t,i)}getNumberingSystem(e){return W(this.locale,this.options,e).options.numberingSystem}constructor(e,t={}){this.locale=e,this.options=t}}const Q=new Map;function W(r,e,t){let i=J(r,e);if(!r.includes("-nu-")&&!i.isValidPartialNumber(t)){for(let n of Ve)if(n!==i.options.numberingSystem){let a=J(r+(r.includes("-u-")?"-nu-":"-u-nu-")+n,e);if(a.isValidPartialNumber(t))return a}}return i}function J(r,e){let t=r+(e?Object.entries(e).sort((n,a)=>n[0]<a[0]?-1:1).join():""),i=Q.get(t);return i||(i=new Se(r,e),Q.set(t,i)),i}class Se{parse(e){let t=this.sanitize(e);if(this.symbols.group&&(t=T(t,this.symbols.group,"")),this.symbols.decimal&&(t=t.replace(this.symbols.decimal,".")),this.symbols.minusSign&&(t=t.replace(this.symbols.minusSign,"-")),t=t.replace(this.symbols.numeral,this.symbols.index),this.options.style==="percent"){let l=t.indexOf("-");t=t.replace("-",""),t=t.replace("+","");let o=t.indexOf(".");o===-1&&(o=t.length),t=t.replace(".",""),o-2===0?t=`0.${t}`:o-2===-1?t=`0.0${t}`:o-2===-2?t="0.00":t=`${t.slice(0,o-2)}.${t.slice(o-2)}`,l>-1&&(t=`-${t}`)}let i=t?+t:NaN;if(isNaN(i))return NaN;if(this.options.style==="percent"){var n,a;let l={...this.options,style:"decimal",minimumFractionDigits:Math.min(((n=this.options.minimumFractionDigits)!==null&&n!==void 0?n:0)+2,20),maximumFractionDigits:Math.min(((a=this.options.maximumFractionDigits)!==null&&a!==void 0?a:0)+2,20)};return new re(this.locale,l).parse(new Z(this.locale,l).format(i))}return this.options.currencySign==="accounting"&&Ne.test(e)&&(i=-1*i),i}sanitize(e){return e=e.replace(this.symbols.literals,""),this.symbols.minusSign&&(e=e.replace("-",this.symbols.minusSign)),this.options.numberingSystem==="arab"&&(this.symbols.decimal&&(e=e.replace(",",this.symbols.decimal),e=e.replace("،",this.symbols.decimal)),this.symbols.group&&(e=T(e,".",this.symbols.group))),this.options.locale==="fr-FR"&&this.symbols.group&&(e=T(e," ",this.symbols.group),e=T(e,/\u00A0/g,this.symbols.group)),e}isValidPartialNumber(e,t=-1/0,i=1/0){return e=this.sanitize(e),this.symbols.minusSign&&e.startsWith(this.symbols.minusSign)&&t<0?e=e.slice(this.symbols.minusSign.length):this.symbols.plusSign&&e.startsWith(this.symbols.plusSign)&&i>0&&(e=e.slice(this.symbols.plusSign.length)),this.symbols.group&&e.startsWith(this.symbols.group)||this.symbols.decimal&&e.indexOf(this.symbols.decimal)>-1&&this.options.maximumFractionDigits===0?!1:(this.symbols.group&&(e=T(e,this.symbols.group,"")),e=e.replace(this.symbols.numeral,""),this.symbols.decimal&&(e=e.replace(this.symbols.decimal,"")),e.length===0)}constructor(e,t={}){this.locale=e,t.roundingIncrement!==1&&t.roundingIncrement!=null&&(t.maximumFractionDigits==null&&t.minimumFractionDigits==null?(t.maximumFractionDigits=0,t.minimumFractionDigits=0):t.maximumFractionDigits==null?t.maximumFractionDigits=t.minimumFractionDigits:t.minimumFractionDigits==null&&(t.minimumFractionDigits=t.maximumFractionDigits)),this.formatter=new Intl.NumberFormat(e,t),this.options=this.formatter.resolvedOptions(),this.symbols=we(e,this.formatter,this.options,t);var i,n;this.options.style==="percent"&&(((i=this.options.minimumFractionDigits)!==null&&i!==void 0?i:0)>18||((n=this.options.maximumFractionDigits)!==null&&n!==void 0?n:0)>18)&&console.warn("NumberParser cannot handle percentages with greater than 18 decimal places, please reduce the number in your options.")}}const X=new Set(["decimal","fraction","integer","minusSign","plusSign","group"]),De=[0,4,2,1,11,20,3,7,100,21,.1,1.1];function we(r,e,t,i){var n,a,l,o;let m=new Intl.NumberFormat(r,{...t,minimumSignificantDigits:1,maximumSignificantDigits:21,roundingIncrement:1,roundingPriority:"auto",roundingMode:"halfExpand"}),V=m.formatToParts(-10000.111),h=m.formatToParts(10000.111),f=De.map(s=>m.formatToParts(s));var g;let $=(g=(n=V.find(s=>s.type==="minusSign"))===null||n===void 0?void 0:n.value)!==null&&g!==void 0?g:"-",p=(a=h.find(s=>s.type==="plusSign"))===null||a===void 0?void 0:a.value;!p&&((i==null?void 0:i.signDisplay)==="exceptZero"||(i==null?void 0:i.signDisplay)==="always")&&(p="+");let D=(l=new Intl.NumberFormat(r,{...t,minimumFractionDigits:2,maximumFractionDigits:2}).formatToParts(.001).find(s=>s.type==="decimal"))===null||l===void 0?void 0:l.value,w=(o=V.find(s=>s.type==="group"))===null||o===void 0?void 0:o.value,x=V.filter(s=>!X.has(s.type)).map(s=>H(s.value)),y=f.flatMap(s=>s.filter(E=>!X.has(E.type)).map(E=>H(E.value))),v=[...new Set([...x,...y])].sort((s,E)=>E.length-s.length),d=v.length===0?new RegExp("[\\p{White_Space}]","gu"):new RegExp(`${v.join("|")}|[\\p{White_Space}]`,"gu"),P=[...new Intl.NumberFormat(t.locale,{useGrouping:!1}).format(9876543210)].reverse(),S=new Map(P.map((s,E)=>[s,E])),F=new RegExp(`[${P.join("")}]`,"g");return{minusSign:$,plusSign:p,decimal:D,group:w,literals:d,numeral:F,index:s=>String(S.get(s))}}function T(r,e,t){return r.replaceAll?r.replaceAll(e,t):r.split(e).join(t)}function H(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xe(r){let{minValue:e,maxValue:t,step:i,formatOptions:n,value:a,defaultValue:l=NaN,onChange:o,locale:m,isDisabled:V,isReadOnly:h}=r;a===null&&(a=NaN),a!==void 0&&!isNaN(a)&&(i!==void 0&&!isNaN(i)?a=M(a,e,t,i):a=L(a,e,t)),isNaN(l)||(i!==void 0&&!isNaN(i)?l=M(l,e,t,i):l=L(l,e,t));let[f,g]=pe.$458b0a5536c1a7cf$export$40bfa8c7b0832715(a,isNaN(l)?NaN:l,o),[$,p]=u.useState(()=>isNaN(f)?"":new Z(m,n).format(f)),b=u.useMemo(()=>new re(m,n),[m,n]),D=u.useMemo(()=>b.getNumberingSystem($),[b,$]),w=u.useMemo(()=>new Z(m,{...n,numberingSystem:D}),[m,n,D]),x=u.useMemo(()=>w.resolvedOptions(),[w]),y=u.useCallback(c=>isNaN(c)||c===null?"":w.format(c),[w]),v=he({...r,value:f}),d=i!==void 0&&!isNaN(i)?i:1;x.style==="percent"&&(i===void 0||isNaN(i))&&(d=.01);let[P,S]=u.useState(f),[F,I]=u.useState(m),[s,E]=u.useState(n);(!Object.is(f,P)||m!==F||n!==s)&&(p(y(f)),S(f),I(m),E(n));let N=u.useMemo(()=>b.parse($),[b,$]),ae=()=>{if(!$.length){g(NaN),p(a===void 0?"":y(f));return}if(isNaN(N)){p(y(f));return}let c;i===void 0||isNaN(i)?c=L(N,e,t):c=M(N,e,t,i),c=b.parse(y(c)),g(c),p(y(a===void 0?c:f))},B=(c,K=0)=>{let R=N;if(isNaN(R)){let C=isNaN(K)?0:K;return M(C,e,t,d)}else{let C=M(R,e,t,d);return c==="+"&&C>R||c==="-"&&C<R?C:M(_(c,R,d),e,t,d)}},ne=()=>{let c=B("+",e);c===f&&p(y(c)),g(c),v.commitValidation()},se=()=>{let c=B("-",t);c===f&&p(y(c)),g(c),v.commitValidation()},le=()=>{t!=null&&(g(M(t,e,t,d)),v.commitValidation())},oe=()=>{e!=null&&(g(e),v.commitValidation())},ue=u.useMemo(()=>!V&&!h&&(isNaN(N)||t===void 0||isNaN(t)||M(N,e,t,d)>N||_("+",N,d)<=t),[V,h,e,t,d,N]),ce=u.useMemo(()=>!V&&!h&&(isNaN(N)||e===void 0||isNaN(e)||M(N,e,t,d)<N||_("-",N,d)>=e),[V,h,e,t,d,N]);return{...v,validate:c=>b.isValidPartialNumber(c,e,t),increment:ne,incrementToMax:le,decrement:se,decrementToMin:oe,canIncrement:ue,canDecrement:ce,minValue:e,maxValue:t,numberValue:N,setNumberValue:g,setInputValue:p,inputValue:$,commit:ae}}function _(r,e,t){let i=r==="+"?e+t:e-t;if(e%1!==0||t%1!==0){const n=e.toString().split("."),a=t.toString().split("."),l=n[1]&&n[1].length||0,o=a[1]&&a[1].length||0,m=Math.pow(10,Math.max(l,o));e=Math.round(e*m),t=Math.round(t*m),i=r==="+"?e+t:e-t,i/=m}return i}const Pe=u.forwardRef(({placeholder:r,variant:e,disabled:t,type:i,readOnly:n,leftAdornments:a,rightAdornments:l,leftAdornmentsProps:o,rightAdornmentsProps:m,leftAdornmentsWidth:V,rightAdornmentsWidth:h,className:f,style:g,label:$,value:p,...b},D)=>{const x=xe({...b,label:$,value:p,onChange:d=>{b.onChange&&b.onChange(d)},locale:"nb-NO"}),y=u.useRef(null),{inputProps:v}=de.useNumberField({...b,label:$,value:p},x,y);return me.jsx(fe.Input,{placeholder:r,variant:e,disabled:t,type:i,readOnly:n,leftAdornments:a,rightAdornments:l,leftAdornmentsProps:o,rightAdornmentsProps:m,leftAdornmentsWidth:V,rightAdornmentsWidth:h,className:f,style:g,"data-testid":`number-field-${$}`,...v,onKeyDown:d=>{var P;if(d.key==="."){d.preventDefault();const S=d.target;if((P=S.value)!=null&&P.includes(","))return;const F=S.selectionStart||0,I=S.selectionEnd||0;S.value=S.value.substring(0,F)+","+S.value.substring(I)}},ref:D,"aria-label":$})});exports.NumberField=Pe;