tyrell-components 1.0.0-RC14 → 1.0.0-RC16

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 (287) hide show
  1. package/README.md +53 -53
  2. package/css/tyrell-theme.css +32 -4
  3. package/css/tyrell.css +10 -15
  4. package/dist/tyrell-colors-static.css +1 -316
  5. package/dist/tyrell-theme.css +1 -1443
  6. package/dist/tyrell.css +1 -1390
  7. package/dist/tyrell.js +1 -1
  8. package/lib/base/ty-component.d.ts +14 -0
  9. package/lib/base/ty-component.d.ts.map +1 -0
  10. package/lib/base/ty-component.js +223 -196
  11. package/lib/base/ty-component.js.map +1 -0
  12. package/lib/components/button.d.ts +1 -1
  13. package/lib/components/button.d.ts.map +1 -0
  14. package/lib/components/button.js +267 -259
  15. package/lib/components/button.js.map +1 -0
  16. package/lib/components/calendar-month.d.ts +2 -2
  17. package/lib/components/calendar-month.d.ts.map +1 -0
  18. package/lib/components/calendar-month.js +440 -416
  19. package/lib/components/calendar-month.js.map +1 -0
  20. package/lib/components/calendar-navigation.d.ts +11 -0
  21. package/lib/components/calendar-navigation.d.ts.map +1 -0
  22. package/lib/components/calendar-navigation.js +272 -261
  23. package/lib/components/calendar-navigation.js.map +1 -0
  24. package/lib/components/calendar.d.ts +31 -3
  25. package/lib/components/calendar.d.ts.map +1 -0
  26. package/lib/components/calendar.js +785 -603
  27. package/lib/components/calendar.js.map +1 -0
  28. package/lib/components/checkbox.d.ts +1 -1
  29. package/lib/components/checkbox.d.ts.map +1 -0
  30. package/lib/components/checkbox.js +273 -272
  31. package/lib/components/checkbox.js.map +1 -0
  32. package/lib/components/copy.d.ts +1 -1
  33. package/lib/components/copy.d.ts.map +1 -0
  34. package/lib/components/copy.js +287 -278
  35. package/lib/components/copy.js.map +1 -0
  36. package/lib/components/date-picker.d.ts +16 -10
  37. package/lib/components/date-picker.d.ts.map +1 -0
  38. package/lib/components/date-picker.js +1068 -1122
  39. package/lib/components/date-picker.js.map +1 -0
  40. package/lib/components/dropdown.d.ts +403 -0
  41. package/lib/components/dropdown.d.ts.map +1 -0
  42. package/lib/components/dropdown.js +1315 -0
  43. package/lib/components/dropdown.js.map +1 -0
  44. package/lib/components/file-upload.d.ts +4 -0
  45. package/lib/components/file-upload.js +418 -404
  46. package/lib/components/icon.d.ts.map +1 -0
  47. package/lib/components/icon.js +141 -141
  48. package/lib/components/icon.js.map +1 -0
  49. package/lib/components/input.d.ts +1 -1
  50. package/lib/components/input.d.ts.map +1 -0
  51. package/lib/components/input.js +593 -596
  52. package/lib/components/input.js.map +1 -0
  53. package/lib/components/modal.d.ts +2 -8
  54. package/lib/components/modal.d.ts.map +1 -0
  55. package/lib/components/modal.js +309 -319
  56. package/lib/components/modal.js.map +1 -0
  57. package/lib/components/multiselect.d.ts +389 -0
  58. package/lib/components/multiselect.d.ts.map +1 -0
  59. package/lib/components/multiselect.js +1301 -0
  60. package/lib/components/multiselect.js.map +1 -0
  61. package/lib/components/option.d.ts.map +1 -0
  62. package/lib/components/option.js +167 -167
  63. package/lib/components/option.js.map +1 -0
  64. package/lib/components/popup.d.ts.map +1 -0
  65. package/lib/components/popup.js +236 -233
  66. package/lib/components/popup.js.map +1 -0
  67. package/lib/components/radio.d.ts +17 -2
  68. package/lib/components/radio.js +437 -406
  69. package/lib/components/resize-observer.d.ts.map +1 -0
  70. package/lib/components/resize-observer.js +67 -67
  71. package/lib/components/resize-observer.js.map +1 -0
  72. package/lib/components/scroll-container.d.ts +3 -2
  73. package/lib/components/scroll-container.d.ts.map +1 -0
  74. package/lib/components/scroll-container.js +289 -294
  75. package/lib/components/scroll-container.js.map +1 -0
  76. package/lib/components/select.d.ts +85 -18
  77. package/lib/components/select.js +1647 -1529
  78. package/lib/components/selected-tags.d.ts +1 -1
  79. package/lib/components/selected-tags.js +188 -182
  80. package/lib/components/step.d.ts.map +1 -0
  81. package/lib/components/step.js +62 -62
  82. package/lib/components/step.js.map +1 -0
  83. package/lib/components/switch.d.ts +1 -1
  84. package/lib/components/switch.js +214 -213
  85. package/lib/components/tab.d.ts +49 -1
  86. package/lib/components/tab.d.ts.map +1 -0
  87. package/lib/components/tab.js +203 -62
  88. package/lib/components/tab.js.map +1 -0
  89. package/lib/components/tabs.d.ts +15 -2
  90. package/lib/components/tabs.d.ts.map +1 -0
  91. package/lib/components/tabs.js +576 -496
  92. package/lib/components/tabs.js.map +1 -0
  93. package/lib/components/tag.d.ts +5 -8
  94. package/lib/components/tag.d.ts.map +1 -0
  95. package/lib/components/tag.js +235 -235
  96. package/lib/components/tag.js.map +1 -0
  97. package/lib/components/textarea.d.ts +5 -4
  98. package/lib/components/textarea.d.ts.map +1 -0
  99. package/lib/components/textarea.js +458 -456
  100. package/lib/components/textarea.js.map +1 -0
  101. package/lib/components/tooltip.d.ts +4 -3
  102. package/lib/components/tooltip.d.ts.map +1 -0
  103. package/lib/components/tooltip.js +293 -283
  104. package/lib/components/tooltip.js.map +1 -0
  105. package/lib/components/wizard.d.ts +5 -4
  106. package/lib/components/wizard.d.ts.map +1 -0
  107. package/lib/components/wizard.js +359 -395
  108. package/lib/components/wizard.js.map +1 -0
  109. package/lib/icons/fontawesome/brands.d.ts.map +1 -0
  110. package/lib/icons/fontawesome/brands.js.map +1 -0
  111. package/lib/icons/fontawesome/regular.d.ts.map +1 -0
  112. package/lib/icons/fontawesome/regular.js.map +1 -0
  113. package/lib/icons/fontawesome/solid.d.ts.map +1 -0
  114. package/lib/icons/fontawesome/solid.js.map +1 -0
  115. package/lib/icons/heroicons/micro.d.ts.map +1 -0
  116. package/lib/icons/heroicons/micro.js +392 -392
  117. package/lib/icons/heroicons/micro.js.map +1 -0
  118. package/lib/icons/heroicons/mini.d.ts.map +1 -0
  119. package/lib/icons/heroicons/mini.js +382 -382
  120. package/lib/icons/heroicons/mini.js.map +1 -0
  121. package/lib/icons/heroicons/outline.d.ts.map +1 -0
  122. package/lib/icons/heroicons/outline.js +337 -337
  123. package/lib/icons/heroicons/outline.js.map +1 -0
  124. package/lib/icons/heroicons/solid.d.ts.map +1 -0
  125. package/lib/icons/heroicons/solid.js +407 -407
  126. package/lib/icons/heroicons/solid.js.map +1 -0
  127. package/lib/icons/lucide.d.ts.map +1 -0
  128. package/lib/icons/lucide.js +22843 -22843
  129. package/lib/icons/lucide.js.map +1 -0
  130. package/lib/icons/material/filled.d.ts.map +1 -0
  131. package/lib/icons/material/filled.js +9653 -9653
  132. package/lib/icons/material/filled.js.map +1 -0
  133. package/lib/icons/material/outlined.d.ts.map +1 -0
  134. package/lib/icons/material/outlined.js +10271 -10271
  135. package/lib/icons/material/outlined.js.map +1 -0
  136. package/lib/icons/material/round.d.ts.map +1 -0
  137. package/lib/icons/material/round.js +10495 -10495
  138. package/lib/icons/material/round.js.map +1 -0
  139. package/lib/icons/material/sharp.d.ts.map +1 -0
  140. package/lib/icons/material/sharp.js +9905 -9905
  141. package/lib/icons/material/sharp.js.map +1 -0
  142. package/lib/icons/material/two-tone.d.ts.map +1 -0
  143. package/lib/icons/material/two-tone.js +12792 -12792
  144. package/lib/icons/material/two-tone.js.map +1 -0
  145. package/lib/index.d.ts +1 -1
  146. package/lib/index.d.ts.map +1 -0
  147. package/lib/index.js +21 -21
  148. package/lib/index.js.map +1 -0
  149. package/lib/styles/button.d.ts.map +1 -0
  150. package/lib/styles/button.js +200 -302
  151. package/lib/styles/button.js.map +1 -0
  152. package/lib/styles/calendar-month.d.ts +3 -0
  153. package/lib/styles/calendar-month.d.ts.map +1 -0
  154. package/lib/styles/calendar-month.js +141 -185
  155. package/lib/styles/calendar-month.js.map +1 -0
  156. package/lib/styles/calendar-navigation.d.ts +1 -1
  157. package/lib/styles/calendar-navigation.d.ts.map +1 -0
  158. package/lib/styles/calendar-navigation.js +100 -86
  159. package/lib/styles/calendar-navigation.js.map +1 -0
  160. package/lib/styles/calendar.d.ts +3 -2
  161. package/lib/styles/calendar.d.ts.map +1 -0
  162. package/lib/styles/calendar.js +83 -9
  163. package/lib/styles/calendar.js.map +1 -0
  164. package/lib/styles/checkbox.js +62 -77
  165. package/lib/styles/copy.d.ts.map +1 -0
  166. package/lib/styles/copy.js +71 -91
  167. package/lib/styles/copy.js.map +1 -0
  168. package/lib/styles/custom-scrollbar.js +80 -100
  169. package/lib/styles/date-picker.d.ts.map +1 -0
  170. package/lib/styles/date-picker.js +295 -335
  171. package/lib/styles/date-picker.js.map +1 -0
  172. package/lib/styles/dropdown.d.ts +12 -0
  173. package/lib/styles/dropdown.d.ts.map +1 -0
  174. package/lib/styles/dropdown.js +725 -0
  175. package/lib/styles/dropdown.js.map +1 -0
  176. package/lib/styles/field-size.d.ts +6 -0
  177. package/lib/styles/field-size.js +91 -0
  178. package/lib/styles/file-upload.js +139 -169
  179. package/lib/styles/icon.d.ts.map +1 -0
  180. package/lib/styles/icon.js +92 -156
  181. package/lib/styles/icon.js.map +1 -0
  182. package/lib/styles/input.d.ts.map +1 -0
  183. package/lib/styles/input.js +125 -241
  184. package/lib/styles/input.js.map +1 -0
  185. package/lib/styles/modal.d.ts.map +1 -0
  186. package/lib/styles/modal.js +67 -102
  187. package/lib/styles/modal.js.map +1 -0
  188. package/lib/styles/multiselect.d.ts +6 -0
  189. package/lib/styles/multiselect.d.ts.map +1 -0
  190. package/lib/styles/multiselect.js +568 -0
  191. package/lib/styles/multiselect.js.map +1 -0
  192. package/lib/styles/option.d.ts +1 -1
  193. package/lib/styles/option.d.ts.map +1 -0
  194. package/lib/styles/option.js +47 -67
  195. package/lib/styles/option.js.map +1 -0
  196. package/lib/styles/popup.d.ts +1 -1
  197. package/lib/styles/popup.d.ts.map +1 -0
  198. package/lib/styles/popup.js +37 -65
  199. package/lib/styles/popup.js.map +1 -0
  200. package/lib/styles/radio.js +75 -96
  201. package/lib/styles/resize-observer.d.ts.map +1 -0
  202. package/lib/styles/resize-observer.js +2 -5
  203. package/lib/styles/resize-observer.js.map +1 -0
  204. package/lib/styles/scroll-container.d.ts +1 -1
  205. package/lib/styles/scroll-container.d.ts.map +1 -0
  206. package/lib/styles/scroll-container.js +101 -131
  207. package/lib/styles/scroll-container.js.map +1 -0
  208. package/lib/styles/select-base.js +596 -773
  209. package/lib/styles/select.d.ts +1 -1
  210. package/lib/styles/select.js +146 -228
  211. package/lib/styles/step.d.ts +1 -1
  212. package/lib/styles/step.d.ts.map +1 -0
  213. package/lib/styles/step.js +15 -30
  214. package/lib/styles/step.js.map +1 -0
  215. package/lib/styles/switch.js +37 -55
  216. package/lib/styles/tab.d.ts +1 -1
  217. package/lib/styles/tab.d.ts.map +1 -0
  218. package/lib/styles/tab.js +86 -29
  219. package/lib/styles/tab.js.map +1 -0
  220. package/lib/styles/tabs.d.ts +1 -1
  221. package/lib/styles/tabs.d.ts.map +1 -0
  222. package/lib/styles/tabs.js +190 -180
  223. package/lib/styles/tabs.js.map +1 -0
  224. package/lib/styles/tag.d.ts.map +1 -0
  225. package/lib/styles/tag.js +137 -191
  226. package/lib/styles/tag.js.map +1 -0
  227. package/lib/styles/textarea.d.ts +1 -1
  228. package/lib/styles/textarea.d.ts.map +1 -0
  229. package/lib/styles/textarea.js +205 -271
  230. package/lib/styles/textarea.js.map +1 -0
  231. package/lib/styles/tooltip.d.ts.map +1 -0
  232. package/lib/styles/tooltip.js +3 -3
  233. package/lib/styles/tooltip.js.map +1 -0
  234. package/lib/styles/wizard.d.ts +9 -5
  235. package/lib/styles/wizard.d.ts.map +1 -0
  236. package/lib/styles/wizard.js +301 -245
  237. package/lib/styles/wizard.js.map +1 -0
  238. package/lib/types/common.d.ts +4 -2
  239. package/lib/types/common.d.ts.map +1 -0
  240. package/lib/types/common.js +6 -5
  241. package/lib/types/common.js.map +1 -0
  242. package/lib/utils/calendar-utils.d.ts.map +1 -0
  243. package/lib/utils/calendar-utils.js +100 -100
  244. package/lib/utils/calendar-utils.js.map +1 -0
  245. package/lib/utils/custom-scrollbar.js +272 -272
  246. package/lib/utils/flavor-sheet.js +14 -14
  247. package/lib/utils/icon-registry.d.ts.map +1 -0
  248. package/lib/utils/icon-registry.js +127 -127
  249. package/lib/utils/icon-registry.js.map +1 -0
  250. package/lib/utils/loader-registry.js +3 -3
  251. package/lib/utils/locale.d.ts.map +1 -0
  252. package/lib/utils/locale.js +34 -34
  253. package/lib/utils/locale.js.map +1 -0
  254. package/lib/utils/mobile.js +1 -1
  255. package/lib/utils/number-format.d.ts.map +1 -0
  256. package/lib/utils/number-format.js +54 -54
  257. package/lib/utils/number-format.js.map +1 -0
  258. package/lib/utils/parse-boolean.d.ts +39 -0
  259. package/lib/utils/parse-boolean.d.ts.map +1 -0
  260. package/lib/utils/parse-boolean.js +23 -0
  261. package/lib/utils/parse-boolean.js.map +1 -0
  262. package/lib/utils/positioning.d.ts.map +1 -0
  263. package/lib/utils/positioning.js +212 -212
  264. package/lib/utils/positioning.js.map +1 -0
  265. package/lib/utils/property-capture.d.ts.map +1 -0
  266. package/lib/utils/property-capture.js +36 -36
  267. package/lib/utils/property-capture.js.map +1 -0
  268. package/lib/utils/property-manager.d.ts +1 -1
  269. package/lib/utils/property-manager.d.ts.map +1 -0
  270. package/lib/utils/property-manager.js +127 -125
  271. package/lib/utils/property-manager.js.map +1 -0
  272. package/lib/utils/resize-observer.d.ts.map +1 -0
  273. package/lib/utils/resize-observer.js +23 -23
  274. package/lib/utils/resize-observer.js.map +1 -0
  275. package/lib/utils/scroll-lock.d.ts.map +1 -0
  276. package/lib/utils/scroll-lock.js +57 -57
  277. package/lib/utils/scroll-lock.js.map +1 -0
  278. package/lib/utils/styles.d.ts.map +1 -0
  279. package/lib/utils/styles.js +17 -17
  280. package/lib/utils/styles.js.map +1 -0
  281. package/lib/utils/validity.d.ts +26 -0
  282. package/lib/utils/validity.js +53 -0
  283. package/lib/version.d.ts +1 -1
  284. package/lib/version.d.ts.map +1 -0
  285. package/lib/version.js +1 -1
  286. package/lib/version.js.map +1 -0
  287. package/package.json +28 -7
@@ -1,3 +1,4 @@
1
+ import { DEFAULT_SIZE } from '../types/common.js';
1
2
  import { TyComponent } from '../base/ty-component.js';
2
3
  import { ensureStyles } from '../utils/styles.js';
3
4
  import { textareaStyles } from '../styles/textarea.js';
@@ -5,465 +6,466 @@ import { CustomScrollbar, isCustomScrollbarEnabled } from '../utils/custom-scrol
5
6
  import { customScrollbarStyles } from '../styles/custom-scrollbar.js';
6
7
  const REQUIRED_ICON = `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>`;
7
8
  export class TyTextarea extends TyComponent {
8
- constructor() {
9
- super();
10
- this._textareaEl = null;
11
- this._dummyEl = null;
12
- this._scrollbar = null;
13
- this._isFocused = false;
14
- this.handleInputEvent = (e) => {
15
- const target = e.target;
16
- const newValue = target.value;
17
- this.value = newValue;
18
- if (this._textareaEl && this._dummyEl) {
19
- this.resizeTextarea(this._textareaEl, this._dummyEl);
20
- }
21
- this.emitValueEvents(e);
22
- };
23
- this.handleFocusEvent = () => {
24
- this._isFocused = true;
25
- };
26
- this.handleBlurEvent = () => {
27
- this._isFocused = false;
28
- };
29
- const shadow = this.shadowRoot;
30
- ensureStyles(shadow, { css: textareaStyles, id: 'ty-textarea' });
31
- if (isCustomScrollbarEnabled()) {
32
- ensureStyles(shadow, { css: customScrollbarStyles, id: 'ty-custom-scrollbar' });
33
- }
34
- }
35
- onConnect() {
36
- }
37
- onDisconnect() {
38
- this._destroyScrollbar();
39
- if (this._textareaEl) {
40
- const newTextarea = this._textareaEl.cloneNode(true);
41
- this._textareaEl.parentNode?.replaceChild(newTextarea, this._textareaEl);
42
- this._textareaEl = null;
43
- }
44
- this._dummyEl = null;
45
- }
46
- onPropertiesChanged(changes) {
47
- }
48
- getFormValue() {
49
- return this.getProperty('value') || null;
50
- }
51
- get value() { return this.getProperty('value'); }
52
- set value(v) { this.setProperty('value', v); }
53
- get name() { return this.getProperty('name'); }
54
- set name(v) { this.setProperty('name', v); }
55
- get placeholder() { return this.getProperty('placeholder'); }
56
- set placeholder(v) { this.setProperty('placeholder', v); }
57
- get label() { return this.getProperty('label'); }
58
- set label(v) { this.setProperty('label', v); }
59
- get disabled() { return this.getProperty('disabled'); }
60
- set disabled(v) { this.setProperty('disabled', v); }
61
- get required() { return this.getProperty('required'); }
62
- set required(v) { this.setProperty('required', v); }
63
- get error() { return this.getProperty('error'); }
64
- set error(v) { this.setProperty('error', v); }
65
- get size() {
66
- return this.getProperty('size');
67
- }
68
- set size(v) {
69
- this.setProperty('size', v);
70
- }
71
- get rows() { return this.getProperty('rows'); }
72
- set rows(v) { this.setProperty('rows', v); }
73
- get cols() { return this.getProperty('cols'); }
74
- set cols(v) { this.setProperty('cols', v); }
75
- get resize() {
76
- return this.getProperty('resize');
77
- }
78
- set resize(v) {
79
- this.setProperty('resize', v);
80
- }
81
- get minHeight() { return this.getProperty('minHeight'); }
82
- set minHeight(v) { this.setProperty('minHeight', v); }
83
- get maxHeight() { return this.getProperty('maxHeight'); }
84
- set maxHeight(v) { this.setProperty('maxHeight', v); }
85
- getFontStyle(el) {
86
- const computedStyle = window.getComputedStyle(el);
87
- return {
88
- fontFamily: computedStyle.fontFamily,
89
- fontSize: computedStyle.fontSize,
90
- fontWeight: computedStyle.fontWeight,
91
- lineHeight: computedStyle.lineHeight,
92
- letterSpacing: computedStyle.letterSpacing,
93
- fontStyle: computedStyle.fontStyle
94
- };
95
- }
96
- getSpacingStyle(el) {
97
- const computedStyle = window.getComputedStyle(el);
98
- return {
99
- padding: computedStyle.padding,
100
- paddingTop: computedStyle.paddingTop,
101
- paddingRight: computedStyle.paddingRight,
102
- paddingBottom: computedStyle.paddingBottom,
103
- paddingLeft: computedStyle.paddingLeft,
104
- margin: computedStyle.margin,
105
- borderWidth: computedStyle.borderWidth
106
- };
107
- }
108
- setupDummyElement(textareaEl) {
109
- const root = this.shadowRoot;
110
- const existingDummy = root.querySelector('.textarea-dummy');
111
- if (existingDummy) {
112
- existingDummy.remove();
113
- }
114
- const dummyEl = document.createElement('pre');
115
- const fontStyle = this.getFontStyle(textareaEl);
116
- const spacingStyle = this.getSpacingStyle(textareaEl);
117
- dummyEl.className = 'textarea-dummy';
118
- const style = dummyEl.style;
119
- style.position = 'absolute';
120
- style.top = '0';
121
- style.left = '0';
122
- style.visibility = 'hidden';
123
- style.whiteSpace = 'pre-wrap';
124
- style.wordBreak = 'break-word';
125
- style.boxSizing = 'border-box';
126
- style.overflow = 'hidden';
127
- style.pointerEvents = 'none';
128
- Object.entries(fontStyle).forEach(([prop, value]) => {
129
- ;
130
- style[prop] = value;
131
- });
132
- Object.entries(spacingStyle).forEach(([prop, value]) => {
133
- ;
134
- style[prop] = value;
135
- });
136
- root.appendChild(dummyEl);
137
- this._dummyEl = dummyEl;
138
- return dummyEl;
139
- }
140
- resizeTextarea(textareaEl, dummyEl) {
141
- if (!textareaEl || !dummyEl)
142
- return;
143
- const value = this.value;
144
- const placeholder = this.placeholder;
145
- const content = (value === '' && placeholder) ? placeholder : value + ' ';
146
- const currentHeight = textareaEl.clientHeight;
147
- dummyEl.textContent = content;
148
- dummyEl.style.width = `${textareaEl.clientWidth}px`;
149
- const measuredHeight = dummyEl.scrollHeight;
150
- const minHeight = this.minHeight ? parseInt(this.minHeight.replace('px', ''), 10) : null;
151
- const maxHeight = this.maxHeight ? parseInt(this.maxHeight.replace('px', ''), 10) : null;
152
- let constrainedHeight = measuredHeight;
153
- if (minHeight !== null)
154
- constrainedHeight = Math.max(constrainedHeight, minHeight);
155
- if (maxHeight !== null)
156
- constrainedHeight = Math.min(constrainedHeight, maxHeight);
157
- if (Math.abs(constrainedHeight - currentHeight) > 2) {
158
- textareaEl.style.height = `${constrainedHeight}px`;
159
- const needsScroll = maxHeight !== null && measuredHeight >= maxHeight;
160
- if (needsScroll) {
161
- textareaEl.style.overflowY = 'auto';
162
- this._setupScrollbar(textareaEl);
163
- }
164
- else {
165
- textareaEl.style.overflowY = 'hidden';
166
- this._destroyScrollbar();
167
- }
168
- }
169
- this._scrollbar?.update();
170
- }
171
- _setupScrollbar(textareaEl) {
172
- if (this._scrollbar || !isCustomScrollbarEnabled())
173
- return;
174
- textareaEl.style.scrollbarWidth = 'none';
175
- this.setAttribute('data-custom-scroll', '');
176
- this._scrollbar = new CustomScrollbar(textareaEl, {
177
- vertical: true,
178
- horizontal: false
179
- });
180
- const scroll = this.shadowRoot.querySelector('.textarea-scroll');
181
- if (scroll && this._scrollbar.trackY) {
182
- scroll.appendChild(this._scrollbar.trackY);
183
- }
184
- }
185
- _destroyScrollbar() {
186
- if (!this._scrollbar)
187
- return;
188
- this._scrollbar.trackY?.remove();
189
- this._scrollbar.destroy();
190
- this._scrollbar = null;
191
- this.removeAttribute('data-custom-scroll');
192
- if (this._textareaEl) {
193
- this._textareaEl.style.scrollbarWidth = '';
194
- }
195
- }
196
- emitValueEvents(originalEvent) {
197
- const value = this.value;
198
- this._internals.setFormValue(value || '');
199
- this.updateValidity();
200
- const data = {
201
- bubbles: true,
202
- composed: true,
203
- detail: {
204
- value,
205
- originalEvent
206
- }
207
- };
208
- setTimeout(() => {
209
- this.dispatchEvent(new CustomEvent('input', data));
210
- this.dispatchEvent(new CustomEvent('change', data));
211
- }, 0);
212
- }
213
- buildClassList() {
214
- const classes = [this.size];
215
- if (this.disabled)
216
- classes.push('disabled');
217
- if (this.required)
218
- classes.push('required');
219
- if (this.error)
220
- classes.push('error');
221
- if (this.resize !== 'none')
222
- classes.push(`resize-${this.resize}`);
223
- const customClass = this.getAttribute('class');
224
- if (customClass)
225
- classes.push(customClass);
226
- return classes.join(' ');
227
- }
228
- applyHeightConstraints(textareaEl) {
229
- if (this.minHeight) {
230
- textareaEl.style.minHeight = this.minHeight;
231
- }
232
- if (this.maxHeight) {
233
- textareaEl.style.maxHeight = this.maxHeight;
234
- }
235
- }
236
- setupTextareaEvents(textareaEl) {
237
- textareaEl.addEventListener('input', this.handleInputEvent);
238
- textareaEl.addEventListener('change', this.handleInputEvent);
239
- textareaEl.addEventListener('focus', this.handleFocusEvent);
240
- textareaEl.addEventListener('blur', this.handleBlurEvent);
241
- }
242
- render() {
243
- const root = this.shadowRoot;
244
- const existingContainer = root.querySelector('.textarea-container');
245
- const existingLabel = root.querySelector('label');
246
- const existingTextarea = root.querySelector('textarea');
247
- const existingError = root.querySelector('.error-message');
248
- if (existingContainer && existingTextarea) {
249
- if (this.label) {
250
- if (existingLabel) {
251
- existingLabel.innerHTML = this.label +
252
- (this.required ? ` <span class="required-icon">${REQUIRED_ICON}</span>` : '');
253
- existingLabel.style.display = 'block';
254
- }
255
- }
256
- else if (existingLabel) {
257
- existingLabel.style.display = 'none';
258
- }
259
- existingTextarea.value = this.value || '';
260
- existingTextarea.placeholder = this.placeholder || '';
261
- existingTextarea.disabled = this.disabled;
262
- existingTextarea.required = this.required;
263
- existingTextarea.className = this.buildClassList();
264
- if (this.label)
265
- existingTextarea.setAttribute('aria-label', this.label);
266
- else
267
- existingTextarea.removeAttribute('aria-label');
268
- if (this.name) {
269
- existingTextarea.setAttribute('name', this.name);
270
- }
271
- else {
272
- existingTextarea.removeAttribute('name');
273
- }
274
- if (this.rows)
275
- existingTextarea.setAttribute('rows', this.rows);
276
- if (this.cols)
277
- existingTextarea.setAttribute('cols', this.cols);
278
- this.applyHeightConstraints(existingTextarea);
279
- if (this.error) {
280
- if (!existingError) {
281
- const errorEl = document.createElement('div');
282
- errorEl.className = 'error-message';
283
- existingContainer.appendChild(errorEl);
284
- }
285
- const errorEl = root.querySelector('.error-message');
286
- if (errorEl)
287
- errorEl.textContent = this.error;
288
- }
289
- else if (existingError) {
290
- existingError.remove();
291
- }
292
- const dummyEl = this.setupDummyElement(existingTextarea);
293
- setTimeout(() => this.resizeTextarea(existingTextarea, dummyEl), 0);
294
- this._textareaEl = existingTextarea;
295
- }
296
- else {
297
- const container = document.createElement('div');
298
- container.className = 'textarea-container';
299
- const labelEl = document.createElement('label');
300
- labelEl.className = 'ty-field-label';
301
- if (this.label) {
302
- labelEl.innerHTML = this.label +
303
- (this.required ? ` <span class="required-icon">${REQUIRED_ICON}</span>` : '');
304
- labelEl.style.display = 'block';
305
- }
306
- else {
307
- labelEl.style.display = 'none';
308
- }
309
- const textareaEl = document.createElement('textarea');
310
- textareaEl.value = this.value || '';
311
- textareaEl.placeholder = this.placeholder || '';
312
- textareaEl.disabled = this.disabled;
313
- textareaEl.required = this.required;
314
- textareaEl.className = this.buildClassList();
315
- if (this.label)
316
- textareaEl.setAttribute('aria-label', this.label);
317
- if (this.name) {
318
- textareaEl.setAttribute('name', this.name);
319
- }
320
- textareaEl.setAttribute('rows', this.rows || '3');
321
- if (this.cols)
322
- textareaEl.setAttribute('cols', this.cols);
323
- this.applyHeightConstraints(textareaEl);
324
- this.setupTextareaEvents(textareaEl);
325
- const wrapperEl = document.createElement('div');
326
- wrapperEl.className = 'textarea-wrapper';
327
- const headerEl = document.createElement('div');
328
- headerEl.className = 'textarea-header';
329
- const headerSlot = document.createElement('slot');
330
- headerSlot.setAttribute('name', 'header');
331
- headerEl.appendChild(headerSlot);
332
- const scrollEl = document.createElement('div');
333
- scrollEl.className = 'textarea-scroll';
334
- scrollEl.appendChild(textareaEl);
335
- const footerEl = document.createElement('div');
336
- footerEl.className = 'textarea-footer';
337
- const footerSlot = document.createElement('slot');
338
- footerSlot.setAttribute('name', 'footer');
339
- footerEl.appendChild(footerSlot);
340
- wrapperEl.appendChild(headerEl);
341
- wrapperEl.appendChild(scrollEl);
342
- wrapperEl.appendChild(footerEl);
343
- const syncSlot = (slot, region) => {
344
- const update = () => region.classList.toggle('has-content', slot.assignedNodes({ flatten: true }).length > 0);
345
- slot.addEventListener('slotchange', update);
346
- update();
347
- };
348
- syncSlot(headerSlot, headerEl);
349
- syncSlot(footerSlot, footerEl);
350
- container.appendChild(labelEl);
351
- container.appendChild(wrapperEl);
352
- if (this.error) {
353
- const errorEl = document.createElement('div');
354
- errorEl.className = 'error-message';
355
- errorEl.textContent = this.error;
356
- container.appendChild(errorEl);
357
- }
358
- root.appendChild(container);
359
- const dummyEl = this.setupDummyElement(textareaEl);
360
- setTimeout(() => this.resizeTextarea(textareaEl, dummyEl), 0);
361
- this._textareaEl = textareaEl;
362
- }
363
- this.updateValidity();
364
- }
365
- updateValidity() {
366
- const ta = this.shadowRoot?.querySelector('textarea');
367
- if (this.disabled) {
368
- this._internals.setValidity({});
369
- return;
370
- }
371
- const current = ta ? ta.value : String(this.value ?? '');
372
- if (this.required && current.trim() === '') {
373
- this._internals.setValidity({ valueMissing: true }, 'Please fill out this field', ta ?? undefined);
374
- }
375
- else {
376
- this._internals.setValidity({});
377
- }
378
- }
9
+ constructor() {
10
+ super();
11
+ this._textareaEl = null;
12
+ this._dummyEl = null;
13
+ this._scrollbar = null;
14
+ this._isFocused = false;
15
+ this.handleInputEvent = (e) => {
16
+ const target = e.target;
17
+ const newValue = target.value;
18
+ this.value = newValue;
19
+ if (this._textareaEl && this._dummyEl) {
20
+ this.resizeTextarea(this._textareaEl, this._dummyEl);
21
+ }
22
+ this._internals.setFormValue(this.value || '');
23
+ this.updateValidity();
24
+ this.emitValueEvent('input', e);
25
+ };
26
+ this._valueAtFocus = null;
27
+ this.handleFocusEvent = () => {
28
+ this._isFocused = true;
29
+ this._valueAtFocus = this.value;
30
+ };
31
+ this.handleBlurEvent = (e) => {
32
+ this._isFocused = false;
33
+ if (this._valueAtFocus !== null && this.value !== this._valueAtFocus) {
34
+ this.emitValueEvent('change', e);
35
+ }
36
+ this._valueAtFocus = null;
37
+ };
38
+ const shadow = this.shadowRoot;
39
+ ensureStyles(shadow, { css: textareaStyles, id: 'ty-textarea' });
40
+ if (isCustomScrollbarEnabled()) {
41
+ ensureStyles(shadow, { css: customScrollbarStyles, id: 'ty-custom-scrollbar' });
42
+ }
43
+ }
44
+ onConnect() {
45
+ }
46
+ onDisconnect() {
47
+ this._destroyScrollbar();
48
+ if (this._textareaEl) {
49
+ const newTextarea = this._textareaEl.cloneNode(true);
50
+ this._textareaEl.parentNode?.replaceChild(newTextarea, this._textareaEl);
51
+ this._textareaEl = null;
52
+ }
53
+ this._dummyEl = null;
54
+ }
55
+ onPropertiesChanged(changes) {
56
+ }
57
+ getFormValue() {
58
+ return this.getProperty('value') || null;
59
+ }
60
+ get value() { return this.getProperty('value'); }
61
+ set value(v) { this.setProperty('value', v); }
62
+ get name() { return this.getProperty('name'); }
63
+ set name(v) { this.setProperty('name', v); }
64
+ get placeholder() { return this.getProperty('placeholder'); }
65
+ set placeholder(v) { this.setProperty('placeholder', v); }
66
+ get label() { return this.getProperty('label'); }
67
+ set label(v) { this.setProperty('label', v); }
68
+ get disabled() { return this.getProperty('disabled'); }
69
+ set disabled(v) { this.setProperty('disabled', v); }
70
+ get required() { return this.getProperty('required'); }
71
+ set required(v) { this.setProperty('required', v); }
72
+ get error() { return this.getProperty('error'); }
73
+ set error(v) { this.setProperty('error', v); }
74
+ get size() {
75
+ return this.getProperty('size');
76
+ }
77
+ set size(v) {
78
+ this.setProperty('size', v);
79
+ }
80
+ get rows() { return this.getProperty('rows'); }
81
+ set rows(v) { this.setProperty('rows', v); }
82
+ get cols() { return this.getProperty('cols'); }
83
+ set cols(v) { this.setProperty('cols', v); }
84
+ get resize() {
85
+ return this.getProperty('resize');
86
+ }
87
+ set resize(v) {
88
+ this.setProperty('resize', v);
89
+ }
90
+ get minHeight() { return this.getProperty('minHeight'); }
91
+ set minHeight(v) { this.setProperty('minHeight', v); }
92
+ get maxHeight() { return this.getProperty('maxHeight'); }
93
+ set maxHeight(v) { this.setProperty('maxHeight', v); }
94
+ getFontStyle(el) {
95
+ const computedStyle = window.getComputedStyle(el);
96
+ return {
97
+ fontFamily: computedStyle.fontFamily,
98
+ fontSize: computedStyle.fontSize,
99
+ fontWeight: computedStyle.fontWeight,
100
+ lineHeight: computedStyle.lineHeight,
101
+ letterSpacing: computedStyle.letterSpacing,
102
+ fontStyle: computedStyle.fontStyle
103
+ };
104
+ }
105
+ getSpacingStyle(el) {
106
+ const computedStyle = window.getComputedStyle(el);
107
+ return {
108
+ padding: computedStyle.padding,
109
+ paddingTop: computedStyle.paddingTop,
110
+ paddingRight: computedStyle.paddingRight,
111
+ paddingBottom: computedStyle.paddingBottom,
112
+ paddingLeft: computedStyle.paddingLeft,
113
+ margin: computedStyle.margin,
114
+ borderWidth: computedStyle.borderWidth
115
+ };
116
+ }
117
+ setupDummyElement(textareaEl) {
118
+ const root = this.shadowRoot;
119
+ const existingDummy = root.querySelector('.textarea-dummy');
120
+ if (existingDummy) {
121
+ existingDummy.remove();
122
+ }
123
+ const dummyEl = document.createElement('pre');
124
+ const fontStyle = this.getFontStyle(textareaEl);
125
+ const spacingStyle = this.getSpacingStyle(textareaEl);
126
+ dummyEl.className = 'textarea-dummy';
127
+ const style = dummyEl.style;
128
+ style.position = 'absolute';
129
+ style.top = '0';
130
+ style.left = '0';
131
+ style.visibility = 'hidden';
132
+ style.whiteSpace = 'pre-wrap';
133
+ style.wordBreak = 'break-word';
134
+ style.boxSizing = 'border-box';
135
+ style.overflow = 'hidden';
136
+ style.pointerEvents = 'none';
137
+ Object.entries(fontStyle).forEach(([prop, value]) => {
138
+ ;
139
+ style[prop] = value;
140
+ });
141
+ Object.entries(spacingStyle).forEach(([prop, value]) => {
142
+ ;
143
+ style[prop] = value;
144
+ });
145
+ root.appendChild(dummyEl);
146
+ this._dummyEl = dummyEl;
147
+ return dummyEl;
148
+ }
149
+ resizeTextarea(textareaEl, dummyEl) {
150
+ if (!textareaEl || !dummyEl)
151
+ return;
152
+ const value = this.value;
153
+ const placeholder = this.placeholder;
154
+ const content = (value === '' && placeholder) ? placeholder : value + ' ';
155
+ const currentHeight = textareaEl.clientHeight;
156
+ dummyEl.textContent = content;
157
+ dummyEl.style.width = `${textareaEl.clientWidth}px`;
158
+ const measuredHeight = dummyEl.scrollHeight;
159
+ const minHeight = this.minHeight ? parseInt(this.minHeight.replace('px', ''), 10) : null;
160
+ const maxHeight = this.maxHeight ? parseInt(this.maxHeight.replace('px', ''), 10) : null;
161
+ let constrainedHeight = measuredHeight;
162
+ if (minHeight !== null)
163
+ constrainedHeight = Math.max(constrainedHeight, minHeight);
164
+ if (maxHeight !== null)
165
+ constrainedHeight = Math.min(constrainedHeight, maxHeight);
166
+ if (Math.abs(constrainedHeight - currentHeight) > 2) {
167
+ textareaEl.style.height = `${constrainedHeight}px`;
168
+ const needsScroll = maxHeight !== null && measuredHeight >= maxHeight;
169
+ if (needsScroll) {
170
+ textareaEl.style.overflowY = 'auto';
171
+ this._setupScrollbar(textareaEl);
172
+ }
173
+ else {
174
+ textareaEl.style.overflowY = 'hidden';
175
+ this._destroyScrollbar();
176
+ }
177
+ }
178
+ this._scrollbar?.update();
179
+ }
180
+ _setupScrollbar(textareaEl) {
181
+ if (this._scrollbar || !isCustomScrollbarEnabled())
182
+ return;
183
+ textareaEl.style.scrollbarWidth = 'none';
184
+ this.setAttribute('data-custom-scroll', '');
185
+ this._scrollbar = new CustomScrollbar(textareaEl, {
186
+ vertical: true,
187
+ horizontal: false
188
+ });
189
+ const scroll = this.shadowRoot.querySelector('.textarea-scroll');
190
+ if (scroll && this._scrollbar.trackY) {
191
+ scroll.appendChild(this._scrollbar.trackY);
192
+ }
193
+ }
194
+ _destroyScrollbar() {
195
+ if (!this._scrollbar)
196
+ return;
197
+ this._scrollbar.trackY?.remove();
198
+ this._scrollbar.destroy();
199
+ this._scrollbar = null;
200
+ this.removeAttribute('data-custom-scroll');
201
+ if (this._textareaEl) {
202
+ this._textareaEl.style.scrollbarWidth = '';
203
+ }
204
+ }
205
+ emitValueEvent(type, originalEvent) {
206
+ const data = {
207
+ bubbles: true,
208
+ composed: true,
209
+ detail: {
210
+ value: this.value,
211
+ originalEvent
212
+ }
213
+ };
214
+ setTimeout(() => this.dispatchEvent(new CustomEvent(type, data)), 0);
215
+ }
216
+ buildClassList() {
217
+ const classes = [this.size];
218
+ if (this.disabled)
219
+ classes.push('disabled');
220
+ if (this.required)
221
+ classes.push('required');
222
+ if (this.error)
223
+ classes.push('error');
224
+ if (this.resize !== 'none')
225
+ classes.push(`resize-${this.resize}`);
226
+ const customClass = this.getAttribute('class');
227
+ if (customClass)
228
+ classes.push(customClass);
229
+ return classes.join(' ');
230
+ }
231
+ applyHeightConstraints(textareaEl) {
232
+ if (this.minHeight) {
233
+ textareaEl.style.minHeight = this.minHeight;
234
+ }
235
+ if (this.maxHeight) {
236
+ textareaEl.style.maxHeight = this.maxHeight;
237
+ }
238
+ }
239
+ setupTextareaEvents(textareaEl) {
240
+ textareaEl.addEventListener('input', this.handleInputEvent);
241
+ textareaEl.addEventListener('focus', this.handleFocusEvent);
242
+ textareaEl.addEventListener('blur', this.handleBlurEvent);
243
+ }
244
+ render() {
245
+ const root = this.shadowRoot;
246
+ const existingContainer = root.querySelector('.textarea-container');
247
+ const existingLabel = root.querySelector('label');
248
+ const existingTextarea = root.querySelector('textarea');
249
+ const existingError = root.querySelector('.error-message');
250
+ if (existingContainer && existingTextarea) {
251
+ if (this.label) {
252
+ if (existingLabel) {
253
+ existingLabel.innerHTML = this.label +
254
+ (this.required ? ` <span class="required-icon">${REQUIRED_ICON}</span>` : '');
255
+ existingLabel.style.display = 'block';
256
+ }
257
+ }
258
+ else if (existingLabel) {
259
+ existingLabel.style.display = 'none';
260
+ }
261
+ existingTextarea.value = this.value || '';
262
+ existingTextarea.placeholder = this.placeholder || '';
263
+ existingTextarea.disabled = this.disabled;
264
+ existingTextarea.required = this.required;
265
+ existingTextarea.className = this.buildClassList();
266
+ if (this.label)
267
+ existingTextarea.setAttribute('aria-label', this.label);
268
+ else
269
+ existingTextarea.removeAttribute('aria-label');
270
+ if (this.name) {
271
+ existingTextarea.setAttribute('name', this.name);
272
+ }
273
+ else {
274
+ existingTextarea.removeAttribute('name');
275
+ }
276
+ if (this.rows)
277
+ existingTextarea.setAttribute('rows', this.rows);
278
+ if (this.cols)
279
+ existingTextarea.setAttribute('cols', this.cols);
280
+ this.applyHeightConstraints(existingTextarea);
281
+ if (this.error) {
282
+ if (!existingError) {
283
+ const errorEl = document.createElement('div');
284
+ errorEl.className = 'error-message';
285
+ existingContainer.appendChild(errorEl);
286
+ }
287
+ const errorEl = root.querySelector('.error-message');
288
+ if (errorEl)
289
+ errorEl.textContent = this.error;
290
+ }
291
+ else if (existingError) {
292
+ existingError.remove();
293
+ }
294
+ const dummyEl = this.setupDummyElement(existingTextarea);
295
+ setTimeout(() => this.resizeTextarea(existingTextarea, dummyEl), 0);
296
+ this._textareaEl = existingTextarea;
297
+ }
298
+ else {
299
+ const container = document.createElement('div');
300
+ container.className = 'textarea-container';
301
+ const labelEl = document.createElement('label');
302
+ labelEl.className = 'ty-field-label';
303
+ if (this.label) {
304
+ labelEl.innerHTML = this.label +
305
+ (this.required ? ` <span class="required-icon">${REQUIRED_ICON}</span>` : '');
306
+ labelEl.style.display = 'block';
307
+ }
308
+ else {
309
+ labelEl.style.display = 'none';
310
+ }
311
+ const textareaEl = document.createElement('textarea');
312
+ textareaEl.value = this.value || '';
313
+ textareaEl.placeholder = this.placeholder || '';
314
+ textareaEl.disabled = this.disabled;
315
+ textareaEl.required = this.required;
316
+ textareaEl.className = this.buildClassList();
317
+ if (this.label)
318
+ textareaEl.setAttribute('aria-label', this.label);
319
+ if (this.name) {
320
+ textareaEl.setAttribute('name', this.name);
321
+ }
322
+ textareaEl.setAttribute('rows', this.rows || '3');
323
+ if (this.cols)
324
+ textareaEl.setAttribute('cols', this.cols);
325
+ this.applyHeightConstraints(textareaEl);
326
+ this.setupTextareaEvents(textareaEl);
327
+ const wrapperEl = document.createElement('div');
328
+ wrapperEl.className = 'textarea-wrapper';
329
+ const headerEl = document.createElement('div');
330
+ headerEl.className = 'textarea-header';
331
+ const headerSlot = document.createElement('slot');
332
+ headerSlot.setAttribute('name', 'header');
333
+ headerEl.appendChild(headerSlot);
334
+ const scrollEl = document.createElement('div');
335
+ scrollEl.className = 'textarea-scroll';
336
+ scrollEl.appendChild(textareaEl);
337
+ const footerEl = document.createElement('div');
338
+ footerEl.className = 'textarea-footer';
339
+ const footerSlot = document.createElement('slot');
340
+ footerSlot.setAttribute('name', 'footer');
341
+ footerEl.appendChild(footerSlot);
342
+ wrapperEl.appendChild(headerEl);
343
+ wrapperEl.appendChild(scrollEl);
344
+ wrapperEl.appendChild(footerEl);
345
+ const syncSlot = (slot, region) => {
346
+ const update = () => region.classList.toggle('has-content', slot.assignedNodes({ flatten: true }).length > 0);
347
+ slot.addEventListener('slotchange', update);
348
+ update();
349
+ };
350
+ syncSlot(headerSlot, headerEl);
351
+ syncSlot(footerSlot, footerEl);
352
+ container.appendChild(labelEl);
353
+ container.appendChild(wrapperEl);
354
+ if (this.error) {
355
+ const errorEl = document.createElement('div');
356
+ errorEl.className = 'error-message';
357
+ errorEl.textContent = this.error;
358
+ container.appendChild(errorEl);
359
+ }
360
+ root.appendChild(container);
361
+ const dummyEl = this.setupDummyElement(textareaEl);
362
+ setTimeout(() => this.resizeTextarea(textareaEl, dummyEl), 0);
363
+ this._textareaEl = textareaEl;
364
+ }
365
+ this.updateValidity();
366
+ }
367
+ updateValidity() {
368
+ const ta = this.shadowRoot?.querySelector('textarea');
369
+ if (this.disabled) {
370
+ this.applyValidity({});
371
+ return;
372
+ }
373
+ const current = ta ? ta.value : String(this.value ?? '');
374
+ if (this.required && current.trim() === '') {
375
+ this.applyValidity({ valueMissing: true }, 'Please fill out this field', ta ?? undefined);
376
+ }
377
+ else {
378
+ this.applyValidity({});
379
+ }
380
+ }
379
381
  }
380
382
  TyTextarea.formAssociated = true;
381
383
  TyTextarea.properties = {
382
- value: {
383
- type: 'string',
384
- visual: true,
385
- formValue: true,
386
- emitChange: true,
387
- default: ''
388
- },
389
- name: {
390
- type: 'string',
391
- default: ''
392
- },
393
- placeholder: {
394
- type: 'string',
395
- visual: true,
396
- default: ''
397
- },
398
- label: {
399
- type: 'string',
400
- visual: true,
401
- default: ''
402
- },
403
- disabled: {
404
- type: 'boolean',
405
- visual: true,
406
- default: false
407
- },
408
- required: {
409
- type: 'boolean',
410
- visual: true,
411
- default: false
412
- },
413
- error: {
414
- type: 'string',
415
- visual: true,
416
- default: ''
417
- },
418
- size: {
419
- type: 'string',
420
- visual: true,
421
- default: 'md',
422
- validate: (v) => ['xs', 'sm', 'md', 'lg', 'xl'].includes(v),
423
- coerce: (v) => {
424
- if (!['xs', 'sm', 'md', 'lg', 'xl'].includes(v)) {
425
- console.warn(`[ty-textarea] Invalid size '${v}'. Using 'md'.`);
426
- return 'md';
427
- }
428
- return v;
429
- }
430
- },
431
- rows: {
432
- type: 'string',
433
- visual: true,
434
- default: '3',
435
- coerce: (v) => String(v)
436
- },
437
- cols: {
438
- type: 'string',
439
- visual: true,
440
- default: '',
441
- coerce: (v) => v ? String(v) : ''
442
- },
443
- resize: {
444
- type: 'string',
445
- visual: true,
446
- default: 'none',
447
- validate: (v) => ['none', 'both', 'horizontal', 'vertical'].includes(v),
448
- coerce: (v) => {
449
- if (!['none', 'both', 'horizontal', 'vertical'].includes(v)) {
450
- console.warn(`[ty-textarea] Invalid resize '${v}'. Using 'none'.`);
451
- return 'none';
452
- }
453
- return v;
454
- }
455
- },
456
- minHeight: {
457
- type: 'string',
458
- visual: true,
459
- default: ''
460
- },
461
- maxHeight: {
462
- type: 'string',
463
- visual: true,
464
- default: ''
465
- }
384
+ value: {
385
+ type: 'string',
386
+ visual: true,
387
+ formValue: true,
388
+ emitChange: true,
389
+ default: ''
390
+ },
391
+ name: {
392
+ type: 'string',
393
+ default: ''
394
+ },
395
+ placeholder: {
396
+ type: 'string',
397
+ visual: true,
398
+ default: ''
399
+ },
400
+ label: {
401
+ type: 'string',
402
+ visual: true,
403
+ default: ''
404
+ },
405
+ disabled: {
406
+ type: 'boolean',
407
+ visual: true,
408
+ default: false
409
+ },
410
+ required: {
411
+ type: 'boolean',
412
+ visual: true,
413
+ default: false
414
+ },
415
+ error: {
416
+ type: 'string',
417
+ visual: true,
418
+ default: ''
419
+ },
420
+ size: {
421
+ type: 'string',
422
+ visual: true,
423
+ default: DEFAULT_SIZE,
424
+ validate: (v) => ['xs', 'sm', 'md', 'lg', 'xl'].includes(v),
425
+ coerce: (v) => {
426
+ if (!['xs', 'sm', 'md', 'lg', 'xl'].includes(v)) {
427
+ console.warn(`[ty-textarea] Invalid size '${v}'. Using '${DEFAULT_SIZE}'.`);
428
+ return DEFAULT_SIZE;
429
+ }
430
+ return v;
431
+ }
432
+ },
433
+ rows: {
434
+ type: 'string',
435
+ visual: true,
436
+ default: '3',
437
+ coerce: (v) => String(v)
438
+ },
439
+ cols: {
440
+ type: 'string',
441
+ visual: true,
442
+ default: '',
443
+ coerce: (v) => v ? String(v) : ''
444
+ },
445
+ resize: {
446
+ type: 'string',
447
+ visual: true,
448
+ default: 'none',
449
+ validate: (v) => ['none', 'both', 'horizontal', 'vertical'].includes(v),
450
+ coerce: (v) => {
451
+ if (!['none', 'both', 'horizontal', 'vertical'].includes(v)) {
452
+ console.warn(`[ty-textarea] Invalid resize '${v}'. Using 'none'.`);
453
+ return 'none';
454
+ }
455
+ return v;
456
+ }
457
+ },
458
+ minHeight: {
459
+ type: 'string',
460
+ visual: true,
461
+ default: ''
462
+ },
463
+ maxHeight: {
464
+ type: 'string',
465
+ visual: true,
466
+ default: ''
467
+ }
466
468
  };
467
469
  if (!customElements.get('ty-textarea')) {
468
- customElements.define('ty-textarea', TyTextarea);
470
+ customElements.define('ty-textarea', TyTextarea);
469
471
  }