@haiilo/catalyst 0.5.13 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalyst/catalyst.css +1 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/p-12486027.js.map +1 -1
- package/dist/catalyst/p-12b96af6.js +2 -0
- package/dist/catalyst/p-12b96af6.js.map +1 -0
- package/dist/catalyst/p-4c9cd203.entry.js +2 -0
- package/dist/catalyst/p-4c9cd203.entry.js.map +1 -0
- package/dist/catalyst/p-5616e2cd.js +2 -0
- package/dist/catalyst/p-5616e2cd.js.map +1 -0
- package/dist/catalyst/p-9d2eab4f.entry.js +10 -0
- package/dist/catalyst/p-9d2eab4f.entry.js.map +1 -0
- package/dist/cjs/app-globals-aa29ad72.js.map +1 -1
- package/dist/cjs/{cat-alert_15.cjs.entry.js → cat-alert_18.cjs.entry.js} +277 -65
- package/dist/cjs/cat-alert_18.cjs.entry.js.map +1 -0
- package/dist/cjs/cat-form-hint-93a6936b.js +22 -0
- package/dist/cjs/cat-form-hint-93a6936b.js.map +1 -0
- package/dist/cjs/cat-textarea.cjs.entry.js +12 -12
- package/dist/cjs/cat-textarea.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +2 -2
- package/dist/cjs/{index-5d72f0e4.js → index-499bad41.js} +44 -1
- package/dist/cjs/index-499bad41.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/cat-avatar/cat-avatar.css +81 -0
- package/dist/collection/components/cat-avatar/cat-avatar.js +225 -0
- package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -0
- package/dist/collection/components/cat-badge/cat-badge.css +5 -5
- package/dist/collection/components/cat-button/cat-button.js +8 -8
- package/dist/collection/components/cat-button/cat-button.js.map +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +14 -0
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +43 -11
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
- package/dist/collection/components/cat-form-hint/cat-form-hint.js +16 -0
- package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -0
- package/dist/collection/components/cat-input/cat-input.css +12 -6
- package/dist/collection/components/cat-input/cat-input.js +23 -25
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.css +14 -0
- package/dist/collection/components/cat-radio/cat-radio.js +40 -8
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-scrollable/cat-scrollable.js +44 -44
- package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
- package/dist/collection/components/cat-tab/cat-tab.css +12 -0
- package/dist/collection/components/cat-tab/cat-tab.js +203 -0
- package/dist/collection/components/cat-tab/cat-tab.js.map +1 -0
- package/dist/collection/components/cat-tabs/cat-tabs.css +33 -0
- package/dist/collection/components/cat-tabs/cat-tabs.js +122 -0
- package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -0
- package/dist/collection/components/cat-textarea/cat-textarea.css +12 -6
- package/dist/collection/components/cat-textarea/cat-textarea.js +23 -18
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.css +14 -0
- package/dist/collection/components/cat-toggle/cat-toggle.js +39 -7
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +13 -8
- package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
- package/dist/collection/utils/load-img.js +16 -0
- package/dist/collection/utils/load-img.js.map +1 -0
- package/dist/components/cat-avatar.d.ts +11 -0
- package/dist/components/cat-avatar.js +125 -0
- package/dist/components/cat-avatar.js.map +1 -0
- package/dist/components/cat-badge.js +1 -1
- package/dist/components/cat-badge.js.map +1 -1
- package/dist/components/cat-button2.js +5 -5
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-checkbox.js +15 -5
- package/dist/components/cat-checkbox.js.map +1 -1
- package/dist/components/cat-form-hint.js +20 -0
- package/dist/components/cat-form-hint.js.map +1 -0
- package/dist/components/cat-input.js +15 -18
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-radio.js +15 -5
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-scrollable.js +23 -23
- package/dist/components/cat-scrollable.js.map +1 -1
- package/dist/components/cat-tab.d.ts +11 -0
- package/dist/components/cat-tab.js +70 -0
- package/dist/components/cat-tab.js.map +1 -0
- package/dist/components/cat-tabs.d.ts +11 -0
- package/dist/components/cat-tabs.js +107 -0
- package/dist/components/cat-tabs.js.map +1 -0
- package/dist/components/cat-textarea.js +13 -12
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-toggle.js +15 -5
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/cat-tooltip.js +13 -8
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/esm/app-globals-cf55f7f5.js.map +1 -1
- package/dist/esm/{cat-alert_15.entry.js → cat-alert_18.entry.js} +275 -66
- package/dist/esm/cat-alert_18.entry.js.map +1 -0
- package/dist/esm/cat-form-hint-dc443c7c.js +20 -0
- package/dist/esm/cat-form-hint-dc443c7c.js.map +1 -0
- package/dist/esm/cat-textarea.entry.js +12 -12
- package/dist/esm/cat-textarea.entry.js.map +1 -1
- package/dist/esm/catalyst.js +2 -2
- package/dist/esm/{index-fd12be19.js → index-039e6f5f.js} +44 -2
- package/dist/esm/index-039e6f5f.js.map +1 -0
- package/dist/esm/loader.js +2 -2
- package/dist/types/components/cat-avatar/cat-avatar.d.ts +46 -0
- package/dist/types/components/cat-button/cat-button.d.ts +2 -2
- package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +9 -0
- package/dist/types/components/cat-form-hint/cat-form-hint.d.ts +19 -0
- package/dist/types/components/cat-input/cat-input.d.ts +7 -5
- package/dist/types/components/cat-radio/cat-radio.d.ts +9 -0
- package/dist/types/components/cat-scrollable/cat-scrollable.d.ts +12 -12
- package/dist/types/components/cat-tab/cat-tab.d.ts +43 -0
- package/dist/types/components/cat-tabs/cat-tabs.d.ts +25 -0
- package/dist/types/components/cat-textarea/cat-textarea.d.ts +7 -2
- package/dist/types/components/cat-toggle/cat-toggle.d.ts +9 -0
- package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +1 -0
- package/dist/types/components.d.ts +255 -52
- package/dist/types/utils/load-img.d.ts +8 -0
- package/package.json +2 -2
- package/dist/catalyst/p-a8629c54.entry.js +0 -2
- package/dist/catalyst/p-a8629c54.entry.js.map +0 -1
- package/dist/catalyst/p-bfc656ca.js +0 -2
- package/dist/catalyst/p-bfc656ca.js.map +0 -1
- package/dist/catalyst/p-e6491f33.entry.js +0 -10
- package/dist/catalyst/p-e6491f33.entry.js.map +0 -1
- package/dist/cjs/cat-alert_15.cjs.entry.js.map +0 -1
- package/dist/cjs/index-5d72f0e4.js.map +0 -1
- package/dist/esm/cat-alert_15.entry.js.map +0 -1
- package/dist/esm/index-fd12be19.js.map +0 -1
|
@@ -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,8 @@ 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
|
-
if (!this.label) {
|
|
64
|
+
if (!this.label && !this.hostElement.querySelector('[slot="label"]')) {
|
|
68
65
|
log.error('[A11y] Missing ARIA label on input', this);
|
|
69
66
|
}
|
|
70
67
|
}
|
|
@@ -81,13 +78,13 @@ export class CatInput {
|
|
|
81
78
|
* Clear the input.
|
|
82
79
|
*/
|
|
83
80
|
async clear() {
|
|
84
|
-
this.
|
|
81
|
+
this.value = '';
|
|
85
82
|
}
|
|
86
83
|
render() {
|
|
87
84
|
return (h(Host, null,
|
|
88
|
-
this.label && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
|
|
85
|
+
(this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
|
|
89
86
|
h("span", { part: "label" },
|
|
90
|
-
this.label,
|
|
87
|
+
(this.hasSlottedLabel && h("slot", { name: "label" })) || this.label,
|
|
91
88
|
!this.required && (h("span", { class: "input-optional", "aria-hidden": "true" },
|
|
92
89
|
"(",
|
|
93
90
|
this.i18n.getMessage('input.optional'),
|
|
@@ -102,14 +99,18 @@ export class CatInput {
|
|
|
102
99
|
h("div", { class: "input-inner-wrapper" },
|
|
103
100
|
h("input", { ref: el => (this.input = el), id: this.id, class: {
|
|
104
101
|
'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.
|
|
102
|
+
}, 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) }),
|
|
103
|
+
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
104
|
this.icon && this.iconRight && h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l" }),
|
|
108
105
|
this.textSuffix && (h("span", { class: "text-suffix", part: "suffix" }, this.textSuffix))),
|
|
109
|
-
this.
|
|
106
|
+
this.hintSection));
|
|
107
|
+
}
|
|
108
|
+
get hintSection() {
|
|
109
|
+
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
110
|
+
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
110
111
|
}
|
|
111
112
|
onInput(event) {
|
|
112
|
-
this.
|
|
113
|
+
this.value = this.input.value;
|
|
113
114
|
this.catChange.emit(event);
|
|
114
115
|
}
|
|
115
116
|
onFocus(event) {
|
|
@@ -184,15 +185,15 @@ export class CatInput {
|
|
|
184
185
|
"type": "string",
|
|
185
186
|
"mutable": false,
|
|
186
187
|
"complexType": {
|
|
187
|
-
"original": "string",
|
|
188
|
-
"resolved": "string | undefined",
|
|
188
|
+
"original": "string | string[]",
|
|
189
|
+
"resolved": "string | string[] | undefined",
|
|
189
190
|
"references": {}
|
|
190
191
|
},
|
|
191
192
|
"required": false,
|
|
192
193
|
"optional": true,
|
|
193
194
|
"docs": {
|
|
194
195
|
"tags": [],
|
|
195
|
-
"text": "Optional hint text to be displayed with the input."
|
|
196
|
+
"text": "Optional hint text(s) to be displayed with the input."
|
|
196
197
|
},
|
|
197
198
|
"attribute": "hint",
|
|
198
199
|
"reflect": false
|
|
@@ -479,7 +480,7 @@ export class CatInput {
|
|
|
479
480
|
},
|
|
480
481
|
"value": {
|
|
481
482
|
"type": "any",
|
|
482
|
-
"mutable":
|
|
483
|
+
"mutable": true,
|
|
483
484
|
"complexType": {
|
|
484
485
|
"original": "string | number",
|
|
485
486
|
"resolved": "number | string | undefined",
|
|
@@ -496,7 +497,7 @@ export class CatInput {
|
|
|
496
497
|
}
|
|
497
498
|
}; }
|
|
498
499
|
static get states() { return {
|
|
499
|
-
"
|
|
500
|
+
"hasSlottedLabel": {}
|
|
500
501
|
}; }
|
|
501
502
|
static get events() { return [{
|
|
502
503
|
"method": "catChange",
|
|
@@ -598,9 +599,6 @@ export class CatInput {
|
|
|
598
599
|
}
|
|
599
600
|
}
|
|
600
601
|
}; }
|
|
601
|
-
static get
|
|
602
|
-
"propName": "value",
|
|
603
|
-
"methodName": "onValueChange"
|
|
604
|
-
}]; }
|
|
602
|
+
static get elementRef() { return "hostElement"; }
|
|
605
603
|
}
|
|
606
604
|
//# 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,EA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C,QAAQ,IACpC,IAAI,CAAC,UAAU,CACX,CACR,CACG;MACL,IAAI,CAAC,IAAI,IAAI,SAAG,KAAK,EAAC,YAAY,IAAE,IAAI,CAAC,IAAI,CAAK,CAC9C,CACR,CAAC;EACJ,CAAC;EAEO,OAAO,CAAC,KAAY;IAC1B,IAAI,CAAC,UAAU,GAAG,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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C3F,CACF,CAAC;EACJ,CAAC;EAEO,OAAO,CAAC,KAAY;IAC1B,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';\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 if (!this.label && !this.hostElement.querySelector('[slot=\"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.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,7 @@ export class CatRadio {
|
|
|
32
36
|
this.required = false;
|
|
33
37
|
}
|
|
34
38
|
componentWillRender() {
|
|
35
|
-
if (!this.label) {
|
|
39
|
+
if (!this.label && !this.hostElement.querySelector('[slot="label"]')) {
|
|
36
40
|
log.error('[A11y] Missing ARIA label on radio', this);
|
|
37
41
|
}
|
|
38
42
|
}
|
|
@@ -46,13 +50,20 @@ export class CatRadio {
|
|
|
46
50
|
this.input.focus(options);
|
|
47
51
|
}
|
|
48
52
|
render() {
|
|
49
|
-
return (h(
|
|
50
|
-
h("
|
|
51
|
-
h("
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
return (h(Host, null,
|
|
54
|
+
h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } },
|
|
55
|
+
h("span", { class: "radio" },
|
|
56
|
+
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) }),
|
|
57
|
+
h("span", { class: "circle" })),
|
|
58
|
+
h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)),
|
|
59
|
+
this.hintSection));
|
|
60
|
+
}
|
|
61
|
+
get hintSection() {
|
|
62
|
+
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
63
|
+
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
54
64
|
}
|
|
55
65
|
onChange(event) {
|
|
66
|
+
this.value = this.input.value;
|
|
56
67
|
this.catChange.emit(event);
|
|
57
68
|
}
|
|
58
69
|
onFocus(event) {
|
|
@@ -179,7 +190,7 @@ export class CatRadio {
|
|
|
179
190
|
},
|
|
180
191
|
"value": {
|
|
181
192
|
"type": "string",
|
|
182
|
-
"mutable":
|
|
193
|
+
"mutable": true,
|
|
183
194
|
"complexType": {
|
|
184
195
|
"original": "string",
|
|
185
196
|
"resolved": "string | undefined",
|
|
@@ -193,8 +204,28 @@ export class CatRadio {
|
|
|
193
204
|
},
|
|
194
205
|
"attribute": "value",
|
|
195
206
|
"reflect": false
|
|
207
|
+
},
|
|
208
|
+
"hint": {
|
|
209
|
+
"type": "string",
|
|
210
|
+
"mutable": false,
|
|
211
|
+
"complexType": {
|
|
212
|
+
"original": "string | string[]",
|
|
213
|
+
"resolved": "string | string[] | undefined",
|
|
214
|
+
"references": {}
|
|
215
|
+
},
|
|
216
|
+
"required": false,
|
|
217
|
+
"optional": true,
|
|
218
|
+
"docs": {
|
|
219
|
+
"tags": [],
|
|
220
|
+
"text": "Optional hint text(s) to be displayed with the radio."
|
|
221
|
+
},
|
|
222
|
+
"attribute": "hint",
|
|
223
|
+
"reflect": false
|
|
196
224
|
}
|
|
197
225
|
}; }
|
|
226
|
+
static get states() { return {
|
|
227
|
+
"hasSlottedLabel": {}
|
|
228
|
+
}; }
|
|
198
229
|
static get events() { return [{
|
|
199
230
|
"method": "catChange",
|
|
200
231
|
"name": "catChange",
|
|
@@ -279,5 +310,6 @@ export class CatRadio {
|
|
|
279
310
|
}
|
|
280
311
|
}
|
|
281
312
|
}; }
|
|
313
|
+
static get elementRef() { return "hostElement"; }
|
|
282
314
|
}
|
|
283
315
|
//# 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,GA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I,YAAM,IAAI,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 if (!this.label && !this.hostElement.querySelector('[slot=\"label\"]')) {\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"]}
|
|
@@ -8,20 +8,20 @@ export class CatScrollable {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
this.init = new Subject();
|
|
10
10
|
this.destroyed = new Subject();
|
|
11
|
-
/** Flags to enable
|
|
12
|
-
this.
|
|
13
|
-
/** Flags to enable
|
|
14
|
-
this.
|
|
15
|
-
/** Flags to enable
|
|
16
|
-
this.
|
|
17
|
-
/** Flags to enable
|
|
18
|
-
this.
|
|
19
|
-
/** Flag to enable
|
|
20
|
-
this.
|
|
11
|
+
/** Flags to disable/enable scroll shadowX. */
|
|
12
|
+
this.noShadowX = false;
|
|
13
|
+
/** Flags to disable/enable scroll shadowY. */
|
|
14
|
+
this.noShadowY = false;
|
|
15
|
+
/** Flags to disable/enable overflowX. */
|
|
16
|
+
this.noOverflowX = false;
|
|
17
|
+
/** Flags to disable/enable overflowY. */
|
|
18
|
+
this.noOverflowY = false;
|
|
19
|
+
/** Flag to disable/enable overscroll behavior. */
|
|
20
|
+
this.noOverscroll = false;
|
|
21
21
|
/**
|
|
22
|
-
* Flag to fire an initial event after content initialization.
|
|
22
|
+
* Flag to not fire an initial event after content initialization.
|
|
23
23
|
*/
|
|
24
|
-
this.
|
|
24
|
+
this.noScrolledInit = false;
|
|
25
25
|
/**
|
|
26
26
|
* Buffer to be used to calculate the scroll distance.
|
|
27
27
|
*/
|
|
@@ -50,7 +50,7 @@ export class CatScrollable {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
componentDidLoad() {
|
|
53
|
-
if (this.
|
|
53
|
+
if (!this.noScrolledInit) {
|
|
54
54
|
this.init.next();
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -62,15 +62,15 @@ export class CatScrollable {
|
|
|
62
62
|
render() {
|
|
63
63
|
return [
|
|
64
64
|
h("div", { class: "scrollable-wrapper", ref: el => (this.scrollWrapperElement = el) },
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
65
|
+
!this.noShadowY && h("div", { class: "shadow-top" }),
|
|
66
|
+
!this.noShadowX && h("div", { class: "shadow-left" }),
|
|
67
|
+
!this.noShadowX && h("div", { class: "shadow-right" }),
|
|
68
|
+
!this.noShadowY && h("div", { class: "shadow-bottom" })),
|
|
69
69
|
h("div", { ref: el => (this.scrollElement = el), class: {
|
|
70
70
|
'scrollable-content': true,
|
|
71
|
-
'scroll-x': this.
|
|
72
|
-
'scroll-y': this.
|
|
73
|
-
'no-overscroll':
|
|
71
|
+
'scroll-x': !this.noOverflowX,
|
|
72
|
+
'scroll-y': !this.noOverflowY,
|
|
73
|
+
'no-overscroll': this.noOverscroll
|
|
74
74
|
} },
|
|
75
75
|
h("slot", null))
|
|
76
76
|
];
|
|
@@ -119,7 +119,7 @@ export class CatScrollable {
|
|
|
119
119
|
"$": ["cat-scrollable.css"]
|
|
120
120
|
}; }
|
|
121
121
|
static get properties() { return {
|
|
122
|
-
"
|
|
122
|
+
"noShadowX": {
|
|
123
123
|
"type": "boolean",
|
|
124
124
|
"mutable": false,
|
|
125
125
|
"complexType": {
|
|
@@ -131,13 +131,13 @@ export class CatScrollable {
|
|
|
131
131
|
"optional": false,
|
|
132
132
|
"docs": {
|
|
133
133
|
"tags": [],
|
|
134
|
-
"text": "Flags to enable
|
|
134
|
+
"text": "Flags to disable/enable scroll shadowX."
|
|
135
135
|
},
|
|
136
|
-
"attribute": "shadow-x",
|
|
136
|
+
"attribute": "no-shadow-x",
|
|
137
137
|
"reflect": false,
|
|
138
|
-
"defaultValue": "
|
|
138
|
+
"defaultValue": "false"
|
|
139
139
|
},
|
|
140
|
-
"
|
|
140
|
+
"noShadowY": {
|
|
141
141
|
"type": "boolean",
|
|
142
142
|
"mutable": false,
|
|
143
143
|
"complexType": {
|
|
@@ -149,13 +149,13 @@ export class CatScrollable {
|
|
|
149
149
|
"optional": false,
|
|
150
150
|
"docs": {
|
|
151
151
|
"tags": [],
|
|
152
|
-
"text": "Flags to enable
|
|
152
|
+
"text": "Flags to disable/enable scroll shadowY."
|
|
153
153
|
},
|
|
154
|
-
"attribute": "shadow-y",
|
|
154
|
+
"attribute": "no-shadow-y",
|
|
155
155
|
"reflect": false,
|
|
156
|
-
"defaultValue": "
|
|
156
|
+
"defaultValue": "false"
|
|
157
157
|
},
|
|
158
|
-
"
|
|
158
|
+
"noOverflowX": {
|
|
159
159
|
"type": "boolean",
|
|
160
160
|
"mutable": false,
|
|
161
161
|
"complexType": {
|
|
@@ -167,13 +167,13 @@ export class CatScrollable {
|
|
|
167
167
|
"optional": false,
|
|
168
168
|
"docs": {
|
|
169
169
|
"tags": [],
|
|
170
|
-
"text": "Flags to enable
|
|
170
|
+
"text": "Flags to disable/enable overflowX."
|
|
171
171
|
},
|
|
172
|
-
"attribute": "overflow-x",
|
|
172
|
+
"attribute": "no-overflow-x",
|
|
173
173
|
"reflect": false,
|
|
174
|
-
"defaultValue": "
|
|
174
|
+
"defaultValue": "false"
|
|
175
175
|
},
|
|
176
|
-
"
|
|
176
|
+
"noOverflowY": {
|
|
177
177
|
"type": "boolean",
|
|
178
178
|
"mutable": false,
|
|
179
179
|
"complexType": {
|
|
@@ -185,13 +185,13 @@ export class CatScrollable {
|
|
|
185
185
|
"optional": false,
|
|
186
186
|
"docs": {
|
|
187
187
|
"tags": [],
|
|
188
|
-
"text": "Flags to enable
|
|
188
|
+
"text": "Flags to disable/enable overflowY."
|
|
189
189
|
},
|
|
190
|
-
"attribute": "overflow-y",
|
|
190
|
+
"attribute": "no-overflow-y",
|
|
191
191
|
"reflect": false,
|
|
192
|
-
"defaultValue": "
|
|
192
|
+
"defaultValue": "false"
|
|
193
193
|
},
|
|
194
|
-
"
|
|
194
|
+
"noOverscroll": {
|
|
195
195
|
"type": "boolean",
|
|
196
196
|
"mutable": false,
|
|
197
197
|
"complexType": {
|
|
@@ -203,13 +203,13 @@ export class CatScrollable {
|
|
|
203
203
|
"optional": false,
|
|
204
204
|
"docs": {
|
|
205
205
|
"tags": [],
|
|
206
|
-
"text": "Flag to enable
|
|
206
|
+
"text": "Flag to disable/enable overscroll behavior."
|
|
207
207
|
},
|
|
208
|
-
"attribute": "overscroll",
|
|
208
|
+
"attribute": "no-overscroll",
|
|
209
209
|
"reflect": false,
|
|
210
|
-
"defaultValue": "
|
|
210
|
+
"defaultValue": "false"
|
|
211
211
|
},
|
|
212
|
-
"
|
|
212
|
+
"noScrolledInit": {
|
|
213
213
|
"type": "boolean",
|
|
214
214
|
"mutable": false,
|
|
215
215
|
"complexType": {
|
|
@@ -221,11 +221,11 @@ export class CatScrollable {
|
|
|
221
221
|
"optional": false,
|
|
222
222
|
"docs": {
|
|
223
223
|
"tags": [],
|
|
224
|
-
"text": "Flag to fire an initial event after content initialization."
|
|
224
|
+
"text": "Flag to not fire an initial event after content initialization."
|
|
225
225
|
},
|
|
226
|
-
"attribute": "scrolled-init",
|
|
226
|
+
"attribute": "no-scrolled-init",
|
|
227
227
|
"reflect": false,
|
|
228
|
-
"defaultValue": "
|
|
228
|
+
"defaultValue": "false"
|
|
229
229
|
},
|
|
230
230
|
"scrolledBuffer": {
|
|
231
231
|
"type": "number",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-scrollable.js","sourceRoot":"","sources":["../../../src/components/cat-scrollable/cat-scrollable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAc,OAAO,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE9E;;GAEG;AAMH,MAAM,OAAO,aAAa;EAL1B;IAQmB,SAAI,GAAG,IAAI,OAAO,EAAQ,CAAC;IAC3B,cAAS,GAAG,IAAI,OAAO,EAAQ,CAAC;IAGjD,8CAA8C;IAE9C,
|
|
1
|
+
{"version":3,"file":"cat-scrollable.js","sourceRoot":"","sources":["../../../src/components/cat-scrollable/cat-scrollable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAc,OAAO,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE9E;;GAEG;AAMH,MAAM,OAAO,aAAa;EAL1B;IAQmB,SAAI,GAAG,IAAI,OAAO,EAAQ,CAAC;IAC3B,cAAS,GAAG,IAAI,OAAO,EAAQ,CAAC;IAGjD,8CAA8C;IAE9C,cAAS,GAAG,KAAK,CAAC;IAElB,8CAA8C;IAE9C,cAAS,GAAG,KAAK,CAAC;IAElB,yCAAyC;IAEzC,gBAAW,GAAG,KAAK,CAAC;IAEpB,yCAAyC;IAEzC,gBAAW,GAAG,KAAK,CA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CAAC,CAAC;EACX,CAAC;EAEO,WAAW,CAAC,IAAY,EAAE,KAAc;;IAC9C,IAAI,KAAK,EAAE;MACT,MAAA,IAAI,CAAC,oBAAoB,0CAAE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KAChD;SAAM;MACL,MAAA,IAAI,CAAC,oBAAoB,0CAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KACnD;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, h, Prop } from '@stencil/core';\nimport { fromEvent, merge, Observable, Subject } from 'rxjs';\nimport { distinctUntilChanged, filter, map, takeUntil } from 'rxjs/operators';\n\n/**\n * An element to display scrollable content.\n */\n@Component({\n tag: 'cat-scrollable',\n styleUrl: 'cat-scrollable.scss',\n shadow: true\n})\nexport class CatScrollable {\n scrollElement?: HTMLElement;\n scrollWrapperElement?: HTMLElement;\n private readonly init = new Subject<void>();\n private readonly destroyed = new Subject<void>();\n private scrolled!: Observable<Event>;\n\n /** Flags to disable/enable scroll shadowX. */\n @Prop()\n noShadowX = false;\n\n /** Flags to disable/enable scroll shadowY. */\n @Prop()\n noShadowY = false;\n\n /** Flags to disable/enable overflowX. */\n @Prop()\n noOverflowX = false;\n\n /** Flags to disable/enable overflowY. */\n @Prop()\n noOverflowY = false;\n\n /** Flag to disable/enable overscroll behavior. */\n @Prop()\n noOverscroll = false;\n\n /**\n * Flag to not fire an initial event after content initialization.\n */\n @Prop() noScrolledInit = false;\n\n /**\n * Buffer to be used to calculate the scroll distance.\n */\n @Prop() scrolledBuffer = 0;\n\n /**\n * Emitted when the content is fully scrolled to the top.\n */\n @Event() scrolledTop!: EventEmitter<void>;\n\n /**\n * Emitted when the content is fully scrolled to the left.\n */\n @Event() scrolledLeft!: EventEmitter<void>;\n\n /**\n * Emitted when the content is fully scrolled to the right.\n */\n @Event() scrolledRight!: EventEmitter<void>;\n\n /**\n * Emitted when the content is fully scrolled to the bottom.\n */\n @Event() scrolledBottom!: EventEmitter<void>;\n\n componentDidRender() {\n if (this.scrollElement) {\n this.scrolled = fromEvent(this.scrollElement, 'scroll').pipe(takeUntil(this.destroyed));\n }\n this.attachEmitter('left', this.scrolledLeft, this.scrolledBuffer);\n this.attachEmitter('right', this.scrolledRight, this.scrolledBuffer);\n this.attachEmitter('bottom', this.scrolledBottom, this.scrolledBuffer);\n this.attachEmitter('top', this.scrolledTop, this.scrolledBuffer);\n merge(this.init, this.scrolled)\n .pipe(\n map(() => ({\n top: this.getScrollOffset('top') > 0,\n left: this.getScrollOffset('left') > 0,\n right: this.getScrollOffset('right') > 0,\n bottom: this.getScrollOffset('bottom') > 0\n })),\n distinctUntilChanged(),\n takeUntil(this.destroyed)\n )\n .subscribe(({ top, left, right, bottom }) => {\n this.toggleClass('cat-scrollable-top', top);\n this.toggleClass('cat-scrollable-left', left);\n this.toggleClass('cat-scrollable-right', right);\n this.toggleClass('cat-scrollable-bottom', bottom);\n });\n }\n\n componentDidLoad() {\n if (!this.noScrolledInit) {\n this.init.next();\n }\n }\n\n disconnectedCallback() {\n this.init.complete();\n this.destroyed.next();\n this.destroyed.complete();\n }\n\n render() {\n return [\n <div class=\"scrollable-wrapper\" ref={el => (this.scrollWrapperElement = el)}>\n {!this.noShadowY && <div class=\"shadow-top\"></div>}\n {!this.noShadowX && <div class=\"shadow-left\"></div>}\n {!this.noShadowX && <div class=\"shadow-right\"></div>}\n {!this.noShadowY && <div class=\"shadow-bottom\"></div>}\n </div>,\n <div\n ref={el => (this.scrollElement = el)}\n class={{\n 'scrollable-content': true,\n 'scroll-x': !this.noOverflowX,\n 'scroll-y': !this.noOverflowY,\n 'no-overscroll': this.noOverscroll\n }}\n >\n <slot></slot>\n </div>\n ];\n }\n\n private attachEmitter(from: 'top' | 'left' | 'right' | 'bottom', emitter: EventEmitter<void>, buffer: number) {\n merge(this.init, this.scrolled)\n .pipe(map(() => this.getScrollOffset(from)))\n .pipe(map(offset => offset <= buffer))\n .pipe(distinctUntilChanged())\n .pipe(filter(isLower => isLower))\n .pipe(takeUntil(this.destroyed))\n .subscribe(() => emitter.emit());\n }\n\n private getScrollOffset(from: 'top' | 'left' | 'right' | 'bottom') {\n if (this.scrollElement) {\n switch (from) {\n case 'top':\n return this.scrollElement.scrollTop;\n case 'left':\n return this.scrollElement.scrollLeft;\n case 'right':\n return this.scrollElement.scrollWidth - this.scrollElement.clientWidth - this.scrollElement.scrollLeft;\n case 'bottom':\n return this.scrollElement.scrollHeight - this.scrollElement.clientHeight - this.scrollElement.scrollTop;\n default:\n return 0;\n }\n }\n return 0;\n }\n\n private toggleClass(name: string, value: boolean) {\n if (value) {\n this.scrollWrapperElement?.classList.add(name);\n } else {\n this.scrollWrapperElement?.classList.remove(name);\n }\n }\n}\n"]}
|