Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions packages/code-studio/src/styleguide/Inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AutoResizeTextarea,
Checkbox,
ComboBox,
RadioItem,
Radio,
RadioGroup,
SearchInput,
TimeInput,
Expand Down Expand Up @@ -56,12 +56,9 @@ function Inputs(): React.ReactElement {
const [autoResizeTextareaValue, setAutoResizeTextareaValue] = useState(
'-DLiveTableMonitor.updateThreads=8 -DLiveTableMonitor.printDependencyInformation=false -Dassertion.heapDump=true -Drequire.heapDump=true -Dassertion.heapDump=true -Drequire.heapDump=true'
);
const handleRadioChange = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
setRadioValue(event.target.value);
},
[]
);
const handleRadioChange = useCallback((value: string) => {
setRadioValue(value);
}, []);

const handleToggleClick = useCallback(() => {
setOn(!on);
Expand Down Expand Up @@ -186,18 +183,26 @@ function Inputs(): React.ReactElement {

<div className="col">
<form>
<h5> Radios </h5>
<RadioGroup onChange={handleRadioChange} value={radioValue}>
<RadioItem value="1">Toggle this custom radio</RadioItem>
<RadioItem value="2">Or toggle this other custom radio</RadioItem>
<RadioItem value="3" disabled>
<h5 id="inputs-radios-heading">Radios</h5>
<RadioGroup
aria-labelledby="inputs-radios-heading"
onChange={handleRadioChange}
value={radioValue}
isInvalid={radioValue === '4'}
description="Select a radio item"
errorMessage={
radioValue === '4' ? 'Invalid radio selected' : undefined
}
Comment on lines +193 to +195
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't think you necessarily need a ternary here, as the error message is only shown when it's invalid anyway. But no matter.

Suggested change
errorMessage={
radioValue === '4' ? 'Invalid radio selected' : undefined
}
errorMessage="Invalid radio selected"

>
<Radio value="1">Toggle this custom radio</Radio>
<Radio value="2">Or toggle this other custom radio</Radio>
<Radio value="3" isDisabled>
Disabled radio
</RadioItem>
<RadioItem value="4" isInvalid>
Invalid radio
</RadioItem>
{/* eslint-disable-next-line react/jsx-no-useless-fragment */}
<>{check4 && <RadioItem value="5">Extra radio item</RadioItem>}</>
</Radio>
<Radio value="4">Invalid radio</Radio>
<Radio isHidden={!check4} value="5">
Extra radio item
</Radio>
</RadioGroup>
</form>
<div className="form-group">
Expand Down
31 changes: 17 additions & 14 deletions packages/code-studio/src/styleguide/ListViews.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ChangeEvent, ReactNode, useCallback, useState } from 'react';
import React, { ReactNode, useCallback, useState } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { StyleProps } from '@react-types/shared';
import type { BoxAlignmentStyleProps, StyleProps } from '@react-types/shared';
import {
Grid,
Icon,
Expand All @@ -13,7 +13,7 @@ import {
Checkbox,
ListViewProps,
RadioGroup,
RadioItem,
Radio,
useSpectrumThemeProvider,
ListActionGroup,
} from '@deephaven/components';
Expand All @@ -35,7 +35,7 @@ function AccountIllustration(): JSX.Element {
);
}

interface LabeledProps extends StyleProps {
interface LabeledProps extends BoxAlignmentStyleProps, StyleProps {
label: string;
direction?: 'row' | 'column';
children: ReactNode;
Expand Down Expand Up @@ -83,12 +83,9 @@ export function ListViews(): JSX.Element {
2 + // listview border
LIST_VIEW_ROW_HEIGHTS[density ?? 'compact'][scale];

const onDensityChange = useCallback(
(event: ChangeEvent<HTMLInputElement>) => {
setDensity(event.currentTarget.value as ListViewProps['density']);
},
[]
);
const onDensityChange = useCallback((value: string) => {
setDensity(value as ListViewProps['density']);
}, []);

const [showIcons, setShowIcons] = useState(true);
const [lastActionKey, setLastActionKey] = useState<ItemKey>('');
Expand All @@ -115,14 +112,20 @@ export function ListViews(): JSX.Element {
rows={`auto minmax(${singleChildExampleHeight}px, auto) 1fr auto 1fr`}
>
<LabeledFlexContainer
alignItems="center"
direction="row"
label="Density"
gridColumn="span 3"
>
<RadioGroup value={density} onChange={onDensityChange}>
<RadioItem value="compact">Compact</RadioItem>
<RadioItem value="regular">Regular</RadioItem>
<RadioItem value="spacious">Spacious</RadioItem>
<RadioGroup
aria-label="Density"
orientation="horizontal"
value={density}
onChange={onDensityChange}
>
<Radio value="compact">Compact</Radio>
<Radio value="regular">Regular</Radio>
<Radio value="spacious">Spacious</Radio>
</RadioGroup>
</LabeledFlexContainer>

Expand Down
35 changes: 1 addition & 34 deletions packages/code-studio/src/styleguide/SpectrumComparison.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/jsx-props-no-spreading */
/* eslint-disable react/style-prop-object */
import React, { Fragment, useCallback, useState } from 'react';
import React, { Fragment, useState } from 'react';
import {
ActionButton,
Button,
Expand All @@ -11,17 +11,13 @@ import {
Icon,
Item,
Picker,
Radio,
RadioGroup,
SpectrumButtonProps,
TextField,
} from '@adobe/react-spectrum';
import {
Button as BootstrapButtonOld,
Checkbox as CheckboxOld,
ComboBox as ComboBoxOld,
RadioGroup as RadioGroupOld,
RadioItem,
Select,
View,
Text,
Expand Down Expand Up @@ -51,14 +47,6 @@ const options = [

export function SpectrumComparison(): JSX.Element {
const [isChecked, setIsChecked] = useState(false);
const [radioValue, setRadioValue] = useState('1');

const handleRadioChange = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
setRadioValue(event.target.value);
},
[]
);

return (
<div
Expand Down Expand Up @@ -285,27 +273,6 @@ export function SpectrumComparison(): JSX.Element {
Disabled
</CheckboxOld>
<Checkbox isDisabled>Disabled</Checkbox>

<Flex direction="column">
<label>
Radio Group
<RadioGroupOld onChange={handleRadioChange} value={radioValue}>
<RadioItem value="1">One</RadioItem>
<RadioItem value="2">Two</RadioItem>
<RadioItem value="3">Three</RadioItem>
</RadioGroupOld>
</label>
</Flex>

<RadioGroup
label="Radio Group"
value={radioValue}
onChange={setRadioValue}
>
<Radio value="1">One</Radio>
<Radio value="2">Two</Radio>
<Radio value="3">Three</Radio>
</RadioGroup>
</Grid>
</View>
</Flex>
Expand Down
23 changes: 0 additions & 23 deletions packages/components/src/RadioGroup.test.tsx

This file was deleted.

57 changes: 0 additions & 57 deletions packages/components/src/RadioGroup.tsx

This file was deleted.

102 changes: 0 additions & 102 deletions packages/components/src/RadioItem.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export * from './navigation';
export { default as Option } from './Option';
export * from './popper';
export * from './modal';
export { default as RadioGroup } from './RadioGroup';
export { default as RadioItem } from './RadioItem';
export { default as RandomAreaPlotAnimation } from './RandomAreaPlotAnimation';
export * from './SearchableCombobox';
export { default as Select } from './Select';
Expand Down
Loading