@memori.ai/ui 1.0.0-alpha
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/README.md +105 -0
- package/dist/components/Alert/Alert.d.ts +18 -0
- package/dist/components/Alert/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +27 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/ButtonBase/ButtonBase.d.ts +28 -0
- package/dist/components/ButtonBase/index.d.ts +3 -0
- package/dist/components/Card/Card.d.ts +13 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +11 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +12 -0
- package/dist/components/ConfirmDialog/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.d.ts +32 -0
- package/dist/components/Drawer/index.d.ts +2 -0
- package/dist/components/Dropdown/Dropdown.d.ts +11 -0
- package/dist/components/Dropdown/index.d.ts +2 -0
- package/dist/components/Expandable/Expandable.d.ts +15 -0
- package/dist/components/Expandable/helpers.d.ts +3 -0
- package/dist/components/Expandable/index.d.ts +2 -0
- package/dist/components/InputBase/InputBase.d.ts +49 -0
- package/dist/components/InputBase/index.d.ts +3 -0
- package/dist/components/Modal/Modal.d.ts +16 -0
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +16 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Slider/Slider.d.ts +12 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Spin/Spin.d.ts +9 -0
- package/dist/components/Spin/index.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +11 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/i18n/I18nWrapper.d.ts +6 -0
- package/dist/icons/AI.d.ts +5 -0
- package/dist/icons/Alert.d.ts +5 -0
- package/dist/icons/ArrowUp.d.ts +5 -0
- package/dist/icons/Bug.d.ts +5 -0
- package/dist/icons/Chat.d.ts +5 -0
- package/dist/icons/ChevronDown.d.ts +5 -0
- package/dist/icons/ChevronLeft.d.ts +5 -0
- package/dist/icons/ChevronRight.d.ts +5 -0
- package/dist/icons/ChevronUp.d.ts +5 -0
- package/dist/icons/Clear.d.ts +5 -0
- package/dist/icons/Close.d.ts +6 -0
- package/dist/icons/Code.d.ts +5 -0
- package/dist/icons/Copy.d.ts +5 -0
- package/dist/icons/DeepThought.d.ts +5 -0
- package/dist/icons/Delete.d.ts +5 -0
- package/dist/icons/Document.d.ts +5 -0
- package/dist/icons/Download.d.ts +5 -0
- package/dist/icons/Edit.d.ts +5 -0
- package/dist/icons/Expand.d.ts +5 -0
- package/dist/icons/Eye.d.ts +5 -0
- package/dist/icons/EyeInvisible.d.ts +5 -0
- package/dist/icons/Facebook.d.ts +5 -0
- package/dist/icons/Feedback.d.ts +5 -0
- package/dist/icons/File.d.ts +5 -0
- package/dist/icons/FileExcel.d.ts +5 -0
- package/dist/icons/FilePdf.d.ts +5 -0
- package/dist/icons/FileWord.d.ts +5 -0
- package/dist/icons/Fullscreen.d.ts +5 -0
- package/dist/icons/FullscreenExit.d.ts +5 -0
- package/dist/icons/Group.d.ts +5 -0
- package/dist/icons/History.d.ts +6 -0
- package/dist/icons/Image.d.ts +4 -0
- package/dist/icons/Info.d.ts +5 -0
- package/dist/icons/Link.d.ts +5 -0
- package/dist/icons/Linkedin.d.ts +5 -0
- package/dist/icons/Loading.d.ts +6 -0
- package/dist/icons/Logout.d.ts +5 -0
- package/dist/icons/Mail.d.ts +5 -0
- package/dist/icons/MapMarker.d.ts +5 -0
- package/dist/icons/MenuHorizontal.d.ts +6 -0
- package/dist/icons/MenuVertical.d.ts +6 -0
- package/dist/icons/Message.d.ts +5 -0
- package/dist/icons/Microphone.d.ts +5 -0
- package/dist/icons/Minus.d.ts +5 -0
- package/dist/icons/MinusCircle.d.ts +5 -0
- package/dist/icons/PaperClip.d.ts +5 -0
- package/dist/icons/Picture.d.ts +5 -0
- package/dist/icons/Plus.d.ts +5 -0
- package/dist/icons/Preview.d.ts +4 -0
- package/dist/icons/Print.d.ts +6 -0
- package/dist/icons/QuestionHelp.d.ts +5 -0
- package/dist/icons/Refresh.d.ts +5 -0
- package/dist/icons/SelectIcon.d.ts +5 -0
- package/dist/icons/Send.d.ts +5 -0
- package/dist/icons/Setting.d.ts +5 -0
- package/dist/icons/Share.d.ts +5 -0
- package/dist/icons/Sound.d.ts +5 -0
- package/dist/icons/SoundDeactivated.d.ts +5 -0
- package/dist/icons/Telegram.d.ts +5 -0
- package/dist/icons/ThumbDown.d.ts +5 -0
- package/dist/icons/ThumbUp.d.ts +5 -0
- package/dist/icons/Translation.d.ts +5 -0
- package/dist/icons/Twitter.d.ts +5 -0
- package/dist/icons/Upload.d.ts +4 -0
- package/dist/icons/User.d.ts +5 -0
- package/dist/icons/Warning.d.ts +5 -0
- package/dist/icons/WhatsApp.d.ts +5 -0
- package/dist/index.d.ts +13 -0
- package/dist/memori-ai-ui.css +2 -0
- package/dist/memori-ai-ui.es.js +6400 -0
- package/dist/memori-ai-ui.umd.js +23 -0
- package/package.json +97 -0
- package/src/components/Alert/Alert.css +95 -0
- package/src/components/Alert/Alert.stories.tsx +156 -0
- package/src/components/Alert/Alert.test.tsx +122 -0
- package/src/components/Alert/Alert.tsx +124 -0
- package/src/components/Alert/__snapshots__/Alert.test.tsx.snap +67 -0
- package/src/components/Alert/index.tsx +2 -0
- package/src/components/Button/Button.css +173 -0
- package/src/components/Button/Button.stories.tsx +173 -0
- package/src/components/Button/Button.test.tsx +80 -0
- package/src/components/Button/Button.tsx +104 -0
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +204 -0
- package/src/components/Button/index.tsx +2 -0
- package/src/components/ButtonBase/ButtonBase.stories.tsx +194 -0
- package/src/components/ButtonBase/ButtonBase.tsx +84 -0
- package/src/components/ButtonBase/index.tsx +3 -0
- package/src/components/ButtonBase/styles.module.css +135 -0
- package/src/components/Card/Card.css +67 -0
- package/src/components/Card/Card.stories.tsx +104 -0
- package/src/components/Card/Card.test.tsx +67 -0
- package/src/components/Card/Card.tsx +58 -0
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +321 -0
- package/src/components/Card/index.tsx +2 -0
- package/src/components/Checkbox/Checkbox.css +114 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +77 -0
- package/src/components/Checkbox/Checkbox.test.tsx +50 -0
- package/src/components/Checkbox/Checkbox.tsx +61 -0
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +131 -0
- package/src/components/Checkbox/index.tsx +2 -0
- package/src/components/ConfirmDialog/ConfirmDialog.css +44 -0
- package/src/components/ConfirmDialog/ConfirmDialog.stories.tsx +235 -0
- package/src/components/ConfirmDialog/ConfirmDialog.test.tsx +129 -0
- package/src/components/ConfirmDialog/ConfirmDialog.tsx +73 -0
- package/src/components/ConfirmDialog/__snapshots__/ConfirmDialog.test.tsx.snap +11 -0
- package/src/components/ConfirmDialog/index.tsx +2 -0
- package/src/components/Details/Details.css +66 -0
- package/src/components/Details/Details.stories.tsx +67 -0
- package/src/components/Drawer/Drawer.css +210 -0
- package/src/components/Drawer/Drawer.stories.tsx +275 -0
- package/src/components/Drawer/Drawer.test.tsx +158 -0
- package/src/components/Drawer/Drawer.tsx +242 -0
- package/src/components/Drawer/__snapshots__/Drawer.test.tsx.snap +21 -0
- package/src/components/Drawer/index.tsx +2 -0
- package/src/components/Dropdown/Dropdown.css +177 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +73 -0
- package/src/components/Dropdown/Dropdown.test.tsx +88 -0
- package/src/components/Dropdown/Dropdown.tsx +88 -0
- package/src/components/Dropdown/__snapshots__/Dropdown.test.tsx.snap +141 -0
- package/src/components/Dropdown/index.tsx +2 -0
- package/src/components/Expandable/Expandable.css +15 -0
- package/src/components/Expandable/Expandable.stories.tsx +196 -0
- package/src/components/Expandable/Expandable.test.tsx +143 -0
- package/src/components/Expandable/Expandable.tsx +122 -0
- package/src/components/Expandable/__snapshots__/Expandable.test.tsx.snap +199 -0
- package/src/components/Expandable/helpers.ts +16 -0
- package/src/components/Expandable/index.tsx +2 -0
- package/src/components/InputBase/InputBase.stories.tsx +237 -0
- package/src/components/InputBase/InputBase.tsx +105 -0
- package/src/components/InputBase/index.tsx +3 -0
- package/src/components/InputBase/styles.module.css +96 -0
- package/src/components/Modal/Modal.css +95 -0
- package/src/components/Modal/Modal.stories.tsx +184 -0
- package/src/components/Modal/Modal.test.tsx +129 -0
- package/src/components/Modal/Modal.tsx +124 -0
- package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +17 -0
- package/src/components/Modal/index.tsx +2 -0
- package/src/components/Select/Select.css +134 -0
- package/src/components/Select/Select.stories.tsx +85 -0
- package/src/components/Select/Select.test.tsx +85 -0
- package/src/components/Select/Select.tsx +84 -0
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +261 -0
- package/src/components/Select/index.tsx +2 -0
- package/src/components/Slider/Slider.css +194 -0
- package/src/components/Slider/Slider.stories.tsx +85 -0
- package/src/components/Slider/Slider.test.tsx +55 -0
- package/src/components/Slider/Slider.tsx +157 -0
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +419 -0
- package/src/components/Slider/index.tsx +2 -0
- package/src/components/Spin/Spin.css +31 -0
- package/src/components/Spin/Spin.stories.tsx +65 -0
- package/src/components/Spin/Spin.test.tsx +47 -0
- package/src/components/Spin/Spin.tsx +34 -0
- package/src/components/Spin/__snapshots__/Spin.test.tsx.snap +193 -0
- package/src/components/Spin/index.tsx +2 -0
- package/src/components/Table/Table.css +130 -0
- package/src/components/Table/Table.stories.tsx +274 -0
- package/src/components/Tooltip/Tooltip.css +160 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +136 -0
- package/src/components/Tooltip/Tooltip.test.tsx +110 -0
- package/src/components/Tooltip/Tooltip.tsx +46 -0
- package/src/components/Tooltip/__snapshots__/Tooltip.test.tsx.snap +163 -0
- package/src/components/Tooltip/index.tsx +2 -0
- package/src/components/definitions.stories.tsx +150 -0
- package/src/i18n/I18nWrapper.tsx +13 -0
- package/src/i18n/i18n.ts +34 -0
- package/src/icons/AI.tsx +38 -0
- package/src/icons/Alert.tsx +31 -0
- package/src/icons/ArrowUp.tsx +28 -0
- package/src/icons/Bug.tsx +81 -0
- package/src/icons/Chat.tsx +30 -0
- package/src/icons/ChevronDown.tsx +26 -0
- package/src/icons/ChevronLeft.tsx +28 -0
- package/src/icons/ChevronRight.tsx +28 -0
- package/src/icons/ChevronUp.tsx +24 -0
- package/src/icons/Clear.tsx +23 -0
- package/src/icons/Close.tsx +30 -0
- package/src/icons/Code.tsx +30 -0
- package/src/icons/Copy.tsx +30 -0
- package/src/icons/DeepThought.tsx +38 -0
- package/src/icons/Delete.tsx +23 -0
- package/src/icons/Document.tsx +52 -0
- package/src/icons/Download.tsx +23 -0
- package/src/icons/Edit.tsx +17 -0
- package/src/icons/Expand.tsx +23 -0
- package/src/icons/Eye.tsx +17 -0
- package/src/icons/EyeInvisible.tsx +24 -0
- package/src/icons/Facebook.tsx +23 -0
- package/src/icons/Feedback.tsx +27 -0
- package/src/icons/File.tsx +17 -0
- package/src/icons/FileExcel.tsx +23 -0
- package/src/icons/FilePdf.tsx +23 -0
- package/src/icons/FileWord.tsx +23 -0
- package/src/icons/Fullscreen.tsx +23 -0
- package/src/icons/FullscreenExit.tsx +23 -0
- package/src/icons/Group.tsx +30 -0
- package/src/icons/History.tsx +33 -0
- package/src/icons/Image.tsx +37 -0
- package/src/icons/Info.tsx +37 -0
- package/src/icons/Link.tsx +17 -0
- package/src/icons/Linkedin.tsx +23 -0
- package/src/icons/Loading.tsx +28 -0
- package/src/icons/Logout.tsx +33 -0
- package/src/icons/Mail.tsx +17 -0
- package/src/icons/MapMarker.tsx +26 -0
- package/src/icons/MenuHorizontal.tsx +29 -0
- package/src/icons/MenuVertical.tsx +29 -0
- package/src/icons/Message.tsx +23 -0
- package/src/icons/Microphone.tsx +23 -0
- package/src/icons/Minus.tsx +23 -0
- package/src/icons/MinusCircle.tsx +24 -0
- package/src/icons/PaperClip.tsx +23 -0
- package/src/icons/Picture.tsx +23 -0
- package/src/icons/Plus.tsx +18 -0
- package/src/icons/Preview.tsx +31 -0
- package/src/icons/Print.tsx +37 -0
- package/src/icons/QuestionHelp.tsx +34 -0
- package/src/icons/Refresh.tsx +30 -0
- package/src/icons/SelectIcon.tsx +28 -0
- package/src/icons/Send.tsx +17 -0
- package/src/icons/Setting.tsx +23 -0
- package/src/icons/Share.tsx +23 -0
- package/src/icons/Sound.tsx +23 -0
- package/src/icons/SoundDeactivated.tsx +27 -0
- package/src/icons/Telegram.tsx +26 -0
- package/src/icons/ThumbDown.tsx +29 -0
- package/src/icons/ThumbUp.tsx +29 -0
- package/src/icons/Translation.tsx +24 -0
- package/src/icons/Twitter.tsx +23 -0
- package/src/icons/Upload.tsx +34 -0
- package/src/icons/User.tsx +17 -0
- package/src/icons/Warning.tsx +27 -0
- package/src/icons/WhatsApp.tsx +24 -0
- package/src/icons/icons.stories.css +5 -0
- package/src/icons/icons.stories.tsx +110 -0
- package/src/icons/loading.css +14 -0
- package/src/index.ts +15 -0
- package/src/styles/utils.css +17 -0
- package/src/styles.css +4 -0
- package/src/theme/variables.css +110 -0
- package/src/vite-env.d.ts +6 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
3
|
+
import Select from './Select'
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'UI/Select',
|
|
7
|
+
component: Select,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
argTypes: {
|
|
10
|
+
label: {
|
|
11
|
+
control: {
|
|
12
|
+
type: 'text',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
className: {
|
|
16
|
+
control: {
|
|
17
|
+
type: 'text',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
disabled: {
|
|
21
|
+
control: {
|
|
22
|
+
type: 'boolean',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
parameters: {
|
|
27
|
+
controls: { expanded: true },
|
|
28
|
+
},
|
|
29
|
+
} satisfies Meta<typeof Select>
|
|
30
|
+
|
|
31
|
+
export default meta
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<typeof meta>
|
|
34
|
+
|
|
35
|
+
export const Default: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
onChange: console.log,
|
|
38
|
+
label: 'Select me',
|
|
39
|
+
options: [
|
|
40
|
+
{ value: '1', label: '1' },
|
|
41
|
+
{ value: '2', label: '2' },
|
|
42
|
+
{ value: '3', label: '3' },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const Placeholder: Story = {
|
|
48
|
+
args: {
|
|
49
|
+
onChange: console.log,
|
|
50
|
+
label: 'Select me',
|
|
51
|
+
placeholder: 'Select me',
|
|
52
|
+
options: [
|
|
53
|
+
{ value: '1', label: '1' },
|
|
54
|
+
{ value: '2', label: '2' },
|
|
55
|
+
{ value: '3', label: '3' },
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const WithValue: Story = {
|
|
61
|
+
args: {
|
|
62
|
+
onChange: console.log,
|
|
63
|
+
label: 'Select me',
|
|
64
|
+
value: '2',
|
|
65
|
+
options: [
|
|
66
|
+
{ value: '1', label: '1' },
|
|
67
|
+
{ value: '2', label: '2' },
|
|
68
|
+
{ value: '3', label: '3' },
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const Disabled: Story = {
|
|
74
|
+
args: {
|
|
75
|
+
onChange: console.log,
|
|
76
|
+
label: `You can't select me`,
|
|
77
|
+
options: [
|
|
78
|
+
{ value: '1', label: '1' },
|
|
79
|
+
{ value: '2', label: '2' },
|
|
80
|
+
{ value: '3', label: '3' },
|
|
81
|
+
],
|
|
82
|
+
value: 2,
|
|
83
|
+
disabled: true,
|
|
84
|
+
},
|
|
85
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { expect, it, vi } from 'vitest'
|
|
3
|
+
import { render } from '@testing-library/react'
|
|
4
|
+
import Select from './Select'
|
|
5
|
+
|
|
6
|
+
it('renders Select unchanged', () => {
|
|
7
|
+
const { container } = render(
|
|
8
|
+
<Select
|
|
9
|
+
label="Select me"
|
|
10
|
+
options={[
|
|
11
|
+
{ value: '1', label: '1' },
|
|
12
|
+
{ value: '2', label: '2' },
|
|
13
|
+
{ value: '3', label: '3' },
|
|
14
|
+
]}
|
|
15
|
+
onChange={vi.fn()}
|
|
16
|
+
/>,
|
|
17
|
+
)
|
|
18
|
+
expect(container).toMatchSnapshot()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('renders Select with placeholder unchanged', () => {
|
|
22
|
+
const { container } = render(
|
|
23
|
+
<Select
|
|
24
|
+
label="Select me"
|
|
25
|
+
placeholder="Select me"
|
|
26
|
+
options={[
|
|
27
|
+
{ value: '1', label: '1' },
|
|
28
|
+
{ value: '2', label: '2' },
|
|
29
|
+
{ value: '3', label: '3' },
|
|
30
|
+
]}
|
|
31
|
+
onChange={vi.fn()}
|
|
32
|
+
/>,
|
|
33
|
+
)
|
|
34
|
+
expect(container).toMatchSnapshot()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('renders Select with value unchanged', () => {
|
|
38
|
+
const { container } = render(
|
|
39
|
+
<Select
|
|
40
|
+
label="Select me"
|
|
41
|
+
value="2"
|
|
42
|
+
options={[
|
|
43
|
+
{ value: '1', label: '1' },
|
|
44
|
+
{ value: '2', label: '2' },
|
|
45
|
+
{ value: '3', label: '3' },
|
|
46
|
+
]}
|
|
47
|
+
onChange={vi.fn()}
|
|
48
|
+
/>,
|
|
49
|
+
)
|
|
50
|
+
expect(container).toMatchSnapshot()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('renders Select with custom value display unchanged', () => {
|
|
54
|
+
const { container } = render(
|
|
55
|
+
<Select
|
|
56
|
+
label="Select me"
|
|
57
|
+
value="2"
|
|
58
|
+
displayValue="Two"
|
|
59
|
+
options={[
|
|
60
|
+
{ value: '1', label: 'One' },
|
|
61
|
+
{ value: '2', label: 'Two' },
|
|
62
|
+
{ value: '3', label: 'Three' },
|
|
63
|
+
]}
|
|
64
|
+
onChange={vi.fn()}
|
|
65
|
+
/>,
|
|
66
|
+
)
|
|
67
|
+
expect(container).toMatchSnapshot()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('renders Select disabled unchanged', () => {
|
|
71
|
+
const { container } = render(
|
|
72
|
+
<Select
|
|
73
|
+
label="Select me"
|
|
74
|
+
value="2"
|
|
75
|
+
options={[
|
|
76
|
+
{ value: '1', label: '1' },
|
|
77
|
+
{ value: '2', label: '2' },
|
|
78
|
+
{ value: '3', label: '3' },
|
|
79
|
+
]}
|
|
80
|
+
disabled
|
|
81
|
+
onChange={vi.fn()}
|
|
82
|
+
/>,
|
|
83
|
+
)
|
|
84
|
+
expect(container).toMatchSnapshot()
|
|
85
|
+
})
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { Fragment } from 'react'
|
|
2
|
+
import cx from 'classnames'
|
|
3
|
+
import { Listbox, Transition } from '@headlessui/react'
|
|
4
|
+
import SelectIcon from '../../icons/SelectIcon'
|
|
5
|
+
|
|
6
|
+
import './Select.css'
|
|
7
|
+
|
|
8
|
+
export interface Props<T = any> {
|
|
9
|
+
className?: string
|
|
10
|
+
value?: T
|
|
11
|
+
name?: string
|
|
12
|
+
displayValue?: string
|
|
13
|
+
onChange: (value: T) => void
|
|
14
|
+
options: { value: T; label: any }[]
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
label?: string
|
|
17
|
+
placeholder?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const Select = ({
|
|
21
|
+
className,
|
|
22
|
+
value,
|
|
23
|
+
name,
|
|
24
|
+
displayValue,
|
|
25
|
+
options,
|
|
26
|
+
onChange,
|
|
27
|
+
disabled = false,
|
|
28
|
+
label,
|
|
29
|
+
placeholder,
|
|
30
|
+
}: Props) => {
|
|
31
|
+
return (
|
|
32
|
+
<div className={cx('memori-select', className)}>
|
|
33
|
+
<Listbox
|
|
34
|
+
value={value}
|
|
35
|
+
onChange={value => {
|
|
36
|
+
onChange(value)
|
|
37
|
+
}}
|
|
38
|
+
disabled={disabled}
|
|
39
|
+
name={name}
|
|
40
|
+
>
|
|
41
|
+
{label && (
|
|
42
|
+
<Listbox.Label className="memori-select--label">
|
|
43
|
+
{label}:
|
|
44
|
+
</Listbox.Label>
|
|
45
|
+
)}
|
|
46
|
+
<Listbox.Button
|
|
47
|
+
aria-label={label}
|
|
48
|
+
className="memori-select--button"
|
|
49
|
+
>
|
|
50
|
+
<span
|
|
51
|
+
className={cx('memori-select--value', {
|
|
52
|
+
'memori-select--value-placeholder': !value,
|
|
53
|
+
})}
|
|
54
|
+
>
|
|
55
|
+
{value ? displayValue || value : placeholder}
|
|
56
|
+
</span>
|
|
57
|
+
<span className="memori-select--icon">
|
|
58
|
+
<SelectIcon />
|
|
59
|
+
</span>
|
|
60
|
+
</Listbox.Button>
|
|
61
|
+
<Transition
|
|
62
|
+
as={Fragment}
|
|
63
|
+
leave="transition ease-in duration-100"
|
|
64
|
+
leaveFrom="opacity-100"
|
|
65
|
+
leaveTo="opacity-0"
|
|
66
|
+
>
|
|
67
|
+
<Listbox.Options className="memori-select--options">
|
|
68
|
+
{options.map(opt => (
|
|
69
|
+
<Listbox.Option
|
|
70
|
+
key={opt.value}
|
|
71
|
+
value={opt.value}
|
|
72
|
+
className="memori-select--option"
|
|
73
|
+
>
|
|
74
|
+
{opt.label}
|
|
75
|
+
</Listbox.Option>
|
|
76
|
+
))}
|
|
77
|
+
</Listbox.Options>
|
|
78
|
+
</Transition>
|
|
79
|
+
</Listbox>
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default Select
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`renders Select disabled unchanged 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="memori-select"
|
|
7
|
+
>
|
|
8
|
+
<label
|
|
9
|
+
class="memori-select--label"
|
|
10
|
+
data-headlessui-state=""
|
|
11
|
+
for="headlessui-listbox-button-_r_j_"
|
|
12
|
+
id="headlessui-label-_r_i_"
|
|
13
|
+
>
|
|
14
|
+
Select me
|
|
15
|
+
:
|
|
16
|
+
</label>
|
|
17
|
+
<button
|
|
18
|
+
aria-expanded="false"
|
|
19
|
+
aria-haspopup="listbox"
|
|
20
|
+
aria-label="Select me"
|
|
21
|
+
aria-labelledby="headlessui-label-_r_i_ headlessui-listbox-button-_r_j_"
|
|
22
|
+
class="memori-select--button"
|
|
23
|
+
data-disabled=""
|
|
24
|
+
data-headlessui-state="disabled"
|
|
25
|
+
disabled=""
|
|
26
|
+
id="headlessui-listbox-button-_r_j_"
|
|
27
|
+
type="button"
|
|
28
|
+
>
|
|
29
|
+
<span
|
|
30
|
+
class="memori-select--value"
|
|
31
|
+
>
|
|
32
|
+
2
|
|
33
|
+
</span>
|
|
34
|
+
<span
|
|
35
|
+
class="memori-select--icon"
|
|
36
|
+
>
|
|
37
|
+
<svg
|
|
38
|
+
aria-hidden="true"
|
|
39
|
+
fill="currentColor"
|
|
40
|
+
focusable="false"
|
|
41
|
+
role="img"
|
|
42
|
+
viewBox="0 0 20 20"
|
|
43
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
44
|
+
>
|
|
45
|
+
<path
|
|
46
|
+
clip-rule="evenodd"
|
|
47
|
+
d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z"
|
|
48
|
+
fill-rule="evenodd"
|
|
49
|
+
/>
|
|
50
|
+
</svg>
|
|
51
|
+
</span>
|
|
52
|
+
</button>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
exports[`renders Select unchanged 1`] = `
|
|
58
|
+
<div>
|
|
59
|
+
<div
|
|
60
|
+
class="memori-select"
|
|
61
|
+
>
|
|
62
|
+
<label
|
|
63
|
+
class="memori-select--label"
|
|
64
|
+
data-headlessui-state=""
|
|
65
|
+
for="headlessui-listbox-button-_r_3_"
|
|
66
|
+
id="headlessui-label-_r_2_"
|
|
67
|
+
>
|
|
68
|
+
Select me
|
|
69
|
+
:
|
|
70
|
+
</label>
|
|
71
|
+
<button
|
|
72
|
+
aria-expanded="false"
|
|
73
|
+
aria-haspopup="listbox"
|
|
74
|
+
aria-label="Select me"
|
|
75
|
+
aria-labelledby="headlessui-label-_r_2_ headlessui-listbox-button-_r_3_"
|
|
76
|
+
class="memori-select--button"
|
|
77
|
+
data-headlessui-state=""
|
|
78
|
+
id="headlessui-listbox-button-_r_3_"
|
|
79
|
+
type="button"
|
|
80
|
+
>
|
|
81
|
+
<span
|
|
82
|
+
class="memori-select--value memori-select--value-placeholder"
|
|
83
|
+
/>
|
|
84
|
+
<span
|
|
85
|
+
class="memori-select--icon"
|
|
86
|
+
>
|
|
87
|
+
<svg
|
|
88
|
+
aria-hidden="true"
|
|
89
|
+
fill="currentColor"
|
|
90
|
+
focusable="false"
|
|
91
|
+
role="img"
|
|
92
|
+
viewBox="0 0 20 20"
|
|
93
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
94
|
+
>
|
|
95
|
+
<path
|
|
96
|
+
clip-rule="evenodd"
|
|
97
|
+
d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z"
|
|
98
|
+
fill-rule="evenodd"
|
|
99
|
+
/>
|
|
100
|
+
</svg>
|
|
101
|
+
</span>
|
|
102
|
+
</button>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
exports[`renders Select with custom value display unchanged 1`] = `
|
|
108
|
+
<div>
|
|
109
|
+
<div
|
|
110
|
+
class="memori-select"
|
|
111
|
+
>
|
|
112
|
+
<label
|
|
113
|
+
class="memori-select--label"
|
|
114
|
+
data-headlessui-state=""
|
|
115
|
+
for="headlessui-listbox-button-_r_f_"
|
|
116
|
+
id="headlessui-label-_r_e_"
|
|
117
|
+
>
|
|
118
|
+
Select me
|
|
119
|
+
:
|
|
120
|
+
</label>
|
|
121
|
+
<button
|
|
122
|
+
aria-expanded="false"
|
|
123
|
+
aria-haspopup="listbox"
|
|
124
|
+
aria-label="Select me"
|
|
125
|
+
aria-labelledby="headlessui-label-_r_e_ headlessui-listbox-button-_r_f_"
|
|
126
|
+
class="memori-select--button"
|
|
127
|
+
data-headlessui-state=""
|
|
128
|
+
id="headlessui-listbox-button-_r_f_"
|
|
129
|
+
type="button"
|
|
130
|
+
>
|
|
131
|
+
<span
|
|
132
|
+
class="memori-select--value"
|
|
133
|
+
>
|
|
134
|
+
Two
|
|
135
|
+
</span>
|
|
136
|
+
<span
|
|
137
|
+
class="memori-select--icon"
|
|
138
|
+
>
|
|
139
|
+
<svg
|
|
140
|
+
aria-hidden="true"
|
|
141
|
+
fill="currentColor"
|
|
142
|
+
focusable="false"
|
|
143
|
+
role="img"
|
|
144
|
+
viewBox="0 0 20 20"
|
|
145
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
146
|
+
>
|
|
147
|
+
<path
|
|
148
|
+
clip-rule="evenodd"
|
|
149
|
+
d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z"
|
|
150
|
+
fill-rule="evenodd"
|
|
151
|
+
/>
|
|
152
|
+
</svg>
|
|
153
|
+
</span>
|
|
154
|
+
</button>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
`;
|
|
158
|
+
|
|
159
|
+
exports[`renders Select with placeholder unchanged 1`] = `
|
|
160
|
+
<div>
|
|
161
|
+
<div
|
|
162
|
+
class="memori-select"
|
|
163
|
+
>
|
|
164
|
+
<label
|
|
165
|
+
class="memori-select--label"
|
|
166
|
+
data-headlessui-state=""
|
|
167
|
+
for="headlessui-listbox-button-_r_7_"
|
|
168
|
+
id="headlessui-label-_r_6_"
|
|
169
|
+
>
|
|
170
|
+
Select me
|
|
171
|
+
:
|
|
172
|
+
</label>
|
|
173
|
+
<button
|
|
174
|
+
aria-expanded="false"
|
|
175
|
+
aria-haspopup="listbox"
|
|
176
|
+
aria-label="Select me"
|
|
177
|
+
aria-labelledby="headlessui-label-_r_6_ headlessui-listbox-button-_r_7_"
|
|
178
|
+
class="memori-select--button"
|
|
179
|
+
data-headlessui-state=""
|
|
180
|
+
id="headlessui-listbox-button-_r_7_"
|
|
181
|
+
type="button"
|
|
182
|
+
>
|
|
183
|
+
<span
|
|
184
|
+
class="memori-select--value memori-select--value-placeholder"
|
|
185
|
+
>
|
|
186
|
+
Select me
|
|
187
|
+
</span>
|
|
188
|
+
<span
|
|
189
|
+
class="memori-select--icon"
|
|
190
|
+
>
|
|
191
|
+
<svg
|
|
192
|
+
aria-hidden="true"
|
|
193
|
+
fill="currentColor"
|
|
194
|
+
focusable="false"
|
|
195
|
+
role="img"
|
|
196
|
+
viewBox="0 0 20 20"
|
|
197
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
198
|
+
>
|
|
199
|
+
<path
|
|
200
|
+
clip-rule="evenodd"
|
|
201
|
+
d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z"
|
|
202
|
+
fill-rule="evenodd"
|
|
203
|
+
/>
|
|
204
|
+
</svg>
|
|
205
|
+
</span>
|
|
206
|
+
</button>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
`;
|
|
210
|
+
|
|
211
|
+
exports[`renders Select with value unchanged 1`] = `
|
|
212
|
+
<div>
|
|
213
|
+
<div
|
|
214
|
+
class="memori-select"
|
|
215
|
+
>
|
|
216
|
+
<label
|
|
217
|
+
class="memori-select--label"
|
|
218
|
+
data-headlessui-state=""
|
|
219
|
+
for="headlessui-listbox-button-_r_b_"
|
|
220
|
+
id="headlessui-label-_r_a_"
|
|
221
|
+
>
|
|
222
|
+
Select me
|
|
223
|
+
:
|
|
224
|
+
</label>
|
|
225
|
+
<button
|
|
226
|
+
aria-expanded="false"
|
|
227
|
+
aria-haspopup="listbox"
|
|
228
|
+
aria-label="Select me"
|
|
229
|
+
aria-labelledby="headlessui-label-_r_a_ headlessui-listbox-button-_r_b_"
|
|
230
|
+
class="memori-select--button"
|
|
231
|
+
data-headlessui-state=""
|
|
232
|
+
id="headlessui-listbox-button-_r_b_"
|
|
233
|
+
type="button"
|
|
234
|
+
>
|
|
235
|
+
<span
|
|
236
|
+
class="memori-select--value"
|
|
237
|
+
>
|
|
238
|
+
2
|
|
239
|
+
</span>
|
|
240
|
+
<span
|
|
241
|
+
class="memori-select--icon"
|
|
242
|
+
>
|
|
243
|
+
<svg
|
|
244
|
+
aria-hidden="true"
|
|
245
|
+
fill="currentColor"
|
|
246
|
+
focusable="false"
|
|
247
|
+
role="img"
|
|
248
|
+
viewBox="0 0 20 20"
|
|
249
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
250
|
+
>
|
|
251
|
+
<path
|
|
252
|
+
clip-rule="evenodd"
|
|
253
|
+
d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z"
|
|
254
|
+
fill-rule="evenodd"
|
|
255
|
+
/>
|
|
256
|
+
</svg>
|
|
257
|
+
</span>
|
|
258
|
+
</button>
|
|
259
|
+
</div>
|
|
260
|
+
</div>
|
|
261
|
+
`;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
.memori--slider-container {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: 100%;
|
|
4
|
+
max-width: 100%;
|
|
5
|
+
padding: 12px;
|
|
6
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
7
|
+
touch-action: none;
|
|
8
|
+
user-select: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.memori--slider-disabled {
|
|
12
|
+
cursor: not-allowed;
|
|
13
|
+
opacity: 0.6;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.memori--slider-header {
|
|
17
|
+
position: absolute;
|
|
18
|
+
display: flex;
|
|
19
|
+
width: 100%;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: space-between;
|
|
22
|
+
margin-bottom: 16px;
|
|
23
|
+
|
|
24
|
+
/* max-height: 10px; */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.memori--slider-label {
|
|
28
|
+
max-width: 70%;
|
|
29
|
+
font-size: 1.2rem;
|
|
30
|
+
font-weight: 500;
|
|
31
|
+
line-height: 1.2;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.memori--slider-value {
|
|
35
|
+
min-width: 40px;
|
|
36
|
+
max-width: 30%;
|
|
37
|
+
font-size: 1rem;
|
|
38
|
+
font-weight: 500;
|
|
39
|
+
text-align: right;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.memori--slider-track-container {
|
|
43
|
+
position: relative;
|
|
44
|
+
display: flex;
|
|
45
|
+
height: 96px;
|
|
46
|
+
max-height: 96px;
|
|
47
|
+
align-items: center;
|
|
48
|
+
margin-top: 8px;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
touch-action: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.memori--slider-track {
|
|
54
|
+
position: absolute;
|
|
55
|
+
overflow: hidden;
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: 16px;
|
|
58
|
+
max-height: 16px;
|
|
59
|
+
border-radius: 8px;
|
|
60
|
+
background-color: #e5e5e5;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.memori--slider-track-fill {
|
|
64
|
+
position: absolute;
|
|
65
|
+
width: var(--percentage);
|
|
66
|
+
height: 100%;
|
|
67
|
+
border-radius: 8px;
|
|
68
|
+
background-color: var(--memori-primary, #2563eb);
|
|
69
|
+
transition: width 0.15s ease;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.memori--slider-marks {
|
|
73
|
+
position: absolute;
|
|
74
|
+
display: flex;
|
|
75
|
+
width: 100%;
|
|
76
|
+
justify-content: space-between;
|
|
77
|
+
padding: 0 8px;
|
|
78
|
+
padding-top: 24px;
|
|
79
|
+
pointer-events: none;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.memori--slider-mark {
|
|
83
|
+
display: flex;
|
|
84
|
+
min-width: 40px;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
align-items: center;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.memori--slider-mark-line {
|
|
90
|
+
width: 3px;
|
|
91
|
+
height: 8px;
|
|
92
|
+
max-height: 8px;
|
|
93
|
+
margin-bottom: 8px;
|
|
94
|
+
background-color: #9ca3af;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.memori--slider-mark-value {
|
|
98
|
+
color: #666;
|
|
99
|
+
font-size: 1rem;
|
|
100
|
+
font-weight: 500;
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.memori--slider-thumb {
|
|
105
|
+
position: absolute;
|
|
106
|
+
z-index: 1;
|
|
107
|
+
left: var(--percentage);
|
|
108
|
+
width: 40px;
|
|
109
|
+
max-width: 40px;
|
|
110
|
+
height: 40px;
|
|
111
|
+
max-height: 40px;
|
|
112
|
+
border: 4px solid var(--memori-primary, #2563eb);
|
|
113
|
+
border-radius: 50%;
|
|
114
|
+
background-color: white;
|
|
115
|
+
box-shadow: 0 3px 6px rgb(0 0 0 / 20%);
|
|
116
|
+
touch-action: none;
|
|
117
|
+
transform: translateX(-50%);
|
|
118
|
+
transition:
|
|
119
|
+
transform 0.2s ease,
|
|
120
|
+
box-shadow 0.2s ease;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.memori--slider-thumb:hover,
|
|
124
|
+
.memori--slider-thumb:active {
|
|
125
|
+
box-shadow: 0 4px 8px rgb(0 0 0 / 25%);
|
|
126
|
+
transform: translateX(-50%) scale(1.1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* Portrait/Totem specific styles */
|
|
130
|
+
@media screen and (aspect-ratio <= 3/4) {
|
|
131
|
+
.memori--slider-container {
|
|
132
|
+
padding: 16px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.memori--slider-header {
|
|
136
|
+
margin-bottom: 16px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.memori--slider-label {
|
|
140
|
+
font-size: 1.3rem;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.memori--slider-value {
|
|
144
|
+
min-width: 50px;
|
|
145
|
+
font-size: 1.1rem;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.memori--slider-track-container {
|
|
149
|
+
height: 80px;
|
|
150
|
+
margin-top: 8px;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.memori--slider-track {
|
|
154
|
+
height: 16px;
|
|
155
|
+
border-radius: 10px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.memori--slider-thumb {
|
|
159
|
+
width: 48px;
|
|
160
|
+
height: 48px;
|
|
161
|
+
border-width: 4px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.memori--slider-mark-value {
|
|
165
|
+
margin-top: 4px;
|
|
166
|
+
font-size: 1.1rem;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* Very tall displays */
|
|
171
|
+
@media screen and (height >= 1200px) {
|
|
172
|
+
.memori--slider-container {
|
|
173
|
+
padding: 24px 20px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.memori--slider-header {
|
|
177
|
+
margin-bottom: 24px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.memori--slider-label {
|
|
181
|
+
font-size: 1.4rem;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.memori--slider-track-container {
|
|
185
|
+
height: 96px;
|
|
186
|
+
margin-top: 12px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.memori--slider-thumb {
|
|
190
|
+
width: 56px;
|
|
191
|
+
height: 56px;
|
|
192
|
+
border-width: 5px;
|
|
193
|
+
}
|
|
194
|
+
}
|