@onesy/ui-react 1.0.189 → 1.0.191

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.
@@ -261,6 +261,15 @@ const Calendar = props__ => {
261
261
  if (refs.inProgressTransition.current) return;
262
262
  onUpdateCalendar((next ? _date.add : _date.remove)(1, unit, calendar));
263
263
  };
264
+ const scrollToMiddleOfParent = element => {
265
+ const parent = element.parentElement;
266
+ if (!parent) return;
267
+ const top = element.offsetTop - parent.clientHeight / 2 + element.offsetHeight / 2;
268
+ parent.scrollTo({
269
+ top,
270
+ behavior: 'smooth'
271
+ });
272
+ };
264
273
  const onOpen = (valueUpdate = 'month') => {
265
274
  const valueNew_4 = open === valueUpdate ? null : valueUpdate;
266
275
  setOpen(valueNew_4);
@@ -272,11 +281,8 @@ const Calendar = props__ => {
272
281
  if (list) {
273
282
  const valueData = valueNew_4 === 'month' ? calendar.month - 1 : calendar.year;
274
283
  (0, _utils.Try)(() => {
275
- const element = list.querySelector(`[data-value="${valueData}"]`);
276
- if (element) list.scrollTo({
277
- top: (0, _utils.clamp)(element.offsetTop - element.parentElement.offsetTop + (menu === 'month' ? -104 : 51), 0),
278
- behavior: 'smooth'
279
- });
284
+ const element_0 = list.querySelector(`[data-value="${valueData}"]`);
285
+ if (element_0) scrollToMiddleOfParent(element_0);
280
286
  });
281
287
  }
282
288
  });
@@ -318,7 +324,7 @@ const Calendar = props__ => {
318
324
 
319
325
  // Prevent multiple moves of the calendar
320
326
  // before the previous transition is done
321
- const onTransition = (element_0, status) => {
327
+ const onTransition = (element_1, status) => {
322
328
  refs.inProgressTransition.current = !['entered', 'exited', 'removed'].includes(status);
323
329
  };
324
330
  const calendarMonthProps = _objectSpread({
@@ -829,7 +829,7 @@ const Surface = props_ => {
829
829
  }
830
830
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, _objectSpread(_objectSpread(_objectSpread({}, AdditionalProps), {}, {
831
831
  className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)("Surface", theme) && ["onesy-Surface-root"], AdditionalProps === null || AdditionalProps === void 0 ? void 0 : AdditionalProps.className, className, classes.root, classes[`version_${version}`], classes[`version_${version}_color_${color}`], classes[`elevation_${elevation}`], tonal && classes[`version_${version}_tonal_${(0, _utils.is)("string", tonal) ? `${tonal}_` : ""}color_${color}`], noBackground && classes.noBackground, noOutline && classes.noOutline]),
832
- style: _objectSpread(_objectSpread({}, style), styles.root)
832
+ style: _objectSpread(_objectSpread({}, styles.root), style)
833
833
  }, other), {}, {
834
834
  children: children && _react.default.Children.toArray(children).filter(Boolean).map(_temp)
835
835
  }));
@@ -4,7 +4,7 @@ const _excluded = ["ref", "tonal", "color", "version", "size", "value", "valueDe
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  import React from 'react';
7
- import { clamp, is, isEnvironment, Try } from '@onesy/utils';
7
+ import { is, isEnvironment, Try } from '@onesy/utils';
8
8
  import { classNames, style, useOnesyTheme } from '@onesy/style-react';
9
9
  import { OnesyDate, add, remove, format, set } from '@onesy/date';
10
10
  import IconMaterialNavigateBefore from '@onesy/icons-material-rounded-react/IconMaterialNavigateBeforeW100';
@@ -253,6 +253,15 @@ const Calendar = props__ => {
253
253
  if (refs.inProgressTransition.current) return;
254
254
  onUpdateCalendar((next ? add : remove)(1, unit, calendar));
255
255
  };
256
+ const scrollToMiddleOfParent = element => {
257
+ const parent = element.parentElement;
258
+ if (!parent) return;
259
+ const top = element.offsetTop - parent.clientHeight / 2 + element.offsetHeight / 2;
260
+ parent.scrollTo({
261
+ top,
262
+ behavior: 'smooth'
263
+ });
264
+ };
256
265
  const onOpen = (valueUpdate = 'month') => {
257
266
  const valueNew_4 = open === valueUpdate ? null : valueUpdate;
258
267
  setOpen(valueNew_4);
@@ -263,11 +272,8 @@ const Calendar = props__ => {
263
272
  if (list) {
264
273
  const valueData = valueNew_4 === 'month' ? calendar.month - 1 : calendar.year;
265
274
  Try(() => {
266
- const element = list.querySelector(`[data-value="${valueData}"]`);
267
- if (element) list.scrollTo({
268
- top: clamp(element.offsetTop - element.parentElement.offsetTop + (menu === 'month' ? -104 : 51), 0),
269
- behavior: 'smooth'
270
- });
275
+ const element_0 = list.querySelector(`[data-value="${valueData}"]`);
276
+ if (element_0) scrollToMiddleOfParent(element_0);
271
277
  });
272
278
  }
273
279
  });
@@ -308,7 +314,7 @@ const Calendar = props__ => {
308
314
 
309
315
  // Prevent multiple moves of the calendar
310
316
  // before the previous transition is done
311
- const onTransition = (element_0, status) => {
317
+ const onTransition = (element_1, status) => {
312
318
  refs.inProgressTransition.current = !['entered', 'exited', 'removed'].includes(status);
313
319
  };
314
320
  const calendarMonthProps = _objectSpread({
@@ -821,7 +821,7 @@ const Surface = props_ => {
821
821
  }
822
822
  return /*#__PURE__*/_jsx(Component, _objectSpread(_objectSpread(_objectSpread({}, AdditionalProps), {}, {
823
823
  className: classNames([staticClassName("Surface", theme) && ["onesy-Surface-root"], AdditionalProps?.className, className, classes.root, classes[`version_${version}`], classes[`version_${version}_color_${color}`], classes[`elevation_${elevation}`], tonal && classes[`version_${version}_tonal_${is("string", tonal) ? `${tonal}_` : ""}color_${color}`], noBackground && classes.noBackground, noOutline && classes.noOutline]),
824
- style: _objectSpread(_objectSpread({}, style), styles.root)
824
+ style: _objectSpread(_objectSpread({}, styles.root), style)
825
825
  }, other), {}, {
826
826
  children: children && React.Children.toArray(children).filter(Boolean).map(_temp)
827
827
  }));
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license UiReact v1.0.188
1
+ /** @license UiReact v1.0.190
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license UiReact v1.0.188
1
+ /** @license UiReact v1.0.190
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onesy/ui-react",
3
- "version": "1.0.189",
3
+ "version": "1.0.191",
4
4
  "description": "UI for React",
5
5
  "repository": "https://github.com/onesy-me/onesy.git",
6
6
  "author": "Lazar Erić <lazareric1@proton.me>",