@lowdefy/blocks-diff 0.0.0-experimental-20260420110710

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,225 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ export default {
16
+ category: 'display',
17
+ icons: [],
18
+ valueType: null,
19
+ cssKeys: {
20
+ element: 'The DiffList wrapper element.',
21
+ title: 'The DiffList title.',
22
+ group: 'A group panel wrapper around changes sharing a top-level key.',
23
+ row: 'A single change row label.',
24
+ tag: 'The change-type tag element (Added / Removed / Changed / Unchanged).'
25
+ },
26
+ properties: {
27
+ type: 'object',
28
+ additionalProperties: false,
29
+ properties: {
30
+ before: {
31
+ description: 'Previous state. An object or array; null / undefined is treated as empty so "newly created" records diff cleanly.',
32
+ docs: {
33
+ displayType: 'yaml'
34
+ },
35
+ oneOf: [
36
+ {
37
+ type: 'object'
38
+ },
39
+ {
40
+ type: 'array'
41
+ },
42
+ {
43
+ type: 'null'
44
+ }
45
+ ]
46
+ },
47
+ after: {
48
+ description: 'New state. An object or array; null / undefined is treated as empty so "deleted" records diff cleanly.',
49
+ docs: {
50
+ displayType: 'yaml'
51
+ },
52
+ oneOf: [
53
+ {
54
+ type: 'object'
55
+ },
56
+ {
57
+ type: 'array'
58
+ },
59
+ {
60
+ type: 'null'
61
+ }
62
+ ]
63
+ },
64
+ maxDepth: {
65
+ type: 'integer',
66
+ default: 4,
67
+ minimum: 1,
68
+ description: 'Paths deeper than this collapse into a single "Changed" row rendered as JSON. Defaults to 4 (covers array-of-objects + one nested object + a leaf). Lower to compress deeply nested payloads.'
69
+ },
70
+ title: {
71
+ type: 'string',
72
+ description: 'Optional title rendered above the diff. Supports html.'
73
+ },
74
+ emptyText: {
75
+ type: 'string',
76
+ default: 'No changes',
77
+ description: 'Shown when there are no differences between before and after.'
78
+ },
79
+ showUnchanged: {
80
+ type: 'boolean',
81
+ default: false,
82
+ description: 'Also render unchanged leaf fields in a muted style. Useful for "everything at a glance" views.'
83
+ },
84
+ groupByRoot: {
85
+ type: 'boolean',
86
+ default: true,
87
+ description: 'Group changes by their top-level key. When false, changes render as one flat list.'
88
+ },
89
+ collapseNested: {
90
+ type: 'boolean',
91
+ default: true,
92
+ description: 'Render entirely-new or entirely-removed nested objects and arrays inside a collapsible panel.'
93
+ },
94
+ labels: {
95
+ type: 'object',
96
+ description: 'Map of dotted path to display label. Example: { "user.email": "Email address", "address": "Mailing address" }.',
97
+ docs: {
98
+ displayType: 'yaml'
99
+ },
100
+ additionalProperties: {
101
+ type: 'string'
102
+ }
103
+ },
104
+ hide: {
105
+ type: 'array',
106
+ description: 'Patterns to hide. Each entry is an exact dotted path (e.g. `user.email`), a `prefix.*` prefix match, or a `*.leaf` tail match.',
107
+ items: {
108
+ type: 'string'
109
+ }
110
+ },
111
+ show: {
112
+ type: 'array',
113
+ description: 'Allowlist; same pattern syntax as `hide`. Applied before `hide`.',
114
+ items: {
115
+ type: 'string'
116
+ }
117
+ },
118
+ format: {
119
+ type: 'object',
120
+ description: 'Per-path value formatter. Keys are dotted paths (with optional "prefix.*" or "*.leaf" globs); values describe how to render matched values.',
121
+ docs: {
122
+ displayType: 'yaml'
123
+ },
124
+ additionalProperties: {
125
+ type: 'object',
126
+ required: [
127
+ 'type'
128
+ ],
129
+ additionalProperties: false,
130
+ properties: {
131
+ type: {
132
+ type: 'string',
133
+ enum: [
134
+ 'date',
135
+ 'datetime',
136
+ 'boolean',
137
+ 'currency',
138
+ 'json',
139
+ 'code',
140
+ 'enum'
141
+ ],
142
+ description: 'Formatter type.'
143
+ },
144
+ pattern: {
145
+ type: 'string',
146
+ description: 'Dayjs format pattern (date and datetime formatters).'
147
+ },
148
+ locale: {
149
+ type: 'string',
150
+ description: 'Intl locale (currency formatter). Defaults to the browser locale.'
151
+ },
152
+ currency: {
153
+ type: 'string',
154
+ description: 'ISO 4217 currency code (currency formatter). Defaults to "USD".'
155
+ },
156
+ yes: {
157
+ type: 'string',
158
+ default: 'Yes',
159
+ description: 'Text shown for truthy values (boolean formatter).'
160
+ },
161
+ no: {
162
+ type: 'string',
163
+ default: 'No',
164
+ description: 'Text shown for falsy values (boolean formatter).'
165
+ },
166
+ map: {
167
+ type: 'object',
168
+ description: 'Enum value map (enum formatter). Each entry is either a plain string label, or { label, color }.',
169
+ additionalProperties: {
170
+ oneOf: [
171
+ {
172
+ type: 'string'
173
+ },
174
+ {
175
+ type: 'object',
176
+ additionalProperties: false,
177
+ properties: {
178
+ label: {
179
+ type: 'string'
180
+ },
181
+ color: {
182
+ type: 'string'
183
+ }
184
+ }
185
+ }
186
+ ]
187
+ }
188
+ }
189
+ }
190
+ }
191
+ },
192
+ changeTypeLabels: {
193
+ type: 'object',
194
+ description: 'Override the tag labels for each change type.',
195
+ additionalProperties: false,
196
+ properties: {
197
+ added: {
198
+ type: 'string',
199
+ default: 'Added'
200
+ },
201
+ removed: {
202
+ type: 'string',
203
+ default: 'Removed'
204
+ },
205
+ changed: {
206
+ type: 'string',
207
+ default: 'Changed'
208
+ },
209
+ unchanged: {
210
+ type: 'string',
211
+ default: 'Unchanged'
212
+ }
213
+ }
214
+ },
215
+ theme: {
216
+ type: 'object',
217
+ description: 'Antd Descriptions design token overrides. See <a href="https://ant.design/components/descriptions#design-token">antd design tokens</a>.',
218
+ docs: {
219
+ displayType: 'yaml',
220
+ link: 'https://ant.design/components/descriptions#design-token'
221
+ }
222
+ }
223
+ }
224
+ }
225
+ };
@@ -0,0 +1,65 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import React, { useMemo } from 'react';
16
+ import { withBlockDefaults } from '@lowdefy/block-utils';
17
+ import DiffShell from '../../shared/DiffShell.js';
18
+ import SideBySideRenderer from '../../shared/renderers/SideBySideRenderer.js';
19
+ import buildDiffModel from '../../shared/buildDiffModel.js';
20
+ import withTheme from '../../shared/withTheme.js';
21
+ const DiffSideBySideBlock = ({ blockId, classNames = {}, properties, methods, styles = {} })=>{
22
+ const { before, after, title, emptyText = 'No changes', labels, hide, show, format, showUnchanged = false, groupByRoot = true, collapseNested = true, changeTypeLabels, maxDepth = 4 } = properties;
23
+ const model = useMemo(()=>buildDiffModel({
24
+ before,
25
+ after,
26
+ options: {
27
+ labels,
28
+ hide,
29
+ show,
30
+ format,
31
+ showUnchanged,
32
+ groupByRoot,
33
+ maxDepth
34
+ }
35
+ }), [
36
+ before,
37
+ after,
38
+ labels,
39
+ hide,
40
+ show,
41
+ format,
42
+ showUnchanged,
43
+ groupByRoot,
44
+ maxDepth
45
+ ]);
46
+ return /*#__PURE__*/ React.createElement(DiffShell, {
47
+ blockId: blockId,
48
+ classNames: classNames,
49
+ styles: styles,
50
+ title: title,
51
+ emptyText: emptyText,
52
+ empty: model.empty,
53
+ methods: methods
54
+ }, /*#__PURE__*/ React.createElement(SideBySideRenderer, {
55
+ model: model,
56
+ labels: labels,
57
+ classNames: classNames,
58
+ styles: styles,
59
+ collapseNested: collapseNested,
60
+ changeTypeLabels: changeTypeLabels,
61
+ before: before,
62
+ after: after
63
+ }));
64
+ };
65
+ export default withTheme('Descriptions', withBlockDefaults(DiffSideBySideBlock));
@@ -0,0 +1,25 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { createBlockHelper, escapeId } from '@lowdefy/e2e-utils';
16
+ import { expect } from '@playwright/test';
17
+ const locator = (page, blockId)=>page.locator(`#bl-${escapeId(blockId)}`);
18
+ export default createBlockHelper({
19
+ locator,
20
+ do: {},
21
+ expect: {
22
+ hasText: (page, blockId, text)=>expect(locator(page, blockId)).toContainText(text),
23
+ isVisible: (page, blockId)=>expect(locator(page, blockId)).toBeVisible()
24
+ }
25
+ });
@@ -0,0 +1,225 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ export default {
16
+ category: 'display',
17
+ icons: [],
18
+ valueType: null,
19
+ cssKeys: {
20
+ element: 'The DiffSideBySide wrapper element.',
21
+ title: 'The DiffSideBySide title.',
22
+ group: 'A paired Descriptions wrapper (one per side).',
23
+ row: 'A single row label within either side.',
24
+ tag: 'The change-type tag element.'
25
+ },
26
+ properties: {
27
+ type: 'object',
28
+ additionalProperties: false,
29
+ properties: {
30
+ before: {
31
+ description: 'Previous state. An object or array; null / undefined is treated as empty so "newly created" records diff cleanly.',
32
+ docs: {
33
+ displayType: 'yaml'
34
+ },
35
+ oneOf: [
36
+ {
37
+ type: 'object'
38
+ },
39
+ {
40
+ type: 'array'
41
+ },
42
+ {
43
+ type: 'null'
44
+ }
45
+ ]
46
+ },
47
+ after: {
48
+ description: 'New state. An object or array; null / undefined is treated as empty so "deleted" records diff cleanly.',
49
+ docs: {
50
+ displayType: 'yaml'
51
+ },
52
+ oneOf: [
53
+ {
54
+ type: 'object'
55
+ },
56
+ {
57
+ type: 'array'
58
+ },
59
+ {
60
+ type: 'null'
61
+ }
62
+ ]
63
+ },
64
+ maxDepth: {
65
+ type: 'integer',
66
+ default: 4,
67
+ minimum: 1,
68
+ description: 'Paths deeper than this collapse into a single "Changed" row rendered as JSON. Defaults to 4.'
69
+ },
70
+ title: {
71
+ type: 'string',
72
+ description: 'Optional title rendered above the diff. Supports html.'
73
+ },
74
+ emptyText: {
75
+ type: 'string',
76
+ default: 'No changes',
77
+ description: 'Shown when there are no differences between before and after.'
78
+ },
79
+ showUnchanged: {
80
+ type: 'boolean',
81
+ default: false,
82
+ description: 'Also render unchanged leaf fields in a muted style in both columns.'
83
+ },
84
+ groupByRoot: {
85
+ type: 'boolean',
86
+ default: true,
87
+ description: 'Group changes by their top-level key. When false, changes render as one flat paired list.'
88
+ },
89
+ collapseNested: {
90
+ type: 'boolean',
91
+ default: true,
92
+ description: 'Render entirely-new or entirely-removed nested objects and arrays inside a collapsible panel.'
93
+ },
94
+ labels: {
95
+ type: 'object',
96
+ description: 'Map of dotted path to display label. Example: { "user.email": "Email address" }.',
97
+ docs: {
98
+ displayType: 'yaml'
99
+ },
100
+ additionalProperties: {
101
+ type: 'string'
102
+ }
103
+ },
104
+ hide: {
105
+ type: 'array',
106
+ description: 'Patterns to hide. Each entry is an exact dotted path (e.g. `user.email`), a `prefix.*` prefix match, or a `*.leaf` tail match.',
107
+ items: {
108
+ type: 'string'
109
+ }
110
+ },
111
+ show: {
112
+ type: 'array',
113
+ description: 'Allowlist; same pattern syntax as `hide`. Applied before `hide`.',
114
+ items: {
115
+ type: 'string'
116
+ }
117
+ },
118
+ format: {
119
+ type: 'object',
120
+ description: 'Per-path value formatter. Keys are dotted paths (with optional "prefix.*" or "*.leaf" globs); values describe how to render matched values.',
121
+ docs: {
122
+ displayType: 'yaml'
123
+ },
124
+ additionalProperties: {
125
+ type: 'object',
126
+ required: [
127
+ 'type'
128
+ ],
129
+ additionalProperties: false,
130
+ properties: {
131
+ type: {
132
+ type: 'string',
133
+ enum: [
134
+ 'date',
135
+ 'datetime',
136
+ 'boolean',
137
+ 'currency',
138
+ 'json',
139
+ 'code',
140
+ 'enum'
141
+ ],
142
+ description: 'Formatter type.'
143
+ },
144
+ pattern: {
145
+ type: 'string',
146
+ description: 'Dayjs format pattern.'
147
+ },
148
+ locale: {
149
+ type: 'string',
150
+ description: 'Intl locale (currency formatter).'
151
+ },
152
+ currency: {
153
+ type: 'string',
154
+ description: 'ISO 4217 currency code.'
155
+ },
156
+ yes: {
157
+ type: 'string',
158
+ default: 'Yes',
159
+ description: 'Boolean truthy text.'
160
+ },
161
+ no: {
162
+ type: 'string',
163
+ default: 'No',
164
+ description: 'Boolean falsy text.'
165
+ },
166
+ map: {
167
+ type: 'object',
168
+ description: 'Enum value map.',
169
+ additionalProperties: {
170
+ oneOf: [
171
+ {
172
+ type: 'string'
173
+ },
174
+ {
175
+ type: 'object',
176
+ additionalProperties: false,
177
+ properties: {
178
+ label: {
179
+ type: 'string'
180
+ },
181
+ color: {
182
+ type: 'string'
183
+ }
184
+ }
185
+ }
186
+ ]
187
+ }
188
+ }
189
+ }
190
+ }
191
+ },
192
+ changeTypeLabels: {
193
+ type: 'object',
194
+ description: 'Override the tag labels for each change type.',
195
+ additionalProperties: false,
196
+ properties: {
197
+ added: {
198
+ type: 'string',
199
+ default: 'Added'
200
+ },
201
+ removed: {
202
+ type: 'string',
203
+ default: 'Removed'
204
+ },
205
+ changed: {
206
+ type: 'string',
207
+ default: 'Changed'
208
+ },
209
+ unchanged: {
210
+ type: 'string',
211
+ default: 'Unchanged'
212
+ }
213
+ }
214
+ },
215
+ theme: {
216
+ type: 'object',
217
+ description: 'Antd Descriptions design token overrides. See <a href="https://ant.design/components/descriptions#design-token">antd design tokens</a>.',
218
+ docs: {
219
+ displayType: 'yaml',
220
+ link: 'https://ant.design/components/descriptions#design-token'
221
+ }
222
+ }
223
+ }
224
+ }
225
+ };
@@ -0,0 +1,62 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import React, { useMemo } from 'react';
16
+ import { withBlockDefaults } from '@lowdefy/block-utils';
17
+ import DiffShell from '../../shared/DiffShell.js';
18
+ import TimelineRenderer from '../../shared/renderers/TimelineRenderer.js';
19
+ import buildDiffModel from '../../shared/buildDiffModel.js';
20
+ import withTheme from '../../shared/withTheme.js';
21
+ const DiffTimelineBlock = ({ blockId, classNames = {}, properties, methods, styles = {} })=>{
22
+ const { before, after, title, emptyText = 'No changes', labels, hide, show, format, showUnchanged = false, collapseNested = true, changeTypeLabels, maxDepth = 4 } = properties;
23
+ const model = useMemo(()=>buildDiffModel({
24
+ before,
25
+ after,
26
+ options: {
27
+ labels,
28
+ hide,
29
+ show,
30
+ format,
31
+ showUnchanged,
32
+ groupByRoot: false,
33
+ maxDepth
34
+ }
35
+ }), [
36
+ before,
37
+ after,
38
+ labels,
39
+ hide,
40
+ show,
41
+ format,
42
+ showUnchanged,
43
+ maxDepth
44
+ ]);
45
+ return /*#__PURE__*/ React.createElement(DiffShell, {
46
+ blockId: blockId,
47
+ classNames: classNames,
48
+ styles: styles,
49
+ title: title,
50
+ emptyText: emptyText,
51
+ empty: model.empty,
52
+ methods: methods
53
+ }, /*#__PURE__*/ React.createElement(TimelineRenderer, {
54
+ model: model,
55
+ showUnchanged: showUnchanged,
56
+ collapseNested: collapseNested,
57
+ changeTypeLabels: changeTypeLabels,
58
+ classNames: classNames,
59
+ styles: styles
60
+ }));
61
+ };
62
+ export default withTheme('Timeline', withBlockDefaults(DiffTimelineBlock));
@@ -0,0 +1,25 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { createBlockHelper, escapeId } from '@lowdefy/e2e-utils';
16
+ import { expect } from '@playwright/test';
17
+ const locator = (page, blockId)=>page.locator(`#bl-${escapeId(blockId)}`);
18
+ export default createBlockHelper({
19
+ locator,
20
+ do: {},
21
+ expect: {
22
+ hasText: (page, blockId, text)=>expect(locator(page, blockId)).toContainText(text),
23
+ isVisible: (page, blockId)=>expect(locator(page, blockId)).toBeVisible()
24
+ }
25
+ });