@kaspernj/api-maker 1.0.403 → 1.0.405

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.403",
3
+ "version": "1.0.405",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
package/src/icon.jsx ADDED
@@ -0,0 +1,51 @@
1
+ import BaseComponent from "./base-component"
2
+ import {Image} from "react-native"
3
+ import {memo, useMemo} from "react"
4
+ import PropTypes from "prop-types"
5
+ import {shapeComponent} from "set-state-compare/src/shape-component.js"
6
+
7
+ export default memo(shapeComponent(class ComponentsIcon extends BaseComponent {
8
+ static propTypes = {
9
+ icon: PropTypes.string.isRequired
10
+ }
11
+
12
+ setup() {
13
+ const {icon} = this.p
14
+
15
+ this.useStates({
16
+ IconComponent: null,
17
+ imageSource: null
18
+ })
19
+
20
+ useMemo(() => {
21
+ this.loadIcon()
22
+ }, [icon])
23
+ }
24
+
25
+ async loadIcon() {
26
+ const {icon} = this.p
27
+ const IconComponent = await import(`./icons/${icon}.svg`)
28
+
29
+ this.setState({IconComponent})
30
+ }
31
+
32
+ render() {
33
+ const {icon, style, ...restProps} = this.props
34
+ const {IconComponent} = this.s
35
+ const actualStyle = Object.assign(
36
+ {
37
+ width: 16,
38
+ height: 16
39
+ },
40
+ style
41
+ )
42
+
43
+ if (!IconComponent) {
44
+ return null
45
+ }
46
+
47
+ return (
48
+ <Image source={IconComponent.default} style={actualStyle} {...restProps} />
49
+ )
50
+ }
51
+ }))
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M0 96C0 78.3 14.3 64 32 64l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 288c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32L32 448c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M495.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4L83.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4C64.6 273.1 64 264.6 64 256s.6-17.1 1.7-25.4L22.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M362.7 19.3L314.3 67.7 444.3 197.7l48.4-48.4c25-25 25-65.5 0-90.5L453.3 19.3c-25-25-65.5-25-90.5 0zm-71 71L58.6 323.5c-10.4 10.4-18 23.3-22.2 37.4L1 481.2C-1.5 489.7 .8 498.8 7 505s15.3 8.5 23.7 6.1l120.3-35.4c14.1-4.2 27-11.8 37.4-22.2L421.7 220.3 291.7 90.3z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>
package/src/run-last.mjs CHANGED
@@ -33,7 +33,7 @@ export default class RunLast {
33
33
  }
34
34
 
35
35
  run() {
36
- clearTimeout(this.flushTimeout)
36
+ this.clearTimeout()
37
37
  this.callback()
38
38
  }
39
39
  }
@@ -1,10 +1,11 @@
1
1
  import "./style"
2
2
  import BaseComponent from "../../../base-component"
3
+ import Icon from "../../../icon"
3
4
  import {memo, useRef} from "react"
4
5
  import PropTypes from "prop-types"
5
6
  import PropTypesExact from "prop-types-exact"
6
7
  import {shapeComponent} from "set-state-compare/src/shape-component.js"
7
- import {Text, View} from "react-native"
8
+ import {Pressable, Text, View} from "react-native"
8
9
  import useBreakpoint from "../../../use-breakpoint"
9
10
  import useEventListener from "../../../use-event-listener"
10
11
 
@@ -104,24 +105,21 @@ export default memo(shapeComponent(class ApiMakerSuperAdminLayoutHeader extends
104
105
  </View>
105
106
  </View>
106
107
  }
107
- <div className="burger-menu-container">
108
+ <View dataSet={{class: "burger-menu-container"}}>
108
109
  {actions &&
109
- <a className="actions-link" href="#" onClick={this.tt.onGearsClicked}>
110
- <i className="fa fa-gear" />
111
- </a>
110
+ <Pressable dataSet={{class: "actions-link"}} onPress={this.tt.onGearsClicked} style={{marginRight: 8, fontSize: 22}}>
111
+ <Icon icon="gear-solid" />
112
+ </Pressable>
112
113
  }
113
- <a className="burger-menu-link" href="#" onClick={onTriggerMenu}>
114
- <i className="fa fa-bars" />
115
- </a>
116
- </div>
114
+ <Pressable dataSet={{class: "burger-menu-link"}} onPress={onTriggerMenu}>
115
+ <Icon icon="bars-solid" />
116
+ </Pressable>
117
+ </View>
117
118
  </View>
118
119
  )
119
120
  }
120
121
 
121
- onGearsClicked = (e) => {
122
- e.preventDefault()
123
- this.setState({headerActionsActive: !this.s.headerActionsActive})
124
- }
122
+ onGearsClicked = () => this.setState({headerActionsActive: !this.s.headerActionsActive})
125
123
 
126
124
  onWindowMouseUp = (e) => {
127
125
  // Close the header actions menu if clicked happened outside
@@ -7,10 +7,6 @@
7
7
  display: block;
8
8
  padding: 11px;
9
9
 
10
- .fa {
11
- margin-right: 5px;
12
- }
13
-
14
10
  + .action-button {
15
11
  border-top: 1px solid #c9c9c9;
16
12
  }
@@ -47,7 +43,7 @@
47
43
  }
48
44
  }
49
45
 
50
- .burger-menu-container {
46
+ [data-class="burger-menu-container"] {
51
47
  @media (max-width: $sm-to) {
52
48
  margin-left: auto;
53
49
  font-size: 28px;
@@ -57,17 +53,4 @@
57
53
  display: none;
58
54
  }
59
55
  }
60
-
61
- .actions-link {
62
- margin-right: 8px;
63
- font-size: 22px;
64
- }
65
-
66
- .actions-link,
67
- .burger-menu-link {
68
- &:link,
69
- &:visited {
70
- color: #1b1c1e;
71
- }
72
- }
73
56
  }
@@ -5,6 +5,7 @@ import Column from "./components/column"
5
5
  import columnIdentifier from "./column-identifier.mjs"
6
6
  import columnVisible from "./column-visible.mjs"
7
7
  import {digs} from "diggerize"
8
+ import Icon from "../icon"
8
9
  import * as inflection from "inflection"
9
10
  import Link from "../link"
10
11
  import MoneyFormatter from "../money-formatter"
@@ -62,23 +63,17 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
62
63
  {actionsContent && actionsContent(this.modelCallbackArgs)}
63
64
  {viewPath &&
64
65
  <Link dataSet={{class: "view-button"}} to={viewPath}>
65
- <Text>
66
- &#x1F50D;
67
- </Text>
66
+ <Icon icon="magnifying-glass-solid" />
68
67
  </Link>
69
68
  }
70
69
  {editPath &&
71
70
  <Link dataSet={{class: "edit-button"}} to={editPath}>
72
- <Text>
73
- &#x270E;
74
- </Text>
71
+ <Icon icon="pen-solid" />
75
72
  </Link>
76
73
  }
77
74
  {destroyEnabled && model.can("destroy") &&
78
75
  <Pressable dataSet={{class: "destroy-button"}} onPress={this.tt.onDestroyClicked}>
79
- <Text>
80
- &#x2715;
81
- </Text>
76
+ <Icon icon="xmark-solid" />
82
77
  </Pressable>
83
78
  }
84
79
  </Column>
@@ -33,7 +33,7 @@ export default memo(shapeComponent(class ColumnRow extends BaseComponent {
33
33
  }
34
34
 
35
35
  return (
36
- <View dataSet={{component: "api-maker--table--settings--column-row"}} style={{zIndex: 1, justifyContent: "center"}}>
36
+ <View dataSet={{component: "api-maker--table--settings--column-row"}} style={{justifyContent: "center"}}>
37
37
  <label style={{whiteSpace: "nowrap"}}>
38
38
  <input
39
39
  className="api-maker--table--setings--column-checkbox"
@@ -1,4 +1,3 @@
1
- import "./style"
2
1
  import BaseComponent from "../../base-component"
3
2
  import columnIdentifier from "../column-identifier.mjs"
4
3
  import ColumnRow from "./column-row"
@@ -6,8 +5,7 @@ import {memo, useRef} from "react"
6
5
  import PropTypes from "prop-types"
7
6
  import propTypesExact from "prop-types-exact"
8
7
  import {shapeComponent} from "set-state-compare/src/shape-component.js"
9
- import useEventListener from "../../use-event-listener"
10
- import {Text, View} from "react-native"
8
+ import {Modal, Text, View} from "react-native"
11
9
 
12
10
  export default memo(shapeComponent(class ApiMakerTableSettings extends BaseComponent {
13
11
  static propTypes = propTypesExact({
@@ -18,7 +16,6 @@ export default memo(shapeComponent(class ApiMakerTableSettings extends BaseCompo
18
16
  setup() {
19
17
  this.rootRef = useRef()
20
18
 
21
- useEventListener(window, "mouseup", this.tt.onWindowMouseUp)
22
19
  this.useStates({
23
20
  fixedTableLayout: this.tableSetting().fixedTableLayout()
24
21
  })
@@ -31,27 +28,34 @@ export default memo(shapeComponent(class ApiMakerTableSettings extends BaseCompo
31
28
  const {preparedColumns} = table.s
32
29
 
33
30
  return (
34
- <div className="api-maker--table--settings" ref={this.tt.rootRef}>
35
- <View style={{marginBottom: 5}}>
36
- <Text style={{fontSize: 16, fontWeight: "bold"}}>
37
- Settings
38
- </Text>
31
+ <Modal onBackdropPress={this.p.onRequestClose} onRequestClose={this.p.onRequestClose} transparent>
32
+ <View
33
+ dataSet={{class: "api-maker--table--settings"}}
34
+ style={{
35
+ width: "100%",
36
+ maxWidth: 800,
37
+ marginHorizontal: "auto",
38
+ marginVertical: "auto",
39
+ padding: 20,
40
+ backgroundColor: "#fff",
41
+ border: "1px solid black"
42
+ }}
43
+ >
44
+ <View style={{marginBottom: 5}}>
45
+ <Text style={{fontSize: 16, fontWeight: "bold"}}>
46
+ Settings
47
+ </Text>
48
+ </View>
49
+ <View style={{marginBottom: 5}}>
50
+ <Text style={{fontSize: 16, fontWeight: "bold"}}>
51
+ Columns
52
+ </Text>
53
+ </View>
54
+ {preparedColumns?.map(({column, tableSettingColumn}) =>
55
+ <ColumnRow column={column} key={columnIdentifier(column)} table={table} tableSettingColumn={tableSettingColumn} />
56
+ )}
39
57
  </View>
40
- <View style={{marginBottom: 5}}>
41
- <Text style={{fontSize: 16, fontWeight: "bold"}}>
42
- Columns
43
- </Text>
44
- </View>
45
- {preparedColumns?.map(({column, tableSettingColumn}) =>
46
- <ColumnRow column={column} key={columnIdentifier(column)} table={table} tableSettingColumn={tableSettingColumn} />
47
- )}
48
- </div>
58
+ </Modal>
49
59
  )
50
60
  }
51
-
52
- onWindowMouseUp = (e) => {
53
- if (this.tt.rootRef.current && !this.tt.rootRef.current.contains(e.target)) {
54
- this.p.onRequestClose()
55
- }
56
- }
57
61
  }))
@@ -1,15 +1,17 @@
1
1
  import "./style"
2
+ import {digg, digs} from "diggerize"
3
+ import {Pressable, View} from "react-native"
2
4
  import BaseComponent from "../base-component"
3
5
  import Card from "../bootstrap/card"
4
6
  import classNames from "classnames"
5
7
  import Collection from "../collection"
6
8
  import columnVisible from "./column-visible.mjs"
7
9
  import debounce from "debounce"
8
- import {digg, digs} from "diggerize"
9
10
  import Filters from "./filters"
10
11
  import FlatList from "./components/flat-list"
11
12
  import Header from "./components/header"
12
13
  import HeaderColumn from "./header-column"
14
+ import Icon from "../icon"
13
15
  import * as inflection from "inflection"
14
16
  import modelClassRequire from "../model-class-require.mjs"
15
17
  import ModelRow from "./model-row"
@@ -27,7 +29,6 @@ import uniqunize from "uniqunize"
27
29
  import useBreakpoint from "../use-breakpoint"
28
30
  import useCollection from "../use-collection"
29
31
  import useQueryParams from "on-location-changed/src/use-query-params.js"
30
- import {View} from "react-native"
31
32
  import Widths from "./widths"
32
33
 
33
34
  const paginationOptions = [30, 60, 90, ["All", "all"]]
@@ -80,6 +81,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
80
81
  queryName: PropTypes.string,
81
82
  select: PropTypes.object,
82
83
  selectColumns: PropTypes.object,
84
+ styles: PropTypes.object,
83
85
  viewModelPath: PropTypes.func,
84
86
  workplace: PropTypes.bool.isRequired
85
87
  }
@@ -235,7 +237,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
235
237
  }
236
238
 
237
239
  return (
238
- <div className={this.className()}>
240
+ <div className={this.className()} style={this.props.styles?.container}>
239
241
  {showNoRecordsAvailableContent &&
240
242
  <div className="live-table--no-records-available-content">
241
243
  {noRecordsAvailableContent({models, qParams, overallCount})}
@@ -370,7 +372,13 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
370
372
  this.filterForm()
371
373
  }
372
374
  {card &&
373
- <Card className={classNames("live-table--table-card", "mb-4", className)} controls={this.tableControls()} header={headerContent} footer={this.tableFooter()} {...restProps}>
375
+ <Card
376
+ className={classNames("live-table--table-card", "mb-4", className)}
377
+ controls={this.tableControls()}
378
+ header={headerContent}
379
+ footer={this.tableFooter()}
380
+ {...restProps}
381
+ >
374
382
  {flatList}
375
383
  </Card>
376
384
  }
@@ -484,20 +492,20 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
484
492
  const {models, qParams, query, result} = digs(this.collection, "models", "qParams", "query", "result")
485
493
 
486
494
  return (
487
- <>
495
+ <View style={{flexDirection: "row"}}>
488
496
  {controls && controls({models, qParams, query, result})}
489
- <a className="filter-button" href="#" onClick={this.tt.onFilterClicked}>
490
- <i className="fa fa-fw fa-magnifying-glass la la-fw la-search" />
491
- </a>
492
- <span style={{position: "relative"}}>
497
+ <Pressable dataSet={{class: "filter-button"}} onPress={this.tt.onFilterClicked}>
498
+ <Icon icon="magnifying-glass-solid" />
499
+ </Pressable>
500
+ <View style={{position: "relative"}}>
493
501
  {showSettings &&
494
502
  <Settings onRequestClose={this.tt.onRequestCloseSettings} table={this} />
495
503
  }
496
- <a className="settings-button" href="#" onClick={this.tt.onSettingsClicked}>
497
- <i className="fa fa-fw fa-gear la la-fw la-gear" />
498
- </a>
499
- </span>
500
- </>
504
+ <Pressable dataSet={{class: "settings-button"}} onPress={this.tt.onSettingsClicked}>
505
+ <Icon icon="gear-solid" />
506
+ </Pressable>
507
+ </View>
508
+ </View>
501
509
  )
502
510
  }
503
511
 
package/src/use-model.mjs CHANGED
@@ -167,7 +167,11 @@ const useModel = (modelClassArg, argsArg = {}) => {
167
167
  }
168
168
  }, [args.onDestroyed, s.s.model?.id()])
169
169
 
170
- const result = {}
170
+ const result = {
171
+ model: s.s.model,
172
+ modelId,
173
+ notFound: s.s.notFound
174
+ }
171
175
 
172
176
  result[modelVariableName] = s.s.model
173
177
  result[`${modelVariableName}Id`] = modelId
@@ -1,8 +0,0 @@
1
- .api-maker--table--settings {
2
- position: absolute;
3
- right: 0px;
4
- padding: 12px;
5
- background-color: #fff;
6
- border: 1px solid black;
7
- font-size: 12px;
8
- }