@lumx/react 4.19.0-next.0 → 4.19.0-next.1

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 CHANGED
@@ -1987,6 +1987,8 @@ interface TextFieldProps$1 extends HasClassName, HasTheme, HasAriaDisabled, HasD
1987
1987
  labelProps?: InputLabelProps$1;
1988
1988
  /** Max string length the input accepts (constrains the input and displays a character counter). */
1989
1989
  maxLength?: number;
1990
+ /** Character counter message formatter. Receives remaining character count, returns accessible label (e.g. \"{n} characters remaining\"). */
1991
+ charCounterMessage?: (charCount: number) => string | JSXElement;
1990
1992
  /** Whether the text field is a textarea or an input. */
1991
1993
  multiline?: boolean;
1992
1994
  /** Placeholder text. */
@@ -2006,7 +2008,7 @@ interface TextFieldProps$1 extends HasClassName, HasTheme, HasAriaDisabled, HasD
2006
2008
  /** Ref to the component root. */
2007
2009
  ref?: CommonRef;
2008
2010
  }
2009
- type TextFieldPropsToOverride = 'input' | 'IconButton' | 'labelProps' | 'textFieldRef' | 'clearButtonProps' | 'helperId' | 'errorId' | 'labelId' | 'isAnyDisabled' | 'isFocus';
2011
+ type TextFieldPropsToOverride = 'input' | 'IconButton' | 'labelProps' | 'textFieldRef' | 'clearButtonProps' | 'charCounterMessage' | 'helperId' | 'errorId' | 'labelId' | 'isAnyDisabled' | 'isFocus';
2010
2012
 
2011
2013
  interface InputLabelProps extends ReactToJSX<InputLabelProps$1>, GenericProps$1 {
2012
2014
  }
@@ -2023,6 +2025,8 @@ declare const InputLabel: Comp<InputLabelProps, HTMLLabelElement>;
2023
2025
  * Defines the props of the component.
2024
2026
  */
2025
2027
  interface TextFieldProps extends GenericProps$1, ReactToJSX<TextFieldProps$1, TextFieldPropsToOverride> {
2028
+ /** Character counter message formatter. Receives remaining character count, returns accessible label (e.g. \"{n} characters remaining\"). */
2029
+ charCounterMessage?: (charCount: number) => string | ReactNode;
2026
2030
  /** Props to pass to the clear button (minus those already set by the TextField props). If not specified, the button won't be displayed. */
2027
2031
  clearButtonProps?: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;
2028
2032
  /** Reference to the <input> or <textarea> element. */
package/index.js CHANGED
@@ -7668,6 +7668,7 @@ const TextField$1 = props => {
7668
7668
  multiline,
7669
7669
  placeholder,
7670
7670
  textFieldRef,
7671
+ charCounterMessage,
7671
7672
  helperId,
7672
7673
  errorId,
7673
7674
  labelId,
@@ -7681,6 +7682,15 @@ const TextField$1 = props => {
7681
7682
  } = props;
7682
7683
  const valueLength = (value || '').length;
7683
7684
  const isNotEmpty = valueLength > 0;
7685
+ const remaining = maxLength ? maxLength - valueLength : 0;
7686
+ const charCounter = maxLength ? /*#__PURE__*/jsxs("span", {
7687
+ className: element$M('char-counter'),
7688
+ role: "status",
7689
+ children: [charCounterMessage ? charCounterMessage(remaining) : remaining, remaining === 0 && Icon$1({
7690
+ icon: mdiAlertCircle,
7691
+ size: Size.xxs
7692
+ })]
7693
+ }) : undefined;
7684
7694
  return /*#__PURE__*/jsxs("div", {
7685
7695
  ref: ref,
7686
7696
  className: classnames(className, block$$({
@@ -7698,25 +7708,17 @@ const TextField$1 = props => {
7698
7708
  'is-valid': isValid,
7699
7709
  [`theme-${theme}`]: Boolean(theme)
7700
7710
  })),
7701
- children: [(label || maxLength) && /*#__PURE__*/jsxs("div", {
7711
+ children: [(label || maxLength) && /*#__PURE__*/jsx("div", {
7702
7712
  className: element$M('header'),
7703
- children: [label && InputLabel$1({
7713
+ children: InputLabel$1({
7704
7714
  ...labelProps,
7705
7715
  id: labelId,
7706
7716
  htmlFor: textFieldId,
7707
7717
  className: element$M('label'),
7708
7718
  isRequired,
7709
7719
  theme,
7710
- children: label
7711
- }), maxLength && /*#__PURE__*/jsxs("div", {
7712
- className: element$M('char-counter'),
7713
- children: [/*#__PURE__*/jsx("span", {
7714
- children: maxLength - valueLength
7715
- }), maxLength - valueLength === 0 && Icon$1({
7716
- icon: mdiAlertCircle,
7717
- size: Size.xxs
7718
- })]
7719
- })]
7720
+ children: [label, charCounter]
7721
+ })
7720
7722
  }), /*#__PURE__*/jsxs("div", {
7721
7723
  className: element$M('wrapper'),
7722
7724
  ref: textFieldRef,
@@ -8017,6 +8019,7 @@ const TextField = forwardRef((props, ref) => {
8017
8019
  label,
8018
8020
  labelProps,
8019
8021
  maxLength,
8022
+ charCounterMessage,
8020
8023
  minimumRows,
8021
8024
  multiline,
8022
8025
  name,
@@ -8116,6 +8119,7 @@ const TextField = forwardRef((props, ref) => {
8116
8119
  labelId,
8117
8120
  multiline,
8118
8121
  maxLength,
8122
+ charCounterMessage,
8119
8123
  isRequired,
8120
8124
  errorId,
8121
8125
  placeholder,