Skip to content

Commit

Permalink
Merge branch 'main' into 6756-side-panel-framer-motion-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderMelox authored Jan 31, 2025
2 parents b0d647a + 9add0eb commit 025cfe2
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 734 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test.describe('NotificationsPanel @avt', () => {
test('@avt-default-state', async ({ page }) => {
await visitStory(page, {
component: 'NotificationsPanel',
id: 'ibm-products-patterns-notifications-notificationspanel--default',
id: 'ibm-products-components-notifications-panel-notificationspanel--default',
globals: {
carbonTheme: 'white',
},
Expand All @@ -28,7 +28,7 @@ test.describe('NotificationsPanel @avt', () => {
test('@avt-notification-panel-focus-trap', async ({ page }) => {
await visitStory(page, {
component: 'NotificationsPanel',
id: 'ibm-products-patterns-notifications-notificationspanel--default',
id: 'ibm-products-components-notifications-panel-notificationspanel--default',
globals: {
carbonTheme: 'white',
},
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@use '@carbon/react/scss/theme' as *;
@use '@carbon/react/scss/spacing' as *;
@use '@carbon/react/scss/motion' as *;
@use '@carbon/styles/scss/components/tag' as *;
@use '@carbon/styles/scss/components/tag/tokens' as *;
@use '@carbon/styles/scss/utilities/focus-outline';
@use '../../../global/styles/project-settings' as c4p-settings;
@use '@carbon/styles/scss/type';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@use '@carbon/react/scss/utilities';
@use '@carbon/react/scss/motion' as *;
@use '@carbon/react/scss/utilities/focus-outline';
@use '@carbon/styles/scss/components/tag';
@use '@carbon/styles/scss/components/tag/tokens' as *;

@use '@carbon/styles/scss/type' as *;
@use '@carbon/react/scss/colors' as *;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// Copyright IBM Corp. 2025, 2025
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@use '@carbon/react/scss/components/toggle/toggle';
@use '@carbon/react/scss/components/ui-shell/side-nav';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright IBM Corp. 2022, 2022
// Copyright IBM Corp. 2022, 2025
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
Expand All @@ -17,10 +17,6 @@
// Other Carbon settings.
@use '@carbon/react/scss/grid' as *;

// EditTearsheet uses the following Carbon components:
@use '@carbon/react/scss/components/toggle/toggle';
@use '@carbon/react/scss/components/ui-shell/side-nav';

// EditTearsheet uses the following IBM Products components:
// TearsheetShell
@use '../Tearsheet/tearsheet';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// Copyright IBM Corp. 2025, 2025
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@use './carbon-imports';
@use './edit-tearsheet';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright IBM Corp. 2024, 2024
// Copyright IBM Corp. 2024, 2025
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
Expand All @@ -15,17 +15,6 @@
@use '@carbon/styles/scss/spacing' as *;
@use '@carbon/styles/scss/type';

// Other Carbon settings if needed
// TODO: @use '@carbon/styles/scss/grid';
// or
// TODO: @use '@carbon/react/scss/grid';

// UserAvatar uses the following Carbon for IBM Products components:
// TODO: @use(s) of IBM Products component styles used by UserAvatar
@use '@carbon/react/scss/components/tooltip';

// The block part of our conventional BEM class names (blockClass__E--M).

$block-class: #{$pkg-prefix}--user-avatar;

$sizes: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@use './CreateTearsheet/index-with-carbon' as *;
@use './Datagrid/index-with-carbon' as *;
@use './EditInPlace/index-with-carbon' as *;
@use './EditTearsheet/index-with-carbon' as *;
@use './EmptyStates/index-with-carbon' as *;
@use './ExportModal/index-with-carbon' as *;
@use './ExpressiveCard/index-with-carbon' as *;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
@use './EditSidePanel/index-with-carbon' as *;
@use './OptionsTile/index-with-carbon' as *;
@use './EditInPlace/index-with-carbon' as *;
@use './EditTearsheet/index-with-carbon' as *;
@use './DataSpreadsheet/index-with-carbon' as *;
@use './Datagrid/index-with-carbon' as *;
@use './EditUpdateCards/index-with-carbon' as *;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ const inputData = {
config: {
component: CustomInput,
operators: customOperators,
valueFormatter: (value) => value?.toUpperCase(),
},
},
],
Expand Down Expand Up @@ -396,7 +397,7 @@ const defaultProps = {
getConditionState: () => {},
variant: NON_HIERARCHICAL_VARIANT,
};

const testInputText = 'testID123';
const inputConfigOptionType = {
properties: [
{
Expand Down Expand Up @@ -786,12 +787,12 @@ describe(componentName, () => {
);

const inputText = document.querySelector('#id');
fireEvent.change(inputText, { target: { value: 'testID123' } });
fireEvent.change(inputText, { target: { value: testInputText } });

const container = document.querySelector(`.${blockClass}`);
await act(() => userEvent.click(container));

const selectedItem = screen.getByRole('button', { name: 'testID123' });
const selectedItem = screen.getByRole('button', { name: testInputText });

expect(selectedItem);
});
Expand All @@ -815,12 +816,12 @@ describe(componentName, () => {
await act(() => userEvent.click(isOperator));

const inputText = document.querySelector('#id_long');
fireEvent.change(inputText, { target: { value: 'testID123' } });
fireEvent.change(inputText, { target: { value: testInputText } });

const container = document.querySelector(`.${blockClass}`);
await act(() => userEvent.click(container));

const selectedItem = screen.getByRole('button', { name: 'testID123' });
const selectedItem = screen.getByRole('button', { name: testInputText });

expect(selectedItem);
});
Expand Down Expand Up @@ -1612,12 +1613,15 @@ describe(componentName, () => {
);

const inputText = document.querySelector('#customInput');
fireEvent.change(inputText, { target: { value: 'testID123' } });
fireEvent.change(inputText, { target: { value: testInputText } });

const container = document.querySelector(`.${blockClass}`);
await act(() => userEvent.click(container));

const selectedItem = screen.getByRole('button', { name: 'testID123' });
// the value formatter will format to uppercase
// cspell: disable
const selectedItem = screen.getByRole('button', {
name: testInputText.toUpperCase(),
});

expect(selectedItem);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ ConditionBuilder.propTypes = {
label: PropTypes.string.isRequired,
})
),
valueFormatter: PropTypes.func,
}),
})
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export interface PropertyConfigNumber {

export type PropertyConfigDate = {
type: 'date';
config: object;
config: {
valueFormatter?: (value: string) => string;
};
};

export type PropertyConfigTime = {
Expand All @@ -108,6 +110,7 @@ export type PropertyConfigCustom = {
label: string;
id: string;
}[];
valueFormatter?: (value: string) => string;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const ConditionBuilderItem = ({
}
const propertyId =
rest['data-name'] == 'valueField' && type
? getValue[type](label, config)
? getValue(type, label, config)
: labelText;

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,10 @@ export const inputData = {
config: {
component: CustomInput,
operators: customOperators,
valueFormatter: (value) => {
// add any customization to the value to be populated
return value;
},
},
},
],
Expand Down
67 changes: 37 additions & 30 deletions packages/ibm-products/src/components/ConditionBuilder/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,35 +112,42 @@ const formatDate = (date) => {
return `${day}/${month}/${year}`;
};

export const getValue = {
text: (value) => value,
textarea: (value) => value,
time: (value) => value,
number: (value) => value,
option: (value) => {
if (value && typeof value !== 'string') {
const selectedValues = Array.isArray(value) ? value : [value];
return selectedValues.map((option) => option.label).join(', ');
}
export const getValue = (type, value, config) => {
if (config?.valueFormatter && ['date', 'custom'].includes(type)) {
return config.valueFormatter(value);
} else {
const formatters = {
text: (value) => value,
textarea: (value) => value,
time: (value) => value,
number: (value) => value,
option: (value) => {
if (value && typeof value !== 'string') {
const selectedValues = Array.isArray(value) ? value : [value];
return selectedValues.map((option) => option.label).join(', ');
}

return value;
},
date: (value) => {
if (Array.isArray(value) && value.length > 1) {
const start =
value?.[0] && !isNaN(new Date(value[0]))
? formatDate(new Date(value[0]))
: '';
const end =
value?.[1] && !isNaN(new Date(value[1]))
? formatDate(new Date(value[1]))
: '';
return `${start} To ${end}`;
} else if (Array.isArray(value) && !isNaN(new Date(value[0]))) {
return formatDate(new Date(value[0]));
} else {
return value;
}
},
custom: (value) => value,
return value;
},
date: (value) => {
if (Array.isArray(value) && value.length > 1) {
const start =
value?.[0] && !isNaN(new Date(value[0]))
? formatDate(new Date(value[0]))
: '';
const end =
value?.[1] && !isNaN(new Date(value[1]))
? formatDate(new Date(value[1]))
: '';
return `${start} To ${end}`;
} else if (Array.isArray(value) && !isNaN(new Date(value[0]))) {
return formatDate(new Date(value[0]));
} else {
return value;
}
},
custom: (value) => value,
};
return formatters[type](value, config);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
HeaderGlobalAction,
} from '@carbon/react';
import { User, Notification } from '@carbon/react/icons';
import { StoryDocsPage } from '../../global/js/utils/StoryDocsPage';
import styles from './_storybook-styles.scss?inline';
import uuidv4 from '../../global/js/utils/uuidv4';
import { UnreadNotificationBell } from './preview-components/UnreadNotificationBell';
Expand All @@ -30,17 +31,17 @@ const storyBlockClass = `${pkg.prefix}--notifications-panel__story`;
const blockClass = `${pkg.prefix}--notifications-panel`;

export default {
title: 'IBM Products/Patterns/Notifications/NotificationsPanel',
title: 'IBM Products/Components/Notifications panel/NotificationsPanel',
component: NotificationsPanel,
tags: ['autodocs'],
parameters: {
styles,
layout: 'fullscreen',
/*
docs: {
page: mdx,
docs: {
page: () => (
<StoryDocsPage altGuidelinesHref="https://pages.github.ibm.com/carbon/ibm-products/components/notification-panel/usage/" />
),
},
*/
},
};

Expand Down
51 changes: 0 additions & 51 deletions packages/ibm-products/src/components/TooltipTrigger/useExample.js

This file was deleted.

0 comments on commit 025cfe2

Please sign in to comment.