dhre-component-lib 0.2.6 → 0.2.8
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/dist/components/Accordian/Accordian.d.ts +1 -0
- package/dist/components/Search/Search.d.ts +12 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.esm.js +46 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +46 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./Search.module.scss";
|
|
3
|
+
interface Suggestion {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
faqAnswer: string;
|
|
7
|
+
faqQuestion: string;
|
|
8
|
+
fieldFaqCategory: string;
|
|
9
|
+
isBookmarked: boolean;
|
|
10
|
+
images: string[];
|
|
11
|
+
videos: string[];
|
|
12
|
+
}
|
|
3
13
|
interface CustomSearchFieldProps {
|
|
4
14
|
searchIcon: React.ReactNode;
|
|
5
15
|
crossIcon: React.ReactNode;
|
|
6
16
|
disabled?: boolean;
|
|
7
17
|
onSearch: (query: string) => void;
|
|
18
|
+
onSelectSuggestion: (selectedSuggestion: Suggestion | null) => void;
|
|
19
|
+
suggestions: Suggestion[] | null | undefined;
|
|
8
20
|
placeholder: string;
|
|
9
21
|
className?: string;
|
|
10
22
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -171,11 +171,23 @@ interface TypographyProps {
|
|
|
171
171
|
}
|
|
172
172
|
declare const Typography: React.FC<TypographyProps>;
|
|
173
173
|
|
|
174
|
+
interface Suggestion {
|
|
175
|
+
id: string;
|
|
176
|
+
title: string;
|
|
177
|
+
faqAnswer: string;
|
|
178
|
+
faqQuestion: string;
|
|
179
|
+
fieldFaqCategory: string;
|
|
180
|
+
isBookmarked: boolean;
|
|
181
|
+
images: string[];
|
|
182
|
+
videos: string[];
|
|
183
|
+
}
|
|
174
184
|
interface CustomSearchFieldProps {
|
|
175
185
|
searchIcon: React.ReactNode;
|
|
176
186
|
crossIcon: React.ReactNode;
|
|
177
187
|
disabled?: boolean;
|
|
178
188
|
onSearch: (query: string) => void;
|
|
189
|
+
onSelectSuggestion: (selectedSuggestion: Suggestion | null) => void;
|
|
190
|
+
suggestions: Suggestion[] | null | undefined;
|
|
179
191
|
placeholder: string;
|
|
180
192
|
className?: string;
|
|
181
193
|
}
|
|
@@ -198,6 +210,7 @@ type AccordionProps = {
|
|
|
198
210
|
border?: boolean;
|
|
199
211
|
upArrowIcon: React.ReactNode;
|
|
200
212
|
downArrowIcon: React.ReactNode;
|
|
213
|
+
openByDefault?: boolean;
|
|
201
214
|
};
|
|
202
215
|
declare const Accordion: React.FC<AccordionProps>;
|
|
203
216
|
|
package/dist/index.esm.js
CHANGED
|
@@ -9338,48 +9338,84 @@ const Typography = ({ variant = 'B1', weight = 'MEDIUM', children, className })
|
|
|
9338
9338
|
return React.createElement("div", { className: classNames }, children);
|
|
9339
9339
|
};
|
|
9340
9340
|
|
|
9341
|
-
var css$2 = ".search-field-container {\n display: flex;\n align-items: center;\n padding: 8px;\n border-radius: 10px;\n background-color: #FFFFFF;\n transition: border-color 0.3s ease;\n}\n.search-field-container.default-border {\n border: 1px solid #A7A7A7;\n}\n.search-field-container.typing-border {\n border: 1px solid #FFFFFF;\n}\n.search-field-container.stopped-border {\n border: 1px solid #00B578;\n}\n.search-field-container.disabled-border {\n border: 1px solid #4F4F4F;\n background-color: #E1E1E1;\n}\n\n.search-icon {\n margin-right: 8px;\n}\n\n.search-input {\n flex: 1;\n border: none;\n background-color: transparent;\n outline: none;\n}\n\n.cross-icon {\n margin-left: 8px;\n cursor: pointer;\n}";
|
|
9341
|
+
var css$2 = ".search-field-container {\n display: flex;\n align-items: center;\n padding: 8px;\n border-radius: 10px;\n background-color: #FFFFFF;\n transition: border-color 0.3s ease;\n}\n.search-field-container.default-border {\n border: 1px solid #A7A7A7;\n}\n.search-field-container.typing-border {\n border: 1px solid #FFFFFF;\n}\n.search-field-container.stopped-border {\n border: 1px solid #00B578;\n}\n.search-field-container.disabled-border {\n border: 1px solid #4F4F4F;\n background-color: #E1E1E1;\n}\n\n.search-icon {\n margin-right: 8px;\n}\n\n.search-input {\n flex: 1;\n border: none;\n background-color: transparent;\n outline: none;\n}\n\n.cross-icon {\n margin-left: 8px;\n cursor: pointer;\n}\n\n.suggestions-dropdown {\n list-style: none;\n margin: 0;\n border: 1px solid #ccc;\n overflow-y: auto;\n background-color: white;\n position: absolute;\n width: 585px;\n z-index: 10;\n top: 55px;\n border-radius: 10px;\n}\n@media (max-width: 767px) {\n .suggestions-dropdown {\n width: 95%;\n }\n}\n\n.suggestion-item {\n padding: 16px 8px 16px 8px;\n cursor: pointer;\n text-align: left;\n}\n\n.underline {\n height: 1px;\n background-color: #CECECE;\n margin-left: 24px;\n margin-right: 24px;\n}\n\n.suggestion-item:hover {\n background-color: none;\n}\n\n.row {\n flex-direction: row;\n display: flex;\n background: none;\n border: none;\n align-items: center;\n padding-left: 10px;\n}";
|
|
9342
9342
|
n(css$2,{});
|
|
9343
9343
|
|
|
9344
|
-
const Search = ({ searchIcon, crossIcon, disabled = false, onSearch, placeholder, className = {}, }) => {
|
|
9344
|
+
const Search = ({ searchIcon, crossIcon, disabled = false, onSearch, onSelectSuggestion, suggestions, placeholder, className = {}, }) => {
|
|
9345
9345
|
const [query, setQuery] = useState("");
|
|
9346
9346
|
const [borderClass, setBorderClass] = useState("default-border");
|
|
9347
9347
|
const [timeoutId, setTimeoutId] = useState(null);
|
|
9348
|
-
const
|
|
9349
|
-
|
|
9348
|
+
const [filteredSuggestions, setFilteredSuggestions] = useState([]);
|
|
9349
|
+
const [showSuggestions, setShowSuggestions] = useState(false);
|
|
9350
|
+
const queryRef = useRef(query);
|
|
9350
9351
|
useEffect(() => {
|
|
9351
9352
|
queryRef.current = query;
|
|
9352
9353
|
}, [query]);
|
|
9353
9354
|
const handleChange = (e) => {
|
|
9354
9355
|
if (disabled)
|
|
9355
9356
|
return;
|
|
9356
|
-
|
|
9357
|
+
const value = e.target.value;
|
|
9358
|
+
setQuery(value);
|
|
9359
|
+
if (value.length < 3) {
|
|
9360
|
+
setBorderClass("default-border");
|
|
9361
|
+
setShowSuggestions(false);
|
|
9362
|
+
if (timeoutId)
|
|
9363
|
+
clearTimeout(timeoutId);
|
|
9364
|
+
return;
|
|
9365
|
+
}
|
|
9357
9366
|
setBorderClass("typing-border");
|
|
9358
9367
|
if (timeoutId)
|
|
9359
9368
|
clearTimeout(timeoutId);
|
|
9360
9369
|
const newTimeoutId = setTimeout(() => {
|
|
9361
9370
|
setBorderClass("stopped-border");
|
|
9362
9371
|
onSearch(queryRef.current);
|
|
9363
|
-
},
|
|
9372
|
+
}, 500);
|
|
9364
9373
|
setTimeoutId(newTimeoutId);
|
|
9374
|
+
if (suggestions && value) {
|
|
9375
|
+
const filtered = suggestions
|
|
9376
|
+
.filter((suggestion) => suggestion.title.toLowerCase().includes(value.toLowerCase()))
|
|
9377
|
+
.slice(0, 5);
|
|
9378
|
+
setFilteredSuggestions(filtered);
|
|
9379
|
+
setShowSuggestions(true);
|
|
9380
|
+
}
|
|
9381
|
+
else {
|
|
9382
|
+
setShowSuggestions(false);
|
|
9383
|
+
}
|
|
9365
9384
|
};
|
|
9366
9385
|
const handleClear = () => {
|
|
9367
9386
|
if (disabled)
|
|
9368
9387
|
return;
|
|
9369
9388
|
setQuery("");
|
|
9370
9389
|
setBorderClass("default-border");
|
|
9390
|
+
setShowSuggestions(false);
|
|
9391
|
+
onSelectSuggestion(null);
|
|
9392
|
+
};
|
|
9393
|
+
const handleSelectSuggestion = (suggestion) => {
|
|
9394
|
+
setQuery(suggestion.title);
|
|
9395
|
+
setShowSuggestions(false);
|
|
9396
|
+
onSelectSuggestion(suggestion);
|
|
9371
9397
|
};
|
|
9372
9398
|
useEffect(() => {
|
|
9373
9399
|
if (disabled) {
|
|
9374
9400
|
setQuery("");
|
|
9375
9401
|
setBorderClass("disabled-border");
|
|
9402
|
+
setShowSuggestions(false);
|
|
9376
9403
|
}
|
|
9377
9404
|
}, [disabled]);
|
|
9378
|
-
const classNames = `${className ??
|
|
9405
|
+
const classNames = `${className ?? ""}`;
|
|
9379
9406
|
return (React.createElement("div", { className: `search-field-container ${borderClass} ${classNames}` },
|
|
9380
9407
|
React.createElement("span", { className: "search-icon" }, searchIcon),
|
|
9381
9408
|
React.createElement("input", { type: "text", value: query, onChange: handleChange, disabled: disabled, className: "search-input", placeholder: placeholder }),
|
|
9382
|
-
query && !disabled && (React.createElement("span", { onClick: handleClear, className: "cross-icon" }, crossIcon))
|
|
9409
|
+
query && !disabled && (React.createElement("span", { onClick: handleClear, className: "cross-icon" }, crossIcon)),
|
|
9410
|
+
showSuggestions &&
|
|
9411
|
+
filteredSuggestions &&
|
|
9412
|
+
filteredSuggestions?.length > 0 && (React.createElement("div", { className: "suggestions-dropdown" }, filteredSuggestions?.map((suggestion) => {
|
|
9413
|
+
return (React.createElement(React.Fragment, null,
|
|
9414
|
+
React.createElement("button", { key: suggestion.id, onClick: () => handleSelectSuggestion(suggestion), className: "row" },
|
|
9415
|
+
searchIcon,
|
|
9416
|
+
React.createElement(Typography, { variant: "B4", weight: "SEMI_BOLD", className: "suggestion-item" }, suggestion.title)),
|
|
9417
|
+
React.createElement("div", { className: "underline" })));
|
|
9418
|
+
})))));
|
|
9383
9419
|
};
|
|
9384
9420
|
|
|
9385
9421
|
var css$1 = ".modal-overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background-color: rgba(0, 0, 0, 0.6);\n display: flex;\n justify-content: center;\n align-items: center;\n z-index: 1000;\n}\n\n.modal-container {\n background-color: white;\n padding: 40px;\n border-radius: 20px;\n width: 560px;\n max-width: 560px;\n box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);\n position: relative;\n transition: transform 0.3s ease, opacity 0.3s ease;\n}\n@media (min-width: 768px) {\n .modal-container {\n width: 80%;\n }\n}\n@media (min-width: 1024px) {\n .modal-container {\n width: 60%;\n }\n}\n\n.modal-header {\n font-size: 1.5rem;\n font-weight: bold;\n margin-bottom: 15px;\n}\n\n.modal-content {\n margin-bottom: 20px;\n}\n\n.modal-close {\n position: absolute;\n top: 40px;\n right: 40px;\n background: none;\n border: none;\n font-size: 1.5rem;\n cursor: pointer;\n}\n\n@media (max-width: 767px) {\n .modal-container {\n width: 95%;\n }\n}";
|
|
@@ -9409,8 +9445,8 @@ const Modal = ({ isOpen, onClose, title, children, crossIcon }) => {
|
|
|
9409
9445
|
var css = ".accordion {\n padding: 10px;\n cursor: pointer;\n display: flex;\n flex-direction: column;\n}\n.accordion.with-border {\n border: 1px solid #CECECE;\n padding: 24px 16px 24px 16px;\n border-radius: 16px;\n}\n.accordion.without-border {\n border-bottom: 1px solid #686868;\n padding: 16px 0px 16px 0px;\n margin-top: 16px;\n}\n.accordion .accordion-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n.accordion .accordion-header .accordion-icon {\n margin-right: 10px;\n}\n.accordion .accordion-header .accordion-text {\n display: flex;\n flex-direction: column;\n}\n.accordion .accordion-header .accordian-arrow {\n display: flex;\n justify-content: flex-end;\n}\n.accordion .accordion-content {\n padding: 16px 4px 16px 4px;\n}";
|
|
9410
9446
|
n(css,{});
|
|
9411
9447
|
|
|
9412
|
-
const Accordion = ({ icon, title, description, children, border = false, upArrowIcon, downArrowIcon }) => {
|
|
9413
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
9448
|
+
const Accordion = ({ icon, title, description, children, border = false, upArrowIcon, downArrowIcon, openByDefault }) => {
|
|
9449
|
+
const [isOpen, setIsOpen] = useState(openByDefault ? true : false);
|
|
9414
9450
|
const toggleAccordion = () => {
|
|
9415
9451
|
setIsOpen(!isOpen);
|
|
9416
9452
|
};
|