@postxl/ui-components 1.2.1 → 1.2.3

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
@@ -1478,12 +1478,12 @@ function DropdownMenuSubContent({ className,...props }) {
1478
1478
  const TooltipProvider = TooltipPrimitive.Provider;
1479
1479
  const Tooltip = TooltipPrimitive.Root;
1480
1480
  const TooltipTrigger = TooltipPrimitive.Trigger;
1481
- const TooltipContent = React$34.forwardRef(({ className, sideOffset = 4,...props }, ref) => /* @__PURE__ */ jsx(TooltipPrimitive.Content, {
1481
+ const TooltipContent = React$34.forwardRef(({ className, sideOffset = 4,...props }, ref) => /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Content, {
1482
1482
  ref,
1483
1483
  sideOffset,
1484
1484
  className: cn("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className),
1485
1485
  ...props
1486
- }));
1486
+ }) }));
1487
1487
  TooltipContent.displayName = TooltipPrimitive.Content.displayName;
1488
1488
 
1489
1489
  //#endregion
@@ -2491,10 +2491,7 @@ function DataGridRowImpl({ row, virtualRowIndex, virtualStart, rowVirtualizer, r
2491
2491
  ...getCommonPinningStyles({ column: cell.column }),
2492
2492
  width: `calc(var(--col-${cell.column.id}-size) * 1px)`
2493
2493
  },
2494
- children: typeof cell.column.columnDef.header === "function" ? /* @__PURE__ */ jsx("div", {
2495
- className: cn("size-full px-3 py-1.5", { "bg-accent-foreground/10": isRowSelected }),
2496
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
2497
- }) : flexRender(cell.column.columnDef.cell, cell.getContext())
2494
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
2498
2495
  }, cell.id);
2499
2496
  })
2500
2497
  }, row.id);
@@ -2760,7 +2757,7 @@ function DataGrid({ dataGridRef, headerRef, rowMapRef, footerRef, table, rowVirt
2760
2757
  width: `calc(var(--header-${header.id}-size) * 1px)`
2761
2758
  },
2762
2759
  children: header.isPlaceholder ? null : typeof header.column.columnDef.header === "function" ? /* @__PURE__ */ jsx("div", {
2763
- className: "size-full px-3 py-1.5 bg-secondary/80 hover:bg-secondary/40",
2760
+ className: "size-full px-3 py-1.5 bg-sidebar-accent/80 hover:bg-secondary/40",
2764
2761
  children: flexRender(header.column.columnDef.header, header.getContext())
2765
2762
  }) : /* @__PURE__ */ jsx(DataGridColumnHeader, {
2766
2763
  header,
@@ -2842,7 +2839,7 @@ function DataGrid({ dataGridRef, headerRef, rowMapRef, footerRef, table, rowVirt
2842
2839
 
2843
2840
  //#endregion
2844
2841
  //#region src/data-grid/data-grid-cell-wrapper.tsx
2845
- function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFocused, isSelected, className, onClick: onClickProp, onKeyDown: onKeyDownProp,...props }) {
2842
+ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFocused, isSelected, className, onClick: onClickProp, onKeyDown: onKeyDownProp, children,...props }) {
2846
2843
  const meta = table.options.meta;
2847
2844
  const rowOriginal = cell?.row?.original ?? {};
2848
2845
  const colCellMeta = cell?.column?.columnDef?.meta;
@@ -2949,7 +2946,9 @@ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFoc
2949
2946
  isEditable
2950
2947
  ]);
2951
2948
  const rowHeight = meta?.rowHeight ?? "short";
2952
- return /* @__PURE__ */ jsx("div", {
2949
+ const cellOverlay = colCellMeta?.cellOverlay;
2950
+ const overlayContent = cellOverlay ? cellOverlay(rowOriginal, cell.getValue(), rowIndex, columnId) : null;
2951
+ return /* @__PURE__ */ jsxs("div", {
2953
2952
  role: "button",
2954
2953
  "data-slot": "grid-cell-wrapper",
2955
2954
  "data-editing": isEditing ? "" : void 0,
@@ -2969,7 +2968,8 @@ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFoc
2969
2968
  "**:data-[slot=grid-cell-content]:line-clamp-1": !isEditing && rowHeight === "short",
2970
2969
  "**:data-[slot=grid-cell-content]:line-clamp-2": !isEditing && rowHeight === "medium",
2971
2970
  "**:data-[slot=grid-cell-content]:line-clamp-3": !isEditing && rowHeight === "tall",
2972
- "**:data-[slot=grid-cell-content]:line-clamp-4": !isEditing && rowHeight === "extra-tall"
2971
+ "**:data-[slot=grid-cell-content]:line-clamp-4": !isEditing && rowHeight === "extra-tall",
2972
+ "relative overflow-visible": !!overlayContent
2973
2973
  }, colCellClassName, className),
2974
2974
  onClick,
2975
2975
  onContextMenu,
@@ -2978,7 +2978,8 @@ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFoc
2978
2978
  onMouseEnter,
2979
2979
  onMouseUp,
2980
2980
  onKeyDown,
2981
- ...props
2981
+ ...props,
2982
+ children: [children, overlayContent]
2982
2983
  });
2983
2984
  }
2984
2985
 
@@ -3717,7 +3718,23 @@ function NumberCell({ cell, table, rowIndex, columnId, isFocused, isEditing, isS
3717
3718
  return typeof v === "function" ? v : () => Boolean(v);
3718
3719
  }, [colMeta?.editable]);
3719
3720
  const isEditable = editableResolver(cell.row.original);
3720
- const { min, max, step, prefix = "", suffix = "", fallbackValue = "" } = cellOptions?.variant === "number" ? cellOptions : {};
3721
+ const { min, max, step, prefix, suffix, fallbackValue = "" } = cellOptions?.variant === "number" ? cellOptions : {};
3722
+ const resolvedPrefix = React$19.useMemo(() => {
3723
+ if (typeof prefix === "function") return prefix(cell.row.original, initialValue);
3724
+ return prefix ?? null;
3725
+ }, [
3726
+ prefix,
3727
+ cell.row.original,
3728
+ initialValue
3729
+ ]);
3730
+ const resolvedSuffix = React$19.useMemo(() => {
3731
+ if (typeof suffix === "function") return suffix(cell.row.original, initialValue);
3732
+ return suffix ?? null;
3733
+ }, [
3734
+ suffix,
3735
+ cell.row.original,
3736
+ initialValue
3737
+ ]);
3721
3738
  const [editValue, setEditValue] = React$19.useState(initialValue !== null && initialValue !== void 0 ? String(initialValue) : "");
3722
3739
  const hasSubmittedRef = React$19.useRef(false);
3723
3740
  React$19.useEffect(() => {
@@ -3748,7 +3765,7 @@ function NumberCell({ cell, table, rowIndex, columnId, isFocused, isEditing, isS
3748
3765
  const saveAndStop = React$19.useCallback((options) => {
3749
3766
  hasSubmittedRef.current = true;
3750
3767
  const numValue = parseNumValue();
3751
- if (numValue !== initialValue) meta?.onDataUpdate?.({
3768
+ meta?.onDataUpdate?.({
3752
3769
  rowIndex,
3753
3770
  columnId,
3754
3771
  value: numValue
@@ -3756,7 +3773,6 @@ function NumberCell({ cell, table, rowIndex, columnId, isFocused, isEditing, isS
3756
3773
  meta?.onCellEditingStop?.(options);
3757
3774
  }, [
3758
3775
  parseNumValue,
3759
- initialValue,
3760
3776
  meta,
3761
3777
  rowIndex,
3762
3778
  columnId
@@ -3832,10 +3848,10 @@ function NumberCell({ cell, table, rowIndex, columnId, isFocused, isEditing, isS
3832
3848
  }) : /* @__PURE__ */ jsx("span", {
3833
3849
  "data-slot": "grid-cell-content",
3834
3850
  className: cn("tabular-nums", colMeta?.align ?? "text-right"),
3835
- children: initialValue === null || initialValue === void 0 || editValue === "" ? fallbackValue : /* @__PURE__ */ jsxs(Fragment, { children: [
3836
- prefix,
3851
+ children: initialValue === null || initialValue === void 0 ? fallbackValue : /* @__PURE__ */ jsxs(Fragment, { children: [
3852
+ resolvedPrefix,
3837
3853
  initialValue.toLocaleString(),
3838
- suffix
3854
+ resolvedSuffix
3839
3855
  ] })
3840
3856
  })
3841
3857
  });
@@ -3843,16 +3859,26 @@ function NumberCell({ cell, table, rowIndex, columnId, isFocused, isEditing, isS
3843
3859
 
3844
3860
  //#endregion
3845
3861
  //#region src/data-grid/cell-variants/react-node-cell.tsx
3846
- function ReactNodeCell({ cell, table, rowIndex, columnId, isFocused, isSelected }) {
3847
- const children = cell.getValue();
3862
+ function ReactNodeCell({ cell, table, rowIndex, columnId, isFocused, isSelected, isEditing }) {
3848
3863
  const containerRef = React$18.useRef(null);
3864
+ const cellOpts = cell.column.columnDef.meta?.cell;
3865
+ const renderFn = cellOpts?.variant === "react-node" ? cellOpts.render : void 0;
3866
+ const children = renderFn ? renderFn({
3867
+ cell,
3868
+ table,
3869
+ rowIndex,
3870
+ columnId,
3871
+ isFocused,
3872
+ isSelected,
3873
+ isEditing
3874
+ }) : cell.getValue();
3849
3875
  return /* @__PURE__ */ jsx(DataGridCellWrapper, {
3850
3876
  ref: containerRef,
3851
3877
  cell,
3852
3878
  table,
3853
3879
  rowIndex,
3854
3880
  columnId,
3855
- isEditing: false,
3881
+ isEditing,
3856
3882
  isFocused,
3857
3883
  isSelected,
3858
3884
  className: "flex size-full justify-center p-0",
@@ -4042,7 +4068,8 @@ function ShortTextCell({ cell, table, rowIndex, columnId, isEditing, isFocused,
4042
4068
  const onBlur = React$16.useCallback(() => {
4043
4069
  if (hasSubmittedRef.current) return;
4044
4070
  const currentValue = inputRef.current?.value ?? "";
4045
- if (currentValue !== initialValue) meta?.onDataUpdate?.({
4071
+ const normalizedInitial = initialValue ?? "";
4072
+ if (currentValue !== normalizedInitial) meta?.onDataUpdate?.({
4046
4073
  rowIndex,
4047
4074
  columnId,
4048
4075
  value: currentValue
@@ -4062,7 +4089,7 @@ function ShortTextCell({ cell, table, rowIndex, columnId, isEditing, isFocused,
4062
4089
  event.preventDefault();
4063
4090
  hasSubmittedRef.current = true;
4064
4091
  const currentValue = inputRef.current?.value ?? "";
4065
- if (currentValue !== initialValue) meta?.onDataUpdate?.({
4092
+ meta?.onDataUpdate?.({
4066
4093
  rowIndex,
4067
4094
  columnId,
4068
4095
  value: currentValue
@@ -4072,7 +4099,7 @@ function ShortTextCell({ cell, table, rowIndex, columnId, isEditing, isFocused,
4072
4099
  event.preventDefault();
4073
4100
  hasSubmittedRef.current = true;
4074
4101
  const currentValue = inputRef.current?.value ?? "";
4075
- if (currentValue !== initialValue) meta?.onDataUpdate?.({
4102
+ meta?.onDataUpdate?.({
4076
4103
  rowIndex,
4077
4104
  columnId,
4078
4105
  value: currentValue
@@ -7105,7 +7132,7 @@ function TabsContent({ className,...props }) {
7105
7132
 
7106
7133
  //#endregion
7107
7134
  //#region src/toggle/toggle.tsx
7108
- const toggleVariants = cva("inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground", {
7135
+ const toggleVariants = cva("inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground cursor-pointer", {
7109
7136
  variants: {
7110
7137
  variant: {
7111
7138
  default: "bg-transparent",