funda-ui 4.6.111 → 4.6.151

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.
@@ -28,6 +28,8 @@ import {
28
28
  import { isNumeric } from 'funda-utils/dist/cjs/math';
29
29
  import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
30
30
 
31
+
32
+
31
33
  import Calendar from './Calendar';
32
34
 
33
35
 
@@ -196,6 +198,9 @@ const Date = forwardRef((props: DateProps, externalRef: any) => {
196
198
  return typeof s === 'undefined' || s === null || s === 'null' || s === '';
197
199
  };
198
200
 
201
+ const propExist = (p: any) => {
202
+ return typeof p !== 'undefined' && p !== null && p !== '';
203
+ };
199
204
 
200
205
 
201
206
 
@@ -901,7 +906,52 @@ const Date = forwardRef((props: DateProps, externalRef: any) => {
901
906
  return [_res, v]
902
907
 
903
908
  }
904
-
909
+
910
+ function tools() {
911
+ return <span className={combinedCls(
912
+ 'date2d__control-tools',
913
+ {
914
+ 'date2d__control-tools--hover-show-tools': SHOW_TOOLS_ENABLED
915
+ }
916
+
917
+ )}>
918
+
919
+ <a
920
+ tabIndex={-1}
921
+ href="#"
922
+ className={combinedCls(
923
+ 'date2d__control-tools__close',
924
+ {
925
+ 'd-none': HIDE_CLEAR_BTN_ENABLED || !dateDefaultValueExist
926
+ }
927
+ )} onClick={(e: React.MouseEvent) => {
928
+ e.preventDefault();
929
+ e.stopPropagation(); // Avoid triggering pop-ups
930
+
931
+ clearAll();
932
+ onClear?.(getFullTimeData(''));
933
+ }}
934
+ ><svg width="12px" height="12px" viewBox="0 0 1024 1024"><path fill="#000" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z" /></svg></a>
935
+
936
+ <a
937
+ tabIndex={-1}
938
+ href="#"
939
+ className="date2d__control-tools__trigger"
940
+ onClick={(e: React.MouseEvent) => {
941
+ e.preventDefault();
942
+ e.stopPropagation(); // Avoid triggering pop-ups
943
+
944
+ handleShow();
945
+ }}
946
+ >
947
+ <svg width="14px" height="14px" viewBox="0 0 24 24" fill="none">
948
+ <path d="M3 9H21M9 15L11 17L15 13M7 3V5M17 3V5M6.2 21H17.8C18.9201 21 19.4802 21 19.908 20.782C20.2843 20.5903 20.5903 20.2843 20.782 19.908C21 19.4802 21 18.9201 21 17.8V8.2C21 7.07989 21 6.51984 20.782 6.09202C20.5903 5.71569 20.2843 5.40973 19.908 5.21799C19.4802 5 18.9201 5 17.8 5H6.2C5.0799 5 4.51984 5 4.09202 5.21799C3.71569 5.40973 3.40973 5.71569 3.21799 6.09202C3 6.51984 3 7.07989 3 8.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
949
+ </svg>
950
+ </a>
951
+
952
+ </span>;
953
+ }
954
+
905
955
 
906
956
  useEffect(() => {
907
957
 
@@ -1309,54 +1359,21 @@ const Date = forwardRef((props: DateProps, externalRef: any) => {
1309
1359
  */}
1310
1360
 
1311
1361
  </div>
1362
+
1363
+
1364
+
1365
+ {/* TOOLS */}
1366
+ {propExist(iconRight) ? tools() : null}
1367
+ {/* /TOOLS */}
1368
+
1369
+
1312
1370
  </>}
1313
1371
  style={style}
1314
1372
  {...attributes}
1315
1373
  />
1316
1374
 
1317
1375
  {/* TOOLS */}
1318
- <span className={combinedCls(
1319
- 'date2d__control-tools',
1320
- {
1321
- 'date2d__control-tools--hover-show-tools': SHOW_TOOLS_ENABLED
1322
- }
1323
-
1324
- )}>
1325
-
1326
- <a
1327
- tabIndex={-1}
1328
- href="#"
1329
- className={combinedCls(
1330
- 'date2d__control-tools__close',
1331
- {
1332
- 'd-none': HIDE_CLEAR_BTN_ENABLED || !dateDefaultValueExist
1333
- }
1334
- )} onClick={(e: React.MouseEvent) => {
1335
- e.preventDefault();
1336
- e.stopPropagation(); // Avoid triggering pop-ups
1337
-
1338
- clearAll();
1339
- onClear?.(getFullTimeData(''));
1340
- }}
1341
- ><svg width="12px" height="12px" viewBox="0 0 1024 1024"><path fill="#000" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z" /></svg></a>
1342
-
1343
- <a
1344
- tabIndex={-1}
1345
- href="#"
1346
- className="date2d__control-tools__trigger"
1347
- onClick={(e: React.MouseEvent) => {
1348
- e.preventDefault();
1349
- e.stopPropagation(); // Avoid triggering pop-ups
1350
-
1351
- handleShow();
1352
- }}
1353
- >
1354
- <svg width="14px" height="14px" viewBox="0 0 24 24" fill="none">
1355
- <path d="M3 9H21M9 15L11 17L15 13M7 3V5M17 3V5M6.2 21H17.8C18.9201 21 19.4802 21 19.908 20.782C20.2843 20.5903 20.5903 20.2843 20.782 19.908C21 19.4802 21 18.9201 21 17.8V8.2C21 7.07989 21 6.51984 20.782 6.09202C20.5903 5.71569 20.2843 5.40973 19.908 5.21799C19.4802 5 18.9201 5 17.8 5H6.2C5.0799 5 4.51984 5 4.09202 5.21799C3.71569 5.40973 3.40973 5.71569 3.21799 6.09202C3 6.51984 3 7.07989 3 8.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
1356
- </svg>
1357
- </a>
1358
-
1359
- </span>
1376
+ {!propExist(iconRight) ? tools() : null}
1360
1377
  {/* /TOOLS */}
1361
1378
 
1362
1379
 
@@ -6,6 +6,7 @@ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
6
6
  import { actualPropertyValue, getTextTop } from 'funda-utils/dist/cjs/inputsCalculation';
7
7
  import useDebounce from 'funda-utils/dist/cjs/useDebounce';
8
8
 
9
+
9
10
  export type InputProps = {
10
11
  contentRef?: React.ForwardedRef<any>;
11
12
  wrapperClassName?: string;
@@ -50,7 +50,6 @@ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
50
50
 
51
51
 
52
52
 
53
-
54
53
  export type SelectOptionChangeFnType = (arg1: any, arg2: any, arg3: any) => void;
55
54
 
56
55
  export interface MultiSelectDataConfig {
@@ -68,9 +67,9 @@ export interface OptionConfig {
68
67
  disabled?: boolean;
69
68
  optgroup?: any[];
70
69
  group?: boolean;
71
- label: any;
72
- listItemLabel?: any;
73
- value: any;
70
+ label: string;
71
+ listItemLabel?: string;
72
+ value: string | number | boolean;
74
73
  queryString: string | number;
75
74
  callback?: () => void;
76
75
  }
@@ -109,7 +108,7 @@ export type SelectProps = {
109
108
  multiSelect?: MultiSelectConfig;
110
109
  multiSelectEntireAreaTrigger?: boolean;
111
110
  multiSelectSelectedItemOnlyStatus?: multiSelectSelectedItemOnlyStatusConfig;
112
- renderSelectedValue?: (selectedData: MultiSelectControlValConfig, removeFunc: (e: React.MouseEvent) => void) => void;
111
+ renderSelectedValue?: (selectedData: MultiSelectControlValConfig, removeFunc: (e: React.MouseEvent) => void) => React.ReactNode;
113
112
  cleanTrigger?: CleanTriggerConfig;
114
113
  defaultValue?: string | OptionConfig;
115
114
  value?: string | OptionConfig;
@@ -13,6 +13,12 @@ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
13
13
 
14
14
 
15
15
 
16
+ export interface TagValConfig {
17
+ content: string;
18
+ id: number;
19
+ [key: string]: string | boolean | number; // Allows dynamic attributes
20
+ }
21
+
16
22
  export type TagInputProps = {
17
23
  contentRef?: React.ForwardedRef<any>;
18
24
  wrapperClassName?: string;
@@ -27,6 +33,7 @@ export type TagInputProps = {
27
33
  required?: any;
28
34
  readOnly?: any;
29
35
  placeholder?: string;
36
+ renderSelectedValue?: (selectedData: TagValConfig[], removeFunc: (e: React.MouseEvent) => void) => React.ReactNode;
30
37
  /** Whether to use square brackets to save result and initialize default value */
31
38
  extractValueByBrackets?: boolean;
32
39
  /** -- */
@@ -52,6 +59,7 @@ const TagInput = forwardRef((props: TagInputProps, externalRef: any) => {
52
59
  disabled,
53
60
  required,
54
61
  placeholder,
62
+ renderSelectedValue,
55
63
  readOnly,
56
64
  value,
57
65
  requiredLabel,
@@ -82,7 +90,7 @@ const TagInput = forwardRef((props: TagInputProps, externalRef: any) => {
82
90
  const max = maxTags ? maxTags : 10;
83
91
  const [lastId, setLastId] = useState<number>(-1);
84
92
  const [userInput, setUserInput] = useState<string>('');
85
- const [items, setItems] = useState<any[]>([]);
93
+ const [items, setItems] = useState<TagValConfig[]>([]);
86
94
  const [alreadyInItems, setAlreadyInItems] = useState<boolean>(false);
87
95
  const [onComposition, setOnComposition] = useState<boolean>(false);
88
96
 
@@ -115,7 +123,7 @@ const TagInput = forwardRef((props: TagInputProps, externalRef: any) => {
115
123
  } else {
116
124
  const _val = VALUE_BY_BRACKETS ? extractContentsOfBrackets(defaultValue) : defaultValue.trim().replace(/^\,|\,$/g, '').split(',');
117
125
  if (Array.isArray(_val)) {
118
- setItems(_val.map((item: any, index: number) => {
126
+ setItems(_val.map((item: string, index: number) => {
119
127
  return {
120
128
  content: item,
121
129
  id: index
@@ -129,13 +137,15 @@ const TagInput = forwardRef((props: TagInputProps, externalRef: any) => {
129
137
  }
130
138
 
131
139
 
132
- function handleRemove(e: MouseEvent<HTMLAnchorElement>) {
140
+ function handleRemove(e: any) {
133
141
  e.preventDefault();
142
+ e.stopPropagation(); /* REQUIRED */
134
143
 
135
144
  const idToRemove = Number(e.currentTarget.dataset.item);
136
145
  const newArray = items!.filter((item: any) => item.id !== idToRemove);
137
146
  setItems(newArray);
138
147
 
148
+
139
149
  //
140
150
  onChange?.(inputRef.current, newArray, VALUE_BY_BRACKETS ? convertArrToValByBrackets(newArray.map(v => v.content)) : newArray.map(v => v.content).join(','));
141
151
  }
@@ -270,13 +280,23 @@ const TagInput = forwardRef((props: TagInputProps, externalRef: any) => {
270
280
  <div className="tag-input__control-wrapper">
271
281
  <div>
272
282
  <ul className="tag-input__list">
273
- {items ? items.map((item: any, index: number) => (
274
- <li key={index}>
275
- {item.content}
276
-
277
- <a href="#" tabIndex={-1} onClick={handleRemove} data-item={item.id}><svg width="10px" height="10px" viewBox="0 0 1024 1024"><path fill="#000" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"/></svg></a>
278
- </li>
279
- )) : null}
283
+
284
+ {/* ITEMS LIST */}
285
+ {typeof renderSelectedValue === 'function' ? <>
286
+ {renderSelectedValue(items, handleRemove)}
287
+ </> : <>
288
+ {items ? items.map((item: any, index: number) => (
289
+ <li key={index}>
290
+ {item.content}
291
+
292
+ <a href="#" tabIndex={-1} onClick={handleRemove} data-item={item.id}><svg width="10px" height="10px" viewBox="0 0 1024 1024"><path fill="#000" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"/></svg></a>
293
+ </li>
294
+ )) : null}
295
+ </>}
296
+
297
+
298
+
299
+
280
300
  </ul>
281
301
 
282
302
 
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.6.111",
5
+ "version": "4.6.151",
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",