@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.
Files changed (186) hide show
  1. package/bundle/bundle.umd.js +18 -17
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/model/DefaultControlType.d.ts +7 -0
  4. package/bundle/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
  5. package/bundle/ui-kit/Input/InputProps.d.ts +2 -6
  6. package/bundle/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
  7. package/bundle/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
  8. package/bundle/ui-kit/Select/Select.d.ts +4 -7
  9. package/bundle/ui-kit/Select/SelectControl.d.ts +1 -8
  10. package/bundle/utils/getRequiredLabel.d.ts +2 -0
  11. package/dist/model/DefaultControlType.d.ts +7 -0
  12. package/dist/model/DefaultControlType.js +2 -0
  13. package/dist/model/DefaultControlType.js.map +1 -0
  14. package/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -1
  15. package/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
  16. package/dist/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
  17. package/dist/ui-kit/DatePicker/DatePickerControl.js +2 -1
  18. package/dist/ui-kit/DatePicker/DatePickerControl.js.map +1 -1
  19. package/dist/ui-kit/FormField/Fields/SexField.js +5 -4
  20. package/dist/ui-kit/FormField/Fields/SexField.js.map +1 -1
  21. package/dist/ui-kit/FormField/Fields/VedField.js +1 -1
  22. package/dist/ui-kit/FormField/Fields/VedField.js.map +1 -1
  23. package/dist/ui-kit/Input/InputControl.js +2 -2
  24. package/dist/ui-kit/Input/InputControl.js.map +1 -1
  25. package/dist/ui-kit/Input/InputPhoneControl.js +2 -1
  26. package/dist/ui-kit/Input/InputPhoneControl.js.map +1 -1
  27. package/dist/ui-kit/Input/InputProps.d.ts +2 -6
  28. package/dist/ui-kit/Input/InputSnilsControl.js +2 -1
  29. package/dist/ui-kit/Input/InputSnilsControl.js.map +1 -1
  30. package/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
  31. package/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.js +1 -1
  32. package/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
  33. package/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
  34. package/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js +10 -0
  35. package/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js.map +1 -0
  36. package/dist/ui-kit/Select/Select.d.ts +4 -7
  37. package/dist/ui-kit/Select/Select.js +3 -4
  38. package/dist/ui-kit/Select/Select.js.map +1 -1
  39. package/dist/ui-kit/Select/SelectControl.d.ts +1 -8
  40. package/dist/ui-kit/Select/SelectControl.js +2 -1
  41. package/dist/ui-kit/Select/SelectControl.js.map +1 -1
  42. package/dist/utils/getRequiredLabel.d.ts +2 -0
  43. package/dist/utils/getRequiredLabel.js +5 -0
  44. package/dist/utils/getRequiredLabel.js.map +1 -0
  45. package/lib/model/DefaultControlType.d.ts +7 -0
  46. package/lib/model/DefaultControlType.js +2 -0
  47. package/lib/model/DefaultControlType.js.map +1 -0
  48. package/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -1
  49. package/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
  50. package/lib/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
  51. package/lib/ui-kit/DatePicker/DatePickerControl.js +2 -1
  52. package/lib/ui-kit/DatePicker/DatePickerControl.js.map +1 -1
  53. package/lib/ui-kit/FormField/Fields/SexField.js +5 -4
  54. package/lib/ui-kit/FormField/Fields/SexField.js.map +1 -1
  55. package/lib/ui-kit/FormField/Fields/VedField.js +1 -1
  56. package/lib/ui-kit/FormField/Fields/VedField.js.map +1 -1
  57. package/lib/ui-kit/Input/InputControl.js +2 -2
  58. package/lib/ui-kit/Input/InputControl.js.map +1 -1
  59. package/lib/ui-kit/Input/InputPhoneControl.js +2 -1
  60. package/lib/ui-kit/Input/InputPhoneControl.js.map +1 -1
  61. package/lib/ui-kit/Input/InputProps.d.ts +2 -6
  62. package/lib/ui-kit/Input/InputSnilsControl.js +2 -1
  63. package/lib/ui-kit/Input/InputSnilsControl.js.map +1 -1
  64. package/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
  65. package/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.js +1 -1
  66. package/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
  67. package/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
  68. package/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js +8 -0
  69. package/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js.map +1 -0
  70. package/lib/ui-kit/Select/Select.d.ts +4 -7
  71. package/lib/ui-kit/Select/Select.js +3 -4
  72. package/lib/ui-kit/Select/Select.js.map +1 -1
  73. package/lib/ui-kit/Select/SelectControl.d.ts +1 -8
  74. package/lib/ui-kit/Select/SelectControl.js +2 -1
  75. package/lib/ui-kit/Select/SelectControl.js.map +1 -1
  76. package/lib/utils/getRequiredLabel.d.ts +2 -0
  77. package/lib/utils/getRequiredLabel.js +2 -0
  78. package/lib/utils/getRequiredLabel.js.map +1 -0
  79. package/mobile/bundle/bundle.umd.js +18 -17
  80. package/mobile/bundle/bundle.umd.min.js +1 -1
  81. package/mobile/bundle/model/DefaultControlType.d.ts +7 -0
  82. package/mobile/bundle/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
  83. package/mobile/bundle/ui-kit/Input/InputProps.d.ts +2 -6
  84. package/mobile/bundle/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
  85. package/mobile/bundle/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
  86. package/mobile/bundle/ui-kit/Select/Select.d.ts +4 -7
  87. package/mobile/bundle/ui-kit/Select/SelectControl.d.ts +1 -8
  88. package/mobile/bundle/utils/getRequiredLabel.d.ts +2 -0
  89. package/mobile/dist/model/DefaultControlType.d.ts +7 -0
  90. package/mobile/dist/model/DefaultControlType.js +2 -0
  91. package/mobile/dist/model/DefaultControlType.js.map +1 -0
  92. package/mobile/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -1
  93. package/mobile/dist/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
  94. package/mobile/dist/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
  95. package/mobile/dist/ui-kit/DatePicker/DatePickerControl.js +2 -1
  96. package/mobile/dist/ui-kit/DatePicker/DatePickerControl.js.map +1 -1
  97. package/mobile/dist/ui-kit/FormField/Fields/SexField.js +5 -4
  98. package/mobile/dist/ui-kit/FormField/Fields/SexField.js.map +1 -1
  99. package/mobile/dist/ui-kit/FormField/Fields/VedField.js +1 -1
  100. package/mobile/dist/ui-kit/FormField/Fields/VedField.js.map +1 -1
  101. package/mobile/dist/ui-kit/Input/InputControl.js +2 -2
  102. package/mobile/dist/ui-kit/Input/InputControl.js.map +1 -1
  103. package/mobile/dist/ui-kit/Input/InputPhoneControl.js +2 -1
  104. package/mobile/dist/ui-kit/Input/InputPhoneControl.js.map +1 -1
  105. package/mobile/dist/ui-kit/Input/InputProps.d.ts +2 -6
  106. package/mobile/dist/ui-kit/Input/InputSnilsControl.js +2 -1
  107. package/mobile/dist/ui-kit/Input/InputSnilsControl.js.map +1 -1
  108. package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
  109. package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.js +1 -1
  110. package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
  111. package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
  112. package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js +10 -0
  113. package/mobile/dist/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js.map +1 -0
  114. package/mobile/dist/ui-kit/Select/Select.d.ts +4 -7
  115. package/mobile/dist/ui-kit/Select/Select.js +3 -4
  116. package/mobile/dist/ui-kit/Select/Select.js.map +1 -1
  117. package/mobile/dist/ui-kit/Select/SelectControl.d.ts +1 -8
  118. package/mobile/dist/ui-kit/Select/SelectControl.js +2 -1
  119. package/mobile/dist/ui-kit/Select/SelectControl.js.map +1 -1
  120. package/mobile/dist/utils/getRequiredLabel.d.ts +2 -0
  121. package/mobile/dist/utils/getRequiredLabel.js +5 -0
  122. package/mobile/dist/utils/getRequiredLabel.js.map +1 -0
  123. package/mobile/lib/model/DefaultControlType.d.ts +7 -0
  124. package/mobile/lib/model/DefaultControlType.js +2 -0
  125. package/mobile/lib/model/DefaultControlType.js.map +1 -0
  126. package/mobile/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js +1 -1
  127. package/mobile/lib/ui-kit/Calculator/renderBinaryRadioButtonGroup.js.map +1 -1
  128. package/mobile/lib/ui-kit/DatePicker/DatePickerControl.d.ts +3 -7
  129. package/mobile/lib/ui-kit/DatePicker/DatePickerControl.js +2 -1
  130. package/mobile/lib/ui-kit/DatePicker/DatePickerControl.js.map +1 -1
  131. package/mobile/lib/ui-kit/FormField/Fields/SexField.js +5 -4
  132. package/mobile/lib/ui-kit/FormField/Fields/SexField.js.map +1 -1
  133. package/mobile/lib/ui-kit/FormField/Fields/VedField.js +1 -1
  134. package/mobile/lib/ui-kit/FormField/Fields/VedField.js.map +1 -1
  135. package/mobile/lib/ui-kit/Input/InputControl.js +2 -2
  136. package/mobile/lib/ui-kit/Input/InputControl.js.map +1 -1
  137. package/mobile/lib/ui-kit/Input/InputPhoneControl.js +2 -1
  138. package/mobile/lib/ui-kit/Input/InputPhoneControl.js.map +1 -1
  139. package/mobile/lib/ui-kit/Input/InputProps.d.ts +2 -6
  140. package/mobile/lib/ui-kit/Input/InputSnilsControl.js +2 -1
  141. package/mobile/lib/ui-kit/Input/InputSnilsControl.js.map +1 -1
  142. package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.d.ts +3 -5
  143. package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.js +1 -1
  144. package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
  145. package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.d.ts +2 -0
  146. package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js +8 -0
  147. package/mobile/lib/ui-kit/RadioButtonGroup/RadioButtonGroupControl.js.map +1 -0
  148. package/mobile/lib/ui-kit/Select/Select.d.ts +4 -7
  149. package/mobile/lib/ui-kit/Select/Select.js +3 -4
  150. package/mobile/lib/ui-kit/Select/Select.js.map +1 -1
  151. package/mobile/lib/ui-kit/Select/SelectControl.d.ts +1 -8
  152. package/mobile/lib/ui-kit/Select/SelectControl.js +2 -1
  153. package/mobile/lib/ui-kit/Select/SelectControl.js.map +1 -1
  154. package/mobile/lib/utils/getRequiredLabel.d.ts +2 -0
  155. package/mobile/lib/utils/getRequiredLabel.js +2 -0
  156. package/mobile/lib/utils/getRequiredLabel.js.map +1 -0
  157. package/mobile/src/model/DefaultControlType.ts +7 -0
  158. package/mobile/src/ui-kit/Calculator/renderBinaryRadioButtonGroup.tsx +1 -1
  159. package/mobile/src/ui-kit/DatePicker/DatePickerControl.tsx +6 -14
  160. package/mobile/src/ui-kit/FormField/Fields/SexField.tsx +13 -11
  161. package/mobile/src/ui-kit/FormField/Fields/VedField.tsx +1 -1
  162. package/mobile/src/ui-kit/Input/InputControl.tsx +2 -3
  163. package/mobile/src/ui-kit/Input/InputPhoneControl.tsx +2 -1
  164. package/mobile/src/ui-kit/Input/InputProps.ts +2 -6
  165. package/mobile/src/ui-kit/Input/InputSnilsControl.tsx +2 -1
  166. package/mobile/src/ui-kit/RadioButtonGroup/RadioButtonGroup.tsx +9 -10
  167. package/mobile/src/ui-kit/RadioButtonGroup/RadioButtonGroupControl.tsx +18 -0
  168. package/mobile/src/ui-kit/Select/Select.tsx +8 -10
  169. package/mobile/src/ui-kit/Select/SelectControl.tsx +4 -10
  170. package/mobile/src/utils/getRequiredLabel.ts +4 -0
  171. package/package.json +1 -1
  172. package/src/model/DefaultControlType.ts +7 -0
  173. package/src/ui-kit/Calculator/renderBinaryRadioButtonGroup.tsx +1 -1
  174. package/src/ui-kit/DatePicker/DatePickerControl.tsx +6 -14
  175. package/src/ui-kit/FormField/Fields/SexField.tsx +13 -11
  176. package/src/ui-kit/FormField/Fields/VedField.tsx +1 -1
  177. package/src/ui-kit/Input/InputControl.tsx +2 -3
  178. package/src/ui-kit/Input/InputPhoneControl.tsx +2 -1
  179. package/src/ui-kit/Input/InputProps.ts +2 -6
  180. package/src/ui-kit/Input/InputSnilsControl.tsx +2 -1
  181. package/src/ui-kit/RadioButtonGroup/RadioButtonGroup.fixture.tsx +2 -2
  182. package/src/ui-kit/RadioButtonGroup/RadioButtonGroup.tsx +9 -10
  183. package/src/ui-kit/RadioButtonGroup/RadioButtonGroupControl.tsx +18 -0
  184. package/src/ui-kit/Select/Select.tsx +8 -10
  185. package/src/ui-kit/Select/SelectControl.tsx +4 -10
  186. 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
- interface SelectControlProps extends SelectProps {
6
- label?: string;
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={rest?.errors ? `${label}*` : label} />
9
+ <Select {...rest} valid={!error} label={getRequiredLabel({ label, errors })} />
16
10
  {renderErrorText(error)}
17
11
  </div>
18
12
  ),
@@ -0,0 +1,4 @@
1
+ import type { DefaultControlType } from '../model/DefaultControlType';
2
+
3
+ export const getRequiredLabel = ({ label, errors }: DefaultControlType) =>
4
+ label && errors ? `${label}*` : label;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.594",
3
+ "version": "0.14.595",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -0,0 +1,7 @@
1
+ export interface DefaultControlType {
2
+ className?: string;
3
+ label?: string;
4
+ error?: string;
5
+ errors?: string[];
6
+ placeholder?: string;
7
+ }
@@ -44,7 +44,7 @@ export const renderBinaryRadioButtonGroup = ({
44
44
  <RadioButtonGroup
45
45
  orientation={orientation}
46
46
  items={items}
47
- checkedItem={items[value ? 0 : 1].id}
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 { RadioButtonGroup, type RadioButtonItem } from '../../RadioButtonGroup/RadioButtonGroup';
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
- <RadioButtonGroup
15
- title="Пол"
16
- orientation="horizontal"
17
- items={SEX_TYPES}
18
- checkedItem={value}
19
- onChange={(_) => onChange && onChange(_)}
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
  });
@@ -25,7 +25,7 @@ export const VedField = JSX<CustomFieldProps>(({ field }) => {
25
25
  className="whitespace-normal"
26
26
  orientation="horizontal"
27
27
  items={VED_TYPES}
28
- checkedItem={value}
28
+ value={value}
29
29
  onChange={(_) => onChange && onChange(_)}
30
30
  />
31
31
  </div>
@@ -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={getLabel(errors, 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={rest?.errors ? `${label}*` : 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 LabelProps } from '../../model/HeadlineType';
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>, LabelProps {
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={rest?.errors ? `${label}*` : 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
- checkedItem={'Аннуитетный'}
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
- checkedItem={'Аннуитетный'}
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
- title,
28
+ label,
30
29
  items,
31
- checkedItem,
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
- {title ? (
39
- <div role="radiogroup" aria-label={title}>
37
+ {label ? (
38
+ <div role="radiogroup" aria-label={label}>
40
39
  <Text color="text-secondary-text" font="font-light">
41
- {title}
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={checkedItem === id}
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 LabelProps } from '../../model/HeadlineType';
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 type SelectProps = LabelProps & {
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 || options.length === 0;
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
- interface SelectControlProps extends SelectProps {
6
- label?: string;
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={rest?.errors ? `${label}*` : label} />
9
+ <Select {...rest} valid={!error} label={getRequiredLabel({ label, errors })} />
16
10
  {renderErrorText(error)}
17
11
  </div>
18
12
  ),
@@ -0,0 +1,4 @@
1
+ import type { DefaultControlType } from '../model/DefaultControlType';
2
+
3
+ export const getRequiredLabel = ({ label, errors }: DefaultControlType) =>
4
+ label && errors ? `${label}*` : label;