@kaspernj/api-maker 1.0.408 → 1.0.409

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": "@kaspernj/api-maker",
3
- "version": "1.0.408",
3
+ "version": "1.0.409",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
@@ -54,7 +54,7 @@ export default memo(shapeComponent(class ApiMakerBootstrapSortLink extends BaseC
54
54
 
55
55
  render () {
56
56
  const LinkComponent = this.linkComponent()
57
- const {attribute, className, defaultParams, linkComponent, onChanged, query, title, ...restProps} = this.props
57
+ const {attribute, className, defaultParams, linkComponent, onChanged, query, textProps, title, ...restProps} = this.props
58
58
 
59
59
  return (
60
60
  <LinkComponent
@@ -67,7 +67,7 @@ export default memo(shapeComponent(class ApiMakerBootstrapSortLink extends BaseC
67
67
  to={this.href()}
68
68
  {...restProps}
69
69
  >
70
- <Text>
70
+ <Text {...textProps}>
71
71
  {this.title()}
72
72
  </Text>
73
73
  </LinkComponent>
@@ -34,6 +34,7 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
34
34
  render() {
35
35
  const {column, table, tableSettingColumn, width} = this.p
36
36
  const {defaultParams} = table.props
37
+ const {styleForHeader, styleForHeaderText} = table.tt
37
38
  const {query} = digs(table.collection, "query")
38
39
 
39
40
  return (
@@ -43,7 +44,7 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
43
44
  identifier: tableSettingColumn.identifier()
44
45
  }}
45
46
  onLayout={this.tt.onLayout}
46
- style={{width: `${width}%`}}
47
+ style={styleForHeader({style: {width: `${width}%`}})}
47
48
  {...table.columnProps(column)}
48
49
  >
49
50
  <View style={{display: "flex", flexDirection: "row", alignItems: "center"}}>
@@ -53,6 +54,7 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
53
54
  defaultParams={defaultParams}
54
55
  query={query}
55
56
  style={{whiteSpace: "nowrap", overflow: "hidden"}}
57
+ textProps={{ellipsizeMode: "clip", numberOfLines: 1, style: styleForHeaderText()}}
56
58
  title={table.headerLabelForColumn(column)}
57
59
  />
58
60
  }
@@ -21,6 +21,7 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
21
21
  static propTypes = propTypesExact({
22
22
  cacheKey: PropTypes.string.isRequired,
23
23
  columnWidths: PropTypes.object.isRequired,
24
+ index: PropTypes.number.isRequired,
24
25
  isSmallScreen: PropTypes.bool.isRequired,
25
26
  model: PropTypes.object.isRequired,
26
27
  liveTable: PropTypes.object.isRequired,
@@ -29,10 +30,12 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
29
30
  })
30
31
 
31
32
  render() {
32
- const {model} = this.p
33
- const {modelClass, workplace} = this.p.liveTable.p
34
- const {actionsContent, columnsContent, destroyEnabled, editModelPath, viewModelPath} = this.p.liveTable.props
35
- const {columns, currentWorkplace} = this.p.liveTable.state
33
+ const {index, liveTable, model} = this.p
34
+ const {modelClass, workplace} = liveTable.p
35
+ const {actionsContent, destroyEnabled, editModelPath, viewModelPath} = liveTable.props
36
+ const {columns, currentWorkplace} = liveTable.state
37
+ const {styleForColumn, styleForRow} = liveTable.tt
38
+ const even = index % 2 == 0
36
39
 
37
40
  this.modelCallbackArgs = this._modelCallbackArgs() // 'model' can change so this needs to be re-cached for every render
38
41
 
@@ -47,9 +50,12 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
47
50
  }
48
51
 
49
52
  return (
50
- <Row dataSet={{class: `${inflection.dasherize(modelClass.modelClassData().paramKey)}-row`, modelId: model.id()}}>
53
+ <Row
54
+ dataSet={{class: `${inflection.dasherize(modelClass.modelClassData().paramKey)}-row`, modelId: model.id()}}
55
+ style={styleForRow({even})}
56
+ >
51
57
  {workplace &&
52
- <Column dataSet={{class: "workplace-column"}} style={{width: 25}}>
58
+ <Column dataSet={{class: "workplace-column"}} style={styleForColumn({even, style: {width: 41}})}>
53
59
  <WorkerPluginsCheckbox
54
60
  currentWorkplace={currentWorkplace}
55
61
  model={model}
@@ -57,9 +63,8 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
57
63
  />
58
64
  </Column>
59
65
  }
60
- {columns && this.columnsContentFromColumns(model)}
61
- {!columns && columnsContent && columnsContent(this.modelCallbackArgs)}
62
- <Column dataSet={{class: "actions-column"}} style={{flexDirection: "row"}}>
66
+ {columns && this.columnsContentFromColumns(model, even)}
67
+ <Column dataSet={{class: "actions-column"}} style={styleForColumn({even, style: {flexDirection: "row"}})}>
63
68
  {actionsContent && actionsContent(this.modelCallbackArgs)}
64
69
  {viewPath &&
65
70
  <Link dataSet={{class: "view-button"}} to={viewPath}>
@@ -81,7 +86,7 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
81
86
  )
82
87
  }
83
88
 
84
- columnClassNamesForColumn (column) {
89
+ columnClassNamesForColumn(column) {
85
90
  const classNames = ["table--column"]
86
91
 
87
92
  if (column.commonProps && column.commonProps.className) classNames.push(column.commonProps.className)
@@ -90,17 +95,17 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
90
95
  return classNames
91
96
  }
92
97
 
93
- columnsContentFromColumns (model) {
98
+ columnsContentFromColumns(model, even) {
94
99
  const {isSmallScreen, preparedColumns} = this.p
95
100
 
96
- return preparedColumns?.map(({column, tableSettingColumn, width}) => columnVisible(column, tableSettingColumn) &&
101
+ return preparedColumns?.map(({column, tableSettingColumn, width}, columnIndex) => columnVisible(column, tableSettingColumn) &&
97
102
  <Column
98
103
  dataSet={{
99
104
  class: classNames(this.columnClassNamesForColumn(column)),
100
105
  identifier: columnIdentifier(column)
101
106
  }}
102
107
  key={columnIdentifier(column)}
103
- style={{width: `${width}%`}}
108
+ style={this.p.liveTable.styleForColumn({column, columnIndex, even, style: {width: `${width}%`}})}
104
109
  {...this.props.liveTable.columnProps(column)}
105
110
  >
106
111
  {isSmallScreen &&
@@ -55,7 +55,6 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
55
55
  className: PropTypes.string,
56
56
  collection: PropTypes.instanceOf(Collection),
57
57
  columns: PropTypes.oneOfType([PropTypes.array, PropTypes.func]),
58
- columnsContent: PropTypes.func,
59
58
  controls: PropTypes.func,
60
59
  currentUser: PropTypes.object,
61
60
  defaultDateFormatName: PropTypes.string,
@@ -297,7 +296,6 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
297
296
  className,
298
297
  collection,
299
298
  columns,
300
- columnsContent,
301
299
  controls,
302
300
  currentUser,
303
301
  defaultDateFormatName,
@@ -351,12 +349,14 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
351
349
  const flatList = (
352
350
  <FlatList
353
351
  data={models}
354
- dataSet={{class: className}}
352
+ dataSet={{class: classNames("api-maker--table", className)}}
355
353
  extraData={this.s.lastUpdate}
356
354
  keyExtractor={this.tt.keyExtrator}
357
355
  ListHeaderComponent={this.tt.listHeaderComponent}
358
356
  onLayout={this.tt.onFlatListLayout}
359
357
  renderItem={this.tt.renderItem}
358
+ showsHorizontalScrollIndicator
359
+ style={{overflowX: "auto"}}
360
360
  {...restProps}
361
361
  />
362
362
  )
@@ -453,9 +453,9 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
453
453
  const {query} = digs(this.collection, "query")
454
454
 
455
455
  return (
456
- <Row dataSet={{class: "live-table-header-row"}}>
456
+ <Row dataSet={{class: "live-table-header-row"}} style={this.styleForRow()}>
457
457
  {workplace && currentWorkplace &&
458
- <Header style={{width: 25}}>
458
+ <Header style={this.styleForHeader({style: {width: 41}})}>
459
459
  <WorkerPluginsCheckAllCheckbox
460
460
  currentWorkplace={currentWorkplace}
461
461
  query={query}
@@ -464,18 +464,19 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
464
464
  </Header>
465
465
  }
466
466
  {this.headersContentFromColumns()}
467
- <Header />
467
+ <Header style={this.styleForHeader({style: {}})} />
468
468
  </Row>
469
469
  )
470
470
  }
471
471
 
472
- renderItem = ({item: model}) => {
472
+ renderItem = ({index, item: model}) => {
473
473
  const {preparedColumns, tableSettingFullCacheKey} = this.s
474
474
 
475
475
  return (
476
476
  <ModelRow
477
477
  cacheKey={model.cacheKey()}
478
478
  columnWidths={this.columnWidths()}
479
+ index={index}
479
480
  isSmallScreen={this.tt.isSmallScreen}
480
481
  key={model.id()}
481
482
  liveTable={this}
@@ -486,6 +487,49 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
486
487
  )
487
488
  }
488
489
 
490
+ styleForColumn({column, columnIndex, even, style}) {
491
+ const actualStyle = Object.assign(
492
+ {
493
+ padding: 8,
494
+ backgroundColor: even ? "#f5f5f5" : undefined,
495
+ },
496
+ style
497
+ )
498
+
499
+ return actualStyle
500
+ }
501
+
502
+ styleForHeader({column, columnIndex, style}) {
503
+ const actualStyle = Object.assign(
504
+ {
505
+ padding: 8
506
+ },
507
+ style
508
+ )
509
+
510
+ return actualStyle
511
+ }
512
+
513
+ styleForHeaderText() {
514
+ const actualStyle = {fontWeight: "bold"}
515
+
516
+ return actualStyle
517
+ }
518
+
519
+ styleForRow({even} = {}) {
520
+ const actualStyle = {
521
+ flex: 1,
522
+ alignItems: "center",
523
+ borderBottom: "1px solid #f2f2f2"
524
+ }
525
+
526
+ if (even) {
527
+ actualStyle.backgroundColor = "#f5f5f5"
528
+ }
529
+
530
+ return actualStyle
531
+ }
532
+
489
533
  tableControls() {
490
534
  const {controls} = this.props
491
535
  const {showSettings} = this.s