@tedi-design-system/react 17.0.0 → 17.1.0-rc.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.
- package/bundle-stats.html +1 -1
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/tedi/components/form/field/field.cjs.js +1 -0
- package/src/tedi/components/form/field/field.d.ts +88 -0
- package/src/tedi/components/form/field/field.es.js +54 -0
- package/src/tedi/components/form/field/field.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/field/field.module.scss.es.js +6 -0
- package/src/tedi/components/form/file-upload/file-upload.cjs.js +1 -1
- package/src/tedi/components/form/file-upload/file-upload.d.ts +14 -2
- package/src/tedi/components/form/file-upload/file-upload.es.js +97 -90
- package/src/tedi/components/form/input-group/components/input/input.cjs.js +1 -0
- package/src/tedi/components/form/input-group/components/input/input.d.ts +19 -0
- package/src/tedi/components/form/input-group/components/input/input.es.js +20 -0
- package/src/tedi/components/form/input-group/components/prefix/prefix.cjs.js +1 -0
- package/src/tedi/components/form/input-group/components/prefix/prefix.d.ts +18 -0
- package/src/tedi/components/form/input-group/components/prefix/prefix.es.js +26 -0
- package/src/tedi/components/form/input-group/components/suffix/suffix.cjs.js +1 -0
- package/src/tedi/components/form/input-group/components/suffix/suffix.d.ts +18 -0
- package/src/tedi/components/form/input-group/components/suffix/suffix.es.js +26 -0
- package/src/tedi/components/form/input-group/index.d.ts +4 -0
- package/src/tedi/components/form/input-group/input-group.cjs.js +1 -0
- package/src/tedi/components/form/input-group/input-group.d.ts +87 -0
- package/src/tedi/components/form/input-group/input-group.es.js +61 -0
- package/src/tedi/components/form/input-group/input-group.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/input-group/input-group.module.scss.es.js +16 -0
- package/src/tedi/components/form/search/search.cjs.js +1 -1
- package/src/tedi/components/form/search/search.es.js +35 -25
- package/src/tedi/components/form/select/components/select-control.cjs.js +1 -1
- package/src/tedi/components/form/select/components/select-control.es.js +7 -3
- package/src/tedi/components/form/select/select.cjs.js +1 -1
- package/src/tedi/components/form/select/select.d.ts +3 -2
- package/src/tedi/components/form/select/select.es.js +168 -166
- package/src/tedi/components/form/textfield/textfield.cjs.js +1 -1
- package/src/tedi/components/form/textfield/textfield.d.ts +118 -36
- package/src/tedi/components/form/textfield/textfield.es.js +134 -172
- package/src/tedi/index.d.ts +2 -0
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +168 -156
|
@@ -1,163 +1,165 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { FeedbackText as
|
|
7
|
-
import { FormLabel as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
1
|
+
import { jsx as l, jsxs as w } from "react/jsx-runtime";
|
|
2
|
+
import Oe from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import c, { forwardRef as ve } from "react";
|
|
4
|
+
import Ce from "../../../../../external/react-select/dist/react-select.esm.es.js";
|
|
5
|
+
import Le from "../../../../../external/react-select/async/dist/react-select-async.esm.es.js";
|
|
6
|
+
import { FeedbackText as he } from "../feedback-text/feedback-text.es.js";
|
|
7
|
+
import { FormLabel as ye } from "../form-label/form-label.es.js";
|
|
8
|
+
import { useOptionalInputGroup as Ne } from "../input-group/input-group.es.js";
|
|
9
|
+
import { SelectClearIndicator as Ve } from "./components/select-clear-indicator.es.js";
|
|
10
|
+
import { SelectControl as Re } from "./components/select-control.es.js";
|
|
11
|
+
import { SelectDropDownIndicator as we } from "./components/select-dropdown-indicator.es.js";
|
|
12
|
+
import { SelectGroup as _e } from "./components/select-group.es.js";
|
|
13
|
+
import { SelectGroupHeading as $e } from "./components/select-group-heading.es.js";
|
|
14
|
+
import { SelectIndicatorsContainer as xe } from "./components/select-indicators-container.es.js";
|
|
15
|
+
import { SelectInput as He } from "./components/select-input.es.js";
|
|
16
|
+
import { SelectLoadingIndicator as Pe } from "./components/select-loading-indicator.es.js";
|
|
17
|
+
import { SelectMenu as Te } from "./components/select-menu.es.js";
|
|
18
|
+
import { SelectMenuList as De } from "./components/select-menu-list.es.js";
|
|
19
|
+
import { SelectMenuPortal as Fe } from "./components/select-menu-portal.es.js";
|
|
20
|
+
import { SelectMultiValue as je } from "./components/select-multi-value.es.js";
|
|
21
|
+
import { SelectMultiValueRemove as ke } from "./components/select-multi-value-remove.es.js";
|
|
22
|
+
import { SelectOption as Ee } from "./components/select-option.es.js";
|
|
23
|
+
import { SelectValueContainer as Be } from "./components/select-value-container.es.js";
|
|
23
24
|
import o from "./select.module.scss.es.js";
|
|
24
|
-
import { useLabels as
|
|
25
|
-
const
|
|
26
|
-
(
|
|
25
|
+
import { useLabels as Ge } from "../../../providers/label-provider/use-labels.es.js";
|
|
26
|
+
const qe = ve(
|
|
27
|
+
(g, _) => {
|
|
28
|
+
var R;
|
|
27
29
|
const {
|
|
28
|
-
options:
|
|
29
|
-
defaultOptions:
|
|
30
|
-
id:
|
|
31
|
-
name:
|
|
32
|
-
iconName:
|
|
33
|
-
label:
|
|
34
|
-
required:
|
|
35
|
-
value:
|
|
36
|
-
defaultValue:
|
|
37
|
-
tagsDirection:
|
|
38
|
-
onChange:
|
|
39
|
-
onInputChange:
|
|
40
|
-
inputValue:
|
|
41
|
-
loadOptions:
|
|
42
|
-
isLoading:
|
|
30
|
+
options: $,
|
|
31
|
+
defaultOptions: x,
|
|
32
|
+
id: S,
|
|
33
|
+
name: H,
|
|
34
|
+
iconName: P = "arrow_drop_down",
|
|
35
|
+
label: T,
|
|
36
|
+
required: b,
|
|
37
|
+
value: D,
|
|
38
|
+
defaultValue: F,
|
|
39
|
+
tagsDirection: M = "row",
|
|
40
|
+
onChange: d,
|
|
41
|
+
onInputChange: j,
|
|
42
|
+
inputValue: k,
|
|
43
|
+
loadOptions: E,
|
|
44
|
+
isLoading: B,
|
|
43
45
|
openMenuOnFocus: G = !1,
|
|
44
|
-
openMenuOnClick:
|
|
45
|
-
tabSelectsValue:
|
|
46
|
-
disabled:
|
|
47
|
-
className:
|
|
48
|
-
hideLabel:
|
|
46
|
+
openMenuOnClick: q = !0,
|
|
47
|
+
tabSelectsValue: z = !1,
|
|
48
|
+
disabled: I = !1,
|
|
49
|
+
className: O,
|
|
50
|
+
hideLabel: A = !1,
|
|
49
51
|
helper: t,
|
|
50
|
-
placeholder:
|
|
51
|
-
invalid:
|
|
52
|
-
valid:
|
|
53
|
-
size:
|
|
54
|
-
async:
|
|
55
|
-
renderOption:
|
|
56
|
-
renderMessageListFooter:
|
|
57
|
-
noOptionsMessage:
|
|
58
|
-
loadingMessage:
|
|
59
|
-
multiple:
|
|
60
|
-
closeMenuOnSelect:
|
|
61
|
-
blurInputOnSelect:
|
|
62
|
-
autoFocus:
|
|
63
|
-
isClearable:
|
|
64
|
-
isClearIndicatorVisible:
|
|
65
|
-
isSearchable:
|
|
66
|
-
menuIsOpen:
|
|
67
|
-
onMenuClose:
|
|
68
|
-
onMenuOpen:
|
|
69
|
-
onBlur:
|
|
70
|
-
inputIsHidden:
|
|
71
|
-
isTagRemovable:
|
|
72
|
-
optionGroupHeadingText:
|
|
73
|
-
cacheOptions:
|
|
74
|
-
showRadioButtons:
|
|
75
|
-
renderWithoutLabel:
|
|
76
|
-
tooltip:
|
|
77
|
-
classNames:
|
|
78
|
-
} =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
() =>
|
|
52
|
+
placeholder: W,
|
|
53
|
+
invalid: J,
|
|
54
|
+
valid: K,
|
|
55
|
+
size: m,
|
|
56
|
+
async: Q = !1,
|
|
57
|
+
renderOption: U,
|
|
58
|
+
renderMessageListFooter: v,
|
|
59
|
+
noOptionsMessage: X,
|
|
60
|
+
loadingMessage: Y,
|
|
61
|
+
multiple: u = !1,
|
|
62
|
+
closeMenuOnSelect: Z = !u,
|
|
63
|
+
blurInputOnSelect: C = !1,
|
|
64
|
+
autoFocus: ee = !1,
|
|
65
|
+
isClearable: te = !0,
|
|
66
|
+
isClearIndicatorVisible: oe = !1,
|
|
67
|
+
isSearchable: L = !0,
|
|
68
|
+
menuIsOpen: ae,
|
|
69
|
+
onMenuClose: ne,
|
|
70
|
+
onMenuOpen: re,
|
|
71
|
+
onBlur: ie,
|
|
72
|
+
inputIsHidden: se,
|
|
73
|
+
isTagRemovable: h = !1,
|
|
74
|
+
optionGroupHeadingText: le = { modifiers: "small", color: "tertiary" },
|
|
75
|
+
cacheOptions: ce = !0,
|
|
76
|
+
showRadioButtons: de = !1,
|
|
77
|
+
renderWithoutLabel: me,
|
|
78
|
+
tooltip: ue,
|
|
79
|
+
classNames: y
|
|
80
|
+
} = g, a = (R = Ne) == null ? void 0 : R(), pe = c.useId(), fe = a == null ? void 0 : a.hasExternalLabel, p = g.id ?? (a == null ? void 0 : a.inputId) ?? pe, N = t ? (t == null ? void 0 : t.id) ?? `${p}-helper` : void 0, r = c.useRef(null), { getLabel: V } = Ge();
|
|
81
|
+
c.useImperativeHandle(
|
|
82
|
+
_,
|
|
83
|
+
() => r.current
|
|
82
84
|
);
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
return (
|
|
85
|
+
const ge = (n) => {
|
|
86
|
+
d == null || d(n), !C && r.current && setTimeout(() => {
|
|
87
|
+
var i, s;
|
|
88
|
+
return (s = (i = r.current) == null ? void 0 : i.inputRef) == null ? void 0 : s.focus();
|
|
87
89
|
}, 0);
|
|
88
|
-
},
|
|
89
|
-
(
|
|
90
|
-
[
|
|
91
|
-
),
|
|
92
|
-
const
|
|
93
|
-
ClearIndicator: (e) =>
|
|
94
|
-
DropdownIndicator: () =>
|
|
90
|
+
}, Se = c.useCallback(
|
|
91
|
+
(n) => /* @__PURE__ */ l(De, { ...n, renderMessageListFooter: v }),
|
|
92
|
+
[v]
|
|
93
|
+
), be = () => {
|
|
94
|
+
const n = {
|
|
95
|
+
ClearIndicator: (e) => Ve({ isClearIndicatorVisible: oe, ...e }),
|
|
96
|
+
DropdownIndicator: () => we({ iconName: P }),
|
|
95
97
|
IndicatorSeparator: () => null,
|
|
96
|
-
MenuPortal:
|
|
97
|
-
Menu:
|
|
98
|
-
MenuList:
|
|
99
|
-
Option: (e) =>
|
|
100
|
-
Control:
|
|
101
|
-
Input:
|
|
102
|
-
MultiValue: (e) =>
|
|
103
|
-
MultiValueRemove:
|
|
104
|
-
Group:
|
|
105
|
-
GroupHeading: (e) =>
|
|
106
|
-
IndicatorsContainer:
|
|
107
|
-
ValueContainer:
|
|
108
|
-
LoadingIndicator:
|
|
109
|
-
},
|
|
110
|
-
return /* @__PURE__ */
|
|
111
|
-
|
|
98
|
+
MenuPortal: Fe,
|
|
99
|
+
Menu: Te,
|
|
100
|
+
MenuList: Se,
|
|
101
|
+
Option: (e) => Ee({ renderOption: U, multiple: u, showRadioButtons: de, ...e }),
|
|
102
|
+
Control: (e) => Re({ ...e, className: O }),
|
|
103
|
+
Input: He,
|
|
104
|
+
MultiValue: (e) => je({ isTagRemovable: h, ...e }),
|
|
105
|
+
MultiValueRemove: ke,
|
|
106
|
+
Group: _e,
|
|
107
|
+
GroupHeading: (e) => $e({ optionGroupHeadingText: le, ...e }),
|
|
108
|
+
IndicatorsContainer: xe,
|
|
109
|
+
ValueContainer: Be,
|
|
110
|
+
LoadingIndicator: Pe
|
|
111
|
+
}, i = Q ? Le : Ce, s = () => V("select.no-options"), Ie = () => V("select.loading");
|
|
112
|
+
return /* @__PURE__ */ l(
|
|
113
|
+
i,
|
|
112
114
|
{
|
|
113
|
-
id:
|
|
114
|
-
"aria-describedby":
|
|
115
|
-
autoFocus:
|
|
116
|
-
ref:
|
|
117
|
-
instanceId:
|
|
115
|
+
id: p,
|
|
116
|
+
"aria-describedby": N,
|
|
117
|
+
autoFocus: ee,
|
|
118
|
+
ref: r,
|
|
119
|
+
instanceId: S,
|
|
118
120
|
className: "tedi-select__wrapper",
|
|
119
|
-
name:
|
|
120
|
-
options:
|
|
121
|
-
defaultOptions:
|
|
122
|
-
value:
|
|
123
|
-
defaultValue:
|
|
124
|
-
cacheOptions:
|
|
125
|
-
onChange:
|
|
126
|
-
onInputChange:
|
|
127
|
-
onBlur:
|
|
128
|
-
inputValue:
|
|
129
|
-
inputId: `${
|
|
130
|
-
loadOptions:
|
|
131
|
-
isLoading:
|
|
132
|
-
noOptionsMessage:
|
|
133
|
-
loadingMessage:
|
|
121
|
+
name: H,
|
|
122
|
+
options: $,
|
|
123
|
+
defaultOptions: x,
|
|
124
|
+
value: D,
|
|
125
|
+
defaultValue: F,
|
|
126
|
+
cacheOptions: ce,
|
|
127
|
+
onChange: ge,
|
|
128
|
+
onInputChange: j,
|
|
129
|
+
onBlur: ie,
|
|
130
|
+
inputValue: k,
|
|
131
|
+
inputId: `${S}-input`,
|
|
132
|
+
loadOptions: E,
|
|
133
|
+
isLoading: B,
|
|
134
|
+
noOptionsMessage: X || s,
|
|
135
|
+
loadingMessage: Y || Ie,
|
|
134
136
|
classNamePrefix: "select",
|
|
135
|
-
components:
|
|
136
|
-
isDisabled:
|
|
137
|
-
isSearchable:
|
|
138
|
-
menuIsOpen:
|
|
137
|
+
components: n,
|
|
138
|
+
isDisabled: I,
|
|
139
|
+
isSearchable: L,
|
|
140
|
+
menuIsOpen: ae,
|
|
139
141
|
openMenuOnFocus: G,
|
|
140
|
-
openMenuOnClick:
|
|
141
|
-
tabSelectsValue:
|
|
142
|
-
onMenuClose:
|
|
143
|
-
onMenuOpen:
|
|
144
|
-
placeholder:
|
|
145
|
-
isClearable:
|
|
146
|
-
backspaceRemovesValue:
|
|
142
|
+
openMenuOnClick: q,
|
|
143
|
+
tabSelectsValue: z,
|
|
144
|
+
onMenuClose: ne,
|
|
145
|
+
onMenuOpen: re,
|
|
146
|
+
placeholder: W || "",
|
|
147
|
+
isClearable: te,
|
|
148
|
+
backspaceRemovesValue: h,
|
|
147
149
|
menuShouldScrollIntoView: !0,
|
|
148
|
-
isMulti:
|
|
150
|
+
isMulti: u,
|
|
149
151
|
hideSelectedOptions: !1,
|
|
150
|
-
closeMenuOnSelect:
|
|
151
|
-
blurInputOnSelect:
|
|
152
|
+
closeMenuOnSelect: Z,
|
|
153
|
+
blurInputOnSelect: C,
|
|
152
154
|
menuPlacement: "auto",
|
|
153
|
-
inputIsHidden:
|
|
154
|
-
required:
|
|
155
|
+
inputIsHidden: se,
|
|
156
|
+
required: b,
|
|
155
157
|
menuPortalTarget: document.body,
|
|
156
158
|
menuPosition: "absolute",
|
|
157
|
-
classNames:
|
|
158
|
-
Object.entries(
|
|
159
|
+
classNames: y ? Object.fromEntries(
|
|
160
|
+
Object.entries(y).map(([e, f]) => [
|
|
159
161
|
e,
|
|
160
|
-
typeof
|
|
162
|
+
typeof f == "string" ? () => f : f
|
|
161
163
|
])
|
|
162
164
|
) : void 0,
|
|
163
165
|
theme: (e) => ({
|
|
@@ -177,37 +179,37 @@ const Fe = Se(
|
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
);
|
|
180
|
-
},
|
|
182
|
+
}, Me = Oe(
|
|
181
183
|
o["tedi-select"],
|
|
182
|
-
|
|
183
|
-
{ [o["tedi-select--invalid"]]:
|
|
184
|
-
{ [o["tedi-select--valid"]]:
|
|
185
|
-
{ [o[`tedi-select--${
|
|
186
|
-
{ [o[`tedi-select--tags-${
|
|
187
|
-
{ [o["tedi-select--searchable"]]:
|
|
188
|
-
{ [o["tedi-select--disabled"]]:
|
|
184
|
+
O,
|
|
185
|
+
{ [o["tedi-select--invalid"]]: J || (t == null ? void 0 : t.type) === "error" },
|
|
186
|
+
{ [o["tedi-select--valid"]]: K || (t == null ? void 0 : t.type) === "valid" },
|
|
187
|
+
{ [o[`tedi-select--${m}`]]: m },
|
|
188
|
+
{ [o[`tedi-select--tags-${M}`]]: M },
|
|
189
|
+
{ [o["tedi-select--searchable"]]: L },
|
|
190
|
+
{ [o["tedi-select--disabled"]]: I }
|
|
189
191
|
);
|
|
190
|
-
return /* @__PURE__ */
|
|
191
|
-
/* @__PURE__ */
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
|
|
192
|
+
return /* @__PURE__ */ w("div", { "data-name": "select", className: Me, children: [
|
|
193
|
+
/* @__PURE__ */ w("div", { className: o["tedi-select__inner"], children: [
|
|
194
|
+
!fe && /* @__PURE__ */ l(
|
|
195
|
+
ye,
|
|
194
196
|
{
|
|
195
|
-
id: `${
|
|
196
|
-
label:
|
|
197
|
-
required:
|
|
198
|
-
hideLabel:
|
|
199
|
-
size:
|
|
200
|
-
renderWithoutLabel:
|
|
201
|
-
tooltip:
|
|
197
|
+
id: `${p}-input`,
|
|
198
|
+
label: T,
|
|
199
|
+
required: b,
|
|
200
|
+
hideLabel: A,
|
|
201
|
+
size: m,
|
|
202
|
+
renderWithoutLabel: me,
|
|
203
|
+
tooltip: ue
|
|
202
204
|
}
|
|
203
205
|
),
|
|
204
|
-
|
|
206
|
+
be()
|
|
205
207
|
] }),
|
|
206
|
-
t && /* @__PURE__ */
|
|
208
|
+
t && /* @__PURE__ */ l(he, { ...t, id: N })
|
|
207
209
|
] });
|
|
208
210
|
}
|
|
209
211
|
);
|
|
210
|
-
|
|
212
|
+
qe.displayName = "Select";
|
|
211
213
|
export {
|
|
212
|
-
|
|
214
|
+
qe as Select
|
|
213
215
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),A=require("../../../../../external/classnames/index.cjs.js"),i=require("react"),E=require("../../base/icon/icon.cjs.js"),fe=require("../../buttons/closing-button/closing-button.cjs.js"),xe=require("../../misc/separator/separator.cjs.js"),H=require("../feedback-text/feedback-text.cjs.js"),me=require("../field/field.cjs.js"),ye=require("../form-label/form-label.cjs.js"),k=require("../input-group/input-group.cjs.js"),r=require("./textfield.module.scss.cjs.js"),be=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),ve=require("../../../providers/label-provider/use-labels.cjs.js"),pe={large:24,default:18},N=i.forwardRef((v,K)=>{var V;const{getCurrentBreakpointProps:O}=be.useBreakpointProps(v.defaultServerBreakpoint),{id:_e,label:p,className:D,inputClassName:U,disabled:c,required:q,hideLabel:I,invalid:u,readOnly:C,icon:s,onIconClick:_,size:d="default",placeholder:J,isArrowsHidden:Q=!0,isClearable:B,onClear:y,onChange:o,onChangeEvent:W,onKeyUp:X,onKeyDown:Y,onKeyPress:Z,defaultValue:F,value:h,onFocus:g,onBlur:j,onClick:G,helper:e,input:n,name:ee,isTextArea:te,...re}=O(v)||{},{getLabel:T}=ve.useLabels(),w=i.useRef(null),L=i.useRef(null),[ae,R]=i.useState(h??F??""),S=h??ae,f=!!(B&&S&&!C),x=(V=k.useOptionalInputGroup)==null?void 0:V.call(k),le=i.useId(),ie=x==null?void 0:x.hasExternalLabel,m=v.id??(x==null?void 0:x.inputId)??le;i.useImperativeHandle(K,()=>({get input(){return L.current},get inner(){return w.current}}));const M=i.useMemo(()=>Array.isArray(e)?u||e.some(t=>t.type==="error"):u||(e==null?void 0:e.type)==="error",[u,e]),se=i.useMemo(()=>!e||Array.isArray(e)&&e.length===0?!1:Array.isArray(e)?!u&&e.every(t=>t.type==="valid"):!u&&e.type==="valid",[u,e]),ne=d==="large"?"default":d,b=h!==void 0,de=i.useCallback(t=>{b||R(t),o==null||o(t)},[b,o]),P=i.useCallback(()=>{b||R(""),o==null||o(""),y==null||y()},[b,o,y]),z=i.useCallback(()=>{if(!s)return null;const t={size:d==="large"?24:d==="small"?16:18,className:r.default["tedi-textfield__icon"]},l=typeof s=="string"?{...t,name:s}:{...t,...s,className:A.default(t.className,s.className)};return _?a.jsx("button",{type:"button",className:r.default["tedi-textfield__icon-wrapper"],onClick:c?void 0:_,disabled:c,children:a.jsx(E.Icon,{...l})}):a.jsx("div",{className:r.default["tedi-textfield__icon-wrapper"],"aria-hidden":"true",children:a.jsx(E.Icon,{...l})})},[s,d,_,c]),$=i.useMemo(()=>f?a.jsx(fe.ClosingButton,{iconSize:pe[d==="large"?"large":"default"],onClick:c?void 0:P,disabled:c,title:T("clear"),className:r.default["tedi-textfield__clear-button"]}):null,[f,d,c,P,T]),oe=i.useMemo(()=>!f&&!s?null:a.jsxs("div",{className:r.default["tedi-textfield__right-area"],children:[$,f&&s&&a.jsx(xe.Separator,{color:"primary",axis:"vertical",className:r.default["tedi-textfield__separator"]}),s&&z()]}),[f,s,$,z]),ce=A.default(r.default["tedi-textfield"],{[r.default[`tedi-textfield--${d}`]]:d},{[r.default["tedi-textfield--with-icon"]]:s},{[r.default["tedi-textfield--invalid"]]:M},{[r.default["tedi-textfield--valid"]]:se},{[r.default["tedi-textfield--clearable"]]:f},D),ue=()=>!e||Array.isArray(e)&&e.length===0?null:a.jsx("div",{className:r.default["tedi-textfield__feedback-wrapper"],children:Array.isArray(e)?e.map((t,l)=>a.jsx(H.FeedbackText,{...t,id:`${m}-helper-${l}`},l)):a.jsx(H.FeedbackText,{...e,id:`${m}-helper`})});return a.jsxs("div",{"data-name":"textfield",...re,className:ce,children:[!ie&&a.jsx(ye.FormLabel,{id:m,label:p,required:q,hideLabel:I,size:ne}),a.jsxs("div",{className:r.default["tedi-textfield__inner"],onKeyDown:Y,onKeyUp:X,onKeyPress:Z,onClick:G,ref:w,children:[a.jsx(me.Field,{...n,id:m,name:ee,value:S,defaultValue:F,onChange:de,onChangeEvent:W,disabled:c,readOnly:C,required:q,invalid:M,placeholder:J,className:A.default(r.default["tedi-textfield__input"],U,{[r.default["tedi-textfield__input--hidden-arrows"]]:Q}),onFocus:t=>{var l;(l=n==null?void 0:n.onFocus)==null||l.call(n,t),g==null||g(t)},onBlur:t=>{var l;(l=n==null?void 0:n.onBlur)==null||l.call(n,t),j==null||j(t)},isTextArea:te,"aria-describedby":!e||Array.isArray(e)&&e.length===0?void 0:Array.isArray(e)?e.map((t,l)=>`${m}-helper-${l}`).join(" "):`${m}-helper`,"aria-label":I&&typeof p=="string"?p:void 0,ref:L}),(B||s)&&oe]}),ue()]})});N.displayName="TextField";exports.TextField=N;exports.default=N;
|
|
@@ -2,114 +2,196 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { BreakpointSupport } from '../../../helpers';
|
|
3
3
|
import { IconWithoutBackgroundProps } from '../../base/icon/icon';
|
|
4
4
|
import { FeedbackTextProps } from '../feedback-text/feedback-text';
|
|
5
|
+
import { FieldElement } from '../field/field';
|
|
5
6
|
import { FormLabelProps } from '../form-label/form-label';
|
|
6
7
|
type TextFieldBreakpointProps = {
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Controls the visual size of the text field.
|
|
10
|
+
*
|
|
11
|
+
* - `'small'` → Compact version (smaller height, padding, and font size)
|
|
12
|
+
* - `'default'` → Standard size (most commonly used)
|
|
13
|
+
* - `'large'` → Larger touch target, bigger text and padding
|
|
14
|
+
*
|
|
9
15
|
* @default 'default'
|
|
10
16
|
*/
|
|
11
17
|
size?: 'default' | 'small' | 'large';
|
|
12
18
|
/**
|
|
13
|
-
* Icon
|
|
19
|
+
* Icon displayed inside the text field on the right side.
|
|
20
|
+
*
|
|
21
|
+
* Accepts either:
|
|
22
|
+
* - A simple string (icon name) → e.g. `'search'`, `'user'`, `'calendar'`
|
|
23
|
+
* - A full `IconWithoutBackgroundProps` object for advanced configuration (size, color, className, etc.)
|
|
24
|
+
*
|
|
25
|
+
* When `onIconClick` is provided, the icon becomes a clickable button.
|
|
26
|
+
* Otherwise, it is rendered as a non-interactive decorative element.
|
|
14
27
|
*/
|
|
15
28
|
icon?: string | IconWithoutBackgroundProps;
|
|
16
29
|
/**
|
|
17
|
-
*
|
|
30
|
+
* If `true`, renders a `<textarea>` instead of a regular `<input>`.
|
|
31
|
+
* Useful for multi-line text input (comments, descriptions, addresses, etc.).
|
|
32
|
+
*
|
|
33
|
+
* Note: When using `isTextArea`, the component still behaves like a text field
|
|
34
|
+
* (same styling, clear button, icon support, validation, etc.).
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
18
37
|
*/
|
|
19
38
|
isTextArea?: boolean;
|
|
20
39
|
/**
|
|
21
|
-
* Placeholder text
|
|
40
|
+
* Placeholder text shown when the field is empty.
|
|
41
|
+
*
|
|
42
|
+
* Recommended to be short and descriptive. Avoid using placeholder as a label.
|
|
22
43
|
*/
|
|
23
44
|
placeholder?: string;
|
|
24
45
|
/**
|
|
25
|
-
*
|
|
46
|
+
* When `true`, displays a clear (×) button on the right side when the field has a value.
|
|
47
|
+
*
|
|
48
|
+
* Clicking the button clears the input and calls `onClear` (if provided).
|
|
49
|
+
*
|
|
50
|
+
* @default false
|
|
26
51
|
*/
|
|
27
52
|
isClearable?: boolean;
|
|
28
53
|
/**
|
|
29
|
-
*
|
|
54
|
+
* Additional CSS class name applied to the root container (`<div>`).
|
|
55
|
+
*
|
|
56
|
+
* Use this for layout adjustments, custom spacing, or theming the entire text field wrapper.
|
|
30
57
|
*/
|
|
31
58
|
className?: string;
|
|
32
59
|
};
|
|
33
|
-
export interface TextFieldProps extends BreakpointSupport<TextFieldBreakpointProps>, Omit<FormLabelProps, 'size'> {
|
|
60
|
+
export interface TextFieldProps extends BreakpointSupport<TextFieldBreakpointProps>, Omit<FormLabelProps, 'size' | 'id' | 'label'> {
|
|
34
61
|
/**
|
|
35
|
-
* Unique identifier for the
|
|
62
|
+
* Unique identifier for the text field.
|
|
63
|
+
*
|
|
64
|
+
* Required for accessibility (associates label, helper text, and input).
|
|
65
|
+
* Also used to generate `aria-describedby` and helper IDs automatically.
|
|
36
66
|
*/
|
|
37
|
-
id
|
|
67
|
+
id?: string;
|
|
68
|
+
label?: React.ReactNode;
|
|
38
69
|
/**
|
|
39
|
-
* Name attribute for the input element.
|
|
70
|
+
* Name attribute for the underlying input/textarea element.
|
|
71
|
+
*
|
|
72
|
+
* Important for form submission and integration with form libraries (React Hook Form, Formik, etc.).
|
|
40
73
|
*/
|
|
41
74
|
name?: string;
|
|
42
75
|
/**
|
|
43
|
-
* Custom CSS
|
|
76
|
+
* Custom CSS class applied directly to the `<input>` or `<textarea>` element (via the internal `Field` component).
|
|
77
|
+
*
|
|
78
|
+
* Use this when you need to style the input itself (e.g. text alignment, font, custom focus styles).
|
|
79
|
+
*
|
|
80
|
+
* Note: The root container uses `className`.
|
|
44
81
|
*/
|
|
45
82
|
inputClassName?: string;
|
|
46
83
|
/**
|
|
47
|
-
* Callback
|
|
84
|
+
* Callback fired when the value changes. Receives the new value as a plain string.
|
|
85
|
+
*
|
|
86
|
+
* Preferred for most use cases (simpler than `onChangeEvent`).
|
|
87
|
+
*
|
|
88
|
+
* @param value - The current value of the field after change
|
|
48
89
|
*/
|
|
49
90
|
onChange?: (value: string) => void;
|
|
50
91
|
/**
|
|
51
|
-
*
|
|
92
|
+
* Native `onChange` event handler.
|
|
93
|
+
*
|
|
94
|
+
* Gives you access to the full `ChangeEvent` object (useful if you need `event.target`, `event.preventDefault()`, etc.).
|
|
95
|
+
*
|
|
96
|
+
* Note: Both `onChange` and `onChangeEvent` are called when the value changes.
|
|
52
97
|
*/
|
|
53
|
-
onChangeEvent?: React.ChangeEventHandler<
|
|
98
|
+
onChangeEvent?: React.ChangeEventHandler<FieldElement>;
|
|
54
99
|
/**
|
|
55
|
-
*
|
|
100
|
+
* Keyboard event handlers attached to the inner wrapper `<div>`.
|
|
101
|
+
*
|
|
102
|
+
* Useful for handling Enter key submission, arrow key navigation, or custom keyboard shortcuts.
|
|
103
|
+
*
|
|
104
|
+
* Note: These are **not** attached to the input/textarea directly, but to the surrounding container.
|
|
56
105
|
*/
|
|
57
106
|
onKeyPress?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
58
|
-
/**
|
|
59
|
-
* Callback for keydown events.
|
|
60
|
-
*/
|
|
61
107
|
onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
62
|
-
/**
|
|
63
|
-
* Callback for keyup events.
|
|
64
|
-
*/
|
|
65
108
|
onKeyUp?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
66
109
|
/**
|
|
67
|
-
*
|
|
110
|
+
* Default value for **uncontrolled** usage.
|
|
111
|
+
*
|
|
112
|
+
* Use this when you don't want to manage state yourself.
|
|
113
|
+
* The component will manage its internal state.
|
|
68
114
|
*/
|
|
69
115
|
defaultValue?: string;
|
|
70
116
|
/**
|
|
71
|
-
* Controlled value of the
|
|
117
|
+
* Controlled value of the text field.
|
|
118
|
+
*
|
|
119
|
+
* When provided, the component becomes **fully controlled**.
|
|
120
|
+
* You must update this value via `onChange` to reflect user input.
|
|
72
121
|
*/
|
|
73
122
|
value?: string;
|
|
74
123
|
/**
|
|
75
|
-
*
|
|
124
|
+
* Called when the user clicks on the icon (only works if `icon` is provided).
|
|
125
|
+
*
|
|
126
|
+
* The icon is automatically wrapped in a `<button>` when this prop is present.
|
|
127
|
+
*
|
|
128
|
+
* @param event - Mouse event from the icon wrapper
|
|
76
129
|
*/
|
|
77
130
|
onIconClick?: (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
|
|
78
131
|
/**
|
|
79
|
-
*
|
|
132
|
+
* Click handler for the entire inner container (the area around the input).
|
|
133
|
+
*
|
|
134
|
+
* Can be used to focus the input when clicking anywhere in the field area,
|
|
135
|
+
* or to trigger custom behavior.
|
|
80
136
|
*/
|
|
81
137
|
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
82
138
|
/**
|
|
83
|
-
*
|
|
139
|
+
* Disables the entire text field.
|
|
140
|
+
*
|
|
141
|
+
* When `true`:
|
|
142
|
+
* - Input becomes non-editable and non-focusable
|
|
143
|
+
* - Clear button and icon are disabled
|
|
144
|
+
* - Visual disabled styles are applied
|
|
84
145
|
*/
|
|
85
146
|
disabled?: boolean;
|
|
86
147
|
/**
|
|
87
|
-
*
|
|
148
|
+
* Marks the field as invalid and triggers error styling.
|
|
149
|
+
*
|
|
150
|
+
* Also affects `aria-invalid` attribute.
|
|
151
|
+
*
|
|
152
|
+
* Note: The `helper` prop can override this if it contains items with `type: 'error'`.
|
|
88
153
|
*/
|
|
89
154
|
invalid?: boolean;
|
|
90
155
|
/**
|
|
91
|
-
*
|
|
156
|
+
* Makes the field read-only.
|
|
157
|
+
*
|
|
158
|
+
* User can focus and select text, but cannot modify the value.
|
|
159
|
+
* Useful for pre-filled data that should not be changed.
|
|
92
160
|
*/
|
|
93
161
|
readOnly?: boolean;
|
|
94
162
|
/**
|
|
95
|
-
* Helper text or
|
|
163
|
+
* Helper text, success message, or error message displayed below the field.
|
|
164
|
+
*
|
|
165
|
+
* Accepts either:
|
|
166
|
+
* - A single `FeedbackTextProps` object
|
|
167
|
+
* - An array of `FeedbackTextProps` (useful for multiple messages or mixed error/success states)
|
|
168
|
+
*
|
|
169
|
+
* The component automatically detects error states from helper items.
|
|
96
170
|
*/
|
|
97
171
|
helper?: FeedbackTextProps | FeedbackTextProps[];
|
|
98
172
|
/**
|
|
99
|
-
*
|
|
173
|
+
* Fired when the input/textarea receives focus.
|
|
100
174
|
*/
|
|
101
|
-
onFocus?: React.FocusEventHandler<
|
|
175
|
+
onFocus?: React.FocusEventHandler<FieldElement>;
|
|
102
176
|
/**
|
|
103
|
-
*
|
|
177
|
+
* Fired when the input/textarea loses focus.
|
|
104
178
|
*/
|
|
105
|
-
onBlur?: React.FocusEventHandler<
|
|
179
|
+
onBlur?: React.FocusEventHandler<FieldElement>;
|
|
106
180
|
/**
|
|
107
|
-
*
|
|
181
|
+
* Hides the spinner/arrows for number inputs (`type="number"`).
|
|
182
|
+
*
|
|
183
|
+
* Only has effect when the underlying input has `type="number"`.
|
|
184
|
+
*
|
|
108
185
|
* @default true
|
|
109
186
|
*/
|
|
110
187
|
isArrowsHidden?: boolean;
|
|
111
188
|
/**
|
|
112
|
-
* Callback
|
|
189
|
+
* Callback fired when the clear button (×) is clicked.
|
|
190
|
+
*
|
|
191
|
+
* Useful if you need to perform additional actions besides clearing the value
|
|
192
|
+
* (e.g. analytics, resetting related fields, etc.).
|
|
193
|
+
*
|
|
194
|
+
* Note: The field value is automatically cleared regardless of this callback.
|
|
113
195
|
*/
|
|
114
196
|
onClear?: () => void;
|
|
115
197
|
/**
|
|
@@ -118,7 +200,7 @@ export interface TextFieldProps extends BreakpointSupport<TextFieldBreakpointPro
|
|
|
118
200
|
input?: React.InputHTMLAttributes<HTMLInputElement> | React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
119
201
|
}
|
|
120
202
|
export interface TextFieldForwardRef {
|
|
121
|
-
input:
|
|
203
|
+
input: FieldElement | null;
|
|
122
204
|
inner: HTMLDivElement | null;
|
|
123
205
|
}
|
|
124
206
|
export declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<TextFieldForwardRef>>;
|