@primer/behaviors 1.0.1-rc.fc715af → 1.0.1

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 function 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 function 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';
@@ -14,4 +14,4 @@ export const scrollIntoViewingArea = (child, viewingArea, direction = 'vertical'
14
14
  const scrollHeightToChildBottom = childEnd - viewingAreaEnd + viewingArea[scrollSide];
15
15
  viewingArea.scrollTo({ behavior, [startSide]: scrollHeightToChildBottom + startMargin });
16
16
  }
17
- };
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/behaviors",
3
- "version": "1.0.1-rc.fc715af",
3
+ "version": "1.0.1",
4
4
  "description": "Shared behaviors for JavaScript components",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -57,13 +57,13 @@
57
57
  "@types/react": "^17.0.37",
58
58
  "esbuild": "^0.14.1",
59
59
  "esbuild-jest": "^0.5.0",
60
- "eslint": "^8.2.0",
60
+ "eslint": "^8.3.0",
61
61
  "eslint-plugin-github": "^4.3.5",
62
62
  "jest": "^27.4.3",
63
- "prettier": "^2.4.1",
63
+ "prettier": "^2.5.0",
64
64
  "react": "^17.0.2",
65
65
  "react-dom": "^17.0.2",
66
66
  "size-limit": "^7.0.3",
67
- "typescript": "^4.4.4"
67
+ "typescript": "^4.5.2"
68
68
  }
69
69
  }
package/CHANGELOG.md DELETED
@@ -1,8 +0,0 @@
1
- # @primer/behaviors
2
-
3
- ## 1.0.1
4
- ### Patch Changes
5
-
6
-
7
-
8
- - [#10](https://github.com/primer/behaviors/pull/10) [`88b6f34`](https://github.com/primer/behaviors/commit/88b6f34bf4874f3c81473020a01a58b197dd6e16) Thanks [@dgreif](https://github.com/dgreif)! - Set up changesets
@@ -1 +0,0 @@
1
- export declare const scrollIntoViewingArea: (child: HTMLElement, viewingArea: HTMLElement, direction?: 'horizontal' | 'vertical', startMargin?: number, endMargin?: number, behavior?: ScrollBehavior) => void;