@koobiq/react-components 0.3.1 → 0.5.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/types.d.ts +3 -3
- package/dist/components/DateInput/types.js +2 -1
- package/dist/components/FieldComponents/FieldContentGroup/FieldContentGroup.d.ts +2 -2
- package/dist/components/FieldComponents/FieldContentGroup/FieldContentGroup.js +5 -6
- package/dist/components/FieldComponents/FieldContentGroup/FieldContentGroupContext.d.ts +3 -2
- package/dist/components/FieldComponents/FieldContentGroup/FieldContentGroupContext.js +2 -2
- package/dist/components/FieldComponents/FieldContentGroup/types.d.ts +4 -4
- package/dist/components/FieldComponents/FieldContentGroup/types.js +4 -0
- package/dist/components/FieldComponents/FieldInput/FieldInput.d.ts +2 -2
- package/dist/components/FieldComponents/FieldInputDate/FieldInputDate.d.ts +2 -2
- package/dist/components/FieldComponents/FieldSelect/types.d.ts +2 -2
- package/dist/components/Input/Input.d.ts +3 -3
- package/dist/components/Input/types.d.ts +4 -4
- package/dist/components/Input/types.js +2 -1
- package/dist/components/InputNumber/InputNumber.d.ts +2 -2
- package/dist/components/InputNumber/components/InputNumberCounterControls.js +2 -2
- package/dist/components/InputNumber/types.d.ts +3 -3
- package/dist/components/InputNumber/types.js +2 -1
- package/dist/components/List/List.d.ts +2 -1
- package/dist/components/List/List.js +16 -3
- package/dist/components/List/List.module.css.js +4 -1
- package/dist/components/Menu/Menu.js +1 -1
- package/dist/components/Menu/components/MenuInner/MenuInner.js +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +21 -0
- package/dist/components/SearchInput/SearchInput.js +119 -0
- package/dist/components/SearchInput/SearchInput.module.css.js +17 -0
- package/dist/components/SearchInput/index.d.ts +2 -0
- package/dist/components/SearchInput/types.d.ts +47 -0
- package/dist/components/SearchInput/types.js +5 -0
- package/dist/components/Select/Select.d.ts +3 -2
- package/dist/components/Select/Select.js +83 -101
- package/dist/components/Select/Select.module.css.js +8 -2
- package/dist/components/Select/components/SelectList/SelectList.d.ts +8 -0
- package/dist/components/Select/components/SelectList/SelectList.js +51 -0
- package/dist/components/Select/components/SelectList/SelectList.module.css.js +11 -0
- package/dist/components/Select/components/SelectList/index.d.ts +1 -0
- package/dist/components/Select/components/SelectOption/SelectOption.d.ts +7 -0
- package/dist/components/Select/components/SelectOption/SelectOption.js +42 -0
- package/dist/components/Select/components/SelectOption/index.d.ts +1 -0
- package/dist/components/Select/components/Tag/Tag.d.ts +17 -0
- package/dist/components/Select/components/Tag/Tag.js +64 -0
- package/dist/components/Select/components/Tag/index.d.ts +1 -0
- package/dist/components/Select/components/Tag/intl.json.js +7 -0
- package/dist/components/Select/components/Tag/utils.d.ts +3 -0
- package/dist/components/Select/components/Tag/utils.js +9 -0
- package/dist/components/Select/components/TagGroup/TagGroup.d.ts +13 -0
- package/dist/components/Select/components/TagGroup/TagGroup.js +24 -0
- package/dist/components/Select/components/TagGroup/TagGroup.module.css.js +23 -0
- package/dist/components/Select/components/TagGroup/TagGroupMultiline.d.ts +3 -0
- package/dist/components/Select/components/TagGroup/TagGroupMultiline.js +47 -0
- package/dist/components/Select/components/TagGroup/TagGroupResponsive.d.ts +3 -0
- package/dist/components/Select/components/TagGroup/TagGroupResponsive.js +66 -0
- package/dist/components/Select/components/TagGroup/index.d.ts +1 -0
- package/dist/components/Select/components/TagGroup/utils.d.ts +1 -0
- package/dist/components/Select/components/TagGroup/utils.js +4 -0
- package/dist/components/Select/components/index.d.ts +3 -0
- package/dist/components/Select/intl.d.ts +2 -0
- package/dist/components/Select/intl.js +15 -0
- package/dist/components/Select/types.d.ts +36 -43
- package/dist/components/Select/types.js +7 -0
- package/dist/components/Textarea/types.d.ts +2 -2
- package/dist/components/Textarea/types.js +2 -1
- package/dist/components/TimePicker/types.d.ts +2 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/style.css +257 -130
- package/package.json +5 -5
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useHideOverflowItems, useLocalizedStringFormatter, clsx } from "@koobiq/react-core";
|
|
3
|
+
import intlMessages from "../../intl.js";
|
|
4
|
+
import s from "./TagGroup.module.css.js";
|
|
5
|
+
import { getHiddenCount } from "./utils.js";
|
|
6
|
+
import { useFieldContentGroup } from "../../../FieldComponents/FieldContentGroup/FieldContentGroupContext.js";
|
|
7
|
+
import { Tag } from "../Tag/Tag.js";
|
|
8
|
+
const TagGroupResponsive = ({
|
|
9
|
+
state,
|
|
10
|
+
states
|
|
11
|
+
}) => {
|
|
12
|
+
const { isDisabled, isInvalid } = states;
|
|
13
|
+
const length = state?.selectedItems?.length || 0;
|
|
14
|
+
const { parentRef, visibleMap, itemsRefs } = useHideOverflowItems({
|
|
15
|
+
length: length + 1,
|
|
16
|
+
pinnedIndex: 0
|
|
17
|
+
});
|
|
18
|
+
const hiddenCount = getHiddenCount(visibleMap);
|
|
19
|
+
const t = useLocalizedStringFormatter(intlMessages);
|
|
20
|
+
const { hasStartAddon } = useFieldContentGroup();
|
|
21
|
+
return /* @__PURE__ */ jsxs(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
className: clsx(s.container, hasStartAddon && s.hasStartAddon),
|
|
25
|
+
ref: parentRef,
|
|
26
|
+
"aria-hidden": true,
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ jsx(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
className: s.base,
|
|
32
|
+
"data-limit-tags": "responsive",
|
|
33
|
+
"aria-label": t.format("selected items"),
|
|
34
|
+
children: state.selectedItems?.map((item, i) => /* @__PURE__ */ jsx(
|
|
35
|
+
Tag,
|
|
36
|
+
{
|
|
37
|
+
ref: itemsRefs[i],
|
|
38
|
+
className: clsx(s.tag, !visibleMap[i] && s.hidden),
|
|
39
|
+
isDisabled,
|
|
40
|
+
variant: isInvalid ? "error-fade" : "contrast-fade",
|
|
41
|
+
onRemove: () => {
|
|
42
|
+
if (state.selectionManager.isSelected(item.key)) {
|
|
43
|
+
state.selectionManager.toggleSelection(item.key);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
children: item.textValue
|
|
47
|
+
},
|
|
48
|
+
item.key
|
|
49
|
+
))
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
ref: itemsRefs[itemsRefs.length - 1],
|
|
56
|
+
className: clsx(s.more, !visibleMap[length] && s.hidden),
|
|
57
|
+
children: t.format("more", { count: hiddenCount })
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
TagGroupResponsive
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TagGroup';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getHiddenCount: (map: boolean[]) => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const intlMessages = {
|
|
2
|
+
"ru-RU": {
|
|
3
|
+
"selected items": "Выбранные элементы",
|
|
4
|
+
clear: "Очистить",
|
|
5
|
+
more: ({ count }) => `еще ${count}`
|
|
6
|
+
},
|
|
7
|
+
"en-US": {
|
|
8
|
+
"selected items": "Selected items",
|
|
9
|
+
clear: "Clear",
|
|
10
|
+
more: ({ count }) => `${count} more`
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
intlMessages as default
|
|
15
|
+
};
|
|
@@ -1,49 +1,38 @@
|
|
|
1
1
|
import type { ComponentRef, CSSProperties, ReactElement, ReactNode, Ref } from 'react';
|
|
2
|
-
import type { ExtendableProps
|
|
3
|
-
import type { AriaSelectProps } from '@koobiq/react-primitives';
|
|
4
|
-
import type { FieldErrorProps, FieldLabelProps, FieldSelectProps, FieldCaptionProps,
|
|
2
|
+
import type { ExtendableProps } from '@koobiq/react-core';
|
|
3
|
+
import type { AriaSelectProps, MultiSelectState, useMultiSelectState } from '@koobiq/react-primitives';
|
|
4
|
+
import type { FieldErrorProps, FieldLabelProps, FieldSelectProps, FieldCaptionProps, FieldContentGroupProps } from '../FieldComponents';
|
|
5
|
+
import type { IconButtonProps } from '../IconButton';
|
|
5
6
|
import type { ListProps } from '../List';
|
|
6
7
|
import type { PopoverProps } from '../Popover';
|
|
7
|
-
export
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
* If `true`, the component is disabled.
|
|
11
|
-
* @default false
|
|
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
|
-
* @deprecated
|
|
20
|
-
* The "error" prop is deprecated. Use "isInvalid" prop to replace it.
|
|
21
|
-
*/
|
|
22
|
-
error?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* If `true`, the label is displayed as required and the input element is required.
|
|
25
|
-
* @default false
|
|
26
|
-
* @deprecated
|
|
27
|
-
* The "required" prop is deprecated. Use "isRequired" prop to replace it.
|
|
28
|
-
*/
|
|
29
|
-
required?: boolean;
|
|
8
|
+
export declare const selectPropSelectedTagsOverflow: readonly ["multiline", "responsive"];
|
|
9
|
+
export type SelectPropSelectedTagsOverflow = (typeof selectPropSelectedTagsOverflow)[number];
|
|
10
|
+
export type SelectProps<T> = ExtendableProps<{
|
|
30
11
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
|
|
12
|
+
* Defines how selected tags are displayed when they exceed the available space.
|
|
13
|
+
*
|
|
14
|
+
*- `"multiline"` — tags wrap to multiple lines.
|
|
15
|
+
*- `"responsive"` — tags collapse into a summary (e.g., "3 more").
|
|
16
|
+
* @default "responsive"
|
|
34
17
|
*/
|
|
35
|
-
|
|
18
|
+
selectedTagsOverflow?: SelectPropSelectedTagsOverflow;
|
|
19
|
+
/** Handler that is called when the clear button is clicked. */
|
|
20
|
+
onClear?: () => void;
|
|
21
|
+
/** Sets the CSS [`className`](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** The initial selected keys in the collection (uncontrolled). */
|
|
24
|
+
defaultSelectedKeys?: Parameters<typeof useMultiSelectState>['0']['defaultSelectedKeys'];
|
|
25
|
+
/** Whether the field can be emptied. */
|
|
26
|
+
isClearable?: boolean;
|
|
27
|
+
/** Handler that is called when the selection changes. */
|
|
28
|
+
onSelectionChange?: Parameters<typeof useMultiSelectState>['0']['onSelectionChange'];
|
|
29
|
+
/** The currently selected keys in the collection (controlled). */
|
|
30
|
+
selectedKeys?: Parameters<typeof useMultiSelectState>['0']['selectedKeys'];
|
|
36
31
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @default
|
|
39
|
-
* @deprecated
|
|
40
|
-
* The "hiddenLabel" prop is deprecated. Use "isLabelHidden" prop to replace it.
|
|
32
|
+
* The type of selection that is allowed in the collection.
|
|
33
|
+
* @default 'single'
|
|
41
34
|
*/
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
export type SelectProps<T> = ExtendableProps<{
|
|
45
|
-
/** Additional CSS-classes. */
|
|
46
|
-
className?: string;
|
|
35
|
+
selectionMode?: 'single' | 'multiple';
|
|
47
36
|
/** Addon placed before the children. */
|
|
48
37
|
startAddon?: ReactNode;
|
|
49
38
|
/** Addon placed after the children. */
|
|
@@ -69,7 +58,11 @@ export type SelectProps<T> = ExtendableProps<{
|
|
|
69
58
|
/** Ref to the control */
|
|
70
59
|
ref?: Ref<HTMLDivElement>;
|
|
71
60
|
/** A render function for displaying the selected value. */
|
|
72
|
-
renderValue?: (
|
|
61
|
+
renderValue?: (state: MultiSelectState<T>, states: {
|
|
62
|
+
isInvalid?: boolean;
|
|
63
|
+
isDisabled?: boolean;
|
|
64
|
+
isRequired?: boolean;
|
|
65
|
+
}) => ReactNode;
|
|
73
66
|
/** The props used for each slot inside. */
|
|
74
67
|
slotProps?: {
|
|
75
68
|
popover?: PopoverProps;
|
|
@@ -77,10 +70,10 @@ export type SelectProps<T> = ExtendableProps<{
|
|
|
77
70
|
list?: ListProps<T>;
|
|
78
71
|
control?: FieldSelectProps;
|
|
79
72
|
caption?: FieldCaptionProps;
|
|
80
|
-
group?:
|
|
73
|
+
group?: FieldContentGroupProps;
|
|
81
74
|
errorMessage?: FieldErrorProps;
|
|
75
|
+
clearButton?: IconButtonProps;
|
|
82
76
|
};
|
|
83
|
-
}
|
|
77
|
+
}, Omit<AriaSelectProps<T>, 'description' | 'validate' | 'validationBehavior' | 'validationState' | 'selectedKey' | 'onSelectionChange' | 'defaultSelectedKey'>>;
|
|
84
78
|
export type SelectComponent = <T>(props: SelectProps<T>) => ReactElement | null;
|
|
85
79
|
export type SelectRef = ComponentRef<'div'>;
|
|
86
|
-
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ComponentRef, ReactNode } from 'react';
|
|
2
2
|
import type { ExtendableProps } from '@koobiq/react-core';
|
|
3
3
|
import type { TextFieldProps } from '@koobiq/react-primitives';
|
|
4
|
-
import type
|
|
4
|
+
import { type FieldCaptionProps, type FieldContentGroupPropVariant, type FieldErrorProps, type FieldInputProps, type FieldLabelProps } from '../FieldComponents';
|
|
5
5
|
export declare const textareaPropVariant: readonly ["filled", "transparent"];
|
|
6
|
-
export type TextareaPropVariant =
|
|
6
|
+
export type TextareaPropVariant = FieldContentGroupPropVariant;
|
|
7
7
|
export declare const textareaPropExpand: readonly ["auto-size", "vertical-resize"];
|
|
8
8
|
export type TextareaPropExpand = (typeof textareaPropExpand)[number];
|
|
9
9
|
type TextareaDeprecatedProps = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { fieldContentGroupPropVariant } from "../FieldComponents/FieldContentGroup/types.js";
|
|
2
|
+
const textareaPropVariant = fieldContentGroupPropVariant;
|
|
2
3
|
const textareaPropExpand = ["auto-size", "vertical-resize"];
|
|
3
4
|
export {
|
|
4
5
|
textareaPropExpand,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentRef, CSSProperties, ReactElement, ReactNode, Ref } from 'react';
|
|
2
2
|
import type { AriaTimeFieldProps, TimeValue } from '@koobiq/react-primitives';
|
|
3
3
|
import type { DateInputPropVariant } from '../DateInput';
|
|
4
|
-
import type { FieldCaptionProps, FieldControlProps, FieldErrorProps, FieldInputDateProps,
|
|
4
|
+
import type { FieldCaptionProps, FieldControlProps, FieldErrorProps, FieldInputDateProps, FieldContentGroupProps, FieldLabelProps } from '../FieldComponents';
|
|
5
5
|
export type TimePickerProps<T extends TimeValue> = {
|
|
6
6
|
/** Inline styles. */
|
|
7
7
|
style?: CSSProperties;
|
|
@@ -25,7 +25,7 @@ export type TimePickerProps<T extends TimeValue> = {
|
|
|
25
25
|
slotProps?: {
|
|
26
26
|
root?: FieldControlProps;
|
|
27
27
|
label?: FieldLabelProps;
|
|
28
|
-
group?:
|
|
28
|
+
group?: FieldContentGroupProps;
|
|
29
29
|
caption?: FieldCaptionProps;
|
|
30
30
|
inputDate?: FieldInputDateProps;
|
|
31
31
|
errorMessage?: FieldErrorProps;
|
|
@@ -34,6 +34,7 @@ export * from './Calendar';
|
|
|
34
34
|
export * from './DateInput';
|
|
35
35
|
export * from './DatePicker';
|
|
36
36
|
export * from './TimePicker';
|
|
37
|
+
export * from './SearchInput';
|
|
37
38
|
export * from './layout';
|
|
38
39
|
export { useListData, type ListData, type ListOptions, type TimeValue, type DateValue, } from '@koobiq/react-primitives';
|
|
39
40
|
export { useRouter, useLocale, type Locale, RouterProvider, useDateFormatter, } from '@koobiq/react-core';
|
package/dist/index.js
CHANGED
|
@@ -62,6 +62,7 @@ import { List, ListInner } from "./components/List/List.js";
|
|
|
62
62
|
import { ListItemText } from "./components/List/components/ListItemText/ListItemText.js";
|
|
63
63
|
import { AnimatedIcon } from "./components/AnimatedIcon/AnimatedIcon.js";
|
|
64
64
|
import { Select } from "./components/Select/Select.js";
|
|
65
|
+
import { selectPropSelectedTagsOverflow } from "./components/Select/types.js";
|
|
65
66
|
import { Divider } from "./components/Divider/Divider.js";
|
|
66
67
|
import { dividerPropDisplay } from "./components/Divider/types.js";
|
|
67
68
|
import { Menu } from "./components/Menu/Menu.js";
|
|
@@ -76,6 +77,8 @@ import { DateInput, DateInputRender } from "./components/DateInput/DateInput.js"
|
|
|
76
77
|
import { dateInputPropVariant } from "./components/DateInput/types.js";
|
|
77
78
|
import { DatePicker, DatePickerRender } from "./components/DatePicker/DatePicker.js";
|
|
78
79
|
import { TimePicker, TimePickerRender } from "./components/TimePicker/TimePicker.js";
|
|
80
|
+
import { SearchInput } from "./components/SearchInput/SearchInput.js";
|
|
81
|
+
import { searchInputPropVariant } from "./components/SearchInput/types.js";
|
|
79
82
|
import { flex, flexPropAlignItems, flexPropDirection, flexPropFlex, flexPropGap, flexPropJustifyContent, flexPropOrder, flexPropWrap } from "./components/layout/flex/flex.js";
|
|
80
83
|
import { spacing, spacingGap } from "./components/layout/spacing/spacing.js";
|
|
81
84
|
export {
|
|
@@ -126,6 +129,7 @@ export {
|
|
|
126
129
|
RadioGroupDescription,
|
|
127
130
|
RadioGroupLabel,
|
|
128
131
|
RouterProvider,
|
|
132
|
+
SearchInput,
|
|
129
133
|
Select,
|
|
130
134
|
SidePanel,
|
|
131
135
|
SidePanelContent,
|
|
@@ -177,6 +181,8 @@ export {
|
|
|
177
181
|
radioGroupPropSize,
|
|
178
182
|
radioPropLabelPlacement,
|
|
179
183
|
radioPropSize,
|
|
184
|
+
searchInputPropVariant,
|
|
185
|
+
selectPropSelectedTagsOverflow,
|
|
180
186
|
sidePanelPropPlacement,
|
|
181
187
|
sidePanelPropPosition,
|
|
182
188
|
sidePanelPropSize,
|