@lowdefy/blocks-diff 6.0.0 → 7.0.0
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/blocks/DiffGit/DiffGit.js +2 -1
- package/dist/blocks/DiffList/DiffList.js +2 -1
- package/dist/blocks/DiffList/meta.js +8 -1
- package/dist/blocks/DiffSideBySide/DiffSideBySide.js +2 -1
- package/dist/blocks/DiffSideBySide/meta.js +4 -1
- package/dist/blocks/DiffTimeline/DiffTimeline.js +2 -1
- package/dist/blocks/DiffTimeline/meta.js +8 -1
- package/dist/shared/ChangeTypeTag.js +10 -9
- package/dist/shared/DiffShell.js +6 -3
- package/dist/shared/IconContext.js +19 -0
- package/dist/shared/ValueCell.js +13 -6
- package/dist/shared/changeTypeIcons.js +22 -0
- package/dist/shared/renderers/TimelineRenderer.js +10 -9
- package/package.json +8 -6
|
@@ -17,7 +17,7 @@ import { withBlockDefaults } from '@lowdefy/block-utils';
|
|
|
17
17
|
import DiffShell from '../../shared/DiffShell.js';
|
|
18
18
|
import GitDiffRenderer from '../../shared/renderers/GitDiffRenderer.js';
|
|
19
19
|
import withTheme from '../../shared/withTheme.js';
|
|
20
|
-
const DiffGitBlock = ({ blockId, classNames = {}, properties, methods, styles = {} })=>{
|
|
20
|
+
const DiffGitBlock = ({ blockId, classNames = {}, components: { Icon }, properties, methods, styles = {} })=>{
|
|
21
21
|
const { before, after, title, emptyText = 'No changes', hide, show } = properties;
|
|
22
22
|
return /*#__PURE__*/ React.createElement(DiffShell, {
|
|
23
23
|
blockId: blockId,
|
|
@@ -26,6 +26,7 @@ const DiffGitBlock = ({ blockId, classNames = {}, properties, methods, styles =
|
|
|
26
26
|
title: title,
|
|
27
27
|
emptyText: emptyText,
|
|
28
28
|
empty: false,
|
|
29
|
+
Icon: Icon,
|
|
29
30
|
methods: methods
|
|
30
31
|
}, /*#__PURE__*/ React.createElement(GitDiffRenderer, {
|
|
31
32
|
before: before,
|
|
@@ -18,7 +18,7 @@ import DiffShell from '../../shared/DiffShell.js';
|
|
|
18
18
|
import ListRenderer from '../../shared/renderers/ListRenderer.js';
|
|
19
19
|
import buildDiffModel from '../../shared/buildDiffModel.js';
|
|
20
20
|
import withTheme from '../../shared/withTheme.js';
|
|
21
|
-
const DiffListBlock = ({ blockId, classNames = {}, properties, methods, styles = {} })=>{
|
|
21
|
+
const DiffListBlock = ({ blockId, classNames = {}, components: { Icon }, properties, methods, styles = {} })=>{
|
|
22
22
|
const { before, after, title, emptyText = 'No changes', labels, hide, show, format, showUnchanged = false, groupByRoot = true, collapseNested = true, changeTypeLabels, maxDepth = 4 } = properties;
|
|
23
23
|
const model = useMemo(()=>buildDiffModel({
|
|
24
24
|
before,
|
|
@@ -50,6 +50,7 @@ const DiffListBlock = ({ blockId, classNames = {}, properties, methods, styles =
|
|
|
50
50
|
title: title,
|
|
51
51
|
emptyText: emptyText,
|
|
52
52
|
empty: model.empty,
|
|
53
|
+
Icon: Icon,
|
|
53
54
|
methods: methods
|
|
54
55
|
}, /*#__PURE__*/ React.createElement(ListRenderer, {
|
|
55
56
|
model: model,
|
|
@@ -14,7 +14,14 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ export default {
|
|
16
16
|
category: 'display',
|
|
17
|
-
icons: [
|
|
17
|
+
icons: [
|
|
18
|
+
'add-circle',
|
|
19
|
+
'remove',
|
|
20
|
+
'edit',
|
|
21
|
+
'unchanged',
|
|
22
|
+
'arrow-right',
|
|
23
|
+
'chevron-right'
|
|
24
|
+
],
|
|
18
25
|
valueType: null,
|
|
19
26
|
cssKeys: {
|
|
20
27
|
element: 'The DiffList wrapper element.',
|
|
@@ -18,7 +18,7 @@ import DiffShell from '../../shared/DiffShell.js';
|
|
|
18
18
|
import SideBySideRenderer from '../../shared/renderers/SideBySideRenderer.js';
|
|
19
19
|
import buildDiffModel from '../../shared/buildDiffModel.js';
|
|
20
20
|
import withTheme from '../../shared/withTheme.js';
|
|
21
|
-
const DiffSideBySideBlock = ({ blockId, classNames = {}, properties, methods, styles = {} })=>{
|
|
21
|
+
const DiffSideBySideBlock = ({ blockId, classNames = {}, components: { Icon }, properties, methods, styles = {} })=>{
|
|
22
22
|
const { before, after, title, emptyText = 'No changes', labels, hide, show, format, showUnchanged = false, groupByRoot = true, collapseNested = true, changeTypeLabels, maxDepth = 4 } = properties;
|
|
23
23
|
const model = useMemo(()=>buildDiffModel({
|
|
24
24
|
before,
|
|
@@ -50,6 +50,7 @@ const DiffSideBySideBlock = ({ blockId, classNames = {}, properties, methods, st
|
|
|
50
50
|
title: title,
|
|
51
51
|
emptyText: emptyText,
|
|
52
52
|
empty: model.empty,
|
|
53
|
+
Icon: Icon,
|
|
53
54
|
methods: methods
|
|
54
55
|
}, /*#__PURE__*/ React.createElement(SideBySideRenderer, {
|
|
55
56
|
model: model,
|
|
@@ -18,7 +18,7 @@ import DiffShell from '../../shared/DiffShell.js';
|
|
|
18
18
|
import TimelineRenderer from '../../shared/renderers/TimelineRenderer.js';
|
|
19
19
|
import buildDiffModel from '../../shared/buildDiffModel.js';
|
|
20
20
|
import withTheme from '../../shared/withTheme.js';
|
|
21
|
-
const DiffTimelineBlock = ({ blockId, classNames = {}, properties, methods, styles = {} })=>{
|
|
21
|
+
const DiffTimelineBlock = ({ blockId, classNames = {}, components: { Icon }, properties, methods, styles = {} })=>{
|
|
22
22
|
const { before, after, title, emptyText = 'No changes', labels, hide, show, format, showUnchanged = false, collapseNested = true, changeTypeLabels, maxDepth = 4 } = properties;
|
|
23
23
|
const model = useMemo(()=>buildDiffModel({
|
|
24
24
|
before,
|
|
@@ -49,6 +49,7 @@ const DiffTimelineBlock = ({ blockId, classNames = {}, properties, methods, styl
|
|
|
49
49
|
title: title,
|
|
50
50
|
emptyText: emptyText,
|
|
51
51
|
empty: model.empty,
|
|
52
|
+
Icon: Icon,
|
|
52
53
|
methods: methods
|
|
53
54
|
}, /*#__PURE__*/ React.createElement(TimelineRenderer, {
|
|
54
55
|
model: model,
|
|
@@ -14,7 +14,14 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ export default {
|
|
16
16
|
category: 'display',
|
|
17
|
-
icons: [
|
|
17
|
+
icons: [
|
|
18
|
+
'add-circle',
|
|
19
|
+
'remove',
|
|
20
|
+
'edit',
|
|
21
|
+
'unchanged',
|
|
22
|
+
'arrow-right',
|
|
23
|
+
'chevron-right'
|
|
24
|
+
],
|
|
18
25
|
valueType: null,
|
|
19
26
|
cssKeys: {
|
|
20
27
|
element: 'The DiffTimeline wrapper element.',
|
|
@@ -12,16 +12,11 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import React from 'react';
|
|
15
|
+
*/ import React, { useContext } from 'react';
|
|
16
16
|
import { Tag } from 'antd';
|
|
17
|
-
import
|
|
17
|
+
import changeTypeIcons from './changeTypeIcons.js';
|
|
18
|
+
import IconContext from './IconContext.js';
|
|
18
19
|
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
20
|
const LABEL_KEYS = {
|
|
26
21
|
[CHANGE_TYPES.CREATE]: 'added',
|
|
27
22
|
[CHANGE_TYPES.REMOVE]: 'removed',
|
|
@@ -29,12 +24,18 @@ const LABEL_KEYS = {
|
|
|
29
24
|
[CHANGE_TYPES.UNCHANGED]: 'unchanged'
|
|
30
25
|
};
|
|
31
26
|
function ChangeTypeTag({ type, labels, className }) {
|
|
27
|
+
const Icon = useContext(IconContext);
|
|
32
28
|
const color = CHANGE_TYPE_TAG_COLORS[type] ?? 'default';
|
|
33
29
|
const labelKey = LABEL_KEYS[type] ?? 'changed';
|
|
34
30
|
const labelText = (labels && labels[labelKey]) ?? DEFAULT_CHANGE_TYPE_LABELS[labelKey];
|
|
35
31
|
return /*#__PURE__*/ React.createElement(Tag, {
|
|
36
32
|
color: color,
|
|
37
|
-
icon:
|
|
33
|
+
icon: /*#__PURE__*/ React.createElement(Icon, {
|
|
34
|
+
properties: {
|
|
35
|
+
name: changeTypeIcons[type],
|
|
36
|
+
title: ''
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
38
39
|
className: className,
|
|
39
40
|
style: {
|
|
40
41
|
marginInlineEnd: 0
|
package/dist/shared/DiffShell.js
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
*/ import React from 'react';
|
|
16
16
|
import { Empty, Space, Typography } from 'antd';
|
|
17
17
|
import { renderHtml } from '@lowdefy/block-utils';
|
|
18
|
+
import IconContext from './IconContext.js';
|
|
18
19
|
const { Title } = Typography;
|
|
19
|
-
function DiffShell({ blockId, classNames = {}, styles = {}, title, emptyText, empty, methods, children }) {
|
|
20
|
+
function DiffShell({ blockId, classNames = {}, styles = {}, title, emptyText, empty, Icon, methods, children }) {
|
|
20
21
|
const body = empty ? /*#__PURE__*/ React.createElement(Empty, {
|
|
21
22
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
22
23
|
description: emptyText,
|
|
@@ -24,7 +25,9 @@ function DiffShell({ blockId, classNames = {}, styles = {}, title, emptyText, em
|
|
|
24
25
|
padding: '16px 0'
|
|
25
26
|
}
|
|
26
27
|
}) : children;
|
|
27
|
-
return /*#__PURE__*/ React.createElement(
|
|
28
|
+
return /*#__PURE__*/ React.createElement(IconContext.Provider, {
|
|
29
|
+
value: Icon
|
|
30
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
28
31
|
id: blockId,
|
|
29
32
|
className: classNames.element,
|
|
30
33
|
style: styles.element
|
|
@@ -45,6 +48,6 @@ function DiffShell({ blockId, classNames = {}, styles = {}, title, emptyText, em
|
|
|
45
48
|
}, renderHtml({
|
|
46
49
|
html: title,
|
|
47
50
|
methods
|
|
48
|
-
})), body));
|
|
51
|
+
})), body)));
|
|
49
52
|
}
|
|
50
53
|
export default DiffShell;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { createContext } from 'react';
|
|
16
|
+
// The diff renderers nest several helper components deep; a context gives them the
|
|
17
|
+
// app's Icon component without threading it through every one.
|
|
18
|
+
const IconContext = /*#__PURE__*/ createContext(null);
|
|
19
|
+
export default IconContext;
|
package/dist/shared/ValueCell.js
CHANGED
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import React from 'react';
|
|
15
|
+
*/ import React, { useContext } from 'react';
|
|
16
16
|
import { Collapse, Space, Typography } from 'antd';
|
|
17
|
-
import { ArrowRightOutlined } from '@ant-design/icons';
|
|
18
17
|
import { type } from '@lowdefy/helpers';
|
|
19
18
|
import { CHANGE_TYPES } from './constants.js';
|
|
19
|
+
import IconContext from './IconContext.js';
|
|
20
20
|
import formatValue from './formatValue.js';
|
|
21
21
|
const { Text } = Typography;
|
|
22
22
|
function isComplex(value) {
|
|
@@ -95,6 +95,7 @@ function renderCollapsibleObject(value, formatter) {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
function ValueCell({ change, collapseNested = true }) {
|
|
98
|
+
const Icon = useContext(IconContext);
|
|
98
99
|
const { type: changeType, oldValue, newValue, formatter } = change;
|
|
99
100
|
if (changeType === CHANGE_TYPES.CREATE) {
|
|
100
101
|
if (collapseNested && isComplex(newValue) && type.isNone(formatter)) {
|
|
@@ -116,10 +117,16 @@ function ValueCell({ change, collapseNested = true }) {
|
|
|
116
117
|
return /*#__PURE__*/ React.createElement(Space, {
|
|
117
118
|
size: 8,
|
|
118
119
|
wrap: true
|
|
119
|
-
}, renderOld(oldValue, formatter), /*#__PURE__*/ React.createElement(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
}, renderOld(oldValue, formatter), /*#__PURE__*/ React.createElement(Icon, {
|
|
121
|
+
properties: {
|
|
122
|
+
name: 'arrow-right',
|
|
123
|
+
title: ''
|
|
124
|
+
},
|
|
125
|
+
styles: {
|
|
126
|
+
element: {
|
|
127
|
+
color: 'var(--ant-color-text-quaternary, rgba(0,0,0,0.25))',
|
|
128
|
+
fontSize: 12
|
|
129
|
+
}
|
|
123
130
|
}
|
|
124
131
|
}), renderNew(newValue, formatter));
|
|
125
132
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { CHANGE_TYPES } from './constants.js';
|
|
16
|
+
const changeTypeIcons = {
|
|
17
|
+
[CHANGE_TYPES.CREATE]: 'add-circle',
|
|
18
|
+
[CHANGE_TYPES.REMOVE]: 'remove',
|
|
19
|
+
[CHANGE_TYPES.CHANGE]: 'edit',
|
|
20
|
+
[CHANGE_TYPES.UNCHANGED]: 'unchanged'
|
|
21
|
+
};
|
|
22
|
+
export default changeTypeIcons;
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import React from 'react';
|
|
15
|
+
*/ import React, { useContext } from 'react';
|
|
16
16
|
import { Space, Timeline, Typography } from 'antd';
|
|
17
|
-
import
|
|
17
|
+
import changeTypeIcons from '../changeTypeIcons.js';
|
|
18
|
+
import IconContext from '../IconContext.js';
|
|
18
19
|
import ValueCell from '../ValueCell.js';
|
|
19
20
|
import { CHANGE_TYPES } from '../constants.js';
|
|
20
21
|
const { Text } = Typography;
|
|
@@ -24,20 +25,20 @@ const COLOR_MAP = {
|
|
|
24
25
|
[CHANGE_TYPES.CHANGE]: 'blue',
|
|
25
26
|
[CHANGE_TYPES.UNCHANGED]: 'gray'
|
|
26
27
|
};
|
|
27
|
-
const ICON_MAP = {
|
|
28
|
-
[CHANGE_TYPES.CREATE]: /*#__PURE__*/ React.createElement(PlusCircleOutlined, null),
|
|
29
|
-
[CHANGE_TYPES.REMOVE]: /*#__PURE__*/ React.createElement(MinusCircleOutlined, null),
|
|
30
|
-
[CHANGE_TYPES.CHANGE]: /*#__PURE__*/ React.createElement(EditOutlined, null),
|
|
31
|
-
[CHANGE_TYPES.UNCHANGED]: /*#__PURE__*/ React.createElement(PauseCircleOutlined, null)
|
|
32
|
-
};
|
|
33
28
|
function TimelineRenderer({ model, collapseNested = true, showUnchanged = false, classNames = {}, styles = {} }) {
|
|
29
|
+
const Icon = useContext(IconContext);
|
|
34
30
|
const flattened = model.groups.flatMap((group)=>group.changes);
|
|
35
31
|
const filtered = flattened.filter((change)=>showUnchanged === true || change.type !== CHANGE_TYPES.UNCHANGED);
|
|
36
32
|
if (filtered.length === 0) return null;
|
|
37
33
|
const items = filtered.map((change, index)=>({
|
|
38
34
|
key: change.pathStr || `change-${index}`,
|
|
39
35
|
color: COLOR_MAP[change.type],
|
|
40
|
-
dot:
|
|
36
|
+
dot: /*#__PURE__*/ React.createElement(Icon, {
|
|
37
|
+
properties: {
|
|
38
|
+
name: changeTypeIcons[change.type],
|
|
39
|
+
title: ''
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
41
42
|
children: /*#__PURE__*/ React.createElement(Space, {
|
|
42
43
|
direction: "vertical",
|
|
43
44
|
size: 2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/blocks-diff",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy diff blocks — list, side-by-side, timeline, and git-diff views for before/after object comparisons.",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
"url": "https://github.com/lowdefy/lowdefy.git"
|
|
29
29
|
},
|
|
30
30
|
"type": "module",
|
|
31
|
+
"sideEffects": [
|
|
32
|
+
"**/*.css"
|
|
33
|
+
],
|
|
31
34
|
"exports": {
|
|
32
35
|
"./*": "./dist/*",
|
|
33
36
|
"./blocks": "./dist/blocks.js",
|
|
@@ -39,9 +42,8 @@
|
|
|
39
42
|
"dist/*"
|
|
40
43
|
],
|
|
41
44
|
"dependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@lowdefy/
|
|
44
|
-
"@lowdefy/helpers": "6.0.0",
|
|
45
|
+
"@lowdefy/block-utils": "7.0.0",
|
|
46
|
+
"@lowdefy/helpers": "7.0.0",
|
|
45
47
|
"dayjs": "1.11.20",
|
|
46
48
|
"diff": "5.2.2",
|
|
47
49
|
"microdiff": "1.5.0",
|
|
@@ -54,8 +56,8 @@
|
|
|
54
56
|
"react-dom": ">=18"
|
|
55
57
|
},
|
|
56
58
|
"devDependencies": {
|
|
57
|
-
"@lowdefy/block-dev-e2e": "
|
|
58
|
-
"@lowdefy/e2e-utils": "
|
|
59
|
+
"@lowdefy/block-dev-e2e": "7.0.0",
|
|
60
|
+
"@lowdefy/e2e-utils": "7.0.0",
|
|
59
61
|
"@playwright/test": "1.59.1",
|
|
60
62
|
"@swc/cli": "0.8.1",
|
|
61
63
|
"@swc/core": "1.15.32",
|