@lumx/react 4.18.0 → 4.18.1-alpha.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. */
@@ -5493,6 +5497,17 @@ interface TimePickerFieldWrapperProps {
5493
5497
  * Translation labels for clear and show suggestions buttons.
5494
5498
  */
5495
5499
  translations: TimePickerFieldTranslations;
5500
+ /**
5501
+ * Callback to customize individual option props.
5502
+ * Called for each time option with the hour and minute.
5503
+ * Return partial `ComboboxOptionProps` to override default option rendering
5504
+ * (e.g. `before`, `after`, `children`, `tooltipProps`, `actionProps`).
5505
+ * `isDisabled` is merged with the out-of-range state using `||`.
5506
+ */
5507
+ getOptionProps?: ({ hour, minute }: {
5508
+ hour: number;
5509
+ minute: number;
5510
+ }) => Partial<ComboboxOptionProps$1>;
5496
5511
  }
5497
5512
  /**
5498
5513
  * `SelectTextField` props managed internally by the `TimePickerField` wrappers
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,
@@ -21740,6 +21744,7 @@ const TimePickerField$1 = (props, {
21740
21744
  handleChange,
21741
21745
  handleSearch,
21742
21746
  handleBlur,
21747
+ getOptionProps,
21743
21748
  ...fowardedProps
21744
21749
  } = props;
21745
21750
  return /*#__PURE__*/jsx(SelectTextField, {
@@ -21748,9 +21753,23 @@ const TimePickerField$1 = (props, {
21748
21753
  selectionType: "single",
21749
21754
  options: options,
21750
21755
  getOptionId: "name",
21751
- renderOption: entry => /*#__PURE__*/jsx(Option, {
21752
- isDisabled: entry.outOfRange
21753
- }),
21756
+ renderOption: ({
21757
+ hour,
21758
+ minute,
21759
+ outOfRange
21760
+ }) => {
21761
+ const {
21762
+ isDisabled,
21763
+ ...extraProps
21764
+ } = getOptionProps?.({
21765
+ hour,
21766
+ minute
21767
+ }) || {};
21768
+ return /*#__PURE__*/jsx(Option, {
21769
+ isDisabled: outOfRange || isDisabled,
21770
+ ...extraProps
21771
+ });
21772
+ },
21754
21773
  onChange: handleChange,
21755
21774
  onSearch: handleSearch,
21756
21775
  onBlur: handleBlur,
@@ -21950,6 +21969,7 @@ const TimePickerField = props => {
21950
21969
  theme,
21951
21970
  translations,
21952
21971
  name,
21972
+ getOptionProps,
21953
21973
  ...forwardedProps
21954
21974
  } = props;
21955
21975
 
@@ -22014,7 +22034,8 @@ const TimePickerField = props => {
22014
22034
  handleChange,
22015
22035
  handleSearch,
22016
22036
  handleBlur,
22017
- searchInputValue
22037
+ searchInputValue,
22038
+ getOptionProps
22018
22039
  }, {
22019
22040
  SelectTextField,
22020
22041
  Option: SelectTextField.Option