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.
Files changed (105) hide show
  1. package/css/tyrell-theme.css +25 -2
  2. package/css/tyrell.css +4 -0
  3. package/dist/tyrell-colors-static.css +1 -316
  4. package/dist/tyrell-theme.css +1 -1443
  5. package/dist/tyrell.css +1 -1390
  6. package/dist/tyrell.js +1 -1
  7. package/lib/base/ty-component.js +196 -196
  8. package/lib/components/button.d.ts +1 -1
  9. package/lib/components/button.js +260 -259
  10. package/lib/components/calendar-month.d.ts +2 -2
  11. package/lib/components/calendar-month.js +426 -416
  12. package/lib/components/calendar-navigation.js +238 -238
  13. package/lib/components/calendar.js +605 -602
  14. package/lib/components/checkbox.d.ts +1 -1
  15. package/lib/components/checkbox.js +273 -272
  16. package/lib/components/copy.d.ts +1 -1
  17. package/lib/components/copy.js +279 -278
  18. package/lib/components/date-picker.d.ts +1 -1
  19. package/lib/components/date-picker.js +1103 -1108
  20. package/lib/components/file-upload.js +404 -404
  21. package/lib/components/icon.js +141 -141
  22. package/lib/components/input.d.ts +1 -1
  23. package/lib/components/input.js +593 -596
  24. package/lib/components/modal.js +319 -319
  25. package/lib/components/option.js +167 -167
  26. package/lib/components/popup.js +233 -233
  27. package/lib/components/radio.d.ts +2 -2
  28. package/lib/components/radio.js +407 -406
  29. package/lib/components/resize-observer.js +67 -67
  30. package/lib/components/scroll-container.js +294 -294
  31. package/lib/components/select.d.ts +1 -1
  32. package/lib/components/select.js +1524 -1532
  33. package/lib/components/selected-tags.js +184 -184
  34. package/lib/components/step.js +62 -62
  35. package/lib/components/switch.d.ts +1 -1
  36. package/lib/components/switch.js +214 -213
  37. package/lib/components/tab.js +62 -62
  38. package/lib/components/tabs.js +507 -507
  39. package/lib/components/tag.d.ts +1 -1
  40. package/lib/components/tag.js +236 -235
  41. package/lib/components/textarea.d.ts +1 -1
  42. package/lib/components/textarea.js +457 -456
  43. package/lib/components/tooltip.js +283 -283
  44. package/lib/components/wizard.js +384 -384
  45. package/lib/icons/heroicons/micro.js +392 -392
  46. package/lib/icons/heroicons/mini.js +382 -382
  47. package/lib/icons/heroicons/outline.js +337 -337
  48. package/lib/icons/heroicons/solid.js +407 -407
  49. package/lib/icons/lucide.js +22843 -22843
  50. package/lib/icons/material/filled.js +9653 -9653
  51. package/lib/icons/material/outlined.js +10271 -10271
  52. package/lib/icons/material/round.js +10495 -10495
  53. package/lib/icons/material/sharp.js +9905 -9905
  54. package/lib/icons/material/two-tone.js +12792 -12792
  55. package/lib/index.js +21 -21
  56. package/lib/styles/button.js +176 -288
  57. package/lib/styles/calendar-month.js +123 -183
  58. package/lib/styles/calendar-navigation.js +60 -79
  59. package/lib/styles/calendar.js +8 -9
  60. package/lib/styles/checkbox.js +45 -72
  61. package/lib/styles/copy.js +67 -91
  62. package/lib/styles/custom-scrollbar.js +80 -100
  63. package/lib/styles/date-picker.js +261 -331
  64. package/lib/styles/field-size.d.ts +6 -0
  65. package/lib/styles/field-size.js +91 -0
  66. package/lib/styles/file-upload.js +139 -169
  67. package/lib/styles/icon.js +92 -156
  68. package/lib/styles/input.js +125 -241
  69. package/lib/styles/modal.js +67 -102
  70. package/lib/styles/option.d.ts +1 -1
  71. package/lib/styles/option.js +47 -67
  72. package/lib/styles/popup.js +34 -65
  73. package/lib/styles/radio.js +69 -96
  74. package/lib/styles/resize-observer.js +2 -5
  75. package/lib/styles/scroll-container.js +100 -130
  76. package/lib/styles/select-base.js +525 -778
  77. package/lib/styles/select.js +140 -228
  78. package/lib/styles/step.js +22 -29
  79. package/lib/styles/switch.js +34 -55
  80. package/lib/styles/tab.js +22 -29
  81. package/lib/styles/tabs.js +171 -252
  82. package/lib/styles/tag.js +135 -188
  83. package/lib/styles/textarea.d.ts +1 -1
  84. package/lib/styles/textarea.js +205 -271
  85. package/lib/styles/tooltip.js +3 -3
  86. package/lib/styles/wizard.js +170 -226
  87. package/lib/types/common.d.ts +2 -0
  88. package/lib/types/common.js +6 -5
  89. package/lib/utils/calendar-utils.js +100 -100
  90. package/lib/utils/custom-scrollbar.js +272 -272
  91. package/lib/utils/flavor-sheet.js +14 -14
  92. package/lib/utils/icon-registry.js +127 -127
  93. package/lib/utils/loader-registry.js +3 -3
  94. package/lib/utils/locale.js +34 -34
  95. package/lib/utils/mobile.js +1 -1
  96. package/lib/utils/number-format.js +54 -54
  97. package/lib/utils/positioning.js +212 -212
  98. package/lib/utils/property-capture.js +36 -36
  99. package/lib/utils/property-manager.js +125 -125
  100. package/lib/utils/resize-observer.js +23 -23
  101. package/lib/utils/scroll-lock.js +57 -57
  102. package/lib/utils/styles.js +17 -17
  103. package/lib/version.d.ts +1 -1
  104. package/lib/version.js +1 -1
  105. package/package.json +4 -4
@@ -1,194 +1,194 @@
1
1
  function parseValues(raw) {
2
- return raw.split(',').map(s => s.trim()).filter(Boolean);
2
+ return raw.split(',').map(s => s.trim()).filter(Boolean);
3
3
  }
4
4
  function interpolate(text, ctx) {
5
- return text.replace(/\{([\w-]+)\}/g, (match, key) => ctx[key] ?? match);
5
+ return text.replace(/\{([\w-]+)\}/g, (match, key) => ctx[key] ?? match);
6
6
  }
7
7
  export class TySelectedOptions extends HTMLElement {
8
- constructor() {
9
- super(...arguments);
10
- this._picker = null;
11
- this._onChange = () => this.renderChips();
12
- this._childObserver = null;
13
- this._pickerObserver = null;
14
- this._lastTemplate = null;
15
- this._pickerOpen = false;
16
- this._onPickerOpen = () => {
17
- this._pickerOpen = true;
18
- };
19
- this._onPickerClose = () => {
20
- this._pickerOpen = false;
21
- this.renderChips();
22
- };
23
- }
24
- static get observedAttributes() {
25
- return ['for'];
26
- }
27
- connectedCallback() {
28
- if (!this.style.display)
29
- this.style.display = 'contents';
30
- this.bind();
31
- this.renderChips();
32
- this._childObserver = new MutationObserver(() => {
33
- const template = this.template();
34
- if (template !== this._lastTemplate) {
35
- this.renderChips();
36
- }
37
- });
38
- this._childObserver.observe(this, { childList: true });
39
- }
40
- disconnectedCallback() {
41
- this.unbind();
42
- this._childObserver?.disconnect();
43
- this._childObserver = null;
44
- }
45
- attributeChangedCallback() {
46
- if (!this.isConnected)
47
- return;
48
- this.bind();
49
- this.renderChips();
50
- }
51
- resolvePicker() {
52
- const id = this.getAttribute('for');
53
- const el = id
54
- ? document.getElementById(id)
55
- : this.previousElementSibling;
56
- return el ?? null;
57
- }
58
- bind() {
59
- const next = this.resolvePicker();
60
- if (next === this._picker)
61
- return;
62
- this.unbind();
63
- this._picker = next;
64
- this._picker?.addEventListener('change', this._onChange);
65
- this._picker?.addEventListener('open', this._onPickerOpen);
66
- this._picker?.addEventListener('close', this._onPickerClose);
67
- if (this._picker) {
68
- this._pickerObserver = new MutationObserver(() => this.renderChips());
69
- this._pickerObserver.observe(this._picker, {
70
- childList: true,
71
- subtree: true,
72
- attributes: true,
73
- attributeFilter: ['selected'],
74
- });
75
- }
76
- }
77
- unbind() {
78
- this._picker?.removeEventListener('change', this._onChange);
79
- this._picker?.removeEventListener('open', this._onPickerOpen);
80
- this._picker?.removeEventListener('close', this._onPickerClose);
81
- this._pickerObserver?.disconnect();
82
- this._pickerObserver = null;
83
- this._picker = null;
84
- this._pickerOpen = false;
85
- }
86
- values() {
87
- return parseValues(this._picker?.value ?? '');
88
- }
89
- template() {
90
- return this.querySelector(':scope > template');
91
- }
92
- context(value) {
93
- const opt = this._picker?.querySelector(`[value="${CSS.escape(value)}"]`);
94
- const ctx = {
95
- value,
96
- label: opt?.getAttribute('label') || opt?.textContent?.trim() || value,
97
- flavor: opt?.getAttribute('flavor') ?? '',
98
- };
99
- if (opt) {
100
- for (const attr of Array.from(opt.attributes)) {
101
- if (attr.name.startsWith('data-'))
102
- ctx[attr.name] = attr.value;
103
- }
104
- }
105
- return ctx;
106
- }
107
- templateSource(template) {
108
- if (template.content.hasChildNodes())
109
- return template.content;
110
- const frag = document.createDocumentFragment();
111
- template.childNodes.forEach(n => frag.appendChild(n.cloneNode(true)));
112
- return frag;
113
- }
114
- stampTemplate(template, value) {
115
- const ctx = this.context(value);
116
- const clone = this.templateSource(template).cloneNode(true);
117
- const walker = document.createTreeWalker(clone, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT);
118
- for (let node = walker.nextNode(); node; node = walker.nextNode()) {
119
- if (node.nodeType === Node.TEXT_NODE) {
120
- if (node.textContent?.includes('{')) {
121
- node.textContent = interpolate(node.textContent, ctx);
122
- }
123
- }
124
- else {
125
- const el = node;
126
- for (const attr of Array.from(el.attributes)) {
127
- if (!attr.value.includes('{'))
128
- continue;
129
- const resolved = interpolate(attr.value, ctx);
130
- if (/^\{[\w-]+\}$/.test(attr.value) && (resolved === '' || resolved === attr.value)) {
131
- el.removeAttribute(attr.name);
132
- }
133
- else {
134
- el.setAttribute(attr.name, resolved);
135
- }
136
- }
137
- }
138
- }
139
- for (const el of Array.from(clone.children)) {
140
- el.addEventListener('dismiss', (e) => {
141
- e.stopPropagation();
142
- this.deselect(value);
143
- });
144
- }
145
- return clone;
146
- }
147
- defaultChip(value) {
148
- const ctx = this.context(value);
149
- const tag = document.createElement('ty-tag');
150
- tag.setAttribute('value', value);
151
- tag.setAttribute('dismissible', 'true');
152
- if (ctx.flavor)
153
- tag.setAttribute('flavor', ctx.flavor);
154
- tag.textContent = ctx.label;
155
- tag.addEventListener('dismiss', () => this.deselect(value));
156
- return tag;
157
- }
158
- renderChips() {
159
- if (this._pickerOpen)
160
- return;
161
- const template = this.template();
162
- this._lastTemplate = template;
163
- if (!this._picker) {
164
- this.replaceChildren(...(template ? [template] : []));
165
- return;
166
- }
167
- const frag = document.createDocumentFragment();
168
- if (template)
169
- frag.appendChild(template);
170
- for (const value of this.values()) {
171
- frag.appendChild(template ? this.stampTemplate(template, value) : this.defaultChip(value));
172
- }
173
- this.replaceChildren(frag);
174
- }
175
- deselect(value) {
176
- if (!this._picker)
177
- return;
178
- const picker = this._picker;
179
- if (typeof picker.deselectValue === 'function') {
180
- picker.deselectValue(value);
181
- }
182
- else {
183
- picker.value = this.values().filter(v => v !== value).join(',');
184
- this.renderChips();
185
- }
186
- }
8
+ constructor() {
9
+ super(...arguments);
10
+ this._picker = null;
11
+ this._onChange = () => this.renderChips();
12
+ this._childObserver = null;
13
+ this._pickerObserver = null;
14
+ this._lastTemplate = null;
15
+ this._pickerOpen = false;
16
+ this._onPickerOpen = () => {
17
+ this._pickerOpen = true;
18
+ };
19
+ this._onPickerClose = () => {
20
+ this._pickerOpen = false;
21
+ this.renderChips();
22
+ };
23
+ }
24
+ static get observedAttributes() {
25
+ return ['for'];
26
+ }
27
+ connectedCallback() {
28
+ if (!this.style.display)
29
+ this.style.display = 'contents';
30
+ this.bind();
31
+ this.renderChips();
32
+ this._childObserver = new MutationObserver(() => {
33
+ const template = this.template();
34
+ if (template !== this._lastTemplate) {
35
+ this.renderChips();
36
+ }
37
+ });
38
+ this._childObserver.observe(this, { childList: true });
39
+ }
40
+ disconnectedCallback() {
41
+ this.unbind();
42
+ this._childObserver?.disconnect();
43
+ this._childObserver = null;
44
+ }
45
+ attributeChangedCallback() {
46
+ if (!this.isConnected)
47
+ return;
48
+ this.bind();
49
+ this.renderChips();
50
+ }
51
+ resolvePicker() {
52
+ const id = this.getAttribute('for');
53
+ const el = id
54
+ ? document.getElementById(id)
55
+ : this.previousElementSibling;
56
+ return el ?? null;
57
+ }
58
+ bind() {
59
+ const next = this.resolvePicker();
60
+ if (next === this._picker)
61
+ return;
62
+ this.unbind();
63
+ this._picker = next;
64
+ this._picker?.addEventListener('change', this._onChange);
65
+ this._picker?.addEventListener('open', this._onPickerOpen);
66
+ this._picker?.addEventListener('close', this._onPickerClose);
67
+ if (this._picker) {
68
+ this._pickerObserver = new MutationObserver(() => this.renderChips());
69
+ this._pickerObserver.observe(this._picker, {
70
+ childList: true,
71
+ subtree: true,
72
+ attributes: true,
73
+ attributeFilter: ['selected'],
74
+ });
75
+ }
76
+ }
77
+ unbind() {
78
+ this._picker?.removeEventListener('change', this._onChange);
79
+ this._picker?.removeEventListener('open', this._onPickerOpen);
80
+ this._picker?.removeEventListener('close', this._onPickerClose);
81
+ this._pickerObserver?.disconnect();
82
+ this._pickerObserver = null;
83
+ this._picker = null;
84
+ this._pickerOpen = false;
85
+ }
86
+ values() {
87
+ return parseValues(this._picker?.value ?? '');
88
+ }
89
+ template() {
90
+ return this.querySelector(':scope > template');
91
+ }
92
+ context(value) {
93
+ const opt = this._picker?.querySelector(`[value="${CSS.escape(value)}"]`);
94
+ const ctx = {
95
+ value,
96
+ label: opt?.getAttribute('label') || opt?.textContent?.trim() || value,
97
+ flavor: opt?.getAttribute('flavor') ?? '',
98
+ };
99
+ if (opt) {
100
+ for (const attr of Array.from(opt.attributes)) {
101
+ if (attr.name.startsWith('data-'))
102
+ ctx[attr.name] = attr.value;
103
+ }
104
+ }
105
+ return ctx;
106
+ }
107
+ templateSource(template) {
108
+ if (template.content.hasChildNodes())
109
+ return template.content;
110
+ const frag = document.createDocumentFragment();
111
+ template.childNodes.forEach(n => frag.appendChild(n.cloneNode(true)));
112
+ return frag;
113
+ }
114
+ stampTemplate(template, value) {
115
+ const ctx = this.context(value);
116
+ const clone = this.templateSource(template).cloneNode(true);
117
+ const walker = document.createTreeWalker(clone, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT);
118
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
119
+ if (node.nodeType === Node.TEXT_NODE) {
120
+ if (node.textContent?.includes('{')) {
121
+ node.textContent = interpolate(node.textContent, ctx);
122
+ }
123
+ }
124
+ else {
125
+ const el = node;
126
+ for (const attr of Array.from(el.attributes)) {
127
+ if (!attr.value.includes('{'))
128
+ continue;
129
+ const resolved = interpolate(attr.value, ctx);
130
+ if (/^\{[\w-]+\}$/.test(attr.value) && (resolved === '' || resolved === attr.value)) {
131
+ el.removeAttribute(attr.name);
132
+ }
133
+ else {
134
+ el.setAttribute(attr.name, resolved);
135
+ }
136
+ }
137
+ }
138
+ }
139
+ for (const el of Array.from(clone.children)) {
140
+ el.addEventListener('dismiss', (e) => {
141
+ e.stopPropagation();
142
+ this.deselect(value);
143
+ });
144
+ }
145
+ return clone;
146
+ }
147
+ defaultChip(value) {
148
+ const ctx = this.context(value);
149
+ const tag = document.createElement('ty-tag');
150
+ tag.setAttribute('value', value);
151
+ tag.setAttribute('dismissible', 'true');
152
+ if (ctx.flavor)
153
+ tag.setAttribute('flavor', ctx.flavor);
154
+ tag.textContent = ctx.label;
155
+ tag.addEventListener('dismiss', () => this.deselect(value));
156
+ return tag;
157
+ }
158
+ renderChips() {
159
+ if (this._pickerOpen)
160
+ return;
161
+ const template = this.template();
162
+ this._lastTemplate = template;
163
+ if (!this._picker) {
164
+ this.replaceChildren(...(template ? [template] : []));
165
+ return;
166
+ }
167
+ const frag = document.createDocumentFragment();
168
+ if (template)
169
+ frag.appendChild(template);
170
+ for (const value of this.values()) {
171
+ frag.appendChild(template ? this.stampTemplate(template, value) : this.defaultChip(value));
172
+ }
173
+ this.replaceChildren(frag);
174
+ }
175
+ deselect(value) {
176
+ if (!this._picker)
177
+ return;
178
+ const picker = this._picker;
179
+ if (typeof picker.deselectValue === 'function') {
180
+ picker.deselectValue(value);
181
+ }
182
+ else {
183
+ picker.value = this.values().filter(v => v !== value).join(',');
184
+ this.renderChips();
185
+ }
186
+ }
187
187
  }
188
188
  if (!customElements.get('ty-selected-options')) {
189
- customElements.define('ty-selected-options', TySelectedOptions);
189
+ customElements.define('ty-selected-options', TySelectedOptions);
190
190
  }
191
191
  if (!customElements.get('ty-selected-tags')) {
192
- customElements.define('ty-selected-tags', class TySelectedTags extends TySelectedOptions {
193
- });
192
+ customElements.define('ty-selected-tags', class TySelectedTags extends TySelectedOptions {
193
+ });
194
194
  }
@@ -2,68 +2,68 @@ import { ensureStyles } from '../utils/styles.js';
2
2
  import { stepStyles } from '../styles/step.js';
3
3
  import { CustomScrollbar, isCustomScrollbarEnabled } from '../utils/custom-scrollbar.js';
4
4
  export class TyStep extends HTMLElement {
5
- static get observedAttributes() {
6
- return ['id', 'label', 'description', 'disabled', 'status'];
7
- }
8
- constructor() {
9
- super();
10
- this._scrollbar = null;
11
- this.attachShadow({ mode: 'open' });
12
- }
13
- connectedCallback() {
14
- this._render();
15
- }
16
- disconnectedCallback() {
17
- this._destroyScrollbar();
18
- }
19
- attributeChangedCallback(_name, _oldValue, _newValue) {
20
- this._render();
21
- }
22
- _render() {
23
- const shadowRoot = this.shadowRoot;
24
- if (!shadowRoot)
25
- return;
26
- const id = this.getAttribute('id');
27
- if (!shadowRoot.querySelector('.step-wrapper')) {
28
- ensureStyles(shadowRoot, { css: stepStyles, id: 'ty-step' });
29
- shadowRoot.innerHTML = `
30
- <div class="step-wrapper"
31
- role="tabpanel"
32
- ${id ? `id="panel-${id}"` : ''}
33
- ${id ? `aria-labelledby="step-${id}"` : ''}
34
- >
35
- <div class="step-panel">
36
- <slot></slot>
37
- </div>
38
- </div>
39
- `;
40
- this._setupScrollbar();
41
- }
42
- }
43
- _setupScrollbar() {
44
- const panel = this.shadowRoot?.querySelector('.step-panel');
45
- const wrapper = this.shadowRoot?.querySelector('.step-wrapper');
46
- if (!panel || !wrapper)
47
- return;
48
- if (!isCustomScrollbarEnabled())
49
- return;
50
- panel.classList.add('ty-custom-scroll');
51
- this._scrollbar = new CustomScrollbar(panel, { vertical: true });
52
- if (this._scrollbar.trackY) {
53
- wrapper.appendChild(this._scrollbar.trackY);
54
- }
55
- }
56
- _destroyScrollbar() {
57
- if (this._scrollbar) {
58
- this._scrollbar.trackY?.remove();
59
- this._scrollbar.destroy();
60
- this._scrollbar = null;
61
- }
62
- }
63
- resetScroll() {
64
- this._scrollbar?.scrollToTop(false);
65
- }
5
+ static get observedAttributes() {
6
+ return ['id', 'label', 'description', 'disabled', 'status'];
7
+ }
8
+ constructor() {
9
+ super();
10
+ this._scrollbar = null;
11
+ this.attachShadow({ mode: 'open' });
12
+ }
13
+ connectedCallback() {
14
+ this._render();
15
+ }
16
+ disconnectedCallback() {
17
+ this._destroyScrollbar();
18
+ }
19
+ attributeChangedCallback(_name, _oldValue, _newValue) {
20
+ this._render();
21
+ }
22
+ _render() {
23
+ const shadowRoot = this.shadowRoot;
24
+ if (!shadowRoot)
25
+ return;
26
+ const id = this.getAttribute('id');
27
+ if (!shadowRoot.querySelector('.step-wrapper')) {
28
+ ensureStyles(shadowRoot, { css: stepStyles, id: 'ty-step' });
29
+ shadowRoot.innerHTML = `
30
+ <div class="step-wrapper"
31
+ role="tabpanel"
32
+ ${id ? `id="panel-${id}"` : ''}
33
+ ${id ? `aria-labelledby="step-${id}"` : ''}
34
+ >
35
+ <div class="step-panel">
36
+ <slot></slot>
37
+ </div>
38
+ </div>
39
+ `;
40
+ this._setupScrollbar();
41
+ }
42
+ }
43
+ _setupScrollbar() {
44
+ const panel = this.shadowRoot?.querySelector('.step-panel');
45
+ const wrapper = this.shadowRoot?.querySelector('.step-wrapper');
46
+ if (!panel || !wrapper)
47
+ return;
48
+ if (!isCustomScrollbarEnabled())
49
+ return;
50
+ panel.classList.add('ty-custom-scroll');
51
+ this._scrollbar = new CustomScrollbar(panel, { vertical: true });
52
+ if (this._scrollbar.trackY) {
53
+ wrapper.appendChild(this._scrollbar.trackY);
54
+ }
55
+ }
56
+ _destroyScrollbar() {
57
+ if (this._scrollbar) {
58
+ this._scrollbar.trackY?.remove();
59
+ this._scrollbar.destroy();
60
+ this._scrollbar = null;
61
+ }
62
+ }
63
+ resetScroll() {
64
+ this._scrollbar?.scrollToTop(false);
65
+ }
66
66
  }
67
67
  if (!customElements.get('ty-step')) {
68
- customElements.define('ty-step', TyStep);
68
+ customElements.define('ty-step', TyStep);
69
69
  }
@@ -53,7 +53,7 @@ export declare class TySwitch extends TyComponent<SwitchState> implements TySwit
53
53
  size: {
54
54
  type: "string";
55
55
  visual: boolean;
56
- default: string;
56
+ default: Size;
57
57
  validate: (v: any) => boolean;
58
58
  coerce: (v: any) => any;
59
59
  };