@kaspernj/api-maker 1.0.440 → 1.0.442

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.440",
3
+ "version": "1.0.442",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
@@ -1,12 +1,14 @@
1
- import {Checkbox} from "../inputs/checkbox"
1
+ import {shapeComponent, ShapeComponent} from "set-state-compare/src/shape-component.js"
2
+ import Checkbox from "../inputs/checkbox"
2
3
  import classNames from "classnames"
3
4
  import {digs} from "diggerize"
4
- import inputWrapper from "../inputs/input-wrapper"
5
5
  import InvalidFeedback from "./invalid-feedback"
6
+ import memo from "set-state-compare/src/memo"
6
7
  import PropTypes from "prop-types"
7
8
  import React from "react"
9
+ import useInput from "../use-input"
8
10
 
9
- class ApiMakerBootstrapCheckbox extends React.PureComponent {
11
+ export default memo(shapeComponent(class ApiMakerBootstrapCheckbox extends ShapeComponent {
10
12
  static defaultProps = {
11
13
  defaultValue: 1,
12
14
  zeroInput: true
@@ -28,8 +30,15 @@ class ApiMakerBootstrapCheckbox extends React.PureComponent {
28
30
  zeroInput: PropTypes.bool
29
31
  }
30
32
 
33
+ setup() {
34
+ const {inputProps, restProps: useInputRestProps, wrapperOpts} = useInput({props: this.props, wrapperOptions: {type: "checkbox"}})
35
+
36
+ this.setInstance({inputProps, useInputRestProps, wrapperOpts})
37
+ }
38
+
31
39
  render () {
32
- const {className, hint, id, inputProps, inputRef, label, labelClassName, wrapperClassName, wrapperOpts, ...restProps} = this.props
40
+ const {inputProps, useInputRestProps, wrapperOpts} = this.tt
41
+ const {className, hint, id, inputRef, label, labelClassName, wrapperClassName, ...restProps} = useInputRestProps
33
42
  const {errors} = digs(wrapperOpts, "errors")
34
43
 
35
44
  return (
@@ -37,8 +46,8 @@ class ApiMakerBootstrapCheckbox extends React.PureComponent {
37
46
  <div className="form-check">
38
47
  <Checkbox
39
48
  className={classNames("form-check-input", className, {"is-invalid": errors.length > 0})}
40
- inputProps={inputProps}
41
- wrapperOpts={wrapperOpts}
49
+ id={id}
50
+ inputRef={inputRef}
42
51
  {...restProps}
43
52
  />
44
53
  {wrapperOpts.label &&
@@ -74,6 +83,4 @@ class ApiMakerBootstrapCheckbox extends React.PureComponent {
74
83
 
75
84
  return classNames.join(" ")
76
85
  }
77
- }
78
-
79
- export default inputWrapper(ApiMakerBootstrapCheckbox, {type: "checkbox"})
86
+ }))
@@ -1,34 +1,115 @@
1
+ import {shapeComponent, ShapeComponent} from "set-state-compare/src/shape-component.js"
1
2
  import {digs} from "diggerize"
2
- import inputWrapper from "../inputs/input-wrapper"
3
+ import {useForm} from "../form"
3
4
  import * as inflection from "inflection"
4
5
  import InvalidFeedback from "./invalid-feedback"
6
+ import memo from "set-state-compare/src/memo"
5
7
  import PropTypes from "prop-types"
6
8
  import propTypesExact from "prop-types-exact"
7
- import React from "react"
9
+ import useInput from "../use-input"
10
+ import {useMemo} from "react"
8
11
 
9
- class ApiMakerBootstrapCheckboxes extends React.PureComponent {
12
+ const OptionElement = memo(shapeComponent(class OptionElement extends ShapeComponent {
13
+ render() {
14
+ const {generatedId, inputCheckboxClassName, isDefaultSelected, inputName, option, optionIndex, options, wrapperOpts} = this.p
15
+ const {errors} = digs(wrapperOpts, "errors")
16
+ const id = `${generatedId}-${optionIndex}`
17
+
18
+ return (
19
+ <div className="checkboxes-option" key={`option-${option[1]}`}>
20
+ <input
21
+ className={inputCheckboxClassName}
22
+ data-option-value={option[1]}
23
+ defaultChecked={isDefaultSelected}
24
+ id={id}
25
+ name={inputName}
26
+ onChange={this.tt.onChange}
27
+ type="checkbox"
28
+ value={option[1]}
29
+ />
30
+
31
+ <label className="ml-1" htmlFor={id}>
32
+ {option[0]}
33
+ </label>
34
+
35
+ {(optionIndex + 1) == options.length && errors.length > 0 &&
36
+ <InvalidFeedback errors={errors} />
37
+ }
38
+ </div>
39
+ )
40
+ }
41
+
42
+ onChange = (event, ...restProps) => {
43
+ this.p.onOptionChecked({event, option: this.p.option})
44
+
45
+ if (this.props.onChange) this.props.onChange(event, ...restProps)
46
+ }
47
+ }))
48
+
49
+ export default memo(shapeComponent(class ApiMakerBootstrapCheckboxes extends ShapeComponent {
10
50
  static propTypes = propTypesExact({
11
51
  attribute: PropTypes.string,
12
52
  defaultValue: PropTypes.array,
13
- inputProps: PropTypes.object.isRequired,
14
53
  label: PropTypes.string,
15
54
  labelClassName: PropTypes.string,
16
55
  model: PropTypes.object,
17
56
  name: PropTypes.string,
18
57
  onChange: PropTypes.func,
19
- options: PropTypes.array.isRequired,
20
- wrapperOpts: PropTypes.object.isRequired
58
+ options: PropTypes.array.isRequired
21
59
  })
22
60
 
61
+ setup() {
62
+ const {inputProps, wrapperOpts} = useInput({props: this.props})
63
+
64
+ this.generatedId = useMemo(
65
+ () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
66
+ []
67
+ )
68
+
69
+ this.setInstance({
70
+ form: useForm(),
71
+ inputProps,
72
+ wrapperOpts
73
+ })
74
+ this.useStates({
75
+ checkedOptions: () => {
76
+ if (Array.isArray(this.props.defaultValue)) return this.props.defaultValue
77
+ if (this.props.defaultValue) return [this.props.defaultValue]
78
+
79
+ return []
80
+ }
81
+ })
82
+
83
+ useMemo(() => {
84
+ if (this.form && inputProps.name) {
85
+ this.form.setValue(inputProps.name, this.s.checkedOptions)
86
+ }
87
+ }, [])
88
+ }
89
+
23
90
  render () {
24
91
  return (
25
92
  <div className="component-bootstrap-checkboxes form-group">
26
93
  <label className={this.labelClassName()}>
27
- {this.props.wrapperOpts.label}
94
+ {this.tt.wrapperOpts.label}
28
95
  </label>
29
96
 
30
- <input name={this.inputName()} ref={this.props.inputProps.ref} type="hidden" value="" />
31
- {this.props.options.map((option, index) => this.optionElement(option, index))}
97
+ <input name={this.inputName()} ref={this.tt.inputProps.ref} type="hidden" value="" />
98
+ {this.props.options.map((option, index) =>
99
+ <OptionElement
100
+ inputCheckboxClassName={this.tt.inputCheckboxClassName()}
101
+ inputName={this.inputName()}
102
+ isDefaultSelected={this.isDefaultSelected(option[1])}
103
+ generatedId={this.tt.generatedId}
104
+ key={option[1]}
105
+ onChange={this.props.onChange}
106
+ onOptionChecked={this.tt.onOptionChecked}
107
+ option={option}
108
+ optionIndex={index}
109
+ options={this.props.options}
110
+ wrapperOpts={this.tt.wrapperOpts}
111
+ />
112
+ )}
32
113
  </div>
33
114
  )
34
115
  }
@@ -39,8 +120,7 @@ class ApiMakerBootstrapCheckboxes extends React.PureComponent {
39
120
  if (defaultValue) {
40
121
  return defaultValue
41
122
  } else if (attribute && model) {
42
- if (!model[attribute])
43
- throw `No such attribute: ${attribute}`
123
+ if (!model[attribute]) throw `No such attribute: ${attribute}`
44
124
 
45
125
  return this.props.model[attribute]()
46
126
  }
@@ -49,7 +129,7 @@ class ApiMakerBootstrapCheckboxes extends React.PureComponent {
49
129
  inputCheckboxClassName () {
50
130
  const classNames = []
51
131
 
52
- if (this.props.wrapperOpts.errors.length > 0) classNames.push("is-invalid")
132
+ if (this.tt.wrapperOpts.errors.length > 0) classNames.push("is-invalid")
53
133
 
54
134
  return classNames.join(" ")
55
135
  }
@@ -82,41 +162,24 @@ class ApiMakerBootstrapCheckboxes extends React.PureComponent {
82
162
  return classNames.join(" ")
83
163
  }
84
164
 
85
- generatedId () {
86
- if (!this.generatedIdValue)
87
- this.generatedIdValue = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)
165
+ onOptionChecked = ({event, option}) => {
166
+ const {inputProps, form} = this.tt
167
+ const {name} = inputProps
168
+ const checked = event.target.checked
169
+ let newOptions
88
170
 
89
- return this.generatedIdValue
90
- }
171
+ if (checked) {
172
+ newOptions = this.s.checkedOptions.concat([option[1]])
91
173
 
92
- optionElement (option, index) {
93
- const {onChange, options, wrapperOpts} = this.props
94
- const {errors} = digs(wrapperOpts, "errors")
95
- const id = `${this.generatedId()}-${index}`
96
-
97
- return (
98
- <div className="checkboxes-option" key={`option-${option[1]}`}>
99
- <input
100
- className={this.inputCheckboxClassName()}
101
- data-option-value={option[1]}
102
- defaultChecked={this.isDefaultSelected(option[1])}
103
- id={id}
104
- name={this.inputName()}
105
- onChange={onChange}
106
- type="checkbox"
107
- value={option[1]}
108
- />
174
+ this.setState({checkedOptions: newOptions})
175
+ } else {
176
+ newOptions = this.s.checkedOptions.filter((value) => value != option[1])
109
177
 
110
- <label className="ml-1" htmlFor={id}>
111
- {option[0]}
112
- </label>
178
+ this.setState({checkedOptions: newOptions})
179
+ }
113
180
 
114
- {(index + 1) == options.length && errors.length > 0 &&
115
- <InvalidFeedback errors={errors} />
116
- }
117
- </div>
118
- )
181
+ if (form && name) {
182
+ form.setValue(name, newOptions)
183
+ }
119
184
  }
120
- }
121
-
122
- export default inputWrapper(ApiMakerBootstrapCheckboxes)
185
+ }))
@@ -1,6 +1,6 @@
1
1
  import BaseComponent from "../base-component"
2
2
  import {Input as ApiMakerInput} from "@kaspernj/api-maker/src/inputs/input"
3
- import {Checkbox} from "./checkbox"
3
+ import Checkbox from "./checkbox"
4
4
  import memo from "set-state-compare/src/memo"
5
5
  import {shapeComponent} from "set-state-compare/src/shape-component.js"
6
6
 
@@ -13,16 +13,19 @@ export default memo(shapeComponent(class ApiMakerInputsAttachment extends BaseCo
13
13
  }
14
14
 
15
15
  setup() {
16
+ const {inputProps} = useInput({props: this.props})
17
+
18
+ this.setInstance({inputProps})
16
19
  this.useStates({
17
20
  purgeChecked: false
18
21
  })
19
22
  }
20
23
 
21
24
  render() {
22
- const {attribute, checkboxComponent, className, inputProps, label, model, name, onPurgeChanged, purgeName, wrapperOpts, ...restProps} = this.props
25
+ const {inputProps} = this.tt
26
+ const {attribute, checkboxComponent, className, label, model, name, onPurgeChanged, purgeName, wrapperOpts, ...restProps} = this.props
23
27
  const CheckboxComponent = checkboxComponent || Checkbox
24
-
25
- inputProps.type = "file"
28
+ const newInputProps = Object.assign({}, inputProps, {type: "file"})
26
29
 
27
30
  return (
28
31
  <div className={classNames("api-maker--inputs--attachment", "components--inputs--input", className)} {...restProps}>
@@ -33,16 +36,16 @@ export default memo(shapeComponent(class ApiMakerInputsAttachment extends BaseCo
33
36
  }
34
37
  {this.getUrl() &&
35
38
  <div className="input-checkbox" style={{paddingTop: "15px", paddingBottom: "15px"}}>
36
- <CheckboxComponent inputProps={{id: this.getPurgeInputId(), name: this.getPurgeInputName()}} onChange={this.props.onPurgeChanged} />
39
+ <CheckboxComponent id={this.getPurgeInputId()} name={this.getPurgeInputName()} onChange={this.props.onPurgeChanged} />
37
40
  <label className="checkbox-label" htmlFor={this.getPurgeInputId()}>
38
41
  {I18n.t("js.shared.delete")}
39
42
  </label>
40
43
  </div>
41
44
  }
42
- {!this.state.purgeChecked &&
45
+ {!this.s.purgeChecked &&
43
46
  <ApiMakerInput
44
47
  defaultValue={null}
45
- inputProps={inputProps}
48
+ inputProps={newInputProps}
46
49
  model={model}
47
50
  />
48
51
  }
@@ -17,7 +17,7 @@ export default class ApiMakerInputsAutoSubmit {
17
17
  }
18
18
 
19
19
  value () {
20
- const inputRef = this.component.props.inputRef || this.component.props.inputProps.ref || this.component.inputRef
20
+ const inputRef = this.component.props.inputRef || this.component.props.inputProps?.ref || this.component.inputProps?.ref || this.component.inputRef
21
21
  const input = digg(inputRef, "current")
22
22
 
23
23
  if (input.type == "checkbox") {
@@ -1,14 +1,14 @@
1
1
  import AutoSubmit from "./auto-submit.mjs"
2
2
  import BaseComponent from "../base-component"
3
- import {digg, digs} from "diggerize"
3
+ import {digg} from "diggerize"
4
4
  import EventUpdated from "../event-updated"
5
- import inputWrapper from "./input-wrapper"
6
5
  import PropTypes from "prop-types"
7
6
  import memo from "set-state-compare/src/memo"
8
7
  import {shapeComponent} from "set-state-compare/src/shape-component.js"
8
+ import useInput from "../use-input"
9
9
  import {useForm} from "../form"
10
10
 
11
- const ApiMakerInputsCheckbox = memo(shapeComponent(class ApiMakerInputsCheckbox extends BaseComponent {
11
+ export default memo(shapeComponent(class ApiMakerInputsCheckbox extends BaseComponent {
12
12
  static defaultProps = {
13
13
  autoRefresh: false,
14
14
  autoSubmit: false,
@@ -32,10 +32,17 @@ const ApiMakerInputsCheckbox = memo(shapeComponent(class ApiMakerInputsCheckbox
32
32
  }
33
33
 
34
34
  setup() {
35
- this.form = useForm()
35
+ const {inputProps, restProps: useInputRestProps} = useInput({props: this.props, wrapperOptions: {type: "checkbox"}})
36
+
37
+ this.setInstance({
38
+ form: useForm(),
39
+ inputProps,
40
+ useInputRestProps
41
+ })
36
42
  }
37
43
 
38
44
  render () {
45
+ const {inputProps, useInputRestProps} = this.tt
39
46
  const {
40
47
  attribute,
41
48
  autoRefresh,
@@ -44,20 +51,20 @@ const ApiMakerInputsCheckbox = memo(shapeComponent(class ApiMakerInputsCheckbox
44
51
  defaultChecked,
45
52
  defaultValue,
46
53
  id,
47
- inputProps,
48
54
  inputRef,
49
55
  model,
50
56
  name,
51
57
  onChange,
52
58
  zeroInput,
53
- wrapperOpts,
54
59
  ...restProps
55
- } = this.props
60
+ } = useInputRestProps
61
+
62
+ console.log("ApiMakerInputsCheckbox", {inputProps, restProps})
56
63
 
57
64
  return (
58
65
  <>
59
66
  {autoRefresh && model &&
60
- <EventUpdated model={model} onUpdated={digg(this, "onModelUpdated")} />
67
+ <EventUpdated model={model} onUpdated={this.tt.onModelUpdated} />
61
68
  }
62
69
  {zeroInput && inputProps.name &&
63
70
  <input defaultValue="0" name={inputProps.name} type="hidden" />
@@ -67,7 +74,7 @@ const ApiMakerInputsCheckbox = memo(shapeComponent(class ApiMakerInputsCheckbox
67
74
  data-auto-refresh={autoRefresh}
68
75
  data-auto-submit={autoSubmit}
69
76
  defaultValue={defaultValue}
70
- onChange={digg(this, "onChanged")}
77
+ onChange={this.tt.onChanged}
71
78
  type="checkbox"
72
79
  {...restProps}
73
80
  />
@@ -85,14 +92,14 @@ const ApiMakerInputsCheckbox = memo(shapeComponent(class ApiMakerInputsCheckbox
85
92
  }
86
93
 
87
94
  onModelUpdated = (args) => {
88
- const inputRef = digg(this, "props", "inputProps", "ref")
95
+ const inputRef = digg(this.tt.inputProps, "ref")
89
96
 
90
97
  if (!inputRef.current) {
91
98
  // This can happen if the component is being unmounted
92
99
  return
93
100
  }
94
101
 
95
- const {attribute} = digs(this.props, "attribute")
102
+ const {attribute} = this.p
96
103
  const newModel = digg(args, "model")
97
104
  const currentChecked = digg(inputRef, "current", "checked")
98
105
  const newValue = newModel.readAttribute(attribute)
@@ -102,6 +109,3 @@ const ApiMakerInputsCheckbox = memo(shapeComponent(class ApiMakerInputsCheckbox
102
109
  }
103
110
  }
104
111
  }))
105
-
106
- export {ApiMakerInputsCheckbox as Checkbox}
107
- export default inputWrapper(ApiMakerInputsCheckbox, {type: "checkbox"})
package/src/params.mjs CHANGED
@@ -5,11 +5,11 @@ import qs from "qs"
5
5
  import urlEncode from "./url-encode.mjs"
6
6
 
7
7
  export default class Params {
8
- static parse () {
8
+ static parse() {
9
9
  return qs.parse(globalThis.location.search.substr(1))
10
10
  }
11
11
 
12
- static change (given) {
12
+ static change(given) {
13
13
  const incorporator = new Incorporator({objects: [Params.parse(), given]})
14
14
 
15
15
  incorporator.replaceArrayIfExists(true)
@@ -17,14 +17,14 @@ export default class Params {
17
17
  return incorporator.merge()
18
18
  }
19
19
 
20
- static withParams (params) {
20
+ static withParams(params) {
21
21
  const newParams = qs.stringify(params, {encoder: urlEncode})
22
22
  const newPath = `${location.pathname}?${newParams}`
23
23
 
24
24
  return newPath
25
25
  }
26
26
 
27
- static changeParams (given, opts = {}) {
27
+ static changeParams(given, opts = {}) {
28
28
  const params = Params.change(given)
29
29
  const newParams = qs.stringify(params, {encoder: urlEncode})
30
30
  const newPath = `${location.pathname}?${newParams}`
@@ -33,13 +33,13 @@ export default class Params {
33
33
  appHistory.push(newPath)
34
34
  }
35
35
 
36
- static serializeForm (form) {
36
+ static serializeForm(form) {
37
37
  const hash = formSerialize(form, {empty: true, hash: true})
38
38
  return Params.setUndefined(hash)
39
39
  }
40
40
 
41
41
  // This is used to set all empty values to 'undefined' which makes qs removed those elements from the query string
42
- static setUndefined (given) {
42
+ static setUndefined(given) {
43
43
  if (Array.isArray(given)) {
44
44
  if (given.length == 0)
45
45
  return undefined
@@ -184,7 +184,7 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
184
184
  </View>
185
185
  <View style={{flexDirection: "row"}}>
186
186
  <View>
187
- {this.s.associations?.map((reflection) =>
187
+ {this.s.associations && this.sortedReflectionsByName(this.s.associations).map((reflection) =>
188
188
  <ReflectionElement
189
189
  key={reflection.reflectionName}
190
190
  modelClassName={this.s.modelClassName}
@@ -194,7 +194,7 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
194
194
  )}
195
195
  </View>
196
196
  <View>
197
- {this.s.ransackableAttributes?.map((attribute) =>
197
+ {this.s.ransackableAttributes && this.sortedAttributesByName(this.s.ransackableAttributes)?.map((attribute) =>
198
198
  <AttributeElement
199
199
  active={attribute.attributeName == this.s.attribute?.attributeName}
200
200
  attribute={attribute}
@@ -377,9 +377,23 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
377
377
  })
378
378
  }
379
379
 
380
- sortedByName(reflections, currentModelClass) {
380
+ sortedAttributesByName(attributes) {
381
+ return attributes.sort((a, b) =>
382
+ digg(a, "humanName")
383
+ .toLowerCase()
384
+ .localeCompare(
385
+ digg(b, "humanName").toLowerCase()
386
+ )
387
+ )
388
+ }
389
+
390
+ sortedReflectionsByName(reflections) {
381
391
  return reflections.sort((a, b) =>
382
- currentModelClass.humanAttributeName(a.name()).toLowerCase().localeCompare(currentModelClass.humanAttributeName(b.name()).toLowerCase())
392
+ digg(a, "humanName")
393
+ .toLowerCase()
394
+ .localeCompare(
395
+ digg(b, "humanName").toLowerCase()
396
+ )
383
397
  )
384
398
  }
385
399
  }))
@@ -44,7 +44,7 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
44
44
  />
45
45
  }
46
46
  {(!tableSettingColumn.hasSortKey() || !query) &&
47
- <Text ellipsizeMode="clip" numberOfLines={1}>
47
+ <Text ellipsizeMode="clip" numberOfLines={1} style={{fontWeight: "bold"}}>
48
48
  {table.headerLabelForColumn(column)}
49
49
  </Text>
50
50
  }
@@ -536,7 +536,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
536
536
  const {qParams} = digs(this.collection, "qParams")
537
537
 
538
538
  return (
539
- <Form className="live-table--filter-form" formRef={filterFormRef} onSubmit={this.onFilterFormSubmit} setForm={this.setStates.filterForm}>
539
+ <Form className="live-table--filter-form" formRef={filterFormRef} onSubmit={this.tt.onFilterFormSubmit} setForm={this.setStates.filterForm}>
540
540
  {"s" in qParams &&
541
541
  <input name="s" type="hidden" value={qParams.s} />
542
542
  }
@@ -853,9 +853,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
853
853
  onSettingsClicked = (e) => {
854
854
  e.preventDefault()
855
855
 
856
- const {showSettings} = this.s
857
-
858
- this.setState({showSettings: !showSettings})
856
+ this.setState({showSettings: !this.s.showSettings})
859
857
  }
860
858
 
861
859
  submitFilter = () => {
package/src/use-input.mjs CHANGED
@@ -18,6 +18,8 @@ const useInput = ({props, wrapperOptions}) => {
18
18
  }, [s.props.inputRef?.current])
19
19
 
20
20
  s.meta.fakeComponent = {props}
21
+ s.meta.isCheckbox = props.type == "checkbox" || wrapperOptions?.type == "checkbox"
22
+ s.meta.isSelect = wrapperOptions?.type == "select"
21
23
 
22
24
  const formatValue = useCallback((value) => {
23
25
  const {formatValue} = s.props
@@ -36,19 +38,6 @@ const useInput = ({props, wrapperOptions}) => {
36
38
  return value
37
39
  }, [])
38
40
 
39
- const handleAsCheckbox = useCallback(() => {
40
- if (s.props.type == "checkbox") return true
41
- if (!("type" in s.props) && wrapperOptions?.type == "checkbox") return true
42
-
43
- return false
44
- }, [])
45
-
46
- const handleAsSelect = useCallback(() => {
47
- if (wrapperOptions?.type == "select") return true
48
-
49
- return false
50
- }, [])
51
-
52
41
  const inputDefaultChecked = useCallback(() => {
53
42
  if ("defaultChecked" in s.props) {
54
43
  return s.props.defaultChecked
@@ -82,8 +71,10 @@ const useInput = ({props, wrapperOptions}) => {
82
71
 
83
72
  const inputType = useCallback(() => {
84
73
  if ("type" in s.props) {
74
+ console.log("Type in props", s.p.type)
75
+
85
76
  return s.props.type
86
- } else if (wrapperOptions?.type == "checkbox") {
77
+ } else if (s.m.isCheckbox) {
87
78
  return "checkbox"
88
79
  } else {
89
80
  return "text"
@@ -121,7 +112,7 @@ const useInput = ({props, wrapperOptions}) => {
121
112
  givenInputProps
122
113
  )
123
114
 
124
- if (handleAsCheckbox()) {
115
+ if (s.m.isCheckbox) {
125
116
  if ("checked" in s.props) {
126
117
  inputProps.checked = s.props.checked
127
118
  }
@@ -138,14 +129,14 @@ const useInput = ({props, wrapperOptions}) => {
138
129
  return inputProps
139
130
  }, [])
140
131
 
141
- const {inputProps: oldInputProps, ...restProps} = props
132
+ const {inputProps: oldInputProps, wrapperOpts: oldWrapperOpts, ...restProps} = props
142
133
  const type = inputType()
143
134
 
144
135
  s.meta.inputProps = getInputProps()
145
136
  s.meta.inputNameWithoutId = useMemo(() => s.m.inputProps.name?.replace(/\[(.+)_id\]$/, "[$1]"), [s.m.inputProps.name])
146
137
 
147
138
  if (!s.m.inputProps.ref) throw new Error("No input ref?")
148
- if (!handleAsSelect()) s.m.inputProps.type = type
139
+ if (!s.m.isSelect) s.m.inputProps.type = type
149
140
 
150
141
  const {validationErrors} = useValidationErrors((validationError) =>
151
142
  validationError.inputName == s.m.inputProps.name || validationError.inputName == s.m.inputNameWithoutId