From dc39b578891c28121ca738ab4afdfc4e5e2c0ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20D=C3=ADaz=20Gonz=C3=A1lez?= Date: Thu, 25 Jan 2024 08:22:18 +0000 Subject: [PATCH] [web] Minor core/Selector adjustments --- web/src/components/core/Selector.jsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/web/src/components/core/Selector.jsx b/web/src/components/core/Selector.jsx index 9634300758..b4522312cb 100644 --- a/web/src/components/core/Selector.jsx +++ b/web/src/components/core/Selector.jsx @@ -21,6 +21,7 @@ // @ts-check import React from 'react'; +import { noop } from '~/utils'; /** * Convenient component for letting the consumer build the selector options @@ -57,6 +58,11 @@ const Item = ({ id, type, isSelected = false, onClick, children }) => { ); }; +/** + * @callback onSelectionChangeCallback + * @param {Array} selection - ids of selected options + */ + /** * Agama component for building a selector * @@ -76,20 +82,20 @@ const Item = ({ id, type, isSelected = false, onClick, children }) => { * NOTE: using Children API to allow sending "rich content" as option children * directly with JSX. But most probably this will be changed to use a * item / renderItem props combination or similar to avoid both, using the - * Children API and iterating collections twice (one in the component mounted + * Children API and iterating collections twice (one in the component mounting * the selector and another here) * * @param {object} props - component props * @param {Array<*>} [props.selectedIds=[]] - Identifiers for selected options. * @param {boolean} [props.isMultiple=false] - Whether the selector should allow multiple selection. - * @param {(Array) => void } [props.onSelectionChange] - Callback to be called when the selection changes. + * @param {onSelectionChangeCallback} [props.onSelectionChange=noop] - Callback to be called when the selection changes. * @param {React.ReactNode} props.children - Selector options * @param {object} [props.props] - Other props sent to the internal selector
    component */ const Selector = ({ selectedIds = [], isMultiple = false, - onSelectionChange = () => {}, + onSelectionChange = noop, children, ...props }) => {