Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
RocketChat
Rocket.Chat.Fuselage
Commits
4761c66a
Unverified
Commit
4761c66a
authored
Feb 25, 2021
by
Tasso Evangelista
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prepare jsx-runtime
parent
630044c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
5 deletions
+110
-5
packages/ui-kit/jsx-runtime/package.json
packages/ui-kit/jsx-runtime/package.json
+13
-0
packages/ui-kit/src/index.ts
packages/ui-kit/src/index.ts
+0
-2
packages/ui-kit/src/jsx/jsx-runtime.spec.tsx
packages/ui-kit/src/jsx/jsx-runtime.spec.tsx
+1
-3
packages/ui-kit/src/jsx/jsx-runtime.ts
packages/ui-kit/src/jsx/jsx-runtime.ts
+96
-0
No files found.
packages/ui-kit/jsx-runtime/package.json
0 → 100644
View file @
4761c66a
{
"private"
:
true
,
"main"
:
"../dist/cjs/jsx/jsx-runtime.js"
,
"module"
:
"../dist/esm/jsx/jsx-runtime.js"
,
"types"
:
"../dist/esm/jsx/jsx-runtime.d.ts"
,
"typesVersions"
:
{
"<4.1"
:
{
"*"
:
[
"../dist/ts3.4/jsx/*"
]
}
}
}
packages/ui-kit/src/index.ts
View file @
4761c66a
...
...
@@ -47,5 +47,3 @@ export { uiKitModal } from './rendering/surfaces/uiKitModal';
export
{
UiKitParserBanner
}
from
'
./rendering/surfaces/UiKitParserBanner
'
;
export
{
UiKitParserMessage
}
from
'
./rendering/surfaces/UiKitParserMessage
'
;
export
{
UiKitParserModal
}
from
'
./rendering/surfaces/UiKitParserModal
'
;
export
{
jsx
}
from
'
./rendering/jsx
'
;
packages/ui-kit/src/
rendering/jsx
.spec.tsx
→
packages/ui-kit/src/
jsx/jsx-runtime
.spec.tsx
View file @
4761c66a
/** @jsx jsx */
/** @jsxFrag jsxFrag */
/** @jsxImportSource . */
import
{
Option
}
from
'
../blocks/Option
'
;
import
{
jsx
,
jsxFrag
}
from
'
./jsx
'
;
describe
(
'
divider
'
,
()
=>
{
it
(
'
renders
'
,
()
=>
{
...
...
packages/ui-kit/src/
rendering/jsx
.ts
→
packages/ui-kit/src/
jsx/jsx-runtime
.ts
View file @
4761c66a
...
...
@@ -2,6 +2,14 @@
/* eslint-disable @typescript-eslint/no-namespace */
import
{
Block
}
from
'
../blocks/Block
'
;
import
{
TextObject
}
from
'
../blocks/TextObject
'
;
import
{
TextObjectType
}
from
'
../blocks/TextObjectType
'
;
type
TypeToPropsMap
=
{
[
T
in
TextObject
as
T
[
'
type
'
]]:
Omit
<
T
,
'
type
'
|
'
text
'
>
&
{
children
?:
string
;
};
};
type
PropsForBlock
<
B
extends
Block
>
=
Omit
<
{
...
...
@@ -19,15 +27,17 @@ namespace JSXInternal {
};
}
export
{
JSXInternal
as
JSX
};
export
const
jsxFrag
=
Symbol
(
'
jsxFrag
'
);
export
function
jsx
(
type
:
undefined
,
props
:
{
children
:
Block
;
}
):
[
Block
];
export
function
jsx
<
B
extends
Block
>
(
type
:
typeof
jsxFrag
,
props
:
never
,
...
children
:
B
[]
):
B
;
export
function
jsx
(
type
:
TextObject
[
'
type
'
],
props
:
TypeToPropsMap
[
TextObject
[
'
type
'
]]
):
TextObject
;
export
function
jsx
<
B
extends
Block
>
(
type
:
B
[
'
type
'
],
...
...
@@ -36,20 +46,51 @@ export function jsx<B extends Block>(
):
B
;
export
function
jsx
(
type
:
unknown
,
props
:
Record
<
string
,
unknown
>
,
...
children
:
Block
[]
type
:
undefined
|
TextObject
[
'
type
'
]
|
unknown
,
props
:
|
{
children
:
Block
;
}
|
TypeToPropsMap
[
TextObject
[
'
type
'
]]
|
Record
<
string
,
unknown
>
):
unknown
{
if
(
type
===
jsxFrag
)
{
return
children
;
switch
(
type
)
{
case
undefined
:
return
[
props
.
children
];
case
TextObjectType
.
PLAIN_TEXT
:
case
TextObjectType
.
MARKDOWN
:
{
const
{
children
,
...
rest
}
=
props
;
return
{
type
,
text
:
children
,
...
rest
};
}
default
:
return
{
type
,
...
props
};
}
}
return
{
type
,
...
props
,
};
export
function
jsxs
<
B
extends
Block
[]
>
(
type
:
undefined
,
props
:
{
children
:
B
;
}
):
B
;
export
function
jsxs
(
type
:
Block
[
'
type
'
]
|
undefined
,
props
:
Record
<
string
,
unknown
>
)
{
switch
(
type
)
{
case
undefined
:
return
props
.
children
;
default
:
return
jsx
(
type
,
props
);
}
}
export
namespace
jsx
{
export
import
JSX
=
JSXInternal
;
}
export
{
JSXInternal
as
JSX
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment