@haiilo/catalyst 0.6.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/catalyst.esm.js.map +1 -1
  3. package/dist/catalyst/p-12486027.js.map +1 -1
  4. package/dist/catalyst/p-12b96af6.js +2 -0
  5. package/dist/catalyst/p-12b96af6.js.map +1 -0
  6. package/dist/catalyst/p-4254363e.entry.js +2 -0
  7. package/dist/catalyst/p-4254363e.entry.js.map +1 -0
  8. package/dist/catalyst/p-5616e2cd.js +2 -0
  9. package/dist/catalyst/p-5616e2cd.js.map +1 -0
  10. package/dist/catalyst/p-dda85567.entry.js +10 -0
  11. package/dist/catalyst/p-dda85567.entry.js.map +1 -0
  12. package/dist/catalyst/scss/_mixins.scss +9 -0
  13. package/dist/catalyst/scss/_variables.scss +64 -0
  14. package/dist/catalyst/scss/_variables.tokens.scss +84 -0
  15. package/dist/catalyst/scss/core/_base.scss +12 -0
  16. package/dist/catalyst/scss/core/_nav.scss +23 -0
  17. package/dist/catalyst/scss/core/_typography.scss +237 -0
  18. package/dist/catalyst/scss/fonts/_fonts.mixins.azeret.scss +14 -0
  19. package/dist/catalyst/scss/fonts/_fonts.mixins.dm.scss +53 -0
  20. package/dist/catalyst/scss/fonts/_fonts.mixins.lato.scss +185 -0
  21. package/dist/catalyst/scss/fonts/_fonts.mixins.scss +3 -0
  22. package/dist/catalyst/scss/fonts/_fonts.scss +13 -0
  23. package/dist/catalyst/scss/index.scss +32 -0
  24. package/dist/catalyst/scss/utils/_color.scss +52 -0
  25. package/dist/catalyst/scss/utils/_disabled.mixins.scss +7 -0
  26. package/dist/catalyst/scss/utils/_display.scss +20 -0
  27. package/dist/catalyst/scss/utils/_elevation.mixins.scss +10 -0
  28. package/dist/catalyst/scss/utils/_elevation.scss +19 -0
  29. package/dist/catalyst/scss/utils/_layout.scss +78 -0
  30. package/dist/catalyst/scss/utils/_media.mixins.scss +37 -0
  31. package/dist/catalyst/scss/utils/_ratio.mixins.scss +12 -0
  32. package/dist/catalyst/scss/utils/_ratio.scss +20 -0
  33. package/dist/catalyst/scss/utils/_sizing.mixins.scss +15 -0
  34. package/dist/catalyst/scss/utils/_sizing.scss +16 -0
  35. package/dist/catalyst/scss/utils/_spacing.mixins.scss +5 -0
  36. package/dist/catalyst/scss/utils/_spacing.scss +49 -0
  37. package/dist/catalyst/scss/utils/_toast.scss +77 -0
  38. package/dist/catalyst/scss/utils/_typography.mixins.scss +102 -0
  39. package/dist/catalyst/scss/utils/_typography.scss +34 -0
  40. package/dist/catalyst/scss/utils/_visibility.mixins.scss +29 -0
  41. package/dist/catalyst/scss/utils/_visibility.scss +13 -0
  42. package/dist/cjs/app-globals-aa29ad72.js.map +1 -1
  43. package/dist/cjs/{cat-alert_16.cjs.entry.js → cat-alert_18.cjs.entry.js} +174 -44
  44. package/dist/cjs/cat-alert_18.cjs.entry.js.map +1 -0
  45. package/dist/cjs/cat-form-hint-93a6936b.js +22 -0
  46. package/dist/cjs/cat-form-hint-93a6936b.js.map +1 -0
  47. package/dist/cjs/cat-textarea.cjs.entry.js +13 -12
  48. package/dist/cjs/cat-textarea.cjs.entry.js.map +1 -1
  49. package/dist/cjs/catalyst.cjs.js +2 -2
  50. package/dist/cjs/{index-5d72f0e4.js → index-499bad41.js} +44 -1
  51. package/dist/cjs/index-499bad41.js.map +1 -0
  52. package/dist/cjs/loader.cjs.js +2 -2
  53. package/dist/collection/collection-manifest.json +2 -0
  54. package/dist/collection/components/cat-checkbox/cat-checkbox.css +14 -0
  55. package/dist/collection/components/cat-checkbox/cat-checkbox.js +44 -11
  56. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  57. package/dist/collection/components/cat-form-hint/cat-form-hint.js +16 -0
  58. package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -0
  59. package/dist/collection/components/cat-icon/cat-icon.css +4 -1
  60. package/dist/collection/components/cat-input/cat-input.css +12 -6
  61. package/dist/collection/components/cat-input/cat-input.js +24 -25
  62. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  63. package/dist/collection/components/cat-radio/cat-radio.css +14 -0
  64. package/dist/collection/components/cat-radio/cat-radio.js +41 -8
  65. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  66. package/dist/collection/components/cat-tab/cat-tab.css +12 -0
  67. package/dist/collection/components/cat-tab/cat-tab.js +203 -0
  68. package/dist/collection/components/cat-tab/cat-tab.js.map +1 -0
  69. package/dist/collection/components/cat-tabs/cat-tabs.css +33 -0
  70. package/dist/collection/components/cat-tabs/cat-tabs.js +122 -0
  71. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -0
  72. package/dist/collection/components/cat-textarea/cat-textarea.css +12 -6
  73. package/dist/collection/components/cat-textarea/cat-textarea.js +24 -18
  74. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  75. package/dist/collection/components/cat-toggle/cat-toggle.css +14 -0
  76. package/dist/collection/components/cat-toggle/cat-toggle.js +40 -7
  77. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  78. package/dist/collection/components/cat-tooltip/cat-tooltip.js +13 -8
  79. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
  80. package/dist/collection/scss/_mixins.scss +9 -0
  81. package/dist/collection/scss/_variables.scss +64 -0
  82. package/dist/collection/scss/_variables.tokens.scss +84 -0
  83. package/dist/collection/scss/core/_base.scss +12 -0
  84. package/dist/collection/scss/core/_nav.scss +23 -0
  85. package/dist/collection/scss/core/_typography.scss +237 -0
  86. package/dist/collection/scss/fonts/_fonts.mixins.azeret.scss +14 -0
  87. package/dist/collection/scss/fonts/_fonts.mixins.dm.scss +53 -0
  88. package/dist/collection/scss/fonts/_fonts.mixins.lato.scss +185 -0
  89. package/dist/collection/scss/fonts/_fonts.mixins.scss +3 -0
  90. package/dist/collection/scss/fonts/_fonts.scss +13 -0
  91. package/dist/collection/scss/index.scss +32 -0
  92. package/dist/collection/scss/utils/_color.scss +52 -0
  93. package/dist/collection/scss/utils/_disabled.mixins.scss +7 -0
  94. package/dist/collection/scss/utils/_display.scss +20 -0
  95. package/dist/collection/scss/utils/_elevation.mixins.scss +10 -0
  96. package/dist/collection/scss/utils/_elevation.scss +19 -0
  97. package/dist/collection/scss/utils/_layout.scss +78 -0
  98. package/dist/collection/scss/utils/_media.mixins.scss +37 -0
  99. package/dist/collection/scss/utils/_ratio.mixins.scss +12 -0
  100. package/dist/collection/scss/utils/_ratio.scss +20 -0
  101. package/dist/collection/scss/utils/_sizing.mixins.scss +15 -0
  102. package/dist/collection/scss/utils/_sizing.scss +16 -0
  103. package/dist/collection/scss/utils/_spacing.mixins.scss +5 -0
  104. package/dist/collection/scss/utils/_spacing.scss +49 -0
  105. package/dist/collection/scss/utils/_toast.scss +77 -0
  106. package/dist/collection/scss/utils/_typography.mixins.scss +102 -0
  107. package/dist/collection/scss/utils/_typography.scss +34 -0
  108. package/dist/collection/scss/utils/_visibility.mixins.scss +29 -0
  109. package/dist/collection/scss/utils/_visibility.scss +13 -0
  110. package/dist/components/cat-checkbox.js +16 -5
  111. package/dist/components/cat-checkbox.js.map +1 -1
  112. package/dist/components/cat-form-hint.js +20 -0
  113. package/dist/components/cat-form-hint.js.map +1 -0
  114. package/dist/components/cat-icon2.js +1 -1
  115. package/dist/components/cat-icon2.js.map +1 -1
  116. package/dist/components/cat-input.js +16 -18
  117. package/dist/components/cat-input.js.map +1 -1
  118. package/dist/components/cat-radio.js +16 -5
  119. package/dist/components/cat-radio.js.map +1 -1
  120. package/dist/components/cat-tab.d.ts +11 -0
  121. package/dist/components/cat-tab.js +70 -0
  122. package/dist/components/cat-tab.js.map +1 -0
  123. package/dist/components/cat-tabs.d.ts +11 -0
  124. package/dist/components/cat-tabs.js +107 -0
  125. package/dist/components/cat-tabs.js.map +1 -0
  126. package/dist/components/cat-textarea.js +14 -12
  127. package/dist/components/cat-textarea.js.map +1 -1
  128. package/dist/components/cat-toggle.js +16 -5
  129. package/dist/components/cat-toggle.js.map +1 -1
  130. package/dist/components/cat-tooltip.js +13 -8
  131. package/dist/components/cat-tooltip.js.map +1 -1
  132. package/dist/components/index.js.map +1 -1
  133. package/dist/esm/app-globals-cf55f7f5.js.map +1 -1
  134. package/dist/esm/{cat-alert_16.entry.js → cat-alert_18.entry.js} +173 -45
  135. package/dist/esm/cat-alert_18.entry.js.map +1 -0
  136. package/dist/esm/cat-form-hint-dc443c7c.js +20 -0
  137. package/dist/esm/cat-form-hint-dc443c7c.js.map +1 -0
  138. package/dist/esm/cat-textarea.entry.js +13 -12
  139. package/dist/esm/cat-textarea.entry.js.map +1 -1
  140. package/dist/esm/catalyst.js +2 -2
  141. package/dist/esm/{index-fd12be19.js → index-039e6f5f.js} +44 -2
  142. package/dist/esm/index-039e6f5f.js.map +1 -0
  143. package/dist/esm/loader.js +2 -2
  144. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +9 -0
  145. package/dist/types/components/cat-form-hint/cat-form-hint.d.ts +19 -0
  146. package/dist/types/components/cat-input/cat-input.d.ts +7 -5
  147. package/dist/types/components/cat-radio/cat-radio.d.ts +9 -0
  148. package/dist/types/components/cat-tab/cat-tab.d.ts +43 -0
  149. package/dist/types/components/cat-tabs/cat-tabs.d.ts +25 -0
  150. package/dist/types/components/cat-textarea/cat-textarea.d.ts +7 -2
  151. package/dist/types/components/cat-toggle/cat-toggle.d.ts +9 -0
  152. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +1 -0
  153. package/dist/types/components.d.ts +134 -8
  154. package/package.json +2 -2
  155. package/dist/catalyst/p-6a5f0d4a.entry.js +0 -10
  156. package/dist/catalyst/p-6a5f0d4a.entry.js.map +0 -1
  157. package/dist/catalyst/p-a8629c54.entry.js +0 -2
  158. package/dist/catalyst/p-a8629c54.entry.js.map +0 -1
  159. package/dist/catalyst/p-bfc656ca.js +0 -2
  160. package/dist/catalyst/p-bfc656ca.js.map +0 -1
  161. package/dist/cjs/cat-alert_16.cjs.entry.js.map +0 -1
  162. package/dist/cjs/index-5d72f0e4.js.map +0 -1
  163. package/dist/esm/cat-alert_16.entry.js.map +0 -1
  164. package/dist/esm/index-fd12be19.js.map +0 -1
@@ -0,0 +1,77 @@
1
+ @import 'variables';
2
+ @import 'mixins';
3
+
4
+ $-background-color: cat-token('color.base.neutral.0');
5
+ $-text-color: cat-token('color.base.neutral.900');
6
+ $-title-border: cat-token('color.base.neutral.300');
7
+ $-shadow: cat-token('color.ui.border.dark');
8
+ $-error-color: cat-token('color.theme.danger.text');
9
+ $-info-color: cat-token('color.theme.secondary.text');
10
+ $-success-color: cat-token('color.theme.success.text');
11
+
12
+ .cat-toastify {
13
+ background: $-background-color;
14
+ color: $-text-color;
15
+ padding: 0;
16
+ @include cat-elevation(1);
17
+
18
+ .toast-close {
19
+ float: right;
20
+ font-size: 20px;
21
+ margin-top: 0.5rem;
22
+ position: absolute;
23
+ top: 0;
24
+ right: 0;
25
+ z-index: 10;
26
+ }
27
+
28
+ .cat-toastify-wrapper {
29
+ display: block;
30
+ position: relative;
31
+
32
+ .cat-toastify-icon-wrapper {
33
+ position: absolute;
34
+ top: 6px;
35
+ left: 5px;
36
+
37
+ &.info {
38
+ color: $-info-color;
39
+ }
40
+
41
+ &.error {
42
+ color: $-error-color;
43
+ }
44
+
45
+ &.success {
46
+ color: $-success-color;
47
+ }
48
+ }
49
+
50
+ .cat-toastify-title-wrapper {
51
+ width: 100%;
52
+ padding: 0.5rem 0.5rem 0.5rem 2rem;
53
+
54
+ &.has-message {
55
+ border-bottom: 1px solid $-title-border;
56
+ }
57
+
58
+ .cat-toastify-title {
59
+ width: 100%;
60
+ padding-right: 25px;
61
+ overflow: hidden;
62
+ text-overflow: ellipsis;
63
+ white-space: nowrap;
64
+ font-size: 15px;
65
+ line-height: 20px;
66
+ font-weight: 600;
67
+ color: $-text-color;
68
+ }
69
+ }
70
+
71
+ .cat-toastify-message {
72
+ width: 100%;
73
+ padding: 0.5rem;
74
+ color: $-text-color;
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,102 @@
1
+ @use '../variables' as *;
2
+
3
+ // ---- Head
4
+
5
+ @function cat-head-font-family() {
6
+ @return cat-token('font.family.head'), $font-fallback-sans-serif;
7
+ }
8
+
9
+ @function cat-head-font-size($size) {
10
+ @return cat-token('size.font.head.#{$size}');
11
+ }
12
+
13
+ @function cat-head-line-height($size) {
14
+ @return cat-token('size.line.head.#{$size}');
15
+ }
16
+
17
+ @mixin cat-head($size, $weight: null) {
18
+ font-family: cat-head-font-family();
19
+ font-size: cat-head-font-size($size);
20
+ line-height: cat-head-line-height($size);
21
+ color: cat-token('color.ui.font.head');
22
+ font-weight: $weight;
23
+ }
24
+
25
+ // ---- Body
26
+
27
+ @function cat-body-font-family() {
28
+ @return cat-token('font.family.body'), $font-fallback-sans-serif;
29
+ }
30
+
31
+ @function cat-body-font-size($size) {
32
+ @return cat-token('size.font.body.#{$size}');
33
+ }
34
+
35
+ @function cat-body-line-height($size) {
36
+ @return cat-token('size.line.body.#{$size}');
37
+ }
38
+
39
+ @mixin cat-body($size, $weight: null) {
40
+ // skip font family, as it is set on the body
41
+ // skip color, as it is set on the body
42
+ font-size: cat-body-font-size($size);
43
+ line-height: cat-body-line-height($size);
44
+ font-weight: $weight;
45
+ }
46
+
47
+ // ---- Mono
48
+
49
+ @function cat-mono-font-family() {
50
+ @return cat-token('font.family.mono'), $font-fallback-monospace;
51
+ }
52
+
53
+ @function cat-mono-font-size($size) {
54
+ @return cat-token('size.font.mono.#{$size}');
55
+ }
56
+
57
+ @function cat-mono-line-height($size) {
58
+ @return cat-token('size.line.mono.#{$size}');
59
+ }
60
+
61
+ @mixin cat-mono($size, $weight: null) {
62
+ font-family: cat-mono-font-family();
63
+ font-size: cat-mono-font-size($size);
64
+ line-height: cat-mono-line-height($size);
65
+ color: cat-token('color.ui.font.mono');
66
+ font-weight: $weight;
67
+ }
68
+
69
+ // ---- Utils
70
+
71
+ @mixin cat-break-word {
72
+ word-wrap: break-word;
73
+ word-break: break-word;
74
+ }
75
+
76
+ @mixin cat-ellipsis($lines: 1) {
77
+ /* stylelint-disable value-no-vendor-prefix, property-no-vendor-prefix */
78
+ @if $lines == 1 {
79
+ overflow: hidden;
80
+ text-overflow: ellipsis;
81
+ white-space: nowrap;
82
+ } @else {
83
+ display: -webkit-box;
84
+ -webkit-line-clamp: $lines;
85
+ -webkit-box-orient: vertical;
86
+ overflow: hidden;
87
+ }
88
+ /* stylelint-enable value-no-vendor-prefix, property-no-vendor-prefix */
89
+ }
90
+
91
+ @mixin cat-select($select: auto) {
92
+ /* stylelint-disable property-no-vendor-prefix */
93
+ -webkit-user-select: $select;
94
+ -ms-user-select: $select;
95
+ user-select: $select;
96
+ /* stylelint-enable property-no-vendor-prefix */
97
+ }
98
+
99
+ @mixin cat-font-smooth() {
100
+ -webkit-font-smoothing: antialiased;
101
+ -moz-osx-font-smoothing: greyscale;
102
+ }
@@ -0,0 +1,34 @@
1
+ @use 'typography.mixins' as *;
2
+
3
+ .cat-text-left {
4
+ text-align: left !important;
5
+ }
6
+
7
+ .cat-text-center {
8
+ text-align: center !important;
9
+ }
10
+
11
+ .cat-text-right {
12
+ text-align: right !important;
13
+ }
14
+
15
+ .cat-ellipsis {
16
+ @include cat-ellipsis;
17
+ }
18
+ @for $i from 1 through 5 {
19
+ .cat-ellipsis-#{$i} {
20
+ @include cat-ellipsis($i);
21
+ }
22
+ }
23
+
24
+ .cat-select {
25
+ @include cat-select;
26
+ }
27
+
28
+ .cat-no-select {
29
+ @include cat-select(none);
30
+ }
31
+
32
+ .cat-break-word {
33
+ @include cat-break-word;
34
+ }
@@ -0,0 +1,29 @@
1
+ @mixin cat-visually-hidden {
2
+ position: absolute !important;
3
+ width: 1px !important;
4
+ height: 1px !important;
5
+ padding: 0 !important;
6
+ margin: -1px !important;
7
+ overflow: hidden !important;
8
+ clip: rect(0, 0, 0, 0) !important;
9
+ white-space: nowrap !important;
10
+ border: 0 !important;
11
+ }
12
+
13
+ @mixin cat-visually-hidden-focusable {
14
+ &:not(:focus):not(:focus-within) {
15
+ @include cat-visually-hidden;
16
+ }
17
+ }
18
+
19
+ @mixin cat-visually-hidden-hoverable($container: null) {
20
+ @if $container {
21
+ #{$container}:not(:hover):not(:focus):not(:focus-within) & {
22
+ @include cat-visually-hidden;
23
+ }
24
+ } @else {
25
+ *:not(:hover):not(:focus):not(:focus-within) > & {
26
+ @include cat-visually-hidden;
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,13 @@
1
+ @use 'visibility.mixins' as *;
2
+
3
+ .cat-visually-hidden {
4
+ @include cat-visually-hidden;
5
+ }
6
+
7
+ .cat-visually-hidden-focusable {
8
+ @include cat-visually-hidden-focusable;
9
+ }
10
+
11
+ .cat-visually-hidden-hoverable {
12
+ @include cat-visually-hidden-hoverable;
13
+ }
@@ -1,7 +1,8 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
2
  import { l as loglevel } from './loglevel.js';
3
+ import { C as CatFormHint } from './cat-form-hint.js';
3
4
 
4
- const catCheckboxCss = ":host{display:flex;margin-bottom:1rem}:host([hidden]){display:none}label{flex:0 1 auto;display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;-webkit-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}input{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.box{flex:0 0 auto;display:flex;position:relative;height:1.25rem;width:1.25rem;background-color:white;border:1px solid #d7dbe0;border-radius:0.125rem;transition:background-color 0.13s ease, border-color 0.13s ease}.box svg{fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:16px;stroke-dashoffset:16px;transition:all 0.13s ease;width:70%;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%) scale(0.99)}:checked+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:checked+.box .check{stroke-dashoffset:0}:indeterminate+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:indeterminate+.box .dash{stroke-dashoffset:0}:focus-visible+.box{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.label{flex:1 1 auto}.is-hidden .label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.is-disabled{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}";
5
+ const catCheckboxCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;margin:0}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{flex:0 1 auto;display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;-webkit-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}input{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.box{flex:0 0 auto;display:flex;position:relative;height:1.25rem;width:1.25rem;background-color:white;border:1px solid #d7dbe0;border-radius:0.125rem;transition:background-color 0.13s ease, border-color 0.13s ease}.box svg{fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:16px;stroke-dashoffset:16px;transition:all 0.13s ease;width:70%;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%) scale(0.99)}:checked+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:checked+.box .check{stroke-dashoffset:0}:indeterminate+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:indeterminate+.box .dash{stroke-dashoffset:0}:focus-visible+.box{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.label{flex:1 1 auto}.is-hidden .label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.is-disabled{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}";
5
6
 
6
7
  let nextUniqueId = 0;
7
8
  const CatCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
@@ -13,6 +14,7 @@ const CatCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
13
14
  this.catFocus = createEvent(this, "catFocus", 7);
14
15
  this.catBlur = createEvent(this, "catBlur", 7);
15
16
  this.id = `cat-checkbox-${nextUniqueId++}`;
17
+ this.hasSlottedLabel = false;
16
18
  /**
17
19
  * Checked state of the checkbox
18
20
  */
@@ -44,7 +46,8 @@ const CatCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
44
46
  }
45
47
  }
46
48
  componentWillRender() {
47
- if (!this.label) {
49
+ this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
50
+ if (!this.label && !this.hasSlottedLabel) {
48
51
  loglevel.error('[A11y] Missing ARIA label on checkbox', this);
49
52
  }
50
53
  }
@@ -58,9 +61,14 @@ const CatCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
58
61
  this.input.focus(options);
59
62
  }
60
63
  render() {
61
- return (h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } }, h("input", { ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }), h("span", { class: "box", "aria-hidden": "true", part: "checkbox" }, h("svg", { class: "check", viewBox: "0 0 12 10" }, h("polyline", { points: "1.5 6 4.5 9 10.5 1" })), h("svg", { class: "dash", viewBox: "0 0 12 10" }, h("polyline", { points: "1.5 5 10.5 5" }))), h("span", { class: "label", part: "label" }, this.label)));
64
+ return (h(Host, null, h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } }, h("input", { ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }), h("span", { class: "box", "aria-hidden": "true", part: "checkbox" }, h("svg", { class: "check", viewBox: "0 0 12 10" }, h("polyline", { points: "1.5 6 4.5 9 10.5 1" })), h("svg", { class: "dash", viewBox: "0 0 12 10" }, h("polyline", { points: "1.5 5 10.5 5" }))), h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)), this.hintSection));
65
+ }
66
+ get hintSection() {
67
+ const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
68
+ return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
62
69
  }
63
70
  onInput(event) {
71
+ this.value = this.input.value;
64
72
  this.catChange.emit(event);
65
73
  }
66
74
  onFocus(event) {
@@ -69,6 +77,7 @@ const CatCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
69
77
  onBlur(event) {
70
78
  this.catBlur.emit(event);
71
79
  }
80
+ get hostElement() { return this; }
72
81
  static get style() { return catCheckboxCss; }
73
82
  }, [1, "cat-checkbox", {
74
83
  "checked": [4],
@@ -78,7 +87,9 @@ const CatCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
78
87
  "labelHidden": [4, "label-hidden"],
79
88
  "name": [1],
80
89
  "required": [4],
81
- "value": [1],
90
+ "value": [1025],
91
+ "hint": [1],
92
+ "hasSlottedLabel": [32],
82
93
  "setFocus": [64]
83
94
  }]);
84
95
  function defineCustomElement$1() {
@@ -1 +1 @@
1
- {"file":"cat-checkbox.js","mappings":";;;AAAA,MAAM,cAAc,GAAG,yxDAAyxD;;ACGhzD,IAAI,YAAY,GAAG,CAAC,CAAC;MAcRA,aAAW;EALxB;;;;;;;IAMmB,OAAE,GAAG,gBAAgB,YAAY,EAAE,EAAE,CAAC;;;;IAM/C,YAAO,GAAG,KAAK,CAAC;;;;IAKhB,aAAQ,GAAG,KAAK,CAAC;;;;IAKjB,kBAAa,GAAG,KAAK,CAAC;;;;IAKtB,UAAK,GAAG,EAAE,CAAC;;;;IAKX,gBAAW,GAAG,KAAK,CAAC;;;;IAUpB,aAAQ,GAAG,KAAK,CAAC;GAuF1B;EAjEC,gBAAgB;IACd,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,aAAa,EAAE;MACpC,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;KACjC;GACF;EAED,mBAAmB;IACjB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;MACfC,QAAG,CAAC,KAAK,CAAC,uCAAuC,EAAE,IAAI,CAAC,CAAC;KAC1D;GACF;;;;;;;EASD,MAAM,QAAQ,CAAC,OAAsB;IACnC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;GAC3B;EAED,MAAM;IACJ,QACE,aAAO,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,IAAI,CAAC,QAAQ,EAAE,IAC7F,aACE,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/cat-checkbox.scss?tag=cat-checkbox&encapsulation=shadow","./src/components/cat-checkbox/cat-checkbox.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n\n:host {\n display: flex;\n margin-bottom: $cat-body-margin-bottom;\n}\n\n:host([hidden]) {\n display: none;\n}\n\nlabel {\n flex: 0 1 auto;\n display: flex;\n gap: 0.5rem;\n @include cat-body('m');\n @include cat-select(none);\n cursor: pointer;\n}\n\ninput {\n @include cat-visually-hidden;\n}\n\n.box {\n flex: 0 0 auto;\n display: flex;\n position: relative;\n height: 1.25rem;\n width: 1.25rem;\n background-color: cat-token('color.ui.background.input');\n border: 1px solid cat-token('color.ui.border.input');\n border-radius: cat-border-radius(s);\n transition: background-color cat-token('time.transition.s') ease, border-color cat-token('time.transition.s') ease;\n\n svg {\n fill: none;\n stroke-width: 2;\n stroke-linecap: round;\n stroke-linejoin: round;\n stroke-dasharray: 16px;\n stroke-dashoffset: 16px;\n transition: all cat-token('time.transition.s') ease;\n width: 70%;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.99);\n }\n\n :checked + & {\n background-color: cat-token('color.theme.primary.bg');\n border-color: cat-token('color.theme.primary.bg');\n stroke: cat-token('color.theme.primary.fill');\n\n .check {\n stroke-dashoffset: 0;\n }\n }\n\n :indeterminate + & {\n background-color: cat-token('color.theme.primary.bg');\n border-color: cat-token('color.theme.primary.bg');\n stroke: cat-token('color.theme.primary.fill');\n\n .dash {\n stroke-dashoffset: 0;\n }\n }\n\n :focus-visible + & {\n outline: 2px solid cat-token('color.ui.border.focus');\n outline-offset: 1px;\n }\n}\n\n.label {\n flex: 1 1 auto;\n\n .is-hidden & {\n @include cat-visually-hidden;\n }\n}\n\n.is-disabled {\n cursor: not-allowed;\n color: cat-token('color.ui.font.muted');\n}\n","import { Component, Event, EventEmitter, h, Method, Prop } from '@stencil/core';\nimport log from 'loglevel';\n\nlet nextUniqueId = 0;\n\n/**\n * Checkboxes are used to let a user choose one or more options from a limited\n * number of options.\n *\n * @part checkbox - The checkbox element.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-checkbox',\n styleUrls: ['cat-checkbox.scss'],\n shadow: true\n})\nexport class CatCheckbox {\n private readonly id = `cat-checkbox-${nextUniqueId++}`;\n private input!: HTMLInputElement;\n\n /**\n * Checked state of the checkbox\n */\n @Prop() checked = false;\n\n /**\n * Disabled state of the checkbox\n */\n @Prop() disabled = false;\n\n /**\n * Indeterminate state of the checkbox\n */\n @Prop() indeterminate = false;\n\n /**\n * Label of the checkbox which is presented in the UI\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * The name of the input\n */\n @Prop() name?: string;\n\n /**\n * Required state of the checkbox\n */\n @Prop() required = false;\n\n /**\n * The value of the checkbox\n */\n @Prop() value?: string;\n\n /**\n * Emitted when the checked status of the checkbox is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the checkbox received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the checkbox loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentDidLoad() {\n if (this.input && this.indeterminate) {\n this.input.indeterminate = true;\n }\n }\n\n componentWillRender(): void {\n if (!this.label) {\n log.error('[A11y] Missing ARIA label on checkbox', this);\n }\n }\n\n /**\n * Sets focus on the checkbox. Use this method instead of `checkbox.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async setFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n render() {\n return (\n <label htmlFor={this.id} class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled }}>\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n type=\"checkbox\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n required={this.required}\n disabled={this.disabled}\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n />\n <span class=\"box\" aria-hidden=\"true\" part=\"checkbox\">\n <svg class=\"check\" viewBox=\"0 0 12 10\">\n <polyline points=\"1.5 6 4.5 9 10.5 1\"></polyline>\n </svg>\n <svg class=\"dash\" viewBox=\"0 0 12 10\">\n <polyline points=\"1.5 5 10.5 5\"></polyline>\n </svg>\n </span>\n <span class=\"label\" part=\"label\">\n {this.label}\n </span>\n </label>\n );\n }\n\n private onInput(event: Event) {\n this.catChange.emit(event);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"],"version":3}
1
+ {"file":"cat-checkbox.js","mappings":";;;;AAAA,MAAM,cAAc,GAAG,k+DAAk+D;;ACIz/D,IAAI,YAAY,GAAG,CAAC,CAAC;MAgBRA,aAAW;EALxB;;;;;;;IAMmB,OAAE,GAAG,gBAAgB,YAAY,EAAE,EAAE,CAAC;IAK9C,oBAAe,GAAG,KAAK,CAAC;;;;IAKzB,YAAO,GAAG,KAAK,CAAC;;;;IAKhB,aAAQ,GAAG,KAAK,CAAC;;;;IAKjB,kBAAa,GAAG,KAAK,CAAC;;;;IAKtB,UAAK,GAAG,EAAE,CAAC;;;;IAKX,gBAAW,GAAG,KAAK,CAAC;;;;IAUpB,aAAQ,GAAG,KAAK,CAAC;GA0G1B;EA/EC,gBAAgB;IACd,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,aAAa,EAAE;MACpC,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;KACjC;GACF;EAED,mBAAmB;IACjB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1E,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;MACxCC,QAAG,CAAC,KAAK,CAAC,uCAAuC,EAA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,CAAC,KAAK,CAC9D,CACD,EACP,IAAI,CAAC,WAAW,CACZ,EACP;GACH;EAED,IAAY,WAAW;IACrB,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IACzE,QACE,CAAC,IAAI,CAAC,IAAI,IAAI,cAAc,MAC1B,EAAC,WAAW,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,IAAI,YAAM,IAAI,EAAC,MAAM,GAAQ,GAAI,CAC3F,EACD;GACH;EAEO,OAAO,CAAC,KAAY;IAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;GAC5B;EAEO,OAAO,CAAC,KAAiB;IAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;GAC3B;EAEO,MAAM,CAAC,KAAiB;IAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;GAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CatCheckbox","log"],"sources":["./src/components/cat-checkbox/cat-checkbox.scss?tag=cat-checkbox&encapsulation=shadow","./src/components/cat-checkbox/cat-checkbox.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n@use 'src/components/cat-form-hint/cat-form-hint';\n\n:host {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n margin-bottom: $cat-body-margin-bottom;\n}\n\n:host([hidden]) {\n display: none;\n}\n\nlabel {\n flex: 0 1 auto;\n display: flex;\n gap: 0.5rem;\n @include cat-body('m');\n @include cat-select(none);\n cursor: pointer;\n}\n\ninput {\n @include cat-visually-hidden;\n}\n\n.box {\n flex: 0 0 auto;\n display: flex;\n position: relative;\n height: 1.25rem;\n width: 1.25rem;\n background-color: cat-token('color.ui.background.input');\n border: 1px solid cat-token('color.ui.border.input');\n border-radius: cat-border-radius(s);\n transition: background-color cat-token('time.transition.s') ease, border-color cat-token('time.transition.s') ease;\n\n svg {\n fill: none;\n stroke-width: 2;\n stroke-linecap: round;\n stroke-linejoin: round;\n stroke-dasharray: 16px;\n stroke-dashoffset: 16px;\n transition: all cat-token('time.transition.s') ease;\n width: 70%;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.99);\n }\n\n :checked + & {\n background-color: cat-token('color.theme.primary.bg');\n border-color: cat-token('color.theme.primary.bg');\n stroke: cat-token('color.theme.primary.fill');\n\n .check {\n stroke-dashoffset: 0;\n }\n }\n\n :indeterminate + & {\n background-color: cat-token('color.theme.primary.bg');\n border-color: cat-token('color.theme.primary.bg');\n stroke: cat-token('color.theme.primary.fill');\n\n .dash {\n stroke-dashoffset: 0;\n }\n }\n\n :focus-visible + & {\n outline: 2px solid cat-token('color.ui.border.focus');\n outline-offset: 1px;\n }\n}\n\n.label {\n flex: 1 1 auto;\n\n .is-hidden & {\n @include cat-visually-hidden;\n }\n}\n\n.is-disabled {\n cursor: not-allowed;\n color: cat-token('color.ui.font.muted');\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State } from '@stencil/core';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\n\nlet nextUniqueId = 0;\n\n/**\n * Checkboxes are used to let a user choose one or more options from a limited\n * number of options.\n *\n * @slot hint - Optional hint element to be displayed with the checkbox.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part checkbox - The checkbox element.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-checkbox',\n styleUrls: ['cat-checkbox.scss'],\n shadow: true\n})\nexport class CatCheckbox {\n private readonly id = `cat-checkbox-${nextUniqueId++}`;\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Checked state of the checkbox\n */\n @Prop() checked = false;\n\n /**\n * Disabled state of the checkbox\n */\n @Prop() disabled = false;\n\n /**\n * Indeterminate state of the checkbox\n */\n @Prop() indeterminate = false;\n\n /**\n * Label of the checkbox which is presented in the UI\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * The name of the input\n */\n @Prop() name?: string;\n\n /**\n * Required state of the checkbox\n */\n @Prop() required = false;\n\n /**\n * The value of the checkbox\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Optional hint text(s) to be displayed with the checkbox.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Emitted when the checked status of the checkbox is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the checkbox received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the checkbox loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentDidLoad() {\n if (this.input && this.indeterminate) {\n this.input.indeterminate = true;\n }\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.error('[A11y] Missing ARIA label on checkbox', this);\n }\n }\n\n /**\n * Sets focus on the checkbox. Use this method instead of `checkbox.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async setFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n render() {\n return (\n <Host>\n <label htmlFor={this.id} class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled }}>\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n type=\"checkbox\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n required={this.required}\n disabled={this.disabled}\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n />\n <span class=\"box\" aria-hidden=\"true\" part=\"checkbox\">\n <svg class=\"check\" viewBox=\"0 0 12 10\">\n <polyline points=\"1.5 6 4.5 9 10.5 1\"></polyline>\n </svg>\n <svg class=\"dash\" viewBox=\"0 0 12 10\">\n <polyline points=\"1.5 5 10.5 5\"></polyline>\n </svg>\n </span>\n <span class=\"label\" part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n </span>\n </label>\n {this.hintSection}\n </Host>\n );\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onInput(event: Event) {\n this.value = this.input.value;\n this.catChange.emit(event);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"],"version":3}
@@ -0,0 +1,20 @@
1
+ import { h } from '@stencil/core/internal/client';
2
+
3
+ /**
4
+ * CatFormHint is a functional component that represents the hint area of form elements.
5
+ *
6
+ * @param props - {@link CatFormHintProps}
7
+ * @return a JSX.Element
8
+ */
9
+ const CatFormHint = props => {
10
+ const { hint, slottedHint } = props;
11
+ return (h("div", { class: "hint-section" }, [
12
+ hint &&
13
+ (Array.isArray(hint) ? hint.map(item => h("p", { class: "input-hint" }, item)) : h("p", { class: "input-hint" }, hint)),
14
+ slottedHint
15
+ ]));
16
+ };
17
+
18
+ export { CatFormHint as C };
19
+
20
+ //# sourceMappingURL=cat-form-hint.js.map
@@ -0,0 +1 @@
1
+ {"file":"cat-form-hint.js","mappings":";;AAaA;;;;;;MAMa,WAAW,GAA0C,KAAK;EACrE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;EACpC,QACE,WAAK,KAAK,EAAC,cAAc,IACtB;IACC,IAAI;OACD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,SAAG,KAAK,EAAC,YAAY,IAAE,IAAI,CAAK,CAAC,GAAG,SAAG,KAAK,EAAC,YAAY,IAAE,IAAI,CAAK,CAAC;IAC/G,WAAW;GACZ,CACG,EACN;AACJ;;;;","names":[],"sources":["./src/components/cat-form-hint/cat-form-hint.tsx"],"sourcesContent":["import { h, FunctionalComponent } from '@stencil/core';\n\n/**\n * Properties of CatFormHint.\n *\n * @property hint - Optional hint text(s) of the form field.\n * @property slottedHint - Optional hint element of the form field.\n */\ninterface CatFormHintProps {\n hint?: string | string[];\n slottedHint?: HTMLSlotElement;\n}\n\n/**\n * CatFormHint is a functional component that represents the hint area of form elements.\n *\n * @param props - {@link CatFormHintProps}\n * @return a JSX.Element\n */\nexport const CatFormHint: FunctionalComponent<CatFormHintProps> = props => {\n const { hint, slottedHint } = props;\n return (\n <div class=\"hint-section\">\n {[\n hint &&\n (Array.isArray(hint) ? hint.map(item => <p class=\"input-hint\">{item}</p>) : <p class=\"input-hint\">{hint}</p>),\n slottedHint\n ]}\n </div>\n );\n};\n"],"version":3}
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
2
  import { C as CatIconRegistry } from './cat-icon-registry.js';
3
3
 
4
- const catIconCss = ":host{display:inline-flex;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host([hidden]){display:none}span{display:inline-flex}svg{fill:currentColor;stroke:none;transform-origin:center center;width:1em;height:1em}.icon-xs svg{font-size:0.75rem}.icon-s svg{font-size:1rem}.icon-m svg{font-size:1.25rem}.icon-l svg{font-size:1.5rem}.icon-xl svg{font-size:1.75rem}";
4
+ const catIconCss = ":host{display:inline-flex;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host([hidden]){display:none}span{display:inline-flex}svg{fill:currentColor;stroke:none;transform-origin:center center;height:1em;width:calc(var(--cat-icon-ratio, 1) * 1em)}.icon-xs svg{font-size:0.75rem}.icon-s svg{font-size:1rem}.icon-m svg{font-size:1.25rem}.icon-l svg{font-size:1.5rem}.icon-xl svg{font-size:1.75rem}";
5
5
 
6
6
  const CatIcon = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
7
  constructor() {
@@ -1 +1 @@
1
- {"file":"cat-icon2.js","mappings":";;;AAAA,MAAM,UAAU,GAAG,kZAAkZ;;MCcxZ,OAAO;EALpB;;;;IAMmB,iBAAY,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;;;;IAKtD,SAAI,GAAG,EAAE,CAAC;;;;IAKV,SAAI,GAA6C,GAAG,CAAC;GAsB9D;EAdC,MAAM;IACJ,QACE,YACE,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,gBACnC,IAAI,CAAC,SAAS,iBACb,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,MAAM,EAC3C,IAAI,EAAC,MAAM,EACX,KAAK,EAAE;QACL,IAAI,EAAE,IAAI;QACV,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ;OAC9C,GACK,EACR;GACH;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/cat-icon/cat-icon.scss?tag=cat-icon&encapsulation=shadow","./src/components/cat-icon/cat-icon.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n\n:host {\n display: inline-flex;\n vertical-align: middle;\n @include cat-select(none);\n}\n\n:host([hidden]) {\n display: none;\n}\n\nspan {\n display: inline-flex;\n}\n\nsvg {\n fill: currentColor;\n stroke: none;\n transform-origin: center center;\n width: 1em;\n height: 1em;\n}\n\n// ----- size\n\n@mixin size($size) {\n .icon-#{$size} svg {\n font-size: cat-size($size) * 0.5;\n }\n}\n\n@include size('xs');\n@include size('s');\n@include size('m');\n@include size('l');\n@include size('xl');\n","import { Component, h, Prop } from '@stencil/core';\nimport { CatIconRegistry } from './cat-icon-registry';\n\n/**\n * Icons are used to provide additional meaning or in places where text label\n * doesn't fit.\n *\n * @part icon - The span element wrapping the SVG icon.\n */\n@Component({\n tag: 'cat-icon',\n styleUrl: 'cat-icon.scss',\n shadow: true\n})\nexport class CatIcon {\n private readonly iconRegistry = CatIconRegistry.getInstance();\n\n /**\n * The name of the icon.\n */\n @Prop() icon = '';\n\n /**\n * The size of the icon.\n */\n @Prop() size: 'xs' | 's' | 'm' | 'l' | 'xl' | 'inline' = 'm';\n\n /**\n * Adds accessible label for the icon that is only shown for screen\n * readers. The `aria-hidden` attribute will be set if no label is present.\n */\n @Prop({ attribute: 'a11y-label' }) a11yLabel?: string;\n\n render() {\n return (\n <span\n innerHTML={this.iconRegistry.getIcon(this.icon)}\n aria-label={this.a11yLabel}\n aria-hidden={this.a11yLabel ? null : 'true'}\n part=\"icon\"\n class={{\n icon: true,\n [`icon-${this.size}`]: this.size !== 'inline'\n }}\n ></span>\n );\n }\n}\n"],"version":3}
1
+ {"file":"cat-icon2.js","mappings":";;;AAAA,MAAM,UAAU,GAAG,mbAAmb;;MCczb,OAAO;EALpB;;;;IAMmB,iBAAY,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;;;;IAKtD,SAAI,GAAG,EAAE,CAAC;;;;IAKV,SAAI,GAA6C,GAAG,CAAC;GAsB9D;EAdC,MAAM;IACJ,QACE,YACE,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,gBACnC,IAAI,CAAC,SAAS,iBACb,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,MAAM,EAC3C,IAAI,EAAC,MAAM,EACX,KAAK,EAAE;QACL,IAAI,EAAE,IAAI;QACV,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ;OAC9C,GACK,EACR;GACH;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/cat-icon/cat-icon.scss?tag=cat-icon&encapsulation=shadow","./src/components/cat-icon/cat-icon.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n\n:host {\n /**\n * @prop --cat-icon-ratio: The aspect ratio of the avatar.\n */\n display: inline-flex;\n vertical-align: middle;\n @include cat-select(none);\n}\n\n:host([hidden]) {\n display: none;\n}\n\nspan {\n display: inline-flex;\n}\n\nsvg {\n fill: currentColor;\n stroke: none;\n transform-origin: center center;\n height: 1em;\n width: calc(var(--cat-icon-ratio, 1) * 1em);\n}\n\n// ----- size\n\n@mixin size($size) {\n .icon-#{$size} svg {\n font-size: cat-size($size) * 0.5;\n }\n}\n\n@include size('xs');\n@include size('s');\n@include size('m');\n@include size('l');\n@include size('xl');\n","import { Component, h, Prop } from '@stencil/core';\nimport { CatIconRegistry } from './cat-icon-registry';\n\n/**\n * Icons are used to provide additional meaning or in places where text label\n * doesn't fit.\n *\n * @part icon - The span element wrapping the SVG icon.\n */\n@Component({\n tag: 'cat-icon',\n styleUrl: 'cat-icon.scss',\n shadow: true\n})\nexport class CatIcon {\n private readonly iconRegistry = CatIconRegistry.getInstance();\n\n /**\n * The name of the icon.\n */\n @Prop() icon = '';\n\n /**\n * The size of the icon.\n */\n @Prop() size: 'xs' | 's' | 'm' | 'l' | 'xl' | 'inline' = 'm';\n\n /**\n * Adds accessible label for the icon that is only shown for screen\n * readers. The `aria-hidden` attribute will be set if no label is present.\n */\n @Prop({ attribute: 'a11y-label' }) a11yLabel?: string;\n\n render() {\n return (\n <span\n innerHTML={this.iconRegistry.getIcon(this.icon)}\n aria-label={this.a11yLabel}\n aria-hidden={this.a11yLabel ? null : 'true'}\n part=\"icon\"\n class={{\n icon: true,\n [`icon-${this.size}`]: this.size !== 'inline'\n }}\n ></span>\n );\n }\n}\n"],"version":3}
@@ -1,11 +1,12 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
2
  import { l as loglevel } from './loglevel.js';
3
+ import { C as CatFormHint } from './cat-form-hint.js';
3
4
  import { C as CatI18nRegistry } from './cat-i18n-registry.js';
4
5
  import { d as defineCustomElement$4 } from './cat-button2.js';
5
6
  import { d as defineCustomElement$3 } from './cat-icon2.js';
6
7
  import { d as defineCustomElement$2 } from './cat-spinner2.js';
7
8
 
8
- const catInputCss = ":host{display:flex;flex-direction:column;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;margin-bottom:1rem}:host([hidden]){display:none}.input-wrapper{display:flex;align-items:stretch;gap:0.75rem;padding:0 0.75rem;height:2.5rem;overflow:hidden;background:white;border-radius:0.25rem;box-shadow:0 0 0 1px #d7dbe0;transition:box-shadow 0.13s linear}.input-wrapper.input-round{border-radius:10rem}.input-wrapper.input-disabled{background:#f8f8fb;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.input-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px #d7dbe0}.input-wrapper:not(.input-disabled):focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}label{align-self:flex-start}label.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.text-prefix,.text-suffix{display:inline-flex;align-items:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;}.text-prefix{border-right:1px solid #d7dbe0;padding-right:0.75rem}.text-suffix{border-left:1px solid #d7dbe0;padding-left:0.75rem}.icon-prefix,.icon-suffix{align-self:center}.input-inner-wrapper{display:flex;position:relative;flex:1 1 auto}input{font:inherit;margin:0;padding:0;width:100%;min-width:0;border:none;outline:none;background:none}.input-disabled input{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}input.has-clearable{padding-right:1.5rem}input::placeholder{color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.clearable{position:absolute;top:calc(50% - 1rem);right:-0.5rem}.input-hint{font-size:0.875rem;line-height:1rem;margin:0}";
9
+ const catInputCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;margin:0}:host{display:flex;flex-direction:column;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;margin-bottom:1rem}:host([hidden]){display:none}.input-wrapper{display:flex;align-items:stretch;gap:0.75rem;padding:0 0.75rem;height:2.5rem;overflow:hidden;background:white;border-radius:0.25rem;box-shadow:0 0 0 1px #d7dbe0;transition:box-shadow 0.13s linear}.input-wrapper.input-round{border-radius:10rem}.input-wrapper.input-disabled{background:#f8f8fb;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.input-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px #d7dbe0}.input-wrapper:not(.input-disabled):focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}label{align-self:flex-start}label.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.text-prefix,.text-suffix{display:inline-flex;align-items:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;}.text-prefix{border-right:1px solid #d7dbe0;padding-right:0.75rem}.text-suffix{border-left:1px solid #d7dbe0;padding-left:0.75rem}.icon-prefix,.icon-suffix{align-self:center}.input-inner-wrapper{display:flex;position:relative;flex:1 1 auto}input{font:inherit;margin:0;padding:0;width:100%;min-width:0;border:none;outline:none;background:none}.input-disabled input{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}input.has-clearable{padding-right:1.5rem}input::placeholder{color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.clearable{position:absolute;top:calc(50% - 1rem);right:-0.5rem}";
9
10
 
10
11
  let nextUniqueId = 0;
11
12
  const CatInput$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
@@ -18,7 +19,7 @@ const CatInput$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
18
19
  this.catBlur = createEvent(this, "catBlur", 7);
19
20
  this.i18n = CatI18nRegistry.getInstance();
20
21
  this.id = `cat-input-${nextUniqueId++}`;
21
- this.inputValue = '';
22
+ this.hasSlottedLabel = false;
22
23
  /**
23
24
  * Whether the input should show a clear button.
24
25
  */
@@ -60,14 +61,9 @@ const CatInput$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
60
61
  */
61
62
  this.type = 'text';
62
63
  }
63
- onValueChange(value) {
64
- this.inputValue = '' + (value !== null && value !== void 0 ? value : '');
65
- }
66
- componentWillLoad() {
67
- this.onValueChange(this.value);
68
- }
69
64
  componentWillRender() {
70
- if (!this.label) {
65
+ this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
66
+ if (!this.label && !this.hasSlottedLabel) {
71
67
  loglevel.error('[A11y] Missing ARIA label on input', this);
72
68
  }
73
69
  }
@@ -84,19 +80,23 @@ const CatInput$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
84
80
  * Clear the input.
85
81
  */
86
82
  async clear() {
87
- this.inputValue = '';
83
+ this.value = '';
88
84
  }
89
85
  render() {
90
- return (h(Host, null, this.label && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } }, h("span", { part: "label" }, this.label, !this.required && (h("span", { class: "input-optional", "aria-hidden": "true" }, "(", this.i18n.getMessage('input.optional'), ")"))))), h("div", { class: {
86
+ return (h(Host, null, (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } }, h("span", { part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label, !this.required && (h("span", { class: "input-optional", "aria-hidden": "true" }, "(", this.i18n.getMessage('input.optional'), ")"))))), h("div", { class: {
91
87
  'input-wrapper': true,
92
88
  'input-round': this.round,
93
89
  'input-disabled': this.disabled
94
90
  }, 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", { ref: el => (this.input = el), id: this.id, class: {
95
91
  'has-clearable': this.clearable && !this.disabled
96
- }, 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) }), 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) }))), this.icon && this.iconRight && h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l" }), this.textSuffix && (h("span", { class: "text-suffix", part: "suffix" }, this.textSuffix))), this.hint && h("p", { class: "input-hint" }, this.hint)));
92
+ }, 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) }), 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) }))), this.icon && this.iconRight && h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l" }), this.textSuffix && (h("span", { class: "text-suffix", part: "suffix" }, this.textSuffix))), this.hintSection));
93
+ }
94
+ get hintSection() {
95
+ const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
96
+ return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
97
97
  }
98
98
  onInput(event) {
99
- this.inputValue = this.input.value;
99
+ this.value = this.input.value;
100
100
  this.catChange.emit(event);
101
101
  }
102
102
  onFocus(event) {
@@ -105,9 +105,7 @@ const CatInput$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
105
105
  onBlur(event) {
106
106
  this.catBlur.emit(event);
107
107
  }
108
- static get watchers() { return {
109
- "value": ["onValueChange"]
110
- }; }
108
+ get hostElement() { return this; }
111
109
  static get style() { return catInputCss; }
112
110
  }, [1, "cat-input", {
113
111
  "autoComplete": [1, "auto-complete"],
@@ -130,8 +128,8 @@ const CatInput$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
130
128
  "required": [4],
131
129
  "round": [4],
132
130
  "type": [1],
133
- "value": [8],
134
- "inputValue": [32],
131
+ "value": [1032],
132
+ "hasSlottedLabel": [32],
135
133
  "setFocus": [64],
136
134
  "clear": [64]
137
135
  }]);
@@ -1 +1 @@
1
- {"file":"cat-input.js","mappings":";;;;;;;AAAA,MAAM,WAAW,GAAG,62DAA62D;;ACIj4D,IAAI,YAAY,GAAG,CAAC,CAAC;MAgBRA,UAAQ;EALrB;;;;;;;IAMmB,SAAI,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IACrC,OAAE,GAAG,aAAa,YAAY,EAAE,EAAE,CAAC;IAGnC,eAAU,GAAG,EAAE,CAAC;;;;IAUzB,cAAS,GAAG,KAAK,CAAC;;;;IAKlB,aAAQ,GAAG,KAAK,CAAC;;;;IAejB,cAAS,GAAG,KAAK,CAAC;;;;IAKlB,UAAK,GAAG,EAAE,CAAC;;;;IAKX,gBAAW,GAAG,KAAK,CAAC;;;;IAyBpB,SAAI,GAAG,EAAE,CAAC;;;;IAoBV,aAAQ,GAAG,KAAK,CAAC;;;;IAKjB,aAAQ,GAAG,KAAK,CAAC;;;;IAKjB,UAAK,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AAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAC/C,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAClB,CACf,CACG,EACL,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,IAAI,gBAAU,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAC,aAAa,EAAC,IAAI,EAAC,GAAG,GAAY,EAClG,IAAI,CAAC,UAAU,KACd,YAAM,KAAK,EAAC,aAAa,EAAC,IAAI,EAAC,QAAQ,IACpC,IAAI,CAAC,UAAU,CACX,CACR,CACG,EACL,IAAI,CAAC,IAAI,IAAI,SAAG,KAAK,EAAC,YAAY,IAAE,IAAI,CAAC,IAAI,CAAK,CAC9C,EACP;GACH;EAEO,OAAO,CAAC,KAAY;IAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IACnC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;GAC5B;EAEO,OAAO,CAAC,KAAiB;IAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;GAC3B;EAEO,MAAM,CAAC,KAAiB;IAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;GAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CatInput","log"],"sources":["./src/components/cat-input/cat-input.scss?tag=cat-input&encapsulation=shadow","./src/components/cat-input/cat-input.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n\n:host {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n @include cat-body('m');\n margin-bottom: $cat-body-margin-bottom;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.input-wrapper {\n display: flex;\n align-items: stretch;\n gap: 0.75rem;\n padding: 0 0.75rem;\n height: cat-size('m');\n overflow: hidden;\n background: cat-token('color.ui.background.input');\n border-radius: cat-border-radius('m');\n box-shadow: 0 0 0 1px cat-token('color.ui.border.input');\n transition: box-shadow cat-token('time.transition.s') linear;\n\n &.input-round {\n border-radius: 10rem;\n }\n\n &.input-disabled {\n background: cat-token('color.ui.background.inputDisabled');\n cursor: not-allowed;\n color: cat-token('color.ui.font.muted');\n }\n\n &:not(.input-disabled) {\n &:hover {\n box-shadow: 0 0 0 2px cat-token('color.ui.border.input');\n }\n\n &:focus-within {\n outline: 2px solid cat-token('color.ui.border.focus');\n }\n }\n}\n\nlabel {\n align-self: flex-start;\n\n &.hidden {\n @include cat-visually-hidden;\n }\n}\n\n.input-optional {\n margin-left: 0.25rem;\n @include cat-body('xs');\n color: cat-token('color.ui.font.muted');\n}\n\n.text-prefix,\n.text-suffix {\n display: inline-flex;\n align-items: center;\n @include cat-select(none);\n}\n\n.text-prefix {\n border-right: 1px solid cat-token('color.ui.border.input');\n padding-right: 0.75rem;\n}\n\n.text-suffix {\n border-left: 1px solid cat-token('color.ui.border.input');\n padding-left: 0.75rem;\n}\n\n.icon-prefix,\n.icon-suffix {\n align-self: center;\n}\n\n.input-inner-wrapper {\n display: flex;\n position: relative;\n flex: 1 1 auto;\n}\n\ninput {\n font: inherit;\n margin: 0;\n padding: 0;\n width: 100%;\n min-width: 0;\n border: none;\n outline: none;\n background: none;\n\n .input-disabled & {\n cursor: not-allowed;\n color: cat-token('color.ui.font.muted');\n }\n\n &.has-clearable {\n padding-right: calc(cat-size('s') - 0.5rem);\n }\n\n &::placeholder {\n color: cat-token('color.ui.font.muted');\n }\n}\n\n.clearable {\n position: absolute;\n top: calc(50% - cat-size('s') / 2);\n right: -0.5rem;\n}\n\n.input-hint {\n @include cat-body('s');\n margin: 0;\n}\n","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"],"version":3}
1
+ {"file":"cat-input.js","mappings":";;;;;;;;AAAA,MAAM,WAAW,GAAG,49DAA49D;;ACKh/D,IAAI,YAAY,GAAG,CAAC,CAAC;MAkBRA,UAAQ;EALrB;;;;;;;IAMmB,SAAI,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IACrC,OAAE,GAAG,aAAa,YAAY,EAAE,EAAE,CAAC;IAK3C,oBAAe,GAAG,KAAK,CAAC;;;;IAUzB,cAAS,GAAG,KAAK,CAAC;;;;IAKlB,aAAQ,GAAG,KAAK,CAAC;;;;IAejB,cAAS,GAAG,KAAK,CAAC;;;;IAKlB,UAAK,GAAG,EAAE,CAAC;;;;IAKX,gBAAW,GAAG,KAAK,CAAC;;;;IAyBpB,SAAI,GAAG,EAAE,CAAC;;;;IAoBV,aAAQ,GAAG,KAAK,CAAC;;;;IAKjB,aAAQ,GAAG,KAAK,CAAC;;;;IAKjB,UAAK,GAAG,KAAK,CAAC;;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at-input.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n@use 'src/components/cat-form-hint/cat-form-hint';\n\n:host {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n @include cat-body('m');\n margin-bottom: $cat-body-margin-bottom;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.input-wrapper {\n display: flex;\n align-items: stretch;\n gap: 0.75rem;\n padding: 0 0.75rem;\n height: cat-size('m');\n overflow: hidden;\n background: cat-token('color.ui.background.input');\n border-radius: cat-border-radius('m');\n box-shadow: 0 0 0 1px cat-token('color.ui.border.input');\n transition: box-shadow cat-token('time.transition.s') linear;\n\n &.input-round {\n border-radius: 10rem;\n }\n\n &.input-disabled {\n background: cat-token('color.ui.background.inputDisabled');\n cursor: not-allowed;\n color: cat-token('color.ui.font.muted');\n }\n\n &:not(.input-disabled) {\n &:hover {\n box-shadow: 0 0 0 2px cat-token('color.ui.border.input');\n }\n\n &:focus-within {\n outline: 2px solid cat-token('color.ui.border.focus');\n }\n }\n}\n\nlabel {\n align-self: flex-start;\n\n &.hidden {\n @include cat-visually-hidden;\n }\n}\n\n.input-optional {\n margin-left: 0.25rem;\n @include cat-body('xs');\n color: cat-token('color.ui.font.muted');\n}\n\n.text-prefix,\n.text-suffix {\n display: inline-flex;\n align-items: center;\n @include cat-select(none);\n}\n\n.text-prefix {\n border-right: 1px solid cat-token('color.ui.border.input');\n padding-right: 0.75rem;\n}\n\n.text-suffix {\n border-left: 1px solid cat-token('color.ui.border.input');\n padding-left: 0.75rem;\n}\n\n.icon-prefix,\n.icon-suffix {\n align-self: center;\n}\n\n.input-inner-wrapper {\n display: flex;\n position: relative;\n flex: 1 1 auto;\n}\n\ninput {\n font: inherit;\n margin: 0;\n padding: 0;\n width: 100%;\n min-width: 0;\n border: none;\n outline: none;\n background: none;\n\n .input-disabled & {\n cursor: not-allowed;\n color: cat-token('color.ui.font.muted');\n }\n\n &.has-clearable {\n padding-right: calc(cat-size('s') - 0.5rem);\n }\n\n &::placeholder {\n color: cat-token('color.ui.font.muted');\n }\n}\n\n.clearable {\n position: absolute;\n top: calc(50% - cat-size('s') / 2);\n right: -0.5rem;\n}\n","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"],"version":3}