@ngrok/mantle 0.79.3 → 0.80.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/accordion.d.ts +169 -12
- package/dist/accordion.js +1 -1
- package/dist/agent.json +1 -1
- package/dist/alert-dialog.d.ts +496 -30
- package/dist/alert-dialog.js +1 -1
- package/dist/alert.d.ts +129 -9
- package/dist/alert.js +1 -1
- package/dist/anchor-_2meGDfj.js +1 -0
- package/dist/anchor.d.ts +2 -2
- package/dist/anchor.js +1 -1
- package/dist/as-child-D23mGo4f.d.ts +49 -0
- package/dist/badge.d.ts +44 -5
- package/dist/badge.js +1 -1
- package/dist/breadcrumb.d.ts +214 -14
- package/dist/breadcrumb.js +1 -1
- package/dist/button-5WsvzIQ6.js +1 -0
- package/dist/{button-DcXOWUYo.d.ts → button-BPMwa2jN.d.ts} +3 -3
- package/dist/button-D9n09xUg.js +1 -0
- package/dist/button.d.ts +3 -3
- package/dist/button.js +1 -1
- package/dist/calendar.d.ts +0 -3
- package/dist/calendar.js +1 -1
- package/dist/card.d.ts +146 -9
- package/dist/card.js +1 -1
- package/dist/centered-layout.d.ts +224 -8
- package/dist/centered-layout.js +1 -1
- package/dist/checkbox-Cq17y0-R.js +1 -0
- package/dist/checkbox.d.ts +12 -10
- package/dist/checkbox.js +1 -1
- package/dist/choice-Cc8dA5r8.js +1 -0
- package/dist/choice-Ct0KK8jw.d.ts +269 -0
- package/dist/choice.d.ts +1 -252
- package/dist/choice.js +1 -1
- package/dist/code-block.d.ts +270 -50
- package/dist/code-block.js +6 -6
- package/dist/code.d.ts +3 -2
- package/dist/code.js +1 -1
- package/dist/combobox.d.ts +190 -11
- package/dist/combobox.js +1 -1
- package/dist/command.d.ts +285 -81
- package/dist/command.js +1 -1
- package/dist/compose-refs-BdBMM9ga.js +1 -0
- package/dist/data-table.d.ts +33 -5
- package/dist/data-table.js +1 -1
- package/dist/description-list.d.ts +79 -6
- package/dist/description-list.js +1 -1
- package/dist/dialog-CQ2C6vkE.js +1 -0
- package/dist/dialog.d.ts +239 -18
- package/dist/dialog.js +1 -1
- package/dist/dropdown-menu-CSCDdA3K.js +1 -0
- package/dist/{dropdown-menu-DP_Ne9Mr.d.ts → dropdown-menu-CoyozLzy.d.ts} +170 -29
- package/dist/dropdown-menu.d.ts +2 -2
- package/dist/dropdown-menu.js +1 -1
- package/dist/empty.d.ts +1 -1
- package/dist/empty.js +1 -1
- package/dist/field.d.ts +596 -45
- package/dist/field.js +1 -1
- package/dist/flag.d.ts +0 -3
- package/dist/flag.js +1 -1
- package/dist/hooks.d.ts +3 -4
- package/dist/hooks.js +1 -1
- package/dist/hover-card.d.ts +54 -4
- package/dist/hover-card.js +1 -1
- package/dist/{icon-Cevjo93X.d.ts → icon-BDqpcZ-n.d.ts} +1 -1
- package/dist/icon-CGgMKpJg.js +1 -0
- package/dist/{icon-button-BvQvT790.d.ts → icon-button-C1AfGnQx.d.ts} +6 -60
- package/dist/icon-button-DiOhreJD.js +1 -0
- package/dist/icon.d.ts +2 -2
- package/dist/icon.js +1 -1
- package/dist/icons.d.ts +5 -13
- package/dist/icons.js +1 -1
- package/dist/{in-view-nkSOdED2.d.ts → in-view-DDEGUKDR.d.ts} +17 -9
- package/dist/index-B8mIWKIU.d.ts +211 -0
- package/dist/{index-Rv8RL7xy.d.ts → index-BtwKJTLq.d.ts} +1 -1
- package/dist/{index-BSAizFod.d.ts → index-C2jj8U4a.d.ts} +5 -5
- package/dist/index-CdPXa9h1.d.ts +1 -0
- package/dist/{index-D47aqlpz.d.ts → index-DA4ig3gj.d.ts} +1 -1
- package/dist/input-CVyAVbim.js +1 -0
- package/dist/{types-C19IR7jf.d.ts → input-DV9M6K4v.d.ts} +42 -2
- package/dist/input.d.ts +4 -55
- package/dist/input.js +1 -1
- package/dist/{label-v2-bv98k.d.ts → label-C6YH9skg.d.ts} +8 -6
- package/dist/label-D-D11mlp.js +1 -0
- package/dist/label.d.ts +1 -1
- package/dist/label.js +1 -1
- package/dist/list.d.ts +150 -6
- package/dist/list.js +1 -1
- package/dist/llms.txt +1 -1
- package/dist/main.d.ts +20 -4
- package/dist/main.js +1 -1
- package/dist/media-object.d.ts +27 -4
- package/dist/media-object.js +1 -1
- package/dist/multi-select.d.ts +312 -15
- package/dist/multi-select.js +1 -1
- package/dist/otp-input.d.ts +129 -5
- package/dist/otp-input.js +1 -1
- package/dist/pagination.d.ts +70 -6
- package/dist/pagination.js +1 -1
- package/dist/popover-CBMADtjV.js +1 -0
- package/dist/popover.d.ts +1 -181
- package/dist/popover.js +1 -1
- package/dist/primitive-CJRIlrLz.d.ts +31 -0
- package/dist/primitive-DCPHJsRs.js +1 -0
- package/dist/progress.js +1 -1
- package/dist/qr-code.d.ts +113 -5
- package/dist/qr-code.js +1 -1
- package/dist/radio-group.d.ts +128 -23
- package/dist/radio-group.js +1 -1
- package/dist/sandboxed-on-click.d.ts +2 -2
- package/dist/sandboxed-on-click.js +1 -1
- package/dist/select-SR_9-bxA.js +1 -0
- package/dist/select-idm1jy7y.d.ts +600 -0
- package/dist/select.d.ts +1 -1
- package/dist/select.js +1 -1
- package/dist/selectable-list.d.ts +252 -298
- package/dist/selectable-list.js +1 -1
- package/dist/separator-B5UmkVRL.d.ts +75 -0
- package/dist/separator-bpE_kooz.js +1 -0
- package/dist/separator.d.ts +1 -52
- package/dist/separator.js +1 -1
- package/dist/sheet.d.ts +295 -21
- package/dist/sheet.js +1 -1
- package/dist/skeleton-CsbUHbBA.js +1 -0
- package/dist/skeleton.d.ts +4 -7
- package/dist/skeleton.js +1 -1
- package/dist/skip-to-main-link.d.ts +24 -4
- package/dist/skip-to-main-link.js +1 -1
- package/dist/slot-CDk0Bb9z.js +1 -0
- package/dist/slot.d.ts +1 -1
- package/dist/slot.js +1 -1
- package/dist/{sort-BPX2Fk9t.js → sort-B_DDQcVD.js} +1 -1
- package/dist/split-button.d.ts +28 -13
- package/dist/split-button.js +1 -1
- package/dist/{svg-only-BFeFS1aa.d.ts → svg-only-CdI_v82i.d.ts} +1 -1
- package/dist/svg-only-d-nMCfAI.js +1 -0
- package/dist/switch.d.ts +9 -6
- package/dist/switch.js +1 -1
- package/dist/table-DUSvU_Jw.d.ts +875 -0
- package/dist/table-GDkapNFi.js +1 -0
- package/dist/table.d.ts +1 -1
- package/dist/table.js +1 -1
- package/dist/tabs.d.ts +135 -21
- package/dist/tabs.js +1 -1
- package/dist/text-area.d.ts +1 -1
- package/dist/text-area.js +1 -1
- package/dist/theme-provider-BftkIiZn.js +1 -0
- package/dist/theme-switcher.d.ts +110 -29
- package/dist/theme-switcher.js +1 -1
- package/dist/theme-wVnzzx2F.js +1 -0
- package/dist/theme.d.ts +53 -14
- package/dist/theme.js +1 -1
- package/dist/toast-DKgMRv4F.js +1 -0
- package/dist/toast.d.ts +98 -10
- package/dist/toast.js +1 -1
- package/dist/tooltip.d.ts +28 -1
- package/dist/tooltip.js +1 -1
- package/dist/{traffic-policy-file-0g5RXFqu.js → traffic-policy-file-CF1lbWtp.js} +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/dist/virtual-UrzmaSQm.js +1 -0
- package/dist/well.d.ts +3 -3
- package/dist/well.js +1 -1
- package/package.json +3 -3
- package/dist/anchor-C_tjSVy6.js +0 -1
- package/dist/as-child-CYEVu1WY.d.ts +0 -23
- package/dist/button-5t6-JS_I.js +0 -1
- package/dist/button-ClC60Nzg.js +0 -1
- package/dist/checkbox-DJ2xl7Rc.js +0 -1
- package/dist/choice-DOdyNzFC.js +0 -1
- package/dist/compose-refs-Cjf2gfB8.js +0 -1
- package/dist/dialog-vxLIvB8M.js +0 -1
- package/dist/dropdown-menu-Bt1aKF1g.js +0 -1
- package/dist/icon-CDtYjF_H.js +0 -1
- package/dist/icon-button-DV2-GZHf.js +0 -1
- package/dist/index-g2rfwNCH.d.ts +0 -1
- package/dist/input-Ct1YOqSy.js +0 -1
- package/dist/label-BMlHW_2D.js +0 -1
- package/dist/popover-D5WxxnBY.js +0 -1
- package/dist/primitive-C64-m48O.d.ts +0 -13
- package/dist/primitive-IKruV2iB.js +0 -1
- package/dist/select-Bwt2YduR.d.ts +0 -345
- package/dist/select-D-5u0Blc.js +0 -1
- package/dist/separator-kBnnv3Cw.js +0 -1
- package/dist/skeleton-Bu3tgNcW.js +0 -1
- package/dist/slot-DmPrjM7N.js +0 -1
- package/dist/svg-only-DDx6FtJd.js +0 -1
- package/dist/table-CPH2md2-.js +0 -1
- package/dist/table-CwFHXC-G.d.ts +0 -414
- package/dist/theme-D3MDng6U.js +0 -1
- package/dist/theme-provider-C9zpDyJW.js +0 -1
- package/dist/toast-BsCjaMVS.js +0 -1
- package/dist/virtual-DZMBu7Ch.js +0 -1
package/dist/llms.txt
CHANGED
package/dist/main.d.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
//#region src/components/main/main.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A focusable `<main>` landmark for the page's primary content. Renders with
|
|
5
|
+
* `id="main"` and `tabIndex={-1}` so a skip link (or any programmatic focus
|
|
6
|
+
* call) can send keyboard users directly to the main content without exposing
|
|
7
|
+
* a visible focus ring on the region itself (`focus:outline-hidden`).
|
|
8
|
+
*
|
|
9
|
+
* Pair with the `<SkipToMainLink>` component at the top of the document.
|
|
10
|
+
*
|
|
11
|
+
* @see https://mantle.ngrok.com/components/primitives/main
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <SkipToMainLink />
|
|
16
|
+
* <Header />
|
|
17
|
+
* <Main>
|
|
18
|
+
* <h1>Page title</h1>
|
|
19
|
+
* </Main>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare const Main: ({ className, ...props }: ComponentProps<"main">) => import("react").JSX.Element;
|
|
7
23
|
//#endregion
|
|
8
24
|
export { Main };
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./cx-IiQEAKf5.js";import{jsx as t}from"react/jsx-runtime";const n=({className:n,...r})=>t(`main`,{...r,"data-slot":`main`,id:`main`,tabIndex:-1,className:e(`focus:outline-hidden`,n)});
|
|
1
|
+
import{t as e}from"./cx-IiQEAKf5.js";import{jsx as t}from"react/jsx-runtime";const n=({className:n,...r})=>t(`main`,{...r,"data-slot":`main`,id:`main`,tabIndex:-1,className:e(`focus:outline-hidden`,n)});export{n as Main};
|
package/dist/media-object.d.ts
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as WithAsChild } from "./as-child-D23mGo4f.js";
|
|
2
2
|
import { ComponentProps } from "react";
|
|
3
3
|
//#region src/components/media-object/media-object.d.ts
|
|
4
4
|
type Props = ComponentProps<"div"> & WithAsChild;
|
|
5
|
+
/**
|
|
6
|
+
* The media object is an image/icon (media) to the left, with descriptive
|
|
7
|
+
* content (title and subtitle/description) to the right. This is the root
|
|
8
|
+
* component of the media object.
|
|
9
|
+
*/
|
|
10
|
+
declare const Root: {
|
|
11
|
+
({ asChild, className, children, style, ref }: Props): import("react").JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The container for an image or icon to display in the media slot of the media object.
|
|
16
|
+
*/
|
|
17
|
+
declare const Media: {
|
|
18
|
+
({ asChild, className, children, style, ref }: Props): import("react").JSX.Element;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The container for the content slot of a media object.
|
|
23
|
+
*/
|
|
24
|
+
declare const Content: {
|
|
25
|
+
({ asChild, className, children, style, ref }: Props): import("react").JSX.Element;
|
|
26
|
+
displayName: string;
|
|
27
|
+
};
|
|
5
28
|
/**
|
|
6
29
|
* A small, reusable layout primitive for "image/icon on one side,
|
|
7
30
|
* descriptive content on the other" — the foundational
|
|
@@ -81,7 +104,7 @@ declare const MediaObject: {
|
|
|
81
104
|
* </MediaObject.Root>
|
|
82
105
|
* ```
|
|
83
106
|
*/
|
|
84
|
-
readonly Root:
|
|
107
|
+
readonly Root: typeof Root;
|
|
85
108
|
/**
|
|
86
109
|
* The container for an image or icon to display in the media slot of the media object.
|
|
87
110
|
*
|
|
@@ -99,7 +122,7 @@ declare const MediaObject: {
|
|
|
99
122
|
* </MediaObject.Root>
|
|
100
123
|
* ```
|
|
101
124
|
*/
|
|
102
|
-
readonly Media:
|
|
125
|
+
readonly Media: typeof Media;
|
|
103
126
|
/**
|
|
104
127
|
* The container for the content slot of a media object.
|
|
105
128
|
*
|
|
@@ -117,7 +140,7 @@ declare const MediaObject: {
|
|
|
117
140
|
* </MediaObject.Root>
|
|
118
141
|
* ```
|
|
119
142
|
*/
|
|
120
|
-
readonly Content:
|
|
143
|
+
readonly Content: typeof Content;
|
|
121
144
|
};
|
|
122
145
|
//#endregion
|
|
123
146
|
export { MediaObject };
|
package/dist/media-object.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./cx-IiQEAKf5.js";import{t}from"./slot-
|
|
1
|
+
import{t as e}from"./cx-IiQEAKf5.js";import{t}from"./slot-CDk0Bb9z.js";import{jsx as n}from"react/jsx-runtime";const r=({asChild:r=!1,className:i,children:a,style:o,ref:s})=>n(r?t:`div`,{ref:s,"data-slot":`media-object`,className:e(`flex gap-4`,i),style:o,children:a});r.displayName=`MediaObject`;const i=({asChild:r=!1,className:i,children:a,style:o,ref:s})=>n(r?t:`div`,{ref:s,"data-slot":`media-object-media`,className:e(`shrink-0 leading-none`,i),style:o,children:a});i.displayName=`MediaObjectMedia`;const a=({asChild:r=!1,className:i,children:a,style:o,ref:s})=>n(r?t:`div`,{ref:s,"data-slot":`media-object-content`,className:e(`min-w-0 flex-1`,i),style:o,children:a});a.displayName=`MediaObject.Content`;const o={Root:r,Media:i,Content:a};export{o as MediaObject};
|
package/dist/multi-select.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as WithAsChild } from "./as-child-D23mGo4f.js";
|
|
2
2
|
import { o as WithValidation } from "./validation-7QeiTFwl.js";
|
|
3
|
+
import { n as Separator } from "./separator-B5UmkVRL.js";
|
|
3
4
|
import { ComponentProps, ReactNode } from "react";
|
|
4
5
|
import * as Primitive from "@ariakit/react";
|
|
5
6
|
//#region src/components/multi-select/multi-select.d.ts
|
|
@@ -41,6 +42,30 @@ declare const Root: {
|
|
|
41
42
|
({ children, defaultSelectedValue, ...props }: MultiSelectProps): import("react").JSX.Element;
|
|
42
43
|
displayName: string;
|
|
43
44
|
};
|
|
45
|
+
type MultiSelectTriggerProps = ComponentProps<"div"> & WithValidation;
|
|
46
|
+
/**
|
|
47
|
+
* The trigger container for the multi-select. Wraps the input and selected
|
|
48
|
+
* value tags in a styled container that looks like a form input.
|
|
49
|
+
*
|
|
50
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselecttrigger
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <MultiSelect.Root>
|
|
55
|
+
* <MultiSelect.Trigger>
|
|
56
|
+
* <MultiSelect.TagValues />
|
|
57
|
+
* <MultiSelect.Input placeholder="Select items..." />
|
|
58
|
+
* </MultiSelect.Trigger>
|
|
59
|
+
* <MultiSelect.Content>
|
|
60
|
+
* <MultiSelect.Item value="apple">Apple</MultiSelect.Item>
|
|
61
|
+
* </MultiSelect.Content>
|
|
62
|
+
* </MultiSelect.Root>
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare const Trigger: {
|
|
66
|
+
({ "aria-invalid": _ariaInvalid, className, children, onKeyDown, onMouseDown, ref, validation: _validation, ...props }: MultiSelectTriggerProps): import("react").JSX.Element;
|
|
67
|
+
displayName: string;
|
|
68
|
+
};
|
|
44
69
|
type TagProps = Omit<ComponentProps<"span">, "children"> & {
|
|
45
70
|
/**
|
|
46
71
|
* The value to display in the tag label.
|
|
@@ -56,6 +81,34 @@ type TagProps = Omit<ComponentProps<"span">, "children"> & {
|
|
|
56
81
|
*/
|
|
57
82
|
locked?: boolean;
|
|
58
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* The default tag rendered inside `MultiSelect.TagValues` for each selected value.
|
|
86
|
+
* Displays the value label with a remove button and full keyboard navigation support.
|
|
87
|
+
*
|
|
88
|
+
* Use this when building a custom `TagValues`-like component and you want the
|
|
89
|
+
* default tag chrome with consistent styling.
|
|
90
|
+
*
|
|
91
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselecttag
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <MultiSelect.Root>
|
|
96
|
+
* <MultiSelect.Trigger>
|
|
97
|
+
* <MultiSelect.TagValues>
|
|
98
|
+
* {(props) => <MultiSelect.Tag key={props.value} {...props} />}
|
|
99
|
+
* </MultiSelect.TagValues>
|
|
100
|
+
* <MultiSelect.Input placeholder="Select items..." />
|
|
101
|
+
* </MultiSelect.Trigger>
|
|
102
|
+
* <MultiSelect.Content>
|
|
103
|
+
* <MultiSelect.Item value="apple">Apple</MultiSelect.Item>
|
|
104
|
+
* </MultiSelect.Content>
|
|
105
|
+
* </MultiSelect.Root>
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
declare const Tag: {
|
|
109
|
+
({ className, value, onRemove, locked, onKeyDown, ref, ...props }: TagProps): import("react").JSX.Element;
|
|
110
|
+
displayName: string;
|
|
111
|
+
};
|
|
59
112
|
/**
|
|
60
113
|
* Props passed to the children render function of `MultiSelect.TagValues`.
|
|
61
114
|
* Spread these onto `MultiSelect.Tag` (or your own tag component) to
|
|
@@ -127,10 +180,257 @@ type MultiSelectInputProps = Omit<Primitive.ComboboxProps, "render"> & {
|
|
|
127
180
|
*/
|
|
128
181
|
onValueChange?: (value: string) => void;
|
|
129
182
|
};
|
|
183
|
+
/**
|
|
184
|
+
* The combobox input for filtering items. Place this inside `MultiSelect.Trigger`,
|
|
185
|
+
* after `MultiSelect.TagValues`.
|
|
186
|
+
*
|
|
187
|
+
* `MultiSelect.Input` is the focusable element of the multi-select. When the
|
|
188
|
+
* surrounding `MultiSelect.Root` is wrapped in `Field.Control`, the generated
|
|
189
|
+
* `id`, `aria-invalid`, `aria-describedby`, and `aria-errormessage` flow onto
|
|
190
|
+
* the input here via `FieldControlContext`.
|
|
191
|
+
*
|
|
192
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselectinput
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```tsx
|
|
196
|
+
* <MultiSelect.Root>
|
|
197
|
+
* <MultiSelect.Trigger>
|
|
198
|
+
* <MultiSelect.TagValues />
|
|
199
|
+
* <MultiSelect.Input placeholder="Select items..." />
|
|
200
|
+
* </MultiSelect.Trigger>
|
|
201
|
+
* <MultiSelect.Content>
|
|
202
|
+
* <MultiSelect.Item value="apple">Apple</MultiSelect.Item>
|
|
203
|
+
* </MultiSelect.Content>
|
|
204
|
+
* </MultiSelect.Root>
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
declare const Input: {
|
|
208
|
+
({ className, onBlur, onChange, onFocus, onKeyDown, onValueChange, placeholder, ref, ...props }: MultiSelectInputProps): import("react").JSX.Element;
|
|
209
|
+
displayName: string;
|
|
210
|
+
};
|
|
130
211
|
type MultiSelectContentProps = Omit<Primitive.ComboboxPopoverProps, "render"> & WithAsChild;
|
|
212
|
+
/**
|
|
213
|
+
* Renders a popover that contains multi-select content, such as items, groups,
|
|
214
|
+
* and separators. Opens below the trigger.
|
|
215
|
+
*
|
|
216
|
+
* `MultiSelect.Content` renders at Tailwind `z-50`, Mantle's shared floating
|
|
217
|
+
* z-index. When multiple shared layers are open, the most recently mounted
|
|
218
|
+
* layer renders on top.
|
|
219
|
+
*
|
|
220
|
+
* By default, mantle disables Ariakit's body scroll lock when the trigger is
|
|
221
|
+
* inside a mantle modal (`Dialog`, `Sheet`, `AlertDialog`) — the modal already
|
|
222
|
+
* locks body scroll — and enables it otherwise. Pass `preventBodyScroll` to
|
|
223
|
+
* override.
|
|
224
|
+
*
|
|
225
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselectcontent
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```tsx
|
|
229
|
+
* <MultiSelect.Root>
|
|
230
|
+
* <MultiSelect.Trigger>
|
|
231
|
+
* <MultiSelect.TagValues />
|
|
232
|
+
* <MultiSelect.Input placeholder="Select items..." />
|
|
233
|
+
* </MultiSelect.Trigger>
|
|
234
|
+
* <MultiSelect.Content>
|
|
235
|
+
* <MultiSelect.Item value="apple">Apple</MultiSelect.Item>
|
|
236
|
+
* <MultiSelect.Item value="banana">Banana</MultiSelect.Item>
|
|
237
|
+
* </MultiSelect.Content>
|
|
238
|
+
* </MultiSelect.Root>
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
declare const Content: {
|
|
242
|
+
({ asChild, backdrop, children, className, modal, portalElement, preventBodyScroll, ref, sameWidth, unmountOnHide, ...props }: MultiSelectContentProps): import("react").JSX.Element;
|
|
243
|
+
displayName: string;
|
|
244
|
+
};
|
|
131
245
|
type MultiSelectItemProps = Omit<Primitive.ComboboxItemProps, "render"> & WithAsChild;
|
|
246
|
+
/**
|
|
247
|
+
* Renders a selectable item inside a `MultiSelect.Content` component.
|
|
248
|
+
* Items display a checkbox indicator when selected.
|
|
249
|
+
*
|
|
250
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselectitem
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```tsx
|
|
254
|
+
* <MultiSelect.Root>
|
|
255
|
+
* <MultiSelect.Trigger>
|
|
256
|
+
* <MultiSelect.TagValues />
|
|
257
|
+
* <MultiSelect.Input placeholder="Select items..." />
|
|
258
|
+
* </MultiSelect.Trigger>
|
|
259
|
+
* <MultiSelect.Content>
|
|
260
|
+
* <MultiSelect.Item value="apple">Apple</MultiSelect.Item>
|
|
261
|
+
* <MultiSelect.Item value="banana">Banana</MultiSelect.Item>
|
|
262
|
+
* </MultiSelect.Content>
|
|
263
|
+
* </MultiSelect.Root>
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
declare const Item: {
|
|
267
|
+
({ asChild, children, className, focusOnHover, value, onClick, ref, ...props }: MultiSelectItemProps): import("react").JSX.Element;
|
|
268
|
+
displayName: string;
|
|
269
|
+
};
|
|
132
270
|
type MultiSelectGroupProps = Omit<Primitive.ComboboxGroupProps, "render"> & WithAsChild;
|
|
271
|
+
/**
|
|
272
|
+
* Renders a group for MultiSelect.Item elements.
|
|
273
|
+
*
|
|
274
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselectgroup
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```tsx
|
|
278
|
+
* <MultiSelect.Root>
|
|
279
|
+
* <MultiSelect.Trigger>
|
|
280
|
+
* <MultiSelect.TagValues />
|
|
281
|
+
* <MultiSelect.Input placeholder="Select items..." />
|
|
282
|
+
* </MultiSelect.Trigger>
|
|
283
|
+
* <MultiSelect.Content>
|
|
284
|
+
* <MultiSelect.Group>
|
|
285
|
+
* <MultiSelect.GroupLabel>Fruits</MultiSelect.GroupLabel>
|
|
286
|
+
* <MultiSelect.Item value="apple">Apple</MultiSelect.Item>
|
|
287
|
+
* <MultiSelect.Item value="banana">Banana</MultiSelect.Item>
|
|
288
|
+
* </MultiSelect.Group>
|
|
289
|
+
* </MultiSelect.Content>
|
|
290
|
+
* </MultiSelect.Root>
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
declare const Group: {
|
|
294
|
+
({ asChild, children, ref, ...props }: MultiSelectGroupProps): import("react").JSX.Element;
|
|
295
|
+
displayName: string;
|
|
296
|
+
};
|
|
133
297
|
type MultiSelectGroupLabelProps = Omit<Primitive.ComboboxGroupLabelProps, "render"> & WithAsChild;
|
|
298
|
+
/**
|
|
299
|
+
* Renders a label in a multi-select group.
|
|
300
|
+
*
|
|
301
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselectgrouplabel
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```tsx
|
|
305
|
+
* <MultiSelect.Root>
|
|
306
|
+
* <MultiSelect.Trigger>
|
|
307
|
+
* <MultiSelect.TagValues />
|
|
308
|
+
* <MultiSelect.Input placeholder="Select items..." />
|
|
309
|
+
* </MultiSelect.Trigger>
|
|
310
|
+
* <MultiSelect.Content>
|
|
311
|
+
* <MultiSelect.Group>
|
|
312
|
+
* <MultiSelect.GroupLabel>Fruits</MultiSelect.GroupLabel>
|
|
313
|
+
* <MultiSelect.Item value="apple">Apple</MultiSelect.Item>
|
|
314
|
+
* </MultiSelect.Group>
|
|
315
|
+
* </MultiSelect.Content>
|
|
316
|
+
* </MultiSelect.Root>
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
declare const GroupLabel: {
|
|
320
|
+
({ asChild, children, className, ref, ...props }: MultiSelectGroupLabelProps): import("react").JSX.Element;
|
|
321
|
+
displayName: string;
|
|
322
|
+
};
|
|
323
|
+
type MultiSelectGroupDescriptionProps = ComponentProps<"p">;
|
|
324
|
+
/**
|
|
325
|
+
* Renders a description below a `MultiSelect.GroupLabel` inside a `MultiSelect.Group`.
|
|
326
|
+
* Provides context about the group's purpose or constraints.
|
|
327
|
+
*
|
|
328
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselectgroupdescription
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```tsx
|
|
332
|
+
* <MultiSelect.Root>
|
|
333
|
+
* <MultiSelect.Trigger>
|
|
334
|
+
* <MultiSelect.TagValues />
|
|
335
|
+
* <MultiSelect.Input placeholder="Select regions..." />
|
|
336
|
+
* </MultiSelect.Trigger>
|
|
337
|
+
* <MultiSelect.Content>
|
|
338
|
+
* <MultiSelect.Group>
|
|
339
|
+
* <MultiSelect.GroupLabel>Regional Aliases</MultiSelect.GroupLabel>
|
|
340
|
+
* <MultiSelect.GroupDescription>
|
|
341
|
+
* Include all points of presence that are geographically within the region.
|
|
342
|
+
* </MultiSelect.GroupDescription>
|
|
343
|
+
* <MultiSelect.Item value="global">global</MultiSelect.Item>
|
|
344
|
+
* </MultiSelect.Group>
|
|
345
|
+
* </MultiSelect.Content>
|
|
346
|
+
* </MultiSelect.Root>
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare const GroupDescription: {
|
|
350
|
+
({ className, children, ref, ...props }: MultiSelectGroupDescriptionProps): import("react").JSX.Element;
|
|
351
|
+
displayName: string;
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* Renders a separator between MultiSelect.Items or MultiSelect.Groups.
|
|
355
|
+
*
|
|
356
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselectseparator
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```tsx
|
|
360
|
+
* <MultiSelect.Root>
|
|
361
|
+
* <MultiSelect.Trigger>
|
|
362
|
+
* <MultiSelect.TagValues />
|
|
363
|
+
* <MultiSelect.Input placeholder="Select items..." />
|
|
364
|
+
* </MultiSelect.Trigger>
|
|
365
|
+
* <MultiSelect.Content>
|
|
366
|
+
* <MultiSelect.Group>
|
|
367
|
+
* <MultiSelect.Item value="apple">Apple</MultiSelect.Item>
|
|
368
|
+
* </MultiSelect.Group>
|
|
369
|
+
* <MultiSelect.Separator />
|
|
370
|
+
* <MultiSelect.Group>
|
|
371
|
+
* <MultiSelect.Item value="carrot">Carrot</MultiSelect.Item>
|
|
372
|
+
* </MultiSelect.Group>
|
|
373
|
+
* </MultiSelect.Content>
|
|
374
|
+
* </MultiSelect.Root>
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
declare const MultiSelectSeparatorComponent: {
|
|
378
|
+
({ className, ref, ...props }: ComponentProps<typeof Separator>): import("react").JSX.Element;
|
|
379
|
+
displayName: string;
|
|
380
|
+
};
|
|
381
|
+
type MultiSelectEmptyProps = ComponentProps<"div">;
|
|
382
|
+
/**
|
|
383
|
+
* Renders a message when no items match the current filter.
|
|
384
|
+
*
|
|
385
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselectempty
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```tsx
|
|
389
|
+
* <MultiSelect.Root>
|
|
390
|
+
* <MultiSelect.Trigger>
|
|
391
|
+
* <MultiSelect.TagValues />
|
|
392
|
+
* <MultiSelect.Input placeholder="Select items..." />
|
|
393
|
+
* </MultiSelect.Trigger>
|
|
394
|
+
* <MultiSelect.Content>
|
|
395
|
+
* {matches.length === 0 && (
|
|
396
|
+
* <MultiSelect.Empty>No results found</MultiSelect.Empty>
|
|
397
|
+
* )}
|
|
398
|
+
* </MultiSelect.Content>
|
|
399
|
+
* </MultiSelect.Root>
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
declare const Empty: {
|
|
403
|
+
({ className, children, ref, ...props }: MultiSelectEmptyProps): import("react").JSX.Element;
|
|
404
|
+
displayName: string;
|
|
405
|
+
};
|
|
406
|
+
type MultiSelectContentFooterProps = ComponentProps<"div">;
|
|
407
|
+
/**
|
|
408
|
+
* Renders a sticky footer pinned to the bottom inside `MultiSelect.Content`,
|
|
409
|
+
* with a separator border at the top.
|
|
410
|
+
*
|
|
411
|
+
* @see https://mantle.ngrok.com/components/forms/multi-select#multiselectcontentfooter
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```tsx
|
|
415
|
+
* <MultiSelect.Root>
|
|
416
|
+
* <MultiSelect.Trigger>
|
|
417
|
+
* <MultiSelect.TagValues />
|
|
418
|
+
* <MultiSelect.Input placeholder="Select items..." />
|
|
419
|
+
* </MultiSelect.Trigger>
|
|
420
|
+
* <MultiSelect.Content>
|
|
421
|
+
* <MultiSelect.Item value="apple">Apple</MultiSelect.Item>
|
|
422
|
+
* <MultiSelect.ContentFooter>
|
|
423
|
+
* <p>Upgrade to unlock more options.</p>
|
|
424
|
+
* <Button appearance="filled" intent="accent">Upgrade</Button>
|
|
425
|
+
* </MultiSelect.ContentFooter>
|
|
426
|
+
* </MultiSelect.Content>
|
|
427
|
+
* </MultiSelect.Root>
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
declare const ContentFooter: {
|
|
431
|
+
({ className, children, ref, ...props }: MultiSelectContentFooterProps): import("react").JSX.Element;
|
|
432
|
+
displayName: string;
|
|
433
|
+
};
|
|
134
434
|
/**
|
|
135
435
|
* A multi-select combobox that allows users to select multiple values with
|
|
136
436
|
* typeahead filtering. Selected values are displayed as removable tags.
|
|
@@ -230,7 +530,7 @@ declare const MultiSelect: {
|
|
|
230
530
|
* </MultiSelect.Root>
|
|
231
531
|
* ```
|
|
232
532
|
*/
|
|
233
|
-
readonly Trigger:
|
|
533
|
+
readonly Trigger: typeof Trigger;
|
|
234
534
|
/**
|
|
235
535
|
* Renders the selected values as removable tags. Place this inside
|
|
236
536
|
* `MultiSelect.Trigger`, followed by `MultiSelect.Input`.
|
|
@@ -289,7 +589,7 @@ declare const MultiSelect: {
|
|
|
289
589
|
* </MultiSelect.Root>
|
|
290
590
|
* ```
|
|
291
591
|
*/
|
|
292
|
-
readonly Input:
|
|
592
|
+
readonly Input: typeof Input;
|
|
293
593
|
/**
|
|
294
594
|
* The default tag rendered inside `MultiSelect.TagValues` for each selected value.
|
|
295
595
|
* Displays the value label with a remove button and keyboard navigation support.
|
|
@@ -311,7 +611,7 @@ declare const MultiSelect: {
|
|
|
311
611
|
* </MultiSelect.Root>
|
|
312
612
|
* ```
|
|
313
613
|
*/
|
|
314
|
-
readonly Tag:
|
|
614
|
+
readonly Tag: typeof Tag;
|
|
315
615
|
/**
|
|
316
616
|
* Renders a popover that contains multi-select content.
|
|
317
617
|
*
|
|
@@ -335,7 +635,7 @@ declare const MultiSelect: {
|
|
|
335
635
|
* </MultiSelect.Root>
|
|
336
636
|
* ```
|
|
337
637
|
*/
|
|
338
|
-
readonly Content:
|
|
638
|
+
readonly Content: typeof Content;
|
|
339
639
|
/**
|
|
340
640
|
* Renders a sticky footer pinned to the bottom inside `MultiSelect.Content`,
|
|
341
641
|
* with a separator border at the top.
|
|
@@ -358,7 +658,7 @@ declare const MultiSelect: {
|
|
|
358
658
|
* </MultiSelect.Root>
|
|
359
659
|
* ```
|
|
360
660
|
*/
|
|
361
|
-
readonly ContentFooter:
|
|
661
|
+
readonly ContentFooter: typeof ContentFooter;
|
|
362
662
|
/**
|
|
363
663
|
* Renders a selectable item with a checkbox indicator inside a `MultiSelect.Content`.
|
|
364
664
|
*
|
|
@@ -378,7 +678,7 @@ declare const MultiSelect: {
|
|
|
378
678
|
* </MultiSelect.Root>
|
|
379
679
|
* ```
|
|
380
680
|
*/
|
|
381
|
-
readonly Item:
|
|
681
|
+
readonly Item: typeof Item;
|
|
382
682
|
/**
|
|
383
683
|
* Renders a group for MultiSelect.Item elements.
|
|
384
684
|
*
|
|
@@ -400,7 +700,7 @@ declare const MultiSelect: {
|
|
|
400
700
|
* </MultiSelect.Root>
|
|
401
701
|
* ```
|
|
402
702
|
*/
|
|
403
|
-
readonly Group:
|
|
703
|
+
readonly Group: typeof Group;
|
|
404
704
|
/**
|
|
405
705
|
* Renders a label in a multi-select group.
|
|
406
706
|
*
|
|
@@ -422,7 +722,7 @@ declare const MultiSelect: {
|
|
|
422
722
|
* </MultiSelect.Root>
|
|
423
723
|
* ```
|
|
424
724
|
*/
|
|
425
|
-
readonly GroupLabel:
|
|
725
|
+
readonly GroupLabel: typeof GroupLabel;
|
|
426
726
|
/**
|
|
427
727
|
* Renders a description below a `MultiSelect.GroupLabel` inside a `MultiSelect.Group`.
|
|
428
728
|
*
|
|
@@ -447,7 +747,7 @@ declare const MultiSelect: {
|
|
|
447
747
|
* </MultiSelect.Root>
|
|
448
748
|
* ```
|
|
449
749
|
*/
|
|
450
|
-
readonly GroupDescription:
|
|
750
|
+
readonly GroupDescription: typeof GroupDescription;
|
|
451
751
|
/**
|
|
452
752
|
* Renders a separator between items or groups.
|
|
453
753
|
*
|
|
@@ -472,10 +772,7 @@ declare const MultiSelect: {
|
|
|
472
772
|
* </MultiSelect.Root>
|
|
473
773
|
* ```
|
|
474
774
|
*/
|
|
475
|
-
readonly Separator:
|
|
476
|
-
orientation?: "horizontal" | "vertical";
|
|
477
|
-
semantic?: boolean;
|
|
478
|
-
}, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
775
|
+
readonly Separator: typeof MultiSelectSeparatorComponent;
|
|
479
776
|
/**
|
|
480
777
|
* Renders a message when no items match the current filter.
|
|
481
778
|
*
|
|
@@ -496,7 +793,7 @@ declare const MultiSelect: {
|
|
|
496
793
|
* </MultiSelect.Root>
|
|
497
794
|
* ```
|
|
498
795
|
*/
|
|
499
|
-
readonly Empty:
|
|
796
|
+
readonly Empty: typeof Empty;
|
|
500
797
|
};
|
|
501
798
|
//#endregion
|
|
502
799
|
export { MultiSelect };
|
package/dist/multi-select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./compose-refs-Cjf2gfB8.js";import{t}from"./cx-IiQEAKf5.js";import{t as n}from"./icon-CDtYjF_H.js";import{t as r}from"./slot-DmPrjM7N.js";import{a as i,r as a}from"./validation-Bpptk_9t.js";import{t as o}from"./field-context-BR01g789.js";import{n as s}from"./separator-kBnnv3Cw.js";import{t as c}from"./use-prefers-reduced-motion-CagaNRgm.js";import{createContext as l,forwardRef as u,useCallback as d,useContext as f,useEffect as p,useMemo as m,useRef as h,useState as g}from"react";import{Fragment as _,jsx as v,jsxs as y}from"react/jsx-runtime";import{XIcon as b}from"@phosphor-icons/react/X";import{CheckIcon as x}from"@phosphor-icons/react/Check";import*as S from"@ariakit/react";import{LockIcon as C}from"@phosphor-icons/react/Lock";const w=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),T=[],E=l({current:null}),D=l({current:[]}),O=l({onInputKeyDownRef:{current:void 0},inputRef:{current:null}}),k=({children:e,defaultSelectedValue:t=T,...n})=>{let r=h(null),i=h(void 0),a=h(null),o=h([]),s=m(()=>({onInputKeyDownRef:i,inputRef:a}),[]);return v(E.Provider,{value:r,children:v(O.Provider,{value:s,children:v(D.Provider,{value:o,children:v(S.ComboboxProvider,{defaultSelectedValue:t,...n,children:e})})})})};k.displayName=`MultiSelect`;const A=u(({"aria-invalid":n,className:r,children:o,onKeyDown:s,onMouseDown:c,validation:l,...u},d)=>{let p=f(E),{inputRef:m}=f(O),h=S.useComboboxContext(),g=i(),{validation:_}=a({"aria-invalid":n,validation:l??g});return v(`div`,{role:`group`,"data-slot":`multi-select-trigger`,className:t(`cursor-text select-none font-sans text-sm`,`border-form bg-form text-strong flex min-h-9 w-full flex-wrap items-center gap-1 rounded-md border px-3 py-1 has-[[data-slot=multi-select-tag]]:px-1`,`has-focus:outline-hidden has-focus-within:ring-4 has-aria-expanded:ring-4`,`has-focus-within:border-accent-600 has-focus-within:ring-focus-accent has-aria-expanded:border-accent-600 has-aria-expanded:ring-focus-accent`,`data-validation-success:border-success-600 data-validation-success:has-focus-within:border-success-600 data-validation-success:has-focus-within:ring-focus-success data-validation-success:has-aria-expanded:border-success-600 data-validation-success:has-aria-expanded:ring-focus-success`,`data-validation-warning:border-warning-600 data-validation-warning:has-focus-within:border-warning-600 data-validation-warning:has-focus-within:ring-focus-warning data-validation-warning:has-aria-expanded:border-warning-600 data-validation-warning:has-aria-expanded:ring-focus-warning`,`data-validation-error:border-danger-600 data-validation-error:has-focus-within:border-danger-600 data-validation-error:has-focus-within:ring-focus-danger data-validation-error:has-aria-expanded:border-danger-600 data-validation-error:has-aria-expanded:ring-focus-danger`,r),"data-validation":_||void 0,onKeyDown:e=>{e.key===`Escape`&&h?.getState().open&&(e.preventDefault(),h.hide()),s?.(e)},onMouseDown:e=>{e.target instanceof HTMLElement&&!e.target.closest(`button, input, [role='option']`)&&(e.preventDefault(),m.current?.focus()),c?.(e)},ref:e(p,d),...u,children:o})});A.displayName=`MultiSelectTrigger`;const j=u(({className:r,value:i,onRemove:a,locked:o=!1,onKeyDown:s,...c},l)=>{let u=h(null);return y(`span`,{ref:e(u,l),role:`option`,"aria-selected":!0,tabIndex:-1,"data-slot":`multi-select-tag`,"data-locked":o||void 0,className:t(`cursor-default bg-neutral-500/10 border border-neutral-500/20 rounded-xs text-strong inline-flex items-center gap-1 pl-2 pr-0.5 py-0.5 text-sm font-normal`,`focus-visible:outline-hidden focus-visible:border-accent-600/50 focus-visible:ring-3 focus-visible:ring-focus-accent`,r),onKeyDown:e=>{if(o&&(e.key===`Backspace`||e.key===`Delete`)){e.preventDefault(),U(e.currentTarget);return}s?.(e)},...c,children:[i,v(`button`,{type:`button`,"aria-label":`Remove ${i}`,tabIndex:-1,"aria-disabled":o||void 0,className:t(`cursor-pointer text-strong/40 hover:bg-neutral-500/15 hover:text-strong rounded-xs p-0.5`,`aria-disabled:cursor-default aria-disabled:hover:bg-transparent aria-disabled:hover:text-strong/40`),onClick:e=>{if(e.stopPropagation(),o){let e=u.current;e&&U(e);return}a?.()},onMouseDown:e=>{e.preventDefault()},children:v(n,{svg:o?v(C,{}):v(b,{weight:`bold`}),className:`size-4`})})]})});j.displayName=`MultiSelectTag`;const M=({children:e,lockedValues:t=T})=>{let n=S.useComboboxContext(),r=S.useStoreState(n,`selectedValue`),i=(w(r)?r:void 0)??T,a=h(i);a.current=i;let o=f(D);o.current=t;let s=m(()=>new Set(t),[t]),c=h(new Map),{onInputKeyDownRef:l,inputRef:u}=f(O),d=h(new Set);p(()=>()=>{d.current.forEach(cancelAnimationFrame)},[]);let g=e=>{let t=requestAnimationFrame(()=>{d.current.delete(t),e()});d.current.add(t)},y=e=>{if(n){let t=n.getState().selectedValue;if(!w(t))return;n.setSelectedValue(t.filter(t=>t!==e))}},b=e=>{let t=a.current[e];if(t==null)return;let r=c.current.get(t);r&&(r.focus(),n?.show())},x=()=>{u.current?.focus()},C=(e,t)=>{let n=i[t];switch(e.key){case`ArrowLeft`:e.preventDefault(),t>0&&b(t-1);break;case`ArrowRight`:e.preventDefault(),t<i.length-1?b(t+1):x();break;case`Backspace`:case`Delete`:if(e.preventDefault(),n!=null){if(s.has(n)){let e=c.current.get(n);e&&U(e);break}if(y(n),e.key===`Backspace`)if(t>0){let e=t-1;g(()=>b(e))}else g(()=>{a.current.length>0?b(0):x()});else g(()=>{t<a.current.length?b(t):x()})}break;case`ArrowUp`:case`ArrowDown`:e.preventDefault(),x(),u.current?.dispatchEvent(new KeyboardEvent(`keydown`,{key:e.key,bubbles:!0,cancelable:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey}));break;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&x();break}};return l.current=e=>{if(e.key===`ArrowLeft`&&e.currentTarget.selectionStart===0&&e.currentTarget.selectionEnd===0&&i.length>0){e.preventDefault(),b(i.length-1);return}if(e.key===`Backspace`&&e.currentTarget.value===``&&i.length>0){let e=i[i.length-1];if(e!=null)if(o.current.includes(e)){let t=c.current.get(e);t&&U(t)}else y(e)}},v(_,{children:i.map((t,n)=>{let r={value:t,locked:s.has(t),onRemove:()=>{if(s.has(t)){let e=c.current.get(t);e&&U(e);return}y(t)},ref:e=>{e?c.current.set(t,e):c.current.delete(t)},onKeyDown:e=>C(e,n),onClick:()=>b(n)};return e?e(r):v(j,{...r},t)})})};M.displayName=`MultiSelectTagValues`;const N=u(({className:n,onBlur:r,onChange:i,onFocus:a,onKeyDown:s,onValueChange:c,placeholder:l,...u},d)=>{let p=S.useComboboxContext(),{onInputKeyDownRef:m,inputRef:h}=f(O),g=f(o),_=S.useStoreState(p,`selectedValue`),y=((w(_)?_:void 0)?.length??0)>0;return v(S.Combobox,{autoSelect:!0,"data-slot":`multi-select-input`,className:t(`pointer-coarse:text-base min-w-20 flex-1 select-text border-0 bg-transparent text-sm outline-hidden`,`placeholder:select-none placeholder:text-placeholder`,n),onChange:e=>{c?.(e.target.value),i?.(e)},onKeyDown:e=>{m.current?.(e),s?.(e)},onBlur:e=>{e.relatedTarget instanceof HTMLElement&&e.relatedTarget.closest(`[data-slot="multi-select-tag"]`)&&p?.show(),r?.(e)},onFocus:e=>{p?.show(),a?.(e)},placeholder:y?void 0:l,ref:e(h,d),...u,...g?{"aria-describedby":g[`aria-describedby`],"aria-errormessage":g[`aria-errormessage`],"aria-invalid":g[`aria-invalid`],id:g.id,name:g.name}:void 0})});N.displayName=`MultiSelectInput`;const P=u(({asChild:e=!1,backdrop:n=!1,children:i,className:a,modal:o=!0,portalElement:s,preventBodyScroll:c,sameWidth:l=!0,unmountOnHide:u=!0,...m},h)=>{let _=f(E),[y,b]=g(!1);p(()=>{b(_.current?.closest(`[data-mantle-modal-content]`)!=null)},[_]);let x=d(()=>_.current?.getBoundingClientRect()??null,[_]),C=d(e=>typeof s==`function`?s(e):s??_.current?.closest(`[data-mantle-modal-content]`)??e.ownerDocument.body,[s,_]),w=d(e=>!(e.target instanceof Node&&_.current?.contains(e.target)),[_]);return v(S.ComboboxPopover,{"data-slot":`multi-select-content`,className:t(`border-popover bg-popover relative z-50 max-h-96 min-w-32 scrollbar overflow-y-scroll overflow-x-hidden overscroll-y-none rounded-md border shadow-md pt-1 pb-1 has-data-content-footer:pb-0 font-sans flex flex-col gap-px focus:outline-hidden`,a),backdrop:n,getAnchorRect:x,gutter:4,hideOnInteractOutside:w,modal:o,portalElement:C,preventBodyScroll:c??!y,ref:h,render:e?({ref:e,...t})=>v(r,{ref:e,...t}):void 0,sameWidth:l,unmountOnHide:u,...m,children:i})});P.displayName=`MultiSelectContent`;const F=u(({asChild:e=!1,children:i,className:a,focusOnHover:o=!0,value:s,onClick:c,...l},u)=>{let d=f(D),p=s!=null&&d.current.includes(s);return y(S.ComboboxItem,{"data-slot":`multi-select-item`,className:t(`relative mx-1 cursor-pointer rounded-md pl-2 pr-8 py-1.5 text-strong text-sm font-normal flex min-w-0 items-center gap-2`,`[[role=option]+&]:mt-px`,`data-active-item:bg-active-menu-item`,`aria-disabled:opacity-50`,`aria-selected:bg-selected-menu-item aria-selected:data-active-item:bg-active-selected-menu-item`,a),focusOnHover:o,onClick:e=>{if(p){e.preventDefault();return}c?.(e)},ref:u,render:e?({ref:e,...t})=>v(r,{ref:e,...t}):void 0,resetValueOnSelect:!0,value:s,...l,children:[i,v(S.ComboboxItemCheck,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:v(n,{svg:v(x,{weight:`bold`}),className:`size-4 text-accent-600`})})]})});F.displayName=`MultiSelectItem`;const I=u(({asChild:e=!1,children:t,...n},i)=>v(S.ComboboxGroup,{"data-slot":`multi-select-group`,className:`mx-1`,ref:i,render:e?({ref:e,...t})=>v(r,{ref:e,...t}):void 0,...n,children:t}));I.displayName=`MultiSelectGroup`;const L=u(({asChild:e=!1,children:n,className:i,...a},o)=>v(S.ComboboxGroupLabel,{"data-slot":`multi-select-group-label`,className:t(`text-muted px-2 py-1 text-xs font-medium`,i),ref:o,render:e?({ref:e,...t})=>v(r,{ref:e,...t}):void 0,...a,children:n}));L.displayName=`MultiSelectGroupLabel`;const R=u(({className:e,children:n,...r},i)=>v(`p`,{"data-slot":`multi-select-group-description`,className:t(`text-muted px-2 pb-1 text-xs`,e),ref:i,...r,children:n}));R.displayName=`MultiSelectGroupDescription`;const z=u(({className:e,...n},r)=>v(s,{"data-slot":`multi-select-separator`,ref:r,className:t(`my-1 w-auto`,e),...n}));z.displayName=`MultiSelectSeparator`;const B=u(({className:e,children:n,...r},i)=>v(`div`,{"data-slot":`multi-select-empty`,className:t(`mx-1 text-muted px-2 py-6 text-center text-sm`,e),ref:i,role:`presentation`,...r,children:n}));B.displayName=`MultiSelectEmpty`;const V=u(({className:e,children:n,...r},i)=>v(`div`,{ref:i,"data-slot":`multi-select-content-footer`,"data-content-footer":!0,className:t(`bg-popover sticky bottom-0 border-t border-popover`,e),...r,children:n}));V.displayName=`MultiSelectContentFooter`;const H={Root:k,Trigger:A,TagValues:M,Input:N,Tag:j,Content:P,ContentFooter:V,Item:F,Group:I,GroupLabel:L,GroupDescription:R,Separator:z,Empty:B};function U(e){c()||e.animate([{transform:`translateX(0)`},{transform:`translateX(-4px)`},{transform:`translateX(4px)`},{transform:`translateX(-4px)`},{transform:`translateX(4px)`},{transform:`translateX(0)`}],{duration:300,easing:`ease-in-out`})}export{H as MultiSelect};
|
|
1
|
+
import{t as e}from"./compose-refs-BdBMM9ga.js";import{t}from"./cx-IiQEAKf5.js";import{t as n}from"./icon-CGgMKpJg.js";import{t as r}from"./slot-CDk0Bb9z.js";import{a as i,r as a}from"./validation-Bpptk_9t.js";import{t as o}from"./field-context-BR01g789.js";import{n as s}from"./separator-bpE_kooz.js";import{t as c}from"./use-prefers-reduced-motion-CagaNRgm.js";import{createContext as l,useCallback as u,useContext as d,useEffect as f,useMemo as p,useRef as m,useState as h}from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";import{XIcon as y}from"@phosphor-icons/react/X";import{CheckIcon as b}from"@phosphor-icons/react/Check";import*as x from"@ariakit/react";import{LockIcon as S}from"@phosphor-icons/react/Lock";const C=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),w=[],T=l({current:null}),E=l({current:[]}),D=l({onInputKeyDownRef:{current:void 0},inputRef:{current:null}}),O=({children:e,defaultSelectedValue:t=w,...n})=>{let r=m(null),i=m(void 0),a=m(null),o=m([]),s=p(()=>({onInputKeyDownRef:i,inputRef:a}),[]);return _(T.Provider,{value:r,children:_(D.Provider,{value:s,children:_(E.Provider,{value:o,children:_(x.ComboboxProvider,{defaultSelectedValue:t,...n,children:e})})})})};O.displayName=`MultiSelect`;const k=({"aria-invalid":n,className:r,children:o,onKeyDown:s,onMouseDown:c,ref:l,validation:u,...f})=>{let p=d(T),{inputRef:m}=d(D),h=x.useComboboxContext(),g=i(),{validation:v}=a({"aria-invalid":n,validation:u??g});return _(`div`,{role:`group`,"data-slot":`multi-select-trigger`,className:t(`cursor-text select-none font-sans text-sm`,`border-form bg-form text-strong flex min-h-9 w-full flex-wrap items-center gap-1 rounded-md border px-3 py-1 has-[[data-slot=multi-select-tag]]:px-1`,`has-focus:outline-hidden has-focus-within:ring-4 has-aria-expanded:ring-4`,`has-focus-within:border-accent-600 has-focus-within:ring-focus-accent has-aria-expanded:border-accent-600 has-aria-expanded:ring-focus-accent`,`data-validation-success:border-success-600 data-validation-success:has-focus-within:border-success-600 data-validation-success:has-focus-within:ring-focus-success data-validation-success:has-aria-expanded:border-success-600 data-validation-success:has-aria-expanded:ring-focus-success`,`data-validation-warning:border-warning-600 data-validation-warning:has-focus-within:border-warning-600 data-validation-warning:has-focus-within:ring-focus-warning data-validation-warning:has-aria-expanded:border-warning-600 data-validation-warning:has-aria-expanded:ring-focus-warning`,`data-validation-error:border-danger-600 data-validation-error:has-focus-within:border-danger-600 data-validation-error:has-focus-within:ring-focus-danger data-validation-error:has-aria-expanded:border-danger-600 data-validation-error:has-aria-expanded:ring-focus-danger`,r),"data-validation":v||void 0,onKeyDown:e=>{e.key===`Escape`&&h?.getState().open&&(e.preventDefault(),h.hide()),s?.(e)},onMouseDown:e=>{e.target instanceof HTMLElement&&!e.target.closest(`button, input, [role='option']`)&&(e.preventDefault(),m.current?.focus()),c?.(e)},ref:e(p,l),...f,children:o})};k.displayName=`MultiSelectTrigger`;const A=({className:r,value:i,onRemove:a,locked:o=!1,onKeyDown:s,ref:c,...l})=>{let u=m(null);return v(`span`,{ref:e(u,c),role:`option`,"aria-selected":!0,tabIndex:-1,"data-slot":`multi-select-tag`,"data-locked":o||void 0,className:t(`cursor-default bg-neutral-500/10 border border-neutral-500/20 rounded-xs text-strong inline-flex items-center gap-1 pl-2 pr-0.5 py-0.5 text-sm font-normal`,`focus-visible:outline-hidden focus-visible:border-accent-600/50 focus-visible:ring-3 focus-visible:ring-focus-accent`,r),onKeyDown:e=>{if(o&&(e.key===`Backspace`||e.key===`Delete`)){e.preventDefault(),H(e.currentTarget);return}s?.(e)},...l,children:[i,_(`button`,{type:`button`,"aria-label":`Remove ${i}`,tabIndex:-1,"aria-disabled":o||void 0,className:t(`cursor-pointer text-strong/40 hover:bg-neutral-500/15 hover:text-strong rounded-xs p-0.5`,`aria-disabled:cursor-default aria-disabled:hover:bg-transparent aria-disabled:hover:text-strong/40`),onClick:e=>{if(e.stopPropagation(),o){let e=u.current;e&&H(e);return}a?.()},onMouseDown:e=>{e.preventDefault()},children:_(n,{svg:o?_(S,{}):_(y,{weight:`bold`}),className:`size-4`})})]})};A.displayName=`MultiSelectTag`;const j=({children:e,lockedValues:t=w})=>{let n=x.useComboboxContext(),r=x.useStoreState(n,`selectedValue`),i=(C(r)?r:void 0)??w,a=m(i);a.current=i;let o=d(E);o.current=t;let s=p(()=>new Set(t),[t]),c=m(new Map),{onInputKeyDownRef:l,inputRef:u}=d(D),h=m(new Set);f(()=>()=>{h.current.forEach(cancelAnimationFrame)},[]);let v=e=>{let t=requestAnimationFrame(()=>{h.current.delete(t),e()});h.current.add(t)},y=e=>{if(n){let t=n.getState().selectedValue;if(!C(t))return;n.setSelectedValue(t.filter(t=>t!==e))}},b=e=>{let t=a.current[e];if(t==null)return;let r=c.current.get(t);r&&(r.focus(),n?.show())},S=()=>{u.current?.focus()},T=(e,t)=>{let n=i[t];switch(e.key){case`ArrowLeft`:e.preventDefault(),t>0&&b(t-1);break;case`ArrowRight`:e.preventDefault(),t<i.length-1?b(t+1):S();break;case`Backspace`:case`Delete`:if(e.preventDefault(),n!=null){if(s.has(n)){let e=c.current.get(n);e&&H(e);break}if(y(n),e.key===`Backspace`)if(t>0){let e=t-1;v(()=>b(e))}else v(()=>{a.current.length>0?b(0):S()});else v(()=>{t<a.current.length?b(t):S()})}break;case`ArrowUp`:case`ArrowDown`:e.preventDefault(),S(),u.current?.dispatchEvent(new KeyboardEvent(`keydown`,{key:e.key,bubbles:!0,cancelable:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey}));break;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&S();break}};return l.current=e=>{if(e.key===`ArrowLeft`&&e.currentTarget.selectionStart===0&&e.currentTarget.selectionEnd===0&&i.length>0){e.preventDefault(),b(i.length-1);return}if(e.key===`Backspace`&&e.currentTarget.value===``&&i.length>0){let e=i[i.length-1];if(e!=null)if(o.current.includes(e)){let t=c.current.get(e);t&&H(t)}else y(e)}},_(g,{children:i.map((t,n)=>{let r={value:t,locked:s.has(t),onRemove:()=>{if(s.has(t)){let e=c.current.get(t);e&&H(e);return}y(t)},ref:e=>{e?c.current.set(t,e):c.current.delete(t)},onKeyDown:e=>T(e,n),onClick:()=>b(n)};return e?e(r):_(A,{...r},t)})})};j.displayName=`MultiSelectTagValues`;const M=({className:n,onBlur:r,onChange:i,onFocus:a,onKeyDown:s,onValueChange:c,placeholder:l,ref:u,...f})=>{let p=x.useComboboxContext(),{onInputKeyDownRef:m,inputRef:h}=d(D),g=d(o),v=x.useStoreState(p,`selectedValue`),y=((C(v)?v:void 0)?.length??0)>0;return _(x.Combobox,{autoSelect:!0,"data-slot":`multi-select-input`,className:t(`pointer-coarse:text-base min-w-20 flex-1 select-text border-0 bg-transparent text-sm outline-hidden`,`placeholder:select-none placeholder:text-placeholder`,n),onChange:e=>{c?.(e.target.value),i?.(e)},onKeyDown:e=>{m.current?.(e),s?.(e)},onBlur:e=>{e.relatedTarget instanceof HTMLElement&&e.relatedTarget.closest(`[data-slot="multi-select-tag"]`)&&p?.show(),r?.(e)},onFocus:e=>{p?.show(),a?.(e)},placeholder:y?void 0:l,ref:e(h,u),...f,...g?{"aria-describedby":g[`aria-describedby`],"aria-errormessage":g[`aria-errormessage`],"aria-invalid":g[`aria-invalid`],id:g.id,name:g.name}:void 0})};M.displayName=`MultiSelectInput`;const N=({asChild:e=!1,backdrop:n=!1,children:i,className:a,modal:o=!0,portalElement:s,preventBodyScroll:c,ref:l,sameWidth:p=!0,unmountOnHide:m=!0,...g})=>{let v=d(T),[y,b]=h(!1);f(()=>{b(v.current?.closest(`[data-mantle-modal-content]`)!=null)},[v]);let S=u(()=>v.current?.getBoundingClientRect()??null,[v]),C=u(e=>typeof s==`function`?s(e):s??v.current?.closest(`[data-mantle-modal-content]`)??e.ownerDocument.body,[s,v]),w=u(e=>!(e.target instanceof Node&&v.current?.contains(e.target)),[v]);return _(x.ComboboxPopover,{"data-slot":`multi-select-content`,className:t(`border-popover bg-popover relative z-50 max-h-96 min-w-32 scrollbar overflow-y-scroll overflow-x-hidden overscroll-y-none rounded-md border shadow-md pt-1 pb-1 has-data-content-footer:pb-0 font-sans flex flex-col gap-px focus:outline-hidden`,a),backdrop:n,getAnchorRect:S,gutter:4,hideOnInteractOutside:w,modal:o,portalElement:C,preventBodyScroll:c??!y,ref:l,render:e?({ref:e,...t})=>_(r,{ref:e,...t}):void 0,sameWidth:p,unmountOnHide:m,...g,children:i})};N.displayName=`MultiSelectContent`;const P=({asChild:e=!1,children:i,className:a,focusOnHover:o=!0,value:s,onClick:c,ref:l,...u})=>{let f=d(E),p=s!=null&&f.current.includes(s);return v(x.ComboboxItem,{"data-slot":`multi-select-item`,className:t(`relative mx-1 cursor-pointer rounded-md pl-2 pr-8 py-1.5 text-strong text-sm font-normal flex min-w-0 items-center gap-2`,`[[role=option]+&]:mt-px`,`data-active-item:bg-active-menu-item`,`aria-disabled:opacity-50`,`aria-selected:bg-selected-menu-item aria-selected:data-active-item:bg-active-selected-menu-item`,a),focusOnHover:o,onClick:e=>{if(p){e.preventDefault();return}c?.(e)},ref:l,render:e?({ref:e,...t})=>_(r,{ref:e,...t}):void 0,resetValueOnSelect:!0,value:s,...u,children:[i,_(x.ComboboxItemCheck,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:_(n,{svg:_(b,{weight:`bold`}),className:`size-4 text-accent-600`})})]})};P.displayName=`MultiSelectItem`;const F=({asChild:e=!1,children:t,ref:n,...i})=>_(x.ComboboxGroup,{"data-slot":`multi-select-group`,className:`mx-1`,ref:n,render:e?({ref:e,...t})=>_(r,{ref:e,...t}):void 0,...i,children:t});F.displayName=`MultiSelectGroup`;const I=({asChild:e=!1,children:n,className:i,ref:a,...o})=>_(x.ComboboxGroupLabel,{"data-slot":`multi-select-group-label`,className:t(`text-muted px-2 py-1 text-xs font-medium`,i),ref:a,render:e?({ref:e,...t})=>_(r,{ref:e,...t}):void 0,...o,children:n});I.displayName=`MultiSelectGroupLabel`;const L=({className:e,children:n,ref:r,...i})=>_(`p`,{"data-slot":`multi-select-group-description`,className:t(`text-muted px-2 pb-1 text-xs`,e),ref:r,...i,children:n});L.displayName=`MultiSelectGroupDescription`;const R=({className:e,ref:n,...r})=>_(s,{"data-slot":`multi-select-separator`,ref:n,className:t(`my-1 w-auto`,e),...r});R.displayName=`MultiSelectSeparator`;const z=({className:e,children:n,ref:r,...i})=>_(`div`,{"data-slot":`multi-select-empty`,className:t(`mx-1 text-muted px-2 py-6 text-center text-sm`,e),ref:r,role:`presentation`,...i,children:n});z.displayName=`MultiSelectEmpty`;const B=({className:e,children:n,ref:r,...i})=>_(`div`,{ref:r,"data-slot":`multi-select-content-footer`,"data-content-footer":!0,className:t(`bg-popover sticky bottom-0 border-t border-popover`,e),...i,children:n});B.displayName=`MultiSelectContentFooter`;const V={Root:O,Trigger:k,TagValues:j,Input:M,Tag:A,Content:N,ContentFooter:B,Item:P,Group:F,GroupLabel:I,GroupDescription:L,Separator:R,Empty:z};function H(e){c()||e.animate([{transform:`translateX(0)`},{transform:`translateX(-4px)`},{transform:`translateX(4px)`},{transform:`translateX(-4px)`},{transform:`translateX(4px)`},{transform:`translateX(0)`}],{duration:300,easing:`ease-in-out`})}export{V as MultiSelect};
|