@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
package/dist/select.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { type ListData, type SelectContentProps, type SelectContentState, type SelectEmptyState, type SelectItemIconProps, type SelectItemIconState, type SelectItemProps, type SelectItemState, type SelectItemTextState, type SelectOptions, type SelectSelectAllState, type SelectTriggerProps, type SelectTriggerState, type SelectValueProps, type SelectValueState } from "@ui-sdk/core/select";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { type PartProps } from "./use-primitive.js";
|
|
4
|
+
type Clashing = "value" | "defaultValue" | "onChange" | "onSelect";
|
|
5
|
+
/**
|
|
6
|
+
* The props of `Select`.
|
|
7
|
+
* @stable
|
|
8
|
+
*/
|
|
9
|
+
type SelectProps<T = string, Multiple extends boolean | undefined = false> = SelectOptions<T, Multiple> & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Picks one value, or several, from a list in a popup.
|
|
14
|
+
* `T` is inferred from `value`, `defaultValue`, `items` or `onValueChange`, and
|
|
15
|
+
* `multiple` makes the value a list.
|
|
16
|
+
* @stable
|
|
17
|
+
*/
|
|
18
|
+
declare function Select<T = string, Multiple extends boolean | undefined = false>({ children, container, ...options }: SelectProps<T, Multiple>): React.JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* A visible label for the select. Pressing it focuses the trigger, like a native select's label.
|
|
21
|
+
* @stable
|
|
22
|
+
*/
|
|
23
|
+
declare const SelectLabel: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/select").SelectPrimitive, "label", "div">;
|
|
24
|
+
/**
|
|
25
|
+
* The button that opens the list: a combobox named by the label. Typing on it selects the item that matches.
|
|
26
|
+
* @stable
|
|
27
|
+
*/
|
|
28
|
+
declare function SelectTrigger({ disabled, controller, render, ...props }: Omit<PartProps<"button", SelectTriggerState>, Clashing> & SelectTriggerProps): React.JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* The selected item's label, or the placeholder. Renders it for you when it has no children.
|
|
31
|
+
* @stable
|
|
32
|
+
*/
|
|
33
|
+
declare function SelectValue({ placeholder, maxLabels, getMoreLabel, render, children, ...props }: Omit<PartProps<"span", SelectValueState>, Clashing> & SelectValueProps): React.JSX.Element;
|
|
34
|
+
/**
|
|
35
|
+
* The popup that holds the items, positioned against the trigger.
|
|
36
|
+
* @stable
|
|
37
|
+
*/
|
|
38
|
+
declare function SelectContent({ side, align, sideOffset, alignOffset, collisionPadding, arrowPadding, anchor, alignItemWithTrigger, keepMounted, container, render, children, ...props }: PartProps<"div", SelectContentState> & SelectContentProps): React.JSX.Element | null;
|
|
39
|
+
/**
|
|
40
|
+
* The listbox, when the content holds more than items, like a `SelectInput`. Without children, it renders the select's `items` that match.
|
|
41
|
+
* @stable
|
|
42
|
+
*/
|
|
43
|
+
declare function SelectList({ children, ...props }: PartProps<"div", SelectContentState>): React.JSX.Element | null;
|
|
44
|
+
/**
|
|
45
|
+
* A search field inside `SelectContent` that filters the list while focus stays in it. Put the items in a `SelectList`. Name it with `aria-label`.
|
|
46
|
+
* @stable
|
|
47
|
+
*/
|
|
48
|
+
declare const SelectInput: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/select").SelectPrimitive, "input", "input">;
|
|
49
|
+
/**
|
|
50
|
+
* Shown while no item matches the search. Its message is announced when it appears.
|
|
51
|
+
* @stable
|
|
52
|
+
*/
|
|
53
|
+
declare function SelectEmpty({ children, ...props }: PartProps<"div", SelectEmptyState>): React.JSX.Element | null;
|
|
54
|
+
/**
|
|
55
|
+
* A polite live region for loading and result counts. Its content is yours, usually a function of its state.
|
|
56
|
+
* @stable
|
|
57
|
+
*/
|
|
58
|
+
declare const SelectStatus: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/select").SelectPrimitive, "status", "div">;
|
|
59
|
+
/**
|
|
60
|
+
* An option. Pressing it selects it, or toggles it with `multiple`.
|
|
61
|
+
* @stable
|
|
62
|
+
*/
|
|
63
|
+
declare const SelectItem: <T = string>(props: Omit<PartProps<"div", SelectItemState>, Clashing> & SelectItemProps<T>) => React.ReactNode;
|
|
64
|
+
/**
|
|
65
|
+
* The item's text, with the part the search matched in `<mark>`. Without string content, it shows the item's label.
|
|
66
|
+
* @stable
|
|
67
|
+
*/
|
|
68
|
+
declare function SelectItemText({ children, ...props }: PartProps<"span", SelectItemTextState>): React.JSX.Element | null;
|
|
69
|
+
/**
|
|
70
|
+
* An option that selects every item that matches, with `multiple`: in its group inside a `SelectGroup`, or in the whole list.
|
|
71
|
+
* @stable
|
|
72
|
+
*/
|
|
73
|
+
declare function SelectSelectAll({ render, ...props }: PartProps<"div", SelectSelectAllState>): React.JSX.Element | null;
|
|
74
|
+
/**
|
|
75
|
+
* The check inside a selected item. Rendered while it's selected, or always with `keepMounted`.
|
|
76
|
+
* @stable
|
|
77
|
+
*/
|
|
78
|
+
declare const SelectItemIndicator: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/select").SelectPrimitive, "item-indicator", "span">;
|
|
79
|
+
/**
|
|
80
|
+
* An icon inside an item. `SelectValueIcon` shows the selected item's in the trigger. Screen
|
|
81
|
+
* readers, typeahead and filtering skip it, and `mirror` flips it in right-to-left text.
|
|
82
|
+
* @stable
|
|
83
|
+
*/
|
|
84
|
+
declare const SelectItemIcon: ({ mirror, render, ...props }: PartProps<"span", SelectItemIconState> & SelectItemIconProps) => React.JSX.Element | null;
|
|
85
|
+
/**
|
|
86
|
+
* The selected item's icon, copied from its `SelectItemIcon`, like before the value in the
|
|
87
|
+
* trigger. Rendered while one item is selected and it has an icon.
|
|
88
|
+
* @stable
|
|
89
|
+
*/
|
|
90
|
+
declare function SelectValueIcon(props: Omit<PartProps<"span">, "children">): React.JSX.Element | null;
|
|
91
|
+
/**
|
|
92
|
+
* A group of items, named by its `SelectGroupLabel`, and hidden while none of its items shows.
|
|
93
|
+
* @stable
|
|
94
|
+
*/
|
|
95
|
+
declare const SelectGroup: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/select").SelectPrimitive, "group", "div">;
|
|
96
|
+
/**
|
|
97
|
+
* The group's heading, which names the group.
|
|
98
|
+
* @stable
|
|
99
|
+
*/
|
|
100
|
+
declare const SelectGroupLabel: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/select").SelectPrimitive, "group-label", "div">;
|
|
101
|
+
/**
|
|
102
|
+
* A line between items or groups, hidden from screen readers.
|
|
103
|
+
* @stable
|
|
104
|
+
*/
|
|
105
|
+
declare const SelectSeparator: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/select").SelectPrimitive, "separator", "div">;
|
|
106
|
+
/**
|
|
107
|
+
* A button that selects nothing. Shown while something is selected, or always with `keepMounted`.
|
|
108
|
+
* @stable
|
|
109
|
+
*/
|
|
110
|
+
declare const SelectClear: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/select").SelectPrimitive, "clear", "button">;
|
|
111
|
+
/**
|
|
112
|
+
* An arrow on the popup's edge that points at the trigger.
|
|
113
|
+
* @stable
|
|
114
|
+
*/
|
|
115
|
+
declare const SelectArrow: import("./use-primitive.js").PartComponent<import("@ui-sdk/core/select").SelectPrimitive, "arrow", "div">;
|
|
116
|
+
/**
|
|
117
|
+
* Renders data items. Used by data selects, and available for custom layouts.
|
|
118
|
+
* @stable
|
|
119
|
+
*/
|
|
120
|
+
declare function SelectItems({ items }: {
|
|
121
|
+
items: ListData<unknown>;
|
|
122
|
+
}): React.JSX.Element;
|
|
123
|
+
export { createSelectController } from "@ui-sdk/core/select";
|
|
124
|
+
export type { ListAnnouncement, ListData, ListFilter, ListGroup, ListHighlightDetails, ListItem, ListSeparator, MatchSegment, SelectApi, SelectArrowState, SelectChangeOptions, SelectClearProps, SelectClearState, SelectContentProps, SelectContentState, SelectController, SelectDismissReason, SelectEmptyState, SelectInputState, SelectItemIconProps, SelectItemIconState, SelectItemIndicatorProps, SelectItemIndicatorState, SelectItemProps, SelectItemState, SelectItemTextState, SelectOpenChangeReason, SelectOptions, SelectPrimitive, SelectQueryChangeReason, SelectSelectAllState, SelectStatusState, SelectTriggerProps, SelectTriggerState, SelectValue as SelectValueData, SelectValueChangeReason, SelectValueProps, SelectValueState, } from "@ui-sdk/core/select";
|
|
125
|
+
export { Select, SelectArrow, SelectClear, SelectContent, SelectEmpty, SelectGroup, SelectGroupLabel, SelectInput, SelectItem, SelectItemIcon, SelectItemIndicator, SelectItems, SelectItemText, SelectLabel, SelectList, type SelectProps, SelectSelectAll, SelectSeparator, SelectStatus, SelectTrigger, SelectValue, SelectValueIcon, };
|
package/dist/select.js
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/select.tsx
|
|
3
|
+
import {
|
|
4
|
+
select as selectPrimitive
|
|
5
|
+
} from "@ui-sdk/core/select";
|
|
6
|
+
import {
|
|
7
|
+
selectAllKey,
|
|
8
|
+
selectItemIcons,
|
|
9
|
+
selectSelectAll
|
|
10
|
+
} from "@ui-sdk/core/renderer";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import {
|
|
13
|
+
hasChild,
|
|
14
|
+
learnLabels,
|
|
15
|
+
notLabel,
|
|
16
|
+
Placed,
|
|
17
|
+
usePlaceContent,
|
|
18
|
+
usePlacedContent
|
|
19
|
+
} from "./children.js";
|
|
20
|
+
import { controlRender, useFieldControl } from "./field-context.js";
|
|
21
|
+
import { markSegments, textToMark } from "./list-text.js";
|
|
22
|
+
import {
|
|
23
|
+
Connected,
|
|
24
|
+
renderPopup,
|
|
25
|
+
sheetViewport,
|
|
26
|
+
useControllerEntry,
|
|
27
|
+
useOwnContainer,
|
|
28
|
+
usePopupContainer
|
|
29
|
+
} from "./popup.js";
|
|
30
|
+
import {
|
|
31
|
+
createParts,
|
|
32
|
+
HandleScope,
|
|
33
|
+
renderElement,
|
|
34
|
+
useHandle,
|
|
35
|
+
useAround,
|
|
36
|
+
useNearest,
|
|
37
|
+
usePart,
|
|
38
|
+
usePrimitive
|
|
39
|
+
} from "./use-primitive.js";
|
|
40
|
+
import { FormInputs } from "./form-inputs.js";
|
|
41
|
+
import { ListItems } from "./list-items.js";
|
|
42
|
+
import { createSelectController } from "@ui-sdk/core/select";
|
|
43
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
44
|
+
var parts = createParts(selectPrimitive, {
|
|
45
|
+
label: "div",
|
|
46
|
+
input: "input",
|
|
47
|
+
status: "div",
|
|
48
|
+
item: "div",
|
|
49
|
+
"item-indicator": "span",
|
|
50
|
+
group: "div",
|
|
51
|
+
"group-label": "div",
|
|
52
|
+
separator: "div",
|
|
53
|
+
clear: "button",
|
|
54
|
+
arrow: "div"
|
|
55
|
+
});
|
|
56
|
+
var ContainerContext = React.createContext(void 0);
|
|
57
|
+
function useSelect() {
|
|
58
|
+
return useHandle(selectPrimitive);
|
|
59
|
+
}
|
|
60
|
+
function Select({
|
|
61
|
+
children,
|
|
62
|
+
container,
|
|
63
|
+
...options
|
|
64
|
+
}) {
|
|
65
|
+
const field = useFieldControl();
|
|
66
|
+
const select = usePrimitive(selectPrimitive, {
|
|
67
|
+
...options,
|
|
68
|
+
name: options.name ?? field?.name,
|
|
69
|
+
disabled: options.disabled || field?.disabled
|
|
70
|
+
});
|
|
71
|
+
useControllerEntry(options.controller, select);
|
|
72
|
+
learnLabels(select.api.internal, children, itemDecorations);
|
|
73
|
+
const found = hasChild(children, SelectContent);
|
|
74
|
+
const [placed, place] = usePlacedContent(!!options.items && !found);
|
|
75
|
+
const own = placed || found;
|
|
76
|
+
return /* @__PURE__ */ jsx(HandleScope, { handle: select, children: /* @__PURE__ */ jsxs(ContainerContext.Provider, { value: container, children: [
|
|
77
|
+
/* @__PURE__ */ jsx(Placed, { value: place, children }),
|
|
78
|
+
/* @__PURE__ */ jsx(Placed, { value: null, children: options.items && !own && /* @__PURE__ */ jsx(SelectContent, {}) }),
|
|
79
|
+
/* @__PURE__ */ jsx(FormInputs, { handle: select })
|
|
80
|
+
] }) });
|
|
81
|
+
}
|
|
82
|
+
var SelectLabel = parts.Label;
|
|
83
|
+
function SelectTrigger({
|
|
84
|
+
disabled,
|
|
85
|
+
controller,
|
|
86
|
+
render,
|
|
87
|
+
...props
|
|
88
|
+
}) {
|
|
89
|
+
const unconnected = () => renderElement("button", { type: "button", disabled, ...props }, render, {
|
|
90
|
+
open: false,
|
|
91
|
+
disabled: !!disabled,
|
|
92
|
+
readOnly: false,
|
|
93
|
+
required: false,
|
|
94
|
+
placeholder: true
|
|
95
|
+
});
|
|
96
|
+
return /* @__PURE__ */ jsx(
|
|
97
|
+
Connected,
|
|
98
|
+
{
|
|
99
|
+
primitive: selectPrimitive,
|
|
100
|
+
controller,
|
|
101
|
+
fallback: unconnected,
|
|
102
|
+
children: /* @__PURE__ */ jsx(TriggerPart, { disabled, render, ...props })
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
function TriggerPart({
|
|
107
|
+
disabled,
|
|
108
|
+
render,
|
|
109
|
+
children = /* @__PURE__ */ jsx(SelectValue, {}),
|
|
110
|
+
...props
|
|
111
|
+
}) {
|
|
112
|
+
const field = useFieldControl(props);
|
|
113
|
+
const element = {
|
|
114
|
+
...props,
|
|
115
|
+
children,
|
|
116
|
+
render: controlRender(field, "button", render)
|
|
117
|
+
};
|
|
118
|
+
return usePart(
|
|
119
|
+
selectPrimitive,
|
|
120
|
+
"trigger",
|
|
121
|
+
{ disabled, named: !!field || props["aria-labelledby"] != null },
|
|
122
|
+
element,
|
|
123
|
+
"button"
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
var unselected = {
|
|
127
|
+
value: null,
|
|
128
|
+
label: "",
|
|
129
|
+
labels: [],
|
|
130
|
+
placeholder: true
|
|
131
|
+
};
|
|
132
|
+
function SelectValue({
|
|
133
|
+
placeholder,
|
|
134
|
+
maxLabels,
|
|
135
|
+
getMoreLabel,
|
|
136
|
+
render,
|
|
137
|
+
children,
|
|
138
|
+
...props
|
|
139
|
+
}) {
|
|
140
|
+
if (!useNearest(selectPrimitive)) {
|
|
141
|
+
return renderElement(
|
|
142
|
+
"span",
|
|
143
|
+
{ ...props, children: children ?? placeholder ?? null },
|
|
144
|
+
render,
|
|
145
|
+
unselected
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
return /* @__PURE__ */ jsx(
|
|
149
|
+
ValuePart,
|
|
150
|
+
{
|
|
151
|
+
part: { placeholder, maxLabels, getMoreLabel },
|
|
152
|
+
render,
|
|
153
|
+
props,
|
|
154
|
+
children
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
function ValuePart({
|
|
159
|
+
part,
|
|
160
|
+
render,
|
|
161
|
+
props,
|
|
162
|
+
children
|
|
163
|
+
}) {
|
|
164
|
+
const select = useSelect();
|
|
165
|
+
const { placeholder } = part;
|
|
166
|
+
const content = (state) => typeof children === "function" ? children(state) : children ?? (state.placeholder ? placeholder ?? select.state.placeholder ?? null : state.label);
|
|
167
|
+
return usePart(
|
|
168
|
+
select,
|
|
169
|
+
"value",
|
|
170
|
+
part,
|
|
171
|
+
{ ...props, children: content, render },
|
|
172
|
+
"span"
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
function SelectContent({
|
|
176
|
+
side,
|
|
177
|
+
align,
|
|
178
|
+
sideOffset,
|
|
179
|
+
alignOffset,
|
|
180
|
+
collisionPadding,
|
|
181
|
+
arrowPadding,
|
|
182
|
+
anchor,
|
|
183
|
+
alignItemWithTrigger,
|
|
184
|
+
keepMounted,
|
|
185
|
+
container,
|
|
186
|
+
render,
|
|
187
|
+
children,
|
|
188
|
+
...props
|
|
189
|
+
}) {
|
|
190
|
+
usePlaceContent();
|
|
191
|
+
const select = useSelect();
|
|
192
|
+
const target = usePopupContainer(useOwnContainer(container, ContainerContext));
|
|
193
|
+
const content = {
|
|
194
|
+
side,
|
|
195
|
+
align,
|
|
196
|
+
sideOffset,
|
|
197
|
+
alignOffset,
|
|
198
|
+
collisionPadding,
|
|
199
|
+
arrowPadding,
|
|
200
|
+
anchor,
|
|
201
|
+
alignItemWithTrigger,
|
|
202
|
+
keepMounted
|
|
203
|
+
};
|
|
204
|
+
const body = (state) => typeof children === "function" ? children(state) : children ?? (state.items && select.state.items && /* @__PURE__ */ jsx(SelectItems, { items: state.items }));
|
|
205
|
+
const element = usePart(select, "content", content, {
|
|
206
|
+
...props,
|
|
207
|
+
children: body,
|
|
208
|
+
render: sheetViewport(select, render)
|
|
209
|
+
});
|
|
210
|
+
return element && renderPopup(element, target);
|
|
211
|
+
}
|
|
212
|
+
function SelectList({
|
|
213
|
+
children = listItems,
|
|
214
|
+
...props
|
|
215
|
+
}) {
|
|
216
|
+
return usePart(selectPrimitive, "list", {}, { ...props, children });
|
|
217
|
+
}
|
|
218
|
+
var listItems = (state) => /* @__PURE__ */ jsx(SelectItems, { items: state.items });
|
|
219
|
+
var SelectInput = parts.Input;
|
|
220
|
+
function SelectEmpty({
|
|
221
|
+
children,
|
|
222
|
+
...props
|
|
223
|
+
}) {
|
|
224
|
+
const content = (state) => typeof children === "function" ? children(state) : state.empty ? children : null;
|
|
225
|
+
return usePart(selectPrimitive, "empty", {}, { ...props, children: content });
|
|
226
|
+
}
|
|
227
|
+
var SelectStatus = parts.Status;
|
|
228
|
+
var SelectItem = parts.Item;
|
|
229
|
+
function SelectItemText({
|
|
230
|
+
children,
|
|
231
|
+
...props
|
|
232
|
+
}) {
|
|
233
|
+
const item = useAround(selectPrimitive, "item");
|
|
234
|
+
if (!item) {
|
|
235
|
+
throw new Error("<SelectItemText> must be used inside <SelectItem>.");
|
|
236
|
+
}
|
|
237
|
+
const label = item.label ?? item.value;
|
|
238
|
+
const part = { id: item.value, text: textToMark(children, label) };
|
|
239
|
+
const content = typeof children === "function" ? children : (state) => markSegments(state.segments);
|
|
240
|
+
return usePart(
|
|
241
|
+
selectPrimitive,
|
|
242
|
+
"item-text",
|
|
243
|
+
part,
|
|
244
|
+
{ ...props, children: content },
|
|
245
|
+
"span"
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
function SelectSelectAll({
|
|
249
|
+
render,
|
|
250
|
+
...props
|
|
251
|
+
}) {
|
|
252
|
+
const select = useSelect();
|
|
253
|
+
select.instance.use(selectSelectAll);
|
|
254
|
+
const part = {
|
|
255
|
+
id: selectAllKey(
|
|
256
|
+
useAround(selectPrimitive, "group")?.id
|
|
257
|
+
)
|
|
258
|
+
};
|
|
259
|
+
return usePart(select, "select-all", part, { ...props, render }, "div");
|
|
260
|
+
}
|
|
261
|
+
var SelectItemIndicator = parts.ItemIndicator;
|
|
262
|
+
var SelectItemIcon = /* @__PURE__ */ notLabel(function SelectItemIcon2({
|
|
263
|
+
mirror,
|
|
264
|
+
render,
|
|
265
|
+
...props
|
|
266
|
+
}) {
|
|
267
|
+
const select = useSelect();
|
|
268
|
+
select.instance.use(selectItemIcons);
|
|
269
|
+
const part = {
|
|
270
|
+
id: React.useId(),
|
|
271
|
+
mirror,
|
|
272
|
+
item: useAround(selectPrimitive, "item")?.value
|
|
273
|
+
};
|
|
274
|
+
return usePart(select, "item-icon", part, { ...props, render }, "span");
|
|
275
|
+
});
|
|
276
|
+
var itemDecorations = /* @__PURE__ */ new Set([SelectItemIndicator]);
|
|
277
|
+
function SelectValueIcon(props) {
|
|
278
|
+
return useNearest(selectPrimitive) ? /* @__PURE__ */ jsx(SelectValueIconPart, { ...props }) : null;
|
|
279
|
+
}
|
|
280
|
+
function SelectValueIconPart(props) {
|
|
281
|
+
const select = useSelect();
|
|
282
|
+
select.instance.use(selectItemIcons);
|
|
283
|
+
return usePart(select, "value-icon", {}, props, "span");
|
|
284
|
+
}
|
|
285
|
+
var SelectGroup = parts.Group;
|
|
286
|
+
var SelectGroupLabel = parts.GroupLabel;
|
|
287
|
+
var SelectSeparator = parts.Separator;
|
|
288
|
+
var SelectClear = parts.Clear;
|
|
289
|
+
var SelectArrow = parts.Arrow;
|
|
290
|
+
function SelectItems({ items }) {
|
|
291
|
+
const select = useSelect();
|
|
292
|
+
return /* @__PURE__ */ jsx(
|
|
293
|
+
ListItems,
|
|
294
|
+
{
|
|
295
|
+
items,
|
|
296
|
+
parts: listParts,
|
|
297
|
+
keyOf: select.api.internal.keyOf
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
var listParts = {
|
|
302
|
+
Item: SelectItem,
|
|
303
|
+
Group: SelectGroup,
|
|
304
|
+
GroupLabel: SelectGroupLabel,
|
|
305
|
+
Separator: SelectSeparator
|
|
306
|
+
};
|
|
307
|
+
export {
|
|
308
|
+
Select,
|
|
309
|
+
SelectArrow,
|
|
310
|
+
SelectClear,
|
|
311
|
+
SelectContent,
|
|
312
|
+
SelectEmpty,
|
|
313
|
+
SelectGroup,
|
|
314
|
+
SelectGroupLabel,
|
|
315
|
+
SelectInput,
|
|
316
|
+
SelectItem,
|
|
317
|
+
SelectItemIcon,
|
|
318
|
+
SelectItemIndicator,
|
|
319
|
+
SelectItemText,
|
|
320
|
+
SelectItems,
|
|
321
|
+
SelectLabel,
|
|
322
|
+
SelectList,
|
|
323
|
+
SelectSelectAll,
|
|
324
|
+
SelectSeparator,
|
|
325
|
+
SelectStatus,
|
|
326
|
+
SelectTrigger,
|
|
327
|
+
SelectValue,
|
|
328
|
+
SelectValueIcon,
|
|
329
|
+
createSelectController
|
|
330
|
+
};
|