@koobiq/react-components 0.0.1-beta.5 → 0.0.1-beta.6

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.
@@ -8,27 +8,29 @@ import { ListSection } from "./components/ListSection/ListSection.js";
8
8
  import { Typography } from "../Typography/Typography.js";
9
9
  import { ListOption } from "./components/ListOption/ListOption.js";
10
10
  function ListRender(props, ref) {
11
- const { className, label } = props;
11
+ const { label, className, style, slotProps } = props;
12
12
  const domRef = useDOMRef(ref);
13
13
  const state = useListState(props);
14
14
  const { listBoxProps, labelProps } = useListBox(props, state, domRef);
15
+ const titleProps = mergeProps(
16
+ {
17
+ className: s.label,
18
+ variant: "text-normal-strong"
19
+ },
20
+ slotProps?.label,
21
+ labelProps
22
+ );
15
23
  const listProps = mergeProps(
16
24
  {
17
- className: clsx(s.base, className),
18
- ref: domRef
25
+ style,
26
+ ref: domRef,
27
+ className: clsx(s.base, className)
19
28
  },
29
+ slotProps?.list,
20
30
  listBoxProps
21
31
  );
22
32
  return /* @__PURE__ */ jsxs(Fragment, { children: [
23
- isNotNil(label) && /* @__PURE__ */ jsx(
24
- Typography,
25
- {
26
- variant: "text-normal-strong",
27
- className: s.label,
28
- ...labelProps,
29
- children: label
30
- }
31
- ),
33
+ isNotNil(label) && /* @__PURE__ */ jsx(Typography, { ...titleProps, children: label }),
32
34
  /* @__PURE__ */ jsx("ul", { ...listProps, children: [...state.collection].map(
33
35
  (item) => item.type === "section" ? /* @__PURE__ */ jsx(ListSection, { section: item, state }, item.key) : /* @__PURE__ */ jsx(ListOption, { item, state }, item.key)
34
36
  ) })
@@ -1,5 +1,6 @@
1
- import type { ComponentRef, ReactElement, ReactNode, Ref } from 'react';
1
+ import type { ComponentPropsWithRef, ComponentRef, CSSProperties, ReactElement, ReactNode, Ref } from 'react';
2
2
  import type { AriaListBoxProps } from '@koobiq/react-primitives';
3
+ import type { TypographyProps } from '../Typography';
3
4
  export declare const listPropSelectionMode: readonly ["none", "single", "multiple"];
4
5
  export type ListPropSelectionMode = (typeof listPropSelectionMode)[number];
5
6
  export type ListPropItems<T extends object> = AriaListBoxProps<T>['items'];
@@ -14,8 +15,11 @@ export type ListBaseProps<T extends object> = {
14
15
  label?: ReactNode;
15
16
  /** Additional CSS-classes. */
16
17
  className?: string;
18
+ /** Inline styles. */
19
+ style?: CSSProperties;
17
20
  /** The type of selection that is allowed in the collection. */
18
21
  selectionMode?: ListPropSelectionMode;
22
+ /** Ref to the HTML ul-element. */
19
23
  ref?: Ref<HTMLElement>;
20
24
  /** The contents of the collection. */
21
25
  children?: ListPropChildren<T>;
@@ -36,6 +40,11 @@ export type ListBaseProps<T extends object> = {
36
40
  onAction?: ListPropOnAction<T>;
37
41
  /** How multiple selection should behave in the collection. */
38
42
  selectionBehavior?: ListPropSelectionBehavior<T>;
43
+ /** The props used for each slot inside. */
44
+ slotProps?: {
45
+ label?: TypographyProps;
46
+ list?: ComponentPropsWithRef<'div'>;
47
+ };
39
48
  };
40
49
  export type ListProps<T extends object> = ListBaseProps<T>;
41
50
  export type ListRef = ComponentRef<'ul'>;
@@ -12,6 +12,7 @@ const Popover = forwardRef(
12
12
  const {
13
13
  placement: placementProp = "top",
14
14
  arrowBoundaryOffset = 20,
15
+ containerPadding = 12,
15
16
  hideArrow = false,
16
17
  size = "medium",
17
18
  crossOffset = 0,
@@ -58,9 +59,9 @@ const Popover = forwardRef(
58
59
  isNonModal,
59
60
  crossOffset,
60
61
  maxHeight: 480,
62
+ containerPadding,
61
63
  popoverRef: domRef,
62
64
  arrowBoundaryOffset,
63
- containerPadding: 24,
64
65
  placement: placementProp,
65
66
  isKeyboardDismissDisabled: disableExitOnEscapeKeyDown,
66
67
  triggerRef: anchorRef || controlRef
@@ -88,6 +89,13 @@ const Popover = forwardRef(
88
89
  },
89
90
  slotProps?.dialog
90
91
  );
92
+ const backdropProps = mergeProps(
93
+ {
94
+ className: s.underlay
95
+ },
96
+ slotProps?.backdrop,
97
+ underlayProps
98
+ );
91
99
  return /* @__PURE__ */ jsxs(Fragment, { children: [
92
100
  control?.({
93
101
  onClick: onPress,
@@ -111,7 +119,7 @@ const Popover = forwardRef(
111
119
  portalContainer,
112
120
  disableFocusManagement,
113
121
  children: [
114
- /* @__PURE__ */ jsx("div", { ...underlayProps, className: s.underlay }),
122
+ /* @__PURE__ */ jsx("div", { ...backdropProps }),
115
123
  /* @__PURE__ */ jsxs(
116
124
  "div",
117
125
  {
@@ -57,7 +57,7 @@ export type PopoverProps = {
57
57
  * */
58
58
  placement?: PopoverPropPlacement;
59
59
  /** The ref for the element which the popover positions itself with respect to. */
60
- anchorRef?: RefObject<HTMLElement>;
60
+ anchorRef?: RefObject<HTMLElement | null>;
61
61
  /**
62
62
  * If `true`, the arrow isn't shown.
63
63
  * @default false
@@ -77,6 +77,12 @@ export type PopoverProps = {
77
77
  * @default 0
78
78
  */
79
79
  arrowBoundaryOffset?: number;
80
+ /**
81
+ * The placement padding that should be applied between the element and its
82
+ * surrounding container.
83
+ * @default 12
84
+ */
85
+ containerPadding?: number;
80
86
  /**
81
87
  * The additional offset applied along the main axis between the element and its
82
88
  * anchor element.
@@ -93,5 +99,6 @@ export type PopoverProps = {
93
99
  slotProps?: {
94
100
  dialog?: DialogProps;
95
101
  arrow?: ComponentPropsWithRef<'div'>;
102
+ backdrop?: ComponentPropsWithRef<'div'>;
96
103
  };
97
104
  };
@@ -3,8 +3,9 @@ import type { Breakpoints } from './types';
3
3
  export type BreakpointsProviderProps = {
4
4
  children: ReactNode;
5
5
  breakpoints: Breakpoints;
6
+ defaultMatches?: boolean[];
6
7
  };
7
8
  export declare const BreakpointsProvider: {
8
- ({ children, breakpoints: _breakpoints, }: BreakpointsProviderProps): import("react/jsx-runtime").JSX.Element;
9
+ ({ children, defaultMatches, breakpoints: _breakpoints, }: BreakpointsProviderProps): import("react/jsx-runtime").JSX.Element;
9
10
  displayName: string;
10
11
  };
@@ -4,9 +4,16 @@ import { BreakpointsContext } from "./BreakpointsContext.js";
4
4
  import { useBreakpoints } from "./utils/useBreakpoints.js";
5
5
  const BreakpointsProvider = ({
6
6
  children,
7
+ defaultMatches,
7
8
  breakpoints: _breakpoints
8
9
  }) => {
9
- const breakpoints = useBreakpoints(_breakpoints);
10
+ const breakpoints = useBreakpoints(
11
+ _breakpoints,
12
+ defaultMatches && {
13
+ ssr: true,
14
+ defaultMatches
15
+ }
16
+ );
10
17
  return /* @__PURE__ */ jsx(BreakpointsContext.Provider, { value: breakpoints, children });
11
18
  };
12
19
  BreakpointsProvider.displayName = "BreakpointsProvider";
@@ -1,6 +1,6 @@
1
1
  import type { Breakpoints, ProviderProps } from './types';
2
2
  export declare const defaultBreakpoints: Breakpoints;
3
3
  export declare const Provider: {
4
- ({ breakpoints, children, locale, }: ProviderProps): import("react/jsx-runtime").JSX.Element;
4
+ ({ breakpoints, breakpointsFallback, children, locale, }: ProviderProps): import("react/jsx-runtime").JSX.Element;
5
5
  displayName: string;
6
6
  };
@@ -19,9 +19,17 @@ const defaultBreakpoints = {
19
19
  };
20
20
  const Provider = ({
21
21
  breakpoints = defaultBreakpoints,
22
+ breakpointsFallback,
22
23
  children,
23
24
  locale
24
- }) => /* @__PURE__ */ jsx(ProviderContext.Provider, { value: { breakpoints, locale }, children: /* @__PURE__ */ jsx(I18nProvider, { locale, children: /* @__PURE__ */ jsx(BreakpointsProvider, { breakpoints, children }) }) });
25
+ }) => /* @__PURE__ */ jsx(ProviderContext.Provider, { value: { breakpoints, locale }, children: /* @__PURE__ */ jsx(I18nProvider, { locale, children: /* @__PURE__ */ jsx(
26
+ BreakpointsProvider,
27
+ {
28
+ breakpoints,
29
+ defaultMatches: breakpointsFallback,
30
+ children
31
+ }
32
+ ) }) });
25
33
  Provider.displayName = "Provider";
26
34
  export {
27
35
  Provider,
@@ -10,7 +10,12 @@ export type Breakpoints = {
10
10
  [custom: string]: number | undefined;
11
11
  };
12
12
  export type ProviderProps = {
13
+ /** The content of the component. */
13
14
  children?: ReactNode;
15
+ /** Responsive breakpoints for your application. */
14
16
  breakpoints?: Breakpoints;
17
+ /** SSR-fallback for responsive breakpoints for your application. */
18
+ breakpointsFallback?: boolean[];
19
+ /** The locale for your application as a [BCP 47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code. Defaults to the browser/OS language setting. */
15
20
  locale?: I18nProviderProps['locale'];
16
21
  };
@@ -1,2 +1,3 @@
1
+ import type { UseMediaQueryOptions } from '@koobiq/react-core';
1
2
  import type { Breakpoints } from '../types';
2
- export declare function useBreakpoints(breakpoints: Breakpoints): {};
3
+ export declare function useBreakpoints(breakpoints: Breakpoints, options?: UseMediaQueryOptions): {};
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import { useMediaQuery } from "@koobiq/react-core";
3
- function useBreakpoints(breakpoints) {
3
+ function useBreakpoints(breakpoints, options) {
4
4
  const queries = Object.values(breakpoints).map(
5
5
  (width) => `(min-width: ${width}px)`
6
6
  );
7
- const matches = useMediaQuery(queries);
7
+ const matches = useMediaQuery(queries, options);
8
8
  return Object.keys(breakpoints).reduce(
9
9
  (acc, item, index) => ({ ...acc, [item]: matches[index] }),
10
10
  {}
@@ -7,7 +7,7 @@ export declare const Tooltip: import("react").ForwardRefExoticComponent<{
7
7
  children?: import("react").ReactNode;
8
8
  control?: import("./types").TooltipPropControl;
9
9
  placement?: import("./types").TooltipPropPlacement;
10
- anchorRef?: import("react").RefObject<HTMLElement>;
10
+ anchorRef?: import("react").RefObject<HTMLElement | null>;
11
11
  arrowBoundaryOffset?: number;
12
12
  offset?: number;
13
13
  crossOffset?: number;
@@ -34,7 +34,7 @@ export type TooltipProps = {
34
34
  * */
35
35
  placement?: TooltipPropPlacement;
36
36
  /** The ref for the element which the popover positions itself with respect to. */
37
- anchorRef?: RefObject<HTMLElement>;
37
+ anchorRef?: RefObject<HTMLElement | null>;
38
38
  /**
39
39
  * The minimum distance the arrow's edge should be from the edge of the overlay element.
40
40
  * @default 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koobiq/react-components",
3
- "version": "0.0.1-beta.5",
3
+ "version": "0.0.1-beta.6",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -22,10 +22,10 @@
22
22
  "@koobiq/design-tokens": "^3.12.1",
23
23
  "@types/react-transition-group": "^4.4.12",
24
24
  "react-transition-group": "^4.4.5",
25
- "@koobiq/react-core": "0.0.1-beta.5",
26
- "@koobiq/react-icons": "0.0.1-beta.5",
27
- "@koobiq/logger": "0.0.1-beta.5",
28
- "@koobiq/react-primitives": "0.0.1-beta.5"
25
+ "@koobiq/logger": "0.0.1-beta.6",
26
+ "@koobiq/react-icons": "0.0.1-beta.6",
27
+ "@koobiq/react-primitives": "0.0.1-beta.6",
28
+ "@koobiq/react-core": "0.0.1-beta.6"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@koobiq/design-tokens": "^3.11.2",