@koobiq/react-components 0.0.1-beta.30 → 0.0.1-beta.31

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.
Files changed (40) hide show
  1. package/dist/components/FieldComponents/FieldAddon/FieldAddon.d.ts +1 -1
  2. package/dist/components/FieldComponents/FieldAddon/FieldAddon.js +7 -2
  3. package/dist/components/FieldComponents/FieldAddon/FieldAddon.module.css.js +3 -3
  4. package/dist/components/FieldComponents/FieldCaption/FieldCaption.d.ts +4 -6
  5. package/dist/components/FieldComponents/FieldCaption/FieldCaption.js +1 -1
  6. package/dist/components/FieldComponents/FieldControl/FieldControl.d.ts +2 -1
  7. package/dist/components/FieldComponents/FieldError/FieldError.d.ts +1 -1
  8. package/dist/components/FieldComponents/FieldError/FieldError.js +1 -1
  9. package/dist/components/FieldComponents/FieldInput/FieldInput.d.ts +2 -2
  10. package/dist/components/FieldComponents/FieldInput/FieldInput.js +4 -4
  11. package/dist/components/FieldComponents/FieldInput/FieldInput.module.css.js +3 -3
  12. package/dist/components/FieldComponents/FieldInputGroup/FieldInputGroup.d.ts +2 -2
  13. package/dist/components/FieldComponents/FieldInputGroup/FieldInputGroup.js +29 -5
  14. package/dist/components/FieldComponents/FieldInputGroup/FieldInputGroupContext.d.ts +3 -3
  15. package/dist/components/FieldComponents/FieldLabel/FieldLabel.d.ts +2 -2
  16. package/dist/components/FieldComponents/FieldLabel/FieldLabel.js +3 -3
  17. package/dist/components/FieldComponents/FieldSelect/FieldSelect.d.ts +5 -4
  18. package/dist/components/FieldComponents/FieldSelect/FieldSelect.js +5 -5
  19. package/dist/components/FieldComponents/FieldSelect/FieldSelect.module.css.js +4 -4
  20. package/dist/components/Input/Input.d.ts +30 -10
  21. package/dist/components/Input/Input.js +58 -13
  22. package/dist/components/Input/types.d.ts +66 -9
  23. package/dist/components/InputNumber/InputNumber.d.ts +25 -9
  24. package/dist/components/InputNumber/InputNumber.js +75 -25
  25. package/dist/components/InputNumber/components/InputNumberCounterControls.js +2 -2
  26. package/dist/components/InputNumber/types.d.ts +52 -7
  27. package/dist/components/Provider/Provider.d.ts +1 -1
  28. package/dist/components/Provider/Provider.js +8 -4
  29. package/dist/components/Provider/types.d.ts +3 -1
  30. package/dist/components/Select/Select.js +80 -65
  31. package/dist/components/Select/types.d.ts +48 -6
  32. package/dist/components/Textarea/Textarea.d.ts +14 -6
  33. package/dist/components/Textarea/Textarea.js +46 -2
  34. package/dist/components/Textarea/components/TextareaContextConsumer/TextareaContextConsumer.d.ts +4 -4
  35. package/dist/components/Textarea/components/TextareaContextConsumer/TextareaContextConsumer.js +15 -9
  36. package/dist/components/Textarea/types.d.ts +57 -7
  37. package/dist/components/Textarea/utils/useTextareaAutosize.d.ts +1 -1
  38. package/dist/components/Textarea/utils/useTextareaAutosize.js +2 -2
  39. package/dist/style.css +4 -4
  40. package/package.json +5 -5
@@ -1,22 +1,38 @@
1
- export declare const InputNumber: import("react").ForwardRefExoticComponent<Omit<Omit<import("@koobiq/react-primitives").UseNumberFieldProps, "inputElementType">, "caption" | "label" | "style" | "className" | "disabled" | "required" | "error" | "variant" | "slotProps" | "fullWidth" | "data-testid" | "errorMessage" | "startAddon" | "endAddon" | "hiddenLabel"> & {
1
+ import { NumberField } from '@koobiq/react-primitives';
2
+ import { type FieldControlProps, type FieldLabelProps, type FieldCaptionProps, type FieldErrorProps, type FieldInputGroupProps, type FieldInputProps } from '../FieldComponents';
3
+ export declare const InputNumber: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-types/numberfield").AriaNumberFieldProps, "inputElementType">, "caption" | "label" | "style" | "className" | "isDisabled" | "variant" | "slotProps" | "fullWidth" | "data-testid" | "isInvalid" | "isRequired" | "errorMessage" | "startAddon" | "endAddon" | "isLabelHidden" | keyof {
4
+ disabled?: boolean;
5
+ error?: boolean;
6
+ required?: boolean;
7
+ readonly?: boolean;
8
+ hiddenLabel?: boolean;
9
+ }> & {
2
10
  label?: import("react").ReactNode;
3
11
  className?: string;
4
12
  startAddon?: import("react").ReactNode;
5
13
  endAddon?: import("react").ReactNode;
6
14
  variant?: import("./types").InputNumberPropVariant;
7
- error?: boolean;
15
+ isInvalid?: boolean;
8
16
  errorMessage?: string | number;
9
17
  fullWidth?: boolean;
10
- disabled?: boolean;
11
- hiddenLabel?: boolean;
18
+ isDisabled?: boolean;
19
+ isLabelHidden?: boolean;
12
20
  caption?: string | number;
13
- required?: boolean;
21
+ isRequired?: boolean;
14
22
  style?: import("react").CSSProperties;
15
23
  'data-testid'?: string | number;
16
24
  slotProps?: {
17
- label?: import("../FieldComponents").FieldLabelProps;
18
- input?: import("../FieldComponents").FieldInputProps;
19
- caption?: import("../FieldComponents").FieldCaptionProps;
20
- errorMessage?: import("../FieldComponents").FieldErrorProps;
25
+ root?: FieldControlProps<typeof NumberField>;
26
+ label?: FieldLabelProps;
27
+ input?: FieldInputProps;
28
+ caption?: FieldCaptionProps;
29
+ group?: FieldInputGroupProps;
30
+ errorMessage?: FieldErrorProps;
21
31
  };
32
+ } & {
33
+ disabled?: boolean;
34
+ error?: boolean;
35
+ required?: boolean;
36
+ readonly?: boolean;
37
+ hiddenLabel?: boolean;
22
38
  } & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
3
  import { forwardRef } from "react";
4
+ import { deprecate } from "@koobiq/logger";
4
5
  import { useDOMRef, mergeProps } from "@koobiq/react-core";
5
6
  import { NumberField } from "@koobiq/react-primitives";
6
7
  import { InputNumberCounterControls } from "./components/InputNumberCounterControls.js";
@@ -15,7 +16,16 @@ const InputNumber = forwardRef(
15
16
  const {
16
17
  variant = "filled",
17
18
  fullWidth = false,
18
- hiddenLabel = false,
19
+ hiddenLabel,
20
+ isLabelHidden: isLabelHiddenProp,
21
+ disabled,
22
+ isDisabled: isDisabledProp,
23
+ error,
24
+ isInvalid: isInvalidProp,
25
+ required,
26
+ isRequired: isRequiredProp,
27
+ readonly,
28
+ isReadOnly: isReadOnlyProp,
19
29
  label,
20
30
  startAddon,
21
31
  endAddon,
@@ -24,43 +34,83 @@ const InputNumber = forwardRef(
24
34
  caption,
25
35
  ...other
26
36
  } = props;
27
- const domRef = useDOMRef(ref);
37
+ const inputRef = useDOMRef(ref);
38
+ const isDisabled = isDisabledProp ?? disabled ?? false;
39
+ const isRequired = isRequiredProp ?? required ?? false;
40
+ const isReadOnly = isReadOnlyProp ?? readonly ?? false;
41
+ const isInvalid = isInvalidProp ?? error ?? false;
42
+ const isLabelHidden = isLabelHiddenProp ?? hiddenLabel ?? false;
43
+ if (process.env.NODE_ENV !== "production" && "disabled" in props) {
44
+ deprecate(
45
+ 'InputNumber: the "disabled" prop is deprecated. Use "isDisabled" prop to replace it.'
46
+ );
47
+ }
48
+ if (process.env.NODE_ENV !== "production" && "required" in props) {
49
+ deprecate(
50
+ 'InputNumber: the "required" prop is deprecated. Use "isRequired" prop to replace it.'
51
+ );
52
+ }
53
+ if (process.env.NODE_ENV !== "production" && "error" in props) {
54
+ deprecate(
55
+ 'InputNumber: the "error" prop is deprecated. Use "isInvalid" prop to replace it.'
56
+ );
57
+ }
58
+ if (process.env.NODE_ENV !== "production" && "readonly" in props) {
59
+ deprecate(
60
+ 'InputNumber: the "readonly" prop is deprecated. Use "isReadOnly" prop to replace it.'
61
+ );
62
+ }
63
+ if (process.env.NODE_ENV !== "production" && "hiddenLabel" in props) {
64
+ deprecate(
65
+ 'InputNumber: the "hiddenLabel" prop is deprecated. Use "isLabelHidden" prop to replace it.'
66
+ );
67
+ }
28
68
  const rootProps = mergeProps(
29
69
  {
30
70
  label,
31
71
  fullWidth,
72
+ isDisabled,
73
+ isRequired,
74
+ isReadOnly,
75
+ isInvalid,
32
76
  errorMessage,
33
77
  "data-variant": variant,
34
- "data-fullwidth": fullWidth
78
+ "data-fullwidth": fullWidth,
79
+ ...other
35
80
  },
36
- other
81
+ slotProps?.root
37
82
  );
38
- return /* @__PURE__ */ jsx(FieldControl, { as: NumberField, ...rootProps, children: ({ error, required, disabled }) => {
39
- const labelProps = mergeProps(
40
- { hidden: hiddenLabel, required },
41
- slotProps?.label
42
- );
83
+ return /* @__PURE__ */ jsx(FieldControl, { as: NumberField, ...rootProps, children: ({ isInvalid: isInvalid2, isRequired: isRequired2, isDisabled: isDisabled2 }) => {
84
+ const labelProps = mergeProps({ isHidden: isLabelHidden, isRequired: isRequired2 }, slotProps?.label);
43
85
  const inputProps = mergeProps(
44
- { error, variant, disabled, ref: domRef },
86
+ {
87
+ variant,
88
+ isInvalid: isInvalid2,
89
+ isDisabled: isDisabled2,
90
+ ref: inputRef
91
+ },
45
92
  slotProps?.input
46
93
  );
47
- const captionProps = slotProps?.caption;
48
- const errorProps = mergeProps({ error }, slotProps?.errorMessage);
94
+ const captionProps = mergeProps(
95
+ { isInvalid: isInvalid2 },
96
+ slotProps?.caption
97
+ );
98
+ const errorProps = mergeProps({ isInvalid: isInvalid2 }, slotProps?.errorMessage);
99
+ const groupProps = mergeProps(
100
+ {
101
+ endAddon: /* @__PURE__ */ jsxs(Fragment, { children: [
102
+ endAddon,
103
+ /* @__PURE__ */ jsx(InputNumberCounterControls, {})
104
+ ] }),
105
+ isInvalid: isInvalid2,
106
+ startAddon,
107
+ isDisabled: isDisabled2
108
+ },
109
+ slotProps?.group
110
+ );
49
111
  return /* @__PURE__ */ jsxs(Fragment, { children: [
50
112
  /* @__PURE__ */ jsx(FieldLabel, { ...labelProps, children: labelProps?.children || label }),
51
- /* @__PURE__ */ jsx(
52
- FieldInputGroup,
53
- {
54
- error,
55
- disabled,
56
- startAddon,
57
- endAddon: /* @__PURE__ */ jsxs(Fragment, { children: [
58
- endAddon,
59
- /* @__PURE__ */ jsx(InputNumberCounterControls, {})
60
- ] }),
61
- children: /* @__PURE__ */ jsx(FieldInput, { ...inputProps })
62
- }
63
- ),
113
+ /* @__PURE__ */ jsx(FieldInputGroup, { ...groupProps, children: /* @__PURE__ */ jsx(FieldInput, { ...inputProps }) }),
64
114
  /* @__PURE__ */ jsx(FieldCaption, { ...captionProps, children: captionProps?.children || caption }),
65
115
  /* @__PURE__ */ jsx(FieldError, { ...errorProps, children: errorProps.children || errorMessage })
66
116
  ] });
@@ -5,8 +5,8 @@ import s from "./InputNumberCounterControls.module.css.js";
5
5
  import { useFieldInputGroup } from "../../FieldComponents/FieldInputGroup/FieldInputGroupContext.js";
6
6
  import { IconButton } from "../../IconButton/IconButton.js";
7
7
  const InputNumberCounterControls = () => {
8
- const { hovered, hasValue, focusWithin } = useFieldInputGroup();
9
- const visible = (hovered || focusWithin) && hasValue;
8
+ const { isHovered, hasValue, isFocusWithin } = useFieldInputGroup();
9
+ const visible = (isHovered || isFocusWithin) && hasValue;
10
10
  return /* @__PURE__ */ jsxs("div", { className: clsx(s.base, visible && s.visible), children: [
11
11
  /* @__PURE__ */ jsx(
12
12
  IconButton,
@@ -1,9 +1,51 @@
1
1
  import type { ComponentRef, CSSProperties, ReactNode } from 'react';
2
2
  import type { ExtendableProps } from '@koobiq/react-core';
3
- import type { UseNumberFieldProps } from '@koobiq/react-primitives';
4
- import type { FieldCaptionProps, FieldErrorProps, FieldInputProps, FieldLabelProps } from '../FieldComponents';
3
+ import type { NumberField, UseNumberFieldProps } from '@koobiq/react-primitives';
4
+ import type { FieldCaptionProps, FieldControlProps, FieldErrorProps, FieldInputGroupProps, FieldInputProps, FieldLabelProps } from '../FieldComponents';
5
5
  export declare const inputNumberPropVariant: readonly ["filled", "transparent"];
6
6
  export type InputNumberPropVariant = (typeof inputNumberPropVariant)[number];
7
+ type InputNumberDeprecatedProps = {
8
+ /**
9
+ * If `true`, the component is disabled.
10
+ * @default false
11
+ *
12
+ * @deprecated
13
+ * The "disabled" prop is deprecated. Use "isDisabled" prop to replace it.
14
+ */
15
+ disabled?: boolean;
16
+ /**
17
+ * If `true`, the input will indicate an error.
18
+ * @default false
19
+ *
20
+ * @deprecated
21
+ * The "error" prop is deprecated. Use "isInvalid" prop to replace it.
22
+ */
23
+ error?: boolean;
24
+ /**
25
+ * If `true`, the label is displayed as required and the input element is required.
26
+ * @default false
27
+ *
28
+ * @deprecated
29
+ * The "required" prop is deprecated. Use "isRequired" prop to replace it.
30
+ */
31
+ required?: boolean;
32
+ /**
33
+ * If `true`, the input can be selected but not changed by the user.
34
+ * @default false
35
+ *
36
+ * @deprecated
37
+ * The "readonly" prop is deprecated. Use "isReadOnly" prop to replace it.
38
+ */
39
+ readonly?: boolean;
40
+ /**
41
+ * If `true`, the label is hidden. Be sure to add aria-label to the input element.
42
+ * @default false
43
+ *
44
+ * @deprecated
45
+ * The "hiddenLabel" prop is deprecated. Use "isLabelHidden" prop to replace it.
46
+ */
47
+ hiddenLabel?: boolean;
48
+ };
7
49
  export type InputNumberProps = ExtendableProps<{
8
50
  /** The content to display as the label. */
9
51
  label?: ReactNode;
@@ -22,7 +64,7 @@ export type InputNumberProps = ExtendableProps<{
22
64
  * If `true`, the input will indicate an error.
23
65
  * @default false
24
66
  */
25
- error?: boolean;
67
+ isInvalid?: boolean;
26
68
  /** Message for the error state. */
27
69
  errorMessage?: string | number;
28
70
  /**
@@ -34,29 +76,32 @@ export type InputNumberProps = ExtendableProps<{
34
76
  * If `true`, the component is disabled.
35
77
  * @default false
36
78
  */
37
- disabled?: boolean;
79
+ isDisabled?: boolean;
38
80
  /**
39
81
  * If `true`, the label is hidden. Be sure to add aria-label to the input element.
40
82
  * @default false
41
83
  */
42
- hiddenLabel?: boolean;
84
+ isLabelHidden?: boolean;
43
85
  /** The helper text content. */
44
86
  caption?: string | number;
45
87
  /**
46
88
  * If `true`, the label is displayed as required and the input element is required.
47
89
  * @default false
48
90
  */
49
- required?: boolean;
91
+ isRequired?: boolean;
50
92
  /** Inline styles. */
51
93
  style?: CSSProperties;
52
94
  /** Unique identifier for testing purposes. */
53
95
  'data-testid'?: string | number;
54
96
  /** The props used for each slot inside. */
55
97
  slotProps?: {
98
+ root?: FieldControlProps<typeof NumberField>;
56
99
  label?: FieldLabelProps;
57
100
  input?: FieldInputProps;
58
101
  caption?: FieldCaptionProps;
102
+ group?: FieldInputGroupProps;
59
103
  errorMessage?: FieldErrorProps;
60
104
  };
61
- }, Omit<UseNumberFieldProps, 'inputElementType'>>;
105
+ } & InputNumberDeprecatedProps, Omit<UseNumberFieldProps, 'inputElementType'>>;
62
106
  export type InputNumberRef = ComponentRef<'input'>;
107
+ export {};
@@ -3,6 +3,6 @@ import type { Breakpoints, ProviderProps } from './types';
3
3
  export { useLocale };
4
4
  export declare const defaultBreakpoints: Breakpoints;
5
5
  export declare const Provider: {
6
- ({ breakpoints, breakpointsFallback, children, locale, }: ProviderProps): import("react/jsx-runtime").JSX.Element;
6
+ ({ breakpoints, breakpointsFallback, children, router, locale, }: ProviderProps): import("react/jsx-runtime").JSX.Element;
7
7
  displayName: string;
8
8
  };
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { I18nProvider } from "@koobiq/react-primitives";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { I18nProvider, RouterProvider } from "@koobiq/react-primitives";
4
4
  import { useLocale } from "@koobiq/react-primitives";
5
5
  import { BreakpointsProvider } from "./BreakpointsProvider.js";
6
6
  import { ProviderContext } from "./ProviderContext.js";
@@ -22,13 +22,17 @@ const Provider = ({
22
22
  breakpoints = defaultBreakpoints,
23
23
  breakpointsFallback,
24
24
  children,
25
+ router,
25
26
  locale
26
- }) => /* @__PURE__ */ jsx(ProviderContext.Provider, { value: { breakpoints, locale }, children: /* @__PURE__ */ jsx(I18nProvider, { locale, children: /* @__PURE__ */ jsx(
27
+ }) => /* @__PURE__ */ jsx(ProviderContext.Provider, { value: { breakpoints, locale }, children: /* @__PURE__ */ jsx(I18nProvider, { locale, children: /* @__PURE__ */ jsxs(
27
28
  BreakpointsProvider,
28
29
  {
29
30
  breakpoints,
30
31
  defaultMatches: breakpointsFallback,
31
- children
32
+ children: [
33
+ router?.navigate && /* @__PURE__ */ jsx(RouterProvider, { ...router, children }),
34
+ !router?.navigate && children
35
+ ]
32
36
  }
33
37
  ) }) });
34
38
  Provider.displayName = "Provider";
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
- import type { I18nProviderProps } from '@koobiq/react-primitives';
2
+ import type { I18nProviderProps, RouterProvider } from '@koobiq/react-primitives';
3
3
  export type Breakpoints = {
4
4
  xs?: number;
5
5
  s?: number;
@@ -18,4 +18,6 @@ export type ProviderProps = {
18
18
  breakpointsFallback?: boolean[];
19
19
  /** The locale for your application as a [BCP 47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code. Defaults to the browser/OS language setting. */
20
20
  locale?: I18nProviderProps['locale'];
21
+ /** Configuration object for routing. If provided, wraps children in a RouterProvider. */
22
+ router?: Omit<Parameters<typeof RouterProvider>[0], 'children'>;
21
23
  };
@@ -1,8 +1,9 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- import { useDOMRef, useBoolean, mergeProps, clsx, useElementSize } from "@koobiq/react-core";
3
+ import { deprecate } from "@koobiq/logger";
4
+ import { useDOMRef, useBoolean, useElementSize, mergeProps, clsx } from "@koobiq/react-core";
4
5
  import { IconChevronDownS16 } from "@koobiq/react-icons";
5
- import { useSelectState, useSelect, HiddenSelect } from "@koobiq/react-primitives";
6
+ import { useSelectState, removeDataAttributes, useSelect, HiddenSelect } from "@koobiq/react-primitives";
6
7
  import s from "./Select.module.css.js";
7
8
  import { FieldSelect } from "../FieldComponents/FieldSelect/FieldSelect.js";
8
9
  import { PopoverInner } from "../Popover/Popover.js";
@@ -18,88 +19,102 @@ import { ListItemText } from "../List/components/ListItemText/ListItemText.js";
18
19
  function SelectRender(props, ref) {
19
20
  const {
20
21
  fullWidth = false,
21
- hiddenLabel = false,
22
22
  "data-testid": testId,
23
+ className,
24
+ style,
23
25
  open,
24
- onOpenChange,
25
- defaultOpen,
26
- items,
26
+ isOpen: isOpenProp,
27
+ hiddenLabel,
28
+ isLabelHidden: isLabelHiddenProp,
29
+ disabled,
30
+ isDisabled: isDisabledProp,
27
31
  error,
32
+ isInvalid: isInvalidProp,
33
+ required,
34
+ isRequired: isRequiredProp,
28
35
  caption,
36
+ placeholder,
29
37
  endAddon,
30
- required,
31
- disabled,
32
- children,
33
38
  slotProps,
34
39
  startAddon,
35
- selectedKey,
36
- placeholder,
40
+ label,
41
+ name,
37
42
  errorMessage,
38
- disabledKeys,
39
- onSelectionChange,
40
- defaultSelectedKey,
41
- renderValue: renderValueProp,
42
- ...other
43
+ renderValue: renderValueProp
43
44
  } = props;
45
+ const isOpen = isOpenProp ?? open;
46
+ const isInvalid = isInvalidProp ?? error ?? false;
47
+ const isDisabled = isDisabledProp ?? disabled ?? false;
48
+ const isRequired = isRequiredProp ?? required ?? false;
49
+ const isLabelHidden = isLabelHiddenProp ?? hiddenLabel ?? false;
50
+ if (process.env.NODE_ENV !== "production" && "disabled" in props) {
51
+ deprecate(
52
+ 'Select: the "disabled" prop is deprecated. Use "isDisabled" prop to replace it.'
53
+ );
54
+ }
55
+ if (process.env.NODE_ENV !== "production" && "required" in props) {
56
+ deprecate(
57
+ 'Select: the "required" prop is deprecated. Use "isRequired" prop to replace it.'
58
+ );
59
+ }
60
+ if (process.env.NODE_ENV !== "production" && "error" in props) {
61
+ deprecate(
62
+ 'Select: the "error" prop is deprecated. Use "isInvalid" prop to replace it.'
63
+ );
64
+ }
65
+ if (process.env.NODE_ENV !== "production" && "open" in props) {
66
+ deprecate(
67
+ 'Select: the "open" prop is deprecated. Use "isOpen" prop to replace it.'
68
+ );
69
+ }
70
+ if (process.env.NODE_ENV !== "production" && "hiddenLabel" in props) {
71
+ deprecate(
72
+ 'Select: the "hiddenLabel" prop is deprecated. Use "isLabelHidden" prop to replace it.'
73
+ );
74
+ }
75
+ const domRef = useDOMRef(ref);
44
76
  const state = useSelectState({
45
- ...other,
46
- items,
47
- defaultOpen,
48
- onOpenChange,
49
- isOpen: open,
50
- placeholder,
51
- selectedKey,
52
- disabledKeys,
53
- errorMessage,
54
- isInvalid: error,
55
- onSelectionChange,
56
- defaultSelectedKey,
57
- isRequired: required,
58
- isDisabled: disabled,
59
- children
77
+ ...removeDataAttributes(props),
78
+ isOpen,
79
+ isInvalid,
80
+ isDisabled,
81
+ isRequired
60
82
  });
61
- const domRef = useDOMRef(ref);
62
83
  const [opened, { on, off }] = useBoolean(state.isOpen);
63
84
  const {
64
85
  menuProps,
65
86
  valueProps,
66
87
  triggerProps,
67
- labelProps: labelPropsCommon
88
+ labelProps: labelPropsAria,
89
+ descriptionProps,
90
+ errorMessageProps
68
91
  } = useSelect(
69
92
  {
70
- ...other,
71
- placeholder,
72
- errorMessage,
73
- disabledKeys,
74
- isInvalid: error,
75
- isRequired: required,
76
- isDisabled: disabled
93
+ ...removeDataAttributes(props),
94
+ isOpen,
95
+ isInvalid,
96
+ isDisabled,
97
+ isRequired
77
98
  },
78
99
  { ...state, isOpen: state.isOpen || opened },
79
100
  domRef
80
101
  );
81
- const rootProps = mergeProps(
82
- {
83
- "data-testid": testId,
84
- "data-fullwidth": fullWidth,
85
- "data-disabled": disabled,
86
- "data-required": required,
87
- "data-error": error,
88
- className: clsx(s.base, fullWidth && s.fullWidth)
89
- },
90
- other
91
- );
92
102
  const { ref: containerRef, width } = useElementSize();
103
+ const rootProps = mergeProps({
104
+ "data-testid": testId,
105
+ "data-invalid": isInvalid,
106
+ "data-fullwidth": fullWidth,
107
+ "data-disabled": isDisabled,
108
+ "data-required": isRequired,
109
+ className: clsx(s.base, fullWidth && s.fullWidth, className),
110
+ style
111
+ });
93
112
  const listProps = mergeProps(
94
113
  { className: s.list, state },
95
114
  slotProps?.list,
96
115
  menuProps
97
116
  );
98
- const labelProps = mergeProps(
99
- { hidden: hiddenLabel, required },
100
- slotProps?.label,
101
- labelPropsCommon
102
- );
117
+ const labelProps = mergeProps({ isHidden: isLabelHidden, isRequired }, slotProps?.label, labelPropsAria);
103
118
  const groupProps = mergeProps(
104
119
  {
105
120
  slotProps: {
@@ -111,15 +126,15 @@ function SelectRender(props, ref) {
111
126
  endAddon,
112
127
  /* @__PURE__ */ jsx(IconChevronDownS16, {})
113
128
  ] }),
114
- error,
129
+ isInvalid,
115
130
  ref: containerRef
116
131
  },
117
132
  slotProps?.group
118
133
  );
119
134
  const controlProps = mergeProps(
120
135
  {
121
- error,
122
- disabled,
136
+ isInvalid,
137
+ isDisabled,
123
138
  ref: domRef,
124
139
  placeholder
125
140
  },
@@ -127,8 +142,8 @@ function SelectRender(props, ref) {
127
142
  valueProps,
128
143
  triggerProps
129
144
  );
130
- const captionProps = slotProps?.caption;
131
- const errorProps = mergeProps({ error }, slotProps?.errorMessage);
145
+ const captionProps = mergeProps({ isInvalid }, slotProps?.caption, descriptionProps);
146
+ const errorProps = mergeProps({ isInvalid }, slotProps?.errorMessage, errorMessageProps);
132
147
  const popoverProps = mergeProps(
133
148
  {
134
149
  state,
@@ -152,15 +167,15 @@ function SelectRender(props, ref) {
152
167
  const renderValue = renderValueProp || renderDefaultValue;
153
168
  return /* @__PURE__ */ jsxs(Fragment, { children: [
154
169
  /* @__PURE__ */ jsxs(FieldControl, { ...rootProps, children: [
155
- /* @__PURE__ */ jsx(FieldLabel, { ...labelProps, children: props.label }),
170
+ /* @__PURE__ */ jsx(FieldLabel, { ...labelProps, children: label }),
156
171
  /* @__PURE__ */ jsx(
157
172
  HiddenSelect,
158
173
  {
174
+ name,
175
+ label,
159
176
  state,
160
- isDisabled: disabled,
161
177
  triggerRef: domRef,
162
- label: props.label,
163
- name: props.name
178
+ isDisabled
164
179
  }
165
180
  ),
166
181
  /* @__PURE__ */ jsx(FieldInputGroup, { ...groupProps, children: /* @__PURE__ */ jsx(FieldSelect, { ...controlProps, children: renderValue(state?.selectedItem) }) }),
@@ -5,6 +5,47 @@ import type { ListPropItems, ListPropChildren, ListPropDisabledKeys } from '../L
5
5
  import type { PopoverProps } from '../Popover';
6
6
  export type SelectKey = string | number;
7
7
  export type SelectPropOnSelectionChange = (selected: SelectKey) => void;
8
+ type SelectDeprecatedProps = {
9
+ /**
10
+ * If `true`, the component is disabled.
11
+ * @default false
12
+ *
13
+ * @deprecated
14
+ * The "disabled" prop is deprecated. Use "isDisabled" prop to replace it.
15
+ */
16
+ disabled?: boolean;
17
+ /**
18
+ * If `true`, the input will indicate an error.
19
+ * @default false
20
+ *
21
+ * @deprecated
22
+ * The "error" prop is deprecated. Use "isInvalid" prop to replace it.
23
+ */
24
+ error?: boolean;
25
+ /**
26
+ * If `true`, the label is displayed as required and the input element is required.
27
+ * @default false
28
+ *
29
+ * @deprecated
30
+ * The "required" prop is deprecated. Use "isRequired" prop to replace it.
31
+ */
32
+ required?: boolean;
33
+ /**
34
+ * Sets the open state of the menu.
35
+ *
36
+ * @deprecated
37
+ * The "open" prop is deprecated. Use "isOpen" prop to replace it.
38
+ */
39
+ open?: boolean;
40
+ /**
41
+ * If `true`, the label is hidden. Be sure to add aria-label to the input element.
42
+ * @default false
43
+ *
44
+ * @deprecated
45
+ * The "hiddenLabel" prop is deprecated. Use "isLabelHidden" prop to replace it.
46
+ */
47
+ hiddenLabel?: boolean;
48
+ };
8
49
  export type SelectProps<T extends object> = {
9
50
  /** Additional CSS-classes. */
10
51
  className?: string;
@@ -26,14 +67,14 @@ export type SelectProps<T extends object> = {
26
67
  * If `true`, the input will indicate an error.
27
68
  * @default false
28
69
  */
29
- error?: boolean;
70
+ isInvalid?: boolean;
30
71
  /** Message for the error state */
31
72
  errorMessage?: string | number;
32
73
  /**
33
74
  * If `true`, the label is hidden. Be sure to add aria-label to the input element.
34
75
  * @default false
35
76
  */
36
- hiddenLabel?: boolean;
77
+ isLabelHidden?: boolean;
37
78
  /** The helper text content. */
38
79
  caption?: string | number;
39
80
  /**
@@ -45,12 +86,12 @@ export type SelectProps<T extends object> = {
45
86
  * If `true`, the component is disabled.
46
87
  * @default false
47
88
  */
48
- disabled?: boolean;
89
+ isDisabled?: boolean;
49
90
  /**
50
91
  * If `true`, the label is displayed as required and the input element is required.
51
92
  * @default false
52
93
  */
53
- required?: boolean;
94
+ isRequired?: boolean;
54
95
  /** Unique identifier for testing purposes. */
55
96
  'data-testid'?: string | number;
56
97
  /** Ref to the control */
@@ -64,7 +105,7 @@ export type SelectProps<T extends object> = {
64
105
  /** Handler that is called when the selection changes. */
65
106
  onSelectionChange?: SelectPropOnSelectionChange;
66
107
  /** Sets the open state of the menu. */
67
- open?: boolean;
108
+ isOpen?: boolean;
68
109
  /** Sets the default open state of the menu. */
69
110
  defaultOpen?: boolean;
70
111
  /** Method that is called when the open state of the menu changes. */
@@ -82,6 +123,7 @@ export type SelectProps<T extends object> = {
82
123
  group?: FieldInputGroupProps;
83
124
  errorMessage?: FieldErrorProps;
84
125
  };
85
- };
126
+ } & SelectDeprecatedProps;
86
127
  export type SelectComponentProp = <T extends object>(props: SelectProps<T>) => ReactElement | null;
87
128
  export type SelectRef = ComponentRef<'button'>;
129
+ export {};