@gridui/select 1.6.0 → 2.0.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/README.md +10 -3
- package/dist/autocomplete/autocomplete.d.ts +2 -0
- package/dist/autocomplete-suggestions/autocomplete-suggestions.d.ts +2 -0
- package/dist/combobox/combobox.d.ts +3 -1
- package/dist/index.js +56 -36
- package/dist/index.js.map +2 -2
- package/dist/select/style.d.ts +2 -1
- package/dist/shared/popup/selection-popup.d.ts +2 -0
- package/dist/shared/style.d.ts +2 -1
- package/dist/shared/types.d.ts +3 -1
- package/dist/styles.css +108 -84
- package/dist/styles.local.css +3 -3
- package/docs/catalog.json +12 -12
- package/docs/reference/autocomplete-suggestions.md +7 -1
- package/docs/reference/autocomplete.md +14 -4
- package/docs/reference/combobox.md +20 -8
- package/docs/reference/multi-select.md +16 -2
- package/docs/reference/select.md +16 -8
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @gridui/select
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Controls family. Public API: `AutocompleteSuggestions`, `AutocompleteSuggestionsProps`, `AutocompleteInputPropsGetter`, `Autocomplete`, `AutocompleteProps`, `Combobox`, `ComboboxProps`, `MultiSelect`, `MultiSelectProps`, `Select`, `SelectAction`, `SelectGroup`, `SelectOption`, `SelectProps`.
|
|
4
4
|
|
|
5
5
|
Import components from `@gridui/select`. Load these styles in order for Select,
|
|
6
6
|
Combobox, and MultiSelect:
|
|
@@ -15,7 +15,7 @@ rows, group labels, and trailing check slots. Form hides MultiSelect’s native
|
|
|
15
15
|
multiple-value bridge. Applications own routes, labels, state persistence, and
|
|
16
16
|
branding.
|
|
17
17
|
|
|
18
|
-
See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/component-ownership.md) and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-
|
|
18
|
+
See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/component-ownership.md) and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-controls/select/.changeset/history).
|
|
19
19
|
|
|
20
20
|
## Styles
|
|
21
21
|
|
|
@@ -219,7 +219,7 @@ unmounts without waiting for an animation event.
|
|
|
219
219
|
|
|
220
220
|
Shared animation policy and tempo come from `MotionConfig` in `@gridui/motion`.
|
|
221
221
|
Disabled or reduced-motion policy settles decoration without disabling interaction.
|
|
222
|
-
See the [motion guide](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-
|
|
222
|
+
See the [motion guide](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-foundation/motion)
|
|
223
223
|
for CSS scopes, portal behavior, and specialized timing contracts.
|
|
224
224
|
|
|
225
225
|
## Compose suggestions with a host-owned input
|
|
@@ -257,3 +257,10 @@ TagInput composes it with its existing draft and tag state.
|
|
|
257
257
|
Search result availability, active-item fallback and clamped navigation reuse
|
|
258
258
|
Interaction's React-free searchable-list model. A defined `errorLabel`, including
|
|
259
259
|
an empty string, removes stale options without losing committed value labels.
|
|
260
|
+
|
|
261
|
+
## Sizing and density
|
|
262
|
+
|
|
263
|
+
Select, Combobox, MultiSelect and Autocomplete use size small, medium (default) or large. density independently selects compact/comfortable popup rows, including portaled options and actions. Combobox and Input-derived Autocomplete support htmlSize for native character width. AutocompleteSuggestions keeps getInputProps native and accepts popup density; adapting its result to GridUI Input requires mapping numeric size to htmlSize.
|
|
264
|
+
|
|
265
|
+
See the [shared sizing contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/usage/sizing.md)
|
|
266
|
+
for native attributes, scope precedence, tokens and target behavior.
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { SelectGroup, SelectionSearchProps, SelectOption } from "../shared/types";
|
|
8
8
|
import { type InputProps } from "@gridui/input";
|
|
9
|
+
import type { Density } from "@gridui/theme";
|
|
9
10
|
import { type FC } from "react";
|
|
10
11
|
export type AutocompleteProps = Omit<InputProps, "value" | "defaultValue" | "type"> & Omit<SelectionSearchProps, "query" | "onQueryChange"> & {
|
|
11
12
|
readonly value?: string | undefined;
|
|
@@ -15,6 +16,7 @@ export type AutocompleteProps = Omit<InputProps, "value" | "defaultValue" | "typ
|
|
|
15
16
|
readonly emptyLabel: string;
|
|
16
17
|
readonly portalContainer?: HTMLElement | undefined;
|
|
17
18
|
readonly rootClassName?: string;
|
|
19
|
+
readonly density?: Density | undefined;
|
|
18
20
|
readonly onOptionSelect?: (option: SelectOption) => void;
|
|
19
21
|
};
|
|
20
22
|
export declare const Autocomplete: FC<AutocompleteProps>;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @namespace AutocompleteSuggestions
|
|
5
5
|
* @description Autocomplete Suggestions
|
|
6
6
|
*/
|
|
7
|
+
import type { Density } from "@gridui/theme";
|
|
7
8
|
import type { SelectGroup, SelectionSearchProps, SelectOption } from "../shared/types";
|
|
8
9
|
import { type ComponentPropsWithRef, type FC, type ReactNode } from "react";
|
|
9
10
|
type InputProps = ComponentPropsWithRef<"input">;
|
|
@@ -11,6 +12,7 @@ type InputProps = ComponentPropsWithRef<"input">;
|
|
|
11
12
|
export type AutocompleteInputPropsGetter = (props: InputProps) => InputProps;
|
|
12
13
|
export type AutocompleteSuggestionsProps = Omit<SelectionSearchProps, "query" | "onQueryChange"> & Pick<InputProps, "disabled" | "readOnly" | "dir" | "onKeyDown" | "form"> & {
|
|
13
14
|
readonly value: string;
|
|
15
|
+
readonly density?: Density | undefined;
|
|
14
16
|
readonly options: readonly (SelectOption | SelectGroup)[];
|
|
15
17
|
readonly searchLabel: string;
|
|
16
18
|
readonly emptyLabel: string;
|
|
@@ -6,5 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { SelectionProps, SelectionSearchLabels, SelectionSearchProps } from "../shared/types";
|
|
8
8
|
import { type ComponentPropsWithRef, type FC } from "react";
|
|
9
|
-
export type ComboboxProps = Omit<ComponentPropsWithRef<"input">, "children" | "value" | "defaultValue" | "onChange" | "type" | "size"> & SelectionProps & SelectionSearchProps & SelectionSearchLabels
|
|
9
|
+
export type ComboboxProps = Omit<ComponentPropsWithRef<"input">, "children" | "value" | "defaultValue" | "onChange" | "type" | "size"> & SelectionProps & SelectionSearchProps & SelectionSearchLabels & {
|
|
10
|
+
readonly htmlSize?: number | undefined;
|
|
11
|
+
};
|
|
10
12
|
export declare const Combobox: FC<ComboboxProps>;
|
package/dist/index.js
CHANGED
|
@@ -15,10 +15,10 @@ var selectActionStyles = cva(cn(
|
|
|
15
15
|
overlayListItemStyles(),
|
|
16
16
|
"gridui-u-select--w-full gridui-u-select--text-start"
|
|
17
17
|
));
|
|
18
|
-
var comboboxContentStyles =
|
|
19
|
-
overlayListStyles(),
|
|
18
|
+
var comboboxContentStyles = (density) => cn(
|
|
19
|
+
overlayListStyles({ density }),
|
|
20
20
|
"gridui-combobox-content gridui-u-select--box-border gridui-u-select--flex gridui-u-select--flex-col gridui-u-select--overflow-hidden gridui-u-select--min-w-0 gridui-u-select--w-(--anchor-width) gridui-u-select--max-h-(--available-height) gridui-u-select--max-w-(--available-width)"
|
|
21
|
-
)
|
|
21
|
+
);
|
|
22
22
|
|
|
23
23
|
// src/shared/popup/selection-popup.tsx
|
|
24
24
|
import { isComposingKeyEvent } from "@gridui/interaction";
|
|
@@ -27,7 +27,7 @@ import * as Primitive from "@radix-ui/react-popover";
|
|
|
27
27
|
import { jsx } from "react/jsx-runtime";
|
|
28
28
|
var SelectionPopup = (props) => {
|
|
29
29
|
const motionStyle = useMotionStyle();
|
|
30
|
-
const { open, children, container, anchorRef, initialFocus, finalFocus, onEscape, onDismiss, ...restProps } = props;
|
|
30
|
+
const { open, density = "comfortable", children, container, anchorRef, initialFocus, finalFocus, onEscape, onDismiss, ...restProps } = props;
|
|
31
31
|
return /* @__PURE__ */ jsx(
|
|
32
32
|
Primitive.Portal,
|
|
33
33
|
{
|
|
@@ -40,7 +40,8 @@ var SelectionPopup = (props) => {
|
|
|
40
40
|
sideOffset: 8,
|
|
41
41
|
align: "start",
|
|
42
42
|
collisionPadding: 16,
|
|
43
|
-
|
|
43
|
+
"data-density": density,
|
|
44
|
+
className: comboboxContentStyles(density),
|
|
44
45
|
onOpenAutoFocus: (event) => {
|
|
45
46
|
event.preventDefault();
|
|
46
47
|
initialFocus?.();
|
|
@@ -455,6 +456,7 @@ var AutocompleteSuggestions = (props) => {
|
|
|
455
456
|
resultCountLabel,
|
|
456
457
|
portalContainer,
|
|
457
458
|
rootClassName,
|
|
459
|
+
density = "comfortable",
|
|
458
460
|
onOptionSelect,
|
|
459
461
|
disabled,
|
|
460
462
|
readOnly,
|
|
@@ -581,6 +583,7 @@ var AutocompleteSuggestions = (props) => {
|
|
|
581
583
|
/* @__PURE__ */ jsxs2(
|
|
582
584
|
SelectionPopup,
|
|
583
585
|
{
|
|
586
|
+
density,
|
|
584
587
|
open: popup.open,
|
|
585
588
|
ref: popup.popupRef,
|
|
586
589
|
container: portalContainer,
|
|
@@ -641,7 +644,9 @@ var Autocomplete = (props) => {
|
|
|
641
644
|
ref,
|
|
642
645
|
onChange,
|
|
643
646
|
onKeyDown,
|
|
644
|
-
|
|
647
|
+
size,
|
|
648
|
+
htmlSize,
|
|
649
|
+
density,
|
|
645
650
|
...restProps
|
|
646
651
|
} = props;
|
|
647
652
|
const [local, setLocal] = useState4(defaultValue);
|
|
@@ -675,6 +680,7 @@ var Autocomplete = (props) => {
|
|
|
675
680
|
loadingLabel,
|
|
676
681
|
errorLabel,
|
|
677
682
|
resultCountLabel,
|
|
683
|
+
density,
|
|
678
684
|
portalContainer,
|
|
679
685
|
rootClassName,
|
|
680
686
|
disabled: restProps.disabled,
|
|
@@ -686,23 +692,28 @@ var Autocomplete = (props) => {
|
|
|
686
692
|
change(option.label);
|
|
687
693
|
onOptionSelect?.(option);
|
|
688
694
|
},
|
|
689
|
-
children: (getInputProps) =>
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
onChange
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
695
|
+
children: (getInputProps) => {
|
|
696
|
+
const { size: nativeSize, ...nativeProps } = getInputProps({
|
|
697
|
+
...restProps,
|
|
698
|
+
size: htmlSize,
|
|
699
|
+
ref: input,
|
|
700
|
+
type: "text",
|
|
701
|
+
autoComplete: restProps.autoComplete ?? "off",
|
|
702
|
+
value: text,
|
|
703
|
+
onChange: (event) => {
|
|
704
|
+
onChange?.(event);
|
|
705
|
+
change(event.currentTarget.value);
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
return /* @__PURE__ */ jsx4(
|
|
709
|
+
Input,
|
|
710
|
+
{
|
|
711
|
+
...nativeProps,
|
|
712
|
+
htmlSize: nativeSize,
|
|
713
|
+
...size === void 0 ? {} : { size }
|
|
714
|
+
}
|
|
715
|
+
);
|
|
716
|
+
}
|
|
706
717
|
}
|
|
707
718
|
);
|
|
708
719
|
};
|
|
@@ -911,7 +922,9 @@ var Combobox = (props) => {
|
|
|
911
922
|
value,
|
|
912
923
|
defaultValue = "",
|
|
913
924
|
onValueChange,
|
|
914
|
-
|
|
925
|
+
size = "medium",
|
|
926
|
+
density = "comfortable",
|
|
927
|
+
htmlSize,
|
|
915
928
|
clearLabel,
|
|
916
929
|
required,
|
|
917
930
|
disabled,
|
|
@@ -1002,6 +1015,7 @@ var Combobox = (props) => {
|
|
|
1002
1015
|
...restProps,
|
|
1003
1016
|
id: restProps.id ?? inputId,
|
|
1004
1017
|
type: "text",
|
|
1018
|
+
size: htmlSize,
|
|
1005
1019
|
role: "combobox",
|
|
1006
1020
|
ref: (element) => {
|
|
1007
1021
|
controlRef.current = element;
|
|
@@ -1024,7 +1038,7 @@ var Combobox = (props) => {
|
|
|
1024
1038
|
form,
|
|
1025
1039
|
disabled,
|
|
1026
1040
|
readOnly,
|
|
1027
|
-
className: cn3(controlVariants({ size
|
|
1041
|
+
className: cn3(controlVariants({ size }), comboboxInputStyles(), className),
|
|
1028
1042
|
value: text,
|
|
1029
1043
|
onClick: (event) => {
|
|
1030
1044
|
onClick?.(event);
|
|
@@ -1122,7 +1136,7 @@ var Combobox = (props) => {
|
|
|
1122
1136
|
close();
|
|
1123
1137
|
focus();
|
|
1124
1138
|
},
|
|
1125
|
-
className: cn3(controlVariants({ size
|
|
1139
|
+
className: cn3(controlVariants({ size }), "gridui-u-select--flex gridui-u-select--w-auto gridui-u-select--shrink-0 gridui-u-select--items-center gridui-u-select--justify-center gridui-u-select--min-w-(--gridui-control-size) gridui-u-select--cursor-pointer"),
|
|
1126
1140
|
children: /* @__PURE__ */ jsx7(
|
|
1127
1141
|
X,
|
|
1128
1142
|
{
|
|
@@ -1155,6 +1169,7 @@ var Combobox = (props) => {
|
|
|
1155
1169
|
/* @__PURE__ */ jsxs5(
|
|
1156
1170
|
SelectionPopup,
|
|
1157
1171
|
{
|
|
1172
|
+
density,
|
|
1158
1173
|
open,
|
|
1159
1174
|
container: portalContainer,
|
|
1160
1175
|
ref: popupRef,
|
|
@@ -1248,6 +1263,8 @@ var MultiSelect = (props) => {
|
|
|
1248
1263
|
errorLabel,
|
|
1249
1264
|
resultCountLabel,
|
|
1250
1265
|
selectionAppearance = "filled",
|
|
1266
|
+
size = "medium",
|
|
1267
|
+
density = "comfortable",
|
|
1251
1268
|
...restProps
|
|
1252
1269
|
} = props;
|
|
1253
1270
|
const search = useRef8(null);
|
|
@@ -1321,7 +1338,7 @@ var MultiSelect = (props) => {
|
|
|
1321
1338
|
ref.current = element;
|
|
1322
1339
|
}
|
|
1323
1340
|
},
|
|
1324
|
-
className: cn4(controlVariants2(), "gridui-u-select--flex gridui-u-select--flex-1 gridui-u-select--items-center gridui-u-select--gap-gridui-8 gridui-u-select--text-start", className),
|
|
1341
|
+
className: cn4(controlVariants2({ size }), "gridui-u-select--flex gridui-u-select--flex-1 gridui-u-select--items-center gridui-u-select--gap-gridui-8 gridui-u-select--text-start", className),
|
|
1325
1342
|
onKeyDown: (event) => {
|
|
1326
1343
|
onKeyDown?.(event);
|
|
1327
1344
|
if (!event.defaultPrevented && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
|
|
@@ -1357,7 +1374,7 @@ var MultiSelect = (props) => {
|
|
|
1357
1374
|
type: "button",
|
|
1358
1375
|
"aria-label": clearLabel,
|
|
1359
1376
|
disabled: disabled || readOnly || required || !selected.length,
|
|
1360
|
-
className: cn4(controlVariants2(), "gridui-u-select--flex gridui-u-select--w-auto gridui-u-select--shrink-0 gridui-u-select--items-center gridui-u-select--justify-center gridui-u-select--min-w-
|
|
1377
|
+
className: cn4(controlVariants2({ size }), "gridui-u-select--flex gridui-u-select--w-auto gridui-u-select--shrink-0 gridui-u-select--items-center gridui-u-select--justify-center gridui-u-select--min-w-(--gridui-control-size) gridui-u-select--cursor-pointer"),
|
|
1361
1378
|
onClick: () => {
|
|
1362
1379
|
change([]);
|
|
1363
1380
|
control.current?.focus();
|
|
@@ -1417,6 +1434,7 @@ var MultiSelect = (props) => {
|
|
|
1417
1434
|
/* @__PURE__ */ jsxs6(
|
|
1418
1435
|
SelectionPopup,
|
|
1419
1436
|
{
|
|
1437
|
+
density,
|
|
1420
1438
|
open,
|
|
1421
1439
|
container: portalContainer,
|
|
1422
1440
|
ref: popup,
|
|
@@ -1444,7 +1462,7 @@ var MultiSelect = (props) => {
|
|
|
1444
1462
|
"aria-controls": `${id}-list`,
|
|
1445
1463
|
"aria-activedescendant": activeOptionId,
|
|
1446
1464
|
value: query ?? "",
|
|
1447
|
-
className: cn4(controlVariants2({ size
|
|
1465
|
+
className: cn4(controlVariants2({ size }), "gridui-u-select--m-gridui-8 gridui-u-select--w-auto gridui-u-select--shrink-0"),
|
|
1448
1466
|
onChange: (event) => {
|
|
1449
1467
|
searchOptions.changeQuery(event.target.value);
|
|
1450
1468
|
},
|
|
@@ -1636,10 +1654,10 @@ var SelectOptionItem = (props) => {
|
|
|
1636
1654
|
import { overlayListStyles as overlayListStyles2 } from "@gridui/overlay";
|
|
1637
1655
|
import { cn as cn5 } from "@gridui/style-utils";
|
|
1638
1656
|
import { cva as cva3 } from "class-variance-authority";
|
|
1639
|
-
var selectContentStyles =
|
|
1640
|
-
overlayListStyles2(),
|
|
1657
|
+
var selectContentStyles = (density) => cn5(
|
|
1658
|
+
overlayListStyles2({ density }),
|
|
1641
1659
|
"gridui-select-content gridui-u-select--box-border gridui-u-select--relative gridui-u-select--flex gridui-u-select--flex-col gridui-u-select--overflow-hidden gridui-u-select--min-w-0 gridui-u-select--w-(--anchor-width) gridui-u-select--max-w-(--available-width) gridui-u-select--max-h-(--available-height)"
|
|
1642
|
-
)
|
|
1660
|
+
);
|
|
1643
1661
|
var selectScrollArrowStyles = cva3("gridui-u-select--absolute gridui-u-select--inset-x-0 gridui-u-select--z-(--gridui-z-content) gridui-u-select--flex gridui-u-select--h-gridui-24 gridui-u-select--items-center gridui-u-select--justify-center gridui-u-select--bg-background gridui-u-select--text-foreground", {
|
|
1644
1662
|
variants: {
|
|
1645
1663
|
direction: {
|
|
@@ -1666,7 +1684,8 @@ var Select = (props) => {
|
|
|
1666
1684
|
defaultValue = "",
|
|
1667
1685
|
onValueChange,
|
|
1668
1686
|
placeholder,
|
|
1669
|
-
|
|
1687
|
+
size = "medium",
|
|
1688
|
+
density = "comfortable",
|
|
1670
1689
|
position = "popper",
|
|
1671
1690
|
clearLabel,
|
|
1672
1691
|
required,
|
|
@@ -1750,7 +1769,7 @@ var Select = (props) => {
|
|
|
1750
1769
|
ref.current = element;
|
|
1751
1770
|
}
|
|
1752
1771
|
},
|
|
1753
|
-
className: cn6(controlVariants3({ size
|
|
1772
|
+
className: cn6(controlVariants3({ size }), "gridui-u-select--flex gridui-u-select--flex-1 gridui-u-select--items-center gridui-u-select--gap-gridui-8 gridui-u-select--text-start", className),
|
|
1754
1773
|
children: [
|
|
1755
1774
|
selected?.icon && /* @__PURE__ */ jsx10(
|
|
1756
1775
|
"span",
|
|
@@ -1794,7 +1813,7 @@ var Select = (props) => {
|
|
|
1794
1813
|
change("");
|
|
1795
1814
|
controlRef.current?.focus();
|
|
1796
1815
|
},
|
|
1797
|
-
className: cn6(controlVariants3({ size
|
|
1816
|
+
className: cn6(controlVariants3({ size }), "gridui-u-select--flex gridui-u-select--w-auto gridui-u-select--shrink-0 gridui-u-select--items-center gridui-u-select--justify-center gridui-u-select--min-w-(--gridui-control-size) gridui-u-select--cursor-pointer"),
|
|
1798
1817
|
children: /* @__PURE__ */ jsx10(
|
|
1799
1818
|
X3,
|
|
1800
1819
|
{
|
|
@@ -1832,6 +1851,7 @@ var Select = (props) => {
|
|
|
1832
1851
|
Primitive6.Content,
|
|
1833
1852
|
{
|
|
1834
1853
|
...interactionLayerProps2,
|
|
1854
|
+
"data-density": density,
|
|
1835
1855
|
position,
|
|
1836
1856
|
align: "start",
|
|
1837
1857
|
sideOffset: 8,
|
|
@@ -1842,7 +1862,7 @@ var Select = (props) => {
|
|
|
1842
1862
|
"data-side": "none",
|
|
1843
1863
|
style: { width: triggerWidth }
|
|
1844
1864
|
} : {},
|
|
1845
|
-
className: selectContentStyles(),
|
|
1865
|
+
className: selectContentStyles(density),
|
|
1846
1866
|
dir,
|
|
1847
1867
|
onCloseAutoFocus: (event) => {
|
|
1848
1868
|
event.preventDefault();
|