@verifiedinc-public/shared-ui-elements 12.9.1-rc.21 → 12.9.1-rc.24
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/ConditionsField.mjs +1 -1
- package/dist/components/NetworkRules/editor/fields/values/InlineValuesInput.mjs +1 -1
- package/dist/components/NetworkRules/editor/fields/values/RemoteValuesInput.mjs +1 -1
- package/dist/components/NetworkRules/shared/OptionChips.d.ts +4 -3
- package/dist/components/NetworkRules/shared/OptionChips.mjs +1 -1
- package/dist/components/NetworkRules/shared/OptionLabel.d.ts +5 -0
- package/dist/components/NetworkRules/shared/OptionLabel.mjs +1 -0
- package/dist/components/NetworkRules/table/NetworkRuleConditionsTable.mjs +1 -1
- package/dist/components/NetworkRules/types.d.ts +8 -9
- package/dist/components/NetworkRules/utils/catalog.mjs +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Dialog as
|
|
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.value).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 l,Typography as c,Button as x,Alert as F,FormHelperText as A}from"@mui/material";import{Add as I}from"@mui/icons-material";import{useFormContext as b,useFieldArray as
|
|
1
|
+
"use strict";import{Stack as l,Typography as c,Button as x,Alert as F,FormHelperText as A}from"@mui/material";import{Add as I}from"@mui/icons-material";import{useFormContext as b,useFieldArray as j}from"react-hook-form";import{emptyConditionFormValues as w}from"../../utils/condition.mjs";import{ConditionRow as P}from"./ConditionRow.mjs";import{jsxs as m,jsx as e}from"react/jsx-runtime";function R({catalog:p,addedPresets:u,onCreatePreset:f,disabled:n,focusIndex:h}){var t,i,r;const{control:v,formState:s}=b(),{fields:a,append:g,remove:y}=j({control:v,name:"conditions"}),d=((i=(t=s.errors.conditions)==null?void 0:t.root)==null?void 0:i.message)??((r=s.errors.conditions)==null?void 0:r.message);return m(l,{spacing:2,children:[m(l,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e(c,{fontWeight:700,children:"Conditions"}),e(x,{startIcon:e(I,{}),disabled:n,onClick:()=>{g(w())},children:"Add Condition"})]}),e(F,{severity:"info",children:"If multiple values are selected for a given condition, that condition applies if any one of the values matches. (It's an inclusive OR.)"}),a.length===0&&e(c,{variant:"body2",color:"text.secondary",children:"No conditions yet. A rule needs at least one; all conditions must match."}),a.map((C,o)=>e(P,{index:o,catalog:p,addedPresets:u,onCreatePreset:f,disabled:n,autoFocus:o===h,onRemove:()=>{y(o)}},C.id)),d&&e(A,{error:!0,children:d})]})}export{R as ConditionsField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Autocomplete as
|
|
1
|
+
"use strict";import{Autocomplete as h,TextField as x,Checkbox as v}from"@mui/material";import{OptionLabel as O}from"../../../shared/OptionLabel.mjs";import{toOptions as f}from"../../../utils/catalog.mjs";import{jsx as t,jsxs as g}from"react/jsx-runtime";function T({options:s,values:i,onChange:n,multi:a,label:p,error:u,helperText:c,disabled:d}){const m=f(i,s);return t(h,{multiple:!0,options:s,value:m,disabled:d,limitTags:4,disableCloseOnSelect:a,getOptionLabel:e=>e.label,isOptionEqualToValue:(e,l)=>e.value===l.value,onChange:(e,l)=>{const o=l.map(r=>r.value);n(a?o:o.slice(-1))},renderOption:(e,l,{selected:o})=>{const{key:r,...b}=e;return g("li",{...b,children:[a&&t(v,{checked:o,sx:{mr:1}}),t(O,{option:l})]},r)},renderInput:e=>t(x,{...e,label:p,placeholder:i.length===0?"Select\u2026":void 0,error:u,helperText:c})})}export{T as InlineValuesInput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useState as
|
|
1
|
+
"use strict";import{useState as d}from"react";import{Button as w,TextField as C,Autocomplete as R,Checkbox as U,Box as z,CircularProgress as M}from"@mui/material";import{LogoAvatar as N}from"../../../../UI/LogoAvatar.mjs";import{LogoChip as P}from"../../../../UI/LogoChip.mjs";import{useNetworkRuleSourceSearch as V}from"../../../hooks/useNetworkRuleSourceSearch.mjs";import{useResolvedConditionOptions as A}from"../../../hooks/useResolvedConditionOptions.mjs";import{OptionLabel as H}from"../../../shared/OptionLabel.mjs";import{jsx as l,jsxs as B}from"react/jsx-runtime";const E=50;function q({keyDef:n,values:p,onChange:O,multi:c,label:m,error:k,helperText:y,disabled:L}){const[u,h]=d(""),[g,f]=d(!1),[S,I]=d([]),t=V(n.values.source,u,{enabled:g}),b=A(n,p,{known:S}),v=t.service,x=t.isLoading||t.isLoadingMore,j=o=>{const e=o.currentTarget;e.scrollTop+e.clientHeight>=e.scrollHeight-E&&t.loadMore()};let T=u.trim()?"No matches":"Type to search";return t.error&&(T=l(w,{size:"small",onClick:t.retry,children:"Search failed. Retry"})),t.isSupported?l(R,{multiple:!0,open:g,onOpen:()=>{f(!0)},onClose:()=>{f(!1)},options:t.options,value:b.options,loading:x||b.isLoading,ListboxProps:{onScroll:j},popupIcon:x?l(z,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center"},children:l(M,{color:"inherit",size:18})}):void 0,disabled:L,limitTags:4,disableCloseOnSelect:c,filterOptions:o=>o,inputValue:u,onInputChange:(o,e,r)=>{r!=="reset"&&h(e)},getOptionLabel:o=>o.label,isOptionEqualToValue:(o,e)=>o.value===e.value,onChange:(o,e)=>{I(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 r=e.map(s=>s.value);O(c?r:r.slice(-1)),h("")},noOptionsText:T,renderOption:(o,e,{selected:r})=>{const{key:s,...i}=o;return B("li",{...i,children:[c&&l(U,{checked:r,sx:{mr:1}}),l(N,{name:e.label,logoUrl:e.logoUrl,size:28,sx:{mr:1}}),l(H,{option:e})]},s)},renderTags:(o,e)=>o.map((r,s)=>{const{key:i,...a}=e({index:s});return l(P,{...a,label:r.label,name:r.label,logoUrl:r.logoUrl},i)}),renderInput:o=>l(C,{...o,label:m,placeholder:p.length===0?v?.searchPlaceholder??"Type to search\u2026":void 0,error:k,helperText:y})}):l(C,{fullWidth:!0,disabled:!0,label:m,value:p.join(", "),error:!0,helperText:`No data source is registered for "${n.values.source}"`})}export{q as RemoteValuesInput};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { NetworkRuleOption
|
|
2
|
+
import { NetworkRuleOption } from '../types';
|
|
3
3
|
export interface OptionChipsProps {
|
|
4
4
|
options: readonly NetworkRuleOption[];
|
|
5
|
-
|
|
5
|
+
/** Remote-source values: chips carry the option's logo, or its initial. */
|
|
6
|
+
withLogo?: boolean;
|
|
6
7
|
emptyPlaceholder?: ReactNode;
|
|
7
8
|
}
|
|
8
9
|
/** Condition values as a wrapping row of chips. */
|
|
9
|
-
export declare function OptionChips({ options,
|
|
10
|
+
export declare function OptionChips({ options, withLogo, emptyPlaceholder, }: Readonly<OptionChipsProps>): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{Stack as i,Chip as p}from"@mui/material";import{LogoChip as s}from"../../UI/LogoChip.mjs";import{jsx as e,Fragment as t}from"react/jsx-runtime";function m({options:l,withLogo:o=!1,emptyPlaceholder:r="-"}){return l.length===0?e(t,{children:r}):e(i,{direction:"row",flexWrap:"wrap",useFlexGap:!0,gap:.75,children:l.map(a=>o?e(s,{size:"small",label:a.label,name:a.label,logoUrl:a.logoUrl},a.value):e(p,{size:"small",label:a.label},a.value))})}export{m as OptionChips};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NetworkRuleOption } from '../types';
|
|
2
|
+
/** The label with its code inline, so the code ends the label's last line when the label wraps. */
|
|
3
|
+
export declare function OptionLabel({ option, }: Readonly<{
|
|
4
|
+
option: NetworkRuleOption;
|
|
5
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Typography as n}from"@mui/material";import{jsxs as a,jsx as r}from"react/jsx-runtime";function t({option:o}){return a(n,{children:[o.label,r(n,{component:"span",variant:"caption",color:"text.secondary",sx:{ml:1},children:o.value})]})}export{t as OptionLabel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useMemo as
|
|
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.value),[n.value]),{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};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ReactElement
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import { ChipProps } from '@mui/material';
|
|
3
3
|
import { QueryClient } from '@tanstack/react-query';
|
|
4
4
|
export type NetworkRuleOption<TData = unknown> = {
|
|
5
5
|
value: string;
|
|
6
6
|
label: string;
|
|
7
|
-
/**
|
|
7
|
+
/** Remote options show it as an avatar before the label, with the label's initial as fallback. */
|
|
8
|
+
logoUrl?: string | null;
|
|
9
|
+
/** The raw record a remote source returned. */
|
|
8
10
|
data?: TData;
|
|
9
11
|
};
|
|
10
12
|
export type NetworkRuleStatusPresentation = {
|
|
@@ -31,13 +33,15 @@ export type NetworkRuleKeyDef = {
|
|
|
31
33
|
operators: string[];
|
|
32
34
|
type?: string;
|
|
33
35
|
values?: NetworkRuleKeyValues;
|
|
36
|
+
/** The brand's saved suggestions for a free-text key. */
|
|
37
|
+
presets?: string[];
|
|
34
38
|
};
|
|
35
39
|
export type NetworkRuleCatalog = {
|
|
36
40
|
statuses: string[];
|
|
37
41
|
operators: Record<string, NetworkRuleOperatorDef>;
|
|
38
42
|
keys: NetworkRuleKeyDef[];
|
|
39
|
-
/** The brand's saved suggestions
|
|
40
|
-
|
|
43
|
+
/** The brand's saved suggestions for the rule's note. */
|
|
44
|
+
notePresets?: string[];
|
|
41
45
|
};
|
|
42
46
|
/** `value` is one string or several (inclusive OR). */
|
|
43
47
|
export type NetworkRuleCondition = {
|
|
@@ -97,16 +101,11 @@ export type NetworkRuleSourceSearchParams = {
|
|
|
97
101
|
limit?: number;
|
|
98
102
|
skip?: number;
|
|
99
103
|
};
|
|
100
|
-
export type NetworkRuleRenderOption<TData = unknown> = (option: NetworkRuleOption<TData>) => ReactNode;
|
|
101
|
-
/** Receives the props the default chip would get; spread them to keep size, deletion and keyboard behaviour. */
|
|
102
|
-
export type NetworkRuleRenderChip<TData = unknown> = (option: NetworkRuleOption<TData>, chipProps: ChipProps) => ReactNode;
|
|
103
104
|
/** One remote option source, keyed by `NetworkRuleKeyDef.values.source`. */
|
|
104
105
|
export type NetworkRuleSourceService<TData = unknown> = {
|
|
105
106
|
search: (params: NetworkRuleSourceSearchParams, signal?: AbortSignal) => Promise<Array<NetworkRuleOption<TData>>>;
|
|
106
107
|
/** Labels for stored values. Without it they render as their raw string. */
|
|
107
108
|
resolve?: (values: string[], signal?: AbortSignal) => Promise<Array<NetworkRuleOption<TData>>>;
|
|
108
|
-
renderOption?: NetworkRuleRenderOption<TData>;
|
|
109
|
-
renderChip?: NetworkRuleRenderChip<TData>;
|
|
110
109
|
searchPlaceholder?: string;
|
|
111
110
|
};
|
|
112
111
|
export type NetworkRulesServices = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{getStatusPresentation as a}from"../statuses.mjs";function l(e,
|
|
1
|
+
"use strict";import{getStatusPresentation as a}from"../statuses.mjs";function l(e,t){return e?.keys.find(n=>n.key===t)}function r(e,t){var n;return((n=l(e,t))==null?void 0:n.label)??t}function s(e,t){var n;return((n=e?.operators[t])==null?void 0:n.label)??t}function i(e,t){var n;return((n=e?.operators[t])==null?void 0:n.multi)??!0}function v(e){return a(e).label}function o(e){var t;return Array.isArray((t=e?.values)==null?void 0:t.options)}function f(e){var t;return!o(e)&&typeof((t=e?.values)==null?void 0:t.source)=="string"&&e.values.source.length>0}function d(e,t){return e.map(n=>t.find(u=>u.value===n)??{value:n,label:n})}function p(e,t){var n;return t==="notes"?e?.notePresets??[]:((n=l(e,t))==null?void 0:n.presets)??[]}export{l as getKeyDef,r as getKeyLabel,s as getOperatorLabel,p as getPresets,v as getStatusLabel,o as hasInlineOptions,f as hasRemoteSource,i as isOperatorMulti,d as toOptions};
|
package/package.json
CHANGED