tyrell-components 1.0.0-RC13 → 1.0.0-RC15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/css/tyrell-theme.css +192 -180
- package/css/tyrell.css +23 -0
- package/dist/tyrell-colors-static.css +1 -316
- package/dist/tyrell-theme.css +1 -1454
- package/dist/tyrell.css +1 -1371
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +20 -10
- package/lib/base/ty-component.js +196 -319
- package/lib/components/button.d.ts +3 -17
- package/lib/components/button.js +261 -295
- package/lib/components/calendar-month.d.ts +4 -50
- package/lib/components/calendar-month.js +443 -582
- package/lib/components/calendar-navigation.d.ts +3 -48
- package/lib/components/calendar-navigation.js +239 -362
- package/lib/components/calendar.d.ts +8 -83
- package/lib/components/calendar.js +616 -829
- package/lib/components/checkbox.d.ts +5 -72
- package/lib/components/checkbox.js +273 -416
- package/lib/components/copy.d.ts +4 -57
- package/lib/components/copy.js +280 -397
- package/lib/components/date-picker.d.ts +21 -163
- package/lib/components/date-picker.js +1143 -1674
- package/lib/components/file-upload.d.ts +9 -15
- package/lib/components/file-upload.js +404 -426
- package/lib/components/icon.d.ts +3 -24
- package/lib/components/icon.js +141 -230
- package/lib/components/input.d.ts +8 -108
- package/lib/components/input.js +593 -784
- package/lib/components/modal.d.ts +17 -26
- package/lib/components/modal.js +340 -484
- package/lib/components/option.d.ts +2 -9
- package/lib/components/option.js +168 -216
- package/lib/components/popup.d.ts +2 -17
- package/lib/components/popup.js +249 -380
- package/lib/components/radio.d.ts +5 -25
- package/lib/components/radio.js +407 -461
- package/lib/components/resize-observer.d.ts +3 -30
- package/lib/components/resize-observer.js +69 -103
- package/lib/components/scroll-container.d.ts +2 -12
- package/lib/components/scroll-container.js +293 -338
- package/lib/components/select.d.ts +87 -159
- package/lib/components/select.js +1609 -2090
- package/lib/components/selected-tags.d.ts +5 -48
- package/lib/components/selected-tags.js +188 -276
- package/lib/components/step.d.ts +1 -6
- package/lib/components/step.js +62 -68
- package/lib/components/switch.d.ts +1 -12
- package/lib/components/switch.js +214 -247
- package/lib/components/tab.d.ts +1 -6
- package/lib/components/tab.js +62 -69
- package/lib/components/tabs.d.ts +6 -63
- package/lib/components/tabs.js +545 -777
- package/lib/components/tag.d.ts +3 -37
- package/lib/components/tag.js +236 -335
- package/lib/components/textarea.d.ts +7 -87
- package/lib/components/textarea.js +457 -627
- package/lib/components/tooltip.d.ts +3 -11
- package/lib/components/tooltip.js +307 -443
- package/lib/components/wizard.d.ts +6 -54
- package/lib/components/wizard.js +405 -618
- package/lib/icons/fontawesome/brands.d.ts +0 -1
- package/lib/icons/fontawesome/brands.js +0 -8
- package/lib/icons/fontawesome/regular.d.ts +0 -1
- package/lib/icons/fontawesome/regular.js +0 -8
- package/lib/icons/fontawesome/solid.d.ts +0 -1
- package/lib/icons/fontawesome/solid.js +0 -8
- package/lib/icons/heroicons/micro.d.ts +0 -1
- package/lib/icons/heroicons/micro.js +392 -400
- package/lib/icons/heroicons/mini.d.ts +0 -1
- package/lib/icons/heroicons/mini.js +382 -390
- package/lib/icons/heroicons/outline.d.ts +0 -1
- package/lib/icons/heroicons/outline.js +337 -345
- package/lib/icons/heroicons/solid.d.ts +0 -1
- package/lib/icons/heroicons/solid.js +407 -415
- package/lib/icons/lucide.d.ts +0 -1
- package/lib/icons/lucide.js +24479 -26351
- package/lib/icons/material/filled.d.ts +0 -1
- package/lib/icons/material/filled.js +9653 -9663
- package/lib/icons/material/outlined.d.ts +0 -1
- package/lib/icons/material/outlined.js +10271 -10281
- package/lib/icons/material/round.d.ts +0 -1
- package/lib/icons/material/round.js +10495 -10505
- package/lib/icons/material/sharp.d.ts +0 -1
- package/lib/icons/material/sharp.js +9905 -9915
- package/lib/icons/material/two-tone.d.ts +0 -1
- package/lib/icons/material/two-tone.js +12792 -12802
- package/lib/index.d.ts +0 -1
- package/lib/index.js +21 -41
- package/lib/styles/button.d.ts +2 -20
- package/lib/styles/button.js +202 -404
- package/lib/styles/calendar-month.d.ts +1 -5
- package/lib/styles/calendar-month.js +127 -244
- package/lib/styles/calendar-navigation.d.ts +2 -6
- package/lib/styles/calendar-navigation.js +64 -104
- package/lib/styles/calendar.d.ts +1 -2
- package/lib/styles/calendar.js +9 -22
- package/lib/styles/checkbox.d.ts +0 -1
- package/lib/styles/checkbox.js +45 -94
- package/lib/styles/copy.d.ts +0 -1
- package/lib/styles/copy.js +67 -106
- package/lib/styles/custom-scrollbar.d.ts +1 -2
- package/lib/styles/custom-scrollbar.js +80 -115
- package/lib/styles/date-picker.d.ts +1 -5
- package/lib/styles/date-picker.js +261 -335
- package/lib/styles/field-size.d.ts +6 -0
- package/lib/styles/field-size.js +91 -0
- package/lib/styles/file-upload.d.ts +1 -2
- package/lib/styles/file-upload.js +143 -188
- package/lib/styles/icon.d.ts +2 -6
- package/lib/styles/icon.js +92 -170
- package/lib/styles/input.d.ts +1 -6
- package/lib/styles/input.js +125 -290
- package/lib/styles/modal.d.ts +1 -2
- package/lib/styles/modal.js +71 -108
- package/lib/styles/option.d.ts +2 -6
- package/lib/styles/option.js +49 -64
- package/lib/styles/popup.d.ts +1 -2
- package/lib/styles/popup.js +42 -77
- package/lib/styles/radio.d.ts +0 -1
- package/lib/styles/radio.js +69 -110
- package/lib/styles/resize-observer.d.ts +1 -2
- package/lib/styles/resize-observer.js +2 -12
- package/lib/styles/scroll-container.d.ts +1 -2
- package/lib/styles/scroll-container.js +100 -149
- package/lib/styles/select-base.d.ts +0 -1
- package/lib/styles/select-base.js +597 -785
- package/lib/styles/select.d.ts +1 -2
- package/lib/styles/select.js +140 -236
- package/lib/styles/step.d.ts +1 -2
- package/lib/styles/step.js +22 -33
- package/lib/styles/switch.d.ts +0 -1
- package/lib/styles/switch.js +34 -73
- package/lib/styles/tab.d.ts +1 -2
- package/lib/styles/tab.js +22 -34
- package/lib/styles/tabs.d.ts +3 -11
- package/lib/styles/tabs.js +190 -222
- package/lib/styles/tag.d.ts +1 -5
- package/lib/styles/tag.js +136 -218
- package/lib/styles/textarea.d.ts +1 -2
- package/lib/styles/textarea.js +210 -319
- package/lib/styles/tooltip.d.ts +0 -1
- package/lib/styles/tooltip.js +3 -13
- package/lib/styles/wizard.d.ts +5 -21
- package/lib/styles/wizard.js +170 -306
- package/lib/types/common.d.ts +2 -2
- package/lib/types/common.js +6 -17
- package/lib/utils/calendar-utils.d.ts +4 -21
- package/lib/utils/calendar-utils.js +100 -273
- package/lib/utils/custom-scrollbar.d.ts +6 -20
- package/lib/utils/custom-scrollbar.js +273 -317
- package/lib/utils/flavor-sheet.d.ts +0 -1
- package/lib/utils/flavor-sheet.js +14 -37
- package/lib/utils/icon-registry.d.ts +0 -2
- package/lib/utils/icon-registry.js +137 -243
- package/lib/utils/icons.d.ts +0 -1
- package/lib/utils/icons.js +0 -9
- package/lib/utils/loader-registry.d.ts +0 -1
- package/lib/utils/loader-registry.js +3 -35
- package/lib/utils/locale.d.ts +2 -23
- package/lib/utils/locale.js +34 -120
- package/lib/utils/mobile.d.ts +0 -1
- package/lib/utils/mobile.js +1 -18
- package/lib/utils/number-format.d.ts +6 -3
- package/lib/utils/number-format.js +54 -110
- package/lib/utils/positioning.d.ts +50 -7
- package/lib/utils/positioning.js +224 -234
- package/lib/utils/property-capture.d.ts +5 -27
- package/lib/utils/property-capture.js +36 -144
- package/lib/utils/property-manager.d.ts +0 -1
- package/lib/utils/property-manager.js +126 -196
- package/lib/utils/resize-observer.d.ts +0 -1
- package/lib/utils/resize-observer.js +23 -59
- package/lib/utils/scroll-lock.d.ts +4 -11
- package/lib/utils/scroll-lock.js +65 -172
- package/lib/utils/styles.d.ts +0 -1
- package/lib/utils/styles.js +17 -41
- package/lib/version.d.ts +1 -2
- package/lib/version.js +1 -11
- package/package.json +4 -4
- package/lib/base/ty-component.d.ts.map +0 -1
- package/lib/base/ty-component.js.map +0 -1
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js.map +0 -1
- package/lib/components/calendar-month.d.ts.map +0 -1
- package/lib/components/calendar-month.js.map +0 -1
- package/lib/components/calendar-navigation.d.ts.map +0 -1
- package/lib/components/calendar-navigation.js.map +0 -1
- package/lib/components/calendar.d.ts.map +0 -1
- package/lib/components/calendar.js.map +0 -1
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js.map +0 -1
- package/lib/components/copy.d.ts.map +0 -1
- package/lib/components/copy.js.map +0 -1
- package/lib/components/date-picker.d.ts.map +0 -1
- package/lib/components/date-picker.js.map +0 -1
- package/lib/components/file-upload.d.ts.map +0 -1
- package/lib/components/file-upload.js.map +0 -1
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js.map +0 -1
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js.map +0 -1
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js.map +0 -1
- package/lib/components/option.d.ts.map +0 -1
- package/lib/components/option.js.map +0 -1
- package/lib/components/popup.d.ts.map +0 -1
- package/lib/components/popup.js.map +0 -1
- package/lib/components/radio.d.ts.map +0 -1
- package/lib/components/radio.js.map +0 -1
- package/lib/components/resize-observer.d.ts.map +0 -1
- package/lib/components/resize-observer.js.map +0 -1
- package/lib/components/scroll-container.d.ts.map +0 -1
- package/lib/components/scroll-container.js.map +0 -1
- package/lib/components/select.d.ts.map +0 -1
- package/lib/components/select.js.map +0 -1
- package/lib/components/selected-tags.d.ts.map +0 -1
- package/lib/components/selected-tags.js.map +0 -1
- package/lib/components/step.d.ts.map +0 -1
- package/lib/components/step.js.map +0 -1
- package/lib/components/switch.d.ts.map +0 -1
- package/lib/components/switch.js.map +0 -1
- package/lib/components/tab.d.ts.map +0 -1
- package/lib/components/tab.js.map +0 -1
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js.map +0 -1
- package/lib/components/tag.d.ts.map +0 -1
- package/lib/components/tag.js.map +0 -1
- package/lib/components/textarea.d.ts.map +0 -1
- package/lib/components/textarea.js.map +0 -1
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js.map +0 -1
- package/lib/components/wizard.d.ts.map +0 -1
- package/lib/components/wizard.js.map +0 -1
- package/lib/icons/fontawesome/brands.d.ts.map +0 -1
- package/lib/icons/fontawesome/brands.js.map +0 -1
- package/lib/icons/fontawesome/regular.d.ts.map +0 -1
- package/lib/icons/fontawesome/regular.js.map +0 -1
- package/lib/icons/fontawesome/solid.d.ts.map +0 -1
- package/lib/icons/fontawesome/solid.js.map +0 -1
- package/lib/icons/heroicons/micro.d.ts.map +0 -1
- package/lib/icons/heroicons/micro.js.map +0 -1
- package/lib/icons/heroicons/mini.d.ts.map +0 -1
- package/lib/icons/heroicons/mini.js.map +0 -1
- package/lib/icons/heroicons/outline.d.ts.map +0 -1
- package/lib/icons/heroicons/outline.js.map +0 -1
- package/lib/icons/heroicons/solid.d.ts.map +0 -1
- package/lib/icons/heroicons/solid.js.map +0 -1
- package/lib/icons/lucide.d.ts.map +0 -1
- package/lib/icons/lucide.js.map +0 -1
- package/lib/icons/material/filled.d.ts.map +0 -1
- package/lib/icons/material/filled.js.map +0 -1
- package/lib/icons/material/outlined.d.ts.map +0 -1
- package/lib/icons/material/outlined.js.map +0 -1
- package/lib/icons/material/round.d.ts.map +0 -1
- package/lib/icons/material/round.js.map +0 -1
- package/lib/icons/material/sharp.d.ts.map +0 -1
- package/lib/icons/material/sharp.js.map +0 -1
- package/lib/icons/material/two-tone.d.ts.map +0 -1
- package/lib/icons/material/two-tone.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/styles/button.d.ts.map +0 -1
- package/lib/styles/button.js.map +0 -1
- package/lib/styles/calendar-month.d.ts.map +0 -1
- package/lib/styles/calendar-month.js.map +0 -1
- package/lib/styles/calendar-navigation.d.ts.map +0 -1
- package/lib/styles/calendar-navigation.js.map +0 -1
- package/lib/styles/calendar.d.ts.map +0 -1
- package/lib/styles/calendar.js.map +0 -1
- package/lib/styles/checkbox.d.ts.map +0 -1
- package/lib/styles/checkbox.js.map +0 -1
- package/lib/styles/copy.d.ts.map +0 -1
- package/lib/styles/copy.js.map +0 -1
- package/lib/styles/custom-scrollbar.d.ts.map +0 -1
- package/lib/styles/custom-scrollbar.js.map +0 -1
- package/lib/styles/date-picker.d.ts.map +0 -1
- package/lib/styles/date-picker.js.map +0 -1
- package/lib/styles/file-upload.d.ts.map +0 -1
- package/lib/styles/file-upload.js.map +0 -1
- package/lib/styles/icon.d.ts.map +0 -1
- package/lib/styles/icon.js.map +0 -1
- package/lib/styles/input.d.ts.map +0 -1
- package/lib/styles/input.js.map +0 -1
- package/lib/styles/modal.d.ts.map +0 -1
- package/lib/styles/modal.js.map +0 -1
- package/lib/styles/multiselect.d.ts +0 -8
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -849
- package/lib/styles/multiselect.js.map +0 -1
- package/lib/styles/option.d.ts.map +0 -1
- package/lib/styles/option.js.map +0 -1
- package/lib/styles/popup.d.ts.map +0 -1
- package/lib/styles/popup.js.map +0 -1
- package/lib/styles/radio.d.ts.map +0 -1
- package/lib/styles/radio.js.map +0 -1
- package/lib/styles/resize-observer.d.ts.map +0 -1
- package/lib/styles/resize-observer.js.map +0 -1
- package/lib/styles/scroll-container.d.ts.map +0 -1
- package/lib/styles/scroll-container.js.map +0 -1
- package/lib/styles/select-base.d.ts.map +0 -1
- package/lib/styles/select-base.js.map +0 -1
- package/lib/styles/select.d.ts.map +0 -1
- package/lib/styles/select.js.map +0 -1
- package/lib/styles/step.d.ts.map +0 -1
- package/lib/styles/step.js.map +0 -1
- package/lib/styles/switch.d.ts.map +0 -1
- package/lib/styles/switch.js.map +0 -1
- package/lib/styles/tab.d.ts.map +0 -1
- package/lib/styles/tab.js.map +0 -1
- package/lib/styles/tabs.d.ts.map +0 -1
- package/lib/styles/tabs.js.map +0 -1
- package/lib/styles/tag.d.ts.map +0 -1
- package/lib/styles/tag.js.map +0 -1
- package/lib/styles/textarea.d.ts.map +0 -1
- package/lib/styles/textarea.js.map +0 -1
- package/lib/styles/tooltip.d.ts.map +0 -1
- package/lib/styles/tooltip.js.map +0 -1
- package/lib/styles/wizard.d.ts.map +0 -1
- package/lib/styles/wizard.js.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/common.js.map +0 -1
- package/lib/utils/calendar-utils.d.ts.map +0 -1
- package/lib/utils/calendar-utils.js.map +0 -1
- package/lib/utils/custom-scrollbar.d.ts.map +0 -1
- package/lib/utils/custom-scrollbar.js.map +0 -1
- package/lib/utils/flavor-sheet.d.ts.map +0 -1
- package/lib/utils/flavor-sheet.js.map +0 -1
- package/lib/utils/icon-registry.d.ts.map +0 -1
- package/lib/utils/icon-registry.js.map +0 -1
- package/lib/utils/icons.d.ts.map +0 -1
- package/lib/utils/icons.js.map +0 -1
- package/lib/utils/loader-registry.d.ts.map +0 -1
- package/lib/utils/loader-registry.js.map +0 -1
- package/lib/utils/locale.d.ts.map +0 -1
- package/lib/utils/locale.js.map +0 -1
- package/lib/utils/mobile.d.ts.map +0 -1
- package/lib/utils/mobile.js.map +0 -1
- package/lib/utils/number-format.d.ts.map +0 -1
- package/lib/utils/number-format.js.map +0 -1
- package/lib/utils/parse-boolean.d.ts +0 -39
- package/lib/utils/parse-boolean.d.ts.map +0 -1
- package/lib/utils/parse-boolean.js +0 -58
- package/lib/utils/parse-boolean.js.map +0 -1
- package/lib/utils/positioning.d.ts.map +0 -1
- package/lib/utils/positioning.js.map +0 -1
- package/lib/utils/property-capture.d.ts.map +0 -1
- package/lib/utils/property-capture.js.map +0 -1
- package/lib/utils/property-manager.d.ts.map +0 -1
- package/lib/utils/property-manager.js.map +0 -1
- package/lib/utils/resize-observer.d.ts.map +0 -1
- package/lib/utils/resize-observer.js.map +0 -1
- package/lib/utils/scroll-lock.d.ts.map +0 -1
- package/lib/utils/scroll-lock.js.map +0 -1
- package/lib/utils/styles.d.ts.map +0 -1
- package/lib/utils/styles.js.map +0 -1
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js.map +0 -1
|
@@ -1,640 +1,470 @@
|
|
|
1
|
-
|
|
2
|
-
* ty-textarea - Enhanced textarea component with auto-resize functionality
|
|
3
|
-
*
|
|
4
|
-
* Features:
|
|
5
|
-
* - Auto-resize based on content
|
|
6
|
-
* - Form-associated custom element
|
|
7
|
-
* - Min/max height constraints
|
|
8
|
-
* - Size variants (xs, sm, md, lg, xl)
|
|
9
|
-
* - Validation states (error, required)
|
|
10
|
-
* - Manual resize control options
|
|
11
|
-
* - Accessibility support
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```html
|
|
15
|
-
* <!-- Basic usage -->
|
|
16
|
-
* <ty-textarea label="Description" placeholder="Enter details..."></ty-textarea>
|
|
17
|
-
*
|
|
18
|
-
* <!-- With validation -->
|
|
19
|
-
* <ty-textarea
|
|
20
|
-
* label="Bio"
|
|
21
|
-
* required
|
|
22
|
-
* error="Bio is required"
|
|
23
|
-
* size="lg">
|
|
24
|
-
* </ty-textarea>
|
|
25
|
-
*
|
|
26
|
-
* <!-- With height constraints -->
|
|
27
|
-
* <ty-textarea
|
|
28
|
-
* min-height="100px"
|
|
29
|
-
* max-height="300px"
|
|
30
|
-
* placeholder="Auto-resizing textarea">
|
|
31
|
-
* </ty-textarea>
|
|
32
|
-
*
|
|
33
|
-
* <!-- Manual resize control -->
|
|
34
|
-
* <ty-textarea resize="vertical"></ty-textarea>
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @fires {CustomEvent<{value: string, originalEvent: Event}>} input - Emitted on input
|
|
38
|
-
* @fires {CustomEvent<{value: string, originalEvent: Event}>} change - Emitted on change
|
|
39
|
-
*/
|
|
1
|
+
import { DEFAULT_SIZE } from '../types/common.js';
|
|
40
2
|
import { TyComponent } from '../base/ty-component.js';
|
|
41
3
|
import { ensureStyles } from '../utils/styles.js';
|
|
42
4
|
import { textareaStyles } from '../styles/textarea.js';
|
|
43
5
|
import { CustomScrollbar, isCustomScrollbarEnabled } from '../utils/custom-scrollbar.js';
|
|
44
6
|
import { customScrollbarStyles } from '../styles/custom-scrollbar.js';
|
|
45
|
-
/**
|
|
46
|
-
* Required icon SVG (matches input.ts)
|
|
47
|
-
*/
|
|
48
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>`;
|
|
49
8
|
export class TyTextarea extends TyComponent {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
existingTextarea.setAttribute('cols', this.cols);
|
|
422
|
-
// Apply height constraints
|
|
423
|
-
this.applyHeightConstraints(existingTextarea);
|
|
424
|
-
// Update error message
|
|
425
|
-
if (this.error) {
|
|
426
|
-
if (!existingError) {
|
|
427
|
-
const errorEl = document.createElement('div');
|
|
428
|
-
errorEl.className = 'error-message';
|
|
429
|
-
existingContainer.appendChild(errorEl);
|
|
430
|
-
}
|
|
431
|
-
const errorEl = root.querySelector('.error-message');
|
|
432
|
-
if (errorEl)
|
|
433
|
-
errorEl.textContent = this.error;
|
|
434
|
-
}
|
|
435
|
-
else if (existingError) {
|
|
436
|
-
existingError.remove();
|
|
437
|
-
}
|
|
438
|
-
// Setup dummy element and trigger resize
|
|
439
|
-
const dummyEl = this.setupDummyElement(existingTextarea);
|
|
440
|
-
setTimeout(() => this.resizeTextarea(existingTextarea, dummyEl), 0);
|
|
441
|
-
this._textareaEl = existingTextarea;
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
// Create new structure
|
|
445
|
-
const container = document.createElement('div');
|
|
446
|
-
container.className = 'textarea-container';
|
|
447
|
-
const labelEl = document.createElement('label');
|
|
448
|
-
labelEl.className = 'ty-field-label';
|
|
449
|
-
if (this.label) {
|
|
450
|
-
labelEl.innerHTML = this.label +
|
|
451
|
-
(this.required ? ` <span class="required-icon">${REQUIRED_ICON}</span>` : '');
|
|
452
|
-
labelEl.style.display = 'block';
|
|
453
|
-
}
|
|
454
|
-
else {
|
|
455
|
-
labelEl.style.display = 'none';
|
|
456
|
-
}
|
|
457
|
-
const textareaEl = document.createElement('textarea');
|
|
458
|
-
textareaEl.value = this.value || '';
|
|
459
|
-
textareaEl.placeholder = this.placeholder || '';
|
|
460
|
-
textareaEl.disabled = this.disabled;
|
|
461
|
-
textareaEl.required = this.required;
|
|
462
|
-
textareaEl.className = this.buildClassList();
|
|
463
|
-
if (this.label)
|
|
464
|
-
textareaEl.setAttribute('aria-label', this.label); // a11y: name the control
|
|
465
|
-
// Set name for form association
|
|
466
|
-
if (this.name) {
|
|
467
|
-
textareaEl.setAttribute('name', this.name);
|
|
468
|
-
}
|
|
469
|
-
// Set default or specified rows/cols
|
|
470
|
-
textareaEl.setAttribute('rows', this.rows || '3');
|
|
471
|
-
if (this.cols)
|
|
472
|
-
textareaEl.setAttribute('cols', this.cols);
|
|
473
|
-
// Apply height constraints
|
|
474
|
-
this.applyHeightConstraints(textareaEl);
|
|
475
|
-
// Setup event listeners
|
|
476
|
-
this.setupTextareaEvents(textareaEl);
|
|
477
|
-
// Build composer structure:
|
|
478
|
-
// .textarea-wrapper (border) > [.textarea-header > slot] · .textarea-scroll(textarea) · [.textarea-footer > slot]
|
|
479
|
-
const wrapperEl = document.createElement('div');
|
|
480
|
-
wrapperEl.className = 'textarea-wrapper';
|
|
481
|
-
const headerEl = document.createElement('div');
|
|
482
|
-
headerEl.className = 'textarea-header';
|
|
483
|
-
const headerSlot = document.createElement('slot');
|
|
484
|
-
headerSlot.setAttribute('name', 'header');
|
|
485
|
-
headerEl.appendChild(headerSlot);
|
|
486
|
-
// Scroll region wraps only the textarea so the custom scrollbar can't
|
|
487
|
-
// overlap header/footer.
|
|
488
|
-
const scrollEl = document.createElement('div');
|
|
489
|
-
scrollEl.className = 'textarea-scroll';
|
|
490
|
-
scrollEl.appendChild(textareaEl);
|
|
491
|
-
const footerEl = document.createElement('div');
|
|
492
|
-
footerEl.className = 'textarea-footer';
|
|
493
|
-
const footerSlot = document.createElement('slot');
|
|
494
|
-
footerSlot.setAttribute('name', 'footer');
|
|
495
|
-
footerEl.appendChild(footerSlot);
|
|
496
|
-
wrapperEl.appendChild(headerEl);
|
|
497
|
-
wrapperEl.appendChild(scrollEl);
|
|
498
|
-
wrapperEl.appendChild(footerEl);
|
|
499
|
-
// Collapse empty slots (no padding/divider) by toggling .has-content.
|
|
500
|
-
// slotchange fires on initial assignment too.
|
|
501
|
-
const syncSlot = (slot, region) => {
|
|
502
|
-
const update = () => region.classList.toggle('has-content', slot.assignedNodes({ flatten: true }).length > 0);
|
|
503
|
-
slot.addEventListener('slotchange', update);
|
|
504
|
-
update();
|
|
505
|
-
};
|
|
506
|
-
syncSlot(headerSlot, headerEl);
|
|
507
|
-
syncSlot(footerSlot, footerEl);
|
|
508
|
-
container.appendChild(labelEl);
|
|
509
|
-
container.appendChild(wrapperEl);
|
|
510
|
-
// Add error message if present
|
|
511
|
-
if (this.error) {
|
|
512
|
-
const errorEl = document.createElement('div');
|
|
513
|
-
errorEl.className = 'error-message';
|
|
514
|
-
errorEl.textContent = this.error;
|
|
515
|
-
container.appendChild(errorEl);
|
|
516
|
-
}
|
|
517
|
-
root.appendChild(container);
|
|
518
|
-
// Setup dummy element and trigger initial resize
|
|
519
|
-
const dummyEl = this.setupDummyElement(textareaEl);
|
|
520
|
-
setTimeout(() => this.resizeTextarea(textareaEl, dummyEl), 0);
|
|
521
|
-
this._textareaEl = textareaEl;
|
|
522
|
-
}
|
|
523
|
-
// Reflect constraint validation to the owning <form>. Without this `required`
|
|
524
|
-
// is cosmetic — the inner shadow <textarea> can't block the outer form.
|
|
525
|
-
this.updateValidity();
|
|
526
|
-
}
|
|
527
|
-
/** required + empty => valueMissing; otherwise valid. Disabled fields are
|
|
528
|
-
* barred from constraint validation. */
|
|
529
|
-
updateValidity() {
|
|
530
|
-
const ta = this.shadowRoot?.querySelector('textarea');
|
|
531
|
-
if (this.disabled) {
|
|
532
|
-
this._internals.setValidity({});
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
const current = ta ? ta.value : String(this.value ?? '');
|
|
536
|
-
if (this.required && current.trim() === '') {
|
|
537
|
-
this._internals.setValidity({ valueMissing: true }, 'Please fill out this field', ta ?? undefined);
|
|
538
|
-
}
|
|
539
|
-
else {
|
|
540
|
-
this._internals.setValidity({});
|
|
541
|
-
}
|
|
542
|
-
}
|
|
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.emitValueEvents(e);
|
|
23
|
+
};
|
|
24
|
+
this.handleFocusEvent = () => {
|
|
25
|
+
this._isFocused = true;
|
|
26
|
+
};
|
|
27
|
+
this.handleBlurEvent = () => {
|
|
28
|
+
this._isFocused = false;
|
|
29
|
+
};
|
|
30
|
+
const shadow = this.shadowRoot;
|
|
31
|
+
ensureStyles(shadow, { css: textareaStyles, id: 'ty-textarea' });
|
|
32
|
+
if (isCustomScrollbarEnabled()) {
|
|
33
|
+
ensureStyles(shadow, { css: customScrollbarStyles, id: 'ty-custom-scrollbar' });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
onConnect() {
|
|
37
|
+
}
|
|
38
|
+
onDisconnect() {
|
|
39
|
+
this._destroyScrollbar();
|
|
40
|
+
if (this._textareaEl) {
|
|
41
|
+
const newTextarea = this._textareaEl.cloneNode(true);
|
|
42
|
+
this._textareaEl.parentNode?.replaceChild(newTextarea, this._textareaEl);
|
|
43
|
+
this._textareaEl = null;
|
|
44
|
+
}
|
|
45
|
+
this._dummyEl = null;
|
|
46
|
+
}
|
|
47
|
+
onPropertiesChanged(changes) {
|
|
48
|
+
}
|
|
49
|
+
getFormValue() {
|
|
50
|
+
return this.getProperty('value') || null;
|
|
51
|
+
}
|
|
52
|
+
get value() { return this.getProperty('value'); }
|
|
53
|
+
set value(v) { this.setProperty('value', v); }
|
|
54
|
+
get name() { return this.getProperty('name'); }
|
|
55
|
+
set name(v) { this.setProperty('name', v); }
|
|
56
|
+
get placeholder() { return this.getProperty('placeholder'); }
|
|
57
|
+
set placeholder(v) { this.setProperty('placeholder', v); }
|
|
58
|
+
get label() { return this.getProperty('label'); }
|
|
59
|
+
set label(v) { this.setProperty('label', v); }
|
|
60
|
+
get disabled() { return this.getProperty('disabled'); }
|
|
61
|
+
set disabled(v) { this.setProperty('disabled', v); }
|
|
62
|
+
get required() { return this.getProperty('required'); }
|
|
63
|
+
set required(v) { this.setProperty('required', v); }
|
|
64
|
+
get error() { return this.getProperty('error'); }
|
|
65
|
+
set error(v) { this.setProperty('error', v); }
|
|
66
|
+
get size() {
|
|
67
|
+
return this.getProperty('size');
|
|
68
|
+
}
|
|
69
|
+
set size(v) {
|
|
70
|
+
this.setProperty('size', v);
|
|
71
|
+
}
|
|
72
|
+
get rows() { return this.getProperty('rows'); }
|
|
73
|
+
set rows(v) { this.setProperty('rows', v); }
|
|
74
|
+
get cols() { return this.getProperty('cols'); }
|
|
75
|
+
set cols(v) { this.setProperty('cols', v); }
|
|
76
|
+
get resize() {
|
|
77
|
+
return this.getProperty('resize');
|
|
78
|
+
}
|
|
79
|
+
set resize(v) {
|
|
80
|
+
this.setProperty('resize', v);
|
|
81
|
+
}
|
|
82
|
+
get minHeight() { return this.getProperty('minHeight'); }
|
|
83
|
+
set minHeight(v) { this.setProperty('minHeight', v); }
|
|
84
|
+
get maxHeight() { return this.getProperty('maxHeight'); }
|
|
85
|
+
set maxHeight(v) { this.setProperty('maxHeight', v); }
|
|
86
|
+
getFontStyle(el) {
|
|
87
|
+
const computedStyle = window.getComputedStyle(el);
|
|
88
|
+
return {
|
|
89
|
+
fontFamily: computedStyle.fontFamily,
|
|
90
|
+
fontSize: computedStyle.fontSize,
|
|
91
|
+
fontWeight: computedStyle.fontWeight,
|
|
92
|
+
lineHeight: computedStyle.lineHeight,
|
|
93
|
+
letterSpacing: computedStyle.letterSpacing,
|
|
94
|
+
fontStyle: computedStyle.fontStyle
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
getSpacingStyle(el) {
|
|
98
|
+
const computedStyle = window.getComputedStyle(el);
|
|
99
|
+
return {
|
|
100
|
+
padding: computedStyle.padding,
|
|
101
|
+
paddingTop: computedStyle.paddingTop,
|
|
102
|
+
paddingRight: computedStyle.paddingRight,
|
|
103
|
+
paddingBottom: computedStyle.paddingBottom,
|
|
104
|
+
paddingLeft: computedStyle.paddingLeft,
|
|
105
|
+
margin: computedStyle.margin,
|
|
106
|
+
borderWidth: computedStyle.borderWidth
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
setupDummyElement(textareaEl) {
|
|
110
|
+
const root = this.shadowRoot;
|
|
111
|
+
const existingDummy = root.querySelector('.textarea-dummy');
|
|
112
|
+
if (existingDummy) {
|
|
113
|
+
existingDummy.remove();
|
|
114
|
+
}
|
|
115
|
+
const dummyEl = document.createElement('pre');
|
|
116
|
+
const fontStyle = this.getFontStyle(textareaEl);
|
|
117
|
+
const spacingStyle = this.getSpacingStyle(textareaEl);
|
|
118
|
+
dummyEl.className = 'textarea-dummy';
|
|
119
|
+
const style = dummyEl.style;
|
|
120
|
+
style.position = 'absolute';
|
|
121
|
+
style.top = '0';
|
|
122
|
+
style.left = '0';
|
|
123
|
+
style.visibility = 'hidden';
|
|
124
|
+
style.whiteSpace = 'pre-wrap';
|
|
125
|
+
style.wordBreak = 'break-word';
|
|
126
|
+
style.boxSizing = 'border-box';
|
|
127
|
+
style.overflow = 'hidden';
|
|
128
|
+
style.pointerEvents = 'none';
|
|
129
|
+
Object.entries(fontStyle).forEach(([prop, value]) => {
|
|
130
|
+
;
|
|
131
|
+
style[prop] = value;
|
|
132
|
+
});
|
|
133
|
+
Object.entries(spacingStyle).forEach(([prop, value]) => {
|
|
134
|
+
;
|
|
135
|
+
style[prop] = value;
|
|
136
|
+
});
|
|
137
|
+
root.appendChild(dummyEl);
|
|
138
|
+
this._dummyEl = dummyEl;
|
|
139
|
+
return dummyEl;
|
|
140
|
+
}
|
|
141
|
+
resizeTextarea(textareaEl, dummyEl) {
|
|
142
|
+
if (!textareaEl || !dummyEl)
|
|
143
|
+
return;
|
|
144
|
+
const value = this.value;
|
|
145
|
+
const placeholder = this.placeholder;
|
|
146
|
+
const content = (value === '' && placeholder) ? placeholder : value + ' ';
|
|
147
|
+
const currentHeight = textareaEl.clientHeight;
|
|
148
|
+
dummyEl.textContent = content;
|
|
149
|
+
dummyEl.style.width = `${textareaEl.clientWidth}px`;
|
|
150
|
+
const measuredHeight = dummyEl.scrollHeight;
|
|
151
|
+
const minHeight = this.minHeight ? parseInt(this.minHeight.replace('px', ''), 10) : null;
|
|
152
|
+
const maxHeight = this.maxHeight ? parseInt(this.maxHeight.replace('px', ''), 10) : null;
|
|
153
|
+
let constrainedHeight = measuredHeight;
|
|
154
|
+
if (minHeight !== null)
|
|
155
|
+
constrainedHeight = Math.max(constrainedHeight, minHeight);
|
|
156
|
+
if (maxHeight !== null)
|
|
157
|
+
constrainedHeight = Math.min(constrainedHeight, maxHeight);
|
|
158
|
+
if (Math.abs(constrainedHeight - currentHeight) > 2) {
|
|
159
|
+
textareaEl.style.height = `${constrainedHeight}px`;
|
|
160
|
+
const needsScroll = maxHeight !== null && measuredHeight >= maxHeight;
|
|
161
|
+
if (needsScroll) {
|
|
162
|
+
textareaEl.style.overflowY = 'auto';
|
|
163
|
+
this._setupScrollbar(textareaEl);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
textareaEl.style.overflowY = 'hidden';
|
|
167
|
+
this._destroyScrollbar();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
this._scrollbar?.update();
|
|
171
|
+
}
|
|
172
|
+
_setupScrollbar(textareaEl) {
|
|
173
|
+
if (this._scrollbar || !isCustomScrollbarEnabled())
|
|
174
|
+
return;
|
|
175
|
+
textareaEl.style.scrollbarWidth = 'none';
|
|
176
|
+
this.setAttribute('data-custom-scroll', '');
|
|
177
|
+
this._scrollbar = new CustomScrollbar(textareaEl, {
|
|
178
|
+
vertical: true,
|
|
179
|
+
horizontal: false
|
|
180
|
+
});
|
|
181
|
+
const scroll = this.shadowRoot.querySelector('.textarea-scroll');
|
|
182
|
+
if (scroll && this._scrollbar.trackY) {
|
|
183
|
+
scroll.appendChild(this._scrollbar.trackY);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
_destroyScrollbar() {
|
|
187
|
+
if (!this._scrollbar)
|
|
188
|
+
return;
|
|
189
|
+
this._scrollbar.trackY?.remove();
|
|
190
|
+
this._scrollbar.destroy();
|
|
191
|
+
this._scrollbar = null;
|
|
192
|
+
this.removeAttribute('data-custom-scroll');
|
|
193
|
+
if (this._textareaEl) {
|
|
194
|
+
this._textareaEl.style.scrollbarWidth = '';
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
emitValueEvents(originalEvent) {
|
|
198
|
+
const value = this.value;
|
|
199
|
+
this._internals.setFormValue(value || '');
|
|
200
|
+
this.updateValidity();
|
|
201
|
+
const data = {
|
|
202
|
+
bubbles: true,
|
|
203
|
+
composed: true,
|
|
204
|
+
detail: {
|
|
205
|
+
value,
|
|
206
|
+
originalEvent
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
setTimeout(() => {
|
|
210
|
+
this.dispatchEvent(new CustomEvent('input', data));
|
|
211
|
+
this.dispatchEvent(new CustomEvent('change', data));
|
|
212
|
+
}, 0);
|
|
213
|
+
}
|
|
214
|
+
buildClassList() {
|
|
215
|
+
const classes = [this.size];
|
|
216
|
+
if (this.disabled)
|
|
217
|
+
classes.push('disabled');
|
|
218
|
+
if (this.required)
|
|
219
|
+
classes.push('required');
|
|
220
|
+
if (this.error)
|
|
221
|
+
classes.push('error');
|
|
222
|
+
if (this.resize !== 'none')
|
|
223
|
+
classes.push(`resize-${this.resize}`);
|
|
224
|
+
const customClass = this.getAttribute('class');
|
|
225
|
+
if (customClass)
|
|
226
|
+
classes.push(customClass);
|
|
227
|
+
return classes.join(' ');
|
|
228
|
+
}
|
|
229
|
+
applyHeightConstraints(textareaEl) {
|
|
230
|
+
if (this.minHeight) {
|
|
231
|
+
textareaEl.style.minHeight = this.minHeight;
|
|
232
|
+
}
|
|
233
|
+
if (this.maxHeight) {
|
|
234
|
+
textareaEl.style.maxHeight = this.maxHeight;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
setupTextareaEvents(textareaEl) {
|
|
238
|
+
textareaEl.addEventListener('input', this.handleInputEvent);
|
|
239
|
+
textareaEl.addEventListener('change', this.handleInputEvent);
|
|
240
|
+
textareaEl.addEventListener('focus', this.handleFocusEvent);
|
|
241
|
+
textareaEl.addEventListener('blur', this.handleBlurEvent);
|
|
242
|
+
}
|
|
243
|
+
render() {
|
|
244
|
+
const root = this.shadowRoot;
|
|
245
|
+
const existingContainer = root.querySelector('.textarea-container');
|
|
246
|
+
const existingLabel = root.querySelector('label');
|
|
247
|
+
const existingTextarea = root.querySelector('textarea');
|
|
248
|
+
const existingError = root.querySelector('.error-message');
|
|
249
|
+
if (existingContainer && existingTextarea) {
|
|
250
|
+
if (this.label) {
|
|
251
|
+
if (existingLabel) {
|
|
252
|
+
existingLabel.innerHTML = this.label +
|
|
253
|
+
(this.required ? ` <span class="required-icon">${REQUIRED_ICON}</span>` : '');
|
|
254
|
+
existingLabel.style.display = 'block';
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else if (existingLabel) {
|
|
258
|
+
existingLabel.style.display = 'none';
|
|
259
|
+
}
|
|
260
|
+
existingTextarea.value = this.value || '';
|
|
261
|
+
existingTextarea.placeholder = this.placeholder || '';
|
|
262
|
+
existingTextarea.disabled = this.disabled;
|
|
263
|
+
existingTextarea.required = this.required;
|
|
264
|
+
existingTextarea.className = this.buildClassList();
|
|
265
|
+
if (this.label)
|
|
266
|
+
existingTextarea.setAttribute('aria-label', this.label);
|
|
267
|
+
else
|
|
268
|
+
existingTextarea.removeAttribute('aria-label');
|
|
269
|
+
if (this.name) {
|
|
270
|
+
existingTextarea.setAttribute('name', this.name);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
existingTextarea.removeAttribute('name');
|
|
274
|
+
}
|
|
275
|
+
if (this.rows)
|
|
276
|
+
existingTextarea.setAttribute('rows', this.rows);
|
|
277
|
+
if (this.cols)
|
|
278
|
+
existingTextarea.setAttribute('cols', this.cols);
|
|
279
|
+
this.applyHeightConstraints(existingTextarea);
|
|
280
|
+
if (this.error) {
|
|
281
|
+
if (!existingError) {
|
|
282
|
+
const errorEl = document.createElement('div');
|
|
283
|
+
errorEl.className = 'error-message';
|
|
284
|
+
existingContainer.appendChild(errorEl);
|
|
285
|
+
}
|
|
286
|
+
const errorEl = root.querySelector('.error-message');
|
|
287
|
+
if (errorEl)
|
|
288
|
+
errorEl.textContent = this.error;
|
|
289
|
+
}
|
|
290
|
+
else if (existingError) {
|
|
291
|
+
existingError.remove();
|
|
292
|
+
}
|
|
293
|
+
const dummyEl = this.setupDummyElement(existingTextarea);
|
|
294
|
+
setTimeout(() => this.resizeTextarea(existingTextarea, dummyEl), 0);
|
|
295
|
+
this._textareaEl = existingTextarea;
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
const container = document.createElement('div');
|
|
299
|
+
container.className = 'textarea-container';
|
|
300
|
+
const labelEl = document.createElement('label');
|
|
301
|
+
labelEl.className = 'ty-field-label';
|
|
302
|
+
if (this.label) {
|
|
303
|
+
labelEl.innerHTML = this.label +
|
|
304
|
+
(this.required ? ` <span class="required-icon">${REQUIRED_ICON}</span>` : '');
|
|
305
|
+
labelEl.style.display = 'block';
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
labelEl.style.display = 'none';
|
|
309
|
+
}
|
|
310
|
+
const textareaEl = document.createElement('textarea');
|
|
311
|
+
textareaEl.value = this.value || '';
|
|
312
|
+
textareaEl.placeholder = this.placeholder || '';
|
|
313
|
+
textareaEl.disabled = this.disabled;
|
|
314
|
+
textareaEl.required = this.required;
|
|
315
|
+
textareaEl.className = this.buildClassList();
|
|
316
|
+
if (this.label)
|
|
317
|
+
textareaEl.setAttribute('aria-label', this.label);
|
|
318
|
+
if (this.name) {
|
|
319
|
+
textareaEl.setAttribute('name', this.name);
|
|
320
|
+
}
|
|
321
|
+
textareaEl.setAttribute('rows', this.rows || '3');
|
|
322
|
+
if (this.cols)
|
|
323
|
+
textareaEl.setAttribute('cols', this.cols);
|
|
324
|
+
this.applyHeightConstraints(textareaEl);
|
|
325
|
+
this.setupTextareaEvents(textareaEl);
|
|
326
|
+
const wrapperEl = document.createElement('div');
|
|
327
|
+
wrapperEl.className = 'textarea-wrapper';
|
|
328
|
+
const headerEl = document.createElement('div');
|
|
329
|
+
headerEl.className = 'textarea-header';
|
|
330
|
+
const headerSlot = document.createElement('slot');
|
|
331
|
+
headerSlot.setAttribute('name', 'header');
|
|
332
|
+
headerEl.appendChild(headerSlot);
|
|
333
|
+
const scrollEl = document.createElement('div');
|
|
334
|
+
scrollEl.className = 'textarea-scroll';
|
|
335
|
+
scrollEl.appendChild(textareaEl);
|
|
336
|
+
const footerEl = document.createElement('div');
|
|
337
|
+
footerEl.className = 'textarea-footer';
|
|
338
|
+
const footerSlot = document.createElement('slot');
|
|
339
|
+
footerSlot.setAttribute('name', 'footer');
|
|
340
|
+
footerEl.appendChild(footerSlot);
|
|
341
|
+
wrapperEl.appendChild(headerEl);
|
|
342
|
+
wrapperEl.appendChild(scrollEl);
|
|
343
|
+
wrapperEl.appendChild(footerEl);
|
|
344
|
+
const syncSlot = (slot, region) => {
|
|
345
|
+
const update = () => region.classList.toggle('has-content', slot.assignedNodes({ flatten: true }).length > 0);
|
|
346
|
+
slot.addEventListener('slotchange', update);
|
|
347
|
+
update();
|
|
348
|
+
};
|
|
349
|
+
syncSlot(headerSlot, headerEl);
|
|
350
|
+
syncSlot(footerSlot, footerEl);
|
|
351
|
+
container.appendChild(labelEl);
|
|
352
|
+
container.appendChild(wrapperEl);
|
|
353
|
+
if (this.error) {
|
|
354
|
+
const errorEl = document.createElement('div');
|
|
355
|
+
errorEl.className = 'error-message';
|
|
356
|
+
errorEl.textContent = this.error;
|
|
357
|
+
container.appendChild(errorEl);
|
|
358
|
+
}
|
|
359
|
+
root.appendChild(container);
|
|
360
|
+
const dummyEl = this.setupDummyElement(textareaEl);
|
|
361
|
+
setTimeout(() => this.resizeTextarea(textareaEl, dummyEl), 0);
|
|
362
|
+
this._textareaEl = textareaEl;
|
|
363
|
+
}
|
|
364
|
+
this.updateValidity();
|
|
365
|
+
}
|
|
366
|
+
updateValidity() {
|
|
367
|
+
const ta = this.shadowRoot?.querySelector('textarea');
|
|
368
|
+
if (this.disabled) {
|
|
369
|
+
this._internals.setValidity({});
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
const current = ta ? ta.value : String(this.value ?? '');
|
|
373
|
+
if (this.required && current.trim() === '') {
|
|
374
|
+
this._internals.setValidity({ valueMissing: true }, 'Please fill out this field', ta ?? undefined);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this._internals.setValidity({});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
543
380
|
}
|
|
544
381
|
TyTextarea.formAssociated = true;
|
|
545
|
-
// ============================================================================
|
|
546
|
-
// PROPERTY CONFIGURATION - Declarative property lifecycle
|
|
547
|
-
// ============================================================================
|
|
548
382
|
TyTextarea.properties = {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
default: ''
|
|
634
|
-
}
|
|
383
|
+
value: {
|
|
384
|
+
type: 'string',
|
|
385
|
+
visual: true,
|
|
386
|
+
formValue: true,
|
|
387
|
+
emitChange: true,
|
|
388
|
+
default: ''
|
|
389
|
+
},
|
|
390
|
+
name: {
|
|
391
|
+
type: 'string',
|
|
392
|
+
default: ''
|
|
393
|
+
},
|
|
394
|
+
placeholder: {
|
|
395
|
+
type: 'string',
|
|
396
|
+
visual: true,
|
|
397
|
+
default: ''
|
|
398
|
+
},
|
|
399
|
+
label: {
|
|
400
|
+
type: 'string',
|
|
401
|
+
visual: true,
|
|
402
|
+
default: ''
|
|
403
|
+
},
|
|
404
|
+
disabled: {
|
|
405
|
+
type: 'boolean',
|
|
406
|
+
visual: true,
|
|
407
|
+
default: false
|
|
408
|
+
},
|
|
409
|
+
required: {
|
|
410
|
+
type: 'boolean',
|
|
411
|
+
visual: true,
|
|
412
|
+
default: false
|
|
413
|
+
},
|
|
414
|
+
error: {
|
|
415
|
+
type: 'string',
|
|
416
|
+
visual: true,
|
|
417
|
+
default: ''
|
|
418
|
+
},
|
|
419
|
+
size: {
|
|
420
|
+
type: 'string',
|
|
421
|
+
visual: true,
|
|
422
|
+
default: DEFAULT_SIZE,
|
|
423
|
+
validate: (v) => ['xs', 'sm', 'md', 'lg', 'xl'].includes(v),
|
|
424
|
+
coerce: (v) => {
|
|
425
|
+
if (!['xs', 'sm', 'md', 'lg', 'xl'].includes(v)) {
|
|
426
|
+
console.warn(`[ty-textarea] Invalid size '${v}'. Using '${DEFAULT_SIZE}'.`);
|
|
427
|
+
return DEFAULT_SIZE;
|
|
428
|
+
}
|
|
429
|
+
return v;
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
rows: {
|
|
433
|
+
type: 'string',
|
|
434
|
+
visual: true,
|
|
435
|
+
default: '3',
|
|
436
|
+
coerce: (v) => String(v)
|
|
437
|
+
},
|
|
438
|
+
cols: {
|
|
439
|
+
type: 'string',
|
|
440
|
+
visual: true,
|
|
441
|
+
default: '',
|
|
442
|
+
coerce: (v) => v ? String(v) : ''
|
|
443
|
+
},
|
|
444
|
+
resize: {
|
|
445
|
+
type: 'string',
|
|
446
|
+
visual: true,
|
|
447
|
+
default: 'none',
|
|
448
|
+
validate: (v) => ['none', 'both', 'horizontal', 'vertical'].includes(v),
|
|
449
|
+
coerce: (v) => {
|
|
450
|
+
if (!['none', 'both', 'horizontal', 'vertical'].includes(v)) {
|
|
451
|
+
console.warn(`[ty-textarea] Invalid resize '${v}'. Using 'none'.`);
|
|
452
|
+
return 'none';
|
|
453
|
+
}
|
|
454
|
+
return v;
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
minHeight: {
|
|
458
|
+
type: 'string',
|
|
459
|
+
visual: true,
|
|
460
|
+
default: ''
|
|
461
|
+
},
|
|
462
|
+
maxHeight: {
|
|
463
|
+
type: 'string',
|
|
464
|
+
visual: true,
|
|
465
|
+
default: ''
|
|
466
|
+
}
|
|
635
467
|
};
|
|
636
|
-
// Register the component
|
|
637
468
|
if (!customElements.get('ty-textarea')) {
|
|
638
|
-
|
|
469
|
+
customElements.define('ty-textarea', TyTextarea);
|
|
639
470
|
}
|
|
640
|
-
//# sourceMappingURL=textarea.js.map
|