@frontify/fondue-components 27.0.1 → 28.0.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.
Files changed (254) hide show
  1. package/dist/fondue-components.js +55 -53
  2. package/dist/fondue-components.js.map +1 -1
  3. package/dist/fondue-components10.js +1 -1
  4. package/dist/fondue-components100.js +17 -6
  5. package/dist/fondue-components100.js.map +1 -1
  6. package/dist/fondue-components101.js +150 -11
  7. package/dist/fondue-components101.js.map +1 -1
  8. package/dist/fondue-components102.js +44 -70
  9. package/dist/fondue-components102.js.map +1 -1
  10. package/dist/fondue-components103.js +14 -15
  11. package/dist/fondue-components103.js.map +1 -1
  12. package/dist/fondue-components104.js +15 -7
  13. package/dist/fondue-components104.js.map +1 -1
  14. package/dist/fondue-components105.js +107 -85
  15. package/dist/fondue-components105.js.map +1 -1
  16. package/dist/fondue-components106.js +11 -79
  17. package/dist/fondue-components106.js.map +1 -1
  18. package/dist/fondue-components107.js +17 -31
  19. package/dist/fondue-components107.js.map +1 -1
  20. package/dist/fondue-components108.js +11 -19
  21. package/dist/fondue-components108.js.map +1 -1
  22. package/dist/fondue-components109.js +16 -39
  23. package/dist/fondue-components109.js.map +1 -1
  24. package/dist/fondue-components11.js +3 -3
  25. package/dist/fondue-components110.js +9 -0
  26. package/dist/fondue-components110.js.map +1 -0
  27. package/dist/fondue-components111.js +15 -0
  28. package/dist/fondue-components111.js.map +1 -0
  29. package/dist/fondue-components112.js +74 -0
  30. package/dist/fondue-components112.js.map +1 -0
  31. package/dist/fondue-components113.js +18 -0
  32. package/dist/fondue-components113.js.map +1 -0
  33. package/dist/fondue-components114.js +10 -0
  34. package/dist/fondue-components114.js.map +1 -0
  35. package/dist/fondue-components115.js +92 -0
  36. package/dist/fondue-components115.js.map +1 -0
  37. package/dist/fondue-components116.js +84 -0
  38. package/dist/fondue-components116.js.map +1 -0
  39. package/dist/fondue-components117.js +34 -0
  40. package/dist/fondue-components117.js.map +1 -0
  41. package/dist/fondue-components118.js +32 -0
  42. package/dist/fondue-components118.js.map +1 -0
  43. package/dist/fondue-components12.js +7 -37
  44. package/dist/fondue-components12.js.map +1 -1
  45. package/dist/fondue-components120.js +44 -0
  46. package/dist/fondue-components120.js.map +1 -0
  47. package/dist/fondue-components121.js +22 -0
  48. package/dist/fondue-components121.js.map +1 -0
  49. package/dist/fondue-components122.js +24 -0
  50. package/dist/fondue-components122.js.map +1 -0
  51. package/dist/fondue-components123.js +43 -0
  52. package/dist/fondue-components123.js.map +1 -0
  53. package/dist/fondue-components124.js +71 -0
  54. package/dist/fondue-components124.js.map +1 -0
  55. package/dist/fondue-components125.js +34 -0
  56. package/dist/fondue-components125.js.map +1 -0
  57. package/dist/fondue-components126.js +12 -0
  58. package/dist/fondue-components126.js.map +1 -0
  59. package/dist/fondue-components127.js +156 -0
  60. package/dist/fondue-components127.js.map +1 -0
  61. package/dist/fondue-components128.js +111 -0
  62. package/dist/fondue-components128.js.map +1 -0
  63. package/dist/fondue-components129.js +19 -0
  64. package/dist/fondue-components129.js.map +1 -0
  65. package/dist/fondue-components13.js +36 -121
  66. package/dist/fondue-components13.js.map +1 -1
  67. package/dist/fondue-components130.js +19 -0
  68. package/dist/fondue-components130.js.map +1 -0
  69. package/dist/fondue-components131.js +32 -0
  70. package/dist/fondue-components131.js.map +1 -0
  71. package/dist/fondue-components132.js +16 -0
  72. package/dist/fondue-components132.js.map +1 -0
  73. package/dist/fondue-components133.js +10 -0
  74. package/dist/fondue-components133.js.map +1 -0
  75. package/dist/fondue-components14.js +121 -36
  76. package/dist/fondue-components14.js.map +1 -1
  77. package/dist/fondue-components15.js +30 -39
  78. package/dist/fondue-components15.js.map +1 -1
  79. package/dist/fondue-components16.js +44 -41
  80. package/dist/fondue-components16.js.map +1 -1
  81. package/dist/fondue-components17.js +42 -57
  82. package/dist/fondue-components17.js.map +1 -1
  83. package/dist/fondue-components18.js +55 -41
  84. package/dist/fondue-components18.js.map +1 -1
  85. package/dist/fondue-components19.js +39 -16
  86. package/dist/fondue-components19.js.map +1 -1
  87. package/dist/fondue-components20.js +17 -43
  88. package/dist/fondue-components20.js.map +1 -1
  89. package/dist/fondue-components21.js +42 -69
  90. package/dist/fondue-components21.js.map +1 -1
  91. package/dist/fondue-components22.js +72 -16
  92. package/dist/fondue-components22.js.map +1 -1
  93. package/dist/fondue-components23.js +18 -77
  94. package/dist/fondue-components23.js.map +1 -1
  95. package/dist/fondue-components24.js +75 -34
  96. package/dist/fondue-components24.js.map +1 -1
  97. package/dist/fondue-components25.js +34 -53
  98. package/dist/fondue-components25.js.map +1 -1
  99. package/dist/fondue-components26.js +55 -23
  100. package/dist/fondue-components26.js.map +1 -1
  101. package/dist/fondue-components27.js +23 -55
  102. package/dist/fondue-components27.js.map +1 -1
  103. package/dist/fondue-components28.js +52 -97
  104. package/dist/fondue-components28.js.map +1 -1
  105. package/dist/fondue-components29.js +98 -31
  106. package/dist/fondue-components29.js.map +1 -1
  107. package/dist/fondue-components3.js +1 -1
  108. package/dist/fondue-components30.js +31 -194
  109. package/dist/fondue-components30.js.map +1 -1
  110. package/dist/fondue-components31.js +184 -134
  111. package/dist/fondue-components31.js.map +1 -1
  112. package/dist/fondue-components32.js +143 -130
  113. package/dist/fondue-components32.js.map +1 -1
  114. package/dist/fondue-components33.js +131 -30
  115. package/dist/fondue-components33.js.map +1 -1
  116. package/dist/fondue-components34.js +29 -78
  117. package/dist/fondue-components34.js.map +1 -1
  118. package/dist/fondue-components35.js +67 -110
  119. package/dist/fondue-components35.js.map +1 -1
  120. package/dist/fondue-components36.js +121 -34
  121. package/dist/fondue-components36.js.map +1 -1
  122. package/dist/fondue-components37.js +36 -56
  123. package/dist/fondue-components37.js.map +1 -1
  124. package/dist/fondue-components38.js +56 -20
  125. package/dist/fondue-components38.js.map +1 -1
  126. package/dist/fondue-components39.js +20 -23
  127. package/dist/fondue-components39.js.map +1 -1
  128. package/dist/fondue-components4.js +3 -3
  129. package/dist/fondue-components40.js +25 -7
  130. package/dist/fondue-components40.js.map +1 -1
  131. package/dist/fondue-components41.js +7 -8
  132. package/dist/fondue-components41.js.map +1 -1
  133. package/dist/fondue-components42.js +9 -41
  134. package/dist/fondue-components42.js.map +1 -1
  135. package/dist/fondue-components43.js +41 -5
  136. package/dist/fondue-components43.js.map +1 -1
  137. package/dist/fondue-components44.js +1 -1
  138. package/dist/fondue-components45.js +3 -11
  139. package/dist/fondue-components45.js.map +1 -1
  140. package/dist/fondue-components46.js +13 -32
  141. package/dist/fondue-components46.js.map +1 -1
  142. package/dist/fondue-components47.js +32 -54
  143. package/dist/fondue-components47.js.map +1 -1
  144. package/dist/fondue-components48.js +48 -125
  145. package/dist/fondue-components48.js.map +1 -1
  146. package/dist/fondue-components49.js +130 -20
  147. package/dist/fondue-components49.js.map +1 -1
  148. package/dist/fondue-components5.js +2 -2
  149. package/dist/fondue-components50.js +21 -53
  150. package/dist/fondue-components50.js.map +1 -1
  151. package/dist/fondue-components51.js +53 -8
  152. package/dist/fondue-components51.js.map +1 -1
  153. package/dist/fondue-components52.js +8 -13
  154. package/dist/fondue-components52.js.map +1 -1
  155. package/dist/fondue-components53.js +13 -17
  156. package/dist/fondue-components53.js.map +1 -1
  157. package/dist/fondue-components54.js +16 -4
  158. package/dist/fondue-components54.js.map +1 -1
  159. package/dist/fondue-components55.js +5 -18
  160. package/dist/fondue-components55.js.map +1 -1
  161. package/dist/fondue-components56.js +18 -19
  162. package/dist/fondue-components56.js.map +1 -1
  163. package/dist/fondue-components57.js +18 -4
  164. package/dist/fondue-components57.js.map +1 -1
  165. package/dist/fondue-components58.js +43 -12
  166. package/dist/fondue-components58.js.map +1 -1
  167. package/dist/fondue-components59.js +24 -4
  168. package/dist/fondue-components59.js.map +1 -1
  169. package/dist/fondue-components6.js +1 -1
  170. package/dist/fondue-components60.js +22 -17
  171. package/dist/fondue-components60.js.map +1 -1
  172. package/dist/fondue-components61.js +4 -10
  173. package/dist/fondue-components61.js.map +1 -1
  174. package/dist/fondue-components62.js +11 -35
  175. package/dist/fondue-components62.js.map +1 -1
  176. package/dist/fondue-components63.js +4 -6
  177. package/dist/fondue-components63.js.map +1 -1
  178. package/dist/fondue-components64.js +17 -4
  179. package/dist/fondue-components64.js.map +1 -1
  180. package/dist/fondue-components65.js +10 -12
  181. package/dist/fondue-components65.js.map +1 -1
  182. package/dist/fondue-components66.js +35 -7
  183. package/dist/fondue-components66.js.map +1 -1
  184. package/dist/fondue-components67.js +6 -12
  185. package/dist/fondue-components67.js.map +1 -1
  186. package/dist/fondue-components68.js +1 -1
  187. package/dist/fondue-components69.js +12 -24
  188. package/dist/fondue-components69.js.map +1 -1
  189. package/dist/fondue-components7.js +1 -1
  190. package/dist/fondue-components70.js +8 -16
  191. package/dist/fondue-components70.js.map +1 -1
  192. package/dist/fondue-components71.js +13 -20
  193. package/dist/fondue-components71.js.map +1 -1
  194. package/dist/fondue-components72.js +5 -20
  195. package/dist/fondue-components72.js.map +1 -1
  196. package/dist/fondue-components73.js +24 -19
  197. package/dist/fondue-components73.js.map +1 -1
  198. package/dist/fondue-components74.js +17 -20
  199. package/dist/fondue-components74.js.map +1 -1
  200. package/dist/fondue-components75.js +20 -19
  201. package/dist/fondue-components75.js.map +1 -1
  202. package/dist/fondue-components76.js +20 -8
  203. package/dist/fondue-components76.js.map +1 -1
  204. package/dist/fondue-components77.js +20 -11
  205. package/dist/fondue-components77.js.map +1 -1
  206. package/dist/fondue-components78.js +20 -11
  207. package/dist/fondue-components78.js.map +1 -1
  208. package/dist/fondue-components79.js +19 -7
  209. package/dist/fondue-components79.js.map +1 -1
  210. package/dist/fondue-components8.js +5 -5
  211. package/dist/fondue-components80.js +8 -13
  212. package/dist/fondue-components80.js.map +1 -1
  213. package/dist/fondue-components81.js +10 -22
  214. package/dist/fondue-components81.js.map +1 -1
  215. package/dist/fondue-components82.js +11 -34
  216. package/dist/fondue-components82.js.map +1 -1
  217. package/dist/fondue-components83.js +6 -10
  218. package/dist/fondue-components83.js.map +1 -1
  219. package/dist/fondue-components84.js +12 -67
  220. package/dist/fondue-components84.js.map +1 -1
  221. package/dist/fondue-components85.js +22 -14
  222. package/dist/fondue-components85.js.map +1 -1
  223. package/dist/fondue-components86.js +34 -25
  224. package/dist/fondue-components86.js.map +1 -1
  225. package/dist/fondue-components87.js +8 -16
  226. package/dist/fondue-components87.js.map +1 -1
  227. package/dist/fondue-components88.js +67 -24
  228. package/dist/fondue-components88.js.map +1 -1
  229. package/dist/fondue-components89.js +14 -8
  230. package/dist/fondue-components89.js.map +1 -1
  231. package/dist/fondue-components9.js +5 -5
  232. package/dist/fondue-components90.js +24 -25
  233. package/dist/fondue-components90.js.map +1 -1
  234. package/dist/fondue-components91.js +18 -6
  235. package/dist/fondue-components91.js.map +1 -1
  236. package/dist/fondue-components92.js +24 -4
  237. package/dist/fondue-components92.js.map +1 -1
  238. package/dist/fondue-components93.js +8 -4
  239. package/dist/fondue-components93.js.map +1 -1
  240. package/dist/fondue-components94.js +30 -16
  241. package/dist/fondue-components94.js.map +1 -1
  242. package/dist/fondue-components95.js +6 -216
  243. package/dist/fondue-components95.js.map +1 -1
  244. package/dist/fondue-components96.js +4 -18
  245. package/dist/fondue-components96.js.map +1 -1
  246. package/dist/fondue-components97.js +4 -16
  247. package/dist/fondue-components97.js.map +1 -1
  248. package/dist/fondue-components98.js +188 -122
  249. package/dist/fondue-components98.js.map +1 -1
  250. package/dist/fondue-components99.js +18 -44
  251. package/dist/fondue-components99.js.map +1 -1
  252. package/dist/index.d.ts +101 -24
  253. package/dist/style.css +1 -1
  254. package/package.json +5 -3
@@ -1,84 +1,35 @@
1
- import { jsxs as m, jsx as t } from "react/jsx-runtime";
2
- import { IconCheckMark as w, IconExclamationMarkTriangle as h } from "@frontify/fondue-icons";
3
- import { forwardRef as f, useRef as S } from "react";
4
- import { LoadingCircle as T } from "./fondue-components19.js";
5
- import a from "./fondue-components87.js";
6
- const u = ({
7
- children: s,
8
- className: c,
9
- status: e = "neutral",
10
- "data-test-id": l = "fondue-text-input",
11
- "aria-errormessage": R,
12
- placeholder: n,
13
- ...o
14
- }, N) => {
15
- const d = S(!1);
16
- return /* @__PURE__ */ m(
17
- "div",
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { forwardRef as p } from "react";
3
+ import t from "./fondue-components90.js";
4
+ const n = p(
5
+ ({
6
+ children: o,
7
+ as: a = "span",
8
+ size: r = "medium",
9
+ weight: s = "default",
10
+ color: i = "default",
11
+ boxColor: e,
12
+ className: m,
13
+ ...d
14
+ }, f) => /* @__PURE__ */ l(
15
+ a,
18
16
  {
19
- className: [a.root, c].filter(Boolean).join(" "),
20
- "data-status": e,
21
- "data-test-id": l,
22
- children: [
23
- e === "loading" ? /* @__PURE__ */ t("div", { className: a.loadingStatus, "data-test-id": `${l}-loader`, children: /* @__PURE__ */ t(T, { size: "xx-small" }) }) : null,
24
- /* @__PURE__ */ m("div", { className: a.inputWrapper, children: [
25
- n && /* @__PURE__ */ t("div", { className: a.placeholder, children: n }),
26
- /* @__PURE__ */ t(
27
- "input",
28
- {
29
- onMouseDown: (r) => {
30
- d.current = !0, r.currentTarget.dataset.showFocusRing = "false";
31
- },
32
- type: "text",
33
- placeholder: n,
34
- ...o,
35
- onFocus: (r) => {
36
- var i;
37
- d.current || (r.target.dataset.showFocusRing = "true"), (i = o.onFocus) == null || i.call(o, r);
38
- },
39
- onBlur: (r) => {
40
- var i;
41
- r.target.dataset.showFocusRing = "false", d.current = !1, (i = o.onBlur) == null || i.call(o, r);
42
- },
43
- ref: N,
44
- className: a.input,
45
- "aria-invalid": e === "error",
46
- "aria-errormessage": e === "error" ? R : void 0
47
- }
48
- )
49
- ] }),
50
- e === "success" ? /* @__PURE__ */ t(w, { size: 16, className: a.iconSuccess, "data-test-id": `${l}-success-icon` }) : null,
51
- e === "error" ? /* @__PURE__ */ t(
52
- h,
53
- {
54
- size: 16,
55
- className: a.iconError,
56
- "data-test-id": `${l}-error-icon`
57
- }
58
- ) : null,
59
- s
60
- ]
17
+ "data-test-id": "text",
18
+ className: [
19
+ t.root,
20
+ t[`size-${r}`],
21
+ t[`weight-${s}`],
22
+ t[e ? `color-box-${e}` : `color-${i}`],
23
+ m
24
+ ].filter(Boolean).join(" "),
25
+ ref: f,
26
+ ...d,
27
+ children: o
61
28
  }
62
- );
63
- };
64
- u.displayName = "TextField.Root";
65
- const x = ({ name: s, className: c, ...e }, l) => /* @__PURE__ */ t(
66
- "div",
67
- {
68
- "data-slot": !0,
69
- "data-name": s,
70
- ...e,
71
- ref: l,
72
- className: [a.slot, c].filter(Boolean).join(" ")
73
- }
29
+ )
74
30
  );
75
- x.displayName = "TextField.Slot";
76
- const F = f(u), v = f(x), g = F;
77
- g.Root = F;
78
- g.Slot = v;
31
+ n.displayName = "FondueText";
79
32
  export {
80
- u as TextFieldRoot,
81
- x as TextFieldSlot,
82
- g as TextInput
33
+ n as Text
83
34
  };
84
35
  //# sourceMappingURL=fondue-components34.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components34.js","sources":["../src/components/TextInput/TextInput.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCheckMark, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport {\n forwardRef,\n useRef,\n type ChangeEvent,\n type FocusEvent,\n type ForwardedRef,\n type KeyboardEvent,\n type ReactNode,\n type SyntheticEvent,\n} from 'react';\n\nimport { LoadingCircle } from '../LoadingCircle/LoadingCircle';\n\nimport styles from './styles/text.module.scss';\n\nexport type TextInputProps = {\n id?: string;\n name?: string;\n /**\n * The place where the input slots are placed\n */\n children?: ReactNode;\n /**\n * The default value of the text input\n * Used for uncontrolled components\n */\n defaultValue?: string | number;\n /**\n * The controlled value of the text input\n */\n value?: string | number;\n /**\n * Type of the text input\n * @default \"text\"\n */\n type?: 'date' | 'email' | 'hidden' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url';\n /**\n * The placeholder in the text input\n */\n placeholder?: string;\n /**\n * Disable the text input\n * @default false\n */\n disabled?: boolean;\n /**\n * Make the text input required in form\n * @default false\n */\n required?: boolean;\n /**\n * Make the text input spell-checkable\n * @default true\n */\n spellCheck?: boolean;\n /**\n * Make the text input read-only\n * @default false\n */\n readOnly?: boolean;\n /**\n * Set the type of input so autocomplete can help the user\n * @default \"on\"\n */\n autoComplete?: string;\n /**\n * The maximum length of the text input\n */\n maxLength?: number;\n /**\n * Status of the text input\n * @default \"neutral\"\n */\n status?: 'neutral' | 'success' | 'error' | 'loading';\n className?: string;\n /**\n * Event handler called when the text input value changes\n */\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the text input is blurred\n */\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the text input is focused\n */\n onFocus?: (event: FocusEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when a key is pressed\n */\n onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when a key is released\n */\n onKeyUp?: (event: KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the text inside of text input is selected\n */\n onSelect?: (event: SyntheticEvent<HTMLInputElement>) => void;\n 'data-test-id'?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n 'aria-errormessage'?: string;\n};\n\nexport const TextFieldRoot = (\n {\n children,\n className,\n status = 'neutral',\n 'data-test-id': dataTestId = 'fondue-text-input',\n 'aria-errormessage': ariaErrormessage,\n placeholder,\n ...inputProps\n }: TextInputProps,\n ref: ForwardedRef<HTMLInputElement>,\n) => {\n const wasClicked = useRef(false);\n\n return (\n <div\n className={[styles.root, className].filter(Boolean).join(' ')}\n data-status={status}\n data-test-id={dataTestId}\n >\n {status === 'loading' ? (\n <div className={styles.loadingStatus} data-test-id={`${dataTestId}-loader`}>\n <LoadingCircle size=\"xx-small\" />\n </div>\n ) : null}\n <div className={styles.inputWrapper}>\n {placeholder && <div className={styles.placeholder}>{placeholder}</div>}\n <input\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n type=\"text\"\n placeholder={placeholder}\n {...inputProps}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n inputProps.onFocus?.(focusEvent);\n }}\n onBlur={(blurEvent) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n inputProps.onBlur?.(blurEvent);\n }}\n ref={ref}\n className={styles.input}\n aria-invalid={status === 'error'}\n aria-errormessage={status === 'error' ? ariaErrormessage : undefined}\n />\n </div>\n\n {status === 'success' ? (\n <IconCheckMark size={16} className={styles.iconSuccess} data-test-id={`${dataTestId}-success-icon`} />\n ) : null}\n\n {status === 'error' ? (\n <IconExclamationMarkTriangle\n size={16}\n className={styles.iconError}\n data-test-id={`${dataTestId}-error-icon`}\n />\n ) : null}\n\n {children}\n </div>\n );\n};\nTextFieldRoot.displayName = 'TextField.Root';\n\nexport type TextFieldSlotProps = {\n children: ReactNode;\n name?: 'left' | 'right';\n className?: string;\n};\n\nexport const TextFieldSlot = (\n { name, className, ...slotProps }: TextFieldSlotProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div\n data-slot\n data-name={name}\n {...slotProps}\n ref={forwardedRef}\n className={[styles.slot, className].filter(Boolean).join(' ')}\n />\n );\n};\n\nTextFieldSlot.displayName = 'TextField.Slot';\n\nconst ForwardedRefTextFieldRoot = forwardRef<HTMLInputElement, TextInputProps>(TextFieldRoot);\nconst ForwardedRefTextFieldSlot = forwardRef<HTMLDivElement, TextFieldSlotProps>(TextFieldSlot);\n// @ts-expect-error We support both single component (without slots) and compound components (with slots)\nexport const TextInput: typeof TextFieldRoot & {\n Root: typeof ForwardedRefTextFieldRoot;\n Slot: typeof ForwardedRefTextFieldSlot;\n} = ForwardedRefTextFieldRoot;\nTextInput.Root = ForwardedRefTextFieldRoot;\nTextInput.Slot = ForwardedRefTextFieldSlot;\n"],"names":["TextFieldRoot","children","className","status","dataTestId","ariaErrormessage","placeholder","inputProps","ref","wasClicked","useRef","jsxs","styles","jsx","LoadingCircle","mouseEvent","focusEvent","_a","blurEvent","IconCheckMark","IconExclamationMarkTriangle","TextFieldSlot","name","slotProps","forwardedRef","ForwardedRefTextFieldRoot","forwardRef","ForwardedRefTextFieldSlot","TextInput"],"mappings":";;;;;AA6GO,MAAMA,IAAgB,CACzB;AAAA,EACI,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,gBAAgBC,IAAa;AAAA,EAC7B,qBAAqBC;AAAA,EACrB,aAAAC;AAAA,EACA,GAAGC;AACP,GACAC,MACC;AACD,QAAMC,IAAaC,EAAO,EAAK;AAE/B,SACI,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW,CAACC,EAAO,MAAMV,CAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MAC5D,eAAaC;AAAA,MACb,gBAAcC;AAAA,MAEb,UAAA;AAAA,QAAAD,MAAW,YACR,gBAAAU,EAAC,OAAA,EAAI,WAAWD,EAAO,eAAe,gBAAc,GAAGR,CAAU,WAC7D,UAAA,gBAAAS,EAACC,GAAA,EAAc,MAAK,WAAA,CAAW,GACnC,IACA;AAAA,QACJ,gBAAAH,EAAC,OAAA,EAAI,WAAWC,EAAO,cAClB,UAAA;AAAA,UAAAN,KAAe,gBAAAO,EAAC,OAAA,EAAI,WAAWD,EAAO,aAAc,UAAAN,GAAY;AAAA,UACjE,gBAAAO;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,aAAa,CAACE,MAAe;AACzB,gBAAAN,EAAW,UAAU,IACrBM,EAAW,cAAc,QAAQ,gBAAgB;AAAA,cACrD;AAAA,cACA,MAAK;AAAA,cACL,aAAAT;AAAA,cACC,GAAGC;AAAA,cACJ,SAAS,CAACS,MAAe;;AACrB,gBAAKP,EAAW,YACZO,EAAW,OAAO,QAAQ,gBAAgB,UAE9CC,IA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) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type ReactNode, forwardRef, type ForwardedRef, type HTMLAttributeAnchorTarget } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\n\nimport styles from './styles/text.module.scss';\n\ntype TextWeight = 'default' | 'strong' | 'x-strong';\ntype TextSize = 'x-small' | 'small' | 'medium' | 'large';\ntype TextColor = 'default' | 'weak' | 'x-weak' | 'disabled' | 'negative' | 'positive' | 'warning' | 'interactive';\ntype BoxColor = 'neutral' | 'selected' | 'disabled' | 'positive' | 'negative' | 'warning';\n\ntype TagType = 'a' | 'abbr' | 'address' | 'em' | 'label' | 'li' | 'span' | 'strong' | 'time' | 'p';\n\nexport type TextProps<TTag extends TagType = 'span'> = CommonAriaProps &\n TagProps<TTag> & {\n /**\n * Id of the element\n */\n id?: string;\n /**\n * Size of the text\n *\n * @default 'medium'\n */\n size?: TextSize;\n /**\n * Weight of the font\n *\n * @default 'default'\n */\n weight?: TextWeight;\n /**\n * The html element used to render\n *\n * @default 'span'\n */\n as?: TTag;\n /**\n * Color of the text\n *\n * @default 'default'\n */\n color?: TextColor;\n /**\n * The texts color when used within a box\n *\n * @description optional color prop that uses the inverse box color when accessibility contrast is needed\n **/\n boxColor?: BoxColor;\n className?: string;\n children?: ReactNode;\n };\n\ntype TagPropMap = {\n a: { href?: string; target: HTMLAttributeAnchorTarget; rel?: string; title?: string };\n abbr: { title?: string };\n address: object;\n em: object;\n label: { for?: string };\n li: { value?: string };\n p: object;\n span: object;\n strong: object;\n time: { dateTime?: string };\n};\ntype TagProps<TTag extends TagType> = TagPropMap[TTag];\n\ntype TextElementMap = {\n a: HTMLAnchorElement;\n abbr: HTMLElement;\n address: HTMLElement;\n em: HTMLElement;\n label: HTMLLabelElement;\n li: HTMLLIElement;\n p: HTMLParagraphElement;\n span: HTMLSpanElement;\n strong: HTMLElement;\n time: HTMLTimeElement;\n};\ntype TextElementType<TTag extends TagType> = TextElementMap[TTag];\n\nexport const Text = forwardRef(\n (\n {\n children,\n as: Tag = 'span',\n size = 'medium',\n weight = 'default',\n color = 'default',\n boxColor,\n className,\n ...props\n },\n ref,\n ) => (\n <Tag\n data-test-id=\"text\"\n className={[\n styles.root,\n styles[`size-${size}`],\n styles[`weight-${weight}`],\n styles[boxColor ? `color-box-${boxColor}` : `color-${color}`],\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n // @ts-expect-error ref can not be inferred properly by TS\n ref={ref}\n {...props}\n >\n {children}\n </Tag>\n ),\n) as (<TTag extends TagType = 'span'>(\n props: TextProps<TTag> & { ref?: ForwardedRef<TextElementType<TTag>> },\n) => JSX.Element) & { displayName: string };\n\nText.displayName = 'FondueText';\n"],"names":["Text","forwardRef","children","Tag","size","weight","color","boxColor","className","props","ref","jsx","styles"],"mappings":";;;AAmFO,MAAMA,IAAOC;AAAA,EAChB,CACI;AAAA,IACI,UAAAC;AAAA,IACA,IAAIC,IAAM;AAAA,IACV,MAAAC,IAAO;AAAA,IACP,QAAAC,IAAS;AAAA,IACT,OAAAC,IAAQ;AAAA,IACR,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAEPC,MAEA,gBAAAC;AAAA,IAACR;AAAA,IAAA;AAAA,MACG,gBAAa;AAAA,MACb,WAAW;AAAA,QACPS,EAAO;AAAA,QACPA,EAAO,QAAQR,CAAI,EAAE;AAAA,QACrBQ,EAAO,UAAUP,CAAM,EAAE;AAAA,QACzBO,EAAOL,IAAW,aAAaA,CAAQ,KAAK,SAASD,CAAK,EAAE;AAAA,QAC5DE;AAAA,MAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,MAEb,KAAAE;AAAA,MACC,GAAGD;AAAA,MAEH,UAAAP;AAAA,IAAA;AAAA,EAAA;AAGb;AAIAF,EAAK,cAAc;"}
@@ -1,127 +1,84 @@
1
- import { jsxs as F, jsx as e } from "react/jsx-runtime";
2
- import { IconCheckMark as J, IconExclamationMarkTriangle as L, IconCross as Q } from "@frontify/fondue-icons";
3
- import { forwardRef as B, useRef as y, useState as U, useEffect as z } from "react";
4
- import { useSyncRefs as X } from "./fondue-components51.js";
5
- import o from "./fondue-components88.js";
6
- const D = ({
7
- "data-test-id": c = "fondue-textarea",
8
- autocomplete: i,
9
- autosize: u,
10
- children: m,
11
- clearable: f,
12
- decorator: h,
13
- defaultValue: g,
14
- disabled: n,
15
- extraActions: r,
16
- focusOnMount: v,
17
- minRows: M = 1,
18
- maxRows: k,
19
- onEnterPressed: w,
20
- readOnly: d,
21
- resizable: $,
22
- selectable: b = !0,
23
- status: s = "default",
24
- value: N,
25
- ...l
26
- }, W) => {
27
- const R = y(null), T = y(!1);
28
- X(R, W);
29
- const [x, S] = U(N ?? g ?? ""), C = (r == null ? void 0 : r.length) !== void 0 || f || ["success", "error"].includes(s), q = () => {
30
- S("");
31
- }, G = (a) => {
32
- var t;
33
- a.key === "Enter" && (w == null || w(a)), (t = l.onKeyDown) == null || t.call(l, a);
34
- };
35
- return z(() => {
36
- S(N ?? g ?? "");
37
- }, [g, N]), z(() => {
38
- var a;
39
- v && ((a = R.current) == null || a.focus());
40
- }, [v]), /* @__PURE__ */ F(
1
+ import { jsxs as m, jsx as t } from "react/jsx-runtime";
2
+ import { IconCheckMark as w, IconExclamationMarkTriangle as h } from "@frontify/fondue-icons";
3
+ import { forwardRef as f, useRef as S } from "react";
4
+ import { LoadingCircle as T } from "./fondue-components20.js";
5
+ import a from "./fondue-components91.js";
6
+ const u = ({
7
+ children: s,
8
+ className: c,
9
+ status: e = "neutral",
10
+ "data-test-id": l = "fondue-text-input",
11
+ "aria-errormessage": R,
12
+ placeholder: n,
13
+ ...o
14
+ }, N) => {
15
+ const d = S(!1);
16
+ return /* @__PURE__ */ m(
41
17
  "div",
42
18
  {
43
- className: o.root,
44
- "data-autosize": u,
45
- "data-clearable": f,
46
- "data-disabled": n || d,
47
- "data-has-decorator": !!h,
48
- "data-has-tools": C,
49
- "data-resizable": $,
50
- "data-status": s,
51
- "data-max-rows": !!k,
52
- "data-test-id": c,
53
- style: { "--max-rows": `${k}` },
19
+ className: [a.root, c].filter(Boolean).join(" "),
20
+ "data-status": e,
21
+ "data-test-id": l,
54
22
  children: [
55
- h ? /* @__PURE__ */ e("div", { className: o.decorator, children: h }) : null,
56
- /* @__PURE__ */ e("div", { className: o.textareaWrapper, "data-replicated-value": x, children: /* @__PURE__ */ e(
57
- "textarea",
58
- {
59
- ...l,
60
- onMouseDown: (a) => {
61
- T.current = !0, a.currentTarget.dataset.showFocusRing = "false";
62
- },
63
- onFocus: (a) => {
64
- var t;
65
- T.current || (a.target.dataset.showFocusRing = "true"), (t = l.onFocus) == null || t.call(l, a);
66
- },
67
- onBlur: (a) => {
68
- var t;
69
- a.target.dataset.showFocusRing = "false", T.current = !1, (t = l.onBlur) == null || t.call(l, a);
70
- },
71
- autoComplete: i ? "on" : "off",
72
- className: o.textarea,
73
- disabled: n,
74
- onKeyDown: G,
75
- onInput: (a) => S(a.currentTarget.value),
76
- onSelect: (a) => {
77
- b || (a.currentTarget.selectionStart = a.currentTarget.selectionEnd);
78
- },
79
- readOnly: d,
80
- ref: R,
81
- rows: M,
82
- value: x
83
- }
84
- ) }),
85
- s === "loading" && /* @__PURE__ */ e("div", { className: o.loadingStatus, "data-test-id": `${c}-loader` }),
86
- C && /* @__PURE__ */ F("div", { className: o.tools, children: [
87
- s === "success" && /* @__PURE__ */ e("div", { className: o.success, children: /* @__PURE__ */ e(J, { size: 20 }) }),
88
- s === "error" && /* @__PURE__ */ e("div", { className: o[s], children: /* @__PURE__ */ e(L, { size: 20 }) }),
89
- r == null ? void 0 : r.map(({ icon: a, title: t, callback: H }) => /* @__PURE__ */ e(
90
- "button",
23
+ e === "loading" ? /* @__PURE__ */ t("div", { className: a.loadingStatus, "data-test-id": `${l}-loader`, children: /* @__PURE__ */ t(T, { size: "xx-small" }) }) : null,
24
+ /* @__PURE__ */ m("div", { className: a.inputWrapper, children: [
25
+ n && /* @__PURE__ */ t("div", { className: a.placeholder, children: n }),
26
+ /* @__PURE__ */ t(
27
+ "input",
91
28
  {
92
- className: o.toolsButton,
93
- disabled: n || d,
94
- onClick: H,
95
- title: t,
96
- children: a
97
- },
98
- t
99
- )),
100
- f && /* @__PURE__ */ e("button", { className: o.toolsButton, onClick: q, disabled: n || d, children: /* @__PURE__ */ e(Q, { size: 20, fill: "currentColor" }) })
29
+ onMouseDown: (r) => {
30
+ d.current = !0, r.currentTarget.dataset.showFocusRing = "false";
31
+ },
32
+ type: "text",
33
+ placeholder: n,
34
+ ...o,
35
+ onFocus: (r) => {
36
+ var i;
37
+ d.current || (r.target.dataset.showFocusRing = "true"), (i = o.onFocus) == null || i.call(o, r);
38
+ },
39
+ onBlur: (r) => {
40
+ var i;
41
+ r.target.dataset.showFocusRing = "false", d.current = !1, (i = o.onBlur) == null || i.call(o, r);
42
+ },
43
+ ref: N,
44
+ className: a.input,
45
+ "aria-invalid": e === "error",
46
+ "aria-errormessage": e === "error" ? R : void 0
47
+ }
48
+ )
101
49
  ] }),
102
- m
50
+ e === "success" ? /* @__PURE__ */ t(w, { size: 16, className: a.iconSuccess, "data-test-id": `${l}-success-icon` }) : null,
51
+ e === "error" ? /* @__PURE__ */ t(
52
+ h,
53
+ {
54
+ size: 16,
55
+ className: a.iconError,
56
+ "data-test-id": `${l}-error-icon`
57
+ }
58
+ ) : null,
59
+ s
103
60
  ]
104
61
  }
105
62
  );
106
63
  };
107
- D.displayName = "Textarea.Root";
108
- const j = ({ name: c, className: i, ...u }, m) => /* @__PURE__ */ e(
64
+ u.displayName = "TextField.Root";
65
+ const x = ({ name: s, className: c, ...e }, l) => /* @__PURE__ */ t(
109
66
  "div",
110
67
  {
111
68
  "data-slot": !0,
112
- "data-name": c,
113
- ...u,
114
- ref: m,
115
- className: [o.slot, i].filter(Boolean).join(" ")
69
+ "data-name": s,
70
+ ...e,
71
+ ref: l,
72
+ className: [a.slot, c].filter(Boolean).join(" ")
116
73
  }
117
74
  );
118
- j.displayName = "Textarea.Slot";
119
- const I = B(D), Y = B(j), K = I;
120
- K.Root = I;
121
- K.Slot = Y;
75
+ x.displayName = "TextField.Slot";
76
+ const F = f(u), v = f(x), g = F;
77
+ g.Root = F;
78
+ g.Slot = v;
122
79
  export {
123
- K as Textarea,
124
- D as TextareaRoot,
125
- j as TextareaSlot
80
+ u as TextFieldRoot,
81
+ x as TextFieldSlot,
82
+ g as TextInput
126
83
  };
127
84
  //# sourceMappingURL=fondue-components35.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components35.js","sources":["../src/components/Textarea/Textarea.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCheckMark, IconCross, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport {\n forwardRef,\n useEffect,\n useRef,\n useState,\n type ChangeEventHandler,\n type CSSProperties,\n type FocusEventHandler,\n type ForwardedRef,\n type KeyboardEventHandler,\n type ReactElement,\n type ReactNode,\n type SyntheticEvent,\n} from 'react';\n\nimport { useSyncRefs } from '#/hooks/useSyncRefs';\n\nimport styles from './styles/textarea.module.scss';\n\n/**\n * @deprecated Use Textarea.Slot instead for custom actions\n */\nexport type ExtraAction = {\n icon: ReactElement;\n title: string;\n callback: () => void;\n};\n\ntype Status = 'default' | 'loading' | 'success' | 'error';\n\ntype TextareaProps = {\n /**\n * The id of the textarea\n */\n id?: string;\n /**\n * The place where the textarea slots are placed\n */\n children?: ReactNode;\n /**\n * If `true`, Textarea will have `autoComplete` functionality\n */\n autocomplete?: boolean;\n /**\n * If `true`, component rendered is a auto sizing Textarea\n */\n autosize?: boolean;\n /**\n * Render `clear` button to clear input on click\n */\n clearable?: boolean;\n /**\n * A `ReactElement` that will be rendered at the start of the `Textarea`\n */\n decorator?: ReactElement;\n /**\n * Initial value\n */\n defaultValue?: string;\n disabled?: boolean;\n /**\n * Collection of extra actions the input can preform\n * @deprecated Use Textarea.Slot instead for custom actions\n */\n extraActions?: ExtraAction[];\n /**\n * If `true`, Textarea will be focused on mount\n */\n focusOnMount?: boolean;\n /**\n * If autosize is false, this is used as rows property for default textarea\n * @default 1\n */\n minRows?: number;\n /**\n * If `autosize` is `false`, this property is ignored\n */\n maxRows?: number;\n /**\n * Event handler called when the textarea value changes\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text input is blurred\n */\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text input is focused\n */\n onFocus?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when a key is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when Enter is pressed\n */\n onEnterPressed?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when a key is released\n */\n onKeyUp?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text inside of text input is selected\n */\n onSelect?: (event: SyntheticEvent<HTMLTextAreaElement>) => void;\n /**\n * If `true`, Textarea will be required\n */\n required?: boolean;\n /**\n * The test id of the textarea\n */\n 'data-test-id'?: string;\n placeholder?: string;\n readOnly?: boolean;\n resizable?: boolean;\n selectable?: boolean;\n /**\n * The current status of the input. It will trigger the corresponding icon to be appended to the Textarea.\n * @default 'default'\n */\n status?: Status;\n value?: string;\n};\n\nexport const TextareaRoot = (\n {\n 'data-test-id': dataTestId = 'fondue-textarea',\n autocomplete,\n autosize,\n children,\n clearable,\n decorator,\n defaultValue,\n disabled,\n extraActions,\n focusOnMount,\n minRows: rows = 1,\n maxRows,\n onEnterPressed,\n readOnly,\n resizable,\n selectable = true,\n status = 'default',\n value: inputValue,\n ...props\n }: TextareaProps,\n forwardedRef: ForwardedRef<HTMLTextAreaElement>,\n) => {\n const ref = useRef<HTMLTextAreaElement>(null);\n const wasClicked = useRef(false);\n\n useSyncRefs<HTMLTextAreaElement>(ref, forwardedRef);\n\n const [value, setValue] = useState(inputValue ?? defaultValue ?? '');\n\n const hasTools = extraActions?.length !== undefined || clearable || ['success', 'error'].includes(status);\n\n const clear = () => {\n setValue('');\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLTextAreaElement> = (event) => {\n if (event.key === 'Enter') {\n onEnterPressed?.(event);\n }\n props.onKeyDown?.(event);\n };\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setValue(inputValue ?? defaultValue ?? '');\n }, [defaultValue, inputValue]);\n\n useEffect(() => {\n if (focusOnMount) {\n ref.current?.focus();\n }\n }, [focusOnMount]);\n\n return (\n <div\n className={styles.root}\n data-autosize={autosize}\n data-clearable={clearable}\n data-disabled={disabled || readOnly}\n data-has-decorator={decorator ? true : false}\n data-has-tools={hasTools}\n data-resizable={resizable}\n data-status={status}\n data-max-rows={!!maxRows}\n data-test-id={dataTestId}\n style={{ '--max-rows': `${maxRows}` } as CSSProperties}\n >\n {decorator ? <div className={styles.decorator}>{decorator}</div> : null}\n <div className={styles.textareaWrapper} data-replicated-value={value}>\n <textarea\n {...props}\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n props.onFocus?.(focusEvent);\n }}\n onBlur={(blurEvent) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n props.onBlur?.(blurEvent);\n }}\n autoComplete={autocomplete ? 'on' : 'off'}\n className={styles.textarea}\n disabled={disabled}\n onKeyDown={handleKeyDown}\n onInput={(event) => setValue(event.currentTarget.value)}\n onSelect={(event) => {\n if (!selectable) {\n event.currentTarget.selectionStart = event.currentTarget.selectionEnd;\n }\n }}\n readOnly={readOnly}\n ref={ref}\n rows={rows}\n value={value}\n ></textarea>\n </div>\n {status === 'loading' && <div className={styles.loadingStatus} data-test-id={`${dataTestId}-loader`} />}\n {hasTools && (\n <div className={styles.tools}>\n {status === 'success' && (\n <div className={styles.success}>\n <IconCheckMark size={20} />\n </div>\n )}\n {status === 'error' && (\n <div className={styles[status]}>\n <IconExclamationMarkTriangle size={20} />\n </div>\n )}\n {extraActions?.map(({ icon, title, callback }) => (\n <button\n className={styles.toolsButton}\n disabled={disabled || readOnly}\n key={title}\n onClick={callback}\n title={title}\n >\n {icon}\n </button>\n ))}\n {clearable && (\n <button className={styles.toolsButton} onClick={clear} disabled={disabled || readOnly}>\n <IconCross size={20} fill=\"currentColor\" />\n </button>\n )}\n </div>\n )}\n {children}\n </div>\n );\n};\nTextareaRoot.displayName = 'Textarea.Root';\n\nexport type TextareaSlotProps = {\n children: ReactNode;\n name?: 'left' | 'right';\n className?: string;\n};\n\nexport const TextareaSlot = (\n { name, className, ...slotProps }: TextareaSlotProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div\n data-slot\n data-name={name}\n {...slotProps}\n ref={forwardedRef}\n className={[styles.slot, className].filter(Boolean).join(' ')}\n />\n );\n};\n\nTextareaSlot.displayName = 'Textarea.Slot';\n\nconst ForwardedRefTextareaRoot = forwardRef<HTMLTextAreaElement, TextareaProps>(TextareaRoot);\nconst ForwardedRefTextareaSlot = forwardRef<HTMLDivElement, TextareaSlotProps>(TextareaSlot);\n\n// @ts-expect-error We support both single component (without slots) and compound components (with slots)\nexport const Textarea: typeof TextareaRoot & {\n Root: typeof ForwardedRefTextareaRoot;\n Slot: typeof ForwardedRefTextareaSlot;\n} = ForwardedRefTextareaRoot;\nTextarea.Root = ForwardedRefTextareaRoot;\nTextarea.Slot = ForwardedRefTextareaSlot;\n"],"names":["TextareaRoot","dataTestId","autocomplete","autosize","children","clearable","decorator","defaultValue","disabled","extraActions","focusOnMount","rows","maxRows","onEnterPressed","readOnly","resizable","selectable","status","inputValue","props","forwardedRef","ref","useRef","wasClicked","useSyncRefs","value","setValue","useState","hasTools","clear","handleKeyDown","event","_a","useEffect","jsxs","styles","jsx","mouseEvent","focusEvent","blurEvent","IconCheckMark","IconExclamationMarkTriangle","icon","title","callback","IconCross","TextareaSlot","name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AAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,EAAA;AAAA;AAKxEF,EAAa,cAAc;AAE3B,MAAMI,IAA2BC,EAA+CnD,CAAY,GACtFoD,IAA2BD,EAA8CL,CAAY,GAG9EO,IAGTH;AACJG,EAAS,OAAOH;AAChBG,EAAS,OAAOD;"}
1
+ {"version":3,"file":"fondue-components35.js","sources":["../src/components/TextInput/TextInput.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCheckMark, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport {\n forwardRef,\n useRef,\n type ChangeEvent,\n type FocusEvent,\n type ForwardedRef,\n type KeyboardEvent,\n type ReactNode,\n type SyntheticEvent,\n} from 'react';\n\nimport { LoadingCircle } from '../LoadingCircle/LoadingCircle';\n\nimport styles from './styles/text.module.scss';\n\nexport type TextInputProps = {\n id?: string;\n name?: string;\n /**\n * The place where the input slots are placed\n */\n children?: ReactNode;\n /**\n * The default value of the text input\n * Used for uncontrolled components\n */\n defaultValue?: string | number;\n /**\n * The controlled value of the text input\n */\n value?: string | number;\n /**\n * Type of the text input\n * @default \"text\"\n */\n type?: 'date' | 'email' | 'hidden' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url';\n /**\n * The placeholder in the text input\n */\n placeholder?: string;\n /**\n * Disable the text input\n * @default false\n */\n disabled?: boolean;\n /**\n * Make the text input required in form\n * @default false\n */\n required?: boolean;\n /**\n * Make the text input spell-checkable\n * @default true\n */\n spellCheck?: boolean;\n /**\n * Make the text input read-only\n * @default false\n */\n readOnly?: boolean;\n /**\n * Set the type of input so autocomplete can help the user\n * @default \"on\"\n */\n autoComplete?: string;\n /**\n * The maximum length of the text input\n */\n maxLength?: number;\n /**\n * Status of the text input\n * @default \"neutral\"\n */\n status?: 'neutral' | 'success' | 'error' | 'loading';\n className?: string;\n /**\n * Event handler called when the text input value changes\n */\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the text input is blurred\n */\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the text input is focused\n */\n onFocus?: (event: FocusEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when a key is pressed\n */\n onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when a key is released\n */\n onKeyUp?: (event: KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the text inside of text input is selected\n */\n onSelect?: (event: SyntheticEvent<HTMLInputElement>) => void;\n 'data-test-id'?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n 'aria-errormessage'?: string;\n};\n\nexport const TextFieldRoot = (\n {\n children,\n className,\n status = 'neutral',\n 'data-test-id': dataTestId = 'fondue-text-input',\n 'aria-errormessage': ariaErrormessage,\n placeholder,\n ...inputProps\n }: TextInputProps,\n ref: ForwardedRef<HTMLInputElement>,\n) => {\n const wasClicked = useRef(false);\n\n return (\n <div\n className={[styles.root, className].filter(Boolean).join(' ')}\n data-status={status}\n data-test-id={dataTestId}\n >\n {status === 'loading' ? (\n <div className={styles.loadingStatus} data-test-id={`${dataTestId}-loader`}>\n <LoadingCircle size=\"xx-small\" />\n </div>\n ) : null}\n <div className={styles.inputWrapper}>\n {placeholder && <div className={styles.placeholder}>{placeholder}</div>}\n <input\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n type=\"text\"\n placeholder={placeholder}\n {...inputProps}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n inputProps.onFocus?.(focusEvent);\n }}\n onBlur={(blurEvent) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n inputProps.onBlur?.(blurEvent);\n }}\n ref={ref}\n className={styles.input}\n aria-invalid={status === 'error'}\n aria-errormessage={status === 'error' ? ariaErrormessage : undefined}\n />\n </div>\n\n {status === 'success' ? (\n <IconCheckMark size={16} className={styles.iconSuccess} data-test-id={`${dataTestId}-success-icon`} />\n ) : null}\n\n {status === 'error' ? (\n <IconExclamationMarkTriangle\n size={16}\n className={styles.iconError}\n data-test-id={`${dataTestId}-error-icon`}\n />\n ) : null}\n\n {children}\n </div>\n );\n};\nTextFieldRoot.displayName = 'TextField.Root';\n\nexport type TextFieldSlotProps = {\n children: ReactNode;\n name?: 'left' | 'right';\n className?: string;\n};\n\nexport const TextFieldSlot = (\n { name, className, ...slotProps }: TextFieldSlotProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div\n data-slot\n data-name={name}\n {...slotProps}\n ref={forwardedRef}\n className={[styles.slot, className].filter(Boolean).join(' ')}\n />\n );\n};\n\nTextFieldSlot.displayName = 'TextField.Slot';\n\nconst ForwardedRefTextFieldRoot = forwardRef<HTMLInputElement, TextInputProps>(TextFieldRoot);\nconst ForwardedRefTextFieldSlot = forwardRef<HTMLDivElement, TextFieldSlotProps>(TextFieldSlot);\n// @ts-expect-error We support both single component (without slots) and compound components (with slots)\nexport const TextInput: typeof TextFieldRoot & {\n Root: typeof ForwardedRefTextFieldRoot;\n Slot: typeof ForwardedRefTextFieldSlot;\n} = ForwardedRefTextFieldRoot;\nTextInput.Root = ForwardedRefTextFieldRoot;\nTextInput.Slot = ForwardedRefTextFieldSlot;\n"],"names":["TextFieldRoot","children","className","status","dataTestId","ariaErrormessage","placeholder","inputProps","ref","wasClicked","useRef","jsxs","styles","jsx","LoadingCircle","mouseEvent","focusEvent","_a","blurEvent","IconCheckMark","IconExclamationMarkTriangle","TextFieldSlot","name","slotProps","forwardedRef","ForwardedRefTextFieldRoot","forwardRef","ForwardedRefTextFieldSlot","TextInput"],"mappings":";;;;;AA6GO,MAAMA,IAAgB,CACzB;AAAA,EACI,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,gBAAgBC,IAAa;AAAA,EAC7B,qBAA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,GACJ;AAAA,QAECF,MAAW,YACR,gBAAAU,EAACM,GAAA,EAAc,MAAM,IAAI,WAAWP,EAAO,aAAa,gBAAc,GAAGR,CAAU,iBAAiB,IACpG;AAAA,QAEHD,MAAW,UACR,gBAAAU;AAAA,UAACO;AAAA,UAAA;AAAA,YACG,MAAM;AAAA,YACN,WAAWR,EAAO;AAAA,YAClB,gBAAc,GAAGR,CAAU;AAAA,UAAA;AAAA,QAAA,IAE/B;AAAA,QAEHH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGb;AACAD,EAAc,cAAc;AAQrB,MAAMqB,IAAgB,CACzB,EAAE,MAAAC,GAAM,WAAApB,GAAW,GAAGqB,EAAA,GACtBC,MAGI,gBAAAX;AAAA,EAAC;AAAA,EAAA;AAAA,IACG,aAAS;AAAA,IACT,aAAWS;AAAA,IACV,GAAGC;AAAA,IACJ,KAAKC;AAAA,IACL,WAAW,CAACZ,EAAO,MAAMV,CAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,EAAA;AAAA;AAKxEmB,EAAc,cAAc;AAE5B,MAAMI,IAA4BC,EAA6C1B,CAAa,GACtF2B,IAA4BD,EAA+CL,CAAa,GAEjFO,IAGTH;AACJG,EAAU,OAAOH;AACjBG,EAAU,OAAOD;"}
@@ -1,40 +1,127 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import d from "./fondue-components89.js";
3
- import { Slot as p } from "@radix-ui/react-slot";
4
- import { createContext as u, useContext as a, useMemo as x } from "react";
5
- import { enUS as s } from "./fondue-components90.js";
6
- const r = u({
7
- theme: "light",
8
- dir: "ltr",
9
- translations: s
10
- });
11
- r.displayName = "ThemeContext";
12
- const g = () => {
13
- const e = a(r);
14
- return {
15
- ...e,
16
- dir: e.dir || "ltr"
1
+ import { jsxs as F, jsx as e } from "react/jsx-runtime";
2
+ import { IconCheckMark as J, IconExclamationMarkTriangle as L, IconCross as Q } from "@frontify/fondue-icons";
3
+ import { forwardRef as B, useRef as y, useState as U, useEffect as z } from "react";
4
+ import { useSyncRefs as X } from "./fondue-components52.js";
5
+ import o from "./fondue-components92.js";
6
+ const D = ({
7
+ "data-test-id": c = "fondue-textarea",
8
+ autocomplete: i,
9
+ autosize: u,
10
+ children: m,
11
+ clearable: f,
12
+ decorator: h,
13
+ defaultValue: g,
14
+ disabled: n,
15
+ extraActions: r,
16
+ focusOnMount: v,
17
+ minRows: M = 1,
18
+ maxRows: k,
19
+ onEnterPressed: w,
20
+ readOnly: d,
21
+ resizable: $,
22
+ selectable: b = !0,
23
+ status: s = "default",
24
+ value: N,
25
+ ...l
26
+ }, W) => {
27
+ const R = y(null), T = y(!1);
28
+ X(R, W);
29
+ const [x, S] = U(N ?? g ?? ""), C = (r == null ? void 0 : r.length) !== void 0 || f || ["success", "error"].includes(s), q = () => {
30
+ S("");
31
+ }, G = (a) => {
32
+ var t;
33
+ a.key === "Enter" && (w == null || w(a)), (t = l.onKeyDown) == null || t.call(l, a);
17
34
  };
18
- }, y = ({
19
- children: e,
20
- theme: t = "light",
21
- dir: o = "ltr",
22
- translations: m = s,
23
- asChild: i = !1
24
- }) => {
25
- const l = i ? p : "div", c = x(
26
- () => ({
27
- theme: t,
28
- dir: o,
29
- translations: m
30
- }),
31
- [o, t, m]
35
+ return z(() => {
36
+ S(N ?? g ?? "");
37
+ }, [g, N]), z(() => {
38
+ var a;
39
+ v && ((a = R.current) == null || a.focus());
40
+ }, [v]), /* @__PURE__ */ F(
41
+ "div",
42
+ {
43
+ className: o.root,
44
+ "data-autosize": u,
45
+ "data-clearable": f,
46
+ "data-disabled": n || d,
47
+ "data-has-decorator": !!h,
48
+ "data-has-tools": C,
49
+ "data-resizable": $,
50
+ "data-status": s,
51
+ "data-max-rows": !!k,
52
+ "data-test-id": c,
53
+ style: { "--max-rows": `${k}` },
54
+ children: [
55
+ h ? /* @__PURE__ */ e("div", { className: o.decorator, children: h }) : null,
56
+ /* @__PURE__ */ e("div", { className: o.textareaWrapper, "data-replicated-value": x, children: /* @__PURE__ */ e(
57
+ "textarea",
58
+ {
59
+ ...l,
60
+ onMouseDown: (a) => {
61
+ T.current = !0, a.currentTarget.dataset.showFocusRing = "false";
62
+ },
63
+ onFocus: (a) => {
64
+ var t;
65
+ T.current || (a.target.dataset.showFocusRing = "true"), (t = l.onFocus) == null || t.call(l, a);
66
+ },
67
+ onBlur: (a) => {
68
+ var t;
69
+ a.target.dataset.showFocusRing = "false", T.current = !1, (t = l.onBlur) == null || t.call(l, a);
70
+ },
71
+ autoComplete: i ? "on" : "off",
72
+ className: o.textarea,
73
+ disabled: n,
74
+ onKeyDown: G,
75
+ onInput: (a) => S(a.currentTarget.value),
76
+ onSelect: (a) => {
77
+ b || (a.currentTarget.selectionStart = a.currentTarget.selectionEnd);
78
+ },
79
+ readOnly: d,
80
+ ref: R,
81
+ rows: M,
82
+ value: x
83
+ }
84
+ ) }),
85
+ s === "loading" && /* @__PURE__ */ e("div", { className: o.loadingStatus, "data-test-id": `${c}-loader` }),
86
+ C && /* @__PURE__ */ F("div", { className: o.tools, children: [
87
+ s === "success" && /* @__PURE__ */ e("div", { className: o.success, children: /* @__PURE__ */ e(J, { size: 20 }) }),
88
+ s === "error" && /* @__PURE__ */ e("div", { className: o[s], children: /* @__PURE__ */ e(L, { size: 20 }) }),
89
+ r == null ? void 0 : r.map(({ icon: a, title: t, callback: H }) => /* @__PURE__ */ e(
90
+ "button",
91
+ {
92
+ className: o.toolsButton,
93
+ disabled: n || d,
94
+ onClick: H,
95
+ title: t,
96
+ children: a
97
+ },
98
+ t
99
+ )),
100
+ f && /* @__PURE__ */ e("button", { className: o.toolsButton, onClick: q, disabled: n || d, children: /* @__PURE__ */ e(Q, { size: 20, fill: "currentColor" }) })
101
+ ] }),
102
+ m
103
+ ]
104
+ }
32
105
  );
33
- return /* @__PURE__ */ n(r.Provider, { value: c, children: /* @__PURE__ */ n(l, { dir: o, className: `${d[t]} fondue-theme-provider`, children: e }) });
34
106
  };
107
+ D.displayName = "Textarea.Root";
108
+ const j = ({ name: c, className: i, ...u }, m) => /* @__PURE__ */ e(
109
+ "div",
110
+ {
111
+ "data-slot": !0,
112
+ "data-name": c,
113
+ ...u,
114
+ ref: m,
115
+ className: [o.slot, i].filter(Boolean).join(" ")
116
+ }
117
+ );
118
+ j.displayName = "Textarea.Slot";
119
+ const I = B(D), Y = B(j), K = I;
120
+ K.Root = I;
121
+ K.Slot = Y;
35
122
  export {
36
- r as ThemeContext,
37
- y as ThemeProvider,
38
- g as useFondueTheme
123
+ K as Textarea,
124
+ D as TextareaRoot,
125
+ j as TextareaSlot
39
126
  };
40
127
  //# sourceMappingURL=fondue-components36.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components36.js","sources":["../src/components/ThemeProvider/ThemeProvider.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport styles from '@frontify/fondue-tokens/themes';\nimport { Slot } from '@radix-ui/react-slot';\nimport { createContext, useContext, useMemo, type ReactNode } from 'react';\n\nimport { enUS, type Translations } from '../../locales';\n\ntype AvailableTheme = keyof typeof styles;\n\ntype ThemeProviderProps = {\n children: ReactNode;\n /**\n * The theme to apply\n * @default \"light\"\n * */\n theme?: AvailableTheme;\n /**\n * Direction to apply to the theme\n * @default \"ltr\"\n */\n dir?: 'ltr' | 'rtl';\n /**\n * Translations object to use for component strings.\n * Import from '@frontify/fondue/components/locales' or provide your own.\n * Must be a complete Translations object.\n * @default \"enUS\"\n * @example\n * ```tsx\n * import { deDE } from '@frontify/fondue/components/locales';\n * <ThemeProvider translations={deDE}>...</ThemeProvider>\n * ```\n */\n translations?: Translations;\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n * @default false\n */\n asChild?: boolean;\n};\n\ntype ThemeContextValue = {\n theme: AvailableTheme;\n dir: 'ltr' | 'rtl';\n translations: Translations;\n};\n\nexport const ThemeContext = createContext<ThemeContextValue>({\n theme: 'light',\n dir: 'ltr',\n translations: enUS,\n});\nThemeContext.displayName = 'ThemeContext';\n\nexport const useFondueTheme = () => {\n const context = useContext(ThemeContext);\n // Ensure we always have a valid direction, defaulting to 'ltr' if not provided\n return {\n ...context,\n dir: context.dir || 'ltr',\n };\n};\n\nexport const ThemeProvider = ({\n children,\n theme = 'light',\n dir = 'ltr',\n translations = enUS,\n asChild = false,\n}: ThemeProviderProps) => {\n const Comp = asChild ? Slot : 'div';\n\n const contextValue = useMemo(\n () => ({\n theme,\n dir,\n translations,\n }),\n [dir, theme, translations],\n );\n\n return (\n <ThemeContext.Provider value={contextValue}>\n <Comp dir={dir} className={`${styles[theme]} fondue-theme-provider`}>\n {children}\n </Comp>\n </ThemeContext.Provider>\n );\n};\n"],"names":["ThemeContext","createContext","enUS","useFondueTheme","context","useContext","ThemeProvider","children","theme","dir","translations","asChild","Comp","Slot","contextValue","useMemo","jsx","styles"],"mappings":";;;;;AA+CO,MAAMA,IAAeC,EAAiC;AAAA,EACzD,OAAO;AAAA,EACP,KAAK;AAAA,EACL,cAAcC;AAClB,CAAC;AACDF,EAAa,cAAc;AAEpB,MAAMG,IAAiB,MAAM;AAChC,QAAMC,IAAUC,EAAWL,CAAY;AAEvC,SAAO;AAAA,IACH,GAAGI;AAAA,IACH,KAAKA,EAAQ,OAAO;AAAA,EAAA;AAE5B,GAEaE,IAAgB,CAAC;AAAA,EAC1B,UAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,KAAAC,IAAM;AAAA,EACN,cAAAC,IAAeR;AAAA,EACf,SAAAS,IAAU;AACd,MAA0B;AACtB,QAAMC,IAAOD,IAAUE,IAAO,OAExBC,IAAeC;AAAA,IACjB,OAAO;AAAA,MACH,OAAAP;AAAA,MACA,KAAAC;AAAA,MACA,cAAAC;AAAA,IAAA;AAAA,IAEJ,CAACD,GAAKD,GAAOE,CAAY;AAAA,EAAA;AAG7B,2BACKV,EAAa,UAAb,EAAsB,OAAOc,GAC1B,UAAA,gBAAAE,EAACJ,GAAA,EAAK,KAAAH,GAAU,WAAW,GAAGQ,EAAOT,CAAK,CAAC,0BACtC,UAAAD,GACL,GACJ;AAER;"}
1
+ {"version":3,"file":"fondue-components36.js","sources":["../src/components/Textarea/Textarea.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCheckMark, IconCross, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport {\n forwardRef,\n useEffect,\n useRef,\n useState,\n type ChangeEventHandler,\n type CSSProperties,\n type FocusEventHandler,\n type ForwardedRef,\n type KeyboardEventHandler,\n type ReactElement,\n type ReactNode,\n type SyntheticEvent,\n} from 'react';\n\nimport { useSyncRefs } from '#/hooks/useSyncRefs';\n\nimport styles from './styles/textarea.module.scss';\n\n/**\n * @deprecated Use Textarea.Slot instead for custom actions\n */\nexport type ExtraAction = {\n icon: ReactElement;\n title: string;\n callback: () => void;\n};\n\ntype Status = 'default' | 'loading' | 'success' | 'error';\n\ntype TextareaProps = {\n /**\n * The id of the textarea\n */\n id?: string;\n /**\n * The place where the textarea slots are placed\n */\n children?: ReactNode;\n /**\n * If `true`, Textarea will have `autoComplete` functionality\n */\n autocomplete?: boolean;\n /**\n * If `true`, component rendered is a auto sizing Textarea\n */\n autosize?: boolean;\n /**\n * Render `clear` button to clear input on click\n */\n clearable?: boolean;\n /**\n * A `ReactElement` that will be rendered at the start of the `Textarea`\n */\n decorator?: ReactElement;\n /**\n * Initial value\n */\n defaultValue?: string;\n disabled?: boolean;\n /**\n * Collection of extra actions the input can preform\n * @deprecated Use Textarea.Slot instead for custom actions\n */\n extraActions?: ExtraAction[];\n /**\n * If `true`, Textarea will be focused on mount\n */\n focusOnMount?: boolean;\n /**\n * If autosize is false, this is used as rows property for default textarea\n * @default 1\n */\n minRows?: number;\n /**\n * If `autosize` is `false`, this property is ignored\n */\n maxRows?: number;\n /**\n * Event handler called when the textarea value changes\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text input is blurred\n */\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text input is focused\n */\n onFocus?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when a key is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when Enter is pressed\n */\n onEnterPressed?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when a key is released\n */\n onKeyUp?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text inside of text input is selected\n */\n onSelect?: (event: SyntheticEvent<HTMLTextAreaElement>) => void;\n /**\n * If `true`, Textarea will be required\n */\n required?: boolean;\n /**\n * The test id of the textarea\n */\n 'data-test-id'?: string;\n placeholder?: string;\n readOnly?: boolean;\n resizable?: boolean;\n selectable?: boolean;\n /**\n * The current status of the input. It will trigger the corresponding icon to be appended to the Textarea.\n * @default 'default'\n */\n status?: Status;\n value?: string;\n};\n\nexport const TextareaRoot = (\n {\n 'data-test-id': dataTestId = 'fondue-textarea',\n autocomplete,\n autosize,\n children,\n clearable,\n decorator,\n defaultValue,\n disabled,\n extraActions,\n focusOnMount,\n minRows: rows = 1,\n maxRows,\n onEnterPressed,\n readOnly,\n resizable,\n selectable = true,\n status = 'default',\n value: inputValue,\n ...props\n }: TextareaProps,\n forwardedRef: ForwardedRef<HTMLTextAreaElement>,\n) => {\n const ref = useRef<HTMLTextAreaElement>(null);\n const wasClicked = useRef(false);\n\n useSyncRefs<HTMLTextAreaElement>(ref, forwardedRef);\n\n const [value, setValue] = useState(inputValue ?? defaultValue ?? '');\n\n const hasTools = extraActions?.length !== undefined || clearable || ['success', 'error'].includes(status);\n\n const clear = () => {\n setValue('');\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLTextAreaElement> = (event) => {\n if (event.key === 'Enter') {\n onEnterPressed?.(event);\n }\n props.onKeyDown?.(event);\n };\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setValue(inputValue ?? defaultValue ?? '');\n }, [defaultValue, inputValue]);\n\n useEffect(() => {\n if (focusOnMount) {\n ref.current?.focus();\n }\n }, [focusOnMount]);\n\n return (\n <div\n className={styles.root}\n data-autosize={autosize}\n data-clearable={clearable}\n data-disabled={disabled || readOnly}\n data-has-decorator={decorator ? true : false}\n data-has-tools={hasTools}\n data-resizable={resizable}\n data-status={status}\n data-max-rows={!!maxRows}\n data-test-id={dataTestId}\n style={{ '--max-rows': `${maxRows}` } as CSSProperties}\n >\n {decorator ? <div className={styles.decorator}>{decorator}</div> : null}\n <div className={styles.textareaWrapper} data-replicated-value={value}>\n <textarea\n {...props}\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n props.onFocus?.(focusEvent);\n }}\n onBlur={(blurEvent) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n props.onBlur?.(blurEvent);\n }}\n autoComplete={autocomplete ? 'on' : 'off'}\n className={styles.textarea}\n disabled={disabled}\n onKeyDown={handleKeyDown}\n onInput={(event) => setValue(event.currentTarget.value)}\n onSelect={(event) => {\n if (!selectable) {\n event.currentTarget.selectionStart = event.currentTarget.selectionEnd;\n }\n }}\n readOnly={readOnly}\n ref={ref}\n rows={rows}\n value={value}\n ></textarea>\n </div>\n {status === 'loading' && <div className={styles.loadingStatus} data-test-id={`${dataTestId}-loader`} />}\n {hasTools && (\n <div className={styles.tools}>\n {status === 'success' && (\n <div className={styles.success}>\n <IconCheckMark size={20} />\n </div>\n )}\n {status === 'error' && (\n <div className={styles[status]}>\n <IconExclamationMarkTriangle size={20} />\n </div>\n )}\n {extraActions?.map(({ icon, title, callback }) => (\n <button\n className={styles.toolsButton}\n disabled={disabled || readOnly}\n key={title}\n onClick={callback}\n title={title}\n >\n {icon}\n </button>\n ))}\n {clearable && (\n <button className={styles.toolsButton} onClick={clear} disabled={disabled || readOnly}>\n <IconCross size={20} fill=\"currentColor\" />\n </button>\n )}\n </div>\n )}\n {children}\n </div>\n );\n};\nTextareaRoot.displayName = 'Textarea.Root';\n\nexport type TextareaSlotProps = {\n children: ReactNode;\n name?: 'left' | 'right';\n className?: string;\n};\n\nexport const TextareaSlot = (\n { name, className, ...slotProps }: TextareaSlotProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div\n data-slot\n data-name={name}\n {...slotProps}\n ref={forwardedRef}\n className={[styles.slot, className].filter(Boolean).join(' ')}\n />\n );\n};\n\nTextareaSlot.displayName = 'Textarea.Slot';\n\nconst ForwardedRefTextareaRoot = forwardRef<HTMLTextAreaElement, TextareaProps>(TextareaRoot);\nconst ForwardedRefTextareaSlot = forwardRef<HTMLDivElement, TextareaSlotProps>(TextareaSlot);\n\n// @ts-expect-error We support both single component (without slots) and compound components (with slots)\nexport const Textarea: typeof TextareaRoot & {\n Root: typeof ForwardedRefTextareaRoot;\n Slot: typeof ForwardedRefTextareaSlot;\n} = ForwardedRefTextareaRoot;\nTextarea.Root = ForwardedRefTextareaRoot;\nTextarea.Slot = ForwardedRefTextareaSlot;\n"],"names":["TextareaRoot","dataTestId","autocomplete","autosize","children","clearable","decorator","defaultValue","disabled","extraActions","focusOnMount","rows","maxRows","onEnterPressed","readOnly","resizable","selectable","status","inputValue","props","forwardedRef","ref","useRef","wasClicked","useSyncRefs","value","setValue","useState","hasTools","clear","handleKeyDown","event","_a","useEffect","jsxs","styles","jsx","mouseEvent","focusEvent","blurEvent","IconCheckMark","IconExclamationMarkTriangle","icon","title","callback","IconCross","TextareaSlot","name","className","slotProps","ForwardedRefTextareaRoot","forwardRef","ForwardedRefTextareaSlot","Textarea"],"mappings":";;;;;AAiIO,MAAMA,IAAe,CACxB;AAAA,EACI,gBAAgBC,IAAa;AAAA,EAC7B,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA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