tyrell-components 1.0.0-TC52 → 1.0.0-TC53
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/css/tyrell-theme.css +25 -2
- package/css/tyrell.css +4 -0
- package/dist/tyrell-colors-static.css +1 -316
- package/dist/tyrell-theme.css +1 -1443
- package/dist/tyrell.css +1 -1390
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.js +196 -196
- package/lib/components/button.d.ts +1 -1
- package/lib/components/button.js +260 -259
- package/lib/components/calendar-month.d.ts +2 -2
- package/lib/components/calendar-month.js +426 -416
- package/lib/components/calendar-navigation.js +238 -238
- package/lib/components/calendar.js +605 -602
- package/lib/components/checkbox.d.ts +1 -1
- package/lib/components/checkbox.js +273 -272
- package/lib/components/copy.d.ts +1 -1
- package/lib/components/copy.js +279 -278
- package/lib/components/date-picker.d.ts +1 -1
- package/lib/components/date-picker.js +1103 -1108
- package/lib/components/file-upload.js +404 -404
- package/lib/components/icon.js +141 -141
- package/lib/components/input.d.ts +1 -1
- package/lib/components/input.js +593 -596
- package/lib/components/modal.js +319 -319
- package/lib/components/option.js +167 -167
- package/lib/components/popup.js +233 -233
- package/lib/components/radio.d.ts +2 -2
- package/lib/components/radio.js +407 -406
- package/lib/components/resize-observer.js +67 -67
- package/lib/components/scroll-container.js +294 -294
- package/lib/components/select.d.ts +1 -1
- package/lib/components/select.js +1524 -1532
- package/lib/components/selected-tags.js +184 -184
- package/lib/components/step.js +62 -62
- package/lib/components/switch.d.ts +1 -1
- package/lib/components/switch.js +214 -213
- package/lib/components/tab.js +62 -62
- package/lib/components/tabs.js +507 -507
- package/lib/components/tag.d.ts +1 -1
- package/lib/components/tag.js +236 -235
- package/lib/components/textarea.d.ts +1 -1
- package/lib/components/textarea.js +457 -456
- package/lib/components/tooltip.js +283 -283
- package/lib/components/wizard.js +384 -384
- package/lib/icons/heroicons/micro.js +392 -392
- package/lib/icons/heroicons/mini.js +382 -382
- package/lib/icons/heroicons/outline.js +337 -337
- package/lib/icons/heroicons/solid.js +407 -407
- package/lib/icons/lucide.js +22843 -22843
- package/lib/icons/material/filled.js +9653 -9653
- package/lib/icons/material/outlined.js +10271 -10271
- package/lib/icons/material/round.js +10495 -10495
- package/lib/icons/material/sharp.js +9905 -9905
- package/lib/icons/material/two-tone.js +12792 -12792
- package/lib/index.js +21 -21
- package/lib/styles/button.js +176 -288
- package/lib/styles/calendar-month.js +123 -183
- package/lib/styles/calendar-navigation.js +60 -79
- package/lib/styles/calendar.js +8 -9
- package/lib/styles/checkbox.js +45 -72
- package/lib/styles/copy.js +67 -91
- package/lib/styles/custom-scrollbar.js +80 -100
- package/lib/styles/date-picker.js +261 -331
- package/lib/styles/field-size.d.ts +6 -0
- package/lib/styles/field-size.js +91 -0
- package/lib/styles/file-upload.js +139 -169
- package/lib/styles/icon.js +92 -156
- package/lib/styles/input.js +125 -241
- package/lib/styles/modal.js +67 -102
- package/lib/styles/option.d.ts +1 -1
- package/lib/styles/option.js +47 -67
- package/lib/styles/popup.js +34 -65
- package/lib/styles/radio.js +69 -96
- package/lib/styles/resize-observer.js +2 -5
- package/lib/styles/scroll-container.js +100 -130
- package/lib/styles/select-base.js +525 -778
- package/lib/styles/select.js +140 -228
- package/lib/styles/step.js +22 -29
- package/lib/styles/switch.js +34 -55
- package/lib/styles/tab.js +22 -29
- package/lib/styles/tabs.js +171 -252
- package/lib/styles/tag.js +135 -188
- package/lib/styles/textarea.d.ts +1 -1
- package/lib/styles/textarea.js +205 -271
- package/lib/styles/tooltip.js +3 -3
- package/lib/styles/wizard.js +170 -226
- package/lib/types/common.d.ts +2 -0
- package/lib/types/common.js +6 -5
- package/lib/utils/calendar-utils.js +100 -100
- package/lib/utils/custom-scrollbar.js +272 -272
- package/lib/utils/flavor-sheet.js +14 -14
- package/lib/utils/icon-registry.js +127 -127
- package/lib/utils/loader-registry.js +3 -3
- package/lib/utils/locale.js +34 -34
- package/lib/utils/mobile.js +1 -1
- package/lib/utils/number-format.js +54 -54
- package/lib/utils/positioning.js +212 -212
- package/lib/utils/property-capture.js +36 -36
- package/lib/utils/property-manager.js +125 -125
- package/lib/utils/resize-observer.js +23 -23
- package/lib/utils/scroll-lock.js +57 -57
- package/lib/utils/styles.js +17 -17
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +4 -4
package/lib/components/copy.js
CHANGED
|
@@ -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 { syncCustomFlavorSheet } from '../utils/flavor-sheet.js';
|
|
@@ -8,289 +9,289 @@ const CHECK_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="24" heigh
|
|
|
8
9
|
const ERROR_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`;
|
|
9
10
|
import { REQUIRED_ICON_SVG } from '../utils/icons.js';
|
|
10
11
|
export class TyCopy extends TyComponent {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this._copyTimeout = null;
|
|
15
|
+
this._showingSuccess = false;
|
|
16
|
+
this._customFlavorSheet = null;
|
|
17
|
+
ensureStyles(this.shadowRoot, { css: inputStyles, id: 'ty-input' });
|
|
18
|
+
ensureStyles(this.shadowRoot, { css: copyStyles, id: 'ty-copy' });
|
|
19
|
+
}
|
|
20
|
+
onConnect() {
|
|
21
|
+
this._syncCustomFlavor();
|
|
22
|
+
}
|
|
23
|
+
_syncCustomFlavor() {
|
|
24
|
+
this._customFlavorSheet = syncCustomFlavorSheet(this.shadowRoot, this._customFlavorSheet, this.flavor, ({ base }) => copyCustomFlavorCss(base));
|
|
25
|
+
}
|
|
26
|
+
onDisconnect() {
|
|
27
|
+
if (this._copyTimeout !== null) {
|
|
28
|
+
clearTimeout(this._copyTimeout);
|
|
29
|
+
this._copyTimeout = null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
onPropertiesChanged(changes) {
|
|
33
|
+
if (changes.some((c) => c.name === 'flavor')) {
|
|
34
|
+
this._syncCustomFlavor();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
buildClassList() {
|
|
38
|
+
const classes = [];
|
|
39
|
+
if (this.disabled)
|
|
40
|
+
classes.push('disabled');
|
|
41
|
+
if (this.required)
|
|
42
|
+
classes.push('required');
|
|
43
|
+
return classes.join(' ');
|
|
44
|
+
}
|
|
45
|
+
async copyToClipboard() {
|
|
46
|
+
if (this.disabled || !this.value)
|
|
47
|
+
return;
|
|
48
|
+
try {
|
|
49
|
+
await navigator.clipboard.writeText(this.value);
|
|
50
|
+
this.dispatchEvent(new CustomEvent('copy-success', {
|
|
51
|
+
detail: { value: this.value },
|
|
52
|
+
bubbles: true,
|
|
53
|
+
composed: true
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
try {
|
|
58
|
+
const textarea = document.createElement('textarea');
|
|
59
|
+
textarea.value = this.value;
|
|
60
|
+
textarea.style.position = 'fixed';
|
|
61
|
+
textarea.style.opacity = '0';
|
|
62
|
+
document.body.appendChild(textarea);
|
|
63
|
+
textarea.select();
|
|
64
|
+
document.execCommand('copy');
|
|
65
|
+
document.body.removeChild(textarea);
|
|
66
|
+
this.dispatchEvent(new CustomEvent('copy-success', {
|
|
67
|
+
detail: { value: this.value },
|
|
68
|
+
bubbles: true,
|
|
69
|
+
composed: true
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
catch (fallbackErr) {
|
|
73
|
+
console.error('[ty-copy] Failed to copy:', fallbackErr);
|
|
74
|
+
this.dispatchEvent(new CustomEvent('copy-error', {
|
|
75
|
+
detail: { error: fallbackErr },
|
|
76
|
+
bubbles: true,
|
|
77
|
+
composed: true
|
|
78
|
+
}));
|
|
79
|
+
this.showCopyError();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
this.showCopySuccess();
|
|
84
|
+
}
|
|
85
|
+
showCopySuccess() {
|
|
86
|
+
if (this._copyTimeout !== null) {
|
|
87
|
+
clearTimeout(this._copyTimeout);
|
|
88
|
+
}
|
|
89
|
+
this._showingSuccess = true;
|
|
90
|
+
const copyButton = this.shadowRoot.querySelector('.copy-button');
|
|
91
|
+
if (copyButton) {
|
|
92
|
+
copyButton.classList.add('success');
|
|
93
|
+
copyButton.innerHTML = CHECK_ICON_SVG;
|
|
94
|
+
copyButton.setAttribute('aria-label', 'Copied!');
|
|
95
|
+
}
|
|
96
|
+
this._copyTimeout = window.setTimeout(() => {
|
|
97
|
+
this._showingSuccess = false;
|
|
98
|
+
const btn = this.shadowRoot.querySelector('.copy-button');
|
|
99
|
+
if (btn) {
|
|
100
|
+
btn.classList.remove('success');
|
|
101
|
+
btn.innerHTML = COPY_ICON_SVG;
|
|
102
|
+
btn.setAttribute('aria-label', 'Copy to clipboard');
|
|
103
|
+
}
|
|
104
|
+
this._copyTimeout = null;
|
|
105
|
+
}, 2000);
|
|
106
|
+
}
|
|
107
|
+
showCopyError() {
|
|
108
|
+
if (this._copyTimeout !== null) {
|
|
109
|
+
clearTimeout(this._copyTimeout);
|
|
110
|
+
}
|
|
111
|
+
this._showingSuccess = false;
|
|
112
|
+
const copyButton = this.shadowRoot.querySelector('.copy-button');
|
|
113
|
+
if (copyButton) {
|
|
114
|
+
copyButton.classList.add('error');
|
|
115
|
+
copyButton.innerHTML = ERROR_ICON_SVG;
|
|
116
|
+
copyButton.setAttribute('aria-label', 'Copy failed');
|
|
117
|
+
}
|
|
118
|
+
this._copyTimeout = window.setTimeout(() => {
|
|
119
|
+
const btn = this.shadowRoot.querySelector('.copy-button');
|
|
120
|
+
if (btn) {
|
|
121
|
+
btn.classList.remove('error');
|
|
122
|
+
btn.innerHTML = COPY_ICON_SVG;
|
|
123
|
+
btn.setAttribute('aria-label', 'Copy to clipboard');
|
|
124
|
+
}
|
|
125
|
+
this._copyTimeout = null;
|
|
126
|
+
}, 2000);
|
|
127
|
+
}
|
|
128
|
+
setupEventListeners() {
|
|
129
|
+
const shadow = this.shadowRoot;
|
|
130
|
+
const inputWrapper = shadow.querySelector('.input-wrapper');
|
|
131
|
+
const copyButton = shadow.querySelector('.copy-button');
|
|
132
|
+
if (inputWrapper && !this.disabled) {
|
|
133
|
+
const wrapperEl = inputWrapper;
|
|
134
|
+
wrapperEl.addEventListener('click', (e) => {
|
|
135
|
+
if (e.target === copyButton || e.target.closest('.copy-button')) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
this.copyToClipboard();
|
|
139
|
+
});
|
|
140
|
+
wrapperEl.style.cursor = 'pointer';
|
|
141
|
+
}
|
|
142
|
+
if (copyButton) {
|
|
143
|
+
copyButton.addEventListener('click', () => {
|
|
144
|
+
this.copyToClipboard();
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
render() {
|
|
149
|
+
const shadow = this.shadowRoot;
|
|
150
|
+
const classes = this.buildClassList();
|
|
151
|
+
const valueClass = [
|
|
152
|
+
'copy-field-value',
|
|
153
|
+
this.multiline ? 'multiline' : '',
|
|
154
|
+
this.horizontalScroll ? 'horizontal-scroll' : '',
|
|
155
|
+
].filter(Boolean).join(' ');
|
|
156
|
+
const displayElement = this.format === 'code'
|
|
157
|
+
? `<code class="${valueClass}">${this.value || ''}</code>`
|
|
158
|
+
: `<div class="${valueClass}">${this.value || ''}</div>`;
|
|
159
|
+
const labelHtml = this.label ? `
|
|
160
|
+
<label class="ty-field-label">
|
|
161
|
+
${this.label}
|
|
162
|
+
${this.required ? `<span class="required-icon">${REQUIRED_ICON_SVG}</span>` : ''}
|
|
163
|
+
</label>
|
|
164
|
+
` : '';
|
|
165
|
+
shadow.innerHTML = `
|
|
166
|
+
<div class="input-container">
|
|
167
|
+
${labelHtml}
|
|
168
|
+
<div class="input-wrapper ${classes}">
|
|
169
|
+
${displayElement}
|
|
170
|
+
<button class="copy-button${this._showingSuccess ? ' success' : ''}" type="button" aria-label="${this._showingSuccess ? 'Copied!' : 'Copy to clipboard'}" ${this.disabled ? 'disabled' : ''}>
|
|
171
|
+
${this._showingSuccess ? CHECK_ICON_SVG : COPY_ICON_SVG}
|
|
172
|
+
</button>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
`;
|
|
176
|
+
this.setupEventListeners();
|
|
177
|
+
}
|
|
178
|
+
get value() {
|
|
179
|
+
return this.getProperty('value');
|
|
180
|
+
}
|
|
181
|
+
set value(val) {
|
|
182
|
+
this.setProperty('value', val);
|
|
183
|
+
}
|
|
184
|
+
get label() {
|
|
185
|
+
return this.getProperty('label');
|
|
186
|
+
}
|
|
187
|
+
set label(val) {
|
|
188
|
+
this.setProperty('label', val);
|
|
189
|
+
}
|
|
190
|
+
get size() {
|
|
191
|
+
return this.getProperty('size');
|
|
192
|
+
}
|
|
193
|
+
set size(value) {
|
|
194
|
+
this.setProperty('size', value);
|
|
195
|
+
}
|
|
196
|
+
get flavor() {
|
|
197
|
+
return this.getProperty('flavor');
|
|
198
|
+
}
|
|
199
|
+
set flavor(value) {
|
|
200
|
+
this.setProperty('flavor', value);
|
|
201
|
+
}
|
|
202
|
+
get format() {
|
|
203
|
+
return this.getProperty('format');
|
|
204
|
+
}
|
|
205
|
+
set format(value) {
|
|
206
|
+
this.setProperty('format', value);
|
|
207
|
+
}
|
|
208
|
+
get multiline() {
|
|
209
|
+
return this.getProperty('multiline');
|
|
210
|
+
}
|
|
211
|
+
set multiline(value) {
|
|
212
|
+
this.setProperty('multiline', value);
|
|
213
|
+
}
|
|
214
|
+
get horizontalScroll() {
|
|
215
|
+
return this.getProperty('horizontalScroll');
|
|
216
|
+
}
|
|
217
|
+
set horizontalScroll(value) {
|
|
218
|
+
this.setProperty('horizontalScroll', value);
|
|
219
|
+
}
|
|
220
|
+
get disabled() {
|
|
221
|
+
return this.getProperty('disabled');
|
|
222
|
+
}
|
|
223
|
+
set disabled(value) {
|
|
224
|
+
this.setProperty('disabled', value);
|
|
225
|
+
}
|
|
226
|
+
get required() {
|
|
227
|
+
return this.getProperty('required');
|
|
228
|
+
}
|
|
229
|
+
set required(value) {
|
|
230
|
+
this.setProperty('required', value);
|
|
231
|
+
}
|
|
231
232
|
}
|
|
232
233
|
TyCopy.formAssociated = true;
|
|
233
234
|
TyCopy.properties = {
|
|
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
|
-
|
|
235
|
+
value: {
|
|
236
|
+
type: 'string',
|
|
237
|
+
visual: true,
|
|
238
|
+
formValue: true,
|
|
239
|
+
default: '',
|
|
240
|
+
},
|
|
241
|
+
label: {
|
|
242
|
+
type: 'string',
|
|
243
|
+
visual: true,
|
|
244
|
+
default: '',
|
|
245
|
+
},
|
|
246
|
+
size: {
|
|
247
|
+
type: 'string',
|
|
248
|
+
visual: true,
|
|
249
|
+
default: DEFAULT_SIZE,
|
|
250
|
+
validate: (v) => ['xs', 'sm', 'md', 'lg', 'xl'].includes(v),
|
|
251
|
+
coerce: (v) => {
|
|
252
|
+
if (!['xs', 'sm', 'md', 'lg', 'xl'].includes(v)) {
|
|
253
|
+
console.warn(`[ty-copy] Invalid size '${v}'. Using '${DEFAULT_SIZE}'.`);
|
|
254
|
+
return DEFAULT_SIZE;
|
|
255
|
+
}
|
|
256
|
+
return v;
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
flavor: {
|
|
260
|
+
type: 'string',
|
|
261
|
+
visual: true,
|
|
262
|
+
default: 'neutral',
|
|
263
|
+
},
|
|
264
|
+
format: {
|
|
265
|
+
type: 'string',
|
|
266
|
+
visual: true,
|
|
267
|
+
default: 'text',
|
|
268
|
+
coerce: (v) => (v === 'code' ? 'code' : 'text'),
|
|
269
|
+
},
|
|
270
|
+
multiline: {
|
|
271
|
+
type: 'boolean',
|
|
272
|
+
visual: true,
|
|
273
|
+
default: false,
|
|
274
|
+
},
|
|
275
|
+
horizontalScroll: {
|
|
276
|
+
type: 'boolean',
|
|
277
|
+
visual: true,
|
|
278
|
+
default: false,
|
|
279
|
+
},
|
|
280
|
+
disabled: {
|
|
281
|
+
type: 'boolean',
|
|
282
|
+
visual: true,
|
|
283
|
+
default: false,
|
|
284
|
+
},
|
|
285
|
+
required: {
|
|
286
|
+
type: 'boolean',
|
|
287
|
+
visual: true,
|
|
288
|
+
default: false,
|
|
289
|
+
},
|
|
289
290
|
};
|
|
290
291
|
if (!customElements.get('ty-copy')) {
|
|
291
|
-
|
|
292
|
+
customElements.define('ty-copy', TyCopy);
|
|
292
293
|
}
|
|
293
294
|
if (!customElements.get('ty-copy-field')) {
|
|
294
|
-
|
|
295
|
-
|
|
295
|
+
customElements.define('ty-copy-field', class TyCopyField extends TyCopy {
|
|
296
|
+
});
|
|
296
297
|
}
|