onekijs-ui 0.18.0 → 0.18.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.
@@ -5,15 +5,15 @@ 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").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)[]>;
8
+ check(): Generator<void | import("redux-saga/effects").AllEffect<import("redux-saga/effects").CallEffect<Generator<I[] | Generator<void | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | 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").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | 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
  setData(data: T[], query?: Query): void;
10
- 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>;
10
+ 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").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | 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").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | 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>;
11
11
  setDefaultValueLoading(loading: boolean): void;
12
12
  setItemWidth(_item: I, value: number): void;
13
13
  setValue(value: null | T | T[]): void;
14
14
  setUrl(url: string, query?: Query): void;
15
15
  _buildItem(data: T | null | undefined, adaptee: unknown, context?: AnonymousObject): I;
16
- _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>>;
16
+ _filterItem(item: I | undefined, query: Query, valid: boolean): Generator<I[] | Generator<void | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined)>, I | undefined, I[] & CollectionFetcherResult<T>>;
17
17
  _compareItem(a: I | undefined, b: I | undefined): boolean;
18
18
  _setDefaultValue(value: T | T[] | null | undefined): void;
19
19
  _setValidDefaultValue(value: T | T[] | null): void;
@@ -7,4 +7,6 @@ export interface TooltipProps extends Config {
7
7
  popperOptions?: PopperOptions;
8
8
  kind?: ColorPropertyTheme;
9
9
  delayHide?: number;
10
+ delayShow?: number;
11
+ attachToBody?: boolean;
10
12
  }
package/dist/index.d.ts CHANGED
@@ -52,6 +52,7 @@ export { default as Row } from './components/grid/Row';
52
52
  export { colStyle, rowStyle } from './components/grid/style';
53
53
  export { ColProps, GridSize, RowProps } from './components/grid/typings';
54
54
  export { default as CloseAllIcon } from './components/icon/CloseAllIcon';
55
+ export { default as HelpIcon } from './components/icon/HelpIcon';
55
56
  export { default as CrossIcon } from './components/icon/CrossIcon';
56
57
  export { default as ErrorIcon } from './components/icon/ErrorIcon';
57
58
  export { default as FileIcon } from './components/icon/FileIcon';
package/dist/index.js CHANGED
@@ -1187,9 +1187,7 @@ const DropdownComponent = ({ animationTimeout = 0, attachToBody = false, classNa
1187
1187
  React.createElement(reactTransitionGroup.CSSTransition, { in: open, classNames: "o-dropdown", timeout: animationTimeout, mountOnEnter: true, appear: false, unmountOnExit: true, onEnter: onEnter, onEntering: onEntering, onEntered: onEntered, onExit: onExit, onExited: onExited, onExiting: onExiting },
1188
1188
  React.createElement("div", { className: "o-dropdown" }, children))));
1189
1189
  if (attachToBody) {
1190
- return React.createElement(React.Fragment, null,
1191
- " ",
1192
- ReactDOM.createPortal(element, document.body));
1190
+ return React.createElement(React.Fragment, null, ReactDOM.createPortal(element, document.body));
1193
1191
  }
1194
1192
  else {
1195
1193
  return React.createElement(React.Fragment, null, element);
@@ -1246,11 +1244,12 @@ const DropdownButton = styled(DropdownButtonComponent) `
1246
1244
  `;
1247
1245
 
1248
1246
  const TooltipComponent = (props) => {
1249
- const { content, className, popperOptions, children, delayHide = 300, ...tooltipConfig } = props;
1247
+ const { content, className, popperOptions, children, delayHide = 300, delayShow = 200, attachToBody, ...tooltipConfig } = props;
1250
1248
  const [show, setShow] = React.useState(true);
1251
1249
  const tooltipOptions = Object.assign({
1252
1250
  interactive: true,
1253
1251
  delayHide,
1252
+ delayShow,
1254
1253
  }, tooltipConfig);
1255
1254
  const { getArrowProps, getTooltipProps, setTooltipRef, setTriggerRef, visible } = reactPopperTooltip.usePopperTooltip(tooltipOptions, popperOptions);
1256
1255
  const { style: containerStyle, ...containerProps } = getTooltipProps({ className: 'o-tooltip-container' });
@@ -1274,11 +1273,19 @@ const TooltipComponent = (props) => {
1274
1273
  document.removeEventListener('tooltipVisible', listener);
1275
1274
  };
1276
1275
  }, [uid]);
1277
- return (React.createElement("div", { className: classNames, ref: setTriggerRef },
1278
- children,
1279
- show && visible && content && (React.createElement("div", { ref: setTooltipRef, style: containerStyle, ...containerProps },
1280
- React.createElement("div", { style: arrowStyle, ...arrowProps }),
1281
- content))));
1276
+ const element = (React.createElement("div", { ref: setTooltipRef, style: containerStyle, ...containerProps },
1277
+ React.createElement("div", { style: arrowStyle, ...arrowProps }),
1278
+ content));
1279
+ if (attachToBody) {
1280
+ return (React.createElement("div", { ref: setTriggerRef },
1281
+ children,
1282
+ show && visible && content && ReactDOM.createPortal(React.createElement("div", { className: classNames, style: { position: 'absolute', width: '100%' } }, element), document.body)));
1283
+ }
1284
+ else {
1285
+ return (React.createElement("div", { className: classNames, ref: setTriggerRef },
1286
+ children,
1287
+ show && visible && content && element));
1288
+ }
1282
1289
  };
1283
1290
 
1284
1291
  const sizeFormatter = (type, value, theme) => {
@@ -1426,7 +1433,7 @@ const tooltipStyle = ({ kind = 'secondary', theme }) => {
1426
1433
  }
1427
1434
  }
1428
1435
  }
1429
- .o-tooltip-arrow {
1436
+ &.o-tooltip-arrow, .o-tooltip-arrow {
1430
1437
  ${height('1rem')}
1431
1438
  ${width('1rem')}
1432
1439
  ${position('absolute')}
@@ -1833,7 +1840,7 @@ const Row = styled(RowComponent) `
1833
1840
  `;
1834
1841
 
1835
1842
  const IconComponent$6 = ({ className, onClick, style }) => {
1836
- return (React.createElement("div", { className: className, onClick: onClick, style: style },
1843
+ return (React.createElement("div", { className: addClassname('o-icon-help', className), onClick: onClick, style: style },
1837
1844
  React.createElement("svg", { className: "o-icon-help-svg", viewBox: "0 0 512 512" },
1838
1845
  React.createElement("path", { d: "M256 90c44.3 0 86 17.3 117.4 48.6C404.7 170 422 211.7 422 256s-17.3 86-48.6 117.4C342 404.7 300.3 422 256 422s-86-17.3-117.4-48.6C107.3 342 90 300.3 90 256s17.3-86 48.6-117.4C170 107.3 211.7 90 256 90m0-42C141.1 48 48 141.1 48 256s93.1 208 208 208 208-93.1 208-208S370.9 48 256 48z" }),
1839
1846
  React.createElement("path", { d: "M235 339h42v42h-42zM276.8 318h-41.6c0-67 62.4-62.2 62.4-103.8 0-22.9-18.7-41.7-41.6-41.7S214.4 192 214.4 214h-41.6c0-46 37.2-83 83.2-83s83.2 37.1 83.2 83.1c0 52-62.4 57.9-62.4 103.9z" }))));
@@ -3706,7 +3713,7 @@ var SuccessIcon = styled(SuccessIconComponent) `
3706
3713
  `;
3707
3714
 
3708
3715
  const InputComponent = (props) => {
3709
- const { className, size = 'medium', status, PrefixComponent, SuffixComponent, onFocus: forwardFocus, onBlur: forwardBlur, ...inputProps } = props;
3716
+ const { className, size = 'medium', status, PrefixComponent, SuffixComponent, onFocus: forwardFocus, onBlur: forwardBlur, onChange: forwardChange, value, ...inputProps } = props;
3710
3717
  const [focus, setFocus] = React.useState(false);
3711
3718
  const classNames = addClassname(`o-input o-input-size-${size}${focus ? ' o-input-focus' : ''}${status ? ' o-input-status-' + status.toLowerCase() : ''}`, className);
3712
3719
  const onFocus = (e) => {
@@ -3717,9 +3724,21 @@ const InputComponent = (props) => {
3717
3724
  setFocus(false);
3718
3725
  forwardBlur && forwardBlur(e);
3719
3726
  };
3727
+ const ref = React.useRef(null);
3728
+ const selectorRef = React.useRef();
3729
+ const onChange = (e) => {
3730
+ selectorRef.current = e.target.selectionStart;
3731
+ forwardChange && forwardChange(e);
3732
+ };
3733
+ React.useEffect(() => {
3734
+ if (selectorRef.current !== undefined && selectorRef.current !== null && ref.current) {
3735
+ ref.current.setSelectionRange(selectorRef.current, selectorRef.current);
3736
+ selectorRef.current = undefined;
3737
+ }
3738
+ }, [value]);
3720
3739
  return (React.createElement("div", { className: classNames },
3721
3740
  PrefixComponent && React.createElement(PrefixComponent, { ...props, className: "o-input-prefix" }),
3722
- React.createElement("input", { className: "o-input-field", ...inputProps, onFocus: onFocus, onBlur: onBlur }),
3741
+ React.createElement("input", { className: "o-input-field", ...inputProps, ref: ref, onFocus: onFocus, onBlur: onBlur, onChange: value === undefined ? undefined : onChange, value: value }),
3723
3742
  SuffixComponent && React.createElement(SuffixComponent, { ...props, className: "o-input-suffix" })));
3724
3743
  };
3725
3744
  InputComponent.displayName = 'InputComponent';
@@ -4460,7 +4479,7 @@ const useListView = ({ controller, height, itemHeight = defaultItemHeight, overs
4460
4479
  let to;
4461
4480
  const first = Math.max(0, lastVirtualItemIndex - increment);
4462
4481
  if (lastVirtualItemIndex > 0) {
4463
- let slice = state.items.slice(Math.max(0, lastVirtualItemIndex - increment), lastVirtualItemIndex);
4482
+ let slice = state.items.slice(first, lastVirtualItemIndex);
4464
4483
  if (slice.length < lastVirtualItemIndex - first) {
4465
4484
  const arr = new Array(lastVirtualItemIndex - first);
4466
4485
  arr.splice(arr.length - slice.length, slice.length, ...slice);
@@ -4506,6 +4525,10 @@ const useListView = ({ controller, height, itemHeight = defaultItemHeight, overs
4506
4525
  to = offset + increment;
4507
4526
  }
4508
4527
  if (from !== undefined && to !== undefined && to > from) {
4528
+ from = Math.max(0, from);
4529
+ if (state.total !== undefined) {
4530
+ to = Math.min(state.total, to);
4531
+ }
4509
4532
  controller.load(to - from, from, true);
4510
4533
  }
4511
4534
  }
@@ -4771,26 +4794,26 @@ const ListBodyComponent = ({ autoRefresh, bodyRef, className, follow, height, it
4771
4794
  });
4772
4795
  React.useEffect(() => {
4773
4796
  const atBottom = () => {
4774
- if (bodyRef && bodyRef.current) {
4775
- const sh = bodyRef.current.scrollHeight;
4776
- const st = bodyRef.current.scrollTop;
4777
- const oh = bodyRef.current.offsetHeight;
4797
+ const ref = parentRef ? parentRef : bodyRef;
4798
+ if (ref && ref.current) {
4799
+ const sh = ref.current.scrollHeight;
4800
+ const st = ref.current.scrollTop;
4801
+ const oh = ref.current.offsetHeight;
4778
4802
  if (oh === 0 || st === sh - oh)
4779
4803
  return true;
4780
4804
  }
4781
4805
  return false;
4782
4806
  };
4783
4807
  if (tail && scrollToIndex && totalSize && bodyRef && bodyRef.current) {
4784
- const lastScrollTop = tailRef.current.lastScrollTop;
4785
4808
  tailRef.current.lastScrollTop = bodyRef.current.scrollTop;
4786
- if (tailRef.current.applyTail === true &&
4787
- lastScrollTop > bodyRef.current.scrollTop &&
4788
- (mouseRef.current || wheelRef.current)) {
4809
+ if (mouseRef.current || wheelRef.current) {
4789
4810
  tailRef.current.applyTail = false;
4790
4811
  }
4791
4812
  else if (tailRef.current.applyTail === true || atBottom()) {
4792
4813
  tailRef.current.applyTail = true;
4793
- scrollToIndex(state.total ? state.total - 1 : state.items ? state.items.length - 1 : 0);
4814
+ scrollToIndex(state.total ? state.total - 1 : state.items ? state.items.length - 1 : 0, {
4815
+ align: 'start',
4816
+ });
4794
4817
  }
4795
4818
  wheelRef.current = false;
4796
4819
  }
@@ -6262,7 +6285,7 @@ const SelectOptionComponent = (props) => {
6262
6285
  return (React.createElement(React.Fragment, null,
6263
6286
  displayGroup && React.createElement(OptionGroupComponent, { ...props }),
6264
6287
  React.createElement("div", { className: classNames, onClick: () => onItemClick(item, index), onMouseEnter: () => hoverable && onMouseEnter && item && onMouseEnter(item, index), onMouseLeave: () => hoverable && onMouseLeave && item && onMouseLeave(item, index) },
6265
- React.createElement("div", { ref: ref },
6288
+ React.createElement("div", { style: { display: 'flex' }, ref: ref },
6266
6289
  service.config?.multiple && (React.createElement(Checkbox, { value: item?.selected ? true : false, onChange: () => onItemClick(item, index), color: "currentColor", className: "o-select-option-multiple-checkbox" })),
6267
6290
  React.createElement(OptionContentComponent, { ...props, onClick: () => onItemClick(item, index) })))));
6268
6291
  };
@@ -6380,8 +6403,13 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6380
6403
  const showActiveRef = React.useRef(false);
6381
6404
  const proxyItem = React.useMemo(() => {
6382
6405
  const search = controller.getSearch();
6383
- if (showActiveRef.current && controller.state.active && controller.state.active.length > 0) {
6384
- return controller.getItem(controller.state.active[0]);
6406
+ const active = controller.state.active;
6407
+ const selected = controller.state.selected;
6408
+ if (showActiveRef.current && active && active.length > 0) {
6409
+ if (multiple && selected && selected.find((i) => i === active[0])) {
6410
+ return undefined;
6411
+ }
6412
+ return controller.getItem(active[0]);
6385
6413
  }
6386
6414
  else if (focus && search) {
6387
6415
  const item = autoCompleteSearch ? findSelectItem(controller, search.toString()) : controller.items[0];
@@ -6390,8 +6418,11 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6390
6418
  }
6391
6419
  return item;
6392
6420
  }
6393
- else if (controller.state.active && controller.state.active.length > 0) {
6394
- return controller.getItem(controller.state.active[0]);
6421
+ else if (active && active.length > 0) {
6422
+ if (multiple && selected && selected.find((i) => i === active[0])) {
6423
+ return undefined;
6424
+ }
6425
+ return controller.getItem(active[0]);
6395
6426
  }
6396
6427
  if (!multiple) {
6397
6428
  return controller.adapt(value);
@@ -8962,7 +8993,7 @@ const TableBodyComponent = ({ className, tableRef, contentRef }) => {
8962
8993
  const itemHeight = React.useCallback(() => {
8963
8994
  return 20;
8964
8995
  }, []);
8965
- const { items, isVirtual, totalSize, virtualItems, measure } = useListView({
8996
+ const { items, isVirtual, totalSize, virtualItems, measure, scrollToIndex } = useListView({
8966
8997
  controller: service,
8967
8998
  height: height,
8968
8999
  ref: parentRef || tableRef,
@@ -8988,7 +9019,7 @@ const TableBodyComponent = ({ className, tableRef, contentRef }) => {
8988
9019
  if (service.status === onekijsFramework.LoadingStatus.Loaded && items.length === 0 && NotFoundComponent) {
8989
9020
  return React.createElement(NotFoundComponent, null);
8990
9021
  }
8991
- 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 }));
9022
+ 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 }));
8992
9023
  };
8993
9024
  TableBodyComponent.displayName = 'TableBody';
8994
9025
 
@@ -11704,6 +11735,7 @@ exports.FormSelect = FormSelect$1;
11704
11735
  exports.FormStep = FormCard;
11705
11736
  exports.FormTable = FormTable;
11706
11737
  exports.FormTextarea = FormTextarea;
11738
+ exports.HelpIcon = HelpIcon;
11707
11739
  exports.Input = Input;
11708
11740
  exports.InputCellComponent = InputCellComponent;
11709
11741
  exports.InputComponent = InputComponent;