@kaspernj/api-maker 1.0.409 → 1.0.410

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.409",
3
+ "version": "1.0.410",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
@@ -3,7 +3,7 @@ import classNames from "classnames"
3
3
  import {digs} from "diggerize"
4
4
  import Header from "./components/header"
5
5
  import {memo} from "react"
6
- import {Pressable, Text, View} from "react-native"
6
+ import {Platform, Pressable, Text, View} from "react-native"
7
7
  import PropTypes from "prop-types"
8
8
  import propTypesExact from "prop-types-exact"
9
9
  import {shapeComponent} from "set-state-compare/src/shape-component"
@@ -14,6 +14,7 @@ import Widths from "./widths"
14
14
  export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseComponent {
15
15
  static propTypes = propTypesExact({
16
16
  column: PropTypes.object.isRequired,
17
+ resizing: PropTypes.bool.isRequired,
17
18
  table: PropTypes.object.isRequired,
18
19
  tableSettingColumn: PropTypes.object.isRequired,
19
20
  width: PropTypes.number.isRequired,
@@ -32,7 +33,7 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
32
33
  }
33
34
 
34
35
  render() {
35
- const {column, table, tableSettingColumn, width} = this.p
36
+ const {column, resizing, table, tableSettingColumn, width} = this.p
36
37
  const {defaultParams} = table.props
37
38
  const {styleForHeader, styleForHeaderText} = table.tt
38
39
  const {query} = digs(table.collection, "query")
@@ -44,7 +45,10 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
44
45
  identifier: tableSettingColumn.identifier()
45
46
  }}
46
47
  onLayout={this.tt.onLayout}
47
- style={styleForHeader({style: {width: `${width}%`}})}
48
+ style={styleForHeader({style: {
49
+ cursor: resizing ? "col-resize" : undefined,
50
+ width: `${width}%`
51
+ }})}
48
52
  {...table.columnProps(column)}
49
53
  >
50
54
  <View style={{display: "flex", flexDirection: "row", alignItems: "center"}}>
@@ -63,12 +67,20 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
63
67
  {table.headerLabelForColumn(column)}
64
68
  </Text>
65
69
  }
66
- <Pressable onPressIn={this.tt.onResizePressIn} style={{marginLeft: "auto", cursor: "col-resize"}}>
67
- <Text>
68
- |
69
- </Text>
70
- </Pressable>
71
70
  </View>
71
+ <Pressable
72
+ onMouseDown={Platform.OS == "web" ? this.tt.onResizeMouseDown : undefined}
73
+ onPressIn={this.tt.onResizePressIn}
74
+ style={{
75
+ position: "absolute",
76
+ top: 0,
77
+ right: 0,
78
+ width: 10,
79
+ height: "100%",
80
+ cursor: "col-resize",
81
+ zIndex: 9999
82
+ }}
83
+ />
72
84
  </Header>
73
85
  )
74
86
  }
@@ -81,12 +93,29 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
81
93
 
82
94
  onResizeEnd = async () => {
83
95
  this.setState({cursorX: undefined, resizing: false})
96
+ this.p.table.setState({resizing: false})
84
97
 
85
98
  const width = this.p.widths.getWidthOfColumn(this.p.tableSettingColumn.identifier())
86
99
 
87
100
  await this.p.tableSettingColumn.update({width})
88
101
  }
89
102
 
103
+ // Otherwise text is selectable on web
104
+ onResizeMouseDown = (e) => {
105
+ e.preventDefault()
106
+ e.stopPropagation()
107
+
108
+ const originalWidth = this.currentWidth
109
+ const cursorX = e.nativeEvent.pageX
110
+
111
+ this.setState({
112
+ cursorX,
113
+ originalWidth,
114
+ resizing: true
115
+ })
116
+ this.p.table.setState({resizing: true})
117
+ }
118
+
90
119
  onResizePressIn = (e) => {
91
120
  e.preventDefault()
92
121
  e.stopPropagation()
@@ -99,6 +128,7 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
99
128
  originalWidth,
100
129
  resizing: true
101
130
  })
131
+ this.p.table.setState({resizing: true})
102
132
  }
103
133
 
104
134
  onWindowMouseMove = (e) => {
@@ -64,7 +64,7 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
64
64
  </Column>
65
65
  }
66
66
  {columns && this.columnsContentFromColumns(model, even)}
67
- <Column dataSet={{class: "actions-column"}} style={styleForColumn({even, style: {flexDirection: "row"}})}>
67
+ <Column dataSet={{class: "actions-column"}} style={styleForColumn({even, style: {flexDirection: "row"}, type: "actions"})}>
68
68
  {actionsContent && actionsContent(this.modelCallbackArgs)}
69
69
  {viewPath &&
70
70
  <Link dataSet={{class: "view-button"}} to={viewPath}>
@@ -115,6 +115,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
115
115
  queryQName: () => `${queryName}_q`,
116
116
  queryPageName: () => `${queryName}_page`,
117
117
  querySName,
118
+ resizing: false,
118
119
  showFilters: () => Boolean(queryParams[querySName]),
119
120
  showSettings: false,
120
121
  tableSetting: undefined,
@@ -356,7 +357,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
356
357
  onLayout={this.tt.onFlatListLayout}
357
358
  renderItem={this.tt.renderItem}
358
359
  showsHorizontalScrollIndicator
359
- style={{overflowX: "auto"}}
360
+ style={{border: "1px solid #dbdbdb", borderRadius: 5, overflowX: "auto"}}
360
361
  {...restProps}
361
362
  />
362
363
  )
@@ -464,7 +465,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
464
465
  </Header>
465
466
  }
466
467
  {this.headersContentFromColumns()}
467
- <Header style={this.styleForHeader({style: {}})} />
468
+ <Header style={this.styleForHeader({style: {}, type: "actions"})} />
468
469
  </Row>
469
470
  )
470
471
  }
@@ -487,23 +488,36 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
487
488
  )
488
489
  }
489
490
 
490
- styleForColumn({column, columnIndex, even, style}) {
491
+ styleForColumn({column, columnIndex, even, style, type}) {
492
+ const defaultStyle = {
493
+ justifyContent: "center",
494
+ padding: 8,
495
+ backgroundColor: even ? "#f5f5f5" : undefined
496
+ }
497
+
498
+ if (type != "actions") {
499
+ defaultStyle.borderRight = "1px solid #dbdbdb"
500
+ }
501
+
491
502
  const actualStyle = Object.assign(
492
- {
493
- padding: 8,
494
- backgroundColor: even ? "#f5f5f5" : undefined,
495
- },
503
+ defaultStyle,
496
504
  style
497
505
  )
498
506
 
499
507
  return actualStyle
500
508
  }
501
509
 
502
- styleForHeader({column, columnIndex, style}) {
510
+ styleForHeader({column, columnIndex, style, type}) {
511
+ const defaultStyle = {
512
+ padding: 8
513
+ }
514
+
515
+ if (type != "actions") {
516
+ defaultStyle.borderRight = "1px solid #dbdbdb"
517
+ }
518
+
503
519
  const actualStyle = Object.assign(
504
- {
505
- padding: 8
506
- },
520
+ defaultStyle,
507
521
  style
508
522
  )
509
523
 
@@ -519,8 +533,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
519
533
  styleForRow({even} = {}) {
520
534
  const actualStyle = {
521
535
  flex: 1,
522
- alignItems: "center",
523
- borderBottom: "1px solid #f2f2f2"
536
+ alignItems: "stretch"
524
537
  }
525
538
 
526
539
  if (even) {
@@ -614,6 +627,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
614
627
  <HeaderColumn
615
628
  column={column}
616
629
  key={tableSettingColumn.identifier()}
630
+ resizing={this.s.resizing}
617
631
  table={this}
618
632
  tableSettingColumn={tableSettingColumn}
619
633
  width={width}