@homefile/components-v2 2.36.13 → 2.36.14

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.
@@ -5,17 +5,15 @@ import { DrawerHeader, DrawerBody, Stack, Text, DrawerFooter, } from '@chakra-ui
5
5
  import { IA } from '../../../assets/images';
6
6
  import { ApplianceSteps, SimpleDynamicForm, FooterButtons, HomeAssistantPanelStep, PanelHeader, Loading, HomeAssistantWizardSteps, DynamicForm, } from '../../../components';
7
7
  import { homeAssistantSteps } from '../../../helpers';
8
- import { dynamicFormProxy, homeAssistantProxy } from '../../../proxies';
9
- import { useSnapshot } from 'valtio';
8
+ import { homeAssistantProxy } from '../../../proxies';
9
+ import { getMutableFields } from '../../../utils';
10
10
  export const HomeAssistantPanel = ({ children, currentForm, currentStep, onApplianceClick = () => { }, onBack, onClose, onNext, onSave, backDisabled, nextDisabled, hasCompleted, isLoading, }) => {
11
11
  var _a, _b;
12
- const { fields } = useSnapshot(dynamicFormProxy);
13
12
  const [addedAppliances, updateAddedAppliances] = useState([]);
14
13
  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
14
  const text = `${t('homeAssistant.details')} ${title.toLowerCase()}:`;
16
15
  const isAppliances = currentStep === 4;
17
16
  const { setHighlight } = homeAssistantProxy;
18
- const fieldsCopy = [...fields];
19
17
  useEffect(() => {
20
18
  var _a;
21
19
  setHighlight(true);
@@ -47,7 +45,7 @@ export const HomeAssistantPanel = ({ children, currentForm, currentStep, onAppli
47
45
  label: !hasCompleted && currentStep === 6
48
46
  ? t('buttons.finish')
49
47
  : t('buttons.saveStep'),
50
- onClick: () => onSave === null || onSave === void 0 ? void 0 : onSave(fieldsCopy),
48
+ onClick: () => onSave === null || onSave === void 0 ? void 0 : onSave(getMutableFields()),
51
49
  }, button3: !hasCompleted && currentStep === 6
52
50
  ? undefined
53
51
  : {
@@ -5,4 +5,5 @@ interface MapApiObjectToFormFieldsI {
5
5
  labelPrefix?: string;
6
6
  }
7
7
  export declare const mapApiObjectToFormFields: ({ obj, depth, labelPrefix, }?: MapApiObjectToFormFieldsI) => ReportI[];
8
+ export declare function getMutableFields(): ReportI[];
8
9
  export {};
@@ -1,4 +1,6 @@
1
+ import { dynamicFormProxy } from '../proxies';
1
2
  import { v4 as uuidv4 } from 'uuid';
3
+ import { snapshot } from 'valtio';
2
4
  const MAX_DEPTH = 10;
3
5
  const FIELDS_TO_IGNORE = ['_id', '__v', 'createdAt', 'updatedAt'];
4
6
  const NESTED_RECURSION_DEPTH = 1;
@@ -100,7 +102,7 @@ value, visible = true) => {
100
102
  value,
101
103
  type: 'collapsible',
102
104
  visible,
103
- children: [childObj]
105
+ children: [childObj],
104
106
  };
105
107
  };
106
108
  const renderObjectArray = (arr) => arr
@@ -142,3 +144,8 @@ const flattenObject = (obj, parentKey = '') => Object.entries(obj).reduce((acc,
142
144
  }
143
145
  return acc;
144
146
  }, {});
147
+ export function getMutableFields() {
148
+ const snap = snapshot(dynamicFormProxy);
149
+ const cloned = structuredClone(snap.fields).map((field) => (Object.assign({}, field)));
150
+ return cloned;
151
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.36.13",
3
+ "version": "2.36.14",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",