@verifiedinc-public/shared-ui-elements 12.15.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/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{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};
|