From 84380072502562088497e8353598e9217f519e6b Mon Sep 17 00:00:00 2001 From: Adrian Borrmann Date: Fri, 26 Sep 2025 12:31:47 -0600 Subject: [PATCH 1/6] refactor checklist portion of dropdown into its own optionlist; implement checklist component --- .../src/components/Checklist.react.js | 230 ------------------ .../src/components/Checklist.tsx | 63 +++++ .../src/components/css/checklist.css | 4 + .../src/components/css/dropdown.css | 35 --- .../src/components/css/optionslist.css | 42 ++++ .../src/fragments/Dropdown.tsx | 80 ++++-- components/dash-core-components/src/index.ts | 2 +- components/dash-core-components/src/types.ts | 89 ++++++- .../src/utils/optionRendering.tsx | 151 ++++++++++++ 9 files changed, 402 insertions(+), 294 deletions(-) delete mode 100644 components/dash-core-components/src/components/Checklist.react.js create mode 100644 components/dash-core-components/src/components/Checklist.tsx create mode 100644 components/dash-core-components/src/components/css/checklist.css create mode 100644 components/dash-core-components/src/components/css/optionslist.css create mode 100644 components/dash-core-components/src/utils/optionRendering.tsx diff --git a/components/dash-core-components/src/components/Checklist.react.js b/components/dash-core-components/src/components/Checklist.react.js deleted file mode 100644 index eb0c6c344b..0000000000 --- a/components/dash-core-components/src/components/Checklist.react.js +++ /dev/null @@ -1,230 +0,0 @@ -import PropTypes from 'prop-types'; -import {append, includes, without} from 'ramda'; -import React, {Component} from 'react'; - -import {sanitizeOptions} from '../utils/optionTypes'; -import LoadingElement from '../utils/LoadingElement'; - -/** - * Checklist is a component that encapsulates several checkboxes. - * The values and labels of the checklist are specified in the `options` - * property and the checked items are specified with the `value` property. - * Each checkbox is rendered as an input with a surrounding label. - */ -export default class Checklist extends Component { - render() { - const { - className, - id, - inputClassName, - inputStyle, - labelClassName, - labelStyle, - options, - setProps, - style, - value, - inline, - } = this.props; - return ( - - {sanitizeOptions(options).map(option => { - return ( - - ); - })} - - ); - } -} - -Checklist.propTypes = { - /** - * An array of options - */ - options: PropTypes.oneOfType([ - /** - * Array of options where the label and the value are the same thing - [string|number|bool] - */ - PropTypes.arrayOf( - PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - PropTypes.bool, - ]) - ), - /** - * Simpler `options` representation in dictionary format. The order is not guaranteed. - * {`value1`: `label1`, `value2`: `label2`, ... } - * which is equal to - * [{label: `label1`, value: `value1`}, {label: `label2`, value: `value2`}, ...] - */ - PropTypes.object, - /** - * An array of options {label: [string|number], value: [string|number]}, - * an optional disabled field can be used for each option - */ - PropTypes.arrayOf( - PropTypes.exact({ - /** - * The option's label - */ - label: PropTypes.node.isRequired, - - /** - * The value of the option. This value - * corresponds to the items specified in the - * `value` property. - */ - value: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - PropTypes.bool, - ]).isRequired, - - /** - * If true, this option is disabled and cannot be selected. - */ - disabled: PropTypes.bool, - - /** - * The HTML 'title' attribute for the option. Allows for - * information on hover. For more information on this attribute, - * see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title - */ - title: PropTypes.string, - }) - ), - ]), - - /** - * The currently selected value - */ - value: PropTypes.arrayOf( - PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number, - PropTypes.bool, - ]) - ), - - /** - * Indicates whether the options labels should be displayed inline (true=horizontal) - * or in a block (false=vertical). - */ - inline: PropTypes.bool, - - /** - * The class of the container (div) - */ - className: PropTypes.string, - - /** - * The style of the container (div) - */ - style: PropTypes.object, - - /** - * The style of the checkbox element - */ - inputStyle: PropTypes.object, - - /** - * The class of the checkbox element - */ - inputClassName: PropTypes.string, - - /** - * The style of the