@onesy/ui-react 1.0.133 → 1.0.134

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.
@@ -214,15 +214,22 @@ const TableCell = /*#__PURE__*/_react.default.forwardRef((props_, ref) => {
214
214
  _react.default.useEffect(() => {
215
215
  if (sticky) {
216
216
  if (root) {
217
- const parentOverflow = (0, _utils2.getOverflowParent)(root, false);
218
- const offsetPrevious = stickyPosition === 'left' ? root.offsetLeft : window.innerWidth - root.getBoundingClientRect().right;
217
+ const parentOverflow = (0, _utils2.getOverflowParent)(root.parentElement, false);
218
+ root.style.position = 'unset';
219
+ const offsetOriginal = root.offsetLeft;
220
+ root.style.position = 'sticky';
219
221
  const method = () => {
220
- const offsetNew = stickyPosition === 'left' ? root.offsetLeft : window.innerWidth - root.getBoundingClientRect().right;
221
- setStickyActive(offsetPrevious !== offsetNew);
222
+ const offsetNew = root.offsetLeft;
223
+ setStickyActive(offsetOriginal !== offsetNew);
222
224
  };
223
- if (parentOverflow) parentOverflow.addEventListener('scroll', method, {
224
- passive: false
225
- });
225
+ if (parentOverflow) {
226
+ parentOverflow.addEventListener('scroll', method, {
227
+ passive: false
228
+ });
229
+
230
+ // initial
231
+ method();
232
+ }
226
233
  return () => {
227
234
  parentOverflow.removeEventListener('scroll', method);
228
235
  };
@@ -191,15 +191,22 @@ const TableCell = /*#__PURE__*/React.forwardRef((props_, ref) => {
191
191
  React.useEffect(() => {
192
192
  if (sticky) {
193
193
  if (root) {
194
- const parentOverflow = getOverflowParent(root, false);
195
- const offsetPrevious = stickyPosition === 'left' ? root.offsetLeft : window.innerWidth - root.getBoundingClientRect().right;
194
+ const parentOverflow = getOverflowParent(root.parentElement, false);
195
+ root.style.position = 'unset';
196
+ const offsetOriginal = root.offsetLeft;
197
+ root.style.position = 'sticky';
196
198
  const method = () => {
197
- const offsetNew = stickyPosition === 'left' ? root.offsetLeft : window.innerWidth - root.getBoundingClientRect().right;
198
- setStickyActive(offsetPrevious !== offsetNew);
199
+ const offsetNew = root.offsetLeft;
200
+ setStickyActive(offsetOriginal !== offsetNew);
199
201
  };
200
- if (parentOverflow) parentOverflow.addEventListener('scroll', method, {
201
- passive: false
202
- });
202
+ if (parentOverflow) {
203
+ parentOverflow.addEventListener('scroll', method, {
204
+ passive: false
205
+ });
206
+
207
+ // initial
208
+ method();
209
+ }
203
210
  return () => {
204
211
  parentOverflow.removeEventListener('scroll', method);
205
212
  };
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license UiReact v1.0.132
1
+ /** @license UiReact v1.0.133
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/esm/utils.js CHANGED
@@ -216,7 +216,7 @@ export const getOverflowParent = (element, vertical = true) => {
216
216
 
217
217
  // width
218
218
  if (!vertical && element.scrollWidth > element.clientWidth) return element;
219
- return getOverflowParent(element.parentElement);
219
+ return getOverflowParent(element.parentElement, vertical);
220
220
  };
221
221
  export const keyboardStandardCommands = ['a', 'c', 'v', 'y', 'z'];
222
222
  export const keyboardStyleCommands = ['b', 'i', 'u'];
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license UiReact v1.0.132
1
+ /** @license UiReact v1.0.133
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.133",
3
+ "version": "1.0.134",
4
4
  "description": "UI for React",
5
5
  "repository": "https://github.com/onesy-me/onesy.git",
6
6
  "author": "Lazar Erić <lazareric1@proton.me>",
package/utils.d.ts CHANGED
@@ -26,7 +26,7 @@ export declare const minMaxBetweenNumbers: (value?: number, min?: number, max?:
26
26
  export declare const sanitize: (value: string) => string;
27
27
  export declare const replace: (value: string, split: string, join: string) => string;
28
28
  export declare const importIframeStyles: (iframeDocument: Document) => void;
29
- export declare const getOverflowParent: (element: HTMLElement, vertical?: boolean) => HTMLElement;
29
+ export declare const getOverflowParent: (element: HTMLElement, vertical?: boolean) => any;
30
30
  export declare const keyboardStandardCommands: string[];
31
31
  export declare const keyboardStyleCommands: string[];
32
32
  export declare const caret: any;
package/utils.js CHANGED
@@ -246,7 +246,7 @@ const getOverflowParent = (element, vertical = true) => {
246
246
 
247
247
  // width
248
248
  if (!vertical && element.scrollWidth > element.clientWidth) return element;
249
- return getOverflowParent(element.parentElement);
249
+ return getOverflowParent(element.parentElement, vertical);
250
250
  };
251
251
  exports.getOverflowParent = getOverflowParent;
252
252
  const keyboardStandardCommands = exports.keyboardStandardCommands = ['a', 'c', 'v', 'y', 'z'];