@idealyst/components 1.2.11 → 1.2.12

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/components",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "description": "Shared component library for React and React Native",
5
5
  "documentation": "https://github.com/IdealystIO/idealyst-framework/tree/main/packages/components#readme",
6
6
  "readme": "README.md",
@@ -56,7 +56,7 @@
56
56
  "publish:npm": "npm publish"
57
57
  },
58
58
  "peerDependencies": {
59
- "@idealyst/theme": "^1.2.11",
59
+ "@idealyst/theme": "^1.2.12",
60
60
  "@mdi/js": ">=7.0.0",
61
61
  "@mdi/react": ">=1.0.0",
62
62
  "@react-native-vector-icons/common": ">=12.0.0",
@@ -106,7 +106,7 @@
106
106
  }
107
107
  },
108
108
  "devDependencies": {
109
- "@idealyst/theme": "^1.2.11",
109
+ "@idealyst/theme": "^1.2.12",
110
110
  "@idealyst/tooling": "^1.2.4",
111
111
  "@mdi/react": "^1.6.1",
112
112
  "@types/react": "^19.1.0",
@@ -0,0 +1,35 @@
1
+ import { Platform as RNPlatform } from 'react-native';
2
+ import type { PlatformAPI, PlatformSelectSpec, PlatformSystem } from './types';
3
+
4
+ const system: PlatformSystem = RNPlatform.OS === 'ios' ? 'ios' : 'android';
5
+
6
+ /**
7
+ * Platform utility for React Native (iOS and Android)
8
+ */
9
+ const Platform: PlatformAPI = {
10
+ system,
11
+ isWeb: false,
12
+ isNative: true,
13
+ isIOS: RNPlatform.OS === 'ios',
14
+ isAndroid: RNPlatform.OS === 'android',
15
+
16
+ select<T>(spec: PlatformSelectSpec<T>): T | undefined {
17
+ // First check for specific platform
18
+ if (system === 'ios' && spec.ios !== undefined) {
19
+ return spec.ios;
20
+ }
21
+ if (system === 'android' && spec.android !== undefined) {
22
+ return spec.android;
23
+ }
24
+
25
+ // Then check for native fallback
26
+ if (spec.native !== undefined) {
27
+ return spec.native;
28
+ }
29
+
30
+ // Finally check for default
31
+ return spec.default;
32
+ },
33
+ };
34
+
35
+ export default Platform;
@@ -0,0 +1,21 @@
1
+ import type { PlatformAPI, PlatformSelectSpec, PlatformSystem } from './types';
2
+
3
+ /**
4
+ * Platform utility for web
5
+ */
6
+ const Platform: PlatformAPI = {
7
+ system: 'web' as PlatformSystem,
8
+ isWeb: true,
9
+ isNative: false,
10
+ isIOS: false,
11
+ isAndroid: false,
12
+
13
+ select<T>(spec: PlatformSelectSpec<T>): T | undefined {
14
+ if (spec.web !== undefined) {
15
+ return spec.web;
16
+ }
17
+ return spec.default;
18
+ },
19
+ };
20
+
21
+ export default Platform;
@@ -0,0 +1,2 @@
1
+ export { default } from './Platform.native';
2
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ export { default } from './Platform.web';
2
+ export * from './types';
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Platform system types
3
+ */
4
+ export type PlatformSystem = 'web' | 'ios' | 'android';
5
+
6
+ /**
7
+ * Platform select specification
8
+ * Allows selecting a value based on the current platform
9
+ */
10
+ export type PlatformSelectSpec<T> = {
11
+ web?: T;
12
+ ios?: T;
13
+ android?: T;
14
+ native?: T; // Fallback for ios and android
15
+ default?: T; // Fallback for any platform
16
+ };
17
+
18
+ /**
19
+ * Platform API interface
20
+ */
21
+ export interface PlatformAPI {
22
+ /**
23
+ * The current platform system: 'web', 'ios', or 'android'
24
+ */
25
+ system: PlatformSystem;
26
+
27
+ /**
28
+ * Whether the current platform is web
29
+ */
30
+ isWeb: boolean;
31
+
32
+ /**
33
+ * Whether the current platform is native (ios or android)
34
+ */
35
+ isNative: boolean;
36
+
37
+ /**
38
+ * Whether the current platform is iOS
39
+ */
40
+ isIOS: boolean;
41
+
42
+ /**
43
+ * Whether the current platform is Android
44
+ */
45
+ isAndroid: boolean;
46
+
47
+ /**
48
+ * Select a value based on the current platform
49
+ *
50
+ * @example
51
+ * const padding = Platform.select({
52
+ * web: 20,
53
+ * ios: 16,
54
+ * android: 14,
55
+ * default: 12,
56
+ * });
57
+ *
58
+ * @example
59
+ * const fontFamily = Platform.select({
60
+ * web: 'Inter',
61
+ * native: 'System',
62
+ * });
63
+ */
64
+ select<T>(spec: PlatformSelectSpec<T>): T | undefined;
65
+ }
@@ -101,8 +101,11 @@ export * from './Chip/types';
101
101
  export { default as Breadcrumb } from './Breadcrumb';
102
102
  export * from './Breadcrumb/types';
103
103
 
104
- export { default as Link } from './Link';
105
- export * from './Link/types';
104
+ export { default as Link } from './Link';
105
+ export * from './Link/types';
106
+
107
+ export { default as Platform } from './Platform';
108
+ export * from './Platform/types';
106
109
 
107
110
  export type { ButtonProps } from './Button/types';
108
111
  export type { TextProps } from './Text/types';
@@ -137,6 +140,7 @@ export type { SkeletonProps, SkeletonGroupProps, SkeletonShape, SkeletonAnimatio
137
140
  export type { ChipProps, ChipSize, ChipIntent } from './Chip/types';
138
141
  export type { BreadcrumbProps, BreadcrumbItem } from './Breadcrumb/types';
139
142
  export type { LinkProps } from './Link/types';
143
+ export type { PlatformAPI, PlatformSystem, PlatformSelectSpec } from './Platform/types';
140
144
 
141
145
  // Event utilities
142
146
  export * from './utils/events';
package/src/index.ts CHANGED
@@ -109,6 +109,9 @@ export * from './Chip/types';
109
109
  export { default as Breadcrumb } from './Breadcrumb';
110
110
  export * from './Breadcrumb/types';
111
111
 
112
+ export { default as Platform } from './Platform';
113
+ export * from './Platform/types';
114
+
112
115
  export type { ButtonProps } from './Button/types';
113
116
  export type { TextProps } from './Text/types';
114
117
  export type { ViewProps } from './View/types';
@@ -142,6 +145,7 @@ export type { AlertProps } from './Alert/types';
142
145
  export type { SkeletonProps, SkeletonGroupProps, SkeletonShape, SkeletonAnimation } from './Skeleton/types';
143
146
  export type { ChipProps, ChipSize, ChipIntent } from './Chip/types';
144
147
  export type { BreadcrumbProps, BreadcrumbItem } from './Breadcrumb/types';
148
+ export type { PlatformAPI, PlatformSystem, PlatformSelectSpec } from './Platform/types';
145
149
 
146
150
  export { useMergeRefs };
147
151