@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.
Files changed (125) hide show
  1. package/dist/catalyst/catalyst.css +1 -1
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/p-12486027.js.map +1 -1
  5. package/dist/catalyst/p-12b96af6.js +2 -0
  6. package/dist/catalyst/p-12b96af6.js.map +1 -0
  7. package/dist/catalyst/p-4c9cd203.entry.js +2 -0
  8. package/dist/catalyst/p-4c9cd203.entry.js.map +1 -0
  9. package/dist/catalyst/p-5616e2cd.js +2 -0
  10. package/dist/catalyst/p-5616e2cd.js.map +1 -0
  11. package/dist/catalyst/p-9d2eab4f.entry.js +10 -0
  12. package/dist/catalyst/p-9d2eab4f.entry.js.map +1 -0
  13. package/dist/cjs/app-globals-aa29ad72.js.map +1 -1
  14. package/dist/cjs/{cat-alert_15.cjs.entry.js → cat-alert_18.cjs.entry.js} +277 -65
  15. package/dist/cjs/cat-alert_18.cjs.entry.js.map +1 -0
  16. package/dist/cjs/cat-form-hint-93a6936b.js +22 -0
  17. package/dist/cjs/cat-form-hint-93a6936b.js.map +1 -0
  18. package/dist/cjs/cat-textarea.cjs.entry.js +12 -12
  19. package/dist/cjs/cat-textarea.cjs.entry.js.map +1 -1
  20. package/dist/cjs/catalyst.cjs.js +2 -2
  21. package/dist/cjs/{index-5d72f0e4.js → index-499bad41.js} +44 -1
  22. package/dist/cjs/index-499bad41.js.map +1 -0
  23. package/dist/cjs/loader.cjs.js +2 -2
  24. package/dist/collection/collection-manifest.json +3 -0
  25. package/dist/collection/components/cat-avatar/cat-avatar.css +81 -0
  26. package/dist/collection/components/cat-avatar/cat-avatar.js +225 -0
  27. package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -0
  28. package/dist/collection/components/cat-badge/cat-badge.css +5 -5
  29. package/dist/collection/components/cat-button/cat-button.js +8 -8
  30. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  31. package/dist/collection/components/cat-checkbox/cat-checkbox.css +14 -0
  32. package/dist/collection/components/cat-checkbox/cat-checkbox.js +43 -11
  33. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  34. package/dist/collection/components/cat-form-hint/cat-form-hint.js +16 -0
  35. package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -0
  36. package/dist/collection/components/cat-input/cat-input.css +12 -6
  37. package/dist/collection/components/cat-input/cat-input.js +23 -25
  38. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  39. package/dist/collection/components/cat-radio/cat-radio.css +14 -0
  40. package/dist/collection/components/cat-radio/cat-radio.js +40 -8
  41. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  42. package/dist/collection/components/cat-scrollable/cat-scrollable.js +44 -44
  43. package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
  44. package/dist/collection/components/cat-tab/cat-tab.css +12 -0
  45. package/dist/collection/components/cat-tab/cat-tab.js +203 -0
  46. package/dist/collection/components/cat-tab/cat-tab.js.map +1 -0
  47. package/dist/collection/components/cat-tabs/cat-tabs.css +33 -0
  48. package/dist/collection/components/cat-tabs/cat-tabs.js +122 -0
  49. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -0
  50. package/dist/collection/components/cat-textarea/cat-textarea.css +12 -6
  51. package/dist/collection/components/cat-textarea/cat-textarea.js +23 -18
  52. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  53. package/dist/collection/components/cat-toggle/cat-toggle.css +14 -0
  54. package/dist/collection/components/cat-toggle/cat-toggle.js +39 -7
  55. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  56. package/dist/collection/components/cat-tooltip/cat-tooltip.js +13 -8
  57. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
  58. package/dist/collection/utils/load-img.js +16 -0
  59. package/dist/collection/utils/load-img.js.map +1 -0
  60. package/dist/components/cat-avatar.d.ts +11 -0
  61. package/dist/components/cat-avatar.js +125 -0
  62. package/dist/components/cat-avatar.js.map +1 -0
  63. package/dist/components/cat-badge.js +1 -1
  64. package/dist/components/cat-badge.js.map +1 -1
  65. package/dist/components/cat-button2.js +5 -5
  66. package/dist/components/cat-button2.js.map +1 -1
  67. package/dist/components/cat-checkbox.js +15 -5
  68. package/dist/components/cat-checkbox.js.map +1 -1
  69. package/dist/components/cat-form-hint.js +20 -0
  70. package/dist/components/cat-form-hint.js.map +1 -0
  71. package/dist/components/cat-input.js +15 -18
  72. package/dist/components/cat-input.js.map +1 -1
  73. package/dist/components/cat-radio.js +15 -5
  74. package/dist/components/cat-radio.js.map +1 -1
  75. package/dist/components/cat-scrollable.js +23 -23
  76. package/dist/components/cat-scrollable.js.map +1 -1
  77. package/dist/components/cat-tab.d.ts +11 -0
  78. package/dist/components/cat-tab.js +70 -0
  79. package/dist/components/cat-tab.js.map +1 -0
  80. package/dist/components/cat-tabs.d.ts +11 -0
  81. package/dist/components/cat-tabs.js +107 -0
  82. package/dist/components/cat-tabs.js.map +1 -0
  83. package/dist/components/cat-textarea.js +13 -12
  84. package/dist/components/cat-textarea.js.map +1 -1
  85. package/dist/components/cat-toggle.js +15 -5
  86. package/dist/components/cat-toggle.js.map +1 -1
  87. package/dist/components/cat-tooltip.js +13 -8
  88. package/dist/components/cat-tooltip.js.map +1 -1
  89. package/dist/components/index.js.map +1 -1
  90. package/dist/esm/app-globals-cf55f7f5.js.map +1 -1
  91. package/dist/esm/{cat-alert_15.entry.js → cat-alert_18.entry.js} +275 -66
  92. package/dist/esm/cat-alert_18.entry.js.map +1 -0
  93. package/dist/esm/cat-form-hint-dc443c7c.js +20 -0
  94. package/dist/esm/cat-form-hint-dc443c7c.js.map +1 -0
  95. package/dist/esm/cat-textarea.entry.js +12 -12
  96. package/dist/esm/cat-textarea.entry.js.map +1 -1
  97. package/dist/esm/catalyst.js +2 -2
  98. package/dist/esm/{index-fd12be19.js → index-039e6f5f.js} +44 -2
  99. package/dist/esm/index-039e6f5f.js.map +1 -0
  100. package/dist/esm/loader.js +2 -2
  101. package/dist/types/components/cat-avatar/cat-avatar.d.ts +46 -0
  102. package/dist/types/components/cat-button/cat-button.d.ts +2 -2
  103. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +9 -0
  104. package/dist/types/components/cat-form-hint/cat-form-hint.d.ts +19 -0
  105. package/dist/types/components/cat-input/cat-input.d.ts +7 -5
  106. package/dist/types/components/cat-radio/cat-radio.d.ts +9 -0
  107. package/dist/types/components/cat-scrollable/cat-scrollable.d.ts +12 -12
  108. package/dist/types/components/cat-tab/cat-tab.d.ts +43 -0
  109. package/dist/types/components/cat-tabs/cat-tabs.d.ts +25 -0
  110. package/dist/types/components/cat-textarea/cat-textarea.d.ts +7 -2
  111. package/dist/types/components/cat-toggle/cat-toggle.d.ts +9 -0
  112. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +1 -0
  113. package/dist/types/components.d.ts +255 -52
  114. package/dist/types/utils/load-img.d.ts +8 -0
  115. package/package.json +2 -2
  116. package/dist/catalyst/p-a8629c54.entry.js +0 -2
  117. package/dist/catalyst/p-a8629c54.entry.js.map +0 -1
  118. package/dist/catalyst/p-bfc656ca.js +0 -2
  119. package/dist/catalyst/p-bfc656ca.js.map +0 -1
  120. package/dist/catalyst/p-e6491f33.entry.js +0 -10
  121. package/dist/catalyst/p-e6491f33.entry.js.map +0 -1
  122. package/dist/cjs/cat-alert_15.cjs.entry.js.map +0 -1
  123. package/dist/cjs/index-5d72f0e4.js.map +0 -1
  124. package/dist/esm/cat-alert_15.entry.js.map +0 -1
  125. package/dist/esm/index-fd12be19.js.map +0 -1
@@ -0,0 +1,225 @@
1
+ import { Component, h, Prop, State, Watch } from '@stencil/core';
2
+ import log from 'loglevel';
3
+ import loadImg from '../../utils/load-img';
4
+ /**
5
+ * Avatars are used to represent a person or object.
6
+ */
7
+ export class CatAvatar {
8
+ constructor() {
9
+ /**
10
+ * The size of the avatar.
11
+ */
12
+ this.size = 'm';
13
+ /**
14
+ * Use round avatar edges.
15
+ */
16
+ this.round = false;
17
+ /**
18
+ * The label of the avatar.
19
+ */
20
+ this.label = '';
21
+ }
22
+ onSrcChanged(value) {
23
+ if (value) {
24
+ loadImg(value).then(() => (this.backgroundImage = `url(${value})`), () => (this.backgroundImage = undefined));
25
+ }
26
+ else {
27
+ this.backgroundImage = undefined;
28
+ }
29
+ }
30
+ componentWillLoad() {
31
+ this.onSrcChanged(this.src);
32
+ }
33
+ componentWillRender() {
34
+ if (!this.label) {
35
+ log.warn('[A11y] Missing ARIA label on avatar', this);
36
+ }
37
+ }
38
+ render() {
39
+ if (this.url) {
40
+ return (h("a", { href: this.url, target: this.urlTarget, style: this.cssStyle, class: this.cssClass, "aria-label": this.label }, this.content));
41
+ }
42
+ else {
43
+ return (h("span", { style: this.cssStyle, class: this.cssClass, "aria-label": this.label }, this.content));
44
+ }
45
+ }
46
+ get content() {
47
+ return !this.backgroundImage
48
+ ? [this.icon ? h("cat-icon", { icon: this.icon, size: this.size }) : this.getInitials()]
49
+ : [];
50
+ }
51
+ get cssStyle() {
52
+ return { 'background-image': this.backgroundImage };
53
+ }
54
+ get cssClass() {
55
+ return {
56
+ avatar: true,
57
+ 'avatar-round': this.round,
58
+ [`avatar-${this.size}`]: Boolean(this.size)
59
+ };
60
+ }
61
+ getInitials() {
62
+ var _a;
63
+ return ((_a = this.initials) !== null && _a !== void 0 ? _a : this.label
64
+ .split(' ')
65
+ .map(n => n[0])
66
+ .join(''));
67
+ }
68
+ static get is() { return "cat-avatar"; }
69
+ static get encapsulation() { return "shadow"; }
70
+ static get originalStyleUrls() { return {
71
+ "$": ["cat-avatar.scss"]
72
+ }; }
73
+ static get styleUrls() { return {
74
+ "$": ["cat-avatar.css"]
75
+ }; }
76
+ static get properties() { return {
77
+ "size": {
78
+ "type": "string",
79
+ "mutable": false,
80
+ "complexType": {
81
+ "original": "'xs' | 's' | 'm' | 'l' | 'xl'",
82
+ "resolved": "\"l\" | \"m\" | \"s\" | \"xl\" | \"xs\"",
83
+ "references": {}
84
+ },
85
+ "required": false,
86
+ "optional": false,
87
+ "docs": {
88
+ "tags": [],
89
+ "text": "The size of the avatar."
90
+ },
91
+ "attribute": "size",
92
+ "reflect": false,
93
+ "defaultValue": "'m'"
94
+ },
95
+ "round": {
96
+ "type": "boolean",
97
+ "mutable": false,
98
+ "complexType": {
99
+ "original": "boolean",
100
+ "resolved": "boolean",
101
+ "references": {}
102
+ },
103
+ "required": false,
104
+ "optional": false,
105
+ "docs": {
106
+ "tags": [],
107
+ "text": "Use round avatar edges."
108
+ },
109
+ "attribute": "round",
110
+ "reflect": false,
111
+ "defaultValue": "false"
112
+ },
113
+ "label": {
114
+ "type": "string",
115
+ "mutable": false,
116
+ "complexType": {
117
+ "original": "string",
118
+ "resolved": "string",
119
+ "references": {}
120
+ },
121
+ "required": false,
122
+ "optional": false,
123
+ "docs": {
124
+ "tags": [],
125
+ "text": "The label of the avatar."
126
+ },
127
+ "attribute": "label",
128
+ "reflect": false,
129
+ "defaultValue": "''"
130
+ },
131
+ "initials": {
132
+ "type": "string",
133
+ "mutable": false,
134
+ "complexType": {
135
+ "original": "string",
136
+ "resolved": "string | undefined",
137
+ "references": {}
138
+ },
139
+ "required": false,
140
+ "optional": true,
141
+ "docs": {
142
+ "tags": [],
143
+ "text": "Custom initials for the avatar."
144
+ },
145
+ "attribute": "initials",
146
+ "reflect": false
147
+ },
148
+ "src": {
149
+ "type": "string",
150
+ "mutable": false,
151
+ "complexType": {
152
+ "original": "string",
153
+ "resolved": "string | undefined",
154
+ "references": {}
155
+ },
156
+ "required": false,
157
+ "optional": true,
158
+ "docs": {
159
+ "tags": [],
160
+ "text": "An optional avatar image."
161
+ },
162
+ "attribute": "src",
163
+ "reflect": false
164
+ },
165
+ "icon": {
166
+ "type": "string",
167
+ "mutable": false,
168
+ "complexType": {
169
+ "original": "string",
170
+ "resolved": "string | undefined",
171
+ "references": {}
172
+ },
173
+ "required": false,
174
+ "optional": true,
175
+ "docs": {
176
+ "tags": [],
177
+ "text": "An icon to be used instead of the initials."
178
+ },
179
+ "attribute": "icon",
180
+ "reflect": false
181
+ },
182
+ "url": {
183
+ "type": "string",
184
+ "mutable": false,
185
+ "complexType": {
186
+ "original": "string",
187
+ "resolved": "string | undefined",
188
+ "references": {}
189
+ },
190
+ "required": false,
191
+ "optional": true,
192
+ "docs": {
193
+ "tags": [],
194
+ "text": "A destination to link to, rendered in the href attribute of a link."
195
+ },
196
+ "attribute": "url",
197
+ "reflect": false
198
+ },
199
+ "urlTarget": {
200
+ "type": "string",
201
+ "mutable": false,
202
+ "complexType": {
203
+ "original": "'_blank' | '_self'",
204
+ "resolved": "\"_blank\" | \"_self\" | undefined",
205
+ "references": {}
206
+ },
207
+ "required": false,
208
+ "optional": true,
209
+ "docs": {
210
+ "tags": [],
211
+ "text": "Specifies where to open the linked document."
212
+ },
213
+ "attribute": "url-target",
214
+ "reflect": false
215
+ }
216
+ }; }
217
+ static get states() { return {
218
+ "backgroundImage": {}
219
+ }; }
220
+ static get watchers() { return [{
221
+ "propName": "src",
222
+ "methodName": "onSrcChanged"
223
+ }]; }
224
+ }
225
+ //# sourceMappingURL=cat-avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cat-avatar.js","sourceRoot":"","sources":["../../../src/components/cat-avatar/cat-avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAE3C;;GAEG;AAMH,MAAM,OAAO,SAAS;EALtB;IAQE;;OAEG;IACK,SAAI,GAAkC,GAAG,CAAC;IAElD;;OAEG;IACK,UAAK,GAAG,KAAK,CAAC;IAEtB;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;G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AAE,CAAC;MAC5F,CAAC,CAAC,EAAE,CAAC;EACT,CAAC;EAED,IAAY,QAAQ;IAClB,OAAO,EAAE,kBAAkB,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC;EACtD,CAAC;EAED,IAAY,QAAQ;IAClB,OAAO;MACL,MAAM,EAAE,IAAI;MACZ,cAAc,EAAE,IAAI,CAAC,KAAK;MAC1B,CAAC,UAAU,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;KAC5C,CAAC;EACJ,CAAC;EAEO,WAAW;;IACjB,OAAO,CACL,MAAA,IAAI,CAAC,QAAQ,mCACb,IAAI,CAAC,KAAK;OACP,KAAK,CAAC,GAAG,CAAC;OACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;OACd,IAAI,CAAC,EAAE,CAAC,CACZ,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Watch } from '@stencil/core';\nimport log from 'loglevel';\nimport loadImg from '../../utils/load-img';\n\n/**\n * Avatars are used to represent a person or object.\n */\n@Component({\n tag: 'cat-avatar',\n styleUrl: 'cat-avatar.scss',\n shadow: true\n})\nexport class CatAvatar {\n @State() backgroundImage?: string;\n\n /**\n * The size of the avatar.\n */\n @Prop() size: 'xs' | 's' | 'm' | 'l' | 'xl' = 'm';\n\n /**\n * Use round avatar edges.\n */\n @Prop() round = false;\n\n /**\n * The label of the avatar.\n */\n @Prop() label = '';\n\n /**\n * Custom initials for the avatar.\n */\n @Prop() initials?: string;\n\n /**\n * An optional avatar image.\n */\n @Prop() src?: string;\n\n /**\n * An icon to be used instead of the initials.\n */\n @Prop() icon?: string;\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 @Watch('src')\n onSrcChanged(value?: string): void {\n if (value) {\n loadImg(value).then(\n () => (this.backgroundImage = `url(${value})`),\n () => (this.backgroundImage = undefined)\n );\n } else {\n this.backgroundImage = undefined;\n }\n }\n\n componentWillLoad(): void {\n this.onSrcChanged(this.src);\n }\n\n componentWillRender(): void {\n if (!this.label) {\n log.warn('[A11y] Missing ARIA label on avatar', this);\n }\n }\n\n render() {\n if (this.url) {\n return (\n <a href={this.url} target={this.urlTarget} style={this.cssStyle} class={this.cssClass} aria-label={this.label}>\n {this.content}\n </a>\n );\n } else {\n return (\n <span style={this.cssStyle} class={this.cssClass} aria-label={this.label}>\n {this.content}\n </span>\n );\n }\n }\n\n private get content() {\n return !this.backgroundImage\n ? [this.icon ? <cat-icon icon={this.icon} size={this.size}></cat-icon> : this.getInitials()]\n : [];\n }\n\n private get cssStyle() {\n return { 'background-image': this.backgroundImage };\n }\n\n private get cssClass() {\n return {\n avatar: true,\n 'avatar-round': this.round,\n [`avatar-${this.size}`]: Boolean(this.size)\n };\n }\n\n private getInitials(): string {\n return (\n this.initials ??\n this.label\n .split(' ')\n .map(n => n[0])\n .join('')\n );\n }\n}\n"]}
@@ -92,35 +92,35 @@
92
92
  height: 0.75rem;
93
93
  min-width: 0.75rem;
94
94
  font-size: 0.75rem;
95
- padding: 0 0.1875rem;
95
+ padding: 0rem 0.25rem;
96
96
  }
97
97
 
98
98
  .badge-s {
99
99
  height: 1rem;
100
100
  min-width: 1rem;
101
101
  font-size: 0.75rem;
102
- padding: 0 0.25rem;
102
+ padding: 0.25rem 0.5rem;
103
103
  }
104
104
 
105
105
  .badge-m {
106
106
  height: 1.25rem;
107
107
  min-width: 1.25rem;
108
108
  font-size: 0.75rem;
109
- padding: 0 0.3125rem;
109
+ padding: 0.5rem 0.75rem;
110
110
  }
111
111
 
112
112
  .badge-l {
113
113
  height: 1.5rem;
114
114
  min-width: 1.5rem;
115
115
  font-size: 0.875rem;
116
- padding: 0 0.375rem;
116
+ padding: 0.75rem 1rem;
117
117
  }
118
118
 
119
119
  .badge-xl {
120
120
  height: 1.75rem;
121
121
  min-width: 1.75rem;
122
122
  font-size: 0.9375rem;
123
- padding: 0 0.4375rem;
123
+ padding: 1rem 1.25rem;
124
124
  }
125
125
 
126
126
  .badge-pulse.badge-filled {
@@ -46,9 +46,9 @@ export class CatButton {
46
46
  */
47
47
  this.submit = false;
48
48
  /**
49
- * Ellipse overflowing button content.
49
+ * Disables ellipse overflowing button content.
50
50
  */
51
- this.ellipsed = true;
51
+ this.noEllipsis = false;
52
52
  /**
53
53
  * Use round button edges.
54
54
  */
@@ -113,7 +113,7 @@ export class CatButton {
113
113
  'cat-button-round': this.round,
114
114
  'cat-button-loading': this.loading,
115
115
  'cat-button-disabled': this.disabled,
116
- 'cat-button-ellipsed': this.ellipsed && !this.isIconButton,
116
+ 'cat-button-ellipsed': !this.noEllipsis && !this.isIconButton,
117
117
  [`cat-button-${this.variant}`]: Boolean(this.variant),
118
118
  [`cat-button-${this.color}`]: Boolean(this.color),
119
119
  [`cat-button-${this.size}`]: Boolean(this.size)
@@ -127,7 +127,7 @@ export class CatButton {
127
127
  'cat-button-round': (_a = this.round) !== null && _a !== void 0 ? _a : this.isIconButton,
128
128
  'cat-button-loading': this.loading,
129
129
  'cat-button-disabled': this.disabled,
130
- 'cat-button-ellipsed': this.ellipsed && !this.isIconButton,
130
+ 'cat-button-ellipsed': !this.noEllipsis && !this.isIconButton,
131
131
  [`cat-button-${this.variant}`]: Boolean(this.variant),
132
132
  [`cat-button-${this.color}`]: Boolean(this.color),
133
133
  [`cat-button-${this.size}`]: Boolean(this.size)
@@ -346,7 +346,7 @@ export class CatButton {
346
346
  "reflect": false,
347
347
  "defaultValue": "false"
348
348
  },
349
- "ellipsed": {
349
+ "noEllipsis": {
350
350
  "type": "boolean",
351
351
  "mutable": false,
352
352
  "complexType": {
@@ -358,11 +358,11 @@ export class CatButton {
358
358
  "optional": false,
359
359
  "docs": {
360
360
  "tags": [],
361
- "text": "Ellipse overflowing button content."
361
+ "text": "Disables ellipse overflowing button content."
362
362
  },
363
- "attribute": "ellipsed",
363
+ "attribute": "no-ellipsis",
364
364
  "reflect": false,
365
- "defaultValue": "true"
365
+ "defaultValue": "false"
366
366
  },
367
367
  "round": {
368
368
  "type": "boolean",
@@ -1 +1 @@
1
- {"version":3,"file":"cat-button.js","sourceRoot":"","sources":["../../../src/components/cat-button/cat-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAc,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;;;GAQG;AAMH,MAAM,OAAO,SAAS;EALtB;IAWW,cAAS,GAAG,IAAI,CAAC;IAE1B;;OAEG;IACK,YAAO,GAAmC,UAAU,CAAC;IAE7D;;OAEG;IACK,UAAK,GAA+D,WAAW,CAAC;IAExF;;OAEG;IACK,WAAM,GAAG,KAAK,CAAC;IAEvB;;OAEG;IACK,SAAI,GAAkC,GAAG,CAAC;IAgBlD;;;OAGG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;;;OAIG;IACK,YAAO,GAAG,KAAK,CAAC;IAExB;;OAEG;IACK,WAAM,GAAG,KAAK,CAAC;IAEvB;;OAEG;IACK,aAAQ,GAAG,IAAI,CAAC;IAExB;;OAEG;IACK,UAAK,GAAG,KAAK,CAAC;IAiBtB;;OAEG;IACK,aAAQ,GAAyB,KAAK,CAAC;IAE/C;;OAEG;IAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, h, Listen, Method, Prop, State, Watch } from '@stencil/core';\nimport log from 'loglevel';\nimport { Breakpoint, Breakpoints, isBreakpoint } from '../../utils/breakpoints';\nimport { MediaMatcher } from '../../utils/media-matcher';\n\n/**\n * Buttons are used for interface actions. Primary style should be used only\n * once per view for main call-to-action.\n *\n * @part button - The native anchor or button element.\n * @part content - The textual content of the button.\n * @part prefix - The prefix icon.\n * @part suffix - The suffix icon.\n */\n@Component({\n tag: 'cat-button',\n styleUrl: 'cat-button.scss',\n shadow: true\n})\nexport class CatButton {\n private button!: HTMLButtonElement | HTMLAnchorElement;\n private mediaMatcher?: MediaMatcher;\n private mediaQueryList?: MediaQueryList;\n private mediaQueryListener?: (event: MediaQueryListEvent) => void;\n\n @State() _iconOnly = true;\n\n /**\n * The rendering style of the button.\n */\n @Prop() variant: 'filled' | 'outlined' | 'text' = 'outlined';\n\n /**\n * The color palette of the button.\n */\n @Prop() color: 'primary' | 'secondary' | 'danger' | 'success' | 'warning' = 'secondary';\n\n /**\n * Show an active status indicator on the left side of the button.\n */\n @Prop() active = false;\n\n /**\n * The size of the button.\n */\n @Prop() size: 'xs' | 's' | 'm' | 'l' | 'xl' = 'm';\n\n /**\n * The name of the button, which gets paired with the button's value when\n * submitted as part of a form. Corresponds with the native HTML name\n * attribute.\n */\n @Prop() name?: string;\n\n /**\n * The value of the button, which gets paired with the button's name when\n * submitted as part of a form. Corresponds with the native HTML value\n * attribute.\n */\n @Prop() value?: string;\n\n /**\n * Specifies that the button should be disabled. A disabled button is unusable\n * and un-clickable. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * Displays the button in a loading state with a spinner. Just like a disabled\n * button, an inactive button is unusable and un-clickable. However, it\n * retains the current focus state.\n */\n @Prop() loading = false;\n\n /**\n * Allows the button to submit a form.\n */\n @Prop() submit = false;\n\n /**\n * Ellipse overflowing button content.\n */\n @Prop() ellipsed = true;\n\n /**\n * Use round button edges.\n */\n @Prop() round = 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 * The name of an icon to be displayed in the button.\n */\n @Prop() icon?: string;\n\n /**\n * Hide the actual button content and only display the icon.\n */\n @Prop() iconOnly: boolean | Breakpoint = false;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * Adds a unique identifier for the button. Please note that with this\n * particular component this ID is added inside the web component. If you need\n * an ID on the HTML element, use the regular `id` attribute instead.\n */\n @Prop() buttonId?: string;\n\n /**\n * Adds accessible label for the button that is only shown for screen\n * readers. Typically, this label text replaces the visible text on the\n * button for users who use assistive technology.\n */\n @Prop({ attribute: 'a11y-label' }) a11yLabel?: string;\n\n @Watch('iconOnly')\n onIconOnlyChanged(value: boolean | Breakpoint): void {\n // teardown\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.mediaQueryList?.removeEventListener('change', this.mediaQueryListener!);\n this.mediaQueryList = undefined;\n this.mediaQueryListener = undefined;\n // setup\n if (isBreakpoint(value)) {\n this.mediaMatcher ??= new MediaMatcher();\n this.mediaQueryList = this.mediaMatcher.matchMedia(Breakpoints[value]);\n this.mediaQueryListener = (event: MediaQueryListEvent) => (this._iconOnly = event.matches);\n this.mediaQueryList.addEventListener('change', this.mediaQueryListener);\n this._iconOnly = this.mediaQueryList.matches;\n } else {\n this._iconOnly = value;\n }\n }\n\n /**\n * Emitted when the button is clicked.\n */\n @Event() catClick!: EventEmitter<MouseEvent>;\n\n /**\n * Emitted when the button received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the button loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillLoad(): void {\n this.onIconOnlyChanged(this.iconOnly);\n }\n\n componentWillRender(): void {\n if (this.isIconButton && !this.a11yLabel) {\n log.warn('[A11y] Missing ARIA label on icon button', this);\n }\n }\n\n @Listen('click')\n haltDisabledEvents(event: Event): void {\n if (this.disabled || this.loading) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n /**\n * Sets focus on the button. Use this method instead of `button.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.button.focus(options);\n }\n\n render() {\n if (this.url) {\n return (\n <a\n ref={el => (this.button = el as HTMLAnchorElement)}\n href={this.disabled ? undefined : this.url}\n target={this.urlTarget}\n aria-disabled={this.disabled ? 'true' : null}\n aria-label={this.a11yLabel}\n id={this.buttonId}\n part=\"button\"\n class={{\n 'cat-button': true,\n 'cat-button-icon': this.isIconButton,\n 'cat-button-round': this.round,\n 'cat-button-loading': this.loading,\n 'cat-button-disabled': this.disabled,\n 'cat-button-ellipsed': this.ellipsed && !this.isIconButton,\n [`cat-button-${this.variant}`]: Boolean(this.variant),\n [`cat-button-${this.color}`]: Boolean(this.color),\n [`cat-button-${this.size}`]: Boolean(this.size)\n }}\n onClick={this.onClick.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n >\n {this.content}\n </a>\n );\n } else {\n return (\n <button\n ref={el => (this.button = el as HTMLButtonElement)}\n type={this.submit ? 'submit' : 'button'}\n name={this.name}\n value={this.value}\n disabled={this.disabled}\n aria-disabled={this.disabled ? 'true' : null}\n aria-label={this.a11yLabel}\n id={this.buttonId}\n part=\"button\"\n class={{\n 'cat-button': true,\n 'cat-button-active': this.active,\n 'cat-button-icon': this.isIconButton,\n 'cat-button-round': this.round ?? this.isIconButton,\n 'cat-button-loading': this.loading,\n 'cat-button-disabled': this.disabled,\n 'cat-button-ellipsed': this.ellipsed && !this.isIconButton,\n [`cat-button-${this.variant}`]: Boolean(this.variant),\n [`cat-button-${this.color}`]: Boolean(this.color),\n [`cat-button-${this.size}`]: Boolean(this.size)\n }}\n onClick={this.onClick.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n >\n {this.content}\n </button>\n );\n }\n }\n\n private get iconSize(): 'xs' | 's' | 'm' | 'l' | 'xl' {\n switch (this.size) {\n case 'xs':\n return 's';\n default:\n return 'l';\n }\n }\n\n private get spinnerSize(): 'xs' | 's' | 'm' | 'l' | 'xl' {\n switch (this.size) {\n case 'xs':\n return 'xs';\n default:\n return 'm';\n }\n }\n\n private get isIconButton() {\n return Boolean(this.icon) && this._iconOnly;\n }\n\n private get hasPrefixIcon() {\n return Boolean(this.icon) && !this._iconOnly && !this.iconRight;\n }\n\n private get hasSuffixIcon() {\n return Boolean(this.icon) && !this._iconOnly && this.iconRight;\n }\n\n private get content() {\n return [\n this.hasPrefixIcon ? (\n <cat-icon icon={this.icon} size={this.iconSize} class=\"cat-button-prefix\" part=\"prefix\"></cat-icon>\n ) : null,\n this.isIconButton ? (\n <cat-icon icon={this.icon} size={this.iconSize}></cat-icon>\n ) : (\n <span class=\"cat-button-content\" part=\"content\">\n <slot></slot>\n </span>\n ),\n this.hasSuffixIcon ? (\n <cat-icon icon={this.icon} size={this.iconSize} class=\"cat-button-suffix\" part=\"suffix\"></cat-icon>\n ) : null,\n this.loading ? <cat-spinner size={this.spinnerSize}></cat-spinner> : null\n ];\n }\n\n private onClick(event: MouseEvent) {\n this.catClick.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"]}
1
+ {"version":3,"file":"cat-button.js","sourceRoot":"","sources":["../../../src/components/cat-button/cat-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,E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,WAAW,GAAgB,CAAC,CAAC,CAAC,IAAI;KAC1E,CAAC;EACJ,CAAC;EAEO,OAAO,CAAC,KAAiB;IAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC5B,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, Listen, Method, Prop, State, Watch } from '@stencil/core';\nimport log from 'loglevel';\nimport { Breakpoint, Breakpoints, isBreakpoint } from '../../utils/breakpoints';\nimport { MediaMatcher } from '../../utils/media-matcher';\n\n/**\n * Buttons are used for interface actions. Primary style should be used only\n * once per view for main call-to-action.\n *\n * @part button - The native anchor or button element.\n * @part content - The textual content of the button.\n * @part prefix - The prefix icon.\n * @part suffix - The suffix icon.\n */\n@Component({\n tag: 'cat-button',\n styleUrl: 'cat-button.scss',\n shadow: true\n})\nexport class CatButton {\n private button!: HTMLButtonElement | HTMLAnchorElement;\n private mediaMatcher?: MediaMatcher;\n private mediaQueryList?: MediaQueryList;\n private mediaQueryListener?: (event: MediaQueryListEvent) => void;\n\n @State() _iconOnly = true;\n\n /**\n * The rendering style of the button.\n */\n @Prop() variant: 'filled' | 'outlined' | 'text' = 'outlined';\n\n /**\n * The color palette of the button.\n */\n @Prop() color: 'primary' | 'secondary' | 'danger' | 'success' | 'warning' = 'secondary';\n\n /**\n * Show an active status indicator on the left side of the button.\n */\n @Prop() active = false;\n\n /**\n * The size of the button.\n */\n @Prop() size: 'xs' | 's' | 'm' | 'l' | 'xl' = 'm';\n\n /**\n * The name of the button, which gets paired with the button's value when\n * submitted as part of a form. Corresponds with the native HTML name\n * attribute.\n */\n @Prop() name?: string;\n\n /**\n * The value of the button, which gets paired with the button's name when\n * submitted as part of a form. Corresponds with the native HTML value\n * attribute.\n */\n @Prop() value?: string;\n\n /**\n * Specifies that the button should be disabled. A disabled button is unusable\n * and un-clickable. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * Displays the button in a loading state with a spinner. Just like a disabled\n * button, an inactive button is unusable and un-clickable. However, it\n * retains the current focus state.\n */\n @Prop() loading = false;\n\n /**\n * Allows the button to submit a form.\n */\n @Prop() submit = false;\n\n /**\n * Disables ellipse overflowing button content.\n */\n @Prop() noEllipsis = false;\n\n /**\n * Use round button edges.\n */\n @Prop() round = 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 * The name of an icon to be displayed in the button.\n */\n @Prop() icon?: string;\n\n /**\n * Hide the actual button content and only display the icon.\n */\n @Prop() iconOnly: boolean | Breakpoint = false;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * Adds a unique identifier for the button. Please note that with this\n * particular component this ID is added inside the web component. If you need\n * an ID on the HTML element, use the regular `id` attribute instead.\n */\n @Prop() buttonId?: string;\n\n /**\n * Adds accessible label for the button that is only shown for screen\n * readers. Typically, this label text replaces the visible text on the\n * button for users who use assistive technology.\n */\n @Prop({ attribute: 'a11y-label' }) a11yLabel?: string;\n\n @Watch('iconOnly')\n onIconOnlyChanged(value: boolean | Breakpoint): void {\n // teardown\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.mediaQueryList?.removeEventListener('change', this.mediaQueryListener!);\n this.mediaQueryList = undefined;\n this.mediaQueryListener = undefined;\n // setup\n if (isBreakpoint(value)) {\n this.mediaMatcher ??= new MediaMatcher();\n this.mediaQueryList = this.mediaMatcher.matchMedia(Breakpoints[value]);\n this.mediaQueryListener = (event: MediaQueryListEvent) => (this._iconOnly = event.matches);\n this.mediaQueryList.addEventListener('change', this.mediaQueryListener);\n this._iconOnly = this.mediaQueryList.matches;\n } else {\n this._iconOnly = value;\n }\n }\n\n /**\n * Emitted when the button is clicked.\n */\n @Event() catClick!: EventEmitter<MouseEvent>;\n\n /**\n * Emitted when the button received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the button loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillLoad(): void {\n this.onIconOnlyChanged(this.iconOnly);\n }\n\n componentWillRender(): void {\n if (this.isIconButton && !this.a11yLabel) {\n log.warn('[A11y] Missing ARIA label on icon button', this);\n }\n }\n\n @Listen('click')\n haltDisabledEvents(event: Event): void {\n if (this.disabled || this.loading) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n /**\n * Sets focus on the button. Use this method instead of `button.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.button.focus(options);\n }\n\n render() {\n if (this.url) {\n return (\n <a\n ref={el => (this.button = el as HTMLAnchorElement)}\n href={this.disabled ? undefined : this.url}\n target={this.urlTarget}\n aria-disabled={this.disabled ? 'true' : null}\n aria-label={this.a11yLabel}\n id={this.buttonId}\n part=\"button\"\n class={{\n 'cat-button': true,\n 'cat-button-icon': this.isIconButton,\n 'cat-button-round': this.round,\n 'cat-button-loading': this.loading,\n 'cat-button-disabled': this.disabled,\n 'cat-button-ellipsed': !this.noEllipsis && !this.isIconButton,\n [`cat-button-${this.variant}`]: Boolean(this.variant),\n [`cat-button-${this.color}`]: Boolean(this.color),\n [`cat-button-${this.size}`]: Boolean(this.size)\n }}\n onClick={this.onClick.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n >\n {this.content}\n </a>\n );\n } else {\n return (\n <button\n ref={el => (this.button = el as HTMLButtonElement)}\n type={this.submit ? 'submit' : 'button'}\n name={this.name}\n value={this.value}\n disabled={this.disabled}\n aria-disabled={this.disabled ? 'true' : null}\n aria-label={this.a11yLabel}\n id={this.buttonId}\n part=\"button\"\n class={{\n 'cat-button': true,\n 'cat-button-active': this.active,\n 'cat-button-icon': this.isIconButton,\n 'cat-button-round': this.round ?? this.isIconButton,\n 'cat-button-loading': this.loading,\n 'cat-button-disabled': this.disabled,\n 'cat-button-ellipsed': !this.noEllipsis && !this.isIconButton,\n [`cat-button-${this.variant}`]: Boolean(this.variant),\n [`cat-button-${this.color}`]: Boolean(this.color),\n [`cat-button-${this.size}`]: Boolean(this.size)\n }}\n onClick={this.onClick.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n >\n {this.content}\n </button>\n );\n }\n }\n\n private get iconSize(): 'xs' | 's' | 'm' | 'l' | 'xl' {\n switch (this.size) {\n case 'xs':\n return 's';\n default:\n return 'l';\n }\n }\n\n private get spinnerSize(): 'xs' | 's' | 'm' | 'l' | 'xl' {\n switch (this.size) {\n case 'xs':\n return 'xs';\n default:\n return 'm';\n }\n }\n\n private get isIconButton() {\n return Boolean(this.icon) && this._iconOnly;\n }\n\n private get hasPrefixIcon() {\n return Boolean(this.icon) && !this._iconOnly && !this.iconRight;\n }\n\n private get hasSuffixIcon() {\n return Boolean(this.icon) && !this._iconOnly && this.iconRight;\n }\n\n private get content() {\n return [\n this.hasPrefixIcon ? (\n <cat-icon icon={this.icon} size={this.iconSize} class=\"cat-button-prefix\" part=\"prefix\"></cat-icon>\n ) : null,\n this.isIconButton ? (\n <cat-icon icon={this.icon} size={this.iconSize}></cat-icon>\n ) : (\n <span class=\"cat-button-content\" part=\"content\">\n <slot></slot>\n </span>\n ),\n this.hasSuffixIcon ? (\n <cat-icon icon={this.icon} size={this.iconSize} class=\"cat-button-suffix\" part=\"suffix\"></cat-icon>\n ) : null,\n this.loading ? <cat-spinner size={this.spinnerSize}></cat-spinner> : null\n ];\n }\n\n private onClick(event: MouseEvent) {\n this.catClick.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
 
@@ -1,16 +1,20 @@
1
- import { Component, Event, h, Method, Prop } from '@stencil/core';
1
+ import { Component, Element, Event, h, Host, Method, Prop, State } from '@stencil/core';
2
2
  import log from 'loglevel';
3
+ import { CatFormHint } from '../cat-form-hint/cat-form-hint';
3
4
  let nextUniqueId = 0;
4
5
  /**
5
6
  * Checkboxes are used to let a user choose one or more options from a limited
6
7
  * number of options.
7
8
  *
9
+ * @slot hint - Optional hint element to be displayed with the checkbox.
10
+ * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.
8
11
  * @part checkbox - The checkbox element.
9
12
  * @part label - The label content.
10
13
  */
11
14
  export class CatCheckbox {
12
15
  constructor() {
13
16
  this.id = `cat-checkbox-${nextUniqueId++}`;
17
+ this.hasSlottedLabel = false;
14
18
  /**
15
19
  * Checked state of the checkbox
16
20
  */
@@ -42,7 +46,7 @@ export class CatCheckbox {
42
46
  }
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 checkbox', this);
47
51
  }
48
52
  }
@@ -56,16 +60,23 @@ export class CatCheckbox {
56
60
  this.input.focus(options);
57
61
  }
58
62
  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)));
63
+ return (h(Host, null,
64
+ h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } },
65
+ 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) }),
66
+ h("span", { class: "box", "aria-hidden": "true", part: "checkbox" },
67
+ h("svg", { class: "check", viewBox: "0 0 12 10" },
68
+ h("polyline", { points: "1.5 6 4.5 9 10.5 1" })),
69
+ h("svg", { class: "dash", viewBox: "0 0 12 10" },
70
+ h("polyline", { points: "1.5 5 10.5 5" }))),
71
+ h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)),
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" }) })));
67
77
  }
68
78
  onInput(event) {
79
+ this.value = this.input.value;
69
80
  this.catChange.emit(event);
70
81
  }
71
82
  onFocus(event) {
@@ -210,7 +221,7 @@ export class CatCheckbox {
210
221
  },
211
222
  "value": {
212
223
  "type": "string",
213
- "mutable": false,
224
+ "mutable": true,
214
225
  "complexType": {
215
226
  "original": "string",
216
227
  "resolved": "string | undefined",
@@ -224,8 +235,28 @@ export class CatCheckbox {
224
235
  },
225
236
  "attribute": "value",
226
237
  "reflect": false
238
+ },
239
+ "hint": {
240
+ "type": "string",
241
+ "mutable": false,
242
+ "complexType": {
243
+ "original": "string | string[]",
244
+ "resolved": "string | string[] | undefined",
245
+ "references": {}
246
+ },
247
+ "required": false,
248
+ "optional": true,
249
+ "docs": {
250
+ "tags": [],
251
+ "text": "Optional hint text(s) to be displayed with the checkbox."
252
+ },
253
+ "attribute": "hint",
254
+ "reflect": false
227
255
  }
228
256
  }; }
257
+ static get states() { return {
258
+ "hasSlottedLabel": {}
259
+ }; }
229
260
  static get events() { return [{
230
261
  "method": "catChange",
231
262
  "name": "catChange",
@@ -310,5 +341,6 @@ export class CatCheckbox {
310
341
  }
311
342
  }
312
343
  }; }
344
+ static get elementRef() { return "hostElement"; }
313
345
  }
314
346
  //# sourceMappingURL=cat-checkbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cat-checkbox.js","sourceRoot":"","sources":["../../../src/components/cat-checkbox/cat-checkbox.tsx"],"names":[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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"]}
1
+ {"version":3,"file":"cat-checkbox.js","sourceRoot":"","sources":["../../../src/components/cat-checkbox/cat-checkbox.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,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,YAAO,GAAG,KAAK,CAAC;IAExB;;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C,CAAC;EAC5B,CAAC;EAEO,MAAM,CAAC,KAAiB;IAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC3B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State } from '@stencil/core';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\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 * @slot hint - Optional hint element to be displayed with the checkbox.\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 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 @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\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({ mutable: true }) value?: string;\n\n /**\n * Optional hint text(s) to be displayed with the checkbox.\n */\n @Prop() hint?: string | 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 && !this.hostElement.querySelector('[slot=\"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 <Host>\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.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n </span>\n </label>\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.input.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"]}
@@ -0,0 +1,16 @@
1
+ import { h } from '@stencil/core';
2
+ /**
3
+ * CatFormHint is a functional component that represents the hint area of form elements.
4
+ *
5
+ * @param props - {@link CatFormHintProps}
6
+ * @return a JSX.Element
7
+ */
8
+ export const CatFormHint = props => {
9
+ const { hint, slottedHint } = props;
10
+ return (h("div", { class: "hint-section" }, [
11
+ hint &&
12
+ (Array.isArray(hint) ? hint.map(item => h("p", { class: "input-hint" }, item)) : h("p", { class: "input-hint" }, hint)),
13
+ slottedHint
14
+ ]));
15
+ };
16
+ //# sourceMappingURL=cat-form-hint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cat-form-hint.js","sourceRoot":"","sources":["../../../src/components/cat-form-hint/cat-form-hint.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAuB,MAAM,eAAe,CAAC;AAavD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAA0C,KAAK,CAAC,EAAE;EACxE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;EACpC,OAAO,CACL,WAAK,KAAK,EAAC,cAAc,IACtB;IACC,IAAI;MACF,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,SAAG,KAAK,EAAC,YAAY,IAAE,IAAI,CAAK,CAAC,CAAC,CAAC,CAAC,SAAG,KAAK,EAAC,YAAY,IAAE,IAAI,CAAK,CAAC;IAC/G,WAAW;GACZ,CACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { h, FunctionalComponent } from '@stencil/core';\n\n/**\n * Properties of CatFormHint.\n *\n * @property hint - Optional hint text(s) of the form field.\n * @property slottedHint - Optional hint element of the form field.\n */\ninterface CatFormHintProps {\n hint?: string | string[];\n slottedHint?: HTMLSlotElement;\n}\n\n/**\n * CatFormHint is a functional component that represents the hint area of form elements.\n *\n * @param props - {@link CatFormHintProps}\n * @return a JSX.Element\n */\nexport const CatFormHint: FunctionalComponent<CatFormHintProps> = props => {\n const { hint, slottedHint } = props;\n return (\n <div class=\"hint-section\">\n {[\n hint &&\n (Array.isArray(hint) ? hint.map(item => <p class=\"input-hint\">{item}</p>) : <p class=\"input-hint\">{hint}</p>),\n slottedHint\n ]}\n </div>\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;
@@ -122,10 +134,4 @@ input::placeholder {
122
134
  position: absolute;
123
135
  top: calc(50% - 1rem);
124
136
  right: -0.5rem;
125
- }
126
-
127
- .input-hint {
128
- font-size: 0.875rem;
129
- line-height: 1rem;
130
- margin: 0;
131
137
  }