diff --git a/packages/primitives/src/icons/check-16.svg b/packages/primitives/src/icons/check-16.svg new file mode 100644 index 00000000..2a4a329a --- /dev/null +++ b/packages/primitives/src/icons/check-16.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + diff --git a/packages/react/.storybook/static/storybook-common.overrides.css b/packages/react/.storybook/static/storybook-common.overrides.css index 4cb57ed7..578dffc3 100644 --- a/packages/react/.storybook/static/storybook-common.overrides.css +++ b/packages/react/.storybook/static/storybook-common.overrides.css @@ -68,7 +68,6 @@ :root { --oxygen-font-family: 'Gilmer'; - --oxygen-palette-divider: rgba(255, 255, 255, 0.12); } body { diff --git a/packages/react/.storybook/static/storybook-preview.overrides.css b/packages/react/.storybook/static/storybook-preview.overrides.css index 6ec8b25f..fc3e07ad 100644 --- a/packages/react/.storybook/static/storybook-preview.overrides.css +++ b/packages/react/.storybook/static/storybook-preview.overrides.css @@ -19,5 +19,5 @@ @import url(./storybook-common.overrides.css); * { - font-family: var(--oxygen-font-family) !important; + font-family: var(--oxygen-font-family); } diff --git a/packages/react/.storybook/story-config.ts b/packages/react/.storybook/story-config.ts index 486c46b9..d56112a5 100644 --- a/packages/react/.storybook/story-config.ts +++ b/packages/react/.storybook/story-config.ts @@ -18,6 +18,7 @@ */ enum StorybookCategories { + ComponentAPI = 'Component API', DataDisplay = 'Data Display', Foundations = 'Foundations', Feedback = 'Feedback', @@ -29,6 +30,7 @@ enum StorybookCategories { Theme = 'Theme', Typography = 'Typography', Surfaces = 'Surfaces', + Utils = 'Utils' } export type Stories = @@ -51,8 +53,10 @@ export type Stories = | 'CardContent' | 'CardHeader' | 'Carousel' + | 'Checkbox' | 'CircularProgressAvatar' | 'Chip' + | 'Code' | 'CollapsibleNavbarItem' | 'ColorModeToggle' | 'Colors' @@ -61,7 +65,11 @@ export type Stories = | 'Divider' | 'Drawer' | 'CountryFlag' + | 'Fab' | 'Footer' + | 'FormControlLabel' + | 'FormGroup' + | 'FormLabel' | 'FormHelperText' | 'FormControl' | 'Grid' @@ -85,7 +93,11 @@ export type Stories = | 'Navbar' | 'NavbarItem' | 'OutlinedInput' + | 'Paper' + | 'Popover' | 'PhoneNumberInput' + | 'Radio' + | 'RadioGroup' | 'Select' | 'SignIn' | 'Snackbar' @@ -159,6 +171,9 @@ const StoryConfig: StorybookConfig = { Button: { hierarchy: `${StorybookCategories.Inputs}/Button`, }, + Checkbox: { + hierarchy: `${StorybookCategories.Inputs}/Checkbox`, + }, CircularProgress: { hierarchy: `${StorybookCategories.Feedback}/Circular Progress`, }, @@ -183,6 +198,9 @@ const StoryConfig: StorybookConfig = { Chip: { hierarchy: `${StorybookCategories.DataDisplay}/Chip`, }, + Code: { + hierarchy: `${StorybookCategories.DataDisplay}/Code`, + }, CollapsibleNavbarItem: { hierarchy: `${StorybookCategories.Navigation}/Collapsible Navbar Item`, }, @@ -207,6 +225,9 @@ const StoryConfig: StorybookConfig = { CountryFlag: { hierarchy: `${StorybookCategories.Icons}/Country Flags`, }, + Fab: { + hierarchy: `${StorybookCategories.Inputs}/Fab`, + }, Footer: { hierarchy: `${StorybookCategories.Navigation}/Footer`, }, @@ -216,6 +237,15 @@ const StoryConfig: StorybookConfig = { FormControl: { hierarchy: `${StorybookCategories.Inputs}/Form Control`, }, + FormControlLabel: { + hierarchy: `${StorybookCategories.ComponentAPI}/Form Control Label`, + }, + FormGroup: { + hierarchy: `${StorybookCategories.ComponentAPI}/Form Group`, + }, + FormLabel: { + hierarchy: `${StorybookCategories.ComponentAPI}/Form Label`, + }, Grid: { hierarchy: `${StorybookCategories.Layout}/Grid`, }, @@ -284,9 +314,21 @@ const StoryConfig: StorybookConfig = { ListItemText: { hierarchy: `${StorybookCategories.DataDisplay}/List Item Text`, }, + Paper: { + hierarchy: `${StorybookCategories.Surfaces}/Paper`, + }, PhoneNumberInput: { hierarchy: `${StorybookCategories.Inputs}/Phone Number Input`, }, + Popover: { + hierarchy: `${StorybookCategories.Utils}/Popover`, + }, + Radio: { + hierarchy: `${StorybookCategories.ComponentAPI}/Radio`, + }, + RadioGroup: { + hierarchy: `${StorybookCategories.Inputs}/Radio Group`, + }, Select: { hierarchy: `${StorybookCategories.Inputs}/Select`, }, diff --git a/packages/react/src/components/ActionCard/__tests__/__snapshots__/ActionCard.test.tsx.snap b/packages/react/src/components/ActionCard/__tests__/__snapshots__/ActionCard.test.tsx.snap index 2c35add3..7a9a12b7 100644 --- a/packages/react/src/components/ActionCard/__tests__/__snapshots__/ActionCard.test.tsx.snap +++ b/packages/react/src/components/ActionCard/__tests__/__snapshots__/ActionCard.test.tsx.snap @@ -28,7 +28,7 @@ exports[`ActionCard should match the snapshot 1`] = ` class="MuiCardActions-root MuiCardActions-spacing oxygen-card-actions css-1t6e9jv-MuiCardActions-root" > + + +`; diff --git a/packages/react/src/components/Fab/index.ts b/packages/react/src/components/Fab/index.ts new file mode 100644 index 00000000..5f228f4f --- /dev/null +++ b/packages/react/src/components/Fab/index.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 {default} from './Fab'; +export type {FabProps} from './Fab'; diff --git a/packages/react/src/components/FormControlLabel/FormControlLabel.stories.mdx b/packages/react/src/components/FormControlLabel/FormControlLabel.stories.mdx new file mode 100644 index 00000000..acebd6a8 --- /dev/null +++ b/packages/react/src/components/FormControlLabel/FormControlLabel.stories.mdx @@ -0,0 +1,46 @@ +import {ArgsTable, Source, Story, Canvas, Meta} from '@storybook/addon-docs'; +import dedent from 'ts-dedent'; +import StoryConfig from '../../../.storybook/story-config.ts'; +import FormControlLabel from './FormControlLabel.tsx'; + +export const meta = { + component: FormControlLabel, + title: StoryConfig.FormControlLabel.hierarchy, +}; + + + +export const Template = args => ; + +# FormControlLabel + +- [Overview](#overview) +- [Props](#props) +- [Usage](#usage) + +## Overview + +Drop-in replacement of the `Radio`, `Switch` and `Checkbox` component. Use this component if you want to display an extra label. + + + + {Template.bind({})} + + + +## Props + + + +## Usage + +Import and use the `FormControlLabel` component in your components as follows. + + diff --git a/packages/react/src/components/FormControlLabel/FormControlLabel.tsx b/packages/react/src/components/FormControlLabel/FormControlLabel.tsx new file mode 100644 index 00000000..ef137acd --- /dev/null +++ b/packages/react/src/components/FormControlLabel/FormControlLabel.tsx @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 MuiFormControlLabel, {FormControlLabelProps as MuiFormControlLabelProps} from '@mui/material/FormControlLabel'; +import clsx from 'clsx'; +import {forwardRef, ForwardRefExoticComponent, ReactElement, MutableRefObject} from 'react'; +import {WithWrapperProps} from '../../models'; +import {composeComponentDisplayName} from '../../utils'; + +export type FormControlLabelProps = MuiFormControlLabelProps; + +const COMPONENT_NAME: string = 'FormControlLabel'; + +const FormControlLabel: ForwardRefExoticComponent & WithWrapperProps = forwardRef( + (props: FormControlLabelProps, ref: MutableRefObject): ReactElement => { + const {className, ...rest} = props; + + const classes: string = clsx('oxygen-form-control-label', className); + + return ; + }, +) as ForwardRefExoticComponent & WithWrapperProps; + +FormControlLabel.displayName = composeComponentDisplayName(COMPONENT_NAME); +FormControlLabel.muiName = COMPONENT_NAME; +FormControlLabel.defaultProps = {}; + +export default FormControlLabel; diff --git a/packages/react/src/components/FormControlLabel/__tests__/FormControlLabel.test.tsx b/packages/react/src/components/FormControlLabel/__tests__/FormControlLabel.test.tsx new file mode 100644 index 00000000..4145ef79 --- /dev/null +++ b/packages/react/src/components/FormControlLabel/__tests__/FormControlLabel.test.tsx @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 {render} from '@unit-testing'; +import Checkbox from '../../Checkbox'; +import FormControlLabel from '../FormControlLabel'; + +describe('FormControlLabel', () => { + it('should render successfully', () => { + const {baseElement} = render(} label="Label" />); + expect(baseElement).toBeTruthy(); + }); + + it('should match the snapshot', () => { + const {baseElement} = render(} label="Label" />); + expect(baseElement).toMatchSnapshot(); + }); +}); diff --git a/packages/react/src/components/FormControlLabel/__tests__/__snapshots__/FormControlLabel.test.tsx.snap b/packages/react/src/components/FormControlLabel/__tests__/__snapshots__/FormControlLabel.test.tsx.snap new file mode 100644 index 00000000..baea57af --- /dev/null +++ b/packages/react/src/components/FormControlLabel/__tests__/__snapshots__/FormControlLabel.test.tsx.snap @@ -0,0 +1,41 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FormControlLabel should match the snapshot 1`] = ` + +
+ +
+ +`; diff --git a/packages/react/src/components/FormControlLabel/index.ts b/packages/react/src/components/FormControlLabel/index.ts new file mode 100644 index 00000000..455daf14 --- /dev/null +++ b/packages/react/src/components/FormControlLabel/index.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 {default} from './FormControlLabel'; +export type {FormControlLabelProps} from './FormControlLabel'; diff --git a/packages/react/src/components/FormGroup/FormGroup.stories.mdx b/packages/react/src/components/FormGroup/FormGroup.stories.mdx new file mode 100644 index 00000000..168b1713 --- /dev/null +++ b/packages/react/src/components/FormGroup/FormGroup.stories.mdx @@ -0,0 +1,46 @@ +import {ArgsTable, Source, Story, Canvas, Meta} from '@storybook/addon-docs'; +import dedent from 'ts-dedent'; +import StoryConfig from '../../../.storybook/story-config.ts'; +import FormGroup from './FormGroup.tsx'; + +export const meta = { + component: FormGroup, + title: StoryConfig.FormGroup.hierarchy, +}; + + + +export const Template = args => ; + +# FormGroup + +- [Overview](#overview) +- [Props](#props) +- [Usage](#usage) + +## Overview + +`FormGroup` wraps controls such as `Checkbox` and `Switch`. It provides compact row layout. For the `Radio`, you should be using the `RadioGroup` component instead of this one. + + + + {Template.bind({})} + + + +## Props + + + +## Usage + +Import and use the `FormGroup` component in your components as follows. + + diff --git a/packages/react/src/components/FormGroup/FormGroup.tsx b/packages/react/src/components/FormGroup/FormGroup.tsx new file mode 100644 index 00000000..912ca2ea --- /dev/null +++ b/packages/react/src/components/FormGroup/FormGroup.tsx @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 MuiFormGroup, {FormGroupProps as MuiFormGroupProps} from '@mui/material/FormGroup'; +import clsx from 'clsx'; +import {forwardRef, ForwardRefExoticComponent, ReactElement, MutableRefObject} from 'react'; +import {WithWrapperProps} from '../../models'; +import {composeComponentDisplayName} from '../../utils'; + +export type FormGroupProps = MuiFormGroupProps; + +const COMPONENT_NAME: string = 'FormGroup'; + +const FormGroup: ForwardRefExoticComponent & WithWrapperProps = forwardRef( + (props: FormGroupProps, ref: MutableRefObject): ReactElement => { + const {className, ...rest} = props; + + const classes: string = clsx('oxygen-form-group', className); + + return ; + }, +) as ForwardRefExoticComponent & WithWrapperProps; + +FormGroup.displayName = composeComponentDisplayName(COMPONENT_NAME); +FormGroup.muiName = COMPONENT_NAME; +FormGroup.defaultProps = {}; + +export default FormGroup; diff --git a/packages/react/src/components/FormGroup/__tests__/FormGroup.test.tsx b/packages/react/src/components/FormGroup/__tests__/FormGroup.test.tsx new file mode 100644 index 00000000..d857c7d4 --- /dev/null +++ b/packages/react/src/components/FormGroup/__tests__/FormGroup.test.tsx @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 {render} from '@unit-testing'; +import FormGroup from '../FormGroup'; + +describe('FormGroup', () => { + it('should render successfully', () => { + const {baseElement} = render(); + expect(baseElement).toBeTruthy(); + }); + + it('should match the snapshot', () => { + const {baseElement} = render(); + expect(baseElement).toMatchSnapshot(); + }); +}); diff --git a/packages/react/src/components/FormGroup/__tests__/__snapshots__/FormGroup.test.tsx.snap b/packages/react/src/components/FormGroup/__tests__/__snapshots__/FormGroup.test.tsx.snap new file mode 100644 index 00000000..f16d1c6f --- /dev/null +++ b/packages/react/src/components/FormGroup/__tests__/__snapshots__/FormGroup.test.tsx.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FormGroup should match the snapshot 1`] = ` + +
+
+
+ +`; diff --git a/packages/react/src/components/FormGroup/index.ts b/packages/react/src/components/FormGroup/index.ts new file mode 100644 index 00000000..a6ed1763 --- /dev/null +++ b/packages/react/src/components/FormGroup/index.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 {default} from './FormGroup'; +export type {FormGroupProps} from './FormGroup'; diff --git a/packages/react/src/components/FormLabel/FormLabel.stories.mdx b/packages/react/src/components/FormLabel/FormLabel.stories.mdx new file mode 100644 index 00000000..b445cfd1 --- /dev/null +++ b/packages/react/src/components/FormLabel/FormLabel.stories.mdx @@ -0,0 +1,53 @@ +import {ArgsTable, Source, Story, Canvas, Meta} from '@storybook/addon-docs'; +import dedent from 'ts-dedent'; +import StoryConfig from '../../../.storybook/story-config.ts'; +import FormLabel from './FormLabel.tsx'; +import LinkTo from '@storybook/addon-links/react'; + +export const meta = { + component: FormLabel, + title: StoryConfig.FormLabel.hierarchy, +}; + + + +export const Template = args => ; + +# FormLabel + +- [Overview](#overview) +- [Props](#props) +- [Usage](#usage) + +## Overview + +API reference docs for the React FormLabel component. Learn about the props, CSS, and other APIs of this exported module. + +For examples and details on the usage of this React component, visit the component demo pages: + +- Checkbox +- Radio Group + + + + {Template.bind({})} + + + +## Props + + + +## Usage + +Import and use the `FormLabel` component in your components as follows. + + diff --git a/packages/react/src/components/FormLabel/FormLabel.tsx b/packages/react/src/components/FormLabel/FormLabel.tsx new file mode 100644 index 00000000..1089810d --- /dev/null +++ b/packages/react/src/components/FormLabel/FormLabel.tsx @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 MuiFormLabel, {FormLabelProps as MuiFormLabelProps} from '@mui/material/FormLabel'; +import clsx from 'clsx'; +import {forwardRef, ForwardRefExoticComponent, ReactElement, MutableRefObject, ElementType} from 'react'; +import {WithWrapperProps} from '../../models'; +import {composeComponentDisplayName} from '../../utils'; + +export type FormLabelProps = { + component?: C; +} & Omit, 'component'>; + +const COMPONENT_NAME: string = 'FormLabel'; + +const FormLabel: ForwardRefExoticComponent & WithWrapperProps = forwardRef( + (props: FormLabelProps, ref: MutableRefObject): ReactElement => { + const {className, ...rest} = props; + + const classes: string = clsx('oxygen-form-label', className); + + return ; + }, +) as ForwardRefExoticComponent & WithWrapperProps; + +FormLabel.displayName = composeComponentDisplayName(COMPONENT_NAME); +FormLabel.muiName = COMPONENT_NAME; +FormLabel.defaultProps = {}; + +export default FormLabel; diff --git a/packages/react/src/components/FormLabel/__tests__/FormLabel.test.tsx b/packages/react/src/components/FormLabel/__tests__/FormLabel.test.tsx new file mode 100644 index 00000000..f780b434 --- /dev/null +++ b/packages/react/src/components/FormLabel/__tests__/FormLabel.test.tsx @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 {render} from '@unit-testing'; +import FormLabel from '../FormLabel'; + +describe('FormLabel', () => { + it('should render successfully', () => { + const {baseElement} = render(); + expect(baseElement).toBeTruthy(); + }); + + it('should match the snapshot', () => { + const {baseElement} = render(); + expect(baseElement).toMatchSnapshot(); + }); +}); diff --git a/packages/react/src/components/FormLabel/__tests__/__snapshots__/FormLabel.test.tsx.snap b/packages/react/src/components/FormLabel/__tests__/__snapshots__/FormLabel.test.tsx.snap new file mode 100644 index 00000000..427b8409 --- /dev/null +++ b/packages/react/src/components/FormLabel/__tests__/__snapshots__/FormLabel.test.tsx.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FormLabel should match the snapshot 1`] = ` + +
+
+ +`; diff --git a/packages/react/src/components/FormLabel/index.ts b/packages/react/src/components/FormLabel/index.ts new file mode 100644 index 00000000..d1987cd7 --- /dev/null +++ b/packages/react/src/components/FormLabel/index.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 {default} from './FormLabel'; +export type {FormLabelProps} from './FormLabel'; diff --git a/packages/react/src/components/Header/__tests__/__snapshots__/Header.test.tsx.snap b/packages/react/src/components/Header/__tests__/__snapshots__/Header.test.tsx.snap index de75faf2..dfbd5d50 100644 --- a/packages/react/src/components/Header/__tests__/__snapshots__/Header.test.tsx.snap +++ b/packages/react/src/components/Header/__tests__/__snapshots__/Header.test.tsx.snap @@ -15,7 +15,7 @@ exports[`Header should match the snapshot 1`] = ` > + + The content of the Popover. + +
+ ); +}; + +# Popover + +- [Overview](#overview) +- [Props](#props) +- [Usage](#usage) + +## Overview + +A Popover can be used to display some content on top of another. + + + + {Template.bind({})} + + + +## Props + + + +## Usage + +Import and use the `Popover` component in your components as follows. + + diff --git a/packages/react/src/components/Popover/Popover.tsx b/packages/react/src/components/Popover/Popover.tsx new file mode 100644 index 00000000..a5cf6a63 --- /dev/null +++ b/packages/react/src/components/Popover/Popover.tsx @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 MuiPopover, {PopoverProps as MuiPopoverProps} from '@mui/material/Popover'; +import clsx from 'clsx'; +import {forwardRef, ForwardRefExoticComponent, ReactElement, MutableRefObject} from 'react'; +import {WithWrapperProps} from '../../models'; +import {composeComponentDisplayName} from '../../utils'; + +export type PopoverProps = MuiPopoverProps; + +const COMPONENT_NAME: string = 'Popover'; + +const Popover: ForwardRefExoticComponent & WithWrapperProps = forwardRef( + (props: PopoverProps, ref: MutableRefObject): ReactElement => { + const {className, ...rest} = props; + + const classes: string = clsx('oxygen-popover', className); + + return ; + }, +) as unknown as ForwardRefExoticComponent & WithWrapperProps; + +Popover.displayName = composeComponentDisplayName(COMPONENT_NAME); +Popover.muiName = COMPONENT_NAME; +Popover.defaultProps = {}; + +export default Popover; diff --git a/packages/react/src/components/Popover/__tests__/Popover.test.tsx b/packages/react/src/components/Popover/__tests__/Popover.test.tsx new file mode 100644 index 00000000..e48af374 --- /dev/null +++ b/packages/react/src/components/Popover/__tests__/Popover.test.tsx @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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 {render} from '@unit-testing'; +import Popover from '../Popover'; + +describe('Popover', () => { + it('should render successfully', () => { + const {baseElement} = render(); + expect(baseElement).toBeTruthy(); + }); + + it('should match the snapshot', () => { + const {baseElement} = render(); + expect(baseElement).toMatchSnapshot(); + }); +}); diff --git a/packages/react/src/components/Popover/__tests__/__snapshots__/Popover.test.tsx.snap b/packages/react/src/components/Popover/__tests__/__snapshots__/Popover.test.tsx.snap new file mode 100644 index 00000000..0080983a --- /dev/null +++ b/packages/react/src/components/Popover/__tests__/__snapshots__/Popover.test.tsx.snap @@ -0,0 +1,34 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Popover should match the snapshot 1`] = ` + +