@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.
Files changed (59) hide show
  1. package/dist/components/Autocomplete/Autocomplete.js +8 -11
  2. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +2 -0
  3. package/dist/components/Breadcrumbs/Breadcrumbs.js +59 -0
  4. package/dist/components/Breadcrumbs/Breadcrumbs.module.css.js +32 -0
  5. package/dist/components/Breadcrumbs/BreadcrumbsContext.d.ts +7 -0
  6. package/dist/components/Breadcrumbs/BreadcrumbsContext.js +9 -0
  7. package/dist/components/Breadcrumbs/components/BreadcrumbItem/BreadcrumbItem.d.ts +4 -0
  8. package/dist/components/Breadcrumbs/components/BreadcrumbItem/BreadcrumbItem.js +70 -0
  9. package/dist/components/Breadcrumbs/components/BreadcrumbItem/BreadcrumbItem.module.css.js +32 -0
  10. package/dist/components/Breadcrumbs/components/BreadcrumbItem/index.d.ts +2 -0
  11. package/dist/components/Breadcrumbs/components/BreadcrumbItem/types.d.ts +14 -0
  12. package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/BreadcrumbsCollapse.d.ts +2 -0
  13. package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/BreadcrumbsCollapse.js +123 -0
  14. package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/index.d.ts +1 -0
  15. package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/utils.d.ts +2 -0
  16. package/dist/components/Breadcrumbs/components/BreadcrumbsCollapse/utils.js +11 -0
  17. package/dist/components/Breadcrumbs/components/BreadcrumbsWrap/BreadcrumbsWrap.d.ts +2 -0
  18. package/dist/components/Breadcrumbs/components/BreadcrumbsWrap/BreadcrumbsWrap.js +27 -0
  19. package/dist/components/Breadcrumbs/components/BreadcrumbsWrap/index.d.ts +1 -0
  20. package/dist/components/Breadcrumbs/components/index.d.ts +3 -0
  21. package/dist/components/Breadcrumbs/index.d.ts +3 -0
  22. package/dist/components/Breadcrumbs/types.d.ts +69 -0
  23. package/dist/components/Breadcrumbs/types.js +6 -0
  24. package/dist/components/Dialog/components/DialogBody.d.ts +3 -2
  25. package/dist/components/Dialog/components/DialogBody.js +6 -6
  26. package/dist/components/Dialog/components/DialogCloseButton.d.ts +1 -24
  27. package/dist/components/FormField/FormFieldCaption/FormFieldCaption.d.ts +1 -5
  28. package/dist/components/FormField/FormFieldClearButton/FormFieldClearButton.d.ts +6 -0
  29. package/dist/components/FormField/FormFieldClearButton/FormFieldClearButton.js +32 -0
  30. package/dist/components/FormField/FormFieldClearButton/FormFieldClearButton.module.css.js +8 -0
  31. package/dist/components/FormField/FormFieldClearButton/index.d.ts +1 -0
  32. package/dist/components/FormField/index.d.ts +1 -0
  33. package/dist/components/Input/Input.d.ts +4 -1
  34. package/dist/components/Input/Input.js +19 -2
  35. package/dist/components/Input/types.d.ts +6 -0
  36. package/dist/components/Menu/Menu.js +3 -1
  37. package/dist/components/Menu/types.d.ts +3 -2
  38. package/dist/components/Modal/Modal.js +5 -10
  39. package/dist/components/Popover/PopoverInner.d.ts +1 -1
  40. package/dist/components/Popover/PopoverInner.js +5 -9
  41. package/dist/components/SearchInput/SearchInput.js +13 -16
  42. package/dist/components/Select/Select.js +7 -10
  43. package/dist/components/Select/components/Tag/Tag.d.ts +4 -3
  44. package/dist/components/Select/components/Tag/Tag.js +3 -1
  45. package/dist/components/Select/components/TagGroup/TagGroup.module.css.js +1 -4
  46. package/dist/components/Select/components/TagGroup/TagGroupResponsive.js +4 -2
  47. package/dist/components/Select/intl.js +0 -2
  48. package/dist/components/SidePanel/SidePanel.js +5 -10
  49. package/dist/components/Tabs/utils.d.ts +1 -1
  50. package/dist/components/Textarea/Textarea.d.ts +1 -1
  51. package/dist/components/ToastProvider/components/Toast/Toast.js +1 -1
  52. package/dist/components/ToastProvider/components/ToastRegion/ToastRegion.js +3 -2
  53. package/dist/components/Tooltip/Tooltip.d.ts +2 -1
  54. package/dist/components/Tooltip/types.d.ts +3 -1
  55. package/dist/components/index.d.ts +1 -0
  56. package/dist/index.js +9 -0
  57. package/dist/style.css +342 -143
  58. package/package.json +7 -7
  59. /package/dist/components/{Autocomplete → FormField/FormFieldClearButton}/intl.json.js +0 -0
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
3
  import { forwardRef, useRef, useCallback } from "react";
4
- import { useDOMRef, useFilter, useLocalizedStringFormatter, useElementSize, mergeProps, clsx } from "@koobiq/react-core";
5
- import { IconCircleXmark16, IconChevronDownS16 } from "@koobiq/react-icons";
4
+ import { useDOMRef, useFilter, useElementSize, mergeProps, clsx } from "@koobiq/react-core";
5
+ import { IconChevronDownS16 } from "@koobiq/react-icons";
6
6
  import { useComboBoxState, removeDataAttributes, useSlottedContext, FormContext, useComboBox, FieldErrorContext } from "@koobiq/react-primitives";
7
7
  import { PopoverInner } from "../Popover/PopoverInner.js";
8
8
  import s from "./Autocomplete.module.css.js";
9
- import intlMessages from "./intl.json.js";
10
9
  import { ListInner, List } from "../List/List.js";
11
10
  import { useForm } from "../Form/FormContext.js";
11
+ import { FormFieldClearButton } from "../FormField/FormFieldClearButton/FormFieldClearButton.js";
12
12
  import { IconButton } from "../IconButton/IconButton.js";
13
13
  import { FormField } from "../FormField/FormField.js";
14
14
  import { Item } from "../Collections/Item.js";
@@ -83,8 +83,7 @@ function AutocompleteRender(props, ref) {
83
83
  }),
84
84
  state
85
85
  );
86
- const t = useLocalizedStringFormatter(intlMessages);
87
- const hasClearButton = isClearable && !isReadOnly && !isDisabled && (allowsCustomValue ? !!state.inputValue : !!state.selectedItem);
86
+ const clearButtonIsHidden = isReadOnly || isDisabled || (allowsCustomValue ? !state.inputValue : !state.selectedItem);
88
87
  const handleClear = useCallback(() => {
89
88
  state.selectionManager.setSelectedKeys(/* @__PURE__ */ new Set());
90
89
  onClear?.();
@@ -147,10 +146,8 @@ function AutocompleteRender(props, ref) {
147
146
  const clearButtonProps = mergeProps(
148
147
  {
149
148
  onPress: handleClear,
150
- className: s.clearButton,
151
- preventFocusOnPress: true,
152
- "aria-label": t.format("clear"),
153
- variant: isInvalid ? "error" : "fade-contrast"
149
+ isHidden: clearButtonIsHidden,
150
+ isClearable
154
151
  },
155
152
  slotProps?.clearButton
156
153
  );
@@ -166,8 +163,8 @@ function AutocompleteRender(props, ref) {
166
163
  e.preventDefault();
167
164
  inputRef?.current?.focus();
168
165
  },
169
- endAddon: /* @__PURE__ */ jsxs(Fragment, { children: [
170
- hasClearButton && /* @__PURE__ */ jsx(IconButton, { ...clearButtonProps, children: /* @__PURE__ */ jsx(IconCircleXmark16, {}) }),
166
+ endAddon: (isClearable || endAddon || !disableShowChevron || void 0) && /* @__PURE__ */ jsxs(Fragment, { children: [
167
+ /* @__PURE__ */ jsx(FormFieldClearButton, { ...clearButtonProps }),
171
168
  endAddon,
172
169
  !disableShowChevron && /* @__PURE__ */ jsx(
173
170
  IconButton,
@@ -0,0 +1,2 @@
1
+ import type { BreadcrumbsProps } from './types';
2
+ export declare const Breadcrumbs: import("react").ForwardRefExoticComponent<Omit<BreadcrumbsProps, "ref"> & import("react").RefAttributes<HTMLElement>>;
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { forwardRef, cloneElement } from "react";
4
+ import { mergeProps, clsx } from "@koobiq/react-core";
5
+ import { useBreadcrumbs } from "@koobiq/react-primitives";
6
+ import s from "./Breadcrumbs.module.css.js";
7
+ import { BreadcrumbsContext } from "./BreadcrumbsContext.js";
8
+ import { BreadcrumbsWrap } from "./components/BreadcrumbsWrap/BreadcrumbsWrap.js";
9
+ import { BreadcrumbsCollapse } from "./components/BreadcrumbsCollapse/BreadcrumbsCollapse.js";
10
+ const Breadcrumbs = forwardRef(
11
+ (props, ref) => {
12
+ const {
13
+ separator = `/`,
14
+ overflowMode = "collapse",
15
+ renderEllipsis,
16
+ onAction,
17
+ ellipsisIndex,
18
+ children: childrenProp,
19
+ size = "normal",
20
+ className,
21
+ ...other
22
+ } = props;
23
+ const children = childrenProp?.map((child, i) => {
24
+ const itemKey = child?.key || i;
25
+ return cloneElement(child, {
26
+ key: itemKey,
27
+ onPress: (e) => {
28
+ child.props?.onPress?.(e);
29
+ onAction?.(itemKey);
30
+ }
31
+ });
32
+ });
33
+ const { navProps: navPropsAria } = useBreadcrumbs(other);
34
+ const navProps = mergeProps(
35
+ {
36
+ "data-size": size,
37
+ "data-overflow-mode": overflowMode,
38
+ className: clsx(s.base, s[size], s[overflowMode], className),
39
+ ...other
40
+ },
41
+ navPropsAria
42
+ );
43
+ return /* @__PURE__ */ jsx(BreadcrumbsContext.Provider, { value: { size }, children: /* @__PURE__ */ jsx("nav", { ...navProps, ref, children: overflowMode === "wrap" ? /* @__PURE__ */ jsx(BreadcrumbsWrap, { ...other, separator, children }) : /* @__PURE__ */ jsx(
44
+ BreadcrumbsCollapse,
45
+ {
46
+ ...other,
47
+ onAction,
48
+ ellipsisIndex,
49
+ renderEllipsis,
50
+ separator,
51
+ children
52
+ }
53
+ ) }) });
54
+ }
55
+ );
56
+ Breadcrumbs.displayName = "Breadcrumbs";
57
+ export {
58
+ Breadcrumbs
59
+ };
@@ -0,0 +1,32 @@
1
+ const base = "kbq-breadcrumbs-922b6f";
2
+ const wrap = "kbq-breadcrumbs-wrap-352442";
3
+ const list = "kbq-breadcrumbs-list-ab1ac2";
4
+ const compact = "kbq-breadcrumbs-compact-2a6f3a";
5
+ const normal = "kbq-breadcrumbs-normal-47d2bc";
6
+ const big = "kbq-breadcrumbs-big-b56335";
7
+ const item = "kbq-breadcrumbs-item-bcbc6b";
8
+ const ellipsis = "kbq-breadcrumbs-ellipsis-60de4d";
9
+ const divider = "kbq-breadcrumbs-divider-31522f";
10
+ const s = {
11
+ base,
12
+ wrap,
13
+ list,
14
+ compact,
15
+ normal,
16
+ big,
17
+ item,
18
+ ellipsis,
19
+ divider
20
+ };
21
+ export {
22
+ base,
23
+ big,
24
+ compact,
25
+ s as default,
26
+ divider,
27
+ ellipsis,
28
+ item,
29
+ list,
30
+ normal,
31
+ wrap
32
+ };
@@ -0,0 +1,7 @@
1
+ import type { BreadcrumbsPropSize } from './types';
2
+ export type BreadcrumbsContextValue = {
3
+ /** Size. */
4
+ size: BreadcrumbsPropSize;
5
+ };
6
+ export declare const BreadcrumbsContext: import("react").Context<BreadcrumbsContextValue>;
7
+ export declare const useBreadcrumbsContext: () => BreadcrumbsContextValue;
@@ -0,0 +1,9 @@
1
+ import { createContext, useContext } from "react";
2
+ const BreadcrumbsContext = createContext({
3
+ size: "compact"
4
+ });
5
+ const useBreadcrumbsContext = () => useContext(BreadcrumbsContext);
6
+ export {
7
+ BreadcrumbsContext,
8
+ useBreadcrumbsContext
9
+ };
@@ -0,0 +1,4 @@
1
+ import type { ComponentPropsWithRef, ElementType } from 'react';
2
+ import type { BreadcrumbItemBaseProps } from './types';
3
+ export declare const BreadcrumbItem: import("@koobiq/react-core").PolyForwardComponent<"span", BreadcrumbItemBaseProps, ElementType>;
4
+ export type BreadcrumbItemProps<As extends ElementType = 'span'> = ComponentPropsWithRef<typeof BreadcrumbItem<As>>;
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ import { jsxs } from "react/jsx-runtime";
3
+ import { polymorphicForwardRef, useDOMRef, useHover, useFocusRing, usePress, filterDOMProps, isNotNil, mergeProps, clsx } from "@koobiq/react-core";
4
+ import { useBreadcrumbItem, removeDataAttributes } from "@koobiq/react-primitives";
5
+ import { useBreadcrumbsContext } from "../../BreadcrumbsContext.js";
6
+ import s from "./BreadcrumbItem.module.css.js";
7
+ const BreadcrumbItem = polymorphicForwardRef((props, ref) => {
8
+ const domRef = useDOMRef(ref);
9
+ const {
10
+ as = "span",
11
+ children,
12
+ endAddon,
13
+ isCurrent,
14
+ startAddon,
15
+ isDisabled,
16
+ className,
17
+ style,
18
+ ...other
19
+ } = props;
20
+ let { itemProps } = useBreadcrumbItem(
21
+ {
22
+ ...removeDataAttributes(props),
23
+ children: props.children || null,
24
+ elementType: props.href ? "a" : `${as}`
25
+ },
26
+ domRef
27
+ );
28
+ const Tag = props.href ? "a" : as;
29
+ const { size } = useBreadcrumbsContext();
30
+ const { hoverProps, isHovered } = useHover({ isDisabled });
31
+ const { focusProps, isFocusVisible } = useFocusRing({});
32
+ const { isPressed, pressProps } = usePress({ isDisabled });
33
+ const DOMProps = filterDOMProps(props);
34
+ delete DOMProps.id;
35
+ if (as !== "a" && as !== "span") {
36
+ itemProps = other;
37
+ }
38
+ return /* @__PURE__ */ jsxs(
39
+ Tag,
40
+ {
41
+ className: clsx(
42
+ s.base,
43
+ s[size],
44
+ isHovered && s.hovered,
45
+ isCurrent && s.current,
46
+ isPressed && s.pressed,
47
+ isDisabled && s.disabled,
48
+ isFocusVisible && s.focusVisible,
49
+ className
50
+ ),
51
+ "data-size": size,
52
+ "data-hovered": isHovered || void 0,
53
+ "data-pressed": isPressed || void 0,
54
+ "data-current": isCurrent || void 0,
55
+ "data-disabled": isDisabled || void 0,
56
+ "data-focus-visible": isFocusVisible || void 0,
57
+ ...mergeProps(DOMProps, itemProps, hoverProps, focusProps, pressProps),
58
+ style,
59
+ ref: domRef,
60
+ children: [
61
+ isNotNil(startAddon) && startAddon,
62
+ children,
63
+ isNotNil(endAddon) && endAddon
64
+ ]
65
+ }
66
+ );
67
+ });
68
+ export {
69
+ BreadcrumbItem
70
+ };
@@ -0,0 +1,32 @@
1
+ const base = "kbq-breadcrumbitem-c1599d";
2
+ const hovered = "kbq-breadcrumbitem-hovered-985b33";
3
+ const pressed = "kbq-breadcrumbitem-pressed-80b3fe";
4
+ const focusVisible = "kbq-breadcrumbitem-focusVisible-16d3f1";
5
+ const disabled = "kbq-breadcrumbitem-disabled-a307b2";
6
+ const current = "kbq-breadcrumbitem-current-f87edc";
7
+ const compact = "kbq-breadcrumbitem-compact-71772d";
8
+ const normal = "kbq-breadcrumbitem-normal-548b3c";
9
+ const big = "kbq-breadcrumbitem-big-7dc306";
10
+ const s = {
11
+ base,
12
+ hovered,
13
+ pressed,
14
+ focusVisible,
15
+ disabled,
16
+ current,
17
+ compact,
18
+ normal,
19
+ big
20
+ };
21
+ export {
22
+ base,
23
+ big,
24
+ compact,
25
+ current,
26
+ s as default,
27
+ disabled,
28
+ focusVisible,
29
+ hovered,
30
+ normal,
31
+ pressed
32
+ };
@@ -0,0 +1,2 @@
1
+ export * from './BreadcrumbItem';
2
+ export * from './types';
@@ -0,0 +1,14 @@
1
+ import type { CSSProperties, ReactNode } from 'react';
2
+ import type { AriaBreadcrumbItemProps } from '@koobiq/react-primitives';
3
+ export type BreadcrumbItemBaseProps = Omit<AriaBreadcrumbItemProps, 'children' | 'elementType'> & {
4
+ /** Icon placed before the children. */
5
+ startAddon?: ReactNode;
6
+ /** Icon placed after the children. */
7
+ endAddon?: ReactNode;
8
+ /** The content of the component. */
9
+ children?: ReactNode;
10
+ /** Additional CSS-classes. */
11
+ className?: string;
12
+ /** Inline styles. */
13
+ style?: CSSProperties;
14
+ };
@@ -0,0 +1,2 @@
1
+ import type { BreadcrumbsProps } from '../../types';
2
+ export declare const BreadcrumbsCollapse: (props: BreadcrumbsProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,123 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Children, isValidElement, cloneElement } from "react";
4
+ import { useHideOverflowItems, mergeProps, isString, isNotNil } from "@koobiq/react-core";
5
+ import { IconEllipsisHorizontal16 } from "@koobiq/react-icons";
6
+ import { Button } from "@koobiq/react-primitives";
7
+ import s from "../../Breadcrumbs.module.css.js";
8
+ import { clampEllipsisIndex, getSlotIndex } from "./utils.js";
9
+ import { BreadcrumbItem } from "../BreadcrumbItem/BreadcrumbItem.js";
10
+ import { Menu } from "../../../Menu/Menu.js";
11
+ const renderEllipsisDefault = ({
12
+ ellipsisIcon,
13
+ onAction,
14
+ items
15
+ }) => {
16
+ if (items.length === 0) return null;
17
+ return /* @__PURE__ */ jsx(
18
+ Menu,
19
+ {
20
+ onAction,
21
+ control: (props) => /* @__PURE__ */ jsx(BreadcrumbItem, { ...props, as: Button, children: ellipsisIcon }),
22
+ children: items.map((item, index) => /* @__PURE__ */ jsx(
23
+ Menu.Item,
24
+ {
25
+ ...item.props,
26
+ textValue: isString(item.children) ? item.children : `${index}`,
27
+ children: /* @__PURE__ */ jsx(Menu.ItemText, { children: item.children })
28
+ },
29
+ item.key
30
+ ))
31
+ }
32
+ );
33
+ };
34
+ const BreadcrumbsCollapse = (props) => {
35
+ const {
36
+ renderEllipsis = renderEllipsisDefault,
37
+ ellipsisIndex = 2,
38
+ onAction,
39
+ separator,
40
+ slotProps,
41
+ children
42
+ } = props;
43
+ const ellipsisIcon = /* @__PURE__ */ jsx(IconEllipsisHorizontal16, {});
44
+ const elements = Children.toArray(children);
45
+ const { length } = elements;
46
+ const slotsLength = length + 1;
47
+ const items = elements.map((element, index) => ({
48
+ element,
49
+ index,
50
+ props: element.props,
51
+ key: element.key ?? null,
52
+ href: element.props.href,
53
+ children: element.props.children
54
+ }));
55
+ const moreIndex = clampEllipsisIndex(ellipsisIndex, length);
56
+ const { parentRef, visibleMap, itemsRefs } = useHideOverflowItems({
57
+ length: slotsLength,
58
+ pinnedIndex: length,
59
+ moreIndex
60
+ });
61
+ const listProps = mergeProps(
62
+ { className: s.list, ref: parentRef },
63
+ slotProps?.list
64
+ );
65
+ const separatorProps = mergeProps(
66
+ { "aria-hidden": "true", className: s.divider },
67
+ slotProps?.divider
68
+ );
69
+ const renderSeparator = (isLast) => !isLast && isNotNil(separator) ? /* @__PURE__ */ jsx("span", { ...separatorProps, children: separator }) : null;
70
+ const collapsedItems = items.filter(
71
+ ({ index }) => !visibleMap[getSlotIndex(index, moreIndex)]
72
+ );
73
+ return /* @__PURE__ */ jsx("ol", { ...listProps, children: Array.from({ length: slotsLength }).map((_, slotIndex) => {
74
+ const isEllipsis = slotIndex === moreIndex;
75
+ const isLast = slotIndex === length;
76
+ const separatorNode = renderSeparator(isLast);
77
+ if (isEllipsis) {
78
+ const defaultEllipsis = /* @__PURE__ */ jsx(BreadcrumbItem, { as: "span", children: ellipsisIcon });
79
+ const customEllipsis = renderEllipsis?.({
80
+ ellipsisIcon,
81
+ ellipsisIndex: slotIndex,
82
+ items: collapsedItems,
83
+ onAction
84
+ });
85
+ return /* @__PURE__ */ jsxs(
86
+ "li",
87
+ {
88
+ className: s.ellipsis,
89
+ ref: itemsRefs[slotIndex],
90
+ "aria-hidden": !visibleMap[slotIndex] || void 0,
91
+ children: [
92
+ customEllipsis ?? defaultEllipsis,
93
+ separatorNode
94
+ ]
95
+ },
96
+ `ellipsis-${moreIndex}`
97
+ );
98
+ }
99
+ const itemIndex = slotIndex < moreIndex ? slotIndex : slotIndex - 1;
100
+ const child = items[itemIndex]?.element;
101
+ if (!child) return null;
102
+ if (!isValidElement(child)) return child;
103
+ const isLastChild = itemIndex === length - 1;
104
+ return /* @__PURE__ */ jsxs(
105
+ "li",
106
+ {
107
+ className: s.item,
108
+ ref: itemsRefs[slotIndex],
109
+ "aria-hidden": !visibleMap[slotIndex] || void 0,
110
+ children: [
111
+ cloneElement(child, {
112
+ isCurrent: child.props.isCurrent ?? isLastChild
113
+ }),
114
+ separatorNode
115
+ ]
116
+ },
117
+ child.key ?? itemIndex
118
+ );
119
+ }) });
120
+ };
121
+ export {
122
+ BreadcrumbsCollapse
123
+ };
@@ -0,0 +1 @@
1
+ export * from './BreadcrumbsCollapse';
@@ -0,0 +1,2 @@
1
+ export declare function clampEllipsisIndex(value: number, length: number): number;
2
+ export declare function getSlotIndex(itemIndex: number, moreIndex: number): number;
@@ -0,0 +1,11 @@
1
+ function clampEllipsisIndex(value, length) {
2
+ if (length <= 1) return 0;
3
+ return Math.max(0, Math.min(value, length - 1));
4
+ }
5
+ function getSlotIndex(itemIndex, moreIndex) {
6
+ return itemIndex < moreIndex ? itemIndex : itemIndex + 1;
7
+ }
8
+ export {
9
+ clampEllipsisIndex,
10
+ getSlotIndex
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { BreadcrumbsProps } from '../../types';
2
+ export declare const BreadcrumbsWrap: (props: BreadcrumbsProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Children, cloneElement } from "react";
4
+ import { mergeProps, isNotNil } from "@koobiq/react-core";
5
+ import s from "../../Breadcrumbs.module.css.js";
6
+ const BreadcrumbsWrap = (props) => {
7
+ const { separator, slotProps, children } = props;
8
+ const items = Children.toArray(children);
9
+ const listProps = mergeProps({ className: s.list }, slotProps?.list);
10
+ const separatorProps = mergeProps(
11
+ { "aria-hidden": "true", className: s.divider },
12
+ slotProps?.divider
13
+ );
14
+ return /* @__PURE__ */ jsx("ol", { ...listProps, children: items.map((item, i) => {
15
+ const isLast = i === items.length - 1;
16
+ const separatorNode = !isLast && isNotNil(separator) ? /* @__PURE__ */ jsx("span", { ...separatorProps, children: separator }) : null;
17
+ return /* @__PURE__ */ jsxs("li", { className: s.item, children: [
18
+ cloneElement(item, {
19
+ isCurrent: item.props.isCurrent ?? isLast
20
+ }),
21
+ separatorNode
22
+ ] }, item.key ?? i);
23
+ }) });
24
+ };
25
+ export {
26
+ BreadcrumbsWrap
27
+ };
@@ -0,0 +1 @@
1
+ export * from './BreadcrumbsWrap';
@@ -0,0 +1,3 @@
1
+ export * from './BreadcrumbItem';
2
+ export * from './BreadcrumbsCollapse';
3
+ export * from './BreadcrumbsWrap';
@@ -0,0 +1,3 @@
1
+ export * from './Breadcrumbs';
2
+ export * from './types';
3
+ export * from './components/BreadcrumbItem';
@@ -0,0 +1,69 @@
1
+ import type { Key, ReactNode, ComponentRef, ReactElement, ComponentPropsWithRef } from 'react';
2
+ import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
+ import type { AriaBreadcrumbsProps } from '@koobiq/react-primitives';
4
+ import type { BreadcrumbItemProps } from './components';
5
+ export declare const breadcrumbsPropSize: readonly ["compact", "normal", "big"];
6
+ export type BreadcrumbsPropSize = (typeof breadcrumbsPropSize)[number];
7
+ export declare const breadcrumbsPropOverflowMode: readonly ["collapse", "wrap"];
8
+ export type BreadcrumbsPropOverflowMode = (typeof breadcrumbsPropOverflowMode)[number];
9
+ export type BreadcrumbRenderItem = {
10
+ /** React element. */
11
+ element: ReactElement<BreadcrumbItemProps>;
12
+ /** Index in the `children` list. */
13
+ index: number;
14
+ /** Key. */
15
+ key: string | number | null;
16
+ /** Convenient access to the element's children. */
17
+ children: ReactNode;
18
+ /** Optional link target extracted from props. */
19
+ href?: string;
20
+ /** Element props shortcut. */
21
+ props: BreadcrumbItemProps;
22
+ };
23
+ export type RenderEllipsisParams = {
24
+ /** The collapsed items. */
25
+ items: BreadcrumbRenderItem[];
26
+ /** The default ellipsis icon. */
27
+ ellipsisIcon: ReactElement;
28
+ /** Index of the ellipsis in the visual list. */
29
+ ellipsisIndex: number;
30
+ /** Handler called when any breadcrumb item is pressed. It returns the item key. */
31
+ onAction?: (key: Key) => void;
32
+ };
33
+ export type BreadcrumbsPropRenderEllipsis = (params: RenderEllipsisParams) => ReactNode;
34
+ export type BreadcrumbsProps = ExtendableComponentPropsWithRef<AriaBreadcrumbsProps & {
35
+ /** The contents of the collection. */
36
+ children?: Array<ReactElement<BreadcrumbItemProps>>;
37
+ /**
38
+ * Size.
39
+ * @default 'normal'
40
+ */
41
+ size?: BreadcrumbsPropSize;
42
+ /**
43
+ * The separator between each breadcrumb.
44
+ * @default "/"
45
+ */
46
+ separator?: ReactNode;
47
+ /** Unique identifier for testing purposes. */
48
+ 'data-testid'?: string | number;
49
+ /** The props used for each slot inside. */
50
+ slotProps?: {
51
+ list?: ComponentPropsWithRef<'ol'>;
52
+ divider?: ComponentPropsWithRef<'span'>;
53
+ };
54
+ /**
55
+ * Position of the ellipsis item.
56
+ * @default 2
57
+ */
58
+ ellipsisIndex?: number;
59
+ /** Render-function for customizing the ellipsis item. */
60
+ renderEllipsis?: BreadcrumbsPropRenderEllipsis;
61
+ /**
62
+ * Controls how breadcrumbs behave when they run out of space — collapse items or wrap to a new line.
63
+ * @default 'collapse'
64
+ */
65
+ overflowMode?: BreadcrumbsPropOverflowMode;
66
+ /** Handler called when any breadcrumb item is pressed. It returns the item key. */
67
+ onAction?: (key: Key) => void;
68
+ }, 'nav'>;
69
+ export type BreadcrumbsRef = ComponentRef<'nav'>;
@@ -0,0 +1,6 @@
1
+ const breadcrumbsPropSize = ["compact", "normal", "big"];
2
+ const breadcrumbsPropOverflowMode = ["collapse", "wrap"];
3
+ export {
4
+ breadcrumbsPropOverflowMode,
5
+ breadcrumbsPropSize
6
+ };
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode, ComponentRef } from 'react';
2
- import { type ExtendableComponentPropsWithRef } from '@koobiq/react-core';
2
+ import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
+ import type { ContextValue } from '@koobiq/react-primitives';
3
4
  export type DialogBodyRef = ComponentRef<'div'>;
4
5
  export type DialogBodyProps = ExtendableComponentPropsWithRef<{
5
6
  /** Additional CSS-classes. */
@@ -9,5 +10,5 @@ export type DialogBodyProps = ExtendableComponentPropsWithRef<{
9
10
  /** Unique identifier for testing purposes. */
10
11
  'data-testid'?: string;
11
12
  }, 'div'>;
12
- export declare const DialogBodyContext: import("react").Context<DialogBodyProps>;
13
+ export declare const DialogBodyContext: import("react").Context<ContextValue<DialogBodyProps, HTMLDivElement>>;
13
14
  export declare const DialogBody: import("react").ForwardRefExoticComponent<Omit<DialogBodyProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,18 +1,18 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { createContext, forwardRef, useContext } from "react";
4
- import { mergeProps, clsx, useMultiRef } from "@koobiq/react-core";
3
+ import { createContext, forwardRef } from "react";
4
+ import { clsx } from "@koobiq/react-core";
5
+ import { useContextProps } from "@koobiq/react-primitives";
5
6
  import { utilClasses } from "../../../styles/utility.js";
6
7
  import s from "../Dialog.module.css.js";
7
- const DialogBodyContext = createContext({});
8
+ const DialogBodyContext = createContext(null);
8
9
  const DialogBody = forwardRef(
9
10
  ({ children, className, ...other }, ref) => {
10
- const defaultProps = useContext(DialogBodyContext);
11
- const { ref: contextRef } = mergeProps(defaultProps, other);
11
+ const [, ctxRef] = useContextProps({}, ref, DialogBodyContext);
12
12
  return /* @__PURE__ */ jsx(
13
13
  "div",
14
14
  {
15
- ref: useMultiRef([ref, contextRef]),
15
+ ref: ctxRef,
16
16
  className: clsx(
17
17
  s.content,
18
18
  utilClasses.typography["text-normal"],
@@ -2,27 +2,4 @@ import type { ComponentRef } from 'react';
2
2
  import { type ButtonProps } from '../../Button';
3
3
  export type DialogCloseButtonRef = ComponentRef<'button'>;
4
4
  export type DialogCloseButtonProps = ButtonProps;
5
- export declare const DialogCloseButton: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
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-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-expanded" | "aria-haspopup" | "aria-label" | "aria-labelledby" | "aria-pressed" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "onClick" | "name" | "target" | "type" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "data-testid" | "isDisabled" | "variant" | "onPress" | "onPressStart" | "onPressEnd" | "onPressChange" | "onPressUp" | "onFocusChange" | "preventFocusOnPress" | "excludeFromTabOrder" | keyof import("@react-types/shared").HoverEvents | "isLoading" | "fullWidth" | "onlyIcon" | "startIcon" | "endIcon" | keyof {
8
- progress?: boolean;
9
- disabled?: boolean;
10
- }> & Omit<Omit<import("@koobiq/react-primitives").ButtonBaseProps, "slot">, "children" | "style" | "className" | "data-testid" | "variant" | "fullWidth" | "onlyIcon" | "startIcon" | "endIcon" | keyof {
11
- progress?: boolean;
12
- disabled?: boolean;
13
- }> & {
14
- children?: import("react").ReactNode;
15
- variant?: import("../..").ButtonPropVariant;
16
- onlyIcon?: boolean;
17
- className?: string;
18
- style?: import("react").CSSProperties;
19
- fullWidth?: boolean;
20
- startIcon?: import("react").ReactNode;
21
- endIcon?: import("react").ReactNode;
22
- 'data-testid'?: string | number;
23
- } & {
24
- progress?: boolean;
25
- disabled?: boolean;
26
- } & {
27
- as?: "button" | undefined;
28
- }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
5
+ export declare const DialogCloseButton: import("react").ForwardRefExoticComponent<Omit<DialogCloseButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
@@ -1,8 +1,4 @@
1
1
  import { type TextProps, type TextRef } from '@koobiq/react-primitives';
2
2
  export type FormFieldCaptionProps = TextProps;
3
3
  export type FormFieldCaptionRef = TextRef;
4
- export declare const FormFieldCaption: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & {
5
- ref?: ((instance: HTMLParagraphElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLParagraphElement> | null | undefined;
6
- }, "as" | keyof import("@koobiq/react-primitives").TextBaseProps> & import("@koobiq/react-primitives").TextBaseProps & {
7
- as?: "p" | undefined;
8
- }, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
4
+ export declare const FormFieldCaption: import("react").ForwardRefExoticComponent<Omit<FormFieldCaptionProps, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;