xmlui 0.9.23 → 0.9.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apiInterceptorWorker-CFF3bC6o.mjs +818 -0
- package/dist/{index-B8C8yAZL.mjs → index-DtxDGaqF.mjs} +11792 -3151
- package/dist/index.css +1298 -521
- package/dist/language-server-web-worker.mjs +1 -1
- package/dist/language-server.mjs +1 -1
- package/dist/lint-CYAUfk0_.mjs +168 -0
- package/dist/metadata-utils-CCIMqe69.mjs +466 -0
- package/dist/scripts/package.json +252 -0
- package/dist/scripts/src/components/App/App.js +0 -2
- package/dist/scripts/src/components/App/AppNative.js +22 -12
- package/dist/scripts/src/components/AppHeader/AppHeader.js +1 -1
- package/dist/scripts/src/components/AppHeader/AppHeaderNative.js +4 -5
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +5 -2
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +13 -10
- package/dist/scripts/src/components/Bookmark/BookmarkNative.js +5 -1
- package/dist/scripts/src/components/CodeBlock/CodeBlock.js +31 -0
- package/dist/scripts/src/components/CodeBlock/CodeBlockNative.js +82 -0
- package/dist/scripts/src/components/ComponentProvider.js +5 -0
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +1 -0
- package/dist/scripts/src/components/Footer/FooterNative.js +2 -1
- package/dist/scripts/src/components/Form/FormNative.js +34 -18
- package/dist/scripts/src/components/FormItem/FormItem.js +5 -2
- package/dist/scripts/src/components/FormItem/FormItemNative.js +4 -3
- package/dist/scripts/src/components/Heading/Heading.js +13 -0
- package/dist/scripts/src/components/Heading/HeadingNative.js +1 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +7 -3
- package/dist/scripts/src/components/Icon/DarkToLightIcon.js +10 -0
- package/dist/scripts/src/components/Icon/LightToDark.js +10 -0
- package/dist/scripts/src/components/IconProvider.js +4 -0
- package/dist/scripts/src/components/Image/ImageNative.js +1 -1
- package/dist/scripts/src/components/Link/Link.js +5 -5
- package/dist/scripts/src/components/List/ListNative.js +1 -1
- package/dist/scripts/src/components/Markdown/Markdown.js +52 -16
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +34 -73
- package/dist/scripts/src/components/Markdown/highlight-code.js +160 -0
- package/dist/scripts/src/components/Markdown/parse-binding-expr.js +60 -0
- package/dist/scripts/src/components/Markdown/utils.js +282 -0
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +116 -0
- package/dist/scripts/src/components/ModalDialog/Dialog.js +20 -0
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +2 -2
- package/dist/scripts/src/components/NestedApp/NestedApp.js +61 -0
- package/dist/scripts/src/components/NestedApp/NestedAppNative.js +125 -0
- package/dist/scripts/src/components/NestedApp/Tooltip.js +46 -0
- package/dist/scripts/src/components/NumberBox/NumberBox.js +4 -1
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +2 -2
- package/dist/scripts/src/components/Option/Option.js +3 -2
- package/dist/scripts/src/components/Select/Select.js +5 -3
- package/dist/scripts/src/components/Select/SelectNative.js +53 -42
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +1 -1
- package/dist/scripts/src/components/Spinner/Spinner.js +0 -1
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +1 -0
- package/dist/scripts/src/components/Text/Text.js +12 -1
- package/dist/scripts/src/components/Text/TextNative.js +5 -1
- package/dist/scripts/src/components/TextBox/TextBox.js +6 -1
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +2 -2
- package/dist/scripts/src/components/Theme/ThemeNative.js +7 -3
- package/dist/scripts/src/components/ToneChangerButton/ToneChangerButton.js +1 -3
- package/dist/scripts/src/components-core/RestApiProxy.js +10 -7
- package/dist/scripts/src/components-core/TableOfContentsContext.js +1 -1
- package/dist/scripts/src/components-core/appContext/date-functions.js +23 -0
- package/dist/scripts/src/components-core/appContext/math-function.js +27 -0
- package/dist/scripts/src/components-core/appContext/misc-utils.js +13 -0
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +199 -0
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +94 -0
- package/dist/scripts/src/components-core/interception/Backend.js +128 -0
- package/dist/scripts/src/components-core/interception/Errors.js +129 -0
- package/dist/scripts/src/components-core/interception/InMemoryDb.js +41 -0
- package/dist/scripts/src/components-core/interception/IndexedDb.js +207 -0
- package/dist/scripts/src/components-core/interception/ReadonlyCollection.js +145 -0
- package/dist/scripts/src/components-core/interception/abstractions.js +2 -0
- package/dist/scripts/src/components-core/interception/apiInterceptorWorker.js +46 -0
- package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +9 -0
- package/dist/scripts/src/components-core/rendering/AppContent.js +336 -0
- package/dist/scripts/src/components-core/rendering/AppRoot.js +84 -0
- package/dist/scripts/src/components-core/rendering/AppWrapper.js +49 -0
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +17 -7
- package/dist/scripts/src/components-core/rendering/Container.js +2 -1
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +2 -7
- package/dist/scripts/src/components-core/theming/themes/root.js +1 -0
- package/dist/scripts/src/components-core/utils/date-utils.js +78 -0
- package/dist/scripts/src/components-core/utils/hooks.js +26 -0
- package/dist/scripts/src/components-core/utils/misc.js +1 -1
- package/dist/scripts/src/components-core/utils/request-params.js +70 -0
- package/dist/scripts/src/logging/LoggerContext.js +22 -0
- package/dist/scripts/src/logging/LoggerInitializer.js +14 -0
- package/dist/scripts/src/logging/LoggerService.js +60 -0
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +7 -0
- package/dist/{server-common-DW5h7Q34.mjs → server-common-9TiLMTJj.mjs} +106 -98
- package/dist/style.css +3325 -2794
- package/dist/{lint-EcgF-9Wr.mjs → transform-DC0Gy6qw.mjs} +1246 -540
- package/dist/xmlui-metadata.mjs +2647 -2521
- package/dist/xmlui-metadata.umd.js +2649 -2523
- package/dist/xmlui-parser.d.ts +49 -4
- package/dist/xmlui-parser.mjs +49 -48
- package/dist/xmlui-standalone.umd.js +34524 -31277
- package/dist/xmlui.d.ts +3 -1
- package/dist/xmlui.mjs +10 -10
- package/package.json +2 -1
- package/dist/apiInterceptorWorker-DZyEgCvB.mjs +0 -8447
- package/dist/parser-CBXS8ft2.mjs +0 -1196
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.ConfirmationModalContextProvider = exports.useConfirm = void 0;
|
|
46
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
47
|
+
const react_1 = __importStar(require("react"));
|
|
48
|
+
const ButtonNative_1 = require("../Button/ButtonNative");
|
|
49
|
+
const StackNative_1 = require("../Stack/StackNative");
|
|
50
|
+
const Dialog_1 = require("./Dialog");
|
|
51
|
+
const ConfirmationModalContext = react_1.default.createContext({
|
|
52
|
+
confirm: (title, message, actionLabel) => __awaiter(void 0, void 0, void 0, function* () { return false; }),
|
|
53
|
+
});
|
|
54
|
+
const useConfirm = () => (0, react_1.useContext)(ConfirmationModalContext);
|
|
55
|
+
exports.useConfirm = useConfirm;
|
|
56
|
+
const ConfirmationModalContextProvider = ({ children }) => {
|
|
57
|
+
// State
|
|
58
|
+
const [showConfirmationModal, setShowConfirmationModal] = (0, react_1.useState)(false);
|
|
59
|
+
const [title, setTitle] = (0, react_1.useState)("Are you sure?");
|
|
60
|
+
const [message, setMessage] = (0, react_1.useState)();
|
|
61
|
+
const [buttons, setButtons] = (0, react_1.useState)([]);
|
|
62
|
+
// Refs and other
|
|
63
|
+
const resolver = (0, react_1.useRef)(null);
|
|
64
|
+
const buttonsRef = (0, react_1.useRef)(null);
|
|
65
|
+
(0, react_1.useEffect)(() => {
|
|
66
|
+
if (showConfirmationModal) {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
var _a;
|
|
69
|
+
const focusable = (_a = buttonsRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll("button");
|
|
70
|
+
if (focusable) {
|
|
71
|
+
focusable[focusable.length - 1].focus();
|
|
72
|
+
}
|
|
73
|
+
}, 0);
|
|
74
|
+
}
|
|
75
|
+
}, [showConfirmationModal]);
|
|
76
|
+
const handleShow = (0, react_1.useCallback)((title, message, actionLabel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
if (typeof title === "string") {
|
|
78
|
+
setTitle(title);
|
|
79
|
+
setButtons([
|
|
80
|
+
{
|
|
81
|
+
label: actionLabel || "Ok",
|
|
82
|
+
value: true,
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
setMessage(message);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
setTitle(title.title);
|
|
89
|
+
setButtons(title.buttons);
|
|
90
|
+
setMessage(title.message);
|
|
91
|
+
}
|
|
92
|
+
setShowConfirmationModal(true);
|
|
93
|
+
return new Promise(function (resolve) {
|
|
94
|
+
resolver.current = resolve;
|
|
95
|
+
});
|
|
96
|
+
}), []);
|
|
97
|
+
const handleOk = (0, react_1.useCallback)((value) => {
|
|
98
|
+
resolver.current && resolver.current(value);
|
|
99
|
+
setShowConfirmationModal(false);
|
|
100
|
+
}, []);
|
|
101
|
+
const handleCancel = (0, react_1.useCallback)(() => {
|
|
102
|
+
resolver.current && resolver.current(false);
|
|
103
|
+
setShowConfirmationModal(false);
|
|
104
|
+
}, []);
|
|
105
|
+
const contextValue = (0, react_1.useMemo)(() => {
|
|
106
|
+
return {
|
|
107
|
+
confirm: handleShow,
|
|
108
|
+
};
|
|
109
|
+
}, [handleShow]);
|
|
110
|
+
return ((0, jsx_runtime_1.jsxs)(ConfirmationModalContext.Provider, { value: contextValue, children: [children, showConfirmationModal && ((0, jsx_runtime_1.jsx)(Dialog_1.Dialog, { title: title, description: message, isOpen: true, onClose: handleCancel, buttons: (0, jsx_runtime_1.jsxs)(StackNative_1.Stack, { orientation: "horizontal", horizontalAlignment: "end", style: { width: "100%", gap: "1em" }, ref: buttonsRef, children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "ghost", themeColor: "secondary", size: "sm", onClick: handleCancel, children: "Cancel" }), buttons.length > 1 ? (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 } }) : undefined, buttons.map(({ label, value, variant = "solid", themeColor = "attention" }, index) => {
|
|
111
|
+
return ((0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: variant, themeColor: themeColor, size: "sm", type: "submit", onClick: () => {
|
|
112
|
+
handleOk(value);
|
|
113
|
+
}, children: label }, index));
|
|
114
|
+
})] }) }))] }));
|
|
115
|
+
};
|
|
116
|
+
exports.ConfirmationModalContextProvider = ConfirmationModalContextProvider;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Dialog = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const Dialog_module_scss_1 = __importDefault(require("./Dialog.module.scss"));
|
|
9
|
+
const TextNative_1 = require("../Text/TextNative");
|
|
10
|
+
const ModalDialogNative_1 = require("./ModalDialogNative");
|
|
11
|
+
/**
|
|
12
|
+
* Dialog component that is customizable with action buttons. The children prop accepts React elements.
|
|
13
|
+
*
|
|
14
|
+
* Note that clicking outside of the dialog or pressing Escape will call the onClose function.
|
|
15
|
+
* Thus, if you want to stop that from firing, do so in the onClose function from outside.
|
|
16
|
+
*/
|
|
17
|
+
const Dialog = ({ title, description, children, isOpen, onClose, buttons, }) => {
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)(ModalDialogNative_1.ModalDialog, { onClose: onClose, isInitiallyOpen: isOpen, title: title, children: [(0, jsx_runtime_1.jsxs)("div", { className: Dialog_module_scss_1.default.dialogContent, children: [(0, jsx_runtime_1.jsx)("div", { id: "dialogDesc", children: (0, jsx_runtime_1.jsx)(TextNative_1.Text, { children: description }) }), children] }), !!buttons && (0, jsx_runtime_1.jsx)("footer", { className: Dialog_module_scss_1.default.dialogActions, children: buttons })] }));
|
|
19
|
+
};
|
|
20
|
+
exports.Dialog = Dialog;
|
|
@@ -18,8 +18,8 @@ const NavPanelNative_1 = require("../NavPanel/NavPanelNative");
|
|
|
18
18
|
exports.defaultProps = {
|
|
19
19
|
iconHorizontalExpanded: "chevronleft",
|
|
20
20
|
iconHorizontalCollapsed: "chevronright",
|
|
21
|
-
iconVerticalExpanded: "
|
|
22
|
-
iconVerticalCollapsed: "
|
|
21
|
+
iconVerticalExpanded: "chevrondown",
|
|
22
|
+
iconVerticalCollapsed: "chevronright",
|
|
23
23
|
};
|
|
24
24
|
const NavGroupContext = (0, react_1.createContext)({
|
|
25
25
|
level: -1,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.nestedAppComponentRenderer = exports.NestedAppMd = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const NestedApp_module_scss_1 = __importDefault(require("./NestedApp.module.scss"));
|
|
9
|
+
const ComponentDefs_1 = require("../../abstractions/ComponentDefs");
|
|
10
|
+
const renderers_1 = require("../../components-core/renderers");
|
|
11
|
+
const themeVars_1 = require("../../components-core/theming/themeVars");
|
|
12
|
+
const NestedAppNative_1 = require("./NestedAppNative");
|
|
13
|
+
const COMP = "NestedApp";
|
|
14
|
+
exports.NestedAppMd = (0, ComponentDefs_1.createMetadata)({
|
|
15
|
+
description: `The ${COMP} component allows you to nest an entire xmlui app into another one.
|
|
16
|
+
`,
|
|
17
|
+
props: {
|
|
18
|
+
app: {
|
|
19
|
+
description: "The source markup of the app to be nested",
|
|
20
|
+
},
|
|
21
|
+
api: {
|
|
22
|
+
description: "This property defines an optional emulated API to be used with the nested app.",
|
|
23
|
+
},
|
|
24
|
+
components: {
|
|
25
|
+
description: "This property defines an optional list of components to be used with the nested app.",
|
|
26
|
+
},
|
|
27
|
+
config: {
|
|
28
|
+
description: "You can define the nested app's configuration with this property.",
|
|
29
|
+
},
|
|
30
|
+
activeTheme: {
|
|
31
|
+
description: "This property defines the active theme for the nested app.",
|
|
32
|
+
},
|
|
33
|
+
activeTone: {
|
|
34
|
+
description: "This property defines the active tone for the nested app.",
|
|
35
|
+
},
|
|
36
|
+
title: {
|
|
37
|
+
description: "The title of the nested app.",
|
|
38
|
+
},
|
|
39
|
+
height: {
|
|
40
|
+
description: "The height of the nested app.",
|
|
41
|
+
},
|
|
42
|
+
allowPlaygroundPopup: {
|
|
43
|
+
description: "This property defines whether the nested app can be opened in the xmlui playground.",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
themeVars: (0, themeVars_1.parseScssVar)(NestedApp_module_scss_1.default.themeVars),
|
|
47
|
+
defaultThemeVars: {
|
|
48
|
+
[`marginTop-${COMP}`]: "$space-3",
|
|
49
|
+
[`marginBottom-${COMP}`]: "$space-3",
|
|
50
|
+
[`padding-${COMP}`]: "$space-4",
|
|
51
|
+
[`paddingTop-${COMP}`]: "$space-3",
|
|
52
|
+
[`borderRadius-${COMP}`]: "$space-4",
|
|
53
|
+
[`backgroundColor-frame-${COMP}`]: "$color-primary-100",
|
|
54
|
+
[`gap-frame-${COMP}`]: "$space-4",
|
|
55
|
+
[`fontWeight-header-${COMP}`]: "$fontWeight-bold",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
exports.nestedAppComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.NestedAppMd, ({ node, extractValue }) => {
|
|
59
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
60
|
+
return ((0, jsx_runtime_1.jsx)(NestedAppNative_1.NestedApp, { app: (_a = node.props) === null || _a === void 0 ? void 0 : _a.app, api: extractValue((_b = node.props) === null || _b === void 0 ? void 0 : _b.api), components: extractValue((_c = node.props) === null || _c === void 0 ? void 0 : _c.components), config: extractValue((_d = node.props) === null || _d === void 0 ? void 0 : _d.config), activeTheme: extractValue((_e = node.props) === null || _e === void 0 ? void 0 : _e.activeTheme), activeTone: extractValue((_f = node.props) === null || _f === void 0 ? void 0 : _f.activeTone), title: extractValue((_g = node.props) === null || _g === void 0 ? void 0 : _g.title), height: extractValue((_h = node.props) === null || _h === void 0 ? void 0 : _h.height), allowPlaygroundPopup: extractValue.asOptionalBoolean((_j = node.props) === null || _j === void 0 ? void 0 : _j.allowPlaygroundPopup) }));
|
|
61
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NestedApp = NestedApp;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const client_1 = __importDefault(require("react-dom/client"));
|
|
10
|
+
const NestedApp_module_scss_1 = __importDefault(require("./NestedApp.module.scss"));
|
|
11
|
+
const AppRoot_1 = require("../../components-core/rendering/AppRoot");
|
|
12
|
+
const lia_1 = require("react-icons/lia");
|
|
13
|
+
const rx_1 = require("react-icons/rx");
|
|
14
|
+
const xmlui_parser_1 = require("../../components-core/xmlui-parser");
|
|
15
|
+
const ApiInterceptorProvider_1 = require("../../components-core/interception/ApiInterceptorProvider");
|
|
16
|
+
const ErrorBoundary_1 = require("../../components-core/rendering/ErrorBoundary");
|
|
17
|
+
const browser_1 = require("msw/browser");
|
|
18
|
+
const Tooltip_1 = require("./Tooltip");
|
|
19
|
+
const ThemeContext_1 = require("../../components-core/theming/ThemeContext");
|
|
20
|
+
const constants_1 = require("../../components-core/constants");
|
|
21
|
+
function NestedApp({ api, app, components = constants_1.EMPTY_ARRAY, config, activeTheme, activeTone, title, height, allowPlaygroundPopup = true, }) {
|
|
22
|
+
const rootRef = (0, react_1.useRef)(null);
|
|
23
|
+
const shadowRef = (0, react_1.useRef)(null);
|
|
24
|
+
const contentRootRef = (0, react_1.useRef)(null);
|
|
25
|
+
const nestedAppId = (0, react_1.useId)();
|
|
26
|
+
const [refreshVersion, setRefreshVersion] = (0, react_1.useState)(0);
|
|
27
|
+
const theme = (0, ThemeContext_1.useTheme)();
|
|
28
|
+
const toneToApply = activeTone || (config === null || config === void 0 ? void 0 : config.defaultTone) || (theme === null || theme === void 0 ? void 0 : theme.activeThemeTone);
|
|
29
|
+
const apiWorker = (0, react_1.useMemo)(() => {
|
|
30
|
+
if (typeof document !== "undefined") {
|
|
31
|
+
return (0, browser_1.setupWorker)();
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
34
|
+
(0, react_1.useEffect)(() => {
|
|
35
|
+
apiWorker === null || apiWorker === void 0 ? void 0 : apiWorker.start({
|
|
36
|
+
onUnhandledRequest: "bypass",
|
|
37
|
+
quiet: true,
|
|
38
|
+
});
|
|
39
|
+
return () => apiWorker === null || apiWorker === void 0 ? void 0 : apiWorker.stop();
|
|
40
|
+
}, [apiWorker]);
|
|
41
|
+
// console.log("apiWorker", apiWorker);
|
|
42
|
+
const mock = (0, react_1.useMemo)(() => {
|
|
43
|
+
return api
|
|
44
|
+
? Object.assign(Object.assign({ type: "in-memory" }, api), { apiUrl: "/api" }) : undefined;
|
|
45
|
+
}, [api]);
|
|
46
|
+
//console.log("mock", mock);
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
48
|
+
var _a;
|
|
49
|
+
if (!shadowRef.current && rootRef.current) {
|
|
50
|
+
// Clone existing style and link tags
|
|
51
|
+
shadowRef.current = rootRef.current.attachShadow({ mode: "open" });
|
|
52
|
+
const styleSheets = document.querySelectorAll('style, link[rel="stylesheet"]');
|
|
53
|
+
styleSheets.forEach((el) => {
|
|
54
|
+
if (el.hasAttribute("data-theme-root")) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
shadowRef.current.appendChild(el.cloneNode(true));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (!contentRootRef.current && shadowRef.current) {
|
|
61
|
+
contentRootRef.current = client_1.default.createRoot(shadowRef.current);
|
|
62
|
+
}
|
|
63
|
+
let { errors, component, erroneousCompoundComponentName } = (0, xmlui_parser_1.xmlUiMarkupToComponent)(`<Fragment xmlns:XMLUIExtensions="component-ns">${app}</Fragment>`);
|
|
64
|
+
if (errors.length > 0) {
|
|
65
|
+
component = (0, xmlui_parser_1.errReportComponent)(errors, "Main.xmlui", erroneousCompoundComponentName);
|
|
66
|
+
}
|
|
67
|
+
const compoundComponents = (components !== null && components !== void 0 ? components : []).map((src) => {
|
|
68
|
+
const isErrorReportComponent = typeof src !== "string";
|
|
69
|
+
if (isErrorReportComponent) {
|
|
70
|
+
return src;
|
|
71
|
+
}
|
|
72
|
+
let { errors, component, erroneousCompoundComponentName } = (0, xmlui_parser_1.xmlUiMarkupToComponent)(src);
|
|
73
|
+
if (errors.length > 0) {
|
|
74
|
+
return (0, xmlui_parser_1.errReportComponent)(errors, `nested xmlui`, erroneousCompoundComponentName);
|
|
75
|
+
}
|
|
76
|
+
return component;
|
|
77
|
+
});
|
|
78
|
+
let globalProps = Object.assign(Object.assign({ name: config === null || config === void 0 ? void 0 : config.name }, ((config === null || config === void 0 ? void 0 : config.appGlobals) || {})), { apiUrl: "" });
|
|
79
|
+
// css variables are leaking into to shadow dom, so we reset them here
|
|
80
|
+
const themeVarReset = {};
|
|
81
|
+
Object.keys(theme.themeStyles).forEach((key) => {
|
|
82
|
+
themeVarReset[key] = "initial";
|
|
83
|
+
});
|
|
84
|
+
(_a = contentRootRef.current) === null || _a === void 0 ? void 0 : _a.render((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { node: component, children: (0, jsx_runtime_1.jsx)(ApiInterceptorProvider_1.ApiInterceptorProvider, { interceptor: mock, apiWorker: apiWorker, children: (0, jsx_runtime_1.jsxs)("div", { className: NestedApp_module_scss_1.default.nestedAppContainer, children: [(0, jsx_runtime_1.jsxs)("div", { className: NestedApp_module_scss_1.default.header, children: [(0, jsx_runtime_1.jsx)("span", { className: NestedApp_module_scss_1.default.headerText, children: title }), (0, jsx_runtime_1.jsx)("div", { className: NestedApp_module_scss_1.default.spacer }), allowPlaygroundPopup && ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { trigger: (0, jsx_runtime_1.jsx)("button", { className: NestedApp_module_scss_1.default.headerButton, onClick: () => {
|
|
85
|
+
// TODO: Open the app in a new window
|
|
86
|
+
}, children: (0, jsx_runtime_1.jsx)(rx_1.RxOpenInNewWindow, {}) }), label: "Edit code in new window" })), (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { trigger: (0, jsx_runtime_1.jsx)("button", { className: NestedApp_module_scss_1.default.headerButton, onClick: () => {
|
|
87
|
+
setRefreshVersion(refreshVersion + 1);
|
|
88
|
+
}, children: (0, jsx_runtime_1.jsx)(lia_1.LiaUndoAltSolid, {}) }), label: "Reset the app" })] }), (0, jsx_runtime_1.jsx)("div", { style: Object.assign({ height }, themeVarReset), children: (0, jsx_runtime_1.jsx)(AppRoot_1.AppRoot, { previewMode: true, standalone: true, trackContainerHeight: height ? "fixed" : "auto", node: component, globalProps: globalProps, defaultTheme: activeTheme || (config === null || config === void 0 ? void 0 : config.defaultTheme), defaultTone: toneToApply, contributes: {
|
|
89
|
+
compoundComponents,
|
|
90
|
+
themes: config === null || config === void 0 ? void 0 : config.themes,
|
|
91
|
+
}, resources: config === null || config === void 0 ? void 0 : config.resources }, `app-${nestedAppId}-${refreshVersion}`) })] }) }) }));
|
|
92
|
+
}, [
|
|
93
|
+
activeTheme,
|
|
94
|
+
allowPlaygroundPopup,
|
|
95
|
+
apiWorker,
|
|
96
|
+
app,
|
|
97
|
+
components,
|
|
98
|
+
config === null || config === void 0 ? void 0 : config.appGlobals,
|
|
99
|
+
config === null || config === void 0 ? void 0 : config.defaultTheme,
|
|
100
|
+
config === null || config === void 0 ? void 0 : config.name,
|
|
101
|
+
config === null || config === void 0 ? void 0 : config.resources,
|
|
102
|
+
config === null || config === void 0 ? void 0 : config.themes,
|
|
103
|
+
height,
|
|
104
|
+
mock,
|
|
105
|
+
nestedAppId,
|
|
106
|
+
refreshVersion,
|
|
107
|
+
theme.themeStyles,
|
|
108
|
+
title,
|
|
109
|
+
toneToApply,
|
|
110
|
+
]);
|
|
111
|
+
(0, react_1.useEffect)(() => {
|
|
112
|
+
return () => {
|
|
113
|
+
var _a;
|
|
114
|
+
(_a = contentRootRef.current) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
115
|
+
contentRootRef.current = null;
|
|
116
|
+
};
|
|
117
|
+
}, []);
|
|
118
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: NestedApp_module_scss_1.default.nestedApp, children: (0, jsx_runtime_1.jsx)("div", { ref: rootRef, style: {
|
|
119
|
+
width: "100%",
|
|
120
|
+
height: "100%",
|
|
121
|
+
overflow: "auto",
|
|
122
|
+
position: "relative",
|
|
123
|
+
isolation: "isolate",
|
|
124
|
+
} }) }));
|
|
125
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Tooltip = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
const RadixTooltip = __importStar(require("@radix-ui/react-tooltip"));
|
|
42
|
+
const Tooltip_module_scss_1 = __importDefault(require("./Tooltip.module.scss"));
|
|
43
|
+
const Tooltip = ({ trigger, label }) => {
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(RadixTooltip.Provider, { children: (0, jsx_runtime_1.jsxs)(RadixTooltip.Root, { children: [(0, jsx_runtime_1.jsx)(RadixTooltip.Trigger, { asChild: true, children: trigger }), (0, jsx_runtime_1.jsx)(RadixTooltip.Portal, { children: (0, jsx_runtime_1.jsx)(RadixTooltip.Content, { side: "bottom", align: "start", className: Tooltip_module_scss_1.default.TooltipContent, children: label }) })] }) }));
|
|
45
|
+
};
|
|
46
|
+
exports.Tooltip = Tooltip;
|
|
@@ -33,6 +33,9 @@ exports.NumberBoxMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
33
33
|
startIcon: (0, metadata_helpers_1.dStartIcon)(),
|
|
34
34
|
endText: (0, metadata_helpers_1.dEndText)(),
|
|
35
35
|
endIcon: (0, metadata_helpers_1.dEndIcon)(),
|
|
36
|
+
gap: {
|
|
37
|
+
description: "This property defines the gap between the adornments and the input area.",
|
|
38
|
+
},
|
|
36
39
|
hasSpinBox: {
|
|
37
40
|
description: `This boolean prop shows (\`true\`) or hides (\`false\`) the spinner buttons for the input field.`,
|
|
38
41
|
valueType: "boolean",
|
|
@@ -73,5 +76,5 @@ exports.NumberBoxMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
73
76
|
themeVars: (0, themeVars_1.parseScssVar)(NumberBox_module_scss_1.default.themeVars),
|
|
74
77
|
});
|
|
75
78
|
exports.numberBoxComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.NumberBoxMd, ({ node, state, updateState, lookupEventHandler, extractValue, layoutCss, registerComponentApi, }) => {
|
|
76
|
-
return ((0, jsx_runtime_1.jsx)(NumberBoxNative_1.NumberBox, { style: layoutCss, value: state === null || state === void 0 ? void 0 : state.value, initialValue: extractValue.asOptionalString(node.props.initialValue), step: extractValue(node.props.step), enabled: extractValue.asOptionalBoolean(node.props.enabled), placeholder: extractValue.asOptionalString(node.props.placeholder), validationStatus: extractValue(node.props.validationStatus), updateState: updateState, onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), registerComponentApi: registerComponentApi, hasSpinBox: extractValue.asOptionalBoolean(node.props.hasSpinBox), integersOnly: extractValue.asOptionalBoolean(node.props.integersOnly), zeroOrPositive: extractValue.asOptionalBoolean(node.props.zeroOrPositive), min: extractValue.asOptionalNumber(node.props.minValue), max: extractValue.asOptionalNumber(node.props.maxValue), startText: extractValue.asOptionalString(node.props.startText), startIcon: extractValue.asOptionalString(node.props.startIcon), endText: extractValue.asOptionalString(node.props.endText), endIcon: extractValue.asOptionalString(node.props.endIcon), autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), readOnly: extractValue.asOptionalBoolean(node.props.readOnly), maxLength: extractValue(node.props.maxLength), label: extractValue(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak), required: extractValue.asOptionalBoolean(node.props.required) }));
|
|
79
|
+
return ((0, jsx_runtime_1.jsx)(NumberBoxNative_1.NumberBox, { style: layoutCss, value: state === null || state === void 0 ? void 0 : state.value, initialValue: extractValue.asOptionalString(node.props.initialValue), step: extractValue(node.props.step), enabled: extractValue.asOptionalBoolean(node.props.enabled), placeholder: extractValue.asOptionalString(node.props.placeholder), validationStatus: extractValue(node.props.validationStatus), updateState: updateState, onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), registerComponentApi: registerComponentApi, hasSpinBox: extractValue.asOptionalBoolean(node.props.hasSpinBox), integersOnly: extractValue.asOptionalBoolean(node.props.integersOnly), zeroOrPositive: extractValue.asOptionalBoolean(node.props.zeroOrPositive), min: extractValue.asOptionalNumber(node.props.minValue), max: extractValue.asOptionalNumber(node.props.maxValue), startText: extractValue.asOptionalString(node.props.startText), startIcon: extractValue.asOptionalString(node.props.startIcon), endText: extractValue.asOptionalString(node.props.endText), gap: extractValue.asOptionalString(node.props.gap), endIcon: extractValue.asOptionalString(node.props.endIcon), autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), readOnly: extractValue.asOptionalBoolean(node.props.readOnly), maxLength: extractValue(node.props.maxLength), label: extractValue(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak), required: extractValue.asOptionalBoolean(node.props.required) }));
|
|
77
80
|
});
|
|
@@ -48,7 +48,7 @@ const IconNative_1 = require("../Icon/IconNative");
|
|
|
48
48
|
const InputAdornment_1 = require("../Input/InputAdornment");
|
|
49
49
|
const ButtonNative_1 = require("../Button/ButtonNative");
|
|
50
50
|
const ItemWithLabel_1 = require("../FormItem/ItemWithLabel");
|
|
51
|
-
exports.NumberBox = (0, react_1.forwardRef)(function NumberBox({ id, value, initialValue, style, enabled = true, placeholder, validationStatus = "none", hasSpinBox = true, step, integersOnly = false, zeroOrPositive = false, min = zeroOrPositive ? 0 : -numberbox_abstractions_1.NUMBERBOX_MAX_VALUE, max = numberbox_abstractions_1.NUMBERBOX_MAX_VALUE, maxLength, updateState = constants_1.noop, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, registerComponentApi, startText, startIcon, endText, endIcon, autoFocus, readOnly, required, label, labelPosition, labelWidth, labelBreak, }, forwardedRef) {
|
|
51
|
+
exports.NumberBox = (0, react_1.forwardRef)(function NumberBox({ id, value, initialValue, style, enabled = true, placeholder, validationStatus = "none", hasSpinBox = true, step, integersOnly = false, zeroOrPositive = false, min = zeroOrPositive ? 0 : -numberbox_abstractions_1.NUMBERBOX_MAX_VALUE, max = numberbox_abstractions_1.NUMBERBOX_MAX_VALUE, maxLength, updateState = constants_1.noop, onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, registerComponentApi, startText, startIcon, endText, endIcon, gap, autoFocus, readOnly, required, label, labelPosition, labelWidth, labelBreak, }, forwardedRef) {
|
|
52
52
|
var _a;
|
|
53
53
|
// Ensure the provided minimum is not smaller than the 0 if zeroOrPositive is set to true
|
|
54
54
|
min = Math.max(zeroOrPositive ? 0 : -numberbox_abstractions_1.NUMBERBOX_MAX_VALUE, min);
|
|
@@ -288,7 +288,7 @@ exports.NumberBox = (0, react_1.forwardRef)(function NumberBox({ id, value, init
|
|
|
288
288
|
}), tabIndex: -1, onFocus: () => {
|
|
289
289
|
var _a;
|
|
290
290
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
291
|
-
}, children: [(0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { text: startText, iconName: startIcon, className: NumberBox_module_scss_1.default.adornment }), (0, jsx_runtime_1.jsx)("input", { id: id, type: "text", inputMode: "numeric", className: (0, classnames_1.default)(NumberBox_module_scss_1.default.input, { [NumberBox_module_scss_1.default.readOnly]: readOnly }), disabled: !enabled, value: valueStrRep, step: step, placeholder: placeholder, onChange: onInputChange, onFocus: handleOnFocus, onBlur: handleOnBlur, onBeforeInput: handleOnBeforeInput, onKeyDown: handleOnKey, readOnly: readOnly, ref: inputRef, autoFocus: autoFocus, maxLength: maxLength, required: required }), (0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { text: endText, iconName: endIcon, className: NumberBox_module_scss_1.default.adornment }), hasSpinBox && ((0, jsx_runtime_1.jsxs)("div", { className: NumberBox_module_scss_1.default.spinnerBox, children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { "data-spinner": "up", type: "button", variant: "ghost", themeColor: "secondary", tabIndex: -1, className: NumberBox_module_scss_1.default.spinnerButton, disabled: !enabled || readOnly, ref: upButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.Icon, { name: "chevronup", size: "sm" }) }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { "data-spinner": "down", type: "button", tabIndex: -1, variant: "ghost", themeColor: "secondary", className: NumberBox_module_scss_1.default.spinnerButton, disabled: !enabled || readOnly, ref: downButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.Icon, { name: "chevrondown", size: "sm" }) })] }))] }) }));
|
|
291
|
+
}, style: { gap }, children: [(0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { text: startText, iconName: startIcon, className: NumberBox_module_scss_1.default.adornment }), (0, jsx_runtime_1.jsx)("input", { id: id, type: "text", inputMode: "numeric", className: (0, classnames_1.default)(NumberBox_module_scss_1.default.input, { [NumberBox_module_scss_1.default.readOnly]: readOnly }), disabled: !enabled, value: valueStrRep, step: step, placeholder: placeholder, onChange: onInputChange, onFocus: handleOnFocus, onBlur: handleOnBlur, onBeforeInput: handleOnBeforeInput, onKeyDown: handleOnKey, readOnly: readOnly, ref: inputRef, autoFocus: autoFocus, maxLength: maxLength, required: required }), (0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { text: endText, iconName: endIcon, className: NumberBox_module_scss_1.default.adornment }), hasSpinBox && ((0, jsx_runtime_1.jsxs)("div", { className: NumberBox_module_scss_1.default.spinnerBox, children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { "data-spinner": "up", type: "button", variant: "ghost", themeColor: "secondary", tabIndex: -1, className: NumberBox_module_scss_1.default.spinnerButton, disabled: !enabled || readOnly, ref: upButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.Icon, { name: "chevronup", size: "sm" }) }), (0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { "data-spinner": "down", type: "button", tabIndex: -1, variant: "ghost", themeColor: "secondary", className: NumberBox_module_scss_1.default.spinnerButton, disabled: !enabled || readOnly, ref: downButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.Icon, { name: "chevrondown", size: "sm" }) })] }))] }) }));
|
|
292
292
|
});
|
|
293
293
|
function applyStep(valueStrRep, step, min, max, integersOnly) {
|
|
294
294
|
const currentValue = (0, numberbox_abstractions_1.toUsableNumber)(valueStrRep, integersOnly);
|
|
@@ -6,7 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const ComponentDefs_1 = require("../../abstractions/ComponentDefs");
|
|
7
7
|
const renderers_1 = require("../../components-core/renderers");
|
|
8
8
|
const metadata_helpers_1 = require("../metadata-helpers");
|
|
9
|
-
const OptionTypeProvider_1 = require("
|
|
9
|
+
const OptionTypeProvider_1 = require("./OptionTypeProvider");
|
|
10
10
|
const container_helpers_1 = require("../container-helpers");
|
|
11
11
|
const COMP = "Option";
|
|
12
12
|
exports.OptionMd = (0, ComponentDefs_1.createMetadata)({
|
|
@@ -21,6 +21,7 @@ exports.OptionMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
21
21
|
enabled: (0, metadata_helpers_1.dEnabled)(),
|
|
22
22
|
optionTemplate: (0, ComponentDefs_1.d)("This property is used to define a custom option template"),
|
|
23
23
|
},
|
|
24
|
+
childrenAsTemplate: "optionTemplate",
|
|
24
25
|
});
|
|
25
26
|
const OptionNative = (0, react_1.memo)((props) => {
|
|
26
27
|
const OptionType = (0, OptionTypeProvider_1.useOptionType)();
|
|
@@ -34,5 +35,5 @@ exports.optionComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP,
|
|
|
34
35
|
const optionTemplate = node.props.optionTemplate;
|
|
35
36
|
return ((0, jsx_runtime_1.jsx)(OptionNative, { optionRenderer: optionTemplate
|
|
36
37
|
? (contextVars) => ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: optionTemplate, renderChild: renderChild, contextVars: contextVars, layoutContext: layoutContext }))
|
|
37
|
-
: undefined, value: extractValue(node.props.value), label: extractValue.asOptionalString(node.props.label) ||
|
|
38
|
+
: undefined, value: extractValue(node.props.value), label: extractValue.asOptionalString(node.props.label) || extractValue(node.props.value), enabled: extractValue.asOptionalBoolean(node.props.enabled), style: layoutCss }));
|
|
38
39
|
});
|
|
@@ -83,7 +83,9 @@ exports.SelectMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
83
83
|
},
|
|
84
84
|
});
|
|
85
85
|
exports.selectComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.SelectMd, ({ node, state, updateState, extractValue, renderChild, lookupEventHandler, layoutCss, registerComponentApi, }) => {
|
|
86
|
-
|
|
86
|
+
const multiSelect = extractValue.asOptionalBoolean(node.props.multiSelect);
|
|
87
|
+
const searchable = extractValue.asOptionalBoolean(node.props.searchable);
|
|
88
|
+
return ((0, jsx_runtime_1.jsx)(SelectNative_1.Select, { multiSelect: multiSelect, style: layoutCss, inProgress: extractValue.asOptionalBoolean(node.props.inProgress), inProgressNotificationMessage: extractValue.asOptionalString(node.props.inProgressNotificationMessage), readOnly: extractValue.asOptionalBoolean(node.props.readOnly), updateState: updateState, searchable: searchable, initialValue: extractValue(node.props.initialValue), value: state === null || state === void 0 ? void 0 : state.value, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), enabled: extractValue.asOptionalBoolean(node.props.enabled), placeholder: extractValue.asOptionalString(node.props.placeholder), validationStatus: extractValue(node.props.validationStatus), onDidChange: lookupEventHandler("didChange"), onFocus: lookupEventHandler("gotFocus"), onBlur: lookupEventHandler("lostFocus"), registerComponentApi: registerComponentApi, emptyListTemplate: renderChild(node.props.emptyListTemplate), dropdownHeight: extractValue(node.props.dropdownHeight), label: extractValue(node.props.label), labelPosition: extractValue(node.props.labelPosition), labelWidth: extractValue(node.props.labelWidth), labelBreak: extractValue.asOptionalBoolean(node.props.labelBreak), required: extractValue.asOptionalBoolean(node.props.required), optionLabelRenderer: node.props.optionLabelTemplate
|
|
87
89
|
? (item) => {
|
|
88
90
|
return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: node.props.optionLabelTemplate, item: item, renderChild: renderChild }));
|
|
89
91
|
}
|
|
@@ -91,8 +93,8 @@ exports.selectComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP,
|
|
|
91
93
|
? (item, val, inTrigger) => {
|
|
92
94
|
return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: node.props.optionTemplate, item: item, contextVars: {
|
|
93
95
|
$selectedValue: val,
|
|
94
|
-
$inTrigger: inTrigger
|
|
95
|
-
}, renderChild: (...args) => ((0, jsx_runtime_1.jsx)(react_select_1.SelectItemText, { children: renderChild(...args) })) }));
|
|
96
|
+
$inTrigger: inTrigger,
|
|
97
|
+
}, renderChild: (...args) => multiSelect || searchable ? (renderChild(...args)) : ((0, jsx_runtime_1.jsx)(react_select_1.SelectItemText, { children: renderChild(...args) })) }));
|
|
96
98
|
}
|
|
97
99
|
: undefined, valueRenderer: node.props.valueTemplate
|
|
98
100
|
? (item, removeItem) => {
|