@primer/behaviors 0.0.0-20211131940 → 0.0.0-2021113211757

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/README.md CHANGED
@@ -1,29 +1,16 @@
1
- <h1 align="center">Primer Behaviors</h1>
2
-
3
- <p align="center">Shared behaviors for JavaScript components</p>
4
-
5
- <p align="center">
6
- <a aria-label="npm package" href="https://www.npmjs.com/package/@primer/behaviors">
7
- <img alt="" src="https://img.shields.io/npm/v/@primer/behaviors.svg">
8
- </a>
9
- <a aria-label="contributors graph" href="https://github.com/primer/behaviors/graphs/contributors">
10
- <img src="https://img.shields.io/github/contributors/primer/behaviors.svg">
11
- </a>
12
- <a aria-label="last commit" href="https://github.com/primer/behaviors/commits/main">
13
- <img alt="" src=
14
- "https://img.shields.io/github/last-commit/primer/behaviors.svg">
15
- </a>
16
- <a aria-label="license" href="https://github.com/primer/behaviors/blob/main/LICENSE">
17
- <img src="https://img.shields.io/github/license/primer/behaviors.svg" alt="">
18
- </a>
19
- </p>
1
+ # Primer Behaviors
2
+
3
+ [![npm](https://img.shields.io/npm/v/@primer/behaviors)](https://www.npmjs.com/package/@primer/behaviors)
4
+ [![CI](https://github.com/primer/behaviors/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/primer/behaviors/actions/workflows/ci.yml)
5
+
6
+ Shared behaviors for JavaScript components
20
7
 
21
8
  ## Documentation
22
9
 
23
- * [Anchored Position](https://primer.style/react/anchoredPosition)
24
- * [Focus Trap](https://primer.style/react/focusTrap)
25
- * [Focus Zone](https://primer.style/react/focusZone)
26
- * Scroll Into Viewing Area - coming soon
10
+ * [Anchored Position](/docs/anchored-position.md)
11
+ * [Focus Trap](/docs/focus-trap.md)
12
+ * [Focus Zone](/docs/focus-zone.md)
13
+ * [Scroll Into View](/docs/scroll-into-view.md)
27
14
 
28
15
  ## Installation
29
16
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './anchored-position.js';
2
2
  export * from './focus-trap.js';
3
3
  export * from './focus-zone.js';
4
- export * from './scroll-into-viewing-area.js';
4
+ export * from './scroll-into-view.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './anchored-position.js';
2
2
  export * from './focus-trap.js';
3
3
  export * from './focus-zone.js';
4
- export * from './scroll-into-viewing-area.js';
4
+ export * from './scroll-into-view.js';
@@ -0,0 +1,7 @@
1
+ export interface ScrollIntoViewOptions {
2
+ direction?: 'horizontal' | 'vertical';
3
+ startMargin?: number;
4
+ endMargin?: number;
5
+ behavior?: ScrollBehavior;
6
+ }
7
+ export declare const scrollIntoView: (child: HTMLElement, viewingArea: HTMLElement, { direction, startMargin, endMargin, behavior }?: ScrollIntoViewOptions) => void;
@@ -1,4 +1,4 @@
1
- export const scrollIntoViewingArea = (child, viewingArea, direction = 'vertical', startMargin = 8, endMargin = 0, behavior = 'smooth') => {
1
+ export const scrollIntoView = (child, viewingArea, { direction = 'vertical', startMargin = 8, endMargin = 0, behavior = 'smooth' } = {}) => {
2
2
  const startSide = direction === 'vertical' ? 'top' : 'left';
3
3
  const endSide = direction === 'vertical' ? 'bottom' : 'right';
4
4
  const scrollSide = direction === 'vertical' ? 'scrollTop' : 'scrollLeft';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/behaviors",
3
- "version": "0.0.0-20211131940",
3
+ "version": "0.0.0-2021113211757",
4
4
  "description": "Shared behaviors for JavaScript components",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- export declare const scrollIntoViewingArea: (child: HTMLElement, viewingArea: HTMLElement, direction?: 'horizontal' | 'vertical', startMargin?: number, endMargin?: number, behavior?: ScrollBehavior) => void;