@koobiq/react-components 0.22.0 → 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 (66) hide show
  1. package/dist/components/Autocomplete/Autocomplete.js +2 -2
  2. package/dist/components/Button/Button.js +1 -0
  3. package/dist/components/Calendar/Calendar.js +9 -10
  4. package/dist/components/Calendar/components/CalendarCell/CalendarCell.js +11 -1
  5. package/dist/components/Calendar/components/CalendarGrid/CalendarGrid.d.ts +2 -6
  6. package/dist/components/Calendar/components/CalendarGrid/CalendarGrid.js +13 -3
  7. package/dist/components/Calendar/components/CalendarGrid/index.d.ts +1 -0
  8. package/dist/components/Calendar/components/CalendarGrid/types.d.ts +10 -0
  9. package/dist/components/Calendar/components/CalendarHeader/CalendarHeader.d.ts +1 -7
  10. package/dist/components/Calendar/components/CalendarHeader/CalendarHeader.js +13 -6
  11. package/dist/components/Calendar/components/CalendarHeader/index.d.ts +1 -0
  12. package/dist/components/Calendar/components/CalendarHeader/types.d.ts +16 -0
  13. package/dist/components/Calendar/components/CalendarMonthDropdown/CalendarMonthDropdown.d.ts +11 -3
  14. package/dist/components/Calendar/components/CalendarMonthDropdown/CalendarMonthDropdown.js +26 -15
  15. package/dist/components/Calendar/components/CalendarYearDropdown/CalendarYearDropdown.d.ts +11 -3
  16. package/dist/components/Calendar/components/CalendarYearDropdown/CalendarYearDropdown.js +26 -15
  17. package/dist/components/Calendar/types.d.ts +8 -1
  18. package/dist/components/CheckboxGroup/CheckboxGroup.js +2 -2
  19. package/dist/components/ContenPanel/ContentPanel.d.ts +32 -0
  20. package/dist/components/ContenPanel/ContentPanel.js +157 -0
  21. package/dist/components/ContenPanel/ContentPanel.module.css.js +17 -0
  22. package/dist/components/ContenPanel/ContentPanelContext.d.ts +3 -0
  23. package/dist/components/ContenPanel/ContentPanelContext.js +6 -0
  24. package/dist/components/ContenPanel/components/ContentPanelContainer/ContentPanelContainer.d.ts +2 -0
  25. package/dist/components/ContenPanel/components/ContentPanelContainer/ContentPanelContainer.js +108 -0
  26. package/dist/components/ContenPanel/components/ContentPanelContainer/ContentPanelContainer.module.css.js +14 -0
  27. package/dist/components/ContenPanel/components/ContentPanelContainer/ContentPanelContainerContext.d.ts +7 -0
  28. package/dist/components/ContenPanel/components/ContentPanelContainer/ContentPanelContainerContext.js +8 -0
  29. package/dist/components/ContenPanel/components/ContentPanelContainer/index.d.ts +3 -0
  30. package/dist/components/ContenPanel/components/ContentPanelContainer/types.d.ts +23 -0
  31. package/dist/components/ContenPanel/components/index.d.ts +1 -0
  32. package/dist/components/ContenPanel/constants.d.ts +1 -0
  33. package/dist/components/ContenPanel/constants.js +4 -0
  34. package/dist/components/ContenPanel/hooks/index.d.ts +2 -0
  35. package/dist/components/ContenPanel/hooks/useContentPanelContainer/index.d.ts +1 -0
  36. package/dist/components/ContenPanel/hooks/useContentPanelContainer/useContentPanelContainer.d.ts +14 -0
  37. package/dist/components/ContenPanel/hooks/useContentPanelContainer/useContentPanelContainer.js +19 -0
  38. package/dist/components/ContenPanel/hooks/useContentPanelResize/index.d.ts +1 -0
  39. package/dist/components/ContenPanel/hooks/useContentPanelResize/intl.json.js +7 -0
  40. package/dist/components/ContenPanel/hooks/useContentPanelResize/useContentPanelResize.d.ts +32 -0
  41. package/dist/components/ContenPanel/hooks/useContentPanelResize/useContentPanelResize.js +80 -0
  42. package/dist/components/ContenPanel/index.d.ts +3 -0
  43. package/dist/components/ContenPanel/types.d.ts +53 -0
  44. package/dist/components/ContenPanel/utils/index.d.ts +3 -0
  45. package/dist/components/ContenPanel/utils/index.js +31 -0
  46. package/dist/components/DateInput/DateInput.js +2 -2
  47. package/dist/components/DatePicker/DatePicker.js +21 -21
  48. package/dist/components/DatePicker/types.d.ts +1 -0
  49. package/dist/components/Dialog/types.d.ts +1 -1
  50. package/dist/components/FormField/FormFieldInputDate/FormFieldInputDate.d.ts +3 -2
  51. package/dist/components/IconButton/IconButton.js +1 -0
  52. package/dist/components/Input/Input.js +2 -2
  53. package/dist/components/InputNumber/InputNumber.js +2 -2
  54. package/dist/components/Link/Link.js +0 -2
  55. package/dist/components/Menu/components/MenuItem/MenuItem.js +8 -1
  56. package/dist/components/RadioGroup/RadioGroup.js +2 -2
  57. package/dist/components/SearchInput/SearchInput.js +2 -2
  58. package/dist/components/Select/Select.js +2 -2
  59. package/dist/components/Select/intl.js +2 -2
  60. package/dist/components/Table/components/TableColumnHeader/TableColumnHeader.js +2 -2
  61. package/dist/components/Textarea/components/TextareaContextConsumer/TextareaContextConsumer.js +2 -2
  62. package/dist/components/TimePicker/TimePicker.js +2 -2
  63. package/dist/components/index.d.ts +1 -0
  64. package/dist/index.js +6 -0
  65. package/dist/style.css +90 -0
  66. package/package.json +5 -5
@@ -204,8 +204,8 @@ function AutocompleteRender(props, ref) {
204
204
  /* @__PURE__ */ jsx(FormField.Label, { ...labelProps }),
205
205
  /* @__PURE__ */ jsxs("div", { className: s.body, children: [
206
206
  /* @__PURE__ */ jsx(FormField.ControlGroup, { ...groupProps, children: /* @__PURE__ */ jsx(FormField.Input, { ...inputProps }) }),
207
- /* @__PURE__ */ jsx(FormField.Caption, { ...captionProps }),
208
- /* @__PURE__ */ jsx(FieldErrorContext.Provider, { value: validation, children: /* @__PURE__ */ jsx(FormField.Error, { ...errorProps }) })
207
+ /* @__PURE__ */ jsx(FieldErrorContext.Provider, { value: validation, children: /* @__PURE__ */ jsx(FormField.Error, { ...errorProps }) }),
208
+ /* @__PURE__ */ jsx(FormField.Caption, { ...captionProps })
209
209
  ] }),
210
210
  /* @__PURE__ */ jsx(PopoverInner, { ...popoverProps, children: /* @__PURE__ */ jsx(ListInner, { ...listProps }) })
211
211
  ] });
@@ -60,6 +60,7 @@ const Button = polymorphicForwardRef(
60
60
  isDisabled,
61
61
  className: classNameFn,
62
62
  "data-variant": variant,
63
+ "data-slot": "button",
63
64
  "data-loading": isLoading || void 0,
64
65
  "data-fullwidth": fullWidth || void 0,
65
66
  "data-onlyicon": !!iconOnly || void 0,
@@ -9,7 +9,7 @@ import { CalendarHeader } from "./components/CalendarHeader/CalendarHeader.js";
9
9
  import { CalendarGrid } from "./components/CalendarGrid/CalendarGrid.js";
10
10
  const textNormal = utilClasses.typography["text-normal"];
11
11
  function CalendarRender(props, ref) {
12
- const { style, className } = props;
12
+ const { style, className, slotProps } = props;
13
13
  const { locale } = useLocale();
14
14
  const state = useCalendarState({
15
15
  createCalendar,
@@ -22,18 +22,17 @@ function CalendarRender(props, ref) {
22
22
  );
23
23
  const rootProps = mergeProps(
24
24
  { className: clsx(s.base, textNormal, className), style, ref },
25
+ slotProps?.root,
25
26
  calendarProps
26
27
  );
28
+ const headerProps = mergeProps(
29
+ { state, prevButtonProps, nextButtonProps },
30
+ slotProps?.header
31
+ );
32
+ const gridProps = mergeProps({ state }, slotProps?.grid);
27
33
  return /* @__PURE__ */ jsxs("div", { ...rootProps, children: [
28
- /* @__PURE__ */ jsx(
29
- CalendarHeader,
30
- {
31
- state,
32
- prevButtonProps,
33
- nextButtonProps
34
- }
35
- ),
36
- /* @__PURE__ */ jsx(CalendarGrid, { state })
34
+ /* @__PURE__ */ jsx(CalendarHeader, { ...headerProps }),
35
+ /* @__PURE__ */ jsx(CalendarGrid, { ...gridProps })
37
36
  ] });
38
37
  }
39
38
  const Calendar = forwardRef(CalendarRender);
@@ -23,12 +23,22 @@ function CalendarCell({ state, date }) {
23
23
  const { hoverProps, isHovered } = useHover({
24
24
  isDisabled: isDisabled || isUnavailable
25
25
  });
26
- const { focusProps, isFocusVisible } = useFocusRing({});
26
+ const { focusProps, isFocusVisible, isFocused } = useFocusRing({});
27
27
  return /* @__PURE__ */ jsx("td", { ...cellProps, children: /* @__PURE__ */ jsx(
28
28
  "div",
29
29
  {
30
30
  ...mergeProps(hoverProps, focusProps, buttonProps),
31
31
  ref,
32
+ "data-slot": "calendar-cell",
33
+ "data-today": isToday || void 0,
34
+ "data-focused": isFocused || void 0,
35
+ "data-pressed": isPressed || void 0,
36
+ "data-hovered": isHovered || void 0,
37
+ "data-invalid": isInvalid || void 0,
38
+ "data-disabled": isDisabled || void 0,
39
+ "data-selected": isSelected || void 0,
40
+ "data-unavailable": isUnavailable || void 0,
41
+ "data-focus-visible": isFocusVisible || void 0,
32
42
  className: clsx(
33
43
  s.base,
34
44
  isToday && s.today,
@@ -1,6 +1,2 @@
1
- import { type CalendarState, type AriaCalendarGridProps } from '@koobiq/react-primitives';
2
- type CalendarGridProps = {
3
- state: CalendarState;
4
- } & AriaCalendarGridProps;
5
- export declare function CalendarGrid({ state, ...props }: CalendarGridProps): import("react/jsx-runtime").JSX.Element;
6
- export {};
1
+ import type { CalendarGridProps } from './index';
2
+ export declare function CalendarGrid({ state, slotProps, ...props }: CalendarGridProps): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useMemo, useRef, useEffect, createRef } from "react";
4
- import { useLocale, getWeeksInMonth, clsx } from "@koobiq/react-core";
4
+ import { useLocale, getWeeksInMonth, mergeProps, clsx } from "@koobiq/react-core";
5
5
  import { useCalendarGrid } from "@koobiq/react-primitives";
6
6
  import { TransitionGroup, CSSTransition } from "react-transition-group";
7
7
  import { utilClasses } from "../../../../styles/utility.js";
@@ -9,7 +9,11 @@ import s from "./CalendarGrid.module.css.js";
9
9
  import { monthIndex } from "./utils.js";
10
10
  import { CalendarCell } from "../CalendarCell/CalendarCell.js";
11
11
  const textNormal = utilClasses.typography["text-normal"];
12
- function CalendarGrid({ state, ...props }) {
12
+ function CalendarGrid({
13
+ state,
14
+ slotProps,
15
+ ...props
16
+ }) {
13
17
  const { locale } = useLocale();
14
18
  const { gridProps, headerProps, weekDays } = useCalendarGrid(
15
19
  { ...props, weekdayStyle: "short" },
@@ -40,7 +44,13 @@ function CalendarGrid({ state, ...props }) {
40
44
  nodeRefs.current.set(k, createRef());
41
45
  }
42
46
  const tbodyRef = nodeRefs.current.get(k);
43
- return /* @__PURE__ */ jsx("div", { className: s.container, children: /* @__PURE__ */ jsxs("table", { ...gridProps, className: clsx(s.base, s[dir], textNormal), children: [
47
+ const rootProps = mergeProps({ className: s.container }, slotProps?.root);
48
+ const tableProps = mergeProps(
49
+ { className: clsx(s.base, s[dir], textNormal) },
50
+ slotProps?.table,
51
+ gridProps
52
+ );
53
+ return /* @__PURE__ */ jsx("div", { ...rootProps, children: /* @__PURE__ */ jsxs("table", { ...tableProps, children: [
44
54
  /* @__PURE__ */ jsxs("thead", { ...headerProps, children: [
45
55
  /* @__PURE__ */ jsx("tr", { children: weekDays.map((day, i) => /* @__PURE__ */ jsx("th", { className: clsx(s.weekDay, textNormal), children: day }, i)) }),
46
56
  /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("th", { colSpan: 7, className: s.divider }) })
@@ -1 +1,2 @@
1
1
  export * from './CalendarGrid';
2
+ export * from './types';
@@ -0,0 +1,10 @@
1
+ import type { ComponentPropsWithRef } from 'react';
2
+ import type { AriaCalendarGridProps, CalendarState } from '@koobiq/react-primitives';
3
+ export type CalendarGridProps = {
4
+ state: CalendarState;
5
+ /** The props used for each slot inside. */
6
+ slotProps?: {
7
+ root?: ComponentPropsWithRef<'div'>;
8
+ table?: ComponentPropsWithRef<'table'>;
9
+ };
10
+ } & AriaCalendarGridProps;
@@ -1,8 +1,2 @@
1
- import type { CalendarState, CalendarAria } from '@koobiq/react-primitives';
2
- type CalendarHeaderProps = {
3
- prevButtonProps: CalendarAria['prevButtonProps'];
4
- nextButtonProps: CalendarAria['nextButtonProps'];
5
- state: CalendarState;
6
- };
1
+ import type { CalendarHeaderProps } from './types';
7
2
  export declare const CalendarHeader: (props: CalendarHeaderProps) => import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -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>>;