-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
161 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { Block } from '../blocks/Block'; | ||
import { BaseSurfaceRenderer } from './BaseSurfaceRenderer'; | ||
import { | ||
BaseSurfaceRenderer, | ||
PossibleAllowedLayouts, | ||
} from './BaseSurfaceRenderer'; | ||
import { Conditions } from './Conditions'; | ||
|
||
export const createSurfaceRenderer = <OutputElement>() => ( | ||
surfaceRenderer: BaseSurfaceRenderer<OutputElement>, | ||
export const createSurfaceRenderer = < | ||
OutputElement, | ||
AllowedBlockTypes extends PossibleAllowedLayouts | ||
>() => ( | ||
surfaceRenderer: BaseSurfaceRenderer<OutputElement, AllowedBlockTypes>, | ||
conditions?: Conditions | ||
) => (blocks: readonly { type: string }[]) => | ||
) => (blocks: readonly Pick<Block, 'type'>[]): OutputElement[] => | ||
surfaceRenderer.render(blocks as Block[], conditions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/ui-kit/src/rendering/surfaces/GenericSurfaceLayout.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { LayoutBlockMap } from '../../blocks/LayoutBlock'; | ||
|
||
type Override<T1, T2> = Omit<T1, keyof T2> & T2; | ||
|
||
export type OverrideLayout< | ||
T extends Partial<LayoutBlockMap>, | ||
D = Override<LayoutBlockMap, T> | ||
> = D; | ||
|
||
type AllowedLayoutsFiltered< | ||
AllowedLayoutsTypes extends keyof LayoutBlockMap, | ||
D, | ||
S = { [P in keyof D]: P extends AllowedLayoutsTypes ? D[P] : never }, | ||
R = S[keyof S] | ||
> = R; | ||
|
||
export type GenericSurfaceLayout< | ||
AllowedLayoutsTypes extends keyof LayoutBlockMap, | ||
T extends Partial<LayoutBlockMap> = LayoutBlockMap | ||
> = AllowedLayoutsFiltered<AllowedLayoutsTypes, OverrideLayout<T>>[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES5", | ||
"lib": ["ES2018"], | ||
"sourceMap": true, | ||
"module": "ES2020", | ||
"lib": ["ES2020"], | ||
"downlevelIteration": true, | ||
"declaration": true, | ||
"declarationMap": true, | ||
"sourceMap": true, | ||
"outDir": "./dist/esm/", | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"skipLibCheck": true | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true | ||
}, | ||
"exclude": ["dist/", "src/**/*.spec.ts"] | ||
} |