onekijs-ui 0.19.14 → 0.19.15
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/typings.d.ts +2 -0
- package/dist/index.js +15 -11
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +15 -11
- package/dist/index.module.js.map +1 -1
- package/dist/styles/border.d.ts +1 -1
- package/dist/styles/flex.d.ts +1 -1
- package/dist/styles/size.d.ts +6 -6
- package/dist/styles/typography.d.ts +2 -2
- package/package.json +3 -3
- package/src/components/table/components/FormTableComponent.tsx +9 -3
- package/src/components/table/components/cells/CheckboxCellComponent.tsx +2 -1
- package/src/components/table/components/cells/InputCellComponent.tsx +2 -1
- package/src/components/table/components/cells/SelectCellComponent.tsx +2 -1
- package/src/components/table/components/cells/TextareaCellComponent.tsx +2 -1
- package/src/components/table/typings.ts +2 -0
|
@@ -40,10 +40,12 @@ export type FormTableProps<T = any, I extends TableItem<T> = TableItem<T>, S ext
|
|
|
40
40
|
export type FormTableContext<T = any> = {
|
|
41
41
|
tableName: string;
|
|
42
42
|
onSelect: (item: TableItem<T>, selected: boolean) => void;
|
|
43
|
+
onAdd: (initialValue: Partial<T> | undefined) => void;
|
|
43
44
|
addLabel: string;
|
|
44
45
|
required?: boolean;
|
|
45
46
|
maxLength?: number;
|
|
46
47
|
minLength?: number;
|
|
48
|
+
editable?: boolean;
|
|
47
49
|
};
|
|
48
50
|
export type FormTableItemDisplayerProps<T = any> = {
|
|
49
51
|
value: T;
|
package/dist/index.js
CHANGED
|
@@ -10245,11 +10245,11 @@ const SelectRowComponent = ({ item }) => {
|
|
|
10245
10245
|
};
|
|
10246
10246
|
const FooterComponent = () => {
|
|
10247
10247
|
const form = onekijsFramework.useForm();
|
|
10248
|
-
const { tableName, addLabel, maxLength } = useFormTableContext();
|
|
10248
|
+
const { tableName, addLabel, maxLength, onAdd } = useFormTableContext();
|
|
10249
10249
|
const isSingleColumnTable = useTableColumns().find((c) => c.id === '');
|
|
10250
10250
|
const addRow = (e) => {
|
|
10251
|
-
form.add(tableName, isSingleColumnTable ? undefined : {});
|
|
10252
10251
|
e.preventDefault();
|
|
10252
|
+
onAdd(isSingleColumnTable ? undefined : {});
|
|
10253
10253
|
};
|
|
10254
10254
|
const currentSize = (form.getValue(tableName) || []).length;
|
|
10255
10255
|
if (maxLength !== undefined && currentSize >= maxLength)
|
|
@@ -10295,7 +10295,11 @@ const FormTableComponent = React.memo(({ addLabel = 'add', controller, value, on
|
|
|
10295
10295
|
onChange && onChange(currentValues.filter((v) => getId(v) !== getId(value)));
|
|
10296
10296
|
}
|
|
10297
10297
|
};
|
|
10298
|
-
|
|
10298
|
+
const onAdd = (initialValue) => {
|
|
10299
|
+
formTableContext.current.editable = true;
|
|
10300
|
+
form.add(name, initialValue);
|
|
10301
|
+
};
|
|
10302
|
+
return { tableName: name, onSelect, onAdd, addLabel, required, minLength, maxLength };
|
|
10299
10303
|
});
|
|
10300
10304
|
// listen on value change from the form
|
|
10301
10305
|
// for the initial value in the table controller
|
|
@@ -10416,12 +10420,12 @@ FormTable.displayName = 'FormTable';
|
|
|
10416
10420
|
|
|
10417
10421
|
const CheckboxCellComponent = (options) => {
|
|
10418
10422
|
const CheckboxCellComponent = ({ item, column, rowIndex }) => {
|
|
10419
|
-
const { tableName } = useFormTableContext();
|
|
10423
|
+
const { tableName, editable } = useFormTableContext();
|
|
10420
10424
|
const { size, ...checkboxOptions } = options;
|
|
10421
10425
|
// if the id is empty, it's a single table column and the value is the row itself
|
|
10422
10426
|
const name = column.id ? `${tableName}.${rowIndex}.${column.id}` : `${tableName}.${rowIndex}`;
|
|
10423
10427
|
const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
|
|
10424
|
-
return (React.createElement(FormCheckbox, { layout: "table", ...checkboxOptions, name: name, className: addClassname('o-table-checkbox', className) }));
|
|
10428
|
+
return (React.createElement(FormCheckbox, { layout: "table", ...checkboxOptions, name: name, className: addClassname('o-table-checkbox', className), editable: editable ?? options.editable }));
|
|
10425
10429
|
};
|
|
10426
10430
|
CheckboxCellComponent.displayName = 'CheckboxCellComponent';
|
|
10427
10431
|
return CheckboxCellComponent;
|
|
@@ -10520,11 +10524,11 @@ const enumColumn = (id, options) => {
|
|
|
10520
10524
|
|
|
10521
10525
|
const InputCellComponent = (options) => {
|
|
10522
10526
|
const InputCellComponent = ({ item, column, rowIndex }) => {
|
|
10523
|
-
const { tableName } = useFormTableContext();
|
|
10527
|
+
const { tableName, editable } = useFormTableContext();
|
|
10524
10528
|
const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
|
|
10525
10529
|
// if the id is empty, it's a single table column and the value is the row itself
|
|
10526
10530
|
const name = column.id ? `${tableName}.${rowIndex}.${column.id}` : `${tableName}.${rowIndex}`;
|
|
10527
|
-
return (React.createElement(FormInput, { size: "small", layout: "table", ...options, name: name, className: addClassname('o-table-input', className) }));
|
|
10531
|
+
return (React.createElement(FormInput, { size: "small", layout: "table", ...options, name: name, className: addClassname('o-table-input', className), editable: editable ?? options.editable }));
|
|
10528
10532
|
};
|
|
10529
10533
|
InputCellComponent.displayName = 'InputCellComponent';
|
|
10530
10534
|
return InputCellComponent;
|
|
@@ -10597,7 +10601,7 @@ const numberColumn = (id, options) => {
|
|
|
10597
10601
|
|
|
10598
10602
|
const SelectCellComponent = (options, broker) => {
|
|
10599
10603
|
const SelectCellComponent = ({ item, column, rowIndex }) => {
|
|
10600
|
-
const { tableName } = useFormTableContext();
|
|
10604
|
+
const { tableName, editable } = useFormTableContext();
|
|
10601
10605
|
const controller = useSelectController(options.dataSource, options);
|
|
10602
10606
|
const service = controller.asService();
|
|
10603
10607
|
// if the id is empty, it's a single table column and the value is the row itself
|
|
@@ -10610,7 +10614,7 @@ const SelectCellComponent = (options, broker) => {
|
|
|
10610
10614
|
broker.removeSubscriber(name);
|
|
10611
10615
|
};
|
|
10612
10616
|
}, [name, service]);
|
|
10613
|
-
return (React.createElement(Component, { size: "small", layout: "table", ...options, name: name, className: addClassname('o-table-select', className), controller: controller }));
|
|
10617
|
+
return (React.createElement(Component, { size: "small", layout: "table", ...options, name: name, className: addClassname('o-table-select', className), controller: controller, editable: editable ?? options.editable }));
|
|
10614
10618
|
};
|
|
10615
10619
|
SelectCellComponent.displayName = 'SelectCellComponent';
|
|
10616
10620
|
return SelectCellComponent;
|
|
@@ -10770,11 +10774,11 @@ FormTextarea.displayName = 'FormTextarea';
|
|
|
10770
10774
|
|
|
10771
10775
|
const TextareaCellComponent = (options) => {
|
|
10772
10776
|
const TextareaCellComponent = ({ item, column, rowIndex }) => {
|
|
10773
|
-
const { tableName } = useFormTableContext();
|
|
10777
|
+
const { tableName, editable } = useFormTableContext();
|
|
10774
10778
|
// if the id is empty, it's a single table column and the value is the row itself
|
|
10775
10779
|
const name = column.id ? `${tableName}.${rowIndex}.${column.id}` : `${tableName}.${rowIndex}`;
|
|
10776
10780
|
const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
|
|
10777
|
-
return (React.createElement(FormTextarea, { size: "small", layout: "table", ...options, name: name, className: addClassname('o-table-textarea', className) }));
|
|
10781
|
+
return (React.createElement(FormTextarea, { size: "small", layout: "table", ...options, name: name, className: addClassname('o-table-textarea', className), editable: editable ?? options.editable }));
|
|
10778
10782
|
};
|
|
10779
10783
|
TextareaCellComponent.displayName = 'TextareaCellComponent';
|
|
10780
10784
|
return TextareaCellComponent;
|