Skip to content

Commit

Permalink
Merge pull request #88 from DripEmail/release-0.17.2
Browse files Browse the repository at this point in the history
Release 0.17.2
  • Loading branch information
Jachin Rupe committed Jan 30, 2023
2 parents d29dde0 + d3d1ae3 commit 9e09ae4
Show file tree
Hide file tree
Showing 37 changed files with 50,908 additions and 524 deletions.
134 changes: 73 additions & 61 deletions dist/much-select-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,16 @@ class MuchSelect extends HTMLElement {

// noinspection JSUnresolvedVariable,JSIgnoredPromiseFromCall
this.appPromise.then((app) =>
app.ports.valueChanged.subscribe(this.valueChangedHandler.bind(this))
app.ports.valueChangedSingleSelect.subscribe(
this.valueChangedHandlerSingleSelect.bind(this)
)
);

// noinspection JSUnresolvedVariable,JSIgnoredPromiseFromCall
this.appPromise.then((app) =>
app.ports.valueChangedMultiSelectSelect.subscribe(
this.valueChangedHandlerMultiSelectSelect.bind(this)
)
);

// noinspection JSUnresolvedVariable,JSIgnoredPromiseFromCall
Expand Down Expand Up @@ -1026,82 +1035,85 @@ class MuchSelect extends HTMLElement {
}

/**
* This method gets called any time the Elm app changes the value of this much select.
* An "outgoing port" if you will.
* This method gets called any time the Elm app changes the value of this much select
* if it is in single select mode. An "outgoing port" if you will.
*
* The selected values always come in an array of tuples, the first part of the tuple
* being the value, and the second part being the label.
*
* @param {array} valuesObjects
* @param {boolean} isInitialValueChange - This prevents events from being emitted while things are getting setup.
*/
valueChangedHandler(valuesObjects, isInitialValueChange = false) {
valueChangedHandlerSingleSelect(valuesObjects) {
const isValid = valuesObjects.filter((v) => !v.isValid).length === 0;

if (isValid) {
this._emitBlurOrUnfocusedValueChanged = true;
}

this.updateDimensions();
if (
this.hasAttribute("multi-select") &&
this.getAttribute("multi-select") !== "false"
) {
if (!isInitialValueChange) {
this.dispatchEvent(
new CustomEvent("valueChanged", {
bubbles: true,
detail: { values: valuesObjects, isValid },
})
);
// The change event is for backwards compatibility.
this.dispatchEvent(
new CustomEvent("change", {
bubbles: true,
detail: { values: valuesObjects, isValid },
})
);
}
} else if (valuesObjects.length === 0) {
if (!isInitialValueChange) {
// If we are in single select mode and the value is empty.
this.dispatchEvent(
new CustomEvent("valueChanged", {
bubbles: true,
detail: { value: null, values: [], isValid },
})
);
// The change event is for backwards compatibility.
this.dispatchEvent(
new CustomEvent("change", {
bubbles: true,
detail: { value: null, values: [], isValid },
})
);
}
} else if (valuesObjects.length === 1) {
if (!isInitialValueChange) {
// If we are in single select mode put the list of values in the event.
this.dispatchEvent(
new CustomEvent("valueChanged", {
bubbles: true,
detail: { value: valuesObjects[0], values: valuesObjects, isValid },
})
);
// The change event is for backwards compatibility.
this.dispatchEvent(
new CustomEvent("changed", {
bubbles: true,
detail: { value: valuesObjects, isValid },
})
);
}
if (valuesObjects.length === 0) {
// If we are in single select mode and the value is empty.
this.dispatchEvent(
new CustomEvent("valueChanged", {
bubbles: true,
detail: { value: null, values: [], isValid },
})
);
// The change event is for backwards compatibility.
this.dispatchEvent(
new CustomEvent("change", {
bubbles: true,
detail: { value: null, values: [], isValid },
})
);
} else {
// If we are in single select mode and there is more than one value then something is wrong.
throw new TypeError(
`In single select mode we are expecting a single value, instead we got ${valuesObjects.length}`
// If we are in single select mode put the list of values in the event.
this.dispatchEvent(
new CustomEvent("valueChanged", {
bubbles: true,
detail: { value: valuesObjects[0], values: valuesObjects, isValid },
})
);
// The change event is for backwards compatibility.
this.dispatchEvent(
new CustomEvent("changed", {
bubbles: true,
detail: { value: valuesObjects, isValid },
})
);
}
}

/**
* This method gets called any time the Elm app changes the value of this much select
* if it is in multi select mode. An "outgoing port" if you will.
*
* The selected values always come in an array of tuples, the first part of the tuple
* being the value, and the second part being the label.
*
* @param {array} valuesObjects
*/
valueChangedHandlerMultiSelectSelect(valuesObjects) {
const isValid = valuesObjects.filter((v) => !v.isValid).length === 0;

if (isValid) {
this._emitBlurOrUnfocusedValueChanged = true;
}

this.updateDimensions();
this.dispatchEvent(
new CustomEvent("valueChanged", {
bubbles: true,
detail: { values: valuesObjects, isValid },
})
);
// The change event is for backwards compatibility.
this.dispatchEvent(
new CustomEvent("change", {
bubbles: true,
detail: { values: valuesObjects, isValid },
})
);
}

customOptionSelected(values) {
Expand Down
35 changes: 23 additions & 12 deletions dist/much-select-elm-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -12816,7 +12816,8 @@ var $author$project$Ports$updateOptionsInWebWorker = _Platform_outgoingPort(
function ($) {
return $elm$json$Json$Encode$null;
});
var $author$project$Ports$valueChanged = _Platform_outgoingPort('valueChanged', $elm$core$Basics$identity);
var $author$project$Ports$valueChangedMultiSelectSelect = _Platform_outgoingPort('valueChangedMultiSelectSelect', $elm$core$Basics$identity);
var $author$project$Ports$valueChangedSingleSelect = _Platform_outgoingPort('valueChangedSingleSelect', $elm$core$Basics$identity);
var $author$project$Ports$valueCleared = _Platform_outgoingPort(
'valueCleared',
function ($) {
Expand Down Expand Up @@ -12851,7 +12852,12 @@ var $author$project$MuchSelect$perform = function (effect) {
return $author$project$Ports$searchOptionsWithWebWorker(value);
case 'ReportValueChanged':
var value = effect.a;
return $author$project$Ports$valueChanged(value);
var selectionMode = effect.b;
if (selectionMode.$ === 'SingleSelect') {
return $author$project$Ports$valueChangedSingleSelect(value);
} else {
return $author$project$Ports$valueChangedMultiSelectSelect(value);
}
case 'ValueCleared':
return $author$project$Ports$valueCleared(_Utils_Tuple0);
case 'InvalidValue':
Expand All @@ -12870,9 +12876,9 @@ var $author$project$MuchSelect$perform = function (effect) {
var bool = effect.a;
return $author$project$Ports$optionsUpdated(bool);
case 'SendCustomValidationRequest':
var _v1 = effect.a;
var string = _v1.a;
var _int = _v1.b;
var _v2 = effect.a;
var string = _v2.a;
var _int = _v2.b;
return $author$project$Ports$sendCustomValidationRequest(
_Utils_Tuple2(string, _int));
case 'ReportErrorMessage':
Expand Down Expand Up @@ -13147,9 +13153,10 @@ var $author$project$MuchSelect$OptionsUpdated = function (a) {
var $author$project$MuchSelect$ReportAllOptions = function (a) {
return {$: 'ReportAllOptions', a: a};
};
var $author$project$MuchSelect$ReportValueChanged = function (a) {
return {$: 'ReportValueChanged', a: a};
};
var $author$project$MuchSelect$ReportValueChanged = F2(
function (a, b) {
return {$: 'ReportValueChanged', a: a, b: b};
});
var $author$project$MuchSelect$ScrollDownToElement = function (a) {
return {$: 'ScrollDownToElement', a: a};
};
Expand Down Expand Up @@ -13795,8 +13802,10 @@ var $author$project$OptionsUtilities$optionsValues = function (options) {
};
var $author$project$MuchSelect$makeEffectsWhenValuesChanges = F4(
function (eventsMode, selectionMode, selectedValueEncoding, selectedOptions) {
var valueChangeCmd = $author$project$OptionsUtilities$allOptionsAreValid(selectedOptions) ? $author$project$MuchSelect$ReportValueChanged(
$author$project$Ports$optionsEncoder(selectedOptions)) : ($author$project$OptionsUtilities$hasAnyPendingValidation(selectedOptions) ? $author$project$MuchSelect$NoEffect : $author$project$MuchSelect$InvalidValue(
var valueChangeCmd = $author$project$OptionsUtilities$allOptionsAreValid(selectedOptions) ? A2(
$author$project$MuchSelect$ReportValueChanged,
$author$project$Ports$optionsEncoder(selectedOptions),
selectionMode) : ($author$project$OptionsUtilities$hasAnyPendingValidation(selectedOptions) ? $author$project$MuchSelect$NoEffect : $author$project$MuchSelect$InvalidValue(
$author$project$Ports$optionsEncoder(selectedOptions)));
var selectedCustomOptions = $author$project$OptionsUtilities$customSelectedOptions(selectedOptions);
var lightDomChangeEffect = function () {
Expand Down Expand Up @@ -17818,9 +17827,11 @@ var $author$project$MuchSelect$update = F2(
$author$project$MuchSelect$batch(
_List_fromArray(
[
$author$project$MuchSelect$ReportValueChanged(
A2(
$author$project$MuchSelect$ReportValueChanged,
$author$project$Ports$optionsEncoder(
$author$project$OptionsUtilities$selectedOptions(updatedOptions))),
$author$project$OptionsUtilities$selectedOptions(updatedOptions)),
$author$project$SelectionMode$getSelectionMode(model.selectionConfig)),
$author$project$MuchSelect$FocusInput
])));
}
Expand Down
35 changes: 23 additions & 12 deletions dist/much-select-elm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7475,7 +7475,8 @@ var $author$project$Ports$updateOptionsInWebWorker = _Platform_outgoingPort(
function ($) {
return $elm$json$Json$Encode$null;
});
var $author$project$Ports$valueChanged = _Platform_outgoingPort('valueChanged', $elm$core$Basics$identity);
var $author$project$Ports$valueChangedMultiSelectSelect = _Platform_outgoingPort('valueChangedMultiSelectSelect', $elm$core$Basics$identity);
var $author$project$Ports$valueChangedSingleSelect = _Platform_outgoingPort('valueChangedSingleSelect', $elm$core$Basics$identity);
var $author$project$Ports$valueCleared = _Platform_outgoingPort(
'valueCleared',
function ($) {
Expand Down Expand Up @@ -7510,7 +7511,12 @@ var $author$project$MuchSelect$perform = function (effect) {
return $author$project$Ports$searchOptionsWithWebWorker(value);
case 10:
var value = effect.a;
return $author$project$Ports$valueChanged(value);
var selectionMode = effect.b;
if (!selectionMode) {
return $author$project$Ports$valueChangedSingleSelect(value);
} else {
return $author$project$Ports$valueChangedMultiSelectSelect(value);
}
case 11:
return $author$project$Ports$valueCleared(0);
case 12:
Expand All @@ -7529,9 +7535,9 @@ var $author$project$MuchSelect$perform = function (effect) {
var bool = effect.a;
return $author$project$Ports$optionsUpdated(bool);
case 17:
var _v1 = effect.a;
var string = _v1.a;
var _int = _v1.b;
var _v2 = effect.a;
var string = _v2.a;
var _int = _v2.b;
return $author$project$Ports$sendCustomValidationRequest(
_Utils_Tuple2(string, _int));
case 18:
Expand Down Expand Up @@ -7808,9 +7814,10 @@ var $author$project$MuchSelect$OptionsUpdated = function (a) {
var $author$project$MuchSelect$ReportAllOptions = function (a) {
return {$: 23, a: a};
};
var $author$project$MuchSelect$ReportValueChanged = function (a) {
return {$: 10, a: a};
};
var $author$project$MuchSelect$ReportValueChanged = F2(
function (a, b) {
return {$: 10, a: a, b: b};
});
var $author$project$MuchSelect$ScrollDownToElement = function (a) {
return {$: 22, a: a};
};
Expand Down Expand Up @@ -8477,8 +8484,10 @@ var $author$project$OptionsUtilities$optionsValues = function (options) {
};
var $author$project$MuchSelect$makeEffectsWhenValuesChanges = F4(
function (eventsMode, selectionMode, selectedValueEncoding, selectedOptions) {
var valueChangeCmd = $author$project$OptionsUtilities$allOptionsAreValid(selectedOptions) ? $author$project$MuchSelect$ReportValueChanged(
$author$project$Ports$optionsEncoder(selectedOptions)) : ($author$project$OptionsUtilities$hasAnyPendingValidation(selectedOptions) ? $author$project$MuchSelect$NoEffect : $author$project$MuchSelect$InvalidValue(
var valueChangeCmd = $author$project$OptionsUtilities$allOptionsAreValid(selectedOptions) ? A2(
$author$project$MuchSelect$ReportValueChanged,
$author$project$Ports$optionsEncoder(selectedOptions),
selectionMode) : ($author$project$OptionsUtilities$hasAnyPendingValidation(selectedOptions) ? $author$project$MuchSelect$NoEffect : $author$project$MuchSelect$InvalidValue(
$author$project$Ports$optionsEncoder(selectedOptions)));
var selectedCustomOptions = $author$project$OptionsUtilities$customSelectedOptions(selectedOptions);
var lightDomChangeEffect = function () {
Expand Down Expand Up @@ -12521,9 +12530,11 @@ var $author$project$MuchSelect$update = F2(
$author$project$MuchSelect$batch(
_List_fromArray(
[
$author$project$MuchSelect$ReportValueChanged(
A2(
$author$project$MuchSelect$ReportValueChanged,
$author$project$Ports$optionsEncoder(
$author$project$OptionsUtilities$selectedOptions(updatedOptions))),
$author$project$OptionsUtilities$selectedOptions(updatedOptions)),
$author$project$SelectionMode$getSelectionMode(model.a)),
$author$project$MuchSelect$FocusInput
])));
}
Expand Down
Loading

0 comments on commit 9e09ae4

Please sign in to comment.