@jobber/components 8.2.0 → 8.4.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/ActivityIndicator.d.ts +1 -0
- package/ActivityIndicator.js +17 -0
- package/dist/ActivityIndicator/ActivityIndicator.d.ts +38 -0
- package/dist/ActivityIndicator/index.cjs +9 -0
- package/dist/ActivityIndicator/index.d.ts +2 -0
- package/dist/ActivityIndicator/index.mjs +3 -0
- package/dist/ActivityIndicator-cjs.js +27 -0
- package/dist/ActivityIndicator-es.js +25 -0
- package/dist/Autocomplete/Autocomplete.d.ts +2 -3
- package/dist/Autocomplete/Autocomplete.types.d.ts +4 -9
- package/dist/Autocomplete/index.cjs +7 -8
- package/dist/Autocomplete/index.d.ts +3 -4
- package/dist/Autocomplete/index.mjs +6 -7
- package/dist/DataList/components/DataListSearch/index.cjs +1 -2
- package/dist/DataList/components/DataListSearch/index.mjs +1 -2
- package/dist/DataList/index.cjs +1 -2
- package/dist/DataList/index.mjs +1 -2
- package/dist/DataListSearch-cjs.js +12 -6
- package/dist/DataListSearch-es.js +11 -5
- package/dist/InputDate/index.cjs +1 -2
- package/dist/InputDate/index.mjs +1 -2
- package/dist/InputDate-cjs.js +2 -2
- package/dist/InputDate-es.js +2 -2
- package/dist/InputText/InputText.d.ts +2 -70
- package/dist/InputText/InputText.types.d.ts +2 -30
- package/dist/InputText/index.cjs +12 -268
- package/dist/InputText/index.d.ts +2 -5
- package/dist/InputText/index.mjs +11 -271
- package/dist/InputText/useInputTextActions.d.ts +2 -2
- package/dist/InputText-cjs.js +199 -0
- package/dist/InputText-es.js +197 -0
- package/dist/Spinner/Spinner.d.ts +6 -0
- package/dist/Spinner-cjs.js +3 -0
- package/dist/Spinner-es.js +3 -0
- package/dist/docs/ActivityIndicator/ActivityIndicator.md +67 -0
- package/dist/docs/Autocomplete/AutocompleteV1.md +1 -2
- package/dist/docs/Autocomplete/AutocompleteV2.md +1 -1
- package/dist/docs/Banner/Banner.md +2 -2
- package/dist/docs/Box/Box.md +2 -2
- package/dist/docs/Glimmer/Glimmer.md +1 -1
- package/dist/docs/Icon/Icon.md +1 -1
- package/dist/docs/InputText/InputText.md +152 -106
- package/dist/docs/Menu/Menu.md +1 -1
- package/dist/docs/Modal/Modal.md +1 -1
- package/dist/docs/Spinner/Spinner.md +9 -1
- package/dist/docs/Stack/Stack.md +1 -1
- package/dist/docs/index.md +1 -0
- package/dist/docs/usage-guidelines/usage-guidelines.md +0 -2
- package/dist/index.cjs +5 -3
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +3 -2
- package/dist/styles.css +279 -0
- package/dist/utils/meta/meta.json +1 -0
- package/package.json +8 -3
- package/dist/InputText/InputText.rebuilt.d.ts +0 -3
|
@@ -1,71 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
3
|
-
export declare const InputText: React.ForwardRefExoticComponent<
|
|
4
|
-
readonly multiline: true;
|
|
5
|
-
readonly rows?: (number | import("./InputText.types").RowRange) | undefined;
|
|
6
|
-
readonly id?: string | undefined;
|
|
7
|
-
readonly align?: ("center" | "right") | undefined;
|
|
8
|
-
readonly description?: React.ReactNode;
|
|
9
|
-
readonly disabled?: boolean | undefined;
|
|
10
|
-
readonly showMiniLabel?: boolean | undefined;
|
|
11
|
-
readonly invalid?: boolean | undefined;
|
|
12
|
-
readonly inline?: boolean | undefined;
|
|
13
|
-
loading?: boolean | undefined;
|
|
14
|
-
readonly name?: string | undefined;
|
|
15
|
-
onChange?: ((newValue: string | number | boolean | Date, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) => void) | undefined;
|
|
16
|
-
onValidation?: ((message: string) => void) | undefined;
|
|
17
|
-
readonly placeholder?: string | undefined;
|
|
18
|
-
readonly size?: ("small" | "large") | undefined;
|
|
19
|
-
readonly value?: (string | number | Date) | undefined;
|
|
20
|
-
readonly clearable?: import("@jobber/hooks").Clearable | undefined;
|
|
21
|
-
version?: 1 | undefined;
|
|
22
|
-
onFocus?: ((event?: React.FocusEvent) => void) | undefined;
|
|
23
|
-
onBlur?: ((event?: React.FocusEvent) => void) | undefined;
|
|
24
|
-
readonly toolbar?: React.ReactNode;
|
|
25
|
-
readonly defaultValue?: (string | Date) | undefined;
|
|
26
|
-
readonly prefix?: import("..").Affix | undefined;
|
|
27
|
-
readonly maxLength?: number | undefined;
|
|
28
|
-
readonly autofocus?: boolean | undefined;
|
|
29
|
-
readonly autocomplete?: (boolean | import("..").AutocompleteTypes) | undefined;
|
|
30
|
-
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined;
|
|
31
|
-
readonly keyboard?: ("numeric" | "decimal") | undefined;
|
|
32
|
-
readonly suffix?: import("ts-xor").XOR<import("..").Affix, import("..").Suffix> | undefined;
|
|
33
|
-
onEnter?: ((event: React.KeyboardEvent) => void) | undefined;
|
|
34
|
-
readonly readonly?: boolean | undefined;
|
|
35
|
-
readonly validations?: import("react-hook-form").RegisterOptions | undefined;
|
|
36
|
-
readonly toolbarVisibility?: ("always" | "while-editing") | undefined;
|
|
37
|
-
} | {
|
|
38
|
-
rows?: undefined;
|
|
39
|
-
multiline?: boolean | undefined;
|
|
40
|
-
readonly id?: string | undefined;
|
|
41
|
-
readonly align?: ("center" | "right") | undefined;
|
|
42
|
-
readonly description?: React.ReactNode;
|
|
43
|
-
readonly disabled?: boolean | undefined;
|
|
44
|
-
readonly showMiniLabel?: boolean | undefined;
|
|
45
|
-
readonly invalid?: boolean | undefined;
|
|
46
|
-
readonly inline?: boolean | undefined;
|
|
47
|
-
loading?: boolean | undefined;
|
|
48
|
-
readonly name?: string | undefined;
|
|
49
|
-
onChange?: ((newValue: string | number | boolean | Date, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) => void) | undefined;
|
|
50
|
-
onValidation?: ((message: string) => void) | undefined;
|
|
51
|
-
readonly placeholder?: string | undefined;
|
|
52
|
-
readonly size?: ("small" | "large") | undefined;
|
|
53
|
-
readonly value?: (string | number | Date) | undefined;
|
|
54
|
-
readonly clearable?: import("@jobber/hooks").Clearable | undefined;
|
|
55
|
-
version?: 1 | undefined;
|
|
56
|
-
onFocus?: ((event?: React.FocusEvent) => void) | undefined;
|
|
57
|
-
onBlur?: ((event?: React.FocusEvent) => void) | undefined;
|
|
58
|
-
readonly toolbar?: React.ReactNode;
|
|
59
|
-
readonly defaultValue?: (string | Date) | undefined;
|
|
60
|
-
readonly prefix?: import("..").Affix | undefined;
|
|
61
|
-
readonly maxLength?: number | undefined;
|
|
62
|
-
readonly autofocus?: boolean | undefined;
|
|
63
|
-
readonly autocomplete?: (boolean | import("..").AutocompleteTypes) | undefined;
|
|
64
|
-
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined;
|
|
65
|
-
readonly keyboard?: ("numeric" | "decimal") | undefined;
|
|
66
|
-
readonly suffix?: import("ts-xor").XOR<import("..").Affix, import("..").Suffix> | undefined;
|
|
67
|
-
onEnter?: ((event: React.KeyboardEvent) => void) | undefined;
|
|
68
|
-
readonly readonly?: boolean | undefined;
|
|
69
|
-
readonly validations?: import("react-hook-form").RegisterOptions | undefined;
|
|
70
|
-
readonly toolbarVisibility?: ("always" | "while-editing") | undefined;
|
|
71
|
-
}) & React.RefAttributes<InputTextRef>>;
|
|
2
|
+
import type { InputTextProps } from "./InputText.types";
|
|
3
|
+
export declare const InputText: React.ForwardRefExoticComponent<InputTextProps & React.RefAttributes<HTMLInputElement | HTMLTextAreaElement>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
1
|
+
import type { FormFieldProps } from "../FormField";
|
|
3
2
|
import type { FocusEvents, HTMLInputBaseProps, KeyboardEvents, MouseEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
|
|
4
3
|
export interface RowRange {
|
|
5
4
|
min: number;
|
|
@@ -16,12 +15,11 @@ interface InputLengthConstraint {
|
|
|
16
15
|
*/
|
|
17
16
|
readonly maxLength?: number;
|
|
18
17
|
}
|
|
19
|
-
export type InputTextVersion = 1 | 2 | undefined;
|
|
20
18
|
/**
|
|
21
19
|
* Experimental version 2 of the InputText component.
|
|
22
20
|
* Do not use unless you have talked with Atlantis first.
|
|
23
21
|
*/
|
|
24
|
-
export interface
|
|
22
|
+
export interface InputTextProps extends HTMLInputBaseProps, MouseEvents<HTMLInputElement | HTMLTextAreaElement>, FocusEvents<HTMLInputElement | HTMLTextAreaElement>, KeyboardEvents<HTMLInputElement | HTMLTextAreaElement>, Omit<RebuiltInputCommonProps, "version">, InputLengthConstraint {
|
|
25
23
|
/**
|
|
26
24
|
* When false, the placeholder text only serves as a standard placeholder and
|
|
27
25
|
* disappears when the user types, instead of floating above the value as a
|
|
@@ -61,30 +59,4 @@ export interface InputTextRebuiltProps extends HTMLInputBaseProps, MouseEvents<H
|
|
|
61
59
|
*/
|
|
62
60
|
readonly onEnter?: FormFieldProps["onEnter"];
|
|
63
61
|
}
|
|
64
|
-
interface BaseProps extends CommonFormFieldProps, Pick<FormFieldProps, "autofocus" | "maxLength" | "readonly" | "autocomplete" | "keyboard" | "onEnter" | "onFocus" | "onBlur" | "onChange" | "inputRef" | "validations" | "defaultValue" | "prefix" | "suffix" | "toolbar" | "toolbarVisibility" | "version"> {
|
|
65
|
-
multiline?: boolean;
|
|
66
|
-
}
|
|
67
|
-
export interface InputTextRef {
|
|
68
|
-
insert(text: string): void;
|
|
69
|
-
blur(): void;
|
|
70
|
-
focus(): void;
|
|
71
|
-
scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
|
|
72
|
-
}
|
|
73
|
-
interface MultilineProps extends BaseProps {
|
|
74
|
-
/**
|
|
75
|
-
* Use this when you're expecting a long answer.
|
|
76
|
-
*/
|
|
77
|
-
readonly multiline: true;
|
|
78
|
-
/**
|
|
79
|
-
* Specifies the visible height of a long answer form field. Can be in the
|
|
80
|
-
* form of a single number to set a static height, or an object with a min
|
|
81
|
-
* and max keys indicating the minimum number of visible rows, and the
|
|
82
|
-
* maximum number of visible rows.
|
|
83
|
-
*/
|
|
84
|
-
readonly rows?: number | RowRange;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* @deprecated Use the v2 InputText component instead (version={2}).
|
|
88
|
-
*/
|
|
89
|
-
export type InputTextLegacyProps = XOR<BaseProps, MultilineProps>;
|
|
90
62
|
export {};
|
package/dist/InputText/index.cjs
CHANGED
|
@@ -1,283 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
require('
|
|
7
|
-
require('../tslib.es6-cjs.js');
|
|
8
|
-
require('react-hook-form');
|
|
3
|
+
var InputText = require('../InputText-cjs.js');
|
|
4
|
+
require('react');
|
|
5
|
+
require('@jobber/hooks');
|
|
6
|
+
require('../FormFieldWrapper-cjs.js');
|
|
9
7
|
require('framer-motion');
|
|
10
8
|
require('@jobber/design');
|
|
9
|
+
require('classnames');
|
|
11
10
|
require('../Button-cjs.js');
|
|
12
|
-
|
|
13
|
-
var FormFieldPostFix = require('../FormFieldPostFix-cjs.js');
|
|
14
|
-
var useAtlantisFormFieldName = require('../useAtlantisFormFieldName-cjs.js');
|
|
15
|
-
var mergeRefs = require('../mergeRefs-cjs.js');
|
|
16
|
-
var filterDataAttributes = require('../filterDataAttributes-cjs.js');
|
|
11
|
+
require('../tslib.es6-cjs.js');
|
|
17
12
|
require('react-router-dom');
|
|
18
13
|
require('../Icon-cjs.js');
|
|
19
14
|
require('../Typography-cjs.js');
|
|
20
15
|
require('../Text-cjs.js');
|
|
21
16
|
require('../useFormFieldFocus-cjs.js');
|
|
22
17
|
require('../InputValidation-cjs.js');
|
|
18
|
+
require('../FormFieldPostFix-cjs.js');
|
|
23
19
|
require('../Spinner-cjs.js');
|
|
20
|
+
require('../useAtlantisFormFieldName-cjs.js');
|
|
21
|
+
require('react-hook-form');
|
|
22
|
+
require('../mergeRefs-cjs.js');
|
|
23
|
+
require('../filterDataAttributes-cjs.js');
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
|
|
27
|
-
*/
|
|
28
|
-
function useTextAreaResize({ rows, value, inputRef, wrapperRef, }) {
|
|
29
|
-
const rowRange = getRowRange(rows);
|
|
30
|
-
jobberHooks.useSafeLayoutEffect(() => {
|
|
31
|
-
if (inputRef &&
|
|
32
|
-
inputRef.current instanceof HTMLTextAreaElement &&
|
|
33
|
-
wrapperRef &&
|
|
34
|
-
wrapperRef.current instanceof HTMLDivElement) {
|
|
35
|
-
resize();
|
|
36
|
-
}
|
|
37
|
-
}, [inputRef.current, wrapperRef.current]);
|
|
38
|
-
// When the consumer passes a new controlled value, we need to recheck the size.
|
|
39
|
-
// The timeout ensures the DOM has a enough time to render the new text before
|
|
40
|
-
// we access the height.
|
|
41
|
-
jobberHooks.useSafeLayoutEffect(() => {
|
|
42
|
-
setTimeout(() => {
|
|
43
|
-
if (inputRef &&
|
|
44
|
-
inputRef.current instanceof HTMLTextAreaElement &&
|
|
45
|
-
wrapperRef &&
|
|
46
|
-
wrapperRef.current instanceof HTMLDivElement) {
|
|
47
|
-
resize();
|
|
48
|
-
}
|
|
49
|
-
}, 0);
|
|
50
|
-
}, [value]);
|
|
51
|
-
function resize() {
|
|
52
|
-
if (inputRef &&
|
|
53
|
-
inputRef.current instanceof HTMLTextAreaElement &&
|
|
54
|
-
wrapperRef &&
|
|
55
|
-
(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) instanceof HTMLDivElement) {
|
|
56
|
-
if (rowRange.min === rowRange.max)
|
|
57
|
-
return;
|
|
58
|
-
inputRef.current.style.flexBasis = "auto";
|
|
59
|
-
wrapperRef.current.style.height = "auto";
|
|
60
|
-
inputRef.current.style.flexBasis =
|
|
61
|
-
textAreaHeight(inputRef.current) + "px";
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function textAreaHeight(textArea) {
|
|
65
|
-
const { lineHeight, borderBottomWidth, borderTopWidth, paddingBottom, paddingTop, } = window.getComputedStyle(textArea);
|
|
66
|
-
const maxHeight = rowRange.max * parseFloat(lineHeight) +
|
|
67
|
-
parseFloat(borderTopWidth) +
|
|
68
|
-
parseFloat(borderBottomWidth) +
|
|
69
|
-
parseFloat(paddingTop) +
|
|
70
|
-
parseFloat(paddingBottom);
|
|
71
|
-
const scrollHeight = textArea.scrollHeight +
|
|
72
|
-
parseFloat(borderTopWidth) +
|
|
73
|
-
parseFloat(borderBottomWidth);
|
|
74
|
-
return Math.min(scrollHeight, maxHeight);
|
|
75
|
-
}
|
|
76
|
-
return { resize, rowRange };
|
|
77
|
-
}
|
|
78
|
-
function getRowRange(rows) {
|
|
79
|
-
if (rows === undefined) {
|
|
80
|
-
return { min: 3, max: 3 };
|
|
81
|
-
}
|
|
82
|
-
else if (typeof rows === "object") {
|
|
83
|
-
return { min: rows.min, max: rows.max };
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
return { min: rows, max: rows };
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function InputTextInternal(
|
|
91
|
-
// eslint-disable-next-line import/no-deprecated
|
|
92
|
-
props, ref) {
|
|
93
|
-
const inputRef = React.useRef(null);
|
|
94
|
-
const actionsRef = React.useRef(null);
|
|
95
|
-
const wrapperRef = React.useRef(null);
|
|
96
|
-
const { resize, rowRange } = useTextAreaResize({
|
|
97
|
-
rows: props.rows,
|
|
98
|
-
value: props.value,
|
|
99
|
-
inputRef,
|
|
100
|
-
wrapperRef,
|
|
101
|
-
});
|
|
102
|
-
React.useImperativeHandle(ref, () => ({
|
|
103
|
-
insert: (text) => {
|
|
104
|
-
insertText(text);
|
|
105
|
-
},
|
|
106
|
-
blur: () => {
|
|
107
|
-
const input = inputRef.current;
|
|
108
|
-
if (input) {
|
|
109
|
-
input.blur();
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
focus: () => {
|
|
113
|
-
const input = inputRef.current;
|
|
114
|
-
if (input) {
|
|
115
|
-
input.focus();
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
scrollIntoView: arg => {
|
|
119
|
-
const input = inputRef.current;
|
|
120
|
-
if (input) {
|
|
121
|
-
input.scrollIntoView(arg);
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
}));
|
|
125
|
-
return (React.createElement(FormField.FormField, Object.assign({}, props, { type: props.multiline ? "textarea" : "text", inputRef: inputRef, actionsRef: actionsRef, wrapperRef: wrapperRef, onChange: handleChange, rows: rowRange.min })));
|
|
126
|
-
function handleChange(newValue) {
|
|
127
|
-
props.onChange && props.onChange(newValue);
|
|
128
|
-
resize();
|
|
129
|
-
}
|
|
130
|
-
function insertText(text) {
|
|
131
|
-
var _a;
|
|
132
|
-
const input = inputRef.current;
|
|
133
|
-
if (input) {
|
|
134
|
-
insertAtCursor(input, text);
|
|
135
|
-
const newValue = input.value;
|
|
136
|
-
(_a = actionsRef.current) === null || _a === void 0 ? void 0 : _a.setValue(newValue);
|
|
137
|
-
props.onChange && props.onChange(newValue);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
const InputText$1 = React.forwardRef(InputTextInternal);
|
|
142
|
-
function insertAtCursor(input, newText) {
|
|
143
|
-
const start = input.selectionStart || 0;
|
|
144
|
-
const end = input.selectionEnd || 0;
|
|
145
|
-
const text = input.value;
|
|
146
|
-
const before = text.substring(0, start);
|
|
147
|
-
const after = text.substring(end, text.length);
|
|
148
|
-
input.value = before + newText + after;
|
|
149
|
-
input.selectionStart = input.selectionEnd = start + newText.length;
|
|
150
|
-
input.focus();
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Combines the actions on the InputText such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputText.
|
|
155
|
-
* DO not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
|
|
156
|
-
*/
|
|
157
|
-
function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, onKeyUp, onMouseDown, onMouseUp, onPointerDown, onPointerUp, onClick, }) {
|
|
158
|
-
function handleClear() {
|
|
159
|
-
var _a;
|
|
160
|
-
onChange && onChange("");
|
|
161
|
-
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
162
|
-
}
|
|
163
|
-
function handleChange(event) {
|
|
164
|
-
const newValue = event.currentTarget.value;
|
|
165
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, event);
|
|
166
|
-
}
|
|
167
|
-
function handleKeyDown(event) {
|
|
168
|
-
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
169
|
-
if (!onEnter)
|
|
170
|
-
return;
|
|
171
|
-
if (event.key !== "Enter")
|
|
172
|
-
return;
|
|
173
|
-
if (event.shiftKey || event.ctrlKey)
|
|
174
|
-
return;
|
|
175
|
-
event.preventDefault();
|
|
176
|
-
onEnter && onEnter(event);
|
|
177
|
-
}
|
|
178
|
-
function handleKeyUp(event) {
|
|
179
|
-
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event);
|
|
180
|
-
}
|
|
181
|
-
function handleFocus(event) {
|
|
182
|
-
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
183
|
-
}
|
|
184
|
-
function handleBlur(event) {
|
|
185
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
186
|
-
}
|
|
187
|
-
function handleMouseDown(event) {
|
|
188
|
-
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
189
|
-
}
|
|
190
|
-
function handleMouseUp(event) {
|
|
191
|
-
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
192
|
-
}
|
|
193
|
-
function handlePointerDown(event) {
|
|
194
|
-
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
195
|
-
}
|
|
196
|
-
function handlePointerUp(event) {
|
|
197
|
-
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
198
|
-
}
|
|
199
|
-
function handleClick(event) {
|
|
200
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
201
|
-
}
|
|
202
|
-
return {
|
|
203
|
-
handleClear,
|
|
204
|
-
handleChange,
|
|
205
|
-
handleKeyDown,
|
|
206
|
-
handleKeyUp,
|
|
207
|
-
handleFocus,
|
|
208
|
-
handleBlur,
|
|
209
|
-
handleMouseDown,
|
|
210
|
-
handleMouseUp,
|
|
211
|
-
handlePointerDown,
|
|
212
|
-
handlePointerUp,
|
|
213
|
-
handleClick,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRef) {
|
|
218
|
-
var _a, _b, _c;
|
|
219
|
-
const inputTextRef = React.useRef(null), wrapperRef = React.useRef(null);
|
|
220
|
-
const id = useInputTextId(props);
|
|
221
|
-
const { rowRange } = useTextAreaResize({
|
|
222
|
-
rows: props.rows,
|
|
223
|
-
value: props.value,
|
|
224
|
-
inputRef: inputTextRef,
|
|
225
|
-
wrapperRef: wrapperRef,
|
|
226
|
-
});
|
|
227
|
-
const { name } = useAtlantisFormFieldName.useAtlantisFormFieldName({
|
|
228
|
-
nameProp: props.name,
|
|
229
|
-
id: id,
|
|
230
|
-
});
|
|
231
|
-
const { handleChange, handleBlur, handleFocus, handleKeyDown, handleKeyUp, handleClear, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, handleClick, } = useInputTextActions({
|
|
232
|
-
onChange: props.onChange,
|
|
233
|
-
onBlur: props.onBlur,
|
|
234
|
-
onFocus: props.onFocus,
|
|
235
|
-
onMouseDown: props.onMouseDown,
|
|
236
|
-
onMouseUp: props.onMouseUp,
|
|
237
|
-
onPointerDown: props.onPointerDown,
|
|
238
|
-
onPointerUp: props.onPointerUp,
|
|
239
|
-
onClick: props.onClick,
|
|
240
|
-
onKeyDown: props.onKeyDown,
|
|
241
|
-
onKeyUp: props.onKeyUp,
|
|
242
|
-
onEnter: props.onEnter,
|
|
243
|
-
inputRef: inputTextRef,
|
|
244
|
-
});
|
|
245
|
-
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
246
|
-
const descriptionVisible = props.description && !props.inline;
|
|
247
|
-
const isInvalid = Boolean(props.error || props.invalid);
|
|
248
|
-
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
249
|
-
const mergedRef = React.useMemo(() => mergeRefs.mergeRefs([inputRef, inputTextRef]), []);
|
|
250
|
-
// Shared props for both TextArea and TextInput
|
|
251
|
-
const commonInputProps = Object.assign({ id,
|
|
252
|
-
name, className: FormFieldWrapper.formFieldStyles.input, value: props.value, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, maxLength: props.maxLength, required: props.required, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
|
|
253
|
-
? descriptionIdentifier
|
|
254
|
-
: props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onClick: handleClick, ref: mergedRef }, dataAttrs);
|
|
255
|
-
return (React.createElement(FormFieldWrapper.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, name: name, wrapperRef: wrapperRef, error: (_a = props.error) !== null && _a !== void 0 ? _a : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: props.multiline ? "textarea" : "text", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, readonly: props.readOnly, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility, showMiniLabel: props.showMiniLabel },
|
|
256
|
-
React.createElement(React.Fragment, null,
|
|
257
|
-
props.multiline ? (React.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
|
|
258
|
-
React.createElement(FormFieldPostFix.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
|
|
259
|
-
});
|
|
260
|
-
function useInputTextId(props) {
|
|
261
|
-
const generatedId = React.useId();
|
|
262
|
-
return props.id || generatedId;
|
|
263
|
-
}
|
|
264
|
-
const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
265
|
-
return React.createElement("textarea", Object.assign({}, props, { ref: ref }));
|
|
266
|
-
});
|
|
267
|
-
const TextInput = React.forwardRef(function TextInput(props, ref) {
|
|
268
|
-
return React.createElement("input", Object.assign({}, props, { ref: ref }));
|
|
269
|
-
});
|
|
270
25
|
|
|
271
|
-
function isNewInputTextProps(props) {
|
|
272
|
-
return props.version === 2;
|
|
273
|
-
}
|
|
274
|
-
const InputText = React.forwardRef(function InputTextShim(props, ref) {
|
|
275
|
-
if (isNewInputTextProps(props)) {
|
|
276
|
-
return (React.createElement(InputTextSPAR, Object.assign({}, props, { ref: ref })));
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
return (React.createElement(InputText$1, Object.assign({}, props, { ref: ref })));
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
26
|
|
|
283
|
-
exports.InputText = InputText;
|
|
27
|
+
exports.InputText = InputText.InputText;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type InputTextShimProps = InputTextLegacyProps | InputTextRebuiltProps;
|
|
4
|
-
export declare const InputText: React.ForwardRefExoticComponent<InputTextShimProps & React.RefAttributes<HTMLInputElement | HTMLTextAreaElement | InputTextRef>>;
|
|
5
|
-
export type { InputTextRef, InputTextRebuiltProps, InputTextLegacyProps };
|
|
1
|
+
export { InputText } from "./InputText";
|
|
2
|
+
export type { InputTextProps } from "./InputText.types";
|