@homefile/components-v2 2.8.31 → 2.8.33

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.
@@ -1,3 +1,3 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { ItemFormPanelI } from '../../../../interfaces';
3
- export declare const ItemFormPanel: ({ children, onClose, onSubmitForm, panelIcon, panelTitle, showOverlay, }: PropsWithChildren<ItemFormPanelI>) => import("react/jsx-runtime").JSX.Element | null;
3
+ export declare const ItemFormPanel: ({ children, onClose, onSubmitForm, panelIcon, panelTitle, showOverlay, }: PropsWithChildren<ItemFormPanelI>) => import("react/jsx-runtime").JSX.Element;
@@ -1,17 +1,19 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
2
3
  import { DrawerBody, DrawerHeader, DrawerContent, DrawerFooter, Box, } from '@chakra-ui/react';
3
- import { PanelHeader, FooterDrawer, ItemFormFooter, Overlay, } from '../../..';
4
+ import { PanelHeader, FooterDrawer, ItemFormFooter, Overlay, Loading } from '../../..';
4
5
  export const ItemFormPanel = ({ children, onClose, onSubmitForm, panelIcon, panelTitle, showOverlay = false, }) => {
5
- let firstChild = null;
6
- let otherChildren = children;
7
- if (Array.isArray(children) && children.length > 0) {
8
- const header = children[0];
9
- if (header.props && header.props.id === 'item-name-header') {
10
- firstChild = header;
11
- otherChildren = children.slice(1);
6
+ const { firstChild, otherChildren } = useMemo(() => {
7
+ let firstChild = null;
8
+ let otherChildren = children;
9
+ if (Array.isArray(children) && children.length > 0) {
10
+ const header = children[0];
11
+ if (header.props && header.props.id === 'item-name-header') {
12
+ firstChild = header;
13
+ otherChildren = children.slice(1);
14
+ }
12
15
  }
13
- }
14
- if (!firstChild)
15
- return null;
16
- return (_jsxs(DrawerContent, { bg: "lightBlue.1", children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: onClose, icon: panelIcon, title: panelTitle }) }), _jsxs(DrawerBody, { p: "0", overflowX: "hidden", bg: "lightBlue.1", children: [firstChild, _jsxs(Box, { position: "relative", mb: "200px", children: [_jsx(Overlay, { showOverlay: showOverlay, position: "absolute", w: "inherit", h: "inherit", zIndex: "9" }), otherChildren] })] }), _jsx(FooterDrawer, { isOpen: !showOverlay, children: _jsx(DrawerFooter, { w: "100%", py: "0", children: _jsx(ItemFormFooter, { onSave: onSubmitForm, onCancel: onClose }) }) })] }));
16
+ return { firstChild, otherChildren };
17
+ }, [children]);
18
+ return (_jsxs(DrawerContent, { bg: "lightBlue.1", children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: onClose, icon: panelIcon, title: panelTitle }) }), _jsx(DrawerBody, { p: "0", overflowX: "hidden", bg: "lightBlue.1", children: firstChild ? (_jsxs(_Fragment, { children: [firstChild, _jsxs(Box, { position: "relative", mb: "200px", children: [_jsx(Overlay, { showOverlay: showOverlay, position: "absolute", w: "inherit", h: "inherit", zIndex: "9" }), otherChildren] })] })) : (_jsx(Loading, {})) }), _jsx(FooterDrawer, { isOpen: !showOverlay, children: _jsx(DrawerFooter, { w: "100%", py: "0", children: _jsx(ItemFormFooter, { onSave: onSubmitForm, onCancel: onClose }) }) })] }));
17
19
  };
@@ -7,7 +7,7 @@ import { House } from '../../assets/images';
7
7
  export const RoomsMenu = ({ activeRoom, rooms, roomsToAdd, onClick, onHomeClick, onAddRoom, disabled, }) => {
8
8
  const { handleDragStart, handleDrop, newRooms } = useRoomList(rooms);
9
9
  const { isOpen, onOpen, onClose } = useDisclosure();
10
- return (_jsx(Show, { breakpoint: "(min-width: 600px)", children: _jsxs(Box, { bg: "neutral.white", minW: "fit-content", children: [_jsxs(Box, { w: "container.roomIcon", minW: "container.roomIcon", transition: "all 0.2s ease-in-out", bg: "lightBlue.4", children: [_jsx(Box, { overflow: "hidden", children: _jsx(Tooltip, { hasArrow: true, isDisabled: false, label: t('addRoom.addBtn'), placement: "right", children: _jsx(Box, { as: "button", w: "full", h: "container.masthead", onClick: onOpen, transition: "all 0.2s ease-in-out", bg: "blue.2", disabled: disabled, overflow: "hidden", _hover: { backgroundColor: 'blue.3' }, _disabled: {
10
+ return (_jsx(Show, { breakpoint: "(min-width: 600px)", children: _jsxs(Box, { bg: "neutral.white", minW: "fit-content", "data-testid": "rooms-menu", children: [_jsxs(Box, { w: "container.roomIcon", minW: "container.roomIcon", transition: "all 0.2s ease-in-out", bg: "lightBlue.4", children: [_jsx(Box, { overflow: "hidden", children: _jsx(Tooltip, { hasArrow: true, isDisabled: false, label: t('addRoom.addBtn'), placement: "right", children: _jsx(Box, { as: "button", w: "full", h: "container.masthead", onClick: onOpen, transition: "all 0.2s ease-in-out", bg: "blue.2", disabled: disabled, overflow: "hidden", _hover: { backgroundColor: 'blue.3' }, _disabled: {
11
11
  filter: 'grayscale(100%)',
12
12
  pointerEvents: 'none',
13
13
  }, children: _jsx(Center, { minW: "container.roomIcon", children: _jsx(Plus, {}) }) }) }) }), _jsx(Tooltip, { hasArrow: true, isDisabled: activeRoom === 'homeboard', label: t('rooms.homeboard'), placement: "right", children: _jsx(Box, { w: "full", as: "button", h: "3.2rem", bg: activeRoom === 'homeboard' ? 'lightGreen.3' : 'neutral.white', onClick: onHomeClick, children: _jsx(Center, { minW: "container.roomIcon", children: _jsx(Image, { src: House, alt: t('ariaLabels.returnHomeBoard'), w: "1.5rem", h: "auto" }) }) }) }), _jsx(Box, { children: newRooms.map((room, i) => {
@@ -8,7 +8,7 @@ import { House } from '../../assets/images';
8
8
  export const RoomsMenuMobile = ({ activeRoom, rooms, roomsToAdd, onClick, onHomeClick, onAddRoom, }) => {
9
9
  const { newRooms } = useRoomList(rooms);
10
10
  const { isOpen, onOpen, onClose } = useDisclosure();
11
- return (_jsx(Show, { breakpoint: "(max-width: 590px)", children: _jsxs(Box, { mt: "2", w: "full", position: "fixed", bottom: "0", shadow: "0 0 8px 1px #00000010", zIndex: "dropdown", overflow: "hidden", overflowX: "auto", css: {
11
+ return (_jsx(Show, { breakpoint: "(max-width: 590px)", children: _jsxs(Box, { "data-testid": "rooms-menu-mobile", mt: "2", w: "full", position: "fixed", bottom: "0", shadow: "0 0 8px 1px #00000010", zIndex: "dropdown", overflow: "hidden", overflowX: "auto", css: {
12
12
  '&::-webkit-scrollbar': {
13
13
  height: '0px',
14
14
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.8.31",
3
+ "version": "2.8.33",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren, ReactNode } from 'react'
1
+ import { PropsWithChildren, ReactNode, useMemo } from 'react'
2
2
  import {
3
3
  DrawerBody,
4
4
  DrawerHeader,
@@ -11,6 +11,7 @@ import {
11
11
  FooterDrawer,
12
12
  ItemFormFooter,
13
13
  Overlay,
14
+ Loading
14
15
  } from '@/components'
15
16
  import { ItemFormPanelI } from '@/interfaces'
16
17
 
@@ -22,18 +23,21 @@ export const ItemFormPanel = ({
22
23
  panelTitle,
23
24
  showOverlay = false,
24
25
  }: PropsWithChildren<ItemFormPanelI>) => {
25
- let firstChild: ReactNode | null = null
26
- let otherChildren: ReactNode = children
27
26
 
28
- if (Array.isArray(children) && children.length > 0) {
29
- const header = children[0]
30
- if (header.props && header.props.id === 'item-name-header') {
31
- firstChild = header
32
- otherChildren = children.slice(1)
33
- }
34
- }
27
+ const { firstChild, otherChildren } = useMemo(() => {
28
+ let firstChild: ReactNode | null = null
29
+ let otherChildren: ReactNode = children
35
30
 
36
- if (!firstChild) return null
31
+ if (Array.isArray(children) && children.length > 0) {
32
+ const header = children[0]
33
+ if (header.props && header.props.id === 'item-name-header') {
34
+ firstChild = header
35
+ otherChildren = children.slice(1)
36
+ }
37
+ }
38
+
39
+ return { firstChild, otherChildren }
40
+ }, [children])
37
41
 
38
42
  return (
39
43
  <DrawerContent bg="lightBlue.1">
@@ -46,17 +50,25 @@ export const ItemFormPanel = ({
46
50
  </DrawerHeader>
47
51
 
48
52
  <DrawerBody p="0" overflowX="hidden" bg="lightBlue.1">
49
- {firstChild}
50
- <Box position="relative" mb="200px">
51
- <Overlay
52
- showOverlay={showOverlay}
53
- position="absolute"
54
- w="inherit"
55
- h="inherit"
56
- zIndex="9"
57
- />
58
- {otherChildren}
59
- </Box>
53
+ {
54
+ firstChild ? (
55
+ <>
56
+ {firstChild}
57
+ <Box position="relative" mb="200px">
58
+ <Overlay
59
+ showOverlay={showOverlay}
60
+ position="absolute"
61
+ w="inherit"
62
+ h="inherit"
63
+ zIndex="9"
64
+ />
65
+ {otherChildren}
66
+ </Box>
67
+ </>
68
+ ) : (
69
+ <Loading />
70
+ )
71
+ }
60
72
  </DrawerBody>
61
73
  <FooterDrawer isOpen={!showOverlay}>
62
74
  <DrawerFooter w="100%" py="0">
@@ -26,7 +26,7 @@ export const RoomsMenu = ({
26
26
 
27
27
  return (
28
28
  <Show breakpoint="(min-width: 600px)">
29
- <Box bg="neutral.white" minW="fit-content">
29
+ <Box bg="neutral.white" minW="fit-content" data-testid="rooms-menu">
30
30
  <Box
31
31
  w="container.roomIcon"
32
32
  minW="container.roomIcon"
@@ -20,6 +20,7 @@ export const RoomsMenuMobile = ({
20
20
  return (
21
21
  <Show breakpoint="(max-width: 590px)">
22
22
  <Box
23
+ data-testid="rooms-menu-mobile"
23
24
  mt="2"
24
25
  w="full"
25
26
  position="fixed"