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,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,160 @@
1
+ import React, { useId, useState, useEffect, useRef, forwardRef } from 'react';
2
+
3
+ declare module 'react' {
4
+ interface ReactI18NextChildren<T> {
5
+ children?: any;
6
+ }
7
+ }
8
+
9
+ type CheckboxOptionChangeFnType = (arg1: any, arg2: any) => void;
10
+
11
+
12
+ type CheckboxProps = {
13
+ wrapperClassName?: string;
14
+ value: string | boolean;
15
+ label?: React.ReactNode | string;
16
+ name?: string;
17
+ disabled?: any;
18
+ required?: any;
19
+ checked?: boolean;
20
+ indeterminate?: boolean;
21
+ /** -- */
22
+ id?: string;
23
+ style?: React.CSSProperties;
24
+ tabIndex?: number;
25
+ [key: `data-${string}`]: string | undefined;
26
+ /** This function is called whenever the data is updated.
27
+ * Exposes the JSON format data about the option as an argument.
28
+ */
29
+ onChange?: CheckboxOptionChangeFnType | null;
30
+ onBlur?: (e: any) => void;
31
+ onFocus?: (e: any) => void;
32
+ };
33
+
34
+ const Checkbox = forwardRef((props: CheckboxProps, ref: any) => {
35
+ const {
36
+ wrapperClassName,
37
+ disabled,
38
+ required,
39
+ value,
40
+ label,
41
+ name,
42
+ id,
43
+ checked,
44
+ indeterminate,
45
+ style,
46
+ tabIndex,
47
+ onChange,
48
+ onBlur,
49
+ onFocus,
50
+ ...attributes
51
+ } = props;
52
+
53
+ const uniqueID = useId();
54
+ const idRes = id || uniqueID;
55
+ const rootRef = useRef<any>(null);
56
+ const valRef = useRef<any>(null);
57
+ const [val, setVal] = useState<any>(null);
58
+
59
+ function handleFocus(event: any) {
60
+ rootRef.current.classList.add('focus');
61
+
62
+ //
63
+ onFocus?.(event);
64
+ }
65
+
66
+
67
+ function handleChange(event: any) {
68
+ const _val = event.target.checked;
69
+
70
+ setVal(_val);
71
+
72
+ //----
73
+ //remove focus style
74
+ rootRef.current.classList.remove('focus');
75
+
76
+ //
77
+ if (typeof (onChange) === 'function') {
78
+ onChange(event, _val);
79
+ }
80
+
81
+
82
+
83
+ }
84
+
85
+
86
+ function handleBlur(event: any) {
87
+
88
+ //----
89
+ //remove focus style
90
+ rootRef.current.classList.remove('focus');
91
+
92
+ //
93
+ onBlur?.(event);
94
+ }
95
+
96
+
97
+ useEffect(() => {
98
+
99
+ // default value
100
+ setVal(checked);
101
+
102
+ // Set a checkbox to indeterminate state
103
+ if ( typeof indeterminate !== 'undefined' ) {
104
+ valRef.current.indeterminate = indeterminate;
105
+ }
106
+
107
+ }, [checked, indeterminate]);
108
+
109
+
110
+ return (
111
+ <>
112
+
113
+ <div className={wrapperClassName || wrapperClassName === '' ? wrapperClassName : "mb-3 position-relative"} ref={rootRef}>
114
+ <div className="form-check">
115
+ <input
116
+ ref={(node) => {
117
+ valRef.current = node;
118
+ if (typeof ref === 'function') {
119
+ ref(node);
120
+ } else if (ref) {
121
+ ref.current = node;
122
+ }
123
+ }}
124
+ tabIndex={tabIndex || 0}
125
+ type="checkbox"
126
+ className="form-check-input"
127
+ id={`label-${idRes}`}
128
+
129
+ // Don't use "name", it's just a container to display the label
130
+ data-name={name?.match(/(\[.*?\])/gi) ? `${name.split('[')[0]}-label[]` : `${name}-label`}
131
+ data-checkbox
132
+ disabled={disabled || null}
133
+ required={required || null}
134
+ onChange={handleChange}
135
+ onFocus={handleFocus}
136
+ onBlur={handleBlur}
137
+ defaultValue={value as string || ''}
138
+ checked={val} // component status will not change if defaultChecked is used
139
+ style={{cursor: 'pointer', ...style}}
140
+ {...attributes}
141
+ />
142
+
143
+
144
+ <input
145
+ type="hidden"
146
+ id={idRes}
147
+ name={name}
148
+ value={val ? value as string || '' : ''} // do not use `defaultValue`
149
+ />
150
+
151
+ {label ? <><label htmlFor={`label-${idRes}`} className="form-check-label">{label}</label></> : null}
152
+ </div>
153
+ </div>
154
+
155
+
156
+ </>
157
+ )
158
+ });
159
+
160
+ export default Checkbox;
@@ -0,0 +1,48 @@
1
+ /* ======================================================
2
+ <!-- Color Picker -->
3
+ /* ====================================================== */
4
+
5
+ .custom-form-control-color {
6
+
7
+ --color-control-border-radius: 0.375rem;
8
+ --color-control-size: 30px;
9
+ --color-control-border-color: rgba(0,0,0,.1);
10
+
11
+
12
+ -webkit-appearance: none;
13
+ -moz-appearance: none;
14
+ appearance: none;
15
+ background-color: transparent;
16
+ padding: 0 !important;
17
+ width: var(--color-control-size) !important;
18
+ height: var(--color-control-size) !important;
19
+ border: none;
20
+ cursor: pointer;
21
+
22
+ &::-webkit-color-swatch {
23
+ border: 2px solid var(--color-control-border-color);
24
+ }
25
+ &::-moz-color-swatch {
26
+ border: 2px solid var(--color-control-border-color);
27
+ }
28
+
29
+ &:disabled {
30
+ cursor: not-allowed;
31
+ }
32
+
33
+ &.custom-form-control-color--rounded::-webkit-color-swatch {
34
+ border-radius: var(--color-control-border-radius);
35
+ }
36
+ &.custom-form-control-color--rounded::-moz-color-swatch {
37
+ border-radius: var(--color-control-border-radius);
38
+ }
39
+
40
+
41
+ &.custom-form-control-color--circle::-webkit-color-swatch {
42
+ border-radius: 50%;
43
+ }
44
+ &.custom-form-control-color--circle::-moz-color-swatch {
45
+ border-radius: 50%;
46
+ }
47
+
48
+ }
@@ -0,0 +1,187 @@
1
+ import React, { useId, useState, useEffect, useRef, forwardRef, ChangeEvent } from 'react';
2
+
3
+ declare module 'react' {
4
+ interface ReactI18NextChildren<T> {
5
+ children?: any;
6
+ }
7
+ }
8
+
9
+ interface ColorPickerProps extends React.ComponentPropsWithoutRef<"input"> {
10
+ wrapperClassName?: string;
11
+ controlClassName?: string;
12
+ value?: string;
13
+ label?: React.ReactNode | string;
14
+ name?: string;
15
+ disabled?: any;
16
+ required?: any;
17
+ readOnly?: any;
18
+ shape?: string;
19
+ /** -- */
20
+ id?: string;
21
+ style?: React.CSSProperties;
22
+ tabIndex?: number;
23
+ [key: `data-${string}`]: string | undefined;
24
+ onChange?: (e: any) => void;
25
+ onBlur?: (e: any) => void;
26
+ onFocus?: (e: any) => void;
27
+
28
+ };
29
+
30
+
31
+ const ColorPicker = forwardRef((props: ColorPickerProps, ref: any) => {
32
+ const {
33
+ wrapperClassName,
34
+ controlClassName,
35
+ disabled,
36
+ required,
37
+ readOnly,
38
+ value,
39
+ label,
40
+ name,
41
+ shape,
42
+ id,
43
+ style,
44
+ tabIndex,
45
+ onChange,
46
+ onBlur,
47
+ onFocus,
48
+ ...attributes
49
+ } = props;
50
+
51
+
52
+ const uniqueID = useId();
53
+ const idRes = id || uniqueID;
54
+ const rootRef = useRef<any>(null);
55
+ const valRef = useRef<any>(null);
56
+ const [changedVal, setChangedVal] = useState<string>(value || '');
57
+ let shapeClassName = '';
58
+
59
+ if (shape && typeof shape === 'string') {
60
+ switch (shape) {
61
+ case 'rounded':
62
+ shapeClassName = 'custom-form-control-color--rounded';
63
+ break;
64
+ case 'circle':
65
+ shapeClassName = 'custom-form-control-color--circle';
66
+ break;
67
+ }
68
+ }
69
+
70
+
71
+
72
+ function handleFocus(event: ChangeEvent<HTMLInputElement>) {
73
+ rootRef.current.classList.add('focus');
74
+
75
+ //
76
+ onFocus?.(event);
77
+ }
78
+
79
+ function handleChange(event: ChangeEvent<HTMLInputElement>) {
80
+ const val = event.target.value;
81
+
82
+ setChangedVal(val);
83
+
84
+
85
+ //----
86
+ //remove focus style
87
+ if (val === '') {
88
+ rootRef.current.classList.remove('focus');
89
+ }
90
+
91
+ //
92
+ onChange?.(event);
93
+
94
+ }
95
+
96
+ function handleBlur(event: ChangeEvent<HTMLInputElement>) {
97
+ const el = event.target;
98
+ const val = event.target.value;
99
+
100
+
101
+ //----
102
+ //remove focus style
103
+ if (val === '') {
104
+ rootRef.current.classList.remove('focus');
105
+ }
106
+
107
+ //
108
+ onBlur?.(event);
109
+ }
110
+
111
+
112
+ useEffect(() => {
113
+
114
+ // update default value
115
+ //--------------
116
+ setChangedVal(value || '');
117
+
118
+ // If you use the dynamic form assignment (such as document.getElementById(xxx).value),
119
+ // you need to judge the value of the input obtained by using the macrotask "setInterval()"
120
+ let timer: any = null;
121
+ let initTimes: number = 0;
122
+ let hasValue: boolean = false;
123
+ timer = setInterval( () => {
124
+ if ( initTimes > 5 || hasValue ) {
125
+ clearInterval(timer);
126
+ } else {
127
+ if ( valRef.current !== null && valRef.current.value !== '' && ( typeof value === 'undefined' || value === '' ) ) {
128
+ setChangedVal(valRef.current.value);
129
+ hasValue = true;
130
+ }
131
+ initTimes++;
132
+
133
+ }
134
+ }, 500);
135
+
136
+ return () => {
137
+ clearInterval(timer);
138
+ }
139
+
140
+ }, [value]);
141
+
142
+
143
+ return (
144
+ <>
145
+
146
+ <div className={wrapperClassName || wrapperClassName === '' ? wrapperClassName : "mb-3 position-relative"} ref={rootRef}>
147
+ {label ? <><label htmlFor={idRes} className="form-label">{label}</label></> : null}
148
+
149
+ <div className="input-group">
150
+ <input
151
+ ref={(node) => {
152
+ valRef.current = node;
153
+ if (typeof ref === 'function') {
154
+ ref(node);
155
+ } else if (ref) {
156
+ ref.current = node;
157
+ }
158
+ }}
159
+
160
+
161
+ tabIndex={tabIndex || 0}
162
+ type='color'
163
+ className={`${controlClassName || controlClassName === '' ? controlClassName : "form-control custom-form-control-color flex-grow-0"} ${shapeClassName}`}
164
+ id={idRes}
165
+ name={name}
166
+ value={changedVal}
167
+ onFocus={handleFocus}
168
+ onBlur={handleBlur}
169
+ onChange={handleChange}
170
+ disabled={disabled || null}
171
+ required={required || null}
172
+ readOnly={readOnly || null}
173
+ style={style}
174
+ {...attributes}
175
+ />
176
+
177
+ </div>
178
+ {required ? <><span className="position-absolute end-0 top-0 my-2 mx-2"><span className="text-danger">*</span></span></> : ''}
179
+
180
+ </div>
181
+
182
+
183
+ </>
184
+ )
185
+ });
186
+
187
+ export default ColorPicker;
@@ -0,0 +1,72 @@
1
+ import React, { useState } from 'react';
2
+
3
+ import useInterval from './utils/useInterval';
4
+
5
+ type DigitalClockProps = {
6
+ tmpl?: (date: any) => void;
7
+ militaryTime?: boolean;
8
+ };
9
+
10
+
11
+ const DigitalClock = (props: DigitalClockProps) => {
12
+ const {
13
+ tmpl,
14
+ militaryTime
15
+ } = props;
16
+
17
+ const [date, setDate] = useState<any>({
18
+ minutes: 'NULL',
19
+ seconds: 'NULL',
20
+ hours: 'NULL',
21
+ amPm: 'NULL'
22
+ });
23
+ const [clockAppearance, setClockAppearance] = useState<React.ReactNode>(null);
24
+
25
+ let time: Date = new Date();
26
+ let minutes: any = time.getMinutes();
27
+ let seconds: any = time.getSeconds();
28
+ let hours: any = time.getHours();
29
+ let amPm = time.getHours() > 12 ? "pm" : "am";
30
+
31
+ useInterval(() => {
32
+ time = new Date();
33
+ minutes = time.getMinutes();
34
+ seconds = time.getSeconds();
35
+ hours = time.getHours();
36
+
37
+ if ( militaryTime ) {
38
+ amPm = 'NULL';
39
+ } else {
40
+ minutes = minutes < 10 ? "0" + minutes : minutes;
41
+ seconds = seconds < 10 ? "0" + seconds : seconds;
42
+ hours = hours < 10 ? "0" + hours : hours;
43
+ hours = hours > 12 ? hours - 12 : hours;
44
+ hours = hours == 0 ? 12 : hours;
45
+ }
46
+
47
+
48
+ const curData = {
49
+ minutes: minutes,
50
+ seconds: seconds,
51
+ hours: hours,
52
+ amPm: amPm
53
+ };
54
+
55
+ setDate(curData);
56
+
57
+ //callback
58
+ const res: any = tmpl?.(curData);
59
+ setClockAppearance(res);
60
+ }, 1000);
61
+
62
+
63
+ return (
64
+ <>
65
+ {date ? <>{clockAppearance}</> : null}
66
+
67
+ </>
68
+ )
69
+ };
70
+
71
+
72
+ export default DigitalClock;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Provides a convenient way to create and manage intervals
3
+ *
4
+ * @usage:
5
+
6
+ const App = () => {
7
+ const [count, setCount] = useState(0);
8
+
9
+ useInterval(() => {
10
+ setCount(count + 1);
11
+ }, 1000);
12
+
13
+ return (
14
+ <div className="app"></div>
15
+ );
16
+ };
17
+
18
+ */
19
+ import { useEffect, useRef } from "react";
20
+
21
+ const useInterval = (fn, delay) => {
22
+ const ref = useRef(null);
23
+
24
+ useEffect(() => {
25
+ ref.current = fn;
26
+ }, [fn]);
27
+
28
+ useEffect(() => {
29
+ function tick() {
30
+ ref.current && ref.current();
31
+ }
32
+
33
+ if (delay !== null && delay > 0) {
34
+ let id = setInterval(tick, delay);
35
+ return () => clearInterval(id);
36
+ } else {
37
+ tick();
38
+ }
39
+ }, [delay]);
40
+ };
41
+
42
+ export default useInterval;
43
+
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+
3
+ interface OptionConfig {
4
+ value?: string | undefined;
5
+ label?: string | undefined;
6
+ }
7
+
8
+ type OptionProps = {
9
+ option?: OptionConfig;
10
+ hyperlinkClassName?: string;
11
+ onSelect?: (option: any) => void | undefined;
12
+ };
13
+
14
+ export default function Option(props: OptionProps) {
15
+
16
+ function handleSelect(e) {
17
+ e.preventDefault();
18
+
19
+ const fn: any = props.onSelect;
20
+ fn(props.option);
21
+ }
22
+
23
+ return (
24
+ <li><a className={props.hyperlinkClassName} data-value={props.option?.value} href="#" tabIndex={-1} onClick={handleSelect} dangerouslySetInnerHTML={{__html: `${props.option?.label}`}}></a></li>
25
+ );
26
+ }
27
+