@verifiedinc-public/shared-ui-elements 12.9.0 → 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/DataTable/DataTable.context.d.ts +2 -0
- package/dist/components/DataTable/DataTable.context.mjs +1 -1
- package/dist/components/DataTable/DataTable.export.mjs +3 -3
- package/dist/components/DataTable/DataTable.mjs +1 -1
- package/dist/components/DataTable/DataTableExpandRow.d.ts +28 -0
- package/dist/components/DataTable/DataTableExpandRow.mjs +1 -0
- package/dist/components/DataTable/DataTableHeaderCell.mjs +1 -1
- package/dist/components/DataTable/index.d.ts +1 -0
- package/dist/components/NetworkRules/NetworkRules.context.d.ts +11 -0
- package/dist/components/NetworkRules/NetworkRules.context.mjs +1 -0
- package/dist/components/NetworkRules/dialog/NetworkRuleDeleteDialog.d.ts +16 -0
- package/dist/components/NetworkRules/dialog/NetworkRuleDeleteDialog.mjs +1 -0
- package/dist/components/NetworkRules/dialog/NetworkRuleDiscardDialog.d.ts +10 -0
- package/dist/components/NetworkRules/dialog/NetworkRuleDiscardDialog.mjs +1 -0
- package/dist/components/NetworkRules/dialog/index.d.ts +2 -0
- package/dist/components/NetworkRules/editor/NetworkRuleEditorDialog.d.ts +10 -0
- package/dist/components/NetworkRules/editor/NetworkRuleEditorDialog.mjs +1 -0
- package/dist/components/NetworkRules/editor/NetworkRuleEditorForm.d.ts +24 -0
- package/dist/components/NetworkRules/editor/NetworkRuleEditorForm.mjs +1 -0
- package/dist/components/NetworkRules/editor/fields/ConditionRow.d.ts +10 -0
- package/dist/components/NetworkRules/editor/fields/ConditionRow.mjs +1 -0
- package/dist/components/NetworkRules/editor/fields/ConditionValuesInput.d.ts +13 -0
- package/dist/components/NetworkRules/editor/fields/ConditionValuesInput.mjs +1 -0
- package/dist/components/NetworkRules/editor/fields/ConditionsField.d.ts +7 -0
- package/dist/components/NetworkRules/editor/fields/ConditionsField.mjs +1 -0
- package/dist/components/NetworkRules/editor/fields/DateField.d.ts +19 -0
- package/dist/components/NetworkRules/editor/fields/DateField.mjs +2 -0
- package/dist/components/NetworkRules/editor/fields/NotesField.d.ts +12 -0
- package/dist/components/NetworkRules/editor/fields/NotesField.mjs +1 -0
- package/dist/components/NetworkRules/editor/fields/StatusField.d.ts +5 -0
- package/dist/components/NetworkRules/editor/fields/StatusField.mjs +1 -0
- package/dist/components/NetworkRules/editor/fields/values/InlineValuesInput.d.ts +12 -0
- package/dist/components/NetworkRules/editor/fields/values/InlineValuesInput.mjs +1 -0
- package/dist/components/NetworkRules/editor/fields/values/RemoteValuesInput.d.ts +17 -0
- package/dist/components/NetworkRules/editor/fields/values/RemoteValuesInput.mjs +1 -0
- package/dist/components/NetworkRules/editor/fields/values/TextValuesInput.d.ts +12 -0
- package/dist/components/NetworkRules/editor/fields/values/TextValuesInput.mjs +1 -0
- package/dist/components/NetworkRules/editor/index.d.ts +5 -0
- package/dist/components/NetworkRules/editor/schema.d.ts +84 -0
- package/dist/components/NetworkRules/editor/schema.mjs +1 -0
- package/dist/components/NetworkRules/hooks/index.d.ts +5 -0
- package/dist/components/NetworkRules/hooks/useHeldWhileClosed.d.ts +2 -0
- package/dist/components/NetworkRules/hooks/useHeldWhileClosed.mjs +1 -0
- package/dist/components/NetworkRules/hooks/useNetworkRuleSourceSearch.d.ts +26 -0
- package/dist/components/NetworkRules/hooks/useNetworkRuleSourceSearch.mjs +1 -0
- package/dist/components/NetworkRules/hooks/useNetworkRulesCatalog.d.ts +3 -0
- package/dist/components/NetworkRules/hooks/useNetworkRulesCatalog.mjs +1 -0
- package/dist/components/NetworkRules/hooks/useNetworkRulesDialogs.d.ts +39 -0
- package/dist/components/NetworkRules/hooks/useNetworkRulesDialogs.mjs +1 -0
- package/dist/components/NetworkRules/hooks/useResolvedConditionOptions.d.ts +16 -0
- package/dist/components/NetworkRules/hooks/useResolvedConditionOptions.mjs +1 -0
- package/dist/components/NetworkRules/index.d.ts +9 -0
- package/dist/components/NetworkRules/index.mjs +1 -0
- package/dist/components/NetworkRules/shared/NetworkStatusChip.d.ts +5 -0
- package/dist/components/NetworkRules/shared/NetworkStatusChip.mjs +1 -0
- package/dist/components/NetworkRules/shared/OptionChips.d.ts +9 -0
- package/dist/components/NetworkRules/shared/OptionChips.mjs +1 -0
- package/dist/components/NetworkRules/shared/index.d.ts +2 -0
- package/dist/components/NetworkRules/statuses.d.ts +3 -0
- package/dist/components/NetworkRules/statuses.mjs +1 -0
- package/dist/components/NetworkRules/table/NetworkRuleConditionsTable.d.ts +9 -0
- package/dist/components/NetworkRules/table/NetworkRuleConditionsTable.mjs +1 -0
- package/dist/components/NetworkRules/table/NetworkRuleExpandedPanel.d.ts +14 -0
- package/dist/components/NetworkRules/table/NetworkRuleExpandedPanel.mjs +1 -0
- package/dist/components/NetworkRules/table/NetworkRuleRow.d.ts +9 -0
- package/dist/components/NetworkRules/table/NetworkRuleRow.mjs +1 -0
- package/dist/components/NetworkRules/table/NetworkRulesTable.d.ts +17 -0
- package/dist/components/NetworkRules/table/NetworkRulesTable.mjs +1 -0
- package/dist/components/NetworkRules/table/columns.d.ts +11 -0
- package/dist/components/NetworkRules/table/columns.mjs +1 -0
- package/dist/components/NetworkRules/table/index.d.ts +5 -0
- package/dist/components/NetworkRules/types.d.ts +113 -0
- package/dist/components/NetworkRules/utils/catalog.d.ts +20 -0
- package/dist/components/NetworkRules/utils/catalog.mjs +1 -0
- package/dist/components/NetworkRules/utils/condition.d.ts +7 -0
- package/dist/components/NetworkRules/utils/condition.mjs +1 -0
- package/dist/components/NetworkRules/utils/date.d.ts +6 -0
- package/dist/components/NetworkRules/utils/date.mjs +1 -0
- package/dist/components/NetworkRules/utils/index.d.ts +3 -0
- package/dist/components/UI/LogoAvatar.d.ts +14 -0
- package/dist/components/UI/LogoAvatar.mjs +1 -0
- package/dist/components/UI/LogoChip.d.ts +14 -0
- package/dist/components/UI/LogoChip.mjs +1 -0
- package/dist/components/UI/index.d.ts +2 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/styles/lib/react-datepicker.d.ts +1 -1
- package/dist/styles/lib/react-datepicker.mjs +8 -2
- package/dist/styles/theme.mjs +1 -1
- package/package.json +1 -1
|
@@ -92,6 +92,8 @@ export interface DataTableContextValue<TData extends DataTableData> {
|
|
|
92
92
|
hasResizedColumns: boolean;
|
|
93
93
|
startColumnResize: (header: Header<TData, unknown>, event: MouseEvent<HTMLElement> | TouchEvent<HTMLElement>) => void;
|
|
94
94
|
virtualizer: Virtualizer<HTMLDivElement, Element>;
|
|
95
|
+
/** The scrolling element around the table; e.g. to size sticky expanded panels to the visible width. */
|
|
96
|
+
scrollContainerRef: RefObject<HTMLDivElement>;
|
|
95
97
|
}
|
|
96
98
|
interface DataTableProviderProps<TData extends DataTableData> {
|
|
97
99
|
value: DataTableContextValue<TData>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{useContext as r,createContext as n}from"react";import{jsx as o}from"react/jsx-runtime";const t=n(null);function s({value:e,children:a}){return o(t.Provider,{value:e,children:a})}function u(){const e=r(t);if(!e)throw new Error("useDataTableContext must be used within a <DataTable/>");return e}export{s as DataTableProvider,u as useDataTableContext};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";import{getColumnLabel as b}from"./DataTable.utils.mjs";function x(e){return e==null?"":typeof e=="number"||typeof e=="boolean"?e:e instanceof Date?e.toLocaleString():typeof e=="object"?JSON.stringify(e):String(e)}function U(e,n=[]){const t=e.getVisibleLeafColumns().filter(o=>o.accessorFn!==void 0),r=t.map(o=>{var s;const a=(s=o.parent)==null?void 0:s.columnDef.header;return typeof a=="string"?a:""});return{groupHeader:r.some(o=>o!=="")?r.map((o,s)=>s>0&&r[s-1]===o?"":o).concat(n.map(()=>"")):void 0,header:[...t.map(o=>b(o)),...n.map(o=>o.header)],rows:e.getPrePaginationRowModel().rows.map(o=>[...t.map(s=>x(o.getValue(s.id))),...n.map(s=>x(s.value(o.original)))])}}function y(e,n){const t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=n,r.click(),URL.revokeObjectURL(t)}function
|
|
2
|
-
`)],{type:"text/csv;charset=utf-8;"});y(r,`${n}.csv`)}function f(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function
|
|
1
|
+
"use strict";import{getColumnLabel as b}from"./DataTable.utils.mjs";function x(e){return e==null?"":typeof e=="number"||typeof e=="boolean"?e:e instanceof Date?e.toLocaleString():typeof e=="object"?JSON.stringify(e):String(e)}function U(e,n=[]){const t=e.getVisibleLeafColumns().filter(o=>o.accessorFn!==void 0),r=t.map(o=>{var s;const a=(s=o.parent)==null?void 0:s.columnDef.header;return typeof a=="string"?a:""});return{groupHeader:r.some(o=>o!=="")?r.map((o,s)=>s>0&&r[s-1]===o?"":o).concat(n.map(()=>"")):void 0,header:[...t.map(o=>b(o)),...n.map(o=>o.header)],rows:e.getPrePaginationRowModel().rows.map(o=>[...t.map(s=>x(o.getValue(s.id))),...n.map(s=>x(s.value(o.original)))])}}function y(e,n){const t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=n,r.click(),URL.revokeObjectURL(t)}const w=/^[=+\-@\t\r]/;function v(e){let n=String(e);return typeof e=="string"&&n.length>1&&w.test(n)&&(n=`'${n}`),/[",\n\r]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}function k(e,n){const t=[...e.groupHeader?[e.groupHeader]:[],e.header,...e.rows].map(o=>o.map(v).join(",")),r=new Blob(["\uFEFF",t.join(`
|
|
2
|
+
`)],{type:"text/csv;charset=utf-8;"});y(r,`${n}.csv`)}function f(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function T(e){let n="",t=e+1;for(;t>0;)n=String.fromCharCode(65+(t-1)%26)+n,t=Math.floor((t-1)/26);return n}function $(e){return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>${[...e.groupHeader?[e.groupHeader]:[],e.header,...e.rows].map((n,t)=>{const r=n.map((o,s)=>{const a=`${T(s)}${t+1}`;return typeof o=="number"&&Number.isFinite(o)?`<c r="${a}"><v>${o}</v></c>`:typeof o=="boolean"?`<c r="${a}" t="b"><v>${o?1:0}</v></c>`:`<c r="${a}" t="inlineStr"><is><t xml:space="preserve">${f(String(o))}</t></is></c>`}).join("");return`<row r="${t+1}">${r}</row>`}).join("")}</sheetData></worksheet>`}const D=[{name:"[Content_Types].xml",content:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/></Types>'},{name:"_rels/.rels",content:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>'},{name:"xl/workbook.xml",content:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="Data" sheetId="1" r:id="rId1"/></sheets></workbook>'},{name:"xl/_rels/workbook.xml.rels",content:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/></Relationships>'}],R=(()=>{const e=new Uint32Array(256);for(let n=0;n<256;n++){let t=n;for(let r=0;r<8;r++)t=t&1?3988292384^t>>>1:t>>>1;e[n]=t>>>0}return e})();function C(e){let n=4294967295;for(let t=0;t<e.length;t++)n=R[(n^e[t])&255]^n>>>8;return(n^4294967295)>>>0}function F(e){const n=new TextEncoder,t=[],r=[];let o=0;for(const p of e){const m=n.encode(p.name),c=n.encode(p.content),g=C(c),l=new DataView(new ArrayBuffer(30));l.setUint32(0,67324752,!0),l.setUint16(4,20,!0),l.setUint16(6,2048,!0),l.setUint16(8,0,!0),l.setUint16(10,0,!0),l.setUint16(12,33,!0),l.setUint32(14,g,!0),l.setUint32(18,c.length,!0),l.setUint32(22,c.length,!0),l.setUint16(26,m.length,!0),l.setUint16(28,0,!0),t.push(new Uint8Array(l.buffer),m,c);const i=new DataView(new ArrayBuffer(46));i.setUint32(0,33639248,!0),i.setUint16(4,20,!0),i.setUint16(6,20,!0),i.setUint16(8,2048,!0),i.setUint16(10,0,!0),i.setUint16(12,0,!0),i.setUint16(14,33,!0),i.setUint32(16,g,!0),i.setUint32(20,c.length,!0),i.setUint32(24,c.length,!0),i.setUint16(28,m.length,!0),i.setUint32(42,o,!0),r.push(new Uint8Array(i.buffer),m),o+=30+m.length+c.length}const s=r.reduce((p,m)=>p+m.length,0),a=new DataView(new ArrayBuffer(22));a.setUint32(0,101010256,!0),a.setUint16(8,e.length,!0),a.setUint16(10,e.length,!0),a.setUint32(12,s,!0),a.setUint32(16,o,!0);const h=new Uint8Array(a.buffer),d=new Uint8Array(o+s+h.length);let u=0;for(const p of[...t,...r,h])d.set(p,u),u+=p.length;return d.buffer}function j(e,n){const t=F([...D,{name:"xl/worksheets/sheet1.xml",content:$(e)}]);y(new Blob([t],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),`${n}.xlsx`)}function A(e,n){const t=(s,a)=>`<tr>${s.map(h=>`<${a}${typeof h=="number"?' class="num"':""}>${f(String(h))}</${a}>`).join("")}</tr>`,r=[...e.groupHeader?[t(e.groupHeader,"th")]:[],t(e.header,"th")].join(""),o=e.rows.map(s=>t(s,"td")).join("");return`<!doctype html><html><head><meta charset="utf-8"><title>${f(n)}</title><style>
|
|
3
3
|
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; margin: 16px; }
|
|
4
4
|
table { border-collapse: collapse; width: 100%; font-size: 12px; }
|
|
5
5
|
th, td { padding: 6px 8px; border-bottom: 1px solid #ddd; text-align: left; }
|
|
6
6
|
th { text-transform: uppercase; font-size: 10px; }
|
|
7
7
|
.num { text-align: right; }
|
|
8
|
-
</style></head><body><table><thead>${r}</thead><tbody>${o}</tbody></table></body></html>`}function
|
|
8
|
+
</style></head><body><table><thead>${r}</thead><tbody>${o}</tbody></table></body></html>`}function E(e,n){const t=document.createElement("iframe");t.style.position="fixed",t.style.right="0",t.style.bottom="0",t.style.width="0",t.style.height="0",t.style.border="0",t.onload=()=>{const r=t.contentWindow;if(!r){t.remove();return}r.addEventListener("afterprint",()=>t.remove()),r.focus(),r.print()},t.srcdoc=A(e,n),document.body.appendChild(t)}export{k as exportDataTableToCsv,j as exportDataTableToExcel,U as getDataTableExportModel,E as printDataTable};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useMemo as V,useState as ie,useRef as D,useEffect as dt}from"react";import{useReactTable as gt,getPaginationRowModel as mt,getSortedRowModel as ft,getCoreRowModel as ct}from"@tanstack/react-table";import{useVirtualizer as ht}from"@tanstack/react-virtual";import{Box as pt,TableContainer as bt,Table as Ct}from"@mui/material";import{useBidirectionalScroll as wt}from"../../hooks/useBidirectionalScroll.mjs";import{DataTableProvider as Rt}from"./DataTable.context.mjs";import{useControllableState as m,useHeaderRowTops as St,useStickyHeaderHeight as Pt,usePinnedOffsets as vt}from"./DataTable.hooks.mjs";import{getLeafAccessorsById as yt,applySearch as xt}from"./DataTable.filters.mjs";import{buildInitialFilterState as Lt,applyFieldFilters as zt}from"./DataTable.filterState.mjs";import{inferColumns as ae,applyMetaWidthsToSizes as
|
|
1
|
+
"use strict";import{useMemo as V,useState as ie,useRef as D,useEffect as dt}from"react";import{useReactTable as gt,getPaginationRowModel as mt,getSortedRowModel as ft,getCoreRowModel as ct}from"@tanstack/react-table";import{useVirtualizer as ht}from"@tanstack/react-virtual";import{Box as pt,TableContainer as bt,Table as Ct}from"@mui/material";import{useBidirectionalScroll as wt}from"../../hooks/useBidirectionalScroll.mjs";import{DataTableProvider as Rt}from"./DataTable.context.mjs";import{useControllableState as m,useHeaderRowTops as St,useStickyHeaderHeight as Pt,usePinnedOffsets as vt}from"./DataTable.hooks.mjs";import{getLeafAccessorsById as yt,applySearch as xt}from"./DataTable.filters.mjs";import{buildInitialFilterState as Lt,applyFieldFilters as zt}from"./DataTable.filterState.mjs";import{inferColumns as ae,applyMetaWidthsToSizes as Tt,getColumnMeta as le,measureRowGroup as Mt}from"./DataTable.utils.mjs";import{DataTableBody as Ht}from"./DataTableBody.mjs";import{DataTableFooter as Ot}from"./DataTableFooter.mjs";import{DataTableHead as Ft}from"./DataTableHead.mjs";import{DataTablePanels as Vt}from"./DataTablePanels.mjs";import{DataTableToolbar as Dt}from"./DataTableToolbar.mjs";import{jsx as u,jsxs as re}from"react/jsx-runtime";const It=100,Et=[10,25,50,100],Bt=53,Nt={},se={left:[],right:[]},ue=()=>{};function de(i){for(const l of i??[]){const d=l.columns;if(d!=null&&d.length){const p=de(d);if(p)return p;continue}if(l.enablePinning===!1)continue;const c=l.accessorKey,h=l.id??(typeof c=="string"?c:void 0);if(h)return h}}function kt({data:i,columns:l,getRowId:d,renderRow:c,initialSorting:h=[],sorting:p,onSortingChange:ge,manualSorting:I=!1,initialPageSize:me=It,pageSizeOptions:fe=Et,pagination:ce,onPaginationChange:he,manualPagination:b=!1,rowCount:P,disableSorting:v=!1,disablePagination:y=!1,bidirectionalScroll:n,enableColumnResizing:g=!1,enableColumnMenu:pe=!1,enableColumnPinning:E=!1,pinFirstColumn:be=!0,showToolbar:Ce=!1,enableExport:we=!1,exportFilename:Re="data",additionalExportColumns:Se,manualFiltering:B=!1,filterFields:C,initialFilterState:Pe,filterState:ve,onFilterStateChange:ye,initialSearch:xe="",search:Le,onSearchChange:ze,initialColumnVisibility:N={},columnVisibility:Te,onColumnVisibilityChange:Me,initialColumnPinning:k=se,columnPinning:W,onColumnPinningChange:He,footerLeft:Oe,estimateRowHeight:Fe=Bt,minWidth:Ve=650,maxHeight:j=800,tableLayout:x="auto",icons:De=Nt,emptyMessage:Ie="No data to display.",isLoading:Ee=!1,renderLoading:Be}){var K,$;const[Ne,ke]=m(h,p,ge),[We,je]=m({pageIndex:0,pageSize:me},ce,he),[L,Ke]=m(Pe??Lt(C??[]),ve,ye),[z,$e]=m(xe,Le,ze),[qe,Ge]=m(N,Te,Me),q=V(()=>de(l??ae(i)),[l,i]),Je=W===void 0&&k===se&&be&&q?{left:[q],right:[]}:k,[T,Qe]=m(Je,W,He),M=E||(((K=T.left)==null?void 0:K.length)??0)>0||((($=T.right)==null?void 0:$.length)??0)>0,[H,Ue]=ie({}),G=g&&Object.keys(H).length>0,[Xe,w]=ie(null),Ye=()=>{w(null)},J=D(null),Q=D(null),U=(e,t)=>{if(t){const r=t.getBoundingClientRect();return{anchorPosition:{top:r.bottom,left:r.right},transformHorizontal:"right"}}const o=e.getBoundingClientRect();return{anchorPosition:{top:o.bottom,left:o.left},transformHorizontal:"left"}},Ze=(e,t)=>{w({type:"filter",columnId:e,...U(t,J.current)})},Ae=e=>{w({type:"manageColumns",...U(e,Q.current)})},R=D(null),s=V(()=>{const e=l??ae(i);return g?Tt(e):e},[l,i,g]),_e=V(()=>{if(B)return i;const e=yt(s);return xt(zt(i,C??[],L,(t,o,r)=>{const f=e[o];return f?f(t,r):t[o]}),z,s)},[i,C,L,z,B,s]),a=gt({data:_e,columns:s,state:{...v?{}:{sorting:Ne},...y?{}:{pagination:We},...M?{columnPinning:T}:{},columnVisibility:qe,columnSizing:H},initialState:{columnVisibility:N},onSortingChange:ke,onPaginationChange:je,onColumnVisibilityChange:Ge,onColumnPinningChange:Qe,onColumnSizingChange:Ue,enableColumnPinning:E,columnResizeMode:"onChange",enableColumnResizing:g,getCoreRowModel:ct(),defaultColumn:{enableSorting:!1},enableSorting:!v,manualSorting:I,...v||I?{}:{getSortedRowModel:ft()},manualPagination:b,...b&&P!==void 0?{rowCount:P}:{},getRowCanExpand:()=>!0,...y||b?{}:{getPaginationRowModel:mt()},...d?{getRowId:d}:{}}),O=a.getRowModel().rows,et=b?P??i.length:a.getPrePaginationRowModel().rows.length,tt=a.getVisibleLeafColumns().length||1,nt=g&&a.getVisibleLeafColumns().some(e=>{var t;return typeof((t=le(e.columnDef.meta))==null?void 0:t.width)=="number"}),ot=G||nt,F=M?a.getLeftVisibleLeafColumns().map(e=>e.id):[],X=M?a.getRightVisibleLeafColumns().map(e=>e.id):[],Y=a.getHeaderGroups().length,{headerRowRefs:Z,headerRowTops:it}=St(Y,s),A=n!==void 0,at=Pt(A,Z,Y,s),{headerCellRefs:_,pinnedOffsets:ee}=vt(F,X,s),lt=(e,t)=>{var o;for(const r of a.getVisibleLeafColumns())if(H[r.id]===void 0){const f=(o=_.current[r.id])==null?void 0:o.getBoundingClientRect().width;f&&(r.columnDef.size=Math.round(f))}e.getResizeHandler()(t)},te=(e,t)=>e==="left"?F[F.length-1]===t:X[0]===t,ne=(e,t)=>{if(e==="left")return{left:ee.left[t]??0};if(e==="right")return{right:ee.right[t]??0}},oe=x==="fixed"?{overflow:"hidden",textOverflow:"ellipsis"}:void 0,rt=(e,t)=>e?o=>({...oe,position:"sticky",zIndex:1,bgcolor:"background.paper",".MuiTableRow-hover:hover > &":{backgroundImage:`linear-gradient(${o.palette.action.hover}, ${o.palette.action.hover})`},...te(e,t)?{boxShadow:`inset ${e==="left"?-1:1}px 0 0 ${o.palette.divider}`}:{}}):oe,st=e=>{var t;const o=e.column.getIsPinned();return{align:(t=le(e.column.columnDef.meta))==null?void 0:t.align,style:ne(o,e.column.id),sx:rt(o,e.column.id)}},S=ht({count:O.length,getScrollElement:()=>R.current,estimateSize:()=>Fe,overscan:5,measureElement:Mt});wt({enabled:A,scrollContainerRef:R,virtualizer:S,rowCount:O.length,hasNewer:n?.hasNewer,hasOlder:n?.hasOlder,isLoadingNewer:n?.isLoadingNewer,isLoadingOlder:n?.isLoadingOlder,onLoadNewer:n?.onLoadNewer??ue,onLoadOlder:n?.onLoadOlder??ue,resetKey:n?.resetKey});const{pageIndex:ut}=a.getState().pagination;return dt(()=>{S.scrollToOffset(0)},[ut,S]),u(Rt,{value:{table:a,data:i,rows:O,totalRowCount:et,columnCount:tt,icons:De,isLoading:Ee,emptyMessage:Ie,tableLayout:x,enableColumnResizing:g,enableColumnMenu:pe,enableExport:we,exportFilename:Re,additionalExportColumns:Se,disablePagination:y,pageSizeOptions:fe,footerLeft:Oe,bidirectionalScroll:n,renderLoading:Be,renderRow:c,filterFields:C,filterState:L,onFilterStateChange:Ke,search:z,onSearchChange:$e,columnPanel:Xe,setColumnPanel:w,closeColumnPanel:Ye,openFilterPanel:Ze,openManageColumnsPanel:Ae,toolbarFilterButtonRef:J,toolbarManageColumnsButtonRef:Q,headerRowRefs:Z,headerCellRefs:_,headerRowTops:it,headerHeight:at,isPinnedEdge:te,getPinnedOffsetStyle:ne,getCellProps:st,hasResizedColumns:G,startColumnResize:lt,virtualizer:S,scrollContainerRef:R},children:re(pt,{sx:{width:"100%",...j==="100%"?{height:"100%",minHeight:0,display:"flex",flexDirection:"column"}:{}},children:[Ce&&u(Dt,{}),u(bt,{ref:R,sx:{maxHeight:j,width:0,minWidth:"100%",flex:"1 1 auto",minHeight:0},children:re(Ct,{stickyHeader:!0,sx:{minWidth:Ve,tableLayout:x},style:ot?{width:`max(${a.getTotalSize()}px, 100%)`}:void 0,"aria-label":"data table",children:[u(Ft,{}),u(Ht,{})]})}),u(Vt,{}),u(Ot,{})]})})}export{kt as DataTable};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ColumnDef, Row } from '@tanstack/react-table';
|
|
2
|
+
export declare const EXPAND_COLUMN_ID = "expand";
|
|
3
|
+
/**
|
|
4
|
+
* Drives both halves of the animation — the chevron's rotation and the detail
|
|
5
|
+
* panel's `Collapse` timeout.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EXPAND_TRANSITION_MS = 200;
|
|
8
|
+
/**
|
|
9
|
+
* Sticky-left, at content width, so an expanded panel follows the viewport
|
|
10
|
+
* while the table scrolls horizontally instead of rolling off to the left and
|
|
11
|
+
* leaving the expanded row blank. Spread it alongside the panel's own padding.
|
|
12
|
+
*/
|
|
13
|
+
export declare const EXPANDED_ROW_PANEL_SX: {
|
|
14
|
+
readonly position: "sticky";
|
|
15
|
+
readonly left: 0;
|
|
16
|
+
readonly width: "fit-content";
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Display-only, so it is skipped by the CSV / Excel / Print export, and opted
|
|
20
|
+
* out of every column feature — there is nothing to sort, filter, hide or
|
|
21
|
+
* resize.
|
|
22
|
+
*/
|
|
23
|
+
export declare function expandColumn<TData>(): ColumnDef<TData, unknown>;
|
|
24
|
+
export interface ExpandRowToggleProps<TData> {
|
|
25
|
+
row: Row<TData>;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function ExpandRowToggle<TData>({ row, disabled, }: Readonly<ExpandRowToggleProps<TData>>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{IconButton as l}from"@mui/material";import{ChevronRight as r}from"@mui/icons-material";import{jsx as a}from"react/jsx-runtime";const o="expand",t=200,s={position:"sticky",left:0,width:"fit-content"};function d(){return{id:o,header:"",meta:{width:72,disableColumnMenu:!0},enableHiding:!1,enableResizing:!1,enablePinning:!1,enableColumnFilter:!1,enableGlobalFilter:!1,enableGrouping:!1,enableMultiSort:!1,enableSorting:!1}}function m({row:n,disabled:i}){const e=n.getIsExpanded();return a(l,{size:"small","aria-label":e?"Collapse row":"Expand row","aria-expanded":e,disabled:i,onClick:n.getToggleExpandedHandler(),children:a(r,{sx:{transform:e?"rotate(90deg)":"none",transition:`transform ${t}ms`}})})}export{s as EXPANDED_ROW_PANEL_SX,o as EXPAND_COLUMN_ID,t as EXPAND_TRANSITION_MS,m as ExpandRowToggle,d as expandColumn};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{flexRender as W}from"@tanstack/react-table";import{Typography as q,TableSortLabel as G,TableCell as J,Box as
|
|
1
|
+
"use strict";import{flexRender as W}from"@tanstack/react-table";import{Typography as q,TableSortLabel as G,TableCell as J,Box as C,Tooltip as v,IconButton as w}from"@mui/material";import{FilterAlt as K,MoreVert as Q}from"@mui/icons-material";import{useDataTableContext as U}from"./DataTable.context.mjs";import{isFilterFieldActive as X}from"./DataTable.filterState.mjs";import{getColumnMeta as Y,getColumnLabel as S}from"./DataTable.utils.mjs";import{jsx as o,jsxs as y}from"react/jsx-runtime";const Z=30,_={left:"flex-start",center:"center",right:"flex-end"};function ee({header:l,rowIndex:s,headerRowCount:T}){const{icons:m,isLoading:z,tableLayout:D,enableColumnResizing:p,enableColumnMenu:f,hasResizedColumns:I,columnPanel:d,setColumnPanel:M,filterFields:R,filterState:B,openFilterPanel:P,startColumnResize:h,getPinnedOffsetStyle:k,isPinnedEdge:A,headerRowTops:F,headerCellRefs:j}=U(),{columnMenu:L=Q,filter:$=K}=m,{column:e}=l,n=Y(e.columnDef.meta),i=e.columns.length>0,g=i?1:T-s,c=n?.align??(i?"center":"left"),H=e.getCanSort(),a=e.getIsSorted(),E=p&&!i&&e.getCanResize(),N=e.getIsResizing(),r=i?!1:e.getIsPinned(),u=f&&!i&&!(n!=null&&n.disableColumnMenu),O=d?.type==="menu"&&d.columnId===e.id,V=(R??[]).some(t=>t.columnId===e.id&&X(t,B[t.id])),b=o(q,{component:"span",variant:"subtitle2",sx:{textTransform:"uppercase",fontSize:12,fontWeight:900},children:W(e.columnDef.header,l.getContext())}),x=H?o(G,{active:a!==!1,direction:a===!1?"asc":a,disabled:z,onClick:e.getToggleSortingHandler(),IconComponent:m.sort,children:b}):b;return y(J,{ref:t=>{i||(j.current[e.id]=t)},align:c,colSpan:l.colSpan>1?l.colSpan:void 0,rowSpan:g>1?g:void 0,sortDirection:a,style:{...I||p&&typeof n?.width=="number"?{width:l.getSize()}:{},...k(r,e.id)},sx:{width:n?.width,verticalAlign:"bottom",...D==="fixed"?{overflow:"hidden",textOverflow:"ellipsis"}:{},...i?{borderBottom:"none"}:{},...s>0?{top:F[s]??0}:{},...r?{zIndex:3,...A(r,e.id)?{boxShadow:t=>`inset ${r==="left"?-1:1}px 0 0 ${t.palette.divider}`}:{}}:{},...u?{"& .DataTable-columnMenuButton":{opacity:O?1:0,transition:"opacity .2s"},"&:hover .DataTable-columnMenuButton, &:focus-within .DataTable-columnMenuButton":{opacity:1}}:{}},children:[i?x:y(C,{sx:{display:"flex",alignItems:"center",gap:.5,minHeight:f?Z:void 0,justifyContent:_[c]},children:[x,u&&V&&o(v,{title:"Active filter",placement:"bottom",arrow:!0,children:o(w,{size:"small","aria-label":`${S(e)} filter`,onClick:t=>P(e.id,t.currentTarget),children:o($,{sx:{fontSize:16}})})}),u&&o(v,{title:"Menu",placement:"bottom",arrow:!0,children:o(w,{size:"small",className:"DataTable-columnMenuButton","aria-label":`${S(e)} column menu`,onClick:t=>M({type:"menu",columnId:e.id,anchorEl:t.currentTarget}),sx:c!=="right"?{ml:"auto"}:void 0,children:o(L,{fontSize:"small"})})})]}),E&&o(C,{className:"DataTable-columnResizer","aria-hidden":!0,onMouseDown:t=>h(l,t),onTouchStart:t=>h(l,t),onDoubleClick:()=>e.resetSize(),sx:{position:"absolute",top:0,bottom:0,right:0,width:9,cursor:"col-resize",touchAction:"none",userSelect:"none",display:"flex",alignItems:"center",justifyContent:"center","&::after":{content:'""',transition:"background-color .2s",width:"1px",height:"50%",bgcolor:"divider"},"&:hover::after":{width:"4px",bgcolor:"primary.main"},...N?{"&::after, &:hover::after":{width:"4px",bgcolor:"primary.main"}}:{}}})]})}export{ee as DataTableHeaderCell};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { NetworkRulesServices } from './types';
|
|
3
|
+
export interface NetworkRulesProviderProps {
|
|
4
|
+
services: NetworkRulesServices;
|
|
5
|
+
/** Status codes a rule may take. Defaults to the catalog's `statuses`. */
|
|
6
|
+
statuses?: readonly string[];
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function NetworkRulesProvider({ services, statuses, children, }: Readonly<NetworkRulesProviderProps>): import("react").JSX.Element;
|
|
10
|
+
export declare function useNetworkRulesServices(): NetworkRulesServices;
|
|
11
|
+
export declare function useNetworkRuleStatuses(): readonly string[] | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useState as c,useMemo as a,createContext as l,useContext as d}from"react";import{QueryClient as f,QueryClientProvider as w}from"@tanstack/react-query";import{jsx as s}from"react/jsx-runtime";const t=l(null);function m({services:e,statuses:r,children:o}){const[u]=c(()=>e.queryClient??new f({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}})),i=a(()=>({services:e,statuses:r}),[e,r]);return s(w,{client:u,children:s(t.Provider,{value:i,children:o})})}function n(){const e=d(t);if(!e)throw new Error("NetworkRules components must be rendered within a NetworkRulesProvider");return e}function v(){return n().services}function p(){return n().statuses}export{m as NetworkRulesProvider,p as useNetworkRuleStatuses,v as useNetworkRulesServices};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { NetworkRule } from '../types';
|
|
3
|
+
export interface NetworkRuleDeleteDialogProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
rule?: NetworkRule | null;
|
|
6
|
+
/** When set, one condition of `rule` is being deleted instead of the rule. */
|
|
7
|
+
conditionIndex?: number | null;
|
|
8
|
+
onConfirm: (rule: NetworkRule, conditionIndex?: number) => void | Promise<void>;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
isDeleting?: boolean;
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: ReactNode;
|
|
13
|
+
confirmLabel?: string;
|
|
14
|
+
cancelLabel?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function NetworkRuleDeleteDialog({ open, rule: ruleProp, conditionIndex: conditionIndexProp, onConfirm, onClose, isDeleting, title, description, confirmLabel, cancelLabel, }: Readonly<NetworkRuleDeleteDialogProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface NetworkRuleDiscardDialogProps {
|
|
2
|
+
open: boolean;
|
|
3
|
+
onKeepEditing: () => void;
|
|
4
|
+
onDiscard: () => void;
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
keepEditingLabel?: string;
|
|
8
|
+
discardLabel?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function NetworkRuleDiscardDialog({ open, onKeepEditing, onDiscard, title, description, keepEditingLabel, discardLabel, }: Readonly<NetworkRuleDiscardDialogProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Dialog as c,DialogTitle as h,DialogContent as g,Typography as p,DialogActions as D,Button as a}from"@mui/material";import{jsxs as o,jsx as i}from"react/jsx-runtime";function u({open:n,onKeepEditing:e,onDiscard:r,title:t="Discard Changes?",description:l="You have unsaved changes that will be lost.",keepEditingLabel:s="Keep editing",discardLabel:d="Discard"}){return o(c,{open:n,onClose:e,maxWidth:"xs",fullWidth:!0,children:[i(h,{children:t}),i(g,{children:i(p,{variant:"body2",children:l})}),o(D,{children:[i(a,{variant:"text",color:"neutral",onClick:e,children:s}),i(a,{variant:"contained",color:"error",onClick:r,children:d})]})]})}export{u as NetworkRuleDiscardDialog};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DialogProps } from '@mui/material';
|
|
2
|
+
import { NetworkRuleEditorFormProps } from './NetworkRuleEditorForm';
|
|
3
|
+
export interface NetworkRuleEditorDialogProps extends Omit<NetworkRuleEditorFormProps, 'id' | 'hideActions' | 'onCancel' | 'onDirtyChange'> {
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** With unsaved changes the user is asked to confirm first. */
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
title?: string;
|
|
8
|
+
maxWidth?: DialogProps['maxWidth'];
|
|
9
|
+
}
|
|
10
|
+
export declare function NetworkRuleEditorDialog({ open, onClose, title, maxWidth, rule: ruleProp, focusConditionIndex: focusConditionIndexProp, isSubmitting, disabled, submitLabel, cancelLabel, ...formProps }: Readonly<NetworkRuleEditorDialogProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NetworkRule, NetworkRuleData, NetworkRuleServerError, NetworkRuleSubmitExtras } from '../types';
|
|
2
|
+
export interface NetworkRuleEditorFormProps {
|
|
3
|
+
/** Omit for a new rule. */
|
|
4
|
+
rule?: Partial<NetworkRule> | null;
|
|
5
|
+
/** Pre-filled, editable name for a new rule, e.g. "Rule #7". */
|
|
6
|
+
defaultName?: string;
|
|
7
|
+
notePresets?: readonly string[];
|
|
8
|
+
/** Offer "Add … as a preset" for a typed note; new presets arrive with `onSubmit`. */
|
|
9
|
+
canCreateNotePresets?: boolean;
|
|
10
|
+
onSubmit: (rule: NetworkRuleData, extras: NetworkRuleSubmitExtras) => void | Promise<void>;
|
|
11
|
+
onCancel?: () => void;
|
|
12
|
+
isSubmitting?: boolean;
|
|
13
|
+
/** Indexed errors highlight their condition row; the rest show at the top. */
|
|
14
|
+
serverErrors?: readonly NetworkRuleServerError[];
|
|
15
|
+
focusConditionIndex?: number;
|
|
16
|
+
submitLabel?: string;
|
|
17
|
+
cancelLabel?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** `id` of the `<form>`, for an external submit button. */
|
|
20
|
+
id?: string;
|
|
21
|
+
hideActions?: boolean;
|
|
22
|
+
onDirtyChange?: (isDirty: boolean) => void;
|
|
23
|
+
}
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NetworkRuleCatalog } from '../../types';
|
|
2
|
+
export interface ConditionRowProps {
|
|
3
|
+
index: number;
|
|
4
|
+
catalog: NetworkRuleCatalog;
|
|
5
|
+
onRemove: () => void;
|
|
6
|
+
canRemove?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
autoFocus?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function ConditionRow({ index, catalog, onRemove, canRemove, disabled, autoFocus, }: Readonly<ConditionRowProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Stack as C,TextField as b,MenuItem as y,IconButton as I}from"@mui/material";import{Delete as T}from"@mui/icons-material";import{useFormContext as W,useController as h,useWatch as O}from"react-hook-form";import{getKeyDef as S,isOperatorMulti as $,getOperatorLabel as j}from"../../utils/catalog.mjs";import{ConditionValuesInput as q}from"./ConditionValuesInput.mjs";import{jsxs as K,jsx as t}from"react/jsx-runtime";function M({index:o,catalog:a,onRemove:k,canRemove:D=!0,disabled:n=!1,autoFocus:R}){var v,p,g;const{control:d,setValue:u,formState:w}=W(),i=h({control:d,name:`conditions.${o}.key`}),l=h({control:d,name:`conditions.${o}.operator`}),m=h({control:d,name:`conditions.${o}.values`}),c=O({control:d,name:`conditions.${o}.values`})??[],s=S(a,i.field.value),V=s?.operators??[],B=$(a,l.field.value),f=w.isSubmitted,F=e=>{var r;i.field.onChange(e);const x=((r=S(a,e))==null?void 0:r.operators)??[];u(`conditions.${o}.operator`,x.length===1?x[0]:"",{shouldDirty:!0,shouldValidate:f}),u(`conditions.${o}.values`,[],{shouldDirty:!0,shouldValidate:f})};return K(C,{direction:{xs:"column",md:"row"},spacing:1.5,alignItems:"flex-start",children:[t(b,{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:n,autoFocus:R,error:i.fieldState.error!==void 0,helperText:(v=i.fieldState.error)==null?void 0:v.message,sx:{minWidth:{md:200},width:{xs:"100%",md:"auto"}},children:a.keys.map(e=>t(y,{value:e.key,children:e.label},e.key))}),t(b,{select:!0,required:!0,label:"Operator",value:l.field.value,onChange:e=>{const r=e.target.value;l.field.onChange(r),!$(a,r)&&c.length>1&&u(`conditions.${o}.values`,c.slice(0,1),{shouldDirty:!0,shouldValidate:f})},onBlur:l.field.onBlur,inputRef:l.field.ref,disabled:n||s===void 0,error:l.fieldState.error!==void 0,helperText:(p=l.fieldState.error)==null?void 0:p.message,sx:{minWidth:{md:180},width:{xs:"100%",md:"auto"}},children:V.map(e=>t(y,{value:e,children:j(a,e)},e))}),t(C,{flex:1,width:"100%",minWidth:0,children:t(q,{keyDef:s,multi:B,values:c,onChange:e=>{m.field.onChange(e)},disabled:n||l.field.value==="",error:m.fieldState.error!==void 0,helperText:(g=m.fieldState.error)==null?void 0:g.message})}),t(I,{"aria-label":`Remove condition ${o+1}`,color:"error",onClick:k,disabled:n||!D,sx:{mt:{md:1}},children:t(T,{})})]})}export{M as ConditionRow};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NetworkRuleKeyDef } from '../../types';
|
|
2
|
+
export interface ConditionValuesInputProps {
|
|
3
|
+
/** Undefined until a key is chosen. */
|
|
4
|
+
keyDef: NetworkRuleKeyDef | undefined;
|
|
5
|
+
multi: boolean;
|
|
6
|
+
values: string[];
|
|
7
|
+
onChange: (values: string[]) => void;
|
|
8
|
+
error?: boolean;
|
|
9
|
+
helperText?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Pick-list, remote search or free text, by the shape of the key's `values`. */
|
|
13
|
+
export declare function ConditionValuesInput({ keyDef, multi, values, onChange, error, helperText, disabled, }: Readonly<ConditionValuesInputProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{TextField as u}from"@mui/material";import{hasInlineOptions as m,hasRemoteSource as p}from"../../utils/catalog.mjs";import{InlineValuesInput as d}from"./values/InlineValuesInput.mjs";import{RemoteValuesInput as h}from"./values/RemoteValuesInput.mjs";import{TextValuesInput as f}from"./values/TextValuesInput.mjs";import{jsx as r}from"react/jsx-runtime";function b({keyDef:e,multi:l,values:o,onChange:s,error:t,helperText:n,disabled:i}){const a=l?"Values":"Value";return e?m(e)?r(d,{options:e.values.options,values:o,onChange:s,multi:l,label:a,error:t,helperText:n,disabled:i}):p(e)?r(h,{keyDef:e,values:o,onChange:s,multi:l,label:a,error:t,helperText:n,disabled:i}):r(f,{values:o,onChange:s,multi:l,label:a,error:t,helperText:n,disabled:i}):r(u,{fullWidth:!0,disabled:!0,label:a,placeholder:"Select a key first",InputLabelProps:{shrink:!0}})}export{b as ConditionValuesInput};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NetworkRuleCatalog } from '../../types';
|
|
2
|
+
export interface ConditionsFieldProps {
|
|
3
|
+
catalog: NetworkRuleCatalog;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
focusIndex?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function ConditionsField({ catalog, disabled, focusIndex, }: Readonly<ConditionsFieldProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface DateFieldProps {
|
|
2
|
+
label: string;
|
|
3
|
+
/** `YYYY-MM-DD` or null. */
|
|
4
|
+
value: string | null;
|
|
5
|
+
onChange: (value: string | null) => void;
|
|
6
|
+
onBlur?: () => void;
|
|
7
|
+
error?: boolean;
|
|
8
|
+
helperText?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
minDate?: Date;
|
|
12
|
+
maxDate?: Date;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
/** CSP nonce for the inline style tag; defaults to `<meta property="csp-nonce">`. */
|
|
16
|
+
nonce?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Calendar-day picker for a rule date. */
|
|
19
|
+
export declare function DateField({ label, value, onChange, onBlur, error, helperText, disabled, required, minDate, maxDate, placeholder, name, nonce: nonceProp, }: Readonly<DateFieldProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";import{useMemo as p,forwardRef as w}from"react";import{Box as T,TextField as g,InputAdornment as M,IconButton as P}from"@mui/material";import{Close as Y,CalendarToday as v}from"@mui/icons-material";import d from"../../../../node_modules/react-datepicker/dist/es/index.mjs";import{reactDatepickerCss as F}from"../../../../styles/lib/react-datepicker.mjs";import{ruleDateToDay as I,dayToRuleDate as z}from"../../utils/date.mjs";import{jsxs as m,jsx as e}from"react/jsx-runtime";const A=d.default??d,u="network-rules-date-popper",k=w(function({onClear:a,InputProps:r,disabled:t,...n},l){return e(g,{...n,disabled:t,inputRef:l,fullWidth:!0,InputProps:{...r,endAdornment:m(M,{position:"end",children:[a&&!t&&e(P,{size:"small","aria-label":"Clear date",onClick:s=>{s.stopPropagation(),a()},children:e(Y,{fontSize:"small"})}),e(v,{fontSize:"small",color:"action"})]})}})});function B({label:a,value:r,onChange:t,onBlur:n,error:l,helperText:s,disabled:c,required:f,minDate:h,maxDate:y,placeholder:x="MM/DD/YYYY",name:D,nonce:i}){const C=p(()=>{var o;if(i)return i;if(!(typeof document>"u"))return((o=document.querySelector('meta[property="csp-nonce"]'))==null?void 0:o.getAttribute("content"))??void 0},[i]),b=p(()=>I(r),[r]);return m(T,{sx:{position:"relative",width:"100%",fontFamily:o=>o.typography.fontFamily},children:[e("style",{nonce:C,children:`${F}
|
|
2
|
+
.${u}{z-index:1500;}`}),e(A,{selected:b,autoComplete:"off",onChange:o=>{t(z(o))},onBlur:n,dateFormat:"MM/dd/yyyy",placeholderText:x,showPopperArrow:!1,showYearDropdown:!0,showMonthDropdown:!0,scrollableYearDropdown:!1,popperClassName:u,popperProps:{strategy:"fixed"},popperPlacement:"bottom-start",minDate:h,maxDate:y,disabled:c,name:D,customInput:e(k,{label:a,error:l,helperText:s,required:f,onClear:r!==null?()=>t(null):void 0})})]})}export{B as DateField};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface NotesFieldProps {
|
|
2
|
+
presets?: readonly string[];
|
|
3
|
+
/** When set, a typed note that is not a preset offers "Add … as a preset". */
|
|
4
|
+
onCreatePreset?: (value: string) => void | Promise<void>;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
helperText?: string;
|
|
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
|
+
*/
|
|
12
|
+
export declare function NotesField({ presets, onCreatePreset, disabled, helperText, }: Readonly<NotesFieldProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{TextField as i,MenuItem as d}from"@mui/material";import{useFormContext as m,useController as f}from"react-hook-form";import{NetworkStatusChip as s}from"../../shared/NetworkStatusChip.mjs";import{jsx as t}from"react/jsx-runtime";function p({statuses:l,disabled:n}){var a;const{control:u}=m(),{field:r,fieldState:o}=f({control:u,name:"status"});return t(i,{select:!0,fullWidth:!0,required:!0,label:"Status",value:r.value,onChange:e=>{r.onChange(e.target.value)},onBlur:r.onBlur,inputRef:r.ref,disabled:n,error:o.error!==void 0,helperText:(a=o.error)==null?void 0:a.message,SelectProps:{renderValue:e=>t(s,{status:String(e)})},children:l.map(e=>t(d,{value:e,children:t(s,{status:e})},e))})}export{p as StatusField};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NetworkRuleOption } from '../../../types';
|
|
2
|
+
export interface InlineValuesInputProps {
|
|
3
|
+
options: readonly NetworkRuleOption[];
|
|
4
|
+
values: string[];
|
|
5
|
+
onChange: (values: string[]) => void;
|
|
6
|
+
multi: boolean;
|
|
7
|
+
label: string;
|
|
8
|
+
error?: boolean;
|
|
9
|
+
helperText?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function InlineValuesInput({ options, values, onChange, multi, label, error, helperText, disabled, }: Readonly<InlineValuesInputProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NetworkRuleKeyDef } from '../../../types';
|
|
2
|
+
export interface RemoteValuesInputProps {
|
|
3
|
+
keyDef: NetworkRuleKeyDef & {
|
|
4
|
+
values: {
|
|
5
|
+
source: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
values: string[];
|
|
9
|
+
onChange: (values: string[]) => void;
|
|
10
|
+
multi: boolean;
|
|
11
|
+
label: string;
|
|
12
|
+
error?: boolean;
|
|
13
|
+
helperText?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Paged search over the key's remote source; the next page loads when the list is scrolled near its end. */
|
|
17
|
+
export declare function RemoteValuesInput({ keyDef, values, onChange, multi, label, error, helperText, disabled, }: Readonly<RemoteValuesInputProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useState as h,Fragment as R}from"react";import{Button as M,TextField as O,Autocomplete as N,Chip as P,Checkbox as V,Box as z,CircularProgress as F}from"@mui/material";import{useNetworkRuleSourceSearch as H}from"../../../hooks/useNetworkRuleSourceSearch.mjs";import{useResolvedConditionOptions as A}from"../../../hooks/useResolvedConditionOptions.mjs";import{jsx as l,jsxs as B}from"react/jsx-runtime";const E=50;function $({keyDef:p,values:d,onChange:k,multi:u,label:m,error:y,helperText:S,disabled:j}){const[c,g]=h(""),[v,b]=h(!1),[w,I]=h([]),t=H(p.values.source,c,{enabled:v}),f=A(p,d,{known:w}),n=t.service,x=t.isLoading||t.isLoadingMore,L=e=>{const o=e.currentTarget;o.scrollTop+o.clientHeight>=o.scrollHeight-E&&t.loadMore()};let C=c.trim()?"No matches":"Type to search";return t.error&&(C=l(M,{size:"small",onClick:t.retry,children:"Search failed. Retry"})),t.isSupported?l(N,{multiple:!0,open:v,onOpen:()=>{b(!0)},onClose:()=>{b(!1)},options:t.options,value:f.options,loading:x||f.isLoading,ListboxProps:{onScroll:L},popupIcon:x?l(z,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center"},children:l(F,{color:"inherit",size:18})}):void 0,disabled:j,limitTags:4,disableCloseOnSelect:u,filterOptions:e=>e,inputValue:c,onInputChange:(e,o,r)=>{r!=="reset"&&g(o)},getOptionLabel:e=>e.label,isOptionEqualToValue:(e,o)=>e.value===o.value,onChange:(e,o)=>{I(s=>{const i=new Map(s.map(a=>[a.value,a]));for(const a of o)i.set(a.value,a);return[...i.values()]});const r=o.map(s=>s.value);k(u?r:r.slice(-1)),g("")},noOptionsText:C,renderOption:(e,o,{selected:r})=>{const{key:s,...i}=e;return B("li",{...i,children:[u&&l(V,{checked:r,sx:{mr:1}}),n!=null&&n.renderOption?n.renderOption(o):o.label]},s)},renderTags:(e,o)=>e.map((r,s)=>{const{key:i,...a}=o({index:s}),T={...a,label:r.label};return l(R,{children:n!=null&&n.renderChip?n.renderChip(r,T):l(P,{...T})},i)}),renderInput:e=>l(O,{...e,label:m,placeholder:d.length===0?n?.searchPlaceholder??"Type to search\u2026":void 0,error:y,helperText:S})}):l(O,{fullWidth:!0,disabled:!0,label:m,value:d.join(", "),error:!0,helperText:`No data source is registered for "${p.values.source}"`})}export{$ as RemoteValuesInput};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface TextValuesInputProps {
|
|
2
|
+
values: string[];
|
|
3
|
+
onChange: (values: string[]) => void;
|
|
4
|
+
multi: boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
helperText?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Free-text chips; Enter or blur adds the typed value. */
|
|
12
|
+
export declare function TextValuesInput({ values, onChange, multi, label, error, helperText, disabled, placeholder, }: Readonly<TextValuesInputProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useState as c}from"react";import{Autocomplete as f,TextField as x}from"@mui/material";import{dedupeValues as g}from"../../../utils/condition.mjs";import{jsx as n}from"react/jsx-runtime";function T({values:r,onChange:p,multi:s,label:u,error:i,helperText:m,disabled:d,placeholder:h="Type a value and press Enter"}){const[l,a]=c(""),o=t=>{const e=g(t);p(s?e:e.slice(-1))};return n(f,{multiple:!0,freeSolo:!0,options:[],value:r,inputValue:l,disabled:d,limitTags:4,onInputChange:(t,e)=>{a(e)},onChange:(t,e)=>{o(e),a("")},onBlur:()=>{l.trim()&&(o([...r,l]),a(""))},renderInput:t=>n(x,{...t,label:u,placeholder:r.length===0?h:void 0,error:i,helperText:m})})}export{T as TextValuesInput};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const networkRuleConditionFormSchema: z.ZodObject<{
|
|
3
|
+
key: z.ZodString;
|
|
4
|
+
operator: z.ZodString;
|
|
5
|
+
values: z.ZodArray<z.ZodString, "many">;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
key: string;
|
|
8
|
+
operator: string;
|
|
9
|
+
values: string[];
|
|
10
|
+
}, {
|
|
11
|
+
key: string;
|
|
12
|
+
operator: string;
|
|
13
|
+
values: string[];
|
|
14
|
+
}>;
|
|
15
|
+
export declare const networkRuleFormSchema: z.ZodEffects<z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
status: z.ZodString;
|
|
18
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
19
|
+
enabled: z.ZodBoolean;
|
|
20
|
+
startDate: z.ZodNullable<z.ZodString>;
|
|
21
|
+
endDate: z.ZodNullable<z.ZodString>;
|
|
22
|
+
conditions: z.ZodArray<z.ZodObject<{
|
|
23
|
+
key: z.ZodString;
|
|
24
|
+
operator: z.ZodString;
|
|
25
|
+
values: z.ZodArray<z.ZodString, "many">;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
key: string;
|
|
28
|
+
operator: string;
|
|
29
|
+
values: string[];
|
|
30
|
+
}, {
|
|
31
|
+
key: string;
|
|
32
|
+
operator: string;
|
|
33
|
+
values: string[];
|
|
34
|
+
}>, "many">;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
name: string;
|
|
37
|
+
status: string;
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
startDate: string | null;
|
|
40
|
+
endDate: string | null;
|
|
41
|
+
notes: string | null;
|
|
42
|
+
conditions: {
|
|
43
|
+
key: string;
|
|
44
|
+
operator: string;
|
|
45
|
+
values: string[];
|
|
46
|
+
}[];
|
|
47
|
+
}, {
|
|
48
|
+
name: string;
|
|
49
|
+
status: string;
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
startDate: string | null;
|
|
52
|
+
endDate: string | null;
|
|
53
|
+
notes: string | null;
|
|
54
|
+
conditions: {
|
|
55
|
+
key: string;
|
|
56
|
+
operator: string;
|
|
57
|
+
values: string[];
|
|
58
|
+
}[];
|
|
59
|
+
}>, {
|
|
60
|
+
name: string;
|
|
61
|
+
status: string;
|
|
62
|
+
enabled: boolean;
|
|
63
|
+
startDate: string | null;
|
|
64
|
+
endDate: string | null;
|
|
65
|
+
notes: string | null;
|
|
66
|
+
conditions: {
|
|
67
|
+
key: string;
|
|
68
|
+
operator: string;
|
|
69
|
+
values: string[];
|
|
70
|
+
}[];
|
|
71
|
+
}, {
|
|
72
|
+
name: string;
|
|
73
|
+
status: string;
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
startDate: string | null;
|
|
76
|
+
endDate: string | null;
|
|
77
|
+
notes: string | null;
|
|
78
|
+
conditions: {
|
|
79
|
+
key: string;
|
|
80
|
+
operator: string;
|
|
81
|
+
values: string[];
|
|
82
|
+
}[];
|
|
83
|
+
}>;
|
|
84
|
+
export type NetworkRuleFormSchema = z.infer<typeof networkRuleFormSchema>;
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useState as f,useEffect as t}from"react";function u(e,s){const[o,r]=f(s);return t(()=>{e&&r(s)},[e,s]),e?s:o}export{u as useHeldWhileClosed};
|