@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.
- package/LICENSE +201 -0
- package/README.md +45 -0
- package/dist/blocks/DiffGit/DiffGit.js +39 -0
- package/dist/blocks/DiffGit/e2e.js +25 -0
- package/dist/blocks/DiffGit/meta.js +95 -0
- package/dist/blocks/DiffList/DiffList.js +63 -0
- package/dist/blocks/DiffList/e2e.js +25 -0
- package/dist/blocks/DiffList/meta.js +225 -0
- package/dist/blocks/DiffSideBySide/DiffSideBySide.js +65 -0
- package/dist/blocks/DiffSideBySide/e2e.js +25 -0
- package/dist/blocks/DiffSideBySide/meta.js +225 -0
- package/dist/blocks/DiffTimeline/DiffTimeline.js +62 -0
- package/dist/blocks/DiffTimeline/e2e.js +25 -0
- package/dist/blocks/DiffTimeline/meta.js +211 -0
- package/dist/blocks.js +18 -0
- package/dist/e2e.js +18 -0
- package/dist/metas.js +18 -0
- package/dist/shared/ChangeTypeTag.js +44 -0
- package/dist/shared/DiffShell.js +50 -0
- package/dist/shared/ValueCell.js +126 -0
- package/dist/shared/breadcrumbLabel.js +44 -0
- package/dist/shared/buildDiffModel.js +231 -0
- package/dist/shared/constants.js +36 -0
- package/dist/shared/formatValue.js +111 -0
- package/dist/shared/pathUtils.js +99 -0
- package/dist/shared/renderers/GitDiffRenderer.js +87 -0
- package/dist/shared/renderers/ListRenderer.js +314 -0
- package/dist/shared/renderers/SideBySideRenderer.js +193 -0
- package/dist/shared/renderers/TimelineRenderer.js +57 -0
- package/dist/shared/serializeYaml.js +74 -0
- package/dist/shared/withTheme.js +40 -0
- package/dist/types.js +17 -0
- package/package.json +74 -0
|
@@ -0,0 +1,211 @@
|
|
|
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 DiffTimeline wrapper element.',
|
|
21
|
+
title: 'The DiffTimeline title.',
|
|
22
|
+
group: 'The antd Timeline element.'
|
|
23
|
+
},
|
|
24
|
+
properties: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
additionalProperties: false,
|
|
27
|
+
properties: {
|
|
28
|
+
before: {
|
|
29
|
+
description: 'Previous state. An object or array; null / undefined is treated as empty so "newly created" records diff cleanly.',
|
|
30
|
+
docs: {
|
|
31
|
+
displayType: 'yaml'
|
|
32
|
+
},
|
|
33
|
+
oneOf: [
|
|
34
|
+
{
|
|
35
|
+
type: 'object'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'array'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'null'
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
after: {
|
|
46
|
+
description: 'New state. An object or array; null / undefined is treated as empty so "deleted" records diff cleanly.',
|
|
47
|
+
docs: {
|
|
48
|
+
displayType: 'yaml'
|
|
49
|
+
},
|
|
50
|
+
oneOf: [
|
|
51
|
+
{
|
|
52
|
+
type: 'object'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'array'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'null'
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
maxDepth: {
|
|
63
|
+
type: 'integer',
|
|
64
|
+
default: 4,
|
|
65
|
+
minimum: 1,
|
|
66
|
+
description: 'Paths deeper than this collapse into a single "Changed" entry rendered as JSON. Defaults to 4.'
|
|
67
|
+
},
|
|
68
|
+
title: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
description: 'Optional title rendered above the timeline. Supports html.'
|
|
71
|
+
},
|
|
72
|
+
emptyText: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
default: 'No changes',
|
|
75
|
+
description: 'Shown when there are no differences between before and after.'
|
|
76
|
+
},
|
|
77
|
+
showUnchanged: {
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
default: false,
|
|
80
|
+
description: 'Also emit muted timeline entries for unchanged leaf fields.'
|
|
81
|
+
},
|
|
82
|
+
collapseNested: {
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
default: true,
|
|
85
|
+
description: 'Render entirely-new or entirely-removed nested objects and arrays inside a collapsible panel.'
|
|
86
|
+
},
|
|
87
|
+
labels: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
description: 'Map of dotted path to display label.',
|
|
90
|
+
docs: {
|
|
91
|
+
displayType: 'yaml'
|
|
92
|
+
},
|
|
93
|
+
additionalProperties: {
|
|
94
|
+
type: 'string'
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
hide: {
|
|
98
|
+
type: 'array',
|
|
99
|
+
description: 'Patterns to hide. Each entry is an exact dotted path, a `prefix.*` prefix match, or a `*.leaf` tail match.',
|
|
100
|
+
items: {
|
|
101
|
+
type: 'string'
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
show: {
|
|
105
|
+
type: 'array',
|
|
106
|
+
description: 'Allowlist; same pattern syntax as `hide`. Applied before `hide`.',
|
|
107
|
+
items: {
|
|
108
|
+
type: 'string'
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
format: {
|
|
112
|
+
type: 'object',
|
|
113
|
+
description: 'Per-path value formatter. Keys are dotted paths (with optional "prefix.*" or "*.leaf" globs); values describe how to render matched values.',
|
|
114
|
+
docs: {
|
|
115
|
+
displayType: 'yaml'
|
|
116
|
+
},
|
|
117
|
+
additionalProperties: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
required: [
|
|
120
|
+
'type'
|
|
121
|
+
],
|
|
122
|
+
additionalProperties: false,
|
|
123
|
+
properties: {
|
|
124
|
+
type: {
|
|
125
|
+
type: 'string',
|
|
126
|
+
enum: [
|
|
127
|
+
'date',
|
|
128
|
+
'datetime',
|
|
129
|
+
'boolean',
|
|
130
|
+
'currency',
|
|
131
|
+
'json',
|
|
132
|
+
'code',
|
|
133
|
+
'enum'
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
pattern: {
|
|
137
|
+
type: 'string'
|
|
138
|
+
},
|
|
139
|
+
locale: {
|
|
140
|
+
type: 'string'
|
|
141
|
+
},
|
|
142
|
+
currency: {
|
|
143
|
+
type: 'string'
|
|
144
|
+
},
|
|
145
|
+
yes: {
|
|
146
|
+
type: 'string',
|
|
147
|
+
default: 'Yes'
|
|
148
|
+
},
|
|
149
|
+
no: {
|
|
150
|
+
type: 'string',
|
|
151
|
+
default: 'No'
|
|
152
|
+
},
|
|
153
|
+
map: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
additionalProperties: {
|
|
156
|
+
oneOf: [
|
|
157
|
+
{
|
|
158
|
+
type: 'string'
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
type: 'object',
|
|
162
|
+
additionalProperties: false,
|
|
163
|
+
properties: {
|
|
164
|
+
label: {
|
|
165
|
+
type: 'string'
|
|
166
|
+
},
|
|
167
|
+
color: {
|
|
168
|
+
type: 'string'
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
changeTypeLabels: {
|
|
179
|
+
type: 'object',
|
|
180
|
+
description: 'Override the tag labels for each change type.',
|
|
181
|
+
additionalProperties: false,
|
|
182
|
+
properties: {
|
|
183
|
+
added: {
|
|
184
|
+
type: 'string',
|
|
185
|
+
default: 'Added'
|
|
186
|
+
},
|
|
187
|
+
removed: {
|
|
188
|
+
type: 'string',
|
|
189
|
+
default: 'Removed'
|
|
190
|
+
},
|
|
191
|
+
changed: {
|
|
192
|
+
type: 'string',
|
|
193
|
+
default: 'Changed'
|
|
194
|
+
},
|
|
195
|
+
unchanged: {
|
|
196
|
+
type: 'string',
|
|
197
|
+
default: 'Unchanged'
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
theme: {
|
|
202
|
+
type: 'object',
|
|
203
|
+
description: 'Antd Timeline design token overrides. See <a href="https://ant.design/components/timeline#design-token">antd design tokens</a>.',
|
|
204
|
+
docs: {
|
|
205
|
+
displayType: 'yaml',
|
|
206
|
+
link: 'https://ant.design/components/timeline#design-token'
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
package/dist/blocks.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 as DiffGit } from './blocks/DiffGit/DiffGit.js';
|
|
16
|
+
export { default as DiffList } from './blocks/DiffList/DiffList.js';
|
|
17
|
+
export { default as DiffSideBySide } from './blocks/DiffSideBySide/DiffSideBySide.js';
|
|
18
|
+
export { default as DiffTimeline } from './blocks/DiffTimeline/DiffTimeline.js';
|
package/dist/e2e.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 as DiffGit } from './blocks/DiffGit/e2e.js';
|
|
16
|
+
export { default as DiffList } from './blocks/DiffList/e2e.js';
|
|
17
|
+
export { default as DiffSideBySide } from './blocks/DiffSideBySide/e2e.js';
|
|
18
|
+
export { default as DiffTimeline } from './blocks/DiffTimeline/e2e.js';
|
package/dist/metas.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 as DiffGit } from './blocks/DiffGit/meta.js';
|
|
16
|
+
export { default as DiffList } from './blocks/DiffList/meta.js';
|
|
17
|
+
export { default as DiffSideBySide } from './blocks/DiffSideBySide/meta.js';
|
|
18
|
+
export { default as DiffTimeline } from './blocks/DiffTimeline/meta.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
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 from 'react';
|
|
16
|
+
import { Tag } from 'antd';
|
|
17
|
+
import { EditOutlined, MinusCircleOutlined, PauseCircleOutlined, PlusCircleOutlined } from '@ant-design/icons';
|
|
18
|
+
import { CHANGE_TYPE_TAG_COLORS, CHANGE_TYPES, DEFAULT_CHANGE_TYPE_LABELS } from './constants.js';
|
|
19
|
+
const ICONS = {
|
|
20
|
+
[CHANGE_TYPES.CREATE]: /*#__PURE__*/ React.createElement(PlusCircleOutlined, null),
|
|
21
|
+
[CHANGE_TYPES.REMOVE]: /*#__PURE__*/ React.createElement(MinusCircleOutlined, null),
|
|
22
|
+
[CHANGE_TYPES.CHANGE]: /*#__PURE__*/ React.createElement(EditOutlined, null),
|
|
23
|
+
[CHANGE_TYPES.UNCHANGED]: /*#__PURE__*/ React.createElement(PauseCircleOutlined, null)
|
|
24
|
+
};
|
|
25
|
+
const LABEL_KEYS = {
|
|
26
|
+
[CHANGE_TYPES.CREATE]: 'added',
|
|
27
|
+
[CHANGE_TYPES.REMOVE]: 'removed',
|
|
28
|
+
[CHANGE_TYPES.CHANGE]: 'changed',
|
|
29
|
+
[CHANGE_TYPES.UNCHANGED]: 'unchanged'
|
|
30
|
+
};
|
|
31
|
+
function ChangeTypeTag({ type, labels, className }) {
|
|
32
|
+
const color = CHANGE_TYPE_TAG_COLORS[type] ?? 'default';
|
|
33
|
+
const labelKey = LABEL_KEYS[type] ?? 'changed';
|
|
34
|
+
const labelText = (labels && labels[labelKey]) ?? DEFAULT_CHANGE_TYPE_LABELS[labelKey];
|
|
35
|
+
return /*#__PURE__*/ React.createElement(Tag, {
|
|
36
|
+
color: color,
|
|
37
|
+
icon: ICONS[type],
|
|
38
|
+
className: className,
|
|
39
|
+
style: {
|
|
40
|
+
marginInlineEnd: 0
|
|
41
|
+
}
|
|
42
|
+
}, labelText);
|
|
43
|
+
}
|
|
44
|
+
export default ChangeTypeTag;
|
|
@@ -0,0 +1,50 @@
|
|
|
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 from 'react';
|
|
16
|
+
import { Empty, Space, Typography } from 'antd';
|
|
17
|
+
import { renderHtml } from '@lowdefy/block-utils';
|
|
18
|
+
const { Title } = Typography;
|
|
19
|
+
function DiffShell({ blockId, classNames = {}, styles = {}, title, emptyText, empty, methods, children }) {
|
|
20
|
+
const body = empty ? /*#__PURE__*/ React.createElement(Empty, {
|
|
21
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
22
|
+
description: emptyText,
|
|
23
|
+
style: {
|
|
24
|
+
padding: '16px 0'
|
|
25
|
+
}
|
|
26
|
+
}) : children;
|
|
27
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
28
|
+
id: blockId,
|
|
29
|
+
className: classNames.element,
|
|
30
|
+
style: styles.element
|
|
31
|
+
}, /*#__PURE__*/ React.createElement(Space, {
|
|
32
|
+
direction: "vertical",
|
|
33
|
+
size: "middle",
|
|
34
|
+
style: {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
width: '100%'
|
|
37
|
+
}
|
|
38
|
+
}, title && /*#__PURE__*/ React.createElement(Title, {
|
|
39
|
+
level: 5,
|
|
40
|
+
className: classNames.title,
|
|
41
|
+
style: {
|
|
42
|
+
margin: 0,
|
|
43
|
+
...styles.title
|
|
44
|
+
}
|
|
45
|
+
}, renderHtml({
|
|
46
|
+
html: title,
|
|
47
|
+
methods
|
|
48
|
+
})), body));
|
|
49
|
+
}
|
|
50
|
+
export default DiffShell;
|
|
@@ -0,0 +1,126 @@
|
|
|
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 from 'react';
|
|
16
|
+
import { Collapse, Space, Typography } from 'antd';
|
|
17
|
+
import { ArrowRightOutlined } from '@ant-design/icons';
|
|
18
|
+
import { type } from '@lowdefy/helpers';
|
|
19
|
+
import { CHANGE_TYPES } from './constants.js';
|
|
20
|
+
import formatValue from './formatValue.js';
|
|
21
|
+
const { Text } = Typography;
|
|
22
|
+
function isComplex(value) {
|
|
23
|
+
return type.isObject(value) || type.isArray(value);
|
|
24
|
+
}
|
|
25
|
+
// Formatters that produce their own coloured/bordered element already
|
|
26
|
+
// communicate the value visually; wrapping them in another highlight strip
|
|
27
|
+
// just nests two rectangles, so the emphasis styles are skipped for them.
|
|
28
|
+
const SELF_STYLED_FORMATTERS = new Set([
|
|
29
|
+
'enum',
|
|
30
|
+
'boolean',
|
|
31
|
+
'json',
|
|
32
|
+
'code'
|
|
33
|
+
]);
|
|
34
|
+
function isSelfStyled(formatter) {
|
|
35
|
+
return type.isObject(formatter) && SELF_STYLED_FORMATTERS.has(formatter.type);
|
|
36
|
+
}
|
|
37
|
+
function renderOld(value, formatter) {
|
|
38
|
+
if (isSelfStyled(formatter)) {
|
|
39
|
+
return /*#__PURE__*/ React.createElement("span", {
|
|
40
|
+
style: {
|
|
41
|
+
opacity: 0.55,
|
|
42
|
+
filter: 'grayscale(0.3)'
|
|
43
|
+
},
|
|
44
|
+
className: "lf-datadiff-old"
|
|
45
|
+
}, formatValue(value, formatter));
|
|
46
|
+
}
|
|
47
|
+
return /*#__PURE__*/ React.createElement("span", {
|
|
48
|
+
style: {
|
|
49
|
+
textDecoration: 'line-through',
|
|
50
|
+
color: 'var(--ant-color-text-tertiary, rgba(0,0,0,0.45))'
|
|
51
|
+
},
|
|
52
|
+
className: "lf-datadiff-old"
|
|
53
|
+
}, formatValue(value, formatter));
|
|
54
|
+
}
|
|
55
|
+
function renderNew(value, formatter) {
|
|
56
|
+
if (isSelfStyled(formatter)) {
|
|
57
|
+
return /*#__PURE__*/ React.createElement("span", {
|
|
58
|
+
className: "lf-datadiff-new"
|
|
59
|
+
}, formatValue(value, formatter));
|
|
60
|
+
}
|
|
61
|
+
return /*#__PURE__*/ React.createElement("span", {
|
|
62
|
+
style: {
|
|
63
|
+
background: 'var(--ant-color-success-bg, rgba(82,196,26,0.1))',
|
|
64
|
+
padding: '1px 6px',
|
|
65
|
+
borderRadius: 'var(--ant-border-radius-sm, 4px)',
|
|
66
|
+
color: 'var(--ant-color-success-text, var(--ant-color-text))'
|
|
67
|
+
},
|
|
68
|
+
className: "lf-datadiff-new"
|
|
69
|
+
}, formatValue(value, formatter));
|
|
70
|
+
}
|
|
71
|
+
function describeComplex(value) {
|
|
72
|
+
if (type.isArray(value)) {
|
|
73
|
+
const n = value.length;
|
|
74
|
+
return `${n} ${n === 1 ? 'item' : 'items'}`;
|
|
75
|
+
}
|
|
76
|
+
const n = Object.keys(value).length;
|
|
77
|
+
return `${n} ${n === 1 ? 'field' : 'fields'}`;
|
|
78
|
+
}
|
|
79
|
+
function renderCollapsibleObject(value, formatter) {
|
|
80
|
+
const items = [
|
|
81
|
+
{
|
|
82
|
+
key: 'details',
|
|
83
|
+
label: /*#__PURE__*/ React.createElement(Text, {
|
|
84
|
+
type: "secondary"
|
|
85
|
+
}, describeComplex(value)),
|
|
86
|
+
children: formatValue(value, formatter ?? {
|
|
87
|
+
type: 'json'
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
return /*#__PURE__*/ React.createElement(Collapse, {
|
|
92
|
+
size: "small",
|
|
93
|
+
ghost: true,
|
|
94
|
+
items: items
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function ValueCell({ change, collapseNested = true }) {
|
|
98
|
+
const { type: changeType, oldValue, newValue, formatter } = change;
|
|
99
|
+
if (changeType === CHANGE_TYPES.CREATE) {
|
|
100
|
+
if (collapseNested && isComplex(newValue) && type.isNone(formatter)) {
|
|
101
|
+
return renderCollapsibleObject(newValue, formatter);
|
|
102
|
+
}
|
|
103
|
+
return renderNew(newValue, formatter);
|
|
104
|
+
}
|
|
105
|
+
if (changeType === CHANGE_TYPES.REMOVE) {
|
|
106
|
+
if (collapseNested && isComplex(oldValue) && type.isNone(formatter)) {
|
|
107
|
+
return renderCollapsibleObject(oldValue, formatter);
|
|
108
|
+
}
|
|
109
|
+
return renderOld(oldValue, formatter);
|
|
110
|
+
}
|
|
111
|
+
if (changeType === CHANGE_TYPES.UNCHANGED) {
|
|
112
|
+
return /*#__PURE__*/ React.createElement(Text, {
|
|
113
|
+
type: "secondary"
|
|
114
|
+
}, formatValue(newValue, formatter));
|
|
115
|
+
}
|
|
116
|
+
return /*#__PURE__*/ React.createElement(Space, {
|
|
117
|
+
size: 8,
|
|
118
|
+
wrap: true
|
|
119
|
+
}, renderOld(oldValue, formatter), /*#__PURE__*/ React.createElement(ArrowRightOutlined, {
|
|
120
|
+
style: {
|
|
121
|
+
color: 'var(--ant-color-text-quaternary, rgba(0,0,0,0.25))',
|
|
122
|
+
fontSize: 12
|
|
123
|
+
}
|
|
124
|
+
}), renderNew(newValue, formatter));
|
|
125
|
+
}
|
|
126
|
+
export default ValueCell;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { type } from '@lowdefy/helpers';
|
|
16
|
+
import { humaniseSegment, isIndex, pathToString, singularise } from './pathUtils.js';
|
|
17
|
+
const SEPARATOR = ' \u203A ';
|
|
18
|
+
function labelForNonIndex(segment, subPath, labelsMap) {
|
|
19
|
+
const subPathStr = pathToString(subPath);
|
|
20
|
+
if (type.isObject(labelsMap) && type.isString(labelsMap[subPathStr])) {
|
|
21
|
+
return labelsMap[subPathStr];
|
|
22
|
+
}
|
|
23
|
+
return humaniseSegment(segment);
|
|
24
|
+
}
|
|
25
|
+
function breadcrumbLabel(path, labelsMap) {
|
|
26
|
+
if (!type.isArray(path) || path.length === 0) return '';
|
|
27
|
+
const parts = [];
|
|
28
|
+
path.forEach((segment, index)=>{
|
|
29
|
+
if (isIndex(segment)) {
|
|
30
|
+
const ordinal = Number(segment) + 1;
|
|
31
|
+
if (parts.length === 0) {
|
|
32
|
+
parts.push(String(ordinal));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const parent = parts[parts.length - 1];
|
|
36
|
+
parts[parts.length - 1] = `${singularise(parent)} ${ordinal}`;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const cumulativePath = path.slice(0, index + 1);
|
|
40
|
+
parts.push(labelForNonIndex(segment, cumulativePath, labelsMap));
|
|
41
|
+
});
|
|
42
|
+
return parts.join(SEPARATOR);
|
|
43
|
+
}
|
|
44
|
+
export default breadcrumbLabel;
|