@geneui/components 2.16.0-canary-b800577-24062024 → 2.16.0-canary-12a636d-09092024

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/Range/index.js CHANGED
@@ -2,7 +2,7 @@ import { _ as _extends } from '../_rollupPluginBabelHelpers-e8fb2e5c.js';
2
2
  import React__default, { useState, useRef, useCallback } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { c as classnames } from '../index-031ff73c.js';
5
- import { c as createSliderWithTooltip, R as Range } from '../rangeAndSlider-693a3d41.js';
5
+ import { c as createSliderWithTooltip, R as Range } from '../rangeAndSlider-63c5d423.js';
6
6
  import useWidth from '../hooks/useWidth.js';
7
7
  import '../dateValidation-67caec66.js';
8
8
  import 'react-dom';
package/Slider/index.js CHANGED
@@ -2,7 +2,7 @@ import { _ as _extends } from '../_rollupPluginBabelHelpers-e8fb2e5c.js';
2
2
  import React__default, { useState, useRef, useCallback, useEffect } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { c as classnames } from '../index-031ff73c.js';
5
- import { c as createSliderWithTooltip, S as Slider } from '../rangeAndSlider-693a3d41.js';
5
+ import { c as createSliderWithTooltip, S as Slider } from '../rangeAndSlider-63c5d423.js';
6
6
  import useWidth from '../hooks/useWidth.js';
7
7
  import '../dateValidation-67caec66.js';
8
8
  import 'react-dom';
@@ -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
- function TimePickerPopover(_ref) {
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
- const openPopover = () => !readOnly && setIsOpen(true);
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(() => {
@@ -259,7 +263,7 @@ function TimePicker(_ref) {
259
263
  setInputValue(time);
260
264
  handleChange(e, time);
261
265
  }, [hour, minute, second, separator, showSeconds, handleChange, combinedValue]);
262
- const handleInputChange = useCallback(e => {
266
+ const handleInputChange = e => {
263
267
  const {
264
268
  value
265
269
  } = e.target;
@@ -269,8 +273,6 @@ function TimePicker(_ref) {
269
273
  const timeParts = replacedValue.split(separator);
270
274
  const lastChar = replacedValue[replacedValue.length - 1];
271
275
  const secondLastChar = replacedValue[replacedValue.length - 2];
272
-
273
- // Checking if last and second last chars are same and equal to separator then return
274
276
  if (lastChar === separator && lastChar === secondLastChar) return;
275
277
  if (value === '') {
276
278
  setHour('');
@@ -310,9 +312,6 @@ function TimePicker(_ref) {
310
312
  outOfRange = true;
311
313
  }
312
314
  }
313
-
314
- // Make field valid when after typing field pass validation
315
- // but we must set error only when user click outside or onBlur event fires
316
315
  !checkTimeValidation(timeParts[0], false) && setHourFieldError(false);
317
316
  !checkMinuteValidation(timeParts[1], false) && setMinuteFieldError(false);
318
317
  (!showSeconds || !checkSecondValidation(timeParts[2], false)) && setSecondFieldError(false);
@@ -320,31 +319,46 @@ function TimePicker(_ref) {
320
319
  setInputValue(replacedValue);
321
320
  onChange(e);
322
321
  }
323
- }, [numberRegExp, separator, showSeconds, checkTimeValidation, checkMinuteValidation, checkSecondValidation, handleChange, hourFormat, onChange]);
322
+ };
324
323
  useEffect(() => {
325
- // if hour format changes, convert value to that format
326
- const formattedHour = convertToFormat(hour, hourFormat);
327
- setHour(formattedHour);
328
- setInputValue(combinedValue(formattedHour, minute, second, false));
329
- }, [combinedValue, hour, hourFormat, minute, second]);
324
+ if ((disabled || readOnly) && childRef.current) {
325
+ childRef.current.toggleOpen(true);
326
+ }
327
+ }, [disabled, readOnly]);
330
328
  useEffect(() => {
331
- // if minute format changes, convert value to that format
332
- const formattedMinute = convertToFormat(minute, minuteFormat);
333
- setMinute(formattedMinute);
334
- setInputValue(combinedValue(hour, formattedMinute, second, false));
335
- }, [combinedValue, hour, minute, minuteFormat, second]);
329
+ if (hour) {
330
+ const formattedHour = convertToFormat(hour, hourFormat);
331
+ setHour(formattedHour);
332
+ setInputValue(combinedValue(formattedHour, minute, second, false));
333
+ }
334
+ }, [hourFormat]);
335
+ useEffect(() => {
336
+ if (minute) {
337
+ const formattedMinute = convertToFormat(minute, minuteFormat);
338
+ setMinute(formattedMinute);
339
+ setInputValue(combinedValue(hour, formattedMinute, second, false));
340
+ }
341
+ }, [minuteFormat]);
342
+ useEffect(() => {
343
+ if (second) {
344
+ const formattedSecond = convertToFormat(second, secondFormat);
345
+ setSecond(formattedSecond);
346
+ setInputValue(combinedValue(hour, minute, formattedSecond, false));
347
+ }
348
+ }, [secondFormat]);
336
349
  useEffect(() => {
337
- // if second format changes, convert value to that format
338
- const formattedSecond = convertToFormat(second, secondFormat);
339
- setSecond(formattedSecond);
340
- setInputValue(combinedValue(hour, minute, formattedSecond, false));
341
- }, [combinedValue, hour, minute, second, secondFormat]);
350
+ if (!inputValue) return;
351
+ const [splitHour, splitMinute, splitSecond] = inputValue.split(separator);
352
+ !showSeconds && setSecond('');
353
+ showSeconds && (inputValue || hour) && !second && setSecond(convertToFormat(second, secondFormat));
354
+ setInputValue(combinedValue(splitHour, splitMinute, splitSecond));
355
+ }, [showSeconds]);
342
356
  useEffect(() => {
343
357
  if (value) {
344
- const timeParts = value.split(separator);
345
- timeParts[0] && setHour(timeParts[0]);
346
- timeParts[1] && setMinute(timeParts[1]);
347
- showSeconds && timeParts[2] && setSecond(timeParts[2]);
358
+ const [splitHour, splitMinute, splitSecond] = value.split(separator);
359
+ splitHour && setHour(splitHour);
360
+ splitMinute && setMinute(splitMinute);
361
+ showSeconds && splitSecond && setSecond(splitSecond);
348
362
  setInputValue(value);
349
363
  }
350
364
  }, [value, separator, showSeconds]);
@@ -389,6 +403,7 @@ function TimePicker(_ref) {
389
403
  onBlur("".concat(hour).concat(hour && minute && ':').concat(minute).concat(minute && second && ':').concat(second), event);
390
404
  }, [hour, minute, second, onBlur, hourFormat, minuteFormat, showSeconds, secondFormat]);
391
405
  const signleInputPopoverValue = useMemo(() => showSeconds ? convertToFormat(second, secondFormat, true) : convertToFormat(minute, minuteFormat, true), [second, secondFormat, minute, minuteFormat, showSeconds]);
406
+ const handleIconClick = () => childRef.current && !readOnly && !disabled && childRef.current.toggleOpen();
392
407
  return /*#__PURE__*/React__default.createElement("div", {
393
408
  className: classnames('time-picker-holder', className, {
394
409
  'read-only': readOnly,
@@ -464,6 +479,7 @@ function TimePicker(_ref) {
464
479
  toggleHandler: handlePopoverToggle,
465
480
  readOnly: readOnly,
466
481
  value: signleInputPopoverValue,
482
+ ref: childRef,
467
483
  Content: /*#__PURE__*/React__default.createElement("ul", {
468
484
  className: "time-picker-drop-holder"
469
485
  }, /*#__PURE__*/React__default.createElement("li", null, hours), /*#__PURE__*/React__default.createElement("li", null, minutes), showSeconds && /*#__PURE__*/React__default.createElement("li", null, seconds)),
@@ -477,6 +493,8 @@ function TimePicker(_ref) {
477
493
  itemsDirection: "end",
478
494
  readOnly: readOnly,
479
495
  writeProtected: isMobile,
496
+ onIconClick: handleIconClick,
497
+ clickableIcon: true,
480
498
  onBlur: handleInputBlur
481
499
  }, restProps))));
482
500
  }
package/index.js CHANGED
@@ -140,7 +140,7 @@ import './localization-4ba17032.js';
140
140
  import './Popover-f4d1cac0.js';
141
141
  import './index-122432cd.js';
142
142
  import './debounce-4419bc2f.js';
143
- import './rangeAndSlider-693a3d41.js';
143
+ import './rangeAndSlider-63c5d423.js';
144
144
  import './index-45eafea6.js';
145
145
  import './react-lifecycles-compat.es-6e1f3768.js';
146
146
  import './SuggestionList/index.js';
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-b800577-24062024",
4
+ "version": "2.16.0-canary-12a636d-09092024",
5
5
  "author": "SoftConstruct",
6
6
  "homepage": "https://github.com/softconstruct/gene-ui-components#readme",
7
7
  "repository": {
@@ -251,20 +251,12 @@ var _cof = function (it) {
251
251
  return toString$2.call(it).slice(8, -1);
252
252
  };
253
253
 
254
- var _iobject;
255
- var hasRequired_iobject;
256
-
257
- function require_iobject () {
258
- if (hasRequired_iobject) return _iobject;
259
- hasRequired_iobject = 1;
260
- // fallback for non-array-like ES3 and non-enumerable old V8 strings
261
- var cof = _cof;
262
- // eslint-disable-next-line no-prototype-builtins
263
- _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
264
- return cof(it) == 'String' ? it.split('') : Object(it);
265
- };
266
- return _iobject;
267
- }
254
+ // fallback for non-array-like ES3 and non-enumerable old V8 strings
255
+ var cof$2 = _cof;
256
+ // eslint-disable-next-line no-prototype-builtins
257
+ var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
258
+ return cof$2(it) == 'String' ? it.split('') : Object(it);
259
+ };
268
260
 
269
261
  // 7.2.1 RequireObjectCoercible(argument)
270
262
  var _defined = function (it) {
@@ -273,7 +265,7 @@ var _defined = function (it) {
273
265
  };
274
266
 
275
267
  // to indexed object, toObject with fallback for non-array-like ES3 strings
276
- var IObject = require_iobject();
268
+ var IObject = _iobject;
277
269
  var defined$2 = _defined;
278
270
  var _toIobject = function (it) {
279
271
  return IObject(defined$2(it));
@@ -446,7 +438,7 @@ function require_objectAssign () {
446
438
  var gOPS = _objectGops;
447
439
  var pIE = require_objectPie();
448
440
  var toObject = _toObject;
449
- var IObject = require_iobject();
441
+ var IObject = _iobject;
450
442
  var $assign = Object.assign;
451
443
 
452
444
  // should work with symbols and should have deterministic property order (V8 bug)