@jobber/components 8.2.0 → 8.3.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/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/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/Stack/Stack.md +1 -1
- package/dist/docs/usage-guidelines/usage-guidelines.md +0 -2
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/InputText/InputText.rebuilt.d.ts +0 -3
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var jobberHooks = require('@jobber/hooks');
|
|
5
|
+
var FormFieldWrapper = require('./FormFieldWrapper-cjs.js');
|
|
6
|
+
var FormFieldPostFix = require('./FormFieldPostFix-cjs.js');
|
|
7
|
+
require('classnames');
|
|
8
|
+
var useAtlantisFormFieldName = require('./useAtlantisFormFieldName-cjs.js');
|
|
9
|
+
require('./tslib.es6-cjs.js');
|
|
10
|
+
require('react-hook-form');
|
|
11
|
+
var mergeRefs = require('./mergeRefs-cjs.js');
|
|
12
|
+
require('./Button-cjs.js');
|
|
13
|
+
require('@jobber/design');
|
|
14
|
+
var filterDataAttributes = require('./filterDataAttributes-cjs.js');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
|
|
18
|
+
*/
|
|
19
|
+
function useTextAreaResize({ rows, value, inputRef, wrapperRef, }) {
|
|
20
|
+
const rowRange = getRowRange(rows);
|
|
21
|
+
jobberHooks.useSafeLayoutEffect(() => {
|
|
22
|
+
if (inputRef &&
|
|
23
|
+
inputRef.current instanceof HTMLTextAreaElement &&
|
|
24
|
+
wrapperRef &&
|
|
25
|
+
wrapperRef.current instanceof HTMLDivElement) {
|
|
26
|
+
resize();
|
|
27
|
+
}
|
|
28
|
+
}, [inputRef.current, wrapperRef.current]);
|
|
29
|
+
// When the consumer passes a new controlled value, we need to recheck the size.
|
|
30
|
+
// The timeout ensures the DOM has a enough time to render the new text before
|
|
31
|
+
// we access the height.
|
|
32
|
+
jobberHooks.useSafeLayoutEffect(() => {
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
if (inputRef &&
|
|
35
|
+
inputRef.current instanceof HTMLTextAreaElement &&
|
|
36
|
+
wrapperRef &&
|
|
37
|
+
wrapperRef.current instanceof HTMLDivElement) {
|
|
38
|
+
resize();
|
|
39
|
+
}
|
|
40
|
+
}, 0);
|
|
41
|
+
}, [value]);
|
|
42
|
+
function resize() {
|
|
43
|
+
if (inputRef &&
|
|
44
|
+
inputRef.current instanceof HTMLTextAreaElement &&
|
|
45
|
+
wrapperRef &&
|
|
46
|
+
(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) instanceof HTMLDivElement) {
|
|
47
|
+
if (rowRange.min === rowRange.max)
|
|
48
|
+
return;
|
|
49
|
+
inputRef.current.style.flexBasis = "auto";
|
|
50
|
+
wrapperRef.current.style.height = "auto";
|
|
51
|
+
inputRef.current.style.flexBasis =
|
|
52
|
+
textAreaHeight(inputRef.current) + "px";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function textAreaHeight(textArea) {
|
|
56
|
+
const { lineHeight, borderBottomWidth, borderTopWidth, paddingBottom, paddingTop, } = window.getComputedStyle(textArea);
|
|
57
|
+
const maxHeight = rowRange.max * parseFloat(lineHeight) +
|
|
58
|
+
parseFloat(borderTopWidth) +
|
|
59
|
+
parseFloat(borderBottomWidth) +
|
|
60
|
+
parseFloat(paddingTop) +
|
|
61
|
+
parseFloat(paddingBottom);
|
|
62
|
+
const scrollHeight = textArea.scrollHeight +
|
|
63
|
+
parseFloat(borderTopWidth) +
|
|
64
|
+
parseFloat(borderBottomWidth);
|
|
65
|
+
return Math.min(scrollHeight, maxHeight);
|
|
66
|
+
}
|
|
67
|
+
return { resize, rowRange };
|
|
68
|
+
}
|
|
69
|
+
function getRowRange(rows) {
|
|
70
|
+
if (rows === undefined) {
|
|
71
|
+
return { min: 3, max: 3 };
|
|
72
|
+
}
|
|
73
|
+
else if (typeof rows === "object") {
|
|
74
|
+
return { min: rows.min, max: rows.max };
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return { min: rows, max: rows };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Combines the actions on the InputText such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputText.
|
|
83
|
+
* 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.
|
|
84
|
+
*/
|
|
85
|
+
function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, onKeyUp, onMouseDown, onMouseUp, onPointerDown, onPointerUp, onClick, }) {
|
|
86
|
+
function handleClear() {
|
|
87
|
+
var _a;
|
|
88
|
+
onChange && onChange("");
|
|
89
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
90
|
+
}
|
|
91
|
+
function handleChange(event) {
|
|
92
|
+
const newValue = event.currentTarget.value;
|
|
93
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, event);
|
|
94
|
+
}
|
|
95
|
+
function handleKeyDown(event) {
|
|
96
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
97
|
+
if (!onEnter)
|
|
98
|
+
return;
|
|
99
|
+
if (event.key !== "Enter")
|
|
100
|
+
return;
|
|
101
|
+
if (event.shiftKey || event.ctrlKey)
|
|
102
|
+
return;
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
onEnter && onEnter(event);
|
|
105
|
+
}
|
|
106
|
+
function handleKeyUp(event) {
|
|
107
|
+
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event);
|
|
108
|
+
}
|
|
109
|
+
function handleFocus(event) {
|
|
110
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
111
|
+
}
|
|
112
|
+
function handleBlur(event) {
|
|
113
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
114
|
+
}
|
|
115
|
+
function handleMouseDown(event) {
|
|
116
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
117
|
+
}
|
|
118
|
+
function handleMouseUp(event) {
|
|
119
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
120
|
+
}
|
|
121
|
+
function handlePointerDown(event) {
|
|
122
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
123
|
+
}
|
|
124
|
+
function handlePointerUp(event) {
|
|
125
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
126
|
+
}
|
|
127
|
+
function handleClick(event) {
|
|
128
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
handleClear,
|
|
132
|
+
handleChange,
|
|
133
|
+
handleKeyDown,
|
|
134
|
+
handleKeyUp,
|
|
135
|
+
handleFocus,
|
|
136
|
+
handleBlur,
|
|
137
|
+
handleMouseDown,
|
|
138
|
+
handleMouseUp,
|
|
139
|
+
handlePointerDown,
|
|
140
|
+
handlePointerUp,
|
|
141
|
+
handleClick,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const InputText = React.forwardRef(function InputTextInternal(props, inputRef) {
|
|
146
|
+
var _a, _b, _c;
|
|
147
|
+
const inputTextRef = React.useRef(null), wrapperRef = React.useRef(null);
|
|
148
|
+
const id = useInputTextId(props);
|
|
149
|
+
const { rowRange } = useTextAreaResize({
|
|
150
|
+
rows: props.rows,
|
|
151
|
+
value: props.value,
|
|
152
|
+
inputRef: inputTextRef,
|
|
153
|
+
wrapperRef: wrapperRef,
|
|
154
|
+
});
|
|
155
|
+
const { name } = useAtlantisFormFieldName.useAtlantisFormFieldName({
|
|
156
|
+
nameProp: props.name,
|
|
157
|
+
id: id,
|
|
158
|
+
});
|
|
159
|
+
const { handleChange, handleBlur, handleFocus, handleKeyDown, handleKeyUp, handleClear, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, handleClick, } = useInputTextActions({
|
|
160
|
+
onChange: props.onChange,
|
|
161
|
+
onBlur: props.onBlur,
|
|
162
|
+
onFocus: props.onFocus,
|
|
163
|
+
onMouseDown: props.onMouseDown,
|
|
164
|
+
onMouseUp: props.onMouseUp,
|
|
165
|
+
onPointerDown: props.onPointerDown,
|
|
166
|
+
onPointerUp: props.onPointerUp,
|
|
167
|
+
onClick: props.onClick,
|
|
168
|
+
onKeyDown: props.onKeyDown,
|
|
169
|
+
onKeyUp: props.onKeyUp,
|
|
170
|
+
onEnter: props.onEnter,
|
|
171
|
+
inputRef: inputTextRef,
|
|
172
|
+
});
|
|
173
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
174
|
+
const descriptionVisible = props.description && !props.inline;
|
|
175
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
176
|
+
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
177
|
+
const mergedRef = React.useMemo(() => mergeRefs.mergeRefs([inputRef, inputTextRef]), []);
|
|
178
|
+
// Shared props for both TextArea and TextInput
|
|
179
|
+
const commonInputProps = Object.assign({ id,
|
|
180
|
+
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
|
|
181
|
+
? descriptionIdentifier
|
|
182
|
+
: 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);
|
|
183
|
+
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 },
|
|
184
|
+
React.createElement(React.Fragment, null,
|
|
185
|
+
props.multiline ? (React.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
|
|
186
|
+
React.createElement(FormFieldPostFix.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
|
|
187
|
+
});
|
|
188
|
+
function useInputTextId(props) {
|
|
189
|
+
const generatedId = React.useId();
|
|
190
|
+
return props.id || generatedId;
|
|
191
|
+
}
|
|
192
|
+
const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
193
|
+
return React.createElement("textarea", Object.assign({}, props, { ref: ref }));
|
|
194
|
+
});
|
|
195
|
+
const TextInput = React.forwardRef(function TextInput(props, ref) {
|
|
196
|
+
return React.createElement("input", Object.assign({}, props, { ref: ref }));
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
exports.InputText = InputText;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import React__default, { forwardRef, useMemo, useId } from 'react';
|
|
2
|
+
import { useSafeLayoutEffect } from '@jobber/hooks';
|
|
3
|
+
import { g as formFieldStyles, c as FormFieldWrapper } from './FormFieldWrapper-es.js';
|
|
4
|
+
import { F as FormFieldPostFix } from './FormFieldPostFix-es.js';
|
|
5
|
+
import 'classnames';
|
|
6
|
+
import { u as useAtlantisFormFieldName } from './useAtlantisFormFieldName-es.js';
|
|
7
|
+
import './tslib.es6-es.js';
|
|
8
|
+
import 'react-hook-form';
|
|
9
|
+
import { m as mergeRefs } from './mergeRefs-es.js';
|
|
10
|
+
import './Button-es.js';
|
|
11
|
+
import '@jobber/design';
|
|
12
|
+
import { f as filterDataAttributes } from './filterDataAttributes-es.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
|
|
16
|
+
*/
|
|
17
|
+
function useTextAreaResize({ rows, value, inputRef, wrapperRef, }) {
|
|
18
|
+
const rowRange = getRowRange(rows);
|
|
19
|
+
useSafeLayoutEffect(() => {
|
|
20
|
+
if (inputRef &&
|
|
21
|
+
inputRef.current instanceof HTMLTextAreaElement &&
|
|
22
|
+
wrapperRef &&
|
|
23
|
+
wrapperRef.current instanceof HTMLDivElement) {
|
|
24
|
+
resize();
|
|
25
|
+
}
|
|
26
|
+
}, [inputRef.current, wrapperRef.current]);
|
|
27
|
+
// When the consumer passes a new controlled value, we need to recheck the size.
|
|
28
|
+
// The timeout ensures the DOM has a enough time to render the new text before
|
|
29
|
+
// we access the height.
|
|
30
|
+
useSafeLayoutEffect(() => {
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
if (inputRef &&
|
|
33
|
+
inputRef.current instanceof HTMLTextAreaElement &&
|
|
34
|
+
wrapperRef &&
|
|
35
|
+
wrapperRef.current instanceof HTMLDivElement) {
|
|
36
|
+
resize();
|
|
37
|
+
}
|
|
38
|
+
}, 0);
|
|
39
|
+
}, [value]);
|
|
40
|
+
function resize() {
|
|
41
|
+
if (inputRef &&
|
|
42
|
+
inputRef.current instanceof HTMLTextAreaElement &&
|
|
43
|
+
wrapperRef &&
|
|
44
|
+
(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) instanceof HTMLDivElement) {
|
|
45
|
+
if (rowRange.min === rowRange.max)
|
|
46
|
+
return;
|
|
47
|
+
inputRef.current.style.flexBasis = "auto";
|
|
48
|
+
wrapperRef.current.style.height = "auto";
|
|
49
|
+
inputRef.current.style.flexBasis =
|
|
50
|
+
textAreaHeight(inputRef.current) + "px";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function textAreaHeight(textArea) {
|
|
54
|
+
const { lineHeight, borderBottomWidth, borderTopWidth, paddingBottom, paddingTop, } = window.getComputedStyle(textArea);
|
|
55
|
+
const maxHeight = rowRange.max * parseFloat(lineHeight) +
|
|
56
|
+
parseFloat(borderTopWidth) +
|
|
57
|
+
parseFloat(borderBottomWidth) +
|
|
58
|
+
parseFloat(paddingTop) +
|
|
59
|
+
parseFloat(paddingBottom);
|
|
60
|
+
const scrollHeight = textArea.scrollHeight +
|
|
61
|
+
parseFloat(borderTopWidth) +
|
|
62
|
+
parseFloat(borderBottomWidth);
|
|
63
|
+
return Math.min(scrollHeight, maxHeight);
|
|
64
|
+
}
|
|
65
|
+
return { resize, rowRange };
|
|
66
|
+
}
|
|
67
|
+
function getRowRange(rows) {
|
|
68
|
+
if (rows === undefined) {
|
|
69
|
+
return { min: 3, max: 3 };
|
|
70
|
+
}
|
|
71
|
+
else if (typeof rows === "object") {
|
|
72
|
+
return { min: rows.min, max: rows.max };
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return { min: rows, max: rows };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Combines the actions on the InputText such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputText.
|
|
81
|
+
* 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.
|
|
82
|
+
*/
|
|
83
|
+
function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, onKeyUp, onMouseDown, onMouseUp, onPointerDown, onPointerUp, onClick, }) {
|
|
84
|
+
function handleClear() {
|
|
85
|
+
var _a;
|
|
86
|
+
onChange && onChange("");
|
|
87
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
88
|
+
}
|
|
89
|
+
function handleChange(event) {
|
|
90
|
+
const newValue = event.currentTarget.value;
|
|
91
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, event);
|
|
92
|
+
}
|
|
93
|
+
function handleKeyDown(event) {
|
|
94
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
95
|
+
if (!onEnter)
|
|
96
|
+
return;
|
|
97
|
+
if (event.key !== "Enter")
|
|
98
|
+
return;
|
|
99
|
+
if (event.shiftKey || event.ctrlKey)
|
|
100
|
+
return;
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
onEnter && onEnter(event);
|
|
103
|
+
}
|
|
104
|
+
function handleKeyUp(event) {
|
|
105
|
+
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event);
|
|
106
|
+
}
|
|
107
|
+
function handleFocus(event) {
|
|
108
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
109
|
+
}
|
|
110
|
+
function handleBlur(event) {
|
|
111
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
112
|
+
}
|
|
113
|
+
function handleMouseDown(event) {
|
|
114
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
115
|
+
}
|
|
116
|
+
function handleMouseUp(event) {
|
|
117
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
118
|
+
}
|
|
119
|
+
function handlePointerDown(event) {
|
|
120
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
121
|
+
}
|
|
122
|
+
function handlePointerUp(event) {
|
|
123
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
124
|
+
}
|
|
125
|
+
function handleClick(event) {
|
|
126
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
handleClear,
|
|
130
|
+
handleChange,
|
|
131
|
+
handleKeyDown,
|
|
132
|
+
handleKeyUp,
|
|
133
|
+
handleFocus,
|
|
134
|
+
handleBlur,
|
|
135
|
+
handleMouseDown,
|
|
136
|
+
handleMouseUp,
|
|
137
|
+
handlePointerDown,
|
|
138
|
+
handlePointerUp,
|
|
139
|
+
handleClick,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const InputText = forwardRef(function InputTextInternal(props, inputRef) {
|
|
144
|
+
var _a, _b, _c;
|
|
145
|
+
const inputTextRef = React__default.useRef(null), wrapperRef = React__default.useRef(null);
|
|
146
|
+
const id = useInputTextId(props);
|
|
147
|
+
const { rowRange } = useTextAreaResize({
|
|
148
|
+
rows: props.rows,
|
|
149
|
+
value: props.value,
|
|
150
|
+
inputRef: inputTextRef,
|
|
151
|
+
wrapperRef: wrapperRef,
|
|
152
|
+
});
|
|
153
|
+
const { name } = useAtlantisFormFieldName({
|
|
154
|
+
nameProp: props.name,
|
|
155
|
+
id: id,
|
|
156
|
+
});
|
|
157
|
+
const { handleChange, handleBlur, handleFocus, handleKeyDown, handleKeyUp, handleClear, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, handleClick, } = useInputTextActions({
|
|
158
|
+
onChange: props.onChange,
|
|
159
|
+
onBlur: props.onBlur,
|
|
160
|
+
onFocus: props.onFocus,
|
|
161
|
+
onMouseDown: props.onMouseDown,
|
|
162
|
+
onMouseUp: props.onMouseUp,
|
|
163
|
+
onPointerDown: props.onPointerDown,
|
|
164
|
+
onPointerUp: props.onPointerUp,
|
|
165
|
+
onClick: props.onClick,
|
|
166
|
+
onKeyDown: props.onKeyDown,
|
|
167
|
+
onKeyUp: props.onKeyUp,
|
|
168
|
+
onEnter: props.onEnter,
|
|
169
|
+
inputRef: inputTextRef,
|
|
170
|
+
});
|
|
171
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
172
|
+
const descriptionVisible = props.description && !props.inline;
|
|
173
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
174
|
+
const dataAttrs = filterDataAttributes(props);
|
|
175
|
+
const mergedRef = useMemo(() => mergeRefs([inputRef, inputTextRef]), []);
|
|
176
|
+
// Shared props for both TextArea and TextInput
|
|
177
|
+
const commonInputProps = Object.assign({ id,
|
|
178
|
+
name, className: 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
|
|
179
|
+
? descriptionIdentifier
|
|
180
|
+
: 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);
|
|
181
|
+
return (React__default.createElement(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 },
|
|
182
|
+
React__default.createElement(React__default.Fragment, null,
|
|
183
|
+
props.multiline ? (React__default.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React__default.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
|
|
184
|
+
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
|
|
185
|
+
});
|
|
186
|
+
function useInputTextId(props) {
|
|
187
|
+
const generatedId = useId();
|
|
188
|
+
return props.id || generatedId;
|
|
189
|
+
}
|
|
190
|
+
const TextArea = forwardRef(function TextArea(props, ref) {
|
|
191
|
+
return React__default.createElement("textarea", Object.assign({}, props, { ref: ref }));
|
|
192
|
+
});
|
|
193
|
+
const TextInput = forwardRef(function TextInput(props, ref) {
|
|
194
|
+
return React__default.createElement("input", Object.assign({}, props, { ref: ref }));
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
export { InputText as I };
|
|
@@ -1322,8 +1322,7 @@ is, focus the extra element and if not it will focus the input.
|
|
|
1322
1322
|
| `onBlur` | `(event?: FocusEvent<Element, Element>) => void` | No | — | Blur callback. |
|
|
1323
1323
|
| `onFocus` | `(event?: FocusEvent<Element, Element>) => void` | No | — | Focus callback. |
|
|
1324
1324
|
| `prefix` | `Affix` | No | — | Adds a prefix label and icon to the field |
|
|
1325
|
-
| `ref` | `Ref<
|
|
1325
|
+
| `ref` | `Ref<HTMLInputElement>` | No | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (... |
|
|
1326
1326
|
| `size` | `"large" | "small"` | No | — | Adjusts the interface to either have small or large spacing. |
|
|
1327
1327
|
| `suffix` | `{ onClick: () => void; readonly ariaLabel: string; readonly icon: IconNames; readonly label?: string; } | { onClick?: never; ariaLabel?: never; readonly label?: string; readonly icon?: IconNames; }` | No | — | Adds a suffix label and icon with an optional action to the field |
|
|
1328
|
-
| `validations` | `RegisterOptions` | No | — | Validations to run on the input. |
|
|
1329
1328
|
| `version` | `1` | No | `1` | Version of the component to use. |
|
|
@@ -781,7 +781,7 @@ This is not yet implemented fully. Avoid using.
|
|
|
781
781
|
| `customRenderAction` | `(args: { value: MenuAction<ExtraProps>; isActive: boolean; origin?: ActionOrigin; }) => ReactNode` | No | — | Render prop to customize the rendering of an action. @param args.value - The action value including all extra keys fr... |
|
|
782
782
|
| `customRenderFooter` | `(args: { value: MenuFooter<ExtraProps>; isActive?: boolean; }) => ReactNode` | No | — | Render prop to customize the rendering of footer items. |
|
|
783
783
|
| `customRenderHeader` | `(args: { value: MenuHeader<ExtraProps>; isActive?: boolean; }) => ReactNode` | No | — | Render prop to customize the rendering of header items. |
|
|
784
|
-
| `customRenderInput` | `(props: { inputRef: Ref<HTMLInputElement | HTMLTextAreaElement>; inputProps:
|
|
784
|
+
| `customRenderInput` | `(props: { inputRef: Ref<HTMLInputElement | HTMLTextAreaElement>; inputProps: InputTextProps; }) => ReactNode` | No | — | Render prop to customize the rendering of the input. @param props.inputRef - The ref to the input element @param prop... |
|
|
785
785
|
| `customRenderLoading` | `ReactNode` | No | — | Custom render prop for content to render when `loading` is true. |
|
|
786
786
|
| `customRenderOption` | `(args: { value: Value; isActive: boolean; isSelected: boolean; }) => ReactNode` | No | — | Render prop to customize the rendering of an option. @param args.value - The option value including all extra keys fr... |
|
|
787
787
|
| `customRenderSection` | `(section: MenuSection<Value, ExtraProps, ExtraProps>) => ReactNode` | No | — | Render prop to customize the rendering of a section. @param args.section - The section value including all extra keys... |
|
|
@@ -441,8 +441,8 @@ Use `UNSAFE_style` to apply inline custom styles to the Banner.
|
|
|
441
441
|
|
|
442
442
|
| Prop | Type | Required | Default | Description |
|
|
443
443
|
|------|------|----------|---------|-------------|
|
|
444
|
-
| `backgroundColor` | `"event" | "invoice" | "job" | "quote" | "request" | "task" | "text" | "visit" | "warning" | "icon" | "
|
|
445
|
-
| `color` | `"task" | "text" | "warning" | "icon" | "
|
|
444
|
+
| `backgroundColor` | `"event" | "invoice" | "job" | "quote" | "request" | "task" | "text" | "visit" | "warning" | "icon" | "success" | "base-grey--100" | "base-grey--200" | "base-grey--300" | "base-grey--400" | ... 269 more ... | "client--onSurface"` | No | — | Sets the background color of the icon. |
|
|
445
|
+
| `color` | `"task" | "text" | "warning" | "icon" | "success" | "blue" | "green" | "yellow" | "red" | "grey" | "white" | "greyBlue" | "lightBlue" | "orange" | "navy" | "interactive" | "destructive" | ... 32 more ... | "brandHighlight"` | No | — | Determines the color of the icon. Some icons have a default system colour like quotes, jobs, and invoices. Others tha... |
|
|
446
446
|
| `customColor` | `string` | No | — | Sets a custom color for the icon. Can be a rgb() or hex value. |
|
|
447
447
|
| `name` | `IconNames` | No | — | The icon to show. |
|
|
448
448
|
| `size` | `"base" | "large" | "small"` | No | `base` | Changes the size to small or large. |
|
package/dist/docs/Box/Box.md
CHANGED
|
@@ -206,9 +206,9 @@ defaults to respecting theme/modes.
|
|
|
206
206
|
| `alignItems` | `AlignItems` | No | — | This feature is well established and works across many devices and browser versions. It’s been available across brows... |
|
|
207
207
|
| `alignSelf` | `AlignSelf` | No | — | This feature is well established and works across many devices and browser versions. It’s been available across brows... |
|
|
208
208
|
| `as` | `"article" | "aside" | "div" | "main" | "section" | "span"` | No | `div` | |
|
|
209
|
-
| `background` | `"event" | "invoice" | "job" | "quote" | "request" | "task" | "text" | "visit" | "warning" | "icon" | "
|
|
209
|
+
| `background` | `"event" | "invoice" | "job" | "quote" | "request" | "task" | "text" | "visit" | "warning" | "icon" | "success" | "base-grey--100" | "base-grey--200" | "base-grey--300" | "base-grey--400" | ... 269 more ... | "client--onSurface"` | No | — | |
|
|
210
210
|
| `border` | `"base" | "thick" | "thicker" | "thickest" | BoxBorderWidth` | No | — | |
|
|
211
|
-
| `borderColor` | `"event" | "invoice" | "job" | "quote" | "request" | "task" | "text" | "visit" | "warning" | "icon" | "
|
|
211
|
+
| `borderColor` | `"event" | "invoice" | "job" | "quote" | "request" | "task" | "text" | "visit" | "warning" | "icon" | "success" | "base-grey--100" | "base-grey--200" | "base-grey--300" | "base-grey--400" | ... 269 more ... | "client--onSurface"` | No | — | |
|
|
212
212
|
| `direction` | `FlexDirection` | No | — | |
|
|
213
213
|
| `gap` | `"base" | "extravagant" | "large" | "larger" | "largest" | "minuscule" | "slim" | "small" | "smaller" | "smallest"` | No | — | |
|
|
214
214
|
| `height` | `BoxDimension` | No | `auto` | |
|
|
@@ -158,7 +158,7 @@ export function GlimmerSemanticBlocksExample() {
|
|
|
158
158
|
|
|
159
159
|
| Prop | Type | Required | Default | Description |
|
|
160
160
|
|------|------|----------|---------|-------------|
|
|
161
|
-
| `level` | `1 | 2 |
|
|
161
|
+
| `level` | `1 | 2 | 3 | 4 | 5` | No | `3` | Adjust the size of the `Glimmer.Header`. |
|
|
162
162
|
| `reverseTheme` | `boolean` | No | — | Use on surfaces with dark backgrounds. |
|
|
163
163
|
| `timing` | `"base" | "fast"` | No | — | Control how fast the shine moves from left to right. This is useful when the glimmer is used on smaller spaces. |
|
|
164
164
|
| `width` | `number` | No | — | Adjust the width of the glimmer in px values. |
|
package/dist/docs/Icon/Icon.md
CHANGED
|
@@ -582,7 +582,7 @@ necessary.
|
|
|
582
582
|
| Prop | Type | Required | Default | Description |
|
|
583
583
|
|------|------|----------|---------|-------------|
|
|
584
584
|
| `name` | `IconNames` | Yes | — | The icon to show. |
|
|
585
|
-
| `color` | `"task" | "text" | "warning" | "icon" | "
|
|
585
|
+
| `color` | `"task" | "text" | "warning" | "icon" | "success" | "blue" | "green" | "yellow" | "red" | "grey" | "white" | "greyBlue" | "lightBlue" | "orange" | "navy" | "interactive" | "destructive" | ... 32 more ... | "brandHighlight"` | No | — | Determines the color of the icon. Some icons have a default system colour like quotes, jobs, and invoices. Others tha... |
|
|
586
586
|
| `customColor` | `string` | No | — | Sets a custom color for the icon. Can be a rgb() or hex value. |
|
|
587
587
|
| `size` | `"base" | "large" | "small"` | No | `base` | Changes the size to small or large. |
|
|
588
588
|
| `testID` | `string` | No | — | Used to locate this view in end-to-end tests |
|