@haiilo/catalyst 0.4.0 → 0.5.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/index.esm.js +1 -1
- package/dist/catalyst/p-23d54bc6.js +2 -0
- package/dist/catalyst/p-23d54bc6.js.map +1 -0
- package/dist/catalyst/p-84693f87.entry.js +24 -0
- package/dist/catalyst/p-84693f87.entry.js.map +1 -0
- package/dist/catalyst/p-8f5cfa78.js +2 -0
- package/dist/catalyst/p-8f5cfa78.js.map +1 -0
- package/dist/catalyst/{p-ed826597.js → p-fa7da4c6.js} +2 -2
- package/dist/catalyst/p-fa7da4c6.js.map +1 -0
- package/dist/cjs/{app-globals-7f2b1f8e.js → app-globals-50e7504d.js} +9 -2
- package/dist/cjs/app-globals-50e7504d.js.map +1 -0
- package/dist/cjs/{cat-alert_9.cjs.entry.js → cat-alert_15.cjs.entry.js} +449 -354
- package/dist/cjs/cat-alert_15.cjs.entry.js.map +1 -0
- package/dist/cjs/cat-icon-registry-6895750f.js +441 -0
- package/dist/cjs/cat-icon-registry-6895750f.js.map +1 -0
- package/dist/cjs/catalyst.cjs.js +4 -4
- package/dist/cjs/{index-c0881ae0.js → index-2db8e23d.js} +1 -2
- package/dist/cjs/index-2db8e23d.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +4 -4
- package/dist/collection/collection-manifest.json +6 -0
- package/dist/collection/components/cat-alert/cat-alert.css +11 -6
- package/dist/collection/components/cat-alert/cat-alert.js +19 -8
- package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
- package/dist/collection/components/cat-badge/cat-badge.css +17 -17
- package/dist/collection/components/cat-badge/cat-badge.js +9 -8
- package/dist/collection/components/cat-badge/cat-badge.js.map +1 -1
- package/dist/collection/components/cat-button/cat-button.css +18 -8
- package/dist/collection/components/cat-button/cat-button.js +32 -8
- package/dist/collection/components/cat-button/cat-button.js.map +1 -1
- package/dist/collection/components/cat-card/cat-card.css +25 -0
- package/dist/collection/components/cat-card/cat-card.js +20 -0
- package/dist/collection/components/cat-card/cat-card.js.map +1 -0
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +105 -0
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +314 -0
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -0
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js +69 -0
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -0
- package/dist/collection/components/cat-icon/cat-icon-registry.js +14 -1
- package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
- package/dist/collection/components/cat-icon/cat-icon.css +5 -5
- package/dist/collection/components/cat-icon/cat-icon.js +3 -2
- package/dist/collection/components/cat-icon/cat-icon.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.css +131 -0
- package/dist/collection/components/cat-input/cat-input.js +606 -0
- package/dist/collection/components/cat-input/cat-input.js.map +1 -0
- package/dist/collection/components/cat-menu/cat-menu.css +2 -1
- package/dist/collection/components/cat-radio/cat-radio.css +84 -0
- package/dist/collection/components/cat-radio/cat-radio.js +283 -0
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -0
- package/dist/collection/components/cat-scrollable/cat-scrollable.js +4 -2
- package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
- package/dist/collection/components/cat-skeleton/cat-skeleton.css +30 -30
- package/dist/collection/components/cat-skeleton/cat-skeleton.js +4 -4
- package/dist/collection/components/cat-skeleton/cat-skeleton.js.map +1 -1
- package/dist/collection/components/cat-spinner/cat-spinner.css +7 -7
- package/dist/collection/components/cat-spinner/cat-spinner.js +1 -1
- package/dist/collection/components/cat-spinner/cat-spinner.js.map +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.css +74 -0
- package/dist/collection/components/cat-textarea/cat-textarea.js +393 -0
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -0
- package/dist/collection/components/cat-toggle/cat-toggle.css +93 -0
- package/dist/collection/components/cat-toggle/cat-toggle.js +283 -0
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -0
- package/dist/collection/components/cat-tooltip/cat-tooltip.css +9 -5
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +2 -2
- package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/init.js +9 -1
- package/dist/collection/init.js.map +1 -1
- package/dist/components/cat-alert.js +15 -6
- package/dist/components/cat-alert.js.map +1 -1
- package/dist/components/cat-badge.js +7 -7
- package/dist/components/cat-badge.js.map +1 -1
- package/dist/components/cat-button.js +1 -647
- package/dist/components/cat-button.js.map +1 -1
- package/dist/components/cat-button2.js +346 -0
- package/dist/components/cat-button2.js.map +1 -0
- package/dist/components/cat-card.d.ts +11 -0
- package/dist/components/cat-card.js +35 -0
- package/dist/components/cat-card.js.map +1 -0
- package/dist/components/cat-checkbox.d.ts +11 -0
- package/dist/components/cat-checkbox.js +103 -0
- package/dist/components/cat-checkbox.js.map +1 -0
- package/dist/components/cat-i18n-registry.js +73 -0
- package/dist/components/cat-i18n-registry.js.map +1 -0
- package/dist/components/cat-icon-registry.js +15 -1
- package/dist/components/cat-icon-registry.js.map +1 -1
- package/dist/components/cat-icon2.js +3 -2
- package/dist/components/cat-icon2.js.map +1 -1
- package/dist/components/cat-input.d.ts +11 -0
- package/dist/components/cat-input.js +172 -0
- package/dist/components/cat-input.js.map +1 -0
- package/dist/components/cat-menu.js +1 -1
- package/dist/components/cat-menu.js.map +1 -1
- package/dist/components/cat-radio.d.ts +11 -0
- package/dist/components/cat-radio.js +93 -0
- package/dist/components/cat-radio.js.map +1 -0
- package/dist/components/cat-scrollable.js +1 -2
- package/dist/components/cat-scrollable.js.map +1 -1
- package/dist/components/cat-skeleton.js +5 -5
- package/dist/components/cat-skeleton.js.map +1 -1
- package/dist/components/cat-spinner2.js +2 -2
- package/dist/components/cat-spinner2.js.map +1 -1
- package/dist/components/cat-textarea.d.ts +11 -0
- package/dist/components/cat-textarea.js +119 -0
- package/dist/components/cat-textarea.js.map +1 -0
- package/dist/components/cat-toggle.d.ts +11 -0
- package/dist/components/cat-toggle.js +93 -0
- package/dist/components/cat-toggle.js.map +1 -0
- package/dist/components/cat-tooltip.js +2 -2
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/first-tabbable.js +5 -4
- package/dist/components/first-tabbable.js.map +1 -1
- package/dist/components/index.js +9 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/loglevel.js +315 -0
- package/dist/components/loglevel.js.map +1 -0
- package/dist/esm/{app-globals-8af9b2cf.js → app-globals-6906ac5c.js} +9 -2
- package/dist/esm/app-globals-6906ac5c.js.map +1 -0
- package/dist/esm/{cat-alert_9.entry.js → cat-alert_15.entry.js} +442 -353
- package/dist/esm/cat-alert_15.entry.js.map +1 -0
- package/dist/esm/cat-icon-registry-77963c26.js +437 -0
- package/dist/esm/cat-icon-registry-77963c26.js.map +1 -0
- package/dist/esm/catalyst.js +4 -4
- package/dist/esm/{index-0ff35bca.js → index-1f3ca03b.js} +2 -2
- package/dist/esm/index-1f3ca03b.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +4 -4
- package/dist/types/components/cat-alert/cat-alert.d.ts +4 -2
- package/dist/types/components/cat-badge/cat-badge.d.ts +3 -2
- package/dist/types/components/cat-button/cat-button.d.ts +8 -3
- package/dist/types/components/cat-card/cat-card.d.ts +7 -0
- package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +69 -0
- package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +18 -0
- package/dist/types/components/cat-icon/cat-icon-registry.d.ts +4 -4
- package/dist/types/components/cat-icon/cat-icon.d.ts +1 -1
- package/dist/types/components/cat-input/cat-input.d.ts +130 -0
- package/dist/types/components/cat-radio/cat-radio.d.ts +63 -0
- package/dist/types/components/cat-scrollable/cat-scrollable.d.ts +3 -1
- package/dist/types/components/cat-textarea/cat-textarea.d.ts +85 -0
- package/dist/types/components/cat-toggle/cat-toggle.d.ts +64 -0
- package/dist/types/components.d.ts +619 -4
- package/dist/types/index.d.ts +1 -0
- package/package.json +5 -3
- package/dist/catalyst/p-89a97b7b.entry.js +0 -10
- package/dist/catalyst/p-89a97b7b.entry.js.map +0 -1
- package/dist/catalyst/p-ed826597.js.map +0 -1
- package/dist/catalyst/p-ef0a8ae9.js +0 -2
- package/dist/catalyst/p-ef0a8ae9.js.map +0 -1
- package/dist/catalyst/p-f151cb13.js +0 -2
- package/dist/catalyst/p-f151cb13.js.map +0 -1
- package/dist/cjs/app-globals-7f2b1f8e.js.map +0 -1
- package/dist/cjs/cat-alert_9.cjs.entry.js.map +0 -1
- package/dist/cjs/cat-icon-registry-850c538c.js +0 -47
- package/dist/cjs/cat-icon-registry-850c538c.js.map +0 -1
- package/dist/cjs/index-c0881ae0.js.map +0 -1
- package/dist/collection/utils/utils.js +0 -4
- package/dist/collection/utils/utils.js.map +0 -1
- package/dist/esm/app-globals-8af9b2cf.js.map +0 -1
- package/dist/esm/cat-alert_9.entry.js.map +0 -1
- package/dist/esm/cat-icon-registry-59da2e37.js +0 -45
- package/dist/esm/cat-icon-registry-59da2e37.js.map +0 -1
- package/dist/esm/index-0ff35bca.js.map +0 -1
- package/dist/types/utils/utils.d.ts +0 -1
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { Component, Event, h, Method, Prop } from '@stencil/core';
|
|
2
|
+
import log from 'loglevel';
|
|
3
|
+
let nextUniqueId = 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checkboxes are used to let a user choose one or more options from a limited
|
|
6
|
+
* number of options.
|
|
7
|
+
*
|
|
8
|
+
* @part checkbox - The checkbox element.
|
|
9
|
+
* @part label - The label content.
|
|
10
|
+
*/
|
|
11
|
+
export class CatCheckbox {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.id = `cat-checkbox-${nextUniqueId++}`;
|
|
14
|
+
/**
|
|
15
|
+
* Checked state of the checkbox
|
|
16
|
+
*/
|
|
17
|
+
this.checked = false;
|
|
18
|
+
/**
|
|
19
|
+
* Disabled state of the checkbox
|
|
20
|
+
*/
|
|
21
|
+
this.disabled = false;
|
|
22
|
+
/**
|
|
23
|
+
* Indeterminate state of the checkbox
|
|
24
|
+
*/
|
|
25
|
+
this.indeterminate = false;
|
|
26
|
+
/**
|
|
27
|
+
* Label of the checkbox which is presented in the UI
|
|
28
|
+
*/
|
|
29
|
+
this.label = '';
|
|
30
|
+
/**
|
|
31
|
+
* Visually hide the label, but still show it to assistive technologies like screen readers.
|
|
32
|
+
*/
|
|
33
|
+
this.labelHidden = false;
|
|
34
|
+
/**
|
|
35
|
+
* Required state of the checkbox
|
|
36
|
+
*/
|
|
37
|
+
this.required = false;
|
|
38
|
+
}
|
|
39
|
+
componentDidLoad() {
|
|
40
|
+
if (this.input && this.indeterminate) {
|
|
41
|
+
this.input.indeterminate = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
componentWillRender() {
|
|
45
|
+
if (!this.label) {
|
|
46
|
+
log.error('[A11y] Missing ARIA label on checkbox', this);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets focus on the checkbox. Use this method instead of `checkbox.focus()`.
|
|
51
|
+
*
|
|
52
|
+
* @param options An optional object providing options to control aspects of
|
|
53
|
+
* the focusing process.
|
|
54
|
+
*/
|
|
55
|
+
async setFocus(options) {
|
|
56
|
+
this.input.focus(options);
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
return (h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } },
|
|
60
|
+
h("input", { ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }),
|
|
61
|
+
h("span", { class: "box", "aria-hidden": "true", part: "checkbox" },
|
|
62
|
+
h("svg", { class: "check", viewBox: "0 0 12 10" },
|
|
63
|
+
h("polyline", { points: "1.5 6 4.5 9 10.5 1" })),
|
|
64
|
+
h("svg", { class: "dash", viewBox: "0 0 12 10" },
|
|
65
|
+
h("polyline", { points: "1.5 5 10.5 5" }))),
|
|
66
|
+
h("span", { class: "label", part: "label" }, this.label)));
|
|
67
|
+
}
|
|
68
|
+
onInput(event) {
|
|
69
|
+
this.catChange.emit(event);
|
|
70
|
+
}
|
|
71
|
+
onFocus(event) {
|
|
72
|
+
this.catFocus.emit(event);
|
|
73
|
+
}
|
|
74
|
+
onBlur(event) {
|
|
75
|
+
this.catBlur.emit(event);
|
|
76
|
+
}
|
|
77
|
+
static get is() { return "cat-checkbox"; }
|
|
78
|
+
static get encapsulation() { return "shadow"; }
|
|
79
|
+
static get originalStyleUrls() { return {
|
|
80
|
+
"$": ["cat-checkbox.scss"]
|
|
81
|
+
}; }
|
|
82
|
+
static get styleUrls() { return {
|
|
83
|
+
"$": ["cat-checkbox.css"]
|
|
84
|
+
}; }
|
|
85
|
+
static get properties() { return {
|
|
86
|
+
"checked": {
|
|
87
|
+
"type": "boolean",
|
|
88
|
+
"mutable": false,
|
|
89
|
+
"complexType": {
|
|
90
|
+
"original": "boolean",
|
|
91
|
+
"resolved": "boolean",
|
|
92
|
+
"references": {}
|
|
93
|
+
},
|
|
94
|
+
"required": false,
|
|
95
|
+
"optional": false,
|
|
96
|
+
"docs": {
|
|
97
|
+
"tags": [],
|
|
98
|
+
"text": "Checked state of the checkbox"
|
|
99
|
+
},
|
|
100
|
+
"attribute": "checked",
|
|
101
|
+
"reflect": false,
|
|
102
|
+
"defaultValue": "false"
|
|
103
|
+
},
|
|
104
|
+
"disabled": {
|
|
105
|
+
"type": "boolean",
|
|
106
|
+
"mutable": false,
|
|
107
|
+
"complexType": {
|
|
108
|
+
"original": "boolean",
|
|
109
|
+
"resolved": "boolean",
|
|
110
|
+
"references": {}
|
|
111
|
+
},
|
|
112
|
+
"required": false,
|
|
113
|
+
"optional": false,
|
|
114
|
+
"docs": {
|
|
115
|
+
"tags": [],
|
|
116
|
+
"text": "Disabled state of the checkbox"
|
|
117
|
+
},
|
|
118
|
+
"attribute": "disabled",
|
|
119
|
+
"reflect": false,
|
|
120
|
+
"defaultValue": "false"
|
|
121
|
+
},
|
|
122
|
+
"indeterminate": {
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"mutable": false,
|
|
125
|
+
"complexType": {
|
|
126
|
+
"original": "boolean",
|
|
127
|
+
"resolved": "boolean",
|
|
128
|
+
"references": {}
|
|
129
|
+
},
|
|
130
|
+
"required": false,
|
|
131
|
+
"optional": false,
|
|
132
|
+
"docs": {
|
|
133
|
+
"tags": [],
|
|
134
|
+
"text": "Indeterminate state of the checkbox"
|
|
135
|
+
},
|
|
136
|
+
"attribute": "indeterminate",
|
|
137
|
+
"reflect": false,
|
|
138
|
+
"defaultValue": "false"
|
|
139
|
+
},
|
|
140
|
+
"label": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"mutable": false,
|
|
143
|
+
"complexType": {
|
|
144
|
+
"original": "string",
|
|
145
|
+
"resolved": "string",
|
|
146
|
+
"references": {}
|
|
147
|
+
},
|
|
148
|
+
"required": false,
|
|
149
|
+
"optional": false,
|
|
150
|
+
"docs": {
|
|
151
|
+
"tags": [],
|
|
152
|
+
"text": "Label of the checkbox which is presented in the UI"
|
|
153
|
+
},
|
|
154
|
+
"attribute": "label",
|
|
155
|
+
"reflect": false,
|
|
156
|
+
"defaultValue": "''"
|
|
157
|
+
},
|
|
158
|
+
"labelHidden": {
|
|
159
|
+
"type": "boolean",
|
|
160
|
+
"mutable": false,
|
|
161
|
+
"complexType": {
|
|
162
|
+
"original": "boolean",
|
|
163
|
+
"resolved": "boolean",
|
|
164
|
+
"references": {}
|
|
165
|
+
},
|
|
166
|
+
"required": false,
|
|
167
|
+
"optional": false,
|
|
168
|
+
"docs": {
|
|
169
|
+
"tags": [],
|
|
170
|
+
"text": "Visually hide the label, but still show it to assistive technologies like screen readers."
|
|
171
|
+
},
|
|
172
|
+
"attribute": "label-hidden",
|
|
173
|
+
"reflect": false,
|
|
174
|
+
"defaultValue": "false"
|
|
175
|
+
},
|
|
176
|
+
"name": {
|
|
177
|
+
"type": "string",
|
|
178
|
+
"mutable": false,
|
|
179
|
+
"complexType": {
|
|
180
|
+
"original": "string",
|
|
181
|
+
"resolved": "string | undefined",
|
|
182
|
+
"references": {}
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"optional": true,
|
|
186
|
+
"docs": {
|
|
187
|
+
"tags": [],
|
|
188
|
+
"text": "The name of the input"
|
|
189
|
+
},
|
|
190
|
+
"attribute": "name",
|
|
191
|
+
"reflect": false
|
|
192
|
+
},
|
|
193
|
+
"required": {
|
|
194
|
+
"type": "boolean",
|
|
195
|
+
"mutable": false,
|
|
196
|
+
"complexType": {
|
|
197
|
+
"original": "boolean",
|
|
198
|
+
"resolved": "boolean",
|
|
199
|
+
"references": {}
|
|
200
|
+
},
|
|
201
|
+
"required": false,
|
|
202
|
+
"optional": false,
|
|
203
|
+
"docs": {
|
|
204
|
+
"tags": [],
|
|
205
|
+
"text": "Required state of the checkbox"
|
|
206
|
+
},
|
|
207
|
+
"attribute": "required",
|
|
208
|
+
"reflect": false,
|
|
209
|
+
"defaultValue": "false"
|
|
210
|
+
},
|
|
211
|
+
"value": {
|
|
212
|
+
"type": "string",
|
|
213
|
+
"mutable": false,
|
|
214
|
+
"complexType": {
|
|
215
|
+
"original": "string",
|
|
216
|
+
"resolved": "string | undefined",
|
|
217
|
+
"references": {}
|
|
218
|
+
},
|
|
219
|
+
"required": false,
|
|
220
|
+
"optional": true,
|
|
221
|
+
"docs": {
|
|
222
|
+
"tags": [],
|
|
223
|
+
"text": "The value of the checkbox"
|
|
224
|
+
},
|
|
225
|
+
"attribute": "value",
|
|
226
|
+
"reflect": false
|
|
227
|
+
}
|
|
228
|
+
}; }
|
|
229
|
+
static get events() { return [{
|
|
230
|
+
"method": "catChange",
|
|
231
|
+
"name": "catChange",
|
|
232
|
+
"bubbles": true,
|
|
233
|
+
"cancelable": true,
|
|
234
|
+
"composed": true,
|
|
235
|
+
"docs": {
|
|
236
|
+
"tags": [],
|
|
237
|
+
"text": "Emitted when the checked status of the checkbox is changed."
|
|
238
|
+
},
|
|
239
|
+
"complexType": {
|
|
240
|
+
"original": "any",
|
|
241
|
+
"resolved": "any",
|
|
242
|
+
"references": {}
|
|
243
|
+
}
|
|
244
|
+
}, {
|
|
245
|
+
"method": "catFocus",
|
|
246
|
+
"name": "catFocus",
|
|
247
|
+
"bubbles": true,
|
|
248
|
+
"cancelable": true,
|
|
249
|
+
"composed": true,
|
|
250
|
+
"docs": {
|
|
251
|
+
"tags": [],
|
|
252
|
+
"text": "Emitted when the checkbox received focus."
|
|
253
|
+
},
|
|
254
|
+
"complexType": {
|
|
255
|
+
"original": "FocusEvent",
|
|
256
|
+
"resolved": "FocusEvent",
|
|
257
|
+
"references": {
|
|
258
|
+
"FocusEvent": {
|
|
259
|
+
"location": "global"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}, {
|
|
264
|
+
"method": "catBlur",
|
|
265
|
+
"name": "catBlur",
|
|
266
|
+
"bubbles": true,
|
|
267
|
+
"cancelable": true,
|
|
268
|
+
"composed": true,
|
|
269
|
+
"docs": {
|
|
270
|
+
"tags": [],
|
|
271
|
+
"text": "Emitted when the checkbox loses focus."
|
|
272
|
+
},
|
|
273
|
+
"complexType": {
|
|
274
|
+
"original": "FocusEvent",
|
|
275
|
+
"resolved": "FocusEvent",
|
|
276
|
+
"references": {
|
|
277
|
+
"FocusEvent": {
|
|
278
|
+
"location": "global"
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}]; }
|
|
283
|
+
static get methods() { return {
|
|
284
|
+
"setFocus": {
|
|
285
|
+
"complexType": {
|
|
286
|
+
"signature": "(options?: FocusOptions | undefined) => Promise<void>",
|
|
287
|
+
"parameters": [{
|
|
288
|
+
"tags": [{
|
|
289
|
+
"name": "param",
|
|
290
|
+
"text": "options An optional object providing options to control aspects of\nthe focusing process."
|
|
291
|
+
}],
|
|
292
|
+
"text": "An optional object providing options to control aspects of\nthe focusing process."
|
|
293
|
+
}],
|
|
294
|
+
"references": {
|
|
295
|
+
"Promise": {
|
|
296
|
+
"location": "global"
|
|
297
|
+
},
|
|
298
|
+
"FocusOptions": {
|
|
299
|
+
"location": "global"
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
"return": "Promise<void>"
|
|
303
|
+
},
|
|
304
|
+
"docs": {
|
|
305
|
+
"text": "Sets focus on the checkbox. Use this method instead of `checkbox.focus()`.",
|
|
306
|
+
"tags": [{
|
|
307
|
+
"name": "param",
|
|
308
|
+
"text": "options An optional object providing options to control aspects of\nthe focusing process."
|
|
309
|
+
}]
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}; }
|
|
313
|
+
}
|
|
314
|
+
//# sourceMappingURL=cat-checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cat-checkbox.js","sourceRoot":"","sources":["../../../src/components/cat-checkbox/cat-checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;GAMG;AAMH,MAAM,OAAO,WAAW;EALxB;IAMmB,OAAE,GAAG,gBAAgB,YAAY,EAAE,EAAE,CAAC;IAGvD;;OAEG;IACK,YAAO,GAAG,KAAK,CAAC;IAExB;;OAEG;IACK,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,IAAI,CAAC,EAChC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAC9B;MACF,YAAM,KAAK,EAAC,KAAK,iBAAa,MAAM,EAAC,IAAI,EAAC,UAAU;QAClD,WAAK,KAAK,EAAC,OAAO,EAAC,OAAO,EAAC,WAAW;UACpC,gBAAU,MAAM,EAAC,oBAAoB,GAAY,CAC7C;QACN,WAAK,KAAK,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW;UACnC,gBAAU,MAAM,EAAC,cAAc,GAAY,CACvC,CACD;MACP,YAAM,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,OAAO,IAC7B,IAAI,CAAC,KAAK,CACN,CACD,CACT,CAAC;EACJ,CAAC;EAEO,OAAO,CAAC,KAAY;IAC1B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC7B,CAAC;EAEO,OAAO,CAAC,KAAiB;IAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC5B,CAAC;EAEO,MAAM,CAAC,KAAiB;IAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC3B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, h, Method, Prop } from '@stencil/core';\nimport log from 'loglevel';\n\nlet nextUniqueId = 0;\n\n/**\n * Checkboxes are used to let a user choose one or more options from a limited\n * number of options.\n *\n * @part checkbox - The checkbox element.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-checkbox',\n styleUrls: ['cat-checkbox.scss'],\n shadow: true\n})\nexport class CatCheckbox {\n private readonly id = `cat-checkbox-${nextUniqueId++}`;\n private input!: HTMLInputElement;\n\n /**\n * Checked state of the checkbox\n */\n @Prop() checked = false;\n\n /**\n * Disabled state of the checkbox\n */\n @Prop() disabled = false;\n\n /**\n * Indeterminate state of the checkbox\n */\n @Prop() indeterminate = false;\n\n /**\n * Label of the checkbox which is presented in the UI\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 * The name of the input\n */\n @Prop() name?: string;\n\n /**\n * Required state of the checkbox\n */\n @Prop() required = false;\n\n /**\n * The value of the checkbox\n */\n @Prop() value?: string;\n\n /**\n * Emitted when the checked status of the checkbox is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the checkbox received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the checkbox loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentDidLoad() {\n if (this.input && this.indeterminate) {\n this.input.indeterminate = true;\n }\n }\n\n componentWillRender(): void {\n if (!this.label) {\n log.error('[A11y] Missing ARIA label on checkbox', this);\n }\n }\n\n /**\n * Sets focus on the checkbox. Use this method instead of `checkbox.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.input.focus(options);\n }\n\n render() {\n return (\n <label htmlFor={this.id} class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled }}>\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n type=\"checkbox\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n required={this.required}\n disabled={this.disabled}\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n />\n <span class=\"box\" aria-hidden=\"true\" part=\"checkbox\">\n <svg class=\"check\" viewBox=\"0 0 12 10\">\n <polyline points=\"1.5 6 4.5 9 10.5 1\"></polyline>\n </svg>\n <svg class=\"dash\" viewBox=\"0 0 12 10\">\n <polyline points=\"1.5 5 10.5 5\"></polyline>\n </svg>\n </span>\n <span class=\"label\" part=\"label\">\n {this.label}\n </span>\n </label>\n );\n }\n\n private onInput(event: Event) {\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"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import log from 'loglevel';
|
|
2
|
+
export class CatI18nRegistry {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.lang = 'en';
|
|
5
|
+
this.messages = new Map();
|
|
6
|
+
// hide constructor
|
|
7
|
+
}
|
|
8
|
+
static getInstance() {
|
|
9
|
+
if (!CatI18nRegistry.instance) {
|
|
10
|
+
CatI18nRegistry.instance = new CatI18nRegistry();
|
|
11
|
+
}
|
|
12
|
+
return CatI18nRegistry.instance;
|
|
13
|
+
}
|
|
14
|
+
getLanguage() {
|
|
15
|
+
return this.lang;
|
|
16
|
+
}
|
|
17
|
+
setLanguage(lang) {
|
|
18
|
+
this.lang = lang;
|
|
19
|
+
}
|
|
20
|
+
getMessage(key) {
|
|
21
|
+
var _a;
|
|
22
|
+
const message = (_a = this.messages.get(this.lang)) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
23
|
+
if (!message) {
|
|
24
|
+
log.error(`[CatI18nRegistry] Unknown message for lang ${this.lang}: ${key}`);
|
|
25
|
+
}
|
|
26
|
+
return message;
|
|
27
|
+
}
|
|
28
|
+
addMessage(lang, key, message) {
|
|
29
|
+
this.getDict(lang).set(key, message);
|
|
30
|
+
log.info(`[CatI18nRegistry] Added message for lang ${lang}: ${key}`);
|
|
31
|
+
window.dispatchEvent(this.buildEvent('cat-i18n-added', { lang, key }));
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
addMessages(lang, i18n) {
|
|
35
|
+
this.messages.set(lang, Object.assign(Object.assign({}, this.getDict(lang)), i18n));
|
|
36
|
+
log.info(`[CatI18nRegistry] Added message for lang ${lang}: ${Object.keys(i18n).concat(', ')}`);
|
|
37
|
+
window.dispatchEvent(this.buildEvent('cat-i18n-added', { lang, keys: Object.keys(i18n) }));
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
removeMessage(lang, key) {
|
|
41
|
+
this.getDict(lang).delete(key);
|
|
42
|
+
log.info(`[CatI18nRegistry] Removed message for lang ${lang}: ${key}`);
|
|
43
|
+
window.dispatchEvent(this.buildEvent('cat-i18n-removed', { lang, key }));
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
removeMessages(lang, keys) {
|
|
47
|
+
const dict = this.getDict(lang);
|
|
48
|
+
keys.forEach(key => dict.delete(key));
|
|
49
|
+
log.info(`[CatI18nRegistry] Removed messages for lang ${lang}: ${keys.concat(', ')}`);
|
|
50
|
+
window.dispatchEvent(this.buildEvent('cat-i18n-added', { lang, keys }));
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
buildEvent(name, detail) {
|
|
54
|
+
return new CustomEvent(name, {
|
|
55
|
+
bubbles: true,
|
|
56
|
+
composed: true,
|
|
57
|
+
detail
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
getDict(lang) {
|
|
61
|
+
let messages = this.messages.get(lang);
|
|
62
|
+
if (!messages) {
|
|
63
|
+
messages = new Map();
|
|
64
|
+
this.messages.set(lang, messages);
|
|
65
|
+
}
|
|
66
|
+
return messages;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=cat-i18n-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cat-i18n-registry.js","sourceRoot":"","sources":["../../../src/components/cat-i18n/cat-i18n-registry.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MA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OAAO,IAAI,WAAW,CAAC,IAAI,EAAE;MAC3B,OAAO,EAAE,IAAI;MACb,QAAQ,EAAE,IAAI;MACd,MAAM;KACP,CAAC,CAAC;EACL,CAAC;EAEO,OAAO,CAAC,IAAY;IAC1B,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,QAAQ,EAAE;MACb,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;MACrB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KACnC;IACD,OAAO,QAAQ,CAAC;EAClB,CAAC;CACF","sourcesContent":["import log from 'loglevel';\n\nexport class CatI18nRegistry {\n private static instance: CatI18nRegistry;\n\n private lang = 'en';\n private readonly messages: Map<string, Map<string, string>> = new Map();\n\n private constructor() {\n // hide constructor\n }\n\n static getInstance(): CatI18nRegistry {\n if (!CatI18nRegistry.instance) {\n CatI18nRegistry.instance = new CatI18nRegistry();\n }\n return CatI18nRegistry.instance;\n }\n\n getLanguage(): string {\n return this.lang;\n }\n\n setLanguage(lang: string): void {\n this.lang = lang;\n }\n\n getMessage(key: string): string | undefined {\n const message = this.messages.get(this.lang)?.get(key);\n if (!message) {\n log.error(`[CatI18nRegistry] Unknown message for lang ${this.lang}: ${key}`);\n }\n return message;\n }\n\n addMessage(lang: string, key: string, message: string): CatI18nRegistry {\n this.getDict(lang).set(key, message);\n log.info(`[CatI18nRegistry] Added message for lang ${lang}: ${key}`);\n window.dispatchEvent(this.buildEvent('cat-i18n-added', { lang, key }));\n return this;\n }\n\n addMessages(lang: string, i18n: { [key: string]: string }): CatI18nRegistry {\n this.messages.set(lang, { ...this.getDict(lang), ...i18n });\n log.info(`[CatI18nRegistry] Added message for lang ${lang}: ${Object.keys(i18n).concat(', ')}`);\n window.dispatchEvent(this.buildEvent('cat-i18n-added', { lang, keys: Object.keys(i18n) }));\n return this;\n }\n\n removeMessage(lang: string, key: string): CatI18nRegistry {\n this.getDict(lang).delete(key);\n log.info(`[CatI18nRegistry] Removed message for lang ${lang}: ${key}`);\n window.dispatchEvent(this.buildEvent('cat-i18n-removed', { lang, key }));\n return this;\n }\n\n removeMessages(lang: string, keys: string[]): CatI18nRegistry {\n const dict = this.getDict(lang);\n keys.forEach(key => dict.delete(key));\n log.info(`[CatI18nRegistry] Removed messages for lang ${lang}: ${keys.concat(', ')}`);\n window.dispatchEvent(this.buildEvent('cat-i18n-added', { lang, keys }));\n return this;\n }\n\n private buildEvent<T>(name: string, detail?: T) {\n return new CustomEvent(name, {\n bubbles: true,\n composed: true,\n detail\n });\n }\n\n private getDict(lang: string) {\n let messages = this.messages.get(lang);\n if (!messages) {\n messages = new Map();\n this.messages.set(lang, messages);\n }\n return messages;\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import log from 'loglevel';
|
|
1
2
|
export class CatIconRegistry {
|
|
2
3
|
constructor() {
|
|
3
4
|
this.icons = new Map();
|
|
@@ -10,23 +11,35 @@ export class CatIconRegistry {
|
|
|
10
11
|
return CatIconRegistry.instance;
|
|
11
12
|
}
|
|
12
13
|
getIcon(name, setName) {
|
|
13
|
-
|
|
14
|
+
const icon = this.icons.get(this.buildName(name, setName));
|
|
15
|
+
if (!icon) {
|
|
16
|
+
log.error(`[CatIconRegistry] Unknown icon${setName ? ` in set ${setName}` : ''}: ${name}`);
|
|
17
|
+
}
|
|
18
|
+
return icon;
|
|
14
19
|
}
|
|
15
20
|
addIcon(name, data, setName) {
|
|
16
21
|
this.icons.set(this.buildName(name, setName), data);
|
|
22
|
+
log.info(`[CatIconRegistry] Added icon${setName ? ` to set ${setName}` : ''}: ${name}`);
|
|
17
23
|
window.dispatchEvent(this.buildEvent('cat-icon-added', { name, setName }));
|
|
24
|
+
return this;
|
|
18
25
|
}
|
|
19
26
|
addIcons(icons, setName) {
|
|
20
27
|
Object.entries(icons).forEach(([name, data]) => this.icons.set(this.buildName(name, setName), data));
|
|
28
|
+
log.info(`[CatIconRegistry] Added icons${setName ? ` to set ${setName}` : ''}: ${Object.keys(icons).concat(', ')}`);
|
|
21
29
|
window.dispatchEvent(this.buildEvent('cat-icons-added', { names: Object.keys(icons), setName }));
|
|
30
|
+
return this;
|
|
22
31
|
}
|
|
23
32
|
removeIcon(name, setName) {
|
|
24
33
|
this.icons.delete(this.buildName(name, setName));
|
|
34
|
+
log.info(`[CatIconRegistry] Removed icon${setName ? ` from set ${setName}` : ''}: ${name}`);
|
|
25
35
|
window.dispatchEvent(this.buildEvent('cat-icon-removed', { name, setName }));
|
|
36
|
+
return this;
|
|
26
37
|
}
|
|
27
38
|
removeIcons(names, setName) {
|
|
28
39
|
names.forEach(name => this.icons.delete(this.buildName(name, setName)));
|
|
40
|
+
log.info(`[CatIconRegistry] Removed icons${setName ? ` from set ${setName}` : ''}: ${names.concat(', ')}`);
|
|
29
41
|
window.dispatchEvent(this.buildEvent('cat-icons-removed', { names, setName }));
|
|
42
|
+
return this;
|
|
30
43
|
}
|
|
31
44
|
buildName(name, setName) {
|
|
32
45
|
return setName ? `${setName}:name` : name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-icon-registry.js","sourceRoot":"","sources":["../../../src/components/cat-icon/cat-icon-registry.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;EAK1B;IAFiB,UAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;IAGtD,mBAAmB;EACrB,CAAC;EAED,MAAM,CAAC,WAAW;IAChB,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;MAC7B,eAAe,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;KAClD;IACD,OAAO,eAAe,CAAC,QAAQ,CAAC;EAClC,CAAC;EAED,OAAO,CAAC,IAAY,EAAE,OAAgB;IACpC,
|
|
1
|
+
{"version":3,"file":"cat-icon-registry.js","sourceRoot":"","sources":["../../../src/components/cat-icon/cat-icon-registry.ts"],"names":[],"m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AAC,CAAC,aAAa,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3G,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC/E,OAAO,IAAI,CAAC;EACd,CAAC;EAEO,SAAS,CAAC,IAAY,EAAE,OAAgB;IAC9C,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;EAC5C,CAAC;EAEO,UAAU,CAAI,IAAY,EAAE,MAAU;IAC5C,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE;MAC3B,OAAO,EAAE,IAAI;MACb,QAAQ,EAAE,IAAI;MACd,MAAM;KACP,CAAC,CAAC;EACL,CAAC;CACF","sourcesContent":["import log from 'loglevel';\n\nexport class CatIconRegistry {\n private static instance: CatIconRegistry;\n\n private readonly icons: Map<string, string> = new Map();\n\n private constructor() {\n // hide constructor\n }\n\n static getInstance(): CatIconRegistry {\n if (!CatIconRegistry.instance) {\n CatIconRegistry.instance = new CatIconRegistry();\n }\n return CatIconRegistry.instance;\n }\n\n getIcon(name: string, setName?: string): string | undefined {\n const icon = this.icons.get(this.buildName(name, setName));\n if (!icon) {\n log.error(`[CatIconRegistry] Unknown icon${setName ? ` in set ${setName}` : ''}: ${name}`);\n }\n return icon;\n }\n\n addIcon(name: string, data: string, setName?: string): CatIconRegistry {\n this.icons.set(this.buildName(name, setName), data);\n log.info(`[CatIconRegistry] Added icon${setName ? ` to set ${setName}` : ''}: ${name}`);\n window.dispatchEvent(this.buildEvent('cat-icon-added', { name, setName }));\n return this;\n }\n\n addIcons(icons: { [name: string]: string }, setName?: string): CatIconRegistry {\n Object.entries(icons).forEach(([name, data]) => this.icons.set(this.buildName(name, setName), data));\n log.info(`[CatIconRegistry] Added icons${setName ? ` to set ${setName}` : ''}: ${Object.keys(icons).concat(', ')}`);\n window.dispatchEvent(this.buildEvent('cat-icons-added', { names: Object.keys(icons), setName }));\n return this;\n }\n\n removeIcon(name: string, setName?: string): CatIconRegistry {\n this.icons.delete(this.buildName(name, setName));\n log.info(`[CatIconRegistry] Removed icon${setName ? ` from set ${setName}` : ''}: ${name}`);\n window.dispatchEvent(this.buildEvent('cat-icon-removed', { name, setName }));\n return this;\n }\n\n removeIcons(names: string[], setName?: string): CatIconRegistry {\n names.forEach(name => this.icons.delete(this.buildName(name, setName)));\n log.info(`[CatIconRegistry] Removed icons${setName ? ` from set ${setName}` : ''}: ${names.concat(', ')}`);\n window.dispatchEvent(this.buildEvent('cat-icons-removed', { names, setName }));\n return this;\n }\n\n private buildName(name: string, setName?: string) {\n return setName ? `${setName}:name` : name;\n }\n\n private buildEvent<T>(name: string, detail?: T) {\n return new CustomEvent(name, {\n bubbles: true,\n composed: true,\n detail\n });\n }\n}\n"]}
|
|
@@ -29,22 +29,22 @@ svg {
|
|
|
29
29
|
height: 1em;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.
|
|
32
|
+
.icon-xs svg {
|
|
33
33
|
font-size: 0.75rem;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.
|
|
36
|
+
.icon-s svg {
|
|
37
37
|
font-size: 1rem;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.
|
|
40
|
+
.icon-m svg {
|
|
41
41
|
font-size: 1.25rem;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.
|
|
44
|
+
.icon-l svg {
|
|
45
45
|
font-size: 1.5rem;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
.
|
|
48
|
+
.icon-xl svg {
|
|
49
49
|
font-size: 1.75rem;
|
|
50
50
|
}
|
|
@@ -4,7 +4,7 @@ import { CatIconRegistry } from './cat-icon-registry';
|
|
|
4
4
|
* Icons are used to provide additional meaning or in places where text label
|
|
5
5
|
* doesn't fit.
|
|
6
6
|
*
|
|
7
|
-
* @part icon - The
|
|
7
|
+
* @part icon - The span element wrapping the SVG icon.
|
|
8
8
|
*/
|
|
9
9
|
export class CatIcon {
|
|
10
10
|
constructor() {
|
|
@@ -20,7 +20,8 @@ export class CatIcon {
|
|
|
20
20
|
}
|
|
21
21
|
render() {
|
|
22
22
|
return (h("span", { innerHTML: this.iconRegistry.getIcon(this.icon), "aria-label": this.a11yLabel, "aria-hidden": this.a11yLabel ? null : 'true', part: "icon", class: {
|
|
23
|
-
|
|
23
|
+
icon: true,
|
|
24
|
+
[`icon-${this.size}`]: this.size !== 'inline'
|
|
24
25
|
} }));
|
|
25
26
|
}
|
|
26
27
|
static get is() { return "cat-icon"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-icon.js","sourceRoot":"","sources":["../../../src/components/cat-icon/cat-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;GAKG;AAMH,MAAM,OAAO,OAAO;EALpB;IAMmB,iBAAY,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IAE9D;;OAEG;IACK,SAAI,GAAG,EAAE,CAAC;IAElB;;OAEG;IACK,SAAI,GAA6C,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"cat-icon.js","sourceRoot":"","sources":["../../../src/components/cat-icon/cat-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;GAKG;AAMH,MAAM,OAAO,OAAO;EALpB;IAMmB,iBAAY,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IAE9D;;OAEG;IACK,SAAI,GAAG,EAAE,CAAC;IAElB;;OAEG;IACK,SAAI,GAA6C,GAAG,CAAC;GAsB9D;EAdC,MAAM;IACJ,OAAO,CACL,YACE,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,gBACnC,IAAI,CAAC,SAAS,iBACb,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAC3C,IAAI,EAAC,MAAM,EACX,KAAK,EAAE;QACL,IAAI,EAAE,IAAI;QACV,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,KAAK,QAAQ;OAC9C,GACK,CACT,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop } from '@stencil/core';\nimport { CatIconRegistry } from './cat-icon-registry';\n\n/**\n * Icons are used to provide additional meaning or in places where text label\n * doesn't fit.\n *\n * @part icon - The span element wrapping the SVG icon.\n */\n@Component({\n tag: 'cat-icon',\n styleUrl: 'cat-icon.scss',\n shadow: true\n})\nexport class CatIcon {\n private readonly iconRegistry = CatIconRegistry.getInstance();\n\n /**\n * The name of the icon.\n */\n @Prop() icon = '';\n\n /**\n * The size of the icon.\n */\n @Prop() size: 'xs' | 's' | 'm' | 'l' | 'xl' | 'inline' = 'm';\n\n /**\n * Adds accessible label for the icon that is only shown for screen\n * readers. The `aria-hidden` attribute will be set if no label is present.\n */\n @Prop({ attribute: 'a11y-label' }) a11yLabel?: string;\n\n render() {\n return (\n <span\n innerHTML={this.iconRegistry.getIcon(this.icon)}\n aria-label={this.a11yLabel}\n aria-hidden={this.a11yLabel ? null : 'true'}\n part=\"icon\"\n class={{\n icon: true,\n [`icon-${this.size}`]: this.size !== 'inline'\n }}\n ></span>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,131 @@
|
|
|
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: column;
|
|
9
|
+
gap: 0.5rem;
|
|
10
|
+
font-size: 0.9375rem;
|
|
11
|
+
line-height: 1.25rem;
|
|
12
|
+
margin-bottom: 1rem;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:host([hidden]) {
|
|
16
|
+
display: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.input-wrapper {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: stretch;
|
|
22
|
+
gap: 0.5rem;
|
|
23
|
+
padding: 0 0.75rem;
|
|
24
|
+
height: 2.5rem;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
background: white;
|
|
27
|
+
border-radius: 0.25rem;
|
|
28
|
+
box-shadow: 0 0 0 1px #d7dbe0;
|
|
29
|
+
transition: box-shadow 0.13s linear;
|
|
30
|
+
}
|
|
31
|
+
.input-wrapper.input-round {
|
|
32
|
+
border-radius: 10rem;
|
|
33
|
+
}
|
|
34
|
+
.input-wrapper.input-disabled {
|
|
35
|
+
background: #f8f8fb;
|
|
36
|
+
cursor: not-allowed;
|
|
37
|
+
color: rgb(var(--cat-font-color-muted, 105, 118, 135));
|
|
38
|
+
}
|
|
39
|
+
.input-wrapper:not(.input-disabled):hover {
|
|
40
|
+
box-shadow: 0 0 0 2px #d7dbe0;
|
|
41
|
+
}
|
|
42
|
+
.input-wrapper:not(.input-disabled):focus-within {
|
|
43
|
+
outline: 2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
label {
|
|
47
|
+
display: block;
|
|
48
|
+
align-self: flex-start;
|
|
49
|
+
}
|
|
50
|
+
label.hidden {
|
|
51
|
+
position: absolute !important;
|
|
52
|
+
width: 1px !important;
|
|
53
|
+
height: 1px !important;
|
|
54
|
+
padding: 0 !important;
|
|
55
|
+
margin: -1px !important;
|
|
56
|
+
overflow: hidden !important;
|
|
57
|
+
clip: rect(0, 0, 0, 0) !important;
|
|
58
|
+
white-space: nowrap !important;
|
|
59
|
+
border: 0 !important;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.input-optional {
|
|
63
|
+
margin-left: 0.25rem;
|
|
64
|
+
font-size: 0.75rem;
|
|
65
|
+
line-height: 1rem;
|
|
66
|
+
color: rgb(var(--cat-font-color-muted, 105, 118, 135));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.text-prefix,
|
|
70
|
+
.text-suffix {
|
|
71
|
+
display: inline-flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
/* stylelint-disable property-no-vendor-prefix */
|
|
74
|
+
-webkit-user-select: none;
|
|
75
|
+
-ms-user-select: none;
|
|
76
|
+
user-select: none;
|
|
77
|
+
/* stylelint-enable property-no-vendor-prefix */
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.text-prefix {
|
|
81
|
+
border-right: 1px solid #d7dbe0;
|
|
82
|
+
padding-right: 0.5rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.text-suffix {
|
|
86
|
+
border-left: 1px solid #d7dbe0;
|
|
87
|
+
padding-left: 0.5rem;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.icon-prefix,
|
|
91
|
+
.icon-suffix {
|
|
92
|
+
align-self: center;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.input-inner-wrapper {
|
|
96
|
+
display: flex;
|
|
97
|
+
position: relative;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
input {
|
|
101
|
+
font: inherit;
|
|
102
|
+
margin: 0;
|
|
103
|
+
padding: 0;
|
|
104
|
+
width: 100%;
|
|
105
|
+
min-width: 0;
|
|
106
|
+
border: none;
|
|
107
|
+
outline: none;
|
|
108
|
+
background: none;
|
|
109
|
+
}
|
|
110
|
+
.input-disabled input {
|
|
111
|
+
cursor: not-allowed;
|
|
112
|
+
color: rgb(var(--cat-font-color-muted, 105, 118, 135));
|
|
113
|
+
}
|
|
114
|
+
input.has-clearable {
|
|
115
|
+
padding-right: 2rem;
|
|
116
|
+
}
|
|
117
|
+
input::placeholder {
|
|
118
|
+
color: rgb(var(--cat-font-color-muted, 105, 118, 135));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.clearable {
|
|
122
|
+
position: absolute;
|
|
123
|
+
top: calc(50% - 1rem);
|
|
124
|
+
right: -0.25rem;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.input-hint {
|
|
128
|
+
font-size: 0.875rem;
|
|
129
|
+
line-height: 1rem;
|
|
130
|
+
margin: 0;
|
|
131
|
+
}
|