|
|
|
@ -5,38 +5,58 @@
|
|
|
|
<option value="{ selected[ state.keys.value ] }" selected each={ selected in state.selected }></option>
|
|
|
|
<option value="{ selected[ state.keys.value ] }" selected each={ selected in state.selected }></option>
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="field-select__options">
|
|
|
|
<div class="field-text field-select__selections" onclick={ (event) => { handleToggleSelection(event) } }>
|
|
|
|
<div class="{ getFilterClasses(['field-select__options-filter']) }" if={ props.searchable !== undefined }>
|
|
|
|
<ul class="field-select__selections-list">
|
|
|
|
<input type="text" class="field-text m-top-0" placeholder={ props.placeholderFilter } onkeyup={ (event) => { handleOnKeyUp(event) }} disabled={ props.disabled !== undefined } />
|
|
|
|
<li class="badge badge--success field-select__selections-item" each={ item in state.selected } onclick={ (event) => { handleToggle(event, item) } }>
|
|
|
|
<button type="button" class="field-select__options-filter-reset" onclick={ (event) => { handleResetSearchable(event) } }>
|
|
|
|
{ item[ state.keys.label ] }
|
|
|
|
⮾
|
|
|
|
<button type="button" class="field-select__selections-remove">
|
|
|
|
</button>
|
|
|
|
⮾
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
<div class="panel">
|
|
|
|
</li>
|
|
|
|
<div class="bar justify-content-end">
|
|
|
|
</ul>
|
|
|
|
<div class="bar__end">
|
|
|
|
<span class="placeholder" if={ props.placeholderLabel && state.selected.length === 0 }>
|
|
|
|
{ state.selected.length } / { state.options.length } 🗇
|
|
|
|
{ props.placeholderLabel }
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="{ getModalClasses(['modal']) }">
|
|
|
|
|
|
|
|
<div class="field-select__options">
|
|
|
|
|
|
|
|
<div class="panel">
|
|
|
|
|
|
|
|
<div class="bar justify-content-end">
|
|
|
|
|
|
|
|
<div class="bar__start">
|
|
|
|
|
|
|
|
{ state.selected.length } / { state.options.length } 🗇
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="{ getFilterClasses(['field-select__options-filter']) }" if={ props.searchable !== undefined }>
|
|
|
|
|
|
|
|
<input type="text" class="field-text m-top-0" placeholder={ props.placeholderFilter } onkeyup={ (event) => { handleOnKeyUp(event) }} disabled={ props.disabled !== undefined } />
|
|
|
|
|
|
|
|
<button type="button" class="field-select__options-filter-reset" onclick={ (event) => { handleResetSearchable(event) } }>
|
|
|
|
|
|
|
|
⮾
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field-select__options-panel">
|
|
|
|
|
|
|
|
<ul class="field-select__options-list">
|
|
|
|
|
|
|
|
<li class="{ getItemClasses(['field-select__options-item'], option) }" each={ option in state.options } onclick={ (event) => { handleToggle(event, option) } }>
|
|
|
|
|
|
|
|
<span class="field-select__options-item-check">
|
|
|
|
|
|
|
|
☑
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="field-select__options-item-uncheck">
|
|
|
|
|
|
|
|
☐
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
{ option[ state.keys.label ] }
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li class="field-select__item field-select__item--empty center color-danger" if={ state.options.length === 0 }>
|
|
|
|
|
|
|
|
∅
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="display-flex">
|
|
|
|
|
|
|
|
<button type="button" class="button button--success button--full m-bottom-0 w-100" onclick={ (event) => { handleOptionsConfirm(event) } }>
|
|
|
|
|
|
|
|
✓
|
|
|
|
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field-select__options-panel">
|
|
|
|
|
|
|
|
<ul class="field-select__options-list">
|
|
|
|
|
|
|
|
<li class="{ getItemClasses(['field-select__options-item'], option) }" each={ option in state.options } onclick={ (event) => { handleToggle(event, option) } }>
|
|
|
|
|
|
|
|
<span class="field-select__options-item-check">
|
|
|
|
|
|
|
|
☑
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="field-select__options-item-uncheck">
|
|
|
|
|
|
|
|
☐
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
{ option[ state.keys.label ] }
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li class="field-select__item field-select__item--empty center color-danger" if={ state.options.length === 0 }>
|
|
|
|
|
|
|
|
∅
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
@ -58,7 +78,8 @@
|
|
|
|
selected: [],
|
|
|
|
selected: [],
|
|
|
|
hasUpdated: false,
|
|
|
|
hasUpdated: false,
|
|
|
|
options: [],
|
|
|
|
options: [],
|
|
|
|
query: ''
|
|
|
|
query: '',
|
|
|
|
|
|
|
|
isSelectionOpen: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.props.label) {
|
|
|
|
if (this.props.label) {
|
|
|
|
@ -74,6 +95,20 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
onBeforeUpdate() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// props has changed after reset
|
|
|
|
|
|
|
|
if (this.props.selected && this.props.selected.length > 0 && !this.state.hasUpdated) {
|
|
|
|
|
|
|
|
this.state.selected = this.props.selected
|
|
|
|
|
|
|
|
this.state.hasUpdated = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -123,18 +158,28 @@
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleOptionsConfirm(event) {
|
|
|
|
|
|
|
|
this.handleToggleSelection(event)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
onBeforeUpdate() {
|
|
|
|
handleToggleSelection(event) {
|
|
|
|
|
|
|
|
|
|
|
|
// props has changed after reset
|
|
|
|
if (this.props.disabled !== undefined) {
|
|
|
|
if (this.props.selected && this.props.selected.length > 0 && !this.state.hasUpdated) {
|
|
|
|
event.preventDefault()
|
|
|
|
this.state.selected = this.props.selected
|
|
|
|
return false
|
|
|
|
this.state.hasUpdated = true
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.state.isSelectionOpen === true) {
|
|
|
|
|
|
|
|
this.state.isSelectionOpen = false
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.state.isSelectionOpen = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.update()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -162,6 +207,8 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
handleToggle(event, option) {
|
|
|
|
handleToggle(event, option) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event.stopPropagation()
|
|
|
|
|
|
|
|
|
|
|
|
if (this.props.disabled !== undefined) {
|
|
|
|
if (this.props.disabled !== undefined) {
|
|
|
|
event.preventDefault()
|
|
|
|
event.preventDefault()
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
@ -220,6 +267,14 @@
|
|
|
|
return classes.join(' ')
|
|
|
|
return classes.join(' ')
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getModalClasses(classes) {
|
|
|
|
|
|
|
|
if (this.state.isSelectionOpen === true) {
|
|
|
|
|
|
|
|
classes.push('modal--open')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return classes.join(' ')
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* search all selected for value return index or false
|
|
|
|
* search all selected for value return index or false
|
|
|
|
*
|
|
|
|
*
|
|
|
|
|