@jobber/components-native 0.90.1-JOB-140976-fc0b992.18 → 0.90.1-JOB-142149-547612b.8
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/Form/Form.js +1 -1
- package/dist/src/Form/components/FormBody/FormBody.js +5 -5
- package/dist/src/InputDate/InputDate.js +2 -2
- package/dist/src/InputFieldWrapper/InputFieldWrapper.js +12 -14
- package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +2 -5
- package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +2 -5
- package/dist/src/InputPressable/InputPressable.js +8 -20
- package/dist/src/InputPressable/InputPressable.style.js +0 -3
- package/dist/src/InputText/InputText.js +11 -22
- package/dist/src/InputText/InputText.style.js +0 -4
- package/dist/src/InputTime/InputTime.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/InputDate/InputDate.d.ts +1 -2
- package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +2 -9
- package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +3 -2
- package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +3 -2
- package/dist/types/src/InputPressable/InputPressable.d.ts +1 -9
- package/dist/types/src/InputPressable/InputPressable.style.d.ts +0 -3
- package/dist/types/src/InputSearch/InputSearch.d.ts +1 -1
- package/dist/types/src/InputText/InputText.d.ts +0 -8
- package/dist/types/src/InputText/InputText.style.d.ts +0 -4
- package/dist/types/src/InputTime/InputTime.d.ts +1 -2
- package/package.json +2 -2
- package/src/Form/Form.tsx +0 -1
- package/src/Form/components/FormBody/FormBody.tsx +6 -6
- package/src/InputDate/InputDate.tsx +1 -5
- package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +1 -48
- package/src/InputFieldWrapper/InputFieldWrapper.tsx +28 -38
- package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +5 -3
- package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +4 -6
- package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +4 -2
- package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +4 -6
- package/src/InputPressable/InputPressable.style.ts +0 -4
- package/src/InputPressable/InputPressable.test.tsx +1 -75
- package/src/InputPressable/InputPressable.tsx +7 -33
- package/src/InputSearch/InputSearch.tsx +0 -1
- package/src/InputText/InputText.style.ts +0 -5
- package/src/InputText/InputText.test.tsx +0 -75
- package/src/InputText/InputText.tsx +12 -32
- package/src/InputTime/InputTime.tsx +1 -5
|
@@ -2,8 +2,7 @@ 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
|
-
|
|
6
|
-
interface BaseInputDateProps extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder">, Pick<InputPressableProps, "showMiniLabel"> {
|
|
5
|
+
interface BaseInputDateProps extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder"> {
|
|
7
6
|
/**
|
|
8
7
|
* Defaulted to "always" so user can clear the dates whenever there's a value.
|
|
9
8
|
*/
|
|
@@ -26,14 +26,7 @@ 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
|
-
|
|
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";
|
|
29
|
+
readonly hasMiniLabel?: boolean;
|
|
37
30
|
readonly hasValue?: boolean;
|
|
38
31
|
/**
|
|
39
32
|
* Symbol to display before the text input
|
|
@@ -85,4 +78,4 @@ export interface InputFieldWrapperProps {
|
|
|
85
78
|
}
|
|
86
79
|
export declare const INPUT_FIELD_WRAPPER_GLIMMERS_TEST_ID = "ATL-InputFieldWrapper-Glimmers";
|
|
87
80
|
export declare const INPUT_FIELD_WRAPPER_SPINNER_TEST_ID = "ATL-InputFieldWrapper-Spinner";
|
|
88
|
-
export declare function InputFieldWrapper({ invalid, disabled, placeholder, assistiveText, prefix, suffix,
|
|
81
|
+
export declare function InputFieldWrapper({ invalid, disabled, placeholder, assistiveText, prefix, suffix, hasMiniLabel, hasValue, error, focused, children, onClear, showClearAction, styleOverride, toolbar, toolbarVisibility, loading, loadingType, }: InputFieldWrapperProps): JSX.Element;
|
|
@@ -3,17 +3,18 @@ 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 hasMiniLabel: 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, hasMiniLabel, 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;
|
|
17
18
|
readonly inputInvalid?: boolean;
|
|
18
19
|
readonly icon: IconNames;
|
|
19
20
|
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 hasMiniLabel: boolean;
|
|
7
7
|
readonly inputInvalid?: boolean;
|
|
8
8
|
readonly label: string;
|
|
9
9
|
readonly hasLeftMargin?: boolean;
|
|
@@ -11,10 +11,11 @@ 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, hasMiniLabel, 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;
|
|
18
19
|
readonly inputInvalid?: boolean;
|
|
19
20
|
readonly icon: IconNames;
|
|
20
21
|
readonly hasLeftMargin?: boolean;
|
|
@@ -39,14 +39,6 @@ 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;
|
|
50
42
|
/**
|
|
51
43
|
* Callback that is called when the text input is focused
|
|
52
44
|
* @param event
|
|
@@ -87,5 +79,5 @@ export interface InputPressableProps {
|
|
|
87
79
|
}
|
|
88
80
|
export type InputPressableRef = NativeText;
|
|
89
81
|
export declare const InputPressable: React.ForwardRefExoticComponent<InputPressableProps & React.RefAttributes<NativeText>>;
|
|
90
|
-
export declare function InputPressableInternal({ value, placeholder, disabled, invalid, error,
|
|
82
|
+
export declare function InputPressableInternal({ value, placeholder, disabled, invalid, error, onPress, accessibilityLabel, accessibilityHint, prefix, suffix, clearable, onClear, focused, }: InputPressableProps, ref: Ref<InputPressableRef>): JSX.Element;
|
|
91
83
|
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"> {
|
|
5
5
|
/**
|
|
6
6
|
* A callback function that handles the update of the new value of the property value.
|
|
7
7
|
*/
|
|
@@ -31,14 +31,6 @@ 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;
|
|
42
34
|
/**
|
|
43
35
|
* Determines what keyboard is shown
|
|
44
36
|
*/
|
|
@@ -2,8 +2,7 @@ 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
|
-
|
|
6
|
-
interface InputTimeBaseProps extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder">, Pick<InputPressableProps, "showMiniLabel"> {
|
|
5
|
+
interface InputTimeBaseProps extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder"> {
|
|
7
6
|
/**
|
|
8
7
|
* Defaulted to "always" so user can clear the time whenever there's a value.
|
|
9
8
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.90.1-JOB-
|
|
3
|
+
"version": "0.90.1-JOB-142149-547612b.8+547612b28",
|
|
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": "547612b28b6ea97cd710210ecbbe6917da0c9734"
|
|
98
98
|
}
|
package/src/Form/Form.tsx
CHANGED
|
@@ -174,7 +174,6 @@ function InternalForm<T extends FieldValues, S>({
|
|
|
174
174
|
ref={scrollViewRef}
|
|
175
175
|
{...keyboardProps}
|
|
176
176
|
extraHeight={headerHeight}
|
|
177
|
-
extraScrollHeight={edgeToEdgeEnabled ? tokens["space-large"] : 0}
|
|
178
177
|
contentContainerStyle={
|
|
179
178
|
!keyboardHeight && styles.scrollContentContainer
|
|
180
179
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
3
4
|
import { useStyles } from "./FormBody.style";
|
|
4
5
|
import { useScreenInformation } from "../../hooks/useScreenInformation";
|
|
5
6
|
import type { FormActionBarProps } from "../FormActionBar";
|
|
@@ -25,13 +26,12 @@ export function FormBody({
|
|
|
25
26
|
setSaveButtonHeight,
|
|
26
27
|
saveButtonOffset,
|
|
27
28
|
}: FormBodyProps): JSX.Element {
|
|
28
|
-
const paddingBottom =
|
|
29
|
-
const fullViewPadding = useMemo(() => ({ paddingBottom }), [paddingBottom]);
|
|
29
|
+
const { bottom: paddingBottom } = useSafeAreaInsets();
|
|
30
30
|
const styles = useStyles();
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
<>
|
|
34
|
-
<View style={
|
|
34
|
+
<View style={styles.container}>
|
|
35
35
|
{children}
|
|
36
36
|
{shouldRenderActionBar && (
|
|
37
37
|
<FormActionBar
|
|
@@ -47,9 +47,9 @@ export function FormBody({
|
|
|
47
47
|
)}
|
|
48
48
|
</View>
|
|
49
49
|
|
|
50
|
-
{
|
|
50
|
+
{!saveButtonOffset && (
|
|
51
51
|
<View
|
|
52
|
-
style={[
|
|
52
|
+
style={[{ paddingBottom }, styles.safeArea]}
|
|
53
53
|
testID="ATL-FormSafeArea"
|
|
54
54
|
/>
|
|
55
55
|
)}
|
|
@@ -8,11 +8,9 @@ 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";
|
|
12
11
|
|
|
13
12
|
interface BaseInputDateProps
|
|
14
|
-
extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder"
|
|
15
|
-
Pick<InputPressableProps, "showMiniLabel"> {
|
|
13
|
+
extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder"> {
|
|
16
14
|
/**
|
|
17
15
|
* Defaulted to "always" so user can clear the dates whenever there's a value.
|
|
18
16
|
*/
|
|
@@ -147,7 +145,6 @@ function InternalInputDate({
|
|
|
147
145
|
minDate,
|
|
148
146
|
placeholder,
|
|
149
147
|
value,
|
|
150
|
-
showMiniLabel = true,
|
|
151
148
|
name,
|
|
152
149
|
onChange,
|
|
153
150
|
accessibilityLabel,
|
|
@@ -177,7 +174,6 @@ function InternalInputDate({
|
|
|
177
174
|
return (
|
|
178
175
|
<>
|
|
179
176
|
<InputPressable
|
|
180
|
-
showMiniLabel={showMiniLabel}
|
|
181
177
|
focused={showPicker}
|
|
182
178
|
clearable={canClearDate}
|
|
183
179
|
disabled={disabled}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { RenderAPI } from "@testing-library/react-native";
|
|
3
|
-
import {
|
|
4
|
-
fireEvent,
|
|
5
|
-
render,
|
|
6
|
-
renderHook,
|
|
7
|
-
screen,
|
|
8
|
-
} from "@testing-library/react-native";
|
|
3
|
+
import { fireEvent, render, renderHook } from "@testing-library/react-native";
|
|
9
4
|
import type { ViewStyle } from "react-native";
|
|
10
5
|
import { Text } from "react-native";
|
|
11
6
|
import type { InputFieldWrapperProps } from ".";
|
|
@@ -316,46 +311,4 @@ describe("InputFieldWrapper", () => {
|
|
|
316
311
|
expect(queryByTestId(INPUT_FIELD_WRAPPER_SPINNER_TEST_ID)).toBeNull();
|
|
317
312
|
});
|
|
318
313
|
});
|
|
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
|
-
});
|
|
361
314
|
});
|
|
@@ -43,14 +43,7 @@ export interface InputFieldWrapperProps {
|
|
|
43
43
|
*/
|
|
44
44
|
readonly assistiveText?: string;
|
|
45
45
|
|
|
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";
|
|
46
|
+
readonly hasMiniLabel?: boolean;
|
|
54
47
|
|
|
55
48
|
readonly hasValue?: boolean;
|
|
56
49
|
|
|
@@ -126,7 +119,7 @@ export function InputFieldWrapper({
|
|
|
126
119
|
assistiveText,
|
|
127
120
|
prefix,
|
|
128
121
|
suffix,
|
|
129
|
-
|
|
122
|
+
hasMiniLabel = false,
|
|
130
123
|
hasValue = false,
|
|
131
124
|
error,
|
|
132
125
|
focused = false,
|
|
@@ -150,9 +143,6 @@ export function InputFieldWrapper({
|
|
|
150
143
|
const showLoadingGlimmer = loading && loadingType === "glimmer";
|
|
151
144
|
const styles = useStyles();
|
|
152
145
|
|
|
153
|
-
const placeholderVisible = placeholderMode !== "hidden";
|
|
154
|
-
const miniLabelActive = placeholderMode === "mini";
|
|
155
|
-
|
|
156
146
|
return (
|
|
157
147
|
<ErrorMessageWrapper message={getMessage({ invalid, error })}>
|
|
158
148
|
<View
|
|
@@ -170,36 +160,35 @@ export function InputFieldWrapper({
|
|
|
170
160
|
<PrefixIcon
|
|
171
161
|
disabled={disabled}
|
|
172
162
|
focused={focused}
|
|
163
|
+
hasMiniLabel={hasMiniLabel}
|
|
173
164
|
inputInvalid={inputInvalid}
|
|
174
165
|
icon={prefix.icon}
|
|
175
166
|
/>
|
|
176
167
|
)}
|
|
177
168
|
<View style={[styles.inputContainer]}>
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
</View>
|
|
197
|
-
)}
|
|
169
|
+
<View
|
|
170
|
+
style={[
|
|
171
|
+
!!placeholder && styles.label,
|
|
172
|
+
hasMiniLabel && styles.miniLabel,
|
|
173
|
+
disabled && styles.disabled,
|
|
174
|
+
hasMiniLabel &&
|
|
175
|
+
showClearAction &&
|
|
176
|
+
styles.miniLabelShowClearAction,
|
|
177
|
+
]}
|
|
178
|
+
pointerEvents="none"
|
|
179
|
+
>
|
|
180
|
+
<Placeholder
|
|
181
|
+
placeholder={placeholder}
|
|
182
|
+
labelVariation={getLabelVariation(error, invalid, disabled)}
|
|
183
|
+
hasMiniLabel={hasMiniLabel}
|
|
184
|
+
styleOverride={styleOverride?.placeholderText}
|
|
185
|
+
/>
|
|
186
|
+
</View>
|
|
198
187
|
{prefix?.label && hasValue && (
|
|
199
188
|
<PrefixLabel
|
|
200
189
|
disabled={disabled}
|
|
201
190
|
focused={focused}
|
|
202
|
-
|
|
191
|
+
hasMiniLabel={hasMiniLabel}
|
|
203
192
|
inputInvalid={inputInvalid}
|
|
204
193
|
label={prefix.label}
|
|
205
194
|
styleOverride={styleOverride?.prefixLabel}
|
|
@@ -236,7 +225,7 @@ export function InputFieldWrapper({
|
|
|
236
225
|
<SuffixLabel
|
|
237
226
|
disabled={disabled}
|
|
238
227
|
focused={focused}
|
|
239
|
-
|
|
228
|
+
hasMiniLabel={hasMiniLabel}
|
|
240
229
|
inputInvalid={inputInvalid}
|
|
241
230
|
label={suffix.label}
|
|
242
231
|
hasLeftMargin={!showClearAction}
|
|
@@ -256,6 +245,7 @@ export function InputFieldWrapper({
|
|
|
256
245
|
<SuffixIcon
|
|
257
246
|
disabled={disabled}
|
|
258
247
|
focused={focused}
|
|
248
|
+
hasMiniLabel={hasMiniLabel}
|
|
259
249
|
hasLeftMargin={!!(!showClearAction || suffix?.label)}
|
|
260
250
|
inputInvalid={inputInvalid}
|
|
261
251
|
icon={suffix.icon}
|
|
@@ -342,12 +332,12 @@ function Placeholder({
|
|
|
342
332
|
placeholder,
|
|
343
333
|
styleOverride,
|
|
344
334
|
labelVariation,
|
|
345
|
-
|
|
335
|
+
hasMiniLabel,
|
|
346
336
|
}: {
|
|
347
337
|
readonly placeholder?: string;
|
|
348
338
|
readonly styleOverride: StyleProp<TextStyle>;
|
|
349
339
|
readonly labelVariation: TextVariation;
|
|
350
|
-
readonly
|
|
340
|
+
readonly hasMiniLabel: boolean;
|
|
351
341
|
}) {
|
|
352
342
|
const typographyStyles = useTypographyStyles();
|
|
353
343
|
|
|
@@ -358,7 +348,7 @@ function Placeholder({
|
|
|
358
348
|
hideFromScreenReader={true}
|
|
359
349
|
maxLines="single"
|
|
360
350
|
variation={labelVariation}
|
|
361
|
-
level={
|
|
351
|
+
level={hasMiniLabel ? "textSupporting" : "text"}
|
|
362
352
|
>
|
|
363
353
|
{placeholder}
|
|
364
354
|
</Text>
|
|
@@ -371,7 +361,7 @@ function Placeholder({
|
|
|
371
361
|
style={[
|
|
372
362
|
typographyStyles[labelVariation],
|
|
373
363
|
typographyStyles.baseRegularRegular,
|
|
374
|
-
|
|
364
|
+
hasMiniLabel
|
|
375
365
|
? typographyStyles.smallSize
|
|
376
366
|
: typographyStyles.defaultSize,
|
|
377
367
|
styleOverride,
|
|
@@ -30,7 +30,7 @@ beforeAll(() => {
|
|
|
30
30
|
function setupLabel({
|
|
31
31
|
disabled = false,
|
|
32
32
|
focused = false,
|
|
33
|
-
|
|
33
|
+
hasMiniLabel = 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
|
+
hasMiniLabel={hasMiniLabel}
|
|
43
43
|
inputInvalid={inputInvalid}
|
|
44
44
|
label={label}
|
|
45
45
|
styleOverride={styleOverride}
|
|
@@ -50,6 +50,7 @@ function setupLabel({
|
|
|
50
50
|
function setupIcon({
|
|
51
51
|
disabled = false,
|
|
52
52
|
focused = false,
|
|
53
|
+
hasMiniLabel = false,
|
|
53
54
|
inputInvalid = false,
|
|
54
55
|
icon = "invoice",
|
|
55
56
|
}: Partial<PrefixIconProps>) {
|
|
@@ -57,6 +58,7 @@ function setupIcon({
|
|
|
57
58
|
<PrefixIcon
|
|
58
59
|
disabled={disabled}
|
|
59
60
|
focused={focused}
|
|
61
|
+
hasMiniLabel={hasMiniLabel}
|
|
60
62
|
inputInvalid={inputInvalid}
|
|
61
63
|
icon={icon}
|
|
62
64
|
/>,
|
|
@@ -148,7 +150,7 @@ describe("Prefix", () => {
|
|
|
148
150
|
|
|
149
151
|
it("updates the position of the label when a value is entered", () => {
|
|
150
152
|
const tree = setupLabel({
|
|
151
|
-
|
|
153
|
+
hasMiniLabel: true,
|
|
152
154
|
});
|
|
153
155
|
const prefixLabel = tree.getByTestId(prefixLabelTestId);
|
|
154
156
|
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 hasMiniLabel: 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
|
+
hasMiniLabel,
|
|
27
27
|
inputInvalid,
|
|
28
28
|
label,
|
|
29
29
|
styleOverride,
|
|
@@ -41,10 +41,7 @@ export function PrefixLabel({
|
|
|
41
41
|
testID={prefixLabelTestId}
|
|
42
42
|
>
|
|
43
43
|
<View
|
|
44
|
-
style={[
|
|
45
|
-
styles.prefixLabel,
|
|
46
|
-
miniLabelActive && styles.fieldAffixMiniLabel,
|
|
47
|
-
]}
|
|
44
|
+
style={[styles.prefixLabel, hasMiniLabel && styles.fieldAffixMiniLabel]}
|
|
48
45
|
>
|
|
49
46
|
{!styleOverride ? (
|
|
50
47
|
<Text variation={disabled ? "disabled" : "base"}>{label}</Text>
|
|
@@ -70,6 +67,7 @@ export function PrefixLabel({
|
|
|
70
67
|
export interface PrefixIconProps {
|
|
71
68
|
readonly focused: boolean;
|
|
72
69
|
readonly disabled?: boolean;
|
|
70
|
+
readonly hasMiniLabel: boolean;
|
|
73
71
|
readonly inputInvalid?: boolean;
|
|
74
72
|
readonly icon: IconNames;
|
|
75
73
|
readonly styleOverride?: StyleProp<ViewStyle>;
|
|
@@ -10,7 +10,7 @@ const mockLabel = "$";
|
|
|
10
10
|
function setupLabel({
|
|
11
11
|
disabled = false,
|
|
12
12
|
focused = false,
|
|
13
|
-
|
|
13
|
+
hasMiniLabel = 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
|
+
hasMiniLabel={hasMiniLabel}
|
|
23
23
|
inputInvalid={inputInvalid}
|
|
24
24
|
label={label}
|
|
25
25
|
styleOverride={styleOverride}
|
|
@@ -30,6 +30,7 @@ function setupLabel({
|
|
|
30
30
|
function setupIcon({
|
|
31
31
|
disabled = false,
|
|
32
32
|
focused = false,
|
|
33
|
+
hasMiniLabel = false,
|
|
33
34
|
inputInvalid = false,
|
|
34
35
|
icon = "invoice",
|
|
35
36
|
}: Partial<SuffixIconProps>) {
|
|
@@ -37,6 +38,7 @@ function setupIcon({
|
|
|
37
38
|
<SuffixIcon
|
|
38
39
|
disabled={disabled}
|
|
39
40
|
focused={focused}
|
|
41
|
+
hasMiniLabel={hasMiniLabel}
|
|
40
42
|
inputInvalid={inputInvalid}
|
|
41
43
|
icon={icon}
|
|
42
44
|
/>,
|
|
@@ -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 hasMiniLabel: 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
|
+
hasMiniLabel,
|
|
28
28
|
inputInvalid,
|
|
29
29
|
label,
|
|
30
30
|
hasLeftMargin = true,
|
|
@@ -44,10 +44,7 @@ export function SuffixLabel({
|
|
|
44
44
|
]}
|
|
45
45
|
>
|
|
46
46
|
<View
|
|
47
|
-
style={[
|
|
48
|
-
styles.suffixLabel,
|
|
49
|
-
miniLabelActive && styles.fieldAffixMiniLabel,
|
|
50
|
-
]}
|
|
47
|
+
style={[styles.suffixLabel, hasMiniLabel && styles.fieldAffixMiniLabel]}
|
|
51
48
|
>
|
|
52
49
|
{!styleOverride ? (
|
|
53
50
|
<Text variation={disabled ? "disabled" : "base"}>{label}</Text>
|
|
@@ -73,6 +70,7 @@ export function SuffixLabel({
|
|
|
73
70
|
export interface SuffixIconProps {
|
|
74
71
|
readonly focused: boolean;
|
|
75
72
|
readonly disabled?: boolean;
|
|
73
|
+
readonly hasMiniLabel: boolean;
|
|
76
74
|
readonly inputInvalid?: boolean;
|
|
77
75
|
readonly icon: IconNames;
|
|
78
76
|
readonly hasLeftMargin?: boolean;
|