diff --git a/src/components/CustomizedPanel/CustomizedForm/Fields/List.tsx b/src/components/CustomizedPanel/CustomizedForm/Fields/List.tsx index 584486cef..3e09bb690 100644 --- a/src/components/CustomizedPanel/CustomizedForm/Fields/List.tsx +++ b/src/components/CustomizedPanel/CustomizedForm/Fields/List.tsx @@ -7,11 +7,14 @@ import { RcListItemAvatar, RcListItemSecondaryAction, RcAvatar, + RcIcon, styled, palette2, css } from '@ringcentral/juno'; +import { ArrowRight } from '@ringcentral/juno-icon'; + const StyledList = styled(RcList)` margin: 0 -16px; `; @@ -32,6 +35,59 @@ const StyledAvatar = styled(RcAvatar)` } `; +const NavigationIcon = styled(RcIcon)` + margin: 8px 0; +`; + +function Item({ + item, + disabled, + selected, + onClick, + showIconAsAvatar, + showAsNavigation, +}) { + return ( + + { + item.icon ? ( + + + + ) : null + } + + { + (item.meta || showAsNavigation) ? ( + + {item.meta} + { + showAsNavigation ? ( + + ) : null + } + + ) : null + } + + ); +} + export function List({ schema, uiSchema, @@ -43,40 +99,24 @@ export function List({ typeof uiSchema['ui:showIconAsAvatar'] === 'undefined' ? true : uiSchema['ui:showIconAsAvatar']; + const showAsNavigation = + typeof uiSchema['ui:navigation'] === 'undefined' ? + false : + uiSchema['ui:navigation']; return ( {schema.oneOf.map((item) => ( - { onChange(item.const); }} - > - { - item.icon ? ( - - - - ) : null - } - - { - item.meta ? ( - - {item.meta} - - ) : null - } - + showIconAsAvatar={showIconAsAvatar} + showAsNavigation={showAsNavigation} + /> ))} ); diff --git a/src/components/CustomizedPanel/CustomizedForm/Templates/ObjectFieldTemplate.tsx b/src/components/CustomizedPanel/CustomizedForm/Templates/ObjectFieldTemplate.tsx index e13e9dda1..246446e8a 100644 --- a/src/components/CustomizedPanel/CustomizedForm/Templates/ObjectFieldTemplate.tsx +++ b/src/components/CustomizedPanel/CustomizedForm/Templates/ObjectFieldTemplate.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { RcGrid as Grid } from '@ringcentral/juno'; +import React, { useState } from 'react'; +import { RcGrid as Grid, RcDivider as Divider } from '@ringcentral/juno'; import { FormContextType, ObjectFieldTemplateProps, @@ -24,7 +24,7 @@ export default function ObjectFieldTemplate< required, disabled, readonly, - uiSchema, + uiSchema = {}, idSchema, schema, formData, @@ -42,6 +42,15 @@ export default function ObjectFieldTemplate< const { ButtonTemplates: { AddButton }, } = registry.templates; + const gridStyle: { + paddingLeft?: string; + marginTop: string; + } = { marginTop: '10px' }; + if (title) { + gridStyle.paddingLeft = '16px'; + } + const collapsible = uiOptions.collapsible || false; + const [extended, setExtended] = useState(collapsible ? false : true); return ( <> {title && ( @@ -52,6 +61,13 @@ export default function ObjectFieldTemplate< schema={schema} uiSchema={uiSchema} registry={registry} + extended={extended} + onClick={() => { + if (!collapsible) { + return; + } + setExtended(!extended); + }} /> )} {description && ( @@ -63,39 +79,46 @@ export default function ObjectFieldTemplate< registry={registry} /> )} - - {properties.map((element, index) => { - // Remove the if the inner element is hidden as the - // itself would otherwise still take up space. - if (element.hidden) { - return element.content; - } - const uiSchemaProperty = uiSchema?.[element.name] || {}; - const style = uiSchemaProperty?.['ui:bulletedList'] ? { - marginLeft: '16px', - } : { - marginBottom: '10px' - }; - return ( - - {element.content} - - ); - })} - {canExpand(schema, uiSchema, formData) && ( - - - - + { + extended && ( + + {properties.map((element, index) => { + // Remove the if the inner element is hidden as the + // itself would otherwise still take up space. + if (element.hidden) { + return element.content; + } + const uiSchemaProperty = uiSchema?.[element.name] || {}; + const style = uiSchemaProperty?.['ui:bulletedList'] ? { + marginLeft: '16px', + } : { + marginBottom: '10px' + }; + return ( + + {element.content} + + ); + })} + {canExpand(schema, uiSchema, formData) && ( + + + + + + )} - )} - + ) + } + { + collapsible && () + } ); } \ No newline at end of file diff --git a/src/components/CustomizedPanel/CustomizedForm/Templates/TitleField.tsx b/src/components/CustomizedPanel/CustomizedForm/Templates/TitleField.tsx index 4aa86ccf0..46082ab58 100644 --- a/src/components/CustomizedPanel/CustomizedForm/Templates/TitleField.tsx +++ b/src/components/CustomizedPanel/CustomizedForm/Templates/TitleField.tsx @@ -1,20 +1,58 @@ import React from 'react'; import { RcBox as Box, - RcDivider as Divider, RcTypography as Typography, + RcIcon, + RcDivider as Divider, + styled, + css, } from '@ringcentral/juno'; +import { ArrowDown2, ArrowUp2 } from '@ringcentral/juno-icon'; import { FormContextType, TitleFieldProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils'; +const StyledTitle = styled(Typography)` + flex: 1; +`; + +const StyledBox = styled(Box)<{ $clickable: boolean }>` + display: flex; + align-items: center; + flex-direction: row; + ${({ $clickable }) => $clickable && css` + cursor: pointer; + `}; +`; + +const StyledIcon = styled(RcIcon)` + margin: 4px 0; +`; + export default function TitleField({ id, title, + uiSchema = {}, + extended = false, + onClick = undefined }: TitleFieldProps) { + const collapsible = uiSchema['ui:collapsible'] || false; return ( - - {title} - - + + {title} + { + collapsible ? ( + + ) : null + } + { + collapsible ? null : () + } + ); } diff --git a/src/components/CustomizedPanel/CustomizedForm/Widgets/CheckboxWidget.tsx b/src/components/CustomizedPanel/CustomizedForm/Widgets/CheckboxWidget.tsx index 079912eda..f4bfcab24 100644 --- a/src/components/CustomizedPanel/CustomizedForm/Widgets/CheckboxWidget.tsx +++ b/src/components/CustomizedPanel/CustomizedForm/Widgets/CheckboxWidget.tsx @@ -1,7 +1,8 @@ import React, { FocusEvent } from 'react'; import { - RcCheckbox as Checkbox, - RcFormControlLabel as FormControlLabel, + RcSwitch, + styled, + css, }from '@ringcentral/juno'; import { ariaDescribedByIds, @@ -15,6 +16,29 @@ import { WidgetProps, } from '@rjsf/utils'; +const SwitchContainer = styled.div` + width: 100%; + + .MuiFormControlLabel-label { + flex: 1; + } + + .MuiFormControlLabel-root { + margin-left: 0; + width: 100%; + } + + .RcSwitch-root { + margin: 2px; + } +`; + +const StyledSwitch = styled(RcSwitch)` + ${(props) => props.readOnly && css` + opacity: 0.5; + `} +`; + export default function CheckboxWidget< T = any, S extends StrictRJSFSchema = RJSFSchema, @@ -62,23 +86,25 @@ export default function CheckboxWidget< registry={registry} /> )} - (id)} - /> - } - label={labelValue(label, hideLabel, false)} - /> + + (id)} + formControlLabelProps={{ + labelPlacement: 'start', + }} + label={labelValue(label, hideLabel, false)} + readOnly={readonly} + /> + ); }