@postxl/ui-components 1.6.3 → 1.7.0
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.d.ts +368 -317
- package/dist/index.js +70 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1380,9 +1380,9 @@ function ComboboxDemo() {
|
|
|
1380
1380
|
|
|
1381
1381
|
//#endregion
|
|
1382
1382
|
//#region src/spinner/spinner.tsx
|
|
1383
|
-
function Spinner({
|
|
1383
|
+
function Spinner({ className }) {
|
|
1384
1384
|
return /* @__PURE__ */ jsx("div", {
|
|
1385
|
-
className: cn("flex justify-center items-center w-full h-full",
|
|
1385
|
+
className: cn("flex justify-center items-center w-full h-full", className),
|
|
1386
1386
|
children: /* @__PURE__ */ jsxs("svg", {
|
|
1387
1387
|
className: "w-auto text-[inherit] h-full animate-spin",
|
|
1388
1388
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1409,7 +1409,7 @@ function Loader({ label, disabled }) {
|
|
|
1409
1409
|
className: "flex absolute z-1 left-0 top-0 bottom-0 right-0 bg-secondary/50",
|
|
1410
1410
|
children: /* @__PURE__ */ jsxs("div", {
|
|
1411
1411
|
className: "flex items-center justify-center flex-1 flex-col",
|
|
1412
|
-
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
1412
|
+
children: [/* @__PURE__ */ jsx(Spinner, { className: "w-[24px] h-[25px]" }), label && /* @__PURE__ */ jsx("h3", {
|
|
1413
1413
|
className: "pb-0 pt-3 font-medium text-xl mb-2 text-muted-foreground",
|
|
1414
1414
|
children: label
|
|
1415
1415
|
})]
|
|
@@ -1466,7 +1466,7 @@ const CommandInput = React.forwardRef(({ className, wrapperClassName, loading, r
|
|
|
1466
1466
|
variant,
|
|
1467
1467
|
inputSize
|
|
1468
1468
|
}), wrapperClassName),
|
|
1469
|
-
children: [loading ? /* @__PURE__ */ jsx(Spinner, {
|
|
1469
|
+
children: [loading ? /* @__PURE__ */ jsx(Spinner, { className: "size-4" }) : /* @__PURE__ */ jsx(MagnifyingGlassIcon, { className: "size-4 shrink-0 opacity-50" }), /* @__PURE__ */ jsx(Command$1.Input, {
|
|
1470
1470
|
ref,
|
|
1471
1471
|
"data-slot": "command-input",
|
|
1472
1472
|
className: cn("placeholder:text-muted-foreground flex w-full rounded bg-transparent text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
@@ -4660,6 +4660,60 @@ function isValidJson(str) {
|
|
|
4660
4660
|
return false;
|
|
4661
4661
|
}
|
|
4662
4662
|
}
|
|
4663
|
+
function JsonEditorWithLineNumbers({ value, onChange, onSave }) {
|
|
4664
|
+
const textareaRef = React$31.useRef(null);
|
|
4665
|
+
const gutterRef = React$31.useRef(null);
|
|
4666
|
+
const lineCount = React$31.useMemo(() => {
|
|
4667
|
+
if (!value) return 1;
|
|
4668
|
+
return value.split("\n").length;
|
|
4669
|
+
}, [value]);
|
|
4670
|
+
const gutterMinWidth = React$31.useMemo(() => {
|
|
4671
|
+
const digits = String(lineCount).length;
|
|
4672
|
+
return `calc(${digits}ch + 16px)`;
|
|
4673
|
+
}, [lineCount]);
|
|
4674
|
+
const onScroll = React$31.useCallback(() => {
|
|
4675
|
+
if (textareaRef.current && gutterRef.current) gutterRef.current.scrollTop = textareaRef.current.scrollTop;
|
|
4676
|
+
}, []);
|
|
4677
|
+
const onKeyDown = React$31.useCallback((e) => {
|
|
4678
|
+
if (e.key === "Tab") {
|
|
4679
|
+
e.preventDefault();
|
|
4680
|
+
const textarea = e.currentTarget;
|
|
4681
|
+
const start = textarea.selectionStart;
|
|
4682
|
+
const end = textarea.selectionEnd;
|
|
4683
|
+
const newValue = value.substring(0, start) + " " + value.substring(end);
|
|
4684
|
+
onChange(newValue);
|
|
4685
|
+
requestAnimationFrame(() => {
|
|
4686
|
+
textarea.selectionStart = textarea.selectionEnd = start + 2;
|
|
4687
|
+
});
|
|
4688
|
+
}
|
|
4689
|
+
if (e.key === "s" && (e.metaKey || e.ctrlKey)) {
|
|
4690
|
+
e.preventDefault();
|
|
4691
|
+
onSave?.();
|
|
4692
|
+
}
|
|
4693
|
+
}, [
|
|
4694
|
+
value,
|
|
4695
|
+
onChange,
|
|
4696
|
+
onSave
|
|
4697
|
+
]);
|
|
4698
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4699
|
+
className: "relative flex min-h-[200px] max-h-[50vh] rounded-md border border-input overflow-hidden",
|
|
4700
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
4701
|
+
ref: gutterRef,
|
|
4702
|
+
"aria-hidden": "true",
|
|
4703
|
+
style: { minWidth: gutterMinWidth },
|
|
4704
|
+
className: "shrink-0 overflow-hidden bg-muted px-2 py-2 text-right font-mono text-sm leading-[1.43] text-muted-foreground select-none border-r border-input",
|
|
4705
|
+
children: Array.from({ length: lineCount }, (_, i) => /* @__PURE__ */ jsx("div", { children: i + 1 }, i))
|
|
4706
|
+
}), /* @__PURE__ */ jsx("textarea", {
|
|
4707
|
+
ref: textareaRef,
|
|
4708
|
+
value,
|
|
4709
|
+
onChange: (e) => onChange(e.target.value),
|
|
4710
|
+
onKeyDown,
|
|
4711
|
+
onScroll,
|
|
4712
|
+
className: "flex-1 resize-none bg-transparent p-2 font-mono text-sm leading-[1.43] outline-none",
|
|
4713
|
+
spellCheck: false
|
|
4714
|
+
})]
|
|
4715
|
+
});
|
|
4716
|
+
}
|
|
4663
4717
|
function JsonCell({ cell, table, rowIndex, columnId, isFocused, isSelected }) {
|
|
4664
4718
|
const rawValue = cell.getValue();
|
|
4665
4719
|
const [dialogOpen, setDialogOpen] = React$31.useState(false);
|
|
@@ -4778,11 +4832,10 @@ function JsonCell({ cell, table, rowIndex, columnId, isFocused, isSelected }) {
|
|
|
4778
4832
|
className: "max-w-2xl max-h-[80vh]",
|
|
4779
4833
|
children: [
|
|
4780
4834
|
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [headerLabel, " (JSON)"] }) }),
|
|
4781
|
-
/* @__PURE__ */ jsx(
|
|
4835
|
+
/* @__PURE__ */ jsx(JsonEditorWithLineNumbers, {
|
|
4782
4836
|
value: editValue,
|
|
4783
|
-
onChange:
|
|
4784
|
-
|
|
4785
|
-
spellCheck: false
|
|
4837
|
+
onChange: setEditValue,
|
|
4838
|
+
onSave
|
|
4786
4839
|
}),
|
|
4787
4840
|
jsonParseError && /* @__PURE__ */ jsx("p", {
|
|
4788
4841
|
className: "text-sm text-destructive",
|
|
@@ -9111,10 +9164,11 @@ PaginationEllipsis.displayName = "PaginationEllipsis";
|
|
|
9111
9164
|
|
|
9112
9165
|
//#endregion
|
|
9113
9166
|
//#region src/progress/progress.tsx
|
|
9114
|
-
const Progress = ({ value, size = "100%" }) => {
|
|
9167
|
+
const Progress = ({ value, size = "100%", className }) => {
|
|
9115
9168
|
return /* @__PURE__ */ jsxs("div", {
|
|
9169
|
+
"data-testid": "progress-bar",
|
|
9116
9170
|
style: { "--parent-width": size },
|
|
9117
|
-
className: "w-(--parent-width) flex justify-center relative rounded-md overflow-hidden h-2 mt-8",
|
|
9171
|
+
className: cn("w-(--parent-width) flex justify-center relative rounded-md overflow-hidden h-2 mt-8", className),
|
|
9118
9172
|
children: [/* @__PURE__ */ jsx("div", {
|
|
9119
9173
|
className: "w-full absolute top-0 left-0 h-2.5 bg-(--discreet-border)",
|
|
9120
9174
|
"data-testid": "progress-bg"
|
|
@@ -11374,11 +11428,12 @@ function Tabs({ className,...props }) {
|
|
|
11374
11428
|
...props
|
|
11375
11429
|
});
|
|
11376
11430
|
}
|
|
11377
|
-
const tabsListVariants = cva("w-fit text-muted-foreground inline-flex items-center justify-center
|
|
11431
|
+
const tabsListVariants = cva("w-fit text-muted-foreground inline-flex items-center justify-center", {
|
|
11378
11432
|
variants: {
|
|
11379
11433
|
variant: {
|
|
11380
|
-
default: "bg-muted p-[3px]",
|
|
11381
|
-
protocol: "bg-transparent"
|
|
11434
|
+
default: "rounded-lg bg-muted p-[3px]",
|
|
11435
|
+
protocol: "rounded-lg bg-transparent",
|
|
11436
|
+
underline: "border-b border-border bg-transparent p-0 rounded-none"
|
|
11382
11437
|
},
|
|
11383
11438
|
size: {
|
|
11384
11439
|
default: "h-9",
|
|
@@ -11405,7 +11460,8 @@ function TabsList({ className, variant, size, asChild = false,...props }) {
|
|
|
11405
11460
|
}
|
|
11406
11461
|
const tabsTriggerVariants = cva("h-[100%] text-lg inline-flex items-center justify-center gap-1.5 font-medium whitespace-nowrap focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 text-foreground", { variants: { variant: {
|
|
11407
11462
|
default: "h-[calc(100%-1px)] flex-1 rounded-md border border-transparent px-2 py-1 transition-[color,box-shadow] dark:text-muted-foreground data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:shadow-sm",
|
|
11408
|
-
protocol: "bg-transparent border-b-2 border-b-transparent hover:text-primary hover:border-b-primary data-[state=active]:border-b-primary data-[state=active]:text-primary"
|
|
11463
|
+
protocol: "bg-transparent border-b-2 border-b-transparent hover:text-primary hover:border-b-primary data-[state=active]:border-b-primary data-[state=active]:text-primary",
|
|
11464
|
+
underline: "rounded-none border-b-2 border-transparent px-4 py-2 hover:border-primary/50 hover:text-foreground data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none"
|
|
11409
11465
|
} } });
|
|
11410
11466
|
function TabsTrigger({ className, variant, asChild = false,...props }) {
|
|
11411
11467
|
const Comp = asChild ? Slot : TabsPrimitive.Trigger;
|