Skip to content

Commit

Permalink
fix: file format + errors reported by svelte-check after minor upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinderoubaix committed Jan 15, 2024
1 parent 64a010f commit ac1508c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
7 changes: 4 additions & 3 deletions angular/headless/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ export type SlotContent<Props extends object = object> =
| Type<unknown>
| ComponentTemplate<Props, any, any>;

export type AdaptSlotContentProps<Props extends Record<string, any>> = Props extends WidgetSlotContext<infer U>
? WidgetSlotContext<AdaptWidgetSlots<U>> & AdaptPropsSlots<Omit<Props, keyof WidgetSlotContext<any>>>
: AdaptPropsSlots<Props>;
export type AdaptSlotContentProps<Props extends Record<string, any>> =
Props extends WidgetSlotContext<infer U>
? WidgetSlotContext<AdaptWidgetSlots<U>> & AdaptPropsSlots<Omit<Props, keyof WidgetSlotContext<any>>>
: AdaptPropsSlots<Props>;

export type AdaptPropsSlots<Props> = Omit<Props, `slot${string}`> & {
[K in keyof Props & `slot${string}`]: Props[K] extends CoreSlotContent<infer U> ? SlotContent<AdaptSlotContentProps<U>> : Props[K];
Expand Down
5 changes: 2 additions & 3 deletions core/src/services/extendWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ export type ExtendWidgetProps<W extends Widget, ExtraProps extends object> = Wid
/**
* Type replacing the original Props with WidgetSlotContext contaning ExtraProps
*/
export type ExtendWidgetAdaptSlotContentProps<Props extends Record<string, any>, ExtraProps extends object> = Props extends WidgetSlotContext<infer U>
? WidgetSlotContext<ExtendWidgetProps<U, ExtraProps>> & Omit<Props, keyof WidgetSlotContext<any>>
: Props;
export type ExtendWidgetAdaptSlotContentProps<Props extends Record<string, any>, ExtraProps extends object> =
Props extends WidgetSlotContext<infer U> ? WidgetSlotContext<ExtendWidgetProps<U, ExtraProps>> & Omit<Props, keyof WidgetSlotContext<any>> : Props;

/**
* Type enriching the original widget slot Props with ExtraProps slots
Expand Down
4 changes: 3 additions & 1 deletion demo/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {intersectionApi} from '$lib/stores';
import {afterUpdate} from 'svelte';

const textToLinesRegex = /\r/g;

export function getTitle(title: string, frameworkName = '') {
return `AgnosUI - ${title}` + (frameworkName ? ` for ${frameworkName}` : '');
}
Expand All @@ -14,7 +16,7 @@ export function getWidgetDescription(name: string, frameworkName = '') {
* @param text text to split
*/
export function textToLines(text: string) {
return text.replaceAll('\r', '').split('\n\n');
return text.replace(textToLinesRegex, '').split('\n\n');
}

const arrowFunctionRegExp = /^\([^(]*\)[^=]*=>/;
Expand Down
2 changes: 1 addition & 1 deletion demo/src/lib/layout/MainSection.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import {createTOC} from '../../app';
const tocDirective = createTOC((node) => [...node.querySelectorAll('section')] as HTMLElement[]);
const tocDirective = createTOC((node) => Array.from(node.querySelectorAll('section')));
</script>

<div use:tocDirective><slot /></div>
7 changes: 4 additions & 3 deletions react/headless/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ export type SlotContent<Props extends object = object> =
| React.ComponentType<Props>
| React.ReactNode;

export type AdaptSlotContentProps<Props extends Record<string, any>> = Props extends WidgetSlotContext<infer U>
? WidgetSlotContext<AdaptWidgetSlots<U>> & AdaptPropsSlots<Omit<Props, keyof WidgetSlotContext<any>>>
: AdaptPropsSlots<Props>;
export type AdaptSlotContentProps<Props extends Record<string, any>> =
Props extends WidgetSlotContext<infer U>
? WidgetSlotContext<AdaptWidgetSlots<U>> & AdaptPropsSlots<Omit<Props, keyof WidgetSlotContext<any>>>
: AdaptPropsSlots<Props>;

export type AdaptPropsSlots<Props> = Omit<Props, `slot${string}`> & {
[K in keyof Props & `slot${string}`]: Props[K] extends CoreSlotContent<infer U> ? SlotContent<AdaptSlotContentProps<U>> : Props[K];
Expand Down
7 changes: 4 additions & 3 deletions svelte/headless/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export type SlotSvelteComponent<Props extends object = object> = ComponentType<

export type SlotContent<Props extends object = object> = CoreSlotContent<Props> | SlotSvelteComponent<Props> | typeof useSvelteSlot;

export type AdaptSlotContentProps<Props extends Record<string, any>> = Props extends WidgetSlotContext<infer U>
? WidgetSlotContext<AdaptWidgetSlots<U>> & AdaptPropsSlots<Omit<Props, keyof WidgetSlotContext<any>>>
: AdaptPropsSlots<Props>;
export type AdaptSlotContentProps<Props extends Record<string, any>> =
Props extends WidgetSlotContext<infer U>
? WidgetSlotContext<AdaptWidgetSlots<U>> & AdaptPropsSlots<Omit<Props, keyof WidgetSlotContext<any>>>
: AdaptPropsSlots<Props>;

export type AdaptPropsSlots<Props> = Omit<Props, `slot${string}`> & {
[K in keyof Props & `slot${string}`]: Props[K] extends CoreSlotContent<infer U> ? SlotContent<AdaptSlotContentProps<U>> : Props[K];
Expand Down

0 comments on commit ac1508c

Please sign in to comment.