@equinor/roma-ui 0.1.2 → 0.2.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/index.d.ts +1 -0
- package/index.js +1 -1
- package/index.mjs +8 -6
- package/lib/NumberField/NumberField.d.ts +3 -0
- package/lib/select/styled-comps.d.ts +3 -0
- package/number.js +15 -0
- package/number.mjs +875 -0
- package/package.json +6 -1
- package/select.js +2 -2
- package/switch.js +1 -1
- package/switch.mjs +55 -79
- package/useControlledState-D0L6S_5r.js +1 -0
- package/useControlledState-u436Wbp1.mjs +30 -0
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./select.js"),t=require("./switch.js");exports.Option=e.Option;exports.Select=e.Select;exports.Styled=e.Styled;exports.Switch=t.Switch;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./select.js"),t=require("./switch.js"),i=require("./number.js");exports.Option=e.Option;exports.Select=e.Select;exports.Styled=e.Styled;exports.Switch=t.Switch;exports.NumberField=i.NumberField;
|
package/index.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Option as
|
|
2
|
-
import { Switch as
|
|
1
|
+
import { Option as r, Select as t, Styled as m } from "./select.mjs";
|
|
2
|
+
import { Switch as f } from "./switch.mjs";
|
|
3
|
+
import { NumberField as l } from "./number.mjs";
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
-
r as
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
l as NumberField,
|
|
6
|
+
r as Option,
|
|
7
|
+
t as Select,
|
|
8
|
+
m as Styled,
|
|
9
|
+
f as Switch
|
|
8
10
|
};
|
|
@@ -26,7 +26,10 @@ declare const _default: {
|
|
|
26
26
|
disabledKeys?: Iterable<import('react-aria-components').Key> | undefined;
|
|
27
27
|
onFocusChange?: ((isFocused: boolean) => void) | undefined;
|
|
28
28
|
selectionBehavior?: import('react-stately').SelectionBehavior | undefined;
|
|
29
|
+
shouldSelectOnPressUp?: boolean | undefined;
|
|
30
|
+
shouldFocusOnHover?: boolean | undefined;
|
|
29
31
|
onAction?: ((key: import('react-aria-components').Key) => void) | undefined;
|
|
32
|
+
escapeKeyBehavior?: "clearSelection" | "none" | undefined;
|
|
30
33
|
shouldFocusWrap?: boolean | undefined;
|
|
31
34
|
selectionMode?: import('react-aria-components').SelectionMode | undefined;
|
|
32
35
|
selectedKeys?: ("all" | Iterable<import('react-aria-components').Key>) | undefined;
|
package/number.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
package/number.mjs
ADDED
|
@@ -0,0 +1,875 @@
|
|
|
1
|
+
import { jsx as ze } from "react/jsx-runtime";
|
|
2
|
+
import * as A from "react";
|
|
3
|
+
import { useMemo as V, useContext as We, createContext as qe, useState as F, useRef as ue, useEffect as Ue, useCallback as Ge, forwardRef as Be } from "react";
|
|
4
|
+
import { useNumberField as Ze } from "react-aria";
|
|
5
|
+
import { Input as Xe } from "@equinor/eds-core-react";
|
|
6
|
+
import { $ as He } from "./useControlledState-u436Wbp1.mjs";
|
|
7
|
+
function ie(r, t = -1 / 0, e = 1 / 0) {
|
|
8
|
+
return Math.min(Math.max(r, t), e);
|
|
9
|
+
}
|
|
10
|
+
function Z(r, t) {
|
|
11
|
+
let e = r, i = t.toString(), o = i.indexOf("."), a = o >= 0 ? i.length - o : 0;
|
|
12
|
+
if (a > 0) {
|
|
13
|
+
let s = Math.pow(10, a);
|
|
14
|
+
e = Math.round(e * s) / s;
|
|
15
|
+
}
|
|
16
|
+
return e;
|
|
17
|
+
}
|
|
18
|
+
function D(r, t, e, i) {
|
|
19
|
+
t = Number(t), e = Number(e);
|
|
20
|
+
let o = (r - (isNaN(t) ? 0 : t)) % i, a = Z(Math.abs(o) * 2 >= i ? r + Math.sign(o) * (i - Math.abs(o)) : r - o, i);
|
|
21
|
+
return isNaN(t) ? !isNaN(e) && a > e && (a = Math.floor(Z(e / i, i)) * i) : a < t ? a = t : !isNaN(e) && a > e && (a = t + Math.floor(Z((e - t) / i, i)) * i), a = Z(a, i), a;
|
|
22
|
+
}
|
|
23
|
+
const Re = {
|
|
24
|
+
badInput: !1,
|
|
25
|
+
customError: !1,
|
|
26
|
+
patternMismatch: !1,
|
|
27
|
+
rangeOverflow: !1,
|
|
28
|
+
rangeUnderflow: !1,
|
|
29
|
+
stepMismatch: !1,
|
|
30
|
+
tooLong: !1,
|
|
31
|
+
tooShort: !1,
|
|
32
|
+
typeMismatch: !1,
|
|
33
|
+
valueMissing: !1,
|
|
34
|
+
valid: !0
|
|
35
|
+
}, Ce = {
|
|
36
|
+
...Re,
|
|
37
|
+
customError: !0,
|
|
38
|
+
valid: !1
|
|
39
|
+
}, j = {
|
|
40
|
+
isInvalid: !1,
|
|
41
|
+
validationDetails: Re,
|
|
42
|
+
validationErrors: []
|
|
43
|
+
}, Ke = qe({}), ge = "__formValidationState" + Date.now();
|
|
44
|
+
function Qe(r) {
|
|
45
|
+
if (r[ge]) {
|
|
46
|
+
let { realtimeValidation: t, displayValidation: e, updateValidation: i, resetValidation: o, commitValidation: a } = r[ge];
|
|
47
|
+
return {
|
|
48
|
+
realtimeValidation: t,
|
|
49
|
+
displayValidation: e,
|
|
50
|
+
updateValidation: i,
|
|
51
|
+
resetValidation: o,
|
|
52
|
+
commitValidation: a
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return Je(r);
|
|
56
|
+
}
|
|
57
|
+
function Je(r) {
|
|
58
|
+
let { isInvalid: t, validationState: e, name: i, value: o, builtinValidation: a, validate: s, validationBehavior: u = "aria" } = r;
|
|
59
|
+
e && (t || (t = e === "invalid"));
|
|
60
|
+
let f = t !== void 0 ? {
|
|
61
|
+
isInvalid: t,
|
|
62
|
+
validationErrors: [],
|
|
63
|
+
validationDetails: Ce
|
|
64
|
+
} : null, g = V(() => {
|
|
65
|
+
if (!s || o == null) return null;
|
|
66
|
+
let c = ke(s, o);
|
|
67
|
+
return $e(c);
|
|
68
|
+
}, [
|
|
69
|
+
s,
|
|
70
|
+
o
|
|
71
|
+
]);
|
|
72
|
+
a != null && a.validationDetails.valid && (a = void 0);
|
|
73
|
+
let $ = We(Ke), y = V(() => i ? Array.isArray(i) ? i.flatMap((c) => ce($[c])) : ce($[i]) : [], [
|
|
74
|
+
$,
|
|
75
|
+
i
|
|
76
|
+
]), [N, h] = F($), [m, S] = F(!1);
|
|
77
|
+
$ !== N && (h($), S(!1));
|
|
78
|
+
let _ = V(() => $e(m ? [] : y), [
|
|
79
|
+
m,
|
|
80
|
+
y
|
|
81
|
+
]), P = ue(j), [x, p] = F(j), d = ue(j), n = () => {
|
|
82
|
+
if (!T) return;
|
|
83
|
+
R(!1);
|
|
84
|
+
let c = g || a || P.current;
|
|
85
|
+
ae(c, d.current) || (d.current = c, p(c));
|
|
86
|
+
}, [T, R] = F(!1);
|
|
87
|
+
return Ue(n), {
|
|
88
|
+
realtimeValidation: f || _ || g || a || j,
|
|
89
|
+
displayValidation: u === "native" ? f || _ || x : f || _ || g || a || x,
|
|
90
|
+
updateValidation(c) {
|
|
91
|
+
u === "aria" && !ae(x, c) ? p(c) : P.current = c;
|
|
92
|
+
},
|
|
93
|
+
resetValidation() {
|
|
94
|
+
let c = j;
|
|
95
|
+
ae(c, d.current) || (d.current = c, p(c)), u === "native" && R(!1), S(!0);
|
|
96
|
+
},
|
|
97
|
+
commitValidation() {
|
|
98
|
+
u === "native" && R(!0), S(!0);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function ce(r) {
|
|
103
|
+
return r ? Array.isArray(r) ? r : [
|
|
104
|
+
r
|
|
105
|
+
] : [];
|
|
106
|
+
}
|
|
107
|
+
function ke(r, t) {
|
|
108
|
+
if (typeof r == "function") {
|
|
109
|
+
let e = r(t);
|
|
110
|
+
if (e && typeof e != "boolean") return ce(e);
|
|
111
|
+
}
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
function $e(r) {
|
|
115
|
+
return r.length ? {
|
|
116
|
+
isInvalid: !0,
|
|
117
|
+
validationErrors: r,
|
|
118
|
+
validationDetails: Ce
|
|
119
|
+
} : null;
|
|
120
|
+
}
|
|
121
|
+
function ae(r, t) {
|
|
122
|
+
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);
|
|
123
|
+
}
|
|
124
|
+
let ne = /* @__PURE__ */ new Map(), fe = !1;
|
|
125
|
+
try {
|
|
126
|
+
fe = new Intl.NumberFormat("de-DE", {
|
|
127
|
+
signDisplay: "exceptZero"
|
|
128
|
+
}).resolvedOptions().signDisplay === "exceptZero";
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
131
|
+
let H = !1;
|
|
132
|
+
try {
|
|
133
|
+
H = new Intl.NumberFormat("de-DE", {
|
|
134
|
+
style: "unit",
|
|
135
|
+
unit: "degree"
|
|
136
|
+
}).resolvedOptions().style === "unit";
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
const Ve = {
|
|
140
|
+
degree: {
|
|
141
|
+
narrow: {
|
|
142
|
+
default: "°",
|
|
143
|
+
"ja-JP": " 度",
|
|
144
|
+
"zh-TW": "度",
|
|
145
|
+
"sl-SI": " °"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
class me {
|
|
150
|
+
/** Formats a number value as a string, according to the locale and options provided to the constructor. */
|
|
151
|
+
format(t) {
|
|
152
|
+
let e = "";
|
|
153
|
+
if (!fe && this.options.signDisplay != null ? e = tt(this.numberFormatter, this.options.signDisplay, t) : e = this.numberFormatter.format(t), this.options.style === "unit" && !H) {
|
|
154
|
+
var i;
|
|
155
|
+
let { unit: o, unitDisplay: a = "short", locale: s } = this.resolvedOptions();
|
|
156
|
+
if (!o) return e;
|
|
157
|
+
let u = (i = Ve[o]) === null || i === void 0 ? void 0 : i[a];
|
|
158
|
+
e += u[s] || u.default;
|
|
159
|
+
}
|
|
160
|
+
return e;
|
|
161
|
+
}
|
|
162
|
+
/** Formats a number to an array of parts such as separators, digits, punctuation, and more. */
|
|
163
|
+
formatToParts(t) {
|
|
164
|
+
return this.numberFormatter.formatToParts(t);
|
|
165
|
+
}
|
|
166
|
+
/** Formats a number range as a string. */
|
|
167
|
+
formatRange(t, e) {
|
|
168
|
+
if (typeof this.numberFormatter.formatRange == "function") return this.numberFormatter.formatRange(t, e);
|
|
169
|
+
if (e < t) throw new RangeError("End date must be >= start date");
|
|
170
|
+
return `${this.format(t)} – ${this.format(e)}`;
|
|
171
|
+
}
|
|
172
|
+
/** Formats a number range as an array of parts. */
|
|
173
|
+
formatRangeToParts(t, e) {
|
|
174
|
+
if (typeof this.numberFormatter.formatRangeToParts == "function") return this.numberFormatter.formatRangeToParts(t, e);
|
|
175
|
+
if (e < t) throw new RangeError("End date must be >= start date");
|
|
176
|
+
let i = this.numberFormatter.formatToParts(t), o = this.numberFormatter.formatToParts(e);
|
|
177
|
+
return [
|
|
178
|
+
...i.map((a) => ({
|
|
179
|
+
...a,
|
|
180
|
+
source: "startRange"
|
|
181
|
+
})),
|
|
182
|
+
{
|
|
183
|
+
type: "literal",
|
|
184
|
+
value: " – ",
|
|
185
|
+
source: "shared"
|
|
186
|
+
},
|
|
187
|
+
...o.map((a) => ({
|
|
188
|
+
...a,
|
|
189
|
+
source: "endRange"
|
|
190
|
+
}))
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
/** Returns the resolved formatting options based on the values passed to the constructor. */
|
|
194
|
+
resolvedOptions() {
|
|
195
|
+
let t = this.numberFormatter.resolvedOptions();
|
|
196
|
+
return !fe && this.options.signDisplay != null && (t = {
|
|
197
|
+
...t,
|
|
198
|
+
signDisplay: this.options.signDisplay
|
|
199
|
+
}), !H && this.options.style === "unit" && (t = {
|
|
200
|
+
...t,
|
|
201
|
+
style: "unit",
|
|
202
|
+
unit: this.options.unit,
|
|
203
|
+
unitDisplay: this.options.unitDisplay
|
|
204
|
+
}), t;
|
|
205
|
+
}
|
|
206
|
+
constructor(t, e = {}) {
|
|
207
|
+
this.numberFormatter = et(t, e), this.options = e;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function et(r, t = {}) {
|
|
211
|
+
let { numberingSystem: e } = t;
|
|
212
|
+
if (e && r.includes("-nu-") && (r.includes("-u-") || (r += "-u-"), r += `-nu-${e}`), t.style === "unit" && !H) {
|
|
213
|
+
var i;
|
|
214
|
+
let { unit: s, unitDisplay: u = "short" } = t;
|
|
215
|
+
if (!s) throw new Error('unit option must be provided with style: "unit"');
|
|
216
|
+
if (!(!((i = Ve[s]) === null || i === void 0) && i[u])) throw new Error(`Unsupported unit ${s} with unitDisplay = ${u}`);
|
|
217
|
+
t = {
|
|
218
|
+
...t,
|
|
219
|
+
style: "decimal"
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
let o = r + (t ? Object.entries(t).sort((s, u) => s[0] < u[0] ? -1 : 1).join() : "");
|
|
223
|
+
if (ne.has(o)) return ne.get(o);
|
|
224
|
+
let a = new Intl.NumberFormat(r, t);
|
|
225
|
+
return ne.set(o, a), a;
|
|
226
|
+
}
|
|
227
|
+
function tt(r, t, e) {
|
|
228
|
+
if (t === "auto") return r.format(e);
|
|
229
|
+
if (t === "never") return r.format(Math.abs(e));
|
|
230
|
+
{
|
|
231
|
+
let i = !1;
|
|
232
|
+
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) {
|
|
233
|
+
let o = r.format(-e), a = r.format(e), s = o.replace(a, "").replace(/\u200e|\u061C/, "");
|
|
234
|
+
return [
|
|
235
|
+
...s
|
|
236
|
+
].length !== 1 && console.warn("@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case"), o.replace(a, "!!!").replace(s, "+").replace("!!!", a);
|
|
237
|
+
} else return r.format(e);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const rt = new RegExp("^.*\\(.*\\).*$"), it = [
|
|
241
|
+
"latn",
|
|
242
|
+
"arab",
|
|
243
|
+
"hanidec",
|
|
244
|
+
"deva",
|
|
245
|
+
"beng"
|
|
246
|
+
];
|
|
247
|
+
class De {
|
|
248
|
+
/**
|
|
249
|
+
* Parses the given string to a number. Returns NaN if a valid number could not be parsed.
|
|
250
|
+
*/
|
|
251
|
+
parse(t) {
|
|
252
|
+
return oe(this.locale, this.options, t).parse(t);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Returns whether the given string could potentially be a valid number. This should be used to
|
|
256
|
+
* validate user input as the user types. If a `minValue` or `maxValue` is provided, the validity
|
|
257
|
+
* of the minus/plus sign characters can be checked.
|
|
258
|
+
*/
|
|
259
|
+
isValidPartialNumber(t, e, i) {
|
|
260
|
+
return oe(this.locale, this.options, t).isValidPartialNumber(t, e, i);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Returns a numbering system for which the given string is valid in the current locale.
|
|
264
|
+
* If no numbering system could be detected, the default numbering system for the current
|
|
265
|
+
* locale is returned.
|
|
266
|
+
*/
|
|
267
|
+
getNumberingSystem(t) {
|
|
268
|
+
return oe(this.locale, this.options, t).options.numberingSystem;
|
|
269
|
+
}
|
|
270
|
+
constructor(t, e = {}) {
|
|
271
|
+
this.locale = t, this.options = e;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const Se = /* @__PURE__ */ new Map();
|
|
275
|
+
function oe(r, t, e) {
|
|
276
|
+
let i = Ee(r, t);
|
|
277
|
+
if (!r.includes("-nu-") && !i.isValidPartialNumber(e)) {
|
|
278
|
+
for (let o of it) if (o !== i.options.numberingSystem) {
|
|
279
|
+
let a = Ee(r + (r.includes("-u-") ? "-nu-" : "-u-nu-") + o, t);
|
|
280
|
+
if (a.isValidPartialNumber(e)) return a;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return i;
|
|
284
|
+
}
|
|
285
|
+
function Ee(r, t) {
|
|
286
|
+
let e = r + (t ? Object.entries(t).sort((o, a) => o[0] < a[0] ? -1 : 1).join() : ""), i = Se.get(e);
|
|
287
|
+
return i || (i = new at(r, t), Se.set(e, i)), i;
|
|
288
|
+
}
|
|
289
|
+
class at {
|
|
290
|
+
parse(t) {
|
|
291
|
+
let e = this.sanitize(t);
|
|
292
|
+
if (this.symbols.group && (e = Y(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") {
|
|
293
|
+
let s = e.indexOf("-");
|
|
294
|
+
e = e.replace("-", ""), e = e.replace("+", "");
|
|
295
|
+
let u = e.indexOf(".");
|
|
296
|
+
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}`);
|
|
297
|
+
}
|
|
298
|
+
let i = e ? +e : NaN;
|
|
299
|
+
if (isNaN(i)) return NaN;
|
|
300
|
+
if (this.options.style === "percent") {
|
|
301
|
+
var o, a;
|
|
302
|
+
let s = {
|
|
303
|
+
...this.options,
|
|
304
|
+
style: "decimal",
|
|
305
|
+
minimumFractionDigits: Math.min(((o = this.options.minimumFractionDigits) !== null && o !== void 0 ? o : 0) + 2, 20),
|
|
306
|
+
maximumFractionDigits: Math.min(((a = this.options.maximumFractionDigits) !== null && a !== void 0 ? a : 0) + 2, 20)
|
|
307
|
+
};
|
|
308
|
+
return new De(this.locale, s).parse(new me(this.locale, s).format(i));
|
|
309
|
+
}
|
|
310
|
+
return this.options.currencySign === "accounting" && rt.test(t) && (i = -1 * i), i;
|
|
311
|
+
}
|
|
312
|
+
sanitize(t) {
|
|
313
|
+
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 = Y(t, ".", this.symbols.group))), this.options.locale === "fr-FR" && this.symbols.group && (t = Y(t, " ", this.symbols.group), t = Y(t, /\u00A0/g, this.symbols.group)), t;
|
|
314
|
+
}
|
|
315
|
+
isValidPartialNumber(t, e = -1 / 0, i = 1 / 0) {
|
|
316
|
+
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 = Y(t, this.symbols.group, "")), t = t.replace(this.symbols.numeral, ""), this.symbols.decimal && (t = t.replace(this.symbols.decimal, "")), t.length === 0);
|
|
317
|
+
}
|
|
318
|
+
constructor(t, e = {}) {
|
|
319
|
+
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 = ot(t, this.formatter, this.options, e);
|
|
320
|
+
var i, o;
|
|
321
|
+
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.");
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const Ne = /* @__PURE__ */ new Set([
|
|
325
|
+
"decimal",
|
|
326
|
+
"fraction",
|
|
327
|
+
"integer",
|
|
328
|
+
"minusSign",
|
|
329
|
+
"plusSign",
|
|
330
|
+
"group"
|
|
331
|
+
]), nt = [
|
|
332
|
+
0,
|
|
333
|
+
4,
|
|
334
|
+
2,
|
|
335
|
+
1,
|
|
336
|
+
11,
|
|
337
|
+
20,
|
|
338
|
+
3,
|
|
339
|
+
7,
|
|
340
|
+
100,
|
|
341
|
+
21,
|
|
342
|
+
0.1,
|
|
343
|
+
1.1
|
|
344
|
+
];
|
|
345
|
+
function ot(r, t, e, i) {
|
|
346
|
+
var o, a, s, u;
|
|
347
|
+
let f = new Intl.NumberFormat(r, {
|
|
348
|
+
...e,
|
|
349
|
+
// Resets so we get the full range of symbols
|
|
350
|
+
minimumSignificantDigits: 1,
|
|
351
|
+
maximumSignificantDigits: 21,
|
|
352
|
+
roundingIncrement: 1,
|
|
353
|
+
roundingPriority: "auto",
|
|
354
|
+
roundingMode: "halfExpand"
|
|
355
|
+
}), g = f.formatToParts(-10000.111), $ = f.formatToParts(10000.111), y = nt.map((c) => f.formatToParts(c));
|
|
356
|
+
var N;
|
|
357
|
+
let h = (N = (o = g.find((c) => c.type === "minusSign")) === null || o === void 0 ? void 0 : o.value) !== null && N !== void 0 ? N : "-", m = (a = $.find((c) => c.type === "plusSign")) === null || a === void 0 ? void 0 : a.value;
|
|
358
|
+
!m && ((i == null ? void 0 : i.signDisplay) === "exceptZero" || (i == null ? void 0 : i.signDisplay) === "always") && (m = "+");
|
|
359
|
+
let _ = (s = new Intl.NumberFormat(r, {
|
|
360
|
+
...e,
|
|
361
|
+
minimumFractionDigits: 2,
|
|
362
|
+
maximumFractionDigits: 2
|
|
363
|
+
}).formatToParts(1e-3).find((c) => c.type === "decimal")) === null || s === void 0 ? void 0 : s.value, P = (u = g.find((c) => c.type === "group")) === null || u === void 0 ? void 0 : u.value, x = g.filter((c) => !Ne.has(c.type)).map((c) => Pe(c.value)), p = y.flatMap((c) => c.filter((C) => !Ne.has(C.type)).map((C) => Pe(C.value))), d = [
|
|
364
|
+
.../* @__PURE__ */ new Set([
|
|
365
|
+
...x,
|
|
366
|
+
...p
|
|
367
|
+
])
|
|
368
|
+
].sort((c, C) => C.length - c.length), n = d.length === 0 ? new RegExp("[\\p{White_Space}]", "gu") : new RegExp(`${d.join("|")}|[\\p{White_Space}]`, "gu"), T = [
|
|
369
|
+
...new Intl.NumberFormat(e.locale, {
|
|
370
|
+
useGrouping: !1
|
|
371
|
+
}).format(9876543210)
|
|
372
|
+
].reverse(), R = new Map(T.map((c, C) => [
|
|
373
|
+
c,
|
|
374
|
+
C
|
|
375
|
+
])), O = new RegExp(`[${T.join("")}]`, "g");
|
|
376
|
+
return {
|
|
377
|
+
minusSign: h,
|
|
378
|
+
plusSign: m,
|
|
379
|
+
decimal: _,
|
|
380
|
+
group: P,
|
|
381
|
+
literals: n,
|
|
382
|
+
numeral: O,
|
|
383
|
+
index: (c) => String(R.get(c))
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function Y(r, t, e) {
|
|
387
|
+
return r.replaceAll ? r.replaceAll(t, e) : r.split(t).join(e);
|
|
388
|
+
}
|
|
389
|
+
function Pe(r) {
|
|
390
|
+
return r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
391
|
+
}
|
|
392
|
+
function st(r) {
|
|
393
|
+
let { minValue: t, maxValue: e, step: i, formatOptions: o, value: a, defaultValue: s = NaN, onChange: u, locale: f, isDisabled: g, isReadOnly: $ } = r;
|
|
394
|
+
a === null && (a = NaN), a !== void 0 && !isNaN(a) && (i !== void 0 && !isNaN(i) ? a = D(a, t, e, i) : a = ie(a, t, e)), isNaN(s) || (i !== void 0 && !isNaN(i) ? s = D(s, t, e, i) : s = ie(s, t, e));
|
|
395
|
+
let [y, N] = He(a, isNaN(s) ? NaN : s, u), [h, m] = F(() => isNaN(y) ? "" : new me(f, o).format(y)), S = V(() => new De(f, o), [
|
|
396
|
+
f,
|
|
397
|
+
o
|
|
398
|
+
]), _ = V(() => S.getNumberingSystem(h), [
|
|
399
|
+
S,
|
|
400
|
+
h
|
|
401
|
+
]), P = V(() => new me(f, {
|
|
402
|
+
...o,
|
|
403
|
+
numberingSystem: _
|
|
404
|
+
}), [
|
|
405
|
+
f,
|
|
406
|
+
o,
|
|
407
|
+
_
|
|
408
|
+
]), x = V(() => P.resolvedOptions(), [
|
|
409
|
+
P
|
|
410
|
+
]), p = Ge((E) => isNaN(E) || E === null ? "" : P.format(E), [
|
|
411
|
+
P
|
|
412
|
+
]), d = Qe({
|
|
413
|
+
...r,
|
|
414
|
+
value: y
|
|
415
|
+
}), n = i !== void 0 && !isNaN(i) ? i : 1;
|
|
416
|
+
x.style === "percent" && (i === void 0 || isNaN(i)) && (n = 0.01);
|
|
417
|
+
let [T, R] = F(y), [O, L] = F(f), [c, C] = F(o);
|
|
418
|
+
(!Object.is(y, T) || f !== O || o !== c) && (m(p(y)), R(y), L(f), C(o));
|
|
419
|
+
let w = V(() => S.parse(h), [
|
|
420
|
+
S,
|
|
421
|
+
h
|
|
422
|
+
]), Q = () => {
|
|
423
|
+
if (!h.length) {
|
|
424
|
+
N(NaN), m(a === void 0 ? "" : p(y));
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (isNaN(w)) {
|
|
428
|
+
m(p(y));
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
let E;
|
|
432
|
+
i === void 0 || isNaN(i) ? E = ie(w, t, e) : E = D(w, t, e, i), E = S.parse(p(E)), N(E), m(p(a === void 0 ? E : y));
|
|
433
|
+
}, W = (E, G = 0) => {
|
|
434
|
+
let M = w;
|
|
435
|
+
if (isNaN(M)) {
|
|
436
|
+
let I = isNaN(G) ? 0 : G;
|
|
437
|
+
return D(I, t, e, n);
|
|
438
|
+
} else {
|
|
439
|
+
let I = D(M, t, e, n);
|
|
440
|
+
return E === "+" && I > M || E === "-" && I < M ? I : D(se(E, M, n), t, e, n);
|
|
441
|
+
}
|
|
442
|
+
}, J = () => {
|
|
443
|
+
let E = W("+", t);
|
|
444
|
+
E === y && m(p(E)), N(E), d.commitValidation();
|
|
445
|
+
}, k = () => {
|
|
446
|
+
let E = W("-", e);
|
|
447
|
+
E === y && m(p(E)), N(E), d.commitValidation();
|
|
448
|
+
}, ee = () => {
|
|
449
|
+
e != null && (N(D(e, t, e, n)), d.commitValidation());
|
|
450
|
+
}, q = () => {
|
|
451
|
+
t != null && (N(t), d.commitValidation());
|
|
452
|
+
}, te = V(() => !g && !$ && (isNaN(w) || e === void 0 || isNaN(e) || D(w, t, e, n) > w || se("+", w, n) <= e), [
|
|
453
|
+
g,
|
|
454
|
+
$,
|
|
455
|
+
t,
|
|
456
|
+
e,
|
|
457
|
+
n,
|
|
458
|
+
w
|
|
459
|
+
]), U = V(() => !g && !$ && (isNaN(w) || t === void 0 || isNaN(t) || D(w, t, e, n) < w || se("-", w, n) >= t), [
|
|
460
|
+
g,
|
|
461
|
+
$,
|
|
462
|
+
t,
|
|
463
|
+
e,
|
|
464
|
+
n,
|
|
465
|
+
w
|
|
466
|
+
]);
|
|
467
|
+
return {
|
|
468
|
+
...d,
|
|
469
|
+
validate: (E) => S.isValidPartialNumber(E, t, e),
|
|
470
|
+
increment: J,
|
|
471
|
+
incrementToMax: ee,
|
|
472
|
+
decrement: k,
|
|
473
|
+
decrementToMin: q,
|
|
474
|
+
canIncrement: te,
|
|
475
|
+
canDecrement: U,
|
|
476
|
+
minValue: t,
|
|
477
|
+
maxValue: e,
|
|
478
|
+
numberValue: w,
|
|
479
|
+
setNumberValue: N,
|
|
480
|
+
setInputValue: m,
|
|
481
|
+
inputValue: h,
|
|
482
|
+
commit: Q
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function se(r, t, e) {
|
|
486
|
+
let i = r === "+" ? t + e : t - e;
|
|
487
|
+
if (t % 1 !== 0 || e % 1 !== 0) {
|
|
488
|
+
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));
|
|
489
|
+
t = Math.round(t * f), e = Math.round(e * f), i = r === "+" ? t + e : t - e, i /= f;
|
|
490
|
+
}
|
|
491
|
+
return i;
|
|
492
|
+
}
|
|
493
|
+
var K = function() {
|
|
494
|
+
return K = Object.assign || function(t) {
|
|
495
|
+
for (var e, i = 1, o = arguments.length; i < o; i++) {
|
|
496
|
+
e = arguments[i];
|
|
497
|
+
for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && (t[a] = e[a]);
|
|
498
|
+
}
|
|
499
|
+
return t;
|
|
500
|
+
}, K.apply(this, arguments);
|
|
501
|
+
};
|
|
502
|
+
function Fe(r, t) {
|
|
503
|
+
var e = {};
|
|
504
|
+
for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && t.indexOf(i) < 0 && (e[i] = r[i]);
|
|
505
|
+
if (r != null && typeof Object.getOwnPropertySymbols == "function")
|
|
506
|
+
for (var o = 0, i = Object.getOwnPropertySymbols(r); o < i.length; o++)
|
|
507
|
+
t.indexOf(i[o]) < 0 && Object.prototype.propertyIsEnumerable.call(r, i[o]) && (e[i[o]] = r[i[o]]);
|
|
508
|
+
return e;
|
|
509
|
+
}
|
|
510
|
+
var X = { exports: {} }, b = {};
|
|
511
|
+
/** @license React v16.13.1
|
|
512
|
+
* react-is.production.min.js
|
|
513
|
+
*
|
|
514
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
515
|
+
*
|
|
516
|
+
* This source code is licensed under the MIT license found in the
|
|
517
|
+
* LICENSE file in the root directory of this source tree.
|
|
518
|
+
*/
|
|
519
|
+
var Te;
|
|
520
|
+
function lt() {
|
|
521
|
+
if (Te) return b;
|
|
522
|
+
Te = 1;
|
|
523
|
+
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, N = 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, _ = r ? Symbol.for("react.fundamental") : 60117, P = r ? Symbol.for("react.responder") : 60118, x = r ? Symbol.for("react.scope") : 60119;
|
|
524
|
+
function p(n) {
|
|
525
|
+
if (typeof n == "object" && n !== null) {
|
|
526
|
+
var T = n.$$typeof;
|
|
527
|
+
switch (T) {
|
|
528
|
+
case t:
|
|
529
|
+
switch (n = n.type, n) {
|
|
530
|
+
case f:
|
|
531
|
+
case g:
|
|
532
|
+
case i:
|
|
533
|
+
case a:
|
|
534
|
+
case o:
|
|
535
|
+
case y:
|
|
536
|
+
return n;
|
|
537
|
+
default:
|
|
538
|
+
switch (n = n && n.$$typeof, n) {
|
|
539
|
+
case u:
|
|
540
|
+
case $:
|
|
541
|
+
case m:
|
|
542
|
+
case h:
|
|
543
|
+
case s:
|
|
544
|
+
return n;
|
|
545
|
+
default:
|
|
546
|
+
return T;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
case e:
|
|
550
|
+
return T;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
function d(n) {
|
|
555
|
+
return p(n) === g;
|
|
556
|
+
}
|
|
557
|
+
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) {
|
|
558
|
+
return d(n) || p(n) === f;
|
|
559
|
+
}, b.isConcurrentMode = d, b.isContextConsumer = function(n) {
|
|
560
|
+
return p(n) === u;
|
|
561
|
+
}, b.isContextProvider = function(n) {
|
|
562
|
+
return p(n) === s;
|
|
563
|
+
}, b.isElement = function(n) {
|
|
564
|
+
return typeof n == "object" && n !== null && n.$$typeof === t;
|
|
565
|
+
}, b.isForwardRef = function(n) {
|
|
566
|
+
return p(n) === $;
|
|
567
|
+
}, b.isFragment = function(n) {
|
|
568
|
+
return p(n) === i;
|
|
569
|
+
}, b.isLazy = function(n) {
|
|
570
|
+
return p(n) === m;
|
|
571
|
+
}, b.isMemo = function(n) {
|
|
572
|
+
return p(n) === h;
|
|
573
|
+
}, b.isPortal = function(n) {
|
|
574
|
+
return p(n) === e;
|
|
575
|
+
}, b.isProfiler = function(n) {
|
|
576
|
+
return p(n) === a;
|
|
577
|
+
}, b.isStrictMode = function(n) {
|
|
578
|
+
return p(n) === o;
|
|
579
|
+
}, b.isSuspense = function(n) {
|
|
580
|
+
return p(n) === y;
|
|
581
|
+
}, b.isValidElementType = function(n) {
|
|
582
|
+
return typeof n == "string" || typeof n == "function" || n === i || n === g || n === a || n === o || n === y || n === N || typeof n == "object" && n !== null && (n.$$typeof === m || n.$$typeof === h || n.$$typeof === s || n.$$typeof === u || n.$$typeof === $ || n.$$typeof === _ || n.$$typeof === P || n.$$typeof === x || n.$$typeof === S);
|
|
583
|
+
}, b.typeOf = p, b;
|
|
584
|
+
}
|
|
585
|
+
var v = {};
|
|
586
|
+
/** @license React v16.13.1
|
|
587
|
+
* react-is.development.js
|
|
588
|
+
*
|
|
589
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
590
|
+
*
|
|
591
|
+
* This source code is licensed under the MIT license found in the
|
|
592
|
+
* LICENSE file in the root directory of this source tree.
|
|
593
|
+
*/
|
|
594
|
+
var _e;
|
|
595
|
+
function ut() {
|
|
596
|
+
return _e || (_e = 1, process.env.NODE_ENV !== "production" && function() {
|
|
597
|
+
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, N = 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, _ = r ? Symbol.for("react.fundamental") : 60117, P = r ? Symbol.for("react.responder") : 60118, x = r ? Symbol.for("react.scope") : 60119;
|
|
598
|
+
function p(l) {
|
|
599
|
+
return typeof l == "string" || typeof l == "function" || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
600
|
+
l === i || l === g || l === a || l === o || l === y || l === N || typeof l == "object" && l !== null && (l.$$typeof === m || l.$$typeof === h || l.$$typeof === s || l.$$typeof === u || l.$$typeof === $ || l.$$typeof === _ || l.$$typeof === P || l.$$typeof === x || l.$$typeof === S);
|
|
601
|
+
}
|
|
602
|
+
function d(l) {
|
|
603
|
+
if (typeof l == "object" && l !== null) {
|
|
604
|
+
var re = l.$$typeof;
|
|
605
|
+
switch (re) {
|
|
606
|
+
case t:
|
|
607
|
+
var B = l.type;
|
|
608
|
+
switch (B) {
|
|
609
|
+
case f:
|
|
610
|
+
case g:
|
|
611
|
+
case i:
|
|
612
|
+
case a:
|
|
613
|
+
case o:
|
|
614
|
+
case y:
|
|
615
|
+
return B;
|
|
616
|
+
default:
|
|
617
|
+
var he = B && B.$$typeof;
|
|
618
|
+
switch (he) {
|
|
619
|
+
case u:
|
|
620
|
+
case $:
|
|
621
|
+
case m:
|
|
622
|
+
case h:
|
|
623
|
+
case s:
|
|
624
|
+
return he;
|
|
625
|
+
default:
|
|
626
|
+
return re;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
case e:
|
|
630
|
+
return re;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
var n = f, T = g, R = u, O = s, L = t, c = $, C = i, w = m, Q = h, W = e, J = a, k = o, ee = y, q = !1;
|
|
635
|
+
function te(l) {
|
|
636
|
+
return q || (q = !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.")), U(l) || d(l) === f;
|
|
637
|
+
}
|
|
638
|
+
function U(l) {
|
|
639
|
+
return d(l) === g;
|
|
640
|
+
}
|
|
641
|
+
function ve(l) {
|
|
642
|
+
return d(l) === u;
|
|
643
|
+
}
|
|
644
|
+
function E(l) {
|
|
645
|
+
return d(l) === s;
|
|
646
|
+
}
|
|
647
|
+
function G(l) {
|
|
648
|
+
return typeof l == "object" && l !== null && l.$$typeof === t;
|
|
649
|
+
}
|
|
650
|
+
function M(l) {
|
|
651
|
+
return d(l) === $;
|
|
652
|
+
}
|
|
653
|
+
function I(l) {
|
|
654
|
+
return d(l) === i;
|
|
655
|
+
}
|
|
656
|
+
function Me(l) {
|
|
657
|
+
return d(l) === m;
|
|
658
|
+
}
|
|
659
|
+
function Ie(l) {
|
|
660
|
+
return d(l) === h;
|
|
661
|
+
}
|
|
662
|
+
function Ae(l) {
|
|
663
|
+
return d(l) === e;
|
|
664
|
+
}
|
|
665
|
+
function Le(l) {
|
|
666
|
+
return d(l) === a;
|
|
667
|
+
}
|
|
668
|
+
function je(l) {
|
|
669
|
+
return d(l) === o;
|
|
670
|
+
}
|
|
671
|
+
function Ye(l) {
|
|
672
|
+
return d(l) === y;
|
|
673
|
+
}
|
|
674
|
+
v.AsyncMode = n, v.ConcurrentMode = T, v.ContextConsumer = R, v.ContextProvider = O, v.Element = L, v.ForwardRef = c, v.Fragment = C, v.Lazy = w, v.Memo = Q, v.Portal = W, v.Profiler = J, v.StrictMode = k, v.Suspense = ee, v.isAsyncMode = te, v.isConcurrentMode = U, v.isContextConsumer = ve, v.isContextProvider = E, v.isElement = G, v.isForwardRef = M, v.isFragment = I, v.isLazy = Me, v.isMemo = Ie, v.isPortal = Ae, v.isProfiler = Le, v.isStrictMode = je, v.isSuspense = Ye, v.isValidElementType = p, v.typeOf = d;
|
|
675
|
+
}()), v;
|
|
676
|
+
}
|
|
677
|
+
var xe;
|
|
678
|
+
function ct() {
|
|
679
|
+
return xe || (xe = 1, process.env.NODE_ENV === "production" ? X.exports = lt() : X.exports = ut()), X.exports;
|
|
680
|
+
}
|
|
681
|
+
var le, we;
|
|
682
|
+
function ft() {
|
|
683
|
+
if (we) return le;
|
|
684
|
+
we = 1;
|
|
685
|
+
var r = ct(), t = {
|
|
686
|
+
childContextTypes: !0,
|
|
687
|
+
contextType: !0,
|
|
688
|
+
contextTypes: !0,
|
|
689
|
+
defaultProps: !0,
|
|
690
|
+
displayName: !0,
|
|
691
|
+
getDefaultProps: !0,
|
|
692
|
+
getDerivedStateFromError: !0,
|
|
693
|
+
getDerivedStateFromProps: !0,
|
|
694
|
+
mixins: !0,
|
|
695
|
+
propTypes: !0,
|
|
696
|
+
type: !0
|
|
697
|
+
}, e = {
|
|
698
|
+
name: !0,
|
|
699
|
+
length: !0,
|
|
700
|
+
prototype: !0,
|
|
701
|
+
caller: !0,
|
|
702
|
+
callee: !0,
|
|
703
|
+
arguments: !0,
|
|
704
|
+
arity: !0
|
|
705
|
+
}, i = {
|
|
706
|
+
$$typeof: !0,
|
|
707
|
+
render: !0,
|
|
708
|
+
defaultProps: !0,
|
|
709
|
+
displayName: !0,
|
|
710
|
+
propTypes: !0
|
|
711
|
+
}, o = {
|
|
712
|
+
$$typeof: !0,
|
|
713
|
+
compare: !0,
|
|
714
|
+
defaultProps: !0,
|
|
715
|
+
displayName: !0,
|
|
716
|
+
propTypes: !0,
|
|
717
|
+
type: !0
|
|
718
|
+
}, a = {};
|
|
719
|
+
a[r.ForwardRef] = i, a[r.Memo] = o;
|
|
720
|
+
function s(m) {
|
|
721
|
+
return r.isMemo(m) ? o : a[m.$$typeof] || t;
|
|
722
|
+
}
|
|
723
|
+
var u = Object.defineProperty, f = Object.getOwnPropertyNames, g = Object.getOwnPropertySymbols, $ = Object.getOwnPropertyDescriptor, y = Object.getPrototypeOf, N = Object.prototype;
|
|
724
|
+
function h(m, S, _) {
|
|
725
|
+
if (typeof S != "string") {
|
|
726
|
+
if (N) {
|
|
727
|
+
var P = y(S);
|
|
728
|
+
P && P !== N && h(m, P, _);
|
|
729
|
+
}
|
|
730
|
+
var x = f(S);
|
|
731
|
+
g && (x = x.concat(g(S)));
|
|
732
|
+
for (var p = s(m), d = s(S), n = 0; n < x.length; ++n) {
|
|
733
|
+
var T = x[n];
|
|
734
|
+
if (!e[T] && !(_ && _[T]) && !(d && d[T]) && !(p && p[T])) {
|
|
735
|
+
var R = $(S, T);
|
|
736
|
+
try {
|
|
737
|
+
u(m, T, R);
|
|
738
|
+
} catch {
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
return m;
|
|
744
|
+
}
|
|
745
|
+
return le = h, le;
|
|
746
|
+
}
|
|
747
|
+
ft();
|
|
748
|
+
function mt(r, t, e) {
|
|
749
|
+
if (e === void 0 && (e = Error), !r)
|
|
750
|
+
throw new e(t);
|
|
751
|
+
}
|
|
752
|
+
var dt = function(r) {
|
|
753
|
+
process.env.NODE_ENV !== "production" && console.error(r);
|
|
754
|
+
}, pt = function(r) {
|
|
755
|
+
process.env.NODE_ENV !== "production" && console.warn(r);
|
|
756
|
+
}, yt = {
|
|
757
|
+
formats: {},
|
|
758
|
+
messages: {},
|
|
759
|
+
timeZone: void 0,
|
|
760
|
+
defaultLocale: "en",
|
|
761
|
+
defaultFormats: {},
|
|
762
|
+
fallbackOnEmptyString: !0,
|
|
763
|
+
onError: dt,
|
|
764
|
+
onWarn: pt
|
|
765
|
+
};
|
|
766
|
+
function bt(r) {
|
|
767
|
+
mt(r, "[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.");
|
|
768
|
+
}
|
|
769
|
+
K(K({}, yt), { textComponent: A.Fragment });
|
|
770
|
+
var ye = typeof window < "u" && !window.__REACT_INTL_BYPASS_GLOBAL_CONTEXT__ ? window.__REACT_INTL_CONTEXT__ || (window.__REACT_INTL_CONTEXT__ = A.createContext(null)) : A.createContext(null);
|
|
771
|
+
ye.Consumer;
|
|
772
|
+
ye.Provider;
|
|
773
|
+
var vt = ye;
|
|
774
|
+
function be() {
|
|
775
|
+
var r = A.useContext(vt);
|
|
776
|
+
return bt(r), r;
|
|
777
|
+
}
|
|
778
|
+
var de;
|
|
779
|
+
(function(r) {
|
|
780
|
+
r.formatDate = "FormattedDate", r.formatTime = "FormattedTime", r.formatNumber = "FormattedNumber", r.formatList = "FormattedList", r.formatDisplayName = "FormattedDisplayName";
|
|
781
|
+
})(de || (de = {}));
|
|
782
|
+
var pe;
|
|
783
|
+
(function(r) {
|
|
784
|
+
r.formatDate = "FormattedDateParts", r.formatTime = "FormattedTimeParts", r.formatNumber = "FormattedNumberParts", r.formatList = "FormattedListParts";
|
|
785
|
+
})(pe || (pe = {}));
|
|
786
|
+
function Oe(r) {
|
|
787
|
+
var t = function(e) {
|
|
788
|
+
var i = be(), o = e.value, a = e.children, s = Fe(e, ["value", "children"]), u = typeof o == "string" ? new Date(o || 0) : o, f = r === "formatDate" ? i.formatDateToParts(u, s) : i.formatTimeToParts(u, s);
|
|
789
|
+
return a(f);
|
|
790
|
+
};
|
|
791
|
+
return t.displayName = pe[r], t;
|
|
792
|
+
}
|
|
793
|
+
function z(r) {
|
|
794
|
+
var t = function(e) {
|
|
795
|
+
var i = be(), o = e.value, a = e.children, s = Fe(
|
|
796
|
+
e,
|
|
797
|
+
["value", "children"]
|
|
798
|
+
), u = i[r](o, s);
|
|
799
|
+
if (typeof a == "function")
|
|
800
|
+
return a(u);
|
|
801
|
+
var f = i.textComponent || A.Fragment;
|
|
802
|
+
return A.createElement(f, null, u);
|
|
803
|
+
};
|
|
804
|
+
return t.displayName = de[r], t;
|
|
805
|
+
}
|
|
806
|
+
z("formatDate");
|
|
807
|
+
z("formatTime");
|
|
808
|
+
z("formatNumber");
|
|
809
|
+
z("formatList");
|
|
810
|
+
z("formatDisplayName");
|
|
811
|
+
Oe("formatDate");
|
|
812
|
+
Oe("formatTime");
|
|
813
|
+
const Nt = Be(
|
|
814
|
+
({
|
|
815
|
+
placeholder: r,
|
|
816
|
+
variant: t,
|
|
817
|
+
disabled: e,
|
|
818
|
+
type: i,
|
|
819
|
+
readOnly: o,
|
|
820
|
+
leftAdornments: a,
|
|
821
|
+
rightAdornments: s,
|
|
822
|
+
leftAdornmentsProps: u,
|
|
823
|
+
rightAdornmentsProps: f,
|
|
824
|
+
leftAdornmentsWidth: g,
|
|
825
|
+
rightAdornmentsWidth: $,
|
|
826
|
+
className: y,
|
|
827
|
+
style: N,
|
|
828
|
+
label: h,
|
|
829
|
+
value: m,
|
|
830
|
+
...S
|
|
831
|
+
}, _) => {
|
|
832
|
+
const { locale: P } = be(), x = st({
|
|
833
|
+
...S,
|
|
834
|
+
label: h,
|
|
835
|
+
value: m,
|
|
836
|
+
onChange: (n) => {
|
|
837
|
+
S.onChange && S.onChange(n);
|
|
838
|
+
},
|
|
839
|
+
locale: P
|
|
840
|
+
}), p = ue(null), { inputProps: d } = Ze(
|
|
841
|
+
{
|
|
842
|
+
...S,
|
|
843
|
+
label: h,
|
|
844
|
+
value: m
|
|
845
|
+
},
|
|
846
|
+
x,
|
|
847
|
+
p
|
|
848
|
+
);
|
|
849
|
+
return /* @__PURE__ */ ze(
|
|
850
|
+
Xe,
|
|
851
|
+
{
|
|
852
|
+
placeholder: r,
|
|
853
|
+
variant: t,
|
|
854
|
+
disabled: e,
|
|
855
|
+
type: i,
|
|
856
|
+
readOnly: o,
|
|
857
|
+
leftAdornments: a,
|
|
858
|
+
rightAdornments: s,
|
|
859
|
+
leftAdornmentsProps: u,
|
|
860
|
+
rightAdornmentsProps: f,
|
|
861
|
+
leftAdornmentsWidth: g,
|
|
862
|
+
rightAdornmentsWidth: $,
|
|
863
|
+
className: y,
|
|
864
|
+
style: N,
|
|
865
|
+
"data-testid": `number-field-${h}`,
|
|
866
|
+
...d,
|
|
867
|
+
ref: _,
|
|
868
|
+
"aria-label": h
|
|
869
|
+
}
|
|
870
|
+
);
|
|
871
|
+
}
|
|
872
|
+
);
|
|
873
|
+
export {
|
|
874
|
+
Nt as NumberField
|
|
875
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/roma-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./index.mjs",
|
|
7
7
|
"require": "./index.js"
|
|
8
8
|
},
|
|
9
|
+
"./number": {
|
|
10
|
+
"types": "./lib/NumberField/NumberField.d.ts",
|
|
11
|
+
"import": "./NumberField.mjs",
|
|
12
|
+
"require": "./NumberField.js"
|
|
13
|
+
},
|
|
9
14
|
"./switch": {
|
|
10
15
|
"types": "./lib/switch/Switch.d.ts",
|
|
11
16
|
"import": "./switch.mjs",
|
package/select.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("react-aria-components"),u=require("@equinor/eds-core-react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("react-aria-components"),u=require("@equinor/eds-core-react"),A=require("@equinor/eds-icons"),n=require("react"),e=require("@equinor/eds-tokens"),r=require("styled-components"),W=r(u.Typography)`
|
|
2
2
|
variant={'helper'};
|
|
3
3
|
group={$group};
|
|
4
4
|
margin-left: 8px;
|
|
@@ -147,4 +147,4 @@
|
|
|
147
147
|
cursor: pointer;
|
|
148
148
|
border-radius: 50%;
|
|
149
149
|
background-color: ${({$isHover:t})=>t?e.tokens.colors.interactive.primary__hover_alt.rgba:""};
|
|
150
|
-
`,G=n.forwardRef(function({children:t,variant:a,selected:d,onSelectedChange:l,label:g,helperText:y,placeholder:k,items:v,ariaLabel:w,disabledKeys:Q,disabled:m,readOnly:p,getValueText:$,onChange:h,showClearButton:X,...S},L){const[x,j]=n.useState(),{density:B,rootElement:I}=u.useEds(),T=n.useMemo(()=>d?`select-option-${d}`:x?`select-option-${x}`:"",[x,d]),q=n.useCallback(
|
|
150
|
+
`,G=n.forwardRef(function({children:t,variant:a,selected:d,onSelectedChange:l,label:g,helperText:y,placeholder:k,items:v,ariaLabel:w,disabledKeys:Q,disabled:m,readOnly:p,getValueText:$,onChange:h,showClearButton:X,...S},L){const[x,j]=n.useState(),{density:B,rootElement:I}=u.useEds(),T=n.useMemo(()=>d?`select-option-${d}`:x?`select-option-${x}`:"",[x,d]),q=n.useCallback(D=>{let c=(D??"").toString().replace("select-option-","");c===""&&(c=null),l?l(c):h?h({target:{value:c},currentTarget:{value:c}}):j(c)},[h,l]),E=n.useRef(),C=L??E,[H,M]=n.useState(!1),[R,b]=n.useState(!1),P=()=>{b(!0)},z=()=>{b(!1)};return o.jsxs(s.Wrapper,{onSelectionChange:q,selectedKey:T,$variant:a,autoComplete:"text",placeholder:k??" ",isOpen:p?!1:H,onOpenChange:M,isDisabled:m??p,"aria-label":w,...S,children:[g&&o.jsx(s.Label,{elementType:"label",children:g}),o.jsxs(s.Trigger,{ref:C,$density:B,$variant:a,$readonly:p??!1,"data-readonly":p,$hasLabel:!!g,children:[o.jsx(i.SelectValue,{children:$}),!p&&o.jsx(V,{onMouseEnter:P,onMouseLeave:z,$isHover:R,children:o.jsx(u.Icon,{size:24,data:A.arrow_drop_down,color:e.tokens.colors.interactive.primary__resting.rgba})})]}),o.jsx(s.Popover,{offset:4,UNSTABLE_portalContainer:I??document.body,children:o.jsx(s.ListBox,{items:v,children:t})}),o.jsx(_,{helperText:y})]})}),J=({value:t,children:a,item:d,...l})=>{const{density:g}=u.useEds();return o.jsx(s.ListBoxItem,{$density:g,id:`select-option-${t}`,value:d,isDisabled:l.disabled,...l,children:a})};exports.Option=J;exports.Select=G;exports.Styled=s;
|
package/switch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),o=require("react-aria"),f=require("react"),c=require("@equinor/eds-tokens"),y=require("@equinor/eds-core-react"),_=require("./useControlledState-D0L6S_5r.js");function k(t={}){let{isReadOnly:e}=t,[i,l]=_.$458b0a5536c1a7cf$export$40bfa8c7b0832715(t.isSelected,t.defaultSelected||!1,t.onChange);function d(u){e||l(u)}function h(){e||l(!i)}return{isSelected:i,setSelected:d,toggle:h}}const g={close:"M8.21967 9.28033C8.51256 9.57322 8.98744 9.57322 9.28033 9.28033C9.57322 8.98744 9.57322 8.51256 9.28033 8.21967L6.06066 5L9.28033 1.78033C9.57322 1.48744 9.57322 1.01256 9.28033 0.71967C8.98744 0.426777 8.51256 0.426777 8.21967 0.71967L5 3.93934L1.78033 0.71967C1.48744 0.426777 1.01256 0.426777 0.71967 0.71967C0.426777 1.01256 0.426777 1.48744 0.71967 1.78033L3.93934 5L0.71967 8.21967C0.426777 8.51256 0.426777 8.98744 0.71967 9.28033C1.01256 9.57322 1.48744 9.57322 1.78033 9.28033L5 6.06066L8.21967 9.28033Z",check:"M13.0303 4.21967C13.3232 4.51256 13.3232 4.98744 13.0303 5.28033L6.78033 11.5303C6.48744 11.8232 6.01256 11.8232 5.71967 11.5303L2.96967 8.78033C2.67678 8.48744 2.67678 8.01256 2.96967 7.71967C3.26256 7.42678 3.73744 7.42678 4.03033 7.71967L6.25 9.93934L11.9697 4.21967C12.2626 3.92678 12.7374 3.92678 13.0303 4.21967Z"};function v(t){const e={...t,isDisabled:t.isDisabled??t.disabled,isReadOnly:t.isReadOnly??t.readOnly,isSelected:t.isSelected??t.checked,defaultSelected:t.defaultSelected??t.defaultChecked},i=k(e),l=f.useRef(null),{inputProps:d}=o.useSwitch(e,i,l),{isFocusVisible:h,focusProps:u}=o.useFocusRing(),{isHovered:x,hoverProps:S}=o.useHover({isDisabled:!1}),{density:b}=y.useEds(),n=b==="compact",r=f.useMemo(()=>({ripple:c.tokens.colors.interactive.primary__hover_alt.rgba,background:i.isSelected?c.tokens.colors.interactive.primary__resting.hex:"rgba(220, 220, 220, 1)",circle:i.isSelected?c.tokens.colors.interactive.primary__hover_alt.hex:"rgba(111, 111, 111, 1)",icon:i.isSelected?c.tokens.colors.interactive.primary__resting.hex:"white",focus:c.tokens.colors.interactive.primary__resting.hex}),[i.isSelected]),p=n?32:48,C=n?4:12,a=n?0:8;return s.jsxs(y.Typography,{as:"label",variant:"text",group:"input",style:{display:"flex",alignItems:"center",width:"fit-content",color:e.isReadOnly||e.isDisabled?c.tokens.colors.text.static_icons__tertiary.rgba:c.tokens.colors.text.static_icons__default.rgba,cursor:e.isReadOnly||e.isDisabled?"not-allowed":"pointer"},children:[s.jsx(o.VisuallyHidden,{children:s.jsx("input",{...d,...u,ref:l})}),s.jsx("div",{style:{display:"inline",height:n?32:48},...S,children:s.jsxs("svg",{width:60,height:p,"aria-hidden":"true",style:{marginRight:4,opacity:e.isDisabled||e.isReadOnly?.4:1},children:[x&&!e.isDisabled&&!e.isReadOnly&&s.jsx("circle",{cx:i.isSelected?42:20,cy:16+a,r:n?16:20,fill:r.ripple}),s.jsx("rect",{x:8,y:C,width:46,height:24,rx:12,fill:r.background}),s.jsx("circle",{cx:i.isSelected?42:20,cy:16+a,r:9.5,fill:r.circle}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:i.isSelected?g.check:g.close,transform:`translate(${i.isSelected?32:14},${(i.isSelected?6:10)+a}) scale(1.2)`,fill:r.icon,style:{pointerEvents:"none"}}),h&&s.jsx("rect",{x:6,y:a,width:50,height:32,rx:12,fill:"none",strokeDasharray:2,stroke:r.focus,strokeWidth:2})]})}),e.children??e.label]})}exports.Switch=v;
|
package/switch.mjs
CHANGED
|
@@ -1,68 +1,43 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useSwitch as
|
|
3
|
-
import {
|
|
4
|
-
import { tokens as
|
|
5
|
-
import { useEds as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}, [
|
|
12
|
-
l
|
|
13
|
-
]);
|
|
14
|
-
let d = l ? e : o, b = v((c, ...s) => {
|
|
15
|
-
let n = (h, ...p) => {
|
|
16
|
-
i && (Object.is(d, h) || i(h, ...p)), l || (d = h);
|
|
17
|
-
};
|
|
18
|
-
typeof c == "function" ? (process.env.NODE_ENV !== "production" && console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"), f((p, ...y) => {
|
|
19
|
-
let g = c(l ? d : p, ...y);
|
|
20
|
-
return n(g, ...s), l ? p : g;
|
|
21
|
-
})) : (l || f(c), n(c, ...s));
|
|
22
|
-
}, [
|
|
23
|
-
l,
|
|
24
|
-
d,
|
|
25
|
-
i
|
|
26
|
-
]);
|
|
27
|
-
return [
|
|
28
|
-
d,
|
|
29
|
-
b
|
|
30
|
-
];
|
|
31
|
-
}
|
|
32
|
-
function E(e = {}) {
|
|
33
|
-
let { isReadOnly: t } = e, [i, o] = V(e.isSelected, e.defaultSelected || !1, e.onChange);
|
|
34
|
-
function f(l) {
|
|
35
|
-
t || o(l);
|
|
1
|
+
import { jsxs as h, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useSwitch as b, useFocusRing as x, useHover as _, VisuallyHidden as v } from "react-aria";
|
|
3
|
+
import { useRef as C, useMemo as R } from "react";
|
|
4
|
+
import { tokens as c } from "@equinor/eds-tokens";
|
|
5
|
+
import { useEds as L, Typography as k } from "@equinor/eds-core-react";
|
|
6
|
+
import { $ as O } from "./useControlledState-u436Wbp1.mjs";
|
|
7
|
+
function $(t = {}) {
|
|
8
|
+
let { isReadOnly: e } = t, [i, s] = O(t.isSelected, t.defaultSelected || !1, t.onChange);
|
|
9
|
+
function o(f) {
|
|
10
|
+
e || s(f);
|
|
36
11
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
12
|
+
function d() {
|
|
13
|
+
e || s(!i);
|
|
39
14
|
}
|
|
40
15
|
return {
|
|
41
16
|
isSelected: i,
|
|
42
|
-
setSelected:
|
|
43
|
-
toggle:
|
|
17
|
+
setSelected: o,
|
|
18
|
+
toggle: d
|
|
44
19
|
};
|
|
45
20
|
}
|
|
46
|
-
const
|
|
21
|
+
const y = {
|
|
47
22
|
close: "M8.21967 9.28033C8.51256 9.57322 8.98744 9.57322 9.28033 9.28033C9.57322 8.98744 9.57322 8.51256 9.28033 8.21967L6.06066 5L9.28033 1.78033C9.57322 1.48744 9.57322 1.01256 9.28033 0.71967C8.98744 0.426777 8.51256 0.426777 8.21967 0.71967L5 3.93934L1.78033 0.71967C1.48744 0.426777 1.01256 0.426777 0.71967 0.71967C0.426777 1.01256 0.426777 1.48744 0.71967 1.78033L3.93934 5L0.71967 8.21967C0.426777 8.51256 0.426777 8.98744 0.71967 9.28033C1.01256 9.57322 1.48744 9.57322 1.78033 9.28033L5 6.06066L8.21967 9.28033Z",
|
|
48
23
|
check: "M13.0303 4.21967C13.3232 4.51256 13.3232 4.98744 13.0303 5.28033L6.78033 11.5303C6.48744 11.8232 6.01256 11.8232 5.71967 11.5303L2.96967 8.78033C2.67678 8.48744 2.67678 8.01256 2.96967 7.71967C3.26256 7.42678 3.73744 7.42678 4.03033 7.71967L6.25 9.93934L11.9697 4.21967C12.2626 3.92678 12.7374 3.92678 13.0303 4.21967Z"
|
|
49
24
|
};
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
...
|
|
53
|
-
isDisabled:
|
|
54
|
-
isReadOnly:
|
|
55
|
-
isSelected:
|
|
56
|
-
defaultSelected:
|
|
57
|
-
}, i =
|
|
58
|
-
ripple:
|
|
59
|
-
background: i.isSelected ?
|
|
60
|
-
circle: i.isSelected ?
|
|
61
|
-
icon: i.isSelected ?
|
|
62
|
-
focus:
|
|
63
|
-
}), [i.isSelected]),
|
|
64
|
-
return /* @__PURE__ */
|
|
65
|
-
|
|
25
|
+
function F(t) {
|
|
26
|
+
const e = {
|
|
27
|
+
...t,
|
|
28
|
+
isDisabled: t.isDisabled ?? t.disabled,
|
|
29
|
+
isReadOnly: t.isReadOnly ?? t.readOnly,
|
|
30
|
+
isSelected: t.isSelected ?? t.checked,
|
|
31
|
+
defaultSelected: t.defaultSelected ?? t.defaultChecked
|
|
32
|
+
}, i = $(e), s = C(null), { inputProps: o } = b(e, i, s), { isFocusVisible: d, focusProps: f } = x(), { isHovered: u, hoverProps: g } = _({ isDisabled: !1 }), { density: p } = L(), r = p === "compact", n = R(() => ({
|
|
33
|
+
ripple: c.colors.interactive.primary__hover_alt.rgba,
|
|
34
|
+
background: i.isSelected ? c.colors.interactive.primary__resting.hex : "rgba(220, 220, 220, 1)",
|
|
35
|
+
circle: i.isSelected ? c.colors.interactive.primary__hover_alt.hex : "rgba(111, 111, 111, 1)",
|
|
36
|
+
icon: i.isSelected ? c.colors.interactive.primary__resting.hex : "white",
|
|
37
|
+
focus: c.colors.interactive.primary__resting.hex
|
|
38
|
+
}), [i.isSelected]), m = r ? 32 : 48, S = r ? 4 : 12, a = r ? 0 : 8;
|
|
39
|
+
return /* @__PURE__ */ h(
|
|
40
|
+
k,
|
|
66
41
|
{
|
|
67
42
|
as: "label",
|
|
68
43
|
variant: "text",
|
|
@@ -70,72 +45,73 @@ function W(e) {
|
|
|
70
45
|
style: {
|
|
71
46
|
display: "flex",
|
|
72
47
|
alignItems: "center",
|
|
73
|
-
|
|
74
|
-
|
|
48
|
+
width: "fit-content",
|
|
49
|
+
color: e.isReadOnly || e.isDisabled ? c.colors.text.static_icons__tertiary.rgba : c.colors.text.static_icons__default.rgba,
|
|
50
|
+
cursor: e.isReadOnly || e.isDisabled ? "not-allowed" : "pointer"
|
|
75
51
|
},
|
|
76
52
|
children: [
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
/* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ l(v, { children: /* @__PURE__ */ l("input", { ...o, ...f, ref: s }) }),
|
|
54
|
+
/* @__PURE__ */ l(
|
|
79
55
|
"div",
|
|
80
56
|
{
|
|
81
|
-
style: { display: "inline", height:
|
|
82
|
-
...
|
|
83
|
-
children: /* @__PURE__ */
|
|
57
|
+
style: { display: "inline", height: r ? 32 : 48 },
|
|
58
|
+
...g,
|
|
59
|
+
children: /* @__PURE__ */ h(
|
|
84
60
|
"svg",
|
|
85
61
|
{
|
|
86
62
|
width: 60,
|
|
87
|
-
height:
|
|
63
|
+
height: m,
|
|
88
64
|
"aria-hidden": "true",
|
|
89
65
|
style: {
|
|
90
66
|
marginRight: 4,
|
|
91
|
-
opacity:
|
|
67
|
+
opacity: e.isDisabled || e.isReadOnly ? 0.4 : 1
|
|
92
68
|
},
|
|
93
69
|
children: [
|
|
94
|
-
|
|
70
|
+
u && !e.isDisabled && !e.isReadOnly && /* @__PURE__ */ l(
|
|
95
71
|
"circle",
|
|
96
72
|
{
|
|
97
73
|
cx: i.isSelected ? 42 : 20,
|
|
98
|
-
cy: 16 +
|
|
99
|
-
r:
|
|
74
|
+
cy: 16 + a,
|
|
75
|
+
r: r ? 16 : 20,
|
|
100
76
|
fill: n.ripple
|
|
101
77
|
}
|
|
102
78
|
),
|
|
103
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ l(
|
|
104
80
|
"rect",
|
|
105
81
|
{
|
|
106
82
|
x: 8,
|
|
107
|
-
y:
|
|
83
|
+
y: S,
|
|
108
84
|
width: 46,
|
|
109
85
|
height: 24,
|
|
110
86
|
rx: 12,
|
|
111
87
|
fill: n.background
|
|
112
88
|
}
|
|
113
89
|
),
|
|
114
|
-
/* @__PURE__ */
|
|
90
|
+
/* @__PURE__ */ l(
|
|
115
91
|
"circle",
|
|
116
92
|
{
|
|
117
93
|
cx: i.isSelected ? 42 : 20,
|
|
118
|
-
cy: 16 +
|
|
94
|
+
cy: 16 + a,
|
|
119
95
|
r: 9.5,
|
|
120
96
|
fill: n.circle
|
|
121
97
|
}
|
|
122
98
|
),
|
|
123
|
-
/* @__PURE__ */
|
|
99
|
+
/* @__PURE__ */ l(
|
|
124
100
|
"path",
|
|
125
101
|
{
|
|
126
102
|
fillRule: "evenodd",
|
|
127
103
|
clipRule: "evenodd",
|
|
128
|
-
d: i.isSelected ?
|
|
129
|
-
transform: `translate(${i.isSelected ? 32 : 14},${(i.isSelected ? 6 : 10) +
|
|
104
|
+
d: i.isSelected ? y.check : y.close,
|
|
105
|
+
transform: `translate(${i.isSelected ? 32 : 14},${(i.isSelected ? 6 : 10) + a}) scale(1.2)`,
|
|
130
106
|
fill: n.icon,
|
|
131
107
|
style: { pointerEvents: "none" }
|
|
132
108
|
}
|
|
133
109
|
),
|
|
134
|
-
|
|
110
|
+
d && /* @__PURE__ */ l(
|
|
135
111
|
"rect",
|
|
136
112
|
{
|
|
137
113
|
x: 6,
|
|
138
|
-
y,
|
|
114
|
+
y: a,
|
|
139
115
|
width: 50,
|
|
140
116
|
height: 32,
|
|
141
117
|
rx: 12,
|
|
@@ -150,11 +126,11 @@ function W(e) {
|
|
|
150
126
|
)
|
|
151
127
|
}
|
|
152
128
|
),
|
|
153
|
-
|
|
129
|
+
e.children ?? e.label
|
|
154
130
|
]
|
|
155
131
|
}
|
|
156
132
|
);
|
|
157
133
|
}
|
|
158
134
|
export {
|
|
159
|
-
|
|
135
|
+
F as Switch
|
|
160
136
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("react");function E(o,p,l){let[b,i]=s.useState(o||p),u=s.useRef(o!==void 0),e=o!==void 0;s.useEffect(()=>{let t=u.current;t!==e&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${t?"controlled":"uncontrolled"} to ${e?"controlled":"uncontrolled"}.`),u.current=e},[e]);let n=e?o:b,$=s.useCallback((t,...f)=>{let a=(c,...r)=>{l&&(Object.is(n,c)||l(c,...r)),e||(n=c)};typeof t=="function"?(process.env.NODE_ENV!=="production"&&console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"),i((r,...V)=>{let d=t(e?n:r,...V);return a(d,...f),e?r:d})):(e||i(t),a(t,...f))},[e,n,l]);return[n,$]}exports.$458b0a5536c1a7cf$export$40bfa8c7b0832715=E;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useState as V, useRef as $, useEffect as E, useCallback as N } from "react";
|
|
2
|
+
function h(o, a, l) {
|
|
3
|
+
let [p, s] = V(o || a), i = $(o !== void 0), e = o !== void 0;
|
|
4
|
+
E(() => {
|
|
5
|
+
let t = i.current;
|
|
6
|
+
t !== e && process.env.NODE_ENV !== "production" && console.warn(`WARN: A component changed from ${t ? "controlled" : "uncontrolled"} to ${e ? "controlled" : "uncontrolled"}.`), i.current = e;
|
|
7
|
+
}, [
|
|
8
|
+
e
|
|
9
|
+
]);
|
|
10
|
+
let n = e ? o : p, b = N((t, ...u) => {
|
|
11
|
+
let f = (r, ...c) => {
|
|
12
|
+
l && (Object.is(n, r) || l(r, ...c)), e || (n = r);
|
|
13
|
+
};
|
|
14
|
+
typeof t == "function" ? (process.env.NODE_ENV !== "production" && console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"), s((c, ...m) => {
|
|
15
|
+
let d = t(e ? n : c, ...m);
|
|
16
|
+
return f(d, ...u), e ? c : d;
|
|
17
|
+
})) : (e || s(t), f(t, ...u));
|
|
18
|
+
}, [
|
|
19
|
+
e,
|
|
20
|
+
n,
|
|
21
|
+
l
|
|
22
|
+
]);
|
|
23
|
+
return [
|
|
24
|
+
n,
|
|
25
|
+
b
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
h as $
|
|
30
|
+
};
|