@kaspernj/api-maker 1.0.438 → 1.0.440

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.438",
3
+ "version": "1.0.440",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
@@ -1,15 +1,12 @@
1
1
  import BaseComponent from "../base-component"
2
2
  import classNames from "classnames"
3
- import {digs} from "diggerize"
4
3
  import Header from "./components/header"
5
4
  import HeaderColumnContent from "./header-column-content"
6
5
  import memo from "set-state-compare/src/memo"
7
- import {Platform, Pressable, View} from "react-native"
6
+ import {Platform, Pressable} from "react-native"
8
7
  import PropTypes from "prop-types"
9
8
  import propTypesExact from "prop-types-exact"
10
9
  import {shapeComponent} from "set-state-compare/src/shape-component"
11
- import SortLink from "../bootstrap/sort-link"
12
- import Text from "../utils/text"
13
10
  import useBreakpoint from "../use-breakpoint"
14
11
  import useEventListener from "../use-event-listener.mjs"
15
12
  import Widths from "./widths"
@@ -40,13 +37,11 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
40
37
  }
41
38
 
42
39
  render() {
43
- const {breakpoint, mdUp, smDown} = this.tt
40
+ const {mdUp} = this.tt
44
41
  const {column, resizing, table, tableSettingColumn, width} = this.p
45
- const {defaultParams} = table.props
46
- const {styleForHeader, styleForHeaderText} = table.tt
47
- const {query} = digs(table.collection, "query")
48
- const columnProps = table.columnProps(column)
49
- const {style, ...restColumnProps} = columnProps
42
+ const {styleForHeader} = table.tt
43
+ const headerProps = table.headerProps(column)
44
+ const {style, ...restColumnProps} = headerProps
50
45
  const actualStyle = Object.assign(
51
46
  {
52
47
  cursor: resizing ? "col-resize" : undefined,
@@ -9,6 +9,7 @@ import debounce from "debounce"
9
9
  import Filters from "./filters"
10
10
  import FlatList from "./components/flat-list"
11
11
  import FontAwesomeIcon from "react-native-vector-icons/FontAwesome"
12
+ import {Form} from "../form"
12
13
  import Header from "./components/header"
13
14
  import HeaderColumn from "./header-column"
14
15
  import HeaderSelect from "./header-select"
@@ -157,6 +158,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
157
158
  columns: columnsAsArray,
158
159
  currentWorkplace: undefined,
159
160
  currentWorkplaceCount: null,
161
+ filterForm: null,
160
162
  identifier: () => this.props.identifier || `${collectionKey}-default`,
161
163
  lastUpdate: () => new Date(),
162
164
  preload: undefined,
@@ -529,18 +531,20 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
529
531
  filterForm = () => {
530
532
  const {filterFormRef, submitFilter, submitFilterDebounce} = this.tt
531
533
  const {filterContent, filterSubmitButton} = this.p
534
+ const {queryQName} = this.s
532
535
  const {filterSubmitLabel} = this.props
533
536
  const {qParams} = digs(this.collection, "qParams")
534
537
 
535
538
  return (
536
- <form className="live-table--filter-form" onSubmit={this.onFilterFormSubmit} ref={filterFormRef}>
539
+ <Form className="live-table--filter-form" formRef={filterFormRef} onSubmit={this.onFilterFormSubmit} setForm={this.setStates.filterForm}>
537
540
  {"s" in qParams &&
538
541
  <input name="s" type="hidden" value={qParams.s} />
539
542
  }
540
543
  {filterContent({
541
544
  onFilterChanged: submitFilter,
542
545
  onFilterChangedWithDelay: submitFilterDebounce,
543
- qParams
546
+ qParams,
547
+ queryQName
544
548
  })}
545
549
  {filterSubmitButton &&
546
550
  <input
@@ -550,7 +554,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
550
554
  value={filterSubmitLabel || this.t(".filter", {defaultValue: "Filter"})}
551
555
  />
552
556
  }
553
- </form>
557
+ </Form>
554
558
  )
555
559
  }
556
560
 
@@ -633,16 +637,21 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
633
637
  }
634
638
 
635
639
  styleForHeader = ({column, columnIndex, style, type}) => {
640
+ const {mdUp} = this.tt
636
641
  const defaultStyle = {
637
642
  flexDirection: "row",
638
643
  alignItems: "center",
639
644
  padding: 8
640
645
  }
641
646
 
642
- if (type != "actions" && this.tt.mdUp && this.p.styleUI) {
647
+ if (type != "actions" && mdUp && this.p.styleUI) {
643
648
  defaultStyle.borderRight = "1px solid #dbdbdb"
644
649
  }
645
650
 
651
+ if (mdUp) {
652
+
653
+ }
654
+
646
655
  const actualStyle = Object.assign(
647
656
  defaultStyle,
648
657
  style
@@ -763,6 +772,22 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
763
772
  return props
764
773
  }
765
774
 
775
+ headerProps(column) {
776
+ const props = {}
777
+
778
+ if (column.textCenter) {
779
+ props.style ||= {}
780
+ props.style.justifyContent = "center"
781
+ }
782
+
783
+ if (column.textRight) {
784
+ props.style ||= {}
785
+ props.style.justifyContent = "end"
786
+ }
787
+
788
+ return props
789
+ }
790
+
766
791
  columnWidths() {
767
792
  const columnWidths = {}
768
793
 
@@ -786,7 +811,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
786
811
  )
787
812
 
788
813
  headerClassNameForColumn(column) {
789
- const classNames = ["live-table-header"]
814
+ const classNames = []
790
815
 
791
816
  if (column.commonProps && column.commonProps.className) classNames.push(column.commonProps.className)
792
817
  if (column.headerProps && column.headerProps.className) classNames.push(column.headerProps.className)
@@ -822,11 +847,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
822
847
  throw new Error("No 'label' or 'attribute' was given")
823
848
  }
824
849
 
825
- onFilterFormSubmit = (e) => {
826
- e.preventDefault()
827
- this.submitFilter()
828
- }
829
-
850
+ onFilterFormSubmit = () => this.submitFilter()
830
851
  onRequestCloseSettings = () => this.setState({showSettings: false})
831
852
 
832
853
  onSettingsClicked = (e) => {
package/src/use-input.mjs CHANGED
@@ -63,7 +63,7 @@ const useInput = ({props, wrapperOptions}) => {
63
63
  const inputDefaultValue = useCallback(() => {
64
64
  if ("defaultValue" in s.props) {
65
65
  return formatValue(s.props.defaultValue)
66
- } else if (s.props.model) {
66
+ } else if (s.props.model && s.props.attribute) {
67
67
  if (!s.props.model[s.props.attribute]) {
68
68
  throw new Error(`No such attribute defined on resource: ${digg(s.props.model.modelClassData(), "name")}#${s.props.attribute}`)
69
69
  }