Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat: add form-layout component (#1125)
zhangw8e493cf6379f
diff --git a/packages/design/src/components/form-layout/FormLayout.stories.tsx b/packages/design/src/components/form-layout/FormLayout.stories.tsxnew file mode 100644index 0000000000..ae661fd2cb--- /dev/null+++ b/packages/design/src/components/form-layout/FormLayout.stories.tsx@@ -0,0 +1,56 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Meta } from '@storybook/react';+import React from 'react';++import { Input } from '../input';+import { Select } from '../select';+import { FormLayout } from './FormLayout';++const meta: Meta = {+ title: 'Components / FormLayout',+ parameters: {+ layout: 'centered',+ },+ tags: ['autodocs'],+ args: {},+};++export default meta;++function PagerDemo() {+ return (+ <>+ <FormLayout label="行标题与列标题" desc="转到“查看”>“冻结”可选择要在所有页面重复的行/列">+ <Input placeholder="请输入" />+ </FormLayout>+ <FormLayout label="行标题与列标题" desc="转到“查看”>“冻结”可选择要在所有页面重复的行/列">+ <Select value={''} onChange={() => {}} />+ </FormLayout>+ </>+ );+}++export const Playground = {+ render: () => {+ return (+ <>+ <PagerDemo />+ </>+ );+ },+};diff --git a/packages/design/src/components/form-layout/FormLayout.tsx b/packages/design/src/components/form-layout/FormLayout.tsxnew file mode 100644index 0000000000..2d9e6f6798--- /dev/null+++ b/packages/design/src/components/form-layout/FormLayout.tsx@@ -0,0 +1,40 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import clsx from 'clsx';+import React from 'react';++import styles from './index.module.less';++export interface IFormLayoutProps {+ label?: React.ReactNode;+ desc?: React.ReactNode;+ children?: React.ReactNode;++ style?: React.CSSProperties;+ className?: string;+}++export const FormLayout = (props: IFormLayoutProps) => {+ const { label, desc, children, style, className } = props;+ return (+ <div className={clsx(styles.formLayout, className)} style={style}>+ <div className={styles.formLayoutLabel}>{label}</div>+ <div className={styles.formLayoutDesc}>{desc}</div>+ <div className={styles.formLayoutContent}>{children}</div>+ </div>+ );+};diff --git a/packages/design/src/components/form-layout/index.module.less b/packages/design/src/components/form-layout/index.module.lessnew file mode 100644index 0000000000..5f20baed38--- /dev/null+++ b/packages/design/src/components/form-layout/index.module.less@@ -0,0 +1,20 @@+.form-layout {+ display: flex;+ flex-direction: column;++ &-label {+ font-size: var(--font-size-sm);+ color: rgba(var(--grey-400));+ }++ &-desc {+ margin-top: var(--margin-xxs);+ font-size: var(--font-size-xs);+ color: rgba(var(--grey-500));+ }++ &-content {+ margin-top: var(--margin-xs);+ margin-bottom: var(--margin-sm);+ }+}diff --git a/packages/design/src/components/form-layout/index.ts b/packages/design/src/components/form-layout/index.tsnew file mode 100644index 0000000000..a4e00a9757--- /dev/null+++ b/packages/design/src/components/form-layout/index.ts@@ -0,0 +1,17 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export * from './FormLayout';diff --git a/packages/design/src/components/input/index.module.less b/packages/design/src/components/input/index.module.lessindex d7b39bd8ee..840b8a8444 100644--- a/packages/design/src/components/input/index.module.less+++ b/packages/design/src/components/input/index.module.less@@ -24,21 +24,25 @@transition: all 0.15s;&-mini {+ display: inline-block;padding: 2px var(--padding-lg);font-size: var(--font-size-xs);}&-small {+ display: inline-block;padding: 6px var(--padding-lg);font-size: var(--font-size-xs);}&-middle {+ display: inline-block;padding: 6px var(--padding-lg);font-size: var(--font-size-sm);}&-large {+ display: inline-block;padding: 8px var(--padding-lg);font-size: var(--font-size-sm);}diff --git a/packages/design/src/index.ts b/packages/design/src/index.tsindex e30ec302b3..971916017a 100644--- a/packages/design/src/index.ts+++ b/packages/design/src/index.ts@@ -25,6 +25,7 @@ export { Confirm, type IConfirmProps } from './components/confirm';export { Container, type IContainerProps } from './components/container';export { Dialog, type IDialogProps } from './components/dialog';export { Dropdown, type IDropdownProps } from './components/dropdown';+export { FormLayout, type IFormLayoutProps } from './components/form-layout';export { type IInputProps, Input } from './components/input';export { type IInputNumberProps, InputNumber } from './components/input-number';export { Menu, MenuItem, MenuItemGroup, SubMenu } from './components/menu';