@bsky.app/sift 0.2.11 → 0.3.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/CHANGELOG.md +16 -0
- package/build/computeStyles.d.ts.map +1 -1
- package/build/computeStyles.js +5 -2
- package/build/computeStyles.js.map +1 -1
- package/build/computeStyles.web.d.ts.map +1 -1
- package/build/computeStyles.web.js +2 -3
- package/build/computeStyles.web.js.map +1 -1
- package/package.json +1 -1
- package/src/computeStyles.ts +6 -2
- package/src/computeStyles.web.ts +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @bsky.app/sift
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ca30299`](https://github.com/bluesky-social/toolbox/commit/ca302996897a01e237c48a5544bff31035311343) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Fix positioning on web
|
|
8
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`878376e`](https://github.com/bluesky-social/toolbox/commit/878376ea9e87779eb8930771acf167a5cb56990f) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Bump stable minor
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`acd32e2`](https://github.com/bluesky-social/toolbox/commit/acd32e28ff75d119f794ed9857d2efc16ebc0f5a) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Fix alignment on android
|
|
18
|
+
|
|
3
19
|
## 0.2.11
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeStyles.d.ts","sourceRoot":"","sources":["../src/computeStyles.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"computeStyles.d.ts","sourceRoot":"","sources":["../src/computeStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,SAAS,EAAC,MAAM,cAAc,CAAA;AACjE,OAAO,EAAC,KAAK,SAAS,EAAC,MAAM,WAAW,CAAA;AAkBxC,wBAAsB,aAAa,CACjC,EACE,MAAM,EACN,KAAK,EACL,OAAO,GACR,EAAE;IACD,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,EAAE,GAAG,CAAA;IACV,OAAO,EAAE,GAAG,GAAG,IAAI,CAAA;CACpB,EACD,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,MAAM,CAAC,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAA;CACvC,GACA,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CA4D3B"}
|
package/build/computeStyles.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dimensions } from 'react-native';
|
|
1
|
+
import { Dimensions, Platform } from 'react-native';
|
|
2
2
|
function measureInWindow(node) {
|
|
3
3
|
return new Promise(resolve => {
|
|
4
4
|
try {
|
|
@@ -29,7 +29,10 @@ export async function computeStyles({ anchor, input, popover, }, options) {
|
|
|
29
29
|
let bottom = 'auto';
|
|
30
30
|
let maxHeight;
|
|
31
31
|
if (side === 'top') {
|
|
32
|
-
|
|
32
|
+
// android reports window size minus insets
|
|
33
|
+
const windowHeight = Dimensions.get('window').height +
|
|
34
|
+
(Platform.OS === 'android' ? insetBottom : 0);
|
|
35
|
+
bottom = windowHeight - anchorRect.y + options.offset;
|
|
33
36
|
maxHeight = anchorRect.y - options.offset - insetTop;
|
|
34
37
|
}
|
|
35
38
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeStyles.js","sourceRoot":"","sources":["../src/computeStyles.ts"],"names":[],"mappings":"AAAA,OAA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K,KAAK,KAAK,EAAE,CAAC;QAC3B,IAAI,GAAG,UAAU,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,GAAG,YAAY,CAAA;IACvD,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,UAAU,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;IAC7D,CAAC;IAED,IAAI,QAA4B,CAAA;IAChC,IAAI,OAAO,CAAC,YAAY,KAAK,KAAK,EAAE,CAAC;QACnC,IAAI,GAAG,UAAU,CAAC,CAAC,CAAA;QACnB,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAA;IAC7B,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,UAAU;QACpB,GAAG;QACH,MAAM;QACN,IAAI;QACJ,QAAQ;QACR,SAAS;KACV,CAAA;AACH,CAAC","sourcesContent":["import {Dimensions, Platform, type ViewStyle} from 'react-native'\nimport {type Placement} from './useSift'\n\nfunction measureInWindow(\n node: any,\n): Promise<{x: number; y: number; width: number; height: number}> {\n return new Promise(resolve => {\n try {\n node.measureInWindow(\n (x: number, y: number, width: number, height: number) => {\n resolve({x, y, width, height})\n },\n )\n } catch {\n resolve({x: 0, y: 0, width: 0, height: 0})\n }\n })\n}\n\nexport async function computeStyles(\n {\n anchor,\n input,\n popover,\n }: {\n anchor: any\n input: any\n popover: any | null\n },\n options: {\n offset: number\n placement: Placement\n dynamicWidth?: boolean\n insets?: {top: number; bottom: number}\n },\n): Promise<ViewStyle | null> {\n const anchorRect = await measureInWindow(anchor)\n const inputRect = await measureInWindow(input)\n const popoverRect = popover ? await measureInWindow(popover) : null\n\n // If any measurement failed (view not in hierarchy yet), return null\n // so the caller keeps the previous styles.\n if (!anchorRect.width || !inputRect.width) return null\n if (popoverRect && !popoverRect.width && !popoverRect.height) return null\n\n const popoverWidth = popoverRect?.width ?? 0\n const [side, align] = options.placement.split('-') as [\n string,\n string | undefined,\n ]\n\n const insetTop = options.insets?.top ?? 0\n const insetBottom = options.insets?.bottom ?? 0\n\n let top: number | 'auto' = 'auto'\n let bottom: number | 'auto' = 'auto'\n let maxHeight: number | undefined\n if (side === 'top') {\n // android reports window size minus insets\n const windowHeight =\n Dimensions.get('window').height +\n (Platform.OS === 'android' ? insetBottom : 0)\n bottom = windowHeight - anchorRect.y + options.offset\n maxHeight = anchorRect.y - options.offset - insetTop\n } else {\n top = anchorRect.y + anchorRect.height + options.offset\n maxHeight =\n Dimensions.get('window').height -\n insetBottom -\n (anchorRect.y + anchorRect.height + options.offset)\n }\n\n let left: number\n if (align === 'start') {\n left = anchorRect.x\n } else if (align === 'end') {\n left = anchorRect.x + anchorRect.width - popoverWidth\n } else {\n left = anchorRect.x + (anchorRect.width - popoverWidth) / 2\n }\n\n let maxWidth: number | undefined\n if (options.dynamicWidth === false) {\n left = anchorRect.x\n maxWidth = anchorRect.width\n }\n\n return {\n position: 'absolute',\n top,\n bottom,\n left,\n maxWidth,\n maxHeight,\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeStyles.web.d.ts","sourceRoot":"","sources":["../src/computeStyles.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,SAAS,EAAC,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAC,KAAK,SAAS,EAAC,MAAM,WAAW,CAAA;AAExC,wBAAgB,aAAa,CAC3B,EACE,MAAM,EACN,KAAK,EACL,OAAO,GACR,EAAE;IACD,MAAM,EAAE,WAAW,CAAA;IACnB,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;CAC5B,EACD,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,MAAM,CAAC,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAA;CACvC,GACA,SAAS,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"computeStyles.web.d.ts","sourceRoot":"","sources":["../src/computeStyles.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,SAAS,EAAC,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAC,KAAK,SAAS,EAAC,MAAM,WAAW,CAAA;AAExC,wBAAgB,aAAa,CAC3B,EACE,MAAM,EACN,KAAK,EACL,OAAO,GACR,EAAE;IACD,MAAM,EAAE,WAAW,CAAA;IACnB,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;CAC5B,EACD,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,MAAM,CAAC,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAA;CACvC,GACA,SAAS,GAAG,IAAI,CAuDlB"}
|
|
@@ -20,7 +20,7 @@ export function computeStyles({ anchor, input, popover, }, options) {
|
|
|
20
20
|
maxHeight = anchorRect.top - options.offset - insetTop;
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
|
-
top = anchorRect.bottom + options.offset
|
|
23
|
+
top = anchorRect.bottom + options.offset;
|
|
24
24
|
maxHeight =
|
|
25
25
|
window.innerHeight - insetBottom - anchorRect.bottom - options.offset;
|
|
26
26
|
}
|
|
@@ -34,10 +34,9 @@ export function computeStyles({ anchor, input, popover, }, options) {
|
|
|
34
34
|
else {
|
|
35
35
|
left = anchorRect.left + (anchorRect.width - popoverWidth) / 2;
|
|
36
36
|
}
|
|
37
|
-
left += window.scrollX;
|
|
38
37
|
let maxWidth;
|
|
39
38
|
if (options.dynamicWidth === false) {
|
|
40
|
-
left = anchorRect.left
|
|
39
|
+
left = anchorRect.left;
|
|
41
40
|
maxWidth = anchorRect.width;
|
|
42
41
|
}
|
|
43
42
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AQ,CAAA;IACxD,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QACxC,SAAS;YACP,MAAM,CAAC,WAAW,GAAG,WAAW,GAAG,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IACzE,CAAC;IAED,IAAI,IAAY,CAAA;IAChB,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;QACtB,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;IACxB,CAAC;SAAM,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QAC3B,IAAI,GAAG,UAAU,CAAC,KAAK,GAAG,YAAY,CAAA;IACxC,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,UAAU,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;IAChE,CAAC;IAED,IAAI,QAA4B,CAAA;IAChC,IAAI,OAAO,CAAC,YAAY,KAAK,KAAK,EAAE,CAAC;QACnC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;QACtB,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAA;IAC7B,CAAC;IAED,OAAO;QACL,aAAa;QACb,QAAQ,EAAE,OAAO;QACjB,GAAG;QACH,MAAM;QACN,IAAI;QACJ,QAAQ;QACR,SAAS;KACV,CAAA;AACH,CAAC","sourcesContent":["import {type ViewStyle} from 'react-native'\nimport {type Placement} from './useSift'\n\nexport function computeStyles(\n {\n anchor,\n input,\n popover,\n }: {\n anchor: HTMLElement\n input: HTMLElement\n popover: HTMLElement | null\n },\n options: {\n offset: number\n placement: Placement\n dynamicWidth?: boolean\n insets?: {top: number; bottom: number}\n },\n): ViewStyle | null {\n const anchorRect = anchor.getBoundingClientRect()\n const inputRect = input.getBoundingClientRect()\n const popoverRect = popover?.getBoundingClientRect()\n\n // If any measurement failed (view not in hierarchy yet), return null\n // so the caller keeps the previous styles.\n if (!anchorRect.width || !inputRect.width) return null\n if (popoverRect && !popoverRect.width && !popoverRect.height) return null\n\n const popoverWidth = popoverRect?.width ?? 0\n const [side, align] = options.placement.split('-') as [\n string,\n string | undefined,\n ]\n\n const insetTop = options.insets?.top ?? 0\n const insetBottom = options.insets?.bottom ?? 0\n\n let top: number | 'auto' = 'auto'\n let bottom: number | 'auto' = 'auto'\n let maxHeight: number | undefined\n if (side === 'top') {\n bottom = window.innerHeight - anchorRect.top + options.offset\n maxHeight = anchorRect.top - options.offset - insetTop\n } else {\n top = anchorRect.bottom + options.offset\n maxHeight =\n window.innerHeight - insetBottom - anchorRect.bottom - options.offset\n }\n\n let left: number\n if (align === 'start') {\n left = anchorRect.left\n } else if (align === 'end') {\n left = anchorRect.right - popoverWidth\n } else {\n left = anchorRect.left + (anchorRect.width - popoverWidth) / 2\n }\n\n let maxWidth: number | undefined\n if (options.dynamicWidth === false) {\n left = anchorRect.left\n maxWidth = anchorRect.width\n }\n\n return {\n // @ts-ignore\n position: 'fixed',\n top,\n bottom,\n left,\n maxWidth,\n maxHeight,\n }\n}\n"]}
|
package/package.json
CHANGED
package/src/computeStyles.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Dimensions, type ViewStyle} from 'react-native'
|
|
1
|
+
import {Dimensions, Platform, type ViewStyle} from 'react-native'
|
|
2
2
|
import {type Placement} from './useSift'
|
|
3
3
|
|
|
4
4
|
function measureInWindow(
|
|
@@ -56,7 +56,11 @@ export async function computeStyles(
|
|
|
56
56
|
let bottom: number | 'auto' = 'auto'
|
|
57
57
|
let maxHeight: number | undefined
|
|
58
58
|
if (side === 'top') {
|
|
59
|
-
|
|
59
|
+
// android reports window size minus insets
|
|
60
|
+
const windowHeight =
|
|
61
|
+
Dimensions.get('window').height +
|
|
62
|
+
(Platform.OS === 'android' ? insetBottom : 0)
|
|
63
|
+
bottom = windowHeight - anchorRect.y + options.offset
|
|
60
64
|
maxHeight = anchorRect.y - options.offset - insetTop
|
|
61
65
|
} else {
|
|
62
66
|
top = anchorRect.y + anchorRect.height + options.offset
|
package/src/computeStyles.web.ts
CHANGED
|
@@ -43,7 +43,7 @@ export function computeStyles(
|
|
|
43
43
|
bottom = window.innerHeight - anchorRect.top + options.offset
|
|
44
44
|
maxHeight = anchorRect.top - options.offset - insetTop
|
|
45
45
|
} else {
|
|
46
|
-
top = anchorRect.bottom + options.offset
|
|
46
|
+
top = anchorRect.bottom + options.offset
|
|
47
47
|
maxHeight =
|
|
48
48
|
window.innerHeight - insetBottom - anchorRect.bottom - options.offset
|
|
49
49
|
}
|
|
@@ -56,11 +56,10 @@ export function computeStyles(
|
|
|
56
56
|
} else {
|
|
57
57
|
left = anchorRect.left + (anchorRect.width - popoverWidth) / 2
|
|
58
58
|
}
|
|
59
|
-
left += window.scrollX
|
|
60
59
|
|
|
61
60
|
let maxWidth: number | undefined
|
|
62
61
|
if (options.dynamicWidth === false) {
|
|
63
|
-
left = anchorRect.left
|
|
62
|
+
left = anchorRect.left
|
|
64
63
|
maxWidth = anchorRect.width
|
|
65
64
|
}
|
|
66
65
|
|