@epam/ai-dial-ui-kit 0.1.0-rc → 0.1.0-rc.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/dist/dial-ui-kit.cjs.js +1 -22
- package/dist/dial-ui-kit.es.js +374 -667
- package/dist/index.css +2 -2
- package/dist/src/components/Input/Input.d.ts +2 -0
- package/dist/src/components/Input/utils.d.ts +2 -0
- package/dist/src/components/Switch/Switch.d.ts +29 -0
- package/dist/src/components/Textarea/Textarea.d.ts +1 -1
- package/dist/src/index.d.ts +1 -1
- package/package.json +6 -3
package/dist/dial-ui-kit.cjs.js
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var K;function be(){if(K)return S;K=1;var r=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function s(l,n,i){var c=null;if(i!==void 0&&(c=""+i),n.key!==void 0&&(c=""+n.key),"key"in n){i={};for(var d in n)d!=="key"&&(i[d]=n[d])}else i=n;return n=i.ref,{$$typeof:r,type:l,key:c,ref:n!==void 0?n:null,props:i}}return S.Fragment=t,S.jsx=s,S.jsxs=s,S}var F={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ee;function ge(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&(function(){function r(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===de?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case _:return"Profiler";case A:return"StrictMode";case le:return"Suspense";case ie:return"SuspenseList";case ue:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case C:return"Portal";case I:return(e.displayName||"Context")+".Provider";case N:return(e._context.displayName||"Context")+".Consumer";case se:var a=e.render;return e=e.displayName,e||(e=a.displayName||a.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ce:return a=e.displayName||null,a!==null?a:r(e.type)||"Memo";case J:a=e._payload,e=e._init;try{return r(e(a))}catch{}}return null}function t(e){return""+e}function s(e){try{t(e);var a=!1}catch{a=!0}if(a){a=console;var u=a.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u.call(a,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),t(e)}}function l(e){if(e===k)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===J)return"<...>";try{var a=r(e);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function n(){var e=L.A;return e===null?null:e.getOwner()}function i(){return Error("react-stack-top-frame")}function c(e){if(G.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function d(e,a){function u(){V||(V=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",a))}u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}function f(){var e=r(this.type);return H[e]||(H[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function x(e,a,u,p,T,j,M,$){return u=j.ref,e={$$typeof:w,type:e,key:a,props:j,_owner:T},(u!==void 0?u:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:f}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:$}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function m(e,a,u,p,T,j,M,$){var b=a.children;if(b!==void 0)if(p)if(fe(b)){for(p=0;p<b.length;p++)v(b[p]);Object.freeze&&Object.freeze(b)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else v(b);if(G.call(a,"key")){b=r(e);var y=Object.keys(a).filter(function(me){return me!=="key"});p=0<y.length?"{key: someKey, "+y.join(": ..., ")+": ...}":"{key: someKey}",Q[b+p]||(y=0<y.length?"{"+y.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
-
let props = %s;
|
|
19
|
-
<%s {...props} />
|
|
20
|
-
React keys must be passed directly to JSX without using spread:
|
|
21
|
-
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,p,b,y,b),Q[b+p]=!0)}if(b=null,u!==void 0&&(s(u),b=""+u),c(a)&&(s(a.key),b=""+a.key),"key"in a){u={};for(var q in a)q!=="key"&&(u[q]=a[q])}else u=a;return b&&d(u,typeof e=="function"?e.displayName||e.name||"Unknown":e),x(e,b,j,T,n(),u,M,$)}function v(e){typeof e=="object"&&e!==null&&e.$$typeof===w&&e._store&&(e._store.validated=1)}var R=h,w=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),I=Symbol.for("react.context"),se=Symbol.for("react.forward_ref"),le=Symbol.for("react.suspense"),ie=Symbol.for("react.suspense_list"),ce=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),ue=Symbol.for("react.activity"),de=Symbol.for("react.client.reference"),L=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=Object.prototype.hasOwnProperty,fe=Array.isArray,Y=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var V,H={},X=R.react_stack_bottom_frame.bind(R,i)(),Z=Y(l(i)),Q={};F.Fragment=k,F.jsx=function(e,a,u,p,T){var j=1e4>L.recentlyCreatedOwnerStacks++;return m(e,a,u,!1,p,T,j?Error("react-stack-top-frame"):X,j?Y(l(e)):Z)},F.jsxs=function(e,a,u,p,T){var j=1e4>L.recentlyCreatedOwnerStacks++;return m(e,a,u,!0,p,T,j?Error("react-stack-top-frame"):X,j?Y(l(e)):Z)}})()),F}var re;function xe(){return re||(re=1,process.env.NODE_ENV==="production"?D.exports=be():D.exports=ge()),D.exports}var o=xe();const O=({icon:r,className:t})=>r?o.jsx("span",{className:E("flex-shrink-0",t),children:r}):null,ve=({title:r,cssClass:t,ref:s,onClick:l,disable:n,iconAfter:i,iconBefore:c,hideTitleOnMobile:d,ariaLabel:f})=>{const x=E("dial-small-semi",i?"mr-2":"",c?"ml-2":"",d?"hidden sm:inline":"inline"),m=E(t,"focus-visible:outline outline-offset-0");return o.jsxs("button",{ref:s,type:"button",className:m,onClick:v=>l?.(v),disabled:n,"aria-label":r||f,children:[o.jsx(O,{icon:c}),r&&o.jsx("span",{className:x,children:r}),o.jsx(O,{icon:i})]})},U=({errorText:r})=>r&&o.jsx("span",{className:"text-error dial-tiny mt-1",children:r}),z=({fieldTitle:r,htmlFor:t,optional:s,optionalText:l,cssClass:n})=>r?o.jsxs("label",{className:E("dial-tiny text-secondary",n,!n?.includes("mb")&&"mb-2"),htmlFor:t,children:[o.jsx("span",{className:"min-h-4",children:r}),s&&o.jsx("span",{className:"ml-1",children:l??"(Optional)"})]}):null,te=({value:r,textareaId:t,placeholder:s,cssClass:l="",disabled:n,invalid:i,readonly:c,onChange:d})=>o.jsx("textarea",{id:t,placeholder:s,value:r,disabled:n,className:E("dial-textarea dial-input",i?"dial-input-error":"",n&&"dial-input-disable",c&&"dial-input-readonly",l),onChange:f=>!c&&d?.(f.currentTarget.value)}),je=7,he=2,ne=h.createContext(null),oe=()=>{const r=h.useContext(ne);if(r==null)throw new Error("Tooltip components must be wrapped in <Tooltip />");return r},Ee=({initialOpen:r=!1,placement:t="bottom",isTriggerClickable:s=!1,open:l,onOpenChange:n}={})=>{const[i,c]=h.useState(r),d=h.useRef(null),f=l??i,x=n??c,m=g.useFloating({placement:t,open:f,onOpenChange:x,whileElementsMounted:g.autoUpdate,middleware:[g.offset(je+he),g.flip({crossAxis:t.includes("-"),fallbackAxisSideDirection:"start",padding:5}),g.shift({padding:5}),g.arrow({element:d})]}),v=g.useHover(m.context,{move:!1,enabled:l==null,mouseOnly:s,delay:{open:500,close:0}}),R=g.useFocus(m.context,{enabled:l==null}),w=g.useDismiss(m.context),C=g.useRole(m.context,{role:"tooltip"}),k=g.useInteractions([v,R,w,C]);return h.useMemo(()=>({open:f,setOpen:x,arrowRef:d,...k,...m}),[f,x,k,m])},ke=({children:r,...t})=>{const s=Ee(t);return o.jsx(ne.Provider,{value:s,children:r})},Re=h.forwardRef(function({style:t,...s},l){const n=oe(),i=g.useMergeRefs([n.refs.setFloating,l]);return n.open?o.jsx(g.FloatingPortal,{id:"tooltip-portal",children:o.jsxs("div",{ref:i,style:{...n.floatingStyles,...t},...n.getFloatingProps(s),className:E("z-[55] whitespace-pre-wrap rounded border border-primary bg-blackout px-2 py-1 dial-tiny shadow max-w-[300px]",n.getFloatingProps(s).className),children:[s.children,o.jsx(g.FloatingArrow,{ref:n.arrowRef,context:n.context,fill:"currentColor",strokeWidth:1,className:"stroke-primary w-2 text-[var(--bg-layer-0,_#000000)]"})]})}):null}),Te=h.forwardRef(function({children:t,asChild:s=!1,...l},n){const i=oe(),d=t&&typeof t=="object"&&"ref"in t&&t.ref!==void 0?t.ref:void 0,f=g.useMergeRefs([i.refs.setReference,n,d]);return s&&h.isValidElement(t)?h.cloneElement(t,i.getReferenceProps({ref:f,...l,...t.props})):o.jsx("span",{ref:f,...i.getReferenceProps(l),className:l.className??"dial-tooltip-trigger text-left",children:t})}),B=({hideTooltip:r,tooltip:t,children:s,triggerClassName:l,contentClassName:n,...i})=>r||!t?o.jsx("span",{className:l,children:s}):o.jsxs(ke,{...i,children:[o.jsx(Te,{className:l,children:s}),o.jsx(Re,{className:E("text-primary",n),children:t})]}),P=({iconBeforeInput:r,iconAfterInput:t,hideBorder:s,value:l,elementId:n,placeholder:i="",cssClass:c="",containerCssClass:d,type:f="text",disabled:x,readonly:m,invalid:v,onChange:R,min:w,max:C,prefix:k,suffix:A,textBeforeInput:_,textAfterInput:N})=>o.jsxs("div",{className:E("dial-input-field flex flex-row items-center justify-between",s?"dial-input-no-border":"dial-input",v&&"dial-input-error",x&&"dial-input-disable",m&&"dial-input-readonly",!_&&"pl-1",!N&&"pr-1",d),children:[_&&o.jsx(B,{tooltip:_,children:o.jsx(P,{hideBorder:!0,containerCssClass:"rounded-r-none border-r-0",cssClass:"px-2 overflow-hidden overflow-ellipsis dial-small",value:_,disabled:!0,elementId:_+"textBefore"})}),k&&o.jsxs("p",{className:"text-secondary dial-small pl-2",children:[" ",k]}),o.jsx(O,{icon:r,className:"pl-2"}),o.jsx("input",{type:f,autoComplete:"new-password",id:n,placeholder:i,value:l??"",title:l?String(l):"",disabled:x,min:w,max:C,className:E("border-0 bg-transparent px-2",c),onChange:I=>!m&&R?.(I.currentTarget.value)}),o.jsx(O,{icon:t,className:"pr-2"}),A&&o.jsxs("p",{className:"text-secondary dial-small pr-2",children:[" ",A]}),N&&o.jsx(B,{tooltip:N,children:o.jsx(P,{hideBorder:!0,containerCssClass:"rounded-l-none border-l-0",cssClass:"px-2",value:N,disabled:!0,elementId:N+"textAfter"})})]}),_e=/^0+\.(\d+)?$/,Ne=/^0+/,ae=({fieldTitle:r,errorText:t,optional:s,elementCssClass:l,elementContainerCssClass:n,elementId:i,containerCssClass:c,readonly:d,defaultEmptyText:f,min:x,max:m,...v})=>o.jsxs("div",{className:E("flex flex-col",c),children:[o.jsx(z,{fieldTitle:r,optional:s,htmlFor:i}),d?o.jsx("span",{children:v.value||(f??"None")}):o.jsxs(o.Fragment,{children:[o.jsx(P,{elementId:i,cssClass:l,containerCssClass:n,invalid:t!=null,min:x,max:m,...v}),o.jsx(U,{errorText:t})]})]}),we=({onChange:r,value:t,min:s,max:l,...n})=>{const i=c=>String(c)?.match(_e)?String(c)?.replace(Ne,"0"):Number(c);return o.jsx(ae,{type:"number",onChange:c=>r?.(i(c)),value:t,min:s,max:l,...n})},ye=({onChange:r,...t})=>o.jsx(ae,{type:"text",onChange:s=>r?.(s),...t}),Ce=({fieldTitle:r,optional:t,elementId:s,elementCssClass:l,errorText:n,...i})=>o.jsxs("div",{className:"flex flex-col",children:[o.jsx(z,{fieldTitle:r,optional:t,htmlFor:s}),o.jsx(te,{textareaId:s,cssClass:l,...i}),o.jsx(U,{errorText:n})]});var W=(r=>(r.dark="dark",r.light="light",r))(W||{});const Se={[W.dark]:{base:"vs-dark",inherit:!1,rules:[{token:"string.key.json",foreground:"#37BABC"},{token:"string.value.json",foreground:"#5C8DEA"},{token:"number",foreground:"#D97C27"},{token:"keyword.json",foreground:"#F4CE46"},{token:"delimiter",foreground:"#F3F4F6"},{token:"delimiter.bracket.json",foreground:"#A972FF"},{token:"delimiter.parenthesis",foreground:"#A972FF"}],colors:{"editor.foreground":"#F76464","editor.background":"#141A23","editorCursor.foreground":"#F3F4F6","editor.selectionBackground":"#5C8DEA2B","editorLineNumber.foreground":"#333942","scrollbarSlider.background":"#333942","scrollbarSlider.hoverBackground":"#333942","scrollbarSlider.activeBackground":"#333942"}},[W.light]:{base:"vs",inherit:!1,rules:[{token:"string.key.json",foreground:"#009D9F"},{token:"string.value.json",foreground:"#2764D9"},{token:"number",foreground:"#B25500"},{token:"keyword.json",foreground:"#3F3D25"},{token:"delimiter",foreground:"#141A23"},{token:"delimiter.bracket.json",foreground:"#843EF3"},{token:"delimiter.parenthesis",foreground:"#843EF3"}],colors:{"editor.foreground":"#AE2F2F","editor.background":"#F3F4F6","editorCursor.foreground":"#141A23","editor.selectionBackground":"#5C8DEA2B","editorLineNumber.foreground":"#333942","scrollbarSlider.background":"#333942","scrollbarSlider.hoverBackground":"#333942","scrollbarSlider.activeBackground":"#333942"}}},Fe=({value:r,onChange:t,onValidateJSON:s,options:l,currentTheme:n,themesConfig:i=Se})=>{function c(d){d?.editor?.defineTheme(n,i[n]),d.languages.json.jsonDefaults.setDiagnosticsOptions({validate:!0,enableSchemaRequest:!1,schemas:[{uri:"http://custom-schema/object-required.json",fileMatch:["*"],schema:{type:"object",description:"Top-level value must be an object",additionalProperties:!0}}]})}return o.jsx(pe.Editor,{beforeMount:c,height:"100%",defaultLanguage:"json",value:r,onChange:t,theme:n,onValidate:s,options:{minimap:{enabled:!1},formatOnType:!0,formatOnPaste:!0,selectOnLineNumbers:!1,automaticLayout:!0,scrollBeyondLastLine:!1,wordWrap:"on",smoothScrolling:!0,overviewRulerLanes:0,scrollbar:{horizontal:"hidden",verticalScrollbarSize:4,verticalSliderSize:4},...l??{}}})};exports.DialButton=ve;exports.DialErrorText=U;exports.DialFieldLabel=z;exports.DialIcon=O;exports.DialInput=P;exports.DialJsonEditor=Fe;exports.DialNumberInputField=we;exports.DialTextAreaField=Ce;exports.DialTextInputField=ye;exports.DialTextarea=te;exports.DialTooltip=B;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("classnames"),u=require("@floating-ui/react"),f=require("react"),D=({icon:e,className:s})=>e?t.jsx("span",{className:p("flex-shrink-0",s),children:e}):null,H=({title:e,cssClass:s,ref:n,onClick:r,disable:l,iconAfter:a,iconBefore:o,hideTitleOnMobile:c,ariaLabel:i})=>{const x=p("dial-small-semi",a?"mr-2":"",o?"ml-2":"",c?"hidden sm:inline":"inline"),d=p(s,"focus-visible:outline outline-offset-0");return t.jsxs("button",{ref:n,type:"button",className:d,onClick:m=>r?.(m),disabled:l,"aria-label":e||i,children:[t.jsx(D,{icon:o}),e&&t.jsx("span",{className:x,children:e}),t.jsx(D,{icon:a})]})},R=({errorText:e})=>e&&t.jsx("span",{className:"text-error dial-tiny mt-1",children:e}),k=({fieldTitle:e,htmlFor:s,optional:n,optionalText:r,cssClass:l})=>e?t.jsxs("label",{className:p("dial-tiny text-secondary",l,!l?.includes("mb")&&"mb-2"),htmlFor:s,children:[t.jsx("span",{className:"min-h-4",children:e}),n&&t.jsx("span",{className:"ml-1",children:r??"(Optional)"})]}):null,U=7,_=2,E=f.createContext(null),I=()=>{const e=f.useContext(E);if(e==null)throw new Error("Tooltip components must be wrapped in <Tooltip />");return e},K=({initialOpen:e=!1,placement:s="bottom",isTriggerClickable:n=!1,open:r,onOpenChange:l}={})=>{const[a,o]=f.useState(e),c=f.useRef(null),i=r??a,x=l??o,d=u.useFloating({placement:s,open:i,onOpenChange:x,whileElementsMounted:u.autoUpdate,middleware:[u.offset(U+_),u.flip({crossAxis:s.includes("-"),fallbackAxisSideDirection:"start",padding:5}),u.shift({padding:5}),u.arrow({element:c})]}),m=u.useHover(d.context,{move:!1,enabled:r==null,mouseOnly:n,delay:{open:500,close:0}}),T=u.useFocus(d.context,{enabled:r==null}),F=u.useDismiss(d.context),h=u.useRole(d.context,{role:"tooltip"}),g=u.useInteractions([m,T,F,h]);return f.useMemo(()=>({open:i,setOpen:x,arrowRef:c,...g,...d}),[i,x,g,d])},O=({children:e,...s})=>{const n=K(s);return t.jsx(E.Provider,{value:n,children:e})},$=f.forwardRef(function({style:s,...n},r){const l=I(),a=u.useMergeRefs([l.refs.setFloating,r]);return l.open?t.jsx(u.FloatingPortal,{id:"tooltip-portal",children:t.jsxs("div",{ref:a,style:{...l.floatingStyles,...s},...l.getFloatingProps(n),className:p("z-[55] whitespace-pre-wrap rounded border border-primary bg-blackout px-2 py-1 dial-tiny shadow max-w-[300px]",l.getFloatingProps(n).className),children:[n.children,t.jsx(u.FloatingArrow,{ref:l.arrowRef,context:l.context,fill:"currentColor",strokeWidth:1,className:"stroke-primary w-2 text-[var(--bg-layer-0,_#000000)]"})]})}):null}),z=f.forwardRef(function({children:s,asChild:n=!1,...r},l){const a=I(),c=s&&typeof s=="object"&&"ref"in s&&s.ref!==void 0?s.ref:void 0,i=u.useMergeRefs([a.refs.setReference,l,c]);return n&&f.isValidElement(s)?f.cloneElement(s,a.getReferenceProps({ref:i,...r,...s.props})):t.jsx("span",{ref:i,...a.getReferenceProps(r),className:r.className??"dial-tooltip-trigger text-left",children:s})}),w=({hideTooltip:e,tooltip:s,children:n,triggerClassName:r,contentClassName:l,...a})=>e||!s?t.jsx("span",{className:r,children:n}):t.jsxs(O,{...a,children:[t.jsx(z,{className:p(r,"truncate"),children:n}),t.jsx($,{className:p("text-primary",l,"max-w-[300px]",(e||!s)&&"hidden"),children:s})]}),A=({value:e,textareaId:s,placeholder:n,cssClass:r="",disabled:l,invalid:a,readonly:o,onChange:c})=>t.jsx(w,{tooltip:e,triggerClassName:"flex",children:t.jsx("textarea",{id:s,placeholder:n,value:e||"",disabled:l,className:p("dial-textarea dial-input",a?"dial-input-error":"",l&&"dial-input-disable",o&&"dial-input-readonly",r),onChange:i=>!o&&c?.(i.currentTarget.value)})}),G=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Tab","Enter","Escape","Home","End"],B=(e,s,n,r)=>{if((s==="number"||n!==void 0||r!==void 0)&&!G.includes(e.key)&&!(e.key==="-"&&e.currentTarget.selectionStart===0&&(n===void 0||n<0))&&!(e.key==="."&&s==="number"&&!e.currentTarget.value.includes("."))){if(!/^[0-9]$/.test(e.key)){e.preventDefault();return}if(n!==void 0||r!==void 0){const a=e.currentTarget.value,o=e.currentTarget.selectionStart||0,c=a.slice(0,o)+e.key+a.slice(o),i=parseFloat(c);if(!isNaN(i)){if(n!==void 0&&i<n){e.preventDefault();return}if(r!==void 0&&i>r){e.preventDefault();return}}}}},y=({iconBeforeInput:e,iconAfterInput:s,hideBorder:n,value:r,elementId:l,placeholder:a="",cssClass:o="",containerCssClass:c,tooltipTriggerClassName:i,type:x="text",disabled:d,readonly:m,invalid:T,onChange:F,min:h,max:g,prefix:P,suffix:S,textBeforeInput:j,textAfterInput:N})=>{const M=b=>b.target.blur(),V=x==="number"||h!==void 0||g!==void 0,W=b=>{B(b,x,h,g)},q=b=>{const v=b.currentTarget.value;if(V&&v!==""){const C=parseFloat(v);if(isNaN(C)&&v!=="-"&&v!=="."||!isNaN(C)&&(h!==void 0&&C<h||g!==void 0&&C>g))return}F?.(v)};return t.jsxs("div",{className:p("dial-input-field flex flex-row items-center justify-between",n?"dial-input-no-border":"dial-input",T&&"dial-input-error",d&&"dial-input-disable",m&&"dial-input-readonly",!j&&"pl-1",!N&&"pr-1",c),children:[j&&t.jsx(w,{tooltip:j,children:t.jsx(y,{hideBorder:!0,containerCssClass:"rounded-r-none border-r-0",cssClass:"px-2 overflow-hidden overflow-ellipsis dial-small",value:j,disabled:!0,elementId:j+"textBefore"})}),P&&t.jsxs("p",{className:"text-secondary dial-small pl-2",children:[" ",P]}),t.jsx(D,{icon:e,className:"pl-2"}),t.jsx(w,{tooltip:r,triggerClassName:i,children:t.jsx("input",{type:x,autoComplete:"off",id:l,placeholder:a,value:r??"",title:r?String(r):"",disabled:d,className:p("border-0 bg-transparent px-2",o),onChange:b=>!m&&q?.(b),onKeyDown:W,onWheel:M,min:h,max:g})}),t.jsx(D,{icon:s,className:"pr-2"}),S&&t.jsxs("p",{className:"text-secondary dial-small pr-2",children:[" ",S]}),N&&t.jsx(w,{tooltip:N,children:t.jsx(y,{hideBorder:!0,containerCssClass:"rounded-l-none border-l-0",cssClass:"px-2",value:N,disabled:!0,elementId:N+"textAfter"})})]})},Y=/^0+\.(\d+)?$/,Z=/^0+/,L=({fieldTitle:e,errorText:s,optional:n,elementCssClass:r,elementContainerCssClass:l,elementId:a,containerCssClass:o,readonly:c,defaultEmptyText:i,min:x,max:d,...m})=>t.jsxs("div",{className:p("flex flex-col",o),children:[t.jsx(k,{fieldTitle:e,optional:n,htmlFor:a}),c?t.jsx("span",{children:m.value||(i??"None")}):t.jsxs(t.Fragment,{children:[t.jsx(y,{elementId:a,cssClass:r,containerCssClass:l,invalid:s!=null,min:x,max:d,...m}),t.jsx(R,{errorText:s})]})]}),J=({onChange:e,value:s,min:n,max:r,...l})=>{const a=o=>String(o)?.match(Y)?String(o)?.replace(Z,"0"):Number(o);return t.jsx(L,{type:"number",onChange:o=>e?.(a(o)),value:s,min:n,max:r,...l})},Q=({onChange:e,...s})=>t.jsx(L,{type:"text",onChange:n=>e?.(n),...s}),X=({fieldTitle:e,optional:s,elementId:n,elementCssClass:r,errorText:l,...a})=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx(k,{fieldTitle:e,optional:s,htmlFor:n}),t.jsx(A,{textareaId:n,cssClass:r,...a}),t.jsx(R,{errorText:l})]}),ee=({title:e,switchId:s,isOn:n=!1,disabled:r,onChange:l})=>{const a=p("flex w-[36px] h-[18px] cursor-pointer items-center gap-1 rounded-full p-0.5 transition-all duration-200",n?"flex-row-reverse":"flex-row",r?"pointer-events-none":"",r?n?"bg-controls-disable":"bg-layer-4":n?"bg-accent-primary":"bg-layer-4"),o=f.useCallback(c=>{c.stopPropagation(),l?.(!n)},[l,n]);return t.jsxs("div",{className:"flex flex-row items-center",children:[t.jsx("input",{type:"checkbox",onChange:o,id:s,disabled:r,className:"invisible w-0 h-0",checked:n}),t.jsx("label",{htmlFor:s,className:a,children:t.jsx("span",{className:p("size-3 rounded-full",r?n?"bg-controls-disable":"bg-layer-4":"bg-controls-enable-primary")})}),e&&t.jsx("span",{className:"h-[14px] pl-2 small text-primary",children:e})]})};exports.DialButton=H;exports.DialErrorText=R;exports.DialFieldLabel=k;exports.DialIcon=D;exports.DialInput=y;exports.DialNumberInputField=J;exports.DialSwitch=ee;exports.DialTextAreaField=X;exports.DialTextInputField=Q;exports.DialTextarea=A;exports.DialTooltip=w;
|