@oneblink/apps-react 1.0.0-beta.1 → 1.0.0-beta.4
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/CopyToClipboardIconButton.js +6 -15
- package/dist/components/CopyToClipboardIconButton.js.map +1 -1
- package/dist/components/CustomAccordion.d.ts +4 -4
- package/dist/components/CustomAccordion.js +29 -34
- package/dist/components/CustomAccordion.js.map +1 -1
- package/dist/components/ErrorSnackbar.d.ts +3 -3
- package/dist/components/ErrorSnackbar.js +15 -44
- package/dist/components/ErrorSnackbar.js.map +1 -1
- package/dist/components/Lists.d.ts +19 -4
- package/dist/components/Lists.js +40 -38
- package/dist/components/Lists.js.map +1 -1
- package/dist/components/formStore/FormStoreTableProvider.d.ts +6 -0
- package/dist/components/formStore/FormStoreTableProvider.js +86 -0
- package/dist/components/formStore/FormStoreTableProvider.js.map +1 -0
- package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.d.ts +5 -0
- package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.js +16 -0
- package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.js.map +1 -0
- package/dist/components/formStore/OneBlinkFormStoreColumnsButton.d.ts +5 -0
- package/dist/components/formStore/{ColumnsConfigurationButton.js → OneBlinkFormStoreColumnsButton.js} +8 -4
- package/dist/components/formStore/OneBlinkFormStoreColumnsButton.js.map +1 -0
- package/dist/components/formStore/OneBlinkFormStoreDownloadButton.d.ts +5 -0
- package/dist/components/formStore/{DownloadSubmissionDataButton.js → OneBlinkFormStoreDownloadButton.js} +8 -4
- package/dist/components/formStore/OneBlinkFormStoreDownloadButton.js.map +1 -0
- package/dist/components/formStore/OneBlinkFormStoreProvider.d.ts +8 -0
- package/dist/components/formStore/OneBlinkFormStoreProvider.js +25 -0
- package/dist/components/formStore/OneBlinkFormStoreProvider.js.map +1 -0
- package/dist/components/formStore/OneBlinkFormStoreRefreshButton.d.ts +5 -0
- package/dist/components/formStore/OneBlinkFormStoreRefreshButton.js +12 -0
- package/dist/components/formStore/OneBlinkFormStoreRefreshButton.js.map +1 -0
- package/dist/components/formStore/OneBlinkFormStoreTable.d.ts +4 -0
- package/dist/components/formStore/OneBlinkFormStoreTable.js +184 -0
- package/dist/components/formStore/OneBlinkFormStoreTable.js.map +1 -0
- package/dist/components/formStore/table/FormElementTableCell.js +28 -8
- package/dist/components/formStore/table/FormElementTableCell.js.map +1 -1
- package/dist/components/formStore/table/RepeatableSetCell.d.ts +0 -1
- package/dist/components/formStore/table/RepeatableSetCell.js +23 -25
- package/dist/components/formStore/table/RepeatableSetCell.js.map +1 -1
- package/dist/components/formStore/table/TableCellCopyButton.js +15 -18
- package/dist/components/formStore/table/TableCellCopyButton.js.map +1 -1
- package/dist/components/formStore/table/generateColumns.js.map +1 -1
- package/dist/components/formStore/table/useFormStoreTable.d.ts +43 -3
- package/dist/components/formStore/table/useFormStoreTable.js +11 -2
- package/dist/components/formStore/table/useFormStoreTable.js.map +1 -1
- package/dist/components/formStore/useFormStoreTableContext.d.ts +44 -0
- package/dist/components/formStore/useFormStoreTableContext.js +10 -0
- package/dist/components/formStore/useFormStoreTableContext.js.map +1 -0
- package/dist/components/{ErrorMessage.d.ts → messages/ErrorMessage.d.ts} +2 -3
- package/dist/components/{ErrorMessage.js → messages/ErrorMessage.js} +1 -1
- package/dist/components/messages/ErrorMessage.js.map +1 -0
- package/dist/components/messages/LargeIconMessage.d.ts +4 -3
- package/dist/components/messages/LargeIconMessage.js +31 -61
- package/dist/components/messages/LargeIconMessage.js.map +1 -1
- package/dist/components/{NoResourcesYet.d.ts → messages/NoResourcesYet.d.ts} +2 -3
- package/dist/components/{NoResourcesYet.js → messages/NoResourcesYet.js} +1 -1
- package/dist/components/messages/NoResourcesYet.js.map +1 -0
- package/dist/form-elements/FormElementDate.js +1 -1
- package/dist/form-elements/FormElementDate.js.map +1 -1
- package/dist/hooks/useSubmissionIdIsValid.d.ts +0 -1
- package/dist/hooks/useSubmissionIdIsValid.js +1 -2
- package/dist/hooks/useSubmissionIdIsValid.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
- package/dist/OneBlinkFormStoreView.d.ts +0 -8
- package/dist/OneBlinkFormStoreView.js +0 -55
- package/dist/OneBlinkFormStoreView.js.map +0 -1
- package/dist/components/ErrorMessage.js.map +0 -1
- package/dist/components/NoResourcesYet.js.map +0 -1
- package/dist/components/formStore/ColumnsConfigurationButton.d.ts +0 -10
- package/dist/components/formStore/ColumnsConfigurationButton.js.map +0 -1
- package/dist/components/formStore/DownloadSubmissionDataButton.d.ts +0 -13
- package/dist/components/formStore/DownloadSubmissionDataButton.js.map +0 -1
- package/dist/components/formStore/FormStore.d.ts +0 -9
- package/dist/components/formStore/FormStore.js +0 -103
- package/dist/components/formStore/FormStore.js.map +0 -1
- package/dist/components/formStore/table/index.d.ts +0 -17
- package/dist/components/formStore/table/index.js +0 -194
- package/dist/components/formStore/table/index.js.map +0 -1
- package/dist/hooks/useLegacyElements.d.ts +0 -16
- package/dist/hooks/useLegacyElements.js +0 -55
- package/dist/hooks/useLegacyElements.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"FormStore.js","sourceRoot":"","sources":["../../../src/components/formStore/FormStore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,WAAW,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,yBAAyB,MAAM,uCAAuC,CAAA;AAC7E,OAAO,cAAc,MAAM,SAAS,CAAA;AACpC,OAAO,iBAAiB,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC7D,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AQ,OAAG,EACvB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAC,SAAS,EACf,OAAO,EAAC,WAAW,EACnB,QAAQ,EAAE,CAAC,CAAC,6BAA6B,cAGlC,CACJ;YACP,oBAAC,IAAI,IAAC,IAAI,QAAC,EAAE,EAAE,EAAE;gBACd,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CACvB,oBAAC,cAAc,IACb,cAAc,EACZ,CAAC,gBAAgB,CAAC,MAAM,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,EAEtD,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,eAAe,GAChC,CACH,CAAC,CAAC,CAAC,CACF,oBAAC,cAAc,IACb,aAAa,EAAE,YAAY,EAC3B,KAAK,EAAC,oBAAoB,EAC1B,YAAY,+HAIG,CAClB;gBAEA,SAAS,IAAI,CACZ,oBAAC,kBAAkB,IAAC,OAAO,EAAC,yBAAyB,GAAG,CACzD;gBAEA,SAAS,IAAI,CACZ;oBACE,oBAAC,YAAY,IACX,KAAK,EAAC,8BAA8B,EACpC,YAAY,QACZ,SAAS,UAER,SAAS,CAAC,OAAO,CACL;oBACf,oBAAC,IAAI,IAAC,SAAS,QAAC,cAAc,EAAC,QAAQ;wBACrC,oBAAC,MAAM,IACL,OAAO,EAAC,UAAU,EAClB,KAAK,EAAC,SAAS,EACf,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,gBAGpB,CACJ,CACN,CACJ,CACI,CACF,CACH,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { useHistory } from 'react-router-dom'\nimport querystring from 'query-string'\nimport { FormStoreRecord } from '@oneblink/types/typescript/submissions'\nimport { formStoreService } from '@oneblink/apps'\nimport useInfiniteScrollDataLoad from '../../hooks/useInfiniteScrollDataLoad'\nimport FormStoreTable from './table'\nimport useFormStoreTable from './table/useFormStoreTable'\nimport { Box, Button, Grid, Typography } from '@mui/material'\nimport {\n FilterList as FilterIcon,\n Settings as SettingsIcon,\n Sync as SyncIcon,\n} from '@mui/icons-material'\nimport { Form } from '@oneblink/types/typescript/forms'\nimport useSubmissionIdValidationMessage, {\n validateIsUUID,\n} from '../../hooks/useSubmissionIdIsValid'\nimport { FormTypes } from '@oneblink/types'\nimport DownloadSubmissionDataButton from './DownloadSubmissionDataButton'\nimport ColumnsConfigurationButton from './ColumnsConfigurationButton'\nimport ErrorMessage from '../ErrorMessage'\nimport LoadingWithMessage from '../LoadingWithMessage'\nimport NoResourcesYet from '../NoResourcesYet'\n\nfunction FormStoreContainer({\n form,\n formElements,\n}: {\n form: Form\n formElements: FormTypes.FormElementWithName[]\n}) {\n const history = useHistory()\n const {\n isLoading,\n loadError,\n records: formStoreRecords,\n onTryAgain,\n onRefresh,\n filters,\n onChangeFilters,\n } = useInfiniteScrollDataLoad<\n formStoreService.FormStoreFilters,\n FormStoreRecord\n >({\n limit: 50,\n debounceSearchMs: 1000,\n onDefaultFilters: React.useCallback((query) => {\n let filters: formStoreService.FormStoreFilters = {}\n try {\n if (typeof query.filters === 'string') {\n filters = JSON.parse(query.filters)\n }\n } catch (error) {\n console.warn('Could not parse filter as JSON', error)\n }\n if (!filters.sorting) {\n filters.sorting = [\n { property: 'dateTimeSubmitted', direction: 'descending' },\n ]\n }\n return filters\n }, []),\n onSearch: React.useCallback(\n async (filters, paging, abortSignal) => {\n // Exclude all search parameters if searching\n // for a specific submission using an identifier\n const searchFilters = filters.submissionId\n ? {\n submissionId: filters.submissionId,\n }\n : filters\n const result = await formStoreService.searchFormStoreRecords(\n {\n paging,\n formId: form.id,\n filters: searchFilters,\n },\n abortSignal,\n )\n return {\n records: result.formStoreRecords,\n meta: result.meta,\n }\n },\n [form.id],\n ),\n onValidateFilters: React.useCallback(\n (currentFilters: formStoreService.FormStoreFilters) => {\n return validateIsUUID(currentFilters.submissionId?.$eq)\n },\n [],\n ),\n })\n\n React.useEffect(() => {\n history.replace({\n search: querystring.stringify({\n filters: JSON.stringify(filters),\n }),\n })\n }, [filters, history])\n\n const submissionIdValidationMessage = useSubmissionIdValidationMessage(\n filters.submissionId?.$eq,\n )\n\n const {\n getTableProps,\n getTableBodyProps,\n headerGroups,\n rows,\n prepareRow,\n allColumns,\n visibleColumns,\n getToggleHideAllColumnsProps,\n } = useFormStoreTable({\n formStoreRecords,\n filters,\n onChangeFilters,\n submissionIdValidationMessage,\n form,\n formElements,\n })\n\n return (\n <Box padding={2} paddingBottom={16}>\n <Grid container spacing={2} alignItems=\"center\">\n <Grid item xs={true}>\n <Typography variant=\"h6\">{form?.name}</Typography>\n </Grid>\n <Grid item xs={false}>\n <Button\n startIcon={<FilterIcon />}\n disabled={!Object.keys(filters).length}\n onClick={() => {\n onChangeFilters(\n (currentFilters) => ({\n sorting: currentFilters.sorting,\n }),\n false,\n )\n }}\n variant=\"text\"\n >\n Clear Filters\n </Button>\n </Grid>\n <Grid item xs={false}>\n <ColumnsConfigurationButton\n allColumns={allColumns}\n getToggleHideAllColumnsProps={getToggleHideAllColumnsProps}\n />\n </Grid>\n <Grid item xs={false}>\n <DownloadSubmissionDataButton\n disabled={false}\n form={form}\n filters={filters}\n visibleColumns={visibleColumns}\n />\n </Grid>\n <Grid item xs={false}>\n <Button\n startIcon={<SyncIcon />}\n onClick={onRefresh}\n color=\"primary\"\n variant=\"contained\"\n disabled={!!submissionIdValidationMessage}\n >\n Refresh\n </Button>\n </Grid>\n <Grid item xs={12}>\n {visibleColumns.length ? (\n <FormStoreTable\n isEmptyResults={\n !formStoreRecords.length && !isLoading && !loadError\n }\n getTableProps={getTableProps}\n getTableBodyProps={getTableBodyProps}\n headerGroups={headerGroups}\n rows={rows}\n prepareRow={prepareRow}\n onChangeFilters={onChangeFilters}\n />\n ) : (\n <NoResourcesYet\n IconComponent={SettingsIcon}\n title=\"No Columns Visible\"\n gutterBottom\n >\n It looks like you have hidden all of the available columns. Please\n enable at least one column to view submissions.\n </NoResourcesYet>\n )}\n\n {isLoading && (\n <LoadingWithMessage message=\"Loading more records...\" />\n )}\n\n {loadError && (\n <>\n <ErrorMessage\n title=\"Error Retrieving Submissions\"\n gutterBottom\n gutterTop\n >\n {loadError.message}\n </ErrorMessage>\n <Grid container justifyContent=\"center\">\n <Button\n variant=\"outlined\"\n color=\"primary\"\n onClick={() => onTryAgain()}\n >\n Try Again\n </Button>\n </Grid>\n </>\n )}\n </Grid>\n </Grid>\n </Box>\n )\n}\n\nexport default React.memo(FormStoreContainer)\n"]}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { TableInstance } from 'react-table';
|
3
|
-
import { SubmissionTypes } from '@oneblink/types';
|
4
|
-
import { OnChangeFilters } from '../../../hooks/useInfiniteScrollDataLoad';
|
5
|
-
import { formStoreService } from '@oneblink/apps';
|
6
|
-
declare type FormStoreTableInstance = TableInstance<SubmissionTypes.FormStoreRecord>;
|
7
|
-
declare function FormStoreTable({ getTableProps, getTableBodyProps, headerGroups, rows, prepareRow, isEmptyResults, onChangeFilters, }: {
|
8
|
-
getTableProps: FormStoreTableInstance['getTableProps'];
|
9
|
-
getTableBodyProps: FormStoreTableInstance['getTableBodyProps'];
|
10
|
-
headerGroups: FormStoreTableInstance['headerGroups'];
|
11
|
-
rows: FormStoreTableInstance['rows'];
|
12
|
-
prepareRow: FormStoreTableInstance['prepareRow'];
|
13
|
-
isEmptyResults: boolean;
|
14
|
-
onChangeFilters: OnChangeFilters<formStoreService.FormStoreFilters>;
|
15
|
-
}): JSX.Element;
|
16
|
-
declare const _default: React.MemoExoticComponent<typeof FormStoreTable>;
|
17
|
-
export default _default;
|
@@ -1,194 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import clsx from 'clsx';
|
3
|
-
import { Box, Paper, TableContainer, Tooltip } from '@mui/material';
|
4
|
-
import makeStyles from '@mui/styles/makeStyles';
|
5
|
-
import { FilterList as FilterListIcon, Warning as WarningIcon, ArrowDownward as SortingIcon, } from '@mui/icons-material';
|
6
|
-
import { IsHoveringProvider } from '../../../hooks/useIsHovering';
|
7
|
-
import { NoResourcesYet } from '../../NoResourcesYet';
|
8
|
-
import FormStoreIcon from '../display/FormStoreIcon';
|
9
|
-
import HeaderCellMoreButton from './HeaderCellMoreButton';
|
10
|
-
const useStyles = makeStyles((theme) => ({
|
11
|
-
tooltip: {
|
12
|
-
zIndex: theme.zIndex.drawer,
|
13
|
-
},
|
14
|
-
sortingIcon: {
|
15
|
-
transition: theme.transitions.create('transform'),
|
16
|
-
},
|
17
|
-
sortingIconDescending: {
|
18
|
-
transform: 'rotate(180deg)',
|
19
|
-
},
|
20
|
-
table: {
|
21
|
-
display: 'inline-block',
|
22
|
-
'& .tbody .tr:last-child .tc': {
|
23
|
-
borderBottom: 0,
|
24
|
-
},
|
25
|
-
'& .tc': {
|
26
|
-
padding: theme.spacing(1),
|
27
|
-
borderBottomColor: theme.palette.divider,
|
28
|
-
borderBottom: '1px solid',
|
29
|
-
display: 'flex',
|
30
|
-
alignItems: 'center',
|
31
|
-
'&.is-clickable': {
|
32
|
-
cursor: 'pointer',
|
33
|
-
transition: theme.transitions.create('transform'),
|
34
|
-
'&:hover': {
|
35
|
-
backgroundColor: theme.palette.action.hover,
|
36
|
-
},
|
37
|
-
},
|
38
|
-
},
|
39
|
-
'& .td': {
|
40
|
-
position: 'relative',
|
41
|
-
borderRight: '1px solid',
|
42
|
-
borderRightColor: theme.palette.divider,
|
43
|
-
overflowX: 'hidden',
|
44
|
-
// minus 1 to cater for the border
|
45
|
-
minHeight: `${parseInt(theme.spacing(5.5)) - 1}px`,
|
46
|
-
'&.is-resizing': {
|
47
|
-
borderRightStyle: 'dashed',
|
48
|
-
},
|
49
|
-
},
|
50
|
-
'& .th': {
|
51
|
-
position: 'relative',
|
52
|
-
fontWeight: theme.typography.fontWeightBold,
|
53
|
-
paddingRight: 0,
|
54
|
-
'& .th-content': {
|
55
|
-
flex: 1,
|
56
|
-
display: 'flex',
|
57
|
-
alignItems: 'center',
|
58
|
-
justifyContent: 'space-between',
|
59
|
-
borderRight: '1px solid',
|
60
|
-
borderRightColor: theme.palette.divider,
|
61
|
-
paddingRight: theme.spacing(),
|
62
|
-
'& .th-label': {
|
63
|
-
display: 'inline-flex',
|
64
|
-
alignItems: 'center',
|
65
|
-
'& .th-icon': {
|
66
|
-
marginLeft: theme.spacing(),
|
67
|
-
},
|
68
|
-
},
|
69
|
-
},
|
70
|
-
'& .resizer': {
|
71
|
-
display: 'inline-flex',
|
72
|
-
alignItems: 'center',
|
73
|
-
justifyContent: 'center',
|
74
|
-
borderWidth: 0,
|
75
|
-
borderLeftStyle: 'solid',
|
76
|
-
borderRightStyle: 'solid',
|
77
|
-
borderColor: theme.palette.divider,
|
78
|
-
paddingTop: theme.spacing(),
|
79
|
-
paddingBottom: theme.spacing(),
|
80
|
-
paddingRight: `calc(${theme.spacing(1)} + 1px)`,
|
81
|
-
position: 'absolute',
|
82
|
-
right: 0,
|
83
|
-
top: theme.spacing(0.5),
|
84
|
-
bottom: theme.spacing(0.5),
|
85
|
-
transform: `translateX(calc(${theme.spacing(0.5)} + 1px))`,
|
86
|
-
zIndex: 1,
|
87
|
-
// prevents from scrolling while dragging on touch devices
|
88
|
-
touchAction: 'none',
|
89
|
-
'&:hover': {
|
90
|
-
borderWidth: '1px',
|
91
|
-
},
|
92
|
-
'&.is-resizing': {
|
93
|
-
borderWidth: '1px',
|
94
|
-
borderColor: theme.palette.grey[700],
|
95
|
-
},
|
96
|
-
},
|
97
|
-
},
|
98
|
-
},
|
99
|
-
}));
|
100
|
-
function FormStoreTable({ getTableProps, getTableBodyProps, headerGroups, rows, prepareRow, isEmptyResults, onChangeFilters, }) {
|
101
|
-
const classes = useStyles();
|
102
|
-
return (React.createElement(React.Fragment, null,
|
103
|
-
React.createElement(Paper, null,
|
104
|
-
React.createElement(TableContainer, null,
|
105
|
-
React.createElement("div", { className: classes.table, ...getTableProps() },
|
106
|
-
React.createElement("div", { className: "thead" },
|
107
|
-
// Loop over the header rows
|
108
|
-
headerGroups.map((headerGroup) => (
|
109
|
-
// Apply the header row props
|
110
|
-
React.createElement("div", { ...headerGroup.getHeaderGroupProps(), className: "tr" },
|
111
|
-
// Loop over the headers in each row
|
112
|
-
headerGroup.headers.map((headerGroup) => {
|
113
|
-
var _a, _b, _c, _d, _e;
|
114
|
-
const sortingProperty = (_a = headerGroup.sorting) === null || _a === void 0 ? void 0 : _a.property;
|
115
|
-
const sortingDirection = (_b = headerGroup.sorting) === null || _b === void 0 ? void 0 : _b.direction;
|
116
|
-
return (React.createElement(Tooltip, { title: headerGroup.tooltip || '', arrow: true, key: headerGroup.id, classes: {
|
117
|
-
popper: classes.tooltip,
|
118
|
-
} },
|
119
|
-
React.createElement("div", { className: clsx('th tc', {
|
120
|
-
'is-clickable': !!sortingProperty,
|
121
|
-
}), onClick: sortingProperty
|
122
|
-
? () => {
|
123
|
-
onChangeFilters((currentFilters) => {
|
124
|
-
switch (sortingDirection) {
|
125
|
-
case 'ascending': {
|
126
|
-
return {
|
127
|
-
...currentFilters,
|
128
|
-
sorting: [
|
129
|
-
{
|
130
|
-
property: sortingProperty,
|
131
|
-
direction: 'descending',
|
132
|
-
},
|
133
|
-
],
|
134
|
-
};
|
135
|
-
}
|
136
|
-
case 'descending': {
|
137
|
-
return {
|
138
|
-
...currentFilters,
|
139
|
-
sorting: undefined,
|
140
|
-
};
|
141
|
-
}
|
142
|
-
default: {
|
143
|
-
return {
|
144
|
-
...currentFilters,
|
145
|
-
sorting: [
|
146
|
-
{
|
147
|
-
property: sortingProperty,
|
148
|
-
direction: 'ascending',
|
149
|
-
},
|
150
|
-
],
|
151
|
-
};
|
152
|
-
}
|
153
|
-
}
|
154
|
-
}, false);
|
155
|
-
}
|
156
|
-
: undefined, ...headerGroup.getHeaderProps() },
|
157
|
-
React.createElement(IsHoveringProvider, { className: "th-content" },
|
158
|
-
React.createElement("div", { className: "th-label" },
|
159
|
-
React.createElement("span", null, headerGroup.headerText),
|
160
|
-
sortingDirection && (React.createElement(SortingIcon, { fontSize: "small", color: "primary", className: clsx('th-icon', classes.sortingIcon, {
|
161
|
-
[classes.sortingIconDescending]: sortingDirection === 'descending',
|
162
|
-
}) })),
|
163
|
-
((_c = headerGroup.filter) === null || _c === void 0 ? void 0 : _c.isInvalid) ? (React.createElement(Tooltip, { title: ((_d = headerGroup.filter) === null || _d === void 0 ? void 0 : _d.validationMessage) ||
|
164
|
-
'' },
|
165
|
-
React.createElement(WarningIcon, { fontSize: "small", color: "error", className: "th-icon" }))) : ((_e = headerGroup.filter) === null || _e === void 0 ? void 0 : _e.value) ? (React.createElement(FilterListIcon, { fontSize: "small", color: "primary", className: "th-icon" })) : null),
|
166
|
-
React.createElement(HeaderCellMoreButton, { headerGroup: headerGroup, onHide: headerGroup.toggleHidden }),
|
167
|
-
React.createElement("div", { ...headerGroup.getResizerProps(), className: clsx('resizer', {
|
168
|
-
'is-resizing': headerGroup.isResizing,
|
169
|
-
}), onClick: (event) => {
|
170
|
-
event.stopPropagation();
|
171
|
-
} })))));
|
172
|
-
}))))),
|
173
|
-
!isEmptyResults ? (React.createElement("div", { ...getTableBodyProps(), className: "tbody" },
|
174
|
-
// Loop over the table rows
|
175
|
-
rows.map((row) => {
|
176
|
-
// Prepare the row for display
|
177
|
-
prepareRow(row);
|
178
|
-
return (
|
179
|
-
// Apply the row props
|
180
|
-
React.createElement("div", { ...row.getRowProps(), className: "tr" },
|
181
|
-
// Loop over the rows cells
|
182
|
-
row.cells.map((cell) => {
|
183
|
-
// Apply the cell props
|
184
|
-
return (React.createElement(IsHoveringProvider, { ...cell.getCellProps(), className: clsx('td tc', {
|
185
|
-
'is-resizing': cell.column.isResizing,
|
186
|
-
}) },
|
187
|
-
// Render the cell contents
|
188
|
-
cell.render('Cell')));
|
189
|
-
})));
|
190
|
-
}))) : (React.createElement(Box, { padding: 2 }))))),
|
191
|
-
isEmptyResults && (React.createElement(NoResourcesYet, { IconComponent: FormStoreIcon, title: "No Records Found..." }, "There are no Submissions matching your filters."))));
|
192
|
-
}
|
193
|
-
export default React.memo(FormStoreTable);
|
194
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/formStore/table/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,UAAU,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EACL,UAAU,IAAI,cAAc,EAC5B,OAAO,IAAI,WAAW,EACtB,aAAa,IAAI,WAAW,GAC7B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,aAAa,MAAM,0BAA0B,CAAA;AACpD,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AAIzD,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACvC,OAAO,EAAE;QACP,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM;KAC5B;IACD,WAAW,EAAE;QACX,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC;KAClD;IACD,qBAAqB,EAAE;QACrB,SAAS,EAAE,gBAAgB;KAC5B;IACD,KAAK,EAAE;QACL,OAAO,EAAE,cAAc;QACvB,6BAA6B,EAAE;YAC7B,YAAY,EAAE,CAAC;SAChB;QACD,OAAO,EAAE;YACP,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CA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AAC,CAAC,CACjB,gCAAS,iBAAiB,EAAE,EAAE,SAAS,EAAC,OAAO;oBAE3C,2BAA2B;oBAC3B,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;wBACf,8BAA8B;wBAC9B,UAAU,CAAC,GAAG,CAAC,CAAA;wBACf,OAAO;wBACL,sBAAsB;wBACtB,gCAAS,GAAG,CAAC,WAAW,EAAE,EAAE,SAAS,EAAC,IAAI;wBAEtC,2BAA2B;wBAC3B,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;4BACrB,uBAAuB;4BACvB,OAAO,CACL,oBAAC,kBAAkB,OACb,IAAI,CAAC,YAAY,EAAE,EACvB,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE;oCACvB,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;iCACtC,CAAC;4BAGA,2BAA2B;4BAC3B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAEF,CACtB,CAAA;wBACH,CAAC,CAAC,CAEA,CACP,CAAA;oBACH,CAAC,CAAC,CAEA,CACP,CAAC,CAAC,CAAC,CACF,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC,GAAI,CACpB,CACG,CACS,CACX;QAEP,cAAc,IAAI,CACjB,oBAAC,cAAc,IACb,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAC,qBAAqB,sDAGZ,CAClB,CACA,CACJ,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { TableInstance } from 'react-table'\nimport clsx from 'clsx'\nimport { Box, Paper, TableContainer, Tooltip } from '@mui/material'\nimport makeStyles from '@mui/styles/makeStyles'\nimport {\n FilterList as FilterListIcon,\n Warning as WarningIcon,\n ArrowDownward as SortingIcon,\n} from '@mui/icons-material'\nimport { SubmissionTypes } from '@oneblink/types'\nimport { IsHoveringProvider } from '../../../hooks/useIsHovering'\nimport { NoResourcesYet } from '../../NoResourcesYet'\nimport FormStoreIcon from '../display/FormStoreIcon'\nimport HeaderCellMoreButton from './HeaderCellMoreButton'\nimport { OnChangeFilters } from '../../../hooks/useInfiniteScrollDataLoad'\nimport { formStoreService } from '@oneblink/apps'\n\nconst useStyles = makeStyles((theme) => ({\n tooltip: {\n zIndex: theme.zIndex.drawer,\n },\n sortingIcon: {\n transition: theme.transitions.create('transform'),\n },\n sortingIconDescending: {\n transform: 'rotate(180deg)',\n },\n table: {\n display: 'inline-block',\n '& .tbody .tr:last-child .tc': {\n borderBottom: 0,\n },\n '& .tc': {\n padding: theme.spacing(1),\n borderBottomColor: theme.palette.divider,\n borderBottom: '1px solid',\n display: 'flex',\n alignItems: 'center',\n '&.is-clickable': {\n cursor: 'pointer',\n transition: theme.transitions.create('transform'),\n '&:hover': {\n backgroundColor: theme.palette.action.hover,\n },\n },\n },\n '& .td': {\n position: 'relative',\n borderRight: '1px solid',\n borderRightColor: theme.palette.divider,\n overflowX: 'hidden',\n // minus 1 to cater for the border\n minHeight: `${parseInt(theme.spacing(5.5)) - 1}px`,\n '&.is-resizing': {\n borderRightStyle: 'dashed',\n },\n },\n '& .th': {\n position: 'relative',\n fontWeight: theme.typography.fontWeightBold,\n paddingRight: 0,\n '& .th-content': {\n flex: 1,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n borderRight: '1px solid',\n borderRightColor: theme.palette.divider,\n paddingRight: theme.spacing(),\n '& .th-label': {\n display: 'inline-flex',\n alignItems: 'center',\n '& .th-icon': {\n marginLeft: theme.spacing(),\n },\n },\n },\n '& .resizer': {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderWidth: 0,\n borderLeftStyle: 'solid',\n borderRightStyle: 'solid',\n borderColor: theme.palette.divider,\n paddingTop: theme.spacing(),\n paddingBottom: theme.spacing(),\n paddingRight: `calc(${theme.spacing(1)} + 1px)`,\n position: 'absolute',\n right: 0,\n top: theme.spacing(0.5),\n bottom: theme.spacing(0.5),\n transform: `translateX(calc(${theme.spacing(0.5)} + 1px))`,\n zIndex: 1,\n // prevents from scrolling while dragging on touch devices\n touchAction: 'none',\n '&:hover': {\n borderWidth: '1px',\n },\n '&.is-resizing': {\n borderWidth: '1px',\n borderColor: theme.palette.grey[700],\n },\n },\n },\n },\n}))\n\ntype FormStoreTableInstance = TableInstance<SubmissionTypes.FormStoreRecord>\n\nfunction FormStoreTable({\n getTableProps,\n getTableBodyProps,\n headerGroups,\n rows,\n prepareRow,\n isEmptyResults,\n onChangeFilters,\n}: {\n getTableProps: FormStoreTableInstance['getTableProps']\n getTableBodyProps: FormStoreTableInstance['getTableBodyProps']\n headerGroups: FormStoreTableInstance['headerGroups']\n rows: FormStoreTableInstance['rows']\n prepareRow: FormStoreTableInstance['prepareRow']\n isEmptyResults: boolean\n onChangeFilters: OnChangeFilters<formStoreService.FormStoreFilters>\n}) {\n const classes = useStyles()\n\n return (\n <>\n <Paper>\n <TableContainer>\n <div className={classes.table} {...getTableProps()}>\n <div className=\"thead\">\n {\n // Loop over the header rows\n headerGroups.map((headerGroup) => (\n // Apply the header row props\n <div {...headerGroup.getHeaderGroupProps()} className=\"tr\">\n {\n // Loop over the headers in each row\n headerGroup.headers.map((headerGroup) => {\n const sortingProperty = headerGroup.sorting?.property\n const sortingDirection = headerGroup.sorting?.direction\n\n return (\n <Tooltip\n title={headerGroup.tooltip || ''}\n arrow\n key={headerGroup.id}\n classes={{\n popper: classes.tooltip,\n }}\n >\n <div\n className={clsx('th tc', {\n 'is-clickable': !!sortingProperty,\n })}\n onClick={\n sortingProperty\n ? () => {\n onChangeFilters((currentFilters) => {\n switch (sortingDirection) {\n case 'ascending': {\n return {\n ...currentFilters,\n sorting: [\n {\n property: sortingProperty,\n direction: 'descending',\n },\n ],\n }\n }\n case 'descending': {\n return {\n ...currentFilters,\n sorting: undefined,\n }\n }\n default: {\n return {\n ...currentFilters,\n sorting: [\n {\n property: sortingProperty,\n direction: 'ascending',\n },\n ],\n }\n }\n }\n }, false)\n }\n : undefined\n }\n // Apply the header cell props\n {...headerGroup.getHeaderProps()}\n >\n <IsHoveringProvider className=\"th-content\">\n <div className=\"th-label\">\n <span>{headerGroup.headerText}</span>\n {sortingDirection && (\n <SortingIcon\n fontSize=\"small\"\n color=\"primary\"\n className={clsx(\n 'th-icon',\n classes.sortingIcon,\n {\n [classes.sortingIconDescending]:\n sortingDirection === 'descending',\n },\n )}\n />\n )}\n {headerGroup.filter?.isInvalid ? (\n <Tooltip\n title={\n headerGroup.filter?.validationMessage ||\n ''\n }\n >\n <WarningIcon\n fontSize=\"small\"\n color=\"error\"\n className=\"th-icon\"\n />\n </Tooltip>\n ) : headerGroup.filter?.value ? (\n <FilterListIcon\n fontSize=\"small\"\n color=\"primary\"\n className=\"th-icon\"\n />\n ) : null}\n </div>\n <HeaderCellMoreButton\n headerGroup={headerGroup}\n onHide={headerGroup.toggleHidden}\n />\n <div\n {...headerGroup.getResizerProps()}\n className={clsx('resizer', {\n 'is-resizing': headerGroup.isResizing,\n })}\n onClick={(event) => {\n event.stopPropagation()\n }}\n />\n </IsHoveringProvider>\n </div>\n </Tooltip>\n )\n })\n }\n </div>\n ))\n }\n </div>\n {!isEmptyResults ? (\n <div {...getTableBodyProps()} className=\"tbody\">\n {\n // Loop over the table rows\n rows.map((row) => {\n // Prepare the row for display\n prepareRow(row)\n return (\n // Apply the row props\n <div {...row.getRowProps()} className=\"tr\">\n {\n // Loop over the rows cells\n row.cells.map((cell) => {\n // Apply the cell props\n return (\n <IsHoveringProvider\n {...cell.getCellProps()}\n className={clsx('td tc', {\n 'is-resizing': cell.column.isResizing,\n })}\n >\n {\n // Render the cell contents\n cell.render('Cell')\n }\n </IsHoveringProvider>\n )\n })\n }\n </div>\n )\n })\n }\n </div>\n ) : (\n <Box padding={2} />\n )}\n </div>\n </TableContainer>\n </Paper>\n\n {isEmptyResults && (\n <NoResourcesYet\n IconComponent={FormStoreIcon}\n title=\"No Records Found...\"\n >\n There are no Submissions matching your filters.\n </NoResourcesYet>\n )}\n </>\n )\n}\n\nexport default React.memo(FormStoreTable)\n"]}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import { FormTypes } from '@oneblink/types';
|
2
|
-
export declare const legacyNameRegex: RegExp;
|
3
|
-
declare const useLegacyFormElements: (formElements: FormTypes.FormElement[]) => {
|
4
|
-
formElementsUsingLegacyStorage: {
|
5
|
-
name: string;
|
6
|
-
label: string;
|
7
|
-
id: string;
|
8
|
-
}[];
|
9
|
-
formElementsUsingLegacyNames: {
|
10
|
-
name: string;
|
11
|
-
label: string;
|
12
|
-
id: string;
|
13
|
-
}[];
|
14
|
-
};
|
15
|
-
export default useLegacyFormElements;
|
16
|
-
export declare const useFormElementLegacyConfigMessage: (formElement: FormTypes.FormElement) => string | undefined;
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import { useMemo } from 'react';
|
2
|
-
import { formElementsService, typeCastService } from '@oneblink/sdk-core';
|
3
|
-
export const legacyNameRegex = /[^a-zA-Z\d_-]/;
|
4
|
-
const checkStorageType = (element) => {
|
5
|
-
const storageElement = typeCastService.formElements.toStorageElement(element);
|
6
|
-
if (storageElement &&
|
7
|
-
(!storageElement.storageType || storageElement.storageType === 'legacy')) {
|
8
|
-
return {
|
9
|
-
label: storageElement.label,
|
10
|
-
name: storageElement.name,
|
11
|
-
id: storageElement.id,
|
12
|
-
};
|
13
|
-
}
|
14
|
-
};
|
15
|
-
const checkName = (element) => {
|
16
|
-
const namedElement = typeCastService.formElements.toNamedElement(element);
|
17
|
-
if (!!namedElement && legacyNameRegex.test(namedElement.name)) {
|
18
|
-
const formElementWithoutForm = typeCastService.formElements.toFormElementWithoutForm(namedElement);
|
19
|
-
return {
|
20
|
-
name: namedElement.name,
|
21
|
-
label: (formElementWithoutForm === null || formElementWithoutForm === void 0 ? void 0 : formElementWithoutForm.label) || 'Nested Form',
|
22
|
-
id: namedElement.id,
|
23
|
-
};
|
24
|
-
}
|
25
|
-
};
|
26
|
-
const useLegacyFormElements = (formElements) => {
|
27
|
-
return useMemo(() => {
|
28
|
-
const formElementsUsingLegacyStorage = [];
|
29
|
-
const formElementsUsingLegacyNames = [];
|
30
|
-
formElementsService.forEachFormElement(formElements || [], (element) => {
|
31
|
-
const legacyStorageType = checkStorageType(element);
|
32
|
-
if (legacyStorageType) {
|
33
|
-
formElementsUsingLegacyStorage.push(legacyStorageType);
|
34
|
-
}
|
35
|
-
const legacyName = checkName(element);
|
36
|
-
if (legacyName) {
|
37
|
-
formElementsUsingLegacyNames.push(legacyName);
|
38
|
-
}
|
39
|
-
});
|
40
|
-
return {
|
41
|
-
formElementsUsingLegacyStorage,
|
42
|
-
formElementsUsingLegacyNames,
|
43
|
-
};
|
44
|
-
}, [formElements]);
|
45
|
-
};
|
46
|
-
export default useLegacyFormElements;
|
47
|
-
const formElementLegacyConfigMessage = 'Element is using unsupported configuration';
|
48
|
-
export const useFormElementLegacyConfigMessage = (formElement) => {
|
49
|
-
return useMemo(() => {
|
50
|
-
if (checkStorageType(formElement) || checkName(formElement)) {
|
51
|
-
return formElementLegacyConfigMessage;
|
52
|
-
}
|
53
|
-
}, [formElement]);
|
54
|
-
};
|
55
|
-
//# sourceMappingURL=useLegacyElements.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useLegacyElements.js","sourceRoot":"","sources":["../../src/hooks/useLegacyElements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGzE,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAA;AAE9C,MAAM,gBAAgB,GAAG,CAAC,OAA8B,EAAE,EAAE;IAC1D,MAAM,cAAc,GAAG,eAAe,CAAC,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAC7E,IACE,cAAc;QACd,CAAC,CAAC,cAAc,CAAC,WAAW,IAAI,cAAc,CAAC,W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C,CAAA;QACF,OAAO;YACL,8BAA8B;YAC9B,4BAA4B;SAC7B,CAAA;IACH,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAA;AACpB,CAAC,CAAA;AAED,eAAe,qBAAqB,CAAA;AAEpC,MAAM,8BAA8B,GAClC,4CAA4C,CAAA;AAC9C,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC/C,WAAkC,EAClC,EAAE;IACF,OAAO,OAAO,CAAqB,GAAG,EAAE;QACtC,IAAI,gBAAgB,CAAC,WAAW,CAAC,IAAI,SAAS,CAAC,WAAW,CAAC,EAAE;YAC3D,OAAO,8BAA8B,CAAA;SACtC;IACH,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;AACnB,CAAC,CAAA","sourcesContent":["import { useMemo } from 'react'\nimport { formElementsService, typeCastService } from '@oneblink/sdk-core'\nimport { FormTypes } from '@oneblink/types'\n\nexport const legacyNameRegex = /[^a-zA-Z\\d_-]/\n\nconst checkStorageType = (element: FormTypes.FormElement) => {\n const storageElement = typeCastService.formElements.toStorageElement(element)\n if (\n storageElement &&\n (!storageElement.storageType || storageElement.storageType === 'legacy')\n ) {\n return {\n label: storageElement.label,\n name: storageElement.name,\n id: storageElement.id,\n }\n }\n}\n\nconst checkName = (element: FormTypes.FormElement) => {\n const namedElement: FormTypes.FormElementWithName | undefined =\n typeCastService.formElements.toNamedElement(element)\n if (!!namedElement && legacyNameRegex.test(namedElement.name)) {\n const formElementWithoutForm =\n typeCastService.formElements.toFormElementWithoutForm(namedElement)\n return {\n name: namedElement.name,\n label: formElementWithoutForm?.label || 'Nested Form',\n id: namedElement.id,\n }\n }\n}\n\nconst useLegacyFormElements = (formElements: FormTypes.FormElement[]) => {\n return useMemo(() => {\n const formElementsUsingLegacyStorage: Array<{\n name: string\n label: string\n id: string\n }> = []\n const formElementsUsingLegacyNames: Array<{\n name: string\n label: string\n id: string\n }> = []\n formElementsService.forEachFormElement(formElements || [], (element) => {\n const legacyStorageType = checkStorageType(element)\n if (legacyStorageType) {\n formElementsUsingLegacyStorage.push(legacyStorageType)\n }\n\n const legacyName = checkName(element)\n if (legacyName) {\n formElementsUsingLegacyNames.push(legacyName)\n }\n })\n return {\n formElementsUsingLegacyStorage,\n formElementsUsingLegacyNames,\n }\n }, [formElements])\n}\n\nexport default useLegacyFormElements\n\nconst formElementLegacyConfigMessage =\n 'Element is using unsupported configuration'\nexport const useFormElementLegacyConfigMessage = (\n formElement: FormTypes.FormElement,\n) => {\n return useMemo<string | undefined>(() => {\n if (checkStorageType(formElement) || checkName(formElement)) {\n return formElementLegacyConfigMessage\n }\n }, [formElement])\n}\n"]}
|