react-science 0.28.1 → 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/app/hooks/file-loading.d.ts +2 -1
- package/lib-esm/app/hooks/file-loading.d.ts.map +1 -1
- package/lib-esm/app/hooks/file-loading.js.map +1 -1
- package/lib-esm/app/panels/SignalProcessingPanel.d.ts.map +1 -1
- package/lib-esm/app/panels/SignalProcessingPanel.js +3 -3
- package/lib-esm/app/panels/SignalProcessingPanel.js.map +1 -1
- package/lib-esm/components/button/Button.d.ts +8 -14
- package/lib-esm/components/button/Button.d.ts.map +1 -1
- package/lib-esm/components/button/Button.js +7 -31
- 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/header/PanelHeader.d.ts.map +1 -1
- package/lib-esm/components/header/PanelHeader.js +1 -2
- package/lib-esm/components/header/PanelHeader.js.map +1 -1
- package/lib-esm/components/index.d.ts +0 -2
- package/lib-esm/components/index.d.ts.map +1 -1
- package/lib-esm/components/index.js +0 -2
- 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 +5 -4
- package/lib-esm/components/info-panel/InfoPanel.js.map +1 -1
- package/lib-esm/components/modal/ConfirmModal.d.ts.map +1 -1
- package/lib-esm/components/modal/ConfirmModal.js +1 -7
- package/lib-esm/components/modal/ConfirmModal.js.map +1 -1
- package/lib-esm/components/modal/Modal.d.ts.map +1 -1
- package/lib-esm/components/modal/Modal.js +2 -2
- package/lib-esm/components/modal/Modal.js.map +1 -1
- package/lib-esm/components/toolbar/PanelPreferencesToolbar.d.ts.map +1 -1
- package/lib-esm/components/toolbar/PanelPreferencesToolbar.js +1 -2
- package/lib-esm/components/toolbar/PanelPreferencesToolbar.js.map +1 -1
- package/lib-esm/components/toolbar/Toolbar.d.ts.map +1 -1
- package/lib-esm/components/toolbar/Toolbar.js +16 -12
- package/lib-esm/components/toolbar/Toolbar.js.map +1 -1
- package/package.json +25 -23
- package/src/app/hooks/file-loading.ts +4 -2
- package/src/app/panels/SignalProcessingPanel.tsx +3 -6
- package/src/components/button/Button.tsx +29 -59
- 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/header/PanelHeader.tsx +1 -8
- package/src/components/index.ts +0 -2
- package/src/components/info-panel/InfoPanel.tsx +6 -3
- package/src/components/modal/ConfirmModal.tsx +2 -16
- package/src/components/modal/Modal.tsx +10 -2
- package/src/components/toolbar/PanelPreferencesToolbar.tsx +2 -15
- package/src/components/toolbar/Toolbar.tsx +25 -29
- package/lib-esm/components/dropdown-menu/DropdownMenu.d.ts +0 -28
- package/lib-esm/components/dropdown-menu/DropdownMenu.d.ts.map +0 -1
- package/lib-esm/components/dropdown-menu/DropdownMenu.js +0 -41
- package/lib-esm/components/dropdown-menu/DropdownMenu.js.map +0 -1
- package/lib-esm/components/dropdown-menu/MenuItems.d.ts +0 -19
- package/lib-esm/components/dropdown-menu/MenuItems.d.ts.map +0 -1
- package/lib-esm/components/dropdown-menu/MenuItems.js +0 -77
- package/lib-esm/components/dropdown-menu/MenuItems.js.map +0 -1
- package/lib-esm/components/dropdown-menu/index.d.ts +0 -3
- package/lib-esm/components/dropdown-menu/index.d.ts.map +0 -1
- package/lib-esm/components/dropdown-menu/index.js +0 -2
- package/lib-esm/components/dropdown-menu/index.js.map +0 -1
- package/lib-esm/components/dropdown-menu/useContextMenuPlacement.d.ts +0 -18
- package/lib-esm/components/dropdown-menu/useContextMenuPlacement.d.ts.map +0 -1
- package/lib-esm/components/dropdown-menu/useContextMenuPlacement.js +0 -49
- package/lib-esm/components/dropdown-menu/useContextMenuPlacement.js.map +0 -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/modal/ModalCloseButton.d.ts +0 -4
- package/lib-esm/components/modal/ModalCloseButton.d.ts.map +0 -1
- package/lib-esm/components/modal/ModalCloseButton.js +0 -11
- package/lib-esm/components/modal/ModalCloseButton.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/dropdown-menu/DropdownMenu.tsx +0 -160
- package/src/components/dropdown-menu/MenuItems.tsx +0 -146
- package/src/components/dropdown-menu/index.ts +0 -2
- package/src/components/dropdown-menu/useContextMenuPlacement.ts +0 -76
- 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/modal/ModalCloseButton.tsx +0 -21
- package/src/components/spinner/FullSpinner.tsx +0 -57
- package/src/components/spinner/index.ts +0 -1
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import styled from '@emotion/styled';
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
|
|
3
|
-
// @ts-ignore This import fails when compiling to CJS.
|
|
4
|
-
import { Menu } from '@headlessui/react';
|
|
5
|
-
import type { ReactNode } from 'react';
|
|
6
|
-
|
|
7
|
-
export interface MenuOption<T> {
|
|
8
|
-
type: 'option';
|
|
9
|
-
label: ReactNode;
|
|
10
|
-
icon?: ReactNode;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
data?: T;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface MenuDivider {
|
|
16
|
-
type: 'divider';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type MenuOptions<T> = Array<MenuOption<T> | MenuDivider>;
|
|
20
|
-
|
|
21
|
-
const ItemDiv = styled.div<{
|
|
22
|
-
disabled: boolean;
|
|
23
|
-
active: boolean;
|
|
24
|
-
}>`
|
|
25
|
-
display: contents;
|
|
26
|
-
cursor: ${(props) => (props.disabled ? 'default' : 'pointer')};
|
|
27
|
-
font-size: 0.875rem;
|
|
28
|
-
color: ${(props) => (!props.disabled ? 'black' : 'rgb(163, 163, 163)')};
|
|
29
|
-
& > div {
|
|
30
|
-
padding-top: 2px;
|
|
31
|
-
padding-bottom: 2px;
|
|
32
|
-
${(props) => props.active && 'background-color: rgb(243, 244, 246);'}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
${(props) =>
|
|
36
|
-
!props.disabled &&
|
|
37
|
-
`
|
|
38
|
-
&:hover > div {
|
|
39
|
-
background-color: rgb(243, 244, 246);
|
|
40
|
-
}
|
|
41
|
-
`}
|
|
42
|
-
`;
|
|
43
|
-
|
|
44
|
-
const Divider = styled.hr`
|
|
45
|
-
width: 100%;
|
|
46
|
-
color: rgb(229, 229, 229);
|
|
47
|
-
margin-top: 5px;
|
|
48
|
-
margin-bottom: 5px;
|
|
49
|
-
grid-column: 1 / -1;
|
|
50
|
-
`;
|
|
51
|
-
|
|
52
|
-
const ItemsDiv = styled.div<{
|
|
53
|
-
hasOneIconOrMore: boolean;
|
|
54
|
-
}>`
|
|
55
|
-
display: grid;
|
|
56
|
-
grid-template-columns: [icon-start] ${(props) =>
|
|
57
|
-
props.hasOneIconOrMore ? '40px' : '0px'} [label-start] auto;
|
|
58
|
-
width: fit-content;
|
|
59
|
-
align-items: center;
|
|
60
|
-
border-radius: 6px;
|
|
61
|
-
background-color: white;
|
|
62
|
-
box-shadow:
|
|
63
|
-
rgba(0, 0, 0, 0.3) 0px 19px 38px,
|
|
64
|
-
rgba(0, 0, 0, 0.22) 0px 5px 12px;
|
|
65
|
-
padding-top: 5px;
|
|
66
|
-
padding-bottom: 5px;
|
|
67
|
-
--cell-padding: 16px;
|
|
68
|
-
`;
|
|
69
|
-
|
|
70
|
-
const LabelDiv = styled.div`
|
|
71
|
-
grid-column-start: label-start;
|
|
72
|
-
padding-right: var(--cell-padding);
|
|
73
|
-
padding-left: var(--cell-padding);
|
|
74
|
-
`;
|
|
75
|
-
|
|
76
|
-
const IconDiv = styled.div`
|
|
77
|
-
grid-column-start: icon-start;
|
|
78
|
-
width: 100%;
|
|
79
|
-
height: 100%;
|
|
80
|
-
padding-left: var(--cell-padding);
|
|
81
|
-
display: flex;
|
|
82
|
-
justify-content: center;
|
|
83
|
-
align-items: center;
|
|
84
|
-
`;
|
|
85
|
-
|
|
86
|
-
export interface MenuItemsProps<T> {
|
|
87
|
-
options: MenuOptions<T>;
|
|
88
|
-
onSelect: (selected: MenuOption<T>) => void;
|
|
89
|
-
itemsStatic?: boolean;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function MenuItems<T>(props: MenuItemsProps<T>) {
|
|
93
|
-
const { options, onSelect, itemsStatic } = props;
|
|
94
|
-
const hasOneOrMoreIcon = options.some(
|
|
95
|
-
(option) => option.type === 'option' && option.icon,
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<Menu.Items
|
|
100
|
-
as={ItemsDiv}
|
|
101
|
-
static={itemsStatic}
|
|
102
|
-
hasOneIconOrMore={hasOneOrMoreIcon}
|
|
103
|
-
>
|
|
104
|
-
{options.map((option, index) => (
|
|
105
|
-
<Item
|
|
106
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
107
|
-
key={index}
|
|
108
|
-
onSelect={onSelect}
|
|
109
|
-
option={option}
|
|
110
|
-
/>
|
|
111
|
-
))}
|
|
112
|
-
</Menu.Items>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
interface ItemProps<T> {
|
|
117
|
-
option: MenuOptions<T>[number];
|
|
118
|
-
onSelect: MenuItemsProps<T>['onSelect'];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function Item<T>(props: ItemProps<T>) {
|
|
122
|
-
const { option, onSelect } = props;
|
|
123
|
-
const isDivider = option.type === 'divider';
|
|
124
|
-
|
|
125
|
-
if (isDivider) {
|
|
126
|
-
return <Divider />;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return (
|
|
130
|
-
<Menu.Item disabled={option.disabled}>
|
|
131
|
-
{({ active }) => (
|
|
132
|
-
<ItemDiv
|
|
133
|
-
onClick={(event) => {
|
|
134
|
-
event.stopPropagation();
|
|
135
|
-
onSelect(option);
|
|
136
|
-
}}
|
|
137
|
-
active={active}
|
|
138
|
-
disabled={option.disabled || false}
|
|
139
|
-
>
|
|
140
|
-
<IconDiv>{option.icon}</IconDiv>
|
|
141
|
-
<LabelDiv>{option.label}</LabelDiv>
|
|
142
|
-
</ItemDiv>
|
|
143
|
-
)}
|
|
144
|
-
</Menu.Item>
|
|
145
|
-
);
|
|
146
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { Placement } from '@popperjs/core';
|
|
2
|
-
import React, { useCallback, useMemo, useState } from 'react';
|
|
3
|
-
import { usePopper } from 'react-popper';
|
|
4
|
-
|
|
5
|
-
interface PositionState {
|
|
6
|
-
clientX: number;
|
|
7
|
-
clientY: number;
|
|
8
|
-
pageX: number;
|
|
9
|
-
pageY: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function useContextMenuPlacement(placement: Placement) {
|
|
13
|
-
const [positionState, setPositionState] = useState<PositionState | null>(
|
|
14
|
-
null,
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
const handleContextMenu = useCallback(
|
|
18
|
-
(event: React.MouseEvent<HTMLDivElement>) => {
|
|
19
|
-
const { clientX, clientY, pageX, pageY } = event;
|
|
20
|
-
event.preventDefault();
|
|
21
|
-
|
|
22
|
-
setPositionState({
|
|
23
|
-
clientX,
|
|
24
|
-
clientY,
|
|
25
|
-
pageX,
|
|
26
|
-
pageY,
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
[],
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const boundingClientRect = useMemo(() => {
|
|
33
|
-
return {
|
|
34
|
-
top: positionState?.clientY || 0,
|
|
35
|
-
left: positionState?.clientX || 0,
|
|
36
|
-
x: positionState?.pageX || 0,
|
|
37
|
-
y: positionState?.pageY || 0,
|
|
38
|
-
|
|
39
|
-
bottom: 0,
|
|
40
|
-
right: 0,
|
|
41
|
-
height: 0,
|
|
42
|
-
width: 0,
|
|
43
|
-
toJSON: () => '',
|
|
44
|
-
};
|
|
45
|
-
}, [positionState]);
|
|
46
|
-
|
|
47
|
-
const virtualElement = useMemo(() => {
|
|
48
|
-
return {
|
|
49
|
-
getBoundingClientRect: () => boundingClientRect,
|
|
50
|
-
};
|
|
51
|
-
}, [boundingClientRect]);
|
|
52
|
-
|
|
53
|
-
const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(
|
|
54
|
-
null,
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const { styles, attributes, state } = usePopper(
|
|
58
|
-
virtualElement,
|
|
59
|
-
popperElement,
|
|
60
|
-
{
|
|
61
|
-
placement,
|
|
62
|
-
},
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
setPopperElement,
|
|
67
|
-
styles,
|
|
68
|
-
attributes,
|
|
69
|
-
popperState: state,
|
|
70
|
-
isPopperElementOpen: positionState !== null,
|
|
71
|
-
handleContextMenu,
|
|
72
|
-
closePopperElement: () => {
|
|
73
|
-
setPositionState(null);
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
@@ -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
|
-
}
|