@jobber/components 9.15.5 → 9.16.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.
@@ -27,6 +27,11 @@ interface SideDrawerProps extends PropsWithChildren {
27
27
  * @default false
28
28
  */
29
29
  readonly inline?: boolean;
30
+ /**
31
+ * Element where the SideDrawer portal should be rendered.
32
+ * @default document.body
33
+ */
34
+ readonly container?: HTMLElement | null;
30
35
  /**
31
36
  * **Use at your own risk:** Custom class names for specific elements. This should only be used as a
32
37
  * **last resort**. Using this may result in unexpected side effects.
@@ -44,7 +49,7 @@ interface SideDrawerProps extends PropsWithChildren {
44
49
  container?: CSSProperties;
45
50
  };
46
51
  }
47
- export declare function SideDrawer({ children, onRequestClose, open, variation, scrollDirection, inline, UNSAFE_className, UNSAFE_style, }: SideDrawerProps): React.JSX.Element | null;
52
+ export declare function SideDrawer({ children, onRequestClose, open, variation, scrollDirection, inline, container, UNSAFE_className, UNSAFE_style, }: SideDrawerProps): React.JSX.Element | null;
48
53
  export declare namespace SideDrawer {
49
54
  var Title: typeof SideDrawerTitle;
50
55
  var Toolbar: typeof SideDrawerToolbar;
@@ -115,14 +115,15 @@ const useSideDrawerState = (open) => {
115
115
  noFooterShadow,
116
116
  };
117
117
  };
118
- function SideDrawer({ children, onRequestClose, open, variation = "base", scrollDirection, inline = false, UNSAFE_className, UNSAFE_style, }) {
118
+ function SideDrawer({ children, onRequestClose, open, variation = "base", scrollDirection, inline = false, container, UNSAFE_className, UNSAFE_style, }) {
119
119
  var _a;
120
120
  const { ref, setRef, components, setComponents, slots, sideDrawerRef, headerShadowRef, noHeaderShadow, footerShadowRef, noFooterShadow, } = useSideDrawerState(open);
121
121
  const { t } = useAtlantisI18n.useAtlantisI18n(sideDrawerMessages);
122
122
  jobberHooks.useRefocusOnActivator(open);
123
- const container = ((_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.body) || null;
123
+ const body = ((_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.body) || null;
124
+ const portalContainer = container || body;
124
125
  const isMounted = jobberHooks.useIsMounted();
125
- if (!isMounted.current && !container)
126
+ if (!isMounted.current && !portalContainer)
126
127
  return null;
127
128
  const SideDrawerRender = (React.createElement(SideDrawerContext.Provider, { value: {
128
129
  actionPortal: ref === null || ref === void 0 ? void 0 : ref.querySelector(slots.actions.selector),
@@ -167,7 +168,7 @@ function SideDrawer({ children, onRequestClose, open, variation = "base", scroll
167
168
  if (inline) {
168
169
  return SideDrawerRender;
169
170
  }
170
- return ReactDOM.createPortal(SideDrawerRender, container);
171
+ return ReactDOM.createPortal(SideDrawerRender, portalContainer);
171
172
  function handleKeyDown(event) {
172
173
  if (event.key === "Escape") {
173
174
  event.stopPropagation();
@@ -113,14 +113,15 @@ const useSideDrawerState = (open) => {
113
113
  noFooterShadow,
114
114
  };
115
115
  };
116
- function SideDrawer({ children, onRequestClose, open, variation = "base", scrollDirection, inline = false, UNSAFE_className, UNSAFE_style, }) {
116
+ function SideDrawer({ children, onRequestClose, open, variation = "base", scrollDirection, inline = false, container, UNSAFE_className, UNSAFE_style, }) {
117
117
  var _a;
118
118
  const { ref, setRef, components, setComponents, slots, sideDrawerRef, headerShadowRef, noHeaderShadow, footerShadowRef, noFooterShadow, } = useSideDrawerState(open);
119
119
  const { t } = useAtlantisI18n(sideDrawerMessages);
120
120
  useRefocusOnActivator(open);
121
- const container = ((_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.body) || null;
121
+ const body = ((_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.body) || null;
122
+ const portalContainer = container || body;
122
123
  const isMounted = useIsMounted();
123
- if (!isMounted.current && !container)
124
+ if (!isMounted.current && !portalContainer)
124
125
  return null;
125
126
  const SideDrawerRender = (React__default.createElement(SideDrawerContext.Provider, { value: {
126
127
  actionPortal: ref === null || ref === void 0 ? void 0 : ref.querySelector(slots.actions.selector),
@@ -165,7 +166,7 @@ function SideDrawer({ children, onRequestClose, open, variation = "base", scroll
165
166
  if (inline) {
166
167
  return SideDrawerRender;
167
168
  }
168
- return createPortal(SideDrawerRender, container);
169
+ return createPortal(SideDrawerRender, portalContainer);
169
170
  function handleKeyDown(event) {
170
171
  if (event.key === "Escape") {
171
172
  event.stopPropagation();
@@ -166,6 +166,7 @@ SideSheet content.
166
166
  |------|------|----------|---------|-------------|
167
167
  | `onRequestClose` | `() => void` | Yes | — | Callback function to close the drawer. |
168
168
  | `open` | `boolean` | Yes | — | Whether or not the drawer is open. |
169
+ | `container` | `HTMLElement` | No | `document.body` | Element where the SideDrawer portal should be rendered. |
169
170
  | `inline` | `boolean` | No | `false` | Changes whether the SideDrawer is positioned to the side of the viewport or inline with the content. |
170
171
  | `scrollDirection` | `"normal" | "reverse"` | No | — | Change the scrolling direction of the drawer. Useful for chat-like interfaces. |
171
172
  | `UNSAFE_className` | `{ container?: string; }` | No | — | **Use at your own risk:** Custom class names for specific elements. This should only be used as a **last resort**. Us... |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "9.15.5",
3
+ "version": "9.16.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -548,5 +548,5 @@
548
548
  "> 1%",
549
549
  "IE 10"
550
550
  ],
551
- "gitHead": "a9ac41dfb966649048fcaf7cce2db45f2569fc29"
551
+ "gitHead": "a4505ca7fe0a7ffe781409655a63fe9b8ea852ec"
552
552
  }