@koobiq/react-components 0.21.1 → 0.23.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 (95) hide show
  1. package/dist/components/Accordion/Accordion.d.ts +9 -0
  2. package/dist/components/Accordion/Accordion.js +89 -0
  3. package/dist/components/Accordion/Accordion.module.css.js +8 -0
  4. package/dist/components/Accordion/AccordionStateContext.d.ts +2 -0
  5. package/dist/components/Accordion/AccordionStateContext.js +7 -0
  6. package/dist/components/Accordion/components/AccordionDetails/AccordionDetails.d.ts +2 -0
  7. package/dist/components/Accordion/components/AccordionDetails/AccordionDetails.js +55 -0
  8. package/dist/components/Accordion/components/AccordionDetails/AccordionDetails.module.css.js +8 -0
  9. package/dist/components/Accordion/components/AccordionDetails/AccordionDetailsContext.d.ts +2 -0
  10. package/dist/components/Accordion/components/AccordionDetails/AccordionDetailsContext.js +7 -0
  11. package/dist/components/Accordion/components/AccordionDetails/index.d.ts +3 -0
  12. package/dist/components/Accordion/components/AccordionDetails/types.d.ts +14 -0
  13. package/dist/components/Accordion/components/AccordionGroup/AccordionGroup.d.ts +2 -0
  14. package/dist/components/Accordion/components/AccordionGroup/AccordionGroup.js +31 -0
  15. package/dist/components/Accordion/components/AccordionGroup/AccordionGroup.module.css.js +8 -0
  16. package/dist/components/Accordion/components/AccordionGroup/AccordionGroupContext.d.ts +2 -0
  17. package/dist/components/Accordion/components/AccordionGroup/AccordionGroupContext.js +5 -0
  18. package/dist/components/Accordion/components/AccordionGroup/index.d.ts +3 -0
  19. package/dist/components/Accordion/components/AccordionGroup/types.d.ts +7 -0
  20. package/dist/components/Accordion/components/AccordionSummary/AccordionSummary.d.ts +4 -0
  21. package/dist/components/Accordion/components/AccordionSummary/AccordionSummary.js +80 -0
  22. package/dist/components/Accordion/components/AccordionSummary/AccordionSummary.module.css.js +24 -0
  23. package/dist/components/Accordion/components/AccordionSummary/AccordionSummaryContext.d.ts +2 -0
  24. package/dist/components/Accordion/components/AccordionSummary/AccordionSummaryContext.js +7 -0
  25. package/dist/components/Accordion/components/AccordionSummary/index.d.ts +3 -0
  26. package/dist/components/Accordion/components/AccordionSummary/types.d.ts +25 -0
  27. package/dist/components/Accordion/components/index.d.ts +3 -0
  28. package/dist/components/Accordion/index.d.ts +4 -0
  29. package/dist/components/Accordion/types.d.ts +8 -0
  30. package/dist/components/Autocomplete/Autocomplete.js +2 -2
  31. package/dist/components/Button/Button.js +1 -0
  32. package/dist/components/Calendar/Calendar.js +9 -10
  33. package/dist/components/Calendar/components/CalendarCell/CalendarCell.js +11 -1
  34. package/dist/components/Calendar/components/CalendarGrid/CalendarGrid.d.ts +2 -6
  35. package/dist/components/Calendar/components/CalendarGrid/CalendarGrid.js +13 -3
  36. package/dist/components/Calendar/components/CalendarGrid/index.d.ts +1 -0
  37. package/dist/components/Calendar/components/CalendarGrid/types.d.ts +10 -0
  38. package/dist/components/Calendar/components/CalendarHeader/CalendarHeader.d.ts +1 -7
  39. package/dist/components/Calendar/components/CalendarHeader/CalendarHeader.js +13 -6
  40. package/dist/components/Calendar/components/CalendarHeader/index.d.ts +1 -0
  41. package/dist/components/Calendar/components/CalendarHeader/types.d.ts +16 -0
  42. package/dist/components/Calendar/components/CalendarMonthDropdown/CalendarMonthDropdown.d.ts +11 -3
  43. package/dist/components/Calendar/components/CalendarMonthDropdown/CalendarMonthDropdown.js +26 -15
  44. package/dist/components/Calendar/components/CalendarYearDropdown/CalendarYearDropdown.d.ts +11 -3
  45. package/dist/components/Calendar/components/CalendarYearDropdown/CalendarYearDropdown.js +26 -15
  46. package/dist/components/Calendar/types.d.ts +8 -1
  47. package/dist/components/CheckboxGroup/CheckboxGroup.js +2 -2
  48. package/dist/components/ContenPanel/ContentPanel.d.ts +32 -0
  49. package/dist/components/ContenPanel/ContentPanel.js +157 -0
  50. package/dist/components/ContenPanel/ContentPanel.module.css.js +17 -0
  51. package/dist/components/ContenPanel/ContentPanelContext.d.ts +3 -0
  52. package/dist/components/ContenPanel/ContentPanelContext.js +6 -0
  53. package/dist/components/ContenPanel/components/ContentPanelContainer/ContentPanelContainer.d.ts +2 -0
  54. package/dist/components/ContenPanel/components/ContentPanelContainer/ContentPanelContainer.js +108 -0
  55. package/dist/components/ContenPanel/components/ContentPanelContainer/ContentPanelContainer.module.css.js +14 -0
  56. package/dist/components/ContenPanel/components/ContentPanelContainer/ContentPanelContainerContext.d.ts +7 -0
  57. package/dist/components/ContenPanel/components/ContentPanelContainer/ContentPanelContainerContext.js +8 -0
  58. package/dist/components/ContenPanel/components/ContentPanelContainer/index.d.ts +3 -0
  59. package/dist/components/ContenPanel/components/ContentPanelContainer/types.d.ts +23 -0
  60. package/dist/components/ContenPanel/components/index.d.ts +1 -0
  61. package/dist/components/ContenPanel/constants.d.ts +1 -0
  62. package/dist/components/ContenPanel/constants.js +4 -0
  63. package/dist/components/ContenPanel/hooks/index.d.ts +2 -0
  64. package/dist/components/ContenPanel/hooks/useContentPanelContainer/index.d.ts +1 -0
  65. package/dist/components/ContenPanel/hooks/useContentPanelContainer/useContentPanelContainer.d.ts +14 -0
  66. package/dist/components/ContenPanel/hooks/useContentPanelContainer/useContentPanelContainer.js +19 -0
  67. package/dist/components/ContenPanel/hooks/useContentPanelResize/index.d.ts +1 -0
  68. package/dist/components/ContenPanel/hooks/useContentPanelResize/intl.json.js +7 -0
  69. package/dist/components/ContenPanel/hooks/useContentPanelResize/useContentPanelResize.d.ts +32 -0
  70. package/dist/components/ContenPanel/hooks/useContentPanelResize/useContentPanelResize.js +80 -0
  71. package/dist/components/ContenPanel/index.d.ts +3 -0
  72. package/dist/components/ContenPanel/types.d.ts +53 -0
  73. package/dist/components/ContenPanel/utils/index.d.ts +3 -0
  74. package/dist/components/ContenPanel/utils/index.js +31 -0
  75. package/dist/components/DateInput/DateInput.js +2 -2
  76. package/dist/components/DatePicker/DatePicker.js +21 -21
  77. package/dist/components/DatePicker/types.d.ts +1 -0
  78. package/dist/components/Dialog/types.d.ts +1 -1
  79. package/dist/components/FormField/FormFieldInputDate/FormFieldInputDate.d.ts +3 -2
  80. package/dist/components/IconButton/IconButton.js +1 -0
  81. package/dist/components/Input/Input.js +2 -2
  82. package/dist/components/InputNumber/InputNumber.js +2 -2
  83. package/dist/components/Link/Link.js +0 -2
  84. package/dist/components/Menu/components/MenuItem/MenuItem.js +8 -1
  85. package/dist/components/RadioGroup/RadioGroup.js +2 -2
  86. package/dist/components/SearchInput/SearchInput.js +2 -2
  87. package/dist/components/Select/Select.js +2 -2
  88. package/dist/components/Select/intl.js +2 -2
  89. package/dist/components/Table/components/TableColumnHeader/TableColumnHeader.js +2 -2
  90. package/dist/components/Textarea/components/TextareaContextConsumer/TextareaContextConsumer.js +2 -2
  91. package/dist/components/TimePicker/TimePicker.js +2 -2
  92. package/dist/components/index.d.ts +2 -0
  93. package/dist/index.js +15 -0
  94. package/dist/style.css +188 -0
  95. package/package.json +5 -5
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from "react/jsx-runtime";
3
- import { useLocalizedStringFormatter, today } from "@koobiq/react-core";
3
+ import { useLocalizedStringFormatter, mergeProps, today } from "@koobiq/react-core";
4
4
  import { IconChevronLeft16, IconCircleXs16, IconChevronRight16 } from "@koobiq/react-icons";
5
5
  import intlMessages from "../../intl.json.js";
6
6
  import s from "./CalendarHeader.module.css.js";
@@ -8,16 +8,21 @@ import { CalendarMonthDropdown } from "../CalendarMonthDropdown/CalendarMonthDro
8
8
  import { CalendarYearDropdown } from "../CalendarYearDropdown/CalendarYearDropdown.js";
9
9
  import { Button } from "../../../Button/Button.js";
10
10
  const CalendarHeader = (props) => {
11
- const { prevButtonProps, nextButtonProps, state } = props;
11
+ const { prevButtonProps, nextButtonProps, state, slotProps } = props;
12
12
  const stringFormatter = useLocalizedStringFormatter(intlMessages);
13
- return /* @__PURE__ */ jsxs("div", { className: s.base, children: [
14
- /* @__PURE__ */ jsx(CalendarMonthDropdown, { state }),
15
- /* @__PURE__ */ jsx(CalendarYearDropdown, { state }),
16
- /* @__PURE__ */ jsxs("div", { className: s.actions, children: [
13
+ const rootProps = mergeProps({ className: s.base }, slotProps?.root);
14
+ const actionsProps = mergeProps({ className: s.actions }, slotProps?.actions);
15
+ const monthDropdown = mergeProps({ state }, slotProps?.["month-picker"]);
16
+ const yearDropdown = mergeProps({ state }, slotProps?.["year-picker"]);
17
+ return /* @__PURE__ */ jsxs("div", { ...rootProps, children: [
18
+ /* @__PURE__ */ jsx(CalendarMonthDropdown, { ...monthDropdown }),
19
+ /* @__PURE__ */ jsx(CalendarYearDropdown, { ...yearDropdown }),
20
+ /* @__PURE__ */ jsxs("div", { ...actionsProps, children: [
17
21
  /* @__PURE__ */ jsx(
18
22
  Button,
19
23
  {
20
24
  ...prevButtonProps,
25
+ "data-slot": "prev-period",
21
26
  variant: "contrast-transparent",
22
27
  startIcon: /* @__PURE__ */ jsx(IconChevronLeft16, {}),
23
28
  onlyIcon: true
@@ -31,6 +36,7 @@ const CalendarHeader = (props) => {
31
36
  const date = today(state.timeZone);
32
37
  state.setFocusedDate(date);
33
38
  },
39
+ "data-slot": "today",
34
40
  isDisabled: state.isDisabled,
35
41
  variant: "contrast-transparent",
36
42
  startIcon: /* @__PURE__ */ jsx(IconCircleXs16, {}),
@@ -41,6 +47,7 @@ const CalendarHeader = (props) => {
41
47
  Button,
42
48
  {
43
49
  ...nextButtonProps,
50
+ "data-slot": "next-period",
44
51
  variant: "contrast-transparent",
45
52
  startIcon: /* @__PURE__ */ jsx(IconChevronRight16, {}),
46
53
  onlyIcon: true
@@ -1 +1,2 @@
1
1
  export * from './CalendarHeader';
2
+ export * from './types';
@@ -0,0 +1,16 @@
1
+ import type { ComponentPropsWithRef } from 'react';
2
+ import type { CalendarAria, CalendarState } from '@koobiq/react-primitives';
3
+ import type { CalendarMonthDropdownProps } from '../CalendarMonthDropdown';
4
+ import type { CalendarYearDropdownProps } from '../CalendarYearDropdown';
5
+ export type CalendarHeaderProps = {
6
+ prevButtonProps: CalendarAria['prevButtonProps'];
7
+ nextButtonProps: CalendarAria['nextButtonProps'];
8
+ state: CalendarState;
9
+ /** The props used for each slot inside. */
10
+ slotProps?: {
11
+ root?: ComponentPropsWithRef<'div'>;
12
+ actions?: ComponentPropsWithRef<'div'>;
13
+ 'month-picker'?: Partial<CalendarMonthDropdownProps>;
14
+ 'year-picker'?: Partial<CalendarYearDropdownProps>;
15
+ };
16
+ };
@@ -1,6 +1,14 @@
1
+ import { type ComponentPropsWithRef } from 'react';
1
2
  import { type CalendarState } from '@koobiq/react-primitives';
2
- type CalendarMonthDropdownProps = {
3
+ import type { ItemProps } from '../../../Collections';
4
+ import type { PopoverProps } from '../../../Popover';
5
+ export type CalendarMonthDropdownProps = {
3
6
  state: CalendarState;
7
+ /** The props used for each slot inside. */
8
+ slotProps?: {
9
+ item?: ItemProps<object>;
10
+ popover?: PopoverProps;
11
+ list?: ComponentPropsWithRef<'ul'>;
12
+ };
4
13
  };
5
- export declare function CalendarMonthDropdown({ state }: CalendarMonthDropdownProps): import("react/jsx-runtime").JSX.Element;
6
- export {};
14
+ export declare function CalendarMonthDropdown({ state, slotProps, }: CalendarMonthDropdownProps): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,17 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { useRef, useEffect } from "react";
4
- import { useBoolean, useDateFormatter, clsx } from "@koobiq/react-core";
4
+ import { useBoolean, useDateFormatter, mergeProps, clsx } from "@koobiq/react-core";
5
5
  import { IconChevronDown16 } from "@koobiq/react-icons";
6
6
  import "@koobiq/react-primitives";
7
7
  import s from "../../Calendar.module.css.js";
8
8
  import { Menu } from "../../../Menu/Menu.js";
9
9
  import { capitalizeFirstLetter } from "../../../../utils/capitalizeFirstLetter/capitalizeFirstLetter.js";
10
10
  import { Button } from "../../../Button/Button.js";
11
- function CalendarMonthDropdown({ state }) {
11
+ function CalendarMonthDropdown({
12
+ state,
13
+ slotProps
14
+ }) {
12
15
  const months = [];
13
16
  const disabledKeys = /* @__PURE__ */ new Set();
14
17
  const [isOpen, { on, off }] = useBoolean();
@@ -54,6 +57,24 @@ function CalendarMonthDropdown({ state }) {
54
57
  name: longFormatter.format(date.toDate(state.timeZone))
55
58
  });
56
59
  }
60
+ const listProps = mergeProps(
61
+ {
62
+ ref: menuRef
63
+ },
64
+ slotProps?.list
65
+ );
66
+ const popoverProps = mergeProps(
67
+ {
68
+ maxBlockSize: 265,
69
+ slotProps: {
70
+ transition: {
71
+ onEnter: on,
72
+ onExited: off
73
+ }
74
+ }
75
+ },
76
+ slotProps?.popover
77
+ );
57
78
  return /* @__PURE__ */ jsx(
58
79
  Menu,
59
80
  {
@@ -70,18 +91,8 @@ function CalendarMonthDropdown({ state }) {
70
91
  ),
71
92
  className: s.popover,
72
93
  slotProps: {
73
- list: {
74
- ref: menuRef
75
- },
76
- popover: {
77
- maxBlockSize: 265,
78
- slotProps: {
79
- transition: {
80
- onEnter: on,
81
- onExited: off
82
- }
83
- }
84
- }
94
+ list: listProps,
95
+ popover: popoverProps
85
96
  },
86
97
  items: months,
87
98
  disabledKeys,
@@ -92,7 +103,7 @@ function CalendarMonthDropdown({ state }) {
92
103
  const date = state.focusedDate.set({ month: +value });
93
104
  state.setFocusedDate(date);
94
105
  },
95
- children: (item) => /* @__PURE__ */ jsx(Menu.Item, { children: capitalizeFirstLetter(item.name) })
106
+ children: (item) => /* @__PURE__ */ jsx(Menu.Item, { ...slotProps?.item, children: capitalizeFirstLetter(item.name) })
96
107
  }
97
108
  );
98
109
  }
@@ -1,6 +1,14 @@
1
+ import { type ComponentPropsWithRef } from 'react';
1
2
  import { type CalendarState } from '@koobiq/react-primitives';
2
- type CalendarYearDropdownProps = {
3
+ import type { ItemProps } from '../../../Collections';
4
+ import type { PopoverProps } from '../../../Popover';
5
+ export type CalendarYearDropdownProps = {
3
6
  state: CalendarState;
7
+ /** The props used for each slot inside. */
8
+ slotProps?: {
9
+ item?: ItemProps<object>;
10
+ popover?: PopoverProps;
11
+ list?: ComponentPropsWithRef<'ul'>;
12
+ };
4
13
  };
5
- export declare function CalendarYearDropdown({ state }: CalendarYearDropdownProps): import("react/jsx-runtime").JSX.Element;
6
- export {};
14
+ export declare function CalendarYearDropdown({ state, slotProps, }: CalendarYearDropdownProps): import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,16 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { useRef, useEffect } from "react";
4
- import { useBoolean, clsx } from "@koobiq/react-core";
4
+ import { useBoolean, mergeProps, clsx } from "@koobiq/react-core";
5
5
  import { IconChevronDown16 } from "@koobiq/react-icons";
6
6
  import "@koobiq/react-primitives";
7
7
  import s from "../../Calendar.module.css.js";
8
8
  import { Menu } from "../../../Menu/Menu.js";
9
9
  import { Button } from "../../../Button/Button.js";
10
- function CalendarYearDropdown({ state }) {
10
+ function CalendarYearDropdown({
11
+ state,
12
+ slotProps
13
+ }) {
11
14
  const years = [];
12
15
  const [isOpen, { on, off }] = useBoolean();
13
16
  const menuRef = useRef(null);
@@ -30,22 +33,30 @@ function CalendarYearDropdown({ state }) {
30
33
  }
31
34
  }, [state.focusedDate.year, isOpen]);
32
35
  const selectedYearName = years.find(({ id }) => id === state.focusedDate.year)?.id ?? "";
36
+ const listProps = mergeProps(
37
+ {
38
+ ref: menuRef
39
+ },
40
+ slotProps?.list
41
+ );
42
+ const popoverProps = mergeProps(
43
+ {
44
+ maxBlockSize: 265,
45
+ slotProps: {
46
+ transition: {
47
+ onEnter: on,
48
+ onExited: off
49
+ }
50
+ }
51
+ },
52
+ slotProps?.popover
53
+ );
33
54
  return /* @__PURE__ */ jsx(
34
55
  Menu,
35
56
  {
36
57
  slotProps: {
37
- list: {
38
- ref: menuRef
39
- },
40
- popover: {
41
- maxBlockSize: 265,
42
- slotProps: {
43
- transition: {
44
- onEnter: on,
45
- onExited: off
46
- }
47
- }
48
- }
58
+ list: listProps,
59
+ popover: popoverProps
49
60
  },
50
61
  control: (props) => /* @__PURE__ */ jsx(
51
62
  Button,
@@ -67,7 +78,7 @@ function CalendarYearDropdown({ state }) {
67
78
  const date = state.focusedDate.set({ year: +value });
68
79
  state.setFocusedDate(date);
69
80
  },
70
- children: (item) => /* @__PURE__ */ jsx(Menu.Item, { textValue: String(item.id), children: item.id })
81
+ children: (item) => /* @__PURE__ */ jsx(Menu.Item, { textValue: String(item.id), ...slotProps?.item, children: item.id })
71
82
  }
72
83
  );
73
84
  }
@@ -1,6 +1,7 @@
1
- import type { ComponentRef, CSSProperties, ReactElement, Ref } from 'react';
1
+ import type { ComponentPropsWithRef, ComponentRef, CSSProperties, ReactElement, Ref } from 'react';
2
2
  import type { ExtendableProps } from '@koobiq/react-core';
3
3
  import type { AriaCalendarProps, DateValue } from '@koobiq/react-primitives';
4
+ import type { CalendarGridProps, CalendarHeaderProps } from './components';
4
5
  export type CalendarProps<T extends DateValue> = ExtendableProps<{
5
6
  /** Ref to the root container. */
6
7
  ref?: Ref<HTMLDivElement>;
@@ -8,6 +9,12 @@ export type CalendarProps<T extends DateValue> = ExtendableProps<{
8
9
  className?: string;
9
10
  /** Inline styles. */
10
11
  style?: CSSProperties;
12
+ /** The props used for each slot inside. */
13
+ slotProps?: {
14
+ root?: ComponentPropsWithRef<'div'>;
15
+ grid?: Partial<CalendarGridProps>;
16
+ header?: Partial<CalendarHeaderProps>;
17
+ };
11
18
  }, Omit<AriaCalendarProps<T>, 'validationState' | 'errorMessage'>>;
12
19
  export type CalendarComponent = <T extends DateValue>(props: CalendarProps<T>) => ReactElement | null;
13
20
  export type CalendarRef = ComponentRef<'div'>;
@@ -104,8 +104,8 @@ const CheckboxGroup = forwardRef((props, ref) => {
104
104
  /* @__PURE__ */ jsx(FormField.Label, { ...labelProps }),
105
105
  /* @__PURE__ */ jsxs("div", { className: s.body, children: [
106
106
  /* @__PURE__ */ jsx(CheckboxGroupContext$1.Provider, { value: state, children: /* @__PURE__ */ jsx("div", { ...checkboxGroupProps, children }) }),
107
- /* @__PURE__ */ jsx(FormField.Caption, { ...descriptionProps }),
108
- /* @__PURE__ */ jsx(FieldErrorContext.Provider, { value: validation, children: /* @__PURE__ */ jsx(FormField.Error, { ...errorMessageProps }) })
107
+ /* @__PURE__ */ jsx(FieldErrorContext.Provider, { value: validation, children: /* @__PURE__ */ jsx(FormField.Error, { ...errorMessageProps }) }),
108
+ /* @__PURE__ */ jsx(FormField.Caption, { ...descriptionProps })
109
109
  ] })
110
110
  ] }) });
111
111
  });
@@ -0,0 +1,32 @@
1
+ import { type ComponentPropsWithRef, type CSSProperties } from 'react';
2
+ import { DialogBody, DialogFooter, DialogHeader, type DialogProps } from '../Dialog';
3
+ declare const ContentPanelComponent: import("react").ForwardRefExoticComponent<{
4
+ children?: import("react").ReactNode;
5
+ width?: import("./types").ContentPanelSize | null;
6
+ minWidth?: import("./types").ContentPanelSize | null;
7
+ maxWidth?: import("./types").ContentPanelSize | null;
8
+ defaultWidth?: import("./types").ContentPanelSize | null;
9
+ isResizable?: boolean;
10
+ onResize?: (width: number) => void;
11
+ onResizeStart?: (width: number) => void;
12
+ onResizeEnd?: (width: number) => void;
13
+ onResetResize?: (initialWidth: number) => number | null | undefined;
14
+ isOpen?: boolean;
15
+ defaultOpen?: boolean;
16
+ onOpenChange?: (open: boolean) => void;
17
+ className?: string;
18
+ style?: CSSProperties;
19
+ slotProps?: {
20
+ dialog?: DialogProps;
21
+ transition?: Partial<import("react-transition-group/Transition").TransitionProps<HTMLElement>>;
22
+ resizer?: ComponentPropsWithRef<"div"> & import("@koobiq/react-core").DataAttributeProps;
23
+ };
24
+ disableExitOnEscapeKeyDown?: boolean;
25
+ } & Pick<DialogProps, "hideCloseButton"> & import("react").RefAttributes<HTMLDivElement>>;
26
+ type CompoundedComponent = typeof ContentPanelComponent & {
27
+ Header: typeof DialogHeader;
28
+ Body: typeof DialogBody;
29
+ Footer: typeof DialogFooter;
30
+ };
31
+ export declare const ContentPanel: CompoundedComponent;
32
+ export {};
@@ -0,0 +1,157 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useRef, useContext } from "react";
4
+ import { useDOMRef, isNumber, mergeProps, clsx } from "@koobiq/react-core";
5
+ import { useContextProps, useOverlayTriggerState, useOverlay } from "@koobiq/react-primitives";
6
+ import { createPortal } from "react-dom";
7
+ import { Transition } from "react-transition-group";
8
+ import { TRANSITION_TIMEOUT } from "./constants.js";
9
+ import s from "./ContentPanel.module.css.js";
10
+ import { ContentPanelContext } from "./ContentPanelContext.js";
11
+ import { parseContentPanelSize } from "./utils/index.js";
12
+ import { ContentPanelContainerContext } from "./components/ContentPanelContainer/ContentPanelContainerContext.js";
13
+ import { useContentPanelResize } from "./hooks/useContentPanelResize/useContentPanelResize.js";
14
+ import { Dialog } from "../Dialog/Dialog.js";
15
+ import { DialogHeader } from "../Dialog/components/DialoglHeader.js";
16
+ import { DialogBody } from "../Dialog/components/DialogBody.js";
17
+ import { DialogFooter } from "../Dialog/components/DialogFooter.js";
18
+ const ContentPanelComponent = forwardRef(
19
+ (props, ref) => {
20
+ const domRef = useDOMRef(ref);
21
+ const overlayRef = useRef(null);
22
+ const [panelProps, panelRef] = useContextProps(
23
+ props,
24
+ domRef,
25
+ ContentPanelContext
26
+ );
27
+ const {
28
+ defaultWidth: defaultWidthProp,
29
+ minWidth: minWidthProp,
30
+ maxWidth: maxWidthProp,
31
+ disableExitOnEscapeKeyDown,
32
+ onResetResize,
33
+ isResizable = false,
34
+ width,
35
+ onResize,
36
+ onResizeEnd,
37
+ onResizeStart,
38
+ isOpen,
39
+ onOpenChange,
40
+ defaultOpen,
41
+ className,
42
+ style,
43
+ children,
44
+ slotProps,
45
+ hideCloseButton,
46
+ ...other
47
+ } = panelProps;
48
+ const {
49
+ portalContainer,
50
+ containerWidth,
51
+ state: containerState
52
+ } = useContext(ContentPanelContainerContext);
53
+ const componentState = useOverlayTriggerState({
54
+ isOpen,
55
+ onOpenChange,
56
+ defaultOpen
57
+ });
58
+ const state = containerState ?? componentState;
59
+ const { isOpen: isOpenState, close } = state;
60
+ const maxWidthPropPx = parseContentPanelSize(containerWidth, maxWidthProp);
61
+ const minWidthPropPx = parseContentPanelSize(containerWidth, minWidthProp);
62
+ const defaultWidthPx = parseContentPanelSize(
63
+ containerWidth,
64
+ defaultWidthProp
65
+ );
66
+ const maxWidth = Math.min(
67
+ isNumber(containerWidth) ? containerWidth : Number.POSITIVE_INFINITY,
68
+ isNumber(maxWidthPropPx) ? maxWidthPropPx : Number.POSITIVE_INFINITY
69
+ );
70
+ const minWidth = Math.max(
71
+ 0,
72
+ isNumber(minWidthPropPx) ? minWidthPropPx : 200
73
+ );
74
+ const defaultWidth = defaultWidthPx ?? 400;
75
+ const widthPx = parseContentPanelSize(containerWidth, width);
76
+ const { width: panelWidth, resizerProps: moveProps } = useContentPanelResize({
77
+ width: widthPx,
78
+ isResizable,
79
+ minWidth,
80
+ maxWidth,
81
+ onResize,
82
+ onResizeEnd,
83
+ onResizeStart,
84
+ onResetResize,
85
+ defaultWidth
86
+ });
87
+ const { overlayProps } = useOverlay(
88
+ {
89
+ onClose: close,
90
+ isOpen: isOpenState,
91
+ isKeyboardDismissDisabled: disableExitOnEscapeKeyDown
92
+ },
93
+ overlayRef
94
+ );
95
+ const rootProps = mergeProps(
96
+ {
97
+ ref: panelRef,
98
+ className: clsx(s.base, isResizable && s.resizable, className),
99
+ style: {
100
+ inlineSize: panelWidth,
101
+ "--content-panel-transition-duration": `${TRANSITION_TIMEOUT}ms`,
102
+ ...style
103
+ }
104
+ },
105
+ other
106
+ );
107
+ const dialogProps = mergeProps(
108
+ {
109
+ onClose: close,
110
+ className: s.dialog,
111
+ hideCloseButton
112
+ },
113
+ slotProps?.dialog,
114
+ overlayProps
115
+ );
116
+ const resizerProps = mergeProps(
117
+ {
118
+ className: s.resizer
119
+ },
120
+ slotProps?.resizer,
121
+ moveProps
122
+ );
123
+ const transitionProps = mergeProps(
124
+ {
125
+ timeout: TRANSITION_TIMEOUT,
126
+ in: isOpenState,
127
+ nodeRef: panelRef,
128
+ unmountOnExit: true
129
+ },
130
+ slotProps?.transition
131
+ );
132
+ const panel = /* @__PURE__ */ jsx(Transition, { ...transitionProps, children: (transition) => /* @__PURE__ */ jsx(
133
+ "div",
134
+ {
135
+ ...rootProps,
136
+ "data-transition": transition,
137
+ "data-resizable": isResizable || void 0,
138
+ children: /* @__PURE__ */ jsxs(Dialog, { ...dialogProps, ref: overlayRef, role: "dialog", children: [
139
+ isResizable && /* @__PURE__ */ jsx("div", { ...resizerProps }),
140
+ children
141
+ ] })
142
+ }
143
+ ) });
144
+ if (containerState && portalContainer) {
145
+ return createPortal(panel, portalContainer);
146
+ }
147
+ return panel;
148
+ }
149
+ );
150
+ ContentPanelComponent.displayName = "ContentPanel";
151
+ const ContentPanel = ContentPanelComponent;
152
+ ContentPanel.Header = DialogHeader;
153
+ ContentPanel.Body = DialogBody;
154
+ ContentPanel.Footer = DialogFooter;
155
+ export {
156
+ ContentPanel
157
+ };
@@ -0,0 +1,17 @@
1
+ const base = "kbq-contentpanel-3541ee";
2
+ const resizable = "kbq-contentpanel-resizable-71e8a7";
3
+ const dialog = "kbq-contentpanel-dialog-872768";
4
+ const resizer = "kbq-contentpanel-resizer-a708c1";
5
+ const s = {
6
+ base,
7
+ resizable,
8
+ dialog,
9
+ resizer
10
+ };
11
+ export {
12
+ base,
13
+ s as default,
14
+ dialog,
15
+ resizable,
16
+ resizer
17
+ };
@@ -0,0 +1,3 @@
1
+ import type { ContextValue } from '@koobiq/react-primitives';
2
+ import type { ContentPanelProps } from './types';
3
+ export declare const ContentPanelContext: import("react").Context<ContextValue<ContentPanelProps, HTMLDivElement>>;
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ import { createContext } from "react";
3
+ const ContentPanelContext = createContext(null);
4
+ export {
5
+ ContentPanelContext
6
+ };
@@ -0,0 +1,2 @@
1
+ import type { ContentPanelContainerProps } from './types';
2
+ export declare const ContentPanelContainer: import("react").ForwardRefExoticComponent<Omit<ContentPanelContainerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,108 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { forwardRef, useState, useRef, useMemo } from "react";
4
+ import { useMultiRef, useResizeObserverRefs, mergeProps, clsx } from "@koobiq/react-core";
5
+ import { useOverlayTriggerState, Provider, ButtonContext, DEFAULT_SLOT } from "@koobiq/react-primitives";
6
+ import { TRANSITION_TIMEOUT } from "../../constants.js";
7
+ import { ContentPanelContext } from "../../ContentPanelContext.js";
8
+ import { getInlineSize } from "../../utils/index.js";
9
+ import s from "./ContentPanelContainer.module.css.js";
10
+ import { ContentPanelContainerContext } from "./ContentPanelContainerContext.js";
11
+ import { useContentPanelContainer } from "../../hooks/useContentPanelContainer/useContentPanelContainer.js";
12
+ const ContentPanelContainer = forwardRef((props, ref) => {
13
+ const {
14
+ children,
15
+ isOpen,
16
+ onOpenChange,
17
+ disableExitOnEscapeKeyDown,
18
+ defaultOpen,
19
+ className,
20
+ slotProps,
21
+ ...other
22
+ } = props;
23
+ const state = useOverlayTriggerState({
24
+ isOpen,
25
+ onOpenChange,
26
+ defaultOpen
27
+ });
28
+ const [portalContainer, setPortalContainer] = useState(
29
+ null
30
+ );
31
+ const { triggerProps, containerProps } = useContentPanelContainer(
32
+ { isKeyboardDismissDisabled: !!disableExitOnEscapeKeyDown },
33
+ state
34
+ );
35
+ const containerRef = useRef(null);
36
+ const panelRef = useRef(null);
37
+ const domRef = useMultiRef([
38
+ ref,
39
+ containerRef,
40
+ setPortalContainer
41
+ ]);
42
+ const observedRefs = useMemo(
43
+ () => [containerRef, panelRef],
44
+ [panelRef.current, containerRef.current, state.isOpen]
45
+ );
46
+ const [containerWidth, panelWidth] = useResizeObserverRefs(
47
+ observedRefs,
48
+ (el) => {
49
+ if (el) return getInlineSize(el);
50
+ return 0;
51
+ }
52
+ );
53
+ const rootProps = mergeProps(
54
+ {
55
+ className: clsx(s.base, className),
56
+ ref: domRef,
57
+ ...other
58
+ },
59
+ containerProps
60
+ );
61
+ const bodyProps = {
62
+ ...slotProps?.body,
63
+ className: clsx(s.body, slotProps?.body?.className),
64
+ children: typeof children === "function" ? children(state) : children,
65
+ style: {
66
+ ...slotProps?.body?.style,
67
+ "--content-panel-inline-size": `${panelWidth}px`,
68
+ "--content-body-transition-duration": `${TRANSITION_TIMEOUT}ms`
69
+ }
70
+ };
71
+ return /* @__PURE__ */ jsx(
72
+ Provider,
73
+ {
74
+ values: [
75
+ [
76
+ ContentPanelContainerContext,
77
+ {
78
+ state,
79
+ containerWidth: containerWidth || void 0,
80
+ portalContainer
81
+ }
82
+ ],
83
+ [
84
+ ContentPanelContext,
85
+ {
86
+ ref: panelRef,
87
+ className: s.panel,
88
+ disableExitOnEscapeKeyDown
89
+ }
90
+ ],
91
+ [
92
+ ButtonContext,
93
+ {
94
+ slots: {
95
+ [DEFAULT_SLOT]: {},
96
+ trigger: triggerProps
97
+ }
98
+ }
99
+ ]
100
+ ],
101
+ children: /* @__PURE__ */ jsx("div", { ...rootProps, children: /* @__PURE__ */ jsx("div", { ...bodyProps }) })
102
+ }
103
+ );
104
+ });
105
+ ContentPanelContainer.displayName = "ContentPanelContainer";
106
+ export {
107
+ ContentPanelContainer
108
+ };
@@ -0,0 +1,14 @@
1
+ const base = "kbq-contentpanelcontainer-476965";
2
+ const body = "kbq-contentpanelcontainer-body-b7b172";
3
+ const panel = "kbq-contentpanelcontainer-panel-03cf65";
4
+ const s = {
5
+ base,
6
+ body,
7
+ panel
8
+ };
9
+ export {
10
+ base,
11
+ body,
12
+ s as default,
13
+ panel
14
+ };
@@ -0,0 +1,7 @@
1
+ import type { OverlayTriggerState } from '@react-stately/overlays';
2
+ export type ContentPanelStateContextProps = {
3
+ portalContainer?: HTMLElement | null;
4
+ containerWidth?: number;
5
+ state: OverlayTriggerState;
6
+ };
7
+ export declare const ContentPanelContainerContext: import("react").Context<ContentPanelStateContextProps>;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { createContext } from "react";
3
+ const ContentPanelContainerContext = createContext(
4
+ {}
5
+ );
6
+ export {
7
+ ContentPanelContainerContext
8
+ };
@@ -0,0 +1,3 @@
1
+ export * from './ContentPanelContainer';
2
+ export * from './ContentPanelContainerContext';
3
+ export * from './types';