@idealyst/mcp-server 1.0.86 → 1.0.88
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/ARCHITECTURE.md +313 -0
- package/README.md +292 -104
- package/TYPE-SYSTEM.md +397 -0
- package/dist/index.js +170 -1
- package/examples/components/Accordion.examples.tsx +147 -0
- package/examples/components/ActivityIndicator.examples.tsx +350 -0
- package/examples/components/Alert.examples.tsx +335 -0
- package/examples/components/Avatar.examples.tsx +188 -0
- package/examples/components/Badge.examples.tsx +242 -0
- package/examples/components/Breadcrumb.examples.tsx +303 -0
- package/examples/components/Button.examples.tsx +113 -0
- package/examples/components/Card.examples.tsx +131 -0
- package/examples/components/Checkbox.examples.tsx +195 -0
- package/examples/components/Chip.examples.tsx +87 -0
- package/examples/components/Dialog.examples.tsx +344 -0
- package/examples/components/Divider.examples.tsx +258 -0
- package/examples/components/Icon.examples.tsx +202 -0
- package/examples/components/Input.examples.tsx +205 -0
- package/examples/components/Menu.examples.tsx +321 -0
- package/examples/components/Popover.examples.tsx +439 -0
- package/examples/components/Progress.examples.tsx +340 -0
- package/examples/components/RadioButton.examples.tsx +443 -0
- package/examples/components/Screen.examples.tsx +347 -0
- package/examples/components/Select.examples.tsx +279 -0
- package/examples/components/Skeleton.examples.tsx +278 -0
- package/examples/components/Slider.examples.tsx +249 -0
- package/examples/components/Switch.examples.tsx +94 -0
- package/examples/components/TabBar.examples.tsx +356 -0
- package/examples/components/Text.examples.tsx +177 -0
- package/examples/components/TextArea.examples.tsx +203 -0
- package/examples/components/Tooltip.examples.tsx +318 -0
- package/examples/components/View.examples.tsx +307 -0
- package/package.json +15 -2
- package/scripts/extract-types.ts +71 -0
- package/scripts/type-extractor.ts +286 -0
- package/scripts/validate-examples.ts +142 -0
- package/src/data/components/Icon.ts +1 -1
- package/src/data/components/index.ts +2 -0
- package/src/index.ts +181 -1
- package/src/tools/get-types.ts +169 -0
- package/tsconfig.examples.json +14 -0
- package/dist/data/cli-commands.d.ts +0 -2
- package/dist/data/cli-commands.d.ts.map +0 -1
- package/dist/data/cli-commands.js +0 -100
- package/dist/data/cli-commands.js.map +0 -1
- package/dist/data/components/Accordion.d.ts +0 -15
- package/dist/data/components/Accordion.d.ts.map +0 -1
- package/dist/data/components/Accordion.js +0 -112
- package/dist/data/components/Accordion.js.map +0 -1
- package/dist/data/components/ActivityIndicator.d.ts +0 -15
- package/dist/data/components/ActivityIndicator.d.ts.map +0 -1
- package/dist/data/components/ActivityIndicator.js +0 -82
- package/dist/data/components/ActivityIndicator.js.map +0 -1
- package/dist/data/components/Alert.d.ts +0 -15
- package/dist/data/components/Alert.d.ts.map +0 -1
- package/dist/data/components/Alert.js +0 -132
- package/dist/data/components/Alert.js.map +0 -1
- package/dist/data/components/Avatar.d.ts +0 -15
- package/dist/data/components/Avatar.d.ts.map +0 -1
- package/dist/data/components/Avatar.js +0 -93
- package/dist/data/components/Avatar.js.map +0 -1
- package/dist/data/components/Badge.d.ts +0 -15
- package/dist/data/components/Badge.d.ts.map +0 -1
- package/dist/data/components/Badge.js +0 -64
- package/dist/data/components/Badge.js.map +0 -1
- package/dist/data/components/Breadcrumb.d.ts +0 -15
- package/dist/data/components/Breadcrumb.d.ts.map +0 -1
- package/dist/data/components/Breadcrumb.js +0 -96
- package/dist/data/components/Breadcrumb.js.map +0 -1
- package/dist/data/components/Button.d.ts +0 -15
- package/dist/data/components/Button.d.ts.map +0 -1
- package/dist/data/components/Button.js +0 -87
- package/dist/data/components/Button.js.map +0 -1
- package/dist/data/components/Card.d.ts +0 -15
- package/dist/data/components/Card.d.ts.map +0 -1
- package/dist/data/components/Card.js +0 -67
- package/dist/data/components/Card.js.map +0 -1
- package/dist/data/components/Checkbox.d.ts +0 -15
- package/dist/data/components/Checkbox.d.ts.map +0 -1
- package/dist/data/components/Checkbox.js +0 -118
- package/dist/data/components/Checkbox.js.map +0 -1
- package/dist/data/components/Chip.d.ts +0 -15
- package/dist/data/components/Chip.d.ts.map +0 -1
- package/dist/data/components/Chip.js +0 -76
- package/dist/data/components/Chip.js.map +0 -1
- package/dist/data/components/Dialog.d.ts +0 -15
- package/dist/data/components/Dialog.d.ts.map +0 -1
- package/dist/data/components/Dialog.js +0 -137
- package/dist/data/components/Dialog.js.map +0 -1
- package/dist/data/components/Divider.d.ts +0 -15
- package/dist/data/components/Divider.d.ts.map +0 -1
- package/dist/data/components/Divider.js +0 -71
- package/dist/data/components/Divider.js.map +0 -1
- package/dist/data/components/Icon.d.ts +0 -15
- package/dist/data/components/Icon.d.ts.map +0 -1
- package/dist/data/components/Icon.js +0 -70
- package/dist/data/components/Icon.js.map +0 -1
- package/dist/data/components/Image.d.ts +0 -15
- package/dist/data/components/Image.d.ts.map +0 -1
- package/dist/data/components/Image.js +0 -122
- package/dist/data/components/Image.js.map +0 -1
- package/dist/data/components/Input.d.ts +0 -15
- package/dist/data/components/Input.d.ts.map +0 -1
- package/dist/data/components/Input.js +0 -109
- package/dist/data/components/Input.js.map +0 -1
- package/dist/data/components/List.d.ts +0 -15
- package/dist/data/components/List.d.ts.map +0 -1
- package/dist/data/components/List.js +0 -113
- package/dist/data/components/List.js.map +0 -1
- package/dist/data/components/Menu.d.ts +0 -15
- package/dist/data/components/Menu.d.ts.map +0 -1
- package/dist/data/components/Menu.js +0 -132
- package/dist/data/components/Menu.js.map +0 -1
- package/dist/data/components/Popover.d.ts +0 -15
- package/dist/data/components/Popover.d.ts.map +0 -1
- package/dist/data/components/Popover.js +0 -159
- package/dist/data/components/Popover.js.map +0 -1
- package/dist/data/components/Pressable.d.ts +0 -15
- package/dist/data/components/Pressable.d.ts.map +0 -1
- package/dist/data/components/Pressable.js +0 -125
- package/dist/data/components/Pressable.js.map +0 -1
- package/dist/data/components/Progress.d.ts +0 -15
- package/dist/data/components/Progress.d.ts.map +0 -1
- package/dist/data/components/Progress.js +0 -95
- package/dist/data/components/Progress.js.map +0 -1
- package/dist/data/components/RadioButton.d.ts +0 -15
- package/dist/data/components/RadioButton.d.ts.map +0 -1
- package/dist/data/components/RadioButton.js +0 -140
- package/dist/data/components/RadioButton.js.map +0 -1
- package/dist/data/components/SVGImage.d.ts +0 -15
- package/dist/data/components/SVGImage.d.ts.map +0 -1
- package/dist/data/components/SVGImage.js +0 -112
- package/dist/data/components/SVGImage.js.map +0 -1
- package/dist/data/components/Screen.d.ts +0 -15
- package/dist/data/components/Screen.d.ts.map +0 -1
- package/dist/data/components/Screen.js +0 -99
- package/dist/data/components/Screen.js.map +0 -1
- package/dist/data/components/Select.d.ts +0 -15
- package/dist/data/components/Select.d.ts.map +0 -1
- package/dist/data/components/Select.js +0 -146
- package/dist/data/components/Select.js.map +0 -1
- package/dist/data/components/Skeleton.d.ts +0 -15
- package/dist/data/components/Skeleton.d.ts.map +0 -1
- package/dist/data/components/Skeleton.js +0 -110
- package/dist/data/components/Skeleton.js.map +0 -1
- package/dist/data/components/Slider.d.ts +0 -15
- package/dist/data/components/Slider.d.ts.map +0 -1
- package/dist/data/components/Slider.js +0 -129
- package/dist/data/components/Slider.js.map +0 -1
- package/dist/data/components/Switch.d.ts +0 -15
- package/dist/data/components/Switch.d.ts.map +0 -1
- package/dist/data/components/Switch.js +0 -127
- package/dist/data/components/Switch.js.map +0 -1
- package/dist/data/components/TabBar.d.ts +0 -15
- package/dist/data/components/TabBar.d.ts.map +0 -1
- package/dist/data/components/TabBar.js +0 -145
- package/dist/data/components/TabBar.js.map +0 -1
- package/dist/data/components/Table.d.ts +0 -15
- package/dist/data/components/Table.d.ts.map +0 -1
- package/dist/data/components/Table.js +0 -151
- package/dist/data/components/Table.js.map +0 -1
- package/dist/data/components/Tabs.d.ts +0 -15
- package/dist/data/components/Tabs.d.ts.map +0 -1
- package/dist/data/components/Tabs.js +0 -150
- package/dist/data/components/Tabs.js.map +0 -1
- package/dist/data/components/Text.d.ts +0 -15
- package/dist/data/components/Text.d.ts.map +0 -1
- package/dist/data/components/Text.js +0 -85
- package/dist/data/components/Text.js.map +0 -1
- package/dist/data/components/TextArea.d.ts +0 -15
- package/dist/data/components/TextArea.d.ts.map +0 -1
- package/dist/data/components/TextArea.js +0 -155
- package/dist/data/components/TextArea.js.map +0 -1
- package/dist/data/components/Tooltip.d.ts +0 -15
- package/dist/data/components/Tooltip.d.ts.map +0 -1
- package/dist/data/components/Tooltip.js +0 -105
- package/dist/data/components/Tooltip.js.map +0 -1
- package/dist/data/components/Video.d.ts +0 -15
- package/dist/data/components/Video.d.ts.map +0 -1
- package/dist/data/components/Video.js +0 -168
- package/dist/data/components/Video.js.map +0 -1
- package/dist/data/components/View.d.ts +0 -15
- package/dist/data/components/View.d.ts.map +0 -1
- package/dist/data/components/View.js +0 -126
- package/dist/data/components/View.js.map +0 -1
- package/dist/data/components/index.d.ts +0 -37
- package/dist/data/components/index.d.ts.map +0 -1
- package/dist/data/components/index.js +0 -110
- package/dist/data/components/index.js.map +0 -1
- package/dist/data/framework-guides.d.ts +0 -2
- package/dist/data/framework-guides.d.ts.map +0 -1
- package/dist/data/framework-guides.js +0 -589
- package/dist/data/framework-guides.js.map +0 -1
- package/dist/data/icon-guide.d.ts +0 -2
- package/dist/data/icon-guide.d.ts.map +0 -1
- package/dist/data/icon-guide.js +0 -285
- package/dist/data/icon-guide.js.map +0 -1
- package/dist/data/icons.json +0 -7452
- package/dist/data/navigation-guides.d.ts +0 -2
- package/dist/data/navigation-guides.d.ts.map +0 -1
- package/dist/data/navigation-guides.js +0 -1196
- package/dist/data/navigation-guides.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accordion Component Examples
|
|
3
|
+
*
|
|
4
|
+
* These examples are type-checked against the actual AccordionProps interface
|
|
5
|
+
* to ensure accuracy and correctness.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { Accordion, Text } from '@idealyst/components';
|
|
10
|
+
import type { AccordionItem } from '@idealyst/components';
|
|
11
|
+
|
|
12
|
+
// Example 1: Basic Accordion
|
|
13
|
+
export function BasicAccordion() {
|
|
14
|
+
const items: AccordionItem[] = [
|
|
15
|
+
{
|
|
16
|
+
id: '1',
|
|
17
|
+
title: 'What is React?',
|
|
18
|
+
content: 'React is a JavaScript library for building user interfaces.',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: '2',
|
|
22
|
+
title: 'What is TypeScript?',
|
|
23
|
+
content: 'TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: '3',
|
|
27
|
+
title: 'What is Idealyst?',
|
|
28
|
+
content: 'Idealyst is a cross-platform component framework for React and React Native.',
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
return <Accordion items={items} />;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Example 2: Accordion Types
|
|
36
|
+
export function AccordionTypes() {
|
|
37
|
+
const items: AccordionItem[] = [
|
|
38
|
+
{
|
|
39
|
+
id: '1',
|
|
40
|
+
title: 'Item 1',
|
|
41
|
+
content: 'Content for item 1',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: '2',
|
|
45
|
+
title: 'Item 2',
|
|
46
|
+
content: 'Content for item 2',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<Accordion items={items} type="standard" />
|
|
53
|
+
<Accordion items={items} type="separated" />
|
|
54
|
+
<Accordion items={items} type="bordered" />
|
|
55
|
+
</>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Example 3: Accordion with Default Expanded Items
|
|
60
|
+
export function AccordionDefaultExpanded() {
|
|
61
|
+
const items: AccordionItem[] = [
|
|
62
|
+
{
|
|
63
|
+
id: '1',
|
|
64
|
+
title: 'Expanded by Default',
|
|
65
|
+
content: 'This item is expanded by default.',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: '2',
|
|
69
|
+
title: 'Collapsed by Default',
|
|
70
|
+
content: 'This item is collapsed by default.',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
return <Accordion items={items} defaultExpanded={['1']} />;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Example 4: Accordion Sizes
|
|
78
|
+
export function AccordionSizes() {
|
|
79
|
+
const items: AccordionItem[] = [
|
|
80
|
+
{
|
|
81
|
+
id: '1',
|
|
82
|
+
title: 'Item',
|
|
83
|
+
content: 'Content',
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<>
|
|
89
|
+
<Accordion items={items} size="xs" />
|
|
90
|
+
<Accordion items={items} size="sm" />
|
|
91
|
+
<Accordion items={items} size="md" />
|
|
92
|
+
<Accordion items={items} size="lg" />
|
|
93
|
+
<Accordion items={items} size="xl" />
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Example 5: Single Expand Mode
|
|
99
|
+
export function SingleExpandAccordion() {
|
|
100
|
+
const items: AccordionItem[] = [
|
|
101
|
+
{
|
|
102
|
+
id: '1',
|
|
103
|
+
title: 'Item 1',
|
|
104
|
+
content: 'Only one item can be expanded at a time.',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: '2',
|
|
108
|
+
title: 'Item 2',
|
|
109
|
+
content: 'Opening this will close others.',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: '3',
|
|
113
|
+
title: 'Item 3',
|
|
114
|
+
content: 'Single expand mode.',
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
return <Accordion items={items} allowMultiple={false} />;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Example 6: Accordion with Default Expanded
|
|
122
|
+
export function AccordionWithDefaultExpanded() {
|
|
123
|
+
const items: AccordionItem[] = [
|
|
124
|
+
{
|
|
125
|
+
id: '1',
|
|
126
|
+
title: 'Default Expanded Item',
|
|
127
|
+
content: 'This item starts expanded by default.',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: '2',
|
|
131
|
+
title: 'Collapsed Item',
|
|
132
|
+
content: 'This item starts collapsed.',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: '3',
|
|
136
|
+
title: 'Another Item',
|
|
137
|
+
content: 'This item also starts collapsed.',
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<Accordion
|
|
143
|
+
items={items}
|
|
144
|
+
defaultExpanded={['1']}
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActivityIndicator Component Examples
|
|
3
|
+
*
|
|
4
|
+
* These examples are type-checked against the actual ActivityIndicatorProps interface
|
|
5
|
+
* to ensure accuracy and correctness.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { ActivityIndicator, View, Text, Button } from '@idealyst/components';
|
|
10
|
+
|
|
11
|
+
// Example 1: Basic ActivityIndicator
|
|
12
|
+
export function BasicActivityIndicator() {
|
|
13
|
+
return (
|
|
14
|
+
<View spacing="md">
|
|
15
|
+
<ActivityIndicator />
|
|
16
|
+
<Text size="sm" >
|
|
17
|
+
Loading...
|
|
18
|
+
</Text>
|
|
19
|
+
</View>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Example 2: ActivityIndicator Sizes
|
|
24
|
+
export function ActivityIndicatorSizes() {
|
|
25
|
+
return (
|
|
26
|
+
<View spacing="md">
|
|
27
|
+
<View spacing="sm">
|
|
28
|
+
<ActivityIndicator size="xs" />
|
|
29
|
+
<Text size="sm">Extra Small</Text>
|
|
30
|
+
</View>
|
|
31
|
+
<View spacing="sm">
|
|
32
|
+
<ActivityIndicator size="sm" />
|
|
33
|
+
<Text size="sm">Small</Text>
|
|
34
|
+
</View>
|
|
35
|
+
<View spacing="sm">
|
|
36
|
+
<ActivityIndicator size="md" />
|
|
37
|
+
<Text size="sm">Medium</Text>
|
|
38
|
+
</View>
|
|
39
|
+
<View spacing="sm">
|
|
40
|
+
<ActivityIndicator size="lg" />
|
|
41
|
+
<Text size="sm">Large</Text>
|
|
42
|
+
</View>
|
|
43
|
+
<View spacing="sm">
|
|
44
|
+
<ActivityIndicator size="xl" />
|
|
45
|
+
<Text size="sm">Extra Large</Text>
|
|
46
|
+
</View>
|
|
47
|
+
</View>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Example 3: ActivityIndicator with Intent Colors
|
|
52
|
+
export function ActivityIndicatorWithIntent() {
|
|
53
|
+
return (
|
|
54
|
+
<View spacing="md">
|
|
55
|
+
<View spacing="sm">
|
|
56
|
+
<ActivityIndicator intent="primary" />
|
|
57
|
+
<Text size="sm">Primary</Text>
|
|
58
|
+
</View>
|
|
59
|
+
<View spacing="sm">
|
|
60
|
+
<ActivityIndicator intent="success" />
|
|
61
|
+
<Text size="sm">Success</Text>
|
|
62
|
+
</View>
|
|
63
|
+
<View spacing="sm">
|
|
64
|
+
<ActivityIndicator intent="error" />
|
|
65
|
+
<Text size="sm">Error</Text>
|
|
66
|
+
</View>
|
|
67
|
+
<View spacing="sm">
|
|
68
|
+
<ActivityIndicator intent="warning" />
|
|
69
|
+
<Text size="sm">Warning</Text>
|
|
70
|
+
</View>
|
|
71
|
+
<View spacing="sm">
|
|
72
|
+
<ActivityIndicator intent="info" />
|
|
73
|
+
<Text size="sm">Info</Text>
|
|
74
|
+
</View>
|
|
75
|
+
<View spacing="sm">
|
|
76
|
+
<ActivityIndicator intent="neutral" />
|
|
77
|
+
<Text size="sm">Neutral</Text>
|
|
78
|
+
</View>
|
|
79
|
+
</View>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Example 4: ActivityIndicator with Custom Color
|
|
84
|
+
export function ActivityIndicatorWithCustomColor() {
|
|
85
|
+
return (
|
|
86
|
+
<View spacing="md">
|
|
87
|
+
<ActivityIndicator color="blue" size="lg" />
|
|
88
|
+
<ActivityIndicator color="green" size="lg" />
|
|
89
|
+
<ActivityIndicator color="red" size="lg" />
|
|
90
|
+
<ActivityIndicator color="purple" size="lg" />
|
|
91
|
+
</View>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Example 5: Animating Control
|
|
96
|
+
export function ActivityIndicatorAnimating() {
|
|
97
|
+
const [animating, setAnimating] = React.useState(true);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<View spacing="md">
|
|
101
|
+
<ActivityIndicator animating={animating} size="lg" />
|
|
102
|
+
<Button onPress={() => setAnimating(!animating)}>
|
|
103
|
+
{animating ? 'Stop' : 'Start'} Animation
|
|
104
|
+
</Button>
|
|
105
|
+
</View>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Example 6: ActivityIndicator with Text
|
|
110
|
+
export function ActivityIndicatorWithText() {
|
|
111
|
+
return (
|
|
112
|
+
<View spacing="md">
|
|
113
|
+
<View spacing="sm">
|
|
114
|
+
<ActivityIndicator size="md" intent="primary" />
|
|
115
|
+
<Text>Loading data...</Text>
|
|
116
|
+
</View>
|
|
117
|
+
</View>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Example 7: Loading Button State
|
|
122
|
+
export function LoadingButtonState() {
|
|
123
|
+
const [loading, setLoading] = React.useState(false);
|
|
124
|
+
|
|
125
|
+
const handleClick = () => {
|
|
126
|
+
setLoading(true);
|
|
127
|
+
setTimeout(() => {
|
|
128
|
+
setLoading(false);
|
|
129
|
+
}, 3000);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<View spacing="md">
|
|
134
|
+
<Button onPress={handleClick} disabled={loading}>
|
|
135
|
+
{loading ? (
|
|
136
|
+
<View spacing="sm">
|
|
137
|
+
<ActivityIndicator size="sm" />
|
|
138
|
+
<Text >Loading...</Text>
|
|
139
|
+
</View>
|
|
140
|
+
) : (
|
|
141
|
+
'Submit'
|
|
142
|
+
)}
|
|
143
|
+
</Button>
|
|
144
|
+
</View>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Example 8: Loading Card
|
|
149
|
+
export function LoadingCard() {
|
|
150
|
+
const [loading, setLoading] = React.useState(true);
|
|
151
|
+
|
|
152
|
+
React.useEffect(() => {
|
|
153
|
+
const timer = setTimeout(() => {
|
|
154
|
+
setLoading(false);
|
|
155
|
+
}, 3000);
|
|
156
|
+
|
|
157
|
+
return () => clearTimeout(timer);
|
|
158
|
+
}, []);
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<View background="primary" spacing="lg" radius="lg">
|
|
162
|
+
{loading ? (
|
|
163
|
+
<View spacing="md">
|
|
164
|
+
<ActivityIndicator size="lg" />
|
|
165
|
+
<Text align="center">Loading content...</Text>
|
|
166
|
+
</View>
|
|
167
|
+
) : (
|
|
168
|
+
<View spacing="md">
|
|
169
|
+
<Text size="lg" weight="bold">
|
|
170
|
+
Content Loaded
|
|
171
|
+
</Text>
|
|
172
|
+
<Text>Here is the content that was loaded.</Text>
|
|
173
|
+
</View>
|
|
174
|
+
)}
|
|
175
|
+
</View>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Example 9: Full Screen Loading
|
|
180
|
+
export function FullScreenLoading() {
|
|
181
|
+
const [loading, setLoading] = React.useState(false);
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<View spacing="md">
|
|
185
|
+
<Button onPress={() => setLoading(true)}>Show Loading Screen</Button>
|
|
186
|
+
{loading && (
|
|
187
|
+
<View
|
|
188
|
+
style={{
|
|
189
|
+
position: 'absolute',
|
|
190
|
+
top: 0,
|
|
191
|
+
left: 0,
|
|
192
|
+
right: 0,
|
|
193
|
+
bottom: 0,
|
|
194
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
195
|
+
justifyContent: 'center',
|
|
196
|
+
alignItems: 'center',
|
|
197
|
+
}}
|
|
198
|
+
>
|
|
199
|
+
<View spacing="md" background="primary" radius="lg">
|
|
200
|
+
<ActivityIndicator size="xl" intent="primary" />
|
|
201
|
+
<Text weight="semibold">Loading...</Text>
|
|
202
|
+
<Button size="sm" onPress={() => setLoading(false)}>
|
|
203
|
+
Cancel
|
|
204
|
+
</Button>
|
|
205
|
+
</View>
|
|
206
|
+
</View>
|
|
207
|
+
)}
|
|
208
|
+
</View>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Example 10: Inline Loading States
|
|
213
|
+
export function InlineLoadingStates() {
|
|
214
|
+
return (
|
|
215
|
+
<View spacing="lg">
|
|
216
|
+
<View spacing="sm">
|
|
217
|
+
<View spacing="xs">
|
|
218
|
+
<ActivityIndicator size="xs" />
|
|
219
|
+
<Text size="sm">Saving changes...</Text>
|
|
220
|
+
</View>
|
|
221
|
+
</View>
|
|
222
|
+
<View spacing="sm">
|
|
223
|
+
<View spacing="xs">
|
|
224
|
+
<ActivityIndicator size="xs" intent="success" />
|
|
225
|
+
<Text size="sm">Syncing data...</Text>
|
|
226
|
+
</View>
|
|
227
|
+
</View>
|
|
228
|
+
<View spacing="sm">
|
|
229
|
+
<View spacing="xs">
|
|
230
|
+
<ActivityIndicator size="xs" intent="info" />
|
|
231
|
+
<Text size="sm">Processing request...</Text>
|
|
232
|
+
</View>
|
|
233
|
+
</View>
|
|
234
|
+
</View>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Example 11: Fetching Data Example
|
|
239
|
+
export function FetchingDataExample() {
|
|
240
|
+
const [loading, setLoading] = React.useState(false);
|
|
241
|
+
const [data, setData] = React.useState<string[]>([]);
|
|
242
|
+
|
|
243
|
+
const fetchData = () => {
|
|
244
|
+
setLoading(true);
|
|
245
|
+
setData([]);
|
|
246
|
+
|
|
247
|
+
setTimeout(() => {
|
|
248
|
+
setData(['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5']);
|
|
249
|
+
setLoading(false);
|
|
250
|
+
}, 2000);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<View spacing="lg">
|
|
255
|
+
<Button onPress={fetchData} disabled={loading}>
|
|
256
|
+
Fetch Data
|
|
257
|
+
</Button>
|
|
258
|
+
{loading ? (
|
|
259
|
+
<View spacing="md">
|
|
260
|
+
<ActivityIndicator size="lg" intent="primary" />
|
|
261
|
+
<Text align="center">Fetching data...</Text>
|
|
262
|
+
</View>
|
|
263
|
+
) : data.length > 0 ? (
|
|
264
|
+
<View spacing="sm">
|
|
265
|
+
{data.map((item, index) => (
|
|
266
|
+
<View key={index} background="primary" spacing="md" radius="md">
|
|
267
|
+
<Text>{item}</Text>
|
|
268
|
+
</View>
|
|
269
|
+
))}
|
|
270
|
+
</View>
|
|
271
|
+
) : (
|
|
272
|
+
<Text size="sm" align="center">
|
|
273
|
+
Click the button to fetch data
|
|
274
|
+
</Text>
|
|
275
|
+
)}
|
|
276
|
+
</View>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Example 12: Uploading Files Example
|
|
281
|
+
export function UploadingFilesExample() {
|
|
282
|
+
const [uploading, setUploading] = React.useState(false);
|
|
283
|
+
const [success, setSuccess] = React.useState(false);
|
|
284
|
+
|
|
285
|
+
const handleUpload = () => {
|
|
286
|
+
setUploading(true);
|
|
287
|
+
setSuccess(false);
|
|
288
|
+
|
|
289
|
+
setTimeout(() => {
|
|
290
|
+
setUploading(false);
|
|
291
|
+
setSuccess(true);
|
|
292
|
+
}, 3000);
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
<View spacing="md">
|
|
297
|
+
<Button onPress={handleUpload} disabled={uploading} intent="primary">
|
|
298
|
+
Upload Files
|
|
299
|
+
</Button>
|
|
300
|
+
{uploading && (
|
|
301
|
+
<View spacing="sm">
|
|
302
|
+
<ActivityIndicator size="md" intent="primary" />
|
|
303
|
+
<Text size="sm" >
|
|
304
|
+
Uploading files...
|
|
305
|
+
</Text>
|
|
306
|
+
</View>
|
|
307
|
+
)}
|
|
308
|
+
{success && !uploading && (
|
|
309
|
+
<Text size="sm" >
|
|
310
|
+
Files uploaded successfully!
|
|
311
|
+
</Text>
|
|
312
|
+
)}
|
|
313
|
+
</View>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Example 13: Refresh Control
|
|
318
|
+
export function RefreshControl() {
|
|
319
|
+
const [refreshing, setRefreshing] = React.useState(false);
|
|
320
|
+
const [lastUpdated, setLastUpdated] = React.useState<Date>(new Date());
|
|
321
|
+
|
|
322
|
+
const handleRefresh = () => {
|
|
323
|
+
setRefreshing(true);
|
|
324
|
+
|
|
325
|
+
setTimeout(() => {
|
|
326
|
+
setLastUpdated(new Date());
|
|
327
|
+
setRefreshing(false);
|
|
328
|
+
}, 2000);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
return (
|
|
332
|
+
<View spacing="md">
|
|
333
|
+
<View spacing="sm">
|
|
334
|
+
<Text weight="semibold">Content Area</Text>
|
|
335
|
+
<Text size="sm" >
|
|
336
|
+
Last updated: {lastUpdated.toLocaleTimeString()}
|
|
337
|
+
</Text>
|
|
338
|
+
</View>
|
|
339
|
+
{refreshing && (
|
|
340
|
+
<View spacing="sm">
|
|
341
|
+
<ActivityIndicator size="sm" intent="primary" />
|
|
342
|
+
<Text size="sm">Refreshing...</Text>
|
|
343
|
+
</View>
|
|
344
|
+
)}
|
|
345
|
+
<Button size="sm" onPress={handleRefresh} disabled={refreshing}>
|
|
346
|
+
Refresh
|
|
347
|
+
</Button>
|
|
348
|
+
</View>
|
|
349
|
+
);
|
|
350
|
+
}
|