Skip to content

Commit

Permalink
fix(sdds-serv): Fix switch types and auto fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
iljs committed Jun 5, 2024
1 parent af6aaa3 commit 6fd8091
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 90 deletions.
38 changes: 4 additions & 34 deletions packages/sdds-serv/api/sdds-serv.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import { dsplMBold } from '@salutejs/sdds-themes/tokens';
import { dsplS } from '@salutejs/sdds-themes/tokens';
import { dsplSBold } from '@salutejs/sdds-themes/tokens';
import { Filter } from '@salutejs/plasma-new-hope/types/engines/types';
import { FocusProps } from '@salutejs/plasma-new-hope/styled-components';
import { ForwardRefExoticComponent } from 'react';
import { FunctionComponent } from 'react';
import { GridProps } from '@salutejs/plasma-new-hope/styled-components';
Expand Down Expand Up @@ -132,7 +131,7 @@ import { SpacingProps } from '@salutejs/plasma-new-hope/styled-components';
import { SSRProvider } from '@salutejs/plasma-new-hope/styled-components';
import { StatusLabels } from '@salutejs/plasma-new-hope/types/components/Avatar/Avatar.types';
import { StyledComponent } from 'styled-components';
import { SwitchPropsVariations } from '@salutejs/plasma-new-hope/types/components/Switch/Switch.types';
import type { SwitchProps } from '@salutejs/plasma-core';
import { TabItemProps } from '@salutejs/plasma-new-hope/styled-components';
import { TabItemRefs } from '@salutejs/plasma-new-hope/styled-components';
import { TabsContext } from '@salutejs/plasma-new-hope/styled-components';
Expand Down Expand Up @@ -1387,39 +1386,10 @@ export type SpinnerProps = HTMLAttributes<HTMLDivElement> & {

export { SSRProvider }

// @public
export const Switch: FunctionComponent<PropsType< {
size: {
m: string;
};
view: {
default: string;
};
labelPosition: {
before: string;
after: string;
};
disabled: {
true: string;
};
focused: {
true: string;
};
}> & Filter<InputHTMLAttributes_2<HTMLInputElement>, "size"> & SwitchPropsVariations & RefAttributes<HTMLInputElement>>;

// @public (undocumented)
export type SwitchProps = {
id?: string;
label?: React.ReactNode;
size?: string;
view?: string;
labelPosition?: 'before' | 'after';
description?: React.ReactNode;
disabled?: boolean;
pressed?: boolean;
focused?: boolean;
outlined?: boolean;
} & FocusProps & Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'onChange' | 'onFocus' | 'onBlur'> & Pick<InputHTMLAttributes_2<HTMLInputElement>, 'name' | 'value' | 'checked' | 'disabled' | 'readOnly' | 'onChange' | 'onFocus' | 'onBlur'>;
export const Switch: ForwardRefExoticComponent<SwitchProps & RefAttributes<HTMLInputElement>>;

export { SwitchProps }

// @public
export const TabItem: FunctionComponent<PropsType< {
Expand Down
62 changes: 6 additions & 56 deletions packages/sdds-serv/src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,12 @@
import type { InputHTMLAttributes } from 'react';
import { switchConfig, component, mergeConfig, FocusProps } from '@salutejs/plasma-new-hope/styled-components';
import { switchConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components';
import type { SwitchProps } from '@salutejs/plasma-core';

import { config } from './Switch.config';

const mergedConfig = mergeConfig(switchConfig, config);
const SwitchComponent = component(mergedConfig);

export type SwitchProps = {
/**
* Уникальный идентификатор контрола
*/
id?: string;
/**
* Метка-подпись к элементу
*/
label?: React.ReactNode;
/**
* Размер контрола.
*/
size?: string;
/**
* Вид контрола.
*/
view?: string;
/**
* Расположение подпись
*/
labelPosition?: 'before' | 'after';
/**
* Описание элемента
*/
description?: React.ReactNode;
/**
* Компонент неактивен
*/
disabled?: boolean;
/**
* Нажатие на компонент
* @deprecated
*/
pressed?: boolean;
/**
* Добавить рамку при фокусе
*/
focused?: boolean;
/**
* Добавить рамку при фокусе
* @deprecated
*/
outlined?: boolean;
} & FocusProps &
Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'onChange' | 'onFocus' | 'onBlur'> &
Pick<
InputHTMLAttributes<HTMLInputElement>,
'name' | 'value' | 'checked' | 'disabled' | 'readOnly' | 'onChange' | 'onFocus' | 'onBlur'
>;

/**
* Визуальный переключатель между двумя взаимоисключающими состояниями — вкл. и выкл.
*/
export const Switch = SwitchComponent;
export const Switch = SwitchComponent as React.ForwardRefExoticComponent<
SwitchProps & React.RefAttributes<HTMLInputElement>
>;
export type { SwitchProps };

0 comments on commit 6fd8091

Please sign in to comment.