x-ui-design 0.8.52 → 0.8.54
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/esm/types/hooks/usePosition.d.ts +1 -1
- package/dist/esm/types/types/datepicker.d.ts +2 -2
- package/dist/esm/types/types/dropdown.d.ts +1 -1
- package/dist/esm/types/types/popover.d.ts +1 -1
- package/dist/esm/types/types/select.d.ts +1 -1
- package/dist/index.esm.js +9 -41
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -41
- package/dist/index.js.map +1 -1
- package/lib/components/DatePicker/RangePicker/RangePicker.tsx +1 -1
- package/lib/components/DatePicker/TimePicker/style.css +0 -6
- package/lib/components/Dropdown/Dropdown.tsx +11 -13
- package/lib/hooks/usePosition.ts +10 -54
- package/lib/types/datepicker.ts +2 -2
- package/lib/types/dropdown.ts +1 -1
- package/lib/types/popover.ts +1 -1
- package/lib/types/select.ts +1 -1
- package/package.json +1 -1
- package/src/app/page.tsx +20 -17
|
@@ -4,7 +4,7 @@ type TPosition = {
|
|
|
4
4
|
isOpen: boolean;
|
|
5
5
|
popupRef: RefObject<HTMLDivElement | null>;
|
|
6
6
|
triggerRef: RefObject<HTMLDivElement | null>;
|
|
7
|
-
getPopupContainer?: HTMLElement
|
|
7
|
+
getPopupContainer?: HTMLElement;
|
|
8
8
|
placement?: Placement;
|
|
9
9
|
offset?: number;
|
|
10
10
|
listenPopoverPossitions?: CSSProperties;
|
|
@@ -34,7 +34,7 @@ export type TDatePickerProps = DefaultProps & {
|
|
|
34
34
|
onChange?: (date: RuleType | RuleType[], dateString: string | string[]) => void;
|
|
35
35
|
onCalendarChange?: (date: RuleType | RuleType[], dateString: string | string[], info: BaseInfo) => void;
|
|
36
36
|
onVisibleChange?: ((open: boolean) => void) | undefined;
|
|
37
|
-
getPopupContainer?: ((node: HTMLElement) => HTMLElement
|
|
37
|
+
getPopupContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
|
|
38
38
|
showToday?: boolean;
|
|
39
39
|
inputReadOnly?: boolean;
|
|
40
40
|
picker?: PanelMode;
|
|
@@ -115,7 +115,7 @@ export type TimePickerProps = DefaultProps & {
|
|
|
115
115
|
onSelect?: ((value: Date | null) => void) | undefined;
|
|
116
116
|
showNow?: boolean;
|
|
117
117
|
clearIcon?: ReactNode;
|
|
118
|
-
getPopupContainer?: ((node: HTMLElement) => HTMLElement
|
|
118
|
+
getPopupContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
|
|
119
119
|
suffixIcon?: ReactNode;
|
|
120
120
|
placeholder?: string;
|
|
121
121
|
placement?: Placement;
|
|
@@ -20,7 +20,7 @@ export type DropdownProps = DefaultProps & {
|
|
|
20
20
|
placement?: Placement;
|
|
21
21
|
overlayClassName?: string;
|
|
22
22
|
overlayStyle?: CSSProperties;
|
|
23
|
-
getPopupContainer?: ((node: HTMLElement) => HTMLElement
|
|
23
|
+
getPopupContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
|
|
24
24
|
destroyOnHidden?: boolean;
|
|
25
25
|
disabled?: boolean;
|
|
26
26
|
arrow?: boolean;
|
|
@@ -12,5 +12,5 @@ export type PopoverProps = DefaultProps & {
|
|
|
12
12
|
visible?: boolean;
|
|
13
13
|
listenPopoverPossitions?: CSSProperties;
|
|
14
14
|
onVisibleChange?: ((open: boolean) => void) | undefined;
|
|
15
|
-
getPopupContainer?: ((node: HTMLElement) => HTMLElement
|
|
15
|
+
getPopupContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
|
|
16
16
|
};
|
|
@@ -43,7 +43,7 @@ export type SelectProps = DefaultProps & {
|
|
|
43
43
|
searchIcon?: ReactNode;
|
|
44
44
|
open?: boolean;
|
|
45
45
|
notFoundContent?: ReactNode;
|
|
46
|
-
getPopupContainer?: ((node: HTMLElement) => HTMLElement
|
|
46
|
+
getPopupContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
|
|
47
47
|
dropdownRender?: (menu: ReactNode) => ReactNode;
|
|
48
48
|
feedbackIcons?: boolean;
|
|
49
49
|
placement?: Placement;
|
package/dist/index.esm.js
CHANGED
|
@@ -2594,15 +2594,6 @@ function getScrollParent(el, includeSelf = false) {
|
|
|
2594
2594
|
}
|
|
2595
2595
|
return document.scrollingElement;
|
|
2596
2596
|
}
|
|
2597
|
-
const clampWithinContainer = (left, popupWidth, containerRect) => {
|
|
2598
|
-
const minLeft = containerRect.left + document.documentElement.scrollLeft;
|
|
2599
|
-
const maxLeft = containerRect.right + document.documentElement.scrollLeft - popupWidth;
|
|
2600
|
-
return {
|
|
2601
|
-
minLeft,
|
|
2602
|
-
maxLeft,
|
|
2603
|
-
leftPosition: Math.min(Math.max(left, minLeft), maxLeft)
|
|
2604
|
-
};
|
|
2605
|
-
};
|
|
2606
2597
|
const usePosition = ({
|
|
2607
2598
|
isOpen,
|
|
2608
2599
|
offset = 4,
|
|
@@ -2625,14 +2616,9 @@ const usePosition = ({
|
|
|
2625
2616
|
const spaceBelow = containerRect.bottom - inputRect.bottom;
|
|
2626
2617
|
const _shouldShowAbove = spaceBelow < dropdownHeight && spaceAbove > dropdownHeight;
|
|
2627
2618
|
const hasRight = placement?.includes('Right');
|
|
2619
|
+
setShowPlacement(_shouldShowAbove ? 'bottom' : '');
|
|
2628
2620
|
if (getPopupContainer) {
|
|
2629
|
-
const
|
|
2630
|
-
minLeft,
|
|
2631
|
-
maxLeft,
|
|
2632
|
-
leftPosition
|
|
2633
|
-
} = clampWithinContainer(hasRight ? (inputRect.left || 0) + (triggerRef.current?.offsetWidth || 0) - (popupRef.current?.offsetWidth || 0) : (inputRect.left || 0) + document.documentElement.scrollLeft, popupRef.current?.offsetWidth || 0, triggerRef.current.getBoundingClientRect());
|
|
2634
|
-
const _center = minLeft + maxLeft < (popupRef.current?.offsetWidth || 0) ? 'center' : '';
|
|
2635
|
-
setShowPlacement(_shouldShowAbove ? `bottom ${_center}` : `${_center}`);
|
|
2621
|
+
const leftPosition = hasRight ? (inputRect.left || 0) + (triggerRef.current?.offsetWidth || 0) - (popupRef.current?.offsetWidth || 0) : (inputRect.left || 0) + document.documentElement.scrollLeft;
|
|
2636
2622
|
const _top = (inputRect.top || 0) + document.documentElement.scrollTop;
|
|
2637
2623
|
if (_shouldShowAbove) {
|
|
2638
2624
|
setDropdownPosition({
|
|
@@ -2649,27 +2635,9 @@ const usePosition = ({
|
|
|
2649
2635
|
setDropdownPosition({
|
|
2650
2636
|
top: (_shouldShowAbove ? triggerRef.current.offsetTop - (popupRef.current?.offsetHeight || dropdownHeight) - offset * 2 : triggerRef.current.offsetTop + triggerRef.current?.offsetHeight) + offset,
|
|
2651
2637
|
...(hasRight ? {
|
|
2652
|
-
left: (
|
|
2653
|
-
const {
|
|
2654
|
-
minLeft,
|
|
2655
|
-
maxLeft,
|
|
2656
|
-
leftPosition
|
|
2657
|
-
} = clampWithinContainer(triggerRef.current.offsetLeft + (triggerRef.current?.offsetWidth || 0) - (popupRef.current?.offsetWidth || dropdownHeight), popupRef.current?.offsetWidth || dropdownHeight, triggerRef.current.getBoundingClientRect());
|
|
2658
|
-
const _center = minLeft + maxLeft < (popupRef.current?.offsetWidth || 0) ? 'center' : '';
|
|
2659
|
-
setShowPlacement(_shouldShowAbove ? `bottom ${_center}` : `${_center}`);
|
|
2660
|
-
return leftPosition;
|
|
2661
|
-
})()
|
|
2638
|
+
left: triggerRef.current.offsetLeft + (triggerRef.current?.offsetWidth || 0) - (popupRef.current?.offsetWidth || 0)
|
|
2662
2639
|
} : {
|
|
2663
|
-
left:
|
|
2664
|
-
const {
|
|
2665
|
-
minLeft,
|
|
2666
|
-
maxLeft,
|
|
2667
|
-
leftPosition
|
|
2668
|
-
} = clampWithinContainer(triggerRef.current.offsetLeft, popupRef.current?.offsetWidth || dropdownHeight, triggerRef.current.getBoundingClientRect());
|
|
2669
|
-
const _center = minLeft + maxLeft < (popupRef.current?.offsetWidth || 0) ? 'center' : '';
|
|
2670
|
-
setShowPlacement(_shouldShowAbove ? `bottom ${_center}` : `${_center}`);
|
|
2671
|
-
return leftPosition;
|
|
2672
|
-
})()
|
|
2640
|
+
left: triggerRef.current.offsetLeft
|
|
2673
2641
|
})
|
|
2674
2642
|
});
|
|
2675
2643
|
}
|
|
@@ -3367,7 +3335,7 @@ var RangePicker$1 = /*#__PURE__*/Object.freeze({
|
|
|
3367
3335
|
default: RangePicker
|
|
3368
3336
|
});
|
|
3369
3337
|
|
|
3370
|
-
var css_248z$h = ".xUi-timepicker-wrapper{display:inline-block;font-size:14px;position:relative}.xUi-timepicker-input-wrapper{position:relative;width:100%}.xUi-timepicker-input{border:1px solid var(--xui-border-color);border-radius:6px;box-sizing:border-box;font-size:14px;height:32px;line-height:32px;padding:4px 11px;transition:all .3s;width:100%}.xUi-timepicker-input:focus,.xUi-timepicker-input:hover{border-color:var(--xui-primary-color-light)}.xUi-timepicker-input:focus{outline:none}.xUi-timepicker-input::placeholder{opacity:.6}.xUi-timepicker-clear{color:rgba(0,0,0,.45);cursor:pointer;font-size:12px;position:absolute;right:8px;top:50%;transform:translateY(-50%);z-index:2}.xUi-timepicker-clear:hover{color:rgba(0,0,0,.75)}.xUi-timepicker-popup{background:#fff;border:1px solid var(--xui-border-color);border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,.15);display:flex;left:0;min-width:max-content;padding:8px 0;z-index:1}.xUi-timepicker-panel{display:flex;width:100%}.xUi-timepicker-column{align-items:center;display:flex;flex:1;flex-direction:column;margin-bottom:5px;max-height:169px;overflow-x:hidden;overflow-y:auto;padding-left:4px;width:52px}.xUi-timepicker-column::-webkit-scrollbar,.xUi-timepicker-column::-webkit-scrollbar-thumb{width:4px}.xUi-timepicker-column:nth-child(2){border-left:1px solid var(--xui-border-color);border-right:1px solid var(--xui-border-color)}.xUi-timepicker-cell{align-items:center;border-radius:4px;cursor:pointer;display:flex;font-size:14px;justify-content:center;margin-bottom:2px;padding:6px 0;text-align:center;transition:background .3s;width:44px}.xUi-timepicker-cell:hover{background-color:#e6f4ff}.xUi-timepicker-cell-selected{background-color:#e6f4ff;font-weight:500}.xUi-timepicker-cell-disabled{color:rgba(0,0,0,.25);pointer-events:none;user-select:none}.xUi-timepicker-now-btn{color:#4096ff;cursor:pointer;font-weight:500;margin-top:10px;padding:0 0 4px;text-align:center;transition:background .3s}.xUi-timepicker-icons{align-items:center;display:flex;gap:4px;position:absolute;right:8px;top:50%;transform:translateY(-50%)}.xUi-timepicker-suffix{align-items:center;cursor:pointer;display:flex;justify-content:center}.xUi-timepicker-suffix svg{color:#999;height:14px;width:14px}.xUi-timepicker-clear{right:0;top:1px}.xUi-timepicker-actions{align-items:center;border-top:1px solid var(--xui-border-color);display:flex;justify-content:space-between;padding:0 8px}.xUi-timepicker-ok-btn{background-color:var(--xui-primary-color);border:none;border-radius:4px;color:#fff;cursor:pointer;margin-top:7px;outline:none;padding:4px 8px;transition:.3s ease}.xUi-timepicker-ok-btn:disabled{background-color:var(--xui-color-disabled);color:grey;font-size:13px}.xUi-timepicker-ok-btn:not(:disabled):hover{background-color:var(--xui-primary-color-light)}
|
|
3338
|
+
var css_248z$h = ".xUi-timepicker-wrapper{display:inline-block;font-size:14px;position:relative}.xUi-timepicker-input-wrapper{position:relative;width:100%}.xUi-timepicker-input{border:1px solid var(--xui-border-color);border-radius:6px;box-sizing:border-box;font-size:14px;height:32px;line-height:32px;padding:4px 11px;transition:all .3s;width:100%}.xUi-timepicker-input:focus,.xUi-timepicker-input:hover{border-color:var(--xui-primary-color-light)}.xUi-timepicker-input:focus{outline:none}.xUi-timepicker-input::placeholder{opacity:.6}.xUi-timepicker-clear{color:rgba(0,0,0,.45);cursor:pointer;font-size:12px;position:absolute;right:8px;top:50%;transform:translateY(-50%);z-index:2}.xUi-timepicker-clear:hover{color:rgba(0,0,0,.75)}.xUi-timepicker-popup{background:#fff;border:1px solid var(--xui-border-color);border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,.15);display:flex;left:0;min-width:max-content;padding:8px 0;position:absolute;top:100%;z-index:1}.xUi-timepicker-panel{display:flex;width:100%}.xUi-timepicker-column{align-items:center;display:flex;flex:1;flex-direction:column;margin-bottom:5px;max-height:169px;overflow-x:hidden;overflow-y:auto;padding-left:4px;width:52px}.xUi-timepicker-column::-webkit-scrollbar,.xUi-timepicker-column::-webkit-scrollbar-thumb{width:4px}.xUi-timepicker-column:nth-child(2){border-left:1px solid var(--xui-border-color);border-right:1px solid var(--xui-border-color)}.xUi-timepicker-cell{align-items:center;border-radius:4px;cursor:pointer;display:flex;font-size:14px;justify-content:center;margin-bottom:2px;padding:6px 0;text-align:center;transition:background .3s;width:44px}.xUi-timepicker-cell:hover{background-color:#e6f4ff}.xUi-timepicker-cell-selected{background-color:#e6f4ff;font-weight:500}.xUi-timepicker-cell-disabled{color:rgba(0,0,0,.25);pointer-events:none;user-select:none}.xUi-timepicker-now-btn{color:#4096ff;cursor:pointer;font-weight:500;margin-top:10px;padding:0 0 4px;text-align:center;transition:background .3s}.xUi-timepicker-icons{align-items:center;display:flex;gap:4px;position:absolute;right:8px;top:50%;transform:translateY(-50%)}.xUi-timepicker-suffix{align-items:center;cursor:pointer;display:flex;justify-content:center}.xUi-timepicker-suffix svg{color:#999;height:14px;width:14px}.xUi-timepicker-clear{right:0;top:1px}.xUi-timepicker-actions{align-items:center;border-top:1px solid var(--xui-border-color);display:flex;justify-content:space-between;padding:0 8px}.xUi-timepicker-ok-btn{background-color:var(--xui-primary-color);border:none;border-radius:4px;color:#fff;cursor:pointer;margin-top:7px;outline:none;padding:4px 8px;transition:.3s ease}.xUi-timepicker-ok-btn:disabled{background-color:var(--xui-color-disabled);color:grey;font-size:13px}.xUi-timepicker-ok-btn:not(:disabled):hover{background-color:var(--xui-primary-color-light)}";
|
|
3371
3339
|
styleInject(css_248z$h);
|
|
3372
3340
|
|
|
3373
3341
|
const HOURS = 24;
|
|
@@ -5427,6 +5395,7 @@ const Dropdown = ({
|
|
|
5427
5395
|
const onTriggerClick = e => {
|
|
5428
5396
|
e.preventDefault();
|
|
5429
5397
|
e.stopPropagation();
|
|
5398
|
+
console.info(e);
|
|
5430
5399
|
if (popupRef.current && !popupRef.current.contains(e.target) && triggerRef.current && !triggerRef.current.contains(e.target) && triggers.includes('click')) {
|
|
5431
5400
|
setOpenInternal(!open);
|
|
5432
5401
|
}
|
|
@@ -5475,8 +5444,7 @@ const Dropdown = ({
|
|
|
5475
5444
|
}, "Empty menu")));
|
|
5476
5445
|
return /*#__PURE__*/React.createElement("div", {
|
|
5477
5446
|
ref: triggerRef,
|
|
5478
|
-
className: className
|
|
5479
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
5447
|
+
className: className,
|
|
5480
5448
|
onClick: onTriggerClick,
|
|
5481
5449
|
onMouseEnter: onTriggerMouseEnter,
|
|
5482
5450
|
onMouseLeave: onTriggerMouseLeave,
|
|
@@ -5484,10 +5452,10 @@ const Dropdown = ({
|
|
|
5484
5452
|
"aria-haspopup": "menu",
|
|
5485
5453
|
style: {
|
|
5486
5454
|
width: 'fit-content',
|
|
5487
|
-
height: '-
|
|
5455
|
+
height: 'fit-content'
|
|
5488
5456
|
},
|
|
5489
5457
|
"aria-expanded": open
|
|
5490
|
-
}, children, open && popup, !open && !destroyOnHidden && null)
|
|
5458
|
+
}, children, open && popup, !open && !destroyOnHidden && null);
|
|
5491
5459
|
};
|
|
5492
5460
|
function MenuInner({
|
|
5493
5461
|
items,
|