Skip to content

Commit

Permalink
Debug tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Oct 21, 2024
1 parent d4144dc commit dc96487
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 30 deletions.
12 changes: 12 additions & 0 deletions docs/data/translations/api-docs/select-option/select-option.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"componentDescription": "",
"propDescriptions": {
"disabled": { "description": "If <code>true</code>, the select option will be disabled." },
"label": {
"description": "A text representation of the select option&#39;s content. Used for keyboard text navigation matching."
},
"onClick": { "description": "The click handler for the select option." },
"value": { "description": "The value of the select option." }
},
"classDescriptions": {}
}
91 changes: 87 additions & 4 deletions packages/mui-base/src/Select/Option/SelectOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import { commonStyleHooks } from '../utils/commonStyleHooks';
import { useEnhancedEffect } from '../../utils/useEnhancedEffect';
import { useCompositeListItem } from '../../Composite/List/useCompositeListItem';

/**
* @ignore - internal component.
*/
const InnerSelectOption = React.memo(
React.forwardRef(function InnerSelectOption(
props: InnerSelectOptionProps,
Expand Down Expand Up @@ -77,7 +74,93 @@ const InnerSelectOption = React.memo(
);

/**
* An unstyled select item to be used within a Select.
*
* Demos:
*
* - [Select](https://base-ui.netlify.app/components/react-select/)
*
* API:
*
* - [SelectOption API](https://base-ui.netlify.app/components/react-select/#api-reference-SelectOption)
*/

InnerSelectOption.propTypes /* remove-proptypes */ = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* @ignore
*/
children: PropTypes.node,
/**
* Class names applied to the element or a function that returns them based on the component's state.
*/
className: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
/**
* If `true`, the select option will be disabled.
* @default false
*/
disabled: PropTypes.bool,
/**
* @ignore
*/
getItemProps: PropTypes.func.isRequired,
/**
* @ignore
*/
handleSelect: PropTypes.func.isRequired,
/**
* @ignore
*/
highlighted: PropTypes.bool.isRequired,
/**
* @ignore
*/
id: PropTypes.string,
/**
* A text representation of the select option's content.
* Used for keyboard text navigation matching.
*/
label: PropTypes.string,
/**
* The click handler for the select option.
*/
onClick: PropTypes.func,
/**
* @ignore
*/
open: PropTypes.bool.isRequired,
/**
* A function to customize rendering of the component.
*/
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
/**
* @ignore
*/
selected: PropTypes.bool.isRequired,
/**
* @ignore
*/
selectionRef: PropTypes.shape({
current: PropTypes.shape({
allowMouseUp: PropTypes.bool.isRequired,
allowSelect: PropTypes.bool.isRequired,
}).isRequired,
}).isRequired,
/**
* @ignore
*/
setOpen: PropTypes.func.isRequired,
/**
* @ignore
*/
typingRef: PropTypes.shape({
current: PropTypes.bool.isRequired,
}).isRequired,
} as any;

/**
*
* Demos:
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
// import * as React from 'react';
// import { Select } from '@base_ui/react/Select';
// import { createRenderer, describeConformance } from '#test-utils';
// import { SelectOptionContext } from '../Option/SelectOptionContext';
import * as React from 'react';
import { Select } from '@base_ui/react/Select';
import { createRenderer, describeConformance } from '#test-utils';

// const selectItemContextValue = {
// open: true,
// selected: true,
// };
describe('<Select.OptionIndicator />', () => {
const { render } = createRenderer();

// describe('<Select.OptionIndicator />', () => {
// const { render } = createRenderer();

// describeConformance(<Select.OptionIndicator />, () => ({
// refInstanceof: window.HTMLSpanElement,
// render(node) {
// return render(
// <Select.Root open animated={false}>
// <Select.Positioner>
// <SelectOptionContext.Provider value={selectItemContextValue}>
// {node}
// </SelectOptionContext.Provider>
// </Select.Positioner>
// </Select.Root>,
// );
// },
// }));
// });
describeConformance(<Select.OptionIndicator />, () => ({
refInstanceof: window.HTMLSpanElement,
render(node) {
return render(
<Select.Root open animated={false}>
<Select.Trigger>
<Select.Value />
</Select.Trigger>
<Select.Positioner>
<Select.Option>{node}</Select.Option>
</Select.Positioner>
</Select.Root>,
);
},
}));
});

0 comments on commit dc96487

Please sign in to comment.