warqadui 0.0.46 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +388 -383
- package/dist/index.mjs +317 -312
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1142,12 +1142,17 @@ var useModal = (initialState = false) => {
|
|
|
1142
1142
|
};
|
|
1143
1143
|
};
|
|
1144
1144
|
|
|
1145
|
-
// src/
|
|
1145
|
+
// src/hooks/uploads/useAntdImageUpload.tsx
|
|
1146
1146
|
var import_react8 = require("react");
|
|
1147
|
+
var import_antd = require("antd");
|
|
1148
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1149
|
+
|
|
1150
|
+
// src/components/Fields/Input.tsx
|
|
1151
|
+
var import_react9 = require("react");
|
|
1147
1152
|
var import_lucide_react6 = require("lucide-react");
|
|
1148
1153
|
var import_react_hook_form = require("react-hook-form");
|
|
1149
|
-
var
|
|
1150
|
-
var Input = (0,
|
|
1154
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1155
|
+
var Input = (0, import_react9.forwardRef)(
|
|
1151
1156
|
({
|
|
1152
1157
|
label,
|
|
1153
1158
|
icon,
|
|
@@ -1162,11 +1167,11 @@ var Input = (0, import_react8.forwardRef)(
|
|
|
1162
1167
|
variant = "default",
|
|
1163
1168
|
...props
|
|
1164
1169
|
}, ref) => {
|
|
1165
|
-
const [isFocused, setIsFocused] = (0,
|
|
1166
|
-
const [showPassword, setShowPassword] = (0,
|
|
1170
|
+
const [isFocused, setIsFocused] = (0, import_react9.useState)(false);
|
|
1171
|
+
const [showPassword, setShowPassword] = (0, import_react9.useState)(false);
|
|
1167
1172
|
const { theme } = useWarqadConfig();
|
|
1168
1173
|
const primaryColor = theme?.primaryColor;
|
|
1169
|
-
(0,
|
|
1174
|
+
(0, import_react9.useEffect)(() => {
|
|
1170
1175
|
if (form && name && props.value !== void 0 && props.value !== null && props.value !== "") {
|
|
1171
1176
|
const currentFormValue = form.getValues(name);
|
|
1172
1177
|
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
@@ -1182,17 +1187,17 @@ var Input = (0, import_react8.forwardRef)(
|
|
|
1182
1187
|
const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
|
|
1183
1188
|
message = errorObj?.message;
|
|
1184
1189
|
}
|
|
1185
|
-
(0,
|
|
1190
|
+
(0, import_react9.useEffect)(() => {
|
|
1186
1191
|
if (form && name) {
|
|
1187
1192
|
form.clearErrors("root");
|
|
1188
1193
|
}
|
|
1189
1194
|
}, [form?.watch(name)]);
|
|
1190
|
-
const renderInput = (inputProps, localType = type || "text") => /* @__PURE__ */ (0,
|
|
1195
|
+
const renderInput = (inputProps, localType = type || "text") => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1191
1196
|
"div",
|
|
1192
1197
|
{
|
|
1193
1198
|
className: `${label ? "space-y-2" : ""} group relative ${containerClassName} `,
|
|
1194
1199
|
children: [
|
|
1195
|
-
label && /* @__PURE__ */ (0,
|
|
1200
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1196
1201
|
"label",
|
|
1197
1202
|
{
|
|
1198
1203
|
htmlFor: props.id,
|
|
@@ -1200,12 +1205,12 @@ var Input = (0, import_react8.forwardRef)(
|
|
|
1200
1205
|
style: { color: isFocused ? primaryColor : void 0 },
|
|
1201
1206
|
children: [
|
|
1202
1207
|
label,
|
|
1203
|
-
props.required && /* @__PURE__ */ (0,
|
|
1208
|
+
props.required && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-red-500 ml-1", children: "*" })
|
|
1204
1209
|
]
|
|
1205
1210
|
}
|
|
1206
1211
|
),
|
|
1207
|
-
/* @__PURE__ */ (0,
|
|
1208
|
-
icon && /* @__PURE__ */ (0,
|
|
1212
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "relative", children: [
|
|
1213
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "absolute inset-y-0 left-0 pl-2.5 flex items-center pointer-events-none", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1209
1214
|
"div",
|
|
1210
1215
|
{
|
|
1211
1216
|
className: `transition-colors duration-200`,
|
|
@@ -1213,7 +1218,7 @@ var Input = (0, import_react8.forwardRef)(
|
|
|
1213
1218
|
children: icon
|
|
1214
1219
|
}
|
|
1215
1220
|
) }),
|
|
1216
|
-
/* @__PURE__ */ (0,
|
|
1221
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1217
1222
|
"input",
|
|
1218
1223
|
{
|
|
1219
1224
|
ref,
|
|
@@ -1235,23 +1240,23 @@ var Input = (0, import_react8.forwardRef)(
|
|
|
1235
1240
|
type: localType === "password" ? showPassword ? "text" : "password" : localType
|
|
1236
1241
|
}
|
|
1237
1242
|
),
|
|
1238
|
-
type === "password" && /* @__PURE__ */ (0,
|
|
1243
|
+
type === "password" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1239
1244
|
"button",
|
|
1240
1245
|
{
|
|
1241
1246
|
type: "button",
|
|
1242
1247
|
onClick: () => setShowPassword(!showPassword),
|
|
1243
1248
|
className: "absolute inset-y-0 right-0 pr-2.5 flex items-center text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-colors focus:outline-none cursor-pointer",
|
|
1244
1249
|
tabIndex: -1,
|
|
1245
|
-
children: showPassword ? /* @__PURE__ */ (0,
|
|
1250
|
+
children: showPassword ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react6.EyeOff, { className: "h-5 w-5" }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react6.Eye, { className: "h-5 w-5" })
|
|
1246
1251
|
}
|
|
1247
1252
|
)
|
|
1248
1253
|
] }),
|
|
1249
|
-
message && /* @__PURE__ */ (0,
|
|
1254
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message })
|
|
1250
1255
|
]
|
|
1251
1256
|
}
|
|
1252
1257
|
);
|
|
1253
1258
|
if (form && name && type === "number") {
|
|
1254
|
-
return /* @__PURE__ */ (0,
|
|
1259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1255
1260
|
import_react_hook_form.Controller,
|
|
1256
1261
|
{
|
|
1257
1262
|
control: form.control,
|
|
@@ -1340,12 +1345,12 @@ var Input = (0, import_react8.forwardRef)(
|
|
|
1340
1345
|
);
|
|
1341
1346
|
|
|
1342
1347
|
// src/components/Fields/PhoneInput.tsx
|
|
1343
|
-
var
|
|
1348
|
+
var import_react10 = require("react");
|
|
1344
1349
|
var import_react_phone_number_input = __toESM(require("react-phone-number-input"));
|
|
1345
1350
|
var import_style = require("react-phone-number-input/style.css");
|
|
1346
1351
|
var import_react_hook_form2 = require("react-hook-form");
|
|
1347
|
-
var
|
|
1348
|
-
var PhoneInput = (0,
|
|
1352
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1353
|
+
var PhoneInput = (0, import_react10.forwardRef)(
|
|
1349
1354
|
({
|
|
1350
1355
|
label,
|
|
1351
1356
|
icon,
|
|
@@ -1358,7 +1363,7 @@ var PhoneInput = (0, import_react9.forwardRef)(
|
|
|
1358
1363
|
className = "",
|
|
1359
1364
|
...props
|
|
1360
1365
|
}, ref) => {
|
|
1361
|
-
const [isFocused, setIsFocused] = (0,
|
|
1366
|
+
const [isFocused, setIsFocused] = (0, import_react10.useState)(false);
|
|
1362
1367
|
const { theme } = useWarqadConfig();
|
|
1363
1368
|
const primaryColor = theme?.primaryColor;
|
|
1364
1369
|
let message = error;
|
|
@@ -1373,8 +1378,8 @@ var PhoneInput = (0, import_react9.forwardRef)(
|
|
|
1373
1378
|
}
|
|
1374
1379
|
message = currentError?.message || message;
|
|
1375
1380
|
}
|
|
1376
|
-
const renderInput = (onChangeHandler, currentValue) => /* @__PURE__ */ (0,
|
|
1377
|
-
/* @__PURE__ */ (0,
|
|
1381
|
+
const renderInput = (onChangeHandler, currentValue) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: `space-y-2 group relative ${containerClassName}`, children: [
|
|
1382
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1378
1383
|
"label",
|
|
1379
1384
|
{
|
|
1380
1385
|
className: `block text-xs font-medium transition-colors duration-200`,
|
|
@@ -1383,12 +1388,12 @@ var PhoneInput = (0, import_react9.forwardRef)(
|
|
|
1383
1388
|
},
|
|
1384
1389
|
children: [
|
|
1385
1390
|
label,
|
|
1386
|
-
props.required && /* @__PURE__ */ (0,
|
|
1391
|
+
props.required && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-red-500 ml-1", children: "*" })
|
|
1387
1392
|
]
|
|
1388
1393
|
}
|
|
1389
1394
|
),
|
|
1390
|
-
/* @__PURE__ */ (0,
|
|
1391
|
-
icon && /* @__PURE__ */ (0,
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "relative", children: [
|
|
1396
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "absolute inset-y-0 left-0 pl-2.5 flex items-center pointer-events-none z-10", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1392
1397
|
"div",
|
|
1393
1398
|
{
|
|
1394
1399
|
className: `transition-colors duration-200`,
|
|
@@ -1396,7 +1401,7 @@ var PhoneInput = (0, import_react9.forwardRef)(
|
|
|
1396
1401
|
children: icon
|
|
1397
1402
|
}
|
|
1398
1403
|
) }),
|
|
1399
|
-
/* @__PURE__ */ (0,
|
|
1404
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1400
1405
|
import_react_phone_number_input.default,
|
|
1401
1406
|
{
|
|
1402
1407
|
ref,
|
|
@@ -1416,10 +1421,10 @@ var PhoneInput = (0, import_react9.forwardRef)(
|
|
|
1416
1421
|
}
|
|
1417
1422
|
)
|
|
1418
1423
|
] }),
|
|
1419
|
-
message && /* @__PURE__ */ (0,
|
|
1424
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message })
|
|
1420
1425
|
] });
|
|
1421
1426
|
if (form && name) {
|
|
1422
|
-
return /* @__PURE__ */ (0,
|
|
1427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1423
1428
|
import_react_hook_form2.Controller,
|
|
1424
1429
|
{
|
|
1425
1430
|
name,
|
|
@@ -1438,21 +1443,21 @@ var PhoneInput = (0, import_react9.forwardRef)(
|
|
|
1438
1443
|
PhoneInput.displayName = "PhoneInput";
|
|
1439
1444
|
|
|
1440
1445
|
// src/components/Fields/select.tsx
|
|
1441
|
-
var
|
|
1446
|
+
var import_react11 = __toESM(require("react"));
|
|
1442
1447
|
var import_react_dom = require("react-dom");
|
|
1443
1448
|
var import_lucide_react7 = require("lucide-react");
|
|
1444
1449
|
var import_react_hook_form3 = require("react-hook-form");
|
|
1445
|
-
var
|
|
1446
|
-
var SelectContext = (0,
|
|
1450
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1451
|
+
var SelectContext = (0, import_react11.createContext)(void 0);
|
|
1447
1452
|
var useSelectContext = () => {
|
|
1448
|
-
const context = (0,
|
|
1453
|
+
const context = (0, import_react11.useContext)(SelectContext);
|
|
1449
1454
|
if (!context)
|
|
1450
1455
|
throw new Error("Select components must be used within a SelectProvider");
|
|
1451
1456
|
return context;
|
|
1452
1457
|
};
|
|
1453
|
-
var Select = (0,
|
|
1458
|
+
var Select = (0, import_react11.forwardRef)((props, ref) => {
|
|
1454
1459
|
const { form, name, onChange, value, children, options = [] } = props;
|
|
1455
|
-
(0,
|
|
1460
|
+
(0, import_react11.useEffect)(() => {
|
|
1456
1461
|
if (form && name && value !== void 0 && value !== null && value !== "") {
|
|
1457
1462
|
const currentFormValue = form.getValues(name);
|
|
1458
1463
|
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
@@ -1461,7 +1466,7 @@ var Select = (0, import_react10.forwardRef)((props, ref) => {
|
|
|
1461
1466
|
}
|
|
1462
1467
|
}, [value, name, form]);
|
|
1463
1468
|
if (form && name) {
|
|
1464
|
-
return /* @__PURE__ */ (0,
|
|
1469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1465
1470
|
import_react_hook_form3.Controller,
|
|
1466
1471
|
{
|
|
1467
1472
|
name,
|
|
@@ -1473,7 +1478,7 @@ var Select = (0, import_react10.forwardRef)((props, ref) => {
|
|
|
1473
1478
|
ref: fieldRef,
|
|
1474
1479
|
onBlur
|
|
1475
1480
|
}
|
|
1476
|
-
}) => /* @__PURE__ */ (0,
|
|
1481
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1477
1482
|
SelectRoot,
|
|
1478
1483
|
{
|
|
1479
1484
|
...props,
|
|
@@ -1490,7 +1495,7 @@ var Select = (0, import_react10.forwardRef)((props, ref) => {
|
|
|
1490
1495
|
}
|
|
1491
1496
|
);
|
|
1492
1497
|
}
|
|
1493
|
-
return /* @__PURE__ */ (0,
|
|
1498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1494
1499
|
SelectRoot,
|
|
1495
1500
|
{
|
|
1496
1501
|
...props,
|
|
@@ -1523,15 +1528,15 @@ var SelectRoot = ({
|
|
|
1523
1528
|
className = "",
|
|
1524
1529
|
...props
|
|
1525
1530
|
}) => {
|
|
1526
|
-
const [isOpen, setIsOpen] = (0,
|
|
1527
|
-
const [isFocused, setIsFocused] = (0,
|
|
1528
|
-
const [activeIndex, setActiveIndex] = (0,
|
|
1529
|
-
const [registeredOptions, setRegisteredOptions] = (0,
|
|
1531
|
+
const [isOpen, setIsOpen] = (0, import_react11.useState)(false);
|
|
1532
|
+
const [isFocused, setIsFocused] = (0, import_react11.useState)(false);
|
|
1533
|
+
const [activeIndex, setActiveIndex] = (0, import_react11.useState)(-1);
|
|
1534
|
+
const [registeredOptions, setRegisteredOptions] = (0, import_react11.useState)([]);
|
|
1530
1535
|
const { theme } = useWarqadConfig();
|
|
1531
1536
|
const primaryColor = theme?.primaryColor;
|
|
1532
|
-
const containerRef = (0,
|
|
1533
|
-
const dropdownAnchorRef = (0,
|
|
1534
|
-
const dropdownContentRef = (0,
|
|
1537
|
+
const containerRef = (0, import_react11.useRef)(null);
|
|
1538
|
+
const dropdownAnchorRef = (0, import_react11.useRef)(null);
|
|
1539
|
+
const dropdownContentRef = (0, import_react11.useRef)(null);
|
|
1535
1540
|
const registerOption = (opt) => {
|
|
1536
1541
|
setRegisteredOptions((prev) => {
|
|
1537
1542
|
const index = prev.findIndex((p) => p.value === opt.value);
|
|
@@ -1553,7 +1558,7 @@ var SelectRoot = ({
|
|
|
1553
1558
|
form.clearErrors(name);
|
|
1554
1559
|
}
|
|
1555
1560
|
};
|
|
1556
|
-
(0,
|
|
1561
|
+
(0, import_react11.useEffect)(() => {
|
|
1557
1562
|
const handleClickOutside = (event) => {
|
|
1558
1563
|
const target = event.target;
|
|
1559
1564
|
if (containerRef.current && !containerRef.current.contains(target) && !(dropdownContentRef.current && dropdownContentRef.current.contains(target))) {
|
|
@@ -1596,26 +1601,26 @@ var SelectRoot = ({
|
|
|
1596
1601
|
fieldInternalProps,
|
|
1597
1602
|
disabled
|
|
1598
1603
|
};
|
|
1599
|
-
const hasChildren =
|
|
1600
|
-
return /* @__PURE__ */ (0,
|
|
1604
|
+
const hasChildren = import_react11.default.Children.count(children) > 0;
|
|
1605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SelectContext.Provider, { value: valueCtx, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1601
1606
|
"div",
|
|
1602
1607
|
{
|
|
1603
1608
|
ref: containerRef,
|
|
1604
1609
|
className: `${label ? "space-y-2" : ""} group relative ${containerClassName}`,
|
|
1605
1610
|
children: [
|
|
1606
|
-
label && /* @__PURE__ */ (0,
|
|
1611
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1607
1612
|
"label",
|
|
1608
1613
|
{
|
|
1609
1614
|
className: `block text-xs font-medium transition-colors duration-200`,
|
|
1610
1615
|
style: { color: isFocused || isOpen ? primaryColor : void 0 },
|
|
1611
1616
|
children: [
|
|
1612
1617
|
label,
|
|
1613
|
-
required && /* @__PURE__ */ (0,
|
|
1618
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-red-500 ml-1", children: "*" })
|
|
1614
1619
|
]
|
|
1615
1620
|
}
|
|
1616
1621
|
),
|
|
1617
|
-
hasChildren ? children : /* @__PURE__ */ (0,
|
|
1618
|
-
/* @__PURE__ */ (0,
|
|
1622
|
+
hasChildren ? children : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1619
1624
|
SelectTrigger,
|
|
1620
1625
|
{
|
|
1621
1626
|
id,
|
|
@@ -1626,7 +1631,7 @@ var SelectRoot = ({
|
|
|
1626
1631
|
...props
|
|
1627
1632
|
}
|
|
1628
1633
|
),
|
|
1629
|
-
allOptions && allOptions.length > 0 && /* @__PURE__ */ (0,
|
|
1634
|
+
allOptions && allOptions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SelectContent, { children: allOptions.map((opt, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1630
1635
|
SelectItem,
|
|
1631
1636
|
{
|
|
1632
1637
|
value: opt.value,
|
|
@@ -1636,12 +1641,12 @@ var SelectRoot = ({
|
|
|
1636
1641
|
String(opt.value) || index
|
|
1637
1642
|
)) })
|
|
1638
1643
|
] }),
|
|
1639
|
-
message && /* @__PURE__ */ (0,
|
|
1644
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message })
|
|
1640
1645
|
]
|
|
1641
1646
|
}
|
|
1642
1647
|
) });
|
|
1643
1648
|
};
|
|
1644
|
-
var SelectTrigger = (0,
|
|
1649
|
+
var SelectTrigger = (0, import_react11.forwardRef)(
|
|
1645
1650
|
({
|
|
1646
1651
|
className = "",
|
|
1647
1652
|
variant = "default",
|
|
@@ -1665,10 +1670,10 @@ var SelectTrigger = (0, import_react10.forwardRef)(
|
|
|
1665
1670
|
fieldInternalProps,
|
|
1666
1671
|
disabled
|
|
1667
1672
|
} = useSelectContext();
|
|
1668
|
-
const lastFocusTime = (0,
|
|
1673
|
+
const lastFocusTime = (0, import_react11.useRef)(0);
|
|
1669
1674
|
const displayOption = options.find((o) => o.value === selectedValue);
|
|
1670
1675
|
const displayValue = displayOption ? displayOption.label : selectedValue != null && selectedValue !== "" ? String(selectedValue) : placeholder;
|
|
1671
|
-
return /* @__PURE__ */ (0,
|
|
1676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "relative", ref: dropdownAnchorRef, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1672
1677
|
"div",
|
|
1673
1678
|
{
|
|
1674
1679
|
id,
|
|
@@ -1717,8 +1722,8 @@ var SelectTrigger = (0, import_react10.forwardRef)(
|
|
|
1717
1722
|
}
|
|
1718
1723
|
},
|
|
1719
1724
|
...props,
|
|
1720
|
-
children: children ? children : /* @__PURE__ */ (0,
|
|
1721
|
-
icon && /* @__PURE__ */ (0,
|
|
1725
|
+
children: children ? children : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
1726
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1722
1727
|
"div",
|
|
1723
1728
|
{
|
|
1724
1729
|
className: `pl-2.5 pr-2 flex items-center transition-colors duration-200`,
|
|
@@ -1728,14 +1733,14 @@ var SelectTrigger = (0, import_react10.forwardRef)(
|
|
|
1728
1733
|
children: icon
|
|
1729
1734
|
}
|
|
1730
1735
|
),
|
|
1731
|
-
/* @__PURE__ */ (0,
|
|
1736
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1732
1737
|
"div",
|
|
1733
1738
|
{
|
|
1734
1739
|
className: `flex-1 truncate text-sm ${icon ? "" : "pl-2.5"} ${!selectedValue && selectedValue !== 0 && selectedValue !== false ? "text-gray-400 dark:text-zinc-500" : ""}`,
|
|
1735
1740
|
children: displayValue
|
|
1736
1741
|
}
|
|
1737
1742
|
),
|
|
1738
|
-
/* @__PURE__ */ (0,
|
|
1743
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "pr-2.5 flex items-center gap-1 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1739
1744
|
import_lucide_react7.ChevronDown,
|
|
1740
1745
|
{
|
|
1741
1746
|
className: `h-4 w-4 text-gray-400 transition-transform ${isOpen ? "rotate-180" : ""}`
|
|
@@ -1747,10 +1752,10 @@ var SelectTrigger = (0, import_react10.forwardRef)(
|
|
|
1747
1752
|
}
|
|
1748
1753
|
);
|
|
1749
1754
|
SelectTrigger.displayName = "SelectTrigger";
|
|
1750
|
-
var SelectContent = (0,
|
|
1755
|
+
var SelectContent = (0, import_react11.forwardRef)(
|
|
1751
1756
|
({ children, className = "", style, ...props }, ref) => {
|
|
1752
1757
|
const { isOpen, setIsOpen, dropdownAnchorRef, dropdownContentRef } = useSelectContext();
|
|
1753
|
-
const [dropdownStyle, setDropdownStyle] = (0,
|
|
1758
|
+
const [dropdownStyle, setDropdownStyle] = (0, import_react11.useState)({});
|
|
1754
1759
|
const updateDropdownPosition = () => {
|
|
1755
1760
|
if (dropdownAnchorRef.current) {
|
|
1756
1761
|
const rect = dropdownAnchorRef.current.getBoundingClientRect();
|
|
@@ -1768,7 +1773,7 @@ var SelectContent = (0, import_react10.forwardRef)(
|
|
|
1768
1773
|
setDropdownStyle(newStyle);
|
|
1769
1774
|
}
|
|
1770
1775
|
};
|
|
1771
|
-
(0,
|
|
1776
|
+
(0, import_react11.useEffect)(() => {
|
|
1772
1777
|
if (isOpen) {
|
|
1773
1778
|
updateDropdownPosition();
|
|
1774
1779
|
window.addEventListener("scroll", updateDropdownPosition, true);
|
|
@@ -1781,7 +1786,7 @@ var SelectContent = (0, import_react10.forwardRef)(
|
|
|
1781
1786
|
}, [isOpen]);
|
|
1782
1787
|
if (!isOpen || typeof document === "undefined") return null;
|
|
1783
1788
|
return (0, import_react_dom.createPortal)(
|
|
1784
|
-
/* @__PURE__ */ (0,
|
|
1789
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1785
1790
|
"div",
|
|
1786
1791
|
{
|
|
1787
1792
|
ref: dropdownContentRef,
|
|
@@ -1789,7 +1794,7 @@ var SelectContent = (0, import_react10.forwardRef)(
|
|
|
1789
1794
|
style: { ...dropdownStyle, ...style },
|
|
1790
1795
|
onMouseDown: (e) => e.stopPropagation(),
|
|
1791
1796
|
...props,
|
|
1792
|
-
children: /* @__PURE__ */ (0,
|
|
1797
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex flex-col gap-0.5", children: import_react11.default.Children.count(children) === 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "p-3 text-center text-sm text-gray-500", children: "No options available" }) : children })
|
|
1793
1798
|
}
|
|
1794
1799
|
),
|
|
1795
1800
|
document.body
|
|
@@ -1797,7 +1802,7 @@ var SelectContent = (0, import_react10.forwardRef)(
|
|
|
1797
1802
|
}
|
|
1798
1803
|
);
|
|
1799
1804
|
SelectContent.displayName = "SelectContent";
|
|
1800
|
-
var SelectItem = (0,
|
|
1805
|
+
var SelectItem = (0, import_react11.forwardRef)(
|
|
1801
1806
|
({ value, label, disabled, children, className = "", ...props }, ref) => {
|
|
1802
1807
|
const {
|
|
1803
1808
|
selectedValue,
|
|
@@ -1809,7 +1814,7 @@ var SelectItem = (0, import_react10.forwardRef)(
|
|
|
1809
1814
|
} = useSelectContext();
|
|
1810
1815
|
const isSelected = selectedValue === value;
|
|
1811
1816
|
const displayLabel = label || children || value;
|
|
1812
|
-
(0,
|
|
1817
|
+
(0, import_react11.useEffect)(() => {
|
|
1813
1818
|
if (value !== void 0) {
|
|
1814
1819
|
registerOption({ value, label: String(displayLabel), disabled });
|
|
1815
1820
|
}
|
|
@@ -1820,7 +1825,7 @@ var SelectItem = (0, import_react10.forwardRef)(
|
|
|
1820
1825
|
setIsOpen(false);
|
|
1821
1826
|
fieldInternalProps?.onBlur?.();
|
|
1822
1827
|
};
|
|
1823
|
-
return /* @__PURE__ */ (0,
|
|
1828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1824
1829
|
"button",
|
|
1825
1830
|
{
|
|
1826
1831
|
ref,
|
|
@@ -1836,8 +1841,8 @@ var SelectItem = (0, import_react10.forwardRef)(
|
|
|
1836
1841
|
},
|
|
1837
1842
|
...props,
|
|
1838
1843
|
children: [
|
|
1839
|
-
/* @__PURE__ */ (0,
|
|
1840
|
-
isSelected && /* @__PURE__ */ (0,
|
|
1844
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "whitespace-nowrap truncate flex-1", children: children || label }),
|
|
1845
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1841
1846
|
import_lucide_react7.Check,
|
|
1842
1847
|
{
|
|
1843
1848
|
className: "h-4 w-4 shrink-0 ml-2",
|
|
@@ -1852,10 +1857,10 @@ var SelectItem = (0, import_react10.forwardRef)(
|
|
|
1852
1857
|
SelectItem.displayName = "SelectItem";
|
|
1853
1858
|
|
|
1854
1859
|
// src/components/Fields/textArea.tsx
|
|
1855
|
-
var
|
|
1860
|
+
var import_react12 = require("react");
|
|
1856
1861
|
var import_react_hook_form4 = require("react-hook-form");
|
|
1857
|
-
var
|
|
1858
|
-
var Textarea = (0,
|
|
1862
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1863
|
+
var Textarea = (0, import_react12.forwardRef)(
|
|
1859
1864
|
({
|
|
1860
1865
|
label,
|
|
1861
1866
|
error,
|
|
@@ -1867,7 +1872,7 @@ var Textarea = (0, import_react11.forwardRef)(
|
|
|
1867
1872
|
className = "",
|
|
1868
1873
|
...props
|
|
1869
1874
|
}, ref) => {
|
|
1870
|
-
const [isFocused, setIsFocused] = (0,
|
|
1875
|
+
const [isFocused, setIsFocused] = (0, import_react12.useState)(false);
|
|
1871
1876
|
const { theme } = useWarqadConfig();
|
|
1872
1877
|
const primaryColor = theme?.primaryColor;
|
|
1873
1878
|
let message = error;
|
|
@@ -1878,8 +1883,8 @@ var Textarea = (0, import_react11.forwardRef)(
|
|
|
1878
1883
|
const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
|
|
1879
1884
|
message = errorObj?.message;
|
|
1880
1885
|
}
|
|
1881
|
-
const renderInput = (inputProps, ref2) => /* @__PURE__ */ (0,
|
|
1882
|
-
/* @__PURE__ */ (0,
|
|
1886
|
+
const renderInput = (inputProps, ref2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `space-y-2 group w-full! relative ${containerClassName}`, children: [
|
|
1887
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
1883
1888
|
"label",
|
|
1884
1889
|
{
|
|
1885
1890
|
htmlFor: props.id,
|
|
@@ -1887,11 +1892,11 @@ var Textarea = (0, import_react11.forwardRef)(
|
|
|
1887
1892
|
style: { color: isFocused ? primaryColor : void 0 },
|
|
1888
1893
|
children: [
|
|
1889
1894
|
label,
|
|
1890
|
-
props.required && /* @__PURE__ */ (0,
|
|
1895
|
+
props.required && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "text-red-500 ml-1", children: "*" })
|
|
1891
1896
|
]
|
|
1892
1897
|
}
|
|
1893
1898
|
),
|
|
1894
|
-
/* @__PURE__ */ (0,
|
|
1899
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "relative", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1895
1900
|
"textarea",
|
|
1896
1901
|
{
|
|
1897
1902
|
ref: ref2,
|
|
@@ -1912,9 +1917,9 @@ var Textarea = (0, import_react11.forwardRef)(
|
|
|
1912
1917
|
...inputProps
|
|
1913
1918
|
}
|
|
1914
1919
|
) }),
|
|
1915
|
-
message && /* @__PURE__ */ (0,
|
|
1920
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message })
|
|
1916
1921
|
] });
|
|
1917
|
-
(0,
|
|
1922
|
+
(0, import_react12.useEffect)(() => {
|
|
1918
1923
|
if (form && name && props.value !== void 0 && props.value !== null && props.value !== "") {
|
|
1919
1924
|
const currentFormValue = form.getValues(name);
|
|
1920
1925
|
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
@@ -1923,7 +1928,7 @@ var Textarea = (0, import_react11.forwardRef)(
|
|
|
1923
1928
|
}
|
|
1924
1929
|
}, [props.value, name, form]);
|
|
1925
1930
|
if (form && name) {
|
|
1926
|
-
return /* @__PURE__ */ (0,
|
|
1931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1927
1932
|
import_react_hook_form4.Controller,
|
|
1928
1933
|
{
|
|
1929
1934
|
control: form.control,
|
|
@@ -1959,26 +1964,26 @@ var Textarea = (0, import_react11.forwardRef)(
|
|
|
1959
1964
|
);
|
|
1960
1965
|
|
|
1961
1966
|
// src/components/Fields/searchApi.tsx
|
|
1962
|
-
var
|
|
1967
|
+
var import_react14 = require("react");
|
|
1963
1968
|
var import_react_dom2 = require("react-dom");
|
|
1964
1969
|
var import_lucide_react8 = require("lucide-react");
|
|
1965
1970
|
|
|
1966
1971
|
// src/hooks/Fetches/useApis.tsx
|
|
1967
|
-
var
|
|
1972
|
+
var import_react13 = require("react");
|
|
1968
1973
|
var import_axios = __toESM(require("axios"));
|
|
1969
1974
|
var useApi = () => {
|
|
1970
1975
|
const { api: configApi } = useWarqadConfig();
|
|
1971
|
-
const api = (0,
|
|
1976
|
+
const api = (0, import_react13.useMemo)(() => {
|
|
1972
1977
|
const baseURL = configApi || "/api";
|
|
1973
1978
|
return import_axios.default.create({
|
|
1974
1979
|
baseURL,
|
|
1975
1980
|
withCredentials: true
|
|
1976
1981
|
});
|
|
1977
1982
|
}, [configApi]);
|
|
1978
|
-
const [data, setData] = (0,
|
|
1979
|
-
const [isLoading, setIsLoading] = (0,
|
|
1980
|
-
const [pdfLoading, setPdfLoading] = (0,
|
|
1981
|
-
const [error, setError] = (0,
|
|
1983
|
+
const [data, setData] = (0, import_react13.useState)();
|
|
1984
|
+
const [isLoading, setIsLoading] = (0, import_react13.useState)(false);
|
|
1985
|
+
const [pdfLoading, setPdfLoading] = (0, import_react13.useState)(false);
|
|
1986
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
1982
1987
|
const get = async ({ url, v = 1, params, delay }) => {
|
|
1983
1988
|
setIsLoading(true);
|
|
1984
1989
|
try {
|
|
@@ -2130,22 +2135,22 @@ var useApis_default = useApi;
|
|
|
2130
2135
|
|
|
2131
2136
|
// src/components/Fields/searchApi.tsx
|
|
2132
2137
|
var import_react_hook_form5 = require("react-hook-form");
|
|
2133
|
-
var
|
|
2134
|
-
var SearchApiContext = (0,
|
|
2138
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2139
|
+
var SearchApiContext = (0, import_react14.createContext)(
|
|
2135
2140
|
void 0
|
|
2136
2141
|
);
|
|
2137
2142
|
var useSearchApiContext = () => {
|
|
2138
|
-
const context = (0,
|
|
2143
|
+
const context = (0, import_react14.useContext)(SearchApiContext);
|
|
2139
2144
|
if (!context)
|
|
2140
2145
|
throw new Error(
|
|
2141
2146
|
"SearchApi components must be used within a SearchApiProvider"
|
|
2142
2147
|
);
|
|
2143
2148
|
return context;
|
|
2144
2149
|
};
|
|
2145
|
-
var SearchApi = (0,
|
|
2150
|
+
var SearchApi = (0, import_react14.forwardRef)(
|
|
2146
2151
|
(props, _) => {
|
|
2147
2152
|
const { form, name, onChange, onSelect, onClear, value, children, ...restProps } = props;
|
|
2148
|
-
(0,
|
|
2153
|
+
(0, import_react14.useEffect)(() => {
|
|
2149
2154
|
if (form && name && value !== void 0 && value !== null && value !== "") {
|
|
2150
2155
|
const currentFormValue = form.getValues(name);
|
|
2151
2156
|
if (currentFormValue === void 0 || currentFormValue === "" || currentFormValue === 0) {
|
|
@@ -2154,12 +2159,12 @@ var SearchApi = (0, import_react13.forwardRef)(
|
|
|
2154
2159
|
}
|
|
2155
2160
|
}, [value, name, form]);
|
|
2156
2161
|
if (form && name) {
|
|
2157
|
-
return /* @__PURE__ */ (0,
|
|
2162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2158
2163
|
import_react_hook_form5.Controller,
|
|
2159
2164
|
{
|
|
2160
2165
|
name,
|
|
2161
2166
|
control: form.control,
|
|
2162
|
-
render: ({ field }) => /* @__PURE__ */ (0,
|
|
2167
|
+
render: ({ field }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2163
2168
|
SearchApiRoot,
|
|
2164
2169
|
{
|
|
2165
2170
|
...restProps,
|
|
@@ -2179,7 +2184,7 @@ var SearchApi = (0, import_react13.forwardRef)(
|
|
|
2179
2184
|
}
|
|
2180
2185
|
);
|
|
2181
2186
|
}
|
|
2182
|
-
return /* @__PURE__ */ (0,
|
|
2187
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2183
2188
|
SearchApiRoot,
|
|
2184
2189
|
{
|
|
2185
2190
|
...restProps,
|
|
@@ -2222,20 +2227,20 @@ var SearchApiRoot = ({
|
|
|
2222
2227
|
className = "",
|
|
2223
2228
|
...props
|
|
2224
2229
|
}) => {
|
|
2225
|
-
const [searchTerm, setSearchTerm] = (0,
|
|
2230
|
+
const [searchTerm, setSearchTerm] = (0, import_react14.useState)("");
|
|
2226
2231
|
const { theme } = useWarqadConfig();
|
|
2227
2232
|
const primaryColor = theme?.primaryColor;
|
|
2228
|
-
const [options, setOptions] = (0,
|
|
2229
|
-
const [isOpen, setIsOpen] = (0,
|
|
2230
|
-
const [isFocused, setIsFocused] = (0,
|
|
2231
|
-
const [activeIndex, setActiveIndex] = (0,
|
|
2232
|
-
const [selectedObject, setSelectedObject] = (0,
|
|
2233
|
-
const [hasAttemptedHydration, setHasAttemptedHydration] = (0,
|
|
2234
|
-
const containerRef = (0,
|
|
2235
|
-
const dropdownAnchorRef = (0,
|
|
2236
|
-
const dropdownContentRef = (0,
|
|
2237
|
-
const inputRef = (0,
|
|
2238
|
-
const prevApiRef = (0,
|
|
2233
|
+
const [options, setOptions] = (0, import_react14.useState)([]);
|
|
2234
|
+
const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
|
|
2235
|
+
const [isFocused, setIsFocused] = (0, import_react14.useState)(false);
|
|
2236
|
+
const [activeIndex, setActiveIndex] = (0, import_react14.useState)(-1);
|
|
2237
|
+
const [selectedObject, setSelectedObject] = (0, import_react14.useState)(void 0);
|
|
2238
|
+
const [hasAttemptedHydration, setHasAttemptedHydration] = (0, import_react14.useState)(false);
|
|
2239
|
+
const containerRef = (0, import_react14.useRef)(null);
|
|
2240
|
+
const dropdownAnchorRef = (0, import_react14.useRef)(null);
|
|
2241
|
+
const dropdownContentRef = (0, import_react14.useRef)(null);
|
|
2242
|
+
const inputRef = (0, import_react14.useRef)(null);
|
|
2243
|
+
const prevApiRef = (0, import_react14.useRef)(api);
|
|
2239
2244
|
const { get, isLoading, error: errorMessage } = useApis_default();
|
|
2240
2245
|
const fetchOptions = async (query) => {
|
|
2241
2246
|
try {
|
|
@@ -2267,7 +2272,7 @@ var SearchApiRoot = ({
|
|
|
2267
2272
|
setOptions([]);
|
|
2268
2273
|
}
|
|
2269
2274
|
};
|
|
2270
|
-
(0,
|
|
2275
|
+
(0, import_react14.useEffect)(() => {
|
|
2271
2276
|
const timer = setTimeout(() => {
|
|
2272
2277
|
if (isOpen) {
|
|
2273
2278
|
fetchOptions(searchTerm);
|
|
@@ -2275,12 +2280,12 @@ var SearchApiRoot = ({
|
|
|
2275
2280
|
}, 300);
|
|
2276
2281
|
return () => clearTimeout(timer);
|
|
2277
2282
|
}, [searchTerm, api, isOpen]);
|
|
2278
|
-
(0,
|
|
2283
|
+
(0, import_react14.useEffect)(() => {
|
|
2279
2284
|
if (isOpen && options.length === 0) {
|
|
2280
2285
|
fetchOptions("");
|
|
2281
2286
|
}
|
|
2282
2287
|
}, [isOpen]);
|
|
2283
|
-
(0,
|
|
2288
|
+
(0, import_react14.useEffect)(() => {
|
|
2284
2289
|
if (currentValue !== void 0 && currentValue !== null && currentValue !== "" && !selectedObject) {
|
|
2285
2290
|
setHasAttemptedHydration(false);
|
|
2286
2291
|
fetchOptions(currentValue).finally(() => {
|
|
@@ -2297,7 +2302,7 @@ var SearchApiRoot = ({
|
|
|
2297
2302
|
}
|
|
2298
2303
|
return option[valueKey];
|
|
2299
2304
|
};
|
|
2300
|
-
(0,
|
|
2305
|
+
(0, import_react14.useEffect)(() => {
|
|
2301
2306
|
if (currentValue !== void 0 && currentValue !== null && currentValue !== "" && !selectedObject && options.length > 0) {
|
|
2302
2307
|
const found = options.find((o) => getOptionValue(o) === currentValue);
|
|
2303
2308
|
if (found) {
|
|
@@ -2311,7 +2316,7 @@ var SearchApiRoot = ({
|
|
|
2311
2316
|
}
|
|
2312
2317
|
}
|
|
2313
2318
|
}, [currentValue, options, obj]);
|
|
2314
|
-
(0,
|
|
2319
|
+
(0, import_react14.useEffect)(() => {
|
|
2315
2320
|
if (prevApiRef.current !== api) {
|
|
2316
2321
|
prevApiRef.current = api;
|
|
2317
2322
|
setSearchTerm("");
|
|
@@ -2336,7 +2341,7 @@ var SearchApiRoot = ({
|
|
|
2336
2341
|
fetchOptions("");
|
|
2337
2342
|
}
|
|
2338
2343
|
}, [api, name, obj]);
|
|
2339
|
-
(0,
|
|
2344
|
+
(0, import_react14.useEffect)(() => {
|
|
2340
2345
|
const handleClickOutside = (event) => {
|
|
2341
2346
|
const target = event.target;
|
|
2342
2347
|
if (containerRef.current && !containerRef.current.contains(target) && !(dropdownContentRef.current && dropdownContentRef.current.contains(target))) {
|
|
@@ -2447,26 +2452,26 @@ var SearchApiRoot = ({
|
|
|
2447
2452
|
onClear
|
|
2448
2453
|
};
|
|
2449
2454
|
const hasChildren = !!children;
|
|
2450
|
-
return /* @__PURE__ */ (0,
|
|
2455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SearchApiContext.Provider, { value: valueCtx, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2451
2456
|
"div",
|
|
2452
2457
|
{
|
|
2453
2458
|
ref: containerRef,
|
|
2454
2459
|
className: `${label ? "space-y-2" : ""} group relative ${containerClassName}`,
|
|
2455
2460
|
children: [
|
|
2456
|
-
label && /* @__PURE__ */ (0,
|
|
2461
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2457
2462
|
"label",
|
|
2458
2463
|
{
|
|
2459
2464
|
className: `block text-xs font-medium transition-colors duration-200`,
|
|
2460
2465
|
style: { color: isFocused || isOpen ? primaryColor : void 0 },
|
|
2461
2466
|
children: [
|
|
2462
2467
|
label,
|
|
2463
|
-
required && /* @__PURE__ */ (0,
|
|
2468
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-red-500 ml-1", children: "*" })
|
|
2464
2469
|
]
|
|
2465
2470
|
}
|
|
2466
2471
|
),
|
|
2467
|
-
hasChildren ? children : /* @__PURE__ */ (0,
|
|
2468
|
-
/* @__PURE__ */ (0,
|
|
2469
|
-
/* @__PURE__ */ (0,
|
|
2472
|
+
hasChildren ? children : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
2473
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SearchApiTrigger, { className, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SearchApiInput, { ...props }) }),
|
|
2474
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SearchApiContent, { children: filteredOptions.map((opt, index) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2470
2475
|
SearchApiItem,
|
|
2471
2476
|
{
|
|
2472
2477
|
option: opt,
|
|
@@ -2479,7 +2484,7 @@ var SearchApiRoot = ({
|
|
|
2479
2484
|
}
|
|
2480
2485
|
) });
|
|
2481
2486
|
};
|
|
2482
|
-
var SearchApiTrigger = (0,
|
|
2487
|
+
var SearchApiTrigger = (0, import_react14.forwardRef)(
|
|
2483
2488
|
({ className = "", children, ...props }, ref) => {
|
|
2484
2489
|
const {
|
|
2485
2490
|
isOpen,
|
|
@@ -2496,7 +2501,7 @@ var SearchApiTrigger = (0, import_react13.forwardRef)(
|
|
|
2496
2501
|
inputRef,
|
|
2497
2502
|
searchTerm
|
|
2498
2503
|
} = useSearchApiContext();
|
|
2499
|
-
return /* @__PURE__ */ (0,
|
|
2504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "relative", ref: dropdownAnchorRef, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2500
2505
|
"div",
|
|
2501
2506
|
{
|
|
2502
2507
|
className: `flex items-center w-full px-0 text-gray-900 dark:text-white transition-all duration-200 cursor-text py-1 ${variant === "ghost" ? "bg-transparent border-transparent shadow-none px-0 h-full" : isFocused || isOpen ? "ring-2 bg-white dark:bg-zinc-900 border rounded-xl h-9" : "border-gray-200 dark:border-zinc-800 border rounded-xl bg-white dark:bg-zinc-900/50 h-9"} ${className}`,
|
|
@@ -2513,25 +2518,25 @@ var SearchApiTrigger = (0, import_react13.forwardRef)(
|
|
|
2513
2518
|
},
|
|
2514
2519
|
...props,
|
|
2515
2520
|
children: [
|
|
2516
|
-
/* @__PURE__ */ (0,
|
|
2521
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2517
2522
|
"div",
|
|
2518
2523
|
{
|
|
2519
2524
|
className: `${variant === "ghost" ? "pl-0" : "pl-2.5"} text-gray-400`,
|
|
2520
|
-
children: /* @__PURE__ */ (0,
|
|
2525
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react8.Search, { className: "h-4 w-4" })
|
|
2521
2526
|
}
|
|
2522
2527
|
),
|
|
2523
|
-
/* @__PURE__ */ (0,
|
|
2524
|
-
/* @__PURE__ */ (0,
|
|
2525
|
-
selectedValue && !disabled && /* @__PURE__ */ (0,
|
|
2528
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex-1 relative ms-2", children }),
|
|
2529
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "pr-2.5 w-16! flex items-center gap-1 shrink-0 min-w-10 justify-end", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react8.Loader2, { className: "h-4 w-4 animate-spin text-blue-500 shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2530
|
+
selectedValue && !disabled && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2526
2531
|
"button",
|
|
2527
2532
|
{
|
|
2528
2533
|
onClick: clearSelection,
|
|
2529
2534
|
type: "button",
|
|
2530
2535
|
className: "p-0.5 hover:bg-gray-200 dark:hover:bg-zinc-700 rounded-full text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",
|
|
2531
|
-
children: /* @__PURE__ */ (0,
|
|
2536
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react8.X, { className: "h-3 w-3" })
|
|
2532
2537
|
}
|
|
2533
2538
|
),
|
|
2534
|
-
/* @__PURE__ */ (0,
|
|
2539
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2535
2540
|
import_lucide_react8.ChevronDown,
|
|
2536
2541
|
{
|
|
2537
2542
|
className: `h-4 w-4 text-gray-400 transition-transform ${isOpen ? "rotate-180" : ""}`
|
|
@@ -2544,7 +2549,7 @@ var SearchApiTrigger = (0, import_react13.forwardRef)(
|
|
|
2544
2549
|
}
|
|
2545
2550
|
);
|
|
2546
2551
|
SearchApiTrigger.displayName = "SearchApiTrigger";
|
|
2547
|
-
var SearchApiInput = (0,
|
|
2552
|
+
var SearchApiInput = (0, import_react14.forwardRef)(
|
|
2548
2553
|
({ className = "", ...props }, ref) => {
|
|
2549
2554
|
const {
|
|
2550
2555
|
isOpen,
|
|
@@ -2611,9 +2616,9 @@ var SearchApiInput = (0, import_react13.forwardRef)(
|
|
|
2611
2616
|
break;
|
|
2612
2617
|
}
|
|
2613
2618
|
};
|
|
2614
|
-
return /* @__PURE__ */ (0,
|
|
2615
|
-
!isOpen && (selectedValue !== void 0 && selectedValue !== null && selectedValue !== "") && /* @__PURE__ */ (0,
|
|
2616
|
-
/* @__PURE__ */ (0,
|
|
2619
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
2620
|
+
!isOpen && (selectedValue !== void 0 && selectedValue !== null && selectedValue !== "") && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "absolute inset-0 flex items-center ms-1 truncate select-none", children: getDisplayValue() }),
|
|
2621
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2617
2622
|
"input",
|
|
2618
2623
|
{
|
|
2619
2624
|
ref: setInternalInputRef,
|
|
@@ -2656,7 +2661,7 @@ var SearchApiInput = (0, import_react13.forwardRef)(
|
|
|
2656
2661
|
}
|
|
2657
2662
|
);
|
|
2658
2663
|
SearchApiInput.displayName = "SearchApiInput";
|
|
2659
|
-
var SearchApiContent = (0,
|
|
2664
|
+
var SearchApiContent = (0, import_react14.forwardRef)(
|
|
2660
2665
|
({ children, className = "", style, ...props }, ref) => {
|
|
2661
2666
|
const {
|
|
2662
2667
|
isOpen,
|
|
@@ -2668,7 +2673,7 @@ var SearchApiContent = (0, import_react13.forwardRef)(
|
|
|
2668
2673
|
options,
|
|
2669
2674
|
error
|
|
2670
2675
|
} = useSearchApiContext();
|
|
2671
|
-
const [dropdownStyle, setDropdownStyle] = (0,
|
|
2676
|
+
const [dropdownStyle, setDropdownStyle] = (0, import_react14.useState)({});
|
|
2672
2677
|
const updateDropdownPosition = () => {
|
|
2673
2678
|
if (dropdownAnchorRef.current) {
|
|
2674
2679
|
const rect = dropdownAnchorRef.current.getBoundingClientRect();
|
|
@@ -2686,7 +2691,7 @@ var SearchApiContent = (0, import_react13.forwardRef)(
|
|
|
2686
2691
|
setDropdownStyle(newStyle);
|
|
2687
2692
|
}
|
|
2688
2693
|
};
|
|
2689
|
-
(0,
|
|
2694
|
+
(0, import_react14.useEffect)(() => {
|
|
2690
2695
|
if (isOpen) {
|
|
2691
2696
|
updateDropdownPosition();
|
|
2692
2697
|
window.addEventListener("scroll", updateDropdownPosition, true);
|
|
@@ -2699,7 +2704,7 @@ var SearchApiContent = (0, import_react13.forwardRef)(
|
|
|
2699
2704
|
}, [isOpen]);
|
|
2700
2705
|
if (!isOpen || typeof document === "undefined") return null;
|
|
2701
2706
|
return (0, import_react_dom2.createPortal)(
|
|
2702
|
-
/* @__PURE__ */ (0,
|
|
2707
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2703
2708
|
"div",
|
|
2704
2709
|
{
|
|
2705
2710
|
ref: dropdownContentRef,
|
|
@@ -2708,11 +2713,11 @@ var SearchApiContent = (0, import_react13.forwardRef)(
|
|
|
2708
2713
|
onMouseDown: (e) => e.stopPropagation(),
|
|
2709
2714
|
...props,
|
|
2710
2715
|
children: [
|
|
2711
|
-
error && /* @__PURE__ */ (0,
|
|
2712
|
-
isLoading && options.length === 0 ? /* @__PURE__ */ (0,
|
|
2713
|
-
/* @__PURE__ */ (0,
|
|
2716
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "px-3 py-2 text-sm text-red-600 dark:text-red-400 border-b border-gray-100 dark:border-zinc-800", children: error }),
|
|
2717
|
+
isLoading && options.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "p-4 text-center text-sm text-gray-500", children: [
|
|
2718
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react8.Loader2, { className: "h-5 w-5 animate-spin mx-auto mb-2" }),
|
|
2714
2719
|
"Loading options..."
|
|
2715
|
-
] }) : children ? /* @__PURE__ */ (0,
|
|
2720
|
+
] }) : children ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "py-1", children }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "p-4 text-center text-sm text-gray-500", children: searchTerm ? `No results for "${searchTerm}"` : "No options available" })
|
|
2716
2721
|
]
|
|
2717
2722
|
}
|
|
2718
2723
|
),
|
|
@@ -2721,7 +2726,7 @@ var SearchApiContent = (0, import_react13.forwardRef)(
|
|
|
2721
2726
|
}
|
|
2722
2727
|
);
|
|
2723
2728
|
SearchApiContent.displayName = "SearchApiContent";
|
|
2724
|
-
var SearchApiItem = (0,
|
|
2729
|
+
var SearchApiItem = (0, import_react14.forwardRef)(
|
|
2725
2730
|
({ option, index, className = "", ...props }, ref) => {
|
|
2726
2731
|
const {
|
|
2727
2732
|
selectedValue,
|
|
@@ -2741,7 +2746,7 @@ var SearchApiItem = (0, import_react13.forwardRef)(
|
|
|
2741
2746
|
const optValue = getOptionValue(option);
|
|
2742
2747
|
const isSelected = selectedValue === optValue;
|
|
2743
2748
|
const isHighlighted = index === activeIndex;
|
|
2744
|
-
return /* @__PURE__ */ (0,
|
|
2749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2745
2750
|
"button",
|
|
2746
2751
|
{
|
|
2747
2752
|
ref,
|
|
@@ -2760,8 +2765,8 @@ var SearchApiItem = (0, import_react13.forwardRef)(
|
|
|
2760
2765
|
onMouseEnter: () => setActiveIndex(index),
|
|
2761
2766
|
...props,
|
|
2762
2767
|
children: [
|
|
2763
|
-
/* @__PURE__ */ (0,
|
|
2764
|
-
isSelected && /* @__PURE__ */ (0,
|
|
2768
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "truncate", children: option[labelKey] }),
|
|
2769
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react8.Check, { className: "h-4 w-4", style: { color: primaryColor } })
|
|
2765
2770
|
]
|
|
2766
2771
|
},
|
|
2767
2772
|
optValue || index
|
|
@@ -2771,15 +2776,15 @@ var SearchApiItem = (0, import_react13.forwardRef)(
|
|
|
2771
2776
|
SearchApiItem.displayName = "SearchApiItem";
|
|
2772
2777
|
|
|
2773
2778
|
// src/components/Fields/date.tsx
|
|
2774
|
-
var
|
|
2775
|
-
var
|
|
2779
|
+
var import_react15 = require("react");
|
|
2780
|
+
var import_antd2 = require("antd");
|
|
2776
2781
|
var import_react_hook_form6 = require("react-hook-form");
|
|
2777
2782
|
var import_dayjs = __toESM(require("dayjs"));
|
|
2778
2783
|
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
2779
2784
|
var import_lucide_react9 = require("lucide-react");
|
|
2780
|
-
var
|
|
2785
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2781
2786
|
import_dayjs.default.extend(import_customParseFormat.default);
|
|
2782
|
-
var DateInput = (0,
|
|
2787
|
+
var DateInput = (0, import_react15.forwardRef)(
|
|
2783
2788
|
({
|
|
2784
2789
|
label,
|
|
2785
2790
|
error,
|
|
@@ -2796,7 +2801,7 @@ var DateInput = (0, import_react14.forwardRef)(
|
|
|
2796
2801
|
}, ref) => {
|
|
2797
2802
|
const { theme } = useWarqadConfig();
|
|
2798
2803
|
const primaryColor = theme?.primaryColor;
|
|
2799
|
-
const [isFocused, setIsFocused] = (0,
|
|
2804
|
+
const [isFocused, setIsFocused] = (0, import_react15.useState)(false);
|
|
2800
2805
|
let message = error;
|
|
2801
2806
|
if (form && name) {
|
|
2802
2807
|
const {
|
|
@@ -2814,8 +2819,8 @@ var DateInput = (0, import_react14.forwardRef)(
|
|
|
2814
2819
|
${className}`;
|
|
2815
2820
|
const renderDatePicker = (val, changeHandler, blurHandler, refProps) => {
|
|
2816
2821
|
const dateValue = val && typeof val === "string" ? (0, import_dayjs.default)(val, "DD/MM/YYYY", true) : import_dayjs.default.isDayjs(val) ? val : null;
|
|
2817
|
-
return /* @__PURE__ */ (0,
|
|
2818
|
-
|
|
2822
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2823
|
+
import_antd2.DatePicker,
|
|
2819
2824
|
{
|
|
2820
2825
|
ref: refProps,
|
|
2821
2826
|
format: "DD/MM/YYYY",
|
|
@@ -2841,7 +2846,7 @@ var DateInput = (0, import_react14.forwardRef)(
|
|
|
2841
2846
|
boxShadow: isFocused && !message ? `${primaryColor}33 0px 0px 0px 2px` : void 0
|
|
2842
2847
|
},
|
|
2843
2848
|
classNames: { popup: { root: "z-50" } },
|
|
2844
|
-
suffixIcon: /* @__PURE__ */ (0,
|
|
2849
|
+
suffixIcon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2845
2850
|
import_lucide_react9.Calendar,
|
|
2846
2851
|
{
|
|
2847
2852
|
className: "h-5 w-5 text-gray-400",
|
|
@@ -2853,8 +2858,8 @@ var DateInput = (0, import_react14.forwardRef)(
|
|
|
2853
2858
|
}
|
|
2854
2859
|
);
|
|
2855
2860
|
};
|
|
2856
|
-
return /* @__PURE__ */ (0,
|
|
2857
|
-
label && /* @__PURE__ */ (0,
|
|
2861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: `space-y-2 group relative ${containerClassName}`, children: [
|
|
2862
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2858
2863
|
"label",
|
|
2859
2864
|
{
|
|
2860
2865
|
className: "block text-xs font-medium transition-colors duration-200",
|
|
@@ -2863,11 +2868,11 @@ var DateInput = (0, import_react14.forwardRef)(
|
|
|
2863
2868
|
},
|
|
2864
2869
|
children: [
|
|
2865
2870
|
label,
|
|
2866
|
-
props.required && /* @__PURE__ */ (0,
|
|
2871
|
+
props.required && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "text-red-500 ml-1", children: "*" })
|
|
2867
2872
|
]
|
|
2868
2873
|
}
|
|
2869
2874
|
),
|
|
2870
|
-
form && name ? /* @__PURE__ */ (0,
|
|
2875
|
+
form && name ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2871
2876
|
import_react_hook_form6.Controller,
|
|
2872
2877
|
{
|
|
2873
2878
|
control: form.control,
|
|
@@ -2880,7 +2885,7 @@ var DateInput = (0, import_react14.forwardRef)(
|
|
|
2880
2885
|
)
|
|
2881
2886
|
}
|
|
2882
2887
|
) : renderDatePicker(value, onChange, onBlur, ref),
|
|
2883
|
-
message && /* @__PURE__ */ (0,
|
|
2888
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message })
|
|
2884
2889
|
] });
|
|
2885
2890
|
}
|
|
2886
2891
|
);
|
|
@@ -2904,10 +2909,10 @@ var Fields = {
|
|
|
2904
2909
|
var Fields_default = Fields;
|
|
2905
2910
|
|
|
2906
2911
|
// src/components/tables/DataTable.tsx
|
|
2907
|
-
var
|
|
2912
|
+
var import_react16 = __toESM(require("react"));
|
|
2908
2913
|
var import_react_table = require("@tanstack/react-table");
|
|
2909
2914
|
var import_lucide_react10 = require("lucide-react");
|
|
2910
|
-
var
|
|
2915
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2911
2916
|
function DataTable({
|
|
2912
2917
|
columns: userColumns,
|
|
2913
2918
|
data,
|
|
@@ -2929,9 +2934,9 @@ function DataTable({
|
|
|
2929
2934
|
}) {
|
|
2930
2935
|
const { theme } = useWarqadConfig();
|
|
2931
2936
|
const primaryColor = theme?.primaryColor;
|
|
2932
|
-
const [sorting, setSorting] = (0,
|
|
2933
|
-
const [columnFilters, setColumnFilters] = (0,
|
|
2934
|
-
const [columnVisibility, setColumnVisibility] = (0,
|
|
2937
|
+
const [sorting, setSorting] = (0, import_react16.useState)([]);
|
|
2938
|
+
const [columnFilters, setColumnFilters] = (0, import_react16.useState)([]);
|
|
2939
|
+
const [columnVisibility, setColumnVisibility] = (0, import_react16.useState)(
|
|
2935
2940
|
() => {
|
|
2936
2941
|
const initialVisibility = {};
|
|
2937
2942
|
userColumns.forEach((col) => {
|
|
@@ -2945,18 +2950,18 @@ function DataTable({
|
|
|
2945
2950
|
return initialVisibility;
|
|
2946
2951
|
}
|
|
2947
2952
|
);
|
|
2948
|
-
const [rowSelection, setRowSelection] = (0,
|
|
2949
|
-
const [globalFilter, setGlobalFilter] = (0,
|
|
2950
|
-
const [pagination, setPagination] = (0,
|
|
2953
|
+
const [rowSelection, setRowSelection] = (0, import_react16.useState)({});
|
|
2954
|
+
const [globalFilter, setGlobalFilter] = (0, import_react16.useState)("");
|
|
2955
|
+
const [pagination, setPagination] = (0, import_react16.useState)({
|
|
2951
2956
|
pageIndex: 0,
|
|
2952
2957
|
pageSize: pageRows || 10
|
|
2953
2958
|
});
|
|
2954
|
-
(0,
|
|
2959
|
+
(0, import_react16.useEffect)(() => {
|
|
2955
2960
|
if (pageRows) {
|
|
2956
2961
|
setPagination((prev) => ({ ...prev, pageSize: pageRows }));
|
|
2957
2962
|
}
|
|
2958
2963
|
}, [pageRows]);
|
|
2959
|
-
const [expanded, setExpanded] = (0,
|
|
2964
|
+
const [expanded, setExpanded] = (0, import_react16.useState)(() => {
|
|
2960
2965
|
const initialState = {};
|
|
2961
2966
|
if (defaultExpanded && renderSubComponent && data) {
|
|
2962
2967
|
data.forEach((row, idx) => {
|
|
@@ -2967,7 +2972,7 @@ function DataTable({
|
|
|
2967
2972
|
}
|
|
2968
2973
|
return initialState;
|
|
2969
2974
|
});
|
|
2970
|
-
const columns = (0,
|
|
2975
|
+
const columns = (0, import_react16.useMemo)(() => {
|
|
2971
2976
|
let mappedColumns = userColumns.map((col) => ({
|
|
2972
2977
|
...col,
|
|
2973
2978
|
accessorKey: col.key || col.accessorKey,
|
|
@@ -2983,7 +2988,7 @@ function DataTable({
|
|
|
2983
2988
|
{
|
|
2984
2989
|
id: "_index",
|
|
2985
2990
|
header: "#",
|
|
2986
|
-
cell: ({ row }) => /* @__PURE__ */ (0,
|
|
2991
|
+
cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-gray-500 font-medium ml-1", children: row.index + 1 }),
|
|
2987
2992
|
enableSorting: false
|
|
2988
2993
|
},
|
|
2989
2994
|
...mappedColumns
|
|
@@ -3017,7 +3022,7 @@ function DataTable({
|
|
|
3017
3022
|
},
|
|
3018
3023
|
manualPagination: false
|
|
3019
3024
|
});
|
|
3020
|
-
(0,
|
|
3025
|
+
(0, import_react16.useEffect)(() => {
|
|
3021
3026
|
if (onChange) {
|
|
3022
3027
|
onChange({
|
|
3023
3028
|
pagination: {
|
|
@@ -3042,29 +3047,29 @@ function DataTable({
|
|
|
3042
3047
|
table.getState().pagination.pageIndex,
|
|
3043
3048
|
table.getState().pagination.pageSize
|
|
3044
3049
|
]);
|
|
3045
|
-
return /* @__PURE__ */ (0,
|
|
3046
|
-
filterables && /* @__PURE__ */ (0,
|
|
3047
|
-
/* @__PURE__ */ (0,
|
|
3050
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: `space-y-4 w-full ${className}`, children: [
|
|
3051
|
+
filterables && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
3052
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex-1 max-w-sm", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3048
3053
|
Fields_default.Input,
|
|
3049
3054
|
{
|
|
3050
3055
|
placeholder: searchPlaceholder,
|
|
3051
3056
|
value: globalFilter,
|
|
3052
3057
|
onChange: (e) => setGlobalFilter(e.target.value),
|
|
3053
|
-
icon: /* @__PURE__ */ (0,
|
|
3058
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react10.Search, { size: 16 }),
|
|
3054
3059
|
className: "h-9!"
|
|
3055
3060
|
}
|
|
3056
3061
|
) }),
|
|
3057
|
-
/* @__PURE__ */ (0,
|
|
3058
|
-
/* @__PURE__ */ (0,
|
|
3062
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "relative group", children: [
|
|
3063
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("button", { className: "flex items-center gap-2 px-3 h-9 rounded-lg border border-gray-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 text-sm font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-zinc-800 transition-colors", children: [
|
|
3059
3064
|
"Columns",
|
|
3060
|
-
/* @__PURE__ */ (0,
|
|
3065
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react10.ChevronDown, { size: 14, className: "text-gray-400" })
|
|
3061
3066
|
] }),
|
|
3062
|
-
/* @__PURE__ */ (0,
|
|
3067
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "absolute right-0 top-full mt-2 w-48 py-1 bg-white dark:bg-zinc-900 border border-gray-200 dark:border-zinc-800 rounded-lg shadow-xl opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-50", children: table.getAllColumns().filter((column) => column.getCanHide()).map((column) => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
3063
3068
|
"label",
|
|
3064
3069
|
{
|
|
3065
3070
|
className: "flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-zinc-800 cursor-pointer capitalize",
|
|
3066
3071
|
children: [
|
|
3067
|
-
/* @__PURE__ */ (0,
|
|
3072
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3068
3073
|
"input",
|
|
3069
3074
|
{
|
|
3070
3075
|
type: "checkbox",
|
|
@@ -3081,13 +3086,13 @@ function DataTable({
|
|
|
3081
3086
|
)) })
|
|
3082
3087
|
] }) })
|
|
3083
3088
|
] }),
|
|
3084
|
-
/* @__PURE__ */ (0,
|
|
3089
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "rounded-lg border border-gray-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 overflow-hidden relative", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
3085
3090
|
"table",
|
|
3086
3091
|
{
|
|
3087
3092
|
className: "w-full text-left border-collapse",
|
|
3088
3093
|
style: { accentColor: primaryColor },
|
|
3089
3094
|
children: [
|
|
3090
|
-
/* @__PURE__ */ (0,
|
|
3095
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("thead", { className: "bg-gray-50/50 dark:bg-zinc-900/50 border-b border-gray-200 dark:border-zinc-800", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("tr", { children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3091
3096
|
"th",
|
|
3092
3097
|
{
|
|
3093
3098
|
className: `${rowPadding} text-sm font-semibold text-gray-900 dark:text-zinc-100 text-left ${verticalLines ? "border-x border-gray-200 dark:border-zinc-800" : ""} ${header.id === "_index" || header.id === "select" || header.id === "_select" ? "w-px whitespace-nowrap" : ""}`,
|
|
@@ -3098,22 +3103,22 @@ function DataTable({
|
|
|
3098
3103
|
},
|
|
3099
3104
|
header.id
|
|
3100
3105
|
)) }, headerGroup.id)) }),
|
|
3101
|
-
/* @__PURE__ */ (0,
|
|
3106
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("tbody", { className: "", children: isLoading ? Array.from({ length: pageRows || 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3102
3107
|
"tr",
|
|
3103
3108
|
{
|
|
3104
3109
|
className: "border-b border-gray-100 dark:border-zinc-800/50",
|
|
3105
|
-
children: columns.map((_2, j) => /* @__PURE__ */ (0,
|
|
3110
|
+
children: columns.map((_2, j) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3106
3111
|
"td",
|
|
3107
3112
|
{
|
|
3108
3113
|
className: `${rowPadding} ${verticalLines ? "border-x border-gray-200 dark:border-zinc-800/50" : ""}`,
|
|
3109
|
-
children: /* @__PURE__ */ (0,
|
|
3114
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "h-4 bg-gray-100 dark:bg-zinc-800 rounded animate-pulse w-full" })
|
|
3110
3115
|
},
|
|
3111
3116
|
`skeleton-cell-${j}`
|
|
3112
3117
|
))
|
|
3113
3118
|
},
|
|
3114
3119
|
`skeleton-${i}`
|
|
3115
|
-
)) : table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0,
|
|
3116
|
-
/* @__PURE__ */ (0,
|
|
3120
|
+
)) : table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react16.default.Fragment, { children: [
|
|
3121
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3117
3122
|
"tr",
|
|
3118
3123
|
{
|
|
3119
3124
|
className: `border-b border-gray-200 dark:border-zinc-800 hover:bg-gray-50/50 dark:hover:bg-zinc-900/50 transition-colors last:border-b-0 ${renderSubComponent && hasSubComponent(row.original) ? "cursor-pointer" : ""}`,
|
|
@@ -3128,7 +3133,7 @@ function DataTable({
|
|
|
3128
3133
|
}
|
|
3129
3134
|
}
|
|
3130
3135
|
},
|
|
3131
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0,
|
|
3136
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3132
3137
|
"td",
|
|
3133
3138
|
{
|
|
3134
3139
|
className: `${rowPadding} text-sm text-gray-700 dark:text-gray-200 ${verticalLines ? "border-x border-gray-200 dark:border-zinc-800" : ""} ${cell.column.id === "_index" || cell.column.id === "select" || cell.column.id === "_select" ? "w-px whitespace-nowrap" : ""}`,
|
|
@@ -3141,14 +3146,14 @@ function DataTable({
|
|
|
3141
3146
|
))
|
|
3142
3147
|
}
|
|
3143
3148
|
),
|
|
3144
|
-
renderSubComponent && row.getIsExpanded() && hasSubComponent(row.original) && /* @__PURE__ */ (0,
|
|
3145
|
-
/* @__PURE__ */ (0,
|
|
3149
|
+
renderSubComponent && row.getIsExpanded() && hasSubComponent(row.original) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("tr", { className: "border-b border-gray-200 dark:border-zinc-800 bg-gray-50/20 dark:bg-zinc-900/20", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("td", { colSpan: columns.length, className: "px-2 py-0", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "relative pl-6 pb-2 pr-2 pt-2 h-full", children: [
|
|
3150
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "absolute left-2 top-0 bottom-2 w-6 border-l-2 border-b-2 rounded-bl-xl border-(--theme-primary) dark:border-(--theme-primary) pointer-events-none" }),
|
|
3146
3151
|
renderSubComponent({
|
|
3147
3152
|
row: row.original,
|
|
3148
3153
|
index: row.index
|
|
3149
3154
|
})
|
|
3150
3155
|
] }) }) })
|
|
3151
|
-
] }, row.id)) : /* @__PURE__ */ (0,
|
|
3156
|
+
] }, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3152
3157
|
"td",
|
|
3153
3158
|
{
|
|
3154
3159
|
colSpan: columns.length,
|
|
@@ -3160,7 +3165,7 @@ function DataTable({
|
|
|
3160
3165
|
(group) => group.headers.some(
|
|
3161
3166
|
(header) => header.column.columnDef.footer
|
|
3162
3167
|
)
|
|
3163
|
-
) && /* @__PURE__ */ (0,
|
|
3168
|
+
) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("tfoot", { className: "bg-gray-50/50 dark:bg-zinc-900/50 border-t border-gray-200 dark:border-zinc-800", children: table.getFooterGroups().map((footerGroup) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("tr", { children: footerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3164
3169
|
"td",
|
|
3165
3170
|
{
|
|
3166
3171
|
className: `${rowPadding} text-sm font-semibold text-gray-900 dark:text-zinc-100 text-left ${verticalLines ? "border-x border-gray-200 dark:border-zinc-800" : ""} ${header.id === "_index" || header.id === "select" || header.id === "_select" ? "w-px whitespace-nowrap" : ""}`,
|
|
@@ -3174,24 +3179,24 @@ function DataTable({
|
|
|
3174
3179
|
]
|
|
3175
3180
|
}
|
|
3176
3181
|
) }) }),
|
|
3177
|
-
/* @__PURE__ */ (0,
|
|
3178
|
-
/* @__PURE__ */ (0,
|
|
3182
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center justify-between px-2", children: [
|
|
3183
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex-1 text-xs text-gray-500", children: selectable && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
3179
3184
|
table.getFilteredSelectedRowModel().rows.length,
|
|
3180
3185
|
" of",
|
|
3181
3186
|
" ",
|
|
3182
3187
|
table.getFilteredRowModel().rows.length,
|
|
3183
3188
|
" row(s) selected."
|
|
3184
3189
|
] }) }),
|
|
3185
|
-
pageRows && table.getPageCount() > 1 && /* @__PURE__ */ (0,
|
|
3186
|
-
/* @__PURE__ */ (0,
|
|
3190
|
+
pageRows && table.getPageCount() > 1 && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3191
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "text-sm text-gray-700 dark:text-gray-300 mr-2 select-none", children: [
|
|
3187
3192
|
"Page",
|
|
3188
3193
|
" ",
|
|
3189
|
-
/* @__PURE__ */ (0,
|
|
3194
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "font-semibold", children: table.getState().pagination.pageIndex + 1 }),
|
|
3190
3195
|
" ",
|
|
3191
3196
|
"of ",
|
|
3192
|
-
/* @__PURE__ */ (0,
|
|
3197
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "font-semibold", children: table.getPageCount() })
|
|
3193
3198
|
] }),
|
|
3194
|
-
/* @__PURE__ */ (0,
|
|
3199
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3195
3200
|
"button",
|
|
3196
3201
|
{
|
|
3197
3202
|
onClick: () => table.previousPage(),
|
|
@@ -3200,7 +3205,7 @@ function DataTable({
|
|
|
3200
3205
|
children: "Previous"
|
|
3201
3206
|
}
|
|
3202
3207
|
),
|
|
3203
|
-
/* @__PURE__ */ (0,
|
|
3208
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3204
3209
|
"button",
|
|
3205
3210
|
{
|
|
3206
3211
|
onClick: () => table.nextPage(),
|
|
@@ -3215,17 +3220,17 @@ function DataTable({
|
|
|
3215
3220
|
}
|
|
3216
3221
|
|
|
3217
3222
|
// src/components/tables/PostTable.tsx
|
|
3218
|
-
var
|
|
3223
|
+
var import_react17 = __toESM(require("react"));
|
|
3219
3224
|
var import_react_table2 = require("@tanstack/react-table");
|
|
3220
3225
|
var import_lucide_react11 = require("lucide-react");
|
|
3221
|
-
var
|
|
3222
|
-
var TableCell =
|
|
3226
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3227
|
+
var TableCell = import_react17.default.memo(
|
|
3223
3228
|
({
|
|
3224
3229
|
cell,
|
|
3225
3230
|
rowPadding,
|
|
3226
3231
|
verticalLines
|
|
3227
3232
|
}) => {
|
|
3228
|
-
return /* @__PURE__ */ (0,
|
|
3233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3229
3234
|
"td",
|
|
3230
3235
|
{
|
|
3231
3236
|
className: cn(
|
|
@@ -3249,7 +3254,7 @@ var TableCell = import_react16.default.memo(
|
|
|
3249
3254
|
return prev.cell.getValue() === next.cell.getValue() && prev.cell.row.original === next.cell.row.original && prev.cell.row.getIsExpanded() === next.cell.row.getIsExpanded() && prev.cell.row.getIsSelected() === next.cell.row.getIsSelected() && prev.rowPadding === next.rowPadding && prev.verticalLines === next.verticalLines;
|
|
3250
3255
|
}
|
|
3251
3256
|
);
|
|
3252
|
-
var TableRow =
|
|
3257
|
+
var TableRow = import_react17.default.memo(
|
|
3253
3258
|
({
|
|
3254
3259
|
row,
|
|
3255
3260
|
rowPadding,
|
|
@@ -3260,8 +3265,8 @@ var TableRow = import_react16.default.memo(
|
|
|
3260
3265
|
}) => {
|
|
3261
3266
|
const isExpanded = row.getIsExpanded();
|
|
3262
3267
|
const subComponentVisible = renderSubComponent && isExpanded && hasSubComponent(row.original);
|
|
3263
|
-
return /* @__PURE__ */ (0,
|
|
3264
|
-
/* @__PURE__ */ (0,
|
|
3268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react17.default.Fragment, { children: [
|
|
3269
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3265
3270
|
"tr",
|
|
3266
3271
|
{
|
|
3267
3272
|
className: `border-b border-gray-200 dark:border-zinc-800 hover:bg-gray-50/50 dark:hover:bg-zinc-900/50 transition-colors last:border-b-0 ${renderSubComponent && hasSubComponent(row.original) ? "cursor-pointer" : ""}`,
|
|
@@ -3274,7 +3279,7 @@ var TableRow = import_react16.default.memo(
|
|
|
3274
3279
|
}
|
|
3275
3280
|
}
|
|
3276
3281
|
},
|
|
3277
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0,
|
|
3282
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3278
3283
|
TableCell,
|
|
3279
3284
|
{
|
|
3280
3285
|
cell,
|
|
@@ -3285,8 +3290,8 @@ var TableRow = import_react16.default.memo(
|
|
|
3285
3290
|
))
|
|
3286
3291
|
}
|
|
3287
3292
|
),
|
|
3288
|
-
subComponentVisible && /* @__PURE__ */ (0,
|
|
3289
|
-
/* @__PURE__ */ (0,
|
|
3293
|
+
subComponentVisible && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tr", { className: "border-b border-gray-200 dark:border-zinc-800 bg-gray-50/20 dark:bg-zinc-900/20", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("td", { colSpan: columnsCount, className: "px-2 py-0", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "relative pl-6 pb-2 pr-2 pt-2 h-full", children: [
|
|
3294
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "absolute left-2 top-0 bottom-2 w-6 border-l-2 border-b-2 rounded-bl-xl border-(--theme-primary) dark:border-(--theme-primary) pointer-events-none" }),
|
|
3290
3295
|
renderSubComponent({
|
|
3291
3296
|
row: row.original,
|
|
3292
3297
|
index: row.index
|
|
@@ -3319,10 +3324,10 @@ function PostTable({
|
|
|
3319
3324
|
}) {
|
|
3320
3325
|
const { theme } = useWarqadConfig();
|
|
3321
3326
|
const primaryColor = theme?.primaryColor;
|
|
3322
|
-
const [sorting, setSorting] = (0,
|
|
3323
|
-
const [columnFilters, setColumnFilters] = (0,
|
|
3324
|
-
const [columnVisibility, setColumnVisibility] = (0,
|
|
3325
|
-
const [expanded, setExpanded] = (0,
|
|
3327
|
+
const [sorting, setSorting] = (0, import_react17.useState)([]);
|
|
3328
|
+
const [columnFilters, setColumnFilters] = (0, import_react17.useState)([]);
|
|
3329
|
+
const [columnVisibility, setColumnVisibility] = (0, import_react17.useState)({});
|
|
3330
|
+
const [expanded, setExpanded] = (0, import_react17.useState)(() => {
|
|
3326
3331
|
const initialState = {};
|
|
3327
3332
|
if (defaultExpanded && renderSubComponent && controlledData) {
|
|
3328
3333
|
controlledData.forEach((row, idx) => {
|
|
@@ -3333,10 +3338,10 @@ function PostTable({
|
|
|
3333
3338
|
}
|
|
3334
3339
|
return initialState;
|
|
3335
3340
|
});
|
|
3336
|
-
const [internalData, setInternalData] = (0,
|
|
3341
|
+
const [internalData, setInternalData] = (0, import_react17.useState)(controlledData || []);
|
|
3337
3342
|
const isControlled = controlledData !== void 0;
|
|
3338
3343
|
const data = isControlled ? controlledData : internalData;
|
|
3339
|
-
const entryRowRef = (0,
|
|
3344
|
+
const entryRowRef = (0, import_react17.useRef)(null);
|
|
3340
3345
|
const focusAndScrollEntryRow = () => {
|
|
3341
3346
|
setTimeout(() => {
|
|
3342
3347
|
if (entryRowRef.current) {
|
|
@@ -3353,14 +3358,14 @@ function PostTable({
|
|
|
3353
3358
|
}
|
|
3354
3359
|
}, 50);
|
|
3355
3360
|
};
|
|
3356
|
-
(0,
|
|
3361
|
+
(0, import_react17.useEffect)(() => {
|
|
3357
3362
|
focusAndScrollEntryRow();
|
|
3358
3363
|
}, []);
|
|
3359
|
-
const [entryData, setEntryData] = (0,
|
|
3360
|
-
const [editingIndex, setEditingIndex] = (0,
|
|
3361
|
-
const [isSavingAsync, setIsSavingAsync] = (0,
|
|
3362
|
-
const [fieldErrors, setFieldErrors] = (0,
|
|
3363
|
-
const latestStateRef = (0,
|
|
3364
|
+
const [entryData, setEntryData] = (0, import_react17.useState)({});
|
|
3365
|
+
const [editingIndex, setEditingIndex] = (0, import_react17.useState)(null);
|
|
3366
|
+
const [isSavingAsync, setIsSavingAsync] = (0, import_react17.useState)(false);
|
|
3367
|
+
const [fieldErrors, setFieldErrors] = (0, import_react17.useState)({});
|
|
3368
|
+
const latestStateRef = (0, import_react17.useRef)({
|
|
3364
3369
|
data,
|
|
3365
3370
|
entryData,
|
|
3366
3371
|
editingIndex,
|
|
@@ -3372,7 +3377,7 @@ function PostTable({
|
|
|
3372
3377
|
onEdit,
|
|
3373
3378
|
onDelete
|
|
3374
3379
|
});
|
|
3375
|
-
(0,
|
|
3380
|
+
(0, import_react17.useEffect)(() => {
|
|
3376
3381
|
latestStateRef.current = {
|
|
3377
3382
|
data,
|
|
3378
3383
|
entryData,
|
|
@@ -3386,7 +3391,7 @@ function PostTable({
|
|
|
3386
3391
|
onDelete
|
|
3387
3392
|
};
|
|
3388
3393
|
});
|
|
3389
|
-
const handleSaveField = (0,
|
|
3394
|
+
const handleSaveField = (0, import_react17.useCallback)(async () => {
|
|
3390
3395
|
const { data: data2, entryData: entryData2, editingIndex: editingIndex2, onChange: onChange2 } = latestStateRef.current;
|
|
3391
3396
|
if (Object.keys(entryData2).length === 0) return;
|
|
3392
3397
|
const actionType = editingIndex2 !== null ? "edit" : "add";
|
|
@@ -3452,20 +3457,20 @@ function PostTable({
|
|
|
3452
3457
|
setTimeout(() => focusAndScrollEntryRow(), 0);
|
|
3453
3458
|
}
|
|
3454
3459
|
}, []);
|
|
3455
|
-
const handleCancelEdit = (0,
|
|
3460
|
+
const handleCancelEdit = (0, import_react17.useCallback)(() => {
|
|
3456
3461
|
const { onCancel: onCancel2 } = latestStateRef.current;
|
|
3457
3462
|
setEditingIndex(null);
|
|
3458
3463
|
setEntryData({});
|
|
3459
3464
|
setFieldErrors({});
|
|
3460
3465
|
if (onCancel2) onCancel2();
|
|
3461
3466
|
}, []);
|
|
3462
|
-
const handleEdit = (0,
|
|
3467
|
+
const handleEdit = (0, import_react17.useCallback)((index2, rowOriginal) => {
|
|
3463
3468
|
const { onEdit: onEdit2 } = latestStateRef.current;
|
|
3464
3469
|
setEditingIndex(index2);
|
|
3465
3470
|
setEntryData({ ...rowOriginal });
|
|
3466
3471
|
if (onEdit2) onEdit2(rowOriginal);
|
|
3467
3472
|
}, []);
|
|
3468
|
-
const handleDelete = (0,
|
|
3473
|
+
const handleDelete = (0, import_react17.useCallback)(
|
|
3469
3474
|
async (index2) => {
|
|
3470
3475
|
const { data: data2, editingIndex: editingIndex2, onChange: onChange2, onDelete: onDelete2 } = latestStateRef.current;
|
|
3471
3476
|
const rowToDelete = data2[index2];
|
|
@@ -3520,31 +3525,31 @@ function PostTable({
|
|
|
3520
3525
|
},
|
|
3521
3526
|
[handleCancelEdit]
|
|
3522
3527
|
);
|
|
3523
|
-
const actionColumn = (0,
|
|
3528
|
+
const actionColumn = (0, import_react17.useMemo)(
|
|
3524
3529
|
() => ({
|
|
3525
3530
|
id: "actions",
|
|
3526
3531
|
header: "Actions",
|
|
3527
3532
|
cell: ({ row, table: table2 }) => {
|
|
3528
3533
|
const { handleEdit: handleEdit2, handleDelete: handleDelete2, submitLoading: submitLoading2, isSavingAsync: isSavingAsync2 } = table2.options.meta;
|
|
3529
|
-
return /* @__PURE__ */ (0,
|
|
3530
|
-
/* @__PURE__ */ (0,
|
|
3534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3535
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3531
3536
|
"button",
|
|
3532
3537
|
{
|
|
3533
3538
|
onClick: () => handleEdit2(row.index, row.original),
|
|
3534
3539
|
disabled: submitLoading2 || isSavingAsync2,
|
|
3535
3540
|
className: "p-1 px-2 rounded-md hover:bg-gray-100 dark:hover:bg-zinc-800 text-gray-500 hover:text-(--theme-primary) dark:hover:text-(--theme-primary) transition-colors disabled:opacity-50",
|
|
3536
3541
|
title: "Edit",
|
|
3537
|
-
children: submitLoading2 || isSavingAsync2 ? /* @__PURE__ */ (0,
|
|
3542
|
+
children: submitLoading2 || isSavingAsync2 ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.Loader2, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.Edit2, { size: 16 })
|
|
3538
3543
|
}
|
|
3539
3544
|
),
|
|
3540
|
-
/* @__PURE__ */ (0,
|
|
3545
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3541
3546
|
"button",
|
|
3542
3547
|
{
|
|
3543
3548
|
onClick: () => handleDelete2(row.index),
|
|
3544
3549
|
disabled: submitLoading2 || isSavingAsync2,
|
|
3545
3550
|
className: "p-1 px-2 rounded-md hover:bg-gray-100 dark:hover:bg-zinc-800 text-gray-500 hover:text-red-600 dark:hover:text-red-400 transition-colors disabled:opacity-50",
|
|
3546
3551
|
title: "Delete",
|
|
3547
|
-
children: submitLoading2 || isSavingAsync2 ? /* @__PURE__ */ (0,
|
|
3552
|
+
children: submitLoading2 || isSavingAsync2 ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.Loader2, { size: 16, className: "animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.Trash2, { size: 16 })
|
|
3548
3553
|
}
|
|
3549
3554
|
)
|
|
3550
3555
|
] });
|
|
@@ -3552,7 +3557,7 @@ function PostTable({
|
|
|
3552
3557
|
}),
|
|
3553
3558
|
[]
|
|
3554
3559
|
);
|
|
3555
|
-
const columns = (0,
|
|
3560
|
+
const columns = (0, import_react17.useMemo)(() => {
|
|
3556
3561
|
const mappedUserColumns = userColumns.map((col) => ({
|
|
3557
3562
|
...col,
|
|
3558
3563
|
accessorKey: col.key || col.accessorKey,
|
|
@@ -3566,9 +3571,9 @@ function PostTable({
|
|
|
3566
3571
|
size: 40,
|
|
3567
3572
|
minSize: 40,
|
|
3568
3573
|
maxSize: 40,
|
|
3569
|
-
cell: ({ row }) => /* @__PURE__ */ (0,
|
|
3570
|
-
/* @__PURE__ */ (0,
|
|
3571
|
-
renderSubComponent && hasSubComponent(row.original) && /* @__PURE__ */ (0,
|
|
3574
|
+
cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3575
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-gray-500 font-medium ml-1", children: row.index + 1 }),
|
|
3576
|
+
renderSubComponent && hasSubComponent(row.original) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3572
3577
|
import_lucide_react11.ChevronDown,
|
|
3573
3578
|
{
|
|
3574
3579
|
size: 16,
|
|
@@ -3578,7 +3583,7 @@ function PostTable({
|
|
|
3578
3583
|
] }),
|
|
3579
3584
|
enableSorting: false,
|
|
3580
3585
|
meta: {
|
|
3581
|
-
field: () => /* @__PURE__ */ (0,
|
|
3586
|
+
field: () => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-gray-400 font-medium px-2 block select-none", children: "#" })
|
|
3582
3587
|
}
|
|
3583
3588
|
});
|
|
3584
3589
|
}
|
|
@@ -3608,13 +3613,13 @@ function PostTable({
|
|
|
3608
3613
|
isSavingAsync
|
|
3609
3614
|
}
|
|
3610
3615
|
});
|
|
3611
|
-
return /* @__PURE__ */ (0,
|
|
3616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3612
3617
|
"div",
|
|
3613
3618
|
{
|
|
3614
3619
|
className: `space-y-4 w-full ${className}`,
|
|
3615
3620
|
style: { "--theme-primary": primaryColor || "#3b82f6" },
|
|
3616
|
-
children: /* @__PURE__ */ (0,
|
|
3617
|
-
/* @__PURE__ */ (0,
|
|
3621
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "rounded-lg border border-gray-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 relative", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("table", { className: "w-full text-left border-collapse", children: [
|
|
3622
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("thead", { className: "bg-gray-50/50 dark:bg-zinc-900/50 border-b border-gray-200 dark:border-zinc-800", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tr", { children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3618
3623
|
"th",
|
|
3619
3624
|
{
|
|
3620
3625
|
className: cn(
|
|
@@ -3636,12 +3641,12 @@ function PostTable({
|
|
|
3636
3641
|
},
|
|
3637
3642
|
header.id
|
|
3638
3643
|
)) }, headerGroup.id)) }),
|
|
3639
|
-
/* @__PURE__ */ (0,
|
|
3640
|
-
isLoading ? Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0,
|
|
3644
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("tbody", { className: "", children: [
|
|
3645
|
+
isLoading ? Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3641
3646
|
"tr",
|
|
3642
3647
|
{
|
|
3643
3648
|
className: "border-b border-gray-100 dark:border-zinc-800/50",
|
|
3644
|
-
children: columns.map((col, j) => /* @__PURE__ */ (0,
|
|
3649
|
+
children: columns.map((col, j) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3645
3650
|
"td",
|
|
3646
3651
|
{
|
|
3647
3652
|
className: cn(
|
|
@@ -3654,13 +3659,13 @@ function PostTable({
|
|
|
3654
3659
|
minWidth: col.meta?.width ?? col.minSize,
|
|
3655
3660
|
maxWidth: col.meta?.width ?? col.maxSize
|
|
3656
3661
|
},
|
|
3657
|
-
children: /* @__PURE__ */ (0,
|
|
3662
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-4 bg-gray-100 dark:bg-zinc-800 rounded animate-pulse w-full" })
|
|
3658
3663
|
},
|
|
3659
3664
|
`skeleton-cell-${j}`
|
|
3660
3665
|
))
|
|
3661
3666
|
},
|
|
3662
3667
|
`skeleton-${i}`
|
|
3663
|
-
)) : table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0,
|
|
3668
|
+
)) : table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3664
3669
|
TableRow,
|
|
3665
3670
|
{
|
|
3666
3671
|
row,
|
|
@@ -3671,7 +3676,7 @@ function PostTable({
|
|
|
3671
3676
|
columnsCount: columns.length
|
|
3672
3677
|
},
|
|
3673
3678
|
row.id
|
|
3674
|
-
)) : /* @__PURE__ */ (0,
|
|
3679
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3675
3680
|
"td",
|
|
3676
3681
|
{
|
|
3677
3682
|
colSpan: columns.length,
|
|
@@ -3679,7 +3684,7 @@ function PostTable({
|
|
|
3679
3684
|
children: "No results found."
|
|
3680
3685
|
}
|
|
3681
3686
|
) }),
|
|
3682
|
-
/* @__PURE__ */ (0,
|
|
3687
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3683
3688
|
"tr",
|
|
3684
3689
|
{
|
|
3685
3690
|
ref: entryRowRef,
|
|
@@ -3694,7 +3699,7 @@ function PostTable({
|
|
|
3694
3699
|
return visibleColumns.map((column) => {
|
|
3695
3700
|
const currentId = column.id || column.columnDef.accessorKey;
|
|
3696
3701
|
if (column.id === "actions") {
|
|
3697
|
-
return /* @__PURE__ */ (0,
|
|
3702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3698
3703
|
"td",
|
|
3699
3704
|
{
|
|
3700
3705
|
className: cn(
|
|
@@ -3702,38 +3707,38 @@ function PostTable({
|
|
|
3702
3707
|
"py-1! text-sm align-middle transition-colors duration-200",
|
|
3703
3708
|
verticalLines ? "border-x border-gray-200 dark:border-zinc-800" : ""
|
|
3704
3709
|
),
|
|
3705
|
-
children: /* @__PURE__ */ (0,
|
|
3706
|
-
/* @__PURE__ */ (0,
|
|
3710
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex items-center gap-2", children: editingIndex !== null ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
3711
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3707
3712
|
"button",
|
|
3708
3713
|
{
|
|
3709
3714
|
onClick: handleSaveField,
|
|
3710
3715
|
disabled: isSavingAsync || submitLoading,
|
|
3711
3716
|
className: "flex-1 h-8 flex items-center justify-center rounded-lg bg-green-500/10 text-green-600 dark:bg-emerald-500/20 dark:text-emerald-400 hover:bg-green-500 hover:text-white dark:hover:bg-emerald-500 transition-colors shadow-sm active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
3712
3717
|
title: "Update",
|
|
3713
|
-
children: isSavingAsync || submitLoading ? /* @__PURE__ */ (0,
|
|
3718
|
+
children: isSavingAsync || submitLoading ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3714
3719
|
import_lucide_react11.Loader2,
|
|
3715
3720
|
{
|
|
3716
3721
|
size: 16,
|
|
3717
3722
|
className: "animate-spin"
|
|
3718
3723
|
}
|
|
3719
|
-
) : /* @__PURE__ */ (0,
|
|
3724
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.Check, { size: 16, strokeWidth: 2.5 })
|
|
3720
3725
|
}
|
|
3721
3726
|
),
|
|
3722
|
-
/* @__PURE__ */ (0,
|
|
3727
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3723
3728
|
"button",
|
|
3724
3729
|
{
|
|
3725
3730
|
onClick: handleCancelEdit,
|
|
3726
3731
|
disabled: isSavingAsync || submitLoading,
|
|
3727
3732
|
className: "flex-1 h-8 flex items-center justify-center rounded-lg bg-red-500/10 text-red-600 dark:bg-red-500/20 dark:text-red-400 hover:bg-red-500 hover:text-white dark:hover:bg-red-500 transition-colors shadow-sm active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
3728
3733
|
title: "Cancel",
|
|
3729
|
-
children: /* @__PURE__ */ (0,
|
|
3734
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.X, { size: 16, strokeWidth: 2.5 })
|
|
3730
3735
|
}
|
|
3731
3736
|
)
|
|
3732
|
-
] }) : /* @__PURE__ */ (0,
|
|
3737
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: renderAddButton ? renderAddButton(
|
|
3733
3738
|
entryData,
|
|
3734
3739
|
handleSaveField,
|
|
3735
3740
|
isSavingAsync
|
|
3736
|
-
) : /* @__PURE__ */ (0,
|
|
3741
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3737
3742
|
"button",
|
|
3738
3743
|
{
|
|
3739
3744
|
onClick: handleSaveField,
|
|
@@ -3744,14 +3749,14 @@ function PostTable({
|
|
|
3744
3749
|
},
|
|
3745
3750
|
title: "Add Row",
|
|
3746
3751
|
children: [
|
|
3747
|
-
isSavingAsync || submitLoading ? /* @__PURE__ */ (0,
|
|
3752
|
+
isSavingAsync || submitLoading ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3748
3753
|
import_lucide_react11.Loader2,
|
|
3749
3754
|
{
|
|
3750
3755
|
size: 14,
|
|
3751
3756
|
className: "animate-spin"
|
|
3752
3757
|
}
|
|
3753
|
-
) : /* @__PURE__ */ (0,
|
|
3754
|
-
/* @__PURE__ */ (0,
|
|
3758
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.Plus, { size: 14, strokeWidth: 2.5 }),
|
|
3759
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: isSavingAsync || submitLoading ? "Adding..." : "Add" })
|
|
3755
3760
|
]
|
|
3756
3761
|
}
|
|
3757
3762
|
) }) })
|
|
@@ -3777,7 +3782,7 @@ function PostTable({
|
|
|
3777
3782
|
});
|
|
3778
3783
|
}
|
|
3779
3784
|
};
|
|
3780
|
-
return /* @__PURE__ */ (0,
|
|
3785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3781
3786
|
"td",
|
|
3782
3787
|
{
|
|
3783
3788
|
"data-column-id": column.id,
|
|
@@ -3803,7 +3808,7 @@ function PostTable({
|
|
|
3803
3808
|
minWidth: column.columnDef.meta?.width ?? column.columnDef.minSize,
|
|
3804
3809
|
maxWidth: column.columnDef.meta?.width ?? column.columnDef.maxSize
|
|
3805
3810
|
},
|
|
3806
|
-
children: /* @__PURE__ */ (0,
|
|
3811
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3807
3812
|
"div",
|
|
3808
3813
|
{
|
|
3809
3814
|
className: cn(
|
|
@@ -3834,7 +3839,7 @@ function PostTable({
|
|
|
3834
3839
|
onChange: onChangeValue,
|
|
3835
3840
|
rowData: entryData,
|
|
3836
3841
|
setRowData: setEntryData
|
|
3837
|
-
}) : /* @__PURE__ */ (0,
|
|
3842
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3838
3843
|
Fields_default.Input,
|
|
3839
3844
|
{
|
|
3840
3845
|
id: `pti-${accessor}`,
|
|
@@ -3846,7 +3851,7 @@ function PostTable({
|
|
|
3846
3851
|
placeholder: `${typeof column.columnDef.header === "string" ? column.columnDef.header : column.id}`
|
|
3847
3852
|
}
|
|
3848
3853
|
),
|
|
3849
|
-
typeof error === "string" && /* @__PURE__ */ (0,
|
|
3854
|
+
typeof error === "string" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-9999 pointer-events-none opacity-0 group-hover:opacity-100 focus-within:opacity-100 group-focus-within:opacity-100 transition-opacity whitespace-nowrap bg-red-500 text-white text-xs px-2.5 py-1.5 rounded shadow-lg before:content-[''] before:absolute before:top-full before:left-1/2 before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-red-500", children: error })
|
|
3850
3855
|
]
|
|
3851
3856
|
}
|
|
3852
3857
|
)
|
|
@@ -3862,7 +3867,7 @@ function PostTable({
|
|
|
3862
3867
|
(group) => group.headers.some(
|
|
3863
3868
|
(header) => header.column.columnDef.footer
|
|
3864
3869
|
)
|
|
3865
|
-
) && /* @__PURE__ */ (0,
|
|
3870
|
+
) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tfoot", { className: "bg-gray-50/50 dark:bg-zinc-900/50 border-t border-gray-200 dark:border-zinc-800", children: table.getFooterGroups().map((footerGroup) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("tr", { children: footerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3866
3871
|
"td",
|
|
3867
3872
|
{
|
|
3868
3873
|
className: cn(
|
|
@@ -3890,9 +3895,9 @@ function PostTable({
|
|
|
3890
3895
|
}
|
|
3891
3896
|
|
|
3892
3897
|
// src/components/tables/SimpleTable.tsx
|
|
3893
|
-
var
|
|
3898
|
+
var import_react18 = require("react");
|
|
3894
3899
|
var import_react_table3 = require("@tanstack/react-table");
|
|
3895
|
-
var
|
|
3900
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3896
3901
|
function SimpleTable({
|
|
3897
3902
|
columns: userColumns,
|
|
3898
3903
|
data,
|
|
@@ -3908,7 +3913,7 @@ function SimpleTable({
|
|
|
3908
3913
|
emptyState,
|
|
3909
3914
|
skeletonCount = 5
|
|
3910
3915
|
}) {
|
|
3911
|
-
const columns = (0,
|
|
3916
|
+
const columns = (0, import_react18.useMemo)(() => {
|
|
3912
3917
|
const cols = userColumns.filter((col) => !col.hide).map((col) => ({
|
|
3913
3918
|
...col,
|
|
3914
3919
|
accessorKey: col.key || col.accessorKey,
|
|
@@ -3924,7 +3929,7 @@ function SimpleTable({
|
|
|
3924
3929
|
id: "index",
|
|
3925
3930
|
width: 75,
|
|
3926
3931
|
className: "whitespace-nowrap px-2 text-center",
|
|
3927
|
-
cell: (info) => /* @__PURE__ */ (0,
|
|
3932
|
+
cell: (info) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "tabular-nums", children: info.row.index + 1 + startIndex })
|
|
3928
3933
|
});
|
|
3929
3934
|
}
|
|
3930
3935
|
return cols;
|
|
@@ -3934,24 +3939,24 @@ function SimpleTable({
|
|
|
3934
3939
|
columns,
|
|
3935
3940
|
getCoreRowModel: (0, import_react_table3.getCoreRowModel)()
|
|
3936
3941
|
});
|
|
3937
|
-
const hasFooters = (0,
|
|
3942
|
+
const hasFooters = (0, import_react18.useMemo)(() => {
|
|
3938
3943
|
return table.getFooterGroups().some(
|
|
3939
3944
|
(group) => group.headers.some(
|
|
3940
3945
|
(header) => !header.isPlaceholder && header.column.columnDef.footer
|
|
3941
3946
|
)
|
|
3942
3947
|
);
|
|
3943
3948
|
}, [table]);
|
|
3944
|
-
return /* @__PURE__ */ (0,
|
|
3945
|
-
/* @__PURE__ */ (0,
|
|
3949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: `w-full overflow-hidden ${className}`, children: [
|
|
3950
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3946
3951
|
"table",
|
|
3947
3952
|
{
|
|
3948
3953
|
className: `w-full max-w-full text-left border-collapse table-fixed ${verticalLines ? "border border-black dark:border-white" : ""}`,
|
|
3949
3954
|
children: [
|
|
3950
|
-
/* @__PURE__ */ (0,
|
|
3955
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("thead", { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3951
3956
|
"tr",
|
|
3952
3957
|
{
|
|
3953
3958
|
className: `border-b ${verticalLines ? "border-black dark:border-white" : "border-gray-200 dark:border-zinc-800"}`,
|
|
3954
|
-
children: headerGroup.headers.map((header) => /* @__PURE__ */ (0,
|
|
3959
|
+
children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3955
3960
|
"th",
|
|
3956
3961
|
{
|
|
3957
3962
|
className: `${rowPadding} font-semibold text-gray-900 dark:text-zinc-100 text-sm align-top ${verticalLines ? "border-x border-black dark:border-white" : ""} ${header.column.columnDef.className || "wrap-break-word"}`,
|
|
@@ -3970,15 +3975,15 @@ function SimpleTable({
|
|
|
3970
3975
|
},
|
|
3971
3976
|
headerGroup.id
|
|
3972
3977
|
)) }),
|
|
3973
|
-
/* @__PURE__ */ (0,
|
|
3978
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("tbody", { className: "text-black dark:text-white font-semibold font-sans tabular-nums", children: isLoading && data.length === 0 ? Array.from({ length: skeletonCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3974
3979
|
"tr",
|
|
3975
3980
|
{
|
|
3976
3981
|
className: `border-b ${verticalLines ? "border-black dark:border-white" : "border-gray-100 dark:border-zinc-800/60 last:border-0"}`,
|
|
3977
|
-
children: columns.map((col, colIdx) => /* @__PURE__ */ (0,
|
|
3982
|
+
children: columns.map((col, colIdx) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3978
3983
|
"td",
|
|
3979
3984
|
{
|
|
3980
3985
|
className: `text-sm ${rowPadding} align-top ${verticalLines ? "border-x border-black dark:border-white" : ""}`,
|
|
3981
|
-
children: /* @__PURE__ */ (0,
|
|
3986
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3982
3987
|
"div",
|
|
3983
3988
|
{
|
|
3984
3989
|
className: `h-4 bg-gray-200 dark:bg-zinc-800/50 rounded-sm animate-pulse ${colIdx % 2 === 0 ? "w-3/4" : "w-1/2"} ${colIdx === 0 ? "w-4" : ""}`
|
|
@@ -3989,18 +3994,18 @@ function SimpleTable({
|
|
|
3989
3994
|
))
|
|
3990
3995
|
},
|
|
3991
3996
|
`skeleton-row-${i}`
|
|
3992
|
-
)) : data.length === 0 && !isLoading ? /* @__PURE__ */ (0,
|
|
3997
|
+
)) : data.length === 0 && !isLoading ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3993
3998
|
"td",
|
|
3994
3999
|
{
|
|
3995
4000
|
colSpan: columns.length,
|
|
3996
4001
|
className: "text-center text-gray-500 font-medium",
|
|
3997
|
-
children: emptyState || /* @__PURE__ */ (0,
|
|
4002
|
+
children: emptyState || /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "py-8", children: "No transactions found." })
|
|
3998
4003
|
}
|
|
3999
|
-
) }) : table.getRowModel().rows.map((row) => /* @__PURE__ */ (0,
|
|
4004
|
+
) }) : table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4000
4005
|
"tr",
|
|
4001
4006
|
{
|
|
4002
4007
|
className: `border-b ${verticalLines ? "border-black dark:border-white" : "border-gray-100 dark:border-zinc-800/60 last:border-0"} hover:bg-gray-50/50 dark:hover:bg-zinc-900/30 transition-colors`,
|
|
4003
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0,
|
|
4008
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4004
4009
|
"td",
|
|
4005
4010
|
{
|
|
4006
4011
|
className: `text-sm ${rowPadding} align-top ${verticalLines ? "border-x border-black dark:border-white" : ""} ${cell.column.columnDef.className || "wrap-break-word"}`,
|
|
@@ -4011,11 +4016,11 @@ function SimpleTable({
|
|
|
4011
4016
|
},
|
|
4012
4017
|
row.id
|
|
4013
4018
|
)) }),
|
|
4014
|
-
hasFooters && !isLoading && /* @__PURE__ */ (0,
|
|
4019
|
+
hasFooters && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("tfoot", { className: "text-black dark:text-white font-bold font-sans tabular-nums", children: table.getFooterGroups().map((footerGroup) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4015
4020
|
"tr",
|
|
4016
4021
|
{
|
|
4017
4022
|
className: `${verticalLines ? "border-t border-black dark:border-white" : "bg-gray-50/30 dark:bg-zinc-900/10"}`,
|
|
4018
|
-
children: footerGroup.headers.map((header) => /* @__PURE__ */ (0,
|
|
4023
|
+
children: footerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4019
4024
|
"td",
|
|
4020
4025
|
{
|
|
4021
4026
|
className: `text-sm ${rowPadding} ${verticalLines ? "border-x border-black dark:border-white" : ""} ${header.column.columnDef.className || "wrap-break-word"}`,
|
|
@@ -4032,14 +4037,14 @@ function SimpleTable({
|
|
|
4032
4037
|
]
|
|
4033
4038
|
}
|
|
4034
4039
|
),
|
|
4035
|
-
componentFooter && /* @__PURE__ */ (0,
|
|
4040
|
+
componentFooter && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "mt-2 pt-3 border-t border-gray-200 dark:border-zinc-800", children: componentFooter() })
|
|
4036
4041
|
] });
|
|
4037
4042
|
}
|
|
4038
4043
|
|
|
4039
4044
|
// src/components/Badge.tsx
|
|
4040
|
-
var
|
|
4041
|
-
var
|
|
4042
|
-
var Badge =
|
|
4045
|
+
var import_react19 = __toESM(require("react"));
|
|
4046
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
4047
|
+
var Badge = import_react19.default.forwardRef(
|
|
4043
4048
|
({
|
|
4044
4049
|
children,
|
|
4045
4050
|
className,
|
|
@@ -4060,7 +4065,7 @@ var Badge = import_react18.default.forwardRef(
|
|
|
4060
4065
|
md: "px-2.5 py-1 text-xs leading-tight font-semibold",
|
|
4061
4066
|
lg: "px-3 py-1.5 text-sm leading-tight font-semibold"
|
|
4062
4067
|
};
|
|
4063
|
-
return /* @__PURE__ */ (0,
|
|
4068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4064
4069
|
"span",
|
|
4065
4070
|
{
|
|
4066
4071
|
ref,
|
|
@@ -4074,13 +4079,13 @@ var Badge = import_react18.default.forwardRef(
|
|
|
4074
4079
|
Badge.displayName = "Badge";
|
|
4075
4080
|
|
|
4076
4081
|
// src/components/Branding.tsx
|
|
4077
|
-
var
|
|
4082
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
4078
4083
|
var Branding = ({
|
|
4079
4084
|
text,
|
|
4080
4085
|
disabled = false,
|
|
4081
4086
|
className
|
|
4082
4087
|
}) => {
|
|
4083
|
-
return /* @__PURE__ */ (0,
|
|
4088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4084
4089
|
"p",
|
|
4085
4090
|
{
|
|
4086
4091
|
className: cn(
|
|
@@ -4094,10 +4099,10 @@ var Branding = ({
|
|
|
4094
4099
|
};
|
|
4095
4100
|
|
|
4096
4101
|
// src/hooks/Fetches/useA4DataView.tsx
|
|
4097
|
-
var
|
|
4102
|
+
var import_react20 = require("react");
|
|
4098
4103
|
var import_react_to_print = require("react-to-print");
|
|
4099
4104
|
var import_lucide_react12 = require("lucide-react");
|
|
4100
|
-
var
|
|
4105
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
4101
4106
|
var useA4StatementView = ({
|
|
4102
4107
|
url,
|
|
4103
4108
|
v = 1,
|
|
@@ -4106,7 +4111,7 @@ var useA4StatementView = ({
|
|
|
4106
4111
|
startPage = 1
|
|
4107
4112
|
} = {}) => {
|
|
4108
4113
|
const { data: apiData, isLoading, get, error: apiError } = useApis_default();
|
|
4109
|
-
const contentRef = (0,
|
|
4114
|
+
const contentRef = (0, import_react20.useRef)(null);
|
|
4110
4115
|
const reactToPrintFn = (0, import_react_to_print.useReactToPrint)({
|
|
4111
4116
|
contentRef
|
|
4112
4117
|
});
|
|
@@ -4116,7 +4121,7 @@ var useA4StatementView = ({
|
|
|
4116
4121
|
await get({ url, v, params, delay });
|
|
4117
4122
|
}
|
|
4118
4123
|
};
|
|
4119
|
-
(0,
|
|
4124
|
+
(0, import_react20.useEffect)(() => {
|
|
4120
4125
|
getData();
|
|
4121
4126
|
}, [url, v, JSON.stringify(params), delay]);
|
|
4122
4127
|
const A4DataViewComponent = ({
|
|
@@ -4147,12 +4152,12 @@ var useA4StatementView = ({
|
|
|
4147
4152
|
}) => {
|
|
4148
4153
|
const { store } = useWarqadConfig();
|
|
4149
4154
|
const isActuallyLoading = externalLoading ?? isLoading;
|
|
4150
|
-
const measureContainerRef = (0,
|
|
4151
|
-
const [pages, setPages] = (0,
|
|
4152
|
-
const [isMeasuring, setIsMeasuring] = (0,
|
|
4153
|
-
const [globalFilter, setGlobalFilter] = (0,
|
|
4154
|
-
const [currentPageIndex, setCurrentPageIndex] = (0,
|
|
4155
|
-
const [pageSearch, setPageSearch] = (0,
|
|
4155
|
+
const measureContainerRef = (0, import_react20.useRef)(null);
|
|
4156
|
+
const [pages, setPages] = (0, import_react20.useState)([]);
|
|
4157
|
+
const [isMeasuring, setIsMeasuring] = (0, import_react20.useState)(true);
|
|
4158
|
+
const [globalFilter, setGlobalFilter] = (0, import_react20.useState)("");
|
|
4159
|
+
const [currentPageIndex, setCurrentPageIndex] = (0, import_react20.useState)(0);
|
|
4160
|
+
const [pageSearch, setPageSearch] = (0, import_react20.useState)("");
|
|
4156
4161
|
const displayColumnsForSearch = columns.filter((col) => !col.hide);
|
|
4157
4162
|
const filteredDisplayData = data.filter((row) => {
|
|
4158
4163
|
if (!globalFilter) return true;
|
|
@@ -4168,20 +4173,20 @@ var useA4StatementView = ({
|
|
|
4168
4173
|
const columnsWithFooters = columns.filter(
|
|
4169
4174
|
(col) => col.renderFooter && !col.hide
|
|
4170
4175
|
);
|
|
4171
|
-
const DisplayFinalTotalEl = columnsWithFooters.length > 0 ? /* @__PURE__ */ (0,
|
|
4176
|
+
const DisplayFinalTotalEl = columnsWithFooters.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4172
4177
|
"div",
|
|
4173
4178
|
{
|
|
4174
4179
|
id: "a4-final-total",
|
|
4175
4180
|
className: "mt-6 flex flex-wrap justify-end items-center pt-4 border-t border-black dark:border-zinc-700 print:border-black gap-4",
|
|
4176
4181
|
children: [
|
|
4177
|
-
/* @__PURE__ */ (0,
|
|
4178
|
-
columnsWithFooters.map((col, idx) => /* @__PURE__ */ (0,
|
|
4182
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "text-black dark:text-white print:text-black font-bold uppercase tracking-widest text-xs mr-auto", children: "Grand Totals" }),
|
|
4183
|
+
columnsWithFooters.map((col, idx) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4179
4184
|
"div",
|
|
4180
4185
|
{
|
|
4181
4186
|
className: "flex items-center gap-3 px-4 py-2 rounded-md border border-black dark:border-zinc-700 print:border-black",
|
|
4182
4187
|
children: [
|
|
4183
|
-
/* @__PURE__ */ (0,
|
|
4184
|
-
/* @__PURE__ */ (0,
|
|
4188
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-black dark:text-white print:text-black font-bold uppercase tracking-widest text-xs", children: typeof col.header === "string" ? col.header : typeof col.key === "string" ? col.key : "Total" }),
|
|
4189
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "text-base font-bold font-sans tabular-nums text-black dark:text-white print:text-black", children: col.renderFooter(filteredDisplayData) })
|
|
4185
4190
|
]
|
|
4186
4191
|
},
|
|
4187
4192
|
col.key || idx
|
|
@@ -4197,7 +4202,7 @@ var useA4StatementView = ({
|
|
|
4197
4202
|
renderFooter: c.renderFooter ? c.renderFooter.toString() : ""
|
|
4198
4203
|
}))
|
|
4199
4204
|
});
|
|
4200
|
-
(0,
|
|
4205
|
+
(0, import_react20.useEffect)(() => {
|
|
4201
4206
|
if (filteredDisplayData && filteredDisplayData.length > 0) {
|
|
4202
4207
|
setIsMeasuring(true);
|
|
4203
4208
|
setPages((prev) => prev.length === 0 ? [[]] : prev);
|
|
@@ -4212,7 +4217,7 @@ var useA4StatementView = ({
|
|
|
4212
4217
|
setCurrentPageIndex(0);
|
|
4213
4218
|
}
|
|
4214
4219
|
}, [depsString]);
|
|
4215
|
-
(0,
|
|
4220
|
+
(0, import_react20.useEffect)(() => {
|
|
4216
4221
|
if (!isMeasuring || filteredDisplayData.length === 0) return;
|
|
4217
4222
|
const timer = setTimeout(() => {
|
|
4218
4223
|
if (!measureContainerRef.current) return;
|
|
@@ -4268,28 +4273,28 @@ var useA4StatementView = ({
|
|
|
4268
4273
|
}, 150);
|
|
4269
4274
|
return () => clearTimeout(timer);
|
|
4270
4275
|
}, [isMeasuring, depsString]);
|
|
4271
|
-
const HeaderEl = /* @__PURE__ */ (0,
|
|
4276
|
+
const HeaderEl = /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4272
4277
|
"div",
|
|
4273
4278
|
{
|
|
4274
4279
|
className: "flex justify-between items-start mb-5 px-8 pt-8",
|
|
4275
4280
|
id: "a4-header-section",
|
|
4276
4281
|
children: [
|
|
4277
|
-
/* @__PURE__ */ (0,
|
|
4278
|
-
/* @__PURE__ */ (0,
|
|
4279
|
-
/* @__PURE__ */ (0,
|
|
4282
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("section", { children: [
|
|
4283
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h1", { className: "text-4xl font-bold text-blue-600 dark:text-blue-500 print:text-blue-600 tracking-tight uppercase", children: title }),
|
|
4284
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-gray-500 dark:text-gray-400 print:text-gray-500 mt-1 uppercase text-xs font-semibold tracking-wider", children: subtitle })
|
|
4280
4285
|
] }) }) }),
|
|
4281
|
-
/* @__PURE__ */ (0,
|
|
4282
|
-
/* @__PURE__ */ (0,
|
|
4283
|
-
/* @__PURE__ */ (0,
|
|
4284
|
-
store?.address && /* @__PURE__ */ (0,
|
|
4285
|
-
store?.phone && /* @__PURE__ */ (0,
|
|
4286
|
-
store?.email && /* @__PURE__ */ (0,
|
|
4286
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "text-right", children: [
|
|
4287
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h2", { className: "text-lg font-bold text-gray-800 dark:text-gray-100 print:text-gray-800", children: store?.name }),
|
|
4288
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "text-sm text-gray-500 dark:text-gray-400 print:text-gray-500 leading-relaxed text-right flex flex-col items-end", children: [
|
|
4289
|
+
store?.address && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "whitespace-pre-line", children: store.address }),
|
|
4290
|
+
store?.phone && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: store.phone }),
|
|
4291
|
+
store?.email && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: store.email })
|
|
4287
4292
|
] })
|
|
4288
4293
|
] })
|
|
4289
4294
|
]
|
|
4290
4295
|
}
|
|
4291
4296
|
);
|
|
4292
|
-
const DisplayInfoGridEl = Array.isArray(info) && info.length > 0 ? /* @__PURE__ */ (0,
|
|
4297
|
+
const DisplayInfoGridEl = Array.isArray(info) && info.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { id: "a4-info-grid", className: "px-8", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4293
4298
|
InfoGrid,
|
|
4294
4299
|
{
|
|
4295
4300
|
className: "mb-4",
|
|
@@ -4297,29 +4302,29 @@ var useA4StatementView = ({
|
|
|
4297
4302
|
isLoading: isActuallyLoading
|
|
4298
4303
|
}
|
|
4299
4304
|
) }) : null;
|
|
4300
|
-
const statusOverlay = isActuallyLoading || error || !data || data.length === 0 ? /* @__PURE__ */ (0,
|
|
4301
|
-
isActuallyLoading ? /* @__PURE__ */ (0,
|
|
4302
|
-
/* @__PURE__ */ (0,
|
|
4303
|
-
/* @__PURE__ */ (0,
|
|
4304
|
-
url && !isActuallyLoading && /* @__PURE__ */ (0,
|
|
4305
|
+
const statusOverlay = isActuallyLoading || error || !data || data.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-col relative w-full items-center justify-center py-12 min-h-[400px]", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col items-center justify-center p-8 bg-gray-50/50 dark:bg-zinc-900/30 rounded-2xl border border-dashed border-gray-300 dark:border-zinc-700 w-full max-w-lg text-center shadow-sm", children: [
|
|
4306
|
+
isActuallyLoading ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ClassicSpin, {}) }) : error ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-14 h-14 bg-red-100 dark:bg-red-500/10 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react12.AlertCircle, { className: "w-7 h-7 text-red-600 dark:text-red-500" }) }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-14 h-14 bg-gray-200 dark:bg-zinc-800 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react12.FileX, { className: "w-7 h-7 text-gray-500 dark:text-gray-400" }) }),
|
|
4307
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h3", { className: "text-lg font-bold text-gray-900 dark:text-white mb-2", children: isActuallyLoading ? "Loading data..." : error ? "Failed to Load Statement" : "No Records Found" }),
|
|
4308
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400 max-w-xs mb-6 leading-relaxed", children: isActuallyLoading ? "Please wait while we prepare your statement." : error ? typeof error === "string" ? error : "An unexpected error occurred while fetching the statement data." : "There are no transactions or records available in this requested statement." }),
|
|
4309
|
+
url && !isActuallyLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4305
4310
|
"button",
|
|
4306
4311
|
{
|
|
4307
4312
|
onClick: () => getData(),
|
|
4308
4313
|
className: "flex items-center gap-2 px-5 py-2 bg-black dark:bg-white text-white dark:text-black font-semibold rounded-lg shadow-md hover:bg-gray-800 dark:hover:bg-gray-100 transition-all active:scale-95 text-sm",
|
|
4309
4314
|
children: [
|
|
4310
|
-
/* @__PURE__ */ (0,
|
|
4315
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react12.RefreshCw, { size: 14 }),
|
|
4311
4316
|
"Try Again"
|
|
4312
4317
|
]
|
|
4313
4318
|
}
|
|
4314
4319
|
)
|
|
4315
4320
|
] }) }) : null;
|
|
4316
|
-
return /* @__PURE__ */ (0,
|
|
4317
|
-
isMeasuring && filteredDisplayData.length > 0 && /* @__PURE__ */ (0,
|
|
4321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col relative w-full items-center", children: [
|
|
4322
|
+
isMeasuring && filteredDisplayData.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "absolute top-0 opacity-0 pointer-events-none -left-full", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4318
4323
|
"div",
|
|
4319
4324
|
{
|
|
4320
4325
|
style: { width: "210mm", boxSizing: "border-box" },
|
|
4321
4326
|
className: "bg-white",
|
|
4322
|
-
children: /* @__PURE__ */ (0,
|
|
4327
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4323
4328
|
"div",
|
|
4324
4329
|
{
|
|
4325
4330
|
ref: measureContainerRef,
|
|
@@ -4327,9 +4332,9 @@ var useA4StatementView = ({
|
|
|
4327
4332
|
children: [
|
|
4328
4333
|
HeaderEl,
|
|
4329
4334
|
DisplayInfoGridEl,
|
|
4330
|
-
/* @__PURE__ */ (0,
|
|
4331
|
-
/* @__PURE__ */ (0,
|
|
4332
|
-
/* @__PURE__ */ (0,
|
|
4335
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "grow w-full px-8 pb-8", children: [
|
|
4336
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "mb-4 border-b border-gray-200 dark:border-zinc-800 print:border-gray-200 pb-2 flex items-center gap-2 justify-between px-2 mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h3", { className: "text-sm font-bold text-gray-800 dark:text-gray-100 print:text-gray-800 uppercase tracking-wide shrink-0", children: tableTitle }) }),
|
|
4337
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4333
4338
|
SimpleTable,
|
|
4334
4339
|
{
|
|
4335
4340
|
columns,
|
|
@@ -4347,52 +4352,52 @@ var useA4StatementView = ({
|
|
|
4347
4352
|
)
|
|
4348
4353
|
}
|
|
4349
4354
|
) }),
|
|
4350
|
-
/* @__PURE__ */ (0,
|
|
4355
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "py-2 px-0 md:px-4 w-full", ref: contentRef, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-col gap-8 print:block print:gap-0 w-full items-center", children: pages.map((pageData, pageIndex) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4351
4356
|
"div",
|
|
4352
4357
|
{
|
|
4353
4358
|
className: pageIndex === currentPageIndex ? "w-full" : "hidden print:block w-full",
|
|
4354
|
-
children: /* @__PURE__ */ (0,
|
|
4359
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4355
4360
|
PageA4,
|
|
4356
4361
|
{
|
|
4357
4362
|
className: "w-full",
|
|
4358
4363
|
pageNumber: pageIndex + 1,
|
|
4359
4364
|
totalPages: pages.length,
|
|
4360
4365
|
isLastPage: pageIndex === pages.length - 1,
|
|
4361
|
-
children: /* @__PURE__ */ (0,
|
|
4362
|
-
/* @__PURE__ */ (0,
|
|
4366
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col h-full grow w-full", children: [
|
|
4367
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("header", { className: "flex justify-between gap-2 items-center px-8 pt-4 print:hidden", children: [
|
|
4363
4368
|
headers,
|
|
4364
|
-
printable && pageIndex === currentPageIndex && /* @__PURE__ */ (0,
|
|
4365
|
-
/* @__PURE__ */ (0,
|
|
4369
|
+
printable && pageIndex === currentPageIndex && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex items-center justify-end ", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
4370
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4366
4371
|
"button",
|
|
4367
4372
|
{
|
|
4368
4373
|
onClick: async () => await getData(),
|
|
4369
4374
|
disabled: isLoading,
|
|
4370
4375
|
className: "flex items-center gap-2 px-3 py-1.5 text-gray-600 dark:text-gray-300 hover:text-black dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-all disabled:opacity-50",
|
|
4371
4376
|
children: [
|
|
4372
|
-
/* @__PURE__ */ (0,
|
|
4377
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4373
4378
|
import_lucide_react12.RefreshCw,
|
|
4374
4379
|
{
|
|
4375
4380
|
size: 16,
|
|
4376
4381
|
className: isLoading ? "animate-spin" : ""
|
|
4377
4382
|
}
|
|
4378
4383
|
),
|
|
4379
|
-
/* @__PURE__ */ (0,
|
|
4384
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-xs font-semibold", children: "Reload" })
|
|
4380
4385
|
]
|
|
4381
4386
|
}
|
|
4382
4387
|
),
|
|
4383
|
-
/* @__PURE__ */ (0,
|
|
4388
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4384
4389
|
"button",
|
|
4385
4390
|
{
|
|
4386
4391
|
onClick: () => reactToPrintFn(),
|
|
4387
4392
|
className: "flex items-center gap-2 px-4 py-1.5 bg-black dark:bg-zinc-800 text-white rounded-md text-xs font-bold shadow-sm hover:bg-zinc-800 dark:hover:bg-zinc-700 transition-all active:scale-95",
|
|
4388
4393
|
children: [
|
|
4389
|
-
/* @__PURE__ */ (0,
|
|
4394
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react12.Printer, { size: 16 }),
|
|
4390
4395
|
"Print"
|
|
4391
4396
|
]
|
|
4392
4397
|
}
|
|
4393
4398
|
),
|
|
4394
|
-
/* @__PURE__ */ (0,
|
|
4395
|
-
/* @__PURE__ */ (0,
|
|
4399
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1.5 ml-2 pl-2 border-l border-gray-200 dark:border-zinc-700", children: [
|
|
4400
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4396
4401
|
"button",
|
|
4397
4402
|
{
|
|
4398
4403
|
onClick: (e) => {
|
|
@@ -4403,11 +4408,11 @@ var useA4StatementView = ({
|
|
|
4403
4408
|
},
|
|
4404
4409
|
disabled: currentPageIndex === 0,
|
|
4405
4410
|
className: "p-1 rounded hover:bg-gray-100 dark:hover:bg-zinc-800 disabled:opacity-30 transition-colors text-gray-600 dark:text-gray-400",
|
|
4406
|
-
children: /* @__PURE__ */ (0,
|
|
4411
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react12.ChevronLeft, { size: 18 })
|
|
4407
4412
|
}
|
|
4408
4413
|
),
|
|
4409
|
-
/* @__PURE__ */ (0,
|
|
4410
|
-
/* @__PURE__ */ (0,
|
|
4414
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1 text-[11px] font-bold tabular-nums", children: [
|
|
4415
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4411
4416
|
Select,
|
|
4412
4417
|
{
|
|
4413
4418
|
value: currentPageIndex + 1,
|
|
@@ -4420,9 +4425,9 @@ var useA4StatementView = ({
|
|
|
4420
4425
|
variant: "ghost",
|
|
4421
4426
|
containerClassName: "inline-block",
|
|
4422
4427
|
children: [
|
|
4423
|
-
/* @__PURE__ */ (0,
|
|
4424
|
-
/* @__PURE__ */ (0,
|
|
4425
|
-
/* @__PURE__ */ (0,
|
|
4428
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SelectTrigger, { className: "h-7 px-2 min-w-[40px] border border-gray-200 dark:border-zinc-700 rounded flex items-center justify-center bg-white dark:bg-zinc-900 hover:bg-gray-100 dark:hover:bg-zinc-800 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-gray-900 dark:text-white", children: currentPageIndex + 1 }) }),
|
|
4429
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(SelectContent, { className: "min-w-[100px] max-h-64 overflow-y-auto p-0", children: [
|
|
4430
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "p-2 border-b border-gray-100 dark:border-zinc-800 sticky top-0 bg-white dark:bg-zinc-950 z-10", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4426
4431
|
"input",
|
|
4427
4432
|
{
|
|
4428
4433
|
type: "text",
|
|
@@ -4434,17 +4439,17 @@ var useA4StatementView = ({
|
|
|
4434
4439
|
autoFocus: true
|
|
4435
4440
|
}
|
|
4436
4441
|
) }),
|
|
4437
|
-
/* @__PURE__ */ (0,
|
|
4442
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "p-1", children: pages.map((_, i) => i + 1).filter(
|
|
4438
4443
|
(p) => String(p).includes(pageSearch)
|
|
4439
|
-
).map((p) => /* @__PURE__ */ (0,
|
|
4444
|
+
).map((p) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SelectItem, { value: p, children: p }, p)) })
|
|
4440
4445
|
] })
|
|
4441
4446
|
]
|
|
4442
4447
|
}
|
|
4443
4448
|
),
|
|
4444
|
-
/* @__PURE__ */ (0,
|
|
4445
|
-
/* @__PURE__ */ (0,
|
|
4449
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-gray-400 mx-0.5", children: "/" }),
|
|
4450
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-gray-600 dark:text-gray-400", children: pages.length })
|
|
4446
4451
|
] }),
|
|
4447
|
-
/* @__PURE__ */ (0,
|
|
4452
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4448
4453
|
"button",
|
|
4449
4454
|
{
|
|
4450
4455
|
onClick: (e) => {
|
|
@@ -4455,7 +4460,7 @@ var useA4StatementView = ({
|
|
|
4455
4460
|
},
|
|
4456
4461
|
disabled: currentPageIndex === pages.length - 1,
|
|
4457
4462
|
className: "p-1 rounded hover:bg-gray-100 dark:hover:bg-zinc-800 disabled:opacity-30 transition-colors text-gray-600 dark:text-gray-400",
|
|
4458
|
-
children: /* @__PURE__ */ (0,
|
|
4463
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react12.ChevronRight, { size: 18 })
|
|
4459
4464
|
}
|
|
4460
4465
|
)
|
|
4461
4466
|
] })
|
|
@@ -4463,10 +4468,10 @@ var useA4StatementView = ({
|
|
|
4463
4468
|
] }),
|
|
4464
4469
|
pageIndex === 0 && HeaderEl,
|
|
4465
4470
|
pageIndex === 0 && DisplayInfoGridEl,
|
|
4466
|
-
/* @__PURE__ */ (0,
|
|
4467
|
-
pageIndex === 0 && /* @__PURE__ */ (0,
|
|
4468
|
-
/* @__PURE__ */ (0,
|
|
4469
|
-
/* @__PURE__ */ (0,
|
|
4471
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "grow w-full px-8 pb-8", children: [
|
|
4472
|
+
pageIndex === 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "mb-4 border-b border-gray-200 dark:border-zinc-700 print:border-gray-200 pb-2 flex items-center gap-2 justify-between px-2 mt-2 print:hidden", children: [
|
|
4473
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h3", { className: "text-sm font-bold text-gray-800 dark:text-gray-100 print:text-gray-800 uppercase tracking-wide shrink-0", children: tableTitle }),
|
|
4474
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4470
4475
|
"input",
|
|
4471
4476
|
{
|
|
4472
4477
|
type: "text",
|
|
@@ -4477,9 +4482,9 @@ var useA4StatementView = ({
|
|
|
4477
4482
|
}
|
|
4478
4483
|
)
|
|
4479
4484
|
] }),
|
|
4480
|
-
pageIndex === 0 && /* @__PURE__ */ (0,
|
|
4481
|
-
pageIndex > 0 && /* @__PURE__ */ (0,
|
|
4482
|
-
statusOverlay ? /* @__PURE__ */ (0,
|
|
4485
|
+
pageIndex === 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "hidden print:flex mb-4 border-b border-gray-200 print:border-gray-200 pb-2 items-center gap-2 justify-between px-2 mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h3", { className: "text-sm font-bold text-gray-800 print:text-gray-800 uppercase tracking-wide shrink-0", children: tableTitle }) }),
|
|
4486
|
+
pageIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "h-7 print:h-0" }),
|
|
4487
|
+
statusOverlay ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "px-8 pb-8", children: statusOverlay }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4483
4488
|
SimpleTable,
|
|
4484
4489
|
{
|
|
4485
4490
|
columns,
|
|
@@ -4515,10 +4520,10 @@ var useA4StatementView = ({
|
|
|
4515
4520
|
var useA4DataView_default = useA4StatementView;
|
|
4516
4521
|
|
|
4517
4522
|
// src/hooks/Fetches/useTransaction.tsx
|
|
4518
|
-
var
|
|
4523
|
+
var import_react21 = require("react");
|
|
4519
4524
|
var import_lucide_react13 = require("lucide-react");
|
|
4520
4525
|
var import_moment = __toESM(require("moment"));
|
|
4521
|
-
var
|
|
4526
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
4522
4527
|
var useTransaction = ({
|
|
4523
4528
|
url,
|
|
4524
4529
|
v = 1,
|
|
@@ -4526,7 +4531,7 @@ var useTransaction = ({
|
|
|
4526
4531
|
params = {},
|
|
4527
4532
|
dateFilter = true
|
|
4528
4533
|
}) => {
|
|
4529
|
-
const [date, setDate] = (0,
|
|
4534
|
+
const [date, setDate] = (0, import_react21.useState)(
|
|
4530
4535
|
(0, import_moment.default)().format("DD/MM/YYYY")
|
|
4531
4536
|
);
|
|
4532
4537
|
const dateObj = {};
|
|
@@ -4544,7 +4549,7 @@ var useTransaction = ({
|
|
|
4544
4549
|
delay
|
|
4545
4550
|
});
|
|
4546
4551
|
};
|
|
4547
|
-
(0,
|
|
4552
|
+
(0, import_react21.useEffect)(() => {
|
|
4548
4553
|
getData();
|
|
4549
4554
|
}, [url, v, JSON.stringify(params), delay, date]);
|
|
4550
4555
|
const TransactionViewComponent = ({
|
|
@@ -4571,21 +4576,21 @@ var useTransaction = ({
|
|
|
4571
4576
|
createTitle = "Add New",
|
|
4572
4577
|
...rest
|
|
4573
4578
|
}) => {
|
|
4574
|
-
const emptyState = !isLoading && (error || !data || data.length === 0) ? /* @__PURE__ */ (0,
|
|
4579
|
+
const emptyState = !isLoading && (error || !data || data.length === 0) ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4575
4580
|
"div",
|
|
4576
4581
|
{
|
|
4577
4582
|
className: `flex flex-col relative w-full items-center justify-center py-12 min-h-[300px] ${className}`,
|
|
4578
|
-
children: /* @__PURE__ */ (0,
|
|
4579
|
-
error ? /* @__PURE__ */ (0,
|
|
4580
|
-
/* @__PURE__ */ (0,
|
|
4581
|
-
/* @__PURE__ */ (0,
|
|
4582
|
-
url && /* @__PURE__ */ (0,
|
|
4583
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-col items-center justify-center p-8 bg-gray-50/50 dark:bg-zinc-900/30 rounded-2xl border border-dashed border-gray-300 dark:border-zinc-700 w-full max-w-lg text-center shadow-sm", children: [
|
|
4584
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "w-14 h-14 bg-red-100 dark:bg-red-500/10 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react13.AlertCircle, { className: "w-7 h-7 text-red-600 dark:text-red-500" }) }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "w-14 h-14 bg-gray-200 dark:bg-zinc-800 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react13.FileX, { className: "w-7 h-7 text-gray-500 dark:text-gray-400" }) }),
|
|
4585
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("h3", { className: "text-lg font-bold text-gray-900 dark:text-white mb-2", children: error ? "Failed to Load Data" : "No Records Found" }),
|
|
4586
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400 max-w-xs mb-6 leading-relaxed", children: error ? typeof error === "string" ? error : "An unexpected error occurred while fetching the data." : "There are no transactions or records available to display here." }),
|
|
4587
|
+
url && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
4583
4588
|
"button",
|
|
4584
4589
|
{
|
|
4585
4590
|
onClick: () => getData(),
|
|
4586
4591
|
className: "flex items-center gap-2 px-5 py-2 bg-black dark:bg-white text-white dark:text-black font-semibold rounded-lg shadow-md hover:bg-gray-800 dark:hover:bg-gray-100 transition-all active:scale-95 text-sm",
|
|
4587
4592
|
children: [
|
|
4588
|
-
/* @__PURE__ */ (0,
|
|
4593
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react13.RefreshCw, { size: 14 }),
|
|
4589
4594
|
"Try Again"
|
|
4590
4595
|
]
|
|
4591
4596
|
}
|
|
@@ -4593,14 +4598,14 @@ var useTransaction = ({
|
|
|
4593
4598
|
] })
|
|
4594
4599
|
}
|
|
4595
4600
|
) : void 0;
|
|
4596
|
-
return /* @__PURE__ */ (0,
|
|
4597
|
-
/* @__PURE__ */ (0,
|
|
4598
|
-
/* @__PURE__ */ (0,
|
|
4599
|
-
/* @__PURE__ */ (0,
|
|
4600
|
-
/* @__PURE__ */ (0,
|
|
4601
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Card, { children: [
|
|
4602
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Card.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("header", { className: "flex items-center justify-between gap-4 py-2", children: [
|
|
4603
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "space-y-1", children: [
|
|
4604
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Card.Title, { children: title }),
|
|
4605
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Card.Description, { children: description })
|
|
4601
4606
|
] }),
|
|
4602
|
-
/* @__PURE__ */ (0,
|
|
4603
|
-
dateFilter && /* @__PURE__ */ (0,
|
|
4607
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("section", { className: "flex gap-2 items-center", children: [
|
|
4608
|
+
dateFilter && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4604
4609
|
Fields_default.DateInput,
|
|
4605
4610
|
{
|
|
4606
4611
|
value: date,
|
|
@@ -4610,20 +4615,20 @@ var useTransaction = ({
|
|
|
4610
4615
|
}
|
|
4611
4616
|
}
|
|
4612
4617
|
),
|
|
4613
|
-
/* @__PURE__ */ (0,
|
|
4618
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4614
4619
|
Button,
|
|
4615
4620
|
{
|
|
4616
4621
|
size: "sm",
|
|
4617
4622
|
className: "rounded-md!",
|
|
4618
4623
|
onClick: onCreate,
|
|
4619
4624
|
variant: "primary",
|
|
4620
|
-
icon: /* @__PURE__ */ (0,
|
|
4625
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react13.Plus, {}),
|
|
4621
4626
|
children: createTitle
|
|
4622
4627
|
}
|
|
4623
4628
|
)
|
|
4624
4629
|
] })
|
|
4625
4630
|
] }) }),
|
|
4626
|
-
/* @__PURE__ */ (0,
|
|
4631
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Card.Content, { className: "space-y-6", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: `w-full ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4627
4632
|
DataTable,
|
|
4628
4633
|
{
|
|
4629
4634
|
columns,
|