@inf-monkeys-tech/monkeys-design 0.4.32 → 0.4.34
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/LICENSE +21 -21
- package/README.md +226 -226
- package/dist/components/base/index.d.mts +2 -2
- package/dist/components/base/index.d.ts +2 -2
- package/dist/components/base/index.js +990 -28
- package/dist/components/base/index.js.map +1 -1
- package/dist/components/base/index.mjs +987 -30
- package/dist/components/base/index.mjs.map +1 -1
- package/dist/components/data-explorer/index.js.map +1 -1
- package/dist/components/data-explorer/index.mjs.map +1 -1
- package/dist/components/layout/index.js.map +1 -1
- package/dist/components/layout/index.mjs.map +1 -1
- package/dist/components/login/index.js.map +1 -1
- package/dist/components/login/index.mjs.map +1 -1
- package/dist/components/toolbar/index.js.map +1 -1
- package/dist/components/toolbar/index.mjs.map +1 -1
- package/dist/components/workbench/index.d.mts +193 -2
- package/dist/components/workbench/index.d.ts +193 -2
- package/dist/components/workbench/index.js +2164 -585
- package/dist/components/workbench/index.js.map +1 -1
- package/dist/components/workbench/index.mjs +2367 -813
- package/dist/components/workbench/index.mjs.map +1 -1
- package/dist/icons/oauth/index.js.map +1 -1
- package/dist/icons/oauth/index.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1958 -170
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1950 -172
- package/dist/index.mjs.map +1 -1
- package/dist/palette/index.js.map +1 -1
- package/dist/palette/index.mjs.map +1 -1
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/index.mjs.map +1 -1
- package/dist/styles/artist-login.scss +374 -374
- package/dist/styles/global.scss +21 -21
- package/dist/styles/workflow-board.scss +440 -440
- package/dist/styles/workflow-nodes.css +340 -340
- package/dist/{theme-CvbotXXr.d.ts → theme-Clm5dVb0.d.mts} +10 -3
- package/dist/{theme-6RDum855.d.mts → theme-sIoU5-YC.d.ts} +10 -3
- package/dist/theme-system/index.d.mts +1 -1
- package/dist/theme-system/index.d.ts +1 -1
- package/dist/theme-system/index.js +842 -18
- package/dist/theme-system/index.js.map +1 -1
- package/dist/theme-system/index.mjs +843 -19
- package/dist/theme-system/index.mjs.map +1 -1
- package/dist/themes/artist/index.js.map +1 -1
- package/dist/themes/artist/index.mjs.map +1 -1
- package/dist/themes/bsd/index.js.map +1 -1
- package/dist/themes/bsd/index.mjs.map +1 -1
- package/dist/themes/concept/index.js.map +1 -1
- package/dist/themes/concept/index.mjs.map +1 -1
- package/dist/themes/default/index.js.map +1 -1
- package/dist/themes/default/index.mjs.map +1 -1
- package/dist/{types-BgEEUqSm.d.mts → types-Bn6PEDsX.d.mts} +163 -1
- package/dist/{types-BgEEUqSm.d.ts → types-Bn6PEDsX.d.ts} +163 -1
- package/package.json +139 -138
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, useRef, useState, useEffect, useId, useMemo, createContext } from 'react';
|
|
1
|
+
import { forwardRef, useRef, useState, useEffect, useId, useMemo, createContext, useContext } from 'react';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import '@radix-ui/react-context-menu';
|
|
4
4
|
import '@radix-ui/react-dropdown-menu';
|
|
@@ -8546,7 +8546,41 @@ var baseSlots = {
|
|
|
8546
8546
|
tableEmptyActions: "mt-4 flex flex-wrap items-center justify-center gap-2",
|
|
8547
8547
|
tableLoadingRow: "border-b border-border/60",
|
|
8548
8548
|
tableLoadingCell: "px-3 py-2",
|
|
8549
|
-
tableLoadingSkeleton: "h-4 w-full rounded-md bg-muted/70"
|
|
8549
|
+
tableLoadingSkeleton: "h-4 w-full rounded-md bg-muted/70",
|
|
8550
|
+
layoutRoot: cn(
|
|
8551
|
+
"grid min-w-0 overflow-hidden grid-rows-[auto_minmax(0,1fr)_auto] gap-3 rounded-lg border border-border/70 bg-background p-3 text-foreground",
|
|
8552
|
+
motionBase
|
|
8553
|
+
),
|
|
8554
|
+
layoutRootFull: "h-full min-h-0",
|
|
8555
|
+
layoutHeader: "min-w-0",
|
|
8556
|
+
layoutBody: "grid min-h-0 min-w-0 overflow-hidden gap-3",
|
|
8557
|
+
layoutSidebar: "min-h-0 min-w-0 overflow-hidden",
|
|
8558
|
+
layoutMain: "min-h-0 min-w-0 overflow-hidden",
|
|
8559
|
+
layoutAside: "min-h-0 min-w-0 overflow-hidden",
|
|
8560
|
+
layoutFooter: "min-w-0",
|
|
8561
|
+
layoutPane: cn(
|
|
8562
|
+
"h-full max-h-full min-h-0 min-w-0 overflow-hidden rounded-lg bg-background text-foreground",
|
|
8563
|
+
motionBase
|
|
8564
|
+
),
|
|
8565
|
+
layoutPaneScrollable: "overflow-auto",
|
|
8566
|
+
layoutPaneBordered: "border border-border/70",
|
|
8567
|
+
layoutPaneMuted: "bg-muted/25",
|
|
8568
|
+
layoutPaneSoft: "bg-background/95 shadow-sm",
|
|
8569
|
+
layoutPaneTransparent: "bg-transparent shadow-none",
|
|
8570
|
+
layoutSplitRoot: "grid min-h-0 min-w-0 overflow-hidden",
|
|
8571
|
+
layoutSplitHorizontal: "grid-flow-col",
|
|
8572
|
+
layoutSplitVertical: "grid-flow-row",
|
|
8573
|
+
layoutSplitPane: "min-h-0 min-w-0 overflow-hidden",
|
|
8574
|
+
layoutSplitPrimary: "",
|
|
8575
|
+
layoutSplitSecondary: "",
|
|
8576
|
+
layoutResizeHandle: cn(
|
|
8577
|
+
"group/resize relative z-10 flex shrink-0 items-center justify-center bg-transparent text-muted-foreground hover:bg-border/60 active:bg-border/70 focus-visible:bg-border/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30",
|
|
8578
|
+
motionInteractive
|
|
8579
|
+
),
|
|
8580
|
+
layoutResizeHandleHorizontal: "w-2 cursor-col-resize",
|
|
8581
|
+
layoutResizeHandleVertical: "h-2 cursor-row-resize",
|
|
8582
|
+
layoutResizeHandleDisabled: "cursor-default opacity-60",
|
|
8583
|
+
layoutResizeHandleIndicator: "rounded-full bg-muted-foreground/45 group-hover/resize:bg-primary/70"
|
|
8550
8584
|
};
|
|
8551
8585
|
var densitySlots = {
|
|
8552
8586
|
compact: {
|
|
@@ -8620,7 +8654,12 @@ var densitySlots = {
|
|
|
8620
8654
|
tableCell: "px-2 py-1.5 text-xs",
|
|
8621
8655
|
tableHeadLabel: "text-[11px]",
|
|
8622
8656
|
tableHeadDescription: "text-[10px] leading-3",
|
|
8623
|
-
tableLoadingCell: "px-2 py-1.5"
|
|
8657
|
+
tableLoadingCell: "px-2 py-1.5",
|
|
8658
|
+
layoutRoot: "gap-2 p-2",
|
|
8659
|
+
layoutBody: "gap-2",
|
|
8660
|
+
layoutPane: "rounded-md text-xs",
|
|
8661
|
+
layoutResizeHandleHorizontal: "w-1.5",
|
|
8662
|
+
layoutResizeHandleVertical: "h-1.5"
|
|
8624
8663
|
},
|
|
8625
8664
|
default: {
|
|
8626
8665
|
buttonBase: "h-9"
|
|
@@ -8671,7 +8710,12 @@ var densitySlots = {
|
|
|
8671
8710
|
menuSubTrigger: "min-h-9 px-3 py-2",
|
|
8672
8711
|
tableHead: "h-12 px-4 py-3",
|
|
8673
8712
|
tableCell: "px-4 py-3",
|
|
8674
|
-
tableLoadingCell: "px-4 py-3"
|
|
8713
|
+
tableLoadingCell: "px-4 py-3",
|
|
8714
|
+
layoutRoot: "gap-4 p-4",
|
|
8715
|
+
layoutBody: "gap-4",
|
|
8716
|
+
layoutPane: "rounded-xl",
|
|
8717
|
+
layoutResizeHandleHorizontal: "w-2.5",
|
|
8718
|
+
layoutResizeHandleVertical: "h-2.5"
|
|
8675
8719
|
}
|
|
8676
8720
|
};
|
|
8677
8721
|
var radiusSlots = {
|
|
@@ -8715,7 +8759,9 @@ var radiusSlots = {
|
|
|
8715
8759
|
menuSubContent: "rounded-none",
|
|
8716
8760
|
tableContainer: "rounded-none",
|
|
8717
8761
|
tableEmptyIcon: "rounded-none",
|
|
8718
|
-
tableLoadingSkeleton: "rounded-none"
|
|
8762
|
+
tableLoadingSkeleton: "rounded-none",
|
|
8763
|
+
layoutRoot: "rounded-none",
|
|
8764
|
+
layoutPane: "rounded-none"
|
|
8719
8765
|
},
|
|
8720
8766
|
sm: {
|
|
8721
8767
|
buttonBase: "rounded-sm",
|
|
@@ -8757,7 +8803,9 @@ var radiusSlots = {
|
|
|
8757
8803
|
menuSubContent: "rounded-sm",
|
|
8758
8804
|
tableContainer: "rounded-sm",
|
|
8759
8805
|
tableEmptyIcon: "rounded-sm",
|
|
8760
|
-
tableLoadingSkeleton: "rounded-sm"
|
|
8806
|
+
tableLoadingSkeleton: "rounded-sm",
|
|
8807
|
+
layoutRoot: "rounded-sm",
|
|
8808
|
+
layoutPane: "rounded-sm"
|
|
8761
8809
|
},
|
|
8762
8810
|
md: {},
|
|
8763
8811
|
lg: {
|
|
@@ -8794,7 +8842,9 @@ var radiusSlots = {
|
|
|
8794
8842
|
menuSubContent: "rounded-lg",
|
|
8795
8843
|
tableContainer: "rounded-xl",
|
|
8796
8844
|
tableEmptyIcon: "rounded-xl",
|
|
8797
|
-
tableLoadingSkeleton: "rounded-lg"
|
|
8845
|
+
tableLoadingSkeleton: "rounded-lg",
|
|
8846
|
+
layoutRoot: "rounded-xl",
|
|
8847
|
+
layoutPane: "rounded-xl"
|
|
8798
8848
|
},
|
|
8799
8849
|
xl: {
|
|
8800
8850
|
buttonBase: "rounded-xl",
|
|
@@ -8832,7 +8882,9 @@ var radiusSlots = {
|
|
|
8832
8882
|
menuSubContent: "rounded-xl",
|
|
8833
8883
|
tableContainer: "rounded-2xl",
|
|
8834
8884
|
tableEmptyIcon: "rounded-2xl",
|
|
8835
|
-
tableLoadingSkeleton: "rounded-xl"
|
|
8885
|
+
tableLoadingSkeleton: "rounded-xl",
|
|
8886
|
+
layoutRoot: "rounded-2xl",
|
|
8887
|
+
layoutPane: "rounded-2xl"
|
|
8836
8888
|
},
|
|
8837
8889
|
full: {
|
|
8838
8890
|
buttonBase: "rounded-full",
|
|
@@ -8874,7 +8926,9 @@ var radiusSlots = {
|
|
|
8874
8926
|
menuSubContent: "rounded-2xl",
|
|
8875
8927
|
tableContainer: "rounded-2xl",
|
|
8876
8928
|
tableEmptyIcon: "rounded-full",
|
|
8877
|
-
tableLoadingSkeleton: "rounded-full"
|
|
8929
|
+
tableLoadingSkeleton: "rounded-full",
|
|
8930
|
+
layoutRoot: "rounded-2xl",
|
|
8931
|
+
layoutPane: "rounded-2xl"
|
|
8878
8932
|
}
|
|
8879
8933
|
};
|
|
8880
8934
|
var borderSlots = {
|
|
@@ -8916,7 +8970,10 @@ var borderSlots = {
|
|
|
8916
8970
|
tableFooterBarAttached: "border-t border-transparent",
|
|
8917
8971
|
tableRow: "border-transparent",
|
|
8918
8972
|
tableEmptyRow: "border-transparent",
|
|
8919
|
-
tableLoadingRow: "border-transparent"
|
|
8973
|
+
tableLoadingRow: "border-transparent",
|
|
8974
|
+
layoutRoot: "border-transparent",
|
|
8975
|
+
layoutPaneBordered: "border-transparent",
|
|
8976
|
+
layoutResizeHandle: "bg-transparent hover:bg-transparent active:bg-transparent focus-visible:bg-transparent"
|
|
8920
8977
|
},
|
|
8921
8978
|
subtle: {
|
|
8922
8979
|
buttonDefault: "border-border/60",
|
|
@@ -8956,7 +9013,9 @@ var borderSlots = {
|
|
|
8956
9013
|
tableFooterBarAttached: "border-t border-border/60",
|
|
8957
9014
|
tableRow: "border-border/50",
|
|
8958
9015
|
tableEmptyRow: "border-border/50",
|
|
8959
|
-
tableLoadingRow: "border-border/50"
|
|
9016
|
+
tableLoadingRow: "border-border/50",
|
|
9017
|
+
layoutRoot: "border-border/60",
|
|
9018
|
+
layoutPaneBordered: "border-border/60"
|
|
8960
9019
|
},
|
|
8961
9020
|
solid: {},
|
|
8962
9021
|
strong: {
|
|
@@ -8997,7 +9056,10 @@ var borderSlots = {
|
|
|
8997
9056
|
tableFooterBarAttached: "border-t border-foreground/20",
|
|
8998
9057
|
tableRow: "border-foreground/15",
|
|
8999
9058
|
tableEmptyRow: "border-foreground/15",
|
|
9000
|
-
tableLoadingRow: "border-foreground/15"
|
|
9059
|
+
tableLoadingRow: "border-foreground/15",
|
|
9060
|
+
layoutRoot: "border-foreground/20",
|
|
9061
|
+
layoutPaneBordered: "border-foreground/20",
|
|
9062
|
+
layoutResizeHandle: "hover:bg-foreground/15 active:bg-foreground/20 focus-visible:bg-foreground/15"
|
|
9001
9063
|
}
|
|
9002
9064
|
};
|
|
9003
9065
|
var backgroundSlots = {
|
|
@@ -9039,7 +9101,11 @@ var backgroundSlots = {
|
|
|
9039
9101
|
tableFooter: "bg-muted/35",
|
|
9040
9102
|
tableFooterBar: "bg-muted/30 shadow-none",
|
|
9041
9103
|
tableRowInteractive: "cursor-pointer hover:bg-muted/45",
|
|
9042
|
-
tableLoadingSkeleton: "bg-muted"
|
|
9104
|
+
tableLoadingSkeleton: "bg-muted",
|
|
9105
|
+
layoutRoot: "bg-card",
|
|
9106
|
+
layoutPane: "bg-card",
|
|
9107
|
+
layoutPaneMuted: "bg-muted/35",
|
|
9108
|
+
layoutResizeHandle: "hover:bg-border/70 active:bg-border/80 focus-visible:bg-border/70"
|
|
9043
9109
|
},
|
|
9044
9110
|
soft: {
|
|
9045
9111
|
buttonDefault: "bg-muted/30 hover:bg-muted/55",
|
|
@@ -9075,7 +9141,10 @@ var backgroundSlots = {
|
|
|
9075
9141
|
tableFooter: "bg-muted/25",
|
|
9076
9142
|
tableFooterBar: "bg-muted/25 shadow-none",
|
|
9077
9143
|
tableRowInteractive: "cursor-pointer hover:bg-muted/35",
|
|
9078
|
-
tableLoadingSkeleton: "bg-muted/65"
|
|
9144
|
+
tableLoadingSkeleton: "bg-muted/65",
|
|
9145
|
+
layoutRoot: "bg-background/95 shadow-sm",
|
|
9146
|
+
layoutPane: "bg-background/95 shadow-sm",
|
|
9147
|
+
layoutPaneSoft: "bg-background/95 shadow-md"
|
|
9079
9148
|
},
|
|
9080
9149
|
glass: {
|
|
9081
9150
|
buttonBase: "backdrop-blur-md",
|
|
@@ -9136,7 +9205,13 @@ var backgroundSlots = {
|
|
|
9136
9205
|
tableRow: "border-white/10",
|
|
9137
9206
|
tableRowInteractive: "cursor-pointer hover:bg-white/[0.08]",
|
|
9138
9207
|
tableHeadLabel: "text-foreground",
|
|
9139
|
-
tableLoadingSkeleton: "bg-white/[0.16]"
|
|
9208
|
+
tableLoadingSkeleton: "bg-white/[0.16]",
|
|
9209
|
+
layoutRoot: "border-white/10 bg-white/[0.05] shadow-none backdrop-blur-md",
|
|
9210
|
+
layoutPane: "border-white/10 bg-white/[0.06] shadow-none backdrop-blur-md",
|
|
9211
|
+
layoutPaneMuted: "bg-white/[0.08]",
|
|
9212
|
+
layoutPaneSoft: "bg-white/[0.10] shadow-none backdrop-blur-md",
|
|
9213
|
+
layoutResizeHandle: "text-foreground/65 hover:bg-white/10 active:bg-white/15 focus-visible:bg-white/10",
|
|
9214
|
+
layoutResizeHandleIndicator: "bg-white/45 group-hover/resize:bg-white/75"
|
|
9140
9215
|
},
|
|
9141
9216
|
dark: {
|
|
9142
9217
|
buttonBase: "border-white/15 text-white shadow-lg backdrop-blur",
|
|
@@ -9265,7 +9340,13 @@ var backgroundSlots = {
|
|
|
9265
9340
|
menuSubTrigger: "text-white focus:bg-white/[0.10] focus:text-white data-[highlighted]:bg-white/[0.10] data-[highlighted]:text-white data-[state=open]:bg-white/[0.12]",
|
|
9266
9341
|
menuSubTriggerIcon: "text-white/55",
|
|
9267
9342
|
menuSubContent: "border-white/10 bg-slate-950 text-white shadow-2xl",
|
|
9268
|
-
tableLoadingSkeleton: "bg-white/[0.14]"
|
|
9343
|
+
tableLoadingSkeleton: "bg-white/[0.14]",
|
|
9344
|
+
layoutRoot: "border-white/10 bg-slate-950 text-white shadow-none",
|
|
9345
|
+
layoutPane: "border-white/10 bg-slate-950 text-white shadow-none",
|
|
9346
|
+
layoutPaneMuted: "bg-white/[0.06]",
|
|
9347
|
+
layoutPaneSoft: "bg-white/[0.08] shadow-none",
|
|
9348
|
+
layoutResizeHandle: "text-white/65 hover:bg-white/10 active:bg-white/15 focus-visible:bg-white/10",
|
|
9349
|
+
layoutResizeHandleIndicator: "bg-white/45 group-hover/resize:bg-white/75"
|
|
9269
9350
|
}
|
|
9270
9351
|
};
|
|
9271
9352
|
var presetDefaults = {
|
|
@@ -9693,6 +9774,448 @@ forwardRef(
|
|
|
9693
9774
|
);
|
|
9694
9775
|
}
|
|
9695
9776
|
);
|
|
9777
|
+
function normalizeValues(values) {
|
|
9778
|
+
const nextValues = [];
|
|
9779
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9780
|
+
values?.forEach((value) => {
|
|
9781
|
+
if (seen.has(value)) return;
|
|
9782
|
+
seen.add(value);
|
|
9783
|
+
nextValues.push(value);
|
|
9784
|
+
});
|
|
9785
|
+
return nextValues;
|
|
9786
|
+
}
|
|
9787
|
+
function getNextEnabledIndex(options, currentIndex, direction) {
|
|
9788
|
+
if (!options.length) return -1;
|
|
9789
|
+
const startIndex = currentIndex >= 0 ? currentIndex : 0;
|
|
9790
|
+
for (let offset = 1; offset <= options.length; offset += 1) {
|
|
9791
|
+
const nextIndex = (startIndex + offset * direction + options.length) % options.length;
|
|
9792
|
+
if (!options[nextIndex]?.disabled) {
|
|
9793
|
+
return nextIndex;
|
|
9794
|
+
}
|
|
9795
|
+
}
|
|
9796
|
+
return -1;
|
|
9797
|
+
}
|
|
9798
|
+
function getFirstEnabledIndex(options) {
|
|
9799
|
+
return options.findIndex((option) => !option.disabled);
|
|
9800
|
+
}
|
|
9801
|
+
function getSafeTagCount(maxTagCount, total) {
|
|
9802
|
+
if (maxTagCount === void 0) return total;
|
|
9803
|
+
if (!Number.isFinite(maxTagCount)) return total;
|
|
9804
|
+
return Math.max(0, Math.min(total, Math.floor(maxTagCount)));
|
|
9805
|
+
}
|
|
9806
|
+
function getDefaultRemoveLabel(option) {
|
|
9807
|
+
return `Remove ${option.value}`;
|
|
9808
|
+
}
|
|
9809
|
+
forwardRef(
|
|
9810
|
+
function BaseMultiSelect2({
|
|
9811
|
+
options,
|
|
9812
|
+
value,
|
|
9813
|
+
defaultValue,
|
|
9814
|
+
name,
|
|
9815
|
+
placeholder = "Select options",
|
|
9816
|
+
icon,
|
|
9817
|
+
invalid = false,
|
|
9818
|
+
disabled = false,
|
|
9819
|
+
required = false,
|
|
9820
|
+
openForPreview = false,
|
|
9821
|
+
maxTagCount,
|
|
9822
|
+
removeLabel = getDefaultRemoveLabel,
|
|
9823
|
+
emptyLabel = "No options",
|
|
9824
|
+
appearance,
|
|
9825
|
+
className,
|
|
9826
|
+
classNames,
|
|
9827
|
+
style,
|
|
9828
|
+
id,
|
|
9829
|
+
"aria-invalid": nativeAriaInvalid,
|
|
9830
|
+
"aria-label": nativeAriaLabel,
|
|
9831
|
+
"aria-labelledby": nativeAriaLabelledBy,
|
|
9832
|
+
onValueChange,
|
|
9833
|
+
...rootProps
|
|
9834
|
+
}, ref) {
|
|
9835
|
+
const theme = resolveBaseAppearance(appearance);
|
|
9836
|
+
const generatedId = useId();
|
|
9837
|
+
const multiSelectId = id ?? generatedId;
|
|
9838
|
+
const controlId = `${multiSelectId}-control`;
|
|
9839
|
+
const listboxId = `${multiSelectId}-listbox`;
|
|
9840
|
+
const rootRef = useRef(null);
|
|
9841
|
+
const optionList = options ?? [];
|
|
9842
|
+
const forceOpen = openForPreview;
|
|
9843
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
9844
|
+
const open = forceOpen || uncontrolledOpen;
|
|
9845
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(
|
|
9846
|
+
() => normalizeValues(defaultValue)
|
|
9847
|
+
);
|
|
9848
|
+
const [activeIndex, setActiveIndex] = useState(
|
|
9849
|
+
() => getFirstEnabledIndex(optionList)
|
|
9850
|
+
);
|
|
9851
|
+
const isControlled = value !== void 0;
|
|
9852
|
+
const selectedValues = useMemo(
|
|
9853
|
+
() => normalizeValues(isControlled ? value : uncontrolledValue),
|
|
9854
|
+
[isControlled, uncontrolledValue, value]
|
|
9855
|
+
);
|
|
9856
|
+
const selectedValueSet = useMemo(
|
|
9857
|
+
() => new Set(selectedValues),
|
|
9858
|
+
[selectedValues]
|
|
9859
|
+
);
|
|
9860
|
+
const optionByValue = useMemo(() => {
|
|
9861
|
+
const map = /* @__PURE__ */ new Map();
|
|
9862
|
+
optionList.forEach((option) => {
|
|
9863
|
+
if (!map.has(option.value)) {
|
|
9864
|
+
map.set(option.value, option);
|
|
9865
|
+
}
|
|
9866
|
+
});
|
|
9867
|
+
return map;
|
|
9868
|
+
}, [optionList]);
|
|
9869
|
+
const selectedOptions = useMemo(
|
|
9870
|
+
() => selectedValues.map((selectedValue) => optionByValue.get(selectedValue)).filter(
|
|
9871
|
+
(option) => option !== void 0
|
|
9872
|
+
),
|
|
9873
|
+
[optionByValue, selectedValues]
|
|
9874
|
+
);
|
|
9875
|
+
const firstEnabledIndex = useMemo(
|
|
9876
|
+
() => getFirstEnabledIndex(optionList),
|
|
9877
|
+
[optionList]
|
|
9878
|
+
);
|
|
9879
|
+
const resolvedActiveIndex = activeIndex >= 0 && !optionList[activeIndex]?.disabled ? activeIndex : firstEnabledIndex;
|
|
9880
|
+
const visibleTagCount = getSafeTagCount(
|
|
9881
|
+
maxTagCount,
|
|
9882
|
+
selectedOptions.length
|
|
9883
|
+
);
|
|
9884
|
+
const visibleOptions = selectedOptions.slice(0, visibleTagCount);
|
|
9885
|
+
const overflowCount = selectedOptions.length - visibleOptions.length;
|
|
9886
|
+
const isPlaceholder = selectedOptions.length === 0;
|
|
9887
|
+
const setRootRef = (node) => {
|
|
9888
|
+
rootRef.current = node;
|
|
9889
|
+
if (typeof ref === "function") {
|
|
9890
|
+
ref(node);
|
|
9891
|
+
} else if (ref) {
|
|
9892
|
+
ref.current = node;
|
|
9893
|
+
}
|
|
9894
|
+
};
|
|
9895
|
+
const setOpen = (nextOpen) => {
|
|
9896
|
+
if (disabled || forceOpen) return;
|
|
9897
|
+
setUncontrolledOpen(nextOpen);
|
|
9898
|
+
if (nextOpen) {
|
|
9899
|
+
setActiveIndex(resolvedActiveIndex);
|
|
9900
|
+
}
|
|
9901
|
+
};
|
|
9902
|
+
useEffect(() => {
|
|
9903
|
+
if (!open || forceOpen) return void 0;
|
|
9904
|
+
const handlePointerDown = (event) => {
|
|
9905
|
+
if (!rootRef.current?.contains(event.target)) {
|
|
9906
|
+
setUncontrolledOpen(false);
|
|
9907
|
+
}
|
|
9908
|
+
};
|
|
9909
|
+
document.addEventListener("pointerdown", handlePointerDown);
|
|
9910
|
+
return () => {
|
|
9911
|
+
document.removeEventListener("pointerdown", handlePointerDown);
|
|
9912
|
+
};
|
|
9913
|
+
}, [forceOpen, open]);
|
|
9914
|
+
useEffect(() => {
|
|
9915
|
+
if (resolvedActiveIndex >= 0 && resolvedActiveIndex !== activeIndex) {
|
|
9916
|
+
setActiveIndex(resolvedActiveIndex);
|
|
9917
|
+
}
|
|
9918
|
+
}, [activeIndex, resolvedActiveIndex]);
|
|
9919
|
+
const commitValues = (nextValues) => {
|
|
9920
|
+
const normalizedValues = normalizeValues(nextValues);
|
|
9921
|
+
if (!isControlled) {
|
|
9922
|
+
setUncontrolledValue(normalizedValues);
|
|
9923
|
+
}
|
|
9924
|
+
onValueChange?.(normalizedValues);
|
|
9925
|
+
};
|
|
9926
|
+
const toggleOption = (option) => {
|
|
9927
|
+
if (!option || option.disabled || disabled) return;
|
|
9928
|
+
const nextValues = selectedValueSet.has(option.value) ? selectedValues.filter((selectedValue) => selectedValue !== option.value) : [...selectedValues, option.value];
|
|
9929
|
+
commitValues(nextValues);
|
|
9930
|
+
};
|
|
9931
|
+
const removeOption = (option) => {
|
|
9932
|
+
if (disabled) return;
|
|
9933
|
+
commitValues(
|
|
9934
|
+
selectedValues.filter((selectedValue) => selectedValue !== option.value)
|
|
9935
|
+
);
|
|
9936
|
+
};
|
|
9937
|
+
const focusOption = (direction) => {
|
|
9938
|
+
const nextIndex = getNextEnabledIndex(
|
|
9939
|
+
optionList,
|
|
9940
|
+
resolvedActiveIndex,
|
|
9941
|
+
direction
|
|
9942
|
+
);
|
|
9943
|
+
if (nextIndex >= 0) {
|
|
9944
|
+
setActiveIndex(nextIndex);
|
|
9945
|
+
}
|
|
9946
|
+
};
|
|
9947
|
+
const handleKeyDown = (event) => {
|
|
9948
|
+
if (disabled) return;
|
|
9949
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
9950
|
+
event.preventDefault();
|
|
9951
|
+
if (!open) {
|
|
9952
|
+
setOpen(true);
|
|
9953
|
+
setActiveIndex(firstEnabledIndex);
|
|
9954
|
+
return;
|
|
9955
|
+
}
|
|
9956
|
+
focusOption(event.key === "ArrowDown" ? 1 : -1);
|
|
9957
|
+
return;
|
|
9958
|
+
}
|
|
9959
|
+
if (event.key === "Home") {
|
|
9960
|
+
event.preventDefault();
|
|
9961
|
+
setOpen(true);
|
|
9962
|
+
setActiveIndex(firstEnabledIndex);
|
|
9963
|
+
return;
|
|
9964
|
+
}
|
|
9965
|
+
if (event.key === "End") {
|
|
9966
|
+
event.preventDefault();
|
|
9967
|
+
setOpen(true);
|
|
9968
|
+
for (let index = optionList.length - 1; index >= 0; index -= 1) {
|
|
9969
|
+
if (!optionList[index]?.disabled) {
|
|
9970
|
+
setActiveIndex(index);
|
|
9971
|
+
break;
|
|
9972
|
+
}
|
|
9973
|
+
}
|
|
9974
|
+
return;
|
|
9975
|
+
}
|
|
9976
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
9977
|
+
event.preventDefault();
|
|
9978
|
+
if (!open) {
|
|
9979
|
+
setOpen(true);
|
|
9980
|
+
return;
|
|
9981
|
+
}
|
|
9982
|
+
toggleOption(optionList[resolvedActiveIndex]);
|
|
9983
|
+
return;
|
|
9984
|
+
}
|
|
9985
|
+
if (event.key === "Escape") {
|
|
9986
|
+
setOpen(false);
|
|
9987
|
+
}
|
|
9988
|
+
};
|
|
9989
|
+
return /* @__PURE__ */ jsxs(
|
|
9990
|
+
"div",
|
|
9991
|
+
{
|
|
9992
|
+
...rootProps,
|
|
9993
|
+
id,
|
|
9994
|
+
ref: setRootRef,
|
|
9995
|
+
className: cn(
|
|
9996
|
+
theme.slots.controlWrapper,
|
|
9997
|
+
"overflow-visible",
|
|
9998
|
+
open && "z-50",
|
|
9999
|
+
invalid && theme.slots.controlInvalid,
|
|
10000
|
+
disabled && theme.slots.controlDisabled,
|
|
10001
|
+
classNames?.root,
|
|
10002
|
+
className
|
|
10003
|
+
),
|
|
10004
|
+
style: {
|
|
10005
|
+
...theme.styles.control,
|
|
10006
|
+
...invalid ? theme.styles.controlInvalid : void 0,
|
|
10007
|
+
...disabled ? theme.styles.controlDisabled : void 0,
|
|
10008
|
+
...style
|
|
10009
|
+
},
|
|
10010
|
+
children: [
|
|
10011
|
+
hasRenderableNode(icon) ? /* @__PURE__ */ jsx("span", { className: cn(theme.slots.controlIcon, classNames?.icon), children: icon }) : null,
|
|
10012
|
+
/* @__PURE__ */ jsx(
|
|
10013
|
+
"div",
|
|
10014
|
+
{
|
|
10015
|
+
id: controlId,
|
|
10016
|
+
role: "combobox",
|
|
10017
|
+
tabIndex: disabled ? -1 : 0,
|
|
10018
|
+
"aria-haspopup": "listbox",
|
|
10019
|
+
"aria-expanded": open,
|
|
10020
|
+
"aria-controls": listboxId,
|
|
10021
|
+
"aria-disabled": disabled || void 0,
|
|
10022
|
+
"aria-required": required || void 0,
|
|
10023
|
+
"aria-invalid": nativeAriaInvalid ?? (invalid || void 0),
|
|
10024
|
+
"aria-label": nativeAriaLabel,
|
|
10025
|
+
"aria-labelledby": nativeAriaLabelledBy,
|
|
10026
|
+
className: cn(
|
|
10027
|
+
theme.slots.controlBase,
|
|
10028
|
+
"flex min-h-9 cursor-pointer flex-wrap items-center gap-1.5 py-1.5 pr-9 text-left",
|
|
10029
|
+
disabled && "!cursor-not-allowed",
|
|
10030
|
+
classNames?.control
|
|
10031
|
+
),
|
|
10032
|
+
onClick: () => setOpen(!open),
|
|
10033
|
+
onKeyDown: handleKeyDown,
|
|
10034
|
+
children: /* @__PURE__ */ jsxs(
|
|
10035
|
+
"span",
|
|
10036
|
+
{
|
|
10037
|
+
className: cn(
|
|
10038
|
+
"flex min-w-0 flex-1 flex-wrap items-center gap-1.5",
|
|
10039
|
+
classNames?.tagList
|
|
10040
|
+
),
|
|
10041
|
+
children: [
|
|
10042
|
+
visibleOptions.map((option) => /* @__PURE__ */ jsxs(
|
|
10043
|
+
"span",
|
|
10044
|
+
{
|
|
10045
|
+
className: cn(
|
|
10046
|
+
"inline-flex max-w-full items-center gap-1 rounded-full border border-border/70 bg-muted/65 px-2 py-0.5 text-xs font-medium text-foreground",
|
|
10047
|
+
classNames?.tag
|
|
10048
|
+
),
|
|
10049
|
+
children: [
|
|
10050
|
+
/* @__PURE__ */ jsx(
|
|
10051
|
+
"span",
|
|
10052
|
+
{
|
|
10053
|
+
className: cn(
|
|
10054
|
+
"max-w-40 truncate",
|
|
10055
|
+
classNames?.tagLabel
|
|
10056
|
+
),
|
|
10057
|
+
children: option.label
|
|
10058
|
+
}
|
|
10059
|
+
),
|
|
10060
|
+
/* @__PURE__ */ jsx(
|
|
10061
|
+
"button",
|
|
10062
|
+
{
|
|
10063
|
+
type: "button",
|
|
10064
|
+
"aria-label": removeLabel(option),
|
|
10065
|
+
disabled,
|
|
10066
|
+
className: cn(
|
|
10067
|
+
"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-background/80 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30 disabled:!cursor-not-allowed",
|
|
10068
|
+
classNames?.tagRemove
|
|
10069
|
+
),
|
|
10070
|
+
onClick: (event) => {
|
|
10071
|
+
event.preventDefault();
|
|
10072
|
+
event.stopPropagation();
|
|
10073
|
+
removeOption(option);
|
|
10074
|
+
},
|
|
10075
|
+
onMouseDown: (event) => {
|
|
10076
|
+
event.preventDefault();
|
|
10077
|
+
event.stopPropagation();
|
|
10078
|
+
},
|
|
10079
|
+
onKeyDown: (event) => event.stopPropagation(),
|
|
10080
|
+
children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "x" })
|
|
10081
|
+
}
|
|
10082
|
+
)
|
|
10083
|
+
]
|
|
10084
|
+
},
|
|
10085
|
+
option.value
|
|
10086
|
+
)),
|
|
10087
|
+
overflowCount > 0 ? /* @__PURE__ */ jsxs(
|
|
10088
|
+
"span",
|
|
10089
|
+
{
|
|
10090
|
+
className: cn(
|
|
10091
|
+
"inline-flex max-w-full items-center rounded-full border border-border/70 bg-muted/45 px-2 py-0.5 text-xs font-medium text-muted-foreground",
|
|
10092
|
+
classNames?.tag
|
|
10093
|
+
),
|
|
10094
|
+
children: [
|
|
10095
|
+
"+",
|
|
10096
|
+
overflowCount
|
|
10097
|
+
]
|
|
10098
|
+
}
|
|
10099
|
+
) : null,
|
|
10100
|
+
isPlaceholder ? /* @__PURE__ */ jsx(
|
|
10101
|
+
"span",
|
|
10102
|
+
{
|
|
10103
|
+
className: cn(
|
|
10104
|
+
"min-w-0 truncate",
|
|
10105
|
+
theme.slots.selectPlaceholder,
|
|
10106
|
+
classNames?.placeholder
|
|
10107
|
+
),
|
|
10108
|
+
children: placeholder
|
|
10109
|
+
}
|
|
10110
|
+
) : null
|
|
10111
|
+
]
|
|
10112
|
+
}
|
|
10113
|
+
)
|
|
10114
|
+
}
|
|
10115
|
+
),
|
|
10116
|
+
/* @__PURE__ */ jsx(
|
|
10117
|
+
"span",
|
|
10118
|
+
{
|
|
10119
|
+
className: cn(
|
|
10120
|
+
theme.slots.selectChevron,
|
|
10121
|
+
open && "rotate-[225deg]",
|
|
10122
|
+
classNames?.chevron
|
|
10123
|
+
)
|
|
10124
|
+
}
|
|
10125
|
+
),
|
|
10126
|
+
name ? selectedValues.map((selectedValue) => /* @__PURE__ */ jsx(
|
|
10127
|
+
"input",
|
|
10128
|
+
{
|
|
10129
|
+
type: "hidden",
|
|
10130
|
+
name,
|
|
10131
|
+
value: selectedValue,
|
|
10132
|
+
className: classNames?.hiddenInput
|
|
10133
|
+
},
|
|
10134
|
+
selectedValue
|
|
10135
|
+
)) : null,
|
|
10136
|
+
open ? /* @__PURE__ */ jsx(
|
|
10137
|
+
"div",
|
|
10138
|
+
{
|
|
10139
|
+
id: listboxId,
|
|
10140
|
+
role: "listbox",
|
|
10141
|
+
"aria-multiselectable": "true",
|
|
10142
|
+
"aria-labelledby": controlId,
|
|
10143
|
+
className: cn(theme.slots.selectMenu, classNames?.menu),
|
|
10144
|
+
style: theme.styles.selectMenu,
|
|
10145
|
+
children: optionList.length > 0 ? optionList.map((option, index) => {
|
|
10146
|
+
const selected = selectedValueSet.has(option.value);
|
|
10147
|
+
const active = index === resolvedActiveIndex;
|
|
10148
|
+
return /* @__PURE__ */ jsxs(
|
|
10149
|
+
"button",
|
|
10150
|
+
{
|
|
10151
|
+
type: "button",
|
|
10152
|
+
role: "option",
|
|
10153
|
+
"aria-selected": selected,
|
|
10154
|
+
disabled: option.disabled,
|
|
10155
|
+
className: cn(
|
|
10156
|
+
theme.slots.selectOption,
|
|
10157
|
+
"gap-2",
|
|
10158
|
+
active && theme.slots.selectOptionActive,
|
|
10159
|
+
selected && theme.slots.selectOptionSelected,
|
|
10160
|
+
option.disabled && theme.slots.selectOptionDisabled,
|
|
10161
|
+
classNames?.option
|
|
10162
|
+
),
|
|
10163
|
+
style: {
|
|
10164
|
+
...theme.styles.selectOption,
|
|
10165
|
+
...active ? theme.styles.selectOptionActive : void 0,
|
|
10166
|
+
...selected ? theme.styles.selectOptionSelected : void 0
|
|
10167
|
+
},
|
|
10168
|
+
onMouseEnter: () => {
|
|
10169
|
+
if (!option.disabled) {
|
|
10170
|
+
setActiveIndex(index);
|
|
10171
|
+
}
|
|
10172
|
+
},
|
|
10173
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
10174
|
+
onClick: () => toggleOption(option),
|
|
10175
|
+
children: [
|
|
10176
|
+
/* @__PURE__ */ jsx(
|
|
10177
|
+
"span",
|
|
10178
|
+
{
|
|
10179
|
+
"aria-hidden": "true",
|
|
10180
|
+
className: cn(
|
|
10181
|
+
"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-border/70 text-[10px]",
|
|
10182
|
+
selected && "border-primary/40 bg-primary text-primary-foreground",
|
|
10183
|
+
classNames?.optionIndicator
|
|
10184
|
+
),
|
|
10185
|
+
children: selected ? "\u2713" : null
|
|
10186
|
+
}
|
|
10187
|
+
),
|
|
10188
|
+
/* @__PURE__ */ jsx(
|
|
10189
|
+
"span",
|
|
10190
|
+
{
|
|
10191
|
+
className: cn(
|
|
10192
|
+
"min-w-0 flex-1 truncate",
|
|
10193
|
+
classNames?.optionLabel
|
|
10194
|
+
),
|
|
10195
|
+
children: option.label
|
|
10196
|
+
}
|
|
10197
|
+
)
|
|
10198
|
+
]
|
|
10199
|
+
},
|
|
10200
|
+
option.value
|
|
10201
|
+
);
|
|
10202
|
+
}) : /* @__PURE__ */ jsx(
|
|
10203
|
+
"div",
|
|
10204
|
+
{
|
|
10205
|
+
className: cn(
|
|
10206
|
+
"px-2.5 py-2 text-sm text-muted-foreground",
|
|
10207
|
+
classNames?.empty
|
|
10208
|
+
),
|
|
10209
|
+
children: emptyLabel
|
|
10210
|
+
}
|
|
10211
|
+
)
|
|
10212
|
+
}
|
|
10213
|
+
) : null
|
|
10214
|
+
]
|
|
10215
|
+
}
|
|
10216
|
+
);
|
|
10217
|
+
}
|
|
10218
|
+
);
|
|
9696
10219
|
function findOption(options, value) {
|
|
9697
10220
|
if (value === void 0) return void 0;
|
|
9698
10221
|
return options.find((option) => option.value === value);
|
|
@@ -9703,7 +10226,7 @@ function getInitialValue(options, defaultValue) {
|
|
|
9703
10226
|
}
|
|
9704
10227
|
return "";
|
|
9705
10228
|
}
|
|
9706
|
-
function
|
|
10229
|
+
function getNextEnabledIndex2(options, currentIndex, direction) {
|
|
9707
10230
|
if (!options.length) return -1;
|
|
9708
10231
|
for (let offset = 1; offset <= options.length; offset += 1) {
|
|
9709
10232
|
const nextIndex = (currentIndex + offset * direction + options.length) % options.length;
|
|
@@ -9805,7 +10328,7 @@ forwardRef(
|
|
|
9805
10328
|
};
|
|
9806
10329
|
const focusOption = (direction) => {
|
|
9807
10330
|
const currentIndex = activeIndex >= 0 ? activeIndex : 0;
|
|
9808
|
-
const nextIndex =
|
|
10331
|
+
const nextIndex = getNextEnabledIndex2(optionList, currentIndex, direction);
|
|
9809
10332
|
if (nextIndex >= 0) {
|
|
9810
10333
|
commitValue(optionList[nextIndex].value, optionList[nextIndex].disabled);
|
|
9811
10334
|
}
|
|
@@ -10116,7 +10639,308 @@ forwardRef(
|
|
|
10116
10639
|
);
|
|
10117
10640
|
}
|
|
10118
10641
|
);
|
|
10119
|
-
|
|
10642
|
+
var DATA_TRANSFER_COLUMN_TYPE = "application/x-monkeys-base-table-column";
|
|
10643
|
+
var BaseTableContext = createContext(null);
|
|
10644
|
+
function useBaseTableContext(appearance) {
|
|
10645
|
+
const context = useContext(BaseTableContext);
|
|
10646
|
+
if (context) {
|
|
10647
|
+
return {
|
|
10648
|
+
...context,
|
|
10649
|
+
theme: appearance ? resolveBaseAppearance(appearance) : context.theme,
|
|
10650
|
+
appearance: appearance ?? context.appearance
|
|
10651
|
+
};
|
|
10652
|
+
}
|
|
10653
|
+
const theme = resolveBaseAppearance(appearance);
|
|
10654
|
+
return {
|
|
10655
|
+
appearance,
|
|
10656
|
+
theme,
|
|
10657
|
+
setDraggingColumnId: () => {
|
|
10658
|
+
}
|
|
10659
|
+
};
|
|
10660
|
+
}
|
|
10661
|
+
function toCssSize(value) {
|
|
10662
|
+
if (value === void 0) return void 0;
|
|
10663
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
10664
|
+
}
|
|
10665
|
+
function clampWidth(value, minWidth, maxWidth) {
|
|
10666
|
+
const min5 = minWidth ?? 48;
|
|
10667
|
+
const max5 = maxWidth ?? Number.POSITIVE_INFINITY;
|
|
10668
|
+
return Math.min(Math.max(value, min5), max5);
|
|
10669
|
+
}
|
|
10670
|
+
function getNextColumnOrder(order, columnId, targetColumnId) {
|
|
10671
|
+
if (!order || columnId === targetColumnId) return void 0;
|
|
10672
|
+
const fromIndex = order.indexOf(columnId);
|
|
10673
|
+
const toIndex = order.indexOf(targetColumnId);
|
|
10674
|
+
if (fromIndex < 0 || toIndex < 0) return void 0;
|
|
10675
|
+
const next = [...order];
|
|
10676
|
+
const [moved] = next.splice(fromIndex, 1);
|
|
10677
|
+
next.splice(toIndex, 0, moved);
|
|
10678
|
+
return next;
|
|
10679
|
+
}
|
|
10680
|
+
function sortAriaValue(direction) {
|
|
10681
|
+
switch (direction) {
|
|
10682
|
+
case "asc":
|
|
10683
|
+
return "ascending";
|
|
10684
|
+
case "desc":
|
|
10685
|
+
return "descending";
|
|
10686
|
+
default:
|
|
10687
|
+
return void 0;
|
|
10688
|
+
}
|
|
10689
|
+
}
|
|
10690
|
+
function SortIndicator({
|
|
10691
|
+
direction,
|
|
10692
|
+
className
|
|
10693
|
+
}) {
|
|
10694
|
+
return /* @__PURE__ */ jsx(
|
|
10695
|
+
"span",
|
|
10696
|
+
{
|
|
10697
|
+
"aria-hidden": "true",
|
|
10698
|
+
className: cn(
|
|
10699
|
+
className,
|
|
10700
|
+
direction === "desc" && "rotate-180",
|
|
10701
|
+
(!direction || direction === "none") && "opacity-45"
|
|
10702
|
+
),
|
|
10703
|
+
children: "\u25B2"
|
|
10704
|
+
}
|
|
10705
|
+
);
|
|
10706
|
+
}
|
|
10707
|
+
function DragHandleIcon() {
|
|
10708
|
+
return /* @__PURE__ */ jsxs("span", { "aria-hidden": "true", className: "grid gap-0.5", children: [
|
|
10709
|
+
/* @__PURE__ */ jsx("span", { className: "h-0.5 w-0.5 rounded-full bg-current" }),
|
|
10710
|
+
/* @__PURE__ */ jsx("span", { className: "h-0.5 w-0.5 rounded-full bg-current" }),
|
|
10711
|
+
/* @__PURE__ */ jsx("span", { className: "h-0.5 w-0.5 rounded-full bg-current" })
|
|
10712
|
+
] });
|
|
10713
|
+
}
|
|
10714
|
+
forwardRef(function BaseTableHead2({
|
|
10715
|
+
columnId,
|
|
10716
|
+
align = "left",
|
|
10717
|
+
icon,
|
|
10718
|
+
label,
|
|
10719
|
+
description,
|
|
10720
|
+
meta,
|
|
10721
|
+
actions,
|
|
10722
|
+
trailing,
|
|
10723
|
+
sortable,
|
|
10724
|
+
sortDirection = "none",
|
|
10725
|
+
sortLabel,
|
|
10726
|
+
onSort,
|
|
10727
|
+
draggable,
|
|
10728
|
+
dragLabel,
|
|
10729
|
+
resizable,
|
|
10730
|
+
resizeLabel,
|
|
10731
|
+
width,
|
|
10732
|
+
minWidth,
|
|
10733
|
+
maxWidth,
|
|
10734
|
+
appearance,
|
|
10735
|
+
className,
|
|
10736
|
+
classNames,
|
|
10737
|
+
style,
|
|
10738
|
+
children,
|
|
10739
|
+
onDragOver,
|
|
10740
|
+
onDrop,
|
|
10741
|
+
...headProps
|
|
10742
|
+
}, forwardedRef) {
|
|
10743
|
+
const tableContext = useBaseTableContext(appearance);
|
|
10744
|
+
const { theme } = tableContext;
|
|
10745
|
+
const headRef = useRef(null);
|
|
10746
|
+
const setHeadRef = (node) => {
|
|
10747
|
+
headRef.current = node;
|
|
10748
|
+
if (typeof forwardedRef === "function") {
|
|
10749
|
+
forwardedRef(node);
|
|
10750
|
+
} else if (forwardedRef) {
|
|
10751
|
+
forwardedRef.current = node;
|
|
10752
|
+
}
|
|
10753
|
+
};
|
|
10754
|
+
const controlledWidth = columnId && tableContext.columnSizes?.[columnId] !== void 0 ? tableContext.columnSizes[columnId] : width;
|
|
10755
|
+
const canDrag = Boolean(
|
|
10756
|
+
columnId && draggable !== false && (draggable || tableContext.columnDragEnabled) && tableContext.columnOrder && tableContext.onColumnOrderChange
|
|
10757
|
+
);
|
|
10758
|
+
const canResize = Boolean(
|
|
10759
|
+
columnId && resizable !== false && (resizable || tableContext.columnResizeEnabled) && tableContext.onColumnSizeChange
|
|
10760
|
+
);
|
|
10761
|
+
const interactiveSort = Boolean(sortable || onSort);
|
|
10762
|
+
const ariaSort = sortAriaValue(sortDirection);
|
|
10763
|
+
const content = hasRenderableNode(label) ? label : children;
|
|
10764
|
+
const usesRichHeader = canDrag || hasRenderableNode(icon) || hasRenderableNode(label) || hasRenderableNode(description) || hasRenderableNode(meta) || hasRenderableNode(actions) || hasRenderableNode(trailing) || interactiveSort;
|
|
10765
|
+
const renderedContent = usesRichHeader ? /* @__PURE__ */ jsxs("div", { className: cn(theme.slots.tableHeadContent, classNames?.content), children: [
|
|
10766
|
+
/* @__PURE__ */ jsxs("div", { className: cn(theme.slots.tableHeadMain, classNames?.main), children: [
|
|
10767
|
+
canDrag ? /* @__PURE__ */ jsx(
|
|
10768
|
+
"button",
|
|
10769
|
+
{
|
|
10770
|
+
type: "button",
|
|
10771
|
+
draggable: true,
|
|
10772
|
+
title: dragLabel,
|
|
10773
|
+
"aria-label": dragLabel ?? `Drag column ${columnId}`,
|
|
10774
|
+
className: cn(theme.slots.tableHeadDragHandle, classNames?.dragHandle),
|
|
10775
|
+
onClick: (event) => event.stopPropagation(),
|
|
10776
|
+
onDragStart: (event) => {
|
|
10777
|
+
event.stopPropagation();
|
|
10778
|
+
tableContext.setDraggingColumnId(columnId);
|
|
10779
|
+
event.dataTransfer.effectAllowed = "move";
|
|
10780
|
+
event.dataTransfer.setData(DATA_TRANSFER_COLUMN_TYPE, columnId);
|
|
10781
|
+
},
|
|
10782
|
+
onDragEnd: (event) => {
|
|
10783
|
+
event.stopPropagation();
|
|
10784
|
+
tableContext.setDraggingColumnId(void 0);
|
|
10785
|
+
},
|
|
10786
|
+
children: /* @__PURE__ */ jsx(DragHandleIcon, {})
|
|
10787
|
+
}
|
|
10788
|
+
) : null,
|
|
10789
|
+
icon ? /* @__PURE__ */ jsx("span", { className: cn(theme.slots.tableHeadIcon, classNames?.icon), children: icon }) : null,
|
|
10790
|
+
interactiveSort ? /* @__PURE__ */ jsxs(
|
|
10791
|
+
"button",
|
|
10792
|
+
{
|
|
10793
|
+
type: "button",
|
|
10794
|
+
disabled: !onSort,
|
|
10795
|
+
title: sortLabel,
|
|
10796
|
+
className: cn(theme.slots.tableHeadSortButton, classNames?.sortButton),
|
|
10797
|
+
onClick: (event) => {
|
|
10798
|
+
event.stopPropagation();
|
|
10799
|
+
onSort?.(columnId);
|
|
10800
|
+
},
|
|
10801
|
+
children: [
|
|
10802
|
+
/* @__PURE__ */ jsxs("span", { className: cn(theme.slots.tableHeadText, classNames?.text), children: [
|
|
10803
|
+
hasRenderableNode(content) ? /* @__PURE__ */ jsx("span", { className: cn(theme.slots.tableHeadLabel, classNames?.label), children: content }) : null,
|
|
10804
|
+
hasRenderableNode(description) ? /* @__PURE__ */ jsx(
|
|
10805
|
+
"span",
|
|
10806
|
+
{
|
|
10807
|
+
className: cn(
|
|
10808
|
+
theme.slots.tableHeadDescription,
|
|
10809
|
+
classNames?.description
|
|
10810
|
+
),
|
|
10811
|
+
children: description
|
|
10812
|
+
}
|
|
10813
|
+
) : null
|
|
10814
|
+
] }),
|
|
10815
|
+
/* @__PURE__ */ jsx(
|
|
10816
|
+
SortIndicator,
|
|
10817
|
+
{
|
|
10818
|
+
direction: sortDirection,
|
|
10819
|
+
className: cn(theme.slots.tableHeadSortIcon, classNames?.sortIcon)
|
|
10820
|
+
}
|
|
10821
|
+
)
|
|
10822
|
+
]
|
|
10823
|
+
}
|
|
10824
|
+
) : /* @__PURE__ */ jsxs("span", { className: cn(theme.slots.tableHeadText, classNames?.text), children: [
|
|
10825
|
+
hasRenderableNode(content) ? /* @__PURE__ */ jsx("span", { className: cn(theme.slots.tableHeadLabel, classNames?.label), children: content }) : null,
|
|
10826
|
+
hasRenderableNode(description) ? /* @__PURE__ */ jsx(
|
|
10827
|
+
"span",
|
|
10828
|
+
{
|
|
10829
|
+
className: cn(
|
|
10830
|
+
theme.slots.tableHeadDescription,
|
|
10831
|
+
classNames?.description
|
|
10832
|
+
),
|
|
10833
|
+
children: description
|
|
10834
|
+
}
|
|
10835
|
+
) : null
|
|
10836
|
+
] })
|
|
10837
|
+
] }),
|
|
10838
|
+
hasRenderableNode(meta) || hasRenderableNode(actions) || hasRenderableNode(trailing) ? /* @__PURE__ */ jsxs("div", { className: cn(theme.slots.tableHeadActions, classNames?.actions), children: [
|
|
10839
|
+
hasRenderableNode(meta) ? /* @__PURE__ */ jsx("span", { className: cn(theme.slots.tableHeadMeta, classNames?.meta), children: meta }) : null,
|
|
10840
|
+
actions,
|
|
10841
|
+
trailing
|
|
10842
|
+
] }) : null
|
|
10843
|
+
] }) : children;
|
|
10844
|
+
const handleDragOver = (event) => {
|
|
10845
|
+
onDragOver?.(event);
|
|
10846
|
+
if (!canDrag || !tableContext.draggingColumnId || tableContext.draggingColumnId === columnId) {
|
|
10847
|
+
return;
|
|
10848
|
+
}
|
|
10849
|
+
event.preventDefault();
|
|
10850
|
+
event.dataTransfer.dropEffect = "move";
|
|
10851
|
+
};
|
|
10852
|
+
const handleDrop = (event) => {
|
|
10853
|
+
onDrop?.(event);
|
|
10854
|
+
if (!canDrag || !columnId) return;
|
|
10855
|
+
const sourceColumnId = tableContext.draggingColumnId || event.dataTransfer.getData(DATA_TRANSFER_COLUMN_TYPE);
|
|
10856
|
+
if (!sourceColumnId || sourceColumnId === columnId) return;
|
|
10857
|
+
const nextOrder = getNextColumnOrder(
|
|
10858
|
+
tableContext.columnOrder,
|
|
10859
|
+
sourceColumnId,
|
|
10860
|
+
columnId
|
|
10861
|
+
);
|
|
10862
|
+
if (nextOrder) {
|
|
10863
|
+
event.preventDefault();
|
|
10864
|
+
tableContext.onColumnOrderChange?.(nextOrder, {
|
|
10865
|
+
columnId: sourceColumnId,
|
|
10866
|
+
targetColumnId: columnId
|
|
10867
|
+
});
|
|
10868
|
+
}
|
|
10869
|
+
tableContext.setDraggingColumnId(void 0);
|
|
10870
|
+
};
|
|
10871
|
+
const handleResizePointerDown = (event) => {
|
|
10872
|
+
if (!canResize || !columnId || !tableContext.onColumnSizeChange) return;
|
|
10873
|
+
event.preventDefault();
|
|
10874
|
+
event.stopPropagation();
|
|
10875
|
+
const startX = event.clientX;
|
|
10876
|
+
const currentWidth = typeof controlledWidth === "number" ? controlledWidth : headRef.current?.offsetWidth ?? minWidth ?? 96;
|
|
10877
|
+
const previousWidth = clampWidth(currentWidth, minWidth, maxWidth);
|
|
10878
|
+
const pointerId = event.pointerId;
|
|
10879
|
+
const target = event.currentTarget;
|
|
10880
|
+
target.setPointerCapture?.(pointerId);
|
|
10881
|
+
const handlePointerMove = (moveEvent) => {
|
|
10882
|
+
const nextWidth = clampWidth(
|
|
10883
|
+
previousWidth + moveEvent.clientX - startX,
|
|
10884
|
+
minWidth,
|
|
10885
|
+
maxWidth
|
|
10886
|
+
);
|
|
10887
|
+
tableContext.onColumnSizeChange?.(columnId, nextWidth, {
|
|
10888
|
+
columnId,
|
|
10889
|
+
previousWidth,
|
|
10890
|
+
minWidth,
|
|
10891
|
+
maxWidth
|
|
10892
|
+
});
|
|
10893
|
+
};
|
|
10894
|
+
const cleanup = () => {
|
|
10895
|
+
target.releasePointerCapture?.(pointerId);
|
|
10896
|
+
window.removeEventListener("pointermove", handlePointerMove);
|
|
10897
|
+
window.removeEventListener("pointerup", cleanup);
|
|
10898
|
+
window.removeEventListener("pointercancel", cleanup);
|
|
10899
|
+
};
|
|
10900
|
+
window.addEventListener("pointermove", handlePointerMove);
|
|
10901
|
+
window.addEventListener("pointerup", cleanup);
|
|
10902
|
+
window.addEventListener("pointercancel", cleanup);
|
|
10903
|
+
};
|
|
10904
|
+
return /* @__PURE__ */ jsxs(
|
|
10905
|
+
"th",
|
|
10906
|
+
{
|
|
10907
|
+
...headProps,
|
|
10908
|
+
ref: setHeadRef,
|
|
10909
|
+
scope: headProps.scope ?? "col",
|
|
10910
|
+
"aria-sort": ariaSort,
|
|
10911
|
+
className: cn(
|
|
10912
|
+
theme.slots.tableHead,
|
|
10913
|
+
align === "center" && theme.slots.tableCellAlignCenter,
|
|
10914
|
+
align === "right" && theme.slots.tableCellAlignRight,
|
|
10915
|
+
classNames?.root,
|
|
10916
|
+
className
|
|
10917
|
+
),
|
|
10918
|
+
style: {
|
|
10919
|
+
...theme.styles.tableHead,
|
|
10920
|
+
width: toCssSize(controlledWidth),
|
|
10921
|
+
minWidth: toCssSize(minWidth),
|
|
10922
|
+
maxWidth: toCssSize(maxWidth),
|
|
10923
|
+
...style
|
|
10924
|
+
},
|
|
10925
|
+
onDragOver: handleDragOver,
|
|
10926
|
+
onDrop: handleDrop,
|
|
10927
|
+
children: [
|
|
10928
|
+
renderedContent,
|
|
10929
|
+
canResize ? /* @__PURE__ */ jsx(
|
|
10930
|
+
"button",
|
|
10931
|
+
{
|
|
10932
|
+
type: "button",
|
|
10933
|
+
title: resizeLabel,
|
|
10934
|
+
"aria-label": resizeLabel ?? `Resize column ${columnId}`,
|
|
10935
|
+
className: cn(theme.slots.tableHeadResizeHandle, classNames?.resizeHandle),
|
|
10936
|
+
onClick: (event) => event.stopPropagation(),
|
|
10937
|
+
onPointerDown: handleResizePointerDown
|
|
10938
|
+
}
|
|
10939
|
+
) : null
|
|
10940
|
+
]
|
|
10941
|
+
}
|
|
10942
|
+
);
|
|
10943
|
+
});
|
|
10120
10944
|
forwardRef(
|
|
10121
10945
|
function BaseTextarea2({
|
|
10122
10946
|
invalid = false,
|