Skip to content

Commit

Permalink
fix: react build
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideMininni-Fincons committed Apr 23, 2024
1 parent 52774fd commit 2fd5f4b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/components/core/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './interfaces/dialog-close-details.js';
export * from './interfaces/types.js';
export * from './interfaces/validation-change.js';
4 changes: 4 additions & 0 deletions src/components/core/interfaces/dialog-close-details.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type SbbDialogCloseEventDetails = {
returnValue?: any;
closeTarget?: HTMLElement;
};
11 changes: 1 addition & 10 deletions src/components/dialog/dialog/dialog-base-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ import { SbbLanguageController } from '../../core/controllers.js';
import { hostContext, SbbScrollHandler } from '../../core/dom.js';
import { EventEmitter } from '../../core/eventing.js';
import { i18nDialog } from '../../core/i18n.js';
import type { SbbOpenedClosedState } from '../../core/interfaces.js';
import type { SbbDialogCloseEventDetails, SbbOpenedClosedState } from '../../core/interfaces.js';
import { SbbNegativeMixin } from '../../core/mixins.js';
import { applyInertMechanism, removeInertMechanism } from '../../core/overlay.js';
import type { SbbScreenReaderOnlyElement } from '../../screen-reader-only.js';

// A global collection of existing dialogs
export const dialogRefs: SbbDialogBaseElement[] = [];

export type SbbDialogCloseEventDetails = {
returnValue?: any;
closeTarget?: HTMLElement;
};

export abstract class SbbDialogBaseElement extends SbbNegativeMixin(LitElement) {
public static readonly events = {
willOpen: 'willOpen',
Expand All @@ -30,10 +25,6 @@ export abstract class SbbDialogBaseElement extends SbbNegativeMixin(LitElement)
/** This will be forwarded as aria-label to the relevant nested element. */
@property({ attribute: 'accessibility-label' }) public accessibilityLabel: string | undefined;

/** Whether the animation is enabled. */
@property({ attribute: 'disable-animation', reflect: true, type: Boolean })
public disableAnimation = false;

/** The state of the overlay. */
protected set state(state: SbbOpenedClosedState) {
this.setAttribute('data-state', state);
Expand Down
2 changes: 0 additions & 2 deletions src/components/overlay.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export * from './overlay/overlay.js';
// FIXME this is needed due to the react build: it fails without the SbbDialogCloseEventDetails explicit export
export * from './dialog/dialog/dialog-base-element.js';
11 changes: 5 additions & 6 deletions tools/vite/generate-react-wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function renderTemplate(
const extensionImport = !extensions.size
? ''
: `
import { ${Array.from(extensions.keys()).join(', ')} } from '${relativeCoreImportPath}';`;
const extension = [...extensions.values()].reduce(
(current, next) => (v) => current(next(v)),
Expand All @@ -141,10 +141,9 @@ function renderTemplate(
// If a type or interface needs to be imported, the custom elements analyzer will not
// detect/extract these and therefore we need to have a manual list of required
// types/interfaces.
const interfaces = new Map<string, string>().set(
'SbbValidationChangeEvent',
'core/interfaces.js',
);
const interfaces = new Map<string, string>()
.set('SbbDialogCloseEventDetails', 'core/interfaces.js')
.set('SbbValidationChangeEvent', 'core/interfaces.js');
for (const customEventType of customEventTypes) {
const exportModule = exports.find((e) => e.name === customEventType);
if (exportModule) {
Expand Down Expand Up @@ -173,7 +172,7 @@ function renderTemplate(
)
.join('\n')}
import react from 'react';${extensionImport}
// eslint-disable-next-line @typescript-eslint/naming-convention
export const ${declaration.name.replace(/Element$/, '')} = ${extension(`createComponent({
tagName: '${declaration.tagName}',
Expand Down

0 comments on commit 2fd5f4b

Please sign in to comment.