-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ComboBoxNormalized - windowed data component (#2072)
* Created `ComboBoxNormalized` component. This component handles normalized item and section data which is needed to support windowed data. (there will be 1 more PR providing the ComboBox component in the jsapi-components package that will handle the table support. Similar to Picker) * Styleguide example showing controlled data + validation for no selection * Split out `usePickerNormalizedProps` hook from `PickerNormalized` so that the logic could be reused in `ComboBoxNormalized` * Cleaned up some generics for utils using Spectrum `DomRef` resolves #2071
- Loading branch information
Showing
20 changed files
with
287 additions
and
161 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
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
39 changes: 39 additions & 0 deletions
39
packages/components/src/spectrum/comboBox/ComboBoxNormalized.tsx
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,39 @@ | ||
import { ComboBox as SpectrumComboBox } from '@adobe/react-spectrum'; | ||
import { FocusableRef } from '@react-types/shared'; | ||
import cl from 'classnames'; | ||
import { PickerNormalizedPropsT, usePickerNormalizedProps } from '../picker'; | ||
import { ComboBoxProps } from './ComboBox'; | ||
|
||
export type ComboBoxNormalizedProps = PickerNormalizedPropsT<ComboBoxProps>; | ||
|
||
/** | ||
* ComboBox that takes an array of `NormalizedItem` or `NormalizedSection` items | ||
* as children and uses a render item function to render the items. `NormalizedItem` | ||
* and `NormalizedSection` datums always provide a `key` property but have an | ||
* optional `item` property that can be lazy loaded. This is necessary to support | ||
* windowed data since we need a representative key for every item in the | ||
* collection. | ||
*/ | ||
export function ComboBoxNormalized({ | ||
UNSAFE_className, | ||
...props | ||
}: ComboBoxNormalizedProps): JSX.Element { | ||
const { forceRerenderKey, ref, ...pickerProps } = | ||
usePickerNormalizedProps<ComboBoxNormalizedProps>(props); | ||
|
||
return ( | ||
<SpectrumComboBox | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...pickerProps} | ||
key={forceRerenderKey} | ||
ref={ref as FocusableRef<HTMLElement>} | ||
UNSAFE_className={cl( | ||
'dh-combobox', | ||
'dh-combobox-normalized', | ||
UNSAFE_className | ||
)} | ||
/> | ||
); | ||
} | ||
|
||
export default ComboBoxNormalized; |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './ComboBox'; | ||
export * from './ComboBoxNormalized'; |
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
98 changes: 7 additions & 91 deletions
98
packages/components/src/spectrum/picker/PickerNormalized.tsx
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
Oops, something went wrong.