@nocobase/plugin-graph-collection-manager 0.11.0-alpha.1 → 0.11.1-alpha.1

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.
@@ -4,12 +4,9 @@ import { uid } from '@formily/shared';
4
4
  import {
5
5
  Action,
6
6
  Checkbox,
7
- collection,
8
7
  CollectionCategroriesContext,
9
8
  CollectionField,
10
9
  CollectionProvider,
11
- css,
12
- cx,
13
10
  Form,
14
11
  FormItem,
15
12
  Formula,
@@ -21,6 +18,8 @@ import {
21
18
  SchemaComponent,
22
19
  SchemaComponentProvider,
23
20
  Select,
21
+ collection,
22
+ css,
24
23
  useCollectionManager,
25
24
  useCompile,
26
25
  useCurrentAppInfo,
@@ -37,7 +36,7 @@ import {
37
36
  useUpdateCollectionActionAndRefreshCM,
38
37
  useValuesFromRecord,
39
38
  } from '../action-hooks';
40
- import { collectiionPopoverClass, entityContainer, headClass, tableBtnClass, tableNameClass } from '../style';
39
+ import useStyles from '../style';
41
40
  import { getPopupContainer, useGCMTranslation } from '../utils';
42
41
  import { AddFieldAction } from './AddFieldAction';
43
42
  import { CollectionNodeProvder } from './CollectionNodeProvder';
@@ -52,6 +51,7 @@ const Entity: React.FC<{
52
51
  setTargetNode: Function | any;
53
52
  targetGraph: any;
54
53
  }> = (props) => {
54
+ const { styles } = useStyles();
55
55
  const { node, setTargetNode, targetGraph } = props;
56
56
  const {
57
57
  store: {
@@ -86,12 +86,13 @@ const Entity: React.FC<{
86
86
  };
87
87
  return (
88
88
  <div
89
- className={cx(entityContainer)}
89
+ className={styles.entityContainer}
90
90
  style={{ boxShadow: attrs?.boxShadow, border: select ? '2px dashed #f5a20a' : 0 }}
91
91
  >
92
92
  {category.map((v, index) => {
93
93
  return (
94
94
  <Badge.Ribbon
95
+ key={index}
95
96
  color={v.color}
96
97
  style={{ width: '103%', height: '3px', marginTop: index * 5 - 8, borderRadius: 0 }}
97
98
  placement="start"
@@ -99,12 +100,12 @@ const Entity: React.FC<{
99
100
  );
100
101
  })}
101
102
  <div
102
- className={headClass}
103
+ className={styles.headClass}
103
104
  style={{ background: attrs?.hightLight ? '#1890ff' : null, paddingTop: category.length * 3 }}
104
105
  >
105
- <span className={tableNameClass}>{compile(title)}</span>
106
+ <span className={styles.tableNameClass}>{compile(title)}</span>
106
107
 
107
- <div className={tableBtnClass}>
108
+ <div className={styles.tableBtnClass}>
108
109
  <SchemaComponentProvider>
109
110
  <CollectionNodeProvder setTargetNode={setTargetNode} node={node}>
110
111
  <CollectionProvider collection={collection}>
@@ -140,6 +141,7 @@ const Entity: React.FC<{
140
141
  'x-component-props': {
141
142
  type: 'primary',
142
143
  item: collectionData.current,
144
+ className: 'btn-edit-in-head',
143
145
  },
144
146
  },
145
147
  delete: {
@@ -149,16 +151,7 @@ const Entity: React.FC<{
149
151
  'x-component-props': {
150
152
  component: DeleteOutlined,
151
153
  icon: 'DeleteOutlined',
152
- className: css`
153
- background-color: rgb(255 236 232);
154
- border-color: transparent;
155
- color: #e31c1c;
156
- height: 20px;
157
- padding: 5px;
158
- &:hover {
159
- background-color: rgb(253 205 197);
160
- }
161
- `,
154
+ className: 'btn-del',
162
155
 
163
156
  confirm: {
164
157
  title: "{{t('Delete record')}}",
@@ -207,9 +200,11 @@ const PortsCom = React.memo<any>(({ targetGraph, collectionData, setTargetNode,
207
200
  return `${prefix || ''}${uid()}`;
208
201
  };
209
202
  const CollectionConten = (data) => {
203
+ const { styles } = useStyles();
210
204
  const { type, name, primaryKey, allowNull, autoIncrement } = data;
205
+
211
206
  return (
212
- <div className={cx(collectiionPopoverClass)}>
207
+ <div className={styles.collectionPopoverClass}>
213
208
  <div className="field-content">
214
209
  <div>
215
210
  <span>name</span>: <span className="field-type">{name}</span>
@@ -318,17 +313,7 @@ const PortsCom = React.memo<any>(({ targetGraph, collectionData, setTargetNode,
318
313
  'x-component-props': {
319
314
  component: DeleteOutlined,
320
315
  icon: 'DeleteOutlined',
321
- className: css`
322
- background-color: rgb(255 236 232);
323
- border-color: transparent;
324
- color: #e31c1c;
325
- height: 20px;
326
- width: 20px;
327
- padding: 5px;
328
- &:hover {
329
- background-color: rgb(253 205 197);
330
- }
331
- `,
316
+ className: 'btn-del',
332
317
  confirm: {
333
318
  title: "{{t('Delete record')}}",
334
319
  getContainer: getPopupContainer,
@@ -1,206 +1,227 @@
1
- import { css } from '@nocobase/client';
1
+ import { createStyles } from '@nocobase/client';
2
2
 
3
- export const nodeSubtreeClass = css`
4
- display: flex;
5
- flex-direction: column-reverse;
6
- align-items: center;
7
- `;
3
+ const useStyles = createStyles(({ token, css }) => {
4
+ return {
5
+ // 右下角的小画布
6
+ graphMinimap: css`
7
+ .x6-widget-minimap {
8
+ background-color: ${token.colorBgContainer};
9
+ }
10
+ `,
8
11
 
9
- export const addButtonClass = css`
10
- flex-shrink: 0;
11
- padding: 2em 0;
12
- `;
12
+ addButtonClass: css`
13
+ flex-shrink: 0;
14
+ padding: 2em 0;
15
+ `,
13
16
 
14
- export const entityContainer = css`
15
- width: 250px;
16
- height: 100%;
17
- border-radius: 2px;
18
- background-color: #fff;
19
- border: 0;
20
- &:hover {
21
- box-shadow: 0 1px 2px -2px rgb(0 0 0 / 16%), 0 3px 6px 0 rgb(0 0 0 / 12%), 0 5px 12px 4px rgb(0 0 0 / 9%);
22
- }
23
- .body {
24
- width: 100%;
25
- height: 100%;
26
- background-color: #fff;
27
- cursor: pointer;
28
- .morePorts {
29
- max-height: 300px;
30
- overflow: auto;
31
- }
32
- .body-item {
33
- display: inline-table;
34
- width: 100%;
35
- max-width: 250px;
36
- height: 40px;
37
- font-size: 14px;
38
- color: rgba(0, 0, 0, 0.85);
39
- height: 40px;
40
- border-top: 1px solid #f0f0f0;
41
- text-overflow: ellipsis;
42
- display: flex;
43
- flex-direction: row;
44
- align-items: center;
45
- justify-content: space-between;
46
-
47
- .field-operator {
48
- display: none;
17
+ entityContainer: css`
18
+ .btn-del {
19
+ border-color: transparent;
20
+ background-color: ${token.colorErrorBg};
21
+ color: ${token.colorErrorText};
22
+ height: 20px;
23
+ width: 20px;
24
+ &:hover {
25
+ background-color: ${token.colorErrorBgHover};
26
+ }
27
+ }
28
+ .btn-add {
29
+ background: ${token.colorSuccessBg};
30
+ border-color: transparent;
31
+ color: ${token.colorSuccessText};
32
+ width: 20px;
33
+ &:hover {
34
+ background-color: ${token.colorSuccessBgHover};
35
+ }
49
36
  }
37
+ .btn-edit {
38
+ color: ${token.colorText};
39
+ display: flex;
40
+ &:hover {
41
+ background: ${token.colorBgTextHover};
42
+ }
43
+ }
44
+ .btn-edit-in-head {
45
+ border-color: transparent;
46
+ color: ${token.colorText};
47
+ height: 20px;
48
+ width: 22px;
49
+ margin: 0px 5px 4px;
50
+ line-height: 25px;
51
+ &:hover {
52
+ background: ${token.colorBgTextHover};
53
+ }
54
+ }
55
+ width: 250px;
56
+ height: 100%;
57
+ border-radius: ${token.borderRadiusLG}px;
58
+ background-color: ${token.colorBgContainer};
59
+ border: 0;
60
+ overflow: hidden;
50
61
  &:hover {
51
- .field-operator {
62
+ box-shadow: ${token.boxShadowTertiary};
63
+ }
64
+ .body {
65
+ width: 100%;
66
+ height: 100%;
67
+ background-color: ${token.colorBgContainer};
68
+ cursor: pointer;
69
+ .morePorts {
70
+ max-height: 300px;
71
+ overflow: auto;
72
+ }
73
+ .body-item {
74
+ display: inline-table;
75
+ width: 100%;
76
+ max-width: 250px;
77
+ height: 40px;
78
+ font-size: 14px;
79
+ color: ${token.colorText};
80
+ border-top: 1px solid ${token.colorBorderSecondary};
81
+ text-overflow: ellipsis;
52
82
  display: flex;
53
- flex-direction: row-reverse;
54
- height: 32px;
55
- line-height: 32px;
56
- z-index: 999;
57
- cursor: pointer;
58
- text-align: right;
59
- background: #fff;
60
- padding-right: 3px;
61
- span {
62
- margin: 3px;
63
- margin-left: 4px;
64
- padding: 3px;
65
- height: 20px;
66
- width: 20px;
83
+ flex-direction: row;
84
+ align-items: center;
85
+ justify-content: space-between;
86
+
87
+ .field-operator {
88
+ display: none;
67
89
  }
68
- .btn-del {
69
- border-color: transparent;
70
- color: rgb(78 89 105);
71
- height: 20px;
72
- width: 20px;
73
- &:hover {
74
- background-color: rgb(229 230 235);
90
+ &:hover {
91
+ .field-operator {
92
+ display: flex;
93
+ flex-direction: row-reverse;
94
+ height: 32px;
95
+ line-height: 32px;
96
+ z-index: 999;
97
+ cursor: pointer;
98
+ text-align: right;
99
+ background: ${token.colorBgContainer};
100
+ padding-right: 3px;
101
+ span {
102
+ margin: 3px;
103
+ margin-left: 4px;
104
+ padding: 3px;
105
+ height: 20px;
106
+ width: 20px;
107
+ }
108
+ .btn-override {
109
+ border-color: transparent;
110
+ width: 20px;
111
+ color: ${token.colorText};
112
+ &:hover {
113
+ background-color: ${token.colorBgTextHover};
114
+ }
115
+ }
116
+ .btn-view {
117
+ border-color: transparent;
118
+ color: ${token.colorText};
119
+ width: 20px;
120
+ }
121
+ .btn-view:hover {
122
+ background: ${token.colorBgTextHover};
123
+ }
75
124
  }
76
- }
77
- .btn-add {
78
- background: rgb(232 255 234);
79
- border-color: transparent;
80
- color: rgb(0, 180, 42);
81
- width: 20px;
82
- }
83
- .btn-edit {
84
- color: rgba(0, 0, 0, 0.85);
85
- display: flex;
86
- }
87
- .btn-edit:hover {
88
- background: rgb(229 230 235);
89
- }
90
- .btn-override {
91
- border-color: transparent;
92
- width: 20px;
93
- color: rgba(0, 0, 0, 0.85);
94
- &:hover {
95
- background-color: rgb(229 230 235);
125
+ .field_type {
126
+ display: none;
96
127
  }
97
128
  }
98
- .btn-view {
99
- border-color: transparent;
100
- color: rgba(0, 0, 0, 0.85);
101
- width: 20px;
129
+
130
+ .name {
131
+ text-overflow: ellipsis;
132
+ white-space: nowrap;
133
+ overflow: hidden;
134
+ margin-left: 8px;
102
135
  }
103
- .btn-view:hover {
104
- background: rgb(229 230 235);
136
+
137
+ .type {
138
+ color: ${token.colorTextTertiary};
139
+ margin-right: 8px;
140
+ text-overflow: ellipsis;
141
+ white-space: nowrap;
142
+ overflow: hidden;
105
143
  }
106
144
  }
107
- .field_type {
108
- display: none;
109
- }
110
145
  }
146
+ `,
111
147
 
112
- .name {
113
- text-overflow: ellipsis;
114
- white-space: nowrap;
115
- overflow: hidden;
116
- margin-left: 8px;
117
- }
118
-
119
- .type {
120
- color: rgba(0, 0, 0, 0.45);
121
- margin-right: 8px;
122
- text-overflow: ellipsis;
123
- white-space: nowrap;
124
- overflow: hidden;
125
- }
126
- }
127
- }
128
- `;
148
+ headClass: css`
149
+ height: 50px;
150
+ font-size: 14px;
151
+ font-weight: 500;
152
+ display: flex;
153
+ flex-direction: row;
154
+ justify-content: space-between;
155
+ align-items: center;
156
+ background: ${token.colorFillAlter};
157
+ color: ${token.colorTextHeading};
158
+ padding: 0 8px;
159
+ `,
129
160
 
130
- export const headClass = css`
131
- height: 50px;
132
- font-size: 14px;
133
- font-weight: 500;
134
- display: flex;
135
- flex-direction: row;
136
- justify-content: space-between;
137
- align-items: center;
138
- background: #fafafa;
139
- color: rgb(29 33 41);
140
- padding: 0 8px;
141
- border-radius: 3px;
142
- `;
161
+ tableNameClass: css`
162
+ max-width: 80%;
163
+ overflow: hidden;
164
+ text-overflow: ellipsis;
165
+ white-space: nowrap;
166
+ font-weight: 500;
167
+ `,
143
168
 
144
- export const tableNameClass = css`
145
- max-width: 80%;
146
- overflow: hidden;
147
- text-overflow: ellipsis;
148
- white-space: nowrap;
149
- font-weight: 500;
150
- `;
169
+ tableBtnClass: css`
170
+ display: flex;
171
+ span {
172
+ cursor: pointer;
173
+ }
174
+ `,
151
175
 
152
- export const tableBtnClass = css`
153
- display: flex;
154
- span {
155
- cursor: pointer;
156
- }
157
- `;
176
+ collectionPopoverClass: css`
177
+ div.field-content {
178
+ font-size: 14px;
179
+ color: ${token.colorTextSecondary};
180
+ opacity: 0.8;
181
+ display: block;
182
+ .field-type {
183
+ color: ${token.colorText};
184
+ float: right;
185
+ }
186
+ }
187
+ `,
158
188
 
159
- export const collectiionPopoverClass = css`
160
- div.field-content {
161
- font-size: 14px;
162
- color: rgb(134 144 156);
163
- opacity: 0.8;
164
- display: block;
165
- .field-type {
166
- color: #333;
189
+ collectionListClass: css`
167
190
  float: right;
168
- }
169
- }
170
- `;
191
+ position: fixed;
192
+ margin-top: 24px;
193
+ right: 24px;
194
+ z-index: 1000;
195
+ .trigger {
196
+ float: right;
197
+ margin: 2px 4px;
198
+ font-size: 16px;
199
+ }
200
+ .ant-input {
201
+ margin: 4px;
202
+ }
203
+ .ant-menu-inline {
204
+ border-top: 1px solid ${token.colorBorderSecondary};
205
+ }
206
+ .ant-layout-sider {
207
+ margin-top: 24px;
208
+ }
209
+ .ant-menu-item {
210
+ height: 32px;
211
+ }
212
+ .ant-btn {
213
+ border: 0;
214
+ }
215
+ `,
171
216
 
172
- export const collectionListClass = css`
173
- float: right;
174
- position: fixed;
175
- margin-top: 24px;
176
- right: 24px;
177
- z-index: 1000;
178
- .trigger {
179
- float: right;
180
- margin: 2px 4px;
181
- font-size: 16px;
182
- }
183
- .ant-input {
184
- margin: 4px;
185
- }
186
- .ant-menu-inline {
187
- border-top: 1px solid #f0f0f0;
188
- }
189
- .ant-layout-sider {
190
- margin-top: 24px;
191
- }
192
- .ant-menu-item {
193
- height: 32px;
194
- }
195
- .ant-btn {
196
- border: 0;
197
- }
198
- `;
217
+ graphCollectionContainerClass: css`
218
+ overflow: hidden;
219
+ .x6-graph-scroller {
220
+ height: calc(100vh) !important;
221
+ width: calc(100vw) !important;
222
+ }
223
+ `,
224
+ };
225
+ });
199
226
 
200
- export const graphCollectionContainerClass = css`
201
- overflow: hidden;
202
- .x6-graph-scroller {
203
- height: calc(100vh) !important;
204
- width: calc(100vw) !important;
205
- }
206
- `;
227
+ export default useStyles;