onekijs-ui 0.16.2 → 0.16.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.
Files changed (40) hide show
  1. package/dist/components/list/DropdownList.d.ts +1 -0
  2. package/dist/components/list/components/ArrayListComponent.d.ts +1 -0
  3. package/dist/components/list/components/CollectionListComponent.d.ts +1 -0
  4. package/dist/components/list/components/ListBodyComponent.d.ts +1 -0
  5. package/dist/components/list/components/ListComponent.d.ts +1 -0
  6. package/dist/components/list/components/VirtualListComponent.d.ts +1 -0
  7. package/dist/components/list/index.d.ts +1 -0
  8. package/dist/components/select/TreeSelect.d.ts +0 -1
  9. package/dist/components/select/components/ControlledSelectComponent.d.ts +1 -1
  10. package/dist/components/select/components/SelectTokensComponent.d.ts +1 -1
  11. package/dist/components/select/index.d.ts +0 -1
  12. package/dist/components/select/typings.d.ts +3 -0
  13. package/dist/components/tree/components/ArrayTreeComponent.d.ts +1 -0
  14. package/dist/components/tree/components/ControllerTreeComponent.d.ts +1 -0
  15. package/dist/components/tree/components/TreeBodyComponent.d.ts +1 -0
  16. package/dist/components/tree/components/TreeComponent.d.ts +1 -0
  17. package/dist/components/tree/components/TreeItemComponent.d.ts +1 -0
  18. package/dist/components/tree/components/TreeListComponent.d.ts +1 -0
  19. package/dist/components/tree/components/VirtualTreeBodyComponent.d.ts +1 -0
  20. package/dist/components/tree/components/VirtualTreeListComponent.d.ts +1 -0
  21. package/dist/components/tree/index.d.ts +1 -0
  22. package/dist/index.js +73 -29
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.module.js +73 -29
  25. package/dist/index.module.js.map +1 -1
  26. package/dist/styles/size.d.ts +6 -6
  27. package/dist/styles/typography.d.ts +1 -1
  28. package/package.json +3 -3
  29. package/src/components/icon/LoadingIcon.tsx +12 -3
  30. package/src/components/select/FormSelect.tsx +5 -7
  31. package/src/components/select/SelectService.ts +3 -1
  32. package/src/components/select/components/ControlledSelectComponent.tsx +4 -0
  33. package/src/components/select/components/SelectInputComponent.tsx +7 -4
  34. package/src/components/select/components/SelectTokenComponent.tsx +2 -1
  35. package/src/components/select/components/SelectTokensComponent.tsx +29 -18
  36. package/src/components/select/style.ts +10 -1
  37. package/src/components/select/typings.ts +3 -0
  38. package/src/components/table/components/ControllerTableComponent.tsx +1 -1
  39. package/src/components/table/components/filters/TableSelectFilterComponent.tsx +2 -1
  40. package/src/components/tooltip/components/TooltipComponent.tsx +24 -2
@@ -719,8 +719,8 @@ const iconCircleKeyFrame = keyframes `
719
719
  transform: rotate(360deg);
720
720
  }
721
721
  `;
722
- var LoadingIcon = styled(IconComponent$7) `
723
- ${({ width: cssWidth = '16px', height: cssHeight = '16px', color: cssColor = 'primary' }) => css `
722
+ const iconStyle = ({ width: cssWidth = '16px', height: cssHeight = '16px', color: cssColor = 'primary', }) => {
723
+ return css `
724
724
  height: ${cssHeight};
725
725
  width: ${cssWidth};
726
726
  display: inline-flex;
@@ -739,7 +739,10 @@ var LoadingIcon = styled(IconComponent$7) `
739
739
  stroke-width: 10px;
740
740
  transform-origin: 50% 50%;
741
741
  }
742
- `}
742
+ `;
743
+ };
744
+ var LoadingIcon = styled(IconComponent$7) `
745
+ ${iconStyle}
743
746
  `;
744
747
 
745
748
  const toDegree = (position) => {
@@ -1235,6 +1238,7 @@ const DropdownButton = styled(DropdownButtonComponent) `
1235
1238
 
1236
1239
  const TooltipComponent = (props) => {
1237
1240
  const { content, className, popperOptions, children, delayHide = 300, ...tooltipConfig } = props;
1241
+ const [show, setShow] = useState(true);
1238
1242
  const tooltipOptions = Object.assign({
1239
1243
  interactive: true,
1240
1244
  delayHide,
@@ -1243,9 +1247,27 @@ const TooltipComponent = (props) => {
1243
1247
  const { style: containerStyle, ...containerProps } = getTooltipProps({ className: 'o-tooltip-container' });
1244
1248
  const { style: arrowStyle, ...arrowProps } = getArrowProps({ className: 'o-tooltip-arrow' });
1245
1249
  const classNames = addClassname('o-tooltip', className);
1250
+ const uid = useId();
1251
+ useEffect(() => {
1252
+ if (visible) {
1253
+ const event = new CustomEvent('tooltipVisible', {
1254
+ detail: uid,
1255
+ });
1256
+ document.dispatchEvent(event);
1257
+ }
1258
+ }, [visible, uid]);
1259
+ useEffect(() => {
1260
+ const listener = (e) => {
1261
+ setShow(e.detail === uid);
1262
+ };
1263
+ document.addEventListener('tooltipVisible', listener);
1264
+ return () => {
1265
+ document.removeEventListener('tooltipVisible', listener);
1266
+ };
1267
+ }, [uid]);
1246
1268
  return (React.createElement("div", { className: classNames, ref: setTriggerRef },
1247
1269
  children,
1248
- visible && content && (React.createElement("div", { ref: setTooltipRef, style: containerStyle, ...containerProps },
1270
+ show && visible && content && (React.createElement("div", { ref: setTooltipRef, style: containerStyle, ...containerProps },
1249
1271
  React.createElement("div", { style: arrowStyle, ...arrowProps }),
1250
1272
  content))));
1251
1273
  };
@@ -5676,7 +5698,9 @@ let SelectService = class SelectService extends CollectionService {
5676
5698
  else {
5677
5699
  yield this._setValidDefaultValue(this.config === undefined || this.config.nullable || !this.state.items
5678
5700
  ? null
5679
- : this.config.defaultValue === undefined || this.state.defaultValue === null
5701
+ : this.config.defaultValue === undefined ||
5702
+ this.config.defaultValue === null ||
5703
+ this.state.defaultValue === null
5680
5704
  ? this.state.items[0]?.data || null
5681
5705
  : null);
5682
5706
  }
@@ -5877,14 +5901,15 @@ const SelectIconComponent = ({ onClick, open, loading }) => {
5877
5901
  const SelectTokenComponent = ({ token, onRemove, index, }) => {
5878
5902
  return (React.createElement("div", { className: "o-select-token" },
5879
5903
  React.createElement("div", { className: "o-select-token-text", key: "o-select-token-text" }, token.text),
5880
- React.createElement("div", { className: "o-select-token-remove", key: "o-select-token-remove", onClick: () => {
5904
+ React.createElement("div", { className: "o-select-token-remove", key: "o-select-token-remove", onClick: (e) => {
5881
5905
  onRemove(token, index);
5906
+ e.stopPropagation();
5882
5907
  } }, "\u2716")));
5883
5908
  };
5884
5909
  SelectTokenComponent.displayName = 'SelectTokenComponent';
5885
5910
  var SelectTokenComponent$1 = React.memo(SelectTokenComponent);
5886
5911
 
5887
- const SelectTokensComponent = ({ tokens, onRemove, }) => {
5912
+ const SelectTokensComponent = ({ tokens, onRemove, maxDisplayTokens, }) => {
5888
5913
  const widthRef = useRef();
5889
5914
  const onExiting = (node) => {
5890
5915
  node.style.width = '0';
@@ -5901,15 +5926,23 @@ const SelectTokensComponent = ({ tokens, onRemove, }) => {
5901
5926
  }, 0);
5902
5927
  };
5903
5928
  if (tokens !== undefined) {
5904
- return (React.createElement(TransitionGroup, { component: null }, tokens.map((token, index) => (React.createElement(CSSTransition, { timeout: 150, classNames: "o-select-token-animation", mountOnEnter: true, appear: true, unmountOnExit: true, key: `o-select-token-${token.id}`, onEntering: onEntering, onExiting: onExiting },
5905
- React.createElement(SelectTokenComponent$1, { token: token, onRemove: onRemove, index: index }))))));
5929
+ if (!maxDisplayTokens || tokens.length <= maxDisplayTokens) {
5930
+ return (React.createElement(TransitionGroup, { component: null }, tokens.map((token, index) => (React.createElement(CSSTransition, { timeout: 150, classNames: "o-select-token-animation", mountOnEnter: true, appear: true, unmountOnExit: true, key: `o-select-token-${token.id}`, onEntering: onEntering, onExiting: onExiting },
5931
+ React.createElement(SelectTokenComponent$1, { token: token, onRemove: onRemove, index: index }))))));
5932
+ }
5933
+ else {
5934
+ return (React.createElement("div", { className: "o-select-token o-select-token-disabled" },
5935
+ React.createElement("div", { className: "o-select-token-text", key: "o-select-token-text" },
5936
+ tokens.length,
5937
+ " selected")));
5938
+ }
5906
5939
  }
5907
5940
  return null;
5908
5941
  };
5909
5942
  SelectTokensComponent.displayName = 'SelectTokensComponent';
5910
5943
  var SelectTokensComponent$1 = React.memo(SelectTokensComponent);
5911
5944
 
5912
- const SelectInputComponent = ({ setOpen, open, placeholder, loading, fetching, IconComponent = SelectIconComponent, onFocus: forwardFocus, onBlur: forwardBlur, onChange, onRemove, value, focus, multiple, tokens, autoFocus, style, nullable, clickable, searchable, minChars, disabled, }, ref) => {
5945
+ const SelectInputComponent = ({ setOpen, open, placeholder, loading, fetching, IconComponent = SelectIconComponent, onFocus: forwardFocus, onBlur: forwardBlur, onChange, onRemove, value, focus, multiple, tokens, autoFocus, style, nullable, clickable, searchable, minChars, disabled, maxDisplayTokens, }, ref) => {
5913
5946
  const inputRef = useRef(null);
5914
5947
  const autoSizeRef = useRef(null);
5915
5948
  // partialValue is the part of the selected item entered by the user
@@ -6054,12 +6087,12 @@ const SelectInputComponent = ({ setOpen, open, placeholder, loading, fetching, I
6054
6087
  }
6055
6088
  }, [autoFocus]);
6056
6089
  return (React.createElement("div", { className: className, style: style, ref: ref },
6057
- React.createElement("div", { className: "o-select-input-data" },
6058
- multiple && React.createElement(SelectTokensComponent$1, { tokens: tokens, onRemove: onRemove }),
6090
+ React.createElement("div", { className: "o-select-input-data", onClick: searchable ? undefined : onClick },
6091
+ multiple && React.createElement(SelectTokensComponent$1, { tokens: tokens, onRemove: onRemove, maxDisplayTokens: maxDisplayTokens }),
6059
6092
  React.createElement("div", { className: "o-select-input-wrapper" },
6060
6093
  React.createElement("span", { ref: autoSizeRef, className: "o-select-input-auto-sizer" }),
6061
- React.createElement("input", { ref: inputRef, placeholder: placeholder, className: "o-select-input", onFocus: onFocus, onBlur: onBlur, onChange: handleChange, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, value: proxyValue, onClick: onClick, autoCapitalize: "none", autoComplete: "off", autoCorrect: "off", spellCheck: "false", disabled: disabled }),
6062
- !searchable && (React.createElement("span", { className: "o-select-input o-select-input-text", onClick: onClick }, proxyValue || '')))),
6094
+ React.createElement("input", { ref: inputRef, placeholder: placeholder, className: "o-select-input", onFocus: onFocus, onBlur: onBlur, onChange: handleChange, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, value: searchable ? proxyValue : '', onClick: onClick, autoCapitalize: "none", autoComplete: "off", autoCorrect: "off", spellCheck: "false", disabled: disabled }),
6095
+ !searchable && (React.createElement("span", { className: "o-select-input o-select-input-text", onClick: onClick }, multiple ? '' : proxyValue || '')))),
6063
6096
  !multiple && nullable && value && !disabled && (React.createElement("div", { className: "o-select-remover", onClick: onNullify }, "\u2716")),
6064
6097
  React.createElement(IconComponent, { onClick: onIconClick, open: open, loading: loading, fetching: fetching })));
6065
6098
  };
@@ -6144,7 +6177,7 @@ const DefaultSelectListComponent = (props) => {
6144
6177
  });
6145
6178
  return (React.createElement(ListBodyComponent, { ...props, className: "o-select-options", bodyRef: props.optionsRef, items: selectItems, totalSize: totalSize, virtualItems: isVirtual ? virtualItems : undefined, scrollToIndex: scrollToIndex, keyboardNavigable: true, service: props.controller?.asService(), state: props.controller.state }));
6146
6179
  };
6147
- const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '', placeholder, controller, InputComponent = SelectInputComponent$1, IconComponent, OptionContentComponent = SelectOptionContent, OptionComponent = SelectOptionComponent$1, OptionLoadingComponent = LoadingItem$1, MultiOptionsComponent = SelectOptionComponent$1, NotFoundComponent = SelectNotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height = 220, multiple = false, status = ValidationStatus.None, size = 'medium', nullable, minChars = 0, openOnFocus = false, searchable = true, dropdownWidthModifier = 'min', preload = 50, increment = 50, animationMs = 200, disabled, defaultValue, required = false, sameWidth = true, overscan, clickable = true, ListComponent = DefaultSelectListComponent, autoCompleteSearch = true, }) => {
6180
+ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '', placeholder, controller, InputComponent = SelectInputComponent$1, IconComponent, OptionContentComponent = SelectOptionContent, OptionComponent = SelectOptionComponent$1, OptionLoadingComponent = LoadingItem$1, MultiOptionsComponent = SelectOptionComponent$1, NotFoundComponent = SelectNotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height = 220, multiple = false, status = ValidationStatus.None, size = 'medium', nullable, minChars = 0, openOnFocus = false, searchable = true, dropdownWidthModifier = 'min', preload = 50, increment = 50, animationMs = 200, disabled, defaultValue, required = false, sameWidth = true, overscan, clickable = true, ListComponent = DefaultSelectListComponent, autoCompleteSearch = true, maxDisplayTokens, }) => {
6148
6181
  if (nullable === undefined) {
6149
6182
  nullable = !required;
6150
6183
  }
@@ -6187,6 +6220,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6187
6220
  sameWidth,
6188
6221
  overscan,
6189
6222
  autoCompleteSearch,
6223
+ maxDisplayTokens,
6190
6224
  };
6191
6225
  }
6192
6226
  else {
@@ -6224,6 +6258,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6224
6258
  sameWidth,
6225
6259
  overscan,
6226
6260
  autoCompleteSearch,
6261
+ maxDisplayTokens,
6227
6262
  };
6228
6263
  }
6229
6264
  const id = useId();
@@ -6565,7 +6600,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6565
6600
  useEventListener('keydown', onKeyDown, false);
6566
6601
  return (React.createElement(SelectServiceContext.Provider, { value: service },
6567
6602
  React.createElement("div", { className: classNames, ref: containerRef, onMouseDown: () => (stateRef.current.keepFocus = true), onMouseUp: () => (stateRef.current.keepFocus = false) },
6568
- React.createElement(InputComponent, { placeholder: placeholder, setOpen: setOpen, open: open, loading: loading, fetching: fetching, onChange: onInputChange, value: autoCompleteSearch ? (proxyItem ? proxyItem.text : '') : controller.getSearch() || '', focus: focus, onFocus: onFocus, onBlur: onBlur, tokens: tokens, multiple: multiple, onRemove: onRemoveToken, autoFocus: autoFocus, style: style, nullable: nullable, IconComponent: IconComponent, searchable: searchable, clickable: clickable, minChars: minChars, ref: triggerRef, disabled: disabled, autoCompleteSearch: autoCompleteSearch }),
6603
+ React.createElement(InputComponent, { placeholder: placeholder, setOpen: setOpen, open: open, loading: loading, fetching: fetching, onChange: onInputChange, value: autoCompleteSearch ? (proxyItem ? proxyItem.text : '') : controller.getSearch() || '', focus: focus, onFocus: onFocus, onBlur: onBlur, tokens: tokens, multiple: multiple, onRemove: onRemoveToken, autoFocus: autoFocus, style: style, nullable: nullable, IconComponent: IconComponent, searchable: searchable, clickable: clickable, minChars: minChars, ref: triggerRef, disabled: disabled, autoCompleteSearch: autoCompleteSearch, maxDisplayTokens: maxDisplayTokens }),
6569
6604
  React.createElement(Dropdown, { attachToBody: attachDropdownToBody, open: open, distance: 0, animationTimeout: animationMs, onDropStart: onOpen, onCollapseDone: onClosed, placement: "bottom-start", widthModifier: dropdownWidthModifier, className: className, zIndex: attachDropdownToBody ? 2000 : undefined },
6570
6605
  React.createElement(ListComponent, { className: "o-select-options", height: height, ItemComponent: multiple ? MultiOptionsComponent : OptionComponent, ItemLoadingComponent: OptionLoadingComponent, ItemContentComponent: OptionContentComponent, NotFoundComponent: NotFoundComponent, onItemSelect: onSelect, onItemUnselect: onSelect, controller: controller, keyboardNavigable: true, multiSelect: multiple, onItemActivate: onActivate, optionsRef: optionsRef })))));
6571
6606
  };
@@ -6788,7 +6823,8 @@ const selectStyle = ({ theme, clickable = true, searchable = true }) => {
6788
6823
  ${flexGrow(1)}
6789
6824
  ${flexWrap('wrap')}
6790
6825
  ${alignItems('center')}
6791
- ${paddingX('sm')}
6826
+ ${paddingLeft('sm')}
6827
+ ${paddingRight(searchable ? 'sm' : 0)}
6792
6828
  ${maxWidth('calc(100% - 32px)')}
6793
6829
  }
6794
6830
 
@@ -6833,6 +6869,13 @@ const selectStyle = ({ theme, clickable = true, searchable = true }) => {
6833
6869
  ${flexGrow(1)}
6834
6870
  ${paddingLeft('sm')}
6835
6871
  }
6872
+
6873
+ .o-select-token-disabled {
6874
+ ${paddingRight('sm')}
6875
+ ${backgroundColor('dark')}
6876
+ ${color('lightest')}
6877
+ }
6878
+
6836
6879
  .o-select-token-remove {
6837
6880
  ${cursor('pointer')}
6838
6881
  ${color('white', { hover: 'danger' })}
@@ -6978,12 +7021,13 @@ const Select = styled(SelectComponent$1) `
6978
7021
  `;
6979
7022
 
6980
7023
  const FormSelect = (props) => {
6981
- const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({
6982
- defaultValue: props.defaultValue === undefined ? (props.multiple ? [] : null) : props.defaultValue,
6983
- }, props));
7024
+ const defaultValue = props.defaultValue === undefined ? (props.multiple ? [] : null) : props.defaultValue;
7025
+ const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({}, props, {
7026
+ defaultValue,
7027
+ }));
6984
7028
  const Component = props.FieldComponent || Select;
6985
7029
  return (React.createElement(FieldLayout, { ...fieldLayoutProps, required: props.required },
6986
- React.createElement(Component, { ...fieldComponentProps, required: props.required, defaultValue: props.defaultValue })));
7030
+ React.createElement(Component, { ...fieldComponentProps, required: props.required, defaultValue: defaultValue })));
6987
7031
  };
6988
7032
  FormSelect.displayName = 'FormSelect';
6989
7033
  var FormSelect$1 = React.memo(FormSelect);
@@ -8675,12 +8719,6 @@ const useTableState = () => {
8675
8719
  return useContext(TableStateContext);
8676
8720
  };
8677
8721
 
8678
- const ExpandedCellComponent = ({ item, className }) => {
8679
- const service = useTableService();
8680
- return (React.createElement("div", { className: addClassname('o-table-cell-expander-content', className), onClick: () => service.toggle(item) },
8681
- React.createElement(TogglerIcon, { open: item.expanded, model: "plus", color: "primary" })));
8682
- };
8683
-
8684
8722
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8685
8723
  const useTableColumns = () => {
8686
8724
  return useTableState().columns;
@@ -9446,6 +9484,12 @@ const TableHeaderComponent = ({ columns, className }) => {
9446
9484
  };
9447
9485
  TableHeaderComponent.displayName = 'TableHeader';
9448
9486
 
9487
+ const ExpandedCellComponent = ({ item, className }) => {
9488
+ const service = useTableService();
9489
+ return (React.createElement("div", { className: addClassname('o-table-cell-expander-content', className), onClick: () => service.toggle(item) },
9490
+ React.createElement(TogglerIcon, { open: item.expanded, model: "plus", color: "primary" })));
9491
+ };
9492
+
9449
9493
  const ControllerTableComponent = ({ autoRefresh, controller, className, bodyClassName, BodyComponent = TableBodyComponent, ExpandedComponent, filterable, fit, fixHeader = true, 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, }) => {
9450
9494
  const classNames = addClassname('o-table', className);
9451
9495
  const { columns, items } = controller.state;
@@ -9795,7 +9839,7 @@ const addFilter = (controller, value, column, operator) => {
9795
9839
  controller.removeFilter(column.id);
9796
9840
  }
9797
9841
  };
9798
- const operators$1 = [{ text: 'equals', operator: 'eq', not: false }];
9842
+ const operators$1 = [{ text: 'any of', operator: 'in', not: false }];
9799
9843
  const TableSelectFilterComponent = ({ column, dataSource, }) => {
9800
9844
  const controller = useTableService();
9801
9845
  const filter = controller.getFilterById(column.id);
@@ -9814,7 +9858,7 @@ const TableSelectFilterComponent = ({ column, dataSource, }) => {
9814
9858
  const scClassName = className ? className.split(' ').slice(0, 2).join(' ') : '';
9815
9859
  return (React.createElement("div", { className: "o-table-filter-select-container" },
9816
9860
  React.createElement(TableFilterOperatorComponent, { operators: operators$1, onChange: onOperatorChange, selected: currentOperator, className: filterValue && filterValue.length > 0 ? 'o-table-filter-active' : '' }),
9817
- React.createElement(Select, { className: addClassname('o-table-filter-select', scClassName), multiple: true, dataSource: dataSource, value: filterValue, nullable: true, searchable: false, onChange: onValueChange, size: "xsmall", attachDropdownToBody: true })));
9861
+ React.createElement(Select, { className: addClassname('o-table-filter-select', scClassName), multiple: true, dataSource: dataSource, value: filterValue, nullable: true, searchable: false, onChange: onValueChange, size: "xsmall", attachDropdownToBody: true, maxDisplayTokens: 1 })));
9818
9862
  };
9819
9863
  TableSelectFilterComponent.displayName = 'TableInputFilterComponent';
9820
9864