@haiilo/catalyst 0.6.0 → 0.7.2
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.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/p-12486027.js.map +1 -1
- package/dist/catalyst/p-12b96af6.js +2 -0
- package/dist/catalyst/p-12b96af6.js.map +1 -0
- package/dist/catalyst/p-4254363e.entry.js +2 -0
- package/dist/catalyst/p-4254363e.entry.js.map +1 -0
- package/dist/catalyst/p-5616e2cd.js +2 -0
- package/dist/catalyst/p-5616e2cd.js.map +1 -0
- package/dist/catalyst/p-dda85567.entry.js +10 -0
- package/dist/catalyst/p-dda85567.entry.js.map +1 -0
- package/dist/catalyst/scss/_mixins.scss +9 -0
- package/dist/catalyst/scss/_variables.scss +64 -0
- package/dist/catalyst/scss/_variables.tokens.scss +84 -0
- package/dist/catalyst/scss/core/_base.scss +12 -0
- package/dist/catalyst/scss/core/_nav.scss +23 -0
- package/dist/catalyst/scss/core/_typography.scss +237 -0
- package/dist/catalyst/scss/fonts/_fonts.mixins.azeret.scss +14 -0
- package/dist/catalyst/scss/fonts/_fonts.mixins.dm.scss +53 -0
- package/dist/catalyst/scss/fonts/_fonts.mixins.lato.scss +185 -0
- package/dist/catalyst/scss/fonts/_fonts.mixins.scss +3 -0
- package/dist/catalyst/scss/fonts/_fonts.scss +13 -0
- package/dist/catalyst/scss/index.scss +32 -0
- package/dist/catalyst/scss/utils/_color.scss +52 -0
- package/dist/catalyst/scss/utils/_disabled.mixins.scss +7 -0
- package/dist/catalyst/scss/utils/_display.scss +20 -0
- package/dist/catalyst/scss/utils/_elevation.mixins.scss +10 -0
- package/dist/catalyst/scss/utils/_elevation.scss +19 -0
- package/dist/catalyst/scss/utils/_layout.scss +78 -0
- package/dist/catalyst/scss/utils/_media.mixins.scss +37 -0
- package/dist/catalyst/scss/utils/_ratio.mixins.scss +12 -0
- package/dist/catalyst/scss/utils/_ratio.scss +20 -0
- package/dist/catalyst/scss/utils/_sizing.mixins.scss +15 -0
- package/dist/catalyst/scss/utils/_sizing.scss +16 -0
- package/dist/catalyst/scss/utils/_spacing.mixins.scss +5 -0
- package/dist/catalyst/scss/utils/_spacing.scss +49 -0
- package/dist/catalyst/scss/utils/_toast.scss +77 -0
- package/dist/catalyst/scss/utils/_typography.mixins.scss +102 -0
- package/dist/catalyst/scss/utils/_typography.scss +34 -0
- package/dist/catalyst/scss/utils/_visibility.mixins.scss +29 -0
- package/dist/catalyst/scss/utils/_visibility.scss +13 -0
- package/dist/cjs/app-globals-aa29ad72.js.map +1 -1
- package/dist/cjs/{cat-alert_16.cjs.entry.js → cat-alert_18.cjs.entry.js} +174 -44
- package/dist/cjs/cat-alert_18.cjs.entry.js.map +1 -0
- package/dist/cjs/cat-form-hint-93a6936b.js +22 -0
- package/dist/cjs/cat-form-hint-93a6936b.js.map +1 -0
- package/dist/cjs/cat-textarea.cjs.entry.js +13 -12
- package/dist/cjs/cat-textarea.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +2 -2
- package/dist/cjs/{index-5d72f0e4.js → index-499bad41.js} +44 -1
- package/dist/cjs/index-499bad41.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +14 -0
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +44 -11
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
- package/dist/collection/components/cat-form-hint/cat-form-hint.js +16 -0
- package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -0
- package/dist/collection/components/cat-icon/cat-icon.css +4 -1
- package/dist/collection/components/cat-input/cat-input.css +12 -6
- package/dist/collection/components/cat-input/cat-input.js +24 -25
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.css +14 -0
- package/dist/collection/components/cat-radio/cat-radio.js +41 -8
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-tab/cat-tab.css +12 -0
- package/dist/collection/components/cat-tab/cat-tab.js +203 -0
- package/dist/collection/components/cat-tab/cat-tab.js.map +1 -0
- package/dist/collection/components/cat-tabs/cat-tabs.css +33 -0
- package/dist/collection/components/cat-tabs/cat-tabs.js +122 -0
- package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -0
- package/dist/collection/components/cat-textarea/cat-textarea.css +12 -6
- package/dist/collection/components/cat-textarea/cat-textarea.js +24 -18
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.css +14 -0
- package/dist/collection/components/cat-toggle/cat-toggle.js +40 -7
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +13 -8
- package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
- package/dist/collection/scss/_mixins.scss +9 -0
- package/dist/collection/scss/_variables.scss +64 -0
- package/dist/collection/scss/_variables.tokens.scss +84 -0
- package/dist/collection/scss/core/_base.scss +12 -0
- package/dist/collection/scss/core/_nav.scss +23 -0
- package/dist/collection/scss/core/_typography.scss +237 -0
- package/dist/collection/scss/fonts/_fonts.mixins.azeret.scss +14 -0
- package/dist/collection/scss/fonts/_fonts.mixins.dm.scss +53 -0
- package/dist/collection/scss/fonts/_fonts.mixins.lato.scss +185 -0
- package/dist/collection/scss/fonts/_fonts.mixins.scss +3 -0
- package/dist/collection/scss/fonts/_fonts.scss +13 -0
- package/dist/collection/scss/index.scss +32 -0
- package/dist/collection/scss/utils/_color.scss +52 -0
- package/dist/collection/scss/utils/_disabled.mixins.scss +7 -0
- package/dist/collection/scss/utils/_display.scss +20 -0
- package/dist/collection/scss/utils/_elevation.mixins.scss +10 -0
- package/dist/collection/scss/utils/_elevation.scss +19 -0
- package/dist/collection/scss/utils/_layout.scss +78 -0
- package/dist/collection/scss/utils/_media.mixins.scss +37 -0
- package/dist/collection/scss/utils/_ratio.mixins.scss +12 -0
- package/dist/collection/scss/utils/_ratio.scss +20 -0
- package/dist/collection/scss/utils/_sizing.mixins.scss +15 -0
- package/dist/collection/scss/utils/_sizing.scss +16 -0
- package/dist/collection/scss/utils/_spacing.mixins.scss +5 -0
- package/dist/collection/scss/utils/_spacing.scss +49 -0
- package/dist/collection/scss/utils/_toast.scss +77 -0
- package/dist/collection/scss/utils/_typography.mixins.scss +102 -0
- package/dist/collection/scss/utils/_typography.scss +34 -0
- package/dist/collection/scss/utils/_visibility.mixins.scss +29 -0
- package/dist/collection/scss/utils/_visibility.scss +13 -0
- package/dist/components/cat-checkbox.js +16 -5
- package/dist/components/cat-checkbox.js.map +1 -1
- package/dist/components/cat-form-hint.js +20 -0
- package/dist/components/cat-form-hint.js.map +1 -0
- package/dist/components/cat-icon2.js +1 -1
- package/dist/components/cat-icon2.js.map +1 -1
- package/dist/components/cat-input.js +16 -18
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-radio.js +16 -5
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-tab.d.ts +11 -0
- package/dist/components/cat-tab.js +70 -0
- package/dist/components/cat-tab.js.map +1 -0
- package/dist/components/cat-tabs.d.ts +11 -0
- package/dist/components/cat-tabs.js +107 -0
- package/dist/components/cat-tabs.js.map +1 -0
- package/dist/components/cat-textarea.js +14 -12
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-toggle.js +16 -5
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/cat-tooltip.js +13 -8
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/esm/app-globals-cf55f7f5.js.map +1 -1
- package/dist/esm/{cat-alert_16.entry.js → cat-alert_18.entry.js} +173 -45
- package/dist/esm/cat-alert_18.entry.js.map +1 -0
- package/dist/esm/cat-form-hint-dc443c7c.js +20 -0
- package/dist/esm/cat-form-hint-dc443c7c.js.map +1 -0
- package/dist/esm/cat-textarea.entry.js +13 -12
- package/dist/esm/cat-textarea.entry.js.map +1 -1
- package/dist/esm/catalyst.js +2 -2
- package/dist/esm/{index-fd12be19.js → index-039e6f5f.js} +44 -2
- package/dist/esm/index-039e6f5f.js.map +1 -0
- package/dist/esm/loader.js +2 -2
- package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +9 -0
- package/dist/types/components/cat-form-hint/cat-form-hint.d.ts +19 -0
- package/dist/types/components/cat-input/cat-input.d.ts +7 -5
- package/dist/types/components/cat-radio/cat-radio.d.ts +9 -0
- package/dist/types/components/cat-tab/cat-tab.d.ts +43 -0
- package/dist/types/components/cat-tabs/cat-tabs.d.ts +25 -0
- package/dist/types/components/cat-textarea/cat-textarea.d.ts +7 -2
- package/dist/types/components/cat-toggle/cat-toggle.d.ts +9 -0
- package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +1 -0
- package/dist/types/components.d.ts +134 -8
- package/package.json +2 -2
- package/dist/catalyst/p-6a5f0d4a.entry.js +0 -10
- package/dist/catalyst/p-6a5f0d4a.entry.js.map +0 -1
- package/dist/catalyst/p-a8629c54.entry.js +0 -2
- package/dist/catalyst/p-a8629c54.entry.js.map +0 -1
- package/dist/catalyst/p-bfc656ca.js +0 -2
- package/dist/catalyst/p-bfc656ca.js.map +0 -1
- package/dist/cjs/cat-alert_16.cjs.entry.js.map +0 -1
- package/dist/cjs/index-5d72f0e4.js.map +0 -1
- package/dist/esm/cat-alert_16.entry.js.map +0 -1
- package/dist/esm/index-fd12be19.js.map +0 -1
|
@@ -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,8 @@ export class CatCheckbox {
|
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
componentWillRender() {
|
|
45
|
-
|
|
49
|
+
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
50
|
+
if (!this.label && !this.hasSlottedLabel) {
|
|
46
51
|
log.error('[A11y] Missing ARIA label on checkbox', this);
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -56,16 +61,23 @@ export class CatCheckbox {
|
|
|
56
61
|
this.input.focus(options);
|
|
57
62
|
}
|
|
58
63
|
render() {
|
|
59
|
-
return (h(
|
|
60
|
-
h("
|
|
61
|
-
|
|
62
|
-
h("
|
|
63
|
-
h("
|
|
64
|
-
|
|
65
|
-
h("
|
|
66
|
-
|
|
64
|
+
return (h(Host, null,
|
|
65
|
+
h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } },
|
|
66
|
+
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) }),
|
|
67
|
+
h("span", { class: "box", "aria-hidden": "true", part: "checkbox" },
|
|
68
|
+
h("svg", { class: "check", viewBox: "0 0 12 10" },
|
|
69
|
+
h("polyline", { points: "1.5 6 4.5 9 10.5 1" })),
|
|
70
|
+
h("svg", { class: "dash", viewBox: "0 0 12 10" },
|
|
71
|
+
h("polyline", { points: "1.5 5 10.5 5" }))),
|
|
72
|
+
h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)),
|
|
73
|
+
this.hintSection));
|
|
74
|
+
}
|
|
75
|
+
get hintSection() {
|
|
76
|
+
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
77
|
+
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
67
78
|
}
|
|
68
79
|
onInput(event) {
|
|
80
|
+
this.value = this.input.value;
|
|
69
81
|
this.catChange.emit(event);
|
|
70
82
|
}
|
|
71
83
|
onFocus(event) {
|
|
@@ -210,7 +222,7 @@ export class CatCheckbox {
|
|
|
210
222
|
},
|
|
211
223
|
"value": {
|
|
212
224
|
"type": "string",
|
|
213
|
-
"mutable":
|
|
225
|
+
"mutable": true,
|
|
214
226
|
"complexType": {
|
|
215
227
|
"original": "string",
|
|
216
228
|
"resolved": "string | undefined",
|
|
@@ -224,8 +236,28 @@ export class CatCheckbox {
|
|
|
224
236
|
},
|
|
225
237
|
"attribute": "value",
|
|
226
238
|
"reflect": false
|
|
239
|
+
},
|
|
240
|
+
"hint": {
|
|
241
|
+
"type": "string",
|
|
242
|
+
"mutable": false,
|
|
243
|
+
"complexType": {
|
|
244
|
+
"original": "string | string[]",
|
|
245
|
+
"resolved": "string | string[] | undefined",
|
|
246
|
+
"references": {}
|
|
247
|
+
},
|
|
248
|
+
"required": false,
|
|
249
|
+
"optional": true,
|
|
250
|
+
"docs": {
|
|
251
|
+
"tags": [],
|
|
252
|
+
"text": "Optional hint text(s) to be displayed with the checkbox."
|
|
253
|
+
},
|
|
254
|
+
"attribute": "hint",
|
|
255
|
+
"reflect": false
|
|
227
256
|
}
|
|
228
257
|
}; }
|
|
258
|
+
static get states() { return {
|
|
259
|
+
"hasSlottedLabel": {}
|
|
260
|
+
}; }
|
|
229
261
|
static get events() { return [{
|
|
230
262
|
"method": "catChange",
|
|
231
263
|
"name": "catChange",
|
|
@@ -310,5 +342,6 @@ export class CatCheckbox {
|
|
|
310
342
|
}
|
|
311
343
|
}
|
|
312
344
|
}; }
|
|
345
|
+
static get elementRef() { return "hostElement"; }
|
|
313
346
|
}
|
|
314
347
|
//# sourceMappingURL=cat-checkbox.js.map
|
|
@@ -1 +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;
|
|
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;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,kBAAa,GAAG,KAAK,CAAC;IAE9B;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAEnB;;OAEG;IACK,gBAAW,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,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 this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\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"]}
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
/* stylelint-disable value-keyword-case */
|
|
5
5
|
/* stylelint-enable value-keyword-case */
|
|
6
6
|
:host {
|
|
7
|
+
/**
|
|
8
|
+
* @prop --cat-icon-ratio: The aspect ratio of the avatar.
|
|
9
|
+
*/
|
|
7
10
|
display: inline-flex;
|
|
8
11
|
vertical-align: middle;
|
|
9
12
|
/* stylelint-disable property-no-vendor-prefix */
|
|
@@ -25,8 +28,8 @@ svg {
|
|
|
25
28
|
fill: currentColor;
|
|
26
29
|
stroke: none;
|
|
27
30
|
transform-origin: center center;
|
|
28
|
-
width: 1em;
|
|
29
31
|
height: 1em;
|
|
32
|
+
width: calc(var(--cat-icon-ratio, 1) * 1em);
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
.icon-xs svg {
|
|
@@ -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
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Component, Event, h, Host, Method, Prop, State
|
|
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
|
import { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';
|
|
4
5
|
let nextUniqueId = 0;
|
|
5
6
|
/**
|
|
@@ -7,6 +8,8 @@ let nextUniqueId = 0;
|
|
|
7
8
|
* is short. As well as plain text, Input supports various types of text,
|
|
8
9
|
* including passwords and numbers.
|
|
9
10
|
*
|
|
11
|
+
* @slot hint - Optional hint element to be displayed with the input.
|
|
12
|
+
* @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.
|
|
10
13
|
* @part label - The label content.
|
|
11
14
|
* @part prefix - The text prefix.
|
|
12
15
|
* @part suffix - The text suffix.
|
|
@@ -15,7 +18,7 @@ export class CatInput {
|
|
|
15
18
|
constructor() {
|
|
16
19
|
this.i18n = CatI18nRegistry.getInstance();
|
|
17
20
|
this.id = `cat-input-${nextUniqueId++}`;
|
|
18
|
-
this.
|
|
21
|
+
this.hasSlottedLabel = false;
|
|
19
22
|
/**
|
|
20
23
|
* Whether the input should show a clear button.
|
|
21
24
|
*/
|
|
@@ -57,14 +60,9 @@ export class CatInput {
|
|
|
57
60
|
*/
|
|
58
61
|
this.type = 'text';
|
|
59
62
|
}
|
|
60
|
-
onValueChange(value) {
|
|
61
|
-
this.inputValue = '' + (value !== null && value !== void 0 ? value : '');
|
|
62
|
-
}
|
|
63
|
-
componentWillLoad() {
|
|
64
|
-
this.onValueChange(this.value);
|
|
65
|
-
}
|
|
66
63
|
componentWillRender() {
|
|
67
|
-
|
|
64
|
+
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
65
|
+
if (!this.label && !this.hasSlottedLabel) {
|
|
68
66
|
log.error('[A11y] Missing ARIA label on input', this);
|
|
69
67
|
}
|
|
70
68
|
}
|
|
@@ -81,13 +79,13 @@ export class CatInput {
|
|
|
81
79
|
* Clear the input.
|
|
82
80
|
*/
|
|
83
81
|
async clear() {
|
|
84
|
-
this.
|
|
82
|
+
this.value = '';
|
|
85
83
|
}
|
|
86
84
|
render() {
|
|
87
85
|
return (h(Host, null,
|
|
88
|
-
this.label && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
|
|
86
|
+
(this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
|
|
89
87
|
h("span", { part: "label" },
|
|
90
|
-
this.label,
|
|
88
|
+
(this.hasSlottedLabel && h("slot", { name: "label" })) || this.label,
|
|
91
89
|
!this.required && (h("span", { class: "input-optional", "aria-hidden": "true" },
|
|
92
90
|
"(",
|
|
93
91
|
this.i18n.getMessage('input.optional'),
|
|
@@ -102,14 +100,18 @@ export class CatInput {
|
|
|
102
100
|
h("div", { class: "input-inner-wrapper" },
|
|
103
101
|
h("input", { ref: el => (this.input = el), id: this.id, class: {
|
|
104
102
|
'has-clearable': this.clearable && !this.disabled
|
|
105
|
-
}, autocomplete: this.autoComplete, disabled: this.disabled, max: this.max, maxlength: this.maxLength, min: this.max, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, type: this.type, value: this.
|
|
106
|
-
this.clearable && !this.disabled && this.
|
|
103
|
+
}, autocomplete: this.autoComplete, disabled: this.disabled, max: this.max, maxlength: this.maxLength, min: this.max, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, type: this.type, value: this.value, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }),
|
|
104
|
+
this.clearable && !this.disabled && this.value && (h("cat-button", { class: "clearable", icon: "cross-circle-outlined", "icon-only": "true", size: "s", variant: "text", "a11y-label": this.i18n.getMessage('input.clear'), onClick: this.clear.bind(this) }))),
|
|
107
105
|
this.icon && this.iconRight && h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l" }),
|
|
108
106
|
this.textSuffix && (h("span", { class: "text-suffix", part: "suffix" }, this.textSuffix))),
|
|
109
|
-
this.
|
|
107
|
+
this.hintSection));
|
|
108
|
+
}
|
|
109
|
+
get hintSection() {
|
|
110
|
+
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
111
|
+
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
110
112
|
}
|
|
111
113
|
onInput(event) {
|
|
112
|
-
this.
|
|
114
|
+
this.value = this.input.value;
|
|
113
115
|
this.catChange.emit(event);
|
|
114
116
|
}
|
|
115
117
|
onFocus(event) {
|
|
@@ -184,15 +186,15 @@ export class CatInput {
|
|
|
184
186
|
"type": "string",
|
|
185
187
|
"mutable": false,
|
|
186
188
|
"complexType": {
|
|
187
|
-
"original": "string",
|
|
188
|
-
"resolved": "string | undefined",
|
|
189
|
+
"original": "string | string[]",
|
|
190
|
+
"resolved": "string | string[] | undefined",
|
|
189
191
|
"references": {}
|
|
190
192
|
},
|
|
191
193
|
"required": false,
|
|
192
194
|
"optional": true,
|
|
193
195
|
"docs": {
|
|
194
196
|
"tags": [],
|
|
195
|
-
"text": "Optional hint text to be displayed with the input."
|
|
197
|
+
"text": "Optional hint text(s) to be displayed with the input."
|
|
196
198
|
},
|
|
197
199
|
"attribute": "hint",
|
|
198
200
|
"reflect": false
|
|
@@ -479,7 +481,7 @@ export class CatInput {
|
|
|
479
481
|
},
|
|
480
482
|
"value": {
|
|
481
483
|
"type": "any",
|
|
482
|
-
"mutable":
|
|
484
|
+
"mutable": true,
|
|
483
485
|
"complexType": {
|
|
484
486
|
"original": "string | number",
|
|
485
487
|
"resolved": "number | string | undefined",
|
|
@@ -496,7 +498,7 @@ export class CatInput {
|
|
|
496
498
|
}
|
|
497
499
|
}; }
|
|
498
500
|
static get states() { return {
|
|
499
|
-
"
|
|
501
|
+
"hasSlottedLabel": {}
|
|
500
502
|
}; }
|
|
501
503
|
static get events() { return [{
|
|
502
504
|
"method": "catChange",
|
|
@@ -598,9 +600,6 @@ export class CatInput {
|
|
|
598
600
|
}
|
|
599
601
|
}
|
|
600
602
|
}; }
|
|
601
|
-
static get
|
|
602
|
-
"propName": "value",
|
|
603
|
-
"methodName": "onValueChange"
|
|
604
|
-
}]; }
|
|
603
|
+
static get elementRef() { return "hostElement"; }
|
|
605
604
|
}
|
|
606
605
|
//# sourceMappingURL=cat-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-input.js","sourceRoot":"","sources":["../../../src/components/cat-input/cat-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;;;GAQG;AAMH,MA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AAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IACnC,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, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport log from 'loglevel';\nimport { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';\n\nlet nextUniqueId = 0;\n\n/**\n * Inputs are used to allow users to provide text input when the expected input\n * is short. As well as plain text, Input supports various types of text,\n * including passwords and numbers.\n *\n * @part label - The label content.\n * @part prefix - The text prefix.\n * @part suffix - The text suffix.\n */\n@Component({\n tag: 'cat-input',\n styleUrl: 'cat-input.scss',\n shadow: true\n})\nexport class CatInput {\n private readonly i18n = CatI18nRegistry.getInstance();\n private readonly id = `cat-input-${nextUniqueId++}`;\n private input!: HTMLInputElement;\n\n @State() private inputValue = '';\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text to be displayed with the input.\n */\n @Prop() hint?: string;\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value for numeric values.\n */\n @Prop() max?: number;\n\n /**\n * A maximum length (number of characters) for textual values.\n */\n @Prop() maxLength?: number;\n\n /**\n * A minimum value for numeric values.\n */\n @Prop() min?: number;\n\n /**\n * A minimum length (number of characters) for textual values.\n */\n @Prop() minLength?: number;\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name = '';\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * Use round input edges.\n */\n @Prop() round = false;\n\n /**\n * Type of form control.\n */\n @Prop() type: 'text' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'number' = 'text';\n\n /**\n * The initial value of the control.\n */\n @Prop() value?: string | number;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n @Watch('value')\n onValueChange(value?: string | number) {\n this.inputValue = '' + (value ?? '');\n }\n\n componentWillLoad() {\n this.onValueChange(this.value);\n }\n\n componentWillRender(): void {\n if (!this.label) {\n log.error('[A11y] Missing ARIA label on input', this);\n }\n }\n\n /**\n * Sets focus on the input. Use this method instead of `input.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 /**\n * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.inputValue = '';\n }\n\n render() {\n return (\n <Host>\n {this.label && (\n <label htmlFor={this.id} class={{ hidden: this.labelHidden }}>\n <span part=\"label\">\n {this.label}\n {!this.required && (\n <span class=\"input-optional\" aria-hidden=\"true\">\n ({this.i18n.getMessage('input.optional')})\n </span>\n )}\n </span>\n </label>\n )}\n <div\n class={{\n 'input-wrapper': true,\n 'input-round': this.round,\n 'input-disabled': this.disabled\n }}\n onClick={() => this.input.focus()}\n >\n {this.textPrefix && (\n <span class=\"text-prefix\" part=\"prefix\">\n {this.textPrefix}\n </span>\n )}\n {this.icon && !this.iconRight && <cat-icon icon={this.icon} class=\"icon-prefix\" size=\"l\"></cat-icon>}\n <div class=\"input-inner-wrapper\">\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n class={{\n 'has-clearable': this.clearable && !this.disabled\n }}\n autocomplete={this.autoComplete}\n disabled={this.disabled}\n max={this.max}\n maxlength={this.maxLength}\n min={this.max}\n minlength={this.minLength}\n name={this.name}\n placeholder={this.placeholder}\n readonly={this.readonly}\n required={this.required}\n type={this.type}\n value={this.inputValue}\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n ></input>\n {this.clearable && !this.disabled && this.inputValue && (\n <cat-button\n class=\"clearable\"\n icon=\"cross-circle-outlined\"\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={this.i18n.getMessage('input.clear')}\n onClick={this.clear.bind(this)}\n ></cat-button>\n )}\n </div>\n {this.icon && this.iconRight && <cat-icon icon={this.icon} class=\"icon-suffix\" size=\"l\"></cat-icon>}\n {this.textSuffix && (\n <span class=\"text-suffix\" part=\"suffix\">\n {this.textSuffix}\n </span>\n )}\n </div>\n {this.hint && <p class=\"input-hint\">{this.hint}</p>}\n </Host>\n );\n }\n\n private onInput(event: Event) {\n this.inputValue = 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"]}
|
|
1
|
+
{"version":3,"file":"cat-input.js","sourceRoot":"","sources":["../../../src/components/cat-input/cat-input.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;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;;;;;GAUG;AAMH,MAAM,OAAO,QAAQ;EALrB;IAMmB,SAAI,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IACrC,OAAE,GAAG,aAAa,YAAY,EAAE,EAAE,CAAC;IAK3C,oBAAe,GAAG,KAAK,CAAC;IAOjC;;OAEG;IACK,cAAS,GAAG,KAAK,CAAC;IAE1B;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAYzB;;OAEG;IACK,cAAS,GAAG,KAAK,CAAC;IAE1B;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAEnB;;OAEG;IACK,gBAA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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, Element, Event, EventEmitter, h, Host, Method, Prop, State } from '@stencil/core';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\nimport { CatI18nRegistry } from '../cat-i18n/cat-i18n-registry';\n\nlet nextUniqueId = 0;\n\n/**\n * Inputs are used to allow users to provide text input when the expected input\n * is short. As well as plain text, Input supports various types of text,\n * including passwords and numbers.\n *\n * @slot hint - Optional hint element to be displayed with the input.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n * @part prefix - The text prefix.\n * @part suffix - The text suffix.\n */\n@Component({\n tag: 'cat-input',\n styleUrl: 'cat-input.scss',\n shadow: true\n})\nexport class CatInput {\n private readonly i18n = CatI18nRegistry.getInstance();\n private readonly id = `cat-input-${nextUniqueId++}`;\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value for numeric values.\n */\n @Prop() max?: number;\n\n /**\n * A maximum length (number of characters) for textual values.\n */\n @Prop() maxLength?: number;\n\n /**\n * A minimum value for numeric values.\n */\n @Prop() min?: number;\n\n /**\n * A minimum length (number of characters) for textual values.\n */\n @Prop() minLength?: number;\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name = '';\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * Use round input edges.\n */\n @Prop() round = false;\n\n /**\n * Type of form control.\n */\n @Prop() type: 'text' | 'email' | 'password' | 'tel' | 'url' | 'search' | 'number' = 'text';\n\n /**\n * The initial value of the control.\n */\n @Prop({ mutable: true }) value?: string | number;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.error('[A11y] Missing ARIA label on input', this);\n }\n }\n\n /**\n * Sets focus on the input. Use this method instead of `input.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 /**\n * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.value = '';\n }\n\n render() {\n return (\n <Host>\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={this.id} class={{ hidden: this.labelHidden }}>\n <span part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n {!this.required && (\n <span class=\"input-optional\" aria-hidden=\"true\">\n ({this.i18n.getMessage('input.optional')})\n </span>\n )}\n </span>\n </label>\n )}\n <div\n class={{\n 'input-wrapper': true,\n 'input-round': this.round,\n 'input-disabled': this.disabled\n }}\n onClick={() => this.input.focus()}\n >\n {this.textPrefix && (\n <span class=\"text-prefix\" part=\"prefix\">\n {this.textPrefix}\n </span>\n )}\n {this.icon && !this.iconRight && <cat-icon icon={this.icon} class=\"icon-prefix\" size=\"l\"></cat-icon>}\n <div class=\"input-inner-wrapper\">\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n class={{\n 'has-clearable': this.clearable && !this.disabled\n }}\n autocomplete={this.autoComplete}\n disabled={this.disabled}\n max={this.max}\n maxlength={this.maxLength}\n min={this.max}\n minlength={this.minLength}\n name={this.name}\n placeholder={this.placeholder}\n readonly={this.readonly}\n required={this.required}\n type={this.type}\n value={this.value}\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n ></input>\n {this.clearable && !this.disabled && this.value && (\n <cat-button\n class=\"clearable\"\n icon=\"cross-circle-outlined\"\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={this.i18n.getMessage('input.clear')}\n onClick={this.clear.bind(this)}\n ></cat-button>\n )}\n </div>\n {this.icon && this.iconRight && <cat-icon icon={this.icon} class=\"icon-suffix\" size=\"l\"></cat-icon>}\n {this.textSuffix && (\n <span class=\"text-suffix\" part=\"suffix\">\n {this.textSuffix}\n </span>\n )}\n </div>\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"]}
|
|
@@ -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,15 +1,19 @@
|
|
|
1
|
-
import { Component, Event, h,
|
|
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
|
* Radio Buttons are graphical interface elements that allow user to choose
|
|
6
7
|
* only one of a predefined set of mutually exclusive options.
|
|
7
8
|
*
|
|
9
|
+
* @slot hint - Optional hint element to be displayed with the radio.
|
|
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 label - The label content.
|
|
9
12
|
*/
|
|
10
13
|
export class CatRadio {
|
|
11
14
|
constructor() {
|
|
12
15
|
this.id = `cat-radio-${++nextUniqueId}`;
|
|
16
|
+
this.hasSlottedLabel = false;
|
|
13
17
|
/**
|
|
14
18
|
* Whether this radio is checked.
|
|
15
19
|
*/
|
|
@@ -32,7 +36,8 @@ export class CatRadio {
|
|
|
32
36
|
this.required = false;
|
|
33
37
|
}
|
|
34
38
|
componentWillRender() {
|
|
35
|
-
|
|
39
|
+
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
40
|
+
if (!this.label && !this.hasSlottedLabel) {
|
|
36
41
|
log.error('[A11y] Missing ARIA label on radio', this);
|
|
37
42
|
}
|
|
38
43
|
}
|
|
@@ -46,13 +51,20 @@ export class CatRadio {
|
|
|
46
51
|
this.input.focus(options);
|
|
47
52
|
}
|
|
48
53
|
render() {
|
|
49
|
-
return (h(
|
|
50
|
-
h("
|
|
51
|
-
h("
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
return (h(Host, null,
|
|
55
|
+
h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } },
|
|
56
|
+
h("span", { class: "radio" },
|
|
57
|
+
h("input", { ref: el => (this.input = el), id: this.id, type: "radio", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, onInput: this.onChange.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }),
|
|
58
|
+
h("span", { class: "circle" })),
|
|
59
|
+
h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)),
|
|
60
|
+
this.hintSection));
|
|
61
|
+
}
|
|
62
|
+
get hintSection() {
|
|
63
|
+
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
64
|
+
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
54
65
|
}
|
|
55
66
|
onChange(event) {
|
|
67
|
+
this.value = this.input.value;
|
|
56
68
|
this.catChange.emit(event);
|
|
57
69
|
}
|
|
58
70
|
onFocus(event) {
|
|
@@ -179,7 +191,7 @@ export class CatRadio {
|
|
|
179
191
|
},
|
|
180
192
|
"value": {
|
|
181
193
|
"type": "string",
|
|
182
|
-
"mutable":
|
|
194
|
+
"mutable": true,
|
|
183
195
|
"complexType": {
|
|
184
196
|
"original": "string",
|
|
185
197
|
"resolved": "string | undefined",
|
|
@@ -193,8 +205,28 @@ export class CatRadio {
|
|
|
193
205
|
},
|
|
194
206
|
"attribute": "value",
|
|
195
207
|
"reflect": false
|
|
208
|
+
},
|
|
209
|
+
"hint": {
|
|
210
|
+
"type": "string",
|
|
211
|
+
"mutable": false,
|
|
212
|
+
"complexType": {
|
|
213
|
+
"original": "string | string[]",
|
|
214
|
+
"resolved": "string | string[] | undefined",
|
|
215
|
+
"references": {}
|
|
216
|
+
},
|
|
217
|
+
"required": false,
|
|
218
|
+
"optional": true,
|
|
219
|
+
"docs": {
|
|
220
|
+
"tags": [],
|
|
221
|
+
"text": "Optional hint text(s) to be displayed with the radio."
|
|
222
|
+
},
|
|
223
|
+
"attribute": "hint",
|
|
224
|
+
"reflect": false
|
|
196
225
|
}
|
|
197
226
|
}; }
|
|
227
|
+
static get states() { return {
|
|
228
|
+
"hasSlottedLabel": {}
|
|
229
|
+
}; }
|
|
198
230
|
static get events() { return [{
|
|
199
231
|
"method": "catChange",
|
|
200
232
|
"name": "catChange",
|
|
@@ -279,5 +311,6 @@ export class CatRadio {
|
|
|
279
311
|
}
|
|
280
312
|
}
|
|
281
313
|
}; }
|
|
314
|
+
static get elementRef() { return "hostElement"; }
|
|
282
315
|
}
|
|
283
316
|
//# sourceMappingURL=cat-radio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-radio.js","sourceRoot":"","sources":["../../../src/components/cat-radio/cat-radio.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"cat-radio.js","sourceRoot":"","sources":["../../../src/components/cat-radio/cat-radio.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;;;;;;;GAOG;AAMH,MAAM,OAAO,QAAQ;EALrB;IAMmB,OAAE,GAAG,aAAa,EAAE,YAAY,EAAE,CAAC;IAK3C,oBAAe,GAAG,KAAK,CAAC;IAEjC;;OAEG;IACK,YAAO,GAAG,KAAK,CAAC;IAExB;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAEnB;;OAEG;IACK,gBAAW,GAAG,KAAK,CAAC;IAO5B;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;GA+F1B;EApEC,mBAAmB;IACjB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC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,EAAC,OAAO,GAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAC9D,CACD;MACP,IAAI,CAAC,WAAW,CACZ,CACR,CAAC;EACJ,CAAC;EAED,IAAY,WAAW;IACrB,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IACzE,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,IAAI,cAAc,CAAC,IAAI,CAC/B,EAAC,WAAW,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,IAAI,YAAM,IAAI,EAAC,MAAM,GAAQ,GAAI,CAC3F,CACF,CAAC;EACJ,CAAC;EAEO,QAAQ,CAAC,KAAY;IAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC9B,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, 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 * Radio Buttons are graphical interface elements that allow user to choose\n * only one of a predefined set of mutually exclusive options.\n *\n * @slot hint - Optional hint element to be displayed with the radio.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-radio',\n styleUrl: 'cat-radio.scss',\n shadow: true\n})\nexport class CatRadio {\n private readonly id = `cat-radio-${++nextUniqueId}`;\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Whether this radio is checked.\n */\n @Prop() checked = false;\n\n /**\n * Whether this radio is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * The label of the radio that is visible.\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 radio component.\n */\n @Prop() name?: string;\n\n /**\n * Whether the radio is required.\n */\n @Prop() required = false;\n\n /**\n * The value of the radio component.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Optional hint text(s) to be displayed with the radio.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Emitted when the radio is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the radio received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the radio loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.error('[A11y] Missing ARIA label on radio', this);\n }\n }\n\n /**\n * Sets focus on the radio. Use this method instead of `radio.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 <span class=\"radio\">\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n type=\"radio\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n required={this.required}\n disabled={this.disabled}\n onInput={this.onChange.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n />\n <span class=\"circle\"></span>\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 onChange(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"]}
|