@lumx/react 4.6.1-alpha.0 → 4.7.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/index.d.ts +55 -27
- package/index.js +186 -109
- package/index.js.map +1 -1
- package/package.json +5 -4
package/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as _lumx_core_js_types from '@lumx/core/js/types';
|
|
|
4
4
|
import { GenericProps as GenericProps$1, HasTheme as HasTheme$1, ValueOf as ValueOf$1, PropsToOverride, HasCloseMode as HasCloseMode$1, HasClassName as HasClassName$1, JSXElement as JSXElement$1, CommonRef as CommonRef$1, Falsy, HeadingElement as HeadingElement$1, HasAriaDisabled as HasAriaDisabled$1, HasRequiredLinkHref as HasRequiredLinkHref$2, HasAriaLabelOrLabelledBy as HasAriaLabelOrLabelledBy$1 } from '@lumx/core/js/types';
|
|
5
5
|
export * from '@lumx/core/js/types';
|
|
6
6
|
import * as React$1 from 'react';
|
|
7
|
-
import React__default, { Ref, ReactElement, ReactNode, SyntheticEvent, MouseEventHandler, KeyboardEventHandler, RefObject, CSSProperties, ImgHTMLAttributes, AriaAttributes as AriaAttributes$1, SetStateAction, Key, ComponentProps, ElementType as ElementType$1 } from 'react';
|
|
7
|
+
import React__default, { Ref, ReactElement, ReactNode, SyntheticEvent, MouseEventHandler, KeyboardEventHandler, RefObject, CSSProperties, ImgHTMLAttributes, AriaAttributes as AriaAttributes$1, SetStateAction, Key, ComponentProps, ElementType as ElementType$1, HTMLInputTypeAttribute } from 'react';
|
|
8
8
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
9
9
|
|
|
10
10
|
/** LumX Component Type. */
|
|
@@ -787,7 +787,7 @@ interface ButtonProps extends GenericProps$1, ReactToJSX<ButtonProps$1> {
|
|
|
787
787
|
* @param ref Component ref.
|
|
788
788
|
* @return React element.
|
|
789
789
|
*/
|
|
790
|
-
declare const Button: Comp<ButtonProps,
|
|
790
|
+
declare const Button: Comp<ButtonProps, HTMLButtonElement | HTMLAnchorElement>;
|
|
791
791
|
|
|
792
792
|
interface IconButtonProps$1 extends BaseButtonProps {
|
|
793
793
|
/**
|
|
@@ -2371,7 +2371,7 @@ interface LinkProps extends GenericProps$1, ReactToJSX<LinkProps$1> {
|
|
|
2371
2371
|
* @param ref Component ref.
|
|
2372
2372
|
* @return React element.
|
|
2373
2373
|
*/
|
|
2374
|
-
declare const Link: Comp<LinkProps,
|
|
2374
|
+
declare const Link: Comp<LinkProps, HTMLButtonElement | HTMLAnchorElement>;
|
|
2375
2375
|
|
|
2376
2376
|
/**
|
|
2377
2377
|
* Defines the props of the component.
|
|
@@ -3810,29 +3810,29 @@ declare const Text: Comp<TextProps, HTMLElement>;
|
|
|
3810
3810
|
/**
|
|
3811
3811
|
* Defines the props of the component.
|
|
3812
3812
|
*/
|
|
3813
|
-
interface TextFieldProps extends
|
|
3813
|
+
interface TextFieldProps$1 extends HasClassName, HasTheme, HasAriaDisabled, HasDisabled {
|
|
3814
3814
|
/** Chip Group to be rendered before the main text input. */
|
|
3815
|
-
chips?:
|
|
3815
|
+
chips?: JSXElement;
|
|
3816
3816
|
/** Props to pass to the clear button (minus those already set by the TextField props). If not specified, the button won't be displayed. */
|
|
3817
|
-
clearButtonProps?:
|
|
3817
|
+
clearButtonProps?: GenericProps;
|
|
3818
3818
|
/** Error message. */
|
|
3819
|
-
error?: string |
|
|
3819
|
+
error?: string | JSXElement;
|
|
3820
3820
|
/** Whether we force the focus style or not. */
|
|
3821
3821
|
forceFocusStyle?: boolean;
|
|
3822
3822
|
/** Whether the text field is displayed with error style or not. */
|
|
3823
3823
|
hasError?: boolean;
|
|
3824
3824
|
/** Additional element to put at the end of the text field. */
|
|
3825
|
-
afterElement?:
|
|
3825
|
+
afterElement?: JSXElement;
|
|
3826
3826
|
/** Helper text. */
|
|
3827
|
-
helper?: string |
|
|
3827
|
+
helper?: string | JSXElement;
|
|
3828
3828
|
/** Icon (SVG path). */
|
|
3829
3829
|
icon?: string;
|
|
3830
3830
|
/** Native input id property (generated if not provided to link the label element). */
|
|
3831
|
-
id
|
|
3832
|
-
/**
|
|
3833
|
-
|
|
3834
|
-
/**
|
|
3835
|
-
|
|
3831
|
+
id: string;
|
|
3832
|
+
/** Generated helper id for accessibility attributes. */
|
|
3833
|
+
helperId?: string;
|
|
3834
|
+
/** Generated error id for accessibility attributes. */
|
|
3835
|
+
errorId?: string;
|
|
3836
3836
|
/** Whether the component is required or not. */
|
|
3837
3837
|
isRequired?: boolean;
|
|
3838
3838
|
/** Whether the text field is displayed with valid style or not. */
|
|
@@ -3840,23 +3840,46 @@ interface TextFieldProps extends GenericProps$1, HasTheme$1, HasAriaDisabled$1 {
|
|
|
3840
3840
|
/** Label text. */
|
|
3841
3841
|
label?: string;
|
|
3842
3842
|
/** Additional label props. */
|
|
3843
|
-
labelProps?: InputLabelProps;
|
|
3843
|
+
labelProps?: InputLabelProps$1;
|
|
3844
3844
|
/** Max string length the input accepts (constrains the input and displays a character counter). */
|
|
3845
3845
|
maxLength?: number;
|
|
3846
|
-
/** Minimum number of rows displayed in multiline mode (requires `multiline` to be enabled). */
|
|
3847
|
-
minimumRows?: number;
|
|
3848
3846
|
/** Whether the text field is a textarea or an input. */
|
|
3849
3847
|
multiline?: boolean;
|
|
3850
|
-
/** Native input name property. */
|
|
3851
|
-
name?: string;
|
|
3852
3848
|
/** Placeholder text. */
|
|
3853
3849
|
placeholder?: string;
|
|
3854
3850
|
/** Reference to the wrapper. */
|
|
3851
|
+
textFieldRef?: CommonRef;
|
|
3852
|
+
/** Value. */
|
|
3853
|
+
value?: string;
|
|
3854
|
+
/** Whether any part is disabled. */
|
|
3855
|
+
isAnyDisabled?: boolean;
|
|
3856
|
+
/** The input element (input or textarea). */
|
|
3857
|
+
input: JSXElement;
|
|
3858
|
+
/** Whether the input is focused. */
|
|
3859
|
+
isFocus?: boolean;
|
|
3860
|
+
/** IconButton component. */
|
|
3861
|
+
IconButton: (props: Record<string, any>) => any;
|
|
3862
|
+
/** Ref to the component root. */
|
|
3863
|
+
ref?: CommonRef;
|
|
3864
|
+
}
|
|
3865
|
+
type TextFieldPropsToOverride = 'id' | 'input' | 'IconButton' | 'labelProps' | 'textFieldRef' | 'clearButtonProps' | 'helperId' | 'errorId' | 'isFocus';
|
|
3866
|
+
|
|
3867
|
+
/**
|
|
3868
|
+
* Defines the props of the component.
|
|
3869
|
+
*/
|
|
3870
|
+
interface TextFieldProps extends GenericProps$1, ReactToJSX<TextFieldProps$1, TextFieldPropsToOverride> {
|
|
3871
|
+
/** Props to pass to the clear button (minus those already set by the TextField props). If not specified, the button won't be displayed. */
|
|
3872
|
+
clearButtonProps?: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;
|
|
3873
|
+
/** Reference to the <input> or <textarea> element. */
|
|
3874
|
+
inputRef?: Ref<HTMLInputElement | HTMLTextAreaElement>;
|
|
3875
|
+
/** Additional label props. */
|
|
3876
|
+
labelProps?: InputLabelProps;
|
|
3877
|
+
/** Native input name property. */
|
|
3878
|
+
name?: string;
|
|
3879
|
+
/** Reference to the wrapper. */
|
|
3855
3880
|
textFieldRef?: Ref<HTMLDivElement>;
|
|
3856
3881
|
/** Native input type (only when `multiline` is disabled). */
|
|
3857
3882
|
type?: React.ComponentProps<'input'>['type'];
|
|
3858
|
-
/** Value. */
|
|
3859
|
-
value?: string;
|
|
3860
3883
|
/** On blur callback. */
|
|
3861
3884
|
onBlur?(event: React.FocusEvent): void;
|
|
3862
3885
|
/** On change callback. */
|
|
@@ -3875,19 +3898,22 @@ interface TextFieldProps extends GenericProps$1, HasTheme$1, HasAriaDisabled$1 {
|
|
|
3875
3898
|
*/
|
|
3876
3899
|
declare const TextField: Comp<TextFieldProps, HTMLDivElement>;
|
|
3877
3900
|
|
|
3878
|
-
type NativeInputProps = Omit<ComponentProps<'input'>, 'value' | 'onChange'>;
|
|
3879
3901
|
/**
|
|
3880
3902
|
* Defines the props of the component.
|
|
3881
3903
|
*/
|
|
3882
|
-
interface RawInputTextProps$1 extends
|
|
3904
|
+
interface RawInputTextProps$1 extends HasTheme, HasClassName {
|
|
3883
3905
|
value?: string;
|
|
3906
|
+
type?: HTMLInputTypeAttribute;
|
|
3907
|
+
name?: string | undefined;
|
|
3908
|
+
ref?: CommonRef;
|
|
3884
3909
|
handleChange?: (value: string, name?: string, event?: any) => void;
|
|
3885
3910
|
}
|
|
3886
3911
|
|
|
3912
|
+
type NativeInputProps = Omit<ComponentProps<'input'>, 'value' | 'onChange'>;
|
|
3887
3913
|
/**
|
|
3888
3914
|
* Defines the props of the component.
|
|
3889
3915
|
*/
|
|
3890
|
-
interface RawInputTextProps extends ReactToJSX<RawInputTextProps$1> {
|
|
3916
|
+
interface RawInputTextProps extends NativeInputProps, ReactToJSX<RawInputTextProps$1> {
|
|
3891
3917
|
onChange?: (value: string, name?: string, event?: SyntheticEvent) => void;
|
|
3892
3918
|
}
|
|
3893
3919
|
|
|
@@ -3897,20 +3923,22 @@ interface RawInputTextProps extends ReactToJSX<RawInputTextProps$1> {
|
|
|
3897
3923
|
*/
|
|
3898
3924
|
declare const RawInputText: Comp<RawInputTextProps, HTMLInputElement>;
|
|
3899
3925
|
|
|
3900
|
-
type NativeTextareaProps = Omit<ComponentProps<'textarea'>, 'value' | 'onChange'>;
|
|
3901
3926
|
/**
|
|
3902
3927
|
* Defines the props of the component.
|
|
3903
3928
|
*/
|
|
3904
|
-
interface RawInputTextareaProps$1 extends
|
|
3929
|
+
interface RawInputTextareaProps$1 extends HasTheme, HasClassName {
|
|
3905
3930
|
value?: string;
|
|
3906
3931
|
rows?: number;
|
|
3932
|
+
name?: string | undefined;
|
|
3933
|
+
ref?: CommonRef;
|
|
3907
3934
|
handleChange?: (value: string, name?: string, event?: any) => void;
|
|
3908
3935
|
}
|
|
3909
3936
|
|
|
3937
|
+
type NativeTextareaProps = Omit<ComponentProps<'textarea'>, 'value' | 'onChange'>;
|
|
3910
3938
|
/**
|
|
3911
3939
|
* Defines the props of the component.
|
|
3912
3940
|
*/
|
|
3913
|
-
interface RawInputTextareaProps extends ReactToJSX<RawInputTextareaProps$1, 'rows'> {
|
|
3941
|
+
interface RawInputTextareaProps extends NativeTextareaProps, ReactToJSX<RawInputTextareaProps$1, 'rows'> {
|
|
3914
3942
|
minimumRows?: number;
|
|
3915
3943
|
onChange?: (value: string, name?: string, event?: SyntheticEvent) => void;
|
|
3916
3944
|
}
|
package/index.js
CHANGED
|
@@ -14226,7 +14226,158 @@ const CLASSNAME$5 = 'lumx-text-field';
|
|
|
14226
14226
|
const INPUT_NATIVE_CLASSNAME = `${CLASSNAME$5}__input-native`;
|
|
14227
14227
|
|
|
14228
14228
|
const {
|
|
14229
|
-
block: block$7
|
|
14229
|
+
block: block$7,
|
|
14230
|
+
element: element$5
|
|
14231
|
+
} = bem(CLASSNAME$5);
|
|
14232
|
+
|
|
14233
|
+
/**
|
|
14234
|
+
* Defines the props of the component.
|
|
14235
|
+
*/
|
|
14236
|
+
|
|
14237
|
+
/**
|
|
14238
|
+
* Generate unique accessibility IDs for helper and error texts.
|
|
14239
|
+
* Combines them with any existing aria-describedby in priority order (error > helper > existing).
|
|
14240
|
+
*
|
|
14241
|
+
* @param helper Helper text content
|
|
14242
|
+
* @param error Error text content
|
|
14243
|
+
* @param generatedId Unique ID for this text field instance
|
|
14244
|
+
* @param existingAriaDescribedBy Existing aria-describedby value to merge
|
|
14245
|
+
* @return Object containing helperId, errorId, and combined describedById
|
|
14246
|
+
*/
|
|
14247
|
+
function generateAccessibilityIds(helper, error, generatedId, existingAriaDescribedBy) {
|
|
14248
|
+
const helperId = helper ? `text-field-helper-${generatedId}` : undefined;
|
|
14249
|
+
const errorId = error ? `text-field-error-${generatedId}` : undefined;
|
|
14250
|
+
const describedByIds = [errorId, helperId, existingAriaDescribedBy].filter(Boolean);
|
|
14251
|
+
const describedById = describedByIds.length === 0 ? undefined : describedByIds.join(' ');
|
|
14252
|
+
return {
|
|
14253
|
+
helperId,
|
|
14254
|
+
errorId,
|
|
14255
|
+
describedById
|
|
14256
|
+
};
|
|
14257
|
+
}
|
|
14258
|
+
|
|
14259
|
+
/**
|
|
14260
|
+
* TextField component.
|
|
14261
|
+
*
|
|
14262
|
+
* @param props Component props.
|
|
14263
|
+
* @param ref Component ref.
|
|
14264
|
+
* @return React element.
|
|
14265
|
+
*/
|
|
14266
|
+
const TextField$1 = props => {
|
|
14267
|
+
const {
|
|
14268
|
+
chips,
|
|
14269
|
+
className,
|
|
14270
|
+
clearButtonProps,
|
|
14271
|
+
error,
|
|
14272
|
+
forceFocusStyle,
|
|
14273
|
+
hasError,
|
|
14274
|
+
helper,
|
|
14275
|
+
icon,
|
|
14276
|
+
id: textFieldId,
|
|
14277
|
+
isRequired,
|
|
14278
|
+
isValid,
|
|
14279
|
+
label,
|
|
14280
|
+
labelProps,
|
|
14281
|
+
isAnyDisabled,
|
|
14282
|
+
maxLength,
|
|
14283
|
+
multiline,
|
|
14284
|
+
placeholder,
|
|
14285
|
+
textFieldRef,
|
|
14286
|
+
helperId,
|
|
14287
|
+
errorId,
|
|
14288
|
+
theme,
|
|
14289
|
+
value,
|
|
14290
|
+
afterElement,
|
|
14291
|
+
input,
|
|
14292
|
+
isFocus,
|
|
14293
|
+
IconButton,
|
|
14294
|
+
ref
|
|
14295
|
+
} = props;
|
|
14296
|
+
const valueLength = (value || '').length;
|
|
14297
|
+
const isNotEmpty = valueLength > 0;
|
|
14298
|
+
return /*#__PURE__*/jsxs("div", {
|
|
14299
|
+
ref: ref,
|
|
14300
|
+
className: classnames(className, block$7({
|
|
14301
|
+
'has-chips': Boolean(chips),
|
|
14302
|
+
'has-error': !isValid && hasError,
|
|
14303
|
+
'has-icon': Boolean(icon),
|
|
14304
|
+
'has-input': !multiline,
|
|
14305
|
+
'has-input-clear': Boolean(clearButtonProps && isNotEmpty),
|
|
14306
|
+
'has-label': Boolean(label),
|
|
14307
|
+
'has-placeholder': Boolean(placeholder),
|
|
14308
|
+
'has-textarea': multiline,
|
|
14309
|
+
'has-value': Boolean(value),
|
|
14310
|
+
'is-disabled': isAnyDisabled,
|
|
14311
|
+
'is-focus': isFocus || forceFocusStyle,
|
|
14312
|
+
'is-valid': isValid,
|
|
14313
|
+
[`theme-${theme}`]: Boolean(theme)
|
|
14314
|
+
})),
|
|
14315
|
+
children: [(label || maxLength) && /*#__PURE__*/jsxs("div", {
|
|
14316
|
+
className: element$5('header'),
|
|
14317
|
+
children: [label && InputLabel$1({
|
|
14318
|
+
...labelProps,
|
|
14319
|
+
htmlFor: textFieldId,
|
|
14320
|
+
className: element$5('label'),
|
|
14321
|
+
isRequired,
|
|
14322
|
+
theme,
|
|
14323
|
+
children: label
|
|
14324
|
+
}), maxLength && /*#__PURE__*/jsxs("div", {
|
|
14325
|
+
className: element$5('char-counter'),
|
|
14326
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
14327
|
+
children: maxLength - valueLength
|
|
14328
|
+
}), maxLength - valueLength === 0 && Icon$1({
|
|
14329
|
+
icon: mdiAlertCircle,
|
|
14330
|
+
size: Size.xxs
|
|
14331
|
+
})]
|
|
14332
|
+
})]
|
|
14333
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
14334
|
+
className: element$5('wrapper'),
|
|
14335
|
+
ref: textFieldRef,
|
|
14336
|
+
children: [icon && Icon$1({
|
|
14337
|
+
className: element$5('input-icon'),
|
|
14338
|
+
color: theme === Theme.dark ? 'light' : undefined,
|
|
14339
|
+
icon,
|
|
14340
|
+
size: Size.xs
|
|
14341
|
+
}), chips ? /*#__PURE__*/jsxs("div", {
|
|
14342
|
+
className: element$5('chips'),
|
|
14343
|
+
children: [chips, input]
|
|
14344
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
14345
|
+
className: element$5('input-wrapper'),
|
|
14346
|
+
children: input
|
|
14347
|
+
}), (isValid || hasError) && Icon$1({
|
|
14348
|
+
className: element$5('input-validity'),
|
|
14349
|
+
color: theme === Theme.dark ? 'light' : undefined,
|
|
14350
|
+
icon: isValid ? mdiCheckCircle : mdiAlertCircle,
|
|
14351
|
+
size: Size.xxs
|
|
14352
|
+
}), clearButtonProps && isNotEmpty && !isAnyDisabled && /*#__PURE__*/jsx(IconButton, {
|
|
14353
|
+
...clearButtonProps,
|
|
14354
|
+
className: element$5('input-clear'),
|
|
14355
|
+
icon: mdiCloseCircle,
|
|
14356
|
+
emphasis: Emphasis.low,
|
|
14357
|
+
size: Size.s,
|
|
14358
|
+
theme: theme,
|
|
14359
|
+
type: "button"
|
|
14360
|
+
}), afterElement && /*#__PURE__*/jsx("div", {
|
|
14361
|
+
className: element$5('after-element'),
|
|
14362
|
+
children: afterElement
|
|
14363
|
+
})]
|
|
14364
|
+
}), hasError && error && InputHelper$1({
|
|
14365
|
+
children: error,
|
|
14366
|
+
className: element$5('helper'),
|
|
14367
|
+
kind: Kind.error,
|
|
14368
|
+
theme,
|
|
14369
|
+
id: errorId
|
|
14370
|
+
}), helper && InputHelper$1({
|
|
14371
|
+
className: element$5('helper'),
|
|
14372
|
+
theme,
|
|
14373
|
+
id: helperId,
|
|
14374
|
+
children: helper
|
|
14375
|
+
})]
|
|
14376
|
+
});
|
|
14377
|
+
};
|
|
14378
|
+
|
|
14379
|
+
const {
|
|
14380
|
+
block: block$6
|
|
14230
14381
|
} = bem(INPUT_NATIVE_CLASSNAME);
|
|
14231
14382
|
|
|
14232
14383
|
/**
|
|
@@ -14263,7 +14414,7 @@ const RawInputText$1 = props => {
|
|
|
14263
14414
|
name: name,
|
|
14264
14415
|
type: type,
|
|
14265
14416
|
ref: ref,
|
|
14266
|
-
className: classnames(className, block$
|
|
14417
|
+
className: classnames(className, block$6({
|
|
14267
14418
|
[`theme-${theme}`]: Boolean(theme),
|
|
14268
14419
|
text: true
|
|
14269
14420
|
})),
|
|
@@ -14292,7 +14443,7 @@ const RawInputText = forwardRef((props, ref) => {
|
|
|
14292
14443
|
});
|
|
14293
14444
|
|
|
14294
14445
|
const {
|
|
14295
|
-
block: block$
|
|
14446
|
+
block: block$5
|
|
14296
14447
|
} = bem(INPUT_NATIVE_CLASSNAME);
|
|
14297
14448
|
|
|
14298
14449
|
/**
|
|
@@ -14328,7 +14479,7 @@ const RawInputTextarea$1 = props => {
|
|
|
14328
14479
|
...forwardedProps,
|
|
14329
14480
|
name: name,
|
|
14330
14481
|
ref: ref,
|
|
14331
|
-
className: classnames(className, block$
|
|
14482
|
+
className: classnames(className, block$5({
|
|
14332
14483
|
[`theme-${theme}`]: Boolean(theme),
|
|
14333
14484
|
textarea: true
|
|
14334
14485
|
})),
|
|
@@ -14415,15 +14566,6 @@ const RawInputTextarea = forwardRef((props, ref) => {
|
|
|
14415
14566
|
});
|
|
14416
14567
|
});
|
|
14417
14568
|
|
|
14418
|
-
const {
|
|
14419
|
-
block: block$5,
|
|
14420
|
-
element: element$5
|
|
14421
|
-
} = classNames.bem(CLASSNAME$5);
|
|
14422
|
-
|
|
14423
|
-
/**
|
|
14424
|
-
* Defines the props of the component.
|
|
14425
|
-
*/
|
|
14426
|
-
|
|
14427
14569
|
/**
|
|
14428
14570
|
* Component default props.
|
|
14429
14571
|
*/
|
|
@@ -14446,20 +14588,15 @@ const TextField = forwardRef((props, ref) => {
|
|
|
14446
14588
|
} = useDisableStateProps(props);
|
|
14447
14589
|
const defaultTheme = useTheme() || Theme$1.light;
|
|
14448
14590
|
const {
|
|
14449
|
-
chips,
|
|
14450
14591
|
className,
|
|
14451
14592
|
clearButtonProps,
|
|
14452
14593
|
error,
|
|
14453
14594
|
forceFocusStyle,
|
|
14454
14595
|
hasError,
|
|
14455
14596
|
helper,
|
|
14456
|
-
icon,
|
|
14457
14597
|
id,
|
|
14458
14598
|
inputRef: inputRefProps,
|
|
14459
14599
|
isRequired,
|
|
14460
|
-
isValid,
|
|
14461
|
-
label,
|
|
14462
|
-
labelProps,
|
|
14463
14600
|
maxLength,
|
|
14464
14601
|
minimumRows,
|
|
14465
14602
|
multiline,
|
|
@@ -14482,19 +14619,12 @@ const TextField = forwardRef((props, ref) => {
|
|
|
14482
14619
|
const localInputRef = useRef(null);
|
|
14483
14620
|
/** Merge prop input ref and local input ref */
|
|
14484
14621
|
const inputRef = mergeRefs(localInputRef, inputRefProps);
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
|
|
14489
|
-
|
|
14490
|
-
*/
|
|
14491
|
-
const helperId = helper ? `text-field-helper-${generatedTextFieldId}` : undefined;
|
|
14492
|
-
const errorId = error ? `text-field-error-${generatedTextFieldId}` : undefined;
|
|
14493
|
-
const describedByIds = [errorId, helperId, forwardedProps['aria-describedby']].filter(Boolean);
|
|
14494
|
-
const describedById = describedByIds.length === 0 ? undefined : describedByIds.join(' ');
|
|
14622
|
+
const {
|
|
14623
|
+
helperId,
|
|
14624
|
+
errorId,
|
|
14625
|
+
describedById
|
|
14626
|
+
} = generateAccessibilityIds(helper, error, generatedTextFieldId, forwardedProps['aria-describedby']);
|
|
14495
14627
|
const [isFocus, setFocus] = useState(false);
|
|
14496
|
-
const valueLength = (value || '').length;
|
|
14497
|
-
const isNotEmpty = valueLength > 0;
|
|
14498
14628
|
|
|
14499
14629
|
/**
|
|
14500
14630
|
* Function triggered when the Clear Button is clicked.
|
|
@@ -14548,85 +14678,32 @@ const TextField = forwardRef((props, ref) => {
|
|
|
14548
14678
|
type: type,
|
|
14549
14679
|
...inputProps
|
|
14550
14680
|
});
|
|
14551
|
-
return
|
|
14552
|
-
ref
|
|
14553
|
-
className
|
|
14554
|
-
|
|
14555
|
-
|
|
14556
|
-
|
|
14557
|
-
|
|
14558
|
-
|
|
14559
|
-
|
|
14560
|
-
|
|
14561
|
-
|
|
14562
|
-
|
|
14563
|
-
|
|
14564
|
-
|
|
14565
|
-
|
|
14566
|
-
|
|
14567
|
-
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
|
|
14575
|
-
|
|
14576
|
-
|
|
14577
|
-
}), maxLength && /*#__PURE__*/jsxs("div", {
|
|
14578
|
-
className: element$5('char-counter'),
|
|
14579
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
14580
|
-
children: maxLength - valueLength
|
|
14581
|
-
}), maxLength - valueLength === 0 && /*#__PURE__*/jsx(Icon, {
|
|
14582
|
-
icon: mdiAlertCircle,
|
|
14583
|
-
size: Size$1.xxs
|
|
14584
|
-
})]
|
|
14585
|
-
})]
|
|
14586
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
14587
|
-
className: element$5('wrapper'),
|
|
14588
|
-
ref: textFieldRef,
|
|
14589
|
-
children: [icon && /*#__PURE__*/jsx(Icon, {
|
|
14590
|
-
className: element$5('input-icon'),
|
|
14591
|
-
color: theme === Theme$1.dark ? 'light' : undefined,
|
|
14592
|
-
icon: icon,
|
|
14593
|
-
size: Size$1.xs
|
|
14594
|
-
}), chips ? /*#__PURE__*/jsxs("div", {
|
|
14595
|
-
className: element$5('chips'),
|
|
14596
|
-
children: [chips, input]
|
|
14597
|
-
}) : /*#__PURE__*/jsx("div", {
|
|
14598
|
-
className: element$5('input-wrapper'),
|
|
14599
|
-
children: input
|
|
14600
|
-
}), (isValid || hasError) && /*#__PURE__*/jsx(Icon, {
|
|
14601
|
-
className: element$5('input-validity'),
|
|
14602
|
-
color: theme === Theme$1.dark ? 'light' : undefined,
|
|
14603
|
-
icon: isValid ? mdiCheckCircle : mdiAlertCircle,
|
|
14604
|
-
size: Size$1.xxs
|
|
14605
|
-
}), clearButtonProps && isNotEmpty && !isAnyDisabled && /*#__PURE__*/jsx(IconButton, {
|
|
14606
|
-
...clearButtonProps,
|
|
14607
|
-
className: element$5('input-clear'),
|
|
14608
|
-
icon: mdiCloseCircle,
|
|
14609
|
-
emphasis: Emphasis$1.low,
|
|
14610
|
-
size: Size$1.s,
|
|
14611
|
-
theme: theme,
|
|
14612
|
-
onClick: handleClear,
|
|
14613
|
-
type: "button"
|
|
14614
|
-
}), afterElement && /*#__PURE__*/jsx("div", {
|
|
14615
|
-
className: element$5('after-element'),
|
|
14616
|
-
children: afterElement
|
|
14617
|
-
})]
|
|
14618
|
-
}), hasError && error && /*#__PURE__*/jsx(InputHelper, {
|
|
14619
|
-
className: element$5('helper'),
|
|
14620
|
-
kind: Kind$1.error,
|
|
14621
|
-
theme: theme,
|
|
14622
|
-
id: errorId,
|
|
14623
|
-
children: error
|
|
14624
|
-
}), helper && /*#__PURE__*/jsx(InputHelper, {
|
|
14625
|
-
className: element$5('helper'),
|
|
14626
|
-
theme: theme,
|
|
14627
|
-
id: helperId,
|
|
14628
|
-
children: helper
|
|
14629
|
-
})]
|
|
14681
|
+
return TextField$1({
|
|
14682
|
+
ref,
|
|
14683
|
+
className,
|
|
14684
|
+
isAnyDisabled,
|
|
14685
|
+
input,
|
|
14686
|
+
id: textFieldId,
|
|
14687
|
+
afterElement,
|
|
14688
|
+
hasError,
|
|
14689
|
+
helperId,
|
|
14690
|
+
multiline,
|
|
14691
|
+
maxLength,
|
|
14692
|
+
isRequired,
|
|
14693
|
+
errorId,
|
|
14694
|
+
placeholder,
|
|
14695
|
+
textFieldRef,
|
|
14696
|
+
value,
|
|
14697
|
+
theme,
|
|
14698
|
+
error,
|
|
14699
|
+
helper,
|
|
14700
|
+
IconButton: IconButton,
|
|
14701
|
+
isFocus,
|
|
14702
|
+
...forwardedProps,
|
|
14703
|
+
clearButtonProps: clearButtonProps ? {
|
|
14704
|
+
...clearButtonProps,
|
|
14705
|
+
onClick: handleClear
|
|
14706
|
+
} : undefined
|
|
14630
14707
|
});
|
|
14631
14708
|
});
|
|
14632
14709
|
TextField.displayName = COMPONENT_NAME$4;
|