@nocobase/client-v2 2.3.0-beta.26 → 2.3.0-beta.27
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/client-v2",
|
|
3
|
-
"version": "2.3.0-beta.
|
|
3
|
+
"version": "2.3.0-beta.27",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"@formily/antd-v5": "1.2.3",
|
|
28
28
|
"@formily/react": "^2.2.27",
|
|
29
29
|
"@formily/shared": "^2.2.27",
|
|
30
|
-
"@nocobase/evaluators": "2.3.0-beta.
|
|
31
|
-
"@nocobase/flow-engine": "2.3.0-beta.
|
|
32
|
-
"@nocobase/sdk": "2.3.0-beta.
|
|
33
|
-
"@nocobase/shared": "2.3.0-beta.
|
|
34
|
-
"@nocobase/utils": "2.3.0-beta.
|
|
30
|
+
"@nocobase/evaluators": "2.3.0-beta.27",
|
|
31
|
+
"@nocobase/flow-engine": "2.3.0-beta.27",
|
|
32
|
+
"@nocobase/sdk": "2.3.0-beta.27",
|
|
33
|
+
"@nocobase/shared": "2.3.0-beta.27",
|
|
34
|
+
"@nocobase/utils": "2.3.0-beta.27",
|
|
35
35
|
"ahooks": "^3.7.2",
|
|
36
36
|
"antd": "5.24.2",
|
|
37
37
|
"antd-style": "3.7.1",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"react-router-dom": "^6.30.1",
|
|
50
50
|
"zxing-wasm": "^3.1.3"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "203e0acfefa07c130b3dea47a635a41c8a0b763e"
|
|
53
53
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { css } from '@emotion/css';
|
|
10
11
|
import {
|
|
11
12
|
Collection,
|
|
12
13
|
DisplayItemModel,
|
|
@@ -22,6 +23,16 @@ import { DetailsGridModel } from './DetailsGridModel';
|
|
|
22
23
|
import { rebuildFieldSubModel } from '../../../internal/utils/rebuildFieldSubModel';
|
|
23
24
|
import { isToManyAssociationField } from '../../../internal/utils/modelUtils';
|
|
24
25
|
|
|
26
|
+
const mobileHorizontalItemMargin = css`
|
|
27
|
+
&& {
|
|
28
|
+
margin-bottom: 11px;
|
|
29
|
+
|
|
30
|
+
@media (max-width: 575px) {
|
|
31
|
+
margin-bottom: 3px;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
|
|
25
36
|
/**
|
|
26
37
|
* 从 record 中取值
|
|
27
38
|
* @param record 当前行数据
|
|
@@ -218,7 +229,13 @@ export class DetailsItemModel extends DisplayItemModel<{
|
|
|
218
229
|
}),
|
|
219
230
|
);
|
|
220
231
|
return (
|
|
221
|
-
<FormItem
|
|
232
|
+
<FormItem
|
|
233
|
+
{...mergedProps}
|
|
234
|
+
itemMarginClassName={
|
|
235
|
+
this.context.isMobileLayout && mergedProps.layout === 'horizontal' ? mobileHorizontalItemMargin : undefined
|
|
236
|
+
}
|
|
237
|
+
value={value}
|
|
238
|
+
>
|
|
222
239
|
<FieldModelRenderer model={modelForRender} />
|
|
223
240
|
</FormItem>
|
|
224
241
|
);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { FlowEngine } from '@nocobase/flow-engine';
|
|
11
|
+
import { render } from '@testing-library/react';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { expect, it, vi } from 'vitest';
|
|
14
|
+
import { DetailsItemModel } from '../DetailsItemModel';
|
|
15
|
+
|
|
16
|
+
it.each([
|
|
17
|
+
[true, 'horizontal', ''],
|
|
18
|
+
[true, 'vertical', '12px'],
|
|
19
|
+
[false, 'horizontal', '12px'],
|
|
20
|
+
] as const)('sets field spacing for isMobileLayout=%s and layout=%s', (isMobileLayout, layout, inlineMargin) => {
|
|
21
|
+
const model = new DetailsItemModel({ uid: 'detail-field', flowEngine: new FlowEngine() });
|
|
22
|
+
model.context.defineProperty('isMobileLayout', { value: isMobileLayout });
|
|
23
|
+
model.context.defineProperty('blockModel', { value: { props: { layout } } });
|
|
24
|
+
model.setProps('label', 'Name');
|
|
25
|
+
model.setStepParams('fieldSettings', 'init', { fieldPath: 'name' });
|
|
26
|
+
const Field = vi.fn(() => <span>Value</span>);
|
|
27
|
+
|
|
28
|
+
const { container } = render(React.cloneElement(model.renderItem(), {}, <Field />));
|
|
29
|
+
|
|
30
|
+
const item = container.querySelector<HTMLElement>('.ant-form-item');
|
|
31
|
+
expect(item.style.marginBottom).toBe(inlineMargin);
|
|
32
|
+
const rules = Array.from(document.styleSheets).flatMap((sheet) => Array.from(sheet.cssRules));
|
|
33
|
+
const matchesMargin = (rule: CSSRule, value: string) =>
|
|
34
|
+
rule instanceof CSSStyleRule &&
|
|
35
|
+
rule.style.getPropertyValue('margin-bottom') === value &&
|
|
36
|
+
item.matches(rule.selectorText);
|
|
37
|
+
|
|
38
|
+
const responsive = isMobileLayout && layout === 'horizontal';
|
|
39
|
+
expect(rules.some((rule) => matchesMargin(rule, '11px'))).toBe(responsive);
|
|
40
|
+
expect(
|
|
41
|
+
rules.some(
|
|
42
|
+
(rule) =>
|
|
43
|
+
rule instanceof CSSMediaRule &&
|
|
44
|
+
rule.conditionText === '(max-width: 575px)' &&
|
|
45
|
+
Array.from(rule.cssRules).some((child) => matchesMargin(child, '3px')),
|
|
46
|
+
),
|
|
47
|
+
).toBe(responsive);
|
|
48
|
+
expect(container.querySelector<HTMLElement>('.ant-form-item-label')?.style.paddingBottom).toBe(
|
|
49
|
+
layout === 'vertical' ? '0px' : '',
|
|
50
|
+
);
|
|
51
|
+
expect(Field).toHaveBeenCalledWith(expect.not.objectContaining({ itemMarginClassName: expect.any(String) }), {});
|
|
52
|
+
});
|