@lumx/react 3.3.0 → 3.3.1-alpha.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/_internal/types.d.ts +2 -0
- package/index.d.ts +0 -2
- package/index.js +24 -57
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/index.ts +2 -0
- package/src/components/popover/Popover.tsx +9 -7
- package/src/components/select/SelectMultiple.stories.tsx +2 -105
- package/src/components/select/WithSelectContext.tsx +4 -10
- package/src/components/text-field/TextField.stories.tsx +0 -1
- package/src/components/text-field/TextField.test.tsx +4 -52
- package/src/components/text-field/TextField.tsx +4 -32
- package/src/hooks/useFocusTrap.ts +2 -2
package/_internal/types.d.ts
CHANGED
|
@@ -238,6 +238,8 @@ declare type Typography = TypographyInterface | TypographyCustom;
|
|
|
238
238
|
declare const AspectRatio: {
|
|
239
239
|
/** Intrinsic content ratio. */
|
|
240
240
|
readonly original: "original";
|
|
241
|
+
/** Ratio 3:1 */
|
|
242
|
+
readonly panoramic: "panoramic";
|
|
241
243
|
/** Ratio 16:9 */
|
|
242
244
|
readonly wide: "wide";
|
|
243
245
|
/** Ratio 3:2 */
|
package/index.d.ts
CHANGED
|
@@ -2695,8 +2695,6 @@ interface TextFieldProps extends GenericProps, HasTheme {
|
|
|
2695
2695
|
onBlur?(event: React.FocusEvent): void;
|
|
2696
2696
|
/** On change callback. */
|
|
2697
2697
|
onChange(value: string, name?: string, event?: SyntheticEvent): void;
|
|
2698
|
-
/** On clear callback. */
|
|
2699
|
-
onClear?(event?: SyntheticEvent): void;
|
|
2700
2698
|
/** On focus callback. */
|
|
2701
2699
|
onFocus?(event: React.FocusEvent): void;
|
|
2702
2700
|
}
|
package/index.js
CHANGED
|
@@ -220,6 +220,8 @@ const Typography = _objectSpread2(_objectSpread2({}, TypographyInterface), {}, {
|
|
|
220
220
|
const AspectRatio = {
|
|
221
221
|
/** Intrinsic content ratio. */
|
|
222
222
|
original: 'original',
|
|
223
|
+
/** Ratio 3:1 */
|
|
224
|
+
panoramic: 'panoramic',
|
|
223
225
|
/** Ratio 16:9 */
|
|
224
226
|
wide: 'wide',
|
|
225
227
|
/** Ratio 3:2 */
|
|
@@ -2282,15 +2284,11 @@ function useFocusTrap(focusZoneElement, focusElement) {
|
|
|
2282
2284
|
// SETUP:
|
|
2283
2285
|
if (focusElement && focusZoneElement.contains(focusElement)) {
|
|
2284
2286
|
// Focus the given element.
|
|
2285
|
-
focusElement.focus(
|
|
2286
|
-
preventScroll: true
|
|
2287
|
-
});
|
|
2287
|
+
focusElement.focus();
|
|
2288
2288
|
} else {
|
|
2289
2289
|
var _getFirstAndLastFocus;
|
|
2290
2290
|
// Focus the first focusable element in the zone.
|
|
2291
|
-
(_getFirstAndLastFocus = getFirstAndLastFocusable(focusZoneElement).first) === null || _getFirstAndLastFocus === void 0 ? void 0 : _getFirstAndLastFocus.focus(
|
|
2292
|
-
preventScroll: true
|
|
2293
|
-
});
|
|
2291
|
+
(_getFirstAndLastFocus = getFirstAndLastFocusable(focusZoneElement).first) === null || _getFirstAndLastFocus === void 0 ? void 0 : _getFirstAndLastFocus.focus();
|
|
2294
2292
|
}
|
|
2295
2293
|
FOCUS_TRAPS.register(focusTrap);
|
|
2296
2294
|
|
|
@@ -6202,19 +6200,18 @@ const _InnerPopover = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
6202
6200
|
* unless specifically requested not to.
|
|
6203
6201
|
*/
|
|
6204
6202
|
if (isFocusedWithin.current && focusAnchorOnClose) {
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
if (!elementToFocus && anchorRef !== null && anchorRef !== void 0 && anchorRef.current) {
|
|
6208
|
-
// Focus the first focusable element in anchor.
|
|
6209
|
-
elementToFocus = getFirstAndLastFocusable(anchorRef.current).first;
|
|
6203
|
+
if (parentElement !== null && parentElement !== void 0 && parentElement.current) {
|
|
6204
|
+
parentElement === null || parentElement === void 0 ? void 0 : parentElement.current.focus();
|
|
6210
6205
|
}
|
|
6211
|
-
|
|
6206
|
+
const firstFocusable = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) && getFirstAndLastFocusable(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current).first;
|
|
6207
|
+
if (firstFocusable) {
|
|
6208
|
+
// Focus the first focusable element in anchor.
|
|
6209
|
+
firstFocusable.focus();
|
|
6210
|
+
} else {
|
|
6211
|
+
var _anchorRef$current;
|
|
6212
6212
|
// Fallback on the anchor element.
|
|
6213
|
-
|
|
6213
|
+
anchorRef === null || anchorRef === void 0 ? void 0 : (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.focus();
|
|
6214
6214
|
}
|
|
6215
|
-
(_elementToFocus = elementToFocus) === null || _elementToFocus === void 0 ? void 0 : _elementToFocus.focus({
|
|
6216
|
-
preventScroll: true
|
|
6217
|
-
});
|
|
6218
6215
|
}
|
|
6219
6216
|
onClose();
|
|
6220
6217
|
}, [anchorRef, focusAnchorOnClose, onClose, parentElement]);
|
|
@@ -9296,7 +9293,7 @@ const SelectVariant = {
|
|
|
9296
9293
|
chip: 'chip'
|
|
9297
9294
|
};
|
|
9298
9295
|
|
|
9299
|
-
const _excluded$Y = ["children", "className", "
|
|
9296
|
+
const _excluded$Y = ["children", "className", "isMultiple", "closeOnClick", "disabled", "error", "hasError", "helper", "id", "isDisabled", "isEmpty", "isOpen", "isRequired", "isValid", "label", "onClear", "onDropdownClose", "onInfiniteScroll", "onInputClick", "placeholder", "theme", "value", "variant"];
|
|
9300
9297
|
|
|
9301
9298
|
/** The display name of the component. */
|
|
9302
9299
|
const COMPONENT_NAME$W = 'Select';
|
|
@@ -9313,7 +9310,6 @@ const WithSelectContext = (SelectElement, _ref, ref) => {
|
|
|
9313
9310
|
let {
|
|
9314
9311
|
children,
|
|
9315
9312
|
className,
|
|
9316
|
-
focusElement,
|
|
9317
9313
|
isMultiple,
|
|
9318
9314
|
closeOnClick = !isMultiple,
|
|
9319
9315
|
disabled,
|
|
@@ -9340,7 +9336,6 @@ const WithSelectContext = (SelectElement, _ref, ref) => {
|
|
|
9340
9336
|
const selectId = useMemo(() => id || `select-${uid()}`, [id]);
|
|
9341
9337
|
const anchorRef = useRef(null);
|
|
9342
9338
|
const selectRef = useRef(null);
|
|
9343
|
-
const dropdownRef = useRef(null);
|
|
9344
9339
|
const isFocus = useListenFocus(anchorRef);
|
|
9345
9340
|
const handleKeyboardNav = useCallback(evt => {
|
|
9346
9341
|
if ((evt.key === 'Enter' || evt.key === ' ' || evt.key === 'ArrowDown') && onInputClick) {
|
|
@@ -9355,9 +9350,6 @@ const WithSelectContext = (SelectElement, _ref, ref) => {
|
|
|
9355
9350
|
}
|
|
9356
9351
|
anchorRef === null || anchorRef === void 0 ? void 0 : (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.blur();
|
|
9357
9352
|
};
|
|
9358
|
-
|
|
9359
|
-
// Handle focus trap.
|
|
9360
|
-
useFocusTrap(isOpen && dropdownRef.current, focusElement === null || focusElement === void 0 ? void 0 : focusElement.current);
|
|
9361
9353
|
return /*#__PURE__*/React.createElement("div", {
|
|
9362
9354
|
ref: mergeRefs(ref, selectRef),
|
|
9363
9355
|
className: classnames(className, handleBasicClasses({
|
|
@@ -9398,8 +9390,7 @@ const WithSelectContext = (SelectElement, _ref, ref) => {
|
|
|
9398
9390
|
isOpen: !!isOpen,
|
|
9399
9391
|
placement: Placement.BOTTOM_START,
|
|
9400
9392
|
onClose: onClose,
|
|
9401
|
-
onInfiniteScroll: onInfiniteScroll
|
|
9402
|
-
ref: dropdownRef
|
|
9393
|
+
onInfiniteScroll: onInfiniteScroll
|
|
9403
9394
|
}, children), hasError && error && /*#__PURE__*/React.createElement(InputHelper, {
|
|
9404
9395
|
className: `${CLASSNAME$T}__helper`,
|
|
9405
9396
|
kind: Kind.error,
|
|
@@ -11718,8 +11709,8 @@ TabPanel.displayName = COMPONENT_NAME$1f;
|
|
|
11718
11709
|
TabPanel.className = CLASSNAME$1c;
|
|
11719
11710
|
TabPanel.defaultProps = DEFAULT_PROPS$Z;
|
|
11720
11711
|
|
|
11721
|
-
const _excluded$1k = ["id", "isDisabled", "isRequired", "placeholder", "multiline", "value", "setFocus", "onChange", "onFocus", "onBlur", "inputRef", "rows", "recomputeNumberOfRows", "type", "name"
|
|
11722
|
-
_excluded2$3 = ["chips", "className", "clearButtonProps", "disabled", "error", "forceFocusStyle", "hasError", "helper", "icon", "id", "inputRef", "isDisabled", "isRequired", "isValid", "label", "maxLength", "minimumRows", "multiline", "name", "onBlur", "onChange", "
|
|
11712
|
+
const _excluded$1k = ["id", "isDisabled", "isRequired", "placeholder", "multiline", "value", "setFocus", "onChange", "onFocus", "onBlur", "inputRef", "rows", "recomputeNumberOfRows", "type", "name"],
|
|
11713
|
+
_excluded2$3 = ["chips", "className", "clearButtonProps", "disabled", "error", "forceFocusStyle", "hasError", "helper", "icon", "id", "inputRef", "isDisabled", "isRequired", "isValid", "label", "maxLength", "minimumRows", "multiline", "name", "onBlur", "onChange", "onFocus", "placeholder", "textFieldRef", "theme", "type", "value", "afterElement"];
|
|
11723
11714
|
|
|
11724
11715
|
/**
|
|
11725
11716
|
* Defines the props of the component.
|
|
@@ -11799,9 +11790,7 @@ const renderInputNative = props => {
|
|
|
11799
11790
|
rows,
|
|
11800
11791
|
recomputeNumberOfRows,
|
|
11801
11792
|
type,
|
|
11802
|
-
name
|
|
11803
|
-
hasError,
|
|
11804
|
-
describedById
|
|
11793
|
+
name
|
|
11805
11794
|
} = props,
|
|
11806
11795
|
forwardedProps = _objectWithoutProperties(props, _excluded$1k);
|
|
11807
11796
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -11837,8 +11826,6 @@ const renderInputNative = props => {
|
|
|
11837
11826
|
onFocus: onTextFieldFocus,
|
|
11838
11827
|
onBlur: onTextFieldBlur,
|
|
11839
11828
|
onChange: handleChange,
|
|
11840
|
-
'aria-invalid': hasError ? 'true' : undefined,
|
|
11841
|
-
'aria-describedby': describedById,
|
|
11842
11829
|
ref: mergeRefs(inputRef, ref)
|
|
11843
11830
|
});
|
|
11844
11831
|
if (multiline) {
|
|
@@ -11879,7 +11866,6 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
11879
11866
|
name,
|
|
11880
11867
|
onBlur,
|
|
11881
11868
|
onChange,
|
|
11882
|
-
onClear,
|
|
11883
11869
|
onFocus,
|
|
11884
11870
|
placeholder,
|
|
11885
11871
|
textFieldRef,
|
|
@@ -11890,16 +11876,6 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
11890
11876
|
} = props,
|
|
11891
11877
|
forwardedProps = _objectWithoutProperties(props, _excluded2$3);
|
|
11892
11878
|
const textFieldId = useMemo(() => id || `text-field-${uid()}`, [id]);
|
|
11893
|
-
/**
|
|
11894
|
-
* Generate unique ids for both the helper and error texts, in order to
|
|
11895
|
-
* later on add them to the input native as aria-describedby. If both the error and the helper are present,
|
|
11896
|
-
* we want to first use the most important one, which is the errorId. That way, screen readers will read first
|
|
11897
|
-
* the error and then the helper
|
|
11898
|
-
*/
|
|
11899
|
-
const helperId = helper ? `text-field-helper-${uid()}` : undefined;
|
|
11900
|
-
const errorId = error ? `text-field-error-${uid()}` : undefined;
|
|
11901
|
-
const describedByIds = [errorId, helperId].filter(Boolean);
|
|
11902
|
-
const describedById = describedByIds.length === 0 ? undefined : describedByIds.join(' ');
|
|
11903
11879
|
const [isFocus, setFocus] = useState(false);
|
|
11904
11880
|
const {
|
|
11905
11881
|
rows,
|
|
@@ -11914,14 +11890,11 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
11914
11890
|
* and remove focus from the clear button.
|
|
11915
11891
|
* @param evt On clear event.
|
|
11916
11892
|
*/
|
|
11917
|
-
const
|
|
11893
|
+
const onClear = evt => {
|
|
11918
11894
|
evt.nativeEvent.preventDefault();
|
|
11919
11895
|
evt.nativeEvent.stopPropagation();
|
|
11920
11896
|
evt.currentTarget.blur();
|
|
11921
11897
|
onChange('');
|
|
11922
|
-
if (onClear) {
|
|
11923
|
-
onClear(evt);
|
|
11924
|
-
}
|
|
11925
11898
|
};
|
|
11926
11899
|
return /*#__PURE__*/React.createElement("div", {
|
|
11927
11900
|
ref: ref,
|
|
@@ -11979,9 +11952,7 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
11979
11952
|
setFocus,
|
|
11980
11953
|
type,
|
|
11981
11954
|
value,
|
|
11982
|
-
name
|
|
11983
|
-
hasError,
|
|
11984
|
-
describedById
|
|
11955
|
+
name
|
|
11985
11956
|
}, forwardedProps))), !chips && /*#__PURE__*/React.createElement("div", {
|
|
11986
11957
|
className: `${CLASSNAME$1d}__input-wrapper`
|
|
11987
11958
|
}, renderInputNative(_objectSpread2({
|
|
@@ -12000,9 +11971,7 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
12000
11971
|
setFocus,
|
|
12001
11972
|
type,
|
|
12002
11973
|
value,
|
|
12003
|
-
name
|
|
12004
|
-
hasError,
|
|
12005
|
-
describedById
|
|
11974
|
+
name
|
|
12006
11975
|
}, forwardedProps))), (isValid || hasError) && /*#__PURE__*/React.createElement(Icon, {
|
|
12007
11976
|
className: `${CLASSNAME$1d}__input-validity`,
|
|
12008
11977
|
color: theme === Theme.dark ? 'light' : undefined,
|
|
@@ -12014,19 +11983,17 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
12014
11983
|
emphasis: Emphasis.low,
|
|
12015
11984
|
size: Size.s,
|
|
12016
11985
|
theme: theme,
|
|
12017
|
-
onClick:
|
|
11986
|
+
onClick: onClear,
|
|
12018
11987
|
type: "button"
|
|
12019
11988
|
})), afterElement && /*#__PURE__*/React.createElement("div", {
|
|
12020
11989
|
className: `${CLASSNAME$1d}__after-element`
|
|
12021
11990
|
}, afterElement)), hasError && error && /*#__PURE__*/React.createElement(InputHelper, {
|
|
12022
11991
|
className: `${CLASSNAME$1d}__helper`,
|
|
12023
11992
|
kind: Kind.error,
|
|
12024
|
-
theme: theme
|
|
12025
|
-
id: errorId
|
|
11993
|
+
theme: theme
|
|
12026
11994
|
}, error), helper && /*#__PURE__*/React.createElement(InputHelper, {
|
|
12027
11995
|
className: `${CLASSNAME$1d}__helper`,
|
|
12028
|
-
theme: theme
|
|
12029
|
-
id: helperId
|
|
11996
|
+
theme: theme
|
|
12030
11997
|
}, helper));
|
|
12031
11998
|
});
|
|
12032
11999
|
TextField.displayName = COMPONENT_NAME$1g;
|