@verifiedinc-public/shared-ui-elements 12.13.0 → 12.15.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/components/NetworkRules/editor/fields/ConditionRow.mjs +1 -1
- package/dist/components/NetworkRules/editor/fields/ConditionsField.mjs +1 -1
- package/dist/components/NetworkRules/editor/fields/values/InlineValuesInput.mjs +1 -1
- package/dist/components/NetworkRules/editor/fields/values/OrSeparator.d.ts +5 -0
- package/dist/components/NetworkRules/editor/fields/values/OrSeparator.mjs +1 -0
- package/dist/components/NetworkRules/editor/fields/values/RemoteValuesInput.mjs +1 -1
- package/dist/components/NetworkRules/editor/fields/values/TextValuesInput.mjs +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Stack as b,TextField as k,MenuItem as S,IconButton as
|
|
1
|
+
"use strict";import{Stack as b,Typography as j,TextField as k,MenuItem as S,IconButton as O}from"@mui/material";import{Delete as P}from"@mui/icons-material";import{useFormContext as q,useController as h,useWatch as K}from"react-hook-form";import{getKeyDef as $,isOperatorMulti as D,getPresets as M,getOperatorLabel as z}from"../../utils/catalog.mjs";import{ConditionValuesInput as A}from"./ConditionValuesInput.mjs";import{jsxs as H,jsx as l}from"react/jsx-runtime";function L({index:o,catalog:r,onRemove:R,addedPresets:v,onCreatePreset:p,canRemove:w=!0,disabled:d=!1,autoFocus:B}){var g,x,y;const{control:s,setValue:u,formState:I}=q(),a=h({control:s,name:`conditions.${o}.key`}),i=h({control:s,name:`conditions.${o}.operator`}),m=h({control:s,name:`conditions.${o}.values`}),c=K({control:s,name:`conditions.${o}.values`})??[],t=$(r,a.field.value),T=t?.operators??[],V=D(r,i.field.value),f=I.isSubmitted,W=t?[...M(r,t.key),...v?.[t.key]??[]]:[],F=e=>{var n;a.field.onChange(e);const C=((n=$(r,e))==null?void 0:n.operators)??[];u(`conditions.${o}.operator`,C.length===1?C[0]:"",{shouldDirty:!0,shouldValidate:f}),u(`conditions.${o}.values`,[],{shouldDirty:!0,shouldValidate:f})};return H(b,{direction:{xs:"column",md:"row"},spacing:1.5,alignItems:"flex-start",children:[l(j,{fontSize:20,fontWeight:300,sx:{display:"flex",alignItems:"center",justifyContent:{md:"flex-end"},minHeight:{md:56},minWidth:{md:48},flexShrink:0},children:o===0?"IF":"AND"}),l(k,{select:!0,required:!0,label:"Key",value:a.field.value,onChange:e=>{F(e.target.value)},onBlur:a.field.onBlur,inputRef:a.field.ref,disabled:d,autoFocus:B,error:a.fieldState.error!==void 0,helperText:(g=a.fieldState.error)==null?void 0:g.message,sx:{minWidth:{md:200},width:{xs:"100%",md:"auto"}},children:r.keys.map(e=>l(S,{value:e.key,children:e.label},e.key))}),l(k,{select:!0,required:!0,label:"Operator",value:i.field.value,onChange:e=>{const n=e.target.value;i.field.onChange(n),!D(r,n)&&c.length>1&&u(`conditions.${o}.values`,c.slice(0,1),{shouldDirty:!0,shouldValidate:f})},onBlur:i.field.onBlur,inputRef:i.field.ref,disabled:d||t===void 0,error:i.fieldState.error!==void 0,helperText:(x=i.fieldState.error)==null?void 0:x.message,sx:{minWidth:{md:180},width:{xs:"100%",md:"auto"}},children:T.map(e=>l(S,{value:e,children:z(r,e)},e))}),l(b,{flex:1,width:"100%",minWidth:0,children:l(A,{keyDef:t,multi:V,values:c,onChange:e=>{m.field.onChange(e)},presets:W,onCreatePreset:p&&t?e=>{p(t.key,e)}:void 0,disabled:d||i.field.value==="",error:m.fieldState.error!==void 0,helperText:(y=m.fieldState.error)==null?void 0:y.message})}),l(O,{"aria-label":`Remove condition ${o+1}`,color:"error",onClick:R,disabled:d||!w,sx:{mt:{md:1}},children:l(P,{})})]})}export{L as ConditionRow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Stack as l,Typography as c,Button as
|
|
1
|
+
"use strict";import{Stack as l,Typography as c,Button as v,FormHelperText as F}from"@mui/material";import{Add as b}from"@mui/icons-material";import{useFormContext as A,useFieldArray as j}from"react-hook-form";import{emptyConditionFormValues as w}from"../../utils/condition.mjs";import{ConditionRow as I}from"./ConditionRow.mjs";import{jsxs as m,jsx as o}from"react/jsx-runtime";function P({catalog:p,addedPresets:u,onCreatePreset:f,disabled:n,focusIndex:C}){var t,r,s;const{control:g,formState:i}=A(),{fields:a,append:h,remove:x}=j({control:g,name:"conditions"}),d=((r=(t=i.errors.conditions)==null?void 0:t.root)==null?void 0:r.message)??((s=i.errors.conditions)==null?void 0:s.message);return m(l,{spacing:2,children:[m(l,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[o(c,{fontWeight:700,children:"Conditions"}),o(v,{startIcon:o(b,{}),disabled:n,onClick:()=>{h(w())},children:"Add Condition"})]}),a.length===0&&o(c,{variant:"body2",color:"text.secondary",children:"No conditions yet. A rule needs at least one; all conditions must match."}),a.map((y,e)=>o(I,{index:e,catalog:p,addedPresets:u,onCreatePreset:f,disabled:n,autoFocus:e===C,onRemove:()=>{x(e)}},y.id)),d&&o(F,{error:!0,children:d})]})}export{P as ConditionsField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Autocomplete as
|
|
1
|
+
"use strict";import{Fragment as f}from"react";import{Autocomplete as g,TextField as O,Chip as v,Checkbox as T}from"@mui/material";import{OptionLabel as C}from"../../../shared/OptionLabel.mjs";import{toOptions as k}from"../../../utils/catalog.mjs";import{OrSeparator as I}from"./OrSeparator.mjs";import{jsx as a,jsxs as p}from"react/jsx-runtime";function S({options:n,values:i,onChange:m,multi:t,label:u,error:c,helperText:d,disabled:b}){const h=k(i,n);return a(g,{multiple:!0,options:n,value:h,disabled:b,limitTags:4,disableCloseOnSelect:t,getOptionLabel:e=>e.label,isOptionEqualToValue:(e,l)=>e.value===l.value,onChange:(e,l)=>{const o=l.map(r=>r.value);m(t?o:o.slice(-1))},renderOption:(e,l,{selected:o})=>{const{key:r,...s}=e;return p("li",{...s,children:[t&&a(T,{checked:o,sx:{mr:1}}),a(C,{option:l})]},r)},renderTags:(e,l)=>e.map((o,r)=>{const{key:s,...x}=l({index:r});return p(f,{children:[r>0&&a(I,{}),a(v,{...x,label:o.label})]},s)}),renderInput:e=>a(O,{...e,label:u,placeholder:i.length===0?"Select\u2026":void 0,error:c,helperText:d})})}export{S as InlineValuesInput};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Typography as r}from"@mui/material";import{jsx as o}from"react/jsx-runtime";function a(){return o(r,{component:"span",variant:"body2",color:"text.primary",sx:{alignSelf:"center",mx:.5},children:"OR"})}export{a as OrSeparator};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useState as d}from"react";import{Button as
|
|
1
|
+
"use strict";import{useState as d,Fragment as R}from"react";import{Button as U,TextField as C,Autocomplete as z,Checkbox as M,Box as N,CircularProgress as P}from"@mui/material";import{LogoAvatar as V}from"../../../../UI/LogoAvatar.mjs";import{LogoChip as A}from"../../../../UI/LogoChip.mjs";import{useNetworkRuleSourceSearch as B}from"../../../hooks/useNetworkRuleSourceSearch.mjs";import{useResolvedConditionOptions as F}from"../../../hooks/useResolvedConditionOptions.mjs";import{OptionLabel as H}from"../../../shared/OptionLabel.mjs";import{OrSeparator as E}from"./OrSeparator.mjs";import{jsx as r,jsxs as O}from"react/jsx-runtime";const q=50;function D({keyDef:n,values:p,onChange:k,multi:c,label:m,error:y,helperText:L,disabled:S}){const[u,h]=d(""),[g,f]=d(!1),[j,w]=d([]),t=B(n.values.source,u,{enabled:g}),b=F(n,p,{known:j}),v=t.service,x=t.isLoading||t.isLoadingMore,I=o=>{const e=o.currentTarget;e.scrollTop+e.clientHeight>=e.scrollHeight-q&&t.loadMore()};let T=u.trim()?"No matches":"Type to search";return t.error&&(T=r(U,{size:"small",onClick:t.retry,children:"Search failed. Retry"})),t.isSupported?r(z,{multiple:!0,open:g,onOpen:()=>{f(!0)},onClose:()=>{f(!1)},options:t.options,value:b.options,loading:x||b.isLoading,ListboxProps:{onScroll:I},popupIcon:x?r(N,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center"},children:r(P,{color:"inherit",size:18})}):void 0,disabled:S,limitTags:4,disableCloseOnSelect:c,filterOptions:o=>o,inputValue:u,onInputChange:(o,e,l)=>{l!=="reset"&&h(e)},getOptionLabel:o=>o.label,isOptionEqualToValue:(o,e)=>o.value===e.value,onChange:(o,e)=>{w(s=>{const i=new Map(s.map(a=>[a.value,a]));for(const a of e)i.set(a.value,a);return[...i.values()]});const l=e.map(s=>s.value);k(c?l:l.slice(-1)),h("")},noOptionsText:T,renderOption:(o,e,{selected:l})=>{const{key:s,...i}=o;return O("li",{...i,children:[c&&r(M,{checked:l,sx:{mr:1}}),r(V,{name:e.label,logoUrl:e.logoUrl,size:28,sx:{mr:1}}),r(H,{option:e})]},s)},renderTags:(o,e)=>o.map((l,s)=>{const{key:i,...a}=e({index:s});return O(R,{children:[s>0&&r(E,{}),r(A,{...a,label:l.label,name:l.label,logoUrl:l.logoUrl})]},i)}),renderInput:o=>r(C,{...o,label:m,placeholder:p.length===0?v?.searchPlaceholder??"Type to search\u2026":void 0,error:y,helperText:L})}):r(C,{fullWidth:!0,disabled:!0,label:m,value:p.join(", "),error:!0,helperText:`No data source is registered for "${n.values.source}"`})}export{D as RemoteValuesInput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useState as
|
|
1
|
+
"use strict";import{useState as y,Fragment as O}from"react";import{Autocomplete as C,TextField as V,Chip as I}from"@mui/material";import{dedupeValues as S}from"../../../utils/condition.mjs";import{presetOptionLabel as u,filterPresetOptions as j}from"../presetOptions.mjs";import{OrSeparator as F}from"./OrSeparator.mjs";import{jsx as a,jsxs as L}from"react/jsx-runtime";function P({values:l,onChange:m,multi:d,label:f,presets:g=[],onCreatePreset:s,error:h,helperText:c,disabled:x,placeholder:b="Type a value and press Enter"}){const[n,p]=y(""),i=t=>{const e=S(t);m(d?e:e.slice(-1))};return a(C,{multiple:!0,freeSolo:!0,autoHighlight:!0,options:g,value:l,inputValue:n,disabled:x,limitTags:4,getOptionLabel:u,filterOptions:(t,e)=>j(t,e,s!==void 0),onInputChange:(t,e)=>{p(e)},onChange:(t,e)=>{const o=e.find(r=>typeof r!="string");o!==void 0&&typeof o!="string"&&s?.(o.inputValue),i(e.map(r=>typeof r=="string"?r:r.inputValue)),p("")},onBlur:()=>{n.trim()&&(i([...l,n]),p(""))},renderTags:(t,e)=>t.map((o,r)=>{const{key:T,...v}=e({index:r});return L(O,{children:[r>0&&a(F,{}),a(I,{...v,label:u(o)})]},T)}),renderInput:t=>a(V,{...t,label:f,placeholder:l.length===0?b:void 0,error:h,helperText:c})})}export{P as TextValuesInput};
|