@performant-software/semantic-components 1.0.12 → 1.0.13-beta.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.
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Items.js +48 -28
- package/types/components/Items.js.flow +48 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@performant-software/semantic-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13-beta.1",
|
|
4
4
|
"description": "A package of shared components based on the Semantic UI Framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./build/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build": "webpack --mode production && flow-copy-source -v src types"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@performant-software/shared-components": "^1.0.
|
|
15
|
+
"@performant-software/shared-components": "^1.0.13-beta.1",
|
|
16
16
|
"@react-google-maps/api": "^2.8.1",
|
|
17
17
|
"axios": "^0.26.1",
|
|
18
18
|
"i18next": "^19.4.4",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"react-dnd": "^11.1.3",
|
|
22
22
|
"react-dnd-html5-backend": "^11.1.3",
|
|
23
23
|
"react-i18next": "^11.4.0",
|
|
24
|
-
"react-pdf": "^
|
|
24
|
+
"react-pdf": "^7.1.1",
|
|
25
25
|
"react-syntax-highlighter": "^15.5.0",
|
|
26
26
|
"react-uuid": "^1.0.2",
|
|
27
27
|
"semantic-ui-less": "2.4.1",
|
package/src/components/Items.js
CHANGED
|
@@ -35,6 +35,11 @@ type Props = ListProps & {
|
|
|
35
35
|
*/
|
|
36
36
|
items: Array<any>,
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* If true, the list items will be formatted as a link.
|
|
40
|
+
*/
|
|
41
|
+
link?: boolean,
|
|
42
|
+
|
|
38
43
|
/**
|
|
39
44
|
* Callback fired when a table row is dragged
|
|
40
45
|
*/
|
|
@@ -56,6 +61,11 @@ type Props = ListProps & {
|
|
|
56
61
|
*/
|
|
57
62
|
renderAdditionalContent?: (item: any) => Element<any>,
|
|
58
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Renders the container element for passed item.
|
|
66
|
+
*/
|
|
67
|
+
renderContainer?: (item: any, children: Element<any>) => ComponentType<any>,
|
|
68
|
+
|
|
59
69
|
/**
|
|
60
70
|
* A function that returns a JSX element to render as the card description.
|
|
61
71
|
* See Semantic UI <a href="https://react.semantic-ui.com/views/card/">Card</a>.
|
|
@@ -197,9 +207,10 @@ class ItemsClass extends Component<Props, {}> {
|
|
|
197
207
|
* @returns {*}
|
|
198
208
|
*/
|
|
199
209
|
renderCard(item, index) {
|
|
200
|
-
|
|
210
|
+
let card = (
|
|
201
211
|
<Card
|
|
202
212
|
key={item.id || index}
|
|
213
|
+
link={this.props.link}
|
|
203
214
|
>
|
|
204
215
|
{ this.props.renderImage && this.props.renderImage(item) }
|
|
205
216
|
<Card.Content>
|
|
@@ -255,21 +266,25 @@ class ItemsClass extends Component<Props, {}> {
|
|
|
255
266
|
</Card>
|
|
256
267
|
);
|
|
257
268
|
|
|
258
|
-
if (
|
|
259
|
-
|
|
269
|
+
if (this.props.onDrag) {
|
|
270
|
+
card = (
|
|
271
|
+
<Draggable
|
|
272
|
+
id={item.id || item.uid}
|
|
273
|
+
index={index}
|
|
274
|
+
item={item}
|
|
275
|
+
key={item.id || item.uid}
|
|
276
|
+
onDrag={this.props.onDrag.bind(this)}
|
|
277
|
+
>
|
|
278
|
+
{ card }
|
|
279
|
+
</Draggable>
|
|
280
|
+
);
|
|
260
281
|
}
|
|
261
282
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
key={item.id || item.uid}
|
|
268
|
-
onDrag={this.props.onDrag.bind(this)}
|
|
269
|
-
>
|
|
270
|
-
{ card }
|
|
271
|
-
</Draggable>
|
|
272
|
-
);
|
|
283
|
+
if (this.props.renderContainer) {
|
|
284
|
+
card = this.props.renderContainer(item, card);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return card;
|
|
273
288
|
}
|
|
274
289
|
|
|
275
290
|
/**
|
|
@@ -330,7 +345,7 @@ class ItemsClass extends Component<Props, {}> {
|
|
|
330
345
|
* @returns {*}
|
|
331
346
|
*/
|
|
332
347
|
renderItem(item, index) {
|
|
333
|
-
|
|
348
|
+
let listItem = (
|
|
334
349
|
<Item
|
|
335
350
|
key={item.id || index}
|
|
336
351
|
>
|
|
@@ -387,21 +402,25 @@ class ItemsClass extends Component<Props, {}> {
|
|
|
387
402
|
</Item>
|
|
388
403
|
);
|
|
389
404
|
|
|
390
|
-
if (
|
|
391
|
-
|
|
405
|
+
if (this.props.onDrag) {
|
|
406
|
+
listItem = (
|
|
407
|
+
<Draggable
|
|
408
|
+
id={item.id || item.uid}
|
|
409
|
+
index={index}
|
|
410
|
+
item={item}
|
|
411
|
+
key={item.id || item.uid}
|
|
412
|
+
onDrag={this.props.onDrag.bind(this)}
|
|
413
|
+
>
|
|
414
|
+
{ listItem }
|
|
415
|
+
</Draggable>
|
|
416
|
+
);
|
|
392
417
|
}
|
|
393
418
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
key={item.id || item.uid}
|
|
400
|
-
onDrag={this.props.onDrag.bind(this)}
|
|
401
|
-
>
|
|
402
|
-
{ listItem }
|
|
403
|
-
</Draggable>
|
|
404
|
-
);
|
|
419
|
+
if (this.props.renderContainer) {
|
|
420
|
+
listItem = this.props.renderContainer(item, listItem);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return listItem;
|
|
405
424
|
}
|
|
406
425
|
|
|
407
426
|
/**
|
|
@@ -417,6 +436,7 @@ class ItemsClass extends Component<Props, {}> {
|
|
|
417
436
|
return (
|
|
418
437
|
<Item.Group
|
|
419
438
|
divided
|
|
439
|
+
link={this.props.link}
|
|
420
440
|
relaxed='very'
|
|
421
441
|
>
|
|
422
442
|
{ _.map(this.props.items, this.renderItem.bind(this)) }
|
|
@@ -35,6 +35,11 @@ type Props = ListProps & {
|
|
|
35
35
|
*/
|
|
36
36
|
items: Array<any>,
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* If true, the list items will be formatted as a link.
|
|
40
|
+
*/
|
|
41
|
+
link?: boolean,
|
|
42
|
+
|
|
38
43
|
/**
|
|
39
44
|
* Callback fired when a table row is dragged
|
|
40
45
|
*/
|
|
@@ -56,6 +61,11 @@ type Props = ListProps & {
|
|
|
56
61
|
*/
|
|
57
62
|
renderAdditionalContent?: (item: any) => Element<any>,
|
|
58
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Renders the container element for passed item.
|
|
66
|
+
*/
|
|
67
|
+
renderContainer?: (item: any, children: Element<any>) => ComponentType<any>,
|
|
68
|
+
|
|
59
69
|
/**
|
|
60
70
|
* A function that returns a JSX element to render as the card description.
|
|
61
71
|
* See Semantic UI <a href="https://react.semantic-ui.com/views/card/">Card</a>.
|
|
@@ -197,9 +207,10 @@ class ItemsClass extends Component<Props, {}> {
|
|
|
197
207
|
* @returns {*}
|
|
198
208
|
*/
|
|
199
209
|
renderCard(item, index) {
|
|
200
|
-
|
|
210
|
+
let card = (
|
|
201
211
|
<Card
|
|
202
212
|
key={item.id || index}
|
|
213
|
+
link={this.props.link}
|
|
203
214
|
>
|
|
204
215
|
{ this.props.renderImage && this.props.renderImage(item) }
|
|
205
216
|
<Card.Content>
|
|
@@ -255,21 +266,25 @@ class ItemsClass extends Component<Props, {}> {
|
|
|
255
266
|
</Card>
|
|
256
267
|
);
|
|
257
268
|
|
|
258
|
-
if (
|
|
259
|
-
|
|
269
|
+
if (this.props.onDrag) {
|
|
270
|
+
card = (
|
|
271
|
+
<Draggable
|
|
272
|
+
id={item.id || item.uid}
|
|
273
|
+
index={index}
|
|
274
|
+
item={item}
|
|
275
|
+
key={item.id || item.uid}
|
|
276
|
+
onDrag={this.props.onDrag.bind(this)}
|
|
277
|
+
>
|
|
278
|
+
{ card }
|
|
279
|
+
</Draggable>
|
|
280
|
+
);
|
|
260
281
|
}
|
|
261
282
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
key={item.id || item.uid}
|
|
268
|
-
onDrag={this.props.onDrag.bind(this)}
|
|
269
|
-
>
|
|
270
|
-
{ card }
|
|
271
|
-
</Draggable>
|
|
272
|
-
);
|
|
283
|
+
if (this.props.renderContainer) {
|
|
284
|
+
card = this.props.renderContainer(item, card);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return card;
|
|
273
288
|
}
|
|
274
289
|
|
|
275
290
|
/**
|
|
@@ -330,7 +345,7 @@ class ItemsClass extends Component<Props, {}> {
|
|
|
330
345
|
* @returns {*}
|
|
331
346
|
*/
|
|
332
347
|
renderItem(item, index) {
|
|
333
|
-
|
|
348
|
+
let listItem = (
|
|
334
349
|
<Item
|
|
335
350
|
key={item.id || index}
|
|
336
351
|
>
|
|
@@ -387,21 +402,25 @@ class ItemsClass extends Component<Props, {}> {
|
|
|
387
402
|
</Item>
|
|
388
403
|
);
|
|
389
404
|
|
|
390
|
-
if (
|
|
391
|
-
|
|
405
|
+
if (this.props.onDrag) {
|
|
406
|
+
listItem = (
|
|
407
|
+
<Draggable
|
|
408
|
+
id={item.id || item.uid}
|
|
409
|
+
index={index}
|
|
410
|
+
item={item}
|
|
411
|
+
key={item.id || item.uid}
|
|
412
|
+
onDrag={this.props.onDrag.bind(this)}
|
|
413
|
+
>
|
|
414
|
+
{ listItem }
|
|
415
|
+
</Draggable>
|
|
416
|
+
);
|
|
392
417
|
}
|
|
393
418
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
key={item.id || item.uid}
|
|
400
|
-
onDrag={this.props.onDrag.bind(this)}
|
|
401
|
-
>
|
|
402
|
-
{ listItem }
|
|
403
|
-
</Draggable>
|
|
404
|
-
);
|
|
419
|
+
if (this.props.renderContainer) {
|
|
420
|
+
listItem = this.props.renderContainer(item, listItem);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return listItem;
|
|
405
424
|
}
|
|
406
425
|
|
|
407
426
|
/**
|
|
@@ -417,6 +436,7 @@ class ItemsClass extends Component<Props, {}> {
|
|
|
417
436
|
return (
|
|
418
437
|
<Item.Group
|
|
419
438
|
divided
|
|
439
|
+
link={this.props.link}
|
|
420
440
|
relaxed='very'
|
|
421
441
|
>
|
|
422
442
|
{ _.map(this.props.items, this.renderItem.bind(this)) }
|