@postxl/ui-components 1.2.1 → 1.2.2

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
@@ -2760,7 +2760,7 @@ function DataGrid({ dataGridRef, headerRef, rowMapRef, footerRef, table, rowVirt
2760
2760
  width: `calc(var(--header-${header.id}-size) * 1px)`
2761
2761
  },
2762
2762
  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",
2763
+ className: "size-full px-3 py-1.5 bg-sidebar-accent/80 hover:bg-secondary/40",
2764
2764
  children: flexRender(header.column.columnDef.header, header.getContext())
2765
2765
  }) : /* @__PURE__ */ jsx(DataGridColumnHeader, {
2766
2766
  header,
@@ -2842,7 +2842,7 @@ function DataGrid({ dataGridRef, headerRef, rowMapRef, footerRef, table, rowVirt
2842
2842
 
2843
2843
  //#endregion
2844
2844
  //#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 }) {
2845
+ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFocused, isSelected, className, onClick: onClickProp, onKeyDown: onKeyDownProp, children,...props }) {
2846
2846
  const meta = table.options.meta;
2847
2847
  const rowOriginal = cell?.row?.original ?? {};
2848
2848
  const colCellMeta = cell?.column?.columnDef?.meta;
@@ -2949,7 +2949,9 @@ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFoc
2949
2949
  isEditable
2950
2950
  ]);
2951
2951
  const rowHeight = meta?.rowHeight ?? "short";
2952
- return /* @__PURE__ */ jsx("div", {
2952
+ const cellOverlay = colCellMeta?.cellOverlay;
2953
+ const overlayContent = cellOverlay ? cellOverlay(rowOriginal, cell.getValue(), rowIndex, columnId) : null;
2954
+ return /* @__PURE__ */ jsxs("div", {
2953
2955
  role: "button",
2954
2956
  "data-slot": "grid-cell-wrapper",
2955
2957
  "data-editing": isEditing ? "" : void 0,
@@ -2969,7 +2971,8 @@ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFoc
2969
2971
  "**:data-[slot=grid-cell-content]:line-clamp-1": !isEditing && rowHeight === "short",
2970
2972
  "**:data-[slot=grid-cell-content]:line-clamp-2": !isEditing && rowHeight === "medium",
2971
2973
  "**:data-[slot=grid-cell-content]:line-clamp-3": !isEditing && rowHeight === "tall",
2972
- "**:data-[slot=grid-cell-content]:line-clamp-4": !isEditing && rowHeight === "extra-tall"
2974
+ "**:data-[slot=grid-cell-content]:line-clamp-4": !isEditing && rowHeight === "extra-tall",
2975
+ "relative overflow-visible": !!overlayContent
2973
2976
  }, colCellClassName, className),
2974
2977
  onClick,
2975
2978
  onContextMenu,
@@ -2978,7 +2981,8 @@ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFoc
2978
2981
  onMouseEnter,
2979
2982
  onMouseUp,
2980
2983
  onKeyDown,
2981
- ...props
2984
+ ...props,
2985
+ children: [children, overlayContent]
2982
2986
  });
2983
2987
  }
2984
2988
 
@@ -3717,7 +3721,23 @@ function NumberCell({ cell, table, rowIndex, columnId, isFocused, isEditing, isS
3717
3721
  return typeof v === "function" ? v : () => Boolean(v);
3718
3722
  }, [colMeta?.editable]);
3719
3723
  const isEditable = editableResolver(cell.row.original);
3720
- const { min, max, step, prefix = "", suffix = "", fallbackValue = "" } = cellOptions?.variant === "number" ? cellOptions : {};
3724
+ const { min, max, step, prefix, suffix, fallbackValue = "" } = cellOptions?.variant === "number" ? cellOptions : {};
3725
+ const resolvedPrefix = React$19.useMemo(() => {
3726
+ if (typeof prefix === "function") return prefix(cell.row.original, initialValue);
3727
+ return prefix ?? null;
3728
+ }, [
3729
+ prefix,
3730
+ cell.row.original,
3731
+ initialValue
3732
+ ]);
3733
+ const resolvedSuffix = React$19.useMemo(() => {
3734
+ if (typeof suffix === "function") return suffix(cell.row.original, initialValue);
3735
+ return suffix ?? null;
3736
+ }, [
3737
+ suffix,
3738
+ cell.row.original,
3739
+ initialValue
3740
+ ]);
3721
3741
  const [editValue, setEditValue] = React$19.useState(initialValue !== null && initialValue !== void 0 ? String(initialValue) : "");
3722
3742
  const hasSubmittedRef = React$19.useRef(false);
3723
3743
  React$19.useEffect(() => {
@@ -3748,7 +3768,7 @@ function NumberCell({ cell, table, rowIndex, columnId, isFocused, isEditing, isS
3748
3768
  const saveAndStop = React$19.useCallback((options) => {
3749
3769
  hasSubmittedRef.current = true;
3750
3770
  const numValue = parseNumValue();
3751
- if (numValue !== initialValue) meta?.onDataUpdate?.({
3771
+ meta?.onDataUpdate?.({
3752
3772
  rowIndex,
3753
3773
  columnId,
3754
3774
  value: numValue
@@ -3756,7 +3776,6 @@ function NumberCell({ cell, table, rowIndex, columnId, isFocused, isEditing, isS
3756
3776
  meta?.onCellEditingStop?.(options);
3757
3777
  }, [
3758
3778
  parseNumValue,
3759
- initialValue,
3760
3779
  meta,
3761
3780
  rowIndex,
3762
3781
  columnId
@@ -3832,10 +3851,10 @@ function NumberCell({ cell, table, rowIndex, columnId, isFocused, isEditing, isS
3832
3851
  }) : /* @__PURE__ */ jsx("span", {
3833
3852
  "data-slot": "grid-cell-content",
3834
3853
  className: cn("tabular-nums", colMeta?.align ?? "text-right"),
3835
- children: initialValue === null || initialValue === void 0 || editValue === "" ? fallbackValue : /* @__PURE__ */ jsxs(Fragment, { children: [
3836
- prefix,
3854
+ children: initialValue === null || initialValue === void 0 ? fallbackValue : /* @__PURE__ */ jsxs(Fragment, { children: [
3855
+ resolvedPrefix,
3837
3856
  initialValue.toLocaleString(),
3838
- suffix
3857
+ resolvedSuffix
3839
3858
  ] })
3840
3859
  })
3841
3860
  });
@@ -4042,7 +4061,8 @@ function ShortTextCell({ cell, table, rowIndex, columnId, isEditing, isFocused,
4042
4061
  const onBlur = React$16.useCallback(() => {
4043
4062
  if (hasSubmittedRef.current) return;
4044
4063
  const currentValue = inputRef.current?.value ?? "";
4045
- if (currentValue !== initialValue) meta?.onDataUpdate?.({
4064
+ const normalizedInitial = initialValue ?? "";
4065
+ if (currentValue !== normalizedInitial) meta?.onDataUpdate?.({
4046
4066
  rowIndex,
4047
4067
  columnId,
4048
4068
  value: currentValue
@@ -4062,7 +4082,7 @@ function ShortTextCell({ cell, table, rowIndex, columnId, isEditing, isFocused,
4062
4082
  event.preventDefault();
4063
4083
  hasSubmittedRef.current = true;
4064
4084
  const currentValue = inputRef.current?.value ?? "";
4065
- if (currentValue !== initialValue) meta?.onDataUpdate?.({
4085
+ meta?.onDataUpdate?.({
4066
4086
  rowIndex,
4067
4087
  columnId,
4068
4088
  value: currentValue
@@ -4072,7 +4092,7 @@ function ShortTextCell({ cell, table, rowIndex, columnId, isEditing, isFocused,
4072
4092
  event.preventDefault();
4073
4093
  hasSubmittedRef.current = true;
4074
4094
  const currentValue = inputRef.current?.value ?? "";
4075
- if (currentValue !== initialValue) meta?.onDataUpdate?.({
4095
+ meta?.onDataUpdate?.({
4076
4096
  rowIndex,
4077
4097
  columnId,
4078
4098
  value: currentValue
@@ -7105,7 +7125,7 @@ function TabsContent({ className,...props }) {
7105
7125
 
7106
7126
  //#endregion
7107
7127
  //#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", {
7128
+ 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
7129
  variants: {
7110
7130
  variant: {
7111
7131
  default: "bg-transparent",