@spscommerce/positioning 5.18.3-ie → 5.19.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spscommerce/positioning",
3
3
  "description": "Service for positioning dropdown/popup elements.",
4
- "version": "5.18.3-ie",
4
+ "version": "5.19.0",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/positioning",
@@ -13,10 +13,10 @@
13
13
  "access": "public"
14
14
  },
15
15
  "peerDependencies": {
16
- "@spscommerce/utils": "5.18.3-ie"
16
+ "@spscommerce/utils": "5.19.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@spscommerce/utils": "5.18.3-ie",
19
+ "@spscommerce/utils": "5.19.0",
20
20
  "raf-stub": "^2.0.2"
21
21
  },
22
22
  "dependencies": {
@@ -24,12 +24,12 @@
24
24
  "intersection-observer": "0.12.0"
25
25
  },
26
26
  "scripts": {
27
- "build": "pnpm run build:es5 && pnpm run build:js && pnpm run build:types",
28
- "build:es5": "tsc -p tsconfig.json",
29
- "build:js": "rollup -c rollup.config.js",
27
+ "build": "pnpm run build:js && pnpm run build:types",
28
+ "build:js": "vite build",
30
29
  "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib",
31
30
  "watch": "vite build --watch",
32
31
  "clean": "git clean -fdX",
33
32
  "pub": "pnpm pack && node ../../scripts/publish-package.js"
34
- }
33
+ },
34
+ "readme": "[//]: # \"START_AUTOGENERATED\"\n\n## [@spscommerce/positioning](https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/positioning#readme)\n\n![release: 1.1.0](https://img.shields.io/badge/release-1.1.0-blue.svg?style=flat-square)\n![build: passing](https://img.shields.io/badge/build-passing-green.svg?style=flat-square)\n![tests: failing](https://img.shields.io/badge/tests-failing-red.svg?style=flat-square)\n\nService for positioning dropdown/popup elements. \n \n ### Installation \n \n ```shell\nnpm install --save @spscommerce/positioning\n```\n\n#### Peer Dependencies\n\n<div class=\"row\">\n <div class=\"col-5\"> \n <table class=\"sps-table\">\n <thead class=\"sps-table__head\">\n <tr class=\"sps-table__row\">\n <th class=\"sps-table__header\">\n <span class=\"sps-table__header-cell-body\"> \n Package\n </span>\n </th>\n <th class=\"sps-table__header text-right\">\n <span class=\"sps-table__header-cell-body\"> \n Version\n </span>\n </th>\n </tr>\n </thead>\n <tbody class=\"sps-table__body\">\n <tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/utils#readme\">@spscommerce/utils</a></td><td class=\"sps-table__cell text-right\">^1.1.0</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"git://github.com/primus/eventemitter3.git\">eventemitter3</a></td><td class=\"sps-table__cell text-right\">^3.1.0</td></tr>\n<tr class=\"sps-table__row\"><td class=\"sps-table__cell\"><a href=\"git@github.com:w3c/IntersectionObserver.git\">intersection-observer</a></td><td class=\"sps-table__cell text-right\">^0.5.1</td></tr>\n </tbody>\n </table>\n </div>\n <div class=\"col-7\">\n &nbsp;\n </div>\n</div>\n\n[//]: # \"END_AUTOGENERATED\"\n"
35
35
  }
package/vite.config.js CHANGED
@@ -7,7 +7,7 @@ import pkg from './package.json';
7
7
  export default defineConfig({
8
8
  build: {
9
9
  lib: {
10
- entry: path.resolve(__dirname, 'dist/out-tsc/index.js'),
10
+ entry: path.resolve(__dirname, 'src/index.ts'),
11
11
  formats: ['es', 'cjs'],
12
12
  fileName: (format) => `index.${format}.js`,
13
13
  },
@@ -1,4 +0,0 @@
1
- export * from "./position.enum";
2
- export * from "./position-anchor.enum";
3
- export * from "./positioning-options.interface";
4
- export * from "./positioning.service";
@@ -1,5 +0,0 @@
1
- export * from "./position.enum";
2
- export * from "./position-anchor.enum";
3
- export * from "./positioning-options.interface";
4
- export * from "./positioning.service";
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC"}
@@ -1,7 +0,0 @@
1
- /** Indicates which point on a positioned element it should be positioned by. */
2
- export declare enum PositionAnchor {
3
- TOP_LEFT = "top left",
4
- TOP_RIGHT = "top right",
5
- BOTTOM_LEFT = "bottom left",
6
- BOTTOM_RIGHT = "bottom right"
7
- }
@@ -1,9 +0,0 @@
1
- /** Indicates which point on a positioned element it should be positioned by. */
2
- export var PositionAnchor;
3
- (function (PositionAnchor) {
4
- PositionAnchor["TOP_LEFT"] = "top left";
5
- PositionAnchor["TOP_RIGHT"] = "top right";
6
- PositionAnchor["BOTTOM_LEFT"] = "bottom left";
7
- PositionAnchor["BOTTOM_RIGHT"] = "bottom right";
8
- })(PositionAnchor || (PositionAnchor = {}));
9
- //# sourceMappingURL=position-anchor.enum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"position-anchor.enum.js","sourceRoot":"","sources":["../../src/position-anchor.enum.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,yCAAuB,CAAA;IACvB,6CAA2B,CAAA;IAC3B,+CAA6B,CAAA;AAC/B,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB"}
@@ -1,18 +0,0 @@
1
- /**
2
- * These are the possibilities for the `position` option of
3
- * `PositioningOptions` when using `relativeTo`.
4
- */
5
- export declare enum Position {
6
- TOP_LEFT = "top left",
7
- TOP_MIDDLE = "top middle",
8
- TOP_RIGHT = "top right",
9
- RIGHT_TOP = "right top",
10
- RIGHT_MIDDLE = "right middle",
11
- RIGHT_BOTTOM = "right bottom",
12
- BOTTOM_RIGHT = "bottom right",
13
- BOTTOM_MIDDLE = "bottom middle",
14
- BOTTOM_LEFT = "bottom left",
15
- LEFT_BOTTOM = "left bottom",
16
- LEFT_MIDDLE = "left middle",
17
- LEFT_TOP = "left top"
18
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * These are the possibilities for the `position` option of
3
- * `PositioningOptions` when using `relativeTo`.
4
- */
5
- export var Position;
6
- (function (Position) {
7
- Position["TOP_LEFT"] = "top left";
8
- Position["TOP_MIDDLE"] = "top middle";
9
- Position["TOP_RIGHT"] = "top right";
10
- Position["RIGHT_TOP"] = "right top";
11
- Position["RIGHT_MIDDLE"] = "right middle";
12
- Position["RIGHT_BOTTOM"] = "right bottom";
13
- Position["BOTTOM_RIGHT"] = "bottom right";
14
- Position["BOTTOM_MIDDLE"] = "bottom middle";
15
- Position["BOTTOM_LEFT"] = "bottom left";
16
- Position["LEFT_BOTTOM"] = "left bottom";
17
- Position["LEFT_MIDDLE"] = "left middle";
18
- Position["LEFT_TOP"] = "left top";
19
- })(Position || (Position = {}));
20
- //# sourceMappingURL=position.enum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"position.enum.js","sourceRoot":"","sources":["../../src/position.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,QAaX;AAbD,WAAY,QAAQ;IAClB,iCAAqB,CAAA;IACrB,qCAAyB,CAAA;IACzB,mCAAuB,CAAA;IACvB,mCAAuB,CAAA;IACvB,yCAA6B,CAAA;IAC7B,yCAA6B,CAAA;IAC7B,yCAA6B,CAAA;IAC7B,2CAA+B,CAAA;IAC/B,uCAA2B,CAAA;IAC3B,uCAA2B,CAAA;IAC3B,uCAA2B,CAAA;IAC3B,iCAAqB,CAAA;AACvB,CAAC,EAbW,QAAQ,KAAR,QAAQ,QAanB"}
@@ -1,37 +0,0 @@
1
- import { Position } from "./position.enum";
2
- import { PositionAnchor } from "./position-anchor.enum";
3
- /** Options that can be passed to `position()` method. */
4
- export interface PositioningOptions {
5
- /** Indicates which point on the positioned element it should be positioned by. */
6
- anchor?: PositionAnchor;
7
- /**
8
- * An array of pixel offsets. Each offset is applied
9
- * to the corresponding term in `position`. So to continue the above example of
10
- * `"bottom left"`, if the offsets are `[-7, 9]`, the element will be placed at
11
- * the bottom of the `relativeTo` element minus 7 pixels, and at the left of it
12
- * plus 9 pixels. (NB: The values will be converted to rem.)
13
- */
14
- offsets?: number[];
15
- /**
16
- * When using `relativeTo`, this describes the positioning relationship between
17
- * the two elements. For example, if it's `"bottom left"`, the positioned element
18
- * will be placed at the bottom left of the `relativeTo` element.
19
- */
20
- position?: Position;
21
- /**
22
- * Normally, an element positioned by the service will simply have its current
23
- * position on the page locked in place. Instead you can have it positioned
24
- * relative to another element.
25
- */
26
- relativeTo?: HTMLElement;
27
- /**
28
- * The width of the positioned element will be set to the width of the element
29
- * provided to the relativeTo option, rather than its own natural width.
30
- */
31
- useRelativeTargetWidth?: boolean;
32
- /** Specify a z-index override for the positioned element. */
33
- zIndex?: number;
34
- /** The element's ancestor that scrolls, if it's not the window itself */
35
- scrollParent?: HTMLElement;
36
- }
37
- export declare const DEFAULT_POSITIONING_OPTIONS: PositioningOptions;
@@ -1,8 +0,0 @@
1
- import { Position } from "./position.enum";
2
- import { PositionAnchor } from "./position-anchor.enum";
3
- export var DEFAULT_POSITIONING_OPTIONS = {
4
- anchor: PositionAnchor.TOP_LEFT,
5
- offsets: [],
6
- position: Position.TOP_LEFT,
7
- };
8
- //# sourceMappingURL=positioning-options.interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"positioning-options.interface.js","sourceRoot":"","sources":["../../src/positioning-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AA2CxD,MAAM,CAAC,IAAM,2BAA2B,GAAuB;IAC7D,MAAM,EAAE,cAAc,CAAC,QAAQ;IAC/B,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,QAAQ,CAAC,QAAQ;CAC5B,CAAC"}
@@ -1,55 +0,0 @@
1
- import "intersection-observer";
2
- import type { PositioningOptions } from "./positioning-options.interface";
3
- /**
4
- * This class follows a singleton pattern where you can create an instance by calling
5
- * `new PositioningService()` if you wish, but all instance methods pass through to
6
- * static methods, so there's really only one set of elements being positioned that's
7
- * shared between all instances and static usages of PositioningService.
8
- */
9
- export declare class PositioningService {
10
- static elements: Map<HTMLElement, PositioningOptions>;
11
- private static registeredScrollParents;
12
- private static events;
13
- private static viewportObserver;
14
- static on(eventName: any, handler: any): void;
15
- static off(eventName: any, handler: any): void;
16
- static once(eventName: any, handler: any): void;
17
- static checkCollisions(element: HTMLElement, otherElements?: HTMLElement[]): void;
18
- /**
19
- * Returns `true` if the element is currently being positioned by the service
20
- * and `false` otherwise.
21
- */
22
- static isPositioned(element: HTMLElement): boolean;
23
- /**
24
- * Returns the options currently beinng used for positioning the element,
25
- * if it is indeed being positioned by the service.
26
- */
27
- static getPositioningOptions(element: HTMLElement): PositioningOptions;
28
- /** PositioningService will start controlling the position of the given element. */
29
- static position(element: HTMLElement, options?: PositioningOptions): void;
30
- /** PositioningService will stop controlling the position of the given element. */
31
- static release(element: HTMLElement): void;
32
- static releaseAll(): void;
33
- /** PositioningService will refresh the positioning of the given element */
34
- static refresh(element: HTMLElement): void;
35
- static refreshAll(): void;
36
- /** Update the positioning options of a currently positioned element */
37
- static reposition(element: HTMLElement, newOptions: PositioningOptions): void;
38
- private static onViewportIntersection;
39
- private static onElementIntersection;
40
- private static getRootBounds;
41
- private static clearStyles;
42
- private static fixElementPosition;
43
- private static update;
44
- on(eventName: any, handler: any): void;
45
- off(eventName: any, handler: any): void;
46
- once(eventName: any, handler: any): void;
47
- isPositioned(element: HTMLElement): boolean;
48
- getPositioningOptions(element: HTMLElement): PositioningOptions;
49
- position(element: HTMLElement, options?: PositioningOptions): void;
50
- release(element: HTMLElement): void;
51
- releaseAll(): void;
52
- refresh(element: HTMLElement): void;
53
- refreshAll(): void;
54
- reposition(element: HTMLElement, newOptions: PositioningOptions): void;
55
- }