funda-ui 1.0.272

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 (246) hide show
  1. package/BackToTop/index.css +34 -0
  2. package/BackToTop/index.d.ts +11 -0
  3. package/BackToTop/index.js +458 -0
  4. package/CascadingSelect/index.css +159 -0
  5. package/CascadingSelect/index.d.ts +56 -0
  6. package/CascadingSelect/index.js +958 -0
  7. package/CascadingSelectE2E/index.css +159 -0
  8. package/CascadingSelectE2E/index.d.ts +60 -0
  9. package/CascadingSelectE2E/index.js +1126 -0
  10. package/Checkbox/index.d.ts +30 -0
  11. package/Checkbox/index.js +226 -0
  12. package/ColorPicker/index.css +38 -0
  13. package/ColorPicker/index.d.ts +27 -0
  14. package/ColorPicker/index.js +246 -0
  15. package/DigitalClock/index.d.ts +7 -0
  16. package/DigitalClock/index.js +208 -0
  17. package/DropdownMenu/index.css +127 -0
  18. package/DropdownMenu/index.d.ts +37 -0
  19. package/DropdownMenu/index.js +237 -0
  20. package/DynamicFields/index.d.ts +26 -0
  21. package/DynamicFields/index.js +412 -0
  22. package/File/index.d.ts +36 -0
  23. package/File/index.js +473 -0
  24. package/Input/index.d.ts +42 -0
  25. package/Input/index.js +286 -0
  26. package/LiveSearch/index.d.ts +37 -0
  27. package/LiveSearch/index.js +1195 -0
  28. package/ModalDialog/index.d.ts +60 -0
  29. package/ModalDialog/index.js +725 -0
  30. package/ModeSwitch/index.d.ts +17 -0
  31. package/ModeSwitch/index.js +202 -0
  32. package/MultiFuncSelect/index.css +178 -0
  33. package/MultiFuncSelect/index.d.ts +67 -0
  34. package/MultiFuncSelect/index.js +1826 -0
  35. package/MultilevelDropdownMenu/index.css +35 -0
  36. package/MultilevelDropdownMenu/index.d.ts +25 -0
  37. package/MultilevelDropdownMenu/index.js +464 -0
  38. package/Pagination/index.d.ts +49 -0
  39. package/Pagination/index.js +341 -0
  40. package/README.md +108 -0
  41. package/Radio/index.d.ts +31 -0
  42. package/Radio/index.js +246 -0
  43. package/RangeSlider/index.css +149 -0
  44. package/RangeSlider/index.d.ts +21 -0
  45. package/RangeSlider/index.js +730 -0
  46. package/ScrollReveal/index.css +23 -0
  47. package/ScrollReveal/index.d.ts +21 -0
  48. package/ScrollReveal/index.js +216 -0
  49. package/Scrollbar/index.css +168 -0
  50. package/Scrollbar/index.d.ts +15 -0
  51. package/Scrollbar/index.js +605 -0
  52. package/SearchBar/index.d.ts +32 -0
  53. package/SearchBar/index.js +246 -0
  54. package/Select/index.d.ts +34 -0
  55. package/Select/index.js +331 -0
  56. package/ShowMoreLess/index.css +23 -0
  57. package/ShowMoreLess/index.d.ts +30 -0
  58. package/ShowMoreLess/index.js +202 -0
  59. package/Switch/index.d.ts +29 -0
  60. package/Switch/index.js +211 -0
  61. package/Table/index.css +533 -0
  62. package/Table/index.d.ts +25 -0
  63. package/Table/index.js +2113 -0
  64. package/Tabs/index.d.ts +3 -0
  65. package/Tabs/index.js +323 -0
  66. package/TagInput/index.css +90 -0
  67. package/TagInput/index.d.ts +28 -0
  68. package/TagInput/index.js +370 -0
  69. package/Textarea/index.d.ts +30 -0
  70. package/Textarea/index.js +242 -0
  71. package/Toast/index.css +95 -0
  72. package/Toast/index.d.ts +35 -0
  73. package/Toast/index.js +340 -0
  74. package/Tooltip/index.css +240 -0
  75. package/Tooltip/index.d.ts +19 -0
  76. package/Tooltip/index.js +200 -0
  77. package/Tree/index.css +225 -0
  78. package/Tree/index.d.ts +37 -0
  79. package/Tree/index.js +1406 -0
  80. package/all.d.ts +33 -0
  81. package/all.js +35 -0
  82. package/lib/cjs/BackToTop/index.d.ts +11 -0
  83. package/lib/cjs/BackToTop/index.js +458 -0
  84. package/lib/cjs/CascadingSelect/index.d.ts +56 -0
  85. package/lib/cjs/CascadingSelect/index.js +958 -0
  86. package/lib/cjs/CascadingSelectE2E/index.d.ts +60 -0
  87. package/lib/cjs/CascadingSelectE2E/index.js +1126 -0
  88. package/lib/cjs/Checkbox/index.d.ts +30 -0
  89. package/lib/cjs/Checkbox/index.js +226 -0
  90. package/lib/cjs/ColorPicker/index.d.ts +27 -0
  91. package/lib/cjs/ColorPicker/index.js +246 -0
  92. package/lib/cjs/DigitalClock/index.d.ts +7 -0
  93. package/lib/cjs/DigitalClock/index.js +208 -0
  94. package/lib/cjs/DropdownMenu/index.d.ts +37 -0
  95. package/lib/cjs/DropdownMenu/index.js +237 -0
  96. package/lib/cjs/DynamicFields/index.d.ts +26 -0
  97. package/lib/cjs/DynamicFields/index.js +412 -0
  98. package/lib/cjs/File/index.d.ts +36 -0
  99. package/lib/cjs/File/index.js +473 -0
  100. package/lib/cjs/Input/index.d.ts +42 -0
  101. package/lib/cjs/Input/index.js +286 -0
  102. package/lib/cjs/LiveSearch/index.d.ts +37 -0
  103. package/lib/cjs/LiveSearch/index.js +1195 -0
  104. package/lib/cjs/ModalDialog/index.d.ts +60 -0
  105. package/lib/cjs/ModalDialog/index.js +725 -0
  106. package/lib/cjs/ModeSwitch/index.d.ts +17 -0
  107. package/lib/cjs/ModeSwitch/index.js +202 -0
  108. package/lib/cjs/MultiFuncSelect/index.d.ts +67 -0
  109. package/lib/cjs/MultiFuncSelect/index.js +1826 -0
  110. package/lib/cjs/MultilevelDropdownMenu/index.d.ts +25 -0
  111. package/lib/cjs/MultilevelDropdownMenu/index.js +464 -0
  112. package/lib/cjs/Pagination/index.d.ts +49 -0
  113. package/lib/cjs/Pagination/index.js +341 -0
  114. package/lib/cjs/Radio/index.d.ts +31 -0
  115. package/lib/cjs/Radio/index.js +246 -0
  116. package/lib/cjs/RangeSlider/index.d.ts +21 -0
  117. package/lib/cjs/RangeSlider/index.js +730 -0
  118. package/lib/cjs/ScrollReveal/index.d.ts +21 -0
  119. package/lib/cjs/ScrollReveal/index.js +216 -0
  120. package/lib/cjs/Scrollbar/index.d.ts +15 -0
  121. package/lib/cjs/Scrollbar/index.js +605 -0
  122. package/lib/cjs/SearchBar/index.d.ts +32 -0
  123. package/lib/cjs/SearchBar/index.js +246 -0
  124. package/lib/cjs/Select/index.d.ts +34 -0
  125. package/lib/cjs/Select/index.js +331 -0
  126. package/lib/cjs/ShowMoreLess/index.d.ts +30 -0
  127. package/lib/cjs/ShowMoreLess/index.js +202 -0
  128. package/lib/cjs/Switch/index.d.ts +29 -0
  129. package/lib/cjs/Switch/index.js +211 -0
  130. package/lib/cjs/Table/index.d.ts +25 -0
  131. package/lib/cjs/Table/index.js +2113 -0
  132. package/lib/cjs/Tabs/index.d.ts +3 -0
  133. package/lib/cjs/Tabs/index.js +323 -0
  134. package/lib/cjs/TagInput/index.d.ts +28 -0
  135. package/lib/cjs/TagInput/index.js +370 -0
  136. package/lib/cjs/Textarea/index.d.ts +30 -0
  137. package/lib/cjs/Textarea/index.js +242 -0
  138. package/lib/cjs/Toast/index.d.ts +35 -0
  139. package/lib/cjs/Toast/index.js +340 -0
  140. package/lib/cjs/Tooltip/index.d.ts +19 -0
  141. package/lib/cjs/Tooltip/index.js +200 -0
  142. package/lib/cjs/Tree/index.d.ts +37 -0
  143. package/lib/cjs/Tree/index.js +1406 -0
  144. package/lib/cjs/index.d.ts +33 -0
  145. package/lib/cjs/index.js +35 -0
  146. package/lib/css/BackToTop/index.css +34 -0
  147. package/lib/css/CascadingSelect/index.css +159 -0
  148. package/lib/css/CascadingSelectE2E/index.css +159 -0
  149. package/lib/css/ColorPicker/index.css +38 -0
  150. package/lib/css/DropdownMenu/index.css +127 -0
  151. package/lib/css/MultiFuncSelect/index.css +178 -0
  152. package/lib/css/MultilevelDropdownMenu/index.css +35 -0
  153. package/lib/css/RangeSlider/index.css +149 -0
  154. package/lib/css/ScrollReveal/index.css +23 -0
  155. package/lib/css/Scrollbar/index.css +168 -0
  156. package/lib/css/ShowMoreLess/index.css +23 -0
  157. package/lib/css/Table/index.css +533 -0
  158. package/lib/css/TagInput/index.css +90 -0
  159. package/lib/css/Toast/index.css +95 -0
  160. package/lib/css/Tooltip/index.css +240 -0
  161. package/lib/css/Tree/index.css +225 -0
  162. package/lib/esm/BackToTop/index.scss +47 -0
  163. package/lib/esm/BackToTop/index.tsx +182 -0
  164. package/lib/esm/BackToTop/utils/easing.js +200 -0
  165. package/lib/esm/BackToTop/utils/performance.js +52 -0
  166. package/lib/esm/CascadingSelect/Group.tsx +39 -0
  167. package/lib/esm/CascadingSelect/index.scss +214 -0
  168. package/lib/esm/CascadingSelect/index.tsx +922 -0
  169. package/lib/esm/CascadingSelect/utils/performance.js +52 -0
  170. package/lib/esm/CascadingSelectE2E/Group.tsx +39 -0
  171. package/lib/esm/CascadingSelectE2E/index.scss +214 -0
  172. package/lib/esm/CascadingSelectE2E/index.tsx +1091 -0
  173. package/lib/esm/CascadingSelectE2E/utils/performance.js +52 -0
  174. package/lib/esm/Checkbox/index.tsx +160 -0
  175. package/lib/esm/ColorPicker/index.scss +48 -0
  176. package/lib/esm/ColorPicker/index.tsx +187 -0
  177. package/lib/esm/DigitalClock/index.tsx +72 -0
  178. package/lib/esm/DigitalClock/utils/useInterval.js +43 -0
  179. package/lib/esm/DropdownMenu/Option.tsx +27 -0
  180. package/lib/esm/DropdownMenu/index.scss +180 -0
  181. package/lib/esm/DropdownMenu/index.tsx +148 -0
  182. package/lib/esm/DynamicFields/index.tsx +386 -0
  183. package/lib/esm/File/index.tsx +302 -0
  184. package/lib/esm/Input/index.tsx +233 -0
  185. package/lib/esm/LiveSearch/index.tsx +582 -0
  186. package/lib/esm/LiveSearch/utils/performance.js +52 -0
  187. package/lib/esm/LiveSearch/utils/useThrottle.js +36 -0
  188. package/lib/esm/ModalDialog/index.tsx +479 -0
  189. package/lib/esm/ModalDialog/plugins/BSL/bodyScrollLock.es6.js +262 -0
  190. package/lib/esm/ModalDialog/plugins/BSL/index.ts +2 -0
  191. package/lib/esm/ModeSwitch/index.tsx +82 -0
  192. package/lib/esm/MultiFuncSelect/index.scss +269 -0
  193. package/lib/esm/MultiFuncSelect/index.tsx +1597 -0
  194. package/lib/esm/MultiFuncSelect/utils/performance.js +52 -0
  195. package/lib/esm/MultiFuncSelect/utils/tree.js +103 -0
  196. package/lib/esm/MultiFuncSelect/utils/useThrottle.js +36 -0
  197. package/lib/esm/MultilevelDropdownMenu/MenuList.tsx +230 -0
  198. package/lib/esm/MultilevelDropdownMenu/index.scss +75 -0
  199. package/lib/esm/MultilevelDropdownMenu/index.tsx +71 -0
  200. package/lib/esm/MultilevelDropdownMenu/utils/dom.js +81 -0
  201. package/lib/esm/Pagination/index.tsx +230 -0
  202. package/lib/esm/Pagination/pagination-navigators.tsx +60 -0
  203. package/lib/esm/Radio/index.tsx +201 -0
  204. package/lib/esm/RangeSlider/index.scss +184 -0
  205. package/lib/esm/RangeSlider/index.tsx +223 -0
  206. package/lib/esm/ScrollReveal/index.scss +27 -0
  207. package/lib/esm/ScrollReveal/index.tsx +146 -0
  208. package/lib/esm/Scrollbar/index.scss +217 -0
  209. package/lib/esm/Scrollbar/index.tsx +497 -0
  210. package/lib/esm/Scrollbar/utils/performance.js +52 -0
  211. package/lib/esm/SearchBar/index.tsx +181 -0
  212. package/lib/esm/Select/index.tsx +276 -0
  213. package/lib/esm/ShowMoreLess/index.scss +27 -0
  214. package/lib/esm/ShowMoreLess/index.tsx +144 -0
  215. package/lib/esm/Switch/index.tsx +143 -0
  216. package/lib/esm/Table/TableColgroup.tsx +29 -0
  217. package/lib/esm/Table/TableField.tsx +40 -0
  218. package/lib/esm/Table/TableFieldRow.tsx +212 -0
  219. package/lib/esm/Table/TableHeaders.tsx +146 -0
  220. package/lib/esm/Table/TableRow.tsx +127 -0
  221. package/lib/esm/Table/TableSummaries.tsx +36 -0
  222. package/lib/esm/Table/index.scss +364 -0
  223. package/lib/esm/Table/index.tsx +576 -0
  224. package/lib/esm/Table/table-utils.ts +65 -0
  225. package/lib/esm/Table/utils/dom.js +81 -0
  226. package/lib/esm/Table/utils/performance.js +52 -0
  227. package/lib/esm/Tabs/TabList.tsx +42 -0
  228. package/lib/esm/Tabs/TabPanel.tsx +34 -0
  229. package/lib/esm/Tabs/Tabs.tsx +232 -0
  230. package/lib/esm/Tabs/index.tsx +3 -0
  231. package/lib/esm/TagInput/index.scss +125 -0
  232. package/lib/esm/TagInput/index.tsx +314 -0
  233. package/lib/esm/Textarea/index.tsx +178 -0
  234. package/lib/esm/Toast/Item.tsx +75 -0
  235. package/lib/esm/Toast/index.scss +120 -0
  236. package/lib/esm/Toast/index.tsx +249 -0
  237. package/lib/esm/Tooltip/index.scss +327 -0
  238. package/lib/esm/Tooltip/index.tsx +142 -0
  239. package/lib/esm/Tree/TreeList.tsx +503 -0
  240. package/lib/esm/Tree/index.scss +375 -0
  241. package/lib/esm/Tree/index.tsx +301 -0
  242. package/lib/esm/Tree/init-height.tsx +27 -0
  243. package/lib/esm/Tree/utils/convert-tree.js +29 -0
  244. package/lib/esm/Tree/utils/dom.js +81 -0
  245. package/lib/esm/index.js +31 -0
  246. package/package.json +40 -0
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Dom Utilities
3
+ * @param {HTMLElement} el - Element
4
+ * @param {?String} filter - A filter string
5
+ * @returns HtmlElementCollection
6
+ */
7
+ function matches(el, filter) {
8
+ if (el && el.nodeType === 1) {
9
+ if (filter) {
10
+ return el.matches(filter);
11
+ }
12
+ return true;
13
+ }
14
+ return false;
15
+ }
16
+
17
+ // the next siblings
18
+ function getNextSiblings(el, filter = false || '') {
19
+ const sibs = [];
20
+ while (el = el.nextSibling) {
21
+ if (matches(el, filter)) {
22
+ sibs.push(el);
23
+ }
24
+ }
25
+ return sibs;
26
+ }
27
+
28
+ // previous siblings
29
+ function getPreviousSiblings(el, filter = false || '') {
30
+ const sibs = [];
31
+ while (el = el.previousSibling) {
32
+ if (matches(el, filter)) {
33
+ sibs.push(el);
34
+ }
35
+ }
36
+ return sibs;
37
+ }
38
+
39
+ // parent and get all the siblings
40
+ function getAllSiblings(el, filter = false || '') {
41
+ const sibs = [];
42
+ el = el.parentNode.firstChild;
43
+ while (el = el.nextSibling) {
44
+ if (matches(el, filter)) {
45
+ sibs.push(el);
46
+ }
47
+ }
48
+ return sibs;
49
+ }
50
+
51
+ // all parent nodes
52
+ function getParents(el, filter = false || '') {
53
+ const parents = [];
54
+ while (el = el.parentNode) {
55
+ if (matches(el, filter)) {
56
+ parents.push(el);
57
+ }
58
+ }
59
+ return parents;
60
+ }
61
+
62
+ // all child nodes
63
+ function getChildren(el, filter = false || '', all = []) {
64
+ all.push(...el.childNodes);
65
+ for (const child of el.childNodes) {
66
+ getChildren(child, filter, all);
67
+ }
68
+
69
+ const res = all.filter( item => matches(item, filter) );
70
+ return res;
71
+ }
72
+
73
+
74
+ module.exports = {
75
+ getNextSiblings,
76
+ getPreviousSiblings,
77
+ getAllSiblings,
78
+ getParents,
79
+ getChildren
80
+ }
81
+
@@ -0,0 +1,52 @@
1
+
2
+ /*
3
+ * Debounce
4
+ *
5
+ * @param {Function} fn - A function to be executed within the time limit.
6
+ * @param {Number} limit - Waiting time.
7
+ * @return {Function} - Returns a new function.
8
+ */
9
+ function debounce( fn, limit = 300 ) {
10
+ let timer;
11
+ return function() {
12
+
13
+ //Every time this returned function is called, the timer is cleared to ensure that fn is not executed
14
+ clearTimeout(timer);
15
+
16
+ // When the returned function is called for the last time (that is the user stops a continuous operation)
17
+ // Execute fn after another delay milliseconds
18
+ timer = setTimeout(function() {
19
+ fn.apply(this, arguments);
20
+ }, limit);
21
+ }
22
+ }
23
+
24
+
25
+
26
+
27
+
28
+ /*
29
+ * Throttle
30
+ *
31
+ * @param {Function} fn - A function to be executed within the time limit.
32
+ * @param {Number} limit - Waiting time.
33
+ * @return {Function} - Returns a new function.
34
+ */
35
+ function throttle( fn, limit = 300 ) {
36
+ let waiting = false;
37
+ return function () {
38
+ if (!waiting) {
39
+ fn.apply(this, arguments);
40
+ waiting = true;
41
+ setTimeout(function () {
42
+ waiting = false;
43
+ }, limit);
44
+ }
45
+ }
46
+ }
47
+
48
+
49
+ module.exports = {
50
+ debounce,
51
+ throttle
52
+ }
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+
3
+ interface TabListProps extends React.ComponentPropsWithoutRef<any> {
4
+ defaultActive?: string | boolean | undefined;
5
+ expandedActiveClassNameForNav?: string;
6
+ targetId?: string;
7
+ index?: number;
8
+ /** Handling events for collapsing item */
9
+ switchEv?: React.MouseEventHandler<HTMLElement>;
10
+ /** -- */
11
+ children: React.ReactNode;
12
+ };
13
+
14
+
15
+ const TabList = (props: TabListProps) => {
16
+
17
+ const {
18
+ defaultActive,
19
+ expandedActiveClassNameForNav,
20
+ targetId,
21
+ index,
22
+ switchEv,
23
+ children
24
+ } = props;
25
+
26
+
27
+ const _expandClassName = typeof(expandedActiveClassNameForNav) !== 'undefined' ? expandedActiveClassNameForNav : '';
28
+ const activedClassName = typeof(defaultActive) !== 'undefined' && defaultActive !== false ? ` active ${_expandClassName}` : ` ${_expandClassName}`;
29
+
30
+ return (
31
+ <>
32
+
33
+ <li className={`nav-item ${activedClassName}`} role="presentation" onClick={switchEv} data-tab={targetId}>
34
+ {children}
35
+ </li>
36
+
37
+ </>
38
+ )
39
+ }
40
+
41
+
42
+ export default TabList;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+
3
+
4
+ interface TabPanelProps extends React.ComponentPropsWithoutRef<"div"> {
5
+ defaultActive?: string | boolean | undefined;
6
+ expandedActiveClassNameForPanel?: string;
7
+ tabpanelClass?: string;
8
+ targetId?: string;
9
+ };
10
+
11
+ const TabPanel = (props: TabPanelProps) => {
12
+
13
+ const {
14
+ defaultActive,
15
+ expandedActiveClassNameForPanel,
16
+ tabpanelClass,
17
+ targetId,
18
+ ...attributes
19
+ } = props;
20
+
21
+ const _expandClassName = typeof(expandedActiveClassNameForPanel) !== 'undefined' ? expandedActiveClassNameForPanel : '';
22
+ const activedClassName = typeof(defaultActive) !== 'undefined' && defaultActive !== false ? ` show active ${_expandClassName}` : ` ${_expandClassName}`;
23
+
24
+
25
+ return (
26
+ <>
27
+
28
+ <div role="tabpanel" id={targetId} className={ tabpanelClass ? `tab-pane fade ${tabpanelClass} ${activedClassName}` : `tab-pane fade ${activedClassName}`} {...attributes}></div>
29
+
30
+ </>
31
+ )
32
+ }
33
+
34
+ export default TabPanel;
@@ -0,0 +1,232 @@
1
+ import React, { useId, useEffect, useRef } from 'react';
2
+
3
+
4
+ //
5
+ import TabList from './TabList';
6
+ import TabPanel from './TabPanel';
7
+
8
+
9
+ type TabsProps = {
10
+ wrapperClassName?: string;
11
+ navClassName?: string;
12
+ panelClassName?: string;
13
+ expandedActiveClassNameForNav?: string;
14
+ expandedActiveClassNameForPanel?: string;
15
+ animTransitionDuration?: number;
16
+ /** -- */
17
+ style?: React.CSSProperties;
18
+ onChange?: (nav: any, targetId: any, index: number) => void;
19
+ children: React.ReactNode | React.ReactNode[];
20
+ };
21
+
22
+ const Tabs = (props: TabsProps) => {
23
+
24
+ const {
25
+ wrapperClassName,
26
+ navClassName,
27
+ panelClassName,
28
+ expandedActiveClassNameForNav,
29
+ expandedActiveClassNameForPanel,
30
+ animTransitionDuration,
31
+ style,
32
+ onChange,
33
+ children // the contents of the TabList and TabPanel in a loop
34
+ } = props;
35
+
36
+ const uniqueID = useId().replace(/\:/g, "-");
37
+ const rootRef = useRef<any>(null);
38
+ const speed = animTransitionDuration ? animTransitionDuration : 150;
39
+
40
+
41
+ function handleClickItem(e: any) {
42
+ e.preventDefault();
43
+
44
+ const el = e.currentTarget;
45
+ const currentIndex = Array.prototype.slice.call(el.parentElement.children).indexOf(el);
46
+
47
+ itemInit(el, false);
48
+
49
+ //
50
+ if (typeof (onChange) === 'function') {
51
+ onChange(el, el.dataset.tab, currentIndex);
52
+
53
+ }
54
+ }
55
+
56
+
57
+ function itemInit(targetEl: any, itemsInit: boolean) {
58
+
59
+ const reactDomWrapperEl: any = rootRef.current;
60
+ const $li = targetEl.parentElement.children;
61
+ let $allContent: HTMLElement[] = [];
62
+ const tabID = targetEl.dataset.tab;
63
+ const _classNameNav = expandedActiveClassNameForNav ? expandedActiveClassNameForNav : '';
64
+ const _classNamePanel = expandedActiveClassNameForPanel ? expandedActiveClassNameForPanel : '';
65
+
66
+
67
+ const runExClassName = (node: HTMLElement, str: string, type: string) => {
68
+ if (str && node !== null) {
69
+ const _c = str.replace(/\s+(\W)/g, ' ').split(' ');
70
+ _c.forEach( (classname: any) => {
71
+ if ( type === 'remove' ) node.classList.remove(classname);
72
+ if ( type === 'add' ) node.classList.add(classname);
73
+
74
+ });
75
+ }
76
+ };
77
+
78
+ //get all panels of this wrapper
79
+ Array.prototype.forEach.call($li, (node) => {
80
+ const panelId = node.dataset.tab;
81
+ $allContent.push(reactDomWrapperEl.querySelector('#' + panelId) as never);
82
+ });
83
+
84
+
85
+ //
86
+ Array.prototype.forEach.call($li, (node) => {
87
+ node.classList.remove('active');
88
+ node.firstChild.classList.remove('active');
89
+
90
+ runExClassName(node, _classNameNav, 'remove');
91
+ runExClassName(node.firstChild, _classNameNav, 'remove');
92
+ });
93
+
94
+
95
+
96
+ $allContent.forEach( (node) => {
97
+ node.classList.remove('show');
98
+ setTimeout(() => {
99
+ node.classList.remove('active');
100
+ runExClassName(node, _classNamePanel, 'remove');
101
+ }, speed);
102
+ });
103
+
104
+ // currently active
105
+ targetEl.classList.add('active');
106
+ targetEl.firstChild.classList.add('active');
107
+
108
+ runExClassName(targetEl, _classNameNav, 'add');
109
+ runExClassName(targetEl.firstChild, _classNameNav, 'add');
110
+
111
+ if (tabID !== undefined) {
112
+ setTimeout(() => {
113
+ const _panel = document.getElementById(tabID) as HTMLElement;
114
+ if ( _panel !== null ) {
115
+ _panel.classList.add('active', 'show');
116
+ runExClassName(_panel, _classNamePanel, 'add');
117
+ }
118
+ }, speed);
119
+ }
120
+
121
+ }
122
+
123
+
124
+ useEffect(() => {
125
+
126
+ // Initialize tabs
127
+ //--------------
128
+ const reactDomWrapperEl: any = rootRef.current;
129
+ const $li = [].slice.call(reactDomWrapperEl.querySelectorAll('ul > li'));
130
+ $li.forEach((el: any, i: number) => {
131
+ if (el.classList.contains('active')) {
132
+ itemInit($li[i], true);
133
+ }
134
+ });
135
+
136
+ }, []);
137
+
138
+
139
+
140
+
141
+ return (
142
+ <>
143
+
144
+ <div className={wrapperClassName || wrapperClassName === '' ? wrapperClassName : "mb-3 position-relative"} ref={rootRef} style={style}>
145
+ <ul className={navClassName ? navClassName : "nav nav-tabs mb-3"} role="tablist">
146
+
147
+ {(() => {
148
+ if (children != null) {
149
+ let tabListIndex = 0;
150
+
151
+ // If <TabList /> uses map to return, it will be wrapped into an array
152
+ /*
153
+ Such as:
154
+
155
+ {[1,2,3].map((item: any, i: number) =>{
156
+ return <TabList key={`tab-list-${i}`} defaultActive={i === 0 ? true : false}>{item}</TabList>
157
+ })}
158
+ */
159
+
160
+ const elements: React.ReactNode | React.ReactNode[] = Array.isArray((children as any[])[0]) ? (children as any[])[0] : children;
161
+
162
+ return (elements as any[]).map((item, i) => {
163
+ const childProps = { ...item.props };
164
+ delete childProps.key;
165
+
166
+ if (item.key.indexOf('tab-list') >= 0) {
167
+ tabListIndex++;
168
+ return <TabList
169
+ key={item.key}
170
+ index={tabListIndex}
171
+ expandedActiveClassNameForNav={expandedActiveClassNameForNav}
172
+ switchEv={handleClickItem}
173
+ targetId={`tabs-show-${uniqueID}-${tabListIndex}`}
174
+ {...childProps} />;
175
+ }
176
+
177
+
178
+ });
179
+ }
180
+ })()}
181
+
182
+
183
+ </ul>
184
+
185
+ <div className={panelClassName ? panelClassName : "tab-content"}>
186
+ {(() => {
187
+ if (children != null) {
188
+ let tabPanelIndex = 0;
189
+
190
+ // If <TabPanel /> uses map to return, it will be wrapped into an array
191
+ /*
192
+ Such as:
193
+
194
+ {[1,2,3].map((item: any, i: number) =>{
195
+ return <TabPanel key={`tab-panel-${i}`} tabpanelClass="fs-6" defaultActive={i === 0 ? true : false}>{item}</TabPanel>
196
+ })}
197
+ */
198
+ const elements: React.ReactNode | React.ReactNode[] = Array.isArray((children as any[])[1]) ? (children as any[])[1] : children;
199
+
200
+ return (elements as any[]).map((item, i) => {
201
+ const childProps = { ...item.props };
202
+ delete childProps.key;
203
+
204
+ if (item.key.indexOf('tab-panel') >= 0) {
205
+ tabPanelIndex++;
206
+ return <TabPanel
207
+ key={item.key}
208
+ expandedActiveClassNameForPanel={expandedActiveClassNameForPanel}
209
+ targetId={`tabs-show-${uniqueID}-${tabPanelIndex}`}
210
+ {...childProps} />;
211
+ }
212
+
213
+
214
+
215
+ });
216
+ }
217
+ })()}
218
+ </div>
219
+
220
+
221
+ </div>
222
+
223
+
224
+ </>
225
+ )
226
+
227
+ }
228
+
229
+
230
+
231
+
232
+ export default Tabs;
@@ -0,0 +1,3 @@
1
+ export { default as Tabs } from './Tabs';
2
+ export { default as TabList } from './TabList';
3
+ export { default as TabPanel } from './TabPanel';
@@ -0,0 +1,125 @@
1
+ /* ======================================================
2
+ <!-- Tag Input -->
3
+ /* ====================================================== */
4
+
5
+ .tag-input__wrapper {
6
+
7
+ --tag-input-control-border-radius: 0.375rem;
8
+ --tag-input-control-wrapper-bg: #fff;
9
+ --tag-input-control-wrapper-border-color: #dee2e6;
10
+ --tag-input-control-color: #adb5bd;
11
+ --tag-input-list-bg: #efefef;
12
+ --tag-input-removebtn-fill: #000;
13
+ --tag-input-removebtn-hover-fill: #f00;
14
+ --tag-input-focus-border-color:#86b7fe;
15
+ --tag-input-focus-box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25);
16
+
17
+
18
+ display: flex;
19
+
20
+
21
+ ul,
22
+ li {
23
+ padding: 0;
24
+ margin: 0;
25
+ list-style: none;
26
+ }
27
+
28
+
29
+ .tag-input__control-wrapper {
30
+ display: flex;
31
+
32
+ > div {
33
+ position: relative;
34
+ align-items: center;
35
+ display: flex;
36
+ flex-wrap: wrap;
37
+
38
+ /* bootstrap style that match ".form-control" */
39
+ padding: 0.375rem;
40
+ background-color: var(--tag-input-control-wrapper-bg);
41
+ background-clip: padding-box;
42
+ border: 1px solid var(--tag-input-control-wrapper-border-color);
43
+ appearance: none;
44
+ border-radius: var(--tag-input-control-border-radius);
45
+ transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
46
+ padding-bottom: 1px;
47
+
48
+
49
+ .tag-input__control {
50
+ margin-bottom: 0.375rem;
51
+
52
+ input {
53
+ background: transparent;
54
+ border: none;
55
+ outline: none;
56
+ padding: 0;
57
+ margin: 0;
58
+ margin-left: .5rem;
59
+
60
+ /* bootstrap style that match ".form-control" */
61
+ font-size: 0.875rem;
62
+ font-weight: 400;
63
+ line-height: 1.5;
64
+ color: var(--tag-input-control-color);
65
+
66
+ &:focus {
67
+ outline: none;
68
+ box-shadow: none;
69
+ }
70
+ }
71
+
72
+ }
73
+
74
+ }
75
+
76
+ }
77
+
78
+
79
+ ul.tag-input__list {
80
+ li {
81
+ display: inline-block;
82
+ margin: 5px;
83
+ margin-bottom: 0;
84
+ padding: .1rem 1.5rem .1rem 1rem;
85
+ font-size: 0.875rem;
86
+ background: var(--tag-input-list-bg);
87
+ border-radius: 30px;
88
+ overflow: hidden;
89
+ text-overflow: ellipsis;
90
+ position: relative;
91
+
92
+ > a {
93
+ font-weight: 400;
94
+ opacity: .6;
95
+ font-size: 18px;
96
+ line-height: 20px;
97
+ position: absolute;
98
+ right: 8px;
99
+ top: 0;
100
+
101
+ path {
102
+ fill: var(--tag-input-removebtn-fill);
103
+ }
104
+
105
+ &:hover {
106
+ path {
107
+ fill: var(--tag-input-removebtn-hover-fill);
108
+ }
109
+ }
110
+ }
111
+
112
+ }
113
+
114
+ }
115
+
116
+ &.focus {
117
+ .tag-input__control-wrapper {
118
+ > div {
119
+ box-shadow: var(--tag-input-focus-box-shadow);
120
+ border-color: var(--tag-input-focus-border-color);
121
+ }
122
+ }
123
+ }
124
+
125
+ }