@wavemaker/react-runtime 11.14.2-1.245 → 12.0.0-next.28533
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/actions/base-action.js +5 -7
- package/actions/login-action.js +7 -8
- package/actions/logout-action.js +5 -7
- package/actions/navigation-action.js +32 -10
- package/actions/notification-action.js +22 -8
- package/actions/timer-action.js +13 -15
- package/actions/toast.js +4 -2
- package/actions/toast.service.js +1 -2
- package/components/advanced/carousel/index.js +1 -1
- package/components/advanced/carousel/template.js +1 -1
- package/components/basic/anchor/index.js +26 -9
- package/components/basic/html/index.js +115 -24
- package/components/basic/icon/index.js +2 -1
- package/components/basic/iframe/index.js +2 -1
- package/components/basic/label/index.js +12 -9
- package/components/basic/message/index.js +12 -3
- package/components/basic/picture/index.js +11 -4
- package/components/basic/progress-bar/index.js +1 -1
- package/components/basic/progress-circle/index.js +34 -28
- package/components/basic/progress-circle/props.js +10 -2
- package/components/basic/richtexteditor/index.js +95 -94
- package/components/basic/search/index.js +401 -156
- package/components/basic/search/providers.js +126 -61
- package/components/basic/spinner/index.js +2 -1
- package/components/basic/tree/index.js +34 -34
- package/components/basic/tree/utils.js +10 -4
- package/components/chart/components/barColumnChart/index.js +36 -33
- package/components/chart/components/bubbleChart/index.js +35 -25
- package/components/chart/components/chartLegend/utils.js +2 -1
- package/components/chart/components/cumulativeLineChart/index.js +30 -26
- package/components/chart/components/lineAreaChart/index.js +50 -32
- package/components/chart/components/pieDonutChart/index.js +13 -4
- package/components/chart/hooks/useXAxisConfig.js +15 -8
- package/components/chart/index.js +223 -53
- package/components/chart/utils.js +12 -1
- package/components/constants.js +5 -2
- package/components/container/accordion/accordion-pane/index.js +17 -12
- package/components/container/accordion/index.js +9 -4
- package/components/container/alignment-utils.js +56 -1
- package/components/container/index.js +49 -20
- package/components/container/panel/components/panel-header/index.js +3 -4
- package/components/container/panel/index.js +15 -10
- package/components/container/tabs/index.js +92 -14
- package/components/container/tabs/tab-pane/index.js +15 -8
- package/components/container/tabs/utils.js +51 -0
- package/components/container/wizard/components/StepComponents.js +2 -1
- package/components/container/wizard/components/WizardStep.js +2 -1
- package/components/container/wizard/index.js +64 -35
- package/components/container/wizard/utils.js +46 -1
- package/components/container/wizard/wizard-step/index.js +11 -1
- package/components/data/card/card-content/index.js +1 -1
- package/components/data/form/base-form/index.js +991 -180
- package/components/data/form/base-form/props.js +3 -1
- package/components/data/form/base-form/utils.js +159 -1
- package/components/data/form/dynamic-fields/constant.js +53 -0
- package/components/data/form/dynamic-fields/index.js +10 -45
- package/components/data/form/dynamic-fields/utils.js +37 -2
- package/components/data/form/form-action/index.js +5 -4
- package/components/data/form/form-context.js +5 -1
- package/components/data/form/form-controller/utils.js +84 -0
- package/components/data/form/form-controller/validation-contrustor.js +402 -189
- package/components/data/form/form-controller/withFormController.js +191 -52
- package/components/data/form/form-field/base-field.js +54 -33
- package/components/data/form/form-field/index.js +28 -5
- package/components/data/form/form-header/index.js +3 -4
- package/components/data/form/index.js +20 -1
- package/components/data/list/components/ListDND.js +2 -1
- package/components/data/list/components/ListItem.js +6 -2
- package/components/data/list/components/ListItemWithTemplate.js +46 -2
- package/components/data/list/components/ListItems.js +17 -26
- package/components/data/list/components/ListPagination.js +3 -3
- package/components/data/list/components/StandardListItems.js +3 -4
- package/components/data/list/hooks/useListEffects.js +55 -14
- package/components/data/list/hooks/useListEventHandlers.js +3 -1
- package/components/data/list/hooks/useListState.js +3 -1
- package/components/data/list/hooks/usePaginatedGroupedData.js +18 -5
- package/components/data/list/index.js +74 -55
- package/components/data/list/utils/list-helpers.js +73 -35
- package/components/data/list/utils/list-widget-methods.js +138 -95
- package/components/data/live-filter/index.js +26 -15
- package/components/data/live-form/index.js +23 -7
- package/components/data/live-form/props.js +1 -1
- package/components/data/pagination/components/BasicPagination.js +71 -16
- package/components/data/pagination/components/PageSizeSelector.js +8 -3
- package/components/data/pagination/components/TotalRecords.js +1 -5
- package/components/data/pagination/hooks/usePagination.js +349 -66
- package/components/data/pagination/index.js +137 -19
- package/components/data/table/components/AddNewRow.js +5 -1
- package/components/data/table/components/EditableCell.js +2 -2
- package/components/data/table/components/RowCells.js +64 -0
- package/components/data/table/components/RowExpansionButton.js +2 -2
- package/components/data/table/components/SummaryCell.js +111 -0
- package/components/data/table/components/SummaryRow.js +54 -0
- package/components/data/table/components/SummaryRowFooter.js +46 -0
- package/components/data/table/components/TableBody.js +61 -59
- package/components/data/table/components/TableDataRow.js +109 -0
- package/components/data/table/components/TableFilters.js +225 -121
- package/components/data/table/components/TableHeader.js +291 -23
- package/components/data/table/components/TablePanelHeading.js +139 -8
- package/components/data/table/components/index.js +22 -1
- package/components/data/table/hooks/use-edited-rows.js +141 -0
- package/components/data/table/hooks/useCellState.js +5 -12
- package/components/data/table/hooks/useFormWidget.js +58 -51
- package/components/data/table/hooks/usePaginationState.js +45 -24
- package/components/data/table/hooks/usePanelStructure.js +4 -4
- package/components/data/table/hooks/useRowHandlers.js +39 -5
- package/components/data/table/hooks/useRowSelection.js +244 -50
- package/components/data/table/hooks/useServerSideSorting.js +81 -37
- package/components/data/table/hooks/useTableColumns.js +211 -118
- package/components/data/table/hooks/useTableData.js +54 -9
- package/components/data/table/hooks/useTableEdit.js +272 -97
- package/components/data/table/hooks/useTableEffects.js +31 -13
- package/components/data/table/hooks/useTableFilter.js +1 -1
- package/components/data/table/hooks/useTableInitialization.js +23 -22
- package/components/data/table/hooks/useTableState.js +11 -5
- package/components/data/table/hooks/useTableStateManager.js +140 -65
- package/components/data/table/index.js +637 -274
- package/components/data/table/live-table/index.js +54 -22
- package/components/data/table/table-action/index.js +1 -1
- package/components/data/table/table-group/index.js +26 -0
- package/components/data/table/table-row-action/index.js +32 -18
- package/components/data/table/utils/buildSelectionColumns.js +12 -21
- package/components/data/table/utils/columnBuilder.js +29 -14
- package/components/data/table/utils/columnProxy.js +68 -1
- package/components/data/table/utils/constants.js +6 -2
- package/components/data/table/utils/crud-handlers.js +68 -63
- package/components/data/table/utils/groupHeaderUtils.js +102 -0
- package/components/data/table/utils/index.js +210 -21
- package/components/data/table/utils/renderDisplayCell.js +6 -6
- package/components/data/table/utils/selectionUtils.js +25 -26
- package/components/data/table/utils/validation.js +1 -0
- package/components/data/utils/filter-field-util.js +3 -3
- package/components/dialogs/alert-dialog/index.js +1 -1
- package/components/dialogs/confirm-dialog/index.js +1 -1
- package/components/dialogs/dialog/index.js +4 -1
- package/components/dialogs/dialog-content/index.js +3 -1
- package/components/dialogs/dialog-header/index.js +2 -2
- package/components/dialogs/iframe-dialog/index.js +11 -5
- package/components/dialogs/index.js +1 -1
- package/components/dialogs/login-dialog/index.js +1 -1
- package/components/dialogs/page-dialog/index.js +1 -1
- package/components/form/button/index.js +33 -7
- package/components/input/calendar/index.js +18 -6
- package/components/input/chips/index.js +99 -28
- package/components/input/chips/utils.js +34 -4
- package/components/input/color-picker/index.js +74 -25
- package/components/input/composite/index.js +3 -3
- package/components/input/currency/index.js +35 -49
- package/components/input/default/checkbox/index.js +23 -28
- package/components/input/default/checkboxset/index.js +38 -18
- package/components/input/default/checkboxset/utils.js +30 -0
- package/components/input/default/radioset/index.js +36 -39
- package/components/input/default/switch/index.js +30 -13
- package/components/input/epoch/date/index.js +130 -69
- package/components/input/epoch/date/utils.js +94 -1
- package/components/input/epoch/datetime/index.js +72 -22
- package/components/input/epoch/datetime/utils.js +49 -10
- package/components/input/epoch/time/index.js +68 -19
- package/components/input/epoch/time/utils.js +62 -14
- package/components/input/fileupload/Utils.js +12 -7
- package/components/input/fileupload/components/MultiUpload.js +2 -6
- package/components/input/fileupload/components/SingleUpload.js +3 -7
- package/components/input/fileupload/index.js +6 -10
- package/components/input/fileupload/useFileUpload.js +16 -5
- package/components/input/number/index.js +158 -43
- package/components/input/rating/index.js +90 -7
- package/components/input/select/index.js +147 -70
- package/components/input/slider/index.js +84 -26
- package/components/input/text/index.js +38 -18
- package/components/input/text/util.js +283 -130
- package/components/input/textarea/index.js +13 -10
- package/components/input/upload/index.js +124 -0
- package/components/input/upload/props.js +5 -0
- package/components/input/util/index.js +11 -0
- package/components/navbar/index.js +51 -3
- package/components/navbar/nav/index.js +46 -16
- package/components/navbar/nav-item/index.js +11 -5
- package/components/navigation/menu/components/ListItems.js +3 -0
- package/components/navigation/menu/constants.js +2 -1
- package/components/navigation/menu/hooks/useHoverState.hook.js +48 -0
- package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +37 -0
- package/components/navigation/menu/hooks/useTransformedDataset.hook.js +15 -0
- package/components/navigation/menu/index.js +326 -188
- package/components/navigation/menu/utils/action-task.js +14 -0
- package/components/navigation/menu/utils/role-filter.js +76 -0
- package/components/navigation/popover/index.js +99 -26
- package/components/page/partial-container/index.js +34 -5
- package/components/prefab/index.js +2 -4
- package/context/PrefabContext.js +10 -6
- package/context/WidgetProvider.js +30 -31
- package/core/app.service.js +1 -1
- package/core/constants/events.js +57 -1
- package/core/dialog.service.js +1 -2
- package/core/event-notifier.js +1 -2
- package/core/formatter/array-formatters.js +33 -0
- package/core/formatter/date-formatters.js +2 -4
- package/core/formatter/index.js +2 -1
- package/core/formatter/number-formatters.js +5 -10
- package/core/formatter/security-formatters.js +2 -4
- package/core/formatter/string-formatters.js +3 -6
- package/core/proxy-service.js +84 -13
- package/core/script-registry.js +108 -48
- package/core/util/common.js +4 -4
- package/core/util/compare.js +30 -0
- package/core/util/dom.js +8 -8
- package/core/util/index.js +16 -6
- package/core/util/safe-is-equal.js +156 -0
- package/core/util/security.js +1 -2
- package/core/util/utils.js +16 -7
- package/higherOrder/BaseApp.js +108 -65
- package/higherOrder/BaseDateTime.js +31 -13
- package/higherOrder/BasePage.js +268 -144
- package/higherOrder/BasePartial.js +1 -1
- package/higherOrder/BasePrefab.js +33 -15
- package/higherOrder/DataNav.js +99 -16
- package/higherOrder/helper.js +5 -0
- package/higherOrder/withBaseWrapper.js +41 -28
- package/hooks/useAuth.js +11 -5
- package/hooks/useHttp.js +280 -94
- package/mui-config/theme-provider.js +1 -1
- package/mui-config/theme.js +1 -1
- package/package-lock.json +711 -669
- package/package.json +8 -8
- package/store/bindActions/i18nActions.js +18 -0
- package/store/index.js +3 -1
- package/store/slices/appConfigSlice.js +2 -2
- package/store/slices/authSlice.js +31 -28
- package/store/slices/i18nSlice.js +2 -2
- package/store/slices/navigationSlice.js +35 -0
- package/store/viewport.service.js +255 -0
- package/utils/attr.js +35 -0
- package/utils/dataset-util.js +1 -2
- package/utils/form-state.util.js +43 -12
- package/utils/form-utils.js +47 -2
- package/utils/format-util.js +28 -13
- package/utils/page-params-util.js +33 -1
- package/utils/state-persistance.js +72 -13
- package/utils/transformedDataset-utils.js +35 -24
- package/variables/base-variable.js +12 -14
- package/variables/crud-variable.js +225 -0
- package/variables/live-variable.js +56 -20
- package/variables/metadata.service.js +123 -0
- package/variables/model-variable.js +21 -15
- package/variables/service-variable.js +88 -83
|
@@ -15,6 +15,8 @@ var _joditReact = _interopRequireDefault(require("jodit-react"));
|
|
|
15
15
|
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
16
16
|
var _withBaseWrapper = require("@wavemaker/react-runtime/higherOrder/withBaseWrapper");
|
|
17
17
|
var lodash = _interopRequireWildcard(require("lodash-es"));
|
|
18
|
+
var _withFormController = _interopRequireDefault(require("@wavemaker/react-runtime/components/data/form/form-controller/withFormController"));
|
|
19
|
+
var _util = require("@wavemaker/react-runtime/core/util");
|
|
18
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
19
21
|
var __jsx = _react["default"].createElement;
|
|
20
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -57,7 +59,8 @@ var EditorContainer = (0, _styles.styled)(_material.Box)(function (_ref) {
|
|
|
57
59
|
// Reset problematic global styles that override rich text editor
|
|
58
60
|
"& .jodit-wysiwyg": {
|
|
59
61
|
padding: "unset !important",
|
|
60
|
-
margin: "unset !important"
|
|
62
|
+
margin: "unset !important",
|
|
63
|
+
minHeight: "100px !important "
|
|
61
64
|
},
|
|
62
65
|
"& .jodit-wysiwyg ul, & .jodit-wysiwyg li": {
|
|
63
66
|
paddingLeft: "2em !important",
|
|
@@ -84,7 +87,7 @@ var PreviewContainer = (0, _styles.styled)(_material.Box)(function (_ref2) {
|
|
|
84
87
|
borderRadius: theme.shape.borderRadius,
|
|
85
88
|
backgroundColor: theme.palette.background.paper,
|
|
86
89
|
color: theme.palette.text.primary,
|
|
87
|
-
minHeight: "100px",
|
|
90
|
+
minHeight: "100px !important",
|
|
88
91
|
overflowY: "auto",
|
|
89
92
|
"& img": {
|
|
90
93
|
maxWidth: "100%"
|
|
@@ -103,7 +106,7 @@ var PreviewContainer = (0, _styles.styled)(_material.Box)(function (_ref2) {
|
|
|
103
106
|
var HiddenInput = (0, _styles.styled)("input")({
|
|
104
107
|
display: "none"
|
|
105
108
|
});
|
|
106
|
-
var
|
|
109
|
+
var WmRichTextEditorBase = function WmRichTextEditorBase(props) {
|
|
107
110
|
var name = props.name,
|
|
108
111
|
className = props.className,
|
|
109
112
|
_props$placeholder = props.placeholder,
|
|
@@ -125,7 +128,9 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
125
128
|
onBeforerender = props.onBeforerender,
|
|
126
129
|
hint = props.hint,
|
|
127
130
|
arialabel = props.arialabel,
|
|
128
|
-
listener = props.listener
|
|
131
|
+
listener = props.listener,
|
|
132
|
+
_props$updateon = props.updateon,
|
|
133
|
+
updateon = _props$updateon === void 0 ? "keypress" : _props$updateon;
|
|
129
134
|
|
|
130
135
|
// Extract dimensions from props or styles, converting numbers to pixel strings
|
|
131
136
|
var getDimension = function getDimension(value) {
|
|
@@ -159,6 +164,7 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
159
164
|
var hiddenInputRef = (0, _react.useRef)(null);
|
|
160
165
|
var lastValueRef = (0, _react.useRef)(actualValue || "");
|
|
161
166
|
var isMountedRef = (0, _react.useRef)(true);
|
|
167
|
+
var internalValueRef = (0, _react.useRef)(actualValue || "");
|
|
162
168
|
var widgetInstance = listener === null || listener === void 0 ? void 0 : listener.Widgets[name];
|
|
163
169
|
|
|
164
170
|
// Memoize editor options
|
|
@@ -166,16 +172,15 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
166
172
|
return {
|
|
167
173
|
toolbar: true,
|
|
168
174
|
placeholder: placeholder,
|
|
169
|
-
|
|
175
|
+
minHeight: height ? typeof height === "string" && height.endsWith("px") ? parseInt(height, 10) : 100 : 100,
|
|
170
176
|
width: width,
|
|
171
|
-
|
|
172
|
-
disabled:
|
|
177
|
+
readonly: readonly,
|
|
178
|
+
disabled: disabled,
|
|
173
179
|
statusbar: true,
|
|
174
|
-
toolbarAdaptive:
|
|
180
|
+
toolbarAdaptive: false,
|
|
175
181
|
askBeforePasteHTML: false,
|
|
176
182
|
askBeforePasteFromWord: false,
|
|
177
|
-
buttons: ["source", "|", "bold", "italic", "underline", "strikethrough", "|", "font", "fontsize", "brush", "paragraph", "|", "superscript", "subscript", "|", "ul", "ol", "|", "outdent", "indent", "|", "align", "undo", "redo", "|", "hr", "eraser", "fullsize", "|", "table", "link", "image", "video"],
|
|
178
|
-
removeButtons: ["about"],
|
|
183
|
+
buttons: ["source", "|", "bold", "italic", "underline", "strikethrough", "|", "font", "fontsize", "brush", "paragraph", "|", "superscript", "subscript", "|", "ul", "ol", "|", "outdent", "indent", "|", "align", "undo", "redo", "|", "hr", "eraser", "fullsize", "|", "table", "link", "image", "video", "|", "about"],
|
|
179
184
|
showXPathInStatusbar: false,
|
|
180
185
|
showCharsCounter: false,
|
|
181
186
|
showWordsCounter: false,
|
|
@@ -205,8 +210,24 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
205
210
|
if (hiddenInputRef.current) {
|
|
206
211
|
hiddenInputRef.current.value = sanitizedContent;
|
|
207
212
|
}
|
|
213
|
+
if (props.datavalue === sanitizedContent) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (onChange && updateon !== "keypress") {
|
|
217
|
+
var _editorRef$current;
|
|
218
|
+
// tempDiv.innerHTML = lastValueRef.current;
|
|
219
|
+
// const old_text_context = tempDiv.textContent || tempDiv.innerText || "";
|
|
220
|
+
var syntheticEvent = {
|
|
221
|
+
target: {
|
|
222
|
+
value: sanitizedContent,
|
|
223
|
+
name: name
|
|
224
|
+
},
|
|
225
|
+
currentTarget: (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.editor) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.workplace
|
|
226
|
+
};
|
|
227
|
+
onChange(syntheticEvent, widgetInstance, newContent, sanitizedContent);
|
|
228
|
+
}
|
|
208
229
|
if (listener !== null && listener !== void 0 && listener.onChange) {
|
|
209
|
-
listener.onChange(props.name, {
|
|
230
|
+
listener.onChange(props.fieldName || props.name, {
|
|
210
231
|
datavalue: sanitizedContent
|
|
211
232
|
});
|
|
212
233
|
}
|
|
@@ -219,8 +240,8 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
219
240
|
|
|
220
241
|
// Memoize performEditorOperation
|
|
221
242
|
var performEditorOperation = (0, _react.useCallback)(function (operation, value) {
|
|
222
|
-
var _editorRef$
|
|
223
|
-
if (!isEditorLoaded || !((_editorRef$
|
|
243
|
+
var _editorRef$current2;
|
|
244
|
+
if (!isEditorLoaded || !((_editorRef$current2 = editorRef.current) !== null && _editorRef$current2 !== void 0 && _editorRef$current2.editor)) {
|
|
224
245
|
setOperationStack(function (prev) {
|
|
225
246
|
return [].concat((0, _toConsumableArray2["default"])(prev), [{
|
|
226
247
|
type: operation,
|
|
@@ -291,20 +312,18 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
291
312
|
console.error("Error performing editor operation ".concat(operation, ":"), error);
|
|
292
313
|
}
|
|
293
314
|
}, [isEditorLoaded, sanitizeHtml]);
|
|
294
|
-
|
|
295
|
-
// Memoize handleOnBeforeRender
|
|
296
|
-
var handleOnBeforeRender = (0, _react.useCallback)(function () {
|
|
315
|
+
(0, _react.useEffect)(function () {
|
|
297
316
|
if (onBeforerender) {
|
|
298
|
-
var _editorRef$
|
|
317
|
+
var _editorRef$current3;
|
|
299
318
|
var syntheticEvent = {
|
|
300
319
|
target: {
|
|
301
320
|
value: ""
|
|
302
321
|
},
|
|
303
|
-
currentTarget: (_editorRef$
|
|
322
|
+
currentTarget: (_editorRef$current3 = editorRef.current) === null || _editorRef$current3 === void 0 || (_editorRef$current3 = _editorRef$current3.editor) === null || _editorRef$current3 === void 0 ? void 0 : _editorRef$current3.workplace
|
|
304
323
|
};
|
|
305
324
|
onBeforerender(syntheticEvent, widgetInstance);
|
|
306
325
|
}
|
|
307
|
-
}, [
|
|
326
|
+
}, []);
|
|
308
327
|
|
|
309
328
|
// Create a debounced version of handleOnChange
|
|
310
329
|
var debouncedHandleOnChange = (0, _react.useMemo)(function () {
|
|
@@ -313,31 +332,34 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
313
332
|
var tempDiv = document.createElement("div");
|
|
314
333
|
tempDiv.innerHTML = newContent;
|
|
315
334
|
var new_text_content = tempDiv.textContent || tempDiv.innerText || "";
|
|
335
|
+
internalValueRef.current = new_text_content;
|
|
316
336
|
if (name && widgetInstance) {
|
|
317
337
|
widgetInstance.displayValue = new_text_content;
|
|
318
338
|
}
|
|
319
|
-
if (
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
widgetInstance
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
hiddenInputRef.current
|
|
339
|
+
if (updateon === "keypress") {
|
|
340
|
+
if (onChange) {
|
|
341
|
+
var _editorRef$current4;
|
|
342
|
+
tempDiv.innerHTML = lastValueRef.current;
|
|
343
|
+
var old_text_context = tempDiv.textContent || tempDiv.innerText || "";
|
|
344
|
+
var syntheticEvent = {
|
|
345
|
+
target: {
|
|
346
|
+
value: new_text_content,
|
|
347
|
+
name: name
|
|
348
|
+
},
|
|
349
|
+
currentTarget: (_editorRef$current4 = editorRef.current) === null || _editorRef$current4 === void 0 || (_editorRef$current4 = _editorRef$current4.editor) === null || _editorRef$current4 === void 0 ? void 0 : _editorRef$current4.workplace
|
|
350
|
+
};
|
|
351
|
+
onChange(syntheticEvent, widgetInstance, new_text_content, old_text_context);
|
|
352
|
+
}
|
|
353
|
+
if (name && widgetInstance) {
|
|
354
|
+
widgetInstance.datavalue = new_text_content;
|
|
355
|
+
}
|
|
356
|
+
lastValueRef.current = sanitizedContent;
|
|
357
|
+
if (hiddenInputRef.current) {
|
|
358
|
+
hiddenInputRef.current.value = sanitizedContent;
|
|
359
|
+
}
|
|
338
360
|
}
|
|
339
|
-
});
|
|
340
|
-
}, [
|
|
361
|
+
}, parseInt(props.updatedelay || "10"));
|
|
362
|
+
}, [onChange]);
|
|
341
363
|
|
|
342
364
|
// Cleanup debounced function on unmount
|
|
343
365
|
(0, _react.useEffect)(function () {
|
|
@@ -348,9 +370,13 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
348
370
|
|
|
349
371
|
// Memoize handleEditorInit
|
|
350
372
|
var handleEditorInit = (0, _react.useCallback)(function () {
|
|
351
|
-
var _editorRef$
|
|
373
|
+
var _editorRef$current5;
|
|
352
374
|
setIsEditorLoaded(true);
|
|
353
|
-
if ((_editorRef$
|
|
375
|
+
if ((_editorRef$current5 = editorRef.current) !== null && _editorRef$current5 !== void 0 && _editorRef$current5.editor) {
|
|
376
|
+
// Initialize content explicitly to avoid relying on value prop
|
|
377
|
+
if (content !== undefined && content !== null) {
|
|
378
|
+
editorRef.current.editor.value = content === null || content === void 0 ? void 0 : content.toString();
|
|
379
|
+
}
|
|
354
380
|
if (height) {
|
|
355
381
|
var heightValue = typeof height === "string" && height.endsWith("px") ? parseInt(height, 10) : height;
|
|
356
382
|
performEditorOperation("height", heightValue);
|
|
@@ -372,11 +398,11 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
372
398
|
return _objectSpread(_objectSpread({}, editorOptions), {}, {
|
|
373
399
|
tabIndex: tabindex,
|
|
374
400
|
events: {
|
|
375
|
-
|
|
376
|
-
|
|
401
|
+
ready: handleEditorInit
|
|
402
|
+
// afterInit: handleEditorInit,
|
|
377
403
|
}
|
|
378
404
|
});
|
|
379
|
-
}, [editorOptions, tabindex,
|
|
405
|
+
}, [editorOptions, tabindex, handleEditorInit]);
|
|
380
406
|
|
|
381
407
|
// Memoize the component's JSX
|
|
382
408
|
var editorJSX = (0, _react.useMemo)(function () {
|
|
@@ -386,23 +412,23 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
386
412
|
style: {
|
|
387
413
|
width: width
|
|
388
414
|
},
|
|
389
|
-
height: styles === null || styles === void 0 ? void 0 : styles.height
|
|
415
|
+
height: styles === null || styles === void 0 ? void 0 : styles.height,
|
|
416
|
+
"aria-readonly": readonly,
|
|
417
|
+
hidden: props.hidden
|
|
390
418
|
}, __jsx(_joditReact["default"], {
|
|
391
419
|
ref: editorRef,
|
|
392
|
-
value: content.toString(),
|
|
420
|
+
value: content === null || content === void 0 ? void 0 : content.toString(),
|
|
393
421
|
config: editorConfig,
|
|
394
422
|
onBlur: handleEditorBlur,
|
|
395
|
-
onChange:
|
|
396
|
-
,
|
|
397
|
-
onReady: handleEditorInit
|
|
423
|
+
onChange: debouncedHandleOnChange
|
|
398
424
|
}), __jsx(HiddenInput, {
|
|
399
425
|
ref: hiddenInputRef,
|
|
400
426
|
className: "model-holder",
|
|
401
427
|
disabled: disabled,
|
|
402
|
-
value: content.toString(),
|
|
428
|
+
value: content === null || content === void 0 ? void 0 : content.toString(),
|
|
403
429
|
name: name,
|
|
404
430
|
readOnly: true
|
|
405
|
-
})), showpreview && __jsx(PreviewContainer, {
|
|
431
|
+
})), (0, _util.toBoolean)(showpreview) && __jsx(PreviewContainer, {
|
|
406
432
|
className: "ta-preview",
|
|
407
433
|
style: {
|
|
408
434
|
width: width
|
|
@@ -442,16 +468,16 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
442
468
|
|
|
443
469
|
// Handle datavalue changes
|
|
444
470
|
(0, _react.useEffect)(function () {
|
|
445
|
-
if (datavalue !=
|
|
471
|
+
if (datavalue != internalValueRef.current) {
|
|
446
472
|
setContent(datavalue);
|
|
447
|
-
|
|
473
|
+
internalValueRef.current = datavalue;
|
|
448
474
|
}
|
|
449
475
|
}, [datavalue]);
|
|
450
476
|
|
|
451
477
|
// Initialize editor and handle prop changes
|
|
452
478
|
(0, _react.useEffect)(function () {
|
|
453
|
-
var _editorRef$
|
|
454
|
-
if ((_editorRef$
|
|
479
|
+
var _editorRef$current6;
|
|
480
|
+
if ((_editorRef$current6 = editorRef.current) !== null && _editorRef$current6 !== void 0 && _editorRef$current6.editor && isEditorLoaded) {
|
|
455
481
|
// Handle readonly/disabled state changes
|
|
456
482
|
if (readonly || disabled) {
|
|
457
483
|
performEditorOperation("disable");
|
|
@@ -477,41 +503,6 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
477
503
|
}
|
|
478
504
|
}, [readonly, disabled, placeholder, height, width, performEditorOperation, isEditorLoaded]);
|
|
479
505
|
|
|
480
|
-
// Expose editor methods to parent components
|
|
481
|
-
(0, _react.useImperativeHandle)(ref, function () {
|
|
482
|
-
return {
|
|
483
|
-
// Get current HTML content
|
|
484
|
-
htmlcontent: function htmlcontent() {
|
|
485
|
-
return performEditorOperation("code");
|
|
486
|
-
},
|
|
487
|
-
// Get current selection position
|
|
488
|
-
getCurrentPosition: function getCurrentPosition() {
|
|
489
|
-
return performEditorOperation("createRange");
|
|
490
|
-
},
|
|
491
|
-
// Undo last operation
|
|
492
|
-
undo: function undo() {
|
|
493
|
-
return performEditorOperation("undo");
|
|
494
|
-
},
|
|
495
|
-
// Focus the editor
|
|
496
|
-
focus: function focus() {
|
|
497
|
-
return performEditorOperation("focus");
|
|
498
|
-
},
|
|
499
|
-
// Get editor instance
|
|
500
|
-
getEditor: function getEditor() {
|
|
501
|
-
var _editorRef$current6;
|
|
502
|
-
return (_editorRef$current6 = editorRef.current) === null || _editorRef$current6 === void 0 ? void 0 : _editorRef$current6.editor;
|
|
503
|
-
},
|
|
504
|
-
// Set editor content
|
|
505
|
-
setContent: function setContent(newContent) {
|
|
506
|
-
performEditorOperation("code", newContent);
|
|
507
|
-
},
|
|
508
|
-
// Perform custom editor operation
|
|
509
|
-
performOperation: function performOperation(operation, value) {
|
|
510
|
-
return performEditorOperation(operation, value);
|
|
511
|
-
}
|
|
512
|
-
};
|
|
513
|
-
});
|
|
514
|
-
|
|
515
506
|
// Clean up on unmount
|
|
516
507
|
(0, _react.useEffect)(function () {
|
|
517
508
|
isMountedRef.current = true;
|
|
@@ -520,7 +511,8 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
520
511
|
isMountedRef.current = false;
|
|
521
512
|
if ((_editorRef$current7 = editorRef.current) !== null && _editorRef$current7 !== void 0 && _editorRef$current7.editor) {
|
|
522
513
|
try {
|
|
523
|
-
|
|
514
|
+
var _editorRef$current8;
|
|
515
|
+
editorRef === null || editorRef === void 0 || (_editorRef$current8 = editorRef.current) === null || _editorRef$current8 === void 0 || (_editorRef$current8 = _editorRef$current8.editor) === null || _editorRef$current8 === void 0 || _editorRef$current8.destruct();
|
|
524
516
|
} catch (error) {
|
|
525
517
|
console.error("Error destructing editor:", error);
|
|
526
518
|
}
|
|
@@ -528,6 +520,15 @@ var WmRichTextEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
528
520
|
};
|
|
529
521
|
}, []);
|
|
530
522
|
return editorJSX;
|
|
523
|
+
};
|
|
524
|
+
WmRichTextEditorBase.displayName = "WmRichTextEditor";
|
|
525
|
+
|
|
526
|
+
// Memoize editor to avoid unnecessary re-renders from changing handler identities
|
|
527
|
+
var WmRichTextEditor = /*#__PURE__*/_react["default"].memo(WmRichTextEditorBase, function (prev, next) {
|
|
528
|
+
// Core props that should trigger a re-render when changed
|
|
529
|
+
var keys = ["datavalue", "readonly", "disabled", "placeholder", "tabindex", "showpreview", "hint", "arialabel", "hidden", "name"];
|
|
530
|
+
return keys.every(function (key) {
|
|
531
|
+
return lodash.isEqual(prev[key], next[key]);
|
|
532
|
+
});
|
|
531
533
|
});
|
|
532
|
-
|
|
533
|
-
var _default = exports["default"] = /*#__PURE__*/_react["default"].memo((0, _withBaseWrapper.withBaseWrapper)(WmRichTextEditor));
|
|
534
|
+
var _default = exports["default"] = (0, _withBaseWrapper.withBaseWrapper)((0, _withFormController["default"])(WmRichTextEditor));
|