@haiilo/catalyst 0.5.14 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/catalyst/catalyst.css +1 -1
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/p-12486027.js.map +1 -1
  5. package/dist/catalyst/p-12b96af6.js +2 -0
  6. package/dist/catalyst/p-12b96af6.js.map +1 -0
  7. package/dist/catalyst/p-4254363e.entry.js +2 -0
  8. package/dist/catalyst/p-4254363e.entry.js.map +1 -0
  9. package/dist/catalyst/p-5616e2cd.js +2 -0
  10. package/dist/catalyst/p-5616e2cd.js.map +1 -0
  11. package/dist/catalyst/p-dda85567.entry.js +10 -0
  12. package/dist/catalyst/p-dda85567.entry.js.map +1 -0
  13. package/dist/cjs/app-globals-aa29ad72.js.map +1 -1
  14. package/dist/cjs/{cat-alert_15.cjs.entry.js → cat-alert_18.cjs.entry.js} +282 -66
  15. package/dist/cjs/cat-alert_18.cjs.entry.js.map +1 -0
  16. package/dist/cjs/cat-form-hint-93a6936b.js +22 -0
  17. package/dist/cjs/cat-form-hint-93a6936b.js.map +1 -0
  18. package/dist/cjs/cat-textarea.cjs.entry.js +13 -12
  19. package/dist/cjs/cat-textarea.cjs.entry.js.map +1 -1
  20. package/dist/cjs/catalyst.cjs.js +2 -2
  21. package/dist/cjs/{index-5d72f0e4.js → index-499bad41.js} +44 -1
  22. package/dist/cjs/index-499bad41.js.map +1 -0
  23. package/dist/cjs/loader.cjs.js +2 -2
  24. package/dist/collection/collection-manifest.json +3 -0
  25. package/dist/collection/components/cat-avatar/cat-avatar.css +81 -0
  26. package/dist/collection/components/cat-avatar/cat-avatar.js +225 -0
  27. package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -0
  28. package/dist/collection/components/cat-badge/cat-badge.css +5 -5
  29. package/dist/collection/components/cat-button/cat-button.js +8 -8
  30. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  31. package/dist/collection/components/cat-checkbox/cat-checkbox.css +14 -0
  32. package/dist/collection/components/cat-checkbox/cat-checkbox.js +44 -11
  33. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  34. package/dist/collection/components/cat-form-hint/cat-form-hint.js +16 -0
  35. package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -0
  36. package/dist/collection/components/cat-icon/cat-icon.css +4 -1
  37. package/dist/collection/components/cat-input/cat-input.css +12 -6
  38. package/dist/collection/components/cat-input/cat-input.js +24 -25
  39. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  40. package/dist/collection/components/cat-radio/cat-radio.css +14 -0
  41. package/dist/collection/components/cat-radio/cat-radio.js +41 -8
  42. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  43. package/dist/collection/components/cat-scrollable/cat-scrollable.js +44 -44
  44. package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
  45. package/dist/collection/components/cat-tab/cat-tab.css +12 -0
  46. package/dist/collection/components/cat-tab/cat-tab.js +203 -0
  47. package/dist/collection/components/cat-tab/cat-tab.js.map +1 -0
  48. package/dist/collection/components/cat-tabs/cat-tabs.css +33 -0
  49. package/dist/collection/components/cat-tabs/cat-tabs.js +122 -0
  50. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -0
  51. package/dist/collection/components/cat-textarea/cat-textarea.css +12 -6
  52. package/dist/collection/components/cat-textarea/cat-textarea.js +24 -18
  53. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  54. package/dist/collection/components/cat-toggle/cat-toggle.css +14 -0
  55. package/dist/collection/components/cat-toggle/cat-toggle.js +40 -7
  56. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  57. package/dist/collection/components/cat-tooltip/cat-tooltip.js +13 -8
  58. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
  59. package/dist/collection/utils/load-img.js +16 -0
  60. package/dist/collection/utils/load-img.js.map +1 -0
  61. package/dist/components/cat-avatar.d.ts +11 -0
  62. package/dist/components/cat-avatar.js +125 -0
  63. package/dist/components/cat-avatar.js.map +1 -0
  64. package/dist/components/cat-badge.js +1 -1
  65. package/dist/components/cat-badge.js.map +1 -1
  66. package/dist/components/cat-button2.js +5 -5
  67. package/dist/components/cat-button2.js.map +1 -1
  68. package/dist/components/cat-checkbox.js +16 -5
  69. package/dist/components/cat-checkbox.js.map +1 -1
  70. package/dist/components/cat-form-hint.js +20 -0
  71. package/dist/components/cat-form-hint.js.map +1 -0
  72. package/dist/components/cat-icon2.js +1 -1
  73. package/dist/components/cat-icon2.js.map +1 -1
  74. package/dist/components/cat-input.js +16 -18
  75. package/dist/components/cat-input.js.map +1 -1
  76. package/dist/components/cat-radio.js +16 -5
  77. package/dist/components/cat-radio.js.map +1 -1
  78. package/dist/components/cat-scrollable.js +23 -23
  79. package/dist/components/cat-scrollable.js.map +1 -1
  80. package/dist/components/cat-tab.d.ts +11 -0
  81. package/dist/components/cat-tab.js +70 -0
  82. package/dist/components/cat-tab.js.map +1 -0
  83. package/dist/components/cat-tabs.d.ts +11 -0
  84. package/dist/components/cat-tabs.js +107 -0
  85. package/dist/components/cat-tabs.js.map +1 -0
  86. package/dist/components/cat-textarea.js +14 -12
  87. package/dist/components/cat-textarea.js.map +1 -1
  88. package/dist/components/cat-toggle.js +16 -5
  89. package/dist/components/cat-toggle.js.map +1 -1
  90. package/dist/components/cat-tooltip.js +13 -8
  91. package/dist/components/cat-tooltip.js.map +1 -1
  92. package/dist/components/index.js.map +1 -1
  93. package/dist/esm/app-globals-cf55f7f5.js.map +1 -1
  94. package/dist/esm/{cat-alert_15.entry.js → cat-alert_18.entry.js} +280 -67
  95. package/dist/esm/cat-alert_18.entry.js.map +1 -0
  96. package/dist/esm/cat-form-hint-dc443c7c.js +20 -0
  97. package/dist/esm/cat-form-hint-dc443c7c.js.map +1 -0
  98. package/dist/esm/cat-textarea.entry.js +13 -12
  99. package/dist/esm/cat-textarea.entry.js.map +1 -1
  100. package/dist/esm/catalyst.js +2 -2
  101. package/dist/esm/{index-fd12be19.js → index-039e6f5f.js} +44 -2
  102. package/dist/esm/index-039e6f5f.js.map +1 -0
  103. package/dist/esm/loader.js +2 -2
  104. package/dist/types/components/cat-avatar/cat-avatar.d.ts +46 -0
  105. package/dist/types/components/cat-button/cat-button.d.ts +2 -2
  106. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +9 -0
  107. package/dist/types/components/cat-form-hint/cat-form-hint.d.ts +19 -0
  108. package/dist/types/components/cat-input/cat-input.d.ts +7 -5
  109. package/dist/types/components/cat-radio/cat-radio.d.ts +9 -0
  110. package/dist/types/components/cat-scrollable/cat-scrollable.d.ts +12 -12
  111. package/dist/types/components/cat-tab/cat-tab.d.ts +43 -0
  112. package/dist/types/components/cat-tabs/cat-tabs.d.ts +25 -0
  113. package/dist/types/components/cat-textarea/cat-textarea.d.ts +7 -2
  114. package/dist/types/components/cat-toggle/cat-toggle.d.ts +9 -0
  115. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +1 -0
  116. package/dist/types/components.d.ts +255 -52
  117. package/dist/types/utils/load-img.d.ts +8 -0
  118. package/package.json +2 -2
  119. package/dist/catalyst/p-a8629c54.entry.js +0 -2
  120. package/dist/catalyst/p-a8629c54.entry.js.map +0 -1
  121. package/dist/catalyst/p-bfc656ca.js +0 -2
  122. package/dist/catalyst/p-bfc656ca.js.map +0 -1
  123. package/dist/catalyst/p-e6491f33.entry.js +0 -10
  124. package/dist/catalyst/p-e6491f33.entry.js.map +0 -1
  125. package/dist/cjs/cat-alert_15.cjs.entry.js.map +0 -1
  126. package/dist/cjs/index-5d72f0e4.js.map +0 -1
  127. package/dist/esm/cat-alert_15.entry.js.map +0 -1
  128. package/dist/esm/index-fd12be19.js.map +0 -1
@@ -1,5 +1,6 @@
1
- import { Component, Event, h, Host, Method, Prop, State, Watch } 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
  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.inputValue = '';
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
- if (!this.label) {
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.inputValue = '';
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.inputValue, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }),
106
- this.clearable && !this.disabled && this.inputValue && (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) }))),
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.hint && h("p", { class: "input-hint" }, this.hint)));
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.inputValue = this.input.value;
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": false,
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
- "inputValue": {}
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 watchers() { return [{
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;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Y;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,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;IA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9B,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 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, Prop, Method } 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
  * 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
- if (!this.label) {
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("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } },
50
- h("span", { class: "radio" },
51
- 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) }),
52
- h("span", { class: "circle" })),
53
- h("span", { class: "label", part: "label" }, this.label)));
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": false,
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;AAChF,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;GAKG;AAM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,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAC9B;QACF,YAAM,KAAK,EAAC,QAAQ,GAAQ,CACvB;MACP,YAAM,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,OAAO,IAC7B,IAAI,CAAC,KAAK,CACN,CACD,CACT,CAAC;EACJ,CAAC;EAEO,QAAQ,CAAC,KAAY;IAC3B,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, Prop, Method } from '@stencil/core';\nimport log from 'loglevel';\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 * @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 /**\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() value?: 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) {\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 <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.label}\n </span>\n </label>\n );\n }\n\n private onChange(event: Event) {\n this.catChange.emit(event);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"]}
1
+ {"version":3,"file":"cat-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;AAC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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"]}
@@ -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/disable scroll shadowX. */
12
- this.shadowX = true;
13
- /** Flags to enable/disable scroll shadowY. */
14
- this.shadowY = true;
15
- /** Flags to enable/disable overflowX. */
16
- this.overflowX = true;
17
- /** Flags to enable/disable overflowY. */
18
- this.overflowY = true;
19
- /** Flag to enable/disable overscroll behavior. */
20
- this.overscroll = true;
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.scrolledInit = true;
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.scrolledInit) {
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.shadowY && h("div", { class: "shadow-top" }),
66
- this.shadowX && h("div", { class: "shadow-left" }),
67
- this.shadowX && h("div", { class: "shadow-right" }),
68
- this.shadowY && h("div", { class: "shadow-bottom" })),
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.overflowX,
72
- 'scroll-y': this.overflowY,
73
- 'no-overscroll': !this.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
- "shadowX": {
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/disable scroll shadowX."
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": "true"
138
+ "defaultValue": "false"
139
139
  },
140
- "shadowY": {
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/disable scroll shadowY."
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": "true"
156
+ "defaultValue": "false"
157
157
  },
158
- "overflowX": {
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/disable overflowX."
170
+ "text": "Flags to disable/enable overflowX."
171
171
  },
172
- "attribute": "overflow-x",
172
+ "attribute": "no-overflow-x",
173
173
  "reflect": false,
174
- "defaultValue": "true"
174
+ "defaultValue": "false"
175
175
  },
176
- "overflowY": {
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/disable overflowY."
188
+ "text": "Flags to disable/enable overflowY."
189
189
  },
190
- "attribute": "overflow-y",
190
+ "attribute": "no-overflow-y",
191
191
  "reflect": false,
192
- "defaultValue": "true"
192
+ "defaultValue": "false"
193
193
  },
194
- "overscroll": {
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/disable overscroll behavior."
206
+ "text": "Flag to disable/enable overscroll behavior."
207
207
  },
208
- "attribute": "overscroll",
208
+ "attribute": "no-overscroll",
209
209
  "reflect": false,
210
- "defaultValue": "true"
210
+ "defaultValue": "false"
211
211
  },
212
- "scrolledInit": {
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": "true"
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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AI,CAAC,aAAa,CAAC,UAAU,CAAC;QACvC,KAAK,OAAO;UACV,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC;QACzG,KAAK,QAAQ;UACX,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;QAC1G;UACE,OAAO,CAAC,CAAC;OACZ;KACF;IACD,OAAO,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 enable/disable scroll shadowX. */\n @Prop()\n shadowX = true;\n\n /** Flags to enable/disable scroll shadowY. */\n @Prop()\n shadowY = true;\n\n /** Flags to enable/disable overflowX. */\n @Prop()\n overflowX = true;\n\n /** Flags to enable/disable overflowY. */\n @Prop()\n overflowY = true;\n\n /** Flag to enable/disable overscroll behavior. */\n @Prop()\n overscroll = true;\n\n /**\n * Flag to fire an initial event after content initialization.\n */\n @Prop() scrolledInit = true;\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.scrolledInit) {\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.shadowY && <div class=\"shadow-top\"></div>}\n {this.shadowX && <div class=\"shadow-left\"></div>}\n {this.shadowX && <div class=\"shadow-right\"></div>}\n {this.shadowY && <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.overflowX,\n 'scroll-y': this.overflowY,\n 'no-overscroll': !this.overscroll\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"]}
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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,KAAK,KAAK;UACR,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;QACtC,KAAK,MAAM;UACT,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC;QACvC,KAAK,OAAO;UACV,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC;QACzG,KAAK,QAAQ;UACX,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;QAC1G;UACE,OAAO,CAAC,CAAC;OACZ;KACF;IACD,OAAO,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"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Auto-generated file. Do not edit directly.
3
+ */
4
+ /* stylelint-disable value-keyword-case */
5
+ /* stylelint-enable value-keyword-case */
6
+ :host {
7
+ display: block;
8
+ }
9
+
10
+ :host([hidden]) {
11
+ display: none;
12
+ }