@midas-ds/components 10.1.0 → 10.1.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/CHANGELOG.md +33 -0
- package/card/Card.d.ts +3 -0
- package/combobox/ComboBox.d.ts +9 -5
- package/combobox/index.d.ts +1 -1
- package/combobox/types.d.ts +6 -0
- package/combobox/utils.d.ts +3 -10
- package/index.cjs +39 -34
- package/index.css +1 -1
- package/index.d.ts +1 -0
- package/index.js +5449 -5514
- package/link/Link.d.ts +4 -1
- package/link-button/LinkButton.d.ts +24 -1
- package/list-box/ListBox.d.ts +4 -0
- package/list-box/ListBoxButton.d.ts +2 -0
- package/list-box/ListBoxItem.d.ts +3 -0
- package/list-box/ListBoxPopover.d.ts +3 -0
- package/list-box/ListBoxSection.d.ts +8 -0
- package/list-box/index.d.ts +6 -0
- package/list-box/types.d.ts +23 -0
- package/package.json +1 -1
- package/select/HiddenMultiSelect.d.ts +5 -4
- package/select/MultiSelectValueTag.d.ts +11 -0
- package/select/Select.d.ts +2 -77
- package/select/SelectFieldError.d.ts +8 -0
- package/select/SelectListBox.d.ts +4 -3
- package/select/SelectTrigger.d.ts +10 -0
- package/select/index.d.ts +1 -0
- package/select/types.d.ts +188 -0
- package/select/useMultiSelect.d.ts +4 -21
- package/select/useMultiSelectListState.d.ts +3 -15
- package/select/useMultiSelectState.d.ts +3 -19
- package/utils/test.d.ts +1 -1
- package/select/SelectPopover.d.ts +0 -10
- /package/{select → list-box}/SectionedListLayout.d.ts +0 -0
package/link/Link.d.ts
CHANGED
|
@@ -9,8 +9,11 @@ interface MidasLinkProps<C extends React.ElementType> {
|
|
|
9
9
|
/** Optional icon, placed to the left of the link */
|
|
10
10
|
icon?: LucideIcon;
|
|
11
11
|
className?: string;
|
|
12
|
+
/** Replace base component with any Client Side Routing link instead.
|
|
13
|
+
* @see {@link https://designsystem.migrationsverket.se/dev/client-side-routing/|Client side routing}
|
|
14
|
+
*/
|
|
12
15
|
as?: C;
|
|
13
16
|
}
|
|
14
17
|
export type LinkProps<C extends React.ElementType> = MidasLinkProps<C> & Omit<React.ComponentProps<C>, keyof MidasLinkProps<C>>;
|
|
15
|
-
export declare const Link: <C extends React.ElementType = (props: import('react-aria-components').LinkProps & React.RefAttributes<HTMLAnchorElement>) => React.ReactElement | null>({ children, standalone, stretched, icon: IconComponent, className, as, ...rest }: LinkProps<C>) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const Link: <C extends React.ElementType = (props: import('react-aria-components').LinkProps & React.RefAttributes<HTMLAnchorElement>) => React.ReactElement | null>({ children, standalone, target, stretched, download, icon: IconComponent, className, as, ...rest }: LinkProps<C>) => import("react/jsx-runtime").JSX.Element;
|
|
16
19
|
export { RouterProvider };
|
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { Link as AriaLink, RouterProvider } from 'react-aria-components';
|
|
3
3
|
import { LucideIcon } from 'lucide-react';
|
|
4
|
+
import { Size } from '../common/types';
|
|
4
5
|
interface MidasLinkProps<C extends React.ElementType> {
|
|
5
6
|
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Primary button is used as a positive action in a flow. Always use one primary button and never a seconday button on it's own. When using just an icon you must pass an aria-label
|
|
9
|
+
*
|
|
10
|
+
* @default 'primary'
|
|
11
|
+
* */
|
|
6
12
|
variant?: 'primary' | 'secondary' | 'tertiary' | 'danger' | 'icon';
|
|
13
|
+
/**
|
|
14
|
+
* Adds width: 100%; for the button to span entire width of parent
|
|
15
|
+
*
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
7
18
|
fullwidth?: boolean;
|
|
19
|
+
/** Display the icon on the left or right side of the button text */
|
|
8
20
|
iconPlacement?: 'left' | 'right';
|
|
21
|
+
/** Add an icon from lucide-react
|
|
22
|
+
*
|
|
23
|
+
* @see {@link https://lucide.dev/icons/|Lucide}
|
|
24
|
+
*/
|
|
9
25
|
icon?: LucideIcon; /**Optional icon prop */
|
|
10
26
|
className?: string;
|
|
27
|
+
/** Replace base component with any Client Side Routing link instead.
|
|
28
|
+
* @see {@link https://designsystem.migrationsverket.se/dev/client-side-routing/|Client side routing}
|
|
29
|
+
*/
|
|
11
30
|
as?: C;
|
|
31
|
+
/** Component size (large: height 48px, medium: height 40px)
|
|
32
|
+
* @default 'large'
|
|
33
|
+
**/
|
|
34
|
+
size?: Size;
|
|
12
35
|
}
|
|
13
36
|
export type LinkButtonProps<C extends React.ElementType> = MidasLinkProps<C> & Omit<React.ComponentProps<C>, keyof MidasLinkProps<C>>;
|
|
14
37
|
/**
|
|
15
38
|
* A link to be used when a user expects a button but web technologies force us to use a a-tag
|
|
16
39
|
* */
|
|
17
|
-
export declare const LinkButton: <C extends React.ElementType = (props: import('react-aria-components').LinkProps & React.RefAttributes<HTMLAnchorElement>) => React.ReactElement | null>({ children, variant, fullwidth, icon: IconComponent, iconPlacement, className, as, ...rest }: LinkButtonProps<C>) => import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export declare const LinkButton: <C extends React.ElementType = (props: import('react-aria-components').LinkProps & React.RefAttributes<HTMLAnchorElement>) => React.ReactElement | null>({ children, variant, fullwidth, icon: IconComponent, iconPlacement, className, as, size, ...rest }: LinkButtonProps<C>) => import("react/jsx-runtime").JSX.Element;
|
|
18
41
|
export { RouterProvider };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ListBoxProps } from 'react-aria-components';
|
|
2
|
+
import { ListBoxOption } from './types';
|
|
3
|
+
import { Node } from '@react-types/shared';
|
|
4
|
+
export declare const ListBox: <T extends ListBoxOption | Node<ListBoxOption>>({ className, children, ...rest }: ListBoxProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ListBoxSectionProps as AriaListBoxSectionProps } from 'react-aria-components';
|
|
2
|
+
import { ListBoxSectionElement } from './types';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export interface ListBoxSectionProps<T extends ListBoxSectionElement> extends Omit<AriaListBoxSectionProps<T>, 'children'> {
|
|
5
|
+
name: React.ReactNode;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const ListBoxSection: <T extends ListBoxSectionElement>({ children, name, ...rest }: ListBoxSectionProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Key } from 'react-aria-components';
|
|
2
|
+
export type ListBoxItemElement = {
|
|
3
|
+
children?: never;
|
|
4
|
+
id: Key;
|
|
5
|
+
name: string | React.ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Textual representation of `name` in case it is not a string. Used for searching.
|
|
8
|
+
*/
|
|
9
|
+
textValue?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Additional properties.
|
|
12
|
+
*/
|
|
13
|
+
[prop: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
export type ListBoxSectionElement = {
|
|
16
|
+
children: ListBoxItemElement[];
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* Additional properties for backwards compatibility.
|
|
20
|
+
*/
|
|
21
|
+
[prop: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
export type ListBoxOption = ListBoxItemElement | ListBoxSectionElement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FocusableElement, RefObject } from '@react-types/shared';
|
|
2
2
|
import { default as React, ReactNode } from 'react';
|
|
3
|
-
import { MultiSelectState } from './
|
|
3
|
+
import { MultiSelectState } from './types';
|
|
4
|
+
import { ListBoxOption } from '../list-box';
|
|
4
5
|
export interface AriaHiddenMultiSelectProps {
|
|
5
6
|
/**
|
|
6
7
|
* Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).
|
|
@@ -15,7 +16,7 @@ export interface AriaHiddenMultiSelectProps {
|
|
|
15
16
|
/** Sets the required state of the select and input. */
|
|
16
17
|
isRequired?: boolean;
|
|
17
18
|
}
|
|
18
|
-
export interface HiddenMultiSelectProps<T> extends AriaHiddenMultiSelectProps {
|
|
19
|
+
export interface HiddenMultiSelectProps<T extends ListBoxOption> extends AriaHiddenMultiSelectProps {
|
|
19
20
|
/** State for the select. */
|
|
20
21
|
state: MultiSelectState<T>;
|
|
21
22
|
/** A ref to the trigger element. */
|
|
@@ -38,10 +39,10 @@ interface HiddenMultiSelectAria {
|
|
|
38
39
|
* can be used in combination with `useSelect` to support browser form autofill, mobile form
|
|
39
40
|
* navigation, and native HTML form submission.
|
|
40
41
|
*/
|
|
41
|
-
export declare function useHiddenMultiSelect<T>({ autoComplete, name, isDisabled, isRequired, selectRef, }: AriaHiddenMultiSelectOptions, state: MultiSelectState<T>, triggerRef: RefObject<FocusableElement | null>): HiddenMultiSelectAria;
|
|
42
|
+
export declare function useHiddenMultiSelect<T extends ListBoxOption>({ autoComplete, name, isDisabled, isRequired, selectRef, }: AriaHiddenMultiSelectOptions, state: MultiSelectState<T>, triggerRef: RefObject<FocusableElement | null>): HiddenMultiSelectAria;
|
|
42
43
|
/**
|
|
43
44
|
* Renders a hidden native `<select>` element, which can be used to support browser
|
|
44
45
|
* form autofill, mobile form navigation, and native form submission.
|
|
45
46
|
*/
|
|
46
|
-
export declare function HiddenMultiSelect<T>(props: HiddenMultiSelectProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
47
|
+
export declare function HiddenMultiSelect<T extends ListBoxOption>(props: HiddenMultiSelectProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
47
48
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MultiSelectState, SelectProps } from './types';
|
|
2
|
+
import { ListBoxOption } from '../list-box';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
interface MultiSelectValueTagProps extends SelectProps {
|
|
5
|
+
state: MultiSelectState<ListBoxOption>;
|
|
6
|
+
parentWidth: number;
|
|
7
|
+
onClear: () => void;
|
|
8
|
+
triggerRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
9
|
+
}
|
|
10
|
+
export declare const MultiSelectValueTag: React.FC<MultiSelectValueTagProps>;
|
|
11
|
+
export {};
|
package/select/Select.d.ts
CHANGED
|
@@ -1,80 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMultiSelectState } from './useMultiSelectState';
|
|
3
|
-
import { Size } from '../common/types';
|
|
1
|
+
import { SelectProps } from './types';
|
|
4
2
|
import * as React from 'react';
|
|
5
|
-
export type OptionItem = {
|
|
6
|
-
children?: never;
|
|
7
|
-
id: Key;
|
|
8
|
-
name: string | React.ReactNode;
|
|
9
|
-
/** Textual representation of `name` in case it is not a string. Used for searching. */
|
|
10
|
-
textValue?: string;
|
|
11
|
-
/** Allow additional properties for an option. */
|
|
12
|
-
[prop: string]: unknown;
|
|
13
|
-
};
|
|
14
|
-
type OptionSection = {
|
|
15
|
-
children: OptionItem[];
|
|
16
|
-
name: string;
|
|
17
|
-
};
|
|
18
|
-
export type Option = OptionItem | OptionSection;
|
|
19
|
-
export type SelectionMode = 'single' | 'multiple';
|
|
20
|
-
export type SelectProps = {
|
|
21
|
-
/** Whether the element should receive focus on render. */
|
|
22
|
-
autoFocus?: boolean;
|
|
23
|
-
children: CollectionChildren<Option>;
|
|
24
|
-
/** Sets the CSS [`className`](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. */
|
|
25
|
-
className?: string;
|
|
26
|
-
/** Sets the default open state of the field (uncontrolled). */
|
|
27
|
-
defaultOpen?: boolean;
|
|
28
|
-
/** The initial selected keys in the collection (uncontrolled). */
|
|
29
|
-
defaultSelectedKeys?: Parameters<typeof useMultiSelectState>['0']['defaultSelectedKeys'];
|
|
30
|
-
/** The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with. */
|
|
31
|
-
disabledKeys?: Parameters<typeof useMultiSelectState>['0']['disabledKeys'];
|
|
32
|
-
excludeFromTabOrder?: boolean;
|
|
33
|
-
items: Option[];
|
|
34
|
-
/** Whether the field can be emptied. */
|
|
35
|
-
isClearable?: boolean;
|
|
36
|
-
/** Whether the field is disabled. */
|
|
37
|
-
isDisabled?: boolean;
|
|
38
|
-
/** Whether to show a button to select all items. */
|
|
39
|
-
isSelectableAll?: boolean;
|
|
40
|
-
/** Sets the open state of the field (controlled). */
|
|
41
|
-
isOpen?: boolean;
|
|
42
|
-
/** The content to display as the label. */
|
|
43
|
-
label: string;
|
|
44
|
-
/** Optional description */
|
|
45
|
-
description?: string;
|
|
46
|
-
/** Placeholder value */
|
|
47
|
-
placeholder?: string;
|
|
48
|
-
/** Show selected items as tags below select */
|
|
49
|
-
showTags?: boolean;
|
|
50
|
-
/** Handler that is called when the select's open state changes. */
|
|
51
|
-
onOpenChange?: Parameters<typeof useMultiSelectState>['0']['onOpenChange'];
|
|
52
|
-
/** Handler that is called when the selection changes. */
|
|
53
|
-
onSelectionChange?: Parameters<typeof useMultiSelectState>['0']['onSelectionChange'];
|
|
54
|
-
/** The currently selected keys in the collection (controlled). */
|
|
55
|
-
selectedKeys?: Parameters<typeof useMultiSelectState>['0']['selectedKeys'];
|
|
56
|
-
/**
|
|
57
|
-
* The type of selection that is allowed in the collection.
|
|
58
|
-
* @default 'single'
|
|
59
|
-
*/
|
|
60
|
-
selectionMode: SelectionMode;
|
|
61
|
-
/** The selection is valid or not */
|
|
62
|
-
isInvalid?: boolean;
|
|
63
|
-
/** Error message to be displayed in case of invalid state*/
|
|
64
|
-
errorMessage?: string;
|
|
65
|
-
/** Whether the field is required. */
|
|
66
|
-
isRequired?: boolean;
|
|
67
|
-
/** Name of the field, for uncontrolled use */
|
|
68
|
-
name?: string;
|
|
69
|
-
errorPosition?: 'top' | 'bottom';
|
|
70
|
-
/** Component size (large: height 48px, medium: height 40px)
|
|
71
|
-
* @default 'large'
|
|
72
|
-
* */
|
|
73
|
-
size?: Size;
|
|
74
|
-
};
|
|
75
|
-
export declare const SelectComponent: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
76
3
|
export declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "children" | "items"> & {
|
|
77
|
-
|
|
78
|
-
options: Option[];
|
|
4
|
+
options: import('..').ListBoxOption[];
|
|
79
5
|
} & React.RefAttributes<HTMLButtonElement>>;
|
|
80
|
-
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ListBoxOption } from '../list-box';
|
|
2
|
+
import { MultiSelectState, SelectProps } from './types';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
interface SelectFieldErrorProps extends SelectProps {
|
|
5
|
+
state: MultiSelectState<ListBoxOption>;
|
|
6
|
+
}
|
|
7
|
+
export declare const SelectFieldError: React.FC<SelectFieldErrorProps>;
|
|
8
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListBoxOption } from '../list-box';
|
|
2
2
|
import { AriaListBoxOptions } from '@react-aria/listbox';
|
|
3
|
-
|
|
3
|
+
import { MultiSelectState } from './types';
|
|
4
|
+
interface ListBoxProps<T extends ListBoxOption> extends AriaListBoxOptions<T> {
|
|
4
5
|
state: MultiSelectState<T>;
|
|
5
6
|
}
|
|
6
|
-
export declare const SelectListBox: <T>({ state, ...rest }: ListBoxProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const SelectListBox: <T extends ListBoxOption>({ state, ...rest }: ListBoxProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AriaButtonProps } from 'react-aria';
|
|
3
|
+
import { SelectProps, MultiSelectState } from './types';
|
|
4
|
+
import { ListBoxOption } from '../list-box';
|
|
5
|
+
interface SelectTriggerProps extends Omit<SelectProps, 'children'>, AriaButtonProps<'button'> {
|
|
6
|
+
state: MultiSelectState<ListBoxOption>;
|
|
7
|
+
triggerRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
8
|
+
}
|
|
9
|
+
export declare const SelectTrigger: React.FC<SelectTriggerProps>;
|
|
10
|
+
export {};
|
package/select/index.d.ts
CHANGED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { MenuTriggerState } from '@react-stately/menu';
|
|
2
|
+
import { FormValidationState } from '@react-stately/form';
|
|
3
|
+
import { OverlayTriggerProps } from '@react-types/overlays';
|
|
4
|
+
import { ListState } from '@react-stately/list';
|
|
5
|
+
import { AsyncLoadable, CollectionBase, FocusableProps, InputBase, LabelableProps, MultipleSelection, TextInputBase, Validation, Key, Node, CollectionChildren } from '@react-types/shared';
|
|
6
|
+
import { HTMLAttributes } from 'react';
|
|
7
|
+
import { AriaListBoxOptions } from 'react-aria';
|
|
8
|
+
import { AriaButtonProps } from '@react-types/button';
|
|
9
|
+
import { AriaSelectProps } from '@react-types/select';
|
|
10
|
+
import { Size } from '../common/types';
|
|
11
|
+
import { ListBoxItemElement, ListBoxOption, ListBoxSectionElement } from '../list-box/';
|
|
12
|
+
/**
|
|
13
|
+
* Props used for setting up the list state
|
|
14
|
+
*/
|
|
15
|
+
export interface MultiSelectListProps<T extends ListBoxOption> extends CollectionBase<T>, MultipleSelection {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The state of the select list
|
|
19
|
+
*/
|
|
20
|
+
export interface MultiSelectListState<T extends ListBoxOption> extends ListState<T> {
|
|
21
|
+
/**
|
|
22
|
+
* The keys for the currently selected items.
|
|
23
|
+
*/
|
|
24
|
+
selectedKeys: Set<Key>;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the selected keys.
|
|
27
|
+
*/
|
|
28
|
+
setSelectedKeys(keys: Iterable<Key>): void;
|
|
29
|
+
/**
|
|
30
|
+
* The value of the currently selected items.
|
|
31
|
+
*/
|
|
32
|
+
selectedItems: Node<T>[] | null;
|
|
33
|
+
/**
|
|
34
|
+
* The type of selection.
|
|
35
|
+
*/
|
|
36
|
+
selectionMode: MultiSelectListProps<T>['selectionMode'];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Props used for setting up the select component state
|
|
40
|
+
*/
|
|
41
|
+
export interface MultiSelectStateProps<T extends ListBoxOption> extends MultiSelectListProps<T>, AsyncLoadable, FocusableProps, LabelableProps, Omit<InputBase, 'isReadOnly'>, OverlayTriggerProps, TextInputBase, Validation {
|
|
42
|
+
/**
|
|
43
|
+
* Whether the menu should automatically flip direction when space is limited.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
shouldFlip?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The state of the select component
|
|
50
|
+
*/
|
|
51
|
+
export interface MultiSelectState<T extends ListBoxOption> extends MultiSelectListState<T>, MenuTriggerState, FormValidationState {
|
|
52
|
+
/**
|
|
53
|
+
* Whether the select is currently focused.
|
|
54
|
+
*/
|
|
55
|
+
isFocused: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Sets whether the select is focused.
|
|
58
|
+
*/
|
|
59
|
+
setFocused(isFocused: boolean): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Props for setting up the select component parts
|
|
63
|
+
*/
|
|
64
|
+
export interface MultiSelectProps<T extends ListBoxOption> extends Omit<AriaSelectProps<T>, 'onSelectionChange'> {
|
|
65
|
+
/**
|
|
66
|
+
* Wheter to allow an empty selection or not
|
|
67
|
+
*/
|
|
68
|
+
disallowEmptySelection?: boolean;
|
|
69
|
+
onSelectionChange?: MultiSelectStateProps<T>['onSelectionChange'];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* DOM attributes for rendering the parts of the Select component
|
|
73
|
+
*/
|
|
74
|
+
export interface MultiSelectDOMProps<T extends ListBoxOption> {
|
|
75
|
+
/**
|
|
76
|
+
* Props for the label element.
|
|
77
|
+
*/
|
|
78
|
+
labelProps: HTMLAttributes<HTMLElement>;
|
|
79
|
+
/**
|
|
80
|
+
* Props for the popup trigger element.
|
|
81
|
+
*/
|
|
82
|
+
triggerProps: AriaButtonProps;
|
|
83
|
+
/**
|
|
84
|
+
* Props for the element representing the selected value.
|
|
85
|
+
*/
|
|
86
|
+
valueProps: HTMLAttributes<HTMLElement>;
|
|
87
|
+
/**
|
|
88
|
+
* Props for the popup.
|
|
89
|
+
*/
|
|
90
|
+
menuProps: AriaListBoxOptions<T>;
|
|
91
|
+
}
|
|
92
|
+
export type SelectionMode = 'single' | 'multiple';
|
|
93
|
+
export interface SelectProps extends MultiSelectStateProps<ListBoxOption> {
|
|
94
|
+
/**
|
|
95
|
+
* Whether the element should receive focus on render.
|
|
96
|
+
*/
|
|
97
|
+
autoFocus?: boolean;
|
|
98
|
+
children: CollectionChildren<ListBoxOption>;
|
|
99
|
+
/**
|
|
100
|
+
* Sets the CSS [`className`](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element.
|
|
101
|
+
*/
|
|
102
|
+
className?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Sets the default open state of the field (uncontrolled).
|
|
105
|
+
*/
|
|
106
|
+
defaultOpen?: boolean;
|
|
107
|
+
excludeFromTabOrder?: boolean;
|
|
108
|
+
items: ListBoxOption[];
|
|
109
|
+
/**
|
|
110
|
+
* Whether the field can be emptied.
|
|
111
|
+
* @default true
|
|
112
|
+
*/
|
|
113
|
+
isClearable?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Whether the field is disabled.
|
|
116
|
+
*/
|
|
117
|
+
isDisabled?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Whether to show a button to select all items.
|
|
120
|
+
*/
|
|
121
|
+
isSelectableAll?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Sets the open state of the field (controlled).
|
|
124
|
+
*/
|
|
125
|
+
isOpen?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* The content to display as the label.
|
|
128
|
+
*/
|
|
129
|
+
label: string;
|
|
130
|
+
/**
|
|
131
|
+
* Optional description
|
|
132
|
+
*/
|
|
133
|
+
description?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Placeholder value
|
|
136
|
+
*/
|
|
137
|
+
placeholder?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Show selected items as tags below select
|
|
140
|
+
*/
|
|
141
|
+
showTags?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* The type of selection that is allowed in the collection.
|
|
144
|
+
* @default 'single'
|
|
145
|
+
*/
|
|
146
|
+
selectionMode?: SelectionMode;
|
|
147
|
+
/**
|
|
148
|
+
* The selection is valid or not
|
|
149
|
+
*/
|
|
150
|
+
isInvalid?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Error message to be displayed in case of invalid state
|
|
153
|
+
*/
|
|
154
|
+
errorMessage?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Whether the field is required.
|
|
157
|
+
*/
|
|
158
|
+
isRequired?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Name of the field, for uncontrolled use
|
|
161
|
+
*/
|
|
162
|
+
name?: string;
|
|
163
|
+
/**
|
|
164
|
+
* The position of the error message
|
|
165
|
+
* @default "top"
|
|
166
|
+
*/
|
|
167
|
+
errorPosition?: 'top' | 'bottom';
|
|
168
|
+
/** Component size (large: height 48px, medium: height 40px)
|
|
169
|
+
* @default 'large'
|
|
170
|
+
*/
|
|
171
|
+
size?: Size;
|
|
172
|
+
}
|
|
173
|
+
export type SelectContainerProps = Omit<SelectProps, 'children' | 'items'> & {
|
|
174
|
+
/** Item objects in the collection. */
|
|
175
|
+
options: ListBoxOption[];
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* @deprecated since v10.1.0 please use `ListBoxOption` intead
|
|
179
|
+
*/
|
|
180
|
+
export type Option = ListBoxOption;
|
|
181
|
+
/**
|
|
182
|
+
* @deprecated since v10.1.0 please use `ListBoxItemElement` intead
|
|
183
|
+
*/
|
|
184
|
+
export type OptionItem = ListBoxItemElement;
|
|
185
|
+
/**
|
|
186
|
+
* @deprecated since v10.1.0 please use `ListBoxSectionElement` intead
|
|
187
|
+
*/
|
|
188
|
+
export type OptionSection = ListBoxSectionElement;
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { AriaSelectProps } from '@react-types/select';
|
|
6
|
-
type MultiSelectProps<T> = Omit<AriaSelectProps<T>, 'onSelectionChange'> & {
|
|
7
|
-
disallowEmptySelection?: boolean;
|
|
8
|
-
onSelectionChange?: MultiSelectStateProps<T>['onSelectionChange'];
|
|
9
|
-
};
|
|
10
|
-
interface MultiSelectAria<T> {
|
|
11
|
-
/** Props for the label element. */
|
|
12
|
-
labelProps: HTMLAttributes<HTMLElement>;
|
|
13
|
-
/** Props for the popup trigger element. */
|
|
14
|
-
triggerProps: AriaButtonProps;
|
|
15
|
-
/** Props for the element representing the selected value. */
|
|
16
|
-
valueProps: HTMLAttributes<HTMLElement>;
|
|
17
|
-
/** Props for the popup. */
|
|
18
|
-
menuProps: AriaListBoxOptions<T>;
|
|
19
|
-
}
|
|
20
|
-
export declare function useMultiSelect<T>(props: MultiSelectProps<T>, state: MultiSelectState<T>, ref: RefObject<HTMLElement>): MultiSelectAria<T>;
|
|
21
|
-
export {};
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { MultiSelectDOMProps, MultiSelectProps, MultiSelectState } from './types';
|
|
3
|
+
import { ListBoxOption } from '../list-box';
|
|
4
|
+
export declare function useMultiSelect<T extends ListBoxOption>(props: MultiSelectProps<T>, state: MultiSelectState<T>, ref: RefObject<HTMLElement>): MultiSelectDOMProps<T>;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
}
|
|
5
|
-
export interface MultiSelectListState<T> extends ListState<T> {
|
|
6
|
-
/** The keys for the currently selected items. */
|
|
7
|
-
selectedKeys: Set<Key>;
|
|
8
|
-
/** Sets the selected keys. */
|
|
9
|
-
setSelectedKeys(keys: Iterable<Key>): void;
|
|
10
|
-
/** The value of the currently selected items. */
|
|
11
|
-
selectedItems: Node<T>[] | null;
|
|
12
|
-
/** The type of selection. */
|
|
13
|
-
selectionMode: MultipleSelection['selectionMode'];
|
|
14
|
-
}
|
|
15
|
-
export declare function useMultiSelectListState<T extends object>(props: MultiSelectListProps<T>): MultiSelectListState<T>;
|
|
1
|
+
import { MultiSelectListProps, MultiSelectListState } from './types';
|
|
2
|
+
import { ListBoxOption } from '../list-box';
|
|
3
|
+
export declare function useMultiSelectListState<T extends ListBoxOption>(props: MultiSelectListProps<T>): MultiSelectListState<T>;
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { AsyncLoadable, CollectionBase, FocusableProps, InputBase, LabelableProps, MultipleSelection, TextInputBase, Validation } from '@react-types/shared';
|
|
5
|
-
import { FormValidationState } from '@react-stately/form';
|
|
6
|
-
export interface MultiSelectProps<T> extends CollectionBase<T>, AsyncLoadable, Omit<InputBase, 'isReadOnly'>, Validation, LabelableProps, TextInputBase, MultipleSelection, FocusableProps, OverlayTriggerProps {
|
|
7
|
-
/**
|
|
8
|
-
* Whether the menu should automatically flip direction when space is limited.
|
|
9
|
-
* @default true
|
|
10
|
-
*/
|
|
11
|
-
shouldFlip?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export interface MultiSelectState<T> extends MultiSelectListState<T>, MenuTriggerState, FormValidationState {
|
|
14
|
-
/** Whether the select is currently focused. */
|
|
15
|
-
isFocused: boolean;
|
|
16
|
-
/** Sets whether the select is focused. */
|
|
17
|
-
setFocused(isFocused: boolean): void;
|
|
18
|
-
}
|
|
19
|
-
export declare function useMultiSelectState<T extends object>(props: MultiSelectProps<T>): MultiSelectState<T>;
|
|
1
|
+
import { MultiSelectState, MultiSelectStateProps } from './types';
|
|
2
|
+
import { ListBoxOption } from '../list-box';
|
|
3
|
+
export declare function useMultiSelectState<T extends ListBoxOption>(props: MultiSelectStateProps<T>): MultiSelectState<T>;
|
package/utils/test.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A utility for making visual assertions in Storybook play tests based on the browsers "prefers-colors-scheme" setting
|
|
3
3
|
*/
|
|
4
|
-
export declare const lightDark: (light: string, dark: string) => string;
|
|
4
|
+
export declare const lightDark: (light: string, dark: string, mode?: "light" | "dark") => string;
|
|
5
5
|
/**
|
|
6
6
|
* Convert a CSS hex color to CSS rgb color
|
|
7
7
|
* ```
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
type PopoverProps = {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
className?: string;
|
|
5
|
-
isOpen?: boolean;
|
|
6
|
-
onClose: () => void;
|
|
7
|
-
triggerRef: React.RefObject<HTMLButtonElement>;
|
|
8
|
-
};
|
|
9
|
-
export declare const SelectPopover: React.FC<PopoverProps>;
|
|
10
|
-
export {};
|
|
File without changes
|