@smart_links/apps 2.0.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.
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { type SmartLinksAppsStrings, type SmartLinksScreenProps } from '@smart_links/core';
3
+ type AppItem = {
4
+ id?: number;
5
+ name?: string;
6
+ icon_url?: string;
7
+ store_url?: string;
8
+ };
9
+ export type AppsScreenProps = SmartLinksScreenProps & {
10
+ strings?: Partial<SmartLinksAppsStrings>;
11
+ renderItem?: (item: AppItem, openStore: () => void) => React.ReactElement | null;
12
+ ListEmptyComponent?: React.ReactElement | null;
13
+ LoadingComponent?: React.ReactElement | null;
14
+ onAppPress?: (item: AppItem) => void;
15
+ };
16
+ export declare function AppsScreen({ style, contentContainerStyle, testID, safeAreaEdges, strings: stringOverrides, renderItem, ListEmptyComponent, LoadingComponent, onAppPress, }?: AppsScreenProps): React.JSX.Element;
17
+ export { AppsScreen as SmartLinksAppsScreen };
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAU5D,OAAO,EAML,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAE3B,KAAK,OAAO,GAAG;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,qBAAqB,GAAG;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACzC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,KAAK,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IACjF,kBAAkB,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IAC/C,gBAAgB,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IAC7C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACtC,CAAC;AAEF,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,qBAAqB,EACrB,MAAM,EACN,aAAiC,EACjC,OAAO,EAAE,eAAe,EACxB,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,GACX,GAAE,eAAoB,qBAgEtB;AAED,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useState } from 'react';
3
+ import { ActivityIndicator, FlatList, Image, Linking, Pressable, Text, View, } from 'react-native';
4
+ import { SmartLinksApi, SmartLinksCore, SmartLinksSafeArea, createThemedStyles, getSmartLinksCustomization, } from '@smart_links/core';
5
+ export function AppsScreen({ style, contentContainerStyle, testID, safeAreaEdges = ['top', 'bottom'], strings: stringOverrides, renderItem, ListEmptyComponent, LoadingComponent, onAppPress, } = {}) {
6
+ const { theme, locale } = getSmartLinksCustomization();
7
+ const styles = useMemo(() => createThemedStyles(theme), [theme]);
8
+ const strings = { ...locale.apps, ...stringOverrides };
9
+ const [apps, setApps] = useState([]);
10
+ const [loading, setLoading] = useState(true);
11
+ useEffect(() => {
12
+ SmartLinksCore.requireInitialized();
13
+ SmartLinksApi.fetchApps()
14
+ .then((data) => setApps(data))
15
+ .finally(() => setLoading(false));
16
+ }, []);
17
+ if (loading) {
18
+ return (_jsx(SmartLinksSafeArea, { style: style, edges: safeAreaEdges, children: LoadingComponent ?? (_jsx(View, { style: styles.center, testID: testID, children: _jsx(ActivityIndicator, { color: theme.colors.primary }) })) }));
19
+ }
20
+ return (_jsx(SmartLinksSafeArea, { style: style, edges: safeAreaEdges, children: _jsx(FlatList, { contentContainerStyle: [styles.screen, contentContainerStyle], testID: testID, data: apps, keyExtractor: (item, index) => String(item.id ?? index), renderItem: ({ item }) => {
21
+ const openStore = () => {
22
+ onAppPress?.(item);
23
+ if (item.store_url)
24
+ void Linking.openURL(item.store_url);
25
+ };
26
+ if (renderItem)
27
+ return renderItem(item, openStore);
28
+ return (_jsxs(Pressable, { style: styles.row, onPress: openStore, children: [item.icon_url ? (_jsx(Image, { source: { uri: item.icon_url }, style: { width: 48, height: 48, borderRadius: theme.radii.md } })) : (_jsx(View, { style: {
29
+ width: 48,
30
+ height: 48,
31
+ borderRadius: theme.radii.md,
32
+ backgroundColor: theme.colors.border,
33
+ } })), _jsx(Text, { style: [styles.body, { fontWeight: '600' }], children: item.name ?? strings.defaultAppName })] }));
34
+ }, ListEmptyComponent: ListEmptyComponent ?? _jsx(Text, { style: styles.empty, children: strings.empty }) }) }));
35
+ }
36
+ export { AppsScreen as SmartLinksAppsScreen };
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,KAAK,EACL,OAAO,EACP,SAAS,EACT,IAAI,EACJ,IAAI,GACL,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,GAG3B,MAAM,mBAAmB,CAAC;AAiB3B,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,qBAAqB,EACrB,MAAM,EACN,aAAa,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,EACjC,OAAO,EAAE,eAAe,EACxB,UAAU,EACV,kBAAkB,E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,CAAC,EACD,kBAAkB,EAChB,kBAAkB,IAAI,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,KAAK,YAAG,OAAO,CAAC,KAAK,GAAQ,GAEvE,GACiB,CACtB,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@smart_links/apps",
3
+ "version": "2.0.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://gitlab.com/elmansoryanas/smartlinks-react-native.git",
15
+ "directory": "packages/apps"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc -p tsconfig.json",
19
+ "typecheck": "tsc -p tsconfig.json --noEmit",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "dependencies": {
23
+ "@smart_links/core": "2.0.0"
24
+ },
25
+ "peerDependencies": {
26
+ "react": "*",
27
+ "react-native": "*"
28
+ },
29
+ "devDependencies": {
30
+ "@types/react": "^18.3.18",
31
+ "typescript": "^5.7.3"
32
+ },
33
+ "license": "Apache-2.0"
34
+ }