@oliasoft-open-source/react-ui-library 5.11.7 → 5.12.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.
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { Context } from 'react';
3
3
  import { CSSProperties } from 'react';
4
4
  import { default as default_2 } from 'react';
5
5
  import { DependencyList } from 'react';
6
+ import { DropOptions } from '@minoru/react-dnd-treeview';
6
7
  import { ElementType as ElementType_2 } from 'react';
7
8
  import { FC } from 'react';
8
9
  import { FocusEvent as FocusEvent_2 } from 'react';
@@ -1060,6 +1061,11 @@ export declare interface INumberInputProps {
1060
1061
  disableValidationOnFocus?: boolean;
1061
1062
  }
1062
1063
 
1064
+ declare interface IOnRowClickFunction {
1065
+ (): any;
1066
+ noStyle?: boolean;
1067
+ }
1068
+
1063
1069
  export declare interface IOptionDropdownProps {
1064
1070
  name?: string;
1065
1071
  disabled?: boolean;
@@ -1720,41 +1726,24 @@ declare interface ITopBarTitleProps {
1720
1726
  onClick?: MouseEventHandler<HTMLDivElement | HTMLAnchorElement>;
1721
1727
  }
1722
1728
 
1729
+ declare interface ITreeListItemProps extends IListItem {
1730
+ id: TStringOrNumber;
1731
+ parent: TStringOrNumber;
1732
+ droppable?: boolean;
1733
+ onDrop?: (event: default_2.DragEvent<HTMLDivElement>) => void;
1734
+ }
1735
+
1723
1736
  declare interface ITreeListProps {
1724
1737
  name?: string | default_2.ReactNode;
1725
1738
  noHeader?: boolean;
1726
- items: {
1727
- id: TStringOrNumber;
1728
- name: string | default_2.ReactNode;
1729
- parent: TStringOrNumber;
1730
- droppable?: boolean;
1731
- details?: string | default_2.ReactNode;
1732
- active?: boolean;
1733
- testId?: string;
1734
- icon?: {
1735
- icon: default_2.ReactNode;
1736
- color: string;
1737
- tooltip?: {
1738
- text: TStringOrNumber | default_2.ReactNode;
1739
- error?: boolean;
1740
- warning?: boolean;
1741
- placement?: string;
1742
- enabled?: boolean;
1743
- maxWidth?: TStringOrNumber;
1744
- triggerOffset?: TStringOrNumber;
1745
- possiblePlacements?: string[];
1746
- fontSize?: TStringOrNumber;
1747
- padding?: TStringOrNumber;
1748
- };
1749
- };
1750
- onDrop?: (event: default_2.DragEvent<HTMLDivElement>) => void;
1751
- }[];
1739
+ items: ITreeListItemProps[] | ITreeRowItem[];
1752
1740
  onClick?: TEmpty;
1753
1741
  actions?: any[];
1754
1742
  }
1755
1743
 
1756
1744
  export declare interface ITreeProps {
1757
1745
  list: ITreeListProps;
1746
+ canDrop?: (tree: NodeModel[], options: DropOptions) => boolean | void;
1758
1747
  draggable?: boolean;
1759
1748
  onListReorder?: (newList: any[]) => void;
1760
1749
  onChangeOpen?: (id: TStringOrNumber[]) => void;
@@ -1771,6 +1760,22 @@ export declare interface ITreeProps {
1771
1760
  allowParentReassignment?: boolean;
1772
1761
  stickyHeader?: boolean;
1773
1762
  height?: number | string;
1763
+ render?: (node: NodeModel<any>, options: {
1764
+ depth: number;
1765
+ draggable: boolean;
1766
+ handleRef: RefObject<HTMLDivElement>;
1767
+ hasChild: boolean;
1768
+ isOpen: boolean;
1769
+ onToggle: (id: TStringOrNumber) => void;
1770
+ }) => ReactElement;
1771
+ }
1772
+
1773
+ declare interface ITreeRowItem extends TRowType_2 {
1774
+ id: TStringOrNumber;
1775
+ name?: string;
1776
+ parent: TStringOrNumber;
1777
+ droppable?: boolean;
1778
+ onDrop?: (event: default_2.DragEvent<HTMLDivElement>) => void;
1774
1779
  }
1775
1780
 
1776
1781
  declare interface IUnitConfigItem {
@@ -2165,7 +2170,7 @@ declare const TRANSLATION_FALLBACK: {
2165
2170
  unknown: string;
2166
2171
  };
2167
2172
 
2168
- export declare const Tree: ({ list, draggable, onListReorder, onChangeOpen, testId, isInitialOpen, autoOpenActiveItems, treeRef: treeRefProp, itemHasChild, onItemToggle, icons, allowParentReassignment, stickyHeader, height, }: ITreeProps) => JSX_2.Element;
2173
+ export declare const Tree: ({ list, canDrop, draggable, onListReorder, onChangeOpen, testId, isInitialOpen, autoOpenActiveItems, treeRef: treeRefProp, itemHasChild, onItemToggle, icons, allowParentReassignment, stickyHeader, height, render, }: ITreeProps) => JSX_2.Element;
2169
2174
 
2170
2175
  export declare enum TriggerType {
2171
2176
  TEXT = "Text",
@@ -2185,6 +2190,23 @@ declare type TRowType = {
2185
2190
  onRowMouseLeave?: TEmpty;
2186
2191
  };
2187
2192
 
2193
+ declare type TRowType_2 = {
2194
+ active?: boolean;
2195
+ error?: boolean;
2196
+ warning?: boolean;
2197
+ cells: TCellShape[];
2198
+ noDrag?: boolean;
2199
+ onRowClick?: IOnRowClickFunction;
2200
+ onRowFocus?: IOnRowClickFunction;
2201
+ onRowMouseEnter?: IOnRowClickFunction;
2202
+ onRowMouseLeave?: IOnRowClickFunction;
2203
+ expandedContent?: {
2204
+ content: ReactNode;
2205
+ flush?: boolean;
2206
+ };
2207
+ actions?: any[];
2208
+ };
2209
+
2188
2210
  declare type TSliderMark = {
2189
2211
  value: number | string;
2190
2212
  label?: number | string | ReactNode;
package/dist/index.js CHANGED
@@ -3061,34 +3061,34 @@ const ExpandedContentRow = ({ colSpan: e, children: t, flush: n }) => /* @__PURE
3061
3061
  return r && t ? e[n] || [] : i ? e : (console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."), []);
3062
3062
  };
3063
3063
  var cell_module_default = {
3064
- inputInTable: "_inputInTable_ie6ng_1",
3065
- inputHover: "_inputHover_ie6ng_13",
3066
- inputFocus: "_inputFocus_ie6ng_18",
3067
- inputError: "_inputError_ie6ng_25",
3068
- inputWarning: "_inputWarning_ie6ng_26",
3069
- inputDisabled: "_inputDisabled_ie6ng_61",
3070
- hideScrollbars: "_hideScrollbars_ie6ng_67",
3071
- cell: "_cell_ie6ng_77",
3072
- disabledLink: "_disabledLink_ie6ng_87",
3073
- inputWrapper: "_inputWrapper_ie6ng_91",
3074
- numberInputWrapper: "_numberInputWrapper_ie6ng_106",
3075
- breakWord: "_breakWord_ie6ng_113",
3076
- inputCell: "_inputCell_ie6ng_116",
3077
- sliderCell: "_sliderCell_ie6ng_119",
3078
- staticCell: "_staticCell_ie6ng_123",
3079
- staticCellContent: "_staticCellContent_ie6ng_126",
3080
- unit: "_unit_ie6ng_148",
3081
- sortingCell: "_sortingCell_ie6ng_151",
3082
- sortingCellIcon: "_sortingCellIcon_ie6ng_162",
3083
- icon: "_icon_ie6ng_173",
3084
- checkBoxCell: "_checkBoxCell_ie6ng_177",
3085
- iconCellWrapper: "_iconCellWrapper_ie6ng_181",
3086
- actionsCell: "_actionsCell_ie6ng_185",
3087
- rightAligned: "_rightAligned_ie6ng_193",
3088
- centerAligned: "_centerAligned_ie6ng_199",
3089
- leftAligned: "_leftAligned_ie6ng_205",
3090
- popover: "_popover_ie6ng_208",
3091
- disabledPointerEvents: "_disabledPointerEvents_ie6ng_211"
3064
+ inputInTable: "_inputInTable_1b0yl_1",
3065
+ inputHover: "_inputHover_1b0yl_13",
3066
+ inputFocus: "_inputFocus_1b0yl_18",
3067
+ inputError: "_inputError_1b0yl_25",
3068
+ inputWarning: "_inputWarning_1b0yl_26",
3069
+ inputDisabled: "_inputDisabled_1b0yl_61",
3070
+ hideScrollbars: "_hideScrollbars_1b0yl_67",
3071
+ cell: "_cell_1b0yl_77",
3072
+ disabledLink: "_disabledLink_1b0yl_87",
3073
+ inputWrapper: "_inputWrapper_1b0yl_91",
3074
+ numberInputWrapper: "_numberInputWrapper_1b0yl_106",
3075
+ breakWord: "_breakWord_1b0yl_113",
3076
+ inputCell: "_inputCell_1b0yl_116",
3077
+ sliderCell: "_sliderCell_1b0yl_119",
3078
+ staticCell: "_staticCell_1b0yl_123",
3079
+ staticCellContent: "_staticCellContent_1b0yl_126",
3080
+ unit: "_unit_1b0yl_147",
3081
+ sortingCell: "_sortingCell_1b0yl_150",
3082
+ sortingCellIcon: "_sortingCellIcon_1b0yl_161",
3083
+ icon: "_icon_1b0yl_172",
3084
+ checkBoxCell: "_checkBoxCell_1b0yl_176",
3085
+ iconCellWrapper: "_iconCellWrapper_1b0yl_180",
3086
+ actionsCell: "_actionsCell_1b0yl_184",
3087
+ rightAligned: "_rightAligned_1b0yl_192",
3088
+ centerAligned: "_centerAligned_1b0yl_198",
3089
+ leftAligned: "_leftAligned_1b0yl_204",
3090
+ popover: "_popover_1b0yl_207",
3091
+ disabledPointerEvents: "_disabledPointerEvents_1b0yl_210"
3092
3092
  };
3093
3093
  const InputCell = ({ cell: e, columnAlignment: t, testId: n, type: r }) => /* @__PURE__ */ jsx(Input, {
3094
3094
  name: e.name,
@@ -6460,12 +6460,12 @@ const Content = ({ title: e, okText: t, onClickOk: n, disableConfirmButton: r, c
6460
6460
  children: e
6461
6461
  });
6462
6462
  var tree_module_default = {
6463
- tree: "_tree_1mtkj_1",
6464
- toggle: "_toggle_1mtkj_7",
6465
- dropTarget: "_dropTarget_1mtkj_14",
6466
- placeholder: "_placeholder_1mtkj_29",
6467
- draggingSource: "_draggingSource_1mtkj_35",
6468
- placeholderContainer: "_placeholderContainer_1mtkj_38"
6463
+ tree: "_tree_1cqsz_1",
6464
+ toggle: "_toggle_1cqsz_7",
6465
+ dropTarget: "_dropTarget_1cqsz_14",
6466
+ placeholder: "_placeholder_1cqsz_29",
6467
+ draggingSource: "_draggingSource_1cqsz_35",
6468
+ placeholderContainer: "_placeholderContainer_1cqsz_38"
6469
6469
  };
6470
6470
  const TreeItem = ({ node: t, depth: n, isOpen: r, onToggle: i, hasChild: a, draggable: o, icons: s, onDrop: c }) => {
6471
6471
  let { id: l, data: u } = t, { active: d, testId: f, onClick: p, actions: m = [] } = u, [h, _] = React.useState(!1), [v, y] = React.useState(0), b = (e) => {
@@ -6522,39 +6522,39 @@ const TreeItem = ({ node: t, depth: n, isOpen: r, onToggle: i, hasChild: a, drag
6522
6522
  }, TreePlaceholder = ({ depth: e }) => /* @__PURE__ */ jsx("div", {
6523
6523
  className: tree_module_default.placeholder,
6524
6524
  style: { left: e * 24 }
6525
- }), Tree = ({ list: e, draggable: t = !1, onListReorder: n, onChangeOpen: r, testId: i, isInitialOpen: a = !1, autoOpenActiveItems: o = !1, treeRef: s, itemHasChild: l, onItemToggle: u, icons: d, allowParentReassignment: f, stickyHeader: m, height: h }) => {
6526
- let g = s ?? useRef(null), _ = (e) => {
6527
- r && r(e);
6528
- }, v = (t) => {
6525
+ }), Tree = ({ list: e, canDrop: t, draggable: n = !1, onListReorder: r, onChangeOpen: i, testId: a, isInitialOpen: o = !1, autoOpenActiveItems: s = !1, treeRef: l, itemHasChild: u, onItemToggle: d, icons: f, allowParentReassignment: m, stickyHeader: h, height: g, render: _ }) => {
6526
+ let v = l ?? useRef(null), y = (e) => {
6527
+ i && i(e);
6528
+ }, b = (t) => {
6529
6529
  let n = e.items.find((e) => e.id === t);
6530
- return n && n.parent ? [n.parent, ...v(n.parent)] : [];
6530
+ return n && n.parent ? [n.parent, ...b(n.parent)] : [];
6531
6531
  };
6532
6532
  useEffect(() => {
6533
- if (o) {
6533
+ if (s) {
6534
6534
  let t = e.items.find((e) => e.active);
6535
6535
  if (t) {
6536
- let e = v(t.id);
6537
- g.current?.open(e);
6536
+ let e = b(t.id);
6537
+ v.current?.open(e);
6538
6538
  }
6539
6539
  }
6540
- }, [o, e.items]);
6541
- let y = (e, t) => e?.findIndex((e) => e?.id === t) ?? -1, b = (e, t) => {
6542
- let n = y(t, e?.parent);
6540
+ }, [s, e.items]);
6541
+ let x = (e, t) => e?.findIndex((e) => e?.id === t) ?? -1, S = (e, t) => {
6542
+ let n = x(t, e?.parent);
6543
6543
  if (n >= 0) {
6544
6544
  let r = t?.find((e) => e?.id === t[n]?.parent);
6545
6545
  e.parent = r ? r.id : 0;
6546
6546
  }
6547
- }, x = (e, t) => t?.filter((t) => t?.id !== e?.id) ?? [], S = (e, t, n) => (n?.splice(t, 0, e), n), C = (e) => e.map(({ id: e, parent: t, droppable: n, data: r }) => ({
6547
+ }, C = (e, t) => t?.filter((t) => t?.id !== e?.id) ?? [], w = (e, t, n) => (n?.splice(t, 0, e), n), T = (e) => e.map(({ id: e, parent: t, droppable: n, data: r }) => ({
6548
6548
  id: e,
6549
6549
  parent: t,
6550
6550
  droppable: n,
6551
6551
  ...r
6552
- })), w = (e, t) => {
6553
- let { dragSource: r, dropTarget: i } = t, a = [...e];
6554
- if (!n) return;
6555
- let o = y(a, r?.id), s = y(a, r?.parent), c = [];
6556
- r?.parent === i?.id && o === 0 && f && (b(r, a), a = x(r, a), a = S(r, s, a)), c = C(a), n(c);
6557
- }, T = e?.items?.map(({ id: e, droppable: t, parent: n, name: r, onDrop: i,...a }) => ({
6552
+ })), E = (e, t) => {
6553
+ let { dragSource: n, dropTarget: i } = t, a = [...e];
6554
+ if (!r) return;
6555
+ let o = x(a, n?.id), s = x(a, n?.parent), c = [];
6556
+ n?.parent === i?.id && o === 0 && m && (S(n, a), a = C(n, a), a = w(n, s, a)), c = T(a), r(c);
6557
+ }, D = e?.items?.map(({ id: e, droppable: t, parent: n, name: r, onDrop: i,...a }) => ({
6558
6558
  id: e,
6559
6559
  text: r,
6560
6560
  droppable: t,
@@ -6566,41 +6566,48 @@ const TreeItem = ({ node: t, depth: n, isOpen: r, onToggle: i, hasChild: a, drag
6566
6566
  }
6567
6567
  }));
6568
6568
  return /* @__PURE__ */ jsxs("div", {
6569
- "data-testid": i,
6569
+ "data-testid": a,
6570
6570
  className: list_module_default.list,
6571
- style: { height: h },
6571
+ style: { height: g },
6572
6572
  children: [e.name && !e.noHeader && /* @__PURE__ */ jsx(ListHeading, {
6573
6573
  name: e.name,
6574
6574
  actions: e.actions,
6575
- stickyHeader: m
6575
+ stickyHeader: h
6576
6576
  }), /* @__PURE__ */ jsx(DndProvider, {
6577
6577
  backend: MultiBackend,
6578
6578
  options: getBackendOptions(),
6579
6579
  context: window,
6580
6580
  children: /* @__PURE__ */ jsx(Tree$1, {
6581
- ref: g,
6582
- tree: T,
6581
+ ref: v,
6582
+ tree: D,
6583
6583
  sort: !1,
6584
6584
  insertDroppableFirst: !1,
6585
- canDrag: () => t,
6586
- canDrop: (e, { dragSource: t, dropTargetId: n }) => {
6585
+ canDrag: () => n,
6586
+ canDrop: t || ((e, { dragSource: t, dropTargetId: n }) => {
6587
6587
  if (t?.parent === n) return !0;
6588
- },
6588
+ }),
6589
6589
  rootId: 0,
6590
- render: (e, { depth: n, isOpen: r, onToggle: i, hasChild: a }) => /* @__PURE__ */ jsx(TreeItem, {
6591
- hasChild: l ? l(e) : a,
6590
+ render: (e, { depth: t, hasChild: r, handleRef: i, isOpen: a, onToggle: o }) => _ ? _(e, {
6591
+ depth: t,
6592
+ draggable: n,
6593
+ handleRef: i,
6594
+ hasChild: r,
6595
+ isOpen: a,
6596
+ onToggle: o
6597
+ }) : /* @__PURE__ */ jsx(TreeItem, {
6598
+ hasChild: u ? u(e) : r,
6592
6599
  node: e,
6593
- depth: n,
6594
- isOpen: r,
6600
+ depth: t,
6601
+ isOpen: a,
6595
6602
  onToggle: () => {
6596
- u?.(e, !r), i();
6603
+ d?.(e, !a), o();
6597
6604
  },
6598
- draggable: t,
6599
- icons: d,
6605
+ draggable: n,
6606
+ icons: f,
6600
6607
  onDrop: e.data?.onDrop
6601
6608
  }),
6602
- onDrop: w,
6603
- onChangeOpen: _,
6609
+ onDrop: E,
6610
+ onChangeOpen: y,
6604
6611
  dropTargetOffset: 10,
6605
6612
  placeholderRender: (e, { depth: t }) => /* @__PURE__ */ jsx(TreePlaceholder, { depth: t }),
6606
6613
  placeholderComponent: "div",
@@ -6612,7 +6619,8 @@ const TreeItem = ({ node: t, depth: n, isOpen: r, onToggle: i, hasChild: a, drag
6612
6619
  dropTarget: tree_module_default.dropTarget,
6613
6620
  placeholder: tree_module_default.placeholderContainer
6614
6621
  },
6615
- initialOpen: a
6622
+ initialOpen: o,
6623
+ enableAnimateExpand: !0
6616
6624
  })
6617
6625
  })]
6618
6626
  });
@@ -8573,7 +8581,10 @@ const countDeltas = (e) => (Array.isArray(e) ? e : e ? [e] : []).reduce((e, t) =
8573
8581
  if (i) return i;
8574
8582
  }
8575
8583
  return "";
8576
- }, toText = (e) => Array.isArray(e) ? e.length === 0 ? "" : e.some((e) => e && typeof e == "object") ? "Multiple changes..." : String(e) : e && typeof e == "object" ? Object.keys(e).length === 0 ? "" : "Multiple changes..." : String(e), defaultMessage = (e) => {
8584
+ }, toText = (e) => {
8585
+ let t = (e) => isValueWithUnit(e) ? withPrettyUnitLabel(e) : String(e);
8586
+ return Array.isArray(e) ? e.length === 0 ? "" : e.some((e) => e && typeof e == "object") ? "Multiple changes..." : e.map(t).join(", ") : e && typeof e == "object" ? Object.keys(e).length === 0 ? "" : "Multiple changes..." : t(e);
8587
+ }, defaultMessage = (e) => {
8577
8588
  switch (e.length) {
8578
8589
  case 1: {
8579
8590
  let [t] = e;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "5.11.7",
3
+ "version": "5.12.1",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {