update checklist components

This commit is contained in:
f0x 2023-01-31 00:34:01 +01:00
commit 79c792b832
5 changed files with 104 additions and 73 deletions

View file

@ -81,7 +81,6 @@ module.exports = function useCheckListInput({ name }, { entries, uniqueKey = "ke
const toggleAllRef = React.useRef(null);
React.useEffect(() => {
performance.mark("GoToSocial-useCheckListInput-useEffect-start");
/* Updates (un)check all checkbox, based on shortcode checkboxes
Can be 0 (not checked), 1 (checked) or 2 (indeterminate)
*/
@ -108,8 +107,6 @@ module.exports = function useCheckListInput({ name }, { entries, uniqueKey = "ke
setToggleAllState(all ? 1 : 0);
toggleAllRef.current.indeterminate = false;
}
performance.mark("GoToSocial-useCheckListInput-useEffect-finish");
performance.measure("GoToSocial-useCheckListInput-useEffect-processed", "GoToSocial-useCheckListInput-useEffect-start", "GoToSocial-useCheckListInput-useEffect-finish");
}, [state, toggleAllRef]);
const reset = React.useCallback(
@ -137,7 +134,8 @@ module.exports = function useCheckListInput({ name }, { entries, uniqueKey = "ke
function selectedValues() {
return syncpipe(state, [
(_) => Object.values(_),
(_) => _.filter((entry) => entry.checked)
(_) => _.filter((entry) => entry.checked),
(_) => _.map((entry) => ({ ...entry }))
]);
}

View file

@ -87,6 +87,7 @@ module.exports = function useTextInput({ name, Name }, {
ref: textRef,
setter: setText,
valid,
validate: () => setValidation(validator(text)),
hasChanged: () => text != defaultValue
});
};