@verifiedinc-public/shared-ui-elements 12.15.1 → 12.17.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.
Files changed (53) hide show
  1. package/dist/components/DataTable/DataTable.filterState.mjs +1 -1
  2. package/dist/components/DataTable/DataTable.types.d.ts +21 -1
  3. package/dist/components/DataTable/DataTableFieldFilterPanel.mjs +1 -1
  4. package/dist/components/NetworkRules/dialog/NetworkRuleDeleteDialog.mjs +1 -1
  5. package/dist/components/NetworkRules/editor/NetworkRuleEditorForm.mjs +1 -1
  6. package/dist/components/NetworkRules/editor/fields/ConditionRow.mjs +1 -1
  7. package/dist/components/NetworkRules/editor/fields/MetadataField.d.ts +12 -0
  8. package/dist/components/NetworkRules/editor/fields/MetadataField.mjs +1 -0
  9. package/dist/components/NetworkRules/editor/fields/MetadataRow.d.ts +14 -0
  10. package/dist/components/NetworkRules/editor/fields/MetadataRow.mjs +1 -0
  11. package/dist/components/NetworkRules/editor/fields/PresetTextInput.d.ts +22 -0
  12. package/dist/components/NetworkRules/editor/fields/PresetTextInput.mjs +1 -0
  13. package/dist/components/NetworkRules/editor/schema.d.ts +44 -2
  14. package/dist/components/NetworkRules/editor/schema.mjs +1 -1
  15. package/dist/components/NetworkRules/hooks/useNetworkRulesDialogs.d.ts +1 -1
  16. package/dist/components/NetworkRules/hooks/useNetworkRulesDialogs.mjs +1 -1
  17. package/dist/components/NetworkRules/index.mjs +1 -1
  18. package/dist/components/NetworkRules/table/NetworkRuleConditionsTable.d.ts +1 -4
  19. package/dist/components/NetworkRules/table/NetworkRuleConditionsTable.mjs +1 -1
  20. package/dist/components/NetworkRules/table/NetworkRuleExpandedPanel.d.ts +1 -3
  21. package/dist/components/NetworkRules/table/NetworkRuleExpandedPanel.mjs +1 -1
  22. package/dist/components/NetworkRules/table/NetworkRuleMetadataTable.d.ts +9 -0
  23. package/dist/components/NetworkRules/table/NetworkRuleMetadataTable.mjs +1 -0
  24. package/dist/components/NetworkRules/table/NetworkRulesTable.d.ts +1 -1
  25. package/dist/components/NetworkRules/table/filters.d.ts +6 -2
  26. package/dist/components/NetworkRules/table/filters.mjs +1 -1
  27. package/dist/components/NetworkRules/table/index.d.ts +1 -0
  28. package/dist/components/NetworkRules/table/query.d.ts +11 -0
  29. package/dist/components/NetworkRules/table/query.mjs +1 -1
  30. package/dist/components/NetworkRules/types.d.ts +33 -3
  31. package/dist/components/NetworkRules/utils/catalog.d.ts +5 -2
  32. package/dist/components/NetworkRules/utils/catalog.mjs +1 -1
  33. package/dist/components/NetworkRules/utils/condition.d.ts +0 -5
  34. package/dist/components/NetworkRules/utils/condition.mjs +1 -1
  35. package/dist/components/NetworkRules/utils/index.d.ts +1 -0
  36. package/dist/components/NetworkRules/utils/metadata.d.ts +41 -0
  37. package/dist/components/NetworkRules/utils/metadata.mjs +1 -0
  38. package/dist/components/UI/SectionLabel.d.ts +6 -0
  39. package/dist/components/UI/SectionLabel.mjs +1 -0
  40. package/dist/components/UI/index.d.ts +1 -0
  41. package/dist/components/form/AddressInput/index.mjs +1 -1
  42. package/dist/components/form/NewOneClickForm/core/fields/employer.d.ts +5 -0
  43. package/dist/components/form/NewOneClickForm/core/fields/index.d.ts +5 -0
  44. package/dist/components/form/NewOneClickForm/core/validations/employer/employer.schema.d.ts +5 -0
  45. package/dist/components/form/NewOneClickForm/core/validations/employer/employer.schema.mjs +1 -1
  46. package/dist/components/form/NewOneClickForm/react/ui/fields/input/employer.field.mjs +1 -1
  47. package/dist/components/form/NewOneClickForm/react/ui/fields/readonly/employer.field.mjs +1 -1
  48. package/dist/components/form/NewOneClickForm/react/ui/fields/readonly/healthInsurance.field.mjs +1 -1
  49. package/dist/components/form/NewOneClickForm/react/ui/fields/shared.d.ts +2 -0
  50. package/dist/components/index.mjs +1 -1
  51. package/dist/index.mjs +1 -1
  52. package/dist/styles/theme.mjs +1 -1
  53. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";function d(t){var e;switch(t.kind){case"text":return{kind:"text",operator:((e=t.operators)==null?void 0:e[0])??"contains",value:""};case"select":return{kind:"select",value:null};case"multiSelect":return{kind:"multiSelect",values:[]};case"boolean":return{kind:"boolean",value:null};case"group":return{kind:"group",values:{}}}}function p(t){const e={};for(const l of t)e[l.id]=d(l);return e}function o(t,e,l){return l&&e.length>0&&e.every(u=>t.includes(u))}function c(t,e){if(!e||e.kind!==t.kind)return!1;const l=t.selectAllClears??!0;switch(e.kind){case"text":return e.operator==="isEmpty"||e.operator==="isNotEmpty"?!0:e.value.trim()!=="";case"select":return e.value!=null&&e.value!=="";case"multiSelect":return e.values.length>0&&!o(e.values,(t.options??[]).map(u=>u.value),l);case"boolean":return e.value!=null;case"group":return(t.sections??[]).some(u=>{const r=e.values[u.key]??[];return r.length>0&&!o(r,u.options.map(n=>n.value),l)})}}function f(t,e){return t.filter(l=>c(l,e[l.id])).length}function g(t,e,l){const u=t==null||t==="",r=u?"":String(t).toLowerCase();if(e==="isEmpty")return u;if(e==="isNotEmpty")return!u;const n=l.trim().toLowerCase();if(n==="")return!0;switch(e){case"doesNotContain":return!r.includes(n);case"equals":return r===n;case"doesNotEqual":return r!==n;case"startsWith":return r.startsWith(n);case"endsWith":return r.endsWith(n);case"contains":default:return r.includes(n)}}function m(t){return typeof t=="boolean"?t:t==="true"||t==="Yes"?!0:t==="false"||t==="No"?!1:null}function h(t,e){switch(e.kind){case"text":return g(t,e.operator,e.value);case"select":return e.value==null||String(t)===e.value;case"multiSelect":return e.values.length===0||e.values.includes(String(t));case"boolean":return e.value==null||m(t)===e.value;case"group":return!0}}function k(t,e,l){const u=t.selectAllClears??!0;return(t.sections??[]).every(r=>{const n=e[r.key]??[];return n.length===0||o(n,r.options.map(s=>s.value),u)?!0:n.includes(String(l(r.key)))})}function y(t,e,l,u=(r,n)=>r[n]){const r=e.filter(n=>c(n,l[n.id])?n.kind==="group"||n.columnId!==void 0:!1);return r.length===0?t:t.filter((n,s)=>r.every(a=>{const i=l[a.id];return i===void 0?!0:i.kind==="group"?k(a,i.values,v=>u(n,v,s)):h(u(n,a.columnId,s),i)}))}export{y as applyFieldFilters,p as buildInitialFilterState,f as effectiveFilterFieldCount,d as emptyFieldValue,c as isFilterFieldActive};
1
+ "use strict";function d(n){var e,r;switch(n.kind){case"text":return{kind:"text",operator:((e=n.operators)==null?void 0:e[0])??"contains",value:""};case"select":return{kind:"select",value:null};case"multiSelect":return{kind:"multiSelect",values:[]};case"boolean":return{kind:"boolean",value:null};case"group":return{kind:"group",values:{}};case"keyedText":return{kind:"keyedText",key:null,operator:((r=n.operators)==null?void 0:r[0])??"contains",value:""}}}function k(n){const e={};for(const r of n)e[r.id]=d(r);return e}function i(n,e,r){return r&&e.length>0&&e.every(l=>n.includes(l))&&n.every(l=>e.includes(l))}function c(n,e){if(!e||e.kind!==n.kind)return!1;const r=n.selectAllClears??!0;switch(e.kind){case"text":return v(e);case"select":return e.value!=null&&e.value!=="";case"multiSelect":return e.values.length>0&&!i(e.values,(n.options??[]).map(l=>l.value),r);case"boolean":return e.value!=null;case"group":return(n.sections??[]).some(l=>{const u=e.values[l.key]??[];return u.length>0&&!i(u,l.options.map(t=>t.value),r)});case"keyedText":return!!e.key&&v(e)}}function v(n){return n.operator==="isEmpty"||n.operator==="isNotEmpty"?!0:n.value.trim()!==""}function y(n,e){return n.filter(r=>c(r,e[r.id])).length}function p(n,e,r){const l=n==null||n==="",u=l?"":String(n).toLowerCase();if(e==="isEmpty")return l;if(e==="isNotEmpty")return!l;const t=r.trim().toLowerCase();if(t==="")return!0;switch(e){case"doesNotContain":return!u.includes(t);case"equals":return u===t;case"doesNotEqual":return u!==t;case"startsWith":return u.startsWith(t);case"endsWith":return u.endsWith(t);case"contains":default:return u.includes(t)}}function g(n){return typeof n=="boolean"?n:n==="true"||n==="Yes"?!0:n==="false"||n==="No"?!1:null}function m(n,e){switch(e.kind){case"text":return p(n,e.operator,e.value);case"select":return e.value==null||String(n)===e.value;case"multiSelect":return e.values.length===0||e.values.includes(String(n));case"boolean":return e.value==null||g(n)===e.value;case"group":return!0;case"keyedText":return e.key==null?!0:p((typeof n=="object"&&n!==null?n:{})[e.key],e.operator,e.value)}}function h(n,e,r){const l=n.selectAllClears??!0;return(n.sections??[]).every(u=>{const t=e[u.key]??[];return t.length===0||i(t,u.options.map(s=>s.value),l)?!0:t.includes(String(r(u.key)))})}function x(n,e,r,l=(u,t)=>u[t]){const u=e.filter(t=>c(t,r[t.id])?t.kind==="group"||t.columnId!==void 0:!1);return u.length===0?n:n.filter((t,s)=>u.every(a=>{const o=r[a.id];return o===void 0?!0:o.kind==="group"?h(a,o.values,f=>l(t,f,s)):m(l(t,a.columnId,s),o)}))}export{x as applyFieldFilters,k as buildInitialFilterState,y as effectiveFilterFieldCount,d as emptyFieldValue,c as isFilterFieldActive};
@@ -11,7 +11,7 @@ export type DataTableData = Record<string, unknown>;
11
11
  /** Text-match operators for a `text` filter field. */
12
12
  export type DataTableFilterOperator = 'contains' | 'doesNotContain' | 'equals' | 'doesNotEqual' | 'startsWith' | 'endsWith' | 'isEmpty' | 'isNotEmpty' | 'isAnyOf';
13
13
  /** Control kind a `DataTableFilterField` renders in the filter panel. */
14
- export type DataTableFilterFieldKind = 'text' | 'select' | 'multiSelect' | 'boolean' | 'group';
14
+ export type DataTableFilterFieldKind = 'text' | 'select' | 'multiSelect' | 'boolean' | 'group' | 'keyedText';
15
15
  /**
16
16
  * One selectable choice. `value` is the server value carried end-to-end (a
17
17
  * uuid, enum code, `'true'`/`'false'`, ...), `label` is what the user sees.
@@ -66,6 +66,10 @@ export interface DataTableFilterField {
66
66
  loadOptions?: (search: string) => Promise<DataTableFilterOption[]>;
67
67
  /** Sections for `group`. */
68
68
  sections?: DataTableFilterSection[];
69
+ /** Keys suggested for a `keyedText` field's match; any key can still be typed. `options` then suggests values. */
70
+ keys?: DataTableFilterOption[];
71
+ /** Label of a `keyedText` field's key picker. Defaults to "Key"; `label` names the value input. */
72
+ keyLabel?: string;
69
73
  /**
70
74
  * Text operators offered (and their order) for a `text` field. Defaults to
71
75
  * `['contains']`. The first entry is the default operator.
@@ -79,6 +83,17 @@ export interface DataTableFilterField {
79
83
  selectAllClears?: boolean;
80
84
  /** Placeholder for the input (text / select / multiSelect). */
81
85
  placeholder?: string;
86
+ /**
87
+ * For `multiSelect`: typed entries are accepted alongside the listed options and kept as their
88
+ * own value, for a set the list only suggests — the keys a record may carry, say.
89
+ */
90
+ freeSolo?: boolean;
91
+ /**
92
+ * Groups the field under a labelled separator in the panel: consecutive fields sharing a
93
+ * heading sit together beneath it. Fields without one are listed plainly, so the rule's own
94
+ * columns can lead and the related controls follow in named sections.
95
+ */
96
+ heading?: string;
82
97
  }
83
98
  /**
84
99
  * The value of a single field, discriminated by `kind`. Stored under the
@@ -100,6 +115,11 @@ export type DataTableFilterFieldValue = {
100
115
  } | {
101
116
  kind: 'group';
102
117
  values: Record<string, string[]>;
118
+ } | {
119
+ kind: 'keyedText';
120
+ key: string | null;
121
+ operator: DataTableFilterOperator;
122
+ value: string;
103
123
  };
104
124
  /** Full filter state: each field's value keyed by its `id`. */
105
125
  export type DataTableFilterState = Record<string, DataTableFilterFieldValue>;
@@ -1 +1 @@
1
- "use strict";import{useState as O,useRef as G,useEffect as J,createElement as B}from"react";import{Popover as K,Box as M,Typography as W,Stack as I,Divider as Q,Button as X,Autocomplete as q,TextField as F,CircularProgress as Z,Checkbox as ee,Chip as le,createFilterOptions as ne}from"@mui/material";import{DeleteOutline as oe}from"@mui/icons-material";import{useDebounceValue as ae}from"../../hooks/useDebounceValue.mjs";import{LogoAvatar as te}from"../UI/LogoAvatar.mjs";import{LogoChip as ie}from"../UI/LogoChip.mjs";import{buildInitialFilterState as re,emptyFieldValue as se}from"./DataTable.filterState.mjs";import{jsxs as f,jsx as o,Fragment as L}from"react/jsx-runtime";const D="__select_all__",_=2,H=[{label:"Yes",value:"true"},{label:"No",value:"false"}],ue={contains:"contains",doesNotContain:"does not contain",equals:"equals",doesNotEqual:"does not equal",startsWith:"starts with",endsWith:"ends with",isEmpty:"is empty",isNotEmpty:"is not empty",isAnyOf:"is any of"},R=ne({stringify:n=>`${n.label} ${n.value}`});function ce(n,u){return(n??[]).filter(c=>u.includes(c.value))}function pe({operators:n,value:u,onChange:c}){return o(q,{size:"small",disableClearable:!0,options:n,getOptionLabel:p=>ue[p],value:u,onChange:(p,b)=>c(b),renderInput:p=>o(F,{...p,size:"small",label:"Operator"}),sx:{minWidth:150}})}function Y({option:n}){return f(L,{children:[n.logoUrl!==void 0&&o(te,{name:n.label,logoUrl:n.logoUrl,size:24,sx:{mr:1}}),f(W,{variant:"body2",children:[n.label,n.caption&&o(W,{component:"span",variant:"caption",color:"text.secondary",sx:{ml:1},children:n.caption})]})]})}function de({field:n,value:u,onChange:c}){const p=(n.options??[]).map(h=>h.value),b=n.placeholder??"Filter value";return p.length===0?o(F,{size:"small",label:n.label,placeholder:b,value:u,onChange:h=>c(h.target.value),sx:{flex:1,minWidth:200}}):o(q,{freeSolo:!0,autoHighlight:!0,size:"small",options:p,value:u,inputValue:u,onInputChange:(h,v)=>c(v),renderInput:h=>o(F,{...h,size:"small",label:n.label,placeholder:b}),sx:{flex:1,minWidth:200}})}function he({field:n,options:u,values:c,onChange:p,label:b,pickedOptions:h}){const v=n.loadOptions!==void 0,[C,S]=O(!1),[y,g]=O(""),[N,P]=O([]),[z,E]=O(!1),[T,A]=O(!1),w=ae(y,300),U=G(n.loadOptions);U.current=n.loadOptions;const e=l=>`${n.id}\0${l}`,t=l=>{l.forEach(a=>{h.set(e(a.value),a)})};J(()=>{const l=U.current;if(!C||l===void 0)return;let a=!0;return E(!0),l(w).then(d=>{a&&(P(d),A(!1))}).catch(()=>{a&&(P([]),A(!0))}).finally(()=>{a&&E(!1)}),()=>{a=!1}},[C,w]);const i=v?N:u,r=u.map(l=>l.value),s=!v&&r.length>0&&r.every(l=>c.includes(l)),k=!v&&u.length>1?[{label:"Select all",value:D},...i]:i,m=v?c.map(l=>h.get(e(l))??i.find(a=>a.value===l)??{label:l,value:l}):ce(u,c);return o(q,{multiple:!0,size:"small",disableCloseOnSelect:!0,open:C,onOpen:()=>S(!0),onClose:()=>{S(!1),g("")},options:k,loading:z,noOptionsText:T?"The options could not be loaded":"No options",getOptionLabel:l=>l.label,filterOptions:v?l=>l:R,isOptionEqualToValue:(l,a)=>l.value===a.value,onInputChange:(l,a,d)=>{v&&d==="input"&&g(a)},value:m,onChange:(l,a)=>{if(a.some(d=>d.value===D)){p(s?[]:r);return}t(a),p(a.map(d=>d.value))},renderTags:(l,a)=>{const d=l.slice(0,_);return f(L,{children:[d.map((x,V)=>{const{key:$,...j}=a({index:V});return x.logoUrl===void 0?B(le,{...j,key:x.value,size:"small",label:x.label}):B(ie,{...j,key:x.value,size:"small",name:x.label,logoUrl:x.logoUrl,label:x.label})}),l.length>_&&f(W,{variant:"body2",color:"text.secondary",sx:{ml:.5},children:["+",l.length-_," more"]})]})},renderOption:(l,a,{selected:d})=>{const{key:x,...V}=l,$=a.value===D?s:d;return f("li",{...V,children:[o(ee,{size:"small",checked:$,sx:{mr:1}}),o(Y,{option:a})]},a.value)},renderInput:l=>o(F,{...l,size:"small",label:b,placeholder:c.length===0?n.placeholder:void 0,InputProps:{...l.InputProps,endAdornment:f(L,{children:[z&&o(Z,{size:16}),l.InputProps.endAdornment]})}}),sx:{flex:1,minWidth:240}})}function ve({fields:n,pickedOptions:u,filterState:c,onFilterStateChange:p,anchorPosition:b,transformHorizontal:h="left",icons:v={},onClose:C}){const{removeAllFilters:S=oe}=v,y=e=>c[e.id]??se(e),g=(e,t)=>{p({...c,[e.id]:t})},N=()=>{p(re(n)),C()},P=e=>{var t;const i=y(e),r=i.kind==="text"?i:{operator:((t=e.operators)==null?void 0:t[0])??"contains",value:""},s=e.operators??["contains"];return f(I,{direction:"row",spacing:1,sx:{flex:1},children:[s.length>1&&o(pe,{operators:s,value:r.operator,onChange:k=>g(e,{kind:"text",operator:k,value:r.value})}),o(de,{field:e,value:r.value,onChange:k=>g(e,{kind:"text",operator:r.operator,value:k})})]})},z=(e,t,i,r,s,k)=>o(q,{size:"small",options:t,getOptionLabel:m=>m.label,filterOptions:R,isOptionEqualToValue:(m,l)=>m.value===l.value,value:i,onChange:(m,l)=>r(l),renderOption:(m,l)=>{const{key:a,...d}=m;return o("li",{...d,children:o(Y,{option:l})},l.value)},renderInput:m=>o(F,{...m,size:"small",label:e.label,placeholder:s}),sx:{flex:1,minWidth:k}}),E=e=>{var t;const i=y(e),r=i.kind==="select"&&i.value!=null?((t=e.options)==null?void 0:t.find(s=>s.value===i.value))??null:null;return z(e,e.options??[],r,s=>g(e,{kind:"select",value:s?.value??null}),e.placeholder,220)},T=(e,t,i,r,s)=>o(he,{field:e,options:t,values:i,onChange:r,label:s,pickedOptions:u}),A=e=>{const t=y(e),i=t.kind==="boolean"?t.value:null,r=i===null?null:H.find(s=>s.value===String(i))??null;return z(e,H,r,s=>g(e,{kind:"boolean",value:s?s.value==="true":null}),e.placeholder??"Any",200)},w=e=>{const t=y(e),i=t.kind==="group"?t.values:{};return o(I,{spacing:1,sx:{flex:1},children:(e.sections??[]).map(r=>T(e,r.options,i[r.key]??[],s=>g(e,{kind:"group",values:{...i,[r.key]:s}}),r.label))})},U=e=>{switch(e.kind){case"text":return P(e);case"select":return E(e);case"multiSelect":{const t=y(e);return T(e,e.options??[],t.kind==="multiSelect"?t.values:[],i=>g(e,{kind:"multiSelect",values:i}),e.label)}case"boolean":return A(e);case"group":return w(e)}};return f(K,{open:!0,anchorReference:"anchorPosition",anchorPosition:b,transformOrigin:{vertical:"top",horizontal:h},onClose:C,children:[o(M,{sx:{p:1.5,width:420},children:n.length===0?o(W,{variant:"body2",color:"text.secondary",sx:{pl:.5},children:"No filters available."}):o(I,{spacing:1.5,children:n.map(e=>o(I,{direction:"row",alignItems:"flex-start",children:U(e)},e.id))})}),n.length>0&&f(L,{children:[o(Q,{}),o(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",sx:{px:1.5,py:.75},children:o(X,{size:"small",color:"primary",startIcon:o(S,{}),onClick:N,children:"Clear all"})})]})]})}export{ve as DataTableFieldFilterPanel};
1
+ "use strict";import{useState as S,useRef as M,useEffect as Q,createElement as j}from"react";import{Popover as X,Box as Z,Typography as B,Stack as C,Divider as R,Button as ee,TextField as I,Autocomplete as N,CircularProgress as le,Checkbox as ne,Chip as ae,createFilterOptions as oe}from"@mui/material";import{DeleteOutline as te}from"@mui/icons-material";import{useDebounceValue as ie}from"../../hooks/useDebounceValue.mjs";import{LogoAvatar as re}from"../UI/LogoAvatar.mjs";import{LogoChip as se}from"../UI/LogoChip.mjs";import{SectionLabel as ue}from"../UI/SectionLabel.mjs";import{buildInitialFilterState as ce,emptyFieldValue as pe}from"./DataTable.filterState.mjs";import{jsxs as f,jsx as t,Fragment as U}from"react/jsx-runtime";const D="__select_all__",H=2,Y=[{label:"Yes",value:"true"},{label:"No",value:"false"}],de={contains:"contains",doesNotContain:"does not contain",equals:"equals",doesNotEqual:"does not equal",startsWith:"starts with",endsWith:"ends with",isEmpty:"is empty",isNotEmpty:"is not empty",isAnyOf:"is any of"},G=oe({stringify:n=>`${n.label} ${n.value}`}),P=n=>typeof n=="string"?{label:n,value:n}:n;function he({operators:n,value:h,onChange:p}){return t(N,{size:"small",disableClearable:!0,options:n,getOptionLabel:d=>de[d],value:h,onChange:(d,b)=>p(b),renderInput:d=>t(I,{...d,size:"small",label:"Operator"}),sx:{minWidth:150}})}function K({option:n}){return f(U,{children:[n.logoUrl!==void 0&&t(re,{name:n.label,logoUrl:n.logoUrl,size:24,sx:{mr:1}}),f(B,{variant:"body2",children:[n.label,n.caption&&t(B,{component:"span",variant:"caption",color:"text.secondary",sx:{ml:1},children:n.caption})]})]})}function J({field:n,value:h,onChange:p}){const d=(n.options??[]).map(m=>m.value),b=n.placeholder??"Filter value";return d.length===0?t(I,{size:"small",label:n.label,placeholder:b,value:h,onChange:m=>p(m.target.value),sx:{flex:1,minWidth:200}}):t(N,{freeSolo:!0,autoHighlight:!0,size:"small",options:d,value:h,inputValue:h,onInputChange:(m,g)=>p(g),renderInput:m=>t(I,{...m,size:"small",label:n.label,placeholder:b}),sx:{flex:1,minWidth:200}})}function ve({field:n,options:h,values:p,onChange:d,label:b,pickedOptions:m}){const g=n.loadOptions!==void 0,[k,T]=S(!1),[y,x]=S(""),[V,O]=S([]),[F,w]=S(!1),[E,A]=S(!1),z=ie(y,300),W=M(n.loadOptions);W.current=n.loadOptions;const q=l=>`${n.id}\0${l}`,L=l=>{l.forEach(o=>{m.set(q(o.value),o)})};Q(()=>{const l=W.current;if(!k||l===void 0)return;let o=!0;return w(!0),l(z).then(u=>{o&&(O(u),A(!1))}).catch(()=>{o&&(O([]),A(!0))}).finally(()=>{o&&w(!1)}),()=>{o=!1}},[k,z]);const e=g?V:h,a=h.map(l=>l.value),i=!g&&a.length>0&&a.every(l=>p.includes(l)),s=!g&&h.length>1?[{label:"Select all",value:D},...e]:e,r=p.map(l=>m.get(q(l))??e.find(o=>o.value===l)??{label:l,value:l});return t(N,{multiple:!0,freeSolo:n.freeSolo,clearOnBlur:!0,size:"small",disableCloseOnSelect:!0,open:k,onOpen:()=>T(!0),onClose:()=>{T(!1),x("")},options:s,loading:F,noOptionsText:E?"The options could not be loaded":"No options",getOptionLabel:l=>P(l).label,filterOptions:g?l=>l:G,isOptionEqualToValue:(l,o)=>P(l).value===P(o).value,onInputChange:(l,o,u)=>{g&&u==="input"&&x(o)},value:r,onChange:(l,o)=>{const u=o.map(P).filter(c=>c.value.trim()!=="");if(u.some(c=>c.value===D)){const c=p.filter(v=>!a.includes(v));d(i?c:[...c,...a]);return}L(u),d(u.map(c=>c.value))},renderTags:(l,o)=>{const u=l.slice(0,H).map(P);return f(U,{children:[u.map((c,v)=>{const{key:_,...$}=o({index:v});return c.logoUrl===void 0?j(ae,{...$,key:c.value,size:"small",label:c.label}):j(se,{...$,key:c.value,size:"small",name:c.label,logoUrl:c.logoUrl,label:c.label})}),l.length>H&&f(B,{variant:"body2",color:"text.secondary",sx:{ml:.5},children:["+",l.length-H," more"]})]})},renderOption:(l,o,{selected:u})=>{const{key:c,...v}=l,_=o.value===D?i:u;return f("li",{...v,children:[t(ne,{size:"small",checked:_,sx:{mr:1}}),t(K,{option:o})]},o.value)},renderInput:l=>t(I,{...l,size:"small",label:b,placeholder:p.length===0?n.placeholder:void 0,inputProps:{...l.inputProps,onBlur:o=>{var u,c;const v=n.freeSolo?o.target.value.trim():"";(c=(u=l.inputProps).onBlur)==null||c.call(u,o),v!==""&&!p.includes(v)&&(L([{label:v,value:v}]),d([...p,v]))}},InputProps:{...l.InputProps,endAdornment:f(U,{children:[F&&t(le,{size:16}),l.InputProps.endAdornment]})}}),sx:{flex:1,minWidth:240}})}function me(n){const h=[];return n.forEach(p=>{const d=h.at(-1);d&&d.heading===p.heading?d.fields.push(p):h.push({heading:p.heading,fields:[p]})}),h}function fe({fields:n,pickedOptions:h,filterState:p,onFilterStateChange:d,anchorPosition:b,transformHorizontal:m="left",icons:g={},onClose:k}){const{removeAllFilters:T=te}=g,y=e=>p[e.id]??pe(e),x=(e,a)=>{d({...p,[e.id]:a})},V=()=>{d(ce(n)),k()},O=(e,a,i,s)=>{const r=e.operators??["contains"];return f(C,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",sx:{flex:1},children:[s,r.length>1&&t(he,{operators:r,value:a.operator,onChange:l=>i({operator:l})}),t(J,{field:e,value:a.value,onChange:l=>i({value:l})})]})},F=e=>{var a;const i=y(e),s=i.kind==="text"?i:{operator:((a=e.operators)==null?void 0:a[0])??"contains",value:""};return O(e,s,r=>x(e,{kind:"text",...s,...r}))},w=e=>{var a;const i=y(e),s=i.kind==="keyedText"?i:{key:null,operator:((a=e.operators)==null?void 0:a[0])??"contains",value:""},r=l=>{x(e,{kind:"keyedText",...s,...l})};return O(e,s,r,t(J,{field:{...e,label:e.keyLabel??"Key",options:e.keys,placeholder:"Type or pick a key"},value:s.key??"",onChange:l=>r({key:l.trim()===""?null:l})}))},E=(e,a,i,s,r,l)=>t(N,{size:"small",options:a,getOptionLabel:o=>o.label,filterOptions:G,isOptionEqualToValue:(o,u)=>o.value===u.value,value:i,onChange:(o,u)=>s(u),renderOption:(o,u)=>{const{key:c,...v}=o;return t("li",{...v,children:t(K,{option:u})},u.value)},renderInput:o=>t(I,{...o,size:"small",label:e.label,placeholder:r}),sx:{flex:1,minWidth:l}}),A=e=>{var a;const i=y(e),s=i.kind==="select"&&i.value!=null?((a=e.options)==null?void 0:a.find(r=>r.value===i.value))??null:null;return E(e,e.options??[],s,r=>x(e,{kind:"select",value:r?.value??null}),e.placeholder,220)},z=(e,a,i,s,r)=>t(ve,{field:e,options:a,values:i,onChange:s,label:r,pickedOptions:h}),W=e=>{const a=y(e),i=a.kind==="boolean"?a.value:null,s=i===null?null:Y.find(r=>r.value===String(i))??null;return E(e,Y,s,r=>x(e,{kind:"boolean",value:r?r.value==="true":null}),e.placeholder??"Any",200)},q=e=>{const a=y(e),i=a.kind==="group"?a.values:{};return t(C,{spacing:1,sx:{flex:1},children:(e.sections??[]).map(s=>z(e,s.options,i[s.key]??[],r=>x(e,{kind:"group",values:{...i,[s.key]:r}}),s.label))})},L=e=>{switch(e.kind){case"text":return F(e);case"select":return A(e);case"multiSelect":{const a=y(e);return z(e,e.options??[],a.kind==="multiSelect"?a.values:[],i=>x(e,{kind:"multiSelect",values:i}),e.label)}case"boolean":return W(e);case"group":return q(e);case"keyedText":return w(e)}};return f(X,{open:!0,anchorReference:"anchorPosition",anchorPosition:b,transformOrigin:{vertical:"top",horizontal:m},onClose:k,slotProps:{paper:{sx:{display:"flex",flexDirection:"column",maxHeight:"calc(100vh - 32px)"}}},children:[t(Z,{sx:{p:1.5,width:"min(420px, calc(100vw - 32px))",overflowY:"auto",minHeight:0},children:n.length===0?t(B,{variant:"body2",color:"text.secondary",sx:{pl:.5},children:"No filters available."}):t(C,{spacing:2,children:me(n).map(e=>f(C,{spacing:1.5,children:[e.heading!==void 0&&t(R,{textAlign:"left",children:t(ue,{color:"text.secondary",children:e.heading})}),e.fields.map(a=>t(C,{direction:"row",alignItems:"flex-start",children:L(a)},a.id))]},e.fields[0].id))})}),n.length>0&&f(U,{children:[t(R,{}),t(C,{direction:"row",alignItems:"center",justifyContent:"flex-end",sx:{px:1.5,py:.75},children:t(ee,{size:"small",color:"primary",startIcon:t(T,{}),onClick:V,children:"Clear all"})})]})]})}export{fe as DataTableFieldFilterPanel};
@@ -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.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
+ "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{jsxs as u,jsx as n}from"react/jsx-runtime";function W(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)} ${i.values.join(", ")}`:`Condition ${t+1}`}" will be removed from "${e.name}". The rule keeps its other conditions.`}function y({open:o,rule:e,conditionIndex:t,onConfirm:i,onClose:l,isDeleting:a=!1,title:m,description:h,confirmLabel:v="Delete",cancelLabel:g="Cancel"}){const{data:p}=T(),r=c(o,e??void 0),s=c(o,t??void 0),C=m??(s!==void 0?"Delete condition?":"Delete rule?"),f=h??(r===void 0?void 0:W(p,r,s));return u(D,{open:o,onClose:a?void 0:l,maxWidth:"xs",fullWidth:!0,children:[n(b,{children:C}),n($,{children:n(x,{children:f})}),u(k,{children:[n(d,{color:"neutral",onClick:l,disabled:a,children:g}),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:v})]})]})}export{y as NetworkRuleDeleteDialog};
@@ -1 +1 @@
1
- "use strict";import{useState as V,useEffect as w,useRef as Y,useMemo as Z}from"react";import{Stack as m,Alert as z,Button as E,TextField as _,FormControlLabel as ee,Switch as re,CircularProgress as oe,Skeleton as S}from"@mui/material";import{zodResolver as te}from"@hookform/resolvers/zod";import{addDays as ae}from"date-fns";import{useForm as ne,useWatch as se,FormProvider as ie,Controller as y}from"react-hook-form";import{useNetworkRuleStatuses as le}from"../NetworkRules.context.mjs";import{useNetworkRulesCatalog as de}from"../hooks/useNetworkRulesCatalog.mjs";import{getPresets as L}from"../utils/catalog.mjs";import{fromNetworkRuleFormValues as ue,toNetworkRuleFormValues as ce,emptyConditionFormValues as me}from"../utils/condition.mjs";import{ruleDateToDay as fe}from"../utils/date.mjs";import{ConditionsField as he}from"./fields/ConditionsField.mjs";import{DateField as I}from"./fields/DateField.mjs";import{NotesField as pe}from"./fields/NotesField.mjs";import{StatusField as ve}from"./fields/StatusField.mjs";import{networkRuleFormSchema as ge}from"./schema.mjs";import{jsx as e,jsxs as f,Fragment as be}from"react/jsx-runtime";function M(n,l){const s=ce(n);return!(n!=null&&n.uuid)&&!s.name&&l&&(s.name=l),s.conditions.length===0&&(s.conditions=[me()]),s}function Ce(n,l){const s=[],p=[];for(const u of l){const c=u.message??u.code;if(typeof u.index=="number"){const h=`conditions.${u.index}.values`;n.setError(h,{type:"server",message:c}),p.push(h)}else s.push(c)}return s.length>0&&n.setError("root.server",{type:"server",message:s.join(" ")}),p}function Se(){return f(m,{spacing:2,"aria-busy":!0,children:[e(S,{variant:"rounded",height:56}),e(S,{variant:"rounded",height:56}),e(S,{variant:"rounded",height:56}),e(S,{variant:"rounded",height:120})]})}function ye({rule:n,defaultName:l,canCreatePresets:s=!1,onSubmit:p,onCancel:u,isSubmitting:c=!1,serverErrors:h,focusConditionIndex:W,submitLabel:A="Save",cancelLabel:K="Cancel",disabled:O=!1,id:U,hideActions:$=!1,onDirtyChange:x}){var k,D;const v=de(),i=v.data,q=le()??i?.statuses??[],g=n?.uuid??"new",[R,G]=V(g),t=ne({defaultValues:M(n,l),resolver:te(ge),mode:"onSubmit",reValidateMode:"onChange"}),[b,N]=V({});w(()=>{g!==R&&(t.reset(M(n,l)),N({}),G(g))},[t,n,l,g,R]);const F=Y([]);w(()=>{t.clearErrors("root.server"),F.current.length>0&&t.clearErrors(F.current),F.current=Ce(t,h??[])},[t,h]);const{isDirty:P}=t.formState;w(()=>{x?.(P)},[P,x]);const d=O||c,T=(D=(k=t.formState.errors.root)==null?void 0:k.server)==null?void 0:D.message,H=se({control:t.control,name:"startDate"}),B=fe(H),J=B?ae(B,1):void 0,Q=Z(()=>[...L(i,"notes"),...b.notes??[]],[i,b.notes]),j=(r,a)=>{N(o=>{const C=o[r]??[];return C.includes(a)?o:{...o,[r]:[...C,a]}})},X=t.handleSubmit(async r=>{if(i===void 0)return;const a=Object.fromEntries(Object.entries(b).map(([o,C])=>[o,[...L(i,o),...C]]));await p(ue(r),{presets:a})});return e(ie,{...t,children:e("form",{id:U,noValidate:!0,onSubmit:r=>{r.preventDefault(),r.stopPropagation(),X(r)},children:f(m,{spacing:3,children:[v.isError&&e(z,{severity:"error",action:e(E,{color:"inherit",size:"small",onClick:()=>{v.refetch()},children:"Retry"}),children:"The rule catalog could not be loaded."}),T&&e(z,{severity:"error",children:T}),i===void 0?!v.isError&&e(Se,{}):f(be,{children:[f(m,{direction:{xs:"column",md:"row"},spacing:2,children:[e(y,{control:t.control,name:"name",render:({field:r,fieldState:a})=>{var o;return e(_,{...r,label:"Rule Name",required:!0,fullWidth:!0,disabled:d,error:a.error!==void 0,helperText:(o=a.error)==null?void 0:o.message,sx:{flex:2}})}}),e(m,{flex:1,minWidth:{md:220},children:e(ve,{statuses:q,disabled:d})})]}),f(m,{direction:{xs:"column",md:"row"},spacing:2,children:[e(y,{control:t.control,name:"startDate",render:({field:r,fieldState:a})=>{var o;return e(I,{label:"Starts",value:r.value,onChange:r.onChange,onBlur:r.onBlur,disabled:d,error:a.error!==void 0,helperText:((o=a.error)==null?void 0:o.message)??"Starts applying at the start of this day (UTC)"})}}),e(y,{control:t.control,name:"endDate",render:({field:r,fieldState:a})=>{var o;return e(I,{label:"Ends",value:r.value,onChange:r.onChange,onBlur:r.onBlur,disabled:d,minDate:J,error:a.error!==void 0,helperText:((o=a.error)==null?void 0:o.message)??"Stops applying at the start of this day (UTC)"})}})]}),e(pe,{presets:Q,onCreatePreset:s?r=>{j("notes",r)}:void 0,disabled:d}),e(y,{control:t.control,name:"enabled",render:({field:r})=>e(ee,{label:"Enabled",control:e(re,{checked:r.value,onChange:(a,o)=>{r.onChange(o)},onBlur:r.onBlur,inputRef:r.ref,disabled:d})})}),e(he,{catalog:i,addedPresets:b,onCreatePreset:s?j:void 0,disabled:d,focusIndex:W})]}),!$&&f(m,{direction:"row",spacing:1,justifyContent:"flex-end",children:[u&&e(E,{onClick:u,disabled:c,children:K}),e(E,{type:"submit",variant:"contained",disabled:d||i===void 0,startIcon:c?e(oe,{size:16,color:"inherit"}):void 0,children:A})]})]})})})}export{ye as NetworkRuleEditorForm};
1
+ "use strict";import{useState as V,useMemo as z,useEffect as k,useRef as Q}from"react";import{Stack as f,Alert as L,Button as w,TextField as ee,FormControlLabel as re,Switch as oe,CircularProgress as te,Skeleton as C}from"@mui/material";import{zodResolver as ae}from"@hookform/resolvers/zod";import{addDays as ne}from"date-fns";import{useForm as se,useWatch as ie,FormProvider as le,Controller as y}from"react-hook-form";import{useNetworkRuleStatuses as de}from"../NetworkRules.context.mjs";import{useNetworkRulesCatalog as ue}from"../hooks/useNetworkRulesCatalog.mjs";import{getPresets as M}from"../utils/catalog.mjs";import{fromNetworkRuleFormValues as ce,toNetworkRuleFormValues as me,emptyConditionFormValues as fe}from"../utils/condition.mjs";import{ruleDateToDay as he}from"../utils/date.mjs";import{ConditionsField as ve}from"./fields/ConditionsField.mjs";import{DateField as W}from"./fields/DateField.mjs";import{MetadataField as pe}from"./fields/MetadataField.mjs";import{NotesField as ge}from"./fields/NotesField.mjs";import{StatusField as be}from"./fields/StatusField.mjs";import{createNetworkRuleFormSchema as Ce}from"./schema.mjs";import{jsx as e,jsxs as h,Fragment as ye}from"react/jsx-runtime";function A(i,d){const n=me(i);return!(i!=null&&i.uuid)&&!n.name&&d&&(n.name=d),n.conditions.length===0&&(n.conditions=[fe()]),n}function Se(i,d){const n=[],p=[];for(const u of d){const c=u.message??u.code;if(typeof u.index=="number"){const v=`conditions.${u.index}.values`;i.setError(v,{type:"server",message:c}),p.push(v)}else n.push(c)}return n.length>0&&i.setError("root.server",{type:"server",message:n.join(" ")}),p}function xe(){return h(f,{spacing:2,"aria-busy":!0,children:[e(C,{variant:"rounded",height:56}),e(C,{variant:"rounded",height:56}),e(C,{variant:"rounded",height:56}),e(C,{variant:"rounded",height:120})]})}function Fe({rule:i,defaultName:d,canCreatePresets:n=!1,onSubmit:p,onCancel:u,isSubmitting:c=!1,serverErrors:v,focusConditionIndex:I,submitLabel:O="Save",cancelLabel:U="Cancel",disabled:$=!1,id:q,hideActions:G=!1,onDirtyChange:S}){var E,D;const g=ue(),s=g.data,H=de()??s?.statuses??[],b=i?.uuid??"new",[R,J]=V(b),K=z(()=>ae(Ce(s?.metadata)),[s]),t=se({defaultValues:A(i,d),resolver:K,mode:"onSubmit",reValidateMode:"onChange"}),[m,P]=V({});k(()=>{b!==R&&(t.reset(A(i,d)),P({}),J(b))},[t,i,d,b,R]);const x=Q([]);k(()=>{t.clearErrors("root.server"),x.current.length>0&&t.clearErrors(x.current),x.current=Se(t,v??[])},[t,v]);const{isDirty:N}=t.formState;k(()=>{S?.(N)},[N,S]);const l=$||c,T=(D=(E=t.formState.errors.root)==null?void 0:E.server)==null?void 0:D.message,X=ie({control:t.control,name:"startDate"}),B=he(X),Y=B?ne(B,1):void 0,Z=z(()=>M(s,"notes",m),[s,m]),F=(r,a)=>{P(o=>{const j=o[r]??[];return j.includes(a)?o:{...o,[r]:[...j,a]}})},_=t.handleSubmit(async r=>{if(s===void 0)return;const a=Object.fromEntries(Object.keys(m).map(o=>[o,M(s,o,m)]));await p(ce(r),{presets:a})});return e(le,{...t,children:e("form",{id:q,noValidate:!0,onSubmit:r=>{r.preventDefault(),r.stopPropagation(),_(r)},children:h(f,{spacing:3,children:[g.isError&&e(L,{severity:"error",action:e(w,{color:"inherit",size:"small",onClick:()=>{g.refetch()},children:"Retry"}),children:"The rule catalog could not be loaded."}),T&&e(L,{severity:"error",children:T}),s===void 0?!g.isError&&e(xe,{}):h(ye,{children:[h(f,{direction:{xs:"column",md:"row"},spacing:2,children:[e(y,{control:t.control,name:"name",render:({field:r,fieldState:a})=>{var o;return e(ee,{...r,label:"Rule Name",required:!0,fullWidth:!0,disabled:l,error:a.error!==void 0,helperText:(o=a.error)==null?void 0:o.message,sx:{flex:2}})}}),e(f,{flex:1,minWidth:{md:220},children:e(be,{statuses:H,disabled:l})})]}),h(f,{direction:{xs:"column",md:"row"},spacing:2,children:[e(y,{control:t.control,name:"startDate",render:({field:r,fieldState:a})=>{var o;return e(W,{label:"Starts",value:r.value,onChange:r.onChange,onBlur:r.onBlur,disabled:l,error:a.error!==void 0,helperText:((o=a.error)==null?void 0:o.message)??"Starts applying at the start of this day (UTC)"})}}),e(y,{control:t.control,name:"endDate",render:({field:r,fieldState:a})=>{var o;return e(W,{label:"Ends",value:r.value,onChange:r.onChange,onBlur:r.onBlur,disabled:l,minDate:Y,error:a.error!==void 0,helperText:((o=a.error)==null?void 0:o.message)??"Stops applying at the start of this day (UTC)"})}})]}),e(ge,{presets:Z,onCreatePreset:n?r=>{F("notes",r)}:void 0,disabled:l}),e(y,{control:t.control,name:"enabled",render:({field:r})=>e(re,{label:"Enabled",control:e(oe,{checked:r.value,onChange:(a,o)=>{r.onChange(o)},onBlur:r.onBlur,inputRef:r.ref,disabled:l})})}),e(ve,{catalog:s,addedPresets:m,onCreatePreset:n?F:void 0,disabled:l,focusIndex:I}),e(pe,{catalog:s,addedPresets:m,onCreatePreset:n?F:void 0,disabled:l})]}),!G&&h(f,{direction:"row",spacing:1,justifyContent:"flex-end",children:[u&&e(w,{onClick:u,disabled:c,children:U}),e(w,{type:"submit",variant:"contained",disabled:l||s===void 0,startIcon:c?e(te,{size:16,color:"inherit"}):void 0,children:O})]})]})})})}export{Fe as NetworkRuleEditorForm};
@@ -1 +1 @@
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
+ "use strict";import{Stack as C,Typography as j,TextField as S,MenuItem as b,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 k,isOperatorMulti as $,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:a,onRemove:D,addedPresets:R,onCreatePreset:v,canRemove:w=!0,disabled:s=!1,autoFocus:B}){var p,g,x;const{control:d,setValue:u,formState:I}=q(),i=h({control:d,name:`conditions.${o}.key`}),r=h({control:d,name:`conditions.${o}.operator`}),m=h({control:d,name:`conditions.${o}.values`}),c=K({control:d,name:`conditions.${o}.values`})??[],t=k(a,i.field.value),T=t?.operators??[],V=$(a,r.field.value),f=I.isSubmitted,W=t?M(a,t.key,R):[],F=e=>{var n;i.field.onChange(e);const y=((n=k(a,e))==null?void 0:n.operators)??[];u(`conditions.${o}.operator`,y.length===1?y[0]:"",{shouldDirty:!0,shouldValidate:f}),u(`conditions.${o}.values`,[],{shouldDirty:!0,shouldValidate:f})};return H(C,{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(S,{select:!0,required:!0,label:"Key",value:i.field.value,onChange:e=>{F(e.target.value)},onBlur:i.field.onBlur,inputRef:i.field.ref,disabled:s,autoFocus:B,error:i.fieldState.error!==void 0,helperText:(p=i.fieldState.error)==null?void 0:p.message,sx:{minWidth:{md:200},width:{xs:"100%",md:"auto"}},children:a.keys.map(e=>l(b,{value:e.key,children:e.label},e.key))}),l(S,{select:!0,required:!0,label:"Operator",value:r.field.value,onChange:e=>{const n=e.target.value;r.field.onChange(n),!$(a,n)&&c.length>1&&u(`conditions.${o}.values`,c.slice(0,1),{shouldDirty:!0,shouldValidate:f})},onBlur:r.field.onBlur,inputRef:r.field.ref,disabled:s||t===void 0,error:r.fieldState.error!==void 0,helperText:(g=r.fieldState.error)==null?void 0:g.message,sx:{minWidth:{md:180},width:{xs:"100%",md:"auto"}},children:T.map(e=>l(b,{value:e,children:z(a,e)},e))}),l(C,{flex:1,width:"100%",minWidth:0,children:l(A,{keyDef:t,multi:V,values:c,onChange:e=>{m.field.onChange(e)},presets:W,onCreatePreset:v&&t?e=>{v(t.key,e)}:void 0,disabled:s||r.field.value==="",error:m.fieldState.error!==void 0,helperText:(x=m.fieldState.error)==null?void 0:x.message})}),l(O,{"aria-label":`Remove condition ${o+1}`,color:"error",onClick:D,disabled:s||!w,sx:{mt:{md:1}},children:l(P,{})})]})}export{L as ConditionRow};
@@ -0,0 +1,12 @@
1
+ import { NetworkRuleCatalog } from '../../types';
2
+ export interface MetadataFieldProps {
3
+ catalog: NetworkRuleCatalog;
4
+ addedPresets?: Readonly<Record<string, readonly string[]>>;
5
+ onCreatePreset?: (field: string, value: string) => void;
6
+ disabled?: boolean;
7
+ }
8
+ /**
9
+ * Typed key/value pairs returned with the decision. Optional: a rule may have none, and a catalog
10
+ * without `metadata` offers no section at all, as the filter panel offers no controls.
11
+ */
12
+ export declare function MetadataField({ catalog, addedPresets, onCreatePreset, disabled, }: Readonly<MetadataFieldProps>): import("react").JSX.Element | null;
@@ -0,0 +1 @@
1
+ "use strict";import{Stack as c,Typography as u,Button as k,FormHelperText as w}from"@mui/material";import{Add as R}from"@mui/icons-material";import{useFormContext as T,useFieldArray as b}from"react-hook-form";import{getPresets as h}from"../../utils/catalog.mjs";import{NETWORK_RULE_METADATA_PRESET_FIELDS as y,emptyMetadataFormValues as C}from"../../utils/metadata.mjs";import{MetadataRow as S}from"./MetadataRow.mjs";import{jsxs as f,jsx as e}from"react/jsx-runtime";function _({catalog:a,addedPresets:o,onCreatePreset:g,disabled:s=!1}){var d,n,i;const{control:v,formState:m}=T(),{fields:r,append:x,remove:P}=b({control:v,name:"metadata"}),{metadata:t}=a;if(t===void 0)return null;const l=((n=(d=m.errors.metadata)==null?void 0:d.root)==null?void 0:n.message)??((i=m.errors.metadata)==null?void 0:i.message),A=h(a,y.key,o),E=h(a,y.value,o),F=r.length>=t.limits.maxEntries;return f(c,{spacing:2,children:[f(c,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e(u,{fontWeight:700,children:"Metadata"}),e(k,{startIcon:e(R,{}),disabled:s||F,onClick:()=>{x(C(t.types[0]))},children:"Add Metadata"})]}),r.length===0&&e(u,{variant:"body2",color:"text.secondary",children:"No metadata yet. Pairs added here are returned with the network status so your app can act on them."}),r.map((M,p)=>e(S,{index:p,types:t.types,limits:t.limits,keyPresets:A,valuePresets:E,onCreatePreset:g,disabled:s,onRemove:()=>{P(p)}},M.id)),l&&e(w,{error:!0,children:l})]})}export{_ as MetadataField};
@@ -0,0 +1,14 @@
1
+ import { NetworkRuleMetadataLimits, NetworkRuleMetadataType } from '../../types';
2
+ export interface MetadataRowProps {
3
+ index: number;
4
+ onRemove: () => void;
5
+ types: readonly NetworkRuleMetadataType[];
6
+ limits: NetworkRuleMetadataLimits;
7
+ keyPresets?: readonly string[];
8
+ valuePresets?: readonly string[];
9
+ /** Called with the preset field the value belongs to, as `ConditionRow` does with its key. */
10
+ onCreatePreset?: (field: string, value: string) => void;
11
+ disabled?: boolean;
12
+ }
13
+ /** One `key: value` pair. No IF/AND: metadata is carried along, not matched on. */
14
+ export declare function MetadataRow({ index, onRemove, types, limits, keyPresets, valuePresets, onCreatePreset, disabled, }: Readonly<MetadataRowProps>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";import{Stack as f,TextField as h,MenuItem as y,IconButton as w}from"@mui/material";import{Delete as D}from"@mui/icons-material";import{useFormContext as M,useController as p}from"react-hook-form";import{NETWORK_RULE_METADATA_PRESET_FIELDS as P,metadataTypeLabel as N,NETWORK_RULE_METADATA_BOOLEAN_OPTIONS as V,isPartialNumberInput as S}from"../../utils/metadata.mjs";import{PresetTextInput as E}from"./PresetTextInput.mjs";import{jsxs as R,jsx as a}from"react/jsx-runtime";function $({index:i,onRemove:k,types:L,limits:c,keyPresets:_=[],valuePresets:A=[],onCreatePreset:v,disabled:d=!1}){var g,x,b;const{control:u,setValue:B,formState:W}=M(),r=p({control:u,name:`metadata.${i}.key`}),o=p({control:u,name:`metadata.${i}.type`}),t=p({control:u,name:`metadata.${i}.value`}),n=o.field.value,l=t.field.value,I=W.isSubmitted,C=(g=t.fieldState.error)==null?void 0:g.message,m={required:!0,label:"Value",onBlur:t.field.onBlur,inputRef:t.field.ref,disabled:d,error:C!==void 0,helperText:C},T=e=>v?s=>{v(e,s)}:void 0,O=e=>{o.field.onChange(e),e==="string"||e==="number"&&S(l)||e==="boolean"&&(l==="true"||l==="false")||B(`metadata.${i}.value`,"",{shouldDirty:!0,shouldValidate:I})};return R(f,{direction:{xs:"column",md:"row"},spacing:1.5,alignItems:"flex-start",children:[a(f,{sx:{minWidth:{md:200},width:{xs:"100%",md:"auto"}},children:a(E,{label:"Key",required:!0,value:r.field.value,onChange:r.field.onChange,onBlur:r.field.onBlur,inputRef:r.field.ref,presets:_,onCreatePreset:T(P.key),maxLength:c.maxKeyLength,placeholder:"Pick a preset or type a key",disabled:d,error:r.fieldState.error!==void 0,helperText:(x=r.fieldState.error)==null?void 0:x.message})}),a(h,{select:!0,required:!0,label:"Type",value:n,onChange:e=>{O(e.target.value)},onBlur:o.field.onBlur,inputRef:o.field.ref,disabled:d,error:o.fieldState.error!==void 0,helperText:(b=o.fieldState.error)==null?void 0:b.message,sx:{minWidth:{md:140},width:{xs:"100%",md:"auto"}},children:L.map(e=>a(y,{value:e,children:N(e)},e))}),R(f,{flex:1,width:"100%",minWidth:0,children:[n==="boolean"&&a(h,{...m,select:!0,fullWidth:!0,value:l==="true"||l==="false"?l:"",onChange:e=>{t.field.onChange(e.target.value)},children:V.map(e=>a(y,{value:e.value,children:e.label},e.value))}),n==="number"&&a(h,{...m,fullWidth:!0,value:l,onChange:e=>{const s=e.target.value;S(s)&&t.field.onChange(s)},placeholder:"Type a number",inputProps:{inputMode:"decimal"}}),n==="string"&&a(E,{...m,value:l,onChange:t.field.onChange,presets:A,onCreatePreset:T(P.value),maxLength:c.maxValueLength,placeholder:"Pick a preset or type a value"})]}),a(w,{"aria-label":`Remove metadata ${i+1}`,color:"error",onClick:k,disabled:d,sx:{mt:{md:1}},children:a(D,{})})]})}export{$ as MetadataRow};
@@ -0,0 +1,22 @@
1
+ import { Ref } from 'react';
2
+ export interface PresetTextInputProps {
3
+ label: string;
4
+ value: string;
5
+ onChange: (value: string) => void;
6
+ onBlur?: () => void;
7
+ presets?: readonly string[];
8
+ onCreatePreset?: (value: string) => void;
9
+ maxLength?: number;
10
+ placeholder?: string;
11
+ required?: boolean;
12
+ disabled?: boolean;
13
+ error?: boolean;
14
+ helperText?: string;
15
+ inputRef?: Ref<HTMLInputElement>;
16
+ }
17
+ /**
18
+ * A single free-text value with the brand's presets as suggestions; the chip-based
19
+ * `TextValuesInput` is for a condition's several values. Leaving the field keeps the text but
20
+ * creates no preset — see the note in `presetOptions.ts` before changing that.
21
+ */
22
+ export declare function PresetTextInput({ label, value, onChange, onBlur, presets, onCreatePreset, maxLength, placeholder, required, disabled, error, helperText, inputRef, }: Readonly<PresetTextInputProps>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";import{Autocomplete as c,TextField as O}from"@mui/material";import{presetOptionLabel as n,filterPresetOptions as T}from"./presetOptions.mjs";import{jsx as i}from"react/jsx-runtime";function P({label:a,value:l,onChange:r,onBlur:p,presets:s=[],onCreatePreset:o,maxLength:u,placeholder:d,required:h,disabled:f,error:m,helperText:g,inputRef:x}){return i(c,{freeSolo:!0,autoHighlight:!0,selectOnFocus:!0,handleHomeEndKeys:!0,options:s,value:l,inputValue:l,disabled:f,getOptionLabel:n,isOptionEqualToValue:(t,e)=>n(t)===n(e),filterOptions:(t,e)=>T(t,e,o!==void 0),onInputChange:(t,e,b)=>{b!=="reset"&&r(e)},onChange:(t,e)=>{e===null?r(""):typeof e=="string"?r(e):(r(e.inputValue),o?.(e.inputValue))},onBlur:p,renderInput:t=>i(O,{...t,label:a,required:h,placeholder:d,error:m,helperText:g,inputRef:x,inputProps:{...t.inputProps,maxLength:u}})})}export{P as PresetTextInput};
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { NetworkRuleCatalogMetadata, NetworkRuleMetadataType } from '../types';
2
3
  export declare const networkRuleConditionFormSchema: z.ZodObject<{
3
4
  key: z.ZodString;
4
5
  operator: z.ZodString;
@@ -12,13 +13,34 @@ export declare const networkRuleConditionFormSchema: z.ZodObject<{
12
13
  operator: string;
13
14
  values: string[];
14
15
  }>;
15
- export declare const networkRuleFormSchema: z.ZodEffects<z.ZodObject<{
16
+ export declare function createNetworkRuleFormSchema(metadata: NetworkRuleCatalogMetadata | undefined): z.ZodEffects<z.ZodObject<{
16
17
  name: z.ZodString;
17
18
  status: z.ZodString;
18
19
  notes: z.ZodNullable<z.ZodString>;
19
20
  enabled: z.ZodBoolean;
20
21
  startDate: z.ZodNullable<z.ZodString>;
21
22
  endDate: z.ZodNullable<z.ZodString>;
23
+ metadata: z.ZodArray<z.ZodEffects<z.ZodObject<{
24
+ key: z.ZodString;
25
+ type: z.ZodEnum<[NetworkRuleMetadataType, ...NetworkRuleMetadataType[]]>;
26
+ value: z.ZodString;
27
+ }, "strip", z.ZodTypeAny, {
28
+ key: string;
29
+ type: NetworkRuleMetadataType;
30
+ value: string;
31
+ }, {
32
+ key: string;
33
+ type: NetworkRuleMetadataType;
34
+ value: string;
35
+ }>, {
36
+ key: string;
37
+ type: NetworkRuleMetadataType;
38
+ value: string;
39
+ }, {
40
+ key: string;
41
+ type: NetworkRuleMetadataType;
42
+ value: string;
43
+ }>, "many"> | z.ZodArray<z.ZodNever, "many">;
22
44
  conditions: z.ZodArray<z.ZodObject<{
23
45
  key: z.ZodString;
24
46
  operator: z.ZodString;
@@ -33,6 +55,11 @@ export declare const networkRuleFormSchema: z.ZodEffects<z.ZodObject<{
33
55
  values: string[];
34
56
  }>, "many">;
35
57
  }, "strip", z.ZodTypeAny, {
58
+ metadata: never[] | {
59
+ key: string;
60
+ type: NetworkRuleMetadataType;
61
+ value: string;
62
+ }[];
36
63
  name: string;
37
64
  status: string;
38
65
  enabled: boolean;
@@ -45,6 +72,11 @@ export declare const networkRuleFormSchema: z.ZodEffects<z.ZodObject<{
45
72
  values: string[];
46
73
  }[];
47
74
  }, {
75
+ metadata: never[] | {
76
+ key: string;
77
+ type: NetworkRuleMetadataType;
78
+ value: string;
79
+ }[];
48
80
  name: string;
49
81
  status: string;
50
82
  enabled: boolean;
@@ -57,6 +89,11 @@ export declare const networkRuleFormSchema: z.ZodEffects<z.ZodObject<{
57
89
  values: string[];
58
90
  }[];
59
91
  }>, {
92
+ metadata: never[] | {
93
+ key: string;
94
+ type: NetworkRuleMetadataType;
95
+ value: string;
96
+ }[];
60
97
  name: string;
61
98
  status: string;
62
99
  enabled: boolean;
@@ -69,6 +106,11 @@ export declare const networkRuleFormSchema: z.ZodEffects<z.ZodObject<{
69
106
  values: string[];
70
107
  }[];
71
108
  }, {
109
+ metadata: never[] | {
110
+ key: string;
111
+ type: NetworkRuleMetadataType;
112
+ value: string;
113
+ }[];
72
114
  name: string;
73
115
  status: string;
74
116
  enabled: boolean;
@@ -81,4 +123,4 @@ export declare const networkRuleFormSchema: z.ZodEffects<z.ZodObject<{
81
123
  values: string[];
82
124
  }[];
83
125
  }>;
84
- export type NetworkRuleFormSchema = z.infer<typeof networkRuleFormSchema>;
126
+ export type NetworkRuleFormSchema = z.infer<ReturnType<typeof createNetworkRuleFormSchema>>;
@@ -1 +1 @@
1
- "use strict";import{z as e}from"zod";const a=e.object({key:e.string().min(1,"Select a key"),operator:e.string().min(1,"Select an operator"),values:e.array(e.string().trim().min(1,"Values cannot be empty")).min(1,"Add at least one value")}),s=e.object({name:e.string().trim().min(1,"Rule name is required"),status:e.string().min(1,"Select a status"),notes:e.string().nullable(),enabled:e.boolean(),startDate:e.string().nullable(),endDate:e.string().nullable(),conditions:e.array(a).min(1,"Add at least one condition")}).superRefine((t,n)=>{t.startDate!==null&&t.endDate!==null&&t.endDate<=t.startDate&&n.addIssue({code:e.ZodIssueCode.custom,path:["endDate"],message:"End must be after start"})});export{a as networkRuleConditionFormSchema,s as networkRuleFormSchema};
1
+ "use strict";import{z as e}from"zod";import{isNumberValue as l,isExactNumberValue as d,NETWORK_RULE_METADATA_TYPES as c}from"../utils/metadata.mjs";const y=a=>a.length>0?a:c,b=({types:a,limits:{maxKeyLength:s,maxValueLength:i}})=>e.object({key:e.string().trim().min(1,"Key is required").max(s,`Key must be at most ${s} characters`),type:e.enum(y(a)),value:e.string()}).superRefine((n,m)=>{const r=n.value.trim(),t=u=>{m.addIssue({code:e.ZodIssueCode.custom,path:["value"],message:u})};if(!r){t("Value is required");return}n.type==="string"&&r.length>i&&t(`Value must be at most ${i} characters`),n.type==="number"&&(l(r)?d(r)||t("Too many digits to keep as a number. Use the String type instead"):t("Value must be a number")),n.type==="boolean"&&r!=="true"&&r!=="false"&&t("Select True or False")}),o=e.object({key:e.string().min(1,"Select a key"),operator:e.string().min(1,"Select an operator"),values:e.array(e.string().trim().min(1,"Values cannot be empty")).min(1,"Add at least one value")});function g(a){return e.object({name:e.string().trim().min(1,"Rule name is required"),status:e.string().min(1,"Select a status"),notes:e.string().nullable(),enabled:e.boolean(),startDate:e.string().nullable(),endDate:e.string().nullable(),metadata:a?e.array(b(a)).max(a.limits.maxEntries,`A rule may have at most ${a.limits.maxEntries} metadata entries`):e.array(e.never()).max(0,"Metadata is not available"),conditions:e.array(o).min(1,"Add at least one condition")}).superRefine((s,i)=>{const n=new Set;s.metadata.forEach((m,r)=>{const t=m.key.trim().toLowerCase();if(t){if(n.has(t)){i.addIssue({code:e.ZodIssueCode.custom,path:["metadata",r,"key"],message:"Key already used"});return}n.add(t)}}),s.startDate!==null&&s.endDate!==null&&s.endDate<=s.startDate&&i.addIssue({code:e.ZodIssueCode.custom,path:["endDate"],message:"End must be after start"})})}export{g as createNetworkRuleFormSchema,o as networkRuleConditionFormSchema};
@@ -15,7 +15,7 @@ export interface NetworkRulesDeletionState {
15
15
  conditionIndex?: number;
16
16
  }
17
17
  /** Table callbacks wired to the dialogs; `onToggleEnabled` stays with the consumer. */
18
- export type NetworkRulesDialogTableHandlers = Required<Pick<NetworkRuleRowHandlers, 'onEdit' | 'onDelete' | 'onEditCondition' | 'onDeleteCondition'>>;
18
+ export type NetworkRulesDialogTableHandlers = Required<Pick<NetworkRuleRowHandlers, 'onEdit' | 'onDelete'>>;
19
19
  export type NetworkRulesEditorDialogProps = Pick<NetworkRuleEditorDialogProps, 'open' | 'rule' | 'focusConditionIndex' | 'serverErrors' | 'onClose'>;
20
20
  export type NetworkRulesDeleteDialogProps = Pick<NetworkRuleDeleteDialogProps, 'open' | 'rule' | 'conditionIndex' | 'onClose'>;
21
21
  export interface UseNetworkRulesDialogsResult {
@@ -1 +1 @@
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};
1
+ "use strict";import{useState as C,useCallback as o,useMemo as v}from"react";function b(){const[n,t]=C({open:!1}),[r,s]=C({open:!1}),[d,i]=C(),x=o(()=>{i(void 0),t({open:!0})},[]),l=o(e=>{i(void 0),t({open:!0,rule:e})},[]),D=o((e,c)=>{i(void 0),t({open:!0,rule:e,focusConditionIndex:c})},[]),u=o(()=>{i(void 0),t(e=>({...e,open:!1}))},[]),p=o(e=>{s({open:!0,rule:e})},[]),E=o((e,c)=>{s({open:!0,rule:e,conditionIndex:c})},[]),a=o(()=>{s(e=>({...e,open:!1}))},[]),I=v(()=>({onEdit:l,onDelete:p}),[l,p]),f=v(()=>({open:n.open,rule:n.rule,focusConditionIndex:n.focusConditionIndex,serverErrors:d,onClose:u}),[n,d,u]),g=v(()=>({open:r.open,rule:r.rule,conditionIndex:r.conditionIndex,onClose:a}),[r,a]);return{editor:n,deletion:r,serverErrors:d,setServerErrors:i,openCreate:x,openEdit:l,openEditCondition:D,closeEditor:u,requestDeleteRule:p,requestDeleteCondition:E,closeDeletion:a,tableHandlers:I,editorDialogProps:f,deleteDialogProps:g}}export{b as useNetworkRulesDialogs};
@@ -1 +1 @@
1
- "use strict";import{NETWORK_RULE_STATUSES as e,getStatusPresentation as o}from"./statuses.mjs";import{NetworkRulesProvider as s,useNetworkRuleStatuses as a,useNetworkRulesServices as t}from"./NetworkRules.context.mjs";import{ConditionValuesInput as r}from"./editor/fields/ConditionValuesInput.mjs";import{DateField as l}from"./editor/fields/DateField.mjs";import{NETWORK_RULES_COLUMN_IDS as i,buildNetworkRulesColumns as u}from"./table/columns.mjs";import{NETWORK_RULES_FILTER_IDS as m,NETWORK_RULES_TEXT_OPERATORS as R,buildNetworkRulesFilterFields as n,conditionFilterId as d,conditionFilterKey as p}from"./table/filters.mjs";import{NetworkRuleConditionsTable as N}from"./table/NetworkRuleConditionsTable.mjs";import{NetworkRuleDeleteDialog as w}from"./dialog/NetworkRuleDeleteDialog.mjs";import{NetworkRuleDiscardDialog as k}from"./dialog/NetworkRuleDiscardDialog.mjs";import{NetworkRuleEditorDialog as S}from"./editor/NetworkRuleEditorDialog.mjs";import{NetworkRuleEditorForm as f}from"./editor/NetworkRuleEditorForm.mjs";import{NetworkRuleExpandedPanel as E}from"./table/NetworkRuleExpandedPanel.mjs";import{NetworkRuleRow as T}from"./table/NetworkRuleRow.mjs";import{NetworkRulesTable as D}from"./table/NetworkRulesTable.mjs";import{NetworkStatusChip as O}from"./shared/NetworkStatusChip.mjs";import{OptionChips as C}from"./shared/OptionChips.mjs";import{buildNetworkRulesListQuery as F}from"./table/query.mjs";import{dayToRuleDate as g,formatRuleDate as _,ruleDateToDay as L}from"./utils/date.mjs";import{dedupeValues as y,emptyConditionFormValues as c,fromNetworkRuleFormValues as h,normalizeConditionValues as b,toNetworkRuleFormValues as K}from"./utils/condition.mjs";import{getKeyDef as I,getKeyLabel as V,getOperatorLabel as U,getPresets as W,getStatusLabel as P,hasInlineOptions as v,hasRemoteSource as x,isOperatorMulti as A,toOptions as Q}from"./utils/catalog.mjs";import{networkRuleConditionFormSchema as M,networkRuleFormSchema as H}from"./editor/schema.mjs";import{networkRulesCatalogQueryKey as X,useNetworkRulesCatalog as z}from"./hooks/useNetworkRulesCatalog.mjs";import{useHeldWhileClosed as j}from"./hooks/useHeldWhileClosed.mjs";import{useNetworkRuleSourceSearch as B}from"./hooks/useNetworkRuleSourceSearch.mjs";import{useNetworkRulesDialogs as G}from"./hooks/useNetworkRulesDialogs.mjs";import{useResolvedConditionOptions as J}from"./hooks/useResolvedConditionOptions.mjs";export{r as ConditionValuesInput,l as DateField,i as NETWORK_RULES_COLUMN_IDS,m as NETWORK_RULES_FILTER_IDS,R as NETWORK_RULES_TEXT_OPERATORS,e as NETWORK_RULE_STATUSES,N as NetworkRuleConditionsTable,w as NetworkRuleDeleteDialog,k as NetworkRuleDiscardDialog,S as NetworkRuleEditorDialog,f as NetworkRuleEditorForm,E as NetworkRuleExpandedPanel,T as NetworkRuleRow,s as NetworkRulesProvider,D as NetworkRulesTable,O as NetworkStatusChip,C as OptionChips,u as buildNetworkRulesColumns,n as buildNetworkRulesFilterFields,F as buildNetworkRulesListQuery,d as conditionFilterId,p as conditionFilterKey,g as dayToRuleDate,y as dedupeValues,c as emptyConditionFormValues,_ as formatRuleDate,h as fromNetworkRuleFormValues,I as getKeyDef,V as getKeyLabel,U as getOperatorLabel,W as getPresets,P as getStatusLabel,o as getStatusPresentation,v as hasInlineOptions,x as hasRemoteSource,A as isOperatorMulti,M as networkRuleConditionFormSchema,H as networkRuleFormSchema,X as networkRulesCatalogQueryKey,b as normalizeConditionValues,L as ruleDateToDay,K as toNetworkRuleFormValues,Q as toOptions,j as useHeldWhileClosed,B as useNetworkRuleSourceSearch,a as useNetworkRuleStatuses,z as useNetworkRulesCatalog,G as useNetworkRulesDialogs,t as useNetworkRulesServices,J as useResolvedConditionOptions};
1
+ "use strict";import{NETWORK_RULE_STATUSES as e,getStatusPresentation as a}from"./statuses.mjs";import{NetworkRulesProvider as s,useNetworkRuleStatuses as t,useNetworkRulesServices as o}from"./NetworkRules.context.mjs";import{ConditionValuesInput as r}from"./editor/fields/ConditionValuesInput.mjs";import{DateField as l}from"./editor/fields/DateField.mjs";import{NETWORK_RULES_COLUMN_IDS as u,buildNetworkRulesColumns as i}from"./table/columns.mjs";import{NETWORK_RULES_FILTER_IDS as m,NETWORK_RULES_TEXT_OPERATORS as R,buildNetworkRulesFilterFields as N,conditionFilterId as d,conditionFilterKey as p}from"./table/filters.mjs";import{NETWORK_RULE_METADATA_BOOLEAN_OPTIONS as E,NETWORK_RULE_METADATA_PRESET_FIELDS as n,NETWORK_RULE_METADATA_TYPES as T,emptyMetadataFormValues as w,formatMetadataValue as k,fromMetadataFormValues as S,isExactNumberValue as _,isNumberValue as O,isPartialNumberInput as f,metadataTypeLabel as D,toMetadataFormValues as F,typeOfMetadataValue as L}from"./utils/metadata.mjs";import{NetworkRuleConditionsTable as b}from"./table/NetworkRuleConditionsTable.mjs";import{NetworkRuleDeleteDialog as g}from"./dialog/NetworkRuleDeleteDialog.mjs";import{NetworkRuleDiscardDialog as A}from"./dialog/NetworkRuleDiscardDialog.mjs";import{NetworkRuleEditorDialog as V}from"./editor/NetworkRuleEditorDialog.mjs";import{NetworkRuleEditorForm as y}from"./editor/NetworkRuleEditorForm.mjs";import{NetworkRuleExpandedPanel as C}from"./table/NetworkRuleExpandedPanel.mjs";import{NetworkRuleMetadataTable as c}from"./table/NetworkRuleMetadataTable.mjs";import{NetworkRuleRow as K}from"./table/NetworkRuleRow.mjs";import{NetworkRulesTable as M}from"./table/NetworkRulesTable.mjs";import{NetworkStatusChip as I}from"./shared/NetworkStatusChip.mjs";import{OptionChips as P}from"./shared/OptionChips.mjs";import{buildNetworkRulesListQuery as U}from"./table/query.mjs";import{createNetworkRuleFormSchema as h,networkRuleConditionFormSchema as W}from"./editor/schema.mjs";import{dayToRuleDate as v,formatRuleDate as x,ruleDateToDay as Q}from"./utils/date.mjs";import{dedupeValues as B,emptyConditionFormValues as X,fromNetworkRuleFormValues as H,toNetworkRuleFormValues as Y}from"./utils/condition.mjs";import{getKeyDef as j,getKeyLabel as z,getOperatorLabel as J,getPresets as $,getStatusLabel as q,hasInlineOptions as G,hasRemoteSource as Z,isOperatorMulti as ee,toOptions as ae}from"./utils/catalog.mjs";import{networkRulesCatalogQueryKey as se,useNetworkRulesCatalog as te}from"./hooks/useNetworkRulesCatalog.mjs";import{useHeldWhileClosed as oe}from"./hooks/useHeldWhileClosed.mjs";import{useNetworkRuleSourceSearch as re}from"./hooks/useNetworkRuleSourceSearch.mjs";import{useNetworkRulesDialogs as le}from"./hooks/useNetworkRulesDialogs.mjs";import{useResolvedConditionOptions as ue}from"./hooks/useResolvedConditionOptions.mjs";export{r as ConditionValuesInput,l as DateField,u as NETWORK_RULES_COLUMN_IDS,m as NETWORK_RULES_FILTER_IDS,R as NETWORK_RULES_TEXT_OPERATORS,E as NETWORK_RULE_METADATA_BOOLEAN_OPTIONS,n as NETWORK_RULE_METADATA_PRESET_FIELDS,T as NETWORK_RULE_METADATA_TYPES,e as NETWORK_RULE_STATUSES,b as NetworkRuleConditionsTable,g as NetworkRuleDeleteDialog,A as NetworkRuleDiscardDialog,V as NetworkRuleEditorDialog,y as NetworkRuleEditorForm,C as NetworkRuleExpandedPanel,c as NetworkRuleMetadataTable,K as NetworkRuleRow,s as NetworkRulesProvider,M as NetworkRulesTable,I as NetworkStatusChip,P as OptionChips,i as buildNetworkRulesColumns,N as buildNetworkRulesFilterFields,U as buildNetworkRulesListQuery,d as conditionFilterId,p as conditionFilterKey,h as createNetworkRuleFormSchema,v as dayToRuleDate,B as dedupeValues,X as emptyConditionFormValues,w as emptyMetadataFormValues,k as formatMetadataValue,x as formatRuleDate,S as fromMetadataFormValues,H as fromNetworkRuleFormValues,j as getKeyDef,z as getKeyLabel,J as getOperatorLabel,$ as getPresets,q as getStatusLabel,a as getStatusPresentation,G as hasInlineOptions,Z as hasRemoteSource,_ as isExactNumberValue,O as isNumberValue,ee as isOperatorMulti,f as isPartialNumberInput,D as metadataTypeLabel,W as networkRuleConditionFormSchema,se as networkRulesCatalogQueryKey,Q as ruleDateToDay,F as toMetadataFormValues,Y as toNetworkRuleFormValues,ae as toOptions,L as typeOfMetadataValue,oe as useHeldWhileClosed,re as useNetworkRuleSourceSearch,t as useNetworkRuleStatuses,te as useNetworkRulesCatalog,le as useNetworkRulesDialogs,o as useNetworkRulesServices,ue as useResolvedConditionOptions};
@@ -2,8 +2,5 @@ import { NetworkRule, NetworkRuleCatalog } from '../types';
2
2
  export interface NetworkRuleConditionsTableProps {
3
3
  rule: NetworkRule;
4
4
  catalog?: NetworkRuleCatalog;
5
- readOnly?: boolean;
6
- onEditCondition?: (rule: NetworkRule, index: number) => void;
7
- onDeleteCondition?: (rule: NetworkRule, index: number) => void;
8
5
  }
9
- export declare function NetworkRuleConditionsTable({ rule, catalog, readOnly, onEditCondition, onDeleteCondition, }: Readonly<NetworkRuleConditionsTableProps>): import("react").JSX.Element;
6
+ export declare function NetworkRuleConditionsTable({ rule, catalog, }: Readonly<NetworkRuleConditionsTableProps>): import("react").JSX.Element;
@@ -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.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};
1
+ "use strict";import{Typography as c,Table as p,TableHead as h,TableRow as s,TableCell as a,TableBody as m,Chip as b,Skeleton as y}from"@mui/material";import{useResolvedConditionOptions as f}from"../hooks/useResolvedConditionOptions.mjs";import{OptionChips as g}from"../shared/OptionChips.mjs";import{getKeyDef as u,getKeyLabel as w,getOperatorLabel as x}from"../utils/catalog.mjs";import{jsx as e,jsxs as n}from"react/jsx-runtime";function T({condition:o,catalog:i}){const r=u(i,o.key),{options:t,isLoading:l,service:d}=f(r,o.values);return n(s,{children:[e(a,{sx:{whiteSpace:"nowrap"},children:e(b,{label:w(i,o.key)})}),e(a,{sx:{whiteSpace:"nowrap"},children:x(i,o.operator)}),e(a,{sx:{width:"100%"},children:l?e(y,{variant:"text",width:160}):e(g,{options:t,withLogo:d!==void 0})})]})}function C({rule:o,catalog:i}){return o.conditions.length===0?e(c,{variant:"body2",color:"text.secondary",children:"No conditions"}):n(p,{"aria-label":`Conditions for ${o.name}`,children:[e(h,{children:n(s,{children:[e(a,{children:"Key"}),e(a,{children:"Operator"}),e(a,{children:"Values"})]})}),e(m,{children:o.conditions.map((r,t)=>e(T,{condition:r,catalog:i},`${r.key}-${r.operator}-${t}`))})]})}export{C as NetworkRuleConditionsTable};
@@ -3,12 +3,10 @@ export interface NetworkRuleRowHandlers {
3
3
  onToggleEnabled?: (rule: NetworkRule, enabled: boolean) => void;
4
4
  onEdit?: (rule: NetworkRule) => void;
5
5
  onDelete?: (rule: NetworkRule) => void;
6
- onEditCondition?: (rule: NetworkRule, index: number) => void;
7
- onDeleteCondition?: (rule: NetworkRule, index: number) => void;
8
6
  }
9
7
  export interface NetworkRuleExpandedPanelProps extends NetworkRuleRowHandlers {
10
8
  rule: NetworkRule;
11
9
  catalog?: NetworkRuleCatalog;
12
10
  readOnly?: boolean;
13
11
  }
14
- export declare function NetworkRuleExpandedPanel({ rule, catalog, readOnly, onEdit, onDelete, onEditCondition, onDeleteCondition, }: Readonly<NetworkRuleExpandedPanelProps>): import("react").JSX.Element;
12
+ export declare function NetworkRuleExpandedPanel({ rule, catalog, readOnly, onEdit, onDelete, }: Readonly<NetworkRuleExpandedPanelProps>): import("react").JSX.Element;
@@ -1 +1 @@
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
+ "use strict";import{Stack as a,Button as l,Typography as i}from"@mui/material";import{Edit as p,Delete as m}from"@mui/icons-material";import{CopyableUuid as h}from"../../CopyableUuid/index.mjs";import{SectionLabel as c}from"../../UI/SectionLabel.mjs";import{NetworkRuleConditionsTable as u}from"./NetworkRuleConditionsTable.mjs";import{NetworkRuleMetadataTable as x}from"./NetworkRuleMetadataTable.mjs";import{jsxs as o,jsx as t}from"react/jsx-runtime";function f({rule:e,catalog:d,readOnly:s=!1,onEdit:n,onDelete:r}){return o(a,{spacing:2,useFlexGap:!0,sx:{px:3,py:2},children:[!s&&(n!==void 0||r!==void 0)&&o(a,{direction:"row",spacing:2,alignItems:"center",children:[n&&t(l,{variant:"text",startIcon:t(p,{}),onClick:()=>n(e),children:"Edit"}),r&&t(l,{variant:"text",color:"error",startIcon:t(m,{}),onClick:()=>r(e),children:"Delete"})]}),o(a,{direction:"row",spacing:4,alignItems:"flex-start",children:[o(a,{children:[t(i,{variant:"caption",color:"text.secondary",children:"Rule UUID"}),t(h,{uuid:e.uuid,label:"Rule UUID",variant:"button",head:36,tail:0,mono:!0,iconSx:{fontSize:14,p:.125}})]}),e.notes&&o(a,{sx:{maxWidth:480},children:[t(i,{variant:"caption",color:"text.secondary",children:"Notes"}),t(i,{variant:"body2",children:e.notes})]})]}),o(a,{spacing:1,children:[t(c,{children:"Conditions"}),t(u,{rule:e,catalog:d})]}),o(a,{spacing:1,children:[t(c,{children:"Metadata"}),t(x,{rule:e})]})]})}export{f as NetworkRuleExpandedPanel};
@@ -0,0 +1,9 @@
1
+ import { NetworkRule } from '../types';
2
+ export interface NetworkRuleMetadataTableProps {
3
+ rule: NetworkRule;
4
+ }
5
+ /**
6
+ * The rule's metadata as the editor lays it out: key, type, value. Read-only; a pair is changed
7
+ * through the rule editor, there being no per-entry endpoint to hang row actions on.
8
+ */
9
+ export declare function NetworkRuleMetadataTable({ rule, }: Readonly<NetworkRuleMetadataTableProps>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";import{Typography as s,Table as i,TableHead as c,TableRow as n,TableCell as e,TableBody as h,Chip as p}from"@mui/material";import{metadataTypeLabel as m,formatMetadataValue as b,typeOfMetadataValue as y}from"../utils/metadata.mjs";import{jsx as a,jsxs as r}from"react/jsx-runtime";function f({rule:l}){const t=Object.entries(l.metadata??{});return t.length===0?a(s,{variant:"body2",color:"text.secondary",children:"No metadata"}):r(i,{"aria-label":`Metadata for ${l.name}`,children:[a(c,{children:r(n,{children:[a(e,{children:"Key"}),a(e,{children:"Type"}),a(e,{children:"Value"})]})}),a(h,{children:t.map(([d,o])=>r(n,{children:[a(e,{sx:{whiteSpace:"nowrap"},children:a(p,{label:d})}),a(e,{sx:{whiteSpace:"nowrap"},children:m(y(o))}),a(e,{sx:{width:"100%",overflowWrap:"anywhere"},children:b(o)})]},d))})]})}export{f as NetworkRuleMetadataTable};
@@ -9,7 +9,7 @@ type ListStateProps = Pick<DataTableProps<NetworkRule>, 'pagination' | 'onPagina
9
9
  export interface NetworkRulesTableProps extends NetworkRuleRowHandlers, ListStateProps {
10
10
  rules: NetworkRule[];
11
11
  isLoading?: boolean;
12
- /** No toggle, no row or condition actions. */
12
+ /** No toggle, no row actions. */
13
13
  readOnly?: boolean;
14
14
  emptyMessage?: string;
15
15
  /** Defaults to 640. `'100%'` fills a parent with a definite height. */
@@ -5,6 +5,10 @@ export declare const NETWORK_RULES_FILTER_IDS: {
5
5
  readonly enabled: "enabled";
6
6
  /** "Has a condition on" any of the selected keys. */
7
7
  readonly conditionKey: "conditionKey";
8
+ /** "Has metadata under" any of the selected keys. */
9
+ readonly metadataKey: "metadataKey";
10
+ /** One key's value, picked together with the key; the API takes one such match per request. */
11
+ readonly metadataValue: "metadataValue";
8
12
  };
9
13
  /** The filter id matching the values of one condition key. */
10
14
  export declare function conditionFilterId(key: string): string;
@@ -13,7 +17,7 @@ export declare function conditionFilterKey(filterId: string): string | undefined
13
17
  /** The text operators the rules list accepts; the first is the default. */
14
18
  export declare const NETWORK_RULES_TEXT_OPERATORS: DataTableFilterOperator[];
15
19
  /**
16
- * The table's filter controls: the rule's own status and enabled flag, then what the rule checks —
17
- * which keys it has a condition on, and the values of each key.
20
+ * The table's filter controls: the rule's own status and enabled flag, what the rule checks —
21
+ * which keys it has a condition on, and the values of each key — then the metadata it carries.
18
22
  */
19
23
  export declare function buildNetworkRulesFilterFields(catalog: NetworkRuleCatalog | undefined, statuses: readonly string[], sources?: NetworkRulesServices['sources']): DataTableFilterField[];
@@ -1 +1 @@
1
- "use strict";import{getStatusLabel as m,isOperatorMulti as v,hasInlineOptions as S,hasRemoteSource as h,getPresets as R}from"../utils/catalog.mjs";import{NETWORK_RULES_COLUMN_IDS as n}from"./columns.mjs";const r={status:n.status,enabled:n.enabled,conditionKey:"conditionKey"},u="condition.";function d(e){return`${u}${e}`}function k(e){return e.startsWith(u)?e.slice(u.length):void 0}const c=["contains","equals","startsWith","endsWith"],E=20,b=e=>({value:e.value,label:e.label,caption:e.value}),y=e=>({...b(e),logoUrl:e.logoUrl??null});function O(e,t,i){const s=d(t.key),l=t.label,o=t.operators.some(a=>v(e,a));if(S(t))return{id:s,label:l,kind:o?"multiSelect":"select",options:t.values.options.map(b),selectAllClears:!1};if(h(t)){const a=i?.[t.values.source];return a?{id:s,label:l,kind:"multiSelect",selectAllClears:!1,placeholder:a.searchPlaceholder,loadOptions:async p=>(await a.search({search:p.trim()||void 0,limit:E})).map(y)}:void 0}return{id:s,label:l,kind:"text",operators:c,options:R(e,t.key).map(a=>({label:a,value:a}))}}function _(e,t,i){const s=e?.keys??[];return[{id:r.status,label:"Status",kind:"multiSelect",columnId:n.status,selectAllClears:!1,options:t.map(l=>({label:m(l),value:l}))},{id:r.enabled,label:"Enabled",kind:"boolean",columnId:n.enabled},{id:r.conditionKey,label:"Has Condition with Key",kind:"multiSelect",selectAllClears:!1,options:s.map(l=>({label:l.label,value:l.key}))},...s.flatMap(l=>{const o=O(e,l,i);return o?[o]:[]})]}export{r as NETWORK_RULES_FILTER_IDS,c as NETWORK_RULES_TEXT_OPERATORS,_ as buildNetworkRulesFilterFields,d as conditionFilterId,k as conditionFilterKey};
1
+ "use strict";import{getStatusLabel as S,isOperatorMulti as E,hasInlineOptions as v,hasRemoteSource as K,getPresets as r}from"../utils/catalog.mjs";import{NETWORK_RULE_METADATA_PRESET_FIELDS as b}from"../utils/metadata.mjs";import{NETWORK_RULES_COLUMN_IDS as d}from"./columns.mjs";const o={status:d.status,enabled:d.enabled,conditionKey:"conditionKey",metadataKey:"metadataKey",metadataValue:"metadataValue"},u="condition.",c={metadata:"Metadata",conditions:"Conditions"};function y(e){return`${u}${e}`}function R(e){return e.startsWith(u)?e.slice(u.length):void 0}const m=["contains","equals","startsWith","endsWith"],_=20,k=e=>({value:e.value,label:e.label,caption:e.value}),f=e=>({...k(e),logoUrl:e.logoUrl??null}),p=e=>({label:e,value:e});function T(e,a,n){const l=y(a.key),t=a.label,s=a.operators.some(i=>E(e,i));if(v(a))return{id:l,label:t,kind:s?"multiSelect":"select",options:a.values.options.map(k),selectAllClears:!1};if(K(a)){const i=n?.[a.values.source];return i?{id:l,label:t,kind:"multiSelect",selectAllClears:!1,placeholder:i.searchPlaceholder,loadOptions:async h=>(await i.search({search:h.trim()||void 0,limit:_})).map(f)}:void 0}return{id:l,label:t,kind:"text",operators:m,options:r(e,a.key).map(p)}}function O(e){if(e?.metadata===void 0)return[];const a=r(e,b.key).map(p);return[{id:o.metadataKey,label:"Has Metadata with Key",heading:c.metadata,kind:"multiSelect",freeSolo:!0,selectAllClears:!1,options:a,placeholder:"Pick or type keys"},{id:o.metadataValue,label:"Metadata Value",keyLabel:"Metadata Key",heading:c.metadata,kind:"keyedText",keys:a,operators:m,placeholder:"What the key is set to",options:r(e,b.value).map(p)}]}function A(e,a,n){const l=e?.keys??[];return[{id:o.status,label:"Status",kind:"multiSelect",columnId:d.status,selectAllClears:!1,options:a.map(t=>({label:S(t),value:t}))},{id:o.enabled,label:"Enabled",kind:"boolean",columnId:d.enabled},{id:o.conditionKey,label:"Has Condition with Key",kind:"multiSelect",selectAllClears:!1,options:l.map(t=>({label:t.label,value:t.key}))},...l.flatMap(t=>{const s=T(e,t,n);return s?[{...s,heading:c.conditions}]:[]}),...O(e)]}export{o as NETWORK_RULES_FILTER_IDS,m as NETWORK_RULES_TEXT_OPERATORS,A as buildNetworkRulesFilterFields,y as conditionFilterId,R as conditionFilterKey};
@@ -5,3 +5,4 @@ export * from './NetworkRulesTable';
5
5
  export * from './NetworkRuleRow';
6
6
  export * from './NetworkRuleExpandedPanel';
7
7
  export * from './NetworkRuleConditionsTable';
8
+ export * from './NetworkRuleMetadataTable';
@@ -12,12 +12,23 @@ export type NetworkRuleTextFilter = {
12
12
  export type NetworkRuleConditionFilter = {
13
13
  key?: string[];
14
14
  } & Record<string, string | string[] | NetworkRuleTextFilter | undefined>;
15
+ /**
16
+ * Filters over the metadata a rule carries: `key` is "has metadata under any of these"; `value`
17
+ * matches one key's value as text. The API takes a single `value`, so the key is part of it.
18
+ */
19
+ export type NetworkRuleMetadataFilter = {
20
+ key?: string[];
21
+ value?: NetworkRuleTextFilter & {
22
+ key: string;
23
+ };
24
+ };
15
25
  /** The rules list query the table's filters, search and sorting map to, ready to send as-is. */
16
26
  export type NetworkRulesListQuery = {
17
27
  status?: {
18
28
  $in: string[];
19
29
  };
20
30
  enabled?: boolean;
31
+ metadata?: NetworkRuleMetadataFilter;
21
32
  condition?: NetworkRuleConditionFilter;
22
33
  search?: string;
23
34
  $sort?: Record<string, 1 | -1>;
@@ -1 +1 @@
1
- "use strict";import{NETWORK_RULES_FILTER_IDS as r,conditionFilterKey as v}from"./filters.mjs";const f=120,c=e=>{const t=e.trim().slice(0,f);return t===""?void 0:t};function d(e){const t=e.map(c).filter(n=>n!==void 0);if(t.length!==0)return t.length===1?t[0]:t}function h(e){switch(e.kind){case"multiSelect":return d(e.values);case"select":return e.value===null?void 0:d([e.value]);case"text":{const t=c(e.value);return t===void 0?void 0:{value:t,operator:e.operator}}default:return}}function m(e){const t={};for(const[o,l]of Object.entries(e)){const i=v(o),s=i===void 0?void 0:h(l);i!==void 0&&s!==void 0&&(t[i]=s)}const n=e[r.conditionKey];return n?.kind==="multiSelect"&&n.values.length>0&&(t.key=n.values),Object.keys(t).length===0?void 0:t}function k({filterState:e={},search:t="",sorting:n=[]}){const o={},l=e[r.status];l?.kind==="multiSelect"&&l.values.length>0&&(o.status={$in:l.values});const i=e[r.enabled];i?.kind==="boolean"&&i.value!==null&&(o.enabled=i.value);const s=m(e);s!==void 0&&(o.condition=s);const u=c(t);return u!==void 0&&(o.search=u),n.length>0&&(o.$sort=Object.fromEntries(n.map(a=>[a.id,a.desc?-1:1]))),o}export{k as buildNetworkRulesListQuery};
1
+ "use strict";import{NETWORK_RULES_FILTER_IDS as l,conditionFilterKey as k}from"./filters.mjs";const y=120,a=e=>{const t=e.trim().slice(0,y);return t===""?void 0:t},c=(e,t)=>{const n=e[t];return n?.kind==="multiSelect"&&n.values.length>0?n.values:void 0};function f(e){const t=e.map(a).filter(n=>n!==void 0);if(t.length!==0)return t.length===1?t[0]:t}function m(e){switch(e.kind){case"multiSelect":return f(e.values);case"select":return e.value===null?void 0:f([e.value]);case"text":{const t=a(e.value);return t===void 0?void 0:{value:t,operator:e.operator}}default:return}}function h(e){const t={};for(const[o,r]of Object.entries(e)){const i=k(o),s=i===void 0?void 0:m(r);i!==void 0&&s!==void 0&&(t[i]=s)}const n=c(e,l.conditionKey);return n&&(t.key=n),Object.keys(t).length===0?void 0:t}function b(e){const t={},n=c(e,l.metadataKey);n&&(t.key=n);const o=e[l.metadataValue];if(o?.kind==="keyedText"&&o.key){const r=a(o.value);r!==void 0&&(t.value={key:o.key,value:r,operator:o.operator})}return Object.keys(t).length===0?void 0:t}function p({filterState:e={},search:t="",sorting:n=[]}){const o={},r=c(e,l.status);r&&(o.status={$in:r});const i=e[l.enabled];i?.kind==="boolean"&&i.value!==null&&(o.enabled=i.value);const s=b(e);s!==void 0&&(o.metadata=s);const u=h(e);u!==void 0&&(o.condition=u);const d=a(t);return d!==void 0&&(o.search=d),n.length>0&&(o.$sort=Object.fromEntries(n.map(v=>[v.id,v.desc?-1:1]))),o}export{p as buildNetworkRulesListQuery};