@true-engineering/true-react-common-ui-kit 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,6 +10,23 @@
10
10
 
11
11
  # Release Notes
12
12
 
13
+ ## v2.1.0
14
+
15
+ ### Changes
16
+
17
+ - **DatePicker**: добавлена пропса `strictParsing`
18
+ - Сохранение JSDoc в `*.d.ts` файлах
19
+
20
+ ### Breaking changes
21
+
22
+ - **Switch**: удалена пропса `label`. Вместо неё нужно использовать `children`
23
+
24
+ ## v2.0.1
25
+
26
+ ### Fixed
27
+
28
+ - **Select**: исправлено выделение активной опции в списке
29
+
13
30
  ## v0.4.0
14
31
 
15
32
  **PhoneInput**. Теперь компонент принимает в качестве аргумента объект с информацией о номере телефона IPhoneValue, а не строку.
@@ -9,17 +9,52 @@ export declare type IButtonView = (typeof BUTTON_VIEWS)[number];
9
9
  export interface IButtonProps extends ICommonProps {
10
10
  tweakStyles?: ButtonStyles;
11
11
  children?: ReactNode;
12
+ /**
13
+ * @default `button`
14
+ */
12
15
  type?: ButtonHTMLAttributes<unknown>['type'];
16
+ /**
17
+ * @default `l`
18
+ */
13
19
  size?: IButtonSize;
20
+ /**
21
+ * @default `primary`
22
+ */
14
23
  view?: IButtonView;
24
+ /**
25
+ * @default false
26
+ */
15
27
  shouldSkipTabNavigation?: boolean;
28
+ /**
29
+ * @default false
30
+ */
16
31
  isDisabled?: boolean;
32
+ /**
33
+ * @default false
34
+ */
17
35
  isFullWidth?: boolean;
36
+ /**
37
+ * Нужно ли убирать скругление у кнопки слева
38
+ * @default false
39
+ */
18
40
  isInline?: boolean;
41
+ /**
42
+ * Нужно ли показать лоадер и заблокировать кнопку
43
+ * @default false
44
+ */
19
45
  isLoading?: boolean;
46
+ /**
47
+ * @default false
48
+ */
20
49
  isActive?: boolean;
21
50
  icon?: IIconType | ReactElement;
51
+ /**
52
+ * @default `left`
53
+ */
22
54
  iconPosition?: 'left' | 'right';
55
+ /**
56
+ * @default `dots`
57
+ */
23
58
  preloaderType?: IThemedPreloaderProps['type'];
24
59
  testId?: string;
25
60
  onClick?(event: MouseEvent<HTMLButtonElement>): void | Promise<void>;
@@ -1,17 +1,30 @@
1
- import { PropsWithChildren } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { ICommonProps } from '../../types';
3
3
  import { CheckboxStyles } from './Checkbox.styles';
4
4
  export interface ICheckboxProps<V> extends ICommonProps {
5
5
  tweakStyles?: CheckboxStyles;
6
+ children?: ReactNode;
6
7
  isChecked?: boolean;
7
8
  isSemiChecked?: boolean;
8
9
  isDisabled?: boolean;
9
10
  isReadonly?: boolean;
10
11
  isInvalid?: boolean;
11
12
  value: V;
13
+ /**
14
+ * @default 18
15
+ */
12
16
  size?: number;
17
+ /**
18
+ * @default `center`
19
+ */
13
20
  alignItems?: 'top' | 'center';
21
+ /**
22
+ * @default `size - 4px`
23
+ */
14
24
  textMargin?: number;
25
+ /**
26
+ * @default `right`
27
+ */
15
28
  labelPosition?: 'right' | 'left';
16
29
  testId?: string;
17
30
  onSelect(value: {
@@ -19,4 +32,4 @@ export interface ICheckboxProps<V> extends ICommonProps {
19
32
  isSelected: boolean;
20
33
  }): void;
21
34
  }
22
- export declare function Checkbox<V>({ children, isDisabled, isReadonly, isChecked, value, size, alignItems, textMargin, data, testId, isSemiChecked, labelPosition, tweakStyles, onSelect, }: PropsWithChildren<ICheckboxProps<V>>): JSX.Element;
35
+ export declare function Checkbox<V>({ children, isDisabled, isReadonly, isChecked, value, size, alignItems, textMargin, data, testId, isSemiChecked, labelPosition, tweakStyles, onSelect, }: ICheckboxProps<V>): JSX.Element;
@@ -7,12 +7,11 @@ export interface IDatePickerProps extends IDatePickerBaseProps {
7
7
  selectedDate?: Date | null;
8
8
  locale: Locale;
9
9
  months?: string[];
10
- minDate?: Date | null;
11
- maxDate?: Date | null;
12
- endDate?: Date | null;
13
- startDate?: Date | null;
14
10
  topPosition?: number;
15
11
  leftPosition?: number;
12
+ /**
13
+ * @default `dd.MM.yyyy`
14
+ */
16
15
  dateFormat?: string;
17
16
  calendarStartDay?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
18
17
  isRange?: boolean;
@@ -1,4 +1,4 @@
1
1
  import { ReactDatePickerProps } from 'react-datepicker';
2
2
  import { IDateInputProps } from '../DateInput';
3
3
  export declare type IRange = [Date | null, Date | null] | null;
4
- export declare type IDatePickerBaseProps = Pick<ReactDatePickerProps, 'allowSameDay' | 'disabledKeyboardNavigation' | 'monthsShown' | 'popperModifiers' | 'popperPlacement' | 'filterDate' | 'dayClassName' | 'calendarContainer' | 'onCalendarOpen' | 'onCalendarClose' | 'onYearChange' | 'onMonthChange' | 'focusSelectedMonth' | 'shouldCloseOnSelect' | 'showPreviousMonths' | 'todayButton' | 'renderCustomHeader' | 'customInputRef' | 'preventOpenOnFocus'> & Omit<IDateInputProps, 'date' | 'startDate' | 'endDate' | 'isRange' | 'isActive' | 'iconType' | 'maxLength' | 'onChange' | 'onClick' | 'tweakStyles'>;
4
+ export declare type IDatePickerBaseProps = Pick<ReactDatePickerProps, 'startDate' | 'endDate' | 'minDate' | 'maxDate' | 'allowSameDay' | 'disabledKeyboardNavigation' | 'monthsShown' | 'popperModifiers' | 'popperPlacement' | 'filterDate' | 'dayClassName' | 'calendarContainer' | 'onCalendarOpen' | 'onCalendarClose' | 'onYearChange' | 'onMonthChange' | 'focusSelectedMonth' | 'shouldCloseOnSelect' | 'showPreviousMonths' | 'todayButton' | 'renderCustomHeader' | 'customInputRef' | 'preventOpenOnFocus' | 'strictParsing'> & Omit<IDateInputProps, 'date' | 'startDate' | 'endDate' | 'isRange' | 'isActive' | 'iconType' | 'maxLength' | 'onChange' | 'onClick' | 'tweakStyles'>;
@@ -7,8 +7,17 @@ export interface IFilterSelectProps<Value> extends ICommonProps {
7
7
  tweakStyles?: FilterSelectStyles;
8
8
  value?: Value;
9
9
  onChange: (value?: Value) => void;
10
+ /**
11
+ * @default false
12
+ */
10
13
  isSearchEnabled?: boolean;
14
+ /**
15
+ * @default false
16
+ */
11
17
  isGroupingEnabled?: boolean;
18
+ /**
19
+ * @default `220px`
20
+ */
12
21
  width?: string | number;
13
22
  localeKey?: IFilterLocaleKey;
14
23
  locale?: Partial<ISelectLocale>;
@@ -18,6 +27,9 @@ export interface IFilterSelectProps<Value> extends ICommonProps {
18
27
  getValueString?: (value: Value) => string;
19
28
  getValueView?: (value: Value) => ReactNode;
20
29
  getValueId?: (value: Value) => string;
30
+ /**
31
+ * @default true
32
+ */
21
33
  hasClearButton?: boolean;
22
34
  testId?: string;
23
35
  }
@@ -10,8 +10,14 @@ export interface IInputProps extends ICommonProps, IReactInputMaskProps {
10
10
  value?: string;
11
11
  label?: string;
12
12
  placeholder?: string;
13
+ /**
14
+ * @default `text`
15
+ */
13
16
  type?: 'text' | 'password' | 'email' | 'number';
14
17
  isDisabled?: boolean;
18
+ /**
19
+ * @default true
20
+ */
15
21
  hasFloatingLabel?: boolean;
16
22
  isReadonly?: boolean;
17
23
  isInvalid?: boolean;
@@ -19,12 +25,23 @@ export interface IInputProps extends ICommonProps, IReactInputMaskProps {
19
25
  isClearable?: boolean;
20
26
  infoMessage?: string;
21
27
  errorMessage?: string;
28
+ /**
29
+ * @default `bottom`
30
+ */
22
31
  errorPosition?: 'top' | 'bottom';
23
32
  inlineStyle?: 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'left' | 'right' | 'middle';
24
33
  border?: 'top' | 'bottom' | 'left' | 'right';
25
34
  isRequired?: boolean;
26
35
  isLoading?: boolean;
36
+ /**
37
+ * Должна ли ширина input'а подстраиваться под ширину контента
38
+ * @default false
39
+ */
27
40
  isAutoSizeable?: boolean;
41
+ /**
42
+ * Ширина input'а по умолчанию. Используется только вместе с `isAutoSizeable` равному `true`
43
+ * @default 6
44
+ */
28
45
  defaultSize?: number;
29
46
  iconType?: IIconType | ReactElement;
30
47
  units?: string;
@@ -6,6 +6,9 @@ export interface IMoreMenuProps extends ICommonProps {
6
6
  tweakStyles?: MoreMenuStyles;
7
7
  items: IListItem[];
8
8
  isDisabled?: boolean;
9
+ /**
10
+ * @default true
11
+ */
9
12
  hasDefaultStateBackground?: boolean;
10
13
  testId?: string;
11
14
  onMenuOpen?(): void;
@@ -5,9 +5,15 @@ export declare type NotificationType = 'error' | 'info' | 'warning' | 'ok' | 'no
5
5
  export interface INotificationProps extends ICommonProps {
6
6
  tweakStyles?: NotificationStyles;
7
7
  type: NotificationType;
8
+ /**
9
+ * @default true
10
+ */
8
11
  isFullWidth?: boolean;
9
12
  text?: string;
10
13
  title?: string;
14
+ /**
15
+ * @default `s`
16
+ */
11
17
  size?: 's' | 'm' | 'l';
12
18
  testId?: string;
13
19
  children?: ReactNode;
@@ -1,13 +1,14 @@
1
- import { PropsWithChildren } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { ICommonProps } from '../../types';
3
3
  import { RadioButtonStyles } from './RadioButton.styles';
4
4
  export interface IRadioButtonProps<Value extends string> extends ICommonProps {
5
5
  tweakStyles?: RadioButtonStyles;
6
+ children?: ReactNode;
6
7
  value: Value;
7
8
  groupName: string;
8
9
  isChecked?: boolean;
9
10
  isDisabled?: boolean;
10
11
  isInvalid?: boolean;
11
- onChange: (value: Value) => void | Promise<void>;
12
+ onChange(value: Value): void | Promise<void>;
12
13
  }
13
- export declare function RadioButton<Value extends string>({ children, value, groupName, isChecked, isDisabled, isInvalid, onChange, data, tweakStyles, }: PropsWithChildren<IRadioButtonProps<Value>>): JSX.Element;
14
+ export declare function RadioButton<Value extends string>({ children, value, groupName, isChecked, isDisabled, isInvalid, data, tweakStyles, onChange, }: IRadioButtonProps<Value>): JSX.Element;
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { ICommonProps } from '../../types';
3
3
  import { SwitchStyles } from './Switch.styles';
4
4
  export interface ISwitchState<V = string> {
@@ -7,14 +7,20 @@ export interface ISwitchState<V = string> {
7
7
  }
8
8
  export interface ISwitchProps<V extends string> extends ICommonProps {
9
9
  tweakStyles?: SwitchStyles;
10
+ children?: ReactNode;
10
11
  value: V;
11
12
  isChecked: boolean;
12
13
  isDisabled?: boolean;
13
14
  isInvalid?: boolean;
14
- label?: string;
15
+ /**
16
+ * @default `right`
17
+ */
15
18
  labelPosition?: 'left' | 'right';
19
+ /**
20
+ * @default `primary`
21
+ */
16
22
  color?: 'primary' | 'secondary';
17
- onChange: (state: ISwitchState<V>) => void;
18
23
  testId?: string;
24
+ onChange(state: ISwitchState<V>): void;
19
25
  }
20
- export declare const Switch: <V extends string>({ isDisabled, isChecked, isInvalid, onChange, value, label, children, labelPosition, color, data, tweakStyles, testId, }: PropsWithChildren<ISwitchProps<V>>) => JSX.Element;
26
+ export declare const Switch: <V extends string>({ isDisabled, isChecked, isInvalid, value, children, labelPosition, color, data, tweakStyles, testId, onChange, }: ISwitchProps<V>) => JSX.Element;
@@ -5,6 +5,9 @@ declare const svgTypes: readonly ["default", "logo"];
5
5
  export declare type IPreloaderSvgType = (typeof svgTypes)[number];
6
6
  export interface IThemedPreloaderProps extends ICommonProps {
7
7
  tweakStyles?: ThemedPreloaderStyles;
8
+ /**
9
+ * @default `default`
10
+ */
8
11
  type?: 'dots' | IPreloaderSvgType;
9
12
  useCurrentColor?: boolean;
10
13
  }
@@ -4,12 +4,25 @@ import { ToasterStyles } from './Toaster.styles';
4
4
  export declare type ToasterType = 'error' | 'info' | 'warning' | 'ok' | 'not-ok';
5
5
  export interface IToasterProps extends ICommonProps {
6
6
  tweakStyles?: ToasterStyles;
7
+ /**
8
+ * @default `error`
9
+ */
7
10
  type?: ToasterType;
8
11
  title?: string;
9
12
  text?: string;
10
13
  children?: ReactNode;
14
+ /**
15
+ * Время автоматического закрытия тостера в миллисекундах
16
+ * @default 7000
17
+ */
11
18
  timeout?: number;
19
+ /**
20
+ * @default false
21
+ */
12
22
  hasCloseButton?: boolean;
23
+ /**
24
+ * @default false
25
+ */
13
26
  shouldCloseOnClick?: boolean;
14
27
  onClose?(): void;
15
28
  onTimeEnd?(): void;
@@ -4,7 +4,13 @@ import { TooltipStyles } from './Tooltip.styles';
4
4
  export interface ITooltipProps extends ICommonProps {
5
5
  tweakStyles?: TooltipStyles;
6
6
  text: ReactNode;
7
+ /**
8
+ * @default `tooltip`
9
+ */
7
10
  view?: 'tooltip' | 'hint';
11
+ /**
12
+ * @default `info`
13
+ */
8
14
  type?: 'info' | 'error';
9
15
  }
10
16
  export declare const Tooltip: FC<ITooltipProps>;
@@ -15,8 +15,17 @@ export declare const setCaretPosition: (elem: HTMLInputElement, caretPos: number
15
15
  export declare const isSpaceChar: (char?: string) => boolean;
16
16
  export declare const isInt: (n: number) => boolean;
17
17
  export declare const getNumberLength: (n?: number) => number;
18
+ /**
19
+ * Проверяет, что `val` не `null`, не `undefined` и не пустая строка
20
+ */
18
21
  export declare const isNotEmpty: <T>(val: T | null | undefined) => val is T;
22
+ /**
23
+ * Проверяет, что переданное значение `null` или `undefined`
24
+ */
19
25
  export declare const isEmpty: <T>(val: T | null | undefined) => val is null | undefined;
26
+ /**
27
+ * Проверяет, что передана непустая строка
28
+ */
20
29
  export declare const isStringNotEmpty: <T extends string>(value: T | null | undefined) => value is T;
21
30
  export declare const trimStringToMaxLength: (val: string, maxLength: number) => string;
22
31
  export declare const addDataAttributes: (data?: IDataAttributes) => IDataAttributes;
@@ -26,4 +35,9 @@ export declare const addDataTestId: (testId: string | undefined, postfix?: strin
26
35
  export declare const getTestId: (testId: string | undefined, postfix?: string | number) => string | undefined;
27
36
  export declare const getSelectKeyHandler: (cb: (e: KeyboardEvent) => void) => (e: KeyboardEvent) => void;
28
37
  export declare const addClickHandler: (cb?: ((e: MouseEvent | KeyboardEvent) => void) | undefined, hasAction?: boolean) => HTMLAttributes<unknown>;
38
+ /**
39
+ * Позволяет создать текстовый фильтр для набора items
40
+ * @param getter - функция возвращающая набор строковых значений из каждого item,
41
+ * по которым должен осуществляться поиск
42
+ */
29
43
  export declare const createFilter: <T>(getter: (item: T) => Array<string | undefined>, compareFn?: ((item: string, query: string) => boolean) | undefined) => (items: T[], query: string) => T[];
@@ -9292,7 +9292,7 @@ var PopperContainer = function(param) {
9292
9292
  });
9293
9293
  };
9294
9294
  var DatePicker = /* @__PURE__ */ forwardRef(function(_param, ref) {
9295
- var data = _param.data, _param_selectedDate = _param.selectedDate, selectedDate = _param_selectedDate === void 0 ? null : _param_selectedDate, minDate = _param.minDate, maxDate = _param.maxDate, _param_endDate = _param.endDate, endDate = _param_endDate === void 0 ? null : _param_endDate, _param_startDate = _param.startDate, startDate = _param_startDate === void 0 ? null : _param_startDate, locale2 = _param.locale, months = _param.months, _param_topPosition = _param.topPosition, topPosition = _param_topPosition === void 0 ? 0 : _param_topPosition, _param_leftPosition = _param.leftPosition, leftPosition = _param_leftPosition === void 0 ? 0 : _param_leftPosition, _param_calendarStartDay = _param.calendarStartDay, calendarStartDay = _param_calendarStartDay === void 0 ? 1 : _param_calendarStartDay, _param_dateFormat = _param.dateFormat, dateFormat = _param_dateFormat === void 0 ? DEFAULT_DATE_FORMAT$2 : _param_dateFormat, monthsShown = _param.monthsShown, placeholder = _param.placeholder, isRange = _param.isRange, isInline = _param.isInline, isDisabled = _param.isDisabled, isClearable = _param.isClearable, focusSelectedMonth = _param.focusSelectedMonth, disabledKeyboardNavigation = _param.disabledKeyboardNavigation, shouldRenderPopperInBody = _param.shouldRenderPopperInBody, _param_allowSameDay = _param.allowSameDay, allowSameDay = _param_allowSameDay === void 0 ? false : _param_allowSameDay, shouldCloseOnSelect = _param.shouldCloseOnSelect, showPreviousMonths = _param.showPreviousMonths, preventOpenOnFocus = _param.preventOpenOnFocus, popperModifiers = _param.popperModifiers, popperPlacement = _param.popperPlacement, todayButton = _param.todayButton, calendarContainer = _param.calendarContainer, dayClassName = _param.dayClassName, tmp = _param.customInput, CustomInput = tmp === void 0 ? DateInput : tmp, customInputRef = _param.customInputRef, renderCustomHeader = _param.renderCustomHeader, filterDate = _param.filterDate, onYearChange = _param.onYearChange, onMonthChange = _param.onMonthChange, onCalendarOpen = _param.onCalendarOpen, onCalendarClose = _param.onCalendarClose, onChangeDate = _param.onChangeDate, onChangeRange = _param.onChangeRange, onBlur = _param.onBlur, onFocus = _param.onFocus, onKeyDown = _param.onKeyDown, tweakStyles = _param.tweakStyles, inputProps = _object_without_properties$4(_param, [
9295
+ var data = _param.data, _param_selectedDate = _param.selectedDate, selectedDate = _param_selectedDate === void 0 ? null : _param_selectedDate, minDate = _param.minDate, maxDate = _param.maxDate, _param_endDate = _param.endDate, endDate = _param_endDate === void 0 ? null : _param_endDate, _param_startDate = _param.startDate, startDate = _param_startDate === void 0 ? null : _param_startDate, locale2 = _param.locale, months = _param.months, _param_topPosition = _param.topPosition, topPosition = _param_topPosition === void 0 ? 0 : _param_topPosition, _param_leftPosition = _param.leftPosition, leftPosition = _param_leftPosition === void 0 ? 0 : _param_leftPosition, _param_calendarStartDay = _param.calendarStartDay, calendarStartDay = _param_calendarStartDay === void 0 ? 1 : _param_calendarStartDay, _param_dateFormat = _param.dateFormat, dateFormat = _param_dateFormat === void 0 ? DEFAULT_DATE_FORMAT$2 : _param_dateFormat, monthsShown = _param.monthsShown, placeholder = _param.placeholder, isRange = _param.isRange, isInline = _param.isInline, isDisabled = _param.isDisabled, isClearable = _param.isClearable, strictParsing = _param.strictParsing, focusSelectedMonth = _param.focusSelectedMonth, disabledKeyboardNavigation = _param.disabledKeyboardNavigation, shouldRenderPopperInBody = _param.shouldRenderPopperInBody, _param_allowSameDay = _param.allowSameDay, allowSameDay = _param_allowSameDay === void 0 ? false : _param_allowSameDay, shouldCloseOnSelect = _param.shouldCloseOnSelect, showPreviousMonths = _param.showPreviousMonths, preventOpenOnFocus = _param.preventOpenOnFocus, popperModifiers = _param.popperModifiers, popperPlacement = _param.popperPlacement, todayButton = _param.todayButton, calendarContainer = _param.calendarContainer, dayClassName = _param.dayClassName, tmp = _param.customInput, CustomInput = tmp === void 0 ? DateInput : tmp, customInputRef = _param.customInputRef, renderCustomHeader = _param.renderCustomHeader, filterDate = _param.filterDate, onYearChange = _param.onYearChange, onMonthChange = _param.onMonthChange, onCalendarOpen = _param.onCalendarOpen, onCalendarClose = _param.onCalendarClose, onChangeDate = _param.onChangeDate, onChangeRange = _param.onChangeRange, onBlur = _param.onBlur, onFocus = _param.onFocus, onKeyDown = _param.onKeyDown, tweakStyles = _param.tweakStyles, inputProps = _object_without_properties$4(_param, [
9296
9296
  "data",
9297
9297
  "selectedDate",
9298
9298
  "minDate",
@@ -9311,6 +9311,7 @@ var DatePicker = /* @__PURE__ */ forwardRef(function(_param, ref) {
9311
9311
  "isInline",
9312
9312
  "isDisabled",
9313
9313
  "isClearable",
9314
+ "strictParsing",
9314
9315
  "focusSelectedMonth",
9315
9316
  "disabledKeyboardNavigation",
9316
9317
  "shouldRenderPopperInBody",
@@ -9484,6 +9485,7 @@ var DatePicker = /* @__PURE__ */ forwardRef(function(_param, ref) {
9484
9485
  popperModifiers,
9485
9486
  popperPlacement,
9486
9487
  selectsRange: isRange,
9488
+ strictParsing,
9487
9489
  preventOpenOnFocus,
9488
9490
  shouldCloseOnSelect,
9489
9491
  customInputRef,
@@ -26722,7 +26724,7 @@ function _object_spread_props$6(target, source) {
26722
26724
  return target;
26723
26725
  }
26724
26726
  function RadioButton(param) {
26725
- var children = param.children, value = param.value, groupName = param.groupName, isChecked = param.isChecked, isDisabled = param.isDisabled, isInvalid = param.isInvalid, onChange = param.onChange, data = param.data, tweakStyles = param.tweakStyles;
26727
+ var children = param.children, value = param.value, groupName = param.groupName, isChecked = param.isChecked, isDisabled = param.isDisabled, isInvalid = param.isInvalid, data = param.data, tweakStyles = param.tweakStyles, onChange = param.onChange;
26726
26728
  var classes = useTheme("RadioButton", styles$6, tweakStyles).classes;
26727
26729
  var _obj;
26728
26730
  return /* @__PURE__ */ jsxs("label", _object_spread_props$6(_object_spread$6({
@@ -26862,10 +26864,8 @@ function _object_spread_props$5(target, source) {
26862
26864
  return target;
26863
26865
  }
26864
26866
  var Switch = function(param) {
26865
- var isDisabled = param.isDisabled, isChecked = param.isChecked, isInvalid = param.isInvalid, onChange = param.onChange, value = param.value, label = param.label, children = param.children, _param_labelPosition = param.labelPosition, labelPosition = _param_labelPosition === void 0 ? "right" : _param_labelPosition, _param_color = param.color, color = _param_color === void 0 ? "primary" : _param_color, data = param.data, tweakStyles = param.tweakStyles, testId = param.testId;
26867
+ var isDisabled = param.isDisabled, isChecked = param.isChecked, isInvalid = param.isInvalid, value = param.value, children = param.children, _param_labelPosition = param.labelPosition, labelPosition = _param_labelPosition === void 0 ? "right" : _param_labelPosition, _param_color = param.color, color = _param_color === void 0 ? "primary" : _param_color, data = param.data, tweakStyles = param.tweakStyles, testId = param.testId, onChange = param.onChange;
26866
26868
  var classes = useTheme("Switch", styles$5, tweakStyles).classes;
26867
- var hasLabel = isNotEmpty(label);
26868
- var hasChild = isNotEmpty(children);
26869
26869
  var handleChange = function() {
26870
26870
  return onChange({
26871
26871
  name: value,
@@ -26875,24 +26875,22 @@ var Switch = function(param) {
26875
26875
  var _obj;
26876
26876
  return /* @__PURE__ */ jsxs("label", _object_spread_props$5(_object_spread$5({
26877
26877
  className: clsx(classes.root, classes[color], (_obj = {}, _define_property$5(_obj, classes.disabled, isDisabled), _define_property$5(_obj, classes.checked, isChecked), _define_property$5(_obj, classes.invalid, isInvalid), _obj))
26878
- }, addDataAttributes(data)), {
26879
- "data-testid": testId,
26878
+ }, addDataTestId(testId), addDataAttributes(data)), {
26880
26879
  children: [
26881
26880
  /* @__PURE__ */ jsx("span", {
26882
26881
  className: classes.switch,
26883
- children: /* @__PURE__ */ jsx("input", {
26882
+ children: /* @__PURE__ */ jsx("input", _object_spread$5({
26884
26883
  type: "checkbox",
26885
26884
  name: value,
26886
26885
  className: classes.input,
26887
26886
  onChange: isDisabled ? void 0 : handleChange,
26888
26887
  checked: isChecked,
26889
- disabled: isDisabled,
26890
- "data-testid": testId !== void 0 ? "".concat(testId, "-input") : void 0
26891
- })
26888
+ disabled: isDisabled
26889
+ }, addDataTestId(testId, "input")))
26892
26890
  }),
26893
- (hasLabel || hasChild) && /* @__PURE__ */ jsx("span", {
26891
+ isNotEmpty(children) && /* @__PURE__ */ jsx("span", {
26894
26892
  className: clsx(classes.label, classes[labelPosition === "left" ? "labelLeft" : "labelRight"]),
26895
- children: hasLabel ? label : children
26893
+ children
26896
26894
  })
26897
26895
  ]
26898
26896
  }));