@haiilo/catalyst 6.2.2 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/catalyst/catalyst.css +57 -23
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/index.esm.js +2 -2
  5. package/dist/catalyst/index.esm.js.map +1 -1
  6. package/dist/catalyst/p-90e9d18f.entry.js +10 -0
  7. package/dist/catalyst/p-90e9d18f.entry.js.map +1 -0
  8. package/dist/catalyst/p-dd8ae83e.js +2 -0
  9. package/dist/catalyst/p-dd8ae83e.js.map +1 -0
  10. package/dist/catalyst/scss/_mixins.scss +2 -1
  11. package/dist/catalyst/scss/_variables.scss +1 -8
  12. package/dist/catalyst/scss/core/_nav.scss +2 -3
  13. package/dist/catalyst/scss/utils/_layout.scss +7 -3
  14. package/dist/catalyst/scss/utils/_z-index.mixins.scss +7 -0
  15. package/dist/catalyst/scss/vendor/_flatpickr.scss +62 -14
  16. package/dist/cjs/{cat-alert_25.cjs.entry.js → cat-alert_26.cjs.entry.js} +7190 -8001
  17. package/dist/cjs/cat-alert_26.cjs.entry.js.map +1 -0
  18. package/dist/cjs/catalyst.cjs.js +1 -1
  19. package/dist/cjs/index.cjs.js +28 -8
  20. package/dist/cjs/index.cjs.js.map +1 -1
  21. package/dist/cjs/loader.cjs.js +1 -1
  22. package/dist/cjs/of-d9fa1990.js +1435 -0
  23. package/dist/cjs/of-d9fa1990.js.map +1 -0
  24. package/dist/collection/collection-manifest.json +1 -0
  25. package/dist/collection/components/cat-button/cat-button.css +21 -5
  26. package/dist/collection/components/cat-button/cat-button.js +18 -2
  27. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  28. package/dist/collection/components/cat-button/cat-button.spec.js +3 -1
  29. package/dist/collection/components/cat-button/cat-button.spec.js.map +1 -1
  30. package/dist/collection/components/cat-button-group/cat-button-group.js +4 -0
  31. package/dist/collection/components/cat-button-group/cat-button-group.js.map +1 -1
  32. package/dist/collection/components/cat-datepicker/cat-datepicker.config.js +41 -20
  33. package/dist/collection/components/cat-datepicker/cat-datepicker.config.js.map +1 -1
  34. package/dist/collection/components/cat-datepicker/cat-datepicker.format.js +22 -0
  35. package/dist/collection/components/cat-datepicker/cat-datepicker.format.js.map +1 -0
  36. package/dist/collection/components/cat-datepicker/cat-datepicker.js +53 -51
  37. package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -1
  38. package/dist/collection/components/cat-datepicker/cat-datepicker.locale.js.map +1 -1
  39. package/dist/collection/components/cat-datepicker/cat-datepicker.mode.js +2 -0
  40. package/dist/collection/components/cat-datepicker/cat-datepicker.mode.js.map +1 -0
  41. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.css +1146 -0
  42. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.e2e.js +10 -0
  43. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.e2e.js.map +1 -0
  44. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js +236 -0
  45. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js.map +1 -0
  46. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.spec.js +20 -0
  47. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.spec.js.map +1 -0
  48. package/dist/collection/components/cat-dropdown/cat-dropdown.css +34 -11
  49. package/dist/collection/components/cat-form-group/cat-form-group.js +6 -6
  50. package/dist/collection/components/cat-form-group/cat-form-group.js.map +1 -1
  51. package/dist/collection/components/cat-input/cat-input.css +8 -0
  52. package/dist/collection/components/cat-input/cat-input.js +6 -5
  53. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  54. package/dist/collection/components/cat-select/cat-select.css +1 -1
  55. package/dist/collection/components/cat-select/cat-select.js +9 -9
  56. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  57. package/dist/collection/components/cat-select/connectors.js +20 -0
  58. package/dist/collection/components/cat-select/connectors.js.map +1 -0
  59. package/dist/collection/components/cat-tab/cat-tab.js +16 -0
  60. package/dist/collection/components/cat-tab/cat-tab.js.map +1 -1
  61. package/dist/collection/components/cat-tabs/cat-tabs.css +24 -2
  62. package/dist/collection/components/cat-tabs/cat-tabs.js +3 -3
  63. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
  64. package/dist/collection/components/cat-textarea/cat-textarea.css +4 -0
  65. package/dist/collection/components/cat-textarea/cat-textarea.js +4 -3
  66. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  67. package/dist/collection/components/cat-tooltip/cat-tooltip.css +1 -1
  68. package/dist/collection/index.js +4 -3
  69. package/dist/collection/index.js.map +1 -1
  70. package/dist/collection/scss/_mixins.scss +2 -1
  71. package/dist/collection/scss/_variables.scss +1 -8
  72. package/dist/collection/scss/core/_nav.scss +2 -3
  73. package/dist/collection/scss/utils/_layout.scss +7 -3
  74. package/dist/collection/scss/utils/_z-index.mixins.scss +7 -0
  75. package/dist/collection/scss/vendor/_flatpickr.scss +62 -14
  76. package/dist/components/cat-button-group.js.map +1 -1
  77. package/dist/components/cat-button2.js +5 -3
  78. package/dist/components/cat-button2.js.map +1 -1
  79. package/dist/components/cat-datepicker-inline.d.ts +11 -0
  80. package/dist/components/cat-datepicker-inline.js +100 -0
  81. package/dist/components/cat-datepicker-inline.js.map +1 -0
  82. package/dist/components/cat-datepicker.js +39 -2770
  83. package/dist/components/cat-datepicker.js.map +1 -1
  84. package/dist/components/cat-datepicker.locale.js +2768 -0
  85. package/dist/components/cat-datepicker.locale.js.map +1 -0
  86. package/dist/components/cat-dropdown2.js +1 -1
  87. package/dist/components/cat-dropdown2.js.map +1 -1
  88. package/dist/components/cat-form-group.js +6 -6
  89. package/dist/components/cat-form-group.js.map +1 -1
  90. package/dist/components/cat-input2.js +7 -6
  91. package/dist/components/cat-input2.js.map +1 -1
  92. package/dist/components/cat-scrollable2.js +2 -910
  93. package/dist/components/cat-scrollable2.js.map +1 -1
  94. package/dist/components/cat-select-demo.js +4 -2
  95. package/dist/components/cat-select-demo.js.map +1 -1
  96. package/dist/components/cat-select2.js +14 -17
  97. package/dist/components/cat-select2.js.map +1 -1
  98. package/dist/components/cat-tab.js +3 -1
  99. package/dist/components/cat-tab.js.map +1 -1
  100. package/dist/components/cat-tabs.js +4 -4
  101. package/dist/components/cat-tabs.js.map +1 -1
  102. package/dist/components/cat-textarea.js +5 -4
  103. package/dist/components/cat-textarea.js.map +1 -1
  104. package/dist/components/cat-tooltip.js +1 -1
  105. package/dist/components/cat-tooltip.js.map +1 -1
  106. package/dist/components/from.js +912 -0
  107. package/dist/components/from.js.map +1 -0
  108. package/dist/components/index.js +21 -1
  109. package/dist/components/index.js.map +1 -1
  110. package/dist/components/of.js +10 -0
  111. package/dist/components/of.js.map +1 -0
  112. package/dist/esm/{cat-alert_25.entry.js → cat-alert_26.entry.js} +7199 -8011
  113. package/dist/esm/cat-alert_26.entry.js.map +1 -0
  114. package/dist/esm/catalyst.js +1 -1
  115. package/dist/esm/index.js +22 -3
  116. package/dist/esm/index.js.map +1 -1
  117. package/dist/esm/loader.js +1 -1
  118. package/dist/esm/of-5472d434.js +1408 -0
  119. package/dist/esm/of-5472d434.js.map +1 -0
  120. package/dist/types/components/cat-button/cat-button.d.ts +6 -0
  121. package/dist/types/components/cat-button-group/cat-button-group.d.ts +4 -0
  122. package/dist/types/components/cat-datepicker/cat-datepicker.config.d.ts +13 -1
  123. package/dist/types/components/cat-datepicker/cat-datepicker.d.ts +6 -2
  124. package/dist/types/components/cat-datepicker/cat-datepicker.format.d.ts +2 -0
  125. package/dist/types/components/cat-datepicker/cat-datepicker.locale.d.ts +2 -2
  126. package/dist/types/components/cat-datepicker/cat-datepicker.mode.d.ts +1 -0
  127. package/dist/types/components/cat-datepicker-inline/cat-datepicker-inline.d.ts +43 -0
  128. package/dist/types/components/cat-form-group/cat-form-group.d.ts +2 -2
  129. package/dist/types/components/cat-input/cat-input.d.ts +1 -1
  130. package/dist/types/components/cat-select/cat-select.d.ts +4 -4
  131. package/dist/types/components/cat-select/connectors.d.ts +8 -0
  132. package/dist/types/components/cat-tab/cat-tab.d.ts +6 -0
  133. package/dist/types/components/cat-tabs/cat-tabs.d.ts +1 -1
  134. package/dist/types/components/cat-textarea/cat-textarea.d.ts +1 -1
  135. package/dist/types/components.d.ts +113 -2
  136. package/dist/types/index.d.ts +4 -3
  137. package/package.json +3 -3
  138. package/dist/catalyst/p-42e63e08.js +0 -2
  139. package/dist/catalyst/p-42e63e08.js.map +0 -1
  140. package/dist/catalyst/p-cd1f4492.entry.js +0 -10
  141. package/dist/catalyst/p-cd1f4492.entry.js.map +0 -1
  142. package/dist/cjs/cat-alert_25.cjs.entry.js.map +0 -1
  143. package/dist/cjs/cat-icon-registry-5c292d3f.js +0 -502
  144. package/dist/cjs/cat-icon-registry-5c292d3f.js.map +0 -1
  145. package/dist/esm/cat-alert_25.entry.js.map +0 -1
  146. package/dist/esm/cat-icon-registry-4fc73466.js +0 -494
  147. package/dist/esm/cat-icon-registry-4fc73466.js.map +0 -1
@@ -0,0 +1,10 @@
1
+ import { newE2EPage } from "@stencil/core/testing";
2
+ describe('cat-datepicker-inline', () => {
3
+ it('renders', async () => {
4
+ const page = await newE2EPage();
5
+ await page.setContent('<cat-datepicker-inline></cat-datepicker-inline>');
6
+ const element = await page.find('cat-datepicker-inline');
7
+ expect(element).toHaveClass('hydrated');
8
+ });
9
+ });
10
+ //# sourceMappingURL=cat-datepicker-inline.e2e.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cat-datepicker-inline.e2e.js","sourceRoot":"","sources":["../../../src/components/cat-datepicker-inline/cat-datepicker-inline.e2e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;EACrC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,IAAI,GAAG,MAAM,UAAU,EAAE,CAAC;IAChC,MAAM,IAAI,CAAC,UAAU,CAAC,iDAAiD,CAAC,CAAC;IAEzE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACzD,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;EAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newE2EPage } from '@stencil/core/testing';\n\ndescribe('cat-datepicker-inline', () => {\n it('renders', async () => {\n const page = await newE2EPage();\n await page.setContent('<cat-datepicker-inline></cat-datepicker-inline>');\n\n const element = await page.find('cat-datepicker-inline');\n expect(element).toHaveClass('hydrated');\n });\n});\n"]}
@@ -0,0 +1,236 @@
1
+ import { Host, h } from "@stencil/core";
2
+ import flatpickr from "flatpickr";
3
+ import { getConfig } from "../cat-datepicker/cat-datepicker.config";
4
+ import { getFormat } from "../cat-datepicker/cat-datepicker.format";
5
+ import { getLocale } from "../cat-datepicker/cat-datepicker.locale";
6
+ import { catI18nRegistry as i18n } from "../cat-i18n/cat-i18n-registry";
7
+ export class CatDatepickerInline {
8
+ constructor() {
9
+ this.disabled = false;
10
+ this.max = undefined;
11
+ this.min = undefined;
12
+ this.mode = 'date';
13
+ this.readonly = false;
14
+ this.step = 5;
15
+ this.value = undefined;
16
+ }
17
+ onValueChanged(value) {
18
+ if (value) {
19
+ this.pickr?.setDate(value, false);
20
+ this.catChange.emit(value);
21
+ }
22
+ else {
23
+ this.pickr?.clear(false);
24
+ this.catChange.emit(undefined);
25
+ }
26
+ }
27
+ onDisabledChanged(value) {
28
+ // Dynamically unsetting 'enabled' value to undefined is not working due to
29
+ // a bug in the library. We thus need to fully recreate the date picker.
30
+ this.pickr?.destroy();
31
+ if (this.input) {
32
+ this.pickr = this.initDatepicker(this.input, value);
33
+ }
34
+ }
35
+ componentDidLoad() {
36
+ if (this.input) {
37
+ this.pickr = this.initDatepicker(this.input, this.disabled);
38
+ }
39
+ }
40
+ render() {
41
+ return (h(Host, null, h("div", { tabIndex: this.disabled || this.readonly ? -1 : undefined, class: {
42
+ 'datepicker-wrapper': true,
43
+ 'datepicker-disabled': this.disabled,
44
+ 'datepicker-readonly': this.readonly
45
+ } }, h("input", { ref: el => (this.input = el), value: this.value, disabled: this.disabled, readonly: this.readonly }))));
46
+ }
47
+ initDatepicker(input, disabled) {
48
+ return flatpickr(input, getConfig({
49
+ locale: getLocale(i18n.getLocale()),
50
+ format: getFormat(i18n.getLocale(), this.mode),
51
+ mode: this.mode,
52
+ min: this.min,
53
+ max: this.max,
54
+ step: this.step,
55
+ disabled,
56
+ readonly: this.readonly,
57
+ applyChange: value => (this.value = value)
58
+ }, {
59
+ ...(disabled ? { enable: [] } : {}),
60
+ inline: true
61
+ }));
62
+ }
63
+ static get is() { return "cat-datepicker-inline"; }
64
+ static get encapsulation() { return "shadow"; }
65
+ static get originalStyleUrls() {
66
+ return {
67
+ "$": ["cat-datepicker-inline.scss"]
68
+ };
69
+ }
70
+ static get styleUrls() {
71
+ return {
72
+ "$": ["cat-datepicker-inline.css"]
73
+ };
74
+ }
75
+ static get properties() {
76
+ return {
77
+ "disabled": {
78
+ "type": "boolean",
79
+ "mutable": false,
80
+ "complexType": {
81
+ "original": "boolean",
82
+ "resolved": "boolean",
83
+ "references": {}
84
+ },
85
+ "required": false,
86
+ "optional": false,
87
+ "docs": {
88
+ "tags": [],
89
+ "text": "Whether the input is disabled."
90
+ },
91
+ "attribute": "disabled",
92
+ "reflect": false,
93
+ "defaultValue": "false"
94
+ },
95
+ "max": {
96
+ "type": "string",
97
+ "mutable": false,
98
+ "complexType": {
99
+ "original": "string",
100
+ "resolved": "string | undefined",
101
+ "references": {}
102
+ },
103
+ "required": false,
104
+ "optional": true,
105
+ "docs": {
106
+ "tags": [],
107
+ "text": "A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z."
108
+ },
109
+ "attribute": "max",
110
+ "reflect": false
111
+ },
112
+ "min": {
113
+ "type": "string",
114
+ "mutable": false,
115
+ "complexType": {
116
+ "original": "string",
117
+ "resolved": "string | undefined",
118
+ "references": {}
119
+ },
120
+ "required": false,
121
+ "optional": true,
122
+ "docs": {
123
+ "tags": [],
124
+ "text": "A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z."
125
+ },
126
+ "attribute": "min",
127
+ "reflect": false
128
+ },
129
+ "mode": {
130
+ "type": "string",
131
+ "mutable": false,
132
+ "complexType": {
133
+ "original": "CatDatepickerMode",
134
+ "resolved": "\"date\" | \"daterange\" | \"datetime\" | \"time\" | \"week\"",
135
+ "references": {
136
+ "CatDatepickerMode": {
137
+ "location": "import",
138
+ "path": "../cat-datepicker/cat-datepicker.mode",
139
+ "id": "src/components/cat-datepicker/cat-datepicker.mode.ts::CatDatepickerMode"
140
+ }
141
+ }
142
+ },
143
+ "required": false,
144
+ "optional": false,
145
+ "docs": {
146
+ "tags": [],
147
+ "text": "The mode of the datepicker, to select a date, time, both, a date range or a week number."
148
+ },
149
+ "attribute": "mode",
150
+ "reflect": false,
151
+ "defaultValue": "'date'"
152
+ },
153
+ "readonly": {
154
+ "type": "boolean",
155
+ "mutable": false,
156
+ "complexType": {
157
+ "original": "boolean",
158
+ "resolved": "boolean",
159
+ "references": {}
160
+ },
161
+ "required": false,
162
+ "optional": false,
163
+ "docs": {
164
+ "tags": [],
165
+ "text": "The value is not editable."
166
+ },
167
+ "attribute": "readonly",
168
+ "reflect": false,
169
+ "defaultValue": "false"
170
+ },
171
+ "step": {
172
+ "type": "number",
173
+ "mutable": false,
174
+ "complexType": {
175
+ "original": "number",
176
+ "resolved": "number",
177
+ "references": {}
178
+ },
179
+ "required": false,
180
+ "optional": false,
181
+ "docs": {
182
+ "tags": [],
183
+ "text": "The step size to use when changing the time."
184
+ },
185
+ "attribute": "step",
186
+ "reflect": false,
187
+ "defaultValue": "5"
188
+ },
189
+ "value": {
190
+ "type": "string",
191
+ "mutable": true,
192
+ "complexType": {
193
+ "original": "string",
194
+ "resolved": "string | undefined",
195
+ "references": {}
196
+ },
197
+ "required": false,
198
+ "optional": true,
199
+ "docs": {
200
+ "tags": [],
201
+ "text": "The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string."
202
+ },
203
+ "attribute": "value",
204
+ "reflect": false
205
+ }
206
+ };
207
+ }
208
+ static get events() {
209
+ return [{
210
+ "method": "catChange",
211
+ "name": "catChange",
212
+ "bubbles": true,
213
+ "cancelable": true,
214
+ "composed": true,
215
+ "docs": {
216
+ "tags": [],
217
+ "text": "Emitted when the value is changed."
218
+ },
219
+ "complexType": {
220
+ "original": "string",
221
+ "resolved": "string",
222
+ "references": {}
223
+ }
224
+ }];
225
+ }
226
+ static get watchers() {
227
+ return [{
228
+ "propName": "value",
229
+ "methodName": "onValueChanged"
230
+ }, {
231
+ "propName": "disabled",
232
+ "methodName": "onDisabledChanged"
233
+ }];
234
+ }
235
+ }
236
+ //# sourceMappingURL=cat-datepicker-inline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cat-datepicker-inline.js","sourceRoot":"","sources":["../../../src/components/cat-datepicker-inline/cat-datepicker-inline.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAOxE,MAAM,OAAO,mBAAmB;;oBAOX,KAAK;;;gBAeU,MAAM;oBAKrB,KAAK;gBAKT,CAAC;;;EAahB,cAAc,CAAC,KAAa;IAC1B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CACD,CACR,CAAC;EACJ,CAAC;EAEO,cAAc,CAAC,KAAuB,EAAE,QAAiB;IAC/D,OAAO,SAAS,CACd,KAAK,EACL,SAAS,CACP;MACE,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;MACnC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC;MAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,GAAG,EAAE,IAAI,CAAC,GAAG;MACb,IAAI,EAAE,IAAI,CAAC,IAAI;MACf,QAAQ;MACR,QAAQ,EAAE,IAAI,CAAC,QAAQ;MACvB,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3C,EACD;MACE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;MACnC,MAAM,EAAE,IAAI;KACb,CACF,CACF,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, Host, Prop, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { getConfig } from '../cat-datepicker/cat-datepicker.config';\nimport { getFormat } from '../cat-datepicker/cat-datepicker.format';\nimport { getLocale } from '../cat-datepicker/cat-datepicker.locale';\nimport { CatDatepickerMode } from '../cat-datepicker/cat-datepicker.mode';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\n@Component({\n tag: 'cat-datepicker-inline',\n styleUrl: 'cat-datepicker-inline.scss',\n shadow: true\n})\nexport class CatDatepickerInline {\n private pickr?: flatpickr.Instance;\n private input?: HTMLInputElement;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n this.catChange.emit(value);\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n onDisabledChanged(value: boolean) {\n // Dynamically unsetting 'enabled' value to undefined is not working due to\n // a bug in the library. We thus need to fully recreate the date picker.\n this.pickr?.destroy();\n if (this.input) {\n this.pickr = this.initDatepicker(this.input, value);\n }\n }\n\n componentDidLoad() {\n if (this.input) {\n this.pickr = this.initDatepicker(this.input, this.disabled);\n }\n }\n\n render() {\n return (\n <Host>\n <div\n tabIndex={this.disabled || this.readonly ? -1 : undefined}\n class={{\n 'datepicker-wrapper': true,\n 'datepicker-disabled': this.disabled,\n 'datepicker-readonly': this.readonly\n }}\n >\n <input\n ref={el => (this.input = el)}\n value={this.value}\n disabled={this.disabled}\n readonly={this.readonly}\n ></input>\n </div>\n </Host>\n );\n }\n\n private initDatepicker(input: HTMLInputElement, disabled: boolean): flatpickr.Instance {\n return flatpickr(\n input,\n getConfig(\n {\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled,\n readonly: this.readonly,\n applyChange: value => (this.value = value)\n },\n {\n ...(disabled ? { enable: [] } : {}),\n inline: true\n }\n )\n );\n }\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import { newSpecPage } from "@stencil/core/testing";
2
+ import { CatDatepickerInline } from "./cat-datepicker-inline";
3
+ describe('cat-datepicker-inline', () => {
4
+ it('renders', async () => {
5
+ const page = await newSpecPage({
6
+ components: [CatDatepickerInline],
7
+ html: `<cat-datepicker-inline></cat-datepicker-inline>`
8
+ });
9
+ expect(page.root).toEqualHtml(`
10
+ <cat-datepicker-inline>
11
+ <mock:shadow-root>
12
+ <div class="datepicker-wrapper">
13
+ <input></input>
14
+ </div>
15
+ </mock:shadow-root>
16
+ </cat-datepicker-inline>
17
+ `);
18
+ });
19
+ });
20
+ //# sourceMappingURL=cat-datepicker-inline.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cat-datepicker-inline.spec.js","sourceRoot":"","sources":["../../../src/components/cat-datepicker-inline/cat-datepicker-inline.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;EACrC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,mBAAmB,CAAC;MACjC,IAAI,EAAE,iDAAiD;KACxD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;KAQ7B,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { CatDatepickerInline } from './cat-datepicker-inline';\n\ndescribe('cat-datepicker-inline', () => {\n it('renders', async () => {\n const page = await newSpecPage({\n components: [CatDatepickerInline],\n html: `<cat-datepicker-inline></cat-datepicker-inline>`\n });\n expect(page.root).toEqualHtml(`\n <cat-datepicker-inline>\n <mock:shadow-root>\n <div class=\"datepicker-wrapper\">\n <input></input>\n </div>\n </mock:shadow-root>\n </cat-datepicker-inline>\n `);\n });\n});\n"]}
@@ -15,8 +15,7 @@
15
15
  }
16
16
 
17
17
  ::slotted(nav) {
18
- padding-top: 0.5rem;
19
- padding-bottom: 0.5rem;
18
+ padding: 0.25rem;
20
19
  min-width: 8rem;
21
20
  max-width: 16rem;
22
21
  }
@@ -24,34 +23,58 @@
24
23
  .content {
25
24
  position: fixed;
26
25
  background: white;
27
- display: none;
28
26
  -webkit-overflow-scrolling: touch;
29
27
  min-height: 2rem;
30
28
  max-height: calc(100vh - 48px);
31
29
  box-shadow: 0 4px 6px -2px rgba(27, 31, 38, 0.03), 0 12px 16px -4px rgba(27, 31, 38, 0.08);
32
30
  border-radius: var(--cat-border-radius-m, 0.25rem);
33
31
  border: 1px solid rgb(var(--cat-border-color, 235, 236, 240));
34
- z-index: 100;
32
+ z-index: calc(var(--cat-z-index, 1000) + 100);
33
+ display: none;
35
34
  opacity: 0;
35
+ transform: scale(0.9);
36
36
  transition: transform 125ms cubic-bezier(0.3, 0, 0.8, 0.15), opacity 125ms cubic-bezier(0.3, 0, 0.8, 0.15);
37
37
  }
38
38
  .content[data-placement^=top] {
39
- transform: translateY(1rem);
39
+ transform-origin: bottom;
40
+ }
41
+ .content[data-placement^=top-start] {
42
+ transform-origin: bottom left;
43
+ }
44
+ .content[data-placement^=top-end] {
45
+ transform-origin: bottom right;
40
46
  }
41
47
  .content[data-placement^=left] {
42
- transform: translateX(1rem);
48
+ transform-origin: right;
49
+ }
50
+ .content[data-placement^=left-start] {
51
+ transform-origin: right top;
52
+ }
53
+ .content[data-placement^=left-end] {
54
+ transform-origin: right bottom;
43
55
  }
44
56
  .content[data-placement^=right] {
45
- transform: translateX(-1rem);
57
+ transform-origin: left;
58
+ }
59
+ .content[data-placement^=right-start] {
60
+ transform-origin: left top;
61
+ }
62
+ .content[data-placement^=right-end] {
63
+ transform-origin: left bottom;
46
64
  }
47
65
  .content[data-placement^=bottom] {
48
- transform: translateY(-1rem);
66
+ transform-origin: top;
67
+ }
68
+ .content[data-placement^=bottom-start] {
69
+ transform-origin: top left;
70
+ }
71
+ .content[data-placement^=bottom-end] {
72
+ transform-origin: top right;
49
73
  }
50
74
  .content.show {
51
75
  opacity: 1;
52
- transform: translateX(0);
53
- transform: translateY(0);
54
- transition: transform 500ms cubic-bezier(0.05, 0.7, 0.1, 1), opacity 500ms cubic-bezier(0.05, 0.7, 0.1, 1);
76
+ transform: scale(1);
77
+ transition: transform 250ms cubic-bezier(0.05, 0.7, 0.1, 1), opacity 250ms cubic-bezier(0.05, 0.7, 0.1, 1);
55
78
  }
56
79
  .content.overflow-auto {
57
80
  overflow: auto;
@@ -6,11 +6,11 @@ export class CatFormGroup {
6
6
  this.horizontal = false;
7
7
  this.labelSize = undefined;
8
8
  }
9
- onRequiredMarker(newRequiredMarker) {
9
+ onRequiredMarkerChanged(newRequiredMarker) {
10
10
  const updateMarker = newRequiredMarker === 'auto' ? this.calculate(this.formElements) : newRequiredMarker;
11
11
  this.formElements.forEach(element => !element.requiredMarker?.endsWith('!') && (element.requiredMarker = updateMarker));
12
12
  }
13
- onHorizontal(newHorizontal) {
13
+ onHorizontalChanged(newHorizontal) {
14
14
  this.formElements.forEach(element => {
15
15
  element.horizontal = newHorizontal;
16
16
  });
@@ -20,8 +20,8 @@ export class CatFormGroup {
20
20
  }
21
21
  onSlotChange() {
22
22
  this.formElements = Array.from(this.hostElement.querySelectorAll('cat-input, cat-textarea, cat-select, cat-datepicker'));
23
- this.onRequiredMarker(this.requiredMarker);
24
- this.onHorizontal(this.horizontal);
23
+ this.onRequiredMarkerChanged(this.requiredMarker);
24
+ this.onHorizontalChanged(this.horizontal);
25
25
  }
26
26
  calculate(elements) {
27
27
  const optionalFields = elements.filter(value => !value.required).length;
@@ -101,10 +101,10 @@ export class CatFormGroup {
101
101
  static get watchers() {
102
102
  return [{
103
103
  "propName": "requiredMarker",
104
- "methodName": "onRequiredMarker"
104
+ "methodName": "onRequiredMarkerChanged"
105
105
  }, {
106
106
  "propName": "horizontal",
107
- "methodName": "onHorizontal"
107
+ "methodName": "onHorizontalChanged"
108
108
  }];
109
109
  }
110
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cat-form-group.js","sourceRoot":"","sources":["../../../src/components/cat-form-group/cat-form-group.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAazE,MAAM,OAAO,YAAY;;IACf,iBAAY,GAA8B,EAAE,CAAC;0BAWe,MAAM;sBAKrD,KAAK;;;EAQ1B,gBAAgB,CAAC,iBAA4D;IAC3E,MAAM,YAAY,GAAG,iBAAiB,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAC1G,IAAI,CAAC,YAAY,CAAC,OAAO,CACvB,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,GAAG,YAAY,CAAC,CAC7F,CAAC;EACJ,CAAC;EAGD,YAAY,CAAC,aAAsB;IACjC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;MAClC,OAAO,CAAC,UAAU,GAAG,aAAa,CAAC;IACrC,CAAC,CAAC,CAAC;EACL,CAAC;EAED,MAAM;IACJ,OAAO,CACL,EAAC,IAAI,IAAC,KAAK,EAAE,EAAE,cAAc,EAAE,IAAI,CAAC,SAAS,EAAE;MAC7C,YAAM,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAS,CACpD,CACR,CAAC;EACJ,CAAC;EAEO,YAAY;IAClB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,IAAI,CAC5B,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,qDAAqD,CAAC,CAC5D,CAAC;IAC/B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;EACrC,CAAC;EAEO,SAAS,CAAC,QAAmC;IACnD,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAC;IACxD,OAAO,cAAc,IAAI,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;EACpE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Host, Prop, Watch } from '@stencil/core';\n\ntype HTMLCatFormFieldElement =\n | HTMLCatInputElement\n | HTMLCatTextareaElement\n | HTMLCatSelectElement\n | HTMLCatDatepickerElement;\n\n@Component({\n tag: 'cat-form-group',\n styleUrl: 'cat-form-group.scss',\n shadow: true\n})\nexport class CatFormGroup {\n private formElements: HTMLCatFormFieldElement[] = [];\n\n @Element() hostElement!: HTMLElement;\n\n /**\n * Whether the labels need a marker to shown if the forms fields are required or optional.<br /><br />\n * By default, it is set to auto, it will display the mark depending on the number of required and optional fields: <br />\n * - If there are more required, the optional will be marked.<br />\n * - If there are less required, it will mark the required.<br /><br />\n * If a form field had \"!\", the requiredMarked of the field would not change.\n */\n @Prop() requiredMarker: 'none' | 'required' | 'optional' | 'auto' = 'auto';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * The space allocated to the input label\n */\n @Prop() labelSize?: string;\n\n @Watch('requiredMarker')\n onRequiredMarker(newRequiredMarker: 'none' | 'required' | 'optional' | 'auto') {\n const updateMarker = newRequiredMarker === 'auto' ? this.calculate(this.formElements) : newRequiredMarker;\n this.formElements.forEach(\n element => !element.requiredMarker?.endsWith('!') && (element.requiredMarker = updateMarker)\n );\n }\n\n @Watch('horizontal')\n onHorizontal(newHorizontal: boolean) {\n this.formElements.forEach(element => {\n element.horizontal = newHorizontal;\n });\n }\n\n render() {\n return (\n <Host style={{ '--label-size': this.labelSize }}>\n <slot onSlotchange={this.onSlotChange.bind(this)}></slot>\n </Host>\n );\n }\n\n private onSlotChange(): void {\n this.formElements = Array.from(\n this.hostElement.querySelectorAll('cat-input, cat-textarea, cat-select, cat-datepicker')\n ) as HTMLCatFormFieldElement[];\n this.onRequiredMarker(this.requiredMarker);\n this.onHorizontal(this.horizontal);\n }\n\n private calculate(elements: HTMLCatFormFieldElement[]): 'optional' | 'required' {\n const optionalFields = elements.filter(value => !value.required).length;\n const requiredFields = elements.length - optionalFields;\n return requiredFields >= optionalFields ? 'optional' : 'required';\n }\n}\n"]}
1
+ {"version":3,"file":"cat-form-group.js","sourceRoot":"","sources":["../../../src/components/cat-form-group/cat-form-group.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAazE,MAAM,OAAO,YAAY;;IACf,iBAAY,GAA8B,EAAE,CAAC;0BAWe,MAAM;sBAKrD,KAAK;;;EAQ1B,uBAAuB,CAAC,iBAA4D;IAClF,MAAM,YAAY,GAAG,iBAAiB,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Host, Prop, Watch } from '@stencil/core';\n\ntype HTMLCatFormFieldElement =\n | HTMLCatInputElement\n | HTMLCatTextareaElement\n | HTMLCatSelectElement\n | HTMLCatDatepickerElement;\n\n@Component({\n tag: 'cat-form-group',\n styleUrl: 'cat-form-group.scss',\n shadow: true\n})\nexport class CatFormGroup {\n private formElements: HTMLCatFormFieldElement[] = [];\n\n @Element() hostElement!: HTMLElement;\n\n /**\n * Whether the labels need a marker to shown if the forms fields are required or optional.<br /><br />\n * By default, it is set to auto, it will display the mark depending on the number of required and optional fields: <br />\n * - If there are more required, the optional will be marked.<br />\n * - If there are less required, it will mark the required.<br /><br />\n * If a form field had \"!\", the requiredMarked of the field would not change.\n */\n @Prop() requiredMarker: 'none' | 'required' | 'optional' | 'auto' = 'auto';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * The space allocated to the input label\n */\n @Prop() labelSize?: string;\n\n @Watch('requiredMarker')\n onRequiredMarkerChanged(newRequiredMarker: 'none' | 'required' | 'optional' | 'auto') {\n const updateMarker = newRequiredMarker === 'auto' ? this.calculate(this.formElements) : newRequiredMarker;\n this.formElements.forEach(\n element => !element.requiredMarker?.endsWith('!') && (element.requiredMarker = updateMarker)\n );\n }\n\n @Watch('horizontal')\n onHorizontalChanged(newHorizontal: boolean) {\n this.formElements.forEach(element => {\n element.horizontal = newHorizontal;\n });\n }\n\n render() {\n return (\n <Host style={{ '--label-size': this.labelSize }}>\n <slot onSlotchange={this.onSlotChange.bind(this)}></slot>\n </Host>\n );\n }\n\n private onSlotChange(): void {\n this.formElements = Array.from(\n this.hostElement.querySelectorAll('cat-input, cat-textarea, cat-select, cat-datepicker')\n ) as HTMLCatFormFieldElement[];\n this.onRequiredMarkerChanged(this.requiredMarker);\n this.onHorizontalChanged(this.horizontal);\n }\n\n private calculate(elements: HTMLCatFormFieldElement[]): 'optional' | 'required' {\n const optionalFields = elements.filter(value => !value.required).length;\n const requiredFields = elements.length - optionalFields;\n return requiredFields >= optionalFields ? 'optional' : 'required';\n }\n}\n"]}
@@ -371,6 +371,9 @@
371
371
  .input-wrapper.input-round {
372
372
  border-radius: 10rem;
373
373
  }
374
+ .input-wrapper.input-readonly {
375
+ pointer-events: none;
376
+ }
374
377
  .input-wrapper.input-disabled {
375
378
  background: #f2f4f7;
376
379
  cursor: not-allowed;
@@ -432,6 +435,11 @@ input {
432
435
  border: none;
433
436
  outline: none;
434
437
  background: none;
438
+ /* stylelint-disable value-no-vendor-prefix, property-no-vendor-prefix */
439
+ overflow: hidden;
440
+ text-overflow: ellipsis;
441
+ white-space: nowrap;
442
+ /* stylelint-enable value-no-vendor-prefix, property-no-vendor-prefix */
435
443
  /* stylelint-disable property-no-vendor-prefix */
436
444
  /* stylelint-enable property-no-vendor-prefix */
437
445
  }
@@ -53,7 +53,7 @@ export class CatInput {
53
53
  return this.identifier || this._id;
54
54
  }
55
55
  componentWillRender() {
56
- this.watchErrorsHandler(this.errors);
56
+ this.onErrorsChanged(this.errors);
57
57
  this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
58
58
  this.hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
59
59
  if (!this.label && !this.hasSlottedLabel) {
@@ -84,7 +84,7 @@ export class CatInput {
84
84
  this.value = '';
85
85
  this.catChange.emit(this.value);
86
86
  }
87
- watchErrorsHandler(value) {
87
+ onErrorsChanged(value) {
88
88
  if (!coerceBoolean(this.errorUpdate)) {
89
89
  this.errorMap = undefined;
90
90
  }
@@ -104,11 +104,12 @@ export class CatInput {
104
104
  } }, h("div", { class: "label-container" }, (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } }, h("span", { class: "label-wrapper", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label, h("div", { class: "label-metadata" }, !this.required && this.requiredMarker.startsWith('optional') && (h("span", { class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.optional'), ")")), this.required && this.requiredMarker.startsWith('required') && (h("span", { class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.required'), ")")), this.maxLength && (h("div", { class: "label-character-count", "aria-hidden": "true" }, this.value?.toString().length ?? 0, "/", this.maxLength))))))), h("div", { class: "input-container" }, h("div", { class: {
105
105
  'input-wrapper': true,
106
106
  'input-round': this.round,
107
+ 'input-readonly': this.readonly,
107
108
  'input-disabled': this.disabled,
108
109
  'input-invalid': this.invalid
109
110
  }, onClick: () => this.input.focus() }, this.textPrefix && (h("span", { class: "text-prefix", part: "prefix" }, this.textPrefix)), this.icon && !this.iconRight && h("cat-icon", { icon: this.icon, class: "icon-prefix", size: "l" }), h("div", { class: "input-inner-wrapper" }, h("input", { ...this.nativeAttributes, ref: el => (this.input = el), id: this.id, class: {
110
- 'has-clearable': this.clearable && !this.disabled
111
- }, autocomplete: this.autoComplete, disabled: this.disabled, max: this.max, maxlength: this.maxLength, min: this.min, 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), "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.hint?.length ? this.id + '-hint' : undefined }), this.clearable && !this.disabled && this.value && (h("cat-button", { class: "clearable", icon: "$cat:input-close", "icon-only": "true", size: "s", variant: "text", "a11y-label": i18n.t('input.clear'), onClick: this.clear.bind(this) }))), !this.invalid && this.icon && this.iconRight && (h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l" })), this.invalid && h("cat-icon", { icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" }), this.textSuffix && (h("span", { class: "text-suffix", part: "suffix" }, this.textSuffix))), (this.hint || this.hasSlottedHint || !!Object.keys(this.errorMap || {}).length) && (h(CatFormHint, { id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))));
111
+ 'has-clearable': this.clearable && !this.disabled && !this.readonly
112
+ }, autocomplete: this.autoComplete, disabled: this.disabled, max: this.max, maxlength: this.maxLength, min: this.min, 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), "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.hint?.length ? this.id + '-hint' : undefined }), this.clearable && !this.disabled && !this.readonly && this.value && (h("cat-button", { class: "clearable", icon: "$cat:input-close", "icon-only": "true", size: "s", variant: "text", "a11y-label": i18n.t('input.clear'), onClick: this.clear.bind(this) }))), !this.invalid && this.icon && this.iconRight && (h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l" })), this.invalid && h("cat-icon", { icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" }), this.textSuffix && (h("span", { class: "text-suffix", part: "suffix" }, this.textSuffix))), (this.hint || this.hasSlottedHint || !!Object.keys(this.errorMap || {}).length) && (h(CatFormHint, { id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))));
112
113
  }
113
114
  get invalid() {
114
115
  return !!this.errorMap;
@@ -779,7 +780,7 @@ export class CatInput {
779
780
  static get watchers() {
780
781
  return [{
781
782
  "propName": "errors",
782
- "methodName": "watchErrorsHandler"
783
+ "methodName": "onErrorsChanged"
783
784
  }];
784
785
  }
785
786
  }
@@ -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,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport log from 'loglevel';\nimport { coerceBoolean, coerceNumber } from '../../utils/coerce';\nimport { CatFormHint, ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { InputType } from './input-type';\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 _id = `cat-input-${nextUniqueId++}`;\n private get id() {\n return this.identifier || this._id;\n }\n\n private input!: HTMLInputElement;\n private errorMapSrc?: ErrorMap;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\n\n @State() errorMap?: ErrorMap;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = 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 * A unique identifier for the input.\n */\n @Prop() identifier?: string;\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 date, time and numeric values.\n */\n @Prop() max?: number | string;\n\n /**\n * A maximum length (number of characters) for textual values.\n */\n @Prop() maxLength?: number;\n\n /**\n * A minimum value for date, time and numeric values.\n */\n @Prop() min?: number | string;\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?: string;\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: InputType = 'text';\n\n /**\n * The value of the control.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors on change with the given delay in milliseconds.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\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.watchErrorsHandler(this.errors);\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.warn('[A11y] Missing ARIA label on input', this);\n }\n }\n\n /**\n * Programmatically move focus to the input. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n /**\n * Programmatically remove focus from the input. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input.blur();\n }\n\n /**\n * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.value = '';\n this.catChange.emit(this.value);\n }\n\n @Watch('errors')\n watchErrorsHandler(value?: boolean | string[] | ErrorMap) {\n if (!coerceBoolean(this.errorUpdate)) {\n this.errorMap = undefined;\n } else {\n this.errorMapSrc = Array.isArray(value)\n ? (value as string[]).reduce((acc, err) => ({ ...acc, [err]: undefined }), {})\n : value === true\n ? {}\n : value || undefined;\n this.showErrorsIfTimeout() || this.showErrorsIfNoFocus();\n }\n }\n\n render() {\n return (\n <div\n class={{\n 'input-field': true,\n 'input-horizontal': this.horizontal\n }}\n >\n <div class=\"label-container\">\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={this.id} class={{ hidden: this.labelHidden }}>\n <span class=\"label-wrapper\" part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n <div class=\"label-metadata\">\n {!this.required && this.requiredMarker.startsWith('optional') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.optional')})\n </span>\n )}\n {this.required && this.requiredMarker.startsWith('required') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.required')})\n </span>\n )}\n {this.maxLength && (\n <div class=\"label-character-count\" aria-hidden=\"true\">\n {this.value?.toString().length ?? 0}/{this.maxLength}\n </div>\n )}\n </div>\n </span>\n </label>\n )}\n </div>\n <div class=\"input-container\">\n <div\n class={{\n 'input-wrapper': true,\n 'input-round': this.round,\n 'input-disabled': this.disabled,\n 'input-invalid': this.invalid\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 {...this.nativeAttributes}\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.min}\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 aria-invalid={this.invalid ? 'true' : undefined}\n aria-describedby={this.hint?.length ? this.id + '-hint' : undefined}\n ></input>\n {this.clearable && !this.disabled && this.value && (\n <cat-button\n class=\"clearable\"\n icon=\"$cat:input-close\"\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={i18n.t('input.clear')}\n onClick={this.clear.bind(this)}\n ></cat-button>\n )}\n </div>\n {!this.invalid && this.icon && this.iconRight && (\n <cat-icon icon={this.icon} class=\"icon-suffix\" size=\"l\"></cat-icon>\n )}\n {this.invalid && <cat-icon icon=\"$cat:input-error\" class=\"icon-suffix cat-text-danger\" 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 || this.hasSlottedHint || !!Object.keys(this.errorMap || {}).length) && (\n <CatFormHint\n id={this.id}\n hint={this.hint}\n slottedHint={this.hasSlottedHint && <slot name=\"hint\"></slot>}\n errorMap={this.errorMap}\n />\n )}\n </div>\n </div>\n );\n }\n\n private get invalid() {\n return !!this.errorMap;\n }\n\n private onInput() {\n this.value = this.input.value;\n this.catChange.emit(this.value);\n this.showErrorsIfTimeout();\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 if (coerceBoolean(this.errorUpdate)) {\n this.showErrors();\n }\n }\n\n private showErrors() {\n this.errorMap = this.errorMapSrc;\n }\n\n private errorUpdateTimeoutId?: number;\n private showErrorsIfTimeout() {\n const errorUpdate = coerceNumber(this.errorUpdate, null);\n if (errorUpdate !== null) {\n typeof this.errorUpdateTimeoutId === 'number' && window.clearTimeout(this.errorUpdateTimeoutId);\n this.errorUpdateTimeoutId = window.setTimeout(() => this.showErrors(), errorUpdate);\n return true;\n }\n return false;\n }\n\n private showErrorsIfNoFocus() {\n const hasFocus = document.activeElement === this.hostElement || document.activeElement === this.input;\n if (!hasFocus) {\n this.showErrors();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"cat-input.js","sourceRoot":"","sources":["../../../src/components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K,CAAC;IACtG,IAAI,CAAC,QAAQ,EAAE;MACb,IAAI,CAAC,UAAU,EAAE,CAAC;KACnB;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport log from 'loglevel';\nimport { coerceBoolean, coerceNumber } from '../../utils/coerce';\nimport { CatFormHint, ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { InputType } from './input-type';\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 _id = `cat-input-${nextUniqueId++}`;\n private get id() {\n return this.identifier || this._id;\n }\n\n private input!: HTMLInputElement;\n private errorMapSrc?: ErrorMap;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\n\n @State() errorMap?: ErrorMap;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = 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 * A unique identifier for the input.\n */\n @Prop() identifier?: string;\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 date, time and numeric values.\n */\n @Prop() max?: number | string;\n\n /**\n * A maximum length (number of characters) for textual values.\n */\n @Prop() maxLength?: number;\n\n /**\n * A minimum value for date, time and numeric values.\n */\n @Prop() min?: number | string;\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?: string;\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: InputType = 'text';\n\n /**\n * The value of the control.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors on change with the given delay in milliseconds.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\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.onErrorsChanged(this.errors);\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.warn('[A11y] Missing ARIA label on input', this);\n }\n }\n\n /**\n * Programmatically move focus to the input. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n /**\n * Programmatically remove focus from the input. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input.blur();\n }\n\n /**\n * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.value = '';\n this.catChange.emit(this.value);\n }\n\n @Watch('errors')\n onErrorsChanged(value?: boolean | string[] | ErrorMap) {\n if (!coerceBoolean(this.errorUpdate)) {\n this.errorMap = undefined;\n } else {\n this.errorMapSrc = Array.isArray(value)\n ? (value as string[]).reduce((acc, err) => ({ ...acc, [err]: undefined }), {})\n : value === true\n ? {}\n : value || undefined;\n this.showErrorsIfTimeout() || this.showErrorsIfNoFocus();\n }\n }\n\n render() {\n return (\n <div\n class={{\n 'input-field': true,\n 'input-horizontal': this.horizontal\n }}\n >\n <div class=\"label-container\">\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={this.id} class={{ hidden: this.labelHidden }}>\n <span class=\"label-wrapper\" part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n <div class=\"label-metadata\">\n {!this.required && this.requiredMarker.startsWith('optional') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.optional')})\n </span>\n )}\n {this.required && this.requiredMarker.startsWith('required') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.required')})\n </span>\n )}\n {this.maxLength && (\n <div class=\"label-character-count\" aria-hidden=\"true\">\n {this.value?.toString().length ?? 0}/{this.maxLength}\n </div>\n )}\n </div>\n </span>\n </label>\n )}\n </div>\n <div class=\"input-container\">\n <div\n class={{\n 'input-wrapper': true,\n 'input-round': this.round,\n 'input-readonly': this.readonly,\n 'input-disabled': this.disabled,\n 'input-invalid': this.invalid\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 {...this.nativeAttributes}\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n class={{\n 'has-clearable': this.clearable && !this.disabled && !this.readonly\n }}\n autocomplete={this.autoComplete}\n disabled={this.disabled}\n max={this.max}\n maxlength={this.maxLength}\n min={this.min}\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 aria-invalid={this.invalid ? 'true' : undefined}\n aria-describedby={this.hint?.length ? this.id + '-hint' : undefined}\n ></input>\n {this.clearable && !this.disabled && !this.readonly && this.value && (\n <cat-button\n class=\"clearable\"\n icon=\"$cat:input-close\"\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={i18n.t('input.clear')}\n onClick={this.clear.bind(this)}\n ></cat-button>\n )}\n </div>\n {!this.invalid && this.icon && this.iconRight && (\n <cat-icon icon={this.icon} class=\"icon-suffix\" size=\"l\"></cat-icon>\n )}\n {this.invalid && <cat-icon icon=\"$cat:input-error\" class=\"icon-suffix cat-text-danger\" 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 || this.hasSlottedHint || !!Object.keys(this.errorMap || {}).length) && (\n <CatFormHint\n id={this.id}\n hint={this.hint}\n slottedHint={this.hasSlottedHint && <slot name=\"hint\"></slot>}\n errorMap={this.errorMap}\n />\n )}\n </div>\n </div>\n );\n }\n\n private get invalid() {\n return !!this.errorMap;\n }\n\n private onInput() {\n this.value = this.input.value;\n this.catChange.emit(this.value);\n this.showErrorsIfTimeout();\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 if (coerceBoolean(this.errorUpdate)) {\n this.showErrors();\n }\n }\n\n private showErrors() {\n this.errorMap = this.errorMapSrc;\n }\n\n private errorUpdateTimeoutId?: number;\n private showErrorsIfTimeout() {\n const errorUpdate = coerceNumber(this.errorUpdate, null);\n if (errorUpdate !== null) {\n typeof this.errorUpdateTimeoutId === 'number' && window.clearTimeout(this.errorUpdateTimeoutId);\n this.errorUpdateTimeoutId = window.setTimeout(() => this.showErrors(), errorUpdate);\n return true;\n }\n return false;\n }\n\n private showErrorsIfNoFocus() {\n const hasFocus = document.activeElement === this.hostElement || document.activeElement === this.input;\n if (!hasFocus) {\n this.showErrors();\n }\n }\n}\n"]}
@@ -506,7 +506,7 @@ cat-spinner {
506
506
  box-shadow: 0 4px 6px -2px rgba(27, 31, 38, 0.03), 0 12px 16px -4px rgba(27, 31, 38, 0.08);
507
507
  border-radius: var(--cat-border-radius-m, 0.25rem);
508
508
  border: 1px solid rgb(var(--cat-border-color, 235, 236, 240));
509
- z-index: 100;
509
+ z-index: calc(var(--cat-z-index, 1000) + 100);
510
510
  /* Avoid layout interference */
511
511
  width: max-content;
512
512
  top: 0;