@haiilo/catalyst 0.5.13 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalyst/catalyst.css +1 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/p-12486027.js.map +1 -1
- package/dist/catalyst/p-12b96af6.js +2 -0
- package/dist/catalyst/p-12b96af6.js.map +1 -0
- package/dist/catalyst/p-4c9cd203.entry.js +2 -0
- package/dist/catalyst/p-4c9cd203.entry.js.map +1 -0
- package/dist/catalyst/p-5616e2cd.js +2 -0
- package/dist/catalyst/p-5616e2cd.js.map +1 -0
- package/dist/catalyst/p-9d2eab4f.entry.js +10 -0
- package/dist/catalyst/p-9d2eab4f.entry.js.map +1 -0
- package/dist/cjs/app-globals-aa29ad72.js.map +1 -1
- package/dist/cjs/{cat-alert_15.cjs.entry.js → cat-alert_18.cjs.entry.js} +277 -65
- package/dist/cjs/cat-alert_18.cjs.entry.js.map +1 -0
- package/dist/cjs/cat-form-hint-93a6936b.js +22 -0
- package/dist/cjs/cat-form-hint-93a6936b.js.map +1 -0
- package/dist/cjs/cat-textarea.cjs.entry.js +12 -12
- package/dist/cjs/cat-textarea.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +2 -2
- package/dist/cjs/{index-5d72f0e4.js → index-499bad41.js} +44 -1
- package/dist/cjs/index-499bad41.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/cat-avatar/cat-avatar.css +81 -0
- package/dist/collection/components/cat-avatar/cat-avatar.js +225 -0
- package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -0
- package/dist/collection/components/cat-badge/cat-badge.css +5 -5
- package/dist/collection/components/cat-button/cat-button.js +8 -8
- package/dist/collection/components/cat-button/cat-button.js.map +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +14 -0
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +43 -11
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
- package/dist/collection/components/cat-form-hint/cat-form-hint.js +16 -0
- package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -0
- package/dist/collection/components/cat-input/cat-input.css +12 -6
- package/dist/collection/components/cat-input/cat-input.js +23 -25
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.css +14 -0
- package/dist/collection/components/cat-radio/cat-radio.js +40 -8
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-scrollable/cat-scrollable.js +44 -44
- package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
- package/dist/collection/components/cat-tab/cat-tab.css +12 -0
- package/dist/collection/components/cat-tab/cat-tab.js +203 -0
- package/dist/collection/components/cat-tab/cat-tab.js.map +1 -0
- package/dist/collection/components/cat-tabs/cat-tabs.css +33 -0
- package/dist/collection/components/cat-tabs/cat-tabs.js +122 -0
- package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -0
- package/dist/collection/components/cat-textarea/cat-textarea.css +12 -6
- package/dist/collection/components/cat-textarea/cat-textarea.js +23 -18
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.css +14 -0
- package/dist/collection/components/cat-toggle/cat-toggle.js +39 -7
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +13 -8
- package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
- package/dist/collection/utils/load-img.js +16 -0
- package/dist/collection/utils/load-img.js.map +1 -0
- package/dist/components/cat-avatar.d.ts +11 -0
- package/dist/components/cat-avatar.js +125 -0
- package/dist/components/cat-avatar.js.map +1 -0
- package/dist/components/cat-badge.js +1 -1
- package/dist/components/cat-badge.js.map +1 -1
- package/dist/components/cat-button2.js +5 -5
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-checkbox.js +15 -5
- package/dist/components/cat-checkbox.js.map +1 -1
- package/dist/components/cat-form-hint.js +20 -0
- package/dist/components/cat-form-hint.js.map +1 -0
- package/dist/components/cat-input.js +15 -18
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-radio.js +15 -5
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-scrollable.js +23 -23
- package/dist/components/cat-scrollable.js.map +1 -1
- package/dist/components/cat-tab.d.ts +11 -0
- package/dist/components/cat-tab.js +70 -0
- package/dist/components/cat-tab.js.map +1 -0
- package/dist/components/cat-tabs.d.ts +11 -0
- package/dist/components/cat-tabs.js +107 -0
- package/dist/components/cat-tabs.js.map +1 -0
- package/dist/components/cat-textarea.js +13 -12
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-toggle.js +15 -5
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/cat-tooltip.js +13 -8
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/esm/app-globals-cf55f7f5.js.map +1 -1
- package/dist/esm/{cat-alert_15.entry.js → cat-alert_18.entry.js} +275 -66
- package/dist/esm/cat-alert_18.entry.js.map +1 -0
- package/dist/esm/cat-form-hint-dc443c7c.js +20 -0
- package/dist/esm/cat-form-hint-dc443c7c.js.map +1 -0
- package/dist/esm/cat-textarea.entry.js +12 -12
- package/dist/esm/cat-textarea.entry.js.map +1 -1
- package/dist/esm/catalyst.js +2 -2
- package/dist/esm/{index-fd12be19.js → index-039e6f5f.js} +44 -2
- package/dist/esm/index-039e6f5f.js.map +1 -0
- package/dist/esm/loader.js +2 -2
- package/dist/types/components/cat-avatar/cat-avatar.d.ts +46 -0
- package/dist/types/components/cat-button/cat-button.d.ts +2 -2
- package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +9 -0
- package/dist/types/components/cat-form-hint/cat-form-hint.d.ts +19 -0
- package/dist/types/components/cat-input/cat-input.d.ts +7 -5
- package/dist/types/components/cat-radio/cat-radio.d.ts +9 -0
- package/dist/types/components/cat-scrollable/cat-scrollable.d.ts +12 -12
- package/dist/types/components/cat-tab/cat-tab.d.ts +43 -0
- package/dist/types/components/cat-tabs/cat-tabs.d.ts +25 -0
- package/dist/types/components/cat-textarea/cat-textarea.d.ts +7 -2
- package/dist/types/components/cat-toggle/cat-toggle.d.ts +9 -0
- package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +1 -0
- package/dist/types/components.d.ts +255 -52
- package/dist/types/utils/load-img.d.ts +8 -0
- package/package.json +2 -2
- package/dist/catalyst/p-a8629c54.entry.js +0 -2
- package/dist/catalyst/p-a8629c54.entry.js.map +0 -1
- package/dist/catalyst/p-bfc656ca.js +0 -2
- package/dist/catalyst/p-bfc656ca.js.map +0 -1
- package/dist/catalyst/p-e6491f33.entry.js +0 -10
- package/dist/catalyst/p-e6491f33.entry.js.map +0 -1
- package/dist/cjs/cat-alert_15.cjs.entry.js.map +0 -1
- package/dist/cjs/index-5d72f0e4.js.map +0 -1
- package/dist/esm/cat-alert_15.entry.js.map +0 -1
- package/dist/esm/index-fd12be19.js.map +0 -1
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Component, h, Prop, Event, Listen, Host, Element } from '@stencil/core';
|
|
2
|
+
let nextUniqueId = 0;
|
|
3
|
+
/**
|
|
4
|
+
* A single tab inside a tabs component.
|
|
5
|
+
*/
|
|
6
|
+
export class CatTab {
|
|
7
|
+
constructor() {
|
|
8
|
+
/**
|
|
9
|
+
* The label of the tab.
|
|
10
|
+
*/
|
|
11
|
+
this.label = '';
|
|
12
|
+
/**
|
|
13
|
+
* Hide the actual button content and only display the tab.
|
|
14
|
+
*/
|
|
15
|
+
this.iconOnly = false;
|
|
16
|
+
/**
|
|
17
|
+
* Display the icon on the right.
|
|
18
|
+
*/
|
|
19
|
+
this.iconRight = false;
|
|
20
|
+
/**
|
|
21
|
+
* Specifies that the tab should be deactivated.
|
|
22
|
+
*/
|
|
23
|
+
this.deactivated = false;
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
if (!this.hostElement.id) {
|
|
27
|
+
this.hostElement.id = `cat-tab-${nextUniqueId++}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
onClick(event) {
|
|
31
|
+
this.tabClick.emit(event);
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
return h(Host, null);
|
|
35
|
+
}
|
|
36
|
+
static get is() { return "cat-tab"; }
|
|
37
|
+
static get encapsulation() { return "shadow"; }
|
|
38
|
+
static get originalStyleUrls() { return {
|
|
39
|
+
"$": ["cat-tab.scss"]
|
|
40
|
+
}; }
|
|
41
|
+
static get styleUrls() { return {
|
|
42
|
+
"$": ["cat-tab.css"]
|
|
43
|
+
}; }
|
|
44
|
+
static get properties() { return {
|
|
45
|
+
"label": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"mutable": false,
|
|
48
|
+
"complexType": {
|
|
49
|
+
"original": "string",
|
|
50
|
+
"resolved": "string",
|
|
51
|
+
"references": {}
|
|
52
|
+
},
|
|
53
|
+
"required": false,
|
|
54
|
+
"optional": false,
|
|
55
|
+
"docs": {
|
|
56
|
+
"tags": [],
|
|
57
|
+
"text": "The label of the tab."
|
|
58
|
+
},
|
|
59
|
+
"attribute": "label",
|
|
60
|
+
"reflect": false,
|
|
61
|
+
"defaultValue": "''"
|
|
62
|
+
},
|
|
63
|
+
"icon": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"mutable": false,
|
|
66
|
+
"complexType": {
|
|
67
|
+
"original": "string",
|
|
68
|
+
"resolved": "string | undefined",
|
|
69
|
+
"references": {}
|
|
70
|
+
},
|
|
71
|
+
"required": false,
|
|
72
|
+
"optional": true,
|
|
73
|
+
"docs": {
|
|
74
|
+
"tags": [],
|
|
75
|
+
"text": "The name of an icon to be displayed in the tab."
|
|
76
|
+
},
|
|
77
|
+
"attribute": "icon",
|
|
78
|
+
"reflect": false
|
|
79
|
+
},
|
|
80
|
+
"iconOnly": {
|
|
81
|
+
"type": "any",
|
|
82
|
+
"mutable": false,
|
|
83
|
+
"complexType": {
|
|
84
|
+
"original": "boolean | Breakpoint",
|
|
85
|
+
"resolved": "\"l\" | \"m\" | \"s\" | \"xl\" | \"xs\" | boolean",
|
|
86
|
+
"references": {
|
|
87
|
+
"Breakpoint": {
|
|
88
|
+
"location": "import",
|
|
89
|
+
"path": "../../utils/breakpoints"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"required": false,
|
|
94
|
+
"optional": false,
|
|
95
|
+
"docs": {
|
|
96
|
+
"tags": [],
|
|
97
|
+
"text": "Hide the actual button content and only display the tab."
|
|
98
|
+
},
|
|
99
|
+
"attribute": "icon-only",
|
|
100
|
+
"reflect": false,
|
|
101
|
+
"defaultValue": "false"
|
|
102
|
+
},
|
|
103
|
+
"iconRight": {
|
|
104
|
+
"type": "boolean",
|
|
105
|
+
"mutable": false,
|
|
106
|
+
"complexType": {
|
|
107
|
+
"original": "boolean",
|
|
108
|
+
"resolved": "boolean",
|
|
109
|
+
"references": {}
|
|
110
|
+
},
|
|
111
|
+
"required": false,
|
|
112
|
+
"optional": false,
|
|
113
|
+
"docs": {
|
|
114
|
+
"tags": [],
|
|
115
|
+
"text": "Display the icon on the right."
|
|
116
|
+
},
|
|
117
|
+
"attribute": "icon-right",
|
|
118
|
+
"reflect": false,
|
|
119
|
+
"defaultValue": "false"
|
|
120
|
+
},
|
|
121
|
+
"url": {
|
|
122
|
+
"type": "string",
|
|
123
|
+
"mutable": false,
|
|
124
|
+
"complexType": {
|
|
125
|
+
"original": "string",
|
|
126
|
+
"resolved": "string | undefined",
|
|
127
|
+
"references": {}
|
|
128
|
+
},
|
|
129
|
+
"required": false,
|
|
130
|
+
"optional": true,
|
|
131
|
+
"docs": {
|
|
132
|
+
"tags": [],
|
|
133
|
+
"text": "A destination to link to, rendered in the href attribute of a link."
|
|
134
|
+
},
|
|
135
|
+
"attribute": "url",
|
|
136
|
+
"reflect": false
|
|
137
|
+
},
|
|
138
|
+
"urlTarget": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"mutable": false,
|
|
141
|
+
"complexType": {
|
|
142
|
+
"original": "'_blank' | '_self'",
|
|
143
|
+
"resolved": "\"_blank\" | \"_self\" | undefined",
|
|
144
|
+
"references": {}
|
|
145
|
+
},
|
|
146
|
+
"required": false,
|
|
147
|
+
"optional": true,
|
|
148
|
+
"docs": {
|
|
149
|
+
"tags": [],
|
|
150
|
+
"text": "Specifies where to open the linked document."
|
|
151
|
+
},
|
|
152
|
+
"attribute": "url-target",
|
|
153
|
+
"reflect": false
|
|
154
|
+
},
|
|
155
|
+
"deactivated": {
|
|
156
|
+
"type": "boolean",
|
|
157
|
+
"mutable": false,
|
|
158
|
+
"complexType": {
|
|
159
|
+
"original": "boolean",
|
|
160
|
+
"resolved": "boolean",
|
|
161
|
+
"references": {}
|
|
162
|
+
},
|
|
163
|
+
"required": false,
|
|
164
|
+
"optional": false,
|
|
165
|
+
"docs": {
|
|
166
|
+
"tags": [],
|
|
167
|
+
"text": "Specifies that the tab should be deactivated."
|
|
168
|
+
},
|
|
169
|
+
"attribute": "deactivated",
|
|
170
|
+
"reflect": false,
|
|
171
|
+
"defaultValue": "false"
|
|
172
|
+
}
|
|
173
|
+
}; }
|
|
174
|
+
static get events() { return [{
|
|
175
|
+
"method": "tabClick",
|
|
176
|
+
"name": "tabClick",
|
|
177
|
+
"bubbles": true,
|
|
178
|
+
"cancelable": true,
|
|
179
|
+
"composed": true,
|
|
180
|
+
"docs": {
|
|
181
|
+
"tags": [],
|
|
182
|
+
"text": "Emitted when tab is clicked."
|
|
183
|
+
},
|
|
184
|
+
"complexType": {
|
|
185
|
+
"original": "MouseEvent",
|
|
186
|
+
"resolved": "MouseEvent",
|
|
187
|
+
"references": {
|
|
188
|
+
"MouseEvent": {
|
|
189
|
+
"location": "global"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}]; }
|
|
194
|
+
static get elementRef() { return "hostElement"; }
|
|
195
|
+
static get listeners() { return [{
|
|
196
|
+
"name": "click",
|
|
197
|
+
"method": "onClick",
|
|
198
|
+
"target": undefined,
|
|
199
|
+
"capture": false,
|
|
200
|
+
"passive": false
|
|
201
|
+
}]; }
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=cat-tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cat-tab.js","sourceRoot":"","sources":["../../../src/components/cat-tab/cat-tab.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAgB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG/F,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;GAEG;AAMH,MAAM,OAAO,MAAM;EALnB;IAQE;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAOnB;;OAEG;IACK,aAAQ,GAAyB,KAAK,CAAC;IAE/C;;OAEG;IACK,cAAS,GAAG,KAAK,CAAC;IAY1B;;OAEG;IACK,gBAAW,GAAG,KAAK,CAAC;GAqB7B;EAdC,iBAAiB;IACf,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE;MACxB,IAAI,CAAC,WAAW,CAAC,EAAE,GAAG,WAAW,YAAY,EAAE,EAAE,CAAC;KACnD;EACH,CAAC;EAGD,OAAO,CAAC,KAAiB;IACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC5B,CAAC;EAED,MAAM;IACJ,OAAO,EAAC,IAAI,OAAQ,CAAC;EACvB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, Event, EventEmitter, Listen, Host, Element } from '@stencil/core';\nimport { Breakpoint } from '../../utils/breakpoints';\n\nlet nextUniqueId = 0;\n\n/**\n * A single tab inside a tabs component.\n */\n@Component({\n tag: 'cat-tab',\n styleUrl: 'cat-tab.scss',\n shadow: true\n})\nexport class CatTab {\n @Element() hostElement!: HTMLElement;\n\n /**\n * The label of the tab.\n */\n @Prop() label = '';\n\n /**\n * The name of an icon to be displayed in the tab.\n */\n @Prop() icon?: string;\n\n /**\n * Hide the actual button content and only display the tab.\n */\n @Prop() iconOnly: boolean | Breakpoint = false;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A destination to link to, rendered in the href attribute of a link.\n */\n @Prop() url?: string;\n\n /**\n * Specifies where to open the linked document.\n */\n @Prop() urlTarget?: '_blank' | '_self';\n\n /**\n * Specifies that the tab should be deactivated.\n */\n @Prop() deactivated = false;\n\n /**\n * Emitted when tab is clicked.\n */\n @Event() tabClick!: EventEmitter<MouseEvent>;\n\n connectedCallback() {\n if (!this.hostElement.id) {\n this.hostElement.id = `cat-tab-${nextUniqueId++}`;\n }\n }\n\n @Listen('click')\n onClick(event: MouseEvent) {\n this.tabClick.emit(event);\n }\n\n render() {\n return <Host></Host>;\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated file. Do not edit directly.
|
|
3
|
+
*/
|
|
4
|
+
/* stylelint-disable value-keyword-case */
|
|
5
|
+
/* stylelint-enable value-keyword-case */
|
|
6
|
+
:host {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
box-shadow: inset 0 -1px 0 0 #d7dbe0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:host([hidden]) {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:host([tabs-align=center]) {
|
|
17
|
+
justify-content: center;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:host([tabs-align=right]) {
|
|
21
|
+
justify-content: end;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host([tabs-align=justify]) cat-button {
|
|
25
|
+
flex: 1 0 auto;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.tab {
|
|
29
|
+
padding: 0.5rem;
|
|
30
|
+
}
|
|
31
|
+
.tab.tab-active {
|
|
32
|
+
box-shadow: inset 0 -3px 0 0 #207f8a;
|
|
33
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Component, h, Element, State, Watch, Listen, Host, Prop } from '@stencil/core';
|
|
2
|
+
/**
|
|
3
|
+
* Tabs are used to display multiple panels to be contained within a single
|
|
4
|
+
* window, using tabs as a navigational element.
|
|
5
|
+
*
|
|
6
|
+
* @part tab - The header of the tab.
|
|
7
|
+
*/
|
|
8
|
+
export class CatTabs {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.tabs = [];
|
|
11
|
+
this.buttons = [];
|
|
12
|
+
/**
|
|
13
|
+
* The ID of the active tab.
|
|
14
|
+
*/
|
|
15
|
+
this.activeTab = '';
|
|
16
|
+
/**
|
|
17
|
+
* The alignment of the tabs.
|
|
18
|
+
*/
|
|
19
|
+
this.tabsAlign = 'left';
|
|
20
|
+
}
|
|
21
|
+
onActiveTabChanged(newActiveTab) {
|
|
22
|
+
const activeTab = this.tabs.find(value => value.id === newActiveTab);
|
|
23
|
+
activeTab === null || activeTab === void 0 ? void 0 : activeTab.click();
|
|
24
|
+
}
|
|
25
|
+
componentWillLoad() {
|
|
26
|
+
this.tabs = Array.from(this.hostElement.querySelectorAll('cat-tab'));
|
|
27
|
+
if (this.tabs.length) {
|
|
28
|
+
this.activeTabId = this.activeTab;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
onKeydown(event) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft'].includes(event.key)) {
|
|
34
|
+
const targetElements = this.buttons.filter(button => !button.disabled);
|
|
35
|
+
const activeElement = (_a = this.hostElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement;
|
|
36
|
+
const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
|
|
37
|
+
const activeOff = ['ArrowDown', 'ArrowRight'].includes(event.key) ? 1 : -1;
|
|
38
|
+
const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
|
|
39
|
+
targetElements[targetIdx].setFocus();
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
return (h(Host, null, this.tabs.map((tab) => {
|
|
45
|
+
return (h("cat-button", { ref: el => el && this.updateButtonsRef(el), buttonId: tab.id, role: "tab", part: "tab", class: {
|
|
46
|
+
tab: true,
|
|
47
|
+
'tab-active': Boolean(this.activeTabId && tab.id === this.activeTabId)
|
|
48
|
+
}, color: this.activeTabId && tab.id === this.activeTabId ? 'primary' : 'secondary', variant: "text", icon: tab.icon, iconOnly: tab.iconOnly, iconRight: tab.iconRight, url: tab.url, disabled: tab.deactivated, urlTarget: tab.urlTarget, onCatClick: () => (this.activeTabId = tab.id) }, tab.label));
|
|
49
|
+
})));
|
|
50
|
+
}
|
|
51
|
+
updateButtonsRef(button) {
|
|
52
|
+
const indexOf = this.buttons.indexOf(button);
|
|
53
|
+
if (indexOf >= 0) {
|
|
54
|
+
this.buttons[indexOf] = button;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.buttons.push(button);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
static get is() { return "cat-tabs"; }
|
|
61
|
+
static get encapsulation() { return "shadow"; }
|
|
62
|
+
static get originalStyleUrls() { return {
|
|
63
|
+
"$": ["cat-tabs.scss"]
|
|
64
|
+
}; }
|
|
65
|
+
static get styleUrls() { return {
|
|
66
|
+
"$": ["cat-tabs.css"]
|
|
67
|
+
}; }
|
|
68
|
+
static get properties() { return {
|
|
69
|
+
"activeTab": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"mutable": false,
|
|
72
|
+
"complexType": {
|
|
73
|
+
"original": "string",
|
|
74
|
+
"resolved": "string",
|
|
75
|
+
"references": {}
|
|
76
|
+
},
|
|
77
|
+
"required": false,
|
|
78
|
+
"optional": false,
|
|
79
|
+
"docs": {
|
|
80
|
+
"tags": [],
|
|
81
|
+
"text": "The ID of the active tab."
|
|
82
|
+
},
|
|
83
|
+
"attribute": "active-tab",
|
|
84
|
+
"reflect": false,
|
|
85
|
+
"defaultValue": "''"
|
|
86
|
+
},
|
|
87
|
+
"tabsAlign": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"mutable": false,
|
|
90
|
+
"complexType": {
|
|
91
|
+
"original": "'left' | 'center' | 'right' | 'justify'",
|
|
92
|
+
"resolved": "\"center\" | \"justify\" | \"left\" | \"right\"",
|
|
93
|
+
"references": {}
|
|
94
|
+
},
|
|
95
|
+
"required": false,
|
|
96
|
+
"optional": false,
|
|
97
|
+
"docs": {
|
|
98
|
+
"tags": [],
|
|
99
|
+
"text": "The alignment of the tabs."
|
|
100
|
+
},
|
|
101
|
+
"attribute": "tabs-align",
|
|
102
|
+
"reflect": false,
|
|
103
|
+
"defaultValue": "'left'"
|
|
104
|
+
}
|
|
105
|
+
}; }
|
|
106
|
+
static get states() { return {
|
|
107
|
+
"activeTabId": {}
|
|
108
|
+
}; }
|
|
109
|
+
static get elementRef() { return "hostElement"; }
|
|
110
|
+
static get watchers() { return [{
|
|
111
|
+
"propName": "activeTabId",
|
|
112
|
+
"methodName": "onActiveTabChanged"
|
|
113
|
+
}]; }
|
|
114
|
+
static get listeners() { return [{
|
|
115
|
+
"name": "keydown",
|
|
116
|
+
"method": "onKeydown",
|
|
117
|
+
"target": undefined,
|
|
118
|
+
"capture": false,
|
|
119
|
+
"passive": false
|
|
120
|
+
}]; }
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=cat-tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cat-tabs.js","sourceRoot":"","sources":["../../../src/components/cat-tabs/cat-tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAExF;;;;;GAKG;AAMH,MAAM,OAAO,OAAO;EALpB;IAMU,SAAI,GAAwB,EAAE,CAAC;IAC/B,YAAO,GAA2B,EAAE,CAAC;IAM7C;;OAEG;IACK,cAAS,GAAG,EAAE,CAAC;IAEvB;;OAEG;IACK,cAAS,GAA4C,MAAM,CAAC;GAqErE;EAlEC,kBAAkB,CAAC,YAAoB;IACrC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,YAAY,CAAC,CAAC;IACrE,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,EAAE,CAAC;EACrB,CAAC;EAED,iBAAiB;IACf,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;IACrE,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;MACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC;KACnC;EACH,CAAC;EAGD,SAAS,CAAC,KAAoB;;IAC5B,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;MAC3E,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,C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AC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,EAChF,OAAO,EAAC,MAAM,EACd,IAAI,EAAE,GAAG,CAAC,IAAI,EACd,QAAQ,EAAE,GAAG,CAAC,QAAQ,EACtB,SAAS,EAAE,GAAG,CAAC,SAAS,EACxB,GAAG,EAAE,GAAG,CAAC,GAAG,EACZ,QAAQ,EAAE,GAAG,CAAC,WAAW,EACzB,SAAS,EAAE,GAAG,CAAC,SAAS,EACxB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,EAAE,CAAC,IAE5C,GAAG,CAAC,KAAK,CACC,CACd,CAAC;IACJ,CAAC,CAAC,CACG,CACR,CAAC;EACJ,CAAC;EAEO,gBAAgB,CAAC,MAA4B;IACnD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE7C,IAAI,OAAO,IAAI,CAAC,EAAE;MAChB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;KAChC;SAAM;MACL,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAC3B;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Element, State, Watch, Listen, Host, Prop } from '@stencil/core';\n\n/**\n * Tabs are used to display multiple panels to be contained within a single\n * window, using tabs as a navigational element.\n *\n * @part tab - The header of the tab.\n */\n@Component({\n tag: 'cat-tabs',\n styleUrl: 'cat-tabs.scss',\n shadow: true\n})\nexport class CatTabs {\n private tabs: HTMLCatTabElement[] = [];\n private buttons: HTMLCatButtonElement[] = [];\n\n @Element() hostElement!: HTMLElement;\n\n @State() activeTabId?: string;\n\n /**\n * The ID of the active tab.\n */\n @Prop() activeTab = '';\n\n /**\n * The alignment of the tabs.\n */\n @Prop() tabsAlign: 'left' | 'center' | 'right' | 'justify' = 'left';\n\n @Watch('activeTabId')\n onActiveTabChanged(newActiveTab: string): void {\n const activeTab = this.tabs.find(value => value.id === newActiveTab);\n activeTab?.click();\n }\n\n componentWillLoad(): void {\n this.tabs = Array.from(this.hostElement.querySelectorAll('cat-tab'));\n if (this.tabs.length) {\n this.activeTabId = this.activeTab;\n }\n }\n\n @Listen('keydown')\n onKeydown(event: KeyboardEvent): void {\n if (['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft'].includes(event.key)) {\n const targetElements = this.buttons.filter(button => !button.disabled);\n const activeElement = this.hostElement.shadowRoot?.activeElement as HTMLCatButtonElement;\n const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;\n const activeOff = ['ArrowDown', 'ArrowRight'].includes(event.key) ? 1 : -1;\n const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;\n targetElements[targetIdx].setFocus();\n event.preventDefault();\n }\n }\n\n render() {\n return (\n <Host>\n {this.tabs.map((tab: HTMLCatTabElement) => {\n return (\n <cat-button\n ref={el => el && this.updateButtonsRef(el)}\n buttonId={tab.id}\n role=\"tab\"\n part=\"tab\"\n class={{\n tab: true,\n 'tab-active': Boolean(this.activeTabId && tab.id === this.activeTabId)\n }}\n color={this.activeTabId && tab.id === this.activeTabId ? 'primary' : 'secondary'}\n variant=\"text\"\n icon={tab.icon}\n iconOnly={tab.iconOnly}\n iconRight={tab.iconRight}\n url={tab.url}\n disabled={tab.deactivated}\n urlTarget={tab.urlTarget}\n onCatClick={() => (this.activeTabId = tab.id)}\n >\n {tab.label}\n </cat-button>\n );\n })}\n </Host>\n );\n }\n\n private updateButtonsRef(button: HTMLCatButtonElement) {\n const indexOf = this.buttons.indexOf(button);\n\n if (indexOf >= 0) {\n this.buttons[indexOf] = button;\n } else {\n this.buttons.push(button);\n }\n }\n}\n"]}
|
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/* stylelint-disable value-keyword-case */
|
|
5
5
|
/* stylelint-enable value-keyword-case */
|
|
6
|
+
.hint-section {
|
|
7
|
+
display: flex;
|
|
8
|
+
gap: 0.5rem;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
}
|
|
11
|
+
.hint-section .input-hint,
|
|
12
|
+
.hint-section ::slotted([slot=hint]) {
|
|
13
|
+
font-size: 0.875rem;
|
|
14
|
+
line-height: 1rem;
|
|
15
|
+
margin: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
:host {
|
|
7
19
|
display: flex;
|
|
8
20
|
flex-direction: column;
|
|
@@ -63,10 +75,4 @@ textarea:focus {
|
|
|
63
75
|
}
|
|
64
76
|
textarea::placeholder {
|
|
65
77
|
color: rgb(var(--cat-font-color-muted, 105, 118, 135));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.input-hint {
|
|
69
|
-
font-size: 0.875rem;
|
|
70
|
-
line-height: 1rem;
|
|
71
|
-
margin: 0;
|
|
72
78
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { Component, Event, h, Host, Method, Prop } from '@stencil/core';
|
|
2
|
-
import log from 'loglevel';
|
|
1
|
+
import { Component, Element, Event, h, Host, Method, Prop, State } from '@stencil/core';
|
|
3
2
|
import autosize from 'autosize';
|
|
3
|
+
import log from 'loglevel';
|
|
4
|
+
import { CatFormHint } from '../cat-form-hint/cat-form-hint';
|
|
4
5
|
let nextUniqueId = 0;
|
|
5
6
|
/**
|
|
6
7
|
* Textarea specifies a control that allows user to write text over multiple
|
|
7
8
|
* rows. Used when the expected user input is long. For shorter input, use the
|
|
8
9
|
* input component.
|
|
9
10
|
*
|
|
11
|
+
* @slot hint - Optional hint element to be displayed with the textarea.
|
|
12
|
+
* @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.
|
|
10
13
|
* @part label - The label content.
|
|
11
14
|
*/
|
|
12
15
|
export class CatTextarea {
|
|
13
16
|
constructor() {
|
|
14
17
|
this.id = `cat-textarea-${nextUniqueId++}`;
|
|
18
|
+
this.hasSlottedLabel = false;
|
|
15
19
|
/**
|
|
16
20
|
* Whether the textarea is disabled.
|
|
17
21
|
*/
|
|
@@ -42,7 +46,7 @@ export class CatTextarea {
|
|
|
42
46
|
this.rows = 3;
|
|
43
47
|
}
|
|
44
48
|
componentWillRender() {
|
|
45
|
-
if (!this.label) {
|
|
49
|
+
if (!this.label && !this.hostElement.querySelector('[slot="label"]')) {
|
|
46
50
|
log.error('[A11y] Missing ARIA label on textarea', this);
|
|
47
51
|
}
|
|
48
52
|
}
|
|
@@ -58,24 +62,21 @@ export class CatTextarea {
|
|
|
58
62
|
async setFocus(options) {
|
|
59
63
|
this.textarea.focus(options);
|
|
60
64
|
}
|
|
61
|
-
// /**
|
|
62
|
-
// * Clear the input.
|
|
63
|
-
// */
|
|
64
|
-
// @Method()
|
|
65
|
-
// async clear(): Promise<void> {
|
|
66
|
-
// this.inputValue = '';
|
|
67
|
-
// }
|
|
68
65
|
render() {
|
|
69
66
|
return (h(Host, null,
|
|
70
|
-
this.label && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
|
|
67
|
+
(this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
|
|
71
68
|
h("span", { part: "label" },
|
|
72
|
-
this.label,
|
|
69
|
+
(this.hasSlottedLabel && h("slot", { name: "label" })) || this.label,
|
|
73
70
|
!this.required && (h("span", { class: "input-optional", "aria-hidden": "true" }, "(Optional)"))))),
|
|
74
71
|
h("textarea", { ref: el => (this.textarea = el), id: this.id, disabled: this.disabled, maxlength: this.maxLength, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, rows: this.rows, value: this.value, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }),
|
|
75
|
-
this.
|
|
72
|
+
this.hintSection));
|
|
73
|
+
}
|
|
74
|
+
get hintSection() {
|
|
75
|
+
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
76
|
+
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
76
77
|
}
|
|
77
78
|
onInput(event) {
|
|
78
|
-
|
|
79
|
+
this.value = this.textarea.value;
|
|
79
80
|
this.catChange.emit(event);
|
|
80
81
|
}
|
|
81
82
|
onFocus(event) {
|
|
@@ -115,15 +116,15 @@ export class CatTextarea {
|
|
|
115
116
|
"type": "string",
|
|
116
117
|
"mutable": false,
|
|
117
118
|
"complexType": {
|
|
118
|
-
"original": "string",
|
|
119
|
-
"resolved": "string | undefined",
|
|
119
|
+
"original": "string | string[]",
|
|
120
|
+
"resolved": "string | string[] | undefined",
|
|
120
121
|
"references": {}
|
|
121
122
|
},
|
|
122
123
|
"required": false,
|
|
123
124
|
"optional": true,
|
|
124
125
|
"docs": {
|
|
125
126
|
"tags": [],
|
|
126
|
-
"text": "Optional hint text to be displayed with the textarea."
|
|
127
|
+
"text": "Optional hint text(s) to be displayed with the textarea."
|
|
127
128
|
},
|
|
128
129
|
"attribute": "hint",
|
|
129
130
|
"reflect": false
|
|
@@ -289,7 +290,7 @@ export class CatTextarea {
|
|
|
289
290
|
},
|
|
290
291
|
"value": {
|
|
291
292
|
"type": "any",
|
|
292
|
-
"mutable":
|
|
293
|
+
"mutable": true,
|
|
293
294
|
"complexType": {
|
|
294
295
|
"original": "string | number",
|
|
295
296
|
"resolved": "number | string | undefined",
|
|
@@ -305,6 +306,9 @@ export class CatTextarea {
|
|
|
305
306
|
"reflect": false
|
|
306
307
|
}
|
|
307
308
|
}; }
|
|
309
|
+
static get states() { return {
|
|
310
|
+
"hasSlottedLabel": {}
|
|
311
|
+
}; }
|
|
308
312
|
static get events() { return [{
|
|
309
313
|
"method": "catChange",
|
|
310
314
|
"name": "catChange",
|
|
@@ -389,5 +393,6 @@ export class CatTextarea {
|
|
|
389
393
|
}
|
|
390
394
|
}
|
|
391
395
|
}; }
|
|
396
|
+
static get elementRef() { return "hostElement"; }
|
|
392
397
|
}
|
|
393
398
|
//# sourceMappingURL=cat-textarea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-textarea.js","sourceRoot":"","sources":["../../../src/components/cat-textarea/cat-textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"cat-textarea.js","sourceRoot":"","sources":["../../../src/components/cat-textarea/cat-textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;;;GAQG;AAMH,MAAM,OAAO,WAAW;EALxB;IAMmB,OAAE,GAAG,gBAAgB,YAAY,EAAE,EAAE,CAAC;IAK9C,oBAAe,GAAG,KAAK,CAAC;IAEjC;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAOzB;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAEnB;;OAEG;IACK,gBAAW,GAAG,KAAK,CAAC;IAY5B;;OAEG;IACK,SAAI,GAAG,EAAE,CAAC;IAOlB;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,SAAI,GAAG,CAAC,CAAC;GAoGlB;EA9EC,mBAAmB;IACjB,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State } from '@stencil/core';\nimport autosize from 'autosize';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\n\nlet nextUniqueId = 0;\n\n/**\n * Textarea specifies a control that allows user to write text over multiple\n * rows. Used when the expected user input is long. For shorter input, use the\n * input component.\n *\n * @slot hint - Optional hint element to be displayed with the textarea.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-textarea',\n styleUrl: 'cat-textarea.scss',\n shadow: true\n})\nexport class CatTextarea {\n private readonly id = `cat-textarea-${nextUniqueId++}`;\n private textarea!: HTMLTextAreaElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Whether the textarea is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the textarea.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The label for the textarea.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum length (number of characters) for textual values.\n */\n @Prop() maxLength?: number;\n\n /**\n * A minimum length (number of characters) for textual values.\n */\n @Prop() minLength?: number;\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name = '';\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * Specifies the initial number of lines in the textarea.\n */\n @Prop() rows = 3;\n\n /**\n * The initial value of the control.\n */\n @Prop({ mutable: true }) value?: string | number;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the textarea received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the textarea loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n if (!this.label && !this.hostElement.querySelector('[slot=\"label\"]')) {\n log.error('[A11y] Missing ARIA label on textarea', this);\n }\n }\n\n componentDidLoad(): void {\n autosize(this.textarea);\n }\n\n /**\n * Sets focus on the textarea. Use this method instead of `textarea.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async setFocus(options?: FocusOptions): Promise<void> {\n this.textarea.focus(options);\n }\n\n render() {\n return (\n <Host>\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={this.id} class={{ hidden: this.labelHidden }}>\n <span part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n {!this.required && (\n <span class=\"input-optional\" aria-hidden=\"true\">\n (Optional)\n </span>\n )}\n </span>\n </label>\n )}\n <textarea\n ref={el => (this.textarea = el as HTMLTextAreaElement)}\n id={this.id}\n disabled={this.disabled}\n maxlength={this.maxLength}\n minlength={this.minLength}\n name={this.name}\n placeholder={this.placeholder}\n readonly={this.readonly}\n required={this.required}\n rows={this.rows}\n value={this.value}\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n ></textarea>\n {this.hintSection}\n </Host>\n );\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onInput(event: Event) {\n this.value = this.textarea.value;\n this.catChange.emit(event);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"]}
|
|
@@ -3,8 +3,22 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/* stylelint-disable value-keyword-case */
|
|
5
5
|
/* stylelint-enable value-keyword-case */
|
|
6
|
+
.hint-section {
|
|
7
|
+
display: flex;
|
|
8
|
+
gap: 0.5rem;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
}
|
|
11
|
+
.hint-section .input-hint,
|
|
12
|
+
.hint-section ::slotted([slot=hint]) {
|
|
13
|
+
font-size: 0.875rem;
|
|
14
|
+
line-height: 1rem;
|
|
15
|
+
margin: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
:host {
|
|
7
19
|
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: 0.5rem;
|
|
8
22
|
margin-bottom: 1rem;
|
|
9
23
|
}
|
|
10
24
|
|