@redneckz/wildless-cms-uni-blocks 0.14.594 → 0.14.595
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/bundle/bundle.umd.js +18 -17
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/model/DefaultControlType.d.ts +7 -0
- package/bundle/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
- package/bundle/ui-kit/Input/InputProps.d.ts +2 -6
- package/bundle/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
- package/bundle/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
- package/bundle/ui-kit/Select/Select.d.ts +4 -7
- package/bundle/ui-kit/Select/SelectControl.d.ts +1 -8
- package/bundle/utils/getRequiredLabel.d.ts +2 -0
- package/dist/model/DefaultControlType.d.ts +7 -0
- package/dist/model/DefaultControlType.js +2 -0
- package/dist/model/DefaultControlType.js.map +1 -0
- package/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -1
- package/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
- package/dist/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
- package/dist/ui-kit/DatePicker/DatePickerControl.js +2 -1
- package/dist/ui-kit/DatePicker/DatePickerControl.js.map +1 -1
- package/dist/ui-kit/FormField/Fields/SexField.js +5 -4
- package/dist/ui-kit/FormField/Fields/SexField.js.map +1 -1
- package/dist/ui-kit/FormField/Fields/VedField.js +1 -1
- package/dist/ui-kit/FormField/Fields/VedField.js.map +1 -1
- package/dist/ui-kit/Input/InputControl.js +2 -2
- package/dist/ui-kit/Input/InputControl.js.map +1 -1
- package/dist/ui-kit/Input/InputPhoneControl.js +2 -1
- package/dist/ui-kit/Input/InputPhoneControl.js.map +1 -1
- package/dist/ui-kit/Input/InputProps.d.ts +2 -6
- package/dist/ui-kit/Input/InputSnilsControl.js +2 -1
- package/dist/ui-kit/Input/InputSnilsControl.js.map +1 -1
- package/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
- package/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
- package/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
- package/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js +10 -0
- package/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js.map +1 -0
- package/dist/ui-kit/Select/Select.d.ts +4 -7
- package/dist/ui-kit/Select/Select.js +3 -4
- package/dist/ui-kit/Select/Select.js.map +1 -1
- package/dist/ui-kit/Select/SelectControl.d.ts +1 -8
- package/dist/ui-kit/Select/SelectControl.js +2 -1
- package/dist/ui-kit/Select/SelectControl.js.map +1 -1
- package/dist/utils/getRequiredLabel.d.ts +2 -0
- package/dist/utils/getRequiredLabel.js +5 -0
- package/dist/utils/getRequiredLabel.js.map +1 -0
- package/lib/model/DefaultControlType.d.ts +7 -0
- package/lib/model/DefaultControlType.js +2 -0
- package/lib/model/DefaultControlType.js.map +1 -0
- package/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -1
- package/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
- package/lib/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
- package/lib/ui-kit/DatePicker/DatePickerControl.js +2 -1
- package/lib/ui-kit/DatePicker/DatePickerControl.js.map +1 -1
- package/lib/ui-kit/FormField/Fields/SexField.js +5 -4
- package/lib/ui-kit/FormField/Fields/SexField.js.map +1 -1
- package/lib/ui-kit/FormField/Fields/VedField.js +1 -1
- package/lib/ui-kit/FormField/Fields/VedField.js.map +1 -1
- package/lib/ui-kit/Input/InputControl.js +2 -2
- package/lib/ui-kit/Input/InputControl.js.map +1 -1
- package/lib/ui-kit/Input/InputPhoneControl.js +2 -1
- package/lib/ui-kit/Input/InputPhoneControl.js.map +1 -1
- package/lib/ui-kit/Input/InputProps.d.ts +2 -6
- package/lib/ui-kit/Input/InputSnilsControl.js +2 -1
- package/lib/ui-kit/Input/InputSnilsControl.js.map +1 -1
- package/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
- package/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
- package/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
- package/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js +8 -0
- package/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js.map +1 -0
- package/lib/ui-kit/Select/Select.d.ts +4 -7
- package/lib/ui-kit/Select/Select.js +3 -4
- package/lib/ui-kit/Select/Select.js.map +1 -1
- package/lib/ui-kit/Select/SelectControl.d.ts +1 -8
- package/lib/ui-kit/Select/SelectControl.js +2 -1
- package/lib/ui-kit/Select/SelectControl.js.map +1 -1
- package/lib/utils/getRequiredLabel.d.ts +2 -0
- package/lib/utils/getRequiredLabel.js +2 -0
- package/lib/utils/getRequiredLabel.js.map +1 -0
- package/mobile/bundle/bundle.umd.js +18 -17
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/model/DefaultControlType.d.ts +7 -0
- package/mobile/bundle/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
- package/mobile/bundle/ui-kit/Input/InputProps.d.ts +2 -6
- package/mobile/bundle/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
- package/mobile/bundle/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
- package/mobile/bundle/ui-kit/Select/Select.d.ts +4 -7
- package/mobile/bundle/ui-kit/Select/SelectControl.d.ts +1 -8
- package/mobile/bundle/utils/getRequiredLabel.d.ts +2 -0
- package/mobile/dist/model/DefaultControlType.d.ts +7 -0
- package/mobile/dist/model/DefaultControlType.js +2 -0
- package/mobile/dist/model/DefaultControlType.js.map +1 -0
- package/mobile/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -1
- package/mobile/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
- package/mobile/dist/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
- package/mobile/dist/ui-kit/DatePicker/DatePickerControl.js +2 -1
- package/mobile/dist/ui-kit/DatePicker/DatePickerControl.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/SexField.js +5 -4
- package/mobile/dist/ui-kit/FormField/Fields/SexField.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/VedField.js +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/VedField.js.map +1 -1
- package/mobile/dist/ui-kit/Input/InputControl.js +2 -2
- package/mobile/dist/ui-kit/Input/InputControl.js.map +1 -1
- package/mobile/dist/ui-kit/Input/InputPhoneControl.js +2 -1
- package/mobile/dist/ui-kit/Input/InputPhoneControl.js.map +1 -1
- package/mobile/dist/ui-kit/Input/InputProps.d.ts +2 -6
- package/mobile/dist/ui-kit/Input/InputSnilsControl.js +2 -1
- package/mobile/dist/ui-kit/Input/InputSnilsControl.js.map +1 -1
- package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
- package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
- package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
- package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js +10 -0
- package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js.map +1 -0
- package/mobile/dist/ui-kit/Select/Select.d.ts +4 -7
- package/mobile/dist/ui-kit/Select/Select.js +3 -4
- package/mobile/dist/ui-kit/Select/Select.js.map +1 -1
- package/mobile/dist/ui-kit/Select/SelectControl.d.ts +1 -8
- package/mobile/dist/ui-kit/Select/SelectControl.js +2 -1
- package/mobile/dist/ui-kit/Select/SelectControl.js.map +1 -1
- package/mobile/dist/utils/getRequiredLabel.d.ts +2 -0
- package/mobile/dist/utils/getRequiredLabel.js +5 -0
- package/mobile/dist/utils/getRequiredLabel.js.map +1 -0
- package/mobile/lib/model/DefaultControlType.d.ts +7 -0
- package/mobile/lib/model/DefaultControlType.js +2 -0
- package/mobile/lib/model/DefaultControlType.js.map +1 -0
- package/mobile/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -1
- package/mobile/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
- package/mobile/lib/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
- package/mobile/lib/ui-kit/DatePicker/DatePickerControl.js +2 -1
- package/mobile/lib/ui-kit/DatePicker/DatePickerControl.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/SexField.js +5 -4
- package/mobile/lib/ui-kit/FormField/Fields/SexField.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/VedField.js +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/VedField.js.map +1 -1
- package/mobile/lib/ui-kit/Input/InputControl.js +2 -2
- package/mobile/lib/ui-kit/Input/InputControl.js.map +1 -1
- package/mobile/lib/ui-kit/Input/InputPhoneControl.js +2 -1
- package/mobile/lib/ui-kit/Input/InputPhoneControl.js.map +1 -1
- package/mobile/lib/ui-kit/Input/InputProps.d.ts +2 -6
- package/mobile/lib/ui-kit/Input/InputSnilsControl.js +2 -1
- package/mobile/lib/ui-kit/Input/InputSnilsControl.js.map +1 -1
- package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
- package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
- package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
- package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js +8 -0
- package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js.map +1 -0
- package/mobile/lib/ui-kit/Select/Select.d.ts +4 -7
- package/mobile/lib/ui-kit/Select/Select.js +3 -4
- package/mobile/lib/ui-kit/Select/Select.js.map +1 -1
- package/mobile/lib/ui-kit/Select/SelectControl.d.ts +1 -8
- package/mobile/lib/ui-kit/Select/SelectControl.js +2 -1
- package/mobile/lib/ui-kit/Select/SelectControl.js.map +1 -1
- package/mobile/lib/utils/getRequiredLabel.d.ts +2 -0
- package/mobile/lib/utils/getRequiredLabel.js +2 -0
- package/mobile/lib/utils/getRequiredLabel.js.map +1 -0
- package/mobile/src/model/DefaultControlType.ts +7 -0
- package/mobile/src/ui-kit/Calculator/renderBinaryRadioButtonGroup.tsx +1 -1
- package/mobile/src/ui-kit/DatePicker/DatePickerControl.tsx +6 -14
- package/mobile/src/ui-kit/FormField/Fields/SexField.tsx +13 -11
- package/mobile/src/ui-kit/FormField/Fields/VedField.tsx +1 -1
- package/mobile/src/ui-kit/Input/InputControl.tsx +2 -3
- package/mobile/src/ui-kit/Input/InputPhoneControl.tsx +2 -1
- package/mobile/src/ui-kit/Input/InputProps.ts +2 -6
- package/mobile/src/ui-kit/Input/InputSnilsControl.tsx +2 -1
- package/mobile/src/ui-kit/RadioButtonGroup/RadioButtonGroup.tsx +9 -10
- package/mobile/src/ui-kit/RadioButtonGroup/RadioButtonGroupControl.tsx +18 -0
- package/mobile/src/ui-kit/Select/Select.tsx +8 -10
- package/mobile/src/ui-kit/Select/SelectControl.tsx +4 -10
- package/mobile/src/utils/getRequiredLabel.ts +4 -0
- package/package.json +1 -1
- package/src/model/DefaultControlType.ts +7 -0
- package/src/ui-kit/Calculator/renderBinaryRadioButtonGroup.tsx +1 -1
- package/src/ui-kit/DatePicker/DatePickerControl.tsx +6 -14
- package/src/ui-kit/FormField/Fields/SexField.tsx +13 -11
- package/src/ui-kit/FormField/Fields/VedField.tsx +1 -1
- package/src/ui-kit/Input/InputControl.tsx +2 -3
- package/src/ui-kit/Input/InputPhoneControl.tsx +2 -1
- package/src/ui-kit/Input/InputProps.ts +2 -6
- package/src/ui-kit/Input/InputSnilsControl.tsx +2 -1
- package/src/ui-kit/RadioButtonGroup/RadioButtonGroup.fixture.tsx +2 -2
- package/src/ui-kit/RadioButtonGroup/RadioButtonGroup.tsx +9 -10
- package/src/ui-kit/RadioButtonGroup/RadioButtonGroupControl.tsx +18 -0
- package/src/ui-kit/Select/Select.tsx +8 -10
- package/src/ui-kit/Select/SelectControl.tsx +4 -10
- package/src/utils/getRequiredLabel.ts +4 -0
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { getRequiredLabel } from '../../utils/getRequiredLabel';
|
|
2
3
|
import { renderErrorText } from '../Input/renderErrorText';
|
|
3
4
|
import { Select, type SelectProps } from './Select';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
label
|
|
7
|
-
error?: string;
|
|
8
|
-
errors?: string[];
|
|
9
|
-
className?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const SelectControl = JSX<SelectControlProps>(
|
|
13
|
-
({ className = '', label, error, ...rest }) => (
|
|
6
|
+
export const SelectControl = JSX<SelectProps>(
|
|
7
|
+
({ className = '', label, error, errors, ...rest }) => (
|
|
14
8
|
<div className={className}>
|
|
15
|
-
<Select {...rest} valid={!error} label={
|
|
9
|
+
<Select {...rest} valid={!error} label={getRequiredLabel({ label, errors })} />
|
|
16
10
|
{renderErrorText(error)}
|
|
17
11
|
</div>
|
|
18
12
|
),
|
package/package.json
CHANGED
|
@@ -44,7 +44,7 @@ export const renderBinaryRadioButtonGroup = ({
|
|
|
44
44
|
<RadioButtonGroup
|
|
45
45
|
orientation={orientation}
|
|
46
46
|
items={items}
|
|
47
|
-
|
|
47
|
+
value={items[value ? 0 : 1].id}
|
|
48
48
|
onChange={(_) => onChange && onChange(_ === items[0].id)}
|
|
49
49
|
{...rest}
|
|
50
50
|
/>
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { type DefaultControlType } from '../../model/DefaultControlType';
|
|
3
|
+
import { getRequiredLabel } from '../../utils/getRequiredLabel';
|
|
2
4
|
import { style } from '../../utils/style';
|
|
5
|
+
import { type ControlProps } from '../ControlProps';
|
|
3
6
|
import { renderErrorText } from '../Input/renderErrorText';
|
|
4
7
|
import { DatePicker } from './DatePicker';
|
|
5
8
|
|
|
6
|
-
export interface DatePickerControlProps {
|
|
7
|
-
className?: string;
|
|
8
|
-
label: string;
|
|
9
|
-
value?: Date;
|
|
10
|
-
error?: string;
|
|
11
|
-
errors?: string[];
|
|
12
|
-
onChange?: (value: Date) => void;
|
|
13
|
-
}
|
|
9
|
+
export interface DatePickerControlProps extends DefaultControlType, ControlProps<Date> {}
|
|
14
10
|
|
|
15
11
|
export const DatePickerControl = JSX<DatePickerControlProps>(
|
|
16
|
-
({ className, label, error, ...rest }) => (
|
|
12
|
+
({ className, label, error, errors, ...rest }) => (
|
|
17
13
|
<div className={style('shrink-0 w-full', className)}>
|
|
18
|
-
<DatePicker
|
|
19
|
-
label={label && rest?.errors ? `${label}*` : label}
|
|
20
|
-
valid={Boolean(!error)}
|
|
21
|
-
{...rest}
|
|
22
|
-
/>
|
|
14
|
+
<DatePicker label={getRequiredLabel({ label, errors })} valid={Boolean(!error)} {...rest} />
|
|
23
15
|
{renderErrorText(error)}
|
|
24
16
|
</div>
|
|
25
17
|
),
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import {
|
|
2
|
+
import { type RadioButtonItem } from '../../RadioButtonGroup/RadioButtonGroup';
|
|
3
|
+
import { RadioButtonGroupControl } from '../../RadioButtonGroup/RadioButtonGroupControl';
|
|
3
4
|
import { type CustomFieldProps } from '../CustomFieldProps';
|
|
5
|
+
import { validatorObj } from '../getObjectValidator';
|
|
6
|
+
import { getValidation } from '../getValidation';
|
|
4
7
|
|
|
5
8
|
export const SEX_TYPES: RadioButtonItem[] = [
|
|
6
9
|
{ id: 'male', text: 'Мужской' },
|
|
7
10
|
{ id: 'female', text: 'Женский' },
|
|
8
11
|
];
|
|
9
12
|
|
|
10
|
-
export const SexField = JSX<CustomFieldProps>(({ field }) => {
|
|
11
|
-
const { value, onChange } = field('sex');
|
|
12
|
-
|
|
13
|
+
export const SexField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
13
14
|
return (
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
<div>
|
|
16
|
+
<RadioButtonGroupControl
|
|
17
|
+
label="Пол"
|
|
18
|
+
orientation="horizontal"
|
|
19
|
+
items={SEX_TYPES}
|
|
20
|
+
{...getValidation(field('sex'), validatorObj.sex, input?.required)}
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
21
23
|
);
|
|
22
24
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
|
|
3
3
|
import { useOutsideClick } from '@redneckz/uni-jsx/lib/hooks/useOutsideClick';
|
|
4
|
+
import { getRequiredLabel } from '../../utils/getRequiredLabel';
|
|
4
5
|
import { noop } from '../../utils/noop';
|
|
5
6
|
import { style } from '../../utils/style';
|
|
6
7
|
import { Input } from './Input';
|
|
@@ -44,7 +45,7 @@ export const InputControl = JSX<InputProps>(
|
|
|
44
45
|
<Input
|
|
45
46
|
type={type || 'text'}
|
|
46
47
|
aria-label={label}
|
|
47
|
-
label={
|
|
48
|
+
label={getRequiredLabel({ label, errors })}
|
|
48
49
|
valid={Boolean(!error)}
|
|
49
50
|
value={value}
|
|
50
51
|
onChange={onChange}
|
|
@@ -59,7 +60,5 @@ export const InputControl = JSX<InputProps>(
|
|
|
59
60
|
},
|
|
60
61
|
);
|
|
61
62
|
|
|
62
|
-
const getLabel = (errors?: string[], label?: string) => (label && errors ? `${label}*` : label);
|
|
63
|
-
|
|
64
63
|
const getPlaceholder = (placeholder?: string, errors?: string[], label?: string) =>
|
|
65
64
|
errors && !label ? `${placeholder}*` : placeholder;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { getRequiredLabel } from '../../utils/getRequiredLabel';
|
|
2
3
|
import { style } from '../../utils/style';
|
|
3
4
|
import { PhoneInput } from '../PhoneInput/PhoneInput';
|
|
4
5
|
import { type InputProps } from './InputProps';
|
|
@@ -8,7 +9,7 @@ export const InputPhoneControl = JSX<InputProps>(({ className, label, error, ...
|
|
|
8
9
|
<div className={style('shrink-0 w-full', className)}>
|
|
9
10
|
<PhoneInput
|
|
10
11
|
aria-label={label}
|
|
11
|
-
label={
|
|
12
|
+
label={getRequiredLabel({ label, errors: rest?.errors })}
|
|
12
13
|
valid={Boolean(!error)}
|
|
13
14
|
placeholder="+7 (___) ___-__-__"
|
|
14
15
|
{...rest}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type DefaultControlType } from '../../model/DefaultControlType';
|
|
2
2
|
import { type InputTypes } from '../../model/InputTypes';
|
|
3
3
|
import { type ControlProps } from '../ControlProps';
|
|
4
4
|
import { type PreventableEventWithTarget } from '../PreventableEvent';
|
|
5
5
|
|
|
6
|
-
export interface InputProps<V = string> extends ControlProps<V
|
|
7
|
-
className?: string;
|
|
6
|
+
export interface InputProps<V = string> extends DefaultControlType, ControlProps<V> {
|
|
8
7
|
id?: string;
|
|
9
8
|
name?: string;
|
|
10
9
|
type?: InputTypes;
|
|
11
|
-
placeholder?: string;
|
|
12
10
|
pattern?: string;
|
|
13
11
|
onFocus?: (ev: PreventableEventWithTarget) => void;
|
|
14
12
|
onBlur?: (ev?: PreventableEventWithTarget) => void;
|
|
@@ -16,7 +14,5 @@ export interface InputProps<V = string> extends ControlProps<V>, LabelProps {
|
|
|
16
14
|
disabled?: boolean;
|
|
17
15
|
autoFocus?: boolean;
|
|
18
16
|
isTextarea?: boolean;
|
|
19
|
-
error?: string;
|
|
20
|
-
errors?: string[];
|
|
21
17
|
dadata?: boolean;
|
|
22
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { getRequiredLabel } from '../../utils/getRequiredLabel';
|
|
2
3
|
import { style } from '../../utils/style';
|
|
3
4
|
import { SnilsInput } from '../SnilsInput/SnilsInput';
|
|
4
5
|
import { type InputProps } from './InputProps';
|
|
@@ -9,7 +10,7 @@ export const InputSnilsControl = JSX<InputProps>(
|
|
|
9
10
|
<div className={style('shrink-0 w-full', className)}>
|
|
10
11
|
<SnilsInput
|
|
11
12
|
aria-label={label}
|
|
12
|
-
label={
|
|
13
|
+
label={getRequiredLabel({ label, errors: rest?.errors })}
|
|
13
14
|
valid={Boolean(!error)}
|
|
14
15
|
value={value}
|
|
15
16
|
onChange={onChange}
|
|
@@ -23,7 +23,7 @@ export default {
|
|
|
23
23
|
</Text>
|
|
24
24
|
<RadioButtonGroup
|
|
25
25
|
items={items}
|
|
26
|
-
|
|
26
|
+
value="Аннуитетный"
|
|
27
27
|
onChange={(text) => console.log('Выбран пункт меню: ', text)}
|
|
28
28
|
/>
|
|
29
29
|
</div>
|
|
@@ -34,7 +34,7 @@ export default {
|
|
|
34
34
|
<RadioButtonGroup
|
|
35
35
|
items={items}
|
|
36
36
|
orientation="vertical"
|
|
37
|
-
|
|
37
|
+
value="Аннуитетный"
|
|
38
38
|
onChange={(text) => console.log('Выбран пункт меню: ', text)}
|
|
39
39
|
/>
|
|
40
40
|
</div>
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { type DefaultControlType } from '../../model/DefaultControlType';
|
|
2
3
|
import { type TextProps } from '../../model/HeadlineType';
|
|
3
4
|
import { type ListOrientation } from '../../model/ListOrientation';
|
|
4
5
|
import { style } from '../../utils/style';
|
|
5
6
|
import { Checkbox } from '../Checkbox/Checkbox';
|
|
7
|
+
import { type ControlProps } from '../ControlProps';
|
|
6
8
|
import { Text } from '../Text/Text';
|
|
7
9
|
|
|
8
10
|
export type RadioButtonItem = TextProps & {
|
|
9
11
|
id: string;
|
|
10
12
|
};
|
|
11
13
|
|
|
12
|
-
interface RadioButtonGroupProps {
|
|
13
|
-
title?: string;
|
|
14
|
+
export interface RadioButtonGroupProps extends DefaultControlType, ControlProps<string> {
|
|
14
15
|
items?: RadioButtonItem[];
|
|
15
|
-
checkedItem?: string;
|
|
16
|
-
className?: string;
|
|
17
16
|
onChange?: (id: string) => void;
|
|
18
17
|
disabled?: boolean;
|
|
19
18
|
orientation?: ListOrientation;
|
|
@@ -26,19 +25,19 @@ const orientationStyleMap: Record<ListOrientation, string> = {
|
|
|
26
25
|
|
|
27
26
|
export const RadioButtonGroup = JSX<RadioButtonGroupProps>(
|
|
28
27
|
({
|
|
29
|
-
|
|
28
|
+
label,
|
|
30
29
|
items,
|
|
31
|
-
|
|
30
|
+
value,
|
|
32
31
|
className,
|
|
33
32
|
onChange: onChangeCheckedItem,
|
|
34
33
|
disabled = false,
|
|
35
34
|
orientation = 'horizontal',
|
|
36
35
|
}) => (
|
|
37
36
|
<div className="grid gap-xs whitespace-nowrap">
|
|
38
|
-
{
|
|
39
|
-
<div role="radiogroup" aria-label={
|
|
37
|
+
{label ? (
|
|
38
|
+
<div role="radiogroup" aria-label={label}>
|
|
40
39
|
<Text color="text-secondary-text" font="font-light">
|
|
41
|
-
{
|
|
40
|
+
{label}
|
|
42
41
|
</Text>
|
|
43
42
|
</div>
|
|
44
43
|
) : null}
|
|
@@ -52,7 +51,7 @@ export const RadioButtonGroup = JSX<RadioButtonGroupProps>(
|
|
|
52
51
|
key={String(id)}
|
|
53
52
|
isRadio
|
|
54
53
|
text={text}
|
|
55
|
-
value={
|
|
54
|
+
value={value === id}
|
|
56
55
|
onChange={() => onChangeCheckedItem && onChangeCheckedItem(id)}
|
|
57
56
|
disabled={disabled}
|
|
58
57
|
/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { getRequiredLabel } from '../../utils/getRequiredLabel';
|
|
3
|
+
import { style } from '../../utils/style';
|
|
4
|
+
import { renderErrorText } from '../Input/renderErrorText';
|
|
5
|
+
import { RadioButtonGroup, type RadioButtonGroupProps } from './RadioButtonGroup';
|
|
6
|
+
|
|
7
|
+
export const RadioButtonGroupControl = JSX<RadioButtonGroupProps>(
|
|
8
|
+
({ className, label, onChange, error, ...rest }) => (
|
|
9
|
+
<div className={style('shrink-0 w-full', className)}>
|
|
10
|
+
<RadioButtonGroup
|
|
11
|
+
label={getRequiredLabel({ label, errors: rest?.errors })}
|
|
12
|
+
onChange={(_) => onChange && onChange(_)}
|
|
13
|
+
{...rest}
|
|
14
|
+
/>
|
|
15
|
+
{renderErrorText(error)}
|
|
16
|
+
</div>
|
|
17
|
+
),
|
|
18
|
+
);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
3
|
import { useBool } from '@redneckz/uni-jsx/lib/hooks/useBool';
|
|
4
|
-
import { type
|
|
4
|
+
import { type DefaultControlType } from '../../model/DefaultControlType';
|
|
5
5
|
import { type IconVersion } from '../../model/IconVersion';
|
|
6
6
|
import { style } from '../../utils/style';
|
|
7
|
+
import { type ControlProps } from '../ControlProps';
|
|
7
8
|
import { Icon } from '../Icon/Icon';
|
|
8
9
|
import { Input } from '../Input/Input';
|
|
9
10
|
import { renderLabel } from '../Input/renderLabel';
|
|
@@ -11,21 +12,16 @@ import { formatOption } from './formatOption';
|
|
|
11
12
|
import { type Option } from './Option';
|
|
12
13
|
import { useSelectPopup } from './useSelectPopup';
|
|
13
14
|
|
|
14
|
-
export
|
|
15
|
-
className?: string;
|
|
15
|
+
export interface SelectProps extends DefaultControlType, ControlProps<Option> {
|
|
16
16
|
options?: Option[];
|
|
17
|
-
value?: Option;
|
|
18
17
|
valid?: boolean;
|
|
19
18
|
isBorder?: boolean;
|
|
20
|
-
placeholder?: string;
|
|
21
19
|
isSearch?: boolean;
|
|
22
|
-
onChange?: (value: Option) => void;
|
|
23
20
|
iconVersion?: IconVersion;
|
|
24
21
|
disabled?: boolean;
|
|
25
|
-
}
|
|
22
|
+
}
|
|
26
23
|
|
|
27
24
|
export const Select = JSX<SelectProps>(
|
|
28
|
-
// eslint-disable-next-line complexity
|
|
29
25
|
({
|
|
30
26
|
className,
|
|
31
27
|
label,
|
|
@@ -37,11 +33,11 @@ export const Select = JSX<SelectProps>(
|
|
|
37
33
|
isSearch = false,
|
|
38
34
|
iconVersion = 'black',
|
|
39
35
|
onChange,
|
|
40
|
-
disabled,
|
|
36
|
+
disabled = false,
|
|
41
37
|
}) => {
|
|
42
38
|
const [isOpen, { setFalse: close, setTrue: open }] = useBool();
|
|
43
39
|
const [query, setQuery] = useState('');
|
|
44
|
-
const isDisabled = disabled
|
|
40
|
+
const isDisabled = getDisabled(disabled, options.length);
|
|
45
41
|
const hasOpen = isOpen && !isDisabled;
|
|
46
42
|
|
|
47
43
|
const handleClose = useCallback(() => {
|
|
@@ -101,3 +97,5 @@ const getStyle = (isBorder: boolean, valid: boolean, disabled: boolean) =>
|
|
|
101
97
|
disabled ? 'bg-main-divider' : 'cursor-pointer ',
|
|
102
98
|
valid ? 'border-gray' : 'border-error',
|
|
103
99
|
);
|
|
100
|
+
|
|
101
|
+
const getDisabled = (disabled: boolean, length: number) => disabled || length === 0;
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { getRequiredLabel } from '../../utils/getRequiredLabel';
|
|
2
3
|
import { renderErrorText } from '../Input/renderErrorText';
|
|
3
4
|
import { Select, type SelectProps } from './Select';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
label
|
|
7
|
-
error?: string;
|
|
8
|
-
errors?: string[];
|
|
9
|
-
className?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const SelectControl = JSX<SelectControlProps>(
|
|
13
|
-
({ className = '', label, error, ...rest }) => (
|
|
6
|
+
export const SelectControl = JSX<SelectProps>(
|
|
7
|
+
({ className = '', label, error, errors, ...rest }) => (
|
|
14
8
|
<div className={className}>
|
|
15
|
-
<Select {...rest} valid={!error} label={
|
|
9
|
+
<Select {...rest} valid={!error} label={getRequiredLabel({ label, errors })} />
|
|
16
10
|
{renderErrorText(error)}
|
|
17
11
|
</div>
|
|
18
12
|
),
|