,
+ ));
this.$dom.on('click', '[data-action]', this.handleActionButton.bind(this));
this.$dom.on('vjDomDialogShow', this.beforeShow.bind(this));
this.$dom.on('vjDomDialogHidden', this.afterHide.bind(this));
diff --git a/packages/ui-default/components/selectUser.ts b/packages/ui-default/components/selectUser.tsx
similarity index 60%
rename from packages/ui-default/components/selectUser.ts
rename to packages/ui-default/components/selectUser.tsx
index 3aa05a3b1..9cf75c95d 100644
--- a/packages/ui-default/components/selectUser.ts
+++ b/packages/ui-default/components/selectUser.tsx
@@ -1,24 +1,27 @@
+import React from 'react';
import UserSelectAutoComplete from 'vj/components/autocomplete/UserSelectAutoComplete';
import { ActionDialog } from 'vj/components/dialog';
import { i18n, tpl } from 'vj/utils';
import createHint from './hint';
let hintInserted = false;
-$(tpl`
-
-
${i18n('Select User')}
-
-
-
-
+$(tpl(
+
+
+
{i18n('Select User')}
+
+
-
-
`).appendTo(document.body);
+
,
+)).appendTo(document.body);
const userSelector = UserSelectAutoComplete.getOrConstruct($('.dialog__body--user-select [name="user"]')) as any;
const userSelectDialog = new ActionDialog({
- $body: $('.dialog__body--user-select > div'),
+ $body: $('.dialog__body--user-select'),
onDispatch(action) {
if (action === 'ok' && userSelector.value() === null) {
userSelector.focus();
@@ -30,7 +33,7 @@ const userSelectDialog = new ActionDialog({
export default async function selectUser(hint?: string) {
if (hint && !hintInserted) {
- createHint(hint, $('[name="select_user_hint"]'));
+ createHint(hint, $('#select_user_hint'));
hintInserted = true;
}
userSelector.clear();
diff --git a/packages/ui-default/utils/base.ts b/packages/ui-default/utils/base.ts
index 82831f434..53744dbcb 100644
--- a/packages/ui-default/utils/base.ts
+++ b/packages/ui-default/utils/base.ts
@@ -1,7 +1,8 @@
import $ from 'jquery';
import _ from 'lodash';
import React from 'react';
-import DOMServer from 'react-dom/server.browser';
+import ReactDOM from 'react-dom/client';
+import DOMServer from 'react-dom/server';
export function substitute(str: string, obj: any) {
return str.replace(/\{([^{}]+)\}/g, (match, key) => {
@@ -33,8 +34,17 @@ export function secureRandomString(digit = 32, dict = defaultDict) {
type Substitution = string | number | { templateRaw: true, html: string };
-export function tpl(pieces: TemplateStringsArray, ...substitutions: Substitution[]) {
- if (React.isValidElement(pieces)) return DOMServer.renderToStaticMarkup(pieces);
+export function tpl(node: React.ReactNode, reactive?: boolean);
+export function tpl(pieces: TemplateStringsArray, ...substitutions: Substitution[]);
+export function tpl(pieces: TemplateStringsArray | React.ReactNode, ...substitutions: Substitution[] | boolean[]) {
+ if (React.isValidElement(pieces)) {
+ if (substitutions[0]) {
+ const div = document.createElement('div');
+ ReactDOM.createRoot(div).render(pieces);
+ return div;
+ }
+ return DOMServer.renderToStaticMarkup(pieces);
+ }
let result = pieces[0];
for (let i = 0; i < substitutions.length; ++i) {
const subst = substitutions[i];