@pagenflow/email 1.4.1 → 1.4.3

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,55 @@
1
+ import isEqual from "./isEqual";
2
+ /**
3
+ * Generic deep equality comparison function for React component props.
4
+ * Can be used with React.memo() to prevent unnecessary re-renders.
5
+ *
6
+ * @example
7
+ * export default memo(MyComponent, arePropsEqual);
8
+ */
9
+ export function arePropsEqual(prevProps, nextProps) {
10
+ return isEqual(prevProps, nextProps);
11
+ }
12
+ /**
13
+ * Alternative: More performant version that only compares specific keys
14
+ * Use this if you want to optimize by ignoring certain props like callbacks
15
+ *
16
+ * @example
17
+ * export default memo(MyComponent, (prev, next) =>
18
+ * arePropsEqualExcept(prev, next, ['onCallback'])
19
+ * );
20
+ */
21
+ export function arePropsEqualExcept(prevProps, nextProps, excludeKeys) {
22
+ const prevFiltered = omit(prevProps, excludeKeys);
23
+ const nextFiltered = omit(nextProps, excludeKeys);
24
+ return isEqual(prevFiltered, nextFiltered);
25
+ }
26
+ /**
27
+ * Alternative: Compare only specific keys for performance
28
+ * Useful when you have large props objects but only care about certain values
29
+ *
30
+ * @example
31
+ * export default memo(MyComponent, (prev, next) =>
32
+ * arePropsEqualOnly(prev, next, ['config', 'devMode'])
33
+ * );
34
+ */
35
+ export function arePropsEqualOnly(prevProps, nextProps, includeKeys) {
36
+ const prevFiltered = pick(prevProps, includeKeys);
37
+ const nextFiltered = pick(nextProps, includeKeys);
38
+ return isEqual(prevFiltered, nextFiltered);
39
+ }
40
+ function pick(data, keys) {
41
+ const r = {};
42
+ for (const key of keys) {
43
+ if (key in data) {
44
+ r[key] = data[key];
45
+ }
46
+ }
47
+ return r;
48
+ }
49
+ function omit(data, keys) {
50
+ const r = { ...data };
51
+ for (const key of keys) {
52
+ delete r[key];
53
+ }
54
+ return r;
55
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagenflow/email",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Free Email Compatible Components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",