@marigold/components 0.3.0 → 0.4.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 +66 -161
- package/dist/index.d.ts +364 -32
- package/dist/index.js +1421 -5
- package/dist/index.mjs +1369 -0
- package/package.json +31 -11
- package/dist/ActionGroup/ActionGroup.d.ts +0 -8
- package/dist/ActionGroup/ActionGroup.stories.d.ts +0 -5
- package/dist/ActionGroup/index.d.ts +0 -1
- package/dist/Alert/Alert.d.ts +0 -18
- package/dist/Alert/Alert.stories.d.ts +0 -5
- package/dist/Alert/index.d.ts +0 -1
- package/dist/Badge/Badge.d.ts +0 -13
- package/dist/Badge/Badge.stories.d.ts +0 -5
- package/dist/Badge/index.d.ts +0 -1
- package/dist/Box.d.ts +0 -2
- package/dist/Button/Button.d.ts +0 -9
- package/dist/Button/Button.stories.d.ts +0 -5
- package/dist/Button/index.d.ts +0 -1
- package/dist/Card/Card.d.ts +0 -14
- package/dist/Card/Card.stories.d.ts +0 -5
- package/dist/Card/index.d.ts +0 -1
- package/dist/Checkbox/Checkbox.d.ts +0 -20
- package/dist/Checkbox/Checkbox.stories.d.ts +0 -5
- package/dist/Checkbox/CheckboxIcons.d.ts +0 -9
- package/dist/Checkbox/index.d.ts +0 -1
- package/dist/Column/Column.d.ts +0 -8
- package/dist/Column/Column.stories.d.ts +0 -5
- package/dist/Column/index.d.ts +0 -1
- package/dist/Columns/Columns.d.ts +0 -10
- package/dist/Columns/Columns.stories.d.ts +0 -5
- package/dist/Columns/index.d.ts +0 -1
- package/dist/Container/Container.d.ts +0 -6
- package/dist/Container/Container.stories.d.ts +0 -5
- package/dist/Container/index.d.ts +0 -1
- package/dist/Dialog/Dialog.d.ts +0 -17
- package/dist/Dialog/Dialog.stories.d.ts +0 -5
- package/dist/Dialog/ModalDialog.d.ts +0 -8
- package/dist/Dialog/index.d.ts +0 -1
- package/dist/Divider/Divider.d.ts +0 -12
- package/dist/Divider/Divider.stories.d.ts +0 -5
- package/dist/Divider/index.d.ts +0 -1
- package/dist/Field/Field.d.ts +0 -13
- package/dist/Field/Field.stories.d.ts +0 -5
- package/dist/Field/index.d.ts +0 -1
- package/dist/Image/Image.d.ts +0 -12
- package/dist/Image/Image.stories.d.ts +0 -5
- package/dist/Image/index.d.ts +0 -1
- package/dist/Inline/Inline.d.ts +0 -7
- package/dist/Inline/Inline.stories.d.ts +0 -5
- package/dist/Inline/index.d.ts +0 -1
- package/dist/Input/Input.d.ts +0 -11
- package/dist/Input/Input.stories.d.ts +0 -5
- package/dist/Input/index.d.ts +0 -1
- package/dist/Label/Label.d.ts +0 -19
- package/dist/Label/Label.stories.d.ts +0 -5
- package/dist/Label/index.d.ts +0 -1
- package/dist/Link/Link.d.ts +0 -10
- package/dist/Link/Link.stories.d.ts +0 -5
- package/dist/Link/index.d.ts +0 -1
- package/dist/Menu/Menu.d.ts +0 -15
- package/dist/Menu/Menu.stories.d.ts +0 -5
- package/dist/Menu/index.d.ts +0 -1
- package/dist/MenuItem/MenuItem.d.ts +0 -12
- package/dist/MenuItem/MenuItem.stories.d.ts +0 -5
- package/dist/MenuItem/index.d.ts +0 -1
- package/dist/Message/Message.d.ts +0 -12
- package/dist/Message/Message.stories.d.ts +0 -5
- package/dist/Message/index.d.ts +0 -1
- package/dist/Provider/MarigoldProvider.d.ts +0 -11
- package/dist/Provider/index.d.ts +0 -3
- package/dist/Radio/Radio.d.ts +0 -21
- package/dist/Radio/RadioIcons.d.ts +0 -10
- package/dist/Radio/index.d.ts +0 -1
- package/dist/Select/ListBox.d.ts +0 -9
- package/dist/Select/ListBoxSection.d.ts +0 -9
- package/dist/Select/Option.d.ts +0 -9
- package/dist/Select/Popover.d.ts +0 -9
- package/dist/Select/Select.d.ts +0 -27
- package/dist/Select/Select.stories.d.ts +0 -5
- package/dist/Select/index.d.ts +0 -1
- package/dist/Slider/Slider.d.ts +0 -11
- package/dist/Slider/Slider.stories.d.ts +0 -5
- package/dist/Slider/index.d.ts +0 -1
- package/dist/Stack/Stack.d.ts +0 -7
- package/dist/Stack/Stack.stories.d.ts +0 -5
- package/dist/Stack/index.d.ts +0 -1
- package/dist/Text/Text.d.ts +0 -17
- package/dist/Text/Text.stories.d.ts +0 -5
- package/dist/Text/index.d.ts +0 -1
- package/dist/Textarea/Textarea.d.ts +0 -16
- package/dist/Textarea/Textarea.stories.d.ts +0 -5
- package/dist/Textarea/index.d.ts +0 -1
- package/dist/ValidationMessage/ValidationMessage.d.ts +0 -11
- package/dist/ValidationMessage/ValidationMessage.stories.d.ts +0 -5
- package/dist/ValidationMessage/index.d.ts +0 -1
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +0 -1
- package/dist/VisuallyHidden/VisuallyHidden.stories.d.ts +0 -5
- package/dist/VisuallyHidden/index.d.ts +0 -1
- package/dist/components.cjs.development.js +0 -1422
- package/dist/components.cjs.development.js.map +0 -1
- package/dist/components.cjs.production.min.js +0 -2
- package/dist/components.cjs.production.min.js.map +0 -1
- package/dist/components.esm.js +0 -1348
- package/dist/components.esm.js.map +0 -1
- package/dist/theme.d.ts +0 -23
- package/src/ActionGroup/ActionGroup.stories.tsx +0 -47
- package/src/ActionGroup/ActionGroup.test.tsx +0 -83
- package/src/ActionGroup/ActionGroup.tsx +0 -32
- package/src/ActionGroup/index.ts +0 -1
- package/src/Alert/Alert.stories.tsx +0 -32
- package/src/Alert/Alert.test.tsx +0 -82
- package/src/Alert/Alert.tsx +0 -52
- package/src/Alert/index.ts +0 -1
- package/src/Badge/Badge.stories.tsx +0 -38
- package/src/Badge/Badge.test.tsx +0 -65
- package/src/Badge/Badge.tsx +0 -37
- package/src/Badge/index.ts +0 -1
- package/src/Box.ts +0 -2
- package/src/Button/Button.stories.tsx +0 -57
- package/src/Button/Button.test.tsx +0 -149
- package/src/Button/Button.tsx +0 -64
- package/src/Button/index.ts +0 -1
- package/src/Card/Card.stories.tsx +0 -41
- package/src/Card/Card.test.tsx +0 -71
- package/src/Card/Card.tsx +0 -48
- package/src/Card/index.ts +0 -1
- package/src/Checkbox/Checkbox.stories.mdx +0 -97
- package/src/Checkbox/Checkbox.stories.tsx +0 -78
- package/src/Checkbox/Checkbox.test.tsx +0 -166
- package/src/Checkbox/Checkbox.tsx +0 -101
- package/src/Checkbox/CheckboxIcons.tsx +0 -59
- package/src/Checkbox/index.ts +0 -1
- package/src/Column/Column.stories.tsx +0 -33
- package/src/Column/Column.test.tsx +0 -32
- package/src/Column/Column.tsx +0 -27
- package/src/Column/index.ts +0 -1
- package/src/Columns/Columns.stories.tsx +0 -75
- package/src/Columns/Columns.test.tsx +0 -113
- package/src/Columns/Columns.tsx +0 -69
- package/src/Columns/index.ts +0 -1
- package/src/Container/Container.stories.tsx +0 -14
- package/src/Container/Container.test.tsx +0 -26
- package/src/Container/Container.tsx +0 -13
- package/src/Container/index.ts +0 -1
- package/src/Dialog/Dialog.stories.tsx +0 -88
- package/src/Dialog/Dialog.test.tsx +0 -158
- package/src/Dialog/Dialog.tsx +0 -130
- package/src/Dialog/ModalDialog.tsx +0 -76
- package/src/Dialog/index.ts +0 -1
- package/src/Divider/Divider.stories.tsx +0 -30
- package/src/Divider/Divider.test.tsx +0 -71
- package/src/Divider/Divider.tsx +0 -25
- package/src/Divider/index.ts +0 -1
- package/src/Field/Field.stories.tsx +0 -110
- package/src/Field/Field.test.tsx +0 -130
- package/src/Field/Field.tsx +0 -56
- package/src/Field/index.ts +0 -1
- package/src/Image/Image.stories.tsx +0 -34
- package/src/Image/Image.test.tsx +0 -73
- package/src/Image/Image.tsx +0 -25
- package/src/Image/index.ts +0 -1
- package/src/Inline/Inline.stories.tsx +0 -39
- package/src/Inline/Inline.test.tsx +0 -99
- package/src/Inline/Inline.tsx +0 -38
- package/src/Inline/index.ts +0 -1
- package/src/Input/Input.stories.tsx +0 -54
- package/src/Input/Input.test.tsx +0 -74
- package/src/Input/Input.tsx +0 -25
- package/src/Input/index.ts +0 -1
- package/src/Label/Label.stories.tsx +0 -41
- package/src/Label/Label.test.tsx +0 -109
- package/src/Label/Label.tsx +0 -64
- package/src/Label/index.ts +0 -1
- package/src/Link/Link.stories.tsx +0 -35
- package/src/Link/Link.test.tsx +0 -97
- package/src/Link/Link.tsx +0 -42
- package/src/Link/index.ts +0 -1
- package/src/Menu/Menu.stories.tsx +0 -62
- package/src/Menu/Menu.test.tsx +0 -84
- package/src/Menu/Menu.tsx +0 -51
- package/src/Menu/index.ts +0 -1
- package/src/MenuItem/MenuItem.stories.tsx +0 -30
- package/src/MenuItem/MenuItem.test.tsx +0 -68
- package/src/MenuItem/MenuItem.tsx +0 -35
- package/src/MenuItem/index.ts +0 -1
- package/src/Message/Message.stories.tsx +0 -30
- package/src/Message/Message.test.tsx +0 -90
- package/src/Message/Message.tsx +0 -55
- package/src/Message/index.ts +0 -1
- package/src/Provider/MarigoldProvider.test.tsx +0 -136
- package/src/Provider/MarigoldProvider.tsx +0 -47
- package/src/Provider/index.ts +0 -4
- package/src/Radio/Radio.stories.mdx +0 -97
- package/src/Radio/Radio.test.tsx +0 -119
- package/src/Radio/Radio.tsx +0 -128
- package/src/Radio/RadioIcons.tsx +0 -39
- package/src/Radio/index.ts +0 -1
- package/src/Select/ListBox.tsx +0 -40
- package/src/Select/ListBoxSection.tsx +0 -40
- package/src/Select/Option.tsx +0 -48
- package/src/Select/Popover.tsx +0 -50
- package/src/Select/Select.stories.tsx +0 -81
- package/src/Select/Select.test.tsx +0 -349
- package/src/Select/Select.tsx +0 -174
- package/src/Select/index.ts +0 -1
- package/src/Slider/Slider.stories.tsx +0 -24
- package/src/Slider/Slider.test.tsx +0 -63
- package/src/Slider/Slider.tsx +0 -35
- package/src/Slider/index.ts +0 -1
- package/src/Stack/Stack.stories.tsx +0 -57
- package/src/Stack/Stack.test.tsx +0 -138
- package/src/Stack/Stack.tsx +0 -39
- package/src/Stack/index.ts +0 -1
- package/src/Text/Text.stories.tsx +0 -61
- package/src/Text/Text.test.tsx +0 -99
- package/src/Text/Text.tsx +0 -60
- package/src/Text/index.ts +0 -1
- package/src/Textarea/Textarea.stories.tsx +0 -64
- package/src/Textarea/Textarea.test.tsx +0 -95
- package/src/Textarea/Textarea.tsx +0 -62
- package/src/Textarea/index.ts +0 -1
- package/src/ValidationMessage/ValidationMessage.stories.tsx +0 -27
- package/src/ValidationMessage/ValidationMessage.test.tsx +0 -68
- package/src/ValidationMessage/ValidationMessage.tsx +0 -40
- package/src/ValidationMessage/index.ts +0 -1
- package/src/VisuallyHidden/VisuallyHidden.stories.tsx +0 -19
- package/src/VisuallyHidden/VisuallyHidden.test.tsx +0 -10
- package/src/VisuallyHidden/VisuallyHidden.tsx +0 -1
- package/src/VisuallyHidden/index.ts +0 -1
- package/src/index.ts +0 -34
- package/src/theme.ts +0 -50
- package/tsconfig.build.json +0 -3
package/src/Radio/Radio.test.tsx
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { Radio } from './Radio';
|
|
4
|
-
import { ThemeProvider } from '@marigold/system';
|
|
5
|
-
|
|
6
|
-
const theme = {
|
|
7
|
-
space: {
|
|
8
|
-
none: 0,
|
|
9
|
-
small: 2,
|
|
10
|
-
},
|
|
11
|
-
radio: {
|
|
12
|
-
__default: {
|
|
13
|
-
m: 'small',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
label: {
|
|
17
|
-
above: {
|
|
18
|
-
fontSize: '8px',
|
|
19
|
-
},
|
|
20
|
-
inline: {
|
|
21
|
-
fontSize: '14px',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
test('supports default labelVariant', () => {
|
|
27
|
-
render(
|
|
28
|
-
<ThemeProvider theme={theme}>
|
|
29
|
-
<Radio id="test" title="checkbox" label="label" />
|
|
30
|
-
</ThemeProvider>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const label = screen.getByText(/label/);
|
|
34
|
-
expect(label).toHaveStyle(`font-size: 14px`);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('supports other labelVariant than default', () => {
|
|
38
|
-
render(
|
|
39
|
-
<ThemeProvider theme={theme}>
|
|
40
|
-
<Radio id="test" title="checkbox" label="label" labelVariant="above" />
|
|
41
|
-
</ThemeProvider>
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const label = screen.getByText(/label/);
|
|
45
|
-
expect(label).toHaveStyle(`font-size: 8px`);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('supports label prop', () => {
|
|
49
|
-
render(<Radio label="Test" id="test" title="radio" />);
|
|
50
|
-
|
|
51
|
-
const radioLabel = screen.getByText(/Test/);
|
|
52
|
-
expect(radioLabel).toBeDefined();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('supports required prop and renders required icon', () => {
|
|
56
|
-
render(<Radio label="Test" id="test" required title="radio" />);
|
|
57
|
-
|
|
58
|
-
const label = screen.getByText(/Test/);
|
|
59
|
-
expect(label.nextSibling).toContainHTML('path d="M10.8');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('supports default type', () => {
|
|
63
|
-
render(<Radio id="radio" title="radio" />);
|
|
64
|
-
|
|
65
|
-
const radio = screen.getByTitle(/radio/);
|
|
66
|
-
expect(radio.getAttribute('type')).toEqual('radio');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('renders <input> element', () => {
|
|
70
|
-
render(<Radio id="radio" title="radio" />);
|
|
71
|
-
|
|
72
|
-
const radio = screen.getByTitle(/radio/);
|
|
73
|
-
expect(radio instanceof HTMLInputElement).toBeTruthy();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('supports disabled prop', () => {
|
|
77
|
-
render(
|
|
78
|
-
<ThemeProvider theme={theme}>
|
|
79
|
-
<Radio id="test" title="radio" label="label" disabled />
|
|
80
|
-
</ThemeProvider>
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const radio = screen.getByTitle(/radio/);
|
|
84
|
-
expect(radio).toHaveAttribute('disabled');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('supports error and errorMessage prop', () => {
|
|
88
|
-
render(
|
|
89
|
-
<ThemeProvider theme={theme}>
|
|
90
|
-
<Radio id="test" title="radio" label="test" error errorMessage="error" />
|
|
91
|
-
</ThemeProvider>
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
const errorMessage = screen.getByText(/error/);
|
|
95
|
-
expect(errorMessage).toBeDefined();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('supports checked radio', () => {
|
|
99
|
-
render(
|
|
100
|
-
<ThemeProvider theme={theme}>
|
|
101
|
-
<Radio id="test" title="radio" onChange={() => {}} checked />
|
|
102
|
-
</ThemeProvider>
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const radio = screen.getByTitle(/radio/);
|
|
106
|
-
expect(radio).toBeDefined();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test('supports checked and disabled radio', () => {
|
|
110
|
-
render(
|
|
111
|
-
<ThemeProvider theme={theme}>
|
|
112
|
-
<Radio id="test" title="radio" onChange={() => {}} checked disabled />
|
|
113
|
-
</ThemeProvider>
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const radio = screen.getByTitle(/radio/);
|
|
117
|
-
expect(radio).toBeDefined();
|
|
118
|
-
expect(radio).toHaveAttribute('disabled');
|
|
119
|
-
});
|
package/src/Radio/Radio.tsx
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ComponentProps } from '@marigold/types';
|
|
3
|
-
import { Exclamation } from '@marigold/icons';
|
|
4
|
-
|
|
5
|
-
import { Box } from '../Box';
|
|
6
|
-
import { Label } from '../Label';
|
|
7
|
-
import { ValidationMessage } from '../ValidationMessage';
|
|
8
|
-
|
|
9
|
-
import { RadioChecked, RadioUnchecked } from './RadioIcons';
|
|
10
|
-
|
|
11
|
-
// Theme Extension
|
|
12
|
-
// ---------------
|
|
13
|
-
export interface RadioThemeExtension<Value> {
|
|
14
|
-
radio?: {
|
|
15
|
-
[key: string]: Value;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Radio Icon
|
|
20
|
-
// ---------------
|
|
21
|
-
type RadioIconProps = {
|
|
22
|
-
variant?: string;
|
|
23
|
-
checked?: boolean;
|
|
24
|
-
disabled?: boolean;
|
|
25
|
-
error?: boolean;
|
|
26
|
-
children?: never;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const RadioIcon: React.FC<RadioIconProps> = ({
|
|
30
|
-
variant,
|
|
31
|
-
checked,
|
|
32
|
-
disabled,
|
|
33
|
-
error,
|
|
34
|
-
}) => {
|
|
35
|
-
if (checked) {
|
|
36
|
-
return (
|
|
37
|
-
<Box as={RadioChecked} variant={`radio.${variant}`} disabled={disabled} />
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
return (
|
|
41
|
-
<Box
|
|
42
|
-
as={RadioUnchecked}
|
|
43
|
-
variant={`radio.${variant}`}
|
|
44
|
-
disabled={disabled}
|
|
45
|
-
error={error}
|
|
46
|
-
/>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// Radio Input
|
|
51
|
-
// ---------------
|
|
52
|
-
type RadioInputProps = {
|
|
53
|
-
variant?: string;
|
|
54
|
-
error?: boolean;
|
|
55
|
-
} & ComponentProps<'input'>;
|
|
56
|
-
|
|
57
|
-
const RadioInput: React.FC<RadioInputProps> = ({
|
|
58
|
-
className,
|
|
59
|
-
variant = '',
|
|
60
|
-
error,
|
|
61
|
-
...props
|
|
62
|
-
}) => (
|
|
63
|
-
<Box display="inline-block" className={className}>
|
|
64
|
-
<Box
|
|
65
|
-
as="input"
|
|
66
|
-
type="radio"
|
|
67
|
-
css={{
|
|
68
|
-
position: 'absolute',
|
|
69
|
-
opacity: 0,
|
|
70
|
-
zIndex: -1,
|
|
71
|
-
width: 1,
|
|
72
|
-
height: 1,
|
|
73
|
-
overflow: 'hidden',
|
|
74
|
-
}}
|
|
75
|
-
{...props}
|
|
76
|
-
/>
|
|
77
|
-
<RadioIcon
|
|
78
|
-
checked={props.checked}
|
|
79
|
-
variant={variant}
|
|
80
|
-
disabled={props.disabled}
|
|
81
|
-
error={error}
|
|
82
|
-
/>
|
|
83
|
-
</Box>
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// Radio
|
|
87
|
-
// ---------------
|
|
88
|
-
export type RadioProps = {
|
|
89
|
-
id: string;
|
|
90
|
-
label?: string;
|
|
91
|
-
required?: boolean;
|
|
92
|
-
labelVariant?: string;
|
|
93
|
-
error?: boolean;
|
|
94
|
-
errorMessage?: string;
|
|
95
|
-
} & RadioInputProps;
|
|
96
|
-
|
|
97
|
-
export const Radio: React.FC<RadioProps> = ({
|
|
98
|
-
label,
|
|
99
|
-
required,
|
|
100
|
-
labelVariant = 'inline',
|
|
101
|
-
error,
|
|
102
|
-
errorMessage,
|
|
103
|
-
...props
|
|
104
|
-
}) => {
|
|
105
|
-
if (label) {
|
|
106
|
-
return (
|
|
107
|
-
<>
|
|
108
|
-
<Label
|
|
109
|
-
htmlFor={props.id}
|
|
110
|
-
required={required}
|
|
111
|
-
variant={labelVariant}
|
|
112
|
-
color={props.disabled ? 'disabled' : 'text'}
|
|
113
|
-
>
|
|
114
|
-
<Box as={RadioInput} pr="8px" error={error} {...props} />
|
|
115
|
-
{label}
|
|
116
|
-
</Label>
|
|
117
|
-
{error && errorMessage && (
|
|
118
|
-
<ValidationMessage>
|
|
119
|
-
<Exclamation size={16} />
|
|
120
|
-
{errorMessage}
|
|
121
|
-
</ValidationMessage>
|
|
122
|
-
)}
|
|
123
|
-
</>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return <RadioInput {...props} />;
|
|
128
|
-
};
|
package/src/Radio/RadioIcons.tsx
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SVG } from '@marigold/system';
|
|
3
|
-
|
|
4
|
-
import { Box } from '../Box';
|
|
5
|
-
|
|
6
|
-
export const RadioChecked = ({ disabled = false, ...props }) => (
|
|
7
|
-
<SVG width="16" height="32" viewBox="0 0 16 32" fill="none" {...props}>
|
|
8
|
-
<Box
|
|
9
|
-
as="circle"
|
|
10
|
-
cx="8"
|
|
11
|
-
cy="16"
|
|
12
|
-
r="7.5"
|
|
13
|
-
variant={disabled ? 'radio.checked.disabled' : 'radio.checked'}
|
|
14
|
-
/>
|
|
15
|
-
<Box as="circle" cx="8" cy="16" r="3" variant="radio.checked.circle" />
|
|
16
|
-
</SVG>
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export const RadioUnchecked = ({
|
|
20
|
-
disabled = false,
|
|
21
|
-
error = false,
|
|
22
|
-
...props
|
|
23
|
-
}) => (
|
|
24
|
-
<SVG width="16" height="32" viewBox="0 0 16 32" fill="none" {...props}>
|
|
25
|
-
<Box
|
|
26
|
-
as="circle"
|
|
27
|
-
cx="8"
|
|
28
|
-
cy="16"
|
|
29
|
-
r="7.5"
|
|
30
|
-
variant={
|
|
31
|
-
disabled
|
|
32
|
-
? 'radio.unchecked.disabled'
|
|
33
|
-
: error
|
|
34
|
-
? 'radio.unchecked.error'
|
|
35
|
-
: 'radio.unchecked'
|
|
36
|
-
}
|
|
37
|
-
/>
|
|
38
|
-
</SVG>
|
|
39
|
-
);
|
package/src/Radio/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Radio';
|
package/src/Select/ListBox.tsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import { useListBox } from '@react-aria/listbox';
|
|
3
|
-
import type { AriaListBoxOptions } from '@react-aria/listbox';
|
|
4
|
-
import type { ListState } from '@react-stately/list';
|
|
5
|
-
|
|
6
|
-
import { Box } from '../Box';
|
|
7
|
-
import { Option } from './Option';
|
|
8
|
-
import { ListBoxSection } from './ListBoxSection';
|
|
9
|
-
|
|
10
|
-
interface ListBoxProps extends AriaListBoxOptions<unknown> {
|
|
11
|
-
state: ListState<unknown>;
|
|
12
|
-
error?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const ListBox = (props: ListBoxProps) => {
|
|
16
|
-
const ref = useRef<HTMLUListElement>(null);
|
|
17
|
-
const { state, error } = props;
|
|
18
|
-
const { listBoxProps } = useListBox(props, state, ref);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Box
|
|
22
|
-
as="ul"
|
|
23
|
-
p="none"
|
|
24
|
-
css={{
|
|
25
|
-
listStyle: 'none',
|
|
26
|
-
}}
|
|
27
|
-
{...listBoxProps}
|
|
28
|
-
variant={error ? 'select.listbox.error' : 'select.listbox'}
|
|
29
|
-
ref={ref}
|
|
30
|
-
>
|
|
31
|
-
{[...state.collection].map(item =>
|
|
32
|
-
item.type === 'section' ? (
|
|
33
|
-
<ListBoxSection key={item.key} section={item} state={state} />
|
|
34
|
-
) : (
|
|
35
|
-
<Option key={item.key} item={item} state={state} />
|
|
36
|
-
)
|
|
37
|
-
)}
|
|
38
|
-
</Box>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useListBoxSection } from '@react-aria/listbox';
|
|
3
|
-
import type { ListState } from '@react-stately/list';
|
|
4
|
-
import type { Node } from '@react-types/shared';
|
|
5
|
-
|
|
6
|
-
import { Box } from '../Box';
|
|
7
|
-
import { Option } from './Option';
|
|
8
|
-
|
|
9
|
-
interface SectionProps {
|
|
10
|
-
section: Node<unknown>;
|
|
11
|
-
state: ListState<unknown>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const ListBoxSection = ({ section, state }: SectionProps) => {
|
|
15
|
-
const { itemProps, headingProps, groupProps } = useListBoxSection({
|
|
16
|
-
heading: section.rendered,
|
|
17
|
-
'aria-label': section['aria-label'],
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Box
|
|
22
|
-
as="li"
|
|
23
|
-
{...itemProps}
|
|
24
|
-
css={{
|
|
25
|
-
cursor: 'not-allowed',
|
|
26
|
-
}}
|
|
27
|
-
>
|
|
28
|
-
{section.rendered && (
|
|
29
|
-
<Box as="span" {...headingProps} variant={'select.section'}>
|
|
30
|
-
{section.rendered}
|
|
31
|
-
</Box>
|
|
32
|
-
)}
|
|
33
|
-
<Box as="ul" {...groupProps}>
|
|
34
|
-
{[...section.childNodes].map(node => (
|
|
35
|
-
<Option key={node.key} item={node} state={state} />
|
|
36
|
-
))}
|
|
37
|
-
</Box>
|
|
38
|
-
</Box>
|
|
39
|
-
);
|
|
40
|
-
};
|
package/src/Select/Option.tsx
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import type { ListState } from '@react-stately/list';
|
|
3
|
-
import type { Node } from '@react-types/shared';
|
|
4
|
-
import { useOption } from '@react-aria/listbox';
|
|
5
|
-
|
|
6
|
-
import { Box } from '../Box';
|
|
7
|
-
|
|
8
|
-
interface OptionProps {
|
|
9
|
-
item: Node<unknown>;
|
|
10
|
-
state: ListState<unknown>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const Option = ({ item, state }: OptionProps) => {
|
|
14
|
-
const ref = useRef<HTMLLIElement>(null);
|
|
15
|
-
const [disabled, setDisabled] = useState(false);
|
|
16
|
-
const { optionProps, isSelected } = useOption(
|
|
17
|
-
{
|
|
18
|
-
key: item.key,
|
|
19
|
-
},
|
|
20
|
-
state,
|
|
21
|
-
ref
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
for (const key of state.disabledKeys.values()) {
|
|
26
|
-
if (key === item.key) {
|
|
27
|
-
setDisabled(true);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}, [state.disabledKeys, item.key]);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Box
|
|
34
|
-
as="li"
|
|
35
|
-
{...optionProps}
|
|
36
|
-
ref={ref}
|
|
37
|
-
variant={
|
|
38
|
-
isSelected
|
|
39
|
-
? 'select.option.selected'
|
|
40
|
-
: disabled
|
|
41
|
-
? 'select.option.disabled'
|
|
42
|
-
: 'select.option'
|
|
43
|
-
}
|
|
44
|
-
>
|
|
45
|
-
{item.rendered}
|
|
46
|
-
</Box>
|
|
47
|
-
);
|
|
48
|
-
};
|
package/src/Select/Popover.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, RefObject } from 'react';
|
|
2
|
-
import { FocusScope } from '@react-aria/focus';
|
|
3
|
-
import {
|
|
4
|
-
DismissButton,
|
|
5
|
-
OverlayContainer,
|
|
6
|
-
useModal,
|
|
7
|
-
useOverlay,
|
|
8
|
-
} from '@react-aria/overlays';
|
|
9
|
-
import { mergeProps } from '@react-aria/utils';
|
|
10
|
-
|
|
11
|
-
import { Box } from '../Box';
|
|
12
|
-
|
|
13
|
-
interface PopoverProps {
|
|
14
|
-
isOpen?: boolean;
|
|
15
|
-
onClose?: () => void;
|
|
16
|
-
ref?: React.Ref<HTMLDivElement>;
|
|
17
|
-
className?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const Popover: React.FC<PopoverProps> = forwardRef(
|
|
21
|
-
({ children, className, isOpen, onClose, ...otherProps }, ref) => {
|
|
22
|
-
// Handle events that should cause the popup to close,
|
|
23
|
-
const { overlayProps } = useOverlay(
|
|
24
|
-
{
|
|
25
|
-
isOpen,
|
|
26
|
-
onClose,
|
|
27
|
-
shouldCloseOnBlur: true,
|
|
28
|
-
isDismissable: true,
|
|
29
|
-
},
|
|
30
|
-
ref as RefObject<HTMLElement>
|
|
31
|
-
);
|
|
32
|
-
// Hide content outside the modal from screen readers.
|
|
33
|
-
const { modalProps } = useModal();
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<OverlayContainer>
|
|
37
|
-
<FocusScope restoreFocus>
|
|
38
|
-
<Box
|
|
39
|
-
{...mergeProps(overlayProps, otherProps, modalProps)}
|
|
40
|
-
className={className}
|
|
41
|
-
ref={ref}
|
|
42
|
-
>
|
|
43
|
-
{children}
|
|
44
|
-
<DismissButton onDismiss={onClose} />
|
|
45
|
-
</Box>
|
|
46
|
-
</FocusScope>
|
|
47
|
-
</OverlayContainer>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
);
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Select } from './Select';
|
|
4
|
-
import { Item } from '@marigold/components';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Components/Select',
|
|
8
|
-
argTypes: {
|
|
9
|
-
label: {
|
|
10
|
-
control: {
|
|
11
|
-
type: 'text',
|
|
12
|
-
},
|
|
13
|
-
table: {
|
|
14
|
-
defaultValue: {
|
|
15
|
-
summary: 'Select label',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
defaultValue: 'Favorite Color',
|
|
19
|
-
},
|
|
20
|
-
placeholder: {
|
|
21
|
-
control: {
|
|
22
|
-
type: 'text',
|
|
23
|
-
},
|
|
24
|
-
table: {
|
|
25
|
-
defaultValue: {
|
|
26
|
-
summary: 'Select an option',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
disabled: {
|
|
31
|
-
control: {
|
|
32
|
-
type: 'boolean',
|
|
33
|
-
},
|
|
34
|
-
options: [true, false],
|
|
35
|
-
table: {
|
|
36
|
-
defaultValue: {
|
|
37
|
-
summary: false,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
required: {
|
|
42
|
-
control: {
|
|
43
|
-
type: 'boolean',
|
|
44
|
-
},
|
|
45
|
-
options: [true, false],
|
|
46
|
-
table: {
|
|
47
|
-
defaultValue: {
|
|
48
|
-
summary: false,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
error: {
|
|
53
|
-
control: {
|
|
54
|
-
type: 'boolean',
|
|
55
|
-
},
|
|
56
|
-
description: 'Error',
|
|
57
|
-
table: {
|
|
58
|
-
defaultValue: {
|
|
59
|
-
summary: false,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
errorMessage: {
|
|
64
|
-
control: {
|
|
65
|
-
type: 'text',
|
|
66
|
-
},
|
|
67
|
-
description: 'Error Message',
|
|
68
|
-
},
|
|
69
|
-
width: {
|
|
70
|
-
control: 'number',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
} as Meta;
|
|
74
|
-
|
|
75
|
-
export const Basic: ComponentStory<typeof Select> = args => (
|
|
76
|
-
<Select {...args}>
|
|
77
|
-
<Item>Red</Item>
|
|
78
|
-
<Item>Orange</Item>
|
|
79
|
-
<Item>Yellow</Item>
|
|
80
|
-
</Select>
|
|
81
|
-
);
|