@inspirer-dev/crm-dashboard 1.0.83 → 1.0.84

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,4 +1,4 @@
1
- import React, { forwardRef, useEffect, useMemo, useState } from 'react';
1
+ import React, { forwardRef, useMemo, useRef, useState } from 'react';
2
2
  import {
3
3
  Box,
4
4
  Button,
@@ -17,7 +17,7 @@ import { Plus, Trash } from '@strapi/icons';
17
17
  import { useTheme } from 'styled-components';
18
18
  import { TRIGGER_PARAMS, STAGE_TYPE_LABELS, type TriggerParamDef } from './constants';
19
19
 
20
- type TriggerParamsValue = Record<string, number | undefined>;
20
+ type TriggerParamsValue = Record<string, number | null>;
21
21
 
22
22
  interface TriggerParamsFieldProps {
23
23
  name: string;
@@ -47,13 +47,11 @@ const parseValue = (value: string | TriggerParamsValue | null | undefined): Trig
47
47
  };
48
48
 
49
49
  const serialize = (params: TriggerParamsValue): string => {
50
- const clean: Record<string, number> = {};
50
+ const out: Record<string, number | null> = {};
51
51
  for (const [key, val] of Object.entries(params)) {
52
- if (val !== undefined && val !== null) {
53
- clean[key] = val;
54
- }
52
+ out[key] = typeof val === 'number' ? val : null;
55
53
  }
56
- return JSON.stringify(clean);
54
+ return JSON.stringify(out);
57
55
  };
58
56
 
59
57
  interface StrapiTheme {
@@ -77,13 +75,10 @@ const useThemeColors = () => {
77
75
 
78
76
  const TriggerParamsField = forwardRef<HTMLDivElement, TriggerParamsFieldProps>(
79
77
  ({ name, value, onChange, intlLabel, disabled, error, required, hint }, ref) => {
80
- const [params, setParams] = useState<TriggerParamsValue>(() => parseValue(value));
78
+ const initialRef = useRef(value);
79
+ const [params, setParams] = useState<TriggerParamsValue>(() => parseValue(initialRef.current));
81
80
  const colors = useThemeColors();
82
81
 
83
- useEffect(() => {
84
- setParams(parseValue(value));
85
- }, [value]);
86
-
87
82
  const update = (next: TriggerParamsValue) => {
88
83
  setParams(next);
89
84
  onChange({ target: { name, value: serialize(next) } });
@@ -96,7 +91,7 @@ const TriggerParamsField = forwardRef<HTMLDivElement, TriggerParamsFieldProps>(
96
91
  const addParam = (key: string) => {
97
92
  const def = TRIGGER_PARAMS.find((p) => p.key === key);
98
93
  if (!def) return;
99
- update({ ...params, [key]: undefined });
94
+ update({ ...params, [key]: null });
100
95
  };
101
96
 
102
97
  const removeParam = (key: string) => {
@@ -106,7 +101,7 @@ const TriggerParamsField = forwardRef<HTMLDivElement, TriggerParamsFieldProps>(
106
101
  };
107
102
 
108
103
  const setParamValue = (key: string, val: number | undefined) => {
109
- update({ ...params, [key]: val });
104
+ update({ ...params, [key]: val ?? null });
110
105
  };
111
106
 
112
107
  const getParamDef = (key: string): TriggerParamDef | undefined =>
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useState, useEffect, useMemo } from "react";
2
+ import { forwardRef, useRef, useState, useMemo } from "react";
3
3
  import { Field, Flex, Box, Typography, Card, CardContent, NumberInput, Tooltip, IconButton, SingleSelect, SingleSelectOption, Button } from "@strapi/design-system";
4
4
  import { Trash, Plus } from "@strapi/icons";
5
5
  import { useTheme } from "styled-components";
@@ -114,13 +114,11 @@ const parseValue = (value) => {
114
114
  return {};
115
115
  };
116
116
  const serialize = (params) => {
117
- const clean = {};
117
+ const out = {};
118
118
  for (const [key, val] of Object.entries(params)) {
119
- if (val !== void 0 && val !== null) {
120
- clean[key] = val;
121
- }
119
+ out[key] = typeof val === "number" ? val : null;
122
120
  }
123
- return JSON.stringify(clean);
121
+ return JSON.stringify(out);
124
122
  };
125
123
  const useThemeColors = () => {
126
124
  const theme = useTheme();
@@ -137,11 +135,9 @@ const useThemeColors = () => {
137
135
  };
138
136
  const TriggerParamsField = forwardRef(
139
137
  ({ name, value, onChange, intlLabel, disabled, error, required, hint }, ref) => {
140
- const [params, setParams] = useState(() => parseValue(value));
138
+ const initialRef = useRef(value);
139
+ const [params, setParams] = useState(() => parseValue(initialRef.current));
141
140
  const colors = useThemeColors();
142
- useEffect(() => {
143
- setParams(parseValue(value));
144
- }, [value]);
145
141
  const update = (next) => {
146
142
  setParams(next);
147
143
  onChange({ target: { name, value: serialize(next) } });
@@ -151,7 +147,7 @@ const TriggerParamsField = forwardRef(
151
147
  const addParam = (key) => {
152
148
  const def = TRIGGER_PARAMS.find((p) => p.key === key);
153
149
  if (!def) return;
154
- update({ ...params, [key]: void 0 });
150
+ update({ ...params, [key]: null });
155
151
  };
156
152
  const removeParam = (key) => {
157
153
  const next = { ...params };
@@ -159,7 +155,7 @@ const TriggerParamsField = forwardRef(
159
155
  update(next);
160
156
  };
161
157
  const setParamValue = (key, val) => {
162
- update({ ...params, [key]: val });
158
+ update({ ...params, [key]: val ?? null });
163
159
  };
164
160
  const getParamDef = (key) => TRIGGER_PARAMS.find((p) => p.key === key);
165
161
  return /* @__PURE__ */ jsx(Field.Root, { name, error, required, hint, ref, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, children: [
@@ -116,13 +116,11 @@ const parseValue = (value) => {
116
116
  return {};
117
117
  };
118
118
  const serialize = (params) => {
119
- const clean = {};
119
+ const out = {};
120
120
  for (const [key, val] of Object.entries(params)) {
121
- if (val !== void 0 && val !== null) {
122
- clean[key] = val;
123
- }
121
+ out[key] = typeof val === "number" ? val : null;
124
122
  }
125
- return JSON.stringify(clean);
123
+ return JSON.stringify(out);
126
124
  };
127
125
  const useThemeColors = () => {
128
126
  const theme = styledComponents.useTheme();
@@ -139,11 +137,9 @@ const useThemeColors = () => {
139
137
  };
140
138
  const TriggerParamsField = React.forwardRef(
141
139
  ({ name, value, onChange, intlLabel, disabled, error, required, hint }, ref) => {
142
- const [params, setParams] = React.useState(() => parseValue(value));
140
+ const initialRef = React.useRef(value);
141
+ const [params, setParams] = React.useState(() => parseValue(initialRef.current));
143
142
  const colors = useThemeColors();
144
- React.useEffect(() => {
145
- setParams(parseValue(value));
146
- }, [value]);
147
143
  const update = (next) => {
148
144
  setParams(next);
149
145
  onChange({ target: { name, value: serialize(next) } });
@@ -153,7 +149,7 @@ const TriggerParamsField = React.forwardRef(
153
149
  const addParam = (key) => {
154
150
  const def = TRIGGER_PARAMS.find((p) => p.key === key);
155
151
  if (!def) return;
156
- update({ ...params, [key]: void 0 });
152
+ update({ ...params, [key]: null });
157
153
  };
158
154
  const removeParam = (key) => {
159
155
  const next = { ...params };
@@ -161,7 +157,7 @@ const TriggerParamsField = React.forwardRef(
161
157
  update(next);
162
158
  };
163
159
  const setParamValue = (key, val) => {
164
- update({ ...params, [key]: val });
160
+ update({ ...params, [key]: val ?? null });
165
161
  };
166
162
  const getParamDef = (key) => TRIGGER_PARAMS.find((p) => p.key === key);
167
163
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { name, error, required, hint, ref, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, children: [
@@ -155,7 +155,7 @@ const index = {
155
155
  components: {
156
156
  Input: async () => Promise.resolve().then(() => require(
157
157
  /* webpackChunkName: "crm-trigger-params" */
158
- "../_chunks/index-2rErXqfH.js"
158
+ "../_chunks/index-Cmo9If32.js"
159
159
  ))
160
160
  },
161
161
  options: {
@@ -154,7 +154,7 @@ const index = {
154
154
  components: {
155
155
  Input: async () => import(
156
156
  /* webpackChunkName: "crm-trigger-params" */
157
- "../_chunks/index-BMvCnlEy.mjs"
157
+ "../_chunks/index-Bot_XlI2.mjs"
158
158
  )
159
159
  },
160
160
  options: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inspirer-dev/crm-dashboard",
3
- "version": "1.0.83",
3
+ "version": "1.0.84",
4
4
  "description": "CRM Dashboard and Tools",
5
5
  "strapi": {
6
6
  "name": "crm-dashboard",