Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 0 additions & 14 deletions semcore/accordion/src/Accordion.internal.type.ts

This file was deleted.

30 changes: 14 additions & 16 deletions semcore/accordion/src/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import ChevronRightM from '@semcore/icon/ChevronRight/m';
import { Text } from '@semcore/typography';
import React from 'react';

import type {
AccordionCollapsePropsInternal,
AccordionItemPropsInternal,
AccordionItemTogglePropsInternal,
} from './Accordion.internal.type';
import type {
AccordionCollapseProps,
AccordionComponent,
Expand Down Expand Up @@ -82,8 +77,12 @@ class RootAccordion extends Component<AccordionProps, typeof RootAccordion.enhan
return <Children />;
}
}

export class RootItem extends Component<AccordionItemProps, typeof RootItem.enhance, {}, AccordionItemPropsInternal> {
export class RootItem extends Component<
AccordionItemProps,
typeof RootItem.enhance,
{},
Intergalactic.InternalTypings.InferPropsFromRoot<typeof RootAccordion, 'Item'>
> {
static displayName = 'Item';
static style = style;
static enhance = [uniqueIDEnhancement()] as const;
Expand Down Expand Up @@ -142,7 +141,12 @@ export class RootItem extends Component<AccordionItemProps, typeof RootItem.enha
}
}

class Toggle extends Component<AccordionItemToggleProps, never, {}, AccordionItemTogglePropsInternal> {
class Toggle extends Component<
AccordionItemToggleProps,
never,
{},
Intergalactic.InternalTypings.InferPropsFromRoot<typeof RootItem, 'Toggle'>
> {
toggleRef = React.createRef();

handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {
Expand All @@ -163,13 +167,7 @@ class Toggle extends Component<AccordionItemToggleProps, never, {}, AccordionIte
const SItemToggle = Root;

return sstyled(styles)(
<SItemToggle
use={use}
ref={this.toggleRef}
render={Text}
innerOutline
onKeyDown={this.handleKeyDown}
/>,
<SItemToggle use={use} ref={this.toggleRef} render={Text} innerOutline onKeyDown={this.handleKeyDown} />,
);
}
}
Expand All @@ -190,7 +188,7 @@ function ToggleButton(props: IRootComponentProps) {
);
}

function Collapse(props: AccordionCollapseProps & AccordionCollapsePropsInternal) {
function Collapse(props: AccordionCollapseProps & Intergalactic.InternalTypings.InferPropsFromRoot<typeof RootItem, 'Collapse'>) {
const { selected } = props;
const visible = selected;

Expand Down
4 changes: 4 additions & 0 deletions semcore/core/src/core-types/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ export namespace Intergalactic {
/** @private */
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace InternalTypings {
export type InferPropsFromRoot<
Root extends new (...args: any) => any,
Child extends string,
> = InstanceType<Root>[`get${Child}Props`] extends (...args: any[]) => infer R ? R : Record<string, unknown>;
export type PartialRequired<T, K extends keyof T> = Omit<T, K> & {
[key in K]-?: T[key];
};
Expand Down
Loading