@tsed/react-formio 2.3.2 → 3.0.0-alpha.1
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/chunks/index.js +45 -0
- package/dist/chunks/index.js.map +1 -0
- package/dist/components/actions-table/actionsTable.component.d.ts +10 -11
- package/dist/components/actions-table/actionsTable.component.js +53 -0
- package/dist/components/actions-table/actionsTable.component.js.map +1 -0
- package/dist/components/alert/alert.component.d.ts +5 -6
- package/dist/components/alert/alert.component.js +24 -0
- package/dist/components/alert/alert.component.js.map +1 -0
- package/dist/components/card/card.component.d.ts +6 -7
- package/dist/components/card/card.component.js +12 -0
- package/dist/components/card/card.component.js.map +1 -0
- package/dist/components/form/form.component.d.ts +62 -63
- package/dist/components/form/form.component.js +64 -0
- package/dist/components/form/form.component.js.map +1 -0
- package/dist/components/form/useForm.hook.d.ts +59 -60
- package/dist/components/form/useForm.hook.js +64 -0
- package/dist/components/form/useForm.hook.js.map +1 -0
- package/dist/components/form-access/formAccess.component.d.ts +9 -9
- package/dist/components/form-access/formAccess.component.js +95 -0
- package/dist/components/form-access/formAccess.component.js.map +1 -0
- package/dist/components/form-access/formAccess.schema.d.ts +5 -5
- package/dist/components/form-access/formAccess.schema.js +164 -0
- package/dist/components/form-access/formAccess.schema.js.map +1 -0
- package/dist/components/form-access/formAccess.utils.d.ts +24 -24
- package/dist/components/form-access/formAccess.utils.js +68 -0
- package/dist/components/form-access/formAccess.utils.js.map +1 -0
- package/dist/components/form-action/formAction.component.d.ts +9 -9
- package/dist/components/form-action/formAction.component.js +32 -0
- package/dist/components/form-action/formAction.component.js.map +1 -0
- package/dist/components/form-builder/formBuilder.component.d.ts +53 -53
- package/dist/components/form-builder/formBuilder.component.js +142 -0
- package/dist/components/form-builder/formBuilder.component.js.map +1 -0
- package/dist/components/form-control/formControl.component.d.ts +14 -14
- package/dist/components/form-control/formControl.component.js +26 -0
- package/dist/components/form-control/formControl.component.js.map +1 -0
- package/dist/components/form-edit/formCtas.component.d.ts +28 -28
- package/dist/components/form-edit/formCtas.component.js +70 -0
- package/dist/components/form-edit/formCtas.component.js.map +1 -0
- package/dist/components/form-edit/formEdit.component.d.ts +18 -19
- package/dist/components/form-edit/formEdit.component.js +57 -0
- package/dist/components/form-edit/formEdit.component.js.map +1 -0
- package/dist/components/form-edit/formEdit.reducer.d.ts +10 -10
- package/dist/components/form-edit/formEdit.reducer.js +65 -0
- package/dist/components/form-edit/formEdit.reducer.js.map +1 -0
- package/dist/components/form-edit/formParameters.component.d.ts +34 -34
- package/dist/components/form-edit/formParameters.component.js +92 -0
- package/dist/components/form-edit/formParameters.component.js.map +1 -0
- package/dist/components/form-edit/useFormEdit.hook.d.ts +29 -29
- package/dist/components/form-edit/useFormEdit.hook.js +36 -0
- package/dist/components/form-edit/useFormEdit.hook.js.map +1 -0
- package/dist/components/form-settings/formSettings.component.d.ts +7 -8
- package/dist/components/form-settings/formSettings.component.js +38 -0
- package/dist/components/form-settings/formSettings.component.js.map +1 -0
- package/dist/components/form-settings/formSettings.schema.d.ts +2 -2
- package/dist/components/form-settings/formSettings.schema.js +60 -0
- package/dist/components/form-settings/formSettings.schema.js.map +1 -0
- package/dist/components/form-settings/formSettings.utils.d.ts +8 -8
- package/dist/components/form-settings/formSettings.utils.js +23 -0
- package/dist/components/form-settings/formSettings.utils.js.map +1 -0
- package/dist/components/forms-table/components/formCell.component.d.ts +6 -7
- package/dist/components/forms-table/components/formCell.component.js +50 -0
- package/dist/components/forms-table/components/formCell.component.js.map +1 -0
- package/dist/components/forms-table/formsTable.component.d.ts +10 -11
- package/dist/components/forms-table/formsTable.component.js +29 -0
- package/dist/components/forms-table/formsTable.component.js.map +1 -0
- package/dist/components/index.d.ts +25 -26
- package/dist/components/index.js +86 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/input-tags/inputTags.component.d.ts +18 -19
- package/dist/components/input-tags/inputTags.component.js +37 -0
- package/dist/components/input-tags/inputTags.component.js.map +1 -0
- package/dist/components/input-text/inputText.component.d.ts +27 -28
- package/dist/components/input-text/inputText.component.js +70 -0
- package/dist/components/input-text/inputText.component.js.map +1 -0
- package/dist/components/loader/loader.component.d.ts +17 -17
- package/dist/components/loader/loader.component.js +26 -0
- package/dist/components/loader/loader.component.js.map +1 -0
- package/dist/components/modal/modal.component.d.ts +15 -15
- package/dist/components/modal/modal.component.js +62 -0
- package/dist/components/modal/modal.component.js.map +1 -0
- package/dist/components/modal/removeModal.component.d.ts +9 -9
- package/dist/components/modal/removeModal.component.js +71 -0
- package/dist/components/modal/removeModal.component.js.map +1 -0
- package/dist/components/pagination/pagination.component.d.ts +17 -18
- package/dist/components/pagination/pagination.component.js +87 -0
- package/dist/components/pagination/pagination.component.js.map +1 -0
- package/dist/components/select/select.component.d.ts +14 -14
- package/dist/components/select/select.component.js +60 -0
- package/dist/components/select/select.component.js.map +1 -0
- package/dist/components/submissions-table/submissionsTable.component.d.ts +6 -7
- package/dist/components/submissions-table/submissionsTable.component.js +11 -0
- package/dist/components/submissions-table/submissionsTable.component.js.map +1 -0
- package/dist/components/table/components/defaultArrowSort.component.d.ts +1 -2
- package/dist/components/table/components/defaultArrowSort.component.js +10 -0
- package/dist/components/table/components/defaultArrowSort.component.js.map +1 -0
- package/dist/components/table/components/defaultCell.component.d.ts +1 -2
- package/dist/components/table/components/defaultCell.component.js +11 -0
- package/dist/components/table/components/defaultCell.component.js.map +1 -0
- package/dist/components/table/components/defaultCellHeader.component.d.ts +5 -6
- package/dist/components/table/components/defaultCellHeader.component.js +14 -0
- package/dist/components/table/components/defaultCellHeader.component.js.map +1 -0
- package/dist/components/table/components/defaultCellOperations.component.d.ts +12 -13
- package/dist/components/table/components/defaultCellOperations.component.js +21 -0
- package/dist/components/table/components/defaultCellOperations.component.js.map +1 -0
- package/dist/components/table/components/defaultCells.component.d.ts +4 -5
- package/dist/components/table/components/defaultCells.component.js +23 -0
- package/dist/components/table/components/defaultCells.component.js.map +1 -0
- package/dist/components/table/components/defaultOperationButton.component.d.ts +15 -14
- package/dist/components/table/components/defaultOperationButton.component.js +45 -0
- package/dist/components/table/components/defaultOperationButton.component.js.map +1 -0
- package/dist/components/table/components/defaultRow.component.d.ts +12 -12
- package/dist/components/table/components/defaultRow.component.js +25 -0
- package/dist/components/table/components/defaultRow.component.js.map +1 -0
- package/dist/components/table/components/dragNDropContainer.d.ts +4 -4
- package/dist/components/table/components/dragNDropContainer.js +10 -0
- package/dist/components/table/components/dragNDropContainer.js.map +1 -0
- package/dist/components/table/filters/defaultColumnFilter.component.d.ts +5 -6
- package/dist/components/table/filters/defaultColumnFilter.component.js +32 -0
- package/dist/components/table/filters/defaultColumnFilter.component.js.map +1 -0
- package/dist/components/table/filters/selectColumnFilter.component.d.ts +10 -11
- package/dist/components/table/filters/selectColumnFilter.component.js +34 -0
- package/dist/components/table/filters/selectColumnFilter.component.js.map +1 -0
- package/dist/components/table/filters/sliderColumnFilter.component.d.ts +2 -3
- package/dist/components/table/filters/sliderColumnFilter.component.js +27 -0
- package/dist/components/table/filters/sliderColumnFilter.component.js.map +1 -0
- package/dist/components/table/hooks/useCustomTable.hook.d.ts +128 -128
- package/dist/components/table/hooks/useCustomTable.hook.js +130 -0
- package/dist/components/table/hooks/useCustomTable.hook.js.map +1 -0
- package/dist/components/table/hooks/useDragnDropRow.hook.d.ts +272 -274
- package/dist/components/table/hooks/useDragnDropRow.hook.js +40 -0
- package/dist/components/table/hooks/useDragnDropRow.hook.js.map +1 -0
- package/dist/components/table/hooks/useOperations.hook.d.ts +11 -11
- package/dist/components/table/hooks/useOperations.hook.js +25 -0
- package/dist/components/table/hooks/useOperations.hook.js.map +1 -0
- package/dist/components/table/index.d.ts +15 -15
- package/dist/components/table/index.js +35 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/table/table.component.d.ts +3 -3
- package/dist/components/table/table.component.js +81 -0
- package/dist/components/table/table.component.js.map +1 -0
- package/dist/components/table/utils/getPageNumbers.d.ts +3 -3
- package/dist/components/table/utils/getPageNumbers.js +25 -0
- package/dist/components/table/utils/getPageNumbers.js.map +1 -0
- package/dist/components/table/utils/mapFormToColumns.d.ts +3 -3
- package/dist/components/table/utils/mapFormToColumns.js +23 -0
- package/dist/components/table/utils/mapFormToColumns.js.map +1 -0
- package/dist/components/table/utils/swapElements.d.ts +1 -1
- package/dist/components/table/utils/swapElements.js +5 -0
- package/dist/components/table/utils/swapElements.js.map +1 -0
- package/dist/components/tabs/tabs.component.d.ts +19 -19
- package/dist/components/tabs/tabs.component.js +72 -0
- package/dist/components/tabs/tabs.component.js.map +1 -0
- package/dist/hooks/useTooltip.d.ts +2 -3
- package/dist/hooks/useTooltip.js +12 -0
- package/dist/hooks/useTooltip.js.map +1 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.js +107 -7651
- package/dist/index.js.map +1 -1
- package/dist/interfaces/ActionSchema.d.ts +23 -23
- package/dist/interfaces/ActionSchema.js +2 -0
- package/dist/interfaces/ActionSchema.js.map +1 -0
- package/dist/interfaces/ColumnIdentifier.d.ts +14 -14
- package/dist/interfaces/ColumnIdentifier.js +2 -0
- package/dist/interfaces/ColumnIdentifier.js.map +1 -0
- package/dist/interfaces/FormOptions.d.ts +10 -10
- package/dist/interfaces/FormOptions.js +2 -0
- package/dist/interfaces/FormOptions.js.map +1 -0
- package/dist/interfaces/FormSchema.d.ts +12 -12
- package/dist/interfaces/FormSchema.js +2 -0
- package/dist/interfaces/FormSchema.js.map +1 -0
- package/dist/interfaces/Operation.d.ts +29 -29
- package/dist/interfaces/Operation.js +2 -0
- package/dist/interfaces/Operation.js.map +1 -0
- package/dist/interfaces/QueryOptions.d.ts +23 -23
- package/dist/interfaces/QueryOptions.js +2 -0
- package/dist/interfaces/QueryOptions.js.map +1 -0
- package/dist/interfaces/RoleSchema.d.ts +6 -6
- package/dist/interfaces/RoleSchema.js +2 -0
- package/dist/interfaces/RoleSchema.js.map +1 -0
- package/dist/interfaces/Submission.d.ts +5 -5
- package/dist/interfaces/Submission.js +2 -0
- package/dist/interfaces/Submission.js.map +1 -0
- package/dist/interfaces/index.d.ts +8 -8
- package/dist/interfaces/index.js +2 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/react-app-env.d.js +2 -0
- package/dist/react-app-env.d.js.map +1 -0
- package/dist/react-table.d.js +2 -0
- package/dist/react-table.d.js.map +1 -0
- package/dist/typings.d.js +2 -0
- package/dist/typings.d.js.map +1 -0
- package/dist/utils/callLast.d.ts +1 -1
- package/dist/utils/callLast.js +10 -0
- package/dist/utils/callLast.js.map +1 -0
- package/dist/utils/getEventValue.d.ts +1 -1
- package/dist/utils/getEventValue.js +8 -0
- package/dist/utils/getEventValue.js.map +1 -0
- package/dist/utils/iconClass.d.ts +1 -1
- package/dist/utils/iconClass.js +9 -0
- package/dist/utils/iconClass.js.map +1 -0
- package/dist/utils/mapPagination.d.ts +1 -1
- package/dist/utils/mapPagination.js +11 -0
- package/dist/utils/mapPagination.js.map +1 -0
- package/dist/utils/stopPropagationWrapper.d.ts +1 -1
- package/dist/utils/stopPropagationWrapper.js +7 -0
- package/dist/utils/stopPropagationWrapper.js.map +1 -0
- package/package.json +23 -13
- package/src/components/actions-table/actionsTable.component.spec.tsx +5 -6
- package/src/components/actions-table/actionsTable.component.tsx +1 -1
- package/src/components/alert/alert.component.spec.tsx +0 -1
- package/src/components/alert/alert.component.tsx +0 -2
- package/src/components/alert/alert.stories.tsx +0 -2
- package/src/components/card/card.component.spec.tsx +0 -1
- package/src/components/card/card.component.tsx +1 -2
- package/src/components/card/card.stories.tsx +0 -2
- package/src/components/form/form.component.spec.tsx +1 -1
- package/src/components/form/form.component.tsx +0 -1
- package/src/components/form/form.stories.tsx +2 -3
- package/src/components/form-access/formAccess.component.tsx +1 -2
- package/src/components/form-action/formAction.component.tsx +2 -1
- package/src/components/form-action/formAction.stories.tsx +0 -2
- package/src/components/form-builder/formBuilder.component.tsx +4 -4
- package/src/components/form-builder/formBuilder.stories.tsx +0 -2
- package/src/components/form-control/formControl.component.spec.tsx +0 -1
- package/src/components/form-control/formControl.component.tsx +5 -5
- package/src/components/form-control/formControl.stories.tsx +0 -2
- package/src/components/form-edit/formCtas.component.tsx +1 -1
- package/src/components/form-edit/formEdit.component.tsx +0 -1
- package/src/components/form-edit/formEdit.reducer.ts +0 -1
- package/src/components/form-edit/formEdit.stories.tsx +0 -2
- package/src/components/form-edit/formParameters.component.tsx +1 -1
- package/src/components/form-settings/formSettings.component.spec.tsx +5 -6
- package/src/components/form-settings/formSettings.component.tsx +1 -1
- package/src/components/form-settings/formSettings.stories.tsx +0 -2
- package/src/components/forms-table/components/formCell.component.tsx +0 -1
- package/src/components/forms-table/formsTable.component.tsx +0 -2
- package/src/components/forms-table/formsTable.stories.tsx +0 -1
- package/src/components/index.ts +0 -1
- package/src/components/input-tags/inputTags.component.tsx +1 -1
- package/src/components/input-tags/inputTags.stories.tsx +1 -1
- package/src/components/input-text/inputText.component.spec.tsx +0 -1
- package/src/components/input-text/inputText.component.tsx +1 -1
- package/src/components/input-text/inputText.stories.tsx +1 -1
- package/src/components/loader/loader.component.spec.tsx +1 -1
- package/src/components/loader/loader.component.tsx +1 -1
- package/src/components/loader/loader.stories.tsx +0 -2
- package/src/components/modal/modal.component.spec.tsx +2 -5
- package/src/components/modal/modal.component.tsx +1 -1
- package/src/components/modal/modal.stories.tsx +0 -2
- package/src/components/modal/removeModal.component.tsx +1 -1
- package/src/components/pagination/pagination.component.spec.tsx +7 -10
- package/src/components/pagination/pagination.component.tsx +1 -1
- package/src/components/pagination/pagination.stories.tsx +1 -1
- package/src/components/select/select.component.spec.tsx +1 -2
- package/src/components/select/select.component.tsx +2 -2
- package/src/components/select/select.stories.tsx +1 -1
- package/src/components/submissions-table/submissionsTable.component.tsx +0 -2
- package/src/components/submissions-table/submissionsTable.stories.tsx +4 -4
- package/src/components/table/components/defaultArrowSort.component.tsx +0 -2
- package/src/components/table/components/defaultCell.component.tsx +0 -2
- package/src/components/table/components/defaultCellHeader.component.tsx +0 -1
- package/src/components/table/components/defaultCellOperations.component.tsx +0 -2
- package/src/components/table/components/defaultCells.component.tsx +0 -1
- package/src/components/table/components/defaultOperationButton.component.tsx +5 -0
- package/src/components/table/components/defaultRow.component.tsx +2 -1
- package/src/components/table/components/dragNDropContainer.tsx +1 -1
- package/src/components/table/filters/defaultColumnFilter.component.spec.tsx +2 -5
- package/src/components/table/filters/defaultColumnFilter.component.tsx +2 -1
- package/src/components/table/filters/selectColumnFilter.component.spec.tsx +3 -6
- package/src/components/table/filters/selectColumnFilter.component.tsx +0 -1
- package/src/components/table/filters/sliderColumnFilter.component.tsx +7 -10
- package/src/components/table/hooks/useCustomTable.hook.tsx +16 -20
- package/src/components/table/hooks/useOperations.hook.tsx +1 -1
- package/src/components/table/table.component.tsx +1 -1
- package/src/components/table/table.stories.tsx +8 -8
- package/src/components/table/utils/mapFormToColumns.tsx +0 -1
- package/src/components/tabs/tabs.component.spec.tsx +2 -2
- package/src/components/tabs/tabs.component.stories.tsx +1 -1
- package/src/components/tabs/tabs.component.tsx +1 -1
- package/src/react-table.d.ts +2 -0
- package/src/utils/iconClass.ts +3 -1
- package/tsconfig.app.json +11 -0
- package/tsconfig.json +8 -6
- package/tsconfig.spec.json +14 -0
- package/vite.config.mts +69 -0
- package/vitest.config.mts +21 -0
- package/.eslintignore +0 -13
- package/.eslintrc.js +0 -7
- package/coverage.json +0 -6
- package/dist/components/actions-table/actionsTable.component.spec.d.ts +0 -1
- package/dist/components/actions-table/actionsTable.stories.d.ts +0 -40
- package/dist/components/alert/alert.component.spec.d.ts +0 -1
- package/dist/components/alert/alert.stories.d.ts +0 -15
- package/dist/components/card/card.component.spec.d.ts +0 -1
- package/dist/components/card/card.stories.d.ts +0 -16
- package/dist/components/form/form.component.spec.d.ts +0 -1
- package/dist/components/form/form.stories.d.ts +0 -6445
- package/dist/components/form-access/formAccess.stories.d.ts +0 -21
- package/dist/components/form-access/formAccess.utils.spec.d.ts +0 -1
- package/dist/components/form-action/formAction.stories.d.ts +0 -409
- package/dist/components/form-builder/formBuilder.stories.d.ts +0 -5989
- package/dist/components/form-control/formControl.component.spec.d.ts +0 -1
- package/dist/components/form-control/formControl.stories.d.ts +0 -58
- package/dist/components/form-edit/formEdit.stories.d.ts +0 -396
- package/dist/components/form-settings/formSettings.component.spec.d.ts +0 -1
- package/dist/components/form-settings/formSettings.stories.d.ts +0 -58
- package/dist/components/form-settings/formSettings.utils.spec.d.ts +0 -1
- package/dist/components/forms-table/formsTable.stories.d.ts +0 -117
- package/dist/components/input-tags/inputTags.stories.d.ts +0 -76
- package/dist/components/input-text/inputText.component.spec.d.ts +0 -1
- package/dist/components/input-text/inputText.stories.d.ts +0 -101
- package/dist/components/loader/loader.component.spec.d.ts +0 -1
- package/dist/components/loader/loader.stories.d.ts +0 -15
- package/dist/components/modal/modal.component.spec.d.ts +0 -1
- package/dist/components/modal/modal.stories.d.ts +0 -44
- package/dist/components/pagination/pagination.component.spec.d.ts +0 -1
- package/dist/components/pagination/pagination.stories.d.ts +0 -16
- package/dist/components/react-component/reactComponent.component.d.ts +0 -90
- package/dist/components/select/select.component.spec.d.ts +0 -1
- package/dist/components/select/select.stories.d.ts +0 -164
- package/dist/components/submissions-table/submissionsTable.stories.d.ts +0 -649
- package/dist/components/table/filters/defaultColumnFilter.component.spec.d.ts +0 -1
- package/dist/components/table/filters/selectColumnFilter.component.spec.d.ts +0 -1
- package/dist/components/table/table.stories.d.ts +0 -71
- package/dist/components/table/utils/swapElements.spec.d.ts +0 -1
- package/dist/components/tabs/tabs.component.spec.d.ts +0 -1
- package/dist/components/tabs/tabs.component.stories.d.ts +0 -47
- package/dist/index.modern.js +0 -7435
- package/dist/index.modern.js.map +0 -1
- package/dist/setupTests.d.ts +0 -1
- package/jest.config.js +0 -6
- package/src/components/react-component/reactComponent.component.tsx +0 -197
- package/src/setupTests.tsx +0 -5
- package/tsconfig.node.json +0 -8
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export interface FormAccessProps {
|
|
4
|
-
form: Partial<FormSchema>;
|
|
5
|
-
roles: any;
|
|
6
|
-
onSubmit?: Function;
|
|
7
|
-
options?: FormOptions;
|
|
8
|
-
}
|
|
9
|
-
export declare function FormAccess(props: PropsWithChildren<FormAccessProps>):
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { FormOptions, FormSchema } from '../../interfaces';
|
|
3
|
+
export interface FormAccessProps {
|
|
4
|
+
form: Partial<FormSchema>;
|
|
5
|
+
roles: any;
|
|
6
|
+
onSubmit?: Function;
|
|
7
|
+
options?: FormOptions;
|
|
8
|
+
}
|
|
9
|
+
export declare function FormAccess(props: PropsWithChildren<FormAccessProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsxs as a, jsx as e, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as f, useState as g, useCallback as A, useEffect as N } from "react";
|
|
3
|
+
import { Card as d } from "../card/card.component.js";
|
|
4
|
+
import { Form as v } from "../form/form.component.js";
|
|
5
|
+
import { getFormAccess as S, dataAccessToSubmissions as b, updateSubmissions as x, shouldUpdate as p, submissionsToDataAccess as F } from "./formAccess.utils.js";
|
|
6
|
+
function T({ form: s, roles: r, onSubmit: l, options: t }) {
|
|
7
|
+
const o = f(() => S(r), [r]), [i, n] = g(() => b(s, o)), m = A(
|
|
8
|
+
(c, h) => {
|
|
9
|
+
x(c, h, i, n);
|
|
10
|
+
},
|
|
11
|
+
[i]
|
|
12
|
+
);
|
|
13
|
+
return N(() => {
|
|
14
|
+
const c = b(s, o);
|
|
15
|
+
s != null && s._id && (p("access", i.access, c) || p("submissionAccess", i.submissionAccess, c)) && n(c);
|
|
16
|
+
}, [s == null ? void 0 : s._id]), {
|
|
17
|
+
options: t,
|
|
18
|
+
form: o,
|
|
19
|
+
type: s.type,
|
|
20
|
+
submissions: i,
|
|
21
|
+
onChange: m,
|
|
22
|
+
onSubmit: () => {
|
|
23
|
+
l && l(F(s, i));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function w({ name: s, form: r, submissions: l, options: t, onChange: o, onSubmit: i, children: n }) {
|
|
28
|
+
const [m, c] = g(!0);
|
|
29
|
+
return /* @__PURE__ */ a(y, { children: [
|
|
30
|
+
/* @__PURE__ */ e(
|
|
31
|
+
v,
|
|
32
|
+
{
|
|
33
|
+
name: s,
|
|
34
|
+
form: r[s],
|
|
35
|
+
submission: l[s],
|
|
36
|
+
onChange: ({ data: h, isValid: u }) => {
|
|
37
|
+
u && o(s, { data: h }), c(u);
|
|
38
|
+
},
|
|
39
|
+
options: t
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ e("button", { disabled: !m, className: "mt-5 btn btn-primary", onClick: i, children: "Save access" }),
|
|
43
|
+
n,
|
|
44
|
+
/* @__PURE__ */ e("div", { className: "alert alert-warning mt-5", children: "Elevated permissions allow users to access and modify other user's entities. Assign with caution." })
|
|
45
|
+
] });
|
|
46
|
+
}
|
|
47
|
+
function O(s) {
|
|
48
|
+
const { type: r, form: l, submissions: t, options: o, onChange: i, onSubmit: n } = T(s);
|
|
49
|
+
return /* @__PURE__ */ a("div", { children: [
|
|
50
|
+
s.children,
|
|
51
|
+
/* @__PURE__ */ a("div", { className: "flex mb-5", children: [
|
|
52
|
+
/* @__PURE__ */ e(d, { label: "Manage submission access", className: "flex-1", children: /* @__PURE__ */ e(
|
|
53
|
+
w,
|
|
54
|
+
{
|
|
55
|
+
name: "submissionAccess",
|
|
56
|
+
form: l,
|
|
57
|
+
submissions: t,
|
|
58
|
+
onChange: i,
|
|
59
|
+
onSubmit: n,
|
|
60
|
+
options: o,
|
|
61
|
+
children: s.children
|
|
62
|
+
}
|
|
63
|
+
) }),
|
|
64
|
+
/* @__PURE__ */ e("div", { className: "w-1/4 pl-4", children: /* @__PURE__ */ a(d, { label: "About Submission Data Permissions", children: [
|
|
65
|
+
/* @__PURE__ */ e("p", { children: "Submission Data Permissions allow you to control who can create, view, and modify form submission data." }),
|
|
66
|
+
/* @__PURE__ */ a("ul", { className: "mt-5 pl-7 list-disc", children: [
|
|
67
|
+
/* @__PURE__ */ a("li", { className: "pb-2", children: [
|
|
68
|
+
/* @__PURE__ */ e("strong", { children: "Own Permissions" }),
|
|
69
|
+
" - These permissions apply if the user is the original creator of the submission data and is listed as the owner of the submission in submission.owner. This allows users to create and edit their own submission data without seeing other user's data."
|
|
70
|
+
] }),
|
|
71
|
+
/* @__PURE__ */ a("li", { children: [
|
|
72
|
+
/* @__PURE__ */ e("strong", { children: "All Permissions" }),
|
|
73
|
+
" - These permissions apply to all submission data regardless of who owns it."
|
|
74
|
+
] })
|
|
75
|
+
] })
|
|
76
|
+
] }) })
|
|
77
|
+
] }),
|
|
78
|
+
/* @__PURE__ */ a("div", { className: "flex mb-5", children: [
|
|
79
|
+
/* @__PURE__ */ e(d, { label: `Manage ${r} definition access`, className: "flex-1", children: /* @__PURE__ */ e(w, { name: "access", form: l, submissions: t, onChange: i, onSubmit: n, options: o, children: s.children }) }),
|
|
80
|
+
/* @__PURE__ */ e("div", { className: "w-1/4 pl-4", children: /* @__PURE__ */ a(d, { label: "About Form Definition Access", children: [
|
|
81
|
+
/* @__PURE__ */ e("p", { children: "These permissions allow you to give access to a single form's JSON definition so they can render the form." }),
|
|
82
|
+
/* @__PURE__ */ e("p", { children: "Typically you will want to allow all of your roles to be able to Read the form definition." }),
|
|
83
|
+
/* @__PURE__ */ a("p", { children: [
|
|
84
|
+
"Each form also has an owner at ",
|
|
85
|
+
/* @__PURE__ */ e("strong", { children: "form.owner" }),
|
|
86
|
+
" which is the user who created the form. In some applications users are allowed to create their own forms. In those cases it is helpful to have Owner based permissions as well."
|
|
87
|
+
] })
|
|
88
|
+
] }) })
|
|
89
|
+
] })
|
|
90
|
+
] });
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
O as FormAccess
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=formAccess.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formAccess.component.js","sources":["../../../src/components/form-access/formAccess.component.tsx"],"sourcesContent":["import { PropsWithChildren, useCallback, useEffect, useMemo, useState } from \"react\";\n\nimport type { FormOptions, FormSchema, Submission } from \"../../interfaces\";\nimport { Card } from \"../card/card.component\";\nimport { Form } from \"../form/form.component\";\nimport { ChangedSubmission } from \"../form/useForm.hook\";\nimport {\n AccessRoles,\n dataAccessToSubmissions,\n FormAccessSchema,\n getFormAccess,\n shouldUpdate,\n SubmissionAccess,\n submissionsToDataAccess,\n updateSubmissions\n} from \"./formAccess.utils\";\n\nexport interface FormAccessProps {\n form: Partial<FormSchema>;\n roles: any;\n onSubmit?: Function;\n options?: FormOptions;\n}\n\nfunction useFormAccess({ form: formDefinition, roles, onSubmit, options }: FormAccessProps) {\n const form = useMemo(() => getFormAccess(roles), [roles]);\n\n const [submissions, setSubmissions] = useState(() => dataAccessToSubmissions(formDefinition, form));\n\n const onChange = useCallback(\n (type: string, submission: Submission<AccessRoles>) => {\n updateSubmissions(type, submission, submissions, setSubmissions);\n },\n [submissions]\n );\n\n useEffect(() => {\n const input = dataAccessToSubmissions(formDefinition, form);\n if (formDefinition?._id) {\n if (shouldUpdate(\"access\", submissions.access, input) || shouldUpdate(\"submissionAccess\", submissions.submissionAccess, input)) {\n setSubmissions(input);\n }\n }\n }, [formDefinition?._id]);\n\n return {\n options,\n form,\n type: formDefinition.type,\n submissions,\n onChange,\n onSubmit: () => {\n onSubmit && onSubmit(submissionsToDataAccess(formDefinition, submissions));\n }\n };\n}\n\ninterface NamedFormAccessProps {\n name: \"access\" | \"submissionAccess\";\n form: FormAccessSchema;\n submissions: SubmissionAccess;\n options: any;\n onSubmit: any;\n\n onChange(name: \"access\" | \"submissionAccess\", submission: Submission<AccessRoles>): void;\n}\n\nfunction NamedFormAccess({ name, form, submissions, options, onChange, onSubmit, children }: PropsWithChildren<NamedFormAccessProps>) {\n const [isValid, setIsValid] = useState(true);\n\n return (\n <>\n <Form\n name={name}\n form={form[name]}\n submission={submissions[name]}\n onChange={({ data, isValid }: ChangedSubmission<AccessRoles>) => {\n isValid && onChange(name, { data });\n setIsValid(isValid);\n }}\n options={options}\n />\n\n <button disabled={!isValid} className={\"mt-5 btn btn-primary\"} onClick={onSubmit}>\n Save access\n </button>\n\n {children}\n\n <div className={\"alert alert-warning mt-5\"}>\n Elevated permissions allow users to access and modify other user's entities. Assign with caution.\n </div>\n </>\n );\n}\n\nexport function FormAccess(props: PropsWithChildren<FormAccessProps>) {\n const { type, form, submissions, options, onChange, onSubmit } = useFormAccess(props);\n\n return (\n <div>\n {props.children}\n <div className={\"flex mb-5\"}>\n <Card label={\"Manage submission access\"} className={\"flex-1\"}>\n <NamedFormAccess\n name={\"submissionAccess\"}\n form={form}\n submissions={submissions}\n onChange={onChange}\n onSubmit={onSubmit}\n options={options}\n >\n {props.children}\n </NamedFormAccess>\n </Card>\n <div className={\"w-1/4 pl-4\"}>\n <Card label={\"About Submission Data Permissions\"}>\n <p>Submission Data Permissions allow you to control who can create, view, and modify form submission data.</p>\n\n <ul className={\"mt-5 pl-7 list-disc\"}>\n <li className={\"pb-2\"}>\n <strong>Own Permissions</strong> - These permissions apply if the user is the original creator of the submission data and is\n listed as the owner of the submission in submission.owner. This allows users to create and edit their own submission data\n without seeing other user's data.\n </li>\n <li>\n <strong>All Permissions</strong> - These permissions apply to all submission data regardless of who owns it.\n </li>\n </ul>\n </Card>\n </div>\n </div>\n <div className={\"flex mb-5\"}>\n <Card label={`Manage ${type} definition access`} className={\"flex-1\"}>\n <NamedFormAccess name={\"access\"} form={form} submissions={submissions} onChange={onChange} onSubmit={onSubmit} options={options}>\n {props.children}\n </NamedFormAccess>\n </Card>\n\n <div className={\"w-1/4 pl-4\"}>\n <Card label={\"About Form Definition Access\"}>\n <p>These permissions allow you to give access to a single form's JSON definition so they can render the form.</p>\n\n <p>Typically you will want to allow all of your roles to be able to Read the form definition.</p>\n\n <p>\n Each form also has an owner at <strong>form.owner</strong> which is the user who created the form. In some applications users\n are allowed to create their own forms. In those cases it is helpful to have Owner based permissions as well.\n </p>\n </Card>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["useFormAccess","formDefinition","roles","onSubmit","options","form","useMemo","getFormAccess","submissions","setSubmissions","useState","dataAccessToSubmissions","onChange","useCallback","type","submission","updateSubmissions","useEffect","input","shouldUpdate","submissionsToDataAccess","NamedFormAccess","name","children","isValid","setIsValid","jsxs","Fragment","jsx","Form","data","FormAccess","props","Card"],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExtendedComponentSchema } from
|
|
2
|
-
import { FormSchema } from
|
|
3
|
-
export declare function getRoleComponent({ label, key, description, choices, data }: any): ExtendedComponentSchema;
|
|
4
|
-
export declare function getSubmissionPermissionForm({ choices }: any): FormSchema;
|
|
5
|
-
export declare function getAccessPermissionForm({ choices }: any): FormSchema;
|
|
1
|
+
import { ExtendedComponentSchema } from 'formiojs';
|
|
2
|
+
import { FormSchema } from '../../interfaces/FormSchema';
|
|
3
|
+
export declare function getRoleComponent({ label, key, description, choices, data }: any): ExtendedComponentSchema;
|
|
4
|
+
export declare function getSubmissionPermissionForm({ choices }: any): FormSchema;
|
|
5
|
+
export declare function getAccessPermissionForm({ choices }: any): FormSchema;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
function s({ label: e, key: o, description: i, choices: l, data: a }) {
|
|
2
|
+
return {
|
|
3
|
+
label: e,
|
|
4
|
+
key: o,
|
|
5
|
+
description: i,
|
|
6
|
+
type: "select",
|
|
7
|
+
labelPosition: "top",
|
|
8
|
+
widget: "choicesjs",
|
|
9
|
+
placeholder: "Select roles...",
|
|
10
|
+
tooltip: "",
|
|
11
|
+
multiple: !0,
|
|
12
|
+
dataSrc: "values",
|
|
13
|
+
defaultValue: "",
|
|
14
|
+
data: {
|
|
15
|
+
values: l
|
|
16
|
+
},
|
|
17
|
+
template: "<span>{{ item.label }}</span>",
|
|
18
|
+
searchEnabled: !0,
|
|
19
|
+
selectThreshold: 0,
|
|
20
|
+
validate: {
|
|
21
|
+
required: !1,
|
|
22
|
+
custom: "",
|
|
23
|
+
customPrivate: !1
|
|
24
|
+
},
|
|
25
|
+
values: a
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function t(e, o = !0) {
|
|
29
|
+
return '<span class="text-sm">' + e + "</span> " + (o ? '<hr class="mt-6 mb-5 border-gray-200 mx-20"/>' : "");
|
|
30
|
+
}
|
|
31
|
+
function n({ choices: e }) {
|
|
32
|
+
return {
|
|
33
|
+
description: "<strong>Elevated permissions allow users to access and modify other user's entities. Assign with caution.</strong>",
|
|
34
|
+
components: [
|
|
35
|
+
s({
|
|
36
|
+
key: "create_own",
|
|
37
|
+
label: '<h4 class="text-gray-800">Create Own Submissions</h4>',
|
|
38
|
+
description: t(
|
|
39
|
+
"The Create Own Submissions permission will allow a user with one of the Roles to create a Submission. Upon creating the Submission, the user will be defined as its owner."
|
|
40
|
+
),
|
|
41
|
+
choices: e
|
|
42
|
+
}),
|
|
43
|
+
s({
|
|
44
|
+
key: "create_all",
|
|
45
|
+
label: '<h4 class="text-gray-800">Create All Submissions</h4>',
|
|
46
|
+
description: t(
|
|
47
|
+
'<strong class="text-yellow-600">Elevated Permission:</strong> The Create All Submissions permission will allow a user with one of the Roles to create a new Submission and assign ownership of that Submission to another user.'
|
|
48
|
+
),
|
|
49
|
+
choices: e
|
|
50
|
+
}),
|
|
51
|
+
s({
|
|
52
|
+
key: "read_own",
|
|
53
|
+
label: '<h4 class="text-gray-800">Read Own Submissions</h4>',
|
|
54
|
+
description: t(
|
|
55
|
+
"The Read Own Submissions permission will allow a user with one of the Roles to read a Submission. A user can only read a Submission if they are defined as its owner."
|
|
56
|
+
),
|
|
57
|
+
choices: e
|
|
58
|
+
}),
|
|
59
|
+
s({
|
|
60
|
+
key: "read_all",
|
|
61
|
+
label: '<h4 class="text-gray-800">Read All Submissions</h4>',
|
|
62
|
+
description: t(
|
|
63
|
+
'<strong class="text-yellow-600">Elevated Permission:</strong> The Read All Submissions permission will allow a user with one of the Roles to read all Submissions regardless of who owns them.'
|
|
64
|
+
),
|
|
65
|
+
choices: e
|
|
66
|
+
}),
|
|
67
|
+
s({
|
|
68
|
+
key: "update_own",
|
|
69
|
+
label: '<h4 class="text-gray-800">Update Own Submissions</h4>',
|
|
70
|
+
description: t(
|
|
71
|
+
"The Update Own Submissions permission will allow a user with one of the Roles to update a Submission. A user can only update a Submission if they are defined as its owner."
|
|
72
|
+
),
|
|
73
|
+
choices: e
|
|
74
|
+
}),
|
|
75
|
+
s({
|
|
76
|
+
key: "update_all",
|
|
77
|
+
label: '<h4 class="text-gray-800">Update All Submissions</h4>',
|
|
78
|
+
description: t(
|
|
79
|
+
'<strong class="text-yellow-600">Elevated Permission:</strong> The Update All Submissions permission will allow a user with one of the Roles to update a Submission, regardless of who owns the Submission. Additionally with this permission, a user can change the owner of a Submission.'
|
|
80
|
+
),
|
|
81
|
+
choices: e
|
|
82
|
+
}),
|
|
83
|
+
s({
|
|
84
|
+
key: "delete_own",
|
|
85
|
+
label: '<h4 class="text-gray-800">Delete Own Submissions</h4>',
|
|
86
|
+
description: t(
|
|
87
|
+
"The Delete Own Submissions permission will allow a user with one of the Roles, to delete a Submission. A user can only delete a Submission if they are defined as its owner."
|
|
88
|
+
),
|
|
89
|
+
choices: e
|
|
90
|
+
}),
|
|
91
|
+
s({
|
|
92
|
+
key: "delete_all",
|
|
93
|
+
label: '<h4 class="text-gray-800">Delete All Submissions</h4>',
|
|
94
|
+
description: t(
|
|
95
|
+
'<strong class="text-yellow-600">Elevated Permission:</strong> The Delete All Submissions permission will allow a user with one of the Roles to delete a Submission, regardless of who owns the Submission.',
|
|
96
|
+
!1
|
|
97
|
+
),
|
|
98
|
+
choices: e
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function r({ choices: e }) {
|
|
104
|
+
return {
|
|
105
|
+
description: "<strong>Elevated permissions allow users to access and modify other user's entities. Assign with caution.</strong>",
|
|
106
|
+
components: [
|
|
107
|
+
s({
|
|
108
|
+
key: "read_own",
|
|
109
|
+
label: '<h4 class="text-gray-800">Read Form Definition (Restricted to owner)</h4>',
|
|
110
|
+
description: t(
|
|
111
|
+
"The Read Own permission will allow a user, with one of the given Roles, to read a form. A user can only read a form if they are defined as its owner."
|
|
112
|
+
),
|
|
113
|
+
choices: e
|
|
114
|
+
}),
|
|
115
|
+
s({
|
|
116
|
+
key: "read_all",
|
|
117
|
+
label: "<h4>Read Form Definition</h4>",
|
|
118
|
+
description: t(
|
|
119
|
+
'<strong class="text-yellow-600">Elevated Permission:</strong> The Read permission will allow a user, with one of the given Roles, to read the form.'
|
|
120
|
+
),
|
|
121
|
+
choices: e
|
|
122
|
+
}),
|
|
123
|
+
s({
|
|
124
|
+
key: "update_own",
|
|
125
|
+
label: '<h4 class="text-gray-800">Update Form Definition (Restricted to owner)</h4>',
|
|
126
|
+
description: t(
|
|
127
|
+
"The Update Own permission will allow a user, with one of the given Roles, to update a form. A user can only update a form if they are defined as its owner."
|
|
128
|
+
),
|
|
129
|
+
choices: e
|
|
130
|
+
}),
|
|
131
|
+
s({
|
|
132
|
+
key: "update_all",
|
|
133
|
+
label: '<h4 class="text-gray-800">Update Form Definition</h4>',
|
|
134
|
+
description: t(
|
|
135
|
+
'<strong class="text-yellow-600">Elevated Permission:</strong> The Update permission will allow a user, with one of the given Roles, to read and edit the form.'
|
|
136
|
+
),
|
|
137
|
+
choices: e
|
|
138
|
+
}),
|
|
139
|
+
s({
|
|
140
|
+
key: "delete_own",
|
|
141
|
+
label: '<h4 class="text-gray-800">Delete Form Definition (Restricted to owner)</h4>',
|
|
142
|
+
description: t(
|
|
143
|
+
"The Delete Own permission will allow a user, with one of the given Roles, to delete a form. A user can only delete a form if they are defined as its owner."
|
|
144
|
+
),
|
|
145
|
+
choices: e
|
|
146
|
+
}),
|
|
147
|
+
s({
|
|
148
|
+
key: "delete_all",
|
|
149
|
+
label: '<h4 class="text-gray-800">Delete Form Definition</h4>',
|
|
150
|
+
description: t(
|
|
151
|
+
'<strong class="text-yellow-600">Elevated Permission:</strong> The Delete permission will allow a user, with one of the given Roles, to delete the form.',
|
|
152
|
+
!1
|
|
153
|
+
),
|
|
154
|
+
choices: e
|
|
155
|
+
})
|
|
156
|
+
]
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
r as getAccessPermissionForm,
|
|
161
|
+
s as getRoleComponent,
|
|
162
|
+
n as getSubmissionPermissionForm
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=formAccess.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formAccess.schema.js","sources":["../../../src/components/form-access/formAccess.schema.ts"],"sourcesContent":["import { ExtendedComponentSchema } from \"formiojs\";\n\nimport { FormSchema } from \"../../interfaces/FormSchema\";\n\nexport function getRoleComponent({ label, key, description, choices, data }: any): ExtendedComponentSchema {\n return {\n label,\n key,\n description,\n type: \"select\",\n labelPosition: \"top\",\n widget: \"choicesjs\",\n placeholder: \"Select roles...\",\n tooltip: \"\",\n multiple: true,\n dataSrc: \"values\",\n defaultValue: \"\",\n data: {\n values: choices\n },\n template: \"<span>{{ item.label }}</span>\",\n searchEnabled: true,\n selectThreshold: 0,\n validate: {\n required: false,\n custom: \"\",\n customPrivate: false\n },\n values: data\n };\n}\n\nfunction toDescription(description: string, hr = true): string {\n return '<span class=\"text-sm\">' + description + \"</span> \" + (hr ? '<hr class=\"mt-6 mb-5 border-gray-200 mx-20\"/>' : \"\");\n}\n\nexport function getSubmissionPermissionForm({ choices }: any): FormSchema {\n return {\n description: \"<strong>Elevated permissions allow users to access and modify other user's entities. Assign with caution.</strong>\",\n components: [\n getRoleComponent({\n key: \"create_own\",\n label: '<h4 class=\"text-gray-800\">Create Own Submissions</h4>',\n description: toDescription(\n \"The Create Own Submissions permission will allow a user with one of the Roles to create a Submission. Upon creating the Submission, the user will be defined as its owner.\"\n ),\n choices\n }),\n getRoleComponent({\n key: \"create_all\",\n label: '<h4 class=\"text-gray-800\">Create All Submissions</h4>',\n description: toDescription(\n '<strong class=\"text-yellow-600\">Elevated Permission:</strong> The Create All Submissions permission will allow a user with one of the Roles to create a new Submission and assign ownership of that Submission to another user.'\n ),\n choices\n }),\n getRoleComponent({\n key: \"read_own\",\n label: '<h4 class=\"text-gray-800\">Read Own Submissions</h4>',\n description: toDescription(\n \"The Read Own Submissions permission will allow a user with one of the Roles to read a Submission. A user can only read a Submission if they are defined as its owner.\"\n ),\n choices\n }),\n getRoleComponent({\n key: \"read_all\",\n label: '<h4 class=\"text-gray-800\">Read All Submissions</h4>',\n description: toDescription(\n '<strong class=\"text-yellow-600\">Elevated Permission:</strong> The Read All Submissions permission will allow a user with one of the Roles to read all Submissions regardless of who owns them.'\n ),\n choices\n }),\n getRoleComponent({\n key: \"update_own\",\n label: '<h4 class=\"text-gray-800\">Update Own Submissions</h4>',\n description: toDescription(\n \"The Update Own Submissions permission will allow a user with one of the Roles to update a Submission. A user can only update a Submission if they are defined as its owner.\"\n ),\n choices\n }),\n getRoleComponent({\n key: \"update_all\",\n label: '<h4 class=\"text-gray-800\">Update All Submissions</h4>',\n description: toDescription(\n '<strong class=\"text-yellow-600\">Elevated Permission:</strong> The Update All Submissions permission will allow a user with one of the Roles to update a Submission, regardless of who owns the Submission. Additionally with this permission, a user can change the owner of a Submission.'\n ),\n choices\n }),\n getRoleComponent({\n key: \"delete_own\",\n label: '<h4 class=\"text-gray-800\">Delete Own Submissions</h4>',\n description: toDescription(\n \"The Delete Own Submissions permission will allow a user with one of the Roles, to delete a Submission. A user can only delete a Submission if they are defined as its owner.\"\n ),\n choices\n }),\n getRoleComponent({\n key: \"delete_all\",\n label: '<h4 class=\"text-gray-800\">Delete All Submissions</h4>',\n description: toDescription(\n '<strong class=\"text-yellow-600\">Elevated Permission:</strong> The Delete All Submissions permission will allow a user with one of the Roles to delete a Submission, regardless of who owns the Submission.',\n false\n ),\n choices\n })\n ]\n };\n}\n\nexport function getAccessPermissionForm({ choices }: any): FormSchema {\n return {\n description: \"<strong>Elevated permissions allow users to access and modify other user's entities. Assign with caution.</strong>\",\n components: [\n getRoleComponent({\n key: \"read_own\",\n label: '<h4 class=\"text-gray-800\">Read Form Definition (Restricted to owner)</h4>',\n description: toDescription(\n \"The Read Own permission will allow a user, with one of the given Roles, to read a form. A user can only read a form if they are defined as its owner.\"\n ),\n choices\n }),\n getRoleComponent({\n key: \"read_all\",\n label: \"<h4>Read Form Definition</h4>\",\n description: toDescription(\n '<strong class=\"text-yellow-600\">Elevated Permission:</strong> The Read permission will allow a user, with one of the given Roles, to read the form.'\n ),\n choices\n }),\n getRoleComponent({\n key: \"update_own\",\n label: '<h4 class=\"text-gray-800\">Update Form Definition (Restricted to owner)</h4>',\n description: toDescription(\n \"The Update Own permission will allow a user, with one of the given Roles, to update a form. A user can only update a form if they are defined as its owner.\"\n ),\n choices\n }),\n getRoleComponent({\n key: \"update_all\",\n label: '<h4 class=\"text-gray-800\">Update Form Definition</h4>',\n description: toDescription(\n '<strong class=\"text-yellow-600\">Elevated Permission:</strong> The Update permission will allow a user, with one of the given Roles, to read and edit the form.'\n ),\n choices\n }),\n getRoleComponent({\n key: \"delete_own\",\n label: '<h4 class=\"text-gray-800\">Delete Form Definition (Restricted to owner)</h4>',\n description: toDescription(\n \"The Delete Own permission will allow a user, with one of the given Roles, to delete a form. A user can only delete a form if they are defined as its owner.\"\n ),\n choices\n }),\n getRoleComponent({\n key: \"delete_all\",\n label: '<h4 class=\"text-gray-800\">Delete Form Definition</h4>',\n description: toDescription(\n '<strong class=\"text-yellow-600\">Elevated Permission:</strong> The Delete permission will allow a user, with one of the given Roles, to delete the form.',\n false\n ),\n choices\n })\n ]\n };\n}\n"],"names":["getRoleComponent","label","key","description","choices","data","toDescription","hr","getSubmissionPermissionForm","getAccessPermissionForm"],"mappings":"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"}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { FormSchema, Submission } from
|
|
2
|
-
import { RoleSchema } from
|
|
3
|
-
export interface Choice {
|
|
4
|
-
label: string;
|
|
5
|
-
value: string;
|
|
6
|
-
}
|
|
7
|
-
export interface Access {
|
|
8
|
-
roles: string[];
|
|
9
|
-
type: string;
|
|
10
|
-
}
|
|
11
|
-
export type AccessRoles = Record<string, string[]>;
|
|
12
|
-
export type FormAccessSchema = {
|
|
13
|
-
access: FormSchema;
|
|
14
|
-
submissionAccess: FormSchema;
|
|
15
|
-
};
|
|
16
|
-
export type SubmissionAccess = {
|
|
17
|
-
access: Submission<AccessRoles>;
|
|
18
|
-
submissionAccess: Submission<AccessRoles>;
|
|
19
|
-
};
|
|
20
|
-
export declare function getFormAccess(roles: RoleSchema[]): FormAccessSchema;
|
|
21
|
-
export declare function dataAccessToSubmissions(form: Partial<FormSchema>, formAccess: FormAccessSchema): SubmissionAccess;
|
|
22
|
-
export declare function submissionsToDataAccess(form: Partial<FormSchema>, submissions: SubmissionAccess): Partial<FormSchema>;
|
|
23
|
-
export declare function shouldUpdate(type: string, submission: Submission<AccessRoles>, submissions: SubmissionAccess): boolean;
|
|
24
|
-
export declare function updateSubmissions(type: string, submission: Submission<AccessRoles>, submissions: SubmissionAccess, cb?: Function): SubmissionAccess;
|
|
1
|
+
import { FormSchema, Submission } from '../../interfaces';
|
|
2
|
+
import { RoleSchema } from '../../interfaces/RoleSchema';
|
|
3
|
+
export interface Choice {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Access {
|
|
8
|
+
roles: string[];
|
|
9
|
+
type: string;
|
|
10
|
+
}
|
|
11
|
+
export type AccessRoles = Record<string, string[]>;
|
|
12
|
+
export type FormAccessSchema = {
|
|
13
|
+
access: FormSchema;
|
|
14
|
+
submissionAccess: FormSchema;
|
|
15
|
+
};
|
|
16
|
+
export type SubmissionAccess = {
|
|
17
|
+
access: Submission<AccessRoles>;
|
|
18
|
+
submissionAccess: Submission<AccessRoles>;
|
|
19
|
+
};
|
|
20
|
+
export declare function getFormAccess(roles: RoleSchema[]): FormAccessSchema;
|
|
21
|
+
export declare function dataAccessToSubmissions(form: Partial<FormSchema>, formAccess: FormAccessSchema): SubmissionAccess;
|
|
22
|
+
export declare function submissionsToDataAccess(form: Partial<FormSchema>, submissions: SubmissionAccess): Partial<FormSchema>;
|
|
23
|
+
export declare function shouldUpdate(type: string, submission: Submission<AccessRoles>, submissions: SubmissionAccess): boolean;
|
|
24
|
+
export declare function updateSubmissions(type: string, submission: Submission<AccessRoles>, submissions: SubmissionAccess, cb?: Function): SubmissionAccess;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import r from "lodash/cloneDeep";
|
|
2
|
+
import i from "lodash/isEqual";
|
|
3
|
+
import u from "lodash/noop";
|
|
4
|
+
import { getAccessPermissionForm as m, getSubmissionPermissionForm as d } from "./formAccess.schema.js";
|
|
5
|
+
function f(e) {
|
|
6
|
+
return Object.values(e).map((s) => ({
|
|
7
|
+
label: s.title || "",
|
|
8
|
+
value: s._id || ""
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
function o(e, s = []) {
|
|
12
|
+
const c = Object.values(s).reduce((t, n) => (t[n.type] = n.roles, t), {});
|
|
13
|
+
return (e || []).filter(Boolean).reduce((t, n) => ({
|
|
14
|
+
...t,
|
|
15
|
+
[n]: c[n] || []
|
|
16
|
+
}), {});
|
|
17
|
+
}
|
|
18
|
+
function a(e) {
|
|
19
|
+
const s = [];
|
|
20
|
+
return Object.entries(e).forEach(([c, t]) => {
|
|
21
|
+
c !== "submit" && s.push({
|
|
22
|
+
type: c,
|
|
23
|
+
roles: t
|
|
24
|
+
});
|
|
25
|
+
}), s;
|
|
26
|
+
}
|
|
27
|
+
function g(e) {
|
|
28
|
+
const s = f(e), c = m({ choices: s }), t = d({ choices: s });
|
|
29
|
+
return {
|
|
30
|
+
access: c,
|
|
31
|
+
submissionAccess: t
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function T(e, s) {
|
|
35
|
+
const c = (t) => t.map(({ key: n }) => n);
|
|
36
|
+
return {
|
|
37
|
+
access: {
|
|
38
|
+
data: o(c(s.access.components), e.access)
|
|
39
|
+
},
|
|
40
|
+
submissionAccess: {
|
|
41
|
+
data: o(c(s.submissionAccess.components), e.submissionAccess)
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function j(e, s) {
|
|
46
|
+
return {
|
|
47
|
+
...r(e),
|
|
48
|
+
access: a(s.access.data),
|
|
49
|
+
submissionAccess: a(s.submissionAccess.data)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function p(e, s, c) {
|
|
53
|
+
return !i(s.data, c[e].data);
|
|
54
|
+
}
|
|
55
|
+
function v(e, s, c, t = u) {
|
|
56
|
+
return p(e, s, c) && (c = {
|
|
57
|
+
...c,
|
|
58
|
+
[e]: { data: s.data }
|
|
59
|
+
}, t(c)), c;
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
T as dataAccessToSubmissions,
|
|
63
|
+
g as getFormAccess,
|
|
64
|
+
p as shouldUpdate,
|
|
65
|
+
j as submissionsToDataAccess,
|
|
66
|
+
v as updateSubmissions
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=formAccess.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formAccess.utils.js","sources":["../../../src/components/form-access/formAccess.utils.ts"],"sourcesContent":["import { ExtendedComponentSchema } from \"formiojs\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport isEqual from \"lodash/isEqual\";\nimport noop from \"lodash/noop\";\n\nimport { FormSchema, Submission } from \"../../interfaces\";\nimport { RoleSchema } from \"../../interfaces/RoleSchema\";\nimport { getAccessPermissionForm, getSubmissionPermissionForm } from \"./formAccess.schema\";\n\nexport interface Choice {\n label: string;\n value: string;\n}\n\nexport interface Access {\n roles: string[];\n type: string;\n}\n\nexport type AccessRoles = Record<string, string[]>;\n\nexport type FormAccessSchema = {\n access: FormSchema;\n submissionAccess: FormSchema;\n};\n\nexport type SubmissionAccess = {\n access: Submission<AccessRoles>;\n submissionAccess: Submission<AccessRoles>;\n};\n\nfunction rolesToChoices(roles: RoleSchema[]): Choice[] {\n return Object.values(roles).map((role) => {\n return {\n label: role.title || \"\",\n value: role._id || \"\"\n };\n });\n}\n\nfunction accessToHash(keys: (string | undefined)[] | undefined, access: Access[] = []): AccessRoles {\n const hash = Object.values(access).reduce((o: any, role: any) => {\n o[role.type] = role.roles;\n return o;\n }, {});\n\n return ((keys || []).filter(Boolean) as any[]).reduce((data, key: string) => {\n return {\n ...data,\n [key]: hash[key] || []\n };\n }, {});\n}\n\nfunction hashToAccess(data: AccessRoles) {\n const accessRoles: any[] = [];\n\n Object.entries(data).forEach(([accessType, roles]) => {\n if (accessType === \"submit\") {\n return;\n }\n accessRoles.push({\n type: accessType,\n roles\n });\n });\n\n return accessRoles;\n}\n\nexport function getFormAccess(roles: RoleSchema[]): FormAccessSchema {\n const choices = rolesToChoices(roles);\n const access = getAccessPermissionForm({ choices });\n const submissionAccess = getSubmissionPermissionForm({ choices });\n\n return {\n access,\n submissionAccess\n };\n}\n\nexport function dataAccessToSubmissions(form: Partial<FormSchema>, formAccess: FormAccessSchema): SubmissionAccess {\n const getKeys = (components: ExtendedComponentSchema[]) => components.map(({ key }) => key);\n\n return {\n access: {\n data: accessToHash(getKeys(formAccess.access.components), form.access)\n },\n submissionAccess: {\n data: accessToHash(getKeys(formAccess.submissionAccess.components), form.submissionAccess)\n }\n };\n}\n\nexport function submissionsToDataAccess(form: Partial<FormSchema>, submissions: SubmissionAccess): Partial<FormSchema> {\n return {\n ...cloneDeep(form),\n access: hashToAccess(submissions.access.data),\n submissionAccess: hashToAccess(submissions.submissionAccess.data)\n };\n}\n\nexport function shouldUpdate(type: string, submission: Submission<AccessRoles>, submissions: SubmissionAccess) {\n return !isEqual(submission.data, (submissions as any)[type].data);\n}\n\nexport function updateSubmissions(type: string, submission: Submission<AccessRoles>, submissions: SubmissionAccess, cb: Function = noop) {\n if (shouldUpdate(type, submission, submissions)) {\n submissions = {\n ...submissions,\n [type]: { data: submission.data }\n };\n cb(submissions);\n }\n\n return submissions;\n}\n"],"names":["rolesToChoices","roles","role","accessToHash","keys","access","hash","o","data","key","hashToAccess","accessRoles","accessType","getFormAccess","choices","getAccessPermissionForm","submissionAccess","getSubmissionPermissionForm","dataAccessToSubmissions","form","formAccess","getKeys","components","submissionsToDataAccess","submissions","cloneDeep","shouldUpdate","type","submission","isEqual","updateSubmissions","cb","noop"],"mappings":";;;;AA+BA,SAASA,EAAeC,GAA+B;AACrD,SAAO,OAAO,OAAOA,CAAK,EAAE,IAAI,CAACC,OACxB;AAAA,IACL,OAAOA,EAAK,SAAS;AAAA,IACrB,OAAOA,EAAK,OAAO;AAAA,EACrB,EACD;AACH;AAEA,SAASC,EAAaC,GAA0CC,IAAmB,IAAiB;AAC5F,QAAAC,IAAO,OAAO,OAAOD,CAAM,EAAE,OAAO,CAACE,GAAQL,OAC/CK,EAAAL,EAAK,IAAI,IAAIA,EAAK,OACbK,IACN,EAAE;AAEI,UAAAH,KAAQ,CAAA,GAAI,OAAO,OAAO,EAAY,OAAO,CAACI,GAAMC,OACpD;AAAA,IACL,GAAGD;AAAA,IACH,CAACC,CAAG,GAAGH,EAAKG,CAAG,KAAK,CAAA;AAAA,EACtB,IACC,EAAE;AACP;AAEA,SAASC,EAAaF,GAAmB;AACvC,QAAMG,IAAqB,CAAC;AAErB,gBAAA,QAAQH,CAAI,EAAE,QAAQ,CAAC,CAACI,GAAYX,CAAK,MAAM;AACpD,IAAIW,MAAe,YAGnBD,EAAY,KAAK;AAAA,MACf,MAAMC;AAAA,MACN,OAAAX;AAAA,IAAA,CACD;AAAA,EAAA,CACF,GAEMU;AACT;AAEO,SAASE,EAAcZ,GAAuC;AAC7D,QAAAa,IAAUd,EAAeC,CAAK,GAC9BI,IAASU,EAAwB,EAAE,SAAAD,GAAS,GAC5CE,IAAmBC,EAA4B,EAAE,SAAAH,GAAS;AAEzD,SAAA;AAAA,IACL,QAAAT;AAAA,IACA,kBAAAW;AAAA,EACF;AACF;AAEgB,SAAAE,EAAwBC,GAA2BC,GAAgD;AAC3G,QAAAC,IAAU,CAACC,MAA0CA,EAAW,IAAI,CAAC,EAAE,KAAAb,EAAI,MAAMA,CAAG;AAEnF,SAAA;AAAA,IACL,QAAQ;AAAA,MACN,MAAMN,EAAakB,EAAQD,EAAW,OAAO,UAAU,GAAGD,EAAK,MAAM;AAAA,IACvE;AAAA,IACA,kBAAkB;AAAA,MAChB,MAAMhB,EAAakB,EAAQD,EAAW,iBAAiB,UAAU,GAAGD,EAAK,gBAAgB;AAAA,IAAA;AAAA,EAE7F;AACF;AAEgB,SAAAI,EAAwBJ,GAA2BK,GAAoD;AAC9G,SAAA;AAAA,IACL,GAAGC,EAAUN,CAAI;AAAA,IACjB,QAAQT,EAAac,EAAY,OAAO,IAAI;AAAA,IAC5C,kBAAkBd,EAAac,EAAY,iBAAiB,IAAI;AAAA,EAClE;AACF;AAEgB,SAAAE,EAAaC,GAAcC,GAAqCJ,GAA+B;AAC7G,SAAO,CAACK,EAAQD,EAAW,MAAOJ,EAAoBG,CAAI,EAAE,IAAI;AAClE;AAEO,SAASG,EAAkBH,GAAcC,GAAqCJ,GAA+BO,IAAeC,GAAM;AACvI,SAAIN,EAAaC,GAAMC,GAAYJ,CAAW,MAC9BA,IAAA;AAAA,IACZ,GAAGA;AAAA,IACH,CAACG,CAAI,GAAG,EAAE,MAAMC,EAAW,KAAK;AAAA,EAClC,GACAG,EAAGP,CAAW,IAGTA;AACT;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PropsWithChildren, ReactElement } from
|
|
2
|
-
import { ActionSchema, FormOptions, Submission } from
|
|
3
|
-
export interface FormActionProps {
|
|
4
|
-
actionInfo: Partial<ActionSchema>;
|
|
5
|
-
submission?: Partial<Submission>;
|
|
6
|
-
onSubmit?: (submission: Submission<ActionSchema>) => void;
|
|
7
|
-
options: FormOptions;
|
|
8
|
-
}
|
|
9
|
-
export declare function FormAction({ actionInfo, children, onSubmit, options, ...props }: PropsWithChildren<FormActionProps>): ReactElement;
|
|
1
|
+
import { PropsWithChildren, ReactElement } from 'react';
|
|
2
|
+
import { ActionSchema, FormOptions, Submission } from '../../interfaces';
|
|
3
|
+
export interface FormActionProps {
|
|
4
|
+
actionInfo: Partial<ActionSchema>;
|
|
5
|
+
submission?: Partial<Submission>;
|
|
6
|
+
onSubmit?: (submission: Submission<ActionSchema>) => void;
|
|
7
|
+
options: FormOptions;
|
|
8
|
+
}
|
|
9
|
+
export declare function FormAction({ actionInfo, children, onSubmit, options, ...props }: PropsWithChildren<FormActionProps>): ReactElement;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsxs as m, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import f from "formiojs/utils";
|
|
3
|
+
import { Form as d } from "../form/form.component.js";
|
|
4
|
+
function n(t, s) {
|
|
5
|
+
return {
|
|
6
|
+
...s,
|
|
7
|
+
...t
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function c({ action: t, ...s }) {
|
|
11
|
+
return f.eachComponent(s.components, (r) => {
|
|
12
|
+
const e = "";
|
|
13
|
+
r.type === "resourcefields" && (r.type = "select", r.label = r.title, r.dataSrc = "url", r.data = {
|
|
14
|
+
url: `${r.basePath}?type=resource${e}`
|
|
15
|
+
}, r.valueProperty = "_id", r.template = "<span>{{ item.title }}</span>", r.persistent = !0);
|
|
16
|
+
}), s;
|
|
17
|
+
}
|
|
18
|
+
function F({ actionInfo: t, children: s, onSubmit: r, options: e, ...i }) {
|
|
19
|
+
const { form: u, submission: a } = (() => {
|
|
20
|
+
const o = n(i.submission || {}, t.defaults);
|
|
21
|
+
return { form: c(t.settingsForm), submission: { data: o } };
|
|
22
|
+
})();
|
|
23
|
+
return /* @__PURE__ */ m("div", { children: [
|
|
24
|
+
s,
|
|
25
|
+
/* @__PURE__ */ l(d, { form: u, submission: a, onSubmit: r, options: e }),
|
|
26
|
+
s
|
|
27
|
+
] });
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
F as FormAction
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=formAction.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formAction.component.js","sources":["../../../src/components/form-action/formAction.component.tsx"],"sourcesContent":["import FormioUtils from \"formiojs/utils\";\nimport { PropsWithChildren, ReactElement } from \"react\";\n\nimport { ActionDefaultsSchema, ActionSchema, FormOptions, Submission } from \"../../interfaces\";\nimport { Form } from \"../form/form.component\";\n\nfunction mapData(options: any, defaults: ActionDefaultsSchema): any {\n return {\n ...defaults,\n ...options\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction mapSettingsForm({ action, ...settingsForm }: any): any {\n FormioUtils.eachComponent(settingsForm.components, (component: any) => {\n const resourceExclude = \"\";\n\n if (component.type === \"resourcefields\") {\n component.type = \"select\";\n component.label = component.title;\n component.dataSrc = \"url\";\n component.data = {\n url: `${component.basePath}?type=resource${resourceExclude}`\n };\n component.valueProperty = \"_id\";\n component.template = \"<span>{{ item.title }}</span>\";\n component.persistent = true;\n }\n });\n\n return settingsForm;\n}\n\nexport interface FormActionProps {\n actionInfo: Partial<ActionSchema>;\n submission?: Partial<Submission>;\n onSubmit?: (submission: Submission<ActionSchema>) => void;\n options: FormOptions;\n}\n\nexport function FormAction({ actionInfo, children, onSubmit, options, ...props }: PropsWithChildren<FormActionProps>): ReactElement {\n const { form, submission } = (() => {\n const submission = mapData(props.submission || {}, actionInfo.defaults!);\n const form = mapSettingsForm(actionInfo.settingsForm);\n\n return { form, submission: { data: submission } };\n })();\n\n return (\n <div>\n {children}\n\n <Form form={form} submission={submission} onSubmit={onSubmit} options={options} />\n\n {children}\n </div>\n );\n}\n"],"names":["mapData","options","defaults","mapSettingsForm","action","settingsForm","FormioUtils","component","resourceExclude","FormAction","actionInfo","children","onSubmit","props","form","submission","jsx","Form"],"mappings":";;;AAMA,SAASA,EAAQC,GAAcC,GAAqC;AAC3D,SAAA;AAAA,IACL,GAAGA;AAAA,IACH,GAAGD;AAAA,EACL;AACF;AAGA,SAASE,EAAgB,EAAE,QAAAC,GAAQ,GAAGC,KAA0B;AAC9D,SAAAC,EAAY,cAAcD,EAAa,YAAY,CAACE,MAAmB;AACrE,UAAMC,IAAkB;AAEpB,IAAAD,EAAU,SAAS,qBACrBA,EAAU,OAAO,UACjBA,EAAU,QAAQA,EAAU,OAC5BA,EAAU,UAAU,OACpBA,EAAU,OAAO;AAAA,MACf,KAAK,GAAGA,EAAU,QAAQ,iBAAiBC,CAAe;AAAA,IAC5D,GACAD,EAAU,gBAAgB,OAC1BA,EAAU,WAAW,iCACrBA,EAAU,aAAa;AAAA,EACzB,CACD,GAEMF;AACT;AASgB,SAAAI,EAAW,EAAE,YAAAC,GAAY,UAAAC,GAAU,UAAAC,GAAU,SAAAX,GAAS,GAAGY,KAA2D;AAClI,QAAM,EAAE,MAAAC,GAAM,YAAAC,EAAW,KAAK,MAAM;AAClC,UAAMA,IAAaf,EAAQa,EAAM,cAAc,CAAC,GAAGH,EAAW,QAAS;AAGvE,WAAO,EAAE,MAFIP,EAAgBO,EAAW,YAAY,GAErC,YAAY,EAAE,MAAMK,IAAa;AAAA,EAAA,GAC/C;AAEH,2BACG,OACE,EAAA,UAAA;AAAA,IAAAJ;AAAA,IAEA,gBAAAK,EAAAC,GAAA,EAAK,MAAAH,GAAY,YAAAC,GAAwB,UAAAH,GAAoB,SAAAX,GAAkB;AAAA,IAE/EU;AAAA,EAAA,GACH;AAEJ;"}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { ComponentSchema } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import
|
|
4
|
-
export interface FormBuilderProps {
|
|
5
|
-
components: ComponentSchema[];
|
|
6
|
-
display?: string;
|
|
7
|
-
options?: any;
|
|
8
|
-
builder?: any;
|
|
9
|
-
onChange?: (components: ComponentSchema[]) => void;
|
|
10
|
-
onAddComponent?: Function;
|
|
11
|
-
onUpdateComponent?: Function;
|
|
12
|
-
onRemoveComponent?: Function;
|
|
13
|
-
onSaveComponent?: Function;
|
|
14
|
-
onCancelComponent?: Function;
|
|
15
|
-
onMoveComponent?: Function;
|
|
16
|
-
onEditComponent?: Function;
|
|
17
|
-
onEditJson?: Function;
|
|
18
|
-
onCopyComponent?: Function;
|
|
19
|
-
onPasteComponent?: Function;
|
|
20
|
-
}
|
|
21
|
-
export declare class FormBuilder extends
|
|
22
|
-
static defaultProps: {
|
|
23
|
-
options: {};
|
|
24
|
-
onChange: (...args: any[]) => void;
|
|
25
|
-
onReady: (...args: any[]) => void;
|
|
26
|
-
onDestroy: (...args: any[]) => void;
|
|
27
|
-
};
|
|
28
|
-
static propTypes: {
|
|
29
|
-
components: PropTypes.Requireable<any[]>;
|
|
30
|
-
display: PropTypes.Requireable<string>;
|
|
31
|
-
options: PropTypes.Requireable<object>;
|
|
32
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
33
|
-
onAddComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
34
|
-
onUpdateComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
35
|
-
onRemoveComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
36
|
-
onSaveComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
37
|
-
onCancelComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
38
|
-
onMoveComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
39
|
-
onEditComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
|
-
onEditJson: PropTypes.Requireable<(...args: any[]) => any>;
|
|
41
|
-
onCopyComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
42
|
-
onPasteComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
43
|
-
};
|
|
44
|
-
private elRef;
|
|
45
|
-
private builderRef;
|
|
46
|
-
constructor(props: FormBuilderProps);
|
|
47
|
-
componentDidMount(): Promise<void>;
|
|
48
|
-
create(props: FormBuilderProps): Promise<void>;
|
|
49
|
-
componentWillUnmount(): void;
|
|
50
|
-
componentWillReceiveProps(nextProps: FormBuilderProps): Promise<void>;
|
|
51
|
-
whenComponentsChange(components: ComponentSchema[]): void;
|
|
52
|
-
render():
|
|
53
|
-
}
|
|
1
|
+
import { ComponentSchema } from 'formiojs';
|
|
2
|
+
import { default as PropTypes } from 'prop-types';
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
export interface FormBuilderProps {
|
|
5
|
+
components: ComponentSchema[];
|
|
6
|
+
display?: string;
|
|
7
|
+
options?: any;
|
|
8
|
+
builder?: any;
|
|
9
|
+
onChange?: (components: ComponentSchema[]) => void;
|
|
10
|
+
onAddComponent?: Function;
|
|
11
|
+
onUpdateComponent?: Function;
|
|
12
|
+
onRemoveComponent?: Function;
|
|
13
|
+
onSaveComponent?: Function;
|
|
14
|
+
onCancelComponent?: Function;
|
|
15
|
+
onMoveComponent?: Function;
|
|
16
|
+
onEditComponent?: Function;
|
|
17
|
+
onEditJson?: Function;
|
|
18
|
+
onCopyComponent?: Function;
|
|
19
|
+
onPasteComponent?: Function;
|
|
20
|
+
}
|
|
21
|
+
export declare class FormBuilder extends Component<FormBuilderProps, any> {
|
|
22
|
+
static defaultProps: {
|
|
23
|
+
options: {};
|
|
24
|
+
onChange: (...args: any[]) => void;
|
|
25
|
+
onReady: (...args: any[]) => void;
|
|
26
|
+
onDestroy: (...args: any[]) => void;
|
|
27
|
+
};
|
|
28
|
+
static propTypes: {
|
|
29
|
+
components: PropTypes.Requireable<any[]>;
|
|
30
|
+
display: PropTypes.Requireable<string>;
|
|
31
|
+
options: PropTypes.Requireable<object>;
|
|
32
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
33
|
+
onAddComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
34
|
+
onUpdateComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
35
|
+
onRemoveComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
36
|
+
onSaveComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
37
|
+
onCancelComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
38
|
+
onMoveComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
39
|
+
onEditComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
|
+
onEditJson: PropTypes.Requireable<(...args: any[]) => any>;
|
|
41
|
+
onCopyComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
42
|
+
onPasteComponent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
43
|
+
};
|
|
44
|
+
private elRef;
|
|
45
|
+
private builderRef;
|
|
46
|
+
constructor(props: FormBuilderProps);
|
|
47
|
+
componentDidMount(): Promise<void>;
|
|
48
|
+
create(props: FormBuilderProps): Promise<void>;
|
|
49
|
+
componentWillUnmount(): void;
|
|
50
|
+
componentWillReceiveProps(nextProps: FormBuilderProps): Promise<void>;
|
|
51
|
+
whenComponentsChange(components: ComponentSchema[]): void;
|
|
52
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
}
|