@koobiq/react-components 0.19.0 → 0.21.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/Autocomplete/Autocomplete.js +8 -11
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +59 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.module.css.js +32 -0
- package/dist/components/Breadcrumbs/BreadcrumbsContext.d.ts +7 -0
- package/dist/components/Breadcrumbs/BreadcrumbsContext.js +9 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbItem/BreadcrumbItem.d.ts +4 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbItem/BreadcrumbItem.js +70 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbItem/BreadcrumbItem.module.css.js +32 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbItem/index.d.ts +2 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbItem/types.d.ts +14 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/BreadcrumbsCollapse.d.ts +2 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/BreadcrumbsCollapse.js +123 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/index.d.ts +1 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/utils.d.ts +2 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/utils.js +11 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbsWrap/BreadcrumbsWrap.d.ts +2 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbsWrap/BreadcrumbsWrap.js +27 -0
- package/dist/components/Breadcrumbs/components/BreadcrumbsWrap/index.d.ts +1 -0
- package/dist/components/Breadcrumbs/components/index.d.ts +3 -0
- package/dist/components/Breadcrumbs/index.d.ts +3 -0
- package/dist/components/Breadcrumbs/types.d.ts +69 -0
- package/dist/components/Breadcrumbs/types.js +6 -0
- package/dist/components/Dialog/components/DialogBody.d.ts +3 -2
- package/dist/components/Dialog/components/DialogBody.js +6 -6
- package/dist/components/Dialog/components/DialogCloseButton.d.ts +1 -24
- package/dist/components/FormField/FormFieldCaption/FormFieldCaption.d.ts +1 -5
- package/dist/components/FormField/FormFieldClearButton/FormFieldClearButton.d.ts +6 -0
- package/dist/components/FormField/FormFieldClearButton/FormFieldClearButton.js +32 -0
- package/dist/components/FormField/FormFieldClearButton/FormFieldClearButton.module.css.js +8 -0
- package/dist/components/FormField/FormFieldClearButton/index.d.ts +1 -0
- package/dist/components/FormField/index.d.ts +1 -0
- package/dist/components/Input/Input.d.ts +4 -1
- package/dist/components/Input/Input.js +19 -2
- package/dist/components/Input/types.d.ts +6 -0
- package/dist/components/Menu/Menu.js +3 -1
- package/dist/components/Menu/types.d.ts +3 -2
- package/dist/components/Modal/Modal.js +5 -10
- package/dist/components/Popover/PopoverInner.d.ts +1 -1
- package/dist/components/Popover/PopoverInner.js +5 -9
- package/dist/components/SearchInput/SearchInput.js +13 -16
- package/dist/components/Select/Select.js +7 -10
- package/dist/components/Select/components/Tag/Tag.d.ts +4 -3
- package/dist/components/Select/components/Tag/Tag.js +3 -1
- package/dist/components/Select/components/TagGroup/TagGroup.module.css.js +1 -4
- package/dist/components/Select/components/TagGroup/TagGroupResponsive.js +4 -2
- package/dist/components/Select/intl.js +0 -2
- package/dist/components/SidePanel/SidePanel.js +5 -10
- package/dist/components/Tabs/utils.d.ts +1 -1
- package/dist/components/Textarea/Textarea.d.ts +1 -1
- package/dist/components/ToastProvider/components/Toast/Toast.js +1 -1
- package/dist/components/ToastProvider/components/ToastRegion/ToastRegion.js +3 -2
- package/dist/components/Tooltip/Tooltip.d.ts +2 -1
- package/dist/components/Tooltip/types.d.ts +3 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/index.js +9 -0
- package/dist/style.css +342 -143
- package/package.json +7 -7
- /package/dist/components/{Autocomplete → FormField/FormFieldClearButton}/intl.json.js +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type IconButtonProps } from '../../IconButton';
|
|
2
|
+
export type FormFieldClearButtonProps = {
|
|
3
|
+
isHidden?: boolean;
|
|
4
|
+
isClearable?: boolean;
|
|
5
|
+
} & IconButtonProps;
|
|
6
|
+
export declare const FormFieldClearButton: import("react").ForwardRefExoticComponent<Omit<FormFieldClearButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useLocalizedStringFormatter, clsx } from "@koobiq/react-core";
|
|
4
|
+
import { IconCircleXmark16 } from "@koobiq/react-icons";
|
|
5
|
+
import s from "./FormFieldClearButton.module.css.js";
|
|
6
|
+
import intlMessages from "./intl.json.js";
|
|
7
|
+
import { IconButton } from "../../IconButton/IconButton.js";
|
|
8
|
+
import { useFormFieldControlGroup } from "../FormFieldControlGroup/FormFieldControlGroupContext.js";
|
|
9
|
+
const FormFieldClearButton = forwardRef(({ isHidden, isClearable, className, ...other }, ref) => {
|
|
10
|
+
const { isInvalid } = useFormFieldControlGroup();
|
|
11
|
+
const t = useLocalizedStringFormatter(intlMessages);
|
|
12
|
+
if (!isClearable) return null;
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
IconButton,
|
|
15
|
+
{
|
|
16
|
+
slot: "clear-button",
|
|
17
|
+
"aria-hidden": isHidden,
|
|
18
|
+
tabIndex: isHidden ? -1 : void 0,
|
|
19
|
+
className: clsx(s.base, className),
|
|
20
|
+
variant: isInvalid ? "error" : "fade-contrast",
|
|
21
|
+
"aria-label": t.format("clear"),
|
|
22
|
+
ref,
|
|
23
|
+
preventFocusOnPress: true,
|
|
24
|
+
...other,
|
|
25
|
+
children: /* @__PURE__ */ jsx(IconCircleXmark16, {})
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
FormFieldClearButton.displayName = "FormFieldClearButton";
|
|
30
|
+
export {
|
|
31
|
+
FormFieldClearButton
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FormFieldClearButton';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TextField } from '@koobiq/react-primitives';
|
|
2
2
|
import type { FormFieldProps, FormFieldLabelProps, FormFieldInputProps, FormFieldErrorProps, FormFieldCaptionProps, FormFieldControlGroupProps } from '../FormField';
|
|
3
|
-
export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<import("@koobiq/react-primitives").TextFieldProps<HTMLInputElement>, "children" | "description" | "validationState" | "inputElementType">, "caption" | "style" | "className" | "data-testid" | "startAddon" | "endAddon" | "variant" | "slotProps" | "labelPlacement" | "labelAlign" | "fullWidth" | "isLabelHidden" | keyof {
|
|
3
|
+
export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<import("@koobiq/react-primitives").TextFieldProps<HTMLInputElement>, "children" | "description" | "validationState" | "inputElementType">, "caption" | "style" | "className" | "data-testid" | "startAddon" | "endAddon" | "variant" | "slotProps" | "labelPlacement" | "labelAlign" | "fullWidth" | "isClearable" | "isLabelHidden" | "onClear" | keyof {
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
error?: boolean;
|
|
6
6
|
required?: boolean;
|
|
@@ -15,6 +15,8 @@ export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<
|
|
|
15
15
|
isLabelHidden?: boolean;
|
|
16
16
|
labelPlacement?: import("./types").InputPropLabelPlacement;
|
|
17
17
|
labelAlign?: import("./types").InputPropLabelAlign;
|
|
18
|
+
isClearable?: boolean;
|
|
19
|
+
onClear?: () => void;
|
|
18
20
|
caption?: import("react").ReactNode;
|
|
19
21
|
style?: import("react").CSSProperties;
|
|
20
22
|
'data-testid'?: string | number;
|
|
@@ -24,6 +26,7 @@ export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<
|
|
|
24
26
|
caption?: FormFieldCaptionProps;
|
|
25
27
|
group?: FormFieldControlGroupProps;
|
|
26
28
|
errorMessage?: FormFieldErrorProps;
|
|
29
|
+
clearButton?: import("..").IconButtonProps;
|
|
27
30
|
input?: FormFieldInputProps;
|
|
28
31
|
};
|
|
29
32
|
} & {
|
|
@@ -5,13 +5,16 @@ import { deprecate } from "@koobiq/logger";
|
|
|
5
5
|
import { useDOMRef, mergeProps } from "@koobiq/react-core";
|
|
6
6
|
import { TextField } from "@koobiq/react-primitives";
|
|
7
7
|
import s from "./Input.module.css.js";
|
|
8
|
+
import { FormFieldClearButton } from "../FormField/FormFieldClearButton/FormFieldClearButton.js";
|
|
8
9
|
import { useForm } from "../Form/FormContext.js";
|
|
9
10
|
import { FormField } from "../FormField/FormField.js";
|
|
10
11
|
const Input = forwardRef((props, ref) => {
|
|
11
12
|
const {
|
|
12
13
|
variant = "filled",
|
|
14
|
+
onClear,
|
|
13
15
|
fullWidth,
|
|
14
16
|
hiddenLabel,
|
|
17
|
+
isClearable,
|
|
15
18
|
isLabelHidden: isLabelHiddenProp,
|
|
16
19
|
disabled,
|
|
17
20
|
isDisabled: isDisabledProp,
|
|
@@ -74,23 +77,37 @@ const Input = forwardRef((props, ref) => {
|
|
|
74
77
|
errorMessage,
|
|
75
78
|
labelPlacement,
|
|
76
79
|
labelAlign,
|
|
80
|
+
isClearable,
|
|
81
|
+
onClear,
|
|
77
82
|
"data-variant": variant,
|
|
78
83
|
...other
|
|
79
84
|
},
|
|
80
85
|
slotProps?.root
|
|
81
86
|
);
|
|
82
|
-
return /* @__PURE__ */ jsx(FormField, { as: TextField, inputElementType: "input", ...rootProps, children: ({ isInvalid: isInvalid2, isRequired: isRequired2, isDisabled: isDisabled2 }) => {
|
|
87
|
+
return /* @__PURE__ */ jsx(FormField, { as: TextField, inputElementType: "input", ...rootProps, children: ({ isInvalid: isInvalid2, isRequired: isRequired2, isDisabled: isDisabled2, state }) => {
|
|
88
|
+
const hasValue = state.value !== "";
|
|
89
|
+
const clearButtonIsHidden = !hasValue || isDisabled2 || isReadOnly;
|
|
83
90
|
const labelProps = mergeProps(
|
|
84
91
|
{ isHidden: isLabelHidden, isRequired: isRequired2, children: label },
|
|
85
92
|
slotProps?.label
|
|
86
93
|
);
|
|
94
|
+
const clearButtonProps = mergeProps(
|
|
95
|
+
{
|
|
96
|
+
isClearable,
|
|
97
|
+
isHidden: clearButtonIsHidden
|
|
98
|
+
},
|
|
99
|
+
slotProps?.clearButton
|
|
100
|
+
);
|
|
87
101
|
const inputProps = mergeProps(
|
|
88
102
|
{ ref: inputRef },
|
|
89
103
|
slotProps?.input
|
|
90
104
|
);
|
|
91
105
|
const groupProps = mergeProps(
|
|
92
106
|
{
|
|
93
|
-
endAddon,
|
|
107
|
+
endAddon: (isClearable || endAddon) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
108
|
+
/* @__PURE__ */ jsx(FormFieldClearButton, { ...clearButtonProps }),
|
|
109
|
+
endAddon
|
|
110
|
+
] }),
|
|
94
111
|
variant,
|
|
95
112
|
onMouseDown: (e) => {
|
|
96
113
|
if (e.currentTarget !== e.target) return;
|
|
@@ -2,6 +2,7 @@ import type { ComponentRef, CSSProperties, ReactNode } from 'react';
|
|
|
2
2
|
import type { ExtendableProps } from '@koobiq/react-core';
|
|
3
3
|
import type { TextField, TextFieldProps } from '@koobiq/react-primitives';
|
|
4
4
|
import type { FormFieldProps, FormFieldLabelProps, FormFieldInputProps, FormFieldErrorProps, FormFieldCaptionProps, FormFieldPropLabelAlign, FormFieldControlGroupProps, FormFieldPropLabelPlacement, FormFieldControlGroupPropVariant } from '../FormField';
|
|
5
|
+
import type { IconButtonProps } from '../IconButton';
|
|
5
6
|
export declare const inputPropVariant: readonly ["filled", "transparent"];
|
|
6
7
|
export declare const inputPropLabelPlacement: readonly ["top", "side"];
|
|
7
8
|
export type InputPropVariant = FormFieldControlGroupPropVariant;
|
|
@@ -70,6 +71,10 @@ export type InputProps = ExtendableProps<{
|
|
|
70
71
|
* @default 'start'
|
|
71
72
|
*/
|
|
72
73
|
labelAlign?: InputPropLabelAlign;
|
|
74
|
+
/** Whether the field can be emptied. */
|
|
75
|
+
isClearable?: boolean;
|
|
76
|
+
/** Handler that is called when the clear button is clicked. */
|
|
77
|
+
onClear?: () => void;
|
|
73
78
|
/** The helper text content. */
|
|
74
79
|
caption?: ReactNode;
|
|
75
80
|
/** Inline styles. */
|
|
@@ -83,6 +88,7 @@ export type InputProps = ExtendableProps<{
|
|
|
83
88
|
caption?: FormFieldCaptionProps;
|
|
84
89
|
group?: FormFieldControlGroupProps;
|
|
85
90
|
errorMessage?: FormFieldErrorProps;
|
|
91
|
+
clearButton?: IconButtonProps;
|
|
86
92
|
input?: FormFieldInputProps;
|
|
87
93
|
};
|
|
88
94
|
} & InputDeprecatedProps, Omit<TextFieldProps<HTMLInputElement>, 'description' | 'children' | 'inputElementType' | 'validationState'>>;
|
|
@@ -54,10 +54,12 @@ function MenuRender(props, ref) {
|
|
|
54
54
|
slotProps?.popover
|
|
55
55
|
);
|
|
56
56
|
const listProps = mergeProps(menuProps, other, slotProps?.list);
|
|
57
|
+
const { elementType, ...menuControlProps } = menuTriggerProps;
|
|
57
58
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
58
59
|
control?.({
|
|
60
|
+
as: elementType,
|
|
59
61
|
ref: controlRef,
|
|
60
|
-
...
|
|
62
|
+
...menuControlProps
|
|
61
63
|
}),
|
|
62
64
|
/* @__PURE__ */ jsx(PopoverInner, { type: "menu", placement, ...popoverProps, children: /* @__PURE__ */ jsx(MenuList, { ...listProps }) })
|
|
63
65
|
] });
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ComponentPropsWithRef, ComponentRef, CSSProperties, ReactElement, Ref, RefObject } from 'react';
|
|
1
|
+
import type { ComponentPropsWithRef, ComponentRef, ElementType, CSSProperties, ReactElement, Ref, RefObject } from 'react';
|
|
2
2
|
import type { ExtendableProps } from '@koobiq/react-core';
|
|
3
3
|
import type { ButtonOptions, AriaMenuProps } from '@koobiq/react-primitives';
|
|
4
4
|
import type { PopoverProps, PopoverPropPlacement } from '../Popover';
|
|
5
|
-
export type MenuPropControl = (props: ButtonOptions & {
|
|
5
|
+
export type MenuPropControl = (props: Omit<ButtonOptions, 'elementType'> & {
|
|
6
6
|
ref?: Ref<HTMLButtonElement>;
|
|
7
|
+
as?: ElementType;
|
|
7
8
|
}) => ReactElement;
|
|
8
9
|
export type MenuPropPlacement = PopoverPropPlacement;
|
|
9
10
|
type MenuDeprecatedProps = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
4
|
import { deprecate } from "@koobiq/logger";
|
|
5
5
|
import { useBoolean, useDOMRef, mergeProps, clsx } from "@koobiq/react-core";
|
|
6
6
|
import { useOverlayTriggerState, useOverlayTrigger, useModalOverlay, Overlay } from "@koobiq/react-primitives";
|
|
@@ -47,7 +47,7 @@ const ModalComponent = forwardRef((props, ref) => {
|
|
|
47
47
|
{ type: "dialog" },
|
|
48
48
|
{ ...state, isOpen: isOpenState }
|
|
49
49
|
);
|
|
50
|
-
const { modalProps:
|
|
50
|
+
const { modalProps: modalPropsAria, underlayProps } = useModalOverlay(
|
|
51
51
|
{
|
|
52
52
|
...props,
|
|
53
53
|
shouldCloseOnInteractOutside,
|
|
@@ -57,12 +57,6 @@ const ModalComponent = forwardRef((props, ref) => {
|
|
|
57
57
|
{ ...state, isOpen: isOpened },
|
|
58
58
|
modalRef
|
|
59
59
|
);
|
|
60
|
-
const resolvedChildren = () => {
|
|
61
|
-
if (typeof children === "function")
|
|
62
|
-
return cloneElement(children({ close }), overlayProps);
|
|
63
|
-
if (isValidElement(children)) return cloneElement(children, overlayProps);
|
|
64
|
-
return children;
|
|
65
|
-
};
|
|
66
60
|
const containerProps = mergeProps(
|
|
67
61
|
{
|
|
68
62
|
ref: containerRef,
|
|
@@ -81,16 +75,17 @@ const ModalComponent = forwardRef((props, ref) => {
|
|
|
81
75
|
onClose: close,
|
|
82
76
|
role: "dialog",
|
|
83
77
|
hideCloseButton,
|
|
84
|
-
children:
|
|
78
|
+
children: typeof children === "function" ? children({ close }) : children
|
|
85
79
|
},
|
|
80
|
+
overlayProps,
|
|
86
81
|
slotProps?.dialog
|
|
87
82
|
);
|
|
88
83
|
const modalProps = mergeProps(
|
|
89
|
-
modalCommonProps,
|
|
90
84
|
{
|
|
91
85
|
ref: modalRef,
|
|
92
86
|
className: s.modal
|
|
93
87
|
},
|
|
88
|
+
modalPropsAria,
|
|
94
89
|
slotProps?.modal
|
|
95
90
|
);
|
|
96
91
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useRef
|
|
2
|
+
import { useRef } from "react";
|
|
3
3
|
import { useDOMRef, useBoolean, mergeProps, clsx } from "@koobiq/react-core";
|
|
4
4
|
import { useOverlayTrigger, usePopover, Overlay } from "@koobiq/react-primitives";
|
|
5
5
|
import { Transition } from "react-transition-group";
|
|
@@ -63,12 +63,6 @@ const PopoverInner = (props) => {
|
|
|
63
63
|
},
|
|
64
64
|
{ ...state, isOpen: openState || opened }
|
|
65
65
|
);
|
|
66
|
-
const resolvedChildren = () => {
|
|
67
|
-
if (typeof children === "function")
|
|
68
|
-
return cloneElement(children({ close: state.close }), overlayProps);
|
|
69
|
-
if (isValidElement(children)) return cloneElement(children, overlayProps);
|
|
70
|
-
return children;
|
|
71
|
-
};
|
|
72
66
|
const arrowProps = mergeProps(
|
|
73
67
|
{ className: s.arrow },
|
|
74
68
|
arrowPropsCommon,
|
|
@@ -81,6 +75,7 @@ const PopoverInner = (props) => {
|
|
|
81
75
|
className: s.dialog,
|
|
82
76
|
onClose: state.close
|
|
83
77
|
},
|
|
78
|
+
overlayProps,
|
|
84
79
|
slotProps?.dialog
|
|
85
80
|
);
|
|
86
81
|
const backdropProps = mergeProps(
|
|
@@ -100,6 +95,7 @@ const PopoverInner = (props) => {
|
|
|
100
95
|
},
|
|
101
96
|
slotProps?.transition
|
|
102
97
|
);
|
|
98
|
+
const resolvedChildren = typeof children === "function" ? children({ close: state.close }) : children;
|
|
103
99
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
104
100
|
control?.({
|
|
105
101
|
ref: controlRef,
|
|
@@ -117,9 +113,9 @@ const PopoverInner = (props) => {
|
|
|
117
113
|
{
|
|
118
114
|
ref: domRef,
|
|
119
115
|
"data-size": size,
|
|
120
|
-
"data-arrow": showArrow || void 0,
|
|
121
116
|
"data-placement": placement,
|
|
122
117
|
"data-transition": transition,
|
|
118
|
+
"data-arrow": showArrow || void 0,
|
|
123
119
|
className: clsx(s.base, s[size], className),
|
|
124
120
|
...mergeProps(popoverProps, other),
|
|
125
121
|
style: {
|
|
@@ -129,7 +125,7 @@ const PopoverInner = (props) => {
|
|
|
129
125
|
},
|
|
130
126
|
children: [
|
|
131
127
|
showArrow && /* @__PURE__ */ jsx("div", { ...arrowProps, "data-placement": placement }),
|
|
132
|
-
/* @__PURE__ */ jsx("div", { className: s.container, children: type === "dialog" ? /* @__PURE__ */ jsx(Dialog, { ...dialogProps, children: resolvedChildren
|
|
128
|
+
/* @__PURE__ */ jsx("div", { className: s.container, children: type === "dialog" ? /* @__PURE__ */ jsx(Dialog, { ...dialogProps, children: resolvedChildren }) : resolvedChildren })
|
|
133
129
|
]
|
|
134
130
|
}
|
|
135
131
|
)
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
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
|
-
import { IconMagnifyingGlass16
|
|
5
|
+
import { IconMagnifyingGlass16 } from "@koobiq/react-icons";
|
|
6
6
|
import { useSearchFieldState, removeDataAttributes, useSlottedContext, FormContext, useSearchField, FieldErrorContext } from "@koobiq/react-primitives";
|
|
7
7
|
import s from "./SearchInput.module.css.js";
|
|
8
8
|
import { useForm } from "../Form/FormContext.js";
|
|
9
|
-
import {
|
|
9
|
+
import { FormFieldClearButton } from "../FormField/FormFieldClearButton/FormFieldClearButton.js";
|
|
10
10
|
import { FormField } from "../FormField/FormField.js";
|
|
11
11
|
const SearchInput = forwardRef(
|
|
12
12
|
(props, ref) => {
|
|
@@ -38,7 +38,7 @@ const SearchInput = forwardRef(
|
|
|
38
38
|
const inputRef = useDOMRef(ref);
|
|
39
39
|
const { validationBehavior: formValidationBehavior } = useSlottedContext(FormContext) || {};
|
|
40
40
|
const validationBehavior = props.validationBehavior ?? formValidationBehavior ?? "aria";
|
|
41
|
-
const
|
|
41
|
+
const clearButtonIsHidden = state.value === "" || isDisabled || isReadOnly;
|
|
42
42
|
const {
|
|
43
43
|
labelProps: labelPropsAria,
|
|
44
44
|
inputProps: inputPropsAria,
|
|
@@ -84,24 +84,21 @@ const SearchInput = forwardRef(
|
|
|
84
84
|
inputPropsAria,
|
|
85
85
|
slotProps?.input
|
|
86
86
|
);
|
|
87
|
+
const clearButtonProps = mergeProps(
|
|
88
|
+
{
|
|
89
|
+
className: s.clearButton,
|
|
90
|
+
isHidden: clearButtonIsHidden,
|
|
91
|
+
isClearable: true
|
|
92
|
+
},
|
|
93
|
+
clearButtonPropsAria,
|
|
94
|
+
slotProps?.clearButton
|
|
95
|
+
);
|
|
87
96
|
const groupProps = mergeProps(
|
|
88
97
|
{
|
|
89
98
|
slotProps: { startAddon: { className: s.startAddon } },
|
|
90
99
|
startAddon,
|
|
91
100
|
endAddon: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
92
|
-
|
|
93
|
-
IconButton,
|
|
94
|
-
{
|
|
95
|
-
...clearButtonPropsAria,
|
|
96
|
-
variant: isInvalid ? "error" : "fade-contrast",
|
|
97
|
-
...slotProps?.clearButton,
|
|
98
|
-
className: clsx(
|
|
99
|
-
s.clearButton,
|
|
100
|
-
slotProps?.clearButton?.className
|
|
101
|
-
),
|
|
102
|
-
children: /* @__PURE__ */ jsx(IconCircleXmark16, {})
|
|
103
|
-
}
|
|
104
|
-
),
|
|
101
|
+
/* @__PURE__ */ jsx(FormFieldClearButton, { ...clearButtonProps }),
|
|
105
102
|
endAddon
|
|
106
103
|
] }),
|
|
107
104
|
onMouseDown: (e) => {
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, useCallback } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { useDOMRef, useElementSize, mergeProps } from "@koobiq/react-core";
|
|
5
|
+
import { IconChevronDownS16 } from "@koobiq/react-icons";
|
|
6
6
|
import { useSlottedContext, FormContext, useMultiSelectState, removeDataAttributes, useMultiSelect, FieldErrorContext } from "@koobiq/react-primitives";
|
|
7
7
|
import { PopoverInner } from "../Popover/PopoverInner.js";
|
|
8
|
-
import intlMessages from "./intl.js";
|
|
9
8
|
import s from "./Select.module.css.js";
|
|
10
9
|
import { SelectList } from "./components/SelectList/SelectList.js";
|
|
11
10
|
import { TagGroup } from "./components/TagGroup/TagGroup.js";
|
|
12
11
|
import { List } from "../List/List.js";
|
|
13
12
|
import { useForm } from "../Form/FormContext.js";
|
|
14
|
-
import {
|
|
13
|
+
import { FormFieldClearButton } from "../FormField/FormFieldClearButton/FormFieldClearButton.js";
|
|
15
14
|
import { FormField } from "../FormField/FormField.js";
|
|
16
15
|
import { Item } from "../Collections/Item.js";
|
|
17
16
|
import { Section } from "../Collections/Section.js";
|
|
@@ -46,14 +45,13 @@ function SelectRender(props, ref) {
|
|
|
46
45
|
} = props;
|
|
47
46
|
const { isDisabled: formIsDisabled } = useForm();
|
|
48
47
|
const isDisabled = isDisabledProp ?? formIsDisabled;
|
|
49
|
-
const t = useLocalizedStringFormatter(intlMessages);
|
|
50
48
|
const domRef = useDOMRef(ref);
|
|
51
49
|
const { validationBehavior: formValidationBehavior } = useSlottedContext(FormContext) || {};
|
|
52
50
|
const validationBehavior = props.validationBehavior ?? formValidationBehavior ?? "aria";
|
|
53
51
|
const state = useMultiSelectState(
|
|
54
52
|
removeDataAttributes({ ...props, isDisabled, selectionMode })
|
|
55
53
|
);
|
|
56
|
-
const
|
|
54
|
+
const clearButtonIsHidden = isDisabled || !state.selectedItems;
|
|
57
55
|
const handleClear = useCallback(() => {
|
|
58
56
|
state.selectionManager.setSelectedKeys(/* @__PURE__ */ new Set());
|
|
59
57
|
onClear?.();
|
|
@@ -109,11 +107,10 @@ function SelectRender(props, ref) {
|
|
|
109
107
|
);
|
|
110
108
|
const clearButtonProps = mergeProps(
|
|
111
109
|
{
|
|
112
|
-
|
|
110
|
+
isClearable,
|
|
113
111
|
onPress: handleClear,
|
|
114
112
|
className: s.clearButton,
|
|
115
|
-
|
|
116
|
-
preventFocusOnPress: true
|
|
113
|
+
isHidden: clearButtonIsHidden
|
|
117
114
|
},
|
|
118
115
|
slotProps?.clearButton
|
|
119
116
|
);
|
|
@@ -132,7 +129,7 @@ function SelectRender(props, ref) {
|
|
|
132
129
|
},
|
|
133
130
|
endAddon: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
134
131
|
endAddon,
|
|
135
|
-
|
|
132
|
+
/* @__PURE__ */ jsx(FormFieldClearButton, { ...clearButtonProps }),
|
|
136
133
|
/* @__PURE__ */ jsx("span", { className: s.chevron, children: /* @__PURE__ */ jsx(IconChevronDownS16, {}) })
|
|
137
134
|
] }),
|
|
138
135
|
isInvalid,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
|
|
2
3
|
import type { TagGroupPropVariant } from '../../../TagGroup';
|
|
3
|
-
type TagProps = {
|
|
4
|
+
type TagProps = ExtendableComponentPropsWithRef<{
|
|
4
5
|
/**
|
|
5
6
|
* The variant to use.
|
|
6
7
|
* @default 'theme-fade'
|
|
@@ -12,6 +13,6 @@ type TagProps = {
|
|
|
12
13
|
icon?: ReactNode;
|
|
13
14
|
isDisabled?: boolean;
|
|
14
15
|
onRemove?: () => void;
|
|
15
|
-
}
|
|
16
|
-
export declare const Tag: import("react").ForwardRefExoticComponent<TagProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
16
|
+
}, 'div'>;
|
|
17
|
+
export declare const Tag: import("react").ForwardRefExoticComponent<Omit<TagProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
17
18
|
export {};
|
|
@@ -17,7 +17,8 @@ const Tag = forwardRef((props, ref) => {
|
|
|
17
17
|
style,
|
|
18
18
|
isDisabled,
|
|
19
19
|
children,
|
|
20
|
-
onRemove
|
|
20
|
+
onRemove,
|
|
21
|
+
...other
|
|
21
22
|
} = props;
|
|
22
23
|
const stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
23
24
|
const rootProps = mergeProps({
|
|
@@ -28,6 +29,7 @@ const Tag = forwardRef((props, ref) => {
|
|
|
28
29
|
textNormalMedium,
|
|
29
30
|
className
|
|
30
31
|
),
|
|
32
|
+
...other,
|
|
31
33
|
style
|
|
32
34
|
});
|
|
33
35
|
const removeButtonProps = {
|
|
@@ -3,21 +3,18 @@ const hasStartAddon = "kbq-taggroup-hasStartAddon-40d1f9";
|
|
|
3
3
|
const base = "kbq-taggroup-8253a5";
|
|
4
4
|
const tag = "kbq-taggroup-tag-b9306f";
|
|
5
5
|
const more = "kbq-taggroup-more-b2d6b9";
|
|
6
|
-
const hidden = "kbq-taggroup-hidden-eadb46";
|
|
7
6
|
const s = {
|
|
8
7
|
container,
|
|
9
8
|
hasStartAddon,
|
|
10
9
|
base,
|
|
11
10
|
tag,
|
|
12
|
-
more
|
|
13
|
-
hidden
|
|
11
|
+
more
|
|
14
12
|
};
|
|
15
13
|
export {
|
|
16
14
|
base,
|
|
17
15
|
container,
|
|
18
16
|
s as default,
|
|
19
17
|
hasStartAddon,
|
|
20
|
-
hidden,
|
|
21
18
|
more,
|
|
22
19
|
tag
|
|
23
20
|
};
|
|
@@ -34,9 +34,10 @@ const TagGroupResponsive = ({
|
|
|
34
34
|
children: state.selectedItems?.map((item, i) => /* @__PURE__ */ jsx(
|
|
35
35
|
Tag,
|
|
36
36
|
{
|
|
37
|
+
className: s.tag,
|
|
37
38
|
ref: itemsRefs[i],
|
|
38
|
-
className: clsx(s.tag, !visibleMap[i] && s.hidden),
|
|
39
39
|
isDisabled,
|
|
40
|
+
"aria-hidden": !visibleMap[i] || void 0,
|
|
40
41
|
variant: isInvalid ? "error-fade" : "contrast-fade",
|
|
41
42
|
onRemove: () => {
|
|
42
43
|
if (state.selectionManager.isSelected(item.key)) {
|
|
@@ -52,8 +53,9 @@ const TagGroupResponsive = ({
|
|
|
52
53
|
/* @__PURE__ */ jsx(
|
|
53
54
|
"div",
|
|
54
55
|
{
|
|
56
|
+
className: s.more,
|
|
55
57
|
ref: itemsRefs[itemsRefs.length - 1],
|
|
56
|
-
|
|
58
|
+
"aria-hidden": !visibleMap[length] || void 0,
|
|
57
59
|
children: t.format("more", { count: hiddenCount })
|
|
58
60
|
}
|
|
59
61
|
)
|
|
@@ -3,14 +3,12 @@ const intlMessages = {
|
|
|
3
3
|
"empty items": "Нет вариантов выбора",
|
|
4
4
|
loading: "Загрузка…",
|
|
5
5
|
"selected items": "Выбранные элементы",
|
|
6
|
-
clear: "Очистить",
|
|
7
6
|
more: ({ count }) => `еще ${count}`
|
|
8
7
|
},
|
|
9
8
|
"en-US": {
|
|
10
9
|
"empty items": "No options available",
|
|
11
10
|
"selected items": "Selected items",
|
|
12
11
|
loading: "Loading…",
|
|
13
|
-
clear: "Clear",
|
|
14
12
|
more: ({ count }) => `${count} more`
|
|
15
13
|
}
|
|
16
14
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
4
|
import { deprecate } from "@koobiq/logger";
|
|
5
5
|
import { useBoolean, useDOMRef, mergeProps, clsx } from "@koobiq/react-core";
|
|
6
6
|
import { useOverlayTriggerState, useOverlayTrigger, useModalOverlay, Overlay } from "@koobiq/react-primitives";
|
|
@@ -55,7 +55,7 @@ const SidePanelComponent = forwardRef(
|
|
|
55
55
|
{ type: "dialog" },
|
|
56
56
|
{ ...state, isOpen: isOpenState }
|
|
57
57
|
);
|
|
58
|
-
const { modalProps:
|
|
58
|
+
const { modalProps: modalPropsAria, underlayProps } = useModalOverlay(
|
|
59
59
|
{
|
|
60
60
|
...props,
|
|
61
61
|
shouldCloseOnInteractOutside,
|
|
@@ -65,12 +65,6 @@ const SidePanelComponent = forwardRef(
|
|
|
65
65
|
{ ...state, isOpen: isOpened },
|
|
66
66
|
modalRef
|
|
67
67
|
);
|
|
68
|
-
const resolvedChildren = () => {
|
|
69
|
-
if (typeof children === "function")
|
|
70
|
-
return cloneElement(children({ close }), overlayProps);
|
|
71
|
-
if (isValidElement(children)) return cloneElement(children, overlayProps);
|
|
72
|
-
return children;
|
|
73
|
-
};
|
|
74
68
|
const containerProps = mergeProps(
|
|
75
69
|
{
|
|
76
70
|
ref: containerRef,
|
|
@@ -90,12 +84,13 @@ const SidePanelComponent = forwardRef(
|
|
|
90
84
|
onClose: close,
|
|
91
85
|
role: "dialog",
|
|
92
86
|
hideCloseButton,
|
|
93
|
-
children:
|
|
87
|
+
children: typeof children === "function" ? children({ close }) : children
|
|
94
88
|
},
|
|
89
|
+
overlayProps,
|
|
95
90
|
slotProps?.dialog
|
|
96
91
|
);
|
|
97
92
|
const panelProps = mergeProps(
|
|
98
|
-
|
|
93
|
+
modalPropsAria,
|
|
99
94
|
{
|
|
100
95
|
ref: modalRef,
|
|
101
96
|
className: s.panel
|
|
@@ -12,4 +12,4 @@ export type TabsMeta = {
|
|
|
12
12
|
};
|
|
13
13
|
activeTabMeta: null | DOMRect;
|
|
14
14
|
};
|
|
15
|
-
export declare const getTabsMeta: (tabListRef: RefObject<HTMLElement>, scrollBoxRef: RefObject<HTMLElement>, activeTabRef: RefObject<HTMLElement>) => TabsMeta;
|
|
15
|
+
export declare const getTabsMeta: (tabListRef: RefObject<HTMLElement | null>, scrollBoxRef: RefObject<HTMLElement | null>, activeTabRef: RefObject<HTMLElement | null>) => TabsMeta;
|
|
@@ -4,7 +4,7 @@ export declare const Textarea: import("react").ForwardRefExoticComponent<Omit<{
|
|
|
4
4
|
required?: boolean;
|
|
5
5
|
hiddenLabel?: boolean;
|
|
6
6
|
readonly?: boolean;
|
|
7
|
-
} & Omit<import("@koobiq/react-primitives").TextFieldProps<HTMLTextAreaElement>, "children" | "style" | "className" | "description" | "validationState" | "inputElementType">, "caption" | "style" | "className" | "cols" | "
|
|
7
|
+
} & Omit<import("@koobiq/react-primitives").TextFieldProps<HTMLTextAreaElement>, "children" | "style" | "className" | "description" | "validationState" | "inputElementType">, "caption" | "style" | "className" | "cols" | "data-testid" | "rows" | "variant" | "slotProps" | "labelPlacement" | "labelAlign" | "fullWidth" | "isLabelHidden" | "expand"> & {
|
|
8
8
|
className?: string;
|
|
9
9
|
style?: import("react").CSSProperties;
|
|
10
10
|
variant?: import("./types").TextareaPropVariant;
|
|
@@ -59,7 +59,7 @@ function Toast({
|
|
|
59
59
|
{ variant: "theme-contrast", className: s.closeIcon },
|
|
60
60
|
slotProps?.closeIcon
|
|
61
61
|
);
|
|
62
|
-
return /* @__PURE__ */ jsx("div", { ...toastProps, children: /* @__PURE__ */ jsxs("div", { className: s.wrapper, children: [
|
|
62
|
+
return /* @__PURE__ */ jsx("div", { ...toastProps, tabIndex: void 0, children: /* @__PURE__ */ jsxs("div", { className: s.wrapper, children: [
|
|
63
63
|
!hideCloseButton && /* @__PURE__ */ jsx(IconButton, { ...closeButtonProps, children: /* @__PURE__ */ jsx(IconXmarkS16, {}) }),
|
|
64
64
|
!hideIcon && /* @__PURE__ */ jsx(
|
|
65
65
|
ToastStatusIcon,
|
|
@@ -42,8 +42,9 @@ function ToastRegionRender({
|
|
|
42
42
|
},
|
|
43
43
|
props
|
|
44
44
|
);
|
|
45
|
+
const visibleToasts = stackDirection === "ascending" ? [...state.visibleToasts].reverse() : state.visibleToasts;
|
|
45
46
|
return createPortal(
|
|
46
|
-
/* @__PURE__ */ jsx("div", { ...regionProps, children: /* @__PURE__ */ jsx(TransitionGroup, { component: null, appear: true, enter: true, children:
|
|
47
|
+
/* @__PURE__ */ jsx("div", { ...regionProps, children: /* @__PURE__ */ jsx(TransitionGroup, { component: null, appear: true, enter: true, children: visibleToasts.map((toast, idx) => {
|
|
47
48
|
const nodeRef = getNodeRef(toast.key);
|
|
48
49
|
return /* @__PURE__ */ jsx(
|
|
49
50
|
Transition,
|
|
@@ -62,7 +63,7 @@ function ToastRegionRender({
|
|
|
62
63
|
"data-transition": transition,
|
|
63
64
|
"data-placement": placement,
|
|
64
65
|
style: {
|
|
65
|
-
|
|
66
|
+
"--toast-transition-z-index": stackDirection === "ascending" ? -(idx + 1) : -(total - (idx + 1)),
|
|
66
67
|
"--toast-transition-block-size": `${inner?.clientHeight}px`,
|
|
67
68
|
"--toast-transition-duration": `${TRANSITION_TIMEOUT}ms`
|
|
68
69
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const Tooltip: import("react").ForwardRefExoticComponent<Omit<import("@react-types/tooltip").TooltipTriggerProps, "children" | "
|
|
1
|
+
export declare const Tooltip: import("react").ForwardRefExoticComponent<Omit<import("@react-types/tooltip").TooltipTriggerProps, "children" | "style" | "className" | "id" | "placement" | `data-${string}` | "variant" | "offset" | "control" | "portalContainer" | "anchorRef" | "hideArrow" | "arrowBoundaryOffset" | "crossOffset" | "delay" | "closeDelay" | keyof {
|
|
2
2
|
open?: boolean;
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
}> & {
|
|
@@ -15,6 +15,7 @@ export declare const Tooltip: import("react").ForwardRefExoticComponent<Omit<imp
|
|
|
15
15
|
closeDelay?: number;
|
|
16
16
|
id?: string;
|
|
17
17
|
className?: string;
|
|
18
|
+
style?: import("react").CSSProperties;
|
|
18
19
|
portalContainer?: Element;
|
|
19
20
|
} & {
|
|
20
21
|
open?: boolean;
|