-
-
Notifications
You must be signed in to change notification settings - Fork 629
Expand file tree
/
Copy pathreact.js
More file actions
62 lines (60 loc) · 3.43 KB
/
react.js
File metadata and controls
62 lines (60 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const React = require('react')
const passthrough = (name) => {
const C = ({ children, className, ...props }) =>
React.createElement('div', { 'data-testid': name, className, ...props }, children)
C.displayName = name
return C
}
module.exports = {
Breadcrumbs: ({ children, className, separator, 'aria-label': ariaLabel, ...props }) => {
const items = React.Children.toArray(children)
return React.createElement('nav', { 'aria-label': ariaLabel, className },
React.createElement('ol', { 'data-slot': 'list' },
items.map((item, i) =>
React.createElement(React.Fragment, { key: i },
item,
i < items.length - 1
? React.createElement('li', { 'data-slot': 'separator' }, separator)
: null
)
)
)
)
},
BreadcrumbsItem: ({ children, className, isDisabled, ...props }) => React.createElement('li', { className, 'aria-disabled': isDisabled || undefined, ...props }, children),
BreadcrumbsRoot: passthrough('BreadcrumbsRoot'),
Button: ({ children, variant, className, ...props }) => React.createElement('button', { 'data-testid': 'dropdown-button', 'data-variant': variant, className, ...props }, children),
ButtonRoot: passthrough('ButtonRoot'),
Dropdown: ({ children, ...props }) => React.createElement('div', { 'data-testid': 'dropdown' }, children),
DropdownTrigger: ({ children }) => React.createElement('div', { 'data-testid': 'dropdown-trigger' }, children),
DropdownMenu: ({ children, onAction, selectedKeys, selectionMode, ...props }) => React.createElement('div', { 'data-testid': 'dropdown-menu', 'data-selected-keys': selectedKeys, 'data-selection-mode': selectionMode, ...props }, children),
DropdownItem: ({ children, onPress, ...props }) => React.createElement('div', { 'data-testid': 'dropdown-item', onClick: onPress, ...props }, children),
DropdownSection: ({ children, 'data-title': title, ...props }) => React.createElement('div', { 'data-testid': 'dropdown-section', 'data-title': title, ...props }, title ? React.createElement('span', { 'data-testid': 'dropdown-section-title' }, title) : null, children),
DropdownRoot: passthrough('DropdownRoot'),
DropdownPopover: passthrough('DropdownPopover'),
Input: ({ className, id, type, value, onChange, placeholder, ...props }) => React.createElement('input', { id, type: type || 'text', value, onChange, placeholder, className }),
InputRoot: passthrough('InputRoot'),
Autocomplete: passthrough('Autocomplete'),
AutocompleteRoot: passthrough('AutocompleteRoot'),
ListBoxItem: ({ children, ...props }) => React.createElement('div', props, children),
PaginationRoot: passthrough('PaginationRoot'),
PaginationContent: passthrough('PaginationContent'),
PaginationItem: passthrough('PaginationItem'),
PaginationLink: passthrough('PaginationLink'),
PaginationPrevious: passthrough('PaginationPrevious'),
PaginationNext: passthrough('PaginationNext'),
PaginationEllipsis: passthrough('PaginationEllipsis'),
ToastProvider: () => null,
Tooltip: passthrough('Tooltip'),
Modal: passthrough('Modal'),
ModalRoot: passthrough('ModalRoot'),
ModalBody: passthrough('ModalBody'),
ModalHeader: passthrough('ModalHeader'),
ModalFooter: passthrough('ModalFooter'),
ModalContent: passthrough('ModalContent'),
ModalTrigger: passthrough('ModalTrigger'),
Skeleton: passthrough('Skeleton'),
Select: passthrough('Select'),
SelectItem: passthrough('SelectItem'),
addToast: jest.fn(),
}