@homefile/components-v2 2.36.11 → 2.36.13

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,20 +1,21 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from 'react';
3
- import { FormProvider } from 'react-hook-form';
4
3
  import { t } from 'i18next';
5
4
  import { DrawerHeader, DrawerBody, Stack, Text, DrawerFooter, } from '@chakra-ui/react';
6
5
  import { IA } from '../../../assets/images';
7
6
  import { ApplianceSteps, SimpleDynamicForm, FooterButtons, HomeAssistantPanelStep, PanelHeader, Loading, HomeAssistantWizardSteps, DynamicForm, } from '../../../components';
8
7
  import { homeAssistantSteps } from '../../../helpers';
9
- import { useSimpleDynamicForm } from '../../../hooks';
10
- import { homeAssistantProxy } from '../../../proxies';
8
+ import { dynamicFormProxy, homeAssistantProxy } from '../../../proxies';
9
+ import { useSnapshot } from 'valtio';
11
10
  export const HomeAssistantPanel = ({ children, currentForm, currentStep, onApplianceClick = () => { }, onBack, onClose, onNext, onSave, backDisabled, nextDisabled, hasCompleted, isLoading, }) => {
12
11
  var _a, _b;
12
+ const { fields } = useSnapshot(dynamicFormProxy);
13
13
  const [addedAppliances, updateAddedAppliances] = useState([]);
14
14
  const title = (_b = (_a = homeAssistantSteps === null || homeAssistantSteps === void 0 ? void 0 : homeAssistantSteps[currentStep - 1]) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : '';
15
15
  const text = `${t('homeAssistant.details')} ${title.toLowerCase()}:`;
16
16
  const isAppliances = currentStep === 4;
17
17
  const { setHighlight } = homeAssistantProxy;
18
+ const fieldsCopy = [...fields];
18
19
  useEffect(() => {
19
20
  var _a;
20
21
  setHighlight(true);
@@ -30,16 +31,13 @@ export const HomeAssistantPanel = ({ children, currentForm, currentStep, onAppli
30
31
  setHighlight(false);
31
32
  };
32
33
  }, [currentForm, isAppliances]);
33
- const { form, updatedFields } = useSimpleDynamicForm({
34
- fields: currentForm,
35
- });
36
34
  const handleClose = () => {
37
35
  onClose();
38
36
  setHighlight(false);
39
37
  };
40
38
  if (isLoading)
41
39
  return _jsx(Loading, {});
42
- return (_jsxs(_Fragment, { children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: handleClose, title: t('homeAssistant.title'), icon: IA }) }), _jsxs(DrawerBody, { p: "0", children: [_jsx(HomeAssistantPanelStep, { currentStep: currentStep }), children, isAppliances && (_jsx(ApplianceSteps, { onClick: onApplianceClick, addedAppliances: addedAppliances })), _jsxs(Stack, { spacing: "base", p: "base", children: [_jsx(Text, { fontFamily: "secondary", fontSize: "sm", children: text }), _jsx(FormProvider, Object.assign({}, form, { children: _jsx(SimpleDynamicForm, { fields: currentForm }) }))] })] }), _jsx(DrawerFooter, { px: "0", py: "6", bg: "neutral.white", children: _jsx(FooterButtons, { button1: {
40
+ return (_jsxs(_Fragment, { children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: handleClose, title: t('homeAssistant.title'), icon: IA }) }), _jsxs(DrawerBody, { p: "0", children: [_jsx(HomeAssistantPanelStep, { currentStep: currentStep }), children, isAppliances && (_jsx(ApplianceSteps, { onClick: onApplianceClick, addedAppliances: addedAppliances })), _jsxs(Stack, { spacing: "base", p: "base", children: [_jsx(Text, { fontFamily: "secondary", fontSize: "sm", children: text }), _jsx(SimpleDynamicForm, { fields: currentForm })] })] }), _jsx(DrawerFooter, { px: "0", py: "6", bg: "neutral.white", children: _jsx(FooterButtons, { button1: {
43
41
  buttonStyle: 'secondaryFooter',
44
42
  label: t('buttons.back'),
45
43
  onClick: onBack,
@@ -49,7 +47,7 @@ export const HomeAssistantPanel = ({ children, currentForm, currentStep, onAppli
49
47
  label: !hasCompleted && currentStep === 6
50
48
  ? t('buttons.finish')
51
49
  : t('buttons.saveStep'),
52
- onClick: () => onSave === null || onSave === void 0 ? void 0 : onSave(updatedFields),
50
+ onClick: () => onSave === null || onSave === void 0 ? void 0 : onSave(fieldsCopy),
53
51
  }, button3: !hasCompleted && currentStep === 6
54
52
  ? undefined
55
53
  : {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.36.11",
3
+ "version": "2.36.13",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",