@tsed/react-formio 2.2.3 → 2.3.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/components/table/components/defaultCell.component.d.ts +1 -0
- package/dist/components/table/filters/selectColumnFilter.component.d.ts +9 -1
- package/dist/components/table/hooks/useCustomTable.hook.d.ts +15 -1
- package/dist/components/table/hooks/useDragnDropRow.hook.d.ts +1 -0
- package/dist/components/table/table.stories.d.ts +2 -2
- package/dist/components/table/utils/mapFormToColumns.d.ts +2 -2
- package/dist/index.js +114 -89
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +113 -85
- package/dist/index.modern.js.map +1 -1
- package/dist/package.json +3 -0
- package/package.json +7 -3
- package/src/components/table/components/defaultCells.component.tsx +12 -3
- package/src/components/table/filters/selectColumnFilter.component.spec.tsx +21 -0
- package/src/components/table/filters/selectColumnFilter.component.tsx +38 -12
- package/src/components/table/hooks/useCustomTable.hook.tsx +31 -1
- package/src/components/table/table.component.tsx +1 -0
- package/src/components/table/utils/mapFormToColumns.tsx +5 -4
package/dist/index.modern.js
CHANGED
|
@@ -450,7 +450,10 @@ function DefaultCells({
|
|
|
450
450
|
}
|
|
451
451
|
return /*#__PURE__*/React.createElement("td", _extends({
|
|
452
452
|
colSpan: colspan
|
|
453
|
-
}, cell.getCellProps(
|
|
453
|
+
}, cell.getCellProps({
|
|
454
|
+
className: cell.column.className,
|
|
455
|
+
style: cell.column.style
|
|
456
|
+
}), {
|
|
454
457
|
key: `tableInstance.page.cells.${cell.value || "value"}.${i}`
|
|
455
458
|
}), cell.render("Cell"));
|
|
456
459
|
}));
|
|
@@ -1164,24 +1167,24 @@ function Form(props) {
|
|
|
1164
1167
|
Form.propTypes = {
|
|
1165
1168
|
name: PropTypes.string,
|
|
1166
1169
|
className: PropTypes.string,
|
|
1167
|
-
/**
|
|
1168
|
-
*
|
|
1170
|
+
/**
|
|
1171
|
+
*
|
|
1169
1172
|
*/
|
|
1170
1173
|
src: PropTypes.string,
|
|
1171
|
-
/**
|
|
1172
|
-
* url to fetch form
|
|
1174
|
+
/**
|
|
1175
|
+
* url to fetch form
|
|
1173
1176
|
*/
|
|
1174
1177
|
url: PropTypes.string,
|
|
1175
|
-
/**
|
|
1176
|
-
* Raw form object
|
|
1178
|
+
/**
|
|
1179
|
+
* Raw form object
|
|
1177
1180
|
*/
|
|
1178
1181
|
form: PropTypes.object,
|
|
1179
|
-
/**
|
|
1180
|
-
* Data submission
|
|
1182
|
+
/**
|
|
1183
|
+
* Data submission
|
|
1181
1184
|
*/
|
|
1182
1185
|
submission: PropTypes.object,
|
|
1183
|
-
/**
|
|
1184
|
-
* Configuration option
|
|
1186
|
+
/**
|
|
1187
|
+
* Configuration option
|
|
1185
1188
|
*/
|
|
1186
1189
|
options: PropTypes.shape({
|
|
1187
1190
|
readOnly: PropTypes.bool,
|
|
@@ -2290,34 +2293,58 @@ function FormSettings(props) {
|
|
|
2290
2293
|
}, i18n("Save settings")));
|
|
2291
2294
|
}
|
|
2292
2295
|
|
|
2293
|
-
function
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
+
function useSelectColumnFilter(props) {
|
|
2297
|
+
const {
|
|
2298
|
+
column
|
|
2299
|
+
} = props;
|
|
2296
2300
|
const {
|
|
2297
2301
|
id,
|
|
2298
|
-
preFilteredRows
|
|
2299
|
-
filterValue,
|
|
2300
|
-
setFilter
|
|
2302
|
+
preFilteredRows
|
|
2301
2303
|
} = column;
|
|
2302
2304
|
const {
|
|
2303
2305
|
choices: customChoices
|
|
2304
2306
|
} = column;
|
|
2305
|
-
const
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
}
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2307
|
+
const {
|
|
2308
|
+
filterValue,
|
|
2309
|
+
setFilter
|
|
2310
|
+
} = column;
|
|
2311
|
+
const choices = (() => {
|
|
2312
|
+
if (customChoices) {
|
|
2313
|
+
if (typeof customChoices === "function") {
|
|
2314
|
+
return customChoices(props);
|
|
2315
|
+
}
|
|
2316
|
+
return customChoices;
|
|
2317
|
+
}
|
|
2318
|
+
return [...new Set(preFilteredRows.map(row => row.values[id]))].filter(value => value).map(value => ({
|
|
2319
|
+
label: value,
|
|
2320
|
+
value
|
|
2321
|
+
}));
|
|
2322
|
+
})();
|
|
2323
|
+
const onChange = (_, value) => {
|
|
2324
|
+
setFilter(value || undefined);
|
|
2325
|
+
};
|
|
2326
|
+
return {
|
|
2313
2327
|
value: filterValue,
|
|
2328
|
+
onChange,
|
|
2314
2329
|
choices: [{
|
|
2315
2330
|
value: "",
|
|
2316
2331
|
label: "All"
|
|
2317
|
-
}].concat(choices)
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2332
|
+
}].concat(choices)
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2335
|
+
function SelectColumnFilter(props) {
|
|
2336
|
+
const {
|
|
2337
|
+
value,
|
|
2338
|
+
choices,
|
|
2339
|
+
onChange
|
|
2340
|
+
} = useSelectColumnFilter(props);
|
|
2341
|
+
return /*#__PURE__*/React.createElement(Select, {
|
|
2342
|
+
key: `filter-${props.column.id}`,
|
|
2343
|
+
name: `filter-${props.column.id}`,
|
|
2344
|
+
size: "sm",
|
|
2345
|
+
value: value,
|
|
2346
|
+
choices: choices,
|
|
2347
|
+
onChange: onChange
|
|
2321
2348
|
});
|
|
2322
2349
|
}
|
|
2323
2350
|
|
|
@@ -7087,23 +7114,23 @@ function RemoveModal(_ref) {
|
|
|
7087
7114
|
}
|
|
7088
7115
|
|
|
7089
7116
|
class ReactComponent extends Components.components.field {
|
|
7090
|
-
/**
|
|
7091
|
-
* This is the first phase of component building where the component is instantiated.
|
|
7092
|
-
*
|
|
7093
|
-
* @param component - The component definition created from the settings form.
|
|
7094
|
-
* @param options - Any options passed into the renderer.
|
|
7095
|
-
* @param data - The submission data where this component's data exists.
|
|
7117
|
+
/**
|
|
7118
|
+
* This is the first phase of component building where the component is instantiated.
|
|
7119
|
+
*
|
|
7120
|
+
* @param component - The component definition created from the settings form.
|
|
7121
|
+
* @param options - Any options passed into the renderer.
|
|
7122
|
+
* @param data - The submission data where this component's data exists.
|
|
7096
7123
|
*/ // eslint-disable-next-line no-useless-constructor,import/no-anonymous-default-export
|
|
7097
7124
|
constructor(component, options, data) {
|
|
7098
7125
|
super(component, options, data);
|
|
7099
7126
|
this.reactInstance = void 0;
|
|
7100
7127
|
this.shouldSetValue = void 0;
|
|
7101
7128
|
this.dataForSetting = void 0;
|
|
7102
|
-
/**
|
|
7103
|
-
* The user has changed the value in the component and the value needs to be updated on the main submission object and other components notified of a change event.
|
|
7104
|
-
*
|
|
7105
|
-
* @param value
|
|
7106
|
-
* @param flags
|
|
7129
|
+
/**
|
|
7130
|
+
* The user has changed the value in the component and the value needs to be updated on the main submission object and other components notified of a change event.
|
|
7131
|
+
*
|
|
7132
|
+
* @param value
|
|
7133
|
+
* @param flags
|
|
7107
7134
|
*/
|
|
7108
7135
|
this.updateValue = (value, flags) => {
|
|
7109
7136
|
flags = flags || {};
|
|
@@ -7117,37 +7144,37 @@ class ReactComponent extends Components.components.field {
|
|
|
7117
7144
|
get $reactNode() {
|
|
7118
7145
|
return this.refs[`react-${this.id}`];
|
|
7119
7146
|
}
|
|
7120
|
-
/**
|
|
7121
|
-
* This method is called any time the component needs to be rebuilt. It is most frequently used to listen to other
|
|
7122
|
-
* components using the this.on() function.
|
|
7147
|
+
/**
|
|
7148
|
+
* This method is called any time the component needs to be rebuilt. It is most frequently used to listen to other
|
|
7149
|
+
* components using the this.on() function.
|
|
7123
7150
|
*/
|
|
7124
7151
|
init() {
|
|
7125
7152
|
return super.init();
|
|
7126
7153
|
}
|
|
7127
|
-
/**
|
|
7128
|
-
* This method is called before the component is going to be destroyed, which is when the component instance is
|
|
7129
|
-
* destroyed. This is different from detach which is when the component instance still exists but the dom instance is
|
|
7130
|
-
* removed.
|
|
7154
|
+
/**
|
|
7155
|
+
* This method is called before the component is going to be destroyed, which is when the component instance is
|
|
7156
|
+
* destroyed. This is different from detach which is when the component instance still exists but the dom instance is
|
|
7157
|
+
* removed.
|
|
7131
7158
|
*/
|
|
7132
7159
|
destroy() {
|
|
7133
7160
|
return super.destroy();
|
|
7134
7161
|
}
|
|
7135
|
-
/**
|
|
7136
|
-
* The second phase of component building where the component is rendered as an HTML string.
|
|
7137
|
-
*
|
|
7138
|
-
* @returns {string} - The return is the full string of the component
|
|
7162
|
+
/**
|
|
7163
|
+
* The second phase of component building where the component is rendered as an HTML string.
|
|
7164
|
+
*
|
|
7165
|
+
* @returns {string} - The return is the full string of the component
|
|
7139
7166
|
*/
|
|
7140
7167
|
render() {
|
|
7141
7168
|
// For react components, we simply render as a div which will become the react instance.
|
|
7142
7169
|
// By calling super.render(string) it will wrap the component with the needed wrappers to make it a full component.
|
|
7143
7170
|
return super.render(`<div ref="react-${this.id}"></div>`);
|
|
7144
7171
|
}
|
|
7145
|
-
/**
|
|
7146
|
-
* The third phase of component building where the component has been attached to the DOM as 'element' and is ready
|
|
7147
|
-
* to have its javascript events attached.
|
|
7148
|
-
*
|
|
7149
|
-
* @param element
|
|
7150
|
-
* @returns {Promise<void>} - Return a promise that resolves when the attach is complete.
|
|
7172
|
+
/**
|
|
7173
|
+
* The third phase of component building where the component has been attached to the DOM as 'element' and is ready
|
|
7174
|
+
* to have its javascript events attached.
|
|
7175
|
+
*
|
|
7176
|
+
* @param element
|
|
7177
|
+
* @returns {Promise<void>} - Return a promise that resolves when the attach is complete.
|
|
7151
7178
|
*/
|
|
7152
7179
|
async attach(element) {
|
|
7153
7180
|
super.attach(element);
|
|
@@ -7166,9 +7193,9 @@ class ReactComponent extends Components.components.field {
|
|
|
7166
7193
|
}
|
|
7167
7194
|
}
|
|
7168
7195
|
}
|
|
7169
|
-
/**
|
|
7170
|
-
* The fourth phase of component building where the component is being removed from the page. This could be a redraw
|
|
7171
|
-
* or it is being removed from the form.
|
|
7196
|
+
/**
|
|
7197
|
+
* The fourth phase of component building where the component is being removed from the page. This could be a redraw
|
|
7198
|
+
* or it is being removed from the form.
|
|
7172
7199
|
*/
|
|
7173
7200
|
detach() {
|
|
7174
7201
|
// @ts-ignore
|
|
@@ -7178,24 +7205,24 @@ class ReactComponent extends Components.components.field {
|
|
|
7178
7205
|
}
|
|
7179
7206
|
super.detach();
|
|
7180
7207
|
}
|
|
7181
|
-
/**
|
|
7182
|
-
* Override this function to render a react component.
|
|
7208
|
+
/**
|
|
7209
|
+
* Override this function to render a react component.
|
|
7183
7210
|
*/
|
|
7184
7211
|
renderReact() {
|
|
7185
7212
|
return null;
|
|
7186
7213
|
}
|
|
7187
|
-
/**
|
|
7188
|
-
* Override this function to insert your custom component.
|
|
7189
|
-
*
|
|
7190
|
-
* @param element
|
|
7214
|
+
/**
|
|
7215
|
+
* Override this function to insert your custom component.
|
|
7216
|
+
*
|
|
7217
|
+
* @param element
|
|
7191
7218
|
*/
|
|
7192
7219
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7193
7220
|
attachReact(element) {
|
|
7194
7221
|
// eslint-disable-next-line react/no-render-return-value
|
|
7195
7222
|
return ReactDOM.render(this.renderReact(), element);
|
|
7196
7223
|
}
|
|
7197
|
-
/**
|
|
7198
|
-
* Override this function.
|
|
7224
|
+
/**
|
|
7225
|
+
* Override this function.
|
|
7199
7226
|
*/
|
|
7200
7227
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7201
7228
|
detachReact(element) {
|
|
@@ -7203,11 +7230,11 @@ class ReactComponent extends Components.components.field {
|
|
|
7203
7230
|
ReactDOM.unmountComponentAtNode(element);
|
|
7204
7231
|
}
|
|
7205
7232
|
}
|
|
7206
|
-
/**
|
|
7207
|
-
* Something external has set a value and our component needs to be updated to reflect that. For example, loading a submission.
|
|
7208
|
-
*
|
|
7209
|
-
* @param value
|
|
7210
|
-
* @param flags
|
|
7233
|
+
/**
|
|
7234
|
+
* Something external has set a value and our component needs to be updated to reflect that. For example, loading a submission.
|
|
7235
|
+
*
|
|
7236
|
+
* @param value
|
|
7237
|
+
* @param flags
|
|
7211
7238
|
*/
|
|
7212
7239
|
setValue(value, flags) {
|
|
7213
7240
|
if (this.reactInstance) {
|
|
@@ -7221,10 +7248,10 @@ class ReactComponent extends Components.components.field {
|
|
|
7221
7248
|
}
|
|
7222
7249
|
return false;
|
|
7223
7250
|
}
|
|
7224
|
-
/**
|
|
7225
|
-
* Get the current value of the component. Should return the value set in the react component.
|
|
7226
|
-
*
|
|
7227
|
-
* @returns {*}
|
|
7251
|
+
/**
|
|
7252
|
+
* Get the current value of the component. Should return the value set in the react component.
|
|
7253
|
+
*
|
|
7254
|
+
* @returns {*}
|
|
7228
7255
|
*/
|
|
7229
7256
|
getValue() {
|
|
7230
7257
|
if (this.reactInstance) {
|
|
@@ -7232,13 +7259,13 @@ class ReactComponent extends Components.components.field {
|
|
|
7232
7259
|
}
|
|
7233
7260
|
return this.defaultValue;
|
|
7234
7261
|
}
|
|
7235
|
-
/**
|
|
7236
|
-
* Override normal validation check to insert custom validation in react component.
|
|
7237
|
-
*
|
|
7238
|
-
* @param data
|
|
7239
|
-
* @param dirty
|
|
7240
|
-
* @param rowData
|
|
7241
|
-
* @returns {boolean}
|
|
7262
|
+
/**
|
|
7263
|
+
* Override normal validation check to insert custom validation in react component.
|
|
7264
|
+
*
|
|
7265
|
+
* @param data
|
|
7266
|
+
* @param dirty
|
|
7267
|
+
* @param rowData
|
|
7268
|
+
* @returns {boolean}
|
|
7242
7269
|
*/
|
|
7243
7270
|
checkValidity(data, dirty, rowData) {
|
|
7244
7271
|
const valid = super.checkValidity(data, dirty, rowData);
|
|
@@ -7279,6 +7306,7 @@ function mapFormToColumns(form) {
|
|
|
7279
7306
|
const column = {
|
|
7280
7307
|
Header: component.label || component.title || component.key,
|
|
7281
7308
|
accessor: `data.${component.key}`,
|
|
7309
|
+
className: "text-center",
|
|
7282
7310
|
Cell: props => /*#__PURE__*/React.createElement(DefaultCell, _extends({}, props, {
|
|
7283
7311
|
render: value => cmp.asString(value)
|
|
7284
7312
|
}))
|
|
@@ -7421,5 +7449,5 @@ function mapPagination({
|
|
|
7421
7449
|
};
|
|
7422
7450
|
}
|
|
7423
7451
|
|
|
7424
|
-
export { ActionsTable, Alert, ButtonTab, Card, DefaultArrowSort, DefaultCell, DefaultCellHeader, DefaultCellOperations, DefaultColumnFilter, DefaultOperationButton, Form, FormAccess, FormAction, FormBuilder, FormControl, FormEdit, FormEditCTAs, FormParameters, FormSettings, FormsTable, InputTags, InputText, LEFT_PAGE, Loader, Modal, Pagination, RIGHT_PAGE, ReactComponent, RemoveModal, Select, SelectColumnFilter, SliderColumnFilter, SubmissionsTable, Table, Tabs, callLast, defaultDisplayChoices, getOperationCallback, getPageNumbers, iconClass, mapFormToColumns, mapPagination, stopPropagationWrapper, swapElements, useCustomTable, useForm, useFormEdit, useModal, useOperations, useTooltip };
|
|
7452
|
+
export { ActionsTable, Alert, ButtonTab, Card, DefaultArrowSort, DefaultCell, DefaultCellHeader, DefaultCellOperations, DefaultColumnFilter, DefaultOperationButton, Form, FormAccess, FormAction, FormBuilder, FormControl, FormEdit, FormEditCTAs, FormParameters, FormSettings, FormsTable, InputTags, InputText, LEFT_PAGE, Loader, Modal, Pagination, RIGHT_PAGE, ReactComponent, RemoveModal, Select, SelectColumnFilter, SliderColumnFilter, SubmissionsTable, Table, Tabs, callLast, defaultDisplayChoices, getOperationCallback, getPageNumbers, iconClass, mapFormToColumns, mapPagination, stopPropagationWrapper, swapElements, useCustomTable, useForm, useFormEdit, useModal, useOperations, useSelectColumnFilter, useTooltip };
|
|
7425
7453
|
//# sourceMappingURL=index.modern.js.map
|