@ozen-ui/kit 0.40.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/__inner__/cjs/components/Autocomplete/helper.d.ts +2 -0
- package/__inner__/cjs/components/Autocomplete/types.d.ts +2 -2
- package/__inner__/cjs/components/FieldControl/FieldControl.css +25 -19
- package/__inner__/cjs/components/FieldLabel/FieldLabel.css +6 -6
- package/__inner__/cjs/components/Fieldset/Fieldset.css +1 -1
- package/__inner__/cjs/components/FilePicker/FilePicker.css +38 -98
- package/__inner__/cjs/components/FilePicker/FilePicker.d.ts +71 -1
- package/__inner__/cjs/components/FilePicker/FilePicker.js +26 -25
- package/__inner__/cjs/components/FilePicker/types.d.ts +19 -7
- package/__inner__/cjs/components/IconButtonNext/IconButton.css +1 -0
- package/__inner__/cjs/components/Input/Input.css +2 -2
- package/__inner__/cjs/components/Input/Input.js +2 -2
- package/__inner__/cjs/components/Input/types.d.ts +3 -0
- package/__inner__/cjs/components/InputNumber/InputNumber.css +2 -2
- package/__inner__/cjs/components/InputNumber/InputNumber.js +2 -2
- package/__inner__/cjs/components/InputNumber/types.d.ts +4 -1
- package/__inner__/cjs/components/Pagination/Pagination.css +9 -9
- package/__inner__/cjs/components/Pagination/Pagination.d.ts +2 -2
- package/__inner__/cjs/components/Pagination/Pagination.js +21 -11
- package/__inner__/cjs/components/Pagination/components/PaginationItem/PaginationItem.css +19 -13
- package/__inner__/cjs/components/Pagination/components/PaginationItem/PaginationItem.js +7 -6
- package/__inner__/cjs/components/Pagination/constants.d.ts +4 -0
- package/__inner__/cjs/components/Pagination/constants.js +5 -1
- package/__inner__/cjs/components/Pagination/helpers/getItemAriaLabel/getItemAriaLabel.js +4 -4
- package/__inner__/cjs/components/Pagination/types.d.ts +6 -3
- package/__inner__/cjs/components/Select/Select.css +2 -2
- package/__inner__/cjs/components/Select/Select.js +2 -2
- package/__inner__/cjs/components/Select/components/SelectInput/SelectInput.js +2 -2
- package/__inner__/cjs/components/Select/components/SelectInput/types.d.ts +5 -1
- package/__inner__/cjs/components/Select/types.d.ts +2 -2
- package/__inner__/cjs/components/Textarea/Textarea.css +2 -2
- package/__inner__/cjs/components/Textarea/Textarea.js +2 -2
- package/__inner__/cjs/components/Textarea/components/TextareaConsumer.js +2 -2
- package/__inner__/cjs/components/Textarea/types.d.ts +4 -1
- package/__inner__/cjs/locale/locale.js +58 -0
- package/__inner__/esm/components/Autocomplete/Autocomplete.js +2 -2
- package/__inner__/esm/components/Autocomplete/helper.d.ts +2 -0
- package/__inner__/esm/components/Autocomplete/types.d.ts +2 -2
- package/__inner__/esm/components/FieldControl/FieldControl.css +25 -19
- package/__inner__/esm/components/FieldLabel/FieldLabel.css +6 -6
- package/__inner__/esm/components/Fieldset/Fieldset.css +1 -1
- package/__inner__/esm/components/FilePicker/FilePicker.css +38 -98
- package/__inner__/esm/components/FilePicker/FilePicker.d.ts +71 -1
- package/__inner__/esm/components/FilePicker/FilePicker.js +28 -27
- package/__inner__/esm/components/FilePicker/types.d.ts +19 -7
- package/__inner__/esm/components/IconButtonNext/IconButton.css +1 -0
- package/__inner__/esm/components/Input/Input.css +2 -2
- package/__inner__/esm/components/Input/Input.js +2 -2
- package/__inner__/esm/components/Input/types.d.ts +3 -0
- package/__inner__/esm/components/InputNumber/InputNumber.css +2 -2
- package/__inner__/esm/components/InputNumber/InputNumber.js +5 -5
- package/__inner__/esm/components/InputNumber/types.d.ts +4 -1
- package/__inner__/esm/components/Pagination/Pagination.css +9 -9
- package/__inner__/esm/components/Pagination/Pagination.d.ts +2 -2
- package/__inner__/esm/components/Pagination/Pagination.js +23 -13
- package/__inner__/esm/components/Pagination/components/PaginationItem/PaginationItem.css +19 -13
- package/__inner__/esm/components/Pagination/components/PaginationItem/PaginationItem.js +8 -7
- package/__inner__/esm/components/Pagination/constants.d.ts +4 -0
- package/__inner__/esm/components/Pagination/constants.js +4 -0
- package/__inner__/esm/components/Pagination/helpers/getItemAriaLabel/getItemAriaLabel.js +4 -4
- package/__inner__/esm/components/Pagination/types.d.ts +6 -3
- package/__inner__/esm/components/Select/Select.css +2 -2
- package/__inner__/esm/components/Select/Select.js +3 -3
- package/__inner__/esm/components/Select/components/SelectInput/SelectInput.js +2 -2
- package/__inner__/esm/components/Select/components/SelectInput/types.d.ts +5 -1
- package/__inner__/esm/components/Select/types.d.ts +2 -2
- package/__inner__/esm/components/Textarea/Textarea.css +2 -2
- package/__inner__/esm/components/Textarea/Textarea.js +2 -2
- package/__inner__/esm/components/Textarea/components/TextareaConsumer.js +2 -2
- package/__inner__/esm/components/Textarea/types.d.ts +4 -1
- package/__inner__/esm/locale/locale.js +58 -0
- package/package.json +4 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.enUS = exports.kkKZ = exports.ruRU = void 0;
|
|
4
|
+
var constants_1 = require("../components/Pagination/constants");
|
|
4
5
|
exports.ruRU = {
|
|
5
6
|
defaultProps: {
|
|
6
7
|
Autocomplete: {
|
|
@@ -31,6 +32,25 @@ exports.ruRU = {
|
|
|
31
32
|
incrementButtonText: 'Увеличить',
|
|
32
33
|
decrementButtonText: 'Уменьшить',
|
|
33
34
|
},
|
|
35
|
+
Pagination: {
|
|
36
|
+
'aria-label': 'Навигация по страницам',
|
|
37
|
+
getItemAriaLabel: function (_a) {
|
|
38
|
+
var page = _a.page, type = _a.type, selected = _a.selected;
|
|
39
|
+
if (type === constants_1.NEXT) {
|
|
40
|
+
return 'Перейти на следующую страницу';
|
|
41
|
+
}
|
|
42
|
+
if (type === constants_1.PREVIOUS) {
|
|
43
|
+
return 'Перейти на предыдущую страницу';
|
|
44
|
+
}
|
|
45
|
+
if (selected) {
|
|
46
|
+
return "\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 ".concat(page);
|
|
47
|
+
}
|
|
48
|
+
if (type === constants_1.PAGE) {
|
|
49
|
+
return "\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043D\u0430 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0443 ".concat(page);
|
|
50
|
+
}
|
|
51
|
+
return '';
|
|
52
|
+
},
|
|
53
|
+
},
|
|
34
54
|
},
|
|
35
55
|
};
|
|
36
56
|
exports.kkKZ = {
|
|
@@ -63,6 +83,25 @@ exports.kkKZ = {
|
|
|
63
83
|
incrementButtonText: 'Үлкейту',
|
|
64
84
|
decrementButtonText: 'Азайту',
|
|
65
85
|
},
|
|
86
|
+
Pagination: {
|
|
87
|
+
'aria-label': 'Беттерді шарлау',
|
|
88
|
+
getItemAriaLabel: function (_a) {
|
|
89
|
+
var page = _a.page, type = _a.type, selected = _a.selected;
|
|
90
|
+
if (type === constants_1.NEXT) {
|
|
91
|
+
return 'Келесі бетке өтіңіз';
|
|
92
|
+
}
|
|
93
|
+
if (type === constants_1.PREVIOUS) {
|
|
94
|
+
return 'Алдыңғы бетке өтіңіз';
|
|
95
|
+
}
|
|
96
|
+
if (selected) {
|
|
97
|
+
return "".concat(page, " \u0431\u0435\u0442");
|
|
98
|
+
}
|
|
99
|
+
if (type === constants_1.PAGE) {
|
|
100
|
+
return "".concat(page, "-\u0431\u0435\u0442\u043A\u0435 \u04E9\u0442\u0456\u04A3\u0456\u0437");
|
|
101
|
+
}
|
|
102
|
+
return '';
|
|
103
|
+
},
|
|
104
|
+
},
|
|
66
105
|
},
|
|
67
106
|
};
|
|
68
107
|
exports.enUS = {
|
|
@@ -95,5 +134,24 @@ exports.enUS = {
|
|
|
95
134
|
incrementButtonText: 'Increment',
|
|
96
135
|
decrementButtonText: 'Decrement',
|
|
97
136
|
},
|
|
137
|
+
Pagination: {
|
|
138
|
+
'aria-label': 'Pagination navigation',
|
|
139
|
+
getItemAriaLabel: function (_a) {
|
|
140
|
+
var page = _a.page, type = _a.type, selected = _a.selected;
|
|
141
|
+
if (type === constants_1.NEXT) {
|
|
142
|
+
return 'Go to next page';
|
|
143
|
+
}
|
|
144
|
+
if (type === constants_1.PREVIOUS) {
|
|
145
|
+
return 'Go to previous page';
|
|
146
|
+
}
|
|
147
|
+
if (selected) {
|
|
148
|
+
return "Page ".concat(page);
|
|
149
|
+
}
|
|
150
|
+
if (type === constants_1.PAGE) {
|
|
151
|
+
return "Go to page ".concat(page);
|
|
152
|
+
}
|
|
153
|
+
return '';
|
|
154
|
+
},
|
|
155
|
+
},
|
|
98
156
|
},
|
|
99
157
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __assign, __read, __rest, __spreadArray } from "tslib";
|
|
2
2
|
import './Autocomplete.css';
|
|
3
|
-
import React, { useEffect, useRef,
|
|
3
|
+
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { useControlled } from '../../hooks/useControlled';
|
|
5
5
|
import { useMutableRef } from '../../hooks/useMutableRef';
|
|
6
6
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
@@ -9,7 +9,7 @@ import { isKeys } from '../../utils/isKeys';
|
|
|
9
9
|
import { DataList, DataListOption } from '../DataList';
|
|
10
10
|
import { Input } from '../Input';
|
|
11
11
|
import { AutocompleteLoading, AutocompleteNoOptions, AutocompleteRenderRight, } from './components';
|
|
12
|
-
import {
|
|
12
|
+
import { AUTOCOMPLETE_DEFAULT_ALLOW_CUSTOM_VALUE, AUTOCOMPLETE_DEFAULT_AUTOFOCUS, AUTOCOMPLETE_DEFAULT_DISABLE_CLEAR_BUTTON, AUTOCOMPLETE_DEFAULT_DISABLE_CLOSE_ON_SELECT, AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_CHEVRON, AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_EMPTY_OPTIONS_LIST, AUTOCOMPLETE_DEFAULT_DISABLED, AUTOCOMPLETE_DEFAULT_FULLWIDTH, AUTOCOMPLETE_DEFAULT_REQUIRED, AUTOCOMPLETE_DEFAULT_SIZE, } from './constants';
|
|
13
13
|
import { withDefaultGetters } from './helper';
|
|
14
14
|
export var cnAutocomplete = cn('Autocomplete');
|
|
15
15
|
function AutocompleteRender(inProps, ref) {
|
|
@@ -80,6 +80,7 @@ export declare function withDefaultGetters<OPTION>(props: AutocompleteProps<OPTI
|
|
|
80
80
|
} & {
|
|
81
81
|
'data-testid'?: string | undefined;
|
|
82
82
|
}) | undefined;
|
|
83
|
+
hintProps?: Omit<import("../FieldHint").FieldHintProps, "children"> | undefined;
|
|
83
84
|
} & {
|
|
84
85
|
open?: boolean | undefined;
|
|
85
86
|
defaultOpen?: undefined;
|
|
@@ -176,6 +177,7 @@ export declare function withDefaultGetters<OPTION>(props: AutocompleteProps<OPTI
|
|
|
176
177
|
} & {
|
|
177
178
|
'data-testid'?: string | undefined;
|
|
178
179
|
}) | undefined;
|
|
180
|
+
hintProps?: Omit<import("../FieldHint").FieldHintProps, "children"> | undefined;
|
|
179
181
|
} & {
|
|
180
182
|
open?: undefined;
|
|
181
183
|
defaultOpen?: boolean | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChangeEvent, ReactElement, ReactNode, SyntheticEvent } from 'react';
|
|
2
2
|
import type { FormElementSizeVariant } from '../../types/FormElementSizeVariant';
|
|
3
3
|
import type { DataListProps } from '../DataList';
|
|
4
4
|
import type { InputProps } from '../Input';
|
|
@@ -31,7 +31,7 @@ type AutocompleteOpenUncontrolledProps = {
|
|
|
31
31
|
/** Состояние открытие по умолчанию (неконтролируемый компонент) */
|
|
32
32
|
defaultOpen?: boolean;
|
|
33
33
|
};
|
|
34
|
-
type AutocompleteInputProps = Pick<InputProps, 'placeholder' | 'autoFocus' | 'fullWidth' | 'disabled' | 'label' | 'required' | 'style' | 'error' | 'hint' | 'renderLeft' | 'renderRight' | 'className' | 'inputProps' | 'onKeyDown'>;
|
|
34
|
+
type AutocompleteInputProps = Pick<InputProps, 'placeholder' | 'autoFocus' | 'fullWidth' | 'disabled' | 'label' | 'required' | 'style' | 'error' | 'hint' | 'renderLeft' | 'renderRight' | 'className' | 'inputProps' | 'hintProps' | 'onKeyDown'>;
|
|
35
35
|
type AutocompleteDataListProps = Partial<Omit<DataListProps, 'onClose' | 'open' | 'anchorRef' | 'multiple' | 'selected' | 'onSelect'>>;
|
|
36
36
|
export type AutocompleteProps<OPTION = AutocompleteDefaultOption> = {
|
|
37
37
|
/** Список вариантов выбора (опции) */
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
/* stylelint-disable */
|
|
2
2
|
.FieldControl {
|
|
3
3
|
--textfield-color: var(--color-content-primary);
|
|
4
|
-
--textfield-background-color: var(--color-background-primary);
|
|
5
4
|
--textfield-border-width: var(--border-width-s);
|
|
6
5
|
--textfield-border-color: var(--color-border-main);
|
|
6
|
+
--textfield-placeholder-color: var(--color-content-tertiary);
|
|
7
|
+
--textfield-background-color: var(--color-background-primary);
|
|
7
8
|
cursor: text;
|
|
8
|
-
display: inline-flex;
|
|
9
9
|
vertical-align: top;
|
|
10
|
+
display: inline-flex;
|
|
10
11
|
flex-direction: column;
|
|
11
12
|
}
|
|
12
13
|
.FieldControl > * {
|
|
13
14
|
cursor: text;
|
|
14
15
|
}
|
|
15
16
|
.FieldControl_size_2xs {
|
|
16
|
-
--textfield-gutter-x: 12px;
|
|
17
|
-
--textfield-input-height: 32px;
|
|
18
17
|
--textfield-input-padding: 8px 0;
|
|
19
18
|
--textfield-input-gap: var(--spacing-2xs);
|
|
19
|
+
--textfield-gutter-x: var(--control-padding-xs);
|
|
20
|
+
--textfield-border-radius: var(--border-radius-xs);
|
|
21
|
+
--textfield-input-height: var(--control-height-2xs);
|
|
20
22
|
|
|
21
23
|
font: var(--typography-text-2xs-font);
|
|
22
24
|
|
|
@@ -25,10 +27,11 @@
|
|
|
25
27
|
text-transform: var(--typography-text-2xs-text_transform, none);
|
|
26
28
|
}
|
|
27
29
|
.FieldControl_size_xs {
|
|
28
|
-
--textfield-gutter-x: 12px;
|
|
29
|
-
--textfield-input-height: 40px;
|
|
30
30
|
--textfield-input-padding: 12px 0;
|
|
31
31
|
--textfield-input-gap: var(--spacing-2xs);
|
|
32
|
+
--textfield-gutter-x: var(--control-padding-xs);
|
|
33
|
+
--textfield-border-radius: var(--border-radius-xs);
|
|
34
|
+
--textfield-input-height: var(--control-height-xs);
|
|
32
35
|
|
|
33
36
|
font: var(--typography-text-xs-font);
|
|
34
37
|
|
|
@@ -37,10 +40,11 @@
|
|
|
37
40
|
text-transform: var(--typography-text-xs-text_transform, none);
|
|
38
41
|
}
|
|
39
42
|
.FieldControl_size_s {
|
|
40
|
-
--textfield-gutter-x: 16px;
|
|
41
|
-
--textfield-input-height: 48px;
|
|
42
43
|
--textfield-input-padding: 14px 0;
|
|
43
44
|
--textfield-input-gap: var(--spacing-xs);
|
|
45
|
+
--textfield-gutter-x: var(--control-padding-s);
|
|
46
|
+
--textfield-border-radius: var(--border-radius-xs);
|
|
47
|
+
--textfield-input-height: var(--control-height-s);
|
|
44
48
|
|
|
45
49
|
font: var(--typography-text-s-font);
|
|
46
50
|
|
|
@@ -49,10 +53,11 @@
|
|
|
49
53
|
text-transform: var(--typography-text-s-text_transform, none);
|
|
50
54
|
}
|
|
51
55
|
.FieldControl_size_m {
|
|
52
|
-
--textfield-gutter-x: 20px;
|
|
53
|
-
--textfield-input-height: 56px;
|
|
54
56
|
--textfield-input-padding: 16px 0;
|
|
55
57
|
--textfield-input-gap: var(--spacing-xs);
|
|
58
|
+
--textfield-gutter-x: var(--control-padding-m);
|
|
59
|
+
--textfield-border-radius: var(--border-radius-xs);
|
|
60
|
+
--textfield-input-height: var(--control-height-m);
|
|
56
61
|
|
|
57
62
|
font: var(--typography-text-m-font);
|
|
58
63
|
|
|
@@ -61,10 +66,11 @@
|
|
|
61
66
|
text-transform: var(--typography-text-m-text_transform, none);
|
|
62
67
|
}
|
|
63
68
|
.FieldControl_size_l {
|
|
64
|
-
--textfield-gutter-x: 24px;
|
|
65
|
-
--textfield-input-height: 64px;
|
|
66
69
|
--textfield-input-padding: 18px 0;
|
|
67
70
|
--textfield-input-gap: var(--spacing-s);
|
|
71
|
+
--textfield-gutter-x: var(--control-padding-l);
|
|
72
|
+
--textfield-border-radius: var(--border-radius-xs);
|
|
73
|
+
--textfield-input-height: var(--control-height-l);
|
|
68
74
|
|
|
69
75
|
font: var(--typography-text-l-font);
|
|
70
76
|
|
|
@@ -76,16 +82,16 @@
|
|
|
76
82
|
--textfield-input-padding: 8px 0 8px;
|
|
77
83
|
}
|
|
78
84
|
.FieldControl_hasLabel.FieldControl_size_xs {
|
|
79
|
-
--textfield-input-padding:
|
|
85
|
+
--textfield-input-padding: 20px 0 4px;
|
|
80
86
|
}
|
|
81
87
|
.FieldControl_hasLabel.FieldControl_size_s {
|
|
82
|
-
--textfield-input-padding:
|
|
88
|
+
--textfield-input-padding: 22px 0 6px;
|
|
83
89
|
}
|
|
84
90
|
.FieldControl_hasLabel.FieldControl_size_m {
|
|
85
|
-
--textfield-input-padding: 24px 0
|
|
91
|
+
--textfield-input-padding: 24px 0 8px;
|
|
86
92
|
}
|
|
87
93
|
.FieldControl_hasLabel.FieldControl_size_l {
|
|
88
|
-
--textfield-input-padding:
|
|
94
|
+
--textfield-input-padding: 28px 0 8px;
|
|
89
95
|
}
|
|
90
96
|
.FieldControl_hasLabel .FieldInput::placeholder {
|
|
91
97
|
opacity: 0;
|
|
@@ -102,8 +108,8 @@
|
|
|
102
108
|
.FieldControl_focused,
|
|
103
109
|
.FieldControl_focused:hover {
|
|
104
110
|
--textfield-border-width: var(--border-width-m);
|
|
105
|
-
--textfield-background-color: var(--color-background-main);
|
|
106
111
|
--textfield-border-color: var(--color-border-action);
|
|
112
|
+
--textfield-background-color: var(--color-background-main);
|
|
107
113
|
}
|
|
108
114
|
.FieldControl_error,
|
|
109
115
|
.FieldControl_error.FieldControl:hover,
|
|
@@ -112,9 +118,9 @@
|
|
|
112
118
|
--textfield-border-color: var(--color-border-error);
|
|
113
119
|
}
|
|
114
120
|
.FieldControl_disabled {
|
|
121
|
+
--textfield-color: var(--color-content-secondary);
|
|
115
122
|
--textfield-border-color: var(--color-border-disabled);
|
|
116
123
|
--textfield-background-color: var(--color-background-disabled);
|
|
117
|
-
--textfield-color: var(--color-content-secondary);
|
|
118
|
-
pointer-events: none;
|
|
119
124
|
cursor: default;
|
|
125
|
+
pointer-events: none;
|
|
120
126
|
}
|
|
@@ -48,22 +48,22 @@
|
|
|
48
48
|
.FieldLabel_size_s {
|
|
49
49
|
--field-label-font: var(--typography-text-s-font);
|
|
50
50
|
--field-label-scaled: var(--typography-text-3xs-font);
|
|
51
|
-
--field-label-translate_y: -
|
|
51
|
+
--field-label-translate_y: -8px;
|
|
52
52
|
--field-label-top: 14px;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.FieldLabel_size_m {
|
|
56
56
|
--field-label-font: var(--typography-text-m-font);
|
|
57
|
-
--field-label-scaled: var(--typography-text-
|
|
58
|
-
--field-label-translate_y: -
|
|
59
|
-
--field-label-top:
|
|
57
|
+
--field-label-scaled: var(--typography-text-xs-font);
|
|
58
|
+
--field-label-translate_y: -8px;
|
|
59
|
+
--field-label-top: 16px;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
.FieldLabel_size_l {
|
|
63
63
|
--field-label-font: var(--typography-text-l-font);
|
|
64
64
|
--field-label-scaled: var(--typography-text-s-font);
|
|
65
|
-
--field-label-translate_y: -
|
|
66
|
-
--field-label-top:
|
|
65
|
+
--field-label-translate_y: -10px;
|
|
66
|
+
--field-label-top: 18px;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
.FieldLabel_disabled {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
margin: 0;
|
|
5
5
|
padding: 0;
|
|
6
6
|
pointer-events: none;
|
|
7
|
-
border-radius: var(--border-radius
|
|
7
|
+
border-radius: var(--textfield-border-radius);
|
|
8
8
|
border: var(--textfield-border-width) solid var(--textfield-border-color);
|
|
9
9
|
transition: border var(--transition-default);
|
|
10
10
|
}
|
|
@@ -1,130 +1,70 @@
|
|
|
1
|
-
/* stylelint-disable */
|
|
2
|
-
.FilePicker {
|
|
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);
|
|
8
|
-
display: inline-flex;
|
|
9
|
-
vertical-align: top;
|
|
10
|
-
flex-direction: column;
|
|
11
|
-
}
|
|
12
1
|
.FilePicker-Body {
|
|
13
|
-
position: relative;
|
|
14
2
|
display: flex;
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
cursor: pointer;
|
|
4
|
+
position: relative;
|
|
17
5
|
align-items: center;
|
|
18
6
|
box-sizing: border-box;
|
|
7
|
+
color: var(--textfield-color);
|
|
19
8
|
padding: 0 var(--textfield-gutter-x);
|
|
9
|
+
-moz-column-gap: var(--textfield-input-gap);
|
|
10
|
+
column-gap: var(--textfield-input-gap);
|
|
11
|
+
border-radius: var(--textfield-border-radius);
|
|
20
12
|
background-color: var(--textfield-background-color);
|
|
21
13
|
transition: background-color var(--transition-slow);
|
|
22
|
-
color: var(--textfield-color);
|
|
23
|
-
border-radius: var(--border-radius-xs);
|
|
24
|
-
cursor: pointer;
|
|
25
14
|
}
|
|
26
|
-
.FilePicker-FieldContainer {
|
|
15
|
+
.FilePicker-FieldContainer {
|
|
16
|
+
overflow: hidden;
|
|
27
17
|
inline-size: 100%;
|
|
28
18
|
min-inline-size: 0;
|
|
29
19
|
position: relative;
|
|
30
|
-
overflow: hidden;
|
|
31
20
|
}
|
|
32
|
-
.FilePicker-FileName,
|
|
21
|
+
.FilePicker-FileName,
|
|
33
22
|
.FilePicker-Placeholder {
|
|
34
|
-
|
|
35
|
-
white-space: nowrap;
|
|
36
|
-
overflow: hidden;
|
|
23
|
+
padding: 0;
|
|
37
24
|
border: none;
|
|
38
|
-
outline: none;
|
|
39
|
-
position: relative;
|
|
40
25
|
display: flex;
|
|
41
|
-
|
|
26
|
+
outline: none;
|
|
27
|
+
overflow: hidden;
|
|
42
28
|
inline-size: 100%;
|
|
43
|
-
padding: 0;
|
|
44
29
|
background: none;
|
|
30
|
+
position: relative;
|
|
31
|
+
align-items: center;
|
|
32
|
+
white-space: nowrap;
|
|
45
33
|
box-sizing: border-box;
|
|
46
|
-
|
|
34
|
+
text-overflow: ellipsis;
|
|
47
35
|
block-size: var(--textfield-input-height);
|
|
48
36
|
}
|
|
49
|
-
.FilePicker-
|
|
37
|
+
.FilePicker-Placeholder {
|
|
38
|
+
color: var(--textfield-placeholder-color);
|
|
39
|
+
}
|
|
40
|
+
.FilePicker-Input {
|
|
41
|
+
opacity: 0;
|
|
42
|
+
inline-size: 100%;
|
|
50
43
|
inset-block-end: 0;
|
|
51
|
-
inset-inline-start: 0;
|
|
52
44
|
position: absolute;
|
|
53
|
-
opacity: 0;
|
|
54
45
|
pointer-events: none;
|
|
55
|
-
inline-
|
|
46
|
+
inset-inline-start: 0;
|
|
56
47
|
}
|
|
57
|
-
.FilePicker-Input:focus + .FilePicker-Placeholder {
|
|
48
|
+
.FilePicker-Input:focus + .FilePicker-Placeholder {
|
|
58
49
|
opacity: 1;
|
|
59
50
|
}
|
|
60
|
-
.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
--textfield-input-font: var(--typography-text-2xs-font);
|
|
64
|
-
--textfield-input-padding: 8px 0 8px;
|
|
65
|
-
--textfield-input-gap: var(--spacing-2xs);
|
|
66
|
-
}
|
|
67
|
-
.FilePicker_size_xs {
|
|
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(--spacing-2xs);
|
|
73
|
-
}
|
|
74
|
-
.FilePicker_size_s {
|
|
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(--spacing-xs);
|
|
80
|
-
}
|
|
81
|
-
.FilePicker_size_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(--spacing-xs);
|
|
87
|
-
}
|
|
88
|
-
.FilePicker_size_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(--spacing-s);
|
|
94
|
-
}
|
|
95
|
-
.FilePicker_fullWidth {
|
|
96
|
-
inline-size: 100%;
|
|
51
|
+
.FilePicker-ClearButton {
|
|
52
|
+
visibility: hidden;
|
|
53
|
+
transition: visibility var(--transition-default);
|
|
97
54
|
}
|
|
98
|
-
.
|
|
99
|
-
|
|
55
|
+
.FilePicker-ClearButton_visibility {
|
|
56
|
+
visibility: visible;
|
|
57
|
+
}
|
|
58
|
+
.FilePicker-RenderRight {
|
|
59
|
+
display: flex;
|
|
60
|
+
gap: var(--spacing-2xs);
|
|
100
61
|
}
|
|
101
|
-
|
|
62
|
+
|
|
63
|
+
.FieldControl_hasLabel .FilePicker-Placeholder {
|
|
102
64
|
opacity: 0;
|
|
103
65
|
}
|
|
104
|
-
|
|
105
|
-
|
|
66
|
+
|
|
67
|
+
.FieldControl_hasLabel .FilePicker-FileName,
|
|
68
|
+
.FieldControl_hasLabel .FilePicker-Placeholder {
|
|
106
69
|
padding: var(--textfield-input-padding);
|
|
107
|
-
font: var(--textfield-input-font);
|
|
108
70
|
}
|
|
109
|
-
.FilePicker:hover {
|
|
110
|
-
--textfield-border-color: var(--color-border-main-hover);
|
|
111
|
-
}
|
|
112
|
-
.FilePicker_focused,
|
|
113
|
-
.FilePicker_focused:hover {
|
|
114
|
-
--textfield-border-width: var(--border-width-m);
|
|
115
|
-
--textfield-background-color: var(--color-background-main);
|
|
116
|
-
--textfield-border-color: var(--color-border-action);
|
|
117
|
-
}
|
|
118
|
-
.FilePicker_error,
|
|
119
|
-
.FilePicker_error.FilePicker:hover,
|
|
120
|
-
.FilePicker_error.FilePicker_focused,
|
|
121
|
-
.FilePicker_error.FilePicker_focused:hover {
|
|
122
|
-
--textfield-border-color: var(--color-border-error);
|
|
123
|
-
}
|
|
124
|
-
.FilePicker_disabled {
|
|
125
|
-
--textfield-border-color: var(--color-border-disabled);
|
|
126
|
-
--textfield-background-color: var(--color-background-disabled);
|
|
127
|
-
--textfield-color: var(--color-content-secondary);
|
|
128
|
-
pointer-events: none;
|
|
129
|
-
cursor: default;
|
|
130
|
-
}
|
|
@@ -1,4 +1,74 @@
|
|
|
1
1
|
import './FilePicker.css';
|
|
2
|
+
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
export declare const cnFilePicker: import("@bem-react/classname").ClassNameFormatter;
|
|
4
|
-
export declare const FilePicker: React.ForwardRefExoticComponent<
|
|
5
|
+
export declare const FilePicker: React.ForwardRefExoticComponent<{
|
|
6
|
+
id?: string | undefined;
|
|
7
|
+
name?: string | undefined;
|
|
8
|
+
size?: "s" | "m" | "l" | "2xs" | "xs" | undefined;
|
|
9
|
+
label?: string | undefined;
|
|
10
|
+
accept?: string | undefined;
|
|
11
|
+
placeholder?: string | undefined;
|
|
12
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement> | undefined;
|
|
13
|
+
multiple?: boolean | undefined;
|
|
14
|
+
fileList?: File[] | undefined;
|
|
15
|
+
fullWidth?: boolean | undefined;
|
|
16
|
+
autoFocus?: boolean | undefined;
|
|
17
|
+
inputProps?: (Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & {
|
|
18
|
+
ref?: ((instance: HTMLInputElement | null) => void) | React.RefObject<HTMLInputElement> | null | undefined;
|
|
19
|
+
} & {
|
|
20
|
+
'data-testid'?: string | undefined;
|
|
21
|
+
}) | undefined;
|
|
22
|
+
disableTruncate?: boolean | undefined;
|
|
23
|
+
required?: boolean | undefined;
|
|
24
|
+
renderLeft?: string | number | React.FC<React.SVGProps<SVGSVGElement> & {
|
|
25
|
+
color?: string | undefined;
|
|
26
|
+
ref?: React.Ref<SVGSVGElement> | undefined;
|
|
27
|
+
} & {
|
|
28
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
29
|
+
}> | React.ReactElement<React.SVGProps<SVGSVGElement> & {
|
|
30
|
+
color?: string | undefined;
|
|
31
|
+
ref?: React.Ref<SVGSVGElement> | undefined;
|
|
32
|
+
} & {
|
|
33
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
34
|
+
}, string | React.JSXElementConstructor<any>> | (() => React.ReactElement<React.SVGProps<SVGSVGElement> & {
|
|
35
|
+
color?: string | undefined;
|
|
36
|
+
ref?: React.Ref<SVGSVGElement> | undefined;
|
|
37
|
+
} & {
|
|
38
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
39
|
+
}, string | React.JSXElementConstructor<any>>) | undefined;
|
|
40
|
+
renderRight?: string | number | React.FC<React.SVGProps<SVGSVGElement> & {
|
|
41
|
+
color?: string | undefined;
|
|
42
|
+
ref?: React.Ref<SVGSVGElement> | undefined;
|
|
43
|
+
} & {
|
|
44
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
45
|
+
}> | React.ReactElement<React.SVGProps<SVGSVGElement> & {
|
|
46
|
+
color?: string | undefined;
|
|
47
|
+
ref?: React.Ref<SVGSVGElement> | undefined;
|
|
48
|
+
} & {
|
|
49
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
50
|
+
}, string | React.JSXElementConstructor<any>> | (() => React.ReactElement<React.SVGProps<SVGSVGElement> & {
|
|
51
|
+
color?: string | undefined;
|
|
52
|
+
ref?: React.Ref<SVGSVGElement> | undefined;
|
|
53
|
+
} & {
|
|
54
|
+
size?: import("@ozen-ui/icons").IconSize | undefined;
|
|
55
|
+
}, string | React.JSXElementConstructor<any>>) | undefined;
|
|
56
|
+
hint?: string | null | undefined;
|
|
57
|
+
error?: boolean | undefined;
|
|
58
|
+
disabled?: boolean | undefined;
|
|
59
|
+
labelProps?: import("../FieldLabel").FieldLabelProps | undefined;
|
|
60
|
+
hintProps?: Omit<import("../FieldHint").FieldHintProps, "children"> | undefined;
|
|
61
|
+
renderValue?: import("./types").FilePickerRenderValue | undefined;
|
|
62
|
+
clearText?: string | undefined;
|
|
63
|
+
onClear?: ((e: KeyboardEvent<HTMLInputElement> | MouseEvent<HTMLButtonElement, globalThis.MouseEvent>, payload: {
|
|
64
|
+
name?: string | undefined;
|
|
65
|
+
}) => void) | undefined;
|
|
66
|
+
className?: string | undefined;
|
|
67
|
+
'data-testid'?: string | undefined;
|
|
68
|
+
} & {
|
|
69
|
+
labelRef?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
70
|
+
inputRef?: React.Ref<HTMLInputElement> | undefined;
|
|
71
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "name" | "label" | "className" | "id" | "onChange" | "autoFocus" | "disabled" | "accept" | "multiple" | "placeholder" | "required" | "size" | "error" | "fullWidth" | "labelProps" | "data-testid" | "hint" | "renderLeft" | "renderRight" | "inputProps" | "hintProps" | "clearText" | "onClear" | "fileList" | "disableTruncate" | "renderValue" | keyof {
|
|
72
|
+
labelRef?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
73
|
+
inputRef?: React.Ref<HTMLInputElement> | undefined;
|
|
74
|
+
}> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import './FilePicker.css';
|
|
3
|
-
import React, { forwardRef,
|
|
3
|
+
import React, { forwardRef, useRef, useState } from 'react';
|
|
4
4
|
import { AttachmentIcon, CrossIcon } from '@ozen-ui/icons';
|
|
5
|
+
import { deprecate } from '@ozen-ui/logger';
|
|
5
6
|
import { useMultiRef } from '../../hooks/useMultiRef';
|
|
6
7
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
7
8
|
import { cn } from '../../utils/classname';
|
|
8
9
|
import { isKey } from '../../utils/isKey';
|
|
10
|
+
import { FieldControl } from '../FieldControl';
|
|
9
11
|
import { FieldHint } from '../FieldHint';
|
|
10
12
|
import { FieldIcon } from '../FieldIcon';
|
|
11
13
|
import { FieldLabel } from '../FieldLabel';
|
|
12
14
|
import { Fieldset } from '../Fieldset';
|
|
13
|
-
import { IconButton } from '../
|
|
14
|
-
import {
|
|
15
|
+
import { IconButton } from '../IconButtonNext';
|
|
16
|
+
import { FILE_PICKER_DEFAULT_DISABLE_TRUNCATE, FILE_PICKER_DEFAULT_DISABLED, FILE_PICKER_DEFAULT_FULL_WIDTH, FILE_PICKER_DEFAULT_MULTIPLE, FILE_PICKER_DEFAULT_REQUIRED, FILE_PICKER_DEFAULT_SIZE, FILE_PICKER_DEFAULT_VALUE_RENDERER, } from './constants';
|
|
15
17
|
export var cnFilePicker = cn('FilePicker');
|
|
16
18
|
export var FilePicker = forwardRef(function (inProps, ref) {
|
|
17
19
|
var _a = useThemeProps({
|
|
18
20
|
props: inProps,
|
|
19
21
|
name: 'FilePicker',
|
|
20
|
-
}), _b = _a.size, size = _b === void 0 ? FILE_PICKER_DEFAULT_SIZE : _b, _c = _a.disabled, disabled = _c === void 0 ? FILE_PICKER_DEFAULT_DISABLED : _c, _d = _a.required, required = _d === void 0 ? FILE_PICKER_DEFAULT_REQUIRED : _d, _e = _a.fullWidth, fullWidth = _e === void 0 ? FILE_PICKER_DEFAULT_FULL_WIDTH : _e, _f = _a.disableTruncate, disableTruncate = _f === void 0 ? FILE_PICKER_DEFAULT_DISABLE_TRUNCATE : _f, _g = _a.multiple, multiple = _g === void 0 ? FILE_PICKER_DEFAULT_MULTIPLE : _g, placeholder = _a.placeholder, clearText = _a.clearText, _h = _a.renderRight, renderRight = _h === void 0 ? AttachmentIcon : _h, renderValueProp = _a.renderValue, onChangeProp = _a.onChange, onClearProp = _a.onClear,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
}), _b = _a.size, size = _b === void 0 ? FILE_PICKER_DEFAULT_SIZE : _b, _c = _a.disabled, disabled = _c === void 0 ? FILE_PICKER_DEFAULT_DISABLED : _c, _d = _a.required, required = _d === void 0 ? FILE_PICKER_DEFAULT_REQUIRED : _d, _e = _a.fullWidth, fullWidth = _e === void 0 ? FILE_PICKER_DEFAULT_FULL_WIDTH : _e, _f = _a.disableTruncate, disableTruncate = _f === void 0 ? FILE_PICKER_DEFAULT_DISABLE_TRUNCATE : _f, _g = _a.multiple, multiple = _g === void 0 ? FILE_PICKER_DEFAULT_MULTIPLE : _g, placeholder = _a.placeholder, clearText = _a.clearText, _h = _a.renderRight, renderRight = _h === void 0 ? AttachmentIcon : _h, renderValueProp = _a.renderValue, onChangeProp = _a.onChange, onClearProp = _a.onClear, inputRef = _a.inputRef, fileList = _a.fileList, accept = _a.accept, id = _a.id, name = _a.name, label = _a.label, autoFocus = _a.autoFocus, error = _a.error, hint = _a.hint, renderLeft = _a.renderLeft, labelProps = _a.labelProps, inputProps = _a.inputProps, hintProps = _a.hintProps, labelRef = _a.labelRef, className = _a.className, other = __rest(_a, ["size", "disabled", "required", "fullWidth", "disableTruncate", "multiple", "placeholder", "clearText", "renderRight", "renderValue", "onChange", "onClear", "inputRef", "fileList", "accept", "id", "name", "label", "autoFocus", "error", "hint", "renderLeft", "labelProps", "inputProps", "hintProps", "labelRef", "className"]);
|
|
23
|
+
if (process.env.NODE_ENV !== 'production' && labelRef) {
|
|
24
|
+
deprecate('Свойство «labelRef» устарело. Для замены используйте «labelProps.ref».');
|
|
25
|
+
}
|
|
26
|
+
if (process.env.NODE_ENV !== 'production' && inputRef) {
|
|
27
|
+
deprecate('Свойство «inputRef» устарело. Для замены используйте «inputProps.ref».');
|
|
28
|
+
}
|
|
29
|
+
var inputInnerRef = useRef(null);
|
|
24
30
|
var _j = __read(useState(false), 2), focused = _j[0], setFocused = _j[1];
|
|
31
|
+
var hasFiles = !!(fileList === null || fileList === void 0 ? void 0 : fileList.length);
|
|
25
32
|
var handleFocus = function (e) {
|
|
26
33
|
var _a;
|
|
27
34
|
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
@@ -34,8 +41,8 @@ export var FilePicker = forwardRef(function (inProps, ref) {
|
|
|
34
41
|
};
|
|
35
42
|
var onChange = function (e) {
|
|
36
43
|
onChangeProp === null || onChangeProp === void 0 ? void 0 : onChangeProp(e);
|
|
37
|
-
if (
|
|
38
|
-
|
|
44
|
+
if (inputInnerRef.current) {
|
|
45
|
+
inputInnerRef.current.value = '';
|
|
39
46
|
}
|
|
40
47
|
};
|
|
41
48
|
var onClear = function (e) {
|
|
@@ -52,25 +59,19 @@ export var FilePicker = forwardRef(function (inProps, ref) {
|
|
|
52
59
|
? renderValueProp(file)
|
|
53
60
|
: FILE_PICKER_DEFAULT_VALUE_RENDERER(file, disableTruncate);
|
|
54
61
|
};
|
|
55
|
-
return (React.createElement(
|
|
56
|
-
hasLabel: !!label,
|
|
57
|
-
hasValue: !!(fileList === null || fileList === void 0 ? void 0 : fileList.length),
|
|
58
|
-
size: size,
|
|
59
|
-
error: error,
|
|
60
|
-
focused: focused,
|
|
61
|
-
disabled: disabled,
|
|
62
|
-
required: required,
|
|
63
|
-
fullWidth: fullWidth,
|
|
64
|
-
}, [className]), ref: useMultiRef([fieldRef, ref]) }),
|
|
62
|
+
return (React.createElement(FieldControl, __assign({ size: size, error: error, focused: focused, disabled: disabled, required: required, fullWidth: fullWidth, filled: hasFiles }, other, { className: cnFilePicker('', [className]), ref: ref }),
|
|
65
63
|
React.createElement("label", { className: cnFilePicker('Body') },
|
|
66
|
-
React.createElement(FieldIcon, {
|
|
64
|
+
React.createElement(FieldIcon, { icon: renderLeft }),
|
|
67
65
|
React.createElement("div", { className: cnFilePicker('FieldContainer') },
|
|
68
|
-
|
|
69
|
-
React.createElement("input", __assign({ id: id, name: name,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
React.createElement(FieldLabel, __assign({}, labelProps, { ref: labelRef || (labelProps === null || labelProps === void 0 ? void 0 : labelProps.ref), className: cnFilePicker('Label', [labelProps === null || labelProps === void 0 ? void 0 : labelProps.className]) }), label),
|
|
67
|
+
React.createElement("input", __assign({ id: id, name: name, accept: accept, multiple: multiple, onBlur: handleBlur, required: required, disabled: disabled, autoFocus: autoFocus, onFocus: handleFocus, className: cnFilePicker('Input') }, inputProps, { type: "file", onChange: onChange, onKeyDown: onKeyDown, ref: useMultiRef([inputRef || (inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref), inputInnerRef]) })),
|
|
68
|
+
hasFiles ? (React.createElement("span", { className: cnFilePicker('FileName') }, renderValue(fileList, disableTruncate))) : (React.createElement("span", { "aria-placeholder": placeholder, className: cnFilePicker('Placeholder') }, placeholder))),
|
|
69
|
+
React.createElement("div", { className: cnFilePicker('RenderRight') },
|
|
70
|
+
onClearProp && (React.createElement(IconButton, { size: size, tabIndex: -1, icon: CrossIcon, onClick: onClear, variant: "function", "aria-label": clearText, className: cnFilePicker('ClearButton', {
|
|
71
|
+
visibility: hasFiles,
|
|
72
|
+
}) })),
|
|
73
|
+
React.createElement(FieldIcon, { icon: renderRight })),
|
|
74
|
+
React.createElement(Fieldset, null)),
|
|
75
|
+
React.createElement(FieldHint, __assign({}, hintProps), hint)));
|
|
75
76
|
});
|
|
76
77
|
FilePicker.displayName = 'FilePicker';
|