@ui-sdk/react 0.0.0-stage → 0.1.0-beta.1
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 +202 -0
- package/README.md +10 -2
- package/dist/accordion.d.ts +331 -0
- package/dist/accordion.js +25 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +8 -0
- package/dist/alert-dialog.d.ts +56 -0
- package/dist/alert-dialog.js +45 -0
- package/dist/async-options.d.ts +22 -0
- package/dist/async-options.js +56 -0
- package/dist/autocomplete.d.ts +102 -0
- package/dist/autocomplete.js +195 -0
- package/dist/avatar.d.ts +301 -0
- package/dist/avatar.js +17 -0
- package/dist/button.d.ts +21 -0
- package/dist/button.js +45 -0
- package/dist/calendar-context.d.ts +10 -0
- package/dist/calendar-context.js +9 -0
- package/dist/calendar.d.ts +80 -0
- package/dist/calendar.js +257 -0
- package/dist/carousel.d.ts +52 -0
- package/dist/carousel.js +151 -0
- package/dist/checkbox.d.ts +24 -0
- package/dist/checkbox.js +98 -0
- package/dist/children.d.ts +38 -0
- package/dist/children.js +63 -0
- package/dist/collapsible.d.ts +302 -0
- package/dist/collapsible.js +19 -0
- package/dist/color-picker.d.ts +72 -0
- package/dist/color-picker.js +133 -0
- package/dist/color.d.ts +2 -0
- package/dist/color.js +22 -0
- package/dist/combobox.d.ts +152 -0
- package/dist/combobox.js +338 -0
- package/dist/command.d.ts +88 -0
- package/dist/command.js +233 -0
- package/dist/controller-target.d.ts +3 -0
- package/dist/controller-target.js +59 -0
- package/dist/date-input.d.ts +19 -0
- package/dist/date-input.js +58 -0
- package/dist/date-picker.d.ts +47 -0
- package/dist/date-picker.js +310 -0
- package/dist/date.d.ts +2 -0
- package/dist/date.js +60 -0
- package/dist/dialog-parts.d.ts +23 -0
- package/dist/dialog-parts.js +142 -0
- package/dist/dialog.d.ts +57 -0
- package/dist/dialog.js +32 -0
- package/dist/drawer.d.ts +70 -0
- package/dist/drawer.js +158 -0
- package/dist/editor-context.d.ts +4 -0
- package/dist/editor-context.js +9 -0
- package/dist/field-context.d.ts +47 -0
- package/dist/field-context.js +87 -0
- package/dist/field.d.ts +49 -0
- package/dist/field.js +169 -0
- package/dist/file-input.d.ts +46 -0
- package/dist/file-input.js +170 -0
- package/dist/form-inputs.d.ts +5 -0
- package/dist/form-inputs.js +22 -0
- package/dist/gesture.d.ts +1 -0
- package/dist/gesture.js +16 -0
- package/dist/history.d.ts +2 -0
- package/dist/history.js +12 -0
- package/dist/hover-card.d.ts +33 -0
- package/dist/hover-card.js +84 -0
- package/dist/image-cropper.d.ts +333 -0
- package/dist/image-cropper.js +37 -0
- package/dist/image.d.ts +2 -0
- package/dist/image.js +6 -0
- package/dist/input.d.ts +22 -0
- package/dist/input.js +51 -0
- package/dist/label.d.ts +294 -0
- package/dist/label.js +9 -0
- package/dist/list-items.d.ts +15 -0
- package/dist/list-items.js +39 -0
- package/dist/list-text.d.ts +4 -0
- package/dist/list-text.js +15 -0
- package/dist/listbox.d.ts +56 -0
- package/dist/listbox.js +122 -0
- package/dist/menu.d.ts +116 -0
- package/dist/menu.js +426 -0
- package/dist/menubar-context.d.ts +4 -0
- package/dist/menubar-context.js +7 -0
- package/dist/menubar.d.ts +11 -0
- package/dist/menubar.js +32 -0
- package/dist/meter.d.ts +312 -0
- package/dist/meter.js +30 -0
- package/dist/navigation-menu.d.ts +61 -0
- package/dist/navigation-menu.js +169 -0
- package/dist/number-input.d.ts +44 -0
- package/dist/number-input.js +185 -0
- package/dist/number.d.ts +2 -0
- package/dist/number.js +40 -0
- package/dist/observe.d.ts +2 -0
- package/dist/observe.js +8 -0
- package/dist/otp-input.d.ts +29 -0
- package/dist/otp-input.js +94 -0
- package/dist/overlays.d.ts +26 -0
- package/dist/overlays.js +82 -0
- package/dist/pagination.d.ts +336 -0
- package/dist/pagination.js +71 -0
- package/dist/password-input.d.ts +23 -0
- package/dist/password-input.js +65 -0
- package/dist/popover.d.ts +54 -0
- package/dist/popover.js +151 -0
- package/dist/popup.d.ts +41 -0
- package/dist/popup.js +180 -0
- package/dist/preferences.d.ts +35 -0
- package/dist/preferences.js +93 -0
- package/dist/primitive.d.ts +2 -0
- package/dist/primitive.js +14 -0
- package/dist/progress.d.ts +312 -0
- package/dist/progress.js +30 -0
- package/dist/radio.d.ts +22 -0
- package/dist/radio.js +86 -0
- package/dist/rating.d.ts +20 -0
- package/dist/rating.js +94 -0
- package/dist/render-element.d.ts +35 -0
- package/dist/render-element.js +103 -0
- package/dist/resizable.d.ts +302 -0
- package/dist/resizable.js +23 -0
- package/dist/scroll-area.d.ts +324 -0
- package/dist/scroll-area.js +49 -0
- package/dist/segmented-control.d.ts +24 -0
- package/dist/segmented-control.js +78 -0
- package/dist/segmented-input.d.ts +15 -0
- package/dist/segmented-input.js +48 -0
- package/dist/select.d.ts +125 -0
- package/dist/select.js +330 -0
- package/dist/separator.d.ts +290 -0
- package/dist/separator.js +9 -0
- package/dist/shortcuts.d.ts +32 -0
- package/dist/shortcuts.js +61 -0
- package/dist/slider.d.ts +38 -0
- package/dist/slider.js +163 -0
- package/dist/switch.d.ts +15 -0
- package/dist/switch.js +39 -0
- package/dist/tabs.d.ts +331 -0
- package/dist/tabs.js +28 -0
- package/dist/text-control.d.ts +22 -0
- package/dist/text-control.js +24 -0
- package/dist/text-match.d.ts +2 -0
- package/dist/text-match.js +8 -0
- package/dist/textarea.d.ts +10 -0
- package/dist/textarea.js +48 -0
- package/dist/time-input.d.ts +19 -0
- package/dist/time-input.js +63 -0
- package/dist/timeline.d.ts +327 -0
- package/dist/timeline.js +31 -0
- package/dist/toast-parts.d.ts +63 -0
- package/dist/toast-parts.js +144 -0
- package/dist/toast.d.ts +2 -0
- package/dist/toast.js +22 -0
- package/dist/toggle.d.ts +23 -0
- package/dist/toggle.js +76 -0
- package/dist/token-input.d.ts +35 -0
- package/dist/token-input.js +100 -0
- package/dist/toolbar-context.d.ts +6 -0
- package/dist/toolbar-context.js +16 -0
- package/dist/toolbar.d.ts +38 -0
- package/dist/toolbar.js +63 -0
- package/dist/tooltip.d.ts +39 -0
- package/dist/tooltip.js +108 -0
- package/dist/tree.d.ts +51 -0
- package/dist/tree.js +150 -0
- package/dist/trigger-menu.d.ts +83 -0
- package/dist/trigger-menu.js +167 -0
- package/dist/use-primitive.d.ts +178 -0
- package/dist/use-primitive.js +674 -0
- package/dist/waterfall.d.ts +80 -0
- package/dist/waterfall.js +108 -0
- package/docs/README.md +89 -0
- package/docs/agents.md +1523 -0
- package/docs/components/accordion.md +1391 -0
- package/docs/components/alert-dialog.md +850 -0
- package/docs/components/autocomplete.md +1963 -0
- package/docs/components/avatar.md +252 -0
- package/docs/components/button.md +444 -0
- package/docs/components/calendar.md +1687 -0
- package/docs/components/carousel.md +1244 -0
- package/docs/components/checkbox.md +1069 -0
- package/docs/components/collapsible.md +567 -0
- package/docs/components/color-picker.md +736 -0
- package/docs/components/combobox.md +3647 -0
- package/docs/components/command.md +1573 -0
- package/docs/components/date-input.md +608 -0
- package/docs/components/date-picker.md +1266 -0
- package/docs/components/dialog.md +1469 -0
- package/docs/components/drawer.md +1197 -0
- package/docs/components/field.md +549 -0
- package/docs/components/file-input.md +609 -0
- package/docs/components/hover-card.md +514 -0
- package/docs/components/image-cropper.md +579 -0
- package/docs/components/input.md +301 -0
- package/docs/components/label.md +217 -0
- package/docs/components/listbox.md +1130 -0
- package/docs/components/menu.md +1286 -0
- package/docs/components/menubar.md +455 -0
- package/docs/components/meter.md +304 -0
- package/docs/components/navigation-menu.md +1581 -0
- package/docs/components/number-input.md +1086 -0
- package/docs/components/otp-input.md +565 -0
- package/docs/components/pagination.md +648 -0
- package/docs/components/password-input.md +737 -0
- package/docs/components/popover.md +1552 -0
- package/docs/components/preferences.md +220 -0
- package/docs/components/progress.md +443 -0
- package/docs/components/radio.md +846 -0
- package/docs/components/rating.md +458 -0
- package/docs/components/resizable.md +982 -0
- package/docs/components/scroll-area.md +980 -0
- package/docs/components/segmented-control.md +465 -0
- package/docs/components/select.md +2133 -0
- package/docs/components/separator.md +243 -0
- package/docs/components/slider.md +1169 -0
- package/docs/components/switch.md +613 -0
- package/docs/components/tabs.md +1014 -0
- package/docs/components/textarea.md +318 -0
- package/docs/components/time-input.md +231 -0
- package/docs/components/timeline.md +677 -0
- package/docs/components/toast.md +1395 -0
- package/docs/components/toggle.md +541 -0
- package/docs/components/token-input.md +1007 -0
- package/docs/components/toolbar.md +787 -0
- package/docs/components/tooltip.md +884 -0
- package/docs/components/tree.md +1346 -0
- package/docs/components/trigger-menu.md +1257 -0
- package/docs/components/waterfall.md +754 -0
- package/docs/controllers.md +89 -0
- package/docs/core.md +8027 -0
- package/docs/custom-parts.md +120 -0
- package/docs/first-component.md +83 -0
- package/docs/forms.md +148 -0
- package/docs/hooks/async-options.md +366 -0
- package/docs/hooks/shortcuts.md +221 -0
- package/docs/installation.md +45 -0
- package/docs/introduction.md +32 -0
- package/docs/lists-and-menus.md +170 -0
- package/docs/llms.txt +1844 -0
- package/docs/parts-and-composition.md +93 -0
- package/docs/popups.md +117 -0
- package/docs/rendering.md +121 -0
- package/docs/server-rendering.md +253 -0
- package/docs/state-and-events.md +105 -0
- package/docs/styling-and-animation.md +176 -0
- package/package.json +333 -3
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/file-input.tsx
|
|
3
|
+
import {
|
|
4
|
+
fileInput
|
|
5
|
+
} from "@ui-sdk/core/file-input";
|
|
6
|
+
import { fileKey } from "@ui-sdk/core/renderer";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { useControllerEntry } from "./controller-target.js";
|
|
9
|
+
import { controlRender, useFieldControl } from "./field-context.js";
|
|
10
|
+
import { Connected } from "./popup.js";
|
|
11
|
+
import {
|
|
12
|
+
createParts,
|
|
13
|
+
renderElement,
|
|
14
|
+
usePart,
|
|
15
|
+
usePrimitive
|
|
16
|
+
} from "./use-primitive.js";
|
|
17
|
+
import {
|
|
18
|
+
createFileInputController,
|
|
19
|
+
formatFileSize,
|
|
20
|
+
relativePath
|
|
21
|
+
} from "@ui-sdk/core/file-input";
|
|
22
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
var parts = createParts(fileInput, { trigger: "button", dropzone: "div" });
|
|
24
|
+
var FileContext = React.createContext(null);
|
|
25
|
+
function useItemFile(part, own) {
|
|
26
|
+
const listed = React.useContext(FileContext);
|
|
27
|
+
const file = own ?? listed;
|
|
28
|
+
if (!file) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`${part} must be used inside <FileInputList>, or be given a file.`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return file;
|
|
34
|
+
}
|
|
35
|
+
function FileInput({
|
|
36
|
+
value,
|
|
37
|
+
defaultValue,
|
|
38
|
+
onValueChange,
|
|
39
|
+
onReject,
|
|
40
|
+
accept,
|
|
41
|
+
multiple,
|
|
42
|
+
directory,
|
|
43
|
+
capture,
|
|
44
|
+
maxFiles,
|
|
45
|
+
maxSize,
|
|
46
|
+
minSize,
|
|
47
|
+
validate,
|
|
48
|
+
name,
|
|
49
|
+
form,
|
|
50
|
+
required,
|
|
51
|
+
disabled,
|
|
52
|
+
announcement,
|
|
53
|
+
controller,
|
|
54
|
+
debug,
|
|
55
|
+
children,
|
|
56
|
+
...props
|
|
57
|
+
}) {
|
|
58
|
+
const field = useFieldControl();
|
|
59
|
+
const handle = usePrimitive(fileInput, {
|
|
60
|
+
value,
|
|
61
|
+
defaultValue,
|
|
62
|
+
onValueChange,
|
|
63
|
+
onReject,
|
|
64
|
+
accept,
|
|
65
|
+
multiple,
|
|
66
|
+
directory,
|
|
67
|
+
capture,
|
|
68
|
+
maxFiles,
|
|
69
|
+
maxSize,
|
|
70
|
+
minSize,
|
|
71
|
+
validate,
|
|
72
|
+
name: name ?? field?.name,
|
|
73
|
+
form,
|
|
74
|
+
required,
|
|
75
|
+
disabled: disabled || field?.disabled,
|
|
76
|
+
announcement,
|
|
77
|
+
controller,
|
|
78
|
+
debug
|
|
79
|
+
});
|
|
80
|
+
useControllerEntry(controller, handle);
|
|
81
|
+
const content = (current) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
82
|
+
typeof children === "function" ? children(current) : children,
|
|
83
|
+
/* @__PURE__ */ jsx(HiddenInput, {})
|
|
84
|
+
] });
|
|
85
|
+
return usePart(handle, "root", {}, { ...props, children: content });
|
|
86
|
+
}
|
|
87
|
+
function HiddenInput() {
|
|
88
|
+
return usePart(fileInput, "input", {}, {}, "input");
|
|
89
|
+
}
|
|
90
|
+
function FileInputTrigger({
|
|
91
|
+
controller,
|
|
92
|
+
render,
|
|
93
|
+
...props
|
|
94
|
+
}) {
|
|
95
|
+
const unconnected = () => renderElement(
|
|
96
|
+
"button",
|
|
97
|
+
{ type: "button", ...props },
|
|
98
|
+
render,
|
|
99
|
+
unconnectedState
|
|
100
|
+
);
|
|
101
|
+
return /* @__PURE__ */ jsx(
|
|
102
|
+
Connected,
|
|
103
|
+
{
|
|
104
|
+
primitive: fileInput,
|
|
105
|
+
controller,
|
|
106
|
+
fallback: unconnected,
|
|
107
|
+
children: /* @__PURE__ */ jsx(TriggerPart, { ...props, render })
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
var unconnectedState = {
|
|
112
|
+
value: [],
|
|
113
|
+
disabled: false,
|
|
114
|
+
required: false,
|
|
115
|
+
dragging: false
|
|
116
|
+
};
|
|
117
|
+
function TriggerPart({ render, ...props }) {
|
|
118
|
+
return /* @__PURE__ */ jsx(
|
|
119
|
+
parts.Trigger,
|
|
120
|
+
{
|
|
121
|
+
...props,
|
|
122
|
+
render: controlRender(useFieldControl(), "button", render)
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
var FileInputDropzone = parts.Dropzone;
|
|
127
|
+
function FileInputList({
|
|
128
|
+
children,
|
|
129
|
+
...props
|
|
130
|
+
}) {
|
|
131
|
+
const items = (state) => state.value.map((file) => /* @__PURE__ */ jsx(FileContext.Provider, { value: file, children }, fileKey(file)));
|
|
132
|
+
return usePart(fileInput, "list", {}, { ...props, children: items });
|
|
133
|
+
}
|
|
134
|
+
function FileInputItem({
|
|
135
|
+
file: own,
|
|
136
|
+
...props
|
|
137
|
+
}) {
|
|
138
|
+
const file = useItemFile("FileInputItem", own);
|
|
139
|
+
const element = usePart(
|
|
140
|
+
fileInput,
|
|
141
|
+
"item",
|
|
142
|
+
{ file, value: fileKey(file) },
|
|
143
|
+
props
|
|
144
|
+
);
|
|
145
|
+
return /* @__PURE__ */ jsx(FileContext.Provider, { value: file, children: element });
|
|
146
|
+
}
|
|
147
|
+
function FileInputItemRemove({
|
|
148
|
+
file: own,
|
|
149
|
+
...props
|
|
150
|
+
}) {
|
|
151
|
+
const file = useItemFile("FileInputItemRemove", own);
|
|
152
|
+
return usePart(
|
|
153
|
+
fileInput,
|
|
154
|
+
"item-remove",
|
|
155
|
+
{ file, value: fileKey(file) },
|
|
156
|
+
props,
|
|
157
|
+
"button"
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
FileInput,
|
|
162
|
+
FileInputDropzone,
|
|
163
|
+
FileInputItem,
|
|
164
|
+
FileInputItemRemove,
|
|
165
|
+
FileInputList,
|
|
166
|
+
FileInputTrigger,
|
|
167
|
+
createFileInputController,
|
|
168
|
+
formatFileSize,
|
|
169
|
+
relativePath
|
|
170
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/form-inputs.tsx
|
|
3
|
+
import { readIn, slotIn, usePart } from "./use-primitive.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
function FormInputs({ handle }) {
|
|
6
|
+
const inputs = ({ value, ...input }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7
|
+
/* @__PURE__ */ jsx("input", { ...input, defaultValue: value }),
|
|
8
|
+
handle.state.multiple && readIn(handle, () => handle.api.internal.serialized()).map(
|
|
9
|
+
(key) => {
|
|
10
|
+
const { value: value2, ...hidden } = slotIn(handle, "value-input", {
|
|
11
|
+
id: key,
|
|
12
|
+
value: key
|
|
13
|
+
});
|
|
14
|
+
return /* @__PURE__ */ jsx("input", { ...hidden, defaultValue: value2 }, key);
|
|
15
|
+
}
|
|
16
|
+
)
|
|
17
|
+
] });
|
|
18
|
+
return usePart(handle, "form-input", {}, { render: inputs }, "input");
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
FormInputs
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createVelocityTracker, projectDistance, rubberBand, sectorOf, solveSpring, } from "@ui-sdk/core/gesture";
|
package/dist/gesture.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/gesture.ts
|
|
3
|
+
import {
|
|
4
|
+
createVelocityTracker,
|
|
5
|
+
projectDistance,
|
|
6
|
+
rubberBand,
|
|
7
|
+
sectorOf,
|
|
8
|
+
solveSpring
|
|
9
|
+
} from "@ui-sdk/core/gesture";
|
|
10
|
+
export {
|
|
11
|
+
createVelocityTracker,
|
|
12
|
+
projectDistance,
|
|
13
|
+
rubberBand,
|
|
14
|
+
sectorOf,
|
|
15
|
+
solveSpring
|
|
16
|
+
};
|
package/dist/history.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type HoverCardContentProps, type HoverCardContentState, type HoverCardOptions, type HoverCardTriggerProps, type HoverCardTriggerState } from "@ui-sdk/core/hover-card";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { type PartProps } from "./use-primitive.js";
|
|
4
|
+
/**
|
|
5
|
+
* The props of `HoverCard`.
|
|
6
|
+
* @stable
|
|
7
|
+
*/
|
|
8
|
+
type HoverCardProps = HoverCardOptions & {
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A preview of what a link points to, shown when the pointer rests on the link or keyboard focus stays on it.
|
|
13
|
+
* @stable
|
|
14
|
+
*/
|
|
15
|
+
declare function HoverCard({ children, container, ...options }: HoverCardProps): React.JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* A link by default: pressing it follows the link, and hover or focus opens the card.
|
|
18
|
+
* @stable
|
|
19
|
+
*/
|
|
20
|
+
declare function HoverCardTrigger({ controller, ...props }: PartProps<"a", HoverCardTriggerState> & HoverCardTriggerProps): React.JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* The card itself, positioned against its trigger.
|
|
23
|
+
* @stable
|
|
24
|
+
*/
|
|
25
|
+
declare function HoverCardContent<Payload = unknown>({ side, align, sideOffset, alignOffset, collisionPadding, arrowPadding, anchor, keepMounted, container, ...props }: PartProps<"div", HoverCardContentState<Payload>> & HoverCardContentProps): React.JSX.Element | null;
|
|
26
|
+
/**
|
|
27
|
+
* An arrow on the card's edge that points at its trigger.
|
|
28
|
+
* @stable
|
|
29
|
+
*/
|
|
30
|
+
declare const HoverCardArrow: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/hover-card").HoverCardPrimitive, "arrow", "div">;
|
|
31
|
+
export { createHoverCardController } from "@ui-sdk/core/hover-card";
|
|
32
|
+
export type { HoverCardApi, HoverCardArrowState, HoverCardContentProps, HoverCardContentState, HoverCardController, HoverCardOpenChangeReason, HoverCardOptions, HoverCardPayloadChangeReason, HoverCardPrimitive, HoverCardTriggerProps, HoverCardTriggerState, } from "@ui-sdk/core/hover-card";
|
|
33
|
+
export { HoverCard, HoverCardArrow, HoverCardContent, type HoverCardProps, HoverCardTrigger, };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/hover-card.tsx
|
|
3
|
+
import {
|
|
4
|
+
hoverCard
|
|
5
|
+
} from "@ui-sdk/core/hover-card";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import {
|
|
8
|
+
Connected,
|
|
9
|
+
renderPopup,
|
|
10
|
+
useControllerEntry,
|
|
11
|
+
useOwnContainer,
|
|
12
|
+
usePopupContainer
|
|
13
|
+
} from "./popup.js";
|
|
14
|
+
import {
|
|
15
|
+
createParts,
|
|
16
|
+
HandleScope,
|
|
17
|
+
renderElement,
|
|
18
|
+
usePart,
|
|
19
|
+
usePrimitive
|
|
20
|
+
} from "./use-primitive.js";
|
|
21
|
+
import { createHoverCardController } from "@ui-sdk/core/hover-card";
|
|
22
|
+
import { jsx } from "react/jsx-runtime";
|
|
23
|
+
var parts = createParts(hoverCard, { trigger: "a", arrow: "div" });
|
|
24
|
+
var ContainerContext = React.createContext(void 0);
|
|
25
|
+
function HoverCard({ children, container, ...options }) {
|
|
26
|
+
const handle = usePrimitive(hoverCard, options);
|
|
27
|
+
useControllerEntry(options.controller, handle);
|
|
28
|
+
return /* @__PURE__ */ jsx(HandleScope, { handle, children: /* @__PURE__ */ jsx(ContainerContext.Provider, { value: container, children }) });
|
|
29
|
+
}
|
|
30
|
+
function HoverCardTrigger({
|
|
31
|
+
controller,
|
|
32
|
+
...props
|
|
33
|
+
}) {
|
|
34
|
+
const { payload: _, render, ...rest } = props;
|
|
35
|
+
const unconnected = () => renderElement("a", rest, render, { open: false });
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
Connected,
|
|
38
|
+
{
|
|
39
|
+
primitive: hoverCard,
|
|
40
|
+
controller,
|
|
41
|
+
fallback: unconnected,
|
|
42
|
+
children: /* @__PURE__ */ jsx(parts.Trigger, { ...props })
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
function HoverCardContent({
|
|
47
|
+
side,
|
|
48
|
+
align,
|
|
49
|
+
sideOffset,
|
|
50
|
+
alignOffset,
|
|
51
|
+
collisionPadding,
|
|
52
|
+
arrowPadding,
|
|
53
|
+
anchor,
|
|
54
|
+
keepMounted,
|
|
55
|
+
container,
|
|
56
|
+
...props
|
|
57
|
+
}) {
|
|
58
|
+
const target = usePopupContainer(useOwnContainer(container, ContainerContext));
|
|
59
|
+
const content = {
|
|
60
|
+
side,
|
|
61
|
+
align,
|
|
62
|
+
sideOffset,
|
|
63
|
+
alignOffset,
|
|
64
|
+
collisionPadding,
|
|
65
|
+
arrowPadding,
|
|
66
|
+
anchor,
|
|
67
|
+
keepMounted
|
|
68
|
+
};
|
|
69
|
+
const element = usePart(
|
|
70
|
+
hoverCard,
|
|
71
|
+
"content",
|
|
72
|
+
content,
|
|
73
|
+
props
|
|
74
|
+
);
|
|
75
|
+
return element && renderPopup(element, target);
|
|
76
|
+
}
|
|
77
|
+
var HoverCardArrow = parts.Arrow;
|
|
78
|
+
export {
|
|
79
|
+
HoverCard,
|
|
80
|
+
HoverCardArrow,
|
|
81
|
+
HoverCardContent,
|
|
82
|
+
HoverCardTrigger,
|
|
83
|
+
createHoverCardController
|
|
84
|
+
};
|