@sustaina/shared-ui 1.4.0 → 1.4.1
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 +80 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -86
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React4 from 'react';
|
|
2
2
|
import React4__default, { createContext, isValidElement, useState, useEffect, useId, useContext, useRef, useCallback, useMemo, createElement } from 'react';
|
|
3
|
-
import { Controller, useFormContext, useForm, useFieldArray, FormProvider, get, set, appendErrors, useFormState } from 'react-hook-form';
|
|
3
|
+
import { Controller, useFormContext, useForm, useFieldArray, FormProvider, useWatch, get, set, appendErrors, useFormState } from 'react-hook-form';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import clsx3, { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -1453,7 +1453,6 @@ function TooltipContent({
|
|
|
1453
1453
|
}
|
|
1454
1454
|
function SortableRow({
|
|
1455
1455
|
availableColumns,
|
|
1456
|
-
currentColumns,
|
|
1457
1456
|
control,
|
|
1458
1457
|
name,
|
|
1459
1458
|
value,
|
|
@@ -1469,88 +1468,86 @@ function SortableRow({
|
|
|
1469
1468
|
transition
|
|
1470
1469
|
};
|
|
1471
1470
|
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
1472
|
-
const
|
|
1473
|
-
id: col.id,
|
|
1474
|
-
label: capitalize(col.id)
|
|
1475
|
-
}));
|
|
1471
|
+
const currentFormColumns = useWatch({ control, name: "columns" });
|
|
1476
1472
|
return /* @__PURE__ */ jsx("div", { ref: setNodeRef, style, className: "flex items-center rounded-md bg-white", children: /* @__PURE__ */ jsx(
|
|
1477
1473
|
FormField2,
|
|
1478
1474
|
{
|
|
1479
1475
|
control,
|
|
1480
1476
|
name,
|
|
1481
|
-
render: ({ field }) =>
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
{
|
|
1486
|
-
...attributes,
|
|
1487
|
-
...listeners,
|
|
1488
|
-
className: cn(
|
|
1489
|
-
"h-5 w-5 text-[#B9B9B9] focus:outline-none cursor-grab",
|
|
1490
|
-
name == "columns.0.id" && "opacity-0 pointer-events-none"
|
|
1491
|
-
)
|
|
1492
|
-
}
|
|
1493
|
-
),
|
|
1494
|
-
/* @__PURE__ */ jsxs(
|
|
1495
|
-
Select,
|
|
1496
|
-
{
|
|
1497
|
-
value: field.value,
|
|
1498
|
-
onValueChange: field.onChange,
|
|
1499
|
-
disabled: name == "columns.0.id",
|
|
1500
|
-
children: [
|
|
1501
|
-
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
1502
|
-
SelectTrigger,
|
|
1503
|
-
{
|
|
1504
|
-
className: cn(
|
|
1505
|
-
"w-full border-[#DDDDDD] data-[disabled]:opacity-100 aria-invalid:border-[#BB0B0E]",
|
|
1506
|
-
name == "columns.0.id" ? "text-[#8B8B8B] bg-[#EAEAEA] cursor-not-allowed" : ""
|
|
1507
|
-
),
|
|
1508
|
-
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Choose column..." })
|
|
1509
|
-
}
|
|
1510
|
-
) }),
|
|
1511
|
-
/* @__PURE__ */ jsx(SelectContent, { children: options.filter(
|
|
1512
|
-
(i2) => i2.id === field.value || !currentColumns?.some((c, idx) => c.id === i2.id && idx !== index)
|
|
1513
|
-
).sort(
|
|
1514
|
-
(a, b) => a.id === field.value ? -1 : b.id === field.value ? 1 : 0
|
|
1515
|
-
).map((opt) => /* @__PURE__ */ jsx(
|
|
1516
|
-
SelectItem,
|
|
1517
|
-
{
|
|
1518
|
-
value: opt.id,
|
|
1519
|
-
className: cn(
|
|
1520
|
-
"focus:bg-[#e8edea]",
|
|
1521
|
-
opt.id === field.value ? "font-bold bg-[#dae5de] focus:bg-[#dae5de]" : ""
|
|
1522
|
-
),
|
|
1523
|
-
children: opt.label
|
|
1524
|
-
},
|
|
1525
|
-
opt.id
|
|
1526
|
-
)) })
|
|
1527
|
-
]
|
|
1528
|
-
}
|
|
1529
|
-
),
|
|
1530
|
-
name == "columns.0.id" ? /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
1531
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Info, { className: "h-5 w-5", stroke: "white", fill: "#8B8B8B" }) }),
|
|
1477
|
+
render: ({ field }) => {
|
|
1478
|
+
const options = availableColumns.filter((col) => col.id === field.value || !currentFormColumns?.some((c) => c.id === col.id)).map((col) => ({ id: col.id, label: capitalize(col.id) }));
|
|
1479
|
+
return /* @__PURE__ */ jsxs(FormItem2, { className: "flex-1", children: [
|
|
1480
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1532
1481
|
/* @__PURE__ */ jsx(
|
|
1533
|
-
|
|
1482
|
+
GripVertical,
|
|
1534
1483
|
{
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
className:
|
|
1538
|
-
|
|
1539
|
-
|
|
1484
|
+
...attributes,
|
|
1485
|
+
...listeners,
|
|
1486
|
+
className: cn(
|
|
1487
|
+
"h-5 w-5 text-[#B9B9B9] focus:outline-none cursor-grab",
|
|
1488
|
+
name == "columns.0.id" && "opacity-0 pointer-events-none"
|
|
1489
|
+
)
|
|
1490
|
+
}
|
|
1491
|
+
),
|
|
1492
|
+
/* @__PURE__ */ jsxs(
|
|
1493
|
+
Select,
|
|
1494
|
+
{
|
|
1495
|
+
value: field.value,
|
|
1496
|
+
onValueChange: field.onChange,
|
|
1497
|
+
disabled: name == "columns.0.id",
|
|
1498
|
+
children: [
|
|
1499
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
1500
|
+
SelectTrigger,
|
|
1501
|
+
{
|
|
1502
|
+
className: cn(
|
|
1503
|
+
"w-full border-[#DDDDDD] data-[disabled]:opacity-100 aria-invalid:border-[#BB0B0E]",
|
|
1504
|
+
name == "columns.0.id" ? "text-[#8B8B8B] bg-[#EAEAEA] cursor-not-allowed" : ""
|
|
1505
|
+
),
|
|
1506
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Choose column..." })
|
|
1507
|
+
}
|
|
1508
|
+
) }),
|
|
1509
|
+
/* @__PURE__ */ jsx(SelectContent, { children: options.sort(
|
|
1510
|
+
(a, b) => a.id === field.value ? -1 : b.id === field.value ? 1 : 0
|
|
1511
|
+
).map((opt) => /* @__PURE__ */ jsx(
|
|
1512
|
+
SelectItem,
|
|
1513
|
+
{
|
|
1514
|
+
value: opt.id,
|
|
1515
|
+
className: cn(
|
|
1516
|
+
"focus:bg-[#e8edea]",
|
|
1517
|
+
opt.id === field.value ? "font-bold bg-[#dae5de] focus:bg-[#dae5de]" : ""
|
|
1518
|
+
),
|
|
1519
|
+
children: opt.label
|
|
1520
|
+
},
|
|
1521
|
+
opt.id
|
|
1522
|
+
)) })
|
|
1523
|
+
]
|
|
1524
|
+
}
|
|
1525
|
+
),
|
|
1526
|
+
name == "columns.0.id" ? /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
1527
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Info, { className: "h-5 w-5", stroke: "white", fill: "#8B8B8B" }) }),
|
|
1528
|
+
/* @__PURE__ */ jsx(
|
|
1529
|
+
TooltipContent,
|
|
1530
|
+
{
|
|
1531
|
+
align: "start",
|
|
1532
|
+
alignOffset: 10,
|
|
1533
|
+
className: "bg-[#8B8B8B] rounded-none",
|
|
1534
|
+
arrowClassName: "!hidden",
|
|
1535
|
+
children: /* @__PURE__ */ jsx("p", { children: "Column cannot be removed." })
|
|
1536
|
+
}
|
|
1537
|
+
)
|
|
1538
|
+
] }) }) : /* @__PURE__ */ jsx(
|
|
1539
|
+
CircleMinus,
|
|
1540
|
+
{
|
|
1541
|
+
onClick: onRemove,
|
|
1542
|
+
className: "h-5 w-5 cursor-pointer",
|
|
1543
|
+
stroke: "white",
|
|
1544
|
+
fill: "#C32A2C"
|
|
1540
1545
|
}
|
|
1541
1546
|
)
|
|
1542
|
-
] })
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
className: "h-5 w-5 cursor-pointer",
|
|
1547
|
-
stroke: "white",
|
|
1548
|
-
fill: "#C32A2C"
|
|
1549
|
-
}
|
|
1550
|
-
)
|
|
1551
|
-
] }),
|
|
1552
|
-
!isDragging && /* @__PURE__ */ jsx(FormMessage, { className: cn("pl-6 text-[#BB0B0E]") })
|
|
1553
|
-
] })
|
|
1547
|
+
] }),
|
|
1548
|
+
!isDragging && /* @__PURE__ */ jsx(FormMessage, { className: cn("pl-6 text-[#BB0B0E]") })
|
|
1549
|
+
] });
|
|
1550
|
+
}
|
|
1554
1551
|
}
|
|
1555
1552
|
) });
|
|
1556
1553
|
}
|
|
@@ -1704,8 +1701,7 @@ var GridSettingsModal = ({
|
|
|
1704
1701
|
control,
|
|
1705
1702
|
name: `columns.0.id`,
|
|
1706
1703
|
isDragging,
|
|
1707
|
-
availableColumns
|
|
1708
|
-
currentColumns: fields
|
|
1704
|
+
availableColumns
|
|
1709
1705
|
},
|
|
1710
1706
|
fields[0]?.fieldId
|
|
1711
1707
|
),
|
|
@@ -1724,16 +1720,15 @@ var GridSettingsModal = ({
|
|
|
1724
1720
|
{
|
|
1725
1721
|
items: fields?.slice(1).map((c) => c?.fieldId),
|
|
1726
1722
|
strategy: verticalListSortingStrategy,
|
|
1727
|
-
children: fields?.slice(1).map((col,
|
|
1723
|
+
children: fields?.slice(1).map((col, index) => /* @__PURE__ */ jsx(
|
|
1728
1724
|
SortableRow,
|
|
1729
1725
|
{
|
|
1730
1726
|
value: col?.fieldId,
|
|
1731
1727
|
control,
|
|
1732
|
-
name: `columns.${
|
|
1728
|
+
name: `columns.${index + 1}.id`,
|
|
1733
1729
|
isDragging,
|
|
1734
1730
|
availableColumns,
|
|
1735
|
-
|
|
1736
|
-
onRemove: () => remove(index2 + 1)
|
|
1731
|
+
onRemove: () => remove(index + 1)
|
|
1737
1732
|
},
|
|
1738
1733
|
col?.fieldId
|
|
1739
1734
|
))
|
|
@@ -2620,8 +2615,8 @@ var TagsInput = ({ value = [], onChange, onClear, error }) => {
|
|
|
2620
2615
|
onChange([...value, trimmed]);
|
|
2621
2616
|
setInputValue("");
|
|
2622
2617
|
};
|
|
2623
|
-
const removeTag = (
|
|
2624
|
-
const newTags = value.filter((_, i2) => i2 !==
|
|
2618
|
+
const removeTag = (index) => {
|
|
2619
|
+
const newTags = value.filter((_, i2) => i2 !== index);
|
|
2625
2620
|
onChange(newTags);
|
|
2626
2621
|
};
|
|
2627
2622
|
const handleKeyDown = (e2) => {
|
|
@@ -2960,8 +2955,8 @@ function buildLocalizeFn(args) {
|
|
|
2960
2955
|
const width = options?.width ? String(options.width) : args.defaultWidth;
|
|
2961
2956
|
valuesArray = args.values[width] || args.values[defaultWidth];
|
|
2962
2957
|
}
|
|
2963
|
-
const
|
|
2964
|
-
return valuesArray[
|
|
2958
|
+
const index = args.argumentCallback ? args.argumentCallback(value) : value;
|
|
2959
|
+
return valuesArray[index];
|
|
2965
2960
|
};
|
|
2966
2961
|
}
|
|
2967
2962
|
|
|
@@ -3281,7 +3276,7 @@ var match = {
|
|
|
3281
3276
|
defaultMatchWidth: "wide",
|
|
3282
3277
|
parsePatterns: parseQuarterPatterns,
|
|
3283
3278
|
defaultParseWidth: "any",
|
|
3284
|
-
valueCallback: (
|
|
3279
|
+
valueCallback: (index) => index + 1
|
|
3285
3280
|
}),
|
|
3286
3281
|
month: buildMatchFn({
|
|
3287
3282
|
matchPatterns: matchMonthPatterns,
|