@ozen-ui/kit 0.8.0 → 0.9.1

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 (171) hide show
  1. package/FieldControl/package.json +5 -0
  2. package/FieldInput/package.json +5 -0
  3. package/Fieldset/package.json +5 -0
  4. package/__inner__/cjs/components/Backdrop/Backdrop.d.ts +2 -2
  5. package/__inner__/cjs/components/Breadcrumbs/types.d.ts +2 -2
  6. package/__inner__/cjs/components/DataList/DataList.d.ts +1 -1
  7. package/__inner__/cjs/components/DataList/DataListProvider.d.ts +5 -5
  8. package/__inner__/cjs/components/FieldControl/FieldControl.css +135 -0
  9. package/__inner__/cjs/components/FieldControl/FieldControl.d.ts +13 -0
  10. package/__inner__/cjs/components/FieldControl/FieldControl.js +82 -0
  11. package/__inner__/cjs/components/FieldControl/FieldControlContext.d.ts +15 -0
  12. package/__inner__/cjs/components/FieldControl/FieldControlContext.js +6 -0
  13. package/__inner__/cjs/components/FieldControl/index.d.ts +2 -0
  14. package/__inner__/cjs/components/FieldControl/index.js +5 -0
  15. package/__inner__/cjs/components/FieldHint/FieldHint.d.ts +6 -9
  16. package/__inner__/cjs/components/FieldHint/FieldHint.js +24 -4
  17. package/__inner__/cjs/components/FieldIcon/FieldIcon.css +1 -21
  18. package/__inner__/cjs/components/FieldIcon/FieldIcon.d.ts +8 -12
  19. package/__inner__/cjs/components/FieldIcon/FieldIcon.js +15 -4
  20. package/__inner__/cjs/components/FieldInput/FieldInput.d.ts +11 -0
  21. package/__inner__/cjs/components/FieldInput/FieldInput.js +55 -0
  22. package/__inner__/cjs/components/FieldInput/index.d.ts +1 -0
  23. package/__inner__/cjs/components/FieldInput/index.js +4 -0
  24. package/__inner__/cjs/components/FieldLabel/FieldLabel.d.ts +7 -5
  25. package/__inner__/cjs/components/FieldLabel/FieldLabel.js +40 -10
  26. package/__inner__/cjs/components/Fieldset/Fieldset.css +13 -0
  27. package/__inner__/cjs/components/Fieldset/Fieldset.d.ts +10 -0
  28. package/__inner__/cjs/components/Fieldset/Fieldset.js +15 -0
  29. package/__inner__/cjs/components/Fieldset/index.d.ts +1 -0
  30. package/__inner__/cjs/components/Fieldset/index.js +4 -0
  31. package/__inner__/cjs/components/FilePicker/FilePicker.css +48 -59
  32. package/__inner__/cjs/components/FilePicker/FilePicker.js +2 -1
  33. package/__inner__/cjs/components/Input/Input.css +9 -121
  34. package/__inner__/cjs/components/Input/Input.d.ts +1 -62
  35. package/__inner__/cjs/components/Input/Input.js +32 -53
  36. package/__inner__/cjs/components/Input/constants.d.ts +1 -0
  37. package/__inner__/cjs/components/Input/constants.js +4 -0
  38. package/__inner__/cjs/components/Input/index.d.ts +1 -0
  39. package/__inner__/cjs/components/Input/index.js +1 -0
  40. package/__inner__/cjs/components/Input/types.d.ts +71 -0
  41. package/__inner__/cjs/components/Input/types.js +13 -0
  42. package/__inner__/cjs/components/InputNumber/InputNumber.css +61 -74
  43. package/__inner__/cjs/components/InputNumber/InputNumber.js +2 -1
  44. package/__inner__/cjs/components/InputNumber/utils.d.ts +2 -2
  45. package/__inner__/cjs/components/Link/Link.d.ts +1 -1
  46. package/__inner__/cjs/components/List/components/ListItem/ListItem.d.ts +1 -2
  47. package/__inner__/cjs/components/List/components/ListItemButton/ListItemButton.d.ts +1 -2
  48. package/__inner__/cjs/components/List/types.d.ts +3 -3
  49. package/__inner__/cjs/components/Menu/components/MenuItem/MenuItem.d.ts +1 -1
  50. package/__inner__/cjs/components/Menu/components/MenuList/MenuList.d.ts +1 -1
  51. package/__inner__/cjs/components/Modal/Modal.d.ts +1 -1
  52. package/__inner__/cjs/components/Modal/Modal.js +1 -1
  53. package/__inner__/cjs/components/Modal/components/ModalConsumer.d.ts +2 -2
  54. package/__inner__/cjs/components/Pagination/helpers/createPaginationRange/createPaginationRange.d.ts +1 -1
  55. package/__inner__/cjs/components/Pagination/types.d.ts +5 -5
  56. package/__inner__/cjs/components/Popover/types.d.ts +4 -5
  57. package/__inner__/cjs/components/ProgressBar/ProgressBar.d.ts +2 -2
  58. package/__inner__/cjs/components/Select/Select.css +5 -16
  59. package/__inner__/cjs/components/Select/components/SelectInput/SelectInput.js +2 -1
  60. package/__inner__/cjs/components/Select/types.d.ts +3 -4
  61. package/__inner__/cjs/components/Slider/types.d.ts +1 -1
  62. package/__inner__/cjs/components/Snackbar/types.d.ts +1 -1
  63. package/__inner__/cjs/components/Tag/components/RemoveButton/RemoveButton.d.ts +1 -1
  64. package/__inner__/cjs/components/Textarea/Textarea.css +3 -107
  65. package/__inner__/cjs/components/Textarea/Textarea.d.ts +1 -59
  66. package/__inner__/cjs/components/Textarea/Textarea.js +8 -62
  67. package/__inner__/cjs/components/Textarea/components/TextareaConsumer.d.ts +3 -0
  68. package/__inner__/cjs/components/Textarea/components/TextareaConsumer.js +36 -0
  69. package/__inner__/cjs/components/Textarea/components/TextareaCounter.d.ts +7 -0
  70. package/__inner__/cjs/components/Textarea/components/TextareaCounter.js +25 -0
  71. package/__inner__/cjs/components/Textarea/components/index.d.ts +2 -0
  72. package/__inner__/cjs/components/Textarea/components/index.js +5 -0
  73. package/__inner__/cjs/components/Textarea/constants.d.ts +1 -0
  74. package/__inner__/cjs/components/Textarea/constants.js +4 -0
  75. package/__inner__/cjs/components/Textarea/index.d.ts +1 -0
  76. package/__inner__/cjs/components/Textarea/index.js +1 -0
  77. package/__inner__/cjs/components/Textarea/types.d.ts +69 -0
  78. package/__inner__/cjs/components/Textarea/types.js +4 -0
  79. package/__inner__/cjs/components/ThemeProvider/ThemeProvider.d.ts +2 -1
  80. package/__inner__/cjs/components/ThemeProvider/types.d.ts +2 -0
  81. package/__inner__/cjs/components/Tooltip/types.d.ts +1 -1
  82. package/__inner__/cjs/hooks/useMultiRef/useMultiRef.d.ts +2 -3
  83. package/__inner__/cjs/types/ResponsiveValue.d.ts +1 -1
  84. package/__inner__/cjs/utils/isKey.d.ts +2 -2
  85. package/__inner__/cjs/utils/polymorphicComponentWithRef.d.ts +0 -1
  86. package/__inner__/esm/components/Backdrop/Backdrop.d.ts +2 -2
  87. package/__inner__/esm/components/Backdrop/Backdrop.js +1 -1
  88. package/__inner__/esm/components/Breadcrumbs/types.d.ts +2 -2
  89. package/__inner__/esm/components/DataList/DataList.d.ts +1 -1
  90. package/__inner__/esm/components/DataList/DataListProvider.d.ts +5 -5
  91. package/__inner__/esm/components/FieldControl/FieldControl.css +135 -0
  92. package/__inner__/esm/components/FieldControl/FieldControl.d.ts +13 -0
  93. package/__inner__/esm/components/FieldControl/FieldControl.js +79 -0
  94. package/__inner__/esm/components/FieldControl/FieldControlContext.d.ts +15 -0
  95. package/__inner__/esm/components/FieldControl/FieldControlContext.js +2 -0
  96. package/__inner__/esm/components/FieldControl/index.d.ts +2 -0
  97. package/__inner__/esm/components/FieldControl/index.js +2 -0
  98. package/__inner__/esm/components/FieldHint/FieldHint.d.ts +6 -9
  99. package/__inner__/esm/components/FieldHint/FieldHint.js +25 -5
  100. package/__inner__/esm/components/FieldIcon/FieldIcon.css +1 -21
  101. package/__inner__/esm/components/FieldIcon/FieldIcon.d.ts +8 -12
  102. package/__inner__/esm/components/FieldIcon/FieldIcon.js +16 -5
  103. package/__inner__/esm/components/FieldInput/FieldInput.d.ts +11 -0
  104. package/__inner__/esm/components/FieldInput/FieldInput.js +52 -0
  105. package/__inner__/esm/components/FieldInput/index.d.ts +1 -0
  106. package/__inner__/esm/components/FieldInput/index.js +1 -0
  107. package/__inner__/esm/components/FieldLabel/FieldLabel.d.ts +7 -5
  108. package/__inner__/esm/components/FieldLabel/FieldLabel.js +39 -8
  109. package/__inner__/esm/components/Fieldset/Fieldset.css +13 -0
  110. package/__inner__/esm/components/Fieldset/Fieldset.d.ts +10 -0
  111. package/__inner__/esm/components/Fieldset/Fieldset.js +12 -0
  112. package/__inner__/esm/components/Fieldset/index.d.ts +1 -0
  113. package/__inner__/esm/components/Fieldset/index.js +1 -0
  114. package/__inner__/esm/components/FilePicker/FilePicker.css +48 -59
  115. package/__inner__/esm/components/FilePicker/FilePicker.js +2 -1
  116. package/__inner__/esm/components/Input/Input.css +9 -121
  117. package/__inner__/esm/components/Input/Input.d.ts +1 -62
  118. package/__inner__/esm/components/Input/Input.js +33 -54
  119. package/__inner__/esm/components/Input/constants.d.ts +1 -0
  120. package/__inner__/esm/components/Input/constants.js +1 -0
  121. package/__inner__/esm/components/Input/index.d.ts +1 -0
  122. package/__inner__/esm/components/Input/index.js +1 -0
  123. package/__inner__/esm/components/Input/types.d.ts +71 -0
  124. package/__inner__/esm/components/Input/types.js +10 -0
  125. package/__inner__/esm/components/InputNumber/InputNumber.css +61 -74
  126. package/__inner__/esm/components/InputNumber/InputNumber.js +2 -1
  127. package/__inner__/esm/components/InputNumber/utils.d.ts +2 -2
  128. package/__inner__/esm/components/Link/Link.d.ts +1 -1
  129. package/__inner__/esm/components/List/components/ListItem/ListItem.d.ts +1 -2
  130. package/__inner__/esm/components/List/components/ListItemButton/ListItemButton.d.ts +1 -2
  131. package/__inner__/esm/components/List/types.d.ts +3 -3
  132. package/__inner__/esm/components/Menu/components/MenuItem/MenuItem.d.ts +1 -1
  133. package/__inner__/esm/components/Menu/components/MenuList/MenuList.d.ts +1 -1
  134. package/__inner__/esm/components/Modal/Modal.d.ts +1 -1
  135. package/__inner__/esm/components/Modal/Modal.js +1 -1
  136. package/__inner__/esm/components/Modal/components/ModalConsumer.d.ts +2 -2
  137. package/__inner__/esm/components/Pagination/helpers/createPaginationRange/createPaginationRange.d.ts +1 -1
  138. package/__inner__/esm/components/Pagination/types.d.ts +5 -5
  139. package/__inner__/esm/components/Popover/types.d.ts +4 -5
  140. package/__inner__/esm/components/ProgressBar/ProgressBar.d.ts +2 -2
  141. package/__inner__/esm/components/ProgressBar/ProgressBar.js +1 -1
  142. package/__inner__/esm/components/Select/Select.css +5 -16
  143. package/__inner__/esm/components/Select/components/SelectInput/SelectInput.js +2 -1
  144. package/__inner__/esm/components/Select/types.d.ts +3 -4
  145. package/__inner__/esm/components/Slider/types.d.ts +1 -1
  146. package/__inner__/esm/components/Snackbar/types.d.ts +1 -1
  147. package/__inner__/esm/components/Tag/components/RemoveButton/RemoveButton.d.ts +1 -1
  148. package/__inner__/esm/components/Textarea/Textarea.css +3 -107
  149. package/__inner__/esm/components/Textarea/Textarea.d.ts +1 -59
  150. package/__inner__/esm/components/Textarea/Textarea.js +9 -63
  151. package/__inner__/esm/components/Textarea/components/TextareaConsumer.d.ts +3 -0
  152. package/__inner__/esm/components/Textarea/components/TextareaConsumer.js +32 -0
  153. package/__inner__/esm/components/Textarea/components/TextareaCounter.d.ts +7 -0
  154. package/__inner__/esm/components/Textarea/components/TextareaCounter.js +21 -0
  155. package/__inner__/esm/components/Textarea/components/index.d.ts +2 -0
  156. package/__inner__/esm/components/Textarea/components/index.js +2 -0
  157. package/__inner__/esm/components/Textarea/constants.d.ts +1 -0
  158. package/__inner__/esm/components/Textarea/constants.js +1 -0
  159. package/__inner__/esm/components/Textarea/index.d.ts +1 -0
  160. package/__inner__/esm/components/Textarea/index.js +1 -0
  161. package/__inner__/esm/components/Textarea/types.d.ts +69 -0
  162. package/__inner__/esm/components/Textarea/types.js +1 -0
  163. package/__inner__/esm/components/ThemeProvider/ThemeProvider.d.ts +2 -1
  164. package/__inner__/esm/components/ThemeProvider/types.d.ts +2 -0
  165. package/__inner__/esm/components/Tooltip/Tooltip.js +1 -1
  166. package/__inner__/esm/components/Tooltip/types.d.ts +1 -1
  167. package/__inner__/esm/hooks/useMultiRef/useMultiRef.d.ts +2 -3
  168. package/__inner__/esm/types/ResponsiveValue.d.ts +1 -1
  169. package/__inner__/esm/utils/isKey.d.ts +2 -2
  170. package/__inner__/esm/utils/polymorphicComponentWithRef.d.ts +0 -1
  171. package/package.json +1 -1
@@ -1,14 +1,45 @@
1
- import { forwardRef } from 'react';
2
- import * as React from 'react';
3
- import { cn } from '../../utils/classname';
1
+ import { __assign, __read } from "tslib";
4
2
  import './FieldLabel.css';
5
- export var fieldLabelSizeVariant = ['2xs', 'xs', 's', 'm', 'l'];
3
+ import React, { forwardRef, useContext } from 'react';
4
+ import { useIsomorphicEffect } from '../../hooks/useIsomorphicEffect';
5
+ import { cn } from '../../utils/classname';
6
+ import { FieldControlContext } from '../FieldControl';
7
+ export var FIELD_LABEL_DEFAULT_TAG = 'span';
6
8
  export var cnFieldLabel = cn('FieldLabel');
7
9
  export var FieldLabel = forwardRef(function (_a, ref) {
8
- var focused = _a.focused, children = _a.children, filled = _a.filled, shrink = _a.shrink, required = _a.required, disabled = _a.disabled, className = _a.className, size = _a.size;
9
- return (React.createElement("span", { className: cnFieldLabel({ filled: filled, shrink: shrink, focused: focused, disabled: disabled, size: size }, [
10
- className,
11
- ]), ref: ref },
10
+ var focusedProp = _a.focused, children = _a.children, filledProp = _a.filled, shrink = _a.shrink, requiredProp = _a.required, disabledProp = _a.disabled, className = _a.className, sizeProp = _a.size;
11
+ var context = useContext(FieldControlContext);
12
+ var _b = __read(context, 2), fieldControl = _b[0], setFieldControl = _b[1];
13
+ var Tag = FIELD_LABEL_DEFAULT_TAG;
14
+ var size = sizeProp;
15
+ var required = requiredProp;
16
+ var disabled = disabledProp;
17
+ var focused = focusedProp;
18
+ var filled = filledProp;
19
+ useIsomorphicEffect(function () {
20
+ setFieldControl(function (prevState) { return (__assign(__assign({}, prevState), { label: children })); });
21
+ }, [children]);
22
+ if (!children) {
23
+ return null;
24
+ }
25
+ if (fieldControl) {
26
+ if (size === undefined && fieldControl.size) {
27
+ size = fieldControl.size;
28
+ }
29
+ if (required === undefined && fieldControl.required) {
30
+ required = fieldControl.required;
31
+ }
32
+ if (disabled === undefined && fieldControl.disabled) {
33
+ disabled = fieldControl.disabled;
34
+ }
35
+ if (focused === undefined && fieldControl.focused) {
36
+ focused = fieldControl.focused;
37
+ }
38
+ if (filled === undefined && fieldControl.filled) {
39
+ filled = fieldControl.filled;
40
+ }
41
+ }
42
+ return (React.createElement(Tag, { className: cnFieldLabel({ filled: filled, shrink: shrink, focused: focused, disabled: disabled, size: size, required: required }, [className]), ref: ref },
12
43
  children,
13
44
  " ",
14
45
  required && React.createElement("sup", null, "*")));
@@ -0,0 +1,13 @@
1
+ .Fieldset {
2
+ position: absolute;
3
+ inset-block-end: 0;
4
+ inset-inline-end: 0;
5
+ inset-block-start: 0;
6
+ inset-inline-start: 0;
7
+ margin: 0;
8
+ padding: 0;
9
+ pointer-events: none;
10
+ border-radius: var(--border-radius-xs);
11
+ border: var(--textfield-border-width) solid var(--textfield-border-color);
12
+ transition: border var(--transition-default);
13
+ }
@@ -0,0 +1,10 @@
1
+ import './Fieldset.css';
2
+ import React from 'react';
3
+ import type { ComponentPropsWithRef, ComponentRef } from 'react';
4
+ export declare const FIELDSET_DEFAULT_TAG = "fieldset";
5
+ export type FieldsetRef = ComponentRef<typeof FIELDSET_DEFAULT_TAG>;
6
+ export type FieldsetProps = ComponentPropsWithRef<typeof FIELDSET_DEFAULT_TAG>;
7
+ export declare const cnFieldset: import("@bem-react/classname").ClassNameFormatter;
8
+ export declare const Fieldset: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, "ref"> & {
9
+ ref?: ((instance: HTMLFieldSetElement | null) => void) | React.RefObject<HTMLFieldSetElement> | null | undefined;
10
+ }, "ref"> & React.RefAttributes<HTMLFieldSetElement>>;
@@ -0,0 +1,12 @@
1
+ import { __assign, __rest } from "tslib";
2
+ import './Fieldset.css';
3
+ import React, { forwardRef } from 'react';
4
+ import { cn } from '../../utils/classname';
5
+ export var FIELDSET_DEFAULT_TAG = 'fieldset';
6
+ export var cnFieldset = cn('Fieldset');
7
+ export var Fieldset = forwardRef(function (_a, ref) {
8
+ var className = _a.className, other = __rest(_a, ["className"]);
9
+ var Tag = FIELDSET_DEFAULT_TAG;
10
+ return React.createElement(Tag, __assign({ className: cnFieldset({}, [className]) }, other, { ref: ref }));
11
+ });
12
+ Fieldset.displayName = 'Fieldset';
@@ -0,0 +1 @@
1
+ export * from './Fieldset';
@@ -0,0 +1 @@
1
+ export * from './Fieldset';
@@ -1,9 +1,10 @@
1
1
  /* stylelint-disable */
2
2
  .FilePicker {
3
- --file-picker-color: var(--color-content-tertiary);
4
- --file-picker-background-color: var(--color-background-primary);
5
- --file-picker-border-width: var(--border-width-s);
6
- --file-picker-border-color: var(--color-border-main);
3
+ --textfield-color: var(--color-content-tertiary);
4
+ --textfield-background-color: var(--color-background-primary);
5
+ --textfield-border-width: var(--border-width-s);
6
+ --textfield-border-color: var(--color-border-main);
7
+ font: var(--textfield-input-font);
7
8
  display: inline-flex;
8
9
  vertical-align: top;
9
10
  flex-direction: column;
@@ -11,14 +12,14 @@
11
12
  .FilePicker-Body {
12
13
  position: relative;
13
14
  display: flex;
14
- -moz-column-gap: var(--file-picker-input-gap);
15
- column-gap: var(--file-picker-input-gap);
15
+ -moz-column-gap: var(--textfield-input-gap);
16
+ column-gap: var(--textfield-input-gap);
16
17
  align-items: center;
17
18
  box-sizing: border-box;
18
- padding: 0 var(--file-picker-gutter-x);
19
- background-color: var(--file-picker-background-color);
19
+ padding: 0 var(--textfield-gutter-x);
20
+ background-color: var(--textfield-background-color);
20
21
  transition: background-color var(--transition-slow);
21
- color: var(--file-picker-color);
22
+ color: var(--textfield-color);
22
23
  border-radius: var(--border-radius-xs);
23
24
  cursor: pointer;
24
25
  }
@@ -42,9 +43,8 @@
42
43
  padding: 0;
43
44
  background: none;
44
45
  box-sizing: border-box;
45
- color: var(--file-picker-color);
46
- block-size: var(--file-picker-input-height);
47
- font: var(--file-picker-input-font);
46
+ color: var(--textfield-color);
47
+ block-size: var(--textfield-input-height);
48
48
  }
49
49
  .FilePicker-Input {
50
50
  inset-block-end: 0;
@@ -57,85 +57,74 @@
57
57
  .FilePicker-Input:focus + .FilePicker-Placeholder {
58
58
  opacity: 1;
59
59
  }
60
- .FilePicker-Fieldset {
61
- position: absolute;
62
- inset: 0;
63
- margin: 0;
64
- padding: 0;
65
- pointer-events: none;
66
- border-radius: var(--border-radius-xs);
67
- border: var(--file-picker-border-width) solid
68
- var(--file-picker-border-color);
69
- transition: border var(--transition-default);
70
- }
71
60
  .FilePicker_size_2xs {
72
- --file-picker-gutter-x: 12px;
73
- --file-picker-input-height: 32px;
74
- --file-picker-input-font: var(--typography-text-2xs-font);
75
- --file-picker-input-padding: 8px 0 8px;
76
- --file-picker-input-gap: var(--space-s);
61
+ --textfield-gutter-x: 12px;
62
+ --textfield-input-height: 32px;
63
+ --textfield-input-font: var(--typography-text-2xs-font);
64
+ --textfield-input-padding: 8px 0 8px;
65
+ --textfield-input-gap: var(--space-s);
77
66
  }
78
67
  .FilePicker_size_xs {
79
- --file-picker-gutter-x: 12px;
80
- --file-picker-input-height: 40px;
81
- --file-picker-input-font: var(--typography-text-xs-font);
82
- --file-picker-input-padding: 19px 0 4px;
83
- --file-picker-input-gap: var(--space-s);
68
+ --textfield-gutter-x: 12px;
69
+ --textfield-input-height: 40px;
70
+ --textfield-input-font: var(--typography-text-xs-font);
71
+ --textfield-input-padding: 19px 0 4px;
72
+ --textfield-input-gap: var(--space-s);
84
73
  }
85
74
  .FilePicker_size_s {
86
- --file-picker-gutter-x: 16px;
87
- --file-picker-input-height: 48px;
88
- --file-picker-input-font: var(--typography-text-s-font);
89
- --file-picker-input-padding: 21px 0 6px;
90
- --file-picker-input-gap: var(--space-m);
75
+ --textfield-gutter-x: 16px;
76
+ --textfield-input-height: 48px;
77
+ --textfield-input-font: var(--typography-text-s-font);
78
+ --textfield-input-padding: 21px 0 6px;
79
+ --textfield-input-gap: var(--space-m);
91
80
  }
92
81
  .FilePicker_size_m {
93
- --file-picker-gutter-x: 20px;
94
- --file-picker-input-height: 56px;
95
- --file-picker-input-font: var(--typography-text-m-font);
96
- --file-picker-input-padding: 24px 0 6px;
97
- --file-picker-input-gap: var(--space-m);
82
+ --textfield-gutter-x: 20px;
83
+ --textfield-input-height: 56px;
84
+ --textfield-input-font: var(--typography-text-m-font);
85
+ --textfield-input-padding: 24px 0 6px;
86
+ --textfield-input-gap: var(--space-m);
98
87
  }
99
88
  .FilePicker_size_l {
100
- --file-picker-gutter-x: 24px;
101
- --file-picker-input-height: 64px;
102
- --file-picker-input-font: var(--typography-text-l-font);
103
- --file-picker-input-padding: 26px 0 6px;
104
- --file-picker-input-gap: var(--space-l);
89
+ --textfield-gutter-x: 24px;
90
+ --textfield-input-height: 64px;
91
+ --textfield-input-font: var(--typography-text-l-font);
92
+ --textfield-input-padding: 26px 0 6px;
93
+ --textfield-input-gap: var(--space-l);
105
94
  }
106
95
  .FilePicker_fullWidth {
107
96
  inline-size: 100%;
108
97
  }
109
98
  .FilePicker_hasValue {
110
- --file-picker-color: var(--color-content-primary);
99
+ --textfield-color: var(--color-content-primary);
111
100
  }
112
101
  .FilePicker_hasLabel .FilePicker-Placeholder {
113
102
  opacity: 0;
114
103
  }
115
104
  .FilePicker_hasLabel .FilePicker-FileName,
116
105
  .FilePicker_hasLabel .FilePicker-Placeholder {
117
- padding: var(--file-picker-input-padding);
118
- font: var(--file-picker-input-font);
106
+ padding: var(--textfield-input-padding);
107
+ font: var(--textfield-input-font);
119
108
  }
120
109
  .FilePicker:hover {
121
- --file-picker-border-color: var(--color-border-main-hover);
110
+ --textfield-border-color: var(--color-border-main-hover);
122
111
  }
123
112
  .FilePicker_focused,
124
113
  .FilePicker_focused:hover {
125
- --file-picker-border-width: var(--border-width-m);
126
- --file-picker-background-color: var(--color-background-main);
127
- --file-picker-border-color: var(--color-border-action);
114
+ --textfield-border-width: var(--border-width-m);
115
+ --textfield-background-color: var(--color-background-main);
116
+ --textfield-border-color: var(--color-border-action);
128
117
  }
129
118
  .FilePicker_error,
130
119
  .FilePicker_error.FilePicker:hover,
131
120
  .FilePicker_error.FilePicker_focused,
132
121
  .FilePicker_error.FilePicker_focused:hover {
133
- --file-picker-border-color: var(--color-border-error);
122
+ --textfield-border-color: var(--color-border-error);
134
123
  }
135
124
  .FilePicker_disabled {
136
- --file-picker-border-color: var(--color-border-disabled);
137
- --file-picker-background-color: var(--color-background-disabled);
138
- --file-picker-color: var(--color-content-secondary);
125
+ --textfield-border-color: var(--color-border-disabled);
126
+ --textfield-background-color: var(--color-background-disabled);
127
+ --textfield-color: var(--color-content-secondary);
139
128
  pointer-events: none;
140
129
  cursor: default;
141
130
  }
@@ -9,6 +9,7 @@ import { isKey } from '../../utils/isKey';
9
9
  import { FieldHint } from '../FieldHint';
10
10
  import { FieldIcon } from '../FieldIcon';
11
11
  import { FieldLabel } from '../FieldLabel';
12
+ import { Fieldset } from '../Fieldset';
12
13
  import { IconButton } from '../IconButton';
13
14
  import { FILE_PICKER_DEFAULT_SIZE, FILE_PICKER_DEFAULT_PLACEHOLDER, FILE_PICKER_DEFAULT_DISABLED, FILE_PICKER_DEFAULT_REQUIRED, FILE_PICKER_DEFAULT_FULL_WIDTH, FILE_PICKER_DEFAULT_DISABLE_TRUNCATE, FILE_PICKER_DEFAULT_VALUE_RENDERER, FILE_PICKER_DEFAULT_MULTIPLE, FILE_PICKER_DEFAULT_MULTIPLE_CLEAR_TEXT, } from './constants';
14
15
  export var cnFilePicker = cn('FilePicker');
@@ -69,7 +70,7 @@ export var FilePicker = forwardRef(function (inProps, ref) {
69
70
  (fileList === null || fileList === void 0 ? void 0 : fileList.length) ? (React.createElement("span", { className: cnFilePicker('FileName') }, renderValue(fileList, disableTruncate))) : (React.createElement("span", { "aria-placeholder": placeholder, className: cnFilePicker('Placeholder') }, placeholder))),
70
71
  !!(fileList === null || fileList === void 0 ? void 0 : fileList.length) && onClearProp && (React.createElement(IconButton, { tabIndex: -1, variant: "function", "aria-label": clearText, ref: clearRef, onClick: onClear, size: size, icon: CloseIcon })),
71
72
  React.createElement(FieldIcon, { className: cnFilePicker('RenderRight'), icon: renderRight, size: size }),
72
- React.createElement("fieldset", { className: cnFilePicker('Fieldset') })),
73
+ React.createElement(Fieldset, { className: cnFilePicker('Fieldset') })),
73
74
  React.createElement(FieldHint, { size: size, error: error, disabled: disabled }, hint)));
74
75
  });
75
76
  FilePicker.displayName = 'FilePicker';
@@ -1,30 +1,3 @@
1
- /* stylelint-disable */
2
- .Input {
3
- --textfield-color: var(--color-content-primary);
4
- --textfield-background-color: var(--color-background-primary);
5
- --textfield-border-width: var(--border-width-s);
6
- --textfield-border-color: var(--color-border-main);
7
- cursor: text;
8
- display: inline-flex;
9
- vertical-align: top;
10
- flex-direction: column;
11
- }
12
- .Input > * {
13
- cursor: text;
14
- }
15
- .Input-Fieldset {
16
- position: absolute;
17
- inset-block-end: 0;
18
- inset-inline-end: 0;
19
- inset-block-start: 0;
20
- inset-inline-start: 0;
21
- margin: 0;
22
- padding: 0;
23
- pointer-events: none;
24
- border-radius: var(--border-radius-xs);
25
- border: var(--textfield-border-width) solid var(--textfield-border-color);
26
- transition: border var(--transition-default);
27
- }
28
1
  .Input-Body {
29
2
  position: relative;
30
3
  display: flex;
@@ -38,133 +11,48 @@
38
11
  color: var(--textfield-color);
39
12
  border-radius: var(--border-radius-xs);
40
13
  }
41
- .Input-FieldContainer {
14
+ .Input-FieldContainer {
42
15
  inline-size: 100%;
43
16
  position: relative;
44
17
  }
45
- .Input-Field {
18
+ .Input-Field {
46
19
  border: none;
47
20
  outline: none;
48
21
  display: flex;
49
22
  inline-size: 100%;
50
- padding: 0;
23
+ padding: var(--textfield-input-padding);
51
24
  background: none;
52
25
  color: var(--textfield-color);
53
26
  box-sizing: border-box;
54
27
  block-size: var(--textfield-input-height);
55
- font: var(--textfield-input-font);
28
+ font: inherit;
56
29
  }
57
- .Input-Field::placeholder {
30
+ .Input-Field::placeholder {
58
31
  opacity: 1;
59
32
  color: var(--color-content-tertiary);
60
33
  }
61
- .Input-Field:-webkit-autofill,
34
+ .Input-Field:-webkit-autofill,
62
35
  .Input-Field:-webkit-autofill:hover,
63
36
  .Input-Field:-webkit-autofill:focus {
64
37
  box-shadow: 0 0 0 1000px var(--textfield-background-color) inset !important;
65
38
  background-color: transparent !important;
66
39
  -webkit-text-fill-color: var(--color-content-info-dark);
67
40
  }
68
- .Input-Field::-webkit-outer-spin-button,
41
+ .Input-Field::-webkit-outer-spin-button,
69
42
  .Input-Field::-webkit-inner-spin-button {
70
43
  -webkit-appearance: none;
71
44
  appearance: none;
72
45
  margin: 0;
73
46
  }
74
- .Input-Field::-webkit-calendar-picker-indicator {
47
+ .Input-Field::-webkit-calendar-picker-indicator {
75
48
  opacity: 0;
76
49
  position: absolute;
77
50
  inset-block-start: 50%;
78
51
  transform: translateY(-50%);
79
52
  cursor: pointer;
80
53
  }
81
- .Input-Field[type='number'] {
54
+ .Input-Field[type='number'] {
82
55
  -webkit-appearance: textfield;
83
56
  -moz-appearance: textfield;
84
57
  appearance: textfield;
85
58
  }
86
- .Input_size_2xs {
87
- --textfield-gutter-x: 12px;
88
- --textfield-input-height: 32px;
89
- --textfield-input-font: var(--typography-text-2xs-font);
90
- --textfield-input-padding: 8px 0 8px;
91
- --textfield-input-gap: var(--space-s);
92
- }
93
- .Input_size_2xs .Input-Field::-webkit-calendar-picker-indicator {
94
- inset-inline-end: -25px;
95
- }
96
- .Input_size_xs {
97
- --textfield-gutter-x: 12px;
98
- --textfield-input-height: 40px;
99
- --textfield-input-font: var(--typography-text-xs-font);
100
- --textfield-input-padding: 19px 0 4px;
101
- --textfield-input-gap: var(--space-s);
102
- }
103
- .Input_size_xs .Input-Field::-webkit-calendar-picker-indicator {
104
- inset-inline-end: -25px;
105
- }
106
- .Input_size_s {
107
- --textfield-gutter-x: 16px;
108
- --textfield-input-height: 48px;
109
- --textfield-input-font: var(--typography-text-s-font);
110
- --textfield-input-padding: 21px 0 6px;
111
- --textfield-input-gap: var(--space-m);
112
- }
113
- .Input_size_s .Input-Field::-webkit-calendar-picker-indicator {
114
- inset-inline-end: -30px;
115
- }
116
- .Input_size_m {
117
- --textfield-gutter-x: 20px;
118
- --textfield-input-height: 56px;
119
- --textfield-input-font: var(--typography-text-m-font);
120
- --textfield-input-padding: 24px 0 6px;
121
- --textfield-input-gap: var(--space-m);
122
- }
123
- .Input_size_m .Input-Field::-webkit-calendar-picker-indicator {
124
- inset-inline-end: -34px;
125
- }
126
- .Input_size_l {
127
- --textfield-gutter-x: 24px;
128
- --textfield-input-height: 64px;
129
- --textfield-input-font: var(--typography-text-l-font);
130
- --textfield-input-padding: 26px 0 6px;
131
- --textfield-input-gap: var(--space-l);
132
- }
133
- .Input_size_l .Input-Field::-webkit-calendar-picker-indicator {
134
- inset-inline-end: -39px;
135
- }
136
- .Input_fullWidth {
137
- inline-size: 100%;
138
- }
139
- .Input_hasLabel .Input-Field {
140
- padding: var(--textfield-input-padding);
141
- font: var(--textfield-input-font);
142
- }
143
- .Input_hasLabel .Input-Field::placeholder {
144
- opacity: 0;
145
- }
146
- .Input_hasLabel .Input-Field:focus::placeholder {
147
- opacity: 1;
148
- }
149
- .Input:hover {
150
- --textfield-border-color: var(--color-border-main-hover);
151
- }
152
- .Input_focused,
153
- .Input_focused:hover {
154
- --textfield-border-width: var(--border-width-m);
155
- --textfield-background-color: var(--color-background-main);
156
- --textfield-border-color: var(--color-border-action);
157
- }
158
- .Input_error,
159
- .Input_error.Input:hover,
160
- .Input_error.Input_focused,
161
- .Input_error.Input_focused:hover {
162
- --textfield-border-color: var(--color-border-error);
163
- }
164
- .Input_disabled {
165
- --textfield-border-color: var(--color-border-disabled);
166
- --textfield-background-color: var(--color-background-disabled);
167
- --textfield-color: var(--color-content-secondary);
168
- pointer-events: none;
169
- cursor: default;
170
- }
@@ -1,66 +1,5 @@
1
1
  import './Input.css';
2
2
  import React from 'react';
3
- import type { HTMLAttributes, InputHTMLAttributes, Ref } from 'react';
4
- import type { FormElementSizeVariant } from '../../types/FormElementSizeVariant';
5
- import { type FieldIconProps } from '../FieldIcon';
6
- import { type FieldLabelProps } from '../FieldLabel';
7
- export declare const inputTypeVariant: readonly ["number", "date", "datetime-local", "time", "text", "tel", "password", "email"];
8
- export type InputTypeVariant = (typeof inputTypeVariant)[number];
9
- export type InputSizeVariant = FormElementSizeVariant;
10
- type InputElement = InputHTMLAttributes<HTMLInputElement>;
11
- export type InputProps = {
12
- /** Атрибут id для элемента input */
13
- id?: string;
14
- /** Атрибут name для элемента input */
15
- name?: string;
16
- /** Лейбл */
17
- label?: string;
18
- /** Размер компонента */
19
- size?: InputSizeVariant;
20
- /** Подсказка. Отображается, когда вариант не выбран */
21
- placeholder?: string;
22
- /** Если {true} устанавливает автофокус */
23
- autoFocus?: boolean;
24
- /** Если {true} переводит поле в состояние ошибки */
25
- error?: boolean;
26
- /** Если {true} растягивает поле на всю ширину */
27
- fullWidth?: boolean;
28
- /** Дополнительное описание к полю */
29
- hint?: string | null | undefined;
30
- /** Атрибут type для элемента input */
31
- type?: InputTypeVariant;
32
- /** Если {true} делает элемент неактивным */
33
- disabled?: boolean;
34
- /** Если {true} делает элемент обязательным к заполнению */
35
- required?: boolean;
36
- /** Минимальное количество символов разрешенных для ввода */
37
- minLength?: InputElement['minLength'];
38
- /** Максимальное количество символов разрешенных для ввода */
39
- maxLength?: InputElement['maxLength'];
40
- /** Текст или иконка слева */
41
- renderLeft?: FieldIconProps['icon'];
42
- /** Текст или иконка справа */
43
- renderRight?: FieldIconProps['icon'];
44
- /** Выбранное значение */
45
- value?: InputElement['value'];
46
- /** Значение по умолчанию (неконтролируемый компонент) */
47
- defaultValue?: InputElement['defaultValue'];
48
- /** Обработчик события на изменение значения поля */
49
- onChange?: InputElement['onChange'];
50
- /** Ссылка на элемент input */
51
- inputRef?: Ref<HTMLInputElement>;
52
- /** Свойства элемента input */
53
- inputProps?: InputElement & {
54
- 'data-testid'?: string;
55
- };
56
- /** Ссылка на FieldLabel */
57
- labelRef?: FieldLabelProps['ref'];
58
- /** Свойства FieldLabel */
59
- labelProps?: FieldLabelProps;
60
- /** Ссылка на корневой DOM-элемент компонента */
61
- ref?: Ref<HTMLDivElement>;
62
- 'data-testid'?: string;
63
- } & Omit<HTMLAttributes<HTMLDivElement>, 'value' | 'defaultValue' | 'onChange'>;
3
+ import type { InputProps } from './index';
64
4
  export declare const cnInput: import("@bem-react/classname").ClassNameFormatter;
65
5
  export declare const Input: React.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
66
- export {};
@@ -1,71 +1,50 @@
1
- import { __assign, __read, __rest } from "tslib";
1
+ import { __assign, __rest } from "tslib";
2
2
  import './Input.css';
3
- import React, { useState, useCallback, useRef, forwardRef } from 'react';
3
+ import React, { forwardRef, useRef } from 'react';
4
+ import { useEventListener } from '../../hooks/useEventListener';
4
5
  import { useMultiRef } from '../../hooks/useMultiRef';
5
6
  import { useThemeProps } from '../../hooks/useThemeProps';
6
7
  import { cn } from '../../utils/classname';
8
+ import { FieldControl } from '../FieldControl';
7
9
  import { FieldHint } from '../FieldHint';
8
10
  import { FieldIcon } from '../FieldIcon';
11
+ import { FieldInput } from '../FieldInput';
9
12
  import { FieldLabel } from '../FieldLabel';
10
- export var inputTypeVariant = [
11
- 'number',
12
- 'date',
13
- 'datetime-local',
14
- 'time',
15
- 'text',
16
- 'tel',
17
- 'password',
18
- 'email',
19
- ];
13
+ import { Fieldset } from '../Fieldset';
14
+ import { INPUT_DEFAULT_SIZE } from './constants';
20
15
  export var cnInput = cn('Input');
21
16
  export var Input = forwardRef(function (inProps, ref) {
22
17
  var props = useThemeProps({
23
18
  props: inProps,
24
19
  name: 'Input'
25
20
  });
26
- var _a = props.size, size = _a === void 0 ? 'm' : _a, label = props.label, error = props.error, autoFocus = props.autoFocus, placeholder = props.placeholder, id = props.id, name = props.name, type = props.type, renderLeft = props.renderLeft, renderRight = props.renderRight, inputRef = props.inputRef, fullWidth = props.fullWidth, disabled = props.disabled, hint = props.hint, required = props.required, className = props.className, inputProps = props.inputProps, valueProp = props.value, defaultValue = props.defaultValue, onChange = props.onChange, labelRef = props.labelRef, labelProps = props.labelProps, other = __rest(props, ["size", "label", "error", "autoFocus", "placeholder", "id", "name", "type", "renderLeft", "renderRight", "inputRef", "fullWidth", "disabled", "hint", "required", "className", "inputProps", "value", "defaultValue", "onChange", "labelRef", "labelProps"]);
27
- var isControlled = typeof valueProp !== 'undefined';
28
- var _b = __read(useState(), 2), focused = _b[0], setFocused = _b[1];
29
- var fieldRef = useRef(null);
30
- var _c = __read(useState(defaultValue), 2), valueState = _c[0], setValueState = _c[1];
31
- var filled = isControlled
32
- ? !!valueProp || valueProp === 0
33
- : !!valueState || valueState === 0;
34
- var handleChange = useCallback(function (e) {
35
- if (disabled)
36
- return;
37
- var value = e.target.value;
38
- if (!isControlled) {
39
- setValueState(value);
21
+ var _a = props.size, size = _a === void 0 ? INPUT_DEFAULT_SIZE : _a, label = props.label, error = props.error, autoFocus = props.autoFocus, placeholder = props.placeholder, id = props.id, name = props.name, type = props.type, renderLeft = props.renderLeft, renderRight = props.renderRight, inputRef = props.inputRef, fullWidth = props.fullWidth, disabled = props.disabled, hint = props.hint, required = props.required, className = props.className, inputProps = props.inputProps, value = props.value, defaultValue = props.defaultValue, onChange = props.onChange, labelProps = props.labelProps, labelRef = props.labelRef, other = __rest(props, ["size", "label", "error", "autoFocus", "placeholder", "id", "name", "type", "renderLeft", "renderRight", "inputRef", "fullWidth", "disabled", "hint", "required", "className", "inputProps", "value", "defaultValue", "onChange", "labelProps", "labelRef"]);
22
+ var labelInnerRef = useRef(null);
23
+ var fieldInnerRef = useRef(null);
24
+ /* Хук useEventListener необходим для того, чтобы при нажатии на кнопку мыши
25
+ * внутри HTML-элемента label - фокус не переходил на body или на цель нажатия кнопки мыши.
26
+ * Если же нажатие кнопки происходит на самом HTML-элементе input, то мы ничего не делаем,
27
+ * так как в противном случае мы сломаем возможность выделять текст для копирования.
28
+ */
29
+ useEventListener({
30
+ element: labelInnerRef,
31
+ eventName: 'mousedown',
32
+ handler: function (e) {
33
+ var _a;
34
+ if (e.target !== fieldInnerRef.current) {
35
+ e.preventDefault();
36
+ (_a = fieldInnerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
37
+ }
40
38
  }
41
- onChange === null || onChange === void 0 ? void 0 : onChange(e);
42
- }, [onChange, isControlled, disabled]);
43
- var handleFocus = useCallback(function (e) {
44
- var _a;
45
- setFocused(true);
46
- (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
47
- }, [inputProps === null || inputProps === void 0 ? void 0 : inputProps.onFocus]);
48
- var handleBlur = useCallback(function (e) {
49
- var _a;
50
- setFocused(false);
51
- (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
52
- }, [inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur]);
53
- return (React.createElement("div", __assign({}, other, { ref: ref, className: cnInput({
54
- fullWidth: fullWidth,
55
- size: size,
56
- error: error,
57
- disabled: disabled,
58
- required: required,
59
- hasLabel: !!label,
60
- focused: focused
61
- }, [className]) }),
62
- React.createElement("label", { className: cnInput('Body') },
63
- React.createElement(FieldIcon, { className: cnInput('RenderLeft'), icon: renderLeft, size: size }),
39
+ });
40
+ return (React.createElement(FieldControl, __assign({ size: size, error: error, disabled: disabled, required: required, fullWidth: fullWidth }, other, { ref: ref, className: cnInput({}, [className]) }),
41
+ React.createElement("label", { className: cnInput('Body'), ref: labelInnerRef },
42
+ React.createElement(FieldIcon, { icon: renderLeft }),
64
43
  React.createElement("div", { className: cnInput('FieldContainer') },
65
- label && (React.createElement(FieldLabel, __assign({ filled: filled, focused: focused, required: required, disabled: disabled, size: size }, labelProps, { className: cnInput('Label', [labelProps === null || labelProps === void 0 ? void 0 : labelProps.className]), ref: labelRef }), label)),
66
- React.createElement("input", __assign({ id: id, name: name, autoFocus: autoFocus, disabled: disabled, value: valueProp, type: type, defaultValue: defaultValue, required: required, placeholder: placeholder }, inputProps, { className: cnInput('Field', { filled: filled }, [inputProps === null || inputProps === void 0 ? void 0 : inputProps.className]), onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, ref: useMultiRef([inputRef, fieldRef]) }))),
67
- React.createElement(FieldIcon, { className: cnInput('RenderRight'), icon: renderRight, size: size }),
68
- React.createElement("fieldset", { className: cnInput('Fieldset') })),
69
- React.createElement(FieldHint, { size: size, error: error, disabled: disabled }, hint)));
44
+ React.createElement(FieldLabel, __assign({}, labelProps, { ref: labelRef || (labelProps === null || labelProps === void 0 ? void 0 : labelProps.ref), className: labelProps === null || labelProps === void 0 ? void 0 : labelProps.className }), label),
45
+ React.createElement(FieldInput, __assign({ id: id, name: name, autoFocus: autoFocus, value: value, type: type, defaultValue: defaultValue, placeholder: placeholder, onChange: onChange }, inputProps, { className: cnInput('Field', [inputProps === null || inputProps === void 0 ? void 0 : inputProps.className]), ref: useMultiRef([inputRef || (inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref), fieldInnerRef]) }))),
46
+ React.createElement(FieldIcon, { icon: renderRight }),
47
+ React.createElement(Fieldset, null)),
48
+ React.createElement(FieldHint, null, hint)));
70
49
  });
71
50
  Input.displayName = 'Input';
@@ -0,0 +1 @@
1
+ export declare const INPUT_DEFAULT_SIZE = "m";
@@ -0,0 +1 @@
1
+ export var INPUT_DEFAULT_SIZE = 'm';
@@ -1 +1,2 @@
1
1
  export * from './Input';
2
+ export * from './types';