Skip to content

Commit

Permalink
replace ExpandableText with web component
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas742 committed Jan 8, 2025
1 parent fa1f7a2 commit fda991d
Show file tree
Hide file tree
Showing 12 changed files with 865 additions and 778 deletions.
583 changes: 181 additions & 402 deletions .storybook/custom-element-manifests/fiori.json

Large diffs are not rendered by default.

648 changes: 518 additions & 130 deletions .storybook/custom-element-manifests/main.json

Large diffs are not rendered by default.

83 changes: 0 additions & 83 deletions packages/main/src/components/ExpandableText/ExpandableText.cy.tsx

This file was deleted.

This file was deleted.

This file was deleted.

107 changes: 0 additions & 107 deletions packages/main/src/components/ExpandableText/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/main/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export { ObjectPageHeader } from './components/ObjectPageHeader/index.js';
export type { ObjectPageHeaderPropTypes } from './components/ObjectPageHeader/index.js';
export { ObjectPageTitle } from './components/ObjectPageTitle/index.js';
export type { ObjectPageTitlePropTypes } from './components/ObjectPageTitle/index.js';
export * from './components/ExpandableText/index.js';
export * from './components/FilterBar/index.js';
export * from './components/FilterGroupItem/index.js';
export * from './components/FlexBox/index.js';
Expand Down
28 changes: 28 additions & 0 deletions packages/main/src/internal/withWebComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,31 @@ export const withWebComponent = <Props extends Record<string, any>, RefType = Ui
return null;
}

// compatibility wrapper for ExpandableText - remove in v3
if (tagName === 'ui5-expandable-text') {
const renderWhiteSpace = nonWebComponentRelatedProps['renderWhitespace'] ? true : undefined;
// @ts-expect-error: overflowMode is available
const { ['overflow-mode']: overflowMode, text, ...restRegularProps } = regularProps;
const showOverflowInPopover = nonWebComponentRelatedProps['showOverflowInPopover'];
return (
<Component
ref={componentRef}
{...booleanProps}
{...restRegularProps}
{...eventHandlers}
{...nonWebComponentRelatedProps}
// @ts-expect-error: overflowMode is available
overflowMode={overflowMode ?? (showOverflowInPopover ? 'Popover' : 'InPlace')}
text={text ?? children}
class={className}
suppressHydrationWarning
data-_render-whitespace={renderWhiteSpace}
>
{slots}
</Component>
);
}

return (
<Component
ref={componentRef}
Expand All @@ -201,6 +226,9 @@ export const withWebComponent = <Props extends Record<string, any>, RefType = Ui
{...nonWebComponentRelatedProps}
class={className}
suppressHydrationWarning
data-render-whitespace={
tagName === 'ui5-expandable-text' && nonWebComponentRelatedProps['renderWhitespace'] ? true : undefined
}
>
{slots}
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ControlsWithNote, DocsHeader, Footer } from '@sb/components';
import { Canvas, Meta } from '@storybook/blocks';
import * as ComponentStories from './ExpandableText.stories';
import { ControlsWithNote, DocsHeader, Footer } from '@sb/components';
import * as ComponentStories from './ExpandableText.stories.tsx';

<Meta of={ComponentStories} />

<DocsHeader since="1.23.0" />
<DocsHeader />

<br />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { Meta, StoryObj } from '@storybook/react';
import ExpandableTextOverflowMode from '@ui5/webcomponents/dist/types/ExpandableTextOverflowMode.js';
import TextEmptyIndicatorMode from '@ui5/webcomponents/dist/types/TextEmptyIndicatorMode.js';
import { ExpandableText } from './index.js';

const meta = {
title: 'Data Display / ExpandableText',
component: ExpandableText,
argTypes: {
text: { control: 'text' },
maxCharacters: { control: 'number' },
children: { control: { disable: true } },
showOverflowInPopover: { control: { disable: true } }
//todo: uncomment once white-space can be applied w/o addCustomCSS
// renderWhitespace: { control: { disable: true } }
},
args: {
emptyIndicatorMode: TextEmptyIndicatorMode.Off,
overflowMode: ExpandableTextOverflowMode.InPlace,
text: ` If "renderWhitespace" is set to true, there will be thirteen white spaces in front and after this sentence. Lorem ipsum dolor st amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat`,
maxCharacters: 100
},
tags: ['package:@ui5/webcomponents']
} satisfies Meta<typeof ExpandableText>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {};
Loading

0 comments on commit fda991d

Please sign in to comment.