From 31480c3a0b5079dcf4e1e5940d840e69579cc608 Mon Sep 17 00:00:00 2001 From: Mikhail Golbakh Date: Tue, 5 Sep 2023 15:29:31 +0300 Subject: [PATCH] feat(ObjectBase): add inline variant (#104) --- .../Inputs/ObjectBase/ObjectBase.scss | 19 ++++++ .../Inputs/ObjectBase/ObjectBase.tsx | 44 ++++++++++--- .../kit/components/Views/ObjectBaseView.tsx | 36 ---------- .../Views/ObjectBaseView/ObjectBaseView.scss | 19 ++++++ .../Views/ObjectBaseView/ObjectBaseView.tsx | 58 ++++++++++++++++ .../components/Views/ObjectBaseView/index.ts | 1 + src/lib/kit/constants/config.tsx | 6 ++ src/lib/kit/utils/index.ts | 1 + src/lib/kit/utils/objectInline.ts | 9 +++ src/stories/ObjectInline.stories.tsx | 66 +++++++++++++++++++ 10 files changed, 214 insertions(+), 45 deletions(-) create mode 100644 src/lib/kit/components/Inputs/ObjectBase/ObjectBase.scss delete mode 100644 src/lib/kit/components/Views/ObjectBaseView.tsx create mode 100644 src/lib/kit/components/Views/ObjectBaseView/ObjectBaseView.scss create mode 100644 src/lib/kit/components/Views/ObjectBaseView/ObjectBaseView.tsx create mode 100644 src/lib/kit/components/Views/ObjectBaseView/index.ts create mode 100644 src/lib/kit/utils/objectInline.ts create mode 100644 src/stories/ObjectInline.stories.tsx diff --git a/src/lib/kit/components/Inputs/ObjectBase/ObjectBase.scss b/src/lib/kit/components/Inputs/ObjectBase/ObjectBase.scss new file mode 100644 index 00000000..106b008e --- /dev/null +++ b/src/lib/kit/components/Inputs/ObjectBase/ObjectBase.scss @@ -0,0 +1,19 @@ +@import '../../../styles/variables.scss'; + +.#{$ns}object-base { + &__content { + &_inline { + display: flex; + + & > .#{$ns}use-search { + width: 150px; + margin-bottom: 0; + margin-right: 8px; + + &:last-child { + margin-right: 0; + } + } + } + } +} diff --git a/src/lib/kit/components/Inputs/ObjectBase/ObjectBase.tsx b/src/lib/kit/components/Inputs/ObjectBase/ObjectBase.tsx index 3f0d6a83..24349249 100644 --- a/src/lib/kit/components/Inputs/ObjectBase/ObjectBase.tsx +++ b/src/lib/kit/components/Inputs/ObjectBase/ObjectBase.tsx @@ -9,13 +9,28 @@ import { FieldObjectValue, FieldValue, ObjectIndependentInput, + ObjectIndependentInputProps, ObjectValue, - Spec, ValidateError, transformArrIn, } from '../../../../core'; +import {block, filterPropertiesForObjectInline} from '../../../utils'; -export const ObjectBase: ObjectIndependentInput = ({spec, name, Layout, ...restProps}) => { +import './ObjectBase.scss'; + +const b = block('object-base'); + +export interface ObjectBaseProps extends ObjectIndependentInputProps { + inline?: boolean; +} + +export const ObjectBase: React.FC = ({ + inline, + spec, + name, + Layout, + ...restProps +}) => { const addBtn = React.useMemo( () => (