@koobiq/react-components 0.24.0 → 0.26.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.
Files changed (94) hide show
  1. package/dist/components/ActionsPanel/ActionPanel.module.css.js +17 -0
  2. package/dist/components/ActionsPanel/ActionsPanel.d.ts +11 -0
  3. package/dist/components/ActionsPanel/ActionsPanel.js +170 -0
  4. package/dist/components/ActionsPanel/ActionsPanelContext.d.ts +3 -0
  5. package/dist/components/ActionsPanel/ActionsPanelContext.js +6 -0
  6. package/dist/components/ActionsPanel/components/ActionsPanelAction/ActionsPanelAction.d.ts +2 -0
  7. package/dist/components/ActionsPanel/components/ActionsPanelAction/ActionsPanelAction.js +22 -0
  8. package/dist/components/ActionsPanel/components/ActionsPanelAction/ActionsPanelAction.module.css.js +8 -0
  9. package/dist/components/ActionsPanel/components/ActionsPanelAction/index.d.ts +2 -0
  10. package/dist/components/ActionsPanel/components/ActionsPanelAction/types.d.ts +5 -0
  11. package/dist/components/ActionsPanel/components/ActionsPanelClearButton/ActionsPanelClearButton.d.ts +5 -0
  12. package/dist/components/ActionsPanel/components/ActionsPanelClearButton/ActionsPanelClearButton.js +30 -0
  13. package/dist/components/ActionsPanel/components/ActionsPanelClearButton/ActionsPanelClearButton.module.css.js +8 -0
  14. package/dist/components/ActionsPanel/components/ActionsPanelClearButton/index.d.ts +1 -0
  15. package/dist/components/ActionsPanel/components/ActionsPanelContainer/ActionPanelContainer.module.css.js +11 -0
  16. package/dist/components/ActionsPanel/components/ActionsPanelContainer/ActionsPanelContainer.d.ts +2 -0
  17. package/dist/components/ActionsPanel/components/ActionsPanelContainer/ActionsPanelContainer.js +32 -0
  18. package/dist/components/ActionsPanel/components/ActionsPanelContainer/index.d.ts +2 -0
  19. package/dist/components/ActionsPanel/components/ActionsPanelContainer/types.d.ts +5 -0
  20. package/dist/components/ActionsPanel/components/ActionsPanelCounter/ActionsPanelCounter.d.ts +6 -0
  21. package/dist/components/ActionsPanel/components/ActionsPanelCounter/ActionsPanelCounter.js +44 -0
  22. package/dist/components/ActionsPanel/components/ActionsPanelCounter/ActionsPanelCounter.module.css.js +17 -0
  23. package/dist/components/ActionsPanel/components/ActionsPanelCounter/index.d.ts +1 -0
  24. package/dist/components/ActionsPanel/components/ActionsPanelDivider/ActionsPanelDivider.d.ts +3 -0
  25. package/dist/components/ActionsPanel/components/ActionsPanelDivider/ActionsPanelDivider.js +18 -0
  26. package/dist/components/ActionsPanel/components/ActionsPanelDivider/ActionsPanelDivider.module.css.js +8 -0
  27. package/dist/components/ActionsPanel/components/ActionsPanelDivider/index.d.ts +1 -0
  28. package/dist/components/ActionsPanel/components/ActionsPanelMoreAction/ActionsPanelMoreAction.d.ts +2 -0
  29. package/dist/components/ActionsPanel/components/ActionsPanelMoreAction/ActionsPanelMoreAction.js +72 -0
  30. package/dist/components/ActionsPanel/components/ActionsPanelMoreAction/ActionsPanelMoreAction.module.css.js +14 -0
  31. package/dist/components/ActionsPanel/components/ActionsPanelMoreAction/index.d.ts +2 -0
  32. package/dist/components/ActionsPanel/components/ActionsPanelMoreAction/types.d.ts +9 -0
  33. package/dist/components/ActionsPanel/components/index.d.ts +4 -0
  34. package/dist/components/ActionsPanel/hooks/index.d.ts +1 -0
  35. package/dist/components/ActionsPanel/hooks/useInlinePaddingSize.d.ts +6 -0
  36. package/dist/components/ActionsPanel/hooks/useInlinePaddingSize.js +17 -0
  37. package/dist/components/ActionsPanel/index.d.ts +5 -0
  38. package/dist/components/ActionsPanel/intl.json.js +7 -0
  39. package/dist/components/ActionsPanel/types.d.ts +47 -0
  40. package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/BreadcrumbsCollapse.js +9 -5
  41. package/dist/components/Breadcrumbs/intl.json.js +7 -0
  42. package/dist/components/Breadcrumbs/types.d.ts +2 -0
  43. package/dist/components/ContenPanel/ContentPanel.d.ts +3 -2
  44. package/dist/components/ContenPanel/ContentPanel.js +9 -9
  45. package/dist/components/Divider/Divider.d.ts +14 -4
  46. package/dist/components/Divider/Divider.js +23 -8
  47. package/dist/components/Divider/types.d.ts +4 -3
  48. package/dist/components/Navbar/components/NavbarItem.d.ts +4 -0
  49. package/dist/components/Navbar/components/NavbarItem.js +11 -1
  50. package/dist/components/SearchInput/SearchInput.d.ts +1 -1
  51. package/dist/components/Select/Select.d.ts +4 -0
  52. package/dist/components/SelectNext/Select.d.ts +13 -0
  53. package/dist/components/SelectNext/Select.js +258 -0
  54. package/dist/components/SelectNext/Select.module.css.js +23 -0
  55. package/dist/components/SelectNext/SelectContext.d.ts +2 -0
  56. package/dist/components/SelectNext/SelectContext.js +5 -0
  57. package/dist/components/SelectNext/components/SelectList/SelectList.d.ts +37 -0
  58. package/dist/components/SelectNext/components/SelectList/SelectList.js +131 -0
  59. package/dist/components/SelectNext/components/SelectList/SelectList.module.css.js +11 -0
  60. package/dist/components/SelectNext/components/SelectList/index.d.ts +1 -0
  61. package/dist/components/SelectNext/components/SelectOption/SelectOption.d.ts +37 -0
  62. package/dist/components/SelectNext/components/SelectOption/SelectOption.js +48 -0
  63. package/dist/components/SelectNext/components/SelectOption/index.d.ts +1 -0
  64. package/dist/components/SelectNext/components/SelectSection/SelectSection.d.ts +9 -0
  65. package/dist/components/SelectNext/components/SelectSection/SelectSection.js +51 -0
  66. package/dist/components/SelectNext/components/SelectSection/index.d.ts +1 -0
  67. package/dist/components/SelectNext/components/Tag/Tag.d.ts +18 -0
  68. package/dist/components/SelectNext/components/Tag/Tag.js +67 -0
  69. package/dist/components/SelectNext/components/Tag/index.d.ts +1 -0
  70. package/dist/components/SelectNext/components/Tag/intl.json.js +7 -0
  71. package/dist/components/SelectNext/components/Tag/utils.d.ts +3 -0
  72. package/dist/components/SelectNext/components/Tag/utils.js +9 -0
  73. package/dist/components/SelectNext/components/TagGroup/TagGroup.d.ts +13 -0
  74. package/dist/components/SelectNext/components/TagGroup/TagGroup.js +25 -0
  75. package/dist/components/SelectNext/components/TagGroup/TagGroup.module.css.js +20 -0
  76. package/dist/components/SelectNext/components/TagGroup/TagGroupMultiline.d.ts +3 -0
  77. package/dist/components/SelectNext/components/TagGroup/TagGroupMultiline.js +44 -0
  78. package/dist/components/SelectNext/components/TagGroup/TagGroupResponsive.d.ts +3 -0
  79. package/dist/components/SelectNext/components/TagGroup/TagGroupResponsive.js +65 -0
  80. package/dist/components/SelectNext/components/TagGroup/index.d.ts +1 -0
  81. package/dist/components/SelectNext/components/TagGroup/utils.d.ts +1 -0
  82. package/dist/components/SelectNext/components/TagGroup/utils.js +4 -0
  83. package/dist/components/SelectNext/components/index.d.ts +5 -0
  84. package/dist/components/SelectNext/index.d.ts +2 -0
  85. package/dist/components/SelectNext/intl.d.ts +2 -0
  86. package/dist/components/SelectNext/intl.js +21 -0
  87. package/dist/components/SelectNext/types.d.ts +99 -0
  88. package/dist/components/SelectNext/types.js +12 -0
  89. package/dist/components/SelectNext/utils.d.ts +9 -0
  90. package/dist/components/SelectNext/utils.js +26 -0
  91. package/dist/components/index.d.ts +3 -1
  92. package/dist/index.js +14 -1
  93. package/dist/style.css +324 -47
  94. package/package.json +5 -5
@@ -0,0 +1,131 @@
1
+ "use client";
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { useLocalizedStringFormatter, useFilter, useControlledState, useMultiRef, mergeProps, clsx } from "@koobiq/react-core";
5
+ import { useAutocompleteState, useAutocomplete, UNSTABLE_useFilteredListState, useListBox } from "@koobiq/react-primitives";
6
+ import { utilClasses } from "../../../../styles/utility.js";
7
+ import intlMessages from "../../intl.js";
8
+ import { SelectContext } from "../../SelectContext.js";
9
+ import { CollectionRoot } from "../../utils.js";
10
+ import s from "./SelectList.module.css.js";
11
+ import { SearchInput } from "../../../SearchInput/SearchInput.js";
12
+ import { Divider } from "../../../Divider/Divider.js";
13
+ import { ListEmptyState } from "../../../List/components/ListEmptyState/ListEmptyState.js";
14
+ import { ListLoadingState } from "../../../List/components/ListLoadingState/ListLoadingState.js";
15
+ const { list } = utilClasses;
16
+ function SelectList(props) {
17
+ const {
18
+ style,
19
+ isLoading,
20
+ className,
21
+ onLoadMore,
22
+ slotProps,
23
+ inputValue,
24
+ isSearchable,
25
+ onInputChange,
26
+ defaultFilter,
27
+ state: inState,
28
+ defaultInputValue,
29
+ noItemsText: noItemsTextProp,
30
+ loadingText: loadingTextProp
31
+ } = props;
32
+ const t = useLocalizedStringFormatter(intlMessages);
33
+ const domRef = useRef(null);
34
+ const inputRef = useRef(null);
35
+ const collectionRef = useRef(null);
36
+ const { contains } = useFilter({ sensitivity: "base" });
37
+ const [filterText, setFilterText] = useControlledState(
38
+ inputValue,
39
+ defaultInputValue ?? "",
40
+ onInputChange
41
+ );
42
+ const noItemsText = (() => {
43
+ if (noItemsTextProp !== void 0) return noItemsTextProp;
44
+ const hasQuery = isSearchable && filterText.trim().length > 0;
45
+ return hasQuery ? t.format("nothing found") : t.format("empty items");
46
+ })();
47
+ const autocompleteState = useAutocompleteState({
48
+ inputValue: isSearchable ? filterText : "",
49
+ onInputChange: isSearchable ? setFilterText : () => {
50
+ }
51
+ });
52
+ const {
53
+ inputProps,
54
+ collectionProps,
55
+ filter: filterFn,
56
+ collectionRef: mergedCollectionRef
57
+ } = useAutocomplete(
58
+ {
59
+ inputRef,
60
+ collectionRef,
61
+ filter: defaultFilter || contains
62
+ },
63
+ autocompleteState
64
+ );
65
+ const listRef = useMultiRef([mergedCollectionRef, domRef]);
66
+ const state = UNSTABLE_useFilteredListState(
67
+ inState,
68
+ isSearchable ? filterFn : null
69
+ );
70
+ const isEmpty = state.collection.size === 0;
71
+ const { listBoxProps } = useListBox(
72
+ mergeProps(props, isSearchable ? collectionProps : null),
73
+ state,
74
+ domRef
75
+ );
76
+ const rootProps = mergeProps({ className: s.base }, slotProps?.root);
77
+ const listProps = mergeProps(
78
+ {
79
+ style,
80
+ ref: listRef,
81
+ "data-padded": true,
82
+ className: clsx(list, className)
83
+ },
84
+ listBoxProps
85
+ );
86
+ const searchInputProps = mergeProps(
87
+ {
88
+ autoFocus: true,
89
+ fullWidth: true,
90
+ isLabelHidden: true,
91
+ className: s.search,
92
+ placeholder: t.format("search"),
93
+ "aria-label": t.format("search"),
94
+ variant: "transparent"
95
+ },
96
+ slotProps?.["search-input"],
97
+ inputProps
98
+ );
99
+ const loadingText = loadingTextProp ?? t.format("loading");
100
+ const { collection } = state;
101
+ return /* @__PURE__ */ jsxs("div", { ...rootProps, children: [
102
+ isSearchable && /* @__PURE__ */ jsxs(Fragment, { children: [
103
+ /* @__PURE__ */ jsx(SearchInput, { ref: inputRef, ...searchInputProps }),
104
+ /* @__PURE__ */ jsx(Divider, { disablePaddings: true, ...slotProps?.divider })
105
+ ] }),
106
+ /* @__PURE__ */ jsxs("ul", { ...listProps, children: [
107
+ /* @__PURE__ */ jsx(SelectContext.Provider, { value: state, children: /* @__PURE__ */ jsx(CollectionRoot, { collection }) }),
108
+ /* @__PURE__ */ jsx(
109
+ ListEmptyState,
110
+ {
111
+ isEmpty,
112
+ isLoading,
113
+ noItemsText
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsx(
117
+ ListLoadingState,
118
+ {
119
+ root: domRef.current,
120
+ isLoading,
121
+ onLoadMore,
122
+ loadingText,
123
+ observeDeps: [state.collection]
124
+ }
125
+ )
126
+ ] })
127
+ ] });
128
+ }
129
+ export {
130
+ SelectList
131
+ };
@@ -0,0 +1,11 @@
1
+ const base = "kbq-selectlist-68b1db";
2
+ const search = "kbq-selectlist-search-800542";
3
+ const s = {
4
+ base,
5
+ search
6
+ };
7
+ export {
8
+ base,
9
+ s as default,
10
+ search
11
+ };
@@ -0,0 +1 @@
1
+ export * from './SelectList';
@@ -0,0 +1,37 @@
1
+ import type { Key, ExtendableComponentPropsWithRef } from '@koobiq/react-core';
2
+ export type SelectOptionProps<T = object> = ExtendableComponentPropsWithRef<{
3
+ className?: string;
4
+ /** The unique id of the item. */
5
+ id?: Key;
6
+ /** The object value that this item represents. When using dynamic collections, this is set automatically. */
7
+ value?: T;
8
+ /** A string representation of the item's contents, used for features like typeahead. */
9
+ textValue?: string;
10
+ /** An accessibility label for this item. */
11
+ 'aria-label'?: string;
12
+ /** Whether the item is disabled. */
13
+ isDisabled?: boolean;
14
+ /**
15
+ * Handler that is called when a user performs an action on the item. The exact user event depends on
16
+ * the collection's `selectionBehavior` prop and the interaction modality.
17
+ */
18
+ onAction?: () => void;
19
+ }, 'a'>;
20
+ export declare const SelectOption: <T extends object>(props: Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "value" | "className" | "id" | "aria-label" | "isDisabled" | "textValue" | "onAction"> & {
21
+ className?: string;
22
+ /** The unique id of the item. */
23
+ id?: Key;
24
+ /** The object value that this item represents. When using dynamic collections, this is set automatically. */
25
+ value?: object | undefined;
26
+ /** A string representation of the item's contents, used for features like typeahead. */
27
+ textValue?: string;
28
+ /** An accessibility label for this item. */
29
+ 'aria-label'?: string;
30
+ /** Whether the item is disabled. */
31
+ isDisabled?: boolean;
32
+ /**
33
+ * Handler that is called when a user performs an action on the item. The exact user event depends on
34
+ * the collection's `selectionBehavior` prop and the interaction modality.
35
+ */
36
+ onAction?: () => void;
37
+ } & import("react").RefAttributes<HTMLElement>) => import("react").ReactElement | null;
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { useRef, useContext } from "react";
4
+ import { useMultiRef, useHover, usePress, filterDOMProps, clsx, mergeProps } from "@koobiq/react-core";
5
+ import { createLeafComponent, ItemNode, useOption } from "@koobiq/react-primitives";
6
+ import { utilClasses } from "../../../../styles/utility.js";
7
+ import { SelectContext } from "../../SelectContext.js";
8
+ import { Checkbox } from "../../../Checkbox/Checkbox.js";
9
+ const textVariant = utilClasses.typography;
10
+ const { listItem } = utilClasses;
11
+ const SelectOption = createLeafComponent(ItemNode, function SelectItem(props, forwardedRef, item) {
12
+ const { href, className, style } = props;
13
+ const domRef = useRef(null);
14
+ const ref = useMultiRef([forwardedRef, domRef]);
15
+ const state = useContext(SelectContext);
16
+ const { optionProps, isSelected, isDisabled, isFocusVisible } = useOption(
17
+ { key: item.key },
18
+ state,
19
+ domRef
20
+ );
21
+ const { hoverProps, isHovered } = useHover({ isDisabled });
22
+ const { isPressed, pressProps } = usePress({ isDisabled });
23
+ const Tag = href ? "a" : "li";
24
+ const DOMProps = filterDOMProps(props, { global: true });
25
+ delete DOMProps.id;
26
+ delete DOMProps.onClick;
27
+ return /* @__PURE__ */ jsxs(
28
+ Tag,
29
+ {
30
+ ref,
31
+ style,
32
+ "data-hovered": isHovered || void 0,
33
+ "data-pressed": isPressed || void 0,
34
+ "data-disabled": isDisabled || void 0,
35
+ "data-selected": isSelected || void 0,
36
+ "data-focus-visible": isFocusVisible || void 0,
37
+ ...mergeProps(optionProps, hoverProps, pressProps),
38
+ className: clsx(listItem, textVariant["text-normal"], className),
39
+ children: [
40
+ state.selectionManager.selectionMode === "multiple" && /* @__PURE__ */ jsx(Checkbox, { isDisabled, isSelected, isReadOnly: true }),
41
+ item.rendered
42
+ ]
43
+ }
44
+ );
45
+ });
46
+ export {
47
+ SelectOption
48
+ };
@@ -0,0 +1 @@
1
+ export * from './SelectOption';
@@ -0,0 +1,9 @@
1
+ import type { Key, SectionProps, ExtendableComponentPropsWithRef } from '@koobiq/react-core';
2
+ export type SelectSectionProps<T> = ExtendableComponentPropsWithRef<SectionProps<T> & {
3
+ /** The unique id of the item. */
4
+ id?: Key;
5
+ }, 'section'>;
6
+ export declare const SelectSection: <T extends object>(props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "id" | keyof SectionProps<T_1>> & SectionProps<T> & {
7
+ /** The unique id of the item. */
8
+ id?: Key;
9
+ } & import("react").RefAttributes<HTMLElement>) => import("react").ReactElement | null;
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { useContext } from "react";
4
+ import { filterDOMProps, mergeProps } from "@koobiq/react-core";
5
+ import { createBranchComponent, SectionNode, useListBoxSection } from "@koobiq/react-primitives";
6
+ import { utilClasses } from "../../../../styles/utility.js";
7
+ import { SelectContext } from "../../SelectContext.js";
8
+ import { CollectionBranch } from "../../utils.js";
9
+ import { Typography } from "../../../Typography/Typography.js";
10
+ const { listHeading } = utilClasses;
11
+ function SelectSectionInner(props, ref, section) {
12
+ const state = useContext(SelectContext);
13
+ const { className, style } = props;
14
+ const { headingProps, groupProps } = useListBoxSection({
15
+ heading: section.rendered,
16
+ "aria-label": props["aria-label"] ?? void 0
17
+ });
18
+ const DOMProps = filterDOMProps(props, { global: true });
19
+ delete DOMProps.id;
20
+ return /* @__PURE__ */ jsxs(
21
+ "section",
22
+ {
23
+ ...mergeProps(DOMProps, groupProps),
24
+ className,
25
+ style,
26
+ ref,
27
+ children: [
28
+ /* @__PURE__ */ jsx(
29
+ Typography,
30
+ {
31
+ as: "span",
32
+ display: "block",
33
+ variant: "caps-compact-strong",
34
+ color: "contrast-secondary",
35
+ className: listHeading,
36
+ ...headingProps,
37
+ children: props.title
38
+ }
39
+ ),
40
+ /* @__PURE__ */ jsx(CollectionBranch, { collection: state.collection, parent: section })
41
+ ]
42
+ }
43
+ );
44
+ }
45
+ const SelectSection = createBranchComponent(
46
+ SectionNode,
47
+ SelectSectionInner
48
+ );
49
+ export {
50
+ SelectSection
51
+ };
@@ -0,0 +1 @@
1
+ export * from './SelectSection';
@@ -0,0 +1,18 @@
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
+ import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
+ import type { TagGroupPropVariant } from '../../../TagGroup';
4
+ type TagProps = ExtendableComponentPropsWithRef<{
5
+ /**
6
+ * The variant to use.
7
+ * @default 'theme-fade'
8
+ */
9
+ variant?: TagGroupPropVariant;
10
+ className?: string;
11
+ style?: CSSProperties;
12
+ children?: ReactNode;
13
+ icon?: ReactNode;
14
+ isDisabled?: boolean;
15
+ onRemove?: () => void;
16
+ }, 'div'>;
17
+ export declare const Tag: import("react").ForwardRefExoticComponent<Omit<TagProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
18
+ export {};
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
4
+ import { useLocalizedStringFormatter, mergeProps, clsx, isNotNil } from "@koobiq/react-core";
5
+ import { IconXmarkS16 } from "@koobiq/react-icons";
6
+ import { utilClasses } from "../../../../styles/utility.js";
7
+ import s from "../../../TagGroup/components/Tag/Tag.module.css.js";
8
+ import intlMessages from "./intl.json.js";
9
+ import { matchVariantToCloseButton } from "./utils.js";
10
+ import { IconButton } from "../../../IconButton/IconButton.js";
11
+ const textNormalMedium = utilClasses.typography["text-normal-medium"];
12
+ const Tag = forwardRef((props, ref) => {
13
+ const {
14
+ variant = "theme-fade",
15
+ icon,
16
+ className,
17
+ style,
18
+ isDisabled,
19
+ children,
20
+ onRemove,
21
+ ...other
22
+ } = props;
23
+ const stringFormatter = useLocalizedStringFormatter(intlMessages);
24
+ const rootProps = mergeProps({
25
+ className: clsx(
26
+ s.base,
27
+ s[variant],
28
+ isDisabled && s.disabled,
29
+ textNormalMedium,
30
+ className
31
+ ),
32
+ ...other,
33
+ style
34
+ });
35
+ const removeButtonProps = {
36
+ isCompact: true,
37
+ isDisabled,
38
+ className: s.cancelIcon,
39
+ variant: matchVariantToCloseButton[variant],
40
+ "aria-label": stringFormatter.format("remove")
41
+ };
42
+ const contentProps = mergeProps({
43
+ className: s.content
44
+ });
45
+ const iconProps = mergeProps({
46
+ className: s.icon
47
+ });
48
+ return /* @__PURE__ */ jsxs("div", { ref, ...rootProps, children: [
49
+ isNotNil(icon) && /* @__PURE__ */ jsx("span", { ...iconProps, children: icon }),
50
+ isNotNil(children) && /* @__PURE__ */ jsx("span", { ...contentProps, children }),
51
+ /* @__PURE__ */ jsx(
52
+ IconButton,
53
+ {
54
+ as: "div",
55
+ size: "l",
56
+ ...removeButtonProps,
57
+ tabIndex: void 0,
58
+ onPress: onRemove,
59
+ children: /* @__PURE__ */ jsx(IconXmarkS16, {})
60
+ }
61
+ )
62
+ ] });
63
+ });
64
+ Tag.displayName = "SelectTag";
65
+ export {
66
+ Tag
67
+ };
@@ -0,0 +1 @@
1
+ export * from './Tag';
@@ -0,0 +1,7 @@
1
+ const intlMessages = {
2
+ "ru-RU": { "remove": "Удалить" },
3
+ "en-US": { "remove": "Remove" }
4
+ };
5
+ export {
6
+ intlMessages as default
7
+ };
@@ -0,0 +1,3 @@
1
+ import type { IconButtonPropVariant } from '../../../IconButton';
2
+ import type { TagGroupPropVariant } from '../../../TagGroup';
3
+ export declare const matchVariantToCloseButton: Record<TagGroupPropVariant, IconButtonPropVariant>;
@@ -0,0 +1,9 @@
1
+ const matchVariantToCloseButton = {
2
+ "theme-fade": "theme",
3
+ "contrast-fade": "fade-contrast",
4
+ "error-fade": "error",
5
+ "warning-fade": "warning"
6
+ };
7
+ export {
8
+ matchVariantToCloseButton
9
+ };
@@ -0,0 +1,13 @@
1
+ import type { SelectState } from '@koobiq/react-primitives';
2
+ import type { SelectionMode } from '@react-types/select';
3
+ import type { SelectNextPropSelectedTagsOverflow } from '../../types';
4
+ export type TagGroupProps<T extends object, M extends SelectionMode = 'single'> = {
5
+ state: SelectState<T, M>;
6
+ states: {
7
+ isInvalid?: boolean;
8
+ isDisabled?: boolean;
9
+ isRequired?: boolean;
10
+ };
11
+ selectedTagsOverflow?: SelectNextPropSelectedTagsOverflow;
12
+ };
13
+ export declare function TagGroup<T extends object, M extends SelectionMode = 'single'>({ selectedTagsOverflow, ...rest }: TagGroupProps<T, M>): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { logger } from "@koobiq/logger";
4
+ import { TagGroupMultiline } from "./TagGroupMultiline.js";
5
+ import { TagGroupResponsive } from "./TagGroupResponsive.js";
6
+ function assertNever(x) {
7
+ logger.error(`Unhandled selectedTagsOverflow variant: ${x}`);
8
+ return null;
9
+ }
10
+ function TagGroup({
11
+ selectedTagsOverflow = "responsive",
12
+ ...rest
13
+ }) {
14
+ switch (selectedTagsOverflow) {
15
+ case "responsive":
16
+ return /* @__PURE__ */ jsx(TagGroupResponsive, { ...rest });
17
+ case "multiline":
18
+ return /* @__PURE__ */ jsx(TagGroupMultiline, { ...rest });
19
+ default:
20
+ return assertNever(selectedTagsOverflow);
21
+ }
22
+ }
23
+ export {
24
+ TagGroup
25
+ };
@@ -0,0 +1,20 @@
1
+ const container = "kbq-taggroup-container-5d455a";
2
+ const hasStartAddon = "kbq-taggroup-hasStartAddon-eb7d88";
3
+ const base = "kbq-taggroup-b97495";
4
+ const tag = "kbq-taggroup-tag-262753";
5
+ const more = "kbq-taggroup-more-db5a34";
6
+ const s = {
7
+ container,
8
+ hasStartAddon,
9
+ base,
10
+ tag,
11
+ more
12
+ };
13
+ export {
14
+ base,
15
+ container,
16
+ s as default,
17
+ hasStartAddon,
18
+ more,
19
+ tag
20
+ };
@@ -0,0 +1,3 @@
1
+ import type { SelectionMode } from '@react-types/select';
2
+ import type { TagGroupProps } from './TagGroup';
3
+ export declare function TagGroupMultiline<T extends object, M extends SelectionMode = 'single'>({ state, states }: TagGroupProps<T, M>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,44 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useLocalizedStringFormatter, clsx } from "@koobiq/react-core";
3
+ import intlMessages from "../../intl.js";
4
+ import s from "./TagGroup.module.css.js";
5
+ import { Tag } from "../Tag/Tag.js";
6
+ import { useFormFieldControlGroup } from "../../../FormField/FormFieldControlGroup/FormFieldControlGroupContext.js";
7
+ function TagGroupMultiline({ state, states }) {
8
+ const { isDisabled, isInvalid } = states;
9
+ const t = useLocalizedStringFormatter(intlMessages);
10
+ const { hasStartAddon } = useFormFieldControlGroup();
11
+ return /* @__PURE__ */ jsx(
12
+ "div",
13
+ {
14
+ className: clsx(s.container, hasStartAddon && s.hasStartAddon),
15
+ "aria-hidden": true,
16
+ children: /* @__PURE__ */ jsx(
17
+ "div",
18
+ {
19
+ className: s.base,
20
+ "data-limit-tags": "multiline",
21
+ "aria-label": t.format("selected items"),
22
+ children: state.selectedItems?.map((item) => /* @__PURE__ */ jsx(
23
+ Tag,
24
+ {
25
+ className: s.tag,
26
+ isDisabled,
27
+ variant: isInvalid ? "error-fade" : "contrast-fade",
28
+ onRemove: () => {
29
+ if (state.selectionManager.isSelected(item.key)) {
30
+ state.selectionManager.toggleSelection(item.key);
31
+ }
32
+ },
33
+ children: item.textValue
34
+ },
35
+ item.key
36
+ ))
37
+ }
38
+ )
39
+ }
40
+ );
41
+ }
42
+ export {
43
+ TagGroupMultiline
44
+ };
@@ -0,0 +1,3 @@
1
+ import type { SelectionMode } from '@react-types/select';
2
+ import type { TagGroupProps } from './TagGroup';
3
+ export declare function TagGroupResponsive<T extends object, M extends SelectionMode = 'single'>({ state, states }: TagGroupProps<T, M>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,65 @@
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 { useFormFieldControlGroup } from "../../../FormField/FormFieldControlGroup/FormFieldControlGroupContext.js";
7
+ import { Tag } from "../Tag/Tag.js";
8
+ function TagGroupResponsive({ state, states }) {
9
+ const { isDisabled, isInvalid } = states;
10
+ const length = state?.selectedItems?.length || 0;
11
+ const { parentRef, visibleMap, itemsRefs } = useHideOverflowItems({
12
+ length: length + 1,
13
+ pinnedIndex: 0
14
+ });
15
+ const hiddenCount = getHiddenCount(visibleMap);
16
+ const t = useLocalizedStringFormatter(intlMessages);
17
+ const { hasStartAddon } = useFormFieldControlGroup();
18
+ return /* @__PURE__ */ jsxs(
19
+ "div",
20
+ {
21
+ className: clsx(s.container, hasStartAddon && s.hasStartAddon),
22
+ ref: parentRef,
23
+ "aria-hidden": true,
24
+ children: [
25
+ /* @__PURE__ */ jsx(
26
+ "div",
27
+ {
28
+ className: s.base,
29
+ "data-limit-tags": "responsive",
30
+ "aria-label": t.format("selected items"),
31
+ children: state.selectedItems?.map((item, i) => /* @__PURE__ */ jsx(
32
+ Tag,
33
+ {
34
+ className: s.tag,
35
+ ref: itemsRefs[i],
36
+ isDisabled,
37
+ "aria-hidden": !visibleMap[i] || void 0,
38
+ variant: isInvalid ? "error-fade" : "contrast-fade",
39
+ onRemove: () => {
40
+ if (state.selectionManager.isSelected(item.key)) {
41
+ state.selectionManager.toggleSelection(item.key);
42
+ }
43
+ },
44
+ children: item.textValue
45
+ },
46
+ item.key
47
+ ))
48
+ }
49
+ ),
50
+ /* @__PURE__ */ jsx(
51
+ "div",
52
+ {
53
+ className: s.more,
54
+ ref: itemsRefs[itemsRefs.length - 1],
55
+ "aria-hidden": !visibleMap[length] || void 0,
56
+ children: t.format("more", { count: hiddenCount })
57
+ }
58
+ )
59
+ ]
60
+ }
61
+ );
62
+ }
63
+ export {
64
+ TagGroupResponsive
65
+ };
@@ -0,0 +1 @@
1
+ export * from './TagGroup';
@@ -0,0 +1 @@
1
+ export declare const getHiddenCount: (map: boolean[]) => number;
@@ -0,0 +1,4 @@
1
+ const getHiddenCount = (map) => map.filter((item) => !item).length;
2
+ export {
3
+ getHiddenCount
4
+ };
@@ -0,0 +1,5 @@
1
+ export * from './SelectList';
2
+ export * from './Tag';
3
+ export * from './SelectOption';
4
+ export * from './SelectSection';
5
+ export * from './TagGroup';
@@ -0,0 +1,2 @@
1
+ export * from './Select';
2
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ declare const _default: Record<string, Record<string, string>>;
2
+ export default _default;
@@ -0,0 +1,21 @@
1
+ const intlMessages = {
2
+ "ru-RU": {
3
+ "empty items": "Нет вариантов выбора",
4
+ "nothing found": "Ничего не найдено",
5
+ loading: "Загрузка…",
6
+ "selected items": "Выбранные элементы",
7
+ search: "Поиск",
8
+ more: ({ count }) => `+${count}`
9
+ },
10
+ "en-US": {
11
+ "empty items": "No options available",
12
+ "nothing found": "Nothing found",
13
+ "selected items": "Selected items",
14
+ loading: "Loading…",
15
+ search: "Search",
16
+ more: ({ count }) => `+${count}`
17
+ }
18
+ };
19
+ export {
20
+ intlMessages as default
21
+ };