@jobber/components-native 0.90.0 → 0.90.1-JOB-140976-676a3bc.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +2 -2
- package/dist/src/InputDate/InputDate.js +2 -2
- package/dist/src/InputFieldWrapper/InputFieldWrapper.js +14 -12
- package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +5 -2
- package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +5 -2
- package/dist/src/InputPressable/InputPressable.js +20 -8
- package/dist/src/InputPressable/InputPressable.style.js +3 -0
- package/dist/src/InputText/InputText.js +19 -11
- package/dist/src/InputTime/InputTime.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/InputDate/InputDate.d.ts +2 -1
- package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +9 -2
- package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +2 -3
- package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +2 -3
- package/dist/types/src/InputPressable/InputPressable.d.ts +9 -1
- package/dist/types/src/InputPressable/InputPressable.style.d.ts +3 -0
- package/dist/types/src/InputSearch/InputSearch.d.ts +1 -1
- package/dist/types/src/InputText/InputText.d.ts +8 -0
- package/dist/types/src/InputTime/InputTime.d.ts +2 -1
- package/package.json +2 -2
- package/src/InputDate/InputDate.tsx +5 -1
- package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +48 -1
- package/src/InputFieldWrapper/InputFieldWrapper.tsx +38 -28
- package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +3 -5
- package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +6 -4
- package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +2 -4
- package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +6 -4
- package/src/InputPressable/InputPressable.style.ts +4 -0
- package/src/InputPressable/InputPressable.test.tsx +75 -1
- package/src/InputPressable/InputPressable.tsx +33 -7
- package/src/InputSearch/InputSearch.tsx +1 -0
- package/src/InputText/InputText.test.tsx +75 -0
- package/src/InputText/InputText.tsx +29 -12
- package/src/InputTime/InputTime.tsx +5 -1
|
@@ -2,7 +2,8 @@ import type { UseControllerProps } from "react-hook-form";
|
|
|
2
2
|
import type { XOR } from "ts-xor";
|
|
3
3
|
import type { Clearable } from "@jobber/hooks";
|
|
4
4
|
import type { InputFieldWrapperProps } from "../InputFieldWrapper";
|
|
5
|
-
|
|
5
|
+
import type { InputPressableProps } from "../InputPressable/InputPressable";
|
|
6
|
+
interface BaseInputDateProps extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder">, Pick<InputPressableProps, "showMiniLabel"> {
|
|
6
7
|
/**
|
|
7
8
|
* Defaulted to "always" so user can clear the dates whenever there's a value.
|
|
8
9
|
*/
|
|
@@ -26,7 +26,14 @@ export interface InputFieldWrapperProps {
|
|
|
26
26
|
* Text that goes below the input to help the user understand the input
|
|
27
27
|
*/
|
|
28
28
|
readonly assistiveText?: string;
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Controls how the placeholder text is displayed.
|
|
31
|
+
* - normal: the placeholder text will be displayed in the normal placeholder position
|
|
32
|
+
* - mini: the placeholder text will float above the input value
|
|
33
|
+
* - hidden: the placeholder text will not be displayed
|
|
34
|
+
* @default "normal"
|
|
35
|
+
*/
|
|
36
|
+
readonly placeholderMode?: "normal" | "mini" | "hidden";
|
|
30
37
|
readonly hasValue?: boolean;
|
|
31
38
|
/**
|
|
32
39
|
* Symbol to display before the text input
|
|
@@ -78,4 +85,4 @@ export interface InputFieldWrapperProps {
|
|
|
78
85
|
}
|
|
79
86
|
export declare const INPUT_FIELD_WRAPPER_GLIMMERS_TEST_ID = "ATL-InputFieldWrapper-Glimmers";
|
|
80
87
|
export declare const INPUT_FIELD_WRAPPER_SPINNER_TEST_ID = "ATL-InputFieldWrapper-Spinner";
|
|
81
|
-
export declare function InputFieldWrapper({ invalid, disabled, placeholder, assistiveText, prefix, suffix,
|
|
88
|
+
export declare function InputFieldWrapper({ invalid, disabled, placeholder, assistiveText, prefix, suffix, placeholderMode, hasValue, error, focused, children, onClear, showClearAction, styleOverride, toolbar, toolbarVisibility, loading, loadingType, }: InputFieldWrapperProps): JSX.Element;
|
|
@@ -3,18 +3,17 @@ import type { IconNames } from "@jobber/design";
|
|
|
3
3
|
export interface PrefixLabelProps {
|
|
4
4
|
readonly focused: boolean;
|
|
5
5
|
readonly disabled?: boolean;
|
|
6
|
-
readonly
|
|
6
|
+
readonly miniLabelActive: boolean;
|
|
7
7
|
readonly inputInvalid: boolean;
|
|
8
8
|
readonly label: string;
|
|
9
9
|
readonly styleOverride?: StyleProp<TextStyle>;
|
|
10
10
|
}
|
|
11
11
|
export declare const prefixLabelTestId = "ATL-InputFieldWrapper-PrefixLabel";
|
|
12
12
|
export declare const prefixIconTestId = "ATL-InputFieldWrapper-PrefixIcon";
|
|
13
|
-
export declare function PrefixLabel({ focused, disabled,
|
|
13
|
+
export declare function PrefixLabel({ focused, disabled, miniLabelActive, inputInvalid, label, styleOverride, }: PrefixLabelProps): JSX.Element;
|
|
14
14
|
export interface PrefixIconProps {
|
|
15
15
|
readonly focused: boolean;
|
|
16
16
|
readonly disabled?: boolean;
|
|
17
|
-
readonly hasMiniLabel: boolean;
|
|
18
17
|
readonly inputInvalid?: boolean;
|
|
19
18
|
readonly icon: IconNames;
|
|
20
19
|
readonly styleOverride?: StyleProp<ViewStyle>;
|
|
@@ -3,7 +3,7 @@ import type { IconNames } from "@jobber/design";
|
|
|
3
3
|
export interface SuffixLabelProps {
|
|
4
4
|
readonly focused: boolean;
|
|
5
5
|
readonly disabled?: boolean;
|
|
6
|
-
readonly
|
|
6
|
+
readonly miniLabelActive: boolean;
|
|
7
7
|
readonly inputInvalid?: boolean;
|
|
8
8
|
readonly label: string;
|
|
9
9
|
readonly hasLeftMargin?: boolean;
|
|
@@ -11,11 +11,10 @@ export interface SuffixLabelProps {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const suffixLabelTestId = "ATL-InputFieldWrapper-SuffixLabel";
|
|
13
13
|
export declare const suffixIconTestId = "ATL-InputFieldWrapper-SuffixIcon";
|
|
14
|
-
export declare function SuffixLabel({ focused, disabled,
|
|
14
|
+
export declare function SuffixLabel({ focused, disabled, miniLabelActive, inputInvalid, label, hasLeftMargin, styleOverride, }: SuffixLabelProps): JSX.Element;
|
|
15
15
|
export interface SuffixIconProps {
|
|
16
16
|
readonly focused: boolean;
|
|
17
17
|
readonly disabled?: boolean;
|
|
18
|
-
readonly hasMiniLabel: boolean;
|
|
19
18
|
readonly inputInvalid?: boolean;
|
|
20
19
|
readonly icon: IconNames;
|
|
21
20
|
readonly hasLeftMargin?: boolean;
|
|
@@ -39,6 +39,14 @@ export interface InputPressableProps {
|
|
|
39
39
|
* Indicates the current selection is invalid
|
|
40
40
|
*/
|
|
41
41
|
readonly invalid?: boolean | string;
|
|
42
|
+
/**
|
|
43
|
+
* Controls the visibility of the mini label that appears inside the input
|
|
44
|
+
* when a value is entered. By default, the placeholder text moves up to
|
|
45
|
+
* become a mini label. Set to false to disable this behavior.
|
|
46
|
+
*
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
readonly showMiniLabel?: boolean;
|
|
42
50
|
/**
|
|
43
51
|
* Callback that is called when the text input is focused
|
|
44
52
|
* @param event
|
|
@@ -79,5 +87,5 @@ export interface InputPressableProps {
|
|
|
79
87
|
}
|
|
80
88
|
export type InputPressableRef = NativeText;
|
|
81
89
|
export declare const InputPressable: React.ForwardRefExoticComponent<InputPressableProps & React.RefAttributes<NativeText>>;
|
|
82
|
-
export declare function InputPressableInternal({ value, placeholder, disabled, invalid, error, onPress, accessibilityLabel, accessibilityHint, prefix, suffix, clearable, onClear, focused, }: InputPressableProps, ref: Ref<InputPressableRef>): JSX.Element;
|
|
90
|
+
export declare function InputPressableInternal({ value, placeholder, disabled, invalid, error, showMiniLabel, onPress, accessibilityLabel, accessibilityHint, prefix, suffix, clearable, onClear, focused, }: InputPressableProps, ref: Ref<InputPressableRef>): JSX.Element;
|
|
83
91
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { InputTextProps, InputTextRef } from "../InputText";
|
|
3
3
|
export declare const InputSearch: React.ForwardRefExoticComponent<InputSearchProps & React.RefAttributes<InputTextRef>>;
|
|
4
|
-
export interface InputSearchProps extends Pick<InputTextProps, "accessibilityHint" | "accessibilityLabel" | "autoFocus" | "placeholder" | "prefix"> {
|
|
4
|
+
export interface InputSearchProps extends Pick<InputTextProps, "accessibilityHint" | "accessibilityLabel" | "autoFocus" | "placeholder" | "prefix" | "showMiniLabel"> {
|
|
5
5
|
/**
|
|
6
6
|
* A callback function that handles the update of the new value of the property value.
|
|
7
7
|
*/
|
|
@@ -31,6 +31,14 @@ export interface InputTextProps extends Pick<InputFieldWrapperProps, "toolbar" |
|
|
|
31
31
|
* Text that helps the user understand the input
|
|
32
32
|
*/
|
|
33
33
|
readonly assistiveText?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Controls the visibility of the mini label that appears inside the input
|
|
36
|
+
* when a value is entered. By default, the placeholder text moves up to
|
|
37
|
+
* become a mini label. Set to false to disable this behavior.
|
|
38
|
+
*
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
readonly showMiniLabel?: boolean;
|
|
34
42
|
/**
|
|
35
43
|
* Determines what keyboard is shown
|
|
36
44
|
*/
|
|
@@ -2,7 +2,8 @@ import type { UseControllerProps } from "react-hook-form";
|
|
|
2
2
|
import type { XOR } from "ts-xor";
|
|
3
3
|
import type { Clearable } from "@jobber/hooks";
|
|
4
4
|
import type { InputFieldWrapperProps } from "../InputFieldWrapper";
|
|
5
|
-
|
|
5
|
+
import type { InputPressableProps } from "../InputPressable/InputPressable";
|
|
6
|
+
interface InputTimeBaseProps extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder">, Pick<InputPressableProps, "showMiniLabel"> {
|
|
6
7
|
/**
|
|
7
8
|
* Defaulted to "always" so user can clear the time whenever there's a value.
|
|
8
9
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.1-JOB-140976-676a3bc.17+676a3bc2e",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"react-native-safe-area-context": "^5.4.0",
|
|
95
95
|
"react-native-svg": ">=12.0.0"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "676a3bc2eb3879aa5fda68db6121d30c9bf4828f"
|
|
98
98
|
}
|
|
@@ -8,9 +8,11 @@ import type { InputFieldWrapperProps } from "../InputFieldWrapper";
|
|
|
8
8
|
import { FormField } from "../FormField";
|
|
9
9
|
import { InputPressable } from "../InputPressable";
|
|
10
10
|
import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
|
|
11
|
+
import type { InputPressableProps } from "../InputPressable/InputPressable";
|
|
11
12
|
|
|
12
13
|
interface BaseInputDateProps
|
|
13
|
-
extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder"
|
|
14
|
+
extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder">,
|
|
15
|
+
Pick<InputPressableProps, "showMiniLabel"> {
|
|
14
16
|
/**
|
|
15
17
|
* Defaulted to "always" so user can clear the dates whenever there's a value.
|
|
16
18
|
*/
|
|
@@ -145,6 +147,7 @@ function InternalInputDate({
|
|
|
145
147
|
minDate,
|
|
146
148
|
placeholder,
|
|
147
149
|
value,
|
|
150
|
+
showMiniLabel = true,
|
|
148
151
|
name,
|
|
149
152
|
onChange,
|
|
150
153
|
accessibilityLabel,
|
|
@@ -174,6 +177,7 @@ function InternalInputDate({
|
|
|
174
177
|
return (
|
|
175
178
|
<>
|
|
176
179
|
<InputPressable
|
|
180
|
+
showMiniLabel={showMiniLabel}
|
|
177
181
|
focused={showPicker}
|
|
178
182
|
clearable={canClearDate}
|
|
179
183
|
disabled={disabled}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { RenderAPI } from "@testing-library/react-native";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
fireEvent,
|
|
5
|
+
render,
|
|
6
|
+
renderHook,
|
|
7
|
+
screen,
|
|
8
|
+
} from "@testing-library/react-native";
|
|
4
9
|
import type { ViewStyle } from "react-native";
|
|
5
10
|
import { Text } from "react-native";
|
|
6
11
|
import type { InputFieldWrapperProps } from ".";
|
|
@@ -311,4 +316,46 @@ describe("InputFieldWrapper", () => {
|
|
|
311
316
|
expect(queryByTestId(INPUT_FIELD_WRAPPER_SPINNER_TEST_ID)).toBeNull();
|
|
312
317
|
});
|
|
313
318
|
});
|
|
319
|
+
|
|
320
|
+
describe("placeholderMode", () => {
|
|
321
|
+
it("renders the placeholder in its normal position", () => {
|
|
322
|
+
renderInputFieldWrapper({
|
|
323
|
+
placeholder: "placeholder",
|
|
324
|
+
placeholderMode: "normal",
|
|
325
|
+
});
|
|
326
|
+
const placeholder = screen.getByText("placeholder", {
|
|
327
|
+
includeHiddenElements: true,
|
|
328
|
+
});
|
|
329
|
+
expect(placeholder).toBeDefined();
|
|
330
|
+
expect(placeholder.props.style).toContainEqual(
|
|
331
|
+
typographyStyles.defaultSize,
|
|
332
|
+
);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it("renders the placeholder in its mini label position", () => {
|
|
336
|
+
renderInputFieldWrapper({
|
|
337
|
+
placeholder: "placeholder",
|
|
338
|
+
placeholderMode: "mini",
|
|
339
|
+
});
|
|
340
|
+
const placeholder = screen.getByText("placeholder", {
|
|
341
|
+
includeHiddenElements: true,
|
|
342
|
+
});
|
|
343
|
+
expect(placeholder).toBeDefined();
|
|
344
|
+
expect(placeholder.props.style).toContainEqual(
|
|
345
|
+
typographyStyles.smallSize,
|
|
346
|
+
);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it("does not render the placeholder", () => {
|
|
350
|
+
renderInputFieldWrapper({
|
|
351
|
+
placeholder: "placeholder",
|
|
352
|
+
placeholderMode: "hidden",
|
|
353
|
+
});
|
|
354
|
+
expect(
|
|
355
|
+
screen.queryByText("placeholder", {
|
|
356
|
+
includeHiddenElements: true,
|
|
357
|
+
}),
|
|
358
|
+
).toBeNull();
|
|
359
|
+
});
|
|
360
|
+
});
|
|
314
361
|
});
|
|
@@ -43,7 +43,14 @@ export interface InputFieldWrapperProps {
|
|
|
43
43
|
*/
|
|
44
44
|
readonly assistiveText?: string;
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Controls how the placeholder text is displayed.
|
|
48
|
+
* - normal: the placeholder text will be displayed in the normal placeholder position
|
|
49
|
+
* - mini: the placeholder text will float above the input value
|
|
50
|
+
* - hidden: the placeholder text will not be displayed
|
|
51
|
+
* @default "normal"
|
|
52
|
+
*/
|
|
53
|
+
readonly placeholderMode?: "normal" | "mini" | "hidden";
|
|
47
54
|
|
|
48
55
|
readonly hasValue?: boolean;
|
|
49
56
|
|
|
@@ -119,7 +126,7 @@ export function InputFieldWrapper({
|
|
|
119
126
|
assistiveText,
|
|
120
127
|
prefix,
|
|
121
128
|
suffix,
|
|
122
|
-
|
|
129
|
+
placeholderMode = "normal",
|
|
123
130
|
hasValue = false,
|
|
124
131
|
error,
|
|
125
132
|
focused = false,
|
|
@@ -143,6 +150,9 @@ export function InputFieldWrapper({
|
|
|
143
150
|
const showLoadingGlimmer = loading && loadingType === "glimmer";
|
|
144
151
|
const styles = useStyles();
|
|
145
152
|
|
|
153
|
+
const placeholderVisible = placeholderMode !== "hidden";
|
|
154
|
+
const miniLabelActive = placeholderMode === "mini";
|
|
155
|
+
|
|
146
156
|
return (
|
|
147
157
|
<ErrorMessageWrapper message={getMessage({ invalid, error })}>
|
|
148
158
|
<View
|
|
@@ -160,35 +170,36 @@ export function InputFieldWrapper({
|
|
|
160
170
|
<PrefixIcon
|
|
161
171
|
disabled={disabled}
|
|
162
172
|
focused={focused}
|
|
163
|
-
hasMiniLabel={hasMiniLabel}
|
|
164
173
|
inputInvalid={inputInvalid}
|
|
165
174
|
icon={prefix.icon}
|
|
166
175
|
/>
|
|
167
176
|
)}
|
|
168
177
|
<View style={[styles.inputContainer]}>
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
178
|
+
{placeholderVisible && (
|
|
179
|
+
<View
|
|
180
|
+
style={[
|
|
181
|
+
!!placeholder && styles.label,
|
|
182
|
+
miniLabelActive && styles.miniLabel,
|
|
183
|
+
disabled && styles.disabled,
|
|
184
|
+
miniLabelActive &&
|
|
185
|
+
showClearAction &&
|
|
186
|
+
styles.miniLabelShowClearAction,
|
|
187
|
+
]}
|
|
188
|
+
pointerEvents="none"
|
|
189
|
+
>
|
|
190
|
+
<Placeholder
|
|
191
|
+
placeholder={placeholder}
|
|
192
|
+
labelVariation={getLabelVariation(error, invalid, disabled)}
|
|
193
|
+
miniLabelActive={miniLabelActive}
|
|
194
|
+
styleOverride={styleOverride?.placeholderText}
|
|
195
|
+
/>
|
|
196
|
+
</View>
|
|
197
|
+
)}
|
|
187
198
|
{prefix?.label && hasValue && (
|
|
188
199
|
<PrefixLabel
|
|
189
200
|
disabled={disabled}
|
|
190
201
|
focused={focused}
|
|
191
|
-
|
|
202
|
+
miniLabelActive={miniLabelActive}
|
|
192
203
|
inputInvalid={inputInvalid}
|
|
193
204
|
label={prefix.label}
|
|
194
205
|
styleOverride={styleOverride?.prefixLabel}
|
|
@@ -225,7 +236,7 @@ export function InputFieldWrapper({
|
|
|
225
236
|
<SuffixLabel
|
|
226
237
|
disabled={disabled}
|
|
227
238
|
focused={focused}
|
|
228
|
-
|
|
239
|
+
miniLabelActive={miniLabelActive}
|
|
229
240
|
inputInvalid={inputInvalid}
|
|
230
241
|
label={suffix.label}
|
|
231
242
|
hasLeftMargin={!showClearAction}
|
|
@@ -245,7 +256,6 @@ export function InputFieldWrapper({
|
|
|
245
256
|
<SuffixIcon
|
|
246
257
|
disabled={disabled}
|
|
247
258
|
focused={focused}
|
|
248
|
-
hasMiniLabel={hasMiniLabel}
|
|
249
259
|
hasLeftMargin={!!(!showClearAction || suffix?.label)}
|
|
250
260
|
inputInvalid={inputInvalid}
|
|
251
261
|
icon={suffix.icon}
|
|
@@ -332,12 +342,12 @@ function Placeholder({
|
|
|
332
342
|
placeholder,
|
|
333
343
|
styleOverride,
|
|
334
344
|
labelVariation,
|
|
335
|
-
|
|
345
|
+
miniLabelActive,
|
|
336
346
|
}: {
|
|
337
347
|
readonly placeholder?: string;
|
|
338
348
|
readonly styleOverride: StyleProp<TextStyle>;
|
|
339
349
|
readonly labelVariation: TextVariation;
|
|
340
|
-
readonly
|
|
350
|
+
readonly miniLabelActive: boolean;
|
|
341
351
|
}) {
|
|
342
352
|
const typographyStyles = useTypographyStyles();
|
|
343
353
|
|
|
@@ -348,7 +358,7 @@ function Placeholder({
|
|
|
348
358
|
hideFromScreenReader={true}
|
|
349
359
|
maxLines="single"
|
|
350
360
|
variation={labelVariation}
|
|
351
|
-
level={
|
|
361
|
+
level={miniLabelActive ? "textSupporting" : "text"}
|
|
352
362
|
>
|
|
353
363
|
{placeholder}
|
|
354
364
|
</Text>
|
|
@@ -361,7 +371,7 @@ function Placeholder({
|
|
|
361
371
|
style={[
|
|
362
372
|
typographyStyles[labelVariation],
|
|
363
373
|
typographyStyles.baseRegularRegular,
|
|
364
|
-
|
|
374
|
+
miniLabelActive
|
|
365
375
|
? typographyStyles.smallSize
|
|
366
376
|
: typographyStyles.defaultSize,
|
|
367
377
|
styleOverride,
|
|
@@ -30,7 +30,7 @@ beforeAll(() => {
|
|
|
30
30
|
function setupLabel({
|
|
31
31
|
disabled = false,
|
|
32
32
|
focused = false,
|
|
33
|
-
|
|
33
|
+
miniLabelActive = false,
|
|
34
34
|
inputInvalid = false,
|
|
35
35
|
label = mockLabel,
|
|
36
36
|
styleOverride,
|
|
@@ -39,7 +39,7 @@ function setupLabel({
|
|
|
39
39
|
<PrefixLabel
|
|
40
40
|
disabled={disabled}
|
|
41
41
|
focused={focused}
|
|
42
|
-
|
|
42
|
+
miniLabelActive={miniLabelActive}
|
|
43
43
|
inputInvalid={inputInvalid}
|
|
44
44
|
label={label}
|
|
45
45
|
styleOverride={styleOverride}
|
|
@@ -50,7 +50,6 @@ function setupLabel({
|
|
|
50
50
|
function setupIcon({
|
|
51
51
|
disabled = false,
|
|
52
52
|
focused = false,
|
|
53
|
-
hasMiniLabel = false,
|
|
54
53
|
inputInvalid = false,
|
|
55
54
|
icon = "invoice",
|
|
56
55
|
}: Partial<PrefixIconProps>) {
|
|
@@ -58,7 +57,6 @@ function setupIcon({
|
|
|
58
57
|
<PrefixIcon
|
|
59
58
|
disabled={disabled}
|
|
60
59
|
focused={focused}
|
|
61
|
-
hasMiniLabel={hasMiniLabel}
|
|
62
60
|
inputInvalid={inputInvalid}
|
|
63
61
|
icon={icon}
|
|
64
62
|
/>,
|
|
@@ -150,7 +148,7 @@ describe("Prefix", () => {
|
|
|
150
148
|
|
|
151
149
|
it("updates the position of the label when a value is entered", () => {
|
|
152
150
|
const tree = setupLabel({
|
|
153
|
-
|
|
151
|
+
miniLabelActive: true,
|
|
154
152
|
});
|
|
155
153
|
const prefixLabel = tree.getByTestId(prefixLabelTestId);
|
|
156
154
|
const labelWrapper = prefixLabel.children[0] as ReactTestInstance;
|
|
@@ -11,7 +11,7 @@ import { useStyles } from "../../InputFieldWrapper.style";
|
|
|
11
11
|
export interface PrefixLabelProps {
|
|
12
12
|
readonly focused: boolean;
|
|
13
13
|
readonly disabled?: boolean;
|
|
14
|
-
readonly
|
|
14
|
+
readonly miniLabelActive: boolean;
|
|
15
15
|
readonly inputInvalid: boolean;
|
|
16
16
|
readonly label: string;
|
|
17
17
|
readonly styleOverride?: StyleProp<TextStyle>;
|
|
@@ -23,7 +23,7 @@ export const prefixIconTestId = "ATL-InputFieldWrapper-PrefixIcon";
|
|
|
23
23
|
export function PrefixLabel({
|
|
24
24
|
focused,
|
|
25
25
|
disabled,
|
|
26
|
-
|
|
26
|
+
miniLabelActive,
|
|
27
27
|
inputInvalid,
|
|
28
28
|
label,
|
|
29
29
|
styleOverride,
|
|
@@ -41,7 +41,10 @@ export function PrefixLabel({
|
|
|
41
41
|
testID={prefixLabelTestId}
|
|
42
42
|
>
|
|
43
43
|
<View
|
|
44
|
-
style={[
|
|
44
|
+
style={[
|
|
45
|
+
styles.prefixLabel,
|
|
46
|
+
miniLabelActive && styles.fieldAffixMiniLabel,
|
|
47
|
+
]}
|
|
45
48
|
>
|
|
46
49
|
{!styleOverride ? (
|
|
47
50
|
<Text variation={disabled ? "disabled" : "base"}>{label}</Text>
|
|
@@ -67,7 +70,6 @@ export function PrefixLabel({
|
|
|
67
70
|
export interface PrefixIconProps {
|
|
68
71
|
readonly focused: boolean;
|
|
69
72
|
readonly disabled?: boolean;
|
|
70
|
-
readonly hasMiniLabel: boolean;
|
|
71
73
|
readonly inputInvalid?: boolean;
|
|
72
74
|
readonly icon: IconNames;
|
|
73
75
|
readonly styleOverride?: StyleProp<ViewStyle>;
|
|
@@ -10,7 +10,7 @@ const mockLabel = "$";
|
|
|
10
10
|
function setupLabel({
|
|
11
11
|
disabled = false,
|
|
12
12
|
focused = false,
|
|
13
|
-
|
|
13
|
+
miniLabelActive = false,
|
|
14
14
|
inputInvalid = false,
|
|
15
15
|
label = mockLabel,
|
|
16
16
|
styleOverride,
|
|
@@ -19,7 +19,7 @@ function setupLabel({
|
|
|
19
19
|
<SuffixLabel
|
|
20
20
|
disabled={disabled}
|
|
21
21
|
focused={focused}
|
|
22
|
-
|
|
22
|
+
miniLabelActive={miniLabelActive}
|
|
23
23
|
inputInvalid={inputInvalid}
|
|
24
24
|
label={label}
|
|
25
25
|
styleOverride={styleOverride}
|
|
@@ -30,7 +30,6 @@ function setupLabel({
|
|
|
30
30
|
function setupIcon({
|
|
31
31
|
disabled = false,
|
|
32
32
|
focused = false,
|
|
33
|
-
hasMiniLabel = false,
|
|
34
33
|
inputInvalid = false,
|
|
35
34
|
icon = "invoice",
|
|
36
35
|
}: Partial<SuffixIconProps>) {
|
|
@@ -38,7 +37,6 @@ function setupIcon({
|
|
|
38
37
|
<SuffixIcon
|
|
39
38
|
disabled={disabled}
|
|
40
39
|
focused={focused}
|
|
41
|
-
hasMiniLabel={hasMiniLabel}
|
|
42
40
|
inputInvalid={inputInvalid}
|
|
43
41
|
icon={icon}
|
|
44
42
|
/>,
|
|
@@ -11,7 +11,7 @@ import { useStyles } from "../../InputFieldWrapper.style";
|
|
|
11
11
|
export interface SuffixLabelProps {
|
|
12
12
|
readonly focused: boolean;
|
|
13
13
|
readonly disabled?: boolean;
|
|
14
|
-
readonly
|
|
14
|
+
readonly miniLabelActive: boolean;
|
|
15
15
|
readonly inputInvalid?: boolean;
|
|
16
16
|
readonly label: string;
|
|
17
17
|
readonly hasLeftMargin?: boolean;
|
|
@@ -24,7 +24,7 @@ export const suffixIconTestId = "ATL-InputFieldWrapper-SuffixIcon";
|
|
|
24
24
|
export function SuffixLabel({
|
|
25
25
|
focused,
|
|
26
26
|
disabled,
|
|
27
|
-
|
|
27
|
+
miniLabelActive,
|
|
28
28
|
inputInvalid,
|
|
29
29
|
label,
|
|
30
30
|
hasLeftMargin = true,
|
|
@@ -44,7 +44,10 @@ export function SuffixLabel({
|
|
|
44
44
|
]}
|
|
45
45
|
>
|
|
46
46
|
<View
|
|
47
|
-
style={[
|
|
47
|
+
style={[
|
|
48
|
+
styles.suffixLabel,
|
|
49
|
+
miniLabelActive && styles.fieldAffixMiniLabel,
|
|
50
|
+
]}
|
|
48
51
|
>
|
|
49
52
|
{!styleOverride ? (
|
|
50
53
|
<Text variation={disabled ? "disabled" : "base"}>{label}</Text>
|
|
@@ -70,7 +73,6 @@ export function SuffixLabel({
|
|
|
70
73
|
export interface SuffixIconProps {
|
|
71
74
|
readonly focused: boolean;
|
|
72
75
|
readonly disabled?: boolean;
|
|
73
|
-
readonly hasMiniLabel: boolean;
|
|
74
76
|
readonly inputInvalid?: boolean;
|
|
75
77
|
readonly icon: IconNames;
|
|
76
78
|
readonly hasLeftMargin?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { fireEvent, render } from "@testing-library/react-native";
|
|
2
|
+
import { fireEvent, render, screen } from "@testing-library/react-native";
|
|
3
3
|
import { InputPressable } from ".";
|
|
4
4
|
import type { InputFieldWrapperProps } from "../InputFieldWrapper";
|
|
5
5
|
|
|
@@ -120,6 +120,80 @@ describe("InputPressable", () => {
|
|
|
120
120
|
expect(getByText(value, { includeHiddenElements: true })).toBeDefined();
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
|
+
|
|
124
|
+
describe("showMiniLabel", () => {
|
|
125
|
+
it("defaults to true", () => {
|
|
126
|
+
const props = { placeholder: "placeholder", value: "value" };
|
|
127
|
+
render(<InputPressable {...props} />);
|
|
128
|
+
expect(
|
|
129
|
+
screen.getByText("placeholder", { includeHiddenElements: true }),
|
|
130
|
+
).toBeDefined();
|
|
131
|
+
expect(MockInputFieldWrapper).toHaveBeenCalledWith(
|
|
132
|
+
expect.objectContaining({
|
|
133
|
+
placeholderMode: "mini",
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe("when true", () => {
|
|
139
|
+
it("renders the placeholder in its normal position when the input has no value", () => {
|
|
140
|
+
const props = { showMiniLabel: true, placeholder: "placeholder" };
|
|
141
|
+
render(<InputPressable {...props} />);
|
|
142
|
+
expect(
|
|
143
|
+
screen.getByText("placeholder", { includeHiddenElements: true }),
|
|
144
|
+
).toBeDefined();
|
|
145
|
+
expect(MockInputFieldWrapper).toHaveBeenCalledWith(
|
|
146
|
+
expect.objectContaining({
|
|
147
|
+
placeholderMode: "normal",
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("renders the placeholder as a mini label when the input has a value", () => {
|
|
153
|
+
const props = {
|
|
154
|
+
showMiniLabel: true,
|
|
155
|
+
placeholder: "placeholder",
|
|
156
|
+
value: "value",
|
|
157
|
+
};
|
|
158
|
+
render(<InputPressable {...props} />);
|
|
159
|
+
expect(
|
|
160
|
+
screen.getByText("placeholder", { includeHiddenElements: true }),
|
|
161
|
+
).toBeDefined();
|
|
162
|
+
expect(MockInputFieldWrapper).toHaveBeenCalledWith(
|
|
163
|
+
expect.objectContaining({
|
|
164
|
+
placeholderMode: "mini",
|
|
165
|
+
}),
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe("when false", () => {
|
|
171
|
+
it("renders the placeholder in its normal position when the input has no value", () => {
|
|
172
|
+
const props = { showMiniLabel: false, placeholder: "placeholder" };
|
|
173
|
+
render(<InputPressable {...props} />);
|
|
174
|
+
expect(
|
|
175
|
+
screen.getByText("placeholder", { includeHiddenElements: true }),
|
|
176
|
+
).toBeDefined();
|
|
177
|
+
expect(MockInputFieldWrapper).toHaveBeenCalledWith(
|
|
178
|
+
expect.objectContaining({
|
|
179
|
+
placeholderMode: "normal",
|
|
180
|
+
}),
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("does not render the placeholder when the input has a value", () => {
|
|
185
|
+
const props = {
|
|
186
|
+
showMiniLabel: false,
|
|
187
|
+
placeholder: "placeholder",
|
|
188
|
+
value: "value",
|
|
189
|
+
};
|
|
190
|
+
render(<InputPressable {...props} />);
|
|
191
|
+
expect(
|
|
192
|
+
screen.queryByText("placeholder", { includeHiddenElements: true }),
|
|
193
|
+
).toBeNull();
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
});
|
|
123
197
|
});
|
|
124
198
|
|
|
125
199
|
describe("accessibilityLabel", () => {
|