haya-select 1.0.13 → 1.0.15
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 +1 -1
- package/src/select/index.jsx +7 -6
package/package.json
CHANGED
package/src/select/index.jsx
CHANGED
|
@@ -4,14 +4,14 @@ import config from "../config.js"
|
|
|
4
4
|
import {digg, digs} from "diggerize"
|
|
5
5
|
import debounce from "debounce"
|
|
6
6
|
import EventListener from "@kaspernj/api-maker/src/event-listener"
|
|
7
|
-
import idForComponent from "@kaspernj/api-maker
|
|
8
|
-
import nameForComponent from "@kaspernj/api-maker
|
|
7
|
+
import idForComponent from "@kaspernj/api-maker/src/inputs/id-for-component.mjs"
|
|
8
|
+
import nameForComponent from "@kaspernj/api-maker/src/inputs/name-for-component.mjs"
|
|
9
9
|
import PropTypes from "prop-types"
|
|
10
10
|
|
|
11
11
|
const nameForComponentWithMultiple = (component) => {
|
|
12
12
|
let name = nameForComponent(component)
|
|
13
13
|
|
|
14
|
-
if (component.props.multiple) name += "[]"
|
|
14
|
+
if (component.props.multiple && name) name += "[]"
|
|
15
15
|
|
|
16
16
|
return name
|
|
17
17
|
}
|
|
@@ -85,9 +85,9 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
componentDidMount() {
|
|
88
|
-
const {attribute, defaultValue, defaultValuesFromOptions, model, options} = this.props
|
|
88
|
+
const {attribute, defaultValue, defaultValues, defaultValuesFromOptions, model, options} = this.props
|
|
89
89
|
|
|
90
|
-
if (((defaultValue || defaultValuesFromOptions) || (attribute && model)) && typeof options == "function") {
|
|
90
|
+
if (((defaultValue || defaultValues || defaultValuesFromOptions) || (attribute && model)) && typeof options == "function") {
|
|
91
91
|
this.loadDefaultValuesFromOptionsCallback()
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -166,10 +166,11 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
defaultValues () {
|
|
169
|
-
const {attribute, defaultValue, defaultValuesFromOptions, model} = this.props
|
|
169
|
+
const {attribute, defaultValue, defaultValues, defaultValuesFromOptions, model} = this.props
|
|
170
170
|
|
|
171
171
|
if (defaultValuesFromOptions) return defaultValuesFromOptions
|
|
172
172
|
if (defaultValue) return defaultValue
|
|
173
|
+
if (defaultValues) return defaultValues
|
|
173
174
|
|
|
174
175
|
if (attribute && model) {
|
|
175
176
|
if (!(attribute in model)) throw new Error(`No such attribute on ${model.modelClassData().name}: ${attribute}`)
|