haya-select 1.0.23 → 1.0.24
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 +2 -2
- package/src/select/index.jsx +3 -0
- package/src/select/option-group.jsx +12 -12
- package/src/select/option.jsx +27 -29
- package/src/select/style.scss +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "haya-select",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"debounce": "^1.2.1",
|
|
14
14
|
"diggerize": "^1.0.4",
|
|
15
15
|
"fetching-object": "^1.0.1",
|
|
16
|
-
"set-state-compare": "^1.0.
|
|
16
|
+
"set-state-compare": "^1.0.27"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"prop-types": ">= 15.7.2",
|
package/src/select/index.jsx
CHANGED
|
@@ -485,6 +485,9 @@ export default class HayaSelect extends React.PureComponent {
|
|
|
485
485
|
newState.currentOptions = currentOptions.filter((currentOption) => currentOption.value != loadedOption.value)
|
|
486
486
|
}
|
|
487
487
|
} else {
|
|
488
|
+
// Don't do anything if the clicked option is disabled
|
|
489
|
+
if (loadedOption.disabled) return
|
|
490
|
+
|
|
488
491
|
if (toggleOptions) {
|
|
489
492
|
newToggled[loadedOption.value] = 0
|
|
490
493
|
newState.toggled = newToggled
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import PropTypes from "prop-types"
|
|
2
|
-
import
|
|
2
|
+
import {memo} from "react"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
option
|
|
7
|
-
|
|
4
|
+
const OptionGroup = ({option}) => {
|
|
5
|
+
return (
|
|
6
|
+
<div className="haya-select--option-group">
|
|
7
|
+
{option.text}
|
|
8
|
+
</div>
|
|
9
|
+
)
|
|
10
|
+
}
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<div className="haya-select--option-group">
|
|
12
|
-
{this.props.option.text}
|
|
13
|
-
</div>
|
|
14
|
-
)
|
|
15
|
-
}
|
|
12
|
+
OptionGroup.propTypes = {
|
|
13
|
+
option: PropTypes.object.isRequired
|
|
16
14
|
}
|
|
15
|
+
|
|
16
|
+
export default memo(OptionGroup)
|
package/src/select/option.jsx
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
import {digs} from "diggerize"
|
|
2
1
|
import PropTypes from "prop-types"
|
|
3
|
-
import
|
|
2
|
+
import {memo, useMemo} from "react"
|
|
3
|
+
import useShape from "set-state-compare/src/use-shape.js"
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
onOptionClicked: PropTypes.func.isRequired,
|
|
10
|
-
option: PropTypes.object.isRequired,
|
|
11
|
-
presentOption: PropTypes.func.isRequired
|
|
12
|
-
}
|
|
5
|
+
const Option = (props) => {
|
|
6
|
+
const s = useShape(props)
|
|
7
|
+
const onClick = useCallback((e) => s.p.onOptionClicked(e, s.p.option), [])
|
|
8
|
+
const selected = Boolean(s.p.currentOptions.find((currentOption) => currentOption.value == s.p.option.value))
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
style={this.style}
|
|
27
|
-
>
|
|
28
|
-
{this.props.presentOption(option)}
|
|
29
|
-
</div>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
10
|
+
return (
|
|
11
|
+
<div
|
|
12
|
+
className="haya-select-option"
|
|
13
|
+
data-disabled={Boolean(s.p.option.disabled)}
|
|
14
|
+
data-selected={selected}
|
|
15
|
+
data-value={s.p.option.value}
|
|
16
|
+
onClick={onClick}
|
|
17
|
+
>
|
|
18
|
+
{props.presentOption(s.p.option)}
|
|
19
|
+
</div>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
32
22
|
|
|
33
|
-
|
|
23
|
+
Option.propTypes = {
|
|
24
|
+
currentOptions: PropTypes.array.isRequired,
|
|
25
|
+
disabled: PropTypes.bool,
|
|
26
|
+
icon: PropTypes.string,
|
|
27
|
+
onOptionClicked: PropTypes.func.isRequired,
|
|
28
|
+
option: PropTypes.object.isRequired,
|
|
29
|
+
presentOption: PropTypes.func.isRequired
|
|
34
30
|
}
|
|
31
|
+
|
|
32
|
+
export default memo(Option)
|
package/src/select/style.scss
CHANGED