@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 CHANGED
@@ -1482,7 +1482,6 @@ function TooltipContent({
1482
1482
  }
1483
1483
  function SortableRow({
1484
1484
  availableColumns,
1485
- currentColumns,
1486
1485
  control,
1487
1486
  name,
1488
1487
  value,
@@ -1498,88 +1497,86 @@ function SortableRow({
1498
1497
  transition
1499
1498
  };
1500
1499
  const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
1501
- const options = availableColumns.map((col) => ({
1502
- id: col.id,
1503
- label: capitalize(col.id)
1504
- }));
1500
+ const currentFormColumns = reactHookForm.useWatch({ control, name: "columns" });
1505
1501
  return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: setNodeRef, style, className: "flex items-center rounded-md bg-white", children: /* @__PURE__ */ jsxRuntime.jsx(
1506
1502
  FormField2,
1507
1503
  {
1508
1504
  control,
1509
1505
  name,
1510
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem2, { className: "flex-1", children: [
1511
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1512
- /* @__PURE__ */ jsxRuntime.jsx(
1513
- lucideReact.GripVertical,
1514
- {
1515
- ...attributes,
1516
- ...listeners,
1517
- className: cn(
1518
- "h-5 w-5 text-[#B9B9B9] focus:outline-none cursor-grab",
1519
- name == "columns.0.id" && "opacity-0 pointer-events-none"
1520
- )
1521
- }
1522
- ),
1523
- /* @__PURE__ */ jsxRuntime.jsxs(
1524
- Select,
1525
- {
1526
- value: field.value,
1527
- onValueChange: field.onChange,
1528
- disabled: name == "columns.0.id",
1529
- children: [
1530
- /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
1531
- SelectTrigger,
1532
- {
1533
- className: cn(
1534
- "w-full border-[#DDDDDD] data-[disabled]:opacity-100 aria-invalid:border-[#BB0B0E]",
1535
- name == "columns.0.id" ? "text-[#8B8B8B] bg-[#EAEAEA] cursor-not-allowed" : ""
1536
- ),
1537
- children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Choose column..." })
1538
- }
1539
- ) }),
1540
- /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.filter(
1541
- (i2) => i2.id === field.value || !currentColumns?.some((c, idx) => c.id === i2.id && idx !== index)
1542
- ).sort(
1543
- (a, b) => a.id === field.value ? -1 : b.id === field.value ? 1 : 0
1544
- ).map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
1545
- SelectItem,
1546
- {
1547
- value: opt.id,
1548
- className: cn(
1549
- "focus:bg-[#e8edea]",
1550
- opt.id === field.value ? "font-bold bg-[#dae5de] focus:bg-[#dae5de]" : ""
1551
- ),
1552
- children: opt.label
1553
- },
1554
- opt.id
1555
- )) })
1556
- ]
1557
- }
1558
- ),
1559
- name == "columns.0.id" ? /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
1560
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { className: "h-5 w-5", stroke: "white", fill: "#8B8B8B" }) }),
1506
+ render: ({ field }) => {
1507
+ 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) }));
1508
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem2, { className: "flex-1", children: [
1509
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1561
1510
  /* @__PURE__ */ jsxRuntime.jsx(
1562
- TooltipContent,
1511
+ lucideReact.GripVertical,
1563
1512
  {
1564
- align: "start",
1565
- alignOffset: 10,
1566
- className: "bg-[#8B8B8B] rounded-none",
1567
- arrowClassName: "!hidden",
1568
- children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Column cannot be removed." })
1513
+ ...attributes,
1514
+ ...listeners,
1515
+ className: cn(
1516
+ "h-5 w-5 text-[#B9B9B9] focus:outline-none cursor-grab",
1517
+ name == "columns.0.id" && "opacity-0 pointer-events-none"
1518
+ )
1519
+ }
1520
+ ),
1521
+ /* @__PURE__ */ jsxRuntime.jsxs(
1522
+ Select,
1523
+ {
1524
+ value: field.value,
1525
+ onValueChange: field.onChange,
1526
+ disabled: name == "columns.0.id",
1527
+ children: [
1528
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
1529
+ SelectTrigger,
1530
+ {
1531
+ className: cn(
1532
+ "w-full border-[#DDDDDD] data-[disabled]:opacity-100 aria-invalid:border-[#BB0B0E]",
1533
+ name == "columns.0.id" ? "text-[#8B8B8B] bg-[#EAEAEA] cursor-not-allowed" : ""
1534
+ ),
1535
+ children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Choose column..." })
1536
+ }
1537
+ ) }),
1538
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.sort(
1539
+ (a, b) => a.id === field.value ? -1 : b.id === field.value ? 1 : 0
1540
+ ).map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
1541
+ SelectItem,
1542
+ {
1543
+ value: opt.id,
1544
+ className: cn(
1545
+ "focus:bg-[#e8edea]",
1546
+ opt.id === field.value ? "font-bold bg-[#dae5de] focus:bg-[#dae5de]" : ""
1547
+ ),
1548
+ children: opt.label
1549
+ },
1550
+ opt.id
1551
+ )) })
1552
+ ]
1553
+ }
1554
+ ),
1555
+ name == "columns.0.id" ? /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
1556
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { className: "h-5 w-5", stroke: "white", fill: "#8B8B8B" }) }),
1557
+ /* @__PURE__ */ jsxRuntime.jsx(
1558
+ TooltipContent,
1559
+ {
1560
+ align: "start",
1561
+ alignOffset: 10,
1562
+ className: "bg-[#8B8B8B] rounded-none",
1563
+ arrowClassName: "!hidden",
1564
+ children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Column cannot be removed." })
1565
+ }
1566
+ )
1567
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
1568
+ lucideReact.CircleMinus,
1569
+ {
1570
+ onClick: onRemove,
1571
+ className: "h-5 w-5 cursor-pointer",
1572
+ stroke: "white",
1573
+ fill: "#C32A2C"
1569
1574
  }
1570
1575
  )
1571
- ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
1572
- lucideReact.CircleMinus,
1573
- {
1574
- onClick: onRemove,
1575
- className: "h-5 w-5 cursor-pointer",
1576
- stroke: "white",
1577
- fill: "#C32A2C"
1578
- }
1579
- )
1580
- ] }),
1581
- !isDragging && /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: cn("pl-6 text-[#BB0B0E]") })
1582
- ] })
1576
+ ] }),
1577
+ !isDragging && /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: cn("pl-6 text-[#BB0B0E]") })
1578
+ ] });
1579
+ }
1583
1580
  }
1584
1581
  ) });
1585
1582
  }
@@ -1733,8 +1730,7 @@ var GridSettingsModal = ({
1733
1730
  control,
1734
1731
  name: `columns.0.id`,
1735
1732
  isDragging,
1736
- availableColumns,
1737
- currentColumns: fields
1733
+ availableColumns
1738
1734
  },
1739
1735
  fields[0]?.fieldId
1740
1736
  ),
@@ -1753,16 +1749,15 @@ var GridSettingsModal = ({
1753
1749
  {
1754
1750
  items: fields?.slice(1).map((c) => c?.fieldId),
1755
1751
  strategy: sortable.verticalListSortingStrategy,
1756
- children: fields?.slice(1).map((col, index2) => /* @__PURE__ */ jsxRuntime.jsx(
1752
+ children: fields?.slice(1).map((col, index) => /* @__PURE__ */ jsxRuntime.jsx(
1757
1753
  SortableRow,
1758
1754
  {
1759
1755
  value: col?.fieldId,
1760
1756
  control,
1761
- name: `columns.${index2 + 1}.id`,
1757
+ name: `columns.${index + 1}.id`,
1762
1758
  isDragging,
1763
1759
  availableColumns,
1764
- currentColumns: fields,
1765
- onRemove: () => remove(index2 + 1)
1760
+ onRemove: () => remove(index + 1)
1766
1761
  },
1767
1762
  col?.fieldId
1768
1763
  ))
@@ -2649,8 +2644,8 @@ var TagsInput = ({ value = [], onChange, onClear, error }) => {
2649
2644
  onChange([...value, trimmed]);
2650
2645
  setInputValue("");
2651
2646
  };
2652
- const removeTag = (index2) => {
2653
- const newTags = value.filter((_, i2) => i2 !== index2);
2647
+ const removeTag = (index) => {
2648
+ const newTags = value.filter((_, i2) => i2 !== index);
2654
2649
  onChange(newTags);
2655
2650
  };
2656
2651
  const handleKeyDown = (e2) => {
@@ -2989,8 +2984,8 @@ function buildLocalizeFn(args) {
2989
2984
  const width = options?.width ? String(options.width) : args.defaultWidth;
2990
2985
  valuesArray = args.values[width] || args.values[defaultWidth];
2991
2986
  }
2992
- const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
2993
- return valuesArray[index2];
2987
+ const index = args.argumentCallback ? args.argumentCallback(value) : value;
2988
+ return valuesArray[index];
2994
2989
  };
2995
2990
  }
2996
2991
 
@@ -3310,7 +3305,7 @@ var match = {
3310
3305
  defaultMatchWidth: "wide",
3311
3306
  parsePatterns: parseQuarterPatterns,
3312
3307
  defaultParseWidth: "any",
3313
- valueCallback: (index2) => index2 + 1
3308
+ valueCallback: (index) => index + 1
3314
3309
  }),
3315
3310
  month: buildMatchFn({
3316
3311
  matchPatterns: matchMonthPatterns,