xmlui 0.9.12 → 0.9.14
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-dYrfbzdh.mjs → apiInterceptorWorker-B9XuRkxC.mjs} +1 -1
- package/dist/{index-Dh2MThrK.mjs → index-D82p1y9A.mjs} +600 -275
- package/dist/index.css +347 -318
- package/dist/scripts/src/components/Card/Card.js +17 -1
- package/dist/scripts/src/components/Card/CardNative.js +2 -3
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +2 -2
- package/dist/scripts/src/components/Form/FormNative.js +8 -2
- package/dist/scripts/src/components/Form/formActions.js +5 -4
- package/dist/scripts/src/components/FormItem/FormItemNative.js +16 -12
- package/dist/scripts/src/components/Markdown/Markdown.js +10 -8
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +13 -10
- package/dist/scripts/src/components/Option/Option.js +0 -1
- package/dist/scripts/src/components/Select/Select.js +3 -2
- package/dist/scripts/src/components/Select/SelectNative.js +1 -1
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +1 -1
- package/dist/scripts/src/components/SelectionStore/SelectionStoreNative.js +10 -7
- package/dist/scripts/src/components/Table/Table.js +7 -1
- package/dist/scripts/src/components/Table/TableNative.js +2 -1
- package/dist/scripts/src/components-core/LoaderComponent.js +14 -0
- package/dist/scripts/src/components-core/abstractions/containers.js +1 -0
- package/dist/scripts/src/components-core/loader/ApiLoader.js +4 -5
- package/dist/scripts/src/components-core/loader/DataLoader.js +4 -4
- package/dist/scripts/src/components-core/loader/ExternalDataLoader.js +4 -7
- package/dist/scripts/src/components-core/loader/Loader.js +23 -11
- package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +3 -3
- package/dist/scripts/src/components-core/loader/PageableLoader.js +14 -4
- package/dist/scripts/src/components-core/rendering/reducer.js +9 -3
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +2 -2
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +10 -2
- package/dist/style.css +347 -318
- package/dist/xmlui-metadata.mjs +236 -175
- package/dist/xmlui-metadata.umd.js +236 -175
- package/dist/xmlui-standalone.umd.js +5197 -3030
- package/dist/xmlui.d.ts +45 -1
- package/dist/xmlui.mjs +2 -1
- package/package.json +2 -2
|
@@ -26,6 +26,11 @@ exports.CardMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
26
26
|
valueType: "boolean",
|
|
27
27
|
defaultValue: CardNative_1.defaultProps.showAvatar,
|
|
28
28
|
},
|
|
29
|
+
avatarSize: {
|
|
30
|
+
description: `This prop sets the size of the avatar. The default value is \`sm\`.`,
|
|
31
|
+
availableValues: ["xs", "sm", "md", "lg"],
|
|
32
|
+
valueType: "string",
|
|
33
|
+
},
|
|
29
34
|
title: {
|
|
30
35
|
description: `This prop sets the prestyled title.`,
|
|
31
36
|
valueType: "string",
|
|
@@ -58,10 +63,21 @@ exports.CardMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
58
63
|
[`borderRadius-${COMP}`]: "$borderRadius",
|
|
59
64
|
[`boxShadow-${COMP}`]: "none",
|
|
60
65
|
[`backgroundColor-${COMP}`]: "$color-surface-raised",
|
|
66
|
+
[`gap-${COMP}`]: "var(--stack-gap-default)",
|
|
67
|
+
[`gap-title-${COMP}`]: "$gap-normal",
|
|
68
|
+
[`gap-avatar-${COMP}`]: "$gap-normal",
|
|
69
|
+
[`verticalAlignment-title-${COMP}`]: "center",
|
|
61
70
|
},
|
|
71
|
+
themeVarDescriptions: {
|
|
72
|
+
[`gap-${COMP}`]: "The gap between the component's children.",
|
|
73
|
+
[`gap-title-${COMP}`]: "The gap between the title and the subtitle",
|
|
74
|
+
[`gap-avatar-${COMP}`]: "The gap between the avatar and the title panel",
|
|
75
|
+
[`horizontalAlignment-title-${COMP}`]: "The horizontal alignment of panel with the title and subtitle",
|
|
76
|
+
[`verticalAlignment-title-${COMP}`]: "The vertical alignment of the title and subtitle to the avatar",
|
|
77
|
+
}
|
|
62
78
|
});
|
|
63
79
|
exports.cardComponentRenderer = (0, renderers_1.createComponentRenderer)("Card", exports.CardMd, ({ node, extractValue, renderChild, layoutCss }) => {
|
|
64
|
-
return ((0, jsx_runtime_1.jsx)(CardNative_1.Card, { style: layoutCss, title: extractValue.asOptionalString(node.props.title), linkTo: extractValue.asOptionalString(node.props.linkTo), subtitle: extractValue.asOptionalString(node.props.subtitle), avatarUrl: extractValue.asOptionalString(node.props.avatarUrl), showAvatar: extractValue.asOptionalBoolean(node.props.showAvatar), orientation: extractValue.asOptionalString(node.props.orientation), children: renderChild(node.children, {
|
|
80
|
+
return ((0, jsx_runtime_1.jsx)(CardNative_1.Card, { style: layoutCss, title: extractValue.asOptionalString(node.props.title), linkTo: extractValue.asOptionalString(node.props.linkTo), subtitle: extractValue.asOptionalString(node.props.subtitle), avatarUrl: extractValue.asOptionalString(node.props.avatarUrl), showAvatar: extractValue.asOptionalBoolean(node.props.showAvatar), avatarSize: extractValue.asOptionalString(node.props.avatarSize), orientation: extractValue.asOptionalString(node.props.orientation), children: renderChild(node.children, {
|
|
65
81
|
type: "Stack",
|
|
66
82
|
orientation: "vertical",
|
|
67
83
|
}) }));
|
|
@@ -11,13 +11,12 @@ const Card_module_scss_1 = __importDefault(require("./Card.module.scss"));
|
|
|
11
11
|
const AvatarNative_1 = require("../Avatar/AvatarNative");
|
|
12
12
|
const LinkNative_1 = require("../Link/LinkNative");
|
|
13
13
|
const HeadingNative_1 = require("../Heading/HeadingNative");
|
|
14
|
-
const StackNative_1 = require("../Stack/StackNative");
|
|
15
14
|
const TextNative_1 = require("../Text/TextNative");
|
|
16
15
|
exports.defaultProps = {
|
|
17
16
|
orientation: "vertical",
|
|
18
17
|
showAvatar: false,
|
|
19
18
|
};
|
|
20
|
-
exports.Card = (0, react_1.forwardRef)(function Card({ children, orientation = exports.defaultProps.orientation, style, title, subtitle, linkTo, avatarUrl, showAvatar = !!avatarUrl || exports.defaultProps.showAvatar, onClick, }, forwardedRef) {
|
|
19
|
+
exports.Card = (0, react_1.forwardRef)(function Card({ children, orientation = exports.defaultProps.orientation, style, title, subtitle, linkTo, avatarUrl, showAvatar = !!avatarUrl || exports.defaultProps.showAvatar, avatarSize, onClick, }, forwardedRef) {
|
|
21
20
|
const titleProps = {
|
|
22
21
|
level: "h2",
|
|
23
22
|
};
|
|
@@ -25,5 +24,5 @@ exports.Card = (0, react_1.forwardRef)(function Card({ children, orientation = e
|
|
|
25
24
|
[Card_module_scss_1.default.isClickable]: !!onClick,
|
|
26
25
|
[Card_module_scss_1.default.vertical]: orientation === "vertical",
|
|
27
26
|
[Card_module_scss_1.default.horizontal]: orientation === "horizontal",
|
|
28
|
-
}), style: style, onClick: onClick, children: [[title, subtitle, avatarUrl, showAvatar].some(Boolean) && ((0, jsx_runtime_1.jsxs)(
|
|
27
|
+
}), style: style, onClick: onClick, children: [[title, subtitle, avatarUrl, showAvatar].some(Boolean) && ((0, jsx_runtime_1.jsxs)("div", { className: Card_module_scss_1.default.avatarWrapper, children: [showAvatar && (0, jsx_runtime_1.jsx)(AvatarNative_1.Avatar, { url: avatarUrl, name: title, size: avatarSize }), (0, jsx_runtime_1.jsxs)("div", { className: Card_module_scss_1.default.titleWrapper, children: [linkTo ? (title ? ((0, jsx_runtime_1.jsx)(LinkNative_1.LocalLink, { to: linkTo + "", children: (0, jsx_runtime_1.jsx)(HeadingNative_1.Heading, Object.assign({}, titleProps, { children: title })) })) : null) : title ? ((0, jsx_runtime_1.jsx)(HeadingNative_1.Heading, Object.assign({}, titleProps, { children: title }))) : null, subtitle !== undefined && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(TextNative_1.Text, { variant: "small", children: subtitle }) }))] })] })), children] }));
|
|
29
28
|
});
|
|
@@ -176,12 +176,12 @@ exports.DatePicker = (0, react_1.forwardRef)(function DatePicker({ id, initialVa
|
|
|
176
176
|
setOpen(false);
|
|
177
177
|
}
|
|
178
178
|
}, [onDidChange, updateState, mode, dateFormat]);
|
|
179
|
-
return inline ? ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("div", { className: DatePicker_module_scss_1.default.inlinePickerMenu, children: (0, jsx_runtime_1.jsx)(react_day_picker_1.DayPicker, { fixedWeeks: true,
|
|
179
|
+
return inline ? ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("div", { className: DatePicker_module_scss_1.default.inlinePickerMenu, children: (0, jsx_runtime_1.jsx)(react_day_picker_1.DayPicker, { required: undefined, captionLayout: "dropdown", fixedWeeks: true, startMonth: startDate, endMonth: endDate, disabled: disabled, weekStartsOn: _weekStartsOn, showWeekNumber: showWeekNumber, showOutsideDays: true, classNames: DatePicker_module_scss_1.default, mode: mode === "single" ? "single" : "range", selected: selected, onSelect: handleSelect, autoFocus: !inline, numberOfMonths: mode === "range" ? 2 : 1 }) }) })) : ((0, jsx_runtime_1.jsxs)(ReactDropdownMenu.Root, { open: open, onOpenChange: setOpen, modal: false, children: [(0, jsx_runtime_1.jsx)(ReactDropdownMenu.Trigger, { asChild: true, children: (0, jsx_runtime_1.jsxs)("button", { disabled: !enabled, id: id, ref: ref, style: style, className: (0, classnames_1.default)(DatePicker_module_scss_1.default.datePicker, {
|
|
180
180
|
[DatePicker_module_scss_1.default.disabled]: !enabled,
|
|
181
181
|
[DatePicker_module_scss_1.default.error]: validationStatus === "error",
|
|
182
182
|
[DatePicker_module_scss_1.default.warning]: validationStatus === "warning",
|
|
183
183
|
[DatePicker_module_scss_1.default.valid]: validationStatus === "valid",
|
|
184
|
-
}), onFocus: handleOnButtonFocus, onBlur: handleOnButtonBlur, children: [(0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { text: startText, iconName: startIcon, className: DatePicker_module_scss_1.default.adornment }), (0, jsx_runtime_1.jsx)("div", { className: DatePicker_module_scss_1.default.datePickerValue, children: mode === "single" && selected ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, date_fns_1.format)(selected, dateFormat) })) : mode === "range" && typeof selected === "object" && selected.from ? (selected.to ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, date_fns_1.format)(selected.from, dateFormat), " - ", (0, date_fns_1.format)(selected.to, dateFormat)] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, date_fns_1.format)(selected.from, dateFormat) }))) : placeholder ? ((0, jsx_runtime_1.jsx)("span", { className: DatePicker_module_scss_1.default.placeholder, children: placeholder })) : ((0, jsx_runtime_1.jsx)("span", { children: "\u00A0" })) }), (0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { text: endText, iconName: endIcon, className: DatePicker_module_scss_1.default.adornment })] }) }), (0, jsx_runtime_1.jsx)(ReactDropdownMenu.Portal, { container: root, children: (0, jsx_runtime_1.jsx)(ReactDropdownMenu.Content, { align: "start", className: DatePicker_module_scss_1.default.datePickerMenu, onFocus: handleOnMenuFocus, onBlur: handleOnMenuBlur, onInteractOutside: handleOnMenuBlur, children: (0, jsx_runtime_1.jsx)(react_day_picker_1.DayPicker, { fixedWeeks: true,
|
|
184
|
+
}), onFocus: handleOnButtonFocus, onBlur: handleOnButtonBlur, children: [(0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { text: startText, iconName: startIcon, className: DatePicker_module_scss_1.default.adornment }), (0, jsx_runtime_1.jsx)("div", { className: DatePicker_module_scss_1.default.datePickerValue, children: mode === "single" && selected ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, date_fns_1.format)(selected, dateFormat) })) : mode === "range" && typeof selected === "object" && selected.from ? (selected.to ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, date_fns_1.format)(selected.from, dateFormat), " - ", (0, date_fns_1.format)(selected.to, dateFormat)] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, date_fns_1.format)(selected.from, dateFormat) }))) : placeholder ? ((0, jsx_runtime_1.jsx)("span", { className: DatePicker_module_scss_1.default.placeholder, children: placeholder })) : ((0, jsx_runtime_1.jsx)("span", { children: "\u00A0" })) }), (0, jsx_runtime_1.jsx)(InputAdornment_1.Adornment, { text: endText, iconName: endIcon, className: DatePicker_module_scss_1.default.adornment })] }) }), (0, jsx_runtime_1.jsx)(ReactDropdownMenu.Portal, { container: root, children: (0, jsx_runtime_1.jsx)(ReactDropdownMenu.Content, { align: "start", sideOffset: 5, className: DatePicker_module_scss_1.default.datePickerMenu, onFocus: handleOnMenuFocus, onBlur: handleOnMenuBlur, onInteractOutside: handleOnMenuBlur, children: (0, jsx_runtime_1.jsx)(react_day_picker_1.DayPicker, { required: undefined, fixedWeeks: true, classNames: DatePicker_module_scss_1.default, captionLayout: "dropdown", startMonth: startDate, endMonth: endDate, disabled: disabled, weekStartsOn: _weekStartsOn, showWeekNumber: showWeekNumber, showOutsideDays: true, mode: mode === "single" ? "single" : "range", selected: selected, onSelect: handleSelect, autoFocus: !inline, numberOfMonths: mode === "range" ? 2 : 1 }) }) })] }));
|
|
185
185
|
});
|
|
186
186
|
const isoRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/;
|
|
187
187
|
const parseISODate = (dateString) => {
|
|
@@ -140,7 +140,6 @@ const formReducer = (0, immer_1.default)((state, action) => {
|
|
|
140
140
|
break;
|
|
141
141
|
}
|
|
142
142
|
case formActions_1.FormActionKind.BACKEND_VALIDATION_ARRIVED: {
|
|
143
|
-
//console.log(state.validationResults[field]) //action.payload.fieldValidationResults
|
|
144
143
|
state.submitInProgress = false;
|
|
145
144
|
state.generalValidationResults = action.payload.generalValidationResults;
|
|
146
145
|
Object.keys(state.validationResults).forEach((key) => {
|
|
@@ -241,7 +240,14 @@ const Form = (0, react_2.forwardRef)(function ({ formState, dispatch, initialVal
|
|
|
241
240
|
const prevFocused = document.activeElement;
|
|
242
241
|
dispatch((0, formActions_1.formSubmitting)());
|
|
243
242
|
try {
|
|
244
|
-
|
|
243
|
+
// --- Remove the properties from formState.subject where the property name ends with UNBOUND_FIELD_SUFFIX
|
|
244
|
+
const filteredSubject = Object.entries(formState.subject).reduce((acc, [key, value]) => {
|
|
245
|
+
if (!key.endsWith(formActions_1.UNBOUND_FIELD_SUFFIX)) {
|
|
246
|
+
acc[key] = value;
|
|
247
|
+
}
|
|
248
|
+
return acc;
|
|
249
|
+
}, {});
|
|
250
|
+
yield (onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(filteredSubject, {
|
|
245
251
|
passAsDefaultBody: true,
|
|
246
252
|
}));
|
|
247
253
|
dispatch((0, formActions_1.formSubmitted)());
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormActionKind = void 0;
|
|
3
|
+
exports.FormActionKind = exports.UNBOUND_FIELD_SUFFIX = void 0;
|
|
4
4
|
exports.fieldInitialized = fieldInitialized;
|
|
5
5
|
exports.fieldChanged = fieldChanged;
|
|
6
6
|
exports.fieldFocused = fieldFocused;
|
|
@@ -12,6 +12,7 @@ exports.formSubmitting = formSubmitting;
|
|
|
12
12
|
exports.formSubmitted = formSubmitted;
|
|
13
13
|
exports.formReset = formReset;
|
|
14
14
|
exports.backendValidationArrived = backendValidationArrived;
|
|
15
|
+
exports.UNBOUND_FIELD_SUFFIX = "__UNBOUND_FIELD__";
|
|
15
16
|
var FormActionKind;
|
|
16
17
|
(function (FormActionKind) {
|
|
17
18
|
FormActionKind["FIELD_LOST_FOCUS"] = "FormActionKind:FIELD_LOST_FOCUS";
|
|
@@ -99,16 +100,16 @@ function formReset(originalSubject) {
|
|
|
99
100
|
return {
|
|
100
101
|
type: FormActionKind.RESET,
|
|
101
102
|
payload: {
|
|
102
|
-
originalSubject
|
|
103
|
+
originalSubject,
|
|
103
104
|
},
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
|
-
function backendValidationArrived({ generalValidationResults = [], fieldValidationResults = {} }) {
|
|
107
|
+
function backendValidationArrived({ generalValidationResults = [], fieldValidationResults = {}, }) {
|
|
107
108
|
return {
|
|
108
109
|
type: FormActionKind.BACKEND_VALIDATION_ARRIVED,
|
|
109
110
|
payload: {
|
|
110
111
|
generalValidationResults,
|
|
111
|
-
fieldValidationResults
|
|
112
|
+
fieldValidationResults,
|
|
112
113
|
},
|
|
113
114
|
};
|
|
114
115
|
}
|
|
@@ -47,32 +47,36 @@ exports.defaultProps = {
|
|
|
47
47
|
};
|
|
48
48
|
exports.FormItem = (0, react_1.memo)(function FormItem(_a) {
|
|
49
49
|
var { style, bindTo, type = exports.defaultProps.type, label, enabled = exports.defaultProps.enabled, labelPosition, labelWidth, labelBreak = exports.defaultProps.labelBreak, children, validations, onValidate, customValidationsDebounce = exports.defaultProps.customValidationsDebounce, validationMode, registerComponentApi, maxTextLength, inputRenderer } = _a, rest = __rest(_a, ["style", "bindTo", "type", "label", "enabled", "labelPosition", "labelWidth", "labelBreak", "children", "validations", "onValidate", "customValidationsDebounce", "validationMode", "registerComponentApi", "maxTextLength", "inputRenderer"]);
|
|
50
|
+
const defaultId = (0, react_1.useId)();
|
|
51
|
+
const [formItemId, setFormItemId] = (0, react_1.useState)(bindTo);
|
|
50
52
|
const labelWidthValue = (0, FormContext_1.useFormContextPart)((value) => labelWidth || value.itemLabelWidth);
|
|
51
53
|
const labelBreakValue = (0, FormContext_1.useFormContextPart)((value) => labelBreak !== undefined ? labelBreak : value.itemLabelBreak);
|
|
52
54
|
const labelPositionValue = (0, FormContext_1.useFormContextPart)((value) => labelPosition || value.itemLabelPosition || DEFAULT_LABEL_POSITIONS[type]);
|
|
53
|
-
const initialValueFromSubject = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value.originalSubject,
|
|
55
|
+
const initialValueFromSubject = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value.originalSubject, formItemId));
|
|
54
56
|
const initialValue = initialValueFromSubject === undefined ? rest.initialValue : initialValueFromSubject;
|
|
55
|
-
const value = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value.subject,
|
|
56
|
-
const validationResult = (0, FormContext_1.useFormContextPart)((value) => value.validationResults[
|
|
57
|
+
const value = (0, FormContext_1.useFormContextPart)((value) => (0, FormNative_1.getByPath)(value.subject, formItemId));
|
|
58
|
+
const validationResult = (0, FormContext_1.useFormContextPart)((value) => value.validationResults[formItemId]);
|
|
57
59
|
const dispatch = (0, FormContext_1.useFormContextPart)((value) => value.dispatch);
|
|
58
60
|
const formEnabled = (0, FormContext_1.useFormContextPart)((value) => value.enabled);
|
|
59
61
|
const isEnabled = enabled && formEnabled;
|
|
60
62
|
(0, react_1.useEffect)(() => {
|
|
61
|
-
|
|
63
|
+
const newId = bindTo || `${defaultId}${formActions_1.UNBOUND_FIELD_SUFFIX}`;
|
|
64
|
+
setFormItemId(newId);
|
|
65
|
+
dispatch((0, formActions_1.fieldInitialized)(newId, initialValue));
|
|
62
66
|
}, [bindTo, dispatch, initialValue]);
|
|
63
|
-
(0, Validations_1.useValidation)(validations, onValidate, value, dispatch,
|
|
67
|
+
(0, Validations_1.useValidation)(validations, onValidate, value, dispatch, formItemId, customValidationsDebounce);
|
|
64
68
|
const onStateChange = (0, react_1.useCallback)(({ value }, options) => {
|
|
65
69
|
//we already handled the initial value in the useEffect with fieldInitialized(...);
|
|
66
70
|
if (!(options === null || options === void 0 ? void 0 : options.initial)) {
|
|
67
|
-
dispatch((0, formActions_1.fieldChanged)(
|
|
71
|
+
dispatch((0, formActions_1.fieldChanged)(formItemId, value));
|
|
68
72
|
}
|
|
69
|
-
}, [
|
|
73
|
+
}, [formItemId, dispatch]);
|
|
70
74
|
(0, react_1.useEffect)(() => {
|
|
71
75
|
return () => {
|
|
72
|
-
dispatch((0, formActions_1.fieldRemoved)(
|
|
76
|
+
dispatch((0, formActions_1.fieldRemoved)(formItemId));
|
|
73
77
|
};
|
|
74
|
-
}, [
|
|
75
|
-
const { validationStatus, isHelperTextShown } = (0, Validations_1.useValidationDisplay)(
|
|
78
|
+
}, [formItemId, dispatch]);
|
|
79
|
+
const { validationStatus, isHelperTextShown } = (0, Validations_1.useValidationDisplay)(formItemId, value, validationResult, validationMode);
|
|
76
80
|
let formControl = null;
|
|
77
81
|
switch (type) {
|
|
78
82
|
case "select": {
|
|
@@ -150,10 +154,10 @@ exports.FormItem = (0, react_1.memo)(function FormItem(_a) {
|
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
156
|
const onFocus = (0, misc_1.useEvent)(() => {
|
|
153
|
-
dispatch((0, formActions_1.fieldFocused)(
|
|
157
|
+
dispatch((0, formActions_1.fieldFocused)(formItemId));
|
|
154
158
|
});
|
|
155
159
|
const onBlur = (0, misc_1.useEvent)(() => {
|
|
156
|
-
dispatch((0, formActions_1.fieldLostFocus)(
|
|
160
|
+
dispatch((0, formActions_1.fieldLostFocus)(formItemId));
|
|
157
161
|
});
|
|
158
162
|
const [animateContainerRef] = (0, react_2.useAutoAnimate)({ duration: 100 });
|
|
159
163
|
return ((0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, { labelPosition: labelPositionValue, label: label, labelWidth: labelWidthValue, labelBreak: labelBreakValue, enabled: isEnabled, required: validations.required, validationInProgress: validationResult === null || validationResult === void 0 ? void 0 : validationResult.partial, onFocus: onFocus, onBlur: onBlur, style: style, validationResult: (0, jsx_runtime_1.jsx)("div", { ref: animateContainerRef, children: isHelperTextShown &&
|
|
@@ -28,17 +28,19 @@ exports.MarkdownMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
28
28
|
defaultThemeVars: {
|
|
29
29
|
"backgroundColor-Admonition": "$color-warn-300",
|
|
30
30
|
"borderRadius-Admonition": "$space-4",
|
|
31
|
-
"iconSize-Admonition": "
|
|
32
|
-
"padding-Admonition": "
|
|
33
|
-
"marginBottom-Admonition": "
|
|
34
|
-
"marginLeft-Admonition-content": "
|
|
31
|
+
"iconSize-Admonition": "$space-6",
|
|
32
|
+
"padding-Admonition": "$space-4",
|
|
33
|
+
"marginBottom-Admonition": "$space-4",
|
|
34
|
+
"marginLeft-Admonition-content": "$space-2",
|
|
35
35
|
"backgroundColor-Blockquote": "$color-warn-200",
|
|
36
36
|
"accentWidth-Blockquote": "3px",
|
|
37
37
|
"accentColor-Blockquote": "$color-surface-500",
|
|
38
|
-
"padding-Blockquote": "
|
|
39
|
-
"marginBottom-Blockquote": "
|
|
40
|
-
"marginBottom-Text-codefence": "
|
|
41
|
-
"marginBottom-Text-markdown": "
|
|
38
|
+
"padding-Blockquote": "$space-2",
|
|
39
|
+
"marginBottom-Blockquote": "$space-4",
|
|
40
|
+
"marginBottom-Text-codefence": "$space-2",
|
|
41
|
+
"marginBottom-Text-markdown": "$space-2",
|
|
42
|
+
"marginTop-HtmlLi": "$space-2",
|
|
43
|
+
"marginBottom-HtmlLi": "$space-2",
|
|
42
44
|
light: {
|
|
43
45
|
// --- No light-specific theme vars
|
|
44
46
|
},
|
|
@@ -27,7 +27,6 @@ const HtmlTags_module_scss_1 = __importDefault(require("../HtmlTags/HtmlTags.mod
|
|
|
27
27
|
const HeadingNative_1 = require("../Heading/HeadingNative");
|
|
28
28
|
const TextNative_1 = require("../Text/TextNative");
|
|
29
29
|
const LinkNative_1 = require("../Link/LinkNative");
|
|
30
|
-
const ImageNative_1 = require("../Image/ImageNative");
|
|
31
30
|
const Toggle_1 = require("../Toggle/Toggle");
|
|
32
31
|
const ScriptingSourceTree_1 = require("../../abstractions/scripting/ScriptingSourceTree");
|
|
33
32
|
exports.Markdown = (0, react_1.memo)(function Markdown({ extractValue, removeIndents = true, children, style, }) {
|
|
@@ -44,6 +43,10 @@ exports.Markdown = (0, react_1.memo)(function Markdown({ extractValue, removeInd
|
|
|
44
43
|
var { children, node } = _a, props = __rest(_a, ["children", "node"]);
|
|
45
44
|
return (0, jsx_runtime_1.jsx)("video", Object.assign({ className: HtmlTags_module_scss_1.default.htmlVideo }, props, { children: children }));
|
|
46
45
|
},
|
|
46
|
+
img(_a) {
|
|
47
|
+
var { children, node } = _a, props = __rest(_a, ["children", "node"]);
|
|
48
|
+
return (0, jsx_runtime_1.jsx)("img", Object.assign({ className: HtmlTags_module_scss_1.default.htmlImage }, props, { children: children }));
|
|
49
|
+
},
|
|
47
50
|
h1({ children }) {
|
|
48
51
|
return (0, jsx_runtime_1.jsx)(HeadingNative_1.Heading, { level: "h1", children: children });
|
|
49
52
|
},
|
|
@@ -83,14 +86,17 @@ exports.Markdown = (0, react_1.memo)(function Markdown({ extractValue, removeInd
|
|
|
83
86
|
blockquote({ children }) {
|
|
84
87
|
return (0, jsx_runtime_1.jsx)(Blockquote, { children: children });
|
|
85
88
|
},
|
|
86
|
-
ol(
|
|
87
|
-
|
|
89
|
+
ol(_a) {
|
|
90
|
+
var { children, node } = _a, props = __rest(_a, ["children", "node"]);
|
|
91
|
+
return (0, jsx_runtime_1.jsx)("ol", Object.assign({ className: HtmlTags_module_scss_1.default.htmlOl }, props, { children: children }));
|
|
88
92
|
},
|
|
89
|
-
ul(
|
|
90
|
-
|
|
93
|
+
ul(_a) {
|
|
94
|
+
var { children, node } = _a, props = __rest(_a, ["children", "node"]);
|
|
95
|
+
return (0, jsx_runtime_1.jsx)("ul", Object.assign({ className: HtmlTags_module_scss_1.default.htmlUl }, props, { children: children }));
|
|
91
96
|
},
|
|
92
|
-
li(
|
|
93
|
-
|
|
97
|
+
li(_a) {
|
|
98
|
+
var { children, node } = _a, props = __rest(_a, ["children", "node"]);
|
|
99
|
+
return (0, jsx_runtime_1.jsx)("li", Object.assign({ className: HtmlTags_module_scss_1.default.htmlLi }, props, { children: children }));
|
|
94
100
|
},
|
|
95
101
|
hr() {
|
|
96
102
|
return (0, jsx_runtime_1.jsx)(HorizontalRule, {});
|
|
@@ -100,9 +106,6 @@ exports.Markdown = (0, react_1.memo)(function Markdown({ extractValue, removeInd
|
|
|
100
106
|
const allowedProps = ['style', 'disabled', 'active', 'icon', 'onClick'];
|
|
101
107
|
return ((0, jsx_runtime_1.jsx)(LinkNative_1.LocalLink, Object.assign({ to: href }, allowedProps, { children: children })));
|
|
102
108
|
},
|
|
103
|
-
img({ src, alt }) {
|
|
104
|
-
return (0, jsx_runtime_1.jsx)(ImageNative_1.Image, { src: src, alt: alt });
|
|
105
|
-
},
|
|
106
109
|
// TODO: somehow get the label from the containing li element
|
|
107
110
|
input({ disabled, checked }) {
|
|
108
111
|
return ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { variant: "checkbox", readOnly: disabled, value: checked }));
|
|
@@ -21,7 +21,6 @@ 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"
|
|
25
24
|
});
|
|
26
25
|
const OptionNative = (0, react_1.memo)((props) => {
|
|
27
26
|
const OptionType = (0, OptionTypeProvider_1.useOptionType)();
|
|
@@ -11,7 +11,8 @@ const renderers_1 = require("../../components-core/renderers");
|
|
|
11
11
|
const themeVars_1 = require("../../components-core/theming/themeVars");
|
|
12
12
|
const metadata_helpers_1 = require("../metadata-helpers");
|
|
13
13
|
const container_helpers_1 = require("../container-helpers");
|
|
14
|
-
const SelectNative_1 = require("
|
|
14
|
+
const SelectNative_1 = require("./SelectNative");
|
|
15
|
+
const react_select_1 = require("@radix-ui/react-select");
|
|
15
16
|
const COMP = "Select";
|
|
16
17
|
exports.SelectMd = (0, ComponentDefs_1.createMetadata)({
|
|
17
18
|
description: "Provides a dropdown with a list of options to choose from.",
|
|
@@ -88,7 +89,7 @@ exports.selectComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP,
|
|
|
88
89
|
}
|
|
89
90
|
: undefined, optionRenderer: node.props.optionTemplate
|
|
90
91
|
? (item) => {
|
|
91
|
-
return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: node.props.optionTemplate, item: item, renderChild: renderChild }));
|
|
92
|
+
return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: node.props.optionTemplate, item: item, renderChild: (...args) => ((0, jsx_runtime_1.jsx)(react_select_1.SelectItemText, { children: renderChild(...args) })) }));
|
|
92
93
|
}
|
|
93
94
|
: undefined, valueRenderer: node.props.valueTemplate
|
|
94
95
|
? (item, removeItem) => {
|
|
@@ -224,7 +224,7 @@ const SelectOption = react_1.default.forwardRef((option, ref) => {
|
|
|
224
224
|
return () => onOptionRemove(option);
|
|
225
225
|
}, [option, onOptionAdd, onOptionRemove]);
|
|
226
226
|
return ((0, jsx_runtime_1.jsx)(react_select_1.Item, { ref: ref, className: Select_module_scss_1.default.selectItem, value: value + "", disabled: !enabled, children: (0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectItemContent, children: optionRenderer ? (optionRenderer({
|
|
227
|
-
label
|
|
227
|
+
label,
|
|
228
228
|
value,
|
|
229
229
|
enabled,
|
|
230
230
|
})) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_select_1.ItemText, { className: Select_module_scss_1.default.selectItemContent, children: optionLabelRenderer ? optionLabelRenderer({ value, label }) : label }), (0, jsx_runtime_1.jsx)("span", { className: Select_module_scss_1.default.selectItemIndicator, children: (0, jsx_runtime_1.jsx)(react_select_1.ItemIndicator, { children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" }) }) })] })) }) }));
|
|
@@ -7,7 +7,7 @@ const renderers_1 = require("../../components-core/renderers");
|
|
|
7
7
|
const SelectionStoreNative_1 = require("./SelectionStoreNative");
|
|
8
8
|
const COMP = "SelectionStore";
|
|
9
9
|
exports.SelectionStoreMd = (0, ComponentDefs_1.createMetadata)({
|
|
10
|
-
status: "
|
|
10
|
+
status: "experimental",
|
|
11
11
|
description: `The \`${COMP}\` is a non-visual component that may wrap components (items) and manage ` +
|
|
12
12
|
`their selection state to accommodate the usage of other actions.`,
|
|
13
13
|
props: {
|
|
@@ -41,28 +41,31 @@ const lodash_es_1 = require("lodash-es");
|
|
|
41
41
|
const misc_1 = require("../../components-core/utils/misc");
|
|
42
42
|
const constants_1 = require("../../components-core/constants");
|
|
43
43
|
const EMPTY_SELECTION_STATE = {
|
|
44
|
-
value: constants_1.EMPTY_ARRAY
|
|
44
|
+
value: constants_1.EMPTY_ARRAY,
|
|
45
45
|
};
|
|
46
46
|
const StandaloneSelectionStore = ({ children }) => {
|
|
47
47
|
const [selection, setSelection] = (0, react_1.useState)(EMPTY_SELECTION_STATE);
|
|
48
|
-
return (0, jsx_runtime_1.jsx)(exports.SelectionStore, { updateState: setSelection, selectedItems: selection.value, children: children });
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(exports.SelectionStore, { updateState: setSelection, selectedItems: selection.value, children: children }));
|
|
49
49
|
};
|
|
50
50
|
exports.StandaloneSelectionStore = StandaloneSelectionStore;
|
|
51
51
|
const SelectionStore = ({ updateState = lodash_es_1.noop, idKey = "id", children, selectedItems = constants_1.EMPTY_ARRAY, registerComponentApi = lodash_es_1.noop, }) => {
|
|
52
52
|
const [items, setItems] = (0, react_1.useState)(selectedItems);
|
|
53
53
|
const valueInitializedRef = (0, react_1.useRef)(false);
|
|
54
54
|
const refreshSelection = (0, misc_1.useEvent)((allItems = constants_1.EMPTY_ARRAY) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const safeAllItems = allItems || constants_1.EMPTY_ARRAY;
|
|
56
|
+
const safeSelectedItems = selectedItems || constants_1.EMPTY_ARRAY;
|
|
57
|
+
setItems(safeAllItems);
|
|
58
|
+
let value = safeAllItems.filter((item) => !!safeSelectedItems.find((si) => si && item && si[idKey] === item[idKey]));
|
|
59
|
+
if (!(0, lodash_es_1.isEqual)(safeSelectedItems, value) || !valueInitializedRef.current) {
|
|
58
60
|
valueInitializedRef.current = true;
|
|
59
61
|
updateState({
|
|
60
|
-
value
|
|
62
|
+
value,
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
});
|
|
64
66
|
const setSelectedRowIds = (0, misc_1.useEvent)((rowIds) => {
|
|
65
|
-
|
|
67
|
+
const safeItems = items || constants_1.EMPTY_ARRAY;
|
|
68
|
+
updateState({ value: safeItems.filter((item) => rowIds.includes(item[idKey])) });
|
|
66
69
|
});
|
|
67
70
|
const clearSelection = (0, misc_1.useEvent)(() => {
|
|
68
71
|
setSelectedRowIds(constants_1.EMPTY_ARRAY);
|
|
@@ -74,6 +74,12 @@ exports.TableMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
74
74
|
valueType: "boolean",
|
|
75
75
|
defaultValue: false,
|
|
76
76
|
},
|
|
77
|
+
noBottomBorder: {
|
|
78
|
+
description: `This property indicates whether the table should have a bottom border. When set to ` +
|
|
79
|
+
`\`true\`, the table does not have a bottom border. Otherwise, it has a bottom border.`,
|
|
80
|
+
valueType: "boolean",
|
|
81
|
+
defaultValue: false,
|
|
82
|
+
}
|
|
77
83
|
},
|
|
78
84
|
events: {
|
|
79
85
|
sortingDidChange: (0, ComponentDefs_1.d)(`This event is fired when the table data sorting has changed. It has two arguments: ` +
|
|
@@ -175,7 +181,7 @@ const TableWithColumns = (0, react_1.forwardRef)(({ extractValue, node, renderCh
|
|
|
175
181
|
const tableContent = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TableContext_1.TableContext.Provider, { value: tableContextValue, children: renderChild(node.children) }, tableKey), (0, jsx_runtime_1.jsx)(TableContext_1.TableContext.Provider, { value: columnRefresherContextValue, children: renderChild(node.children) }), (0, jsx_runtime_1.jsx)(TableNative_1.Table, { ref: ref, data: data, columns: columns, pageSizes: extractValue(node.props.pageSizes), rowsSelectable: extractValue.asOptionalBoolean(node.props.rowsSelectable), registerComponentApi: registerComponentApi, noDataRenderer: node.props.noDataTemplate &&
|
|
176
182
|
(() => {
|
|
177
183
|
return renderChild(node.props.noDataTemplate);
|
|
178
|
-
}), hideNoDataView: node.props.noDataTemplate === null || node.props.noDataTemplate === "", loading: extractValue.asOptionalBoolean(node.props.loading), isPaginated: extractValue.asOptionalBoolean((_a = node.props) === null || _a === void 0 ? void 0 : _a.isPaginated), headerHeight: extractValue.asSize(node.props.headerHeight), rowDisabledPredicate: lookupSyncCallback(node.props.rowDisabledPredicate), sortBy: extractValue((_b = node.props) === null || _b === void 0 ? void 0 : _b.sortBy), sortingDirection: extractValue((_c = node.props) === null || _c === void 0 ? void 0 : _c.sortDirection), iconSortAsc: extractValue.asOptionalString((_d = node.props) === null || _d === void 0 ? void 0 : _d.iconSortAsc), iconSortDesc: extractValue.asOptionalString((_e = node.props) === null || _e === void 0 ? void 0 : _e.iconSortDesc), iconNoSort: extractValue.asOptionalString((_f = node.props) === null || _f === void 0 ? void 0 : _f.iconNoSort), sortingDidChange: lookupEventHandler("sortingDidChange"), onSelectionDidChange: lookupEventHandler("selectionDidChange"), willSort: lookupEventHandler("willSort"), style: layoutCss, uid: node.uid, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), hideHeader: extractValue.asOptionalBoolean(node.props.hideHeader), enableMultiRowSelection: extractValue.asOptionalBoolean(node.props.enableMultiRowSelection), alwaysShowSelectionHeader: extractValue.asOptionalBoolean(node.props.alwaysShowSelectionHeader) })] }));
|
|
184
|
+
}), hideNoDataView: node.props.noDataTemplate === null || node.props.noDataTemplate === "", loading: extractValue.asOptionalBoolean(node.props.loading), isPaginated: extractValue.asOptionalBoolean((_a = node.props) === null || _a === void 0 ? void 0 : _a.isPaginated), headerHeight: extractValue.asSize(node.props.headerHeight), rowDisabledPredicate: lookupSyncCallback(node.props.rowDisabledPredicate), sortBy: extractValue((_b = node.props) === null || _b === void 0 ? void 0 : _b.sortBy), sortingDirection: extractValue((_c = node.props) === null || _c === void 0 ? void 0 : _c.sortDirection), iconSortAsc: extractValue.asOptionalString((_d = node.props) === null || _d === void 0 ? void 0 : _d.iconSortAsc), iconSortDesc: extractValue.asOptionalString((_e = node.props) === null || _e === void 0 ? void 0 : _e.iconSortDesc), iconNoSort: extractValue.asOptionalString((_f = node.props) === null || _f === void 0 ? void 0 : _f.iconNoSort), sortingDidChange: lookupEventHandler("sortingDidChange"), onSelectionDidChange: lookupEventHandler("selectionDidChange"), willSort: lookupEventHandler("willSort"), style: layoutCss, uid: node.uid, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), hideHeader: extractValue.asOptionalBoolean(node.props.hideHeader), enableMultiRowSelection: extractValue.asOptionalBoolean(node.props.enableMultiRowSelection), alwaysShowSelectionHeader: extractValue.asOptionalBoolean(node.props.alwaysShowSelectionHeader), noBottomBorder: extractValue.asOptionalBoolean(node.props.noBottomBorder) })] }));
|
|
179
185
|
if (selectionContext === null) {
|
|
180
186
|
return (0, jsx_runtime_1.jsx)(SelectionStoreNative_1.StandaloneSelectionStore, { children: tableContent });
|
|
181
187
|
}
|
|
@@ -73,7 +73,7 @@ const getCommonPinningStyles = (column) => {
|
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
// eslint-disable-next-line react/display-name
|
|
76
|
-
exports.Table = (0, react_1.forwardRef)(({ data = constants_1.EMPTY_ARRAY, columns = constants_1.EMPTY_ARRAY, isPaginated = false, loading = false, headerHeight, rowsSelectable = false, enableMultiRowSelection = true, pageSizes = DEFAULT_PAGE_SIZES, rowDisabledPredicate = defaultIsRowDisabled, sortBy, sortingDirection = "ascending", iconSortAsc, iconSortDesc, iconNoSort, sortingDidChange, willSort, style, noDataRenderer, autoFocus = false, hideHeader = false, hideNoDataView = false, alwaysShowSelectionHeader = false, registerComponentApi, onSelectionDidChange,
|
|
76
|
+
exports.Table = (0, react_1.forwardRef)(({ data = constants_1.EMPTY_ARRAY, columns = constants_1.EMPTY_ARRAY, isPaginated = false, loading = false, headerHeight, rowsSelectable = false, enableMultiRowSelection = true, pageSizes = DEFAULT_PAGE_SIZES, rowDisabledPredicate = defaultIsRowDisabled, sortBy, sortingDirection = "ascending", iconSortAsc, iconSortDesc, iconNoSort, sortingDidChange, willSort, style, noDataRenderer, autoFocus = false, hideHeader = false, hideNoDataView = false, alwaysShowSelectionHeader = false, registerComponentApi, onSelectionDidChange, noBottomBorder = false,
|
|
77
77
|
// cols
|
|
78
78
|
}, forwardedRef) => {
|
|
79
79
|
var _a, _b, _c, _d;
|
|
@@ -423,6 +423,7 @@ exports.Table = (0, react_1.forwardRef)(({ data = constants_1.EMPTY_ARRAY, colum
|
|
|
423
423
|
[Table_module_scss_1.default.selected]: row.getIsSelected(),
|
|
424
424
|
[Table_module_scss_1.default.focused]: focusedIndex === rowIndex,
|
|
425
425
|
[Table_module_scss_1.default.disabled]: rowDisabledPredicate(row.original),
|
|
426
|
+
[Table_module_scss_1.default.noBottomBorder]: noBottomBorder,
|
|
426
427
|
}), ref: (el) => {
|
|
427
428
|
if (el && estimatedHeightRef.current === null) {
|
|
428
429
|
estimatedHeightRef.current = Math.round(el.getBoundingClientRect().height);
|
|
@@ -38,6 +38,9 @@ function LoaderComponent({ node, state, dispatch, lookupAction, lookupSyncCallba
|
|
|
38
38
|
const memoedLoaderInProgressChanged = (0, react_1.useCallback)((isInProgress) => {
|
|
39
39
|
dispatch(loaderInProgressChanged(uid, isInProgress));
|
|
40
40
|
}, [dispatch, uid]);
|
|
41
|
+
const memoedLoaderIsRefetchingChanged = (0, react_1.useCallback)((isRefetching) => {
|
|
42
|
+
dispatch(loaderIsRefetchingChanged(uid, isRefetching));
|
|
43
|
+
}, [dispatch, uid]);
|
|
41
44
|
const memoedLoaderLoaded = (0, react_1.useCallback)((data, pageInfo) => {
|
|
42
45
|
dispatch(loaderLoaded(uid, data, pageInfo));
|
|
43
46
|
}, [dispatch, uid]);
|
|
@@ -54,6 +57,7 @@ function LoaderComponent({ node, state, dispatch, lookupAction, lookupSyncCallba
|
|
|
54
57
|
state,
|
|
55
58
|
dispatch,
|
|
56
59
|
loaderInProgressChanged: memoedLoaderInProgressChanged,
|
|
60
|
+
loaderIsRefetchingChanged: memoedLoaderIsRefetchingChanged,
|
|
57
61
|
loaderLoaded: memoedLoaderLoaded,
|
|
58
62
|
loaderError: memoedLoaderError,
|
|
59
63
|
extractValue: valueExtractor,
|
|
@@ -72,6 +76,16 @@ function loaderInProgressChanged(uid, isInProgress) {
|
|
|
72
76
|
},
|
|
73
77
|
};
|
|
74
78
|
}
|
|
79
|
+
// Signs that a particular loader (`uid`) has just started refetching its data (or executing its operation).
|
|
80
|
+
function loaderIsRefetchingChanged(uid, isRefetching) {
|
|
81
|
+
return {
|
|
82
|
+
type: containers_1.ContainerActionKind.LOADER_IS_REFETCHING_CHANGED,
|
|
83
|
+
payload: {
|
|
84
|
+
uid,
|
|
85
|
+
isRefetching,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
75
89
|
// Signs that a particular loader (`uid`) has just fetched its data (`pageInfo`) successfully.
|
|
76
90
|
function loaderLoaded(uid, data, pageInfo) {
|
|
77
91
|
return {
|
|
@@ -9,6 +9,7 @@ var ContainerActionKind;
|
|
|
9
9
|
(function (ContainerActionKind) {
|
|
10
10
|
ContainerActionKind["LOADER_LOADED"] = "ContainerActionKind:LOADER_LOADED";
|
|
11
11
|
ContainerActionKind["LOADER_IN_PROGRESS_CHANGED"] = "ContainerActionKind:LOADER_IN_PROGRESS_CHANGED";
|
|
12
|
+
ContainerActionKind["LOADER_IS_REFETCHING_CHANGED"] = "ContainerActionKind:LOADER_IS_REFETCHING_CHANGED";
|
|
12
13
|
ContainerActionKind["LOADER_ERROR"] = "ContainerActionKind:LOADER_ERROR";
|
|
13
14
|
ContainerActionKind["EVENT_HANDLER_STARTED"] = "ContainerActionKind:EVENT_HANDLER_STARTED";
|
|
14
15
|
ContainerActionKind["EVENT_HANDLER_COMPLETED"] = "ContainerActionKind:EVENT_HANDLER_COMPLETED";
|
|
@@ -21,7 +21,7 @@ const Loader_1 = require("./Loader");
|
|
|
21
21
|
/**
|
|
22
22
|
* Represents a non-displayed React component, which handles the specified API loader
|
|
23
23
|
*/
|
|
24
|
-
function ApiLoader({ loader, loaderInProgressChanged, loaderLoaded, loaderError, state, doNotRemoveNulls, }) {
|
|
24
|
+
function ApiLoader({ loader, loaderInProgressChanged, loaderIsRefetchingChanged, loaderLoaded, loaderError, state, doNotRemoveNulls, }) {
|
|
25
25
|
const appContext = (0, AppContext_1.useAppContext)();
|
|
26
26
|
const url = (0, extractParam_1.extractParam)(state, loader.props.url, appContext);
|
|
27
27
|
const loadable = !!url;
|
|
@@ -29,7 +29,6 @@ function ApiLoader({ loader, loaderInProgressChanged, loaderLoaded, loaderError,
|
|
|
29
29
|
if (!loadable) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
console.log("doLoad ", url);
|
|
33
32
|
const response = yield fetch(url);
|
|
34
33
|
if (loader.props.raw) {
|
|
35
34
|
return yield response.text();
|
|
@@ -40,7 +39,7 @@ function ApiLoader({ loader, loaderInProgressChanged, loaderLoaded, loaderError,
|
|
|
40
39
|
}
|
|
41
40
|
return responseObj;
|
|
42
41
|
}), [doNotRemoveNulls, loadable, loader.props.raw, url]);
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(Loader_1.Loader, { state: state, loader: loader, loaderInProgressChanged: loaderInProgressChanged, loaderLoaded: loaderLoaded, loaderError: loaderError, loaderFn: doLoad }));
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)(Loader_1.Loader, { state: state, loader: loader, loaderInProgressChanged: loaderInProgressChanged, loaderIsRefetchingChanged: loaderIsRefetchingChanged, loaderLoaded: loaderLoaded, loaderError: loaderError, loaderFn: doLoad }));
|
|
44
43
|
}
|
|
45
44
|
const ApiLoaderMd = (0, ComponentDefs_1.createMetadata)({
|
|
46
45
|
description: `Represents a loader that calls an API through an HTTP/HTTPS GET request`,
|
|
@@ -49,6 +48,6 @@ const ApiLoaderMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
49
48
|
raw: (0, ComponentDefs_1.d)("If true, the loader returns the raw text response instead of parsing it as JSON"),
|
|
50
49
|
},
|
|
51
50
|
});
|
|
52
|
-
exports.apiLoaderRenderer = (0, renderers_1.createLoaderRenderer)("ApiLoader", ({ loader, state,
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(ApiLoader, { loader: loader, state: state, loaderInProgressChanged: loaderInProgressChanged, loaderLoaded: loaderLoaded, loaderError: loaderError }));
|
|
51
|
+
exports.apiLoaderRenderer = (0, renderers_1.createLoaderRenderer)("ApiLoader", ({ loader, state, loaderInProgressChanged, loaderIsRefetchingChanged, loaderLoaded, loaderError }) => {
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(ApiLoader, { loader: loader, state: state, loaderInProgressChanged: loaderInProgressChanged, loaderIsRefetchingChanged: loaderIsRefetchingChanged, loaderLoaded: loaderLoaded, loaderError: loaderError }));
|
|
54
53
|
}, ApiLoaderMd);
|
|
@@ -26,7 +26,7 @@ const PageableLoader_1 = require("../loader/PageableLoader");
|
|
|
26
26
|
const Loader_1 = require("../loader/Loader");
|
|
27
27
|
const AppContext_1 = require("../AppContext");
|
|
28
28
|
const hooks_1 = require("../utils/hooks");
|
|
29
|
-
function DataLoader({ loader, state, registerComponentApi, onLoaded, onError, loaderInProgressChanged, loaderLoaded, loaderError, transformResult, }) {
|
|
29
|
+
function DataLoader({ loader, state, registerComponentApi, onLoaded, onError, loaderInProgressChanged, loaderIsRefetchingChanged, loaderLoaded, loaderError, transformResult, }) {
|
|
30
30
|
const appContext = (0, AppContext_1.useAppContext)();
|
|
31
31
|
const url = (0, extractParam_1.extractParam)(state, loader.props.url, appContext);
|
|
32
32
|
const queryParamsInner = (0, react_1.useMemo)(() => {
|
|
@@ -290,7 +290,7 @@ function DataLoader({ loader, state, registerComponentApi, onLoaded, onError, lo
|
|
|
290
290
|
}
|
|
291
291
|
}), [appContext, loader.props.errorNotificationMessage, loaderError, onError]);
|
|
292
292
|
const pollIntervalInSeconds = (0, extractParam_1.extractParam)(state, loader.props.pollIntervalInSeconds, appContext);
|
|
293
|
-
return hasPaging ? ((0, jsx_runtime_1.jsx)(PageableLoader_1.PageableLoader, { queryId: queryId, state: state, loader: loader, loaderInProgressChanged: inProgress, loaderLoaded: loaded, loaderError: error, loaderFn: doLoad, registerComponentApi: registerComponentApi, pollIntervalInSeconds: pollIntervalInSeconds, onLoaded: onLoaded, transformResult: transformResult }, queryId === null || queryId === void 0 ? void 0 : queryId.join(""))) : ((0, jsx_runtime_1.jsx)(Loader_1.Loader, { queryId: queryId, state: state, loader: loader, loaderInProgressChanged: inProgress, loaderLoaded: loaded, loaderError: error, loaderFn: doLoad, pollIntervalInSeconds: pollIntervalInSeconds, registerComponentApi: registerComponentApi, onLoaded: onLoaded, transformResult: transformResult }, queryId === null || queryId === void 0 ? void 0 : queryId.join("")));
|
|
293
|
+
return hasPaging ? ((0, jsx_runtime_1.jsx)(PageableLoader_1.PageableLoader, { queryId: queryId, state: state, loader: loader, loaderInProgressChanged: inProgress, loaderIsRefetchingChanged: loaderIsRefetchingChanged, loaderLoaded: loaded, loaderError: error, loaderFn: doLoad, registerComponentApi: registerComponentApi, pollIntervalInSeconds: pollIntervalInSeconds, onLoaded: onLoaded, transformResult: transformResult }, queryId === null || queryId === void 0 ? void 0 : queryId.join(""))) : ((0, jsx_runtime_1.jsx)(Loader_1.Loader, { queryId: queryId, state: state, loader: loader, loaderInProgressChanged: inProgress, loaderIsRefetchingChanged: loaderIsRefetchingChanged, loaderLoaded: loaded, loaderError: error, loaderFn: doLoad, pollIntervalInSeconds: pollIntervalInSeconds, registerComponentApi: registerComponentApi, onLoaded: onLoaded, transformResult: transformResult }, queryId === null || queryId === void 0 ? void 0 : queryId.join("")));
|
|
294
294
|
}
|
|
295
295
|
exports.DataLoaderMd = (0, ComponentDefs_1.createMetadata)({
|
|
296
296
|
description: "This component manages data fetching from a web API",
|
|
@@ -316,11 +316,11 @@ exports.DataLoaderMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
316
316
|
error: (0, ComponentDefs_1.d)("This event fires when an error occurs while fetching data"),
|
|
317
317
|
},
|
|
318
318
|
});
|
|
319
|
-
exports.dataLoaderRenderer = (0, renderers_1.createLoaderRenderer)("DataLoader", ({ loader, state, loaderLoaded, loaderInProgressChanged, loaderError, registerComponentApi, lookupAction, lookupSyncCallback, }) => {
|
|
319
|
+
exports.dataLoaderRenderer = (0, renderers_1.createLoaderRenderer)("DataLoader", ({ loader, state, loaderLoaded, loaderInProgressChanged, loaderIsRefetchingChanged, loaderError, registerComponentApi, lookupAction, lookupSyncCallback, }) => {
|
|
320
320
|
var _a, _b, _c;
|
|
321
321
|
// --- Check for required properties
|
|
322
322
|
if (!((_a = loader.props) === null || _a === void 0 ? void 0 : _a.url) || !loader.props.url.trim()) {
|
|
323
323
|
throw new Error("You must specify a non-empty (not whitespace-only) 'url' property for DataSource");
|
|
324
324
|
}
|
|
325
|
-
return ((0, jsx_runtime_1.jsx)(DataLoader, { loader: loader, state: state, loaderInProgressChanged: loaderInProgressChanged, loaderLoaded: loaderLoaded, loaderError: loaderError, registerComponentApi: registerComponentApi, transformResult: lookupSyncCallback(loader.props.transformResult), onLoaded: lookupAction((_b = loader.events) === null || _b === void 0 ? void 0 : _b.loaded, { eventName: "loaded" }), onError: lookupAction((_c = loader.events) === null || _c === void 0 ? void 0 : _c.error, { eventName: "error" }) }));
|
|
325
|
+
return ((0, jsx_runtime_1.jsx)(DataLoader, { loader: loader, state: state, loaderInProgressChanged: loaderInProgressChanged, loaderIsRefetchingChanged: loaderIsRefetchingChanged, loaderLoaded: loaderLoaded, loaderError: loaderError, registerComponentApi: registerComponentApi, transformResult: lookupSyncCallback(loader.props.transformResult), onLoaded: lookupAction((_b = loader.events) === null || _b === void 0 ? void 0 : _b.loaded, { eventName: "loaded" }), onError: lookupAction((_c = loader.events) === null || _c === void 0 ? void 0 : _c.error, { eventName: "error" }) }));
|
|
326
326
|
}, exports.DataLoaderMd);
|
|
@@ -21,19 +21,17 @@ const Loader_1 = require("./Loader");
|
|
|
21
21
|
/**
|
|
22
22
|
* Represents a non-displayed React component, which handles the specified API loader
|
|
23
23
|
*/
|
|
24
|
-
function ExternalDataLoader({ loader, loaderInProgressChanged, loaderError, loaderLoaded, state, doNotRemoveNulls, }) {
|
|
24
|
+
function ExternalDataLoader({ loader, loaderInProgressChanged, loaderIsRefetchingChanged, loaderError, loaderLoaded, state, doNotRemoveNulls, }) {
|
|
25
25
|
const appContext = (0, AppContext_1.useAppContext)();
|
|
26
26
|
const method = (0, extractParam_1.extractParam)(state, loader.props.method, appContext);
|
|
27
27
|
const headers = (0, extractParam_1.extractParam)(state, loader.props.headers, appContext);
|
|
28
28
|
const data = (0, extractParam_1.extractParam)(state, loader.props.data, appContext);
|
|
29
|
-
console.log("resolve");
|
|
30
29
|
const url = (0, extractParam_1.extractParam)(state, loader.props.url, appContext);
|
|
31
30
|
const urlLoadable = !!url;
|
|
32
31
|
const doLoad = (0, react_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
|
|
33
32
|
if (!urlLoadable) {
|
|
34
33
|
return;
|
|
35
34
|
}
|
|
36
|
-
console.log("doLoad ", url, data);
|
|
37
35
|
const response = yield fetch(url, {
|
|
38
36
|
method: method || "POST",
|
|
39
37
|
headers: Object.assign({ "Content-Type": "application/json" }, headers),
|
|
@@ -43,10 +41,9 @@ function ExternalDataLoader({ loader, loaderInProgressChanged, loaderError, load
|
|
|
43
41
|
if (!doNotRemoveNulls) {
|
|
44
42
|
(0, misc_1.removeNullProperties)(responseObj);
|
|
45
43
|
}
|
|
46
|
-
console.log("result", responseObj);
|
|
47
44
|
return responseObj;
|
|
48
45
|
}), [urlLoadable, headers, data, url, method, doNotRemoveNulls]);
|
|
49
|
-
return ((0, jsx_runtime_1.jsx)(Loader_1.Loader, { state: state, loader: loader, loaderInProgressChanged: loaderInProgressChanged, loaderLoaded: loaderLoaded, loaderError: loaderError, loaderFn: doLoad }));
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(Loader_1.Loader, { state: state, loader: loader, loaderInProgressChanged: loaderInProgressChanged, loaderIsRefetchingChanged: loaderIsRefetchingChanged, loaderLoaded: loaderLoaded, loaderError: loaderError, loaderFn: doLoad }));
|
|
50
47
|
}
|
|
51
48
|
exports.ExternalDataLoaderMd = (0, ComponentDefs_1.createMetadata)({
|
|
52
49
|
description: `Represents a loader that calls an API through an HTTP/HTTPS GET request`,
|
|
@@ -57,6 +54,6 @@ exports.ExternalDataLoaderMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
57
54
|
data: (0, ComponentDefs_1.d)("The body of the request to be sent as JSON"),
|
|
58
55
|
},
|
|
59
56
|
});
|
|
60
|
-
exports.externalDataLoaderRenderer = (0, renderers_1.createLoaderRenderer)("ExternalDataLoader", ({ loader, state, loaderInProgressChanged, loaderError, loaderLoaded }) => {
|
|
61
|
-
return ((0, jsx_runtime_1.jsx)(ExternalDataLoader, { loader: loader, state: state, loaderInProgressChanged: loaderInProgressChanged, loaderLoaded: loaderLoaded, loaderError: loaderError }));
|
|
57
|
+
exports.externalDataLoaderRenderer = (0, renderers_1.createLoaderRenderer)("ExternalDataLoader", ({ loader, state, loaderInProgressChanged, loaderIsRefetchingChanged, loaderError, loaderLoaded }) => {
|
|
58
|
+
return ((0, jsx_runtime_1.jsx)(ExternalDataLoader, { loader: loader, state: state, loaderInProgressChanged: loaderInProgressChanged, loaderIsRefetchingChanged: loaderIsRefetchingChanged, loaderLoaded: loaderLoaded, loaderError: loaderError }));
|
|
62
59
|
}, exports.ExternalDataLoaderMd);
|