@jobber/components-native 0.42.2 → 0.43.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.
@@ -8,7 +8,6 @@ export const defaultValues = {
8
8
  setLocalCache: () => undefined,
9
9
  removeLocalCache: () => undefined,
10
10
  }),
11
- headerHeight: 0,
12
11
  };
13
12
  export const AtlantisFormContext = createContext(defaultValues);
14
13
  export function useAtlantisFormContext() {
@@ -1,9 +1,9 @@
1
1
  import { useWindowDimensions } from "react-native";
2
2
  import { useSafeAreaInsets } from "react-native-safe-area-context";
3
3
  import { KEYBOARD_TOP_PADDING_AUTO_SCROLL } from "../constants";
4
- import { useAtlantisFormContext } from "../context";
4
+ import { useAtlantisContext } from "../../AtlantisContext";
5
5
  export function useScreenInformation() {
6
- const { headerHeight } = useAtlantisFormContext();
6
+ const { headerHeight } = useAtlantisContext();
7
7
  const windowHeight = useWindowDimensions().height;
8
8
  const headerHeightWithPadding = headerHeight + KEYBOARD_TOP_PADDING_AUTO_SCROLL;
9
9
  const insets = useSafeAreaInsets();
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import isNil from "lodash/isNil";
4
+ import { RowCount } from "./types";
5
+ import { styles } from "./ThumbnailList.style";
6
+ import { FormatFile } from "../FormatFile";
7
+ function isImage(file) {
8
+ return !!file.contentType && file.contentType.includes("image/");
9
+ }
10
+ function hasValidUrl(file) {
11
+ return !isNil(file.url);
12
+ }
13
+ export const filterImages = (files) => {
14
+ return files.filter((file) => {
15
+ return isImage(file) && hasValidUrl(file);
16
+ });
17
+ };
18
+ export function ThumbnailList({ files, rowCount = RowCount.TwoRows, handleOpenFile, createThumbnail, }) {
19
+ const imageList = filterImages(files);
20
+ return (React.createElement(View, { style: [
21
+ styles.list,
22
+ rowCount === RowCount.ThreeRows && styles.maxDimensionsForThreeRows,
23
+ ] }, files.map((file, index) => {
24
+ return (React.createElement(FormatFile, { file: file, accessibilityLabel: file.fileName, key: `${file.fileName}-${index}`, styleInGrid: true, onTap: openFile(file, index), createThumbnail: createThumbnail }));
25
+ })));
26
+ function openFile(file, index) {
27
+ return () => {
28
+ handleOpenFile === null || handleOpenFile === void 0 ? void 0 : handleOpenFile({ file, index, imageList });
29
+ };
30
+ }
31
+ }
@@ -0,0 +1,49 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../utils/design";
3
+ export const styles = StyleSheet.create({
4
+ list: {
5
+ display: "flex",
6
+ flexDirection: "row",
7
+ flexWrap: "wrap",
8
+ maxHeight: (tokens["space-extravagant"] + tokens["space-smaller"]) * 2,
9
+ overflow: "hidden",
10
+ marginTop: tokens["space-smaller"],
11
+ },
12
+ maxDimensionsForThreeRows: {
13
+ maxHeight: (tokens["space-extravagant"] + tokens["space-smaller"]) * 3,
14
+ },
15
+ thumbnail: {
16
+ width: tokens["space-extravagant"],
17
+ height: tokens["space-extravagant"],
18
+ marginRight: tokens["space-smaller"],
19
+ marginBottom: tokens["space-smaller"],
20
+ borderRadius: tokens["radius-base"],
21
+ borderColor: tokens["color-border"],
22
+ borderWidth: tokens["border-base"],
23
+ },
24
+ centerThumbnailImage: {
25
+ display: "flex",
26
+ alignItems: "center",
27
+ justifyContent: "center",
28
+ },
29
+ dimensionsThumbnailImage: {
30
+ width: tokens["space-extravagant"],
31
+ height: tokens["space-extravagant"],
32
+ },
33
+ thumbnailName: {
34
+ position: "absolute",
35
+ right: 0,
36
+ bottom: 0,
37
+ left: 0,
38
+ paddingHorizontal: tokens["space-smaller"],
39
+ paddingVertical: tokens["space-smallest"],
40
+ borderTopColor: tokens["color-border"],
41
+ borderTopWidth: tokens["space-minuscule"],
42
+ },
43
+ thumbnailIcon: {
44
+ top: tokens["space-smaller"],
45
+ display: "flex",
46
+ alignItems: "center",
47
+ justifyContent: "center",
48
+ },
49
+ });
@@ -0,0 +1,2 @@
1
+ export { ThumbnailList } from "./ThumbnailList";
2
+ export * from "./types";
@@ -0,0 +1,5 @@
1
+ export var RowCount;
2
+ (function (RowCount) {
3
+ RowCount[RowCount["TwoRows"] = 2] = "TwoRows";
4
+ RowCount[RowCount["ThreeRows"] = 3] = "ThreeRows";
5
+ })(RowCount || (RowCount = {}));
package/dist/src/index.js CHANGED
@@ -34,6 +34,7 @@ export * from "./InputTime";
34
34
  export * from "./InputText";
35
35
  export * from "./Menu";
36
36
  export * from "./TextList";
37
+ export * from "./ThumbnailList";
37
38
  export * from "./ProgressBar";
38
39
  export * from "./Select";
39
40
  export * from "./StatusLabel";