@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.
Files changed (39) hide show
  1. package/bundle-stats.html +1 -1
  2. package/index.css +1 -1
  3. package/package.json +1 -1
  4. package/src/tedi/components/form/field/field.cjs.js +1 -0
  5. package/src/tedi/components/form/field/field.d.ts +88 -0
  6. package/src/tedi/components/form/field/field.es.js +54 -0
  7. package/src/tedi/components/form/field/field.module.scss.cjs.js +1 -0
  8. package/src/tedi/components/form/field/field.module.scss.es.js +6 -0
  9. package/src/tedi/components/form/file-upload/file-upload.cjs.js +1 -1
  10. package/src/tedi/components/form/file-upload/file-upload.d.ts +14 -2
  11. package/src/tedi/components/form/file-upload/file-upload.es.js +97 -90
  12. package/src/tedi/components/form/input-group/components/input/input.cjs.js +1 -0
  13. package/src/tedi/components/form/input-group/components/input/input.d.ts +19 -0
  14. package/src/tedi/components/form/input-group/components/input/input.es.js +20 -0
  15. package/src/tedi/components/form/input-group/components/prefix/prefix.cjs.js +1 -0
  16. package/src/tedi/components/form/input-group/components/prefix/prefix.d.ts +18 -0
  17. package/src/tedi/components/form/input-group/components/prefix/prefix.es.js +26 -0
  18. package/src/tedi/components/form/input-group/components/suffix/suffix.cjs.js +1 -0
  19. package/src/tedi/components/form/input-group/components/suffix/suffix.d.ts +18 -0
  20. package/src/tedi/components/form/input-group/components/suffix/suffix.es.js +26 -0
  21. package/src/tedi/components/form/input-group/index.d.ts +4 -0
  22. package/src/tedi/components/form/input-group/input-group.cjs.js +1 -0
  23. package/src/tedi/components/form/input-group/input-group.d.ts +87 -0
  24. package/src/tedi/components/form/input-group/input-group.es.js +61 -0
  25. package/src/tedi/components/form/input-group/input-group.module.scss.cjs.js +1 -0
  26. package/src/tedi/components/form/input-group/input-group.module.scss.es.js +16 -0
  27. package/src/tedi/components/form/search/search.cjs.js +1 -1
  28. package/src/tedi/components/form/search/search.es.js +35 -25
  29. package/src/tedi/components/form/select/components/select-control.cjs.js +1 -1
  30. package/src/tedi/components/form/select/components/select-control.es.js +7 -3
  31. package/src/tedi/components/form/select/select.cjs.js +1 -1
  32. package/src/tedi/components/form/select/select.d.ts +3 -2
  33. package/src/tedi/components/form/select/select.es.js +168 -166
  34. package/src/tedi/components/form/textfield/textfield.cjs.js +1 -1
  35. package/src/tedi/components/form/textfield/textfield.d.ts +118 -36
  36. package/src/tedi/components/form/textfield/textfield.es.js +134 -172
  37. package/src/tedi/index.d.ts +2 -0
  38. package/tedi.cjs.js +1 -1
  39. package/tedi.es.js +168 -156
@@ -1,163 +1,165 @@
1
- import { jsx as s, jsxs as h } from "react/jsx-runtime";
2
- import ge from "../../../../../external/classnames/index.es.js";
3
- import p, { forwardRef as Se } from "react";
4
- import Me from "../../../../../external/react-select/dist/react-select.esm.es.js";
5
- import be from "../../../../../external/react-select/async/dist/react-select-async.esm.es.js";
6
- import { FeedbackText as Ie } from "../feedback-text/feedback-text.es.js";
7
- import { FormLabel as Oe } from "../form-label/form-label.es.js";
8
- import { SelectClearIndicator as Ce } from "./components/select-clear-indicator.es.js";
9
- import { SelectControl as ve } from "./components/select-control.es.js";
10
- import { SelectDropDownIndicator as Le } from "./components/select-dropdown-indicator.es.js";
11
- import { SelectGroup as he } from "./components/select-group.es.js";
12
- import { SelectGroupHeading as ye } from "./components/select-group-heading.es.js";
13
- import { SelectIndicatorsContainer as Ne } from "./components/select-indicators-container.es.js";
14
- import { SelectInput as Ve } from "./components/select-input.es.js";
15
- import { SelectLoadingIndicator as Re } from "./components/select-loading-indicator.es.js";
16
- import { SelectMenu as we } from "./components/select-menu.es.js";
17
- import { SelectMenuList as _e } from "./components/select-menu-list.es.js";
18
- import { SelectMenuPortal as $e } from "./components/select-menu-portal.es.js";
19
- import { SelectMultiValue as xe } from "./components/select-multi-value.es.js";
20
- import { SelectMultiValueRemove as He } from "./components/select-multi-value-remove.es.js";
21
- import { SelectOption as Pe } from "./components/select-option.es.js";
22
- import { SelectValueContainer as Te } from "./components/select-value-container.es.js";
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 De } from "../../../providers/label-provider/use-labels.es.js";
25
- const Fe = Se(
26
- (y, N) => {
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: V,
29
- defaultOptions: R,
30
- id: a,
31
- name: w,
32
- iconName: _ = "arrow_drop_down",
33
- label: $,
34
- required: f,
35
- value: x,
36
- defaultValue: H,
37
- tagsDirection: g = "row",
38
- onChange: c,
39
- onInputChange: P,
40
- inputValue: T,
41
- loadOptions: D,
42
- isLoading: F,
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: j = !0,
45
- tabSelectsValue: k = !1,
46
- disabled: S = !1,
47
- className: B,
48
- hideLabel: E = !1,
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: q,
51
- invalid: z,
52
- valid: A,
53
- size: d,
54
- async: W = !1,
55
- renderOption: J,
56
- renderMessageListFooter: M,
57
- noOptionsMessage: K,
58
- loadingMessage: Q,
59
- multiple: m = !1,
60
- closeMenuOnSelect: U = !m,
61
- blurInputOnSelect: b = !1,
62
- autoFocus: X = !1,
63
- isClearable: Y = !0,
64
- isClearIndicatorVisible: Z = !1,
65
- isSearchable: I = !0,
66
- menuIsOpen: ee,
67
- onMenuClose: te,
68
- onMenuOpen: oe,
69
- onBlur: ae,
70
- inputIsHidden: re,
71
- isTagRemovable: O = !1,
72
- optionGroupHeadingText: ie = { modifiers: "small", color: "tertiary" },
73
- cacheOptions: ne = !0,
74
- showRadioButtons: le = !1,
75
- renderWithoutLabel: se,
76
- tooltip: ce,
77
- classNames: C
78
- } = y, v = t ? (t == null ? void 0 : t.id) ?? `${a}-helper` : void 0, i = p.useRef(null), { getLabel: L } = De();
79
- p.useImperativeHandle(
80
- N,
81
- () => i.current
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 de = (r) => {
84
- c == null || c(r), !b && i.current && setTimeout(() => {
85
- var n, l;
86
- return (l = (n = i.current) == null ? void 0 : n.inputRef) == null ? void 0 : l.focus();
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
- }, me = p.useCallback(
89
- (r) => /* @__PURE__ */ s(_e, { ...r, renderMessageListFooter: M }),
90
- [M]
91
- ), ue = () => {
92
- const r = {
93
- ClearIndicator: (e) => Ce({ isClearIndicatorVisible: Z, ...e }),
94
- DropdownIndicator: () => Le({ iconName: _ }),
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: $e,
97
- Menu: we,
98
- MenuList: me,
99
- Option: (e) => Pe({ renderOption: J, multiple: m, showRadioButtons: le, ...e }),
100
- Control: ve,
101
- Input: Ve,
102
- MultiValue: (e) => xe({ isTagRemovable: O, ...e }),
103
- MultiValueRemove: He,
104
- Group: he,
105
- GroupHeading: (e) => ye({ optionGroupHeadingText: ie, ...e }),
106
- IndicatorsContainer: Ne,
107
- ValueContainer: Te,
108
- LoadingIndicator: Re
109
- }, n = W ? be : Me, l = () => L("select.no-options"), fe = () => L("select.loading");
110
- return /* @__PURE__ */ s(
111
- n,
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: a,
114
- "aria-describedby": v,
115
- autoFocus: X,
116
- ref: i,
117
- instanceId: a,
115
+ id: p,
116
+ "aria-describedby": N,
117
+ autoFocus: ee,
118
+ ref: r,
119
+ instanceId: S,
118
120
  className: "tedi-select__wrapper",
119
- name: w,
120
- options: V,
121
- defaultOptions: R,
122
- value: x,
123
- defaultValue: H,
124
- cacheOptions: ne,
125
- onChange: de,
126
- onInputChange: P,
127
- onBlur: ae,
128
- inputValue: T,
129
- inputId: `${a}-input`,
130
- loadOptions: D,
131
- isLoading: F,
132
- noOptionsMessage: K || l,
133
- loadingMessage: Q || fe,
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: r,
136
- isDisabled: S,
137
- isSearchable: I,
138
- menuIsOpen: ee,
137
+ components: n,
138
+ isDisabled: I,
139
+ isSearchable: L,
140
+ menuIsOpen: ae,
139
141
  openMenuOnFocus: G,
140
- openMenuOnClick: j,
141
- tabSelectsValue: k,
142
- onMenuClose: te,
143
- onMenuOpen: oe,
144
- placeholder: q || "",
145
- isClearable: Y,
146
- backspaceRemovesValue: O,
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: m,
150
+ isMulti: u,
149
151
  hideSelectedOptions: !1,
150
- closeMenuOnSelect: U,
151
- blurInputOnSelect: b,
152
+ closeMenuOnSelect: Z,
153
+ blurInputOnSelect: C,
152
154
  menuPlacement: "auto",
153
- inputIsHidden: re,
154
- required: f,
155
+ inputIsHidden: se,
156
+ required: b,
155
157
  menuPortalTarget: document.body,
156
158
  menuPosition: "absolute",
157
- classNames: C ? Object.fromEntries(
158
- Object.entries(C).map(([e, u]) => [
159
+ classNames: y ? Object.fromEntries(
160
+ Object.entries(y).map(([e, f]) => [
159
161
  e,
160
- typeof u == "string" ? () => u : u
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
- }, pe = ge(
182
+ }, Me = Oe(
181
183
  o["tedi-select"],
182
- B,
183
- { [o["tedi-select--invalid"]]: z || (t == null ? void 0 : t.type) === "error" },
184
- { [o["tedi-select--valid"]]: A || (t == null ? void 0 : t.type) === "valid" },
185
- { [o[`tedi-select--${d}`]]: d },
186
- { [o[`tedi-select--tags-${g}`]]: g },
187
- { [o["tedi-select--searchable"]]: I },
188
- { [o["tedi-select--disabled"]]: S }
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__ */ h("div", { "data-name": "select", className: pe, children: [
191
- /* @__PURE__ */ h("div", { className: o["tedi-select__inner"], children: [
192
- /* @__PURE__ */ s(
193
- Oe,
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: `${a}-input`,
196
- label: $,
197
- required: f,
198
- hideLabel: E,
199
- size: d,
200
- renderWithoutLabel: se,
201
- tooltip: ce
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
- ue()
206
+ be()
205
207
  ] }),
206
- t && /* @__PURE__ */ s(Ie, { ...t, id: v })
208
+ t && /* @__PURE__ */ l(he, { ...t, id: N })
207
209
  ] });
208
210
  }
209
211
  );
210
- Fe.displayName = "Select";
212
+ qe.displayName = "Select";
211
213
  export {
212
- Fe as Select
214
+ qe as Select
213
215
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),p=require("../../../../../external/classnames/index.cjs.js"),r=require("react"),ce=require("../../base/icon/icon.cjs.js"),fe=require("../../buttons/closing-button/closing-button.cjs.js"),xe=require("../../misc/separator/separator.cjs.js"),U=require("../feedback-text/feedback-text.cjs.js"),pe=require("../form-label/form-label.cjs.js"),a=require("./textfield.module.scss.cjs.js"),me=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),be=require("../../../providers/label-provider/use-labels.cjs.js"),ye={large:24,default:18},C=r.forwardRef((f,G)=>{const{getCurrentBreakpointProps:J}=me.useBreakpointProps(f.defaultServerBreakpoint),{id:u,label:k,className:Q,inputClassName:q,disabled:l,required:A,hideLabel:h,invalid:o,readOnly:B,icon:c,onIconClick:m,size:n,placeholder:T,isArrowsHidden:M=!0,isClearable:R,onClear:b,onChange:d,onChangeEvent:y,onKeyUp:X,onKeyDown:Y,onKeyPress:ve,defaultValue:Z,value:j,onFocus:w,onBlur:F,onClick:ee,helper:t,input:P,name:S,isTextArea:v,...te}=J(f)||{},{getLabel:$}=be.useLabels(),x=r.useRef(null),z=r.useRef(null),[L,V]=r.useState(j??Z??""),_=r.useMemo(()=>{var e;if(t)return Array.isArray(t)?((e=t[0])==null?void 0:e.id)??`${u}-helper`:t.id??`${u}-helper`},[t,u]),N=r.useMemo(()=>j??L,[j,L]),g=R&&N;r.useImperativeHandle(G,()=>({get input(){return x.current},get inner(){return z.current}}));const I=r.useMemo(()=>Array.isArray(t)?o||t.some(e=>e.type==="error"):o||(t==null?void 0:t.type)==="error",[o,t]),re=r.useMemo(()=>!t||Array.isArray(t)&&t.length===0?!1:Array.isArray(t)?!o&&t.every(e=>e.type==="valid"):!o&&t.type==="valid",[o,t]),ae=n==="large"?"default":n,H=r.useCallback(e=>{const s={size:n==="large"?24:n==="small"?16:18,className:p.default(a.default["tedi-textfield__icon"])},de=typeof e=="string"?{...s,name:e}:{...s,...e,className:p.default(s.className,e==null?void 0:e.className)},ue=i.jsx(ce.Icon,{...de}),oe=m?"button":"div";return i.jsx(oe,{className:a.default["tedi-textfield__icon-wrapper"],type:m?"button":void 0,onClick:l?void 0:m,disabled:l,tabIndex:l?-1:0,children:ue})},[l,m,n]),K=r.useCallback(e=>{const s=e.currentTarget.value;V(s),d==null||d(s),y==null||y(e)},[d,y]),E=r.useCallback(()=>{V(""),d==null||d(""),b==null||b()},[d,b]),O=r.useCallback((e,s)=>!!v,[v]),W=r.useCallback((e,s)=>!v,[v]),le=r.useMemo(()=>{const e={...P,id:u,name:S,...h?{"aria-label":k}:{},"aria-describedby":_,"aria-disabled":l||void 0,className:p.default(a.default["tedi-textfield__input"],q,{[a.default["tedi-textfield__input--hidden-arrows"]]:M}),disabled:l,required:A,"aria-invalid":I||void 0,placeholder:T,readOnly:B,onChange:K,value:N,onBlur:F,onFocus:w};return O(f,x)?i.jsx("textarea",{...e,ref:x,tabIndex:l?-1:0}):W(f,x)?i.jsx("input",{...e,ref:x,tabIndex:l?-1:0}):null},[P,u,S,h,k,_,l,q,M,A,I,T,B,K,N,F,w,O,f,W]),D=r.useMemo(()=>{const e={iconSize:ye[n==="large"?"large":"default"],onClick:l?()=>{}:E,disabled:l,"aria-disabled":l||void 0,title:`${$("clear")}`,className:p.default(a.default["tedi-textfield__clear-button"])};return i.jsx(fe.ClosingButton,{...e})},[E,l,$,n]),ie=r.useMemo(()=>i.jsxs("div",{className:a.default["tedi-textfield__right-area"],children:[g&&D,g&&c?i.jsx(xe.Separator,{color:"primary",axis:"vertical",className:a.default["tedi-textfield__separator"]}):null,c&&H(c)]}),[H,c,D,g]),se=p.default(a.default["tedi-textfield"],{[a.default[`tedi-textfield--${n}`]]:n},{[a.default["tedi-textfield--with-icon"]]:c},{[a.default["tedi-textfield--invalid"]]:I},{[a.default["tedi-textfield--valid"]]:re},{[a.default["tedi-textfield--clearable"]]:g},Q),ne=()=>!t||Array.isArray(t)&&t.length===0?null:i.jsx("div",{className:a.default["tedi-textfield__feedback-wrapper"],children:Array.isArray(t)?t.map((e,s)=>i.jsx(U.FeedbackText,{...e,id:`${_}-${s}`},s)):i.jsx(U.FeedbackText,{...t,id:_})});return i.jsxs("div",{"data-name":"textfield",...te,className:se,children:[i.jsx(pe.FormLabel,{id:u,label:k,required:A,hideLabel:h,size:ae}),i.jsxs("div",{className:a.default["tedi-textfield__inner"],onKeyDown:Y,onKeyUp:X,onClick:ee,ref:z,children:[le,R||c?ie:null]}),ne()]})});C.displayName="TextField";exports.TextField=C;exports.default=C;
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
- * Input field size
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 name or configuration for the input field.
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
- * Whether to render a textarea instead of an input.
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 displayed inside the input.
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
- * Whether the input includes a clear button.
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
- * Custom CSS classes for the container.
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 input field.
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: string;
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 classes for the input element.
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 triggered when the input value changes.
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
- * Callback triggered with the change event.
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<HTMLTextAreaElement | HTMLInputElement>;
98
+ onChangeEvent?: React.ChangeEventHandler<FieldElement>;
54
99
  /**
55
- * Callback for keypress events.
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
- * Initial default value of the input.
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 input field.
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
- * Callback for clicking the icon.
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
- * Callback for input container clicks.
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
- * Whether the input is disabled.
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
- * Whether the input is marked as invalid.
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
- * Whether the input is read-only.
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 feedback messages.
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
- * Callback for input focus events.
173
+ * Fired when the input/textarea receives focus.
100
174
  */
101
- onFocus?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
175
+ onFocus?: React.FocusEventHandler<FieldElement>;
102
176
  /**
103
- * Callback for input blur events.
177
+ * Fired when the input/textarea loses focus.
104
178
  */
105
- onBlur?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
179
+ onBlur?: React.FocusEventHandler<FieldElement>;
106
180
  /**
107
- * Whether to hide arrows for number inputs.
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 triggered when the clear button is clicked.
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: HTMLInputElement | HTMLTextAreaElement | null;
203
+ input: FieldElement | null;
122
204
  inner: HTMLDivElement | null;
123
205
  }
124
206
  export declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<TextFieldForwardRef>>;