@m4l/components 0.1.9 → 0.1.11

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.
Files changed (35) hide show
  1. package/components/DataGrid/formatters/columnBooleanFormatter/index.d.ts +3 -0
  2. package/components/DataGrid/formatters/columnBooleanFormatter/types.d.ts +7 -0
  3. package/components/DataGrid/formatters/columnDateFormatter/index.d.ts +3 -0
  4. package/components/DataGrid/formatters/columnDateFormatter/types.d.ts +8 -0
  5. package/components/DataGrid/formatters/index.d.ts +2 -0
  6. package/components/DataGrid/index.js +3 -0
  7. package/components/DynamicFilter/index.js +5 -3
  8. package/components/ErrorLabel/index.d.ts +1 -0
  9. package/components/ErrorLabel/index.js +18 -0
  10. package/components/Icon/index.js +1 -1
  11. package/components/{hook-form/RHFPeriod → Period}/dictionary.d.ts +3 -0
  12. package/components/Period/index.d.ts +3 -0
  13. package/components/Period/index.js +230 -0
  14. package/components/Period/styles.d.ts +7 -0
  15. package/components/Period/types.d.ts +30 -0
  16. package/components/PropertyValue/index.js +0 -1
  17. package/components/formatters/BooleanFormatter/index.js +30 -11
  18. package/components/formatters/BooleanFormatter/types.d.ts +2 -2
  19. package/components/formatters/DateFormatter/index.js +20 -16
  20. package/components/formatters/DateFormatter/types.d.ts +2 -2
  21. package/components/formatters/index.js +8 -8
  22. package/components/hook-form/RHFPeriod/index.js +47 -0
  23. package/components/hook-form/RHFPeriod/styles.d.ts +0 -4
  24. package/components/hook-form/RHFPeriod/types.d.ts +1 -25
  25. package/components/hook-form/index.d.ts +1 -2
  26. package/components/index.d.ts +2 -0
  27. package/hooks/useFormAddEdit/index.js +42 -0
  28. package/index.js +11 -277
  29. package/package.json +1 -1
  30. package/react-draggable.js +3 -3
  31. package/react-json-view.js +2 -2
  32. package/react-lazy-load-image-component.js +2 -2
  33. package/react-resizable.js +3 -3
  34. package/react-splitter-layout.js +2 -2
  35. package/utils/index.js +2 -2
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { ColumnBooleanFormatterProps } from './types';
3
+ export declare function columnBooleanFormatter(props: ColumnBooleanFormatterProps): (obProps: any) => JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { ComponentType } from 'react';
2
+ import { PresentationType } from '../../../../components/formatters/BooleanFormatter/types';
3
+ export interface ColumnBooleanFormatterProps {
4
+ Component?: ComponentType;
5
+ presentationType: PresentationType;
6
+ fieldValue: string;
7
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { ColumnDateFormatterProps } from './types';
3
+ export declare function columnDateFormatter(props: ColumnDateFormatterProps): (obProps: any) => JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { ComponentType } from 'react';
2
+ import { PresentationType } from '../../../formatters/DateFormatter/types';
3
+ export interface ColumnDateFormatterProps {
4
+ Component?: ComponentType;
5
+ presentationType: PresentationType;
6
+ format?: string;
7
+ fieldValue: string;
8
+ }
@@ -1,4 +1,6 @@
1
1
  export { columnUncertaintyFormatter } from './columnUncertaintyFormatter';
2
2
  export { columnPointsFormatter } from './columnPointsFormatter';
3
3
  export { columnNestedValueFormatter } from './columnNestedValueFormatter';
4
+ export { columnBooleanFormatter } from './columnBooleanFormatter';
5
+ export { columnDateFormatter } from './columnDateFormatter';
4
6
  export type { ColumnUncertaintyFormatterProps } from './columnUncertaintyFormatter/types';
@@ -82,6 +82,9 @@ const OriginalDataGridWrapperStyled = styled("div")(({
82
82
  right: "0px",
83
83
  top: "25%",
84
84
  bottom: "25%"
85
+ },
86
+ "& .m4l_icon": {
87
+ height: "100%"
85
88
  }
86
89
  },
87
90
  "& .rdg-cell.rdg-cell-align-left": {
@@ -1,6 +1,6 @@
1
1
  import { S as ScrollBar } from "../ScrollBar/index.js";
2
2
  import { styled } from "@mui/material/styles";
3
- import require$$0, { useRef, useState, useMemo, useCallback, useEffect, createContext, useContext } from "react";
3
+ import React, { useRef, useState, useMemo, useCallback, useEffect, createContext, useContext } from "react";
4
4
  import { useModuleDictionary, useHostTools, useEnvironment, voidFunction, useFlagsPresent } from "@m4l/core";
5
5
  import * as Yup from "yup";
6
6
  import { useFormContext, useWatch } from "react-hook-form";
@@ -13,7 +13,9 @@ import "../hook-form/RHFCheckbox/index.js";
13
13
  import { R as RHFDateTime } from "../hook-form/RHFDateTime/index.js";
14
14
  import "@mui/x-date-pickers";
15
15
  import { R as RHFTextField } from "../hook-form/RHFTextField/index.js";
16
- import "../../index.js";
16
+ import "../hook-form/RHFPeriod/index.js";
17
+ import "../ErrorLabel/index.js";
18
+ import "../Period/index.js";
17
19
  import { I as Icon } from "../Icon/index.js";
18
20
  import { L as LabelMemuItem, b as Actions, g as getCommonActionsDictionary } from "../CommonActions/components/Actions/index.js";
19
21
  import "@mui/material/Button";
@@ -690,7 +692,7 @@ const strategiesEditFilterComponent = {
690
692
  number: NumberFilter,
691
693
  boolean: BooleanFilter,
692
694
  datetime: DateTimeFilter,
693
- __default__: require$$0.Fragment
695
+ __default__: React.Fragment
694
696
  };
695
697
  const PopupEditFilterComponent = (props) => {
696
698
  const {
@@ -1,3 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ErrorLabelProps } from './types';
3
3
  export declare const ErrorLabel: (props: ErrorLabelProps) => JSX.Element;
4
+ export default ErrorLabel;
@@ -0,0 +1,18 @@
1
+ import { styled } from "@mui/material";
2
+ import { jsx } from "react/jsx-runtime";
3
+ const Wrapper = styled("p")(({
4
+ theme
5
+ }) => ({
6
+ ...theme.typography.caption,
7
+ color: theme.palette.error.main,
8
+ margin: "8px 14px 0 14px"
9
+ }));
10
+ const ErrorLabel = (props) => {
11
+ const {
12
+ message
13
+ } = props;
14
+ return /* @__PURE__ */ jsx(Wrapper, {
15
+ children: message
16
+ });
17
+ };
18
+ export { ErrorLabel as E };
@@ -66,7 +66,7 @@ function Icon(props) {
66
66
  }, [src]);
67
67
  const placeHolder = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI2LjMuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkNhcGFfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiCgkgdmlld0JveD0iMCAwIDcwIDcwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA3MCA3MDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiM2MzczODE7fQo8L3N0eWxlPgo8Zz4KCTxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik00NSw4LjdjMS40LTEuNSwzLjQtMi4zLDUuNC0yLjNzMy45LDAuOCw1LjQsMi4zczIuNCwzLjUsMi41LDUuN2MwLDIuMi0wLjksNC4yLTIuNCw1LjdzLTMuNSwyLjMtNS41LDIuMgoJCWMtMi4xLDAuMS00LTAuNy01LjUtMi4yYy0xLjQtMS41LTIuMy0zLjUtMi40LTUuN0M0Mi42LDEyLjIsNDMuNSwxMC4yLDQ1LDguN3oiLz4KCTxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik02OC40LDYyLjFjLTAuMywwLjUtMC43LDAuOC0xLjIsMS4xcy0xLDAuNC0xLjYsMC40SDQuM2MtMC42LDAtMS4xLTAuMS0xLjYtMC40cy0wLjktMC42LTEuMi0xLjEKCQljLTAuMi0wLjUtMC40LTEtMC40LTEuNXMwLjEtMS4xLDAuNC0xLjVsMjMtMzYuNGMwLjMtMC41LDAuNy0wLjgsMS4yLTEuMXMxLTAuNCwxLjYtMC40czEuMSwwLjEsMS42LDAuNHMwLjksMC42LDEuMiwxLjEKCQlsMTEuNSwxOC4yYzAuMiwwLjMsMC41LDAuNSwwLjgsMC43czAuNiwwLjMsMSwwLjNjMC4zLDAsMC43LTAuMSwxLTAuM3MwLjYtMC40LDAuOC0wLjdsMy4xLTQuOWMwLjMtMC41LDAuNy0wLjgsMS4yLTEuMQoJCXMxLTAuNCwxLjYtMC40czEuMSwwLjEsMS42LDAuNGMwLjUsMC4zLDAuOSwwLjYsMS4yLDEuMWwxNC42LDIzLjFjMC4zLDAuNSwwLjMsMSwwLjMsMS41UzY4LjcsNjEuNyw2OC40LDYyLjF6Ii8+CjwvZz4KPC9zdmc+Cg==";
68
68
  return /* @__PURE__ */ jsx(WrapperPlaceHolder, {
69
- id: "IconReact",
69
+ className: "m4l_icon",
70
70
  children: resource ? /* @__PURE__ */ jsx(DivIcon, {
71
71
  src: resource,
72
72
  size: finalSize,
@@ -1,3 +1,6 @@
1
1
  import { Dictionary } from '@m4l/core';
2
2
  export declare function getPeriodComponetsDictionary(): string[];
3
3
  export declare const defaultPeriodDictionary: Dictionary;
4
+ export declare const LABEL_YEARS = "label_years";
5
+ export declare const LABEL_MONTHS = "label_months";
6
+ export declare const LABEL_DAYS = "label_days";
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { PeriodProps } from './types';
3
+ export declare const Period: (props: PeriodProps) => JSX.Element;
@@ -0,0 +1,230 @@
1
+ import { useModuleDictionary, useModuleSkeleton, useEnvironment } from "@m4l/core";
2
+ import { styled, Skeleton, Autocomplete, TextField } from "@mui/material";
3
+ import { useMemo } from "react";
4
+ import { I as Icon } from "../Icon/index.js";
5
+ import { jsxs, jsx } from "react/jsx-runtime";
6
+ import { g as getCommonActionsDictionary } from "../CommonActions/components/Actions/index.js";
7
+ import "@mui/material/Button";
8
+ import "../mui_extended/Button/index.js";
9
+ import "react-hook-form";
10
+ import "react-router-dom";
11
+ import "../../contexts/ModalContext/index.js";
12
+ import "@mui/lab";
13
+ const ContainerPeriod = styled("div")(({
14
+ theme,
15
+ error
16
+ }) => ({
17
+ display: "flex",
18
+ width: "100%",
19
+ height: "auto",
20
+ alignItems: "center",
21
+ gap: theme.spacing(1),
22
+ border: error ? `1px solid ${theme.palette.error.main}` : `1px solid ${theme.palette.divider}`,
23
+ padding: theme.spacing(0.5, 1),
24
+ borderRadius: "4px",
25
+ "& .MuiAutocomplete-root, & .MuiTextField-root": {
26
+ width: "100%"
27
+ },
28
+ "& .MuiAutocomplete-root .MuiTextField-root": {
29
+ width: "100%"
30
+ },
31
+ "& .MuiTextField-root .MuiInput-input": {
32
+ padding: "5px!important"
33
+ }
34
+ }));
35
+ const Gap = styled("div")(({
36
+ theme
37
+ }) => ({
38
+ width: "1px",
39
+ height: "20px",
40
+ backgroundColor: theme.palette.divider
41
+ }));
42
+ const SKTWrapper = styled("div")(({
43
+ theme
44
+ }) => ({
45
+ display: "flex",
46
+ width: "auto",
47
+ height: "37.5px",
48
+ alignItems: "center",
49
+ gap: theme.spacing(1),
50
+ border: `1px solid ${theme.palette.divider}`,
51
+ padding: theme.spacing(0.5, 1),
52
+ borderRadius: "4px"
53
+ }));
54
+ const FieldPeriod = styled("div")(({
55
+ theme
56
+ }) => ({
57
+ ...theme.typography.body2,
58
+ width: "100%",
59
+ display: "flex",
60
+ textOverflow: "elipsis",
61
+ overflow: "hidden",
62
+ padding: "5px",
63
+ textAlign: "left"
64
+ }));
65
+ const FieldValue = styled("div")(({
66
+ theme
67
+ }) => ({
68
+ ...theme.typography.body2,
69
+ width: "70px",
70
+ display: "flex",
71
+ textOverflow: "elipsis",
72
+ overflow: "hidden",
73
+ padding: "5px",
74
+ textAlign: "left"
75
+ }));
76
+ var ETimePeriods = /* @__PURE__ */ ((ETimePeriods2) => {
77
+ ETimePeriods2[ETimePeriods2["YEARS"] = 0] = "YEARS";
78
+ ETimePeriods2[ETimePeriods2["MONTHS"] = 1] = "MONTHS";
79
+ ETimePeriods2[ETimePeriods2["DAYS"] = 2] = "DAYS";
80
+ return ETimePeriods2;
81
+ })(ETimePeriods || {});
82
+ const getSelPeriodTime = (period) => {
83
+ if (!period)
84
+ return ETimePeriods.YEARS;
85
+ if (period.selPeriodTime)
86
+ return period.selPeriodTime;
87
+ if (period.years && period.years > 0)
88
+ return ETimePeriods.YEARS;
89
+ if (period.months && period.months > 0)
90
+ return ETimePeriods.MONTHS;
91
+ if (period.days && period.days > 0)
92
+ return ETimePeriods.DAYS;
93
+ return ETimePeriods.YEARS;
94
+ };
95
+ const getSingleValue = (period) => {
96
+ if (!period)
97
+ return "";
98
+ if (period.singleValue !== void 0)
99
+ return period.singleValue;
100
+ if (period.years && period.years > 0)
101
+ return period.years;
102
+ if (period.months && period.months > 0)
103
+ return period.months;
104
+ if (period.days && period.days > 0)
105
+ return period.days;
106
+ return "";
107
+ };
108
+ const Period = (props) => {
109
+ const {
110
+ value,
111
+ onChange,
112
+ error = false,
113
+ readOnly = false
114
+ } = props;
115
+ const {
116
+ getLabel
117
+ } = useModuleDictionary();
118
+ const isSkeleton = useModuleSkeleton();
119
+ const selPeriodTime = getSelPeriodTime(value);
120
+ const singleValue = getSingleValue(value);
121
+ const onTotalChange = (newPeriodTime, newValue) => {
122
+ const newPeriod = {
123
+ selPeriodTime: newPeriodTime,
124
+ singleValue: newValue
125
+ };
126
+ if (newValue !== "" && newValue > 0) {
127
+ newPeriod.years = 0;
128
+ newPeriod.months = 0;
129
+ newPeriod.days = 0;
130
+ if (newPeriodTime === ETimePeriods.YEARS)
131
+ newPeriod.years = newValue;
132
+ if (newPeriodTime === ETimePeriods.MONTHS)
133
+ newPeriod.months = newValue;
134
+ if (newPeriodTime === ETimePeriods.DAYS)
135
+ newPeriod.days = newValue;
136
+ }
137
+ onChange(newPeriod);
138
+ };
139
+ const onChangeTime = (newPeriodTime) => {
140
+ if (newPeriodTime) {
141
+ onTotalChange(newPeriodTime.id, singleValue);
142
+ }
143
+ };
144
+ const {
145
+ host_static_assets,
146
+ environment_assets
147
+ } = useEnvironment();
148
+ const options = useMemo(() => [{
149
+ id: 0,
150
+ label: getLabel("period.years")
151
+ }, {
152
+ id: 1,
153
+ label: getLabel("period.months")
154
+ }, {
155
+ id: 2,
156
+ label: getLabel("period.days")
157
+ }], [getLabel]);
158
+ if (isSkeleton) {
159
+ return /* @__PURE__ */ jsxs(SKTWrapper, {
160
+ children: [/* @__PURE__ */ jsx(Skeleton, {
161
+ variant: "rounded",
162
+ width: "100%"
163
+ }), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(Skeleton, {
164
+ variant: "rounded",
165
+ width: "100%"
166
+ }), /* @__PURE__ */ jsx(Skeleton, {
167
+ variant: "circular",
168
+ width: 20,
169
+ sx: {
170
+ minWidth: "20px",
171
+ minHeight: "20px"
172
+ }
173
+ })]
174
+ });
175
+ }
176
+ if (readOnly) {
177
+ /* @__PURE__ */ jsxs(ContainerPeriod, {
178
+ error: false,
179
+ children: [/* @__PURE__ */ jsx(FieldPeriod, {
180
+ children: value.selPeriodTime
181
+ }), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(FieldValue, {
182
+ children: value.singleValue
183
+ }), /* @__PURE__ */ jsx(Icon, {
184
+ src: `${host_static_assets}/${environment_assets}/frontend/components/period/assets/icons/clock.svg`
185
+ })]
186
+ });
187
+ }
188
+ return /* @__PURE__ */ jsxs(ContainerPeriod, {
189
+ error,
190
+ children: [/* @__PURE__ */ jsx(Autocomplete, {
191
+ options,
192
+ value: options[selPeriodTime],
193
+ disableClearable: true,
194
+ onChange: (_event, autcValue) => {
195
+ onChangeTime(autcValue);
196
+ },
197
+ renderInput: (params) => {
198
+ return /* @__PURE__ */ jsx(TextField, {
199
+ ...params,
200
+ fullWidth: true,
201
+ variant: "standard",
202
+ SelectProps: {
203
+ native: true
204
+ },
205
+ InputProps: {
206
+ disableUnderline: true,
207
+ ...params.InputProps
208
+ },
209
+ autoComplete: "off"
210
+ }, `tx_async_${params.id}`);
211
+ }
212
+ }), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(TextField, {
213
+ type: "number",
214
+ variant: "standard",
215
+ value: singleValue,
216
+ InputProps: {
217
+ disableUnderline: true
218
+ },
219
+ onChange: (e) => {
220
+ onTotalChange(selPeriodTime, e.target.value === "" ? "" : parseInt(e.target.value));
221
+ }
222
+ }), /* @__PURE__ */ jsx(Icon, {
223
+ src: `${host_static_assets}/${environment_assets}/frontend/components/period/assets/icons/clock.svg`
224
+ })]
225
+ });
226
+ };
227
+ function getPeriodComponetsDictionary() {
228
+ return ["period"].concat(getCommonActionsDictionary());
229
+ }
230
+ export { Period as P, getPeriodComponetsDictionary as g };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { WrapperProps } from './types';
3
+ export declare const ContainerPeriod: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & WrapperProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
4
+ export declare const Gap: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
5
+ export declare const SKTWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
+ export declare const FieldPeriod: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
7
+ export declare const FieldValue: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,30 @@
1
+ export declare enum ETimePeriods {
2
+ YEARS = 0,
3
+ MONTHS = 1,
4
+ DAYS = 2
5
+ }
6
+ export declare type PeriodVariant = 'monoperiod' | 'multiperiod';
7
+ export declare type PeriodTime = {
8
+ id: number;
9
+ label: string;
10
+ };
11
+ export interface WrapperProps {
12
+ error: boolean;
13
+ }
14
+ export declare type PeriodType = {
15
+ selPeriodTime: ETimePeriods;
16
+ singleValue: number | '';
17
+ years?: number;
18
+ months?: number;
19
+ days?: number;
20
+ };
21
+ export interface PeriodProps {
22
+ value: PeriodType;
23
+ onChange: (newValue: PeriodType) => void;
24
+ error?: boolean;
25
+ readOnly?: boolean;
26
+ variant?: PeriodVariant;
27
+ }
28
+ export interface WrapperProps {
29
+ error: boolean;
30
+ }
@@ -70,7 +70,6 @@ const Value = styled("div", {
70
70
  height: valueHeight,
71
71
  marginTop: theme.spacing(1),
72
72
  [theme.breakpoints.up("sm")]: {
73
- marginLeft: theme.spacing(0),
74
73
  marginTop: "0px"
75
74
  },
76
75
  overflow: "hidden",
@@ -1,17 +1,23 @@
1
- import require$$0 from "react";
2
- import { useModuleDictionary } from "@m4l/core";
3
- import { Checkbox } from "@mui/material";
1
+ import { useModuleDictionary, useEnvironment, getPropertyByString } from "@m4l/core";
2
+ import React from "react";
3
+ import { I as Icon } from "../../Icon/index.js";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  function BooleanFormatter(props) {
6
6
  const {
7
7
  presentationType,
8
8
  value,
9
- Component = require$$0.Fragment
9
+ Component = React.Fragment
10
10
  } = props;
11
11
  const {
12
12
  getLabel
13
13
  } = useModuleDictionary();
14
+ const {
15
+ host_static_assets,
16
+ environment_assets
17
+ } = useEnvironment();
14
18
  const final_value = value ?? false;
19
+ const srcCheckTrue = `${host_static_assets}/${environment_assets}/frontend/components/data_grid/components/boolean_formatter/assets/icons/check_true.svg`;
20
+ const srcCheckFalse = `${host_static_assets}/${environment_assets}/frontend/components/data_grid/components/boolean_formatter/assets/icons/check_false.svg`;
15
21
  if (presentationType === "string_yes_no") {
16
22
  return /* @__PURE__ */ jsx(Component, {
17
23
  children: final_value ? getLabel("formatters.boolean_yes") : getLabel("formatters.boolean_no")
@@ -22,12 +28,25 @@ function BooleanFormatter(props) {
22
28
  children: final_value ? getLabel("formatters.boolean_true") : getLabel("formatters.boolean_false")
23
29
  });
24
30
  }
25
- return /* @__PURE__ */ jsx(Checkbox, {
26
- checked: final_value,
27
- size: "small",
28
- readOnly: true,
29
- disableFocusRipple: true,
30
- disableRipple: true
31
+ return /* @__PURE__ */ jsx(Component, {
32
+ children: /* @__PURE__ */ jsx(Icon, {
33
+ src: final_value ? srcCheckTrue : srcCheckFalse,
34
+ bgColor: "action.disabled"
35
+ })
31
36
  });
32
37
  }
33
- export { BooleanFormatter as B };
38
+ function columnBooleanFormatter(props) {
39
+ const {
40
+ fieldValue,
41
+ presentationType,
42
+ Component = React.Fragment
43
+ } = props;
44
+ return (obProps) => {
45
+ return /* @__PURE__ */ jsx(BooleanFormatter, {
46
+ presentationType,
47
+ value: getPropertyByString(obProps, fieldValue),
48
+ Component
49
+ });
50
+ };
51
+ }
52
+ export { BooleanFormatter as B, columnBooleanFormatter as c };
@@ -1,7 +1,7 @@
1
- import { ComponentForrmaterType } from '../types';
1
+ import { ComponentType } from 'react';
2
2
  export declare type PresentationType = 'string_yes_no' | 'string_true_false' | 'check';
3
3
  export interface BooleanFormatterProps {
4
- Component?: ComponentForrmaterType;
4
+ Component?: ComponentType;
5
5
  presentationType: PresentationType;
6
6
  value?: boolean;
7
7
  }
@@ -1,12 +1,14 @@
1
- import { useEnvironment, useHostTools } from "@m4l/core";
2
- import require$$0 from "react";
1
+ import React from "react";
2
+ import { useEnvironment, useHostTools, getPropertyByString } from "@m4l/core";
3
+ import "../../Icon/index.js";
4
+ import "@mui/material/styles";
3
5
  import { jsx, Fragment } from "react/jsx-runtime";
4
6
  function DateFormatter(props) {
5
7
  const {
6
8
  presentationType,
7
9
  value,
8
10
  format,
9
- Component = require$$0.Fragment
11
+ Component = React.Fragment
10
12
  } = props;
11
13
  const {
12
14
  dfnsFormat
@@ -43,20 +45,22 @@ function DateFormatter(props) {
43
45
  } catch (e) {
44
46
  result = "err_typing";
45
47
  }
46
- switch (Component) {
47
- case "div":
48
- return /* @__PURE__ */ jsx("div", {
49
- className: "DateFormatter",
50
- children: result
51
- });
52
- case "span":
53
- return /* @__PURE__ */ jsx("span", {
54
- className: "DateFormatter",
55
- children: result
56
- });
57
- }
58
48
  return /* @__PURE__ */ jsx(Component, {
59
49
  children: result
60
50
  });
61
51
  }
62
- export { DateFormatter as D };
52
+ function columnDateFormatter(props) {
53
+ const {
54
+ fieldValue,
55
+ presentationType,
56
+ Component = React.Fragment
57
+ } = props;
58
+ return (obProps) => {
59
+ return /* @__PURE__ */ jsx(DateFormatter, {
60
+ presentationType,
61
+ value: getPropertyByString(obProps, fieldValue),
62
+ Component
63
+ });
64
+ };
65
+ }
66
+ export { DateFormatter as D, columnDateFormatter as c };
@@ -1,8 +1,8 @@
1
1
  import { Maybe } from '@m4l/core';
2
- import { ComponentForrmaterType } from '../types';
2
+ import { ComponentType } from 'react';
3
3
  export declare type PresentationType = 'date' | 'datetime' | 'time';
4
4
  export interface DateFormatterProps {
5
- Component?: ComponentForrmaterType;
5
+ Component?: ComponentType;
6
6
  presentationType: PresentationType;
7
7
  format?: string;
8
8
  value: Maybe<Date | string | number>;
@@ -1,13 +1,14 @@
1
- import require$$0 from "react";
1
+ import React from "react";
2
2
  import { jsx, Fragment } from "react/jsx-runtime";
3
3
  import { getPropertyByString } from "@m4l/core";
4
- import "@mui/material";
4
+ import "../Icon/index.js";
5
+ import "@mui/material/styles";
5
6
  function UncertaintyFormatter(props) {
6
7
  const {
7
8
  value,
8
9
  unit,
9
10
  symbol,
10
- Component = require$$0.Fragment
11
+ Component = React.Fragment
11
12
  } = props;
12
13
  if (value === void 0 || value === null || !Array.isArray(value)) {
13
14
  return /* @__PURE__ */ jsx(Fragment, {
@@ -28,7 +29,7 @@ function PointsFormatter(props) {
28
29
  const {
29
30
  value,
30
31
  unit,
31
- Component = require$$0.Fragment
32
+ Component = React.Fragment
32
33
  } = props;
33
34
  console.log("points", value);
34
35
  if (value === void 0 || value === null || !Array.isArray(value)) {
@@ -50,7 +51,7 @@ function PointsFormatter(props) {
50
51
  function PriceFormatter(props) {
51
52
  const {
52
53
  value,
53
- Component = require$$0.Fragment
54
+ Component = React.Fragment
54
55
  } = props;
55
56
  return /* @__PURE__ */ jsx(Component, {
56
57
  children: `${value}$Cop`
@@ -100,12 +101,11 @@ function columnPointsFormatter(props) {
100
101
  function columnNestedValueFormatter(props) {
101
102
  const {
102
103
  fieldValue,
103
- Component = require$$0.Fragment
104
+ Component = React.Fragment
104
105
  } = props;
105
106
  return (obProps) => {
106
- console.log("columnNestedValueFormatter", obProps, fieldValue);
107
107
  return /* @__PURE__ */ jsx(Component, {
108
- children: getPropertyByString(obProps, fieldValue)
108
+ children: getPropertyByString(obProps, fieldValue) + ""
109
109
  });
110
110
  };
111
111
  }
@@ -0,0 +1,47 @@
1
+ import { styled } from "@mui/material";
2
+ import { useFormContext, Controller } from "react-hook-form";
3
+ import { E as ErrorLabel } from "../../ErrorLabel/index.js";
4
+ import { P as Period } from "../../Period/index.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ const Wrapper = styled("div")(({
7
+ theme
8
+ }) => ({
9
+ width: "100%",
10
+ display: "flex",
11
+ flexDirection: "column",
12
+ justifyContent: "center",
13
+ alignItems: "flex-start",
14
+ gap: theme.spacing(1)
15
+ }));
16
+ const RHFPeriod = (props) => {
17
+ const {
18
+ name
19
+ } = props;
20
+ const {
21
+ control
22
+ } = useFormContext();
23
+ return /* @__PURE__ */ jsx(Controller, {
24
+ name,
25
+ control,
26
+ render: ({
27
+ field: {
28
+ onChange,
29
+ value
30
+ },
31
+ fieldState: {
32
+ error
33
+ }
34
+ }) => {
35
+ return /* @__PURE__ */ jsxs(Wrapper, {
36
+ children: [/* @__PURE__ */ jsx(Period, {
37
+ value,
38
+ onChange,
39
+ error: !!error
40
+ }), error && /* @__PURE__ */ jsx(ErrorLabel, {
41
+ message: error.message || ""
42
+ })]
43
+ });
44
+ }
45
+ });
46
+ };
47
+ export { RHFPeriod as R };
@@ -1,6 +1,2 @@
1
1
  /// <reference types="react" />
2
- import { WrapperProps } from './types';
3
2
  export declare const Wrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
4
- export declare const ContainerPeriod: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & WrapperProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
5
- export declare const SKTWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
- export declare const Gap: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -1,28 +1,4 @@
1
- export declare type PeriodProps = {
2
- name: string;
3
- variant?: 'single';
4
- };
5
- export declare enum ETimePeriods {
6
- YEARS = 0,
7
- MONTHS = 1,
8
- DAYS = 2
9
- }
10
- export declare type PeriodVariant = 'monoperiod' | 'multiperiod';
11
- export declare type PeriodTime = {
12
- id: number;
13
- label: string;
14
- };
15
- export declare type PeriodType = {
16
- variant: PeriodVariant;
17
- selPeriodTime: ETimePeriods;
18
- singleValue: number | '';
19
- years?: number;
20
- months?: number;
21
- days?: number;
22
- };
23
- export interface WrapperProps {
24
- error: boolean;
25
- }
1
+ import { PeriodVariant } from '../../../components/Period/types';
26
2
  export declare type RHFPeriodProps = {
27
3
  name: string;
28
4
  variant?: PeriodVariant;
@@ -9,6 +9,5 @@ export { RHFSelect } from './RHFSelect';
9
9
  export { RHFTextField } from './RHFTextField';
10
10
  export { RHFRadioGroup } from './RHFRadioGroup';
11
11
  export { RHFPeriod } from './RHFPeriod';
12
- export type { PeriodType } from './RHFPeriod/types';
13
- export { getPeriodComponetsDictionary } from './RHFPeriod/dictionary';
12
+ export { getPeriodComponetsDictionary } from '../Period/dictionary';
14
13
  export * from './RHFUpload';
@@ -28,6 +28,8 @@ export * from '../components/NoItemSelected/dictionary';
28
28
  export * from '../components/ObjectLogs';
29
29
  export * from '../components/ObjectLogs/dictionary';
30
30
  export * from '../components/PaperForm';
31
+ export * from '../components/Period';
32
+ export type { PeriodType } from '../components/Period/types';
31
33
  export * from '../components/Page';
32
34
  export * from '../components/PropertyValue';
33
35
  export * from '../components/Resizeable';
@@ -0,0 +1,42 @@
1
+ import { useNetwork, useFlags } from "@m4l/core";
2
+ import { useState, useEffect } from "react";
3
+ const useFormAddEdit = (props) => {
4
+ const { initialValues, objectId, endPoint, formatDataEnpoint } = props;
5
+ const [formValues, setFormValues] = useState(initialValues);
6
+ const [statusLoad, setStatusLoad] = useState(
7
+ objectId === void 0 ? "new" : "edit"
8
+ );
9
+ const { networkOperation } = useNetwork();
10
+ const { addFlag } = useFlags();
11
+ useEffect(() => {
12
+ let mounted = true;
13
+ if (statusLoad === "edit") {
14
+ networkOperation({
15
+ method: "GET",
16
+ endPoint: `${endPoint}/${objectId}`
17
+ }).then(
18
+ (response) => {
19
+ if (mounted) {
20
+ if (formatDataEnpoint) {
21
+ setFormValues(formatDataEnpoint(response));
22
+ } else {
23
+ setFormValues(response);
24
+ }
25
+ setStatusLoad("reload_values_provider");
26
+ }
27
+ },
28
+ () => {
29
+ setStatusLoad("error");
30
+ }
31
+ );
32
+ } else if (statusLoad === "new" || statusLoad === "reload_values_provider") {
33
+ addFlag("form_loaded");
34
+ setStatusLoad("ready");
35
+ }
36
+ return () => {
37
+ mounted = false;
38
+ };
39
+ }, [statusLoad]);
40
+ return { formValues, statusLoad };
41
+ };
42
+ export { useFormAddEdit as u };
package/index.js CHANGED
@@ -1,22 +1,23 @@
1
1
  export { I as IconButton, a as IconButtonAnimate } from "./components/mui_extended/IconButton/index.js";
2
2
  import "framer-motion";
3
- import { styled, Skeleton, Autocomplete, TextField } from "@mui/material";
4
- import { jsx, jsxs } from "react/jsx-runtime";
3
+ import "@mui/material";
4
+ import "react/jsx-runtime";
5
5
  export { L as LoadingScreen } from "./components/animate/LoadingScreen/index.js";
6
- import { useMemo, useState, useEffect } from "react";
7
- import { useFormContext, Controller } from "react-hook-form";
6
+ import "react";
7
+ import "react-hook-form";
8
8
  export { F as FormProvider } from "./components/hook-form/FormProvider/index.js";
9
- import { useModuleDictionary, useModuleSkeleton, useEnvironment, useNetwork, useFlags } from "@m4l/core";
9
+ import "@m4l/core";
10
10
  export { R as RHFAutocomplete } from "./components/hook-form/RHFAutocomplete/index.js";
11
11
  export { R as RHFAutocompleteAsync } from "./components/hook-form/RHFAutocompleteAsync/index.js";
12
12
  export { R as RHFCheckbox } from "./components/hook-form/RHFCheckbox/index.js";
13
13
  export { R as RHFDateTime } from "./components/hook-form/RHFDateTime/index.js";
14
14
  import "@mui/x-date-pickers";
15
15
  export { R as RHFTextField } from "./components/hook-form/RHFTextField/index.js";
16
- import { I as Icon } from "./components/Icon/index.js";
16
+ export { R as RHFPeriod } from "./components/hook-form/RHFPeriod/index.js";
17
+ export { E as ErrorLabel } from "./components/ErrorLabel/index.js";
18
+ export { P as Period, g as getPeriodComponetsDictionary } from "./components/Period/index.js";
17
19
  export { I as Icon } from "./components/Icon/index.js";
18
20
  import "@mui/material/styles";
19
- import { g as getCommonActionsDictionary } from "./components/CommonActions/components/Actions/index.js";
20
21
  export { b as Actions, M as MenuActions, d as defaultCommonActionsDictionary, g as getCommonActionsDictionary } from "./components/CommonActions/components/Actions/index.js";
21
22
  import "@mui/material/Button";
22
23
  export { B as Button, L as LoadingButton } from "./components/mui_extended/Button/index.js";
@@ -66,8 +67,8 @@ export { B as BoxIcon } from "./components/mui_extended/BoxIcon/index.js";
66
67
  export { B as Breadcrumbs } from "./components/mui_extended/Breadcrumbs/index.js";
67
68
  export { L as LinkWithRoute } from "./components/mui_extended/LinkWithRoute/index.js";
68
69
  export { T as Typography } from "./components/mui_extended/Typography/index.js";
69
- export { B as BooleanFormatter } from "./components/formatters/BooleanFormatter/index.js";
70
- export { D as DateFormatter } from "./components/formatters/DateFormatter/index.js";
70
+ export { B as BooleanFormatter, c as columnBooleanFormatter } from "./components/formatters/BooleanFormatter/index.js";
71
+ export { D as DateFormatter, c as columnDateFormatter } from "./components/formatters/DateFormatter/index.js";
71
72
  export { P as PointsFormatter, a as PriceFormatter, U as UncertaintyFormatter, e as columnNestedValueFormatter, b as columnPointsFormatter, c as columnUncertaintyFormatter, d as defaultFormattersDictionary, g as getFormattersComponentsDictionary } from "./components/formatters/index.js";
72
73
  export { A as ActionCancel } from "./components/CommonActions/components/ActionCancel/index.js";
73
74
  export { A as ActionIntro } from "./components/CommonActions/components/ActionIntro/index.js";
@@ -75,6 +76,7 @@ export { A as ActionFormCancel } from "./components/CommonActions/components/Act
75
76
  export { A as ActionFormIntro } from "./components/CommonActions/components/ActionFormIntro/index.js";
76
77
  export { L as Loadable } from "./components/Loadable/index.js";
77
78
  export { S as ScrollToTop } from "./components/ScrollToTop/index.js";
79
+ export { u as useFormAddEdit } from "./hooks/useFormAddEdit/index.js";
78
80
  export { u as useModal } from "./hooks/useModal/index.js";
79
81
  export { L as Logo } from "./assets/Logo/index.js";
80
82
  import "./node_modules.js";
@@ -86,273 +88,5 @@ import "prop-types";
86
88
  import "react-dom";
87
89
  import "simplebar-react";
88
90
  import "yup";
89
- import "./index.js";
90
91
  import "./react-resizable.js";
91
92
  import "react-helmet-async";
92
- const Wrapper$1 = styled("div")(({
93
- theme
94
- }) => ({
95
- width: "100%",
96
- display: "flex",
97
- flexDirection: "column",
98
- justifyContent: "center",
99
- alignItems: "flex-start",
100
- gap: theme.spacing(1)
101
- }));
102
- const ContainerPeriod = styled("div")(({
103
- theme,
104
- error
105
- }) => ({
106
- display: "flex",
107
- width: "100%",
108
- height: "auto",
109
- alignItems: "center",
110
- gap: theme.spacing(1),
111
- border: error ? `1px solid ${theme.palette.error.main}` : `1px solid ${theme.palette.divider}`,
112
- padding: theme.spacing(0.5, 1),
113
- borderRadius: "4px",
114
- "& .MuiAutocomplete-root, & .MuiTextField-root": {
115
- width: "100%"
116
- },
117
- "& .MuiAutocomplete-root .MuiTextField-root": {
118
- width: "100%"
119
- },
120
- "& .MuiTextField-root .MuiInput-input": {
121
- padding: "5px!important"
122
- }
123
- }));
124
- const SKTWrapper = styled("div")(({
125
- theme
126
- }) => ({
127
- display: "flex",
128
- width: "auto",
129
- height: "37.5px",
130
- alignItems: "center",
131
- gap: theme.spacing(1),
132
- border: `1px solid ${theme.palette.divider}`,
133
- padding: theme.spacing(0.5, 1),
134
- borderRadius: "4px"
135
- }));
136
- const Gap = styled("div")(({
137
- theme
138
- }) => ({
139
- width: "1px",
140
- height: "20px",
141
- backgroundColor: theme.palette.divider
142
- }));
143
- var ETimePeriods = /* @__PURE__ */ ((ETimePeriods2) => {
144
- ETimePeriods2[ETimePeriods2["YEARS"] = 0] = "YEARS";
145
- ETimePeriods2[ETimePeriods2["MONTHS"] = 1] = "MONTHS";
146
- ETimePeriods2[ETimePeriods2["DAYS"] = 2] = "DAYS";
147
- return ETimePeriods2;
148
- })(ETimePeriods || {});
149
- const Wrapper = styled("p")(({
150
- theme
151
- }) => ({
152
- ...theme.typography.caption,
153
- color: theme.palette.error.main
154
- }));
155
- const ErrorLabel = (props) => {
156
- const {
157
- message
158
- } = props;
159
- return /* @__PURE__ */ jsx(Wrapper, {
160
- children: message
161
- });
162
- };
163
- const getSelPeriodTime = (period) => {
164
- if (!period)
165
- return ETimePeriods.YEARS;
166
- if (period.selPeriodTime)
167
- return period.selPeriodTime;
168
- if (period.years && period.years > 0)
169
- return ETimePeriods.YEARS;
170
- if (period.months && period.months > 0)
171
- return ETimePeriods.MONTHS;
172
- if (period.days && period.days > 0)
173
- return ETimePeriods.DAYS;
174
- return ETimePeriods.YEARS;
175
- };
176
- const getSingleValue = (period) => {
177
- if (!period)
178
- return "";
179
- if (period.singleValue !== void 0)
180
- return period.singleValue;
181
- if (period.years && period.years > 0)
182
- return period.years;
183
- if (period.months && period.months > 0)
184
- return period.months;
185
- if (period.days && period.days > 0)
186
- return period.days;
187
- return "";
188
- };
189
- const RHFPeriod = (props) => {
190
- const {
191
- name,
192
- variant = "monoperiod"
193
- } = props;
194
- const {
195
- getLabel
196
- } = useModuleDictionary();
197
- const isSkeleton = useModuleSkeleton();
198
- const {
199
- control
200
- } = useFormContext();
201
- const {
202
- host_static_assets,
203
- environment_assets
204
- } = useEnvironment();
205
- const options = useMemo(() => [{
206
- id: 0,
207
- label: getLabel("period.years")
208
- }, {
209
- id: 1,
210
- label: getLabel("period.months")
211
- }, {
212
- id: 2,
213
- label: getLabel("period.days")
214
- }], [getLabel]);
215
- if (isSkeleton) {
216
- return /* @__PURE__ */ jsxs(SKTWrapper, {
217
- children: [/* @__PURE__ */ jsx(Skeleton, {
218
- variant: "rounded",
219
- width: "100%"
220
- }), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(Skeleton, {
221
- variant: "rounded",
222
- width: "100%"
223
- }), /* @__PURE__ */ jsx(Skeleton, {
224
- variant: "circular",
225
- width: 20,
226
- sx: {
227
- minWidth: "20px",
228
- minHeight: "20px"
229
- }
230
- })]
231
- });
232
- }
233
- return /* @__PURE__ */ jsx(Controller, {
234
- name,
235
- control,
236
- render: ({
237
- field: {
238
- onChange,
239
- value
240
- },
241
- fieldState: {
242
- error
243
- }
244
- }) => {
245
- const selPeriodTime = getSelPeriodTime(value);
246
- const singleValue = getSingleValue(value);
247
- const onTotalChange = (newPeriodTime, newValue) => {
248
- const newPeriod = {
249
- selPeriodTime: newPeriodTime,
250
- singleValue: newValue,
251
- variant
252
- };
253
- if (newValue !== "" && newValue > 0) {
254
- newPeriod.years = 0;
255
- newPeriod.months = 0;
256
- newPeriod.days = 0;
257
- if (newPeriodTime === ETimePeriods.YEARS)
258
- newPeriod.years = newValue;
259
- if (newPeriodTime === ETimePeriods.MONTHS)
260
- newPeriod.months = newValue;
261
- if (newPeriodTime === ETimePeriods.DAYS)
262
- newPeriod.days = newValue;
263
- }
264
- onChange(newPeriod);
265
- };
266
- const onChangeTime = (newPeriodTime) => {
267
- if (newPeriodTime) {
268
- onTotalChange(newPeriodTime.id, singleValue);
269
- }
270
- };
271
- return /* @__PURE__ */ jsxs(Wrapper$1, {
272
- children: [/* @__PURE__ */ jsxs(ContainerPeriod, {
273
- error: !!error,
274
- children: [/* @__PURE__ */ jsx(Autocomplete, {
275
- options,
276
- value: options[selPeriodTime],
277
- disableClearable: true,
278
- onChange: (_event, autcValue) => {
279
- onChangeTime(autcValue);
280
- },
281
- renderInput: (params) => {
282
- return /* @__PURE__ */ jsx(TextField, {
283
- ...params,
284
- fullWidth: true,
285
- variant: "standard",
286
- SelectProps: {
287
- native: true
288
- },
289
- InputProps: {
290
- disableUnderline: true,
291
- ...params.InputProps
292
- },
293
- autoComplete: "off"
294
- }, `tx_async_${params.id}`);
295
- }
296
- }), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(TextField, {
297
- type: "number",
298
- variant: "standard",
299
- value: singleValue,
300
- InputProps: {
301
- disableUnderline: true
302
- },
303
- onChange: (e2) => {
304
- onTotalChange(selPeriodTime, e2.target.value === "" ? "" : parseInt(e2.target.value));
305
- }
306
- }), /* @__PURE__ */ jsx(Icon, {
307
- src: `${host_static_assets}/${environment_assets}/frontend/components/period/assets/icons/clock.svg`
308
- })]
309
- }), error && /* @__PURE__ */ jsx(ErrorLabel, {
310
- message: error.message || ""
311
- })]
312
- });
313
- }
314
- });
315
- };
316
- function getPeriodComponetsDictionary() {
317
- return ["period"].concat(getCommonActionsDictionary());
318
- }
319
- const useFormAddEdit = (props) => {
320
- const { initialValues, objectId, endPoint, formatDataEnpoint } = props;
321
- const [formValues, setFormValues] = useState(initialValues);
322
- const [statusLoad, setStatusLoad] = useState(
323
- objectId === void 0 ? "new" : "edit"
324
- );
325
- const { networkOperation } = useNetwork();
326
- const { addFlag } = useFlags();
327
- useEffect(() => {
328
- let mounted = true;
329
- if (statusLoad === "edit") {
330
- networkOperation({
331
- method: "GET",
332
- endPoint: `${endPoint}/${objectId}`
333
- }).then(
334
- (response) => {
335
- if (mounted) {
336
- if (formatDataEnpoint) {
337
- setFormValues(formatDataEnpoint(response.data));
338
- } else {
339
- setFormValues(response.data);
340
- }
341
- setStatusLoad("reload_values_provider");
342
- }
343
- },
344
- () => {
345
- setStatusLoad("error");
346
- }
347
- );
348
- } else if (statusLoad === "new" || statusLoad === "reload_values_provider") {
349
- addFlag("form_loaded");
350
- setStatusLoad("ready");
351
- }
352
- return () => {
353
- mounted = false;
354
- };
355
- }, [statusLoad]);
356
- return { formValues, statusLoad };
357
- };
358
- export { ErrorLabel, RHFPeriod, getPeriodComponetsDictionary, useFormAddEdit };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "license": "UNLICENSED",
5
5
  "dependencies": {
6
6
  "@m4l/core": "*",
@@ -1,4 +1,4 @@
1
- import require$$0 from "react";
1
+ import React$1 from "react";
2
2
  import require$$1 from "prop-types";
3
3
  import require$$2 from "react-dom";
4
4
  import clsx from "clsx";
@@ -18,7 +18,7 @@ Object.defineProperty(DraggableCore$2, "__esModule", {
18
18
  value: true
19
19
  });
20
20
  DraggableCore$2.default = void 0;
21
- var React = _interopRequireWildcard(require$$0);
21
+ var React = _interopRequireWildcard(React$1);
22
22
  var _propTypes = _interopRequireDefault(require$$1);
23
23
  var _reactDom = _interopRequireDefault(require$$2);
24
24
  var _domFns = domFns;
@@ -480,7 +480,7 @@ _defineProperty(DraggableCore$1, "defaultProps", {
480
480
  }
481
481
  });
482
482
  exports.default = void 0;
483
- var React2 = _interopRequireWildcard2(require$$0);
483
+ var React2 = _interopRequireWildcard2(React$1);
484
484
  var _propTypes2 = _interopRequireDefault2(require$$1);
485
485
  var _reactDom2 = _interopRequireDefault2(require$$2);
486
486
  var _clsx2 = _interopRequireDefault2(clsx);
@@ -1,9 +1,9 @@
1
1
  import { c as commonjsGlobal, g as getDefaultExportFromCjs } from "./commonjs.js";
2
- import require$$0 from "react";
2
+ import React from "react";
3
3
  var main = { exports: {} };
4
4
  (function(module, exports) {
5
5
  !function(e, t) {
6
- module.exports = t(require$$0);
6
+ module.exports = t(React);
7
7
  }(commonjsGlobal, function(e) {
8
8
  return function(e2) {
9
9
  var t = {};
@@ -1,4 +1,4 @@
1
- import require$$0 from "react";
1
+ import React from "react";
2
2
  import require$$2 from "react-dom";
3
3
  var build = { exports: {} };
4
4
  (() => {
@@ -200,7 +200,7 @@ var build = { exports: {} };
200
200
  var n = {};
201
201
  (() => {
202
202
  r.r(n), r.d(n, { LazyLoadComponent: () => J, LazyLoadImage: () => ue, trackWindowScroll: () => C });
203
- const e2 = require$$0;
203
+ const e2 = React;
204
204
  var t2 = r.n(e2), o = r(697);
205
205
  const i = require$$2;
206
206
  var c = r.n(i);
@@ -1,4 +1,4 @@
1
- import require$$0 from "react";
1
+ import React$2 from "react";
2
2
  import { c as cjs } from "./react-draggable.js";
3
3
  import { u as utils } from "./utils/index.js";
4
4
  import require$$1 from "prop-types";
@@ -47,7 +47,7 @@ var resizableProps = {
47
47
  propTypes.resizableProps = resizableProps;
48
48
  Resizable$1.__esModule = true;
49
49
  Resizable$1.default = void 0;
50
- var React$1 = _interopRequireWildcard$1(require$$0);
50
+ var React$1 = _interopRequireWildcard$1(React$2);
51
51
  var _reactDraggable = cjs.exports;
52
52
  var _utils = utils;
53
53
  var _propTypes$1 = propTypes;
@@ -335,7 +335,7 @@ Resizable.defaultProps = {
335
335
  var ResizableBox$2 = {};
336
336
  ResizableBox$2.__esModule = true;
337
337
  ResizableBox$2.default = void 0;
338
- var React = _interopRequireWildcard(require$$0);
338
+ var React = _interopRequireWildcard(React$2);
339
339
  var _propTypes = _interopRequireDefault(require$$1);
340
340
  var _Resizable = _interopRequireDefault(Resizable$1);
341
341
  var _propTypes2 = propTypes;
@@ -1,10 +1,10 @@
1
1
  import { g as getDefaultExportFromCjs } from "./commonjs.js";
2
2
  import require$$1 from "prop-types";
3
- import require$$0 from "react";
3
+ import React from "react";
4
4
  var lib = { exports: {} };
5
5
  (function(module, exports) {
6
6
  !function(e, t) {
7
- module.exports = t(require$$1, require$$0);
7
+ module.exports = t(require$$1, React);
8
8
  }(window, function(e, t) {
9
9
  return function(e2) {
10
10
  var t2 = {};
package/utils/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import require$$0 from "react";
1
+ import React from "react";
2
2
  const getPaletteColor = function(palette, s) {
3
3
  s = s.replace(/\[(\w+)\]/g, ".$1");
4
4
  s = s.replace(/^\./, "");
@@ -518,7 +518,7 @@ function log() {
518
518
  var utils = {};
519
519
  utils.__esModule = true;
520
520
  utils.cloneElement = cloneElement;
521
- var _react = _interopRequireDefault(require$$0);
521
+ var _react = _interopRequireDefault(React);
522
522
  function _interopRequireDefault(obj) {
523
523
  return obj && obj.__esModule ? obj : { default: obj };
524
524
  }