@takaro/lib-components 0.0.1 → 0.0.4
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/package.json +4 -5
- package/src/components/actions/Button/index.tsx +68 -70
- package/src/components/actions/Button/style.ts +1 -1
- package/src/components/actions/ContextMenu/Group.tsx +1 -1
- package/src/components/actions/ContextMenu/MenuItem.tsx +4 -1
- package/src/components/actions/ContextMenu/index.tsx +11 -12
- package/src/components/actions/Dropdown/DropdownMenu.tsx +5 -2
- package/src/components/actions/Dropdown/DropdownTrigger.tsx +55 -57
- package/src/components/actions/Dropdown/useDropdown.tsx +1 -1
- package/src/components/actions/IconButton/index.tsx +11 -10
- package/src/components/actions/IconButton/style.ts +5 -2
- package/src/components/actions/ToggleButton/ToggleButton.tsx +26 -28
- package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +3 -8
- package/src/components/actions/ToggleButton/style.ts +5 -7
- package/src/components/charts/AreaChart/index.tsx +7 -8
- package/src/components/charts/BarChart/index.tsx +4 -4
- package/src/components/charts/GeoMercator/index.tsx +1 -1
- package/src/components/charts/Heatmap/index.tsx +3 -4
- package/src/components/charts/LineChart/index.tsx +3 -3
- package/src/components/charts/PieChart/index.tsx +1 -1
- package/src/components/charts/RadarChart/index.tsx +1 -1
- package/src/components/charts/RadialBarChart/index.tsx +1 -1
- package/src/components/charts/index.tsx +3 -0
- package/src/components/data/Avatar/index.tsx +7 -3
- package/src/components/data/Avatar/style.ts +2 -2
- package/src/components/data/Chip/index.tsx +39 -41
- package/src/components/data/Chip/style.ts +3 -2
- package/src/components/data/Console/Console.tsx +14 -12
- package/src/components/data/CopyId/index.tsx +3 -2
- package/src/components/data/Drawer/Drawer.stories.tsx +3 -5
- package/src/components/data/Drawer/DrawerContent.tsx +1 -1
- package/src/components/data/Drawer/DrawerHeading.tsx +30 -29
- package/src/components/data/Drawer/useDrawer.tsx +1 -1
- package/src/components/data/InfiniteScroll/index.tsx +37 -36
- package/src/components/data/Table/Table.stories.tsx +6 -2
- package/src/components/data/Table/index.tsx +63 -44
- package/src/components/data/Table/style.ts +3 -2
- package/src/components/data/Table/subcomponents/ColumnHeader/ColumnSettings.tsx +22 -19
- package/src/components/data/Table/subcomponents/ColumnHeader/index.tsx +3 -3
- package/src/components/data/Table/subcomponents/ColumnHeader/style.ts +2 -1
- package/src/components/data/Table/subcomponents/Filter/field.tsx +2 -3
- package/src/components/data/Table/subcomponents/Filter/index.tsx +6 -10
- package/src/components/data/Table/subcomponents/Pagination/{index.tsx → PagePicker.tsx} +7 -7
- package/src/components/data/Table/subcomponents/Pagination/PageSizeSelect.tsx +37 -0
- package/src/components/data/Table/subcomponents/Pagination/style.ts +1 -1
- package/src/components/dialogs/Dialog/Dialog.stories.tsx +1 -2
- package/src/components/dialogs/Dialog/DialogBody.tsx +18 -17
- package/src/components/dialogs/Dialog/DialogContent.tsx +30 -28
- package/src/components/dialogs/Dialog/DialogHeading.tsx +1 -1
- package/src/components/dialogs/Dialog/useDialog.tsx +1 -1
- package/src/components/feedback/Alert/index.tsx +74 -73
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx +1 -1
- package/src/components/feedback/NotificationBanner/index.tsx +1 -1
- package/src/components/feedback/Popover/PopoverContent.tsx +4 -1
- package/src/components/feedback/Popover/PopoverTrigger.tsx +33 -31
- package/src/components/feedback/Popover/usePopover.tsx +1 -1
- package/src/components/feedback/ProgressBar/index.tsx +1 -1
- package/src/components/feedback/QuestionTooltip/index.tsx +1 -2
- package/src/components/feedback/Tooltip/TooltipContent.tsx +4 -1
- package/src/components/feedback/Tooltip/TooltipTrigger.tsx +3 -3
- package/src/components/feedback/Tooltip/useTooltip.tsx +1 -1
- package/src/components/feedback/snacks/CookieConsent/index.tsx +5 -2
- package/src/components/feedback/snacks/Default/index.tsx +51 -50
- package/src/components/feedback/snacks/Drawer/index.tsx +22 -21
- package/src/components/feedback/snacks/NetworkDetector/index.tsx +35 -31
- package/src/components/inputs/CheckBox/Controlled.tsx +2 -3
- package/src/components/inputs/CheckBox/Generic.tsx +18 -72
- package/src/components/inputs/CheckBox/style.ts +40 -97
- package/src/components/inputs/CodeField/CodeField.stories.tsx +4 -5
- package/src/components/inputs/CodeField/index.tsx +1 -0
- package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +2 -3
- package/src/components/inputs/Date/DatePicker/Generic.tsx +20 -10
- package/src/components/inputs/Date/DateRangePicker/Context.tsx +12 -1
- package/src/components/inputs/Date/DateRangePicker/Controlled.tsx +74 -0
- package/src/components/inputs/Date/DateRangePicker/DateRangePicker.stories.tsx +11 -6
- package/src/components/inputs/Date/DateRangePicker/DateSelector/Absolute.tsx +3 -3
- package/src/components/inputs/Date/DateRangePicker/DateSelector/Relative.tsx +1 -1
- package/src/components/inputs/Date/DateRangePicker/DateSelector/index.tsx +1 -1
- package/src/components/inputs/Date/DateRangePicker/{index.tsx → Generic.tsx} +43 -11
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +1 -1
- package/src/components/inputs/Date/DateRangePicker/style.ts +19 -5
- package/src/components/inputs/Date/subcomponents/Calendar/index.tsx +1 -1
- package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +1 -1
- package/src/components/inputs/DurationField/Generic.tsx +149 -152
- package/src/components/inputs/FileField/FileField.stories.tsx +6 -6
- package/src/components/inputs/FileField/Generic.tsx +101 -99
- package/src/components/inputs/InputProps.ts +0 -2
- package/src/components/inputs/RadioGroup/Controlled.tsx +1 -2
- package/src/components/inputs/RadioGroup/RadioGroup.stories.tsx +6 -4
- package/src/components/inputs/RadioGroup/RadioItem.tsx +54 -53
- package/src/components/inputs/Slider/Generic.tsx +1 -1
- package/src/components/inputs/Slider/Slider.stories.tsx +1 -1
- package/src/components/inputs/Slider/handle.tsx +1 -0
- package/src/components/inputs/Switch/Controlled.tsx +1 -2
- package/src/components/inputs/Switch/Generic.tsx +18 -45
- package/src/components/inputs/Switch/Switch.stories.tsx +2 -4
- package/src/components/inputs/Switch/style.ts +44 -38
- package/src/components/inputs/TagField/Generic.tsx +109 -109
- package/src/components/inputs/TextAreaField/Generic.tsx +41 -39
- package/src/components/inputs/TextAreaField/TextAreaField.stories.tsx +2 -3
- package/src/components/inputs/TextField/Generic.tsx +81 -79
- package/src/components/inputs/TextField/TextField.stories.tsx +3 -4
- package/src/components/inputs/index.ts +3 -2
- package/src/components/inputs/layout/Description.tsx +1 -2
- package/src/components/inputs/layout/InputWrapper.ts +2 -2
- package/src/components/inputs/selects/SelectField/Controlled.tsx +1 -2
- package/src/components/inputs/selects/SelectField/Generic/FilterInput.tsx +4 -1
- package/src/components/inputs/selects/SelectField/SelectField.stories.tsx +9 -10
- package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +200 -197
- package/src/components/inputs/selects/SelectQueryField/SelectQueryField.stories.tsx +1 -1
- package/src/components/inputs/selects/SubComponents/Option.tsx +3 -3
- package/src/components/inputs/selects/SubComponents/OptionGroup.tsx +1 -1
- package/src/components/inputs/selects/SubComponents/style.ts +18 -4
- package/src/components/inputs/selects/index.tsx +5 -2
- package/src/components/inputs/selects/sharedStyle.ts +1 -0
- package/src/components/navigation/HorizontalNav/index.tsx +5 -32
- package/src/components/navigation/HorizontalNav/style.ts +11 -26
- package/src/components/navigation/IconNav/index.tsx +1 -1
- package/src/components/navigation/Steppers/SlimStepper/index.tsx +1 -1
- package/src/components/navigation/Steppers/SlimStepper/style.ts +1 -2
- package/src/components/navigation/Steppers/Stepper/index.tsx +1 -1
- package/src/components/navigation/Steppers/context.tsx +2 -2
- package/src/components/navigation/Tabs/Content.tsx +4 -1
- package/src/components/navigation/Tabs/Trigger.tsx +24 -23
- package/src/components/navigation/index.ts +1 -1
- package/src/components/other/ActionMenu/ActionMenu.stories.tsx +1 -2
- package/src/components/other/ActionMenu/index.tsx +30 -29
- package/src/components/other/Collapsible/CollapsibleTrigger.tsx +8 -4
- package/src/components/other/Company/index.tsx +25 -26
- package/src/components/other/Empty/Empty.stories.tsx +1 -1
- package/src/components/other/Empty/index.tsx +1 -3
- package/src/components/other/PermissionsGuard/index.tsx +2 -2
- package/src/components/visual/Card/index.tsx +4 -1
- package/src/errors/base.ts +4 -1
- package/src/errors/errors.ts +19 -2
- package/src/helpers/getSnackbarProvider.tsx +3 -3
- package/src/helpers/regexprs.ts +1 -0
- package/src/hooks/useFocus.tsx +3 -1
- package/src/hooks/useOnScreen.ts +1 -1
- package/src/hooks/useTableActions.ts +10 -5
- package/src/styled/GlobalStyle.ts +2 -1
- package/src/styled/zIndex.ts +1 -1
- package/src/test/testUtils.tsx +3 -0
- package/src/components/data/Table/subcomponents/index.ts +0 -4
|
@@ -4,7 +4,7 @@ import { ParentSize } from '@visx/responsive';
|
|
|
4
4
|
import { GridColumns } from '@visx/grid';
|
|
5
5
|
import { Group } from '@visx/group';
|
|
6
6
|
import { AreaClosed, Bar } from '@visx/shape';
|
|
7
|
-
import { max, extent } from '@visx/vendor/d3-array';
|
|
7
|
+
import { max, extent, bisector } from '@visx/vendor/d3-array';
|
|
8
8
|
import { scaleTime, scaleLinear } from '@visx/scale';
|
|
9
9
|
import { AxisBottom, AxisLeft } from '@visx/axis';
|
|
10
10
|
import { curveMonotoneX } from '@visx/curve';
|
|
@@ -14,7 +14,6 @@ import { timeFormat } from '@visx/vendor/d3-time-format';
|
|
|
14
14
|
import { PatternLines } from '@visx/pattern';
|
|
15
15
|
import { Brush } from '@visx/brush';
|
|
16
16
|
import { Bounds } from '@visx/brush/lib/types';
|
|
17
|
-
import { bisector } from '@visx/vendor/d3-array';
|
|
18
17
|
|
|
19
18
|
import { useTheme } from '../../../hooks';
|
|
20
19
|
import { useGradients } from '../useGradients';
|
|
@@ -143,7 +142,7 @@ const Chart = <T,>({
|
|
|
143
142
|
range: [0, xMax],
|
|
144
143
|
domain: extent(filteredData, xAccessor) as [Date, Date],
|
|
145
144
|
}),
|
|
146
|
-
[xMax, filteredData]
|
|
145
|
+
[xMax, filteredData],
|
|
147
146
|
);
|
|
148
147
|
|
|
149
148
|
const yScale = useMemo(
|
|
@@ -153,7 +152,7 @@ const Chart = <T,>({
|
|
|
153
152
|
domain: [0, max(filteredData, yAccessor) || 0],
|
|
154
153
|
nice: true,
|
|
155
154
|
}),
|
|
156
|
-
[yMax, filteredData]
|
|
155
|
+
[yMax, filteredData],
|
|
157
156
|
);
|
|
158
157
|
|
|
159
158
|
const xBrushScale = useMemo(
|
|
@@ -162,7 +161,7 @@ const Chart = <T,>({
|
|
|
162
161
|
range: [0, xBrushMax],
|
|
163
162
|
domain: extent(data, xAccessor) as [Date, Date],
|
|
164
163
|
}),
|
|
165
|
-
[xBrushMax]
|
|
164
|
+
[xBrushMax],
|
|
166
165
|
);
|
|
167
166
|
|
|
168
167
|
const yBrushScale = useMemo(
|
|
@@ -172,7 +171,7 @@ const Chart = <T,>({
|
|
|
172
171
|
domain: [0, max(data, yAccessor) || 0],
|
|
173
172
|
nice: true,
|
|
174
173
|
}),
|
|
175
|
-
[yBrushMax]
|
|
174
|
+
[yBrushMax],
|
|
176
175
|
);
|
|
177
176
|
|
|
178
177
|
const initialBrushPosition = useMemo(
|
|
@@ -180,7 +179,7 @@ const Chart = <T,>({
|
|
|
180
179
|
start: { x: xBrushScale(xAccessor(data[0])) },
|
|
181
180
|
end: { x: xBrushScale(xAccessor(data[data.length - 1])) },
|
|
182
181
|
}),
|
|
183
|
-
[xBrushScale]
|
|
182
|
+
[xBrushScale],
|
|
184
183
|
);
|
|
185
184
|
|
|
186
185
|
const onBrushChange = (domain: Bounds | null) => {
|
|
@@ -213,7 +212,7 @@ const Chart = <T,>({
|
|
|
213
212
|
tooltipTop: tooltipY,
|
|
214
213
|
});
|
|
215
214
|
},
|
|
216
|
-
[yScale, xScale, filteredData, yAccessor, xAccessor, width, height]
|
|
215
|
+
[yScale, xScale, filteredData, yAccessor, xAccessor, width, height],
|
|
217
216
|
);
|
|
218
217
|
|
|
219
218
|
if (width < 10) return null;
|
|
@@ -127,7 +127,7 @@ const Chart = <T,>({
|
|
|
127
127
|
domain: filteredData.map(xAccessor),
|
|
128
128
|
padding: 0.4,
|
|
129
129
|
}),
|
|
130
|
-
[xMax, filteredData]
|
|
130
|
+
[xMax, filteredData],
|
|
131
131
|
);
|
|
132
132
|
const yScale = useMemo(
|
|
133
133
|
() =>
|
|
@@ -136,7 +136,7 @@ const Chart = <T,>({
|
|
|
136
136
|
round: true,
|
|
137
137
|
domain: [0, max(filteredData, yAccessor) ?? 0],
|
|
138
138
|
}),
|
|
139
|
-
[yMax, filteredData]
|
|
139
|
+
[yMax, filteredData],
|
|
140
140
|
);
|
|
141
141
|
|
|
142
142
|
const xBrushScale = useMemo(
|
|
@@ -146,7 +146,7 @@ const Chart = <T,>({
|
|
|
146
146
|
domain: data.map(xAccessor),
|
|
147
147
|
round: true,
|
|
148
148
|
}),
|
|
149
|
-
[xBrushMax]
|
|
149
|
+
[xBrushMax],
|
|
150
150
|
);
|
|
151
151
|
|
|
152
152
|
const yBrushScale = useMemo(
|
|
@@ -156,7 +156,7 @@ const Chart = <T,>({
|
|
|
156
156
|
domain: [0, Math.max(...data.map(yAccessor))],
|
|
157
157
|
nice: true,
|
|
158
158
|
}),
|
|
159
|
-
[yBrushMax]
|
|
159
|
+
[yBrushMax],
|
|
160
160
|
);
|
|
161
161
|
|
|
162
162
|
const onBrushChange = (domain: Bounds | null) => {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ParentSize } from '@visx/responsive';
|
|
2
|
-
import { scaleLinear } from '@visx/scale';
|
|
3
2
|
import { Group } from '@visx/group';
|
|
4
3
|
import { AxisTop, AxisLeft } from '@visx/axis';
|
|
5
4
|
import { HeatmapRect } from '@visx/heatmap';
|
|
6
5
|
import { useTooltipInPortal } from '@visx/tooltip';
|
|
7
|
-
import { scaleBand } from '@visx/scale';
|
|
6
|
+
import { scaleLinear, scaleBand } from '@visx/scale';
|
|
8
7
|
|
|
9
8
|
import { InnerChartProps, Margin } from '../util';
|
|
10
9
|
import { useTheme } from '../../../hooks';
|
|
@@ -169,7 +168,7 @@ const Chart = <T,>({
|
|
|
169
168
|
fillOpacity={bin.opacity}
|
|
170
169
|
/>
|
|
171
170
|
);
|
|
172
|
-
})
|
|
171
|
+
}),
|
|
173
172
|
)
|
|
174
173
|
}
|
|
175
174
|
</HeatmapRect>
|
|
@@ -200,7 +199,7 @@ function transformData<T>(
|
|
|
200
199
|
xAccessor: (d: T) => number,
|
|
201
200
|
yAccessor: (d: T) => number,
|
|
202
201
|
zAccessor: (d: T) => number,
|
|
203
|
-
tooltipAccessor: (d: T) => string
|
|
202
|
+
tooltipAccessor: (d: T) => string,
|
|
204
203
|
): OuterBin[] {
|
|
205
204
|
const map = new Map<number, Map<number, { count: number; tooltip: string }>>();
|
|
206
205
|
|
|
@@ -103,7 +103,7 @@ const Chart = <T,>({
|
|
|
103
103
|
range: [margin.left, innerWidth],
|
|
104
104
|
domain: extent(data, xAccessor) as [Date, Date],
|
|
105
105
|
}),
|
|
106
|
-
[innerWidth]
|
|
106
|
+
[innerWidth],
|
|
107
107
|
);
|
|
108
108
|
|
|
109
109
|
const yScale = useMemo(
|
|
@@ -112,7 +112,7 @@ const Chart = <T,>({
|
|
|
112
112
|
range: [innerHeight, margin.bottom],
|
|
113
113
|
domain: [0, max(data, yAccessor) as number],
|
|
114
114
|
}),
|
|
115
|
-
[innerHeight]
|
|
115
|
+
[innerHeight],
|
|
116
116
|
);
|
|
117
117
|
|
|
118
118
|
const handleTooltip = useCallback(
|
|
@@ -134,7 +134,7 @@ const Chart = <T,>({
|
|
|
134
134
|
tooltipTop: tooltipY,
|
|
135
135
|
});
|
|
136
136
|
},
|
|
137
|
-
[yScale, xScale, data, yAccessor, xAccessor, width, height]
|
|
137
|
+
[yScale, xScale, data, yAccessor, xAccessor, width, height],
|
|
138
138
|
);
|
|
139
139
|
|
|
140
140
|
return width === 10 ? null : (
|
|
@@ -16,5 +16,8 @@ export type { RadarChartProps } from './RadarChart';
|
|
|
16
16
|
export { RadialLineChart } from './RadialLineChart';
|
|
17
17
|
export type { RadialLineChartProps } from './RadialLineChart';
|
|
18
18
|
|
|
19
|
+
export { LineChart } from './LineChart';
|
|
20
|
+
export type { LineChartProps } from './LineChart';
|
|
21
|
+
|
|
19
22
|
export { RadialBarChart } from './RadialBarChart';
|
|
20
23
|
export type { RadialBarChartProps } from './RadialBarChart';
|
|
@@ -29,7 +29,9 @@ const AvatarImage = forwardRef<HTMLImageElement, AvatarImageProps>(
|
|
|
29
29
|
const context = useAvatarContext();
|
|
30
30
|
const imageLoadingStatus = useImageLoadingStatus(src);
|
|
31
31
|
const handleLoadingStatusChange = useCallbackRef((status: ImageLoadingStatus) => {
|
|
32
|
-
|
|
32
|
+
if (onLoadingStatusChange) {
|
|
33
|
+
onLoadingStatusChange(status);
|
|
34
|
+
}
|
|
33
35
|
context.onImageLoadingStatusChange(status);
|
|
34
36
|
});
|
|
35
37
|
|
|
@@ -44,8 +46,9 @@ const AvatarImage = forwardRef<HTMLImageElement, AvatarImageProps>(
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
return imageLoadingStatus === 'loaded' ? <img {...imageProps} ref={ref} src={src} /> : null;
|
|
47
|
-
}
|
|
49
|
+
},
|
|
48
50
|
);
|
|
51
|
+
AvatarImage.displayName = 'AvatarImage';
|
|
49
52
|
|
|
50
53
|
// * -------------------------------------------------------------------------------------------------
|
|
51
54
|
// * FallBack
|
|
@@ -68,8 +71,9 @@ export const AvatarFallBack = forwardRef<HTMLSpanElement, PropsWithChildren<Avat
|
|
|
68
71
|
}, [delayMs]);
|
|
69
72
|
|
|
70
73
|
return canRender && imageLoadingStatus !== 'loaded' ? <span ref={ref}>{children}</span> : null;
|
|
71
|
-
}
|
|
74
|
+
},
|
|
72
75
|
);
|
|
76
|
+
AvatarFallBack.displayName = 'AvatarFallBack';
|
|
73
77
|
|
|
74
78
|
// * -------------------------------------------------------------------------------------------------
|
|
75
79
|
// * FallBack
|
|
@@ -21,56 +21,54 @@ export interface ChipProps {
|
|
|
21
21
|
showIcon?: ShowIcon;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const Chip = forwardRef<HTMLDivElement, ChipProps>(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
41
|
-
if (isLoading) {
|
|
42
|
-
return (
|
|
43
|
-
<Container
|
|
44
|
-
ref={ref}
|
|
45
|
-
clickable={!readOnly && !disabled && onClick !== undefined}
|
|
46
|
-
color={color}
|
|
47
|
-
disabled={disabled}
|
|
48
|
-
outline={false}
|
|
49
|
-
onClick={onClick ? onClick : undefined}
|
|
50
|
-
className="placeholder"
|
|
51
|
-
showIcon={showIcon}
|
|
52
|
-
>
|
|
53
|
-
{dot && <Dot color={color} outline={variant !== 'default'} />}
|
|
54
|
-
<span style={{ minWidth: '70px', minHeight: '15px' }}></span>
|
|
55
|
-
</Container>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
24
|
+
export const Chip = forwardRef<HTMLDivElement, ChipProps>(function Chip(
|
|
25
|
+
{
|
|
26
|
+
color,
|
|
27
|
+
variant = 'default',
|
|
28
|
+
label,
|
|
29
|
+
disabled = false,
|
|
30
|
+
readOnly = false,
|
|
31
|
+
onClick = undefined,
|
|
32
|
+
onDelete = undefined,
|
|
33
|
+
isLoading = false,
|
|
34
|
+
dot = false,
|
|
35
|
+
icon,
|
|
36
|
+
showIcon = 'always',
|
|
37
|
+
},
|
|
38
|
+
ref,
|
|
39
|
+
) {
|
|
40
|
+
if (isLoading) {
|
|
59
41
|
return (
|
|
60
42
|
<Container
|
|
61
43
|
ref={ref}
|
|
62
|
-
clickable={onClick !== undefined}
|
|
44
|
+
clickable={!readOnly && !disabled && onClick !== undefined}
|
|
63
45
|
color={color}
|
|
64
46
|
disabled={disabled}
|
|
47
|
+
outline={false}
|
|
65
48
|
onClick={onClick ? onClick : undefined}
|
|
66
|
-
|
|
49
|
+
className="placeholder"
|
|
67
50
|
showIcon={showIcon}
|
|
68
51
|
>
|
|
69
52
|
{dot && <Dot color={color} outline={variant !== 'default'} />}
|
|
70
|
-
<span
|
|
71
|
-
{!onDelete && icon && cloneElement(icon, { size: 12, className: 'icon' })}
|
|
72
|
-
{onDelete && !readOnly && !disabled && <Icon onClick={onDelete} size={12} />}
|
|
53
|
+
<span style={{ minWidth: '70px', minHeight: '15px' }}></span>
|
|
73
54
|
</Container>
|
|
74
55
|
);
|
|
75
56
|
}
|
|
76
|
-
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Container
|
|
60
|
+
ref={ref}
|
|
61
|
+
clickable={onClick !== undefined}
|
|
62
|
+
color={color}
|
|
63
|
+
disabled={disabled}
|
|
64
|
+
onClick={onClick ? onClick : undefined}
|
|
65
|
+
outline={variant !== 'default'}
|
|
66
|
+
showIcon={showIcon}
|
|
67
|
+
>
|
|
68
|
+
{dot && <Dot color={color} outline={variant !== 'default'} />}
|
|
69
|
+
<span>{label}</span>
|
|
70
|
+
{!onDelete && icon && cloneElement(icon, { size: 12, className: 'icon' })}
|
|
71
|
+
{onDelete && !readOnly && !disabled && <Icon onClick={onDelete} size={12} />}
|
|
72
|
+
</Container>
|
|
73
|
+
);
|
|
74
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { styled } from '../../../styled';
|
|
2
2
|
import { ChipColor, ShowIcon } from '.';
|
|
3
|
+
import { shade } from 'polished';
|
|
3
4
|
|
|
4
5
|
export const Container = styled.div<{
|
|
5
6
|
disabled: boolean;
|
|
@@ -35,7 +36,7 @@ export const Container = styled.div<{
|
|
|
35
36
|
if (!outline) {
|
|
36
37
|
return 'border: 0.1rem solid transparent;';
|
|
37
38
|
}
|
|
38
|
-
return `border: 0.1rem solid ${theme.colors[color]};`;
|
|
39
|
+
return `border: 0.1rem solid ${shade(0.5, theme.colors[color])};`;
|
|
39
40
|
}}
|
|
40
41
|
|
|
41
42
|
&:hover {
|
|
@@ -69,7 +70,7 @@ export const Container = styled.div<{
|
|
|
69
70
|
|
|
70
71
|
${({ theme, color, outline }): string => {
|
|
71
72
|
if (outline) {
|
|
72
|
-
return
|
|
73
|
+
return `background-color: ${shade('0.8', theme.colors[color])};`;
|
|
73
74
|
}
|
|
74
75
|
return `background-color: ${theme.colors[color]};`;
|
|
75
76
|
}}
|
|
@@ -67,17 +67,19 @@ export const Console: FC<ConsoleProps> = ({ listenerFactory, onExecuteCommand, s
|
|
|
67
67
|
// this is required so that react-window knows the padding of the element
|
|
68
68
|
// again, react-window does not have types, cba to type this.
|
|
69
69
|
//
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
const InnerElementType = forwardRef<HTMLDivElement, any>(function InnerConsole({ style, ...rest }, ref) {
|
|
71
|
+
return (
|
|
72
|
+
<div
|
|
73
|
+
ref={ref}
|
|
74
|
+
style={{
|
|
75
|
+
...style,
|
|
76
|
+
height: `${style.height + LIST_PADDING_SIZE * 2}px`,
|
|
77
|
+
paddingTop: `${GUTTER_SIZE}px`,
|
|
78
|
+
}}
|
|
79
|
+
{...rest}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
});
|
|
81
83
|
|
|
82
84
|
return (
|
|
83
85
|
<Wrapper>
|
|
@@ -99,7 +101,7 @@ export const Console: FC<ConsoleProps> = ({ listenerFactory, onExecuteCommand, s
|
|
|
99
101
|
width={width}
|
|
100
102
|
height={height}
|
|
101
103
|
onScroll={toggleLiveModeOnConsoleScroll}
|
|
102
|
-
innerElementType={
|
|
104
|
+
innerElementType={InnerElementType}
|
|
103
105
|
ref={consoleMessagesBoxRef}
|
|
104
106
|
>
|
|
105
107
|
{({ data, index, style }) => {
|
|
@@ -5,9 +5,10 @@ import { AiFillCopy as CopyIcon, AiOutlineCheck as CheckmarkIcon } from 'react-i
|
|
|
5
5
|
export interface CopyIdProps {
|
|
6
6
|
id?: string;
|
|
7
7
|
placeholder?: string;
|
|
8
|
+
copyText?: string;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
export const CopyId: FC<CopyIdProps> = ({ id, placeholder }) => {
|
|
11
|
+
export const CopyId: FC<CopyIdProps> = ({ id, placeholder, copyText = 'copied' }) => {
|
|
11
12
|
const [copied, setCopied] = useState<boolean>(false);
|
|
12
13
|
|
|
13
14
|
function handleCopy(text: string) {
|
|
@@ -31,7 +32,7 @@ export const CopyId: FC<CopyIdProps> = ({ id, placeholder }) => {
|
|
|
31
32
|
icon={copied ? <CheckmarkIcon /> : <CopyIcon />}
|
|
32
33
|
onClick={() => handleCopy(id)}
|
|
33
34
|
variant="outline"
|
|
34
|
-
label={copied ?
|
|
35
|
+
label={copied ? copyText : placeholder ? placeholder : id}
|
|
35
36
|
color="backgroundAccent"
|
|
36
37
|
/>
|
|
37
38
|
);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import { useState } from 'react';
|
|
1
|
+
import React, { useState, useMemo } from 'react';
|
|
3
2
|
import { Meta, StoryFn } from '@storybook/react';
|
|
4
|
-
|
|
5
3
|
import { Button, TextField, CollapseList, Chip, RadioGroup, Switch, Drawer, DrawerSkeleton } from '../../../components';
|
|
6
4
|
import { styled } from '../../../styled';
|
|
7
5
|
import { SubmitHandler, useForm } from 'react-hook-form';
|
|
@@ -41,11 +39,11 @@ export const Default: StoryFn = () => {
|
|
|
41
39
|
const validationSchema = useMemo(
|
|
42
40
|
() =>
|
|
43
41
|
z.object({
|
|
44
|
-
name: z.string().
|
|
42
|
+
name: z.string().min(1, 'Name field is required'),
|
|
45
43
|
description: z.string().min(20, 'description must be at least 20 characters'),
|
|
46
44
|
priceType: z.enum(['fixed', 'variable']),
|
|
47
45
|
}),
|
|
48
|
-
[]
|
|
46
|
+
[],
|
|
49
47
|
);
|
|
50
48
|
|
|
51
49
|
const { handleSubmit, control } = useForm<FormFields>({
|
|
@@ -34,7 +34,7 @@ export const HandleContainer = styled.div`
|
|
|
34
34
|
}
|
|
35
35
|
`;
|
|
36
36
|
|
|
37
|
-
export const DrawerContent = forwardRef<HTMLElement, HTMLProps<HTMLDivElement>>((props, propRef)
|
|
37
|
+
export const DrawerContent = forwardRef<HTMLElement, HTMLProps<HTMLDivElement>>(function DrawerContent(props, propRef) {
|
|
38
38
|
const { context, labelId, descriptionId, getFloatingProps, setOpen, canDrag } = useDrawerContext();
|
|
39
39
|
|
|
40
40
|
const ref = useMergeRefs([context.refs.setFloating, propRef]);
|
|
@@ -16,34 +16,35 @@ interface DialogHeadingProps extends HTMLProps<HTMLHeadingElement> {
|
|
|
16
16
|
hasClose?: boolean;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const DrawerHeading = forwardRef<HTMLHeadingElement, DialogHeadingProps>(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
export const DrawerHeading = forwardRef<HTMLHeadingElement, DialogHeadingProps>(function DrawerHeading(
|
|
20
|
+
{ children, hasClose = true, ...props },
|
|
21
|
+
ref,
|
|
22
|
+
) {
|
|
23
|
+
const { setLabelId, setOpen } = useDrawerContext();
|
|
24
|
+
const id = useId();
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
useLayoutEffect(() => {
|
|
27
|
+
setLabelId(id);
|
|
28
|
+
return () => setLabelId(undefined);
|
|
29
|
+
}, [id, setLabelId]);
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
);
|
|
31
|
+
return (
|
|
32
|
+
<Container>
|
|
33
|
+
<h2 {...props} ref={ref} id={id}>
|
|
34
|
+
{children}
|
|
35
|
+
</h2>
|
|
36
|
+
{hasClose && (
|
|
37
|
+
<Tooltip>
|
|
38
|
+
<Tooltip.Trigger asChild>
|
|
39
|
+
<IconButton
|
|
40
|
+
onClick={() => setOpen(false)}
|
|
41
|
+
icon={<CloseIcon size={18} cursor="pointer" />}
|
|
42
|
+
ariaLabel="Close"
|
|
43
|
+
/>
|
|
44
|
+
</Tooltip.Trigger>
|
|
45
|
+
<Tooltip.Content>Close</Tooltip.Content>
|
|
46
|
+
</Tooltip>
|
|
47
|
+
)}
|
|
48
|
+
</Container>
|
|
49
|
+
);
|
|
50
|
+
});
|
|
@@ -10,42 +10,43 @@ export interface InfiniteScrollProps {
|
|
|
10
10
|
hasNextPage?: boolean;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const InfiniteScroll = forwardRef<HTMLElement, InfiniteScrollProps>(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
export const InfiniteScroll = forwardRef<HTMLElement, InfiniteScrollProps>(function InfiniteScroll(
|
|
14
|
+
{ hasNextPage = false, fetchNextPage, isFetching, isFetchingNextPage },
|
|
15
|
+
propRef,
|
|
16
|
+
) {
|
|
17
|
+
const { ref: viewRef, inView } = useInView();
|
|
18
|
+
const ref = useMergeRefs([propRef, viewRef]);
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
fetchNextPage();
|
|
21
|
-
}
|
|
22
|
-
}, [inView]);
|
|
23
|
-
|
|
24
|
-
// Fallback: sometimes the inView event does not trigger automatically.
|
|
25
|
-
// the user will have to manually click the button to fetch the next page.
|
|
26
|
-
const handleOnClick = () => {
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (inView) {
|
|
27
22
|
fetchNextPage();
|
|
28
|
-
}
|
|
23
|
+
}
|
|
24
|
+
}, [inView]);
|
|
25
|
+
|
|
26
|
+
// Fallback: sometimes the inView event does not trigger automatically.
|
|
27
|
+
// the user will have to manually click the button to fetch the next page.
|
|
28
|
+
const handleOnClick = () => {
|
|
29
|
+
fetchNextPage();
|
|
30
|
+
};
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
{!isFetchingNextPage && hasNextPage && !isFetching && (
|
|
35
|
+
<div
|
|
36
|
+
ref={ref}
|
|
37
|
+
style={{ display: 'flex', height: '100%', width: '100%', justifyContent: 'center', alignItems: 'center' }}
|
|
38
|
+
>
|
|
39
|
+
<Button text="Load more" ref={ref} onClick={handleOnClick} />
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
{hasNextPage && isFetchingNextPage && (
|
|
43
|
+
<div
|
|
44
|
+
ref={ref}
|
|
45
|
+
style={{ display: 'flex', height: '100%', width: '100%', justifyContent: 'center', alignItems: 'center' }}
|
|
46
|
+
>
|
|
47
|
+
<Spinner size="medium" />
|
|
48
|
+
</div>
|
|
49
|
+
)}
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
@@ -105,6 +105,7 @@ export default {
|
|
|
105
105
|
sort: false,
|
|
106
106
|
refetching: true,
|
|
107
107
|
isLoading: false,
|
|
108
|
+
data,
|
|
108
109
|
},
|
|
109
110
|
} as Meta<TableProps<User>>;
|
|
110
111
|
|
|
@@ -121,7 +122,7 @@ const Users: FC<TableProps<User>> = (args) => {
|
|
|
121
122
|
return (
|
|
122
123
|
<Table
|
|
123
124
|
id="story-table"
|
|
124
|
-
data={data}
|
|
125
|
+
data={args.data}
|
|
125
126
|
columns={columns}
|
|
126
127
|
pagination={{
|
|
127
128
|
...pagination,
|
|
@@ -139,4 +140,7 @@ const Users: FC<TableProps<User>> = (args) => {
|
|
|
139
140
|
);
|
|
140
141
|
};
|
|
141
142
|
|
|
142
|
-
export const
|
|
143
|
+
export const EmptyTable: StoryFn<TableProps<User>> = (args) => {
|
|
144
|
+
return <Users {...args} data={[]} />;
|
|
145
|
+
};
|
|
146
|
+
export const DataTable: StoryFn<TableProps<User>> = (args) => <Users {...args} />;
|