@koobiq/react-components 0.9.0 → 0.11.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/dist/components/DateInput/DateInput.js +8 -2
- package/dist/components/Dialog/components/DialogCloseButton.d.ts +2 -2
- package/dist/components/FieldComponents/FieldSelect/FieldSelect.js +1 -1
- package/dist/components/Form/Form.d.ts +19 -0
- package/dist/components/Form/Form.js +63 -0
- package/dist/components/Form/Form.module.css.js +17 -0
- package/dist/components/Form/FormContext.d.ts +7 -0
- package/dist/components/Form/FormContext.js +7 -0
- package/dist/components/Form/index.d.ts +3 -0
- package/dist/components/Form/types.d.ts +30 -0
- package/dist/components/Form/types.js +18 -0
- package/dist/components/Form/utils.d.ts +15 -0
- package/dist/components/Form/utils.js +18 -0
- package/dist/components/FormControl/FormControl.js +25 -24
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/InputNumber/InputNumber.d.ts +1 -1
- package/dist/components/List/List.js +4 -3
- package/dist/components/List/List.module.css.js +1 -4
- package/dist/components/List/components/ListSection/ListSection.js +5 -4
- package/dist/components/List/types.d.ts +2 -0
- package/dist/components/Menu/Menu.js +2 -2
- package/dist/components/Menu/components/MenuList/MenuList.d.ts +6 -0
- package/dist/components/Menu/components/{MenuInner/MenuInner.js → MenuList/MenuList.js} +6 -5
- package/dist/components/Menu/components/MenuList/MenuList.module.css.js +8 -0
- package/dist/components/Menu/components/MenuList/index.d.ts +1 -0
- package/dist/components/Menu/components/MenuSection/MenuSection.js +4 -3
- package/dist/components/Menu/components/index.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.js +8 -2
- package/dist/components/Select/Select.js +12 -8
- package/dist/components/Select/components/SelectList/SelectList.d.ts +4 -2
- package/dist/components/Select/components/SelectList/SelectList.js +35 -7
- package/dist/components/Select/components/SelectList/SelectList.module.css.js +3 -3
- package/dist/components/Select/intl.js +2 -0
- package/dist/components/Select/types.d.ts +4 -2
- package/dist/components/Textarea/Textarea.d.ts +1 -1
- package/dist/components/Textarea/components/TextareaContextConsumer/TextareaContextConsumer.d.ts +1 -1
- package/dist/components/TimePicker/TimePicker.js +4 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/index.js +10 -0
- package/dist/style.css +94 -51
- package/dist/styles/utility.d.ts +1 -0
- package/dist/styles/utility.js +2 -1
- package/dist/styles/utility.module.css.js +2 -1
- package/dist/utils/index.d.ts +1 -0
- package/package.json +5 -5
- package/dist/components/List/components/ListSection/ListSection.module.css.js +0 -11
- package/dist/components/Menu/components/MenuInner/MenuInner.d.ts +0 -6
- package/dist/components/Menu/components/MenuInner/MenuInner.module.css.js +0 -11
- package/dist/components/Menu/components/MenuInner/index.d.ts +0 -1
- package/dist/components/Menu/components/MenuSection/MenuSection.module.css.js +0 -11
- /package/dist/{components/FieldComponents/FieldSelect/utils.d.ts → utils/isPrimitiveNode.d.ts} +0 -0
- /package/dist/{components/FieldComponents/FieldSelect/utils.js → utils/isPrimitiveNode.js} +0 -0
|
@@ -3,7 +3,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { createCalendar } from "@internationalized/date";
|
|
5
5
|
import { useLocale, useDOMRef, mergeProps, clsx } from "@koobiq/react-core";
|
|
6
|
-
import { useDateFieldState, removeDataAttributes, useDateField, FieldErrorContext } from "@koobiq/react-primitives";
|
|
6
|
+
import { useDateFieldState, removeDataAttributes, useSlottedContext, FormContext, useDateField, FieldErrorContext } from "@koobiq/react-primitives";
|
|
7
7
|
import s from "./DateInput.module.css.js";
|
|
8
8
|
import { FieldInputDate } from "../FieldComponents/FieldInputDate/FieldInputDate.js";
|
|
9
9
|
import { DateSegment } from "../DateSegment/DateSegment.js";
|
|
@@ -38,6 +38,8 @@ function DateInputRender(props, ref) {
|
|
|
38
38
|
createCalendar
|
|
39
39
|
});
|
|
40
40
|
const domRef = useDOMRef(ref);
|
|
41
|
+
const { validationBehavior: formValidationBehavior } = useSlottedContext(FormContext) || {};
|
|
42
|
+
const validationBehavior = props.validationBehavior ?? formValidationBehavior ?? "aria";
|
|
41
43
|
const {
|
|
42
44
|
labelProps: labelPropReactAria,
|
|
43
45
|
fieldProps,
|
|
@@ -45,7 +47,11 @@ function DateInputRender(props, ref) {
|
|
|
45
47
|
errorMessageProps,
|
|
46
48
|
inputProps,
|
|
47
49
|
...validation
|
|
48
|
-
} = useDateField(
|
|
50
|
+
} = useDateField(
|
|
51
|
+
{ ...removeDataAttributes(props), validationBehavior },
|
|
52
|
+
state,
|
|
53
|
+
domRef
|
|
54
|
+
);
|
|
49
55
|
const { isRequired, isDisabled } = state;
|
|
50
56
|
const { isInvalid } = validation;
|
|
51
57
|
const rootProps = mergeProps(
|
|
@@ -4,10 +4,10 @@ export type DialogCloseButtonRef = ComponentRef<'button'>;
|
|
|
4
4
|
export type DialogCloseButtonProps = ButtonProps;
|
|
5
5
|
export declare const DialogCloseButton: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
6
6
|
ref?: ((instance: HTMLButtonElement | 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<HTMLButtonElement> | null | undefined;
|
|
7
|
-
}, "children" | "value" | "form" | "style" | "as" | "className" | "autoFocus" | "id" | "tabIndex" | "rel" | "aria-controls" | "aria-describedby" | "aria-details" | "aria-expanded" | "aria-haspopup" | "aria-label" | "aria-labelledby" | "aria-pressed" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "onClick" | "name" | "target" | "type" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "fullWidth" | "isDisabled" | "onPress" | "onPressStart" | "onPressEnd" | "onPressChange" | "onPressUp" | "onFocusChange" | "preventFocusOnPress" | "excludeFromTabOrder" | keyof import("@react-types/shared").HoverEvents | "isLoading" | "
|
|
7
|
+
}, "children" | "value" | "form" | "style" | "as" | "className" | "autoFocus" | "id" | "tabIndex" | "rel" | "aria-controls" | "aria-describedby" | "aria-details" | "aria-expanded" | "aria-haspopup" | "aria-label" | "aria-labelledby" | "aria-pressed" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "onClick" | "name" | "target" | "type" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "variant" | "fullWidth" | "isDisabled" | "onPress" | "onPressStart" | "onPressEnd" | "onPressChange" | "onPressUp" | "onFocusChange" | "preventFocusOnPress" | "excludeFromTabOrder" | keyof import("@react-types/shared").HoverEvents | "isLoading" | "onlyIcon" | "startIcon" | "endIcon" | "data-testid" | keyof {
|
|
8
8
|
progress?: boolean;
|
|
9
9
|
disabled?: boolean;
|
|
10
|
-
}> & Omit<Omit<import("@koobiq/react-primitives").ButtonBaseProps, "slot">, "children" | "style" | "className" | "
|
|
10
|
+
}> & Omit<Omit<import("@koobiq/react-primitives").ButtonBaseProps, "slot">, "children" | "style" | "className" | "variant" | "fullWidth" | "onlyIcon" | "startIcon" | "endIcon" | "data-testid" | keyof {
|
|
11
11
|
progress?: boolean;
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
}> & {
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { polymorphicForwardRef, clsx, isNotNil } from "@koobiq/react-core";
|
|
3
3
|
import { Button } from "@koobiq/react-primitives";
|
|
4
4
|
import s from "./FieldSelect.module.css.js";
|
|
5
|
-
import { isPrimitiveNode } from "
|
|
5
|
+
import { isPrimitiveNode } from "../../../utils/isPrimitiveNode.js";
|
|
6
6
|
const FieldSelect = polymorphicForwardRef(
|
|
7
7
|
({
|
|
8
8
|
variant = "filled",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const FormComponent: import("react").ForwardRefExoticComponent<{
|
|
2
|
+
labelPlacement?: import("..").FormControlPropLabelPlacement | import("../../utils").ResponsiveValue<import("..").FormControlPropLabelPlacement>;
|
|
3
|
+
labelAlign?: import("..").FormControlPropLabelAlign | import("../../utils").ResponsiveValue<import("..").FormControlPropLabelAlign>;
|
|
4
|
+
labelInlineSize?: import("./types").FormPropLabelInlineSize | import("../../utils").ResponsiveValue<import("./types").FormPropLabelInlineSize>;
|
|
5
|
+
} & import("@koobiq/react-primitives").FormProps & import("react").RefAttributes<HTMLFormElement>>;
|
|
6
|
+
export declare const Fieldset: import("@koobiq/react-core").PolyForwardComponent<"div", {
|
|
7
|
+
className?: string;
|
|
8
|
+
}, import("react").ElementType>;
|
|
9
|
+
export declare const Legend: import("@koobiq/react-core").PolyForwardComponent<"p", Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & {
|
|
10
|
+
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;
|
|
11
|
+
}, "as" | keyof import("..").TypographyBaseProps> & import("..").TypographyBaseProps & {
|
|
12
|
+
as?: "p" | undefined;
|
|
13
|
+
}, import("react").ElementType>;
|
|
14
|
+
type CompoundedComponent = typeof FormComponent & {
|
|
15
|
+
Fieldset: typeof Fieldset;
|
|
16
|
+
Legend: typeof Legend;
|
|
17
|
+
};
|
|
18
|
+
export declare const Form: CompoundedComponent;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { polymorphicForwardRef, clsx } from "@koobiq/react-core";
|
|
4
|
+
import { Form as Form$1 } from "@koobiq/react-primitives";
|
|
5
|
+
import s from "./Form.module.css.js";
|
|
6
|
+
import { FormContext } from "./FormContext.js";
|
|
7
|
+
import { templatePresets } from "./utils.js";
|
|
8
|
+
import { Typography } from "../Typography/Typography.js";
|
|
9
|
+
import { useMatchedBreakpoints } from "../Provider/BreakpointsContext.js";
|
|
10
|
+
import { getResponsiveValue } from "../../utils/getResponsiveValue/getResponsiveValue.js";
|
|
11
|
+
const FormComponent = forwardRef((props, ref) => {
|
|
12
|
+
const {
|
|
13
|
+
labelPlacement: labelPlacementProp,
|
|
14
|
+
labelAlign: labelAlignProp,
|
|
15
|
+
labelInlineSize: labelInlineSizeProp,
|
|
16
|
+
className,
|
|
17
|
+
style,
|
|
18
|
+
...other
|
|
19
|
+
} = props;
|
|
20
|
+
const breakpoints = useMatchedBreakpoints();
|
|
21
|
+
const labelPlacement = getResponsiveValue(labelPlacementProp, breakpoints);
|
|
22
|
+
const labelAlign = getResponsiveValue(labelAlignProp, breakpoints);
|
|
23
|
+
const labelInlineSize = getResponsiveValue(labelInlineSizeProp, breakpoints);
|
|
24
|
+
const orientation = labelPlacement === "side" ? "horizontal" : "vertical";
|
|
25
|
+
const formStyle = labelInlineSize ? {
|
|
26
|
+
"--template-columns": templatePresets[labelInlineSize]
|
|
27
|
+
} : void 0;
|
|
28
|
+
return /* @__PURE__ */ jsx(FormContext.Provider, { value: { labelPlacement, labelAlign }, children: /* @__PURE__ */ jsx(
|
|
29
|
+
Form$1,
|
|
30
|
+
{
|
|
31
|
+
"data-orientation": orientation,
|
|
32
|
+
className: clsx(s.base, s[orientation], className),
|
|
33
|
+
style: { ...style, ...formStyle },
|
|
34
|
+
...other,
|
|
35
|
+
ref
|
|
36
|
+
}
|
|
37
|
+
) });
|
|
38
|
+
});
|
|
39
|
+
const Fieldset = polymorphicForwardRef(
|
|
40
|
+
({ className, as: Tag = "fieldset", ...other }, ref) => /* @__PURE__ */ jsx(Tag, { className: clsx(s.fieldset, className), ...other, ref })
|
|
41
|
+
);
|
|
42
|
+
const Legend = polymorphicForwardRef(
|
|
43
|
+
({ className, as = "p", ...other }, ref) => /* @__PURE__ */ jsx(
|
|
44
|
+
Typography,
|
|
45
|
+
{
|
|
46
|
+
as,
|
|
47
|
+
variant: "text-big",
|
|
48
|
+
className: clsx(s.legend, className),
|
|
49
|
+
...other,
|
|
50
|
+
ref
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
FormComponent.displayName = "Form";
|
|
55
|
+
const Form = FormComponent;
|
|
56
|
+
Form.Fieldset = Fieldset;
|
|
57
|
+
Form.Legend = Legend;
|
|
58
|
+
export {
|
|
59
|
+
Fieldset,
|
|
60
|
+
Form,
|
|
61
|
+
FormComponent,
|
|
62
|
+
Legend
|
|
63
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const base = "kbq-form-40d37e";
|
|
2
|
+
const fieldset = "kbq-form-fieldset-b2924b";
|
|
3
|
+
const legend = "kbq-form-legend-91e738";
|
|
4
|
+
const horizontal = "kbq-form-horizontal-52dea8";
|
|
5
|
+
const s = {
|
|
6
|
+
base,
|
|
7
|
+
fieldset,
|
|
8
|
+
legend,
|
|
9
|
+
horizontal
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
base,
|
|
13
|
+
s as default,
|
|
14
|
+
fieldset,
|
|
15
|
+
horizontal,
|
|
16
|
+
legend
|
|
17
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FormControlPropLabelAlign, FormControlPropLabelPlacement } from '../FormControl';
|
|
2
|
+
export type FormContextProps = {
|
|
3
|
+
labelPlacement?: FormControlPropLabelPlacement;
|
|
4
|
+
labelAlign?: FormControlPropLabelAlign;
|
|
5
|
+
};
|
|
6
|
+
export declare const FormContext: import("react").Context<FormContextProps>;
|
|
7
|
+
export declare const useForm: () => FormContextProps;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ComponentRef } from 'react';
|
|
2
|
+
import type { FormProps as FormPropsPrimitive } from '@koobiq/react-primitives';
|
|
3
|
+
import type { ResponsiveValue } from '../../utils';
|
|
4
|
+
import type { FormControlPropLabelAlign, FormControlPropLabelPlacement } from '../FormControl';
|
|
5
|
+
export declare const formPropLabelInlineSize: readonly ["80", "128", "160", "200", "240", "280", "320", "360", "400", "1/4", "2/5", "1/2", "max-content"];
|
|
6
|
+
export type FormPropLabelInlineSize = (typeof formPropLabelInlineSize)[number];
|
|
7
|
+
export type FormProps = {
|
|
8
|
+
/**
|
|
9
|
+
* The label's overall position relative to the element it is labeling.
|
|
10
|
+
* Responsive values allowed.
|
|
11
|
+
* @default 'top'
|
|
12
|
+
*/
|
|
13
|
+
labelPlacement?: FormControlPropLabelPlacement | ResponsiveValue<FormControlPropLabelPlacement>;
|
|
14
|
+
/**
|
|
15
|
+
* The label's horizontal alignment relative to the element it is labeling.
|
|
16
|
+
* Responsive values allowed.
|
|
17
|
+
* @default 'start'
|
|
18
|
+
*/
|
|
19
|
+
labelAlign?: FormControlPropLabelAlign | ResponsiveValue<FormControlPropLabelAlign>;
|
|
20
|
+
/**
|
|
21
|
+
* Size of the label column when `labelPlacement="side"`.
|
|
22
|
+
* Ignored for `"top"`.
|
|
23
|
+
*
|
|
24
|
+
* Supports px tokens (`'80'–'400'`), fractions (`'1/4'`, `'2/5'`, `'1/2'`),
|
|
25
|
+
* or `'max-content'`. Responsive values allowed.
|
|
26
|
+
* @default 'max-content'
|
|
27
|
+
*/
|
|
28
|
+
labelInlineSize?: FormPropLabelInlineSize | ResponsiveValue<FormPropLabelInlineSize>;
|
|
29
|
+
} & FormPropsPrimitive;
|
|
30
|
+
export type FormRef = ComponentRef<'form'>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const templatePresets: {
|
|
2
|
+
'max-content': undefined;
|
|
3
|
+
'1/4': string;
|
|
4
|
+
'2/5': string;
|
|
5
|
+
'1/2': string;
|
|
6
|
+
'80': string;
|
|
7
|
+
'128': string;
|
|
8
|
+
'160': string;
|
|
9
|
+
'200': string;
|
|
10
|
+
'240': string;
|
|
11
|
+
'280': string;
|
|
12
|
+
'320': string;
|
|
13
|
+
'360': string;
|
|
14
|
+
'400': string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const templatePresets = {
|
|
2
|
+
"max-content": void 0,
|
|
3
|
+
"1/4": "1fr 3fr",
|
|
4
|
+
"2/5": "2fr 3fr",
|
|
5
|
+
"1/2": "1fr 1fr",
|
|
6
|
+
"80": "80px 1fr",
|
|
7
|
+
"128": "128px 1fr",
|
|
8
|
+
"160": "160px 1fr",
|
|
9
|
+
"200": "200px 1fr",
|
|
10
|
+
"240": "240px 1fr",
|
|
11
|
+
"280": "280px 1fr",
|
|
12
|
+
"320": "320px 1fr",
|
|
13
|
+
"360": "360px 1fr",
|
|
14
|
+
"400": "400px 1fr"
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
templatePresets
|
|
18
|
+
};
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { polymorphicForwardRef, clsx } from "@koobiq/react-core";
|
|
3
3
|
import s from "./FormControl.module.css.js";
|
|
4
|
+
import { useForm } from "../Form/FormContext.js";
|
|
4
5
|
const FormControl = polymorphicForwardRef(
|
|
5
|
-
({
|
|
6
|
-
|
|
7
|
-
labelAlign =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
(props, ref) => {
|
|
7
|
+
const { as: Tag = "div", fullWidth, className, ...other } = props;
|
|
8
|
+
const { labelPlacement: formLabelPlacement, labelAlign: formLabelAlign } = useForm();
|
|
9
|
+
const labelPlacement = props.labelPlacement ?? formLabelPlacement ?? "top";
|
|
10
|
+
const labelAlign = props.labelAlign ?? formLabelAlign ?? "start";
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
Tag,
|
|
13
|
+
{
|
|
14
|
+
className: clsx(
|
|
15
|
+
s.base,
|
|
16
|
+
className,
|
|
17
|
+
s[labelAlign],
|
|
18
|
+
s[labelPlacement],
|
|
19
|
+
fullWidth && s.fullWidth
|
|
20
|
+
),
|
|
21
|
+
"data-slot": "form-control",
|
|
22
|
+
"data-label-align": labelAlign,
|
|
23
|
+
"data-label-placement": labelPlacement,
|
|
24
|
+
"data-fullwidth": fullWidth || void 0,
|
|
25
|
+
...other,
|
|
26
|
+
ref
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
29
30
|
);
|
|
30
31
|
FormControl.displayName = "FormControl";
|
|
31
32
|
export {
|
|
@@ -2,7 +2,7 @@ import { TextField } from '@koobiq/react-primitives';
|
|
|
2
2
|
import { type FieldContentGroupProps, type FieldCaptionProps, type FieldInputProps, type FieldErrorProps } from '../FieldComponents';
|
|
3
3
|
import { type FormControlProps } from '../FormControl';
|
|
4
4
|
import { type FormControlLabelProps } from '../FormControlLabel';
|
|
5
|
-
export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<import("@koobiq/react-primitives").TextFieldProps<HTMLInputElement>, "children" | "validationState" | "description" | "inputElementType">, "caption" | "style" | "className" | "
|
|
5
|
+
export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<import("@koobiq/react-primitives").TextFieldProps<HTMLInputElement>, "children" | "validationState" | "description" | "inputElementType">, "caption" | "style" | "className" | "variant" | "labelPlacement" | "labelAlign" | "fullWidth" | "slotProps" | "data-testid" | "startAddon" | "endAddon" | "isLabelHidden" | keyof {
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
error?: boolean;
|
|
8
8
|
required?: boolean;
|
|
@@ -2,7 +2,7 @@ import { NumberField } from '@koobiq/react-primitives';
|
|
|
2
2
|
import { type FieldCaptionProps, type FieldContentGroupProps, type FieldInputProps, type FieldErrorProps } from '../FieldComponents';
|
|
3
3
|
import { type FormControlProps } from '../FormControl';
|
|
4
4
|
import { type FormControlLabelProps } from '../FormControlLabel';
|
|
5
|
-
export declare const InputNumber: import("react").ForwardRefExoticComponent<Omit<Omit<import("@koobiq/react-primitives").NumberFieldProps, "children" | "validationState" | "description" | "inputElementType">, "caption" | "style" | "className" | "
|
|
5
|
+
export declare const InputNumber: import("react").ForwardRefExoticComponent<Omit<Omit<import("@koobiq/react-primitives").NumberFieldProps, "children" | "validationState" | "description" | "inputElementType">, "caption" | "style" | "className" | "variant" | "labelPlacement" | "labelAlign" | "fullWidth" | "slotProps" | "data-testid" | "startAddon" | "endAddon" | "isLabelHidden" | keyof {
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
error?: boolean;
|
|
8
8
|
required?: boolean;
|
|
@@ -15,7 +15,7 @@ import { Typography } from "../Typography/Typography.js";
|
|
|
15
15
|
import { ListOption } from "./components/ListOption/ListOption.js";
|
|
16
16
|
const { list } = utilClasses;
|
|
17
17
|
function ListInner(props) {
|
|
18
|
-
const { label, className, style, slotProps, state, listRef } = props;
|
|
18
|
+
const { label, className, style, slotProps, state, listRef, isPadded } = props;
|
|
19
19
|
const domRef = useDOMRef(listRef);
|
|
20
20
|
const { listBoxProps, labelProps } = useListBox(props, state, domRef);
|
|
21
21
|
const titleProps = mergeProps(
|
|
@@ -30,7 +30,8 @@ function ListInner(props) {
|
|
|
30
30
|
{
|
|
31
31
|
style,
|
|
32
32
|
ref: domRef,
|
|
33
|
-
className: clsx(list, className)
|
|
33
|
+
className: clsx(list, className),
|
|
34
|
+
"data-padded": isPadded || void 0
|
|
34
35
|
},
|
|
35
36
|
slotProps?.list,
|
|
36
37
|
listBoxProps
|
|
@@ -38,7 +39,7 @@ function ListInner(props) {
|
|
|
38
39
|
const renderItems = (listState) => [...listState.collection].map((item) => {
|
|
39
40
|
switch (item.type) {
|
|
40
41
|
case "divider":
|
|
41
|
-
return /* @__PURE__ */ jsx(Divider, {
|
|
42
|
+
return /* @__PURE__ */ jsx(Divider, {}, item.key);
|
|
42
43
|
case "item":
|
|
43
44
|
return /* @__PURE__ */ jsx(ListOption, { item, state }, item.key);
|
|
44
45
|
case "section":
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useListBoxSection } from "@koobiq/react-primitives";
|
|
4
|
-
import
|
|
5
|
-
import { Typography } from "../../../Typography/Typography.js";
|
|
4
|
+
import { utilClasses } from "../../../../styles/utility.js";
|
|
6
5
|
import { ListOption } from "../ListOption/ListOption.js";
|
|
6
|
+
import { Typography } from "../../../Typography/Typography.js";
|
|
7
|
+
const { listHeading } = utilClasses;
|
|
7
8
|
function ListSection({ section, state }) {
|
|
8
9
|
const { itemProps, headingProps, groupProps } = useListBoxSection({
|
|
9
10
|
heading: section.rendered,
|
|
@@ -17,12 +18,12 @@ function ListSection({ section, state }) {
|
|
|
17
18
|
display: "block",
|
|
18
19
|
variant: "caps-compact-strong",
|
|
19
20
|
color: "contrast-secondary",
|
|
20
|
-
className:
|
|
21
|
+
className: listHeading,
|
|
21
22
|
...headingProps,
|
|
22
23
|
children: section.rendered
|
|
23
24
|
}
|
|
24
25
|
),
|
|
25
|
-
/* @__PURE__ */ jsx("ul", { ...groupProps,
|
|
26
|
+
/* @__PURE__ */ jsx("ul", { ...groupProps, children: [...section.childNodes].map((node) => /* @__PURE__ */ jsx(ListOption, { item: node, state }, node.key)) })
|
|
26
27
|
] }) });
|
|
27
28
|
}
|
|
28
29
|
export {
|
|
@@ -14,6 +14,8 @@ export type ListProps<T> = ExtendableProps<{
|
|
|
14
14
|
label?: TypographyProps;
|
|
15
15
|
list?: ComponentPropsWithRef<'div'>;
|
|
16
16
|
};
|
|
17
|
+
/** Whether the component has outer padding. */
|
|
18
|
+
isPadded?: boolean;
|
|
17
19
|
}, AriaListBoxProps<T>>;
|
|
18
20
|
export type ListRef = ComponentRef<'ul'>;
|
|
19
21
|
export type ListComponent = <T>(props: ListProps<T>) => ReactElement | null;
|
|
@@ -6,7 +6,7 @@ import { useDOMRef, mergeProps, clsx, Pressable } from "@koobiq/react-core";
|
|
|
6
6
|
import { useMenuTriggerState, useMenuTrigger } from "@koobiq/react-primitives";
|
|
7
7
|
import { PopoverInner } from "../Popover/PopoverInner.js";
|
|
8
8
|
import s from "./Menu.module.css.js";
|
|
9
|
-
import {
|
|
9
|
+
import { MenuList } from "./components/MenuList/MenuList.js";
|
|
10
10
|
import { Header } from "../Collections/Header.js";
|
|
11
11
|
import { Item } from "../Collections/Item.js";
|
|
12
12
|
import { Section } from "../Collections/Section.js";
|
|
@@ -59,7 +59,7 @@ function MenuRender(props, ref) {
|
|
|
59
59
|
ref: controlRef,
|
|
60
60
|
...menuTriggerProps
|
|
61
61
|
}),
|
|
62
|
-
/* @__PURE__ */ jsx(PopoverInner, { type: "menu", placement, ...popoverProps, children: /* @__PURE__ */ jsx(
|
|
62
|
+
/* @__PURE__ */ jsx(PopoverInner, { type: "menu", placement, ...popoverProps, children: /* @__PURE__ */ jsx(MenuList, { ...listProps }) })
|
|
63
63
|
] });
|
|
64
64
|
}
|
|
65
65
|
const MenuComponent = forwardRef(MenuRender);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ComponentRef, ReactElement } from 'react';
|
|
2
|
+
import type { AriaMenuOptions } from '@koobiq/react-primitives';
|
|
3
|
+
export type MenuListProps<T> = AriaMenuOptions<T>;
|
|
4
|
+
export type MenuListComponent = <T>(props: MenuListProps<T>) => ReactElement | null;
|
|
5
|
+
export type MenuListRef = ComponentRef<'ul'>;
|
|
6
|
+
export declare const MenuList: MenuListComponent;
|
|
@@ -4,13 +4,13 @@ import { forwardRef } from "react";
|
|
|
4
4
|
import { useDOMRef, clsx } from "@koobiq/react-core";
|
|
5
5
|
import { useTreeState, useMenu } from "@koobiq/react-primitives";
|
|
6
6
|
import { utilClasses } from "../../../../styles/utility.js";
|
|
7
|
-
import s from "./
|
|
7
|
+
import s from "./MenuList.module.css.js";
|
|
8
8
|
import { MenuSection } from "../MenuSection/MenuSection.js";
|
|
9
9
|
import { MenuHeader } from "../MenuHeader/MenuHeader.js";
|
|
10
10
|
import { MenuItem } from "../MenuItem/MenuItem.js";
|
|
11
11
|
import { Divider } from "../../../Divider/Divider.js";
|
|
12
12
|
const { list } = utilClasses;
|
|
13
|
-
function
|
|
13
|
+
function MenuListRender(props, ref) {
|
|
14
14
|
const state = useTreeState(props);
|
|
15
15
|
const domRef = useDOMRef(ref);
|
|
16
16
|
const { menuProps } = useMenu(props, state, domRef);
|
|
@@ -20,7 +20,7 @@ function MenuInnerRender(props, ref) {
|
|
|
20
20
|
case "header":
|
|
21
21
|
return /* @__PURE__ */ jsx(MenuHeader, { item }, item.key);
|
|
22
22
|
case "divider":
|
|
23
|
-
return /* @__PURE__ */ jsx(Divider, {
|
|
23
|
+
return /* @__PURE__ */ jsx(Divider, {}, item.key);
|
|
24
24
|
case "item":
|
|
25
25
|
return /* @__PURE__ */ jsx(MenuItem, { item, state }, item.key);
|
|
26
26
|
case "section":
|
|
@@ -33,6 +33,7 @@ function MenuInnerRender(props, ref) {
|
|
|
33
33
|
"ul",
|
|
34
34
|
{
|
|
35
35
|
...menuProps,
|
|
36
|
+
"data-padded": true,
|
|
36
37
|
className: clsx(s.base, list),
|
|
37
38
|
...multiple && { "aria-multiselectable": true },
|
|
38
39
|
ref: domRef,
|
|
@@ -40,7 +41,7 @@ function MenuInnerRender(props, ref) {
|
|
|
40
41
|
}
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
|
-
const
|
|
44
|
+
const MenuList = forwardRef(MenuListRender);
|
|
44
45
|
export {
|
|
45
|
-
|
|
46
|
+
MenuList
|
|
46
47
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MenuList';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useMenuSection } from "@koobiq/react-primitives";
|
|
4
|
-
import
|
|
4
|
+
import { utilClasses } from "../../../../styles/utility.js";
|
|
5
5
|
import { MenuItem } from "../MenuItem/MenuItem.js";
|
|
6
6
|
import { Typography } from "../../../Typography/Typography.js";
|
|
7
|
+
const { listHeading } = utilClasses;
|
|
7
8
|
function MenuSection({ section, state }) {
|
|
8
9
|
const { itemProps, headingProps, groupProps } = useMenuSection({
|
|
9
10
|
heading: section.rendered,
|
|
@@ -17,12 +18,12 @@ function MenuSection({ section, state }) {
|
|
|
17
18
|
display: "block",
|
|
18
19
|
variant: "caps-compact-strong",
|
|
19
20
|
color: "contrast-secondary",
|
|
20
|
-
className:
|
|
21
|
+
className: listHeading,
|
|
21
22
|
...headingProps,
|
|
22
23
|
children: section.rendered
|
|
23
24
|
}
|
|
24
25
|
),
|
|
25
|
-
/* @__PURE__ */ jsx("ul", { ...groupProps,
|
|
26
|
+
/* @__PURE__ */ jsx("ul", { ...groupProps, children: [...section.childNodes].map((node) => /* @__PURE__ */ jsx(MenuItem, { item: node, state }, node.key)) })
|
|
26
27
|
] });
|
|
27
28
|
}
|
|
28
29
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './MenuList';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type FieldCaptionProps, type FieldContentGroupProps, type FieldInputProps, type FieldErrorProps } from '../FieldComponents';
|
|
2
2
|
import { type FormControlProps } from '../FormControl';
|
|
3
3
|
import { type FormControlLabelProps } from '../FormControlLabel';
|
|
4
|
-
export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-types/searchfield").AriaSearchFieldProps, "validationState" | "description">, "caption" | "style" | "className" |
|
|
4
|
+
export declare const SearchInput: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-types/searchfield").AriaSearchFieldProps, "validationState" | "description">, "caption" | "style" | "className" | "variant" | "labelPlacement" | "labelAlign" | `data-${string}` | "fullWidth" | "slotProps" | "startAddon" | "endAddon" | "isLabelHidden"> & {
|
|
5
5
|
className?: string;
|
|
6
6
|
style?: import("react").CSSProperties;
|
|
7
7
|
isLabelHidden?: boolean;
|
|
@@ -3,7 +3,7 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useDOMRef, mergeProps, clsx } from "@koobiq/react-core";
|
|
5
5
|
import { IconMagnifyingGlass16, IconXmarkCircle16 } from "@koobiq/react-icons";
|
|
6
|
-
import { useSearchFieldState, removeDataAttributes, useSearchField, FieldErrorContext } from "@koobiq/react-primitives";
|
|
6
|
+
import { useSearchFieldState, removeDataAttributes, useSlottedContext, FormContext, useSearchField, FieldErrorContext } from "@koobiq/react-primitives";
|
|
7
7
|
import s from "./SearchInput.module.css.js";
|
|
8
8
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
9
9
|
import { FormControl } from "../FormControl/FormControl.js";
|
|
@@ -36,6 +36,8 @@ const SearchInput = forwardRef(
|
|
|
36
36
|
} = props;
|
|
37
37
|
const state = useSearchFieldState(removeDataAttributes(props));
|
|
38
38
|
const domRef = useDOMRef(ref);
|
|
39
|
+
const { validationBehavior: formValidationBehavior } = useSlottedContext(FormContext) || {};
|
|
40
|
+
const validationBehavior = props.validationBehavior ?? formValidationBehavior ?? "aria";
|
|
39
41
|
const hasClearButton = state.value !== "" && !isDisabled && !isReadOnly;
|
|
40
42
|
const {
|
|
41
43
|
labelProps: labelPropsAria,
|
|
@@ -44,7 +46,11 @@ const SearchInput = forwardRef(
|
|
|
44
46
|
errorMessageProps: errorMessagePropsAria,
|
|
45
47
|
clearButtonProps: clearButtonPropsAria,
|
|
46
48
|
...validation
|
|
47
|
-
} = useSearchField(
|
|
49
|
+
} = useSearchField(
|
|
50
|
+
{ ...removeDataAttributes(props), validationBehavior },
|
|
51
|
+
state,
|
|
52
|
+
domRef
|
|
53
|
+
);
|
|
48
54
|
const { isInvalid } = validation;
|
|
49
55
|
const rootProps = mergeProps(
|
|
50
56
|
{
|