@m4l/components 0.1.9 → 0.1.10

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.
@@ -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,8 +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
17
  import { I as Icon } from "../Icon/index.js";
18
+ import "../../index.js";
18
19
  import { L as LabelMemuItem, b as Actions, g as getCommonActionsDictionary } from "../CommonActions/components/Actions/index.js";
19
20
  import "@mui/material/Button";
20
21
  import { F as FilterButton } from "../mui_extended/Button/index.js";
@@ -690,7 +691,7 @@ const strategiesEditFilterComponent = {
690
691
  number: NumberFilter,
691
692
  boolean: BooleanFilter,
692
693
  datetime: DateTimeFilter,
693
- __default__: require$$0.Fragment
694
+ __default__: React.Fragment
694
695
  };
695
696
  const PopupEditFilterComponent = (props) => {
696
697
  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;
@@ -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,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,7 +101,7 @@ 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
107
  console.log("columnNestedValueFormatter", obProps, fieldValue);
@@ -0,0 +1,227 @@
1
+ import { useModuleDictionary, useModuleSkeleton, useEnvironment } from "@m4l/core";
2
+ import { styled, Skeleton, Autocomplete, TextField } from "@mui/material";
3
+ import { useMemo } from "react";
4
+ import { useFormContext, Controller } from "react-hook-form";
5
+ import { I as Icon } from "../../Icon/index.js";
6
+ import { ErrorLabel } from "../../../index.js";
7
+ import { jsxs, jsx } from "react/jsx-runtime";
8
+ import { g as getCommonActionsDictionary } from "../../CommonActions/components/Actions/index.js";
9
+ import "@mui/material/Button";
10
+ import "../../mui_extended/Button/index.js";
11
+ import "react-router-dom";
12
+ import "../../../contexts/ModalContext/index.js";
13
+ import "@mui/lab";
14
+ const Wrapper = styled("div")(({
15
+ theme
16
+ }) => ({
17
+ width: "100%",
18
+ display: "flex",
19
+ flexDirection: "column",
20
+ justifyContent: "center",
21
+ alignItems: "flex-start",
22
+ gap: theme.spacing(1)
23
+ }));
24
+ const ContainerPeriod = styled("div")(({
25
+ theme,
26
+ error
27
+ }) => ({
28
+ display: "flex",
29
+ width: "100%",
30
+ height: "auto",
31
+ alignItems: "center",
32
+ gap: theme.spacing(1),
33
+ border: error ? `1px solid ${theme.palette.error.main}` : `1px solid ${theme.palette.divider}`,
34
+ padding: theme.spacing(0.5, 1),
35
+ borderRadius: "4px",
36
+ "& .MuiAutocomplete-root, & .MuiTextField-root": {
37
+ width: "100%"
38
+ },
39
+ "& .MuiAutocomplete-root .MuiTextField-root": {
40
+ width: "100%"
41
+ },
42
+ "& .MuiTextField-root .MuiInput-input": {
43
+ padding: "5px!important"
44
+ }
45
+ }));
46
+ const SKTWrapper = styled("div")(({
47
+ theme
48
+ }) => ({
49
+ display: "flex",
50
+ width: "auto",
51
+ height: "37.5px",
52
+ alignItems: "center",
53
+ gap: theme.spacing(1),
54
+ border: `1px solid ${theme.palette.divider}`,
55
+ padding: theme.spacing(0.5, 1),
56
+ borderRadius: "4px"
57
+ }));
58
+ const Gap = styled("div")(({
59
+ theme
60
+ }) => ({
61
+ width: "1px",
62
+ height: "20px",
63
+ backgroundColor: theme.palette.divider
64
+ }));
65
+ var ETimePeriods = /* @__PURE__ */ ((ETimePeriods2) => {
66
+ ETimePeriods2[ETimePeriods2["YEARS"] = 0] = "YEARS";
67
+ ETimePeriods2[ETimePeriods2["MONTHS"] = 1] = "MONTHS";
68
+ ETimePeriods2[ETimePeriods2["DAYS"] = 2] = "DAYS";
69
+ return ETimePeriods2;
70
+ })(ETimePeriods || {});
71
+ const getSelPeriodTime = (period) => {
72
+ if (!period)
73
+ return ETimePeriods.YEARS;
74
+ if (period.selPeriodTime)
75
+ return period.selPeriodTime;
76
+ if (period.years && period.years > 0)
77
+ return ETimePeriods.YEARS;
78
+ if (period.months && period.months > 0)
79
+ return ETimePeriods.MONTHS;
80
+ if (period.days && period.days > 0)
81
+ return ETimePeriods.DAYS;
82
+ return ETimePeriods.YEARS;
83
+ };
84
+ const getSingleValue = (period) => {
85
+ if (!period)
86
+ return "";
87
+ if (period.singleValue !== void 0)
88
+ return period.singleValue;
89
+ if (period.years && period.years > 0)
90
+ return period.years;
91
+ if (period.months && period.months > 0)
92
+ return period.months;
93
+ if (period.days && period.days > 0)
94
+ return period.days;
95
+ return "";
96
+ };
97
+ const RHFPeriod = (props) => {
98
+ const {
99
+ name,
100
+ variant = "monoperiod"
101
+ } = props;
102
+ const {
103
+ getLabel
104
+ } = useModuleDictionary();
105
+ const isSkeleton = useModuleSkeleton();
106
+ const {
107
+ control
108
+ } = useFormContext();
109
+ const {
110
+ host_static_assets,
111
+ environment_assets
112
+ } = useEnvironment();
113
+ const options = useMemo(() => [{
114
+ id: 0,
115
+ label: getLabel("period.years")
116
+ }, {
117
+ id: 1,
118
+ label: getLabel("period.months")
119
+ }, {
120
+ id: 2,
121
+ label: getLabel("period.days")
122
+ }], [getLabel]);
123
+ if (isSkeleton) {
124
+ return /* @__PURE__ */ jsxs(SKTWrapper, {
125
+ children: [/* @__PURE__ */ jsx(Skeleton, {
126
+ variant: "rounded",
127
+ width: "100%"
128
+ }), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(Skeleton, {
129
+ variant: "rounded",
130
+ width: "100%"
131
+ }), /* @__PURE__ */ jsx(Skeleton, {
132
+ variant: "circular",
133
+ width: 20,
134
+ sx: {
135
+ minWidth: "20px",
136
+ minHeight: "20px"
137
+ }
138
+ })]
139
+ });
140
+ }
141
+ return /* @__PURE__ */ jsx(Controller, {
142
+ name,
143
+ control,
144
+ render: ({
145
+ field: {
146
+ onChange,
147
+ value
148
+ },
149
+ fieldState: {
150
+ error
151
+ }
152
+ }) => {
153
+ const selPeriodTime = getSelPeriodTime(value);
154
+ const singleValue = getSingleValue(value);
155
+ const onTotalChange = (newPeriodTime, newValue) => {
156
+ const newPeriod = {
157
+ selPeriodTime: newPeriodTime,
158
+ singleValue: newValue,
159
+ variant
160
+ };
161
+ if (newValue !== "" && newValue > 0) {
162
+ newPeriod.years = 0;
163
+ newPeriod.months = 0;
164
+ newPeriod.days = 0;
165
+ if (newPeriodTime === ETimePeriods.YEARS)
166
+ newPeriod.years = newValue;
167
+ if (newPeriodTime === ETimePeriods.MONTHS)
168
+ newPeriod.months = newValue;
169
+ if (newPeriodTime === ETimePeriods.DAYS)
170
+ newPeriod.days = newValue;
171
+ }
172
+ onChange(newPeriod);
173
+ };
174
+ const onChangeTime = (newPeriodTime) => {
175
+ if (newPeriodTime) {
176
+ onTotalChange(newPeriodTime.id, singleValue);
177
+ }
178
+ };
179
+ return /* @__PURE__ */ jsxs(Wrapper, {
180
+ children: [/* @__PURE__ */ jsxs(ContainerPeriod, {
181
+ error: !!error,
182
+ children: [/* @__PURE__ */ jsx(Autocomplete, {
183
+ options,
184
+ value: options[selPeriodTime],
185
+ disableClearable: true,
186
+ onChange: (_event, autcValue) => {
187
+ onChangeTime(autcValue);
188
+ },
189
+ renderInput: (params) => {
190
+ return /* @__PURE__ */ jsx(TextField, {
191
+ ...params,
192
+ fullWidth: true,
193
+ variant: "standard",
194
+ SelectProps: {
195
+ native: true
196
+ },
197
+ InputProps: {
198
+ disableUnderline: true,
199
+ ...params.InputProps
200
+ },
201
+ autoComplete: "off"
202
+ }, `tx_async_${params.id}`);
203
+ }
204
+ }), /* @__PURE__ */ jsx(Gap, {}), /* @__PURE__ */ jsx(TextField, {
205
+ type: "number",
206
+ variant: "standard",
207
+ value: singleValue,
208
+ InputProps: {
209
+ disableUnderline: true
210
+ },
211
+ onChange: (e) => {
212
+ onTotalChange(selPeriodTime, e.target.value === "" ? "" : parseInt(e.target.value));
213
+ }
214
+ }), /* @__PURE__ */ jsx(Icon, {
215
+ src: `${host_static_assets}/${environment_assets}/frontend/components/period/assets/icons/clock.svg`
216
+ })]
217
+ }), error && /* @__PURE__ */ jsx(ErrorLabel, {
218
+ message: error.message || ""
219
+ })]
220
+ });
221
+ }
222
+ });
223
+ };
224
+ function getPeriodComponetsDictionary() {
225
+ return ["period"].concat(getCommonActionsDictionary());
226
+ }
227
+ export { RHFPeriod as R, getPeriodComponetsDictionary as g };
package/index.js CHANGED
@@ -1,22 +1,21 @@
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 { styled } from "@mui/material";
4
+ import { jsx } from "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 { useState, useEffect } from "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 { useNetwork, useFlags } from "@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, g as getPeriodComponetsDictionary } from "./components/hook-form/RHFPeriod/index.js";
17
17
  export { I as Icon } from "./components/Icon/index.js";
18
18
  import "@mui/material/styles";
19
- import { g as getCommonActionsDictionary } from "./components/CommonActions/components/Actions/index.js";
20
19
  export { b as Actions, M as MenuActions, d as defaultCommonActionsDictionary, g as getCommonActionsDictionary } from "./components/CommonActions/components/Actions/index.js";
21
20
  import "@mui/material/Button";
22
21
  export { B as Button, L as LoadingButton } from "./components/mui_extended/Button/index.js";
@@ -66,8 +65,8 @@ export { B as BoxIcon } from "./components/mui_extended/BoxIcon/index.js";
66
65
  export { B as Breadcrumbs } from "./components/mui_extended/Breadcrumbs/index.js";
67
66
  export { L as LinkWithRoute } from "./components/mui_extended/LinkWithRoute/index.js";
68
67
  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";
68
+ export { B as BooleanFormatter, c as columnBooleanFormatter } from "./components/formatters/BooleanFormatter/index.js";
69
+ export { D as DateFormatter, c as columnDateFormatter } from "./components/formatters/DateFormatter/index.js";
71
70
  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
71
  export { A as ActionCancel } from "./components/CommonActions/components/ActionCancel/index.js";
73
72
  export { A as ActionIntro } from "./components/CommonActions/components/ActionIntro/index.js";
@@ -78,6 +77,7 @@ export { S as ScrollToTop } from "./components/ScrollToTop/index.js";
78
77
  export { u as useModal } from "./hooks/useModal/index.js";
79
78
  export { L as Logo } from "./assets/Logo/index.js";
80
79
  import "./node_modules.js";
80
+ import "./index.js";
81
81
  import "./utils/index.js";
82
82
  import "./react-data-grid.js";
83
83
  import "clsx";
@@ -86,66 +86,8 @@ import "prop-types";
86
86
  import "react-dom";
87
87
  import "simplebar-react";
88
88
  import "yup";
89
- import "./index.js";
90
89
  import "./react-resizable.js";
91
90
  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
91
  const Wrapper = styled("p")(({
150
92
  theme
151
93
  }) => ({
@@ -160,162 +102,6 @@ const ErrorLabel = (props) => {
160
102
  children: message
161
103
  });
162
104
  };
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
105
  const useFormAddEdit = (props) => {
320
106
  const { initialValues, objectId, endPoint, formatDataEnpoint } = props;
321
107
  const [formValues, setFormValues] = useState(initialValues);
@@ -334,9 +120,9 @@ const useFormAddEdit = (props) => {
334
120
  (response) => {
335
121
  if (mounted) {
336
122
  if (formatDataEnpoint) {
337
- setFormValues(formatDataEnpoint(response.data));
123
+ setFormValues(formatDataEnpoint(response));
338
124
  } else {
339
- setFormValues(response.data);
125
+ setFormValues(response);
340
126
  }
341
127
  setStatusLoad("reload_values_provider");
342
128
  }
@@ -355,4 +141,4 @@ const useFormAddEdit = (props) => {
355
141
  }, [statusLoad]);
356
142
  return { formValues, statusLoad };
357
143
  };
358
- export { ErrorLabel, RHFPeriod, getPeriodComponetsDictionary, useFormAddEdit };
144
+ export { ErrorLabel, 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.10",
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
  }