@cerberus-design/react 0.13.2-next-9a3c62b → 0.13.2-next-61259ca
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/build/legacy/components/DatePicker.client.cjs +15 -43
- package/build/legacy/components/DatePicker.client.cjs.map +1 -1
- package/build/legacy/index.cjs +225 -230
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/{chunk-QX4V5V74.js → chunk-RIZGWERR.js} +1 -9
- package/build/modern/chunk-RIZGWERR.js.map +1 -0
- package/build/modern/components/DatePicker.client.js +1 -2
- package/build/modern/index.js +1 -1
- package/package.json +2 -2
- package/src/components/DatePicker.client.tsx +10 -9
- package/build/modern/chunk-QX4V5V74.js.map +0 -1
package/build/legacy/index.cjs
CHANGED
|
@@ -869,14 +869,13 @@ function CircularProgress(props) {
|
|
|
869
869
|
}
|
|
870
870
|
|
|
871
871
|
// src/components/DatePicker.client.tsx
|
|
872
|
-
var
|
|
872
|
+
var import_react6 = require("@ark-ui/react");
|
|
873
873
|
|
|
874
874
|
// src/components/Portal.tsx
|
|
875
875
|
var import_react4 = require("@ark-ui/react");
|
|
876
876
|
var Portal = import_react4.Portal;
|
|
877
877
|
|
|
878
878
|
// src/components/DatePicker.client.tsx
|
|
879
|
-
var import_react8 = require("react");
|
|
880
879
|
var import_recipes8 = require("@cerberus/styled-system/recipes");
|
|
881
880
|
var import_css10 = require("@cerberus/styled-system/css");
|
|
882
881
|
|
|
@@ -1012,113 +1011,16 @@ function DatePickerTableCellTrigger(props) {
|
|
|
1012
1011
|
var DatePickerView = import_react5.DatePicker.View;
|
|
1013
1012
|
var DatePickerContext = import_react5.DatePicker.Context;
|
|
1014
1013
|
|
|
1015
|
-
// src/hooks/useDate.ts
|
|
1016
|
-
var import_react6 = require("react");
|
|
1017
|
-
function useDate(options) {
|
|
1018
|
-
const initialValue = (options == null ? void 0 : options.initialValue) ?? "";
|
|
1019
|
-
const format = (options == null ? void 0 : options.format) ?? DateFormats.USMilitary;
|
|
1020
|
-
const onChange = options == null ? void 0 : options.onChange;
|
|
1021
|
-
const [value, setValue] = (0, import_react6.useState)(initialValue);
|
|
1022
|
-
const handleChange = (0, import_react6.useCallback)(
|
|
1023
|
-
(e) => {
|
|
1024
|
-
const newValue = formatMilitaryDate(e.currentTarget.value);
|
|
1025
|
-
if (onChange) onChange(e);
|
|
1026
|
-
setValue(newValue);
|
|
1027
|
-
},
|
|
1028
|
-
[onChange]
|
|
1029
|
-
);
|
|
1030
|
-
return (0, import_react6.useMemo)(
|
|
1031
|
-
() => ({
|
|
1032
|
-
format,
|
|
1033
|
-
value,
|
|
1034
|
-
ISO: formatMilitaryToISO(value),
|
|
1035
|
-
onChange: handleChange
|
|
1036
|
-
}),
|
|
1037
|
-
[format, value, handleChange]
|
|
1038
|
-
);
|
|
1039
|
-
}
|
|
1040
|
-
function formatMilitaryToISO(input3) {
|
|
1041
|
-
const [day, month, year] = input3.split(" ");
|
|
1042
|
-
const monthIndex = MONTHS.findIndex((m) => m.startsWith(month));
|
|
1043
|
-
const monthNum = monthIndex + 1;
|
|
1044
|
-
return `${year ?? "0000"}-${monthNum.toString().padStart(2, "0")}-${day.padStart(
|
|
1045
|
-
2,
|
|
1046
|
-
"0"
|
|
1047
|
-
)}`;
|
|
1048
|
-
}
|
|
1049
|
-
function formatMilitaryDate(input3) {
|
|
1050
|
-
let formatted = input3.toUpperCase().replace(/[^0-9A-Z]/g, "");
|
|
1051
|
-
let day = "";
|
|
1052
|
-
let month = "";
|
|
1053
|
-
let year = "";
|
|
1054
|
-
if (formatted.length >= 2) {
|
|
1055
|
-
day = formatted.replace(/[^0-9]/g, "").slice(0, 2);
|
|
1056
|
-
const dayNum = parseInt(day, 10);
|
|
1057
|
-
if (dayNum > 31) day = "31";
|
|
1058
|
-
else if (dayNum === 0) day = "01";
|
|
1059
|
-
formatted = formatted.slice(2);
|
|
1060
|
-
}
|
|
1061
|
-
if (formatted.length >= 3) {
|
|
1062
|
-
month = formatted.slice(0, 3);
|
|
1063
|
-
const monthIndex = MONTHS.findIndex((m) => m.startsWith(month));
|
|
1064
|
-
if (monthIndex !== -1) {
|
|
1065
|
-
month = MONTHS[monthIndex];
|
|
1066
|
-
} else {
|
|
1067
|
-
month = month.replace(/[^A-Z]/g, "");
|
|
1068
|
-
}
|
|
1069
|
-
formatted = formatted.slice(3);
|
|
1070
|
-
}
|
|
1071
|
-
if (formatted.length > 0) {
|
|
1072
|
-
year = formatted.slice(0, 4);
|
|
1073
|
-
}
|
|
1074
|
-
return [day, month, year].filter(Boolean).join(" ");
|
|
1075
|
-
}
|
|
1076
|
-
function formatISOToMilitary(date) {
|
|
1077
|
-
const [year, month, day] = date.split("-");
|
|
1078
|
-
const monthIndex = parseInt(month, 10) - 1;
|
|
1079
|
-
const monthStr = MONTHS[monthIndex];
|
|
1080
|
-
return `${day} ${monthStr} ${year}`;
|
|
1081
|
-
}
|
|
1082
|
-
var DateFormats = {
|
|
1083
|
-
get ISO() {
|
|
1084
|
-
return "YYYY-MM-DD";
|
|
1085
|
-
},
|
|
1086
|
-
get USMilitary() {
|
|
1087
|
-
return "DD MMM YYYY";
|
|
1088
|
-
},
|
|
1089
|
-
get Months() {
|
|
1090
|
-
return MONTHS;
|
|
1091
|
-
}
|
|
1092
|
-
};
|
|
1093
|
-
var MONTHS = [
|
|
1094
|
-
"JAN",
|
|
1095
|
-
"FEB",
|
|
1096
|
-
"MAR",
|
|
1097
|
-
"APR",
|
|
1098
|
-
"MAY",
|
|
1099
|
-
"JUN",
|
|
1100
|
-
"JUL",
|
|
1101
|
-
"AUG",
|
|
1102
|
-
"SEP",
|
|
1103
|
-
"OCT",
|
|
1104
|
-
"NOV",
|
|
1105
|
-
"DEC"
|
|
1106
|
-
];
|
|
1107
|
-
|
|
1108
1014
|
// src/components/DatePicker.client.tsx
|
|
1109
1015
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1110
1016
|
var datePickerStyles2 = (0, import_recipes8.datePicker)();
|
|
1111
1017
|
function DatePicker(props) {
|
|
1112
1018
|
const states = useFieldContext();
|
|
1113
|
-
const handleFormat = (0, import_react8.useCallback)((value) => {
|
|
1114
|
-
return formatISOToMilitary(value.toString());
|
|
1115
|
-
}, []);
|
|
1116
1019
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1117
|
-
|
|
1020
|
+
import_react6.DatePicker.Root,
|
|
1118
1021
|
{
|
|
1119
1022
|
...props,
|
|
1120
1023
|
...states,
|
|
1121
|
-
format: handleFormat,
|
|
1122
1024
|
positioning: {
|
|
1123
1025
|
placement: "bottom-start"
|
|
1124
1026
|
}
|
|
@@ -1127,10 +1029,10 @@ function DatePicker(props) {
|
|
|
1127
1029
|
}
|
|
1128
1030
|
function DatePickerInput(props) {
|
|
1129
1031
|
const { invalid, ...fieldStates } = useFieldContext();
|
|
1130
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react6.DatePicker.Control, { className: datePickerStyles2.control, children: [
|
|
1131
1033
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTrigger, {}),
|
|
1132
1034
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1133
|
-
|
|
1035
|
+
import_react6.DatePicker.Input,
|
|
1134
1036
|
{
|
|
1135
1037
|
...props,
|
|
1136
1038
|
...fieldStates,
|
|
@@ -1144,10 +1046,10 @@ function DatePickerInput(props) {
|
|
|
1144
1046
|
}
|
|
1145
1047
|
function RangePickerInput(props) {
|
|
1146
1048
|
const { invalid, ...fieldStates } = useFieldContext();
|
|
1147
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react6.DatePicker.Control, { "data-range": true, className: datePickerStyles2.control, children: [
|
|
1148
1050
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTrigger, {}),
|
|
1149
1051
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1150
|
-
|
|
1052
|
+
import_react6.DatePicker.Input,
|
|
1151
1053
|
{
|
|
1152
1054
|
...props,
|
|
1153
1055
|
...fieldStates,
|
|
@@ -1160,7 +1062,7 @@ function RangePickerInput(props) {
|
|
|
1160
1062
|
}
|
|
1161
1063
|
),
|
|
1162
1064
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1163
|
-
|
|
1065
|
+
import_react6.DatePicker.Input,
|
|
1164
1066
|
{
|
|
1165
1067
|
...props,
|
|
1166
1068
|
...fieldStates,
|
|
@@ -1177,8 +1079,8 @@ function RangePickerInput(props) {
|
|
|
1177
1079
|
}
|
|
1178
1080
|
function DatePickerContent(props) {
|
|
1179
1081
|
const { children, ...contentProps } = props;
|
|
1180
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1181
|
-
|
|
1082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.Positioner, { className: datePickerStyles2.positioner, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1083
|
+
import_react6.DatePicker.Content,
|
|
1182
1084
|
{
|
|
1183
1085
|
...contentProps,
|
|
1184
1086
|
className: (0, import_css10.cx)(contentProps.className, datePickerStyles2.content),
|
|
@@ -1206,8 +1108,8 @@ function DatePickerDayView(props) {
|
|
|
1206
1108
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerView, { ...props, view: "day", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerContext, { children: (datePicker3) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
1207
1109
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerViewControlGroup, {}),
|
|
1208
1110
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DatePickerTable, { children: [
|
|
1209
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1210
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1111
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.TableRow, { children: datePicker3.weekDays.map((weekDay, id) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTableHeader, { children: weekDay.narrow }, id)) }) }),
|
|
1112
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.TableBody, { children: datePicker3.weeks.map((week, id) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.TableRow, { children: week.map((day, id2) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTableCell, { value: day, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1211
1113
|
DatePickerTableCellTrigger,
|
|
1212
1114
|
{
|
|
1213
1115
|
"data-date": getDayValue(day),
|
|
@@ -1218,15 +1120,15 @@ function DatePickerDayView(props) {
|
|
|
1218
1120
|
] }) }) });
|
|
1219
1121
|
}
|
|
1220
1122
|
function DatePickerMonthView(props) {
|
|
1221
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.View, { ...props, view: "month", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.Context, { children: (datePicker3) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
1222
1124
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerViewControlGroup, {}),
|
|
1223
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTable, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1125
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTable, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.TableBody, { children: datePicker3.getMonthsGrid({ columns: 4, format: "short" }).map((months, id) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.TableRow, { children: months.map((month, id2) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTableCell, { value: month.value, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTableCellTrigger, { children: month.label }) }, id2)) }, id)) }) })
|
|
1224
1126
|
] }) }) });
|
|
1225
1127
|
}
|
|
1226
1128
|
function DatePickerYearView(props) {
|
|
1227
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.View, { ...props, view: "year", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.Context, { children: (datePicker3) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
1228
1130
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerViewControlGroup, {}),
|
|
1229
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTable, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1131
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTable, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.TableBody, { children: datePicker3.getYearsGrid({ columns: 4 }).map((years, id) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react6.DatePicker.TableRow, { children: years.map((year, id2) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTableCell, { value: year.value, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePickerTableCellTrigger, { children: year.label }) }, id2)) }, id)) }) })
|
|
1230
1132
|
] }) }) });
|
|
1231
1133
|
}
|
|
1232
1134
|
function DatePickerCalendar() {
|
|
@@ -1239,11 +1141,11 @@ function DatePickerCalendar() {
|
|
|
1239
1141
|
|
|
1240
1142
|
// src/components/Droppable.tsx
|
|
1241
1143
|
var import_core = require("@dnd-kit/core");
|
|
1242
|
-
var
|
|
1144
|
+
var import_react7 = require("react");
|
|
1243
1145
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1244
1146
|
function Droppable(props) {
|
|
1245
1147
|
const { dropped, id, disabled, data, resizeObserverConfig, ...nativeProps } = props;
|
|
1246
|
-
const uuid = (0,
|
|
1148
|
+
const uuid = (0, import_react7.useId)();
|
|
1247
1149
|
const { isOver, setNodeRef } = (0, import_core.useDroppable)({
|
|
1248
1150
|
data,
|
|
1249
1151
|
disabled,
|
|
@@ -1279,14 +1181,14 @@ function FieldMessage(props) {
|
|
|
1279
1181
|
}
|
|
1280
1182
|
|
|
1281
1183
|
// src/context/feature-flags.tsx
|
|
1282
|
-
var
|
|
1184
|
+
var import_react8 = require("react");
|
|
1283
1185
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1284
|
-
var FeatureFlagContext = (0,
|
|
1186
|
+
var FeatureFlagContext = (0, import_react8.createContext)(null);
|
|
1285
1187
|
function FeatureFlags(props) {
|
|
1286
1188
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(FeatureFlagContext.Provider, { value: props.flags, children: props.children });
|
|
1287
1189
|
}
|
|
1288
1190
|
function useFeatureFlags(key) {
|
|
1289
|
-
const context = (0,
|
|
1191
|
+
const context = (0, import_react8.useContext)(FeatureFlagContext);
|
|
1290
1192
|
if (context === null) {
|
|
1291
1193
|
throw new Error(
|
|
1292
1194
|
"useFeatureFlag must be used within a FeatureFlags Provider"
|
|
@@ -1347,7 +1249,7 @@ function FieldsetLabel(props) {
|
|
|
1347
1249
|
}
|
|
1348
1250
|
|
|
1349
1251
|
// src/components/FileStatus.tsx
|
|
1350
|
-
var
|
|
1252
|
+
var import_react9 = require("react");
|
|
1351
1253
|
var import_recipes12 = require("@cerberus/styled-system/recipes");
|
|
1352
1254
|
var import_css15 = require("@cerberus/styled-system/css");
|
|
1353
1255
|
var import_patterns5 = require("@cerberus/styled-system/patterns");
|
|
@@ -1397,10 +1299,10 @@ var processStatus = /* @__PURE__ */ ((processStatus2) => {
|
|
|
1397
1299
|
})(processStatus || {});
|
|
1398
1300
|
function FileStatus(props) {
|
|
1399
1301
|
const { file, now, status, onClick, ...nativeProps } = props;
|
|
1400
|
-
const actionLabel = (0,
|
|
1401
|
-
const palette = (0,
|
|
1402
|
-
const modalIconPalette = (0,
|
|
1403
|
-
const styles = (0,
|
|
1302
|
+
const actionLabel = (0, import_react9.useMemo)(() => getStatusActionLabel(status), [status]);
|
|
1303
|
+
const palette = (0, import_react9.useMemo)(() => getPalette(status), [status]);
|
|
1304
|
+
const modalIconPalette = (0, import_react9.useMemo)(() => getModalIconPalette(status), [status]);
|
|
1305
|
+
const styles = (0, import_react9.useMemo)(() => {
|
|
1404
1306
|
switch (status) {
|
|
1405
1307
|
case "todo" /* TODO */:
|
|
1406
1308
|
return (0, import_recipes12.fileStatus)({ status: "todo" });
|
|
@@ -1414,7 +1316,7 @@ function FileStatus(props) {
|
|
|
1414
1316
|
return (0, import_recipes12.fileStatus)();
|
|
1415
1317
|
}
|
|
1416
1318
|
}, [status]);
|
|
1417
|
-
const handleClick = (0,
|
|
1319
|
+
const handleClick = (0, import_react9.useCallback)(
|
|
1418
1320
|
(e) => {
|
|
1419
1321
|
const actionStatus = getStatusActionLabel(
|
|
1420
1322
|
status
|
|
@@ -1752,18 +1654,18 @@ function Legend(props) {
|
|
|
1752
1654
|
}
|
|
1753
1655
|
|
|
1754
1656
|
// src/components/Menu.tsx
|
|
1755
|
-
var
|
|
1657
|
+
var import_react10 = require("@ark-ui/react");
|
|
1756
1658
|
var import_recipes17 = require("@cerberus/styled-system/recipes");
|
|
1757
1659
|
var import_css20 = require("@cerberus/styled-system/css");
|
|
1758
1660
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1759
1661
|
var menuStyles = (0, import_recipes17.menu)();
|
|
1760
|
-
var Menu =
|
|
1662
|
+
var Menu = import_react10.Menu.Root;
|
|
1761
1663
|
function MenuTrigger(props) {
|
|
1762
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react10.Menu.Trigger, { ...props, asChild: true });
|
|
1763
1665
|
}
|
|
1764
1666
|
function MenuContent(props) {
|
|
1765
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1766
|
-
|
|
1667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react10.Menu.Positioner, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1668
|
+
import_react10.Menu.Content,
|
|
1767
1669
|
{
|
|
1768
1670
|
...props,
|
|
1769
1671
|
className: (0, import_css20.cx)(props.className, menuStyles.content)
|
|
@@ -1771,12 +1673,12 @@ function MenuContent(props) {
|
|
|
1771
1673
|
) });
|
|
1772
1674
|
}
|
|
1773
1675
|
function MenuItem(props) {
|
|
1774
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_react10.Menu.Item, { ...props, className: (0, import_css20.cx)(props.className, menuStyles.item) });
|
|
1775
1677
|
}
|
|
1776
|
-
var MenuItemGroup =
|
|
1678
|
+
var MenuItemGroup = import_react10.Menu.ItemGroup;
|
|
1777
1679
|
function MenuGroupLabel(props) {
|
|
1778
1680
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1779
|
-
|
|
1681
|
+
import_react10.Menu.ItemGroupLabel,
|
|
1780
1682
|
{
|
|
1781
1683
|
...props,
|
|
1782
1684
|
className: (0, import_css20.cx)(props.className, menuStyles.itemGroupLabel)
|
|
@@ -1785,7 +1687,7 @@ function MenuGroupLabel(props) {
|
|
|
1785
1687
|
}
|
|
1786
1688
|
function MenuSeparator(props) {
|
|
1787
1689
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1788
|
-
|
|
1690
|
+
import_react10.Menu.Separator,
|
|
1789
1691
|
{
|
|
1790
1692
|
...props,
|
|
1791
1693
|
className: (0, import_css20.cx)(props.className, menuStyles.separator)
|
|
@@ -1796,7 +1698,7 @@ function MenuSeparator(props) {
|
|
|
1796
1698
|
// src/components/Modal.tsx
|
|
1797
1699
|
var import_css21 = require("@cerberus/styled-system/css");
|
|
1798
1700
|
var import_recipes18 = require("@cerberus/styled-system/recipes");
|
|
1799
|
-
var
|
|
1701
|
+
var import_react11 = require("react");
|
|
1800
1702
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1801
1703
|
function ModalEl(props, ref) {
|
|
1802
1704
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
@@ -1808,7 +1710,7 @@ function ModalEl(props, ref) {
|
|
|
1808
1710
|
}
|
|
1809
1711
|
);
|
|
1810
1712
|
}
|
|
1811
|
-
var Modal = (0,
|
|
1713
|
+
var Modal = (0, import_react11.forwardRef)(ModalEl);
|
|
1812
1714
|
|
|
1813
1715
|
// src/components/ModalHeader.tsx
|
|
1814
1716
|
var import_css22 = require("@cerberus/styled-system/css");
|
|
@@ -1848,7 +1750,7 @@ function ModalDescription(props) {
|
|
|
1848
1750
|
}
|
|
1849
1751
|
|
|
1850
1752
|
// src/components/NavMenuTrigger.tsx
|
|
1851
|
-
var
|
|
1753
|
+
var import_react13 = require("react");
|
|
1852
1754
|
var import_css26 = require("@cerberus/styled-system/css");
|
|
1853
1755
|
var import_recipes21 = require("@cerberus/styled-system/recipes");
|
|
1854
1756
|
|
|
@@ -1862,17 +1764,17 @@ function createNavTriggerProps(values) {
|
|
|
1862
1764
|
|
|
1863
1765
|
// src/context/navMenu.tsx
|
|
1864
1766
|
var import_css25 = require("@cerberus/styled-system/css");
|
|
1865
|
-
var
|
|
1767
|
+
var import_react12 = require("react");
|
|
1866
1768
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1867
|
-
var NavMenuContext = (0,
|
|
1769
|
+
var NavMenuContext = (0, import_react12.createContext)(null);
|
|
1868
1770
|
function NavMenu(props) {
|
|
1869
|
-
const triggerRef = (0,
|
|
1870
|
-
const menuRef = (0,
|
|
1871
|
-
const [expanded, setExpanded] = (0,
|
|
1872
|
-
const handleToggle = (0,
|
|
1771
|
+
const triggerRef = (0, import_react12.useRef)(null);
|
|
1772
|
+
const menuRef = (0, import_react12.useRef)(null);
|
|
1773
|
+
const [expanded, setExpanded] = (0, import_react12.useState)(false);
|
|
1774
|
+
const handleToggle = (0, import_react12.useCallback)(() => {
|
|
1873
1775
|
setExpanded((prev) => !prev);
|
|
1874
1776
|
}, []);
|
|
1875
|
-
const value = (0,
|
|
1777
|
+
const value = (0, import_react12.useMemo)(
|
|
1876
1778
|
() => ({
|
|
1877
1779
|
triggerRef,
|
|
1878
1780
|
menuRef,
|
|
@@ -1892,7 +1794,7 @@ function NavMenu(props) {
|
|
|
1892
1794
|
) });
|
|
1893
1795
|
}
|
|
1894
1796
|
function useNavMenuContext() {
|
|
1895
|
-
const context = (0,
|
|
1797
|
+
const context = (0, import_react12.useContext)(NavMenuContext);
|
|
1896
1798
|
if (!context) {
|
|
1897
1799
|
throw new Error("useNavMenuContext must be used within a NavMenu.");
|
|
1898
1800
|
}
|
|
@@ -1919,7 +1821,7 @@ function NavMenuTrigger(props) {
|
|
|
1919
1821
|
});
|
|
1920
1822
|
const hasAs = Boolean(as);
|
|
1921
1823
|
const AsSub = as;
|
|
1922
|
-
const handleClick = (0,
|
|
1824
|
+
const handleClick = (0, import_react13.useCallback)(
|
|
1923
1825
|
(e) => {
|
|
1924
1826
|
if (onClick) return onClick(e);
|
|
1925
1827
|
onToggle();
|
|
@@ -1962,7 +1864,7 @@ function NavMenuTrigger(props) {
|
|
|
1962
1864
|
}
|
|
1963
1865
|
|
|
1964
1866
|
// src/components/NavMenuList.tsx
|
|
1965
|
-
var
|
|
1867
|
+
var import_react14 = require("react");
|
|
1966
1868
|
var import_css27 = require("@cerberus/styled-system/css");
|
|
1967
1869
|
var import_patterns10 = require("@cerberus/styled-system/patterns");
|
|
1968
1870
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
@@ -2019,7 +1921,7 @@ var navListStyles = (0, import_patterns10.vstack)({
|
|
|
2019
1921
|
function NavMenuList(props) {
|
|
2020
1922
|
const { position, ...nativeProps } = props;
|
|
2021
1923
|
const { menuRef, expanded } = useNavMenuContext();
|
|
2022
|
-
const locationStyles = (0,
|
|
1924
|
+
const locationStyles = (0, import_react14.useMemo)(
|
|
2023
1925
|
() => getPosition(position ?? "bottom"),
|
|
2024
1926
|
[position]
|
|
2025
1927
|
);
|
|
@@ -2079,7 +1981,7 @@ function NavMenuLink(props) {
|
|
|
2079
1981
|
var import_css29 = require("@cerberus/styled-system/css");
|
|
2080
1982
|
var import_patterns11 = require("@cerberus/styled-system/patterns");
|
|
2081
1983
|
var import_recipes22 = require("@cerberus/styled-system/recipes");
|
|
2082
|
-
var
|
|
1984
|
+
var import_react15 = require("react");
|
|
2083
1985
|
|
|
2084
1986
|
// src/aria-helpers/trap-focus.aria.ts
|
|
2085
1987
|
function trapFocus(modalRef) {
|
|
@@ -2117,7 +2019,7 @@ function MatchNotificationIcon(props) {
|
|
|
2117
2019
|
}
|
|
2118
2020
|
function Notification(props) {
|
|
2119
2021
|
const { children, palette, onClose, ...nativeProps } = props;
|
|
2120
|
-
const ref = (0,
|
|
2022
|
+
const ref = (0, import_react15.useRef)(null);
|
|
2121
2023
|
const onKeyDown = trapFocus(ref);
|
|
2122
2024
|
const styles = (0, import_recipes22.notification)({ palette });
|
|
2123
2025
|
const { close: CloseIcon } = $cerberusIcons;
|
|
@@ -2355,21 +2257,21 @@ function Spinner(props) {
|
|
|
2355
2257
|
}
|
|
2356
2258
|
|
|
2357
2259
|
// src/components/Tab.tsx
|
|
2358
|
-
var
|
|
2260
|
+
var import_react18 = require("react");
|
|
2359
2261
|
|
|
2360
2262
|
// src/context/tabs.tsx
|
|
2361
2263
|
var import_recipes27 = require("@cerberus/styled-system/recipes");
|
|
2362
|
-
var
|
|
2264
|
+
var import_react16 = require("react");
|
|
2363
2265
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
2364
|
-
var TabsContext = (0,
|
|
2266
|
+
var TabsContext = (0, import_react16.createContext)(null);
|
|
2365
2267
|
function Tabs(props) {
|
|
2366
2268
|
const { cache, active, id, palette } = props;
|
|
2367
|
-
const [activeTab, setActiveTab] = (0,
|
|
2368
|
-
const tabsList = (0,
|
|
2369
|
-
const uuid = (0,
|
|
2269
|
+
const [activeTab, setActiveTab] = (0, import_react16.useState)(() => cache ? "" : active ?? "");
|
|
2270
|
+
const tabsList = (0, import_react16.useRef)([]);
|
|
2271
|
+
const uuid = (0, import_react16.useMemo)(() => {
|
|
2370
2272
|
return id ? `cerberus-tabs-${id}` : "cerberus-tabs";
|
|
2371
2273
|
}, [id]);
|
|
2372
|
-
const value = (0,
|
|
2274
|
+
const value = (0, import_react16.useMemo)(
|
|
2373
2275
|
() => ({
|
|
2374
2276
|
tabs: tabsList,
|
|
2375
2277
|
id: uuid,
|
|
@@ -2379,7 +2281,7 @@ function Tabs(props) {
|
|
|
2379
2281
|
}),
|
|
2380
2282
|
[activeTab, setActiveTab, palette, uuid, tabsList]
|
|
2381
2283
|
);
|
|
2382
|
-
(0,
|
|
2284
|
+
(0, import_react16.useEffect)(() => {
|
|
2383
2285
|
if (cache) {
|
|
2384
2286
|
const cachedTab = window.localStorage.getItem(uuid);
|
|
2385
2287
|
setActiveTab(
|
|
@@ -2387,7 +2289,7 @@ function Tabs(props) {
|
|
|
2387
2289
|
);
|
|
2388
2290
|
}
|
|
2389
2291
|
}, [cache, active, uuid]);
|
|
2390
|
-
(0,
|
|
2292
|
+
(0, import_react16.useEffect)(() => {
|
|
2391
2293
|
if (cache && activeTab) {
|
|
2392
2294
|
window.localStorage.setItem(uuid, activeTab);
|
|
2393
2295
|
}
|
|
@@ -2395,7 +2297,7 @@ function Tabs(props) {
|
|
|
2395
2297
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(TabsContext.Provider, { value, children: props.children });
|
|
2396
2298
|
}
|
|
2397
2299
|
function useTabsContext() {
|
|
2398
|
-
const context = (0,
|
|
2300
|
+
const context = (0, import_react16.useContext)(TabsContext);
|
|
2399
2301
|
if (!context) {
|
|
2400
2302
|
throw new Error("useTabsContext must be used within a Tabs Provider.");
|
|
2401
2303
|
}
|
|
@@ -2406,7 +2308,7 @@ function useTabsContext() {
|
|
|
2406
2308
|
var import_css34 = require("@cerberus/styled-system/css");
|
|
2407
2309
|
|
|
2408
2310
|
// src/aria-helpers/tabs.aria.ts
|
|
2409
|
-
var
|
|
2311
|
+
var import_react17 = require("react");
|
|
2410
2312
|
function getNextIndex(index, length) {
|
|
2411
2313
|
return index === length - 1 ? 0 : index + 1;
|
|
2412
2314
|
}
|
|
@@ -2415,8 +2317,8 @@ function getPrevIndex(index, length) {
|
|
|
2415
2317
|
}
|
|
2416
2318
|
function useTabsKeyboardNavigation() {
|
|
2417
2319
|
const { tabs: tabs2 } = useTabsContext();
|
|
2418
|
-
const [activeTab, setActiveTab] = (0,
|
|
2419
|
-
(0,
|
|
2320
|
+
const [activeTab, setActiveTab] = (0, import_react17.useState)(-1);
|
|
2321
|
+
(0, import_react17.useEffect)(() => {
|
|
2420
2322
|
const handleKeyDown = (event) => {
|
|
2421
2323
|
const index = activeTab === -1 ? tabs2.current.findIndex((tab) => tab.ariaSelected === "true") : activeTab;
|
|
2422
2324
|
const nextIndex = getNextIndex(index, tabs2.current.length);
|
|
@@ -2466,9 +2368,9 @@ var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
|
2466
2368
|
function Tab(props) {
|
|
2467
2369
|
const { value, ...nativeProps } = props;
|
|
2468
2370
|
const { active, onTabUpdate, styles } = useTabsContext();
|
|
2469
|
-
const [isPending, startTransition] = (0,
|
|
2371
|
+
const [isPending, startTransition] = (0, import_react18.useTransition)();
|
|
2470
2372
|
const { ref } = useTabsKeyboardNavigation();
|
|
2471
|
-
const isActive = (0,
|
|
2373
|
+
const isActive = (0, import_react18.useMemo)(() => active === value, [active, value]);
|
|
2472
2374
|
function handleClick(e) {
|
|
2473
2375
|
var _a;
|
|
2474
2376
|
(_a = props.onClick) == null ? void 0 : _a.call(props, e);
|
|
@@ -2519,12 +2421,12 @@ function TabList(props) {
|
|
|
2519
2421
|
|
|
2520
2422
|
// src/components/TabPanel.tsx
|
|
2521
2423
|
var import_css36 = require("@cerberus/styled-system/css");
|
|
2522
|
-
var
|
|
2424
|
+
var import_react19 = require("react");
|
|
2523
2425
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
2524
2426
|
function TabPanel(props) {
|
|
2525
2427
|
const { tab, ...nativeProps } = props;
|
|
2526
2428
|
const { active, styles } = useTabsContext();
|
|
2527
|
-
const isActive = (0,
|
|
2429
|
+
const isActive = (0, import_react19.useMemo)(() => active === tab, [active, tab]);
|
|
2528
2430
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Show, { when: isActive, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2529
2431
|
"div",
|
|
2530
2432
|
{
|
|
@@ -2833,26 +2735,26 @@ function Tooltip(props) {
|
|
|
2833
2735
|
}
|
|
2834
2736
|
|
|
2835
2737
|
// src/context/confirm-modal.tsx
|
|
2836
|
-
var
|
|
2738
|
+
var import_react21 = require("react");
|
|
2837
2739
|
var import_css46 = require("@cerberus/styled-system/css");
|
|
2838
2740
|
var import_patterns16 = require("@cerberus/styled-system/patterns");
|
|
2839
2741
|
|
|
2840
2742
|
// src/hooks/useModal.ts
|
|
2841
|
-
var
|
|
2743
|
+
var import_react20 = require("react");
|
|
2842
2744
|
function useModal() {
|
|
2843
|
-
const modalRef = (0,
|
|
2844
|
-
const [isOpen, setIsOpen] = (0,
|
|
2845
|
-
const show = (0,
|
|
2745
|
+
const modalRef = (0, import_react20.useRef)(null);
|
|
2746
|
+
const [isOpen, setIsOpen] = (0, import_react20.useState)(false);
|
|
2747
|
+
const show = (0, import_react20.useCallback)(() => {
|
|
2846
2748
|
var _a;
|
|
2847
2749
|
(_a = modalRef.current) == null ? void 0 : _a.showModal();
|
|
2848
2750
|
setIsOpen(true);
|
|
2849
2751
|
}, []);
|
|
2850
|
-
const close = (0,
|
|
2752
|
+
const close = (0, import_react20.useCallback)(() => {
|
|
2851
2753
|
var _a;
|
|
2852
2754
|
(_a = modalRef.current) == null ? void 0 : _a.close();
|
|
2853
2755
|
setIsOpen(false);
|
|
2854
2756
|
}, []);
|
|
2855
|
-
return (0,
|
|
2757
|
+
return (0, import_react20.useMemo)(() => {
|
|
2856
2758
|
return {
|
|
2857
2759
|
modalRef,
|
|
2858
2760
|
show,
|
|
@@ -2865,19 +2767,19 @@ function useModal() {
|
|
|
2865
2767
|
// src/context/confirm-modal.tsx
|
|
2866
2768
|
var import_jsx2 = require("@cerberus/styled-system/jsx");
|
|
2867
2769
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
2868
|
-
var ConfirmModalContext = (0,
|
|
2770
|
+
var ConfirmModalContext = (0, import_react21.createContext)(null);
|
|
2869
2771
|
function ConfirmModal(props) {
|
|
2870
2772
|
const { modalRef, show, close } = useModal();
|
|
2871
|
-
const resolveRef = (0,
|
|
2872
|
-
const [content, setContent] = (0,
|
|
2773
|
+
const resolveRef = (0, import_react21.useRef)(null);
|
|
2774
|
+
const [content, setContent] = (0, import_react21.useState)(null);
|
|
2873
2775
|
const focusTrap = trapFocus(modalRef);
|
|
2874
2776
|
const ConfirmIcon = $cerberusIcons.confirmModal;
|
|
2875
2777
|
const kind = (content == null ? void 0 : content.kind) ?? "non-destructive";
|
|
2876
|
-
const palette = (0,
|
|
2778
|
+
const palette = (0, import_react21.useMemo)(
|
|
2877
2779
|
() => kind === "destructive" ? "danger" : "action",
|
|
2878
2780
|
[kind]
|
|
2879
2781
|
);
|
|
2880
|
-
const handleChoice = (0,
|
|
2782
|
+
const handleChoice = (0, import_react21.useCallback)(
|
|
2881
2783
|
(e) => {
|
|
2882
2784
|
var _a, _b;
|
|
2883
2785
|
const target = e.currentTarget;
|
|
@@ -2889,7 +2791,7 @@ function ConfirmModal(props) {
|
|
|
2889
2791
|
},
|
|
2890
2792
|
[close]
|
|
2891
2793
|
);
|
|
2892
|
-
const handleShow = (0,
|
|
2794
|
+
const handleShow = (0, import_react21.useCallback)(
|
|
2893
2795
|
(options) => {
|
|
2894
2796
|
return new Promise((resolve) => {
|
|
2895
2797
|
setContent({ ...options });
|
|
@@ -2899,7 +2801,7 @@ function ConfirmModal(props) {
|
|
|
2899
2801
|
},
|
|
2900
2802
|
[show]
|
|
2901
2803
|
);
|
|
2902
|
-
const value = (0,
|
|
2804
|
+
const value = (0, import_react21.useMemo)(
|
|
2903
2805
|
() => ({
|
|
2904
2806
|
show: handleShow
|
|
2905
2807
|
}),
|
|
@@ -2978,7 +2880,7 @@ function ConfirmModal(props) {
|
|
|
2978
2880
|
] });
|
|
2979
2881
|
}
|
|
2980
2882
|
function useConfirmModal() {
|
|
2981
|
-
const context = (0,
|
|
2883
|
+
const context = (0, import_react21.useContext)(ConfirmModalContext);
|
|
2982
2884
|
if (context === null) {
|
|
2983
2885
|
throw new Error(
|
|
2984
2886
|
"useConfirmModal must be used within a ConfirmModal Provider"
|
|
@@ -2988,21 +2890,21 @@ function useConfirmModal() {
|
|
|
2988
2890
|
}
|
|
2989
2891
|
|
|
2990
2892
|
// src/context/cta-modal.tsx
|
|
2991
|
-
var
|
|
2893
|
+
var import_react22 = require("react");
|
|
2992
2894
|
var import_jsx3 = require("@cerberus/styled-system/jsx");
|
|
2993
2895
|
var import_css47 = require("@cerberus/styled-system/css");
|
|
2994
2896
|
var import_jsx4 = require("@cerberus/styled-system/jsx");
|
|
2995
2897
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
2996
|
-
var CTAModalContext = (0,
|
|
2898
|
+
var CTAModalContext = (0, import_react22.createContext)(null);
|
|
2997
2899
|
function CTAModal(props) {
|
|
2998
2900
|
var _a, _b;
|
|
2999
2901
|
const { modalRef, show, close } = useModal();
|
|
3000
|
-
const [content, setContent] = (0,
|
|
2902
|
+
const [content, setContent] = (0, import_react22.useState)(null);
|
|
3001
2903
|
const focusTrap = trapFocus(modalRef);
|
|
3002
2904
|
const FallbackIcon = $cerberusIcons.confirmModal;
|
|
3003
2905
|
const confirmIcon = content == null ? void 0 : content.icon;
|
|
3004
2906
|
const { close: CloseIcon } = $cerberusIcons;
|
|
3005
|
-
const handleShow = (0,
|
|
2907
|
+
const handleShow = (0, import_react22.useCallback)(
|
|
3006
2908
|
(options) => {
|
|
3007
2909
|
const maxActions = 2;
|
|
3008
2910
|
if (options.actions.length > maxActions) {
|
|
@@ -3015,7 +2917,7 @@ function CTAModal(props) {
|
|
|
3015
2917
|
},
|
|
3016
2918
|
[show]
|
|
3017
2919
|
);
|
|
3018
|
-
const handleActionClick = (0,
|
|
2920
|
+
const handleActionClick = (0, import_react22.useCallback)(
|
|
3019
2921
|
(event) => {
|
|
3020
2922
|
const index = event.currentTarget.getAttribute("data-index");
|
|
3021
2923
|
const action = content == null ? void 0 : content.actions[Number(index)];
|
|
@@ -3025,7 +2927,7 @@ function CTAModal(props) {
|
|
|
3025
2927
|
},
|
|
3026
2928
|
[content, close]
|
|
3027
2929
|
);
|
|
3028
|
-
const value = (0,
|
|
2930
|
+
const value = (0, import_react22.useMemo)(
|
|
3029
2931
|
() => ({
|
|
3030
2932
|
show: handleShow
|
|
3031
2933
|
}),
|
|
@@ -3087,7 +2989,7 @@ function CTAModal(props) {
|
|
|
3087
2989
|
] });
|
|
3088
2990
|
}
|
|
3089
2991
|
function useCTAModal() {
|
|
3090
|
-
const context = (0,
|
|
2992
|
+
const context = (0, import_react22.useContext)(CTAModalContext);
|
|
3091
2993
|
if (context === null) {
|
|
3092
2994
|
throw new Error("useCTAModal must be used within a CTAModal Provider");
|
|
3093
2995
|
}
|
|
@@ -3095,22 +2997,22 @@ function useCTAModal() {
|
|
|
3095
2997
|
}
|
|
3096
2998
|
|
|
3097
2999
|
// src/context/notification-center.tsx
|
|
3098
|
-
var
|
|
3000
|
+
var import_react23 = require("react");
|
|
3099
3001
|
var import_patterns17 = require("@cerberus/styled-system/patterns");
|
|
3100
3002
|
var import_recipes37 = require("@cerberus/styled-system/recipes");
|
|
3101
3003
|
var import_css48 = require("@cerberus/styled-system/css");
|
|
3102
3004
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
3103
|
-
var NotificationsContext = (0,
|
|
3005
|
+
var NotificationsContext = (0, import_react23.createContext)(null);
|
|
3104
3006
|
function NotificationCenter(props) {
|
|
3105
|
-
const [activeNotifications, setActiveNotifications] = (0,
|
|
3007
|
+
const [activeNotifications, setActiveNotifications] = (0, import_react23.useState)([]);
|
|
3106
3008
|
const styles = (0, import_recipes37.notification)();
|
|
3107
|
-
const handleNotify = (0,
|
|
3009
|
+
const handleNotify = (0, import_react23.useCallback)((options) => {
|
|
3108
3010
|
setActiveNotifications((prev) => {
|
|
3109
3011
|
const id = `${options.palette}:${prev.length + 1}`;
|
|
3110
3012
|
return [...prev, { ...options, id }];
|
|
3111
3013
|
});
|
|
3112
3014
|
}, []);
|
|
3113
|
-
const handleClose = (0,
|
|
3015
|
+
const handleClose = (0, import_react23.useCallback)((e) => {
|
|
3114
3016
|
const target = e.currentTarget;
|
|
3115
3017
|
setActiveNotifications((prev) => {
|
|
3116
3018
|
const item = prev.find((option) => option.id === target.value);
|
|
@@ -3118,7 +3020,7 @@ function NotificationCenter(props) {
|
|
|
3118
3020
|
return prev.filter((option) => option.id !== target.value);
|
|
3119
3021
|
});
|
|
3120
3022
|
}, []);
|
|
3121
|
-
const handleCloseAll = (0,
|
|
3023
|
+
const handleCloseAll = (0, import_react23.useCallback)(() => {
|
|
3122
3024
|
setActiveNotifications((prev) => {
|
|
3123
3025
|
prev.forEach((item) => {
|
|
3124
3026
|
if (item.onClose) item.onClose();
|
|
@@ -3126,7 +3028,7 @@ function NotificationCenter(props) {
|
|
|
3126
3028
|
return [];
|
|
3127
3029
|
});
|
|
3128
3030
|
}, []);
|
|
3129
|
-
const value = (0,
|
|
3031
|
+
const value = (0, import_react23.useMemo)(
|
|
3130
3032
|
() => ({
|
|
3131
3033
|
notify: handleNotify
|
|
3132
3034
|
}),
|
|
@@ -3217,7 +3119,7 @@ function MatchNotification(props) {
|
|
|
3217
3119
|
}
|
|
3218
3120
|
}
|
|
3219
3121
|
function useNotificationCenter() {
|
|
3220
|
-
const context = (0,
|
|
3122
|
+
const context = (0, import_react23.useContext)(NotificationsContext);
|
|
3221
3123
|
if (!context) {
|
|
3222
3124
|
throw new Error(
|
|
3223
3125
|
"useNotificationCenter must be used within a NotificationsProvider"
|
|
@@ -3227,33 +3129,33 @@ function useNotificationCenter() {
|
|
|
3227
3129
|
}
|
|
3228
3130
|
|
|
3229
3131
|
// src/context/prompt-modal.tsx
|
|
3230
|
-
var
|
|
3132
|
+
var import_react24 = require("react");
|
|
3231
3133
|
var import_css49 = require("@cerberus/styled-system/css");
|
|
3232
3134
|
var import_patterns18 = require("@cerberus/styled-system/patterns");
|
|
3233
3135
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
3234
|
-
var PromptModalContext = (0,
|
|
3136
|
+
var PromptModalContext = (0, import_react24.createContext)(null);
|
|
3235
3137
|
function PromptModal(props) {
|
|
3236
3138
|
const { modalRef, show, close } = useModal();
|
|
3237
|
-
const resolveRef = (0,
|
|
3238
|
-
const [content, setContent] = (0,
|
|
3239
|
-
const [inputValue, setInputValue] = (0,
|
|
3139
|
+
const resolveRef = (0, import_react24.useRef)(null);
|
|
3140
|
+
const [content, setContent] = (0, import_react24.useState)(null);
|
|
3141
|
+
const [inputValue, setInputValue] = (0, import_react24.useState)("");
|
|
3240
3142
|
const focusTrap = trapFocus(modalRef);
|
|
3241
3143
|
const PromptIcon = $cerberusIcons.promptModal;
|
|
3242
|
-
const isValid = (0,
|
|
3144
|
+
const isValid = (0, import_react24.useMemo)(
|
|
3243
3145
|
() => inputValue === (content == null ? void 0 : content.key),
|
|
3244
3146
|
[inputValue, content]
|
|
3245
3147
|
);
|
|
3246
|
-
const palette = (0,
|
|
3148
|
+
const palette = (0, import_react24.useMemo)(
|
|
3247
3149
|
() => (content == null ? void 0 : content.kind) === "destructive" ? "danger" : "action",
|
|
3248
3150
|
[content]
|
|
3249
3151
|
);
|
|
3250
|
-
const handleChange = (0,
|
|
3152
|
+
const handleChange = (0, import_react24.useCallback)(
|
|
3251
3153
|
(e) => {
|
|
3252
3154
|
setInputValue(e.currentTarget.value);
|
|
3253
3155
|
},
|
|
3254
3156
|
[content]
|
|
3255
3157
|
);
|
|
3256
|
-
const handleChoice = (0,
|
|
3158
|
+
const handleChoice = (0, import_react24.useCallback)(
|
|
3257
3159
|
(e) => {
|
|
3258
3160
|
var _a;
|
|
3259
3161
|
const target = e.currentTarget;
|
|
@@ -3264,7 +3166,7 @@ function PromptModal(props) {
|
|
|
3264
3166
|
},
|
|
3265
3167
|
[inputValue, close]
|
|
3266
3168
|
);
|
|
3267
|
-
const handleShow = (0,
|
|
3169
|
+
const handleShow = (0, import_react24.useCallback)(
|
|
3268
3170
|
(options) => {
|
|
3269
3171
|
return new Promise((resolve) => {
|
|
3270
3172
|
setContent({ ...options, kind: options.kind || "non-destructive" });
|
|
@@ -3274,7 +3176,7 @@ function PromptModal(props) {
|
|
|
3274
3176
|
},
|
|
3275
3177
|
[show]
|
|
3276
3178
|
);
|
|
3277
|
-
const value = (0,
|
|
3179
|
+
const value = (0, import_react24.useMemo)(
|
|
3278
3180
|
() => ({
|
|
3279
3181
|
show: handleShow
|
|
3280
3182
|
}),
|
|
@@ -3408,7 +3310,7 @@ function PromptModal(props) {
|
|
|
3408
3310
|
] });
|
|
3409
3311
|
}
|
|
3410
3312
|
function usePromptModal() {
|
|
3411
|
-
const context = (0,
|
|
3313
|
+
const context = (0, import_react24.useContext)(PromptModalContext);
|
|
3412
3314
|
if (context === null) {
|
|
3413
3315
|
throw new Error("usePromptModal must be used within a PromptModal Provider");
|
|
3414
3316
|
}
|
|
@@ -3416,50 +3318,50 @@ function usePromptModal() {
|
|
|
3416
3318
|
}
|
|
3417
3319
|
|
|
3418
3320
|
// src/context/theme.tsx
|
|
3419
|
-
var
|
|
3321
|
+
var import_react26 = require("react");
|
|
3420
3322
|
|
|
3421
3323
|
// src/hooks/useTheme.ts
|
|
3422
|
-
var
|
|
3324
|
+
var import_react25 = require("react");
|
|
3423
3325
|
var THEME_KEY = "cerberus-theme";
|
|
3424
3326
|
var MODE_KEY = "cerberus-mode";
|
|
3425
3327
|
function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options = {}) {
|
|
3426
3328
|
const { updateMode, updateTheme, cache } = options;
|
|
3427
|
-
const [theme, setTheme] = (0,
|
|
3428
|
-
const [colorMode, setColorMode] = (0,
|
|
3429
|
-
const handleThemeChange = (0,
|
|
3329
|
+
const [theme, setTheme] = (0, import_react25.useState)(defaultTheme);
|
|
3330
|
+
const [colorMode, setColorMode] = (0, import_react25.useState)(defaultColorMode);
|
|
3331
|
+
const handleThemeChange = (0, import_react25.useCallback)(
|
|
3430
3332
|
(newTheme) => {
|
|
3431
3333
|
setTheme(newTheme);
|
|
3432
3334
|
updateTheme == null ? void 0 : updateTheme(newTheme);
|
|
3433
3335
|
},
|
|
3434
3336
|
[updateTheme]
|
|
3435
3337
|
);
|
|
3436
|
-
const handleColorModeChange = (0,
|
|
3338
|
+
const handleColorModeChange = (0, import_react25.useCallback)(
|
|
3437
3339
|
(newMode) => {
|
|
3438
3340
|
setColorMode(newMode);
|
|
3439
3341
|
updateMode == null ? void 0 : updateMode(newMode);
|
|
3440
3342
|
},
|
|
3441
3343
|
[updateMode]
|
|
3442
3344
|
);
|
|
3443
|
-
(0,
|
|
3345
|
+
(0, import_react25.useLayoutEffect)(() => {
|
|
3444
3346
|
const theme2 = localStorage.getItem(THEME_KEY);
|
|
3445
3347
|
if (theme2) {
|
|
3446
3348
|
setTheme(theme2);
|
|
3447
3349
|
}
|
|
3448
3350
|
}, []);
|
|
3449
|
-
(0,
|
|
3351
|
+
(0, import_react25.useLayoutEffect)(() => {
|
|
3450
3352
|
const mode = localStorage.getItem(MODE_KEY);
|
|
3451
3353
|
if (mode) {
|
|
3452
3354
|
setColorMode(mode);
|
|
3453
3355
|
}
|
|
3454
3356
|
}, []);
|
|
3455
|
-
(0,
|
|
3357
|
+
(0, import_react25.useEffect)(() => {
|
|
3456
3358
|
const root = document.documentElement;
|
|
3457
3359
|
root.dataset.pandaTheme = theme;
|
|
3458
3360
|
if (cache) {
|
|
3459
3361
|
localStorage.setItem(THEME_KEY, theme);
|
|
3460
3362
|
}
|
|
3461
3363
|
}, [theme, cache]);
|
|
3462
|
-
(0,
|
|
3364
|
+
(0, import_react25.useEffect)(() => {
|
|
3463
3365
|
const root = document.documentElement;
|
|
3464
3366
|
if (colorMode === "system") {
|
|
3465
3367
|
root.dataset.colorMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
@@ -3470,7 +3372,7 @@ function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options
|
|
|
3470
3372
|
localStorage.setItem(MODE_KEY, colorMode);
|
|
3471
3373
|
}
|
|
3472
3374
|
}, [colorMode, cache]);
|
|
3473
|
-
return (0,
|
|
3375
|
+
return (0, import_react25.useMemo)(
|
|
3474
3376
|
() => ({
|
|
3475
3377
|
theme,
|
|
3476
3378
|
mode: colorMode,
|
|
@@ -3483,7 +3385,7 @@ function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options
|
|
|
3483
3385
|
|
|
3484
3386
|
// src/context/theme.tsx
|
|
3485
3387
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
3486
|
-
var ThemeContext = (0,
|
|
3388
|
+
var ThemeContext = (0, import_react26.createContext)(
|
|
3487
3389
|
null
|
|
3488
3390
|
);
|
|
3489
3391
|
function ThemeProvider(props) {
|
|
@@ -3495,19 +3397,112 @@ function ThemeProvider(props) {
|
|
|
3495
3397
|
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(ThemeContext.Provider, { value: state, children: props.children });
|
|
3496
3398
|
}
|
|
3497
3399
|
function useThemeContext() {
|
|
3498
|
-
const context = (0,
|
|
3400
|
+
const context = (0, import_react26.useContext)(ThemeContext);
|
|
3499
3401
|
if (!context) {
|
|
3500
3402
|
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
3501
3403
|
}
|
|
3502
3404
|
return context;
|
|
3503
3405
|
}
|
|
3504
3406
|
|
|
3407
|
+
// src/hooks/useDate.ts
|
|
3408
|
+
var import_react27 = require("react");
|
|
3409
|
+
function useDate(options) {
|
|
3410
|
+
const initialValue = (options == null ? void 0 : options.initialValue) ?? "";
|
|
3411
|
+
const format = (options == null ? void 0 : options.format) ?? DateFormats.USMilitary;
|
|
3412
|
+
const onChange = options == null ? void 0 : options.onChange;
|
|
3413
|
+
const [value, setValue] = (0, import_react27.useState)(initialValue);
|
|
3414
|
+
const handleChange = (0, import_react27.useCallback)(
|
|
3415
|
+
(e) => {
|
|
3416
|
+
const newValue = formatMilitaryDate(e.currentTarget.value);
|
|
3417
|
+
if (onChange) onChange(e);
|
|
3418
|
+
setValue(newValue);
|
|
3419
|
+
},
|
|
3420
|
+
[onChange]
|
|
3421
|
+
);
|
|
3422
|
+
return (0, import_react27.useMemo)(
|
|
3423
|
+
() => ({
|
|
3424
|
+
format,
|
|
3425
|
+
value,
|
|
3426
|
+
ISO: formatMilitaryToISO(value),
|
|
3427
|
+
onChange: handleChange
|
|
3428
|
+
}),
|
|
3429
|
+
[format, value, handleChange]
|
|
3430
|
+
);
|
|
3431
|
+
}
|
|
3432
|
+
function formatMilitaryToISO(input3) {
|
|
3433
|
+
const [day, month, year] = input3.split(" ");
|
|
3434
|
+
const monthIndex = MONTHS.findIndex((m) => m.startsWith(month));
|
|
3435
|
+
const monthNum = monthIndex + 1;
|
|
3436
|
+
return `${year ?? "0000"}-${monthNum.toString().padStart(2, "0")}-${day.padStart(
|
|
3437
|
+
2,
|
|
3438
|
+
"0"
|
|
3439
|
+
)}`;
|
|
3440
|
+
}
|
|
3441
|
+
function formatMilitaryDate(input3) {
|
|
3442
|
+
let formatted = input3.toUpperCase().replace(/[^0-9A-Z]/g, "");
|
|
3443
|
+
let day = "";
|
|
3444
|
+
let month = "";
|
|
3445
|
+
let year = "";
|
|
3446
|
+
if (formatted.length >= 2) {
|
|
3447
|
+
day = formatted.replace(/[^0-9]/g, "").slice(0, 2);
|
|
3448
|
+
const dayNum = parseInt(day, 10);
|
|
3449
|
+
if (dayNum > 31) day = "31";
|
|
3450
|
+
else if (dayNum === 0) day = "01";
|
|
3451
|
+
formatted = formatted.slice(2);
|
|
3452
|
+
}
|
|
3453
|
+
if (formatted.length >= 3) {
|
|
3454
|
+
month = formatted.slice(0, 3);
|
|
3455
|
+
const monthIndex = MONTHS.findIndex((m) => m.startsWith(month));
|
|
3456
|
+
if (monthIndex !== -1) {
|
|
3457
|
+
month = MONTHS[monthIndex];
|
|
3458
|
+
} else {
|
|
3459
|
+
month = month.replace(/[^A-Z]/g, "");
|
|
3460
|
+
}
|
|
3461
|
+
formatted = formatted.slice(3);
|
|
3462
|
+
}
|
|
3463
|
+
if (formatted.length > 0) {
|
|
3464
|
+
year = formatted.slice(0, 4);
|
|
3465
|
+
}
|
|
3466
|
+
return [day, month, year].filter(Boolean).join(" ");
|
|
3467
|
+
}
|
|
3468
|
+
function formatISOToMilitary(date) {
|
|
3469
|
+
const [year, month, day] = date.split("-");
|
|
3470
|
+
const monthIndex = parseInt(month, 10) - 1;
|
|
3471
|
+
const monthStr = MONTHS[monthIndex];
|
|
3472
|
+
return `${day} ${monthStr} ${year}`;
|
|
3473
|
+
}
|
|
3474
|
+
var DateFormats = {
|
|
3475
|
+
get ISO() {
|
|
3476
|
+
return "YYYY-MM-DD";
|
|
3477
|
+
},
|
|
3478
|
+
get USMilitary() {
|
|
3479
|
+
return "DD MMM YYYY";
|
|
3480
|
+
},
|
|
3481
|
+
get Months() {
|
|
3482
|
+
return MONTHS;
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3485
|
+
var MONTHS = [
|
|
3486
|
+
"JAN",
|
|
3487
|
+
"FEB",
|
|
3488
|
+
"MAR",
|
|
3489
|
+
"APR",
|
|
3490
|
+
"MAY",
|
|
3491
|
+
"JUN",
|
|
3492
|
+
"JUL",
|
|
3493
|
+
"AUG",
|
|
3494
|
+
"SEP",
|
|
3495
|
+
"OCT",
|
|
3496
|
+
"NOV",
|
|
3497
|
+
"DEC"
|
|
3498
|
+
];
|
|
3499
|
+
|
|
3505
3500
|
// src/hooks/useToggle.ts
|
|
3506
|
-
var
|
|
3501
|
+
var import_react28 = require("react");
|
|
3507
3502
|
function useToggle(options) {
|
|
3508
|
-
const [checked, setChecked] = (0,
|
|
3503
|
+
const [checked, setChecked] = (0, import_react28.useState)((options == null ? void 0 : options.checked) ?? "");
|
|
3509
3504
|
const onChange = options == null ? void 0 : options.onChange;
|
|
3510
|
-
const handleChange = (0,
|
|
3505
|
+
const handleChange = (0, import_react28.useCallback)(
|
|
3511
3506
|
(e) => {
|
|
3512
3507
|
const target = e.currentTarget;
|
|
3513
3508
|
setChecked((prev) => {
|
|
@@ -3517,25 +3512,25 @@ function useToggle(options) {
|
|
|
3517
3512
|
},
|
|
3518
3513
|
[onChange]
|
|
3519
3514
|
);
|
|
3520
|
-
return (0,
|
|
3515
|
+
return (0, import_react28.useMemo)(() => ({ checked, handleChange }), [checked, handleChange]);
|
|
3521
3516
|
}
|
|
3522
3517
|
|
|
3523
3518
|
// src/hooks/useRootColors.ts
|
|
3524
|
-
var
|
|
3519
|
+
var import_react29 = require("react");
|
|
3525
3520
|
function useRootColors(colors = []) {
|
|
3526
|
-
const [state, dispatch] = (0,
|
|
3527
|
-
const handleRefetch = (0,
|
|
3521
|
+
const [state, dispatch] = (0, import_react29.useReducer)(rootColorsReducer, {});
|
|
3522
|
+
const handleRefetch = (0, import_react29.useCallback)(() => {
|
|
3528
3523
|
return new Promise((resolve) => {
|
|
3529
3524
|
dispatch(formatColors(colors));
|
|
3530
3525
|
resolve();
|
|
3531
3526
|
});
|
|
3532
3527
|
}, []);
|
|
3533
|
-
(0,
|
|
3528
|
+
(0, import_react29.useEffect)(() => {
|
|
3534
3529
|
if (Object.keys(state).length === colors.length) return;
|
|
3535
3530
|
dispatch(formatColors(colors));
|
|
3536
3531
|
console.log("updating colors in root hook");
|
|
3537
3532
|
}, [colors]);
|
|
3538
|
-
return (0,
|
|
3533
|
+
return (0, import_react29.useMemo)(
|
|
3539
3534
|
() => ({ colors: state, refetch: handleRefetch }),
|
|
3540
3535
|
[state, handleRefetch]
|
|
3541
3536
|
);
|