@tsed/react-formio 1.13.3 → 1.13.6
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/components/form/form.stories.d.ts +25 -0
- package/dist/components/form/useForm.hook.d.ts +7 -3
- package/dist/components/index.d.ts +2 -0
- package/dist/index.js +36 -13
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +43 -22
- package/dist/index.modern.js.map +1 -1
- package/package.json +6 -6
- package/src/components/form/form.stories.tsx +58 -1
- package/src/components/form/useForm.hook.ts +35 -11
- package/src/components/index.ts +2 -0
- package/src/components/table/components/defaultCell.component.tsx +1 -1
- package/src/index.ts +0 -1
package/dist/index.modern.js
CHANGED
|
@@ -10,7 +10,6 @@ import Choices from 'choices.js';
|
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import { useTable, useFilters, useGroupBy, useSortBy, usePagination } from 'react-table';
|
|
12
12
|
import AllComponents from 'formiojs/components';
|
|
13
|
-
import noop$1, { get } from 'lodash';
|
|
14
13
|
import cloneDeep from 'lodash/cloneDeep';
|
|
15
14
|
import isEqual from 'lodash/isEqual';
|
|
16
15
|
import FormioUtils from 'formiojs/utils';
|
|
@@ -19,9 +18,10 @@ import FormioFormBuilder from 'formiojs/FormBuilder';
|
|
|
19
18
|
import Tooltip from 'tooltip.js';
|
|
20
19
|
import uniq from 'lodash/uniq';
|
|
21
20
|
import camelCase from 'lodash/camelCase';
|
|
21
|
+
import noop$1 from 'lodash';
|
|
22
22
|
import ReactDOM from 'react-dom';
|
|
23
23
|
import { createAction, createReducer, combine } from '@tsed/redux-utils';
|
|
24
|
-
import get
|
|
24
|
+
import get from 'lodash/get';
|
|
25
25
|
|
|
26
26
|
function _extends() {
|
|
27
27
|
_extends = Object.assign || function (target) {
|
|
@@ -539,7 +539,7 @@ function DefaultOperationButton(props) {
|
|
|
539
539
|
return /*#__PURE__*/React.createElement("button", {
|
|
540
540
|
className: classnames(className, ["btn", buttonOutline && "outline", buttonType].filter(Boolean).join("-"), `btn-${buttonSize}`),
|
|
541
541
|
onClick: stopPropagationWrapper(() => onClick(action))
|
|
542
|
-
}, icon ? /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("i", {
|
|
542
|
+
}, icon ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", {
|
|
543
543
|
className: iconClass(undefined, icon)
|
|
544
544
|
}), " ", title && " ") : null, title && /*#__PURE__*/React.createElement("span", {
|
|
545
545
|
className: icon && title ? "ml-1" : ""
|
|
@@ -868,9 +868,11 @@ function Card({
|
|
|
868
868
|
}, children));
|
|
869
869
|
}
|
|
870
870
|
|
|
871
|
-
function
|
|
871
|
+
function useEvent(event, callback, events) {
|
|
872
872
|
useEffect(() => {
|
|
873
|
-
|
|
873
|
+
if (callback) {
|
|
874
|
+
events.set(event, callback);
|
|
875
|
+
}
|
|
874
876
|
}, [callback, event, events]);
|
|
875
877
|
}
|
|
876
878
|
|
|
@@ -888,7 +890,24 @@ function useEvents(funcs) {
|
|
|
888
890
|
}
|
|
889
891
|
};
|
|
890
892
|
|
|
891
|
-
|
|
893
|
+
useEvent("onBlur", funcs["onBlur"], events.current);
|
|
894
|
+
useEvent("onPrevPage", funcs["onPrevPage"], events.current);
|
|
895
|
+
useEvent("onNextPage", funcs["onNextPage"], events.current);
|
|
896
|
+
useEvent("onCancel", funcs["onCancel"], events.current);
|
|
897
|
+
useEvent("onChange", funcs["onChange"], events.current);
|
|
898
|
+
useEvent("onCustomEvent", funcs["onCustomEvent"], events.current);
|
|
899
|
+
useEvent("onComponentChange", funcs["onComponentChange"], events.current);
|
|
900
|
+
useEvent("onSubmit", funcs["onSubmit"], events.current);
|
|
901
|
+
useEvent("onAsyncSubmit", funcs["onAsyncSubmit"], events.current);
|
|
902
|
+
useEvent("onSubmitDone", funcs["onSubmitDone"], events.current);
|
|
903
|
+
useEvent("onFormLoad", funcs["onFormLoad"], events.current);
|
|
904
|
+
useEvent("onError", funcs["onError"], events.current);
|
|
905
|
+
useEvent("onRender", funcs["onRender"], events.current);
|
|
906
|
+
useEvent("onAttach", funcs["onAttach"], events.current);
|
|
907
|
+
useEvent("onBuild", funcs["onBuild"], events.current);
|
|
908
|
+
useEvent("onFocus", funcs["onFocus"], events.current);
|
|
909
|
+
useEvent("onBlur", funcs["onBlur"], events.current);
|
|
910
|
+
useEvent("onInitialized", funcs["onInitialized"], events.current);
|
|
892
911
|
return {
|
|
893
912
|
events,
|
|
894
913
|
emit,
|
|
@@ -946,10 +965,8 @@ function useForm(props) {
|
|
|
946
965
|
if (event.startsWith("formio.")) {
|
|
947
966
|
const eventName = `on${event.charAt(7).toUpperCase()}${event.slice(8)}`;
|
|
948
967
|
|
|
949
|
-
if (eventName === "onChange") {
|
|
950
|
-
|
|
951
|
-
return;
|
|
952
|
-
}
|
|
968
|
+
if (eventName === "onChange" && !args[0].changed) {
|
|
969
|
+
return;
|
|
953
970
|
}
|
|
954
971
|
|
|
955
972
|
emit(eventName, ...args, instance.current);
|
|
@@ -972,6 +989,10 @@ function useForm(props) {
|
|
|
972
989
|
useEffect(() => {
|
|
973
990
|
if (instance.current) {
|
|
974
991
|
instance.current.ready.then(formio => {
|
|
992
|
+
if (isEqual(formio.submission.data, submission == null ? void 0 : submission.data)) {
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
|
|
975
996
|
submission && (formio.submission = cloneDeep(submission));
|
|
976
997
|
});
|
|
977
998
|
}
|
|
@@ -1332,7 +1353,7 @@ function NamedFormAccess({
|
|
|
1332
1353
|
children
|
|
1333
1354
|
}) {
|
|
1334
1355
|
const [isValid, setIsValid] = useState(true);
|
|
1335
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Form, {
|
|
1356
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Form, {
|
|
1336
1357
|
name: name,
|
|
1337
1358
|
form: form[name],
|
|
1338
1359
|
submission: submissions[name],
|
|
@@ -7813,7 +7834,7 @@ function DefaultCell({
|
|
|
7813
7834
|
render = f => f
|
|
7814
7835
|
}) {
|
|
7815
7836
|
if (value === undefined) {
|
|
7816
|
-
return /*#__PURE__*/React.createElement(
|
|
7837
|
+
return /*#__PURE__*/React.createElement("span", null);
|
|
7817
7838
|
}
|
|
7818
7839
|
|
|
7819
7840
|
const rendered = render(value);
|
|
@@ -7882,7 +7903,7 @@ function SliderColumnFilter({
|
|
|
7882
7903
|
});
|
|
7883
7904
|
return [min, max];
|
|
7884
7905
|
}, [id, preFilteredRows]);
|
|
7885
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("input", {
|
|
7906
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", {
|
|
7886
7907
|
type: "range",
|
|
7887
7908
|
min: min,
|
|
7888
7909
|
max: max,
|
|
@@ -8048,12 +8069,12 @@ function selectRoot(name, state) {
|
|
|
8048
8069
|
|
|
8049
8070
|
return state => selectRoot(name, state);
|
|
8050
8071
|
}
|
|
8051
|
-
const selectError = (name, state) => get
|
|
8052
|
-
const selectIsActive = (name, state) => get
|
|
8072
|
+
const selectError = (name, state) => get(selectRoot(name, state), "error");
|
|
8073
|
+
const selectIsActive = (name, state) => get(selectRoot(name, state), "isActive");
|
|
8053
8074
|
function oneOfIsActive(...names) {
|
|
8054
8075
|
return state => {
|
|
8055
8076
|
return !!names.find(name => {
|
|
8056
|
-
return get
|
|
8077
|
+
return get(state, `${name}.isActive`, get(state, `${name}.current.isActive`));
|
|
8057
8078
|
});
|
|
8058
8079
|
};
|
|
8059
8080
|
}
|
|
@@ -8098,7 +8119,7 @@ const saveAction = (formId, action, done = noop) => async dispatch => {
|
|
|
8098
8119
|
dispatch(sendAction(ACTION, {
|
|
8099
8120
|
action
|
|
8100
8121
|
}));
|
|
8101
|
-
const formio = getFormio(formId, get
|
|
8122
|
+
const formio = getFormio(formId, get(action, "data._id", ""));
|
|
8102
8123
|
|
|
8103
8124
|
try {
|
|
8104
8125
|
const result = await formio.saveAction(action);
|
|
@@ -8382,9 +8403,9 @@ const authReducer = createReducer({
|
|
|
8382
8403
|
}, createInitialState$4)(AUTH);
|
|
8383
8404
|
|
|
8384
8405
|
const selectAuth = state => selectRoot(AUTH, state);
|
|
8385
|
-
const selectUser = state => get
|
|
8386
|
-
const selectRoles = state => get
|
|
8387
|
-
const selectIsAuthenticated = state => get
|
|
8406
|
+
const selectUser = state => get(selectAuth(state), "user");
|
|
8407
|
+
const selectRoles = state => get(selectAuth(state), "roles");
|
|
8408
|
+
const selectIsAuthenticated = state => get(selectAuth(state), "authenticated");
|
|
8388
8409
|
|
|
8389
8410
|
function hasRole(auth, role) {
|
|
8390
8411
|
return auth.is[role];
|
|
@@ -8410,7 +8431,7 @@ function checkRoleFormAccess(auth, form, roles) {
|
|
|
8410
8431
|
return true;
|
|
8411
8432
|
}
|
|
8412
8433
|
|
|
8413
|
-
return roles.includes("owner") && get
|
|
8434
|
+
return roles.includes("owner") && get(form, "owner") === get(auth, "user._id");
|
|
8414
8435
|
}
|
|
8415
8436
|
|
|
8416
8437
|
return true;
|
|
@@ -9015,5 +9036,5 @@ const defaultFormioReducer = combine(authReducer, actionsReducer, actionReducer,
|
|
|
9015
9036
|
}
|
|
9016
9037
|
}), submissionReducer("submission"), submissionsReducer("submissions"));
|
|
9017
9038
|
|
|
9018
|
-
export { ACTION, ACTIONS, ACTION_INFO, AUTH, ActionsTable, Alert, ButtonTab, Card, DefaultArrowSort, DefaultCell, DefaultCellHeader, DefaultCellOperations, DefaultColumnFilter, DefaultOperationButton, Form, FormAccess, FormAction, FormBuilder, FormControl, FormEdit, FormEditCTAs, FormParameters, FormSettings, FormsTable, InputTags, InputText, Loader, Modal, Pagination, ReactComponent, RemoveModal, Select, SelectColumnFilter, SliderColumnFilter, SubmissionsTable, Table, Tabs, actionInfoReducer, actionReducer, actionsReducer, authReducer, checkRoleFormAccess, clearActionError, clearFormError, clearSubmissionError, createInitialState$8 as createInitialState, defaultDisplayChoices, defaultFormioReducer, deleteAction, deleteForm, deleteSubmission, failAction, failActionInfo, failActions, failForm, failForms, failSubmission, failSubmissions, failUser, formAccessUser, formReducer, formsReducer, getAccess, getAction, getActionInfo, getActionUrl, getActions, getForm, getFormUrl, getForms, getProjectAccess, getSubmission, getSubmissionUrl, getSubmissions, hasRole, hasRoles, iconClass, initAuth, isAuthorized, logout, logoutUser, oneOfIsActive, projectAccessUser, receiveAction, receiveActionInfo, receiveActions, receiveForm, receiveForms, receiveSubmission, receiveSubmissions, receiveUser, refreshForms, refreshSubmissions, requestAction, requestActionInfo, requestActions, requestForm, requestForms, requestSubmission, requestSubmissions, requestUser, resetAction, resetActionInfo, resetActions, resetForm, resetForms, resetSubmission, resetSubmissions, saveAction, saveForm, saveSubmission, selectAction, selectActionInfo, selectActions, selectAuth, selectAvailableActions, selectError, selectForm, selectForms, selectFormsParameters, selectIsActive, selectIsAuthenticated, selectRoles, selectRoot, selectSubmission, selectSubmissions, selectSubmissionsParameters, selectUser, sendAction, sendForm, sendSubmission, setUser, submissionAccessUser, submissionReducer, submissionsReducer, useModal, useOperations, useTooltip, userForms, userRoles };
|
|
9039
|
+
export { ACTION, ACTIONS, ACTION_INFO, AUTH, ActionsTable, Alert, ButtonTab, Card, DefaultArrowSort, DefaultCell, DefaultCellHeader, DefaultCellOperations, DefaultColumnFilter, DefaultOperationButton, Form, FormAccess, FormAction, FormBuilder, FormControl, FormEdit, FormEditCTAs, FormParameters, FormSettings, FormsTable, InputTags, InputText, Loader, Modal, Pagination, ReactComponent, RemoveModal, Select, SelectColumnFilter, SliderColumnFilter, SubmissionsTable, Table, Tabs, actionInfoReducer, actionReducer, actionsReducer, authReducer, checkRoleFormAccess, clearActionError, clearFormError, clearSubmissionError, createInitialState$8 as createInitialState, defaultDisplayChoices, defaultFormioReducer, deleteAction, deleteForm, deleteSubmission, failAction, failActionInfo, failActions, failForm, failForms, failSubmission, failSubmissions, failUser, formAccessUser, formReducer, formsReducer, getAccess, getAction, getActionInfo, getActionUrl, getActions, getForm, getFormUrl, getForms, getProjectAccess, getSubmission, getSubmissionUrl, getSubmissions, hasRole, hasRoles, iconClass, initAuth, isAuthorized, logout, logoutUser, oneOfIsActive, projectAccessUser, receiveAction, receiveActionInfo, receiveActions, receiveForm, receiveForms, receiveSubmission, receiveSubmissions, receiveUser, refreshForms, refreshSubmissions, requestAction, requestActionInfo, requestActions, requestForm, requestForms, requestSubmission, requestSubmissions, requestUser, resetAction, resetActionInfo, resetActions, resetForm, resetForms, resetSubmission, resetSubmissions, saveAction, saveForm, saveSubmission, selectAction, selectActionInfo, selectActions, selectAuth, selectAvailableActions, selectError, selectForm, selectForms, selectFormsParameters, selectIsActive, selectIsAuthenticated, selectRoles, selectRoot, selectSubmission, selectSubmissions, selectSubmissionsParameters, selectUser, sendAction, sendForm, sendSubmission, setUser, submissionAccessUser, submissionReducer, submissionsReducer, useForm, useFormEdit, useModal, useOperations, useTooltip, userForms, userRoles };
|
|
9019
9040
|
//# sourceMappingURL=index.modern.js.map
|