bianic-ui 1.16.0-beta.0 → 1.16.0-beta.1
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/cjs/index.js +110 -92
- package/dist/cjs/types/components/Forms/Dropdown/DropdownContainer.d.ts +1 -1
- package/dist/cjs/types/components/Forms/LiveSearch/Example/CustomDropdown.d.ts +1 -2
- package/dist/cjs/types/components/Forms/LiveSearch/Example/DeprecatedSimulation.d.ts +4 -0
- package/dist/cjs/types/components/Forms/LiveSearch/hooks/useLiveSearch.d.ts +9 -0
- package/dist/cjs/types/components/Forms/LiveSearch/index.d.ts +2 -6
- package/dist/cjs/types/components/Forms/LiveSearch/types/index.d.ts +36 -0
- package/dist/cjs/types/components/Forms/LiveSearch/utils/dropdownUtils.d.ts +8 -0
- package/dist/cjs/types/components/Forms/LiveSearch/utils/searchUtils.d.ts +3 -0
- package/dist/cjs/types/components/InfoPanel/index.d.ts +3 -3
- package/dist/cjs/types/components/Tab/Tab.d.ts +2 -1
- package/dist/{esm/types/stories/Form/LiveSearch/LivesearchOld.stories.d.ts → cjs/types/stories/Form/LiveSearch/DeprecatedSimulation.stories.d.ts} +2 -2
- package/dist/cjs/types/stories/Form/LiveSearch/LivesearchCustomDropdownExample.stories.d.ts +4 -3
- package/dist/esm/index.js +111 -93
- package/dist/esm/types/components/Forms/Dropdown/DropdownContainer.d.ts +1 -1
- package/dist/esm/types/components/Forms/LiveSearch/Example/CustomDropdown.d.ts +1 -2
- package/dist/esm/types/components/Forms/LiveSearch/Example/DeprecatedSimulation.d.ts +4 -0
- package/dist/esm/types/components/Forms/LiveSearch/hooks/useLiveSearch.d.ts +9 -0
- package/dist/esm/types/components/Forms/LiveSearch/index.d.ts +2 -6
- package/dist/esm/types/components/Forms/LiveSearch/types/index.d.ts +36 -0
- package/dist/esm/types/components/Forms/LiveSearch/utils/dropdownUtils.d.ts +8 -0
- package/dist/esm/types/components/Forms/LiveSearch/utils/searchUtils.d.ts +3 -0
- package/dist/esm/types/components/InfoPanel/index.d.ts +3 -3
- package/dist/esm/types/components/Tab/Tab.d.ts +2 -1
- package/dist/{cjs/types/stories/Form/LiveSearch/LivesearchOld.stories.d.ts → esm/types/stories/Form/LiveSearch/DeprecatedSimulation.stories.d.ts} +2 -2
- package/dist/esm/types/stories/Form/LiveSearch/LivesearchCustomDropdownExample.stories.d.ts +4 -3
- package/dist/index.d.ts +21 -20
- package/package.json +1 -1
- package/dist/cjs/types/components/Forms/LiveSearch/PropsInterface.d.ts +0 -23
- package/dist/cjs/types/components/Forms/LiveSearch/Simulation.d.ts +0 -4
- package/dist/esm/types/components/Forms/LiveSearch/PropsInterface.d.ts +0 -23
- package/dist/esm/types/components/Forms/LiveSearch/Simulation.d.ts +0 -4
package/dist/cjs/index.js
CHANGED
|
@@ -2520,111 +2520,129 @@ var matchSearchTerm = function (content, term, variant) {
|
|
|
2520
2520
|
return lowerContent.includes(lowerTerm);
|
|
2521
2521
|
}
|
|
2522
2522
|
};
|
|
2523
|
-
function
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
var _o = React.useState(value.label || ''), searchTerm = _o[0], setSearchTerm = _o[1];
|
|
2527
|
-
var _p = sizeConfig$6[size], iconClass = _p.iconClass, iconSize = _p.iconSize, inputClass = _p.inputClass;
|
|
2528
|
-
var dropContClassName = dropContProps.className, dropContOnClickItem = dropContProps.onClickItem, restDropContProps = __rest(dropContProps, ["className", "onClickItem"]);
|
|
2529
|
-
var isValueExist = value && value.label !== undefined && value.label !== '';
|
|
2530
|
-
var inputRef = React.useRef(null);
|
|
2531
|
-
var dropdownContRef = React.useRef(null);
|
|
2532
|
-
// Will be used soon
|
|
2533
|
-
// const handleOutsideClick = (e: MouseEvent) => {
|
|
2534
|
-
// if (inputRef.current && !inputRef.current.contains(e.target as Node)) {
|
|
2535
|
-
// setIsOpen(false)
|
|
2536
|
-
// }
|
|
2537
|
-
// }
|
|
2538
|
-
// useEffect(() => {
|
|
2539
|
-
// document.addEventListener('mousedown', handleOutsideClick)
|
|
2540
|
-
// return () => {
|
|
2541
|
-
// document.removeEventListener('mousedown', handleOutsideClick)
|
|
2542
|
-
// }
|
|
2543
|
-
// })
|
|
2544
|
-
// Synchronize internal searchTerm with external value prop
|
|
2545
|
-
React.useEffect(function () {
|
|
2546
|
-
// Only update searchTerm if the label from the value prop differs from the current searchTerm
|
|
2547
|
-
// This prevents infinite loops if searchTerm is already the same as value.label
|
|
2548
|
-
if (value.label !== searchTerm) {
|
|
2549
|
-
setSearchTerm(value.label || '');
|
|
2550
|
-
}
|
|
2551
|
-
}, [value.label, searchTerm]);
|
|
2552
|
-
var filteredOptions = options === null || options === void 0 ? void 0 : options.filter(function (item) {
|
|
2553
|
-
return item.label.toLowerCase().includes(value.label.toLowerCase());
|
|
2523
|
+
var filterOptions = function (options, searchTerm) {
|
|
2524
|
+
return options === null || options === void 0 ? void 0 : options.filter(function (item) {
|
|
2525
|
+
return item.label.toLowerCase().includes(searchTerm.toLowerCase());
|
|
2554
2526
|
});
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
var
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
}
|
|
2527
|
+
};
|
|
2528
|
+
|
|
2529
|
+
var getItemLabel = function (value) {
|
|
2530
|
+
var _a;
|
|
2531
|
+
return typeof value === 'object' && value !== null && 'label' in value
|
|
2532
|
+
? (_a = value.label) !== null && _a !== void 0 ? _a : ''
|
|
2533
|
+
: String(value !== null && value !== void 0 ? value : '');
|
|
2534
|
+
};
|
|
2535
|
+
var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNoSearch, searchVariant, handleDropdownItemClick) {
|
|
2536
|
+
if (searchVariant === void 0) { searchVariant = 'include'; }
|
|
2537
|
+
return React.Children.map(nodes, function (child) {
|
|
2538
|
+
if (!React.isValidElement(child) || child.type !== DropdownItem) {
|
|
2539
|
+
return child;
|
|
2540
|
+
}
|
|
2541
|
+
var itemProps = child.props;
|
|
2542
|
+
var itemContent = typeof itemProps.content === 'string' ? itemProps.content : '';
|
|
2543
|
+
var itemValue = itemProps.value;
|
|
2544
|
+
var isDisabled = itemProps.disabled;
|
|
2545
|
+
// Filtering Logic
|
|
2546
|
+
if (!includeAllIfNoSearch) {
|
|
2547
|
+
var itemValueStr = typeof itemValue === 'object'
|
|
2548
|
+
? itemValue.label
|
|
2549
|
+
: String(itemValue || '');
|
|
2550
|
+
if (currentSearchTerm &&
|
|
2551
|
+
!matchSearchTerm(itemValueStr, currentSearchTerm, searchVariant)) {
|
|
2552
|
+
return null;
|
|
2582
2553
|
}
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
}
|
|
2596
|
-
if (dropContOnClickItem) {
|
|
2597
|
-
dropContOnClickItem(e, itemValue !== undefined ? itemValue : itemContent);
|
|
2554
|
+
}
|
|
2555
|
+
// Process Nested Children
|
|
2556
|
+
var clonedChildren = itemProps.children
|
|
2557
|
+
? processDropdownChildren(itemProps.children, currentSearchTerm, includeAllIfNoSearch, searchVariant, handleDropdownItemClick)
|
|
2558
|
+
: null;
|
|
2559
|
+
// Clone and Inject Click Handler
|
|
2560
|
+
return React.cloneElement(child, {
|
|
2561
|
+
onClick: function (e) {
|
|
2562
|
+
if (!isDisabled) {
|
|
2563
|
+
if (itemValue === undefined &&
|
|
2564
|
+
typeof itemProps.content === 'string') {
|
|
2565
|
+
return handleDropdownItemClick(e, itemContent);
|
|
2598
2566
|
}
|
|
2599
|
-
if (
|
|
2600
|
-
|
|
2567
|
+
if (typeof itemValue === 'object' || itemValue !== undefined) {
|
|
2568
|
+
return handleDropdownItemClick(e, itemValue);
|
|
2601
2569
|
}
|
|
2602
|
-
}
|
|
2603
|
-
|
|
2604
|
-
|
|
2570
|
+
}
|
|
2571
|
+
if (itemProps.onClickItem) {
|
|
2572
|
+
itemProps.onClickItem(e, itemValue !== undefined ? itemValue : itemContent);
|
|
2573
|
+
}
|
|
2574
|
+
},
|
|
2575
|
+
children: clonedChildren,
|
|
2605
2576
|
});
|
|
2606
|
-
};
|
|
2607
|
-
|
|
2577
|
+
});
|
|
2578
|
+
};
|
|
2579
|
+
var processRenderedChildren = function (children, searchTerm, searchVariant, handleDropdownItemClick) {
|
|
2608
2580
|
var renderedChildren = null;
|
|
2609
2581
|
var hasFilteredResults = false;
|
|
2610
2582
|
if (searchTerm) {
|
|
2611
|
-
|
|
2612
|
-
renderedChildren = processDropdownChildren(children, searchTerm, false);
|
|
2583
|
+
renderedChildren = processDropdownChildren(children, searchTerm, false, searchVariant, handleDropdownItemClick);
|
|
2613
2584
|
hasFilteredResults =
|
|
2614
2585
|
React.Children.toArray(renderedChildren).filter(Boolean).length > 0;
|
|
2615
2586
|
}
|
|
2616
2587
|
else {
|
|
2617
|
-
|
|
2618
|
-
renderedChildren = processDropdownChildren(children, '', true);
|
|
2588
|
+
renderedChildren = processDropdownChildren(children, '', true, searchVariant, handleDropdownItemClick);
|
|
2619
2589
|
hasFilteredResults =
|
|
2620
|
-
React.Children.toArray(renderedChildren).filter(Boolean).length > 0;
|
|
2590
|
+
React.Children.toArray(renderedChildren).filter(Boolean).length > 0;
|
|
2621
2591
|
}
|
|
2592
|
+
return { renderedChildren: renderedChildren, hasFilteredResults: hasFilteredResults };
|
|
2593
|
+
};
|
|
2594
|
+
|
|
2595
|
+
var useLiveSearch = function (_a) {
|
|
2596
|
+
var value = _a.value, setValue = _a.setValue, onChangeText = _a.onChangeText, dropContOnClickItem = _a.dropContOnClickItem;
|
|
2597
|
+
var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
2598
|
+
var _c = React.useState(String(value.label || '')), searchTerm = _c[0], setSearchTerm = _c[1];
|
|
2599
|
+
React.useEffect(function () {
|
|
2600
|
+
if (!isOpen && searchTerm !== '') {
|
|
2601
|
+
setSearchTerm(getItemLabel(value));
|
|
2602
|
+
}
|
|
2603
|
+
}, [isOpen]);
|
|
2604
|
+
var handleInputChange = function (e) {
|
|
2605
|
+
var newSearchTerm = e.target.value;
|
|
2606
|
+
setSearchTerm(newSearchTerm);
|
|
2607
|
+
setIsOpen(true);
|
|
2608
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(e);
|
|
2609
|
+
};
|
|
2610
|
+
var handleDropdownItemClick = React.useCallback(function (event, clickedValue) {
|
|
2611
|
+
dropContOnClickItem === null || dropContOnClickItem === void 0 ? void 0 : dropContOnClickItem(event, clickedValue);
|
|
2612
|
+
var newLabel = getItemLabel(clickedValue);
|
|
2613
|
+
setSearchTerm(newLabel);
|
|
2614
|
+
setValue(clickedValue);
|
|
2615
|
+
setIsOpen(false);
|
|
2616
|
+
}, [setValue, dropContOnClickItem]);
|
|
2617
|
+
return {
|
|
2618
|
+
isOpen: isOpen,
|
|
2619
|
+
setIsOpen: setIsOpen,
|
|
2620
|
+
searchTerm: searchTerm,
|
|
2621
|
+
handleInputChange: handleInputChange,
|
|
2622
|
+
handleDropdownItemClick: handleDropdownItemClick,
|
|
2623
|
+
};
|
|
2624
|
+
};
|
|
2625
|
+
|
|
2626
|
+
function LiveSearch(_a) {
|
|
2627
|
+
var _b = _a.autoComplete, autoComplete = _b === void 0 ? 'off' : _b, _c = _a.children, children = _c === void 0 ? undefined : _c, descText = _a.descText, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.dropContProps, dropContProps = _e === void 0 ? { className: undefined } : _e, id = _a.id, label = _a.label, _f = _a.onChangeText, onChangeText = _f === void 0 ? function () { } : _f, _g = _a.onClickDropdown, onClickDropdown = _g === void 0 ? function () { } : _g, options = _a.options, placeholder = _a.placeholder, _h = _a.readOnly, readOnly = _h === void 0 ? false : _h, _j = _a.required, required = _j === void 0 ? false : _j, _k = _a.searchVariant, searchVariant = _k === void 0 ? 'include' : _k, setValue = _a.setValue, _l = _a.size, size = _l === void 0 ? 'md' : _l, value = _a.value;
|
|
2628
|
+
var inputRef = React.useRef(null);
|
|
2629
|
+
var dropdownContRef = React.useRef(null);
|
|
2630
|
+
var _m = useLiveSearch({
|
|
2631
|
+
value: value,
|
|
2632
|
+
setValue: setValue,
|
|
2633
|
+
onChangeText: onChangeText,
|
|
2634
|
+
dropContOnClickItem: dropContProps.onClickItem
|
|
2635
|
+
}), isOpen = _m.isOpen, setIsOpen = _m.setIsOpen, searchTerm = _m.searchTerm, handleInputChange = _m.handleInputChange, handleDropdownItemClick = _m.handleDropdownItemClick;
|
|
2636
|
+
var _o = sizeConfig$6[size], iconClass = _o.iconClass, iconSize = _o.iconSize, inputClass = _o.inputClass;
|
|
2637
|
+
var dropContClassName = dropContProps.className; dropContProps.onClickItem; var restDropContProps = __rest(dropContProps, ["className", "onClickItem"]);
|
|
2638
|
+
var isValueExist = value && value.label !== undefined && value.label !== '';
|
|
2639
|
+
var filteredOptions = filterOptions(options || [], value.label);
|
|
2640
|
+
var _p = processRenderedChildren(children, searchTerm, searchVariant, handleDropdownItemClick), renderedChildren = _p.renderedChildren, hasFilteredResults = _p.hasFilteredResults;
|
|
2622
2641
|
return (React.createElement("div", { className: "bianic-livesearch field-group group/form flex w-full flex-col gap-y-2 " },
|
|
2623
2642
|
label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
|
|
2624
2643
|
React.createElement("div", { className: "group relative w-full" },
|
|
2625
2644
|
React.createElement("input", { className: "bianic-livesearch-input field peer w-full rounded border border-bia-grey-dark-10 bg-primary-white read-only:pointer-events-none read-only:border-bia-grey-disabled focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-10 disabled:text-bia-coolgrey ".concat(inputClass), onClick: function () { return setIsOpen(!isOpen); }, value: searchTerm, required: required, disabled: disabled, id: id, placeholder: placeholder, ref: inputRef, onChange: function (e) {
|
|
2626
2645
|
onChangeText(e);
|
|
2627
|
-
setValue({ id: null, label: e.target.value });
|
|
2628
2646
|
handleInputChange(e);
|
|
2629
2647
|
}, type: "text", readOnly: readOnly, autoComplete: autoComplete }),
|
|
2630
2648
|
React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 ".concat(iconClass) },
|
|
@@ -3340,18 +3358,17 @@ var sizeConfig$3 = {
|
|
|
3340
3358
|
};
|
|
3341
3359
|
|
|
3342
3360
|
var InfoPanel = function (_a) {
|
|
3343
|
-
var variant = _a.variant, color = _a.color, className = _a.className,
|
|
3361
|
+
var variant = _a.variant, color = _a.color, className = _a.className, children = _a.children;
|
|
3344
3362
|
var sizeClass = sizeConfig$3[variant || 'container'];
|
|
3345
3363
|
var colorClass = colorConfig$1[color || 'yellow'];
|
|
3346
3364
|
var allClasses = "".concat(sizeClass, " ").concat(colorClass, " ").concat(className);
|
|
3347
|
-
return (React.createElement("div", { className: "flex items-center justify-center rounded-radius-md ".concat(allClasses) },
|
|
3348
|
-
React.createElement(Text, { variant: "medium-text", extended: textClassName }, "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")));
|
|
3365
|
+
return (React.createElement("div", { className: "flex items-center justify-center rounded-radius-md ".concat(allClasses) }, children));
|
|
3349
3366
|
};
|
|
3350
3367
|
InfoPanel.defaultProps = {
|
|
3351
3368
|
variant: 'container',
|
|
3352
3369
|
color: 'yellow',
|
|
3353
3370
|
className: '',
|
|
3354
|
-
|
|
3371
|
+
children: null,
|
|
3355
3372
|
};
|
|
3356
3373
|
|
|
3357
3374
|
function Modal(_a) {
|
|
@@ -3756,7 +3773,7 @@ var configTab = {
|
|
|
3756
3773
|
};
|
|
3757
3774
|
|
|
3758
3775
|
function Tab(_a) {
|
|
3759
|
-
var children = _a.children, active = _a.active, icon = _a.icon, disabled = _a.disabled, _b = _a.mode, mode = _b === void 0 ? 'horizontal' : _b, _c = _a.fit, fit = _c === void 0 ? 'fit-content' : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, rest = __rest(_a, ["children", "active", "icon", "disabled", "mode", "fit", "size"]);
|
|
3776
|
+
var children = _a.children, active = _a.active, icon = _a.icon, disabled = _a.disabled, _b = _a.mode, mode = _b === void 0 ? 'horizontal' : _b, _c = _a.fit, fit = _c === void 0 ? 'fit-content' : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, className = _a.className, rest = __rest(_a, ["children", "active", "icon", "disabled", "mode", "fit", "size", "className"]);
|
|
3760
3777
|
var disabledKeyTab = disabled || active ? ' pointer-events-none' : '';
|
|
3761
3778
|
var cursor;
|
|
3762
3779
|
if (disabled) {
|
|
@@ -3777,8 +3794,9 @@ function Tab(_a) {
|
|
|
3777
3794
|
var activeKeyTab = active
|
|
3778
3795
|
? 'group-disabled:text-bia-coolgrey-disabled text-primary-black'
|
|
3779
3796
|
: 'text-bia-coolgrey group-hover:text-bia-coolgrey-hover group-active:text-bia-coolgrey-active group-disabled:text-bia-coolgrey-disabled';
|
|
3797
|
+
var buttonClassName = "".concat(horizontalButtonStyle, " ").concat(disabledKeyTab, " ").concat(fit, " ").concat(className ? className : '');
|
|
3780
3798
|
return (React.createElement("div", { className: "".concat(mode === 'horizontal' ? 'h-full' : 'w-full', " ").concat(cursor) },
|
|
3781
|
-
React.createElement("button", __assign({ type: "button",
|
|
3799
|
+
React.createElement("button", __assign({ type: "button", className: "flex items-stretch justify-between group relative outline-none ".concat(buttonClassName), disabled: disabled }, rest),
|
|
3782
3800
|
React.createElement("div", { className: "flex items-center justify-center ".concat(buttonContentStyle) },
|
|
3783
3801
|
React.createElement("div", { className: "flex items-center justify-center " },
|
|
3784
3802
|
React.createElement("div", { className: "flex items-center space-x-1 text-nowrap ".concat(activeKeyTab, " ").concat(configTab[size].text) },
|
|
@@ -9,7 +9,7 @@ export interface DropdownContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
9
9
|
size?: 'sm' | 'md';
|
|
10
10
|
zIndex?: number;
|
|
11
11
|
anchorRef?: React.RefObject<HTMLElement>;
|
|
12
|
-
onClickItem?: (event: React.MouseEvent<HTMLDivElement>, val: string | number) => void;
|
|
12
|
+
onClickItem?: (event: React.MouseEvent<HTMLDivElement>, val: string | number | object) => void;
|
|
13
13
|
}
|
|
14
14
|
declare const DropdownContainer: {
|
|
15
15
|
(propsComp: DropdownContainerProps): React.JSX.Element | null;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
declare const LiveSearchExample: ({ ...props }: LiveSearchProps) => React.JSX.Element;
|
|
2
|
+
declare const LiveSearchExample: ({ children, ...props }: LiveSearchProps) => React.JSX.Element;
|
|
4
3
|
export default LiveSearchExample;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChangeEvent, MouseEvent } from 'react';
|
|
2
|
+
import { LiveSearchHookProps } from '../types';
|
|
3
|
+
export declare const useLiveSearch: ({ value, setValue, onChangeText, dropContOnClickItem, }: LiveSearchHookProps) => {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
setIsOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
6
|
+
searchTerm: string;
|
|
7
|
+
handleInputChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
handleDropdownItemClick: (event: MouseEvent<HTMLDivElement>, clickedValue: any) => void;
|
|
9
|
+
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import LiveSearchProps from './
|
|
3
|
-
|
|
4
|
-
id: string | number | null;
|
|
5
|
-
label: string | number;
|
|
6
|
-
}
|
|
7
|
-
declare function LiveSearch({ descText, disabled, id, size, label, placeholder, required, options, setValue, value, readOnly, onChangeText, onClickDropdown, autoComplete, children, dropContProps, searchVariant, }: LiveSearchProps): React.JSX.Element;
|
|
2
|
+
import { LiveSearchProps } from './types';
|
|
3
|
+
declare function LiveSearch({ autoComplete, children, descText, disabled, dropContProps, id, label, onChangeText, onClickDropdown, options, placeholder, readOnly, required, searchVariant, setValue, size, value, }: LiveSearchProps): React.JSX.Element;
|
|
8
4
|
declare namespace LiveSearch {
|
|
9
5
|
var defaultProps: {
|
|
10
6
|
descText: string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, MouseEvent, ChangeEvent, ReactNode } from 'react';
|
|
2
|
+
import { DropdownContainerProps } from '../../Dropdown/DropdownContainer';
|
|
3
|
+
export type SearchVariant = 'include' | 'startsWith' | 'endsWith';
|
|
4
|
+
export interface LiveSearchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size' | 'value'> {
|
|
5
|
+
autoComplete?: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
descText?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
dropContProps?: Omit<DropdownContainerProps, 'children'>;
|
|
10
|
+
id?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
onChangeText?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
13
|
+
onClickDropdown?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
14
|
+
options?: any[];
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
searchVariant?: SearchVariant;
|
|
19
|
+
setValue: (value: any) => void;
|
|
20
|
+
size?: 'md' | 'sm';
|
|
21
|
+
value: any;
|
|
22
|
+
}
|
|
23
|
+
export interface LiveSearchHookProps {
|
|
24
|
+
value: any;
|
|
25
|
+
setValue: (value: any) => void;
|
|
26
|
+
onChangeText?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
27
|
+
dropContOnClickItem?: (event: MouseEvent<HTMLDivElement>, value: any) => void;
|
|
28
|
+
searchVariant?: SearchVariant;
|
|
29
|
+
}
|
|
30
|
+
export interface DropdownItemProps {
|
|
31
|
+
content: string | ReactNode;
|
|
32
|
+
value?: any;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
onClickItem?: (event: MouseEvent<HTMLDivElement>, value: any) => void;
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SearchVariant } from '../types';
|
|
3
|
+
export declare const getItemLabel: (value: any) => string;
|
|
4
|
+
export declare const processDropdownChildren: (nodes: React.ReactNode, currentSearchTerm: string, includeAllIfNoSearch: boolean, searchVariant: SearchVariant | undefined, handleDropdownItemClick: (e: React.MouseEvent<HTMLDivElement>, value: any) => void) => React.ReactNode;
|
|
5
|
+
export declare const processRenderedChildren: (children: React.ReactNode | undefined, searchTerm: string, searchVariant: SearchVariant, handleDropdownItemClick: (e: React.MouseEvent<HTMLDivElement>, value: any) => void) => {
|
|
6
|
+
renderedChildren: React.ReactNode;
|
|
7
|
+
hasFilteredResults: boolean;
|
|
8
|
+
};
|
|
@@ -3,15 +3,15 @@ interface InfoPanelProps {
|
|
|
3
3
|
variant?: 'container' | 'form-sm' | 'form-md';
|
|
4
4
|
color?: 'yellow' | 'blue' | 'grey' | 'white';
|
|
5
5
|
className?: string;
|
|
6
|
-
|
|
6
|
+
children: React.ReactNode;
|
|
7
7
|
}
|
|
8
8
|
declare const InfoPanel: {
|
|
9
|
-
({ variant, color, className,
|
|
9
|
+
({ variant, color, className, children, }: InfoPanelProps): React.JSX.Element;
|
|
10
10
|
defaultProps: {
|
|
11
11
|
variant: string;
|
|
12
12
|
color: string;
|
|
13
13
|
className: string;
|
|
14
|
-
|
|
14
|
+
children: null;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
export default InfoPanel;
|
|
@@ -6,5 +6,6 @@ export interface TabProps extends ComponentPropsWithoutRef<'button'> {
|
|
|
6
6
|
mode?: 'horizontal' | 'vertical';
|
|
7
7
|
fit?: 'fit-content' | 'maximize';
|
|
8
8
|
size?: 'md' | 'sm';
|
|
9
|
+
className?: string;
|
|
9
10
|
}
|
|
10
|
-
export default function Tab({ children, active, icon, disabled, mode, fit, size, ...rest }: TabProps): React.JSX.Element;
|
|
11
|
+
export default function Tab({ children, active, icon, disabled, mode, fit, size, className, ...rest }: TabProps): React.JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
import
|
|
2
|
+
import DeprecatedSimulation from '../../../components/Forms/LiveSearch/Example/DeprecatedSimulation';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: typeof
|
|
5
|
+
component: typeof DeprecatedSimulation;
|
|
6
6
|
parameters: {
|
|
7
7
|
layout: string;
|
|
8
8
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { StoryObj } from "@storybook/react/*";
|
|
2
|
+
import React from "react";
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ ...props }:
|
|
5
|
+
component: ({ children, ...props }: LiveSearchProps) => React.JSX.Element;
|
|
6
6
|
parameters: {
|
|
7
7
|
layout: string;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
export default meta;
|
|
11
11
|
type Story = StoryObj<typeof meta>;
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const BasicExample: Story;
|
|
13
|
+
export declare const ObjectOptionsExample: Story;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, forwardRef, useRef, cloneElement, Children, useLayoutEffect,
|
|
1
|
+
import React, { useState, useEffect, forwardRef, useRef, cloneElement, Children, useLayoutEffect, isValidElement, useCallback } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
|
|
4
4
|
function Accordions(_a) {
|
|
@@ -2518,111 +2518,129 @@ var matchSearchTerm = function (content, term, variant) {
|
|
|
2518
2518
|
return lowerContent.includes(lowerTerm);
|
|
2519
2519
|
}
|
|
2520
2520
|
};
|
|
2521
|
-
function
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
var _o = useState(value.label || ''), searchTerm = _o[0], setSearchTerm = _o[1];
|
|
2525
|
-
var _p = sizeConfig$6[size], iconClass = _p.iconClass, iconSize = _p.iconSize, inputClass = _p.inputClass;
|
|
2526
|
-
var dropContClassName = dropContProps.className, dropContOnClickItem = dropContProps.onClickItem, restDropContProps = __rest(dropContProps, ["className", "onClickItem"]);
|
|
2527
|
-
var isValueExist = value && value.label !== undefined && value.label !== '';
|
|
2528
|
-
var inputRef = useRef(null);
|
|
2529
|
-
var dropdownContRef = useRef(null);
|
|
2530
|
-
// Will be used soon
|
|
2531
|
-
// const handleOutsideClick = (e: MouseEvent) => {
|
|
2532
|
-
// if (inputRef.current && !inputRef.current.contains(e.target as Node)) {
|
|
2533
|
-
// setIsOpen(false)
|
|
2534
|
-
// }
|
|
2535
|
-
// }
|
|
2536
|
-
// useEffect(() => {
|
|
2537
|
-
// document.addEventListener('mousedown', handleOutsideClick)
|
|
2538
|
-
// return () => {
|
|
2539
|
-
// document.removeEventListener('mousedown', handleOutsideClick)
|
|
2540
|
-
// }
|
|
2541
|
-
// })
|
|
2542
|
-
// Synchronize internal searchTerm with external value prop
|
|
2543
|
-
useEffect(function () {
|
|
2544
|
-
// Only update searchTerm if the label from the value prop differs from the current searchTerm
|
|
2545
|
-
// This prevents infinite loops if searchTerm is already the same as value.label
|
|
2546
|
-
if (value.label !== searchTerm) {
|
|
2547
|
-
setSearchTerm(value.label || '');
|
|
2548
|
-
}
|
|
2549
|
-
}, [value.label, searchTerm]);
|
|
2550
|
-
var filteredOptions = options === null || options === void 0 ? void 0 : options.filter(function (item) {
|
|
2551
|
-
return item.label.toLowerCase().includes(value.label.toLowerCase());
|
|
2521
|
+
var filterOptions = function (options, searchTerm) {
|
|
2522
|
+
return options === null || options === void 0 ? void 0 : options.filter(function (item) {
|
|
2523
|
+
return item.label.toLowerCase().includes(searchTerm.toLowerCase());
|
|
2552
2524
|
});
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
var
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
}
|
|
2525
|
+
};
|
|
2526
|
+
|
|
2527
|
+
var getItemLabel = function (value) {
|
|
2528
|
+
var _a;
|
|
2529
|
+
return typeof value === 'object' && value !== null && 'label' in value
|
|
2530
|
+
? (_a = value.label) !== null && _a !== void 0 ? _a : ''
|
|
2531
|
+
: String(value !== null && value !== void 0 ? value : '');
|
|
2532
|
+
};
|
|
2533
|
+
var processDropdownChildren = function (nodes, currentSearchTerm, includeAllIfNoSearch, searchVariant, handleDropdownItemClick) {
|
|
2534
|
+
if (searchVariant === void 0) { searchVariant = 'include'; }
|
|
2535
|
+
return Children.map(nodes, function (child) {
|
|
2536
|
+
if (!isValidElement(child) || child.type !== DropdownItem) {
|
|
2537
|
+
return child;
|
|
2538
|
+
}
|
|
2539
|
+
var itemProps = child.props;
|
|
2540
|
+
var itemContent = typeof itemProps.content === 'string' ? itemProps.content : '';
|
|
2541
|
+
var itemValue = itemProps.value;
|
|
2542
|
+
var isDisabled = itemProps.disabled;
|
|
2543
|
+
// Filtering Logic
|
|
2544
|
+
if (!includeAllIfNoSearch) {
|
|
2545
|
+
var itemValueStr = typeof itemValue === 'object'
|
|
2546
|
+
? itemValue.label
|
|
2547
|
+
: String(itemValue || '');
|
|
2548
|
+
if (currentSearchTerm &&
|
|
2549
|
+
!matchSearchTerm(itemValueStr, currentSearchTerm, searchVariant)) {
|
|
2550
|
+
return null;
|
|
2580
2551
|
}
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
}
|
|
2594
|
-
if (dropContOnClickItem) {
|
|
2595
|
-
dropContOnClickItem(e, itemValue !== undefined ? itemValue : itemContent);
|
|
2552
|
+
}
|
|
2553
|
+
// Process Nested Children
|
|
2554
|
+
var clonedChildren = itemProps.children
|
|
2555
|
+
? processDropdownChildren(itemProps.children, currentSearchTerm, includeAllIfNoSearch, searchVariant, handleDropdownItemClick)
|
|
2556
|
+
: null;
|
|
2557
|
+
// Clone and Inject Click Handler
|
|
2558
|
+
return cloneElement(child, {
|
|
2559
|
+
onClick: function (e) {
|
|
2560
|
+
if (!isDisabled) {
|
|
2561
|
+
if (itemValue === undefined &&
|
|
2562
|
+
typeof itemProps.content === 'string') {
|
|
2563
|
+
return handleDropdownItemClick(e, itemContent);
|
|
2596
2564
|
}
|
|
2597
|
-
if (
|
|
2598
|
-
|
|
2565
|
+
if (typeof itemValue === 'object' || itemValue !== undefined) {
|
|
2566
|
+
return handleDropdownItemClick(e, itemValue);
|
|
2599
2567
|
}
|
|
2600
|
-
}
|
|
2601
|
-
|
|
2602
|
-
|
|
2568
|
+
}
|
|
2569
|
+
if (itemProps.onClickItem) {
|
|
2570
|
+
itemProps.onClickItem(e, itemValue !== undefined ? itemValue : itemContent);
|
|
2571
|
+
}
|
|
2572
|
+
},
|
|
2573
|
+
children: clonedChildren,
|
|
2603
2574
|
});
|
|
2604
|
-
};
|
|
2605
|
-
|
|
2575
|
+
});
|
|
2576
|
+
};
|
|
2577
|
+
var processRenderedChildren = function (children, searchTerm, searchVariant, handleDropdownItemClick) {
|
|
2606
2578
|
var renderedChildren = null;
|
|
2607
2579
|
var hasFilteredResults = false;
|
|
2608
2580
|
if (searchTerm) {
|
|
2609
|
-
|
|
2610
|
-
renderedChildren = processDropdownChildren(children, searchTerm, false);
|
|
2581
|
+
renderedChildren = processDropdownChildren(children, searchTerm, false, searchVariant, handleDropdownItemClick);
|
|
2611
2582
|
hasFilteredResults =
|
|
2612
2583
|
Children.toArray(renderedChildren).filter(Boolean).length > 0;
|
|
2613
2584
|
}
|
|
2614
2585
|
else {
|
|
2615
|
-
|
|
2616
|
-
renderedChildren = processDropdownChildren(children, '', true);
|
|
2586
|
+
renderedChildren = processDropdownChildren(children, '', true, searchVariant, handleDropdownItemClick);
|
|
2617
2587
|
hasFilteredResults =
|
|
2618
|
-
Children.toArray(renderedChildren).filter(Boolean).length > 0;
|
|
2588
|
+
Children.toArray(renderedChildren).filter(Boolean).length > 0;
|
|
2619
2589
|
}
|
|
2590
|
+
return { renderedChildren: renderedChildren, hasFilteredResults: hasFilteredResults };
|
|
2591
|
+
};
|
|
2592
|
+
|
|
2593
|
+
var useLiveSearch = function (_a) {
|
|
2594
|
+
var value = _a.value, setValue = _a.setValue, onChangeText = _a.onChangeText, dropContOnClickItem = _a.dropContOnClickItem;
|
|
2595
|
+
var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
2596
|
+
var _c = useState(String(value.label || '')), searchTerm = _c[0], setSearchTerm = _c[1];
|
|
2597
|
+
useEffect(function () {
|
|
2598
|
+
if (!isOpen && searchTerm !== '') {
|
|
2599
|
+
setSearchTerm(getItemLabel(value));
|
|
2600
|
+
}
|
|
2601
|
+
}, [isOpen]);
|
|
2602
|
+
var handleInputChange = function (e) {
|
|
2603
|
+
var newSearchTerm = e.target.value;
|
|
2604
|
+
setSearchTerm(newSearchTerm);
|
|
2605
|
+
setIsOpen(true);
|
|
2606
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(e);
|
|
2607
|
+
};
|
|
2608
|
+
var handleDropdownItemClick = useCallback(function (event, clickedValue) {
|
|
2609
|
+
dropContOnClickItem === null || dropContOnClickItem === void 0 ? void 0 : dropContOnClickItem(event, clickedValue);
|
|
2610
|
+
var newLabel = getItemLabel(clickedValue);
|
|
2611
|
+
setSearchTerm(newLabel);
|
|
2612
|
+
setValue(clickedValue);
|
|
2613
|
+
setIsOpen(false);
|
|
2614
|
+
}, [setValue, dropContOnClickItem]);
|
|
2615
|
+
return {
|
|
2616
|
+
isOpen: isOpen,
|
|
2617
|
+
setIsOpen: setIsOpen,
|
|
2618
|
+
searchTerm: searchTerm,
|
|
2619
|
+
handleInputChange: handleInputChange,
|
|
2620
|
+
handleDropdownItemClick: handleDropdownItemClick,
|
|
2621
|
+
};
|
|
2622
|
+
};
|
|
2623
|
+
|
|
2624
|
+
function LiveSearch(_a) {
|
|
2625
|
+
var _b = _a.autoComplete, autoComplete = _b === void 0 ? 'off' : _b, _c = _a.children, children = _c === void 0 ? undefined : _c, descText = _a.descText, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.dropContProps, dropContProps = _e === void 0 ? { className: undefined } : _e, id = _a.id, label = _a.label, _f = _a.onChangeText, onChangeText = _f === void 0 ? function () { } : _f, _g = _a.onClickDropdown, onClickDropdown = _g === void 0 ? function () { } : _g, options = _a.options, placeholder = _a.placeholder, _h = _a.readOnly, readOnly = _h === void 0 ? false : _h, _j = _a.required, required = _j === void 0 ? false : _j, _k = _a.searchVariant, searchVariant = _k === void 0 ? 'include' : _k, setValue = _a.setValue, _l = _a.size, size = _l === void 0 ? 'md' : _l, value = _a.value;
|
|
2626
|
+
var inputRef = useRef(null);
|
|
2627
|
+
var dropdownContRef = useRef(null);
|
|
2628
|
+
var _m = useLiveSearch({
|
|
2629
|
+
value: value,
|
|
2630
|
+
setValue: setValue,
|
|
2631
|
+
onChangeText: onChangeText,
|
|
2632
|
+
dropContOnClickItem: dropContProps.onClickItem
|
|
2633
|
+
}), isOpen = _m.isOpen, setIsOpen = _m.setIsOpen, searchTerm = _m.searchTerm, handleInputChange = _m.handleInputChange, handleDropdownItemClick = _m.handleDropdownItemClick;
|
|
2634
|
+
var _o = sizeConfig$6[size], iconClass = _o.iconClass, iconSize = _o.iconSize, inputClass = _o.inputClass;
|
|
2635
|
+
var dropContClassName = dropContProps.className; dropContProps.onClickItem; var restDropContProps = __rest(dropContProps, ["className", "onClickItem"]);
|
|
2636
|
+
var isValueExist = value && value.label !== undefined && value.label !== '';
|
|
2637
|
+
var filteredOptions = filterOptions(options || [], value.label);
|
|
2638
|
+
var _p = processRenderedChildren(children, searchTerm, searchVariant, handleDropdownItemClick), renderedChildren = _p.renderedChildren, hasFilteredResults = _p.hasFilteredResults;
|
|
2620
2639
|
return (React.createElement("div", { className: "bianic-livesearch field-group group/form flex w-full flex-col gap-y-2 " },
|
|
2621
2640
|
label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
|
|
2622
2641
|
React.createElement("div", { className: "group relative w-full" },
|
|
2623
2642
|
React.createElement("input", { className: "bianic-livesearch-input field peer w-full rounded border border-bia-grey-dark-10 bg-primary-white read-only:pointer-events-none read-only:border-bia-grey-disabled focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:border-bia-grey-dark-10 disabled:bg-bia-grey-light-10 disabled:text-bia-coolgrey ".concat(inputClass), onClick: function () { return setIsOpen(!isOpen); }, value: searchTerm, required: required, disabled: disabled, id: id, placeholder: placeholder, ref: inputRef, onChange: function (e) {
|
|
2624
2643
|
onChangeText(e);
|
|
2625
|
-
setValue({ id: null, label: e.target.value });
|
|
2626
2644
|
handleInputChange(e);
|
|
2627
2645
|
}, type: "text", readOnly: readOnly, autoComplete: autoComplete }),
|
|
2628
2646
|
React.createElement("div", { className: "absolute inset-y-0 flex items-center pl-3 ".concat(iconClass) },
|
|
@@ -3338,18 +3356,17 @@ var sizeConfig$3 = {
|
|
|
3338
3356
|
};
|
|
3339
3357
|
|
|
3340
3358
|
var InfoPanel = function (_a) {
|
|
3341
|
-
var variant = _a.variant, color = _a.color, className = _a.className,
|
|
3359
|
+
var variant = _a.variant, color = _a.color, className = _a.className, children = _a.children;
|
|
3342
3360
|
var sizeClass = sizeConfig$3[variant || 'container'];
|
|
3343
3361
|
var colorClass = colorConfig$1[color || 'yellow'];
|
|
3344
3362
|
var allClasses = "".concat(sizeClass, " ").concat(colorClass, " ").concat(className);
|
|
3345
|
-
return (React.createElement("div", { className: "flex items-center justify-center rounded-radius-md ".concat(allClasses) },
|
|
3346
|
-
React.createElement(Text, { variant: "medium-text", extended: textClassName }, "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")));
|
|
3363
|
+
return (React.createElement("div", { className: "flex items-center justify-center rounded-radius-md ".concat(allClasses) }, children));
|
|
3347
3364
|
};
|
|
3348
3365
|
InfoPanel.defaultProps = {
|
|
3349
3366
|
variant: 'container',
|
|
3350
3367
|
color: 'yellow',
|
|
3351
3368
|
className: '',
|
|
3352
|
-
|
|
3369
|
+
children: null,
|
|
3353
3370
|
};
|
|
3354
3371
|
|
|
3355
3372
|
function Modal(_a) {
|
|
@@ -3754,7 +3771,7 @@ var configTab = {
|
|
|
3754
3771
|
};
|
|
3755
3772
|
|
|
3756
3773
|
function Tab(_a) {
|
|
3757
|
-
var children = _a.children, active = _a.active, icon = _a.icon, disabled = _a.disabled, _b = _a.mode, mode = _b === void 0 ? 'horizontal' : _b, _c = _a.fit, fit = _c === void 0 ? 'fit-content' : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, rest = __rest(_a, ["children", "active", "icon", "disabled", "mode", "fit", "size"]);
|
|
3774
|
+
var children = _a.children, active = _a.active, icon = _a.icon, disabled = _a.disabled, _b = _a.mode, mode = _b === void 0 ? 'horizontal' : _b, _c = _a.fit, fit = _c === void 0 ? 'fit-content' : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, className = _a.className, rest = __rest(_a, ["children", "active", "icon", "disabled", "mode", "fit", "size", "className"]);
|
|
3758
3775
|
var disabledKeyTab = disabled || active ? ' pointer-events-none' : '';
|
|
3759
3776
|
var cursor;
|
|
3760
3777
|
if (disabled) {
|
|
@@ -3775,8 +3792,9 @@ function Tab(_a) {
|
|
|
3775
3792
|
var activeKeyTab = active
|
|
3776
3793
|
? 'group-disabled:text-bia-coolgrey-disabled text-primary-black'
|
|
3777
3794
|
: 'text-bia-coolgrey group-hover:text-bia-coolgrey-hover group-active:text-bia-coolgrey-active group-disabled:text-bia-coolgrey-disabled';
|
|
3795
|
+
var buttonClassName = "".concat(horizontalButtonStyle, " ").concat(disabledKeyTab, " ").concat(fit, " ").concat(className ? className : '');
|
|
3778
3796
|
return (React.createElement("div", { className: "".concat(mode === 'horizontal' ? 'h-full' : 'w-full', " ").concat(cursor) },
|
|
3779
|
-
React.createElement("button", __assign({ type: "button",
|
|
3797
|
+
React.createElement("button", __assign({ type: "button", className: "flex items-stretch justify-between group relative outline-none ".concat(buttonClassName), disabled: disabled }, rest),
|
|
3780
3798
|
React.createElement("div", { className: "flex items-center justify-center ".concat(buttonContentStyle) },
|
|
3781
3799
|
React.createElement("div", { className: "flex items-center justify-center " },
|
|
3782
3800
|
React.createElement("div", { className: "flex items-center space-x-1 text-nowrap ".concat(activeKeyTab, " ").concat(configTab[size].text) },
|
|
@@ -9,7 +9,7 @@ export interface DropdownContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
9
9
|
size?: 'sm' | 'md';
|
|
10
10
|
zIndex?: number;
|
|
11
11
|
anchorRef?: React.RefObject<HTMLElement>;
|
|
12
|
-
onClickItem?: (event: React.MouseEvent<HTMLDivElement>, val: string | number) => void;
|
|
12
|
+
onClickItem?: (event: React.MouseEvent<HTMLDivElement>, val: string | number | object) => void;
|
|
13
13
|
}
|
|
14
14
|
declare const DropdownContainer: {
|
|
15
15
|
(propsComp: DropdownContainerProps): React.JSX.Element | null;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
declare const LiveSearchExample: ({ ...props }: LiveSearchProps) => React.JSX.Element;
|
|
2
|
+
declare const LiveSearchExample: ({ children, ...props }: LiveSearchProps) => React.JSX.Element;
|
|
4
3
|
export default LiveSearchExample;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChangeEvent, MouseEvent } from 'react';
|
|
2
|
+
import { LiveSearchHookProps } from '../types';
|
|
3
|
+
export declare const useLiveSearch: ({ value, setValue, onChangeText, dropContOnClickItem, }: LiveSearchHookProps) => {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
setIsOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
6
|
+
searchTerm: string;
|
|
7
|
+
handleInputChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
handleDropdownItemClick: (event: MouseEvent<HTMLDivElement>, clickedValue: any) => void;
|
|
9
|
+
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import LiveSearchProps from './
|
|
3
|
-
|
|
4
|
-
id: string | number | null;
|
|
5
|
-
label: string | number;
|
|
6
|
-
}
|
|
7
|
-
declare function LiveSearch({ descText, disabled, id, size, label, placeholder, required, options, setValue, value, readOnly, onChangeText, onClickDropdown, autoComplete, children, dropContProps, searchVariant, }: LiveSearchProps): React.JSX.Element;
|
|
2
|
+
import { LiveSearchProps } from './types';
|
|
3
|
+
declare function LiveSearch({ autoComplete, children, descText, disabled, dropContProps, id, label, onChangeText, onClickDropdown, options, placeholder, readOnly, required, searchVariant, setValue, size, value, }: LiveSearchProps): React.JSX.Element;
|
|
8
4
|
declare namespace LiveSearch {
|
|
9
5
|
var defaultProps: {
|
|
10
6
|
descText: string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, MouseEvent, ChangeEvent, ReactNode } from 'react';
|
|
2
|
+
import { DropdownContainerProps } from '../../Dropdown/DropdownContainer';
|
|
3
|
+
export type SearchVariant = 'include' | 'startsWith' | 'endsWith';
|
|
4
|
+
export interface LiveSearchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size' | 'value'> {
|
|
5
|
+
autoComplete?: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
descText?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
dropContProps?: Omit<DropdownContainerProps, 'children'>;
|
|
10
|
+
id?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
onChangeText?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
13
|
+
onClickDropdown?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
14
|
+
options?: any[];
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
searchVariant?: SearchVariant;
|
|
19
|
+
setValue: (value: any) => void;
|
|
20
|
+
size?: 'md' | 'sm';
|
|
21
|
+
value: any;
|
|
22
|
+
}
|
|
23
|
+
export interface LiveSearchHookProps {
|
|
24
|
+
value: any;
|
|
25
|
+
setValue: (value: any) => void;
|
|
26
|
+
onChangeText?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
27
|
+
dropContOnClickItem?: (event: MouseEvent<HTMLDivElement>, value: any) => void;
|
|
28
|
+
searchVariant?: SearchVariant;
|
|
29
|
+
}
|
|
30
|
+
export interface DropdownItemProps {
|
|
31
|
+
content: string | ReactNode;
|
|
32
|
+
value?: any;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
onClickItem?: (event: MouseEvent<HTMLDivElement>, value: any) => void;
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SearchVariant } from '../types';
|
|
3
|
+
export declare const getItemLabel: (value: any) => string;
|
|
4
|
+
export declare const processDropdownChildren: (nodes: React.ReactNode, currentSearchTerm: string, includeAllIfNoSearch: boolean, searchVariant: SearchVariant | undefined, handleDropdownItemClick: (e: React.MouseEvent<HTMLDivElement>, value: any) => void) => React.ReactNode;
|
|
5
|
+
export declare const processRenderedChildren: (children: React.ReactNode | undefined, searchTerm: string, searchVariant: SearchVariant, handleDropdownItemClick: (e: React.MouseEvent<HTMLDivElement>, value: any) => void) => {
|
|
6
|
+
renderedChildren: React.ReactNode;
|
|
7
|
+
hasFilteredResults: boolean;
|
|
8
|
+
};
|
|
@@ -3,15 +3,15 @@ interface InfoPanelProps {
|
|
|
3
3
|
variant?: 'container' | 'form-sm' | 'form-md';
|
|
4
4
|
color?: 'yellow' | 'blue' | 'grey' | 'white';
|
|
5
5
|
className?: string;
|
|
6
|
-
|
|
6
|
+
children: React.ReactNode;
|
|
7
7
|
}
|
|
8
8
|
declare const InfoPanel: {
|
|
9
|
-
({ variant, color, className,
|
|
9
|
+
({ variant, color, className, children, }: InfoPanelProps): React.JSX.Element;
|
|
10
10
|
defaultProps: {
|
|
11
11
|
variant: string;
|
|
12
12
|
color: string;
|
|
13
13
|
className: string;
|
|
14
|
-
|
|
14
|
+
children: null;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
export default InfoPanel;
|
|
@@ -6,5 +6,6 @@ export interface TabProps extends ComponentPropsWithoutRef<'button'> {
|
|
|
6
6
|
mode?: 'horizontal' | 'vertical';
|
|
7
7
|
fit?: 'fit-content' | 'maximize';
|
|
8
8
|
size?: 'md' | 'sm';
|
|
9
|
+
className?: string;
|
|
9
10
|
}
|
|
10
|
-
export default function Tab({ children, active, icon, disabled, mode, fit, size, ...rest }: TabProps): React.JSX.Element;
|
|
11
|
+
export default function Tab({ children, active, icon, disabled, mode, fit, size, className, ...rest }: TabProps): React.JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
import
|
|
2
|
+
import DeprecatedSimulation from '../../../components/Forms/LiveSearch/Example/DeprecatedSimulation';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: typeof
|
|
5
|
+
component: typeof DeprecatedSimulation;
|
|
6
6
|
parameters: {
|
|
7
7
|
layout: string;
|
|
8
8
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { StoryObj } from "@storybook/react/*";
|
|
2
|
+
import React from "react";
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ ...props }:
|
|
5
|
+
component: ({ children, ...props }: LiveSearchProps) => React.JSX.Element;
|
|
6
6
|
parameters: {
|
|
7
7
|
layout: string;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
export default meta;
|
|
11
11
|
type Story = StoryObj<typeof meta>;
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const BasicExample: Story;
|
|
13
|
+
export declare const ObjectOptionsExample: Story;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import React$1, { ComponentPropsWithoutRef, ComponentPropsWithRef, ChangeEvent, ReactNode, HTMLAttributes } from 'react';
|
|
2
|
+
import React$1, { ComponentPropsWithoutRef, ComponentPropsWithRef, ChangeEvent, ReactNode, MouseEvent, HTMLAttributes } from 'react';
|
|
3
3
|
|
|
4
4
|
interface AccordionsProps extends ComponentPropsWithoutRef<'div'> {
|
|
5
5
|
title: string;
|
|
@@ -303,7 +303,7 @@ interface DropdownContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
303
303
|
size?: 'sm' | 'md';
|
|
304
304
|
zIndex?: number;
|
|
305
305
|
anchorRef?: React$1.RefObject<HTMLElement>;
|
|
306
|
-
onClickItem?: (event: React$1.MouseEvent<HTMLDivElement>, val: string | number) => void;
|
|
306
|
+
onClickItem?: (event: React$1.MouseEvent<HTMLDivElement>, val: string | number | object) => void;
|
|
307
307
|
}
|
|
308
308
|
declare const DropdownContainer: {
|
|
309
309
|
(propsComp: DropdownContainerProps): React$1.JSX.Element | null;
|
|
@@ -343,28 +343,28 @@ declare namespace SelectInput {
|
|
|
343
343
|
};
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
|
|
346
|
+
type SearchVariant = 'include' | 'startsWith' | 'endsWith';
|
|
347
|
+
interface LiveSearchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size' | 'value'> {
|
|
348
|
+
autoComplete?: string;
|
|
349
|
+
children?: ReactNode;
|
|
347
350
|
descText?: string;
|
|
348
351
|
disabled?: boolean;
|
|
352
|
+
dropContProps?: Omit<DropdownContainerProps, 'children'>;
|
|
349
353
|
id?: string;
|
|
350
|
-
size?: 'md' | 'sm';
|
|
351
354
|
label?: string;
|
|
355
|
+
onChangeText?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
356
|
+
onClickDropdown?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
357
|
+
options?: any[];
|
|
352
358
|
placeholder?: string;
|
|
353
|
-
required?: boolean;
|
|
354
|
-
options?: any;
|
|
355
|
-
setValue?: any;
|
|
356
|
-
value?: any;
|
|
357
359
|
readOnly?: boolean;
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
dropContProps?: Omit<DropdownContainerProps, 'children'>;
|
|
364
|
-
searchVariant?: 'startsWith' | 'endsWith' | 'include';
|
|
360
|
+
required?: boolean;
|
|
361
|
+
searchVariant?: SearchVariant;
|
|
362
|
+
setValue: (value: any) => void;
|
|
363
|
+
size?: 'md' | 'sm';
|
|
364
|
+
value: any;
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
declare function LiveSearch({ descText, disabled,
|
|
367
|
+
declare function LiveSearch({ autoComplete, children, descText, disabled, dropContProps, id, label, onChangeText, onClickDropdown, options, placeholder, readOnly, required, searchVariant, setValue, size, value, }: LiveSearchProps): React$1.JSX.Element;
|
|
368
368
|
declare namespace LiveSearch {
|
|
369
369
|
var defaultProps: {
|
|
370
370
|
descText: string;
|
|
@@ -533,15 +533,15 @@ interface InfoPanelProps {
|
|
|
533
533
|
variant?: 'container' | 'form-sm' | 'form-md';
|
|
534
534
|
color?: 'yellow' | 'blue' | 'grey' | 'white';
|
|
535
535
|
className?: string;
|
|
536
|
-
|
|
536
|
+
children: React$1.ReactNode;
|
|
537
537
|
}
|
|
538
538
|
declare const InfoPanel: {
|
|
539
|
-
({ variant, color, className,
|
|
539
|
+
({ variant, color, className, children, }: InfoPanelProps): React$1.JSX.Element;
|
|
540
540
|
defaultProps: {
|
|
541
541
|
variant: string;
|
|
542
542
|
color: string;
|
|
543
543
|
className: string;
|
|
544
|
-
|
|
544
|
+
children: null;
|
|
545
545
|
};
|
|
546
546
|
};
|
|
547
547
|
|
|
@@ -644,8 +644,9 @@ interface TabProps extends ComponentPropsWithoutRef<'button'> {
|
|
|
644
644
|
mode?: 'horizontal' | 'vertical';
|
|
645
645
|
fit?: 'fit-content' | 'maximize';
|
|
646
646
|
size?: 'md' | 'sm';
|
|
647
|
+
className?: string;
|
|
647
648
|
}
|
|
648
|
-
declare function Tab({ children, active, icon, disabled, mode, fit, size, ...rest }: TabProps): React$1.JSX.Element;
|
|
649
|
+
declare function Tab({ children, active, icon, disabled, mode, fit, size, className, ...rest }: TabProps): React$1.JSX.Element;
|
|
649
650
|
|
|
650
651
|
interface TabMenuProps extends ComponentPropsWithoutRef<'div'> {
|
|
651
652
|
variant?: 'default' | 'alternative';
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"@biaenergi:registry": "https://gitlab.com/api/v4/projects/50905269/packages/npm/"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.0-beta.
|
|
6
|
+
"version": "1.16.0-beta.1",
|
|
7
7
|
"description": "Design Language System develop by BIAENERGI",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"rollup": "rollup -c",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import { DropdownContainerProps } from '../Dropdown/DropdownContainer';
|
|
3
|
-
interface LiveSearchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size'> {
|
|
4
|
-
descText?: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
id?: string;
|
|
7
|
-
size?: 'md' | 'sm';
|
|
8
|
-
label?: string;
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
options?: any;
|
|
12
|
-
setValue?: any;
|
|
13
|
-
value?: any;
|
|
14
|
-
readOnly?: boolean;
|
|
15
|
-
autoComplete?: string;
|
|
16
|
-
onChangeText?: (value: any) => void;
|
|
17
|
-
onClickDropdown?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
18
|
-
children?: React.ReactNode;
|
|
19
|
-
dropdownClassName?: string;
|
|
20
|
-
dropContProps?: Omit<DropdownContainerProps, 'children'>;
|
|
21
|
-
searchVariant?: 'startsWith' | 'endsWith' | 'include';
|
|
22
|
-
}
|
|
23
|
-
export default LiveSearchProps;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import { DropdownContainerProps } from '../Dropdown/DropdownContainer';
|
|
3
|
-
interface LiveSearchProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size'> {
|
|
4
|
-
descText?: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
id?: string;
|
|
7
|
-
size?: 'md' | 'sm';
|
|
8
|
-
label?: string;
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
options?: any;
|
|
12
|
-
setValue?: any;
|
|
13
|
-
value?: any;
|
|
14
|
-
readOnly?: boolean;
|
|
15
|
-
autoComplete?: string;
|
|
16
|
-
onChangeText?: (value: any) => void;
|
|
17
|
-
onClickDropdown?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
18
|
-
children?: React.ReactNode;
|
|
19
|
-
dropdownClassName?: string;
|
|
20
|
-
dropContProps?: Omit<DropdownContainerProps, 'children'>;
|
|
21
|
-
searchVariant?: 'startsWith' | 'endsWith' | 'include';
|
|
22
|
-
}
|
|
23
|
-
export default LiveSearchProps;
|