@wavemaker/react-runtime 11.14.3-rc.6401 → 11.15.0-2.247
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 +73 -18
- 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 +31 -11
- 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 +4 -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/repeat-template/index.js +33 -0
- package/components/container/tabs/index.js +83 -14
- package/components/container/tabs/tab-pane/index.js +33 -10
- 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 +985 -183
- 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 +67 -45
- 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 +51 -18
- 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 -52
- 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 +209 -72
- 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 +105 -32
- 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 +85 -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 +41 -3
- 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 +423 -331
- 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
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.TIME_PICKER_STYLES = exports.READONLY_STYLES = exports.DEFAULT_TIMEPATTERN = exports.DEFAULT_OUTPUT_FORMAT = exports.DEFAULT_CLASS = void 0;
|
|
8
|
+
exports.createWidgetEvent = createWidgetEvent;
|
|
8
9
|
exports.formatDisplayTimeValue = formatDisplayTimeValue;
|
|
9
10
|
exports.getSupportedTimeFormats = getSupportedTimeFormats;
|
|
10
11
|
exports.parseTimeFormat = parseTimeFormat;
|
|
@@ -14,6 +15,7 @@ exports.updateListener = updateListener;
|
|
|
14
15
|
exports.validateTimeFormat = validateTimeFormat;
|
|
15
16
|
exports.validateTimeRange = validateTimeRange;
|
|
16
17
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
19
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
18
20
|
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; }
|
|
19
21
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -84,7 +86,24 @@ function formatDisplayTimeValue(value, pattern) {
|
|
|
84
86
|
return "";
|
|
85
87
|
}
|
|
86
88
|
}
|
|
89
|
+
|
|
90
|
+
// Get validator error message (similar to datetime widget)
|
|
91
|
+
function getValidatorErrorMessage(validators, validatorType) {
|
|
92
|
+
if (!validators || validators.length === 0) return undefined;
|
|
93
|
+
var validator = validators.find(function (v) {
|
|
94
|
+
return (0, _typeof2["default"])(v) === "object" && v !== null && "type" in v && v.type === validatorType;
|
|
95
|
+
});
|
|
96
|
+
if (validator && (0, _typeof2["default"])(validator) === "object" && "errorMessage" in validator) {
|
|
97
|
+
var errorMessage = validator.errorMessage;
|
|
98
|
+
if (typeof errorMessage === "string") {
|
|
99
|
+
return errorMessage;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
87
104
|
function validateTimeRange(timeValue, minTime, maxTime) {
|
|
105
|
+
var validators = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
106
|
+
var validationmessage = arguments.length > 4 ? arguments[4] : undefined;
|
|
88
107
|
if (!timeValue) return {
|
|
89
108
|
isValid: true
|
|
90
109
|
};
|
|
@@ -94,32 +113,34 @@ function validateTimeRange(timeValue, minTime, maxTime) {
|
|
|
94
113
|
return {
|
|
95
114
|
isValid: false,
|
|
96
115
|
errorType: "format",
|
|
97
|
-
message: "Invalid time format"
|
|
116
|
+
message: validationmessage || "Invalid time format"
|
|
98
117
|
};
|
|
99
118
|
}
|
|
100
119
|
var timeToCheckMinutes = timeToCheck.hours() * 60 + timeToCheck.minutes();
|
|
101
120
|
if (minTime) {
|
|
102
|
-
var minMoment = typeof minTime === "string" ? (0, _momentTimezone["default"])(minTime,
|
|
121
|
+
var minMoment = typeof minTime === "string" ? (0, _momentTimezone["default"])(minTime, getSupportedTimeFormats(), true) : (0, _momentTimezone["default"])(minTime);
|
|
103
122
|
if (minMoment.isValid()) {
|
|
104
123
|
var minMinutes = minMoment.hours() * 60 + minMoment.minutes();
|
|
105
124
|
if (timeToCheckMinutes < minMinutes) {
|
|
125
|
+
var errorMessage = getValidatorErrorMessage(validators, "mintime") || validationmessage || "Time must be later than ".concat(minMoment.format("HH:mm"));
|
|
106
126
|
return {
|
|
107
127
|
isValid: false,
|
|
108
128
|
errorType: "mintime",
|
|
109
|
-
message:
|
|
129
|
+
message: errorMessage
|
|
110
130
|
};
|
|
111
131
|
}
|
|
112
132
|
}
|
|
113
133
|
}
|
|
114
134
|
if (maxTime) {
|
|
115
|
-
var maxMoment = typeof maxTime === "string" ? (0, _momentTimezone["default"])(maxTime,
|
|
135
|
+
var maxMoment = typeof maxTime === "string" ? (0, _momentTimezone["default"])(maxTime, getSupportedTimeFormats(), true) : (0, _momentTimezone["default"])(maxTime);
|
|
116
136
|
if (maxMoment.isValid()) {
|
|
117
137
|
var maxMinutes = maxMoment.hours() * 60 + maxMoment.minutes();
|
|
118
138
|
if (timeToCheckMinutes > maxMinutes) {
|
|
139
|
+
var _errorMessage = getValidatorErrorMessage(validators, "maxtime") || validationmessage || "Time must be earlier than ".concat(maxMoment.format("HH:mm"));
|
|
119
140
|
return {
|
|
120
141
|
isValid: false,
|
|
121
142
|
errorType: "maxtime",
|
|
122
|
-
message:
|
|
143
|
+
message: _errorMessage
|
|
123
144
|
};
|
|
124
145
|
}
|
|
125
146
|
}
|
|
@@ -132,22 +153,25 @@ function validateTimeRange(timeValue, minTime, maxTime) {
|
|
|
132
153
|
return {
|
|
133
154
|
isValid: false,
|
|
134
155
|
errorType: "format",
|
|
135
|
-
message: "Validation error"
|
|
156
|
+
message: validationmessage || "Validation error"
|
|
136
157
|
};
|
|
137
158
|
}
|
|
138
159
|
}
|
|
139
|
-
function validateTimeFormat(inputValue, pattern, required) {
|
|
160
|
+
function validateTimeFormat(inputValue, pattern, required, validationmessage) {
|
|
140
161
|
if (!inputValue.trim()) return {
|
|
141
162
|
isValid: true
|
|
142
163
|
};
|
|
143
164
|
try {
|
|
144
165
|
var parsed = (0, _momentTimezone["default"])(inputValue, pattern, true);
|
|
145
|
-
if (!parsed.isValid()
|
|
146
|
-
|
|
166
|
+
if (!parsed.isValid()) {
|
|
167
|
+
var error = {
|
|
147
168
|
isValid: false,
|
|
148
|
-
errorType: "format"
|
|
149
|
-
message: "Invalid time format. Expected: ".concat(pattern)
|
|
169
|
+
errorType: "format"
|
|
150
170
|
};
|
|
171
|
+
if (required) {
|
|
172
|
+
error.message = validationmessage || "Invalid time format. Expected: ".concat(pattern);
|
|
173
|
+
}
|
|
174
|
+
return error;
|
|
151
175
|
}
|
|
152
176
|
return {
|
|
153
177
|
isValid: true
|
|
@@ -156,7 +180,7 @@ function validateTimeFormat(inputValue, pattern, required) {
|
|
|
156
180
|
return {
|
|
157
181
|
isValid: false,
|
|
158
182
|
errorType: "format",
|
|
159
|
-
message: "Invalid time format"
|
|
183
|
+
message: validationmessage || "Invalid time format"
|
|
160
184
|
};
|
|
161
185
|
}
|
|
162
186
|
}
|
|
@@ -172,7 +196,7 @@ function parseTimeObj(timeValue) {
|
|
|
172
196
|
|
|
173
197
|
// Constants
|
|
174
198
|
var DEFAULT_CLASS = exports.DEFAULT_CLASS = "input-group app-timeinput";
|
|
175
|
-
var DEFAULT_TIMEPATTERN = exports.DEFAULT_TIMEPATTERN = "h:mm:ss
|
|
199
|
+
var DEFAULT_TIMEPATTERN = exports.DEFAULT_TIMEPATTERN = "h:mm:ss A";
|
|
176
200
|
var DEFAULT_OUTPUT_FORMAT = exports.DEFAULT_OUTPUT_FORMAT = "HH:mm:ss";
|
|
177
201
|
|
|
178
202
|
// Styling constants
|
|
@@ -200,10 +224,34 @@ function updateListener(name, listener, props, displayValue, timestamp, datavalu
|
|
|
200
224
|
// Update listener widget display value
|
|
201
225
|
|
|
202
226
|
if (listener !== null && listener !== void 0 && listener.onChange) {
|
|
203
|
-
listener.onChange(
|
|
227
|
+
listener.onChange(props.fieldName || name, _objectSpread(_objectSpread({}, props), {}, {
|
|
204
228
|
displayValue: displayValue,
|
|
205
229
|
timestamp: timestamp,
|
|
206
230
|
datavalue: datavalue
|
|
207
231
|
}));
|
|
208
232
|
}
|
|
233
|
+
}
|
|
234
|
+
function createWidgetEvent(args) {
|
|
235
|
+
var type = args.type,
|
|
236
|
+
name = args.name,
|
|
237
|
+
value = args.value,
|
|
238
|
+
anchor = args.anchor,
|
|
239
|
+
originalEvent = args.originalEvent;
|
|
240
|
+
var base = originalEvent && (0, _typeof2["default"])(originalEvent) === "object" ? _objectSpread({}, originalEvent) : {};
|
|
241
|
+
var evt = base;
|
|
242
|
+
if (!evt.type) {
|
|
243
|
+
evt.type = type;
|
|
244
|
+
}
|
|
245
|
+
if (!evt.target && anchor) {
|
|
246
|
+
evt.target = anchor;
|
|
247
|
+
}
|
|
248
|
+
if (!evt.currentTarget && anchor) {
|
|
249
|
+
evt.currentTarget = anchor;
|
|
250
|
+
}
|
|
251
|
+
if (name !== undefined) evt.name = name;
|
|
252
|
+
if (value !== undefined) evt.value = value;
|
|
253
|
+
if (originalEvent) {
|
|
254
|
+
evt.originalEvent = originalEvent;
|
|
255
|
+
}
|
|
256
|
+
return evt;
|
|
209
257
|
}
|
|
@@ -40,13 +40,16 @@ var isValidFile = exports.isValidFile = function isValidFile(filename, contentty
|
|
|
40
40
|
if (!contenttype) {
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
|
-
var
|
|
43
|
+
var ext = extensionName.toLowerCase();
|
|
44
|
+
|
|
45
|
+
// Split by comma or space (handles ".doc, .docx" and ".doc .docx" formats)
|
|
46
|
+
var contentTypes = contenttype.toLowerCase().split(/[\s,]+/).map(function (type) {
|
|
44
47
|
return type.trim();
|
|
45
|
-
});
|
|
48
|
+
}).filter(Boolean);
|
|
46
49
|
|
|
47
50
|
// Check for direct extension match (e.g., ".csv", ".pdf")
|
|
48
51
|
if (contentTypes.some(function (type) {
|
|
49
|
-
return type === ".".concat(
|
|
52
|
+
return type === ".".concat(ext) || type === ext;
|
|
50
53
|
})) {
|
|
51
54
|
return true;
|
|
52
55
|
}
|
|
@@ -57,16 +60,18 @@ var isValidFile = exports.isValidFile = function isValidFile(filename, contentty
|
|
|
57
60
|
try {
|
|
58
61
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
59
62
|
var type = _step.value;
|
|
60
|
-
|
|
63
|
+
// Normalize type for comparison (remove leading dot if present)
|
|
64
|
+
var normalizedType = type.startsWith(".") ? type.slice(1) : type;
|
|
65
|
+
if (type === "image/*" || normalizedType === "image") {
|
|
61
66
|
if ((0, _constants.isImageFile)(filename)) return true;
|
|
62
67
|
}
|
|
63
|
-
if (type === "audio/*" ||
|
|
68
|
+
if (type === "audio/*" || normalizedType === "audio") {
|
|
64
69
|
if ((0, _constants.isAudioFile)(filename)) return true;
|
|
65
70
|
}
|
|
66
|
-
if (type === "video/*" ||
|
|
71
|
+
if (type === "video/*" || normalizedType === "video") {
|
|
67
72
|
if ((0, _constants.isVideoFile)(filename)) return true;
|
|
68
73
|
}
|
|
69
|
-
if (
|
|
74
|
+
if (normalizedType === "document" || normalizedType === "pdf" || normalizedType === "doc") {
|
|
70
75
|
if ((0, _constants.isDocumentFile)(filename)) return true;
|
|
71
76
|
}
|
|
72
77
|
}
|
|
@@ -33,9 +33,6 @@ var MultipleFileUpload = function MultipleFileUpload(_ref) {
|
|
|
33
33
|
setHighlightDropArea = _ref.setHighlightDropArea,
|
|
34
34
|
onBeforeselect = _ref.onBeforeselect,
|
|
35
35
|
styles = _ref.styles;
|
|
36
|
-
var handleClick = function handleClick(e) {
|
|
37
|
-
onBeforeselect === null || onBeforeselect === void 0 || onBeforeselect(e);
|
|
38
|
-
};
|
|
39
36
|
return __jsx("div", {
|
|
40
37
|
className: "app-multi-file-upload"
|
|
41
38
|
}, __jsx("div", {
|
|
@@ -64,7 +61,7 @@ var MultipleFileUpload = function MultipleFileUpload(_ref) {
|
|
|
64
61
|
name: "files",
|
|
65
62
|
multiple: multiple,
|
|
66
63
|
accept: chooseFilter,
|
|
67
|
-
disabled: disabled
|
|
64
|
+
disabled: disabled,
|
|
68
65
|
required: required,
|
|
69
66
|
"aria-label": arialabel || displayname || "File selection field",
|
|
70
67
|
onChange: onFileSelect,
|
|
@@ -72,8 +69,7 @@ var MultipleFileUpload = function MultipleFileUpload(_ref) {
|
|
|
72
69
|
tabIndex: tabindex,
|
|
73
70
|
style: {
|
|
74
71
|
display: "none"
|
|
75
|
-
}
|
|
76
|
-
onClick: handleClick
|
|
72
|
+
}
|
|
77
73
|
}), __jsx("a", {
|
|
78
74
|
className: "app-anchor upload-label",
|
|
79
75
|
onClick: disabled || readonly ? undefined : triggerFileSelect
|
|
@@ -26,9 +26,6 @@ var SingleFileUpload = function SingleFileUpload(_ref) {
|
|
|
26
26
|
triggerFileSelect = _ref.triggerFileSelect,
|
|
27
27
|
onFileSelect = _ref.onFileSelect,
|
|
28
28
|
onBeforeselect = _ref.onBeforeselect;
|
|
29
|
-
var handleClick = function handleClick(e) {
|
|
30
|
-
onBeforeselect === null || onBeforeselect === void 0 || onBeforeselect(e);
|
|
31
|
-
};
|
|
32
29
|
return __jsx("div", {
|
|
33
30
|
className: "app-single-file-upload"
|
|
34
31
|
}, __jsx("div", {
|
|
@@ -41,7 +38,7 @@ var SingleFileUpload = function SingleFileUpload(_ref) {
|
|
|
41
38
|
type: "file",
|
|
42
39
|
name: "files",
|
|
43
40
|
accept: chooseFilter,
|
|
44
|
-
disabled: disabled
|
|
41
|
+
disabled: disabled,
|
|
45
42
|
required: required,
|
|
46
43
|
"aria-label": arialabel || displayname || "File selection field",
|
|
47
44
|
onChange: onFileSelect,
|
|
@@ -49,14 +46,13 @@ var SingleFileUpload = function SingleFileUpload(_ref) {
|
|
|
49
46
|
tabIndex: tabindex,
|
|
50
47
|
style: {
|
|
51
48
|
display: "none"
|
|
52
|
-
}
|
|
53
|
-
onClick: handleClick
|
|
49
|
+
}
|
|
54
50
|
}), __jsx("button", {
|
|
55
51
|
id: "dropzone",
|
|
56
52
|
type: "button",
|
|
57
53
|
className: "app-button btn btn-default",
|
|
58
54
|
onClick: disabled || readonly ? undefined : triggerFileSelect,
|
|
59
|
-
disabled: disabled
|
|
55
|
+
disabled: disabled,
|
|
60
56
|
style: styles
|
|
61
57
|
}, __jsx("i", {
|
|
62
58
|
className: iconclass
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
@@ -22,8 +21,6 @@ var _confirmDialog = _interopRequireDefault(require("@wavemaker/react-runtime/co
|
|
|
22
21
|
var _excluded = ["fileInputRef", "chooseFilter", "highlightDropArea", "uploadedFiles", "selectedFolders", "setSelectedFolders", "dragOverHandler", "onFileSelect", "onFileDrop", "setHighlightDropArea", "clearSelectedFile", "triggerFileSelect", "onFileDelete", "confirmDialogOpen", "confirmDialogProps", "closeConfirmDialog"];
|
|
23
22
|
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); }
|
|
24
23
|
var __jsx = _react["default"].createElement;
|
|
25
|
-
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; }
|
|
26
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
27
24
|
var WmFileUpload = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
28
25
|
var _props$caption = props.caption,
|
|
29
26
|
caption = _props$caption === void 0 ? _constants.fileUploadConstants.DEFAULT_CLASSES.DEFAULT_CAPTIONS.SELECT : _props$caption,
|
|
@@ -74,16 +71,15 @@ var WmFileUpload = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
74
71
|
confirmDialogProps = _useFileUpload.confirmDialogProps,
|
|
75
72
|
closeConfirmDialog = _useFileUpload.closeConfirmDialog,
|
|
76
73
|
events = (0, _objectWithoutProperties2["default"])(_useFileUpload, _excluded);
|
|
77
|
-
var containerStyle = _objectSpread(_objectSpread({}, styles), {}, {
|
|
78
|
-
width: width !== "auto" ? width : undefined,
|
|
79
|
-
height: height || undefined
|
|
80
|
-
});
|
|
81
74
|
return __jsx(_Box["default"], {
|
|
82
75
|
component: "div",
|
|
83
76
|
className: (0, _clsx["default"])("app-fileupload", className),
|
|
84
77
|
id: id,
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
title: hint,
|
|
79
|
+
hidden: props.hidden,
|
|
80
|
+
style: {
|
|
81
|
+
width: "100%"
|
|
82
|
+
}
|
|
87
83
|
}, !multiple ? __jsx(_SingleUpload["default"], (0, _extends2["default"])({
|
|
88
84
|
fileInputRef: fileInputRef,
|
|
89
85
|
caption: caption,
|
|
@@ -155,7 +151,7 @@ var WmFileUpload = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
155
151
|
listener: {}
|
|
156
152
|
}));
|
|
157
153
|
}, function (prevProps, nextProps) {
|
|
158
|
-
var keysToCheck = ["caption", "name", "hint", "arialabel", "tabindex", "multiple", "fileuploadmessage", "show", "disabled", "contenttype", "maxfilesize", "iconclass", "cleariconclass", "cleariconhint", "uploadpath", "datasource", "selectedFiles", "destination", "filelistheight", "width", "showprogressbar", "showprogressbarpercentage", "deleteiconhint", "extensions", "filetype", "readonly", "required", "deletedatasource", "displayname", "height", "onBeforeselect", "onSelect", "onDelete", "onBeforedelete", "onError"];
|
|
154
|
+
var keysToCheck = ["caption", "name", "hint", "arialabel", "tabindex", "multiple", "fileuploadmessage", "show", "disabled", "contenttype", "maxfilesize", "iconclass", "cleariconclass", "cleariconhint", "uploadpath", "datasource", "selectedFiles", "destination", "filelistheight", "width", "showprogressbar", "showprogressbarpercentage", "deleteiconhint", "extensions", "filetype", "readonly", "required", "deletedatasource", "displayname", "height", "onBeforeselect", "onSelect", "onDelete", "onBeforedelete", "onError", "hidden"];
|
|
159
155
|
|
|
160
156
|
// Check if any props that affect rendering have changed
|
|
161
157
|
var propsChanged = keysToCheck.some(function (key) {
|
|
@@ -181,7 +181,7 @@ var useFileUpload = exports.useFileUpload = function useFileUpload(props) {
|
|
|
181
181
|
// Add event listeners for drag and drop
|
|
182
182
|
if (disabled || readonly) {
|
|
183
183
|
setHighlightDropArea(false);
|
|
184
|
-
window.removeEventListener("focus",
|
|
184
|
+
window.removeEventListener("focus", _disableDropZone);
|
|
185
185
|
} else {
|
|
186
186
|
document.addEventListener("dragover", dragOverCb);
|
|
187
187
|
document.addEventListener("drop", dropCb);
|
|
@@ -212,9 +212,9 @@ var useFileUpload = exports.useFileUpload = function useFileUpload(props) {
|
|
|
212
212
|
e.stopPropagation();
|
|
213
213
|
setHighlightDropArea(true);
|
|
214
214
|
};
|
|
215
|
-
var
|
|
215
|
+
var _disableDropZone = function disableDropZone() {
|
|
216
216
|
setHighlightDropArea(false);
|
|
217
|
-
window.removeEventListener("focus",
|
|
217
|
+
window.removeEventListener("focus", _disableDropZone);
|
|
218
218
|
};
|
|
219
219
|
var onBeforeSelectEventCall = function onBeforeSelectEventCall($event, $files) {
|
|
220
220
|
var files = (0, _Utils.getValidFiles)($files, contenttype, extensions || "", filetype || "", chooseFilter, maxfilesize || "10", onError, listener);
|
|
@@ -233,6 +233,14 @@ var useFileUpload = exports.useFileUpload = function useFileUpload(props) {
|
|
|
233
233
|
}),
|
|
234
234
|
files: files.validFiles
|
|
235
235
|
});
|
|
236
|
+
if (onBeforeselect) {
|
|
237
|
+
var _listener$Widgets2;
|
|
238
|
+
var event = _objectSpread(_objectSpread({}, $event), {}, {
|
|
239
|
+
_reactName: "onBeforeselect"
|
|
240
|
+
});
|
|
241
|
+
onBeforeselect(event, listener === null || listener === void 0 || (_listener$Widgets2 = listener.Widgets) === null || _listener$Widgets2 === void 0 ? void 0 : _listener$Widgets2[name], files.validFiles);
|
|
242
|
+
}
|
|
243
|
+
// Proceed only if neither callback returns false
|
|
236
244
|
if (beforeSelectVal !== false) {
|
|
237
245
|
var _fileInputRef$current;
|
|
238
246
|
var filesWithIds = files.validFiles.map(function (file) {
|
|
@@ -345,12 +353,15 @@ var useFileUpload = exports.useFileUpload = function useFileUpload(props) {
|
|
|
345
353
|
onOk: function onOk() {
|
|
346
354
|
try {
|
|
347
355
|
if (deletedatasource) {
|
|
348
|
-
var _file$_response,
|
|
356
|
+
var _file$_response, _listener$Widgets3, _listener$App3;
|
|
349
357
|
deletedatasource._deleteFileObservable = (0, _eventNotifier.eventObserver)();
|
|
350
358
|
deleteFileProgress(file);
|
|
351
359
|
var fileName = ((_file$_response = file._response) === null || _file$_response === void 0 || (_file$_response = _file$_response[0]) === null || _file$_response === void 0 ? void 0 : _file$_response.fileName) || file.name;
|
|
352
360
|
deletedatasource.setInput("file", fileName);
|
|
353
|
-
|
|
361
|
+
var event = _objectSpread(_objectSpread({}, e), {}, {
|
|
362
|
+
_reactName: "onDelete"
|
|
363
|
+
});
|
|
364
|
+
onDelete === null || onDelete === void 0 || onDelete(event, listener === null || listener === void 0 || (_listener$Widgets3 = listener.Widgets) === null || _listener$Widgets3 === void 0 ? void 0 : _listener$Widgets3[name]);
|
|
354
365
|
listener && (listener === null || listener === void 0 || (_listener$App3 = listener.App) === null || _listener$App3 === void 0 ? void 0 : _listener$App3.notifyApp("File deleted successfully", "Success"));
|
|
355
366
|
}
|
|
356
367
|
} catch (error) {
|