@true-engineering/true-react-common-ui-kit 3.37.0 → 3.39.0
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/README.md +12 -0
- package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.d.ts +1 -1
- package/dist/components/FlexibleTable/types.d.ts +3 -1
- package/dist/true-react-common-ui-kit.js +19 -8
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +19 -8
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.ts +4 -0
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +11 -1
- package/src/components/FlexibleTable/types.ts +7 -1
- package/src/components/Select/Select.stories.tsx +1 -0
- package/src/components/Select/Select.tsx +5 -1
package/package.json
CHANGED
|
@@ -65,9 +65,17 @@ export function FlexibleTableCell<
|
|
|
65
65
|
cellVerticalAlign,
|
|
66
66
|
shouldRenderDataId,
|
|
67
67
|
shouldRenderComponent = isNotEmpty,
|
|
68
|
+
onCellClick,
|
|
68
69
|
} = config[columnName] ?? {};
|
|
69
70
|
|
|
70
71
|
const isSticky = isOldSticky || position === 'sticky';
|
|
72
|
+
const isClickable = !isLoading && isNotEmpty(onCellClick);
|
|
73
|
+
|
|
74
|
+
const cellComponentProps: IValueComponentProps<Row, Row[keyof Row]> = {
|
|
75
|
+
...valueComponentProps,
|
|
76
|
+
value,
|
|
77
|
+
row,
|
|
78
|
+
};
|
|
71
79
|
|
|
72
80
|
const Table = TableRenders[renderMode];
|
|
73
81
|
|
|
@@ -77,6 +85,7 @@ export function FlexibleTableCell<
|
|
|
77
85
|
[classes.sticky]: isSticky,
|
|
78
86
|
[classes.second]: isSecond,
|
|
79
87
|
[classes.loading]: isLoading,
|
|
88
|
+
[classes.clickable]: isClickable,
|
|
80
89
|
})}
|
|
81
90
|
style={{
|
|
82
91
|
textAlign: cellAlign,
|
|
@@ -88,6 +97,7 @@ export function FlexibleTableCell<
|
|
|
88
97
|
left,
|
|
89
98
|
verticalAlign: cellVerticalAlign,
|
|
90
99
|
}}
|
|
100
|
+
onClick={isClickable ? (event) => onCellClick?.(event, cellComponentProps) : undefined}
|
|
91
101
|
{...addDataAttributes({ id: shouldRenderDataId ? columnName : undefined })}
|
|
92
102
|
>
|
|
93
103
|
{isLoading ? (
|
|
@@ -96,7 +106,7 @@ export function FlexibleTableCell<
|
|
|
96
106
|
</div>
|
|
97
107
|
) : (
|
|
98
108
|
applyAction(shouldRenderComponent, value, row, columnName) &&
|
|
99
|
-
applyAction(component,
|
|
109
|
+
applyAction(component, cellComponentProps)
|
|
100
110
|
)}
|
|
101
111
|
</Table.Cell>
|
|
102
112
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties, ReactNode } from 'react';
|
|
1
|
+
import { CSSProperties, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import { IRenderNode } from '../../types';
|
|
3
3
|
|
|
4
4
|
export type IFlexibleTableRenderMode = 'table' | 'divs';
|
|
@@ -27,6 +27,11 @@ export interface IValueComponentProps<Values, Value> {
|
|
|
27
27
|
onSetNestedComponent: (component?: ReactNode) => void;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export type ICellClickHandler<Values, Value> = (
|
|
31
|
+
event: MouseEvent,
|
|
32
|
+
cellComponentProps: IValueComponentProps<Values, Value>,
|
|
33
|
+
) => void;
|
|
34
|
+
|
|
30
35
|
export interface IFlexibleTableRowConfig<
|
|
31
36
|
Values extends ITableRow,
|
|
32
37
|
Key extends keyof Values,
|
|
@@ -52,6 +57,7 @@ export interface IFlexibleTableRowConfig<
|
|
|
52
57
|
* @default isNotEmpty
|
|
53
58
|
*/
|
|
54
59
|
shouldRenderComponent?: boolean | ((value: Values[Key], values: Values, key: Key) => boolean);
|
|
60
|
+
onCellClick?: ICellClickHandler<Values, Values[Key]>;
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
export type IFlexibleTableConfigType<
|
|
@@ -276,6 +276,10 @@ export function Select<Value>(
|
|
|
276
276
|
);
|
|
277
277
|
|
|
278
278
|
const handleListOpen = () => {
|
|
279
|
+
if (isReadonly) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
279
283
|
if (!isListOpen) {
|
|
280
284
|
setIsListOpen(true);
|
|
281
285
|
|
|
@@ -612,7 +616,7 @@ export function Select<Value>(
|
|
|
612
616
|
<div className={classes.root} onKeyDown={handleKeyDown} ref={root}>
|
|
613
617
|
<div
|
|
614
618
|
className={clsx(classes.inputWrapper, isDisabled && classes.disabled)}
|
|
615
|
-
onClick={isDisabled ? undefined : handleOnClick}
|
|
619
|
+
onClick={isDisabled || isReadonly ? undefined : handleOnClick}
|
|
616
620
|
ref={inputWrapper}
|
|
617
621
|
>
|
|
618
622
|
<Input
|