Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SelectInputInset): rename SelectInputNativeInset to SelectInputInset #883

Merged
merged 1 commit into from
Mar 15, 2024
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
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { useState } from 'react';
import { action } from '@storybook/addon-actions';
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import { SelectInputNativeInset } from './SelectInputNativeInset';
import { SelectInputInset } from './SelectInputInset';
import { RESPONSIVE_STORY } from '../../docs/constants';
import { Box } from '../Box/Box';
import { Icon } from '../Icon/Icon';

<Meta
title="Components/SelectInputNativeInset/Overview"
component={SelectInputNativeInset}
title="Components/SelectInputInset/Overview"
component={SelectInputInset}
parameters={{
controls: { hideNoControlsWarning: true },
}}
/>

# SelectInputNativeInset
# SelectInputInset

Use `SelectInputNativeInset` to create a floating label input field, but unlike `TextInputInset` they always show the `label` in the floated state. It is a controlled component, which means that you need to provide a value and an `onChange` handler to update the value.
Use `SelectInputInset` to create a floating label input field, but unlike `TextInputInset` they always show the `label` in the floated state. It is a controlled component, which means that you need to provide a value and an `onChange` handler to update the value.

<Canvas withSource="open">
<Story
Expand All @@ -36,7 +36,7 @@ Use `SelectInputNativeInset` to create a floating label input field, but unlike
{ value: 'vanilla', label: 'Vanilla' },
];
return (
<SelectInputNativeInset
<SelectInputInset
id="default Select"
label="Label"
onChange={event => {
Expand All @@ -52,7 +52,7 @@ Use `SelectInputNativeInset` to create a floating label input field, but unlike

## Props

<ArgsTable of={SelectInputNativeInset} />
<ArgsTable of={SelectInputInset} />

### Required

Expand All @@ -69,7 +69,7 @@ Use the `isRequired` prop to display an `*` after the label and set the `require
];
return (
<Box gap="md">
<SelectInputNativeInset
<SelectInputInset
id="requiredSelect"
label="Required Field"
onChange={event => {
Expand All @@ -79,7 +79,7 @@ Use the `isRequired` prop to display an `*` after the label and set the `require
value={value}
isRequired
/>
<SelectInputNativeInset
<SelectInputInset
id="customRequiredSelect"
label="Custom Required Indicator Field"
onChange={event => {
Expand Down Expand Up @@ -110,7 +110,7 @@ Use `helpText` to provide additional information about the input field.
{ value: 'Tesla', label: 'Tesla' },
];
return (
<SelectInputNativeInset
<SelectInputInset
id="helpTextSelect"
label="Inverter Manufacturer"
helpText="Must be from the approved vendor list"
Expand Down Expand Up @@ -139,7 +139,7 @@ Use the `error` prop to mark the input as invalid. `error` accepts a `boolean`,
{ value: 'Tesla', label: 'Tesla' },
];
return (
<SelectInputNativeInset
<SelectInputInset
id="errorSelect"
label="Inverter Manufacturer"
helpText="Must be from the approved vendor list"
Expand Down Expand Up @@ -169,7 +169,7 @@ Add `isDisabled`to give it a grayed out appearance, remove pointer events, and p
{ value: 'Tesla', label: 'Tesla' },
];
return (
<SelectInputNativeInset
<SelectInputInset
id="disabledSelect"
label="Disabled Input"
onChange={event => {
Expand Down Expand Up @@ -199,7 +199,7 @@ a callback function when the clear icon is clicked, which can then be handled to
{ value: 'option3', label: 'Option 3' },
];
return (
<SelectInputNativeInset
<SelectInputInset
id="clearableSelect"
label="Clearable Input"
onChange={event => {
Expand Down Expand Up @@ -229,22 +229,22 @@ Two sizes, `md` and `lg` are available, with `md` being the default.
];
return (
<Box gap="md">
<SelectInputNativeInset
<SelectInputInset
id="mdFlavorInput"
value={value}
label="md size"
onChange={event => setValue(event.target.value)}
options={options}
/>
<SelectInputNativeInset
<SelectInputInset
id="lgFlavorInput"
value={value}
size="lg"
label="lg size"
onChange={event => setValue(event.target.value)}
options={options}
/>
<SelectInputNativeInset
<SelectInputInset
id="responsiveFlavorInput"
value={value}
size={{ base: 'md', tablet: 'lg', desktop: 'md', hd: 'lg' }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React from 'react';
import { Meta, Story } from '@storybook/react/types-6-0';
import { boxPropsKeys } from '../Box/Box';
import {
SelectInputNativeInset,
SelectInputNativeInsetProps,
} from './SelectInputNativeInset';
import { SelectInputInset, SelectInputInsetProps } from './SelectInputInset';

export default {
title: 'Components/SelectInputNativeInset/Playground',
component: SelectInputNativeInset,
title: 'Components/SelectInputInset/Playground',
component: SelectInputInset,
argTypes: {
id: {
control: 'text',
Expand Down Expand Up @@ -62,15 +59,15 @@ export default {
},
} as Meta;

const Template: Story<SelectInputNativeInsetProps> = ({ ...args }) => (
<SelectInputNativeInset {...args} />
const Template: Story<SelectInputInsetProps> = ({ ...args }) => (
<SelectInputInset {...args} />
);

export const Playground = Template.bind({});
Playground.args = {
id: 'playgroundSelectInputNativeInset',
label: 'Playground SelectInputNativeInset',
name: 'playgroundSelectInputNativeInset',
id: 'playgroundSelectInputInset',
label: 'Playground SelectInputInset',
name: 'playgroundSelectInputInset',
options: [
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'strawberry', label: 'Strawberry' },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import React from 'react';
import { render, fireEvent, screen } from '@testing-library/react';
import { BreakpointSize } from '../../types';
import { SelectInputNativeInset } from './SelectInputNativeInset';
import { SelectInputInset } from './SelectInputInset';

const selectOptions = [
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'strawberry', label: 'Strawberry' },
{ value: 'vanilla', label: 'Vanilla' },
];

describe('SelectInputNativeInset', () => {
describe('SelectInputInset', () => {
describe('Callback Handling', () => {
test('it fires onChange callback on change', async () => {
const mockedHandleChange = jest.fn();

const { getByLabelText } = render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
placeholder="Test Placeholder"
Expand All @@ -35,7 +35,7 @@ describe('SelectInputNativeInset', () => {
const mockedHandleFocus = jest.fn();

render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
onFocus={mockedHandleFocus}
Expand All @@ -56,7 +56,7 @@ describe('SelectInputNativeInset', () => {
const mockedHandleBlur = jest.fn();

render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
onBlur={mockedHandleBlur}
Expand All @@ -78,7 +78,7 @@ describe('SelectInputNativeInset', () => {
test('onClear prop renders clear icon when input has value', () => {
const mockedHandleChange = jest.fn();
render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
options={selectOptions}
Expand All @@ -96,7 +96,7 @@ describe('SelectInputNativeInset', () => {
const mockedHandleClear = jest.fn(() => null);

render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
options={selectOptions}
Expand All @@ -123,7 +123,7 @@ describe('SelectInputNativeInset', () => {
const mockedHandleChange = jest.fn();

render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
label="Select Label"
Expand All @@ -138,7 +138,7 @@ describe('SelectInputNativeInset', () => {

test('assigns the "aria-labelledby" attribute and renders label correct id, when a label is provided', () => {
render(
<SelectInputNativeInset
<SelectInputInset
id="testInput"
label="test label"
options={selectOptions}
Expand All @@ -160,7 +160,7 @@ describe('SelectInputNativeInset', () => {
const mockedHandleChange = jest.fn();

render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
label="Required Select"
Expand All @@ -179,7 +179,7 @@ describe('SelectInputNativeInset', () => {
const mockedHandleChange = jest.fn();

render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
label="Select Label"
Expand All @@ -198,7 +198,7 @@ describe('SelectInputNativeInset', () => {
const mockedHandleChange = jest.fn();

render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
label="disabled test"
Expand All @@ -217,7 +217,7 @@ describe('SelectInputNativeInset', () => {
const mockedHandleChange = jest.fn();

render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
label="Select Label"
Expand All @@ -241,7 +241,7 @@ describe('SelectInputNativeInset', () => {
sizes.forEach(size => {
test(`it has a ${size} class applied to it`, () => {
render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
options={selectOptions}
Expand All @@ -258,7 +258,7 @@ describe('SelectInputNativeInset', () => {
breakpoints.forEach(breakpoint => {
test(`it applies responsive classes for breakpoint: ${breakpoint} and size: ${size}`, () => {
render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
options={selectOptions}
Expand All @@ -279,7 +279,7 @@ describe('SelectInputNativeInset', () => {

test('It applies responsive classes when multiple are applied', () => {
render(
<SelectInputNativeInset
<SelectInputInset
id="testId"
onChange={mockedHandleChange}
options={selectOptions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import { HelpText } from '../HelpText/HelpText';
import { Icon } from '../Icon/Icon';
import { getAutoCompleteValue } from '../../lib/getAutoCompleteValue';
import styles from './SelectInputNativeInset.module.scss';
import styles from './SelectInputInset.module.scss';
import { InputValidationMessage } from '../InputValidationMessage/InputValidationMessage';

export type SelectInputNativeInsetSize = 'md' | 'lg';
export interface SelectInputNativeInsetProps {
export type SelectInputInsetSize = 'md' | 'lg';
export interface SelectInputInsetProps {
/**
* The input's id attribute. Used to programmatically tie the input with its label.
*/
Expand Down Expand Up @@ -103,16 +103,14 @@
/**
* The size of the text input.
*/
size?:
| SelectInputNativeInsetSize
| ResponsiveProp<SelectInputNativeInsetSize>;
size?: SelectInputInsetSize | ResponsiveProp<SelectInputInsetSize>;
/**
* Additional props to be spread to rendered element
*/
[x: string]: any; // eslint-disable-line
}

export const SelectInputNativeInset: ForwardRefExoticComponent<SelectInputNativeInsetProps> = forwardRef<HTMLDivElement, SelectInputNativeInsetProps>(
export const SelectInputInset: ForwardRefExoticComponent<SelectInputInsetProps> = forwardRef<HTMLDivElement, SelectInputInsetProps>(

Check warning on line 113 in src/components/SelectInputInset/SelectInputInset.tsx

View workflow job for this annotation

GitHub Actions / lint js

This line has a length of 132. Maximum allowed is 120
(
{
id,
Expand Down Expand Up @@ -176,7 +174,7 @@
);
};

const computedInputProps: SelectInputNativeInsetProps['inputProps'] = {
const computedInputProps: SelectInputInsetProps['inputProps'] = {
...inputProps, // These are spread first so that we don't have top level props overwritten by the user.
'aria-required': isRequired,
'aria-invalid': !!error,
Expand Down
2 changes: 1 addition & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export * from './RadioGroup/RadioGroup';
export * from './ResponsiveProvider/ResponsiveProvider';
export * from './SelectInput/SelectInput';
export * from './SelectInputNative/SelectInputNative';
export * from './SelectInputNativeInset/SelectInputNativeInset';
export * from './SelectInputInset/SelectInputInset';
export * from './Spinner/Spinner';
export * from './TabPanels/TabPanels';
export * from './Tabs/Tabs';
Expand Down
4 changes: 2 additions & 2 deletions src/docs/FormTheming.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TextInputInset } from '../components/TextInputInset/TextInputInset';
import { CheckboxInput } from '../components/CheckboxInput/CheckboxInput';
import { SelectInput } from '../components/SelectInput/SelectInput';
import { SelectInputNative } from '../components/SelectInputNative/SelectInputNative';
import { SelectInputNativeInset } from '../components/SelectInputNativeInset/SelectInputNativeInset';
import { SelectInputInset } from '../components/SelectInputInset/SelectInputInset';
import { OptionTileGroup } from '../components/OptionTileGroup/OptionTileGroup';
import { RadioGroup } from '../components/RadioGroup/RadioGroup';
import { TextareaInput } from '../components/TextareaInput/TextareaInput';
Expand Down Expand Up @@ -123,7 +123,7 @@ Form controls share tokens since they are designed to have a consistent appearan
options={options}
value={themeExampleValues.selectValue}
/>
<SelectInputNativeInset
<SelectInputInset
id="floationg Select"
label="Inset Select Input"
onChange={event => handleChange('selectValue', event.target.value)}
Expand Down
4 changes: 2 additions & 2 deletions src/stories/FormControls.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TextInputInset } from '../components/TextInputInset/TextInputInset';
import { TextareaInput } from '../components/TextareaInput/TextareaInput';
import { TextareaInputInset } from '../components/TextareaInputInset/TextareaInputInset';
import { SelectInputNative } from '../components/SelectInputNative/SelectInputNative';
import { SelectInputNativeInset } from '../components/SelectInputNativeInset/SelectInputNativeInset';
import { SelectInputInset } from '../components/SelectInputInset/SelectInputInset';
import { Toggle } from '../components/Toggle/Toggle';

<Meta title="Patterns/Form Controls" />
Expand Down Expand Up @@ -69,7 +69,7 @@ Try not to mix Inset style inputs with regular inputs in the same form.
value={formValues.textInputMd}
onChange={event => handleChange('notesInput', event.target.value)}
/>
<SelectInputNativeInset
<SelectInputInset
id="floatingSelectNative"
label="Flavor"
onChange={event => handleChange('selectInput', event.target.value)}
Expand Down
Loading