onekijs-ui 1.0.1 → 1.0.3
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/select/SelectService.d.ts +3 -3
- package/dist/components/tree/TreeService.d.ts +4 -4
- package/dist/components/tree/components/VirtualTreeListComponent.d.ts +1 -1
- package/dist/index.js +46 -14
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +46 -14
- 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/typography.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/button/components/ButtonComponent.tsx +10 -2
- package/src/components/button/style.ts +7 -2
- package/src/components/list/components/ListBodyComponent.tsx +1 -0
- package/src/components/list/components/VirtualListComponent.tsx +2 -0
- package/src/components/list/hooks/useListView.tsx +0 -2
- package/src/components/table/components/FormTableComponent.tsx +1 -1
- package/src/components/tree/components/VirtualTreeListComponent.tsx +61 -24
|
@@ -5,17 +5,17 @@ declare class SelectService<T = any, I extends SelectItem<T> = SelectItem<T>, S
|
|
|
5
5
|
protected lastCheckQuery: Query | undefined;
|
|
6
6
|
get defaultValue(): T | T[] | null | undefined;
|
|
7
7
|
get defaultValueLoading(): boolean | undefined;
|
|
8
|
-
check(): Generator<void | import("redux-saga/effects").AllEffect<import("redux-saga/effects").CallEffect<Generator<I[] | Generator<void | import("redux-saga/effects").
|
|
8
|
+
check(): Generator<void | import("redux-saga/effects").AllEffect<import("redux-saga/effects").CallEffect<Generator<I[] | Generator<void | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | import("redux-saga/effects").CancelEffect | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & (CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined))>, I | undefined, I[] & CollectionFetcherResult<T>>>> | import("redux-saga/effects").AllEffect<Generator<I[] | Generator<void | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | import("redux-saga/effects").CancelEffect | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & (CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined))>, I | undefined, I[] & CollectionFetcherResult<T>>> | import("redux-saga/effects").CallEffect<void>, void, (I | undefined)[]>;
|
|
9
9
|
get status(): CollectionStatus;
|
|
10
10
|
setData(data: T[], query?: Query): void;
|
|
11
|
-
setDefaultValue(value: T | T[] | null | undefined): Generator<void | Generator<void | import("redux-saga/effects").AllEffect<import("redux-saga/effects").CallEffect<Generator<I[] | Generator<void | import("redux-saga/effects").
|
|
11
|
+
setDefaultValue(value: T | T[] | null | undefined): Generator<void | Generator<void | import("redux-saga/effects").AllEffect<import("redux-saga/effects").CallEffect<Generator<I[] | Generator<void | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | import("redux-saga/effects").CancelEffect | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & (CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined))>, I | undefined, I[] & CollectionFetcherResult<T>>>> | import("redux-saga/effects").AllEffect<Generator<I[] | Generator<void | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | import("redux-saga/effects").CancelEffect | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & (CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined))>, I | undefined, I[] & CollectionFetcherResult<T>>> | import("redux-saga/effects").CallEffect<void>, void, (I | undefined)[]>, void, unknown>;
|
|
12
12
|
setDefaultValueLoading(loading: boolean): void;
|
|
13
13
|
setInputValue(value: string | null): Generator<void | T | Promise<T | null> | null, void, T>;
|
|
14
14
|
setItemWidth(_item: I, value: number): void;
|
|
15
15
|
setValue(value: null | T | T[]): void;
|
|
16
16
|
setUrl(url: string, query?: Query): void;
|
|
17
17
|
_buildItem(data: T | null | undefined, adaptee: unknown, context?: AnonymousObject): I;
|
|
18
|
-
_filterItem(item: I | undefined, query: Query, valid: boolean): Generator<I[] | Generator<void | import("redux-saga/effects").
|
|
18
|
+
_filterItem(item: I | undefined, query: Query, valid: boolean): Generator<I[] | Generator<void | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | import("redux-saga/effects").CancelEffect | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & (CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined))>, I | undefined, I[] & CollectionFetcherResult<T>>;
|
|
19
19
|
_compareItem(a: I | undefined, b: I | undefined): boolean;
|
|
20
20
|
_doSearch(search: Primitive | undefined): boolean;
|
|
21
21
|
_setDefaultValue(value: T | T[] | null | undefined): void;
|
|
@@ -6,19 +6,19 @@ declare class TreeService<T = any, I extends TreeItem<T> = TreeItem<T>, S extend
|
|
|
6
6
|
collapse(item: I): void;
|
|
7
7
|
collapsed(item: I): void;
|
|
8
8
|
collapsing(item: I): void;
|
|
9
|
-
expand(item: I): Generator<void | Generator<void |
|
|
9
|
+
expand(item: I): Generator<void | Generator<void | import("redux-saga/effects").CancelEffect | I[] | import("redux-saga/effects").ForkEffect<Generator<import("redux-saga/effects").CallEffect<true> | I[], void, unknown>> | Promise<CollectionFetcherResult<T>>, void, (Task<any> | null) & CollectionFetcherResult<T>>, void, unknown>;
|
|
10
10
|
expanded(item: I): void;
|
|
11
|
-
expanding(item: I): Generator<void | Generator<void |
|
|
11
|
+
expanding(item: I): Generator<void | Generator<void | import("redux-saga/effects").CancelEffect | I[] | import("redux-saga/effects").ForkEffect<Generator<import("redux-saga/effects").CallEffect<true> | I[], void, unknown>> | Promise<CollectionFetcherResult<T>>, void, (Task<any> | null) & CollectionFetcherResult<T>>, void, unknown>;
|
|
12
12
|
initDb(dataSource: T[] | string | undefined): void;
|
|
13
13
|
_adapt(data: T | null | undefined, context?: AnonymousObject): I;
|
|
14
14
|
_addFilterExpanded(item: I): void;
|
|
15
15
|
_buildItem(data: T | null | undefined, adaptee: unknown, context?: AnonymousObject): I;
|
|
16
16
|
_clearFilterExpanded(): void;
|
|
17
|
-
_delayChildrenLoading(delay_ms: number, item: I): Generator<
|
|
17
|
+
_delayChildrenLoading(delay_ms: number, item: I): Generator<import("redux-saga/effects").CallEffect<true> | I[], void, unknown>;
|
|
18
18
|
_execute(items: I[], query: LocalQuery, comparator: QuerySortComparator<T>, comparators: AnonymousObject<QuerySortComparator<T>>, searcher?: QuerySearcher<T>): I[];
|
|
19
19
|
_expand(item: I): void;
|
|
20
20
|
_expanding(item: I): void;
|
|
21
|
-
_fetchChildren(item: I, callbackSuccess?: (item: I) => void, callbackError?: (item: I) => void): Generator<void |
|
|
21
|
+
_fetchChildren(item: I, callbackSuccess?: (item: I) => void, callbackError?: (item: I) => void): Generator<void | import("redux-saga/effects").CancelEffect | I[] | import("redux-saga/effects").ForkEffect<Generator<import("redux-saga/effects").CallEffect<true> | I[], void, unknown>> | Promise<CollectionFetcherResult<T>>, void, (Task<any> | null) & CollectionFetcherResult<T>>;
|
|
22
22
|
_fetchChildrenError(e: any, item: I): void;
|
|
23
23
|
_fetchChildrenSuccess(item: I, result: CollectionFetcherResult<T>): void;
|
|
24
24
|
_removeFilterExpanded(item: I): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TreeItem, VirtualTreeListProps } from '../typings';
|
|
3
|
-
declare const VirtualTreeListComponent: <T = any, I extends TreeItem<T> = TreeItem<T>>({ items, onItemClick, onItemMouseEnter, onItemMouseLeave, virtualItems, }: VirtualTreeListProps<T, I>) => React.JSX.Element;
|
|
3
|
+
declare const VirtualTreeListComponent: <T extends any = any, I extends TreeItem<T> = TreeItem<T>>({ items, onItemClick, onItemMouseEnter, onItemMouseLeave, virtualItems, }: VirtualTreeListProps<T, I>) => React.JSX.Element;
|
|
4
4
|
export default VirtualTreeListComponent;
|
package/dist/index.js
CHANGED
|
@@ -1361,7 +1361,7 @@ const ButtonComponent = React.forwardRef((props, ref) => {
|
|
|
1361
1361
|
if (props.disabled) {
|
|
1362
1362
|
classNames = addClassname('o-button-disabled', classNames);
|
|
1363
1363
|
}
|
|
1364
|
-
return (jsxRuntimeExports.jsxs("button", { ref: ref, className: classNames, ...buttonProps, type: type, children: [loading && jsxRuntimeExports.jsx(LoadingIcon, { onClick: undefined, color: "currentColor" }), !loading && IconComponent && jsxRuntimeExports.jsx(
|
|
1364
|
+
return (jsxRuntimeExports.jsxs("button", { ref: ref, className: classNames, ...buttonProps, type: type, children: [loading && (jsxRuntimeExports.jsx("span", { className: "o-button-icon", children: jsxRuntimeExports.jsx(LoadingIcon, { onClick: undefined, color: "currentColor" }) })), !loading && IconComponent && (jsxRuntimeExports.jsx("span", { className: "o-button-icon", children: jsxRuntimeExports.jsx(IconComponent, { ...props, onClick: undefined }) })), jsxRuntimeExports.jsx("span", { className: "o-button-content", children: children })] }));
|
|
1365
1365
|
});
|
|
1366
1366
|
ButtonComponent.displayName = 'Button';
|
|
1367
1367
|
|
|
@@ -1431,7 +1431,7 @@ const buttonStyle = ({ kind = 'primary', pattern = 'solid', size = 'medium', dis
|
|
|
1431
1431
|
${opacity(disabled ? 0.6 : 1)}
|
|
1432
1432
|
${marginLeft(IconComponent ? 'xs' : 'none')}
|
|
1433
1433
|
${outline('none')}
|
|
1434
|
-
|
|
1434
|
+
|
|
1435
1435
|
.o-icon-loading-container {
|
|
1436
1436
|
${marginRight('xs')}
|
|
1437
1437
|
}
|
|
@@ -1441,6 +1441,11 @@ const buttonStyle = ({ kind = 'primary', pattern = 'solid', size = 'medium', dis
|
|
|
1441
1441
|
hover: disabled ? fontColor : hoverFontColor,
|
|
1442
1442
|
})}
|
|
1443
1443
|
}
|
|
1444
|
+
|
|
1445
|
+
.o-button-icon {
|
|
1446
|
+
${marginRight('xs')}
|
|
1447
|
+
${marginTop('2px')}
|
|
1448
|
+
}
|
|
1444
1449
|
`;
|
|
1445
1450
|
};
|
|
1446
1451
|
const dropdownButtonStyle = () => {
|
|
@@ -5503,17 +5508,13 @@ const useListView = ({ controller, height, itemHeight = defaultItemHeight, overs
|
|
|
5503
5508
|
return itemHeight(index) || defaultItemHeight;
|
|
5504
5509
|
}
|
|
5505
5510
|
return itemHeight;
|
|
5506
|
-
},
|
|
5507
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5508
|
-
[itemHeight]);
|
|
5511
|
+
}, [itemHeight]);
|
|
5509
5512
|
// Trick for force recalcutate position without losing measurementCache
|
|
5510
5513
|
// In the react-virtual code, the position are recalculate if the forceExtractor function change
|
|
5511
5514
|
const forceKeyExtractor = React.useCallback((index) => {
|
|
5512
5515
|
const fn = keyExtractor || defaultKeyExtractor;
|
|
5513
5516
|
return fn(index);
|
|
5514
|
-
},
|
|
5515
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5516
|
-
[keyExtractor, force]);
|
|
5517
|
+
}, [keyExtractor, force]);
|
|
5517
5518
|
const state = controller.state;
|
|
5518
5519
|
const { totalSize, virtualItems, scrollToIndex, scrollToOffset } = useVirtual({
|
|
5519
5520
|
size: state.total ? state.total : state.items?.length || 0,
|
|
@@ -5681,6 +5682,7 @@ const StandardListComponent = ({ items, ItemComponent = ListItemComponent$1, Ite
|
|
|
5681
5682
|
}) }));
|
|
5682
5683
|
};
|
|
5683
5684
|
|
|
5685
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
5684
5686
|
const VirtualItemWrapper = ({ virtualItem, listItem, ItemComponent = ListItemComponent$1, ItemContentComponent = ListItemContent, ItemLoadingComponent = LoadingItem$1, onItemClick, onItemMouseEnter, onItemMouseLeave, }) => {
|
|
5685
5687
|
const { index, measureRef, start } = virtualItem;
|
|
5686
5688
|
const ref = React.useRef(null);
|
|
@@ -5719,6 +5721,7 @@ const VirtualItemWrapper = ({ virtualItem, listItem, ItemComponent = ListItemCom
|
|
|
5719
5721
|
transform: `translateY(${start}px)`,
|
|
5720
5722
|
}, children: jsxRuntimeExports.jsxs("div", { ref: ref, children: [listItem?.loadingStatus === onekijsFramework.LoadingStatus.Loading && jsxRuntimeExports.jsx(ItemLoadingComponent, {}), listItem?.loadingStatus !== onekijsFramework.LoadingStatus.Loading && listItem && listItem.data !== undefined && (jsxRuntimeExports.jsx(ItemComponent, { index: index, item: listItem, data: listItem.data, onClick: onItemClick, onMouseEnter: onItemMouseEnter, onMouseLeave: onItemMouseLeave, ItemContentComponent: ItemContentComponent }, `item-${listItem.uid || index}`))] }) }));
|
|
5721
5723
|
};
|
|
5724
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
5722
5725
|
const VirtualListComponent = ({ items, ItemComponent = ListItemComponent$1, ItemLoadingComponent = LoadingItem$1, ItemContentComponent = ListItemContent, onItemClick, onItemMouseEnter, onItemMouseLeave, virtualItems, }) => {
|
|
5723
5726
|
return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: virtualItems.map((virtualItem) => {
|
|
5724
5727
|
const listItem = items[virtualItem.index];
|
|
@@ -5740,6 +5743,7 @@ const findItemIndex = (items, uid) => {
|
|
|
5740
5743
|
return i.uid === uid;
|
|
5741
5744
|
});
|
|
5742
5745
|
};
|
|
5746
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
5743
5747
|
const ListBodyComponent = ({ autoRefresh, bodyRef, className, follow, height, items, ItemComponent = ListItemComponent$1, ItemLoadingComponent = LoadingItem$1, ItemContentComponent = ListItemContent, NotFoundComponent, keyboardNavigable, ListComponent = StandardListComponent, multiSelect, onItemActivate, onItemDeactivate, onItemSelect, onItemUnselect, onItemHighlight, onItemUnhighlight, parentRef, scrollToIndex, service, state, style, tail, totalSize, virtualItems, VirtualListComponent: VirtualListComponent$1 = VirtualListComponent, LoadingComponent = ListLoadingComponent$1, }) => {
|
|
5744
5748
|
const scrollAlignRef = React.useRef('center');
|
|
5745
5749
|
const lastActiveItemUid = React.useRef(undefined);
|
|
@@ -9117,12 +9121,15 @@ const TreeBodyComponent = ({ className, controller, NotFoundComponent, }) => {
|
|
|
9117
9121
|
TreeBodyComponent.displayName = 'TreeBody';
|
|
9118
9122
|
|
|
9119
9123
|
const timeout$1 = 500;
|
|
9124
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
9120
9125
|
const VirtualTreeListItemComponent = ({ itemClassName, ItemComponent, virtualItem, onClick, onMouseEnter, onMouseLeave, }) => {
|
|
9121
9126
|
const { index, measureRef, children, item } = virtualItem;
|
|
9122
9127
|
const className = typeof itemClassName !== 'function' ? itemClassName : item ? itemClassName(item) : undefined;
|
|
9123
9128
|
const service = useTreeService();
|
|
9124
9129
|
const { animate } = useTreeConfig();
|
|
9125
9130
|
const childrenRef = React.useRef(null);
|
|
9131
|
+
const ref = React.useRef(null);
|
|
9132
|
+
const previousHeightRef = React.useRef(undefined);
|
|
9126
9133
|
const expand = (item, index) => {
|
|
9127
9134
|
if (animate) {
|
|
9128
9135
|
service.expanding(item, index);
|
|
@@ -9158,11 +9165,35 @@ const VirtualTreeListItemComponent = ({ itemClassName, ItemComponent, virtualIte
|
|
|
9158
9165
|
}
|
|
9159
9166
|
};
|
|
9160
9167
|
const expanded = !!(item && isTreeItemExpanded(item, service));
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9168
|
+
const measure = React.useCallback((el) => {
|
|
9169
|
+
if (el?.offsetHeight !== previousHeightRef.current && el?.offsetHeight) {
|
|
9170
|
+
previousHeightRef.current = el.offsetHeight;
|
|
9171
|
+
measureRef(el);
|
|
9172
|
+
}
|
|
9173
|
+
}, [measureRef]);
|
|
9174
|
+
const measureThrottle = onekijsFramework.useThrottle(measure, 50);
|
|
9175
|
+
const resizeObserver = React.useMemo(() => {
|
|
9176
|
+
return new ResizeObserver(() => {
|
|
9177
|
+
measureThrottle(ref.current);
|
|
9178
|
+
});
|
|
9179
|
+
}, [measureThrottle]);
|
|
9180
|
+
React.useEffect(() => {
|
|
9181
|
+
const el = ref.current;
|
|
9182
|
+
if (el) {
|
|
9183
|
+
previousHeightRef.current = el.offsetHeight;
|
|
9184
|
+
resizeObserver.observe(el);
|
|
9185
|
+
}
|
|
9186
|
+
return () => {
|
|
9187
|
+
if (el) {
|
|
9188
|
+
resizeObserver.unobserve(el);
|
|
9189
|
+
}
|
|
9190
|
+
};
|
|
9191
|
+
}, [resizeObserver]);
|
|
9192
|
+
return (jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("div", { className: "o-virtual-item", ref: measureRef, children: jsxRuntimeExports.jsxs("div", { ref: ref, children: [(!item || !item.data) && jsxRuntimeExports.jsx(LoadingItem$1, {}), item && item.data && (jsxRuntimeExports.jsx(DefaultTreeItemContext.Provider, { value: {
|
|
9193
|
+
onExpand: expand,
|
|
9194
|
+
onCollapse: collapse,
|
|
9195
|
+
className,
|
|
9196
|
+
}, children: jsxRuntimeExports.jsx(ItemComponent, { index: index, item: item, data: item.data, onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, `item-${item?.uid || index}`) }))] }) }, `virtual-item-${item?.uid || index}`), jsxRuntimeExports.jsx(reactTransitionGroup.CSSTransition, { in: expanded, nodeRef: childrenRef, classNames: "o-tree-item-children", timeout: timeout$1, mountOnEnter: true, appear: false, unmountOnExit: true, onExiting: () => {
|
|
9166
9197
|
if (childrenRef.current)
|
|
9167
9198
|
onExiting(childrenRef.current);
|
|
9168
9199
|
}, onEntering: () => {
|
|
@@ -9172,6 +9203,7 @@ const VirtualTreeListItemComponent = ({ itemClassName, ItemComponent, virtualIte
|
|
|
9172
9203
|
return (jsxRuntimeExports.jsx(VirtualTreeListItemComponent, { virtualItem: child, ItemComponent: ItemComponent, onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, `virtual-item-${child.item?.uid || child.index}`));
|
|
9173
9204
|
}) }) }) })] }));
|
|
9174
9205
|
};
|
|
9206
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
9175
9207
|
const VirtualTreeListComponent = ({ items, onItemClick, onItemMouseEnter, onItemMouseLeave, virtualItems, }) => {
|
|
9176
9208
|
const logger = onekijsFramework.useLogger();
|
|
9177
9209
|
logger.debug('virtualItems', virtualItems);
|
|
@@ -11040,7 +11072,7 @@ const DefaultDeleteRowComponent = ({ rowIndex }) => {
|
|
|
11040
11072
|
};
|
|
11041
11073
|
const metadata = onekijsFramework.useFormMetadata(tableName);
|
|
11042
11074
|
let disabled = false;
|
|
11043
|
-
if (metadata.readOnly || (metadata.editable === false && form.config.reconfigure)) {
|
|
11075
|
+
if (metadata.disabled || metadata.readOnly || (metadata.editable === false && form.config.reconfigure)) {
|
|
11044
11076
|
disabled = true;
|
|
11045
11077
|
}
|
|
11046
11078
|
return (jsxRuntimeExports.jsx("div", { className: `o-form-table-remove${disabled ? ' o-form-table-remove-disabled' : ''}`, onClick: removeRow, children: jsxRuntimeExports.jsx(RemoveIcon$1, { width: "14px", height: "14px" }) }));
|