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

plasma-*: Edit docs core and change docs Switch, Checkbox and Radiobox #1232

Merged
merged 2 commits into from
Jun 17, 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
23 changes: 6 additions & 17 deletions packages/caldera-online/api/caldera-online.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { dsplMBold } from '@salutejs/caldera-online-themes/tokens';
import { dsplS } from '@salutejs/caldera-online-themes/tokens';
import { dsplSBold } from '@salutejs/caldera-online-themes/tokens';
import { Filter } from '@salutejs/plasma-new-hope/types/engines/types';
import { FocusProps } from '@salutejs/plasma-new-hope/styled-components';
import type { ForwardRefExoticComponent } from 'react';
import { FunctionComponent } from 'react';
import { h1 } from '@salutejs/caldera-online-themes/tokens';
Expand All @@ -48,7 +47,6 @@ import { h5 } from '@salutejs/caldera-online-themes/tokens';
import { h5Bold } from '@salutejs/caldera-online-themes/tokens';
import { HTMLAttributes } from 'react';
import { InputHTMLAttributes } from '@salutejs/plasma-new-hope/types/types';
import type { InputHTMLAttributes as InputHTMLAttributes_2 } from 'react';
import { LinkCustomProps } from '@salutejs/plasma-new-hope/types/components/Link/Link';
import { mediaQuery } from '@salutejs/plasma-new-hope/styled-components';
import { modalClasses } from '@salutejs/plasma-new-hope/styled-components';
Expand All @@ -70,7 +68,7 @@ import { ShowToastArgs } from '@salutejs/plasma-new-hope/styled-components';
import { SpacingProps } from '@salutejs/plasma-new-hope/styled-components';
import { SSRProvider } from '@salutejs/plasma-new-hope/styled-components';
import { StyledComponent } from 'styled-components';
import { SwitchPropsVariations } from '@salutejs/plasma-new-hope/types/components/Switch/Switch.types';
import { SwitchProps as SwitchProps_2 } from '@salutejs/plasma-new-hope/styled-components';
import { textL } from '@salutejs/caldera-online-themes/tokens';
import { textLBold } from '@salutejs/caldera-online-themes/tokens';
import { textM } from '@salutejs/caldera-online-themes/tokens';
Expand Down Expand Up @@ -582,7 +580,7 @@ export type SpinnerProps = HTMLAttributes<HTMLDivElement> & {

export { SSRProvider }

// @public
// @public (undocumented)
export const Switch: FunctionComponent<PropsType< {
size: {
m: string;
Expand All @@ -600,21 +598,12 @@ true: string;
focused: {
true: string;
};
}> & Filter<InputHTMLAttributes_2<HTMLInputElement>, "size"> & SwitchPropsVariations & RefAttributes<HTMLInputElement>>;
}> & SwitchProps_2 & RefAttributes<HTMLInputElement>>;

// Warning: (ae-forgotten-export) The symbol "SwitchComponent" needs to be exported by the entry point index.d.ts
//
// @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 type SwitchProps = ComponentProps<typeof SwitchComponent>;

// @public (undocumented)
export const TextL: FunctionComponent<PropsType< {
Expand Down
58 changes: 3 additions & 55 deletions packages/caldera-online/src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,10 @@
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 { ComponentProps } from 'react';

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 type SwitchProps = ComponentProps<typeof SwitchComponent>;
23 changes: 6 additions & 17 deletions packages/plasma-asdk/api/plasma-asdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ import { ButtonHTMLAttributes } from 'react';
import { CheckboxProps as CheckboxProps_2 } from '@salutejs/plasma-new-hope/types/components/Checkbox/Checkbox.types';
import { ComponentProps } from 'react';
import { Filter } from '@salutejs/plasma-new-hope/types/engines/types';
import { FocusProps } from '@salutejs/plasma-new-hope/styled-components';
import { FunctionComponent } from 'react';
import { HTMLAttributes } from 'react';
import { InputHTMLAttributes } from '@salutejs/plasma-new-hope/types/types';
import type { InputHTMLAttributes as InputHTMLAttributes_2 } from 'react';
import { LinkCustomProps } from '@salutejs/plasma-new-hope/types/components/Link/Link';
import { PropsType } from '@salutejs/plasma-new-hope/types/engines/types';
import { RadioGroup } from '@salutejs/plasma-new-hope/styled-components';
Expand All @@ -28,7 +26,7 @@ import { SpacingProps } from '@salutejs/plasma-new-hope/styled-components';
import { SSRProvider } from '@salutejs/plasma-new-hope/styled-components';
import { StyledComponent } from 'styled-components';
import { SubtitleProps } from '@salutejs/plasma-new-hope/styled-components';
import { SwitchPropsVariations } from '@salutejs/plasma-new-hope/types/components/Switch/Switch.types';
import { SwitchProps as SwitchProps_2 } from '@salutejs/plasma-new-hope/styled-components';
import { TypographyOldProps } from '@salutejs/plasma-new-hope/types/components/Typography/Old/TypographyOld';

// @public (undocumented)
Expand Down Expand Up @@ -437,7 +435,7 @@ m: string;
};
}> & SubtitleProps & RefAttributes<HTMLDivElement>>;

// @public
// @public (undocumented)
export const Switch: FunctionComponent<PropsType< {
size: {
m: string;
Expand All @@ -455,21 +453,12 @@ true: string;
focused: {
true: string;
};
}> & Filter<InputHTMLAttributes_2<HTMLInputElement>, "size"> & SwitchPropsVariations & RefAttributes<HTMLInputElement>>;
}> & SwitchProps_2 & RefAttributes<HTMLInputElement>>;

// Warning: (ae-forgotten-export) The symbol "SwitchComponent" needs to be exported by the entry point index.d.ts
//
// @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 type SwitchProps = ComponentProps<typeof SwitchComponent>;

// @public (undocumented)
export const TextL: FunctionComponent<PropsType< {
Expand Down
58 changes: 3 additions & 55 deletions packages/plasma-asdk/src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,10 @@
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 { ComponentProps } from 'react';

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 type SwitchProps = ComponentProps<typeof SwitchComponent>;
26 changes: 23 additions & 3 deletions packages/plasma-b2c/api/plasma-b2c.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ import { StyledCard } from '@salutejs/plasma-hope';
import { StyledComponent } from 'styled-components';
import { StyledPreviewGallery } from '@salutejs/plasma-hope';
import { SubtitleProps } from '@salutejs/plasma-new-hope/styled-components';
import type { SwitchProps } from '@salutejs/plasma-core';
import { SwitchProps as SwitchProps_2 } from '@salutejs/plasma-new-hope/styled-components';
import { syntheticFocus } from '@salutejs/plasma-core';
import { TabItemProps } from '@salutejs/plasma-new-hope/styled-components';
import { TabItemRefs } from '@salutejs/plasma-new-hope/styled-components';
Expand Down Expand Up @@ -1907,9 +1907,29 @@ m: string;
}> & SubtitleProps & RefAttributes<HTMLDivElement>>;

// @public (undocumented)
export const Switch: ForwardRefExoticComponent<SwitchProps & RefAttributes<HTMLInputElement>>;
export const Switch: FunctionComponent<PropsType< {
size: {
m: string;
};
view: {
default: string;
};
labelPosition: {
before: string;
after: string;
};
disabled: {
true: string;
};
focused: {
true: string;
};
}> & SwitchProps_2 & RefAttributes<HTMLInputElement>>;

export { SwitchProps }
// Warning: (ae-forgotten-export) The symbol "SwitchComponent" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type SwitchProps = ComponentProps<typeof SwitchComponent>;

export { syntheticFocus }

Expand Down
8 changes: 3 additions & 5 deletions packages/plasma-b2c/src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { switchConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components';
import type { SwitchProps } from '@salutejs/plasma-core';
import { ComponentProps } from 'react';

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

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

export const Switch = SwitchComponent as React.ForwardRefExoticComponent<
SwitchProps & React.RefAttributes<HTMLInputElement>
>;
export type { SwitchProps };
export const Switch = SwitchComponent;
export type SwitchProps = ComponentProps<typeof SwitchComponent>;
9 changes: 5 additions & 4 deletions packages/plasma-new-hope/src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const switchRoot = (Root: RootProps<HTMLInputElement, SwitchProps>) =>
size,
view,
focused,
outlined,
disabled,
labelPosition,

Expand All @@ -42,20 +43,20 @@ export const switchRoot = (Root: RootProps<HTMLInputElement, SwitchProps>) =>
// singleLine,

checked,
pressed,
defaultChecked,

...rest
} = props;

const exactChecked = Boolean(checked !== undefined ? checked : defaultChecked);
// const singleLineClass = singleLine ? 'single-line' : '';
const exactChecked = Boolean((checked ?? pressed) !== undefined ? checked ?? pressed : defaultChecked);

return (
<Root
view={view}
size={size}
disabled={disabled}
focused={focused}
focused={focused ?? outlined}
labelPosition={labelPosition}
id={id}
style={style}
Expand All @@ -67,7 +68,7 @@ export const switchRoot = (Root: RootProps<HTMLInputElement, SwitchProps>) =>
role="switch"
aria-checked={exactChecked}
type="checkbox"
checked={checked}
checked={checked ?? pressed}
defaultChecked={defaultChecked}
disabled={disabled}
/>
Expand Down
21 changes: 17 additions & 4 deletions packages/plasma-new-hope/src/components/Switch/Switch.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { InputHTMLAttributes } from 'react';

import { Filter } from '../../engines/types';
import type { InputHTMLAttributes } from '../../types';

export interface SwitchPropsPropsBase {
/**
iljs marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -23,7 +21,22 @@ export interface SwitchPropsVariations extends SwitchPropsPropsBase {
*/
labelPosition?: 'before' | 'after';

/**
* Добавить рамку при фокусе
*/
focused?: boolean;

/**
* Нажатие на компонент
* @deprecated
*/
pressed?: boolean;

/**
* Добавить рамку при фокусе
* @deprecated
*/
outlined?: boolean;
}

export type SwitchProps = Filter<InputHTMLAttributes<HTMLInputElement>, 'size'> & SwitchPropsVariations;
export interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'>, SwitchPropsVariations {}
1 change: 1 addition & 0 deletions packages/plasma-new-hope/src/components/Switch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { labelPosition_Before } from './_label-position/before';

export { switchRoot, switchConfig } from './Switch';
export { tokens as switchTokens } from './Switch.tokens';
export type { SwitchProps } from './Switch.types';

// TODO: Think how we could name such things
export { labelPosition_Before as Switch_LabelPosition_Before };
Expand Down
Loading
Loading