From 681d07175f5aa2e4e9128d39ddfc06e9d0201632 Mon Sep 17 00:00:00 2001 From: Maksim Efremov Date: Thu, 12 Sep 2024 23:49:33 +0300 Subject: [PATCH] fix: add export of TabFieldVerticalProps (rework exports) --- .../CheckBoxControl/CheckBoxControl.tsx | 4 +- src/dialog/CheckBoxControl/index.ts | 1 + src/dialog/CollapsibleSection/index.ts | 1 + src/dialog/Condition/Condition.tsx | 4 +- src/dialog/Condition/index.ts | 1 + src/dialog/CustomBlock/CustomBlock.tsx | 4 +- src/dialog/CustomBlock/index.ts | 1 + src/dialog/Dialog/Dialog.tsx | 67 ++++++++++--------- src/dialog/Dialog/index.ts | 1 + src/dialog/EditableList/EditableList.tsx | 4 +- src/dialog/EditableList/index.ts | 1 + .../EditableManyLists/EditableManyLists.tsx | 6 +- src/dialog/EditableManyLists/index.ts | 1 + .../FocusBlurContainer/FocusBlurContainer.tsx | 2 +- src/dialog/FocusBlurContainer/index.ts | 1 + src/dialog/Icon/index.ts | 1 + .../LabelsGroup/LabelsGroup.tsx | 12 ++-- .../MultiTextControl/MultiTextControl.tsx | 14 ++-- src/dialog/MultiTextControl/index.ts | 1 + src/dialog/PlainText/PlainText.tsx | 4 +- src/dialog/PlainText/index.ts | 1 + .../RadioButtonControl/RadioButtonControl.tsx | 8 +-- src/dialog/RadioButtonControl/index.ts | 1 + src/dialog/SelectControl/index.ts | 1 + src/dialog/TabField/TabField.tsx | 8 +-- src/dialog/TabField/TabFieldVertical.tsx | 10 ++- src/dialog/TabField/index.ts | 2 + .../TextAreaControl/TextAreaControl.tsx | 4 +- src/dialog/TextAreaControl/index.ts | 1 + src/dialog/TextControl/TextControl.tsx | 4 +- src/dialog/TextControl/index.ts | 1 + src/dialog/TumblerControl/TumblerControl.tsx | 4 +- src/dialog/TumblerControl/index.ts | 1 + src/dialog/index.ts | 12 ++++ src/helpers/index.ts | 1 + src/index.ts | 27 +------- src/stories/EditableList.stories.tsx | 5 +- src/stories/EditableManyLists.stories.tsx | 7 +- src/stories/MultiTextControl.stories.tsx | 2 +- src/stories/TumblerControl.stories.tsx | 2 +- .../dialog/00_Base_controls.stories.tsx | 18 +++-- src/stories/dialog/01_One_tab.stories.tsx | 4 +- .../dialog/02_Several_tabs.stories.tsx | 4 +- src/stories/dialog/03_Sections.stories.tsx | 4 +- .../04_Visibility_condition.stories.tsx | 4 +- .../05_Extras_and_linked_fields.stories.tsx | 4 +- .../dialog/06_Field_validators.stories.tsx | 4 +- .../dialog/07_Form_validation.stories.tsx | 4 +- .../dialog/08_Virtualized_tabs.stories.tsx | 4 +- .../dialog/09_Cloneable_tabs.stories.tsx | 4 +- .../dialog/fields/01_full_width.stories.tsx | 4 +- .../register/RegisterControls.stories.tsx | 2 +- 52 files changed, 140 insertions(+), 153 deletions(-) create mode 100644 src/dialog/CheckBoxControl/index.ts create mode 100644 src/dialog/CollapsibleSection/index.ts create mode 100644 src/dialog/Condition/index.ts create mode 100644 src/dialog/CustomBlock/index.ts create mode 100644 src/dialog/Dialog/index.ts create mode 100644 src/dialog/EditableList/index.ts create mode 100644 src/dialog/EditableManyLists/index.ts create mode 100644 src/dialog/FocusBlurContainer/index.ts create mode 100644 src/dialog/Icon/index.ts create mode 100644 src/dialog/MultiTextControl/index.ts create mode 100644 src/dialog/PlainText/index.ts create mode 100644 src/dialog/RadioButtonControl/index.ts create mode 100644 src/dialog/SelectControl/index.ts create mode 100644 src/dialog/TabField/index.ts create mode 100644 src/dialog/TextAreaControl/index.ts create mode 100644 src/dialog/TextControl/index.ts create mode 100644 src/dialog/TumblerControl/index.ts create mode 100644 src/dialog/index.ts create mode 100644 src/helpers/index.ts diff --git a/src/dialog/CheckBoxControl/CheckBoxControl.tsx b/src/dialog/CheckBoxControl/CheckBoxControl.tsx index f2deb5c..aa39857 100644 --- a/src/dialog/CheckBoxControl/CheckBoxControl.tsx +++ b/src/dialog/CheckBoxControl/CheckBoxControl.tsx @@ -10,7 +10,7 @@ export interface CheckBoxControlProps onChange: (value: CheckBoxControlProps['value']) => void; } -function CheckBoxControl({value, onChange, ...props}: CheckBoxControlProps) { +export function CheckBoxControl({value, onChange, ...props}: CheckBoxControlProps) { const onCheckBoxChange = useCallback(() => onChange(!value), [onChange, value]); const {children, ...rest} = props || {}; @@ -28,5 +28,3 @@ CheckBoxControl.getDefaultValue = function () { CheckBoxControl.isEmpty = function (value: CheckBoxControlProps['value']) { return typeof value !== 'boolean' || !value; }; - -export default CheckBoxControl; diff --git a/src/dialog/CheckBoxControl/index.ts b/src/dialog/CheckBoxControl/index.ts new file mode 100644 index 0000000..ea3dee8 --- /dev/null +++ b/src/dialog/CheckBoxControl/index.ts @@ -0,0 +1 @@ +export * from './CheckBoxControl'; diff --git a/src/dialog/CollapsibleSection/index.ts b/src/dialog/CollapsibleSection/index.ts new file mode 100644 index 0000000..4e40ada --- /dev/null +++ b/src/dialog/CollapsibleSection/index.ts @@ -0,0 +1 @@ +export * from './CollapsibleSection'; diff --git a/src/dialog/Condition/Condition.tsx b/src/dialog/Condition/Condition.tsx index 913b2a3..6097c08 100644 --- a/src/dialog/Condition/Condition.tsx +++ b/src/dialog/Condition/Condition.tsx @@ -7,12 +7,10 @@ interface Props { children: React.ReactNode; } -function Condition({when, isActive, children}: Props) { +export function Condition({when, isActive, children}: Props) { return ( {({input: {value}}) => (isActive(value) ? children : null)} ); } - -export default Condition; diff --git a/src/dialog/Condition/index.ts b/src/dialog/Condition/index.ts new file mode 100644 index 0000000..db67358 --- /dev/null +++ b/src/dialog/Condition/index.ts @@ -0,0 +1 @@ +export * from './Condition'; diff --git a/src/dialog/CustomBlock/CustomBlock.tsx b/src/dialog/CustomBlock/CustomBlock.tsx index 568a7a0..c6bf016 100644 --- a/src/dialog/CustomBlock/CustomBlock.tsx +++ b/src/dialog/CustomBlock/CustomBlock.tsx @@ -7,7 +7,7 @@ export interface CustomBlockProps { children: React.ReactNode; } -class CustomBlock extends React.Component { +export class CustomBlock extends React.Component { static renderLabel = () => null; static getDefaultValue = () => undefined; @@ -15,5 +15,3 @@ class CustomBlock extends React.Component { return this.props.children || null; } } - -export default CustomBlock; diff --git a/src/dialog/CustomBlock/index.ts b/src/dialog/CustomBlock/index.ts new file mode 100644 index 0000000..7717f0b --- /dev/null +++ b/src/dialog/CustomBlock/index.ts @@ -0,0 +1 @@ +export * from './CustomBlock'; diff --git a/src/dialog/Dialog/Dialog.tsx b/src/dialog/Dialog/Dialog.tsx index ee72f77..8832e5c 100644 --- a/src/dialog/Dialog/Dialog.tsx +++ b/src/dialog/Dialog/Dialog.tsx @@ -1,11 +1,11 @@ import React, {Component, Fragment} from 'react'; -import _reduce from 'lodash/reduce'; -import _find from 'lodash/find'; -import _findIndex from 'lodash/findIndex'; -import _isEqual from 'lodash/isEqual'; -import _get from 'lodash/get'; -import _isEmpty from 'lodash/isEmpty'; -import _map from 'lodash/map'; +import reduce_ from 'lodash/reduce'; +import find_ from 'lodash/find'; +import findIndex_ from 'lodash/findIndex'; +import isEqual_ from 'lodash/isEqual'; +import get_ from 'lodash/get'; +import isEmpty_ from 'lodash/isEmpty'; +import map_ from 'lodash/map'; import { Dialog as CommonDialog, DialogFooterProps, @@ -21,26 +21,29 @@ import createDecorator, {Calculation, Updates} from 'final-form-calculate'; import {OnChange} from 'react-final-form-listeners'; import {InfoIcon, TooltipIcon, WarningIcon} from '../Icon/Icon'; -import TextControl, {TextControlProps} from '../TextControl/TextControl'; -import TextAreaControl, {TextAreaControlProps} from '../TextAreaControl/TextAreaControl'; -import {SelectControl, SelectControlProps} from '../SelectControl/SelectControl'; -import TumblerControl, {TumblerControlProps} from '../TumblerControl/TumblerControl'; -import PlainText, {PlainTextProps} from '../PlainText/PlainText'; -import CheckBoxControl, {CheckBoxControlProps} from '../CheckBoxControl/CheckBoxControl'; -import Condition from '../Condition/Condition'; -import CustomBlock, {CustomBlockProps} from '../CustomBlock/CustomBlock'; -import RadioButtonControl, { - RadioButtonControlProps, -} from '../RadioButtonControl/RadioButtonControl'; -import EditableList, {EditableListProps} from '../EditableList/EditableList'; -import EditableManyLists, {EditableManyListsProps} from '../EditableManyLists/EditableManyLists'; -import MultiTextControl, {MultiTextControlProps} from '../MultiTextControl/MultiTextControl'; -import TabField, {TabFieldProps, TabItem} from '../TabField/TabField'; +import {TextControl, TextControlProps} from '../TextControl'; +import {TextAreaControl, TextAreaControlProps} from '../TextAreaControl'; +import {SelectControl, SelectControlProps} from '../SelectControl'; +import {TumblerControl, TumblerControlProps} from '../TumblerControl'; +import {PlainText, PlainTextProps} from '../PlainText'; +import {CheckBoxControl, CheckBoxControlProps} from '../CheckBoxControl'; +import {Condition} from '../Condition'; +import {CustomBlock, CustomBlockProps} from '../CustomBlock'; +import {RadioButtonControl, RadioButtonControlProps} from '../RadioButtonControl'; +import {EditableList, EditableListProps} from '../EditableList'; +import {EditableManyLists, EditableManyListsProps} from '../EditableManyLists'; +import {MultiTextControl, MultiTextControlProps} from '../MultiTextControl'; +import { + TabField, + TabFieldProps, + TabFieldVertical, + TabFieldVerticalProps, + TabItem, +} from '../TabField'; import {checkTabId, getTabId, applyFunctions} from './utils'; import {useStableEventHandler} from '../../helpers/useStableEventHendler'; import './Dialog.scss'; -import TabFieldVertical, {TabFieldVerticalProps} from '../TabField/TabFieldVertical'; import i18n from './i18n'; import { @@ -385,7 +388,7 @@ class Dialog< static getDefaultValues, F>( fields: FieldsType = [], ): Record { - return _reduce( + return reduce_( fields, (acc, item) => { const field = item as ArrayElement; @@ -432,7 +435,7 @@ class Dialog< } } - return _isEmpty(res) ? null : res; + return isEmpty_(res) ? null : res; } static hasTabs, FieldT extends ControlField>( @@ -584,7 +587,7 @@ class Dialog< fields: FieldsType, dst: Array<{name: Calculation['field']; subscribers: Calculation['updates']}> = [], ) { - return _reduce( + return reduce_( fields, (acc, field) => { const item = field as ArrayElement; @@ -906,7 +909,7 @@ class Dialog< if (!visibilityCondition) { return true; } - const value = _get(values, visibilityCondition.when); + const value = get_(values, visibilityCondition.when); return visibilityCondition.isActive(value); } @@ -929,7 +932,7 @@ class Dialog< active?: boolean, options: {userOptions?: any} = {}, ) => { - const tabSpec = _find(fields, (fieldSpec) => fieldSpec.name === fieldName); + const tabSpec = find_(fields, (fieldSpec) => fieldSpec.name === fieldName); const {onCreateTab} = tabSpec || {}; if (!tabSpec?.multiple) { return; @@ -937,11 +940,11 @@ class Dialog< const {userOptions} = options; - const index = _findIndex(values[fieldName], this.isActiveTab); + const index = findIndex_(values[fieldName], this.isActiveTab); const {id: _id, ...srcTabData} = values[fieldName][index === -1 ? 0 : index]; const newTabData = onCreateTab ? onCreateTab(srcTabData, {userOptions}) : srcTabData; if (newTabData.id === undefined) { - const ids = new Set(_map(values[fieldName], ({id}) => String(id))); + const ids = new Set(map_(values[fieldName], ({id}) => String(id))); for (let i = 0; i <= ids.size; ++i) { const id = String(i + 1); if (!ids.has(id)) { @@ -960,7 +963,7 @@ class Dialog< }; const removeTab = (tabItemToDelete: TabItem) => { - const tabIndexToDelete = _findIndex(tabItems, (item) => item.id === tabItemToDelete.id); + const tabIndexToDelete = findIndex_(tabItems, (item) => item.id === tabItemToDelete.id); if (tabIndexToDelete < 0) { return; } @@ -1206,7 +1209,7 @@ class Dialog< return (
extends React.Component, State> { +export class EditableList extends React.Component, State> { static defaultProps = { value: [], }; @@ -140,5 +140,3 @@ class EditableList extends React.Component, State> ); } } - -export default EditableList; diff --git a/src/dialog/EditableList/index.ts b/src/dialog/EditableList/index.ts new file mode 100644 index 0000000..00c7a70 --- /dev/null +++ b/src/dialog/EditableList/index.ts @@ -0,0 +1 @@ +export * from './EditableList'; diff --git a/src/dialog/EditableManyLists/EditableManyLists.tsx b/src/dialog/EditableManyLists/EditableManyLists.tsx index a6424a5..3d85547 100644 --- a/src/dialog/EditableManyLists/EditableManyLists.tsx +++ b/src/dialog/EditableManyLists/EditableManyLists.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {dfCN} from '../../helpers/cn'; -import EditableList, {EditableListItemType, EditableListProps} from '../EditableList/EditableList'; +import {EditableList, EditableListItemType, EditableListProps} from '../EditableList'; import './EditableManyLists.scss'; const block = dfCN('editable-many-lists'); @@ -24,7 +24,7 @@ export interface EditableManyListsItemType { data: Array>; } -class EditableManyLists extends React.Component> { +export class EditableManyLists extends React.Component> { static getDefaultValue() { return []; } @@ -63,5 +63,3 @@ class EditableManyLists extends React.Component> { ); } } - -export default EditableManyLists; diff --git a/src/dialog/EditableManyLists/index.ts b/src/dialog/EditableManyLists/index.ts new file mode 100644 index 0000000..c5a02d9 --- /dev/null +++ b/src/dialog/EditableManyLists/index.ts @@ -0,0 +1 @@ +export * from './EditableManyLists'; diff --git a/src/dialog/FocusBlurContainer/FocusBlurContainer.tsx b/src/dialog/FocusBlurContainer/FocusBlurContainer.tsx index cf2cad8..2de0f81 100644 --- a/src/dialog/FocusBlurContainer/FocusBlurContainer.tsx +++ b/src/dialog/FocusBlurContainer/FocusBlurContainer.tsx @@ -5,7 +5,7 @@ import {applyFunctions} from '../Dialog/utils'; function noop() {} -interface FocusBlurContainerProps { +export interface FocusBlurContainerProps { children?: React.ReactNode; className?: string; onFocus?: () => void; diff --git a/src/dialog/FocusBlurContainer/index.ts b/src/dialog/FocusBlurContainer/index.ts new file mode 100644 index 0000000..6d06035 --- /dev/null +++ b/src/dialog/FocusBlurContainer/index.ts @@ -0,0 +1 @@ +export * from './FocusBlurContainer'; diff --git a/src/dialog/Icon/index.ts b/src/dialog/Icon/index.ts new file mode 100644 index 0000000..e263cc0 --- /dev/null +++ b/src/dialog/Icon/index.ts @@ -0,0 +1 @@ +export * from './Icon'; diff --git a/src/dialog/MultiTextControl/LabelsGroup/LabelsGroup.tsx b/src/dialog/MultiTextControl/LabelsGroup/LabelsGroup.tsx index 4135713..6dc6705 100644 --- a/src/dialog/MultiTextControl/LabelsGroup/LabelsGroup.tsx +++ b/src/dialog/MultiTextControl/LabelsGroup/LabelsGroup.tsx @@ -1,5 +1,5 @@ import React, {Component} from 'react'; -import _map from 'lodash/map'; +import map_ from 'lodash/map'; import {Button, Label} from '@gravity-ui/uikit'; import {dfCN} from '../../../helpers/cn'; import withCollapsible from '../../../hoc/withCollapsible'; @@ -9,7 +9,7 @@ import {ArrayElement} from '../../types'; const block = dfCN('labels-group'); -type Props = { +export type LabelGroupProps = { items: Array<{name: string; isDefault?: boolean}>; visibleCount: number; disabled?: boolean; @@ -21,9 +21,9 @@ type Props = { renderToggler?: () => React.ReactNode; }; -type ItemType = ArrayElement; +type ItemType = ArrayElement; -class LabelsGroup extends Component { +class LabelsGroupComponent extends Component { handleLabelClick = (label: ItemType) => { const {onClick} = this.props; if (typeof onClick === 'function') { @@ -68,7 +68,7 @@ class LabelsGroup extends Component { return (
- {_map(items, (label) => this.renderLabel(label))} + {map_(items, (label) => this.renderLabel(label))} {renderToggler?.()} {onRemoveAll && items.length > 0 && (