wcz-layout
Version:
3,389 lines • 97.3 kB
JavaScript
import { a as foldForSearch, o as getFieldStatus } from "./utils-obBGIuT3.mjs";
import { C as useHeaderContext, S as useCellContext, T as useDialogs, _ as Pagination, b as layoutTableFeatures, c as hasColumnLabel, d as moveColumn, i as classNames, l as layoutTableClasses, m as shortcutLabel, n as formatValue, o as columnFlex, s as columnLabel, t as AggregatedCell, v as cellContext, w as useTableContext, x as tableContext, y as headerContext } from "./AggregatedCell-3CIdlmt6.mjs";
import { c } from "react/compiler-runtime";
import { Autocomplete, Badge, Box, Button, Checkbox, Divider, FormControl, FormControlLabel, FormHelperText, FormLabel, IconButton, InputAdornment, InputLabel, ListItemIcon, ListItemText, Menu, MenuItem, Popover, Radio, RadioGroup, Select, Skeleton, Slider, Stack, Switch, TableCell, TableRow, TableSortLabel, TextField, Tooltip, Typography, useTheme } from "@mui/material";
import { DatePicker, DateTimePicker, TimePicker } from "@mui/x-date-pickers";
import dayjs from "dayjs";
import { useEffect, useId, useRef, useState } from "react";
import { useTranslation, useTranslation as useTranslation$1 } from "react-i18next";
import ArrowBack from "@mui/icons-material/ArrowBack";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
import Close from "@mui/icons-material/Close";
import MoreVert from "@mui/icons-material/MoreVert";
import { useInView } from "react-intersection-observer";
import { useHotkey } from "@tanstack/react-hotkeys";
import { FlexRender, Subscribe, constructFilterFn, createTableHook, filterFn_arrHas, filterFn_empty, filterFn_endsWith, filterFn_equals, filterFn_equalsString, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inDateRange, filterFn_inNumberRange, filterFn_includesString, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_notEmpty, filterFn_startsWith } from "@tanstack/react-table";
import { createFormHook, createFormHookContexts } from "@tanstack/react-form";
import { NumericFormat } from "react-number-format";
import KeyboardArrowDown from "@mui/icons-material/KeyboardArrowDown";
import KeyboardArrowRight from "@mui/icons-material/KeyboardArrowRight";
import PushPin from "@mui/icons-material/PushPin";
import Check from "@mui/icons-material/Check";
import localizedFormat from "dayjs/plugin/localizedFormat";
import ArrowDownward from "@mui/icons-material/ArrowDownward";
import ArrowForward from "@mui/icons-material/ArrowForward";
import ArrowUpward from "@mui/icons-material/ArrowUpward";
import Clear from "@mui/icons-material/Clear";
import VisibilityOff from "@mui/icons-material/VisibilityOff";
import Workspaces from "@mui/icons-material/Workspaces";
import ViewColumn from "@mui/icons-material/ViewColumn";
import Add from "@mui/icons-material/Add";
import DeleteForever from "@mui/icons-material/DeleteForever";
import FilterList from "@mui/icons-material/FilterList";
import { useDebouncedCallback } from "@tanstack/react-pacer/debouncer";
import Search from "@mui/icons-material/Search";
import { flushSync } from "react-dom";
// src/components/form/FormAutocomplete.tsx
const FormAutocomplete = (t0) => {
const $ = c(23);
if ($[0] !== "7338e11c7f4d0769336a0666323c7b023a45e63a1c42cdb4d71222e9ba6b3961") {
for (let $i = 0; $i < 23; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "7338e11c7f4d0769336a0666323c7b023a45e63a1c42cdb4d71222e9ba6b3961";
}
let autocompleteProps;
let textFieldProps;
if ($[1] !== t0) {
({textFieldProps, ...autocompleteProps} = t0);
$[1] = t0;
$[2] = autocompleteProps;
$[3] = textFieldProps;
} else {
autocompleteProps = $[2];
textFieldProps = $[3];
}
const field = useFieldContext();
let t1;
if ($[4] !== field) {
t1 = getFieldStatus(field);
$[4] = field;
$[5] = t1;
} else t1 = $[5];
const { isTouched, hasError, helperText } = t1;
let t2;
let t3;
if ($[6] !== autocompleteProps.freeSolo || $[7] !== field) {
t2 = (_, value) => !autocompleteProps.freeSolo && field.handleChange(value);
t3 = (__0, value_0, reason) => reason !== "reset" && autocompleteProps.freeSolo && field.handleChange(value_0);
$[6] = autocompleteProps.freeSolo;
$[7] = field;
$[8] = t2;
$[9] = t3;
} else {
t2 = $[8];
t3 = $[9];
}
let t4;
if ($[10] !== field.name || $[11] !== hasError || $[12] !== helperText || $[13] !== isTouched || $[14] !== textFieldProps) {
t4 = (parameters) => /* @__PURE__ */ jsx(TextField, {
...parameters,
name: field.name,
error: isTouched && hasError,
helperText: isTouched && helperText,
...textFieldProps
});
$[10] = field.name;
$[11] = hasError;
$[12] = helperText;
$[13] = isTouched;
$[14] = textFieldProps;
$[15] = t4;
} else t4 = $[15];
let t5;
if ($[16] !== autocompleteProps || $[17] !== field.handleBlur || $[18] !== field.state.value || $[19] !== t2 || $[20] !== t3 || $[21] !== t4) {
t5 = /* @__PURE__ */ jsx(Autocomplete, {
value: field.state.value,
onChange: t2,
onInputChange: t3,
onBlur: field.handleBlur,
...autocompleteProps,
renderInput: t4
});
$[16] = autocompleteProps;
$[17] = field.handleBlur;
$[18] = field.state.value;
$[19] = t2;
$[20] = t3;
$[21] = t4;
$[22] = t5;
} else t5 = $[22];
return t5;
};
// src/components/form/FormCheckbox.tsx
const FormCheckbox = (t0) => {
const $ = c(29);
if ($[0] !== "b52e840cfa41500a446e044d8a0b97ab30fdcd357b533c9d8b35a26c24a7c45c") {
for (let $i = 0; $i < 29; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "b52e840cfa41500a446e044d8a0b97ab30fdcd357b533c9d8b35a26c24a7c45c";
}
let label;
let props;
if ($[1] !== t0) {
({label, ...props} = t0);
$[1] = t0;
$[2] = label;
$[3] = props;
} else {
label = $[2];
props = $[3];
}
const field = useFieldContext();
let t1;
if ($[4] !== field) {
t1 = getFieldStatus(field);
$[4] = field;
$[5] = t1;
} else t1 = $[5];
const { isTouched, hasError, helperText } = t1;
const showError = isTouched && hasError;
const helperId = useId();
const t2 = field.name;
const t3 = Boolean(field.state.value);
let t4;
if ($[6] !== field) {
t4 = (event) => field.handleChange(event.target.checked);
$[6] = field;
$[7] = t4;
} else t4 = $[7];
const t5 = showError || void 0;
const t6 = showError ? helperId : void 0;
let t7;
if ($[8] !== t5 || $[9] !== t6) {
t7 = { input: {
"aria-invalid": t5,
"aria-describedby": t6
} };
$[8] = t5;
$[9] = t6;
$[10] = t7;
} else t7 = $[10];
let t8;
if ($[11] !== field.handleBlur || $[12] !== field.name || $[13] !== props || $[14] !== t3 || $[15] !== t4 || $[16] !== t7) {
t8 = /* @__PURE__ */ jsx(Checkbox, {
name: t2,
checked: t3,
onChange: t4,
onBlur: field.handleBlur,
slotProps: t7,
...props
});
$[11] = field.handleBlur;
$[12] = field.name;
$[13] = props;
$[14] = t3;
$[15] = t4;
$[16] = t7;
$[17] = t8;
} else t8 = $[17];
const t9 = label ?? "";
let t10;
if ($[18] !== t8 || $[19] !== t9) {
t10 = /* @__PURE__ */ jsx(FormControlLabel, {
control: t8,
label: t9
});
$[18] = t8;
$[19] = t9;
$[20] = t10;
} else t10 = $[20];
let t11;
if ($[21] !== helperId || $[22] !== helperText || $[23] !== showError) {
t11 = showError && /* @__PURE__ */ jsx(FormHelperText, {
id: helperId,
children: helperText
});
$[21] = helperId;
$[22] = helperText;
$[23] = showError;
$[24] = t11;
} else t11 = $[24];
let t12;
if ($[25] !== showError || $[26] !== t10 || $[27] !== t11) {
t12 = /* @__PURE__ */ jsxs(FormControl, {
error: showError,
children: [t10, t11]
});
$[25] = showError;
$[26] = t10;
$[27] = t11;
$[28] = t12;
} else t12 = $[28];
return t12;
};
// src/components/form/FormDatePicker.tsx
const FormDatePicker = (props) => {
const $ = c(19);
if ($[0] !== "d6b4f9d4359d8db9532e9e4c8118f40e659697fbf91270269f75e8a78ff20e99") {
for (let $i = 0; $i < 19; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "d6b4f9d4359d8db9532e9e4c8118f40e659697fbf91270269f75e8a78ff20e99";
}
const field = useFieldContext();
let t0;
if ($[1] !== field) {
t0 = getFieldStatus(field);
$[1] = field;
$[2] = t0;
} else t0 = $[2];
const { isTouched, hasError, helperText } = t0;
let t1;
if ($[3] !== field) {
t1 = (value) => field.handleChange(value);
$[3] = field;
$[4] = t1;
} else t1 = $[4];
const t2 = isTouched && hasError;
const t3 = isTouched && helperText;
let t4;
if ($[5] !== field.handleBlur || $[6] !== props.textFieldProps || $[7] !== t2 || $[8] !== t3) {
t4 = {
onBlur: field.handleBlur,
error: t2,
helperText: t3,
...props.textFieldProps
};
$[5] = field.handleBlur;
$[6] = props.textFieldProps;
$[7] = t2;
$[8] = t3;
$[9] = t4;
} else t4 = $[9];
let t5;
if ($[10] !== props.slotProps || $[11] !== t4) {
t5 = {
textField: t4,
...props.slotProps
};
$[10] = props.slotProps;
$[11] = t4;
$[12] = t5;
} else t5 = $[12];
let t6;
if ($[13] !== field.name || $[14] !== field.state.value || $[15] !== props || $[16] !== t1 || $[17] !== t5) {
t6 = /* @__PURE__ */ jsx(DatePicker, {
name: field.name,
value: field.state.value,
onChange: t1,
slotProps: t5,
...props
});
$[13] = field.name;
$[14] = field.state.value;
$[15] = props;
$[16] = t1;
$[17] = t5;
$[18] = t6;
} else t6 = $[18];
return t6;
};
// src/components/form/FormTimePicker.tsx
const FormTimePicker = (props) => {
const $ = c(19);
if ($[0] !== "744d0fad962078bce5533e19cc937c08ba2334572d7ca10fb52c0bf12490ac64") {
for (let $i = 0; $i < 19; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "744d0fad962078bce5533e19cc937c08ba2334572d7ca10fb52c0bf12490ac64";
}
const field = useFieldContext();
let t0;
if ($[1] !== field) {
t0 = getFieldStatus(field);
$[1] = field;
$[2] = t0;
} else t0 = $[2];
const { isTouched, hasError, helperText } = t0;
let t1;
if ($[3] !== field) {
t1 = (value) => field.handleChange(value);
$[3] = field;
$[4] = t1;
} else t1 = $[4];
const t2 = isTouched && hasError;
const t3 = isTouched && helperText;
let t4;
if ($[5] !== field.handleBlur || $[6] !== props.textFieldProps || $[7] !== t2 || $[8] !== t3) {
t4 = {
onBlur: field.handleBlur,
error: t2,
helperText: t3,
...props.textFieldProps
};
$[5] = field.handleBlur;
$[6] = props.textFieldProps;
$[7] = t2;
$[8] = t3;
$[9] = t4;
} else t4 = $[9];
let t5;
if ($[10] !== props.slotProps || $[11] !== t4) {
t5 = {
textField: t4,
...props.slotProps
};
$[10] = props.slotProps;
$[11] = t4;
$[12] = t5;
} else t5 = $[12];
let t6;
if ($[13] !== field.name || $[14] !== field.state.value || $[15] !== props || $[16] !== t1 || $[17] !== t5) {
t6 = /* @__PURE__ */ jsx(TimePicker, {
name: field.name,
value: field.state.value,
onChange: t1,
slotProps: t5,
...props
});
$[13] = field.name;
$[14] = field.state.value;
$[15] = props;
$[16] = t1;
$[17] = t5;
$[18] = t6;
} else t6 = $[18];
return t6;
};
// src/components/form/FormDateTimePicker.tsx
const FormDateTimePicker = (props) => {
const $ = c(19);
if ($[0] !== "e295cbec254d6f03cb34331cb6a468970ec739fb6b1fd8f4549e43d22aae5dae") {
for (let $i = 0; $i < 19; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "e295cbec254d6f03cb34331cb6a468970ec739fb6b1fd8f4549e43d22aae5dae";
}
const field = useFieldContext();
let t0;
if ($[1] !== field) {
t0 = getFieldStatus(field);
$[1] = field;
$[2] = t0;
} else t0 = $[2];
const { isTouched, hasError, helperText } = t0;
let t1;
if ($[3] !== field) {
t1 = (value) => field.handleChange(value);
$[3] = field;
$[4] = t1;
} else t1 = $[4];
const t2 = isTouched && hasError;
const t3 = isTouched && helperText;
let t4;
if ($[5] !== field.handleBlur || $[6] !== props.textFieldProps || $[7] !== t2 || $[8] !== t3) {
t4 = {
onBlur: field.handleBlur,
error: t2,
helperText: t3,
...props.textFieldProps
};
$[5] = field.handleBlur;
$[6] = props.textFieldProps;
$[7] = t2;
$[8] = t3;
$[9] = t4;
} else t4 = $[9];
let t5;
if ($[10] !== props.slotProps || $[11] !== t4) {
t5 = {
textField: t4,
...props.slotProps
};
$[10] = props.slotProps;
$[11] = t4;
$[12] = t5;
} else t5 = $[12];
let t6;
if ($[13] !== field.name || $[14] !== field.state.value || $[15] !== props || $[16] !== t1 || $[17] !== t5) {
t6 = /* @__PURE__ */ jsx(DateTimePicker, {
name: field.name,
value: field.state.value,
onChange: t1,
slotProps: t5,
...props
});
$[13] = field.name;
$[14] = field.state.value;
$[15] = props;
$[16] = t1;
$[17] = t5;
$[18] = t6;
} else t6 = $[18];
return t6;
};
// src/components/form/FormNumberField.tsx
const FormNumberField = (t0) => {
const $ = c(17);
if ($[0] !== "70985df8f0614c3af7e21139a4ca0a17290f110f3ba08bee8ad2ea22e94532c5") {
for (let $i = 0; $i < 17; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "70985df8f0614c3af7e21139a4ca0a17290f110f3ba08bee8ad2ea22e94532c5";
}
let options;
let props;
if ($[1] !== t0) {
({options, ...props} = t0);
$[1] = t0;
$[2] = options;
$[3] = props;
} else {
options = $[2];
props = $[3];
}
const field = useFieldContext();
let t1;
if ($[4] !== field) {
t1 = getFieldStatus(field);
$[4] = field;
$[5] = t1;
} else t1 = $[5];
const { isTouched, hasError, helperText } = t1;
const t2 = field.state.value ?? "";
let t3;
if ($[6] !== field) {
t3 = (t4) => {
const { floatValue } = t4;
return field.handleChange(floatValue);
};
$[6] = field;
$[7] = t3;
} else t3 = $[7];
const t4 = isTouched && hasError;
const t5 = isTouched && helperText;
let t6;
if ($[8] !== field.handleBlur || $[9] !== field.name || $[10] !== options || $[11] !== props || $[12] !== t2 || $[13] !== t3 || $[14] !== t4 || $[15] !== t5) {
t6 = /* @__PURE__ */ jsx(NumericFormat, {
customInput: TextField,
name: field.name,
value: t2,
onValueChange: t3,
onBlur: field.handleBlur,
error: t4,
helperText: t5,
...props,
...options
});
$[8] = field.handleBlur;
$[9] = field.name;
$[10] = options;
$[11] = props;
$[12] = t2;
$[13] = t3;
$[14] = t4;
$[15] = t5;
$[16] = t6;
} else t6 = $[16];
return t6;
};
// src/components/form/FormRadioGroup.tsx
const FormRadioGroup = (t0) => {
const $ = c(30);
if ($[0] !== "16c9a4c84e60144b586b49450150738a645900f659fbd5b1a25b6b376e240215") {
for (let $i = 0; $i < 30; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "16c9a4c84e60144b586b49450150738a645900f659fbd5b1a25b6b376e240215";
}
let label;
let options;
let props;
if ($[1] !== t0) {
({label, options, ...props} = t0);
$[1] = t0;
$[2] = label;
$[3] = options;
$[4] = props;
} else {
label = $[2];
options = $[3];
props = $[4];
}
const field = useFieldContext();
let t1;
if ($[5] !== field) {
t1 = getFieldStatus(field);
$[5] = field;
$[6] = t1;
} else t1 = $[6];
const { isTouched, hasError, helperText } = t1;
const showError = isTouched && hasError;
const helperId = useId();
let t2;
if ($[7] !== label) {
t2 = label && /* @__PURE__ */ jsx(FormLabel, {
component: "legend",
children: label
});
$[7] = label;
$[8] = t2;
} else t2 = $[8];
const t3 = field.name;
const t4 = field.state.value ?? "";
let t5;
if ($[9] !== field) {
t5 = (event) => field.handleChange(event.target.value);
$[9] = field;
$[10] = t5;
} else t5 = $[10];
const t6 = field.handleBlur;
const t7 = showError ? helperId : void 0;
let t8;
if ($[11] !== options) {
t8 = options.map(_temp$8);
$[11] = options;
$[12] = t8;
} else t8 = $[12];
let t9;
if ($[13] !== field.handleBlur || $[14] !== field.name || $[15] !== props || $[16] !== t4 || $[17] !== t5 || $[18] !== t7 || $[19] !== t8) {
t9 = /* @__PURE__ */ jsx(RadioGroup, {
name: t3,
value: t4,
onChange: t5,
onBlur: t6,
"aria-describedby": t7,
...props,
children: t8
});
$[13] = field.handleBlur;
$[14] = field.name;
$[15] = props;
$[16] = t4;
$[17] = t5;
$[18] = t7;
$[19] = t8;
$[20] = t9;
} else t9 = $[20];
let t10;
if ($[21] !== helperId || $[22] !== helperText || $[23] !== showError) {
t10 = showError && /* @__PURE__ */ jsx(FormHelperText, {
id: helperId,
children: helperText
});
$[21] = helperId;
$[22] = helperText;
$[23] = showError;
$[24] = t10;
} else t10 = $[24];
let t11;
if ($[25] !== showError || $[26] !== t10 || $[27] !== t2 || $[28] !== t9) {
t11 = /* @__PURE__ */ jsxs(FormControl, {
component: "fieldset",
error: showError,
children: [
t2,
t9,
t10
]
});
$[25] = showError;
$[26] = t10;
$[27] = t2;
$[28] = t9;
$[29] = t11;
} else t11 = $[29];
return t11;
};
function _temp$8(option) {
return /* @__PURE__ */ jsx(FormControlLabel, {
value: option.value,
control: /* @__PURE__ */ jsx(Radio, {}),
label: option.label
}, option.value);
}
// src/components/form/FormSlider.tsx
const FormSlider = (t0) => {
const $ = c(26);
if ($[0] !== "796ce6f2474864029c96eb0044cece8a7b539b0d307a77b67fff20edb223d90c") {
for (let $i = 0; $i < 26; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "796ce6f2474864029c96eb0044cece8a7b539b0d307a77b67fff20edb223d90c";
}
let label;
let props;
if ($[1] !== t0) {
({label, ...props} = t0);
$[1] = t0;
$[2] = label;
$[3] = props;
} else {
label = $[2];
props = $[3];
}
const field = useFieldContext();
let t1;
if ($[4] !== field) {
t1 = getFieldStatus(field);
$[4] = field;
$[5] = t1;
} else t1 = $[5];
const { isTouched, hasError, helperText } = t1;
const showError = isTouched && hasError;
const labelId = useId();
let t2;
if ($[6] !== label || $[7] !== labelId) {
t2 = label && /* @__PURE__ */ jsx(FormLabel, {
id: labelId,
children: label
});
$[6] = label;
$[7] = labelId;
$[8] = t2;
} else t2 = $[8];
const t3 = field.state.value ?? 0;
let t4;
if ($[9] !== field) {
t4 = (_, value) => field.handleChange(Array.isArray(value) ? value[0] : value);
$[9] = field;
$[10] = t4;
} else t4 = $[10];
const t5 = label ? labelId : void 0;
let t6;
if ($[11] !== field.handleBlur || $[12] !== field.name || $[13] !== props || $[14] !== t3 || $[15] !== t4 || $[16] !== t5) {
t6 = /* @__PURE__ */ jsx(Slider, {
name: field.name,
value: t3,
onChange: t4,
onBlur: field.handleBlur,
"aria-labelledby": t5,
...props
});
$[11] = field.handleBlur;
$[12] = field.name;
$[13] = props;
$[14] = t3;
$[15] = t4;
$[16] = t5;
$[17] = t6;
} else t6 = $[17];
let t7;
if ($[18] !== helperText || $[19] !== showError) {
t7 = showError && /* @__PURE__ */ jsx(FormHelperText, { children: helperText });
$[18] = helperText;
$[19] = showError;
$[20] = t7;
} else t7 = $[20];
let t8;
if ($[21] !== showError || $[22] !== t2 || $[23] !== t6 || $[24] !== t7) {
t8 = /* @__PURE__ */ jsxs(FormControl, {
error: showError,
children: [
t2,
t6,
t7
]
});
$[21] = showError;
$[22] = t2;
$[23] = t6;
$[24] = t7;
$[25] = t8;
} else t8 = $[25];
return t8;
};
// src/components/form/FormSubmitButton.tsx
const FormSubmitButton = (props) => {
const $ = c(9);
if ($[0] !== "ca7a881dde9e618cbd00cee60a672649e290ccecc82384bdc56b544970349722") {
for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "ca7a881dde9e618cbd00cee60a672649e290ccecc82384bdc56b544970349722";
}
const form = useFormContext();
let t0;
if ($[1] !== form) {
t0 = async (event) => {
event.preventDefault();
event.stopPropagation();
await form.handleSubmit();
};
$[1] = form;
$[2] = t0;
} else t0 = $[2];
const handleClick = t0;
let t1;
if ($[3] !== handleClick || $[4] !== props) {
t1 = (isSubmitting) => /* @__PURE__ */ jsx(Button, {
loading: isSubmitting,
onClick: handleClick,
type: "submit",
...props
});
$[3] = handleClick;
$[4] = props;
$[5] = t1;
} else t1 = $[5];
let t2;
if ($[6] !== form.Subscribe || $[7] !== t1) {
t2 = /* @__PURE__ */ jsx(form.Subscribe, {
selector: _temp$7,
children: t1
});
$[6] = form.Subscribe;
$[7] = t1;
$[8] = t2;
} else t2 = $[8];
return t2;
};
function _temp$7(state) {
return state.isSubmitting;
}
// src/components/form/FormSwitch.tsx
const FormSwitch = (t0) => {
const $ = c(29);
if ($[0] !== "51529726c63de66e4a75023f96d6cfb0ef4919724538ea0ef64ffca8e2c3d2f7") {
for (let $i = 0; $i < 29; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "51529726c63de66e4a75023f96d6cfb0ef4919724538ea0ef64ffca8e2c3d2f7";
}
let label;
let props;
if ($[1] !== t0) {
({label, ...props} = t0);
$[1] = t0;
$[2] = label;
$[3] = props;
} else {
label = $[2];
props = $[3];
}
const field = useFieldContext();
let t1;
if ($[4] !== field) {
t1 = getFieldStatus(field);
$[4] = field;
$[5] = t1;
} else t1 = $[5];
const { isTouched, hasError, helperText } = t1;
const showError = isTouched && hasError;
const helperId = useId();
const t2 = field.name;
const t3 = Boolean(field.state.value);
let t4;
if ($[6] !== field) {
t4 = (event) => field.handleChange(event.target.checked);
$[6] = field;
$[7] = t4;
} else t4 = $[7];
const t5 = showError || void 0;
const t6 = showError ? helperId : void 0;
let t7;
if ($[8] !== t5 || $[9] !== t6) {
t7 = { input: {
"aria-invalid": t5,
"aria-describedby": t6
} };
$[8] = t5;
$[9] = t6;
$[10] = t7;
} else t7 = $[10];
let t8;
if ($[11] !== field.handleBlur || $[12] !== field.name || $[13] !== props || $[14] !== t3 || $[15] !== t4 || $[16] !== t7) {
t8 = /* @__PURE__ */ jsx(Switch, {
name: t2,
checked: t3,
onChange: t4,
onBlur: field.handleBlur,
slotProps: t7,
...props
});
$[11] = field.handleBlur;
$[12] = field.name;
$[13] = props;
$[14] = t3;
$[15] = t4;
$[16] = t7;
$[17] = t8;
} else t8 = $[17];
const t9 = label ?? "";
let t10;
if ($[18] !== t8 || $[19] !== t9) {
t10 = /* @__PURE__ */ jsx(FormControlLabel, {
control: t8,
label: t9
});
$[18] = t8;
$[19] = t9;
$[20] = t10;
} else t10 = $[20];
let t11;
if ($[21] !== helperId || $[22] !== helperText || $[23] !== showError) {
t11 = showError && /* @__PURE__ */ jsx(FormHelperText, {
id: helperId,
children: helperText
});
$[21] = helperId;
$[22] = helperText;
$[23] = showError;
$[24] = t11;
} else t11 = $[24];
let t12;
if ($[25] !== showError || $[26] !== t10 || $[27] !== t11) {
t12 = /* @__PURE__ */ jsxs(FormControl, {
error: showError,
children: [t10, t11]
});
$[25] = showError;
$[26] = t10;
$[27] = t11;
$[28] = t12;
} else t12 = $[28];
return t12;
};
// src/components/form/FormTextField.tsx
const FormTextField = (props) => {
const $ = c(13);
if ($[0] !== "ebeffaf029828deadb4a4a1c7a79e6898adf43d26161417a887df4db360375ef") {
for (let $i = 0; $i < 13; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "ebeffaf029828deadb4a4a1c7a79e6898adf43d26161417a887df4db360375ef";
}
const field = useFieldContext();
let t0;
if ($[1] !== field) {
t0 = getFieldStatus(field);
$[1] = field;
$[2] = t0;
} else t0 = $[2];
const { isTouched, hasError, helperText } = t0;
const t1 = field.state.value ?? "";
let t2;
if ($[3] !== field) {
t2 = (event) => field.handleChange(event.target.value);
$[3] = field;
$[4] = t2;
} else t2 = $[4];
const t3 = isTouched && hasError;
const t4 = isTouched && helperText;
let t5;
if ($[5] !== field.handleBlur || $[6] !== field.name || $[7] !== props || $[8] !== t1 || $[9] !== t2 || $[10] !== t3 || $[11] !== t4) {
t5 = /* @__PURE__ */ jsx(TextField, {
name: field.name,
value: t1,
onChange: t2,
onBlur: field.handleBlur,
error: t3,
helperText: t4,
...props
});
$[5] = field.handleBlur;
$[6] = field.name;
$[7] = props;
$[8] = t1;
$[9] = t2;
$[10] = t3;
$[11] = t4;
$[12] = t5;
} else t5 = $[12];
return t5;
};
// src/hooks/useForm.ts
const { fieldContext, useFieldContext, formContext, useFormContext } = createFormHookContexts();
const { useAppForm: useLayoutForm, withForm: withLayoutForm } = createFormHook({
fieldComponents: {
TextField: FormTextField,
NumberField: FormNumberField,
Autocomplete: FormAutocomplete,
Checkbox: FormCheckbox,
Switch: FormSwitch,
RadioGroup: FormRadioGroup,
Slider: FormSlider,
DatePicker: FormDatePicker,
TimePicker: FormTimePicker,
DateTimePicker: FormDateTimePicker
},
formComponents: { SubmitButton: FormSubmitButton },
fieldContext,
formContext
});
// src/hooks/useScanDetection.ts
const useScanDetection = ({ timeToEvaluate = 100, averageWaitTime = 50, startCharacter = [], endCharacter = ["Enter", "Escape"], onComplete, onError, minLength = 1, ignoreIfFocusOn, stopPropagation = false, preventDefault = false, container, enabled = true }) => {
const buffer = useRef([]);
const timeout = useRef(void 0);
const clearBuffer = () => {
buffer.current = [];
};
const evaluateBuffer = () => {
clearTimeout(timeout.current);
const avg = buffer.current.map(({ time }, k, arr) => k > 0 ? time - arr[k - 1].time : 0).slice(1).reduce((total, delta) => total + delta, 0) / (buffer.current.length - 1);
const code = buffer.current.slice(startCharacter.length > 0 ? 1 : 0).filter(({ char }) => char !== "Shift" && char !== "Tab").map(({ char: char_0 }) => char_0).join("");
if (avg <= averageWaitTime && buffer.current.slice(startCharacter.length > 0 ? 1 : 0).length >= minLength) onComplete(code);
else if (avg <= averageWaitTime) onError?.(code);
clearBuffer();
};
const onKeyDown = (event) => {
if (!enabled) return;
if (event.currentTarget !== ignoreIfFocusOn) {
if (endCharacter.includes(event.key)) evaluateBuffer();
if (buffer.current.length > 0 || startCharacter.includes(event.key) || startCharacter.length === 0) {
clearTimeout(timeout.current);
timeout.current = setTimeout(evaluateBuffer, timeToEvaluate);
buffer.current.push({
time: performance.now(),
char: event.key
});
}
}
if (stopPropagation) event.stopPropagation();
if (preventDefault) event.preventDefault();
};
const onKeyDownRef = useRef(onKeyDown);
onKeyDownRef.current = onKeyDown;
useEffect(() => {
return () => {
clearTimeout(timeout.current);
};
}, []);
useEffect(() => {
const target = container ?? document;
const listener = (event_0) => onKeyDownRef.current(event_0);
target.addEventListener("keydown", listener);
return () => {
target.removeEventListener("keydown", listener);
};
}, [container]);
};
// src/components/table/cells/features/ActionsCell.tsx
const ActionsCell = (t0) => {
const $ = c(9);
if ($[0] !== "46959594726e9a29c70abf62ee75ee54e0137e908154f594a92aa290e96cc70f") {
for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "46959594726e9a29c70abf62ee75ee54e0137e908154f594a92aa290e96cc70f";
}
const { actions } = t0;
const cell = useCellContext();
const { t } = useTranslation$1();
const [anchorEl, setAnchorEl] = useState(null);
let t1;
if ($[1] !== actions || $[2] !== anchorEl || $[3] !== cell || $[4] !== t) {
const buttons = actions.filter(_temp$6);
const menuItems = actions.filter(_temp2$2);
let t2;
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
t2 = { alignItems: "center" };
$[6] = t2;
} else t2 = $[6];
let t3;
if ($[7] !== cell) {
t3 = (action_1) => /* @__PURE__ */ jsx(Tooltip, {
title: action_1.label,
children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(IconButton, {
size: "small",
"aria-label": action_1.label,
disabled: action_1.disabled,
onClick: () => action_1.onClick(cell.row.original),
children: action_1.icon
}) })
}, action_1.label);
$[7] = cell;
$[8] = t3;
} else t3 = $[8];
t1 = /* @__PURE__ */ jsxs(Stack, {
className: layoutTableClasses.actionsCell,
direction: "row",
spacing: 1,
sx: t2,
onClick: _temp3$1,
onDoubleClick: _temp4,
children: [buttons.map(t3), menuItems.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Tooltip, {
title: t("Layout.Table.RowActions"),
children: /* @__PURE__ */ jsx(IconButton, {
size: "small",
"aria-label": "Row actions",
"aria-haspopup": "menu",
onClick: (event_1) => setAnchorEl(event_1.currentTarget),
children: /* @__PURE__ */ jsx(MoreVert, { fontSize: "small" })
})
}), /* @__PURE__ */ jsx(Menu, {
anchorEl,
open: !!anchorEl,
onClose: () => setAnchorEl(null),
children: menuItems.flatMap((action_2) => [...action_2.divider ? [/* @__PURE__ */ jsx(Divider, {}, `${action_2.label}-divider`)] : [], /* @__PURE__ */ jsxs(MenuItem, {
disabled: action_2.disabled,
onClick: () => {
action_2.onClick(cell.row.original);
setAnchorEl(null);
},
children: [action_2.icon && /* @__PURE__ */ jsx(ListItemIcon, { children: action_2.icon }), /* @__PURE__ */ jsx(ListItemText, { children: action_2.label })]
}, action_2.label)])
})] })]
});
$[1] = actions;
$[2] = anchorEl;
$[3] = cell;
$[4] = t;
$[5] = t1;
} else t1 = $[5];
return t1;
};
function _temp$6(action) {
return !action.showInMenu;
}
function _temp2$2(action_0) {
return action_0.showInMenu;
}
function _temp3$1(event) {
return event.stopPropagation();
}
function _temp4(event_0) {
return event_0.stopPropagation();
}
// src/components/table/cells/features/ExpandCell.tsx
const ExpandCell = () => {
const $ = c(6);
if ($[0] !== "5bf7fa154e2a61ce60692d60e635211e65622ff07c7695b4b5bdcbf9878672cd") {
for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "5bf7fa154e2a61ce60692d60e635211e65622ff07c7695b4b5bdcbf9878672cd";
}
const { row } = useCellContext();
let t0;
if ($[1] !== row) {
t0 = () => {
if (!row.getCanExpand()) return null;
const expanded = row.getIsExpanded();
return /* @__PURE__ */ jsx(IconButton, {
className: layoutTableClasses.expandButton,
size: "small",
onClick: (event) => {
event.stopPropagation();
row.toggleExpanded();
},
"aria-label": "Expand row",
"aria-expanded": expanded,
sx: { ml: row.depth * 2 },
children: expanded ? /* @__PURE__ */ jsx(KeyboardArrowDown, { fontSize: "small" }) : /* @__PURE__ */ jsx(KeyboardArrowRight, { fontSize: "small" })
});
};
$[1] = row;
$[2] = t0;
} else t0 = $[2];
let t1;
if ($[3] !== row.table.atoms.expanded || $[4] !== t0) {
t1 = /* @__PURE__ */ jsx(Subscribe, {
source: row.table.atoms.expanded,
children: t0
});
$[3] = row.table.atoms.expanded;
$[4] = t0;
$[5] = t1;
} else t1 = $[5];
return t1;
};
// src/components/table/cells/features/GroupCell.tsx
const GroupCell = () => {
const $ = c(17);
if ($[0] !== "cb40c710e959d4489491bc75103323e77548640fe738a1622265361a452a1d7d") {
for (let $i = 0; $i < 17; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "cb40c710e959d4489491bc75103323e77548640fe738a1622265361a452a1d7d";
}
const cell = useCellContext();
const { row } = cell;
const t0 = row.depth * 2;
let t1;
if ($[1] !== t0) {
t1 = {
ml: t0,
alignItems: "center"
};
$[1] = t0;
$[2] = t1;
} else t1 = $[2];
let t2;
if ($[3] !== row) {
t2 = () => {
const expanded = row.getIsExpanded();
return /* @__PURE__ */ jsx(IconButton, {
size: "small",
onClick: (event) => {
event.stopPropagation();
row.toggleExpanded();
},
"aria-label": "Expand group",
"aria-expanded": expanded,
children: expanded ? /* @__PURE__ */ jsx(KeyboardArrowDown, { fontSize: "small" }) : /* @__PURE__ */ jsx(KeyboardArrowRight, { fontSize: "small" })
});
};
$[3] = row;
$[4] = t2;
} else t2 = $[4];
let t3;
if ($[5] !== row.table.atoms.expanded || $[6] !== t2) {
t3 = /* @__PURE__ */ jsx(Subscribe, {
source: row.table.atoms.expanded,
children: t2
});
$[5] = row.table.atoms.expanded;
$[6] = t2;
$[7] = t3;
} else t3 = $[7];
let t4;
if ($[8] !== cell) {
t4 = /* @__PURE__ */ jsx(FlexRender, { cell });
$[8] = cell;
$[9] = t4;
} else t4 = $[9];
let t5;
if ($[10] !== row.subRows.length) {
t5 = /* @__PURE__ */ jsxs(Typography, {
variant: "caption",
color: "text.secondary",
children: [
"(",
row.subRows.length,
")"
]
});
$[10] = row.subRows.length;
$[11] = t5;
} else t5 = $[11];
let t6;
if ($[12] !== t1 || $[13] !== t3 || $[14] !== t4 || $[15] !== t5) {
t6 = /* @__PURE__ */ jsxs(Stack, {
className: layoutTableClasses.groupCell,
direction: "row",
spacing: .5,
sx: t1,
children: [
t3,
t4,
t5
]
});
$[12] = t1;
$[13] = t3;
$[14] = t4;
$[15] = t5;
$[16] = t6;
} else t6 = $[16];
return t6;
};
// src/components/table/cells/features/PinRowCell.tsx
const PinRowCell = () => {
const $ = c(6);
if ($[0] !== "e194b092212bcba6c7609b9efcd00ea15e11c1593245a7de3874f2d2ce0d3c7e") {
for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "e194b092212bcba6c7609b9efcd00ea15e11c1593245a7de3874f2d2ce0d3c7e";
}
const { row } = useCellContext();
let t0;
if ($[1] !== row) {
t0 = () => {
if (!row.getCanPin()) return null;
const pinned = row.getIsPinned();
return /* @__PURE__ */ jsx(Tooltip, {
title: "Pin row",
children: /* @__PURE__ */ jsx(IconButton, {
"aria-label": "Pin row",
"aria-pressed": !!pinned,
size: "small",
color: pinned ? "primary" : "default",
onClick: (event) => {
event.stopPropagation();
row.pin(pinned ? false : "top");
},
children: /* @__PURE__ */ jsx(PushPin, { fontSize: "small" })
})
});
};
$[1] = row;
$[2] = t0;
} else t0 = $[2];
let t1;
if ($[3] !== row.table.atoms.rowPinning || $[4] !== t0) {
t1 = /* @__PURE__ */ jsx(Subscribe, {
source: row.table.atoms.rowPinning,
children: t0
});
$[3] = row.table.atoms.rowPinning;
$[4] = t0;
$[5] = t1;
} else t1 = $[5];
return t1;
};
// src/components/table/cells/features/SelectCell.tsx
const SelectCell = () => {
const $ = c(6);
if ($[0] !== "63921cbcf7fcb34cd713e4f8ddc73200874bc27abe8c714719a6e3a2f7d9bc3a") {
for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "63921cbcf7fcb34cd713e4f8ddc73200874bc27abe8c714719a6e3a2f7d9bc3a";
}
const { row } = useCellContext();
let t0;
if ($[1] !== row) {
t0 = () => row.getCanSelect() ? /* @__PURE__ */ jsx(Checkbox, {
size: "small",
checked: row.getIsSelected(),
indeterminate: !row.getIsSelected() && row.getIsSomeSelected(),
onChange: row.getToggleSelectedHandler(),
onClick: _temp$5,
slotProps: { input: { "aria-label": "Select row" } }
}) : null;
$[1] = row;
$[2] = t0;
} else t0 = $[2];
let t1;
if ($[3] !== row.table.atoms.rowSelection || $[4] !== t0) {
t1 = /* @__PURE__ */ jsx(Subscribe, {
source: row.table.atoms.rowSelection,
children: t0
});
$[3] = row.table.atoms.rowSelection;
$[4] = t0;
$[5] = t1;
} else t1 = $[5];
return t1;
};
function _temp$5(event) {
return event.stopPropagation();
}
// src/components/table/cells/formatters/BooleanCell.tsx
/** Icons are inline-block, so without this they sit on the baseline and read as too high. */
const ICON_SX = { verticalAlign: "middle" };
const BooleanCell = () => {
const $ = c(3);
if ($[0] !== "c4041104e91084b687210e0524e009dc1af846acee76bcfc3bf9d28753f13090") {
for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "c4041104e91084b687210e0524e009dc1af846acee76bcfc3bf9d28753f13090";
}
const cell = useCellContext();
let t0;
if ($[1] !== cell) {
t0 = cell.getValue() ? /* @__PURE__ */ jsx(Check, {
fontSize: "small",
color: "success",
sx: ICON_SX
}) : /* @__PURE__ */ jsx(Close, {
fontSize: "small",
color: "error",
sx: ICON_SX
});
$[1] = cell;
$[2] = t0;
} else t0 = $[2];
return t0;
};
// src/components/table/cells/formatters/DateCell.tsx
dayjs.extend(localizedFormat);
const DateCell = (t0) => {
const $ = c(19);
if ($[0] !== "21b387c4bddca0bccbe970e472aebb39930745f6d942bddb5392537064b45906") {
for (let $i = 0; $i < 19; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "21b387c4bddca0bccbe970e472aebb39930745f6d942bddb5392537064b45906";
}
let props;
let t1;
if ($[1] !== t0) {
({format: t1, ...props} = t0);
$[1] = t0;
$[2] = props;
$[3] = t1;
} else {
props = $[2];
t1 = $[3];
}
const format = t1 === void 0 ? "L" : t1;
const cell = useCellContext();
let T0;
let t2;
let t3;
let t4;
let t5;
let t6;
if ($[4] !== cell || $[5] !== format || $[6] !== props) {
t6 = Symbol.for("react.early_return_sentinel");
bb0: {
const value = cell.getValue();
if (!value) {
t6 = null;
break bb0;
}
T0 = Typography;
t2 = "body2";
t3 = true;
t4 = props;
t5 = dayjs(value).format(format);
}
$[4] = cell;
$[5] = format;
$[6] = props;
$[7] = T0;
$[8] = t2;
$[9] = t3;
$[10] = t4;
$[11] = t5;
$[12] = t6;
} else {
T0 = $[7];
t2 = $[8];
t3 = $[9];
t4 = $[10];
t5 = $[11];
t6 = $[12];
}
if (t6 !== Symbol.for("react.early_return_sentinel")) return t6;
let t7;
if ($[13] !== T0 || $[14] !== t2 || $[15] !== t3 || $[16] !== t4 || $[17] !== t5) {
t7 = /* @__PURE__ */ jsx(T0, {
variant: t2,
noWrap: t3,
...t4,
children: t5
});
$[13] = T0;
$[14] = t2;
$[15] = t3;
$[16] = t4;
$[17] = t5;
$[18] = t7;
} else t7 = $[18];
return t7;
};
// src/components/table/cells/formatters/DateTimeCell.tsx
const DateTimeCell = (t0) => {
const $ = c(7);
if ($[0] !== "fe9e4fc38583f37e5227c0f76eb86e36fdbf232415dbb06681be0a948a3dc051") {
for (let $i = 0; $i < 7; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "fe9e4fc38583f37e5227c0f76eb86e36fdbf232415dbb06681be0a948a3dc051";
}
let props;
let t1;
if ($[1] !== t0) {
({format: t1, ...props} = t0);
$[1] = t0;
$[2] = props;
$[3] = t1;
} else {
props = $[2];
t1 = $[3];
}
const format = t1 === void 0 ? "L LT" : t1;
let t2;
if ($[4] !== format || $[5] !== props) {
t2 = /* @__PURE__ */ jsx(DateCell, {
format,
...props
});
$[4] = format;
$[5] = props;
$[6] = t2;
} else t2 = $[6];
return t2;
};
// src/components/table/cells/formatters/NumberCell.tsx
const NumberCell = (t0) => {
const $ = c(15);
if ($[0] !== "ff4712bc92382bef5082d0bcb57ed0ce8e368e142befb431a5ec06bbd557a0c7") {
for (let $i = 0; $i < 15; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "ff4712bc92382bef5082d0bcb57ed0ce8e368e142befb431a5ec06bbd557a0c7";
}
let options;
let props;
let sx;
if ($[1] !== t0) {
({options, sx, ...props} = t0);
$[1] = t0;
$[2] = options;
$[3] = props;
$[4] = sx;
} else {
options = $[2];
props = $[3];
sx = $[4];
}
const cell = useCellContext();
let t1;
if ($[5] !== cell || $[6] !== options || $[7] !== props || $[8] !== sx) {
const value = cell.getValue();
let t2;
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
t2 = { fontVariantNumeric: "tabular-nums" };
$[10] = t2;
} else t2 = $[10];
let t3;
if ($[11] !== sx) {
t3 = Array.isArray(sx) ? sx : [sx];
$[11] = sx;
$[12] = t3;
} else t3 = $[12];
let t4;
if ($[13] !== t3) {
t4 = [t2, ...t3];
$[13] = t3;
$[14] = t4;
} else t4 = $[14];
t1 = /* @__PURE__ */ jsx(Typography, {
variant: "body2",
noWrap: true,
sx: t4,
...props,
children: typeof value === "number" && value.toLocaleString(void 0, options)
});
$[5] = cell;
$[6] = options;
$[7] = props;
$[8] = sx;
$[9] = t1;
} else t1 = $[9];
return t1;
};
// src/components/table/cells/formatters/ValueCell.tsx
const ValueCell = (props) => {
const $ = c(6);
if ($[0] !== "0ab00a06181368c5fd56e221c1dd8e5c7a77c9128bcfd533b69fc70bfb59896f") {
for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "0ab00a06181368c5fd56e221c1dd8e5c7a77c9128bcfd533b69fc70bfb59896f";
}
const cell = useCellContext();
let t0;
if ($[1] !== cell) {
t0 = cell.renderValue();
$[1] = cell;
$[2] = t0;
} else t0 = $[2];
const value = t0;
let t1;
if ($[3] !== props || $[4] !== value) {
t1 = /* @__PURE__ */ jsx(Typography, {
variant: "body2",
noWrap: true,
...props,
children: value
});
$[3] = props;
$[4] = value;
$[5] = t1;
} else t1 = $[5];
return t1;
};
// src/components/table/filterFns.ts
const apply = (fn, row, columnId, value) => fn(row, columnId, fn.resolveFilterValue?.(value) ?? value);
const ignoreDiacritics = (fn) => constructFilterFn({
...fn,
resolveFilterValue: foldForSearch,
resolveDataValue: foldForSearch
});
const includesString = ignoreDiacritics(filterFn_includesString);
const equalsString = ignoreDiacritics(filterFn_equalsString);
const startsWith = ignoreDiacritics(filterFn_startsWith);
const endsWith = ignoreDiacritics(filterFn_endsWith);
const isFilterActive = (filter) => filter.operator === "isEmpty" || filter.operator === "isNotEmpty" || !isBlank(filter.value);
const isBlank = (value) => value === void 0 || value === null || value === "" || Array.isArray(value) && (!value.length || value.every(isBlank));
const toTime = (value) => {
if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value.getTime();
if (typeof value === "string" || typeof value === "number") {
const time = new Date(value).getTime();
return Number.isNaN(time) ? null : time;
}
return null;
};
const toDay = (time) => new Date(time).setHours(0, 0, 0, 0);
const compareDates = (row, columnId, value, operator) => {
const rowTime = toTime(row.getValue(columnId));
const filterTime = toTime(value);
if (rowTime === null || filterTime === null) return void 0;
switch (operator) {
case "equals": return toDay(rowTime) === toDay(filterTime);
case "greaterThan": return rowTime > filterTime;
case "greaterThanOrEqualTo": return rowTime >= filterTime;
case "lessThan": return rowTime < filterTime;
case "lessThanOrEqualTo": return rowTime <= filterTime;
default: return;
}
};
const daysFromToday = (row, columnId) => {
const rowTime = toTime(row.getValue(columnId));
if (rowTime === null) return null;
return Math.floor((toDay(rowTime) - toDay(Date.now())) / 864e5);
};
const isRelativeToToday = (row, columnId, value) => {
const diff = daysFromToday(row, columnId);
if (diff === null) return false;
if (Array.isArray(value)) {
const [min, max] = value.map(Number);
return (Number.isNaN(min) || diff >= min) && (Number.isNaN(max) || diff <= max);
}
const days = Number(value);
return !Number.isNaN(days) && diff === days;
};
const equals = (row, columnId, value, variant) => {
if (Array.isArray(value)) return apply(filterFn_arrHas, row, columnId, value);
if (variant === "date") return compareDates(row, columnId, value, "equals") ?? false;
return apply(filterFn_equals, row, columnId, value);
};
const test = (row, columnId, operator, value, variant) => {
switch (operator) {
case "includesString": return apply(includesString, row, columnId, value);
case "notIncludesString": return !apply(includesString, row, columnId, value);
case "equalsString": return apply(equalsString, row, columnId, value);
case "notEqualsString": return !apply(equalsString, row, columnId, value);
case "startsWith": return apply(startsWith, row, columnId, value);
case "endsWith": return apply(endsWith, row, columnId, value);
case "isEmpty": return filterFn_empty(row, columnId, true);
case "isNotEmpty": return filterFn_notEmpty(row, columnId, true);
case "equals": return equals(row, columnId, value, variant);
case "notEquals": return !equals(row, columnId, value, variant);
case "greaterThan":
case "greaterThanOrEqualTo":
case "lessThan":
case "lessThanOrEqualTo": {
if (variant === "date") return compareDates(row, columnId, value, operator) ?? false;
const fn = {
greaterThan: filterFn_greaterThan,
greaterThanOrEqualTo: filterFn_greaterThanOrEqualTo,
lessThan: filterFn_lessThan,
lessThanOrEqualTo: filterFn_lessThanOrEqualTo
}[operator];
return apply(fn, row, columnId, value);
}
case "inRange": return apply(variant === "date" ? filterFn_inDateRange : filterFn_inNumberRange, row, columnId, Array.isArray(value) ? value : [value, value]);
case "isRelativeToToday": return isRelativeToToday(row, columnId, value);
}
};
const dynamicFilterFn = (row, columnId) => {
const filters = row.table.store.state.columnFilters.filter((filter) => filter.id === columnId);
if (!filters.length) return true;
const variant = (row.table.getColumn(columnId)?.columnDef.meta)?.variant ?? "text";
const results = filters.filter(isFilterActive).map((filter) => test(row, columnId, filter.operator ?? "includesString", filter.value, variant));
if (!results.length) return true;
return (filters[0].joinOperator ?? "and") === "and" ? results.every(Boolean) : results.some(Boolean);
};
dynamicFilterFn.autoRemove = () => false;
const globalFilterFn = includesString;
const TEXT_OPERATORS = [
"includesString",
"notIncludesString",
"startsWith",
"endsWith",
"equalsString",
"notEqualsString",
"isEmpty",
"isNotEmpty"
];
const NUMBER_OPERATORS = [
"equals",
"notEquals",
"lessThan",
"lessThanOrEqualTo",
"greaterThan",
"greaterThanOrEqualTo",
"inRange"
];
const DATE_OPERATORS = [
"equals",
"notEquals",
"lessThan",
"lessThanOrEqualTo",
"greaterThan",
"greaterThanOrEqualTo",
"inRange",
"isRelativeToToday",
"isEmpty",
"isNotEmpty"
];
const CHOICE_OPERATORS = [
"equals",
"notEquals",
"isEmpty",
"isNotEmpty"
];
const getFilterOperators = (variant) => {
switch (variant) {
case "number": return NUMBER_OPERATORS;
case "date": return DATE_OPERATORS;
case "boolean":
case "select":
case "multi-select": return CHOICE_OPERATORS;
default: return TEXT_OPERATORS;
}
};
// src/components/table/headers/AggregationFooter.tsx
const AggregationFooter = (t0) => {
const $ = c(8);
if ($[0] !== "6021c56ed0cd1a788bc6e91d5de4a57d460a993de6ae388b5474e2e6ef65be5a") {
for (let $i = 0; $i < 8; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "6021c56ed0cd1a788bc6e91d5de4a57d460a993de6ae388b5474e2e6ef65be5a";
}
const { prefix: t1, options } = t0;
const prefix = t1 === void 0 ? "" : t1;
const { column } = useHeaderContext();
let t2;
if ($[1] !== column || $[2] !== options || $[3] !== prefix) {
t2 = () => {
const value = formatValue(column.getAggregationValue({ rows: column.table.getFilteredRowModel().rows }));
if (!value) return null;
const numeric = Number(value);
return /* @__PURE__ */ jsxs(Typography, {
className: layoutTableClasses.aggregationValue,
variant: "body2",
noWrap: true,
sx: { fontWeight: 700 },
children: [prefix, Number.isFinite(numeric) ? numeric.toLocaleString(void 0, options) : value]
});
};
$[1] = column;
$[2] = options;
$[3] = prefix;
$[4] = t2;
} else t2 = $[4];
let t3;
if ($[5] !== column.table.atoms.columnFilters || $[6] !== t2) {
t3 = /* @__PURE__ */ jsx(Subscribe, {
source: column.table.atoms.columnFilters,
children: t2
});
$[5] = column.table.atoms.columnFilters;
$[6] = t2;
$[7] = t3;
} else t3 = $[7];
return t3;
};
// src/components/table/headers/ExpandAllCell.tsx
const ExpandAllCell = () => {
const $ = c(6);
if ($[0] !== "0d47a2b13f5e66ad5ca22a4e39c7d87da50953524c5b4098e7af4cf8fe4744c9") {
for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "0d47a2b13f5e66ad5ca22a4e39c7d87da50953524c5b4098e7af4cf8fe4744c9";
}
const table = useHeaderContext().table;
let t0;
if ($[1] !== table) {
t0 = () => {
if (!table.getCanSomeRowsExpand()) return null;
return /* @__PURE__ */ jsx(IconButton, {
size: "small",
onClick: table.getToggleAllRowsExpandedHandler(),
"aria-label": "Expand all rows",
"aria-expanded": table.getIsAllRowsExpanded(),
children: /* @__PURE__ */ jsx(ArrowDownward, {
fontSize: "small",
sx: {
transition: "transform 150ms",
transform: table.getIsAllRowsExpanded() ? "rotate(0deg)" : "rotate(-90deg)"
}
})
});
};
$[1] = table;
$[2] = t0;
} else t0 = $[2];
let t1;
if ($[3] !== t0 || $[4] !== table.atoms.expanded) {
t1 = /* @__PURE__ */ jsx(Subscribe, {
source: table.atoms.expanded,
children: t0
});
$[3] = t0;
$[4] = table.atoms.expanded;
$[5] = t1;
} else t1 = $[5];
return t1;
};
// src/components/table/headers/HeaderMenu.tsx
const HeaderMenu = (t0) => {
const $ = c(11);
if ($[0] !== "8f3851e74e25eb958a5ca292bd5da9db42f5c94ea9d9bb58e7d99dc52cc2ccfc") {
for (let $i = 0; $i < 11; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "8f3851e74e25eb958a5ca292bd5da9db42f5c94ea9d9bb58e7d99dc52cc2ccfc";
}
const { disableGrouping: t1 } = t0;
const disableGrouping = t1 === void 0 ? false : t1;
const header = useHeaderContext();
const { t } = useTranslation$1();
const [anchorEl, setAnchorEl] = useState(null);
const { column } = header;
let t2;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t2 = () => setAnchorEl(null);
$[1] = t2;
} else t2 = $[1];
const close = t2;
let t3;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t3 = (action) => () => {
action();
close();
};
$[2] = t3;
} else t3 = $[2];
const run = t3;
if (!hasColumnLabel(column)) return null;
let t4;
if ($[3] !== anchorEl || $[4] !== column || $[5] !== disableGrouping || $[6] !== t) {
t4 = () => {
const canSort = column.getCanSort();
const canPin = column.getCanPin();
const canGroup = !disableGrouping && column.getCanGroup();
const canHide = column.getCanHide();
if (!canSort && !canPin && !canGroup && !canHide) return null;
const sorted = column.getIsSorted();
const pinned = column.getIsPinned();
const grouped = column.getIsGrouped();
const index = column.getIndex();
const leafCount = column.table.getVisibleLeafColumns().length;
return /* @__PURE__ */ jsxs(Box, {
className: layoutTableClasses.menuIcon,
sx: {
display: "flex",
flexShrink: 0,
mr: "-5px",
overflow: "hidden",
width: anchorEl ? "auto" : 0,
".MuiTableCell-root:hover &": { width: "auto" },
"&:focus-within": { width: "auto" },
"@media (hover: none)": { width: "auto" }
},
children: [/* @__PURE__ */ jsx(IconButton, {
size: "small",
onClick: (event) => setAnchorEl(event.currentTarget),
"aria-label": `Column menu: ${columnLabel(column)}`,
"aria-haspopup": "menu",
children: /* @__PURE__ */ jsx(MoreVert, { fontSize: "small" })
}), /* @__PURE__ */ jsxs(Menu, {
anchorEl,
open: !!anchorEl,
onClose: close,
children: [
canSort && sorted !== "asc" && /* @__PURE__ */ jsxs(MenuItem, {
onClick: run(() => column.toggleSorting(false, true)),
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(ArrowUpward, { fontSize: "small" }) }), /* @__PURE__ */ jsx(ListItemText, { children: t("Layout.Table.SortAscending") })]
}),
canSort && sorted !== "desc" && /* @__PURE__ */ jsxs(MenuItem, {
onClick: run(() => column.toggleSorting(true, true)),
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(ArrowDownward, { fontSize: "small" }) }), /* @__PURE__ */ jsx(ListItemText, { children: t("Layout.Table.SortDescending") })]
}),
canSort && sorted !== false && /* @__PURE__ */ jsxs(MenuItem, {
onClick: run(() => column.clearSorting()),
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(Clear, { fontSize: "small" }) }), /* @__PURE__ */ jsx(ListItemText, { children: t("Layout.Table.ClearSort") })]
}),
canPin && /* @__PURE__ */ jsx(Divider, {}),
canPin && ["start", "end"].map((position) => /* @__PURE__ */ jsxs(MenuItem, {
selected: pinned === position,
onClick: run(() => column.pin(pinned === position ? false : position)),
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(PushPin, { fontSize: "small" }) }), /* @__PURE__ */ jsx(ListItemText, { children: pinned === position ? t("Layout.Table.Unpin") : position === "start" ? t("Layout.Table.PinStart") : t("Layout.Table.PinEnd") })]
}, position)),
/* @__PURE__ */ jsx(Divider, {}),
/* @__PURE__ */ jsxs(MenuItem, {
disabled: index <= 0,
onClick: run(() => moveColumn(column, -1)),
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(ArrowBack, { fontSize: "small" }) }), /* @__PURE__ */ jsx(ListItemText, { children: t("Layout.Table.MoveLeft") })]
}),
/* @__PURE__ */ jsxs(MenuItem, {
disabled: index >= leafCount - 1,
onClick: run(() => moveColumn(column, 1)),
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(ArrowForward, { fontSize: "small" }) }), /* @__PURE__ */ jsx(ListItemText, { children: t("Layout.Table.MoveRight") })]
}),
canGroup && /* @__PURE__ */ jsx(Divider, {}),
canGroup && /* @__PURE__ */ jsxs(MenuItem, {
onClick: run(() => column.toggleGrouping()),
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(Workspaces, { fontSize: "small" }) }), /* @__PURE__ */ jsx(ListItemText, { children: grouped ? t("Layout.Table.Ungroup") : t("Layout.Table.GroupBy") })]
}),
canHide && /* @__PURE__ */ jsx(Divider, {}),
canHide && /* @__PURE__ */ jsxs(MenuItem, {
onClick: run(() => column.toggleVisibility(false)),
children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(VisibilityOff, { fontSize: "small" }) }), /* @__PURE__ */ jsx(ListItemText, { children: t("Layout.Table.HideColumn") })]
})
]
})]
});
};
$[3] = anchorEl;
$[4] = column;
$[5] = disableGrouping;
$[6] = t;
$[7] = t4;
} else t4 = $[7];
let t5;
if ($[8] !== column.table.store || $[9] !== t4) {
t5 = /* @__PURE__ */ jsx(Subscribe, {
source: column.table.store,
selector: _temp$4,
children: t4
});
$[8] = column.table.store;
$[9] = t4;
$[10] = t5;
} else t5 = $[10];
return t5;
};
function _temp$4(state) {
return state;
}
// src/components/table/headers/HeaderResizeHandle.tsx
const BAR_HEIGHT = 24;
const TARGET_SIZE = 10;
const bar = (accent) => ({
content: "\"\"",
position: "absolute",
insetInlineEnd: 0,
top: `calc(50% - ${BAR_HEIGHT / 2}px)`,
width: accent ? "3px" : "1px",
height: BAR_HEIGHT,
borderRadius: accent ? "1.5px" : "0.5px",
bgcolor: accent ? "primary.dark" : "divider",
transition: (theme) => theme.transitions.create(["width", "background-color"])
});
const base = {
position: "absolute",
insetBlock: 0,
insetInlineEnd: 0,
width: TARGET_SIZE
};
const HeaderResizeHandle = () => {
const $ = c(14);
if ($[0] !== "33ee7ddf08924e67e0e1a66793089ec21acae2a1b4e0ab77c6b12d588b417cd7") {
for (let $i = 0; $i < 14; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "33ee7ddf08924e67e0e1a66793089ec21acae2a1b4e0ab77c6b12d588b417cd7";
}
const header = useHeaderContext();
const { column } = header;
if (!column.getCanResize()) {
let t0;
if ($[1] !== column) {
t0 = column.getIsLastColumn() ? null : /* @__PURE__ */ jsx(Box, {
className: layoutTableClasses.columnSeparator,
sx: {
...base,
"&::after": bar(false)
}
});
$[1] = column;
$[2] = t0;
} else t0 = $[2];
return t0;
}
let t0;
if ($[3] !== header) {
t0 = header.getResizeHandler();
$[3] = header;
$[4] = t0;
} else t0 = $[4];
const resize = t0;
let t1;
if ($[5] !== column || $[6] !== resize) {
t1 = (event) => {
const width = event.currentTarget.parentElement?.offsetWidth;
if (columnFlex(column) && width) column.table.setColumnSizing((old) => ({
...old,
[column.id]: width
}));
resize(event);
};
$[5] = column;
$[6] = resize;
$[7] = t1;
} else t1 = $[7];
const handler = t1;
let t2;
if ($[8] !== column || $[9] !== handler) {
t2 = () => /* @__PURE__ */ jsx(Box, {
className: classNames(layoutTableClasses.columnSeparator, layoutTableClasses["columnSeparator--resizable"], column.getIsResizing() && layoutTableClasses["columnSeparator--resizing"]),
role: "separator",
"aria-orientation": "vertical",
onMouseDown: handler,
onTouchStart: handler,
onDoubleClick: () => column.resetSize(),
onClick: _temp$3,
sx: {
...base,
cursor: "col-resize",
touchAction: "none",
userSelect: "none",
"&::after": bar(column.getIsResizing()),
"&:hover::after": bar(true)
}
});
$[8] = column;
$[9] = handler;
$[10] = t2;
} else t2 = $[10];
let t3;
if ($[11] !== column.table.atoms.columnResizing || $[12] !== t2) {
t3 = /* @__PURE__ */ jsx(Subscribe, {
source: column.table.atoms.columnResizing,
children: t2
});
$[11] = column.table.atoms.columnResizing;
$[12] = t2;
$[13] = t3;
} else t3 = $[13];
return t3;
};
function _temp$3(event_0) {
return event_0.stopPropagation();
}
// src/components/table/headers/HeaderSortLabel.tsx
const HeaderSortLabel = (t0) => {
const $ = c(7);
if ($[0] !== "f2e2d371d335a2185da67d8487ef4595c4b85eb3dcdf12f44258aee598220df2") {
for (let $i = 0; $i < 7; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "f2e2d371d335a2185da67d8487ef4595c4b85eb3dcdf12f44258aee598220df2";
}
const { children } = t0;
const { column } = useHeaderContext();
if (!column.getCanSort()) return children;
let t1;
if ($[1] !== children || $[2] !== column) {
t1 = (sorting) => {
const direction = column.getIsSorted();
const sortIndex = sorting.length > 1 ? column.getSortIndex() : -1;
return /* @__PURE__ */ jsxs(TableSortLabel, {
className: layoutTableClasses.sortLabel,
active: direction !== false,
direction: direction === false ? "asc" : direction,
onClick: column.getToggleSortingHandler(),
children: [children, sortIndex > -1 && /* @__PURE__ */ jsx(Box, {
component: "span",
className: layoutTableClasses.sortIndex,
sx: {
ml: .5,
fontSize: 11,
opacity: .7
},
children: sortIndex + 1
})]
});
};
$[1] = children;
$[2] = column;
$[3] = t1;
} else t1 = $[3];
let t2;
if ($[4] !== column.table.atoms.sorting || $[5] !== t1) {
t2 = /* @__PURE__ */ jsx(Subscribe, {
source: column.table.atoms.sorting,
children: t1
});
$[4] = column.table.atoms.sorting;
$[5] = t1;
$[6] = t2;
} else t2 = $[6];
return t2;
};
// src/components/table/headers/SelectAllCell.tsx
const SelectAllCell = (t0) => {
const $ = c(7);
if ($[0] !== "33588c3e9cbdc713efa770a1c85d8af909b2a6100693622a56aa84ee845a7d85") {
for (let $i = 0; $i < 7; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "33588c3e9cbdc713efa770a1c85d8af909b2a6100693622a56aa84ee845a7d85";
}
const { scope: t1 } = t0;
const scope = t1 === void 0 ? "page" : t1;
const table = useHeaderContext().table;
let t2;
if ($[1] !== scope || $[2] !== table) {
t2 = () => {
const checked = scope === "page" ? table.getIsAllPageRowsSelected() : table.getIsAllRowsSelected();
const indeterminate = scope === "page" ? table.getIsSomePageRowsSelected() : table.getIsSomeRowsSelected();
return /* @__PURE__ */ jsx(Checkbox, {
size: "small",
checked,
indeterminate: !checked && indeterminate,
onChange: scope === "page" ? table.getToggleAllPageRowsSelectedHandler() : table.getToggleAllRowsSelectedHandler(),
slotProps: { input: { "aria-label": "Select all rows" } }
});
};
$[1] = scope;
$[2] = table;
$[3] = t2;
} else t2 = $[3];
let t3;
if ($[4] !== t2 || $[5] !== table.atoms.rowSelection) {
t3 = /* @__PURE__ */ jsx(Subscribe, {
source: table.atoms.rowSelection,
children: t2
});
$[4] = t2;
$[5] = table.atoms.rowSelection;
$[6] = t3;
} else t3 = $[6];
return t3;
};
// src/components/table/table/ColumnsPanel.tsx
const ColumnsPanel = () => {
const $ = c(29);
if ($[0] !== "d878c4bfcf4a08d07697131d885b96d23c3a42c0d7c9af747c3055cf6957291b") {
for (let $i = 0; $i < 29; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "d878c4bfcf4a08d07697131d885b96d23c3a42c0d7c9af747c3055cf6957291b";
}
const table = useTableContext();
const { t } = useTranslation$1();
const [anchorEl, setAnchorEl] = useState(null);
const buttonRef = useRef(null);
let t0;
if ($[1] !== table) {
t0 = table.getAllLeafColumns().filter(_temp$2);
$[1] = table;
$[2] = t0;
} else t0 = $[2];
const columns = t0;
let t1;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t1 = () => setAnchorEl((current) => current ? null : buttonRef.current);
$[3] = t1;
} else t1 = $[3];
const t2 = columns.length > 0;
let t3;
if ($[4] !== t2) {
t3 = { enabled: t2 };
$[4] = t2;
$[5] = t3;
} else t3 = $[5];
useHotkey("Alt+C", t1, t3);
if (!columns.length) return null;
let t4;
if ($[6] !== t) {
t4 = shortcutLabel(t("Layout.Table.Columns"), "Alt+C");
$[6] = t;
$[7] = t4;
} else t4 = $[7];
let t5;
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
t5 = /* @__PURE__ */ jsx(IconButton, {
ref: buttonRef,
className: layoutTableClasses.columnsButton,
size: "small",
onClick: (event) => setAnchorEl(event.currentTarget),
children: /* @__PURE__ */ jsx(ViewColumn, { fontSize: "small" })
});
$[8] = t5;
} else t5 = $[8];
let t6;
if ($[9] !== t4) {
t6 = /* @__PURE__ */ jsx(Tooltip, {
title: t4,
children: t5
});
$[9] = t4;
$[10] = t6;
} else t6 = $[10];
const t7 = !!anchorEl;
let t10;
let t8;
let t9;
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
t8 = () => setAnchorEl(null);
t9 = {
vertical: "bottom",
horizontal: "right"
};
t10 = {
vertical: "top",
horizontal: "right"
};
$[11] = t10;
$[12] = t8;
$[13] = t9;
} else {
t10 = $[11];
t8 = $[12];
t9 = $[13];
}
let t11;
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
t11 = { paper: {
className: layoutTableClasses.columnsPanel,
sx: { maxWidth: "calc(100vw - 16px)" }
} };
$[14] = t11;
} else t11 = $[14];
let t12;
if ($[15] !== columns || $[16] !== t || $[17] !== table) {
t12 = () => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Box, {
sx: {
display: "flex",
flexDirection: "column",
px: 1.5,
py: 1,
maxHeight: 300,
minWidth: 240,
overflow: "auto"
},
children: columns.map(_temp2$1)
}), /* @__PURE__ */ jsx(Box, {
sx: {
display: "flex",
alignItems: "center",
p: 1.5,
borderTop: 1,
borderColor: "divider"
},
children: /* @__PURE__ */ jsx(FormControlLabel, {
label: t("Layout.Table.ShowHideAll"),
slotProps: { typography: {
variant: "body2",
noWrap: true
} },
control: /* @__PURE__ */ jsx(Checkbox, {
size: "small",
checked: table.getIsAllColumnsVisible(),
indeterminate: table.getIsSomeColumnsVisible() && !table.getIsAllColumnsVisible(),
onChange: table.getToggleAllColumnsVisibilityHandler()
})
})
})] });
$[15] = columns;
$[16] = t;
$[17] = table;
$[18] = t12;
} else t12 = $[18];
let t13;
if ($[19] !== t12 || $[20] !== table.atoms.columnVisibility) {
t13 = /* @__PURE__ */ jsx(Subscribe, {
source: table.atoms.columnVisibility,
children: t12
});
$[19] = t12;
$[20] = table.atoms.columnVisibility;
$[21] = t13;
} else t13 = $[21];
let t14;
if ($[22] !== anchorEl || $[23] !== t13 || $[24] !== t7) {
t14 = /* @__PURE__ */ jsx(Popover, {
anchorEl,
open: t7,
onClose: t8,
anchorOrigin: t9,
transformOrigin: t10,
slotProps: t11,
children: t13
});
$[22] = anchorEl;
$[23] = t13;
$[24] = t7;
$[25] = t14;
} else t14 = $[25];
let t15;
if ($[26] !== t14 || $[27] !== t6) {
t15 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t6, t14] });
$[26] = t14;
$[27] = t6;
$[28] = t15;
} else t15 = $[28];
return t15;
};
function _temp$2(column) {
return hasColumnLabel(column) && column.getCanHide();
}
function _temp2$1(column_0) {
return /* @__PURE__ */ jsx(FormControlLabel, {
label: columnLabel(column_0),
slotProps: { typography: {
variant: "body2",
noWrap: true
} },
control: /* @__PURE__ */ jsx(Checkbox, {
size: "small",
checked: column_0.getIsVisible(),
onChange: column_0.getToggleVisibilityHandler()
})
}, column_0.id);
}
// src/components/table/ColumnFilterField.tsx
const filterMeta = (column) => column.columnDef.meta ?? {};
const resolveOptions = (column) => {
const declared = filterMeta(column).options;
if (declared) return declared;
return Array.from(column.getFacetedUniqueValues().keys()).map((value) => ({
label: formatValue(value),
value: formatValue(value)
})).filter((option) => option.value !== "").sort((a, b) => a.label.localeCompare(b.label));
};
const toDateInputValue = (value) => {
if (!(value instanceof Date || typeof value === "string" || typeof value === "number")) return "";
const date = value instanceof Date ? value : new Date(value);
if (Number.isNaN(date.getTime())) return "";
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
};
const fromDateInputValue = (raw) => raw ? (/* @__PURE__ */ new Date(`${raw}T00:00:00`)).toISOString() : void 0;
const toNumber = (raw) => raw === "" ? "" : Number(raw);
const pair = (value) => Array.isArray(value) ? [value[0], value[1]] : ["", ""];
function ColumnFilterField(t0) {
const $ = c(126);
if ($[0] !== "70d9525a526f8d7a67ab772f022a6cf530f26a1e99c43a5881011caa57faeb51") {
for (let $i = 0; $i < 126; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "70d9525a526f8d7a67ab772f022a6cf530f26a1e99c43a5881011caa57faeb51";
}
const { column, filter, onChange } = t0;
const { t } = useTranslation$1();
let t1;
if ($[1] !== column) {
t1 = filterMeta(column).variant ?? "text";
$[1] = column;
$[2] = t1;
} else t1 = $[2];
const variant = t1;
const operator = filter.operator ?? "includesString";
let t2;
if ($[3] !== t) {
t2 = t("Layout.Table.Value");
$[3] = t;
$[4] = t2;
} else t2 = $[4];
let t3;
if ($[5] !== t2) {
t3 = {
size: "small",
fullWidth: true,
label: t2
};
$[5] = t2;
$[6] = t3;
} else t3 = $[6];
const shared = t3;
const [value, setValue] = useState(filter.value);
let t4;
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
t4 = { wait: 300 };
$[7] = t4;
} else t4 = $[7];
const commit = useDebouncedCallback(onChange, t4);
let t5;
if ($[8] !== commit) {
t5 = (next) => {
setValue(next);
commit(next);
};
$[8] = commit;
$[9] = t5;
} else t5 = $[9];
const change = t5;
if (operator === "isEmpty" || operator === "isNotEmpty") {
let t6;
if ($[10] !== t) {
t6 = t("Layout.Table.NoValueRequired");
$[10] = t;
$[11] = t6;
} else t6 = $[11];
let t7;
if ($[12] !== t6) {
t7 = /* @__PURE__ */ jsx(Typography, {
variant: "body2",
color: "text.secondary",
children: t6
});
$[12] = t6;
$[13] = t7;
} else t7 = $[13];
return t7;
}
if (operator === "inRange") {
let T0;
let T1;
let from;
let isDate;
let t10;
let t11;
let t6;
let t7;
let t8;
let t9;
let to;
if ($[14] !== shared || $[15] !== t || $[16] !== value || $[17] !== variant) {
[from, to] = pair(value);
isDate = variant === "date";
T1 = Stack;
t10 = "row";
t11 = 1;
T0 = TextField;
t6 = shared;
t7 = isDate ? "date" : "number";
if ($[29] !== t) {
t8 = t("Layout.Table.From");
$[29] = t;
$[30] = t8;
} else t8 = $[30];
t9 = isDate ? toDateInputValue(from) : from ?? "";
$[14] = shared;
$[15] = t;
$[16] = value;
$[17] = variant;
$[18] = T0;
$[19] = T1;
$[20] = from;
$[21] = isDate;
$[22] = t10;
$[23] = t11;
$[24] = t6;
$[25] = t7;
$[26] = t8;
$[27] = t9;
$[28] = to;
} else {
T0 = $[18];
T1 = $[19];
from = $[20];
isDate = $[21];
t10 = $[22];
t11 = $[23];
t6 = $[24];
t7 = $[25];
t8 = $[26];
t9 = $[27];
to = $[28];
}
let t12;
if ($[31] !== change || $[32] !== isDate || $[33] !== to) {
t12 = (event) => change([isDate ? fromDateInputValue(event.target.value) : toNumber(event.target.value), to]);
$[31] = change;
$[32] = isDate;
$[33] = to;
$[34] = t12;
} else t12 = $[34];
let t13;
if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
t13 = { inputLabel: { shrink: true } };
$[35] = t13;
} else t13 = $[35];
let t14;
if ($[36] !== T0 || $[37] !== t12 || $[38] !== t6 || $[39] !== t7 || $[40] !== t8 || $[41] !== t9) {
t14 = /* @__PURE__ */ jsx(T0, {
...t6,
type: t7,
label: t8,
value: t9,
onChange: t12,
slotProps: t13
});
$[36] = T0;
$[37] = t12;
$[38] = t6;
$[39] = t7;
$[40] = t8;
$[41] = t9;
$[42] = t14;
} else t14 = $[42];
const t15 = isDate ? "date" : "number";
let t16;
if ($[43] !== t) {
t16 = t("Layout.Table.To");
$[43] = t;
$[44] = t16;
} else t16 = $[44];
let t17;
if ($[45] !== isDate || $[46] !== to) {
t17 = isDate ? toDateInputValue(to) : to ?? "";
$[45] = isDate;
$[46] = to;
$[47] = t17;
} else t17 = $[47];
let t18;
if ($[48] !== change || $[49] !== from || $[50] !== isDate) {
t18 = (event_0) => change([from, isDate ? fromDateInputValue(event_0.target.value) : toNumber(event_0.target.value)]);
$[48] = change;
$[49] = from;
$[50] = isDate;
$[51] = t18;
} else t18 = $[51];
let t19;
if ($[52] === Symbol.for("react.memo_cache_sentinel")) {
t19 = { inputLabel: { shrink: true } };
$[52] = t19;
} else t19 = $[52];
let t20;
if ($[53] !== shared || $[54] !== t15 || $[55] !== t16 || $[56] !== t17 || $[57] !== t18) {
t20 = /* @__PURE__ */ jsx(TextField, {
...shared,
type: t15,
label: t16,
value: t17,
onChange: t18,
slotProps: t19
});
$[53] = shared;
$[54] = t15;
$[55] = t16;
$[56] = t17;
$[57] = t18;
$[58] = t20;
} else t20 = $[58];
let t21;
if ($[59] !== T1 || $[60] !== t10 || $[61] !== t11 || $[62] !== t14 || $[63] !== t20) {
t21 = /* @__PURE__ */ jsxs(T1, {
direction: t10,
spacing: t11,
children: [t14, t20]
});
$[59] = T1;
$[60] = t10;
$[61] = t11;
$[62] = t14;
$[63] = t20;
$[64] = t21;
} else t21 = $[64];
return t21;
}
if (operator === "isRelativeToToday") {
let t6;
if ($[65] !== t) {
t6 = t("Layout.Table.DaysFromToday");
$[65] = t;
$[66] = t6;
} else t6 = $[66];
const t7 = value ?? "";
let t8;
if ($[67] !== change) {
t8 = (event_1) => change(toNumber(event_1.target.value));
$[67] = change;
$[68] = t8;
} else t8 = $[68];
let t9;
if ($[69] !== shared || $[70] !== t6 || $[71] !== t7 || $[72] !== t8) {
t9 = /* @__PURE__ */ jsx(TextField, {
...shared,
type: "number",
label: t6,
value: t7,
onChange: t8
});
$[69] = shared;
$[70] = t6;
$[71] = t7;
$[72] = t8;
$[73] = t9;
} else t9 = $[73];
return t9;
}
if (variant === "select" || variant === "multi-select") {
let T0;
let t10;
let t11;
let t6;
let t7;
let t8;
let t9;
if ($[74] !== column || $[75] !== value || $[76] !== variant) {
const options = resolveOptions(column);
const multiple = variant === "multi-select";
let t12;
if ($[84] !== value) {
t12 = Array.isArray(value) ? value : [];
$[84] = value;
$[85] = t12;
} else t12 = $[85];
const selected = t12;
T0 = Autocomplete;
t6 = "small";
t7 = true;
t8 = multiple;
t9 = options;
t10 = multiple;
t11 = multiple ? options.filter((option) => selected.includes(option.value)) : options.find((option_0) => option_0.value === value) ?? null;
$[74] = column;
$[75] = value;
$[76] = variant;
$[77] = T0;
$[78] = t10;
$[79] = t11;
$[80] = t6;
$[81] = t7;
$[82] = t8;
$[83] = t9;
} else {
T0 = $[77];
t10 = $[78];
t11 = $[79];
t6 = $[80];
t7 = $[81];
t8 = $[82];
t9 = $[83];
}
let t12;
if ($[86] !== change) {
t12 = (_, next_0) => change(Array.isArray(next_0) ? next_0.map(_temp3) : next_0?.value ?? void 0);
$[86] = change;
$[87] = t12;
} else t12 = $[87];
let t13;
if ($[88] !== t) {
t13 = (params) => /* @__PURE__ */ jsx(TextField, {
...params,
size: "small",
label: t("Layout.Table.Value")
});
$[88] = t;
$[89] = t13;
} else t13 = $[89];
let t14;
if ($[90] !== T0 || $[91] !== t10 || $[92] !== t11 || $[93] !== t12 || $[94] !== t13 || $[95] !== t6 || $[96] !== t7 || $[97] !== t8 || $[98] !== t9) {
t14 = /* @__PURE__ */ jsx(T0, {
size: t6,
fullWidth: t7,
multiple: t8,
options: t9,
disableCloseOnSelect: t10,
value: t11,
isOptionEqualToValue: _temp$1,
getOptionLabel: _temp2,
onChange: t12,
renderInput: t13
});
$[90] = T0;
$[91] = t10;
$[92] = t11;
$[93] = t12;
$[94] = t13;
$[95] = t6;
$[96] = t7;
$[97] = t8;
$[98] = t9;
$[99] = t14;
} else t14 = $[99];
return t14;
}
if (variant === "boolean") {
const t6 = typeof value === "boolean" ? String(value) : "";
let t7;
if ($[100] !== change) {
t7 = (event_2) => change(event_2.target.value === "" ? void 0 : event_2.target.value === "true");
$[100] = change;
$[101] = t7;
} else t7 = $[101];
let t10;
let t8;
let t9;
if ($[102] === Symbol.for("react.memo_cache_sentinel")) {
t8 = /* @__PURE__ */ jsx(MenuItem, {
value: "",
children: "—"
});
t9 = /* @__PURE__ */ jsx(MenuItem, {
value: "true",
children: "✓"
});
t10 = /* @__PURE__ */ jsx(MenuItem, {
value: "false",
children: "✗"
});
$[102] = t10;
$[103] = t8;
$[104] = t9;
} else {
t10 = $[102];
t8 = $[103];
t9 = $[104];
}
let t11;
if ($[105] !== shared || $[106] !== t6 || $[107] !== t7) {
t11 = /* @__PURE__ */ jsxs(TextField, {
...shared,
select: true,
value: t6,
onChange: t7,
children: [
t8,
t9,
t10
]
});
$[105] = shared;
$[106] = t6;
$[107] = t7;
$[108] = t11;
} else t11 = $[108];
return t11;
}
if (variant === "date") {
let t6;
if ($[109] !== value) {
t6 = toDateInputValue(value);
$[109] = value;
$[110] = t6;
} else t6 = $[110];
let t7;
if ($[111] !== change) {
t7 = (event_3) => change(fromDateInputValue(event_3.target.value) ?? "");
$[111] = change;
$[112] = t7;
} else t7 = $[112];
let t8;
if ($[113] === Symbol.for("react.memo_cache_sentinel")) {
t8 = { inputLabel: { shrink: true } };
$[113] = t8;
} else t8 = $[113];
let t9;
if ($[114] !== shared || $[115] !== t6 || $[116] !== t7) {
t9 = /* @__PURE__ */ jsx(TextField, {
...shared,
type: "date",
value: t6,
onChange: t7,
slotProps: t8
});
$[114] = shared;
$[115] = t6;
$[116] = t7;
$[117] = t9;
} else t9 = $[117];
return t9;
}
const t6 = variant === "number" ? "number" : "text";
const t7 = value ?? "";
let t8;
if ($[118] !== change || $[119] !== variant) {
t8 = (event_4) => change(variant === "number" ? toNumber(event_4.target.value) : event_4.target.value);
$[118] = change;
$[119] = variant;
$[120] = t8;
} else t8 = $[120];
let t9;
if ($[121] !== shared || $[122] !== t6 || $[123] !== t7 || $[124] !== t8) {
t9 = /* @__PURE__ */ jsx(TextField, {
...shared,
type: t6,
value: t7,
onChange: t8
});
$[121] = shared;
$[122] = t6;
$[123] = t7;
$[124] = t8;
$[125] = t9;
} else t9 = $[125];
return t9;
}
function _temp3(option_3) {
return option_3.value;
}
function _temp2(option_2) {
return option_2.label;
}
function _temp$1(option_1, selectedOption) {
return option_1.value === selectedOption.value;
}
// src/components/table/table/FiltersMenu.tsx
const DATE_OPERATOR_LABELS = {
lessThan: "Layout.Table.Operators.Date.lessThan",
lessThanOrEqualTo: "Layout.Table.Operators.Date.lessThanOrEqualTo",
greaterThan: "Layout.Table.Operators.Date.greaterThan",
greaterThanOrEqualTo: "Layout.Table.Operators.Date.greaterThanOrEqualTo"
};
/** Slot widths taken from the MUI X `GridFilterForm` inputs. */
const LOGIC_WIDTH = 75;
const FIELD_WIDTH = 150;
const VALUE_WIDTH = 190;
const FiltersMenu = () => {
const table = useTableContext();
const { t } = useTranslation$1();
const [anchorEl, setAnchorEl] = useState(null);
const placeholder = useRef(null);
const buttonRef = useRef(null);
const filterableColumns = table.getAllLeafColumns().filter((column) => column.getCanFilter());
const close = () => {
setAnchorEl(null);
placeholder.current = null;
};
useHotkey("Control+F", () => anchorEl ? close() : setAnchorEl(buttonRef.current), { enabled: filterableColumns.length > 0 });
if (!filterableColumns.length) return null;
const setFilters = (filters) => table.setColumnFilters(filters);
const newFilter = (column_0, joinOperator = "and") => ({
id: column_0.id,
filterId: crypto.randomUUID(),
value: "",
operator: getFilterOperators(column_0.columnDef.meta?.variant ?? "text")[0],
joinOperator
});
return /* @__PURE__ */ jsx(Subscribe, {
source: table.atoms.columnFilters,
selector: (filters_0) => filters_0,
children: (columnFilters) => {
if (!columnFilters.length) placeholder.current ??= newFilter(filterableColumns[0]);
const rows = columnFilters.length ? columnFilters : placeholder.current ? [placeholder.current] : [];
const activeCount = columnFilters.filter(isFilterActive).length;
const update = (filterId, patch) => setFilters(rows.map((filter) => filter.filterId === filterId ? {
...filter,
...patch,
..."value" in patch && { value: patch.value ?? "" }
} : filter));
const remove = (filterId_0) => {
const next = rows.filter((filter_0) => filter_0.filterId !== filterId_0);
placeholder.current = null;
setFilters(next);
if (!next.length) close();
};
const add = () => setFilters([...rows, newFilter(filterableColumns[0], rows[0]?.joinOperator ?? "and")]);
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Tooltip, {
title: shortcutLabel(t("Layout.Table.Filters"), "Control+F"),
children: /* @__PURE__ */ jsx(IconButton, {
ref: buttonRef,
className: layoutTableClasses.filtersButton,
size: "small",
color: activeCount ? "primary" : "default",
onClick: (event) => setAnchorEl(event.currentTarget),
children: /* @__PURE__ */ jsx(Badge, {
badgeContent: activeCount,
color: "primary",
variant: "dot",
children: /* @__PURE__ */ jsx(FilterList, { fontSize: "small" })
})
})
}), /* @__PURE__ */ jsxs(Popover, {
anchorEl,
open: !!anchorEl,
onClose: close,
anchorOrigin: {
vertical: "bottom",
horizontal: "right"
},
transformOrigin: {
vertical: "top",
horizontal: "right"
},
slotProps: { paper: {
className: layoutTableClasses.filterPanel,
sx: { maxWidth: "calc(100vw - 16px)" }
} },
children: [/* @__PURE__ */ jsx(Box, {
sx: {
display: "flex",
flexDirection: "column",
gap: 2.5,
p: "20px 12px 16px 8px",
maxHeight: 400,
overflow: "auto"
},
children: rows.map((filter_1, index) => {
const column_1 = table.getColumn(filter_1.id);
if (!column_1 || !filter_1.filterId) return null;
const variant = column_1.columnDef.meta?.variant ?? "text";
const operators = getFilterOperators(variant);
return /* @__PURE__ */ jsxs(Box, {
sx: {
display: "flex",
alignItems: "center",
gap: 1.5
},
children: [
/* @__PURE__ */ jsx(IconButton, {
size: "small",
"aria-label": "Remove filter",
sx: { flexShrink: 0 },
onClick: () => remove(filter_1.filterId),
children: /* @__PURE__ */ jsx(Close, { fontSize: "small" })
}),
/* @__PURE__ */ jsx(FormControl, {
size: "small",
sx: {
width: LOGIC_WIDTH,
flexShrink: 0,
visibility: index === 0 ? "hidden" : "visible"
},
children: /* @__PURE__ */ jsxs(Select, {
disabled: index > 1,
value: filter_1.joinOperator ?? "and",
inputProps: { "aria-label": "Logic operator" },
onChange: (event_0) => setFilters(rows.map((item) => ({
...item,
joinOperator: event_0.target.value
}))),
children: [/* @__PURE__ */ jsx(MenuItem, {
value: "and",
children: t("Layout.Table.And")
}), /* @__PURE__ */ jsx(MenuItem, {
value: "or",
children: t("Layout.Table.Or")
})]
})
}),
/* @__PURE__ */ jsx(Autocomplete, {
size: "small",
sx: {
width: FIELD_WIDTH,
flexShrink: 0
},
disableClearable: true,
options: filterableColumns,
value: column_1,
isOptionEqualToValue: (option, selected) => option.id === selected.id,
getOptionLabel: (option_0) => columnLabel(option_0),
onChange: (_, next_0) => update(filter_1.filterId, {
id: next_0.id,
operator: getFilterOperators(next_0.columnDef.meta?.variant ?? "text")[0],
value: ""
}),
renderInput: (params) => /* @__PURE__ */ jsx(TextField, {
...params,
size: "small",
label: t("Layout.Table.Field")
})
}),
/* @__PURE__ */ jsxs(FormControl, {
size: "small",
sx: {
width: FIELD_WIDTH,
flexShrink: 0
},
children: [/* @__PURE__ */ jsx(InputLabel, { children: t("Layout.Table.Operator") }), /* @__PURE__ */ jsx(Select, {
label: t("Layout.Table.Operator"),
value: filter_1.operator ?? operators[0],
onChange: (event_1) => update(filter_1.filterId, {
operator: event_1.target.value,
value: ""
}),
children: operators.map((operator) => /* @__PURE__ */ jsx(MenuItem, {
value: operator,
children: variant === "date" && operator in DATE_OPERATOR_LABELS ? t(DATE_OPERATOR_LABELS[operator]) : t(`Layout.Table.Operators.${operator}`)
}, operator))
})]
}),
/* @__PURE__ */ jsx(Box, {
sx: {
width: VALUE_WIDTH,
flexGrow: 1
},
children: /* @__PURE__ */ jsx(ColumnFilterField, {
column: column_1,
filter: filter_1,
onChange: (value) => update(filter_1.filterId, { value })
}, `${column_1.id}:${filter_1.operator}`)
})
]
}, filter_1.filterId);
})
}), /* @__PURE__ */ jsxs(Box, {
sx: {
display: "flex",
justifyContent: "space-between",
gap: 1,
p: 1,
borderTop: 1,
borderColor: "divider"
},
children: [/* @__PURE__ */ jsx(Button, {
size: "small",
startIcon: /* @__PURE__ */ jsx(Add, {}),
onClick: add,
children: t("Layout.Table.AddFilter")
}), columnFilters.length > 0 && /* @__PURE__ */ jsx(Button, {
size: "small",
color: "inherit",
startIcon: /* @__PURE__ */ jsx(DeleteForever, {}),
onClick: () => {
placeholder.current = null;
table.resetColumnFilters(true);
},
children: t("Layout.Table.ClearFilters")
})]
})]
})] });
}
});
};
// src/components/table/table/GlobalFilter.tsx
const GlobalFilter = (t0) => {
const $ = c(50);
if ($[0] !== "1c1431759d4bc6e8b3760e4dad41cb552b85e519bae45d3a2d4939c44dafbc2a") {
for (let $i = 0; $i < 50; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "1c1431759d4bc6e8b3760e4dad41cb552b85e519bae45d3a2d4939c44dafbc2a";
}
const { defaultExpanded, debounce: t1 } = t0;
const debounce = t1 === void 0 ? 300 : t1;
const table = useTableContext();
const { t } = useTranslation$1();
const theme = useTheme();
const inputRef = useRef(null);
const buttonRef = useRef(null);
const [value, setValue] = useState(table.state.globalFilter ?? "");
const [expanded, setExpanded] = useState(!!defaultExpanded);
const current = table.state.globalFilter ?? "";
let t2;
let t3;
if ($[1] !== current || $[2] !== debounce || $[3] !== table || $[4] !== value) {
t2 = () => {
if (value === current) return;
const id = setTimeout(() => table.setGlobalFilter(value), debounce);
return () => clearTimeout(id);
};
t3 = [
value,
current,
debounce,
table
];
$[1] = current;
$[2] = debounce;
$[3] = table;
$[4] = value;
$[5] = t2;
$[6] = t3;
} else {
t2 = $[5];
t3 = $[6];
}
useEffect(t2, t3);
let t4;
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
t4 = () => {
setValue("");
flushSync(() => setExpanded(false));
buttonRef.current?.focus();
};
$[7] = t4;
} else t4 = $[7];
const collapse = t4;
let t5;
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
t5 = () => {
flushSync(() => setExpanded(true));
inputRef.current?.focus();
};
$[8] = t5;
} else t5 = $[8];
const expand = t5;
useHotkey("Control+Q", expand);
let t6;
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
t6 = {
display: "grid",
alignItems: "center"
};
$[9] = t6;
} else t6 = $[9];
let t7;
if ($[10] !== t) {
t7 = shortcutLabel(t("Layout.Table.Search"), "Control+Q");
$[10] = t;
$[11] = t7;
} else t7 = $[11];
const t8 = expanded ? 0 : 1;
const t9 = expanded ? "none" : "auto";
let t10;
if ($[12] !== theme.transitions) {
t10 = theme.transitions.create(["opacity"]);
$[12] = theme.transitions;
$[13] = t10;
} else t10 = $[13];
let t11;
if ($[14] !== t10 || $[15] !== t8 || $[16] !== t9) {
t11 = {
gridArea: "1 / 1",
width: "min-content",
height: "min-content",
zIndex: 1,
opacity: t8,
pointerEvents: t9,
transition: t10
};
$[14] = t10;
$[15] = t8;
$[16] = t9;
$[17] = t11;
} else t11 = $[17];
let t12;
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
t12 = /* @__PURE__ */ jsx(Search, { fontSize: "small" });
$[18] = t12;
} else t12 = $[18];
let t13;
if ($[19] !== expanded || $[20] !== t11) {
t13 = /* @__PURE__ */ jsx(IconButton, {
ref: buttonRef,
size: "small",
"aria-label": "Search",
inert: expanded,
onClick: expand,
sx: t11,
children: t12
});
$[19] = expanded;
$[20] = t11;
$[21] = t13;
} else t13 = $[21];
let t14;
if ($[22] !== t13 || $[23] !== t7) {
t14 = /* @__PURE__ */ jsx(Tooltip, {
title: t7,
children: t13
});
$[22] = t13;
$[23] = t7;
$[24] = t14;
} else t14 = $[24];
let t15;
if ($[25] !== t) {
t15 = t("Layout.Table.Search");
$[25] = t;
$[26] = t15;
} else t15 = $[26];
let t16;
let t17;
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
t16 = (event) => setValue(event.target.value);
t17 = (event_0) => event_0.key === "Escape" && collapse();
$[27] = t16;
$[28] = t17;
} else {
t16 = $[27];
t17 = $[28];
}
let t18;
if ($[29] !== defaultExpanded || $[30] !== value) {
t18 = (event_1) => !value && !defaultExpanded && !event_1.currentTarget.parentElement?.contains(event_1.relatedTarget) && setExpanded(false);
$[29] = defaultExpanded;
$[30] = value;
$[31] = t18;
} else t18 = $[31];
const t19 = !expanded;
const t20 = expanded ? 260 : 40;
const t21 = expanded ? 1 : 0;
const t22 = expanded ? "auto" : "none";
let t23;
if ($[32] !== theme.transitions) {
t23 = theme.transitions.create(["width", "opacity"]);
$[32] = theme.transitions;
$[33] = t23;
} else t23 = $[33];
let t24;
if ($[34] !== t20 || $[35] !== t21 || $[36] !== t22 || $[37] !== t23) {
t24 = {
gridArea: "1 / 1",
overflowX: "clip",
width: t20,
opacity: t21,
pointerEvents: t22,
transition: t23
};
$[34] = t20;
$[35] = t21;
$[36] = t22;
$[37] = t23;
$[38] = t24;
} else t24 = $[38];
let t25;
if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
t25 = /* @__PURE__ */ jsx(InputAdornment, {
position: "start",
children: /* @__PURE__ */ jsx(Search, { fontSize: "small" })
});
$[39] = t25;
} else t25 = $[39];
let t26;
if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
t26 = {
input: {
startAdornment: t25,
endAdornment: /* @__PURE__ */ jsx(InputAdornment, {
position: "end",
children: /* @__PURE__ */ jsx(IconButton, {
edge: "end",
size: "small",
"aria-label": "Clear search",
onClick: collapse,
sx: { mr: -.75 },
children: /* @__PURE__ */ jsx(Close, { fontSize: "small" })
})
})
},
htmlInput: { "aria-label": "Search" }
};
$[40] = t26;
} else t26 = $[40];
let t27;
if ($[41] !== t15 || $[42] !== t18 || $[43] !== t19 || $[44] !== t24 || $[45] !== value) {
t27 = /* @__PURE__ */ jsx(TextField, {
inputRef,
size: "small",
value,
placeholder: t15,
onChange: t16,
onKeyDown: t17,
onBlur: t18,
inert: t19,
sx: t24,
slotProps: t26
});
$[41] = t15;
$[42] = t18;
$[43] = t19;
$[44] = t24;
$[45] = value;
$[46] = t27;
} else t27 = $[46];
let t28;
if ($[47] !== t14 || $[48] !== t27) {
t28 = /* @__PURE__ */ jsxs(Box, {
className: layoutTableClasses.toolbarQuickFilter,
sx: t6,
children: [t14, t27]
});
$[47] = t14;
$[48] = t27;
$[49] = t28;
} else t28 = $[49];
return t28;
};
// src/components/table/table/Skeleton.tsx
const Skeleton$1 = (t0) => {
const $ = c(10);
if ($[0] !== "61e6a876d0e9d3f0aa9eabd8c1c21cb4f7db79134597ecae88519117b94b077a") {
for (let $i = 0; $i < 10; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "61e6a876d0e9d3f0aa9eabd8c1c21cb4f7db79134597ecae88519117b94b077a";
}
const { rowHeight } = t0;
const table = useTableContext();
const firstRow = useRef(null);
let t1;
if ($[1] !== table.state.pagination.pageSize) {
t1 = () => Math.min(table.state.pagination.pageSize, 20);
$[1] = table.state.pagination.pageSize;
$[2] = t1;
} else t1 = $[2];
const [rowCount, setRowCount] = useState(t1);
let t2;
let t3;
if ($[3] !== rowHeight) {
t2 = () => {
const container = firstRow.current?.closest(".MuiTableContainer-root");
if (!container) return;
const measure = () => {
const spent = ["thead", "tfoot"].reduce((total, selector) => total + (container.querySelector(selector)?.getBoundingClientRect().height ?? 0), 0);
setRowCount(Math.max(1, Math.floor((container.clientHeight - spent) / rowHeight)));
};
measure();
const observer = new ResizeObserver(measure);
observer.observe(container);
return () => observer.disconnect();
};
t3 = [rowHeight];
$[3] = rowHeight;
$[4] = t2;
$[5] = t3;
} else {
t2 = $[4];
t3 = $[5];
}
useEffect(t2, t3);
let t4;
if ($[6] !== rowCount || $[7] !== rowHeight || $[8] !== table) {
t4 = /* @__PURE__ */ jsx(Fragment$1, { children: Array.from({ length: rowCount }, (_, index) => /* @__PURE__ */ jsxs(TableRow, {
ref: index === 0 ? firstRow : void 0,
className: layoutTableClasses.skeletonRow,
sx: { height: rowHeight },
children: [table.getVisibleLeafColumns().map(_temp), /* @__PURE__ */ jsx(TableCell, {
"aria-hidden": true,
className: layoutTableClasses.filler,
sx: { p: 0 }
})]
}, index)) });
$[6] = rowCount;
$[7] = rowHeight;
$[8] = table;
$[9] = t4;
} else t4 = $[9];
return t4;
};
function _temp(column) {
return hasColumnLabel(column) ? /* @__PURE__ */ jsx(TableCell, {
className: layoutTableClasses.skeletonCell,
sx: {
py: 0,
px: "10px"
},
children: /* @__PURE__ */ jsx(Skeleton, { variant: "text" })
}, column.id) : /* @__PURE__ */ jsx(TableCell, {
className: layoutTableClasses.skeletonCell,
align: "center",
sx: {
px: .5,
py: 0
},
children: /* @__PURE__ */ jsx(Skeleton, {
variant: "circular",
width: 22,
height: 22,
sx: { mx: "auto" }
})
}, column.id);
}
// src/components/table/table/Toolbar.tsx
/** Vertical rule with the MUI X toolbar proportions: half height, 4px gutters. */
const ToolbarDivider = () => {
const $ = c(2);
if ($[0] !== "cd4b9054da9eb7fd9ce3f57d9b8d7675c203d3ef8cdd4658e69bd1fb285f4f39") {
for (let $i = 0; $i < 2; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "cd4b9054da9eb7fd9ce3f57d9b8d7675c203d3ef8cdd4658e69bd1fb285f4f39";
}
let t0;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t0 = /* @__PURE__ */ jsx(Divider, {
className: layoutTableClasses.toolbarDivider,
orientation: "vertical",
sx: {
height: "50%",
alignSelf: "center",
mx: .5
}
});
$[1] = t0;
} else t0 = $[1];
return t0;
};
const Toolbar$1 = (t0) => {
const $ = c(29);
if ($[0] !== "cd4b9054da9eb7fd9ce3f57d9b8d7675c203d3ef8cdd4658e69bd1fb285f4f39") {
for (let $i = 0; $i < 29; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
$[0] = "cd4b9054da9eb7fd9ce3f57d9b8d7675c203d3ef8cdd4658e69bd1fb285f4f39";
}
const { title, actions, disableColumnFilter, disableColumnSelector, disableSearch } = t0;
const table = useTableContext();
const { t } = useTranslation$1();
let t1;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t1 = {
flexShrink: 0,
display: "flex",
alignItems: "center",
justifyContent: "end",
minHeight: 52,
gap: .25,
p: .75,
boxSizing: "border-box",
borderBottom: 1,
borderColor: "divider"
};
$[1] = t1;
} else t1 = $[1];
let t2;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t2 = {
flex: 1,
minWidth: 0,
display: "flex",
alignItems: "center",
gap: 1,
mx: .5
};
$[2] = t2;
} else t2 = $[2];
let t3;
if ($[3] !== title) {
t3 = title && /* @__PURE__ */ jsx(Typography, {
className: layoutTableClasses.toolbarTitle,
variant: "body1",
noWrap: true,
sx: { fontWeight: "bold" },
children: title
});
$[3] = title;
$[4] = t3;
} else t3 = $[4];
let t4;
if ($[5] !== t || $[6] !== table) {
t4 = () => {
const count = table.getSelectedRowIds().length;
if (!count) return null;
return /* @__PURE__ */ jsx(Typography, {
className: layoutTableClasses.toolbarSelectedCount,
variant: "body2",
noWrap: true,
color: "primary",
children: t("Layout.Table.SelectedCount", { count })
});
};
$[5] = t;
$[6] = table;
$[7] = t4;
} else t4 = $[7];
let t5;
if ($[8] !== t4 || $[9] !== table.atoms.rowSelection) {
t5 = /* @__PURE__ */ jsx(Subscribe, {
source: table.atoms.rowSelection,
children: t4
});
$[8] = t4;
$[9] = table.atoms.rowSelection;
$[10] = t5;
} else t5 = $[10];
let t6;
if ($[11] !== t3 || $[12] !== t5) {
t6 = /* @__PURE__ */ jsxs(Box, {
className: layoutTableClasses.toolbarLabel,
sx: t2,
children: [t3, t5]
});
$[11] = t3;
$[12] = t5;
$[13] = t6;
} else t6 = $[13];
let t7;
if ($[14] !== actions) {
t7 = actions && /* @__PURE__ */ jsx(ToolbarDivider, {});
$[14] = actions;
$[15] = t7;
} else t7 = $[15];
let t8;
if ($[16] !== disableColumnSelector) {
t8 = !disableColumnSelector && /* @__PURE__ */ jsx(ColumnsPanel, {});
$[16] = disableColumnSelector;
$[17] = t8;
} else t8 = $[17];
let t9;
if ($[18] !== disableColumnFilter) {
t9 = !disableColumnFilter && /* @__PURE__ */ jsx(FiltersMenu, {});
$[18] = disableColumnFilter;
$[19] = t9;
} else t9 = $[19];
let t10;
if ($[20] !== disableSearch) {
t10 = !disableSearch && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ToolbarDivider, {}), /* @__PURE__ */ jsx(GlobalFilter, {})] });
$[20] = disableSearch;
$[21] = t10;
} else t10 = $[21];
let t11;
if ($[22] !== actions || $[23] !== t10 || $[24] !== t6 || $[25] !== t7 || $[26] !== t8 || $[27] !== t9) {
t11 = /* @__PURE__ */ jsxs(Box, {
className: layoutTableClasses.toolbar,
sx: t1,
children: [
t6,
actions,
t7,
t8,
t9,
t10
]
});
$[22] = actions;
$[23] = t10;
$[24] = t6;
$[25] = t7;
$[26] = t8;
$[27] = t9;
$[28] = t11;
} else t11 = $[28];
return t11;
};
// src/hooks/useLayoutTable.tsx
const { appFeatures, createAppColumnHelper: createLayoutColumnHelper, useAppTable: useLayoutTable } = createTableHook({
features: layoutTableFeatures,
tableContext,
cellContext,
headerContext,
getRowId: (row) => row.id,
defaultColumn: {
filterFn: dynamicFilterFn,
aggregatedCell: () => /* @__PURE__ */ jsx(AggregatedCell, {})
},
globalFilterFn,
columnResizeMode: "onChange",
isMultiSortEvent: (e) => {
const { ctrlKey, metaKey, shiftKey } = e;
return ctrlKey || metaKey || shiftKey;
},
tableComponents: {
ColumnsPanel,
FiltersMenu,
GlobalFilter,
Pagination,
Skeleton: Skeleton$1,
Toolbar: Toolbar$1
},
cellComponents: {
ActionsCell,
AggregatedCell,
BooleanCell,
DateCell,
DateTimeCell,
ExpandCell,
GroupCell,
NumberCell,
PinRowCell,
SelectCell,
ValueCell
},
headerComponents: {
AggregationFooter,
ExpandAllCell,
HeaderMenu,
HeaderResizeHandle,
HeaderSortLabel,
SelectAllCell
}
});
export { createLayoutColumnHelper, layoutTableFeatures, useCellContext, useDialogs, useFieldContext, useFormContext, useHeaderContext, useInView, useLayoutForm, useLayoutTable, useScanDetection, useTableContext, useTranslation, withLayoutForm };
//# sourceMappingURL=hooks.mjs.map