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

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.
@@ -1,6 +1,8 @@
1
1
  import { type TextProps, type TextRef } from '@koobiq/react-primitives';
2
- export type FieldCaptionProps = TextProps & {
3
- isInvalid?: boolean;
4
- };
2
+ export type FieldCaptionProps = TextProps;
5
3
  export type FieldCaptionRef = TextRef;
6
- export declare const FieldCaption: import("react").ForwardRefExoticComponent<Omit<FieldCaptionProps, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
4
+ export declare const FieldCaption: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & {
5
+ ref?: ((instance: HTMLParagraphElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLParagraphElement> | null | undefined;
6
+ }, "as" | keyof import("@koobiq/react-primitives").TextBaseProps> & import("@koobiq/react-primitives").TextBaseProps & {
7
+ as?: "p" | undefined;
8
+ }, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
@@ -4,7 +4,7 @@ import { isNotNil, clsx } from "@koobiq/react-core";
4
4
  import { Text } from "@koobiq/react-primitives";
5
5
  import s from "./FieldCaption.module.css.js";
6
6
  const FieldCaption = forwardRef(
7
- ({ children, className, isInvalid, ...other }, ref) => isNotNil(children) && !isInvalid ? /* @__PURE__ */ jsx(
7
+ ({ children, className, ...other }, ref) => isNotNil(children) ? /* @__PURE__ */ jsx(
8
8
  Text,
9
9
  {
10
10
  className: clsx(s.base, className),
@@ -17,12 +17,12 @@ export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<
17
17
  endAddon?: import("react").ReactNode;
18
18
  variant?: import("./types").InputPropVariant;
19
19
  isInvalid?: boolean;
20
- errorMessage?: string | number;
20
+ errorMessage?: import("react").ReactNode;
21
21
  fullWidth?: boolean;
22
22
  isDisabled?: boolean;
23
23
  isReadOnly?: boolean;
24
24
  isLabelHidden?: boolean;
25
- caption?: string | number;
25
+ caption?: import("react").ReactNode;
26
26
  isRequired?: boolean;
27
27
  style?: import("react").CSSProperties;
28
28
  'data-testid'?: string | number;
@@ -79,7 +79,10 @@ const Input = forwardRef((props, ref) => {
79
79
  slotProps?.root
80
80
  );
81
81
  return /* @__PURE__ */ jsx(FieldControl, { as: TextField, inputElementType: "input", ...rootProps, children: ({ isInvalid: isInvalid2, isRequired: isRequired2, isDisabled: isDisabled2 }) => {
82
- const labelProps = mergeProps({ isHidden: isLabelHidden, isRequired: isRequired2 }, slotProps?.label);
82
+ const labelProps = mergeProps(
83
+ { isHidden: isLabelHidden, isRequired: isRequired2, children: label },
84
+ slotProps?.label
85
+ );
83
86
  const inputProps = mergeProps(
84
87
  {
85
88
  variant,
@@ -97,16 +100,13 @@ const Input = forwardRef((props, ref) => {
97
100
  },
98
101
  slotProps?.group
99
102
  );
100
- const captionProps = mergeProps(
101
- { isInvalid: isInvalid2 },
102
- slotProps?.caption
103
- );
104
- const errorProps = mergeProps({ isInvalid: isInvalid2 }, slotProps?.errorMessage);
103
+ const captionProps = mergeProps({ children: caption }, slotProps?.caption);
104
+ const errorProps = mergeProps({ isInvalid: isInvalid2, children: errorMessage }, slotProps?.errorMessage);
105
105
  return /* @__PURE__ */ jsxs(Fragment, { children: [
106
- /* @__PURE__ */ jsx(FieldLabel, { ...labelProps, children: labelProps?.children || label }),
106
+ /* @__PURE__ */ jsx(FieldLabel, { ...labelProps }),
107
107
  /* @__PURE__ */ jsx(FieldInputGroup, { ...groupProps, children: /* @__PURE__ */ jsx(FieldInput, { ...inputProps }) }),
108
- /* @__PURE__ */ jsx(FieldCaption, { ...captionProps, children: captionProps?.children || caption }),
109
- /* @__PURE__ */ jsx(FieldError, { ...errorProps, children: errorProps.children || errorMessage })
108
+ /* @__PURE__ */ jsx(FieldCaption, { ...captionProps }),
109
+ /* @__PURE__ */ jsx(FieldError, { ...errorProps })
110
110
  ] });
111
111
  } });
112
112
  });
@@ -74,7 +74,7 @@ export type InputProps = ExtendableProps<{
74
74
  */
75
75
  isInvalid?: boolean;
76
76
  /** Message for the error state */
77
- errorMessage?: string | number;
77
+ errorMessage?: ReactNode;
78
78
  /**
79
79
  * If true, the input will take up the full width of its container.
80
80
  * @default false
@@ -96,7 +96,7 @@ export type InputProps = ExtendableProps<{
96
96
  */
97
97
  isLabelHidden?: boolean;
98
98
  /** The helper text content. */
99
- caption?: string | number;
99
+ caption?: ReactNode;
100
100
  /**
101
101
  * If `true`, the label is displayed as required and the input element is required.
102
102
  * @default false
@@ -13,11 +13,11 @@ export declare const InputNumber: import("react").ForwardRefExoticComponent<Omit
13
13
  endAddon?: import("react").ReactNode;
14
14
  variant?: import("./types").InputNumberPropVariant;
15
15
  isInvalid?: boolean;
16
- errorMessage?: string | number;
16
+ errorMessage?: import("react").ReactNode;
17
17
  fullWidth?: boolean;
18
18
  isDisabled?: boolean;
19
19
  isLabelHidden?: boolean;
20
- caption?: string | number;
20
+ caption?: import("react").ReactNode;
21
21
  isRequired?: boolean;
22
22
  style?: import("react").CSSProperties;
23
23
  'data-testid'?: string | number;
@@ -81,7 +81,10 @@ const InputNumber = forwardRef(
81
81
  slotProps?.root
82
82
  );
83
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);
84
+ const labelProps = mergeProps(
85
+ { isHidden: isLabelHidden, children: label, isRequired: isRequired2 },
86
+ slotProps?.label
87
+ );
85
88
  const inputProps = mergeProps(
86
89
  {
87
90
  variant,
@@ -91,11 +94,8 @@ const InputNumber = forwardRef(
91
94
  },
92
95
  slotProps?.input
93
96
  );
94
- const captionProps = mergeProps(
95
- { isInvalid: isInvalid2 },
96
- slotProps?.caption
97
- );
98
- const errorProps = mergeProps({ isInvalid: isInvalid2 }, slotProps?.errorMessage);
97
+ const captionProps = mergeProps({ children: caption }, slotProps?.caption);
98
+ const errorProps = mergeProps({ isInvalid: isInvalid2, children: errorMessage }, slotProps?.errorMessage);
99
99
  const groupProps = mergeProps(
100
100
  {
101
101
  endAddon: /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -109,10 +109,10 @@ const InputNumber = forwardRef(
109
109
  slotProps?.group
110
110
  );
111
111
  return /* @__PURE__ */ jsxs(Fragment, { children: [
112
- /* @__PURE__ */ jsx(FieldLabel, { ...labelProps, children: labelProps?.children || label }),
112
+ /* @__PURE__ */ jsx(FieldLabel, { ...labelProps }),
113
113
  /* @__PURE__ */ jsx(FieldInputGroup, { ...groupProps, children: /* @__PURE__ */ jsx(FieldInput, { ...inputProps }) }),
114
- /* @__PURE__ */ jsx(FieldCaption, { ...captionProps, children: captionProps?.children || caption }),
115
- /* @__PURE__ */ jsx(FieldError, { ...errorProps, children: errorProps.children || errorMessage })
114
+ /* @__PURE__ */ jsx(FieldCaption, { ...captionProps }),
115
+ /* @__PURE__ */ jsx(FieldError, { ...errorProps })
116
116
  ] });
117
117
  } });
118
118
  }
@@ -66,7 +66,7 @@ export type InputNumberProps = ExtendableProps<{
66
66
  */
67
67
  isInvalid?: boolean;
68
68
  /** Message for the error state. */
69
- errorMessage?: string | number;
69
+ errorMessage?: ReactNode;
70
70
  /**
71
71
  * If true, the input will take up the full width of its container.
72
72
  * @default false
@@ -83,7 +83,7 @@ export type InputNumberProps = ExtendableProps<{
83
83
  */
84
84
  isLabelHidden?: boolean;
85
85
  /** The helper text content. */
86
- caption?: string | number;
86
+ caption?: ReactNode;
87
87
  /**
88
88
  * If `true`, the label is displayed as required and the input element is required.
89
89
  * @default false
@@ -114,7 +114,11 @@ function SelectRender(props, ref) {
114
114
  slotProps?.list,
115
115
  menuProps
116
116
  );
117
- const labelProps = mergeProps({ isHidden: isLabelHidden, isRequired }, slotProps?.label, labelPropsAria);
117
+ const labelProps = mergeProps(
118
+ { isHidden: isLabelHidden, children: label, isRequired },
119
+ slotProps?.label,
120
+ labelPropsAria
121
+ );
118
122
  const groupProps = mergeProps(
119
123
  {
120
124
  slotProps: {
@@ -142,8 +146,12 @@ function SelectRender(props, ref) {
142
146
  valueProps,
143
147
  triggerProps
144
148
  );
145
- const captionProps = mergeProps({ isInvalid }, slotProps?.caption, descriptionProps);
146
- const errorProps = mergeProps({ isInvalid }, slotProps?.errorMessage, errorMessageProps);
149
+ const captionProps = mergeProps({ children: caption }, slotProps?.caption, descriptionProps);
150
+ const errorProps = mergeProps(
151
+ { isInvalid, children: errorMessage },
152
+ slotProps?.errorMessage,
153
+ errorMessageProps
154
+ );
147
155
  const popoverProps = mergeProps(
148
156
  {
149
157
  state,
@@ -167,7 +175,7 @@ function SelectRender(props, ref) {
167
175
  const renderValue = renderValueProp || renderDefaultValue;
168
176
  return /* @__PURE__ */ jsxs(Fragment, { children: [
169
177
  /* @__PURE__ */ jsxs(FieldControl, { ...rootProps, children: [
170
- /* @__PURE__ */ jsx(FieldLabel, { ...labelProps, children: label }),
178
+ /* @__PURE__ */ jsx(FieldLabel, { ...labelProps }),
171
179
  /* @__PURE__ */ jsx(
172
180
  HiddenSelect,
173
181
  {
@@ -179,8 +187,8 @@ function SelectRender(props, ref) {
179
187
  }
180
188
  ),
181
189
  /* @__PURE__ */ jsx(FieldInputGroup, { ...groupProps, children: /* @__PURE__ */ jsx(FieldSelect, { ...controlProps, children: renderValue(state?.selectedItem) }) }),
182
- /* @__PURE__ */ jsx(FieldCaption, { ...captionProps, children: captionProps?.children || caption }),
183
- /* @__PURE__ */ jsx(FieldError, { ...errorProps, children: errorProps.children || errorMessage })
190
+ /* @__PURE__ */ jsx(FieldCaption, { ...captionProps }),
191
+ /* @__PURE__ */ jsx(FieldError, { ...errorProps })
184
192
  ] }),
185
193
  /* @__PURE__ */ jsx(PopoverInner, { ...popoverProps, children: /* @__PURE__ */ jsx(ListInner, { ...listProps }) })
186
194
  ] });
@@ -69,14 +69,14 @@ export type SelectProps<T extends object> = {
69
69
  */
70
70
  isInvalid?: boolean;
71
71
  /** Message for the error state */
72
- errorMessage?: string | number;
72
+ errorMessage?: ReactNode;
73
73
  /**
74
74
  * If `true`, the label is hidden. Be sure to add aria-label to the input element.
75
75
  * @default false
76
76
  */
77
77
  isLabelHidden?: boolean;
78
78
  /** The helper text content. */
79
- caption?: string | number;
79
+ caption?: ReactNode;
80
80
  /**
81
81
  * If true, the input will take up the full width of its container.
82
82
  * @default false
@@ -10,11 +10,11 @@ export declare const Textarea: import("react").ForwardRefExoticComponent<Omit<{
10
10
  variant?: import("./types").TextareaPropVariant;
11
11
  isInvalid?: boolean;
12
12
  isReadOnly?: boolean;
13
- errorMessage?: string | number;
13
+ errorMessage?: import("react").ReactNode;
14
14
  fullWidth?: boolean;
15
15
  isDisabled?: boolean;
16
16
  isLabelHidden?: boolean;
17
- caption?: string | number;
17
+ caption?: import("react").ReactNode;
18
18
  isRequired?: boolean;
19
19
  rows?: number;
20
20
  cols?: number;
@@ -39,23 +39,20 @@ const TextareaContextConsumer = forwardRef((props, ref) => {
39
39
  },
40
40
  slotProps?.textarea
41
41
  );
42
- const captionProps = mergeProps(
43
- { isInvalid },
44
- slotProps?.caption
45
- );
42
+ const captionProps = mergeProps({ children: caption }, slotProps?.caption);
46
43
  const errorProps = mergeProps(
47
- { isInvalid },
44
+ { isInvalid, children: errorMessage },
48
45
  slotProps?.errorMessage
49
46
  );
50
47
  const labelProps = mergeProps(
51
- { isHidden: isLabelHidden, isRequired },
48
+ { isHidden: isLabelHidden, children: label, isRequired },
52
49
  slotProps?.label
53
50
  );
54
51
  return /* @__PURE__ */ jsxs(Fragment, { children: [
55
- /* @__PURE__ */ jsx(FieldLabel, { ...labelProps, children: labelProps.children || label }),
52
+ /* @__PURE__ */ jsx(FieldLabel, { ...labelProps }),
56
53
  /* @__PURE__ */ jsx(FieldInput, { as: "textarea", ...textareaProps }),
57
- /* @__PURE__ */ jsx(FieldCaption, { ...captionProps, children: captionProps?.children || caption }),
58
- /* @__PURE__ */ jsx(FieldError, { ...errorProps, children: errorProps.children || errorMessage })
54
+ /* @__PURE__ */ jsx(FieldCaption, { ...captionProps }),
55
+ /* @__PURE__ */ jsx(FieldError, { ...errorProps })
59
56
  ] });
60
57
  });
61
58
  TextareaContextConsumer.displayName = "TextareaContextConsumer";
@@ -69,7 +69,7 @@ export type TextareaProps = ExtendableProps<{
69
69
  */
70
70
  isReadOnly?: boolean;
71
71
  /** Message for the error state */
72
- errorMessage?: string | number;
72
+ errorMessage?: ReactNode;
73
73
  /**
74
74
  * If true, the input will take up the full width of its container.
75
75
  * @default false
@@ -86,7 +86,7 @@ export type TextareaProps = ExtendableProps<{
86
86
  */
87
87
  isLabelHidden?: boolean;
88
88
  /** The helper text content. */
89
- caption?: string | number;
89
+ caption?: ReactNode;
90
90
  /**
91
91
  * If `true`, the label is displayed as required and the input element is required.
92
92
  * @default false
package/dist/style.css CHANGED
@@ -2109,6 +2109,7 @@
2109
2109
  letter-spacing: var(--kbq-typography-text-compact-letter-spacing);
2110
2110
  text-underline-offset: calc(( var(--kbq-typography-text-compact-line-height) - var(--kbq-typography-text-compact-font-size)) / 2);
2111
2111
  color: var(--kbq-foreground-contrast-secondary);
2112
+ margin: 0;
2112
2113
  transition: color var(--kbq-transition-default);
2113
2114
  margin-block-start: var(--kbq-size-xxs);
2114
2115
  }
@@ -2124,6 +2125,7 @@
2124
2125
  letter-spacing: var(--kbq-typography-text-compact-letter-spacing);
2125
2126
  text-underline-offset: calc(( var(--kbq-typography-text-compact-line-height) - var(--kbq-typography-text-compact-font-size)) / 2);
2126
2127
  color: var(--kbq-foreground-error);
2128
+ margin: 0;
2127
2129
  transition: color var(--kbq-transition-default);
2128
2130
  margin-block-start: var(--kbq-size-xxs);
2129
2131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koobiq/react-components",
3
- "version": "0.0.1-beta.31",
3
+ "version": "0.0.1-beta.32",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -27,10 +27,10 @@
27
27
  "@koobiq/design-tokens": "^3.12.1",
28
28
  "@types/react-transition-group": "^4.4.12",
29
29
  "react-transition-group": "^4.4.5",
30
- "@koobiq/logger": "0.0.1-beta.31",
31
- "@koobiq/react-core": "0.0.1-beta.31",
32
- "@koobiq/react-icons": "0.0.1-beta.31",
33
- "@koobiq/react-primitives": "0.0.1-beta.31"
30
+ "@koobiq/logger": "0.0.1-beta.32",
31
+ "@koobiq/react-core": "0.0.1-beta.32",
32
+ "@koobiq/react-primitives": "0.0.1-beta.32",
33
+ "@koobiq/react-icons": "0.0.1-beta.32"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@koobiq/design-tokens": "^3.11.2",