@snack-uikit/fields 0.23.3 → 0.23.5-preview-b0cb52bd.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/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.23.4 (2024-07-29)
7
+
8
+ ### Only dependencies have been changed
9
+ * [@snack-uikit/list@0.14.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/list/CHANGELOG.md)
10
+
11
+
12
+
13
+
14
+
6
15
  ## 0.23.3 (2024-07-19)
7
16
 
8
17
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -317,7 +317,7 @@ FieldStepper в основном предназначен для работы с
317
317
  | showCopyButton | `boolean` | - | Отображение кнопки копирования |
318
318
  | showClearButton | `boolean` | true | Отображение кнопки Очистки поля |
319
319
  | locale | `Locale` | new Intl.Locale('ru-RU') | Текущая локаль календаря |
320
- | buildCellProps | `(date: Date, viewMode: ViewMode) => { isDisabled?: boolean; isHoliday?: boolean };` | - | Колбек установки свойств ячеек календаря. Вызывается на построение каждой ячейки. Принимает два параметра: <br> `Date` - дата ячейки <br> `ViewMode`: <br> - `month` отображение месяца, каждая ячейка - 1 день <br> - `year` отображение года, каждая ячейка - 1 месяц <br> - `decade` отображение декады, каждая ячейка - 1 год <br><br> Колбек должен возвращать объект с полями, отвечающими за отключение и подкраску ячейки. |
320
+ | buildCellProps | `(date: Date, viewMode: ViewMode) => { isDisabled?: boolean; isHoliday?: boolean } ;` | - | Колбек установки свойств ячеек календаря. Вызывается на построение каждой ячейки. Принимает два параметра: <br> `Date` - дата ячейки <br> `ViewMode`: <br> - `month` отображение месяца, каждая ячейка - 1 день <br> - `year` отображение года, каждая ячейка - 1 месяц <br> - `decade` отображение декады, каждая ячейка - 1 год <br><br> Колбек должен возвращать объект с полями, отвечающими за отключение и подкраску ячейки. |
321
321
  | disabled | `boolean` | - | Является ли поле деактивированным |
322
322
  | readonly | `boolean` | - | Является ли поле доступным только для чтения |
323
323
  | id | `string` | - | Значение html-атрибута id |
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CalendarProps } from '@snack-uikit/calendar';
3
2
  import { InputPrivateProps } from '@snack-uikit/input-private';
4
3
  import { WithSupportProps } from '@snack-uikit/utils';
@@ -24,22 +23,22 @@ type FieldDateOwnProps = {
24
23
  } & Pick<CalendarProps, 'buildCellProps'>;
25
24
  export type FieldDateProps = WithSupportProps<FieldDateOwnProps & InputProps & WrapperProps>;
26
25
  export declare const FieldDate: import("react").ForwardRefExoticComponent<{
27
- 'data-test-id'?: string | undefined;
26
+ 'data-test-id'?: string;
28
27
  } & import("react").AriaAttributes & {
29
28
  /** Открыт date-picker */
30
- open?: boolean | undefined;
29
+ open?: boolean;
31
30
  /** Колбек открытия пикера */
32
31
  onOpenChange?(value: boolean): void;
33
32
  /** Колбек смены значения */
34
33
  onChange?(value: string): void;
35
34
  /** Отображение кнопки копирования */
36
- showCopyButton?: boolean | undefined;
35
+ showCopyButton?: boolean;
37
36
  /**
38
37
  * Отображение кнопки Очистки поля
39
38
  * @default true
40
39
  */
41
- showClearButton?: boolean | undefined;
40
+ showClearButton?: boolean;
42
41
  /** Текущая локаль календаря */
43
- locale?: Intl.Locale | undefined;
42
+ locale?: Intl.Locale;
44
43
  } & Pick<CalendarProps, "buildCellProps"> & InputProps & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
45
44
  export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { FieldDecoratorProps } from './FieldDecorator';
3
2
  export declare function extractFieldDecoratorProps<T extends Partial<FieldDecoratorProps>>({ error, required, readonly, label, labelTooltip, labelTooltipPlacement, labelFor, caption, hint, disabled, showHintIcon, size, validationState, className, }: T): {
4
3
  error: string | undefined;
@@ -20,6 +20,6 @@ type FieldSecureOwnProps = {
20
20
  };
21
21
  export type FieldSecureProps = WithSupportProps<FieldSecureOwnProps & InputProps & WrapperProps>;
22
22
  export declare const FieldSecure: import("react").ForwardRefExoticComponent<{
23
- 'data-test-id'?: string | undefined;
23
+ 'data-test-id'?: string;
24
24
  } & import("react").AriaAttributes & FieldSecureOwnProps & Pick<Partial<InputPrivateProps>, "onChange" | "value"> & Pick<InputPrivateProps, "disabled" | "readonly" | "id" | "name" | "onFocus" | "onBlur" | "placeholder" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
25
25
  export {};
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { FieldSelectProps } from './types';
3
2
  export declare const FieldSelect: import("react").ForwardRefExoticComponent<FieldSelectProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,27 +1,26 @@
1
- /// <reference types="react" />
2
1
  import { SelectedOptionFormatter } from './types';
3
2
  export declare const FieldSelectMultiple: import("react").ForwardRefExoticComponent<import("./types").InputProps & import("./types").WrapperProps & {
4
3
  options: import("./types").OptionProps[];
5
- loading?: boolean | undefined;
4
+ loading?: boolean;
6
5
  } & {
7
- removeByBackspace?: boolean | undefined;
6
+ removeByBackspace?: boolean;
8
7
  } & Omit<import("@snack-uikit/list").SelectionMultipleState, "mode"> & Omit<{
9
- 'data-test-id'?: string | undefined;
8
+ 'data-test-id'?: string;
10
9
  } & import("react").AriaAttributes & {
11
10
  options: import("./types").OptionProps[];
12
- pinTop?: import("./types").OptionProps[] | undefined;
13
- pinBottom?: import("./types").OptionProps[] | undefined;
14
- searchable?: boolean | undefined;
15
- showCopyButton?: boolean | undefined;
16
- showClearButton?: boolean | undefined;
17
- readonly?: boolean | undefined;
18
- prefixIcon?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
19
- footer?: import("react").ReactNode;
20
- widthStrategy?: import("@snack-uikit/popover-private/dist/types").PopoverWidthStrategy | undefined;
21
- search?: import("./types").SearchState | undefined;
22
- autocomplete?: boolean | undefined;
23
- addOptionByEnter?: boolean | undefined;
24
- open?: boolean | undefined;
11
+ pinTop?: import("./types").OptionProps[];
12
+ pinBottom?: import("./types").OptionProps[];
13
+ searchable?: boolean;
14
+ showCopyButton?: boolean;
15
+ showClearButton?: boolean;
16
+ readonly?: boolean;
17
+ prefixIcon?: import("react").ReactElement;
18
+ footer?: import("@snack-uikit/list").DroplistProps["footer"];
19
+ widthStrategy?: import("@snack-uikit/list").DroplistProps["widthStrategy"];
20
+ search?: import("./types").SearchState;
21
+ autocomplete?: boolean;
22
+ addOptionByEnter?: boolean;
23
+ open?: boolean;
25
24
  onOpenChange?(open: boolean): void;
26
- selectedOptionFormatter?: SelectedOptionFormatter | undefined;
25
+ selectedOptionFormatter?: SelectedOptionFormatter;
27
26
  } & Pick<import("@snack-uikit/list").DroplistProps, "dataError" | "dataFiltered" | "noDataState" | "noResultsState" | "errorDataState">, "showCopyButton"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,25 +1,24 @@
1
- /// <reference types="react" />
2
1
  import { SelectedOptionFormatter } from './types';
3
2
  export declare const FieldSelectSingle: import("react").ForwardRefExoticComponent<import("./types").InputProps & import("./types").WrapperProps & {
4
3
  options: import("./types").OptionProps[];
5
- loading?: boolean | undefined;
4
+ loading?: boolean;
6
5
  } & Omit<import("@snack-uikit/list").SelectionSingleState, "mode"> & {
7
- 'data-test-id'?: string | undefined;
6
+ 'data-test-id'?: string;
8
7
  } & import("react").AriaAttributes & {
9
8
  options: import("./types").OptionProps[];
10
- pinTop?: import("./types").OptionProps[] | undefined;
11
- pinBottom?: import("./types").OptionProps[] | undefined;
12
- searchable?: boolean | undefined;
13
- showCopyButton?: boolean | undefined;
14
- showClearButton?: boolean | undefined;
15
- readonly?: boolean | undefined;
16
- prefixIcon?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
17
- footer?: import("react").ReactNode;
18
- widthStrategy?: import("@snack-uikit/popover-private/dist/types").PopoverWidthStrategy | undefined;
19
- search?: import("./types").SearchState | undefined;
20
- autocomplete?: boolean | undefined;
21
- addOptionByEnter?: boolean | undefined;
22
- open?: boolean | undefined;
9
+ pinTop?: import("./types").OptionProps[];
10
+ pinBottom?: import("./types").OptionProps[];
11
+ searchable?: boolean;
12
+ showCopyButton?: boolean;
13
+ showClearButton?: boolean;
14
+ readonly?: boolean;
15
+ prefixIcon?: import("react").ReactElement;
16
+ footer?: import("@snack-uikit/list").DroplistProps["footer"];
17
+ widthStrategy?: import("@snack-uikit/list").DroplistProps["widthStrategy"];
18
+ search?: import("./types").SearchState;
19
+ autocomplete?: boolean;
20
+ addOptionByEnter?: boolean;
21
+ open?: boolean;
23
22
  onOpenChange?(open: boolean): void;
24
- selectedOptionFormatter?: SelectedOptionFormatter | undefined;
23
+ selectedOptionFormatter?: SelectedOptionFormatter;
25
24
  } & Pick<import("@snack-uikit/list").DroplistProps, "dataError" | "dataFiltered" | "noDataState" | "noResultsState" | "errorDataState"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -25,9 +25,9 @@ export declare function useSearchInput({ value, onChange, defaultValue, selected
25
25
  selectedOptionFormatter: SelectedOptionFormatter;
26
26
  }): {
27
27
  inputValue: string;
28
- setInputValue: (value: any, ...args: any[]) => any;
28
+ setInputValue: (value: any, ...args: any[]) => ReturnType<Handler> | void;
29
29
  prevInputValue: import("react").MutableRefObject<string>;
30
- onInputValueChange: (value: any, ...args: any[]) => any;
30
+ onInputValueChange: (value: any, ...args: any[]) => ReturnType<Handler> | void;
31
31
  updateInputValue: (selectedItem?: ItemWithId) => void;
32
32
  };
33
33
  export declare function useHandleDeleteItem(setValue: Handler): (item?: ItemWithId) => (e?: MouseEvent<HTMLButtonElement>) => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Size } from '@snack-uikit/input-private';
3
2
  export declare function getArrowIcon({ size, open }: {
4
3
  size: Size;
@@ -24,7 +24,7 @@ export declare function updateMultipleItems({ options, value, selectedItems, }:
24
24
  }): {
25
25
  selectedItems: undefined;
26
26
  items: (import("@snack-uikit/list/dist/components/Items").Item & {
27
- appearance?: import("@snack-uikit/tag/dist/types").Appearance | undefined;
27
+ appearance?: import("@snack-uikit/tag").TagProps["appearance"];
28
28
  })[];
29
29
  } | {
30
30
  selectedItems: ItemWithId[];
@@ -16,6 +16,6 @@ type FieldSliderOwnProps = {
16
16
  };
17
17
  export type FieldSliderProps = WithSupportProps<FieldSliderOwnProps & SliderProps & WrapperProps>;
18
18
  export declare const FieldSlider: import("react").ForwardRefExoticComponent<{
19
- 'data-test-id'?: string | undefined;
19
+ 'data-test-id'?: string;
20
20
  } & import("react").AriaAttributes & FieldSliderOwnProps & Pick<InputPrivateProps, "disabled" | "readonly" | "id" | "name" | "onFocus" | "onBlur"> & Pick<SliderComponentProps, "onChange" | "value" | "range" | "tipFormatter"> & Required<Pick<SliderComponentProps, "max" | "min" | "step" | "marks">> & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
21
21
  export {};
@@ -14,7 +14,7 @@ import mergeRefs from 'merge-refs';
14
14
  import { forwardRef, useCallback, useEffect, useMemo, useRef, useState, } from 'react';
15
15
  import { InputPrivate, SIZE } from '@snack-uikit/input-private';
16
16
  import { Slider } from '@snack-uikit/slider';
17
- import { extractSupportProps } from '@snack-uikit/utils';
17
+ import { extractSupportProps, useEventHandler } from '@snack-uikit/utils';
18
18
  import { CONTAINER_VARIANT, VALIDATION_STATE } from '../../constants';
19
19
  import { FieldContainerPrivate } from '../../helperComponents';
20
20
  import { useValueControl } from '../../hooks';
@@ -113,7 +113,10 @@ export const FieldSlider = forwardRef((_a, ref) => {
113
113
  const { mark } = getClosestMark(textFieldNumValue, allowedValues, mark => mark);
114
114
  handleChange(mark);
115
115
  };
116
- const handleTextValueChange = () => {
116
+ const handleTextValueChange = useEventHandler(() => {
117
+ if (range) {
118
+ return;
119
+ }
117
120
  const parsedValue = parseInt(textFieldInputValue);
118
121
  const actualMinByMark = parseInt(String(getMarkValue(min)));
119
122
  const actualMin = Number.isNaN(actualMinByMark) ? min : actualMinByMark;
@@ -127,7 +130,7 @@ export const FieldSlider = forwardRef((_a, ref) => {
127
130
  else {
128
131
  handleNonEqualMarksSliderChange(textFieldNumValue);
129
132
  }
130
- };
133
+ });
131
134
  const onTextFieldBlur = (e) => {
132
135
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
133
136
  handleTextValueChange();
@@ -142,8 +145,6 @@ export const FieldSlider = forwardRef((_a, ref) => {
142
145
  }, [value, textInputFormatter]);
143
146
  useEffect(() => {
144
147
  handleTextValueChange();
145
- // update value only when marks, min or max are changed
146
- // eslint-disable-next-line react-hooks/exhaustive-deps
147
- }, [marks, min, max]);
148
+ }, [marks, min, max, handleTextValueChange]);
148
149
  return (_jsxs(FieldDecorator, Object.assign({ className: className, label: label, labelTooltip: labelTooltip, labelTooltipPlacement: labelTooltipPlacement, labelFor: id, disabled: disabled, required: required, caption: caption, hint: hint, showHintIcon: showHintIcon, readonly: readonly, size: size }, extractSupportProps(rest), { children: [_jsx(FieldContainerPrivate, { className: styles.fieldContainer, size: size, validationState: VALIDATION_STATE.Default, disabled: disabled, readonly: readonly, variant: CONTAINER_VARIANT.SingleLine, inputRef: localRef, postfix: postfixIcon, children: _jsx(InputPrivate, { ref: mergeRefs(ref, localRef), "data-size": size, value: textFieldInputValue, onChange: range ? undefined : onTextFieldChange, onFocus: onFocus, onBlur: range ? onBlur : onTextFieldBlur, onKeyDown: handleTextFieldKeyChange, disabled: disabled, readonly: range ? true : readonly, type: 'text', id: id, name: name, "data-test-id": 'field-slider__input' }) }), _jsx("div", { className: styles.sliderWrapper, children: _jsx("div", { className: styles.slider, "data-size": size, children: _jsx(Slider, { range: range, min: min, max: max, step: step, value: value, onChange: onChange, marks: showScaleBar ? marks : undefined, disabled: readonly || disabled, "data-test-id": 'field-slider__slider' }) }) })] })));
149
150
  });
@@ -16,6 +16,6 @@ type FieldStepperOwnProps = {
16
16
  };
17
17
  export type FieldStepperProps = WithSupportProps<FieldStepperOwnProps & InputProps & WrapperProps>;
18
18
  export declare const FieldStepper: import("react").ForwardRefExoticComponent<{
19
- 'data-test-id'?: string | undefined;
19
+ 'data-test-id'?: string;
20
20
  } & import("react").AriaAttributes & FieldStepperOwnProps & InputProps & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
21
21
  export {};
@@ -19,6 +19,6 @@ type FieldTextOwnProps = {
19
19
  };
20
20
  export type FieldTextProps = WithSupportProps<FieldTextOwnProps & InputProps & WrapperProps>;
21
21
  export declare const FieldText: import("react").ForwardRefExoticComponent<{
22
- 'data-test-id'?: string | undefined;
22
+ 'data-test-id'?: string;
23
23
  } & import("react").AriaAttributes & FieldTextOwnProps & Pick<Partial<InputPrivateProps>, "onChange" | "value"> & Pick<InputPrivateProps, "disabled" | "readonly" | "id" | "name" | "onFocus" | "onBlur" | "placeholder" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLInputElement>>;
24
24
  export {};
@@ -25,6 +25,6 @@ type FieldTextAreaOwnProps = {
25
25
  };
26
26
  export type FieldTextAreaProps = WithSupportProps<FieldTextAreaOwnProps & InputProps & WrapperProps>;
27
27
  export declare const FieldTextArea: import("react").ForwardRefExoticComponent<{
28
- 'data-test-id'?: string | undefined;
28
+ 'data-test-id'?: string;
29
29
  } & import("react").AriaAttributes & FieldTextAreaOwnProps & Pick<Partial<TextAreaProps>, "value"> & Pick<TextAreaProps, "disabled" | "readonly" | "id" | "name" | "onFocus" | "onBlur" | "placeholder" | "maxLength"> & WrapperProps & import("react").RefAttributes<HTMLTextAreaElement>>;
30
30
  export {};
@@ -3,5 +3,5 @@ type UseValueControl<TValue> = {
3
3
  onChange?(value: TValue): void;
4
4
  defaultValue?: TValue;
5
5
  };
6
- export declare function useValueControl<TValue>({ value, onChange, defaultValue }: UseValueControl<TValue>): readonly [TValue | undefined, (value: any, ...args: any[]) => any];
6
+ export declare function useValueControl<TValue>({ value, onChange, defaultValue }: UseValueControl<TValue>): readonly [TValue | undefined, (value: any, ...args: any[]) => ReturnType<import("uncontrollable").Handler> | void];
7
7
  export {};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Fields",
7
- "version": "0.23.3",
7
+ "version": "0.23.5-preview-b0cb52bd.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -37,7 +37,7 @@
37
37
  "@snack-uikit/dropdown": "0.2.4",
38
38
  "@snack-uikit/icons": "0.22.0",
39
39
  "@snack-uikit/input-private": "3.1.4",
40
- "@snack-uikit/list": "0.14.1",
40
+ "@snack-uikit/list": "0.14.2",
41
41
  "@snack-uikit/scroll": "0.6.0",
42
42
  "@snack-uikit/skeleton": "0.3.4",
43
43
  "@snack-uikit/slider": "0.1.15",
@@ -59,5 +59,5 @@
59
59
  "peerDependencies": {
60
60
  "@snack-uikit/locale": "*"
61
61
  },
62
- "gitHead": "4c153b54a2902cf20883d85b4dc753344313c6cb"
62
+ "gitHead": "0c025d82c687785f267d371b4c50b36037bcc0cc"
63
63
  }
@@ -13,7 +13,7 @@ import {
13
13
 
14
14
  import { InputPrivate, InputPrivateProps, SIZE } from '@snack-uikit/input-private';
15
15
  import { Slider, SliderProps as SliderComponentProps } from '@snack-uikit/slider';
16
- import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
16
+ import { extractSupportProps, useEventHandler, WithSupportProps } from '@snack-uikit/utils';
17
17
 
18
18
  import { CONTAINER_VARIANT, VALIDATION_STATE } from '../../constants';
19
19
  import { FieldContainerPrivate } from '../../helperComponents';
@@ -212,7 +212,11 @@ export const FieldSlider = forwardRef<HTMLInputElement, FieldSliderProps>(
212
212
  handleChange(mark);
213
213
  };
214
214
 
215
- const handleTextValueChange = () => {
215
+ const handleTextValueChange = useEventHandler(() => {
216
+ if (range) {
217
+ return;
218
+ }
219
+
216
220
  const parsedValue = parseInt(textFieldInputValue);
217
221
  const actualMinByMark = parseInt(String(getMarkValue(min)));
218
222
  const actualMin = Number.isNaN(actualMinByMark) ? min : actualMinByMark;
@@ -228,7 +232,7 @@ export const FieldSlider = forwardRef<HTMLInputElement, FieldSliderProps>(
228
232
  } else {
229
233
  handleNonEqualMarksSliderChange(textFieldNumValue);
230
234
  }
231
- };
235
+ });
232
236
 
233
237
  const onTextFieldBlur = (e: FocusEvent<HTMLInputElement, Element>) => {
234
238
  onBlur?.(e);
@@ -247,9 +251,7 @@ export const FieldSlider = forwardRef<HTMLInputElement, FieldSliderProps>(
247
251
 
248
252
  useEffect(() => {
249
253
  handleTextValueChange();
250
- // update value only when marks, min or max are changed
251
- // eslint-disable-next-line react-hooks/exhaustive-deps
252
- }, [marks, min, max]);
254
+ }, [marks, min, max, handleTextValueChange]);
253
255
 
254
256
  return (
255
257
  <FieldDecorator