@jobber/components 6.11.3 → 6.11.5
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/Autocomplete/index.cjs +11 -2
- package/dist/Autocomplete/index.mjs +11 -2
- package/dist/Autocomplete-cjs.js +2 -2
- package/dist/Autocomplete-es.js +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
- package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
- package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
- package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
- package/dist/Chips/index.cjs +2 -2
- package/dist/Chips/index.mjs +2 -2
- package/dist/DataList/components/DataListSearch/index.cjs +10 -1
- package/dist/DataList/components/DataListSearch/index.mjs +10 -1
- package/dist/DataList/index.cjs +8 -1
- package/dist/DataList/index.mjs +8 -1
- package/dist/DataListSearch-cjs.js +2 -2
- package/dist/DataListSearch-es.js +1 -1
- package/dist/DatePicker/index.cjs +3 -2
- package/dist/DatePicker/index.mjs +3 -2
- package/dist/DatePicker-cjs.js +2 -781
- package/dist/DatePicker-es.js +3 -781
- package/dist/FormField/FormFieldTypes.d.ts +3 -3
- package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +3 -3
- package/dist/FormField-cjs.js +5 -2
- package/dist/FormField-es.js +3 -3
- package/dist/InputDate/index.cjs +16 -15
- package/dist/InputDate/index.mjs +16 -15
- package/dist/InputDate-cjs.js +3 -2
- package/dist/InputDate-es.js +2 -1
- package/dist/InputText/InputText.d.ts +10 -20
- package/dist/InputText/InputText.rebuilt.d.ts +3 -0
- package/dist/InputText/InputText.types.d.ts +78 -0
- package/dist/InputText/index.cjs +263 -8
- package/dist/InputText/index.d.ts +5 -1
- package/dist/InputText/index.mjs +266 -7
- package/dist/InputText/useInputTextActions.d.ts +16 -0
- package/dist/InputText/useInputTextFormField.d.ts +347 -0
- package/dist/InputText/useTextAreaResize.d.ts +14 -0
- package/dist/List/index.cjs +2 -2
- package/dist/List/index.mjs +2 -2
- package/dist/_baseEach-cjs.js +12 -12
- package/dist/_baseEach-es.js +2 -2
- package/dist/_baseFlatten-cjs.js +2 -2
- package/dist/_baseFlatten-es.js +1 -1
- package/dist/{_getAllKeys-cjs.js → _baseGet-cjs.js} +181 -181
- package/dist/{_getAllKeys-es.js → _baseGet-es.js} +183 -183
- package/dist/index.cjs +4 -3
- package/dist/index.mjs +3 -2
- package/dist/isTypedArray-es.js +1 -1
- package/dist/omit-cjs.js +783 -0
- package/dist/omit-es.js +781 -0
- package/dist/styles.css +0 -1
- package/dist/useScrollToActive-cjs.js +3 -3
- package/dist/useScrollToActive-es.js +1 -1
- package/package.json +2 -2
- package/dist/InputText-cjs.js +0 -129
- package/dist/InputText-es.js +0 -127
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent, ReactNode, RefObject } from "react";
|
|
1
|
+
import React, { ChangeEvent, ReactNode, RefObject } from "react";
|
|
2
2
|
import { RegisterOptions } from "react-hook-form";
|
|
3
3
|
import { XOR } from "ts-xor";
|
|
4
4
|
import { Clearable } from "@jobber/hooks/src/useShowClear";
|
|
@@ -156,11 +156,11 @@ export interface FormFieldProps extends CommonFormFieldProps {
|
|
|
156
156
|
/**
|
|
157
157
|
* Focus callback.
|
|
158
158
|
*/
|
|
159
|
-
onFocus?(): void;
|
|
159
|
+
onFocus?(event?: React.FocusEvent): void;
|
|
160
160
|
/**
|
|
161
161
|
* Blur callback.
|
|
162
162
|
*/
|
|
163
|
-
onBlur?(): void;
|
|
163
|
+
onBlur?(event?: React.FocusEvent): void;
|
|
164
164
|
onKeyUp?(event: React.KeyboardEvent<HTMLInputElement>): void;
|
|
165
165
|
/**
|
|
166
166
|
* Exclusively for textareas. Specifies the visible height of a textarea.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
2
|
import { FormFieldProps } from "../FormFieldTypes";
|
|
3
3
|
export interface useFormFieldWrapperStylesProps extends Pick<FormFieldProps, "size" | "align" | "placeholder" | "value" | "invalid" | "max" | "maxLength" | "type" | "disabled" | "inline"> {
|
|
4
|
-
readonly error
|
|
5
|
-
suffixRef
|
|
6
|
-
prefixRef
|
|
4
|
+
readonly error?: string;
|
|
5
|
+
suffixRef?: RefObject<HTMLDivElement>;
|
|
6
|
+
prefixRef?: RefObject<HTMLDivElement>;
|
|
7
7
|
}
|
|
8
8
|
export interface LabelPadding {
|
|
9
9
|
paddingLeft: number | string | undefined;
|
package/dist/FormField-cjs.js
CHANGED
|
@@ -132,8 +132,8 @@ function useFormFieldWrapperStyles({ size, align, placeholder, value, invalid, e
|
|
|
132
132
|
setLabelStyle(getAffixPaddding({
|
|
133
133
|
value,
|
|
134
134
|
type,
|
|
135
|
-
prefixWidth: ((_a = prefixRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0,
|
|
136
|
-
suffixWidth: ((_b = suffixRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0,
|
|
135
|
+
prefixWidth: ((_a = prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0,
|
|
136
|
+
suffixWidth: ((_b = suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0,
|
|
137
137
|
}));
|
|
138
138
|
}, [value]);
|
|
139
139
|
return {
|
|
@@ -451,7 +451,10 @@ function setAutocomplete(autocompleteSetting) {
|
|
|
451
451
|
}
|
|
452
452
|
|
|
453
453
|
exports.FormField = FormField;
|
|
454
|
+
exports.FormFieldPostFix = FormFieldPostFix;
|
|
454
455
|
exports.FormFieldWrapper = FormFieldWrapper;
|
|
456
|
+
exports.mergeRefs = mergeRefs;
|
|
457
|
+
exports.styles = styles$1;
|
|
455
458
|
exports.useAtlantisFormField = useAtlantisFormField;
|
|
456
459
|
exports.useAtlantisFormFieldActions = useAtlantisFormFieldActions;
|
|
457
460
|
exports.useAtlantisFormFieldName = useAtlantisFormFieldName;
|
package/dist/FormField-es.js
CHANGED
|
@@ -130,8 +130,8 @@ function useFormFieldWrapperStyles({ size, align, placeholder, value, invalid, e
|
|
|
130
130
|
setLabelStyle(getAffixPaddding({
|
|
131
131
|
value,
|
|
132
132
|
type,
|
|
133
|
-
prefixWidth: ((_a = prefixRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0,
|
|
134
|
-
suffixWidth: ((_b = suffixRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0,
|
|
133
|
+
prefixWidth: ((_a = prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0,
|
|
134
|
+
suffixWidth: ((_b = suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0,
|
|
135
135
|
}));
|
|
136
136
|
}, [value]);
|
|
137
137
|
return {
|
|
@@ -448,4 +448,4 @@ function setAutocomplete(autocompleteSetting) {
|
|
|
448
448
|
return autocompleteSetting;
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
-
export { FormFieldWrapper as F, useAtlantisFormFieldActions as a, useAtlantisFormFieldName as b, useAtlantisReactHookForm as c, useFormFieldWrapperStyles as d, FormField as e, useAtlantisFormField as u };
|
|
451
|
+
export { FormFieldWrapper as F, useAtlantisFormFieldActions as a, useAtlantisFormFieldName as b, useAtlantisReactHookForm as c, useFormFieldWrapperStyles as d, FormField as e, FormFieldPostFix as f, mergeRefs as m, styles$1 as s, useAtlantisFormField as u };
|
package/dist/InputDate/index.cjs
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var InputDate = require('../InputDate-cjs.js');
|
|
4
|
-
require('../
|
|
5
|
-
require('react');
|
|
6
|
-
require('classnames');
|
|
7
|
-
require('../index-cjs.js');
|
|
4
|
+
require('../omit-cjs.js');
|
|
8
5
|
require('../_commonjsHelpers-cjs.js');
|
|
9
|
-
require('
|
|
10
|
-
require('react-popper');
|
|
11
|
-
require('../useRefocusOnActivator-cjs.js');
|
|
12
|
-
require('../Typography-cjs.js');
|
|
13
|
-
require('../Button-cjs.js');
|
|
14
|
-
require('react-router-dom');
|
|
15
|
-
require('../Icon-cjs.js');
|
|
16
|
-
require('@jobber/design');
|
|
17
|
-
require('../_getAllKeys-cjs.js');
|
|
6
|
+
require('../_baseGet-cjs.js');
|
|
18
7
|
require('../isTypedArray-cjs.js');
|
|
19
8
|
require('../isObjectLike-cjs.js');
|
|
20
|
-
require('../isSymbol-cjs.js');
|
|
21
9
|
require('../identity-cjs.js');
|
|
22
10
|
require('../_getTag-cjs.js');
|
|
11
|
+
require('../isSymbol-cjs.js');
|
|
23
12
|
require('../keysIn-cjs.js');
|
|
24
13
|
require('../_baseAssignValue-cjs.js');
|
|
25
14
|
require('../_baseFlatten-cjs.js');
|
|
26
15
|
require('../_setToString-cjs.js');
|
|
27
|
-
require('
|
|
16
|
+
require('react');
|
|
28
17
|
require('../FormField-cjs.js');
|
|
29
18
|
require('framer-motion');
|
|
19
|
+
require('@jobber/design');
|
|
20
|
+
require('classnames');
|
|
21
|
+
require('../Button-cjs.js');
|
|
22
|
+
require('react-router-dom');
|
|
23
|
+
require('../Icon-cjs.js');
|
|
24
|
+
require('../Typography-cjs.js');
|
|
30
25
|
require('../Text-cjs.js');
|
|
31
26
|
require('../useFormFieldFocus-cjs.js');
|
|
32
27
|
require('../InputValidation-cjs.js');
|
|
33
28
|
require('../Spinner-cjs.js');
|
|
34
29
|
require('../tslib.es6-cjs.js');
|
|
35
30
|
require('react-hook-form');
|
|
31
|
+
require('../DatePicker-cjs.js');
|
|
32
|
+
require('../index-cjs.js');
|
|
33
|
+
require('react-dom');
|
|
34
|
+
require('react-popper');
|
|
35
|
+
require('../useRefocusOnActivator-cjs.js');
|
|
36
|
+
require('../AtlantisContext-cjs.js');
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
|
package/dist/InputDate/index.mjs
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
export { I as InputDate } from '../InputDate-es.js';
|
|
2
|
-
import '../
|
|
3
|
-
import 'react';
|
|
4
|
-
import 'classnames';
|
|
5
|
-
import '../index-es.js';
|
|
2
|
+
import '../omit-es.js';
|
|
6
3
|
import '../_commonjsHelpers-es.js';
|
|
7
|
-
import '
|
|
8
|
-
import 'react-popper';
|
|
9
|
-
import '../useRefocusOnActivator-es.js';
|
|
10
|
-
import '../Typography-es.js';
|
|
11
|
-
import '../Button-es.js';
|
|
12
|
-
import 'react-router-dom';
|
|
13
|
-
import '../Icon-es.js';
|
|
14
|
-
import '@jobber/design';
|
|
15
|
-
import '../_getAllKeys-es.js';
|
|
4
|
+
import '../_baseGet-es.js';
|
|
16
5
|
import '../isTypedArray-es.js';
|
|
17
6
|
import '../isObjectLike-es.js';
|
|
18
|
-
import '../isSymbol-es.js';
|
|
19
7
|
import '../identity-es.js';
|
|
20
8
|
import '../_getTag-es.js';
|
|
9
|
+
import '../isSymbol-es.js';
|
|
21
10
|
import '../keysIn-es.js';
|
|
22
11
|
import '../_baseAssignValue-es.js';
|
|
23
12
|
import '../_baseFlatten-es.js';
|
|
24
13
|
import '../_setToString-es.js';
|
|
25
|
-
import '
|
|
14
|
+
import 'react';
|
|
26
15
|
import '../FormField-es.js';
|
|
27
16
|
import 'framer-motion';
|
|
17
|
+
import '@jobber/design';
|
|
18
|
+
import 'classnames';
|
|
19
|
+
import '../Button-es.js';
|
|
20
|
+
import 'react-router-dom';
|
|
21
|
+
import '../Icon-es.js';
|
|
22
|
+
import '../Typography-es.js';
|
|
28
23
|
import '../Text-es.js';
|
|
29
24
|
import '../useFormFieldFocus-es.js';
|
|
30
25
|
import '../InputValidation-es.js';
|
|
31
26
|
import '../Spinner-es.js';
|
|
32
27
|
import '../tslib.es6-es.js';
|
|
33
28
|
import 'react-hook-form';
|
|
29
|
+
import '../DatePicker-es.js';
|
|
30
|
+
import '../index-es.js';
|
|
31
|
+
import 'react-dom';
|
|
32
|
+
import 'react-popper';
|
|
33
|
+
import '../useRefocusOnActivator-es.js';
|
|
34
|
+
import '../AtlantisContext-es.js';
|
package/dist/InputDate-cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var omit = require('./omit-cjs.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var FormField = require('./FormField-cjs.js');
|
|
6
6
|
require('./tslib.es6-cjs.js');
|
|
@@ -9,12 +9,13 @@ require('framer-motion');
|
|
|
9
9
|
require('@jobber/design');
|
|
10
10
|
require('classnames');
|
|
11
11
|
require('react-router-dom');
|
|
12
|
+
var DatePicker = require('./DatePicker-cjs.js');
|
|
12
13
|
|
|
13
14
|
function InputDate(inputProps) {
|
|
14
15
|
const formFieldActionsRef = React.useRef(null);
|
|
15
16
|
return (React.createElement(DatePicker.DatePicker, { selected: inputProps.value, onChange: inputProps.onChange, disabled: inputProps.disabled, readonly: inputProps.readonly, fullWidth: !inputProps.inline, minDate: inputProps.minDate, maxDate: inputProps.maxDate, smartAutofocus: false, activator: activatorProps => {
|
|
16
17
|
const { onChange, onClick, value } = activatorProps;
|
|
17
|
-
const newActivatorProps =
|
|
18
|
+
const newActivatorProps = omit.omit(activatorProps, ["activator"]);
|
|
18
19
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
19
20
|
const suffix = inputProps.showIcon !== false
|
|
20
21
|
? {
|
package/dist/InputDate-es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as omit } from './omit-es.js';
|
|
2
2
|
import React, { useRef, useState, useEffect } from 'react';
|
|
3
3
|
import { e as FormField } from './FormField-es.js';
|
|
4
4
|
import './tslib.es6-es.js';
|
|
@@ -7,6 +7,7 @@ import 'framer-motion';
|
|
|
7
7
|
import '@jobber/design';
|
|
8
8
|
import 'classnames';
|
|
9
9
|
import 'react-router-dom';
|
|
10
|
+
import { D as DatePicker } from './DatePicker-es.js';
|
|
10
11
|
|
|
11
12
|
function InputDate(inputProps) {
|
|
12
13
|
const formFieldActionsRef = useRef(null);
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
export interface RowRange {
|
|
4
|
-
min: number;
|
|
5
|
-
max: number;
|
|
6
|
-
}
|
|
7
|
-
export interface InputTextRef {
|
|
8
|
-
insert(text: string): void;
|
|
9
|
-
blur(): void;
|
|
10
|
-
focus(): void;
|
|
11
|
-
scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
|
|
12
|
-
}
|
|
2
|
+
import { InputTextRef } from "./InputText.types";
|
|
13
3
|
export declare const InputText: React.ForwardRefExoticComponent<({
|
|
14
4
|
readonly multiline: true;
|
|
15
|
-
readonly rows?: (number | RowRange) | undefined;
|
|
5
|
+
readonly rows?: (number | import("./InputText.types").RowRange) | undefined;
|
|
16
6
|
readonly align?: ("center" | "right") | undefined;
|
|
17
7
|
readonly description?: string | undefined;
|
|
18
8
|
readonly disabled?: boolean | undefined;
|
|
@@ -25,10 +15,10 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
25
15
|
readonly placeholder?: string | undefined;
|
|
26
16
|
readonly size?: ("small" | "large") | undefined;
|
|
27
17
|
readonly value?: (string | number | Date) | undefined;
|
|
28
|
-
readonly clearable?: import("@jobber/hooks/
|
|
18
|
+
readonly clearable?: import("@jobber/hooks/dist").Clearable | undefined;
|
|
29
19
|
version?: 1 | undefined;
|
|
30
|
-
onFocus?: (() => void) | undefined;
|
|
31
|
-
onBlur?: (() => void) | undefined;
|
|
20
|
+
onFocus?: ((event?: React.FocusEvent) => void) | undefined;
|
|
21
|
+
onBlur?: ((event?: React.FocusEvent) => void) | undefined;
|
|
32
22
|
readonly toolbar?: React.ReactNode;
|
|
33
23
|
readonly defaultValue?: (string | Date) | undefined;
|
|
34
24
|
readonly prefix?: import("../FormField").Affix | undefined;
|
|
@@ -37,7 +27,7 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
37
27
|
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
|
|
38
28
|
readonly keyboard?: ("numeric" | "decimal") | undefined;
|
|
39
29
|
readonly maxLength?: number | undefined;
|
|
40
|
-
readonly suffix?: XOR<import("../FormField").Affix, import("../FormField").Suffix> | undefined;
|
|
30
|
+
readonly suffix?: import("ts-xor").XOR<import("../FormField").Affix, import("../FormField").Suffix> | undefined;
|
|
41
31
|
onEnter?: ((event: React.KeyboardEvent) => void) | undefined;
|
|
42
32
|
readonly readonly?: boolean | undefined;
|
|
43
33
|
readonly validations?: import("react-hook-form").RegisterOptions | undefined;
|
|
@@ -57,10 +47,10 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
57
47
|
readonly placeholder?: string | undefined;
|
|
58
48
|
readonly size?: ("small" | "large") | undefined;
|
|
59
49
|
readonly value?: (string | number | Date) | undefined;
|
|
60
|
-
readonly clearable?: import("@jobber/hooks/
|
|
50
|
+
readonly clearable?: import("@jobber/hooks/dist").Clearable | undefined;
|
|
61
51
|
version?: 1 | undefined;
|
|
62
|
-
onFocus?: (() => void) | undefined;
|
|
63
|
-
onBlur?: (() => void) | undefined;
|
|
52
|
+
onFocus?: ((event?: React.FocusEvent) => void) | undefined;
|
|
53
|
+
onBlur?: ((event?: React.FocusEvent) => void) | undefined;
|
|
64
54
|
readonly toolbar?: React.ReactNode;
|
|
65
55
|
readonly defaultValue?: (string | Date) | undefined;
|
|
66
56
|
readonly prefix?: import("../FormField").Affix | undefined;
|
|
@@ -69,7 +59,7 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
69
59
|
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
|
|
70
60
|
readonly keyboard?: ("numeric" | "decimal") | undefined;
|
|
71
61
|
readonly maxLength?: number | undefined;
|
|
72
|
-
readonly suffix?: XOR<import("../FormField").Affix, import("../FormField").Suffix> | undefined;
|
|
62
|
+
readonly suffix?: import("ts-xor").XOR<import("../FormField").Affix, import("../FormField").Suffix> | undefined;
|
|
73
63
|
onEnter?: ((event: React.KeyboardEvent) => void) | undefined;
|
|
74
64
|
readonly readonly?: boolean | undefined;
|
|
75
65
|
readonly validations?: import("react-hook-form").RegisterOptions | undefined;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Clearable } from "@jobber/hooks";
|
|
2
|
+
import { XOR } from "ts-xor";
|
|
3
|
+
import { AutocompleteTypes, CommonFormFieldProps, FormFieldProps, FormFieldTypes } from "../FormField";
|
|
4
|
+
export interface RowRange {
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
}
|
|
8
|
+
export type InputTextVersion = 1 | 2 | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Experimental version 2 of the InputText component.
|
|
11
|
+
* Do not use unless you have talked with Atlantis first.
|
|
12
|
+
*/
|
|
13
|
+
export interface InputTextRebuiltProps extends Omit<React.InputHTMLAttributes<HTMLInputElement | HTMLTextAreaElement>, "onChange" | "onBlur" | "maxLength" | "rows" | "size" | "suffix" | "prefix" | "value" | "max" | "min" | "defaultValue"> {
|
|
14
|
+
readonly error?: string;
|
|
15
|
+
readonly invalid?: boolean;
|
|
16
|
+
readonly identifier?: string;
|
|
17
|
+
readonly autocomplete?: boolean | AutocompleteTypes;
|
|
18
|
+
readonly loading?: boolean;
|
|
19
|
+
readonly onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
20
|
+
readonly children?: React.ReactNode;
|
|
21
|
+
readonly clearable?: Clearable;
|
|
22
|
+
/**
|
|
23
|
+
* Use this when you're expecting a long answer.
|
|
24
|
+
*/
|
|
25
|
+
readonly multiline?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Specifies the visible height of a long answer form field. Can be in the
|
|
28
|
+
* form of a single number to set a static height, or an object with a min
|
|
29
|
+
* and max keys indicating the minimum number of visible rows, and the
|
|
30
|
+
* maximum number of visible rows.
|
|
31
|
+
*/
|
|
32
|
+
readonly rows?: number | RowRange;
|
|
33
|
+
readonly type?: FormFieldTypes;
|
|
34
|
+
/**
|
|
35
|
+
* Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
|
|
36
|
+
*/
|
|
37
|
+
readonly version: 2;
|
|
38
|
+
readonly onChange?: (newValue: string, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
39
|
+
readonly onEnter?: FormFieldProps["onEnter"];
|
|
40
|
+
readonly onBlur?: FormFieldProps["onBlur"];
|
|
41
|
+
readonly value: string;
|
|
42
|
+
readonly maxLength?: number;
|
|
43
|
+
readonly size?: FormFieldProps["size"];
|
|
44
|
+
readonly inline?: FormFieldProps["inline"];
|
|
45
|
+
readonly align?: FormFieldProps["align"];
|
|
46
|
+
readonly toolbar?: FormFieldProps["toolbar"];
|
|
47
|
+
readonly toolbarVisibility?: FormFieldProps["toolbarVisibility"];
|
|
48
|
+
readonly prefix?: FormFieldProps["prefix"];
|
|
49
|
+
readonly suffix?: FormFieldProps["suffix"];
|
|
50
|
+
readonly description?: FormFieldProps["description"];
|
|
51
|
+
}
|
|
52
|
+
interface BaseProps extends CommonFormFieldProps, Pick<FormFieldProps, "autofocus" | "maxLength" | "readonly" | "autocomplete" | "keyboard" | "onEnter" | "onFocus" | "onBlur" | "onChange" | "inputRef" | "validations" | "defaultValue" | "prefix" | "suffix" | "toolbar" | "toolbarVisibility" | "version"> {
|
|
53
|
+
multiline?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface InputTextRef {
|
|
56
|
+
insert(text: string): void;
|
|
57
|
+
blur(): void;
|
|
58
|
+
focus(): void;
|
|
59
|
+
scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
|
|
60
|
+
}
|
|
61
|
+
interface MultilineProps extends BaseProps {
|
|
62
|
+
/**
|
|
63
|
+
* Use this when you're expecting a long answer.
|
|
64
|
+
*/
|
|
65
|
+
readonly multiline: true;
|
|
66
|
+
/**
|
|
67
|
+
* Specifies the visible height of a long answer form field. Can be in the
|
|
68
|
+
* form of a single number to set a static height, or an object with a min
|
|
69
|
+
* and max keys indicating the minimum number of visible rows, and the
|
|
70
|
+
* maximum number of visible rows.
|
|
71
|
+
*/
|
|
72
|
+
readonly rows?: number | RowRange;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* InputText props for the existing version of InputText
|
|
76
|
+
*/
|
|
77
|
+
export type InputTextLegacyProps = XOR<BaseProps, MultilineProps>;
|
|
78
|
+
export {};
|
package/dist/InputText/index.cjs
CHANGED
|
@@ -1,23 +1,278 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('
|
|
5
|
-
require('../
|
|
6
|
-
require('../
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var useSafeLayoutEffect = require('../useSafeLayoutEffect-cjs.js');
|
|
5
|
+
var FormField = require('../FormField-cjs.js');
|
|
6
|
+
var tslib_es6 = require('../tslib.es6-cjs.js');
|
|
7
|
+
require('react-hook-form');
|
|
7
8
|
require('framer-motion');
|
|
8
9
|
require('@jobber/design');
|
|
9
10
|
require('classnames');
|
|
10
|
-
require('../Button-cjs.js');
|
|
11
11
|
require('react-router-dom');
|
|
12
|
+
var omit = require('../omit-cjs.js');
|
|
13
|
+
require('../Button-cjs.js');
|
|
12
14
|
require('../Icon-cjs.js');
|
|
13
15
|
require('../Typography-cjs.js');
|
|
14
16
|
require('../Text-cjs.js');
|
|
15
17
|
require('../useFormFieldFocus-cjs.js');
|
|
16
18
|
require('../InputValidation-cjs.js');
|
|
17
19
|
require('../Spinner-cjs.js');
|
|
18
|
-
require('../
|
|
19
|
-
require('
|
|
20
|
+
require('../_commonjsHelpers-cjs.js');
|
|
21
|
+
require('../_baseGet-cjs.js');
|
|
22
|
+
require('../isTypedArray-cjs.js');
|
|
23
|
+
require('../isObjectLike-cjs.js');
|
|
24
|
+
require('../identity-cjs.js');
|
|
25
|
+
require('../_getTag-cjs.js');
|
|
26
|
+
require('../isSymbol-cjs.js');
|
|
27
|
+
require('../keysIn-cjs.js');
|
|
28
|
+
require('../_baseAssignValue-cjs.js');
|
|
29
|
+
require('../_baseFlatten-cjs.js');
|
|
30
|
+
require('../_setToString-cjs.js');
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
|
|
34
|
+
*/
|
|
35
|
+
function useTextAreaResize({ rows, value, inputRef, wrapperRef, }) {
|
|
36
|
+
const rowRange = getRowRange(rows);
|
|
37
|
+
useSafeLayoutEffect.useSafeLayoutEffect_1(() => {
|
|
38
|
+
if (inputRef &&
|
|
39
|
+
inputRef.current instanceof HTMLTextAreaElement &&
|
|
40
|
+
wrapperRef &&
|
|
41
|
+
wrapperRef.current instanceof HTMLDivElement) {
|
|
42
|
+
resize();
|
|
43
|
+
}
|
|
44
|
+
}, [inputRef.current, wrapperRef.current]);
|
|
45
|
+
// When the consumer passes a new controlled value, we need to recheck the size.
|
|
46
|
+
// The timeout ensures the DOM has a enough time to render the new text before
|
|
47
|
+
// we access the height.
|
|
48
|
+
useSafeLayoutEffect.useSafeLayoutEffect_1(() => {
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
if (inputRef &&
|
|
51
|
+
inputRef.current instanceof HTMLTextAreaElement &&
|
|
52
|
+
wrapperRef &&
|
|
53
|
+
wrapperRef.current instanceof HTMLDivElement) {
|
|
54
|
+
resize();
|
|
55
|
+
}
|
|
56
|
+
}, 0);
|
|
57
|
+
}, [value]);
|
|
58
|
+
function resize() {
|
|
59
|
+
if (inputRef &&
|
|
60
|
+
inputRef.current instanceof HTMLTextAreaElement &&
|
|
61
|
+
wrapperRef &&
|
|
62
|
+
(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) instanceof HTMLDivElement) {
|
|
63
|
+
if (rowRange.min === rowRange.max)
|
|
64
|
+
return;
|
|
65
|
+
inputRef.current.style.flexBasis = "auto";
|
|
66
|
+
wrapperRef.current.style.height = "auto";
|
|
67
|
+
inputRef.current.style.flexBasis =
|
|
68
|
+
textAreaHeight(inputRef.current) + "px";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function textAreaHeight(textArea) {
|
|
72
|
+
const { lineHeight, borderBottomWidth, borderTopWidth, paddingBottom, paddingTop, } = window.getComputedStyle(textArea);
|
|
73
|
+
const maxHeight = rowRange.max * parseFloat(lineHeight) +
|
|
74
|
+
parseFloat(borderTopWidth) +
|
|
75
|
+
parseFloat(borderBottomWidth) +
|
|
76
|
+
parseFloat(paddingTop) +
|
|
77
|
+
parseFloat(paddingBottom);
|
|
78
|
+
const scrollHeight = textArea.scrollHeight +
|
|
79
|
+
parseFloat(borderTopWidth) +
|
|
80
|
+
parseFloat(borderBottomWidth);
|
|
81
|
+
return Math.min(scrollHeight, maxHeight);
|
|
82
|
+
}
|
|
83
|
+
return { resize, rowRange };
|
|
84
|
+
}
|
|
85
|
+
function getRowRange(rows) {
|
|
86
|
+
if (rows === undefined) {
|
|
87
|
+
return { min: 3, max: 3 };
|
|
88
|
+
}
|
|
89
|
+
else if (typeof rows === "object") {
|
|
90
|
+
return { min: rows.min, max: rows.max };
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return { min: rows, max: rows };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function InputTextInternal(props, ref) {
|
|
98
|
+
const inputRef = React.useRef(null);
|
|
99
|
+
const actionsRef = React.useRef(null);
|
|
100
|
+
const wrapperRef = React.useRef(null);
|
|
101
|
+
const { resize, rowRange } = useTextAreaResize({
|
|
102
|
+
rows: props.rows,
|
|
103
|
+
value: props.value,
|
|
104
|
+
inputRef,
|
|
105
|
+
wrapperRef,
|
|
106
|
+
});
|
|
107
|
+
React.useImperativeHandle(ref, () => ({
|
|
108
|
+
insert: (text) => {
|
|
109
|
+
insertText(text);
|
|
110
|
+
},
|
|
111
|
+
blur: () => {
|
|
112
|
+
const input = inputRef.current;
|
|
113
|
+
if (input) {
|
|
114
|
+
input.blur();
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
focus: () => {
|
|
118
|
+
const input = inputRef.current;
|
|
119
|
+
if (input) {
|
|
120
|
+
input.focus();
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
scrollIntoView: arg => {
|
|
124
|
+
const input = inputRef.current;
|
|
125
|
+
if (input) {
|
|
126
|
+
input.scrollIntoView(arg);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
}));
|
|
130
|
+
return (React.createElement(FormField.FormField, Object.assign({}, props, { type: props.multiline ? "textarea" : "text", inputRef: inputRef, actionsRef: actionsRef, wrapperRef: wrapperRef, onChange: handleChange, rows: rowRange.min })));
|
|
131
|
+
function handleChange(newValue) {
|
|
132
|
+
props.onChange && props.onChange(newValue);
|
|
133
|
+
resize();
|
|
134
|
+
}
|
|
135
|
+
function insertText(text) {
|
|
136
|
+
var _a;
|
|
137
|
+
const input = inputRef.current;
|
|
138
|
+
if (input) {
|
|
139
|
+
insertAtCursor(input, text);
|
|
140
|
+
const newValue = input.value;
|
|
141
|
+
(_a = actionsRef.current) === null || _a === void 0 ? void 0 : _a.setValue(newValue);
|
|
142
|
+
props.onChange && props.onChange(newValue);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const InputText$1 = React.forwardRef(InputTextInternal);
|
|
147
|
+
function insertAtCursor(input, newText) {
|
|
148
|
+
const start = input.selectionStart || 0;
|
|
149
|
+
const end = input.selectionEnd || 0;
|
|
150
|
+
const text = input.value;
|
|
151
|
+
const before = text.substring(0, start);
|
|
152
|
+
const after = text.substring(end, text.length);
|
|
153
|
+
input.value = before + newText + after;
|
|
154
|
+
input.selectionStart = input.selectionEnd = start + newText.length;
|
|
155
|
+
input.focus();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Combines the actions on the InputText such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputText.
|
|
160
|
+
* 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.
|
|
161
|
+
*/
|
|
162
|
+
function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, }) {
|
|
163
|
+
function handleClear() {
|
|
164
|
+
var _a;
|
|
165
|
+
handleBlur();
|
|
166
|
+
onChange && onChange("");
|
|
167
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
168
|
+
}
|
|
169
|
+
function handleChange(event) {
|
|
170
|
+
const newValue = event.currentTarget.value;
|
|
171
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, event);
|
|
172
|
+
}
|
|
173
|
+
function handleKeyDown(event) {
|
|
174
|
+
if (!onEnter)
|
|
175
|
+
return;
|
|
176
|
+
if (event.key !== "Enter")
|
|
177
|
+
return;
|
|
178
|
+
if (event.shiftKey || event.ctrlKey)
|
|
179
|
+
return;
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
onEnter && onEnter(event);
|
|
182
|
+
}
|
|
183
|
+
function handleFocus(event) {
|
|
184
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
185
|
+
}
|
|
186
|
+
function handleBlur(event) {
|
|
187
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
handleClear,
|
|
191
|
+
handleChange,
|
|
192
|
+
handleKeyDown,
|
|
193
|
+
handleFocus,
|
|
194
|
+
handleBlur,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Provides the props for the html fields rendered by the html input.
|
|
200
|
+
* 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.
|
|
201
|
+
*/
|
|
202
|
+
function useInputTextFormField(_a) {
|
|
203
|
+
var { id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = tslib_es6.__rest(_a, ["id", "name", "description", "inline", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
|
|
204
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
205
|
+
const fieldProps = Object.assign(Object.assign(Object.assign({ id, className: FormField.styles.input, name, disabled: rest.disabled, inputMode: rest.inputMode, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus }, (description &&
|
|
206
|
+
!inline && { "aria-describedby": descriptionIdentifier })), { "aria-invalid": rest["aria-invalid"] || error || rest.invalid ? true : undefined, autoFocus: rest.autoFocus, invalid: error || rest.invalid ? "true" : undefined, onKeyDown: handleKeyDown }), rest);
|
|
207
|
+
return { fieldProps, descriptionIdentifier };
|
|
208
|
+
}
|
|
20
209
|
|
|
210
|
+
const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRefs) {
|
|
211
|
+
var _a, _b, _c;
|
|
212
|
+
const inputTextRef = React.useRef(null);
|
|
213
|
+
const wrapperRef = React.useRef(null);
|
|
214
|
+
const legacyPropHelper = Object.assign(Object.assign({}, props), { version: 1 });
|
|
215
|
+
const id = React.useId();
|
|
216
|
+
const { rowRange } = useTextAreaResize({
|
|
217
|
+
rows: props.rows,
|
|
218
|
+
value: props.value,
|
|
219
|
+
inputRef: inputTextRef,
|
|
220
|
+
wrapperRef: wrapperRef,
|
|
221
|
+
});
|
|
222
|
+
const type = props.multiline ? "textarea" : "text";
|
|
223
|
+
const { inputStyle } = FormField.useFormFieldWrapperStyles(legacyPropHelper);
|
|
224
|
+
const { name } = FormField.useAtlantisFormFieldName({
|
|
225
|
+
nameProp: props.name,
|
|
226
|
+
id: props.id || id,
|
|
227
|
+
});
|
|
228
|
+
const { handleChange, handleBlur, handleFocus, handleKeyDown, handleClear } = useInputTextActions({
|
|
229
|
+
onChange: props.onChange,
|
|
230
|
+
onBlur: props.onBlur,
|
|
231
|
+
onFocus: props.onFocus,
|
|
232
|
+
onEnter: props.onEnter,
|
|
233
|
+
inputRef: inputTextRef,
|
|
234
|
+
});
|
|
235
|
+
const inputProps = omit.omit(props, [
|
|
236
|
+
"onChange",
|
|
237
|
+
"onBlur",
|
|
238
|
+
"onFocus",
|
|
239
|
+
"onEnter",
|
|
240
|
+
"size",
|
|
241
|
+
"placeholder",
|
|
242
|
+
"multiline",
|
|
243
|
+
"prefix",
|
|
244
|
+
"suffix",
|
|
245
|
+
"version",
|
|
246
|
+
]);
|
|
247
|
+
const { fieldProps, descriptionIdentifier } = useInputTextFormField(Object.assign(Object.assign({}, inputProps), { id,
|
|
248
|
+
name,
|
|
249
|
+
handleChange,
|
|
250
|
+
handleBlur,
|
|
251
|
+
handleFocus,
|
|
252
|
+
handleKeyDown }));
|
|
253
|
+
return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, autofocus: props.autoFocus, 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, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
|
|
254
|
+
React.createElement(React.Fragment, null,
|
|
255
|
+
type === "textarea" ? (React.createElement(TextArea, { fieldProps: fieldProps, rowRange: rowRange, inputRefs: [inputRefs, inputTextRef], value: props.value, inputStyle: inputStyle })) : (React.createElement(TextInput, { fieldProps: fieldProps, inputRefs: [inputRefs, inputTextRef], value: props.value, inputStyle: inputStyle })),
|
|
256
|
+
React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
|
|
257
|
+
props.children)));
|
|
258
|
+
});
|
|
259
|
+
function TextArea({ fieldProps, rowRange, inputRefs, value, inputStyle, }) {
|
|
260
|
+
return (React.createElement("textarea", Object.assign({}, fieldProps, { rows: rowRange.min, ref: FormField.mergeRefs(inputRefs), className: inputStyle, value: value })));
|
|
261
|
+
}
|
|
262
|
+
function TextInput({ fieldProps, inputRefs, value, inputStyle, }) {
|
|
263
|
+
return (React.createElement("input", Object.assign({}, fieldProps, { ref: FormField.mergeRefs(inputRefs), className: inputStyle, value: value })));
|
|
264
|
+
}
|
|
21
265
|
|
|
266
|
+
function isNewInputTextProps(props) {
|
|
267
|
+
return props.version === 2;
|
|
268
|
+
}
|
|
269
|
+
const InputText = React.forwardRef(function InputTextShim(props, ref) {
|
|
270
|
+
if (isNewInputTextProps(props)) {
|
|
271
|
+
return (React.createElement(InputTextSPAR, Object.assign({}, props, { ref: ref })));
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
return (React.createElement(InputText$1, Object.assign({}, props, { ref: ref })));
|
|
275
|
+
}
|
|
276
|
+
});
|
|
22
277
|
|
|
23
|
-
exports.InputText = InputText
|
|
278
|
+
exports.InputText = InputText;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { InputTextLegacyProps, InputTextRebuiltProps, InputTextRef } from "./InputText.types";
|
|
3
|
+
export type InputTextShimProps = InputTextLegacyProps | InputTextRebuiltProps;
|
|
4
|
+
export declare const InputText: React.ForwardRefExoticComponent<InputTextShimProps & React.RefAttributes<HTMLInputElement | HTMLTextAreaElement | InputTextRef>>;
|
|
5
|
+
export { InputTextRef, InputTextRebuiltProps, InputTextLegacyProps };
|