@sustaina/shared-ui 1.10.1 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +58 -3
- package/dist/index.d.ts +58 -3
- package/dist/index.js +416 -209
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +308 -103
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2,10 +2,10 @@ import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
|
2
2
|
import clsx2, { clsx } from 'clsx';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
5
|
+
import * as React4 from 'react';
|
|
6
|
+
import React4__default, { forwardRef, useRef, useMemo, useCallback, isValidElement, useState, useEffect, createElement } from 'react';
|
|
7
7
|
import { format, isValid, parseISO, isAfter, compareAsc, parse } from 'date-fns';
|
|
8
|
-
import { CircleX, CircleHelp, Undo, Redo, Bold, Italic, Underline, Strikethrough, Code, Pilcrow, Heading1, Heading2, Heading3, List as List$1, ListOrdered, Quote, CodeSquare, Link, Link2Off, Image, AlignLeft, AlignCenter, AlignRight, XIcon, ChevronRight, CheckIcon, Triangle, CalendarIcon, X, Search, ChevronUp, ChevronDown, Plus, ChevronLeft, CircleUserRound, PanelLeftIcon, Bug, GripVertical, Info, CircleMinus, Minus } from 'lucide-react';
|
|
8
|
+
import { CircleX, CircleHelp, Undo, Redo, Bold, Italic, Underline, Strikethrough, Code, Pilcrow, Heading1, Heading2, Heading3, List as List$1, ListOrdered, Quote, CodeSquare, Link, Link2Off, Image as Image$1, AlignLeft, AlignCenter, AlignRight, XIcon, ChevronRight, CheckIcon, Triangle, CalendarIcon, X, Search, ChevronUp, ChevronDown, Plus, ChevronLeft, CircleUserRound, PanelLeftIcon, Bug, GripVertical, Info, CircleMinus, Minus } from 'lucide-react';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
10
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
11
11
|
import { useForm, FormProvider, Controller, useFormContext, useFormState, useFieldArray, useWatch } from 'react-hook-form';
|
|
@@ -48,6 +48,7 @@ import { mergeRegister } from '@lexical/utils';
|
|
|
48
48
|
import { $setBlocksType } from '@lexical/selection';
|
|
49
49
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
50
50
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
51
|
+
import Cropper from 'react-easy-crop';
|
|
51
52
|
|
|
52
53
|
var __defProp = Object.defineProperty;
|
|
53
54
|
var __export = (target, all) => {
|
|
@@ -939,7 +940,7 @@ var OPERATOR_LABEL = {
|
|
|
939
940
|
containsAll: "Contains all of"
|
|
940
941
|
};
|
|
941
942
|
var OperatorSelect = ({ row, operators, onChangeOperator, error }) => {
|
|
942
|
-
|
|
943
|
+
React4__default.useEffect(() => {
|
|
943
944
|
if (!operators.length) return;
|
|
944
945
|
if (!operators.includes(row.operator)) {
|
|
945
946
|
onChangeOperator(operators[0]);
|
|
@@ -974,15 +975,15 @@ function Label2({ className, ...props }) {
|
|
|
974
975
|
);
|
|
975
976
|
}
|
|
976
977
|
var Form = FormProvider;
|
|
977
|
-
var FormFieldContext =
|
|
978
|
+
var FormFieldContext = React4.createContext({});
|
|
978
979
|
var FormField = ({
|
|
979
980
|
...props
|
|
980
981
|
}) => {
|
|
981
982
|
return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
|
|
982
983
|
};
|
|
983
984
|
var useFormField = () => {
|
|
984
|
-
const fieldContext =
|
|
985
|
-
const itemContext =
|
|
985
|
+
const fieldContext = React4.useContext(FormFieldContext);
|
|
986
|
+
const itemContext = React4.useContext(FormItemContext);
|
|
986
987
|
const { getFieldState } = useFormContext();
|
|
987
988
|
const formState = useFormState({ name: fieldContext.name });
|
|
988
989
|
const fieldState = getFieldState(fieldContext.name, formState);
|
|
@@ -999,18 +1000,17 @@ var useFormField = () => {
|
|
|
999
1000
|
...fieldState
|
|
1000
1001
|
};
|
|
1001
1002
|
};
|
|
1002
|
-
var FormItemContext =
|
|
1003
|
+
var FormItemContext = React4.createContext({});
|
|
1003
1004
|
function FormItem({ className, ...props }) {
|
|
1004
|
-
const id =
|
|
1005
|
+
const id = React4.useId();
|
|
1005
1006
|
return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx("div", { "data-slot": "form-item", className: cn("grid gap-2", className), ...props }) });
|
|
1006
1007
|
}
|
|
1007
1008
|
function FormLabel({ className, ...props }) {
|
|
1008
|
-
const {
|
|
1009
|
+
const { formItemId } = useFormField();
|
|
1009
1010
|
return /* @__PURE__ */ jsx(
|
|
1010
1011
|
Label2,
|
|
1011
1012
|
{
|
|
1012
1013
|
"data-slot": "form-label",
|
|
1013
|
-
"data-error": !!error,
|
|
1014
1014
|
className: cn("data-[error=true]:text-destructive", className),
|
|
1015
1015
|
htmlFor: formItemId,
|
|
1016
1016
|
...props
|
|
@@ -1060,23 +1060,6 @@ function FormMessage({ className, ...props }) {
|
|
|
1060
1060
|
}
|
|
1061
1061
|
);
|
|
1062
1062
|
}
|
|
1063
|
-
var InputPrimitive = React5.forwardRef(
|
|
1064
|
-
({ className, type = "text", ...props }, ref) => {
|
|
1065
|
-
return /* @__PURE__ */ jsx(
|
|
1066
|
-
"input",
|
|
1067
|
-
{
|
|
1068
|
-
ref,
|
|
1069
|
-
type,
|
|
1070
|
-
className: cn(
|
|
1071
|
-
"placeholder:text-neutral-400 text-neutral-900 flex h-10 w-full min-w-0 items-center rounded-lg border bg-white px-4 text-sm transition-colors outline-none file:inline-flex file:h-7 file:rounded-md file:border-0 file:bg-transparent file:px-2 file:text-sm file:font-medium hover:border-neutral-500 focus-visible:border-neutral-900 focus-visible:ring-0 disabled:cursor-not-allowed disabled:bg-neutral-100 disabled:text-neutral-400 disabled:border-neutral-200 aria-invalid:border-destructive",
|
|
1072
|
-
className
|
|
1073
|
-
),
|
|
1074
|
-
...props
|
|
1075
|
-
}
|
|
1076
|
-
);
|
|
1077
|
-
}
|
|
1078
|
-
);
|
|
1079
|
-
InputPrimitive.displayName = "InputPrimitive";
|
|
1080
1063
|
var spinnerVariants = cva("relative inline-block aspect-square transform-gpu", {
|
|
1081
1064
|
variants: {
|
|
1082
1065
|
variant: {
|
|
@@ -1123,6 +1106,23 @@ var Spinner = ({ className, variant, size = "default", ...props }) => /* @__PURE
|
|
|
1123
1106
|
]
|
|
1124
1107
|
}
|
|
1125
1108
|
);
|
|
1109
|
+
var InputPrimitive = React4.forwardRef(
|
|
1110
|
+
({ className, type = "text", ...props }, ref) => {
|
|
1111
|
+
return /* @__PURE__ */ jsx(
|
|
1112
|
+
"input",
|
|
1113
|
+
{
|
|
1114
|
+
ref,
|
|
1115
|
+
type,
|
|
1116
|
+
className: cn(
|
|
1117
|
+
"placeholder:text-neutral-400 text-neutral-900 flex h-10 w-full min-w-0 items-center rounded-lg border bg-white px-4 text-sm transition-colors outline-none file:inline-flex file:h-7 file:rounded-md file:border-0 file:bg-transparent file:px-2 file:text-sm file:font-medium hover:border-neutral-500 focus-visible:border-neutral-900 focus-visible:ring-0 disabled:cursor-not-allowed disabled:bg-neutral-100 disabled:text-neutral-400 disabled:border-neutral-200 aria-invalid:border-destructive",
|
|
1118
|
+
className
|
|
1119
|
+
),
|
|
1120
|
+
...props
|
|
1121
|
+
}
|
|
1122
|
+
);
|
|
1123
|
+
}
|
|
1124
|
+
);
|
|
1125
|
+
InputPrimitive.displayName = "InputPrimitive";
|
|
1126
1126
|
var inputVariants = cva("", {
|
|
1127
1127
|
variants: {
|
|
1128
1128
|
controlSize: {
|
|
@@ -1145,7 +1145,7 @@ var inputVariants = cva("", {
|
|
|
1145
1145
|
appearance: "filled"
|
|
1146
1146
|
}
|
|
1147
1147
|
});
|
|
1148
|
-
var Input =
|
|
1148
|
+
var Input = React4.forwardRef(
|
|
1149
1149
|
({
|
|
1150
1150
|
className,
|
|
1151
1151
|
wrapperClassName,
|
|
@@ -1154,14 +1154,17 @@ var Input = React5.forwardRef(
|
|
|
1154
1154
|
appearance,
|
|
1155
1155
|
prefix,
|
|
1156
1156
|
prefixProps,
|
|
1157
|
+
prefixInteractive,
|
|
1157
1158
|
suffix,
|
|
1158
1159
|
suffixProps,
|
|
1160
|
+
suffixInteractive,
|
|
1159
1161
|
invalid,
|
|
1160
1162
|
loading,
|
|
1161
1163
|
loadingIcon,
|
|
1162
1164
|
validationMessage,
|
|
1163
1165
|
validationIcon,
|
|
1164
1166
|
validationMessageProps,
|
|
1167
|
+
onValueChange,
|
|
1165
1168
|
type = "text",
|
|
1166
1169
|
...rest
|
|
1167
1170
|
}, ref) => {
|
|
@@ -1171,10 +1174,18 @@ var Input = React5.forwardRef(
|
|
|
1171
1174
|
const {
|
|
1172
1175
|
"aria-invalid": ariaInvalidProp,
|
|
1173
1176
|
"aria-describedby": ariaDescribedByProp,
|
|
1177
|
+
onChange: onChangeProp,
|
|
1174
1178
|
...inputProps
|
|
1175
1179
|
} = rest;
|
|
1176
1180
|
const ariaInvalid = invalid ?? ariaInvalidProp;
|
|
1177
|
-
const messageId =
|
|
1181
|
+
const messageId = React4.useId();
|
|
1182
|
+
const handleChange = React4.useCallback(
|
|
1183
|
+
(event) => {
|
|
1184
|
+
onChangeProp?.(event);
|
|
1185
|
+
onValueChange?.(event.target.value);
|
|
1186
|
+
},
|
|
1187
|
+
[onChangeProp, onValueChange]
|
|
1188
|
+
);
|
|
1178
1189
|
const resolvedAriaInvalid = typeof ariaInvalid === "string" ? ariaInvalid : ariaInvalid ? true : void 0;
|
|
1179
1190
|
const describedBy = validationMessage ? [ariaDescribedByProp, messageId].filter(Boolean).join(" ") : ariaDescribedByProp;
|
|
1180
1191
|
const controlWrapperClassName = cn(
|
|
@@ -1196,6 +1207,7 @@ var Input = React5.forwardRef(
|
|
|
1196
1207
|
),
|
|
1197
1208
|
"aria-invalid": resolvedAriaInvalid,
|
|
1198
1209
|
"aria-describedby": describedBy || void 0,
|
|
1210
|
+
onChange: handleChange,
|
|
1199
1211
|
...inputProps
|
|
1200
1212
|
}
|
|
1201
1213
|
);
|
|
@@ -1215,7 +1227,8 @@ var Input = React5.forwardRef(
|
|
|
1215
1227
|
{
|
|
1216
1228
|
...prefixRest,
|
|
1217
1229
|
className: cn(
|
|
1218
|
-
"
|
|
1230
|
+
"absolute left-3 top-1/2 -translate-y-1/2 inline-flex items-center text-muted-foreground",
|
|
1231
|
+
!prefixInteractive && "pointer-events-none",
|
|
1219
1232
|
prefixClassName
|
|
1220
1233
|
),
|
|
1221
1234
|
children: prefix
|
|
@@ -1227,7 +1240,8 @@ var Input = React5.forwardRef(
|
|
|
1227
1240
|
{
|
|
1228
1241
|
...suffixRest,
|
|
1229
1242
|
className: cn(
|
|
1230
|
-
"
|
|
1243
|
+
"absolute right-3 top-1/2 -translate-y-1/2 inline-flex items-center gap-2 text-muted-foreground",
|
|
1244
|
+
!suffixInteractive && "pointer-events-none",
|
|
1231
1245
|
suffixClassName
|
|
1232
1246
|
),
|
|
1233
1247
|
children: suffixContent
|
|
@@ -1490,20 +1504,20 @@ function DatePicker({
|
|
|
1490
1504
|
className,
|
|
1491
1505
|
...props
|
|
1492
1506
|
}) {
|
|
1493
|
-
const today =
|
|
1494
|
-
const [displayed, setDisplayed] =
|
|
1507
|
+
const today = React4.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
|
|
1508
|
+
const [displayed, setDisplayed] = React4.useState(
|
|
1495
1509
|
selectedDate ? new Date(selectedDate) : /* @__PURE__ */ new Date()
|
|
1496
1510
|
);
|
|
1497
1511
|
minDate = clampToDay(minDate);
|
|
1498
1512
|
maxDate = clampToDay(maxDate);
|
|
1499
|
-
const disabledSet =
|
|
1513
|
+
const disabledSet = React4.useMemo(() => {
|
|
1500
1514
|
const s = /* @__PURE__ */ new Set();
|
|
1501
1515
|
disabledDates?.forEach((d) => s.add(startOfDay(d).toISOString()));
|
|
1502
1516
|
return s;
|
|
1503
1517
|
}, [disabledDates]);
|
|
1504
1518
|
const displayYear = displayed.getFullYear();
|
|
1505
1519
|
const displayMonth = displayed.getMonth();
|
|
1506
|
-
const weekdays =
|
|
1520
|
+
const weekdays = React4.useMemo(() => {
|
|
1507
1521
|
const labels = [];
|
|
1508
1522
|
for (let i = 0; i < 7; i++) {
|
|
1509
1523
|
const idx = i;
|
|
@@ -1512,7 +1526,7 @@ function DatePicker({
|
|
|
1512
1526
|
}
|
|
1513
1527
|
return labels;
|
|
1514
1528
|
}, [callbacks]);
|
|
1515
|
-
const grid =
|
|
1529
|
+
const grid = React4.useMemo(() => buildCalendarGrid(displayed, true), [displayed]);
|
|
1516
1530
|
const isDateDisabled = (date) => {
|
|
1517
1531
|
const d = startOfDay(date);
|
|
1518
1532
|
if (minDate && d < minDate) return true;
|
|
@@ -1522,7 +1536,7 @@ function DatePicker({
|
|
|
1522
1536
|
};
|
|
1523
1537
|
const minYear = minDate?.getFullYear();
|
|
1524
1538
|
const maxYear = maxDate?.getFullYear();
|
|
1525
|
-
const getMonthLabel =
|
|
1539
|
+
const getMonthLabel = React4.useCallback(
|
|
1526
1540
|
(year, monthIndex) => {
|
|
1527
1541
|
const label = callbacks?.monthLabel?.(year, monthIndex);
|
|
1528
1542
|
if (label === null || label === void 0) {
|
|
@@ -1532,7 +1546,7 @@ function DatePicker({
|
|
|
1532
1546
|
},
|
|
1533
1547
|
[callbacks]
|
|
1534
1548
|
);
|
|
1535
|
-
const getYearLabel =
|
|
1549
|
+
const getYearLabel = React4.useCallback(
|
|
1536
1550
|
(year) => {
|
|
1537
1551
|
const label = callbacks?.yearLabel?.(year);
|
|
1538
1552
|
if (label === null || label === void 0) return String(year);
|
|
@@ -1540,7 +1554,7 @@ function DatePicker({
|
|
|
1540
1554
|
},
|
|
1541
1555
|
[callbacks]
|
|
1542
1556
|
);
|
|
1543
|
-
const clampMonthToBounds =
|
|
1557
|
+
const clampMonthToBounds = React4.useCallback(
|
|
1544
1558
|
(year, monthIndex) => {
|
|
1545
1559
|
let output = monthIndex;
|
|
1546
1560
|
if (typeof minYear === "number" && year === minYear && minDate) {
|
|
@@ -1555,7 +1569,7 @@ function DatePicker({
|
|
|
1555
1569
|
},
|
|
1556
1570
|
[maxDate, minDate, maxYear, minYear]
|
|
1557
1571
|
);
|
|
1558
|
-
const yearOptions =
|
|
1572
|
+
const yearOptions = React4.useMemo(() => {
|
|
1559
1573
|
const fallbackWindow = 50;
|
|
1560
1574
|
const start = typeof minYear === "number" ? minYear : displayYear - fallbackWindow;
|
|
1561
1575
|
const end = typeof maxYear === "number" ? maxYear : displayYear + fallbackWindow;
|
|
@@ -1576,7 +1590,7 @@ function DatePicker({
|
|
|
1576
1590
|
}
|
|
1577
1591
|
return years;
|
|
1578
1592
|
}, [displayYear, maxYear, minYear, selectedDate]);
|
|
1579
|
-
const monthOptions =
|
|
1593
|
+
const monthOptions = React4.useMemo(() => {
|
|
1580
1594
|
const months = Array.from({ length: 12 }, (_, monthIndex) => {
|
|
1581
1595
|
const disabled = typeof minYear === "number" && displayYear === minYear && minDate && monthIndex < minDate.getMonth() || typeof maxYear === "number" && displayYear === maxYear && maxDate && monthIndex > maxDate.getMonth();
|
|
1582
1596
|
return {
|
|
@@ -1595,7 +1609,7 @@ function DatePicker({
|
|
|
1595
1609
|
}
|
|
1596
1610
|
return months.sort((a, b) => a.value - b.value).filter((option, index, arr) => index === 0 || option.value !== arr[index - 1].value);
|
|
1597
1611
|
}, [displayMonth, displayYear, getMonthLabel, maxDate, maxYear, minDate, minYear]);
|
|
1598
|
-
const handleMonthSelect =
|
|
1612
|
+
const handleMonthSelect = React4.useCallback((nextValue) => {
|
|
1599
1613
|
const nextMonth = Number.parseInt(nextValue, 10);
|
|
1600
1614
|
if (Number.isNaN(nextMonth)) return;
|
|
1601
1615
|
setDisplayed((prev) => {
|
|
@@ -1605,7 +1619,7 @@ function DatePicker({
|
|
|
1605
1619
|
return next;
|
|
1606
1620
|
});
|
|
1607
1621
|
}, []);
|
|
1608
|
-
const handleYearSelect =
|
|
1622
|
+
const handleYearSelect = React4.useCallback(
|
|
1609
1623
|
(nextValue) => {
|
|
1610
1624
|
const nextYear = Number.parseInt(nextValue, 10);
|
|
1611
1625
|
if (Number.isNaN(nextYear)) return;
|
|
@@ -1753,14 +1767,14 @@ var DatePicker2 = ({
|
|
|
1753
1767
|
ariaLabel,
|
|
1754
1768
|
...calendarProps
|
|
1755
1769
|
}) => {
|
|
1756
|
-
const [open, setOpen] =
|
|
1757
|
-
const parser =
|
|
1758
|
-
const outputFormatter =
|
|
1759
|
-
const labelFormatter =
|
|
1770
|
+
const [open, setOpen] = React4__default.useState(false);
|
|
1771
|
+
const parser = React4__default.useMemo(() => valueParser ?? defaultValueParser, [valueParser]);
|
|
1772
|
+
const outputFormatter = React4__default.useMemo(() => valueFormatter ?? defaultValueFormatter, [valueFormatter]);
|
|
1773
|
+
const labelFormatter = React4__default.useMemo(
|
|
1760
1774
|
() => displayFormatter ?? defaultDisplayFormatter,
|
|
1761
1775
|
[displayFormatter]
|
|
1762
1776
|
);
|
|
1763
|
-
const parsedValue =
|
|
1777
|
+
const parsedValue = React4__default.useMemo(() => {
|
|
1764
1778
|
if (value === null || value === void 0) return void 0;
|
|
1765
1779
|
if (value instanceof Date) return value;
|
|
1766
1780
|
const parsed = parser(value);
|
|
@@ -1769,26 +1783,26 @@ var DatePicker2 = ({
|
|
|
1769
1783
|
const buttonLabel = parsedValue ? labelFormatter(parsedValue) : placeholder3;
|
|
1770
1784
|
const buttonAriaLabel = ariaLabel ?? (parsedValue ? `Change date, current selection ${labelFormatter(parsedValue)}` : "Open date picker");
|
|
1771
1785
|
const shouldShowClear = allowClear && !disabled && !!parsedValue;
|
|
1772
|
-
const handleClose =
|
|
1773
|
-
const emitChange =
|
|
1786
|
+
const handleClose = React4__default.useCallback(() => setOpen(false), []);
|
|
1787
|
+
const emitChange = React4__default.useCallback(
|
|
1774
1788
|
(next) => {
|
|
1775
1789
|
onChange?.(next);
|
|
1776
1790
|
onValueChange?.(next ? outputFormatter(next) : void 0);
|
|
1777
1791
|
},
|
|
1778
1792
|
[onChange, onValueChange, outputFormatter]
|
|
1779
1793
|
);
|
|
1780
|
-
const handleSelect =
|
|
1794
|
+
const handleSelect = React4__default.useCallback(
|
|
1781
1795
|
(next) => {
|
|
1782
1796
|
emitChange(next);
|
|
1783
1797
|
if (closeOnSelect && next) handleClose();
|
|
1784
1798
|
},
|
|
1785
1799
|
[closeOnSelect, emitChange, handleClose]
|
|
1786
1800
|
);
|
|
1787
|
-
const handleClear =
|
|
1801
|
+
const handleClear = React4__default.useCallback(() => {
|
|
1788
1802
|
emitChange(void 0);
|
|
1789
1803
|
handleClose();
|
|
1790
1804
|
}, [emitChange, handleClose]);
|
|
1791
|
-
const handleOpenChange =
|
|
1805
|
+
const handleOpenChange = React4__default.useCallback(
|
|
1792
1806
|
(nextOpen) => {
|
|
1793
1807
|
if (disabled && nextOpen) return;
|
|
1794
1808
|
setOpen(nextOpen);
|
|
@@ -1960,15 +1974,15 @@ function MonthCal({
|
|
|
1960
1974
|
onYearBackward,
|
|
1961
1975
|
onYearForward
|
|
1962
1976
|
}) {
|
|
1963
|
-
const today =
|
|
1977
|
+
const today = React4.useMemo(() => {
|
|
1964
1978
|
const now = /* @__PURE__ */ new Date();
|
|
1965
1979
|
now.setDate(1);
|
|
1966
1980
|
now.setHours(0, 0, 0, 0);
|
|
1967
1981
|
return now;
|
|
1968
1982
|
}, []);
|
|
1969
|
-
const selectedMonthDate =
|
|
1970
|
-
const min =
|
|
1971
|
-
const max =
|
|
1983
|
+
const selectedMonthDate = React4.useMemo(() => normalizeMonth(selectedDate), [selectedDate]);
|
|
1984
|
+
const min = React4.useMemo(() => normalizeMonth(minDate), [minDate]);
|
|
1985
|
+
const max = React4.useMemo(() => normalizeMonth(maxDate), [maxDate]);
|
|
1972
1986
|
let effectiveMin = min;
|
|
1973
1987
|
if (min && max && min > max) {
|
|
1974
1988
|
effectiveMin = max;
|
|
@@ -1977,10 +1991,10 @@ function MonthCal({
|
|
|
1977
1991
|
const minMonth = effectiveMin?.getMonth();
|
|
1978
1992
|
const maxYear = max?.getFullYear();
|
|
1979
1993
|
const maxMonth = max?.getMonth();
|
|
1980
|
-
const [menuYear, setMenuYear] =
|
|
1994
|
+
const [menuYear, setMenuYear] = React4.useState(
|
|
1981
1995
|
() => selectedMonthDate?.getFullYear() ?? today.getFullYear()
|
|
1982
1996
|
);
|
|
1983
|
-
|
|
1997
|
+
React4.useEffect(() => {
|
|
1984
1998
|
if (selectedMonthDate) {
|
|
1985
1999
|
const year = selectedMonthDate.getFullYear();
|
|
1986
2000
|
if (year !== menuYear) {
|
|
@@ -1988,7 +2002,7 @@ function MonthCal({
|
|
|
1988
2002
|
}
|
|
1989
2003
|
}
|
|
1990
2004
|
}, [selectedMonthDate, menuYear]);
|
|
1991
|
-
|
|
2005
|
+
React4.useEffect(() => {
|
|
1992
2006
|
if (typeof minYear === "number" && menuYear < minYear) {
|
|
1993
2007
|
setMenuYear(minYear);
|
|
1994
2008
|
return;
|
|
@@ -1999,7 +2013,7 @@ function MonthCal({
|
|
|
1999
2013
|
}, [minYear, maxYear, menuYear]);
|
|
2000
2014
|
const disablePrevYear = typeof minYear === "number" ? menuYear <= minYear : false;
|
|
2001
2015
|
const disableNextYear = typeof maxYear === "number" ? menuYear >= maxYear : false;
|
|
2002
|
-
const yearOptions =
|
|
2016
|
+
const yearOptions = React4.useMemo(() => {
|
|
2003
2017
|
const fallbackWindow = 50;
|
|
2004
2018
|
const start = typeof minYear === "number" ? minYear : menuYear - fallbackWindow;
|
|
2005
2019
|
const end = typeof maxYear === "number" ? maxYear : menuYear + fallbackWindow;
|
|
@@ -2013,7 +2027,7 @@ function MonthCal({
|
|
|
2013
2027
|
}
|
|
2014
2028
|
return years;
|
|
2015
2029
|
}, [maxYear, menuYear, minYear]);
|
|
2016
|
-
const formatYearLabel =
|
|
2030
|
+
const formatYearLabel = React4.useCallback(
|
|
2017
2031
|
(year) => {
|
|
2018
2032
|
const raw = callbacks?.yearLabel?.(year);
|
|
2019
2033
|
if (raw === null || raw === void 0) return String(year);
|
|
@@ -2021,7 +2035,7 @@ function MonthCal({
|
|
|
2021
2035
|
},
|
|
2022
2036
|
[callbacks]
|
|
2023
2037
|
);
|
|
2024
|
-
const handleYearSelect =
|
|
2038
|
+
const handleYearSelect = React4.useCallback(
|
|
2025
2039
|
(nextValue) => {
|
|
2026
2040
|
const nextYear = Number.parseInt(nextValue, 10);
|
|
2027
2041
|
if (Number.isNaN(nextYear)) return;
|
|
@@ -2031,7 +2045,7 @@ function MonthCal({
|
|
|
2031
2045
|
},
|
|
2032
2046
|
[maxYear, minYear]
|
|
2033
2047
|
);
|
|
2034
|
-
const disabledPairs =
|
|
2048
|
+
const disabledPairs = React4.useMemo(() => {
|
|
2035
2049
|
if (!disabledDates?.length) return [];
|
|
2036
2050
|
const pairs = [];
|
|
2037
2051
|
disabledDates.forEach((date) => {
|
|
@@ -2176,14 +2190,14 @@ var MonthPicker2 = ({
|
|
|
2176
2190
|
ariaLabel,
|
|
2177
2191
|
...calendarProps
|
|
2178
2192
|
}) => {
|
|
2179
|
-
const [open, setOpen] =
|
|
2180
|
-
const parser =
|
|
2181
|
-
const outputFormatter =
|
|
2182
|
-
const labelFormatter =
|
|
2193
|
+
const [open, setOpen] = React4__default.useState(false);
|
|
2194
|
+
const parser = React4__default.useMemo(() => valueParser ?? defaultValueParser2, [valueParser]);
|
|
2195
|
+
const outputFormatter = React4__default.useMemo(() => valueFormatter ?? defaultValueFormatter2, [valueFormatter]);
|
|
2196
|
+
const labelFormatter = React4__default.useMemo(
|
|
2183
2197
|
() => displayFormatter ?? defaultDisplayFormatter2,
|
|
2184
2198
|
[displayFormatter]
|
|
2185
2199
|
);
|
|
2186
|
-
const parsedValue =
|
|
2200
|
+
const parsedValue = React4__default.useMemo(() => {
|
|
2187
2201
|
if (value === null || value === void 0) return void 0;
|
|
2188
2202
|
if (value instanceof Date) return normalizeMonth2(value);
|
|
2189
2203
|
if (typeof value === "string") {
|
|
@@ -2195,8 +2209,8 @@ var MonthPicker2 = ({
|
|
|
2195
2209
|
const buttonLabel = parsedValue ? labelFormatter(parsedValue) : placeholder3;
|
|
2196
2210
|
const buttonAriaLabel = ariaLabel ?? (parsedValue ? `Change month, current selection ${labelFormatter(parsedValue)}` : "Open month picker");
|
|
2197
2211
|
const shouldShowClear = allowClear && !disabled && !!parsedValue;
|
|
2198
|
-
const handleClose =
|
|
2199
|
-
const emitChange =
|
|
2212
|
+
const handleClose = React4__default.useCallback(() => setOpen(false), []);
|
|
2213
|
+
const emitChange = React4__default.useCallback(
|
|
2200
2214
|
(next) => {
|
|
2201
2215
|
const normalized = next ? normalizeMonth2(next) : void 0;
|
|
2202
2216
|
onChange?.(normalized);
|
|
@@ -2204,18 +2218,18 @@ var MonthPicker2 = ({
|
|
|
2204
2218
|
},
|
|
2205
2219
|
[onChange, onValueChange, outputFormatter]
|
|
2206
2220
|
);
|
|
2207
|
-
const handleSelect =
|
|
2221
|
+
const handleSelect = React4__default.useCallback(
|
|
2208
2222
|
(next) => {
|
|
2209
2223
|
emitChange(next);
|
|
2210
2224
|
if (closeOnSelect && next) handleClose();
|
|
2211
2225
|
},
|
|
2212
2226
|
[closeOnSelect, emitChange, handleClose]
|
|
2213
2227
|
);
|
|
2214
|
-
const handleClear =
|
|
2228
|
+
const handleClear = React4__default.useCallback(() => {
|
|
2215
2229
|
emitChange(void 0);
|
|
2216
2230
|
handleClose();
|
|
2217
2231
|
}, [emitChange, handleClose]);
|
|
2218
|
-
const handleOpenChange =
|
|
2232
|
+
const handleOpenChange = React4__default.useCallback(
|
|
2219
2233
|
(nextOpen) => {
|
|
2220
2234
|
if (disabled && nextOpen) return;
|
|
2221
2235
|
setOpen(nextOpen);
|
|
@@ -3275,7 +3289,7 @@ var AdvanceSearch = ({
|
|
|
3275
3289
|
defaultValues: {}
|
|
3276
3290
|
});
|
|
3277
3291
|
const { handleSubmit, unregister, resetField, getValues, clearErrors, setError } = form;
|
|
3278
|
-
const [operatorErrors, setOperatorErrors] =
|
|
3292
|
+
const [operatorErrors, setOperatorErrors] = React4__default.useState({});
|
|
3279
3293
|
const clearOperatorError = useCallback(
|
|
3280
3294
|
(rowId) => {
|
|
3281
3295
|
setOperatorErrors((prev) => {
|
|
@@ -3866,7 +3880,7 @@ var ColumnSeparator = ({ show, className, ...props }) => {
|
|
|
3866
3880
|
}
|
|
3867
3881
|
);
|
|
3868
3882
|
};
|
|
3869
|
-
var ColumnSeparator_default =
|
|
3883
|
+
var ColumnSeparator_default = React4__default.memo(ColumnSeparator);
|
|
3870
3884
|
var StatusContentSlot = ({
|
|
3871
3885
|
content,
|
|
3872
3886
|
icon,
|
|
@@ -3885,7 +3899,7 @@ var StatusContentSlot = ({
|
|
|
3885
3899
|
content
|
|
3886
3900
|
] });
|
|
3887
3901
|
};
|
|
3888
|
-
var StatusContentSlot_default =
|
|
3902
|
+
var StatusContentSlot_default = React4__default.memo(StatusContentSlot);
|
|
3889
3903
|
var stateOptions = [
|
|
3890
3904
|
"columnFilters",
|
|
3891
3905
|
"globalFilter",
|
|
@@ -4860,7 +4874,7 @@ function SortableRow({
|
|
|
4860
4874
|
id: value,
|
|
4861
4875
|
disabled: name === "columns.0.id"
|
|
4862
4876
|
});
|
|
4863
|
-
const style =
|
|
4877
|
+
const style = React4.useMemo(
|
|
4864
4878
|
() => ({
|
|
4865
4879
|
transform: CSS.Transform.toString(transform),
|
|
4866
4880
|
transition
|
|
@@ -5202,7 +5216,7 @@ var useGridSettingsStore = create(
|
|
|
5202
5216
|
);
|
|
5203
5217
|
var useGridSettingsStore_default = useGridSettingsStore;
|
|
5204
5218
|
var ListTable = ({ onTableReady, children }) => {
|
|
5205
|
-
|
|
5219
|
+
React4.useEffect(() => {
|
|
5206
5220
|
if (onTableReady) {
|
|
5207
5221
|
onTableReady({ ready: true });
|
|
5208
5222
|
}
|
|
@@ -5306,26 +5320,48 @@ var InfoIcon = (props) => {
|
|
|
5306
5320
|
return /* @__PURE__ */ jsxs(
|
|
5307
5321
|
"svg",
|
|
5308
5322
|
{
|
|
5309
|
-
width: "
|
|
5310
|
-
height: "
|
|
5311
|
-
viewBox: "0 0
|
|
5323
|
+
width: "20",
|
|
5324
|
+
height: "20",
|
|
5325
|
+
viewBox: "0 0 20 20",
|
|
5312
5326
|
fill: "none",
|
|
5313
5327
|
xmlns: "http://www.w3.org/2000/svg",
|
|
5314
5328
|
...props,
|
|
5315
5329
|
children: [
|
|
5316
|
-
/* @__PURE__ */ jsx("circle", { cx: "6.98438", cy: "6.63281", r: "6.25", fill: "white" }),
|
|
5317
5330
|
/* @__PURE__ */ jsx(
|
|
5318
5331
|
"path",
|
|
5319
5332
|
{
|
|
5320
|
-
d: "
|
|
5321
|
-
|
|
5333
|
+
d: "M10.0013 18.3327C14.6037 18.3327 18.3346 14.6017 18.3346 9.99935C18.3346 5.39698 14.6037 1.66602 10.0013 1.66602C5.39893 1.66602 1.66797 5.39698 1.66797 9.99935C1.66797 14.6017 5.39893 18.3327 10.0013 18.3327Z",
|
|
5334
|
+
stroke: "white",
|
|
5335
|
+
"stroke-width": "1.5",
|
|
5336
|
+
"stroke-linecap": "round",
|
|
5337
|
+
"stroke-linejoin": "round"
|
|
5338
|
+
}
|
|
5339
|
+
),
|
|
5340
|
+
/* @__PURE__ */ jsx(
|
|
5341
|
+
"path",
|
|
5342
|
+
{
|
|
5343
|
+
d: "M10 13.3333V10",
|
|
5344
|
+
stroke: "white",
|
|
5345
|
+
"stroke-width": "1.5",
|
|
5346
|
+
"stroke-linecap": "round",
|
|
5347
|
+
"stroke-linejoin": "round"
|
|
5348
|
+
}
|
|
5349
|
+
),
|
|
5350
|
+
/* @__PURE__ */ jsx(
|
|
5351
|
+
"path",
|
|
5352
|
+
{
|
|
5353
|
+
d: "M10 6.66602H10.0083",
|
|
5354
|
+
stroke: "white",
|
|
5355
|
+
"stroke-width": "1.5",
|
|
5356
|
+
"stroke-linecap": "round",
|
|
5357
|
+
"stroke-linejoin": "round"
|
|
5322
5358
|
}
|
|
5323
5359
|
)
|
|
5324
5360
|
]
|
|
5325
5361
|
}
|
|
5326
5362
|
);
|
|
5327
5363
|
};
|
|
5328
|
-
var InfoIcon_default =
|
|
5364
|
+
var InfoIcon_default = React4__default.memo(InfoIcon);
|
|
5329
5365
|
var Navbar = ({
|
|
5330
5366
|
className,
|
|
5331
5367
|
title,
|
|
@@ -5456,7 +5492,7 @@ var Navbar = ({
|
|
|
5456
5492
|
}
|
|
5457
5493
|
);
|
|
5458
5494
|
};
|
|
5459
|
-
var navbar_default =
|
|
5495
|
+
var navbar_default = React4__default.memo(Navbar);
|
|
5460
5496
|
function Sheet({ ...props }) {
|
|
5461
5497
|
return /* @__PURE__ */ jsx(SheetPrimitive.Root, { "data-slot": "sheet", ...props });
|
|
5462
5498
|
}
|
|
@@ -6061,7 +6097,7 @@ function ToolbarPlugin({
|
|
|
6061
6097
|
isLink: hasLink
|
|
6062
6098
|
}));
|
|
6063
6099
|
}, []);
|
|
6064
|
-
|
|
6100
|
+
React4.useEffect(() => {
|
|
6065
6101
|
return mergeRegister(
|
|
6066
6102
|
editor.registerCommand(
|
|
6067
6103
|
CAN_UNDO_COMMAND,
|
|
@@ -6478,7 +6514,7 @@ function ToolbarPlugin({
|
|
|
6478
6514
|
ToolbarButton,
|
|
6479
6515
|
{
|
|
6480
6516
|
label: "Insert image",
|
|
6481
|
-
icon: Image,
|
|
6517
|
+
icon: Image$1,
|
|
6482
6518
|
onClick: handleInsertImage,
|
|
6483
6519
|
disabled: disabled || !canInsertImage
|
|
6484
6520
|
}
|
|
@@ -6647,7 +6683,7 @@ function ControlledValuePlugin({
|
|
|
6647
6683
|
trackAppliedValue
|
|
6648
6684
|
}) {
|
|
6649
6685
|
const [editor] = useLexicalComposerContext();
|
|
6650
|
-
|
|
6686
|
+
React4.useEffect(() => {
|
|
6651
6687
|
if (value == null || trackAppliedValue.current === value) {
|
|
6652
6688
|
return;
|
|
6653
6689
|
}
|
|
@@ -6671,14 +6707,14 @@ function ControlledValuePlugin({
|
|
|
6671
6707
|
}
|
|
6672
6708
|
function EditableStatePlugin({ editable }) {
|
|
6673
6709
|
const [editor] = useLexicalComposerContext();
|
|
6674
|
-
|
|
6710
|
+
React4.useEffect(() => {
|
|
6675
6711
|
editor.setEditable(editable);
|
|
6676
6712
|
}, [editor, editable]);
|
|
6677
6713
|
return null;
|
|
6678
6714
|
}
|
|
6679
6715
|
function ImagesPlugin() {
|
|
6680
6716
|
const [editor] = useLexicalComposerContext();
|
|
6681
|
-
|
|
6717
|
+
React4.useEffect(() => {
|
|
6682
6718
|
return editor.registerCommand(
|
|
6683
6719
|
INSERT_IMAGE_COMMAND,
|
|
6684
6720
|
(payload) => {
|
|
@@ -6888,6 +6924,7 @@ __export(ui_exports, {
|
|
|
6888
6924
|
FormItem: () => FormItem,
|
|
6889
6925
|
FormLabel: () => FormLabel,
|
|
6890
6926
|
FormMessage: () => FormMessage,
|
|
6927
|
+
Input: () => Input,
|
|
6891
6928
|
InputPrimitive: () => InputPrimitive,
|
|
6892
6929
|
Label: () => Label2,
|
|
6893
6930
|
MonthPicker: () => MonthPicker,
|
|
@@ -6961,6 +6998,7 @@ __export(ui_exports, {
|
|
|
6961
6998
|
TooltipProvider: () => TooltipProvider2,
|
|
6962
6999
|
TooltipTrigger: () => TooltipTrigger2,
|
|
6963
7000
|
buttonVariants: () => buttonVariants,
|
|
7001
|
+
inputVariants: () => inputVariants,
|
|
6964
7002
|
spinnerVariants: () => spinnerVariants,
|
|
6965
7003
|
useFormField: () => useFormField,
|
|
6966
7004
|
useSidebar: () => useSidebar
|
|
@@ -7059,9 +7097,9 @@ var SIDEBAR_WIDTH = "16rem";
|
|
|
7059
7097
|
var SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
7060
7098
|
var SIDEBAR_WIDTH_ICON = "3rem";
|
|
7061
7099
|
var SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
7062
|
-
var SidebarContext =
|
|
7100
|
+
var SidebarContext = React4.createContext(null);
|
|
7063
7101
|
function useSidebar() {
|
|
7064
|
-
const context =
|
|
7102
|
+
const context = React4.useContext(SidebarContext);
|
|
7065
7103
|
if (!context) {
|
|
7066
7104
|
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
7067
7105
|
}
|
|
@@ -7077,10 +7115,10 @@ function SidebarProvider({
|
|
|
7077
7115
|
...props
|
|
7078
7116
|
}) {
|
|
7079
7117
|
const isMobile = useIsMobile();
|
|
7080
|
-
const [openMobile, setOpenMobile] =
|
|
7081
|
-
const [_open, _setOpen] =
|
|
7118
|
+
const [openMobile, setOpenMobile] = React4.useState(false);
|
|
7119
|
+
const [_open, _setOpen] = React4.useState(defaultOpen);
|
|
7082
7120
|
const open = openProp ?? _open;
|
|
7083
|
-
const setOpen =
|
|
7121
|
+
const setOpen = React4.useCallback(
|
|
7084
7122
|
(value) => {
|
|
7085
7123
|
const openState = typeof value === "function" ? value(open) : value;
|
|
7086
7124
|
if (setOpenProp) {
|
|
@@ -7092,10 +7130,10 @@ function SidebarProvider({
|
|
|
7092
7130
|
},
|
|
7093
7131
|
[setOpenProp, open]
|
|
7094
7132
|
);
|
|
7095
|
-
const toggleSidebar =
|
|
7133
|
+
const toggleSidebar = React4.useCallback(() => {
|
|
7096
7134
|
return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
|
|
7097
7135
|
}, [isMobile, setOpen, setOpenMobile]);
|
|
7098
|
-
|
|
7136
|
+
React4.useEffect(() => {
|
|
7099
7137
|
const handleKeyDown = (event) => {
|
|
7100
7138
|
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
7101
7139
|
event.preventDefault();
|
|
@@ -7106,7 +7144,7 @@ function SidebarProvider({
|
|
|
7106
7144
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
7107
7145
|
}, [toggleSidebar]);
|
|
7108
7146
|
const state = open ? "expanded" : "collapsed";
|
|
7109
|
-
const contextValue =
|
|
7147
|
+
const contextValue = React4.useMemo(
|
|
7110
7148
|
() => ({
|
|
7111
7149
|
state,
|
|
7112
7150
|
open,
|
|
@@ -7548,7 +7586,7 @@ function SidebarMenuSkeleton({
|
|
|
7548
7586
|
showIcon = false,
|
|
7549
7587
|
...props
|
|
7550
7588
|
}) {
|
|
7551
|
-
const width =
|
|
7589
|
+
const width = React4.useMemo(() => {
|
|
7552
7590
|
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
7553
7591
|
}, []);
|
|
7554
7592
|
return /* @__PURE__ */ jsxs(
|
|
@@ -7642,6 +7680,173 @@ function SidebarLayout({
|
|
|
7642
7680
|
] }) });
|
|
7643
7681
|
}
|
|
7644
7682
|
|
|
7645
|
-
|
|
7683
|
+
// src/components/cropperModal/helper.ts
|
|
7684
|
+
var createImage = (url) => new Promise((resolve, reject) => {
|
|
7685
|
+
const image = new Image();
|
|
7686
|
+
image.addEventListener("load", () => resolve(image));
|
|
7687
|
+
image.addEventListener("error", (error) => reject(error));
|
|
7688
|
+
image.setAttribute("crossOrigin", "anonymous");
|
|
7689
|
+
image.src = url;
|
|
7690
|
+
});
|
|
7691
|
+
async function getCroppedImg(imageSrc, pixelCrop, desiredDimension) {
|
|
7692
|
+
const image = await createImage(imageSrc);
|
|
7693
|
+
const canvas = document.createElement("canvas");
|
|
7694
|
+
const ctx = canvas.getContext("2d");
|
|
7695
|
+
if (!ctx) {
|
|
7696
|
+
throw new Error("can not create canvas");
|
|
7697
|
+
}
|
|
7698
|
+
canvas.width = image.width;
|
|
7699
|
+
canvas.height = image.height;
|
|
7700
|
+
ctx.drawImage(image, 0, 0);
|
|
7701
|
+
const croppedCanvas = document.createElement("canvas");
|
|
7702
|
+
const croppedCtx = croppedCanvas.getContext("2d");
|
|
7703
|
+
if (!croppedCtx) {
|
|
7704
|
+
throw new Error("can not create canvas");
|
|
7705
|
+
}
|
|
7706
|
+
croppedCanvas.width = desiredDimension?.width ?? pixelCrop.width;
|
|
7707
|
+
croppedCanvas.height = desiredDimension?.height ?? pixelCrop.height;
|
|
7708
|
+
croppedCtx.drawImage(
|
|
7709
|
+
canvas,
|
|
7710
|
+
pixelCrop.x,
|
|
7711
|
+
pixelCrop.y,
|
|
7712
|
+
pixelCrop.width,
|
|
7713
|
+
pixelCrop.height,
|
|
7714
|
+
0,
|
|
7715
|
+
0,
|
|
7716
|
+
desiredDimension?.width ?? pixelCrop.width,
|
|
7717
|
+
desiredDimension?.height ?? pixelCrop.height
|
|
7718
|
+
);
|
|
7719
|
+
return new Promise((resolve, reject) => {
|
|
7720
|
+
croppedCanvas.toBlob((file) => {
|
|
7721
|
+
if (file) {
|
|
7722
|
+
resolve(URL.createObjectURL(file));
|
|
7723
|
+
} else {
|
|
7724
|
+
reject("croppedCanvas gave null object");
|
|
7725
|
+
}
|
|
7726
|
+
}, "image/png");
|
|
7727
|
+
});
|
|
7728
|
+
}
|
|
7729
|
+
var CropperModal = ({
|
|
7730
|
+
open,
|
|
7731
|
+
onOpenChange,
|
|
7732
|
+
imageSrc,
|
|
7733
|
+
onConfirm,
|
|
7734
|
+
onCancel,
|
|
7735
|
+
onError,
|
|
7736
|
+
cropSize,
|
|
7737
|
+
outputExactCropSize,
|
|
7738
|
+
generateBlobUrlOutput,
|
|
7739
|
+
title,
|
|
7740
|
+
props
|
|
7741
|
+
}) => {
|
|
7742
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
7743
|
+
const [crop, setCrop] = useState({ x: 0, y: 0 });
|
|
7744
|
+
const [zoom, setZoom] = useState();
|
|
7745
|
+
const [croppedAreaPixels, setCroppedAreaPixels] = useState(null);
|
|
7746
|
+
const handleClose = useCallback(() => {
|
|
7747
|
+
onOpenChange(false);
|
|
7748
|
+
}, [onOpenChange]);
|
|
7749
|
+
const handleCancel = useCallback(() => {
|
|
7750
|
+
if (onCancel) {
|
|
7751
|
+
onCancel();
|
|
7752
|
+
}
|
|
7753
|
+
handleClose();
|
|
7754
|
+
}, [handleClose, onCancel]);
|
|
7755
|
+
const handleCropComplete = useCallback((_, croppedAreaPixels2) => {
|
|
7756
|
+
setCroppedAreaPixels(croppedAreaPixels2);
|
|
7757
|
+
}, []);
|
|
7758
|
+
const handleConfirm = async () => {
|
|
7759
|
+
if (!imageSrc || !onConfirm) {
|
|
7760
|
+
handleClose();
|
|
7761
|
+
return;
|
|
7762
|
+
}
|
|
7763
|
+
if (!generateBlobUrlOutput) {
|
|
7764
|
+
onConfirm({ crop, croppedAreaPixels });
|
|
7765
|
+
return;
|
|
7766
|
+
}
|
|
7767
|
+
if (!croppedAreaPixels) {
|
|
7768
|
+
onConfirm({ crop, croppedAreaPixels, croppedImageBlobUrl: imageSrc });
|
|
7769
|
+
return;
|
|
7770
|
+
}
|
|
7771
|
+
setIsLoading(true);
|
|
7772
|
+
try {
|
|
7773
|
+
const desiredDimension = outputExactCropSize ? cropSize : void 0;
|
|
7774
|
+
const croppedImage = await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
|
|
7775
|
+
onConfirm({ crop, croppedAreaPixels, croppedImageBlobUrl: croppedImage });
|
|
7776
|
+
} catch (e) {
|
|
7777
|
+
if (onError) {
|
|
7778
|
+
onError(e);
|
|
7779
|
+
}
|
|
7780
|
+
} finally {
|
|
7781
|
+
setIsLoading(false);
|
|
7782
|
+
handleClose();
|
|
7783
|
+
}
|
|
7784
|
+
};
|
|
7785
|
+
return /* @__PURE__ */ jsx(
|
|
7786
|
+
Dialog,
|
|
7787
|
+
{
|
|
7788
|
+
open,
|
|
7789
|
+
onOpenChange: (nextOpen) => {
|
|
7790
|
+
if (!nextOpen) {
|
|
7791
|
+
handleClose();
|
|
7792
|
+
} else {
|
|
7793
|
+
onOpenChange(true);
|
|
7794
|
+
}
|
|
7795
|
+
},
|
|
7796
|
+
children: /* @__PURE__ */ jsxs(
|
|
7797
|
+
DialogContent,
|
|
7798
|
+
{
|
|
7799
|
+
className: "flex flex-col w-fit !max-w-6xl p-0 overflow-clip gap-0 border-0",
|
|
7800
|
+
...props?.dialogContent,
|
|
7801
|
+
children: [
|
|
7802
|
+
/* @__PURE__ */ jsxs(
|
|
7803
|
+
"div",
|
|
7804
|
+
{
|
|
7805
|
+
className: "flex w-full bg-[#82B495] text-white justify-between items-center p-4",
|
|
7806
|
+
...props?.dialogTitleContainer,
|
|
7807
|
+
children: [
|
|
7808
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "text-2xl font-semibold", ...props?.dialogTitle, children: title ?? "Crop Image" }),
|
|
7809
|
+
/* @__PURE__ */ jsx(
|
|
7810
|
+
"button",
|
|
7811
|
+
{
|
|
7812
|
+
type: "button",
|
|
7813
|
+
className: "text-white hover:text-gray-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",
|
|
7814
|
+
onClick: handleCancel,
|
|
7815
|
+
disabled: isLoading,
|
|
7816
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "w-4 h-4" })
|
|
7817
|
+
}
|
|
7818
|
+
)
|
|
7819
|
+
]
|
|
7820
|
+
}
|
|
7821
|
+
),
|
|
7822
|
+
/* @__PURE__ */ jsx("div", { className: "w-120 md:w-[50vw] h-[70vh] mx-auto", ...props?.cropperContainer, children: /* @__PURE__ */ jsx(
|
|
7823
|
+
Cropper,
|
|
7824
|
+
{
|
|
7825
|
+
image: imageSrc ?? void 0,
|
|
7826
|
+
crop,
|
|
7827
|
+
onCropChange: setCrop,
|
|
7828
|
+
zoom,
|
|
7829
|
+
onZoomChange: setZoom,
|
|
7830
|
+
style: { containerStyle: { position: "relative", width: "100%", height: "100%" } },
|
|
7831
|
+
onCropComplete: handleCropComplete,
|
|
7832
|
+
aspect: cropSize ? cropSize.width / cropSize.height : void 0,
|
|
7833
|
+
zoomWithScroll: true,
|
|
7834
|
+
showGrid: true,
|
|
7835
|
+
restrictPosition: true,
|
|
7836
|
+
...props?.cropper
|
|
7837
|
+
}
|
|
7838
|
+
) }),
|
|
7839
|
+
/* @__PURE__ */ jsx("div", { className: "w-full py-4 px-8", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between", children: [
|
|
7840
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "cancel", onClick: handleCancel, disabled: isLoading, children: "Cancel" }),
|
|
7841
|
+
/* @__PURE__ */ jsx("div", { className: "ml-auto flex gap-x-2", children: /* @__PURE__ */ jsx(Button, { type: "button", variant: "default", onClick: handleConfirm, disabled: isLoading, children: "Confirm" }) })
|
|
7842
|
+
] }) })
|
|
7843
|
+
]
|
|
7844
|
+
}
|
|
7845
|
+
)
|
|
7846
|
+
}
|
|
7847
|
+
);
|
|
7848
|
+
};
|
|
7849
|
+
|
|
7850
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch_default as AdvanceSearch, arrow_default as ArrowIcon, Button, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CropperModal, DataTable_default as DataTable, DatePicker2 as DatePicker, Dialog, DialogAlert, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, Input, Label2 as Label, List_default as List, container_default as ListContainer, header_default as ListHeader, table_default as ListTable, LookupSelect, MonthPicker2 as MonthPicker, navbar_default as Navbar, not_found_default as NotFoundIcon, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave_default as PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, calendar_default as SuiCalendarIcon, check_default as SuiCheckIcon, dots_vertical_default as SuiDotsVerticalIcon, empty_data_default as SuiEmptyDataIcon, expand_default as SuiExpandIcon, filter_default as SuiFilterIcon, setting_default as SuiSettingIcon, triangle_down_default as SuiTriangleDownIcon, warning_default as SuiWarningIcon, Switch, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, ui_exports as UI, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, stripNullishObject, throttle, useFormField, useGridSettingsStore_default as useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useMediaQuery_default as useMediaQuery, usePreventPageLeave_default as usePreventPageLeave, usePreventPageLeaveStore_default as usePreventPageLeaveStore, useScreenSize_default as useScreenSize, useSidebar, useTruncated_default as useTruncated };
|
|
7646
7851
|
//# sourceMappingURL=index.mjs.map
|
|
7647
7852
|
//# sourceMappingURL=index.mjs.map
|