[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: update to use dynamic imports for web components #210

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a327c2f
Use dynamic imports for web components
web-padawan Dec 26, 2023
e2c9422
Import from theme folder
web-padawan Jan 8, 2024
6047f1d
Fix import for chart-series and iconset
web-padawan Jan 8, 2024
b98d577
Add ts-ignore comment to dynamic imports
web-padawan Jan 8, 2024
394b639
Fix Select to not throw before defined
web-padawan Jan 8, 2024
6fbc419
Re-export types, revert some changes
web-padawan Jan 8, 2024
bc60bfa
Make column re-export from Grid type-only
web-padawan Jan 8, 2024
d68079f
Update ComboBox tests to use await
web-padawan Jan 8, 2024
51bfb3e
Use type-only imports in typings tests
web-padawan Jan 8, 2024
ba1f784
Make Dialog and VirtualList tests async
web-padawan Jan 8, 2024
d2da13a
Make MenuBar and Notification tests async
web-padawan Jan 8, 2024
539eff7
Make ContextMenu and Select tests async
web-padawan Jan 8, 2024
7e55b1f
Fix MultiSelectComboBox event spy in test
web-padawan Jan 8, 2024
77e1d43
Add TODO comment clarifying need for ts-ignore
web-padawan Jan 15, 2024
6948a00
Suppress post-finalize style warning
web-padawan Jan 15, 2024
9652fb1
Revert GridDefaultItem import change
web-padawan Jan 15, 2024
d90f5d8
Make Notification.show import the WC if needed
web-padawan Jan 15, 2024
d4b6ad1
Mark CrudEditColumn as element without theme
web-padawan Jan 15, 2024
3fbf642
Add vaadin-crud-edit to elements without theme
web-padawan Jan 15, 2024
e4533c2
Apply code review suggestion regarding render
web-padawan Jan 15, 2024
8649529
Add define option to call importFunc explicitly
web-padawan Jan 16, 2024
af6f700
Update Dialog to expose define helper
web-padawan Jan 16, 2024
c77b8ca
Fix MenuBar test suite to use type-only import
web-padawan Jan 16, 2024
acfa5ba
Update ContextMenu to expose define helper
web-padawan Jan 16, 2024
16e76c0
Update Select to expose define helper
web-padawan Jan 16, 2024
bf4b085
Update VirtualList to expose define helper
web-padawan Jan 16, 2024
2d36906
Update ComboBox to expose define helper
web-padawan Jan 16, 2024
286ec7f
Update ComboBoxLight to expose define helper
web-padawan Jan 17, 2024
b862067
Update MenuBar to expose define helper
web-padawan Jan 17, 2024
5089f60
Update MultiSelectComboBox to expose define helper
web-padawan Jan 17, 2024
edfca5b
Update Notification to expose define helper
web-padawan Jan 17, 2024
8a17135
Add define helper to components return types
web-padawan Jan 17, 2024
f801fa9
Update DateTimePicker to expose define helper
web-padawan Jan 17, 2024
fd5bc44
Update TimePicker to expose define helper
web-padawan Jan 17, 2024
ca6fbcc
Update TabSheet to expose define helper
web-padawan Jan 17, 2024
2a59862
Add define to Grid, GridPro and columns
web-padawan Jan 17, 2024
84e7dc2
Revert no longer needed generator tweaks
web-padawan Jan 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Dialog to expose define helper
  • Loading branch information
web-padawan committed Jan 17, 2024
commit af6f700eaf7b6ef9c4c5eaaa0974cc5b1c742680
8 changes: 7 additions & 1 deletion src/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {
type ComponentType,
type ForwardedRef,
type ForwardRefExoticComponent,
type HTMLAttributes,
forwardRef,
type ReactElement,
type ReactNode,
type RefAttributes,
} from 'react';
import { Dialog as _Dialog, type DialogElement, type DialogProps as _DialogProps } from './generated/Dialog.js';
import { useSimpleOrChildrenRenderer } from './renderers/useSimpleOrChildrenRenderer.js';
Expand Down Expand Up @@ -48,6 +50,10 @@ function Dialog(
);
}

const ForwardedDialog = forwardRef(Dialog);
const ForwardedDialog = forwardRef(Dialog) as ForwardRefExoticComponent<DialogProps & RefAttributes<DialogElement>> & {
define(): Promise<void>;
};

Object.assign(ForwardedDialog, { define: _Dialog.define });

export { ForwardedDialog as Dialog };
24 changes: 9 additions & 15 deletions test/Dialog.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ describe('Dialog', () => {
ref.opened = false;
});

async function until(predicate: () => boolean) {
while (!predicate()) {
await new Promise((r) => setTimeout(r, 10));
}
}

async function assert() {
await until(() => !!document.querySelector(`${overlayTag}[opened]`));

function assert() {
const dialog = document.querySelector(overlayTag);
expect(dialog).to.exist;

Expand All @@ -39,19 +31,21 @@ describe('Dialog', () => {
expect(body).to.have.text('FooBar');
}

before(Dialog.define);

afterEach(cleanup);
afterEach(catcher);

it('should use children if no renderer property set', async () => {
it('should use children if no renderer property set', () => {
render(
<Dialog ref={ref} opened header={<>Title</>} footer={<>Footer</>}>
FooBar
</Dialog>,
);
await assert();
assert();
});

it('should use renderer prop if it is set', async () => {
it('should use renderer prop if it is set', () => {
render(
<Dialog
ref={ref}
Expand All @@ -61,16 +55,16 @@ describe('Dialog', () => {
renderer={() => <>FooBar</>}
></Dialog>,
);
await assert();
assert();
});

it('should use children as renderer prop', async () => {
it('should use children as renderer prop', () => {
render(
<Dialog ref={ref} opened headerRenderer={() => <>Title</>} footerRenderer={() => <>Footer</>}>
{() => <>FooBar</>}
</Dialog>,
);
await assert();
assert();
});

it('should not warn on open', async () => {
Expand Down