@geneui/components 2.16.0-canary-b800577-24062024 → 2.16.0-canary-36aab18-26082024
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/TimePicker/index.js +20 -7
- package/package.json +1 -1
package/TimePicker/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as _extends } from '../_rollupPluginBabelHelpers-e8fb2e5c.js';
|
|
2
|
-
import React__default, { useRef, useState, useEffect, useMemo, useCallback } from 'react';
|
|
2
|
+
import React__default, { forwardRef, useRef, useState, useImperativeHandle, useEffect, useMemo, useCallback } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { c as classnames } from '../index-031ff73c.js';
|
|
5
5
|
import { g as timePickerConfig, s as screenTypes } from '../configs-1fb8eed2.js';
|
|
@@ -29,7 +29,7 @@ import '../hooks/useMount.js';
|
|
|
29
29
|
import '../index-122432cd.js';
|
|
30
30
|
import '../debounce-4419bc2f.js';
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
const TimePickerPopover = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
33
33
|
let {
|
|
34
34
|
children,
|
|
35
35
|
readOnly,
|
|
@@ -39,16 +39,19 @@ function TimePickerPopover(_ref) {
|
|
|
39
39
|
} = _ref;
|
|
40
40
|
const rootRef = useRef(null);
|
|
41
41
|
const [isOpen, setIsOpen] = useState(false);
|
|
42
|
-
|
|
42
|
+
useImperativeHandle(ref, () => ({
|
|
43
|
+
toggleOpen() {
|
|
44
|
+
let isPopoverOpen = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : isOpen;
|
|
45
|
+
setIsOpen(!isPopoverOpen);
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
const openPopover = () => !readOnly && !isOpen && setIsOpen(true);
|
|
43
49
|
const closePopover = () => setIsOpen(false);
|
|
44
50
|
useKeyDown(openPopover, [openPopover], rootRef, ['Enter']);
|
|
45
51
|
useKeyDown(closePopover, [closePopover], rootRef, ['Tab', 'Escape']);
|
|
46
52
|
const handleOutsideClick = useClickOutside(event => {
|
|
47
53
|
!rootRef.current.contains(event.target) && closePopover();
|
|
48
54
|
});
|
|
49
|
-
|
|
50
|
-
// We need to close popup every time when
|
|
51
|
-
// user select some value from current popup
|
|
52
55
|
useEffect(() => {
|
|
53
56
|
setIsOpen(false);
|
|
54
57
|
}, [value]);
|
|
@@ -63,7 +66,7 @@ function TimePickerPopover(_ref) {
|
|
|
63
66
|
ref: rootRef,
|
|
64
67
|
onClick: openPopover
|
|
65
68
|
}, children));
|
|
66
|
-
}
|
|
69
|
+
});
|
|
67
70
|
|
|
68
71
|
var css_248z = "[data-gene-ui-version=\"2.15.0\"] .time-picker-holder{width:100%}[data-gene-ui-version=\"2.15.0\"] .time-picker-holder.read-only .cursor-pointer{cursor:default}[data-gene-ui-version=\"2.15.0\"] .time-picker-holder.mobile{caret-color:#0000;color:#0000;text-shadow:0 0 0 rgba(var(--background-sc-rgb),.75)}[data-gene-ui-version=\"2.15.0\"] .time-picker-holder.disabled{opacity:.6;pointer-events:none}[data-gene-ui-version=\"2.15.0\"] .time-picker-holder>ul{align-items:center;display:flex;width:100%}[data-gene-ui-version=\"2.15.0\"] .time-picker-holder>ul>li.no-shrink{align-items:center;display:flex;flex-shrink:0;justify-content:center}[data-gene-ui-version=\"2.15.0\"] .time-picker-holder>ul>li.no-shrink>span{display:block;font-weight:600;margin:0 .5rem}[data-gene-ui-version=\"2.15.0\"] .time-picker-holder>ul>li.shrink-auto{flex:auto}[data-gene-ui-version=\"2.15.0\"] .time-picker-holder>ul>li.icon-holder{margin-inline-end:.5rem;width:4rem}[data-gene-ui-version=\"2.15.0\"] .time-picker-drop-holder{display:flex;width:100%}[data-gene-ui-version=\"2.15.0\"] .time-picker-drop-holder>li{width:100%}[data-gene-ui-version=\"2.15.0\"] .time-picker-drop-holder>li+li{border-inline-start:1px solid rgba(var(--background-sc-rgb),.08)}[data-gene-ui-version=\"2.15.0\"] .time-picker-drop{font:600 1.4rem/1.8rem var(--font-family);padding:1rem 0;width:100%}[data-gene-ui-version=\"2.15.0\"] .time-picker-drop ul{width:100%}[data-gene-ui-version=\"2.15.0\"] .time-picker-drop ul li{align-items:center;cursor:pointer;display:flex;height:4rem;justify-content:center;text-align:center;transition:background .4s,color .4s;width:100%}@media (hover:hover){[data-gene-ui-version=\"2.15.0\"] .time-picker-drop ul li:hover{background:rgba(var(--background-sc-rgb),.05)}}[data-gene-ui-version=\"2.15.0\"] .time-picker-drop ul li.active{color:var(--hero)}";
|
|
69
72
|
styleInject(css_248z);
|
|
@@ -133,6 +136,7 @@ function TimePicker(_ref) {
|
|
|
133
136
|
const [hourPopupValue, setHourPopupValue] = useState(null);
|
|
134
137
|
const [minutePopupValue, setMinutePopupValue] = useState(null);
|
|
135
138
|
const [secondPopupValue, setSecondPopupValue] = useState(null);
|
|
139
|
+
const childRef = useRef();
|
|
136
140
|
|
|
137
141
|
// for replacing special symbols
|
|
138
142
|
const numberRegExp = useMemo(() => {
|
|
@@ -321,6 +325,11 @@ function TimePicker(_ref) {
|
|
|
321
325
|
onChange(e);
|
|
322
326
|
}
|
|
323
327
|
}, [numberRegExp, separator, showSeconds, checkTimeValidation, checkMinuteValidation, checkSecondValidation, handleChange, hourFormat, onChange]);
|
|
328
|
+
useEffect(() => {
|
|
329
|
+
if ((disabled || readOnly) && childRef.current) {
|
|
330
|
+
childRef.current.toggleOpen(true);
|
|
331
|
+
}
|
|
332
|
+
}, [disabled, readOnly]);
|
|
324
333
|
useEffect(() => {
|
|
325
334
|
// if hour format changes, convert value to that format
|
|
326
335
|
const formattedHour = convertToFormat(hour, hourFormat);
|
|
@@ -389,6 +398,7 @@ function TimePicker(_ref) {
|
|
|
389
398
|
onBlur("".concat(hour).concat(hour && minute && ':').concat(minute).concat(minute && second && ':').concat(second), event);
|
|
390
399
|
}, [hour, minute, second, onBlur, hourFormat, minuteFormat, showSeconds, secondFormat]);
|
|
391
400
|
const signleInputPopoverValue = useMemo(() => showSeconds ? convertToFormat(second, secondFormat, true) : convertToFormat(minute, minuteFormat, true), [second, secondFormat, minute, minuteFormat, showSeconds]);
|
|
401
|
+
const handleIconClick = () => childRef.current && !readOnly && !disabled && childRef.current.toggleOpen();
|
|
392
402
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
393
403
|
className: classnames('time-picker-holder', className, {
|
|
394
404
|
'read-only': readOnly,
|
|
@@ -464,6 +474,7 @@ function TimePicker(_ref) {
|
|
|
464
474
|
toggleHandler: handlePopoverToggle,
|
|
465
475
|
readOnly: readOnly,
|
|
466
476
|
value: signleInputPopoverValue,
|
|
477
|
+
ref: childRef,
|
|
467
478
|
Content: /*#__PURE__*/React__default.createElement("ul", {
|
|
468
479
|
className: "time-picker-drop-holder"
|
|
469
480
|
}, /*#__PURE__*/React__default.createElement("li", null, hours), /*#__PURE__*/React__default.createElement("li", null, minutes), showSeconds && /*#__PURE__*/React__default.createElement("li", null, seconds)),
|
|
@@ -477,6 +488,8 @@ function TimePicker(_ref) {
|
|
|
477
488
|
itemsDirection: "end",
|
|
478
489
|
readOnly: readOnly,
|
|
479
490
|
writeProtected: isMobile,
|
|
491
|
+
onIconClick: handleIconClick,
|
|
492
|
+
clickableIcon: true,
|
|
480
493
|
onBlur: handleInputBlur
|
|
481
494
|
}, restProps))));
|
|
482
495
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geneui/components",
|
|
3
3
|
"description": "The Gene UI components library designed for BI tools",
|
|
4
|
-
"version": "2.16.0-canary-
|
|
4
|
+
"version": "2.16.0-canary-36aab18-26082024",
|
|
5
5
|
"author": "SoftConstruct",
|
|
6
6
|
"homepage": "https://github.com/softconstruct/gene-ui-components#readme",
|
|
7
7
|
"repository": {
|