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