@choice-ui/react 1.7.3 → 1.7.5
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/components/button/dist/index.d.ts +2 -9
- package/dist/components/button/dist/index.js +38 -19
- package/dist/components/button/src/button.d.ts +2 -9
- package/dist/components/button/src/button.js +22 -13
- package/dist/components/button/src/tv.d.ts +12 -0
- package/dist/components/button/src/tv.js +15 -5
- package/dist/components/comments/src/comment-item/tv.d.ts +3 -3
- package/dist/components/modal/dist/index.js +3 -2
- package/dist/components/modal/src/styles/style.module.css +4 -0
- package/dist/components/modal/src/styles/style.module.css.js +8 -0
- package/dist/components/modal/src/tv.d.ts +3 -3
- package/dist/components/modal/src/tv.js +3 -2
- package/dist/components/numeric-input/dist/index.js +4 -3
- package/dist/components/numeric-input/src/styles/style.module.css +45 -0
- package/dist/components/numeric-input/src/styles/style.module.css.js +12 -0
- package/dist/components/numeric-input/src/tv.js +4 -3
- package/dist/components/otp-input/src/otp-input.js +10 -31
- package/dist/components/otp-input/src/styles/style.module.css +15 -0
- package/dist/components/otp-input/src/styles/style.module.css.js +8 -0
- package/dist/components/otp-input/src/tv.d.ts +3 -3
- package/dist/components/otp-input/src/tv.js +2 -1
- package/dist/components/panel/dist/index.d.ts +16 -16
- package/dist/components/panel/src/components/panel-label.js +2 -1
- package/dist/components/panel/src/components/panel-previewer.js +2 -4
- package/dist/components/panel/src/components/panel-row-label.js +2 -4
- package/dist/components/panel/src/components/panel-row-many-icon.js +4 -5
- package/dist/components/panel/src/components/panel-row.d.ts +12 -12
- package/dist/components/panel/src/components/panel-row.js +3 -3
- package/dist/components/panel/src/components/panel-sortable-row.js +13 -12
- package/dist/components/panel/src/components/panel-sortable.d.ts +1 -1
- package/dist/components/panel/src/components/panel-sortable.js +21 -21
- package/dist/components/panel/src/components/panel-title.js +16 -19
- package/dist/components/panel/src/context/panel-context.d.ts +1 -2
- package/dist/components/panel/src/hooks/use-panel-drag-drop.js +7 -6
- package/dist/components/panel/src/panel.d.ts +2 -2
- package/dist/components/panel/src/panel.js +38 -37
- package/dist/components/panel/src/styles/style.module.css +103 -0
- package/dist/components/panel/src/styles/style.module.css.js +23 -0
- package/dist/components/panel/src/tv.d.ts +89 -0
- package/dist/components/panel/src/tv.js +52 -15
- package/dist/components/skeleton/src/styles/style.module.css +18 -0
- package/dist/components/skeleton/src/styles/style.module.css.js +8 -0
- package/dist/components/skeleton/src/tv.js +2 -1
- package/dist/components/splitter/dist/index.d.ts +1 -1
- package/dist/components/splitter/src/splitter.d.ts +2 -2
- package/dist/components/text-field/dist/index.js +2 -1
- package/dist/components/text-field/src/styles/style.module.css +31 -0
- package/dist/components/text-field/src/styles/style.module.css.js +8 -0
- package/dist/components/text-field/src/tv.js +2 -1
- package/dist/components/toast/dist/index.d.ts +14 -0
- package/dist/components/toast/src/components/toaster-item.js +2 -1
- package/dist/components/toast/src/store.d.ts +14 -0
- package/dist/components/toast/src/store.js +1 -0
- package/dist/styles/components.css +0 -199
- package/package.json +1 -1
- package/dist/components/splitter/src/tv.d.ts +0 -7
|
@@ -36,7 +36,7 @@ export declare const otpInputTv: import('tailwind-variants').TVReturnType<{
|
|
|
36
36
|
group: string;
|
|
37
37
|
slot: string[];
|
|
38
38
|
slotValue: string;
|
|
39
|
-
caret: string;
|
|
39
|
+
caret: string[];
|
|
40
40
|
separator: string;
|
|
41
41
|
}, undefined, {
|
|
42
42
|
variant: {
|
|
@@ -76,7 +76,7 @@ export declare const otpInputTv: import('tailwind-variants').TVReturnType<{
|
|
|
76
76
|
group: string;
|
|
77
77
|
slot: string[];
|
|
78
78
|
slotValue: string;
|
|
79
|
-
caret: string;
|
|
79
|
+
caret: string[];
|
|
80
80
|
separator: string;
|
|
81
81
|
}, import('tailwind-variants').TVReturnType<{
|
|
82
82
|
variant: {
|
|
@@ -116,6 +116,6 @@ export declare const otpInputTv: import('tailwind-variants').TVReturnType<{
|
|
|
116
116
|
group: string;
|
|
117
117
|
slot: string[];
|
|
118
118
|
slotValue: string;
|
|
119
|
-
caret: string;
|
|
119
|
+
caret: string[];
|
|
120
120
|
separator: string;
|
|
121
121
|
}, undefined, unknown, unknown, undefined>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import s from "./styles/style.module.css.js";
|
|
1
2
|
import { tcv } from "../../../shared/utils/tcx/tcx.js";
|
|
2
3
|
const otpInputTv = tcv({
|
|
3
4
|
slots: {
|
|
@@ -12,7 +13,7 @@ const otpInputTv = tcv({
|
|
|
12
13
|
"border border-solid border-transparent"
|
|
13
14
|
],
|
|
14
15
|
slotValue: "",
|
|
15
|
-
caret: "absolute inset-y-2 left-1/2 w-px -translate-x-1/2",
|
|
16
|
+
caret: ["absolute inset-y-2 left-1/2 w-px -translate-x-1/2", s.caret],
|
|
16
17
|
separator: "text-secondary-foreground mx-1"
|
|
17
18
|
},
|
|
18
19
|
variants: {
|
|
@@ -11,20 +11,20 @@ interface PanelRowProps extends Omit<HTMLProps<HTMLFieldSetElement>, "title"> {
|
|
|
11
11
|
* @default "single"
|
|
12
12
|
* @description
|
|
13
13
|
* - `single`: `columns`: 1fr | `areas`: "label" "input" | `rows`: auto minmax(2rem, auto)
|
|
14
|
-
* - `two-columns`: `columns`: 1fr 1fr | `areas`: "label label" "
|
|
14
|
+
* - `two-columns`: `columns`: 1fr 1fr | `areas`: "label-1 label-2" "input-1 input-2" | `rows`: auto minmax(2rem, auto)
|
|
15
15
|
* - `one-label-one-input`: `columns`: 8fr 20fr | `areas`: "label input" | `rows`: 2rem
|
|
16
|
-
* - `one-label-one-input-one-icon`: `columns`: 8fr 20fr
|
|
17
|
-
* - `one-label-two-input`: `columns`: 8fr
|
|
18
|
-
* - `one-icon-one-input`: `columns`:
|
|
19
|
-
* - `one-input-one-icon`: `columns`: 1fr
|
|
20
|
-
* - `one-input-two-icon`: `columns`: 1fr
|
|
21
|
-
* - `two-input-two-icon`: `columns`: 1fr 1fr
|
|
22
|
-
* - `two-input-one-icon`: `columns`:
|
|
23
|
-
* - `one-icon-one-input-
|
|
24
|
-
* - `
|
|
25
|
-
* - `
|
|
16
|
+
* - `one-label-one-input-one-icon`: `columns`: 8fr 20fr 1.5rem | `areas`: "label input icon" | `rows`: 2rem
|
|
17
|
+
* - `one-label-two-input`: `columns`: 8fr 10fr 10fr | `areas`: "label input-1 input-2" | `rows`: 2rem
|
|
18
|
+
* - `one-icon-one-input`: `columns`: 1.5rem 1fr | `areas`: ". label" "icon input" | `rows`: auto minmax(2rem, auto)
|
|
19
|
+
* - `one-input-one-icon`: `columns`: 1fr 1.5rem | `areas`: "label label" "input icon" | `rows`: auto minmax(2rem, auto)
|
|
20
|
+
* - `one-input-two-icon`: `columns`: 1fr 0.5rem 1.5rem 0.25rem 1.5rem | `areas`: "label . . . ." "input . icon-1 . icon-2" | `rows`: auto minmax(2rem, auto)
|
|
21
|
+
* - `two-input-two-icon`: `columns`: minmax(76px, 1fr) 0.5rem 1fr 0.5rem 1.5rem 0.25rem 1.5rem | `areas`: "label-1 label-1 label-2 label-2 . . ." "input-1 . input-2 . icon-1 . icon-2" | `rows`: auto minmax(2rem, auto)
|
|
22
|
+
* - `two-input-one-icon`: `columns`: 1fr 1fr 1.5rem | `areas`: "label-1 label-2 label-2" "input-1 input-2 icon" | `rows`: auto minmax(2rem, auto)
|
|
23
|
+
* - `one-icon-one-input-one-icon`: `columns`: 1.5rem 0.5rem 1fr 0.5rem 1.5rem | `areas`: "label label label label label" "icon-1 . input . icon-2" | `rows`: auto minmax(2rem, auto)
|
|
24
|
+
* - `one-icon-one-input-two-icon`: `columns`: 1.5rem 0.5rem 1fr 0.5rem 1.5rem 0.25rem 1.5rem | `areas`: "label label label label label label label" "icon-1 . input . icon-2 . icon-3" | `rows`: auto minmax(2rem, auto)
|
|
25
|
+
* - `two-input-one-icon-double-row`: `columns`: 1fr 1fr 1.5rem | `areas`: "label-1 label-2 ." "input-1 input-3 icon-1" "input-2 input-3 icon-2" | `rows`: auto 2rem 2rem
|
|
26
26
|
*/
|
|
27
|
-
type?: "single" | "two-columns" | "one-label-one-input" | "one-label-one-input-one-icon" | "one-label-two-input" | "one-icon-one-input" | "one-input-one-icon" | "one-input-two-icon" | "two-input-two-icon" | "two-input-one-icon" | "one-icon-one-input-two-icon" | "two-input-one-icon-double-row";
|
|
27
|
+
type?: "single" | "two-columns" | "one-label-one-input" | "one-label-one-input-one-icon" | "one-label-two-input" | "one-icon-one-input" | "one-input-one-icon" | "one-input-two-icon" | "two-input-two-icon" | "two-input-one-icon" | "one-icon-one-input-one-icon" | "one-icon-one-input-two-icon" | "two-input-one-icon-double-row";
|
|
28
28
|
}
|
|
29
29
|
declare const PanelRow: react.ForwardRefExoticComponent<Omit<PanelRowProps, "ref"> & react.RefAttributes<HTMLFieldSetElement>>;
|
|
30
30
|
|
|
@@ -83,8 +83,8 @@ declare const SortablePaneContext: react__default.Context<SortablePaneContextVal
|
|
|
83
83
|
declare const useSortablePane: () => SortablePaneContextValue;
|
|
84
84
|
|
|
85
85
|
interface PanelSortableProps<T extends SortableItem> {
|
|
86
|
-
children: react__default.ReactNode;
|
|
87
86
|
className?: string;
|
|
87
|
+
children: react__default.ReactNode;
|
|
88
88
|
data: T[];
|
|
89
89
|
onDrop: (position: "top" | "bottom" | null, id: string, newIndex: number) => void;
|
|
90
90
|
onSelectedIdChange: (id: string | null) => void;
|
|
@@ -129,12 +129,12 @@ interface PanelProps extends Omit<HTMLProps<HTMLDivElement>, "title"> {
|
|
|
129
129
|
showLabels?: boolean;
|
|
130
130
|
triggerRef?: React.RefObject<HTMLDivElement>;
|
|
131
131
|
}
|
|
132
|
-
declare const PanelContent:
|
|
132
|
+
declare const PanelContent: react.NamedExoticComponent<{
|
|
133
133
|
children: React.ReactNode;
|
|
134
134
|
collapsible?: boolean;
|
|
135
135
|
otherChildren: React.ReactNode[];
|
|
136
136
|
title: React.ReactNode;
|
|
137
|
-
}
|
|
137
|
+
}>;
|
|
138
138
|
interface PanelComponentProps extends React.ForwardRefExoticComponent<PanelProps & React.RefAttributes<HTMLDivElement>> {
|
|
139
139
|
Content: typeof PanelContent;
|
|
140
140
|
Label: typeof PanelLabel;
|
|
@@ -149,4 +149,4 @@ interface PanelComponentProps extends React.ForwardRefExoticComponent<PanelProps
|
|
|
149
149
|
declare const PanelBase: react.ForwardRefExoticComponent<Omit<PanelProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
150
150
|
declare const Panel: PanelComponentProps;
|
|
151
151
|
|
|
152
|
-
export { Panel, PanelBase, PanelContext, PanelLabel, PanelPreviewer, PanelRow, PanelRowLabel, PanelRowManyIcon, type PanelRowManyIconItem, type PanelRowManyIconProps, type PanelRowProps, PanelSortable, PanelSortableRow, PanelTitle, type SortableItem, SortablePaneContext, type SortablePaneContextValue, SortableRowDataContext, type SortableRowDataContextValue, usePanelContext, useSortablePane, useSortableRowItem };
|
|
152
|
+
export { Panel, PanelBase, PanelContext, type PanelContextType, PanelLabel, PanelPreviewer, PanelRow, PanelRowLabel, PanelRowManyIcon, type PanelRowManyIconItem, type PanelRowManyIconProps, type PanelRowProps, PanelSortable, PanelSortableRow, PanelTitle, type SortableItem, SortablePaneContext, type SortablePaneContextValue, SortableRowDataContext, type SortableRowDataContextValue, usePanelContext, useSortablePane, useSortableRowItem };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
+
import { panelLabelTv } from "../tv.js";
|
|
3
4
|
import { usePanelContext } from "../context/panel-context.js";
|
|
4
5
|
import { tcx } from "../../../../shared/utils/tcx/tcx.js";
|
|
5
6
|
const PanelLabel = forwardRef(
|
|
@@ -10,7 +11,7 @@ const PanelLabel = forwardRef(
|
|
|
10
11
|
"span",
|
|
11
12
|
{
|
|
12
13
|
ref,
|
|
13
|
-
className: tcx(
|
|
14
|
+
className: tcx(panelLabelTv({ showLabels }), className),
|
|
14
15
|
...rest,
|
|
15
16
|
children: showLabels ? children : null
|
|
16
17
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { panelPreviewerTv } from "../tv.js";
|
|
2
3
|
import { tcx } from "../../../../shared/utils/tcx/tcx.js";
|
|
3
4
|
const PanelPreviewer = ({ className, ...rest }) => {
|
|
4
5
|
return /* @__PURE__ */ jsx(
|
|
5
6
|
"div",
|
|
6
7
|
{
|
|
7
|
-
className: tcx(
|
|
8
|
-
"bg-secondary-background text-secondary-foreground relative mx-4 my-2 flex h-32 flex-col items-center justify-center rounded-xl",
|
|
9
|
-
className
|
|
10
|
-
),
|
|
8
|
+
className: tcx(panelPreviewerTv(), className),
|
|
11
9
|
...rest
|
|
12
10
|
}
|
|
13
11
|
);
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { panelRowLabelTv } from "../tv.js";
|
|
2
3
|
import { tcx } from "../../../../shared/utils/tcx/tcx.js";
|
|
3
4
|
const PanelRowLabel = (props) => {
|
|
4
5
|
const { className, label, ...rest } = props;
|
|
5
6
|
return /* @__PURE__ */ jsx(
|
|
6
7
|
"div",
|
|
7
8
|
{
|
|
8
|
-
className: tcx(
|
|
9
|
-
"text-secondary-foreground cursor-default truncate select-none [grid-area:label]",
|
|
10
|
-
className
|
|
11
|
-
),
|
|
9
|
+
className: tcx(panelRowLabelTv(), className),
|
|
12
10
|
...rest,
|
|
13
11
|
children: label
|
|
14
12
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useRef, Fragment } from "react";
|
|
3
3
|
import { useHover } from "usehooks-ts";
|
|
4
|
+
import { panelRowManyIconTv } from "../tv.js";
|
|
4
5
|
import { tcx } from "../../../../shared/utils/tcx/tcx.js";
|
|
5
6
|
import { mergeRefs } from "../../../../shared/utils/merge-refs/merge-refs.js";
|
|
6
7
|
const PanelRowManyIcon = forwardRef(
|
|
@@ -8,18 +9,16 @@ const PanelRowManyIcon = forwardRef(
|
|
|
8
9
|
const { className, children, icons, isEditing, ...rest } = props;
|
|
9
10
|
const innerRef = useRef(null);
|
|
10
11
|
const isHovered = useHover(innerRef);
|
|
12
|
+
const tv = panelRowManyIconTv();
|
|
11
13
|
return /* @__PURE__ */ jsxs(
|
|
12
14
|
"div",
|
|
13
15
|
{
|
|
14
16
|
ref: mergeRefs(ref, innerRef),
|
|
15
|
-
className: tcx(
|
|
16
|
-
"group text-body-medium flex h-8 min-w-0 items-center justify-between gap-x-2 pr-2 pl-4 select-none",
|
|
17
|
-
className
|
|
18
|
-
),
|
|
17
|
+
className: tcx(tv.container(), className),
|
|
19
18
|
...rest,
|
|
20
19
|
children: [
|
|
21
20
|
children,
|
|
22
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
21
|
+
/* @__PURE__ */ jsx("div", { className: tv.iconWrapper(), children: !isEditing && icons.map(({ element, alwaysShow, id }) => {
|
|
23
22
|
return /* @__PURE__ */ jsx(Fragment, { children: isHovered || alwaysShow ? element : null }, id);
|
|
24
23
|
}) })
|
|
25
24
|
]
|
|
@@ -8,19 +8,19 @@ export interface PanelRowProps extends Omit<HTMLProps<HTMLFieldSetElement>, "tit
|
|
|
8
8
|
* @default "single"
|
|
9
9
|
* @description
|
|
10
10
|
* - `single`: `columns`: 1fr | `areas`: "label" "input" | `rows`: auto minmax(2rem, auto)
|
|
11
|
-
* - `two-columns`: `columns`: 1fr 1fr | `areas`: "label label" "
|
|
11
|
+
* - `two-columns`: `columns`: 1fr 1fr | `areas`: "label-1 label-2" "input-1 input-2" | `rows`: auto minmax(2rem, auto)
|
|
12
12
|
* - `one-label-one-input`: `columns`: 8fr 20fr | `areas`: "label input" | `rows`: 2rem
|
|
13
|
-
* - `one-label-one-input-one-icon`: `columns`: 8fr 20fr
|
|
14
|
-
* - `one-label-two-input`: `columns`: 8fr
|
|
15
|
-
* - `one-icon-one-input`: `columns`:
|
|
16
|
-
* - `one-input-one-icon`: `columns`: 1fr
|
|
17
|
-
* - `one-input-two-icon`: `columns`: 1fr
|
|
18
|
-
* - `two-input-two-icon`: `columns`: 1fr 1fr
|
|
19
|
-
* - `two-input-one-icon`: `columns`:
|
|
20
|
-
* - `one-icon-one-input-
|
|
21
|
-
* - `
|
|
22
|
-
* - `
|
|
13
|
+
* - `one-label-one-input-one-icon`: `columns`: 8fr 20fr 1.5rem | `areas`: "label input icon" | `rows`: 2rem
|
|
14
|
+
* - `one-label-two-input`: `columns`: 8fr 10fr 10fr | `areas`: "label input-1 input-2" | `rows`: 2rem
|
|
15
|
+
* - `one-icon-one-input`: `columns`: 1.5rem 1fr | `areas`: ". label" "icon input" | `rows`: auto minmax(2rem, auto)
|
|
16
|
+
* - `one-input-one-icon`: `columns`: 1fr 1.5rem | `areas`: "label label" "input icon" | `rows`: auto minmax(2rem, auto)
|
|
17
|
+
* - `one-input-two-icon`: `columns`: 1fr 0.5rem 1.5rem 0.25rem 1.5rem | `areas`: "label . . . ." "input . icon-1 . icon-2" | `rows`: auto minmax(2rem, auto)
|
|
18
|
+
* - `two-input-two-icon`: `columns`: minmax(76px, 1fr) 0.5rem 1fr 0.5rem 1.5rem 0.25rem 1.5rem | `areas`: "label-1 label-1 label-2 label-2 . . ." "input-1 . input-2 . icon-1 . icon-2" | `rows`: auto minmax(2rem, auto)
|
|
19
|
+
* - `two-input-one-icon`: `columns`: 1fr 1fr 1.5rem | `areas`: "label-1 label-2 label-2" "input-1 input-2 icon" | `rows`: auto minmax(2rem, auto)
|
|
20
|
+
* - `one-icon-one-input-one-icon`: `columns`: 1.5rem 0.5rem 1fr 0.5rem 1.5rem | `areas`: "label label label label label" "icon-1 . input . icon-2" | `rows`: auto minmax(2rem, auto)
|
|
21
|
+
* - `one-icon-one-input-two-icon`: `columns`: 1.5rem 0.5rem 1fr 0.5rem 1.5rem 0.25rem 1.5rem | `areas`: "label label label label label label label" "icon-1 . input . icon-2 . icon-3" | `rows`: auto minmax(2rem, auto)
|
|
22
|
+
* - `two-input-one-icon-double-row`: `columns`: 1fr 1fr 1.5rem | `areas`: "label-1 label-2 ." "input-1 input-3 icon-1" "input-2 input-3 icon-2" | `rows`: auto 2rem 2rem
|
|
23
23
|
*/
|
|
24
|
-
type?: "single" | "two-columns" | "one-label-one-input" | "one-label-one-input-one-icon" | "one-label-two-input" | "one-icon-one-input" | "one-input-one-icon" | "one-input-two-icon" | "two-input-two-icon" | "two-input-one-icon" | "one-icon-one-input-two-icon" | "two-input-one-icon-double-row";
|
|
24
|
+
type?: "single" | "two-columns" | "one-label-one-input" | "one-label-one-input-one-icon" | "one-label-two-input" | "one-icon-one-input" | "one-input-one-icon" | "one-input-two-icon" | "two-input-two-icon" | "two-input-one-icon" | "one-icon-one-input-one-icon" | "one-icon-one-input-two-icon" | "two-input-one-icon-double-row";
|
|
25
25
|
}
|
|
26
26
|
export declare const PanelRow: import('react').ForwardRefExoticComponent<Omit<PanelRowProps, "ref"> & import('react').RefAttributes<HTMLFieldSetElement>>;
|
|
@@ -5,19 +5,19 @@ import { tcx } from "../../../../shared/utils/tcx/tcx.js";
|
|
|
5
5
|
const PanelRow = forwardRef(
|
|
6
6
|
function PanelRow2(props, ref) {
|
|
7
7
|
const { className, children, type, triggerRef, active, ...rest } = props;
|
|
8
|
-
const
|
|
8
|
+
const tv = propertiesPanelRowTv({ type, triggerRef: !!triggerRef, active });
|
|
9
9
|
return /* @__PURE__ */ jsxs(
|
|
10
10
|
"fieldset",
|
|
11
11
|
{
|
|
12
12
|
ref,
|
|
13
|
-
className: tcx(
|
|
13
|
+
className: tcx(tv.container(), className),
|
|
14
14
|
...rest,
|
|
15
15
|
children: [
|
|
16
16
|
triggerRef && /* @__PURE__ */ jsx(
|
|
17
17
|
"div",
|
|
18
18
|
{
|
|
19
19
|
ref: triggerRef,
|
|
20
|
-
className:
|
|
20
|
+
className: tv.triggerRef()
|
|
21
21
|
}
|
|
22
22
|
),
|
|
23
23
|
children
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { GripVerticalSmall } from "@choiceform/icons-react";
|
|
3
|
-
import { memo, forwardRef,
|
|
3
|
+
import { memo, forwardRef, useMemo } from "react";
|
|
4
4
|
import { useEventCallback } from "usehooks-ts";
|
|
5
5
|
import { panelSortableRowTv } from "../tv.js";
|
|
6
6
|
import { PanelRow } from "./panel-row.js";
|
|
7
7
|
import { useSortableRowItem, useSortablePane } from "../context/sortable-context.js";
|
|
8
8
|
import { tcx } from "../../../../shared/utils/tcx/tcx.js";
|
|
9
|
-
import { mergeRefs } from "../../../../shared/utils/merge-refs/merge-refs.js";
|
|
10
9
|
const PanelSortableRow = memo(
|
|
11
10
|
forwardRef(function PanelSortableRow2(props, ref) {
|
|
12
11
|
const { children, className, ...rest } = props;
|
|
13
12
|
const item = useSortableRowItem();
|
|
14
13
|
const { id } = item;
|
|
15
14
|
const { selectedId, isDragging, isNodeBeingDragged, handleMouseDown, itemCount } = useSortablePane();
|
|
16
|
-
const rowRef = useRef(null);
|
|
17
15
|
const isBeingDragged = isNodeBeingDragged(id);
|
|
18
16
|
const isSingleItem = itemCount <= 1;
|
|
19
17
|
const handleOnMouseDown = useEventCallback((e) => {
|
|
@@ -21,24 +19,27 @@ const PanelSortableRow = memo(
|
|
|
21
19
|
if (isSingleItem) return;
|
|
22
20
|
handleMouseDown(id, e);
|
|
23
21
|
});
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const tv = useMemo(
|
|
23
|
+
() => panelSortableRowTv({
|
|
24
|
+
selected: selectedId === id,
|
|
25
|
+
dragging: isDragging,
|
|
26
|
+
beingDragged: isBeingDragged,
|
|
27
|
+
singleItem: isSingleItem
|
|
28
|
+
}),
|
|
29
|
+
[selectedId, id, isDragging, isBeingDragged, isSingleItem]
|
|
30
|
+
);
|
|
30
31
|
return /* @__PURE__ */ jsxs(
|
|
31
32
|
PanelRow,
|
|
32
33
|
{
|
|
33
|
-
ref
|
|
34
|
-
className: tcx(
|
|
34
|
+
ref,
|
|
35
|
+
className: tcx(tv.root(), className),
|
|
35
36
|
onMouseDown: handleOnMouseDown,
|
|
36
37
|
...rest,
|
|
37
38
|
children: [
|
|
38
39
|
/* @__PURE__ */ jsx(
|
|
39
40
|
"div",
|
|
40
41
|
{
|
|
41
|
-
className:
|
|
42
|
+
className: tv.handle(),
|
|
42
43
|
"aria-label": "Drag handle",
|
|
43
44
|
children: /* @__PURE__ */ jsx(GripVerticalSmall, {})
|
|
44
45
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { SortableItem } from '../context';
|
|
3
3
|
interface PanelSortableProps<T extends SortableItem> {
|
|
4
|
-
children: React.ReactNode;
|
|
5
4
|
className?: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
6
|
data: T[];
|
|
7
7
|
onDrop: (position: "top" | "bottom" | null, id: string, newIndex: number) => void;
|
|
8
8
|
onSelectedIdChange: (id: string | null) => void;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import React__default, { forwardRef, useRef,
|
|
2
|
+
import React__default, { forwardRef, useRef, useEffect, useMemo, memo } from "react";
|
|
3
|
+
import { useEventCallback } from "usehooks-ts";
|
|
4
|
+
import { panelSortableContainerTv } from "../tv.js";
|
|
3
5
|
import { usePanelDragDrop } from "../hooks/use-panel-drag-drop.js";
|
|
4
6
|
import { SortablePaneContext, SortableRowDataContext, useSortableRowItem, useSortablePane } from "../context/sortable-context.js";
|
|
5
7
|
import { tcx } from "../../../../shared/utils/tcx/tcx.js";
|
|
6
8
|
import { mergeRefs } from "../../../../shared/utils/merge-refs/merge-refs.js";
|
|
7
9
|
const PanelSortable = forwardRef(function PanelSortable2(props, ref) {
|
|
8
|
-
const { data,
|
|
10
|
+
const { data, className, children, selectedId, onSelectedIdChange, onDrop } = props;
|
|
9
11
|
const containerRef = useRef(null);
|
|
10
|
-
const handleDrop =
|
|
12
|
+
const handleDrop = useEventCallback(
|
|
11
13
|
(dragId, dropId, position) => {
|
|
12
14
|
const items = [...data];
|
|
13
15
|
const dragIndex = items.findIndex((item) => item.id === dragId);
|
|
@@ -16,14 +18,13 @@ const PanelSortable = forwardRef(function PanelSortable2(props, ref) {
|
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
20
|
const isDraggingToSamePosition = dragId === dropId || // 同一个项目
|
|
19
|
-
position === "top" && dragIndex === dropIndex - 1 || //
|
|
21
|
+
position === "top" && dragIndex === dropIndex - 1 || // 拖拽项在目标项上方,放到目标项顶部 = 位置不变
|
|
20
22
|
position === "bottom" && dragIndex === dropIndex + 1;
|
|
21
23
|
if (isDraggingToSamePosition) {
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
24
26
|
onDrop(position, dragId, dropIndex);
|
|
25
|
-
}
|
|
26
|
-
[data, onDrop]
|
|
27
|
+
}
|
|
27
28
|
);
|
|
28
29
|
const {
|
|
29
30
|
containerRef: dragContainerRef,
|
|
@@ -36,18 +37,15 @@ const PanelSortable = forwardRef(function PanelSortable2(props, ref) {
|
|
|
36
37
|
onDrop: handleDrop
|
|
37
38
|
});
|
|
38
39
|
const paneRef = useRef(null);
|
|
39
|
-
const handleMouseDown =
|
|
40
|
-
(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
[handleDragStart, selectedId, onSelectedIdChange]
|
|
50
|
-
);
|
|
40
|
+
const handleMouseDown = useEventCallback((id, e) => {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
if (selectedId !== id) {
|
|
43
|
+
onSelectedIdChange(id);
|
|
44
|
+
}
|
|
45
|
+
const element = document.querySelector(`[data-row-id="${id}"]`);
|
|
46
|
+
if (!element) return;
|
|
47
|
+
handleDragStart({ id, element }, e);
|
|
48
|
+
});
|
|
51
49
|
useEffect(() => {
|
|
52
50
|
const handleDocumentClick = (e) => {
|
|
53
51
|
if (isDragging) return;
|
|
@@ -62,6 +60,7 @@ const PanelSortable = forwardRef(function PanelSortable2(props, ref) {
|
|
|
62
60
|
document.removeEventListener("click", handleDocumentClick);
|
|
63
61
|
};
|
|
64
62
|
}, [isDragging, onSelectedIdChange, containerRef]);
|
|
63
|
+
const tv2 = useMemo(() => panelSortableContainerTv(), []);
|
|
65
64
|
const contextValue = useMemo(
|
|
66
65
|
() => ({
|
|
67
66
|
selectedId,
|
|
@@ -88,12 +87,12 @@ const PanelSortable = forwardRef(function PanelSortable2(props, ref) {
|
|
|
88
87
|
"div",
|
|
89
88
|
{
|
|
90
89
|
ref: mergeRefs(ref, paneRef, dragContainerRef, containerRef),
|
|
91
|
-
className: tcx(
|
|
90
|
+
className: tcx(tv2.container(), className),
|
|
92
91
|
children: /* @__PURE__ */ jsx(SortablePaneContext.Provider, { value: contextValue, children: data.map((item) => /* @__PURE__ */ jsx(
|
|
93
92
|
SortableRowDataContext.Provider,
|
|
94
93
|
{
|
|
95
94
|
value: { item },
|
|
96
|
-
children: /* @__PURE__ */ jsx(RowContainer, { children: React__default.Children.map(
|
|
95
|
+
children: /* @__PURE__ */ jsx(RowContainer, { children: React__default.Children.map(children, (child) => {
|
|
97
96
|
if (React__default.isValidElement(child)) {
|
|
98
97
|
return child;
|
|
99
98
|
}
|
|
@@ -106,6 +105,7 @@ const PanelSortable = forwardRef(function PanelSortable2(props, ref) {
|
|
|
106
105
|
);
|
|
107
106
|
});
|
|
108
107
|
PanelSortable.displayName = "PanelSortable";
|
|
108
|
+
const tv = panelSortableContainerTv();
|
|
109
109
|
const RowContainer = memo(function RowContainer2(props) {
|
|
110
110
|
const { children } = props;
|
|
111
111
|
const item = useSortableRowItem();
|
|
@@ -113,7 +113,7 @@ const RowContainer = memo(function RowContainer2(props) {
|
|
|
113
113
|
return /* @__PURE__ */ jsx(
|
|
114
114
|
"div",
|
|
115
115
|
{
|
|
116
|
-
className:
|
|
116
|
+
className: tv.rowContainer(),
|
|
117
117
|
"data-row-id": item.id,
|
|
118
118
|
"data-row-index": item.indexKey,
|
|
119
119
|
"data-drop-target": "false",
|
|
@@ -9,58 +9,55 @@ const TitleContent = memo(function TitleContent2({
|
|
|
9
9
|
title,
|
|
10
10
|
onClick,
|
|
11
11
|
collapsible,
|
|
12
|
-
|
|
13
|
-
classNames
|
|
12
|
+
titleClassName
|
|
14
13
|
}) {
|
|
14
|
+
const tv = useMemo(() => propertiesPaneTitleTv(), []);
|
|
15
15
|
return collapsible || onClick ? /* @__PURE__ */ jsx(
|
|
16
16
|
"button",
|
|
17
17
|
{
|
|
18
18
|
type: "button",
|
|
19
19
|
onClick,
|
|
20
|
-
className: tcx(
|
|
20
|
+
className: tcx(tv.title(), titleClassName),
|
|
21
21
|
children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: title })
|
|
22
22
|
}
|
|
23
|
-
) : /* @__PURE__ */ jsx("span", { className: tcx(
|
|
23
|
+
) : /* @__PURE__ */ jsx("span", { className: tcx(tv.title(), titleClassName), children: title });
|
|
24
24
|
});
|
|
25
25
|
const PanelTitle = forwardRef(
|
|
26
26
|
function PanelTitle2(props, ref) {
|
|
27
27
|
const { title, children, onHeaderClick, onTitleClick, className, classNames, ...rest } = props;
|
|
28
28
|
const { collapsible, isCollapsed, onCollapsedChange, alwaysShowCollapsible } = usePanelContext();
|
|
29
|
-
const
|
|
29
|
+
const tv = useMemo(() => propertiesPaneTitleTv(), []);
|
|
30
30
|
const handleMouseDown = useEventCallback(() => {
|
|
31
31
|
if (collapsible) {
|
|
32
32
|
onCollapsedChange == null ? void 0 : onCollapsedChange(!isCollapsed);
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
35
|
+
const handleClick = useEventCallback(() => {
|
|
36
|
+
onHeaderClick == null ? void 0 : onHeaderClick();
|
|
37
|
+
});
|
|
38
|
+
const containerClassName = useMemo(() => tcx(tv.container(), className), [tv, className]);
|
|
39
39
|
return /* @__PURE__ */ jsx(
|
|
40
40
|
"div",
|
|
41
41
|
{
|
|
42
42
|
ref,
|
|
43
43
|
className: containerClassName,
|
|
44
44
|
onMouseDown: handleMouseDown,
|
|
45
|
-
onClick:
|
|
46
|
-
onHeaderClick == null ? void 0 : onHeaderClick();
|
|
47
|
-
},
|
|
45
|
+
onClick: handleClick,
|
|
48
46
|
...rest,
|
|
49
|
-
children: /* @__PURE__ */ jsxs("div", { className:
|
|
50
|
-
/* @__PURE__ */ jsxs("div", { className:
|
|
51
|
-
/* @__PURE__ */ jsx("div", { className: tcx(
|
|
52
|
-
/* @__PURE__ */ jsx("div", { className: tcx(
|
|
47
|
+
children: /* @__PURE__ */ jsxs("div", { className: tv.wrapper(), children: [
|
|
48
|
+
/* @__PURE__ */ jsxs("div", { className: tv.content(), children: [
|
|
49
|
+
/* @__PURE__ */ jsx("div", { className: tcx(tv.collapsibleWrapper(), alwaysShowCollapsible && "visible"), children: collapsible && (isCollapsed ? /* @__PURE__ */ jsx(ChevronRightSmall, {}) : /* @__PURE__ */ jsx(ChevronDownSmall, {})) }),
|
|
50
|
+
/* @__PURE__ */ jsx("div", { className: tcx(tv.titleWrapper(), classNames == null ? void 0 : classNames.titleWrapper), children: /* @__PURE__ */ jsx(
|
|
53
51
|
TitleContent,
|
|
54
52
|
{
|
|
55
53
|
title,
|
|
56
54
|
collapsible,
|
|
57
55
|
onClick: onTitleClick,
|
|
58
|
-
|
|
59
|
-
classNames
|
|
56
|
+
titleClassName: classNames == null ? void 0 : classNames.title
|
|
60
57
|
}
|
|
61
58
|
) })
|
|
62
59
|
] }),
|
|
63
|
-
children && /* @__PURE__ */ jsx("div", { className: tcx(
|
|
60
|
+
children && /* @__PURE__ */ jsx("div", { className: tcx(tv.actionWrapper(), classNames == null ? void 0 : classNames.actionWrapper), children })
|
|
64
61
|
] })
|
|
65
62
|
}
|
|
66
63
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface PanelContextType {
|
|
1
|
+
export interface PanelContextType {
|
|
2
2
|
alwaysShowCollapsible?: boolean;
|
|
3
3
|
collapsible?: boolean;
|
|
4
4
|
isCollapsed?: boolean;
|
|
@@ -7,4 +7,3 @@ interface PanelContextType {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const PanelContext: import('react').Context<PanelContextType>;
|
|
9
9
|
export declare const usePanelContext: () => PanelContextType;
|
|
10
|
-
export {};
|
|
@@ -218,15 +218,16 @@ function usePanelDragDrop({
|
|
|
218
218
|
});
|
|
219
219
|
useEffect(() => {
|
|
220
220
|
endDragRef.current = endDrag;
|
|
221
|
+
}, [endDrag]);
|
|
222
|
+
useEffect(() => {
|
|
221
223
|
return () => {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
clearDropIndicators();
|
|
226
|
-
}
|
|
224
|
+
document.removeEventListener("mousemove", handleGlobalMouseMove);
|
|
225
|
+
document.removeEventListener("mouseup", handleGlobalMouseUp);
|
|
226
|
+
clearDropIndicators();
|
|
227
227
|
stopAutoScroll();
|
|
228
|
+
scrollContainerRef.current = null;
|
|
228
229
|
};
|
|
229
|
-
}, [
|
|
230
|
+
}, [handleGlobalMouseMove, handleGlobalMouseUp, clearDropIndicators, stopAutoScroll]);
|
|
230
231
|
const handleDragStart = useEventCallback((item, e) => {
|
|
231
232
|
e.preventDefault();
|
|
232
233
|
e.stopPropagation();
|
|
@@ -12,12 +12,12 @@ interface PanelProps extends Omit<HTMLProps<HTMLDivElement>, "title"> {
|
|
|
12
12
|
showLabels?: boolean;
|
|
13
13
|
triggerRef?: React.RefObject<HTMLDivElement>;
|
|
14
14
|
}
|
|
15
|
-
declare const PanelContent: ({
|
|
15
|
+
declare const PanelContent: import('react').NamedExoticComponent<{
|
|
16
16
|
children: React.ReactNode;
|
|
17
17
|
collapsible?: boolean;
|
|
18
18
|
otherChildren: React.ReactNode[];
|
|
19
19
|
title: React.ReactNode;
|
|
20
|
-
}
|
|
20
|
+
}>;
|
|
21
21
|
interface PanelComponentProps extends React.ForwardRefExoticComponent<PanelProps & React.RefAttributes<HTMLDivElement>> {
|
|
22
22
|
Content: typeof PanelContent;
|
|
23
23
|
Label: typeof PanelLabel;
|