@anker-in/ui 0.1.5 → 0.1.9
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/README.md +162 -37
- package/dist/DemoRoom-YZ2To7p9.d.mts +86 -0
- package/dist/DemoRoom-YZ2To7p9.d.ts +86 -0
- package/dist/demo-room.d.mts +18 -1
- package/dist/demo-room.d.ts +18 -1
- package/dist/demo-room.js +134 -122
- package/dist/demo-room.js.map +1 -1
- package/dist/demo-room.mjs +134 -122
- package/dist/demo-room.mjs.map +1 -1
- package/dist/index.d.mts +117 -3
- package/dist/index.d.ts +117 -3
- package/dist/index.js +404 -219
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +404 -219
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +0 -1
- package/package.json +1 -1
- package/dist/DemoRoom-CZyrsxWe.d.mts +0 -30
- package/dist/DemoRoom-CZyrsxWe.d.ts +0 -30
package/README.md
CHANGED
|
@@ -1,55 +1,187 @@
|
|
|
1
|
-
# @anker-
|
|
1
|
+
# @anker-in/ui
|
|
2
2
|
|
|
3
|
-
React UI components
|
|
3
|
+
React UI components library for demo room booking system with full TypeScript support.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 🎨 **Three Main Components**: DemoRoom, BookingForm, and BookingSuccess
|
|
8
|
+
- 🌍 **Multi-language Support**: Configurable text through pageData props
|
|
9
|
+
- 📱 **Responsive Design**: Works on desktop and mobile devices
|
|
10
|
+
- 🎯 **TypeScript**: Full type safety with TypeScript
|
|
11
|
+
- 🎨 **Tailwind CSS**: Styled with Tailwind CSS
|
|
12
|
+
- 🔧 **Customizable**: Easy to customize through props
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
## Installation
|
|
10
15
|
|
|
11
16
|
```bash
|
|
12
|
-
|
|
17
|
+
npm install @anker-in/ui
|
|
18
|
+
# or
|
|
19
|
+
pnpm add @anker-in/ui
|
|
20
|
+
# or
|
|
21
|
+
yarn add @anker-in/ui
|
|
13
22
|
```
|
|
14
23
|
|
|
15
|
-
###
|
|
24
|
+
### Required Dependencies
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
The package requires the following peer dependencies:
|
|
18
27
|
|
|
19
28
|
```bash
|
|
20
|
-
|
|
21
|
-
pnpm add antd antd-mobile swiper dayjs clsx tailwind-merge @anker-in/headless-ui
|
|
22
|
-
|
|
23
|
-
# Also install dom-helpers if you encounter Module not found errors
|
|
24
|
-
pnpm add dom-helpers
|
|
29
|
+
pnpm add react react-dom antd antd-mobile swiper dayjs clsx tailwind-merge
|
|
25
30
|
```
|
|
26
31
|
|
|
27
|
-
##
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### 1. Import Styles
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import '@anker-in/ui/styles.css'
|
|
38
|
+
```
|
|
28
39
|
|
|
29
|
-
###
|
|
40
|
+
### 2. Use Components
|
|
30
41
|
|
|
31
42
|
```tsx
|
|
32
|
-
import { DemoRoom } from '@anker-
|
|
33
|
-
import '@anker-
|
|
43
|
+
import { DemoRoom, BookingForm, BookingSuccess } from '@anker-in/ui'
|
|
44
|
+
import type { DemoRoomPageData, BookingFormPageData, BookingSuccessPageData } from '@anker-in/ui'
|
|
45
|
+
|
|
46
|
+
// Demo room list page
|
|
47
|
+
<DemoRoom
|
|
48
|
+
apiConfig={{
|
|
49
|
+
baseUrl: '/api/demoroom',
|
|
50
|
+
locale: 'en-US',
|
|
51
|
+
apiKey: 'your-api-key'
|
|
52
|
+
}}
|
|
53
|
+
teamCode='your-team-code'
|
|
54
|
+
onSchedule={(code) => {
|
|
55
|
+
window.location.href = `/book?code=${code}`
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
|
|
59
|
+
// Booking form page
|
|
60
|
+
<BookingForm
|
|
61
|
+
apiConfig={{
|
|
62
|
+
baseUrl: '/api/demoroom',
|
|
63
|
+
locale: 'en-US',
|
|
64
|
+
apiKey: 'your-api-key'
|
|
65
|
+
}}
|
|
66
|
+
demoRoomCode={code}
|
|
67
|
+
handleBookingSuccess={(token) => {
|
|
68
|
+
window.location.href = `/result?token=${token}`
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
// Booking success page
|
|
73
|
+
<BookingSuccess
|
|
74
|
+
apiConfig={{
|
|
75
|
+
baseUrl: '/api/demoroom',
|
|
76
|
+
locale: 'en-US',
|
|
77
|
+
apiKey: 'your-api-key'
|
|
78
|
+
}}
|
|
79
|
+
token={token}
|
|
80
|
+
onScheduleAgain={() => {
|
|
81
|
+
window.location.href = '/demoroom'
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
34
84
|
```
|
|
35
85
|
|
|
36
|
-
|
|
86
|
+
## Multi-language Support
|
|
87
|
+
|
|
88
|
+
All components support customizable text through the `pageData` prop:
|
|
37
89
|
|
|
38
|
-
|
|
90
|
+
```typescript
|
|
91
|
+
import type { DemoRoomPageData } from '@anker-in/ui/demo-room'
|
|
92
|
+
|
|
93
|
+
const pageData: DemoRoomPageData = {
|
|
94
|
+
title: '查找附近的展厅',
|
|
95
|
+
locationFilter: {
|
|
96
|
+
country: '国家',
|
|
97
|
+
state: '州/省',
|
|
98
|
+
city: '城市'
|
|
99
|
+
},
|
|
100
|
+
studioCard: {
|
|
101
|
+
scheduleNow: '立即预约',
|
|
102
|
+
available: '可预约时间'
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
<DemoRoom pageData={pageData} {...otherProps} />
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
See [PAGEDATA_COMPLETE_GUIDE.md](./PAGEDATA_COMPLETE_GUIDE.md) for complete configuration examples.
|
|
110
|
+
|
|
111
|
+
## Available Exports
|
|
112
|
+
|
|
113
|
+
### Components
|
|
114
|
+
|
|
115
|
+
- `DemoRoom` - Demo room list with map and location filtering
|
|
116
|
+
- `BookingForm` - Booking form with calendar and questionnaire
|
|
117
|
+
- `BookingSuccess` - Booking confirmation and cancellation
|
|
118
|
+
- `QuestionnaireForm` - Standalone questionnaire form
|
|
119
|
+
|
|
120
|
+
### Types
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
// From @anker-in/ui
|
|
124
|
+
export type {
|
|
125
|
+
BookingFormPageData,
|
|
126
|
+
BookingSuccessPageData,
|
|
127
|
+
BookingFormProps,
|
|
128
|
+
BookingSuccessProps,
|
|
129
|
+
QuestionnaireFormProps
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// From @anker-in/ui/demo-room
|
|
133
|
+
export type {
|
|
134
|
+
DemoRoomPageData,
|
|
135
|
+
DemoRoomProps
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### API Utilities
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { createDemoRoomApi } from '@anker-in/ui'
|
|
143
|
+
|
|
144
|
+
const apiClient = createDemoRoomApi({
|
|
145
|
+
baseUrl: 'https://api.example.com',
|
|
146
|
+
apiKey: 'your-api-key',
|
|
147
|
+
locale: 'en-US'
|
|
148
|
+
})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Next.js Configuration
|
|
152
|
+
|
|
153
|
+
Add the package to `transpilePackages` in `next.config.js`:
|
|
39
154
|
|
|
40
155
|
```javascript
|
|
41
156
|
module.exports = {
|
|
42
|
-
transpilePackages: ['@anker-
|
|
43
|
-
// ... other config
|
|
157
|
+
transpilePackages: ['@anker-in/ui'],
|
|
44
158
|
}
|
|
45
159
|
```
|
|
46
160
|
|
|
47
|
-
##
|
|
161
|
+
## Documentation
|
|
162
|
+
|
|
163
|
+
- [USAGE_EXAMPLE.md](./USAGE_EXAMPLE.md) - Complete usage examples and integration guide
|
|
164
|
+
- [PAGEDATA_COMPLETE_GUIDE.md](./PAGEDATA_COMPLETE_GUIDE.md) - Full pageData configuration reference
|
|
165
|
+
- [CHANGELOG_v0.1.6.md](./CHANGELOG_v0.1.6.md) - Latest version changes
|
|
166
|
+
|
|
167
|
+
## Component Structure
|
|
168
|
+
|
|
169
|
+
### DemoRoom Page
|
|
170
|
+
- Main component with room list and map
|
|
171
|
+
- Location filtering sidebar/modal
|
|
172
|
+
- Studio cards with distance and availability
|
|
173
|
+
- Google Maps integration
|
|
48
174
|
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
175
|
+
### BookingForm Page
|
|
176
|
+
- Demo room details display
|
|
177
|
+
- Calendar and time slot selection
|
|
178
|
+
- Questionnaire form with validation
|
|
179
|
+
- HTML support in agreement checkboxes
|
|
180
|
+
|
|
181
|
+
### BookingSuccess Page
|
|
182
|
+
- Booking confirmation details
|
|
183
|
+
- Cancellation functionality with confirmation dialog
|
|
184
|
+
- Google Maps integration
|
|
53
185
|
|
|
54
186
|
## Development
|
|
55
187
|
|
|
@@ -60,9 +192,6 @@ pnpm install
|
|
|
60
192
|
# Build the package
|
|
61
193
|
pnpm build
|
|
62
194
|
|
|
63
|
-
# Run tests
|
|
64
|
-
pnpm test
|
|
65
|
-
|
|
66
195
|
# Type check
|
|
67
196
|
pnpm type-check
|
|
68
197
|
|
|
@@ -70,14 +199,10 @@ pnpm type-check
|
|
|
70
199
|
pnpm lint
|
|
71
200
|
```
|
|
72
201
|
|
|
73
|
-
##
|
|
202
|
+
## Version
|
|
74
203
|
|
|
75
|
-
|
|
76
|
-
# In this package directory
|
|
77
|
-
pnpm link --global
|
|
204
|
+
Current version: **0.1.6**
|
|
78
205
|
|
|
79
|
-
|
|
80
|
-
pnpm link --global @anker-dtc/ui
|
|
206
|
+
## License
|
|
81
207
|
|
|
82
|
-
|
|
83
|
-
```
|
|
208
|
+
ISC
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* DemoRoom 页面的可配置数据类型
|
|
5
|
+
*/
|
|
6
|
+
interface DemoRoomPageData {
|
|
7
|
+
/**
|
|
8
|
+
* 页面标题
|
|
9
|
+
*/
|
|
10
|
+
title?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 加载状态文案
|
|
13
|
+
*/
|
|
14
|
+
loadingText?: string;
|
|
15
|
+
/**
|
|
16
|
+
* 加载失败文案
|
|
17
|
+
*/
|
|
18
|
+
errorTitle?: string;
|
|
19
|
+
machine?: string;
|
|
20
|
+
/**
|
|
21
|
+
* 位置筛选相关文案
|
|
22
|
+
*/
|
|
23
|
+
locationFilter?: {
|
|
24
|
+
allLocations?: string;
|
|
25
|
+
clear?: string;
|
|
26
|
+
country?: string;
|
|
27
|
+
state?: string;
|
|
28
|
+
city?: string;
|
|
29
|
+
noStudiosFound?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* 工作室卡片相关文案
|
|
33
|
+
*/
|
|
34
|
+
studioCard?: {
|
|
35
|
+
scheduleNow?: string;
|
|
36
|
+
available?: string;
|
|
37
|
+
away?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 地图相关文案
|
|
41
|
+
*/
|
|
42
|
+
map?: {
|
|
43
|
+
apiKeyRequired?: string;
|
|
44
|
+
loadingMap?: string;
|
|
45
|
+
scheduleNow?: string;
|
|
46
|
+
available?: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* 其他配置
|
|
50
|
+
*/
|
|
51
|
+
defaultCountry?: string;
|
|
52
|
+
noAvailableTime?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface DemoRoomProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
56
|
+
layoutClassName?: string;
|
|
57
|
+
/**
|
|
58
|
+
* 谷歌地图 API Key
|
|
59
|
+
*/
|
|
60
|
+
googleMapsApiKey?: string;
|
|
61
|
+
/**
|
|
62
|
+
* API 配置
|
|
63
|
+
*/
|
|
64
|
+
apiConfig: {
|
|
65
|
+
baseUrl: string;
|
|
66
|
+
apiKey: string;
|
|
67
|
+
locale?: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* 团队编码或品牌站点(二选一)
|
|
71
|
+
*/
|
|
72
|
+
teamCode?: string;
|
|
73
|
+
brandWebsite?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Callback when user clicks "Schedule Now" button
|
|
76
|
+
* @param demoRoomCode - The demo room code
|
|
77
|
+
*/
|
|
78
|
+
onSchedule?: (demoRoomCode: string) => void;
|
|
79
|
+
/**
|
|
80
|
+
* 页面可配置数据(文案、图标等)
|
|
81
|
+
*/
|
|
82
|
+
pageData?: DemoRoomPageData;
|
|
83
|
+
}
|
|
84
|
+
declare const DemoRoom: React.FC<DemoRoomProps>;
|
|
85
|
+
|
|
86
|
+
export { DemoRoom as D, type DemoRoomProps as a, type DemoRoomPageData as b };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* DemoRoom 页面的可配置数据类型
|
|
5
|
+
*/
|
|
6
|
+
interface DemoRoomPageData {
|
|
7
|
+
/**
|
|
8
|
+
* 页面标题
|
|
9
|
+
*/
|
|
10
|
+
title?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 加载状态文案
|
|
13
|
+
*/
|
|
14
|
+
loadingText?: string;
|
|
15
|
+
/**
|
|
16
|
+
* 加载失败文案
|
|
17
|
+
*/
|
|
18
|
+
errorTitle?: string;
|
|
19
|
+
machine?: string;
|
|
20
|
+
/**
|
|
21
|
+
* 位置筛选相关文案
|
|
22
|
+
*/
|
|
23
|
+
locationFilter?: {
|
|
24
|
+
allLocations?: string;
|
|
25
|
+
clear?: string;
|
|
26
|
+
country?: string;
|
|
27
|
+
state?: string;
|
|
28
|
+
city?: string;
|
|
29
|
+
noStudiosFound?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* 工作室卡片相关文案
|
|
33
|
+
*/
|
|
34
|
+
studioCard?: {
|
|
35
|
+
scheduleNow?: string;
|
|
36
|
+
available?: string;
|
|
37
|
+
away?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 地图相关文案
|
|
41
|
+
*/
|
|
42
|
+
map?: {
|
|
43
|
+
apiKeyRequired?: string;
|
|
44
|
+
loadingMap?: string;
|
|
45
|
+
scheduleNow?: string;
|
|
46
|
+
available?: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* 其他配置
|
|
50
|
+
*/
|
|
51
|
+
defaultCountry?: string;
|
|
52
|
+
noAvailableTime?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface DemoRoomProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
56
|
+
layoutClassName?: string;
|
|
57
|
+
/**
|
|
58
|
+
* 谷歌地图 API Key
|
|
59
|
+
*/
|
|
60
|
+
googleMapsApiKey?: string;
|
|
61
|
+
/**
|
|
62
|
+
* API 配置
|
|
63
|
+
*/
|
|
64
|
+
apiConfig: {
|
|
65
|
+
baseUrl: string;
|
|
66
|
+
apiKey: string;
|
|
67
|
+
locale?: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* 团队编码或品牌站点(二选一)
|
|
71
|
+
*/
|
|
72
|
+
teamCode?: string;
|
|
73
|
+
brandWebsite?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Callback when user clicks "Schedule Now" button
|
|
76
|
+
* @param demoRoomCode - The demo room code
|
|
77
|
+
*/
|
|
78
|
+
onSchedule?: (demoRoomCode: string) => void;
|
|
79
|
+
/**
|
|
80
|
+
* 页面可配置数据(文案、图标等)
|
|
81
|
+
*/
|
|
82
|
+
pageData?: DemoRoomPageData;
|
|
83
|
+
}
|
|
84
|
+
declare const DemoRoom: React.FC<DemoRoomProps>;
|
|
85
|
+
|
|
86
|
+
export { DemoRoom as D, type DemoRoomProps as a, type DemoRoomPageData as b };
|
package/dist/demo-room.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DemoRoom, a as DemoRoomProps } from './DemoRoom-
|
|
1
|
+
export { D as DemoRoom, b as DemoRoomPageData, a as DemoRoomProps } from './DemoRoom-YZ2To7p9.mjs';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
interface EventCardButton {
|
|
@@ -103,6 +103,15 @@ interface StudioMapProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
103
103
|
* 点击 Schedule Now 的回调
|
|
104
104
|
*/
|
|
105
105
|
onSchedule?: (demoRoomCode: string) => void;
|
|
106
|
+
/**
|
|
107
|
+
* 可配置的文案数据
|
|
108
|
+
*/
|
|
109
|
+
pageData?: {
|
|
110
|
+
apiKeyRequired?: string;
|
|
111
|
+
loadingMap?: string;
|
|
112
|
+
scheduleNow?: string;
|
|
113
|
+
available?: string;
|
|
114
|
+
};
|
|
106
115
|
}
|
|
107
116
|
declare const StudioMap: React.FC<StudioMapProps>;
|
|
108
117
|
|
|
@@ -139,6 +148,14 @@ interface StudioCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
139
148
|
* Callback when "Schedule Now" is clicked, receives demo room code
|
|
140
149
|
*/
|
|
141
150
|
onSchedule?: (code: string) => void;
|
|
151
|
+
/**
|
|
152
|
+
* 可配置的文案数据
|
|
153
|
+
*/
|
|
154
|
+
pageData?: {
|
|
155
|
+
scheduleNow?: string;
|
|
156
|
+
available?: string;
|
|
157
|
+
away?: string;
|
|
158
|
+
};
|
|
142
159
|
}
|
|
143
160
|
declare const StudioCard: React.FC<StudioCardProps>;
|
|
144
161
|
|
package/dist/demo-room.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DemoRoom, a as DemoRoomProps } from './DemoRoom-
|
|
1
|
+
export { D as DemoRoom, b as DemoRoomPageData, a as DemoRoomProps } from './DemoRoom-YZ2To7p9.js';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
interface EventCardButton {
|
|
@@ -103,6 +103,15 @@ interface StudioMapProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
103
103
|
* 点击 Schedule Now 的回调
|
|
104
104
|
*/
|
|
105
105
|
onSchedule?: (demoRoomCode: string) => void;
|
|
106
|
+
/**
|
|
107
|
+
* 可配置的文案数据
|
|
108
|
+
*/
|
|
109
|
+
pageData?: {
|
|
110
|
+
apiKeyRequired?: string;
|
|
111
|
+
loadingMap?: string;
|
|
112
|
+
scheduleNow?: string;
|
|
113
|
+
available?: string;
|
|
114
|
+
};
|
|
106
115
|
}
|
|
107
116
|
declare const StudioMap: React.FC<StudioMapProps>;
|
|
108
117
|
|
|
@@ -139,6 +148,14 @@ interface StudioCardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
139
148
|
* Callback when "Schedule Now" is clicked, receives demo room code
|
|
140
149
|
*/
|
|
141
150
|
onSchedule?: (code: string) => void;
|
|
151
|
+
/**
|
|
152
|
+
* 可配置的文案数据
|
|
153
|
+
*/
|
|
154
|
+
pageData?: {
|
|
155
|
+
scheduleNow?: string;
|
|
156
|
+
available?: string;
|
|
157
|
+
away?: string;
|
|
158
|
+
};
|
|
142
159
|
}
|
|
143
160
|
declare const StudioCard: React.FC<StudioCardProps>;
|
|
144
161
|
|