@verifiedinc-public/shared-ui-elements 12.9.1-rc.10 → 12.9.1-rc.18
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/NetworkRuleEditorDialog.d.ts +1 -1
- package/dist/components/NetworkRules/editor/NetworkRuleEditorDialog.mjs +1 -1
- package/dist/components/NetworkRules/editor/NetworkRuleEditorForm.d.ts +3 -3
- package/dist/components/NetworkRules/editor/NetworkRuleEditorForm.mjs +1 -1
- package/dist/components/NetworkRules/editor/fields/ConditionsField.mjs +1 -1
- package/dist/components/NetworkRules/editor/fields/NotesField.d.ts +4 -0
- package/dist/components/NetworkRules/editor/fields/NotesField.mjs +1 -1
- package/dist/components/NetworkRules/editor/fields/values/InlineValuesInput.mjs +1 -1
- package/dist/components/NetworkRules/hooks/useNetworkRulesDialogs.d.ts +2 -4
- package/dist/components/NetworkRules/hooks/useNetworkRulesDialogs.mjs +1 -1
- package/dist/components/NetworkRules/table/NetworkRuleExpandedPanel.d.ts +1 -2
- package/dist/components/NetworkRules/table/NetworkRuleExpandedPanel.mjs +1 -1
- package/dist/components/NetworkRules/table/NetworkRuleRow.mjs +1 -1
- package/dist/components/NetworkRules/table/NetworkRulesTable.d.ts +5 -9
- package/dist/components/NetworkRules/table/NetworkRulesTable.mjs +1 -1
- package/dist/components/NetworkRules/table/columns.d.ts +0 -1
- package/dist/components/NetworkRules/table/columns.mjs +1 -1
- package/dist/components/NetworkRules/types.d.ts +2 -0
- package/dist/styles/theme.mjs +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Dialog as
|
|
1
|
+
"use strict";import{Dialog as k,DialogTitle as x,DialogContent as w,DialogContentText as L,DialogActions as T,Button as m,CircularProgress as j}from"@mui/material";import{useHeldWhileClosed as u}from"../hooks/useHeldWhileClosed.mjs";import{useNetworkRulesCatalog as W}from"../hooks/useNetworkRulesCatalog.mjs";import{getKeyLabel as y,getOperatorLabel as z}from"../utils/catalog.mjs";import{normalizeConditionValues as I}from"../utils/condition.mjs";import{jsxs as v,jsx as e}from"react/jsx-runtime";function N({open:r,rule:h,conditionIndex:f,onConfirm:p,onClose:a,isDeleting:n=!1,title:C,description:g,confirmLabel:D="Delete",cancelLabel:b="Cancel"}){const{data:s}=W(),o=u(r,h??void 0),i=u(r,f??void 0),t=o!==void 0&&i!==void 0?o.conditions[i]:void 0,d=i!==void 0,$=C??(d?"Delete condition?":"Delete rule?");let l=g;if(l===void 0&&o!==void 0)if(d)l=`"${t?`${y(s,t.key)} ${z(s,t.operator)} ${I(t.value).join(", ")}`:`Condition ${i+1}`}" will be removed from "${o.name}". The rule keeps its other conditions.`;else{const c=o.conditions.length;l=`"${o.name}" and its ${c} ${c===1?"condition":"conditions"} will be removed. This cannot be undone.`}return v(k,{open:r,onClose:n?void 0:a,maxWidth:"xs",fullWidth:!0,children:[e(x,{children:$}),e(w,{children:e(L,{children:l})}),v(T,{children:[e(m,{color:"neutral",onClick:a,disabled:n,children:b}),e(m,{color:"error",variant:"contained",disabled:n||o===void 0,startIcon:n?e(j,{size:16,color:"inherit"}):void 0,onClick:()=>{o!==void 0&&p(o,i)},children:D})]})]})}export{N as NetworkRuleDeleteDialog};
|
|
@@ -7,4 +7,4 @@ export interface NetworkRuleEditorDialogProps extends Omit<NetworkRuleEditorForm
|
|
|
7
7
|
title?: string;
|
|
8
8
|
maxWidth?: DialogProps['maxWidth'];
|
|
9
9
|
}
|
|
10
|
-
export declare function NetworkRuleEditorDialog({ open, onClose, title, maxWidth, rule: ruleProp,
|
|
10
|
+
export declare function NetworkRuleEditorDialog({ open, onClose, title, maxWidth, rule: ruleProp, focusConditionIndex: focusConditionIndexProp, isSubmitting, disabled, submitLabel, cancelLabel, ...formProps }: Readonly<NetworkRuleEditorDialogProps>): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useId as
|
|
1
|
+
"use strict";import{useId as w,useState as m,useEffect as W,useCallback as v}from"react";import{Dialog as y,DialogTitle as I,DialogContent as S,DialogActions as j,Button as f,CircularProgress as A}from"@mui/material";import{NetworkRuleDiscardDialog as L}from"../dialog/NetworkRuleDiscardDialog.mjs";import{useHeldWhileClosed as l}from"../hooks/useHeldWhileClosed.mjs";import{NetworkRuleEditorForm as $}from"./NetworkRuleEditorForm.mjs";import{jsxs as b,jsx as e}from"react/jsx-runtime";function z(i){return i!=null&&i.uuid?"Edit Network Rule":"Create Network Rule"}function B({open:i,onClose:a,title:h,maxWidth:p="md",rule:s,focusConditionIndex:g,isSubmitting:t=!1,disabled:n=!1,submitLabel:C="Save",cancelLabel:D="Cancel",...k}){const o=w(),[d,u]=m(!1),[x,r]=m(!1);W(()=>{i&&(u(!1),r(!1))},[i]);const c=v(()=>{if(!t){if(d){r(!0);return}a()}},[t,d,a]),E=l(i,s),N=l(i,g),R=l(i,h??z(s));return b(y,{open:i,onClose:c,fullWidth:!0,maxWidth:p,"aria-labelledby":`${o}-title`,children:[e(I,{id:`${o}-title`,children:R}),e(S,{children:e($,{...k,rule:E,focusConditionIndex:N,id:o,hideActions:!0,isSubmitting:t,disabled:n,onDirtyChange:u})}),b(j,{children:[e(f,{color:"neutral",onClick:c,disabled:t,children:D}),e(f,{type:"submit",form:o,variant:"contained",disabled:n||t,startIcon:t?e(A,{size:16,color:"inherit"}):void 0,children:C})]}),e(L,{open:x,onKeepEditing:()=>{r(!1)},onDiscard:()=>{r(!1),a()}})]})}export{B as NetworkRuleEditorDialog};
|
|
@@ -2,6 +2,8 @@ import { NetworkRule, NetworkRuleData, NetworkRuleServerError, NetworkRuleSubmit
|
|
|
2
2
|
export interface NetworkRuleEditorFormProps {
|
|
3
3
|
/** Omit for a new rule. */
|
|
4
4
|
rule?: Partial<NetworkRule> | null;
|
|
5
|
+
/** Pre-filled, editable name for a new rule, e.g. "Rule #7". */
|
|
6
|
+
defaultName?: string;
|
|
5
7
|
notePresets?: readonly string[];
|
|
6
8
|
/** Offer "Add … as a preset" for a typed note; new presets arrive with `onSubmit`. */
|
|
7
9
|
canCreateNotePresets?: boolean;
|
|
@@ -10,8 +12,6 @@ export interface NetworkRuleEditorFormProps {
|
|
|
10
12
|
isSubmitting?: boolean;
|
|
11
13
|
/** Indexed errors highlight their condition row; the rest show at the top. */
|
|
12
14
|
serverErrors?: readonly NetworkRuleServerError[];
|
|
13
|
-
/** Open with one extra empty condition row. */
|
|
14
|
-
appendEmptyCondition?: boolean;
|
|
15
15
|
focusConditionIndex?: number;
|
|
16
16
|
submitLabel?: string;
|
|
17
17
|
cancelLabel?: string;
|
|
@@ -21,4 +21,4 @@ export interface NetworkRuleEditorFormProps {
|
|
|
21
21
|
hideActions?: boolean;
|
|
22
22
|
onDirtyChange?: (isDirty: boolean) => void;
|
|
23
23
|
}
|
|
24
|
-
export declare function NetworkRuleEditorForm({ rule, notePresets, canCreateNotePresets, onSubmit, onCancel, isSubmitting, serverErrors,
|
|
24
|
+
export declare function NetworkRuleEditorForm({ rule, defaultName, notePresets, canCreateNotePresets, onSubmit, onCancel, isSubmitting, serverErrors, focusConditionIndex, submitLabel, cancelLabel, disabled, id, hideActions, onDirtyChange, }: Readonly<NetworkRuleEditorFormProps>): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useState as V,useEffect as
|
|
1
|
+
"use strict";import{useState as V,useEffect as F,useRef as Y,useMemo as Z}from"react";import{Stack as m,Alert as j,Button as w,TextField as _,FormControlLabel as K,Switch as ee,CircularProgress as re,Skeleton as b}from"@mui/material";import{zodResolver as oe}from"@hookform/resolvers/zod";import{addDays as te}from"date-fns";import{useForm as ae,useWatch as ne,FormProvider as se,Controller as C}from"react-hook-form";import{useNetworkRuleStatuses as ie}from"../NetworkRules.context.mjs";import{useNetworkRulesCatalog as le}from"../hooks/useNetworkRulesCatalog.mjs";import{fromNetworkRuleFormValues as de,toNetworkRuleFormValues as ue,emptyConditionFormValues as ce}from"../utils/condition.mjs";import{ruleDateToDay as me}from"../utils/date.mjs";import{ConditionsField as he}from"./fields/ConditionsField.mjs";import{DateField as L}from"./fields/DateField.mjs";import{NotesField as fe}from"./fields/NotesField.mjs";import{StatusField as ve}from"./fields/StatusField.mjs";import{networkRuleFormSchema as pe}from"./schema.mjs";import{jsx as e,jsxs as h,Fragment as ge}from"react/jsx-runtime";function z(a,i){const n=ue(a);return!(a!=null&&a.uuid)&&!n.name&&i&&(n.name=i),n.conditions.length===0&&(n.conditions=[ce()]),n}function be(a,i){const n=[],v=[];for(const d of i){const f=d.message??d.code;if(typeof d.index=="number"){const u=`conditions.${d.index}.values`;a.setError(u,{type:"server",message:f}),v.push(u)}else n.push(f)}return n.length>0&&a.setError("root.server",{type:"server",message:n.join(" ")}),v}function Ce(){return h(m,{spacing:2,"aria-busy":!0,children:[e(b,{variant:"rounded",height:56}),e(b,{variant:"rounded",height:56}),e(b,{variant:"rounded",height:56}),e(b,{variant:"rounded",height:120})]})}function Se({rule:a,defaultName:i,notePresets:n,canCreateNotePresets:v=!1,onSubmit:d,onCancel:f,isSubmitting:u=!1,serverErrors:k,focusConditionIndex:A,submitLabel:I="Save",cancelLabel:W="Cancel",disabled:M=!1,id:U,hideActions:$=!1,onDirtyChange:S}){var D,R;const p=le(),c=p.data,q=ie()??c?.statuses??[],g=a?.uuid??"new",[N,G]=V(g),o=ae({defaultValues:z(a,i),resolver:oe(pe),mode:"onSubmit",reValidateMode:"onChange"}),[y,E]=V([]);F(()=>{g!==N&&(o.reset(z(a,i)),E([]),G(g))},[o,a,i,g,N]);const x=Y([]);F(()=>{o.clearErrors("root.server"),x.current.length>0&&o.clearErrors(x.current),x.current=be(o,k??[])},[o,k]);const{isDirty:T}=o.formState;F(()=>{S?.(T)},[T,S]);const l=M||u,B=(R=(D=o.formState.errors.root)==null?void 0:D.server)==null?void 0:R.message,H=ne({control:o.control,name:"startDate"}),P=me(H),J=P?te(P,1):void 0,O=Z(()=>[...n??[],...y],[n,y]),Q=r=>{E(t=>t.includes(r)?t:[...t,r])},X=o.handleSubmit(async r=>{c!==void 0&&await d(de(r),{newNotePresets:y})});return e(se,{...o,children:e("form",{id:U,noValidate:!0,onSubmit:r=>{r.preventDefault(),r.stopPropagation(),X(r)},children:h(m,{spacing:3,children:[p.isError&&e(j,{severity:"error",action:e(w,{color:"inherit",size:"small",onClick:()=>{p.refetch()},children:"Retry"}),children:"The rule catalog could not be loaded."}),B&&e(j,{severity:"error",children:B}),c===void 0?!p.isError&&e(Ce,{}):h(ge,{children:[h(m,{direction:{xs:"column",md:"row"},spacing:2,children:[e(C,{control:o.control,name:"name",render:({field:r,fieldState:t})=>{var s;return e(_,{...r,label:"Rule Name",required:!0,fullWidth:!0,disabled:l,error:t.error!==void 0,helperText:(s=t.error)==null?void 0:s.message,sx:{flex:2}})}}),e(m,{flex:1,minWidth:{md:220},children:e(ve,{statuses:q,disabled:l})})]}),h(m,{direction:{xs:"column",md:"row"},spacing:2,children:[e(C,{control:o.control,name:"startDate",render:({field:r,fieldState:t})=>{var s;return e(L,{label:"Starts",value:r.value,onChange:r.onChange,onBlur:r.onBlur,disabled:l,error:t.error!==void 0,helperText:((s=t.error)==null?void 0:s.message)??"Starts applying at the start of this day (UTC)"})}}),e(C,{control:o.control,name:"endDate",render:({field:r,fieldState:t})=>{var s;return e(L,{label:"Ends",value:r.value,onChange:r.onChange,onBlur:r.onBlur,disabled:l,minDate:J,error:t.error!==void 0,helperText:((s=t.error)==null?void 0:s.message)??"Stops applying at the start of this day (UTC)"})}})]}),e(fe,{presets:O,onCreatePreset:v?Q:void 0,disabled:l}),e(C,{control:o.control,name:"enabled",render:({field:r})=>e(K,{label:"Enabled",control:e(ee,{checked:r.value,onChange:(t,s)=>{r.onChange(s)},onBlur:r.onBlur,inputRef:r.ref,disabled:l})})}),e(he,{catalog:c,disabled:l,focusIndex:A})]}),!$&&h(m,{direction:"row",spacing:1,justifyContent:"flex-end",children:[f&&e(w,{onClick:f,disabled:u,children:W}),e(w,{type:"submit",variant:"contained",disabled:l||c===void 0,startIcon:u?e(re,{size:16,color:"inherit"}):void 0,children:I})]})]})})})}export{Se as NetworkRuleEditorForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Stack as l,Typography as c,Button as y,FormHelperText as
|
|
1
|
+
"use strict";import{Stack as l,Typography as c,Button as y,Alert as x,FormHelperText as C}from"@mui/material";import{Add as F}from"@mui/icons-material";import{useFormContext as A,useFieldArray as I}from"react-hook-form";import{emptyConditionFormValues as b}from"../../utils/condition.mjs";import{ConditionRow as w}from"./ConditionRow.mjs";import{jsxs as m,jsx as o}from"react/jsx-runtime";function j({catalog:p,disabled:n,focusIndex:u}){var i,t,r;const{control:f,formState:s}=A(),{fields:a,append:h,remove:v}=I({control:f,name:"conditions"}),d=((t=(i=s.errors.conditions)==null?void 0:i.root)==null?void 0:t.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:[o(c,{fontWeight:700,children:"Conditions"}),o(y,{startIcon:o(F,{}),disabled:n,onClick:()=>{h(b())},children:"Add Condition"})]}),o(x,{severity:"info",children:"If multiple values are selected for a given condition, that condition applies if any of the values match. In other words, multiple values map to an inclusive OR."}),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((g,e)=>o(w,{index:e,catalog:p,disabled:n,autoFocus:e===u,onRemove:()=>{v(e)}},g.id)),d&&o(C,{error:!0,children:d})]})}export{j as ConditionsField};
|
|
@@ -5,4 +5,8 @@ export interface NotesFieldProps {
|
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
helperText?: string;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* One note, a preset or free text, shown as a chip so a preset reads as one.
|
|
10
|
+
* `multiple` is only for the chip rendering: picking or typing replaces it.
|
|
11
|
+
*/
|
|
8
12
|
export declare function NotesField({ presets, onCreatePreset, disabled, helperText, }: Readonly<NotesFieldProps>): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Autocomplete as
|
|
1
|
+
"use strict";import{useState as b}from"react";import{Autocomplete as x,TextField as V,createFilterOptions as y}from"@mui/material";import{useFormContext as w,useController as F}from"react-hook-form";import{jsx as c}from"react/jsx-runtime";const L=y(),p=n=>typeof n=="string"?n:n.label;function O({presets:n=[],onCreatePreset:l,disabled:g,helperText:f="Returned with the network status so your app can act on it"}){var d;const{control:C}=w(),{field:r,fieldState:m}=F({control:C,name:"notes"}),[s,i]=b(""),u=(d=r.value)!=null&&d.trim()?r.value:null;return c(x,{multiple:!0,freeSolo:!0,autoHighlight:!0,options:n,value:u?[u]:[],inputValue:s,disabled:g,getOptionLabel:p,isOptionEqualToValue:(o,e)=>p(o)===p(e),onInputChange:(o,e,t)=>{t!=="reset"&&i(e)},onChange:(o,e)=>{const t=e[e.length-1];t===void 0?r.onChange(null):typeof t=="string"?r.onChange(t):(r.onChange(t.inputValue),l?.(t.inputValue)),i("")},onBlur:()=>{s.trim()&&(r.onChange(s.trim()),i("")),r.onBlur()},filterOptions:(o,e)=>{const t=L(o,e),a=e.inputValue.trim(),v=o.some(h=>typeof h=="string"&&h.toLowerCase()===a.toLowerCase());return a&&l&&!v&&t.push({inputValue:a,label:`Add "${a}" as a preset`}),t},renderInput:o=>{var e;return c(V,{...o,label:"Notes",placeholder:u?void 0:"Pick a preset or type a note",error:m.error!==void 0,helperText:((e=m.error)==null?void 0:e.message)??f})}})}export{O as NotesField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Autocomplete as b,TextField as
|
|
1
|
+
"use strict";import{Autocomplete as b,TextField as v,Checkbox as g,Typography as i}from"@mui/material";import{toOptions as O}from"../../../utils/catalog.mjs";import{jsx as o,jsxs as T}from"react/jsx-runtime";function f({options:r,values:s,onChange:p,multi:a,label:c,error:u,helperText:d,disabled:h}){const m=O(s,r);return o(b,{multiple:!0,options:r,value:m,disabled:h,limitTags:4,disableCloseOnSelect:a,getOptionLabel:e=>e.label,isOptionEqualToValue:(e,l)=>e.value===l.value,onChange:(e,l)=>{const t=l.map(n=>n.value);p(a?t:t.slice(-1))},renderOption:(e,l,{selected:t})=>{const{key:n,...x}=e;return T("li",{...x,children:[a&&o(g,{checked:t,sx:{mr:1}}),o(i,{children:l.label}),o(i,{variant:"caption",color:"text.secondary",sx:{ml:1},children:l.value})]},n)},renderInput:e=>o(v,{...e,label:c,placeholder:s.length===0?"Select\u2026":void 0,error:u,helperText:d})})}export{f as InlineValuesInput};
|
|
@@ -6,7 +6,6 @@ export interface NetworkRulesEditorState {
|
|
|
6
6
|
open: boolean;
|
|
7
7
|
/** Undefined for a new rule. */
|
|
8
8
|
rule?: NetworkRule;
|
|
9
|
-
appendEmptyCondition: boolean;
|
|
10
9
|
focusConditionIndex?: number;
|
|
11
10
|
}
|
|
12
11
|
export interface NetworkRulesDeletionState {
|
|
@@ -16,8 +15,8 @@ export interface NetworkRulesDeletionState {
|
|
|
16
15
|
conditionIndex?: number;
|
|
17
16
|
}
|
|
18
17
|
/** Table callbacks wired to the dialogs; `onToggleEnabled` stays with the consumer. */
|
|
19
|
-
export type NetworkRulesDialogTableHandlers = Required<Pick<NetworkRuleRowHandlers, 'onEdit' | 'onDelete' | '
|
|
20
|
-
export type NetworkRulesEditorDialogProps = Pick<NetworkRuleEditorDialogProps, 'open' | 'rule' | '
|
|
18
|
+
export type NetworkRulesDialogTableHandlers = Required<Pick<NetworkRuleRowHandlers, 'onEdit' | 'onDelete' | 'onEditCondition' | 'onDeleteCondition'>>;
|
|
19
|
+
export type NetworkRulesEditorDialogProps = Pick<NetworkRuleEditorDialogProps, 'open' | 'rule' | 'focusConditionIndex' | 'serverErrors' | 'onClose'>;
|
|
21
20
|
export type NetworkRulesDeleteDialogProps = Pick<NetworkRuleDeleteDialogProps, 'open' | 'rule' | 'conditionIndex' | 'onClose'>;
|
|
22
21
|
export interface UseNetworkRulesDialogsResult {
|
|
23
22
|
editor: NetworkRulesEditorState;
|
|
@@ -27,7 +26,6 @@ export interface UseNetworkRulesDialogsResult {
|
|
|
27
26
|
setServerErrors: (errors: NetworkRuleServerError[] | undefined) => void;
|
|
28
27
|
openCreate: () => void;
|
|
29
28
|
openEdit: (rule: NetworkRule) => void;
|
|
30
|
-
openAddCondition: (rule: NetworkRule) => void;
|
|
31
29
|
openEditCondition: (rule: NetworkRule, index: number) => void;
|
|
32
30
|
closeEditor: () => void;
|
|
33
31
|
requestDeleteRule: (rule: NetworkRule) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useState as
|
|
1
|
+
"use strict";import{useState as E,useCallback as o,useMemo as v}from"react";function b(){const[n,t]=E({open:!1}),[i,d]=E({open:!1}),[s,r]=E(),x=o(()=>{r(void 0),t({open:!0})},[]),l=o(e=>{r(void 0),t({open:!0,rule:e})},[]),u=o((e,D)=>{r(void 0),t({open:!0,rule:e,focusConditionIndex:D})},[]),p=o(()=>{r(void 0),t(e=>({...e,open:!1}))},[]),a=o(e=>{d({open:!0,rule:e})},[]),c=o((e,D)=>{d({open:!0,rule:e,conditionIndex:D})},[]),C=o(()=>{d(e=>({...e,open:!1}))},[]),I=v(()=>({onEdit:l,onDelete:a,onEditCondition:u,onDeleteCondition:c}),[l,a,u,c]),f=v(()=>({open:n.open,rule:n.rule,focusConditionIndex:n.focusConditionIndex,serverErrors:s,onClose:p}),[n,s,p]),g=v(()=>({open:i.open,rule:i.rule,conditionIndex:i.conditionIndex,onClose:C}),[i,C]);return{editor:n,deletion:i,serverErrors:s,setServerErrors:r,openCreate:x,openEdit:l,openEditCondition:u,closeEditor:p,requestDeleteRule:a,requestDeleteCondition:c,closeDeletion:C,tableHandlers:I,editorDialogProps:f,deleteDialogProps:g}}export{b as useNetworkRulesDialogs};
|
|
@@ -3,7 +3,6 @@ export interface NetworkRuleRowHandlers {
|
|
|
3
3
|
onToggleEnabled?: (rule: NetworkRule, enabled: boolean) => void;
|
|
4
4
|
onEdit?: (rule: NetworkRule) => void;
|
|
5
5
|
onDelete?: (rule: NetworkRule) => void;
|
|
6
|
-
onAddCondition?: (rule: NetworkRule) => void;
|
|
7
6
|
onEditCondition?: (rule: NetworkRule, index: number) => void;
|
|
8
7
|
onDeleteCondition?: (rule: NetworkRule, index: number) => void;
|
|
9
8
|
}
|
|
@@ -12,4 +11,4 @@ export interface NetworkRuleExpandedPanelProps extends NetworkRuleRowHandlers {
|
|
|
12
11
|
catalog?: NetworkRuleCatalog;
|
|
13
12
|
readOnly?: boolean;
|
|
14
13
|
}
|
|
15
|
-
export declare function NetworkRuleExpandedPanel({ rule, catalog, readOnly, onEdit, onDelete,
|
|
14
|
+
export declare function NetworkRuleExpandedPanel({ rule, catalog, readOnly, onEdit, onDelete, onEditCondition, onDeleteCondition, }: Readonly<NetworkRuleExpandedPanelProps>): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Stack as
|
|
1
|
+
"use strict";import{Stack as n,Button as d,Typography as i}from"@mui/material";import{Edit as x,Delete as h}from"@mui/icons-material";import{CopyableUuid as u}from"../../CopyableUuid/index.mjs";import{NetworkRuleConditionsTable as m}from"./NetworkRuleConditionsTable.mjs";import{jsxs as o,jsx as t}from"react/jsx-runtime";function f({rule:e,catalog:c,readOnly:l=!1,onEdit:r,onDelete:a,onEditCondition:s,onDeleteCondition:p}){return o(n,{spacing:2,useFlexGap:!0,sx:{px:3,py:2},children:[!l&&(r!==void 0||a!==void 0)&&o(n,{direction:"row",spacing:2,alignItems:"center",children:[r&&t(d,{variant:"text",startIcon:t(x,{}),onClick:()=>r(e),children:"Edit"}),a&&t(d,{variant:"text",color:"error",startIcon:t(h,{}),onClick:()=>a(e),children:"Delete"})]}),o(n,{direction:"row",spacing:4,alignItems:"flex-start",children:[o(n,{children:[t(i,{variant:"caption",color:"text.secondary",children:"Rule UUID"}),t(u,{uuid:e.uuid,label:"Rule UUID",variant:"button",head:36,tail:0,mono:!0,iconSx:{fontSize:14,p:.125}})]}),e.notes&&o(n,{sx:{maxWidth:480},children:[t(i,{variant:"caption",color:"text.secondary",children:"Notes"}),t(i,{variant:"body2",children:e.notes})]})]}),o(n,{spacing:1,children:[t(i,{sx:{fontSize:11,fontWeight:700,letterSpacing:.6,textTransform:"uppercase"},children:"Conditions"}),t(m,{rule:e,catalog:c,readOnly:l,onEditCondition:s,onDeleteCondition:p})]})]})}export{f as NetworkRuleExpandedPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{TableRow as u,TableCell as
|
|
1
|
+
"use strict";import{TableRow as u,TableCell as h,Collapse as O,Box as g,Stack as _,Chip as v,Tooltip as S,Switch as T}from"@mui/material";import{flexRender as P}from"@tanstack/react-table";import{useResizeObserver as I}from"../../../hooks/useResizeObserver.mjs";import{useDataTableContext as k}from"../../DataTable/DataTable.context.mjs";import{EXPAND_TRANSITION_MS as A,EXPANDED_ROW_PANEL_SX as L,EXPAND_COLUMN_ID as W,ExpandRowToggle as X}from"../../DataTable/DataTableExpandRow.mjs";import{NetworkStatusChip as $}from"../shared/NetworkStatusChip.mjs";import{NETWORK_RULES_COLUMN_IDS as s}from"./columns.mjs";import{NetworkRuleExpandedPanel as z}from"./NetworkRuleExpandedPanel.mjs";import{jsxs as w,Fragment as M,jsx as e}from"react/jsx-runtime";function U({row:o,rowProps:x,getCellProps:f,catalog:b,readOnly:i=!1,onToggleEnabled:l,...E}){var d;const C=o.getIsExpanded(),t=o.original,n=t.enabled??!0,c=t.conditions.length,m=o.getVisibleCells(),{scrollContainerRef:p}=k();I(p);const r=(d=p.current)==null?void 0:d.clientWidth,N=r!==void 0&&r>0?r:"100%",R=a=>{switch(a.column.id){case W:return e(X,{row:o});case s.enabled:return e(S,{title:n?"Enabled":"Disabled",placement:"top",children:e("span",{children:e(T,{size:"small",checked:n,disabled:i||l===void 0,onChange:(y,D)=>l?.(t,D),inputProps:{"aria-label":`${n?"Disable":"Enable"} rule ${t.name}`}})})});case s.name:return w(_,{direction:"row",spacing:1,alignItems:"center",minWidth:0,children:[e(g,{component:"span",title:t.name,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e(v,{size:"small",label:`${c} ${c===1?"condition":"conditions"}`})]});case s.status:return e($,{status:t.status});default:return P(a.column.columnDef.cell,a.getContext())}};return w(M,{children:[e(u,{...x,hover:!0,sx:{"& > td":{borderBottom:"unset"}},children:m.map(a=>e(h,{...f(a),children:R(a)},a.id))}),e(u,{children:e(h,{sx:{py:0,px:0},colSpan:m.length,children:e(O,{in:C,timeout:A,unmountOnExit:!0,children:e(g,{sx:{...L,width:N},children:e(z,{rule:t,catalog:b,readOnly:i,...E})})})})})]})}export{U as NetworkRuleRow};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { DataTableProps } from '../../DataTable/DataTable.types';
|
|
1
2
|
import { NetworkRule } from '../types';
|
|
2
3
|
import { NetworkRuleRowHandlers } from './NetworkRuleExpandedPanel';
|
|
3
|
-
|
|
4
|
+
type PaginationProps = Pick<DataTableProps<NetworkRule>, 'pagination' | 'onPaginationChange' | 'manualPagination' | 'rowCount' | 'pageSizeOptions'>;
|
|
5
|
+
export interface NetworkRulesTableProps extends NetworkRuleRowHandlers, PaginationProps {
|
|
4
6
|
rules: NetworkRule[];
|
|
5
7
|
isLoading?: boolean;
|
|
6
8
|
/** No toggle, no row or condition actions. */
|
|
@@ -10,12 +12,6 @@ export interface NetworkRulesTableProps extends NetworkRuleRowHandlers {
|
|
|
10
12
|
maxHeight?: number | string;
|
|
11
13
|
/** Defaults to 900. */
|
|
12
14
|
minWidth?: number | string;
|
|
13
|
-
/** Defaults to 'network-rules'. */
|
|
14
|
-
exportFilename?: string;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* through a callback. Rows render once the catalog is available, so codes
|
|
19
|
-
* never flash before their labels.
|
|
20
|
-
*/
|
|
21
|
-
export declare function NetworkRulesTable({ rules, isLoading, readOnly, emptyMessage, maxHeight, minWidth, exportFilename, ...handlers }: Readonly<NetworkRulesTableProps>): import("react").JSX.Element;
|
|
16
|
+
export declare function NetworkRulesTable({ rules, isLoading, readOnly, emptyMessage, maxHeight, minWidth, pagination, onPaginationChange, manualPagination, rowCount, pageSizeOptions, ...handlers }: Readonly<NetworkRulesTableProps>): import("react").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useMemo as
|
|
1
|
+
"use strict";import{useMemo as g}from"react";import{Alert as N,Button as S,Box as x,TableRow as L,TableCell as P,Skeleton as O}from"@mui/material";import{DataTable as T}from"../../DataTable/DataTable.mjs";import{EXPAND_COLUMN_ID as v}from"../../DataTable/DataTableExpandRow.mjs";import{useNetworkRuleStatuses as M}from"../NetworkRules.context.mjs";import{useNetworkRulesCatalog as z}from"../hooks/useNetworkRulesCatalog.mjs";import{getStatusLabel as E}from"../utils/catalog.mjs";import{buildNetworkRulesColumns as I,NETWORK_RULES_COLUMN_IDS as o}from"./columns.mjs";import{NetworkRuleRow as _}from"./NetworkRuleRow.mjs";import{jsx as e,Fragment as A}from"react/jsx-runtime";const D=4;function U({columnCount:a}){return e(A,{children:Array.from({length:D},(i,n)=>e(L,{children:Array.from({length:a},(m,l)=>e(P,{children:e(O,{variant:"text"})},l))},n))})}function F(a){return[{id:o.status,label:"Status",kind:"multiSelect",columnId:o.status,options:a.map(i=>{const n=E(i);return{label:n,value:n}})},{id:o.enabled,label:"Enabled",kind:"boolean",columnId:o.enabled}]}function H({rules:a,isLoading:i=!1,readOnly:n=!1,emptyMessage:m="No network rules yet",maxHeight:l=640,minWidth:c=900,pagination:h,onPaginationChange:b,manualPagination:p,rowCount:f,pageSizeOptions:C,...w}){const s=z(),r=s.data,d=M()??r?.statuses??[],u=r!==void 0,R=g(()=>I(),[]),k=g(()=>F(d),[d]),y=l==="100%";return!u&&s.isError?e(N,{severity:"error",action:e(S,{color:"inherit",size:"small",onClick:()=>{s.refetch()},children:"Retry"}),children:"The rule catalog could not be loaded, so rules cannot be shown."}):e(x,{sx:y?{height:"100%",minHeight:0}:void 0,children:e(T,{data:u?a:[],columns:R,getRowId:t=>t.uuid,isLoading:i||!u,initialPageSize:10,pagination:h,onPaginationChange:b,manualPagination:p,rowCount:f,pageSizeOptions:C,showToolbar:!0,enableColumnMenu:!0,enableColumnResizing:!0,enableColumnPinning:!0,initialColumnPinning:{left:[v,o.enabled,o.name],right:[]},filterFields:k,tableLayout:"fixed",minWidth:c,maxHeight:l,emptyMessage:m,renderRow:t=>e(_,{...t,catalog:r,readOnly:n,...w}),renderLoading:t=>e(U,{columnCount:t})})})}export{H as NetworkRulesTable};
|
|
@@ -3,7 +3,6 @@ import { NetworkRule } from '../types';
|
|
|
3
3
|
export declare const NETWORK_RULES_COLUMN_IDS: {
|
|
4
4
|
readonly enabled: "enabled";
|
|
5
5
|
readonly name: "name";
|
|
6
|
-
readonly conditions: "conditions";
|
|
7
6
|
readonly status: "status";
|
|
8
7
|
readonly startDate: "startDate";
|
|
9
8
|
readonly endDate: "endDate";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{expandColumn as
|
|
1
|
+
"use strict";import{expandColumn as s}from"../../DataTable/DataTableExpandRow.mjs";import{getStatusLabel as l}from"../utils/catalog.mjs";import{formatRuleDate as t}from"../utils/date.mjs";const a={enabled:"enabled",name:"name",status:"status",startDate:"startDate",endDate:"endDate",notes:"notes"},n=({getValue:e})=>e()??"-";function r(){return[s(),{id:a.enabled,header:"Enabled",accessorFn:e=>e.enabled??!0,enableColumnFilter:!1,enableResizing:!1,meta:{width:100,disableColumnMenu:!0}},{id:a.name,header:"Rule Name",accessorFn:e=>e.name,enableColumnFilter:!1,meta:{width:320}},{id:a.status,header:"Status",accessorFn:e=>l(e.status),enableColumnFilter:!1,meta:{width:200}},{id:a.startDate,header:"Starts",accessorFn:e=>t(e.startDate)??void 0,cell:n,enableColumnFilter:!1,meta:{width:280}},{id:a.endDate,header:"Ends",accessorFn:e=>t(e.endDate)??void 0,cell:n,enableColumnFilter:!1,meta:{width:280}},{id:a.notes,header:"Notes",accessorFn:e=>e.notes??"-",enableColumnFilter:!1,meta:{width:300}}]}export{a as NETWORK_RULES_COLUMN_IDS,r as buildNetworkRulesColumns};
|
|
@@ -46,6 +46,8 @@ export type NetworkRuleCondition = {
|
|
|
46
46
|
/** Dates are calendar days, `YYYY-MM-DD`: from the start day up to, not including, the end day. */
|
|
47
47
|
export type NetworkRule = {
|
|
48
48
|
uuid: string;
|
|
49
|
+
/** Per-brand sequence the server assigns on create; absent until then. */
|
|
50
|
+
number?: number;
|
|
49
51
|
name: string;
|
|
50
52
|
status: string;
|
|
51
53
|
notes?: string | null;
|
package/dist/styles/theme.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{createTheme as
|
|
1
|
+
"use strict";import{createTheme as l}from"@mui/material";import{colors as t}from"./colors.mjs";import{typography as n}from"./typography.mjs";import{ensureWcagAAContrast as o}from"../utils/color/index.mjs";function d(r){return typeof r=="object"&&r!==null&&typeof r.main=="string"}function u(r){const{palette:i}=r,a=i.background.default;return i.text.primary=o(i.text.primary,a),i.text.secondary=o(i.text.secondary,a),i.text.disabled=o(i.text.disabled,a),Object.values(i).forEach(e=>{d(e)&&(e.main=o(e.main,a),typeof e.dark=="string"&&(e.dark=o(e.dark,a)),typeof e.contrastText=="string"&&(e.contrastText=o(e.contrastText,e.main)))}),r}const p=({primaryFontFace:r,wcagAAEnabled:i,...a})=>{const e=l({breakpoints:{values:{xs:0,sm:600,md:900,lg:1200,xl:1536}},typography:{fontFamily:r.style.fontFamily,...n},palette:{text:{disabled:t.textDisabled},primary:{main:t.green,light:t.lightGreen,dark:t.darkGreen,contrastText:t.white},secondary:{main:t.blue,light:t.lightBlue,dark:t.darkBlue,contrastText:t.white},error:{main:t.red,light:t.lightRed,dark:t.darkRed,contrastText:t.white},warning:{main:t.yellow,light:t.yellow,dark:t.darkYellow,contrastText:t.white},success:{main:t.green,light:t.green,dark:t.darkGreen,contrastText:t.white},info:{main:t.blue,light:t.lightBlue,dark:t.darkBlue,contrastText:t.infoContrast},neutral:{main:t.grey,light:t.lightGrey,dark:t.darkGrey},neutralContrast:{main:t.greyContrast,light:t.lightGreyContrast,dark:t.darkGreyContrast},warningContrast:{main:t.warningContrast},infoContrast:{main:t.infoContrast},dangerContrast:{main:t.dangerContrast}},components:{MuiAlert:{styleOverrides:{action:{overflowWrap:"normal",display:"flex",alignItems:"center",padding:"8px 0",marginRight:0,"& button, & a":{lineHeight:"0"}}}},MuiAlertTitle:{styleOverrides:{root:{...n.body2,fontSize:"1.1rem",fontWeight:700}}},MuiListItemIcon:{styleOverrides:{root:{minWidth:34}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"1rem",fontWeight:800}}},MuiFab:{styleOverrides:{circular:{width:42,height:42},sizeSmall:{width:40,height:40}}},MuiIconButton:{styleOverrides:{root:{"&.Mui-disabled":{svg:{opacity:.4}}}}},MuiFormLabel:{styleOverrides:{asterisk:({theme:s})=>({color:s.palette.error.main,fontSize:"1.25em",fontWeight:700})}},MuiChip:{styleOverrides:{root:{fontWeight:400}}},MuiButton:{styleOverrides:{root:{fontWeight:800,"&.MuiButton-contained.Mui-focused, &.MuiButton-contained:focus":{boxShadow:"0px 3px 5px -1px rgba(0,0,0,0.25),0px 6px 7px 0px rgba(0,0,0,0.18),0px 1px 12px 0px rgba(0,0,0,0.16)"}}}},MuiDialog:{defaultProps:{maxWidth:"xs"}},MuiDialogTitle:{styleOverrides:{root:{fontSize:20,fontWeight:800,textAlign:"center"}}},MuiDialogContent:{styleOverrides:{root:{paddingTop:"8px!important",paddingBottom:8}}},MuiDialogActions:{styleOverrides:{root:{paddingLeft:24,paddingRight:24,paddingBottom:24,justifyContent:"space-between","& .MuiButton-root":{marginTop:0}}}},MuiRadio:{styleOverrides:{root:{"&.Mui-disabled":{color:`${t.grey} !important`}}}},MuiTableRow:{styleOverrides:{root:{"& th.MuiTableCell-root":{fontSize:12,fontWeight:700,letterSpacing:1},"& td.MuiTableCell-root":{fontSize:20,fontWeight:300}}}},MuiInputBase:{styleOverrides:{root:{"& .MuiInputBase-input":{fontSize:20,fontWeight:300},"& .MuiInputBase-input:not(.MuiInputBase-inputSizeSmall):not(.MuiAutocomplete-input):not(.MuiInputBase-inputMultiline)":{paddingTop:13.625,paddingBottom:13.625},"& .MuiInputBase-input.MuiAutocomplete-input:not(.MuiInputBase-inputSizeSmall)":{paddingTop:4.625,paddingBottom:4.625},"&.MuiInputBase-multiline.MuiInputBase-sizeSmall":{paddingRight:"14px!important"}}}},MuiInputLabel:{defaultProps:{shrink:!0},styleOverrides:{root:{'&[data-shrink="false"]':{fontSize:20,fontWeight:300,transform:"translate(14px, 14px) scale(1)","& span[data-asterisk]":{display:"none"},"&.MuiInputLabel-sizeSmall":{transform:"translate(14px, 9px) scale(1)"}}}}},MuiOutlinedInput:{defaultProps:{notched:!0}},MuiTextField:{defaultProps:{variant:"outlined",size:"medium",InputLabelProps:{shrink:!0}},styleOverrides:{root:{"& .MuiInputBase-multiline textarea":{minHeight:28.75}}}},MuiSelect:{defaultProps:{variant:"outlined",size:"medium",MenuProps:{disableScrollLock:!0}},styleOverrides:{select:{display:"flex",alignItems:"center"}}},MuiAutocomplete:{defaultProps:{size:"medium"}},MuiFormHelperText:{styleOverrides:{root:{wordBreak:"break-word"}}}},...a});return i?u(e):e};export{p as theme};
|
package/package.json
CHANGED