funda-ui 4.2.255 → 4.2.445

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 (77) hide show
  1. package/CascadingSelect/index.js +1 -1
  2. package/EventCalendar/index.css +3 -0
  3. package/EventCalendar/index.d.ts +4 -1
  4. package/EventCalendar/index.js +16 -4
  5. package/EventCalendarTimeline/index.css +17 -0
  6. package/EventCalendarTimeline/index.d.ts +9 -2
  7. package/EventCalendarTimeline/index.js +77 -22
  8. package/LiveSearch/index.css +12 -0
  9. package/LiveSearch/index.js +1 -1
  10. package/ModalDialog/index.js +1 -1
  11. package/MultilevelDropdownMenu/index.css +2 -2
  12. package/MultilevelDropdownMenu/index.js +54 -46
  13. package/MultipleSelect/index.css +35 -26
  14. package/MultipleSelect/index.d.ts +3 -0
  15. package/MultipleSelect/index.js +366 -134
  16. package/NativeSelect/index.js +75 -47
  17. package/Pagination/index.d.ts +2 -0
  18. package/Pagination/index.js +25 -21
  19. package/Radio/index.js +14 -6
  20. package/RangeSlider/index.css +1 -0
  21. package/Select/index.css +5 -0
  22. package/Select/index.d.ts +1 -0
  23. package/Select/index.js +31 -11
  24. package/Tabs/index.js +13 -2
  25. package/Tree/index.js +90 -56
  26. package/lib/cjs/CascadingSelect/index.js +1 -1
  27. package/lib/cjs/EventCalendar/index.d.ts +4 -1
  28. package/lib/cjs/EventCalendar/index.js +16 -4
  29. package/lib/cjs/EventCalendarTimeline/index.d.ts +9 -2
  30. package/lib/cjs/EventCalendarTimeline/index.js +77 -22
  31. package/lib/cjs/LiveSearch/index.js +1 -1
  32. package/lib/cjs/ModalDialog/index.js +1 -1
  33. package/lib/cjs/MultilevelDropdownMenu/index.js +54 -46
  34. package/lib/cjs/MultipleSelect/index.d.ts +3 -0
  35. package/lib/cjs/MultipleSelect/index.js +366 -134
  36. package/lib/cjs/NativeSelect/index.js +75 -47
  37. package/lib/cjs/Pagination/index.d.ts +2 -0
  38. package/lib/cjs/Pagination/index.js +25 -21
  39. package/lib/cjs/Radio/index.js +14 -6
  40. package/lib/cjs/Select/index.d.ts +1 -0
  41. package/lib/cjs/Select/index.js +31 -11
  42. package/lib/cjs/Tabs/index.js +13 -2
  43. package/lib/cjs/Tree/index.js +90 -56
  44. package/lib/css/EventCalendar/index.css +3 -0
  45. package/lib/css/EventCalendarTimeline/index.css +17 -0
  46. package/lib/css/LiveSearch/index.css +12 -0
  47. package/lib/css/MultilevelDropdownMenu/index.css +2 -2
  48. package/lib/css/MultipleSelect/index.css +35 -26
  49. package/lib/css/RangeSlider/index.css +1 -0
  50. package/lib/css/Select/index.css +5 -0
  51. package/lib/esm/CascadingSelect/index.tsx +1 -1
  52. package/lib/esm/EventCalendar/index.scss +2 -0
  53. package/lib/esm/EventCalendar/index.tsx +23 -6
  54. package/lib/esm/EventCalendarTimeline/index.scss +24 -1
  55. package/lib/esm/EventCalendarTimeline/index.tsx +195 -118
  56. package/lib/esm/LiveSearch/index.scss +14 -1
  57. package/lib/esm/LiveSearch/index.tsx +1 -1
  58. package/lib/esm/ModalDialog/index.tsx +1 -1
  59. package/lib/esm/MultilevelDropdownMenu/{MenuList.tsx → ItemList.tsx} +52 -45
  60. package/lib/esm/MultilevelDropdownMenu/index.scss +2 -2
  61. package/lib/esm/MultilevelDropdownMenu/index.tsx +12 -4
  62. package/lib/esm/MultipleSelect/ItemList.tsx +300 -0
  63. package/lib/esm/MultipleSelect/index.scss +61 -30
  64. package/lib/esm/MultipleSelect/index.tsx +56 -87
  65. package/lib/esm/MultipleSelect/multiple-select-utils/func.ts +29 -0
  66. package/lib/esm/NativeSelect/index.tsx +4 -18
  67. package/lib/esm/NativeSelect/native-select-utils/func.ts +40 -0
  68. package/lib/esm/Pagination/index.tsx +31 -22
  69. package/lib/esm/Radio/index.tsx +19 -6
  70. package/lib/esm/RangeSlider/index.scss +2 -0
  71. package/lib/esm/Select/index.scss +6 -1
  72. package/lib/esm/Select/index.tsx +70 -54
  73. package/lib/esm/Table/Table.tsx +2 -0
  74. package/lib/esm/Tabs/Tabs.tsx +19 -4
  75. package/lib/esm/Tree/TreeList.tsx +61 -54
  76. package/lib/esm/Tree/index.tsx +4 -0
  77. package/package.json +1 -1
@@ -81,6 +81,7 @@ type SelectProps = {
81
81
  controlExClassName?: string;
82
82
  exceededSidePosOffset?: number;
83
83
  multiSelect?: MultiSelectConfig;
84
+ multiSelectEntireAreaTrigger?: boolean;
84
85
  multiSelectSelectedItemOnlyStatus?: multiSelectSelectedItemOnlyStatusConfig;
85
86
  renderSelectedValue?: (selectedData: MultiSelectControlValConfig, removeFunc: (e: React.MouseEvent) => void) => void;
86
87
  cleanTrigger?: CleanTriggerConfig;
@@ -139,6 +140,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
139
140
  controlExClassName,
140
141
  exceededSidePosOffset,
141
142
  multiSelect,
143
+ multiSelectEntireAreaTrigger,
142
144
  multiSelectSelectedItemOnlyStatus,
143
145
  renderSelectedValue,
144
146
  disabled,
@@ -189,7 +191,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
189
191
 
190
192
  const INPUT_READONLY = LIVE_SEARCH_DISABLED ? true : (typeof readOnly === 'undefined' ? null : readOnly);
191
193
  const VALUE_BY_BRACKETS = typeof extractValueByBrackets === 'undefined' ? true : extractValueByBrackets;
192
- const LOCK_BODY_SCROLL = typeof lockBodyScroll === 'undefined' ? true : lockBodyScroll;
194
+ const LOCK_BODY_SCROLL = typeof lockBodyScroll === 'undefined' ? false : lockBodyScroll;
193
195
  const WIN_WIDTH = typeof winWidth === 'function' ? winWidth() : winWidth ? winWidth : 'auto';
194
196
  const INDENT_PLACEHOLDER = doubleIndent ? `        ` : `    `;
195
197
  const INDENT_LAST_PLACEHOLDER = `${typeof indentation !== 'undefined' && indentation !== '' ? `${indentation}  ` : ''}`;
@@ -231,10 +233,11 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
231
233
 
232
234
  const selectedSign = useRef<boolean>(false);
233
235
  const MULTI_SEL_VALID = multiSelect ? multiSelect.valid : false;
236
+ const MULTI_SEL_ENTIRE_AREA_TRIGGER = typeof multiSelectEntireAreaTrigger === 'undefined' ? true : multiSelectEntireAreaTrigger;
234
237
  const MULTI_SEL_LABEL = multiSelect ? multiSelect.selectAllLabel : 'Select all options';
235
238
  const MULTI_SEL_SELECTED_STATUS: Record<string, string> = {
236
239
  itemsLabel: '{num} Selected',
237
- allItemsLabel: 'All Content',
240
+ allItemsLabel: 'All Content ({num})',
238
241
  noneLabel: 'No items selected',
239
242
  };
240
243
 
@@ -271,6 +274,12 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
271
274
  useImperativeHandle(
272
275
  contentRef,
273
276
  () => ({
277
+ active: () => {
278
+ handleShowList();
279
+ },
280
+ focus: () => {
281
+ selectInputRef.current.select();
282
+ },
274
283
  clear: (cb?: any) => {
275
284
 
276
285
  if (MULTI_SEL_VALID) {
@@ -1498,6 +1507,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
1498
1507
 
1499
1508
  function handleMultiControlItemRemove(event: any) {
1500
1509
  event.preventDefault();
1510
+ event.stopPropagation(); /* REQUIRED */
1501
1511
 
1502
1512
  const valueToRemove = String(event.currentTarget.dataset.value);
1503
1513
  const getCurrentIndex = controlArr.values.findIndex((item: any) => item.toString() === valueToRemove);
@@ -1817,6 +1827,8 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
1817
1827
 
1818
1828
 
1819
1829
  {!MULTI_SEL_VALID ? <>
1830
+
1831
+ {/** INPUT */}
1820
1832
  <div className="position-relative">
1821
1833
  <input
1822
1834
  ref={(node) => {
@@ -1942,7 +1954,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
1942
1954
 
1943
1955
  {/* SEARCH BUTTON */}
1944
1956
  {fetchTrigger ? <>
1945
- <span className="custom-select-multi__control-searchbtn position-absolute top-0 end-0">
1957
+ <span className="custom-select-multi__control-searchbtn">
1946
1958
  <button tabIndex={-1} type="button" className="btn border-end-0 rounded-pill" onClick={(e: React.MouseEvent) => {
1947
1959
  handleFetch().then((response: any) => {
1948
1960
 
@@ -1974,24 +1986,24 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
1974
1986
  // ++++++++++++++++++++
1975
1987
  */}
1976
1988
  {MULTI_SEL_VALID ? <div ref={rootMultiRef} className="custom-select-multi__inputplaceholder-wrapper">
1977
-
1989
+
1978
1990
 
1979
1991
  {/* PLACEHOLDER */}
1980
1992
  <div className="custom-select-multi__inputplaceholder-inner">
1981
- <div>
1993
+ <div style={MULTI_SEL_ENTIRE_AREA_TRIGGER ? {pointerEvents: 'auto', cursor: 'pointer'} : undefined} onClick={MULTI_SEL_ENTIRE_AREA_TRIGGER ? ( typeof readOnly === 'undefined' || !readOnly ? handleShowList : () => void (0) ) : () => void (0)}>
1982
1994
  <ul className="custom-select-multi__list">
1983
1995
 
1984
1996
  {typeof multiSelectSelectedItemOnlyStatus !== 'undefined' ? <>
1985
1997
 
1986
- <li className="custom-select-multi__list-item-statusstring">
1998
+ <li className="custom-select-multi__list-item-statusstring" >
1987
1999
  {typeof multiSelectSelectedItemOnlyStatus.itemsLabel === 'string' && controlArr.labels.length > 0 && controlArr.labels.length < optionsData.length ? multiSelectSelectedItemOnlyStatus.itemsLabel.replace('{num}', `${controlArr.labels.length}`) : null}
1988
2000
  {typeof multiSelectSelectedItemOnlyStatus.noneLabel === 'string' && controlArr.labels.length === 0 ? multiSelectSelectedItemOnlyStatus.noneLabel : null}
1989
- {typeof multiSelectSelectedItemOnlyStatus.allItemsLabel === 'string' && controlArr.labels.length === optionsData.length ? multiSelectSelectedItemOnlyStatus.allItemsLabel : null}
2001
+ {typeof multiSelectSelectedItemOnlyStatus.allItemsLabel === 'string' && controlArr.labels.length === optionsData.length ? multiSelectSelectedItemOnlyStatus.allItemsLabel.replace('{num}', `${controlArr.labels.length}`) : null}
1990
2002
 
1991
2003
  {/*-----*/}
1992
2004
  {typeof multiSelectSelectedItemOnlyStatus.itemsLabel !== 'string' && controlArr.labels.length > 0 ? MULTI_SEL_SELECTED_STATUS.itemsLabel.replace('{num}', `${controlArr.labels.length}`) : null}
1993
2005
  {typeof multiSelectSelectedItemOnlyStatus.noneLabel !== 'string' && controlArr.labels.length === 0 ? MULTI_SEL_SELECTED_STATUS.noneLabel : null}
1994
- {typeof multiSelectSelectedItemOnlyStatus.allItemsLabel !== 'string' && controlArr.labels.length === optionsData.length ? MULTI_SEL_SELECTED_STATUS.allItemsLabel : null}
2006
+ {typeof multiSelectSelectedItemOnlyStatus.allItemsLabel !== 'string' && controlArr.labels.length === optionsData.length ? MULTI_SEL_SELECTED_STATUS.allItemsLabel.replace('{num}', `${controlArr.labels.length}`) : null}
1995
2007
 
1996
2008
  </li>
1997
2009
  </> : <>
@@ -2005,9 +2017,9 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
2005
2017
  key={'selected-item-' + index}
2006
2018
  data-value={controlArr.values[index]}
2007
2019
  data-label-full={item}
2008
- data-label-text={stripHTML(item)}
2020
+ data-label-text={formatIndentVal(stripHTML(item), INDENT_LAST_PLACEHOLDER)}
2009
2021
  >
2010
- {stripHTML(item)}
2022
+ {formatIndentVal(stripHTML(item), INDENT_LAST_PLACEHOLDER)}
2011
2023
 
2012
2024
  <a
2013
2025
  href="#"
@@ -2019,53 +2031,57 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
2019
2031
  ))}
2020
2032
  </>}
2021
2033
 
2022
- <li className="custom-select-multi__list-item-add">
2023
- <div className="position-relative">
2024
- {/*
2034
+
2035
+ </>}
2036
+
2037
+
2038
+ {/** INPUT */}
2039
+ <li className="custom-select-multi__list-item-add">
2040
+ <div className="position-relative">
2041
+ {/*
2025
2042
  // DO NOT USE following attributes in " Multiple selection Control":
2026
2043
  a) data-select
2027
2044
  b) value
2028
2045
  */}
2029
- <input
2030
- ref={(node) => {
2031
- selectInputRef.current = node;
2032
- if (typeof externalRef === 'function') {
2033
- externalRef(node);
2034
- } else if (externalRef) {
2035
- externalRef.current = node;
2036
- }
2037
- }}
2038
- tabIndex={tabIndex || 0}
2039
- type="text"
2040
- data-overlay-id={`custom-select__options-wrapper-${idRes}`}
2041
- id={`label-${idRes}`}
2042
-
2043
- // Don't use "name", it's just a container to display the label
2044
- data-name={name?.match(/(\[.*?\])/gi) ? `${name.split('[')[0]}-label[]` : `${name}-label`}
2045
- className={`${controlClassName || controlClassName === '' ? controlClassName : "form-control"} ${controlExClassName || ''}`}
2046
- onFocus={handleFocus}
2047
- onBlur={handleBlur}
2048
- onClick={typeof readOnly === 'undefined' || !readOnly ? handleShowList : () => void (0)}
2049
- onChange={handleChange}
2050
- onCompositionStart={handleComposition}
2051
- onCompositionUpdate={handleComposition}
2052
- onCompositionEnd={handleComposition}
2053
- disabled={disabled || null}
2054
- required={required || null}
2055
- readOnly={INPUT_READONLY}
2056
- placeholder={placeholder}
2057
- style={style}
2058
- autoComplete={typeof autoComplete === 'undefined' ? 'off' : autoComplete}
2059
- autoCapitalize={typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize}
2060
- spellCheck={typeof spellCheck === 'undefined' ? false : spellCheck}
2061
- {...attributes}
2062
- />
2063
-
2064
- </div>
2065
-
2066
-
2067
- </li>
2068
- </>}
2046
+ <input
2047
+ ref={(node) => {
2048
+ selectInputRef.current = node;
2049
+ if (typeof externalRef === 'function') {
2050
+ externalRef(node);
2051
+ } else if (externalRef) {
2052
+ externalRef.current = node;
2053
+ }
2054
+ }}
2055
+ tabIndex={tabIndex || 0}
2056
+ type="text"
2057
+ data-overlay-id={`custom-select__options-wrapper-${idRes}`}
2058
+ id={`label-${idRes}`}
2059
+
2060
+ // Don't use "name", it's just a container to display the label
2061
+ data-name={name?.match(/(\[.*?\])/gi) ? `${name.split('[')[0]}-label[]` : `${name}-label`}
2062
+ className={`${controlClassName || controlClassName === '' ? controlClassName : "form-control"} ${controlExClassName || ''}`}
2063
+ onFocus={handleFocus}
2064
+ onBlur={handleBlur}
2065
+ onClick={typeof readOnly === 'undefined' || !readOnly ? handleShowList : () => void (0)}
2066
+ onChange={handleChange}
2067
+ onCompositionStart={handleComposition}
2068
+ onCompositionUpdate={handleComposition}
2069
+ onCompositionEnd={handleComposition}
2070
+ disabled={disabled || null}
2071
+ required={required || null}
2072
+ readOnly={INPUT_READONLY}
2073
+ placeholder={placeholder}
2074
+ style={style}
2075
+ autoComplete={typeof autoComplete === 'undefined' ? 'off' : autoComplete}
2076
+ autoCapitalize={typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize}
2077
+ spellCheck={typeof spellCheck === 'undefined' ? false : spellCheck}
2078
+ {...attributes}
2079
+ />
2080
+
2081
+ </div>
2082
+
2083
+
2084
+ </li>
2069
2085
 
2070
2086
  </ul>
2071
2087
 
@@ -2096,7 +2112,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
2096
2112
 
2097
2113
  {/* SEARCH BUTTON */}
2098
2114
  {fetchTrigger ? <>
2099
- <span className="custom-select-multi__control-searchbtn position-absolute top-0 end-0">
2115
+ <span className="custom-select-multi__control-searchbtn">
2100
2116
  <button tabIndex={-1} type="button" className="btn border-end-0 rounded-pill" onClick={(e: React.MouseEvent) => {
2101
2117
  handleFetch().then((response: any) => {
2102
2118
 
@@ -3,6 +3,8 @@ import React, { useEffect, useState, forwardRef, useRef } from 'react';
3
3
  import {
4
4
  useComId
5
5
  } from 'funda-utils';
6
+
7
+
6
8
  import { TableProvider } from './TableContext';
7
9
  import useTableResponsive from './table-utils/hooks/useTableResponsive';
8
10
  import useTableDraggable from './table-utils/hooks/useTableDraggable';
@@ -1,9 +1,10 @@
1
- import React, { useEffect, useRef } from 'react';
1
+ import React, { forwardRef, useEffect, useRef, useImperativeHandle } from 'react';
2
2
 
3
3
  import {
4
4
  useComId
5
5
  } from 'funda-utils';
6
6
 
7
+
7
8
  //
8
9
  import TabList from './TabList';
9
10
  import TabPanel from './TabPanel';
@@ -24,8 +25,8 @@ type TabsProps = {
24
25
 
25
26
  };
26
27
 
27
- const Tabs = (props: TabsProps) => {
28
-
28
+ const Tabs = forwardRef((props: TabsProps, externalRef: any) => {
29
+
29
30
  const {
30
31
  wrapperClassName,
31
32
  navClassName,
@@ -44,6 +45,20 @@ const Tabs = (props: TabsProps) => {
44
45
  const speed = animTransitionDuration ? animTransitionDuration : 150;
45
46
 
46
47
 
48
+ // exposes the following methods
49
+ useImperativeHandle(
50
+ externalRef,
51
+ () => ({
52
+ go: (index: number) => {
53
+ const reactDomWrapperEl: any = rootRef.current;
54
+ const $li = [].slice.call(reactDomWrapperEl.querySelectorAll('ul > li'));
55
+ itemInit($li[index], false);
56
+ }
57
+ }),
58
+ [externalRef],
59
+ );
60
+
61
+
47
62
 
48
63
  const elDisplay = (type: string, node: HTMLElement) => {
49
64
  if (node === null) return;
@@ -257,7 +272,7 @@ const Tabs = (props: TabsProps) => {
257
272
  </>
258
273
  )
259
274
 
260
- }
275
+ });
261
276
 
262
277
 
263
278
 
@@ -1,11 +1,9 @@
1
- import React, { useEffect, useRef, useCallback } from 'react';
1
+ import React, { useEffect, useRef } from 'react';
2
2
 
3
3
  // HAS CHECKBOX
4
4
 
5
5
  import {
6
6
  getNextSiblings,
7
- getPreviousSiblings,
8
- getParents,
9
7
  getChildren
10
8
  } from 'funda-utils';
11
9
 
@@ -33,6 +31,7 @@ type TreeListProps = {
33
31
  arrow?: React.ReactNode;
34
32
  arrowIcons?: React.ReactNode[];
35
33
  childClassName?: string;
34
+ orginalData: any[any];
36
35
  data: any[any];
37
36
  getCheckedPrint?: any[];
38
37
  updateCheckedPrint?: any;
@@ -56,6 +55,7 @@ export default function TreeList(props: TreeListProps) {
56
55
  arrow,
57
56
  arrowIcons,
58
57
  childClassName,
58
+ orginalData,
59
59
  data,
60
60
  getCheckedPrint,
61
61
  updateCheckedPrint,
@@ -90,66 +90,74 @@ export default function TreeList(props: TreeListProps) {
90
90
  });
91
91
  };
92
92
 
93
- const setCheckboxIndeterminateData = (arr: any[], key: string, val: boolean) => {
94
- arr.forEach((item: any, index: number) => {
95
- if (item.key === key) arr[index].indeterminate = val;
96
- });
97
- };
98
-
99
-
100
-
101
- const setCheckboxIndeterminateStatus = (checkedData: any[], printData: any[], el: HTMLFormElement | null) => {
102
- let _parentsLi: any = [];
103
-
104
- if ( el !== null ) {
105
- _parentsLi = [].slice.call(getParents(el,'li'));
106
- _parentsLi.splice(0, 1);
107
- } else {
108
- _parentsLi = [].slice.call(document.querySelectorAll(`#${checkboxNamePrefix} li`));
93
+ // check whether the node is in the Indeterminate state
94
+ const isIndeterminate = (node: any) => {
95
+ if (!node.children || node.children.length === 0) {
96
+ return false;
109
97
  }
110
98
 
99
+ let hasChecked = false;
100
+ let hasUnchecked = false;
111
101
 
112
- //---
113
- _parentsLi.forEach((node: any) => {
114
- const _checkboxes = getChildren(node, '[type="checkbox"]');
115
- const parentKey = typeof _checkboxes[0] === 'undefined' ? '' : _checkboxes[0].dataset.key;
102
+ for (let child of node.children) {
103
+ if (isIndeterminate(child)) {
104
+ return true;
105
+ }
116
106
 
107
+ if (child.checked) {
108
+ hasChecked = true;
109
+ } else {
110
+ hasUnchecked = true;
111
+ }
117
112
 
118
- //
119
- let _checkedLengthCalcArr: any[] = [];
120
- checkedData.forEach((oitem: any, oindex: number) => {
121
- _checkboxes.forEach((el: any) => {
122
- if (el.dataset.key === oitem.key) _checkedLengthCalcArr.push(oitem);
123
- });
124
- });
125
- _checkedLengthCalcArr = _checkedLengthCalcArr.filter((el: any) => {
126
- return el.key !== parentKey;
127
- })
113
+ // If there are some selected and some unchecked, the node is Indeterminate
114
+ if (hasChecked && hasUnchecked) {
115
+ return true;
116
+ }
117
+ }
128
118
 
129
- //
130
- const _checkedLength = _checkedLengthCalcArr.filter((el: any) => {
131
- return el.checked === true;
132
- }).length;
119
+ // If all child nodes are the same, it is not Indeterminate
120
+ return false;
121
+ };
133
122
 
134
- if ( _checkedLength === 0 ) {
135
- setCheckboxIndeterminateData(checkedData, parentKey, false);
136
- } else {
137
123
 
138
- if ( _checkedLength === _checkboxes.length-1 ) {
139
- setCheckboxIndeterminateData(checkedData, parentKey, false);
140
- setCheckboxCheckedData(checkedData, parentKey, true);
141
- printData.push(formatCheckboxControlVal(_checkboxes[0]));
142
- }
143
-
144
- if ( _checkedLength < _checkboxes.length-1 ) {
145
- setCheckboxIndeterminateData(checkedData, parentKey, true);
146
- setCheckboxCheckedData(checkedData, parentKey, false);
147
- printData = removeItemOnce(printData, parentKey);
148
- }
124
+ const updateTreeCheckedItems = (arr: any[], flatArr: any[]) => {
125
+ if (!Array.isArray(arr)) return;
149
126
 
127
+ for (let i = 0; i < arr.length; i++) {
128
+ const orginalDataKey: React.Key = arr[i].key;
129
+ const targetItem = flatArr.find((v: any) => v.key === orginalDataKey);
130
+ if (typeof targetItem !== 'undefined') {
131
+ // update value of checked
132
+ arr[i].checked = targetItem.checked;
133
+ }
134
+
135
+ if (arr[i].children) updateTreeCheckedItems(arr[i].children, flatArr);
136
+ }
137
+ }
138
+
139
+ const updateIndeterminateData = (arr: any[], flatArr: any[]) => {
140
+ if (!Array.isArray(arr)) return;
141
+
142
+ for (let i = 0; i < arr.length; i++) {
143
+ const orginalDataKey: React.Key = arr[i].key;
144
+ const targetItem = flatArr.find((v: any) => v.key === orginalDataKey);
145
+ if (typeof targetItem !== 'undefined') {
146
+ // update indeterminate of item
147
+ targetItem.indeterminate = isIndeterminate(arr[i]);
150
148
  }
149
+
150
+ if (arr[i].children) updateIndeterminateData(arr[i].children, flatArr);
151
+ }
152
+ }
153
+
154
+ const setCheckboxIndeterminateStatus = (checkedData: any[], printData: any[], el: HTMLFormElement | null) => {
151
155
 
152
- });
156
+ // update checked items from orginal data
157
+ updateTreeCheckedItems(orginalData, checkedData);
158
+
159
+ // check whether the node is in the Indeterminate state
160
+ updateIndeterminateData(orginalData, checkedData);
153
161
 
154
162
  return [checkedData, printData];
155
163
 
@@ -301,7 +309,6 @@ export default function TreeList(props: TreeListProps) {
301
309
  //-----------
302
310
  if ( val === true ) {
303
311
  _res.push(formatCheckboxControlVal(el));
304
- setCheckboxIndeterminateData(_checkedData, _curKey, false);
305
312
  setCheckboxCheckedData(_checkedData, _curKey, true);
306
313
 
307
314
  } else {
@@ -317,7 +324,6 @@ export default function TreeList(props: TreeListProps) {
317
324
  [].slice.call(getChildren(el.closest('li'), '[type="checkbox"]')).forEach((node: any) => {
318
325
  if ( val === true ) {
319
326
  if ( node.dataset.key !== _curKey ) {
320
- setCheckboxIndeterminateData(_checkedData, node.dataset.key, false);
321
327
  setCheckboxCheckedData(_checkedData, node.dataset.key, true);
322
328
  _res.push(formatCheckboxControlVal(node));
323
329
  }
@@ -509,6 +515,7 @@ export default function TreeList(props: TreeListProps) {
509
515
  {item.children && item.children.length > 0 && <TreeList
510
516
  rootNode={rootNode}
511
517
  checkboxNamePrefix={checkboxNamePrefix}
518
+ orginalData={orginalData}
512
519
  data={item.children}
513
520
  first={false}
514
521
  arrow={arrow}
@@ -7,6 +7,7 @@ import {
7
7
  } from 'funda-utils';
8
8
 
9
9
 
10
+
10
11
  import TreeList from './TreeList';
11
12
  import { initUlHeight, initAsyncItems } from './init-height';
12
13
 
@@ -102,6 +103,7 @@ const Tree = (props: TreeProps) => {
102
103
  const uniqueID = useComId();
103
104
  const idRes = id || uniqueID;
104
105
  const rootRef = useRef<any>(null);
106
+ const [orginalData, setOrginalData] = useState<DataNode[] | null>(null);
105
107
  const [list, setList] = useState<DataNode[] | null>(null);
106
108
  const [flatList, setFlatList] = useState<DataNode[]>([]);
107
109
  const [checkedPrint, setCheckedPrint] = useState<any[]>([]);
@@ -348,6 +350,7 @@ const Tree = (props: TreeProps) => {
348
350
 
349
351
  useEffect(() => {
350
352
  initDefaultValue(null, null, true, retrieveData);
353
+ setOrginalData(data);
351
354
  }, [data, retrieveData]);
352
355
 
353
356
 
@@ -367,6 +370,7 @@ const Tree = (props: TreeProps) => {
367
370
  disableCollapse={disableCollapse}
368
371
  arrow={arrow}
369
372
  arrowIcons={arrowIcons}
373
+ orginalData={orginalData}
370
374
  data={Array.isArray(retrieveData) && retrieveData.length > 0 ? filterRetriveData(flatList, retrieveData) : list}
371
375
  childClassName={childClassName || 'tree-diagram-default-nav'}
372
376
  onSelect={onSelect}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "UIUX Lab",
3
3
  "email": "uiuxlab@gmail.com",
4
4
  "name": "funda-ui",
5
- "version": "4.2.255",
5
+ "version": "4.2.445",
6
6
  "description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
7
7
  "repository": {
8
8
  "type": "git",