@sats-group/ui-lib 74.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/README.md +35 -0
- package/catalog-info.yaml +14 -0
- package/eslint.config.mjs +94 -0
- package/fonts/Inter-BoldItalic.woff +0 -0
- package/fonts/Inter-BoldItalic.woff2 +0 -0
- package/fonts/Inter-ExtraBold.woff +0 -0
- package/fonts/Inter-ExtraBold.woff2 +0 -0
- package/fonts/Inter-Italic.woff +0 -0
- package/fonts/Inter-Italic.woff2 +0 -0
- package/fonts/Inter-Regular.woff +0 -0
- package/fonts/Inter-Regular.woff2 +0 -0
- package/fonts/Inter-SemiBold.woff +0 -0
- package/fonts/Inter-SemiBold.woff2 +0 -0
- package/fonts/LICENSE.txt +92 -0
- package/fonts/SATSHeadline-Bold.woff +0 -0
- package/fonts/SATSHeadline-BoldItalic.woff +0 -0
- package/fonts/SATSHeadline-RegularItalic.woff +0 -0
- package/fonts/SATSHeadline-SemiBoldItalic.woff +0 -0
- package/logos/e-avatar.svg +3 -0
- package/logos/elixia-letter.svg +3 -0
- package/logos/elixia-small.svg +8 -0
- package/logos/elixia.svg +8 -0
- package/logos/s-avatar.svg +3 -0
- package/logos/sats-letter.svg +3 -0
- package/logos/sats-small.svg +3 -0
- package/logos/sats.svg +4 -0
- package/package.json +58 -0
- package/react/add-bem-modifiers.ts +51 -0
- package/react/badge/badge.scss +53 -0
- package/react/badge/badge.tsx +28 -0
- package/react/badge/badge.types.ts +34 -0
- package/react/badge/index.ts +2 -0
- package/react/banner/banner.scss +118 -0
- package/react/banner/banner.tsx +92 -0
- package/react/banner/banner.types.ts +10 -0
- package/react/banner/index.ts +2 -0
- package/react/bomb/bomb.scss +33 -0
- package/react/bomb/bomb.tsx +19 -0
- package/react/bomb/bomb.types.ts +1 -0
- package/react/bomb/index.ts +2 -0
- package/react/button/button.tsx +19 -0
- package/react/button/button.types.ts +3 -0
- package/react/button/index.ts +2 -0
- package/react/checkbox/checkbox.scss +218 -0
- package/react/checkbox/checkbox.tsx +176 -0
- package/react/checkbox/checkbox.types.ts +19 -0
- package/react/checkbox/index.ts +2 -0
- package/react/chip/chip.scss +46 -0
- package/react/chip/chip.tsx +37 -0
- package/react/chip/chip.types.ts +18 -0
- package/react/chip/index.ts +2 -0
- package/react/chip/remove.tsx +14 -0
- package/react/chip-selected/chip-selected.scss +47 -0
- package/react/chip-selected/chip-selected.tsx +102 -0
- package/react/chip-selected/chip-selected.types.ts +11 -0
- package/react/chip-selected/index.ts +2 -0
- package/react/confirmation/confirmation.scss +60 -0
- package/react/confirmation/confirmation.tsx +85 -0
- package/react/confirmation/confirmation.types.ts +24 -0
- package/react/confirmation/index.ts +2 -0
- package/react/context-menu/context-menu.scss +183 -0
- package/react/context-menu/context-menu.tsx +200 -0
- package/react/context-menu/context-menu.types.ts +71 -0
- package/react/context-menu/index.ts +2 -0
- package/react/cropped-image/cropped-image.scss +48 -0
- package/react/cropped-image/cropped-image.tsx +36 -0
- package/react/cropped-image/cropped-image.types.ts +26 -0
- package/react/cropped-image/index.ts +2 -0
- package/react/dropdown-list/dropdown-list.scss +170 -0
- package/react/dropdown-list/dropdown-list.tsx +116 -0
- package/react/dropdown-list/dropdown-list.types.ts +17 -0
- package/react/dropdown-list/index.ts +2 -0
- package/react/expander/expander.scss +115 -0
- package/react/expander/expander.tsx +167 -0
- package/react/expander/expander.types.ts +26 -0
- package/react/expander/index.ts +2 -0
- package/react/filter/filter.scss +94 -0
- package/react/filter/filter.tsx +99 -0
- package/react/filter/filter.types.ts +8 -0
- package/react/filter/index.ts +2 -0
- package/react/filter-wrapper/filter-wrapper.scss +46 -0
- package/react/filter-wrapper/filter-wrapper.tsx +24 -0
- package/react/filter-wrapper/filter-wrapper.types.ts +10 -0
- package/react/filter-wrapper/index.ts +2 -0
- package/react/flag/flag.scss +26 -0
- package/react/flag/flag.tsx +27 -0
- package/react/flag/flag.types.ts +17 -0
- package/react/flag/index.ts +2 -0
- package/react/form-content/checkbox-category.tsx +183 -0
- package/react/form-content/form-content.checkbox-list.tsx +126 -0
- package/react/form-content/form-content.checkbox-list.types.ts +36 -0
- package/react/form-content/form-content.radio-list.tsx +58 -0
- package/react/form-content/form-content.range.tsx +20 -0
- package/react/form-content/form-content.range.types.ts +14 -0
- package/react/form-content/form-content.scss +234 -0
- package/react/form-content/form-content.search.tsx +47 -0
- package/react/form-content/form-content.tsx +95 -0
- package/react/form-content/form-content.types.ts +55 -0
- package/react/form-content/index.ts +2 -0
- package/react/form-content/types/index.d.ts +1 -0
- package/react/hidden-input/hidden-input.tsx +9 -0
- package/react/hidden-input/hidden-input.types.ts +6 -0
- package/react/hidden-input/index.ts +2 -0
- package/react/hooks/focus-previous-element.ts +30 -0
- package/react/hooks/is-running-on-client.ts +1 -0
- package/react/hooks/use-click-outside.ts +23 -0
- package/react/hooks/use-escape.ts +18 -0
- package/react/hooks/use-event.ts +29 -0
- package/react/hooks/use-is-mounted.ts +11 -0
- package/react/hooks/use-toggle.ts +19 -0
- package/react/icons/16/close.tsx +12 -0
- package/react/icons/18/close.tsx +18 -0
- package/react/icons/24/arrow-down.tsx +14 -0
- package/react/icons/24/arrow-right.tsx +14 -0
- package/react/icons/24/arrow-up.tsx +14 -0
- package/react/icons/24/close.tsx +12 -0
- package/react/icons/24/remove.tsx +12 -0
- package/react/icons/24/search.tsx +10 -0
- package/react/icons/icons.md +3 -0
- package/react/indexed-access-type.ts +1 -0
- package/react/link/index.ts +2 -0
- package/react/link/link.scss +44 -0
- package/react/link/link.tsx +62 -0
- package/react/link/link.types.ts +37 -0
- package/react/link-button/index.ts +2 -0
- package/react/link-button/link-button.tsx +17 -0
- package/react/link-button/link-button.types.ts +5 -0
- package/react/link-card/index.ts +2 -0
- package/react/link-card/link-card.scss +37 -0
- package/react/link-card/link-card.tsx +24 -0
- package/react/link-card/link-card.types.ts +5 -0
- package/react/logos/e-avatar.tsx +12 -0
- package/react/logos/elixia-letter.tsx +12 -0
- package/react/logos/elixia-small.tsx +12 -0
- package/react/logos/elixia.tsx +12 -0
- package/react/logos/index.ts +8 -0
- package/react/logos/s-avatar.tsx +12 -0
- package/react/logos/sats-letter.tsx +12 -0
- package/react/logos/sats-small.tsx +12 -0
- package/react/logos/sats.tsx +12 -0
- package/react/message/hook/use-message.ts +22 -0
- package/react/message/index.ts +2 -0
- package/react/message/message.scss +92 -0
- package/react/message/message.tsx +60 -0
- package/react/message/message.types.ts +39 -0
- package/react/message/publish.ts +19 -0
- package/react/message-field/index.ts +2 -0
- package/react/message-field/message-field.scss +21 -0
- package/react/message-field/message-field.tsx +70 -0
- package/react/message-field/message-field.types.ts +24 -0
- package/react/modal/index.ts +2 -0
- package/react/modal/modal.scss +162 -0
- package/react/modal/modal.tsx +130 -0
- package/react/modal/modal.types.ts +36 -0
- package/react/modal/tab-trapper.tsx +68 -0
- package/react/progress-bar/index.ts +2 -0
- package/react/progress-bar/progress-bar.scss +71 -0
- package/react/progress-bar/progress-bar.tsx +81 -0
- package/react/progress-bar/progress-bar.types.ts +35 -0
- package/react/radio/index.ts +2 -0
- package/react/radio/radio.scss +142 -0
- package/react/radio/radio.tsx +87 -0
- package/react/radio/radio.types.ts +15 -0
- package/react/scale-bar/index.ts +2 -0
- package/react/scale-bar/scale-bar.scss +22 -0
- package/react/scale-bar/scale-bar.tsx +29 -0
- package/react/scale-bar/scale-bar.types.ts +4 -0
- package/react/search/index.ts +2 -0
- package/react/search/search.scss +207 -0
- package/react/search/search.tsx +255 -0
- package/react/search/search.types.ts +43 -0
- package/react/select/chevron-down.tsx +24 -0
- package/react/select/index.ts +2 -0
- package/react/select/select.scss +135 -0
- package/react/select/select.tsx +105 -0
- package/react/select/select.types.ts +19 -0
- package/react/select-option/README.md +3 -0
- package/react/select-option/index.ts +2 -0
- package/react/select-option/select-option.tsx +16 -0
- package/react/select-option/select-option.types.ts +8 -0
- package/react/tag/index.ts +2 -0
- package/react/tag/tag.scss +107 -0
- package/react/tag/tag.tsx +26 -0
- package/react/tag/tag.types.ts +30 -0
- package/react/text/index.ts +2 -0
- package/react/text/text.scss +109 -0
- package/react/text/text.tsx +40 -0
- package/react/text/text.types.ts +29 -0
- package/react/text-area/index.ts +2 -0
- package/react/text-area/text-area.scss +180 -0
- package/react/text-area/text-area.tsx +153 -0
- package/react/text-area/text-area.types.ts +24 -0
- package/react/text-input/index.ts +2 -0
- package/react/text-input/text-input.scss +233 -0
- package/react/text-input/text-input.tsx +106 -0
- package/react/text-input/text-input.types.ts +19 -0
- package/react/toggle/index.ts +2 -0
- package/react/toggle/toggle.scss +69 -0
- package/react/toggle/toggle.tsx +83 -0
- package/react/toggle/toggle.types.ts +11 -0
- package/react/toolbox/index.ts +2 -0
- package/react/toolbox/toolbox.scss +68 -0
- package/react/toolbox/toolbox.tsx +43 -0
- package/react/toolbox/toolbox.types.ts +39 -0
- package/react/ts/debounce.ts +12 -0
- package/react/types.ts +38 -0
- package/react/use-input-validation.ts +47 -0
- package/react/use-input-validation.types.ts +12 -0
- package/react/visually-button/index.ts +2 -0
- package/react/visually-button/visually-button.scss +470 -0
- package/react/visually-button/visually-button.tsx +130 -0
- package/react/visually-button/visually-button.types.ts +71 -0
- package/react/visually-hidden/index.ts +2 -0
- package/react/visually-hidden/visually-hidden.scss +6 -0
- package/react/visually-hidden/visually-hidden.tsx +10 -0
- package/tokens/corner-radius.scss +5 -0
- package/tokens/dark.scss +392 -0
- package/tokens/darkmode.scss +131 -0
- package/tokens/elevation.scss +57 -0
- package/tokens/font-faces.scss +62 -0
- package/tokens/font-names.scss +2 -0
- package/tokens/font-sizes.scss +95 -0
- package/tokens/light.scss +392 -0
- package/tokens/lightmode.scss +131 -0
- package/tokens/primitives.scss +137 -0
- package/tokens/spacing.scss +12 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
@use '../../tokens/corner-radius';
|
|
2
|
+
@use '../../tokens/font-sizes';
|
|
3
|
+
@use '../../tokens/light';
|
|
4
|
+
@use '../../tokens/spacing';
|
|
5
|
+
|
|
6
|
+
.text-input {
|
|
7
|
+
$block: &;
|
|
8
|
+
$vertical-padding: 13px;
|
|
9
|
+
$line-height: 1;
|
|
10
|
+
$icon-width: 24px;
|
|
11
|
+
$icon-spacing: spacing.$xs;
|
|
12
|
+
|
|
13
|
+
&__wrapper {
|
|
14
|
+
position: relative;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column-reverse;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&__input {
|
|
20
|
+
@include font-sizes.normal(basic);
|
|
21
|
+
border: 1px solid light.$ge-divider-default;
|
|
22
|
+
border-radius: corner-radius.$s;
|
|
23
|
+
padding: clamp(spacing.$xs, 2vw, spacing.$s) clamp(spacing.$s, 2vw, spacing.$m);
|
|
24
|
+
line-height: $line-height;
|
|
25
|
+
background-color: light.$surface-primary-default;
|
|
26
|
+
color: light.$on-surface-primary-default;
|
|
27
|
+
width: 100%;
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
|
|
30
|
+
#{$block}--icon & {
|
|
31
|
+
padding-left: $icon-spacing * 2 + $icon-width;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:focus {
|
|
35
|
+
border-color: light.$ge-border-focused;
|
|
36
|
+
outline: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&::placeholder {
|
|
40
|
+
color: light.$on-surface-primary-alternate;
|
|
41
|
+
opacity: 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&[disabled],
|
|
45
|
+
&[disabled]::placeholder {
|
|
46
|
+
color: light.$on-surface-primary-disabled;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&::-webkit-outer-spin-button,
|
|
50
|
+
&::-webkit-inner-spin-button {
|
|
51
|
+
appearance: none;
|
|
52
|
+
margin: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&[type='number'] {
|
|
56
|
+
appearance: none;
|
|
57
|
+
margin: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&[type='date'] {
|
|
61
|
+
appearance: none;
|
|
62
|
+
min-height: 46px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&[type='time'] {
|
|
66
|
+
appearance: none;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&__icon {
|
|
71
|
+
bottom: $vertical-padding;
|
|
72
|
+
color: light.$on-surface-primary-disabled;
|
|
73
|
+
left: $icon-spacing;
|
|
74
|
+
height: $icon-width;
|
|
75
|
+
pointer-events: none;
|
|
76
|
+
position: absolute;
|
|
77
|
+
width: $icon-width;
|
|
78
|
+
|
|
79
|
+
svg {
|
|
80
|
+
display: block;
|
|
81
|
+
height: 100%;
|
|
82
|
+
width: 100%;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&--moving-label {
|
|
87
|
+
#{$block}__input {
|
|
88
|
+
padding: $vertical-padding spacing.$m;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#{$block}__label {
|
|
92
|
+
position: absolute;
|
|
93
|
+
z-index: 1;
|
|
94
|
+
top: 0;
|
|
95
|
+
margin: 0;
|
|
96
|
+
padding: 0 6px;
|
|
97
|
+
transform: translate(10px, $vertical-padding);
|
|
98
|
+
transition: transform 0.1s cubic-bezier(0.22, 0.57, 0.25, 1);
|
|
99
|
+
transform-origin: left center;
|
|
100
|
+
max-width: calc(100% - 25px);
|
|
101
|
+
overflow: hidden;
|
|
102
|
+
text-overflow: ellipsis;
|
|
103
|
+
white-space: nowrap;
|
|
104
|
+
line-height: $line-height;
|
|
105
|
+
|
|
106
|
+
@media (prefers-reduced-motion) {
|
|
107
|
+
transition: transform 0s;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&::before {
|
|
111
|
+
content: '';
|
|
112
|
+
position: absolute;
|
|
113
|
+
z-index: -1;
|
|
114
|
+
left: 0;
|
|
115
|
+
bottom: 0;
|
|
116
|
+
height: 50%;
|
|
117
|
+
width: 100%;
|
|
118
|
+
background-color: light.$surface-primary-default;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&.text-input--moving-label {
|
|
123
|
+
&.text-input--theme-dark {
|
|
124
|
+
#{$block}__label {
|
|
125
|
+
color: light.$on-fixed-surface-primary-default;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#{$block}__label {
|
|
129
|
+
&::before {
|
|
130
|
+
content: '';
|
|
131
|
+
background-color: light.$fixed-surface-primary-default;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
& #{$block}__input:focus,
|
|
138
|
+
& #{$block}__input:not(:placeholder-shown) {
|
|
139
|
+
~ #{$block}__label {
|
|
140
|
+
transform: translate(10px, -50%) scale(0.8);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&__help {
|
|
146
|
+
margin-top: spacing.$xxs;
|
|
147
|
+
color: light.$on-background-primary-disabled;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&__error {
|
|
151
|
+
margin-top: spacing.$xxs;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&__asterisk {
|
|
155
|
+
color: light.$on-surface-featured;
|
|
156
|
+
margin-left: spacing.$xs;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
&--disabled {
|
|
160
|
+
#{$block}__label,
|
|
161
|
+
#{$block}__icon,
|
|
162
|
+
#{$block}__help {
|
|
163
|
+
color: light.$on-background-primary-disabled;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&--theme-dark {
|
|
168
|
+
#{$block}__icon {
|
|
169
|
+
color: light.$on-fixed-surface-primary-default;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
#{$block}__label {
|
|
173
|
+
color: light.$on-fixed-background-primary-default;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
#{$block}__help {
|
|
177
|
+
color: light.$on-fixed-background-primary-disabled;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#{$block}__input {
|
|
181
|
+
background-color: light.$fixed-surface-secondary-default;
|
|
182
|
+
border-color: light.$ge-border-default;
|
|
183
|
+
color: light.$on-fixed-surface-primary-alternate;
|
|
184
|
+
|
|
185
|
+
&:focus {
|
|
186
|
+
background-color: light.$fixed-surface-primary-default;
|
|
187
|
+
color: light.$on-fixed-surface-primary-default;
|
|
188
|
+
outline: none;
|
|
189
|
+
|
|
190
|
+
~ #{$block}__icon {
|
|
191
|
+
color: light.$on-fixed-surface-primary-default;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&::placeholder {
|
|
196
|
+
color: light.$on-fixed-surface-primary-alternate;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
&[disabled],
|
|
200
|
+
&[disabled]::placeholder {
|
|
201
|
+
color: light.$on-fixed-surface-primary-disabled;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
&#{$block}--disabled {
|
|
206
|
+
#{$block}__label,
|
|
207
|
+
#{$block}__icon,
|
|
208
|
+
#{$block}__help {
|
|
209
|
+
color: light.$on-fixed-background-primary-disabled;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
&#{$block}--error #{$block}__icon {
|
|
213
|
+
color: light.$on-fixed-surface-error;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&--error {
|
|
219
|
+
#{$block}__icon {
|
|
220
|
+
color: light.$on-surface-error;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
#{$block}__input {
|
|
224
|
+
outline: 2px solid light.$ge-signal-error;
|
|
225
|
+
outline-offset: -2px;
|
|
226
|
+
|
|
227
|
+
&:focus {
|
|
228
|
+
outline: 2px solid light.$ge-signal-error;
|
|
229
|
+
outline-offset: -2px;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import Text from '../text';
|
|
5
|
+
import useInputValidation from '../use-input-validation';
|
|
6
|
+
|
|
7
|
+
import { themes, TextInput as Props } from './text-input.types';
|
|
8
|
+
|
|
9
|
+
const RefTextInput = React.forwardRef<HTMLInputElement, Props>(
|
|
10
|
+
(
|
|
11
|
+
{
|
|
12
|
+
customErrorMessages,
|
|
13
|
+
defaultValue,
|
|
14
|
+
disabled,
|
|
15
|
+
hasError,
|
|
16
|
+
hasMovingLabel,
|
|
17
|
+
helpText,
|
|
18
|
+
hiddenLabel,
|
|
19
|
+
icon,
|
|
20
|
+
label,
|
|
21
|
+
name,
|
|
22
|
+
onChange = () => {},
|
|
23
|
+
placeholder,
|
|
24
|
+
required,
|
|
25
|
+
theme,
|
|
26
|
+
type = 'text',
|
|
27
|
+
...restProps
|
|
28
|
+
},
|
|
29
|
+
ref,
|
|
30
|
+
) => {
|
|
31
|
+
const [validationOnChange, onInvalid, error] =
|
|
32
|
+
useInputValidation(customErrorMessages);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<label
|
|
36
|
+
className={cn('text-input', {
|
|
37
|
+
'text-input--theme-dark': theme === themes.dark,
|
|
38
|
+
'text-input--theme-light': theme === themes.light,
|
|
39
|
+
'text-input--disabled': disabled,
|
|
40
|
+
'text-input--error': error || hasError,
|
|
41
|
+
'text-input--moving-label': icon ? false : hasMovingLabel,
|
|
42
|
+
'text-input--icon': icon,
|
|
43
|
+
})}
|
|
44
|
+
>
|
|
45
|
+
<div className="text-input__wrapper">
|
|
46
|
+
<input
|
|
47
|
+
{...restProps}
|
|
48
|
+
className="text-input__input"
|
|
49
|
+
defaultValue={defaultValue}
|
|
50
|
+
disabled={disabled}
|
|
51
|
+
required={required}
|
|
52
|
+
name={name}
|
|
53
|
+
onInvalid={e => onInvalid(e)}
|
|
54
|
+
onChange={e => {
|
|
55
|
+
onChange(e);
|
|
56
|
+
validationOnChange(e);
|
|
57
|
+
}}
|
|
58
|
+
// NOTE: Using " " as placeholder for moving label theme to enable using `:placeholder-shown` to determine when to move the label
|
|
59
|
+
placeholder={
|
|
60
|
+
icon ? placeholder : hasMovingLabel ? ' ' : placeholder
|
|
61
|
+
}
|
|
62
|
+
ref={ref}
|
|
63
|
+
type={type}
|
|
64
|
+
aria-label={icon || hiddenLabel ? label : undefined}
|
|
65
|
+
/>
|
|
66
|
+
|
|
67
|
+
{icon ? (
|
|
68
|
+
<div className="text-input__icon">{icon}</div>
|
|
69
|
+
) : hiddenLabel ? null : (
|
|
70
|
+
<Text
|
|
71
|
+
className="text-input__label"
|
|
72
|
+
theme={Text.themes.emphasis}
|
|
73
|
+
size={Text.sizes.small}
|
|
74
|
+
>
|
|
75
|
+
{label}
|
|
76
|
+
{required ? (
|
|
77
|
+
<span className="text-input__asterisk">*</span>
|
|
78
|
+
) : null}
|
|
79
|
+
</Text>
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
{helpText ? (
|
|
84
|
+
<div className="text-input__help">
|
|
85
|
+
<Text size={Text.sizes.interface}>{helpText}</Text>
|
|
86
|
+
</div>
|
|
87
|
+
) : null}
|
|
88
|
+
{/* NOTE: This is aria-hidden because reporting of validation errors is handled by the browser */}
|
|
89
|
+
{error ? (
|
|
90
|
+
<div aria-hidden="true" className="text-input__error">
|
|
91
|
+
<Text>{error}</Text>
|
|
92
|
+
</div>
|
|
93
|
+
) : null}
|
|
94
|
+
</label>
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// NOTE: If this isn't set, stack traces say "forwardRef" instead of "TextInput"
|
|
100
|
+
RefTextInput.displayName = 'TextInput';
|
|
101
|
+
|
|
102
|
+
const TextInput: typeof RefTextInput & {
|
|
103
|
+
themes: typeof themes;
|
|
104
|
+
} = Object.assign(RefTextInput, { themes });
|
|
105
|
+
|
|
106
|
+
export default TextInput;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InputHtmlProps, ObjectValues } from '../types';
|
|
2
|
+
import { Messages } from '../use-input-validation.types';
|
|
3
|
+
|
|
4
|
+
export const themes = {
|
|
5
|
+
dark: 'dark',
|
|
6
|
+
light: 'light',
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export type TextInput = {
|
|
10
|
+
theme?: ObjectValues<typeof themes>;
|
|
11
|
+
customErrorMessages?: Messages;
|
|
12
|
+
hasError?: boolean;
|
|
13
|
+
hasMovingLabel?: boolean;
|
|
14
|
+
helpText?: string;
|
|
15
|
+
hiddenLabel?: boolean;
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
label: string;
|
|
18
|
+
name: string;
|
|
19
|
+
} & InputHtmlProps;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
@use '../../tokens/light';
|
|
2
|
+
@use '../../tokens/spacing.scss';
|
|
3
|
+
|
|
4
|
+
.toggle {
|
|
5
|
+
$block: &;
|
|
6
|
+
$sizeWidth: 32px;
|
|
7
|
+
$sizeHeight: 20px;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
|
|
10
|
+
&__content {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
gap: spacing.$s;
|
|
15
|
+
|
|
16
|
+
&--space-between {
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&__button-wrap {
|
|
22
|
+
position: relative;
|
|
23
|
+
display: flex;
|
|
24
|
+
height: $sizeHeight;
|
|
25
|
+
width: $sizeWidth;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&__slider {
|
|
29
|
+
background: light.$ge-toggle-unselected-default;
|
|
30
|
+
border-radius: 40px;
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 50%;
|
|
33
|
+
right: 0;
|
|
34
|
+
height: 22px;
|
|
35
|
+
width: 39px;
|
|
36
|
+
transition: 0.4s;
|
|
37
|
+
transform: translateY(-50%);
|
|
38
|
+
padding: 2px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&__slider-element {
|
|
42
|
+
height: 18px;
|
|
43
|
+
width: 18px;
|
|
44
|
+
background: light.$ge-toggle-interactive-element;
|
|
45
|
+
filter: drop-shadow(0px 3px 1px rgba(0, 0, 0, 0.06))
|
|
46
|
+
drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.05))
|
|
47
|
+
drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.05));
|
|
48
|
+
transition: 0.4s;
|
|
49
|
+
border-radius: 100%;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&__input {
|
|
53
|
+
opacity: 0;
|
|
54
|
+
width: $sizeWidth;
|
|
55
|
+
height: $sizeHeight;
|
|
56
|
+
|
|
57
|
+
&:checked + #{$block}__slider {
|
|
58
|
+
background: light.$ge-toggle-selected-default;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:checked + #{$block}__slider #{$block}__slider-element {
|
|
62
|
+
transform: translateX(17px);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&:disabled + #{$block}__slider {
|
|
66
|
+
opacity: 0.4;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import useInputValidation from '../use-input-validation';
|
|
5
|
+
import { Toggle as Props } from './toggle.types';
|
|
6
|
+
|
|
7
|
+
const Toggle = React.forwardRef<
|
|
8
|
+
HTMLInputElement,
|
|
9
|
+
React.PropsWithChildren<Props>
|
|
10
|
+
>(
|
|
11
|
+
(
|
|
12
|
+
{
|
|
13
|
+
children,
|
|
14
|
+
isLabelVisible = true,
|
|
15
|
+
label,
|
|
16
|
+
labelPosition = 'right',
|
|
17
|
+
name,
|
|
18
|
+
value = '',
|
|
19
|
+
spaceBetween,
|
|
20
|
+
testId,
|
|
21
|
+
...rest
|
|
22
|
+
},
|
|
23
|
+
ref,
|
|
24
|
+
) => {
|
|
25
|
+
const [onChange, onInvalid, error] = useInputValidation();
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
className={cn('toggle', {
|
|
30
|
+
'toggle--error': error,
|
|
31
|
+
})}
|
|
32
|
+
>
|
|
33
|
+
<label
|
|
34
|
+
className={cn('toggle__content', {
|
|
35
|
+
'toggle__content--space-between': spaceBetween,
|
|
36
|
+
})}
|
|
37
|
+
data-testid={testId}
|
|
38
|
+
>
|
|
39
|
+
{isLabelVisible && labelPosition === 'left' && (
|
|
40
|
+
<div className="toggle__label">
|
|
41
|
+
{label}
|
|
42
|
+
{children}
|
|
43
|
+
</div>
|
|
44
|
+
)}
|
|
45
|
+
|
|
46
|
+
<div className="toggle__button-wrap">
|
|
47
|
+
<input
|
|
48
|
+
aria-label={isLabelVisible ? undefined : label}
|
|
49
|
+
className="toggle__input"
|
|
50
|
+
type="checkbox"
|
|
51
|
+
name={name}
|
|
52
|
+
onChange={e => {
|
|
53
|
+
// NOTE: If props specify an `onChange`, we need to call that too
|
|
54
|
+
if (rest.onChange) rest.onChange(e);
|
|
55
|
+
onChange(e);
|
|
56
|
+
}}
|
|
57
|
+
onInvalid={e => {
|
|
58
|
+
// NOTE: If props specify an `onInvalid`, we need to call that too
|
|
59
|
+
if (rest.onInvalid) rest.onInvalid(e);
|
|
60
|
+
onInvalid(e);
|
|
61
|
+
}}
|
|
62
|
+
ref={ref}
|
|
63
|
+
value={value}
|
|
64
|
+
{...rest}
|
|
65
|
+
/>
|
|
66
|
+
<span className="toggle__slider">
|
|
67
|
+
<div className="toggle__slider-element"></div>
|
|
68
|
+
</span>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
{isLabelVisible && labelPosition === 'right' && (
|
|
72
|
+
<div className="toggle__label">
|
|
73
|
+
{label}
|
|
74
|
+
{children}
|
|
75
|
+
</div>
|
|
76
|
+
)}
|
|
77
|
+
</label>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
export default Toggle;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InputHtmlProps } from '../types';
|
|
2
|
+
|
|
3
|
+
export type Toggle = Omit<InputHtmlProps, 'value'> & {
|
|
4
|
+
isLabelVisible?: boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
labelPosition?: 'left' | 'right';
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
spaceBetween?: boolean;
|
|
10
|
+
testId?: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
@use '../../tokens/light';
|
|
2
|
+
@use '../../tokens/spacing';
|
|
3
|
+
@use '../../tokens/corner-radius';
|
|
4
|
+
|
|
5
|
+
.toolbox {
|
|
6
|
+
border-top: 1px solid light.$ge-border-default;
|
|
7
|
+
border-bottom-right-radius: corner-radius.$s;
|
|
8
|
+
border-bottom-left-radius: corner-radius.$s;
|
|
9
|
+
background-color: light.$surface-primary-default;
|
|
10
|
+
width: 100%;
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: space-evenly;
|
|
13
|
+
align-items: center;
|
|
14
|
+
|
|
15
|
+
&__item-wrapper {
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
width: 100%;
|
|
18
|
+
|
|
19
|
+
&:hover {
|
|
20
|
+
background: light.$surface-primary-hover;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:first-child {
|
|
24
|
+
border-bottom-left-radius: corner-radius.$s;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:last-child {
|
|
28
|
+
border-bottom-right-radius: corner-radius.$s;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:only-child {
|
|
32
|
+
border-bottom-right-radius: corner-radius.$s;
|
|
33
|
+
border-bottom-left-radius: corner-radius.$s;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:not(:last-child) {
|
|
37
|
+
border-right: 1px solid light.$ge-border-default;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&__list-item-form {
|
|
42
|
+
display: flex;
|
|
43
|
+
justify-content: space-evenly;
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&__item {
|
|
48
|
+
width: 100%;
|
|
49
|
+
height: 100%;
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-wrap: wrap;
|
|
52
|
+
text-decoration: none;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
align-items: center;
|
|
55
|
+
row-gap: spacing.$xs;
|
|
56
|
+
column-gap: spacing.$xxs;
|
|
57
|
+
color: light.$on-buttons-on-link-default;
|
|
58
|
+
padding: spacing.$s;
|
|
59
|
+
background: none;
|
|
60
|
+
border: none;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
|
|
63
|
+
@media(max-width: 400px) {
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Types, type Toolbox as Props } from './toolbox.types';
|
|
4
|
+
import Text from '../text';
|
|
5
|
+
import HiddenInput from '../hidden-input';
|
|
6
|
+
|
|
7
|
+
const Toolbox: React.FunctionComponent<Props> = ({ items }) => (
|
|
8
|
+
<div className="toolbox">
|
|
9
|
+
{items.map(({ item, icon }, i) => (
|
|
10
|
+
<div className="toolbox__item-wrapper" key={i}>
|
|
11
|
+
{item.type === Types.Link ? (
|
|
12
|
+
<a {...item.props.link} className="toolbox__item">
|
|
13
|
+
{icon ? icon : null}
|
|
14
|
+
<Text size={Text.sizes.small}>{item.props.text}</Text>
|
|
15
|
+
</a>
|
|
16
|
+
) : (
|
|
17
|
+
<form
|
|
18
|
+
onSubmit={item.props.handleSubmit}
|
|
19
|
+
method="POST"
|
|
20
|
+
className="toolbox__list-item-form"
|
|
21
|
+
{...item.props.form}
|
|
22
|
+
>
|
|
23
|
+
<button
|
|
24
|
+
className="toolbox__item"
|
|
25
|
+
data-testid={item.props.testId}
|
|
26
|
+
{...item.props.button}
|
|
27
|
+
>
|
|
28
|
+
{icon ? icon : null}
|
|
29
|
+
<Text size={Text.sizes.small}>{item.props.text}</Text>
|
|
30
|
+
</button>
|
|
31
|
+
{item.props.hiddenInputs
|
|
32
|
+
? item.props.hiddenInputs.map((input, index) => (
|
|
33
|
+
<HiddenInput key={input.name + index} {...input} />
|
|
34
|
+
))
|
|
35
|
+
: null}
|
|
36
|
+
</form>
|
|
37
|
+
)}
|
|
38
|
+
</div>
|
|
39
|
+
))}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
export default Toolbox;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { HiddenInput } from '../hidden-input/hidden-input.types';
|
|
4
|
+
import type { ButtonHtmlProps, FormHtmlProps, LinkHtmlProps } from '../types';
|
|
5
|
+
|
|
6
|
+
export enum Types {
|
|
7
|
+
Button = 'Button',
|
|
8
|
+
Link = 'Link',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type LinkItem = {
|
|
12
|
+
type: Types.Link;
|
|
13
|
+
props: {
|
|
14
|
+
text: string;
|
|
15
|
+
link: LinkHtmlProps;
|
|
16
|
+
testId?: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type FormItem = {
|
|
21
|
+
type: Types.Button;
|
|
22
|
+
props: {
|
|
23
|
+
text: string;
|
|
24
|
+
form: FormHtmlProps;
|
|
25
|
+
button: ButtonHtmlProps;
|
|
26
|
+
handleSubmit?: () => void;
|
|
27
|
+
hiddenInputs?: HiddenInput[];
|
|
28
|
+
testId?: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type MenuItem = {
|
|
33
|
+
icon?: ReactNode;
|
|
34
|
+
item: LinkItem | FormItem;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type Toolbox = {
|
|
38
|
+
items: MenuItem[];
|
|
39
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
|
+
export default function debounce<T extends any[]>(
|
|
3
|
+
callback: (...args: T) => void,
|
|
4
|
+
wait: number,
|
|
5
|
+
) {
|
|
6
|
+
let timerRef: number;
|
|
7
|
+
|
|
8
|
+
return (...args: T) => {
|
|
9
|
+
clearTimeout(timerRef);
|
|
10
|
+
timerRef = window.setTimeout(() => callback(...args), wait);
|
|
11
|
+
};
|
|
12
|
+
}
|