@verifiedinc-public/shared-ui-elements 12.14.0 → 12.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/NetworkRules/dialog/NetworkRuleDeleteDialog.mjs +1 -1
- 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/dist/components/NetworkRules/table/NetworkRuleConditionsTable.mjs +1 -1
- package/dist/components/NetworkRules/types.d.ts +2 -2
- package/dist/components/NetworkRules/utils/condition.d.ts +5 -1
- package/dist/components/NetworkRules/utils/condition.mjs +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Dialog as D,DialogTitle as b,DialogContent as $,DialogContentText as x,DialogActions as k,Button as d,CircularProgress as w}from"@mui/material";import{useHeldWhileClosed as c}from"../hooks/useHeldWhileClosed.mjs";import{useNetworkRulesCatalog as T}from"../hooks/useNetworkRulesCatalog.mjs";import{getKeyLabel as j,getOperatorLabel as L}from"../utils/catalog.mjs";import{normalizeConditionValues as W}from"../utils/condition.mjs";import{jsxs as m,jsx as n}from"react/jsx-runtime";function y(o,e,t){if(t===void 0){const l=e.conditions.length;return`"${e.name}" and its ${l} ${l===1?"condition":"conditions"} will be removed. This cannot be undone.`}const i=e.conditions[t];return`"${i?`${j(o,i.key)} ${L(o,i.operator)} ${W(i.
|
|
1
|
+
"use strict";import{Dialog as D,DialogTitle as b,DialogContent as $,DialogContentText as x,DialogActions as k,Button as d,CircularProgress as w}from"@mui/material";import{useHeldWhileClosed as c}from"../hooks/useHeldWhileClosed.mjs";import{useNetworkRulesCatalog as T}from"../hooks/useNetworkRulesCatalog.mjs";import{getKeyLabel as j,getOperatorLabel as L}from"../utils/catalog.mjs";import{normalizeConditionValues as W}from"../utils/condition.mjs";import{jsxs as m,jsx as n}from"react/jsx-runtime";function y(o,e,t){if(t===void 0){const l=e.conditions.length;return`"${e.name}" and its ${l} ${l===1?"condition":"conditions"} will be removed. This cannot be undone.`}const i=e.conditions[t];return`"${i?`${j(o,i.key)} ${L(o,i.operator)} ${W(i.values).join(", ")}`:`Condition ${t+1}`}" will be removed from "${e.name}". The rule keeps its other conditions.`}function z({open:o,rule:e,conditionIndex:t,onConfirm:i,onClose:l,isDeleting:a=!1,title:u,description:h,confirmLabel:p="Delete",cancelLabel:v="Cancel"}){const{data:C}=T(),r=c(o,e??void 0),s=c(o,t??void 0),f=u??(s!==void 0?"Delete condition?":"Delete rule?"),g=h??(r===void 0?void 0:y(C,r,s));return m(D,{open:o,onClose:a?void 0:l,maxWidth:"xs",fullWidth:!0,children:[n(b,{children:f}),n($,{children:n(x,{children:g})}),m(k,{children:[n(d,{color:"neutral",onClick:l,disabled:a,children:v}),n(d,{color:"error",variant:"contained",disabled:a||r===void 0,startIcon:a?n(w,{size:16,color:"inherit"}):void 0,onClick:()=>{r!==void 0&&i(r,s)},children:p})]})]})}export{z as NetworkRuleDeleteDialog};
|
|
@@ -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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useMemo as b}from"react";import{Typography as f,Table as w,TableHead as y,TableRow as h,TableCell as e,TableBody as x,Chip as v,Skeleton as k,IconButton as p}from"@mui/material";import{Edit as T,Delete as S}from"@mui/icons-material";import{useResolvedConditionOptions as $}from"../hooks/useResolvedConditionOptions.mjs";import{OptionChips as z}from"../shared/OptionChips.mjs";import{getKeyDef as D,getKeyLabel as O,getOperatorLabel as E}from"../utils/catalog.mjs";import{normalizeConditionValues as L}from"../utils/condition.mjs";import{jsx as o,jsxs as c}from"react/jsx-runtime";function K({rule:i,condition:n,index:t,catalog:a,showActions:s,onEditCondition:l,onDeleteCondition:r}){const d=D(a,n.key),m=b(()=>L(n.
|
|
1
|
+
"use strict";import{useMemo as b}from"react";import{Typography as f,Table as w,TableHead as y,TableRow as h,TableCell as e,TableBody as x,Chip as v,Skeleton as k,IconButton as p}from"@mui/material";import{Edit as T,Delete as S}from"@mui/icons-material";import{useResolvedConditionOptions as $}from"../hooks/useResolvedConditionOptions.mjs";import{OptionChips as z}from"../shared/OptionChips.mjs";import{getKeyDef as D,getKeyLabel as O,getOperatorLabel as E}from"../utils/catalog.mjs";import{normalizeConditionValues as L}from"../utils/condition.mjs";import{jsx as o,jsxs as c}from"react/jsx-runtime";function K({rule:i,condition:n,index:t,catalog:a,showActions:s,onEditCondition:l,onDeleteCondition:r}){const d=D(a,n.key),m=b(()=>L(n.values),[n.values]),{options:g,isLoading:u,service:C}=$(d,m);return c(h,{children:[o(e,{sx:{whiteSpace:"nowrap"},children:o(v,{label:O(a,n.key)})}),o(e,{sx:{whiteSpace:"nowrap"},children:E(a,n.operator)}),o(e,{sx:{width:"100%"},children:u?o(k,{variant:"text",width:160}):o(z,{options:g,withLogo:C!==void 0})}),s&&c(e,{align:"right",sx:{whiteSpace:"nowrap"},children:[l&&o(p,{size:"small",color:"primary","aria-label":`Edit condition ${t+1}`,onClick:()=>l(i,t),children:o(T,{fontSize:"small"})}),r&&o(p,{size:"small",color:"error","aria-label":`Delete condition ${t+1}`,disabled:i.conditions.length<=1,onClick:()=>r(i,t),children:o(S,{fontSize:"small"})})]})]})}function R({rule:i,catalog:n,readOnly:t=!1,onEditCondition:a,onDeleteCondition:s}){const l=!t&&(a!==void 0||s!==void 0);return i.conditions.length===0?o(f,{variant:"body2",color:"text.secondary",children:"No conditions"}):c(w,{"aria-label":`Conditions for ${i.name}`,children:[o(y,{children:c(h,{children:[o(e,{children:"Key"}),o(e,{children:"Operator"}),o(e,{children:"Values"}),l&&o(e,{align:"right",children:"Actions"})]})}),o(x,{children:i.conditions.map((r,d)=>o(K,{rule:i,condition:r,index:d,catalog:n,showActions:l,onEditCondition:a,onDeleteCondition:s},`${r.key}-${r.operator}-${d}`))})]})}export{R as NetworkRuleConditionsTable};
|
|
@@ -43,11 +43,11 @@ export type NetworkRuleCatalog = {
|
|
|
43
43
|
/** The brand's saved suggestions for the rule's note. */
|
|
44
44
|
notePresets?: string[];
|
|
45
45
|
};
|
|
46
|
-
/** `
|
|
46
|
+
/** `values` always holds at least one entry; several values are an inclusive OR. */
|
|
47
47
|
export type NetworkRuleCondition = {
|
|
48
48
|
key: string;
|
|
49
49
|
operator: string;
|
|
50
|
-
|
|
50
|
+
values: string[];
|
|
51
51
|
};
|
|
52
52
|
/** Dates are calendar days, `YYYY-MM-DD`: from the start day up to, not including, the end day. */
|
|
53
53
|
export type NetworkRule = {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { NetworkRule, NetworkRuleConditionFormValues, NetworkRuleData, NetworkRuleFormValues } from '../types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Conditions carry `values: string[]`, but a record saved before that contract may still hand
|
|
4
|
+
* over a bare string or null, so this stays tolerant.
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeConditionValues(value: string[] | string | null | undefined): string[];
|
|
3
7
|
export declare function emptyConditionFormValues(): NetworkRuleConditionFormValues;
|
|
4
8
|
export declare function toNetworkRuleFormValues(rule?: Partial<NetworkRule> | null): NetworkRuleFormValues;
|
|
5
9
|
export declare function fromNetworkRuleFormValues(values: NetworkRuleFormValues): NetworkRuleData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function
|
|
1
|
+
"use strict";function r(e){return Array.isArray(e)?e:e==null||e===""?[]:[e]}function t(){return{key:"",operator:"",values:[]}}function u(e){return{name:e?.name??"",status:e?.status??"",notes:e?.notes??null,enabled:e?.enabled??!0,startDate:e?.startDate??null,endDate:e?.endDate??null,conditions:(e?.conditions??[]).map(n=>({key:n.key,operator:n.operator,values:r(n.values)}))}}function i(e){var n;return{name:e.name.trim(),status:e.status,notes:(n=e.notes)!=null&&n.trim()?e.notes.trim():null,enabled:e.enabled,startDate:e.startDate,endDate:e.endDate,conditions:e.conditions.map(o=>({key:o.key,operator:o.operator,values:o.values}))}}function d(e){const n=new Set,o=[];for(const l of e){const a=l.trim();if(!a)continue;const s=a.toLowerCase();n.has(s)||(n.add(s),o.push(a))}return o}export{d as dedupeValues,t as emptyConditionFormValues,i as fromNetworkRuleFormValues,r as normalizeConditionValues,u as toNetworkRuleFormValues};
|