@dt-dds/react-dropdown 1.0.0-beta.67 → 1.0.0-beta.69
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 +30 -0
- package/README.md +28 -55
- package/dist/index.d.mts +18 -59
- package/dist/index.d.ts +18 -59
- package/dist/index.js +303 -384
- package/dist/index.mjs +303 -379
- package/package.json +11 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @dt-ui/react-dropdown
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.69
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- feat: implement new Dropdown
|
|
8
|
+
- feat: add native attributes to Typography
|
|
9
|
+
- feat: implement new Select field
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- Updated dependencies [223664b]
|
|
17
|
+
- @dt-dds/react-core@1.0.0-beta.51
|
|
18
|
+
- @dt-dds/react-icon@1.0.0-beta.53
|
|
19
|
+
- @dt-dds/react-icon-button@1.0.0-beta.19
|
|
20
|
+
- @dt-dds/react-typography@1.0.0-beta.42
|
|
21
|
+
- @dt-dds/react-box@1.0.0-beta.48
|
|
22
|
+
|
|
23
|
+
## 1.0.0-beta.68
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- refactor: use component size from core
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- Updated dependencies [223664b]
|
|
30
|
+
- @dt-dds/react-icon@1.0.0-beta.52
|
|
31
|
+
- @dt-dds/react-box@1.0.0-beta.47
|
|
32
|
+
|
|
3
33
|
## 1.0.0-beta.67
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Dropdown Package
|
|
2
2
|
|
|
3
|
-
The Dropdown Menu
|
|
3
|
+
The Dropdown Menu provides the users with a box that can receive any content. It also provides an Option component.
|
|
4
4
|
|
|
5
5
|
## Dropdown Usage
|
|
6
6
|
|
|
@@ -15,13 +15,9 @@ const OPTIONS = [
|
|
|
15
15
|
export const App = () => {
|
|
16
16
|
return (
|
|
17
17
|
<Dropdown>
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
{option.text ?? option.value}
|
|
22
|
-
</Dropdown.Option>
|
|
23
|
-
))}
|
|
24
|
-
</Dropdown.Select>
|
|
18
|
+
{options.map((option) => (
|
|
19
|
+
<Dropdown.Option key={option.value}>{option.text}</Dropdown.Option>
|
|
20
|
+
))}
|
|
25
21
|
</Dropdown>
|
|
26
22
|
);
|
|
27
23
|
};
|
|
@@ -31,56 +27,33 @@ export const App = () => {
|
|
|
31
27
|
|
|
32
28
|
### Dropdown
|
|
33
29
|
|
|
34
|
-
| Property
|
|
35
|
-
|
|
|
36
|
-
| `children`
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
| `
|
|
47
|
-
| `label` | `string` | - | A text to help users understand the scope of the dropdown. |
|
|
48
|
-
| `style` | `React.CSSProperties` | - | Gives the Box Dropdown css properties |
|
|
49
|
-
| `dataTestId` | `string` | `dropdown-select` | Customizable test identifier |
|
|
50
|
-
| `isDisabled` | `boolean` | `false` | Set the dropdown disabled. |
|
|
51
|
-
| `hasBorder` | `boolean` | `true` | Set a border to the component. |
|
|
52
|
-
| `hasError` | `boolean` | `false` | Set error state for dropdown |
|
|
53
|
-
| `fill` | `DropdownFill` | `default` | Styles the input with a specific background color |
|
|
54
|
-
| `variant` | `DropdownVariant` | `outlined` | Styles the input with a specific border |
|
|
55
|
-
| `hasDeselect` | `boolean` | `false` | Set if dropdown has deselect X button/icon |
|
|
56
|
-
| `isRequired` | `boolean` | `false` | Apply required style to the label field |
|
|
57
|
-
|
|
58
|
-
### Dropdown.Menu
|
|
59
|
-
|
|
60
|
-
| Property | Type | Default | Description |
|
|
61
|
-
| ------------ | ----------- | ------- | ------------------------------- |
|
|
62
|
-
| `children` | `ReactNode` | - | Child components to be rendered |
|
|
63
|
-
| `dataTestId` | `string` | `menu` | Customizable test identifier |
|
|
30
|
+
| Property | Type | Default | Description |
|
|
31
|
+
| ------------ | -------------------------------- | ---------- | --------------------------------------------------------------------------- |
|
|
32
|
+
| `children` | `ReactNode` | — | Child components/content to be rendered inside the dropdown. |
|
|
33
|
+
| `style` | `React.CSSProperties` | — | Inline styles merged **after** computed positioning styles. |
|
|
34
|
+
| `dataTestId` | `string` | `dropdown` | Customizable test identifier applied to the dropdown root element. |
|
|
35
|
+
| `isOpen` | `boolean` | `false` | Controls visibility. When `false`, the element is hidden via `aria-hidden`. |
|
|
36
|
+
| `anchorRef` | `RefObject<HTMLElement \| null>` | - | Reference to the anchor element used for positioning. |
|
|
37
|
+
| `matchWidth` | `boolean` | `true` | If `true`, the dropdown width matches the anchor width. |
|
|
38
|
+
| `offsetX` | `number` | `4` | Horizontal offset (px) for `left`/`right` placements. |
|
|
39
|
+
| `offsetY` | `number` | `4` | Vertical offset (px) for `top`/`bottom` placements. |
|
|
40
|
+
| `onClose` | `() => void` | — | Called when a click is detected outside the dropdown/anchor. |
|
|
41
|
+
| `as` | `keyof JSX.IntrinsicElements` | `"div"` | Underlying HTML element (e.g., `"ul"` for list semantics). |
|
|
42
|
+
| `placement` | `DropdownPlacement` | `bottom` | Dropdown position. |
|
|
64
43
|
|
|
65
44
|
### Dropdown.Option
|
|
66
45
|
|
|
67
|
-
| Property
|
|
68
|
-
|
|
|
69
|
-
| `style`
|
|
70
|
-
| `children`
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
| Property | Type | Default | Description |
|
|
79
|
-
| ------------ | ----------- | --------------- | ------------------------------------- |
|
|
80
|
-
| `children` | `ReactNode` | - | Child components to be rendered |
|
|
81
|
-
| `dataTestId` | `string` | `dropdown-text` | Customizable test identifier |
|
|
82
|
-
| `isDisabled` | `boolean` | `false` | Disable the dropdown detail text |
|
|
83
|
-
| `hasError` | `boolean` | `false` | Set error state for the dropdown text |
|
|
46
|
+
| Property | Type | Default | Description |
|
|
47
|
+
| --------------- | ----------------------------------------------------- | ----------------- | ----------------------------------------------------------------------- |
|
|
48
|
+
| `style` | `React.CSSProperties` | — | Inline styles for the option element. |
|
|
49
|
+
| `children` | `ReactNode` | — | Content of the option. |
|
|
50
|
+
| `dataTestId` | `string` | `dropdown-option` | Customizable test identifier for the option element. |
|
|
51
|
+
| `isDisabled` | `boolean` | `false` | When `true`, sets `aria-disabled` and blocks click/keyboard activation. |
|
|
52
|
+
| `isSelected` | `boolean` | `false` | Reflects selection state via `aria-selected` and styling. |
|
|
53
|
+
| `isHighlighted` | `boolean` | `false` | Adds `data-highlighted="true"` for hover/active row styling. |
|
|
54
|
+
| `isMulti` | `boolean` | `false` | Optional styling hint for multi-select contexts (no selection logic). |
|
|
55
|
+
| `onClick` | `(event: MouseEvent<HTMLLIElement>) => void` | — | Click handler. |
|
|
56
|
+
| `...rest` | `React.LiHTMLAttributes<HTMLLIElement>` & `BaseProps` | — | Additional LI attributes (e.g., `role="option"`, `tabIndex`, etc.). |
|
|
84
57
|
|
|
85
58
|
## Stack
|
|
86
59
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,78 +1,37 @@
|
|
|
1
1
|
import { CustomTheme } from '@dt-dds/themes';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { BaseProps } from '@dt-dds/react-core';
|
|
4
3
|
import * as react from 'react';
|
|
5
|
-
import {
|
|
4
|
+
import react__default, { RefObject } from 'react';
|
|
6
5
|
|
|
7
|
-
interface
|
|
6
|
+
interface DropdownOptionProps extends BaseProps, react__default.LiHTMLAttributes<HTMLLIElement> {
|
|
8
7
|
isDisabled?: boolean;
|
|
9
|
-
|
|
8
|
+
isSelected?: boolean;
|
|
9
|
+
isHighlighted?: boolean;
|
|
10
|
+
isMulti?: boolean;
|
|
10
11
|
}
|
|
11
|
-
declare const
|
|
12
|
+
declare const DropdownOption: react__default.ForwardRefExoticComponent<DropdownOptionProps & react__default.RefAttributes<HTMLLIElement>>;
|
|
12
13
|
|
|
13
|
-
type DropdownOptionValue = {
|
|
14
|
-
text?: string;
|
|
15
|
-
value: string;
|
|
16
|
-
};
|
|
17
14
|
type DropdownVariant = 'outlined' | 'bottom-line';
|
|
18
15
|
type DropdownFill = 'default' | 'contrast' | 'light';
|
|
19
|
-
|
|
20
|
-
interface DropdownOptionProps extends BaseProps {
|
|
21
|
-
fill?: DropdownFill;
|
|
22
|
-
option: DropdownOptionValue;
|
|
23
|
-
isDisabled?: boolean;
|
|
24
|
-
onClick?: (option: string, name: string | undefined, event: MouseEvent<HTMLLIElement>) => void;
|
|
25
|
-
}
|
|
26
|
-
declare const DropdownOption: ({ dataTestId, option, children, style, isDisabled, onClick, }: DropdownOptionProps) => react_jsx_runtime.JSX.Element;
|
|
27
|
-
|
|
28
|
-
type DropdownSelectProps = {
|
|
29
|
-
label?: string;
|
|
30
|
-
isDisabled?: boolean;
|
|
31
|
-
isRequired?: boolean;
|
|
32
|
-
hasBorder?: boolean;
|
|
33
|
-
hasError?: boolean;
|
|
34
|
-
hasDeselect?: boolean;
|
|
35
|
-
variant?: DropdownVariant;
|
|
36
|
-
fill?: DropdownFill;
|
|
37
|
-
} & BaseProps;
|
|
38
|
-
declare const DropdownSelect: ({ children, label, style, dataTestId, isDisabled, isRequired, hasBorder, hasError, hasDeselect, variant, fill, }: DropdownSelectProps) => react_jsx_runtime.JSX.Element;
|
|
39
|
-
|
|
40
|
-
declare const DropdownContainer: ({ children, style, dataTestId, }: BaseProps) => react_jsx_runtime.JSX.Element;
|
|
41
|
-
|
|
42
|
-
declare const DropdownMenu: ({ children, dataTestId, style }: BaseProps) => react_jsx_runtime.JSX.Element;
|
|
16
|
+
type DropdownPlacement = 'bottom' | 'top' | 'left' | 'right';
|
|
43
17
|
|
|
44
18
|
interface DropdownProps extends BaseProps {
|
|
45
|
-
|
|
46
|
-
|
|
19
|
+
isOpen?: boolean;
|
|
20
|
+
anchorRef: RefObject<HTMLElement | null>;
|
|
21
|
+
matchWidth?: boolean;
|
|
22
|
+
offsetX?: number;
|
|
23
|
+
offsetY?: number;
|
|
24
|
+
onClose?: () => void;
|
|
25
|
+
as?: keyof JSX.IntrinsicElements;
|
|
26
|
+
placement?: DropdownPlacement;
|
|
47
27
|
}
|
|
48
|
-
declare const Dropdown: {
|
|
49
|
-
|
|
50
|
-
Container: ({ children, style, dataTestId, }: BaseProps) => react_jsx_runtime.JSX.Element;
|
|
51
|
-
Detail: ({ dataTestId, isDisabled, hasError, children, }: DropdownDetailProps) => react_jsx_runtime.JSX.Element;
|
|
52
|
-
Select: ({ children, label, style, dataTestId, isDisabled, isRequired, hasBorder, hasError, hasDeselect, variant, fill, }: DropdownSelectProps) => react_jsx_runtime.JSX.Element;
|
|
53
|
-
Option: ({ dataTestId, option, children, style, isDisabled, onClick, }: DropdownOptionProps) => react_jsx_runtime.JSX.Element;
|
|
54
|
-
Menu: ({ children, dataTestId, style }: BaseProps) => react_jsx_runtime.JSX.Element;
|
|
28
|
+
declare const Dropdown: react.ForwardRefExoticComponent<DropdownProps & react.RefAttributes<HTMLElement>> & {
|
|
29
|
+
Option: react.ForwardRefExoticComponent<DropdownOptionProps & react.RefAttributes<HTMLLIElement>>;
|
|
55
30
|
};
|
|
56
31
|
|
|
57
|
-
interface DropdownContextState {
|
|
58
|
-
state: DropdownOptionValue;
|
|
59
|
-
isOpen: boolean;
|
|
60
|
-
name?: string;
|
|
61
|
-
setState: React.Dispatch<React.SetStateAction<DropdownOptionValue>>;
|
|
62
|
-
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
63
|
-
}
|
|
64
|
-
interface DropdownContextProviderProps {
|
|
65
|
-
children: ReactNode;
|
|
66
|
-
defaultValue?: DropdownOptionValue;
|
|
67
|
-
name?: string;
|
|
68
|
-
}
|
|
69
|
-
declare const DropdownContext: react.Context<DropdownContextState>;
|
|
70
|
-
declare const DropdownContextProvider: ({ children, defaultValue, name, }: DropdownContextProviderProps) => react_jsx_runtime.JSX.Element;
|
|
71
|
-
declare const useDropdownContext: () => DropdownContextState;
|
|
72
|
-
|
|
73
32
|
declare module '@emotion/react' {
|
|
74
33
|
interface Theme extends CustomTheme {
|
|
75
34
|
}
|
|
76
35
|
}
|
|
77
36
|
|
|
78
|
-
export { Dropdown,
|
|
37
|
+
export { Dropdown, type DropdownFill, DropdownOption, type DropdownOptionProps, type DropdownPlacement, type DropdownProps, type DropdownVariant };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,78 +1,37 @@
|
|
|
1
1
|
import { CustomTheme } from '@dt-dds/themes';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { BaseProps } from '@dt-dds/react-core';
|
|
4
3
|
import * as react from 'react';
|
|
5
|
-
import {
|
|
4
|
+
import react__default, { RefObject } from 'react';
|
|
6
5
|
|
|
7
|
-
interface
|
|
6
|
+
interface DropdownOptionProps extends BaseProps, react__default.LiHTMLAttributes<HTMLLIElement> {
|
|
8
7
|
isDisabled?: boolean;
|
|
9
|
-
|
|
8
|
+
isSelected?: boolean;
|
|
9
|
+
isHighlighted?: boolean;
|
|
10
|
+
isMulti?: boolean;
|
|
10
11
|
}
|
|
11
|
-
declare const
|
|
12
|
+
declare const DropdownOption: react__default.ForwardRefExoticComponent<DropdownOptionProps & react__default.RefAttributes<HTMLLIElement>>;
|
|
12
13
|
|
|
13
|
-
type DropdownOptionValue = {
|
|
14
|
-
text?: string;
|
|
15
|
-
value: string;
|
|
16
|
-
};
|
|
17
14
|
type DropdownVariant = 'outlined' | 'bottom-line';
|
|
18
15
|
type DropdownFill = 'default' | 'contrast' | 'light';
|
|
19
|
-
|
|
20
|
-
interface DropdownOptionProps extends BaseProps {
|
|
21
|
-
fill?: DropdownFill;
|
|
22
|
-
option: DropdownOptionValue;
|
|
23
|
-
isDisabled?: boolean;
|
|
24
|
-
onClick?: (option: string, name: string | undefined, event: MouseEvent<HTMLLIElement>) => void;
|
|
25
|
-
}
|
|
26
|
-
declare const DropdownOption: ({ dataTestId, option, children, style, isDisabled, onClick, }: DropdownOptionProps) => react_jsx_runtime.JSX.Element;
|
|
27
|
-
|
|
28
|
-
type DropdownSelectProps = {
|
|
29
|
-
label?: string;
|
|
30
|
-
isDisabled?: boolean;
|
|
31
|
-
isRequired?: boolean;
|
|
32
|
-
hasBorder?: boolean;
|
|
33
|
-
hasError?: boolean;
|
|
34
|
-
hasDeselect?: boolean;
|
|
35
|
-
variant?: DropdownVariant;
|
|
36
|
-
fill?: DropdownFill;
|
|
37
|
-
} & BaseProps;
|
|
38
|
-
declare const DropdownSelect: ({ children, label, style, dataTestId, isDisabled, isRequired, hasBorder, hasError, hasDeselect, variant, fill, }: DropdownSelectProps) => react_jsx_runtime.JSX.Element;
|
|
39
|
-
|
|
40
|
-
declare const DropdownContainer: ({ children, style, dataTestId, }: BaseProps) => react_jsx_runtime.JSX.Element;
|
|
41
|
-
|
|
42
|
-
declare const DropdownMenu: ({ children, dataTestId, style }: BaseProps) => react_jsx_runtime.JSX.Element;
|
|
16
|
+
type DropdownPlacement = 'bottom' | 'top' | 'left' | 'right';
|
|
43
17
|
|
|
44
18
|
interface DropdownProps extends BaseProps {
|
|
45
|
-
|
|
46
|
-
|
|
19
|
+
isOpen?: boolean;
|
|
20
|
+
anchorRef: RefObject<HTMLElement | null>;
|
|
21
|
+
matchWidth?: boolean;
|
|
22
|
+
offsetX?: number;
|
|
23
|
+
offsetY?: number;
|
|
24
|
+
onClose?: () => void;
|
|
25
|
+
as?: keyof JSX.IntrinsicElements;
|
|
26
|
+
placement?: DropdownPlacement;
|
|
47
27
|
}
|
|
48
|
-
declare const Dropdown: {
|
|
49
|
-
|
|
50
|
-
Container: ({ children, style, dataTestId, }: BaseProps) => react_jsx_runtime.JSX.Element;
|
|
51
|
-
Detail: ({ dataTestId, isDisabled, hasError, children, }: DropdownDetailProps) => react_jsx_runtime.JSX.Element;
|
|
52
|
-
Select: ({ children, label, style, dataTestId, isDisabled, isRequired, hasBorder, hasError, hasDeselect, variant, fill, }: DropdownSelectProps) => react_jsx_runtime.JSX.Element;
|
|
53
|
-
Option: ({ dataTestId, option, children, style, isDisabled, onClick, }: DropdownOptionProps) => react_jsx_runtime.JSX.Element;
|
|
54
|
-
Menu: ({ children, dataTestId, style }: BaseProps) => react_jsx_runtime.JSX.Element;
|
|
28
|
+
declare const Dropdown: react.ForwardRefExoticComponent<DropdownProps & react.RefAttributes<HTMLElement>> & {
|
|
29
|
+
Option: react.ForwardRefExoticComponent<DropdownOptionProps & react.RefAttributes<HTMLLIElement>>;
|
|
55
30
|
};
|
|
56
31
|
|
|
57
|
-
interface DropdownContextState {
|
|
58
|
-
state: DropdownOptionValue;
|
|
59
|
-
isOpen: boolean;
|
|
60
|
-
name?: string;
|
|
61
|
-
setState: React.Dispatch<React.SetStateAction<DropdownOptionValue>>;
|
|
62
|
-
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
63
|
-
}
|
|
64
|
-
interface DropdownContextProviderProps {
|
|
65
|
-
children: ReactNode;
|
|
66
|
-
defaultValue?: DropdownOptionValue;
|
|
67
|
-
name?: string;
|
|
68
|
-
}
|
|
69
|
-
declare const DropdownContext: react.Context<DropdownContextState>;
|
|
70
|
-
declare const DropdownContextProvider: ({ children, defaultValue, name, }: DropdownContextProviderProps) => react_jsx_runtime.JSX.Element;
|
|
71
|
-
declare const useDropdownContext: () => DropdownContextState;
|
|
72
|
-
|
|
73
32
|
declare module '@emotion/react' {
|
|
74
33
|
interface Theme extends CustomTheme {
|
|
75
34
|
}
|
|
76
35
|
}
|
|
77
36
|
|
|
78
|
-
export { Dropdown,
|
|
37
|
+
export { Dropdown, type DropdownFill, DropdownOption, type DropdownOptionProps, type DropdownPlacement, type DropdownProps, type DropdownVariant };
|