@faststore/ui 1.6.16 → 1.6.17
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 +11 -0
- package/dist/molecules/Dropdown/Dropdown.d.ts +9 -0
- package/dist/molecules/Dropdown/DropdownButton.d.ts +10 -0
- package/dist/molecules/Dropdown/DropdownItem.d.ts +10 -0
- package/dist/molecules/Dropdown/DropdownMenu.d.ts +22 -0
- package/dist/molecules/Dropdown/contexts/DropdownContext.d.ts +41 -0
- package/dist/molecules/Dropdown/hooks/useDropdown.d.ts +6 -0
- package/dist/molecules/Dropdown/hooks/useDropdownPosition.d.ts +11 -0
- package/dist/molecules/Dropdown/index.d.ts +8 -0
- package/dist/molecules/Dropdown/stories/Dropdown.stories.d.ts +7 -0
- package/dist/molecules/Dropdown/stories/assets/Caret.d.ts +2 -0
- package/dist/ui.cjs.development.js +2 -3
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +2 -3
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/molecules/Dropdown/Dropdown.test.tsx +159 -0
- package/src/molecules/Dropdown/Dropdown.tsx +65 -0
- package/src/molecules/Dropdown/DropdownButton.tsx +42 -0
- package/src/molecules/Dropdown/DropdownItem.tsx +72 -0
- package/src/molecules/Dropdown/DropdownMenu.tsx +156 -0
- package/src/molecules/Dropdown/contexts/DropdownContext.ts +53 -0
- package/src/molecules/Dropdown/hooks/useDropdown.ts +18 -0
- package/src/molecules/Dropdown/hooks/useDropdownPosition.ts +26 -0
- package/src/molecules/Dropdown/index.ts +11 -0
- package/src/molecules/Dropdown/stories/Dropdown.mdx +51 -0
- package/src/molecules/Dropdown/stories/Dropdown.stories.tsx +94 -0
- package/src/molecules/Dropdown/stories/assets/Caret.tsx +19 -0
- package/src/molecules/Modal/ModalContent.tsx +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import type { PropsWithChildren } from 'react'
|
|
3
|
+
import type { Meta, Story } from '@storybook/react'
|
|
4
|
+
|
|
5
|
+
import { Caret } from './assets/Caret'
|
|
6
|
+
import Button from '../../../atoms/Button'
|
|
7
|
+
import type { DropdownProps } from '..'
|
|
8
|
+
import Dropdown, { DropdownButton, DropdownItem, DropdownMenu } from '..'
|
|
9
|
+
import mdx from './Dropdown.mdx'
|
|
10
|
+
|
|
11
|
+
const DropdownUncontrolledTemplate: Story<
|
|
12
|
+
PropsWithChildren<DropdownProps>
|
|
13
|
+
> = () => {
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
<Dropdown>
|
|
17
|
+
<DropdownButton>Dropdown Button</DropdownButton>
|
|
18
|
+
<DropdownMenu>
|
|
19
|
+
<DropdownItem onClick={() => console.log('Item 1')}>
|
|
20
|
+
Dropdown Item 1
|
|
21
|
+
</DropdownItem>
|
|
22
|
+
<DropdownItem onClick={() => console.log('Item 2')}>
|
|
23
|
+
Dropdown Item 2
|
|
24
|
+
</DropdownItem>
|
|
25
|
+
<DropdownItem onClick={() => console.log('Item 3')}>
|
|
26
|
+
Dropdown Item 3
|
|
27
|
+
</DropdownItem>
|
|
28
|
+
</DropdownMenu>
|
|
29
|
+
</Dropdown>
|
|
30
|
+
</>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const Uncontrolled = DropdownUncontrolledTemplate.bind({})
|
|
35
|
+
|
|
36
|
+
const DropdownControlledTemplate: Story<
|
|
37
|
+
PropsWithChildren<DropdownProps>
|
|
38
|
+
> = () => {
|
|
39
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<Button onClick={() => setIsOpen((old) => !old)}>Simple Button</Button>
|
|
44
|
+
<Dropdown isOpen={isOpen} onDismiss={() => setIsOpen(false)}>
|
|
45
|
+
<DropdownButton>DropdownButton</DropdownButton>
|
|
46
|
+
<DropdownMenu>
|
|
47
|
+
<DropdownItem>Dropdown Item 1</DropdownItem>
|
|
48
|
+
<DropdownItem>Dropdown Item 2</DropdownItem>
|
|
49
|
+
<DropdownItem>Dropdown Item 3</DropdownItem>
|
|
50
|
+
</DropdownMenu>
|
|
51
|
+
</Dropdown>
|
|
52
|
+
</>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const Controlled = DropdownControlledTemplate.bind({})
|
|
57
|
+
|
|
58
|
+
const DropdownSelectableTemplate: Story<
|
|
59
|
+
PropsWithChildren<DropdownProps>
|
|
60
|
+
> = () => {
|
|
61
|
+
const [value, setValue] = useState('Selectable')
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<Dropdown>
|
|
66
|
+
<DropdownButton>
|
|
67
|
+
{value} <Caret />
|
|
68
|
+
</DropdownButton>
|
|
69
|
+
<DropdownMenu>
|
|
70
|
+
<DropdownItem onClick={() => setValue('Value 1')}>
|
|
71
|
+
Value 1
|
|
72
|
+
</DropdownItem>
|
|
73
|
+
<DropdownItem onClick={() => setValue('Value 2')}>
|
|
74
|
+
Value 2
|
|
75
|
+
</DropdownItem>
|
|
76
|
+
<DropdownItem onClick={() => setValue('Value 3')}>
|
|
77
|
+
Value 3
|
|
78
|
+
</DropdownItem>
|
|
79
|
+
</DropdownMenu>
|
|
80
|
+
</Dropdown>
|
|
81
|
+
</>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const Selectable = DropdownSelectableTemplate.bind({})
|
|
86
|
+
|
|
87
|
+
export default {
|
|
88
|
+
title: 'Molecules/Dropdown',
|
|
89
|
+
parameters: {
|
|
90
|
+
docs: {
|
|
91
|
+
page: mdx,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
} as Meta
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export const Caret = () => (
|
|
4
|
+
<svg
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
width="24"
|
|
7
|
+
height="24"
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
fill="none"
|
|
10
|
+
stroke="currentColor"
|
|
11
|
+
strokeWidth="2"
|
|
12
|
+
strokeLinecap="round"
|
|
13
|
+
strokeLinejoin="round"
|
|
14
|
+
className="feather feather-chevron-down"
|
|
15
|
+
style={{ display: 'inline' }}
|
|
16
|
+
>
|
|
17
|
+
<polyline points="6 9 12 15 18 9" />
|
|
18
|
+
</svg>
|
|
19
|
+
)
|