onekijs-ui 0.18.2 → 0.19.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/dist/components/accordion/AccordionService.d.ts +2 -1
- package/dist/components/accordion/components/AccordionComponent.d.ts +1 -1
- package/dist/components/accordion/hooks/useAccordionPanel.d.ts +1 -1
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/accordion/typings.d.ts +5 -3
- package/dist/components/button/typings.d.ts +1 -0
- package/dist/components/icon/RefreshIcon.d.ts +4 -0
- package/dist/components/list/components/CollectionListComponent.d.ts +1 -1
- package/dist/components/list/components/ListBodyComponent.d.ts +1 -1
- package/dist/components/list/components/LoadingItem.d.ts +1 -0
- package/dist/components/list/components/VirtualListComponent.d.ts +1 -1
- package/dist/components/table/components/TableActionComponent.d.ts +3 -0
- package/dist/components/table/components/TableLoadingComponent.d.ts +1 -1
- package/dist/components/table/components/TableLoadingRowComponent.d.ts +2 -1
- package/dist/components/table/typings.d.ts +5 -0
- package/dist/index.js +190 -60
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +190 -60
- package/dist/index.module.js.map +1 -1
- package/dist/styles/border.d.ts +1 -1
- package/dist/styles/size.d.ts +6 -6
- package/dist/styles/typings.d.ts +21 -7
- package/dist/styles/typography.d.ts +2 -2
- package/package.json +3 -3
- package/src/components/accordion/AccordionService.ts +21 -6
- package/src/components/accordion/components/AccordionComponent.tsx +2 -2
- package/src/components/accordion/components/AccordionPanel.tsx +6 -3
- package/src/components/accordion/hooks/useAccordionPanel.ts +2 -2
- package/src/components/accordion/index.ts +1 -1
- package/src/components/accordion/style.ts +2 -2
- package/src/components/accordion/typings.ts +5 -3
- package/src/components/button/style.ts +16 -7
- package/src/components/button/typings.ts +1 -0
- package/src/components/icon/RefreshIcon.tsx +41 -0
- package/src/components/list/components/CollectionListComponent.tsx +1 -1
- package/src/components/list/components/ListBodyComponent.tsx +18 -5
- package/src/components/list/components/LoadingItem.tsx +4 -2
- package/src/components/list/components/VirtualListComponent.tsx +2 -2
- package/src/components/list/hooks/useListView.tsx +4 -1
- package/src/components/notifications/components/NotificationsComponent.tsx +7 -1
- package/src/components/notifications/style.ts +13 -2
- package/src/components/select/components/SelectOptionComponent.tsx +4 -2
- package/src/components/table/components/ControllerTableComponent.tsx +38 -19
- package/src/components/table/components/TableActionComponent.tsx +22 -0
- package/src/components/table/components/TableBodyComponent.tsx +12 -4
- package/src/components/table/components/TableBodyRowComponent.tsx +15 -14
- package/src/components/table/components/TableLoadingComponent.tsx +1 -1
- package/src/components/table/components/TableLoadingRowComponent.tsx +7 -3
- package/src/components/table/style.ts +16 -1
- package/src/components/table/typings.ts +5 -0
- package/src/styles/typings.ts +21 -7
- package/src/theme/base.tsx +21 -7
package/dist/index.module.js
CHANGED
|
@@ -40,28 +40,41 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
let AccordionService = class AccordionService extends DefaultService {
|
|
43
|
-
initPanel(uid, initialActive = false) {
|
|
43
|
+
initPanel(uid, initialActive = false, initialExpand = false) {
|
|
44
44
|
if (this.state.panels[uid] === undefined) {
|
|
45
45
|
this.state.panels[uid] = {
|
|
46
46
|
uid,
|
|
47
47
|
active: initialActive,
|
|
48
|
+
expanded: initialExpand,
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
}
|
|
52
|
+
activate(uid) {
|
|
53
|
+
const panel = this.state.panels[uid];
|
|
54
|
+
if (panel) {
|
|
55
|
+
Object.keys(this.state.panels).forEach((uid) => {
|
|
56
|
+
this.state.panels[uid].active = false;
|
|
57
|
+
});
|
|
58
|
+
panel.active = true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
51
61
|
collapse(uid) {
|
|
52
62
|
const panel = this.state.panels[uid];
|
|
53
63
|
if (panel) {
|
|
54
64
|
panel.active = false;
|
|
65
|
+
panel.expanded = false;
|
|
55
66
|
}
|
|
56
67
|
}
|
|
57
68
|
expand(uid) {
|
|
58
69
|
const panel = this.state.panels[uid];
|
|
59
70
|
if (panel) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
Object.keys(this.state.panels).forEach((uid) => {
|
|
72
|
+
this.state.panels[uid].active = false;
|
|
73
|
+
if (!this.state.multiExpand) {
|
|
74
|
+
this.state.panels[uid].expanded = false;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
panel.expanded = true;
|
|
65
78
|
panel.active = true;
|
|
66
79
|
}
|
|
67
80
|
}
|
|
@@ -69,9 +82,15 @@ let AccordionService = class AccordionService extends DefaultService {
|
|
|
69
82
|
__decorate([
|
|
70
83
|
reducer,
|
|
71
84
|
__metadata("design:type", Function),
|
|
72
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
85
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
73
86
|
__metadata("design:returntype", void 0)
|
|
74
87
|
], AccordionService.prototype, "initPanel", null);
|
|
88
|
+
__decorate([
|
|
89
|
+
reducer,
|
|
90
|
+
__metadata("design:type", Function),
|
|
91
|
+
__metadata("design:paramtypes", [String]),
|
|
92
|
+
__metadata("design:returntype", void 0)
|
|
93
|
+
], AccordionService.prototype, "activate", null);
|
|
75
94
|
__decorate([
|
|
76
95
|
reducer,
|
|
77
96
|
__metadata("design:type", Function),
|
|
@@ -271,7 +290,7 @@ const AccordionContainer = ({ className, children }) => {
|
|
|
271
290
|
*
|
|
272
291
|
* @example
|
|
273
292
|
* ```tsx
|
|
274
|
-
* <AccordionComponent
|
|
293
|
+
* <AccordionComponent multiExpand="true" />
|
|
275
294
|
* ```
|
|
276
295
|
*
|
|
277
296
|
* @group Accordion
|
|
@@ -280,7 +299,7 @@ const AccordionContainer = ({ className, children }) => {
|
|
|
280
299
|
*/
|
|
281
300
|
const AccordionComponent = ({ Component = AccordionContainer, ...props }) => {
|
|
282
301
|
const [state, service] = useService(AccordionService, {
|
|
283
|
-
|
|
302
|
+
multiExpand: props.multiExpand,
|
|
284
303
|
panels: {},
|
|
285
304
|
animate: props.animate ?? 150,
|
|
286
305
|
mode: props.mode ?? 'push',
|
|
@@ -635,11 +654,11 @@ const accordionStyle = ({ border = false, animate = 150, theme }) => {
|
|
|
635
654
|
|
|
636
655
|
.o-accordion-panel-active {
|
|
637
656
|
.o-accordion-panel-title {
|
|
638
|
-
${backgroundColor(t.activeBgColor, { hover: t.
|
|
657
|
+
${backgroundColor(t.activeBgColor, { hover: t.activeBgColor })}
|
|
639
658
|
${color(t.activeFontColor, { hover: t.activeFontColor })}
|
|
640
659
|
}
|
|
641
660
|
.o-accordion-content {
|
|
642
|
-
|
|
661
|
+
|
|
643
662
|
}
|
|
644
663
|
}
|
|
645
664
|
|
|
@@ -670,7 +689,7 @@ const accordionStyle = ({ border = false, animate = 150, theme }) => {
|
|
|
670
689
|
*
|
|
671
690
|
* @example
|
|
672
691
|
* ```tsx
|
|
673
|
-
* <Accordion
|
|
692
|
+
* <Accordion multiExpand="false" />
|
|
674
693
|
* ```
|
|
675
694
|
*
|
|
676
695
|
* @see AccordionComponent
|
|
@@ -680,14 +699,14 @@ const Accordion = styled(AccordionComponent) `
|
|
|
680
699
|
${accordionStyle}
|
|
681
700
|
`;
|
|
682
701
|
|
|
683
|
-
const useAccordionPanel = (initialActive = false) => {
|
|
702
|
+
const useAccordionPanel = (initialActive = false, initialExpand = false) => {
|
|
684
703
|
const uid = useId();
|
|
685
704
|
const service = useAccordionService();
|
|
686
705
|
const state = useAccordionState();
|
|
687
706
|
const panel = state.panels[uid];
|
|
688
707
|
useEffect(() => {
|
|
689
708
|
if (panel === undefined) {
|
|
690
|
-
service.initPanel(uid, initialActive);
|
|
709
|
+
service.initPanel(uid, initialActive, initialExpand);
|
|
691
710
|
}
|
|
692
711
|
});
|
|
693
712
|
return panel;
|
|
@@ -845,8 +864,9 @@ const AccordionPanelTitle = ({ title, active, onClick }) => {
|
|
|
845
864
|
React.createElement("span", null, `${title}`)));
|
|
846
865
|
};
|
|
847
866
|
|
|
848
|
-
const AccordionPanel = ({ title, initialActive, children, Component = AccordionPanelTitle, link, }) => {
|
|
849
|
-
|
|
867
|
+
const AccordionPanel = ({ title, initialActive, initialExpand, children, Component = AccordionPanelTitle, link, }) => {
|
|
868
|
+
initialExpand = initialExpand ?? initialActive;
|
|
869
|
+
const panel = useAccordionPanel(initialActive, initialExpand);
|
|
850
870
|
const service = useAccordionService();
|
|
851
871
|
const { animate } = useAccordionState();
|
|
852
872
|
const router = useTryRouter();
|
|
@@ -887,8 +907,8 @@ const AccordionPanel = ({ title, initialActive, children, Component = AccordionP
|
|
|
887
907
|
}
|
|
888
908
|
return (React.createElement("div", { className: `o-accordion-panel${panel.active ? ' o-accordion-panel-active' : ''}` },
|
|
889
909
|
React.createElement(Component, { title: title, active: panel.active, onClick: toggle, link: link }),
|
|
890
|
-
React.createElement(CSSTransition, { in: panel.
|
|
891
|
-
React.createElement("div", null,
|
|
910
|
+
React.createElement(CSSTransition, { in: panel.expanded, classNames: "o-accordion-animate", timeout: animate, mountOnEnter: false, appear: false, unmountOnExit: true, onExiting: onExiting, onEntering: onEntering, onEntered: onEntered },
|
|
911
|
+
React.createElement("div", null, React.createElement("div", { className: "o-accordion-content" }, children)))));
|
|
892
912
|
};
|
|
893
913
|
|
|
894
914
|
const ButtonComponent = React.forwardRef((props, ref) => {
|
|
@@ -929,7 +949,8 @@ const zIndex = cssProperty('z-index');
|
|
|
929
949
|
const getColor = (key, pattern) => {
|
|
930
950
|
return `${key}${pattern === 'solid' ? '' : ucfirst(pattern)}`;
|
|
931
951
|
};
|
|
932
|
-
const buttonStyle = ({ kind = 'primary', pattern = 'solid', disabled, IconComponent, theme, }) => {
|
|
952
|
+
const buttonStyle = ({ kind = 'primary', pattern = 'solid', size = 'medium', disabled, IconComponent, theme, }) => {
|
|
953
|
+
const uSize = ucfirst(size);
|
|
933
954
|
const t = theme.buttons[kind];
|
|
934
955
|
const bgColor = get(t, getColor('bgColor', pattern));
|
|
935
956
|
const hoverBgColor = get(t, getColor('hoverBgColor', pattern));
|
|
@@ -937,6 +958,13 @@ const buttonStyle = ({ kind = 'primary', pattern = 'solid', disabled, IconCompon
|
|
|
937
958
|
const hoverFontColor = get(t, getColor('hoverColor', pattern));
|
|
938
959
|
const bColor = get(t, getColor('borderColor', pattern));
|
|
939
960
|
const hoverBorderColor = get(t, getColor('hoverBorderColor', pattern));
|
|
961
|
+
const tPaddingX = get(t, `paddingX${uSize}`);
|
|
962
|
+
const tPaddingY = get(t, `paddingY${uSize}`);
|
|
963
|
+
const tBorderRadius = get(t, `borderRadius${uSize}`);
|
|
964
|
+
const tBorderWidth = get(t, `borderWidth${uSize}`);
|
|
965
|
+
const tLineHeight = get(t, `lineHeight${uSize}`);
|
|
966
|
+
const tFontSize = get(t, `fontSize${uSize}`);
|
|
967
|
+
const tLetterSpacing = get(t, `letterSpacing${uSize}`);
|
|
940
968
|
return css `
|
|
941
969
|
${display('inline-flex')}
|
|
942
970
|
${alignItems('center')}
|
|
@@ -946,11 +974,11 @@ const buttonStyle = ({ kind = 'primary', pattern = 'solid', disabled, IconCompon
|
|
|
946
974
|
${color(fontColor, {
|
|
947
975
|
hover: disabled ? fontColor : hoverFontColor,
|
|
948
976
|
})}
|
|
949
|
-
${paddingX(
|
|
950
|
-
${paddingY(
|
|
951
|
-
${borderRadius(
|
|
977
|
+
${paddingX(tPaddingX)}
|
|
978
|
+
${paddingY(tPaddingY)}
|
|
979
|
+
${borderRadius(tBorderRadius)}
|
|
952
980
|
${borderStyle(t.borderStyle)}
|
|
953
|
-
${borderWidth(
|
|
981
|
+
${borderWidth(tBorderWidth)}
|
|
954
982
|
${borderColor(bColor, {
|
|
955
983
|
hover: disabled ? bColor : hoverBorderColor,
|
|
956
984
|
})}
|
|
@@ -963,9 +991,9 @@ const buttonStyle = ({ kind = 'primary', pattern = 'solid', disabled, IconCompon
|
|
|
963
991
|
${whiteSpace(t.whiteSpace)}
|
|
964
992
|
${textOverflow(t.textOverflow)}
|
|
965
993
|
${textTransform(t.textTransform)}
|
|
966
|
-
${letterSpacing(
|
|
967
|
-
${lineHeight(
|
|
968
|
-
${fontSize(
|
|
994
|
+
${letterSpacing(tLetterSpacing)}
|
|
995
|
+
${lineHeight(tLineHeight)}
|
|
996
|
+
${fontSize(tFontSize)}
|
|
969
997
|
${opacity(disabled ? 0.6 : 1)}
|
|
970
998
|
${marginLeft(IconComponent ? 'xs' : 'none')}
|
|
971
999
|
${outline('none')}
|
|
@@ -4462,6 +4490,7 @@ const useListView = ({ controller, height, itemHeight = defaultItemHeight, overs
|
|
|
4462
4490
|
if (controller.status !== LoadingStatus.NotReady) {
|
|
4463
4491
|
if (isVirtual) {
|
|
4464
4492
|
if (controller.status === LoadingStatus.NotInitialized) {
|
|
4493
|
+
scrollToOffset(0);
|
|
4465
4494
|
controller.load(preload, undefined, true);
|
|
4466
4495
|
}
|
|
4467
4496
|
else {
|
|
@@ -4478,7 +4507,7 @@ const useListView = ({ controller, height, itemHeight = defaultItemHeight, overs
|
|
|
4478
4507
|
let to;
|
|
4479
4508
|
const first = Math.max(0, lastVirtualItemIndex - increment);
|
|
4480
4509
|
if (lastVirtualItemIndex > 0) {
|
|
4481
|
-
let slice = state.items.slice(first, lastVirtualItemIndex);
|
|
4510
|
+
let slice = state.items.slice(first, lastVirtualItemIndex).filter(() => true);
|
|
4482
4511
|
if (slice.length < lastVirtualItemIndex - first) {
|
|
4483
4512
|
const arr = new Array(lastVirtualItemIndex - first);
|
|
4484
4513
|
arr.splice(arr.length - slice.length, slice.length, ...slice);
|
|
@@ -4588,7 +4617,9 @@ const LoadingItem = ({ className }) => {
|
|
|
4588
4617
|
var LoadingItem$1 = styled(LoadingItem) `
|
|
4589
4618
|
${height('full')}
|
|
4590
4619
|
${width('full')}
|
|
4591
|
-
${
|
|
4620
|
+
${(props) => {
|
|
4621
|
+
return minHeight(`${props.minHeight ?? 37}px`);
|
|
4622
|
+
}}
|
|
4592
4623
|
${marginY('1px')}
|
|
4593
4624
|
animation: skeleton-loading 1s linear infinite alternate;
|
|
4594
4625
|
|
|
@@ -4793,8 +4824,9 @@ const ListBodyComponent = ({ autoRefresh, bodyRef, className, follow, height, it
|
|
|
4793
4824
|
mouseRef.current = false;
|
|
4794
4825
|
});
|
|
4795
4826
|
useEffect(() => {
|
|
4827
|
+
const ref = parentRef ? parentRef : bodyRef;
|
|
4828
|
+
//console.log('parentRef', parentRef, 'ref', ref)
|
|
4796
4829
|
const atBottom = () => {
|
|
4797
|
-
const ref = parentRef ? parentRef : bodyRef;
|
|
4798
4830
|
if (ref && ref.current) {
|
|
4799
4831
|
const sh = ref.current.scrollHeight;
|
|
4800
4832
|
const st = ref.current.scrollTop;
|
|
@@ -4804,9 +4836,21 @@ const ListBodyComponent = ({ autoRefresh, bodyRef, className, follow, height, it
|
|
|
4804
4836
|
}
|
|
4805
4837
|
return false;
|
|
4806
4838
|
};
|
|
4807
|
-
if (tail && scrollToIndex && totalSize &&
|
|
4808
|
-
|
|
4809
|
-
|
|
4839
|
+
if (tail && scrollToIndex && totalSize && ref && ref.current) {
|
|
4840
|
+
// console.log(
|
|
4841
|
+
// 'scrollTop',
|
|
4842
|
+
// ref.current.scrollTop,
|
|
4843
|
+
// 'mouseRef',
|
|
4844
|
+
// mouseRef.current,
|
|
4845
|
+
// 'wheelRef',
|
|
4846
|
+
// wheelRef.current,
|
|
4847
|
+
// 'applyTail',
|
|
4848
|
+
// tailRef.current.applyTail,
|
|
4849
|
+
// 'atBottom',
|
|
4850
|
+
// atBottom(),
|
|
4851
|
+
// );
|
|
4852
|
+
tailRef.current.lastScrollTop = ref.current.scrollTop;
|
|
4853
|
+
if (!atBottom() && (mouseRef.current || wheelRef.current)) {
|
|
4810
4854
|
tailRef.current.applyTail = false;
|
|
4811
4855
|
}
|
|
4812
4856
|
else if (tailRef.current.applyTail === true || atBottom()) {
|
|
@@ -5497,6 +5541,7 @@ const NotificationComponent = ({ className, notification, showTimer = true }) =>
|
|
|
5497
5541
|
const NotificationsComponent = ({ className, topics, NotificationComponent: NotificationComponent$1 = NotificationComponent, max, animate = 500, position = 'bottom-right', showTimer, }) => {
|
|
5498
5542
|
const classNames = addClassname('o-notifications', className);
|
|
5499
5543
|
const translateX = position === 'top-right' || position === 'bottom-right' ? '250px' : '-250px';
|
|
5544
|
+
const notificationService = useNotificationService();
|
|
5500
5545
|
let notifications = useNotifications(topics);
|
|
5501
5546
|
if (max) {
|
|
5502
5547
|
notifications = notifications.slice(0, max);
|
|
@@ -5558,6 +5603,8 @@ const NotificationsComponent = ({ className, topics, NotificationComponent: Noti
|
|
|
5558
5603
|
document.body.style.overflowY = bodyOverflowYRef.current;
|
|
5559
5604
|
};
|
|
5560
5605
|
const element = (React.createElement("div", { className: classNames },
|
|
5606
|
+
notifications.length > 1 && (React.createElement("div", { className: "o-notification-close-all" },
|
|
5607
|
+
React.createElement("span", { className: "o-notification-close-all-content", onClick: () => notificationService.clearAll() }, "Close all"))),
|
|
5561
5608
|
React.createElement(TransitionGroup, { component: null }, notifications.map((notification, index) => (React.createElement(CSSTransition, { timeout: {
|
|
5562
5609
|
appear: animate * 2,
|
|
5563
5610
|
enter: animate * 2,
|
|
@@ -5585,6 +5632,17 @@ const notifcationsStyle = ({ position: pos = 'bottom-right' }) => {
|
|
|
5585
5632
|
${opacity(0)}
|
|
5586
5633
|
${display('flex')}
|
|
5587
5634
|
}
|
|
5635
|
+
.o-notification-close-all {
|
|
5636
|
+
${textAlign('right')}
|
|
5637
|
+
${paddingRight('sm')}
|
|
5638
|
+
${paddingBottom('sm')}
|
|
5639
|
+
}
|
|
5640
|
+
.o-notification-close-all-content{
|
|
5641
|
+
${fontSize('lg')}
|
|
5642
|
+
${cursor('pointer')}
|
|
5643
|
+
${color('primary')}
|
|
5644
|
+
${fontWeight('medium')}
|
|
5645
|
+
}
|
|
5588
5646
|
.o-notification {
|
|
5589
5647
|
${minWidth('450px')}
|
|
5590
5648
|
${maxWidth('450px')}
|
|
@@ -6283,11 +6341,11 @@ const SelectOptionComponent = (props) => {
|
|
|
6283
6341
|
if (!item || !item.data)
|
|
6284
6342
|
return null;
|
|
6285
6343
|
return (React.createElement(React.Fragment, null,
|
|
6286
|
-
displayGroup && React.createElement(OptionGroupComponent, { ...props }),
|
|
6287
|
-
React.createElement("div", { className: classNames, onClick: () => onItemClick(item, index), onMouseEnter: () => hoverable && onMouseEnter && item && onMouseEnter(item, index), onMouseLeave: () => hoverable && onMouseLeave && item && onMouseLeave(item, index) },
|
|
6344
|
+
displayGroup && React.createElement(OptionGroupComponent, { ...props, key: "group" }),
|
|
6345
|
+
React.createElement("div", { className: classNames, onClick: () => onItemClick(item, index), onMouseEnter: () => hoverable && onMouseEnter && item && onMouseEnter(item, index), onMouseLeave: () => hoverable && onMouseLeave && item && onMouseLeave(item, index), key: "content" },
|
|
6288
6346
|
React.createElement("div", { style: { display: 'flex' }, ref: ref },
|
|
6289
|
-
service.config?.multiple && (React.createElement(Checkbox, { value: item?.selected ? true : false, onChange: () => onItemClick(item, index), color: "currentColor", className: "o-select-option-multiple-checkbox" })),
|
|
6290
|
-
React.createElement(OptionContentComponent, { ...props, onClick: () => onItemClick(item, index) })))));
|
|
6347
|
+
service.config?.multiple && (React.createElement(Checkbox, { value: item?.selected ? true : false, onChange: () => onItemClick(item, index), color: "currentColor", className: "o-select-option-multiple-checkbox", key: "checkbox" })),
|
|
6348
|
+
React.createElement(OptionContentComponent, { ...props, onClick: () => onItemClick(item, index), key: "option_content" })))));
|
|
6291
6349
|
};
|
|
6292
6350
|
SelectOptionComponent.displayName = 'SelectOptionComponent';
|
|
6293
6351
|
var SelectOptionComponent$1 = React.memo(SelectOptionComponent);
|
|
@@ -8829,6 +8887,33 @@ const useTableState = () => {
|
|
|
8829
8887
|
return useContext(TableStateContext);
|
|
8830
8888
|
};
|
|
8831
8889
|
|
|
8890
|
+
const RefreshIconComponent = (props) => {
|
|
8891
|
+
return (React.createElement("div", { ...props },
|
|
8892
|
+
React.createElement("svg", { className: "o-icon-refresh-svg", stroke: "currentColor", fill: "none", strokeWidth: "2", viewBox: "0 0 24 24", "aria-hidden": "true", xmlns: "http://www.w3.org/2000/svg" },
|
|
8893
|
+
React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" }))));
|
|
8894
|
+
};
|
|
8895
|
+
var RefreshIcon = styled(RefreshIconComponent) `
|
|
8896
|
+
${({ width = '16px', height = '16px', color: cssColor = 'inherit' }) => css `
|
|
8897
|
+
width: ${width};
|
|
8898
|
+
height: ${height};
|
|
8899
|
+
${display('flex')};
|
|
8900
|
+
${alignItems('center')};
|
|
8901
|
+
${color(cssColor)}
|
|
8902
|
+
.o-icon-refresh-svg {
|
|
8903
|
+
display: inline-block;
|
|
8904
|
+
}
|
|
8905
|
+
`}
|
|
8906
|
+
`;
|
|
8907
|
+
|
|
8908
|
+
const TableActionComponent = () => {
|
|
8909
|
+
const { showRefreshButton, refreshButtonKind } = useTableConfig();
|
|
8910
|
+
const table = useTableService();
|
|
8911
|
+
return (React.createElement("div", { className: "o-table-actions" },
|
|
8912
|
+
React.createElement("div", { className: "o-table-action" }),
|
|
8913
|
+
showRefreshButton && React.createElement("div", { className: "o-table-refresh" },
|
|
8914
|
+
React.createElement(Button, { kind: refreshButtonKind, size: "small", IconComponent: () => React.createElement(RefreshIcon, null), onClick: () => table.reload() }, "Refresh"))));
|
|
8915
|
+
};
|
|
8916
|
+
|
|
8832
8917
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
8833
8918
|
const useTableColumns = () => {
|
|
8834
8919
|
return useTableState().columns;
|
|
@@ -8915,7 +9000,9 @@ const TableBodyCellComponent = React.memo((props) => {
|
|
|
8915
9000
|
TableBodyCellComponent.displayName = 'TableCell';
|
|
8916
9001
|
|
|
8917
9002
|
const TableLoadingRowComponent = (props) => {
|
|
8918
|
-
|
|
9003
|
+
const { itemHeight } = useTableConfig();
|
|
9004
|
+
const minHeight = typeof itemHeight === 'function' ? itemHeight(props.index) : itemHeight;
|
|
9005
|
+
return React.createElement(LoadingItem$1, { ...props, minHeight: minHeight });
|
|
8919
9006
|
};
|
|
8920
9007
|
const style = ({ theme }) => {
|
|
8921
9008
|
const t = theme.table;
|
|
@@ -8929,7 +9016,8 @@ var TableLoadingRowComponent$1 = styled(TableLoadingRowComponent) `
|
|
|
8929
9016
|
`;
|
|
8930
9017
|
|
|
8931
9018
|
const timeout = 500;
|
|
8932
|
-
const TableBodyRowComponent = (
|
|
9019
|
+
const TableBodyRowComponent = (props) => {
|
|
9020
|
+
const { item, index, columns, CellComponent = TableBodyCellComponent, className, onExpand, onExpanding, onExpanded, onCollapse, onCollapsing, onCollapsed, } = props;
|
|
8933
9021
|
const [hover, setHover] = useState(false);
|
|
8934
9022
|
const { highlightRow, stripRows, LoadingRowComponent = TableLoadingRowComponent$1, ExpandedComponent, } = useTableConfig();
|
|
8935
9023
|
const expandedHeightRef = useRef(0);
|
|
@@ -8959,7 +9047,7 @@ const TableBodyRowComponent = ({ item, index, columns, CellComponent = TableBody
|
|
|
8959
9047
|
if (isItemFetching(item)) {
|
|
8960
9048
|
return (React.createElement("div", { className: rowContainerClassName },
|
|
8961
9049
|
React.createElement("div", { className: "o-table-body-row" },
|
|
8962
|
-
React.createElement(LoadingRowComponent,
|
|
9050
|
+
React.createElement(LoadingRowComponent, { ...props }))));
|
|
8963
9051
|
}
|
|
8964
9052
|
return (React.createElement("div", { className: rowContainerClassName },
|
|
8965
9053
|
React.createElement("div", { className: rowClassName, onMouseEnter: highlightRow ? () => setHover(true) : undefined, onMouseLeave: highlightRow ? () => setHover(false) : undefined, style: { display: 'flex' } }, columns.map((column, colIndex) => {
|
|
@@ -8990,16 +9078,19 @@ const TableNotFoundComponent = ({ text = 'No data' }) => {
|
|
|
8990
9078
|
const TableBodyComponent = ({ className, tableRef, contentRef }) => {
|
|
8991
9079
|
const service = useTableService();
|
|
8992
9080
|
const state = useTableState();
|
|
8993
|
-
const { autoRefresh, follow, height, increment, onRowClick, onRowEnter, onRowLeave, paddingEnd, paddingStart, parentRef, preload, RowComponent = TableBodyRowComponent, rowClassName, LoadingComponent = TableLoadingComponent$1, NotFoundComponent = TableNotFoundComponent, tail, } = useTableConfig();
|
|
8994
|
-
const
|
|
8995
|
-
|
|
9081
|
+
const { autoRefresh, follow, height, itemHeight, increment, onRowClick, onRowEnter, onRowLeave, paddingEnd, paddingStart, parentRef, preload, RowComponent = TableBodyRowComponent, rowClassName, LoadingComponent = TableLoadingComponent$1, NotFoundComponent = TableNotFoundComponent, LoadingRowComponent = TableLoadingRowComponent$1, tail, } = useTableConfig();
|
|
9082
|
+
const itemHeightFunction = useCallback((index) => {
|
|
9083
|
+
if (typeof itemHeight === 'function') {
|
|
9084
|
+
return itemHeight(index);
|
|
9085
|
+
}
|
|
9086
|
+
return itemHeight || 37;
|
|
8996
9087
|
}, []);
|
|
8997
9088
|
const { items, isVirtual, totalSize, virtualItems, measure, scrollToIndex } = useListView({
|
|
8998
9089
|
controller: service,
|
|
8999
9090
|
height: height,
|
|
9000
9091
|
ref: parentRef || tableRef,
|
|
9001
9092
|
overscan: 10,
|
|
9002
|
-
itemHeight,
|
|
9093
|
+
itemHeight: itemHeightFunction,
|
|
9003
9094
|
paddingEnd,
|
|
9004
9095
|
paddingStart,
|
|
9005
9096
|
preload,
|
|
@@ -9020,7 +9111,7 @@ const TableBodyComponent = ({ className, tableRef, contentRef }) => {
|
|
|
9020
9111
|
if (service.status === LoadingStatus.Loaded && items.length === 0 && NotFoundComponent) {
|
|
9021
9112
|
return React.createElement(NotFoundComponent, null);
|
|
9022
9113
|
}
|
|
9023
|
-
return (React.createElement(ListBodyComponent, { autoRefresh: autoRefresh, className: addClassname('o-table-body', className), follow: follow, height: height, ItemComponent: ItemComponentRef.current, items: items, onItemSelect: onRowClick, onItemHighlight: onRowEnter, onItemUnhighlight: onRowLeave, parentRef: parentRef || tableRef, bodyRef: contentRef, service: service, state: state, totalSize: totalSize, tail: tail, virtualItems: isVirtual ? virtualItems : undefined, scrollToIndex: scrollToIndex }));
|
|
9114
|
+
return (React.createElement(ListBodyComponent, { autoRefresh: autoRefresh, className: addClassname('o-table-body', className), follow: follow, height: height, ItemComponent: ItemComponentRef.current, ItemLoadingComponent: LoadingRowComponent, items: items, onItemSelect: onRowClick, onItemHighlight: onRowEnter, onItemUnhighlight: onRowLeave, parentRef: parentRef || tableRef, bodyRef: contentRef, service: service, state: state, totalSize: totalSize, tail: tail, virtualItems: isVirtual ? virtualItems : undefined, scrollToIndex: scrollToIndex }));
|
|
9024
9115
|
};
|
|
9025
9116
|
TableBodyComponent.displayName = 'TableBody';
|
|
9026
9117
|
|
|
@@ -9144,6 +9235,18 @@ const tableStyle = ({ theme, fit = true }) => {
|
|
|
9144
9235
|
${() => (fit ? 'flex-grow: 1;' : '')}
|
|
9145
9236
|
}
|
|
9146
9237
|
|
|
9238
|
+
.o-table-actions {
|
|
9239
|
+
${display('flex')}
|
|
9240
|
+
}
|
|
9241
|
+
|
|
9242
|
+
.o-table-action {
|
|
9243
|
+
${flexGrow(1)}
|
|
9244
|
+
}
|
|
9245
|
+
|
|
9246
|
+
.o-table-refresh {
|
|
9247
|
+
${marginBottom('sm')}
|
|
9248
|
+
${marginRight('xl')}
|
|
9249
|
+
}
|
|
9147
9250
|
|
|
9148
9251
|
.o-table-not-found {
|
|
9149
9252
|
${display('flex')}
|
|
@@ -9165,6 +9268,7 @@ const tableStyle = ({ theme, fit = true }) => {
|
|
|
9165
9268
|
${borderBottomStyle(t.tdBorderBottomStyle)}
|
|
9166
9269
|
}
|
|
9167
9270
|
.o-table-body-row-expanded {
|
|
9271
|
+
${fontSize('default')}
|
|
9168
9272
|
.o-table-body-row {
|
|
9169
9273
|
${backgroundColor(t.tdExpandedBgColor)}
|
|
9170
9274
|
}
|
|
@@ -9366,6 +9470,7 @@ const tableStyle = ({ theme, fit = true }) => {
|
|
|
9366
9470
|
|
|
9367
9471
|
|
|
9368
9472
|
&.o-form-table {
|
|
9473
|
+
${flexGrow(1)}
|
|
9369
9474
|
${boxShadow('none')}
|
|
9370
9475
|
${paddingRight('none')}
|
|
9371
9476
|
.o-table-body-row:hover {
|
|
@@ -9600,7 +9705,7 @@ const ExpandedCellComponent = ({ item, className }) => {
|
|
|
9600
9705
|
React.createElement(TogglerIcon, { open: item.expanded, model: "plus", color: "primary" })));
|
|
9601
9706
|
};
|
|
9602
9707
|
|
|
9603
|
-
const ControllerTableComponent = ({ autoRefresh, controller, className, bodyClassName, BodyComponent = TableBodyComponent, ExpandedComponent, filterable, fit, fixHeader = true, follow, grow, FooterComponent = TableFooterComponent, footerClassName, header = true, headerClassName, HeaderComponent = TableHeaderComponent, increment, LoadingComponent, LoadingRowComponent, NotFoundComponent, footer = false, height, highlightRow, onRowClick, onRowEnter, onRowLeave, onRowOver, onRowOut, paddingEnd, paddingStart, parentRef, preload, rowClassName, RowComponent, sortable, stripRows, tail, }) => {
|
|
9708
|
+
const ControllerTableComponent = ({ ActionComponent = TableActionComponent, autoRefresh, controller, className, bodyClassName, BodyComponent = TableBodyComponent, ExpandedComponent, filterable, fit, fixHeader = true, follow, grow, FooterComponent = TableFooterComponent, footerClassName, header = true, headerClassName, HeaderComponent = TableHeaderComponent, increment, itemHeight, LoadingComponent, LoadingRowComponent, NotFoundComponent, footer = false, height, highlightRow, onRowClick, onRowEnter, onRowLeave, onRowOver, onRowOut, paddingEnd, paddingStart, parentRef, preload, refreshButtonKind = 'primary', rowClassName, RowComponent, showRefreshButton, sortable, stripRows, tail, }) => {
|
|
9604
9709
|
const classNames = addClassname('o-table', className);
|
|
9605
9710
|
const { columns, items } = controller.state;
|
|
9606
9711
|
const contentRef = useRef(null);
|
|
@@ -9608,6 +9713,7 @@ const ControllerTableComponent = ({ autoRefresh, controller, className, bodyClas
|
|
|
9608
9713
|
const service = controller.asService();
|
|
9609
9714
|
const config = useMemo(() => {
|
|
9610
9715
|
return {
|
|
9716
|
+
ActionComponent,
|
|
9611
9717
|
autoRefresh,
|
|
9612
9718
|
bodyClassName,
|
|
9613
9719
|
BodyComponent,
|
|
@@ -9627,6 +9733,7 @@ const ControllerTableComponent = ({ autoRefresh, controller, className, bodyClas
|
|
|
9627
9733
|
height,
|
|
9628
9734
|
highlightRow,
|
|
9629
9735
|
increment,
|
|
9736
|
+
itemHeight,
|
|
9630
9737
|
LoadingComponent,
|
|
9631
9738
|
LoadingRowComponent,
|
|
9632
9739
|
NotFoundComponent,
|
|
@@ -9639,13 +9746,16 @@ const ControllerTableComponent = ({ autoRefresh, controller, className, bodyClas
|
|
|
9639
9746
|
paddingStart,
|
|
9640
9747
|
parentRef,
|
|
9641
9748
|
preload,
|
|
9749
|
+
refreshButtonKind,
|
|
9642
9750
|
rowClassName,
|
|
9643
9751
|
RowComponent,
|
|
9752
|
+
showRefreshButton,
|
|
9644
9753
|
sortable,
|
|
9645
9754
|
stripRows,
|
|
9646
|
-
tail
|
|
9755
|
+
tail,
|
|
9647
9756
|
};
|
|
9648
9757
|
}, [
|
|
9758
|
+
ActionComponent,
|
|
9649
9759
|
autoRefresh,
|
|
9650
9760
|
bodyClassName,
|
|
9651
9761
|
BodyComponent,
|
|
@@ -9665,6 +9775,7 @@ const ControllerTableComponent = ({ autoRefresh, controller, className, bodyClas
|
|
|
9665
9775
|
height,
|
|
9666
9776
|
highlightRow,
|
|
9667
9777
|
increment,
|
|
9778
|
+
itemHeight,
|
|
9668
9779
|
LoadingComponent,
|
|
9669
9780
|
LoadingRowComponent,
|
|
9670
9781
|
NotFoundComponent,
|
|
@@ -9677,8 +9788,10 @@ const ControllerTableComponent = ({ autoRefresh, controller, className, bodyClas
|
|
|
9677
9788
|
paddingStart,
|
|
9678
9789
|
parentRef,
|
|
9679
9790
|
preload,
|
|
9791
|
+
refreshButtonKind,
|
|
9680
9792
|
rowClassName,
|
|
9681
9793
|
RowComponent,
|
|
9794
|
+
showRefreshButton,
|
|
9682
9795
|
sortable,
|
|
9683
9796
|
stripRows,
|
|
9684
9797
|
tail,
|
|
@@ -9699,16 +9812,19 @@ const ControllerTableComponent = ({ autoRefresh, controller, className, bodyClas
|
|
|
9699
9812
|
}
|
|
9700
9813
|
}
|
|
9701
9814
|
}, [service, ExpandedComponent]);
|
|
9815
|
+
const id = useId();
|
|
9702
9816
|
return (React.createElement(TableServiceContext.Provider, { value: controller.asService() },
|
|
9703
9817
|
React.createElement(TableStateContext.Provider, { value: controller.state },
|
|
9704
9818
|
React.createElement(TableConfigContext.Provider, { value: config },
|
|
9705
|
-
React.createElement("div", { className:
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9819
|
+
React.createElement("div", { className: className },
|
|
9820
|
+
React.createElement(ActionComponent, null),
|
|
9821
|
+
React.createElement("div", { id: id, className: classNames, ref: tableRef, style: {
|
|
9822
|
+
maxHeight: height,
|
|
9823
|
+
overflow: 'auto',
|
|
9824
|
+
} },
|
|
9825
|
+
header && React.createElement(HeaderComponent, { columns: columns, className: headerClassName }),
|
|
9826
|
+
React.createElement(BodyComponent, { items: items || [], columns: columns, tableRef: tableRef, contentRef: contentRef, className: bodyClassName }),
|
|
9827
|
+
footer && React.createElement(FooterComponent, { columns: columns, className: footerClassName })))))));
|
|
9712
9828
|
};
|
|
9713
9829
|
ControllerTableComponent.displayName = 'Table';
|
|
9714
9830
|
|
|
@@ -11518,15 +11634,21 @@ const baseTheme = (customTheme = {}) => {
|
|
|
11518
11634
|
borderColor: kind,
|
|
11519
11635
|
borderColorFlat: 'transparent',
|
|
11520
11636
|
borderColorOutline: kind,
|
|
11521
|
-
|
|
11637
|
+
borderRadiusMedium: 'sm',
|
|
11638
|
+
borderRadiusSmall: 'sm',
|
|
11639
|
+
borderRadiusLarge: 'sm',
|
|
11522
11640
|
borderStyle: 'solid',
|
|
11523
|
-
|
|
11641
|
+
borderWidthSmall: 1,
|
|
11642
|
+
borderWidthMedium: 1,
|
|
11643
|
+
borderWidthLarge: 1,
|
|
11524
11644
|
color: ['light', 'lightest', 'lighter', 'white'].includes(kind) ? 'darker' : 'white',
|
|
11525
11645
|
colorFlat: kind,
|
|
11526
11646
|
colorOutline: ['light', 'lightest', 'lighter', 'white'].includes(kind) ? 'darkest' : kind,
|
|
11527
11647
|
cursor: 'pointer',
|
|
11528
11648
|
cursorDisabled: 'not-allowed',
|
|
11529
|
-
|
|
11649
|
+
fontSizeMedium: 'md',
|
|
11650
|
+
fontSizeSmall: 'sm',
|
|
11651
|
+
fontSizeLarge: 'lg',
|
|
11530
11652
|
fontWeight: 'bold',
|
|
11531
11653
|
hoverColor: ['light', 'lightest', 'lighter', 'white'].includes(kind) ? 'black' : 'white',
|
|
11532
11654
|
hoverColorFlat: lighten(get(theme.colors, kind, ''), 100),
|
|
@@ -11537,12 +11659,20 @@ const baseTheme = (customTheme = {}) => {
|
|
|
11537
11659
|
hoverBorderColor: darken(get(theme.colors, kind, ''), 100),
|
|
11538
11660
|
hoverBorderColorFlat: 'transparent',
|
|
11539
11661
|
hoverBorderColorOutline: kind,
|
|
11540
|
-
|
|
11541
|
-
|
|
11662
|
+
letterSpacingMedium: 'normal',
|
|
11663
|
+
letterSpacingSmall: 'normal',
|
|
11664
|
+
letterSpacingLarge: 'normal',
|
|
11665
|
+
lineHeightMedium: '3xl',
|
|
11666
|
+
lineHeightSmall: '2xl',
|
|
11667
|
+
lineHeightLarge: '4xl',
|
|
11542
11668
|
opacity: 1,
|
|
11543
11669
|
opacityDisabled: 0.6,
|
|
11544
|
-
|
|
11545
|
-
|
|
11670
|
+
paddingYMedium: 'none',
|
|
11671
|
+
paddingYSmall: 'none',
|
|
11672
|
+
paddingYLarge: 'none',
|
|
11673
|
+
paddingXMedium: 'lg',
|
|
11674
|
+
paddingXSmall: 'md',
|
|
11675
|
+
paddingXLarge: 'xl',
|
|
11546
11676
|
textOverflow: 'ellipsis',
|
|
11547
11677
|
textTransform: 'none',
|
|
11548
11678
|
whiteSpace: 'nowrap',
|