react-science 0.29.0 → 0.30.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/lib-esm/components/button/Button.d.ts.map +1 -1
- package/lib-esm/components/button/Button.js +1 -1
- package/lib-esm/components/button/Button.js.map +1 -1
- package/lib-esm/components/drop-zone/DropZone.d.ts +6 -2
- package/lib-esm/components/drop-zone/DropZone.d.ts.map +1 -1
- package/lib-esm/components/drop-zone/DropZone.js +9 -15
- package/lib-esm/components/drop-zone/DropZone.js.map +1 -1
- package/lib-esm/components/forms/index.d.ts +0 -5
- package/lib-esm/components/forms/index.d.ts.map +1 -1
- package/lib-esm/components/forms/index.js +0 -5
- package/lib-esm/components/forms/index.js.map +1 -1
- package/lib-esm/components/forms/radio-group/RadioGroup.d.ts +1 -0
- package/lib-esm/components/forms/radio-group/RadioGroup.d.ts.map +1 -1
- package/lib-esm/components/forms/radio-group/RadioGroup.js +2 -2
- package/lib-esm/components/forms/radio-group/RadioGroup.js.map +1 -1
- package/lib-esm/components/forms/styles.d.ts +0 -22
- package/lib-esm/components/forms/styles.d.ts.map +1 -1
- package/lib-esm/components/forms/styles.js +0 -72
- package/lib-esm/components/forms/styles.js.map +1 -1
- package/lib-esm/components/index.d.ts +0 -1
- package/lib-esm/components/index.d.ts.map +1 -1
- package/lib-esm/components/index.js +0 -1
- package/lib-esm/components/index.js.map +1 -1
- package/lib-esm/components/info-panel/InfoPanel.d.ts.map +1 -1
- package/lib-esm/components/info-panel/InfoPanel.js +4 -3
- package/lib-esm/components/info-panel/InfoPanel.js.map +1 -1
- package/lib-esm/components/toolbar/Toolbar.js +1 -1
- package/lib-esm/components/toolbar/Toolbar.js.map +1 -1
- package/package.json +2 -1
- package/src/components/button/Button.tsx +9 -3
- package/src/components/drop-zone/DropZone.tsx +42 -25
- package/src/components/forms/index.ts +0 -5
- package/src/components/forms/radio-group/RadioGroup.tsx +3 -0
- package/src/components/forms/styles.ts +0 -92
- package/src/components/index.ts +0 -1
- package/src/components/info-panel/InfoPanel.tsx +5 -2
- package/src/components/toolbar/Toolbar.tsx +1 -1
- package/lib-esm/components/forms/Checkbox.d.ts +0 -11
- package/lib-esm/components/forms/Checkbox.d.ts.map +0 -1
- package/lib-esm/components/forms/Checkbox.js +0 -35
- package/lib-esm/components/forms/Checkbox.js.map +0 -1
- package/lib-esm/components/forms/Input.d.ts +0 -19
- package/lib-esm/components/forms/Input.d.ts.map +0 -1
- package/lib-esm/components/forms/Input.js +0 -60
- package/lib-esm/components/forms/Input.js.map +0 -1
- package/lib-esm/components/forms/Select.d.ts +0 -21
- package/lib-esm/components/forms/Select.d.ts.map +0 -1
- package/lib-esm/components/forms/Select.js +0 -90
- package/lib-esm/components/forms/Select.js.map +0 -1
- package/lib-esm/components/forms/TextArea.d.ts +0 -8
- package/lib-esm/components/forms/TextArea.d.ts.map +0 -1
- package/lib-esm/components/forms/TextArea.js +0 -19
- package/lib-esm/components/forms/TextArea.js.map +0 -1
- package/lib-esm/components/forms/context/FieldsContext.d.ts +0 -16
- package/lib-esm/components/forms/context/FieldsContext.d.ts.map +0 -1
- package/lib-esm/components/forms/context/FieldsContext.js +0 -47
- package/lib-esm/components/forms/context/FieldsContext.js.map +0 -1
- package/lib-esm/components/forms/context/index.d.ts +0 -2
- package/lib-esm/components/forms/context/index.d.ts.map +0 -1
- package/lib-esm/components/forms/context/index.js +0 -2
- package/lib-esm/components/forms/context/index.js.map +0 -1
- package/lib-esm/components/spinner/FullSpinner.d.ts +0 -7
- package/lib-esm/components/spinner/FullSpinner.d.ts.map +0 -1
- package/lib-esm/components/spinner/FullSpinner.js +0 -24
- package/lib-esm/components/spinner/FullSpinner.js.map +0 -1
- package/lib-esm/components/spinner/index.d.ts +0 -2
- package/lib-esm/components/spinner/index.d.ts.map +0 -1
- package/lib-esm/components/spinner/index.js +0 -2
- package/lib-esm/components/spinner/index.js.map +0 -1
- package/src/components/forms/Checkbox.tsx +0 -77
- package/src/components/forms/Input.tsx +0 -144
- package/src/components/forms/Select.tsx +0 -197
- package/src/components/forms/TextArea.tsx +0 -45
- package/src/components/forms/context/FieldsContext.tsx +0 -82
- package/src/components/forms/context/index.ts +0 -1
- package/src/components/spinner/FullSpinner.tsx +0 -57
- package/src/components/spinner/index.ts +0 -1
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @emotion/react */
|
|
2
|
-
import { css } from '@emotion/react';
|
|
3
|
-
import * as RadixCheckbox from '@radix-ui/react-checkbox';
|
|
4
|
-
import { ReactNode } from 'react';
|
|
5
|
-
import { RxCheck, RxMinus } from 'react-icons/rx/index';
|
|
6
|
-
|
|
7
|
-
import { disabledColor, enabledColor } from './styles';
|
|
8
|
-
|
|
9
|
-
export type CheckedState = boolean | 'indeterminate';
|
|
10
|
-
|
|
11
|
-
interface CheckboxProps {
|
|
12
|
-
checked?: CheckedState;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
label?: ReactNode;
|
|
15
|
-
onChange?: (checked: CheckedState) => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function Checkbox(props: CheckboxProps) {
|
|
19
|
-
const {
|
|
20
|
-
checked = 'indeterminate',
|
|
21
|
-
disabled = false,
|
|
22
|
-
label,
|
|
23
|
-
onChange,
|
|
24
|
-
} = props;
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<label
|
|
28
|
-
style={{
|
|
29
|
-
display: 'flex',
|
|
30
|
-
alignItems: 'center',
|
|
31
|
-
fontSize: '1.125em',
|
|
32
|
-
}}
|
|
33
|
-
>
|
|
34
|
-
<RadixCheckbox.Root
|
|
35
|
-
checked={checked}
|
|
36
|
-
onCheckedChange={onChange}
|
|
37
|
-
disabled={disabled}
|
|
38
|
-
css={css({
|
|
39
|
-
width: '16px',
|
|
40
|
-
height: '16px',
|
|
41
|
-
backgroundColor: disabled
|
|
42
|
-
? 'rgba(0, 0, 0, 0.04)'
|
|
43
|
-
: checked
|
|
44
|
-
? enabledColor
|
|
45
|
-
: 'white',
|
|
46
|
-
borderWidth: '1px',
|
|
47
|
-
borderColor: checked && !disabled ? enabledColor : disabledColor,
|
|
48
|
-
borderRadius: '4px',
|
|
49
|
-
display: 'flex',
|
|
50
|
-
alignItems: 'center',
|
|
51
|
-
justifyContent: 'center',
|
|
52
|
-
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
53
|
-
})}
|
|
54
|
-
>
|
|
55
|
-
<RadixCheckbox.Indicator
|
|
56
|
-
css={css({
|
|
57
|
-
color: disabled ? disabledColor : 'white',
|
|
58
|
-
})}
|
|
59
|
-
>
|
|
60
|
-
{checked === true ? (
|
|
61
|
-
<RxCheck />
|
|
62
|
-
) : checked === 'indeterminate' ? (
|
|
63
|
-
<RxMinus />
|
|
64
|
-
) : null}
|
|
65
|
-
</RadixCheckbox.Indicator>
|
|
66
|
-
</RadixCheckbox.Root>
|
|
67
|
-
<span
|
|
68
|
-
style={{
|
|
69
|
-
paddingInline: '8px',
|
|
70
|
-
lineHeight: '16px',
|
|
71
|
-
}}
|
|
72
|
-
>
|
|
73
|
-
{label}
|
|
74
|
-
</span>
|
|
75
|
-
</label>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import styled from '@emotion/styled';
|
|
2
|
-
import { InputHTMLAttributes, ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
import { FullSpinner } from '../index';
|
|
5
|
-
|
|
6
|
-
import { useFieldsContext } from './context/FieldsContext';
|
|
7
|
-
import {
|
|
8
|
-
InputContainer,
|
|
9
|
-
GroupStyled,
|
|
10
|
-
LabelStyled,
|
|
11
|
-
InputVariant,
|
|
12
|
-
} from './styles';
|
|
13
|
-
import { SubText, SubTextProps } from './utils';
|
|
14
|
-
|
|
15
|
-
const InputStyled = styled.input`
|
|
16
|
-
padding: 0;
|
|
17
|
-
flex: 1 1 0%;
|
|
18
|
-
border: none;
|
|
19
|
-
position: relative;
|
|
20
|
-
outline: none;
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
const LeadingAddonStyled = styled.div`
|
|
24
|
-
padding-left: 0.75rem;
|
|
25
|
-
padding-right: 0.75rem;
|
|
26
|
-
border-right-width: 0px;
|
|
27
|
-
border-width: 1px;
|
|
28
|
-
border-top-left-radius: 0.375rem;
|
|
29
|
-
border-bottom-left-radius: 0.375rem;
|
|
30
|
-
align-items: center;
|
|
31
|
-
display: inline-flex;
|
|
32
|
-
|
|
33
|
-
border-right: none;
|
|
34
|
-
|
|
35
|
-
border-color: var(--custom-border-color);
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
const TrailingAddonStyled = styled.div`
|
|
39
|
-
padding-left: 0.75rem;
|
|
40
|
-
padding-right: 0.75rem;
|
|
41
|
-
border-left-width: 0px;
|
|
42
|
-
border-width: 1px;
|
|
43
|
-
border-top-right-radius: 0.375rem;
|
|
44
|
-
border-bottom-right-radius: 0.375rem;
|
|
45
|
-
align-items: center;
|
|
46
|
-
display: inline-flex;
|
|
47
|
-
|
|
48
|
-
border-left: none;
|
|
49
|
-
|
|
50
|
-
border-color: var(--custom-border-color);
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
|
-
const LeadingInlineAddonStyled = styled.div`
|
|
54
|
-
display: flex;
|
|
55
|
-
align-items: center;
|
|
56
|
-
padding-right: 0.5rem;
|
|
57
|
-
`;
|
|
58
|
-
|
|
59
|
-
const TrailingInlineAddonStyled = styled.div`
|
|
60
|
-
display: flex;
|
|
61
|
-
align-items: center;
|
|
62
|
-
padding-left: 0.5rem;
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
interface RenderAddon {
|
|
66
|
-
addon: ReactNode;
|
|
67
|
-
inline?: boolean;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface InputProps
|
|
71
|
-
extends InputHTMLAttributes<HTMLInputElement>,
|
|
72
|
-
SubTextProps {
|
|
73
|
-
variant?: InputVariant;
|
|
74
|
-
leadingAddon?: RenderAddon;
|
|
75
|
-
trailingAddon?: RenderAddon;
|
|
76
|
-
help?: string;
|
|
77
|
-
error?: string;
|
|
78
|
-
valid?: true | string;
|
|
79
|
-
loading?: boolean;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function Input(props: InputProps) {
|
|
83
|
-
const {
|
|
84
|
-
variant: variantProps,
|
|
85
|
-
trailingAddon,
|
|
86
|
-
leadingAddon,
|
|
87
|
-
help,
|
|
88
|
-
error,
|
|
89
|
-
valid,
|
|
90
|
-
loading,
|
|
91
|
-
...otherProps
|
|
92
|
-
} = props;
|
|
93
|
-
|
|
94
|
-
const { name, variant: contextVariant } = useFieldsContext();
|
|
95
|
-
|
|
96
|
-
const hasLeading = (leadingAddon && !leadingAddon.inline) || false;
|
|
97
|
-
const hasTrailing = (trailingAddon && !trailingAddon.inline) || false;
|
|
98
|
-
const variant = variantProps || contextVariant;
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<InputContainer>
|
|
102
|
-
<GroupStyled hasError={!!error} hasValid={!!valid}>
|
|
103
|
-
{leadingAddon && !leadingAddon.inline && (
|
|
104
|
-
<LeadingAddonStyled>{leadingAddon.addon}</LeadingAddonStyled>
|
|
105
|
-
)}
|
|
106
|
-
|
|
107
|
-
<LabelStyled
|
|
108
|
-
variant={variant}
|
|
109
|
-
hasLeading={hasLeading}
|
|
110
|
-
hasTrailing={hasTrailing}
|
|
111
|
-
>
|
|
112
|
-
{leadingAddon?.inline && (
|
|
113
|
-
<LeadingInlineAddonStyled className="addon">
|
|
114
|
-
{leadingAddon.addon}
|
|
115
|
-
</LeadingInlineAddonStyled>
|
|
116
|
-
)}
|
|
117
|
-
<InputStyled id={name} name={name} {...otherProps} />
|
|
118
|
-
{trailingAddon?.inline && (
|
|
119
|
-
<TrailingInlineAddonStyled className="addon">
|
|
120
|
-
{trailingAddon.addon}
|
|
121
|
-
</TrailingInlineAddonStyled>
|
|
122
|
-
)}
|
|
123
|
-
|
|
124
|
-
{loading && (
|
|
125
|
-
<TrailingInlineAddonStyled
|
|
126
|
-
style={{ height: variant === 'default' ? 20 : 10 }}
|
|
127
|
-
>
|
|
128
|
-
<FullSpinner
|
|
129
|
-
height={variant === 'default' ? 20 : 10}
|
|
130
|
-
width={variant === 'default' ? 20 : 10}
|
|
131
|
-
/>
|
|
132
|
-
</TrailingInlineAddonStyled>
|
|
133
|
-
)}
|
|
134
|
-
</LabelStyled>
|
|
135
|
-
|
|
136
|
-
{trailingAddon && !trailingAddon.inline && (
|
|
137
|
-
<TrailingAddonStyled>{trailingAddon.addon}</TrailingAddonStyled>
|
|
138
|
-
)}
|
|
139
|
-
</GroupStyled>
|
|
140
|
-
|
|
141
|
-
<SubText error={error} help={help} valid={valid} />
|
|
142
|
-
</InputContainer>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @emotion/react */
|
|
2
|
-
import styled from '@emotion/styled';
|
|
3
|
-
import * as RadixSelect from '@radix-ui/react-select';
|
|
4
|
-
import { SelectGroup } from '@radix-ui/react-select';
|
|
5
|
-
import { Fragment, ReactNode, CSSProperties } from 'react';
|
|
6
|
-
import { FaCheck, FaChevronDown, FaChevronUp } from 'react-icons/fa';
|
|
7
|
-
|
|
8
|
-
import { Portal } from '../root-layout/Portal';
|
|
9
|
-
|
|
10
|
-
interface Category {
|
|
11
|
-
label: ReactNode;
|
|
12
|
-
options: Option[];
|
|
13
|
-
}
|
|
14
|
-
interface Option {
|
|
15
|
-
label: ReactNode;
|
|
16
|
-
value: string;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface SelectProps {
|
|
21
|
-
placeholder?: string;
|
|
22
|
-
value: string | undefined;
|
|
23
|
-
onSelect?: (value: string | undefined) => void;
|
|
24
|
-
options: Array<Option[] | Category[]>;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
style?: CSSProperties;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const SelectRoot = styled.div`
|
|
30
|
-
display: inline-flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
justify-content: space-between;
|
|
33
|
-
background-color: #ffffff;
|
|
34
|
-
font-size: 1.125em;
|
|
35
|
-
width: 120px;
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
const SelectTrigger = styled(RadixSelect.Trigger)`
|
|
39
|
-
width: 100%;
|
|
40
|
-
display: flex;
|
|
41
|
-
align-items: center;
|
|
42
|
-
justify-content: space-between;
|
|
43
|
-
border-radius: 4px;
|
|
44
|
-
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
45
|
-
padding: 4px 11px;
|
|
46
|
-
user-select: none;
|
|
47
|
-
font-size: 1.125em;
|
|
48
|
-
line-height: 1.125em;
|
|
49
|
-
|
|
50
|
-
&[data-disabled] {
|
|
51
|
-
color: rgba(0, 0, 0, 0.5);
|
|
52
|
-
background-color: #f5f5f5;
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
|
|
56
|
-
const SelectContent = styled(RadixSelect.Content)`
|
|
57
|
-
width: var(--radix-select-trigger-width);
|
|
58
|
-
max-height: var(--radix-select-content-available-height);
|
|
59
|
-
`;
|
|
60
|
-
|
|
61
|
-
const SelectViewport = styled(RadixSelect.Viewport)`
|
|
62
|
-
width: var(--radix-select-trigger-width);
|
|
63
|
-
border-radius: 4px;
|
|
64
|
-
box-sizing: border-box;
|
|
65
|
-
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
66
|
-
background-color: white;
|
|
67
|
-
padding: 5px;
|
|
68
|
-
`;
|
|
69
|
-
|
|
70
|
-
const SelectItem = styled(RadixSelect.Item)`
|
|
71
|
-
user-select: none;
|
|
72
|
-
font-size: 1.125em;
|
|
73
|
-
padding: 4px 11px;
|
|
74
|
-
width: 100%;
|
|
75
|
-
display: flex;
|
|
76
|
-
align-items: center;
|
|
77
|
-
justify-content: space-between;
|
|
78
|
-
|
|
79
|
-
&:hover {
|
|
80
|
-
background-color: #e6f4ff;
|
|
81
|
-
}
|
|
82
|
-
&[data-disabled] {
|
|
83
|
-
color: rgba(0, 0, 0, 0.5);
|
|
84
|
-
}
|
|
85
|
-
`;
|
|
86
|
-
|
|
87
|
-
const SelectLabel = styled(RadixSelect.Label)`
|
|
88
|
-
color: rgba(0, 0, 0, 0.5);
|
|
89
|
-
font-size: 1em;
|
|
90
|
-
padding: 4px 11px;
|
|
91
|
-
margin-top: 8px;
|
|
92
|
-
`;
|
|
93
|
-
|
|
94
|
-
const SelectItemIndicator = styled(RadixSelect.ItemIndicator)`
|
|
95
|
-
right: 0;
|
|
96
|
-
width: 25px;
|
|
97
|
-
display: inline-flex;
|
|
98
|
-
align-items: center;
|
|
99
|
-
justify-content: center;
|
|
100
|
-
`;
|
|
101
|
-
|
|
102
|
-
const SelectSeparator = styled(RadixSelect.Separator)`
|
|
103
|
-
height: 1px;
|
|
104
|
-
width: 100%;
|
|
105
|
-
background-color: rgba(0, 0, 0, 0.15);
|
|
106
|
-
margin: 5px 0;
|
|
107
|
-
`;
|
|
108
|
-
|
|
109
|
-
export function Select(props: SelectProps) {
|
|
110
|
-
const {
|
|
111
|
-
placeholder,
|
|
112
|
-
value,
|
|
113
|
-
onSelect,
|
|
114
|
-
options,
|
|
115
|
-
disabled = false,
|
|
116
|
-
style,
|
|
117
|
-
} = props;
|
|
118
|
-
|
|
119
|
-
const selectedLabel = options
|
|
120
|
-
.flatMap((group) =>
|
|
121
|
-
group.flatMap((optionOrCategory) =>
|
|
122
|
-
'options' in optionOrCategory
|
|
123
|
-
? optionOrCategory.options
|
|
124
|
-
: [optionOrCategory],
|
|
125
|
-
),
|
|
126
|
-
)
|
|
127
|
-
.find((option) => option.value === value)?.label;
|
|
128
|
-
|
|
129
|
-
return (
|
|
130
|
-
<SelectRoot style={{ ...style }}>
|
|
131
|
-
<RadixSelect.Root
|
|
132
|
-
value={value}
|
|
133
|
-
onValueChange={onSelect}
|
|
134
|
-
disabled={disabled}
|
|
135
|
-
>
|
|
136
|
-
<SelectTrigger>
|
|
137
|
-
<RadixSelect.Value>
|
|
138
|
-
<span>{selectedLabel || placeholder} </span>
|
|
139
|
-
</RadixSelect.Value>
|
|
140
|
-
<RadixSelect.Icon asChild>
|
|
141
|
-
<FaChevronDown />
|
|
142
|
-
</RadixSelect.Icon>
|
|
143
|
-
</SelectTrigger>
|
|
144
|
-
<Portal>
|
|
145
|
-
<SelectContent position="popper">
|
|
146
|
-
<RadixSelect.ScrollUpButton>
|
|
147
|
-
<FaChevronUp />
|
|
148
|
-
</RadixSelect.ScrollUpButton>
|
|
149
|
-
<SelectViewport>
|
|
150
|
-
{options.map((group, groupIndex) => (
|
|
151
|
-
<Fragment key={groupIndex}>
|
|
152
|
-
{group.map((optionOrCategory, optionOrCategoryIndex) =>
|
|
153
|
-
'options' in optionOrCategory ? (
|
|
154
|
-
<SelectGroup key={optionOrCategoryIndex}>
|
|
155
|
-
<SelectLabel>{optionOrCategory.label}</SelectLabel>
|
|
156
|
-
{optionOrCategory.options.map((option) => (
|
|
157
|
-
<SelectItem
|
|
158
|
-
key={option.value}
|
|
159
|
-
value={option.value}
|
|
160
|
-
disabled={option.disabled}
|
|
161
|
-
>
|
|
162
|
-
<RadixSelect.ItemText>
|
|
163
|
-
{option.label}
|
|
164
|
-
</RadixSelect.ItemText>
|
|
165
|
-
<SelectItemIndicator>
|
|
166
|
-
<FaCheck />
|
|
167
|
-
</SelectItemIndicator>
|
|
168
|
-
</SelectItem>
|
|
169
|
-
))}
|
|
170
|
-
</SelectGroup>
|
|
171
|
-
) : (
|
|
172
|
-
<SelectItem
|
|
173
|
-
key={optionOrCategory.value}
|
|
174
|
-
value={optionOrCategory.value}
|
|
175
|
-
disabled={optionOrCategory.disabled}
|
|
176
|
-
>
|
|
177
|
-
<RadixSelect.ItemText>
|
|
178
|
-
{optionOrCategory.label}
|
|
179
|
-
</RadixSelect.ItemText>
|
|
180
|
-
<SelectItemIndicator>
|
|
181
|
-
<FaCheck />
|
|
182
|
-
</SelectItemIndicator>
|
|
183
|
-
</SelectItem>
|
|
184
|
-
),
|
|
185
|
-
)}
|
|
186
|
-
{groupIndex < options.length - 1 && <SelectSeparator />}
|
|
187
|
-
</Fragment>
|
|
188
|
-
))}
|
|
189
|
-
</SelectViewport>
|
|
190
|
-
<RadixSelect.ScrollDownButton />
|
|
191
|
-
<RadixSelect.Arrow />
|
|
192
|
-
</SelectContent>
|
|
193
|
-
</Portal>
|
|
194
|
-
</RadixSelect.Root>
|
|
195
|
-
</SelectRoot>
|
|
196
|
-
);
|
|
197
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import styled from '@emotion/styled';
|
|
2
|
-
import { TextareaHTMLAttributes } from 'react';
|
|
3
|
-
|
|
4
|
-
import { useFieldsContext } from './context/FieldsContext';
|
|
5
|
-
import {
|
|
6
|
-
InputContainer,
|
|
7
|
-
GroupStyled,
|
|
8
|
-
LabelStyled,
|
|
9
|
-
InputVariant,
|
|
10
|
-
} from './styles';
|
|
11
|
-
import { SubText, SubTextProps } from './utils';
|
|
12
|
-
|
|
13
|
-
const TextAreaStyled = styled.textarea`
|
|
14
|
-
padding: 0;
|
|
15
|
-
flex: 1 1 0%;
|
|
16
|
-
border: none;
|
|
17
|
-
position: relative;
|
|
18
|
-
outline: none;
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
export interface TextAreaProps
|
|
22
|
-
extends TextareaHTMLAttributes<HTMLTextAreaElement>,
|
|
23
|
-
SubTextProps {
|
|
24
|
-
variant?: InputVariant;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function TextArea(props: TextAreaProps) {
|
|
28
|
-
const { variant: variantProps, help, error, valid, ...otherProps } = props;
|
|
29
|
-
|
|
30
|
-
const { name, variant: contextVariant } = useFieldsContext();
|
|
31
|
-
|
|
32
|
-
const variant = variantProps || contextVariant;
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<InputContainer>
|
|
36
|
-
<GroupStyled hasError={!!error} hasValid={!!valid}>
|
|
37
|
-
<LabelStyled variant={variant}>
|
|
38
|
-
<TextAreaStyled id={name} name={name} {...otherProps} />
|
|
39
|
-
</LabelStyled>
|
|
40
|
-
</GroupStyled>
|
|
41
|
-
|
|
42
|
-
<SubText error={error} help={help} valid={valid} />
|
|
43
|
-
</InputContainer>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import styled from '@emotion/styled';
|
|
2
|
-
import { createContext, ReactNode, useContext, useMemo } from 'react';
|
|
3
|
-
|
|
4
|
-
interface FieldContext {
|
|
5
|
-
name?: string;
|
|
6
|
-
variant: 'default' | 'small';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface FieldProps {
|
|
10
|
-
name: string;
|
|
11
|
-
label: string;
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
variant?: 'default' | 'small';
|
|
14
|
-
required?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const context = createContext<FieldContext | null>(null);
|
|
18
|
-
|
|
19
|
-
const FieldContextRoot = styled.div`
|
|
20
|
-
display: flex;
|
|
21
|
-
flex-flow: row;
|
|
22
|
-
min-width: 0;
|
|
23
|
-
margin: 0;
|
|
24
|
-
padding: 0;
|
|
25
|
-
gap: 5px;
|
|
26
|
-
`;
|
|
27
|
-
|
|
28
|
-
const Label = styled.label<{ variant: FieldProps['variant'] }>`
|
|
29
|
-
position: relative;
|
|
30
|
-
display: inline-flex;
|
|
31
|
-
max-width: 100%;
|
|
32
|
-
line-height: ${(props) => (props.variant === 'small' ? '28px' : '32px')};
|
|
33
|
-
font-size: ${(props) => (props.variant === 'small' ? '1em' : '1.125em')};
|
|
34
|
-
white-space: nowrap;
|
|
35
|
-
text-align: end;
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
const LabelContainer = styled.div`
|
|
39
|
-
flex-grow: 0;
|
|
40
|
-
display: inline-block;
|
|
41
|
-
overflow: hidden;
|
|
42
|
-
text-align: end;
|
|
43
|
-
vertical-align: middle;
|
|
44
|
-
white-space: nowrap;
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
const FieldContextRequired = styled.span`
|
|
48
|
-
color: red;
|
|
49
|
-
`;
|
|
50
|
-
|
|
51
|
-
export function useFieldsContext(): FieldContext {
|
|
52
|
-
const ctx = useContext(context);
|
|
53
|
-
|
|
54
|
-
if (!ctx) {
|
|
55
|
-
return { name: undefined, variant: 'default' };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return ctx;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function Field(props: FieldProps) {
|
|
62
|
-
const { label, name, children, required, variant } = props;
|
|
63
|
-
|
|
64
|
-
const memoized = useMemo(() => {
|
|
65
|
-
return { name, variant: variant || 'default' };
|
|
66
|
-
}, [name, variant]);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<context.Provider value={memoized}>
|
|
70
|
-
<FieldContextRoot>
|
|
71
|
-
<LabelContainer>
|
|
72
|
-
<Label htmlFor={name} variant={memoized.variant}>
|
|
73
|
-
{label} {required && <FieldContextRequired>*</FieldContextRequired>}
|
|
74
|
-
:{' '}
|
|
75
|
-
</Label>
|
|
76
|
-
</LabelContainer>
|
|
77
|
-
|
|
78
|
-
{children}
|
|
79
|
-
</FieldContextRoot>
|
|
80
|
-
</context.Provider>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './FieldsContext';
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { keyframes } from '@emotion/react';
|
|
2
|
-
import styled from '@emotion/styled';
|
|
3
|
-
|
|
4
|
-
const spin = keyframes`
|
|
5
|
-
100% {
|
|
6
|
-
transform: rotate(360deg);
|
|
7
|
-
}
|
|
8
|
-
`;
|
|
9
|
-
|
|
10
|
-
interface FullSpinnerProps {
|
|
11
|
-
width?: number;
|
|
12
|
-
height?: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const Spinner = styled.svg<FullSpinnerProps>`
|
|
16
|
-
height: ${({ height }) => `${height || 40}px`};
|
|
17
|
-
width: ${({ width }) => `${width || 40}px`};
|
|
18
|
-
animation: ${spin} 0.8s linear infinite;
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
export function FullSpinner(props: FullSpinnerProps) {
|
|
22
|
-
// First div is used when using nextjs/dynamic even after component is loaded
|
|
23
|
-
return (
|
|
24
|
-
<div style={{ height: '100%' }}>
|
|
25
|
-
<div
|
|
26
|
-
style={{
|
|
27
|
-
display: 'flex',
|
|
28
|
-
height: '100%',
|
|
29
|
-
width: '100%',
|
|
30
|
-
alignItems: 'center',
|
|
31
|
-
justifyContent: 'center',
|
|
32
|
-
}}
|
|
33
|
-
>
|
|
34
|
-
<Spinner
|
|
35
|
-
{...props}
|
|
36
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
37
|
-
fill="none"
|
|
38
|
-
viewBox="0 0 24 24"
|
|
39
|
-
>
|
|
40
|
-
<circle
|
|
41
|
-
style={{ opacity: 0.25 }}
|
|
42
|
-
cx="12"
|
|
43
|
-
cy="12"
|
|
44
|
-
r="10"
|
|
45
|
-
stroke="currentColor"
|
|
46
|
-
strokeWidth="4"
|
|
47
|
-
/>
|
|
48
|
-
<path
|
|
49
|
-
style={{ opacity: 0.75 }}
|
|
50
|
-
fill="currentColor"
|
|
51
|
-
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
52
|
-
/>
|
|
53
|
-
</Spinner>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './FullSpinner';
|