forked from deephaven/web-client-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: checkbox_group re-export (deephaven#2212)
Resolves deephaven#2211 Needed for changes in plugins PR: deephaven/deephaven-plugins#813
- Loading branch information
1 parent
cc67bce
commit a20fa1d
Showing
9 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import { CheckboxGroup, Flex, Text } from '@deephaven/components'; | ||
// eslint-disable-next-line no-restricted-imports | ||
import { Checkbox } from '@adobe/react-spectrum'; | ||
import SampleSection from './SampleSection'; | ||
|
||
export function CheckboxGroups(): JSX.Element { | ||
return ( | ||
<SampleSection name="checkbox-groups"> | ||
<h2 className="ui-title">Checkbox Groups</h2> | ||
<Flex gap="size-100" gridColumn="span 3" height="100%"> | ||
<Flex direction="column"> | ||
<Text>Single Child</Text> | ||
<CheckboxGroup aria-label="Single Child"> | ||
<Checkbox value="Aaa">Aaa</Checkbox> | ||
</CheckboxGroup> | ||
</Flex> | ||
|
||
<Flex direction="column"> | ||
<Text>Multiple Children</Text> | ||
<CheckboxGroup aria-label="Multiple Children"> | ||
<Checkbox value="Aaa">Aaa</Checkbox> | ||
<Checkbox value="Bbb">Bbb</Checkbox> | ||
<Checkbox value="Ccc">Ccc</Checkbox> | ||
</CheckboxGroup> | ||
</Flex> | ||
|
||
<Flex direction="column"> | ||
<Text>Mixed Children Types</Text> | ||
<CheckboxGroup aria-label="Mixed Children Types"> | ||
{/* eslint-disable react/jsx-curly-brace-presence */} | ||
{'String 1'} | ||
{'String 2'} | ||
{444} | ||
{999} | ||
{true} | ||
{false} | ||
<Checkbox>Aaa</Checkbox> | ||
</CheckboxGroup> | ||
</Flex> | ||
</Flex> | ||
</SampleSection> | ||
); | ||
} | ||
|
||
export default CheckboxGroups; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* eslint-disable react/no-array-index-key */ | ||
import { isElementOfType } from '@deephaven/react-hooks'; | ||
import React, { type ReactNode, useMemo } from 'react'; | ||
import { | ||
Checkbox, | ||
CheckboxGroup as SpectrumCheckboxGroup, | ||
type SpectrumCheckboxGroupProps, | ||
} from '@adobe/react-spectrum'; | ||
import { ensureArray } from '@deephaven/utils'; | ||
|
||
export type CheckboxGroupProps = { | ||
children: ReactNode; | ||
} & Omit<SpectrumCheckboxGroupProps, 'children'>; | ||
|
||
/** | ||
* Augmented version of the Spectrum CheckboxGroup component that supports | ||
* primitive item children. | ||
*/ | ||
export function CheckboxGroup({ | ||
children, | ||
...props | ||
}: CheckboxGroupProps): JSX.Element { | ||
const wrappedChildren = useMemo( | ||
() => | ||
ensureArray(children).map(child => | ||
isElementOfType(child, Checkbox) ? ( | ||
child | ||
) : ( | ||
<Checkbox key={String(child)} value={String(child)}> | ||
{String(child)} | ||
</Checkbox> | ||
) | ||
), | ||
[children] | ||
); | ||
|
||
return ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<SpectrumCheckboxGroup {...props}>{wrappedChildren}</SpectrumCheckboxGroup> | ||
); | ||
} | ||
|
||
export default CheckboxGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+15.4 KB
tests/styleguide.spec.ts-snapshots/checkbox-groups-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.