funda-ui 1.0.607 → 1.1.12
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/Accordion/index.js +82 -75
- package/CascadingSelect/index.d.ts +2 -0
- package/CascadingSelect/index.js +132 -4
- package/CascadingSelectE2E/index.d.ts +2 -0
- package/CascadingSelectE2E/index.js +142 -7
- package/MultipleCheckboxes/index.d.ts +3 -1
- package/MultipleCheckboxes/index.js +131 -4
- package/Select/index.js +2 -2
- package/TagInput/index.d.ts +3 -1
- package/TagInput/index.js +145 -7
- package/lib/cjs/Accordion/index.js +82 -75
- package/lib/cjs/CascadingSelect/index.d.ts +2 -0
- package/lib/cjs/CascadingSelect/index.js +132 -4
- package/lib/cjs/CascadingSelectE2E/index.d.ts +2 -0
- package/lib/cjs/CascadingSelectE2E/index.js +142 -7
- package/lib/cjs/MultipleCheckboxes/index.d.ts +3 -1
- package/lib/cjs/MultipleCheckboxes/index.js +131 -4
- package/lib/cjs/Select/index.js +2 -2
- package/lib/cjs/TagInput/index.d.ts +3 -1
- package/lib/cjs/TagInput/index.js +145 -7
- package/lib/esm/Accordion/AccordionItem.tsx +1 -1
- package/lib/esm/Accordion/utils/anim.js +2 -94
- package/lib/esm/Accordion/utils/init-default-options.js +98 -0
- package/lib/esm/CascadingSelect/index.tsx +15 -3
- package/lib/esm/CascadingSelect/utils/convert.js +55 -0
- package/lib/esm/CascadingSelect/utils/extract.js +57 -0
- package/lib/esm/CascadingSelectE2E/index.tsx +125 -119
- package/lib/esm/CascadingSelectE2E/utils/convert.js +55 -0
- package/lib/esm/CascadingSelectE2E/utils/extract.js +57 -0
- package/lib/esm/MultipleCheckboxes/index.tsx +10 -4
- package/lib/esm/MultipleCheckboxes/utils/convert.js +55 -0
- package/lib/esm/MultipleCheckboxes/utils/extract.js +57 -0
- package/lib/esm/Select/index.tsx +2 -2
- package/lib/esm/TagInput/index.tsx +12 -5
- package/lib/esm/TagInput/utils/convert.js +55 -0
- package/lib/esm/TagInput/utils/extract.js +57 -0
- package/package.json +1 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the contents of square brackets
|
|
3
|
+
* @param {String} str => input string. such as '[1,2] [f][c]'
|
|
4
|
+
* @returns {Array|String} such as: ['1,2','f','c']
|
|
5
|
+
*/
|
|
6
|
+
function extractContentsOfBrackets(str, commaSeparated = false) {
|
|
7
|
+
if (typeof str === 'undefined') return '';
|
|
8
|
+
|
|
9
|
+
const res = str.match(/[^\[]+(?=(\[ \])|\])/g);
|
|
10
|
+
if (commaSeparated) {
|
|
11
|
+
return res === null ? '' : res.join(',').replace(/\,+$/, '');
|
|
12
|
+
} else {
|
|
13
|
+
return res === null ? '' : res;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Extract the contents of curly braces
|
|
20
|
+
* @param {String} str => input string. such as '{1,2} {f}{c}'
|
|
21
|
+
* @returns {Array|String} such as: ['1,2','f','c']
|
|
22
|
+
*/
|
|
23
|
+
function extractContentsOfBraces(str, commaSeparated = false) {
|
|
24
|
+
if (typeof str === 'undefined') return '';
|
|
25
|
+
|
|
26
|
+
const res = str.match(/[^\{]+(?=(\{ \})|\})/g);
|
|
27
|
+
if (commaSeparated) {
|
|
28
|
+
return res === null ? '' : res.join(',').replace(/\,+$/, '');
|
|
29
|
+
} else {
|
|
30
|
+
return res === null ? '' : res;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Extract the contents of parentheses
|
|
37
|
+
* @param {String} str => input string. such as '(1,2) (f)(c)'
|
|
38
|
+
* @returns {Array|String} such as: ['1,2','f','c']
|
|
39
|
+
*/
|
|
40
|
+
function extractContentsOfParentheses(str, commaSeparated = false) {
|
|
41
|
+
if (typeof str === 'undefined') return '';
|
|
42
|
+
|
|
43
|
+
const res = str.match(/[^\(]+(?=(\( \))|\))/g);
|
|
44
|
+
if (commaSeparated) {
|
|
45
|
+
return res === null ? '' : res.join(',').replace(/\,+$/, '');
|
|
46
|
+
} else {
|
|
47
|
+
return res === null ? '' : res;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
extractContentsOfBrackets,
|
|
55
|
+
extractContentsOfBraces,
|
|
56
|
+
extractContentsOfParentheses
|
|
57
|
+
}
|
|
@@ -2,6 +2,8 @@ import React, { useId, useState, useEffect, useRef, forwardRef } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import Checkbox from 'funda-checkbox';
|
|
4
4
|
|
|
5
|
+
import { extractContentsOfBrackets } from './utils/extract';
|
|
6
|
+
import { convertArrToValByBrackets } from './utils/convert';
|
|
5
7
|
|
|
6
8
|
interface OptionConfig {
|
|
7
9
|
[propName: string]: string | number;
|
|
@@ -17,11 +19,13 @@ type MultipleCheckboxesProps = {
|
|
|
17
19
|
options?: OptionConfig[] | string;
|
|
18
20
|
disabled?: any;
|
|
19
21
|
required?: any;
|
|
22
|
+
/** Whether to use square brackets to save result and initialize default value */
|
|
23
|
+
extractValueByBrackets?: boolean;
|
|
20
24
|
/** -- */
|
|
21
25
|
id?: string;
|
|
22
26
|
style?: React.CSSProperties;
|
|
23
27
|
[key: `data-${string}`]: string | undefined;
|
|
24
|
-
onChange?: (e: any, data: any) => void;
|
|
28
|
+
onChange?: (e: any, data: any, dataStr: any) => void;
|
|
25
29
|
|
|
26
30
|
};
|
|
27
31
|
|
|
@@ -37,12 +41,14 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, ref: any)
|
|
|
37
41
|
label,
|
|
38
42
|
name,
|
|
39
43
|
id,
|
|
44
|
+
extractValueByBrackets,
|
|
40
45
|
style,
|
|
41
46
|
onChange,
|
|
42
47
|
...attributes
|
|
43
48
|
} = props;
|
|
44
49
|
|
|
45
50
|
|
|
51
|
+
const VALUE_BY_BRACKETS = typeof extractValueByBrackets === 'undefined' ? true : extractValueByBrackets;
|
|
46
52
|
const uniqueID = useId();
|
|
47
53
|
const idRes = id || uniqueID;
|
|
48
54
|
const rootRef = useRef<any>(null);
|
|
@@ -97,7 +103,7 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, ref: any)
|
|
|
97
103
|
if ( typeof defaultValue === 'undefined' || defaultValue === '' ) {
|
|
98
104
|
setRegTagSelected([]);
|
|
99
105
|
} else {
|
|
100
|
-
setRegTagSelected(defaultValue.trim().replace(/^\,|\,$/g, '').split(',').filter((v: any) => v !== ''));
|
|
106
|
+
setRegTagSelected(VALUE_BY_BRACKETS ? extractContentsOfBrackets(defaultValue) : defaultValue.trim().replace(/^\,|\,$/g, '').split(',').filter((v: any) => v !== ''));
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
|
|
@@ -151,7 +157,7 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, ref: any)
|
|
|
151
157
|
|
|
152
158
|
const _res = (val) ? Array.from(new Set([e.target.value, ...newData])) : newData;
|
|
153
159
|
|
|
154
|
-
onChange?.(e, _res);
|
|
160
|
+
onChange?.(e, _res, VALUE_BY_BRACKETS ? convertArrToValByBrackets(_res) : _res.join(','));
|
|
155
161
|
|
|
156
162
|
return _res;
|
|
157
163
|
});
|
|
@@ -168,7 +174,7 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, ref: any)
|
|
|
168
174
|
type="hidden"
|
|
169
175
|
id={idRes}
|
|
170
176
|
name={name}
|
|
171
|
-
value={regTagSelected.join(',')}
|
|
177
|
+
value={VALUE_BY_BRACKETS ? convertArrToValByBrackets(regTagSelected) : regTagSelected.join(',')}
|
|
172
178
|
required={required || null}
|
|
173
179
|
{...attributes}
|
|
174
180
|
/>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert value to string separated by square brackets
|
|
3
|
+
* @param {String} str such as: 1,2,3
|
|
4
|
+
* @returns {String} such as: [1][2][3]
|
|
5
|
+
*/
|
|
6
|
+
function convertStringByCommaToValByBrackets(str) {
|
|
7
|
+
if (typeof str === 'undefined') return '';
|
|
8
|
+
if ( str.length === 0 ) return '';
|
|
9
|
+
return str.split(',').map((v) => v.includes('[') && v.includes(']') ? `${v}` : `[${v}]`).join('');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Convert array value to string separated by square brackets
|
|
15
|
+
* @param {Array} arr such as: ['1','2','3']
|
|
16
|
+
* @returns {String} such as: [1][2][3]
|
|
17
|
+
*/
|
|
18
|
+
function convertArrToValByBrackets(arr) {
|
|
19
|
+
if (!Array.isArray(arr)) return '';
|
|
20
|
+
|
|
21
|
+
return arr.map((v) => v.includes('[') && v.includes(']') ? `${v}` : `[${v}]`).join('');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Convert value to string separated by curly braces
|
|
28
|
+
* @param {String} str such as: 1,2,3
|
|
29
|
+
* @returns {String} such as: {1}{2}{3}
|
|
30
|
+
*/
|
|
31
|
+
function convertStringByCommaToValByBraces(str) {
|
|
32
|
+
if (typeof str === 'undefined') return '';
|
|
33
|
+
if ( str.length === 0 ) return '';
|
|
34
|
+
return str.split(',').map((v) => v.includes('{') && v.includes('}') ? `${v}` : `{${v}}`).join('');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Convert array value to string separated by curly braces
|
|
40
|
+
* @param {Array} arr such as: ['1','2','3']
|
|
41
|
+
* @returns {String} such as: {1}{2}{3}
|
|
42
|
+
*/
|
|
43
|
+
function convertArrToValByBraces(arr) {
|
|
44
|
+
if (!Array.isArray(arr)) return '';
|
|
45
|
+
|
|
46
|
+
return arr.map((v) => v.includes('{') && v.includes('}') ? `${v}` : `{${v}}`).join('');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
convertStringByCommaToValByBrackets,
|
|
52
|
+
convertArrToValByBrackets,
|
|
53
|
+
convertStringByCommaToValByBraces,
|
|
54
|
+
convertArrToValByBraces
|
|
55
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the contents of square brackets
|
|
3
|
+
* @param {String} str => input string. such as '[1,2] [f][c]'
|
|
4
|
+
* @returns {Array|String} such as: ['1,2','f','c']
|
|
5
|
+
*/
|
|
6
|
+
function extractContentsOfBrackets(str, commaSeparated = false) {
|
|
7
|
+
if (typeof str === 'undefined') return '';
|
|
8
|
+
|
|
9
|
+
const res = str.match(/[^\[]+(?=(\[ \])|\])/g);
|
|
10
|
+
if (commaSeparated) {
|
|
11
|
+
return res === null ? '' : res.join(',').replace(/\,+$/, '');
|
|
12
|
+
} else {
|
|
13
|
+
return res === null ? '' : res;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Extract the contents of curly braces
|
|
20
|
+
* @param {String} str => input string. such as '{1,2} {f}{c}'
|
|
21
|
+
* @returns {Array|String} such as: ['1,2','f','c']
|
|
22
|
+
*/
|
|
23
|
+
function extractContentsOfBraces(str, commaSeparated = false) {
|
|
24
|
+
if (typeof str === 'undefined') return '';
|
|
25
|
+
|
|
26
|
+
const res = str.match(/[^\{]+(?=(\{ \})|\})/g);
|
|
27
|
+
if (commaSeparated) {
|
|
28
|
+
return res === null ? '' : res.join(',').replace(/\,+$/, '');
|
|
29
|
+
} else {
|
|
30
|
+
return res === null ? '' : res;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Extract the contents of parentheses
|
|
37
|
+
* @param {String} str => input string. such as '(1,2) (f)(c)'
|
|
38
|
+
* @returns {Array|String} such as: ['1,2','f','c']
|
|
39
|
+
*/
|
|
40
|
+
function extractContentsOfParentheses(str, commaSeparated = false) {
|
|
41
|
+
if (typeof str === 'undefined') return '';
|
|
42
|
+
|
|
43
|
+
const res = str.match(/[^\(]+(?=(\( \))|\))/g);
|
|
44
|
+
if (commaSeparated) {
|
|
45
|
+
return res === null ? '' : res.join(',').replace(/\,+$/, '');
|
|
46
|
+
} else {
|
|
47
|
+
return res === null ? '' : res;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
extractContentsOfBrackets,
|
|
55
|
+
extractContentsOfBraces,
|
|
56
|
+
extractContentsOfParentheses
|
|
57
|
+
}
|
package/lib/esm/Select/index.tsx
CHANGED
|
@@ -252,7 +252,7 @@ const Select = forwardRef((props: SelectProps, ref: any) => {
|
|
|
252
252
|
|
|
253
253
|
|
|
254
254
|
// Generate list of options
|
|
255
|
-
const selectOptionsList = dataInit.map((item: any, index: number) => {
|
|
255
|
+
const selectOptionsList = Array.isArray(dataInit) ? dataInit.map((item: any, index: number) => {
|
|
256
256
|
|
|
257
257
|
if (typeof item.optgroup !== 'undefined') {
|
|
258
258
|
return <optgroup key={'optgroup-' + index} label={item.label}>
|
|
@@ -273,7 +273,7 @@ const Select = forwardRef((props: SelectProps, ref: any) => {
|
|
|
273
273
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
});
|
|
276
|
+
}) : null;
|
|
277
277
|
|
|
278
278
|
|
|
279
279
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React, { useId, useState, useEffect, useRef, forwardRef } from 'react';
|
|
2
2
|
|
|
3
|
+
import { extractContentsOfBrackets } from './utils/extract';
|
|
4
|
+
import { convertArrToValByBrackets } from './utils/convert';
|
|
5
|
+
|
|
3
6
|
declare module 'react' {
|
|
4
7
|
interface ReactI18NextChildren<T> {
|
|
5
8
|
children?: any;
|
|
@@ -17,12 +20,14 @@ type TagInputProps = {
|
|
|
17
20
|
required?: any;
|
|
18
21
|
readOnly?: any;
|
|
19
22
|
placeholder?: string;
|
|
23
|
+
/** Whether to use square brackets to save result and initialize default value */
|
|
24
|
+
extractValueByBrackets?: boolean;
|
|
20
25
|
/** -- */
|
|
21
26
|
id?: string;
|
|
22
27
|
style?: React.CSSProperties;
|
|
23
28
|
tabIndex?: number;
|
|
24
29
|
[key: `data-${string}`]: string | undefined;
|
|
25
|
-
onChange?: (e: any,
|
|
30
|
+
onChange?: (e: any, data: any, dataStr: any) => void;
|
|
26
31
|
onBlur?: (e: any) => void;
|
|
27
32
|
onFocus?: (e: any) => void;
|
|
28
33
|
|
|
@@ -41,6 +46,7 @@ const TagInput = forwardRef((props: TagInputProps, ref: any) => {
|
|
|
41
46
|
label,
|
|
42
47
|
name,
|
|
43
48
|
id,
|
|
49
|
+
extractValueByBrackets,
|
|
44
50
|
maxLength,
|
|
45
51
|
style,
|
|
46
52
|
tabIndex,
|
|
@@ -51,6 +57,7 @@ const TagInput = forwardRef((props: TagInputProps, ref: any) => {
|
|
|
51
57
|
} = props;
|
|
52
58
|
|
|
53
59
|
|
|
60
|
+
const VALUE_BY_BRACKETS = typeof extractValueByBrackets === 'undefined' ? true : extractValueByBrackets;
|
|
54
61
|
const uniqueID = useId();
|
|
55
62
|
const idRes = id || uniqueID;
|
|
56
63
|
const rootRef = useRef<any>(null);
|
|
@@ -70,7 +77,7 @@ const TagInput = forwardRef((props: TagInputProps, ref: any) => {
|
|
|
70
77
|
if ( typeof defaultValue === 'undefined' || defaultValue === '' ) {
|
|
71
78
|
setItems([]);
|
|
72
79
|
} else {
|
|
73
|
-
setItems(defaultValue.trim().replace(/^\,|\,$/g, '').split(',').map((item: any, index: number) => {
|
|
80
|
+
setItems((VALUE_BY_BRACKETS ? extractContentsOfBrackets(defaultValue) : defaultValue.trim().replace(/^\,|\,$/g, '').split(',')).map((item: any, index: number) => {
|
|
74
81
|
return {
|
|
75
82
|
content: item,
|
|
76
83
|
id: index
|
|
@@ -88,7 +95,7 @@ const TagInput = forwardRef((props: TagInputProps, ref: any) => {
|
|
|
88
95
|
setItems(newArray);
|
|
89
96
|
|
|
90
97
|
//
|
|
91
|
-
onChange?.(inputRef.current, newArray);
|
|
98
|
+
onChange?.(inputRef.current, newArray, VALUE_BY_BRACKETS ? convertArrToValByBrackets(newArray.map(v => v.content)) : newArray.map(v => v.content).join(','));
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
function handleKeypress(event: any) {
|
|
@@ -124,7 +131,7 @@ const TagInput = forwardRef((props: TagInputProps, ref: any) => {
|
|
|
124
131
|
setUserInput('');
|
|
125
132
|
|
|
126
133
|
//
|
|
127
|
-
onChange?.(inputRef.current, items);
|
|
134
|
+
onChange?.(inputRef.current, items, VALUE_BY_BRACKETS ? convertArrToValByBrackets(items.map(v => v.content)) : items.map(v => v.content).join(','));
|
|
128
135
|
|
|
129
136
|
|
|
130
137
|
}
|
|
@@ -273,7 +280,7 @@ const TagInput = forwardRef((props: TagInputProps, ref: any) => {
|
|
|
273
280
|
type="hidden"
|
|
274
281
|
id={idRes}
|
|
275
282
|
name={name}
|
|
276
|
-
value={items.map((item: any) => item.content).join(',')}
|
|
283
|
+
value={VALUE_BY_BRACKETS ? convertArrToValByBrackets(items.map((item: any) => item.content)) : items.map((item: any) => item.content).join(',')}
|
|
277
284
|
required={required || null}
|
|
278
285
|
/>
|
|
279
286
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert value to string separated by square brackets
|
|
3
|
+
* @param {String} str such as: 1,2,3
|
|
4
|
+
* @returns {String} such as: [1][2][3]
|
|
5
|
+
*/
|
|
6
|
+
function convertStringByCommaToValByBrackets(str) {
|
|
7
|
+
if (typeof str === 'undefined') return '';
|
|
8
|
+
if ( str.length === 0 ) return '';
|
|
9
|
+
return str.split(',').map((v) => v.includes('[') && v.includes(']') ? `${v}` : `[${v}]`).join('');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Convert array value to string separated by square brackets
|
|
15
|
+
* @param {Array} arr such as: ['1','2','3']
|
|
16
|
+
* @returns {String} such as: [1][2][3]
|
|
17
|
+
*/
|
|
18
|
+
function convertArrToValByBrackets(arr) {
|
|
19
|
+
if (!Array.isArray(arr)) return '';
|
|
20
|
+
|
|
21
|
+
return arr.map((v) => v.includes('[') && v.includes(']') ? `${v}` : `[${v}]`).join('');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Convert value to string separated by curly braces
|
|
28
|
+
* @param {String} str such as: 1,2,3
|
|
29
|
+
* @returns {String} such as: {1}{2}{3}
|
|
30
|
+
*/
|
|
31
|
+
function convertStringByCommaToValByBraces(str) {
|
|
32
|
+
if (typeof str === 'undefined') return '';
|
|
33
|
+
if ( str.length === 0 ) return '';
|
|
34
|
+
return str.split(',').map((v) => v.includes('{') && v.includes('}') ? `${v}` : `{${v}}`).join('');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Convert array value to string separated by curly braces
|
|
40
|
+
* @param {Array} arr such as: ['1','2','3']
|
|
41
|
+
* @returns {String} such as: {1}{2}{3}
|
|
42
|
+
*/
|
|
43
|
+
function convertArrToValByBraces(arr) {
|
|
44
|
+
if (!Array.isArray(arr)) return '';
|
|
45
|
+
|
|
46
|
+
return arr.map((v) => v.includes('{') && v.includes('}') ? `${v}` : `{${v}}`).join('');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
convertStringByCommaToValByBrackets,
|
|
52
|
+
convertArrToValByBrackets,
|
|
53
|
+
convertStringByCommaToValByBraces,
|
|
54
|
+
convertArrToValByBraces
|
|
55
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the contents of square brackets
|
|
3
|
+
* @param {String} str => input string. such as '[1,2] [f][c]'
|
|
4
|
+
* @returns {Array|String} such as: ['1,2','f','c']
|
|
5
|
+
*/
|
|
6
|
+
function extractContentsOfBrackets(str, commaSeparated = false) {
|
|
7
|
+
if (typeof str === 'undefined') return '';
|
|
8
|
+
|
|
9
|
+
const res = str.match(/[^\[]+(?=(\[ \])|\])/g);
|
|
10
|
+
if (commaSeparated) {
|
|
11
|
+
return res === null ? '' : res.join(',').replace(/\,+$/, '');
|
|
12
|
+
} else {
|
|
13
|
+
return res === null ? '' : res;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Extract the contents of curly braces
|
|
20
|
+
* @param {String} str => input string. such as '{1,2} {f}{c}'
|
|
21
|
+
* @returns {Array|String} such as: ['1,2','f','c']
|
|
22
|
+
*/
|
|
23
|
+
function extractContentsOfBraces(str, commaSeparated = false) {
|
|
24
|
+
if (typeof str === 'undefined') return '';
|
|
25
|
+
|
|
26
|
+
const res = str.match(/[^\{]+(?=(\{ \})|\})/g);
|
|
27
|
+
if (commaSeparated) {
|
|
28
|
+
return res === null ? '' : res.join(',').replace(/\,+$/, '');
|
|
29
|
+
} else {
|
|
30
|
+
return res === null ? '' : res;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Extract the contents of parentheses
|
|
37
|
+
* @param {String} str => input string. such as '(1,2) (f)(c)'
|
|
38
|
+
* @returns {Array|String} such as: ['1,2','f','c']
|
|
39
|
+
*/
|
|
40
|
+
function extractContentsOfParentheses(str, commaSeparated = false) {
|
|
41
|
+
if (typeof str === 'undefined') return '';
|
|
42
|
+
|
|
43
|
+
const res = str.match(/[^\(]+(?=(\( \))|\))/g);
|
|
44
|
+
if (commaSeparated) {
|
|
45
|
+
return res === null ? '' : res.join(',').replace(/\,+$/, '');
|
|
46
|
+
} else {
|
|
47
|
+
return res === null ? '' : res;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
extractContentsOfBrackets,
|
|
55
|
+
extractContentsOfBraces,
|
|
56
|
+
extractContentsOfParentheses
|
|
57
|
+
}
|
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": "1.
|
|
5
|
+
"version": "1.1.12",
|
|
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",
|