@midas-ds/components 3.1.0 → 4.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/CHANGELOG.md +39 -0
- package/button/Button.d.ts +1 -0
- package/calendar/Calendar.d.ts +6 -0
- package/calendar/index.d.ts +1 -0
- package/date-field/DateField.d.ts +8 -0
- package/date-field/index.d.ts +1 -0
- package/index.cjs +33 -28
- package/index.css +1 -1
- package/index.d.ts +2 -1
- package/index.js +8120 -8317
- package/modal/Dialog.d.ts +18 -0
- package/modal/index.d.ts +1 -1
- package/package.json +1 -1
- package/select/HiddenMultiSelect.d.ts +47 -0
- package/select/Select.d.ts +73 -10
- package/select/SelectListBox.d.ts +9 -0
- package/select/SelectPopover.d.ts +10 -0
- package/select/useMultiSelect.d.ts +21 -0
- package/select/useMultiSelectListState.d.ts +15 -0
- package/select/useMultiSelectState.d.ts +25 -0
- package/table/Table.d.ts +1 -0
- package/utils/useObserveElement.d.ts +4 -0
- package/modal/Modal.d.ts +0 -13
- package/multi-select/MultiSelect.d.ts +0 -28
- package/multi-select/index.d.ts +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AriaDialogProps } from 'react-aria';
|
|
2
|
+
import { OverlayTriggerProps } from '@react-types/overlays';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
interface DialogProps extends AriaDialogProps {
|
|
5
|
+
/**
|
|
6
|
+
* An optional title for the dialog. If omitted, please provide an aria-label for accessibility.
|
|
7
|
+
*/
|
|
8
|
+
title?: React.ReactNode;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare const Dialog: React.FC<DialogProps>;
|
|
12
|
+
export declare const ModalTrigger: React.FC<OverlayTriggerProps & {
|
|
13
|
+
isDismissable?: boolean;
|
|
14
|
+
} & {
|
|
15
|
+
children: (close: () => void) => JSX.Element;
|
|
16
|
+
label?: string | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export {};
|
package/modal/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Dialog, ModalTrigger } from './Dialog';
|
package/package.json
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FocusableElement, RefObject } from '@react-types/shared';
|
|
2
|
+
import { default as React, ReactNode } from 'react';
|
|
3
|
+
import { MultiSelectState } from './useMultiSelectState';
|
|
4
|
+
export interface AriaHiddenMultiSelectProps {
|
|
5
|
+
/**
|
|
6
|
+
* 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).
|
|
7
|
+
*/
|
|
8
|
+
autoComplete?: string;
|
|
9
|
+
/** The text label for the select. */
|
|
10
|
+
label?: ReactNode;
|
|
11
|
+
/** HTML form input name. */
|
|
12
|
+
name?: string;
|
|
13
|
+
/** Sets the disabled state of the select and input. */
|
|
14
|
+
isDisabled?: boolean;
|
|
15
|
+
/** Sets the required state of the select and input. */
|
|
16
|
+
isRequired?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface HiddenMultiSelectProps<T> extends AriaHiddenMultiSelectProps {
|
|
19
|
+
/** State for the select. */
|
|
20
|
+
state: MultiSelectState<T>;
|
|
21
|
+
/** A ref to the trigger element. */
|
|
22
|
+
triggerRef: RefObject<FocusableElement | null>;
|
|
23
|
+
}
|
|
24
|
+
interface AriaHiddenMultiSelectOptions extends AriaHiddenMultiSelectProps {
|
|
25
|
+
/** A ref to the hidden `<select>` element. */
|
|
26
|
+
selectRef?: RefObject<HTMLSelectElement | null>;
|
|
27
|
+
}
|
|
28
|
+
interface HiddenMultiSelectAria {
|
|
29
|
+
/** Props for the container element. */
|
|
30
|
+
containerProps: React.HTMLAttributes<FocusableElement>;
|
|
31
|
+
/** Props for the hidden input element. */
|
|
32
|
+
inputProps: React.InputHTMLAttributes<HTMLInputElement>;
|
|
33
|
+
/** Props for the hidden select element. */
|
|
34
|
+
selectProps: React.SelectHTMLAttributes<HTMLSelectElement>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Provides the behavior and accessibility implementation for a hidden `<select>` element, which
|
|
38
|
+
* can be used in combination with `useSelect` to support browser form autofill, mobile form
|
|
39
|
+
* navigation, and native HTML form submission.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useHiddenMultiSelect<T>({ autoComplete, name, isDisabled, isRequired, selectRef, }: AriaHiddenMultiSelectOptions, state: MultiSelectState<T>, triggerRef: RefObject<FocusableElement | null>): HiddenMultiSelectAria;
|
|
42
|
+
/**
|
|
43
|
+
* Renders a hidden native `<select>` element, which can be used to support browser
|
|
44
|
+
* form autofill, mobile form navigation, and native form submission.
|
|
45
|
+
*/
|
|
46
|
+
export declare function HiddenMultiSelect<T>(props: HiddenMultiSelectProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
47
|
+
export {};
|
package/select/Select.d.ts
CHANGED
|
@@ -1,11 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { CollectionChildren } from '@react-types/shared';
|
|
2
|
+
import { useMultiSelectState } from './useMultiSelectState';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export type OptionItem = {
|
|
5
|
+
children?: never;
|
|
6
|
+
id: string;
|
|
7
|
+
name: string | React.ReactNode;
|
|
8
|
+
/** Textual representation of `name` in case it is not a string. Used for searching. */
|
|
9
|
+
textValue?: string;
|
|
10
|
+
/** Allow additional properties for an option. */
|
|
11
|
+
[prop: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
type OptionSection = {
|
|
14
|
+
children: OptionItem[];
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
export type Option = OptionItem | OptionSection;
|
|
18
|
+
export type SelectionMode = 'single' | 'multiple';
|
|
19
|
+
type SelectProps = {
|
|
20
|
+
/** Whether the element should receive focus on render. */
|
|
21
|
+
autoFocus?: boolean;
|
|
22
|
+
children: CollectionChildren<Option>;
|
|
23
|
+
/** Sets the CSS [`className`](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. */
|
|
24
|
+
className?: string;
|
|
25
|
+
/** Sets the default open state of the field (uncontrolled). */
|
|
26
|
+
defaultOpen?: boolean;
|
|
27
|
+
/** The initial selected keys in the collection (uncontrolled). */
|
|
28
|
+
defaultSelectedKeys?: Parameters<typeof useMultiSelectState>['0']['defaultSelectedKeys'];
|
|
29
|
+
/** The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with. */
|
|
30
|
+
disabledKeys?: Parameters<typeof useMultiSelectState>['0']['disabledKeys'];
|
|
31
|
+
excludeFromTabOrder?: boolean;
|
|
32
|
+
items: Option[];
|
|
33
|
+
/** Whether the field can be emptied. */
|
|
34
|
+
isClearable?: boolean;
|
|
35
|
+
/** Whether the field is disabled. */
|
|
36
|
+
isDisabled?: boolean;
|
|
37
|
+
/** Whether to show a button to select all items. */
|
|
38
|
+
isSelectableAll?: boolean;
|
|
39
|
+
/** Sets the open state of the field (controlled). */
|
|
40
|
+
isOpen?: boolean;
|
|
41
|
+
/** The content to display as the label. */
|
|
42
|
+
label: string;
|
|
43
|
+
/** Optional description */
|
|
5
44
|
description?: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
45
|
+
/** Placeholder value */
|
|
46
|
+
placeholder?: string;
|
|
47
|
+
/** Show selected items as tags below select */
|
|
48
|
+
showTags?: boolean;
|
|
49
|
+
/** Handler that is called when the select's open state changes. */
|
|
50
|
+
onOpenChange?: Parameters<typeof useMultiSelectState>['0']['onOpenChange'];
|
|
51
|
+
/** Handler that is called when the selection changes. */
|
|
52
|
+
onSelectionChange?: Parameters<typeof useMultiSelectState>['0']['onSelectionChange'];
|
|
53
|
+
/** The currently selected keys in the collection (controlled). */
|
|
54
|
+
selectedKeys?: Parameters<typeof useMultiSelectState>['0']['selectedKeys'];
|
|
55
|
+
/**
|
|
56
|
+
* The type of selection that is allowed in the collection.
|
|
57
|
+
* @default 'single'
|
|
58
|
+
*/
|
|
59
|
+
selectionMode: SelectionMode;
|
|
60
|
+
/** The selection is valid or not */
|
|
61
|
+
isInvalid?: boolean;
|
|
62
|
+
/** Error message to be displayed in case of invalid state*/
|
|
63
|
+
errorMessage?: string;
|
|
64
|
+
/** Whether the field is required. */
|
|
65
|
+
isRequired?: boolean;
|
|
66
|
+
/** Name of the field, for uncontrolled use */
|
|
67
|
+
name?: string;
|
|
68
|
+
};
|
|
69
|
+
export declare const SelectComponent: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
70
|
+
export declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "children" | "items"> & {
|
|
71
|
+
/** Item objects in the collection. */
|
|
72
|
+
options: Option[];
|
|
73
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MultiSelectState } from './useMultiSelectState';
|
|
2
|
+
import { AriaListBoxOptions } from '@react-aria/listbox';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
interface ListBoxProps<T> extends AriaListBoxOptions<T> {
|
|
5
|
+
listBoxRef?: React.RefObject<HTMLUListElement>;
|
|
6
|
+
state: MultiSelectState<T>;
|
|
7
|
+
}
|
|
8
|
+
export declare const SelectListBox: <T>(props: ListBoxProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
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.VFC<PopoverProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AriaListBoxOptions } from 'react-aria';
|
|
2
|
+
import { HTMLAttributes, RefObject } from 'react';
|
|
3
|
+
import { MultiSelectProps as MultiSelectStateProps, MultiSelectState } from './useMultiSelectState';
|
|
4
|
+
import { AriaButtonProps } from '@react-types/button';
|
|
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 {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ListState } from '@react-stately/list';
|
|
2
|
+
import { Key, CollectionBase, MultipleSelection, Node } from '@react-types/shared';
|
|
3
|
+
export interface MultiSelectListProps<T> extends CollectionBase<T>, MultipleSelection {
|
|
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>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MenuTriggerState } from '@react-stately/menu';
|
|
2
|
+
import { Key } from 'react-aria';
|
|
3
|
+
import { MultiSelectListState } from './useMultiSelectListState';
|
|
4
|
+
import { OverlayTriggerProps } from '@react-types/overlays';
|
|
5
|
+
import { AsyncLoadable, CollectionBase, FocusableProps, InputBase, LabelableProps, MultipleSelection, TextInputBase, Validation, Selection } from '@react-types/shared';
|
|
6
|
+
import { FormValidationState } from '@react-stately/form';
|
|
7
|
+
/** Added this for a better output, will see how this plays out */
|
|
8
|
+
interface ArraySelection extends Omit<MultipleSelection, 'onSelectionChange'> {
|
|
9
|
+
onSelectionChange?: (value: Selection | Key | Key[]) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface MultiSelectProps<T> extends CollectionBase<T>, AsyncLoadable, Omit<InputBase, 'isReadOnly'>, Validation, LabelableProps, TextInputBase, ArraySelection, FocusableProps, OverlayTriggerProps {
|
|
12
|
+
/**
|
|
13
|
+
* Whether the menu should automatically flip direction when space is limited.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
shouldFlip?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface MultiSelectState<T> extends MultiSelectListState<T>, MenuTriggerState, FormValidationState {
|
|
19
|
+
/** Whether the select is currently focused. */
|
|
20
|
+
isFocused: boolean;
|
|
21
|
+
/** Sets whether the select is focused. */
|
|
22
|
+
setFocused(isFocused: boolean): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function useMultiSelectState<T extends object>(props: MultiSelectProps<T>): MultiSelectState<T>;
|
|
25
|
+
export {};
|
package/table/Table.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RowProps, TableHeaderProps, ColumnProps, TableProps as AriaTableProps, CellProps, TableBody } from 'react-aria-components';
|
|
2
2
|
export interface TableProps extends AriaTableProps {
|
|
3
|
+
/** @deprecated This variant will be replaced with a new scaling api accross all components. */
|
|
3
4
|
narrow?: boolean;
|
|
4
5
|
striped?: boolean;
|
|
5
6
|
}
|
package/modal/Modal.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
interface MidasModal extends React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> {
|
|
3
|
-
/** Id for accessibility */
|
|
4
|
-
id: string;
|
|
5
|
-
/** Heading for the modal window */
|
|
6
|
-
title: string;
|
|
7
|
-
/** Whether the modal is open or not */
|
|
8
|
-
isOpen: boolean;
|
|
9
|
-
/** State handler to toggle isOpen */
|
|
10
|
-
onOpenChange: (isOpen: boolean) => void;
|
|
11
|
-
}
|
|
12
|
-
export declare const Modal: React.FC<MidasModal>;
|
|
13
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ValidationResult } from 'react-aria-components';
|
|
2
|
-
import { Key } from 'react-stately';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
interface MidasMultiSelect {
|
|
5
|
-
/** Label for multiselect */
|
|
6
|
-
label: string;
|
|
7
|
-
/** Description for multiselect */
|
|
8
|
-
description?: string;
|
|
9
|
-
/** Array of items that will be included in the list */
|
|
10
|
-
items: {
|
|
11
|
-
name: string;
|
|
12
|
-
id: string;
|
|
13
|
-
}[];
|
|
14
|
-
/** Handler for when list of selected item is changed */
|
|
15
|
-
onSelectionChange?: (selectedKeys: Set<Key>) => void;
|
|
16
|
-
/** Control selected keys */
|
|
17
|
-
selectedKeys?: string[];
|
|
18
|
-
/** Set list of pre-selected keys, or 'all' */
|
|
19
|
-
defaultSelectedKeys?: string[] | 'all';
|
|
20
|
-
/** Set MultiSelect in disabled state */
|
|
21
|
-
isDisabled?: boolean;
|
|
22
|
-
/** Set MultiSelect in invalid state */
|
|
23
|
-
isInvalid?: boolean;
|
|
24
|
-
/** Set error message as string or as a validation function */
|
|
25
|
-
errorMessage?: string | ((validation: ValidationResult) => string) | undefined;
|
|
26
|
-
}
|
|
27
|
-
export declare const MultiSelect: React.FC<MidasMultiSelect>;
|
|
28
|
-
export {};
|
package/multi-select/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MultiSelect } from './MultiSelect';
|