dirk-cfx-react 1.1.14 → 1.1.16

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.
package/dist/index.js CHANGED
@@ -168,11 +168,11 @@ var colorNames = {
168
168
  Yellow: { r: 255, g: 255, b: 0 },
169
169
  YellowGreen: { r: 154, g: 205, b: 50 }
170
170
  };
171
- function colorWithAlpha(color, alpha4) {
171
+ function colorWithAlpha(color, alpha5) {
172
172
  const lowerCasedColor = color.toLowerCase();
173
173
  if (colorNames[lowerCasedColor]) {
174
174
  const rgb = colorNames[lowerCasedColor];
175
- return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha4})`;
175
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha5})`;
176
176
  }
177
177
  if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
178
178
  const hex = color.slice(1);
@@ -180,12 +180,12 @@ function colorWithAlpha(color, alpha4) {
180
180
  const r = bigint >> 16 & 255;
181
181
  const g = bigint >> 8 & 255;
182
182
  const b = bigint & 255;
183
- return `rgba(${r}, ${g}, ${b}, ${alpha4})`;
183
+ return `rgba(${r}, ${g}, ${b}, ${alpha5})`;
184
184
  }
185
185
  if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
186
186
  const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
187
187
  if (result) {
188
- return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha4})`;
188
+ return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha5})`;
189
189
  }
190
190
  }
191
191
  return color;
@@ -1830,7 +1830,7 @@ function Modal() {
1830
1830
  boxShadow: theme2.shadows.xl,
1831
1831
  zIndex: 2100
1832
1832
  },
1833
- bg: "rgba(48, 48, 48, 0.84)",
1833
+ bg: alpha(theme2.colors.dark[9], 0.9),
1834
1834
  initial: { scale: 0.8, opacity: 0, transform: "translate(-50%, -50%)" },
1835
1835
  animate: { scale: 1, opacity: 1, transform: "translate(-50%, -50%)" },
1836
1836
  exit: { scale: 0.8, opacity: 0, transform: "translate(-50%, -50%)" },
@@ -2025,6 +2025,7 @@ function createFormStore(initialValues, validationRules, onSubmit) {
2025
2025
  initialValues,
2026
2026
  values: initialValues,
2027
2027
  errors: {},
2028
+ partialChanged: {},
2028
2029
  canBack: false,
2029
2030
  canForward: false,
2030
2031
  changedFields: [],
@@ -2039,25 +2040,34 @@ function createFormStore(initialValues, validationRules, onSubmit) {
2039
2040
  },
2040
2041
  resetChangeCount: () => {
2041
2042
  changed.clear();
2042
- set({ changedFields: [], changedCount: 0 });
2043
+ set({ changedFields: [], changedCount: 0, partialChanged: {} });
2043
2044
  },
2044
2045
  setInitialValues: (newInitialValues) => set({ initialValues: newInitialValues }),
2045
2046
  setValue: (path, value, options) => {
2046
- const currentValues = get().values;
2047
+ const state = get();
2048
+ const currentValues = state.values;
2047
2049
  const newValues = setNested(currentValues, path, value);
2048
- const oldValue = getNested(get().initialValues, path);
2050
+ const oldValue = getNested(state.initialValues, path);
2051
+ const hasChanged = value !== oldValue;
2049
2052
  history.push(currentValues);
2050
2053
  future.length = 0;
2051
- if (value !== oldValue) changed.add(path);
2052
- else changed.delete(path);
2054
+ let newPartial = state.partialChanged;
2055
+ if (hasChanged) {
2056
+ changed.add(path);
2057
+ newPartial = setNested(newPartial, path, value);
2058
+ } else {
2059
+ changed.delete(path);
2060
+ newPartial = deleteNested(newPartial, path);
2061
+ }
2053
2062
  set({
2054
2063
  values: newValues,
2064
+ partialChanged: newPartial,
2055
2065
  canBack: history.length > 0,
2056
2066
  canForward: false,
2057
2067
  changedFields: Array.from(changed),
2058
2068
  changedCount: changed.size
2059
2069
  });
2060
- if (options?.validate == false) return;
2070
+ if (options?.validate === false) return;
2061
2071
  const rule = flatRules[path];
2062
2072
  if (!rule) return;
2063
2073
  Promise.resolve(runRule(rule, value, newValues)).then((error2) => {
@@ -2105,6 +2115,7 @@ function createFormStore(initialValues, validationRules, onSubmit) {
2105
2115
  set({
2106
2116
  values: initialValues,
2107
2117
  errors: {},
2118
+ partialChanged: {},
2108
2119
  canBack: false,
2109
2120
  canForward: false,
2110
2121
  changedFields: [],
@@ -2115,14 +2126,19 @@ function createFormStore(initialValues, validationRules, onSubmit) {
2115
2126
  if (!history.length) return;
2116
2127
  const prev = history.pop();
2117
2128
  future.push(get().values);
2118
- changed.clear();
2119
2129
  const initial = get().initialValues;
2120
- for (const key in prev) {
2121
- if (JSON.stringify(prev[key]) !== JSON.stringify(initial[key]))
2122
- changed.add(key);
2130
+ let partial = {};
2131
+ changed.clear();
2132
+ for (const path of Object.keys(flatRules)) {
2133
+ const val = getNested(prev, path);
2134
+ if (val !== getNested(initial, path)) {
2135
+ changed.add(path);
2136
+ partial = setNested(partial, path, val);
2137
+ }
2123
2138
  }
2124
2139
  set({
2125
2140
  values: prev,
2141
+ partialChanged: partial,
2126
2142
  canBack: history.length > 0,
2127
2143
  canForward: true,
2128
2144
  changedFields: Array.from(changed),
@@ -2133,14 +2149,19 @@ function createFormStore(initialValues, validationRules, onSubmit) {
2133
2149
  if (!future.length) return;
2134
2150
  const next = future.pop();
2135
2151
  history.push(get().values);
2136
- changed.clear();
2137
2152
  const initial = get().initialValues;
2138
- for (const key in next) {
2139
- if (JSON.stringify(next[key]) !== JSON.stringify(initial[key]))
2140
- changed.add(key);
2153
+ let partial = {};
2154
+ changed.clear();
2155
+ for (const path of Object.keys(flatRules)) {
2156
+ const val = getNested(next, path);
2157
+ if (val !== getNested(initial, path)) {
2158
+ changed.add(path);
2159
+ partial = setNested(partial, path, val);
2160
+ }
2141
2161
  }
2142
2162
  set({
2143
2163
  values: next,
2164
+ partialChanged: partial,
2144
2165
  canBack: true,
2145
2166
  canForward: future.length > 0,
2146
2167
  changedFields: Array.from(changed),