superdesk-ui-framework 3.0.1-beta.25 → 3.0.1-beta.26
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/app/styles/_sd-tag-input.scss +36 -1
- package/app/styles/_table-list.scss +1 -0
- package/app/styles/primereact/_pr-dialog.scss +4 -0
- package/app-typescript/components/Label.tsx +10 -6
- package/app-typescript/components/Layouts/AuthoringFrame.tsx +2 -1
- package/app-typescript/components/Layouts/AuthoringFrameRightBar.tsx +21 -2
- package/app-typescript/components/Lists/TableList.tsx +62 -2
- package/app-typescript/components/Menu.tsx +2 -2
- package/app-typescript/components/Spacer.tsx +1 -1
- package/app-typescript/components/TreeSelect.tsx +85 -33
- package/dist/examples.bundle.js +1549 -1184
- package/dist/playgrounds/react-playgrounds/Index.tsx +1 -0
- package/dist/playgrounds/react-playgrounds/Multiedit.tsx +321 -0
- package/dist/react/TableList.tsx +2 -0
- package/dist/react/TreeSelect.tsx +100 -78
- package/dist/superdesk-ui.bundle.css +34 -2
- package/dist/superdesk-ui.bundle.js +1132 -1059
- package/dist/vendor.bundle.js +4 -4
- package/examples/index.js +4 -0
- package/examples/pages/playgrounds/react-playgrounds/Index.tsx +1 -0
- package/examples/pages/playgrounds/react-playgrounds/Multiedit.tsx +321 -0
- package/examples/pages/react/TableList.tsx +2 -0
- package/examples/pages/react/TreeSelect.tsx +100 -78
- package/package.json +1 -1
- package/react/components/Label.d.ts +1 -1
- package/react/components/Label.js +10 -5
- package/react/components/Layouts/AuthoringFrame.d.ts +1 -0
- package/react/components/Layouts/AuthoringFrame.js +1 -1
- package/react/components/Layouts/AuthoringFrameRightBar.d.ts +9 -2
- package/react/components/Layouts/AuthoringFrameRightBar.js +14 -3
- package/react/components/Lists/TableList.d.ts +1 -0
- package/react/components/Lists/TableList.js +34 -6
- package/react/components/Menu.js +1 -1
- package/react/components/TreeSelect.d.ts +3 -1
- package/react/components/TreeSelect.js +50 -23
@@ -13,51 +13,79 @@ interface IState {
|
|
13
13
|
arr: any;
|
14
14
|
}
|
15
15
|
|
16
|
-
let
|
16
|
+
let options = [
|
17
17
|
{
|
18
|
-
value: 'Category1',
|
18
|
+
value: {name: 'Category1'},
|
19
19
|
children: [
|
20
20
|
{
|
21
|
-
value: 'Sub-
|
21
|
+
value: {name: 'Sub-category1'},
|
22
22
|
children: [
|
23
|
-
{value: '
|
23
|
+
{value: {name: 'Item20'}}
|
24
24
|
]
|
25
25
|
},
|
26
26
|
{
|
27
|
-
value: 'Sub-
|
27
|
+
value: {name: 'Sub-category2'},
|
28
|
+
children: [
|
29
|
+
{value: {name: 'Item21'}}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
,
|
33
|
+
{
|
34
|
+
value: {name: 'Sub-category3'},
|
35
|
+
children: [
|
36
|
+
{value: {name: 'Item22'}}
|
37
|
+
]
|
38
|
+
}
|
39
|
+
,
|
40
|
+
{
|
41
|
+
value: {name: 'Sub-category4'},
|
42
|
+
children: [
|
43
|
+
{value: {name: 'Item23'}}
|
44
|
+
]
|
45
|
+
}
|
46
|
+
,
|
47
|
+
{
|
48
|
+
value: {name: 'Sub-category5'},
|
28
49
|
children: [
|
29
|
-
{value: '
|
50
|
+
{value: {name: 'Item24'}}
|
51
|
+
]
|
52
|
+
}
|
53
|
+
,
|
54
|
+
{
|
55
|
+
value: {name: 'Sub-category6'},
|
56
|
+
children: [
|
57
|
+
{value: {name: 'Item25'}}
|
30
58
|
]
|
31
59
|
}
|
32
60
|
]
|
33
61
|
},
|
34
62
|
{
|
35
|
-
value: 'Category2',
|
63
|
+
value: {name: 'Category2'},
|
36
64
|
children: [
|
37
65
|
{
|
38
|
-
value: '
|
66
|
+
value: {name: 'Item8'}
|
39
67
|
},
|
40
68
|
{
|
41
|
-
value: '
|
69
|
+
value: {name: 'Item9'}
|
42
70
|
}
|
43
71
|
]
|
44
72
|
},
|
45
73
|
{
|
46
|
-
value: 'Category3',
|
74
|
+
value: {name: 'Category3', bgColor: 'red'},
|
47
75
|
children: [
|
48
76
|
{
|
49
|
-
value: '
|
77
|
+
value: {name: 'Item10'}
|
50
78
|
},
|
51
79
|
{
|
52
|
-
value: '
|
80
|
+
value: {name: 'Item11'}
|
53
81
|
}
|
54
82
|
]
|
55
83
|
},
|
56
84
|
]
|
57
85
|
|
58
|
-
let
|
86
|
+
let options2 = [
|
59
87
|
{
|
60
|
-
value: {name: 'Category1'},
|
88
|
+
value: {name: 'Category1', border: 'red'},
|
61
89
|
children: [
|
62
90
|
{
|
63
91
|
value: {name: 'Sub-category1'},
|
@@ -102,7 +130,7 @@ let itemArr2 = [
|
|
102
130
|
]
|
103
131
|
},
|
104
132
|
{
|
105
|
-
value: {name: 'Category2'},
|
133
|
+
value: {name: 'Category2', border: 'green'},
|
106
134
|
children: [
|
107
135
|
{
|
108
136
|
value: {name: 'Item8'}
|
@@ -113,7 +141,7 @@ let itemArr2 = [
|
|
113
141
|
]
|
114
142
|
},
|
115
143
|
{
|
116
|
-
value: {name: 'Category3'},
|
144
|
+
value: {name: 'Category3', border: 'yellow'},
|
117
145
|
children: [
|
118
146
|
{
|
119
147
|
value: {name: 'Item10'}
|
@@ -125,37 +153,6 @@ let itemArr2 = [
|
|
125
153
|
},
|
126
154
|
]
|
127
155
|
|
128
|
-
const source = [
|
129
|
-
{
|
130
|
-
'name': 'Article (news)',
|
131
|
-
'qcode': 'Article (news)',
|
132
|
-
},
|
133
|
-
{
|
134
|
-
'name': 'Article',
|
135
|
-
'qcode': 'Article',
|
136
|
-
},
|
137
|
-
{
|
138
|
-
'name': 'Sidebar',
|
139
|
-
'qcode': 'Sidebar',
|
140
|
-
},
|
141
|
-
{
|
142
|
-
'name': 'Factbox',
|
143
|
-
'qcode': 'Factbox',
|
144
|
-
},
|
145
|
-
{
|
146
|
-
'name': 'Item',
|
147
|
-
'qcode': 'Item',
|
148
|
-
},
|
149
|
-
{
|
150
|
-
'name': 'Array',
|
151
|
-
'qcode': 'Array',
|
152
|
-
},
|
153
|
-
{
|
154
|
-
'name': 'Object',
|
155
|
-
'qcode': 'Object',
|
156
|
-
},
|
157
|
-
];
|
158
|
-
|
159
156
|
let fetchedArr = [];
|
160
157
|
fetch('https://nominatim.openstreetmap.org/search/berlin?format=json&addressdetails=1&limit=20').then(response => response.json()).then(data => fetchedArr = data
|
161
158
|
);
|
@@ -186,8 +183,8 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
186
183
|
this.state = {
|
187
184
|
value: [],
|
188
185
|
value2: [],
|
189
|
-
options:
|
190
|
-
options2:
|
186
|
+
options: options,
|
187
|
+
options2: options,
|
191
188
|
inputValue: '',
|
192
189
|
arr: []
|
193
190
|
}
|
@@ -228,21 +225,29 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
228
225
|
<div className='docs-page__content-row docs-page__content-row--no-margin'>
|
229
226
|
<div className='form__row'>
|
230
227
|
<TreeSelect
|
228
|
+
value={[{name: 'Item1'}, {name: 'Item2'}]}
|
229
|
+
getOptions={() => options}
|
230
|
+
kind={'synchronous'}
|
231
231
|
getId={(item) => item.name}
|
232
232
|
getLabel={(item) => item.name}
|
233
|
-
|
234
|
-
value={[{name: 'Item1'}, {name: 'Item2'}]}
|
233
|
+
getBackgroundColor={(item: any) => item.bgColor}
|
235
234
|
selectBranchWithChildren={true}
|
236
|
-
onChange={(e) => console.log(e)}
|
237
235
|
allowMultiple
|
238
|
-
kind={'synchronous'}
|
239
236
|
fullWidth
|
237
|
+
singleLevelSearch
|
238
|
+
required
|
240
239
|
info={'Info Message'}
|
241
240
|
error={'Error Message'}
|
242
|
-
required
|
243
241
|
label={'TreeSelect Label'}
|
244
|
-
singleLevelSearch
|
245
242
|
searchPlaceholder='Search...'
|
243
|
+
onChange={(e) => false}
|
244
|
+
valueTemplate={(item, Wrapper) => {
|
245
|
+
return (
|
246
|
+
<Wrapper backgroundColor={item.bgColor}>
|
247
|
+
<span>{item.name}</span>
|
248
|
+
</Wrapper>
|
249
|
+
);
|
250
|
+
}}
|
246
251
|
/>
|
247
252
|
</div>
|
248
253
|
</div>
|
@@ -250,21 +255,29 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
250
255
|
|
251
256
|
<Markup.ReactMarkupCode>{`
|
252
257
|
<TreeSelect
|
258
|
+
value={[{name: 'Item1'}, {name: 'Item2'}]}
|
259
|
+
getOptions={() => options}
|
260
|
+
kind={'synchronous'}
|
253
261
|
getId={(item) => item.name}
|
254
262
|
getLabel={(item) => item.name}
|
255
|
-
|
256
|
-
return itemArr2
|
257
|
-
}}
|
258
|
-
value={[{name: 'Item1'}, {name: 'Item2'}]}
|
263
|
+
getBackgroundColor={(item: any) => item.bgColor}
|
259
264
|
selectBranchWithChildren={true}
|
260
|
-
onChange={(e) => console.log(e)}
|
261
265
|
allowMultiple
|
262
|
-
kind={'synchronous'}
|
263
266
|
fullWidth
|
267
|
+
singleLevelSearch
|
268
|
+
required
|
264
269
|
info={'Info Message'}
|
265
270
|
error={'Error Message'}
|
266
|
-
required
|
267
271
|
label={'TreeSelect Label'}
|
272
|
+
searchPlaceholder='Search...'
|
273
|
+
onChange={(e) => false}
|
274
|
+
valueTemplate={(item, Wrapper) => {
|
275
|
+
return (
|
276
|
+
<Wrapper backgroundColor={item.bgColor}>
|
277
|
+
<span>{item.name}</span>
|
278
|
+
</Wrapper>
|
279
|
+
);
|
280
|
+
}}
|
268
281
|
/>
|
269
282
|
`}</Markup.ReactMarkupCode>
|
270
283
|
|
@@ -286,7 +299,6 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
286
299
|
}
|
287
300
|
getId={({qcode}) => qcode.display_name}
|
288
301
|
selectBranchWithChildren={false}
|
289
|
-
//optionTemplate={(item) => <span style={{color: 'blue'}}>{item.display_name}</span>}
|
290
302
|
allowMultiple={true}
|
291
303
|
/>
|
292
304
|
</div>
|
@@ -317,20 +329,23 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
317
329
|
<div className='docs-page__content-row docs-page__content-row--no-margin'>
|
318
330
|
<div className='form__row'>
|
319
331
|
<TreeSelect
|
332
|
+
getOptions={() => options2}
|
333
|
+
kind={'synchronous'}
|
320
334
|
getId={(item) => item.name}
|
321
335
|
getLabel={(item) => item.name}
|
336
|
+
getBackgroundColor={(item) => item.bgColor}
|
337
|
+
getBorderColor={(item) => item.border}
|
322
338
|
placeholder='Select one'
|
323
|
-
|
324
|
-
|
325
|
-
onChange={(e) => console.log(e)}
|
339
|
+
selectBranchWithChildren={true}
|
340
|
+
onChange={(e) => false}
|
326
341
|
optionTemplate={(item: any) => {
|
327
342
|
return <div>Label: {item.name}</div>
|
328
343
|
}}
|
329
|
-
valueTemplate={(item: any) => {
|
330
|
-
return <
|
344
|
+
valueTemplate={(item: any, Wrapper) => {
|
345
|
+
return <Wrapper borderColor={item.border}>
|
346
|
+
<span>{item.name}</span>
|
347
|
+
</Wrapper>
|
331
348
|
}}
|
332
|
-
//allowMultiple
|
333
|
-
//readOnly
|
334
349
|
/>
|
335
350
|
</div>
|
336
351
|
</div>
|
@@ -338,17 +353,22 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
338
353
|
|
339
354
|
<Markup.ReactMarkupCode>{`
|
340
355
|
<TreeSelect
|
356
|
+
getOptions={() => options2}
|
357
|
+
kind={'synchronous'}
|
341
358
|
getId={(item) => item.name}
|
342
359
|
getLabel={(item) => item.name}
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
360
|
+
getBackgroundColor={(item) => item.bgColor}
|
361
|
+
getBorderColor={(item) => item.border}
|
362
|
+
placeholder='Select one'
|
363
|
+
selectBranchWithChildren={true}
|
364
|
+
onChange={(e) => false}
|
347
365
|
optionTemplate={(item: any) => {
|
348
366
|
return <div>Label: {item.name}</div>
|
349
367
|
}}
|
350
|
-
valueTemplate={(item: any) => {
|
351
|
-
return <
|
368
|
+
valueTemplate={(item: any, Wrapper) => {
|
369
|
+
return <Wrapper borderColor={item.border}>
|
370
|
+
<span>{item.name}</span>
|
371
|
+
</Wrapper>
|
352
372
|
}}
|
353
373
|
/>
|
354
374
|
`}</Markup.ReactMarkupCode>
|
@@ -370,8 +390,10 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
370
390
|
<Prop name='searchPlaceholder' isRequired={false} type='string' default='/' description='Filter input placeholder.'/>
|
371
391
|
<Prop name='getLabel' isRequired={true} type='Function' default='/' description='Callback to invoke when value changes.'/>
|
372
392
|
<Prop name='getId' isRequired={true} type='Function' default='/' description='Callback to invoke when value changes.'/>
|
373
|
-
<Prop name='
|
374
|
-
<Prop name='
|
393
|
+
<Prop name='getBackgroundColor' isRequired={true} type='Function' default='/' description='Function to return background color of individual item in options.'/>
|
394
|
+
<Prop name='getBorderColor' isRequired={true} type='Function' default='/' description='Function to return border color of individual item in options in single-select mode.'/>
|
395
|
+
<Prop name='valueTemplate' isRequired={false} type='Function(item, Wrapper)' default='/' description='Function that gets an item in the value and returns the content for it.'/>
|
396
|
+
<Prop name='optionTemplate' isRequired={false} type='Function(item)' default='/' description='Function that gets the option and returns the content for it.'/>
|
375
397
|
<Prop name='searchOptions' isRequired={false} type='Function' default='/' description='The function will be called when a search is initiated from UI in asynchronous mode.'/>
|
376
398
|
<Prop name='onChange' isRequired={true} type='Function' default='/' description='Callback to invoke when value changes.'/>
|
377
399
|
<Prop name='label' isRequired={false} type='string' default='/' description='Input label'/>
|
package/package.json
CHANGED
@@ -13,5 +13,5 @@ interface IProps {
|
|
13
13
|
export declare class Label extends React.PureComponent<IProps> {
|
14
14
|
render(): JSX.Element;
|
15
15
|
}
|
16
|
-
export declare function getTextColor(backgroundColor: string): 'black' | 'white';
|
16
|
+
export declare function getTextColor(backgroundColor: string): 'black' | 'white' | undefined;
|
17
17
|
export {};
|
@@ -84,10 +84,15 @@ var Label = /** @class */ (function (_super) {
|
|
84
84
|
}(React.PureComponent));
|
85
85
|
exports.Label = Label;
|
86
86
|
function getTextColor(backgroundColor) {
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
if (backgroundColor) {
|
88
|
+
var r = parseInt(backgroundColor.substr(1, 2), 16);
|
89
|
+
var g = parseInt(backgroundColor.substr(3, 2), 16);
|
90
|
+
var b = parseInt(backgroundColor.substr(5, 2), 16);
|
91
|
+
var yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
|
92
|
+
return (yiq >= 128) ? 'black' : 'white';
|
93
|
+
}
|
94
|
+
else {
|
95
|
+
return;
|
96
|
+
}
|
92
97
|
}
|
93
98
|
exports.getTextColor = getTextColor;
|
@@ -50,7 +50,7 @@ var AuthoringFrame = /** @class */ (function (_super) {
|
|
50
50
|
this.props.main && (React.createElement(_1.AuthoringFrameMain, null, this.props.main)),
|
51
51
|
this.props.sidePanel && (React.createElement(_1.AuthoringFrameSidePanel, { opened: this.props.sidePanelOpen, pinned: this.props.sidePanelPinned }, this.props.sidePanel)),
|
52
52
|
this.props.sideOverlay && (React.createElement(_1.AuthoringFrameSidePanelOverlay, { opened: this.props.sideOverlayOpen }, this.props.sideOverlay)),
|
53
|
-
this.props.sideBar && (React.createElement(_1.AuthoringFrameRightBar,
|
53
|
+
this.props.sideBar && (React.createElement(_1.AuthoringFrameRightBar, { closed: this.props.sideBarClosed }, this.props.sideBar)),
|
54
54
|
this.props.overlayPanel && (React.createElement(_1.AuthoringFrameOverlay, null, this.props.overlayPanel))));
|
55
55
|
};
|
56
56
|
return AuthoringFrame;
|
@@ -1,8 +1,15 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
interface IProps {
|
3
3
|
children?: React.ReactNode;
|
4
|
+
closed?: boolean;
|
4
5
|
}
|
5
|
-
|
6
|
-
|
6
|
+
interface IState {
|
7
|
+
children?: React.ReactNode;
|
8
|
+
closed?: boolean;
|
9
|
+
}
|
10
|
+
export declare class AuthoringFrameRightBar extends React.PureComponent<IProps, IState> {
|
11
|
+
constructor(props: IProps);
|
12
|
+
componentDidUpdate(prevProps: Readonly<IProps>): void;
|
13
|
+
render(): false | JSX.Element;
|
7
14
|
}
|
8
15
|
export {};
|
@@ -38,11 +38,22 @@ exports.AuthoringFrameRightBar = void 0;
|
|
38
38
|
var React = __importStar(require("react"));
|
39
39
|
var AuthoringFrameRightBar = /** @class */ (function (_super) {
|
40
40
|
__extends(AuthoringFrameRightBar, _super);
|
41
|
-
function AuthoringFrameRightBar() {
|
42
|
-
|
41
|
+
function AuthoringFrameRightBar(props) {
|
42
|
+
var _this = _super.call(this, props) || this;
|
43
|
+
_this.state = {
|
44
|
+
closed: _this.props.closed ? _this.props.closed : false,
|
45
|
+
};
|
46
|
+
return _this;
|
43
47
|
}
|
48
|
+
AuthoringFrameRightBar.prototype.componentDidUpdate = function (prevProps) {
|
49
|
+
if (prevProps.closed !== this.props.closed) {
|
50
|
+
this.setState({
|
51
|
+
closed: this.props.closed,
|
52
|
+
});
|
53
|
+
}
|
54
|
+
};
|
44
55
|
AuthoringFrameRightBar.prototype.render = function () {
|
45
|
-
return (React.createElement("div", { className: "sd-editor-grid__sidetabs-bar" }, this.props.children));
|
56
|
+
return (!this.state.closed && React.createElement("div", { className: "sd-editor-grid__sidetabs-bar" }, this.props.children));
|
46
57
|
};
|
47
58
|
return AuthoringFrameRightBar;
|
48
59
|
}(React.PureComponent));
|
@@ -8,6 +8,7 @@ export interface IProps {
|
|
8
8
|
className?: string;
|
9
9
|
readOnly?: boolean;
|
10
10
|
showDragHandle?: 'always' | 'onHover' | 'none';
|
11
|
+
append?: boolean;
|
11
12
|
onDrag?(start: number, end: number): void;
|
12
13
|
onAddItem?(index: number, item?: IPropsArrayItem): void;
|
13
14
|
itemsDropdown?(index?: number): Array<IMenuItem | ISubmenu | IMenuGroup | 'divider'>;
|
@@ -55,6 +55,7 @@ var react_beautiful_dnd_1 = require("react-beautiful-dnd");
|
|
55
55
|
var Tooltip_1 = require("../Tooltip");
|
56
56
|
var Button_1 = require("../Button");
|
57
57
|
var Dropdown_1 = require("../Dropdown");
|
58
|
+
var react_dom_1 = __importDefault(require("react-dom"));
|
58
59
|
var reorder = function (list, startIndex, endIndex) {
|
59
60
|
var result = Array.from(list);
|
60
61
|
var removed = result.splice(startIndex, 1)[0];
|
@@ -114,13 +115,18 @@ var TableList = /** @class */ (function (_super) {
|
|
114
115
|
? this.props.dragAndDrop
|
115
116
|
? React.createElement(react_beautiful_dnd_1.DragDropContext, { onDragEnd: this.onDragEnd },
|
116
117
|
React.createElement(react_beautiful_dnd_1.Droppable, { droppableId: "droppable" }, function (provided, _snapshot) { return (React.createElement("div", __assign({ role: 'list', className: classes, ref: provided.innerRef }, provided.droppableProps),
|
117
|
-
_this.state.items.map(function (item, index) { return (React.createElement(react_beautiful_dnd_1.Draggable, { key: index, draggableId: "".concat(index), index: index }, function (provided2,
|
118
|
-
React.createElement(
|
119
|
-
|
120
|
-
: undefined, addItem: _this.props.addItem, itemsDropdown: function () { return _this.props.itemsDropdown
|
118
|
+
_this.state.items.map(function (item, index) { return (React.createElement(react_beautiful_dnd_1.Draggable, { key: index, draggableId: "".concat(index), index: index }, function (provided2, snapshot) { return (_this.props.append
|
119
|
+
? React.createElement(PortalItem, { provided: provided2, snapshot: snapshot, item: item, index: index, dragAndDrop: _this.props.dragAndDrop, showDragHandle: _this.props.showDragHandle, addItem: _this.props.addItem, onAddItem: function () { return _this.props.onAddItem
|
120
|
+
&& _this.props.onAddItem(index, item); }, itemsDropdown: function () { return _this.props.itemsDropdown
|
121
121
|
? _this.props.itemsDropdown(index)
|
122
|
-
: []; }
|
123
|
-
|
122
|
+
: []; } })
|
123
|
+
: React.createElement("div", __assign({ ref: provided2.innerRef }, provided2.draggableProps, provided2.dragHandleProps),
|
124
|
+
React.createElement(TableListItem, { dragAndDrop: _this.props.dragAndDrop, start: item.start, center: item.center, end: item.end, action: item.action, onClick: item.onClick ? item.onClick : undefined, onDoubleClick: item.onDoubleClick
|
125
|
+
? item.onDoubleClick
|
126
|
+
: undefined, addItem: _this.props.addItem, itemsDropdown: function () { return _this.props.itemsDropdown
|
127
|
+
? _this.props.itemsDropdown(index)
|
128
|
+
: []; }, hexColor: item.hexColor, locked: item.locked, positionLocked: item.positionLocked, onAddItem: function () { return _this.props.onAddItem
|
129
|
+
&& _this.props.onAddItem(index, item); }, showDragHandle: _this.props.showDragHandle }))); })); }),
|
124
130
|
provided.placeholder,
|
125
131
|
(_this.props.addItem && !_this.props.readOnly) &&
|
126
132
|
React.createElement("div", { className: "table-list__add-item table-list__item--margin" },
|
@@ -206,3 +212,25 @@ var TableListItem = /** @class */ (function (_super) {
|
|
206
212
|
return TableListItem;
|
207
213
|
}(React.PureComponent));
|
208
214
|
exports.TableListItem = TableListItem;
|
215
|
+
var PortalItem = /** @class */ (function (_super) {
|
216
|
+
__extends(PortalItem, _super);
|
217
|
+
function PortalItem() {
|
218
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
219
|
+
}
|
220
|
+
PortalItem.prototype.render = function () {
|
221
|
+
var _this = this;
|
222
|
+
var provided = this.props.provided;
|
223
|
+
var snapshot = this.props.snapshot;
|
224
|
+
var usePortal = snapshot.isDragging;
|
225
|
+
var child = (React.createElement("div", __assign({ ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps),
|
226
|
+
React.createElement(TableListItem, { dragAndDrop: this.props.dragAndDrop, start: this.props.item.start, center: this.props.item.center, end: this.props.item.end, action: this.props.item.action, onClick: this.props.item.onClick ? this.props.item.onClick : undefined, onDoubleClick: this.props.item.onDoubleClick
|
227
|
+
? this.props.item.onDoubleClick
|
228
|
+
: undefined, addItem: this.props.addItem, itemsDropdown: this.props.itemsDropdown, hexColor: this.props.item.hexColor, locked: this.props.item.locked, positionLocked: this.props.item.positionLocked, onAddItem: function () { return _this.props.onAddItem; }, showDragHandle: this.props.showDragHandle })));
|
229
|
+
if (!usePortal) {
|
230
|
+
return child;
|
231
|
+
}
|
232
|
+
// if dragging - put the item in a portal
|
233
|
+
return react_dom_1.default.createPortal(child, document.body);
|
234
|
+
};
|
235
|
+
return PortalItem;
|
236
|
+
}(React.PureComponent));
|
package/react/components/Menu.js
CHANGED
@@ -104,7 +104,7 @@ var Menu = /** @class */ (function (_super) {
|
|
104
104
|
Menu.prototype.render = function () {
|
105
105
|
var _this = this;
|
106
106
|
var _a;
|
107
|
-
return (React.createElement(
|
107
|
+
return (React.createElement(React.Fragment, null,
|
108
108
|
this.props.children(this.toggle),
|
109
109
|
React.createElement("div", { onKeyDown: function (event) {
|
110
110
|
if (event.key === 'Escape') {
|
@@ -34,8 +34,10 @@ interface IPropsBase<T> {
|
|
34
34
|
disabled?: boolean;
|
35
35
|
getLabel(item: T): string;
|
36
36
|
getId(item: T): string;
|
37
|
+
getBackgroundColor?(item: T): string;
|
38
|
+
getBorderColor?(item: T): string;
|
37
39
|
optionTemplate?(item: T): React.ComponentType<T> | JSX.Element;
|
38
|
-
valueTemplate?(item: T): React.ComponentType<T> | JSX.Element;
|
40
|
+
valueTemplate?(item: T, Wrapper: any): React.ComponentType<T> | JSX.Element;
|
39
41
|
onChange(e: Array<T>): void;
|
40
42
|
}
|
41
43
|
interface IPropsSync<T> extends IPropsBase<T> {
|
@@ -55,6 +55,7 @@ var debounce_1 = __importDefault(require("lodash/debounce"));
|
|
55
55
|
var Form_1 = require("./Form");
|
56
56
|
var core_1 = require("@popperjs/core");
|
57
57
|
var lodash_1 = require("lodash");
|
58
|
+
var Label_1 = require("./Label");
|
58
59
|
var TreeSelect = /** @class */ (function (_super) {
|
59
60
|
__extends(TreeSelect, _super);
|
60
61
|
function TreeSelect(props) {
|
@@ -322,10 +323,15 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
322
323
|
event.stopPropagation();
|
323
324
|
_this.handleTree(event, option);
|
324
325
|
} },
|
325
|
-
_this.props.
|
326
|
+
_this.props.getBorderColor
|
327
|
+
&& React.createElement("div", { className: "item-border", style: { backgroundColor: _this.props.getBorderColor(option.value) } }),
|
328
|
+
React.createElement("span", { style: _this.props.getBackgroundColor
|
329
|
+
? { backgroundColor: _this.props.getBackgroundColor(option.value),
|
330
|
+
color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)) }
|
331
|
+
: undefined, className: 'suggestion-item--bgcolor'
|
332
|
+
+ (selectedItem ? ' suggestion-item--disabled' : '') }, _this.props.optionTemplate
|
326
333
|
? _this.props.optionTemplate(option.value)
|
327
|
-
:
|
328
|
-
? 'suggestion-item--disabled' : undefined }, _this.props.getLabel(option.value)),
|
334
|
+
: _this.props.getLabel(option.value)),
|
329
335
|
option.children && React.createElement("span", { className: "suggestion-item__icon" },
|
330
336
|
React.createElement(Icon_1.Icon, { name: "chevron-right-thin" })));
|
331
337
|
});
|
@@ -390,20 +396,29 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
390
396
|
|| React.createElement("button", { ref: this.openDropdownRef, className: "tags-input__add-button", onClick: function () { return _this.setState({ openDropdown: !_this.state.openDropdown }); } },
|
391
397
|
React.createElement("i", { className: "icon-plus-large" })),
|
392
398
|
React.createElement("ul", { className: "tags-input__tag-list" }, this.state.value.map(function (item, i) {
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
399
|
+
var Wrapper = function (_a) {
|
400
|
+
var backgroundColor = _a.backgroundColor, children = _a.children;
|
401
|
+
return (React.createElement("li", { className: "tags-input__tag-item tags-input__tag-item--multi-select"
|
402
|
+
+ (_this.props.readOnly ? ' tags-input__tag-item--readonly' : ''), onClick: function () { return !_this.props.readOnly && _this.removeClick(i); }, style: _this.props.valueTemplate
|
403
|
+
? { backgroundColor: backgroundColor }
|
404
|
+
: _this.props.getBackgroundColor
|
405
|
+
&& { backgroundColor: _this.props.getBackgroundColor(item) } },
|
406
|
+
React.createElement("span", { style: { color: backgroundColor
|
407
|
+
? (0, Label_1.getTextColor)(backgroundColor)
|
408
|
+
: _this.props.getBackgroundColor
|
409
|
+
&& (0, Label_1.getTextColor)(_this.props.getBackgroundColor(item)) }, className: "tags-input__helper-box" },
|
410
|
+
children,
|
411
|
+
!_this.props.readOnly && React.createElement("span", { className: "tags-input__remove-button" },
|
412
|
+
React.createElement(Icon_1.Icon, { name: "close-small" })))));
|
413
|
+
};
|
414
|
+
return (React.createElement(React.Fragment, { key: i }, _this.props.valueTemplate
|
415
|
+
? _this.props.valueTemplate(item, Wrapper)
|
416
|
+
: React.createElement(Wrapper, null,
|
417
|
+
React.createElement("span", null, _this.props.getLabel(item)))));
|
403
418
|
})),
|
404
419
|
this.state.value.length > 0
|
405
420
|
? this.props.readOnly
|
406
|
-
|| React.createElement("button", { className: "tags-input__remove-value", onClick: function () { return _this.setState({ value: [] }); } },
|
421
|
+
|| React.createElement("button", { className: "tags-input__remove-value", style: { position: 'relative', bottom: '2px' }, onClick: function () { return _this.setState({ value: [] }); } },
|
407
422
|
React.createElement(Icon_1.Icon, { name: 'remove-sign' })) : null)
|
408
423
|
: React.createElement("div", { className: "tags-input__tags" },
|
409
424
|
this.props.readOnly
|
@@ -412,16 +427,24 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
412
427
|
+ (this.props.readOnly ? ' tags-input__tag-item--readonly' : '') },
|
413
428
|
React.createElement("span", { className: "tags-input__placeholder" }, this.props.placeholder)),
|
414
429
|
this.state.value.map(function (item, i) {
|
415
|
-
|
416
|
-
|
430
|
+
var Wrapper = function (_a) {
|
431
|
+
var backgroundColor = _a.backgroundColor, borderColor = _a.borderColor, children = _a.children;
|
432
|
+
return (React.createElement("span", { className: 'tags-input__single-item'
|
417
433
|
+ (_this.props.readOnly ? ' tags-input__tag-item--readonly' : ''), onClick: function () { return _this.props.readOnly || _this.removeClick(i); } },
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
434
|
+
_this.props.getBorderColor
|
435
|
+
&& React.createElement("div", { className: "item-border item-border-selected", style: borderColor
|
436
|
+
? { backgroundColor: borderColor }
|
437
|
+
: { backgroundColor: _this.props.getBorderColor(item) } }),
|
438
|
+
React.createElement("span", { style: { color: backgroundColor && (0, Label_1.getTextColor)(backgroundColor) }, className: "tags-input__helper-box" },
|
439
|
+
React.createElement("span", { className: backgroundColor && "tags-input__tag-item", style: { backgroundColor: backgroundColor, margin: 0 } }, children),
|
422
440
|
_this.props.readOnly
|
423
441
|
|| React.createElement("span", { className: "tags-input__remove-button" },
|
424
442
|
React.createElement(Icon_1.Icon, { name: 'remove-sign' })))));
|
443
|
+
};
|
444
|
+
return React.createElement(React.Fragment, { key: i }, _this.props.valueTemplate
|
445
|
+
? _this.props.valueTemplate(item, Wrapper)
|
446
|
+
: React.createElement(Wrapper, null,
|
447
|
+
React.createElement("span", null, _this.props.getLabel(item))));
|
425
448
|
})),
|
426
449
|
this.state.openDropdown
|
427
450
|
&& React.createElement("div", { className: "autocomplete autocomplete--multi-select" + (this.props.width === 'medium' ? ' autocomplete--fixed-width' : ''), ref: this.dropdownRef },
|
@@ -479,10 +502,14 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
479
502
|
event.stopPropagation();
|
480
503
|
_this.handleTree(event, option);
|
481
504
|
} },
|
482
|
-
_this.props.
|
505
|
+
(_this.props.getBorderColor && !_this.props.allowMultiple) && React.createElement("div", { className: "item-border", style: { backgroundColor: _this.props.getBorderColor(option.value) } }),
|
506
|
+
React.createElement("span", { style: (_this.props.getBackgroundColor && option.value)
|
507
|
+
? { backgroundColor: _this.props.getBackgroundColor(option.value),
|
508
|
+
color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)) }
|
509
|
+
: undefined, className: 'suggestion-item--bgcolor'
|
510
|
+
+ (selectedItem ? ' suggestion-item--disabled' : '') }, _this.props.optionTemplate
|
483
511
|
? _this.props.optionTemplate(option.value)
|
484
|
-
:
|
485
|
-
? 'suggestion-item--disabled' : undefined }, _this.props.getLabel(option.value)),
|
512
|
+
: _this.props.getLabel(option.value)),
|
486
513
|
option.children && React.createElement("span", { className: "suggestion-item__icon" },
|
487
514
|
React.createElement(Icon_1.Icon, { name: "chevron-right-thin" }))));
|
488
515
|
})) : null
|