react-restyle-components 0.2.87 → 0.2.89
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/package.json +1 -1
- package/lib/src/core-components/index.d.ts +0 -34
- package/lib/src/core-components/index.d.ts.map +0 -1
- package/lib/src/core-components/index.js +0 -33
- package/lib/src/core-components/src/atoms/button/Button.types.d.ts +0 -26
- package/lib/src/core-components/src/atoms/button/Button.types.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/button/Button.types.js +0 -1
- package/lib/src/core-components/src/atoms/button/button.component.d.ts +0 -4
- package/lib/src/core-components/src/atoms/button/button.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/button/button.component.js +0 -18
- package/lib/src/core-components/src/atoms/button/buttonGroup/buttonGroup.component.d.ts +0 -7
- package/lib/src/core-components/src/atoms/button/buttonGroup/buttonGroup.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/button/buttonGroup/buttonGroup.component.js +0 -4
- package/lib/src/core-components/src/atoms/check-box/checkBox.component.d.ts +0 -10
- package/lib/src/core-components/src/atoms/check-box/checkBox.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/check-box/checkBox.component.js +0 -20
- package/lib/src/core-components/src/atoms/date-picker/date-picker.component.d.ts +0 -12
- package/lib/src/core-components/src/atoms/date-picker/date-picker.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/date-picker/date-picker.component.js +0 -20
- package/lib/src/core-components/src/atoms/form/form.component.d.ts +0 -105
- package/lib/src/core-components/src/atoms/form/form.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/form/form.component.js +0 -87
- package/lib/src/core-components/src/atoms/icons/icons.component.d.ts +0 -12
- package/lib/src/core-components/src/atoms/icons/icons.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/icons/icons.component.js +0 -71
- package/lib/src/core-components/src/atoms/input/input-otp.component.d.ts +0 -14
- package/lib/src/core-components/src/atoms/input/input-otp.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/input/input-otp.component.js +0 -61
- package/lib/src/core-components/src/atoms/input/input-pin.component.d.ts +0 -16
- package/lib/src/core-components/src/atoms/input/input-pin.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/input/input-pin.component.js +0 -76
- package/lib/src/core-components/src/atoms/input/input.component.d.ts +0 -18
- package/lib/src/core-components/src/atoms/input/input.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/input/input.component.js +0 -16
- package/lib/src/core-components/src/atoms/input-dropdown/input-dropdown.component.d.ts +0 -10
- package/lib/src/core-components/src/atoms/input-dropdown/input-dropdown.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/input-dropdown/input-dropdown.component.js +0 -44
- package/lib/src/core-components/src/atoms/loader/loader.component.d.ts +0 -6
- package/lib/src/core-components/src/atoms/loader/loader.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/loader/loader.component.js +0 -6
- package/lib/src/core-components/src/atoms/pdf/pdf-images.components.d.ts +0 -9
- package/lib/src/core-components/src/atoms/pdf/pdf-images.components.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/pdf/pdf-images.components.js +0 -7
- package/lib/src/core-components/src/atoms/pdf/pdf-table.components.d.ts +0 -11
- package/lib/src/core-components/src/atoms/pdf/pdf-table.components.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/pdf/pdf-table.components.js +0 -48
- package/lib/src/core-components/src/atoms/pdf/pdf-typography.components.d.ts +0 -21
- package/lib/src/core-components/src/atoms/pdf/pdf-typography.components.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/pdf/pdf-typography.components.js +0 -70
- package/lib/src/core-components/src/atoms/pdf/pdf-wrapped-view.components.d.ts +0 -53
- package/lib/src/core-components/src/atoms/pdf/pdf-wrapped-view.components.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/pdf/pdf-wrapped-view.components.js +0 -50
- package/lib/src/core-components/src/atoms/radio/radio.component.d.ts +0 -9
- package/lib/src/core-components/src/atoms/radio/radio.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/radio/radio.component.js +0 -20
- package/lib/src/core-components/src/atoms/stepper/stepper.component.d.ts +0 -9
- package/lib/src/core-components/src/atoms/stepper/stepper.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/stepper/stepper.component.js +0 -26
- package/lib/src/core-components/src/atoms/tabs/tabs.component.d.ts +0 -18
- package/lib/src/core-components/src/atoms/tabs/tabs.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/tabs/tabs.component.js +0 -19
- package/lib/src/core-components/src/atoms/timer/timer.component.d.ts +0 -7
- package/lib/src/core-components/src/atoms/timer/timer.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/timer/timer.component.js +0 -76
- package/lib/src/core-components/src/atoms/tooltip/Tooltip.types.d.ts +0 -22
- package/lib/src/core-components/src/atoms/tooltip/Tooltip.types.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/tooltip/Tooltip.types.js +0 -1
- package/lib/src/core-components/src/atoms/tooltip/tooltip.component.d.ts +0 -10
- package/lib/src/core-components/src/atoms/tooltip/tooltip.component.d.ts.map +0 -1
- package/lib/src/core-components/src/atoms/tooltip/tooltip.component.js +0 -10
- package/lib/src/core-components/src/helpers/constants.d.ts +0 -4
- package/lib/src/core-components/src/helpers/constants.d.ts.map +0 -1
- package/lib/src/core-components/src/helpers/constants.js +0 -11
- package/lib/src/core-components/src/hooks/index.d.ts +0 -2
- package/lib/src/core-components/src/hooks/index.d.ts.map +0 -1
- package/lib/src/core-components/src/hooks/index.js +0 -1
- package/lib/src/core-components/src/hooks/outside.hook.d.ts +0 -2
- package/lib/src/core-components/src/hooks/outside.hook.d.ts.map +0 -1
- package/lib/src/core-components/src/hooks/outside.hook.js +0 -28
- package/lib/src/core-components/src/library/assets/svg/index.d.ts +0 -10
- package/lib/src/core-components/src/library/assets/svg/index.d.ts.map +0 -1
- package/lib/src/core-components/src/library/assets/svg/index.js +0 -27
- package/lib/src/core-components/src/molecules/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.d.ts +0 -17
- package/lib/src/core-components/src/molecules/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.js +0 -101
- package/lib/src/core-components/src/molecules/auto-complete-filter-single-select/auto-complete-filter-single-select.component.d.ts +0 -13
- package/lib/src/core-components/src/molecules/auto-complete-filter-single-select/auto-complete-filter-single-select.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/auto-complete-filter-single-select/auto-complete-filter-single-select.component.js +0 -59
- package/lib/src/core-components/src/molecules/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.d.ts +0 -18
- package/lib/src/core-components/src/molecules/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.js +0 -109
- package/lib/src/core-components/src/molecules/auto-complete-group-by/auto-complete-group-by.component.d.ts +0 -10
- package/lib/src/core-components/src/molecules/auto-complete-group-by/auto-complete-group-by.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/auto-complete-group-by/auto-complete-group-by.component.js +0 -128
- package/lib/src/core-components/src/molecules/autocomplete/autocomplete.d.ts +0 -8
- package/lib/src/core-components/src/molecules/autocomplete/autocomplete.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/autocomplete/autocomplete.js +0 -108
- package/lib/src/core-components/src/molecules/color-picker/color-picker.component.d.ts +0 -6
- package/lib/src/core-components/src/molecules/color-picker/color-picker.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/color-picker/color-picker.component.js +0 -12
- package/lib/src/core-components/src/molecules/color-picker-modal/color-picker-modal.component.d.ts +0 -15
- package/lib/src/core-components/src/molecules/color-picker-modal/color-picker-modal.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/color-picker-modal/color-picker-modal.component.js +0 -41
- package/lib/src/core-components/src/molecules/css-multiline-input/css-multiline-input.component.d.ts +0 -11
- package/lib/src/core-components/src/molecules/css-multiline-input/css-multiline-input.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/css-multiline-input/css-multiline-input.component.js +0 -91
- package/lib/src/core-components/src/molecules/css-multiline-input/css-properties.d.ts +0 -8932
- package/lib/src/core-components/src/molecules/css-multiline-input/css-properties.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/css-multiline-input/css-properties.js +0 -161
- package/lib/src/core-components/src/molecules/modal/modal.component.d.ts +0 -10
- package/lib/src/core-components/src/molecules/modal/modal.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/modal/modal.component.js +0 -19
- package/lib/src/core-components/src/molecules/modal-confirm/modal-confirm.component.d.ts +0 -14
- package/lib/src/core-components/src/molecules/modal-confirm/modal-confirm.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/modal-confirm/modal-confirm.component.js +0 -21
- package/lib/src/core-components/src/molecules/multi-select/multi-select.component.d.ts +0 -9
- package/lib/src/core-components/src/molecules/multi-select/multi-select.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/multi-select/multi-select.component.js +0 -49
- package/lib/src/core-components/src/molecules/multi-select-with-field/multi-select-with-field.component.d.ts +0 -10
- package/lib/src/core-components/src/molecules/multi-select-with-field/multi-select-with-field.component.d.ts.map +0 -1
- package/lib/src/core-components/src/molecules/multi-select-with-field/multi-select-with-field.component.js +0 -58
- package/lib/src/core-components/src/utils/index.d.ts +0 -2
- package/lib/src/core-components/src/utils/index.d.ts.map +0 -1
- package/lib/src/core-components/src/utils/index.js +0 -1
- package/lib/src/core-components/src/utils/utility.util.d.ts +0 -3
- package/lib/src/core-components/src/utils/utility.util.d.ts.map +0 -1
- package/lib/src/core-components/src/utils/utility.util.js +0 -5
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
import { useState, useEffect, useRef } from 'react';
|
|
4
|
-
import { Icon } from '../../atoms/icons/icons.component';
|
|
5
|
-
import '../../../tc.module.css';
|
|
6
|
-
import s from '../../tc.module.css';
|
|
7
|
-
import { cn } from '../../utils';
|
|
8
|
-
import { debounce } from '@techabl/core-utils';
|
|
9
|
-
export const AutoCompleteFilterSingleSelectMultiFieldsDisplay = ({ disable = false, loader = false, displayValue = '', placeholder = 'Search...', data, hasError = false, className, posstion = 'absolute', keyboard = 'text', onFilter, onSelect, onBlur, }) => {
|
|
10
|
-
const [value, setValue] = useState(displayValue);
|
|
11
|
-
const [options, setOptions] = useState(data.list);
|
|
12
|
-
const [isListOpen, setIsListOpen] = useState(false);
|
|
13
|
-
const [filterValue, setFilterValue] = useState();
|
|
14
|
-
const useOutsideAlerter = (ref) => {
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
function handleClickOutside(event) {
|
|
17
|
-
if (ref.current && !ref.current.contains(event.target) && isListOpen) {
|
|
18
|
-
setIsListOpen(false);
|
|
19
|
-
//setValue('');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
23
|
-
return () => {
|
|
24
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
25
|
-
};
|
|
26
|
-
}, [ref, isListOpen]);
|
|
27
|
-
};
|
|
28
|
-
const inputRef = useRef(null);
|
|
29
|
-
const wrapperRef = useRef(null);
|
|
30
|
-
useOutsideAlerter(wrapperRef);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
setOptions(data.list);
|
|
33
|
-
}, [data]);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
setValue(displayValue);
|
|
36
|
-
}, [displayValue]);
|
|
37
|
-
const onChange = (e) => {
|
|
38
|
-
const search = e.target.value;
|
|
39
|
-
setValue(search);
|
|
40
|
-
setFilterValue(search);
|
|
41
|
-
const filteredOptions = data.list.filter((item) => data.displayKey.some((key) => item[key]?.toString().toLowerCase().includes(search.toLowerCase())));
|
|
42
|
-
setOptions(filteredOptions);
|
|
43
|
-
debounce(() => {
|
|
44
|
-
onFilter && onFilter(search);
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
const onKeyUp = (e) => {
|
|
48
|
-
const charCode = e.which ? e.which : e.keyCode;
|
|
49
|
-
if (charCode === 8) {
|
|
50
|
-
const search = e.target.value;
|
|
51
|
-
debounce(() => {
|
|
52
|
-
onFilter && onFilter(search);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const onKeyDown = (e) => {
|
|
57
|
-
if (e.key === 'Enter' || e.key === 'Tab') {
|
|
58
|
-
if (options.length > 0) {
|
|
59
|
-
const selectedItem = options.find((item) => item.labId === Number(value));
|
|
60
|
-
if (selectedItem) {
|
|
61
|
-
setValue(data.displayKey.map((key) => `${selectedItem[key]}`).join(' - '));
|
|
62
|
-
setIsListOpen(false);
|
|
63
|
-
onSelect && onSelect(selectedItem);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const calculateMaxHeight = () => {
|
|
69
|
-
if (inputRef.current) {
|
|
70
|
-
const inputRect = inputRef.current.getBoundingClientRect();
|
|
71
|
-
const availableHeight = window.innerHeight - inputRect.bottom - 20; // 10px padding
|
|
72
|
-
return availableHeight;
|
|
73
|
-
}
|
|
74
|
-
return 'calc(100vh - 140px)';
|
|
75
|
-
};
|
|
76
|
-
return (_jsx(_Fragment, { children: _jsxs("div", { ref: wrapperRef, className: "w-full relative", children: [_jsxs("div", { className: cn(s['flex'], s['p-2'], s['leading-4'], s['focus:outline-none'], s['focus:ring'], s['w-full'], s['shadow-sm'], s['sm:text-base'], s['border'], s['rounded-md'], {
|
|
77
|
-
[s['border-red']]: hasError,
|
|
78
|
-
[s['border-gray-300']]: !hasError,
|
|
79
|
-
[s['dark:text-black']]: true,
|
|
80
|
-
}), children: [_jsx("input", { ref: inputRef, placeholder: placeholder, type: keyboard, value: value, className: cn(s['w-full'], s['focus:outline-none'], s['bg-none'], s['dark:text-black'], className), onKeyUp: onKeyUp, onChange: onChange, onClick: () => setIsListOpen(true), disabled: disable, onMouseDown: () => setValue(''), onBlur: (e) => onBlur && onBlur(e), onKeyDown: onKeyDown }), isListOpen ? (_jsx(Icon, { nameIcon: "FaChevronUp", propsIcon: {
|
|
81
|
-
color: '#000000',
|
|
82
|
-
size: 22,
|
|
83
|
-
} })) : (_jsx(Icon, { nameIcon: "FaChevronDown", propsIcon: {
|
|
84
|
-
color: '#000000',
|
|
85
|
-
size: 22,
|
|
86
|
-
} }))] }), options && isListOpen
|
|
87
|
-
? options.length > 0 && (_jsx("div", { className: cn(s['absolute'], s['w-full'], s['bg-gray-100'], s['p-2'], s['rounded-sm'], s['overflow-y-auto']), style: {
|
|
88
|
-
zIndex: 500,
|
|
89
|
-
maxHeight: `${calculateMaxHeight()}px`,
|
|
90
|
-
}, children: _jsx("ul", { children: options?.map((item, index) => (_jsx("li", { className: cn(s['text-gray-400'], s['flex'], s['items-center']), onClick: () => {
|
|
91
|
-
setValue(data.displayKey
|
|
92
|
-
.map((key) => item[key])
|
|
93
|
-
.filter((value) => value !== null && value !== undefined)
|
|
94
|
-
.join(' - '));
|
|
95
|
-
setIsListOpen(false);
|
|
96
|
-
onSelect && onSelect(item);
|
|
97
|
-
}, children: _jsx("label", { className: cn(s['ml-2'], s['mt-1'], s['text-black']), style: {
|
|
98
|
-
textOverflow: 'ellipsis',
|
|
99
|
-
minWidth: 0,
|
|
100
|
-
overflow: 'hidden',
|
|
101
|
-
whiteSpace: 'nowrap',
|
|
102
|
-
}, title: data.displayKey
|
|
103
|
-
.map((key) => item[key])
|
|
104
|
-
.join(' - '), children: data.displayKey
|
|
105
|
-
.map((key) => item[key])
|
|
106
|
-
.filter((value) => value !== null && value !== undefined)
|
|
107
|
-
.join(' - ') }) }, index))) }) }))
|
|
108
|
-
: null] }) }));
|
|
109
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
interface AutocompleteGroupByProps {
|
|
2
|
-
data: any[];
|
|
3
|
-
hasError?: boolean;
|
|
4
|
-
displayValue?: string;
|
|
5
|
-
onChange?: (item: any, children: any) => void;
|
|
6
|
-
onClose?: () => void;
|
|
7
|
-
}
|
|
8
|
-
export declare const AutocompleteGroupBy: ({ data, hasError, displayValue, onChange, onClose, }: AutocompleteGroupByProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=auto-complete-group-by.component.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-complete-group-by.component.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/molecules/auto-complete-group-by/auto-complete-group-by.component.tsx"],"names":[],"mappings":"AAMA,UAAU,wBAAwB;IAChC,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,mBAAmB,yDAM7B,wBAAwB,4CAiP1B,CAAC"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
import { useState, useEffect, useRef } from 'react';
|
|
4
|
-
import { Icon } from '../../atoms/icons/icons.component';
|
|
5
|
-
import s from '../../tc.module.css';
|
|
6
|
-
import { cn } from '../../utils';
|
|
7
|
-
export const AutocompleteGroupBy = ({ data = [], hasError = false, displayValue = '', onChange, onClose, }) => {
|
|
8
|
-
//const [userRouter, setUserRouter] = useState<any>()
|
|
9
|
-
const [value, setValue] = useState(displayValue);
|
|
10
|
-
const [options, setOptions] = useState();
|
|
11
|
-
const [isListOpen, setIsListOpen] = useState(false);
|
|
12
|
-
const useOutsideAlerter = (ref) => {
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
/**
|
|
15
|
-
* Alert if clicked on outside of element
|
|
16
|
-
*/
|
|
17
|
-
function handleClickOutside(event) {
|
|
18
|
-
if (ref.current && !ref.current.contains(event.target) && isListOpen) {
|
|
19
|
-
setIsListOpen(false);
|
|
20
|
-
setValue('');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
// Bind the event listener
|
|
24
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
25
|
-
return () => {
|
|
26
|
-
// Unbind the event listener on clean up
|
|
27
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
28
|
-
};
|
|
29
|
-
}, [ref, isListOpen]);
|
|
30
|
-
};
|
|
31
|
-
const wrapperRef = useRef(null);
|
|
32
|
-
useOutsideAlerter(wrapperRef);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
setValue(displayValue);
|
|
35
|
-
}, [displayValue]);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
setOptions(data || []);
|
|
38
|
-
}, [data]);
|
|
39
|
-
const uniqByKeepFirst = (a, key) => {
|
|
40
|
-
const seen = new Set();
|
|
41
|
-
return a.filter((item) => {
|
|
42
|
-
const k = key(item);
|
|
43
|
-
return seen.has(k) ? false : seen.add(k);
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
const filter = (search, data) => {
|
|
47
|
-
if (search !== '') {
|
|
48
|
-
let filterArray = [];
|
|
49
|
-
data.filter((item) => {
|
|
50
|
-
item.children.filter((children) => {
|
|
51
|
-
const childrenItem = children.title &&
|
|
52
|
-
children.title.toLowerCase().indexOf(search.toLowerCase()) > -1;
|
|
53
|
-
if (childrenItem) {
|
|
54
|
-
const isSameArray = filterArray.filter((filterItem, index) => {
|
|
55
|
-
if (filterItem.name === item.name) {
|
|
56
|
-
const newChildren = filterArray[index].children.concat(children);
|
|
57
|
-
filterArray[index] = {
|
|
58
|
-
...filterArray[index],
|
|
59
|
-
children: newChildren,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
if (isSameArray.length < 1) {
|
|
64
|
-
filterArray.push({ ...item, children: [children] });
|
|
65
|
-
}
|
|
66
|
-
const uniqueChars = uniqByKeepFirst(filterArray, (it) => it.name);
|
|
67
|
-
filterArray = uniqueChars;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
setOptions(filterArray);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
setOptions(data);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const onChangeValue = (e) => {
|
|
78
|
-
const search = e.target.value;
|
|
79
|
-
setValue(search);
|
|
80
|
-
filter(search, data);
|
|
81
|
-
};
|
|
82
|
-
return (_jsx(_Fragment, { children: _jsxs("div", { ref: wrapperRef, className: s['w-full'] + ' ' + s['relative'], children: [_jsxs("div", { className: cn(s['flex'], s['items-center'], s['leading-4'], s['p-2'], s['bg-white'], s['focus:outline-none'], s['focus:ring'], s['w-full'], s['shadow-sm'], s['sm:text-base'], s['border'], s['rounded-md'], {
|
|
83
|
-
[s['border-red']]: hasError,
|
|
84
|
-
[s['border-gray-300']]: !hasError,
|
|
85
|
-
}), children: [_jsx("input", { placeholder: "Search...", value: !isListOpen ? value : value, className: cn(s['w-full'] + ' ' + s['focus:outline-none']),
|
|
86
|
-
// onKeyUp={onKeyUp}
|
|
87
|
-
onChange: onChangeValue, onClick: () => setIsListOpen(true), onKeyDown: (e) => {
|
|
88
|
-
if (e.key === 'Enter') {
|
|
89
|
-
e.preventDefault();
|
|
90
|
-
// Find the selected item and children
|
|
91
|
-
let selectedItem = null;
|
|
92
|
-
let selectedChildren = null;
|
|
93
|
-
for (const item of options) {
|
|
94
|
-
for (const children of item.children) {
|
|
95
|
-
if (children.title.toLowerCase() === value.toLowerCase() ||
|
|
96
|
-
item.title.toLowerCase() === value.toLowerCase()) {
|
|
97
|
-
selectedItem = item;
|
|
98
|
-
selectedChildren = children;
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (selectedItem) {
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// Call props.onChange with the selected item and children
|
|
107
|
-
if (onChange && selectedItem && selectedChildren) {
|
|
108
|
-
onChange(selectedItem, selectedChildren);
|
|
109
|
-
}
|
|
110
|
-
setIsListOpen(false);
|
|
111
|
-
setValue(value); // Set the value to what the user entered
|
|
112
|
-
setOptions([]);
|
|
113
|
-
}
|
|
114
|
-
} }), isListOpen ? (_jsx(Icon, { nameIcon: "FaChevronUp", propsIcon: {
|
|
115
|
-
color: '#000000',
|
|
116
|
-
size: 22,
|
|
117
|
-
} })) : (_jsx(Icon, { nameIcon: "FaChevronDown", propsIcon: {
|
|
118
|
-
color: '#000000',
|
|
119
|
-
size: 22,
|
|
120
|
-
} }))] }), options && isListOpen
|
|
121
|
-
? options?.length > 0 && (_jsx("div", { className: cn(s['flex'], s['mt-1'], s['absolute'], s['z-50'], s['rounded-md'], s['bg-gray-200'], s['w-100'], s['w-full']), children: _jsx("ul", { className: cn(s['flex'], s['p-2'], s['rounded-sm'], s['w-full']), children: _jsx("div", { className: cn(s['flex'], s['flex-col'], s['w-full'], s['overflow-scroll']), style: { height: 'auto', maxHeight: '350px' }, children: options?.map((item, index) => (_jsxs(_Fragment, { children: [_jsx("li", { className: cn(s['flex'] + ' ' + s['text-gray-400']), children: item.title }, index), _jsx("ul", { className: cn(s['flex'], s['flex-col'], s['ml-4'], s['w-full']), children: item?.children?.map((children, childrenIndex) => (_jsx("li", { className: cn(s['flex'], s['hover:bg-gray-200'], s['focus:outline-none'], s['cursor-pointer'], s['w-full']), onClick: async () => {
|
|
122
|
-
onChange && onChange(item, children);
|
|
123
|
-
setIsListOpen(false);
|
|
124
|
-
setValue(children.title);
|
|
125
|
-
setOptions([]);
|
|
126
|
-
}, children: children.title }, childrenIndex))) })] }))) }) }) }))
|
|
127
|
-
: null] }) }));
|
|
128
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
interface AutocompleteProps {
|
|
2
|
-
value: string;
|
|
3
|
-
onValueChange: (value: string) => void;
|
|
4
|
-
options?: string[];
|
|
5
|
-
}
|
|
6
|
-
export declare const Autocomplete: ({ value, onValueChange, options, }: AutocompleteProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=autocomplete.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/molecules/autocomplete/autocomplete.tsx"],"names":[],"mappings":"AAMA,UAAU,iBAAiB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,YAAY,uCAItB,iBAAiB,4CAgNnB,CAAC"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
|
-
import s from '../../tc.module.css';
|
|
4
|
-
import { cn } from '../../utils';
|
|
5
|
-
const LI_ELEMENT_HEIGHT = 34;
|
|
6
|
-
export const Autocomplete = ({ value = '', onValueChange, options = [], }) => {
|
|
7
|
-
const [activeOption, setActiveOption] = useState(value === '' || options.indexOf(value) === -1 ? 0 : options.indexOf(value));
|
|
8
|
-
const [filteredOptions, setFilteredOptions] = useState(options);
|
|
9
|
-
const [shouldShowList, setShouldShowList] = useState(false);
|
|
10
|
-
const [searchValue, setSearchValue] = useState(value);
|
|
11
|
-
const inputRef = useRef(null);
|
|
12
|
-
const listRef = useRef(null);
|
|
13
|
-
const onInputChange = useCallback((event) => {
|
|
14
|
-
const input = event.target.value;
|
|
15
|
-
if (input != '') {
|
|
16
|
-
const newFilteredOptions = options.filter((option) => option.toLowerCase().indexOf(input.toLowerCase()) > -1);
|
|
17
|
-
setFilteredOptions(newFilteredOptions);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
setFilteredOptions(options);
|
|
21
|
-
}
|
|
22
|
-
setActiveOption(0);
|
|
23
|
-
setShouldShowList(true);
|
|
24
|
-
setSearchValue(input);
|
|
25
|
-
}, [
|
|
26
|
-
setActiveOption,
|
|
27
|
-
setFilteredOptions,
|
|
28
|
-
setShouldShowList,
|
|
29
|
-
setSearchValue,
|
|
30
|
-
onValueChange,
|
|
31
|
-
]);
|
|
32
|
-
const onOptionClick = useCallback((event) => {
|
|
33
|
-
const symbol = event.currentTarget.innerText || event.currentTarget.textContent || '';
|
|
34
|
-
setShouldShowList(false);
|
|
35
|
-
setActiveOption(0);
|
|
36
|
-
setFilteredOptions([]);
|
|
37
|
-
setSearchValue(symbol);
|
|
38
|
-
onValueChange(symbol);
|
|
39
|
-
}, [
|
|
40
|
-
setShouldShowList,
|
|
41
|
-
setActiveOption,
|
|
42
|
-
setFilteredOptions,
|
|
43
|
-
setSearchValue,
|
|
44
|
-
onValueChange,
|
|
45
|
-
]);
|
|
46
|
-
const onKeyDown = useCallback((event) => {
|
|
47
|
-
let selectedItem = '';
|
|
48
|
-
if (event.keyCode === 38) {
|
|
49
|
-
// arrow up
|
|
50
|
-
event.preventDefault();
|
|
51
|
-
if (activeOption === 0) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
selectedItem = filteredOptions[activeOption - 1];
|
|
56
|
-
setSearchValue(filteredOptions[activeOption - 1]);
|
|
57
|
-
setActiveOption(activeOption - 1);
|
|
58
|
-
listRef.current?.scroll({
|
|
59
|
-
top: LI_ELEMENT_HEIGHT * (activeOption - 1),
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else if (event.keyCode === 40) {
|
|
64
|
-
// arrow down
|
|
65
|
-
event.preventDefault();
|
|
66
|
-
if (activeOption === filteredOptions.length - 1) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
selectedItem = filteredOptions[activeOption + 1];
|
|
71
|
-
setSearchValue(filteredOptions[activeOption + 1]);
|
|
72
|
-
setActiveOption(activeOption + 1);
|
|
73
|
-
listRef.current?.scroll({
|
|
74
|
-
top: LI_ELEMENT_HEIGHT * (activeOption + 1),
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (Object.keys(selectedItem)?.length > 0) {
|
|
79
|
-
onValueChange(selectedItem);
|
|
80
|
-
}
|
|
81
|
-
}, [
|
|
82
|
-
setActiveOption,
|
|
83
|
-
setSearchValue,
|
|
84
|
-
filteredOptions,
|
|
85
|
-
activeOption,
|
|
86
|
-
onValueChange,
|
|
87
|
-
]);
|
|
88
|
-
const renderList = () => {
|
|
89
|
-
return (_jsx(_Fragment, { children: shouldShowList ? (_jsx(_Fragment, { children: _jsx("div", { className: cn(s['flex'], s['absolute'], s['rounded-sm'], s['w-full']), style: { zIndex: 999 }, children: filteredOptions?.length > 0 ? (_jsx("ul", { role: "list", className: cn(s['flex'], s['flex-col'], s['gap-1'], s['bg-gray-200'], s['w-full']), id: "list", ref: listRef, children: filteredOptions?.map((option, index) => {
|
|
90
|
-
let className = cn(s['flex'], s['gap-2'], s['p-2']);
|
|
91
|
-
if (index === activeOption) {
|
|
92
|
-
className = cn(className, s['font-bold']);
|
|
93
|
-
}
|
|
94
|
-
return (_jsx("li", { className: className, role: "listitem", onClick: onOptionClick, children: option }, index));
|
|
95
|
-
}) })) : (_jsx("div", { className: cn(s['flex'], s['bg-gray-200'], s['w-full'], s['p-2']), children: _jsx("span", { children: "Not Found Result!!" }) })) }) })) : (_jsx(_Fragment, {})) }));
|
|
96
|
-
};
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
// this only works on click when inside timeout
|
|
99
|
-
setTimeout(() => {
|
|
100
|
-
inputRef.current?.select();
|
|
101
|
-
}, 0);
|
|
102
|
-
filteredOptions[0] && onValueChange(filteredOptions[0]);
|
|
103
|
-
// setShouldShowList(true);
|
|
104
|
-
}, []);
|
|
105
|
-
return (_jsx(_Fragment, { children: _jsxs("div", { className: cn(s['flex'], s['flex-col'], s['relative']), children: [_jsx("div", { className: cn(s['flex'], s['leading-4'], s['p-2'], s['focus:outline-none'], s['focus:ring'], s['w-full'], s['shadow-sm'], s['sm:text-base'], s['border'], s['rounded-md']), children: _jsx("input", { type: "text", role: "input", name: "autocomplete-input", className: cn(s['flex'], s['focus:outline-none']), placeholder: "Search...", onChange: onInputChange, onKeyDown: onKeyDown, value: searchValue, ref: inputRef, onClick: () => {
|
|
106
|
-
setShouldShowList(true);
|
|
107
|
-
} }) }), _jsx("div", { className: cn(s['flex']), children: renderList() })] }) }));
|
|
108
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color-picker.component.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/molecules/color-picker/color-picker.component.tsx"],"names":[],"mappings":"AAGA,OAAO,oBAAoB,CAAC;AAE5B,eAAO,MAAM,WAAW;;;6CAqBvB,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useRef, useState } from 'react';
|
|
3
|
-
import { HexColorPicker } from 'react-colorful';
|
|
4
|
-
import { useClickOutside } from '../../hooks';
|
|
5
|
-
import './color-picker.css';
|
|
6
|
-
export const ColorPicker = ({ color, onChange }) => {
|
|
7
|
-
const popover = useRef();
|
|
8
|
-
const [isOpen, toggle] = useState(false);
|
|
9
|
-
const close = useCallback(() => toggle(false), []);
|
|
10
|
-
useClickOutside(popover, close);
|
|
11
|
-
return (_jsxs("div", { className: "picker", children: [_jsx("div", { className: "swatch", style: { backgroundColor: color }, onClick: () => toggle(true) }), isOpen && (_jsx("div", { className: "popover", ref: popover, children: _jsx(HexColorPicker, { color: color, onChange: onChange }) }))] }));
|
|
12
|
-
};
|
package/lib/src/core-components/src/molecules/color-picker-modal/color-picker-modal.component.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import './color-picker-modal.css';
|
|
2
|
-
import '../../tc.module.css';
|
|
3
|
-
interface ColorPickerModalProps {
|
|
4
|
-
color: string;
|
|
5
|
-
isVisible?: boolean;
|
|
6
|
-
testId?: string;
|
|
7
|
-
tooltip?: string;
|
|
8
|
-
tooltipSide?: 'top' | 'bottom' | 'left' | 'right';
|
|
9
|
-
onChange: (color: string) => void;
|
|
10
|
-
onNoFill?: (bgColor: string, textColor: string) => void;
|
|
11
|
-
onClose?: (color?: string) => void;
|
|
12
|
-
}
|
|
13
|
-
export declare const ColorPickerModal: ({ color, isVisible, testId, tooltip, tooltipSide, onChange, onNoFill, onClose, }: ColorPickerModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=color-picker-modal.component.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color-picker-modal.component.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/molecules/color-picker-modal/color-picker-modal.component.tsx"],"names":[],"mappings":"AASA,OAAO,0BAA0B,CAAC;AAClC,OAAO,qBAAqB,CAAC;AAE7B,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAClD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,eAAO,MAAM,gBAAgB,qFAS1B,qBAAqB,4CAwGvB,CAAC"}
|
package/lib/src/core-components/src/molecules/color-picker-modal/color-picker-modal.component.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useRef, useState, useEffect } from 'react';
|
|
3
|
-
import { HexColorPicker } from 'react-colorful';
|
|
4
|
-
import { useClickOutside } from '../../hooks';
|
|
5
|
-
import { TooltipProvider, Tooltip } from '../../atoms/tooltip/tooltip.component';
|
|
6
|
-
import { DEFAULT_BG_COLOR, DEFAULT_TEXT_COLOR, STANDARD_COLORS, } from '../../helpers/constants';
|
|
7
|
-
import './color-picker-modal.css';
|
|
8
|
-
import '../../tc.module.css';
|
|
9
|
-
export const ColorPickerModal = ({ color, isVisible = false, testId = 'color-picker', tooltip = '', tooltipSide = 'bottom', onChange, onNoFill, onClose, }) => {
|
|
10
|
-
const popover = useRef();
|
|
11
|
-
const [currentColor, setCurrentColor] = useState(color);
|
|
12
|
-
const [isOpen, toggle] = useState(isVisible);
|
|
13
|
-
const close = useCallback(() => {
|
|
14
|
-
if (isOpen) {
|
|
15
|
-
toggle(false);
|
|
16
|
-
onClose && onClose(currentColor);
|
|
17
|
-
}
|
|
18
|
-
}, [isOpen, onClose, currentColor]);
|
|
19
|
-
useClickOutside(popover, close);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (!isOpen) {
|
|
22
|
-
setCurrentColor(color || DEFAULT_BG_COLOR);
|
|
23
|
-
}
|
|
24
|
-
}, [color, isOpen]);
|
|
25
|
-
const handleColorChange = useCallback((color) => {
|
|
26
|
-
setCurrentColor(color);
|
|
27
|
-
onChange(color);
|
|
28
|
-
}, [onChange]);
|
|
29
|
-
const handleStandardColorClick = useCallback((color) => {
|
|
30
|
-
setCurrentColor(color);
|
|
31
|
-
onChange(color);
|
|
32
|
-
close();
|
|
33
|
-
}, [onChange, close]);
|
|
34
|
-
const handleNoFillClick = useCallback(() => {
|
|
35
|
-
onNoFill && onNoFill(DEFAULT_BG_COLOR, DEFAULT_TEXT_COLOR);
|
|
36
|
-
setCurrentColor(DEFAULT_BG_COLOR);
|
|
37
|
-
onChange(DEFAULT_BG_COLOR);
|
|
38
|
-
close();
|
|
39
|
-
}, [onNoFill, onChange, close]);
|
|
40
|
-
return (_jsxs("div", { className: "picker-modal", "data-testid": testId, children: [_jsx(TooltipProvider, { children: _jsx(Tooltip, { content: tooltip, className: 'text-white bg-black p-2', side: tooltipSide, children: _jsx("div", { "data-testid": "swatch", className: `${currentColor !== '' ? 'swatch-modal' : 'swatch-modal diagonal-line'} z-10`, style: { backgroundColor: currentColor }, onClick: () => toggle(true) }) }) }), isOpen && (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex justify-center items-center overflow-x-hidden overflow-y-auto fixed inset-0 z-50 outline-none focus:outline-none ", children: _jsx("div", { className: "relative w-auto h-auto mx-auto my-auto bg-white rounded-md", children: _jsx("div", { className: "border-0 rounded-lg relative flex flex-col w-full outline-none focus:outline-none", children: _jsxs("div", { className: "flex flex-col w-full gap-4 justify-center items-center p-4 rounded-lg shadow-lg z-99 color-picker-modal", ref: popover, children: [_jsx(HexColorPicker, { "data-testid": "colorPicker", color: currentColor, onChange: handleColorChange }), _jsxs("div", { className: "flex flex-col mt-4", children: [_jsx("span", { className: "font-serif", children: "Standard Colors" }), _jsx("div", { className: "flex gap-2 mt-2", children: STANDARD_COLORS?.map((color) => (_jsx("div", { className: "rounded-full w-8 h-8 cursor-pointer gap-2", style: { backgroundColor: color }, onClick: () => handleStandardColorClick(color), "data-testid": `standard-color-${color}` }, color))) })] }), _jsx("div", { className: "flex justify-center bg-blue-600 mt-2 rounded-md p-2 mx-8 text-white hover:bg-blue-800 transition duration-300 ease-in-out hover:shadow-lg cursor-pointer", onClick: handleNoFillClick, "data-testid": "no-fill", children: _jsx("span", { className: "font-serif", children: "No Fill" }) })] }) }) }) }), _jsx("div", { className: "opacity-25 fixed inset-0 z-40 bg-black" })] }))] }));
|
|
41
|
-
};
|
package/lib/src/core-components/src/molecules/css-multiline-input/css-multiline-input.component.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface CSSMultilineProps {
|
|
2
|
-
label?: string;
|
|
3
|
-
defaultValue?: string;
|
|
4
|
-
placeholder?: string;
|
|
5
|
-
className?: string;
|
|
6
|
-
style?: any;
|
|
7
|
-
onChange(item: any): void;
|
|
8
|
-
}
|
|
9
|
-
export declare const CSSMultiline: ({ label, defaultValue, className, style, placeholder, onChange, }: CSSMultilineProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=css-multiline-input.component.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"css-multiline-input.component.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/molecules/css-multiline-input/css-multiline-input.component.tsx"],"names":[],"mappings":"AAOA,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,IAAI,KAAA,GAAG,IAAI,CAAC;CACtB;AAWD,eAAO,MAAM,YAAY,sEAOtB,iBAAiB,4CA8HnB,CAAC"}
|
package/lib/src/core-components/src/molecules/css-multiline-input/css-multiline-input.component.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState, useRef } from 'react';
|
|
3
|
-
import * as Form from '../../atoms/form/form.component';
|
|
4
|
-
import { properties as propertiesObj } from './css-properties';
|
|
5
|
-
import s from '../../tc.module.css';
|
|
6
|
-
import { cn } from '../../utils';
|
|
7
|
-
const mapToArray = (arr) => {
|
|
8
|
-
const res = [];
|
|
9
|
-
arr.forEach(function (obj, index) {
|
|
10
|
-
const key = Object.keys(obj)[0];
|
|
11
|
-
const value = key;
|
|
12
|
-
res.push([value, obj[key]]);
|
|
13
|
-
});
|
|
14
|
-
return res;
|
|
15
|
-
};
|
|
16
|
-
const data = mapToArray(propertiesObj);
|
|
17
|
-
export const CSSMultiline = ({ label = 'Main Box CSS', defaultValue = '', className = '', style = {}, placeholder = "Like fontSize: 12,backgroundColor:'#000000',", onChange, }) => {
|
|
18
|
-
const value = useRef('');
|
|
19
|
-
const [properties, setProperties] = useState([]);
|
|
20
|
-
const [isListOpen, setIsListOpen] = useState(false);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
value.current = defaultValue;
|
|
23
|
-
setProperties(data);
|
|
24
|
-
}, [defaultValue]);
|
|
25
|
-
const useOutsideAlerter = (ref) => {
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
function handleClickOutside(event) {
|
|
28
|
-
if (ref.current && !ref.current.contains(event.target)) {
|
|
29
|
-
setIsListOpen(false);
|
|
30
|
-
onChange(value.current);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
34
|
-
return () => {
|
|
35
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
36
|
-
};
|
|
37
|
-
}, [ref]);
|
|
38
|
-
};
|
|
39
|
-
const wrapperRef = useRef(null);
|
|
40
|
-
useOutsideAlerter(wrapperRef);
|
|
41
|
-
const list = [];
|
|
42
|
-
const filter = (css) => {
|
|
43
|
-
let matchString = css?.split(',');
|
|
44
|
-
matchString = matchString[matchString?.length - 1];
|
|
45
|
-
matchString = matchString?.split(':')[0];
|
|
46
|
-
matchString = matchString?.split("'")[0];
|
|
47
|
-
if (css?.length == 0)
|
|
48
|
-
return setProperties(data);
|
|
49
|
-
else {
|
|
50
|
-
data?.map((item) => {
|
|
51
|
-
const innerItem = [];
|
|
52
|
-
const isItems = item[0]?.startsWith(matchString);
|
|
53
|
-
if (isItems)
|
|
54
|
-
innerItem.push(item[0]);
|
|
55
|
-
if (innerItem?.length > 0)
|
|
56
|
-
list.push([item[0], item[1]]);
|
|
57
|
-
});
|
|
58
|
-
setProperties(list);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const onKeyUp = (e) => {
|
|
62
|
-
setIsListOpen(true);
|
|
63
|
-
};
|
|
64
|
-
return (_jsxs("div", { className: cn(s['flex'], s['flex-col'], s['w-full']), ref: wrapperRef, children: [_jsx(Form.MultilineInput, { label: label, style: { color: '#ffffff', backgroundColor: '#000000', ...style }, placeholder: placeholder, value: value.current, className: cn(className), onKeyUp: onKeyUp, onChange: (css) => {
|
|
65
|
-
value.current = css;
|
|
66
|
-
filter(css);
|
|
67
|
-
} }), isListOpen && (_jsx("div", { style: { marginTop: -10 }, children: _jsx("ul", { className: cn(s['flex'], s['flex-col'], s['max-h-40'], s['bg-black'], s['m-2'], s['text-white'], s['overflow-y-scroll']), children: properties?.map((item, index) => (_jsxs("li", { className: cn(s['flex'], s['flex-col'], s['gap-4'], s['p-2']), children: [_jsx("span", { className: cn(s['underline']), children: item[0] }), item[1]?.map((prop) => (_jsxs("li", { className: cn(s['flex'], s['-mt-2'], s['px-2'], s['h-8'], s['bg-slate-800'], s['rounded-md'], s['items-center'], s['cursor-pointer']), onClick: () => {
|
|
68
|
-
let existsString = value.current?.split(',');
|
|
69
|
-
if (value.current.includes(',')) {
|
|
70
|
-
existsString = existsString.map((item) => {
|
|
71
|
-
if (item?.includes(':'))
|
|
72
|
-
return item;
|
|
73
|
-
});
|
|
74
|
-
if (prop != 'number')
|
|
75
|
-
existsString.push(`${item[0]}:'${prop}',`);
|
|
76
|
-
else
|
|
77
|
-
existsString.push(`${item[0]}:1,`);
|
|
78
|
-
value.current = existsString
|
|
79
|
-
.join(',')
|
|
80
|
-
.replaceAll(',,', ',');
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
if (prop != 'number')
|
|
84
|
-
value.current = `${item[0]}:'${prop}',`;
|
|
85
|
-
else {
|
|
86
|
-
value.current = `${item[0]}:1,`;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
filter(existsString.join(''));
|
|
90
|
-
}, children: [' ', prop, ' '] })))] }, index))) }) }))] }));
|
|
91
|
-
};
|